@gpt-platform/client 0.10.5 → 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 -30734
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +311 -4
  46. package/dist/index.js.map +1 -1
  47. package/dist/index.mjs +311 -4
  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 +7 -1
  154. package/package.json +286 -36
  155. package/dist/index.d.mts +0 -30734
@@ -0,0 +1,596 @@
1
+ import type { ChatThread as Thread, ChatMessage as Message, ChatMessageFeedback } from "../_internal/types.gen";
2
+ /** Re-export the generated feedback type under the short alias. */
3
+ export type MessageFeedback = ChatMessageFeedback;
4
+ /** Attributes accepted when creating a new thread. */
5
+ export type CreateThreadAttributes = {
6
+ title?: string;
7
+ agent_id?: string;
8
+ metadata?: Record<string, unknown>;
9
+ [key: string]: unknown;
10
+ };
11
+ /** Attributes accepted when updating an existing thread (PATCH semantics). */
12
+ export type UpdateThreadAttributes = {
13
+ title?: string;
14
+ context_summary?: string;
15
+ metadata?: Record<string, unknown>;
16
+ [key: string]: unknown;
17
+ };
18
+ /** Optional extra attributes when sending a message (beyond content). */
19
+ export type SendMessageAttributes = {
20
+ role?: string;
21
+ metadata?: Record<string, unknown>;
22
+ attachments?: unknown[];
23
+ [key: string]: unknown;
24
+ };
25
+ /** Attributes for inserting a pre-generated message directly (no inference). */
26
+ export type InsertMessageAttributes = {
27
+ /** Message role. Use 'assistant' for injecting agent responses. */
28
+ role: "user" | "assistant" | "system" | "tool";
29
+ /** Optional metadata to attach to the message. */
30
+ metadata?: Record<string, unknown>;
31
+ };
32
+ /** Attributes for rating a message (thumbs up/down). */
33
+ export type RateMessageAttributes = {
34
+ /** Thumbs up or down. */
35
+ rating: "up" | "down";
36
+ /** Optional comment explaining the rating. */
37
+ comment?: string;
38
+ };
39
+ /** Attributes for updating a message (PATCH semantics). */
40
+ export type UpdateMessageAttributes = {
41
+ role?: string;
42
+ content?: string;
43
+ metadata?: Record<string, unknown>;
44
+ [key: string]: unknown;
45
+ };
46
+ import type { RequestOptions } from "../base-client";
47
+ import { RequestBuilder } from "../request-builder";
48
+ import type { StreamMessageChunk, StreamOptions } from "../streaming";
49
+ /**
50
+ * Creates the `threads` namespace, providing methods for managing conversation
51
+ * threads and their messages.
52
+ *
53
+ * A thread is a persistent, ordered sequence of messages between a user and an
54
+ * AI agent. Threads support forking (branching a conversation into a new copy),
55
+ * archiving (soft-deletion with restore), AI-generated summaries, and export in
56
+ * multiple formats. Messages within a thread can be sent synchronously or
57
+ * streamed in real time via Server-Sent Events (SSE).
58
+ *
59
+ * ## Real-time Updates (WebSocket)
60
+ *
61
+ * Connect to `chat_thread:{threadId}` via `client.channels` to receive:
62
+ * - `new_message` — When a new message is added to the thread
63
+ * - `thread_updated` — When thread metadata changes (archived, summarized)
64
+ *
65
+ * @param rb - The `RequestBuilder` instance bound to the authenticated client.
66
+ * @returns An object containing all thread-related methods and the `messages`
67
+ * sub-namespace.
68
+ *
69
+ * @example
70
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
71
+ * const thread = await client.threads.create({ title: 'Support conversation' });
72
+ * console.log(`Thread created: ${thread.id}`);
73
+ */
74
+ export declare function createThreadsNamespace(rb: RequestBuilder): {
75
+ /**
76
+ * Permanently deletes a thread and all of its messages.
77
+ *
78
+ * This action is irreversible. All messages, attachments, and metadata
79
+ * associated with the thread are removed. If you only need to hide the
80
+ * thread from default listings without losing the history, use
81
+ * {@link archive} instead.
82
+ *
83
+ * @param id - The UUID of the thread to delete.
84
+ * @param options - Optional request options.
85
+ * @returns A promise that resolves to `true` on successful deletion.
86
+ *
87
+ * @example
88
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
89
+ * await client.threads.delete('thr_01HXYZ...');
90
+ */
91
+ delete: (id: string, options?: RequestOptions) => Promise<true>;
92
+ /**
93
+ * Lists threads in the workspace with optional pagination controls.
94
+ *
95
+ * By default only non-archived threads are returned. Use {@link listAll}
96
+ * to fetch every thread across all pages automatically.
97
+ *
98
+ * @param options - Optional pagination and request options.
99
+ * @param options.page - The page number to fetch (1-based). Defaults to 1.
100
+ * @param options.pageSize - Number of threads per page. Defaults to the server default.
101
+ * @returns A promise that resolves to an array of `Thread` objects on the requested page.
102
+ *
103
+ * @example
104
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
105
+ *
106
+ * // Second page, 20 threads
107
+ * const page2 = await client.threads.list({ page: 2, pageSize: 20 });
108
+ */
109
+ list: (options?: {
110
+ page?: number;
111
+ pageSize?: number;
112
+ } & RequestOptions) => Promise<Thread[]>;
113
+ /**
114
+ * Lists only the calling user's threads within their current workspace.
115
+ *
116
+ * Unlike {@link list} which returns all threads in the workspace (for admin
117
+ * visibility), `listMine` scopes results to threads owned by the
118
+ * authenticated user. This is the recommended method for end-user UIs.
119
+ *
120
+ * @param options - Optional pagination and request options.
121
+ * @returns A promise that resolves to an array of the user's `Thread` objects.
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * const myThreads = await client.threads.listMine();
126
+ * myThreads.forEach(t => console.log(t.attributes.title));
127
+ * ```
128
+ */
129
+ listMine: (options?: {
130
+ page?: number;
131
+ pageSize?: number;
132
+ } & RequestOptions) => Promise<Thread[]>;
133
+ /**
134
+ * Fetches all threads in the workspace by transparently paginating through
135
+ * every page until exhausted.
136
+ *
137
+ * This is a convenience wrapper that handles page management automatically.
138
+ * For workspaces with very many threads, prefer {@link list} with explicit
139
+ * pagination to control memory usage.
140
+ *
141
+ * @param options - Optional request options.
142
+ * @returns A promise that resolves to a flat array of every `Thread` in the workspace.
143
+ *
144
+ * @example
145
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
146
+ * const allThreads = await client.threads.listAll();
147
+ * console.log(`Total threads: ${allThreads.length}`);
148
+ */
149
+ listAll: (options?: RequestOptions) => Promise<Thread[]>;
150
+ /**
151
+ * Creates a new conversation thread.
152
+ *
153
+ * Threads are the container for messages between a user and an AI agent.
154
+ * You can optionally associate the thread with an agent, a user identity,
155
+ * or a workspace context by passing relevant fields in `attributes`.
156
+ *
157
+ * @param attributes - Thread attributes such as `title`, `agent_id`,
158
+ * `metadata`, or any custom fields accepted by the server.
159
+ * @param options - Optional request options.
160
+ * @returns A promise that resolves to the newly created `Thread` object.
161
+ *
162
+ * @example
163
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
164
+ *
165
+ * const thread = await client.threads.create({
166
+ * title: 'Invoice review session',
167
+ * agent_id: 'agt_01HXYZ...',
168
+ * });
169
+ * console.log(`Thread ID: ${thread.id}`);
170
+ */
171
+ create: (attributes: CreateThreadAttributes, options?: RequestOptions) => Promise<Thread>;
172
+ /**
173
+ * Updates one or more attributes of an existing thread.
174
+ *
175
+ * Only the fields present in `attributes` are changed (PATCH semantics).
176
+ * Commonly used to rename a thread or update its metadata after creation.
177
+ *
178
+ * @param id - The UUID of the thread to update.
179
+ * @param attributes - A partial map of thread attributes to update
180
+ * (e.g. `{ title: 'Renamed thread', metadata: { priority: 'high' } }`).
181
+ * @param options - Optional request options.
182
+ * @returns A promise that resolves to the updated `Thread` object.
183
+ *
184
+ * @example
185
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
186
+ *
187
+ * const updated = await client.threads.update('thr_01HXYZ...', {
188
+ * title: 'Q2 Invoice Review',
189
+ * });
190
+ */
191
+ update: (id: string, attributes: UpdateThreadAttributes, options?: RequestOptions) => Promise<Thread>;
192
+ /**
193
+ * Merge metadata into the thread's existing metadata (shallow merge).
194
+ *
195
+ * Keys present in the input overwrite existing keys; keys not present are
196
+ * preserved. Use `update({ metadata })` instead for full replacement.
197
+ *
198
+ * @param id - The UUID of the thread to update.
199
+ * @param metadata - Key-value pairs to merge into existing metadata.
200
+ * @param options - Optional request options.
201
+ * @returns A promise that resolves to the updated `Thread`.
202
+ *
203
+ * @example
204
+ * ```typescript
205
+ * await client.threads.updateMetadata(threadId, {
206
+ * pinned_context: { client_id: 'uuid', client_name: 'Sarah Johnson' },
207
+ * });
208
+ * ```
209
+ */
210
+ updateMetadata: (id: string, metadata: Record<string, unknown>, options?: RequestOptions) => Promise<Thread>;
211
+ /**
212
+ * Generates an AI-produced summary of the thread's conversation history.
213
+ *
214
+ * Triggers an LLM call that reads all messages in the thread and produces a
215
+ * concise natural-language summary. The summary is stored on the thread and
216
+ * returned as part of the response. Useful for giving users a quick recap of
217
+ * long conversations or for providing context before forking.
218
+ *
219
+ * @param id - The UUID of the thread to summarize.
220
+ * @param options - Optional request options.
221
+ * @returns A promise that resolves to the `Thread` object with the generated
222
+ * summary populated in `attributes.context_summary`.
223
+ *
224
+ * @example
225
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
226
+ * const thread = await client.threads.summarize('thr_01HXYZ...');
227
+ * console.log(thread.attributes.context_summary);
228
+ */
229
+ summarize: (id: string, options?: RequestOptions) => Promise<Thread>;
230
+ /**
231
+ * Forks a thread by creating a new thread that is a full copy of the original,
232
+ * including all of its messages.
233
+ *
234
+ * The forked thread is independent — changes to either thread after forking
235
+ * do not affect the other. Forking is useful for branching a conversation to
236
+ * explore a different line of questioning without losing the original, or for
237
+ * creating a template thread that can be re-used across multiple users.
238
+ *
239
+ * @param id - The UUID of the thread to fork.
240
+ * @param options - Optional request options.
241
+ * @returns A promise that resolves to the newly created fork as a `Thread` object.
242
+ *
243
+ * @example
244
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
245
+ * const fork = await client.threads.fork('thr_01HXYZ...');
246
+ * console.log(`Forked into new thread: ${fork.id}`);
247
+ */
248
+ fork: (id: string, title?: string, options?: RequestOptions) => Promise<Thread>;
249
+ /**
250
+ * Exports a thread and all of its messages in a portable format.
251
+ *
252
+ * The export includes the thread metadata and the full ordered message
253
+ * history. Supported output formats include JSON (structured), Markdown
254
+ * (human-readable), and plain text. The desired format can be specified
255
+ * via request options or query parameters.
256
+ *
257
+ * @param id - The UUID of the thread to export.
258
+ * @param format - Export format: `'json'`, `'markdown'`, or `'text'`. Defaults to `'json'`.
259
+ * @param options - Optional request options.
260
+ * @returns A promise that resolves to the export payload.
261
+ *
262
+ * @example
263
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
264
+ * const exported = await client.threads.export('thr_01HXYZ...', 'markdown');
265
+ * console.log(exported.content);
266
+ */
267
+ export: (id: string, format?: "json" | "markdown" | "text", options?: RequestOptions) => Promise<Thread>;
268
+ /**
269
+ * Fetches a single thread by its ID.
270
+ *
271
+ * @param id - The UUID of the thread to retrieve.
272
+ * @param options - Optional request options.
273
+ * @returns A promise that resolves to the full `Thread` object.
274
+ *
275
+ * @example
276
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
277
+ * const thread = await client.threads.get('thr_01HXYZ...');
278
+ * console.log(thread.attributes.title);
279
+ */
280
+ get: (id: string, options?: RequestOptions) => Promise<Thread>;
281
+ /**
282
+ * Archives a thread, soft-deleting it by hiding it from default listings.
283
+ *
284
+ * Archived threads are not permanently deleted — their messages, metadata,
285
+ * and history are preserved. They will no longer appear in the default
286
+ * `list` results but can be restored at any time using {@link unarchive}.
287
+ * Archiving is the recommended way to "clean up" a thread without losing
288
+ * its history.
289
+ *
290
+ * @param id - The UUID of the thread to archive.
291
+ * @param options - Optional request options.
292
+ * @returns A promise that resolves to the `Thread` object with
293
+ * `attributes.archived_at` populated.
294
+ *
295
+ * @example
296
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
297
+ * const archived = await client.threads.archive('thr_01HXYZ...');
298
+ * console.log(`Archived at: ${archived.attributes.archived_at}`);
299
+ */
300
+ archive: (id: string, options?: RequestOptions) => Promise<Thread>;
301
+ /**
302
+ * Restores a previously archived thread back to active status.
303
+ *
304
+ * After unarchiving, the thread will appear again in default `list` results
305
+ * and all of its messages will be accessible as normal.
306
+ *
307
+ * @param id - The UUID of the archived thread to restore.
308
+ * @param options - Optional request options.
309
+ * @returns A promise that resolves to the restored `Thread` object with
310
+ * `attributes.archived_at` cleared.
311
+ *
312
+ * @example
313
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
314
+ * const restored = await client.threads.unarchive('thr_01HXYZ...');
315
+ * console.log(`Archived at: ${restored.attributes.archived_at}`); // null
316
+ */
317
+ unarchive: (id: string, options?: RequestOptions) => Promise<Thread>;
318
+ /**
319
+ * Sub-namespace for reading and sending messages within a thread.
320
+ *
321
+ * Messages are the ordered entries within a thread. The platform supports
322
+ * both synchronous (request/response) message sending via {@link send} and
323
+ * real-time token streaming via {@link stream} using Server-Sent Events (SSE).
324
+ *
325
+ * @example
326
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
327
+ *
328
+ * // Non-streaming
329
+ * const reply = await client.threads.messages.send('thr_01HXYZ...', 'Hello!');
330
+ *
331
+ * // Streaming
332
+ * const stream = await client.threads.messages.stream('thr_01HXYZ...', { content: 'Hello!' });
333
+ * for await (const chunk of stream) {
334
+ * if (chunk.type === 'token') process.stdout.write(chunk.content ?? '');
335
+ * }
336
+ */
337
+ messages: {
338
+ /**
339
+ * Lists all messages in a thread.
340
+ *
341
+ * Messages are returned in ascending chronological order (oldest first).
342
+ * Each message includes the role (`user` or `assistant`), content, timestamp,
343
+ * and any associated metadata.
344
+ *
345
+ * @param threadId - The UUID of the thread whose messages to list.
346
+ * @param options - Optional request options.
347
+ * @returns A promise that resolves to an array of message objects ordered
348
+ * oldest-first.
349
+ *
350
+ * @example
351
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
352
+ * const messages = await client.threads.messages.list('thr_01HXYZ...');
353
+ * messages.forEach(m => console.log(`${m.attributes.role}: ${m.attributes.content}`));
354
+ */
355
+ list: (threadId: string, options?: RequestOptions) => Promise<Message[]>;
356
+ /**
357
+ * Sends a message to a thread and waits for the full AI response before
358
+ * returning (non-streaming).
359
+ *
360
+ * The platform routes the message to the agent associated with the thread,
361
+ * runs inference, and returns the complete assistant reply once generation
362
+ * finishes. For long responses or low-latency UIs, prefer {@link stream}
363
+ * which delivers tokens incrementally as they are generated.
364
+ *
365
+ * @param threadId - The UUID of the thread to send the message to.
366
+ * @param content - The text content of the user message.
367
+ * @param attributes - Optional additional message attributes such as
368
+ * `attachments`, `metadata`, or `role` override.
369
+ * @param options - Optional request options.
370
+ * @returns A promise that resolves to the created message object, including
371
+ * the full assistant reply in `attributes.content`.
372
+ *
373
+ * @example
374
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
375
+ *
376
+ * const reply = await client.threads.messages.send(
377
+ * 'thr_01HXYZ...',
378
+ * 'What is the total amount due on the invoice?',
379
+ * );
380
+ * console.log(`Assistant: ${reply.attributes.content}`);
381
+ */
382
+ send: (threadId: string, content: string, attributes?: SendMessageAttributes, options?: RequestOptions) => Promise<Message>;
383
+ /**
384
+ * Inserts a pre-generated message into a thread WITHOUT triggering AI inference.
385
+ *
386
+ * Use this to persist results from specialized agent executions (via
387
+ * `sdk.agents.executions.start()`) back into a thread. The message is stored
388
+ * with PII compliance scan and async vectorization, but no LLM call is made.
389
+ *
390
+ * @param threadId - The UUID of the thread to insert the message into.
391
+ * @param content - The message content text.
392
+ * @param attributes - Message attributes including `role` (typically `'assistant'`).
393
+ * @param options - Optional request options.
394
+ * @returns A promise resolving to the created `Message`.
395
+ *
396
+ * @example
397
+ * ```typescript
398
+ * const message = await client.threads.messages.insert(threadId, result.content, {
399
+ * role: 'assistant',
400
+ * metadata: { execution_id: execution.id, agent_id: agentId },
401
+ * });
402
+ * ```
403
+ */
404
+ insert: (threadId: string, content: string, attributes: InsertMessageAttributes, options?: RequestOptions) => Promise<Message>;
405
+ /**
406
+ * Submit thumbs up/down feedback on a message. Uses upsert — calling again
407
+ * on the same message replaces the previous rating.
408
+ *
409
+ * @param messageId - The UUID of the message to rate.
410
+ * @param rating - `'up'` or `'down'`.
411
+ * @param comment - Optional comment explaining the rating.
412
+ * @param options - Optional request options.
413
+ * @returns A promise resolving to the created/updated `MessageFeedback`.
414
+ *
415
+ * @example
416
+ * ```typescript
417
+ * await client.threads.messages.rate(messageId, 'up');
418
+ * await client.threads.messages.rate(messageId, 'down', 'Response was inaccurate');
419
+ * ```
420
+ */
421
+ rate: (messageId: string, rating: "up" | "down", comment?: string, options?: RequestOptions) => Promise<MessageFeedback>;
422
+ /**
423
+ * Update an existing message's content, role, or metadata (PATCH semantics).
424
+ *
425
+ * Only the fields present in `attributes` are changed. Useful for attaching
426
+ * metadata (e.g., execution_id, tool_call details) to a message after creation.
427
+ *
428
+ * @param messageId - The UUID of the message to update.
429
+ * @param attributes - Fields to update.
430
+ * @param options - Optional request options.
431
+ * @returns A promise resolving to the updated `Message`.
432
+ *
433
+ * @example
434
+ * ```typescript
435
+ * await client.threads.messages.update(messageId, {
436
+ * metadata: { execution_id: 'exec_123', reviewed: true },
437
+ * });
438
+ * ```
439
+ */
440
+ update: (messageId: string, attributes: UpdateMessageAttributes, options?: RequestOptions) => Promise<Message>;
441
+ /**
442
+ * Sends a message to a thread and streams the AI response via Server-Sent Events (SSE).
443
+ *
444
+ * For agent-backed threads, the stream includes the full execution lifecycle:
445
+ * - `token` — incremental LLM output tokens
446
+ * - `tool_call` — agent is calling a tool (name + arguments)
447
+ * - `tool_result` — tool execution completed (name + summary)
448
+ * - `iteration_complete` — LLM loop iteration finished
449
+ * - `approval_required` — human approval needed for a sensitive tool
450
+ * - `done` — stream complete, includes metadata with execution_id
451
+ * - `error` — stream error
452
+ *
453
+ * For RAG threads (no agent), only `token`, `done`, and `error` are emitted.
454
+ *
455
+ * SSE security limits: 5-minute idle timeout, 10,000 chunk maximum,
456
+ * 10 MB buffer size limit.
457
+ *
458
+ * @param threadId - The UUID of the thread to stream a message to.
459
+ * @param body - The message payload, including at minimum `content` (string).
460
+ * @param options - Optional request options (e.g. custom headers, abort signal).
461
+ * @param streamOptions - Optional streaming configuration (e.g. chunk timeout).
462
+ * @returns A promise that resolves to an `AsyncIterableIterator<StreamMessageChunk>`.
463
+ *
464
+ * @example
465
+ * ```typescript
466
+ * const stream = await client.threads.messages.stream(threadId, { content: 'Summarize the contract.' });
467
+ * for await (const event of stream) {
468
+ * switch (event.type) {
469
+ * case 'token':
470
+ * process.stdout.write(event.content ?? '');
471
+ * break;
472
+ * case 'tool_call':
473
+ * console.log(`Tool: ${event.data.name}`, event.data.arguments);
474
+ * break;
475
+ * case 'tool_result':
476
+ * console.log(`Result: ${event.data.summary}`);
477
+ * break;
478
+ * case 'done':
479
+ * console.log('Complete', event.metadata);
480
+ * break;
481
+ * }
482
+ * }
483
+ * ```
484
+ */
485
+ stream: (threadId: string, body: Record<string, unknown>, options?: RequestOptions, streamOptions?: StreamOptions) => Promise<AsyncIterableIterator<StreamMessageChunk>>;
486
+ /**
487
+ * Full-text substring search across message content.
488
+ * Optionally filter to a specific thread.
489
+ *
490
+ * @param query - Substring to match against message content.
491
+ * @param threadId - Optional thread UUID to scope the search.
492
+ * @param options - Optional request options.
493
+ * @returns A promise resolving to an array of matching `Message` objects.
494
+ *
495
+ * @example
496
+ * ```typescript
497
+ * // Search all messages
498
+ * const all = await client.threads.messages.search('deadline');
499
+ * // Search within a specific thread
500
+ * const scoped = await client.threads.messages.search('deadline', threadId);
501
+ * ```
502
+ */
503
+ search: (query: string, threadId?: string, options?: RequestOptions) => Promise<Message[]>;
504
+ /**
505
+ * Vector similarity search across messages using a generated embedding.
506
+ * Optionally filter to a specific thread.
507
+ *
508
+ * @param query - Natural-language query string to embed and search.
509
+ * @param limit - Maximum number of results (default: 10).
510
+ * @param threadId - Optional thread UUID to scope the search.
511
+ * @param options - Optional request options.
512
+ * @returns A promise resolving to an array of semantically similar `Message` objects.
513
+ *
514
+ * @example
515
+ * ```typescript
516
+ * const results = await client.threads.messages.semanticSearch('unpaid invoices', 5, threadId);
517
+ * ```
518
+ */
519
+ semanticSearch: (query: string, limit?: number, threadId?: string, options?: RequestOptions) => Promise<Message[]>;
520
+ };
521
+ /**
522
+ * Trigger AI inference on a thread without sending a new user message.
523
+ *
524
+ * Runs the full RAG pipeline (VectorSearch + GraphLookup + SynthesizeResponse)
525
+ * using the thread's last user message as query context. Saves the AI response
526
+ * as an assistant message and returns the updated Thread.
527
+ *
528
+ * Use this to let the AI proactively continue a conversation — for example,
529
+ * after a voice session finalizes, to generate a follow-up or summary without
530
+ * requiring the user to explicitly ask.
531
+ *
532
+ * @param threadId - The UUID of the thread to run AI completion on.
533
+ * @param options - Optional request options.
534
+ * @returns A promise resolving to the updated `Thread` after the assistant
535
+ * message has been saved.
536
+ *
537
+ * @example
538
+ * ```typescript
539
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
540
+ *
541
+ * // After a voice session finalizes, trigger AI continuation:
542
+ * const thread = await client.threads.complete('thr_01HXYZ...');
543
+ * console.log(`Thread updated at: ${thread.attributes?.updated_at}`);
544
+ * ```
545
+ */
546
+ complete: (threadId: string, options?: RequestOptions) => Promise<Thread>;
547
+ /**
548
+ * Trigger AI inference on a thread and receive the response via Server-Sent Events.
549
+ *
550
+ * For agent-backed threads (when execution bridge is enabled), this streams
551
+ * the full execution lifecycle including `token`, `tool_call`, `tool_result`,
552
+ * `iteration_complete`, `approval_required`, `done`, and `error` events.
553
+ *
554
+ * For RAG threads or when the bridge is disabled, delivers the full response
555
+ * as a single `done` event.
556
+ *
557
+ * @param threadId - The UUID of the thread to run AI completion on.
558
+ * @param options - Optional request options (e.g. abort signal).
559
+ * @param streamOptions - Optional streaming configuration.
560
+ * @returns A promise resolving to an `AsyncIterableIterator<StreamMessageChunk>`.
561
+ *
562
+ * @example
563
+ * ```typescript
564
+ * const stream = await client.threads.completeStream('thr_01HXYZ...');
565
+ * for await (const event of stream) {
566
+ * switch (event.type) {
567
+ * case 'token':
568
+ * process.stdout.write(event.content ?? '');
569
+ * break;
570
+ * case 'tool_call':
571
+ * console.log(`Tool: ${event.data.name}`);
572
+ * break;
573
+ * case 'done':
574
+ * console.log('Complete', event.metadata);
575
+ * break;
576
+ * }
577
+ * }
578
+ * ```
579
+ */
580
+ completeStream: (threadId: string, options?: RequestOptions, streamOptions?: StreamOptions) => Promise<AsyncIterableIterator<StreamMessageChunk>>;
581
+ /**
582
+ * Full-text search threads by title or context summary.
583
+ *
584
+ * @param query - The search query string.
585
+ * @param options - Optional request options.
586
+ * @returns A promise resolving to an array of matching `Thread` objects.
587
+ *
588
+ * @example
589
+ * ```typescript
590
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
591
+ * const results = await client.threads.search('invoice review');
592
+ * ```
593
+ */
594
+ search: (query: string, options?: RequestOptions) => Promise<Thread[]>;
595
+ };
596
+ //# sourceMappingURL=threads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../src/namespaces/threads.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EACV,UAAU,IAAI,MAAM,EACpB,WAAW,IAAI,OAAO,EACtB,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAEhC,mEAAmE;AACnE,MAAM,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAElD,sDAAsD;AACtD,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,yEAAyE;AACzE,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,uBAAuB,GAAG;IACpC,mEAAmE;I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