zidane 5.9.3 → 5.9.6

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.
Files changed (73) hide show
  1. package/dist/{agent-DHCQ9Gq3.d.ts → agent-mijmPXdU.d.ts} +54 -10
  2. package/dist/agent-mijmPXdU.d.ts.map +1 -0
  3. package/dist/chat/pure.d.ts +3 -3
  4. package/dist/chat.d.ts +6 -6
  5. package/dist/chat.js +2 -2
  6. package/dist/eval.d.ts +1 -1
  7. package/dist/eval.js +3 -3
  8. package/dist/{headless-C4qg6dN_.js → headless-BRv_OMBY.js} +131 -24
  9. package/dist/headless-BRv_OMBY.js.map +1 -0
  10. package/dist/headless.d.ts +2 -2
  11. package/dist/headless.js +2 -2
  12. package/dist/{index-zpIoZbP-.d.ts → index-Bwg3FuOS.d.ts} +2 -2
  13. package/dist/{index-zpIoZbP-.d.ts.map → index-Bwg3FuOS.d.ts.map} +1 -1
  14. package/dist/{index-BGFY2Xks.d.ts → index-DImx7F54.d.ts} +40 -7
  15. package/dist/index-DImx7F54.d.ts.map +1 -0
  16. package/dist/index.d.ts +4 -4
  17. package/dist/index.js +10 -10
  18. package/dist/{login-BtjX8p55.js → login-D6hyBx6o.js} +22 -8
  19. package/dist/login-D6hyBx6o.js.map +1 -0
  20. package/dist/{mcp-adAkHM-0.js → mcp-abU10KzB.js} +2 -2
  21. package/dist/{mcp-adAkHM-0.js.map → mcp-abU10KzB.js.map} +1 -1
  22. package/dist/mcp.d.ts +1 -1
  23. package/dist/mcp.js +1 -1
  24. package/dist/{messages-Dhva-Ewy.js → messages-CutkEvp4.js} +80 -22
  25. package/dist/messages-CutkEvp4.js.map +1 -0
  26. package/dist/{presets-BfisDyXR.js → presets-DIZMsG1C.js} +2 -2
  27. package/dist/{presets-BfisDyXR.js.map → presets-DIZMsG1C.js.map} +1 -1
  28. package/dist/presets.d.ts +2 -2
  29. package/dist/presets.js +1 -1
  30. package/dist/{providers-CezC9my7.js → providers-XY1GsF43.js} +34 -30
  31. package/dist/providers-XY1GsF43.js.map +1 -0
  32. package/dist/providers.d.ts +1 -1
  33. package/dist/providers.js +2 -2
  34. package/dist/restate.d.ts +1 -1
  35. package/dist/session/sqlite.d.ts +1 -1
  36. package/dist/{session-7CKYn9qT.js → session-Bp2MjGwp.js} +2 -2
  37. package/dist/{session-7CKYn9qT.js.map → session-Bp2MjGwp.js.map} +1 -1
  38. package/dist/session.d.ts +1 -1
  39. package/dist/session.js +2 -2
  40. package/dist/skills.d.ts +2 -2
  41. package/dist/{tool-formatters-Dr3CCAZC.d.ts → tool-formatters-vhqsr-aU.d.ts} +2 -2
  42. package/dist/{tool-formatters-Dr3CCAZC.d.ts.map → tool-formatters-vhqsr-aU.d.ts.map} +1 -1
  43. package/dist/tools/fetch-url.d.ts +1 -1
  44. package/dist/tools/web-search.d.ts +1 -1
  45. package/dist/{tools-qS3yZYAX.js → tools-8Uxv5SLv.js} +121 -23
  46. package/dist/tools-8Uxv5SLv.js.map +1 -0
  47. package/dist/tools.d.ts +2 -2
  48. package/dist/tools.js +1 -1
  49. package/dist/{transcript-anchors-DqKSe8tj.js → transcript-anchors-CRZdb6_V.js} +29 -17
  50. package/dist/transcript-anchors-CRZdb6_V.js.map +1 -0
  51. package/dist/{transcript-anchors-yBIUU4g-.d.ts → transcript-anchors-DB-fcjQw.d.ts} +40 -6
  52. package/dist/transcript-anchors-DB-fcjQw.d.ts.map +1 -0
  53. package/dist/tui.d.ts +3 -3
  54. package/dist/tui.d.ts.map +1 -1
  55. package/dist/tui.js +59 -19
  56. package/dist/tui.js.map +1 -1
  57. package/dist/{turn-operations-hZ30469r.d.ts → turn-operations-CocPmYHx.d.ts} +3 -3
  58. package/dist/{turn-operations-hZ30469r.d.ts.map → turn-operations-CocPmYHx.d.ts.map} +1 -1
  59. package/dist/{types-BPw_i5vb.js → types-DjlRVjWb.js} +22 -7
  60. package/dist/types-DjlRVjWb.js.map +1 -0
  61. package/dist/types.d.ts +3 -3
  62. package/dist/types.js +2 -2
  63. package/package.json +1 -1
  64. package/dist/agent-DHCQ9Gq3.d.ts.map +0 -1
  65. package/dist/headless-C4qg6dN_.js.map +0 -1
  66. package/dist/index-BGFY2Xks.d.ts.map +0 -1
  67. package/dist/login-BtjX8p55.js.map +0 -1
  68. package/dist/messages-Dhva-Ewy.js.map +0 -1
  69. package/dist/providers-CezC9my7.js.map +0 -1
  70. package/dist/tools-qS3yZYAX.js.map +0 -1
  71. package/dist/transcript-anchors-DqKSe8tj.js.map +0 -1
  72. package/dist/transcript-anchors-yBIUU4g-.d.ts.map +0 -1
  73. package/dist/types-BPw_i5vb.js.map +0 -1
@@ -1,12 +1,12 @@
1
1
  import { c as formatTaskStatus, f as buildContextBreakdown, h as utf8ByteLength, l as formatTaskSummary, n as stripLineNumberPrefixes, r as styleReplacementForVia, s as formatDuration, t as resolveOldString, u as previewLine } from "./edit-utils-DnfNoj16.js";
2
- import { a as createCursorOAuthProvider, c as anthropic, d as ANTHROPIC_EXTRA_MODELS, f as FAST_MODE_OPTIONS, n as openai, o as generatePkce, r as local, s as cerebras, t as openrouter } from "./providers-CezC9my7.js";
2
+ import { a as createCursorOAuthProvider, c as anthropic, d as ANTHROPIC_EXTRA_MODELS, f as FAST_MODE_OPTIONS, n as openai, o as generatePkce, r as local, s as cerebras, t as openrouter } from "./providers-XY1GsF43.js";
3
3
  import { i as AgentProviderError, l as errorMessage, n as AgentBudgetExceededError, o as AgentToolPairingError, p as toTypedError, t as AgentAbortedError } from "./errors-B-GeaKTX.js";
4
- import { E as appendStaticSection, a as detectTurnInterruption, c as filterUnresolvedToolUses, k as renderSystemForWire, n as SYNTHETIC_TOOL_RESULT_PLACEHOLDER, o as ensureEndsWithUserMessage, s as ensureToolResultPairing } from "./messages-Dhva-Ewy.js";
4
+ import { E as appendStaticSection, a as detectTurnInterruption, c as filterUnresolvedToolUses, k as renderSystemForWire, n as SYNTHETIC_TOOL_RESULT_PLACEHOLDER, o as ensureEndsWithUserMessage, s as ensureToolResultPairing } from "./messages-CutkEvp4.js";
5
5
  import { t as reconcileImageMediaType } from "./image-sniff-B7uFSNO1.js";
6
6
  import { n as createProcessContext } from "./contexts-BD2U_xpi.js";
7
- import { n as toolOutputByteLength, t as DEFAULT_AGENT_CLOCK } from "./types-BPw_i5vb.js";
7
+ import { n as toolOutputBudgetByteLength, r as toolOutputByteLength, t as DEFAULT_AGENT_CLOCK } from "./types-DjlRVjWb.js";
8
8
  import { b as escapeXml, f as installAllowedToolsGate, g as validateResourcePath, n as resolveSkills, t as interpolateShellCommands, u as buildCatalog, y as createSkillActivationState } from "./interpolate-CmcrnzDZ.js";
9
- import { n as connectMcpServers } from "./mcp-adAkHM-0.js";
9
+ import { n as connectMcpServers } from "./mcp-abU10KzB.js";
10
10
  import { n as flattenTurns, r as formatTokenUsage, t as effectiveInputFromTurn } from "./stats-DAKBEKjc.js";
11
11
  import { dirname, isAbsolute, join, resolve } from "node:path";
12
12
  import { createHooks } from "hookable";
@@ -1958,6 +1958,10 @@ function formatValue(value) {
1958
1958
  //#endregion
1959
1959
  //#region src/loop.ts
1960
1960
  const IMAGE_OMITTED_MARKER = "[image omitted — model does not support vision]";
1961
+ function documentOmittedMarker(doc) {
1962
+ const sizeLabel = doc.encoding === "base64" ? `${doc.data.length} b64 bytes` : `${doc.data.length} chars`;
1963
+ return `[document omitted — model does not support document attachments: ${doc.name ? `${doc.name}, ` : ""}${doc.mediaType}, ${sizeLabel}]`;
1964
+ }
1961
1965
  /**
1962
1966
  * Canonical tool_result text emitted when a tool call is interrupted by the
1963
1967
  * user mid-flight (Esc / Ctrl-C / external `AbortSignal`). Mirrors Claude
@@ -2339,16 +2343,17 @@ function applyPairingRepair(ctx, messages, turnId) {
2339
2343
  return repaired;
2340
2344
  }
2341
2345
  function sanitizeStoredToolResults(provider, messages) {
2342
- if (provider.meta.capabilities?.vision !== false) return messages;
2346
+ if (provider.meta.capabilities?.vision !== false && provider.meta.capabilities?.documents === true) return messages;
2343
2347
  return messages.map((msg) => {
2344
2348
  let changed = false;
2345
2349
  const newContent = msg.content.map((block) => {
2346
2350
  if (block.type !== "tool_result" || typeof block.output === "string") return block;
2351
+ const output = sanitizeToolOutputForProvider(provider, block.output);
2352
+ if (output === block.output) return block;
2347
2353
  changed = true;
2348
- const flattened = block.output.map((b) => b.type === "image" ? IMAGE_OMITTED_MARKER : b.text).join("\n");
2349
2354
  return {
2350
2355
  ...block,
2351
- output: flattened
2356
+ output
2352
2357
  };
2353
2358
  });
2354
2359
  return changed ? {
@@ -3024,10 +3029,10 @@ async function executeTurn(ctx, turn, priorUsage) {
3024
3029
  const name = nameById.get(r.id);
3025
3030
  if (typeof name === "string" && excludeSet.has(name)) return sum;
3026
3031
  }
3027
- return sum + toolOutputByteLength(r.content);
3032
+ return sum + toolOutputBudgetByteLength(r.content);
3028
3033
  }, 0);
3029
3034
  if (totalBytes > ctx.toolOutputBudget) {
3030
- const warning = `[Tool output budget exceeded: ${totalBytes} bytes returned in this turn (cap: ${ctx.toolOutputBudget}). Summarize the salient findings before calling more tools.]`;
3035
+ const warning = `[Tool output budget exceeded: ${totalBytes} text-equivalent bytes returned in this turn (cap: ${ctx.toolOutputBudget}). Summarize the salient findings before calling more tools.]`;
3031
3036
  const userMsg = ctx.provider.userMessage(warning);
3032
3037
  ctx.turns.push({
3033
3038
  id: await ctx.generateTurnId(),
@@ -3066,9 +3071,32 @@ async function executeTurn(ctx, turn, priorUsage) {
3066
3071
  * shape as narrow as possible.
3067
3072
  */
3068
3073
  function stripImagesForNonVision(provider, output) {
3074
+ return sanitizeToolOutputForProvider(provider, output);
3075
+ }
3076
+ function sanitizeToolOutputForProvider(provider, output) {
3069
3077
  if (typeof output === "string") return output;
3070
- if (provider.meta.capabilities?.vision !== false) return output;
3071
- return output.map((b) => b.type === "image" ? IMAGE_OMITTED_MARKER : b.text).join("\n");
3078
+ if (provider.meta.capabilities?.vision !== false && provider.meta.capabilities?.documents === true) return output;
3079
+ let changed = false;
3080
+ const sanitized = output.map((block) => {
3081
+ if (block.type === "image" && provider.meta.capabilities?.vision === false) {
3082
+ changed = true;
3083
+ return {
3084
+ type: "text",
3085
+ text: IMAGE_OMITTED_MARKER
3086
+ };
3087
+ }
3088
+ if (block.type === "document" && provider.meta.capabilities?.documents !== true) {
3089
+ changed = true;
3090
+ return {
3091
+ type: "text",
3092
+ text: documentOmittedMarker(block)
3093
+ };
3094
+ }
3095
+ return block;
3096
+ });
3097
+ if (!changed) return output;
3098
+ if (sanitized.every((block) => block.type === "text")) return sanitized.map((block) => block.text).join("\n");
3099
+ return sanitized;
3072
3100
  }
3073
3101
  /**
3074
3102
  * Build the per-call base for every `tool:*` hook ctx (and the
@@ -5506,6 +5534,7 @@ function resolveBehavior(agentBehavior, runBehavior) {
5506
5534
  readLineNumbers: runBehavior?.readLineNumbers ?? agentBehavior?.readLineNumbers,
5507
5535
  elideStaleReads: runBehavior?.elideStaleReads ?? agentBehavior?.elideStaleReads,
5508
5536
  toolDisclosure: runBehavior?.toolDisclosure ?? agentBehavior?.toolDisclosure ?? "eager",
5537
+ mcpToolNameSeparator: runBehavior?.mcpToolNameSeparator ?? agentBehavior?.mcpToolNameSeparator ?? "_",
5509
5538
  toolSearch: runBehavior?.toolSearch ?? agentBehavior?.toolSearch,
5510
5539
  surfaceMcpInstructions: runBehavior?.surfaceMcpInstructions ?? agentBehavior?.surfaceMcpInstructions ?? true,
5511
5540
  persistThreshold: runBehavior?.persistThreshold ?? agentBehavior?.persistThreshold,
@@ -5541,6 +5570,35 @@ function resolveServerForTool(toolName, servers) {
5541
5570
  }
5542
5571
  return best;
5543
5572
  }
5573
+ function resolveMcpToolParts(canonicalName, servers) {
5574
+ const server = resolveServerForTool(canonicalName, servers);
5575
+ if (server) {
5576
+ const prefix = `mcp_${server.name}_`;
5577
+ return {
5578
+ server: server.name,
5579
+ tool: canonicalName.slice(prefix.length)
5580
+ };
5581
+ }
5582
+ if (!canonicalName.startsWith("mcp_")) return void 0;
5583
+ const tail = canonicalName.slice(4);
5584
+ const sep = tail.indexOf("_");
5585
+ if (sep <= 0 || sep >= tail.length - 1) return void 0;
5586
+ return {
5587
+ server: tail.slice(0, sep),
5588
+ tool: tail.slice(sep + 1)
5589
+ };
5590
+ }
5591
+ function buildMcpToolNameSeparatorAliases(mcpToolNames, servers, separator) {
5592
+ if (separator === "_") return void 0;
5593
+ const aliases = {};
5594
+ for (const canonicalName of mcpToolNames) {
5595
+ const parts = resolveMcpToolParts(canonicalName, servers);
5596
+ if (!parts) continue;
5597
+ const wireName = `mcp${separator}${parts.server}${separator}${parts.tool}`;
5598
+ if (wireName !== canonicalName) aliases[canonicalName] = wireName;
5599
+ }
5600
+ return Object.keys(aliases).length > 0 ? aliases : void 0;
5601
+ }
5544
5602
  /**
5545
5603
  * Partition a tool registry into eager and lazy buckets.
5546
5604
  *
@@ -5893,7 +5951,7 @@ function createAgent({ provider, name: agentName, system: agentSystem, tools: ag
5893
5951
  const thinking = options.thinking ?? "off";
5894
5952
  const model = options.model ?? provider.meta.defaultModel;
5895
5953
  const resolvedBehavior = resolveBehavior(agentBehavior, options.behavior);
5896
- const { maxConcurrentTools, toolBatchExecutor, shouldRethrowToolError, maxTurns, maxCostUsd, maxTotalTokens, maxTokens, retry, thinkingBudget, modelOptions: behaviorModelOptions, schema, cache, toolOutputBudget, toolOutputBudgetExcludeTools, compactStrategy, compactThreshold, compactKeepTurns, thinkingDecay, dedupTools, toolBudgets, repeatGuard, elideStaleReads, toolDisclosure, toolSearch, surfaceMcpInstructions, persistThreshold, persistExcludeTools, persistDir, persistMaxBytes, strictToolPairing, maxConsecutivePauseTurns, persistTurns } = resolvedBehavior;
5954
+ const { maxConcurrentTools, toolBatchExecutor, shouldRethrowToolError, maxTurns, maxCostUsd, maxTotalTokens, maxTokens, retry, thinkingBudget, modelOptions: behaviorModelOptions, schema, cache, toolOutputBudget, toolOutputBudgetExcludeTools, compactStrategy, compactThreshold, compactKeepTurns, thinkingDecay, dedupTools, toolBudgets, repeatGuard, elideStaleReads, toolDisclosure, mcpToolNameSeparator, toolSearch, surfaceMcpInstructions, persistThreshold, persistExcludeTools, persistDir, persistMaxBytes, strictToolPairing, maxConsecutivePauseTurns, persistTurns } = resolvedBehavior;
5897
5955
  const modelOptions = options.modelOptions ?? behaviorModelOptions;
5898
5956
  let system = options.system || agentSystem || "You are a helpful assistant.";
5899
5957
  const baseSystemForBreakdown = renderSystemForWire(system);
@@ -5903,6 +5961,11 @@ function createAgent({ provider, name: agentName, system: agentSystem, tools: ag
5903
5961
  ...mcpConnection.tools
5904
5962
  } : sourceTools;
5905
5963
  const mcpToolNames = options.tools === void 0 && mcpConnection ? new Set(Object.keys(mcpConnection.tools)) : /* @__PURE__ */ new Set();
5964
+ const generatedMcpToolAliases = buildMcpToolNameSeparatorAliases(mcpToolNames, mcpServers, mcpToolNameSeparator);
5965
+ const effectiveToolAliases = generatedMcpToolAliases ? {
5966
+ ...generatedMcpToolAliases,
5967
+ ...toolAliases ?? {}
5968
+ } : toolAliases;
5906
5969
  const mergedWithSkills = options.tools === void 0 && !!resolvedSkills && resolvedSkills.length > 0 && skillsConfig?.tool !== false ? {
5907
5970
  skills_use: createSkillsUseTool({
5908
5971
  catalog: resolvedSkills,
@@ -5925,9 +5988,9 @@ function createAgent({ provider, name: agentName, system: agentSystem, tools: ag
5925
5988
  if (toolsPreSearch.shell === shell) toolsPreSearch.shell = createShellTool({
5926
5989
  allowBackground: typeof resolvedBehavior?.tasksDir === "string" && resolvedBehavior.tasksDir.length > 0 && resolvedBehavior.disableBackgroundTasks !== true,
5927
5990
  registeredCanonicals: new Set(Object.keys(toolsPreSearch)),
5928
- ...toolAliases ? { toolAliases } : {}
5991
+ ...effectiveToolAliases ? { toolAliases: effectiveToolAliases } : {}
5929
5992
  });
5930
- const disclosure = partitionToolDisclosure(toolsPreSearch, mcpToolNames, mcpServers, toolDisclosure, toolAliases);
5993
+ const disclosure = partitionToolDisclosure(toolsPreSearch, mcpToolNames, mcpServers, toolDisclosure, effectiveToolAliases);
5931
5994
  const unlocked = new Set(disclosure.eagerCanonicalNames);
5932
5995
  const initialUnlocked = new Set(disclosure.eagerCanonicalNames);
5933
5996
  const dynamicUnlockOrder = [];
@@ -5956,7 +6019,7 @@ function createAgent({ provider, name: agentName, system: agentSystem, tools: ag
5956
6019
  unlocked.add(toolSearchTool.spec.name);
5957
6020
  initialUnlocked.add(toolSearchTool.spec.name);
5958
6021
  }
5959
- const discoveryToolName = shouldInjectToolSearch ? "tool_search" : hostDefinedToolSearch ? toolAliases?.tool_search ?? "tool_search" : null;
6022
+ const discoveryToolName = shouldInjectToolSearch ? "tool_search" : hostDefinedToolSearch ? effectiveToolAliases?.tool_search ?? "tool_search" : null;
5960
6023
  let searchableCatalogText;
5961
6024
  if (disclosure.lazyEntries.length > 0) {
5962
6025
  searchableCatalogText = buildSearchableCatalog(disclosure.lazyEntries, { discoveryToolName });
@@ -5966,7 +6029,7 @@ function createAgent({ provider, name: agentName, system: agentSystem, tools: ag
5966
6029
  const section = renderMcpInstructionsSection(mcpConnection.instructions);
5967
6030
  if (section.length > 0) system = appendStaticSection(system, section);
5968
6031
  }
5969
- const aliasMaps = buildAliasMaps(toolAliases, Object.keys(tools));
6032
+ const aliasMaps = buildAliasMaps(effectiveToolAliases, Object.keys(tools));
5970
6033
  augmentMcpDoubleUnderscoreAliases(aliasMaps, Object.keys(tools));
5971
6034
  let formattedToolsCache = null;
5972
6035
  function buildFormattedTools() {
@@ -6148,7 +6211,7 @@ function createAgent({ provider, name: agentName, system: agentSystem, tools: ag
6148
6211
  agentName,
6149
6212
  agentSystem,
6150
6213
  agentTools: sourceTools,
6151
- agentToolAliases: toolAliases,
6214
+ agentToolAliases: effectiveToolAliases,
6152
6215
  agentMcpServers: mcpServers,
6153
6216
  agentSkills,
6154
6217
  agentBehavior: resolvedBehavior,
@@ -7428,18 +7491,18 @@ function decodedBase64ByteLength(b64) {
7428
7491
  const DEFAULT_LINE_LIMIT = 2e3;
7429
7492
  const DEFAULT_BYTE_CAP = 262144;
7430
7493
  /**
7431
- * Hard upper bound on raw image bytes we'll inline as a base64 image block.
7494
+ * Hard upper bound on raw attachment bytes we'll inline as a base64 block.
7432
7495
  * Above this, we return a marker instead — the model won't get useful
7433
7496
  * information from a 10 MB+ screenshot rendered as one tool result, and
7434
7497
  * the wire bill gets ugly. Override via the `maxBytes` parameter on the
7435
7498
  * tool call.
7436
7499
  */
7437
- const DEFAULT_IMAGE_BYTE_CAP = 5 * 1024 * 1024;
7500
+ const DEFAULT_ATTACHMENT_BYTE_CAP = 5 * 1024 * 1024;
7438
7501
  const readFile$1 = {
7439
7502
  isConcurrencySafe: true,
7440
7503
  spec: {
7441
7504
  name: "read_file",
7442
- description: "Read a file by path. Returns lines [offset..offset+limit). Default offset=1, limit=2000. Each line is prefixed with its 1-indexed line number followed by a tab (e.g. `42\\tconst foo = bar`); the prefix is metadata, not part of the file. Mirrors Claude Code's `cat -n`-style compact output for token efficiency. A trailing footer explains how to read the rest when truncated. Binary files return a short marker rather than mojibake.",
7505
+ description: "Read a file by path. Text files return lines [offset..offset+limit). Default offset=1, limit=2000. Each line is prefixed with its 1-indexed line number followed by a tab (e.g. `42\\tconst foo = bar`); the prefix is metadata, not part of the file. Mirrors Claude Code's `cat -n`-style compact output for token efficiency. A trailing footer explains how to read the rest when truncated. Images (png/jpg/gif/webp) and PDFs return structured attachments for capable models; other binary files return a short marker rather than mojibake.",
7443
7506
  inputSchema: {
7444
7507
  type: "object",
7445
7508
  properties: {
@@ -7457,7 +7520,7 @@ const readFile$1 = {
7457
7520
  },
7458
7521
  maxBytes: {
7459
7522
  type: "integer",
7460
- description: "Hard byte cap on file content read, regardless of line count. Default: 262144. Set 0 for unlimited. The rendered output may be slightly larger than this cap when `lineNumbers` is on (each line carries a `<N>\\t` prefix)."
7523
+ description: "Hard byte cap on file content read, regardless of line count. Default: 262144 for text, 5242880 for image/PDF attachments. Set 0 for unlimited. The rendered output may be slightly larger than this cap when `lineNumbers` is on (each line carries a `<N>\\t` prefix)."
7461
7524
  },
7462
7525
  lineNumbers: {
7463
7526
  type: "boolean",
@@ -7470,7 +7533,7 @@ const readFile$1 = {
7470
7533
  async execute({ path, offset, limit, maxBytes, lineNumbers }, ctx) {
7471
7534
  const extMedia = imageMediaTypeFor(path);
7472
7535
  if (extMedia) {
7473
- const sizeCap = maxBytes !== void 0 ? normalizeInteger(maxBytes, DEFAULT_IMAGE_BYTE_CAP) : DEFAULT_IMAGE_BYTE_CAP;
7536
+ const sizeCap = maxBytes !== void 0 ? normalizeInteger(maxBytes, DEFAULT_ATTACHMENT_BYTE_CAP) : DEFAULT_ATTACHMENT_BYTE_CAP;
7474
7537
  try {
7475
7538
  const { base64, byteLength } = await readFileAsBase64(ctx.execution, ctx.handle, path);
7476
7539
  if (sizeCap > 0 && byteLength > sizeCap) return `[image too large to inline: ${path}, ${byteLength} bytes (cap ${sizeCap}). Raise maxBytes, or use shell to inspect.]`;
@@ -7488,6 +7551,28 @@ const readFile$1 = {
7488
7551
  return `Image read failed: ${path} — ${errorMessage(err)}.${hint}`;
7489
7552
  }
7490
7553
  }
7554
+ const docMedia = documentMediaTypeFor(path);
7555
+ if (docMedia) {
7556
+ const sizeCap = maxBytes !== void 0 ? normalizeInteger(maxBytes, DEFAULT_ATTACHMENT_BYTE_CAP) : DEFAULT_ATTACHMENT_BYTE_CAP;
7557
+ try {
7558
+ const { base64, byteLength } = await readFileAsBase64(ctx.execution, ctx.handle, path);
7559
+ if (sizeCap > 0 && byteLength > sizeCap) return `[document too large to attach: ${path}, ${byteLength} bytes (cap ${sizeCap}). Raise maxBytes, or use shell/read text extraction to inspect.]`;
7560
+ if (docMedia === "application/pdf" && !isPdfBase64(base64)) return `[binary file: ${path}, ${byteLength} bytes; extension suggests PDF but file header does not start with %PDF-]`;
7561
+ return [{
7562
+ type: "text",
7563
+ text: `Document: ${path} (${byteLength} bytes, ${docMedia})`
7564
+ }, {
7565
+ type: "document",
7566
+ mediaType: docMedia,
7567
+ data: base64,
7568
+ encoding: "base64",
7569
+ name: fileNameForPath(path)
7570
+ }];
7571
+ } catch (err) {
7572
+ const hint = await suggestionFor(ctx.execution, ctx.handle, path);
7573
+ return `Document read failed: ${path} — ${errorMessage(err)}.${hint}`;
7574
+ }
7575
+ }
7491
7576
  let raw;
7492
7577
  try {
7493
7578
  raw = await ctx.execution.readFile(ctx.handle, path);
@@ -7570,6 +7655,19 @@ function normalizeInteger(value, fallback) {
7570
7655
  if (value < 0) return fallback;
7571
7656
  return Math.floor(value);
7572
7657
  }
7658
+ function documentMediaTypeFor(path) {
7659
+ const dot = path.lastIndexOf(".");
7660
+ if (dot === -1) return void 0;
7661
+ return path.slice(dot + 1).toLowerCase() === "pdf" ? "application/pdf" : void 0;
7662
+ }
7663
+ function fileNameForPath(path) {
7664
+ const normalized = path.replace(/\\/g, "/");
7665
+ const slash = normalized.lastIndexOf("/");
7666
+ return slash === -1 ? normalized : normalized.slice(slash + 1);
7667
+ }
7668
+ function isPdfBase64(base64) {
7669
+ return Buffer.from(base64.slice(0, 16), "base64").toString("ascii").startsWith("%PDF-");
7670
+ }
7573
7671
  //#endregion
7574
7672
  //#region src/tools/shell-kill.ts
7575
7673
  const shellKill = {
@@ -8145,4 +8243,4 @@ const writeFile$1 = {
8145
8243
  //#endregion
8146
8244
  export { resolvePersistDir as A, credKeyOf as B, validateToolArgs as C, cleanupPersistedSession as D, buildPersistedStub as E, resolveReadStateMap as F, localDescriptor as G, enabledModelOptions as H, BUILTIN_PROVIDERS as I, modelsForDescriptor as J, modelOptionsFor as K, OUTPUT_RESERVE_TOKENS as L, getReadState as M, hashContent as N, maybePersistToolResult as O, readStateKey as P, restoreModelOptions as Q, anthropicDescriptor as R, TOOL_USE_SKIPPED_MESSAGE as S, PERSISTENCE_PREVIEW_BYTES as T, getContextWindow as U, effectiveContextWindow as V, getModelInfo as W, openrouterDescriptor as X, openaiDescriptor as Y, piIdOf as Z, createShellTool as _, multiEdit as a, SHELL_CASCADE_CANCEL_MESSAGE as b, grep as c, createAgent as d, createToolSearchTool as f, createSkillsReadTool as g, alwaysQuote as h, readFile$1 as i, resolveTasksDir as j, resolveMcpWarningsDir as k, glob$1 as l, createSkillsRunScriptTool as m, createSpawnTool as n, listFiles as o, createSkillsUseTool as p, modelSupportsReasoning as q, shellKill as r, createInteractionTool as s, writeFile$1 as t, edit as u, shell as v, PERSISTED_STUB_PREFIX as w, TOOL_USE_CANCELLED_MESSAGE as x, INTERRUPT_MESSAGE_FOR_TOOL_USE as y, cerebrasDescriptor as z };
8147
8245
 
8148
- //# sourceMappingURL=tools-qS3yZYAX.js.map
8246
+ //# sourceMappingURL=tools-8Uxv5SLv.js.map