@mindstudio-ai/agent 0.1.137 → 0.1.138

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/cli.js CHANGED
@@ -5191,7 +5191,7 @@ function logTaskResult(result) {
5191
5191
  }
5192
5192
  const toolSummary = result.toolCalls.map((tc) => `${tc.name} (${tc.durationMs}ms) ${tc.success ? "\u2713" : "\u2717"}`).join(", ");
5193
5193
  console.log(
5194
- `[task] ${result.turns} turn${result.turns === 1 ? "" : "s"}` + (toolSummary ? `: ${toolSummary}` : "") + ` | ${result.parsedSuccessfully ? "output OK" : "\u26A0 output not valid JSON"} | cost: ${result.usage.totalBillingCost}`
5194
+ `[task] ${result.turns} turn${result.turns === 1 ? "" : "s"}` + (toolSummary ? `: ${toolSummary}` : "") + ` | ${result.parsedSuccessfully ? "output OK" : "\u26A0 output not valid JSON"} | cost: ${result.usage.totalBillingCost} | trace: ${result.traceId}`
5195
5195
  );
5196
5196
  }
5197
5197
  async function runTaskPoll(httpConfig, body) {
@@ -5686,7 +5686,8 @@ ${structuredOutputExample}
5686
5686
  errors,
5687
5687
  turns: loopCount,
5688
5688
  usage: totalUsage,
5689
- toolCalls: toolCallLog
5689
+ toolCalls: toolCallLog,
5690
+ traceId
5690
5691
  }
5691
5692
  );
5692
5693
  };
@@ -5700,7 +5701,12 @@ ${structuredOutputExample}
5700
5701
  `[task] ${err.message}`,
5701
5702
  "task_execution_error",
5702
5703
  500,
5703
- { turns: loopCount, usage: totalUsage, toolCalls: toolCallLog }
5704
+ {
5705
+ turns: loopCount,
5706
+ usage: totalUsage,
5707
+ toolCalls: toolCallLog,
5708
+ traceId
5709
+ }
5704
5710
  );
5705
5711
  }
5706
5712
  return finish(buildResult(null, "", false, loopCount));
@@ -5709,7 +5715,8 @@ ${structuredOutputExample}
5709
5715
  throw new MindStudioError(
5710
5716
  `[task] ${err.message}`,
5711
5717
  err.errorCode ?? "task_turn_error",
5712
- err.status ?? 500
5718
+ err.status ?? 500,
5719
+ { traceId }
5713
5720
  );
5714
5721
  }
5715
5722
  throw err;
@@ -5773,9 +5780,13 @@ ${structuredOutputExample}
5773
5780
  isError: true
5774
5781
  };
5775
5782
  }
5783
+ } else if (kind === "method") {
5784
+ result = await deps.executeMethodTool(toolCall.name, mergedInput, {
5785
+ traceId,
5786
+ toolCallId: toolCall.id
5787
+ });
5776
5788
  } else {
5777
- const execute = kind === "method" ? deps.executeMethodTool : deps.executeStepTool;
5778
- result = await execute(toolCall.name, mergedInput);
5789
+ result = await deps.executeStepTool(toolCall.name, mergedInput);
5779
5790
  }
5780
5791
  toolCallLog.push({
5781
5792
  name: toolCall.name,
@@ -7086,7 +7097,7 @@ var init_client = __esm({
7086
7097
  };
7087
7098
  }
7088
7099
  },
7089
- executeMethodTool: async (methodId, input) => {
7100
+ executeMethodTool: async (methodId, input, call) => {
7090
7101
  try {
7091
7102
  const { data } = await request(
7092
7103
  { ...httpConfig, maxRetries: 0 },
@@ -7094,7 +7105,9 @@ var init_client = __esm({
7094
7105
  "/task/invoke-method",
7095
7106
  {
7096
7107
  methodId,
7097
- input
7108
+ input,
7109
+ traceId: call.traceId,
7110
+ toolCallId: call.toolCallId
7098
7111
  }
7099
7112
  );
7100
7113
  if (data.error) {
@@ -8627,7 +8640,7 @@ function buildReferenceDocs(data) {
8627
8640
 
8628
8641
  User-typed columns: The \`User\` type is just \`string\` at runtime. Write plain UUIDs to user-typed columns \u2014 do NOT add a \`@@user@@\` prefix manually and do NOT use \`as any\`. The SDK adds and strips the prefix automatically on read/write. If TypeScript complains about assigning a plain string to a \`User\` field, use \`db.userRef(id)\` to type-cast cleanly. Reads always return bare UUIDs; use \`resolveUser(id)\` when you need display info (name, email, avatar). Never do your own prefix handling \u2014 it will fight the SDK and cause double-prefixing or orphan refs. The \`@@user@@\` prefix is only visible in storage if you bypass the SDK with raw SQL; app code should never see or produce it.
8629
8642
 
8630
- Task agents: For multi-step tasks requiring autonomous tool use, use \`runTask()\`. Provide a prompt, input, a set of tools, an output contract, and a model. The SDK runs a tool-use loop and returns structured output. Prefer \`outputSchema\` for the output contract: plain JSON Schema (\`type\`/\`properties\`/\`required\`/\`enum\`/\`items\`; nullable via type arrays like \`["string","null"]\` \u2014 never \`nullable: true\`, never \`oneOf\`/\`$ref\`). Output is validated every turn with automatic repair and \`result.output\` is typed by inference from the schema \u2014 no generic argument and no \`parsedSuccessfully\` check needed; the call throws \`MindStudioError\` code \`task_output_schema_mismatch\` instead of ever returning nonconforming output. The legacy \`structuredOutputExample\` option (example object the model imitates) still works but is unvalidated \u2014 always check \`result.parsedSuccessfully\` before using its output. \`result.traceId\` is a stable id for the task's model transcript \u2014 inside a jewel, attach it to the propose/grade return (\`trace: task.traceId\`) to preserve the transcript with the pair. Tools can include any SDK action \u2014 e.g. \`['searchGoogle', 'fetchUrl', { method: 'generateImage', defaults: { imageModelOverride: { model: 'seedream-4.5' } } }]\` \u2014 plus the app's own methods (\`{ appMethod: 'save-vendor', description: 'when to use it' }\`, run as the user who invoked the method that started the task) and inline functions (\`{ name, description, inputSchema, execute }\` \u2014 the function runs in the calling process; thrown errors go back to the model as tool output; no \`defaults\`). Supports SSE streaming via \`onEvent\` callback.
8643
+ Task agents: For multi-step tasks requiring autonomous tool use, use \`runTask()\`. Provide a prompt, input, a set of tools, an output contract, and a model. The SDK runs a tool-use loop and returns structured output. Prefer \`outputSchema\` for the output contract: plain JSON Schema (\`type\`/\`properties\`/\`required\`/\`enum\`/\`items\`; nullable via type arrays like \`["string","null"]\` \u2014 never \`nullable: true\`, never \`oneOf\`/\`$ref\`). Output is validated every turn with automatic repair and \`result.output\` is typed by inference from the schema \u2014 no generic argument and no \`parsedSuccessfully\` check needed; the call throws \`MindStudioError\` code \`task_output_schema_mismatch\` instead of ever returning nonconforming output. The legacy \`structuredOutputExample\` option (example object the model imitates) still works but is unvalidated \u2014 always check \`result.parsedSuccessfully\` before using its output. \`result.traceId\` is a stable id for the task's model transcript, which the platform records for every task (\`remy-admin tasks get <traceId>\` reads it back) \u2014 inside a jewel, also attach it to the propose/grade return (\`trace: task.traceId\`) to preserve the transcript with the pair. Tools can include any SDK action \u2014 e.g. \`['searchGoogle', 'fetchUrl', { method: 'generateImage', defaults: { imageModelOverride: { model: 'seedream-4.5' } } }]\` \u2014 plus the app's own methods (\`{ appMethod: 'save-vendor', description: 'when to use it' }\`, run as the user who invoked the method that started the task) and inline functions (\`{ name, description, inputSchema, execute }\` \u2014 the function runs in the calling process; thrown errors go back to the model as tool output; no \`defaults\`). \`onEvent\` receives each turn's events (text, thinking, tool calls and results) as the turn completes.
8631
8644
 
8632
8645
  Uploading files / getting a hosted URL: For app file storage (user uploads, generated documents, images, marketing assets), use the \`files\` store \u2014 define a store at module scope and call \`await SomeStore.put(bytes, { contentType?, filename? })\` \u2192 returns \`{ url }\` served on the app's own domain (private by default; use a public store for world-readable assets). \`bytes\` is a \`Buffer\`/\`Uint8Array\`, so read/fetch the content first. The older \`mindstudio.uploadFile(...)\` (and the \`mindstudio upload <filepath>\` CLI) upload to the shared account media CDN and are DEPRECATED for app storage \u2014 they remain only for account-level one-off assets (e.g. an agent avatar for \`changeProfilePicture\`). Actions that generate a file (generateImage, generateVideo, generateSpeech, generatePdf, upscaleImage, \u2026) can write their output directly into a store: pass the store handle as \`store\` in the options object, e.g. \`await mindstudio.generateImage({ prompt }, { store: Assets })\`. It's optional \u2014 omit it and the asset goes to the shared CDN as before. More generally: some SDK capabilities are exposed as \`mindstudio\` CLI commands (list-actions, run-agent, exec, batch, \u2026), not only as code \u2014 reach for the CLI for one-off operations instead of writing and running code.
8633
8646
 
@@ -9234,7 +9247,7 @@ async function startMcpServer(options) {
9234
9247
  capabilities: { tools: {} },
9235
9248
  serverInfo: {
9236
9249
  name: "mindstudio-agent",
9237
- version: "0.1.137"
9250
+ version: "0.1.138"
9238
9251
  },
9239
9252
  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.'
9240
9253
  });
@@ -10246,7 +10259,7 @@ function isNewerVersion(current, latest) {
10246
10259
  return false;
10247
10260
  }
10248
10261
  async function checkForUpdate() {
10249
- const currentVersion = "0.1.137";
10262
+ const currentVersion = "0.1.138";
10250
10263
  if (!currentVersion || process.env.MINDSTUDIO_NO_UPDATE_CHECK) {
10251
10264
  return null;
10252
10265
  }
@@ -10281,7 +10294,7 @@ async function checkForUpdate() {
10281
10294
  }
10282
10295
  }
10283
10296
  function printUpdateNotice(latestVersion) {
10284
- const currentVersion = "0.1.137";
10297
+ const currentVersion = "0.1.138";
10285
10298
  process.stderr.write(
10286
10299
  `
10287
10300
  ${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
@@ -10294,7 +10307,7 @@ function isStandaloneBinary() {
10294
10307
  return !argv1.includes("node_modules");
10295
10308
  }
10296
10309
  async function cmdUpdate() {
10297
- const currentVersion = "0.1.137";
10310
+ const currentVersion = "0.1.138";
10298
10311
  process.stderr.write(
10299
10312
  ` ${ansi2.gray("Current version:")} ${currentVersion}
10300
10313
  `
@@ -10435,7 +10448,7 @@ async function cmdLogin(options) {
10435
10448
  process.stderr.write("\n");
10436
10449
  printLogo();
10437
10450
  process.stderr.write("\n");
10438
- const ver = "0.1.137";
10451
+ const ver = "0.1.138";
10439
10452
  process.stderr.write(
10440
10453
  ` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
10441
10454
  `
@@ -10763,7 +10776,7 @@ async function main() {
10763
10776
  const updatePromise = command !== "mcp" && command !== "login" && command !== "update" ? checkForUpdate() : Promise.resolve(null);
10764
10777
  try {
10765
10778
  if (command === "version" || command === "-v") {
10766
- process.stdout.write("0.1.137\n");
10779
+ process.stdout.write("0.1.138\n");
10767
10780
  return;
10768
10781
  }
10769
10782
  if (command === "login") {
package/dist/index.d.ts CHANGED
@@ -3880,9 +3880,10 @@ interface RunTaskOptionsBase {
3880
3880
  /** Thread ID for state persistence. */
3881
3881
  threadId?: string;
3882
3882
  /**
3883
- * SSE event callback. When provided, uses streaming mode instead of polling.
3884
- * Events include text chunks, tool call starts/results, thinking blocks,
3885
- * errors, and the final done event with the structured output.
3883
+ * Event callback: text chunks, thinking, tool call starts and results,
3884
+ * errors, and the final `done` event with the structured output. A turn's
3885
+ * events arrive together once the turn succeeds, so a retried attempt never
3886
+ * reaches it. It doesn't change how the task runs.
3886
3887
  */
3887
3888
  onEvent?: (event: TaskEvent) => void;
3888
3889
  }
@@ -3927,6 +3928,9 @@ interface TaskToolCall {
3927
3928
  interface TaskUsage {
3928
3929
  inputTokens: number;
3929
3930
  outputTokens: number;
3931
+ /** Prompt tokens written to and read from the model's prompt cache. */
3932
+ cacheCreationTokens?: number;
3933
+ cacheReadTokens?: number;
3930
3934
  /** Total cost in nanodollars (1/1,000,000,000th of a US dollar). */
3931
3935
  totalBillingCost: number;
3932
3936
  }
@@ -3945,11 +3949,12 @@ interface RunTaskResult<T = unknown> {
3945
3949
  /** Summary of every tool call made during execution. */
3946
3950
  toolCalls: TaskToolCall[];
3947
3951
  /**
3948
- * Stable id for this task's model transcript. Inside a jewel, attach it to
3949
- * the propose/grade return (`trace: task.traceId`) to preserve the full
3950
- * transcript with the pair — the training row and the audit trail. The
3951
- * platform records transcripts server-side per turn; only the id rides the
3952
- * result.
3952
+ * Stable id for this task's model transcript. The platform records every
3953
+ * task's transcript server-side per turn under it, for 90 days, and only
3954
+ * the id rides the result: `remy-admin tasks get <traceId>` reads it back.
3955
+ * Inside a jewel, also attach it to the propose/grade return
3956
+ * (`trace: task.traceId`) to preserve the full transcript with the pair —
3957
+ * the training row and the audit trail.
3953
3958
  */
3954
3959
  traceId: string;
3955
3960
  }
package/dist/index.js CHANGED
@@ -4989,7 +4989,7 @@ function logTaskResult(result) {
4989
4989
  }
4990
4990
  const toolSummary = result.toolCalls.map((tc) => `${tc.name} (${tc.durationMs}ms) ${tc.success ? "\u2713" : "\u2717"}`).join(", ");
4991
4991
  console.log(
4992
- `[task] ${result.turns} turn${result.turns === 1 ? "" : "s"}` + (toolSummary ? `: ${toolSummary}` : "") + ` | ${result.parsedSuccessfully ? "output OK" : "\u26A0 output not valid JSON"} | cost: ${result.usage.totalBillingCost}`
4992
+ `[task] ${result.turns} turn${result.turns === 1 ? "" : "s"}` + (toolSummary ? `: ${toolSummary}` : "") + ` | ${result.parsedSuccessfully ? "output OK" : "\u26A0 output not valid JSON"} | cost: ${result.usage.totalBillingCost} | trace: ${result.traceId}`
4993
4993
  );
4994
4994
  }
4995
4995
  async function runTaskPoll(httpConfig, body) {
@@ -5496,7 +5496,8 @@ ${structuredOutputExample}
5496
5496
  errors,
5497
5497
  turns: loopCount,
5498
5498
  usage: totalUsage,
5499
- toolCalls: toolCallLog
5499
+ toolCalls: toolCallLog,
5500
+ traceId
5500
5501
  }
5501
5502
  );
5502
5503
  };
@@ -5510,7 +5511,12 @@ ${structuredOutputExample}
5510
5511
  `[task] ${err.message}`,
5511
5512
  "task_execution_error",
5512
5513
  500,
5513
- { turns: loopCount, usage: totalUsage, toolCalls: toolCallLog }
5514
+ {
5515
+ turns: loopCount,
5516
+ usage: totalUsage,
5517
+ toolCalls: toolCallLog,
5518
+ traceId
5519
+ }
5514
5520
  );
5515
5521
  }
5516
5522
  return finish(buildResult(null, "", false, loopCount));
@@ -5519,7 +5525,8 @@ ${structuredOutputExample}
5519
5525
  throw new MindStudioError(
5520
5526
  `[task] ${err.message}`,
5521
5527
  err.errorCode ?? "task_turn_error",
5522
- err.status ?? 500
5528
+ err.status ?? 500,
5529
+ { traceId }
5523
5530
  );
5524
5531
  }
5525
5532
  throw err;
@@ -5583,9 +5590,13 @@ ${structuredOutputExample}
5583
5590
  isError: true
5584
5591
  };
5585
5592
  }
5593
+ } else if (kind === "method") {
5594
+ result = await deps.executeMethodTool(toolCall.name, mergedInput, {
5595
+ traceId,
5596
+ toolCallId: toolCall.id
5597
+ });
5586
5598
  } else {
5587
- const execute = kind === "method" ? deps.executeMethodTool : deps.executeStepTool;
5588
- result = await execute(toolCall.name, mergedInput);
5599
+ result = await deps.executeStepTool(toolCall.name, mergedInput);
5589
5600
  }
5590
5601
  toolCallLog.push({
5591
5602
  name: toolCall.name,
@@ -6795,7 +6806,7 @@ var MindStudioAgent = class {
6795
6806
  };
6796
6807
  }
6797
6808
  },
6798
- executeMethodTool: async (methodId, input) => {
6809
+ executeMethodTool: async (methodId, input, call) => {
6799
6810
  try {
6800
6811
  const { data } = await request(
6801
6812
  { ...httpConfig, maxRetries: 0 },
@@ -6803,7 +6814,9 @@ var MindStudioAgent = class {
6803
6814
  "/task/invoke-method",
6804
6815
  {
6805
6816
  methodId,
6806
- input
6817
+ input,
6818
+ traceId: call.traceId,
6819
+ toolCallId: call.toolCallId
6807
6820
  }
6808
6821
  );
6809
6822
  if (data.error) {