@pyai/sdk 0.17.0 → 0.18.0
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/CLI.md +20 -0
- package/CLI.schema.json +2 -1
- package/README.md +3 -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 +86 -3
- package/dist/index.js +16 -2
- package/package.json +1 -1
- 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 +37 -5
package/src/index.ts
CHANGED
|
@@ -129,7 +129,8 @@ export interface SpeechParams {
|
|
|
129
129
|
voice?: string;
|
|
130
130
|
model?: SpeakModel;
|
|
131
131
|
/**
|
|
132
|
-
* Delivery mode.
|
|
132
|
+
* Delivery mode. `speech` defaults to false; `speechStream` always uses true.
|
|
133
|
+
* The API itself defaults to true and every catalog voice accepts
|
|
133
134
|
* both values. Set false when you want one complete buffered body with a
|
|
134
135
|
* `Content-Length`. A voice whose serving fleet has no streaming lane is
|
|
135
136
|
* rendered buffered either way and says so with `x-pyai-stream: buffered`.
|
|
@@ -183,6 +184,10 @@ export type CreateJobParams = CreateJobOptions & (
|
|
|
183
184
|
);
|
|
184
185
|
|
|
185
186
|
export interface CreateJobOptions {
|
|
187
|
+
/** Spoken-language hint for every audio chunk; omit for automatic detection. */
|
|
188
|
+
transcription_language?: string;
|
|
189
|
+
/** Original script (default), or Roman letters preserving the spoken language; no translation. */
|
|
190
|
+
output_script?: "original" | "latin";
|
|
186
191
|
/** Requires Trace entitlement; incompatible with channel/diarize. */
|
|
187
192
|
trace?: boolean;
|
|
188
193
|
rule_pack?: Record<string, unknown>;
|
|
@@ -500,7 +505,7 @@ export interface HearStreamOptions {
|
|
|
500
505
|
/** Streaming STT model. Server default `pyai-hear`. */
|
|
501
506
|
model?: string;
|
|
502
507
|
/** 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";
|
|
508
|
+
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
509
|
/** Input PCM sample rate in Hz. Default 16000 server-side. */
|
|
505
510
|
sampleRate?: number;
|
|
506
511
|
/** Audio frame encoding. Default "pcm16". */
|
|
@@ -1650,6 +1655,21 @@ export interface TelephonyNumberPurchase {
|
|
|
1650
1655
|
max_monthly_cost_cents?: number;
|
|
1651
1656
|
}
|
|
1652
1657
|
|
|
1658
|
+
export interface TelephonyDesktopEndpoint {
|
|
1659
|
+
object:'telephony.desktop_endpoint';id:string;project_id:string;user_id:string;actor_type:'application';label:string;
|
|
1660
|
+
registered:boolean;available:boolean;number_id:string;status:'active'|'revoked';
|
|
1661
|
+
}
|
|
1662
|
+
export interface TelephonyDesktopEnrollment {object:'telephony.desktop_enrollment';version:1;endpoint_id:string;enrollment_token:string;expires_at:number;redeem_path:string;}
|
|
1663
|
+
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;}
|
|
1664
|
+
export interface TelephonyInboundRingGroup {
|
|
1665
|
+
mode:'simultaneous'|'desktop_first';desktop_endpoint_ids:[string];external_to:string;desktop_timeout_seconds:number;
|
|
1666
|
+
ring_timeout_seconds:number;on_no_answer:'hangup';max_duration_seconds:number;recording:boolean;
|
|
1667
|
+
}
|
|
1668
|
+
export interface TelephonyInboundCapabilities {
|
|
1669
|
+
object:'telephony.inbound_capabilities';number_id:string;binding_version:number;
|
|
1670
|
+
ring_group:{supported:boolean;modes:Array<'simultaneous'|'desktop_first'>;max_desktop_endpoints:1;on_no_answer:['hangup'];desktop_registration_required:true};
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1653
1673
|
export interface TelephonyInboundBinding {
|
|
1654
1674
|
object: "telephony.inbound_binding";
|
|
1655
1675
|
number_id: string;
|
|
@@ -1661,6 +1681,7 @@ export interface TelephonyInboundBinding {
|
|
|
1661
1681
|
agent_profile_sha256?: string;
|
|
1662
1682
|
admission_mode?: "client" | "platform";
|
|
1663
1683
|
forward?: TelephonyInboundForward | null;
|
|
1684
|
+
ring_group?:TelephonyInboundRingGroup|null;
|
|
1664
1685
|
carrier_operation?: { id: string; phase: "pending" | "unknown" | "active" | "rollback_pending" | "rolled_back"; action: "activate" | "rollback" };
|
|
1665
1686
|
}
|
|
1666
1687
|
|
|
@@ -1693,6 +1714,7 @@ export type TelephonyInboundBindingUpdate = {
|
|
|
1693
1714
|
admission_mode?: "client" | "platform";
|
|
1694
1715
|
agent_knowledge_receipt?: Record<string, unknown>;
|
|
1695
1716
|
forward?: TelephonyInboundForward | null;
|
|
1717
|
+
ring_group?:TelephonyInboundRingGroup|null;
|
|
1696
1718
|
});
|
|
1697
1719
|
|
|
1698
1720
|
/* ------------------------------------------------------------------------- *
|
|
@@ -2320,13 +2342,13 @@ export class PyAI {
|
|
|
2320
2342
|
// --- audio --------------------------------------------------------------
|
|
2321
2343
|
|
|
2322
2344
|
audio = {
|
|
2323
|
-
/** Text-to-speech. Returns
|
|
2345
|
+
/** Text-to-speech. Returns complete audio bytes (default WAV, stream:false). */
|
|
2324
2346
|
speech: async (params: SpeechParams): Promise<ArrayBuffer> => {
|
|
2325
2347
|
assertActiveSpeechParams(params);
|
|
2326
2348
|
const res = await this.request("/v1/audio/speech", {
|
|
2327
2349
|
method: "POST",
|
|
2328
2350
|
headers: this.authHeaders({ "Content-Type": "application/json" }),
|
|
2329
|
-
body: JSON.stringify({ model: "pyai-speak", ...params }),
|
|
2351
|
+
body: JSON.stringify({ model: "pyai-speak", ...params, stream: params.stream ?? false }),
|
|
2330
2352
|
});
|
|
2331
2353
|
await validateSpeechResponse(res, params);
|
|
2332
2354
|
return res.arrayBuffer();
|
|
@@ -2417,11 +2439,15 @@ export class PyAI {
|
|
|
2417
2439
|
},
|
|
2418
2440
|
/** Upload a recording with a durable retry key. Requires the current
|
|
2419
2441
|
* 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> => {
|
|
2442
|
+
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
2443
|
if (!opts.idempotencyKey || opts.idempotencyKey.length > 255 || /[\r\n]/.test(opts.idempotencyKey)) throw new Error("A valid recording retry key is required.");
|
|
2422
2444
|
const form = new FormData();
|
|
2423
2445
|
if (params.call_id) form.set("call_id", params.call_id);
|
|
2424
2446
|
if (params.diarize !== undefined) form.set("diarize", String(params.diarize));
|
|
2447
|
+
if (params.channel !== undefined) form.set("channel", String(params.channel));
|
|
2448
|
+
if (params.transcription_language) form.set("transcription_language", params.transcription_language);
|
|
2449
|
+
if (params.output_script) form.set("output_script", params.output_script);
|
|
2450
|
+
if (params.webhook_url) form.set("webhook_url", params.webhook_url);
|
|
2425
2451
|
if (params.output_formats) form.set("output_formats", params.output_formats.join(","));
|
|
2426
2452
|
form.set("audio", params.file, params.filename);
|
|
2427
2453
|
const response = await this.request("/v1/transcription/jobs", { method: "POST", headers: this.authHeaders({ "Idempotency-Key": opts.idempotencyKey }), body: form });
|
|
@@ -2482,6 +2508,11 @@ export class PyAI {
|
|
|
2482
2508
|
|
|
2483
2509
|
telephony = {
|
|
2484
2510
|
/** Server-side methods. Keep the PyAI key in your backend. */
|
|
2511
|
+
desktopEndpoints: {
|
|
2512
|
+
list:(input:{number_id?:string}={}):Promise<ListResponse<TelephonyDesktopEndpoint>>=>this.getJson('/v1/telephony/desktop-endpoints'+(input.number_id?'?'+new URLSearchParams({number_id:input.number_id}):'')),
|
|
2513
|
+
create:(input:{number_id:string;user_id:string;client_reference:string;label:string}):Promise<TelephonyDesktopEndpoint>=>this.postJson('/v1/telephony/desktop-endpoints',input),
|
|
2514
|
+
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)),
|
|
2515
|
+
},
|
|
2485
2516
|
calls: {
|
|
2486
2517
|
create: (input: TelephonyCallCreate, options: { idempotencyKey: string }): Promise<TelephonyCall> =>
|
|
2487
2518
|
this.postJson("/v1/telephony/calls", input, telephonyIdempotencyHeader(options.idempotencyKey)),
|
|
@@ -2548,6 +2579,7 @@ export class PyAI {
|
|
|
2548
2579
|
/** Route a number to an agent (`agentId: null` to unassign). */
|
|
2549
2580
|
assign: (id: string, agentId: string | null): Promise<TelephonyNumber> =>
|
|
2550
2581
|
this.postJson(`/v1/telephony/numbers/${encodeURIComponent(id)}/assign`, { agent_id: agentId }),
|
|
2582
|
+
getInboundCapabilities:(id:string):Promise<TelephonyInboundCapabilities>=>this.getJson(`/v1/telephony/numbers/${encodeURIComponent(id)}/inbound-capabilities`),
|
|
2551
2583
|
getInboundBinding: (id: string): Promise<TelephonyInboundBinding> =>
|
|
2552
2584
|
this.getJson(`/v1/telephony/numbers/${encodeURIComponent(id)}/inbound-binding`),
|
|
2553
2585
|
/** Save the profile and stable operation first; after uncertainty read the
|