@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,1249 @@
1
+ import type { ExtractionAgent, ExtractionBatch, ExtractionDocument, ExtractionResult, TrainingAnalytics } from "../_internal/types.gen";
2
+ import type { RequestOptions } from "../base-client";
3
+ import { RequestBuilder } from "../request-builder";
4
+ /** Attributes for bulk-delete operations. */
5
+ export interface BulkOperationResult {
6
+ deleted_count?: number;
7
+ [key: string]: unknown;
8
+ }
9
+ /** Attributes for bulk-reprocess operations. */
10
+ export interface BulkReprocessResult {
11
+ enqueued_count?: number;
12
+ [key: string]: unknown;
13
+ }
14
+ /** Lightweight document processing status. */
15
+ export interface DocumentStatusResponse {
16
+ status?: string;
17
+ progress_percent?: number;
18
+ [key: string]: unknown;
19
+ }
20
+ /** Attributes for beginning an extraction document upload. */
21
+ export type BeginUploadAttributes = {
22
+ filename?: string;
23
+ content_type?: string;
24
+ size?: number;
25
+ agent_id?: string;
26
+ workspace_id?: string;
27
+ [key: string]: unknown;
28
+ };
29
+ /** Attributes for find-or-begin upload (dedup-aware). */
30
+ export type FindOrBeginUploadAttributes = {
31
+ filename?: string;
32
+ file_hash?: string;
33
+ content_type?: string;
34
+ agent_id?: string;
35
+ [key: string]: unknown;
36
+ };
37
+ /** Aggregate document statistics for a workspace. */
38
+ export interface DocumentStatsResponse {
39
+ total_count?: number;
40
+ processed_count?: number;
41
+ failed_count?: number;
42
+ pending_count?: number;
43
+ processing_count?: number;
44
+ cancelled_count?: number;
45
+ [key: string]: unknown;
46
+ }
47
+ /** Attributes for updating extraction document verification state. */
48
+ export type UpdateVerificationAttributes = {
49
+ verified?: boolean;
50
+ reviewer_id?: string;
51
+ verification_notes?: string;
52
+ [key: string]: unknown;
53
+ };
54
+ /** Result of a dismiss-all-trained operation. */
55
+ export interface DismissAllTrainedResult {
56
+ dismissed_count?: number;
57
+ [key: string]: unknown;
58
+ }
59
+ /** Attributes for requesting a presigned upload URL. */
60
+ export type ExtractionPresignedUploadAttributes = {
61
+ filename: string;
62
+ content_type?: string;
63
+ size?: number;
64
+ [key: string]: unknown;
65
+ };
66
+ /** Response from a presigned upload request. */
67
+ export interface ExtractionPresignedUploadResponse {
68
+ upload_url?: string;
69
+ document_id?: string;
70
+ [key: string]: unknown;
71
+ }
72
+ /** Attributes for updating an extraction result. */
73
+ export type UpdateExtractionResultAttributes = {
74
+ review_status?: string;
75
+ [key: string]: unknown;
76
+ };
77
+ /** Attributes for regenerating an extraction result. */
78
+ export type RegenerateResultAttributes = {
79
+ agent_version?: string;
80
+ [key: string]: unknown;
81
+ };
82
+ /** Attributes for saving corrections on an extraction result. */
83
+ export type SaveCorrectionsAttributes = {
84
+ corrections: Record<string, unknown>[];
85
+ [key: string]: unknown;
86
+ };
87
+ /** Attributes for creating an extraction batch. */
88
+ export type CreateExtractionBatchAttributes = {
89
+ name?: string;
90
+ agent_id?: string;
91
+ workspace_id?: string;
92
+ document_ids?: string[];
93
+ [key: string]: unknown;
94
+ };
95
+ /** An extraction export record. */
96
+ export interface ExtractionExportRecord {
97
+ id?: string;
98
+ status?: string;
99
+ format?: string;
100
+ download_url?: string;
101
+ [key: string]: unknown;
102
+ }
103
+ /** Attributes for creating an extraction export. */
104
+ export type CreateExtractionExportAttributes = {
105
+ format: "csv" | "json" | "excel";
106
+ agent_id?: string;
107
+ [key: string]: unknown;
108
+ };
109
+ /** Attributes for creating a schema discovery job. */
110
+ export type CreateSchemaDiscoveryAttributes = {
111
+ document_ids?: string[];
112
+ sample_text?: string;
113
+ [key: string]: unknown;
114
+ };
115
+ /** A schema discovery record. */
116
+ export interface SchemaDiscoveryRecord {
117
+ id?: string;
118
+ status?: string;
119
+ suggested_fields?: Record<string, unknown>[];
120
+ [key: string]: unknown;
121
+ }
122
+ /** A field template record. */
123
+ export interface FieldTemplateRecord {
124
+ id?: string;
125
+ name?: string;
126
+ category?: string;
127
+ field_type?: string;
128
+ [key: string]: unknown;
129
+ }
130
+ /** Attributes for creating a field template. */
131
+ export type CreateFieldTemplateAttributes = {
132
+ name: string;
133
+ category?: string;
134
+ field_type?: string;
135
+ [key: string]: unknown;
136
+ };
137
+ /** A field mapping record. */
138
+ export interface FieldMappingRecord {
139
+ confirmed?: boolean;
140
+ mappings?: Record<string, unknown>[];
141
+ [key: string]: unknown;
142
+ }
143
+ /** Attributes for creating/confirming a field mapping. */
144
+ export type CreateFieldMappingAttributes = {
145
+ confirmed: boolean;
146
+ mappings?: Record<string, unknown>[];
147
+ [key: string]: unknown;
148
+ };
149
+ /**
150
+ * A single attribute filter predicate for server-side JSONB row filtering.
151
+ * Operators: eq, not_eq, contains, in, lt, gt, not_null
152
+ */
153
+ export interface AttributeFilter {
154
+ /** The column name to filter on */
155
+ field: string;
156
+ /** Comparison operator */
157
+ op: "eq" | "not_eq" | "contains" | "in" | "lt" | "gt" | "not_null";
158
+ /** The comparison value. Not required for `not_null`. For `in`, must be an array. */
159
+ value?: unknown;
160
+ }
161
+ /** Parameters for `results.query()` */
162
+ export interface ExtractionRowQueryParams {
163
+ /** Filter predicates applied server-side (AND semantics). Empty array returns all rows. */
164
+ filters?: AttributeFilter[];
165
+ /** Maximum rows to return. Defaults to 1000. Server enforces max 5000. */
166
+ limit?: number;
167
+ /** Zero-based row offset for pagination. Defaults to 0. */
168
+ offset?: number;
169
+ }
170
+ /** Response from `results.query()` */
171
+ export interface ExtractionRowQueryResult {
172
+ /** Matching rows (up to `limit` rows) */
173
+ rows: Record<string, unknown>[];
174
+ /** Total number of rows in the result (before filtering) */
175
+ total: number;
176
+ /** Number of rows that matched the filters */
177
+ filtered: number;
178
+ /** The effective limit used */
179
+ limit: number;
180
+ /** The effective offset used */
181
+ offset: number;
182
+ }
183
+ /**
184
+ * Creates the extraction namespace providing access to document upload,
185
+ * processing, results, batches, exports, schema discovery, field templates,
186
+ * and field mappings.
187
+ *
188
+ * Access via `client.extraction`.
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
193
+ *
194
+ * // Upload a document and wait for extraction
195
+ * const doc = await client.extraction.documents.upload(file);
196
+ * console.log(doc.id);
197
+ * ```
198
+ */
199
+ export declare function createExtractionNamespace(rb: RequestBuilder): {
200
+ /**
201
+ * Documents — upload, manage, and track extraction documents.
202
+ *
203
+ * Documents move through a lifecycle: `pending` → `processing` → `processed`
204
+ * (or `failed`). Use `documents.status` to poll progress. Completed documents
205
+ * have associated `ExtractionResult` records accessible via `results.byDocument`.
206
+ */
207
+ documents: {
208
+ /**
209
+ * List extraction documents with optional pagination.
210
+ *
211
+ * Returns one page of documents. Use `listAll` to automatically traverse
212
+ * all pages.
213
+ *
214
+ * @param options - Optional page number, page size, and request options.
215
+ * @returns A page of `ExtractionDocument` records.
216
+ *
217
+ * @example
218
+ * ```typescript
219
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
220
+ * const docs = await client.extraction.documents.list({ page: 1, pageSize: 25 });
221
+ * console.log(docs.length);
222
+ * ```
223
+ */
224
+ list: (options?: {
225
+ page?: number;
226
+ pageSize?: number;
227
+ } & RequestOptions) => Promise<ExtractionDocument[]>;
228
+ /**
229
+ * List all extraction documents, automatically paginating through every page.
230
+ *
231
+ * Fetches pages sequentially until the server reports no more results.
232
+ * Suitable for datasets that fit in memory; for very large collections
233
+ * prefer `list` with explicit pagination.
234
+ *
235
+ * @param options - Optional request options (signal, headers, etc.).
236
+ * @returns All `ExtractionDocument` records as a flat array.
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
241
+ * const allDocs = await client.extraction.documents.listAll();
242
+ * console.log(`Total documents: ${allDocs.length}`);
243
+ * ```
244
+ */
245
+ listAll: (options?: RequestOptions) => Promise<ExtractionDocument[]>;
246
+ /**
247
+ * Retrieve a single extraction document by its ID.
248
+ *
249
+ * @param id - The UUID of the extraction document.
250
+ * @param options - Optional request options.
251
+ * @returns The matching `ExtractionDocument`.
252
+ *
253
+ * @example
254
+ * ```typescript
255
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
256
+ * const doc = await client.extraction.documents.get('doc_abc123');
257
+ * console.log(doc.attributes?.status);
258
+ * ```
259
+ */
260
+ get: (id: string, options?: RequestOptions) => Promise<ExtractionDocument>;
261
+ /**
262
+ * Retrieve the viewer-facing representation of an extraction document.
263
+ *
264
+ * Returns a version of the document enriched with display metadata
265
+ * (e.g., page thumbnails, viewer annotations) suitable for rendering
266
+ * in the document review UI. Differs from `get` in that it may include
267
+ * pre-signed URL references for inline rendering.
268
+ *
269
+ * @param id - The UUID of the extraction document.
270
+ * @param options - Optional request options.
271
+ * @returns The viewer-enriched `ExtractionDocument`.
272
+ *
273
+ * @example
274
+ * ```typescript
275
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
276
+ * const viewDoc = await client.extraction.documents.view('doc_abc123');
277
+ * // Use viewDoc.attributes?.viewer_url for embedding in an iframe
278
+ * ```
279
+ */
280
+ view: (id: string, options?: RequestOptions) => Promise<ExtractionDocument>;
281
+ /**
282
+ * Permanently delete an extraction document.
283
+ *
284
+ * This removes the document record and its associated storage object.
285
+ * Deletion is irreversible. Any linked `ExtractionResult` records will
286
+ * also be removed by the server via cascade.
287
+ *
288
+ * @param id - The UUID of the extraction document to delete.
289
+ * @param options - Optional request options.
290
+ * @returns `true` on successful deletion.
291
+ *
292
+ * @example
293
+ * ```typescript
294
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
295
+ * await client.extraction.documents.delete('doc_abc123');
296
+ * ```
297
+ */
298
+ delete: (id: string, options?: RequestOptions) => Promise<true>;
299
+ /**
300
+ * Bulk-delete multiple extraction documents in a single request.
301
+ *
302
+ * More efficient than calling `delete` in a loop. The server processes
303
+ * deletions transactionally; if any ID is not found the entire operation
304
+ * may be rejected (depends on server policy).
305
+ *
306
+ * @param ids - Array of document UUIDs to delete.
307
+ * @param options - Optional request options.
308
+ * @returns An operation result object with counts of deleted records.
309
+ *
310
+ * @example
311
+ * ```typescript
312
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
313
+ * const result = await client.extraction.documents.bulkDelete([
314
+ * 'doc_abc123',
315
+ * 'doc_def456',
316
+ * ]);
317
+ * console.log(result);
318
+ * ```
319
+ */
320
+ bulkDelete: (ids: string[], options?: RequestOptions) => Promise<BulkOperationResult>;
321
+ /**
322
+ * Re-run extraction on an existing document.
323
+ *
324
+ * Queues the document for re-processing through the extraction pipeline.
325
+ * Useful after updating an agent's schema or correcting a failed extraction.
326
+ * The document transitions back to `processing` status and any previous
327
+ * `ExtractionResult` records are replaced on completion.
328
+ *
329
+ * @param id - The UUID of the extraction document to reprocess.
330
+ * @param options - Optional request options.
331
+ * @returns The updated `ExtractionDocument` with new processing status.
332
+ *
333
+ * @example
334
+ * ```typescript
335
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
336
+ * const doc = await client.extraction.documents.reprocess('doc_abc123');
337
+ * console.log(doc.attributes?.status); // "processing"
338
+ * ```
339
+ */
340
+ reprocess: (id: string, options?: RequestOptions) => Promise<ExtractionDocument>;
341
+ /**
342
+ * Re-run extraction on multiple documents in a single request.
343
+ *
344
+ * Enqueues all specified documents for re-processing. More efficient
345
+ * than calling `reprocess` in a loop when handling batch corrections.
346
+ *
347
+ * @param documentIds - Array of document UUIDs to reprocess.
348
+ * @param options - Optional request options.
349
+ * @returns An operation result object indicating how many jobs were enqueued.
350
+ *
351
+ * @example
352
+ * ```typescript
353
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
354
+ * const result = await client.extraction.documents.bulkReprocess([
355
+ * 'doc_abc123',
356
+ * 'doc_def456',
357
+ * ]);
358
+ * console.log(result);
359
+ * ```
360
+ */
361
+ bulkReprocess: (documentIds: string[], options?: RequestOptions) => Promise<BulkReprocessResult>;
362
+ /**
363
+ * Cancel an in-progress extraction job for a document.
364
+ *
365
+ * Signals the extraction pipeline to abort processing. The document
366
+ * transitions to `cancelled` status. A cancelled document can be
367
+ * reprocessed later via `reprocess`.
368
+ *
369
+ * @param id - The UUID of the extraction document to cancel.
370
+ * @param options - Optional request options.
371
+ * @returns The updated `ExtractionDocument` with `status: "cancelled"`.
372
+ *
373
+ * @example
374
+ * ```typescript
375
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
376
+ * const doc = await client.extraction.documents.cancel('doc_abc123');
377
+ * console.log(doc.attributes?.status); // "cancelled"
378
+ * ```
379
+ */
380
+ cancel: (id: string, options?: RequestOptions) => Promise<ExtractionDocument>;
381
+ /**
382
+ * Get the current processing status of an extraction document.
383
+ *
384
+ * Returns a lightweight status object without the full document payload.
385
+ * Suitable for polling in a tight loop to track extraction progress.
386
+ *
387
+ * @param id - The UUID of the extraction document.
388
+ * @param options - Optional request options.
389
+ * @returns A status object with at least `{ status, progress_percent }`.
390
+ *
391
+ * @example
392
+ * ```typescript
393
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
394
+ * const status = await client.extraction.documents.status('doc_abc123');
395
+ * console.log(status.status); // "processing" | "processed" | "failed"
396
+ * ```
397
+ */
398
+ status: (id: string, options?: RequestOptions) => Promise<DocumentStatusResponse>;
399
+ /**
400
+ * Phase 1 of a two-phase presigned upload: create the document record.
401
+ *
402
+ * Creates an `ExtractionDocument` in `pending_upload` status and returns
403
+ * a presigned upload URL. After uploading the file directly to storage
404
+ * using that URL, call `finishUpload` with the same document ID to
405
+ * transition the document into the extraction pipeline.
406
+ *
407
+ * Typical attributes: `{ filename, content_type, size, agent_id, workspace_id }`.
408
+ *
409
+ * @param attrs - Document attributes to seed the record with.
410
+ * @param options - Optional request options.
411
+ * @returns The newly created `ExtractionDocument` including the presigned URL.
412
+ *
413
+ * @example
414
+ * ```typescript
415
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
416
+ * const doc = await client.extraction.documents.beginUpload({
417
+ * filename: 'lab-results.pdf',
418
+ * content_type: 'application/pdf',
419
+ * size: 204800,
420
+ * agent_id: 'agent_xyz',
421
+ * });
422
+ * // doc.attributes?.upload_url contains the presigned PUT URL
423
+ * await fetch(doc.attributes!.upload_url as string, {
424
+ * method: 'PUT',
425
+ * body: fileBlob,
426
+ * });
427
+ * await client.extraction.documents.finishUpload(doc.id!);
428
+ * ```
429
+ */
430
+ beginUpload: (attrs: BeginUploadAttributes, options?: RequestOptions) => Promise<ExtractionDocument>;
431
+ /**
432
+ * Dedup-aware upload: returns an existing document if `file_hash` matches,
433
+ * otherwise creates a new document record and begins the upload flow.
434
+ *
435
+ * Pass a `file_hash` attribute (BLAKE3 or SHA-256 hex) to enable deduplication.
436
+ * If the platform already has a document with that hash in the current workspace,
437
+ * the existing document is returned without creating a duplicate. Otherwise
438
+ * behaves identically to `beginUpload`.
439
+ *
440
+ * @param attrs - Optional document attributes including `file_hash` for dedup.
441
+ * @param options - Optional request options.
442
+ * @returns The matching existing `ExtractionDocument`, or a newly created one.
443
+ *
444
+ * @example
445
+ * ```typescript
446
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
447
+ * const doc = await client.extraction.documents.findOrBeginUpload({
448
+ * filename: 'lab-results.pdf',
449
+ * file_hash: 'abc123def456...',
450
+ * agent_id: 'agent_xyz',
451
+ * });
452
+ * if (doc.attributes?.status === 'processed') {
453
+ * // Already exists — skip upload
454
+ * } else {
455
+ * // New document — proceed with upload
456
+ * }
457
+ * ```
458
+ */
459
+ findOrBeginUpload: (attrs?: FindOrBeginUploadAttributes, options?: RequestOptions) => Promise<ExtractionDocument>;
460
+ /**
461
+ * Phase 2 of a two-phase presigned upload: signal that the file is uploaded.
462
+ *
463
+ * After the binary file has been PUT directly to the presigned storage URL
464
+ * (obtained from `beginUpload`), call this method to notify the platform that
465
+ * the file is ready. The document transitions from `pending_upload` into the
466
+ * extraction pipeline (`processing`).
467
+ *
468
+ * @param id - The UUID of the extraction document created in `beginUpload`.
469
+ * @param options - Optional request options.
470
+ * @returns The updated `ExtractionDocument` now in `processing` status.
471
+ *
472
+ * @example
473
+ * ```typescript
474
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
475
+ * // After the PUT to the presigned URL completes:
476
+ * const doc = await client.extraction.documents.finishUpload('doc_abc123');
477
+ * console.log(doc.attributes?.status); // "processing"
478
+ * ```
479
+ */
480
+ finishUpload: (id: string, options?: RequestOptions) => Promise<ExtractionDocument>;
481
+ /**
482
+ * Retrieve aggregate statistics for all documents in the current workspace.
483
+ *
484
+ * Returns counts broken down by status (pending, processing, processed,
485
+ * failed, cancelled) and any quota/usage information available to the
486
+ * current actor.
487
+ *
488
+ * @param options - Optional request options.
489
+ * @returns A stats object with document counts and usage figures.
490
+ *
491
+ * @example
492
+ * ```typescript
493
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
494
+ * const stats = await client.extraction.documents.stats();
495
+ * console.log(stats.processed_count, stats.failed_count);
496
+ * ```
497
+ */
498
+ stats: (options?: RequestOptions) => Promise<DocumentStatsResponse>;
499
+ /**
500
+ * Dismiss a document from the training queue.
501
+ *
502
+ * Marks the document so it no longer appears in the "needs review" or
503
+ * "needs training" queues, without deleting it. The extracted data is
504
+ * preserved. Useful for clearing noise documents that are not worth
505
+ * adding to the training corpus.
506
+ *
507
+ * @param id - The UUID of the extraction document to dismiss.
508
+ * @param options - Optional request options.
509
+ * @returns The updated `ExtractionDocument` with a dismissed flag.
510
+ *
511
+ * @example
512
+ * ```typescript
513
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
514
+ * const doc = await client.extraction.documents.dismiss('doc_abc123');
515
+ * console.log(doc.attributes?.dismissed); // true
516
+ * ```
517
+ */
518
+ dismiss: (id: string, options?: RequestOptions) => Promise<ExtractionDocument>;
519
+ /**
520
+ * Update the human verification state of an extraction document.
521
+ *
522
+ * Allows a reviewer to mark fields as verified, flag discrepancies,
523
+ * or record the outcome of a manual review pass. Accepted attributes
524
+ * depend on the agent schema but commonly include `verified`, `reviewer_id`,
525
+ * and `verification_notes`.
526
+ *
527
+ * @param id - The UUID of the extraction document.
528
+ * @param attrs - Verification attributes to update.
529
+ * @param options - Optional request options.
530
+ * @returns The updated `ExtractionDocument` reflecting new verification state.
531
+ *
532
+ * @example
533
+ * ```typescript
534
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
535
+ * const doc = await client.extraction.documents.updateVerification('doc_abc123', {
536
+ * verified: true,
537
+ * reviewer_id: 'user_xyz',
538
+ * verification_notes: 'Values confirmed against source records.',
539
+ * });
540
+ * ```
541
+ */
542
+ updateVerification: (id: string, attrs: UpdateVerificationAttributes, options?: RequestOptions) => Promise<ExtractionDocument>;
543
+ /**
544
+ * Dismiss all documents that have already contributed to agent training.
545
+ *
546
+ * Bulk-dismisses every document in the given workspace whose extraction
547
+ * data has been used for model fine-tuning or training. Clears the
548
+ * training queue so only new, unreviewed documents remain.
549
+ *
550
+ * @param workspaceId - The UUID of the workspace to dismiss trained documents in.
551
+ * @param options - Optional request options.
552
+ * @returns An operation result with the count of dismissed documents.
553
+ *
554
+ * @example
555
+ * ```typescript
556
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
557
+ * const result = await client.extraction.documents.dismissAllTrained('ws_abc123');
558
+ * console.log(result.dismissed_count);
559
+ * ```
560
+ */
561
+ dismissAllTrained: (workspaceId: string, options?: RequestOptions) => Promise<DismissAllTrainedResult>;
562
+ /**
563
+ * List extraction documents scoped to a specific workspace.
564
+ *
565
+ * Equivalent to `list` but scoped to a single workspace. Useful when
566
+ * operating with a server-side key that has access to multiple workspaces.
567
+ *
568
+ * @param workspaceId - The UUID of the workspace to list documents for.
569
+ * @param options - Optional page number, page size, and request options.
570
+ * @returns A page of `ExtractionDocument` records in the given workspace.
571
+ *
572
+ * @example
573
+ * ```typescript
574
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
575
+ * const docs = await client.extraction.documents.listByWorkspace('ws_abc123', {
576
+ * page: 1,
577
+ * pageSize: 50,
578
+ * });
579
+ * ```
580
+ */
581
+ listByWorkspace: (workspaceId: string, options?: {
582
+ page?: number;
583
+ pageSize?: number;
584
+ } & RequestOptions) => Promise<ExtractionDocument[]>;
585
+ /**
586
+ * Upload a document file directly (single-request upload).
587
+ *
588
+ * Sends the file binary as the request body. The server creates the
589
+ * document record, stores the file, and enqueues it for extraction in
590
+ * a single atomic operation. Best for files under ~50 MB; for larger
591
+ * files use the two-phase `beginUpload` / `finishUpload` flow with
592
+ * presigned URLs to avoid gateway timeouts.
593
+ *
594
+ * @param file - The `File` or `Blob` to upload.
595
+ * @param options - Optional request options (signal for cancellation, etc.).
596
+ * @returns The newly created `ExtractionDocument` in `processing` status.
597
+ *
598
+ * @example
599
+ * ```typescript
600
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
601
+ * const fileInput = document.querySelector<HTMLInputElement>('#upload')!;
602
+ * const [file] = fileInput.files!;
603
+ * const doc = await client.extraction.documents.upload(file);
604
+ * console.log(`Document ${doc.id} is ${doc.attributes?.status}`);
605
+ * ```
606
+ */
607
+ upload: (file: File | Blob, options?: RequestOptions) => Promise<ExtractionDocument>;
608
+ /**
609
+ * Request a presigned upload URL for a document to be uploaded directly
610
+ * to cloud storage from the client.
611
+ *
612
+ * Returns a presigned PUT URL that the caller can use to upload the file
613
+ * binary directly to the storage backend without routing through the API
614
+ * server. Validated against `PresignedUploadSchema`; `filename` is
615
+ * required, `content_type` and `size` are recommended.
616
+ *
617
+ * @param attrs - Upload request attributes: `filename` (required),
618
+ * `content_type`, and `size` in bytes.
619
+ * @param options - Optional request options.
620
+ * @returns An object containing `upload_url`, `document_id`, and expiry info.
621
+ *
622
+ * @example
623
+ * ```typescript
624
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
625
+ * const result = await client.extraction.documents.presignedUpload({
626
+ * filename: 'intake-form.pdf',
627
+ * content_type: 'application/pdf',
628
+ * size: 512000,
629
+ * });
630
+ * await fetch(result.upload_url as string, {
631
+ * method: 'PUT',
632
+ * body: fileBlob,
633
+ * headers: { 'Content-Type': 'application/pdf' },
634
+ * });
635
+ * ```
636
+ */
637
+ presignedUpload: (attrs: ExtractionPresignedUploadAttributes, options?: RequestOptions) => Promise<ExtractionPresignedUploadResponse>;
638
+ };
639
+ /**
640
+ * Results — access and manage extracted data from processed documents.
641
+ *
642
+ * Each processed `ExtractionDocument` produces one or more `ExtractionResult`
643
+ * records containing the structured data extracted by the agent. Results can
644
+ * be queried, corrected, regenerated, and exported.
645
+ */
646
+ results: {
647
+ /**
648
+ * List extraction results with optional pagination.
649
+ *
650
+ * Returns one page of results. Use `listAll` to automatically traverse
651
+ * all pages.
652
+ *
653
+ * @param options - Optional page number, page size, and request options.
654
+ * @returns A page of `ExtractionResult` records.
655
+ *
656
+ * @example
657
+ * ```typescript
658
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
659
+ * const results = await client.extraction.results.list({ page: 1, pageSize: 20 });
660
+ * ```
661
+ */
662
+ list: (options?: {
663
+ page?: number;
664
+ pageSize?: number;
665
+ } & RequestOptions) => Promise<ExtractionResult[]>;
666
+ /**
667
+ * List all extraction results, automatically paginating through every page.
668
+ *
669
+ * @param options - Optional request options.
670
+ * @returns All `ExtractionResult` records as a flat array.
671
+ *
672
+ * @example
673
+ * ```typescript
674
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
675
+ * const allResults = await client.extraction.results.listAll();
676
+ * ```
677
+ */
678
+ listAll: (options?: RequestOptions) => Promise<ExtractionResult[]>;
679
+ /**
680
+ * Retrieve a single extraction result by its ID.
681
+ *
682
+ * @param id - The UUID of the extraction result.
683
+ * @param options - Optional request options.
684
+ * @returns The matching `ExtractionResult`.
685
+ *
686
+ * @example
687
+ * ```typescript
688
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
689
+ * const result = await client.extraction.results.get('res_abc123');
690
+ * console.log(result.attributes?.rows);
691
+ * ```
692
+ */
693
+ get: (id: string, options?: RequestOptions) => Promise<ExtractionResult>;
694
+ /**
695
+ * Update an extraction result's attributes.
696
+ *
697
+ * Allows updating metadata fields on a result record (e.g., tags,
698
+ * review status, custom attributes). Does not alter the extracted rows;
699
+ * use `saveCorrections` to modify extracted data.
700
+ *
701
+ * @param id - The UUID of the extraction result.
702
+ * @param attributes - Attribute map of fields to update.
703
+ * @param options - Optional request options.
704
+ * @returns The updated `ExtractionResult`.
705
+ *
706
+ * @example
707
+ * ```typescript
708
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
709
+ * const result = await client.extraction.results.update('res_abc123', {
710
+ * review_status: 'approved',
711
+ * });
712
+ * ```
713
+ */
714
+ update: (id: string, attributes: UpdateExtractionResultAttributes, options?: RequestOptions) => Promise<ExtractionResult>;
715
+ /**
716
+ * Permanently delete an extraction result.
717
+ *
718
+ * @param id - The UUID of the extraction result to delete.
719
+ * @param options - Optional request options.
720
+ * @returns `true` on successful deletion.
721
+ *
722
+ * @example
723
+ * ```typescript
724
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
725
+ * await client.extraction.results.delete('res_abc123');
726
+ * ```
727
+ */
728
+ delete: (id: string, options?: RequestOptions) => Promise<true>;
729
+ /**
730
+ * List all extraction results for a specific document.
731
+ *
732
+ * A single document may produce multiple result records (e.g., one per
733
+ * page, or one per extraction pass). This returns all of them.
734
+ *
735
+ * @param documentId - The UUID of the extraction document.
736
+ * @param options - Optional request options.
737
+ * @returns All `ExtractionResult` records for the given document.
738
+ *
739
+ * @example
740
+ * ```typescript
741
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
742
+ * const results = await client.extraction.results.byDocument('doc_abc123');
743
+ * results.forEach(r => console.log(r.attributes?.rows?.length));
744
+ * ```
745
+ */
746
+ byDocument: (documentId: string, options?: RequestOptions) => Promise<ExtractionResult[]>;
747
+ /**
748
+ * Re-run AI extraction for a specific result record.
749
+ *
750
+ * Triggers the extraction agent to reprocess the result, optionally with
751
+ * updated instructions or a different model configuration. The existing
752
+ * rows in the result are replaced when the new extraction completes.
753
+ *
754
+ * @param id - The UUID of the extraction result to regenerate.
755
+ * @param attrs - Optional attributes to influence regeneration (e.g., `agent_version`).
756
+ * @param options - Optional request options.
757
+ * @returns The updated `ExtractionResult` queued for regeneration.
758
+ *
759
+ * @example
760
+ * ```typescript
761
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
762
+ * const result = await client.extraction.results.regenerate('res_abc123', {
763
+ * agent_version: 'v2',
764
+ * });
765
+ * ```
766
+ */
767
+ regenerate: (id: string, attrs: RegenerateResultAttributes, options?: RequestOptions) => Promise<ExtractionResult>;
768
+ /**
769
+ * Submit human corrections to an extraction result for retraining.
770
+ *
771
+ * Persists manually corrected row data against the result record.
772
+ * These corrections feed into the agent's fine-tuning pipeline,
773
+ * improving future extractions on similar documents.
774
+ * Validated against `SaveCorrectionsSchema` — `corrections` must be a
775
+ * non-empty array of row objects.
776
+ *
777
+ * @param id - The UUID of the extraction result to correct.
778
+ * @param attrs - Must include a `corrections` array of corrected row objects.
779
+ * @param options - Optional request options.
780
+ * @returns The updated `ExtractionResult` with corrections applied.
781
+ *
782
+ * @example
783
+ * ```typescript
784
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
785
+ * const result = await client.extraction.results.saveCorrections('res_abc123', {
786
+ * corrections: [
787
+ * { patient_name: 'Jane Smith', dob: '1985-04-12', score: 92 },
788
+ * { patient_name: 'John Doe', dob: '1990-07-03', score: 78 },
789
+ * ],
790
+ * });
791
+ * ```
792
+ */
793
+ saveCorrections: (id: string, attrs: SaveCorrectionsAttributes, options?: RequestOptions) => Promise<ExtractionResult>;
794
+ /**
795
+ * List extraction results scoped to a specific workspace.
796
+ *
797
+ * @param workspaceId - The UUID of the workspace to list results for.
798
+ * @param options - Optional page number, page size, and request options.
799
+ * @returns A page of `ExtractionResult` records in the given workspace.
800
+ *
801
+ * @example
802
+ * ```typescript
803
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
804
+ * const results = await client.extraction.results.listByWorkspace('ws_abc123');
805
+ * ```
806
+ */
807
+ listByWorkspace: (workspaceId: string, options?: {
808
+ page?: number;
809
+ pageSize?: number;
810
+ } & RequestOptions) => Promise<ExtractionResult[]>;
811
+ /**
812
+ * Query rows in an ExtractionResult server-side.
813
+ *
814
+ * Applies `AttributeFilter` predicates against the `rows` JSONB array
815
+ * using a PostgreSQL lateral join. Suitable for datasets with 10K+ rows
816
+ * where fetching the entire result set would be impractical.
817
+ * Empty `filters` array returns all rows (paginated by `limit`/`offset`).
818
+ *
819
+ * Filter operators:
820
+ * - `eq` / `not_eq` — exact match / non-match
821
+ * - `contains` — substring match (string fields)
822
+ * - `in` — membership in an array of values
823
+ * - `lt` / `gt` — numeric less-than / greater-than
824
+ * - `not_null` — field is present and non-null (no `value` needed)
825
+ *
826
+ * @param resultId - The UUID of the extraction result to query.
827
+ * @param params - Query parameters including filters, limit, and offset.
828
+ * @param options - Optional request options.
829
+ * @returns An `ExtractionRowQueryResult` with matching rows and total counts.
830
+ *
831
+ * @example
832
+ * ```typescript
833
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
834
+ * const result = await client.extraction.results.query('res_abc123', {
835
+ * filters: [
836
+ * { field: 'wellness_score', op: 'gt', value: 75 },
837
+ * { field: 'enrolled', op: 'eq', value: 'true' },
838
+ * ],
839
+ * limit: 100,
840
+ * offset: 0,
841
+ * });
842
+ * console.log(`${result.filtered} of ${result.total} rows match`);
843
+ * ```
844
+ */
845
+ query: (resultId: string, params?: ExtractionRowQueryParams, options?: RequestOptions) => Promise<ExtractionRowQueryResult>;
846
+ };
847
+ /**
848
+ * Batches — group documents for coordinated extraction runs.
849
+ *
850
+ * Batches allow you to associate multiple documents under a single job,
851
+ * track overall completion, and perform aggregate exports.
852
+ */
853
+ batches: {
854
+ /**
855
+ * Create a new extraction batch.
856
+ *
857
+ * A batch groups documents for coordinated processing. Typical attributes
858
+ * include `name`, `agent_id`, `workspace_id`, and an initial list of
859
+ * `document_ids`.
860
+ *
861
+ * @param attributes - Batch creation attributes.
862
+ * @param options - Optional request options.
863
+ * @returns The newly created `ExtractionBatch`.
864
+ *
865
+ * @example
866
+ * ```typescript
867
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
868
+ * const batch = await client.extraction.batches.create({
869
+ * name: 'Q1 Lab Reports',
870
+ * agent_id: 'agent_xyz',
871
+ * workspace_id: 'ws_abc123',
872
+ * });
873
+ * console.log(batch.id);
874
+ * ```
875
+ */
876
+ create: (attributes: CreateExtractionBatchAttributes, options?: RequestOptions) => Promise<ExtractionBatch>;
877
+ /**
878
+ * Retrieve a single extraction batch by its ID.
879
+ *
880
+ * @param id - The UUID of the extraction batch.
881
+ * @param options - Optional request options.
882
+ * @returns The matching `ExtractionBatch` with current status and document counts.
883
+ *
884
+ * @example
885
+ * ```typescript
886
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
887
+ * const batch = await client.extraction.batches.get('batch_abc123');
888
+ * console.log(batch.attributes?.completed_count, '/', batch.attributes?.total_count);
889
+ * ```
890
+ */
891
+ get: (id: string, options?: RequestOptions) => Promise<ExtractionBatch>;
892
+ /**
893
+ * Delete an extraction batch.
894
+ *
895
+ * Removes the batch record. Documents that were part of the batch are
896
+ * not deleted; only the batch grouping is removed.
897
+ *
898
+ * @param id - The UUID of the extraction batch to delete.
899
+ * @param options - Optional request options.
900
+ * @returns `true` on successful deletion.
901
+ *
902
+ * @example
903
+ * ```typescript
904
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
905
+ * await client.extraction.batches.delete('batch_abc123');
906
+ * ```
907
+ */
908
+ delete: (id: string, options?: RequestOptions) => Promise<true>;
909
+ /**
910
+ * List extraction batches scoped to a specific workspace.
911
+ *
912
+ * @param workspaceId - The UUID of the workspace to list batches for.
913
+ * @param options - Optional page number, page size, and request options.
914
+ * @returns A page of `ExtractionBatch` records in the given workspace.
915
+ *
916
+ * @example
917
+ * ```typescript
918
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
919
+ * const batches = await client.extraction.batches.listByWorkspace('ws_abc123');
920
+ * ```
921
+ */
922
+ listByWorkspace: (workspaceId: string, options?: {
923
+ page?: number;
924
+ pageSize?: number;
925
+ } & RequestOptions) => Promise<ExtractionBatch[]>;
926
+ };
927
+ /**
928
+ * Exports — generate downloadable files from extraction results.
929
+ *
930
+ * Exports produce CSV, JSON, or Excel files containing the extracted
931
+ * data for a workspace. Export jobs are asynchronous; poll the returned
932
+ * record until `status` is `"ready"`, then use the provided download URL.
933
+ */
934
+ exports: {
935
+ /**
936
+ * List extraction exports for a workspace.
937
+ *
938
+ * @param workspaceId - The UUID of the workspace to list exports for.
939
+ * @param options - Optional page number, page size, and request options.
940
+ * @returns A page of export records.
941
+ *
942
+ * @example
943
+ * ```typescript
944
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
945
+ * const exports = await client.extraction.exports.list('ws_abc123');
946
+ * ```
947
+ */
948
+ list: (workspaceId: string, options?: {
949
+ page?: number;
950
+ pageSize?: number;
951
+ } & RequestOptions) => Promise<ExtractionExportRecord[]>;
952
+ /**
953
+ * Create a new extraction export job for a workspace.
954
+ *
955
+ * Enqueues an async export. Required attributes: `format` (one of
956
+ * `"csv"`, `"json"`, `"excel"`). Optional: `agent_id` to filter results
957
+ * to a specific agent.
958
+ * Validated against `ExportCreateSchema`.
959
+ *
960
+ * @param workspaceId - The UUID of the workspace to export from.
961
+ * @param attrs - Export attributes: `format` and optional `agent_id`.
962
+ * @param options - Optional request options.
963
+ * @returns The newly created export record (initially `status: "pending"`).
964
+ *
965
+ * @example
966
+ * ```typescript
967
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
968
+ * const exportJob = await client.extraction.exports.create('ws_abc123', {
969
+ * format: 'csv',
970
+ * agent_id: 'agent_xyz',
971
+ * });
972
+ * console.log(exportJob.id); // Poll until exportJob.status === "ready"
973
+ * ```
974
+ */
975
+ create: (workspaceId: string, attrs: CreateExtractionExportAttributes, options?: RequestOptions) => Promise<ExtractionExportRecord>;
976
+ /**
977
+ * Fetches a single export by ID.
978
+ *
979
+ * @param workspaceId - The UUID of the workspace.
980
+ * @param id - The export record ID.
981
+ * @param options - Optional request options.
982
+ * @returns The export record.
983
+ *
984
+ * @example
985
+ * ```typescript
986
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
987
+ * const exportJob = await client.extraction.exports.get('ws_abc123', 'export_id');
988
+ * ```
989
+ */
990
+ get: (workspaceId: string, id: string, options?: RequestOptions) => Promise<ExtractionExportRecord>;
991
+ };
992
+ /**
993
+ * Schema Discoveries — AI-powered schema inference from sample documents.
994
+ *
995
+ * Submit sample documents to have the platform infer a recommended
996
+ * extraction schema (field names, types, nesting). Use the discovered
997
+ * schema as a starting point for a new agent definition.
998
+ */
999
+ schemaDiscoveries: {
1000
+ /**
1001
+ * Initiate a new schema discovery job.
1002
+ *
1003
+ * Submits sample document IDs or raw text to the schema inference engine.
1004
+ * The job runs asynchronously; poll with `get` until `status` is `"complete"`.
1005
+ *
1006
+ * @param attrs - Discovery attributes, typically including `document_ids`
1007
+ * or `sample_text`.
1008
+ * @param options - Optional request options.
1009
+ * @returns The newly created schema discovery record.
1010
+ *
1011
+ * @example
1012
+ * ```typescript
1013
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
1014
+ * const discovery = await client.extraction.schemaDiscoveries.create({
1015
+ * document_ids: ['doc_abc123', 'doc_def456'],
1016
+ * });
1017
+ * console.log(discovery.id); // Poll until discovery.status === "complete"
1018
+ * ```
1019
+ */
1020
+ create: (attrs: CreateSchemaDiscoveryAttributes, options?: RequestOptions) => Promise<SchemaDiscoveryRecord>;
1021
+ /**
1022
+ * Retrieve the result of a schema discovery job.
1023
+ *
1024
+ * Once `status` is `"complete"`, the result includes `suggested_fields`
1025
+ * — an array of inferred field definitions suitable for use in an agent
1026
+ * schema.
1027
+ *
1028
+ * @param id - The UUID of the schema discovery job.
1029
+ * @param options - Optional request options.
1030
+ * @returns The schema discovery record with `suggested_fields` when complete.
1031
+ *
1032
+ * @example
1033
+ * ```typescript
1034
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
1035
+ * const discovery = await client.extraction.schemaDiscoveries.get('sd_abc123');
1036
+ * if (discovery.status === 'complete') {
1037
+ * console.log(discovery.suggested_fields);
1038
+ * }
1039
+ * ```
1040
+ */
1041
+ get: (id: string, options?: RequestOptions) => Promise<SchemaDiscoveryRecord>;
1042
+ };
1043
+ /**
1044
+ * Field Templates — reusable extraction field definitions.
1045
+ *
1046
+ * Field templates are named, typed field definitions that can be reused
1047
+ * across multiple agent schemas. They serve as a shared vocabulary of
1048
+ * extraction fields within a workspace, reducing duplication and improving
1049
+ * consistency.
1050
+ */
1051
+ fieldTemplates: {
1052
+ /**
1053
+ * List all field templates available to the current actor.
1054
+ *
1055
+ * @param options - Optional request options.
1056
+ * @returns An array of field template records.
1057
+ *
1058
+ * @example
1059
+ * ```typescript
1060
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
1061
+ * const templates = await client.extraction.fieldTemplates.list();
1062
+ * templates.forEach(t => console.log(t.attributes?.name));
1063
+ * ```
1064
+ */
1065
+ list: (options?: RequestOptions) => Promise<FieldTemplateRecord[]>;
1066
+ /**
1067
+ * Retrieve a single field template by its ID.
1068
+ *
1069
+ * @param id - The UUID of the field template.
1070
+ * @param options - Optional request options.
1071
+ * @returns The matching field template record.
1072
+ *
1073
+ * @example
1074
+ * ```typescript
1075
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
1076
+ * const template = await client.extraction.fieldTemplates.get('ft_abc123');
1077
+ * console.log(template.attributes?.field_type);
1078
+ * ```
1079
+ */
1080
+ get: (id: string, options?: RequestOptions) => Promise<FieldTemplateRecord>;
1081
+ /**
1082
+ * Create a new field template.
1083
+ *
1084
+ * Required attribute: `name`. Optional: `category` (for grouping in the UI)
1085
+ * and `field_type` (e.g., `"text"`, `"number"`, `"date"`).
1086
+ * Validated against `FieldTemplateCreateSchema`.
1087
+ *
1088
+ * @param attrs - Field template attributes. `name` is required.
1089
+ * @param options - Optional request options.
1090
+ * @returns The newly created field template record.
1091
+ *
1092
+ * @example
1093
+ * ```typescript
1094
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
1095
+ * const template = await client.extraction.fieldTemplates.create({
1096
+ * name: 'Patient DOB',
1097
+ * category: 'demographics',
1098
+ * field_type: 'date',
1099
+ * });
1100
+ * console.log(template.id);
1101
+ * ```
1102
+ */
1103
+ create: (attrs: CreateFieldTemplateAttributes, options?: RequestOptions) => Promise<FieldTemplateRecord>;
1104
+ /**
1105
+ * Delete a field template.
1106
+ *
1107
+ * @param id - The UUID of the field template to delete.
1108
+ * @param options - Optional request options.
1109
+ * @returns `true` on successful deletion.
1110
+ *
1111
+ * @example
1112
+ * ```typescript
1113
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
1114
+ * await client.extraction.fieldTemplates.delete('ft_abc123');
1115
+ * ```
1116
+ */
1117
+ delete: (id: string, options?: RequestOptions) => Promise<true>;
1118
+ };
1119
+ /**
1120
+ * Field Mappings — confirm AI-suggested column-to-field mappings.
1121
+ *
1122
+ * When uploading structured documents (CSV, Excel), the platform infers
1123
+ * how source columns map to agent schema fields. Field mappings record
1124
+ * the confirmed (or corrected) mapping for a specific document.
1125
+ */
1126
+ fieldMappings: {
1127
+ /**
1128
+ * Retrieve the current field mapping for a document within a workspace.
1129
+ *
1130
+ * Returns the mapping object describing how source columns in the document
1131
+ * correspond to agent schema fields, along with the current confirmation status.
1132
+ *
1133
+ * @param workspaceId - The UUID of the workspace.
1134
+ * @param documentId - The UUID of the extraction document.
1135
+ * @param options - Optional request options.
1136
+ * @returns The field mapping record for the document.
1137
+ *
1138
+ * @example
1139
+ * ```typescript
1140
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
1141
+ * const mapping = await client.extraction.fieldMappings.get('ws_abc123', 'doc_abc123');
1142
+ * console.log(mapping.mappings);
1143
+ * ```
1144
+ */
1145
+ get: (workspaceId: string, documentId: string, options?: RequestOptions) => Promise<FieldMappingRecord>;
1146
+ /**
1147
+ * Confirm or update the field mapping for a document.
1148
+ *
1149
+ * Saves the mapping between source document columns and agent schema fields.
1150
+ * Must include `confirmed: true` to mark the mapping as approved and trigger
1151
+ * extraction. Optionally include `mappings` to override the AI-suggested mapping.
1152
+ * Validated against `FieldMappingCreateSchema`.
1153
+ *
1154
+ * @param workspaceId - The UUID of the workspace.
1155
+ * @param documentId - The UUID of the extraction document.
1156
+ * @param attrs - Mapping confirmation: `confirmed` (required) and optional `mappings` array.
1157
+ * @param options - Optional request options.
1158
+ * @returns The saved field mapping confirmation record.
1159
+ *
1160
+ * @example
1161
+ * ```typescript
1162
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
1163
+ * const mapping = await client.extraction.fieldMappings.create(
1164
+ * 'ws_abc123',
1165
+ * 'doc_abc123',
1166
+ * {
1167
+ * confirmed: true,
1168
+ * mappings: [
1169
+ * { source_column: 'Patient Name', target_field: 'patient_name' },
1170
+ * { source_column: 'DOB', target_field: 'date_of_birth' },
1171
+ * ],
1172
+ * },
1173
+ * );
1174
+ * ```
1175
+ */
1176
+ create: (workspaceId: string, documentId: string, attrs: CreateFieldMappingAttributes, options?: RequestOptions) => Promise<FieldMappingRecord>;
1177
+ };
1178
+ /** Extraction agents — list and predict best extraction agents for documents. */
1179
+ extractionAgents: {
1180
+ /**
1181
+ * Lists all available extraction agents (system agents tagged with
1182
+ * "extraction" category).
1183
+ *
1184
+ * @param options - Optional request options (abort signal, custom headers).
1185
+ * @returns An array of extraction agent objects.
1186
+ *
1187
+ * @example
1188
+ * ```typescript
1189
+ * const agents = await client.extraction.extractionAgents.list();
1190
+ * ```
1191
+ */
1192
+ list: (options?: RequestOptions) => Promise<ExtractionAgent[]>;
1193
+ /**
1194
+ * Retrieves a single extraction agent by its unique identifier.
1195
+ *
1196
+ * @param id - The UUID of the extraction agent.
1197
+ * @param options - Optional request options (abort signal, custom headers).
1198
+ * @returns The matching extraction agent object.
1199
+ *
1200
+ * @example
1201
+ * ```typescript
1202
+ * const agent = await client.extraction.extractionAgents.get('agent-uuid');
1203
+ * ```
1204
+ */
1205
+ get: (id: string, options?: RequestOptions) => Promise<ExtractionAgent>;
1206
+ /**
1207
+ * Predicts the best extraction agent for a given document based on its
1208
+ * name, description, or file content.
1209
+ *
1210
+ * @param attributes - Prediction input (name, description, file_content, document_id).
1211
+ * @param options - Optional request options (abort signal, custom headers).
1212
+ * @returns A prediction result with recommended agents.
1213
+ *
1214
+ * @example
1215
+ * ```typescript
1216
+ * const prediction = await client.extraction.extractionAgents.predict({
1217
+ * name: 'invoice.pdf',
1218
+ * file_content: 'Invoice #12345...',
1219
+ * });
1220
+ * ```
1221
+ */
1222
+ predict: (attributes: {
1223
+ name?: string;
1224
+ description?: string;
1225
+ file_content?: string;
1226
+ document_id?: string;
1227
+ [key: string]: unknown;
1228
+ }, options?: RequestOptions) => Promise<unknown>;
1229
+ };
1230
+ /** Training analytics — workspace-level extraction training metrics. */
1231
+ trainingAnalytics: {
1232
+ /**
1233
+ * Retrieves training analytics for a specific workspace, including
1234
+ * accuracy trends, correction counts, and low-confidence documents.
1235
+ *
1236
+ * @param workspaceId - The UUID of the workspace.
1237
+ * @param options - Optional request options (abort signal, custom headers).
1238
+ * @returns The training analytics object for the workspace.
1239
+ *
1240
+ * @example
1241
+ * ```typescript
1242
+ * const analytics = await client.extraction.trainingAnalytics.forWorkspace('ws-uuid');
1243
+ * console.log(analytics.avg_confidence, analytics.total_examples);
1244
+ * ```
1245
+ */
1246
+ forWorkspace: (workspaceId: string, options?: RequestOptions) => Promise<TrainingAnalytics>;
1247
+ };
1248
+ };
1249
+ //# sourceMappingURL=extraction.d.ts.map