@gpt-platform/client 0.10.4 → 0.11.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.
Files changed (155) hide show
  1. package/dist/_internal/client/client.gen.d.ts +3 -0
  2. package/dist/_internal/client/client.gen.d.ts.map +1 -0
  3. package/dist/_internal/client/index.d.ts +9 -0
  4. package/dist/_internal/client/index.d.ts.map +1 -0
  5. package/dist/_internal/client/types.gen.d.ts +118 -0
  6. package/dist/_internal/client/types.gen.d.ts.map +1 -0
  7. package/dist/_internal/client/utils.gen.d.ts +34 -0
  8. package/dist/_internal/client/utils.gen.d.ts.map +1 -0
  9. package/dist/_internal/client.gen.d.ts +13 -0
  10. package/dist/_internal/client.gen.d.ts.map +1 -0
  11. package/dist/_internal/core/auth.gen.d.ts +19 -0
  12. package/dist/_internal/core/auth.gen.d.ts.map +1 -0
  13. package/dist/_internal/core/bodySerializer.gen.d.ts +26 -0
  14. package/dist/_internal/core/bodySerializer.gen.d.ts.map +1 -0
  15. package/dist/_internal/core/params.gen.d.ts +44 -0
  16. package/dist/_internal/core/params.gen.d.ts.map +1 -0
  17. package/dist/_internal/core/pathSerializer.gen.d.ts +34 -0
  18. package/dist/_internal/core/pathSerializer.gen.d.ts.map +1 -0
  19. package/dist/_internal/core/queryKeySerializer.gen.d.ts +19 -0
  20. package/dist/_internal/core/queryKeySerializer.gen.d.ts.map +1 -0
  21. package/dist/_internal/core/serverSentEvents.gen.d.ts +72 -0
  22. package/dist/_internal/core/serverSentEvents.gen.d.ts.map +1 -0
  23. package/dist/_internal/core/types.gen.d.ts +79 -0
  24. package/dist/_internal/core/types.gen.d.ts.map +1 -0
  25. package/dist/_internal/core/utils.gen.d.ts +20 -0
  26. package/dist/_internal/core/utils.gen.d.ts.map +1 -0
  27. package/dist/_internal/index.d.ts +3 -0
  28. package/dist/_internal/index.d.ts.map +1 -0
  29. package/dist/_internal/sdk.gen.d.ts +7053 -0
  30. package/dist/_internal/sdk.gen.d.ts.map +1 -0
  31. package/dist/_internal/types.gen.d.ts +146633 -0
  32. package/dist/_internal/types.gen.d.ts.map +1 -0
  33. package/dist/base-client.d.ts +199 -0
  34. package/dist/base-client.d.ts.map +1 -0
  35. package/dist/errors/index.d.ts +128 -0
  36. package/dist/errors/index.d.ts.map +1 -0
  37. package/dist/events.d.ts +69 -0
  38. package/dist/events.d.ts.map +1 -0
  39. package/dist/execution-events.d.ts +95 -0
  40. package/dist/execution-events.d.ts.map +1 -0
  41. package/dist/gpt-client.d.ts +2175 -0
  42. package/dist/gpt-client.d.ts.map +1 -0
  43. package/dist/index.d.ts +51 -30308
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +775 -14
  46. package/dist/index.js.map +1 -1
  47. package/dist/index.mjs +775 -14
  48. package/dist/index.mjs.map +1 -1
  49. package/dist/json-api.d.ts +26 -0
  50. package/dist/json-api.d.ts.map +1 -0
  51. package/dist/logging.d.ts +22 -0
  52. package/dist/logging.d.ts.map +1 -0
  53. package/dist/namespace-types.d.ts +79 -0
  54. package/dist/namespace-types.d.ts.map +1 -0
  55. package/dist/namespaces/access-grants.d.ts +71 -0
  56. package/dist/namespaces/access-grants.d.ts.map +1 -0
  57. package/dist/namespaces/agents.d.ts +1406 -0
  58. package/dist/namespaces/agents.d.ts.map +1 -0
  59. package/dist/namespaces/ai.d.ts +407 -0
  60. package/dist/namespaces/ai.d.ts.map +1 -0
  61. package/dist/namespaces/audit.d.ts +83 -0
  62. package/dist/namespaces/audit.d.ts.map +1 -0
  63. package/dist/namespaces/billing.d.ts +854 -0
  64. package/dist/namespaces/billing.d.ts.map +1 -0
  65. package/dist/namespaces/campaigns.d.ts +973 -0
  66. package/dist/namespaces/campaigns.d.ts.map +1 -0
  67. package/dist/namespaces/catalog.d.ts +964 -0
  68. package/dist/namespaces/catalog.d.ts.map +1 -0
  69. package/dist/namespaces/channels.d.ts +162 -0
  70. package/dist/namespaces/channels.d.ts.map +1 -0
  71. package/dist/namespaces/clinical.d.ts +2443 -0
  72. package/dist/namespaces/clinical.d.ts.map +1 -0
  73. package/dist/namespaces/communication.d.ts +439 -0
  74. package/dist/namespaces/communication.d.ts.map +1 -0
  75. package/dist/namespaces/compliance.d.ts +2310 -0
  76. package/dist/namespaces/compliance.d.ts.map +1 -0
  77. package/dist/namespaces/connectors.d.ts +1368 -0
  78. package/dist/namespaces/connectors.d.ts.map +1 -0
  79. package/dist/namespaces/content.d.ts +188 -0
  80. package/dist/namespaces/content.d.ts.map +1 -0
  81. package/dist/namespaces/crawler.d.ts +408 -0
  82. package/dist/namespaces/crawler.d.ts.map +1 -0
  83. package/dist/namespaces/crm-clusters.d.ts +31 -0
  84. package/dist/namespaces/crm-clusters.d.ts.map +1 -0
  85. package/dist/namespaces/crm.d.ts +1539 -0
  86. package/dist/namespaces/crm.d.ts.map +1 -0
  87. package/dist/namespaces/documents.d.ts +136 -0
  88. package/dist/namespaces/documents.d.ts.map +1 -0
  89. package/dist/namespaces/email.d.ts +550 -0
  90. package/dist/namespaces/email.d.ts.map +1 -0
  91. package/dist/namespaces/extraction.d.ts +1249 -0
  92. package/dist/namespaces/extraction.d.ts.map +1 -0
  93. package/dist/namespaces/identity.d.ts +411 -0
  94. package/dist/namespaces/identity.d.ts.map +1 -0
  95. package/dist/namespaces/imports.d.ts +177 -0
  96. package/dist/namespaces/imports.d.ts.map +1 -0
  97. package/dist/namespaces/index.d.ts +119 -0
  98. package/dist/namespaces/index.d.ts.map +1 -0
  99. package/dist/namespaces/memory.d.ts +105 -0
  100. package/dist/namespaces/memory.d.ts.map +1 -0
  101. package/dist/namespaces/models.d.ts +75 -0
  102. package/dist/namespaces/models.d.ts.map +1 -0
  103. package/dist/namespaces/permissions.d.ts +75 -0
  104. package/dist/namespaces/permissions.d.ts.map +1 -0
  105. package/dist/namespaces/pipeline-executions.d.ts +130 -0
  106. package/dist/namespaces/pipeline-executions.d.ts.map +1 -0
  107. package/dist/namespaces/pipelines.d.ts +120 -0
  108. package/dist/namespaces/pipelines.d.ts.map +1 -0
  109. package/dist/namespaces/platform.d.ts +1430 -0
  110. package/dist/namespaces/platform.d.ts.map +1 -0
  111. package/dist/namespaces/portal.d.ts +198 -0
  112. package/dist/namespaces/portal.d.ts.map +1 -0
  113. package/dist/namespaces/projects.d.ts +553 -0
  114. package/dist/namespaces/projects.d.ts.map +1 -0
  115. package/dist/namespaces/roles.d.ts +65 -0
  116. package/dist/namespaces/roles.d.ts.map +1 -0
  117. package/dist/namespaces/scheduling.d.ts +944 -0
  118. package/dist/namespaces/scheduling.d.ts.map +1 -0
  119. package/dist/namespaces/search.d.ts +224 -0
  120. package/dist/namespaces/search.d.ts.map +1 -0
  121. package/dist/namespaces/session-notes.d.ts +67 -0
  122. package/dist/namespaces/session-notes.d.ts.map +1 -0
  123. package/dist/namespaces/social.d.ts +330 -0
  124. package/dist/namespaces/social.d.ts.map +1 -0
  125. package/dist/namespaces/storage.d.ts +378 -0
  126. package/dist/namespaces/storage.d.ts.map +1 -0
  127. package/dist/namespaces/support.d.ts +427 -0
  128. package/dist/namespaces/support.d.ts.map +1 -0
  129. package/dist/namespaces/threads.d.ts +596 -0
  130. package/dist/namespaces/threads.d.ts.map +1 -0
  131. package/dist/namespaces/training.d.ts +358 -0
  132. package/dist/namespaces/training.d.ts.map +1 -0
  133. package/dist/namespaces/voice.d.ts +752 -0
  134. package/dist/namespaces/voice.d.ts.map +1 -0
  135. package/dist/namespaces/watcher.d.ts +425 -0
  136. package/dist/namespaces/watcher.d.ts.map +1 -0
  137. package/dist/namespaces/webhooks-ns.d.ts +3 -0
  138. package/dist/namespaces/webhooks-ns.d.ts.map +1 -0
  139. package/dist/pagination.d.ts +57 -0
  140. package/dist/pagination.d.ts.map +1 -0
  141. package/dist/request-builder.d.ts +95 -0
  142. package/dist/request-builder.d.ts.map +1 -0
  143. package/dist/security.d.ts +32 -0
  144. package/dist/security.d.ts.map +1 -0
  145. package/dist/streaming.d.ts +135 -0
  146. package/dist/streaming.d.ts.map +1 -0
  147. package/dist/utils/retry.d.ts +63 -0
  148. package/dist/utils/retry.d.ts.map +1 -0
  149. package/dist/version.d.ts +5 -0
  150. package/dist/version.d.ts.map +1 -0
  151. package/dist/webhook-signature.d.ts +109 -0
  152. package/dist/webhook-signature.d.ts.map +1 -0
  153. package/llms.txt +40 -1
  154. package/package.json +286 -36
  155. package/dist/index.d.mts +0 -30308
@@ -0,0 +1,752 @@
1
+ import type { TranscriptionJob, VoiceRecording, VoiceSession, VoiceTranscriptionResult } from "../_internal/types.gen";
2
+ import type { RequestOptions } from "../base-client";
3
+ import { RequestBuilder } from "../request-builder";
4
+ /**
5
+ * Return type for `voice.sessions.start()`.
6
+ *
7
+ * Narrows the generic `VoiceSession` type to guarantee that `livekit_token`
8
+ * and `livekit_room` are present, non-null strings. These fields are populated
9
+ * **only** on the POST /voice/sessions create response (one-time delivery) — the
10
+ * server never persists the token and it is always null in GET/PATCH responses.
11
+ *
12
+ * Using this type instead of `VoiceSession` ensures TypeScript enforces that
13
+ * callers capture the token before it becomes unavailable.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const session = await client.voice.sessions.start();
18
+ * const token: string = session.attributes!.livekit_token; // guaranteed non-null
19
+ * ```
20
+ */
21
+ export type VoiceSessionStart = VoiceSession & {
22
+ attributes: NonNullable<VoiceSession["attributes"]> & {
23
+ /** LiveKit JWT for immediate room connection. One-time delivery — capture this immediately. */
24
+ livekit_token: string;
25
+ /** LiveKit room name. One-time delivery — capture alongside `livekit_token`. */
26
+ livekit_room: string;
27
+ };
28
+ };
29
+ /**
30
+ * Response from the voice transcription endpoint.
31
+ * Not a JSON:API resource — this is a plain object response from the
32
+ * custom VoiceTranscribeController.
33
+ */
34
+ export interface VoiceTranscribeResult {
35
+ transcript: string;
36
+ language_detected: string;
37
+ duration_seconds: number;
38
+ processing_seconds: number;
39
+ segments: Array<{
40
+ text: string;
41
+ start: number;
42
+ end: number;
43
+ confidence?: number;
44
+ /** Present when diarization is enabled. Format: "SPEAKER_00", "SPEAKER_01", etc. */
45
+ speaker_id?: string;
46
+ }>;
47
+ phi_mode?: string;
48
+ phi_entity_count?: number;
49
+ /** Present when phi_mode is "tokenize". Contains token→original value mappings. */
50
+ phi_map?: Record<string, string>;
51
+ /** Advisory: "contains_plaintext_phi" when phi_map is returned in plaintext. */
52
+ phi_map_sensitivity?: string;
53
+ /** Present when phi_mode is "tokenize_encrypt". Base64-encoded ciphertext+tag. */
54
+ phi_map_encrypted?: string;
55
+ /** Present when phi_mode is "tokenize_encrypt". Base64-encoded 12-byte GCM nonce. */
56
+ phi_map_nonce?: string;
57
+ }
58
+ /** Options for starting a voice session. */
59
+ export interface VoiceStartOptions {
60
+ threadId?: string;
61
+ blueprintId?: string;
62
+ blueprintMode?: "chat" | "extraction" | "both";
63
+ phiMode?: "none" | "tokenize" | "tokenize_encrypt";
64
+ phiKey?: string;
65
+ patientId?: string;
66
+ }
67
+ /** Options for finalizing a voice session. */
68
+ export interface VoiceFinalizeOptions {
69
+ blueprintId?: string;
70
+ phiMode?: "none" | "tokenize" | "tokenize_encrypt";
71
+ phiKey?: string;
72
+ patientId?: string;
73
+ }
74
+ /** Options for audio transcription. */
75
+ export interface VoiceTranscribeOptions {
76
+ language?: string;
77
+ modelSize?: "base" | "medium" | "large" | "large-v3";
78
+ phiMode?: "none" | "tokenize" | "tokenize_encrypt";
79
+ /** Base64-encoded 32 bytes. Required when phiMode is not "none". */
80
+ phiKey?: string;
81
+ /** Enable speaker diarization. When true, segments include speaker_id labels. */
82
+ enableDiarization?: boolean;
83
+ /** Expected number of speakers (0 = auto-detect). Only used when enableDiarization is true. */
84
+ numSpeakers?: number;
85
+ /**
86
+ * Vocabulary hint for the STT model (Whisper initial_prompt).
87
+ * Provide domain-specific terms to improve recognition accuracy.
88
+ * @example "albumin, HbA1c, Metformin, MCT oil, prealbumin"
89
+ */
90
+ initialPrompt?: string;
91
+ }
92
+ /** Options for creating a transcription job. */
93
+ export interface TranscriptionJobCreateOptions {
94
+ language?: string;
95
+ modelSize?: "base" | "medium" | "large" | "large-v3";
96
+ enableDiarization?: boolean;
97
+ numSpeakers?: number;
98
+ /**
99
+ * Vocabulary hint for the STT model (Whisper initial_prompt).
100
+ * @example "albumin, HbA1c, Metformin, MCT oil"
101
+ */
102
+ initialPrompt?: string;
103
+ phiMode?: "none" | "tokenize" | "tokenize_encrypt";
104
+ metadata?: Record<string, unknown>;
105
+ }
106
+ /** Response from uploading a transcription chunk. */
107
+ export interface TranscriptionChunkResult {
108
+ chunk_index: number;
109
+ completed_chunks: number;
110
+ text: string;
111
+ segments: Array<{
112
+ text: string;
113
+ start: number;
114
+ end: number;
115
+ confidence?: number;
116
+ speaker_id?: string;
117
+ }>;
118
+ language_detected: string;
119
+ duration_seconds: number;
120
+ processing_seconds: number;
121
+ }
122
+ /** Options for finalizing a transcription job. */
123
+ export interface TranscriptionJobFinalizeOptions {
124
+ blueprintId?: string;
125
+ patientId?: string;
126
+ }
127
+ /** Response from finalizing a transcription job. */
128
+ export interface TranscriptionJobFinalizeResult {
129
+ job_id: string;
130
+ status: "completed";
131
+ assembled_text: string;
132
+ segments: Array<{
133
+ text: string;
134
+ start: number;
135
+ end: number;
136
+ confidence?: number;
137
+ speaker_id?: string;
138
+ }>;
139
+ total_duration_seconds: number;
140
+ total_chunks: number;
141
+ transcription_result_id: string | null;
142
+ }
143
+ /**
144
+ * Voice namespace for audio transcription and real-time voice session management.
145
+ *
146
+ * Access via `client.voice`.
147
+ *
148
+ * The voice system has two independent capabilities:
149
+ * - **Transcription** (`transcribe`) — one-shot audio file transcription with
150
+ * optional PHI tokenization.
151
+ * - **Sessions** — long-running LiveKit-backed voice sessions for real-time
152
+ * clinical conversations, with post-session pipeline integration.
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
157
+ *
158
+ * // Transcribe a recorded audio file
159
+ * const result = await client.voice.transcribe(audioBlob, { language: 'en' });
160
+ * console.log(result.transcript);
161
+ *
162
+ * // Start a real-time session
163
+ * const session = await client.voice.sessions.start({ blueprintId: 'bp_abc123' });
164
+ * const token = session.attributes.livekit_token; // capture immediately
165
+ * ```
166
+ */
167
+ export declare function createVoiceNamespace(rb: RequestBuilder): {
168
+ /**
169
+ * Transcribe an audio file to text.
170
+ *
171
+ * Submits an audio file to the voice transcription pipeline. The file is
172
+ * processed synchronously (the request blocks until transcription completes).
173
+ * Supported formats: mp3, ogg, wav, m4a, webm, flac, aac. Maximum file
174
+ * size: 200 MB.
175
+ *
176
+ * PHI handling modes:
177
+ * - `"none"` (default) — transcript returned as-is, no PHI processing.
178
+ * - `"tokenize"` — PHI entities replaced with placeholder tokens in the
179
+ * transcript; a `phi_map` is returned mapping tokens back to original values.
180
+ * - `"tokenize_encrypt"` — same as tokenize but `phi_map` is AES-256-GCM
181
+ * encrypted; requires a `phiKey` (Base64-encoded 32 bytes).
182
+ *
183
+ * @param audio - The audio file or blob to transcribe (max 200 MB).
184
+ * @param params - Optional transcription parameters.
185
+ * @param params.language - BCP-47 language hint (e.g., `"en"`, `"fr"`).
186
+ * Improves accuracy when the language is known.
187
+ * @param params.modelSize - Whisper model size to use. Larger models are
188
+ * more accurate but slower. Defaults to `"medium"`.
189
+ * @param params.phiMode - PHI handling mode. Defaults to `"none"`.
190
+ * @param params.phiKey - AES-256 key as Base64 (32 raw bytes). Required
191
+ * when `phiMode` is `"tokenize_encrypt"`. Treat as a secret — never log.
192
+ * @param options - Optional request options (signal for cancellation, etc.).
193
+ * @returns A `VoiceTranscribeResult` with transcript, segments, and optional PHI data.
194
+ *
195
+ * @example
196
+ * ```typescript
197
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
198
+ * const fileInput = document.querySelector<HTMLInputElement>('#audio-upload')!;
199
+ * const [audioFile] = fileInput.files!;
200
+ *
201
+ * const result = await client.voice.transcribe(audioFile, {
202
+ * language: 'en',
203
+ * modelSize: 'medium',
204
+ * });
205
+ * console.log(result.transcript);
206
+ * console.log(`Transcribed ${result.duration_seconds}s in ${result.processing_seconds}s`);
207
+ * result.segments.forEach(s => console.log(`[${s.start}–${s.end}] ${s.text}`));
208
+ * ```
209
+ */
210
+ transcribe: (audio: File | Blob, params?: VoiceTranscribeOptions, options?: RequestOptions) => Promise<VoiceTranscribeResult>;
211
+ /**
212
+ * Sessions — real-time voice session lifecycle management.
213
+ *
214
+ * Voice sessions are backed by LiveKit rooms. Each session tracks the
215
+ * full conversation lifecycle from room creation through post-session
216
+ * processing (notes, summaries, clinical alerts).
217
+ *
218
+ * Typical session flow:
219
+ * 1. `start()` — provisions a LiveKit room, returns one-time token.
220
+ * 2. Client connects to LiveKit using the token.
221
+ * 3. `stop(id)` — ends the session and releases the room.
222
+ * 4. `finalize(id)` — triggers post-session processing pipeline.
223
+ */
224
+ sessions: {
225
+ /**
226
+ * List voice sessions with optional pagination.
227
+ *
228
+ * Returns sessions accessible to the current actor, ordered by
229
+ * `created_at` descending.
230
+ *
231
+ * @param options - Optional page number, page size, and request options.
232
+ * @returns A page of `VoiceSession` records.
233
+ *
234
+ * @example
235
+ * ```typescript
236
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
237
+ * const sessions = await client.voice.sessions.list({ page: 1, pageSize: 20 });
238
+ * sessions.forEach(s => console.log(s.attributes?.status, s.attributes?.created_at));
239
+ * ```
240
+ */
241
+ list: (options?: {
242
+ page?: number;
243
+ pageSize?: number;
244
+ /** Filter sessions by status. */
245
+ status?: "active" | "ended" | "failed" | "timed_out";
246
+ /** Filter sessions created after this ISO 8601 timestamp. */
247
+ insertedAfter?: string;
248
+ /** Filter sessions created before this ISO 8601 timestamp. */
249
+ insertedBefore?: string;
250
+ } & RequestOptions) => Promise<VoiceSession[]>;
251
+ /**
252
+ * Retrieve a single voice session by its ID.
253
+ *
254
+ * Note: `livekit_token` and `livekit_room` are always `null` in GET
255
+ * responses — they are only returned on the initial `start()` call.
256
+ *
257
+ * @param id - The UUID of the voice session.
258
+ * @param options - Optional request options.
259
+ * @returns The matching `VoiceSession`.
260
+ *
261
+ * @example
262
+ * ```typescript
263
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
264
+ * const session = await client.voice.sessions.get('vs_abc123');
265
+ * console.log(session.attributes?.status, session.attributes?.duration_seconds);
266
+ * ```
267
+ */
268
+ get: (id: string, options?: RequestOptions) => Promise<VoiceSession>;
269
+ /**
270
+ * List voice sessions belonging to the currently authenticated user.
271
+ *
272
+ * Returns only sessions where the current user is the session owner.
273
+ *
274
+ * @param options - Optional page number, page size, and request options.
275
+ * @returns A page of `VoiceSession` records owned by the current user.
276
+ *
277
+ * @example
278
+ * ```typescript
279
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
280
+ * const mySessions = await client.voice.sessions.listMine({ pageSize: 10 });
281
+ * ```
282
+ */
283
+ listMine: (options?: {
284
+ page?: number;
285
+ pageSize?: number;
286
+ } & RequestOptions) => Promise<VoiceSession[]>;
287
+ /**
288
+ * List voice sessions scoped to a specific workspace.
289
+ *
290
+ * @param workspaceId - The UUID of the workspace to list sessions for.
291
+ * @param options - Optional page number, page size, and request options.
292
+ * @returns A page of `VoiceSession` records in the given workspace.
293
+ *
294
+ * @example
295
+ * ```typescript
296
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
297
+ * const sessions = await client.voice.sessions.listByWorkspace('ws_abc123');
298
+ * ```
299
+ */
300
+ listByWorkspace: (workspaceId: string, options?: {
301
+ page?: number;
302
+ pageSize?: number;
303
+ } & RequestOptions) => Promise<VoiceSession[]>;
304
+ /**
305
+ * Start a new voice session with LiveKit room provisioning.
306
+ *
307
+ * Creates a `VoiceSession` record, provisions a LiveKit room, and returns
308
+ * a one-time JWT (`livekit_token`) and room name (`livekit_room`).
309
+ * **These values are delivered only once** — the server does not persist
310
+ * the token and it will always be `null` in subsequent GET requests.
311
+ * Capture both values immediately before any other operations.
312
+ *
313
+ * @param params - Session startup parameters.
314
+ * @param params.threadId - Optional chat thread ID to associate this session with.
315
+ * @param params.blueprintId - Optional agent blueprint ID. When provided, the
316
+ * session's transcript is processed by this blueprint on finalization.
317
+ * @param params.blueprintMode - How the blueprint processes the session.
318
+ * `"chat"` — sends to chat pipeline; `"extraction"` — runs extraction;
319
+ * `"both"` — runs both pipelines.
320
+ * @param params.phiMode - PHI handling mode for the session transcript.
321
+ * `"none"` | `"tokenize"` | `"tokenize_encrypt"`.
322
+ * @param params.phiKey - AES-256 encryption key as Base64 (32 raw bytes).
323
+ * Required when `phiMode` is `"tokenize_encrypt"`. Treat as a secret —
324
+ * never log, store in `localStorage`, or include in error reports.
325
+ * The server never persists this key.
326
+ * @param params.patientId - Optional CRM patient/contact ID to associate
327
+ * the session with for clinical workflows.
328
+ * @param options - Optional request options.
329
+ * @returns A `VoiceSessionStart` with guaranteed non-null `livekit_token`
330
+ * and `livekit_room`.
331
+ *
332
+ * @remarks
333
+ * **Security — `phiKey`:** Transmitted over HTTPS only. Never send over
334
+ * plain HTTP. Do not log or store this value outside the request.
335
+ *
336
+ * @example
337
+ * ```typescript
338
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
339
+ * const session = await client.voice.sessions.start({
340
+ * blueprintId: 'bp_clinical_notes',
341
+ * blueprintMode: 'both',
342
+ * patientId: 'contact_abc123',
343
+ * });
344
+ *
345
+ * // Capture token immediately — it's only available on start
346
+ * const { livekit_token, livekit_room } = session.attributes;
347
+ * await connectToLiveKit(livekit_room, livekit_token);
348
+ * ```
349
+ */
350
+ start: (params?: VoiceStartOptions, options?: RequestOptions) => Promise<VoiceSessionStart>;
351
+ /**
352
+ * End an active voice session and release the LiveKit room.
353
+ *
354
+ * Signals the server to close the LiveKit room and mark the session
355
+ * as `"ended"`. The `ended_at` timestamp is set automatically by the
356
+ * server. No request body attributes are accepted — passing extra
357
+ * attributes will result in a 422 validation error.
358
+ *
359
+ * After stopping, call `finalize` to trigger post-session processing
360
+ * (note generation, summarization, clinical alerts).
361
+ *
362
+ * @param id - The UUID of the voice session to stop.
363
+ * @param options - Optional request options.
364
+ * @returns The updated `VoiceSession` with `status: "ended"`.
365
+ *
366
+ * @example
367
+ * ```typescript
368
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
369
+ * const session = await client.voice.sessions.stop('vs_abc123');
370
+ * console.log(session.attributes?.status); // "ended"
371
+ * console.log(session.attributes?.ended_at);
372
+ * ```
373
+ */
374
+ stop: (id: string, options?: RequestOptions) => Promise<VoiceSession>;
375
+ /**
376
+ * Trigger post-session processing for a stopped voice session.
377
+ *
378
+ * Dispatches the accumulated session transcript to the configured
379
+ * blueprint or chat pipeline. Depending on the session's `blueprint_mode`,
380
+ * this may trigger: clinical note generation, extraction, chat summarization,
381
+ * trend analysis, and clinical alert workers.
382
+ *
383
+ * Typically called immediately after `stop`. The session must be in
384
+ * `"ended"` status before calling `finalize`.
385
+ *
386
+ * @param id - The UUID of the voice session to finalize.
387
+ * @param params - Finalization parameters (override session-level settings).
388
+ * @param params.blueprintId - Override the blueprint to use for processing.
389
+ * @param params.phiMode - Override the PHI handling mode for the transcript.
390
+ * @param params.phiKey - AES-256 encryption key as Base64 (32 raw bytes).
391
+ * Overrides the key supplied at session start. Required when `phiMode`
392
+ * is `"tokenize_encrypt"`. Treat as a secret — never log or store.
393
+ * @param params.patientId - Override the patient ID for clinical association.
394
+ * @param options - Optional request options.
395
+ * @returns The updated `VoiceSession` with `finalized_at` timestamp set.
396
+ *
397
+ * @remarks
398
+ * **Security — transcript PHI:** The transcript submitted to this endpoint
399
+ * may contain Protected Health Information. Ensure the request is made
400
+ * over HTTPS only.
401
+ *
402
+ * **Security — `phiKey`:** Transmitted over HTTPS only. Never log, store
403
+ * in `localStorage`, or include in error reports.
404
+ *
405
+ * @example
406
+ * ```typescript
407
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
408
+ *
409
+ * // After stopping the session:
410
+ * const finalized = await client.voice.sessions.finalize('vs_abc123', {
411
+ * blueprintId: 'bp_clinical_notes',
412
+ * patientId: 'contact_abc123',
413
+ * });
414
+ * console.log(finalized.attributes?.status); // "finalizing"
415
+ * ```
416
+ */
417
+ finalize: (id: string, params?: VoiceFinalizeOptions, options?: RequestOptions) => Promise<VoiceSession>;
418
+ /**
419
+ * Destroy a voice session.
420
+ *
421
+ * @param id - The voice session ID to destroy
422
+ * @param options - Optional request configuration
423
+ * @returns Promise resolving when session is destroyed
424
+ *
425
+ * @example
426
+ * ```typescript
427
+ * await client.voice.sessions.destroy('session-uuid');
428
+ * ```
429
+ */
430
+ destroy: (id: string, options?: RequestOptions) => Promise<void>;
431
+ };
432
+ /**
433
+ * Voice recordings — recordings for the current workspace.
434
+ */
435
+ recordings: {
436
+ /**
437
+ * List voice recordings.
438
+ *
439
+ * @param options - Optional pagination and request options.
440
+ * @returns Array of VoiceRecording objects.
441
+ *
442
+ * @example
443
+ * ```typescript
444
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
445
+ * const recordings = await client.voice.recordings.list();
446
+ * ```
447
+ */
448
+ list: (options?: {
449
+ page?: number;
450
+ pageSize?: number;
451
+ } & RequestOptions) => Promise<VoiceRecording[]>;
452
+ /**
453
+ * Retrieve a single recording by ID.
454
+ *
455
+ * @param id - The UUID of the recording.
456
+ * @param options - Optional request options.
457
+ * @returns The VoiceRecording.
458
+ *
459
+ * @example
460
+ * ```typescript
461
+ * const recording = await client.voice.recordings.get('recording-uuid');
462
+ * ```
463
+ */
464
+ get: (id: string, options?: RequestOptions) => Promise<VoiceRecording>;
465
+ /**
466
+ * List all recordings for a specific voice session.
467
+ *
468
+ * @param sessionId - The UUID of the voice session.
469
+ * @param options - Optional request options.
470
+ * @returns Array of VoiceRecording objects for the session.
471
+ *
472
+ * @example
473
+ * ```typescript
474
+ * const recordings = await client.voice.recordings.bySession('session-uuid');
475
+ * ```
476
+ */
477
+ bySession: (sessionId: string, options?: RequestOptions) => Promise<VoiceRecording[]>;
478
+ };
479
+ /**
480
+ * Transcription results — results for sessions in the current workspace.
481
+ */
482
+ transcriptionResults: {
483
+ /**
484
+ * List transcription results.
485
+ *
486
+ * @param options - Optional pagination and request options.
487
+ * @returns Array of VoiceTranscriptionResult objects.
488
+ *
489
+ * @example
490
+ * ```typescript
491
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
492
+ * const results = await client.voice.transcriptionResults.list();
493
+ * ```
494
+ */
495
+ list: (options?: {
496
+ page?: number;
497
+ pageSize?: number;
498
+ } & RequestOptions) => Promise<VoiceTranscriptionResult[]>;
499
+ /**
500
+ * Retrieve a single transcription result by ID.
501
+ *
502
+ * @param id - The UUID of the transcription result.
503
+ * @param options - Optional request options.
504
+ * @returns The VoiceTranscriptionResult.
505
+ *
506
+ * @example
507
+ * ```typescript
508
+ * const result = await client.voice.transcriptionResults.get('result-uuid');
509
+ * ```
510
+ */
511
+ get: (id: string, options?: RequestOptions) => Promise<VoiceTranscriptionResult>;
512
+ /**
513
+ * List transcription results for a specific voice session.
514
+ *
515
+ * @param sessionId - The UUID of the voice session.
516
+ * @param options - Optional pagination and request options.
517
+ * @returns Array of VoiceTranscriptionResult objects for the session.
518
+ *
519
+ * @example
520
+ * ```typescript
521
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
522
+ * const results = await client.voice.transcriptionResults.bySession('session-uuid');
523
+ * ```
524
+ */
525
+ bySession: (sessionId: string, options?: {
526
+ page?: number;
527
+ pageSize?: number;
528
+ } & RequestOptions) => Promise<VoiceTranscriptionResult[]>;
529
+ /**
530
+ * Create a transcript record manually.
531
+ *
532
+ * Creates a `VoiceTranscriptionResult` record in the current workspace.
533
+ * Useful when you have a pre-computed transcript (e.g. from an external STT
534
+ * service) that you want to associate with a recording or session.
535
+ *
536
+ * @param attributes - Transcript data. Required: `text` (string).
537
+ * Optional: `recording_id`, `session_id`, `document_id`, `segments`,
538
+ * `language_detected`, `duration_seconds`, `processing_seconds`,
539
+ * `stt_engine`, `stt_model`, `metadata`.
540
+ * @param options - Optional request options.
541
+ * @returns The created `VoiceTranscriptionResult`.
542
+ *
543
+ * @example
544
+ * ```typescript
545
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
546
+ * const result = await client.voice.transcriptionResults.create({
547
+ * text: 'Patient reports chest pain since this morning.',
548
+ * session_id: 'vs_abc123',
549
+ * language_detected: 'en',
550
+ * duration_seconds: 47.2,
551
+ * });
552
+ * console.log(result.id);
553
+ * ```
554
+ */
555
+ create: (attributes: {
556
+ text: string;
557
+ recording_id?: string;
558
+ session_id?: string;
559
+ document_id?: string;
560
+ segments?: Array<{
561
+ text: string;
562
+ start: number;
563
+ end: number;
564
+ confidence?: number;
565
+ }>;
566
+ language_detected?: string;
567
+ duration_seconds?: number;
568
+ processing_seconds?: number;
569
+ stt_engine?: string;
570
+ stt_model?: string;
571
+ metadata?: Record<string, unknown>;
572
+ }, options?: RequestOptions) => Promise<VoiceTranscriptionResult>;
573
+ /**
574
+ * Update a transcript's text, segments, or metadata.
575
+ *
576
+ * Allows correcting transcript text after review, updating segments
577
+ * with corrected timestamps or confidence scores, or annotating with
578
+ * additional metadata. `recording_id`, `session_id`, and STT engine
579
+ * fields are immutable after creation.
580
+ *
581
+ * @param id - The UUID of the transcription result to update.
582
+ * @param attributes - Fields to update. One or more of: `text`, `segments`, `metadata`.
583
+ * @param options - Optional request options.
584
+ * @returns The updated `VoiceTranscriptionResult`.
585
+ *
586
+ * @example
587
+ * ```typescript
588
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
589
+ * const updated = await client.voice.transcriptionResults.update('tr_abc123', {
590
+ * text: 'Patient reports chest pain since yesterday morning.',
591
+ * });
592
+ * ```
593
+ */
594
+ update: (id: string, attributes: {
595
+ text?: string;
596
+ segments?: Array<{
597
+ text: string;
598
+ start: number;
599
+ end: number;
600
+ confidence?: number;
601
+ }>;
602
+ metadata?: Record<string, unknown>;
603
+ }, options?: RequestOptions) => Promise<VoiceTranscriptionResult>;
604
+ /**
605
+ * Delete a transcription result by its ID.
606
+ *
607
+ * Permanently removes the transcript record. Associated recordings and
608
+ * voice sessions are not affected.
609
+ *
610
+ * @param id - The UUID of the transcription result to delete.
611
+ * @param options - Optional request options.
612
+ * @returns A promise that resolves when the record is deleted.
613
+ *
614
+ * @example
615
+ * ```typescript
616
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
617
+ * await client.voice.transcriptionResults.destroy('tr_abc123');
618
+ * ```
619
+ */
620
+ destroy: (id: string, options?: RequestOptions) => Promise<void>;
621
+ };
622
+ /**
623
+ * Transcription jobs — progressive chunked transcription for long recordings.
624
+ *
625
+ * Designed for clinical recording sessions (30–60 minutes). The browser records
626
+ * audio and uploads chunks every 2–3 minutes. Each chunk is transcribed
627
+ * synchronously on upload. On finalize, chunks are assembled into a complete
628
+ * diarized transcript.
629
+ *
630
+ * Typical flow:
631
+ * 1. `create()` — start a new transcription job with config (language, diarization, etc.)
632
+ * 2. `uploadChunk(jobId, audioBlob)` — upload each chunk as it's recorded
633
+ * 3. `finalize(jobId)` — assemble all chunks and optionally trigger pipeline
634
+ *
635
+ * Subscribe to the `voice:{workspace_id}` WebSocket channel for real-time
636
+ * progress events: `transcription:chunk_completed`, `transcription:job_completed`.
637
+ *
638
+ * @example
639
+ * ```typescript
640
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
641
+ *
642
+ * // Create job with medical vocabulary hints
643
+ * const job = await client.voice.transcriptionJobs.create({
644
+ * language: 'en',
645
+ * modelSize: 'large',
646
+ * enableDiarization: true,
647
+ * numSpeakers: 2,
648
+ * initialPrompt: 'albumin, HbA1c, Metformin, MCT oil, prealbumin',
649
+ * });
650
+ *
651
+ * // Upload chunks as they're recorded (MediaRecorder ondataavailable)
652
+ * mediaRecorder.ondataavailable = async (event) => {
653
+ * if (event.data.size > 0) {
654
+ * const result = await client.voice.transcriptionJobs.uploadChunk(
655
+ * job.id!, event.data
656
+ * );
657
+ * console.log(`Chunk ${result.chunk_index}: ${result.text}`);
658
+ * }
659
+ * };
660
+ *
661
+ * // Finalize after recording stops
662
+ * const transcript = await client.voice.transcriptionJobs.finalize(job.id!, {
663
+ * blueprintId: 'bp_clinical_notes',
664
+ * patientId: 'contact_abc123',
665
+ * });
666
+ * console.log(transcript.assembled_text);
667
+ * ```
668
+ */
669
+ transcriptionJobs: {
670
+ /**
671
+ * Create a new transcription job.
672
+ *
673
+ * @param params - Job configuration (language, model, diarization, vocabulary hints).
674
+ * @param options - Optional request options.
675
+ * @returns The created TranscriptionJob resource (JSON:API format).
676
+ */
677
+ create: (params?: TranscriptionJobCreateOptions, options?: RequestOptions) => Promise<TranscriptionJob>;
678
+ /**
679
+ * Get a transcription job by ID.
680
+ *
681
+ * @param id - The UUID of the transcription job.
682
+ * @param options - Optional request options.
683
+ * @returns The TranscriptionJob resource.
684
+ */
685
+ get: (id: string, options?: RequestOptions) => Promise<TranscriptionJob>;
686
+ /**
687
+ * List transcription jobs for the current user.
688
+ *
689
+ * @param options - Optional pagination and request options.
690
+ * @returns Array of TranscriptionJob resources.
691
+ */
692
+ listMine: (options?: {
693
+ page?: number;
694
+ pageSize?: number;
695
+ } & RequestOptions) => Promise<TranscriptionJob[]>;
696
+ /**
697
+ * List all transcription jobs accessible to the current actor.
698
+ *
699
+ * @param options - Optional pagination and request options.
700
+ * @returns Array of TranscriptionJob resources.
701
+ */
702
+ list: (options?: {
703
+ page?: number;
704
+ pageSize?: number;
705
+ } & RequestOptions) => Promise<TranscriptionJob[]>;
706
+ /**
707
+ * List transcription jobs for a specific workspace.
708
+ *
709
+ * @param workspaceId - The UUID of the workspace.
710
+ * @param options - Optional pagination and request options.
711
+ * @returns Array of TranscriptionJob resources.
712
+ */
713
+ listByWorkspace: (workspaceId: string, options?: {
714
+ page?: number;
715
+ pageSize?: number;
716
+ } & RequestOptions) => Promise<TranscriptionJob[]>;
717
+ /**
718
+ * Upload and transcribe an audio chunk.
719
+ *
720
+ * The chunk is transcribed synchronously. For 2–3 minute chunks, expect
721
+ * 10–20 seconds of processing time. The response includes the chunk's
722
+ * transcript and segments (with speaker_id if diarization is enabled).
723
+ *
724
+ * @param jobId - The UUID of the transcription job.
725
+ * @param audio - The audio chunk (File or Blob). Max 50 MB.
726
+ * @param options - Optional request options.
727
+ * @returns Chunk transcription result with text, segments, and timing.
728
+ */
729
+ uploadChunk: (jobId: string, audio: File | Blob, options?: RequestOptions) => Promise<TranscriptionChunkResult>;
730
+ /**
731
+ * Finalize a transcription job — assemble chunks into a complete transcript.
732
+ *
733
+ * Joins all chunk transcripts in order, offsets segment timestamps, and
734
+ * reconciles speaker IDs across chunks. Optionally triggers a blueprint
735
+ * pipeline (e.g., SOAP note generation) on the assembled transcript.
736
+ *
737
+ * @param jobId - The UUID of the transcription job to finalize.
738
+ * @param params - Optional pipeline trigger parameters.
739
+ * @param options - Optional request options.
740
+ * @returns The assembled transcript with full text, segments, and timing.
741
+ */
742
+ finalize: (jobId: string, params?: TranscriptionJobFinalizeOptions, options?: RequestOptions) => Promise<TranscriptionJobFinalizeResult>;
743
+ /**
744
+ * Delete a transcription job.
745
+ *
746
+ * @param id - The UUID of the transcription job to delete.
747
+ * @param options - Optional request options.
748
+ */
749
+ destroy: (id: string, options?: RequestOptions) => Promise<void>;
750
+ };
751
+ };
752
+ //# sourceMappingURL=voice.d.ts.map