buckyos 0.7.206 → 0.7.209

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 (99) hide show
  1. package/cli/dist/cli.mjs +602 -179
  2. package/cli/dist/cli.mjs.map +1 -1
  3. package/cli/modules/ai.ts +460 -23
  4. package/cli/modules/aiws.ts +1 -1
  5. package/cli/version.ts +1 -1
  6. package/dist/{aicc-67851c41.mjs → aicc-286ba457.mjs} +7 -5
  7. package/dist/aicc-286ba457.mjs.map +1 -0
  8. package/dist/aicc-342f2659.js +2 -0
  9. package/dist/aicc-342f2659.js.map +1 -0
  10. package/dist/aicc_client.d.ts +623 -288
  11. package/dist/aicc_client.d.ts.map +1 -1
  12. package/dist/{aiws_write-47c90e76.mjs → aiws_write-5b542439.mjs} +232 -135
  13. package/dist/{aiws_write-47c90e76.mjs.map → aiws_write-5b542439.mjs.map} +1 -1
  14. package/dist/aiws_write-a0769003.js +13 -0
  15. package/dist/{aiws_write-eeea8ed3.js.map → aiws_write-a0769003.js.map} +1 -1
  16. package/dist/app-frame.cjs +1 -1
  17. package/dist/app-frame.cjs.map +1 -1
  18. package/dist/app-frame.d.ts +3 -0
  19. package/dist/app-frame.d.ts.map +1 -1
  20. package/dist/app-frame.mjs +14 -3
  21. package/dist/app-frame.mjs.map +1 -1
  22. package/dist/browser.cjs +1 -1
  23. package/dist/browser.cjs.map +1 -1
  24. package/dist/browser.d.ts +4 -0
  25. package/dist/browser.d.ts.map +1 -1
  26. package/dist/browser.mjs +93 -81
  27. package/dist/browser.mjs.map +1 -1
  28. package/dist/{content_objid-0a095cbd.mjs → content_objid-09031ce1.mjs} +2 -2
  29. package/dist/{content_objid-0a095cbd.mjs.map → content_objid-09031ce1.mjs.map} +1 -1
  30. package/dist/{content_objid-4742308a.js → content_objid-6342d0ba.js} +2 -2
  31. package/dist/{content_objid-4742308a.js.map → content_objid-6342d0ba.js.map} +1 -1
  32. package/dist/index.cjs +1 -1
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.ts +4 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.mjs +93 -81
  37. package/dist/index.mjs.map +1 -1
  38. package/dist/node.cjs +1 -1
  39. package/dist/node.cjs.map +1 -1
  40. package/dist/node.d.ts +4 -0
  41. package/dist/node.d.ts.map +1 -1
  42. package/dist/node.mjs +92 -80
  43. package/dist/node.mjs.map +1 -1
  44. package/dist/{openai-ae2978de.mjs → openai-1c0d8341.mjs} +2 -2
  45. package/dist/{openai-ae2978de.mjs.map → openai-1c0d8341.mjs.map} +1 -1
  46. package/dist/{openai-f560d518.js → openai-7aa4ffbf.js} +2 -2
  47. package/dist/{openai-f560d518.js.map → openai-7aa4ffbf.js.map} +1 -1
  48. package/dist/sdk_core.d.ts +18 -0
  49. package/dist/sdk_core.d.ts.map +1 -1
  50. package/dist/{site_manager-91b4d899.mjs → site_manager-4f1940eb.mjs} +209 -143
  51. package/dist/site_manager-4f1940eb.mjs.map +1 -0
  52. package/dist/site_manager-ca22ffbd.js +2 -0
  53. package/dist/site_manager-ca22ffbd.js.map +1 -0
  54. package/dist/user_preferences-1d49850a.mjs +158 -0
  55. package/dist/user_preferences-1d49850a.mjs.map +1 -0
  56. package/dist/user_preferences-7288c989.js +2 -0
  57. package/dist/user_preferences-7288c989.js.map +1 -0
  58. package/dist/user_preferences.d.ts +50 -0
  59. package/dist/user_preferences.d.ts.map +1 -0
  60. package/dist/xllm/core/loop.d.ts.map +1 -1
  61. package/dist/xllm/core/run.d.ts.map +1 -1
  62. package/dist/xllm/core/types.d.ts +0 -2
  63. package/dist/xllm/core/types.d.ts.map +1 -1
  64. package/dist/xllm/hosts/deno/native_runtime.d.ts.map +1 -1
  65. package/dist/xllm/hosts/deno/native_tools.d.ts +2 -1
  66. package/dist/xllm/hosts/deno/native_tools.d.ts.map +1 -1
  67. package/dist/xllm/index.d.ts +3 -2
  68. package/dist/xllm/index.d.ts.map +1 -1
  69. package/dist/xllm/providers/aicc.d.ts +7 -3
  70. package/dist/xllm/providers/aicc.d.ts.map +1 -1
  71. package/dist/xllm/runtime/hints.d.ts +9 -4
  72. package/dist/xllm/runtime/hints.d.ts.map +1 -1
  73. package/dist/xllm/runtime/step_renderer.d.ts +4 -4
  74. package/dist/xllm/runtime/step_renderer.d.ts.map +1 -1
  75. package/dist/xllm/runtime/text_budget.d.ts +5 -0
  76. package/dist/xllm/runtime/text_budget.d.ts.map +1 -0
  77. package/dist/xllm/runtime/tool_result.d.ts +14 -1
  78. package/dist/xllm/runtime/tool_result.d.ts.map +1 -1
  79. package/dist/xllm.cjs +1 -1
  80. package/dist/xllm.cjs.map +1 -1
  81. package/dist/xllm.mjs +37 -31
  82. package/dist/xllm_deno.cjs +1 -1
  83. package/dist/xllm_deno.cjs.map +1 -1
  84. package/dist/xllm_deno.mjs +125 -44
  85. package/dist/xllm_deno.mjs.map +1 -1
  86. package/dist/xllm_dev.cjs +1 -1
  87. package/dist/xllm_dev.mjs +2 -2
  88. package/package.json +1 -1
  89. package/dist/aicc-67851c41.mjs.map +0 -1
  90. package/dist/aicc-ccb36ef7.js +0 -2
  91. package/dist/aicc-ccb36ef7.js.map +0 -1
  92. package/dist/aiws_write-eeea8ed3.js +0 -13
  93. package/dist/runtime_env-39e4df98.mjs +0 -44
  94. package/dist/runtime_env-39e4df98.mjs.map +0 -1
  95. package/dist/runtime_env-6396e1eb.js +0 -2
  96. package/dist/runtime_env-6396e1eb.js.map +0 -1
  97. package/dist/site_manager-716a2cf5.js +0 -2
  98. package/dist/site_manager-716a2cf5.js.map +0 -1
  99. package/dist/site_manager-91b4d899.mjs.map +0 -1
@@ -4,9 +4,9 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import { n as canonicalJson, i as isObject, X as XllmError, m as cloneJson, p as providerError, A as AiccLlmClient } from "./aicc-67851c41.mjs";
8
- import { aB as normalizePath, aq as MemoryHintLedger, ao as HINT_NS_DEDUP, T as ToolDispatchException, ab as toHost, ay as taskStateObservation, a6 as envelopeObservation, ar as applyHints, aC as PLANNED_RUNTIME_KINDS, s as shellSettings, aD as BUILTIN_TOOL_GROUP_BASH, u as unresolvedReason, d as describeToolSource, aE as BUILTIN_TOOL_GROUP_BASH_CORE, aF as resolveConfigPath, g as generateRunId, R as RUN_RECORD_VERSION, Y as REFUSED_CREDENTIALS, q as mergeConfigLayers, w as parseLlmContextJson, G as MemoryRunStore, $ as XllmTask, a2 as isTerminal, _ as XllmRun } from "./site_manager-91b4d899.mjs";
9
- import { O as OpenAiLlmClient } from "./openai-ae2978de.mjs";
7
+ import { n as canonicalJson, i as isObject, X as XllmError, m as cloneJson, p as providerError, A as AiccLlmClient } from "./aicc-286ba457.mjs";
8
+ import { ac as observationText, aH as normalizePath, ae as RESULT_BUDGET_TOKENS, av as MemoryHintLedger, at as HINT_NS_DEDUP, T as ToolDispatchException, ad as toHost, aE as taskStateObservation, aa as fitResultBudget, a6 as envelopeObservation, aw as applyHints, aI as PLANNED_RUNTIME_KINDS, s as shellSettings, aJ as BUILTIN_TOOL_GROUP_BASH, u as unresolvedReason, d as describeToolSource, aK as BUILTIN_TOOL_GROUP_BASH_CORE, aL as resolveConfigPath, g as generateRunId, R as RUN_RECORD_VERSION, Y as REFUSED_CREDENTIALS, q as mergeConfigLayers, w as parseLlmContextJson, G as MemoryRunStore, $ as XllmTask, a2 as isTerminal, _ as XllmRun } from "./site_manager-4f1940eb.mjs";
9
+ import { O as OpenAiLlmClient } from "./openai-1c0d8341.mjs";
10
10
  import "./krpc_client-673448e5.mjs";
11
11
  function deno() {
12
12
  const d = globalThis.Deno;
@@ -622,13 +622,17 @@ const TOOL_WRITE_FILE = "write_file";
622
622
  const TOOL_EDIT_FILE = "edit_file";
623
623
  const TOOL_SHELL = "shell";
624
624
  const BASH_GROUP_TOOLS = [TOOL_READ_FILE, TOOL_WRITE_FILE, TOOL_EDIT_FILE, TOOL_SHELL];
625
- const EXEC_MAX_OUTPUT_BYTES = 64 * 1024;
625
+ const EXEC_MAX_OUTPUT_BYTES = 60 * 1024;
626
626
  const OUTPUT_TAIL_BYTES = 2048;
627
627
  const TIMEOUT_EXIT_CODE = 124;
628
628
  const ENV_CALL_ID = "XLLM_CALL_ID";
629
629
  const ENV_RUN_ID = "XLLM_RUN_ID";
630
630
  const LOCAL_ENGINE = "native";
631
631
  const READ_FILE_PREVIEW_MAX_LINES = 200;
632
+ const READ_FILE_PREVIEW_RESERVE_BYTES = 2048;
633
+ const READ_FILE_PREVIEW_BYTES = RESULT_BUDGET_TOKENS * 4 - READ_FILE_PREVIEW_RESERVE_BYTES;
634
+ const READ_PAGING_HINT_KEY = "read.paging";
635
+ const READ_PAGING_HINT = '`range` reads any part: "201-400", "201:+200" (200 lines from 201), "-50:$" (the last 50). Line numbers are those of the whole text.';
632
636
  const CMD_PARAM_PREVIEW_KEEP_CHARS = 32;
633
637
  const HISTORY_COMPACT_CMD_MAX_CHARS = 96;
634
638
  class NativeToolError extends Error {
@@ -1109,26 +1113,32 @@ function readFileTool(cfg) {
1109
1113
  const count = selected.length;
1110
1114
  const startLine = count === 0 ? null : chunkStart + si;
1111
1115
  const endLine = startLine === null ? null : startLine + Math.max(count - 1, 0);
1112
- let preview = "";
1113
- if (startLine !== null) {
1114
- preview = selected.slice(0, READ_FILE_PREVIEW_MAX_LINES).map((l, i) => `${startLine + i}: ${trimEndLineBreaks(l)}`).join("\n");
1115
- if (selected.length > READ_FILE_PREVIEW_MAX_LINES)
1116
- preview += `${preview ? "\n" : ""}... truncated to ${READ_FILE_PREVIEW_MAX_LINES} lines`;
1117
- }
1116
+ const preview = buildPreview(startLine, selected, READ_FILE_PREVIEW_BYTES);
1118
1117
  const bytes = byteLength(content);
1119
1118
  const cmdLine = readCmdLine(filePath, firstChunk, range);
1119
+ const totalLines = splitLinesPreserveEnding(full).length;
1120
+ const lastShown = startLine !== null && preview.shown > 0 ? startLine + preview.shown - 1 : null;
1121
+ const notShown = () => {
1122
+ if (endLine === null || startLine === null)
1123
+ return void 0;
1124
+ const next = lastShown === null ? startLine : lastShown + 1;
1125
+ return next <= endLine ? [next, endLine] : void 0;
1126
+ };
1127
+ const goesOn = () => lastShown !== null && notShown() === void 0 && preview.cut === void 0 && lastShown < totalLines ? lastShown : void 0;
1120
1128
  let summary;
1121
- if (matched) {
1122
- const linesText = startLine !== null && endLine !== null ? startLine === endLine ? `1 line at ${startLine}` : `${count} lines at ${startLine}-${endLine}` : "0 lines";
1123
- const base = `succeeded, read ${bytes} bytes across ${linesText}`;
1124
- summary = preview ? `${base}
1125
- \`\`\`content
1126
- ${preview}
1127
- \`\`\`` : base;
1128
- } else {
1129
- summary = "succeeded, first_chunk was not found, read 0 bytes across 0 lines";
1129
+ if (!matched)
1130
+ summary = `first_chunk was not found in ${filePath}: nothing read`;
1131
+ else if (lastShown === null)
1132
+ summary = `${filePath}: read 0 lines (the file has ${totalLines === 1 ? "1 line" : `${totalLines} lines`})`;
1133
+ else {
1134
+ summary = `${filePath}: shown lines ${startLine}–${lastShown} of ${totalLines} (${bytes} bytes read)`;
1135
+ if (preview.cut)
1136
+ summary += `; line ${preview.cut[0]} cut at ${preview.cut[1]} of ${preview.cut[2]} bytes`;
1137
+ const ns = notShown();
1138
+ if (ns)
1139
+ summary += `; lines ${ns[0]}–${ns[1]} not shown`;
1130
1140
  }
1131
- const detail = {};
1141
+ const detail = { path: abs };
1132
1142
  const url = cyfsUrl(cfg.dfsRoot, abs);
1133
1143
  if (url !== void 0)
1134
1144
  detail.cyfs_url = url;
@@ -1138,24 +1148,82 @@ ${preview}
1138
1148
  line_range: label,
1139
1149
  bytes,
1140
1150
  line_count: count,
1151
+ total_lines: totalLines,
1141
1152
  start_line: startLine,
1142
1153
  end_line: endLine,
1143
- preview_truncated: count > READ_FILE_PREVIEW_MAX_LINES
1154
+ preview_truncated: preview.shown < count || preview.cut !== void 0
1144
1155
  });
1145
1156
  const result = builtinResult(TOOL_READ_FILE, detail, cmdLine, summary);
1146
1157
  result.title = `${cmdLine} => ${matched ? "success" : "anchor not found"}`;
1147
- return withReadDedup(result, filePath, canonicalJson(Object.fromEntries(Object.entries(args).filter(([k]) => k !== "path"))));
1158
+ if (preview.text) {
1159
+ let out = preview.text;
1160
+ if (preview.cut) {
1161
+ const [line, shown, all] = preview.cut;
1162
+ out += `
1163
+ [line ${line} has ${all} bytes, the first ${shown} are shown`;
1164
+ if (abs.startsWith("/"))
1165
+ out += `; read the rest with a command such as \`sed -n '${line}p' ${abs} | cut -b ${shown + 1}-${shown + READ_FILE_PREVIEW_BYTES}\``;
1166
+ out += "]";
1167
+ }
1168
+ const ns = notShown();
1169
+ const withoutChunk = firstChunk !== void 0 ? " and without first_chunk (these are lines of the whole file)" : "";
1170
+ const page = Math.max(preview.shown, 1);
1171
+ if (ns) {
1172
+ out += `
1173
+ [lines ${ns[0]}–${ns[1]} not shown: read again with range=${ns[0]}-${Math.min(ns[1], ns[0] + page - 1)}${withoutChunk}]`;
1174
+ } else if (goesOn() !== void 0) {
1175
+ const last = goesOn();
1176
+ out += `
1177
+ [shown lines ${startLine ?? last}–${last} of ${totalLines}; the next lines: range=${last + 1}-${Math.min(totalLines, last + page)}${withoutChunk}]`;
1178
+ }
1179
+ withOutput(result, out);
1180
+ }
1181
+ if (notShown() || preview.cut || goesOn() !== void 0)
1182
+ result.hints = [{ text: READ_PAGING_HINT, once: READ_PAGING_HINT_KEY }];
1183
+ return withReadDedup(result, filePath);
1148
1184
  }
1149
1185
  };
1150
1186
  }
1151
- function withReadDedup(result, what, window) {
1152
- var _a;
1153
- if (result.status !== "success")
1187
+ function buildPreview(startLine, lines, maxBytes) {
1188
+ const p = { text: "", shown: 0 };
1189
+ if (startLine === null)
1190
+ return p;
1191
+ let used = 0;
1192
+ for (let i = 0; i < Math.min(lines.length, READ_FILE_PREVIEW_MAX_LINES); i++) {
1193
+ const no = startLine + i;
1194
+ const body = trimEndLineBreaks(lines[i]);
1195
+ const prefix = `${no}: `;
1196
+ const sep = i > 0 ? 1 : 0;
1197
+ const bodyBytes = byteLength(body);
1198
+ if (used + sep + prefix.length + bodyBytes > maxBytes) {
1199
+ if (i === 0) {
1200
+ const enc = new TextEncoder().encode(body);
1201
+ let keep = Math.min(Math.max(maxBytes - prefix.length, 0), enc.length);
1202
+ while (keep > 0 && keep < enc.length && (enc[keep] & 192) === 128)
1203
+ keep--;
1204
+ p.text = prefix + new TextDecoder().decode(enc.subarray(0, keep));
1205
+ p.shown = 1;
1206
+ p.cut = [no, keep, enc.length];
1207
+ }
1208
+ break;
1209
+ }
1210
+ if (sep)
1211
+ p.text += "\n";
1212
+ p.text += prefix + body;
1213
+ used += sep + prefix.length + bodyBytes;
1214
+ p.shown++;
1215
+ }
1216
+ return p;
1217
+ }
1218
+ function withReadDedup(result, shownAs) {
1219
+ if (result.status !== "success" || !isObject(result.detail))
1154
1220
  return result;
1155
- const text = ((_a = result.output) == null ? void 0 : _a.trim()) ? result.output : result.summary.trim() ? result.summary : canonicalJson(result.detail);
1221
+ const d = result.detail;
1222
+ const what = typeof d.path === "string" ? d.path : shownAs;
1223
+ const line = (k) => typeof d[k] === "number" ? String(d[k]) : "";
1156
1224
  result.dedup = {
1157
- key: `read:${what}#${window}:${blake3Hex(text).slice(0, 16)}`,
1158
- hint: `\`${what}\` is unchanged since you read it earlier in this run; use that content.`
1225
+ key: `read:${what}#${line("start_line")}-${line("end_line")}::${blake3Hex(observationText(result)).slice(0, 16)}`,
1226
+ hint: `\`${shownAs}\` is unchanged`
1159
1227
  };
1160
1228
  return result;
1161
1229
  }
@@ -1251,11 +1319,10 @@ function editFileTool(cfg) {
1251
1319
  if (url !== void 0)
1252
1320
  detail.cyfs_url = url;
1253
1321
  Object.assign(detail, { matched: true, changed, mode: "replace", line, diff, diff_truncated: false });
1254
- const summary = changed ? diff.trim() ? `edited ${filePath} with replace at line ${line}
1255
- \`\`\`diff
1256
- ${diff}
1257
- \`\`\`` : `edited ${filePath} with replace at line ${line}` : `edit ${filePath} made no change`;
1322
+ const summary = changed ? `edited ${filePath} with replace at line ${line}` : `edit ${filePath} made no change`;
1258
1323
  const result = builtinResult(TOOL_EDIT_FILE, detail, cmdLine, summary);
1324
+ if (changed && diff.trim())
1325
+ withOutput(result, diff);
1259
1326
  result.title = `${TOOL_EDIT_FILE} ${filePath} => ${changed ? `success (line ${line})` : "no change"}`;
1260
1327
  return result;
1261
1328
  }
@@ -1285,7 +1352,7 @@ function fmtElapsed(ms) {
1285
1352
  return `${Math.floor(s / 60)}m${String(s % 60).padStart(2, "0")}s`;
1286
1353
  return `${Math.floor(s / 3600)}h${String(Math.floor(s % 3600 / 60)).padStart(2, "0")}m`;
1287
1354
  }
1288
- function boundedText(bytes, max) {
1355
+ function boundedText(bytes, max, source) {
1289
1356
  const headCap = Math.floor(max / 4);
1290
1357
  const tailCap = max - headCap;
1291
1358
  const head = bytes.subarray(0, Math.min(headCap, bytes.length));
@@ -1294,10 +1361,22 @@ function boundedText(bytes, max) {
1294
1361
  const truncated = bytes.length > head.length + tail.length;
1295
1362
  if (!truncated)
1296
1363
  return [decodeLossy(head) + decodeLossy(tail), false];
1364
+ const omitted = bytes.length - head.length - tail.length;
1365
+ const marker = source === void 0 ? `…[${omitted} bytes omitted]…` : `…[${omitted} bytes omitted; full ${source.split("/").pop() || "output"}: ${source}]…`;
1297
1366
  return [`${decodeLossy(head)}
1298
- …[${bytes.length - head.length - tail.length} bytes omitted]…
1367
+ ${marker}
1299
1368
  ${decodeLossy(tail)}`, true];
1300
1369
  }
1370
+ function streamShares(stdout, stderr, max) {
1371
+ if (stdout + stderr <= max)
1372
+ return [stdout, stderr];
1373
+ const half = Math.floor(max / 2);
1374
+ if (stdout <= half)
1375
+ return [stdout, max - stdout];
1376
+ if (stderr <= half)
1377
+ return [max - stderr, stderr];
1378
+ return [half, max - half];
1379
+ }
1301
1380
  async function readBytes(path) {
1302
1381
  try {
1303
1382
  return await deno().readFile(path);
@@ -1305,10 +1384,6 @@ async function readBytes(path) {
1305
1384
  return void 0;
1306
1385
  }
1307
1386
  }
1308
- async function readFileBounded(path, max) {
1309
- const bytes = await readBytes(path);
1310
- return bytes ? boundedText(bytes, Math.max(max, 16)) : ["", false];
1311
- }
1312
1387
  async function readFileTail(path, max) {
1313
1388
  const bytes = await readBytes(path);
1314
1389
  return bytes ? decodeLossy(bytes.subarray(Math.max(0, bytes.length - max))) : "";
@@ -1321,9 +1396,14 @@ async function readExitFile(dir) {
1321
1396
  return void 0;
1322
1397
  }
1323
1398
  }
1324
- async function outputFromExecDir(dir, exitCode, timedOut, elapsedMs, max, cwd) {
1325
- const [stdout, outTrunc] = await readFileBounded(joinPath(dir, "stdout"), max);
1326
- const [stderr, errTrunc] = await readFileBounded(joinPath(dir, "stderr"), max);
1399
+ async function outputFromExecDir(dir, exitCode, timedOut, elapsedMs, max, cwd, kept) {
1400
+ const outPath = joinPath(dir, "stdout");
1401
+ const errPath = joinPath(dir, "stderr");
1402
+ const out = await readBytes(outPath) ?? new Uint8Array();
1403
+ const err = await readBytes(errPath) ?? new Uint8Array();
1404
+ const [outMax, errMax] = streamShares(out.length, err.length, max);
1405
+ const [stdout, outTrunc] = boundedText(out, Math.max(outMax, 16), kept ? outPath : void 0);
1406
+ const [stderr, errTrunc] = boundedText(err, Math.max(errMax, 16), kept ? errPath : void 0);
1327
1407
  let output = stdout;
1328
1408
  if (stderr) {
1329
1409
  if (output && !output.endsWith("\n"))
@@ -1546,7 +1626,7 @@ function shellTool(cfg) {
1546
1626
  const t = sleepOrStop(5e3);
1547
1627
  await Promise.race([child.status, t.done]);
1548
1628
  t.stop();
1549
- const out2 = await outputFromExecDir(dir, TIMEOUT_EXIT_CODE, true, performance.now() - started, EXEC_MAX_OUTPUT_BYTES, cwd);
1629
+ const out2 = await outputFromExecDir(dir, TIMEOUT_EXIT_CODE, true, performance.now() - started, EXEC_MAX_OUTPUT_BYTES, cwd, !temp);
1550
1630
  await cleanup();
1551
1631
  return out2;
1552
1632
  };
@@ -1559,7 +1639,7 @@ function shellTool(cfg) {
1559
1639
  timer.stop();
1560
1640
  let out;
1561
1641
  if ("exited" in first) {
1562
- out = await outputFromExecDir(dir, exitCodeOf(first.exited), false, performance.now() - started, EXEC_MAX_OUTPUT_BYTES, cwd);
1642
+ out = await outputFromExecDir(dir, exitCodeOf(first.exited), false, performance.now() - started, EXEC_MAX_OUTPUT_BYTES, cwd, !temp);
1563
1643
  await cleanup();
1564
1644
  } else if ("timeout" in first) {
1565
1645
  out = await kill();
@@ -1815,7 +1895,8 @@ class NativeToolManager {
1815
1895
  return { kind: "error", call_id: callId, message: `tool \`${call.name}\` returned a pending result without a task_id`, host: toHost(result) };
1816
1896
  return taskStateObservation(callId, taskId, { kind: "unknown", reason: "this runtime has no task backend" }, { kind: "tools" });
1817
1897
  }
1818
- return envelopeObservation(callId, result, applyHints(result, this.ledger));
1898
+ fitResultBudget(result);
1899
+ return envelopeObservation(callId, result, applyHints(result, this.ledger, callId));
1819
1900
  }
1820
1901
  }
1821
1902
  function nativeDescriptor(runtimeId, target, probe) {