@spekoai/sdk 0.4.3 → 0.5.2

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.
Files changed (71) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +88 -0
  3. package/dist/index.d.ts +3 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1 -0
  6. package/dist/lib/client.d.ts +13 -1
  7. package/dist/lib/client.d.ts.map +1 -1
  8. package/dist/lib/client.js +22 -2
  9. package/dist/lib/http.d.ts +12 -4
  10. package/dist/lib/http.d.ts.map +1 -1
  11. package/dist/lib/http.js +31 -14
  12. package/dist/lib/resources/agents.d.ts +12 -2
  13. package/dist/lib/resources/agents.d.ts.map +1 -1
  14. package/dist/lib/resources/agents.js +12 -4
  15. package/dist/lib/resources/calls.d.ts +19 -1
  16. package/dist/lib/resources/calls.d.ts.map +1 -1
  17. package/dist/lib/resources/calls.js +22 -0
  18. package/dist/lib/resources/knowledge-bases.d.ts +1 -1
  19. package/dist/lib/resources/knowledge-bases.js +1 -1
  20. package/dist/lib/resources/phone-numbers.d.ts +2 -1
  21. package/dist/lib/resources/phone-numbers.d.ts.map +1 -1
  22. package/dist/lib/resources/phone-numbers.js +2 -1
  23. package/dist/lib/resources/realtime.d.ts +3 -5
  24. package/dist/lib/resources/realtime.d.ts.map +1 -1
  25. package/dist/lib/resources/realtime.js +829 -91
  26. package/dist/lib/resources/sessions.d.ts +53 -0
  27. package/dist/lib/resources/sessions.d.ts.map +1 -0
  28. package/dist/lib/resources/sessions.js +166 -0
  29. package/dist/lib/resources/sms.d.ts +80 -0
  30. package/dist/lib/resources/sms.d.ts.map +1 -0
  31. package/dist/lib/resources/sms.js +152 -0
  32. package/dist/lib/resources/synthesize.d.ts.map +1 -1
  33. package/dist/lib/resources/synthesize.js +12 -6
  34. package/dist/lib/resources/transcribe.d.ts.map +1 -1
  35. package/dist/lib/resources/transcribe.js +9 -2
  36. package/dist/lib/resources/voice.d.ts +283 -1
  37. package/dist/lib/resources/voice.d.ts.map +1 -1
  38. package/dist/lib/resources/voice.js +345 -0
  39. package/dist/lib/resources/webhooks.d.ts +25 -0
  40. package/dist/lib/resources/webhooks.d.ts.map +1 -0
  41. package/dist/lib/resources/webhooks.js +46 -0
  42. package/dist/lib/types/index.d.ts +998 -9
  43. package/dist/lib/types/index.d.ts.map +1 -1
  44. package/dist/lib/voice-contract.d.ts +280 -0
  45. package/dist/lib/voice-contract.d.ts.map +1 -0
  46. package/dist/lib/voice-contract.js +115 -0
  47. package/package.json +2 -1
  48. package/src/index.ts +212 -0
  49. package/src/lib/client.ts +169 -0
  50. package/src/lib/errors.ts +28 -0
  51. package/src/lib/http.ts +442 -0
  52. package/src/lib/resources/agents.ts +211 -0
  53. package/src/lib/resources/callbacks.ts +40 -0
  54. package/src/lib/resources/calls.ts +113 -0
  55. package/src/lib/resources/complete.ts +63 -0
  56. package/src/lib/resources/credits.ts +41 -0
  57. package/src/lib/resources/knowledge-bases.ts +199 -0
  58. package/src/lib/resources/phone-numbers.ts +109 -0
  59. package/src/lib/resources/realtime-globals.d.ts +31 -0
  60. package/src/lib/resources/realtime.spec.ts +565 -0
  61. package/src/lib/resources/realtime.ts +1169 -0
  62. package/src/lib/resources/sessions.ts +191 -0
  63. package/src/lib/resources/sms.ts +214 -0
  64. package/src/lib/resources/synthesize.ts +101 -0
  65. package/src/lib/resources/transcribe.ts +91 -0
  66. package/src/lib/resources/usage.ts +24 -0
  67. package/src/lib/resources/voice.ts +426 -0
  68. package/src/lib/resources/voices.ts +32 -0
  69. package/src/lib/resources/webhooks.ts +67 -0
  70. package/src/lib/types/index.ts +2409 -0
  71. package/src/lib/voice-contract.ts +358 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.5.2
2
+
3
+ ### Fixes
4
+
5
+ - Correct the SDK User-Agent version and verify it against package.json before publication.
6
+
1
7
  ## 0.4.2 (2026-06-05)
2
8
 
3
9
  ### 🚀 Features
package/README.md CHANGED
@@ -76,6 +76,94 @@ const { text, toolCalls } = await speko.complete({
76
76
  Webhook, builtin, and integration tools run server-side and are folded back into
77
77
  the response; inline tools come back to you as `toolCalls` to execute yourself.
78
78
 
79
+ ## Programmable voice (call control)
80
+
81
+ `speko.callControl` drives **human** calls — on a browser softphone,
82
+ phones on the PSTN — the way Telnyx Call Control does. Every leg of a call has
83
+ an opaque `controlId`, and every verb is addressed to that handle, so a Telnyx
84
+ integration ports one command to one command.
85
+
86
+ ```ts
87
+ // Come online so inbound can ring you, and hold the presence connection open.
88
+ import { PRESENCE_STALE_AFTER_MS } from '@spekoai/sdk';
89
+
90
+ // The API key authenticates the org; brokerId identifies this softphone.
91
+ const speko = new Speko({ apiKey: process.env.SPEKO_API_KEY, brokerId: 'broker-42' });
92
+
93
+ await speko.callControl.register();
94
+ const presence = await speko.callControl.presenceToken(); // → { token, url, ... }
95
+ setInterval(() => speko.callControl.heartbeat(), PRESENCE_STALE_AFTER_MS / 3);
96
+
97
+ // Dial out. The call comes back with its legs attached, plus the room
98
+ // credentials for your own browser leg — you must be in the room before the far
99
+ // end answers, or the first moments are silent.
100
+ const { call, join } = await speko.callControl.dial({ to: '+12015551234' });
101
+ const mine = call.legs.find((leg) => leg.kind === 'browser')!;
102
+ const theirs = call.legs.find((leg) => leg.kind === 'pstn')!;
103
+ // In the browser, join the room with those credentials:
104
+ // VoiceConversation.create({ transportToken: join.token, transportUrl: join.url })
105
+
106
+ await speko.callControl.mute(mine.controlId);
107
+ // DTMF is addressed to the leg the tones are *for* — the customer's PSTN leg.
108
+ // (Speko relays them out through an in-room browser leg, because only a
109
+ // participant inside the room can publish SIP DTMF, but that's internal:
110
+ // naming a non-PSTN leg fails with UNSUPPORTED_COMMAND.)
111
+ await speko.callControl.dtmf(theirs.controlId, { digits: '1w2' });
112
+ await speko.callControl.transfer(mine.controlId, { to: '+12015559876', mode: 'warm' });
113
+ await speko.callControl.hangup(mine.controlId, { reason: 'resolved' });
114
+ ```
115
+
116
+ Answering an inbound ring is the mirror image. A `RingOffer` arrives on the
117
+ presence connection carrying **your own** leg's `controlId`; take a room token
118
+ for it, connect, then answer:
119
+
120
+ ```ts
121
+ // message: PresenceMessage, parsed off the presence data channel
122
+ if (message.type === 'incoming_call') {
123
+ const credentials = await speko.callControl.join(message.controlId);
124
+ await VoiceConversation.create({
125
+ transportToken: credentials.token,
126
+ transportUrl: credentials.url,
127
+ });
128
+ await speko.callControl.answer(message.controlId); // join the room first, then answer
129
+ }
130
+ ```
131
+
132
+ The full verb set is `answer`, `hangup`, `bridge`, `hold`, `unhold`, `mute`,
133
+ `unmute`, `dtmf`, `transfer` — each resolving to the leg's post-command state,
134
+ so you never re-read to find out what you just did. `get`, `list`, and `events`
135
+ read calls back; `events` is the recorded equivalent of the Telnyx webhook
136
+ stream. The same events can be delivered as workspace webhooks (`call.initiated`
137
+ … `call.hangup`); those are sent once, without automatic retry, so treat
138
+ `events` as the durable record and reconcile from it.
139
+
140
+ ### Broker identity
141
+
142
+ The API key authenticates the organization. `brokerId`, supplied once to
143
+ `new Speko({ apiKey, brokerId })`, identifies the softphone. The SDK includes it
144
+ automatically on `dial`, `join`, `register`, `heartbeat`, `setStatus`, and
145
+ `presenceToken`.
146
+
147
+ The command surface — `answer`, `hangup`, `hold`/`unhold`, `mute`/`unmute`,
148
+ `dtmf`, `bridge`, `transfer`, plus `get`, `list`, `events` — accepts API keys on
149
+ purpose: server-side automation acting on a live call is the point of a
150
+ programmable-voice API, and those are scoped by the leg's organization.
151
+
152
+ Two things differ from Telnyx and will bite if you assume otherwise:
153
+
154
+ - **`hold` is silent.** It is synthesized from mute + unsubscribe; with no
155
+ music-on-hold source configured the held party hears nothing at all. Say so in
156
+ your UI — callers read silence as a dropped call.
157
+ - **There is no SIP registrar.** Desk phones, third-party softphones, and other
158
+ PBXes cannot register and be rung. Human legs are browser legs; `browser` and
159
+ `pstn` are the only human-reachable leg kinds.
160
+
161
+ Errors carry stable codes on `SpekoApiError.code`, exported as
162
+ `VOICE_ERROR_CODES` so you can branch without string-matching prose.
163
+
164
+ > `speko.voice.dial(...)` is a different thing and is unchanged: it dials an
165
+ > **AI agent** out over the same telephony gateway.
166
+
79
167
  ## Documentation
80
168
 
81
169
  Full API reference and guides: <https://docs.speko.dev>
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { Speko } from './lib/client.js';
2
2
  export { SpekoApiError, SpekoAuthError, SpekoRateLimitError } from './lib/errors.js';
3
- export type { AgentAmbientClip, AgentBackgroundAudio, AgentCallListEntry, AgentCallListPage, AgentCallListParams, AgentCreateParams, AgentIntent, AgentLifecycleWebhookCreate, AgentLifecycleWebhookSerialized, AgentLifecycleWebhookUpdate, AgentLlmOptions, AgentRow, AgentStackPreferences, AgentSttOptions, AgentToolCreateParams, AgentToolRow, AgentToolSourceBuiltin, AgentToolSourceCreate, AgentToolSourceInline, AgentToolSourceIntegration, AgentToolSourceSerialized, AgentToolSourceUpdate, AgentToolSourceWebhookCreate, AgentToolSourceWebhookSerialized, AgentToolSourceWebhookUpdate, AgentToolUpdateParams, AgentUpdateParams, AgentWebhooksCreate, AgentWebhooksSerialized, AgentWebhooksUpdate, AvailablePhoneNumber, BlindTransferParams, CallCostLine, CallDetail, CallEvent, CallRecording, CallReport, CallTranscriptEntry, CallTransfer, CallTransferResponse, CancelScheduledCallbackParams, CancelWarmTransferParams, ChatMessage, ChatTool, ChatToolCall, ChatToolChoice, ChatToolExecutionMode, ChatToolSource, CompleteParams, CompleteResult, CompleteStreamEvent, CompleteWarmTransferParams, CreditLedgerEntry, CreditLedgerKind, CreditLedgerPage, CreditLedgerQueryParams, FinalizeCallReportParams, FinalizeCallReportResult, KeySource, KnowledgeBaseCreateParams, KnowledgeBaseDocumentCreateParams, KnowledgeBaseDocumentCreateResult, KnowledgeBaseDocumentPollOptions, KnowledgeBaseDocumentRow, KnowledgeBaseDocumentStatus, KnowledgeBaseDocumentUploadParams, KnowledgeBaseDocumentUploadSpec, KnowledgeBaseListParams, KnowledgeBaseRow, OptimizeFor, OrganizationBalance, PhoneNumberCreateParams, PhoneNumberDirection, PhoneNumberImportSipTrunkParams, PhoneNumberKybAuthorizedRepresentative, PhoneNumberKybBusinessProfile, PhoneNumberKybDraftParams, PhoneNumberKybOverview, PhoneNumberKybSlackNotificationStatus, PhoneNumberKybStatus, PhoneNumberKybSubmission, PhoneNumberKybSubmissionStatus, PhoneNumberKybSubmitParams, PhoneNumberRow, PhoneNumberSearchParams, PhoneNumberSetupStatus, PhoneNumberSmsAssignmentStatus, PhoneNumberSource, PhoneNumberUpdateParams, PipelineConstraints, RealtimeConnectParams, RealtimeEventHandler, RealtimeFrame, RealtimeProvider, RealtimeSessionHandle, RealtimeToolSpec, RoutingIntent, ScheduledCallback, ScheduledCallbackStatus, ScheduledCallbacksListParams, SpekoClientOptions, SynthesizeOptions, SynthesizeResult, SynthesizeStreamResult, TranscribeOptions, TranscribeResult, TranscribeStreamEvent, UsageByProvider, UsageQueryParams, UsageSummary, VoiceCatalogEntry, VoiceDialParams, VoiceDialResult, VoicesListParams, VoicesListResult, VoicesProviderEntry, WarmTransferDestination, WarmTransferFallback, WarmTransferFallbackResult, WarmTransferParams, WarmTransferVoicemailDetection, } from './lib/types/index.js';
3
+ export type { AgentAmbientClip, AgentBackgroundAudio, AgentCallListEntry, AgentCallListPage, AgentCallListParams, AgentCreateParams, AgentExtractionField, AgentIntent, AgentLifecycleWebhookCreate, AgentLifecycleWebhookSerialized, AgentLifecycleWebhookUpdate, AgentLlmOptions, AgentRow, AgentStackPreferences, AgentSttOptions, AgentToolCreateParams, AgentToolRow, AgentToolSourceBuiltin, AgentToolSourceCreate, AgentToolSourceInline, AgentToolSourceIntegration, AgentToolSourceSerialized, AgentToolSourceUpdate, AgentToolSourceWebhookCreate, AgentToolSourceWebhookSerialized, AgentToolSourceWebhookUpdate, AgentToolUpdateParams, AgentUpdateParams, AgentWebhookAuthHeader, AgentWebhookAuthHeaderInput, AgentWebhooksCreate, AgentWebhooksSerialized, AgentWebhooksUpdate, AvailablePhoneNumber, BlindTransferParams, CallControlDialParams, CallControlDialResult, CallControlListParams, CallCostLine, CallDetail, CallEvent, CallRecording, CallReport, CallReportWebhookDelivery, CallTranscriptEntry, CallTransfer, CallTransferResponse, CancelScheduledCallbackParams, CancelWarmTransferParams, ChatMessage, ChatTool, ChatToolCall, ChatToolChoice, ChatToolExecutionMode, ChatToolSource, CompleteParams, CompleteResult, CompleteStreamEvent, CompleteWarmTransferParams, CreditLedgerEntry, CreditLedgerKind, CreditLedgerPage, CreditLedgerQueryParams, EndCallResult, FinalizeCallReportParams, FinalizeCallReportResult, KeySource, KnowledgeBaseCreateParams, KnowledgeBaseDocumentCreateParams, KnowledgeBaseDocumentCreateResult, KnowledgeBaseDocumentPollOptions, KnowledgeBaseDocumentRow, KnowledgeBaseDocumentStatus, KnowledgeBaseDocumentUploadParams, KnowledgeBaseDocumentUploadSpec, KnowledgeBaseListParams, KnowledgeBaseRow, OptimizeFor, OrganizationBalance, PhoneNumberCreateParams, PhoneNumberDirection, PhoneNumberImportSipTrunkParams, PhoneNumberKybAttestationContract, PhoneNumberKybAttestor, PhoneNumberKybAuthorizedRepresentative, PhoneNumberKybBusinessProfile, PhoneNumberKybDeclaration, PhoneNumberKybDraftParams, PhoneNumberKybOverview, PhoneNumberKybSlackNotificationStatus, PhoneNumberKybStatus, PhoneNumberKybSubmission, PhoneNumberKybSubmissionStatus, PhoneNumberKybSubmitParams, PhoneNumberRow, PhoneNumberSearchParams, PhoneNumberSetupStatus, PhoneNumberSmsAssignmentStatus, PhoneNumberSource, PhoneNumberUpdateParams, PipelineConstraints, RealtimeConnectParams, RealtimeEventHandler, RealtimeFrame, RealtimeProvider, RealtimeSessionHandle, RealtimeToolSpec, RoutingIntent, ScheduledCallback, ScheduledCallbackStatus, ScheduledCallbacksListParams, SessionStreamEvent, SessionStreamOptions, SessionTranscript, SessionTranscriptEntry, SmsBatch, SmsBatchCreateParams, SmsBatchRecipient, SmsConsent, SmsConsentInput, SmsConsentListParams, SmsConsentSource, SmsConversation, SmsConversationListParams, SmsConversationNote, SmsConversationSendParams, SmsConversationUpdate, SmsMessage, SmsMessageDirection, SmsMessageListParams, SmsMessageOrigin, SmsMessageStatus, SmsPage, SmsSegmentEstimate, SmsSendParams, SmsSettings, SmsSettingsUpdate, SmsStreamEvent, SmsSuppression, SpekoClientOptions, SynthesizeOptions, SynthesizeResult, SynthesizeStreamResult, TranscribeOptions, TranscribeResult, TranscribeStreamEvent, UsageByProvider, UsageQueryParams, UsageSummary, VoiceCatalogEntry, VoiceDialParams, VoiceDialResult, VoicesListParams, VoicesListResult, VoicesProviderEntry, WarmTransferDestination, WarmTransferFallback, WarmTransferFallbackResult, WarmTransferParams, WarmTransferVoicemailDetection, WebhookDelivery, WebhookDeliveryAttempt, WebhookDeliveryDetail, WebhookDeliveryEndpointOption, WebhookDeliveryListParams, WebhookDeliveryPage, WebhookDeliveryStatus, WebhookEndpoint, WebhookEndpointAuthHeaderInput, WebhookEndpointAuthHeaderUpdate, WebhookEndpointInput, WebhookEndpointUpdate, WebhookEventType, WebJoinParams, WebJoinResult, WorkspaceWebhookEventType, } from './lib/types/index.js';
4
+ export type { BridgeCommandPayload, BrokerPresenceResource, BrokerPresenceStatus, CallCommand, CallCommandPayload, CallCommandResult, CallDirection, CallEventNotice, CallEventResource, CallEventType, CallJoinCredentials, CallLegKind, CallLegResource, CallLegStatus, CallResource, CallStatus, DtmfCommandPayload, HangupCommandPayload, PresenceMessage, RingOffer, TransferCommandPayload, VoiceErrorCode, } from './lib/voice-contract.js';
5
+ export { BROKER_ID_PATTERN, CALL_COMMANDS, CALL_EVENTS, DTMF_PATTERN, PRESENCE_STALE_AFTER_MS, VOICE_ERROR_CODES, } from './lib/voice-contract.js';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA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xB,8BAA8B,EAC9B,0BAA0B,EAC1B,cAAc,EACd,uBAAuB,EACvB,sBAAsB,EACtB,8BAA8B,EAC9B,iBAAiB,EACjB,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,uBAAuB,EACvB,4BAA4B,EAC5B,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,kBAAkB,EAClB,8BAA8B,GAC/B,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACrF,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,2BAA2B,EAC3B,+BAA+B,EAC/B,2BAA2B,EAC3B,eAAe,EACf,QAAQ,EACR,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,yBAAyB,EACzB,qBAAqB,EACrB,4BAA4B,EAC5B,gCAAgC,EAChC,4BAA4B,EAC5B,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,E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1,2 +1,3 @@
1
1
  export { Speko } from './lib/client.js';
2
2
  export { SpekoApiError, SpekoAuthError, SpekoRateLimitError } from './lib/errors.js';
3
+ export { BROKER_ID_PATTERN, CALL_COMMANDS, CALL_EVENTS, DTMF_PATTERN, PRESENCE_STALE_AFTER_MS, VOICE_ERROR_CODES, } from './lib/voice-contract.js';
@@ -5,9 +5,12 @@ import { Credits } from './resources/credits.js';
5
5
  import { KnowledgeBases } from './resources/knowledge-bases.js';
6
6
  import { PhoneNumbers } from './resources/phone-numbers.js';
7
7
  import { Realtime } from './resources/realtime.js';
8
+ import { Sessions } from './resources/sessions.js';
9
+ import { Sms } from './resources/sms.js';
8
10
  import { Usage } from './resources/usage.js';
9
- import { Voice } from './resources/voice.js';
11
+ import { CallControl, Voice } from './resources/voice.js';
10
12
  import { Voices } from './resources/voices.js';
13
+ import { Webhooks } from './resources/webhooks.js';
11
14
  import type { CompleteParams, CompleteResult, CompleteStreamEvent, SpekoClientOptions, SynthesizeOptions, SynthesizeResult, SynthesizeStreamResult, TranscribeOptions, TranscribeResult, TranscribeStreamEvent } from './types/index.js';
12
15
  /**
13
16
  * Speko client — one API, every voice provider.
@@ -28,12 +31,21 @@ export declare class Speko {
28
31
  readonly credits: Credits;
29
32
  readonly realtime: Realtime;
30
33
  readonly voice: Voice;
34
+ /**
35
+ * Programmable voice: `controlId`-addressed call control for human calls,
36
+ * plus broker presence. See {@link CallControl} for the Telnyx Call Control
37
+ * mapping — including where it deliberately differs.
38
+ */
39
+ readonly callControl: CallControl;
31
40
  readonly voices: Voices;
32
41
  readonly phoneNumbers: PhoneNumbers;
33
42
  readonly agents: Agents;
34
43
  readonly knowledgeBases: KnowledgeBases;
35
44
  readonly calls: Calls;
36
45
  readonly callbacks: Callbacks;
46
+ readonly sessions: Sessions;
47
+ readonly webhooks: Webhooks;
48
+ readonly sms: Sms;
37
49
  private readonly transcribeResource;
38
50
  private readonly synthesizeResource;
39
51
  private readonly completeResource;
@@ -1 +1 @@
1
- {"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AC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAElB,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAa;IAChD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAa;IAChD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAW;gBAEhC,OAAO,EAAE,kBAAkB;IAqCvC;;;;;;OAMG;IACH,UAAU,CACR,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,iBAAiB,EAC1B,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,gBAAgB,CAAC;IAI5B,gBAAgB,CACd,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,iBAAiB,EAC1B,WAAW,CAAC,EAAE,WAAW,GACxB,qBAAqB,CAAC,qBAAqB,CAAC;IAI/C;;;;OAIG;IACH,UAAU,CACR,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,EAC1B,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,gBAAgB,CAAC;IAI5B,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,EAC1B,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,sBAAsB,CAAC;IAIlC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC;IAIpF,cAAc,CACZ,MAAM,EAAE,cAAc,EACtB,WAAW,CAAC,EAAE,WAAW,GACxB,qBAAqB,CAAC,mBAAmB,CAAC;CAG9C"}
@@ -7,11 +7,15 @@ import { Credits } from './resources/credits.js';
7
7
  import { KnowledgeBases } from './resources/knowledge-bases.js';
8
8
  import { PhoneNumbers } from './resources/phone-numbers.js';
9
9
  import { Realtime } from './resources/realtime.js';
10
+ import { Sessions } from './resources/sessions.js';
11
+ import { Sms } from './resources/sms.js';
10
12
  import { Synthesize } from './resources/synthesize.js';
11
13
  import { Transcribe } from './resources/transcribe.js';
12
14
  import { Usage } from './resources/usage.js';
13
- import { Voice } from './resources/voice.js';
15
+ import { CallControl, Voice } from './resources/voice.js';
14
16
  import { Voices } from './resources/voices.js';
17
+ import { Webhooks } from './resources/webhooks.js';
18
+ import { BROKER_ID_PATTERN } from './voice-contract.js';
15
19
  const DEFAULT_BASE_URL = 'https://api.speko.dev';
16
20
  const DEFAULT_TIMEOUT = 30_000;
17
21
  /**
@@ -33,18 +37,30 @@ export class Speko {
33
37
  credits;
34
38
  realtime;
35
39
  voice;
40
+ /**
41
+ * Programmable voice: `controlId`-addressed call control for human calls,
42
+ * plus broker presence. See {@link CallControl} for the Telnyx Call Control
43
+ * mapping — including where it deliberately differs.
44
+ */
45
+ callControl;
36
46
  voices;
37
47
  phoneNumbers;
38
48
  agents;
39
49
  knowledgeBases;
40
50
  calls;
41
51
  callbacks;
52
+ sessions;
53
+ webhooks;
54
+ sms;
42
55
  transcribeResource;
43
56
  synthesizeResource;
44
57
  completeResource;
45
58
  constructor(options) {
46
59
  if (!options.apiKey) {
47
- throw new Error('Speko: apiKey is required. Get one at https://platform.speko.dev/api-keys');
60
+ throw new Error('Speko: apiKey is required. Get one at https://platform.speko.dev/agents/keys');
61
+ }
62
+ if (options.brokerId !== undefined && !BROKER_ID_PATTERN.test(options.brokerId)) {
63
+ throw new Error('Speko: brokerId must start with a letter or digit and contain only letters, digits, dot, underscore, or hyphen (max 128 characters)');
48
64
  }
49
65
  const http = new HttpClient({
50
66
  baseUrl: options.baseUrl ?? options.baseURL ?? DEFAULT_BASE_URL,
@@ -55,12 +71,16 @@ export class Speko {
55
71
  this.credits = new Credits(http);
56
72
  this.realtime = new Realtime(http);
57
73
  this.voice = new Voice(http);
74
+ this.callControl = new CallControl(http, options.brokerId);
58
75
  this.voices = new Voices(http);
59
76
  this.phoneNumbers = new PhoneNumbers(http);
60
77
  this.agents = new Agents(http);
61
78
  this.knowledgeBases = new KnowledgeBases(http);
62
79
  this.calls = new Calls(http);
63
80
  this.callbacks = new Callbacks(http);
81
+ this.sessions = new Sessions(http);
82
+ this.webhooks = new Webhooks(http);
83
+ this.sms = new Sms(http);
64
84
  this.transcribeResource = new Transcribe(http);
65
85
  this.synthesizeResource = new Synthesize(http);
66
86
  this.completeResource = new Complete(http);
@@ -9,9 +9,9 @@ export declare class HttpClient {
9
9
  private readonly jsonHeaders;
10
10
  private readonly timeout;
11
11
  constructor(options: HttpClientOptions);
12
- request<T>(method: string, path: string, body?: unknown, externalSignal?: AbortSignal): Promise<T>;
12
+ request<T>(method: string, path: string, body?: unknown, externalSignal?: AbortSignal, extraHeaders?: Record<string, string>): Promise<T>;
13
13
  get<T>(path: string, externalSignal?: AbortSignal): Promise<T>;
14
- post<T>(path: string, body: unknown, externalSignal?: AbortSignal): Promise<T>;
14
+ post<T>(path: string, body: unknown, externalSignal?: AbortSignal, extraHeaders?: Record<string, string>): Promise<T>;
15
15
  put<T>(path: string, body: unknown, externalSignal?: AbortSignal): Promise<T>;
16
16
  delete<T>(path: string, externalSignal?: AbortSignal): Promise<T>;
17
17
  patch<T>(path: string, body: unknown, externalSignal?: AbortSignal): Promise<T>;
@@ -29,15 +29,23 @@ export declare class HttpClient {
29
29
  bytes: Uint8Array;
30
30
  headers: Record<string, string>;
31
31
  }>;
32
- requestSse(method: string, path: string, body: unknown, externalSignal?: AbortSignal, extraHeaders?: Record<string, string>): AsyncIterableIterator<{
32
+ requestSse(method: string, path: string, body: unknown, externalSignal?: AbortSignal, extraHeaders?: Record<string, string>,
33
+ /**
34
+ * Per-request override of the client timeout. Long-lived SSE responses
35
+ * (session observation) outlive the default 30 s, which would abort them
36
+ * mid-stream.
37
+ */
38
+ timeoutMs?: number): AsyncIterableIterator<{
33
39
  event: string;
40
+ id?: string;
34
41
  data: unknown;
35
42
  }>;
36
43
  requestRawSse(method: string, path: string, bodyBytes: Uint8Array, extraHeaders: Record<string, string>, externalSignal?: AbortSignal): Promise<AsyncIterableIterator<{
37
44
  event: string;
45
+ id?: string;
38
46
  data: unknown;
39
47
  }>>;
40
- requestBinaryStream(method: string, path: string, body: unknown, externalSignal?: AbortSignal): Promise<{
48
+ requestBinaryStream(method: string, path: string, body: unknown, externalSignal?: AbortSignal, extraHeaders?: Record<string, string>): Promise<{
41
49
  chunks: AsyncIterableIterator<Uint8Array>;
42
50
  headers: Record<string, string>;
43
51
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/lib/http.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAID,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyB;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,OAAO,EAAE,iBAAiB;IAWhC,OAAO,CAAC,CAAC,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,cAAc,CAAC,EAAE,WAAW,GAC3B,OAAO,CAAC,CAAC,CAAC;IAsBP,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;IAI9D,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;IAI9E,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;IAI7E,MAA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C;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;IA+CjE,aAAa,CACjB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,UAAU,EACrB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,cAAc,CAAC,EAAE,WAAW,GAC3B,OAAO,CAAC,qBAAqB,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IA4B1E,mBAAmB,CACvB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,cAAc,CAAC,EAAE,WAAW,EAC5B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,OAAO,CAAC;QAAE,MAAM,EAAE,qBAAqB,CAAC,UAAU,CAAC,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;YAgC3E,WAAW;YA+BX,cAAc;IAiB7B;;;;OAIG;IACH,OAAO,CAAC,WAAW;YAoCL,WAAW;CAyB1B"}
package/dist/lib/http.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { SpekoApiError, SpekoAuthError, SpekoRateLimitError } from './errors.js';
2
- const USER_AGENT = '@spekoai/sdk/0.4.1';
2
+ const USER_AGENT = '@spekoai/sdk/0.5.2';
3
3
  export class HttpClient {
4
4
  baseUrl;
5
5
  authHeader;
@@ -15,19 +15,21 @@ export class HttpClient {
15
15
  };
16
16
  this.timeout = options.timeout;
17
17
  }
18
- async request(method, path, body, externalSignal) {
18
+ async request(method, path, body, externalSignal, extraHeaders) {
19
19
  const url = `${this.baseUrl}${path}`;
20
20
  const { signal, cleanup } = this.buildSignal(externalSignal);
21
21
  try {
22
22
  const response = await fetch(url, {
23
23
  method,
24
- headers: this.jsonHeaders,
24
+ headers: { ...this.jsonHeaders, ...extraHeaders },
25
25
  body: body ? JSON.stringify(body) : undefined,
26
26
  signal,
27
27
  });
28
28
  if (!response.ok) {
29
29
  await this.handleError(response);
30
30
  }
31
+ if (response.status === 204)
32
+ return undefined;
31
33
  return (await response.json());
32
34
  }
33
35
  finally {
@@ -37,8 +39,8 @@ export class HttpClient {
37
39
  async get(path, externalSignal) {
38
40
  return this.request('GET', path, undefined, externalSignal);
39
41
  }
40
- async post(path, body, externalSignal) {
41
- return this.request('POST', path, body, externalSignal);
42
+ async post(path, body, externalSignal, extraHeaders) {
43
+ return this.request('POST', path, body, externalSignal, extraHeaders);
42
44
  }
43
45
  async put(path, body, externalSignal) {
44
46
  return this.request('PUT', path, body, externalSignal);
@@ -106,9 +108,15 @@ export class HttpClient {
106
108
  cleanup();
107
109
  }
108
110
  }
109
- async *requestSse(method, path, body, externalSignal, extraHeaders) {
111
+ async *requestSse(method, path, body, externalSignal, extraHeaders,
112
+ /**
113
+ * Per-request override of the client timeout. Long-lived SSE responses
114
+ * (session observation) outlive the default 30 s, which would abort them
115
+ * mid-stream.
116
+ */
117
+ timeoutMs) {
110
118
  const url = `${this.baseUrl}${path}`;
111
- const { signal, cleanup } = this.buildSignal(externalSignal);
119
+ const { signal, cleanup } = this.buildSignal(externalSignal, timeoutMs);
112
120
  let reader;
113
121
  try {
114
122
  const response = await fetch(url, {
@@ -171,12 +179,12 @@ export class HttpClient {
171
179
  }
172
180
  return this.readSseBody(response.body, cleanup);
173
181
  }
174
- async requestBinaryStream(method, path, body, externalSignal) {
182
+ async requestBinaryStream(method, path, body, externalSignal, extraHeaders) {
175
183
  const url = `${this.baseUrl}${path}`;
176
184
  const { signal, cleanup } = this.buildSignal(externalSignal);
177
185
  const response = await fetch(url, {
178
186
  method,
179
- headers: this.jsonHeaders,
187
+ headers: { ...this.jsonHeaders, ...extraHeaders },
180
188
  body: body ? JSON.stringify(body) : undefined,
181
189
  signal,
182
190
  });
@@ -244,9 +252,10 @@ export class HttpClient {
244
252
  * that callers can cancel in-flight requests (e.g. LiveKit Agents tearing
245
253
  * down a session) while still enforcing the client's configured timeout.
246
254
  */
247
- buildSignal(externalSignal) {
255
+ buildSignal(externalSignal, timeoutMs) {
248
256
  const controller = new AbortController();
249
- const timer = setTimeout(() => controller.abort(), this.timeout);
257
+ const effectiveTimeout = timeoutMs ?? this.timeout;
258
+ const timer = effectiveTimeout > 0 ? setTimeout(() => controller.abort(), effectiveTimeout) : null;
250
259
  if (externalSignal) {
251
260
  if (externalSignal.aborted) {
252
261
  controller.abort(externalSignal.reason);
@@ -257,7 +266,8 @@ export class HttpClient {
257
266
  return {
258
267
  signal: controller.signal,
259
268
  cleanup: () => {
260
- clearTimeout(timer);
269
+ if (timer)
270
+ clearTimeout(timer);
261
271
  externalSignal.removeEventListener('abort', onAbort);
262
272
  },
263
273
  };
@@ -265,7 +275,10 @@ export class HttpClient {
265
275
  }
266
276
  return {
267
277
  signal: controller.signal,
268
- cleanup: () => clearTimeout(timer),
278
+ cleanup: () => {
279
+ if (timer)
280
+ clearTimeout(timer);
281
+ },
269
282
  };
270
283
  }
271
284
  async handleError(response) {
@@ -303,11 +316,15 @@ function drainSseEvents(buffer) {
303
316
  if (!block.trim())
304
317
  continue;
305
318
  let event = 'message';
319
+ let id;
306
320
  const dataLines = [];
307
321
  for (const line of block.split(/\r?\n/)) {
308
322
  if (line.startsWith('event:')) {
309
323
  event = line.slice('event:'.length).trim();
310
324
  }
325
+ else if (line.startsWith('id:')) {
326
+ id = line.slice('id:'.length).trim();
327
+ }
311
328
  else if (line.startsWith('data:')) {
312
329
  dataLines.push(line.slice('data:'.length).trimStart());
313
330
  }
@@ -320,7 +337,7 @@ function drainSseEvents(buffer) {
320
337
  catch {
321
338
  // Keep non-JSON SSE payloads as strings.
322
339
  }
323
- items.push({ event, data });
340
+ items.push({ event, ...(id ? { id } : {}), data });
324
341
  }
325
342
  return { items, remainder: buffer.slice(cursor) };
326
343
  }
@@ -67,7 +67,15 @@ export declare class Agents {
67
67
  export declare class AgentTools {
68
68
  private readonly http;
69
69
  constructor(http: HttpClient);
70
- list(agentId: string, abortSignal?: AbortSignal): Promise<AgentToolRow[]>;
70
+ /**
71
+ * @param opts.available When true, the server returns only tools the agent
72
+ * can actually run right now — integration tools whose backing installation
73
+ * is disconnected/missing are omitted. Use this on the runtime path so the
74
+ * model is never offered a tool that would fail.
75
+ */
76
+ list(agentId: string, abortSignal?: AbortSignal, opts?: {
77
+ available?: boolean;
78
+ }): Promise<AgentToolRow[]>;
71
79
  create(agentId: string, params: AgentToolCreateParams, abortSignal?: AbortSignal): Promise<AgentToolRow>;
72
80
  get(agentId: string, toolId: string, abortSignal?: AbortSignal): Promise<AgentToolRow>;
73
81
  update(agentId: string, toolId: string, params: AgentToolUpdateParams, abortSignal?: AbortSignal): Promise<AgentToolRow>;
@@ -80,6 +88,8 @@ export declare class AgentTools {
80
88
  * four source kinds (`inline`, `webhook`, `builtin`, `integration`) — load
81
89
  * once and pass the result straight to `speko.complete({ tools })`.
82
90
  */
83
- listChatTools(agentId: string, abortSignal?: AbortSignal): Promise<ChatTool[]>;
91
+ listChatTools(agentId: string, abortSignal?: AbortSignal, opts?: {
92
+ available?: boolean;
93
+ }): Promise<ChatTool[]>;
84
94
  }
85
95
  //# sourceMappingURL=agents.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,qBAAqB,EACrB,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,MAAM;IAGL,OAAO,CAAC,QAAQ,CAAC,IA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f,WAAW,CAAC,EAAE,WAAW,EACzB,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAC7B,OAAO,CAAC,QAAQ,EAAE,CAAC;CAIvB"}
@@ -92,8 +92,15 @@ export class AgentTools {
92
92
  constructor(http) {
93
93
  this.http = http;
94
94
  }
95
- list(agentId, abortSignal) {
96
- return this.http.get(`/v1/agents/${encodeURIComponent(agentId)}/tools`, abortSignal);
95
+ /**
96
+ * @param opts.available When true, the server returns only tools the agent
97
+ * can actually run right now — integration tools whose backing installation
98
+ * is disconnected/missing are omitted. Use this on the runtime path so the
99
+ * model is never offered a tool that would fail.
100
+ */
101
+ list(agentId, abortSignal, opts) {
102
+ const query = opts?.available ? '?available=1' : '';
103
+ return this.http.get(`/v1/agents/${encodeURIComponent(agentId)}/tools${query}`, abortSignal);
97
104
  }
98
105
  create(agentId, params, abortSignal) {
99
106
  return this.http.post(`/v1/agents/${encodeURIComponent(agentId)}/tools`, params, abortSignal);
@@ -113,8 +120,8 @@ export class AgentTools {
113
120
  * four source kinds (`inline`, `webhook`, `builtin`, `integration`) — load
114
121
  * once and pass the result straight to `speko.complete({ tools })`.
115
122
  */
116
- async listChatTools(agentId, abortSignal) {
117
- const rows = await this.list(agentId, abortSignal);
123
+ async listChatTools(agentId, abortSignal, opts) {
124
+ const rows = await this.list(agentId, abortSignal, opts);
118
125
  return rows.map(toChatTool);
119
126
  }
120
127
  }
@@ -130,5 +137,6 @@ function toChatTool(row) {
130
137
  parameters: row.parameters,
131
138
  executionMode: row.source.kind,
132
139
  source: row.source,
140
+ ...(row.preToolSpeech !== undefined && { preToolSpeech: row.preToolSpeech }),
133
141
  };
134
142
  }
@@ -1,5 +1,5 @@
1
1
  import type { HttpClient } from '../http.js';
2
- import type { BlindTransferParams, CallDetail, CallEvent, CallRecording, CallReport, CallTransfer, CallTransferResponse, CancelWarmTransferParams, CompleteWarmTransferParams, FinalizeCallReportParams, FinalizeCallReportResult, WarmTransferParams } from '../types/index.js';
2
+ import type { BlindTransferParams, CallDetail, CallEvent, CallRecording, CallReport, CallTransfer, CallTransferResponse, CancelWarmTransferParams, CompleteWarmTransferParams, EndCallResult, FinalizeCallReportParams, FinalizeCallReportResult, WarmTransferParams, WebJoinParams, WebJoinResult } from '../types/index.js';
3
3
  export declare class Calls {
4
4
  private readonly http;
5
5
  constructor(http: HttpClient);
@@ -10,6 +10,24 @@ export declare class Calls {
10
10
  report(callId: string): Promise<CallReport>;
11
11
  finalizeReport(callId: string, params?: FinalizeCallReportParams): Promise<FinalizeCallReportResult>;
12
12
  recording(callId: string): Promise<CallRecording>;
13
+ /**
14
+ * Browser bridge-in: mint a short-lived token that joins THIS live call's
15
+ * room from a web client (pass `token`/`url` to `@spekoai/client`'s
16
+ * `VoiceConversation.create({ transportToken, transportUrl })`). Once the
17
+ * browser publishes audio the platform bridges it to the phone leg and
18
+ * mutes the agent; when the browser leaves, the agent resumes.
19
+ *
20
+ * Mint at click time — the token is short-TTL and a `409` means the call
21
+ * is no longer live. Concurrent/repeat joins are allowed (rejoin after a
22
+ * drop just calls this again).
23
+ */
24
+ webJoin(callId: string, params?: WebJoinParams): Promise<WebJoinResult>;
25
+ /**
26
+ * End a live call now (kill switch): tears the room down, which hangs up
27
+ * every leg. Resolves with `status: 'ending'` once teardown is requested,
28
+ * or `status: 'already_ended'` if the call was over.
29
+ */
30
+ end(callId: string): Promise<EndCallResult>;
13
31
  blindTransfer(callId: string, params: BlindTransferParams): Promise<CallTransfer>;
14
32
  warmTransfer(callId: string, params: WarmTransferParams): Promise<CallTransferResponse>;
15
33
  completeWarmTransfer(callId: string, transferId: string, params?: CompleteWarmTransferParams): Promise<CallTransfer>;
@@ -1 +1 @@
1
- {"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/calls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,mBAAmB,EACnB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,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,wBAA6B,GACpC,OAAO,CAAC,oBAAoB,CAAC;CAMjC"}
@@ -18,6 +18,28 @@ export class Calls {
18
18
  recording(callId) {
19
19
  return this.http.get(`/v1/calls/${encodeURIComponent(callId)}/recording`);
20
20
  }
21
+ /**
22
+ * Browser bridge-in: mint a short-lived token that joins THIS live call's
23
+ * room from a web client (pass `token`/`url` to `@spekoai/client`'s
24
+ * `VoiceConversation.create({ transportToken, transportUrl })`). Once the
25
+ * browser publishes audio the platform bridges it to the phone leg and
26
+ * mutes the agent; when the browser leaves, the agent resumes.
27
+ *
28
+ * Mint at click time — the token is short-TTL and a `409` means the call
29
+ * is no longer live. Concurrent/repeat joins are allowed (rejoin after a
30
+ * drop just calls this again).
31
+ */
32
+ webJoin(callId, params = {}) {
33
+ return this.http.post(`/v1/calls/${encodeURIComponent(callId)}/web-join`, params);
34
+ }
35
+ /**
36
+ * End a live call now (kill switch): tears the room down, which hangs up
37
+ * every leg. Resolves with `status: 'ending'` once teardown is requested,
38
+ * or `status: 'already_ended'` if the call was over.
39
+ */
40
+ end(callId) {
41
+ return this.http.post(`/v1/calls/${encodeURIComponent(callId)}/end`, {});
42
+ }
21
43
  blindTransfer(callId, params) {
22
44
  return this.http.post(`/v1/calls/${encodeURIComponent(callId)}/transfers/blind`, params);
23
45
  }
@@ -2,7 +2,7 @@ import type { HttpClient } from '../http.js';
2
2
  import type { KnowledgeBaseCreateParams, KnowledgeBaseDocumentCreateParams, KnowledgeBaseDocumentCreateResult, KnowledgeBaseDocumentPollOptions, KnowledgeBaseDocumentRow, KnowledgeBaseDocumentUploadParams, KnowledgeBaseListParams, KnowledgeBaseRow } from '../types/index.js';
3
3
  /**
4
4
  * Per-agent knowledge bases. Each KB owns documents that get embedded
5
- * into a Chroma collection so the agent can retrieve relevant chunks
5
+ * into a PHALANX tenant so the agent can retrieve relevant chunks
6
6
  * during a call. Every agent created via {@link Agents.create}
7
7
  * auto-provisions a `Default` KB; additional KBs can be created
8
8
  * explicitly with {@link KnowledgeBases.create}.
@@ -3,7 +3,7 @@ const DEFAULT_POLL_INTERVAL_MS = 2_000;
3
3
  const DEFAULT_POLL_TIMEOUT_MS = 120_000;
4
4
  /**
5
5
  * Per-agent knowledge bases. Each KB owns documents that get embedded
6
- * into a Chroma collection so the agent can retrieve relevant chunks
6
+ * into a PHALANX tenant so the agent can retrieve relevant chunks
7
7
  * during a call. Every agent created via {@link Agents.create}
8
8
  * auto-provisions a `Default` KB; additional KBs can be created
9
9
  * explicitly with {@link KnowledgeBases.create}.
@@ -56,7 +56,8 @@ export declare class PhoneNumbers {
56
56
  */
57
57
  saveKybDraft(params: PhoneNumberKybDraftParams): Promise<PhoneNumberKybSubmission>;
58
58
  /**
59
- * Submit business verification for review. `attestationAccepted` must be `true`.
59
+ * Submit a business declaration for asynchronous review. A current minimal
60
+ * declaration enables purchasing immediately; the legacy full profile remains accepted.
60
61
  */
61
62
  submitKyb(params: PhoneNumberKybSubmitParams): Promise<PhoneNumberKybSubmission>;
62
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"phone-numbers.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/phone-numbers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,oBAAoB,EACpB,uBAAuB,EACvB,+BAA+B,EAC/B,yBAAyB,EACzB,sBAAsB,EACtB,wBAAwB,EACxB,0BAA0B,EAC1B,cAAc,EACd,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,IAAI,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAIjC;;;;;;;;;;OAUG;IACH,eAAe,CAAC,MA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