@craftedxp/sdk-node 0.12.0 → 0.16.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/README.md +107 -13
- package/dist/index.d.mts +229 -28
- package/dist/index.d.ts +229 -28
- package/dist/index.js +140 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +139 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,16 @@ type TtsProvider = 'pockettts' | 'cartesia' | 'fish-audio' | 'gemini' | 'kokoro'
|
|
|
31
31
|
type SttProvider = 'deepgram';
|
|
32
32
|
type LlmProvider = 'gemini' | 'openai' | 'anthropic';
|
|
33
33
|
type EndpointingMode = 'smart' | 'simple';
|
|
34
|
+
/**
|
|
35
|
+
* Agent kind. Set at creation and immutable thereafter — changing what an
|
|
36
|
+
* agent does means creating a new one. Gates which routes accept the agent:
|
|
37
|
+
* - `assistant` — 1:1 voice + text chat + learning mode (LLM + STT + TTS)
|
|
38
|
+
* - `room` — hosts LiveKit rooms; per-speaker transcription + analysis
|
|
39
|
+
* - `transcribe` — 1:1 dictation, STT-only (the agent never speaks)
|
|
40
|
+
*
|
|
41
|
+
* Replaces the legacy `canHostRooms` / `transcribeOnly` boolean flags.
|
|
42
|
+
*/
|
|
43
|
+
type AgentType = 'assistant' | 'room' | 'transcribe';
|
|
34
44
|
interface AgentVoice {
|
|
35
45
|
provider: TtsProvider;
|
|
36
46
|
voiceId?: string;
|
|
@@ -109,6 +119,8 @@ interface AgentRecording {
|
|
|
109
119
|
interface Agent {
|
|
110
120
|
agentId: string;
|
|
111
121
|
orgId: string;
|
|
122
|
+
/** Agent kind — see {@link AgentType}. Immutable after creation. */
|
|
123
|
+
type: AgentType;
|
|
112
124
|
name: string;
|
|
113
125
|
systemPrompt: string;
|
|
114
126
|
/**
|
|
@@ -119,6 +131,8 @@ interface Agent {
|
|
|
119
131
|
* caller speaks first.
|
|
120
132
|
*/
|
|
121
133
|
agentSpeaksFirst?: boolean;
|
|
134
|
+
/** Personal assistant (`assistant` agents only) — the learning tools are live on every `ct_`-token call, not just `mode=learning`. */
|
|
135
|
+
isPersonal?: boolean;
|
|
122
136
|
voice: AgentVoice;
|
|
123
137
|
transcriber: AgentTranscriber;
|
|
124
138
|
model: AgentModel;
|
|
@@ -151,19 +165,22 @@ interface Agent {
|
|
|
151
165
|
* right gateway.
|
|
152
166
|
*/
|
|
153
167
|
transport?: 'ws' | 'webrtc';
|
|
154
|
-
/**
|
|
155
|
-
canHostRooms?: boolean;
|
|
156
|
-
/** Room operating mode (`'notes-only'` today). */
|
|
168
|
+
/** Room operating mode (`'notes-only'` today). Only set on `type: 'room'` agents. */
|
|
157
169
|
roomMode?: 'notes-only';
|
|
158
|
-
/** Transcribe-only mode — the agent listens but never speaks. */
|
|
159
|
-
transcribeOnly?: boolean;
|
|
160
170
|
createdAt: number;
|
|
161
171
|
updatedAt: number;
|
|
162
172
|
}
|
|
163
173
|
interface AgentCreateInput {
|
|
174
|
+
/**
|
|
175
|
+
* Agent kind — see {@link AgentType}. Required and immutable: it cannot be
|
|
176
|
+
* changed via {@link AgentUpdateInput} (it is omitted from that type).
|
|
177
|
+
*/
|
|
178
|
+
type: AgentType;
|
|
164
179
|
name: string;
|
|
165
180
|
systemPrompt: string;
|
|
166
181
|
agentSpeaksFirst?: boolean;
|
|
182
|
+
/** Personal assistant (`assistant` agents only) — the learning tools are live on every `ct_`-token call, not just `mode=learning`. */
|
|
183
|
+
isPersonal?: boolean;
|
|
167
184
|
voice?: AgentVoice;
|
|
168
185
|
transcriber?: AgentTranscriber;
|
|
169
186
|
model?: AgentModel;
|
|
@@ -185,26 +202,18 @@ interface AgentCreateInput {
|
|
|
185
202
|
*/
|
|
186
203
|
avatarUrl?: string;
|
|
187
204
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Room operating mode. Today only `'notes-only'` exists — the agent listens
|
|
194
|
-
* and takes structured notes without speaking. A literal union so future
|
|
195
|
-
* modes can be added without breaking the wire.
|
|
205
|
+
* Room operating mode. Only valid on `type: 'room'` agents. Today only
|
|
206
|
+
* `'notes-only'` exists — the agent listens and takes structured notes
|
|
207
|
+
* without speaking. A literal union so future modes can be added without
|
|
208
|
+
* breaking the wire.
|
|
196
209
|
*/
|
|
197
210
|
roomMode?: 'notes-only';
|
|
198
|
-
/**
|
|
199
|
-
* Transcribe-only mode. When `true`, the agent listens but never speaks: no
|
|
200
|
-
* TTS/LLM, no greeting, idle nudges suppressed, user turns are not routed
|
|
201
|
-
* through the LLM — an STT-only loop that streams `transcript` data-messages
|
|
202
|
-
* back to the caller. `voice` stays required by the schema (defaults apply)
|
|
203
|
-
* but is never read at runtime.
|
|
204
|
-
*/
|
|
205
|
-
transcribeOnly?: boolean;
|
|
206
211
|
}
|
|
207
|
-
|
|
212
|
+
/**
|
|
213
|
+
* Patch shape for `agents.update`. `type` is immutable, so it is omitted
|
|
214
|
+
* here — to change an agent's kind, create a new agent.
|
|
215
|
+
*/
|
|
216
|
+
type AgentUpdateInput = Partial<Omit<AgentCreateInput, 'type'>>;
|
|
208
217
|
/**
|
|
209
218
|
* Trimmed agent shape returned by the consumer catalog
|
|
210
219
|
* (`GET /v1/orgs/:orgId/agents`). Operator-only fields like
|
|
@@ -390,9 +399,9 @@ interface CallTokenMintInput {
|
|
|
390
399
|
initiatedBy?: 'user' | 'agent';
|
|
391
400
|
/**
|
|
392
401
|
* Session channel selector. `voice` (default) routes to WS/WebRTC audio;
|
|
393
|
-
* `text` routes to HTTP+SSE chat via the `chats` resource.
|
|
394
|
-
*
|
|
395
|
-
* is
|
|
402
|
+
* `text` routes to HTTP+SSE chat via the `chats` resource. `text` requires
|
|
403
|
+
* a `type: 'assistant'` agent; non-assistant agents are rejected at mint
|
|
404
|
+
* (`wrong_agent_type`), as is `mode: 'learning'` on a non-assistant agent.
|
|
396
405
|
*/
|
|
397
406
|
channel?: 'voice' | 'text';
|
|
398
407
|
/**
|
|
@@ -400,6 +409,14 @@ interface CallTokenMintInput {
|
|
|
400
409
|
* (admin-bypass only) flags a self-learning session — see Phase 19.
|
|
401
410
|
*/
|
|
402
411
|
mode?: 'standard' | 'learning';
|
|
412
|
+
/**
|
|
413
|
+
* Operator-only: stream diagnostic frames (`tool_call`, `tool_result`,
|
|
414
|
+
* `phase_marker`, `prefetch*`) to this call's client. Requires
|
|
415
|
+
* Firebase-admin auth or an `sk_` key — silently stripped (not an error)
|
|
416
|
+
* for untrusted mints (public/anonymous paths). Default `false`. Stored
|
|
417
|
+
* on the token server-side; NOT echoed back in the mint response.
|
|
418
|
+
*/
|
|
419
|
+
debug?: boolean;
|
|
403
420
|
}
|
|
404
421
|
interface CallTokenMintResult {
|
|
405
422
|
tokenId: string;
|
|
@@ -437,7 +454,7 @@ interface CallTokenSummary {
|
|
|
437
454
|
revoked: boolean;
|
|
438
455
|
allowedOrigins?: string[];
|
|
439
456
|
}
|
|
440
|
-
type PlatformEventName = 'call.started' | 'call.ended' | 'transcript.updated' | 'call.summary.ready' | 'tool.call.requested' | 'tool.call.completed' | 'tool.call.failed' | 'credits.low';
|
|
457
|
+
type PlatformEventName = 'call.started' | 'call.ended' | 'transcript.updated' | 'call.summary.ready' | 'tool.call.requested' | 'tool.call.completed' | 'tool.call.failed' | 'credits.low' | 'speech.ready' | 'speech.failed';
|
|
441
458
|
interface WebhookConfig {
|
|
442
459
|
webhookId: string;
|
|
443
460
|
orgId: string;
|
|
@@ -491,6 +508,17 @@ interface CreateRoomInput {
|
|
|
491
508
|
agentId: string;
|
|
492
509
|
/** 1..240 — enforced by the server. */
|
|
493
510
|
durationMin: number;
|
|
511
|
+
/**
|
|
512
|
+
* Document references forwarded to the room analyzer. Each `docId` is an
|
|
513
|
+
* analysis document (`adoc_…`) uploaded via `POST /v1/analysis-docs` (NOT a
|
|
514
|
+
* knowledge-base file), tagged with an optional semantic role (e.g. `'jd'`,
|
|
515
|
+
* `'cv'`); the worker loads the full text and injects it into the analyzer.
|
|
516
|
+
* Omit when the room agent uses its default analysis behaviour.
|
|
517
|
+
*/
|
|
518
|
+
analysisContext?: Array<{
|
|
519
|
+
docId: string;
|
|
520
|
+
role?: string;
|
|
521
|
+
}>;
|
|
494
522
|
}
|
|
495
523
|
interface CreateRoomResponse {
|
|
496
524
|
roomId: string;
|
|
@@ -553,6 +581,24 @@ interface ListUtterancesResponse {
|
|
|
553
581
|
utterances: UtteranceWire[];
|
|
554
582
|
nextCursor: string | null;
|
|
555
583
|
}
|
|
584
|
+
interface AnalysisWire {
|
|
585
|
+
analysisId: string;
|
|
586
|
+
participantId: string;
|
|
587
|
+
label: string;
|
|
588
|
+
score?: number;
|
|
589
|
+
note?: string;
|
|
590
|
+
createdAt: string;
|
|
591
|
+
/**
|
|
592
|
+
* Which producer emitted this result: `'summary'` | `'rated_dimensions'` |
|
|
593
|
+
* `'suggested_questions'`. Set by the worker on every result it produces;
|
|
594
|
+
* absent only on legacy analysis entries written before producers existed.
|
|
595
|
+
*/
|
|
596
|
+
producer?: string;
|
|
597
|
+
}
|
|
598
|
+
interface ListAnalysisResponse {
|
|
599
|
+
analysis: AnalysisWire[];
|
|
600
|
+
nextCursor: string | null;
|
|
601
|
+
}
|
|
556
602
|
/** Returned by host-action endpoints (`/end` and friends) — 202 + eventId so
|
|
557
603
|
* callers can correlate the async system-message broadcast that follows. */
|
|
558
604
|
interface RoomEventAck {
|
|
@@ -589,6 +635,105 @@ type ChatEvent = {
|
|
|
589
635
|
code: string;
|
|
590
636
|
message: string;
|
|
591
637
|
};
|
|
638
|
+
type SpaceKind = 'audio' | 'video';
|
|
639
|
+
type RecordingMode = 'off' | 'host-source' | 'composite';
|
|
640
|
+
interface RecordingConfig {
|
|
641
|
+
mode: RecordingMode;
|
|
642
|
+
maxMinutesPerSession?: number;
|
|
643
|
+
audioOnly?: boolean;
|
|
644
|
+
}
|
|
645
|
+
/** The redacted space shape the server returns (`toSpaceView`). */
|
|
646
|
+
interface SpaceView {
|
|
647
|
+
spaceId: string;
|
|
648
|
+
agentId: string;
|
|
649
|
+
/** Stable human-friendly join code, e.g. `abc-defg-hij`. */
|
|
650
|
+
code: string;
|
|
651
|
+
kind: SpaceKind;
|
|
652
|
+
notesEnabled: boolean;
|
|
653
|
+
lobbyEnabled: boolean;
|
|
654
|
+
recording: RecordingConfig;
|
|
655
|
+
active: boolean;
|
|
656
|
+
currentSessionId: string | null;
|
|
657
|
+
sessionCount: number;
|
|
658
|
+
createdAt: string;
|
|
659
|
+
updatedAt: string;
|
|
660
|
+
}
|
|
661
|
+
interface CreateSpaceInput {
|
|
662
|
+
agentId: string;
|
|
663
|
+
/** Defaults to `video` server-side. */
|
|
664
|
+
kind?: SpaceKind;
|
|
665
|
+
/** Defaults to `true` server-side. */
|
|
666
|
+
notesEnabled?: boolean;
|
|
667
|
+
/** Defaults to `false` server-side. */
|
|
668
|
+
lobbyEnabled?: boolean;
|
|
669
|
+
recording?: RecordingConfig;
|
|
670
|
+
}
|
|
671
|
+
/** At least one field is required — the server rejects an empty patch. */
|
|
672
|
+
interface SpacePatch {
|
|
673
|
+
notesEnabled?: boolean;
|
|
674
|
+
lobbyEnabled?: boolean;
|
|
675
|
+
active?: boolean;
|
|
676
|
+
recording?: RecordingConfig;
|
|
677
|
+
}
|
|
678
|
+
interface ListSpacesResponse {
|
|
679
|
+
data: SpaceView[];
|
|
680
|
+
}
|
|
681
|
+
interface SpeechSynthesizeInput {
|
|
682
|
+
agentId: string;
|
|
683
|
+
text?: string;
|
|
684
|
+
context?: Record<string, unknown>;
|
|
685
|
+
instructions?: string;
|
|
686
|
+
format?: 'mp3' | 'wav' | 'ogg';
|
|
687
|
+
sampleRate?: 16000 | 24000 | 48000;
|
|
688
|
+
idempotencyKey?: string;
|
|
689
|
+
userTags?: string[];
|
|
690
|
+
ttlSeconds?: number;
|
|
691
|
+
metadata?: Record<string, string>;
|
|
692
|
+
}
|
|
693
|
+
interface SpeechAsset {
|
|
694
|
+
id: string;
|
|
695
|
+
status: 'ready';
|
|
696
|
+
url: string;
|
|
697
|
+
expiresAt: string;
|
|
698
|
+
durationMs: number;
|
|
699
|
+
bytes: number;
|
|
700
|
+
format: 'mp3' | 'wav' | 'ogg';
|
|
701
|
+
sampleRate: number;
|
|
702
|
+
text: string;
|
|
703
|
+
agentId: string;
|
|
704
|
+
idempotencyKey?: string;
|
|
705
|
+
metadata?: Record<string, string>;
|
|
706
|
+
createdAt: string;
|
|
707
|
+
}
|
|
708
|
+
interface SpeechJob {
|
|
709
|
+
id: string;
|
|
710
|
+
status: 'queued' | 'processing' | 'failed';
|
|
711
|
+
error?: {
|
|
712
|
+
code: string;
|
|
713
|
+
message: string;
|
|
714
|
+
};
|
|
715
|
+
idempotencyKey?: string;
|
|
716
|
+
metadata?: Record<string, string>;
|
|
717
|
+
createdAt: string;
|
|
718
|
+
}
|
|
719
|
+
interface SpeechListInput {
|
|
720
|
+
idempotencyKeyPrefix?: string;
|
|
721
|
+
status?: 'queued' | 'processing' | 'ready' | 'failed';
|
|
722
|
+
limit?: number;
|
|
723
|
+
cursor?: string;
|
|
724
|
+
}
|
|
725
|
+
interface SpeechReadyEvent {
|
|
726
|
+
event: 'speech.ready';
|
|
727
|
+
timestamp: string;
|
|
728
|
+
orgId: string;
|
|
729
|
+
data: SpeechAsset;
|
|
730
|
+
}
|
|
731
|
+
interface SpeechFailedEvent {
|
|
732
|
+
event: 'speech.failed';
|
|
733
|
+
timestamp: string;
|
|
734
|
+
orgId: string;
|
|
735
|
+
data: SpeechJob;
|
|
736
|
+
}
|
|
592
737
|
|
|
593
738
|
declare const createMeResource: (http: HttpClient) => {
|
|
594
739
|
get: () => Promise<MeResponse>;
|
|
@@ -730,10 +875,38 @@ declare const createRoomsResource: (http: HttpClient) => {
|
|
|
730
875
|
list: (filters?: RoomListFilters) => Promise<ListRoomsResponse>;
|
|
731
876
|
get: (roomId: string) => Promise<RoomDoc>;
|
|
732
877
|
transcript: (roomId: string, opts?: RoomTranscriptOptions) => Promise<ListUtterancesResponse>;
|
|
878
|
+
analysis: (roomId: string, opts?: RoomTranscriptOptions) => Promise<ListAnalysisResponse>;
|
|
733
879
|
end: (roomId: string) => Promise<RoomEventAck>;
|
|
734
880
|
};
|
|
735
881
|
type RoomsResource = ReturnType<typeof createRoomsResource>;
|
|
736
882
|
|
|
883
|
+
type JoinUrlStyle = 'query' | 'path';
|
|
884
|
+
interface BuildJoinUrlOptions {
|
|
885
|
+
/** Required — the developer's own page that renders <VoiceRoom/>. Absolute URL. */
|
|
886
|
+
baseUrl: string;
|
|
887
|
+
/** 'query' (default) → ?code=… · 'path' → /… */
|
|
888
|
+
style?: JoinUrlStyle;
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Build a participant join URL on the DEVELOPER's domain from a space (or a
|
|
892
|
+
* raw code). White-label: the returned URL never points at a voissia origin —
|
|
893
|
+
* `baseUrl` is required and supplied by the caller.
|
|
894
|
+
*
|
|
895
|
+
* The default `query` style appends `?code=<code>`, matching how
|
|
896
|
+
* `<VoiceRoom/>` (and the example app) read the code from the URL.
|
|
897
|
+
*/
|
|
898
|
+
declare const buildJoinUrl: (spaceOrCode: SpaceView | string, opts: BuildJoinUrlOptions) => string;
|
|
899
|
+
|
|
900
|
+
declare const createSpacesResource: (http: HttpClient) => {
|
|
901
|
+
create: (input: CreateSpaceInput) => Promise<SpaceView>;
|
|
902
|
+
get: (spaceId: string) => Promise<SpaceView>;
|
|
903
|
+
list: () => Promise<ListSpacesResponse>;
|
|
904
|
+
update: (spaceId: string, patch: SpacePatch) => Promise<SpaceView>;
|
|
905
|
+
delete: (spaceId: string) => Promise<void>;
|
|
906
|
+
joinUrl: (spaceOrCode: SpaceView | string, opts: BuildJoinUrlOptions) => string;
|
|
907
|
+
};
|
|
908
|
+
type SpacesResource = ReturnType<typeof createSpacesResource>;
|
|
909
|
+
|
|
737
910
|
interface StartChatInput {
|
|
738
911
|
agentId: string;
|
|
739
912
|
text?: string;
|
|
@@ -759,6 +932,32 @@ declare const createChatsResource: (http: HttpClient, callToken: string) => {
|
|
|
759
932
|
};
|
|
760
933
|
type ChatsResource = ReturnType<typeof createChatsResource>;
|
|
761
934
|
|
|
935
|
+
declare const createSpeechResource: (http: HttpClient) => {
|
|
936
|
+
/**
|
|
937
|
+
* Synchronous. Resolves with the ready asset. Throws PlatformError
|
|
938
|
+
* code 'accepted' (status 202, `body` = SpeechJob) when the server hands
|
|
939
|
+
* the job to the queue instead — poll `get(job.id)` or wait for the
|
|
940
|
+
* `speech.ready` webhook.
|
|
941
|
+
*/
|
|
942
|
+
synthesize: (input: SpeechSynthesizeInput) => Promise<SpeechAsset>;
|
|
943
|
+
/**
|
|
944
|
+
* Asynchronous. Normally returns a queued/processing SpeechJob —
|
|
945
|
+
* completion arrives via the `speech.ready` / `speech.failed` webhook or
|
|
946
|
+
* a later `get(job.id)`. Exception: when `idempotencyKey` matches an
|
|
947
|
+
* existing *ready* asset, the server short-circuits the queue hop and
|
|
948
|
+
* responds 200 with that SpeechAsset directly instead of 202.
|
|
949
|
+
*/
|
|
950
|
+
enqueue: (input: SpeechSynthesizeInput) => Promise<SpeechJob | SpeechAsset>;
|
|
951
|
+
get: (id: string) => Promise<SpeechAsset | SpeechJob>;
|
|
952
|
+
list: (input?: SpeechListInput) => Promise<{
|
|
953
|
+
items: Array<SpeechAsset | SpeechJob>;
|
|
954
|
+
cursor?: string;
|
|
955
|
+
}>;
|
|
956
|
+
/** Idempotent. Deleting a ready asset invalidates its URL immediately. */
|
|
957
|
+
delete: (id: string) => Promise<void>;
|
|
958
|
+
};
|
|
959
|
+
type SpeechResource = ReturnType<typeof createSpeechResource>;
|
|
960
|
+
|
|
762
961
|
interface PlatformClientOptions {
|
|
763
962
|
apiKey: string;
|
|
764
963
|
baseUrl?: string;
|
|
@@ -777,6 +976,8 @@ declare class PlatformClient {
|
|
|
777
976
|
readonly webhooks: WebhooksResource;
|
|
778
977
|
readonly orgs: OrgsResource;
|
|
779
978
|
readonly rooms: RoomsResource;
|
|
979
|
+
readonly spaces: SpacesResource;
|
|
980
|
+
readonly speech: SpeechResource;
|
|
780
981
|
private readonly _http;
|
|
781
982
|
constructor(options: PlatformClientOptions);
|
|
782
983
|
/**
|
|
@@ -791,7 +992,7 @@ declare class PlatformClient {
|
|
|
791
992
|
chatsFor(callToken: string): ChatsResource;
|
|
792
993
|
}
|
|
793
994
|
|
|
794
|
-
type ApiErrorCode = 'unauthorized' | 'forbidden' | 'not_found' | 'bad_request' | 'conflict' | 'rate_limited' | 'payment_required' | 'internal_error' | 'unknown';
|
|
995
|
+
type ApiErrorCode = 'unauthorized' | 'forbidden' | 'not_found' | 'bad_request' | 'conflict' | 'rate_limited' | 'payment_required' | 'internal_error' | 'accepted' | 'service_unavailable' | 'unknown';
|
|
795
996
|
declare class PlatformError extends Error {
|
|
796
997
|
readonly code: ApiErrorCode;
|
|
797
998
|
readonly status: number;
|
|
@@ -811,4 +1012,4 @@ declare class PlatformError extends Error {
|
|
|
811
1012
|
|
|
812
1013
|
declare const verifyWebhookSignature: (rawBody: Buffer | string, signatureHeader: string, secret: string) => boolean;
|
|
813
1014
|
|
|
814
|
-
export { type Agent, type AgentCreateInput, type AgentEndpointing, type AgentHttpTool, type AgentModel, type AgentRecording, type AgentTool, type AgentTranscriber, type AgentUpdateInput, type AgentVoice, type AgentWebhooksResource, type AgentsResource, type ApiErrorCode, type CallListFilters, type CallRecord, type CallRecordingUrlResponse, type CallStatus, type CallSummary, type CallTokenMintInput, type CallTokenMintResult, type CallTokenSummary, type CallTokensResource, type CallsResource, type CatalogAgent, type CatalogListInput, type Chat, type ChatEvent, type ChatsResource, type CostBreakdown, type CreateRoomInput, type CreateRoomResponse, type CreditsResource, type EndReason, type EndpointingMode, type GuestRole, type KnowledgeBase, type KnowledgeBaseFile, type KnowledgeBasesResource, type LedgerEntry, type ListRoomsResponse, type ListUtterancesResponse, type LlmProvider, type MeResource, type MeResponse, type OrgsResource, PlatformClient, type PlatformClientOptions, PlatformError, type PlatformEventName, type RecordingMeta, type RoomDoc, type RoomEndReason, type RoomEventAck, type RoomListFilters, type RoomMetricsWire, type RoomStatus, type RoomTranscriptOptions, type RoomsResource, type StartChatInput, type SttProvider, type TranscriptTurn, type TtsProvider, type UtteranceWire, type WebhookConfig, type WebhookCreateInput, type WebhookDelivery, type WebhookUpdateInput, type WebhooksResource, type WorkerStatus, verifyWebhookSignature };
|
|
1015
|
+
export { type Agent, type AgentCreateInput, type AgentEndpointing, type AgentHttpTool, type AgentModel, type AgentRecording, type AgentTool, type AgentTranscriber, type AgentType, type AgentUpdateInput, type AgentVoice, type AgentWebhooksResource, type AgentsResource, type AnalysisWire, type ApiErrorCode, type BuildJoinUrlOptions, type CallListFilters, type CallRecord, type CallRecordingUrlResponse, type CallStatus, type CallSummary, type CallTokenMintInput, type CallTokenMintResult, type CallTokenSummary, type CallTokensResource, type CallsResource, type CatalogAgent, type CatalogListInput, type Chat, type ChatEvent, type ChatsResource, type CostBreakdown, type CreateRoomInput, type CreateRoomResponse, type CreateSpaceInput, type CreditsResource, type EndReason, type EndpointingMode, type GuestRole, type JoinUrlStyle, type KnowledgeBase, type KnowledgeBaseFile, type KnowledgeBasesResource, type LedgerEntry, type ListAnalysisResponse, type ListRoomsResponse, type ListSpacesResponse, type ListUtterancesResponse, type LlmProvider, type MeResource, type MeResponse, type OrgsResource, PlatformClient, type PlatformClientOptions, PlatformError, type PlatformEventName, type RecordingConfig, type RecordingMeta, type RecordingMode, type RoomDoc, type RoomEndReason, type RoomEventAck, type RoomListFilters, type RoomMetricsWire, type RoomStatus, type RoomTranscriptOptions, type RoomsResource, type SpaceKind, type SpacePatch, type SpaceView, type SpacesResource, type SpeechAsset, type SpeechFailedEvent, type SpeechJob, type SpeechListInput, type SpeechReadyEvent, type SpeechResource, type SpeechSynthesizeInput, type StartChatInput, type SttProvider, type TranscriptTurn, type TtsProvider, type UtteranceWire, type WebhookConfig, type WebhookCreateInput, type WebhookDelivery, type WebhookUpdateInput, type WebhooksResource, type WorkerStatus, buildJoinUrl, verifyWebhookSignature };
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
PlatformClient: () => PlatformClient,
|
|
34
34
|
PlatformError: () => PlatformError,
|
|
35
|
+
buildJoinUrl: () => buildJoinUrl,
|
|
35
36
|
verifyWebhookSignature: () => verifyWebhookSignature
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -599,6 +600,19 @@ var createRoomsResource = (http) => ({
|
|
|
599
600
|
query
|
|
600
601
|
});
|
|
601
602
|
},
|
|
603
|
+
// Analysis pages — analyzer results ordered by createdAt asc. Auth-only
|
|
604
|
+
// (org-scoped); there is no public token-gated variant. Cursor is an ISO
|
|
605
|
+
// timestamp the server enforces — don't construct it yourself.
|
|
606
|
+
analysis: async (roomId, opts = {}) => {
|
|
607
|
+
const query = {};
|
|
608
|
+
if (opts.cursor) query.cursor = opts.cursor;
|
|
609
|
+
if (opts.limit !== void 0) query.limit = opts.limit;
|
|
610
|
+
return http.request({
|
|
611
|
+
method: "GET",
|
|
612
|
+
path: `/v1/rooms/${roomId}/analysis`,
|
|
613
|
+
query
|
|
614
|
+
});
|
|
615
|
+
},
|
|
602
616
|
// End a room — async on the server: returns 202 + eventId once the
|
|
603
617
|
// controlEvents entry is written. The room-worker observes the entry,
|
|
604
618
|
// broadcasts the system message, and tears down LiveKit shortly after.
|
|
@@ -608,6 +622,63 @@ var createRoomsResource = (http) => ({
|
|
|
608
622
|
})
|
|
609
623
|
});
|
|
610
624
|
|
|
625
|
+
// src/joinUrl.ts
|
|
626
|
+
var buildJoinUrl = (spaceOrCode, opts) => {
|
|
627
|
+
const code = typeof spaceOrCode === "string" ? spaceOrCode : spaceOrCode.code;
|
|
628
|
+
if (!code) throw new Error("a space code is required");
|
|
629
|
+
const base = opts.baseUrl?.trim();
|
|
630
|
+
if (!base) throw new Error("baseUrl is required");
|
|
631
|
+
let url;
|
|
632
|
+
try {
|
|
633
|
+
url = new URL(base);
|
|
634
|
+
} catch {
|
|
635
|
+
throw new Error("baseUrl must be an absolute URL (e.g. https://app.example.com/room)");
|
|
636
|
+
}
|
|
637
|
+
if ((opts.style ?? "query") === "path") {
|
|
638
|
+
url.pathname = `${url.pathname.replace(/\/+$/, "")}/${encodeURIComponent(code)}`;
|
|
639
|
+
} else {
|
|
640
|
+
url.searchParams.set("code", code);
|
|
641
|
+
}
|
|
642
|
+
return url.toString();
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
// src/resources/spaces.ts
|
|
646
|
+
var createSpacesResource = (http) => ({
|
|
647
|
+
// Create a durable space. Server returns 201 with the SpaceView, including a
|
|
648
|
+
// stable `code` participants join with. Pass it to `joinUrl` (or the
|
|
649
|
+
// standalone `buildJoinUrl`) to make a link on YOUR domain.
|
|
650
|
+
create: async (input) => http.request({
|
|
651
|
+
method: "POST",
|
|
652
|
+
path: "/v1/spaces",
|
|
653
|
+
body: input
|
|
654
|
+
}),
|
|
655
|
+
get: async (spaceId) => http.request({
|
|
656
|
+
method: "GET",
|
|
657
|
+
path: `/v1/spaces/${spaceId}`
|
|
658
|
+
}),
|
|
659
|
+
// List every space for the org. Plain `{ data: [...] }` — no cursor.
|
|
660
|
+
list: async () => http.request({
|
|
661
|
+
method: "GET",
|
|
662
|
+
path: "/v1/spaces"
|
|
663
|
+
}),
|
|
664
|
+
// Patch a space. The server rejects an empty patch — pass at least one field.
|
|
665
|
+
update: async (spaceId, patch) => http.request({
|
|
666
|
+
method: "PATCH",
|
|
667
|
+
path: `/v1/spaces/${spaceId}`,
|
|
668
|
+
body: patch
|
|
669
|
+
}),
|
|
670
|
+
// Delete a space. Resolves once the server returns 204.
|
|
671
|
+
delete: async (spaceId) => {
|
|
672
|
+
await http.request({
|
|
673
|
+
method: "DELETE",
|
|
674
|
+
path: `/v1/spaces/${spaceId}`
|
|
675
|
+
});
|
|
676
|
+
},
|
|
677
|
+
// Convenience: build a participant join URL on your domain from a space (or
|
|
678
|
+
// raw code). Delegates to the standalone `buildJoinUrl` export.
|
|
679
|
+
joinUrl: (spaceOrCode, opts) => buildJoinUrl(spaceOrCode, opts)
|
|
680
|
+
});
|
|
681
|
+
|
|
611
682
|
// src/resources/chats.ts
|
|
612
683
|
var createChatsResource = (http, callToken) => ({
|
|
613
684
|
async start(input) {
|
|
@@ -653,6 +724,70 @@ async function* replayThen(buffered, rest) {
|
|
|
653
724
|
for await (const x of rest) yield x;
|
|
654
725
|
}
|
|
655
726
|
|
|
727
|
+
// src/resources/speech.ts
|
|
728
|
+
var SYNTHESIZE_TIMEOUT_MS = 9e4;
|
|
729
|
+
var createSpeechResource = (http) => {
|
|
730
|
+
const speech = {
|
|
731
|
+
/**
|
|
732
|
+
* Synchronous. Resolves with the ready asset. Throws PlatformError
|
|
733
|
+
* code 'accepted' (status 202, `body` = SpeechJob) when the server hands
|
|
734
|
+
* the job to the queue instead — poll `get(job.id)` or wait for the
|
|
735
|
+
* `speech.ready` webhook.
|
|
736
|
+
*/
|
|
737
|
+
synthesize: async (input) => {
|
|
738
|
+
const res = await http.request({
|
|
739
|
+
method: "POST",
|
|
740
|
+
path: "/v1/speech",
|
|
741
|
+
body: input,
|
|
742
|
+
// The server's own sync budget is 60s, after which it hands the job
|
|
743
|
+
// to the queue and answers 202. The default 30s client timeout would
|
|
744
|
+
// abort first — turning a perfectly good handoff into a network
|
|
745
|
+
// error — so give the server room to answer.
|
|
746
|
+
timeoutMs: SYNTHESIZE_TIMEOUT_MS
|
|
747
|
+
});
|
|
748
|
+
if (res.status === "ready") return res;
|
|
749
|
+
if (res.status === "failed") {
|
|
750
|
+
throw new PlatformError({
|
|
751
|
+
code: "internal_error",
|
|
752
|
+
message: res.error?.message ?? "Speech synthesis failed",
|
|
753
|
+
status: 200,
|
|
754
|
+
body: res
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
throw new PlatformError({
|
|
758
|
+
code: "accepted",
|
|
759
|
+
message: `Speech job ${res.id} accepted; poll speech.get() or await the speech.ready webhook`,
|
|
760
|
+
status: 202,
|
|
761
|
+
body: res
|
|
762
|
+
});
|
|
763
|
+
},
|
|
764
|
+
/**
|
|
765
|
+
* Asynchronous. Normally returns a queued/processing SpeechJob —
|
|
766
|
+
* completion arrives via the `speech.ready` / `speech.failed` webhook or
|
|
767
|
+
* a later `get(job.id)`. Exception: when `idempotencyKey` matches an
|
|
768
|
+
* existing *ready* asset, the server short-circuits the queue hop and
|
|
769
|
+
* responds 200 with that SpeechAsset directly instead of 202.
|
|
770
|
+
*/
|
|
771
|
+
enqueue: async (input) => http.request({
|
|
772
|
+
method: "POST",
|
|
773
|
+
path: "/v1/speech",
|
|
774
|
+
query: { async: 1 },
|
|
775
|
+
body: input
|
|
776
|
+
}),
|
|
777
|
+
get: async (id) => http.request({ method: "GET", path: `/v1/speech/${id}` }),
|
|
778
|
+
list: async (input = {}) => http.request({
|
|
779
|
+
method: "GET",
|
|
780
|
+
path: "/v1/speech",
|
|
781
|
+
query: input
|
|
782
|
+
}),
|
|
783
|
+
/** Idempotent. Deleting a ready asset invalidates its URL immediately. */
|
|
784
|
+
delete: async (id) => {
|
|
785
|
+
await http.request({ method: "DELETE", path: `/v1/speech/${id}` });
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
return speech;
|
|
789
|
+
};
|
|
790
|
+
|
|
656
791
|
// src/PlatformClient.ts
|
|
657
792
|
var PlatformClient = class {
|
|
658
793
|
me;
|
|
@@ -664,6 +799,8 @@ var PlatformClient = class {
|
|
|
664
799
|
webhooks;
|
|
665
800
|
orgs;
|
|
666
801
|
rooms;
|
|
802
|
+
spaces;
|
|
803
|
+
speech;
|
|
667
804
|
_http;
|
|
668
805
|
constructor(options) {
|
|
669
806
|
if (!options.apiKey) {
|
|
@@ -686,6 +823,8 @@ var PlatformClient = class {
|
|
|
686
823
|
this.webhooks = createWebhooksResource(http);
|
|
687
824
|
this.orgs = createOrgsResource(http);
|
|
688
825
|
this.rooms = createRoomsResource(http);
|
|
826
|
+
this.spaces = createSpacesResource(http);
|
|
827
|
+
this.speech = createSpeechResource(http);
|
|
689
828
|
this._http = http;
|
|
690
829
|
}
|
|
691
830
|
/**
|
|
@@ -718,6 +857,7 @@ var verifyWebhookSignature = (rawBody, signatureHeader, secret) => {
|
|
|
718
857
|
0 && (module.exports = {
|
|
719
858
|
PlatformClient,
|
|
720
859
|
PlatformError,
|
|
860
|
+
buildJoinUrl,
|
|
721
861
|
verifyWebhookSignature
|
|
722
862
|
});
|
|
723
863
|
//# sourceMappingURL=index.js.map
|