graphor 0.17.0 → 0.19.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.
- package/CHANGELOG.md +55 -0
- package/README.md +113 -354
- package/client.d.mts +2 -2
- package/client.d.mts.map +1 -1
- package/client.d.ts +2 -2
- package/client.d.ts.map +1 -1
- package/client.js +11 -0
- package/client.js.map +1 -1
- package/client.mjs +11 -0
- package/client.mjs.map +1 -1
- package/internal/types.d.mts +6 -6
- package/internal/types.d.mts.map +1 -1
- package/internal/types.d.ts +6 -6
- package/internal/types.d.ts.map +1 -1
- package/internal/utils/env.js +2 -2
- package/internal/utils/env.js.map +1 -1
- package/internal/utils/env.mjs +2 -2
- package/internal/utils/env.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/sources.d.mts +189 -23
- package/resources/sources.d.mts.map +1 -1
- package/resources/sources.d.ts +189 -23
- package/resources/sources.d.ts.map +1 -1
- package/resources/sources.js +50 -8
- package/resources/sources.js.map +1 -1
- package/resources/sources.mjs +50 -8
- package/resources/sources.mjs.map +1 -1
- package/src/client.ts +16 -0
- package/src/internal/types.ts +6 -8
- package/src/internal/utils/env.ts +2 -2
- package/src/resources/index.ts +2 -0
- package/src/resources/sources.ts +226 -22
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sources.mjs","sourceRoot":"","sources":["../src/resources/sources.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAIf,EAAE,2BAA2B,EAAE;OAC/B,EAAE,IAAI,EAAE;AAEf,MAAM,OAAO,OAAQ,SAAQ,WAAW;IACtC;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B;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF"}
|
package/src/client.ts
CHANGED
|
@@ -31,6 +31,8 @@ import {
|
|
|
31
31
|
SourceGetBuildStatusResponse,
|
|
32
32
|
SourceGetElementsParams,
|
|
33
33
|
SourceGetElementsResponse,
|
|
34
|
+
SourceGetPageScreenshotParams,
|
|
35
|
+
SourceGetPageScreenshotResponse,
|
|
34
36
|
SourceIngestFileParams,
|
|
35
37
|
SourceIngestFileResponse,
|
|
36
38
|
SourceIngestGitHubParams,
|
|
@@ -199,6 +201,18 @@ export class Graphor {
|
|
|
199
201
|
this.#undiciDispatcher = null;
|
|
200
202
|
this.#encoder = Opts.FallbackEncoder;
|
|
201
203
|
|
|
204
|
+
const customHeadersEnv = readEnv('GRAPHOR_CUSTOM_HEADERS');
|
|
205
|
+
if (customHeadersEnv) {
|
|
206
|
+
const parsed: Record<string, string> = {};
|
|
207
|
+
for (const line of customHeadersEnv.split('\n')) {
|
|
208
|
+
const colon = line.indexOf(':');
|
|
209
|
+
if (colon >= 0) {
|
|
210
|
+
parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
options.defaultHeaders = { ...parsed, ...options.defaultHeaders };
|
|
214
|
+
}
|
|
215
|
+
|
|
202
216
|
this._options = options;
|
|
203
217
|
|
|
204
218
|
this.apiKey = apiKey;
|
|
@@ -786,6 +800,7 @@ export declare namespace Graphor {
|
|
|
786
800
|
type SourceExtractResponse as SourceExtractResponse,
|
|
787
801
|
type SourceGetBuildStatusResponse as SourceGetBuildStatusResponse,
|
|
788
802
|
type SourceGetElementsResponse as SourceGetElementsResponse,
|
|
803
|
+
type SourceGetPageScreenshotResponse as SourceGetPageScreenshotResponse,
|
|
789
804
|
type SourceIngestFileResponse as SourceIngestFileResponse,
|
|
790
805
|
type SourceIngestGitHubResponse as SourceIngestGitHubResponse,
|
|
791
806
|
type SourceIngestURLResponse as SourceIngestURLResponse,
|
|
@@ -798,6 +813,7 @@ export declare namespace Graphor {
|
|
|
798
813
|
type SourceExtractParams as SourceExtractParams,
|
|
799
814
|
type SourceGetBuildStatusParams as SourceGetBuildStatusParams,
|
|
800
815
|
type SourceGetElementsParams as SourceGetElementsParams,
|
|
816
|
+
type SourceGetPageScreenshotParams as SourceGetPageScreenshotParams,
|
|
801
817
|
type SourceIngestFileParams as SourceIngestFileParams,
|
|
802
818
|
type SourceIngestGitHubParams as SourceIngestGitHubParams,
|
|
803
819
|
type SourceIngestURLParams as SourceIngestURLParams,
|
package/src/internal/types.ts
CHANGED
|
@@ -40,7 +40,6 @@ type OverloadedParameters<T> =
|
|
|
40
40
|
: T extends (...args: infer A) => unknown ? A
|
|
41
41
|
: never;
|
|
42
42
|
|
|
43
|
-
/* eslint-disable */
|
|
44
43
|
/**
|
|
45
44
|
* These imports attempt to get types from a parent package's dependencies.
|
|
46
45
|
* Unresolved bare specifiers can trigger [automatic type acquisition][1] in some projects, which
|
|
@@ -63,19 +62,18 @@ type OverloadedParameters<T> =
|
|
|
63
62
|
*
|
|
64
63
|
* [1]: https://www.typescriptlang.org/tsconfig/#typeAcquisition
|
|
65
64
|
*/
|
|
66
|
-
/** @ts-ignore For users with \@types/node */
|
|
65
|
+
/** @ts-ignore For users with \@types/node */ /* prettier-ignore */
|
|
67
66
|
type UndiciTypesRequestInit = NotAny<import('../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/undici-types/index.d.ts').RequestInit>;
|
|
68
|
-
/** @ts-ignore For users with undici */
|
|
67
|
+
/** @ts-ignore For users with undici */ /* prettier-ignore */
|
|
69
68
|
type UndiciRequestInit = NotAny<import('../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/undici/index.d.ts').RequestInit>;
|
|
70
|
-
/** @ts-ignore For users with \@types/bun */
|
|
69
|
+
/** @ts-ignore For users with \@types/bun */ /* prettier-ignore */
|
|
71
70
|
type BunRequestInit = globalThis.FetchRequestInit;
|
|
72
|
-
/** @ts-ignore For users with node-fetch@2 */
|
|
71
|
+
/** @ts-ignore For users with node-fetch@2 */ /* prettier-ignore */
|
|
73
72
|
type NodeFetch2RequestInit = NotAny<import('../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit>;
|
|
74
|
-
/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */
|
|
73
|
+
/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */ /* prettier-ignore */
|
|
75
74
|
type NodeFetch3RequestInit = NotAny<import('../node_modules/node-fetch').RequestInit> | NotAny<import('../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/node-fetch').RequestInit>;
|
|
76
|
-
/** @ts-ignore For users who use Deno */
|
|
75
|
+
/** @ts-ignore For users who use Deno */ /* prettier-ignore */
|
|
77
76
|
type FetchRequestInit = NonNullable<OverloadedParameters<typeof fetch>[1]>;
|
|
78
|
-
/* eslint-enable */
|
|
79
77
|
|
|
80
78
|
type RequestInits =
|
|
81
79
|
| NotAny<UndiciTypesRequestInit>
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export const readEnv = (env: string): string | undefined => {
|
|
11
11
|
if (typeof (globalThis as any).process !== 'undefined') {
|
|
12
|
-
return (globalThis as any).process.env?.[env]?.trim()
|
|
12
|
+
return (globalThis as any).process.env?.[env]?.trim() || undefined;
|
|
13
13
|
}
|
|
14
14
|
if (typeof (globalThis as any).Deno !== 'undefined') {
|
|
15
|
-
return (globalThis as any).Deno.env?.get?.(env)?.trim();
|
|
15
|
+
return (globalThis as any).Deno.env?.get?.(env)?.trim() || undefined;
|
|
16
16
|
}
|
|
17
17
|
return undefined;
|
|
18
18
|
};
|
package/src/resources/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export {
|
|
|
11
11
|
type SourceExtractResponse,
|
|
12
12
|
type SourceGetBuildStatusResponse,
|
|
13
13
|
type SourceGetElementsResponse,
|
|
14
|
+
type SourceGetPageScreenshotResponse,
|
|
14
15
|
type SourceIngestFileResponse,
|
|
15
16
|
type SourceIngestGitHubResponse,
|
|
16
17
|
type SourceIngestURLResponse,
|
|
@@ -23,6 +24,7 @@ export {
|
|
|
23
24
|
type SourceExtractParams,
|
|
24
25
|
type SourceGetBuildStatusParams,
|
|
25
26
|
type SourceGetElementsParams,
|
|
27
|
+
type SourceGetPageScreenshotParams,
|
|
26
28
|
type SourceIngestFileParams,
|
|
27
29
|
type SourceIngestGitHubParams,
|
|
28
30
|
type SourceIngestURLParams,
|
package/src/resources/sources.ts
CHANGED
|
@@ -125,7 +125,7 @@ export class Sources extends APIResource {
|
|
|
125
125
|
* @example
|
|
126
126
|
* ```ts
|
|
127
127
|
* const response = await client.sources.ask({
|
|
128
|
-
* question: '
|
|
128
|
+
* question: "What was the company's revenue in 2025?",
|
|
129
129
|
* });
|
|
130
130
|
* ```
|
|
131
131
|
*/
|
|
@@ -169,8 +169,9 @@ export class Sources extends APIResource {
|
|
|
169
169
|
* @example
|
|
170
170
|
* ```ts
|
|
171
171
|
* const response = await client.sources.extract({
|
|
172
|
-
* output_schema: {
|
|
173
|
-
* user_instruction:
|
|
172
|
+
* output_schema: { properties: 'bar', type: 'bar' },
|
|
173
|
+
* user_instruction:
|
|
174
|
+
* 'Extract all invoice line items including product name, quantity, unit price, and total.',
|
|
174
175
|
* });
|
|
175
176
|
* ```
|
|
176
177
|
*/
|
|
@@ -296,6 +297,52 @@ export class Sources extends APIResource {
|
|
|
296
297
|
return this._client.get('/sources/get-elements', { query, ...options });
|
|
297
298
|
}
|
|
298
299
|
|
|
300
|
+
/**
|
|
301
|
+
* Render a single page of a source file as a base64-encoded PNG screenshot.
|
|
302
|
+
*
|
|
303
|
+
* Use this endpoint to lazily fetch the visual preview of a citation returned by
|
|
304
|
+
* `/ask-sources` without paying the payload cost of inlining base64 in the answer.
|
|
305
|
+
* Supports PDFs, image files (`page_number` must be 1), and Office documents
|
|
306
|
+
* (doc/docx/ppt/pptx/odt — rendered from the converted PDF).
|
|
307
|
+
*
|
|
308
|
+
* **Path parameters:**
|
|
309
|
+
*
|
|
310
|
+
* - **file_id** (str): UUID of the source file.
|
|
311
|
+
* - **page_number** (int): 1-based page number.
|
|
312
|
+
*
|
|
313
|
+
* **Query parameters:**
|
|
314
|
+
*
|
|
315
|
+
* - **max_width** (int, optional, default `900`): Pixel width cap. Clamped to the
|
|
316
|
+
* 300-1600 range.
|
|
317
|
+
*
|
|
318
|
+
* **Returns** a `PublicPageScreenshotResponse` containing:
|
|
319
|
+
*
|
|
320
|
+
* - `file_id`, `file_name`, `page_number` — identifying metadata.
|
|
321
|
+
* - `mime_type` — always `"image/png"`.
|
|
322
|
+
* - `width`, `height` — rendered image dimensions in pixels.
|
|
323
|
+
* - `image_base64` — the base64-encoded PNG bytes.
|
|
324
|
+
*
|
|
325
|
+
* **Error responses:**
|
|
326
|
+
*
|
|
327
|
+
* - `404` — File not found, unsupported file type, or invalid page number.
|
|
328
|
+
* - `500` — Unexpected internal error while rendering.
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```ts
|
|
332
|
+
* const response = await client.sources.getPageScreenshot(0, {
|
|
333
|
+
* file_id: 'file_id',
|
|
334
|
+
* });
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
getPageScreenshot(
|
|
338
|
+
pageNumber: number,
|
|
339
|
+
params: SourceGetPageScreenshotParams,
|
|
340
|
+
options?: RequestOptions,
|
|
341
|
+
): APIPromise<SourceGetPageScreenshotResponse> {
|
|
342
|
+
const { file_id, ...query } = params;
|
|
343
|
+
return this._client.get(path`/sources/${file_id}/pages/${pageNumber}/screenshot`, { query, ...options });
|
|
344
|
+
}
|
|
345
|
+
|
|
299
346
|
/**
|
|
300
347
|
* Upload a local file and schedule ingestion in the background.
|
|
301
348
|
*
|
|
@@ -344,7 +391,7 @@ export class Sources extends APIResource {
|
|
|
344
391
|
* @example
|
|
345
392
|
* ```ts
|
|
346
393
|
* const response = await client.sources.ingestGitHub({
|
|
347
|
-
* url: '
|
|
394
|
+
* url: 'https://github.com/langchain-ai/langchain',
|
|
348
395
|
* });
|
|
349
396
|
* ```
|
|
350
397
|
*/
|
|
@@ -390,7 +437,7 @@ export class Sources extends APIResource {
|
|
|
390
437
|
* @example
|
|
391
438
|
* ```ts
|
|
392
439
|
* const response = await client.sources.ingestURL({
|
|
393
|
-
* url: '
|
|
440
|
+
* url: 'https://example.com/blog/ai-trends-2025',
|
|
394
441
|
* });
|
|
395
442
|
* ```
|
|
396
443
|
*/
|
|
@@ -415,7 +462,7 @@ export class Sources extends APIResource {
|
|
|
415
462
|
* @example
|
|
416
463
|
* ```ts
|
|
417
464
|
* const response = await client.sources.ingestYoutube({
|
|
418
|
-
* url: '
|
|
465
|
+
* url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
|
|
419
466
|
* });
|
|
420
467
|
* ```
|
|
421
468
|
*/
|
|
@@ -444,7 +491,7 @@ export class Sources extends APIResource {
|
|
|
444
491
|
* @example
|
|
445
492
|
* ```ts
|
|
446
493
|
* const response = await client.sources.reprocess({
|
|
447
|
-
* file_id: '
|
|
494
|
+
* file_id: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
|
|
448
495
|
* });
|
|
449
496
|
* ```
|
|
450
497
|
*/
|
|
@@ -484,7 +531,7 @@ export class Sources extends APIResource {
|
|
|
484
531
|
* @example
|
|
485
532
|
* ```ts
|
|
486
533
|
* const response = await client.sources.retrieveChunks({
|
|
487
|
-
* query: '
|
|
534
|
+
* query: "What was the company's net income in 2025?",
|
|
488
535
|
* });
|
|
489
536
|
* ```
|
|
490
537
|
*/
|
|
@@ -607,10 +654,9 @@ export interface Element {
|
|
|
607
654
|
* - fast → basic
|
|
608
655
|
* - balanced → hi_res
|
|
609
656
|
* - accurate → hi_res_ft
|
|
610
|
-
* - vlm → mai
|
|
611
657
|
* - agentic → graphorlm
|
|
612
658
|
*/
|
|
613
|
-
export type Method = 'fast' | 'balanced' | 'accurate' | '
|
|
659
|
+
export type Method = 'fast' | 'balanced' | 'accurate' | 'agentic';
|
|
614
660
|
|
|
615
661
|
export interface PublicSource {
|
|
616
662
|
/**
|
|
@@ -661,7 +707,7 @@ export interface PublicSource {
|
|
|
661
707
|
|
|
662
708
|
/**
|
|
663
709
|
* Partitioning strategy used during ingestion. V1 API: basic, hi_res, hi_res_ft,
|
|
664
|
-
* mai, graphorlm. V2 API: fast, balanced, accurate,
|
|
710
|
+
* mai, graphorlm. V2 API: fast, balanced, accurate, agentic.
|
|
665
711
|
*/
|
|
666
712
|
method?: string | null;
|
|
667
713
|
}
|
|
@@ -704,15 +750,28 @@ export interface SourceAskResponse {
|
|
|
704
750
|
/**
|
|
705
751
|
* The answer to the question. When output_schema is provided, this will be a short
|
|
706
752
|
* status message and the structured data will be in structured_output (and the raw
|
|
707
|
-
* JSON-text in raw_json).
|
|
753
|
+
* JSON-text in raw_json). Inline citations appear as `[N]` markers; use the
|
|
754
|
+
* `citations` field to resolve each marker to its source.
|
|
708
755
|
*/
|
|
709
756
|
answer: string;
|
|
710
757
|
|
|
758
|
+
/**
|
|
759
|
+
* Structured citations extracted from the `[N]` markers in `answer`. When the
|
|
760
|
+
* request includes `include_citation_images=true`, each entry carries a
|
|
761
|
+
* base64-encoded PNG screenshot of the cited page in `image_base64`.
|
|
762
|
+
*/
|
|
763
|
+
citations?: Array<SourceAskResponse.Citation> | null;
|
|
764
|
+
|
|
711
765
|
/**
|
|
712
766
|
* Conversation identifier used to maintain memory context
|
|
713
767
|
*/
|
|
714
768
|
conversation_id?: string | null;
|
|
715
769
|
|
|
770
|
+
/**
|
|
771
|
+
* Wall-clock time in seconds for the request.
|
|
772
|
+
*/
|
|
773
|
+
elapsed_s?: number | null;
|
|
774
|
+
|
|
716
775
|
/**
|
|
717
776
|
* Optional raw JSON-text produced by the sources model before
|
|
718
777
|
* validation/correction.
|
|
@@ -724,6 +783,81 @@ export interface SourceAskResponse {
|
|
|
724
783
|
* output_schema.
|
|
725
784
|
*/
|
|
726
785
|
structured_output?: { [key: string]: unknown } | null;
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* Token usage breakdown for this request.
|
|
789
|
+
*/
|
|
790
|
+
usage?: SourceAskResponse.Usage | null;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
export namespace SourceAskResponse {
|
|
794
|
+
/**
|
|
795
|
+
* A structured citation extracted from the inline `[N]` markers in the answer.
|
|
796
|
+
*
|
|
797
|
+
* Each citation corresponds to one `[N]` marker in the `answer` text. Use the
|
|
798
|
+
* `index` field to map between the marker and the citation entry.
|
|
799
|
+
*/
|
|
800
|
+
export interface Citation {
|
|
801
|
+
/**
|
|
802
|
+
* Optional element identifier within the page/section (e.g. a specific paragraph
|
|
803
|
+
* or table).
|
|
804
|
+
*/
|
|
805
|
+
element_id?: string | null;
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* The unique identifier of the source file the citation refers to.
|
|
809
|
+
*/
|
|
810
|
+
file_id?: string | null;
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* Display name of the source file.
|
|
814
|
+
*/
|
|
815
|
+
file_name?: string | null;
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Base64-encoded PNG screenshot of the cited page. Only populated when the request
|
|
819
|
+
* was made with `include_citation_images=true`. May be null if the underlying
|
|
820
|
+
* source is not visualizable (e.g. plain text).
|
|
821
|
+
*/
|
|
822
|
+
image_base64?: string | null;
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* The 1-based citation number that appears as `[N]` in the answer text.
|
|
826
|
+
*/
|
|
827
|
+
index?: number | null;
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* 1-based page number where the cited content appears.
|
|
831
|
+
*/
|
|
832
|
+
page_number?: number | null;
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Optional section number within the page.
|
|
836
|
+
*/
|
|
837
|
+
section_number?: number | null;
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Short text excerpt around the cited content, useful for quick context.
|
|
841
|
+
*/
|
|
842
|
+
text_preview?: string | null;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* Token usage breakdown for this request.
|
|
847
|
+
*/
|
|
848
|
+
export interface Usage {
|
|
849
|
+
cache_read_tokens?: number;
|
|
850
|
+
|
|
851
|
+
cache_write_tokens?: number;
|
|
852
|
+
|
|
853
|
+
om_tokens_in?: number;
|
|
854
|
+
|
|
855
|
+
om_tokens_out?: number;
|
|
856
|
+
|
|
857
|
+
tokens_in?: number;
|
|
858
|
+
|
|
859
|
+
tokens_out?: number;
|
|
860
|
+
}
|
|
727
861
|
}
|
|
728
862
|
|
|
729
863
|
export interface SourceExtractResponse {
|
|
@@ -832,7 +966,6 @@ export interface SourceGetBuildStatusResponse {
|
|
|
832
966
|
* - fast → basic
|
|
833
967
|
* - balanced → hi_res
|
|
834
968
|
* - accurate → hi_res_ft
|
|
835
|
-
* - vlm → mai
|
|
836
969
|
* - agentic → graphorlm
|
|
837
970
|
*/
|
|
838
971
|
method?: Method | null;
|
|
@@ -902,6 +1035,46 @@ export interface SourceGetElementsResponse {
|
|
|
902
1035
|
total_pages?: number | null;
|
|
903
1036
|
}
|
|
904
1037
|
|
|
1038
|
+
/**
|
|
1039
|
+
* Base64-encoded PNG screenshot of a page from a source file.
|
|
1040
|
+
*/
|
|
1041
|
+
export interface SourceGetPageScreenshotResponse {
|
|
1042
|
+
/**
|
|
1043
|
+
* The unique identifier of the source file.
|
|
1044
|
+
*/
|
|
1045
|
+
file_id: string;
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* Base64-encoded PNG image bytes.
|
|
1049
|
+
*/
|
|
1050
|
+
image_base64: string;
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* 1-based page number that was rendered.
|
|
1054
|
+
*/
|
|
1055
|
+
page_number: number;
|
|
1056
|
+
|
|
1057
|
+
/**
|
|
1058
|
+
* Display name of the source file.
|
|
1059
|
+
*/
|
|
1060
|
+
file_name?: string | null;
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* Pixel height of the rendered image.
|
|
1064
|
+
*/
|
|
1065
|
+
height?: number | null;
|
|
1066
|
+
|
|
1067
|
+
/**
|
|
1068
|
+
* MIME type of the encoded image (always image/png).
|
|
1069
|
+
*/
|
|
1070
|
+
mime_type?: string;
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* Pixel width of the rendered image.
|
|
1074
|
+
*/
|
|
1075
|
+
width?: number | null;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
905
1078
|
export interface SourceIngestFileResponse {
|
|
906
1079
|
/**
|
|
907
1080
|
* The ID of the build. This ID can be used to check the status of the request.
|
|
@@ -1080,6 +1253,25 @@ export interface SourceAskParams {
|
|
|
1080
1253
|
*/
|
|
1081
1254
|
file_names?: Array<string> | null;
|
|
1082
1255
|
|
|
1256
|
+
/**
|
|
1257
|
+
* When true, the response's `citations` entries are populated with a
|
|
1258
|
+
* base64-encoded PNG screenshot of each cited page in `image_base64`. Increases
|
|
1259
|
+
* payload size and latency — leave false (the default) when not needed and fetch
|
|
1260
|
+
* screenshots on demand via
|
|
1261
|
+
* `GET /sources/{file_id}/pages/{page_number}/screenshot`.
|
|
1262
|
+
*/
|
|
1263
|
+
include_citation_images?: boolean | null;
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* When true, the `answer` field keeps the structured citation markup
|
|
1267
|
+
* `[N](file_id|pX|sY|eZ|fNAME)` emitted by the agent. When false (default), the
|
|
1268
|
+
* markup is stripped to plain `[N]` markers and the structured data is exposed via
|
|
1269
|
+
* `citations` instead. Note: the markup format is an implementation detail and may
|
|
1270
|
+
* change in future versions — prefer the `citations` field for stable parsing. Has
|
|
1271
|
+
* no effect when `output_schema` is set.
|
|
1272
|
+
*/
|
|
1273
|
+
include_citation_markup?: boolean | null;
|
|
1274
|
+
|
|
1083
1275
|
/**
|
|
1084
1276
|
* Optional JSON Schema for requesting structured output. When provided, the answer
|
|
1085
1277
|
* field will contain a short status message and the structured data will be in
|
|
@@ -1093,10 +1285,10 @@ export interface SourceAskParams {
|
|
|
1093
1285
|
reset?: boolean | null;
|
|
1094
1286
|
|
|
1095
1287
|
/**
|
|
1096
|
-
* Controls model and thinking budget: 'fast' (cheapest/fastest), 'balanced',
|
|
1097
|
-
* 'accurate' (most thorough)
|
|
1288
|
+
* Controls model and thinking budget: 'fast' (cheapest/fastest), 'balanced',
|
|
1289
|
+
* 'accurate', or 'max' (most thorough)
|
|
1098
1290
|
*/
|
|
1099
|
-
thinking_level?: 'fast' | 'balanced' | 'accurate' | null;
|
|
1291
|
+
thinking_level?: 'fast' | 'balanced' | 'accurate' | 'max' | null;
|
|
1100
1292
|
}
|
|
1101
1293
|
|
|
1102
1294
|
export interface SourceExtractParams {
|
|
@@ -1122,10 +1314,10 @@ export interface SourceExtractParams {
|
|
|
1122
1314
|
file_names?: Array<string> | null;
|
|
1123
1315
|
|
|
1124
1316
|
/**
|
|
1125
|
-
* Controls model and thinking budget: 'fast' (cheapest/fastest), 'balanced',
|
|
1126
|
-
* 'accurate' (most thorough)
|
|
1317
|
+
* Controls model and thinking budget: 'fast' (cheapest/fastest), 'balanced',
|
|
1318
|
+
* 'accurate', or 'max' (most thorough)
|
|
1127
1319
|
*/
|
|
1128
|
-
thinking_level?: 'fast' | 'balanced' | 'accurate' | null;
|
|
1320
|
+
thinking_level?: 'fast' | 'balanced' | 'accurate' | 'max' | null;
|
|
1129
1321
|
}
|
|
1130
1322
|
|
|
1131
1323
|
export interface SourceGetBuildStatusParams {
|
|
@@ -1180,6 +1372,18 @@ export interface SourceGetElementsParams {
|
|
|
1180
1372
|
type?: string | null;
|
|
1181
1373
|
}
|
|
1182
1374
|
|
|
1375
|
+
export interface SourceGetPageScreenshotParams {
|
|
1376
|
+
/**
|
|
1377
|
+
* Path param
|
|
1378
|
+
*/
|
|
1379
|
+
file_id: string;
|
|
1380
|
+
|
|
1381
|
+
/**
|
|
1382
|
+
* Query param: Pixel width cap for the rendered image (clamped to 300-1600).
|
|
1383
|
+
*/
|
|
1384
|
+
max_width?: number;
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1183
1387
|
export interface SourceIngestFileParams {
|
|
1184
1388
|
file: Uploadable;
|
|
1185
1389
|
|
|
@@ -1191,7 +1395,6 @@ export interface SourceIngestFileParams {
|
|
|
1191
1395
|
* - fast → basic
|
|
1192
1396
|
* - balanced → hi_res
|
|
1193
1397
|
* - accurate → hi_res_ft
|
|
1194
|
-
* - vlm → mai
|
|
1195
1398
|
* - agentic → graphorlm
|
|
1196
1399
|
*/
|
|
1197
1400
|
method?: Method | null;
|
|
@@ -1223,7 +1426,6 @@ export interface SourceIngestURLParams {
|
|
|
1223
1426
|
* - fast → basic
|
|
1224
1427
|
* - balanced → hi_res
|
|
1225
1428
|
* - accurate → hi_res_ft
|
|
1226
|
-
* - vlm → mai
|
|
1227
1429
|
* - agentic → graphorlm
|
|
1228
1430
|
*/
|
|
1229
1431
|
method?: Method | null;
|
|
@@ -1244,7 +1446,7 @@ export interface SourceReprocessParams {
|
|
|
1244
1446
|
file_id: string;
|
|
1245
1447
|
|
|
1246
1448
|
/**
|
|
1247
|
-
* Partitioning strategy. One of: fast, balanced, accurate,
|
|
1449
|
+
* Partitioning strategy. One of: fast, balanced, accurate, agentic.
|
|
1248
1450
|
*/
|
|
1249
1451
|
method?: Method;
|
|
1250
1452
|
}
|
|
@@ -1278,6 +1480,7 @@ export declare namespace Sources {
|
|
|
1278
1480
|
type SourceExtractResponse as SourceExtractResponse,
|
|
1279
1481
|
type SourceGetBuildStatusResponse as SourceGetBuildStatusResponse,
|
|
1280
1482
|
type SourceGetElementsResponse as SourceGetElementsResponse,
|
|
1483
|
+
type SourceGetPageScreenshotResponse as SourceGetPageScreenshotResponse,
|
|
1281
1484
|
type SourceIngestFileResponse as SourceIngestFileResponse,
|
|
1282
1485
|
type SourceIngestGitHubResponse as SourceIngestGitHubResponse,
|
|
1283
1486
|
type SourceIngestURLResponse as SourceIngestURLResponse,
|
|
@@ -1290,6 +1493,7 @@ export declare namespace Sources {
|
|
|
1290
1493
|
type SourceExtractParams as SourceExtractParams,
|
|
1291
1494
|
type SourceGetBuildStatusParams as SourceGetBuildStatusParams,
|
|
1292
1495
|
type SourceGetElementsParams as SourceGetElementsParams,
|
|
1496
|
+
type SourceGetPageScreenshotParams as SourceGetPageScreenshotParams,
|
|
1293
1497
|
type SourceIngestFileParams as SourceIngestFileParams,
|
|
1294
1498
|
type SourceIngestGitHubParams as SourceIngestGitHubParams,
|
|
1295
1499
|
type SourceIngestURLParams as SourceIngestURLParams,
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.19.1'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.19.1";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.19.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.19.1'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|