@mindstudio-ai/agent 0.1.182 → 0.1.184

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/dist/index.js CHANGED
@@ -3706,6 +3706,35 @@ function createFiles(call, runStep) {
3706
3706
 
3707
3707
  // src/datasources/source.ts
3708
3708
  import { createHash as createHash2 } from "node:crypto";
3709
+
3710
+ // src/datasources/parts.ts
3711
+ import { gzipSync } from "node:zlib";
3712
+ var PART_DOCUMENTS = 1e3;
3713
+ var PART_BYTES = 8 * 1024 * 1024;
3714
+ async function storePart(grant, lines) {
3715
+ const form = new FormData();
3716
+ for (const [k, v] of Object.entries(grant.uploadFields)) {
3717
+ form.append(k, v);
3718
+ }
3719
+ form.append(
3720
+ "file",
3721
+ new Blob([new Uint8Array(gzipSync(Buffer.from(lines.join("\n") + "\n")))], {
3722
+ type: "application/gzip"
3723
+ }),
3724
+ `${grant.part}.ndjson.gz`
3725
+ );
3726
+ const response = await fetch(grant.uploadUrl, {
3727
+ method: "POST",
3728
+ body: form
3729
+ });
3730
+ if (!response.ok) {
3731
+ throw new Error(
3732
+ `Could not store part ${grant.part} of the documents: HTTP ${response.status}`
3733
+ );
3734
+ }
3735
+ }
3736
+
3737
+ // src/datasources/source.ts
3709
3738
  var DICTIONARY_PAGE_ENTRIES = 1e4;
3710
3739
  var DICTIONARY_PAGE_BYTES = 4e6;
3711
3740
  var REMOVE_WHERE_MAX_PAGES = 100;
@@ -4007,6 +4036,87 @@ var DataSource = class {
4007
4036
  body: bytes.toString("base64")
4008
4037
  });
4009
4038
  }
4039
+ /**
4040
+ * Add many documents at once, built as one job.
4041
+ *
4042
+ * For records your app renders to text: a row of its own table as a short
4043
+ * markdown card, in any number. Each is what a mapper's `documents()`
4044
+ * returns (an `externalId`, a `title`, `markdown`, and optionally
4045
+ * `metadata`, `entities` and `replaces`), given as an array or any iterable
4046
+ * or async iterable, so a generator that yields a document per row never
4047
+ * holds them all. {@link add} is for a file.
4048
+ *
4049
+ * ```ts
4050
+ * const { job } = await Claims.addMany(
4051
+ * claims.map((claim) => ({
4052
+ * externalId: claim.id,
4053
+ * title: claim.title,
4054
+ * markdown: renderCard(claim),
4055
+ * metadata: { firmId: claim.firmId, status: claim.status },
4056
+ * })),
4057
+ * );
4058
+ * ```
4059
+ *
4060
+ * The documents are stored a thousand at a time and one job registers and
4061
+ * builds them, planned and priced like any other; it starts on its own
4062
+ * within `budgetDollars`, or within its plan's projection with headroom when
4063
+ * none is given. The call returns once the job has started: follow it with
4064
+ * {@link job}, and a search sees what has been built throughout.
4065
+ *
4066
+ * The external id is a document's identity. Giving one the source already
4067
+ * holds supersedes that document once the job's documents are all
4068
+ * searchable; unchanged markdown builds nothing, and new metadata or
4069
+ * entities on unchanged markdown update in place. A document that fails
4070
+ * validation is left out and counted on the job; the rest go in. Nothing is
4071
+ * removed for being left out of a later call: use {@link remove} or
4072
+ * {@link removeWhere}.
4073
+ *
4074
+ * @throws `data_source_mapped` on a source with a mapper, which is what
4075
+ * makes that source's documents; `data_source_busy` while another job or
4076
+ * a move is in flight, since a source runs one job at a time.
4077
+ */
4078
+ async addMany(documents2, options) {
4079
+ const { uploadId } = await this._call("add-many/open", {
4080
+ slug: this._slug
4081
+ });
4082
+ const parts = [];
4083
+ let lines = [];
4084
+ let bytes = 0;
4085
+ let documentCount = 0;
4086
+ const storeLines = async () => {
4087
+ if (lines.length === 0) {
4088
+ return;
4089
+ }
4090
+ const grant = await this._call("add-many/part", {
4091
+ slug: this._slug,
4092
+ uploadId
4093
+ });
4094
+ await storePart(grant, lines);
4095
+ parts.push({ part: grant.part, count: lines.length });
4096
+ lines = [];
4097
+ bytes = 0;
4098
+ };
4099
+ for await (const d of documents2) {
4100
+ const line = JSON.stringify({ o: 0, i: documentCount, d });
4101
+ lines.push(line);
4102
+ bytes += line.length;
4103
+ documentCount += 1;
4104
+ if (lines.length >= PART_DOCUMENTS || bytes >= PART_BYTES) {
4105
+ await storeLines();
4106
+ }
4107
+ }
4108
+ await storeLines();
4109
+ if (parts.length === 0) {
4110
+ return { documentCount: 0, job: null };
4111
+ }
4112
+ const { job } = await this._call("add-many/start", {
4113
+ slug: this._slug,
4114
+ uploadId,
4115
+ parts,
4116
+ ...options?.budgetDollars !== void 0 ? { budgetDollars: options.budgetDollars } : {}
4117
+ });
4118
+ return { documentCount, job };
4119
+ }
4010
4120
  /**
4011
4121
  * Documents in the corpus, with ingest status.
4012
4122
  *
@@ -5155,8 +5265,8 @@ var stepMetadata = {
5155
5265
  "evaluateDecision": {
5156
5266
  stepType: "evaluateDecision",
5157
5267
  description: "Ask structured questions about text, JSON, or images and get calibrated answers from a decision model. The model returns a probability, a selected option, or a score. It does not write a reply. Each question is a noul (yes or no, as a probability from 0 to 1), a choice (one option from a set you define, with a probability for each), or a score (a rating against ordered levels). Put every question in the same call. The question id is yours: answers come back under the same ids. The model defaults to Jev (jev-latest).",
5158
- usageNotes: "- state is the content to judge: a string, or a JSON object or array (a record, a chat log, application state).\n- questions is a map. The key is an id you choose. It is not shown to the model. The answer comes back under the same id.\n- A noul asks a yes/no question and returns noul, a probability from 0 (no) to 1 (yes). Optional criteria.true and criteria.false say what a yes and a no mean.\n- A choice picks one option. criteria is a map of option id to a short description (or null). At most 255 options. The answer includes the winning choice, a probability for every option, and confidence.\n- A score rates the state on an ordered rubric. criteria is 2 to 10 level descriptions, low to high. The answer's score can land between levels, and includes a probability per level plus confidence.\n- An answer of type refusal means the model declined that question (GPT-6 Luna Decisions can).\n- instructions may be a string, or an object that keeps the question in one field and reference data in the others. Refer to those fields by name in backticks.\n- Send every question you need in one call. The model reads the state once and answers them together.\n- Probabilities from different models are not comparable: tune a threshold against the model, and the version, it will run on.\n- decisionModelOverride.model picks the model:\n - jev-latest (the default) is TypeSafe's current stable release, text only, up to 64k tokens. jev-preview tracks TypeSafe's newest release. Pin a version such as jev-1.13.0 when a threshold was tuned against that version.\n - clef and clef-flash run Cloudflare Clef, which also reads up to 4 PNG, JPEG, or WebP images, each at most 4 MiB and 8 MiB together, and takes at most 64 questions, each id using only letters, digits, underscore, dot, and hyphen, up to 100 characters. clef is the larger model, clef-flash the faster one. @cf/cloudflare/clef and @cf/cloudflare/clef-flash name the same two.\n - mercury-decide runs Inception's Mercury Decide, which reads up to 64k tokens and up to 16 PNG, JPEG, WebP, or GIF images, each at most 10 MiB and 14 MiB together.\n - drex-max, drex-v2.0 and drex-v1.5 run Nace.AI's Drex, served by DeepInfra, and take at most 16 questions. drex-max reads up to 262k tokens and up to 4 PNG, JPEG, WebP, or GIF images, 9 MiB together. drex-v2.0 and drex-v1.5 read text only, up to 128k tokens. nace-ai/drex-max, nace-ai/drex-v2.0 and nace-ai/drex-v1.5 name the same three.\n - gpt-6-luna-decisions runs OpenAI's Decisions API (in beta), which reads up to 922k tokens and PNG, JPEG, WebP, or GIF images of up to 20 MB each. It takes up to 200 questions, and a choice needs at least 2 options. gpt-6-luna names it too.\n- images is for a model that reads them. Pass URLs or data URLs. A model that reads none refuses the call.\n- The response model field is the version that answered.\n- Billed per input token. Output tokens are free. Each model has its own rate, and GPT-6 Luna Decisions bills a prompt over 272k tokens at twice its rate.",
5159
- inputSchema: { "type": "object", "properties": { "state": { "anyOf": [{ "type": "string" }, { "type": "object", "properties": {}, "required": [] }, { "type": "array", "items": {} }] }, "questions": { "type": "object", "properties": {}, "required": [], "description": "Questions to ask about the state, keyed by an id you choose." }, "images": { "type": "array", "items": { "type": "string" }, "description": "Images for a model that reads them (Clef, Clef Flash, GPT-6 Luna Decisions). Each entry is a URL or a data URL. A model that reads none refuses the call." }, "decisionModelOverride": { "type": "object", "properties": { "model": { "type": "string", "description": "Decision model: a catalog id, its vendor's name for it (`@cf/cloudflare/clef`, `gpt-6-luna`), or a version it pins (`jev-1.13.0`)" }, "config": { "type": "object", "properties": {}, "required": [], "description": "Additional model-specific configuration" } }, "required": ["model"], "description": "Optional model override. Uses the workspace's default decision model (Jev) if not specified" } }, "required": ["state", "questions"] },
5268
+ usageNotes: "- state is the content to judge: a string, or a JSON object or array (a record, a chat log, application state).\n- questions is a map. The key is an id you choose. It is not shown to the model. The answer comes back under the same id.\n- A noul asks a yes/no question and returns noul, a probability from 0 (no) to 1 (yes). Optional criteria.true and criteria.false say what a yes and a no mean.\n- A choice picks one option. criteria is a map of option id to a short description (or null). At most 255 options. The answer includes the winning choice, a probability for every option, and confidence.\n- A score rates the state on an ordered rubric. criteria is 2 to 10 level descriptions, low to high. The answer's score can land between levels, and includes a probability per level plus confidence.\n- An answer of type refusal means the model declined that question (GPT-6 Luna Decisions can).\n- instructions may be a string, or an object that keeps the question in one field and reference data in the others. Refer to those fields by name in backticks.\n- Send every question you need in one call. The model reads the state once and answers them together.\n- Probabilities from different models are not comparable: tune a threshold against the model, and the version, it will run on.\n- decisionModelOverride.model picks the model:\n - jev-latest (the default) is TypeSafe's current stable release, text only, up to 64k tokens. jev-preview tracks TypeSafe's newest release. Pin a version such as jev-1.13.0 when a threshold was tuned against that version.\n - clef and clef-flash run Cloudflare Clef, which also reads up to 4 PNG, JPEG, or WebP images, each at most 4 MiB and 8 MiB together, and takes at most 64 questions, each id using only letters, digits, underscore, dot, and hyphen, up to 100 characters. clef is the larger model, clef-flash the faster one. @cf/cloudflare/clef and @cf/cloudflare/clef-flash name the same two.\n - mercury-decide runs Inception's Mercury Decide, which reads up to 64k tokens and up to 16 PNG, JPEG, WebP, or GIF images, each at most 10 MiB and 14 MiB together.\n - drex-max, drex-v2.0 and drex-v1.5 run Nace.AI's Drex, served by DeepInfra, and take at most 16 questions. drex-max reads up to 262k tokens and up to 4 PNG, JPEG, WebP, or GIF images, 9 MiB together. drex-v2.0 and drex-v1.5 read text only, up to 128k tokens. nace-ai/drex-max, nace-ai/drex-v2.0 and nace-ai/drex-v1.5 name the same three.\n - gpt-6-luna-decisions runs OpenAI's Decisions API (in beta), which reads up to 922k tokens and PNG, JPEG, WebP, or GIF images of up to 20 MB each. It takes up to 200 questions, and a choice needs at least 2 options. gpt-6-luna names it too.\n - gemini-decision-1 runs Google's Gemini Decision 1, which reads up to 262k tokens and PNG, JPEG, WebP, or GIF images, up to 100 MB of image data in one request. It takes 1 to 1,000 questions. A question id uses only letters, digits, underscore, and hyphen, up to 64 characters, and a choice needs 2 to 255 options. A yes/no probability is between 0.01 and 0.99.\n- images is for a model that reads them. Pass URLs or data URLs. A model that reads none refuses the call.\n- The response model field is the version that answered.\n- Billed per input token. Output tokens are free. Each model has its own rate, and GPT-6 Luna Decisions bills a prompt over 272k tokens at twice its rate.",
5269
+ inputSchema: { "type": "object", "properties": { "state": { "anyOf": [{ "type": "string" }, { "type": "object", "properties": {}, "required": [] }, { "type": "array", "items": {} }] }, "questions": { "type": "object", "properties": {}, "required": [], "description": "Questions to ask about the state, keyed by an id you choose." }, "images": { "type": "array", "items": { "type": "string" }, "description": "Images for a model that reads them (Clef, Clef Flash, GPT-6 Luna Decisions, Gemini Decision 1). Each entry is a URL or a data URL. A model that reads none refuses the call." }, "decisionModelOverride": { "type": "object", "properties": { "model": { "type": "string", "description": "Decision model: a catalog id, its vendor's name for it (`@cf/cloudflare/clef`, `gpt-6-luna`), or a version it pins (`jev-1.13.0`)" }, "config": { "type": "object", "properties": {}, "required": [], "description": "Additional model-specific configuration" } }, "required": ["model"], "description": "Optional model override. Uses the workspace's default decision model (Jev) if not specified" } }, "required": ["state", "questions"] },
5160
5270
  outputSchema: { "type": "object", "properties": { "model": { "type": "string", "description": "Versioned model id that answered, such as jev-1.13.0." }, "answers": { "type": "object", "properties": {}, "required": [], "description": "One answer per question, under the same ids." }, "usage": { "type": "object", "properties": { "input_tokens": { "type": "number" }, "output_tokens": { "type": "number" } }, "required": ["input_tokens", "output_tokens"], "description": "Token counts for the call. Input tokens are what the model bills." } }, "required": ["model", "answers", "usage"] }
5161
5271
  },
5162
5272
  "extractAudioFromVideo": {
@@ -5169,7 +5279,7 @@ var stepMetadata = {
5169
5279
  "extractText": {
5170
5280
  stepType: "extractText",
5171
5281
  description: "Download a file from a URL and extract its text content. Supports PDFs (including scanned/image-based PDFs via OCR), plain text files, and other document formats.",
5172
- usageNotes: "- Best suited for PDFs and raw text/document files. For web pages, use the scrapeUrl step instead.\n- Handles both text-layer PDFs and image-based/scanned PDFs (e.g. Figma/Canva exports, scanned documents). Image-based PDFs are processed with OCR automatically \u2014 there is no need to convert PDF pages to images first.\n- Plain text, code, HTML, spreadsheets and Office documents (docx, pptx, odt, rtf, epub) are read without a model and cost nothing. PDFs and images go to the extraction model, billed per page.\n- Accepts a single URL, a comma-separated list of URLs, or a JSON array of URLs.\n- Nothing is published. One of the app's own files \u2014 including a private one, or a share link \u2014 is read where it sits; any other URL is downloaded and staged privately for the extraction model, then discarded when extraction finishes.\n- `text` is each document's text: a string for one URL, an array for several. `documents` has each document page by page, with its page numbers and the pages billed. Set `includeBlocks` to add each page's typed blocks (title, text, table, image, header, footer\u2026) with their bounding boxes, and the page's size.\n- A file that can't be read (unreachable, an unsupported type, past the model's limits, or refused by the model) fails the step with the reason.\n- `extractionModelOverride.model` picks the model; omit it to use the workspace's default:\n - `mistral-ocr-4.1` (the default): PDFs and images up to 50 MB and 1,000 pages, with typed blocks.\n - `mistral-document-ai-2512`: Mistral Document AI on Microsoft Foundry, up to 30 MB and 30 pages, with typed blocks.\n - `llamaparse`: LlamaParse's agentic mode, up to 100 MB and 1,000 pages, markdown without blocks.\n - `google-document-ai`: Google Document AI OCR, up to 500 pages, where the deployment has set it up.\n- Maximum file size is 50MB per URL.",
5282
+ usageNotes: "- Best suited for PDFs and raw text/document files. For web pages, use the scrapeUrl step instead.\n- Handles both text-layer PDFs and image-based/scanned PDFs (e.g. Figma/Canva exports, scanned documents). Image-based PDFs are processed with OCR automatically \u2014 there is no need to convert PDF pages to images first.\n- Plain text, code, HTML, spreadsheets and Office documents (docx, pptx, odt, rtf, epub) are read without a model and cost nothing. PDFs and images go to the extraction model, billed per page.\n- Accepts a single URL, a comma-separated list of URLs, or a JSON array of URLs.\n- Nothing is published. One of the app's own files \u2014 including a private one, or a share link \u2014 is read where it sits; any other URL is downloaded and staged privately for the extraction model, then discarded when extraction finishes.\n- `text` is each document's text: a string for one URL, an array for several. `documents` has each document page by page, with its page numbers and the pages billed. Set `includeBlocks` to add each page's typed blocks (title, text, table, image, header, footer\u2026) with their bounding boxes, and the page's size.\n- A file that can't be read (unreachable, an unsupported type, past the model's limits, or refused by the model) fails the step with the reason.\n- `extractionModelOverride.model` picks the model; omit it to use the workspace's default:\n - `mistral-ocr-4.1` (the default): PDFs and images up to 50 MB and 1,000 pages, with typed blocks.\n - `mistral-document-ai-2512`: Mistral Document AI on Microsoft Foundry, up to 30 MB and 30 pages, with typed blocks.\n - `llamaparse`: LlamaParse's agentic mode, up to 100 MB and 1,000 pages, markdown without blocks.\n - `google-document-ai`: Google Document AI OCR, up to 500 pages, where the deployment has set it up.\n- A URL that isn't one of the app's own files is downloaded first, and can be at most 50 MB. One of the app's own files is read where it sits: up to the model's limit when a model reads it (a PDF, an image), and up to 50 MB for a kind read without a model (text, HTML, spreadsheets and office documents).",
5173
5283
  inputSchema: { "type": "object", "properties": { "url": { "anyOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }] }, "extractionModelOverride": { "type": "object", "properties": { "model": { "type": "string", "description": "Document extraction model identifier" }, "config": { "type": "object", "properties": {}, "required": [], "description": "Additional model-specific configuration" } }, "required": ["model"], "description": "Optional model override. Uses the workspace's default document extraction model if not specified" }, "model": { "type": "string", "description": "Optional extraction model id." }, "includeBlocks": { "type": "boolean", "description": "Add each page's typed blocks, with their bounding boxes, and the page's size to `documents`. Off by default, since they're several times the size of the text." } }, "required": ["url"] },
5174
5284
  outputSchema: { "type": "object", "properties": { "text": { "anyOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }] }, "documents": { "type": "array", "items": { "type": "object", "properties": { "url": { "type": "string", "description": "The URL the document was read from." }, "text": { "type": "string", "description": "The whole document's text." }, "pages": { "type": "array", "items": { "type": "object", "properties": { "pageNumber": { "type": "number", "description": "1-based." }, "markdown": { "type": "string", "description": "The page's text, as markdown." }, "blocks": { "type": "array", "items": { "type": "string" }, "description": "The page's typed regions (title, text, table, image, header, footer\u2026), each with its bounding box, when `includeBlocks` was set and the model returns them." }, "dimensions": { "type": "object", "properties": { "width": { "type": "number" }, "height": { "type": "number" }, "dpi": { "type": "number" } }, "required": ["width", "height"], "description": "The page's size in pixels, the space `blocks`' bounding boxes are in." } }, "required": ["pageNumber", "markdown"], "description": "One page of an extracted document." }, "description": "Its pages, in order. A format read without a model is one page." }, "pagesProcessed": { "type": "number", "description": "The pages the model read and billed, 0 for a format read without one." } }, "required": ["url", "text", "pages", "pagesProcessed"] }, "description": "Each URL's document, in the order given, page by page." } }, "required": ["text", "documents"] }
5175
5285
  },
@@ -5945,7 +6055,7 @@ var stepMetadata = {
5945
6055
  stepType: "typesafeEvaluate",
5946
6056
  description: "Use evaluateDecision: the same questions, answers and models, with decisionModelOverride in place of model. evaluateDecision's earlier name, which still runs: ask structured questions about text, JSON, or images and get calibrated answers from a decision model.",
5947
6057
  usageNotes: "- Runs exactly as evaluateDecision does, with the same questions, answers, models and limits (see its notes), and model in place of decisionModelOverride.model.",
5948
- inputSchema: { "type": "object", "properties": { "state": { "anyOf": [{ "type": "string" }, { "type": "object", "properties": {}, "required": [] }, { "type": "array", "items": {} }] }, "questions": { "type": "object", "properties": {}, "required": [], "description": "Questions to ask about the state, keyed by an id you choose." }, "model": { "type": "string", "description": "Model id or alias. Defaults to the workspace's default decision model (jev-latest). Every model evaluateDecision takes: jev-preview, a pinned version such as jev-1.13.0, clef and clef-flash, gpt-6-luna-decisions." }, "images": { "type": "array", "items": { "type": "string" }, "description": "Images for a model that reads them (Clef, Clef Flash, GPT-6 Luna Decisions). Each entry is a URL or a data URL. A model that reads none refuses the call." } }, "required": ["state", "questions"] },
6058
+ inputSchema: { "type": "object", "properties": { "state": { "anyOf": [{ "type": "string" }, { "type": "object", "properties": {}, "required": [] }, { "type": "array", "items": {} }] }, "questions": { "type": "object", "properties": {}, "required": [], "description": "Questions to ask about the state, keyed by an id you choose." }, "model": { "type": "string", "description": "Model id or alias. Defaults to the workspace's default decision model (jev-latest). Every model evaluateDecision takes: jev-preview, a pinned version such as jev-1.13.0, clef and clef-flash, gpt-6-luna-decisions, gemini-decision-1." }, "images": { "type": "array", "items": { "type": "string" }, "description": "Images for a model that reads them (Clef, Clef Flash, GPT-6 Luna Decisions, Gemini Decision 1). Each entry is a URL or a data URL. A model that reads none refuses the call." } }, "required": ["state", "questions"] },
5949
6059
  outputSchema: { "type": "object", "properties": { "model": { "type": "string", "description": "Versioned model id that answered, such as jev-1.13.0." }, "answers": { "type": "object", "properties": {}, "required": [], "description": "One answer per question, under the same ids." }, "usage": { "type": "object", "properties": { "input_tokens": { "type": "number" }, "output_tokens": { "type": "number" } }, "required": ["input_tokens", "output_tokens"], "description": "Token counts for the call. Input tokens are what the model bills." } }, "required": ["model", "answers", "usage"] }
5950
6060
  },
5951
6061
  "updateGmailLabels": {
@@ -9544,7 +9654,6 @@ function defineJewel(method, config) {
9544
9654
  }
9545
9655
 
9546
9656
  // src/mapper/index.ts
9547
- import { gzipSync } from "node:zlib";
9548
9657
  function documents(list) {
9549
9658
  return {
9550
9659
  kind: "documents",
@@ -9575,8 +9684,6 @@ function deletes(externalIds) {
9575
9684
  }
9576
9685
  var DEFAULT_TIMEOUT_MS = 3e4;
9577
9686
  var DEFAULT_CONCURRENCY2 = 4;
9578
- var PART_DOCUMENTS = 1e3;
9579
- var PART_BYTES = 8 * 1024 * 1024;
9580
9687
  function errorInfo2(e) {
9581
9688
  if (e instanceof Error) {
9582
9689
  return { message: e.message, stack: e.stack };
@@ -9687,27 +9794,7 @@ var PartWriter = class {
9687
9794
  async store(lines, objects) {
9688
9795
  try {
9689
9796
  const grant = await this.source._mapSpillGrant(this.spillId);
9690
- const form = new FormData();
9691
- for (const [k, v] of Object.entries(grant.uploadFields)) {
9692
- form.append(k, v);
9693
- }
9694
- form.append(
9695
- "file",
9696
- new Blob(
9697
- [new Uint8Array(gzipSync(Buffer.from(lines.join("\n") + "\n")))],
9698
- { type: "application/gzip" }
9699
- ),
9700
- `${grant.part}.ndjson.gz`
9701
- );
9702
- const response = await fetch(grant.uploadUrl, {
9703
- method: "POST",
9704
- body: form
9705
- });
9706
- if (!response.ok) {
9707
- throw new Error(
9708
- `Could not store part ${grant.part} of the documents: HTTP ${response.status}`
9709
- );
9710
- }
9797
+ await storePart(grant, lines);
9711
9798
  this.parts.push({ part: grant.part, count: lines.length });
9712
9799
  } catch (e) {
9713
9800
  const err = e instanceof Error ? e : new Error(String(e));