@spekoai/sdk 0.4.0 → 0.4.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.
- package/CHANGELOG.md +28 -0
- package/README.md +32 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/client.d.ts +12 -6
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/client.js +20 -11
- package/dist/lib/http.d.ts +1 -0
- package/dist/lib/http.d.ts.map +1 -1
- package/dist/lib/http.js +4 -1
- package/dist/lib/resources/agents.d.ts +27 -10
- package/dist/lib/resources/agents.d.ts.map +1 -1
- package/dist/lib/resources/agents.js +58 -14
- package/dist/lib/resources/callbacks.d.ts +13 -0
- package/dist/lib/resources/callbacks.d.ts.map +1 -0
- package/dist/lib/resources/callbacks.js +26 -0
- package/dist/lib/resources/calls.d.ts +18 -0
- package/dist/lib/resources/calls.d.ts.map +1 -0
- package/dist/lib/resources/calls.js +33 -0
- package/dist/lib/resources/complete.d.ts +1 -1
- package/dist/lib/resources/complete.d.ts.map +1 -1
- package/dist/lib/resources/complete.js +9 -3
- package/dist/lib/resources/credits.d.ts.map +1 -1
- package/dist/lib/resources/knowledge-bases.d.ts +1 -1
- package/dist/lib/resources/knowledge-bases.d.ts.map +1 -1
- package/dist/lib/resources/knowledge-bases.js +1 -1
- package/dist/lib/resources/phone-numbers.d.ts +20 -6
- package/dist/lib/resources/phone-numbers.d.ts.map +1 -1
- package/dist/lib/resources/phone-numbers.js +27 -5
- package/dist/lib/resources/realtime.d.ts +1 -1
- package/dist/lib/resources/realtime.d.ts.map +1 -1
- package/dist/lib/resources/realtime.js +28 -3
- package/dist/lib/resources/synthesize.d.ts +1 -1
- package/dist/lib/resources/synthesize.d.ts.map +1 -1
- package/dist/lib/resources/synthesize.js +3 -1
- package/dist/lib/resources/transcribe.d.ts +1 -1
- package/dist/lib/resources/transcribe.d.ts.map +1 -1
- package/dist/lib/resources/transcribe.js +5 -2
- package/dist/lib/resources/usage.d.ts +1 -1
- package/dist/lib/resources/usage.d.ts.map +1 -1
- package/dist/lib/resources/voice.d.ts +3 -4
- package/dist/lib/resources/voice.d.ts.map +1 -1
- package/dist/lib/resources/voice.js +3 -4
- package/dist/lib/resources/voices.d.ts +27 -0
- package/dist/lib/resources/voices.d.ts.map +1 -0
- package/dist/lib/resources/voices.js +32 -0
- package/dist/lib/types/index.d.ts +561 -20
- package/dist/lib/types/index.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -33,6 +33,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
33
33
|
|
|
34
34
|
## [Unreleased]
|
|
35
35
|
|
|
36
|
+
### Added
|
|
37
|
+
|
|
38
|
+
- `speko.agents.tools.listChatTools(agentId)` — fetches an agent's registered
|
|
39
|
+
tools and converts them into the `ChatTool[]` shape `complete()` accepts.
|
|
40
|
+
Covers all four source kinds (`inline`, `webhook`, `builtin`, `integration`),
|
|
41
|
+
so the result can be passed straight to `speko.complete({ tools })`.
|
|
42
|
+
- `baseURL` is now accepted as an alias for `baseUrl` on the client constructor.
|
|
43
|
+
If both are set, `baseUrl` wins.
|
|
44
|
+
- Agent tool methods (`speko.agents.tools.*`) accept an optional trailing
|
|
45
|
+
`AbortSignal` to cancel the in-flight request.
|
|
46
|
+
- `integration` tool source support: new `AgentToolSourceIntegration` type, added
|
|
47
|
+
to `AgentToolSourceCreate` and `AgentToolSourceSerialized`. Binds a tool to an
|
|
48
|
+
org-installed Speko app action (e.g. Google Calendar, Slack).
|
|
49
|
+
- `AgentToolSourceWebhookUpdate` / `AgentToolSourceUpdate` types: webhook updates
|
|
50
|
+
may now omit `secret` to keep the existing encrypted secret (only supply it to
|
|
51
|
+
rotate). `AgentToolUpdateParams.source` uses the new update union.
|
|
52
|
+
- Telephony SDK parity: `phoneNumbers.getKyb/saveKybDraft/submitKyb`,
|
|
53
|
+
`calls.recording`, and `agents.listCalls`, plus public types for KYB,
|
|
54
|
+
call recordings, report finalization, SMS assignment fields, and agent call
|
|
55
|
+
pages.
|
|
56
|
+
|
|
57
|
+
### Changed
|
|
58
|
+
|
|
59
|
+
- `PhoneNumberRow.source` now reflects the public API values
|
|
60
|
+
(`managed | sip_trunk`), `PhoneNumberUpdateParams` accepts `null` for clearable
|
|
61
|
+
fields, and `PhoneNumberImportSipTrunkParams` supports both productized SIP
|
|
62
|
+
connection imports and the legacy `sipTrunkId` path.
|
|
63
|
+
|
|
36
64
|
## [0.2.1] - 2026-04-26
|
|
37
65
|
|
|
38
66
|
### Added
|
package/README.md
CHANGED
|
@@ -13,8 +13,6 @@ right provider for every call.
|
|
|
13
13
|
npm install @spekoai/sdk
|
|
14
14
|
# or
|
|
15
15
|
pnpm add @spekoai/sdk
|
|
16
|
-
# or
|
|
17
|
-
bun add @spekoai/sdk
|
|
18
16
|
```
|
|
19
17
|
|
|
20
18
|
## Quickstart
|
|
@@ -47,9 +45,40 @@ const { text: reply } = await speko.complete({
|
|
|
47
45
|
// speko.transcribeStream(...), speko.synthesizeStream(...), speko.completeStream(...)
|
|
48
46
|
```
|
|
49
47
|
|
|
48
|
+
> The client accepts `baseURL` as an alias for `baseUrl` — e.g.
|
|
49
|
+
> `new Speko({ apiKey, baseURL: process.env.SPEKO_BASE_URL })`. If both are set,
|
|
50
|
+
> `baseUrl` wins.
|
|
51
|
+
|
|
52
|
+
## Registered tools
|
|
53
|
+
|
|
54
|
+
Tools registered against an agent (via `speko.agents.tools.create(...)` or the
|
|
55
|
+
dashboard) can be loaded and handed straight to `complete()`.
|
|
56
|
+
`listChatTools(agentId)` fetches the agent's tools and converts every source
|
|
57
|
+
kind — `inline`, `webhook`, `builtin`, and `integration` — into the
|
|
58
|
+
`ChatTool[]` shape `complete()` expects:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
const speko = new Speko({
|
|
62
|
+
apiKey: process.env.SPEKO_API_KEY,
|
|
63
|
+
baseURL: process.env.SPEKO_BASE_URL,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Fetch once, then pass straight to complete()
|
|
67
|
+
const tools = await speko.agents.tools.listChatTools(agentId);
|
|
68
|
+
|
|
69
|
+
const { text, toolCalls } = await speko.complete({
|
|
70
|
+
messages: [{ role: 'user', content: 'Book me a slot tomorrow at 3pm' }],
|
|
71
|
+
intent: { language: 'en' },
|
|
72
|
+
tools,
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Webhook, builtin, and integration tools run server-side and are folded back into
|
|
77
|
+
the response; inline tools come back to you as `toolCalls` to execute yourself.
|
|
78
|
+
|
|
50
79
|
## Documentation
|
|
51
80
|
|
|
52
|
-
Full API reference and guides: <https://docs.speko.
|
|
81
|
+
Full API reference and guides: <https://docs.speko.dev>
|
|
53
82
|
|
|
54
83
|
## Contributing
|
|
55
84
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Speko } from './lib/client.js';
|
|
2
2
|
export { SpekoApiError, SpekoAuthError, SpekoRateLimitError } from './lib/errors.js';
|
|
3
|
-
export type {
|
|
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';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,kBAAkB,EAClB,
|
|
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,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,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,SAAS,EACT,aAAa,EACb,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,6BAA6B,EAC7B,wBAAwB,EACxB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,0BAA0B,EAC1B,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,SAAS,EACT,yBAAyB,EACzB,iCAAiC,EACjC,iCAAiC,EACjC,gCAAgC,EAChC,wBAAwB,EACxB,2BAA2B,EAC3B,iCAAiC,EACjC,+BAA+B,EAC/B,uBAAuB,EACvB,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,+BAA+B,EAC/B,sCAAsC,EACtC,6BAA6B,EAC7B,yBAAyB,EACzB,sBAAsB,EACtB,qCAAqC,EACrC,oBAAoB,EACpB,wBAAwB,EACxB,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"}
|
package/dist/lib/client.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { Agents } from './resources/agents.js';
|
|
2
|
+
import { Callbacks } from './resources/callbacks.js';
|
|
3
|
+
import { Calls } from './resources/calls.js';
|
|
3
4
|
import { Credits } from './resources/credits.js';
|
|
5
|
+
import { KnowledgeBases } from './resources/knowledge-bases.js';
|
|
6
|
+
import { PhoneNumbers } from './resources/phone-numbers.js';
|
|
4
7
|
import { Realtime } from './resources/realtime.js';
|
|
8
|
+
import { Usage } from './resources/usage.js';
|
|
5
9
|
import { Voice } from './resources/voice.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { KnowledgeBases } from './resources/knowledge-bases.js';
|
|
10
|
+
import { Voices } from './resources/voices.js';
|
|
11
|
+
import type { CompleteParams, CompleteResult, CompleteStreamEvent, SpekoClientOptions, SynthesizeOptions, SynthesizeResult, SynthesizeStreamResult, TranscribeOptions, TranscribeResult, TranscribeStreamEvent } from './types/index.js';
|
|
9
12
|
/**
|
|
10
13
|
* Speko client — one API, every voice provider.
|
|
11
14
|
*
|
|
@@ -25,16 +28,19 @@ export declare class Speko {
|
|
|
25
28
|
readonly credits: Credits;
|
|
26
29
|
readonly realtime: Realtime;
|
|
27
30
|
readonly voice: Voice;
|
|
31
|
+
readonly voices: Voices;
|
|
28
32
|
readonly phoneNumbers: PhoneNumbers;
|
|
29
33
|
readonly agents: Agents;
|
|
30
34
|
readonly knowledgeBases: KnowledgeBases;
|
|
35
|
+
readonly calls: Calls;
|
|
36
|
+
readonly callbacks: Callbacks;
|
|
31
37
|
private readonly transcribeResource;
|
|
32
38
|
private readonly synthesizeResource;
|
|
33
39
|
private readonly completeResource;
|
|
34
40
|
constructor(options: SpekoClientOptions);
|
|
35
41
|
/**
|
|
36
42
|
* Transcribe audio. The router picks the best STT provider for your
|
|
37
|
-
* `(language, optimizeFor)` and fails over automatically.
|
|
43
|
+
* `(language, region, optimizeFor)` and fails over automatically.
|
|
38
44
|
*
|
|
39
45
|
* Pass an `AbortSignal` to cancel the in-flight request — useful when a
|
|
40
46
|
* calling framework (e.g. LiveKit Agents) tears down a session mid-call.
|
package/dist/lib/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version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,CAAC;IAE9B,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAa;IAChD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAa;IAChD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAW;gBAEhC,OAAO,EAAE,kBAAkB;IA0BvC;;;;;;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"}
|
package/dist/lib/client.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { HttpClient } from './http.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Synthesize } from './resources/synthesize.js';
|
|
2
|
+
import { Agents } from './resources/agents.js';
|
|
3
|
+
import { Callbacks } from './resources/callbacks.js';
|
|
4
|
+
import { Calls } from './resources/calls.js';
|
|
6
5
|
import { Complete } from './resources/complete.js';
|
|
6
|
+
import { Credits } from './resources/credits.js';
|
|
7
|
+
import { KnowledgeBases } from './resources/knowledge-bases.js';
|
|
8
|
+
import { PhoneNumbers } from './resources/phone-numbers.js';
|
|
7
9
|
import { Realtime } from './resources/realtime.js';
|
|
10
|
+
import { Synthesize } from './resources/synthesize.js';
|
|
11
|
+
import { Transcribe } from './resources/transcribe.js';
|
|
12
|
+
import { Usage } from './resources/usage.js';
|
|
8
13
|
import { Voice } from './resources/voice.js';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import { KnowledgeBases } from './resources/knowledge-bases.js';
|
|
12
|
-
const DEFAULT_BASE_URL = 'https://api.speko.ai';
|
|
14
|
+
import { Voices } from './resources/voices.js';
|
|
15
|
+
const DEFAULT_BASE_URL = 'https://api.speko.dev';
|
|
13
16
|
const DEFAULT_TIMEOUT = 30_000;
|
|
14
17
|
/**
|
|
15
18
|
* Speko client — one API, every voice provider.
|
|
@@ -30,18 +33,21 @@ export class Speko {
|
|
|
30
33
|
credits;
|
|
31
34
|
realtime;
|
|
32
35
|
voice;
|
|
36
|
+
voices;
|
|
33
37
|
phoneNumbers;
|
|
34
38
|
agents;
|
|
35
39
|
knowledgeBases;
|
|
40
|
+
calls;
|
|
41
|
+
callbacks;
|
|
36
42
|
transcribeResource;
|
|
37
43
|
synthesizeResource;
|
|
38
44
|
completeResource;
|
|
39
45
|
constructor(options) {
|
|
40
46
|
if (!options.apiKey) {
|
|
41
|
-
throw new Error('Speko: apiKey is required. Get one at https://
|
|
47
|
+
throw new Error('Speko: apiKey is required. Get one at https://platform.speko.dev/api-keys');
|
|
42
48
|
}
|
|
43
49
|
const http = new HttpClient({
|
|
44
|
-
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
50
|
+
baseUrl: options.baseUrl ?? options.baseURL ?? DEFAULT_BASE_URL,
|
|
45
51
|
apiKey: options.apiKey,
|
|
46
52
|
timeout: options.timeout ?? DEFAULT_TIMEOUT,
|
|
47
53
|
});
|
|
@@ -49,16 +55,19 @@ export class Speko {
|
|
|
49
55
|
this.credits = new Credits(http);
|
|
50
56
|
this.realtime = new Realtime(http);
|
|
51
57
|
this.voice = new Voice(http);
|
|
58
|
+
this.voices = new Voices(http);
|
|
52
59
|
this.phoneNumbers = new PhoneNumbers(http);
|
|
53
60
|
this.agents = new Agents(http);
|
|
54
61
|
this.knowledgeBases = new KnowledgeBases(http);
|
|
62
|
+
this.calls = new Calls(http);
|
|
63
|
+
this.callbacks = new Callbacks(http);
|
|
55
64
|
this.transcribeResource = new Transcribe(http);
|
|
56
65
|
this.synthesizeResource = new Synthesize(http);
|
|
57
66
|
this.completeResource = new Complete(http);
|
|
58
67
|
}
|
|
59
68
|
/**
|
|
60
69
|
* Transcribe audio. The router picks the best STT provider for your
|
|
61
|
-
* `(language, optimizeFor)` and fails over automatically.
|
|
70
|
+
* `(language, region, optimizeFor)` and fails over automatically.
|
|
62
71
|
*
|
|
63
72
|
* Pass an `AbortSignal` to cancel the in-flight request — useful when a
|
|
64
73
|
* calling framework (e.g. LiveKit Agents) tears down a session mid-call.
|
package/dist/lib/http.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class HttpClient {
|
|
|
12
12
|
request<T>(method: string, path: string, body?: unknown, externalSignal?: AbortSignal): Promise<T>;
|
|
13
13
|
get<T>(path: string, externalSignal?: AbortSignal): Promise<T>;
|
|
14
14
|
post<T>(path: string, body: unknown, externalSignal?: AbortSignal): Promise<T>;
|
|
15
|
+
put<T>(path: string, body: unknown, externalSignal?: AbortSignal): Promise<T>;
|
|
15
16
|
delete<T>(path: string, externalSignal?: AbortSignal): Promise<T>;
|
|
16
17
|
patch<T>(path: string, body: unknown, externalSignal?: AbortSignal): Promise<T>;
|
|
17
18
|
/**
|
package/dist/lib/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/lib/http.ts"],"names":[],"mappings":"AAEA,MAAM,WAA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M,CAAC,GACpC,qBAAqB,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;IA+CpD,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,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IA4B7D,mBAAmB,CACvB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,cAAc,CAAC,EAAE,WAAW,GAC3B,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;YA6BL,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.
|
|
2
|
+
const USER_AGENT = '@spekoai/sdk/0.4.1';
|
|
3
3
|
export class HttpClient {
|
|
4
4
|
baseUrl;
|
|
5
5
|
authHeader;
|
|
@@ -40,6 +40,9 @@ export class HttpClient {
|
|
|
40
40
|
async post(path, body, externalSignal) {
|
|
41
41
|
return this.request('POST', path, body, externalSignal);
|
|
42
42
|
}
|
|
43
|
+
async put(path, body, externalSignal) {
|
|
44
|
+
return this.request('PUT', path, body, externalSignal);
|
|
45
|
+
}
|
|
43
46
|
async delete(path, externalSignal) {
|
|
44
47
|
return this.request('DELETE', path, undefined, externalSignal);
|
|
45
48
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from '../http.js';
|
|
2
|
-
import type { AgentCreateParams, AgentRow, AgentToolCreateParams, AgentToolRow, AgentToolUpdateParams, AgentUpdateParams, PhoneNumberRow } from '../types/index.js';
|
|
2
|
+
import type { AgentCallListPage, AgentCallListParams, AgentCreateParams, AgentRow, AgentToolCreateParams, AgentToolRow, AgentToolUpdateParams, AgentUpdateParams, ChatTool, PhoneNumberRow } from '../types/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Per-org agent definitions — the system prompt, voice, intent, and
|
|
5
5
|
* routing constraints used when this agent answers (or places) a call.
|
|
@@ -44,25 +44,42 @@ export declare class Agents {
|
|
|
44
44
|
* `{ agentId: null }`.
|
|
45
45
|
*/
|
|
46
46
|
detachPhoneNumber(phoneNumberId: string): Promise<PhoneNumberRow>;
|
|
47
|
+
/**
|
|
48
|
+
* List recent calls for an agent. Use `next_cursor` from the returned page
|
|
49
|
+
* as `cursor` to page backward in time.
|
|
50
|
+
*/
|
|
51
|
+
listCalls(agentId: string, params?: AgentCallListParams): Promise<AgentCallListPage>;
|
|
47
52
|
}
|
|
48
53
|
/**
|
|
49
|
-
* Per-agent tool definitions exposed to the LLM mid-call.
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* `
|
|
54
|
+
* Per-agent tool definitions exposed to the LLM mid-call. Four execution
|
|
55
|
+
* modes: `inline` (caller runs the tool), `webhook` (Speko POSTs to your URL
|
|
56
|
+
* with a Standard-Webhooks signature), `builtin` (Speko-managed tools like
|
|
57
|
+
* `search_knowledge_base`, `transfer_call`, `end_call`), and `integration`
|
|
58
|
+
* (an org-installed Speko app action such as Google Calendar or Slack).
|
|
53
59
|
*
|
|
54
60
|
* Webhook secrets are encrypted server-side at creation; the returned
|
|
55
61
|
* row carries a `secretRef` pointer instead of the plaintext.
|
|
62
|
+
*
|
|
63
|
+
* Every method accepts an optional trailing `AbortSignal` to cancel the
|
|
64
|
+
* in-flight request — useful when a calling framework tears down a session
|
|
65
|
+
* mid-call.
|
|
56
66
|
*/
|
|
57
67
|
export declare class AgentTools {
|
|
58
68
|
private readonly http;
|
|
59
69
|
constructor(http: HttpClient);
|
|
60
|
-
list(agentId: string): Promise<AgentToolRow[]>;
|
|
61
|
-
create(agentId: string, params: AgentToolCreateParams): Promise<AgentToolRow>;
|
|
62
|
-
get(agentId: string, toolId: string): Promise<AgentToolRow>;
|
|
63
|
-
update(agentId: string, toolId: string, params: AgentToolUpdateParams): Promise<AgentToolRow>;
|
|
64
|
-
delete(agentId: string, toolId: string): Promise<{
|
|
70
|
+
list(agentId: string, abortSignal?: AbortSignal): Promise<AgentToolRow[]>;
|
|
71
|
+
create(agentId: string, params: AgentToolCreateParams, abortSignal?: AbortSignal): Promise<AgentToolRow>;
|
|
72
|
+
get(agentId: string, toolId: string, abortSignal?: AbortSignal): Promise<AgentToolRow>;
|
|
73
|
+
update(agentId: string, toolId: string, params: AgentToolUpdateParams, abortSignal?: AbortSignal): Promise<AgentToolRow>;
|
|
74
|
+
delete(agentId: string, toolId: string, abortSignal?: AbortSignal): Promise<{
|
|
65
75
|
deleted: boolean;
|
|
66
76
|
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Fetch this agent's registered tools and convert them into the
|
|
79
|
+
* {@link ChatTool}[] shape that {@link Speko.complete} accepts. Handles all
|
|
80
|
+
* four source kinds (`inline`, `webhook`, `builtin`, `integration`) — load
|
|
81
|
+
* once and pass the result straight to `speko.complete({ tools })`.
|
|
82
|
+
*/
|
|
83
|
+
listChatTools(agentId: string, abortSignal?: AbortSignal): Promise<ChatTool[]>;
|
|
67
84
|
}
|
|
68
85
|
//# 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,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AAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;CAIrF"}
|
|
@@ -57,34 +57,78 @@ export class Agents {
|
|
|
57
57
|
detachPhoneNumber(phoneNumberId) {
|
|
58
58
|
return this.http.patch(`/v1/phone-numbers/${encodeURIComponent(phoneNumberId)}`, { agentId: null });
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* List recent calls for an agent. Use `next_cursor` from the returned page
|
|
62
|
+
* as `cursor` to page backward in time.
|
|
63
|
+
*/
|
|
64
|
+
listCalls(agentId, params = {}) {
|
|
65
|
+
const query = new URLSearchParams();
|
|
66
|
+
if (params.limit !== undefined)
|
|
67
|
+
query.set('limit', String(params.limit));
|
|
68
|
+
if (params.cursor)
|
|
69
|
+
query.set('cursor', params.cursor);
|
|
70
|
+
if (params.since)
|
|
71
|
+
query.set('since', params.since);
|
|
72
|
+
const suffix = query.toString() ? `?${query}` : '';
|
|
73
|
+
return this.http.get(`/v1/agents/${encodeURIComponent(agentId)}/calls${suffix}`);
|
|
74
|
+
}
|
|
60
75
|
}
|
|
61
76
|
/**
|
|
62
|
-
* Per-agent tool definitions exposed to the LLM mid-call.
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* `
|
|
77
|
+
* Per-agent tool definitions exposed to the LLM mid-call. Four execution
|
|
78
|
+
* modes: `inline` (caller runs the tool), `webhook` (Speko POSTs to your URL
|
|
79
|
+
* with a Standard-Webhooks signature), `builtin` (Speko-managed tools like
|
|
80
|
+
* `search_knowledge_base`, `transfer_call`, `end_call`), and `integration`
|
|
81
|
+
* (an org-installed Speko app action such as Google Calendar or Slack).
|
|
66
82
|
*
|
|
67
83
|
* Webhook secrets are encrypted server-side at creation; the returned
|
|
68
84
|
* row carries a `secretRef` pointer instead of the plaintext.
|
|
85
|
+
*
|
|
86
|
+
* Every method accepts an optional trailing `AbortSignal` to cancel the
|
|
87
|
+
* in-flight request — useful when a calling framework tears down a session
|
|
88
|
+
* mid-call.
|
|
69
89
|
*/
|
|
70
90
|
export class AgentTools {
|
|
71
91
|
http;
|
|
72
92
|
constructor(http) {
|
|
73
93
|
this.http = http;
|
|
74
94
|
}
|
|
75
|
-
list(agentId) {
|
|
76
|
-
return this.http.get(`/v1/agents/${encodeURIComponent(agentId)}/tools
|
|
95
|
+
list(agentId, abortSignal) {
|
|
96
|
+
return this.http.get(`/v1/agents/${encodeURIComponent(agentId)}/tools`, abortSignal);
|
|
97
|
+
}
|
|
98
|
+
create(agentId, params, abortSignal) {
|
|
99
|
+
return this.http.post(`/v1/agents/${encodeURIComponent(agentId)}/tools`, params, abortSignal);
|
|
77
100
|
}
|
|
78
|
-
|
|
79
|
-
return this.http.
|
|
101
|
+
get(agentId, toolId, abortSignal) {
|
|
102
|
+
return this.http.get(`/v1/agents/${encodeURIComponent(agentId)}/tools/${encodeURIComponent(toolId)}`, abortSignal);
|
|
80
103
|
}
|
|
81
|
-
|
|
82
|
-
return this.http.
|
|
104
|
+
update(agentId, toolId, params, abortSignal) {
|
|
105
|
+
return this.http.patch(`/v1/agents/${encodeURIComponent(agentId)}/tools/${encodeURIComponent(toolId)}`, params, abortSignal);
|
|
83
106
|
}
|
|
84
|
-
|
|
85
|
-
return this.http.
|
|
107
|
+
delete(agentId, toolId, abortSignal) {
|
|
108
|
+
return this.http.delete(`/v1/agents/${encodeURIComponent(agentId)}/tools/${encodeURIComponent(toolId)}`, abortSignal);
|
|
86
109
|
}
|
|
87
|
-
|
|
88
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Fetch this agent's registered tools and convert them into the
|
|
112
|
+
* {@link ChatTool}[] shape that {@link Speko.complete} accepts. Handles all
|
|
113
|
+
* four source kinds (`inline`, `webhook`, `builtin`, `integration`) — load
|
|
114
|
+
* once and pass the result straight to `speko.complete({ tools })`.
|
|
115
|
+
*/
|
|
116
|
+
async listChatTools(agentId, abortSignal) {
|
|
117
|
+
const rows = await this.list(agentId, abortSignal);
|
|
118
|
+
return rows.map(toChatTool);
|
|
89
119
|
}
|
|
90
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Convert a serialized {@link AgentToolRow} into a {@link ChatTool}. The row's
|
|
123
|
+
* `source` is structurally identical to `ChatToolSource` for every kind, so the
|
|
124
|
+
* mapping is a direct passthrough; `executionMode` is derived from `source.kind`.
|
|
125
|
+
*/
|
|
126
|
+
function toChatTool(row) {
|
|
127
|
+
return {
|
|
128
|
+
name: row.name,
|
|
129
|
+
description: row.description,
|
|
130
|
+
parameters: row.parameters,
|
|
131
|
+
executionMode: row.source.kind,
|
|
132
|
+
source: row.source,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import type { CancelScheduledCallbackParams, ScheduledCallback, ScheduledCallbacksListParams } from '../types/index.js';
|
|
3
|
+
export declare class Callbacks {
|
|
4
|
+
private readonly http;
|
|
5
|
+
constructor(http: HttpClient);
|
|
6
|
+
list(params?: ScheduledCallbacksListParams): Promise<{
|
|
7
|
+
callbacks: ScheduledCallback[];
|
|
8
|
+
}>;
|
|
9
|
+
get(callbackId: string): Promise<ScheduledCallback>;
|
|
10
|
+
cancel(callbackId: string, params?: CancelScheduledCallbackParams): Promise<ScheduledCallback>;
|
|
11
|
+
dispatch(callbackId: string): Promise<ScheduledCallback>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=callbacks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callbacks.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/callbacks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,6BAA6B,EAC7B,iBAAiB,EACjB,4BAA4B,EAC7B,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,IAAI,CAAC,MAAM,GAAE,4BAAiC,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,iBAAiB,EAAE,CAAA;KAAE,CAAC;IAS5F,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAInD,MAAM,CACJ,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,6BAAkC,GACzC,OAAO,CAAC,iBAAiB,CAAC;IAO7B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAMzD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export class Callbacks {
|
|
2
|
+
http;
|
|
3
|
+
constructor(http) {
|
|
4
|
+
this.http = http;
|
|
5
|
+
}
|
|
6
|
+
list(params = {}) {
|
|
7
|
+
const query = new URLSearchParams();
|
|
8
|
+
if (params.status)
|
|
9
|
+
query.set('status', params.status);
|
|
10
|
+
if (params.sourceSessionId)
|
|
11
|
+
query.set('source_session_id', params.sourceSessionId);
|
|
12
|
+
if (params.limit !== undefined)
|
|
13
|
+
query.set('limit', String(params.limit));
|
|
14
|
+
const suffix = query.toString() ? `?${query}` : '';
|
|
15
|
+
return this.http.get(`/v1/callbacks${suffix}`);
|
|
16
|
+
}
|
|
17
|
+
get(callbackId) {
|
|
18
|
+
return this.http.get(`/v1/callbacks/${encodeURIComponent(callbackId)}`);
|
|
19
|
+
}
|
|
20
|
+
cancel(callbackId, params = {}) {
|
|
21
|
+
return this.http.post(`/v1/callbacks/${encodeURIComponent(callbackId)}/cancel`, params);
|
|
22
|
+
}
|
|
23
|
+
dispatch(callbackId) {
|
|
24
|
+
return this.http.post(`/v1/callbacks/${encodeURIComponent(callbackId)}/dispatch`, {});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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';
|
|
3
|
+
export declare class Calls {
|
|
4
|
+
private readonly http;
|
|
5
|
+
constructor(http: HttpClient);
|
|
6
|
+
get(callId: string): Promise<CallDetail>;
|
|
7
|
+
events(callId: string): Promise<{
|
|
8
|
+
events: CallEvent[];
|
|
9
|
+
}>;
|
|
10
|
+
report(callId: string): Promise<CallReport>;
|
|
11
|
+
finalizeReport(callId: string, params?: FinalizeCallReportParams): Promise<FinalizeCallReportResult>;
|
|
12
|
+
recording(callId: string): Promise<CallRecording>;
|
|
13
|
+
blindTransfer(callId: string, params: BlindTransferParams): Promise<CallTransfer>;
|
|
14
|
+
warmTransfer(callId: string, params: WarmTransferParams): Promise<CallTransferResponse>;
|
|
15
|
+
completeWarmTransfer(callId: string, transferId: string, params?: CompleteWarmTransferParams): Promise<CallTransfer>;
|
|
16
|
+
cancelWarmTransfer(callId: string, transferId: string, params?: CancelWarmTransferParams): Promise<CallTransferResponse>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=calls.d.ts.map
|
|
@@ -0,0 +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,UAAU,EACV,SAAS,EACT,aAAa,EACb,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,KAAK;IACJ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAIxC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,SAAS,EAAE,CAAA;KAAE,CAAC;IAIxD,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI3C,cAAc,CACZ,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,wBAA6B,GACpC,OAAO,CAAC,wBAAwB,CAAC;IAOpC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIjD,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC;IAOjF,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAOvF,oBAAoB,CAClB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,0BAA+B,GACtC,OAAO,CAAC,YAAY,CAAC;IASxB,kBAAkB,CAChB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,wBAA6B,GACpC,OAAO,CAAC,oBAAoB,CAAC;CAMjC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export class Calls {
|
|
2
|
+
http;
|
|
3
|
+
constructor(http) {
|
|
4
|
+
this.http = http;
|
|
5
|
+
}
|
|
6
|
+
get(callId) {
|
|
7
|
+
return this.http.get(`/v1/calls/${encodeURIComponent(callId)}`);
|
|
8
|
+
}
|
|
9
|
+
events(callId) {
|
|
10
|
+
return this.http.get(`/v1/calls/${encodeURIComponent(callId)}/events`);
|
|
11
|
+
}
|
|
12
|
+
report(callId) {
|
|
13
|
+
return this.http.get(`/v1/calls/${encodeURIComponent(callId)}/report`);
|
|
14
|
+
}
|
|
15
|
+
finalizeReport(callId, params = {}) {
|
|
16
|
+
return this.http.post(`/v1/calls/${encodeURIComponent(callId)}/report/finalize`, params);
|
|
17
|
+
}
|
|
18
|
+
recording(callId) {
|
|
19
|
+
return this.http.get(`/v1/calls/${encodeURIComponent(callId)}/recording`);
|
|
20
|
+
}
|
|
21
|
+
blindTransfer(callId, params) {
|
|
22
|
+
return this.http.post(`/v1/calls/${encodeURIComponent(callId)}/transfers/blind`, params);
|
|
23
|
+
}
|
|
24
|
+
warmTransfer(callId, params) {
|
|
25
|
+
return this.http.post(`/v1/calls/${encodeURIComponent(callId)}/transfers/warm`, params);
|
|
26
|
+
}
|
|
27
|
+
completeWarmTransfer(callId, transferId, params = {}) {
|
|
28
|
+
return this.http.post(`/v1/calls/${encodeURIComponent(callId)}/transfers/${encodeURIComponent(transferId)}/complete`, params);
|
|
29
|
+
}
|
|
30
|
+
cancelWarmTransfer(callId, transferId, params = {}) {
|
|
31
|
+
return this.http.post(`/v1/calls/${encodeURIComponent(callId)}/transfers/${encodeURIComponent(transferId)}/cancel`, params);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -5,7 +5,7 @@ export declare class Complete {
|
|
|
5
5
|
constructor(http: HttpClient);
|
|
6
6
|
/**
|
|
7
7
|
* Run an LLM completion. The Speko router picks the best provider for your
|
|
8
|
-
* `(language, optimizeFor)` and falls over automatically.
|
|
8
|
+
* `(language, region, optimizeFor)` and falls over automatically.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"complete.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/complete.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"complete.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/complete.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7F,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;;;OAWG;IACG,IAAI,CAAC,MAAM,EAAE,cAAc,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC;IAuB/E,MAAM,CACX,MAAM,EAAE,cAAc,EACtB,WAAW,CAAC,EAAE,WAAW,GACxB,qBAAqB,CAAC,mBAAmB,CAAC;CAiB9C"}
|
|
@@ -6,7 +6,7 @@ export class Complete {
|
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Run an LLM completion. The Speko router picks the best provider for your
|
|
9
|
-
* `(language, optimizeFor)` and falls over automatically.
|
|
9
|
+
* `(language, region, optimizeFor)` and falls over automatically.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
@@ -40,8 +40,14 @@ export class Complete {
|
|
|
40
40
|
return done;
|
|
41
41
|
}
|
|
42
42
|
async *stream(params, abortSignal) {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const { sessionId, ...body } = params;
|
|
44
|
+
const trimmedSessionId = sessionId?.trim();
|
|
45
|
+
const headers = trimmedSessionId ? { 'x-session-id': trimmedSessionId } : undefined;
|
|
46
|
+
for await (const event of this.http.requestSse('POST', '/v1/complete', body, abortSignal, headers)) {
|
|
47
|
+
yield {
|
|
48
|
+
...event.data,
|
|
49
|
+
type: event.event,
|
|
50
|
+
};
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credits.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/credits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;OAQG;IACH,UAAU,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAI1C;;;;;OAKG;IACH,SAAS,CAAC,MAAM,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"credits.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/credits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;OAQG;IACH,UAAU,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAI1C;;;;;OAKG;IACH,SAAS,CAAC,MAAM,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAQvE"}
|
|
@@ -17,7 +17,7 @@ import type { KnowledgeBaseCreateParams, KnowledgeBaseDocumentCreateParams, Know
|
|
|
17
17
|
* const doc = await speko.knowledgeBases.uploadDocument(kb.id, {
|
|
18
18
|
* filename: 'faq.md',
|
|
19
19
|
* contentType: 'text/markdown',
|
|
20
|
-
* data: await
|
|
20
|
+
* data: await readFile('faq.md'),
|
|
21
21
|
* });
|
|
22
22
|
*
|
|
23
23
|
* const ready = await speko.knowledgeBases.pollDocumentReady(kb.id, doc.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-bases.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/knowledge-bases.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"knowledge-bases.d.ts","sourceRoot":"","sources":["../../../src/lib/resources/knowledge-bases.ts"],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