@mindstudio-ai/agent 0.1.183 → 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/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ What changed in `@mindstudio-ai/agent`, newest first, each version under its own
4
4
 
5
5
  Versions before 0.1.163 aren't recorded here.
6
6
 
7
+ ## 0.1.184
8
+
9
+ ### New
10
+
11
+ - A data source's `addMany(documents, { budgetDollars? })` adds many records at once: rows of the app's own tables rendered to text, as an array or any iterable or async iterable of `{ externalId, title, markdown, metadata?, entities?, replaces? }`, in any number. One job builds them, priced before it runs and starting on its own within the budget, and the call returns `{ documentCount, job }`. An `externalId` the source already holds is superseded when the job finishes, and unchanged markdown builds nothing. It throws `data_source_busy` while another job runs on the source and `data_source_mapped` on a source with a mapper. Check: code that loads many records by calling `add()` in a loop can give them to `addMany()` in one call.
12
+
13
+ ### Changed behavior
14
+
15
+ - The platform limits `add()` to 300 calls a minute per app and answers `rate_limited` (429) past it. Check: a method that adds documents in a loop, or in a `Promise.all` larger than that, should give them to `addMany()`.
16
+ - A source has no limit on how many documents it holds beyond the room where it lives. `add()` doesn't throw `document_limit_reached`; it throws `data_source_full` (422) when the source has no room, and the message says how to give it more. Check: code that catches `document_limit_reached` can catch `data_source_full` instead, or drop the catch.
17
+ - Types only: a job's `source` may be `{ type: 'documents', documents }`, the documents an `addMany()` gave. Check: code that switches over a job's `source.type`.
18
+
7
19
  ## 0.1.183
8
20
 
9
21
  ### Changed behavior
package/dist/cli.js CHANGED
@@ -306,8 +306,8 @@ var init_metadata = __esm({
306
306
  "evaluateDecision": {
307
307
  stepType: "evaluateDecision",
308
308
  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).",
309
- 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.",
310
- 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"] },
309
+ 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.",
310
+ 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"] },
311
311
  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"] }
312
312
  },
313
313
  "extractAudioFromVideo": {
@@ -1096,7 +1096,7 @@ var init_metadata = __esm({
1096
1096
  stepType: "typesafeEvaluate",
1097
1097
  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.",
1098
1098
  usageNotes: "- Runs exactly as evaluateDecision does, with the same questions, answers, models and limits (see its notes), and model in place of decisionModelOverride.model.",
1099
- 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"] },
1099
+ 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"] },
1100
1100
  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"] }
1101
1101
  },
1102
1102
  "updateGmailLabels": {
@@ -5108,12 +5108,46 @@ var init_files = __esm({
5108
5108
  }
5109
5109
  });
5110
5110
 
5111
+ // src/datasources/parts.ts
5112
+ import { gzipSync } from "node:zlib";
5113
+ async function storePart(grant, lines) {
5114
+ const form = new FormData();
5115
+ for (const [k, v] of Object.entries(grant.uploadFields)) {
5116
+ form.append(k, v);
5117
+ }
5118
+ form.append(
5119
+ "file",
5120
+ new Blob([new Uint8Array(gzipSync(Buffer.from(lines.join("\n") + "\n")))], {
5121
+ type: "application/gzip"
5122
+ }),
5123
+ `${grant.part}.ndjson.gz`
5124
+ );
5125
+ const response = await fetch(grant.uploadUrl, {
5126
+ method: "POST",
5127
+ body: form
5128
+ });
5129
+ if (!response.ok) {
5130
+ throw new Error(
5131
+ `Could not store part ${grant.part} of the documents: HTTP ${response.status}`
5132
+ );
5133
+ }
5134
+ }
5135
+ var PART_DOCUMENTS, PART_BYTES;
5136
+ var init_parts = __esm({
5137
+ "src/datasources/parts.ts"() {
5138
+ "use strict";
5139
+ PART_DOCUMENTS = 1e3;
5140
+ PART_BYTES = 8 * 1024 * 1024;
5141
+ }
5142
+ });
5143
+
5111
5144
  // src/datasources/source.ts
5112
5145
  import { createHash as createHash2 } from "node:crypto";
5113
5146
  var DICTIONARY_PAGE_ENTRIES, DICTIONARY_PAGE_BYTES, REMOVE_WHERE_MAX_PAGES, DataSource;
5114
5147
  var init_source = __esm({
5115
5148
  "src/datasources/source.ts"() {
5116
5149
  "use strict";
5150
+ init_parts();
5117
5151
  DICTIONARY_PAGE_ENTRIES = 1e4;
5118
5152
  DICTIONARY_PAGE_BYTES = 4e6;
5119
5153
  REMOVE_WHERE_MAX_PAGES = 100;
@@ -5415,6 +5449,87 @@ var init_source = __esm({
5415
5449
  body: bytes.toString("base64")
5416
5450
  });
5417
5451
  }
5452
+ /**
5453
+ * Add many documents at once, built as one job.
5454
+ *
5455
+ * For records your app renders to text: a row of its own table as a short
5456
+ * markdown card, in any number. Each is what a mapper's `documents()`
5457
+ * returns (an `externalId`, a `title`, `markdown`, and optionally
5458
+ * `metadata`, `entities` and `replaces`), given as an array or any iterable
5459
+ * or async iterable, so a generator that yields a document per row never
5460
+ * holds them all. {@link add} is for a file.
5461
+ *
5462
+ * ```ts
5463
+ * const { job } = await Claims.addMany(
5464
+ * claims.map((claim) => ({
5465
+ * externalId: claim.id,
5466
+ * title: claim.title,
5467
+ * markdown: renderCard(claim),
5468
+ * metadata: { firmId: claim.firmId, status: claim.status },
5469
+ * })),
5470
+ * );
5471
+ * ```
5472
+ *
5473
+ * The documents are stored a thousand at a time and one job registers and
5474
+ * builds them, planned and priced like any other; it starts on its own
5475
+ * within `budgetDollars`, or within its plan's projection with headroom when
5476
+ * none is given. The call returns once the job has started: follow it with
5477
+ * {@link job}, and a search sees what has been built throughout.
5478
+ *
5479
+ * The external id is a document's identity. Giving one the source already
5480
+ * holds supersedes that document once the job's documents are all
5481
+ * searchable; unchanged markdown builds nothing, and new metadata or
5482
+ * entities on unchanged markdown update in place. A document that fails
5483
+ * validation is left out and counted on the job; the rest go in. Nothing is
5484
+ * removed for being left out of a later call: use {@link remove} or
5485
+ * {@link removeWhere}.
5486
+ *
5487
+ * @throws `data_source_mapped` on a source with a mapper, which is what
5488
+ * makes that source's documents; `data_source_busy` while another job or
5489
+ * a move is in flight, since a source runs one job at a time.
5490
+ */
5491
+ async addMany(documents, options) {
5492
+ const { uploadId } = await this._call("add-many/open", {
5493
+ slug: this._slug
5494
+ });
5495
+ const parts = [];
5496
+ let lines = [];
5497
+ let bytes = 0;
5498
+ let documentCount = 0;
5499
+ const storeLines = async () => {
5500
+ if (lines.length === 0) {
5501
+ return;
5502
+ }
5503
+ const grant = await this._call("add-many/part", {
5504
+ slug: this._slug,
5505
+ uploadId
5506
+ });
5507
+ await storePart(grant, lines);
5508
+ parts.push({ part: grant.part, count: lines.length });
5509
+ lines = [];
5510
+ bytes = 0;
5511
+ };
5512
+ for await (const d of documents) {
5513
+ const line = JSON.stringify({ o: 0, i: documentCount, d });
5514
+ lines.push(line);
5515
+ bytes += line.length;
5516
+ documentCount += 1;
5517
+ if (lines.length >= PART_DOCUMENTS || bytes >= PART_BYTES) {
5518
+ await storeLines();
5519
+ }
5520
+ }
5521
+ await storeLines();
5522
+ if (parts.length === 0) {
5523
+ return { documentCount: 0, job: null };
5524
+ }
5525
+ const { job } = await this._call("add-many/start", {
5526
+ slug: this._slug,
5527
+ uploadId,
5528
+ parts,
5529
+ ...options?.budgetDollars !== void 0 ? { budgetDollars: options.budgetDollars } : {}
5530
+ });
5531
+ return { documentCount, job };
5532
+ }
5418
5533
  /**
5419
5534
  * Documents in the corpus, with ingest status.
5420
5535
  *
@@ -10143,7 +10258,7 @@ async function startMcpServer(options) {
10143
10258
  capabilities: { tools: {} },
10144
10259
  serverInfo: {
10145
10260
  name: "mindstudio-agent",
10146
- version: "0.1.183"
10261
+ version: "0.1.184"
10147
10262
  },
10148
10263
  instructions: 'Welcome to MindStudio \u2014 a platform with 200+ AI models, 850+ third-party integrations, and pre-built agents.\n\nGetting started:\n1. Call `ask` with any question about the SDK \u2014 it knows every action, model, and connector and returns working code with real model IDs and config options. Examples: ask("generate an image with FLUX"), ask("what models support vision?"), ask("how do I send a Slack message?").\n2. Call `changeName` to set your display name \u2014 use your name or whatever your user calls you. This is how you\'ll appear in MindStudio request logs.\n3. If you have a profile picture, pass its public image URL to `changeProfilePicture`.\n4. For manual browsing, call `listActions` to discover all available actions.\n\nThen use the tools to generate text, images, video, audio, search the web, work with data sources, run agents, and more.\n\nImportant:\n- AI-powered actions (text generation, image generation, video, audio, etc.) cost money. Before running these, call `estimateActionCost` and confirm with the user before proceeding \u2014 unless they\'ve explicitly told you to go ahead.\n- Not all agents from `listAgents` are configured for API use. Do not try to run an agent just because it appears in the list \u2014 it will likely fail. Only run agents the user specifically asks you to run.'
10149
10264
  });
@@ -11183,7 +11298,7 @@ function isNewerVersion(current, latest) {
11183
11298
  return false;
11184
11299
  }
11185
11300
  async function checkForUpdate() {
11186
- const currentVersion = "0.1.183";
11301
+ const currentVersion = "0.1.184";
11187
11302
  if (!currentVersion || process.env.MINDSTUDIO_NO_UPDATE_CHECK) {
11188
11303
  return null;
11189
11304
  }
@@ -11218,7 +11333,7 @@ async function checkForUpdate() {
11218
11333
  }
11219
11334
  }
11220
11335
  function printUpdateNotice(latestVersion) {
11221
- const currentVersion = "0.1.183";
11336
+ const currentVersion = "0.1.184";
11222
11337
  process.stderr.write(
11223
11338
  `
11224
11339
  ${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
@@ -11231,7 +11346,7 @@ function isStandaloneBinary() {
11231
11346
  return !argv1.includes("node_modules");
11232
11347
  }
11233
11348
  async function cmdUpdate() {
11234
- const currentVersion = "0.1.183";
11349
+ const currentVersion = "0.1.184";
11235
11350
  process.stderr.write(
11236
11351
  ` ${ansi2.gray("Current version:")} ${currentVersion}
11237
11352
  `
@@ -11372,7 +11487,7 @@ async function cmdLogin(options) {
11372
11487
  process.stderr.write("\n");
11373
11488
  printLogo();
11374
11489
  process.stderr.write("\n");
11375
- const ver = "0.1.183";
11490
+ const ver = "0.1.184";
11376
11491
  process.stderr.write(
11377
11492
  ` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
11378
11493
  `
@@ -11702,7 +11817,7 @@ async function main() {
11702
11817
  const updatePromise = command !== "mcp" && command !== "login" && command !== "update" ? checkForUpdate() : Promise.resolve(null);
11703
11818
  try {
11704
11819
  if (command === "version" || command === "-v") {
11705
- process.stdout.write("0.1.183\n");
11820
+ process.stdout.write("0.1.184\n");
11706
11821
  return;
11707
11822
  }
11708
11823
  if (command === "login") {
@@ -31,7 +31,7 @@
31
31
  */
32
32
  import { DataSource, type DataSourcesTransport } from './source.js';
33
33
  export { DataSource } from './source.js';
34
- export type { AddOptions, AddResult, BranchPosition, Citation, DataSourceChunk, DataSourceDocument, DataSourceJob, DataSourceJobPlan, DataSourceJobState, DataSourcePassage, DataSourcePassagePage, DataSourceStats, DictionaryEntry, DictionaryPushResult, DictionaryRelink, DictionaryReport, DocumentMetadata, DocumentSelector, MetadataRange, MetadataValue, SearchExplain, SearchFilter, SearchHit, SearchMode, SearchOptions, SearchRan, } from './source.js';
34
+ export type { AddManyResult, AddOptions, AddResult, BranchPosition, Citation, DataSourceChunk, DataSourceDocument, DataSourceJob, DataSourceJobPlan, DataSourceJobState, DataSourcePassage, DataSourcePassagePage, DataSourceStats, DictionaryEntry, DictionaryPushResult, DictionaryRelink, DictionaryReport, DocumentMetadata, DocumentSelector, MetadataRange, MetadataValue, SearchExplain, SearchFilter, SearchHit, SearchMode, SearchOptions, SearchRan, } from './source.js';
35
35
  /** The `dataSources` namespace object. */
36
36
  export interface DataSources {
37
37
  /**
@@ -0,0 +1,14 @@
1
+ /**
2
+ * A part: what the platform registers in one batch (its own `PART_DOCUMENTS`,
3
+ * the api's customerApps/AppDataSources/mapSpill.ts).
4
+ */
5
+ export declare const PART_DOCUMENTS = 1000;
6
+ export declare const PART_BYTES: number;
7
+ /** A grant to store the next part. */
8
+ export interface PartGrant {
9
+ part: number;
10
+ uploadUrl: string;
11
+ uploadFields: Record<string, string>;
12
+ }
13
+ /** Store one part's lines under its grant. Throws when storage refuses them. */
14
+ export declare function storePart(grant: PartGrant, lines: string[]): Promise<void>;
@@ -1,3 +1,4 @@
1
+ import type { MappedDocument } from '../mapper/index.js';
1
2
  /** @internal Transport: `POST /_internal/v2/datasources/<op>` with the hook token. */
2
3
  export type DataSourcesTransport = (op: string, body: unknown) => Promise<any>;
3
4
  /** Where a retrieved chunk came from — enough to show the user the source. */
@@ -385,6 +386,19 @@ export interface AddResult {
385
386
  */
386
387
  job: DataSourceJob | null;
387
388
  }
389
+ /** What {@link DataSource.addMany} returns. */
390
+ export interface AddManyResult {
391
+ /** How many documents were given. */
392
+ documentCount: number;
393
+ /**
394
+ * The job registering and building them; null only when none were given.
395
+ * It plans and starts on its own (within `budgetDollars`); follow it with
396
+ * {@link DataSource.job}. A document whose external id the source already
397
+ * holds is superseded when the job finishes, once every document of the
398
+ * call is searchable.
399
+ */
400
+ job: DataSourceJob | null;
401
+ }
388
402
  export interface DataSourceDocument {
389
403
  id: string;
390
404
  filename: string | null;
@@ -543,8 +557,9 @@ export interface DataSourceJobPlan {
543
557
  /**
544
558
  * A bulk ingestion job — a sync, a corpus load started from the CLI, a remap
545
559
  * of a mapped source's raw copies, a replay of an earlier job's quarantine, a
546
- * reread of the source's documents by its reader, or the rest of one large
547
- * object an {@link DataSource.add} took.
560
+ * reread of the source's documents by its reader, the rest of one large
561
+ * object an {@link DataSource.add} took, or the documents a
562
+ * {@link DataSource.addMany} gave.
548
563
  */
549
564
  export interface DataSourceJob {
550
565
  id: string;
@@ -576,6 +591,9 @@ export interface DataSourceJob {
576
591
  } | {
577
592
  type: 'object';
578
593
  ref: string;
594
+ } | {
595
+ type: 'documents';
596
+ documents: number;
579
597
  };
580
598
  /**
581
599
  * Objects the mapper skipped or failed on, and documents the reader failed
@@ -907,6 +925,49 @@ export declare class DataSource {
907
925
  * the source refuses it with `data_source_busy`.
908
926
  */
909
927
  add(content: Buffer | Uint8Array | string, options: AddOptions): Promise<AddResult>;
928
+ /**
929
+ * Add many documents at once, built as one job.
930
+ *
931
+ * For records your app renders to text: a row of its own table as a short
932
+ * markdown card, in any number. Each is what a mapper's `documents()`
933
+ * returns (an `externalId`, a `title`, `markdown`, and optionally
934
+ * `metadata`, `entities` and `replaces`), given as an array or any iterable
935
+ * or async iterable, so a generator that yields a document per row never
936
+ * holds them all. {@link add} is for a file.
937
+ *
938
+ * ```ts
939
+ * const { job } = await Claims.addMany(
940
+ * claims.map((claim) => ({
941
+ * externalId: claim.id,
942
+ * title: claim.title,
943
+ * markdown: renderCard(claim),
944
+ * metadata: { firmId: claim.firmId, status: claim.status },
945
+ * })),
946
+ * );
947
+ * ```
948
+ *
949
+ * The documents are stored a thousand at a time and one job registers and
950
+ * builds them, planned and priced like any other; it starts on its own
951
+ * within `budgetDollars`, or within its plan's projection with headroom when
952
+ * none is given. The call returns once the job has started: follow it with
953
+ * {@link job}, and a search sees what has been built throughout.
954
+ *
955
+ * The external id is a document's identity. Giving one the source already
956
+ * holds supersedes that document once the job's documents are all
957
+ * searchable; unchanged markdown builds nothing, and new metadata or
958
+ * entities on unchanged markdown update in place. A document that fails
959
+ * validation is left out and counted on the job; the rest go in. Nothing is
960
+ * removed for being left out of a later call: use {@link remove} or
961
+ * {@link removeWhere}.
962
+ *
963
+ * @throws `data_source_mapped` on a source with a mapper, which is what
964
+ * makes that source's documents; `data_source_busy` while another job or
965
+ * a move is in flight, since a source runs one job at a time.
966
+ */
967
+ addMany(documents: Iterable<MappedDocument> | AsyncIterable<MappedDocument>, options?: {
968
+ /** The job's ceiling, in dollars: it pauses there, and a plan projected over it waits for an approval. */
969
+ budgetDollars?: number;
970
+ }): Promise<AddManyResult>;
910
971
  /**
911
972
  * Documents in the corpus, with ingest status.
912
973
  *
@@ -644,6 +644,7 @@ export interface StepMethods {
644
644
  * - 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.
645
645
  * - 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.
646
646
  * - 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.
647
+ * - 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.
647
648
  * - images is for a model that reads them. Pass URLs or data URLs. A model that reads none refuses the call.
648
649
  * - The response model field is the version that answered.
649
650
  * - 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.
@@ -755,7 +755,7 @@ export interface EvaluateDecisionStepInput {
755
755
  /** Ordered level descriptions, from low to high. At least 2, at most 10. */
756
756
  criteria: string[];
757
757
  }>;
758
- /** 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. */
758
+ /** 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. */
759
759
  images?: string[];
760
760
  /** Optional model override. Uses the workspace's default decision model (Jev) if not specified */
761
761
  decisionModelOverride?: {
@@ -3793,9 +3793,9 @@ export interface TypesafeEvaluateStepInput {
3793
3793
  /** Ordered level descriptions, from low to high. At least 2, at most 10. */
3794
3794
  criteria: string[];
3795
3795
  }>;
3796
- /** 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. */
3796
+ /** 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. */
3797
3797
  model?: string;
3798
- /** 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. */
3798
+ /** 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. */
3799
3799
  images?: string[];
3800
3800
  }
3801
3801
  export interface TypesafeEvaluateStepOutput {
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": {
@@ -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));