@ptkl/sdk 1.16.0 → 1.17.1

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.
@@ -20761,17 +20761,33 @@ class Kortex extends PlatformBaseClient {
20761
20761
  async injectMessage(conversationUUID, data) {
20762
20762
  return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages/inject`, data);
20763
20763
  }
20764
+ // ── Stateless chat ──
20765
+ // Stateless completion — no conversation is created and nothing is
20766
+ // persisted. The caller owns the message list.
20767
+ //
20768
+ // Always responds with an SSE stream (message_start, thinking_delta,
20769
+ // content_delta, message_complete, error). Tool calls are surfaced in
20770
+ // message_complete for client-side execution; post the results back as
20771
+ // messages with role 'tool' and the matching tool_call_id.
20772
+ //
20773
+ // Constraints enforced server-side: agent_uuid is required, the last
20774
+ // message must have role 'user', 'context' or 'tool', and no message
20775
+ // content may exceed 32000 bytes.
20776
+ //
20777
+ // Typed as a Node stream because that is what axios `responseType:
20778
+ // 'stream'` yields under Node, which is where this binding is used.
20779
+ // Browser callers should drive the endpoint with fetch directly rather
20780
+ // than through axios.
20781
+ async chat(data) {
20782
+ return await this.client.post(`${BASE$1}/chat`, data, {
20783
+ responseType: 'stream',
20784
+ timeout: 120000,
20785
+ });
20786
+ }
20764
20787
  // ── OCR ──
20765
20788
  async ocr(data) {
20766
20789
  return await this.client.post(`${BASE$1}/ocr`, data, { timeout: 120000 });
20767
20790
  }
20768
- // ── Workflow ──
20769
- async workflowComplete(data) {
20770
- return await this.client.post(`${BASE$1}/workflow/complete`, data);
20771
- }
20772
- async workflowOcr(data) {
20773
- return await this.client.post(`${BASE$1}/workflow/ocr`, data, { timeout: 120000 });
20774
- }
20775
20791
  // ── User Access ──
20776
20792
  async createUserAccess(data) {
20777
20793
  return await this.client.post(`${BASE$1}/user-access`, data);
@@ -21138,6 +21154,70 @@ class IntegrationsBaseClient extends BaseClient {
21138
21154
  }
21139
21155
  }
21140
21156
 
21157
+ /**
21158
+ * Build an RFC 7233 Range header value from the SDK's range options.
21159
+ *
21160
+ * Validation happens here rather than at the server so a typo (a float offset, a
21161
+ * negative length) fails immediately and locally instead of arriving as an opaque
21162
+ * 400 after a round trip.
21163
+ */
21164
+ function buildRangeHeader(range) {
21165
+ const { offset, length, suffix } = range;
21166
+ if (suffix !== undefined) {
21167
+ if (offset !== undefined || length !== undefined) {
21168
+ throw new Error('readRange: `suffix` cannot be combined with `offset` or `length`');
21169
+ }
21170
+ if (!Number.isInteger(suffix) || suffix <= 0) {
21171
+ throw new Error('readRange: `suffix` must be a positive integer');
21172
+ }
21173
+ return `bytes=-${suffix}`;
21174
+ }
21175
+ const start = offset !== null && offset !== void 0 ? offset : 0;
21176
+ if (!Number.isInteger(start) || start < 0) {
21177
+ throw new Error('readRange: `offset` must be a non-negative integer');
21178
+ }
21179
+ if (length === undefined) {
21180
+ return `bytes=${start}-`;
21181
+ }
21182
+ if (!Number.isInteger(length) || length <= 0) {
21183
+ throw new Error('readRange: `length` must be a positive integer');
21184
+ }
21185
+ // Range end offsets are inclusive, so a length of N ends at start + N - 1.
21186
+ return `bytes=${start}-${start + length - 1}`;
21187
+ }
21188
+ /**
21189
+ * Turn a 206 response into a ByteRangeResult.
21190
+ *
21191
+ * The Content-Range check is the important part. Requests reach media-api through
21192
+ * two proxies, and if any hop ever dropped the Range header the response would be
21193
+ * a perfectly valid 200 carrying the *entire* file — a caller asking for 64 KiB
21194
+ * of a 2 GB object would quietly receive all 2 GB. Failing loudly here turns that
21195
+ * from a silent memory blow-up into an actionable error.
21196
+ */
21197
+ function toByteRangeResult(resp) {
21198
+ var _a, _b, _c, _d, _e, _f, _g;
21199
+ const contentRange = (_b = (_a = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _a === void 0 ? void 0 : _a['content-range']) !== null && _b !== void 0 ? _b : (_c = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _c === void 0 ? void 0 : _c['Content-Range'];
21200
+ const parsed = /^bytes\s+(\d+)-(\d+)\/(\d+)$/.exec(String(contentRange !== null && contentRange !== void 0 ? contentRange : '').trim());
21201
+ if (!parsed) {
21202
+ throw new Error('readRange: response did not include a Content-Range header, so the returned body ' +
21203
+ 'may be the entire object rather than the requested range. ' +
21204
+ 'Check that the media host supports ranged reads and that no proxy is stripping the Range header.');
21205
+ }
21206
+ const start = Number(parsed[1]);
21207
+ const end = Number(parsed[2]);
21208
+ const totalSize = Number(parsed[3]);
21209
+ const etag = (_e = (_d = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _d === void 0 ? void 0 : _d.etag) !== null && _e !== void 0 ? _e : (_f = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _f === void 0 ? void 0 : _f.ETag;
21210
+ return {
21211
+ data: resp.data,
21212
+ start,
21213
+ end,
21214
+ length: end - start + 1,
21215
+ totalSize,
21216
+ eof: end >= totalSize - 1,
21217
+ etag: typeof etag === 'string' ? etag.replace(/^"|"$/g, '') : undefined,
21218
+ contentType: (_g = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _g === void 0 ? void 0 : _g['content-type'],
21219
+ };
21220
+ }
21141
21221
  /**
21142
21222
  * Document Management System (DMS) API client
21143
21223
  *
@@ -21312,6 +21392,93 @@ class DMS extends IntegrationsBaseClient {
21312
21392
  responseType: (!encoding) ? 'blob' : null
21313
21393
  });
21314
21394
  }
21395
+ /**
21396
+ * Read a slice of a stored file without transferring the whole object.
21397
+ *
21398
+ * Uses an HTTP Range request, so only the requested bytes cross the wire.
21399
+ * Slicing is positional and format-agnostic — it works on any file.
21400
+ *
21401
+ * ```ts
21402
+ * // First 64 KiB
21403
+ * const head = await dms.readRange('reports/big.csv', { length: 65536 })
21404
+ *
21405
+ * // Continue from where that stopped
21406
+ * const next = await dms.readRange('reports/big.csv', { offset: head.end + 1, length: 65536 })
21407
+ *
21408
+ * // Final 1 KiB
21409
+ * const tail = await dms.readRange('reports/big.csv', { suffix: 1024 })
21410
+ * ```
21411
+ *
21412
+ * The server caps how much a single call may return, so `length` is an upper
21413
+ * bound rather than a guarantee: always advance using the returned `end`
21414
+ * rather than assuming the window you asked for. `eof` tells you when to stop.
21415
+ *
21416
+ * Byte ranges are not meaningful for .xlsx, .zip or .gz — their contents are
21417
+ * compressed as a unit, so no byte window corresponds to a range of rows.
21418
+ *
21419
+ * @param key Path of the file within the library
21420
+ * @param range Which bytes to read
21421
+ * @throws If the object is smaller than `offset` (nothing left to read), or if
21422
+ * the response came back without range metadata — see `readRange`'s
21423
+ * Content-Range check, which prevents silently receiving a whole file.
21424
+ */
21425
+ async readRange(key, range = {}) {
21426
+ const { responseType = 'arraybuffer' } = range;
21427
+ const resp = await this.request('GET', `media/get/${key}`, {
21428
+ headers: { Range: buildRangeHeader(range) },
21429
+ responseType,
21430
+ });
21431
+ return toByteRangeResult(resp);
21432
+ }
21433
+ /**
21434
+ * Read a file as a sequence of byte windows, newest request issued only when
21435
+ * the previous window has been consumed.
21436
+ *
21437
+ * This is the memory-bounded way to process a large file: the whole object is
21438
+ * never held at once, and a caller can stop early simply by breaking out.
21439
+ *
21440
+ * ```ts
21441
+ * for await (const chunk of dms.streamRanges('logs/huge.ndjson', { chunkSize: 1 << 20 })) {
21442
+ * process(chunk.data) // one window at a time
21443
+ * if (foundWhatIWanted) break // no further requests are made
21444
+ * }
21445
+ * ```
21446
+ *
21447
+ * Windows are contiguous and non-overlapping, so concatenating every `data`
21448
+ * reproduces the file byte for byte. A record spanning a window boundary is
21449
+ * the caller's to reassemble — this yields bytes, not records.
21450
+ *
21451
+ * An empty object yields nothing rather than throwing.
21452
+ *
21453
+ * @param key Path of the file within the library
21454
+ * @param options Where to start and how large each window should be
21455
+ */
21456
+ async *streamRanges(key, options = {}) {
21457
+ var _a, _b;
21458
+ const { chunkSize = 1024 * 1024, responseType = 'arraybuffer' } = options;
21459
+ let offset = (_a = options.offset) !== null && _a !== void 0 ? _a : 0;
21460
+ for (;;) {
21461
+ let chunk;
21462
+ try {
21463
+ chunk = await this.readRange(key, { offset, length: chunkSize, responseType });
21464
+ }
21465
+ catch (err) {
21466
+ // 416 means the offset is at or past the end. For the first request
21467
+ // that is an empty object; afterwards it is a benign race with a
21468
+ // truncating writer. Either way the stream is simply over.
21469
+ if (((_b = err === null || err === void 0 ? void 0 : err.response) === null || _b === void 0 ? void 0 : _b.status) === 416)
21470
+ return;
21471
+ throw err;
21472
+ }
21473
+ yield chunk;
21474
+ if (chunk.eof)
21475
+ return;
21476
+ // Advance from what the server actually returned, never from chunkSize:
21477
+ // the per-request cap can make a window shorter than requested, and
21478
+ // assuming otherwise would skip bytes.
21479
+ offset = chunk.end + 1;
21480
+ }
21481
+ }
21315
21482
  async download(key) {
21316
21483
  return this.request('POST', `media/download`, {
21317
21484
  data: {
@@ -1794,17 +1794,33 @@ class Kortex extends PlatformBaseClient {
1794
1794
  async injectMessage(conversationUUID, data) {
1795
1795
  return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages/inject`, data);
1796
1796
  }
1797
+ // ── Stateless chat ──
1798
+ // Stateless completion — no conversation is created and nothing is
1799
+ // persisted. The caller owns the message list.
1800
+ //
1801
+ // Always responds with an SSE stream (message_start, thinking_delta,
1802
+ // content_delta, message_complete, error). Tool calls are surfaced in
1803
+ // message_complete for client-side execution; post the results back as
1804
+ // messages with role 'tool' and the matching tool_call_id.
1805
+ //
1806
+ // Constraints enforced server-side: agent_uuid is required, the last
1807
+ // message must have role 'user', 'context' or 'tool', and no message
1808
+ // content may exceed 32000 bytes.
1809
+ //
1810
+ // Typed as a Node stream because that is what axios `responseType:
1811
+ // 'stream'` yields under Node, which is where this binding is used.
1812
+ // Browser callers should drive the endpoint with fetch directly rather
1813
+ // than through axios.
1814
+ async chat(data) {
1815
+ return await this.client.post(`${BASE$1}/chat`, data, {
1816
+ responseType: 'stream',
1817
+ timeout: 120000,
1818
+ });
1819
+ }
1797
1820
  // ── OCR ──
1798
1821
  async ocr(data) {
1799
1822
  return await this.client.post(`${BASE$1}/ocr`, data, { timeout: 120000 });
1800
1823
  }
1801
- // ── Workflow ──
1802
- async workflowComplete(data) {
1803
- return await this.client.post(`${BASE$1}/workflow/complete`, data);
1804
- }
1805
- async workflowOcr(data) {
1806
- return await this.client.post(`${BASE$1}/workflow/ocr`, data, { timeout: 120000 });
1807
- }
1808
1824
  // ── User Access ──
1809
1825
  async createUserAccess(data) {
1810
1826
  return await this.client.post(`${BASE$1}/user-access`, data);
@@ -2171,6 +2187,70 @@ class IntegrationsBaseClient extends BaseClient {
2171
2187
  }
2172
2188
  }
2173
2189
 
2190
+ /**
2191
+ * Build an RFC 7233 Range header value from the SDK's range options.
2192
+ *
2193
+ * Validation happens here rather than at the server so a typo (a float offset, a
2194
+ * negative length) fails immediately and locally instead of arriving as an opaque
2195
+ * 400 after a round trip.
2196
+ */
2197
+ function buildRangeHeader(range) {
2198
+ const { offset, length, suffix } = range;
2199
+ if (suffix !== undefined) {
2200
+ if (offset !== undefined || length !== undefined) {
2201
+ throw new Error('readRange: `suffix` cannot be combined with `offset` or `length`');
2202
+ }
2203
+ if (!Number.isInteger(suffix) || suffix <= 0) {
2204
+ throw new Error('readRange: `suffix` must be a positive integer');
2205
+ }
2206
+ return `bytes=-${suffix}`;
2207
+ }
2208
+ const start = offset !== null && offset !== void 0 ? offset : 0;
2209
+ if (!Number.isInteger(start) || start < 0) {
2210
+ throw new Error('readRange: `offset` must be a non-negative integer');
2211
+ }
2212
+ if (length === undefined) {
2213
+ return `bytes=${start}-`;
2214
+ }
2215
+ if (!Number.isInteger(length) || length <= 0) {
2216
+ throw new Error('readRange: `length` must be a positive integer');
2217
+ }
2218
+ // Range end offsets are inclusive, so a length of N ends at start + N - 1.
2219
+ return `bytes=${start}-${start + length - 1}`;
2220
+ }
2221
+ /**
2222
+ * Turn a 206 response into a ByteRangeResult.
2223
+ *
2224
+ * The Content-Range check is the important part. Requests reach media-api through
2225
+ * two proxies, and if any hop ever dropped the Range header the response would be
2226
+ * a perfectly valid 200 carrying the *entire* file — a caller asking for 64 KiB
2227
+ * of a 2 GB object would quietly receive all 2 GB. Failing loudly here turns that
2228
+ * from a silent memory blow-up into an actionable error.
2229
+ */
2230
+ function toByteRangeResult(resp) {
2231
+ var _a, _b, _c, _d, _e, _f, _g;
2232
+ const contentRange = (_b = (_a = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _a === void 0 ? void 0 : _a['content-range']) !== null && _b !== void 0 ? _b : (_c = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _c === void 0 ? void 0 : _c['Content-Range'];
2233
+ const parsed = /^bytes\s+(\d+)-(\d+)\/(\d+)$/.exec(String(contentRange !== null && contentRange !== void 0 ? contentRange : '').trim());
2234
+ if (!parsed) {
2235
+ throw new Error('readRange: response did not include a Content-Range header, so the returned body ' +
2236
+ 'may be the entire object rather than the requested range. ' +
2237
+ 'Check that the media host supports ranged reads and that no proxy is stripping the Range header.');
2238
+ }
2239
+ const start = Number(parsed[1]);
2240
+ const end = Number(parsed[2]);
2241
+ const totalSize = Number(parsed[3]);
2242
+ const etag = (_e = (_d = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _d === void 0 ? void 0 : _d.etag) !== null && _e !== void 0 ? _e : (_f = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _f === void 0 ? void 0 : _f.ETag;
2243
+ return {
2244
+ data: resp.data,
2245
+ start,
2246
+ end,
2247
+ length: end - start + 1,
2248
+ totalSize,
2249
+ eof: end >= totalSize - 1,
2250
+ etag: typeof etag === 'string' ? etag.replace(/^"|"$/g, '') : undefined,
2251
+ contentType: (_g = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _g === void 0 ? void 0 : _g['content-type'],
2252
+ };
2253
+ }
2174
2254
  /**
2175
2255
  * Document Management System (DMS) API client
2176
2256
  *
@@ -2345,6 +2425,93 @@ class DMS extends IntegrationsBaseClient {
2345
2425
  responseType: (!encoding) ? 'blob' : null
2346
2426
  });
2347
2427
  }
2428
+ /**
2429
+ * Read a slice of a stored file without transferring the whole object.
2430
+ *
2431
+ * Uses an HTTP Range request, so only the requested bytes cross the wire.
2432
+ * Slicing is positional and format-agnostic — it works on any file.
2433
+ *
2434
+ * ```ts
2435
+ * // First 64 KiB
2436
+ * const head = await dms.readRange('reports/big.csv', { length: 65536 })
2437
+ *
2438
+ * // Continue from where that stopped
2439
+ * const next = await dms.readRange('reports/big.csv', { offset: head.end + 1, length: 65536 })
2440
+ *
2441
+ * // Final 1 KiB
2442
+ * const tail = await dms.readRange('reports/big.csv', { suffix: 1024 })
2443
+ * ```
2444
+ *
2445
+ * The server caps how much a single call may return, so `length` is an upper
2446
+ * bound rather than a guarantee: always advance using the returned `end`
2447
+ * rather than assuming the window you asked for. `eof` tells you when to stop.
2448
+ *
2449
+ * Byte ranges are not meaningful for .xlsx, .zip or .gz — their contents are
2450
+ * compressed as a unit, so no byte window corresponds to a range of rows.
2451
+ *
2452
+ * @param key Path of the file within the library
2453
+ * @param range Which bytes to read
2454
+ * @throws If the object is smaller than `offset` (nothing left to read), or if
2455
+ * the response came back without range metadata — see `readRange`'s
2456
+ * Content-Range check, which prevents silently receiving a whole file.
2457
+ */
2458
+ async readRange(key, range = {}) {
2459
+ const { responseType = 'arraybuffer' } = range;
2460
+ const resp = await this.request('GET', `media/get/${key}`, {
2461
+ headers: { Range: buildRangeHeader(range) },
2462
+ responseType,
2463
+ });
2464
+ return toByteRangeResult(resp);
2465
+ }
2466
+ /**
2467
+ * Read a file as a sequence of byte windows, newest request issued only when
2468
+ * the previous window has been consumed.
2469
+ *
2470
+ * This is the memory-bounded way to process a large file: the whole object is
2471
+ * never held at once, and a caller can stop early simply by breaking out.
2472
+ *
2473
+ * ```ts
2474
+ * for await (const chunk of dms.streamRanges('logs/huge.ndjson', { chunkSize: 1 << 20 })) {
2475
+ * process(chunk.data) // one window at a time
2476
+ * if (foundWhatIWanted) break // no further requests are made
2477
+ * }
2478
+ * ```
2479
+ *
2480
+ * Windows are contiguous and non-overlapping, so concatenating every `data`
2481
+ * reproduces the file byte for byte. A record spanning a window boundary is
2482
+ * the caller's to reassemble — this yields bytes, not records.
2483
+ *
2484
+ * An empty object yields nothing rather than throwing.
2485
+ *
2486
+ * @param key Path of the file within the library
2487
+ * @param options Where to start and how large each window should be
2488
+ */
2489
+ async *streamRanges(key, options = {}) {
2490
+ var _a, _b;
2491
+ const { chunkSize = 1024 * 1024, responseType = 'arraybuffer' } = options;
2492
+ let offset = (_a = options.offset) !== null && _a !== void 0 ? _a : 0;
2493
+ for (;;) {
2494
+ let chunk;
2495
+ try {
2496
+ chunk = await this.readRange(key, { offset, length: chunkSize, responseType });
2497
+ }
2498
+ catch (err) {
2499
+ // 416 means the offset is at or past the end. For the first request
2500
+ // that is an empty object; afterwards it is a benign race with a
2501
+ // truncating writer. Either way the stream is simply over.
2502
+ if (((_b = err === null || err === void 0 ? void 0 : err.response) === null || _b === void 0 ? void 0 : _b.status) === 416)
2503
+ return;
2504
+ throw err;
2505
+ }
2506
+ yield chunk;
2507
+ if (chunk.eof)
2508
+ return;
2509
+ // Advance from what the server actually returned, never from chunkSize:
2510
+ // the per-request cap can make a window shorter than requested, and
2511
+ // assuming otherwise would skip bytes.
2512
+ offset = chunk.end + 1;
2513
+ }
2514
+ }
2348
2515
  async download(key) {
2349
2516
  return this.request('POST', `media/download`, {
2350
2517
  data: {
@@ -584,3 +584,47 @@ export type FileNotification = {
584
584
  recipient_email?: string;
585
585
  };
586
586
  export type FileNotificationListResponse = FileNotification[];
587
+ /**
588
+ * Which bytes to read. Supply either `offset`/`length` or `suffix`, not both.
589
+ */
590
+ export type ByteRangeRequest = {
591
+ /** First byte to read, 0-based. Defaults to 0. */
592
+ offset?: number;
593
+ /** How many bytes to read. Omit to read to the end of the object, subject to the server's per-request cap. */
594
+ length?: number;
595
+ /** Read the final N bytes instead. Mutually exclusive with `offset`/`length`. */
596
+ suffix?: number;
597
+ /** Axios response type for the body. Defaults to `arraybuffer`. */
598
+ responseType?: 'arraybuffer' | 'blob' | 'text';
599
+ };
600
+ /**
601
+ * A single window of bytes plus the position metadata needed to request the next one.
602
+ */
603
+ export type ByteRangeResult<T = any> = {
604
+ /** The bytes, in the shape requested via `responseType`. */
605
+ data: T;
606
+ /** Offset of the first byte returned. */
607
+ start: number;
608
+ /** Offset of the last byte returned, inclusive. */
609
+ end: number;
610
+ /** Number of bytes returned. May be less than requested — see `ByteRangeRequest.length`. */
611
+ length: number;
612
+ /** Total size of the whole object. */
613
+ totalSize: number;
614
+ /** True when this window ends at the last byte of the object. */
615
+ eof: boolean;
616
+ /** Object validator. Changes if the object is replaced, so a multi-window scan can detect it. */
617
+ etag?: string;
618
+ contentType?: string;
619
+ };
620
+ /**
621
+ * Options for walking an object window by window.
622
+ */
623
+ export type ByteStreamOptions = {
624
+ /** Byte offset to start from. Defaults to 0. */
625
+ offset?: number;
626
+ /** Bytes per window. Defaults to 1 MiB. The server may return less. */
627
+ chunkSize?: number;
628
+ /** Axios response type for each window. Defaults to `arraybuffer`. */
629
+ responseType?: 'arraybuffer' | 'blob' | 'text';
630
+ };
@@ -288,22 +288,16 @@ type KnowledgeBaseSearchChunk = {
288
288
  type KnowledgeBaseSearchResult = {
289
289
  chunks: KnowledgeBaseSearchChunk[];
290
290
  };
291
- type KortexWorkflowMessage = {
292
- role: string;
291
+ type KortexChatRole = 'user' | 'assistant' | 'context' | 'tool';
292
+ type KortexChatMessage = {
293
+ role: KortexChatRole;
293
294
  content: string;
295
+ tool_calls?: ToolCall[];
296
+ tool_call_id?: string;
294
297
  };
295
- type KortexWorkflowPayload = {
296
- agent_uuid?: string;
297
- system_prompt?: string;
298
- response_format?: string;
299
- messages: KortexWorkflowMessage[];
300
- stream?: boolean;
301
- temperature?: number;
302
- max_tokens?: number;
298
+ type KortexChatPayload = {
299
+ agent_uuid: string;
300
+ messages: KortexChatMessage[];
303
301
  tools?: Record<string, any>[];
304
302
  };
305
- type KortexWorkflowResult = {
306
- content: string;
307
- usage: TokenUsage;
308
- };
309
- export { PagedResponse, PaginationParams, RAGConfig, LLMSettings, Agent, AgentCreatePayload, AgentUpdatePayload, ChunkingStrategy, KnowledgeBase, KnowledgeBaseCreatePayload, KnowledgeBaseUpdatePayload, Document, Participant, TokenUsage, ToolCall, RAGSource, Message, Conversation, ConversationCreatePayload, ConversationUpdatePayload, ParticipantAddPayload, ToolResultApproval, ToolResultPayload, PageContext, SendMessagePayload, InjectMessagePayload, OCRPayload, OCRResult, UserAccess, UserAccessCreatePayload, UserAccessUpdatePayload, TopUpPayload, UserMonthlyUsage, UserUsageBreakdown, MyAccess, AggregatedUsage, Tier, KnowledgeBaseSearchPayload, KnowledgeBaseSearchChunk, KnowledgeBaseSearchResult, KortexWorkflowMessage, KortexWorkflowPayload, KortexWorkflowResult, };
303
+ export { PagedResponse, PaginationParams, RAGConfig, LLMSettings, Agent, AgentCreatePayload, AgentUpdatePayload, ChunkingStrategy, KnowledgeBase, KnowledgeBaseCreatePayload, KnowledgeBaseUpdatePayload, Document, Participant, TokenUsage, ToolCall, RAGSource, Message, Conversation, ConversationCreatePayload, ConversationUpdatePayload, ParticipantAddPayload, ToolResultApproval, ToolResultPayload, PageContext, SendMessagePayload, InjectMessagePayload, OCRPayload, OCRResult, UserAccess, UserAccessCreatePayload, UserAccessUpdatePayload, TopUpPayload, UserMonthlyUsage, UserUsageBreakdown, MyAccess, AggregatedUsage, Tier, KnowledgeBaseSearchPayload, KnowledgeBaseSearchChunk, KnowledgeBaseSearchResult, KortexChatRole, KortexChatMessage, KortexChatPayload, };
@@ -1,6 +1,6 @@
1
1
  import IntegrationsBaseClient from "../integrationsBaseClient";
2
2
  import { AxiosResponse } from "axios";
3
- import { PDFFillOptions, DataConversionParams, DataValidationParams, DataInfoParams, DataInfo, DataValidationResult, ConversionOptions, HTML2PDFOptions } from "../../types/integrations";
3
+ import { PDFFillOptions, DataConversionParams, DataValidationParams, DataInfoParams, DataInfo, DataValidationResult, ConversionOptions, HTML2PDFOptions, ByteRangeRequest, ByteRangeResult, ByteStreamOptions } from "../../types/integrations";
4
4
  /**
5
5
  * Document Management System (DMS) API client
6
6
  *
@@ -87,6 +87,63 @@ export default class DMS extends IntegrationsBaseClient {
87
87
  delete(data: any): Promise<AxiosResponse<any, any>>;
88
88
  uploadBase64(data: any): Promise<AxiosResponse<any, any>>;
89
89
  getMedia(lib: string, key: string, encoding: string): Promise<AxiosResponse<any, any>>;
90
+ /**
91
+ * Read a slice of a stored file without transferring the whole object.
92
+ *
93
+ * Uses an HTTP Range request, so only the requested bytes cross the wire.
94
+ * Slicing is positional and format-agnostic — it works on any file.
95
+ *
96
+ * ```ts
97
+ * // First 64 KiB
98
+ * const head = await dms.readRange(libraryUuid, 'reports/big.csv', { length: 65536 })
99
+ *
100
+ * // Continue from where that stopped
101
+ * const next = await dms.readRange(libraryUuid, 'reports/big.csv', { offset: head.end + 1, length: 65536 })
102
+ *
103
+ * // Final 1 KiB
104
+ * const tail = await dms.readRange(libraryUuid, 'reports/big.csv', { suffix: 1024 })
105
+ * ```
106
+ *
107
+ * The server caps how much a single call may return, so `length` is an upper
108
+ * bound rather than a guarantee: always advance using the returned `end`
109
+ * rather than assuming the window you asked for. `eof` tells you when to stop.
110
+ *
111
+ * Byte ranges are not meaningful for .xlsx, .zip or .gz — their contents are
112
+ * compressed as a unit, so no byte window corresponds to a range of rows.
113
+ *
114
+ * @param lib Library UUID
115
+ * @param key Path of the file within the library
116
+ * @param range Which bytes to read
117
+ * @throws If the object is smaller than `offset` (nothing left to read), or if
118
+ * the response came back without range metadata — see `readRange`'s
119
+ * Content-Range check, which prevents silently receiving a whole file.
120
+ */
121
+ readRange(lib: string, key: string, range?: ByteRangeRequest): Promise<ByteRangeResult>;
122
+ /**
123
+ * Read a file as a sequence of byte windows, newest request issued only when
124
+ * the previous window has been consumed.
125
+ *
126
+ * This is the memory-bounded way to process a large file: the whole object is
127
+ * never held at once, and a caller can stop early simply by breaking out.
128
+ *
129
+ * ```ts
130
+ * for await (const chunk of dms.streamRanges(libraryUuid, 'logs/huge.ndjson', { chunkSize: 1 << 20 })) {
131
+ * process(chunk.data) // one window at a time
132
+ * if (foundWhatIWanted) break // no further requests are made
133
+ * }
134
+ * ```
135
+ *
136
+ * Windows are contiguous and non-overlapping, so concatenating every `data`
137
+ * reproduces the file byte for byte. A record spanning a window boundary is
138
+ * the caller's to reassemble — this yields bytes, not records.
139
+ *
140
+ * An empty object yields nothing rather than throwing.
141
+ *
142
+ * @param lib Library UUID
143
+ * @param key Path of the file within the library
144
+ * @param options Where to start and how large each window should be
145
+ */
146
+ streamRanges(lib: string, key: string, options?: ByteStreamOptions): AsyncGenerator<ByteRangeResult>;
90
147
  download(lib: string, key: string): Promise<AxiosResponse<any, any>>;
91
148
  getExifData(lib: string, key: string): Promise<AxiosResponse<any, any>>;
92
149
  html2pdf(lib: string, data: HTML2PDFOptions): Promise<AxiosResponse<any, any>>;