mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 20:14:30 +00:00
chore: Run pnpm format:fix.
This commit is contained in:
@@ -14,7 +14,10 @@ import {
|
||||
} from "./timers.js";
|
||||
import { endCall } from "./outbound.js";
|
||||
|
||||
function shouldAcceptInbound(config: CallManagerContext["config"], from: string | undefined): boolean {
|
||||
function shouldAcceptInbound(
|
||||
config: CallManagerContext["config"],
|
||||
from: string | undefined,
|
||||
): boolean {
|
||||
const { inboundPolicy: policy, allowFrom } = config;
|
||||
|
||||
switch (policy) {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import crypto from "node:crypto";
|
||||
|
||||
import { TerminalStates, type CallId, type CallRecord, type OutboundCallOptions } from "../types.js";
|
||||
import {
|
||||
TerminalStates,
|
||||
type CallId,
|
||||
type CallRecord,
|
||||
type OutboundCallOptions,
|
||||
} from "../types.js";
|
||||
import type { CallMode } from "../config.js";
|
||||
import { mapVoiceToPolly } from "../voice-mapping.js";
|
||||
import type { CallManagerContext } from "./context.js";
|
||||
@@ -8,7 +13,12 @@ import { getCallByProviderCallId } from "./lookup.js";
|
||||
import { generateNotifyTwiml } from "./twiml.js";
|
||||
import { addTranscriptEntry, transitionState } from "./state.js";
|
||||
import { persistCallRecord } from "./store.js";
|
||||
import { clearMaxDurationTimer, clearTranscriptWaiter, rejectTranscriptWaiter, waitForFinalTranscript } from "./timers.js";
|
||||
import {
|
||||
clearMaxDurationTimer,
|
||||
clearTranscriptWaiter,
|
||||
rejectTranscriptWaiter,
|
||||
waitForFinalTranscript,
|
||||
} from "./timers.js";
|
||||
|
||||
export async function initiateCall(
|
||||
ctx: CallManagerContext,
|
||||
@@ -38,8 +48,7 @@ export async function initiateCall(
|
||||
|
||||
const callId = crypto.randomUUID();
|
||||
const from =
|
||||
ctx.config.fromNumber ||
|
||||
(ctx.provider?.name === "mock" ? "+15550000000" : undefined);
|
||||
ctx.config.fromNumber || (ctx.provider?.name === "mock" ? "+15550000000" : undefined);
|
||||
if (!from) {
|
||||
return { callId: "", success: false, error: "fromNumber not configured" };
|
||||
}
|
||||
@@ -120,8 +129,7 @@ export async function speak(
|
||||
|
||||
addTranscriptEntry(call, "bot", text);
|
||||
|
||||
const voice =
|
||||
ctx.provider?.name === "twilio" ? ctx.config.tts?.openai?.voice : undefined;
|
||||
const voice = ctx.provider?.name === "twilio" ? ctx.config.tts?.openai?.voice : undefined;
|
||||
await ctx.provider.playTts({
|
||||
callId,
|
||||
providerCallId: call.providerCallId,
|
||||
|
||||
@@ -35,11 +35,7 @@ export function transitionState(call: CallRecord, newState: CallState): void {
|
||||
}
|
||||
}
|
||||
|
||||
export function addTranscriptEntry(
|
||||
call: CallRecord,
|
||||
speaker: "bot" | "user",
|
||||
text: string,
|
||||
): void {
|
||||
export function addTranscriptEntry(call: CallRecord, speaker: "bot" | "user", text: string): void {
|
||||
const entry: TranscriptEntry = {
|
||||
timestamp: Date.now(),
|
||||
speaker,
|
||||
|
||||
@@ -67,10 +67,7 @@ export function resolveTranscriptWaiter(
|
||||
waiter.resolve(transcript);
|
||||
}
|
||||
|
||||
export function waitForFinalTranscript(
|
||||
ctx: CallManagerContext,
|
||||
callId: CallId,
|
||||
): Promise<string> {
|
||||
export function waitForFinalTranscript(ctx: CallManagerContext, callId: CallId): Promise<string> {
|
||||
// Only allow one in-flight waiter per call.
|
||||
rejectTranscriptWaiter(ctx, callId, "Transcript waiter replaced");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user