@pyai/sdk 0.17.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENT_GUIDE.md +4 -4
- package/CLI.md +24 -4
- package/CLI.schema.json +2 -1
- package/README.md +3 -3
- package/dist/cli-dx.js +3 -1
- package/dist/cli-init.js +4 -3
- package/dist/cli-omni-template.d.ts +2 -2
- package/dist/cli-omni-template.js +2 -2
- package/dist/cli.js +10 -8
- package/dist/dialer/appServer.d.ts +11 -1
- package/dist/dialer/appServer.js +224 -28
- package/dist/dialer/dialerElement.d.ts +2 -0
- package/dist/dialer/dialerElement.js +12 -3
- package/dist/dialer/dialingQueue.d.ts +3 -0
- package/dist/dialer/dialingQueue.js +63 -47
- package/dist/dialer/indexedDbJournal.d.ts +2 -0
- package/dist/dialer/indexedDbJournal.js +8 -0
- package/dist/dialer/managedDialer.js +3 -1
- package/dist/dialer/presentation.d.ts +19 -0
- package/dist/dialer/presentation.js +37 -0
- package/dist/index.d.ts +88 -3
- package/dist/index.js +16 -2
- package/package.json +1 -1
- package/src/cli-dx.ts +5 -1
- package/src/cli-init.ts +5 -3
- package/src/cli-omni-template.ts +2 -2
- package/src/cli.ts +9 -7
- package/src/dialer/app/app.css +6 -1
- package/src/dialer/app/app.html +4 -4
- package/src/dialer/app/app.js +92 -12
- package/src/dialer/app/incoming.js +107 -0
- package/src/dialer/appServer.ts +159 -27
- package/src/dialer/dialerElement.ts +13 -3
- package/src/dialer/dialingQueue.ts +51 -35
- package/src/dialer/indexedDbJournal.ts +6 -1
- package/src/dialer/managedDialer.ts +3 -1
- package/src/dialer/presentation.ts +38 -0
- package/src/index.ts +39 -5
package/src/index.ts
CHANGED
|
@@ -126,10 +126,13 @@ export type SpeakModel = "pyai-speak" | "tts-1" | "tts-1-hd";
|
|
|
126
126
|
|
|
127
127
|
export interface SpeechParams {
|
|
128
128
|
input: string;
|
|
129
|
+
/** Reuse one unique call ID across utterances for enabled call-stable voice recovery. */
|
|
130
|
+
speech_session_id?: string;
|
|
129
131
|
voice?: string;
|
|
130
132
|
model?: SpeakModel;
|
|
131
133
|
/**
|
|
132
|
-
* Delivery mode.
|
|
134
|
+
* Delivery mode. `speech` defaults to false; `speechStream` always uses true.
|
|
135
|
+
* The API itself defaults to true and every catalog voice accepts
|
|
133
136
|
* both values. Set false when you want one complete buffered body with a
|
|
134
137
|
* `Content-Length`. A voice whose serving fleet has no streaming lane is
|
|
135
138
|
* rendered buffered either way and says so with `x-pyai-stream: buffered`.
|
|
@@ -183,6 +186,10 @@ export type CreateJobParams = CreateJobOptions & (
|
|
|
183
186
|
);
|
|
184
187
|
|
|
185
188
|
export interface CreateJobOptions {
|
|
189
|
+
/** Spoken-language hint for every audio chunk; omit for automatic detection. */
|
|
190
|
+
transcription_language?: string;
|
|
191
|
+
/** Original script (default), or Roman letters preserving the spoken language; no translation. */
|
|
192
|
+
output_script?: "original" | "latin";
|
|
186
193
|
/** Requires Trace entitlement; incompatible with channel/diarize. */
|
|
187
194
|
trace?: boolean;
|
|
188
195
|
rule_pack?: Record<string, unknown>;
|
|
@@ -500,7 +507,7 @@ export interface HearStreamOptions {
|
|
|
500
507
|
/** Streaming STT model. Server default `pyai-hear`. */
|
|
501
508
|
model?: string;
|
|
502
509
|
/** Omit or use auto for automatic detection; an explicit code pins recognition. */
|
|
503
|
-
language?: "auto" | "en" | "es" | "fr" | "de" | "hi" | "it" | "pt" | "nl" | "zh" | "yue" | "ar" | "id" | "ko" | "th" | "vi" | "ja" | "tr" | "ms" | "sv" | "da" | "fi" | "pl" | "cs" | "fil" | "fa" | "el" | "hu" | "mk" | "ro";
|
|
510
|
+
language?: "auto" | "en" | "es" | "fr" | "de" | "hi" | "it" | "pt" | "nl" | "zh" | "yue" | "ar" | "id" | "ko" | "th" | "vi" | "ja" | "tr" | "ms" | "sv" | "da" | "fi" | "pl" | "cs" | "fil" | "fa" | "el" | "hu" | "mk" | "ro" | "ru";
|
|
504
511
|
/** Input PCM sample rate in Hz. Default 16000 server-side. */
|
|
505
512
|
sampleRate?: number;
|
|
506
513
|
/** Audio frame encoding. Default "pcm16". */
|
|
@@ -1650,6 +1657,21 @@ export interface TelephonyNumberPurchase {
|
|
|
1650
1657
|
max_monthly_cost_cents?: number;
|
|
1651
1658
|
}
|
|
1652
1659
|
|
|
1660
|
+
export interface TelephonyDesktopEndpoint {
|
|
1661
|
+
object:'telephony.desktop_endpoint';id:string;project_id:string;user_id:string;actor_type:'application';label:string;
|
|
1662
|
+
registered:boolean;available:boolean;number_id:string;status:'active'|'revoked';
|
|
1663
|
+
}
|
|
1664
|
+
export interface TelephonyDesktopEnrollment {object:'telephony.desktop_enrollment';version:1;endpoint_id:string;enrollment_token:string;expires_at:number;redeem_path:string;}
|
|
1665
|
+
export interface TelephonyDesktopCredentials {endpoint_id:string;org_id:string;project_id:string;user_id:string;label:string;refresh_token:string;refresh_expires_at:number;access_token:string;expires_at:number;presence_token:string;heartbeat_interval_seconds:15;}
|
|
1666
|
+
export interface TelephonyInboundRingGroup {
|
|
1667
|
+
mode:'simultaneous'|'desktop_first';desktop_endpoint_ids:[string];external_to:string;desktop_timeout_seconds:number;
|
|
1668
|
+
ring_timeout_seconds:number;on_no_answer:'hangup';max_duration_seconds:number;recording:boolean;
|
|
1669
|
+
}
|
|
1670
|
+
export interface TelephonyInboundCapabilities {
|
|
1671
|
+
object:'telephony.inbound_capabilities';number_id:string;binding_version:number;
|
|
1672
|
+
ring_group:{supported:boolean;modes:Array<'simultaneous'|'desktop_first'>;max_desktop_endpoints:1;on_no_answer:['hangup'];desktop_registration_required:true};
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1653
1675
|
export interface TelephonyInboundBinding {
|
|
1654
1676
|
object: "telephony.inbound_binding";
|
|
1655
1677
|
number_id: string;
|
|
@@ -1661,6 +1683,7 @@ export interface TelephonyInboundBinding {
|
|
|
1661
1683
|
agent_profile_sha256?: string;
|
|
1662
1684
|
admission_mode?: "client" | "platform";
|
|
1663
1685
|
forward?: TelephonyInboundForward | null;
|
|
1686
|
+
ring_group?:TelephonyInboundRingGroup|null;
|
|
1664
1687
|
carrier_operation?: { id: string; phase: "pending" | "unknown" | "active" | "rollback_pending" | "rolled_back"; action: "activate" | "rollback" };
|
|
1665
1688
|
}
|
|
1666
1689
|
|
|
@@ -1693,6 +1716,7 @@ export type TelephonyInboundBindingUpdate = {
|
|
|
1693
1716
|
admission_mode?: "client" | "platform";
|
|
1694
1717
|
agent_knowledge_receipt?: Record<string, unknown>;
|
|
1695
1718
|
forward?: TelephonyInboundForward | null;
|
|
1719
|
+
ring_group?:TelephonyInboundRingGroup|null;
|
|
1696
1720
|
});
|
|
1697
1721
|
|
|
1698
1722
|
/* ------------------------------------------------------------------------- *
|
|
@@ -2320,13 +2344,13 @@ export class PyAI {
|
|
|
2320
2344
|
// --- audio --------------------------------------------------------------
|
|
2321
2345
|
|
|
2322
2346
|
audio = {
|
|
2323
|
-
/** Text-to-speech. Returns
|
|
2347
|
+
/** Text-to-speech. Returns complete audio bytes (default WAV, stream:false). */
|
|
2324
2348
|
speech: async (params: SpeechParams): Promise<ArrayBuffer> => {
|
|
2325
2349
|
assertActiveSpeechParams(params);
|
|
2326
2350
|
const res = await this.request("/v1/audio/speech", {
|
|
2327
2351
|
method: "POST",
|
|
2328
2352
|
headers: this.authHeaders({ "Content-Type": "application/json" }),
|
|
2329
|
-
body: JSON.stringify({ model: "pyai-speak", ...params }),
|
|
2353
|
+
body: JSON.stringify({ model: "pyai-speak", ...params, stream: params.stream ?? false }),
|
|
2330
2354
|
});
|
|
2331
2355
|
await validateSpeechResponse(res, params);
|
|
2332
2356
|
return res.arrayBuffer();
|
|
@@ -2417,11 +2441,15 @@ export class PyAI {
|
|
|
2417
2441
|
},
|
|
2418
2442
|
/** Upload a recording with a durable retry key. Requires the current
|
|
2419
2443
|
* keyed multipart job contract; never change the key after an unknown ACK. */
|
|
2420
|
-
upload: async (params: { file: Blob; filename: string; call_id?: string; diarize?: boolean; output_formats?: Array<"json" | "srt" | "vtt"> }, opts: { idempotencyKey: string }): Promise<TranscriptionJob> => {
|
|
2444
|
+
upload: async (params: { file: Blob; filename: string; call_id?: string; diarize?: boolean; channel?: boolean; transcription_language?: string; output_script?: "original" | "latin"; webhook_url?: string; output_formats?: Array<"json" | "srt" | "vtt"> }, opts: { idempotencyKey: string }): Promise<TranscriptionJob> => {
|
|
2421
2445
|
if (!opts.idempotencyKey || opts.idempotencyKey.length > 255 || /[\r\n]/.test(opts.idempotencyKey)) throw new Error("A valid recording retry key is required.");
|
|
2422
2446
|
const form = new FormData();
|
|
2423
2447
|
if (params.call_id) form.set("call_id", params.call_id);
|
|
2424
2448
|
if (params.diarize !== undefined) form.set("diarize", String(params.diarize));
|
|
2449
|
+
if (params.channel !== undefined) form.set("channel", String(params.channel));
|
|
2450
|
+
if (params.transcription_language) form.set("transcription_language", params.transcription_language);
|
|
2451
|
+
if (params.output_script) form.set("output_script", params.output_script);
|
|
2452
|
+
if (params.webhook_url) form.set("webhook_url", params.webhook_url);
|
|
2425
2453
|
if (params.output_formats) form.set("output_formats", params.output_formats.join(","));
|
|
2426
2454
|
form.set("audio", params.file, params.filename);
|
|
2427
2455
|
const response = await this.request("/v1/transcription/jobs", { method: "POST", headers: this.authHeaders({ "Idempotency-Key": opts.idempotencyKey }), body: form });
|
|
@@ -2482,6 +2510,11 @@ export class PyAI {
|
|
|
2482
2510
|
|
|
2483
2511
|
telephony = {
|
|
2484
2512
|
/** Server-side methods. Keep the PyAI key in your backend. */
|
|
2513
|
+
desktopEndpoints: {
|
|
2514
|
+
list:(input:{number_id?:string}={}):Promise<ListResponse<TelephonyDesktopEndpoint>>=>this.getJson('/v1/telephony/desktop-endpoints'+(input.number_id?'?'+new URLSearchParams({number_id:input.number_id}):'')),
|
|
2515
|
+
create:(input:{number_id:string;user_id:string;client_reference:string;label:string}):Promise<TelephonyDesktopEndpoint>=>this.postJson('/v1/telephony/desktop-endpoints',input),
|
|
2516
|
+
enroll:(id:string,input:{user_id:string},options:{idempotencyKey:string}):Promise<TelephonyDesktopEnrollment>=>this.postJson(`/v1/telephony/desktop-endpoints/${encodeURIComponent(id)}/enrollment`,input,telephonyIdempotencyHeader(options.idempotencyKey)),
|
|
2517
|
+
},
|
|
2485
2518
|
calls: {
|
|
2486
2519
|
create: (input: TelephonyCallCreate, options: { idempotencyKey: string }): Promise<TelephonyCall> =>
|
|
2487
2520
|
this.postJson("/v1/telephony/calls", input, telephonyIdempotencyHeader(options.idempotencyKey)),
|
|
@@ -2548,6 +2581,7 @@ export class PyAI {
|
|
|
2548
2581
|
/** Route a number to an agent (`agentId: null` to unassign). */
|
|
2549
2582
|
assign: (id: string, agentId: string | null): Promise<TelephonyNumber> =>
|
|
2550
2583
|
this.postJson(`/v1/telephony/numbers/${encodeURIComponent(id)}/assign`, { agent_id: agentId }),
|
|
2584
|
+
getInboundCapabilities:(id:string):Promise<TelephonyInboundCapabilities>=>this.getJson(`/v1/telephony/numbers/${encodeURIComponent(id)}/inbound-capabilities`),
|
|
2551
2585
|
getInboundBinding: (id: string): Promise<TelephonyInboundBinding> =>
|
|
2552
2586
|
this.getJson(`/v1/telephony/numbers/${encodeURIComponent(id)}/inbound-binding`),
|
|
2553
2587
|
/** Save the profile and stable operation first; after uncertainty read the
|