hammer-ai 0.2.13 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -213,7 +213,13 @@ var LLMClient = class {
213
213
  delete payload.temperature;
214
214
  }
215
215
  if (this.config.enableThinking !== void 0) {
216
- payload.enable_thinking = this.config.enableThinking;
216
+ if (isDeepSeekRequest(this.config)) {
217
+ payload.thinking = {
218
+ type: this.config.enableThinking ? "enabled" : "disabled"
219
+ };
220
+ } else {
221
+ payload.enable_thinking = this.config.enableThinking;
222
+ }
217
223
  }
218
224
  const headers = {
219
225
  "Content-Type": "application/json",
@@ -465,6 +471,9 @@ var LLMClient = class {
465
471
  };
466
472
  }
467
473
  };
474
+ function isDeepSeekRequest(config) {
475
+ return /deepseek/i.test(config.model) || /deepseek\.com/i.test(config.baseUrl);
476
+ }
468
477
  var ApiError = class extends Error {
469
478
  constructor(status, body) {
470
479
  super(`API error ${status}: ${body}`);
@@ -3124,31 +3133,194 @@ function extractTruncatedToolInfo(calls) {
3124
3133
  }
3125
3134
 
3126
3135
  // src/tool-helpers.ts
3127
- var MAX_TOOL_RESULT_CHARS = 3e4;
3128
- var MAX_PRESENTATION_LINES = 200;
3129
- var MAX_PRESENTATION_CHARS = 5e4;
3130
- function truncateToolResult(resultStr, options) {
3131
- const maxChars = options?.maxChars ?? MAX_TOOL_RESULT_CHARS;
3132
- const strategy = options?.strategy ?? "head-tail";
3133
- if (resultStr.length <= maxChars) return resultStr;
3134
- if (strategy === "head-only") {
3135
- return resultStr.substring(0, maxChars) + "\n...(truncated)";
3136
- }
3137
- const half = Math.floor(maxChars / 2);
3138
- const head = resultStr.substring(0, half);
3139
- const tail = resultStr.substring(resultStr.length - half);
3140
- const omitted = resultStr.length - maxChars;
3141
- return `${head}
3142
- ... [${omitted} chars truncated] ...
3143
- ${tail}`;
3136
+ var DEFAULT_MAX_LINES = 2e3;
3137
+ var DEFAULT_MAX_BYTES = 50 * 1024;
3138
+ function splitLinesForCounting(content) {
3139
+ if (content.length === 0) {
3140
+ return [];
3141
+ }
3142
+ const lines = content.split("\n");
3143
+ if (content.endsWith("\n")) {
3144
+ lines.pop();
3145
+ }
3146
+ return lines;
3147
+ }
3148
+ function truncateHead(content, options = {}) {
3149
+ const maxLines = options.maxLines ?? DEFAULT_MAX_LINES;
3150
+ const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
3151
+ const totalBytes = utf8ByteLength(content);
3152
+ const lines = splitLinesForCounting(content);
3153
+ const totalLines = lines.length;
3154
+ if (totalLines <= maxLines && totalBytes <= maxBytes) {
3155
+ return {
3156
+ content,
3157
+ truncated: false,
3158
+ truncatedBy: null,
3159
+ totalLines,
3160
+ totalBytes,
3161
+ outputLines: totalLines,
3162
+ outputBytes: totalBytes,
3163
+ lastLinePartial: false,
3164
+ firstLineExceedsLimit: false,
3165
+ maxLines,
3166
+ maxBytes
3167
+ };
3168
+ }
3169
+ if (lines.length > 0 && utf8ByteLength(lines[0]) > maxBytes) {
3170
+ return {
3171
+ content: "",
3172
+ truncated: true,
3173
+ truncatedBy: "bytes",
3174
+ totalLines,
3175
+ totalBytes,
3176
+ outputLines: 0,
3177
+ outputBytes: 0,
3178
+ lastLinePartial: false,
3179
+ firstLineExceedsLimit: true,
3180
+ maxLines,
3181
+ maxBytes
3182
+ };
3183
+ }
3184
+ const outputLinesArr = [];
3185
+ let outputBytesCount = 0;
3186
+ let truncatedBy = "lines";
3187
+ for (let i = 0; i < lines.length && i < maxLines; i++) {
3188
+ const line = lines[i];
3189
+ const lineBytes = utf8ByteLength(line) + (i > 0 ? 1 : 0);
3190
+ if (outputBytesCount + lineBytes > maxBytes) {
3191
+ truncatedBy = "bytes";
3192
+ break;
3193
+ }
3194
+ outputLinesArr.push(line);
3195
+ outputBytesCount += lineBytes;
3196
+ }
3197
+ if (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {
3198
+ truncatedBy = "lines";
3199
+ }
3200
+ const outputContent = outputLinesArr.join("\n");
3201
+ const finalOutputBytes = utf8ByteLength(outputContent);
3202
+ return {
3203
+ content: outputContent,
3204
+ truncated: true,
3205
+ truncatedBy,
3206
+ totalLines,
3207
+ totalBytes,
3208
+ outputLines: outputLinesArr.length,
3209
+ outputBytes: finalOutputBytes,
3210
+ lastLinePartial: false,
3211
+ firstLineExceedsLimit: false,
3212
+ maxLines,
3213
+ maxBytes
3214
+ };
3215
+ }
3216
+ function truncateTail(content, options = {}) {
3217
+ const maxLines = options.maxLines ?? DEFAULT_MAX_LINES;
3218
+ const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
3219
+ const totalBytes = utf8ByteLength(content);
3220
+ const lines = splitLinesForCounting(content);
3221
+ const totalLines = lines.length;
3222
+ if (totalLines <= maxLines && totalBytes <= maxBytes) {
3223
+ return {
3224
+ content,
3225
+ truncated: false,
3226
+ truncatedBy: null,
3227
+ totalLines,
3228
+ totalBytes,
3229
+ outputLines: totalLines,
3230
+ outputBytes: totalBytes,
3231
+ lastLinePartial: false,
3232
+ firstLineExceedsLimit: false,
3233
+ maxLines,
3234
+ maxBytes
3235
+ };
3236
+ }
3237
+ const outputLinesArr = [];
3238
+ let outputBytesCount = 0;
3239
+ let truncatedBy = "lines";
3240
+ let lastLinePartial = false;
3241
+ for (let i = lines.length - 1; i >= 0 && outputLinesArr.length < maxLines; i--) {
3242
+ const line = lines[i];
3243
+ const lineBytes = utf8ByteLength(line) + (outputLinesArr.length > 0 ? 1 : 0);
3244
+ if (outputBytesCount + lineBytes > maxBytes) {
3245
+ truncatedBy = "bytes";
3246
+ if (outputLinesArr.length === 0) {
3247
+ const truncatedLine = truncateStringToBytesFromEnd(line, maxBytes);
3248
+ outputLinesArr.unshift(truncatedLine);
3249
+ outputBytesCount = utf8ByteLength(truncatedLine);
3250
+ lastLinePartial = true;
3251
+ }
3252
+ break;
3253
+ }
3254
+ outputLinesArr.unshift(line);
3255
+ outputBytesCount += lineBytes;
3256
+ }
3257
+ if (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {
3258
+ truncatedBy = "lines";
3259
+ }
3260
+ const outputContent = outputLinesArr.join("\n");
3261
+ const finalOutputBytes = utf8ByteLength(outputContent);
3262
+ return {
3263
+ content: outputContent,
3264
+ truncated: true,
3265
+ truncatedBy,
3266
+ totalLines,
3267
+ totalBytes,
3268
+ outputLines: outputLinesArr.length,
3269
+ outputBytes: finalOutputBytes,
3270
+ lastLinePartial,
3271
+ firstLineExceedsLimit: false,
3272
+ maxLines,
3273
+ maxBytes
3274
+ };
3144
3275
  }
3145
3276
  function formatToolResultMessage(toolCall, result) {
3146
3277
  const exitCode = typeof result.exit_code === "number" ? result.exit_code : result.success === true ? 0 : 1;
3147
3278
  const durationMs = typeof result.duration_ms === "number" ? result.duration_ms : 0;
3148
- const command = typeof result.command === "string" && result.command.length > 0 ? result.command : formatPseudoCommand(toolCall);
3149
- const stdout = truncatePresentationOutput(renderToolStdout(result));
3150
- const stderr = renderToolStderr(result, exitCode);
3151
- const metaLine = buildMetaLine(toolCall, result);
3279
+ const command = typeof result.command === "string" && result.command.length > 0 ? result.command : (() => {
3280
+ const unixCommand = formatToolCallAsUnixCommand(toolCall);
3281
+ if (unixCommand) {
3282
+ return unixCommand;
3283
+ }
3284
+ const parts = [toolCall.name];
3285
+ for (const [name, value] of Object.entries(toolCall.parameters ?? {})) {
3286
+ if (value === void 0 || value === null) {
3287
+ continue;
3288
+ }
3289
+ if (typeof value === "boolean") {
3290
+ parts.push(value ? `--${name}` : `--no-${name}`);
3291
+ continue;
3292
+ }
3293
+ if (typeof value === "string" && !value.includes("\n") && !/\s/.test(value)) {
3294
+ parts.push(`--${name}`, value);
3295
+ continue;
3296
+ }
3297
+ parts.push(`--${name}`, JSON.stringify(value));
3298
+ }
3299
+ return parts.join(" ");
3300
+ })();
3301
+ const stdout = truncatePresentationOutput(renderToolStdout(result), toolCall);
3302
+ const stderr = typeof result.stderr === "string" && result.stderr.length > 0 ? result.stderr : exitCode !== 0 && typeof result.error === "string" ? result.error : "";
3303
+ const metaLine = (() => {
3304
+ const commandName = result.command_name;
3305
+ const route = result.route;
3306
+ const metadata = {
3307
+ tool: typeof commandName === "string" ? commandName : toolCall.name,
3308
+ route: typeof route === "string" ? route : toolCall.name
3309
+ };
3310
+ for (const source of [toolCall.parameters ?? {}, result]) {
3311
+ for (const key of ["path", "url", "query", "taskId", "task_id", "pattern"]) {
3312
+ const value = source[key];
3313
+ if (typeof value === "string" && value.length > 0) {
3314
+ metadata[key] = value;
3315
+ }
3316
+ }
3317
+ }
3318
+ const pairs = Object.entries(metadata);
3319
+ if (pairs.length === 0) {
3320
+ return "";
3321
+ }
3322
+ return `[meta] ${pairs.map(([key, value]) => `${key}=${typeof value === "string" ? JSON.stringify(value) : String(value)}`).join(" ")}`;
3323
+ })();
3152
3324
  const lines = [`$ ${command}`];
3153
3325
  if (stdout) {
3154
3326
  lines.push(stdout);
@@ -3167,7 +3339,8 @@ ${stderr}`);
3167
3339
  if (metaLine) {
3168
3340
  lines.push(metaLine);
3169
3341
  }
3170
- lines.push(`[exit:${exitCode} | ${formatDuration(durationMs)}]`);
3342
+ const duration = durationMs >= 1e3 ? `${(durationMs / 1e3).toFixed(1)}s` : `${Math.max(0, Math.round(durationMs))}ms`;
3343
+ lines.push(`[exit:${exitCode} | ${duration}]`);
3171
3344
  return lines.join("\n");
3172
3345
  }
3173
3346
  function parseToolResultMessage(content) {
@@ -3212,7 +3385,14 @@ function parseToolResultMessage(content) {
3212
3385
  const exitMatch = line.match(/^\[exit:(-?\d+)\s*\|\s*([^\]]+)\]$/);
3213
3386
  if (exitMatch) {
3214
3387
  exitCode = Number(exitMatch[1]);
3215
- durationMs = parseDuration(exitMatch[2]);
3388
+ const rawDuration = exitMatch[2].trim().toLowerCase();
3389
+ if (rawDuration.endsWith("ms")) {
3390
+ durationMs = Number(rawDuration.slice(0, -2)) || 0;
3391
+ } else if (rawDuration.endsWith("s")) {
3392
+ durationMs = Math.round((Number(rawDuration.slice(0, -1)) || 0) * 1e3);
3393
+ } else {
3394
+ durationMs = Number(rawDuration) || 0;
3395
+ }
3216
3396
  inStderr = false;
3217
3397
  continue;
3218
3398
  }
@@ -3222,7 +3402,36 @@ function parseToolResultMessage(content) {
3222
3402
  stdoutLines.push(line);
3223
3403
  }
3224
3404
  }
3225
- const metadata = parseMetadata(metaLine);
3405
+ const metadata = (() => {
3406
+ if (!metaLine) {
3407
+ return {};
3408
+ }
3409
+ const values = {};
3410
+ const regex = /(\w+)=((?:"(?:[^"\\]|\\.)*")|\S+)/g;
3411
+ let match;
3412
+ while ((match = regex.exec(metaLine)) !== null) {
3413
+ const key = match[1];
3414
+ const rawValue = match[2];
3415
+ if (rawValue.startsWith('"')) {
3416
+ try {
3417
+ values[key] = JSON.parse(rawValue);
3418
+ } catch {
3419
+ values[key] = rawValue.slice(1, -1);
3420
+ }
3421
+ continue;
3422
+ }
3423
+ if (rawValue === "true") {
3424
+ values[key] = true;
3425
+ } else if (rawValue === "false") {
3426
+ values[key] = false;
3427
+ } else if (!Number.isNaN(Number(rawValue))) {
3428
+ values[key] = Number(rawValue);
3429
+ } else {
3430
+ values[key] = rawValue;
3431
+ }
3432
+ }
3433
+ return values;
3434
+ })();
3226
3435
  const stdout = stdoutLines.join("\n").trim();
3227
3436
  const stderr = stderrLines.join("\n").trim();
3228
3437
  const error = errorLine ?? (exitCode === 0 ? void 0 : stderr || void 0);
@@ -3298,116 +3507,122 @@ function renderToolStdout(result) {
3298
3507
  }
3299
3508
  return JSON.stringify(remainder, null, 2);
3300
3509
  }
3301
- function renderToolStderr(result, exitCode) {
3302
- if (typeof result.stderr === "string" && result.stderr.length > 0) {
3303
- return result.stderr;
3304
- }
3305
- if (exitCode !== 0 && typeof result.error === "string") {
3306
- return result.error;
3307
- }
3308
- return "";
3309
- }
3310
- function truncatePresentationOutput(output) {
3510
+ function truncatePresentationOutput(output, toolCall) {
3311
3511
  if (!output) {
3312
3512
  return "";
3313
3513
  }
3314
- const lines = output.split(/\r?\n/);
3315
- if (lines.length <= MAX_PRESENTATION_LINES && output.length <= MAX_PRESENTATION_CHARS) {
3514
+ const isBash = isBashLikeToolCall(toolCall);
3515
+ const truncation = isBash ? truncateTail(output, { maxLines: DEFAULT_MAX_LINES, maxBytes: DEFAULT_MAX_BYTES }) : truncateHead(output, { maxLines: DEFAULT_MAX_LINES, maxBytes: DEFAULT_MAX_BYTES });
3516
+ if (!truncation.truncated) {
3316
3517
  return output;
3317
3518
  }
3318
- const truncated = lines.slice(0, MAX_PRESENTATION_LINES).join("\n");
3319
- return `${truncated}
3320
- --- output truncated (${lines.length} lines, ${output.length} chars) ---
3321
- Use more specific commands, filters, or line ranges to narrow the result.`;
3322
- }
3323
- function formatPseudoCommand(toolCall) {
3324
- const unixCommand = formatToolCallAsUnixCommand(toolCall);
3325
- if (unixCommand) {
3326
- return unixCommand;
3519
+ const suffix = buildTruncationNotice(toolCall, truncation);
3520
+ if (!suffix) {
3521
+ return truncation.content;
3327
3522
  }
3328
- const parts = [toolCall.name];
3329
- for (const [name, value] of Object.entries(toolCall.parameters ?? {})) {
3330
- if (value === void 0 || value === null) {
3331
- continue;
3523
+ if (!truncation.content) {
3524
+ return suffix;
3525
+ }
3526
+ return `${truncation.content}
3527
+
3528
+ ${suffix}`;
3529
+ }
3530
+ function buildTruncationNotice(toolCall, truncation) {
3531
+ const kind = (() => {
3532
+ if (isBashLikeToolCall(toolCall)) {
3533
+ return "bash";
3332
3534
  }
3333
- if (typeof value === "boolean") {
3334
- parts.push(value ? `--${name}` : `--no-${name}`);
3335
- continue;
3535
+ const normalized = toolCall.name.toLowerCase();
3536
+ if (normalized.includes("read")) return "read";
3537
+ if (normalized === "ls" || normalized.includes("list")) return "ls";
3538
+ if (normalized.includes("grep") || normalized.includes("search")) return "grep";
3539
+ if (normalized.includes("find")) return "find";
3540
+ return "default";
3541
+ })();
3542
+ if (kind === "read") {
3543
+ if (truncation.firstLineExceedsLimit) {
3544
+ return `[Line 1 exceeds ${formatSize(truncation.maxBytes)} limit. Use bash to read a bounded byte range.]`;
3336
3545
  }
3337
- if (typeof value === "string" && !value.includes("\n") && !/\s/.test(value)) {
3338
- parts.push(`--${name}`, value);
3339
- continue;
3546
+ const endLine = Math.max(0, truncation.outputLines);
3547
+ const nextOffset = endLine + 1;
3548
+ if (truncation.truncatedBy === "lines") {
3549
+ return `[Showing lines 1-${endLine} of ${truncation.totalLines}. Use offset=${nextOffset} to continue.]`;
3340
3550
  }
3341
- parts.push(`--${name}`, JSON.stringify(value));
3551
+ return `[Showing lines 1-${endLine} of ${truncation.totalLines} (${formatSize(truncation.maxBytes)} limit). Use offset=${nextOffset} to continue.]`;
3342
3552
  }
3343
- return parts.join(" ");
3344
- }
3345
- function buildMetaLine(toolCall, result) {
3346
- const commandName = result.command_name;
3347
- const route = result.route;
3348
- const metadata = {
3349
- tool: typeof commandName === "string" ? commandName : toolCall.name,
3350
- route: typeof route === "string" ? route : toolCall.name
3351
- };
3352
- for (const source of [toolCall.parameters ?? {}, result]) {
3353
- for (const key of ["path", "url", "query", "taskId", "task_id", "pattern"]) {
3354
- const value = source[key];
3355
- if (typeof value === "string" && value.length > 0) {
3356
- metadata[key] = value;
3357
- }
3553
+ if (kind === "bash") {
3554
+ const startLine = truncation.totalLines - truncation.outputLines + 1;
3555
+ const endLine = truncation.totalLines;
3556
+ if (truncation.lastLinePartial) {
3557
+ return `[Showing last ${formatSize(truncation.outputBytes)} of line ${endLine} (line exceeds ${formatSize(truncation.maxBytes)}).]`;
3558
+ }
3559
+ if (truncation.truncatedBy === "lines") {
3560
+ return `[Showing lines ${startLine}-${endLine} of ${truncation.totalLines}.]`;
3358
3561
  }
3562
+ return `[Showing lines ${startLine}-${endLine} of ${truncation.totalLines} (${formatSize(truncation.maxBytes)} limit).]`;
3359
3563
  }
3360
- const pairs = Object.entries(metadata);
3361
- if (pairs.length === 0) {
3362
- return "";
3564
+ if (kind === "grep") {
3565
+ return `[${formatSize(truncation.maxBytes)} limit reached. Refine pattern or narrow path.]`;
3566
+ }
3567
+ if (kind === "find") {
3568
+ return `[${formatSize(truncation.maxBytes)} limit reached. Refine pattern or increase limit.]`;
3569
+ }
3570
+ if (kind === "ls") {
3571
+ return `[${formatSize(truncation.maxBytes)} limit reached. Use a narrower path.]`;
3363
3572
  }
3364
- return `[meta] ${pairs.map(([key, value]) => `${key}=${typeof value === "string" ? JSON.stringify(value) : String(value)}`).join(" ")}`;
3573
+ return `[Output truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines (${formatSize(truncation.outputBytes)} of ${formatSize(truncation.totalBytes)}).]`;
3365
3574
  }
3366
- function parseMetadata(text) {
3367
- if (!text) {
3368
- return {};
3575
+ function isBashLikeToolCall(toolCall) {
3576
+ if (toolCall.kind === "bash" || toolCall.kind === "background_bash") {
3577
+ return true;
3369
3578
  }
3370
- const values = {};
3371
- const regex = /(\w+)=((?:"(?:[^"\\]|\\.)*")|\S+)/g;
3372
- let match;
3373
- while ((match = regex.exec(text)) !== null) {
3374
- const key = match[1];
3375
- const rawValue = match[2];
3376
- if (rawValue.startsWith('"')) {
3377
- try {
3378
- values[key] = JSON.parse(rawValue);
3379
- } catch {
3380
- values[key] = rawValue.slice(1, -1);
3579
+ const normalized = toolCall.name.toLowerCase();
3580
+ return normalized === "bash" || normalized === "backgroundbash";
3581
+ }
3582
+ function utf8ByteLength(text) {
3583
+ if (!text) {
3584
+ return 0;
3585
+ }
3586
+ return new TextEncoder().encode(text).length;
3587
+ }
3588
+ function truncateStringToBytesFromEnd(str, maxBytes) {
3589
+ if (maxBytes <= 0) return "";
3590
+ let outputBytes = 0;
3591
+ let start = str.length;
3592
+ for (let i = str.length; i > 0; ) {
3593
+ let characterStart = i - 1;
3594
+ const code = str.charCodeAt(characterStart);
3595
+ let characterBytes;
3596
+ if (code >= 56320 && code <= 57343 && characterStart > 0) {
3597
+ const previous = str.charCodeAt(characterStart - 1);
3598
+ if (previous >= 55296 && previous <= 56319) {
3599
+ characterStart--;
3600
+ characterBytes = 4;
3601
+ } else {
3602
+ characterBytes = 3;
3381
3603
  }
3382
- continue;
3383
- }
3384
- if (rawValue === "true") {
3385
- values[key] = true;
3386
- } else if (rawValue === "false") {
3387
- values[key] = false;
3388
- } else if (!Number.isNaN(Number(rawValue))) {
3389
- values[key] = Number(rawValue);
3604
+ } else if (code >= 55296 && code <= 56319) {
3605
+ characterBytes = 3;
3390
3606
  } else {
3391
- values[key] = rawValue;
3607
+ characterBytes = code <= 127 ? 1 : code <= 2047 ? 2 : 3;
3392
3608
  }
3609
+ if (outputBytes + characterBytes > maxBytes) break;
3610
+ outputBytes += characterBytes;
3611
+ start = characterStart;
3612
+ i = characterStart;
3393
3613
  }
3394
- return values;
3614
+ return str.slice(start);
3395
3615
  }
3396
- function formatDuration(durationMs) {
3397
- if (durationMs >= 1e3) {
3398
- return `${(durationMs / 1e3).toFixed(1)}s`;
3616
+ function formatSize(bytes) {
3617
+ if (bytes < 1024) {
3618
+ return `${bytes}B`;
3399
3619
  }
3400
- return `${Math.max(0, Math.round(durationMs))}ms`;
3401
- }
3402
- function parseDuration(raw) {
3403
- const trimmed = raw.trim().toLowerCase();
3404
- if (trimmed.endsWith("ms")) {
3405
- return Number(trimmed.slice(0, -2)) || 0;
3620
+ const kb = bytes / 1024;
3621
+ if (kb < 1024) {
3622
+ return `${kb.toFixed(1)}KB`;
3406
3623
  }
3407
- if (trimmed.endsWith("s")) {
3408
- return Math.round((Number(trimmed.slice(0, -1)) || 0) * 1e3);
3409
- }
3410
- return Number(trimmed) || 0;
3624
+ const mb = kb / 1024;
3625
+ return `${mb.toFixed(1)}MB`;
3411
3626
  }
3412
3627
 
3413
3628
  // src/agent-response-parser.ts
@@ -3779,10 +3994,7 @@ var AgentLoop = class {
3779
3994
  if (this.deps.formatToolResult) {
3780
3995
  result = this.deps.formatToolResult(result, tc.name);
3781
3996
  }
3782
- let resultStr = formatToolResultMessage(tc, result);
3783
- resultStr = truncateToolResult(resultStr, {
3784
- strategy: "head-tail"
3785
- });
3997
+ const resultStr = formatToolResultMessage(tc, result);
3786
3998
  if (wasTruncated && this._truncatedToolInfo && i === 0) {
3787
3999
  this._truncatedToolInfo.executionSucceeded = result.success === true;
3788
4000
  }
@@ -7485,6 +7697,6 @@ async function executeToolLoopStep(options) {
7485
7697
  };
7486
7698
  }
7487
7699
 
7488
- export { AGENT_MACHINE_STATES, AgentLoop, AgentMemoryLayer, ApiError, BackgroundBashRunCommand, BaseMemoryLayer, BaseValidationEnforcer, BashRunCommand, CODE_QUALITY_RULE_LINE, CharTokenEstimator, DEFAULT_AGENT_FALLBACK_SYSTEM_PROMPT, DEFAULT_ALLOWED_RUN_TARGETS, DEFAULT_RUN_COMMAND_REGISTRY, DEFAULT_THREAD_AUTO_SCROLL_BOTTOM_THRESHOLD, DEFAULT_TOOL_MEMORY_EXTRACTOR, ERROR_RECOVERY_RULE_LINE, ERROR_TRUNCATED_RESPONSE, INCREMENTAL_TESTING_RULE_LINE, JUST_BASH_SCRIPT_EXECUTION_RESTRICTION_LINES, JUST_BASH_SHELL_NATIVE_WORKFLOW_COMMAND_EXAMPLES, LLMClient, LLMResponseSchema, MAX_TOOL_RESULT_CHARS, PORT_CONFLICT_RULE_LINE, PendingAgentMessageBuffer, ProxyTool, ROOT_CAUSES_RULE_LINE, RunCommand, RunCommandRegistry, SHARED_TOOL_CALL_EXAMPLE_LINES, SHARED_TOOL_USAGE_RULE, SINGLE_TOOL_CALL_RUN_LINE_EXAMPLE, SKILL_INVOKE_READ_RULE_LINE, STANDARD_TOOL_CALL_FORMAT_RULES, SUPPORTED_RUN_TARGETS, StreamingToolParser, SubAgentTool, TODO_LIST_FIRST_RESPONSE_RULE_LINE, TOOL_CALL_SEPARATOR_RULE, Tool, ToolCallSchema, ToolLoopAgentRuntime, ToolRegistry, ToolRunCommand, VALIDATE_AFTER_CHANGES_RULE_LINE, WebToolLoopAgentRuntime, WebValidationEnforcer, agentMachine, applyIdleWebAgentState, applyInitialWebAgentRunState, buildAgentIdentityLine, buildAgentSystemPrompt, buildCompactionEntry, buildCoreStaticRules, buildNoStructuredResponseFoundError, buildSkillAwareStaticContext, buildSkillsSection, buildStepUserMessage, buildToolLogRevealFrames, buildToolUsageExample, buildValidationErrorMessage, buildWebRuntimeRules, buildWorkspaceCodingStaticRules, canonicalizeCompactionText, coerceToolCallToDefinition, configure, containsStandaloneStructuredInvocationStart, createAgentMemoryLayer, createAppendToolsSectionCustomizer, createBackgroundBashDefinition, createConversationSink, createCustomRunCommandRegistry, createInitialWebAgentState, createRunCommandRuntimeBindings, createRuntimeStore, createToolAgentMessage, createToolRegistry, createToolsSectionOverrideCustomizer, createWebAgentMessageIdGenerator, createWebSearchToolActions, createWebToolLoopCallbacks, decodeEscapedShellText, defineRuntimeController, enrichToolResultWithUnixMetadata, executeBackgroundUnixCommandString, executeToolCallWithRunCommands, executeToolLoopStep, executeToolSafe, executeUnixCommandString, extractPrimaryCommandMetadata, extractTruncatedToolInfo, formatToolCallAsUnixCommand, formatToolDefinitions, formatToolResultMessage, formatToolsSection, formatUnixToolSurface, formatZodValidationError, getDiagnosticSummaryLine, getProviderConfig, getRunCommandPromptAvailability, getToolLogSummaryLine, isBackgroundBashToolCall, isBashToolCall, limitEntriesByRecency, machineStateToWebAgentPhase, mapConversationRoleToAgentRole, parseAgentResponse, parseResponseWithRecovery, parseStructuredAgentText, parseToolResultMessage, parseUnixToolCommand, readDiagnosticLevel, readDiagnosticSource, resolveToolDefinitionForInvocation, runStructuredLLMCompaction, selectLatestByKey, shouldAutoScrollThread, shouldSkipStepUserMessage, stripDiagnosticMessagePrefix, suppressWebValidationLog, tokenizeUnixCommand, truncateToolResult };
7700
+ export { AGENT_MACHINE_STATES, AgentLoop, AgentMemoryLayer, ApiError, BackgroundBashRunCommand, BaseMemoryLayer, BaseValidationEnforcer, BashRunCommand, CODE_QUALITY_RULE_LINE, CharTokenEstimator, DEFAULT_AGENT_FALLBACK_SYSTEM_PROMPT, DEFAULT_ALLOWED_RUN_TARGETS, DEFAULT_RUN_COMMAND_REGISTRY, DEFAULT_THREAD_AUTO_SCROLL_BOTTOM_THRESHOLD, DEFAULT_TOOL_MEMORY_EXTRACTOR, ERROR_RECOVERY_RULE_LINE, ERROR_TRUNCATED_RESPONSE, INCREMENTAL_TESTING_RULE_LINE, JUST_BASH_SCRIPT_EXECUTION_RESTRICTION_LINES, JUST_BASH_SHELL_NATIVE_WORKFLOW_COMMAND_EXAMPLES, LLMClient, LLMResponseSchema, PORT_CONFLICT_RULE_LINE, PendingAgentMessageBuffer, ProxyTool, ROOT_CAUSES_RULE_LINE, RunCommand, RunCommandRegistry, SHARED_TOOL_CALL_EXAMPLE_LINES, SHARED_TOOL_USAGE_RULE, SINGLE_TOOL_CALL_RUN_LINE_EXAMPLE, SKILL_INVOKE_READ_RULE_LINE, STANDARD_TOOL_CALL_FORMAT_RULES, SUPPORTED_RUN_TARGETS, StreamingToolParser, SubAgentTool, TODO_LIST_FIRST_RESPONSE_RULE_LINE, TOOL_CALL_SEPARATOR_RULE, Tool, ToolCallSchema, ToolLoopAgentRuntime, ToolRegistry, ToolRunCommand, VALIDATE_AFTER_CHANGES_RULE_LINE, WebToolLoopAgentRuntime, WebValidationEnforcer, agentMachine, applyIdleWebAgentState, applyInitialWebAgentRunState, buildAgentIdentityLine, buildAgentSystemPrompt, buildCompactionEntry, buildCoreStaticRules, buildNoStructuredResponseFoundError, buildSkillAwareStaticContext, buildSkillsSection, buildStepUserMessage, buildToolLogRevealFrames, buildToolUsageExample, buildValidationErrorMessage, buildWebRuntimeRules, buildWorkspaceCodingStaticRules, canonicalizeCompactionText, coerceToolCallToDefinition, configure, containsStandaloneStructuredInvocationStart, createAgentMemoryLayer, createAppendToolsSectionCustomizer, createBackgroundBashDefinition, createConversationSink, createCustomRunCommandRegistry, createInitialWebAgentState, createRunCommandRuntimeBindings, createRuntimeStore, createToolAgentMessage, createToolRegistry, createToolsSectionOverrideCustomizer, createWebAgentMessageIdGenerator, createWebSearchToolActions, createWebToolLoopCallbacks, decodeEscapedShellText, defineRuntimeController, enrichToolResultWithUnixMetadata, executeBackgroundUnixCommandString, executeToolCallWithRunCommands, executeToolLoopStep, executeToolSafe, executeUnixCommandString, extractPrimaryCommandMetadata, extractTruncatedToolInfo, formatToolCallAsUnixCommand, formatToolDefinitions, formatToolResultMessage, formatToolsSection, formatUnixToolSurface, formatZodValidationError, getDiagnosticSummaryLine, getProviderConfig, getRunCommandPromptAvailability, getToolLogSummaryLine, isBackgroundBashToolCall, isBashToolCall, limitEntriesByRecency, machineStateToWebAgentPhase, mapConversationRoleToAgentRole, parseAgentResponse, parseResponseWithRecovery, parseStructuredAgentText, parseToolResultMessage, parseUnixToolCommand, readDiagnosticLevel, readDiagnosticSource, resolveToolDefinitionForInvocation, runStructuredLLMCompaction, selectLatestByKey, shouldAutoScrollThread, shouldSkipStepUserMessage, stripDiagnosticMessagePrefix, suppressWebValidationLog, tokenizeUnixCommand };
7489
7701
  //# sourceMappingURL=index.js.map
7490
7702
  //# sourceMappingURL=index.js.map