graphor 0.9.1 → 0.10.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.
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/resources/sources.d.mts +85 -8
- package/resources/sources.d.mts.map +1 -1
- package/resources/sources.d.ts +85 -8
- package/resources/sources.d.ts.map +1 -1
- package/resources/sources.js +85 -8
- package/resources/sources.js.map +1 -1
- package/resources/sources.mjs +85 -8
- package/resources/sources.mjs.map +1 -1
- package/src/resources/sources.ts +85 -8
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.0 (2026-02-11)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.9.1...v0.10.0](https://github.com/synapseops/graphor-typescript-sdk/compare/v0.9.1...v0.10.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** api update ([76c2a15](https://github.com/synapseops/graphor-typescript-sdk/commit/76c2a15fd065a38483e5960aea675eca73e86086))
|
|
10
|
+
|
|
3
11
|
## 0.9.1 (2026-02-11)
|
|
4
12
|
|
|
5
13
|
Full Changelog: [v0.9.0...v0.9.1](https://github.com/synapseops/graphor-typescript-sdk/compare/v0.9.0...v0.9.1)
|
package/package.json
CHANGED
package/resources/sources.d.mts
CHANGED
|
@@ -270,17 +270,94 @@ export declare class Sources extends APIResource {
|
|
|
270
270
|
* Upload a local file and ingest it as a source into the project's knowledge
|
|
271
271
|
* graph.
|
|
272
272
|
*
|
|
273
|
-
* This endpoint accepts a multipart
|
|
274
|
-
*
|
|
275
|
-
* and then runs the full data-ingestion
|
|
276
|
-
* partitioning, chunking, embedding, and graph
|
|
273
|
+
* This endpoint accepts a **`multipart/form-data`** request containing the file to
|
|
274
|
+
* upload. It validates the file size (max 100 MB) and extension against the list
|
|
275
|
+
* of allowed types, stores the file, and then runs the full data-ingestion
|
|
276
|
+
* pipeline synchronously — including partitioning, chunking, embedding, and graph
|
|
277
|
+
* persistence.
|
|
278
|
+
*
|
|
279
|
+
* **Usage via SDK (AI agent / MCP context):**
|
|
280
|
+
*
|
|
281
|
+
* The SDK executes code in a **remote sandboxed container** that does **not** have
|
|
282
|
+
* access to the local filesystem. Because of this, `fs.createReadStream()` with a
|
|
283
|
+
* local file path will **not work** — the file does not exist inside the
|
|
284
|
+
* container.
|
|
285
|
+
*
|
|
286
|
+
* For **text-based files** (md, txt, csv, html, etc.), you can read the file
|
|
287
|
+
* content with a local tool (e.g. IDE file-read) and create a `File` object in
|
|
288
|
+
* memory:
|
|
289
|
+
*
|
|
290
|
+
* ```
|
|
291
|
+
* const content = `...file contents read locally...`;
|
|
292
|
+
* const file = new File([content], "my-document.md", { type: "text/markdown" });
|
|
293
|
+
* const result = await client.sources.upload({ file });
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* For **binary files** (pdf, docx, images, video, audio, etc.), the in-memory
|
|
297
|
+
* approach is impractical. Instead, use **`curl`** or **`subprocess`** to call the
|
|
298
|
+
* upload endpoint directly from the local machine, where the file is accessible:
|
|
299
|
+
*
|
|
300
|
+
* ```
|
|
301
|
+
* import { execSync } from "child_process";
|
|
302
|
+
*
|
|
303
|
+
* const result = execSync(`
|
|
304
|
+
* curl -s -X POST "{base_url}/source/upload" \
|
|
305
|
+
* -H "Authorization: Bearer {access_key}" \
|
|
306
|
+
* -F "file=@/local/path/to/document.pdf" \
|
|
307
|
+
* -F "partition_method=graphorlm"
|
|
308
|
+
* `).toString();
|
|
309
|
+
* ```
|
|
310
|
+
*
|
|
311
|
+
* Or with Python `subprocess`:
|
|
312
|
+
*
|
|
313
|
+
* ```
|
|
314
|
+
* import subprocess, json
|
|
315
|
+
*
|
|
316
|
+
* result = subprocess.run([
|
|
317
|
+
* "curl", "-s", "-X", "POST", "{base_url}/source/upload",
|
|
318
|
+
* "-H", "Authorization: Bearer {access_key}",
|
|
319
|
+
* "-F", "file=@/local/path/to/document.pdf",
|
|
320
|
+
* "-F", "partition_method=graphorlm",
|
|
321
|
+
* ], capture_output=True, text=True)
|
|
322
|
+
* response = json.loads(result.stdout)
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* **Important:** Do NOT use `fs.createReadStream("/local/path")` inside the SDK
|
|
326
|
+
* code — it will fail because the execution environment cannot access local paths.
|
|
327
|
+
* Always prefer `curl`/`requests` executed locally for binary uploads.
|
|
328
|
+
*
|
|
329
|
+
* **Usage via curl:**
|
|
330
|
+
*
|
|
331
|
+
* ```
|
|
332
|
+
* curl -X POST "{base_url}/source/upload" \
|
|
333
|
+
* -H "Authorization: Bearer {access_key}" \
|
|
334
|
+
* -F "file=@/path/to/document.pdf" \
|
|
335
|
+
* -F "partition_method=graphorlm"
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
* **Usage via Python `requests`:**
|
|
339
|
+
*
|
|
340
|
+
* ```
|
|
341
|
+
* import requests
|
|
342
|
+
*
|
|
343
|
+
* with open("document.pdf", "rb") as f:
|
|
344
|
+
* response = requests.post(
|
|
345
|
+
* "{base_url}/source/upload",
|
|
346
|
+
* headers={"Authorization": "Bearer {access_key}"},
|
|
347
|
+
* files={"file": ("document.pdf", f, "application/pdf")},
|
|
348
|
+
* data={"partition_method": "graphorlm"}, # optional
|
|
349
|
+
* )
|
|
350
|
+
* ```
|
|
277
351
|
*
|
|
278
352
|
* **Parameters:**
|
|
279
353
|
*
|
|
280
|
-
* - **file** (multipart): The file to upload. Must include a
|
|
281
|
-
* header and have
|
|
282
|
-
*
|
|
283
|
-
*
|
|
354
|
+
* - **file** (`multipart/form-data`): The file to upload. Must include a
|
|
355
|
+
* `Content-Length` header and have one of the supported extensions: pdf, doc,
|
|
356
|
+
* docx, odt, ppt, pptx, csv, tsv, xls, xlsx, txt, text, md, html, htm, png, jpg,
|
|
357
|
+
* jpeg, tiff, bmp, heic, mp4, mov, avi, mkv, webm, mp3, wav, m4a, ogg, flac.
|
|
358
|
+
* - **partition_method** (`form`, optional): The partitioning strategy to apply.
|
|
359
|
+
* One of: `basic`, `hi_res`, `hi_res_ft`, `mai`, `graphorlm`. When omitted, the
|
|
360
|
+
* system default is used.
|
|
284
361
|
*
|
|
285
362
|
* **Returns** a `PublicSourceResponse` with the resulting source metadata (file
|
|
286
363
|
* ID, name, size, type, source origin, partition method, and processing status).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sources.d.mts","sourceRoot":"","sources":["../src/resources/sources.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,KAAK,UAAU,EAAE;OACnB,EAAE,cAAc,EAAE;AAGzB,qBAAa,OAAQ,SAAQ,WAAW;IACtC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,kBAAkB,CAAC;IAI9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,MAAM,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,oBAAoB,CAAC;IAI5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiDG;IACH,GAAG,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,iBAAiB,CAAC;IAInF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,OAAO,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,qBAAqB,CAAC;IAI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BAAkB,EAC7C,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,yBAAyB,IAAI,yBAAyB,GAC5D,CAAC;CACH"}
|
package/resources/sources.d.ts
CHANGED
|
@@ -270,17 +270,94 @@ export declare class Sources extends APIResource {
|
|
|
270
270
|
* Upload a local file and ingest it as a source into the project's knowledge
|
|
271
271
|
* graph.
|
|
272
272
|
*
|
|
273
|
-
* This endpoint accepts a multipart
|
|
274
|
-
*
|
|
275
|
-
* and then runs the full data-ingestion
|
|
276
|
-
* partitioning, chunking, embedding, and graph
|
|
273
|
+
* This endpoint accepts a **`multipart/form-data`** request containing the file to
|
|
274
|
+
* upload. It validates the file size (max 100 MB) and extension against the list
|
|
275
|
+
* of allowed types, stores the file, and then runs the full data-ingestion
|
|
276
|
+
* pipeline synchronously — including partitioning, chunking, embedding, and graph
|
|
277
|
+
* persistence.
|
|
278
|
+
*
|
|
279
|
+
* **Usage via SDK (AI agent / MCP context):**
|
|
280
|
+
*
|
|
281
|
+
* The SDK executes code in a **remote sandboxed container** that does **not** have
|
|
282
|
+
* access to the local filesystem. Because of this, `fs.createReadStream()` with a
|
|
283
|
+
* local file path will **not work** — the file does not exist inside the
|
|
284
|
+
* container.
|
|
285
|
+
*
|
|
286
|
+
* For **text-based files** (md, txt, csv, html, etc.), you can read the file
|
|
287
|
+
* content with a local tool (e.g. IDE file-read) and create a `File` object in
|
|
288
|
+
* memory:
|
|
289
|
+
*
|
|
290
|
+
* ```
|
|
291
|
+
* const content = `...file contents read locally...`;
|
|
292
|
+
* const file = new File([content], "my-document.md", { type: "text/markdown" });
|
|
293
|
+
* const result = await client.sources.upload({ file });
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* For **binary files** (pdf, docx, images, video, audio, etc.), the in-memory
|
|
297
|
+
* approach is impractical. Instead, use **`curl`** or **`subprocess`** to call the
|
|
298
|
+
* upload endpoint directly from the local machine, where the file is accessible:
|
|
299
|
+
*
|
|
300
|
+
* ```
|
|
301
|
+
* import { execSync } from "child_process";
|
|
302
|
+
*
|
|
303
|
+
* const result = execSync(`
|
|
304
|
+
* curl -s -X POST "{base_url}/source/upload" \
|
|
305
|
+
* -H "Authorization: Bearer {access_key}" \
|
|
306
|
+
* -F "file=@/local/path/to/document.pdf" \
|
|
307
|
+
* -F "partition_method=graphorlm"
|
|
308
|
+
* `).toString();
|
|
309
|
+
* ```
|
|
310
|
+
*
|
|
311
|
+
* Or with Python `subprocess`:
|
|
312
|
+
*
|
|
313
|
+
* ```
|
|
314
|
+
* import subprocess, json
|
|
315
|
+
*
|
|
316
|
+
* result = subprocess.run([
|
|
317
|
+
* "curl", "-s", "-X", "POST", "{base_url}/source/upload",
|
|
318
|
+
* "-H", "Authorization: Bearer {access_key}",
|
|
319
|
+
* "-F", "file=@/local/path/to/document.pdf",
|
|
320
|
+
* "-F", "partition_method=graphorlm",
|
|
321
|
+
* ], capture_output=True, text=True)
|
|
322
|
+
* response = json.loads(result.stdout)
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* **Important:** Do NOT use `fs.createReadStream("/local/path")` inside the SDK
|
|
326
|
+
* code — it will fail because the execution environment cannot access local paths.
|
|
327
|
+
* Always prefer `curl`/`requests` executed locally for binary uploads.
|
|
328
|
+
*
|
|
329
|
+
* **Usage via curl:**
|
|
330
|
+
*
|
|
331
|
+
* ```
|
|
332
|
+
* curl -X POST "{base_url}/source/upload" \
|
|
333
|
+
* -H "Authorization: Bearer {access_key}" \
|
|
334
|
+
* -F "file=@/path/to/document.pdf" \
|
|
335
|
+
* -F "partition_method=graphorlm"
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
* **Usage via Python `requests`:**
|
|
339
|
+
*
|
|
340
|
+
* ```
|
|
341
|
+
* import requests
|
|
342
|
+
*
|
|
343
|
+
* with open("document.pdf", "rb") as f:
|
|
344
|
+
* response = requests.post(
|
|
345
|
+
* "{base_url}/source/upload",
|
|
346
|
+
* headers={"Authorization": "Bearer {access_key}"},
|
|
347
|
+
* files={"file": ("document.pdf", f, "application/pdf")},
|
|
348
|
+
* data={"partition_method": "graphorlm"}, # optional
|
|
349
|
+
* )
|
|
350
|
+
* ```
|
|
277
351
|
*
|
|
278
352
|
* **Parameters:**
|
|
279
353
|
*
|
|
280
|
-
* - **file** (multipart): The file to upload. Must include a
|
|
281
|
-
* header and have
|
|
282
|
-
*
|
|
283
|
-
*
|
|
354
|
+
* - **file** (`multipart/form-data`): The file to upload. Must include a
|
|
355
|
+
* `Content-Length` header and have one of the supported extensions: pdf, doc,
|
|
356
|
+
* docx, odt, ppt, pptx, csv, tsv, xls, xlsx, txt, text, md, html, htm, png, jpg,
|
|
357
|
+
* jpeg, tiff, bmp, heic, mp4, mov, avi, mkv, webm, mp3, wav, m4a, ogg, flac.
|
|
358
|
+
* - **partition_method** (`form`, optional): The partitioning strategy to apply.
|
|
359
|
+
* One of: `basic`, `hi_res`, `hi_res_ft`, `mai`, `graphorlm`. When omitted, the
|
|
360
|
+
* system default is used.
|
|
284
361
|
*
|
|
285
362
|
* **Returns** a `PublicSourceResponse` with the resulting source metadata (file
|
|
286
363
|
* ID, name, size, type, source origin, partition method, and processing status).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../src/resources/sources.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,KAAK,UAAU,EAAE;OACnB,EAAE,cAAc,EAAE;AAGzB,qBAAa,OAAQ,SAAQ,WAAW;IACtC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,kBAAkB,CAAC;IAI9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,MAAM,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAA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AI,iBAAiB,EAC3C,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,yBAAyB,IAAI,yBAAyB,GAC5D,CAAC;CACH"}
|
package/resources/sources.js
CHANGED
|
@@ -286,17 +286,94 @@ class Sources extends resource_1.APIResource {
|
|
|
286
286
|
* Upload a local file and ingest it as a source into the project's knowledge
|
|
287
287
|
* graph.
|
|
288
288
|
*
|
|
289
|
-
* This endpoint accepts a multipart
|
|
290
|
-
*
|
|
291
|
-
* and then runs the full data-ingestion
|
|
292
|
-
* partitioning, chunking, embedding, and graph
|
|
289
|
+
* This endpoint accepts a **`multipart/form-data`** request containing the file to
|
|
290
|
+
* upload. It validates the file size (max 100 MB) and extension against the list
|
|
291
|
+
* of allowed types, stores the file, and then runs the full data-ingestion
|
|
292
|
+
* pipeline synchronously — including partitioning, chunking, embedding, and graph
|
|
293
|
+
* persistence.
|
|
294
|
+
*
|
|
295
|
+
* **Usage via SDK (AI agent / MCP context):**
|
|
296
|
+
*
|
|
297
|
+
* The SDK executes code in a **remote sandboxed container** that does **not** have
|
|
298
|
+
* access to the local filesystem. Because of this, `fs.createReadStream()` with a
|
|
299
|
+
* local file path will **not work** — the file does not exist inside the
|
|
300
|
+
* container.
|
|
301
|
+
*
|
|
302
|
+
* For **text-based files** (md, txt, csv, html, etc.), you can read the file
|
|
303
|
+
* content with a local tool (e.g. IDE file-read) and create a `File` object in
|
|
304
|
+
* memory:
|
|
305
|
+
*
|
|
306
|
+
* ```
|
|
307
|
+
* const content = `...file contents read locally...`;
|
|
308
|
+
* const file = new File([content], "my-document.md", { type: "text/markdown" });
|
|
309
|
+
* const result = await client.sources.upload({ file });
|
|
310
|
+
* ```
|
|
311
|
+
*
|
|
312
|
+
* For **binary files** (pdf, docx, images, video, audio, etc.), the in-memory
|
|
313
|
+
* approach is impractical. Instead, use **`curl`** or **`subprocess`** to call the
|
|
314
|
+
* upload endpoint directly from the local machine, where the file is accessible:
|
|
315
|
+
*
|
|
316
|
+
* ```
|
|
317
|
+
* import { execSync } from "child_process";
|
|
318
|
+
*
|
|
319
|
+
* const result = execSync(`
|
|
320
|
+
* curl -s -X POST "{base_url}/source/upload" \
|
|
321
|
+
* -H "Authorization: Bearer {access_key}" \
|
|
322
|
+
* -F "file=@/local/path/to/document.pdf" \
|
|
323
|
+
* -F "partition_method=graphorlm"
|
|
324
|
+
* `).toString();
|
|
325
|
+
* ```
|
|
326
|
+
*
|
|
327
|
+
* Or with Python `subprocess`:
|
|
328
|
+
*
|
|
329
|
+
* ```
|
|
330
|
+
* import subprocess, json
|
|
331
|
+
*
|
|
332
|
+
* result = subprocess.run([
|
|
333
|
+
* "curl", "-s", "-X", "POST", "{base_url}/source/upload",
|
|
334
|
+
* "-H", "Authorization: Bearer {access_key}",
|
|
335
|
+
* "-F", "file=@/local/path/to/document.pdf",
|
|
336
|
+
* "-F", "partition_method=graphorlm",
|
|
337
|
+
* ], capture_output=True, text=True)
|
|
338
|
+
* response = json.loads(result.stdout)
|
|
339
|
+
* ```
|
|
340
|
+
*
|
|
341
|
+
* **Important:** Do NOT use `fs.createReadStream("/local/path")` inside the SDK
|
|
342
|
+
* code — it will fail because the execution environment cannot access local paths.
|
|
343
|
+
* Always prefer `curl`/`requests` executed locally for binary uploads.
|
|
344
|
+
*
|
|
345
|
+
* **Usage via curl:**
|
|
346
|
+
*
|
|
347
|
+
* ```
|
|
348
|
+
* curl -X POST "{base_url}/source/upload" \
|
|
349
|
+
* -H "Authorization: Bearer {access_key}" \
|
|
350
|
+
* -F "file=@/path/to/document.pdf" \
|
|
351
|
+
* -F "partition_method=graphorlm"
|
|
352
|
+
* ```
|
|
353
|
+
*
|
|
354
|
+
* **Usage via Python `requests`:**
|
|
355
|
+
*
|
|
356
|
+
* ```
|
|
357
|
+
* import requests
|
|
358
|
+
*
|
|
359
|
+
* with open("document.pdf", "rb") as f:
|
|
360
|
+
* response = requests.post(
|
|
361
|
+
* "{base_url}/source/upload",
|
|
362
|
+
* headers={"Authorization": "Bearer {access_key}"},
|
|
363
|
+
* files={"file": ("document.pdf", f, "application/pdf")},
|
|
364
|
+
* data={"partition_method": "graphorlm"}, # optional
|
|
365
|
+
* )
|
|
366
|
+
* ```
|
|
293
367
|
*
|
|
294
368
|
* **Parameters:**
|
|
295
369
|
*
|
|
296
|
-
* - **file** (multipart): The file to upload. Must include a
|
|
297
|
-
* header and have
|
|
298
|
-
*
|
|
299
|
-
*
|
|
370
|
+
* - **file** (`multipart/form-data`): The file to upload. Must include a
|
|
371
|
+
* `Content-Length` header and have one of the supported extensions: pdf, doc,
|
|
372
|
+
* docx, odt, ppt, pptx, csv, tsv, xls, xlsx, txt, text, md, html, htm, png, jpg,
|
|
373
|
+
* jpeg, tiff, bmp, heic, mp4, mov, avi, mkv, webm, mp3, wav, m4a, ogg, flac.
|
|
374
|
+
* - **partition_method** (`form`, optional): The partitioning strategy to apply.
|
|
375
|
+
* One of: `basic`, `hi_res`, `hi_res_ft`, `mai`, `graphorlm`. When omitted, the
|
|
376
|
+
* system default is used.
|
|
300
377
|
*
|
|
301
378
|
* **Returns** a `PublicSourceResponse` with the resulting source metadata (file
|
|
302
379
|
* ID, name, size, type, source origin, partition method, and processing status).
|
package/resources/sources.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sources.js","sourceRoot":"","sources":["../src/resources/sources.ts"],"names":[],"mappings":";A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;IAClF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,SAAS,CAAC,IAA2B,EAAE,OAAwB;QAC7D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,4BAA4B,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,aAAa,CAAC,IAA+B,EAAE,OAAwB;QACrE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACnF,CAAC;CACF;AAxfD,0BAwfC"}
|
package/resources/sources.mjs
CHANGED
|
@@ -283,17 +283,94 @@ export class Sources extends APIResource {
|
|
|
283
283
|
* Upload a local file and ingest it as a source into the project's knowledge
|
|
284
284
|
* graph.
|
|
285
285
|
*
|
|
286
|
-
* This endpoint accepts a multipart
|
|
287
|
-
*
|
|
288
|
-
* and then runs the full data-ingestion
|
|
289
|
-
* partitioning, chunking, embedding, and graph
|
|
286
|
+
* This endpoint accepts a **`multipart/form-data`** request containing the file to
|
|
287
|
+
* upload. It validates the file size (max 100 MB) and extension against the list
|
|
288
|
+
* of allowed types, stores the file, and then runs the full data-ingestion
|
|
289
|
+
* pipeline synchronously — including partitioning, chunking, embedding, and graph
|
|
290
|
+
* persistence.
|
|
291
|
+
*
|
|
292
|
+
* **Usage via SDK (AI agent / MCP context):**
|
|
293
|
+
*
|
|
294
|
+
* The SDK executes code in a **remote sandboxed container** that does **not** have
|
|
295
|
+
* access to the local filesystem. Because of this, `fs.createReadStream()` with a
|
|
296
|
+
* local file path will **not work** — the file does not exist inside the
|
|
297
|
+
* container.
|
|
298
|
+
*
|
|
299
|
+
* For **text-based files** (md, txt, csv, html, etc.), you can read the file
|
|
300
|
+
* content with a local tool (e.g. IDE file-read) and create a `File` object in
|
|
301
|
+
* memory:
|
|
302
|
+
*
|
|
303
|
+
* ```
|
|
304
|
+
* const content = `...file contents read locally...`;
|
|
305
|
+
* const file = new File([content], "my-document.md", { type: "text/markdown" });
|
|
306
|
+
* const result = await client.sources.upload({ file });
|
|
307
|
+
* ```
|
|
308
|
+
*
|
|
309
|
+
* For **binary files** (pdf, docx, images, video, audio, etc.), the in-memory
|
|
310
|
+
* approach is impractical. Instead, use **`curl`** or **`subprocess`** to call the
|
|
311
|
+
* upload endpoint directly from the local machine, where the file is accessible:
|
|
312
|
+
*
|
|
313
|
+
* ```
|
|
314
|
+
* import { execSync } from "child_process";
|
|
315
|
+
*
|
|
316
|
+
* const result = execSync(`
|
|
317
|
+
* curl -s -X POST "{base_url}/source/upload" \
|
|
318
|
+
* -H "Authorization: Bearer {access_key}" \
|
|
319
|
+
* -F "file=@/local/path/to/document.pdf" \
|
|
320
|
+
* -F "partition_method=graphorlm"
|
|
321
|
+
* `).toString();
|
|
322
|
+
* ```
|
|
323
|
+
*
|
|
324
|
+
* Or with Python `subprocess`:
|
|
325
|
+
*
|
|
326
|
+
* ```
|
|
327
|
+
* import subprocess, json
|
|
328
|
+
*
|
|
329
|
+
* result = subprocess.run([
|
|
330
|
+
* "curl", "-s", "-X", "POST", "{base_url}/source/upload",
|
|
331
|
+
* "-H", "Authorization: Bearer {access_key}",
|
|
332
|
+
* "-F", "file=@/local/path/to/document.pdf",
|
|
333
|
+
* "-F", "partition_method=graphorlm",
|
|
334
|
+
* ], capture_output=True, text=True)
|
|
335
|
+
* response = json.loads(result.stdout)
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
* **Important:** Do NOT use `fs.createReadStream("/local/path")` inside the SDK
|
|
339
|
+
* code — it will fail because the execution environment cannot access local paths.
|
|
340
|
+
* Always prefer `curl`/`requests` executed locally for binary uploads.
|
|
341
|
+
*
|
|
342
|
+
* **Usage via curl:**
|
|
343
|
+
*
|
|
344
|
+
* ```
|
|
345
|
+
* curl -X POST "{base_url}/source/upload" \
|
|
346
|
+
* -H "Authorization: Bearer {access_key}" \
|
|
347
|
+
* -F "file=@/path/to/document.pdf" \
|
|
348
|
+
* -F "partition_method=graphorlm"
|
|
349
|
+
* ```
|
|
350
|
+
*
|
|
351
|
+
* **Usage via Python `requests`:**
|
|
352
|
+
*
|
|
353
|
+
* ```
|
|
354
|
+
* import requests
|
|
355
|
+
*
|
|
356
|
+
* with open("document.pdf", "rb") as f:
|
|
357
|
+
* response = requests.post(
|
|
358
|
+
* "{base_url}/source/upload",
|
|
359
|
+
* headers={"Authorization": "Bearer {access_key}"},
|
|
360
|
+
* files={"file": ("document.pdf", f, "application/pdf")},
|
|
361
|
+
* data={"partition_method": "graphorlm"}, # optional
|
|
362
|
+
* )
|
|
363
|
+
* ```
|
|
290
364
|
*
|
|
291
365
|
* **Parameters:**
|
|
292
366
|
*
|
|
293
|
-
* - **file** (multipart): The file to upload. Must include a
|
|
294
|
-
* header and have
|
|
295
|
-
*
|
|
296
|
-
*
|
|
367
|
+
* - **file** (`multipart/form-data`): The file to upload. Must include a
|
|
368
|
+
* `Content-Length` header and have one of the supported extensions: pdf, doc,
|
|
369
|
+
* docx, odt, ppt, pptx, csv, tsv, xls, xlsx, txt, text, md, html, htm, png, jpg,
|
|
370
|
+
* jpeg, tiff, bmp, heic, mp4, mov, avi, mkv, webm, mp3, wav, m4a, ogg, flac.
|
|
371
|
+
* - **partition_method** (`form`, optional): The partitioning strategy to apply.
|
|
372
|
+
* One of: `basic`, `hi_res`, `hi_res_ft`, `mai`, `graphorlm`. When omitted, the
|
|
373
|
+
* system default is used.
|
|
297
374
|
*
|
|
298
375
|
* **Returns** a `PublicSourceResponse` with the resulting source metadata (file
|
|
299
376
|
* ID, name, size, type, source origin, partition method, and processing status).
|
|
@@ -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;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;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,SAAS,CAAC,IAA2B,EAAE,OAAwB;QAC7D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,4BAA4B,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,aAAa,CAAC,IAA+B,EAAE,OAAwB;QACrE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACnF,CAAC;CACF"}
|
package/src/resources/sources.ts
CHANGED
|
@@ -301,17 +301,94 @@ export class Sources extends APIResource {
|
|
|
301
301
|
* Upload a local file and ingest it as a source into the project's knowledge
|
|
302
302
|
* graph.
|
|
303
303
|
*
|
|
304
|
-
* This endpoint accepts a multipart
|
|
305
|
-
*
|
|
306
|
-
* and then runs the full data-ingestion
|
|
307
|
-
* partitioning, chunking, embedding, and graph
|
|
304
|
+
* This endpoint accepts a **`multipart/form-data`** request containing the file to
|
|
305
|
+
* upload. It validates the file size (max 100 MB) and extension against the list
|
|
306
|
+
* of allowed types, stores the file, and then runs the full data-ingestion
|
|
307
|
+
* pipeline synchronously — including partitioning, chunking, embedding, and graph
|
|
308
|
+
* persistence.
|
|
309
|
+
*
|
|
310
|
+
* **Usage via SDK (AI agent / MCP context):**
|
|
311
|
+
*
|
|
312
|
+
* The SDK executes code in a **remote sandboxed container** that does **not** have
|
|
313
|
+
* access to the local filesystem. Because of this, `fs.createReadStream()` with a
|
|
314
|
+
* local file path will **not work** — the file does not exist inside the
|
|
315
|
+
* container.
|
|
316
|
+
*
|
|
317
|
+
* For **text-based files** (md, txt, csv, html, etc.), you can read the file
|
|
318
|
+
* content with a local tool (e.g. IDE file-read) and create a `File` object in
|
|
319
|
+
* memory:
|
|
320
|
+
*
|
|
321
|
+
* ```
|
|
322
|
+
* const content = `...file contents read locally...`;
|
|
323
|
+
* const file = new File([content], "my-document.md", { type: "text/markdown" });
|
|
324
|
+
* const result = await client.sources.upload({ file });
|
|
325
|
+
* ```
|
|
326
|
+
*
|
|
327
|
+
* For **binary files** (pdf, docx, images, video, audio, etc.), the in-memory
|
|
328
|
+
* approach is impractical. Instead, use **`curl`** or **`subprocess`** to call the
|
|
329
|
+
* upload endpoint directly from the local machine, where the file is accessible:
|
|
330
|
+
*
|
|
331
|
+
* ```
|
|
332
|
+
* import { execSync } from "child_process";
|
|
333
|
+
*
|
|
334
|
+
* const result = execSync(`
|
|
335
|
+
* curl -s -X POST "{base_url}/source/upload" \
|
|
336
|
+
* -H "Authorization: Bearer {access_key}" \
|
|
337
|
+
* -F "file=@/local/path/to/document.pdf" \
|
|
338
|
+
* -F "partition_method=graphorlm"
|
|
339
|
+
* `).toString();
|
|
340
|
+
* ```
|
|
341
|
+
*
|
|
342
|
+
* Or with Python `subprocess`:
|
|
343
|
+
*
|
|
344
|
+
* ```
|
|
345
|
+
* import subprocess, json
|
|
346
|
+
*
|
|
347
|
+
* result = subprocess.run([
|
|
348
|
+
* "curl", "-s", "-X", "POST", "{base_url}/source/upload",
|
|
349
|
+
* "-H", "Authorization: Bearer {access_key}",
|
|
350
|
+
* "-F", "file=@/local/path/to/document.pdf",
|
|
351
|
+
* "-F", "partition_method=graphorlm",
|
|
352
|
+
* ], capture_output=True, text=True)
|
|
353
|
+
* response = json.loads(result.stdout)
|
|
354
|
+
* ```
|
|
355
|
+
*
|
|
356
|
+
* **Important:** Do NOT use `fs.createReadStream("/local/path")` inside the SDK
|
|
357
|
+
* code — it will fail because the execution environment cannot access local paths.
|
|
358
|
+
* Always prefer `curl`/`requests` executed locally for binary uploads.
|
|
359
|
+
*
|
|
360
|
+
* **Usage via curl:**
|
|
361
|
+
*
|
|
362
|
+
* ```
|
|
363
|
+
* curl -X POST "{base_url}/source/upload" \
|
|
364
|
+
* -H "Authorization: Bearer {access_key}" \
|
|
365
|
+
* -F "file=@/path/to/document.pdf" \
|
|
366
|
+
* -F "partition_method=graphorlm"
|
|
367
|
+
* ```
|
|
368
|
+
*
|
|
369
|
+
* **Usage via Python `requests`:**
|
|
370
|
+
*
|
|
371
|
+
* ```
|
|
372
|
+
* import requests
|
|
373
|
+
*
|
|
374
|
+
* with open("document.pdf", "rb") as f:
|
|
375
|
+
* response = requests.post(
|
|
376
|
+
* "{base_url}/source/upload",
|
|
377
|
+
* headers={"Authorization": "Bearer {access_key}"},
|
|
378
|
+
* files={"file": ("document.pdf", f, "application/pdf")},
|
|
379
|
+
* data={"partition_method": "graphorlm"}, # optional
|
|
380
|
+
* )
|
|
381
|
+
* ```
|
|
308
382
|
*
|
|
309
383
|
* **Parameters:**
|
|
310
384
|
*
|
|
311
|
-
* - **file** (multipart): The file to upload. Must include a
|
|
312
|
-
* header and have
|
|
313
|
-
*
|
|
314
|
-
*
|
|
385
|
+
* - **file** (`multipart/form-data`): The file to upload. Must include a
|
|
386
|
+
* `Content-Length` header and have one of the supported extensions: pdf, doc,
|
|
387
|
+
* docx, odt, ppt, pptx, csv, tsv, xls, xlsx, txt, text, md, html, htm, png, jpg,
|
|
388
|
+
* jpeg, tiff, bmp, heic, mp4, mov, avi, mkv, webm, mp3, wav, m4a, ogg, flac.
|
|
389
|
+
* - **partition_method** (`form`, optional): The partitioning strategy to apply.
|
|
390
|
+
* One of: `basic`, `hi_res`, `hi_res_ft`, `mai`, `graphorlm`. When omitted, the
|
|
391
|
+
* system default is used.
|
|
315
392
|
*
|
|
316
393
|
* **Returns** a `PublicSourceResponse` with the resulting source metadata (file
|
|
317
394
|
* ID, name, size, type, source origin, partition method, and processing status).
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.10.0'; // 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.10.0";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.mts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.mts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.10.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
package/version.js
CHANGED
package/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,QAAQ,CAAC,CAAC,2BAA2B"}
|
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.10.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|
package/version.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,2BAA2B"}
|