@namzu/sdk 62.6.1 → 62.7.0
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 +29 -0
- package/dist/agents/QueryAgent.d.ts.map +1 -1
- package/dist/agents/QueryAgent.js +5 -0
- package/dist/agents/QueryAgent.js.map +1 -1
- package/dist/agents/examples/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/examples/SupervisorAgent.js +1 -0
- package/dist/agents/examples/SupervisorAgent.js.map +1 -1
- package/dist/agents/explore.d.ts.map +1 -1
- package/dist/agents/explore.js +2 -1
- package/dist/agents/explore.js.map +1 -1
- package/dist/compaction/index.d.ts +1 -1
- package/dist/compaction/index.d.ts.map +1 -1
- package/dist/compaction/index.js +1 -1
- package/dist/compaction/index.js.map +1 -1
- package/dist/compaction/model-summary.js +2 -2
- package/dist/compaction/model-summary.js.map +1 -1
- package/dist/compaction/summary.d.ts +16 -1
- package/dist/compaction/summary.d.ts.map +1 -1
- package/dist/compaction/summary.js +25 -2
- package/dist/compaction/summary.js.map +1 -1
- package/dist/config/runtime.d.ts +8 -0
- package/dist/config/runtime.d.ts.map +1 -1
- package/dist/config/runtime.js +15 -0
- package/dist/config/runtime.js.map +1 -1
- package/dist/execution/workflow/runtime.d.ts.map +1 -1
- package/dist/execution/workflow/runtime.js +3 -0
- package/dist/execution/workflow/runtime.js.map +1 -1
- package/dist/execution/workflow/types.d.ts +8 -0
- package/dist/execution/workflow/types.d.ts.map +1 -1
- package/dist/manager/agent/child-session.d.ts +12 -0
- package/dist/manager/agent/child-session.d.ts.map +1 -1
- package/dist/manager/agent/child-session.js +29 -0
- package/dist/manager/agent/child-session.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +8 -0
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/session/turn-recorder.d.ts +13 -2
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +57 -3
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +3 -3
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +5 -3
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +5 -1
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/retry.d.ts +25 -0
- package/dist/provider/retry.d.ts.map +1 -1
- package/dist/provider/retry.js +28 -0
- package/dist/provider/retry.js.map +1 -1
- package/dist/public-runtime.d.ts +3 -3
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +3 -3
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +4 -2
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +5 -2
- package/dist/public-tools.js.map +1 -1
- package/dist/runtime/query/auto-review/classifier.d.ts +7 -1
- package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/classifier.js +8 -4
- package/dist/runtime/query/auto-review/classifier.js.map +1 -1
- package/dist/runtime/query/auto-review/prompt.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/prompt.js +2 -0
- package/dist/runtime/query/auto-review/prompt.js.map +1 -1
- package/dist/runtime/query/auto-review/script-evidence.d.ts +93 -0
- package/dist/runtime/query/auto-review/script-evidence.d.ts.map +1 -0
- package/dist/runtime/query/auto-review/script-evidence.js +566 -0
- package/dist/runtime/query/auto-review/script-evidence.js.map +1 -0
- package/dist/runtime/query/checkpoint.d.ts +13 -0
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +37 -0
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +38 -1
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +130 -11
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/finalize-turn.d.ts +7 -1
- package/dist/runtime/query/finalize-turn.d.ts.map +1 -1
- package/dist/runtime/query/finalize-turn.js +2 -0
- package/dist/runtime/query/finalize-turn.js.map +1 -1
- package/dist/runtime/query/index.d.ts +8 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +7 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +32 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +158 -10
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts +12 -0
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +48 -1
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js +5 -0
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +3 -3
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/prelude-lease.d.ts.map +1 -1
- package/dist/runtime/query/prelude-lease.js +22 -0
- package/dist/runtime/query/prelude-lease.js.map +1 -1
- package/dist/runtime/query/prepare-turn.d.ts.map +1 -1
- package/dist/runtime/query/prepare-turn.js +13 -4
- package/dist/runtime/query/prepare-turn.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +29 -0
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +2 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +1 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/runtime/query/turn/completion-audit.d.ts +27 -1
- package/dist/runtime/query/turn/completion-audit.d.ts.map +1 -1
- package/dist/runtime/query/turn/completion-audit.js +71 -6
- package/dist/runtime/query/turn/completion-audit.js.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.d.ts +113 -0
- package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -0
- package/dist/runtime/query/turn/outcome-ledger.js +578 -0
- package/dist/runtime/query/turn/outcome-ledger.js.map +1 -0
- package/dist/sandbox/glob-segment.d.ts +8 -1
- package/dist/sandbox/glob-segment.d.ts.map +1 -1
- package/dist/sandbox/glob-segment.js +28 -9
- package/dist/sandbox/glob-segment.js.map +1 -1
- package/dist/store/session-log/index.d.ts +1 -0
- package/dist/store/session-log/index.d.ts.map +1 -1
- package/dist/store/session-log/index.js +1 -0
- package/dist/store/session-log/index.js.map +1 -1
- package/dist/store/session-log/turn-outcome.d.ts +37 -0
- package/dist/store/session-log/turn-outcome.d.ts.map +1 -0
- package/dist/store/session-log/turn-outcome.js +77 -0
- package/dist/store/session-log/turn-outcome.js.map +1 -0
- package/dist/tools/builtins/bash.js +1 -1
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/edit-apply.d.ts.map +1 -1
- package/dist/tools/builtins/edit-apply.js +24 -3
- package/dist/tools/builtins/edit-apply.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts +31 -17
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +92 -27
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/glob.js +1 -1
- package/dist/tools/builtins/glob.js.map +1 -1
- package/dist/tools/builtins/grep.js +1 -1
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/notebook-guard.d.ts +19 -0
- package/dist/tools/builtins/notebook-guard.d.ts.map +1 -0
- package/dist/tools/builtins/notebook-guard.js +75 -0
- package/dist/tools/builtins/notebook-guard.js.map +1 -0
- package/dist/tools/builtins/read-render.d.ts.map +1 -1
- package/dist/tools/builtins/read-render.js +8 -2
- package/dist/tools/builtins/read-render.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +14 -1
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/coordinator/agent.d.ts.map +1 -1
- package/dist/tools/coordinator/agent.js +25 -6
- package/dist/tools/coordinator/agent.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +6 -1
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/coordinator/outcome-record.d.ts +22 -0
- package/dist/tools/coordinator/outcome-record.d.ts.map +1 -0
- package/dist/tools/coordinator/outcome-record.js +91 -0
- package/dist/tools/coordinator/outcome-record.js.map +1 -0
- package/dist/tools/defineTool.d.ts +2 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +1 -0
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/file-read-tracker.d.ts +23 -2
- package/dist/tools/file-read-tracker.d.ts.map +1 -1
- package/dist/tools/file-read-tracker.js +37 -2
- package/dist/tools/file-read-tracker.js.map +1 -1
- package/dist/tools/untrusted-envelope.d.ts +6 -0
- package/dist/tools/untrusted-envelope.d.ts.map +1 -1
- package/dist/tools/untrusted-envelope.js +22 -1
- package/dist/tools/untrusted-envelope.js.map +1 -1
- package/dist/toolsets/manager.d.ts.map +1 -1
- package/dist/toolsets/manager.js +3 -4
- package/dist/toolsets/manager.js.map +1 -1
- package/dist/toolsets/validation-issues.d.ts +27 -0
- package/dist/toolsets/validation-issues.d.ts.map +1 -0
- package/dist/toolsets/validation-issues.js +83 -0
- package/dist/toolsets/validation-issues.js.map +1 -0
- package/dist/turn/memory-recall.d.ts +13 -0
- package/dist/turn/memory-recall.d.ts.map +1 -1
- package/dist/turn/memory-recall.js +18 -0
- package/dist/turn/memory-recall.js.map +1 -1
- package/dist/types/agent/base.d.ts +19 -0
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/query.d.ts +2 -0
- package/dist/types/agent/query.d.ts.map +1 -1
- package/dist/types/common/index.d.ts +17 -0
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/index.js +8 -1
- package/dist/types/common/index.js.map +1 -1
- package/dist/types/hitl/index.d.ts +22 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/session/config.d.ts +20 -0
- package/dist/types/session/config.d.ts.map +1 -1
- package/dist/types/session/events.d.ts +3 -3
- package/dist/types/session/events.d.ts.map +1 -1
- package/dist/types/session/index.d.ts +1 -0
- package/dist/types/session/index.d.ts.map +1 -1
- package/dist/types/session/index.js +1 -0
- package/dist/types/session/index.js.map +1 -1
- package/dist/types/session/outcome.d.ts +95 -0
- package/dist/types/session/outcome.d.ts.map +1 -0
- package/dist/types/session/outcome.js +45 -0
- package/dist/types/session/outcome.js.map +1 -0
- package/dist/types/session/prepare-step.d.ts +2 -0
- package/dist/types/session/prepare-step.d.ts.map +1 -1
- package/dist/types/session/records.d.ts +167 -2
- package/dist/types/session/records.d.ts.map +1 -1
- package/dist/types/session/records.js +42 -0
- package/dist/types/session/records.js.map +1 -1
- package/dist/types/session/turn.d.ts +18 -0
- package/dist/types/session/turn.d.ts.map +1 -1
- package/dist/types/session/turn.js.map +1 -1
- package/dist/types/tool/index.d.ts +30 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/package.json +1 -1
- package/src/agents/QueryAgent.ts +5 -0
- package/src/agents/examples/SupervisorAgent.ts +1 -0
- package/src/agents/explore.ts +2 -1
- package/src/compaction/index.ts +1 -0
- package/src/compaction/model-summary.ts +2 -2
- package/src/compaction/summary.ts +30 -2
- package/src/config/runtime.ts +15 -0
- package/src/execution/workflow/runtime.ts +4 -0
- package/src/execution/workflow/types.ts +9 -0
- package/src/manager/agent/child-session.ts +36 -0
- package/src/manager/agent/lifecycle.ts +9 -0
- package/src/manager/session/turn-recorder.ts +62 -3
- package/src/pricing/rates.source.json +1 -1
- package/src/prompt/coding-agent-doctrine.ts +5 -3
- package/src/provider/fallback.ts +6 -1
- package/src/provider/retry.ts +51 -0
- package/src/public-runtime.ts +10 -1
- package/src/public-tools.ts +6 -1
- package/src/runtime/query/auto-review/classifier.ts +21 -5
- package/src/runtime/query/auto-review/prompt.ts +2 -0
- package/src/runtime/query/auto-review/script-evidence.ts +618 -0
- package/src/runtime/query/checkpoint.ts +53 -1
- package/src/runtime/query/executor.ts +159 -19
- package/src/runtime/query/finalize-turn.ts +8 -1
- package/src/runtime/query/index.ts +19 -0
- package/src/runtime/query/iteration/index.ts +167 -14
- package/src/runtime/query/iteration/phases/compaction.ts +53 -3
- package/src/runtime/query/iteration/phases/context.ts +6 -0
- package/src/runtime/query/iteration/stream-turn.ts +3 -3
- package/src/runtime/query/prelude-lease.ts +19 -0
- package/src/runtime/query/prepare-turn.ts +13 -4
- package/src/runtime/query/review-policy.ts +33 -0
- package/src/runtime/query/tooling.ts +3 -0
- package/src/runtime/query/turn/completion-audit.ts +76 -5
- package/src/runtime/query/turn/outcome-ledger.ts +633 -0
- package/src/sandbox/glob-segment.ts +48 -24
- package/src/store/session-log/index.ts +7 -0
- package/src/store/session-log/turn-outcome.ts +84 -0
- package/src/tools/builtins/bash.ts +1 -1
- package/src/tools/builtins/edit-apply.ts +26 -4
- package/src/tools/builtins/edit.ts +106 -41
- package/src/tools/builtins/glob.ts +1 -1
- package/src/tools/builtins/grep.ts +1 -1
- package/src/tools/builtins/notebook-guard.ts +76 -0
- package/src/tools/builtins/read-render.ts +12 -2
- package/src/tools/builtins/write-file.ts +12 -1
- package/src/tools/coordinator/agent.ts +31 -7
- package/src/tools/coordinator/index.ts +6 -1
- package/src/tools/coordinator/outcome-record.ts +93 -0
- package/src/tools/defineTool.ts +3 -0
- package/src/tools/file-read-tracker.ts +51 -2
- package/src/tools/untrusted-envelope.ts +23 -1
- package/src/toolsets/manager.ts +6 -10
- package/src/toolsets/validation-issues.ts +97 -0
- package/src/turn/memory-recall.ts +28 -0
- package/src/types/agent/base.ts +20 -0
- package/src/types/agent/query.ts +2 -0
- package/src/types/common/index.ts +25 -1
- package/src/types/hitl/index.ts +27 -0
- package/src/types/session/config.ts +20 -0
- package/src/types/session/events.ts +3 -3
- package/src/types/session/index.ts +1 -0
- package/src/types/session/outcome.ts +139 -0
- package/src/types/session/prepare-step.ts +2 -0
- package/src/types/session/records.ts +67 -1
- package/src/types/session/turn.ts +19 -0
- package/src/types/tool/index.ts +30 -0
|
@@ -27,6 +27,7 @@ import { compressShellOutput } from '../../utils/shell-compress.js';
|
|
|
27
27
|
import { parseStructuredResultJson } from '../../utils/structured-result-json.js';
|
|
28
28
|
import { ensureScratchpadDirectory } from '../../utils/temp.js';
|
|
29
29
|
import { bindOwner } from '../jobs/registry.js';
|
|
30
|
+
import { analyzeLaunches, changedSinceRead, readLaunchedScripts, } from './auto-review/script-evidence.js';
|
|
30
31
|
import { stillRunningResult } from './detached-calls.js';
|
|
31
32
|
import { formatFailedToolOutput, hookNote, isUnregistered, prepareDirectCall, runPreToolHook, unknownToolMessage, } from './executor/tool-call-admission.js';
|
|
32
33
|
import { describeVisibleFileEvidence, visibleFileEvidence, } from './file-evidence-context.js';
|
|
@@ -252,6 +253,9 @@ export class ToolExecutor {
|
|
|
252
253
|
toolCallBudget;
|
|
253
254
|
preparedBatches = new WeakSet();
|
|
254
255
|
preparedBashDirectories = new WeakMap();
|
|
256
|
+
/** Script files a classifier read for a call, by call id, to be checked again when it runs. */
|
|
257
|
+
reviewedScripts = new Map();
|
|
258
|
+
startedAt = Date.now();
|
|
255
259
|
/** Ephemeral proof of actual execution; restored messages do not acquire it. */
|
|
256
260
|
recordedObservations = new Map();
|
|
257
261
|
/** Set per turn by the orchestrator; see {@link setStepAllowedTools}. */
|
|
@@ -463,6 +467,44 @@ export class ToolExecutor {
|
|
|
463
467
|
fileEvidenceEntries(messages) {
|
|
464
468
|
return visibleFileEvidence(messages, this.fileReadTracker, this.config.workingDirectory, this.sandboxed);
|
|
465
469
|
}
|
|
470
|
+
/**
|
|
471
|
+
* The script files a shell line launches that the agent wrote or that
|
|
472
|
+
* appeared during the session, read now for the auto-mode classifier.
|
|
473
|
+
* Remembers what was read for `callId`, so the file can be checked again
|
|
474
|
+
* just before the call runs.
|
|
475
|
+
*/
|
|
476
|
+
async launchedScripts(callId, line, dialect) {
|
|
477
|
+
if (this.sandboxed) {
|
|
478
|
+
// A sandbox's files are not on this host's disk. Say so rather than
|
|
479
|
+
// letting a launch inside one look like a launch of nothing.
|
|
480
|
+
const analysis = analyzeLaunches(line, dialect);
|
|
481
|
+
const named = analysis.launches.map((l) => l.path);
|
|
482
|
+
return named.length === 0 && analysis.unresolved.length === 0
|
|
483
|
+
? []
|
|
484
|
+
: [
|
|
485
|
+
{
|
|
486
|
+
path: named[0] ?? '(launch form not resolved)',
|
|
487
|
+
origin: 'unknown',
|
|
488
|
+
state: 'unreadable',
|
|
489
|
+
note: 'the command runs in a sandbox whose files are not read for this review, so what the script does is not known',
|
|
490
|
+
},
|
|
491
|
+
];
|
|
492
|
+
}
|
|
493
|
+
const evidence = await readLaunchedScripts(line, dialect, {
|
|
494
|
+
cwd: effectiveBashWorkingDirectory(this.config.sessionId, this.config.workingDirectory, {
|
|
495
|
+
sandboxed: false,
|
|
496
|
+
}),
|
|
497
|
+
startedAt: this.fileReadTracker.startedAt ?? this.startedAt,
|
|
498
|
+
...(this.fileReadTracker.authoredFingerprint
|
|
499
|
+
? { authoredFingerprint: (key) => this.fileReadTracker.authoredFingerprint?.(key) }
|
|
500
|
+
: {}),
|
|
501
|
+
});
|
|
502
|
+
if (evidence.watch.length > 0)
|
|
503
|
+
this.reviewedScripts.set(callId, evidence.watch);
|
|
504
|
+
else
|
|
505
|
+
this.reviewedScripts.delete(callId);
|
|
506
|
+
return evidence.scripts;
|
|
507
|
+
}
|
|
466
508
|
/** The whole of the evidence as one text, from the same ledger. No filesystem I/O. */
|
|
467
509
|
describeFileEvidence(messages) {
|
|
468
510
|
return describeVisibleFileEvidence(messages, this.fileReadTracker, this.config.workingDirectory, this.sandboxed);
|
|
@@ -655,12 +697,13 @@ export class ToolExecutor {
|
|
|
655
697
|
const earlierPaths = [];
|
|
656
698
|
for (const toolCall of response.message.toolCalls ?? []) {
|
|
657
699
|
const prepared = await prepareDirectCall(this.admissionHost(), toolCall, !hostModifiedCallIds?.has(toolCall.id));
|
|
658
|
-
const
|
|
700
|
+
const beforeReview = await this.refusedBeforeReview(prepared, earlierPaths);
|
|
659
701
|
const path = inputPathOf(prepared);
|
|
660
702
|
if (path !== undefined)
|
|
661
703
|
earlierPaths.push(path);
|
|
704
|
+
this.admitScratchpad(beforeReview);
|
|
705
|
+
const call = await this.refusedOutsideRoot(beforeReview);
|
|
662
706
|
calls.set(toolCall.id, call);
|
|
663
|
-
this.admitScratchpad(call);
|
|
664
707
|
const escalation = await this.escalationOrUnfinished(call);
|
|
665
708
|
if (escalation)
|
|
666
709
|
escalations.set(toolCall.id, escalation);
|
|
@@ -670,6 +713,52 @@ export class ToolExecutor {
|
|
|
670
713
|
this.config.abortSignal.throwIfAborted();
|
|
671
714
|
return this.publishPreparedBatch(calls, escalations, scratchpadWrites);
|
|
672
715
|
}
|
|
716
|
+
/**
|
|
717
|
+
* A file tool's path outside the roots, refused with the host's own words
|
|
718
|
+
* (`QueryParams.outsideRootRefusal`) instead of the tool's generic one.
|
|
719
|
+
*
|
|
720
|
+
* It takes the place of the call like any refusal found while preparing it,
|
|
721
|
+
* so it holds in every permission mode and reaches no reviewer. Only a turn
|
|
722
|
+
* that refuses (`outsideRootAccess: 'refuse'`) and has no sandbox is looked
|
|
723
|
+
* at, and only a tool that declares `pathArgument`. The exemptions are the
|
|
724
|
+
* review's: the scratch folder is a root, and so is this session's retained
|
|
725
|
+
* output for `read`.
|
|
726
|
+
*/
|
|
727
|
+
async refusedOutsideRoot(call) {
|
|
728
|
+
const note = this.config.outsideRootRefusal;
|
|
729
|
+
if (call.kind !== 'ready' || note === undefined)
|
|
730
|
+
return call;
|
|
731
|
+
if (this.config.outsideRootAccess !== 'refuse' || this.sandboxed)
|
|
732
|
+
return call;
|
|
733
|
+
const tool = this.config.tools.get(call.toolName);
|
|
734
|
+
if (tool?.pathArgument === undefined)
|
|
735
|
+
return call;
|
|
736
|
+
if (call.input === null || typeof call.input !== 'object')
|
|
737
|
+
return call;
|
|
738
|
+
const value = call.input[tool.pathArgument];
|
|
739
|
+
if (typeof value !== 'string')
|
|
740
|
+
return call;
|
|
741
|
+
try {
|
|
742
|
+
const retained = tool.name === 'read' && (await resolveRetainedOutput(this.outputDirectory(), value));
|
|
743
|
+
if (retained)
|
|
744
|
+
return call;
|
|
745
|
+
const outside = await pathOutsideRoots(this.rootsNow(), value);
|
|
746
|
+
if (outside === undefined)
|
|
747
|
+
return call;
|
|
748
|
+
return {
|
|
749
|
+
kind: 'synthetic',
|
|
750
|
+
toolCall: call.toolCall,
|
|
751
|
+
toolName: call.toolName,
|
|
752
|
+
input: call.input,
|
|
753
|
+
message: formatFailedToolOutput(undefined, `${outside} is outside the working directory. ${note}`),
|
|
754
|
+
isError: true,
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
catch {
|
|
758
|
+
this.config.abortSignal.throwIfAborted();
|
|
759
|
+
return call;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
673
762
|
/**
|
|
674
763
|
* A ready call the tool already knows cannot run, answered now instead of
|
|
675
764
|
* after a reviewer has been asked about it (`ToolDefinition.refuseBeforeReview`).
|
|
@@ -879,9 +968,10 @@ export class ToolExecutor {
|
|
|
879
968
|
const earlierPaths = [];
|
|
880
969
|
for (const toolCall of response.message.toolCalls ?? []) {
|
|
881
970
|
if (changedCallIds.has(toolCall.id)) {
|
|
882
|
-
const
|
|
971
|
+
const beforeReview = await this.refusedBeforeReview(await prepareDirectCall(this.admissionHost(), toolCall, false), earlierPaths);
|
|
972
|
+
this.admitScratchpad(beforeReview);
|
|
973
|
+
const call = await this.refusedOutsideRoot(beforeReview);
|
|
883
974
|
calls.set(toolCall.id, call);
|
|
884
|
-
this.admitScratchpad(call);
|
|
885
975
|
const escalation = await this.escalationOrUnfinished(call);
|
|
886
976
|
if (escalation)
|
|
887
977
|
escalations.set(toolCall.id, escalation);
|
|
@@ -1123,7 +1213,18 @@ export class ToolExecutor {
|
|
|
1123
1213
|
let outcome;
|
|
1124
1214
|
started.add(toolCall.id);
|
|
1125
1215
|
try {
|
|
1126
|
-
|
|
1216
|
+
const reviewedScripts = this.reviewedScripts.get(toolCall.id);
|
|
1217
|
+
this.reviewedScripts.delete(toolCall.id);
|
|
1218
|
+
const moved = reviewedScripts === undefined ? undefined : await changedSinceRead(reviewedScripts);
|
|
1219
|
+
outcome =
|
|
1220
|
+
moved !== undefined
|
|
1221
|
+
? {
|
|
1222
|
+
toolCallId: toolCall.id,
|
|
1223
|
+
toolName: toolCall.function.name,
|
|
1224
|
+
output: `Error: ${moved} changed after the safety check read it, so the command was not run. Run it again and it will be checked against the new text.`,
|
|
1225
|
+
isError: true,
|
|
1226
|
+
}
|
|
1227
|
+
: await this.executeSingle(toolCall, ctx, recordObservation, () => progress.close(), preparedCall);
|
|
1127
1228
|
}
|
|
1128
1229
|
catch (error) {
|
|
1129
1230
|
// A call already answered with the placeholder has no batch
|
|
@@ -1312,6 +1413,7 @@ export class ToolExecutor {
|
|
|
1312
1413
|
failure ??= { error };
|
|
1313
1414
|
}
|
|
1314
1415
|
finally {
|
|
1416
|
+
this.reviewedScripts.delete(unit.toolCall.id);
|
|
1315
1417
|
settledUnit();
|
|
1316
1418
|
inFlight.delete(unit);
|
|
1317
1419
|
pump();
|
|
@@ -1611,7 +1713,7 @@ export class ToolExecutor {
|
|
|
1611
1713
|
toolName: name,
|
|
1612
1714
|
toolUseId: nestedId,
|
|
1613
1715
|
output: rawOutput,
|
|
1614
|
-
maxChars: this.config.
|
|
1716
|
+
maxChars: this.toolOutputCap(this.config.tools.get(name), false),
|
|
1615
1717
|
retainedPreviewChars: this.config.retainedToolPreviewChars,
|
|
1616
1718
|
spillDir: this.outputDirectory(),
|
|
1617
1719
|
recoveryRoutes: this.recoveryRoutes(),
|
|
@@ -2040,10 +2142,7 @@ export class ToolExecutor {
|
|
|
2040
2142
|
];
|
|
2041
2143
|
}
|
|
2042
2144
|
}
|
|
2043
|
-
|
|
2044
|
-
// cap only; a host that set the cap explicitly still gets it.
|
|
2045
|
-
const maxToolOutputChars = this.config.maxToolOutputChars ??
|
|
2046
|
-
(executedDefinition?.selfLimitingOutput === true ? 0 : DEFAULT_MAX_TOOL_OUTPUT_CHARS);
|
|
2145
|
+
const maxToolOutputChars = this.toolOutputCap(executedDefinition, true);
|
|
2047
2146
|
const sourceOutput = output;
|
|
2048
2147
|
// This owner-bound channel follows the selected receipt after both result
|
|
2049
2148
|
// screening and post-tool replacement. ToolResult.data and raw input can
|
|
@@ -2246,6 +2345,7 @@ export class ToolExecutor {
|
|
|
2246
2345
|
? { handoff: result.handoff }
|
|
2247
2346
|
: {}),
|
|
2248
2347
|
...(revealedTools !== undefined ? { revealedTools } : {}),
|
|
2348
|
+
...(result.facts !== undefined && !postOverride ? { facts: result.facts } : {}),
|
|
2249
2349
|
};
|
|
2250
2350
|
}
|
|
2251
2351
|
/**
|
|
@@ -2683,6 +2783,8 @@ export class ToolExecutor {
|
|
|
2683
2783
|
* `executing`, and records a failed activity for the trace.
|
|
2684
2784
|
*/
|
|
2685
2785
|
async recordDenial(toolCall, reason, preparedCall, declined) {
|
|
2786
|
+
// A call that does not run has no use for what a review read of its scripts.
|
|
2787
|
+
this.reviewedScripts.delete(toolCall.id);
|
|
2686
2788
|
const toolName = preparedCall?.toolName ?? toolCall.function.name;
|
|
2687
2789
|
let input = preparedCall?.input ?? {};
|
|
2688
2790
|
if (!preparedCall) {
|
|
@@ -2816,6 +2918,7 @@ export class ToolExecutor {
|
|
|
2816
2918
|
toolName,
|
|
2817
2919
|
output: outcome.output,
|
|
2818
2920
|
isError: outcome.kind === 'error',
|
|
2921
|
+
...(outcome.facts ? { facts: outcome.facts } : {}),
|
|
2819
2922
|
...(outcome.inputFailure ? { inputFailure: outcome.inputFailure } : {}),
|
|
2820
2923
|
...(outcome.skipped ? { skipped: true } : {}),
|
|
2821
2924
|
};
|
|
@@ -2829,6 +2932,22 @@ export class ToolExecutor {
|
|
|
2829
2932
|
...(call.skipped ? { skipped: true } : {}),
|
|
2830
2933
|
});
|
|
2831
2934
|
}
|
|
2935
|
+
/**
|
|
2936
|
+
* The per-result character cap for one tool: the turn's cap, tightened by
|
|
2937
|
+
* the tool's own `maxOutputChars`. A tool that bounds its own output is
|
|
2938
|
+
* exempt from the DEFAULT cap only (`exemptSelfLimiting`); a host that set
|
|
2939
|
+
* the cap explicitly still gets it. 0 means no cap.
|
|
2940
|
+
*/
|
|
2941
|
+
toolOutputCap(definition, exemptSelfLimiting) {
|
|
2942
|
+
const turn = this.config.maxToolOutputChars ??
|
|
2943
|
+
(exemptSelfLimiting && definition?.selfLimitingOutput === true
|
|
2944
|
+
? 0
|
|
2945
|
+
: DEFAULT_MAX_TOOL_OUTPUT_CHARS);
|
|
2946
|
+
const own = definition?.maxOutputChars;
|
|
2947
|
+
if (own === undefined || !Number.isFinite(own) || own <= 0)
|
|
2948
|
+
return turn;
|
|
2949
|
+
return turn > 0 ? Math.min(turn, Math.floor(own)) : Math.floor(own);
|
|
2950
|
+
}
|
|
2832
2951
|
/**
|
|
2833
2952
|
* The host preview and model text may differ; each gets its own text
|
|
2834
2953
|
* budget. Rich bytes are measured separately and withheld whole when
|
|
@@ -2858,7 +2977,7 @@ export class ToolExecutor {
|
|
|
2858
2977
|
toolName,
|
|
2859
2978
|
toolUseId,
|
|
2860
2979
|
output: text,
|
|
2861
|
-
maxChars: this.config.
|
|
2980
|
+
maxChars: this.toolOutputCap(this.config.tools.get(toolName), false),
|
|
2862
2981
|
...(notice ? { notice } : {}),
|
|
2863
2982
|
// A tool may return different host and model text. They must
|
|
2864
2983
|
// never compete for the same exclusive spill filename.
|