@namzu/sdk 62.6.1 → 62.8.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 +42 -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 +107 -29
- 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/context.d.ts.map +1 -1
- package/dist/runtime/query/context.js +28 -2
- package/dist/runtime/query/context.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 +154 -13
- 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 +30 -12
- 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/session-storage.d.ts.map +1 -1
- package/dist/runtime/query/session-storage.js +44 -3
- package/dist/runtime/query/session-storage.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/file-walk.d.ts +7 -1
- package/dist/sandbox/file-walk.d.ts.map +1 -1
- package/dist/sandbox/file-walk.js +30 -4
- package/dist/sandbox/file-walk.js.map +1 -1
- 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/checkpoint/contract.d.ts +12 -0
- package/dist/store/checkpoint/contract.d.ts.map +1 -1
- package/dist/store/checkpoint/contract.js.map +1 -1
- package/dist/store/checkpoint/disk.d.ts.map +1 -1
- package/dist/store/checkpoint/disk.js +34 -2
- package/dist/store/checkpoint/disk.js.map +1 -1
- package/dist/store/checkpoint/prune.d.ts.map +1 -1
- package/dist/store/checkpoint/prune.js +6 -0
- package/dist/store/checkpoint/prune.js.map +1 -1
- package/dist/store/evidence/disk.js +40 -3
- package/dist/store/evidence/disk.js.map +1 -1
- package/dist/store/session-log/incremental.d.ts +23 -0
- package/dist/store/session-log/incremental.d.ts.map +1 -0
- package/dist/store/session-log/incremental.js +117 -0
- package/dist/store/session-log/incremental.js.map +1 -0
- 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/admit-facts.d.ts.map +1 -1
- package/dist/tools/admit-facts.js +1 -0
- package/dist/tools/admit-facts.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +11 -2
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/bounded-file-read.d.ts +19 -1
- package/dist/tools/builtins/bounded-file-read.d.ts.map +1 -1
- package/dist/tools/builtins/bounded-file-read.js +56 -3
- package/dist/tools/builtins/bounded-file-read.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.d.ts +8 -0
- package/dist/tools/builtins/grep.d.ts.map +1 -1
- package/dist/tools/builtins/grep.js +148 -21
- 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/search-support.d.ts +8 -0
- package/dist/tools/builtins/search-support.d.ts.map +1 -1
- package/dist/tools/builtins/search-support.js +66 -0
- package/dist/tools/builtins/search-support.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/dist/types/tool/presentation.d.ts +6 -0
- package/dist/types/tool/presentation.d.ts.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 +115 -30
- 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/context.ts +33 -6
- package/src/runtime/query/executor.ts +183 -21
- 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 +29 -12
- package/src/runtime/query/review-policy.ts +33 -0
- package/src/runtime/query/session-storage.ts +42 -3
- 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/file-walk.ts +41 -4
- package/src/sandbox/glob-segment.ts +48 -24
- package/src/store/checkpoint/contract.ts +15 -0
- package/src/store/checkpoint/disk.ts +34 -2
- package/src/store/checkpoint/prune.ts +13 -0
- package/src/store/evidence/disk.ts +57 -2
- package/src/store/session-log/incremental.ts +147 -0
- package/src/store/session-log/index.ts +7 -0
- package/src/store/session-log/turn-outcome.ts +84 -0
- package/src/tools/admit-facts.ts +1 -0
- package/src/tools/builtins/bash.ts +12 -2
- package/src/tools/builtins/bounded-file-read.ts +59 -2
- 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 +173 -27
- package/src/tools/builtins/notebook-guard.ts +76 -0
- package/src/tools/builtins/read-render.ts +12 -2
- package/src/tools/builtins/search-support.ts +62 -0
- 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
- package/src/types/tool/presentation.ts +6 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* How a turn came out, from the kernel's own record of its tool calls.
|
|
5
|
+
*
|
|
6
|
+
* `checked` says a recognised check passed on the workspace as the turn left
|
|
7
|
+
* it. It does not say the check covers the change.
|
|
8
|
+
*/
|
|
9
|
+
export type TurnOutcomeVerdict =
|
|
10
|
+
/** Nothing in the workspace differs from the start of the turn. */
|
|
11
|
+
| 'unchanged'
|
|
12
|
+
/** Changed; at least one check passed on the final state and none is left failing. */
|
|
13
|
+
| 'checked'
|
|
14
|
+
/** Changed; checks passed, but the workspace changed again after the last pass. */
|
|
15
|
+
| 'stale'
|
|
16
|
+
/** Some check's latest run did not pass. Changed or not. */
|
|
17
|
+
| 'failing'
|
|
18
|
+
/** Changed; checks ran but none established a pass (status hidden, background, timed out, or unknown freshness). */
|
|
19
|
+
| 'inconclusive'
|
|
20
|
+
/** Changed; no check ran. */
|
|
21
|
+
| 'unchecked'
|
|
22
|
+
/**
|
|
23
|
+
* Whether anything changed cannot be told: no write tool ran, but a command
|
|
24
|
+
* that may have changed files did, and no workspace detector answered.
|
|
25
|
+
*/
|
|
26
|
+
| 'unknown'
|
|
27
|
+
|
|
28
|
+
/** What one check established. */
|
|
29
|
+
export type TurnOutcomeCheckResult =
|
|
30
|
+
/** Exit status 0, and the status is the check's own. */
|
|
31
|
+
| 'passed'
|
|
32
|
+
/** Non-zero exit, refused, or errored. */
|
|
33
|
+
| 'failed'
|
|
34
|
+
/** The command line lets something else decide the exit status: a pipe, `;`, `||`, a trailing `&`. */
|
|
35
|
+
| 'masked'
|
|
36
|
+
/** Handed to a background job, continued, timed out, or its status was never seen. */
|
|
37
|
+
| 'unsettled'
|
|
38
|
+
|
|
39
|
+
export interface TurnOutcomeCheck {
|
|
40
|
+
/** As run, clipped. */
|
|
41
|
+
readonly command: string
|
|
42
|
+
/** The loop step the latest run of this command finished in. */
|
|
43
|
+
readonly step: number
|
|
44
|
+
readonly result: TurnOutcomeCheckResult
|
|
45
|
+
readonly exitCode?: number
|
|
46
|
+
/**
|
|
47
|
+
* True when the workspace is the same now as when this check finished. False
|
|
48
|
+
* when it is known to have changed since. Absent when that cannot be told.
|
|
49
|
+
*/
|
|
50
|
+
readonly fresh?: boolean
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface TurnOutcome {
|
|
54
|
+
readonly verdict: TurnOutcomeVerdict
|
|
55
|
+
/**
|
|
56
|
+
* How the workspace was observed. `calls`: only the kernel's own write tools
|
|
57
|
+
* were seen, so a change made by a shell command or another tool is invisible
|
|
58
|
+
* and `unchanged` means only that no write tool ran. `workspace`: the host
|
|
59
|
+
* supplied a change detector and the start, each check and the end were
|
|
60
|
+
* compared with it.
|
|
61
|
+
*/
|
|
62
|
+
readonly basis: 'calls' | 'workspace'
|
|
63
|
+
readonly changes: {
|
|
64
|
+
/** Distinct paths the turn's write tools changed, or the number of write calls when some had no path. */
|
|
65
|
+
readonly total: number
|
|
66
|
+
/** The first of them, bounded. */
|
|
67
|
+
readonly paths: readonly string[]
|
|
68
|
+
/** The workspace moved and no write tool call explains it. */
|
|
69
|
+
readonly outsideKnownTools: boolean
|
|
70
|
+
}
|
|
71
|
+
/** In order of first run; the latest run of each distinct command; bounded. */
|
|
72
|
+
readonly checks: readonly TurnOutcomeCheck[]
|
|
73
|
+
/** How many distinct checks ran, when `checks` was cut. */
|
|
74
|
+
readonly checksTotal?: number
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Host hooks for the turn's outcome record. */
|
|
78
|
+
export interface TurnOutcomeConfig {
|
|
79
|
+
/**
|
|
80
|
+
* A fingerprint of the workspace, or `null` when it cannot be told.
|
|
81
|
+
* `fingerprintWorkspace` is the kernel's own. `null` is never a match.
|
|
82
|
+
* Called before the first call of the turn that could change the workspace,
|
|
83
|
+
* after each check, and once when the turn ends; never in a turn whose calls
|
|
84
|
+
* are all provably read-only.
|
|
85
|
+
*/
|
|
86
|
+
readonly detectChanges?: () => Promise<string | null>
|
|
87
|
+
/** Names a command that checks work, beyond the ones the kernel recognises. */
|
|
88
|
+
readonly isCheck?: (command: string) => boolean
|
|
89
|
+
/** Deadline per detector call. A detector that is late is `null`. Default 3000. */
|
|
90
|
+
readonly detectTimeoutMs?: number
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Bounds on a recorded outcome. */
|
|
94
|
+
export const OUTCOME_MAX_PATHS = 50
|
|
95
|
+
export const OUTCOME_MAX_CHECKS = 20
|
|
96
|
+
export const OUTCOME_MAX_COMMAND_CHARS = 300
|
|
97
|
+
export const OUTCOME_MAX_PATH_CHARS = 300
|
|
98
|
+
export const OUTCOME_DEFAULT_DETECT_TIMEOUT_MS = 3000
|
|
99
|
+
|
|
100
|
+
const verdict = z.enum([
|
|
101
|
+
'unchanged',
|
|
102
|
+
'checked',
|
|
103
|
+
'stale',
|
|
104
|
+
'failing',
|
|
105
|
+
'inconclusive',
|
|
106
|
+
'unchecked',
|
|
107
|
+
'unknown',
|
|
108
|
+
])
|
|
109
|
+
const count = z.number().int().nonnegative().safe()
|
|
110
|
+
|
|
111
|
+
/** The shape a recorded outcome must have to be written to, or read back from, the session log. */
|
|
112
|
+
export const TurnOutcomeSchema: z.ZodType<TurnOutcome, unknown> = z
|
|
113
|
+
.object({
|
|
114
|
+
verdict,
|
|
115
|
+
basis: z.enum(['calls', 'workspace']),
|
|
116
|
+
changes: z
|
|
117
|
+
.object({
|
|
118
|
+
total: count,
|
|
119
|
+
// One more than the bound: a clipped path ends in an ellipsis.
|
|
120
|
+
paths: z.array(z.string().max(OUTCOME_MAX_PATH_CHARS + 1)).max(OUTCOME_MAX_PATHS),
|
|
121
|
+
outsideKnownTools: z.boolean(),
|
|
122
|
+
})
|
|
123
|
+
.strict(),
|
|
124
|
+
checks: z
|
|
125
|
+
.array(
|
|
126
|
+
z
|
|
127
|
+
.object({
|
|
128
|
+
command: z.string().max(OUTCOME_MAX_COMMAND_CHARS + 1),
|
|
129
|
+
step: count,
|
|
130
|
+
result: z.enum(['passed', 'failed', 'masked', 'unsettled']),
|
|
131
|
+
exitCode: z.number().int().safe().optional(),
|
|
132
|
+
fresh: z.boolean().optional(),
|
|
133
|
+
})
|
|
134
|
+
.strict(),
|
|
135
|
+
)
|
|
136
|
+
.max(OUTCOME_MAX_CHECKS),
|
|
137
|
+
checksTotal: count.optional(),
|
|
138
|
+
})
|
|
139
|
+
.strict()
|
|
@@ -285,6 +285,8 @@ export interface RecalledMemory {
|
|
|
285
285
|
* Absent when no selector ran; the words of the request chose it.
|
|
286
286
|
*/
|
|
287
287
|
readonly reason?: string
|
|
288
|
+
/** Set when the host's check found the record may no longer hold, e.g. `may be out of date: a file it names is gone`. */
|
|
289
|
+
readonly caution?: string
|
|
288
290
|
}
|
|
289
291
|
|
|
290
292
|
/**
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
type SessionEvent,
|
|
26
26
|
type SessionEventType,
|
|
27
27
|
} from './events.js'
|
|
28
|
+
import type { TurnSettlement } from './turn.js'
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* The session log: one append-only, hash-chained JSONL file per session, the
|
|
@@ -594,6 +595,49 @@ export const AccountBoundRecordSchema = recordSchema('account_bound', {
|
|
|
594
595
|
reason: z.enum(['start', 'user_switch', 'limit_switch']),
|
|
595
596
|
})
|
|
596
597
|
|
|
598
|
+
/**
|
|
599
|
+
* The three records below carry the turn's outcome record
|
|
600
|
+
* (`docs/sdk/turn-outcome.md`). Each is `ignorable: true`: a release that does
|
|
601
|
+
* not know the type keeps it in the hash chain and skips it (see
|
|
602
|
+
* `IgnorableRecordSchema`), so a log written with them still reads there and
|
|
603
|
+
* loses only the outcome. None of them may become a field of a record that
|
|
604
|
+
* existed before them, because a release that validates that record strictly
|
|
605
|
+
* would refuse the whole log. The body is checked only for being an object
|
|
606
|
+
* here; `TurnOutcomeSchema` judges it where it is read back, so a later
|
|
607
|
+
* release may widen it without making this one refuse the log.
|
|
608
|
+
*/
|
|
609
|
+
const outcomeBody = z.custom<Readonly<Record<string, unknown>>>(isPlainObject, {
|
|
610
|
+
message: 'expected an object',
|
|
611
|
+
})
|
|
612
|
+
|
|
613
|
+
/** A turn's final outcome, written just before its `turn_completed` or `turn_failed`. */
|
|
614
|
+
export const TurnOutcomeRecordedRecordSchema = inTurn('turn_outcome_recorded', {
|
|
615
|
+
ignorable: z.literal(true),
|
|
616
|
+
outcome: outcomeBody,
|
|
617
|
+
})
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* A delegated child's outcome, written in the parent's log just before the
|
|
621
|
+
* child's `child_session_ended`. Carries the spawning turn's id only while that
|
|
622
|
+
* turn is open, as `child_session_ended` does.
|
|
623
|
+
*/
|
|
624
|
+
export const ChildOutcomeRecordedRecordSchema = recordSchema('child_outcome_recorded', {
|
|
625
|
+
ignorable: z.literal(true),
|
|
626
|
+
childSessionId: sessionId,
|
|
627
|
+
outcome: outcomeBody,
|
|
628
|
+
})
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* What the turn's outcome record had gathered when a checkpoint was written,
|
|
632
|
+
* so a resume can restore it. Written just before the `checkpoint_written`
|
|
633
|
+
* record of the same `checkpointId`.
|
|
634
|
+
*/
|
|
635
|
+
export const OutcomeProgressWrittenRecordSchema = inTurn('outcome_progress_written', {
|
|
636
|
+
ignorable: z.literal(true),
|
|
637
|
+
checkpointId,
|
|
638
|
+
progress: outcomeBody,
|
|
639
|
+
})
|
|
640
|
+
|
|
597
641
|
export const LogRepairedRecordSchema = recordSchema('log_repaired', {
|
|
598
642
|
truncatedBytes: positive,
|
|
599
643
|
lastGoodSeq: positive,
|
|
@@ -632,6 +676,9 @@ const RECORD_ONLY_SCHEMAS = {
|
|
|
632
676
|
budget_bound: BudgetBoundRecordSchema,
|
|
633
677
|
account_bound: AccountBoundRecordSchema,
|
|
634
678
|
log_repaired: LogRepairedRecordSchema,
|
|
679
|
+
turn_outcome_recorded: TurnOutcomeRecordedRecordSchema,
|
|
680
|
+
child_outcome_recorded: ChildOutcomeRecordedRecordSchema,
|
|
681
|
+
outcome_progress_written: OutcomeProgressWrittenRecordSchema,
|
|
635
682
|
} as const
|
|
636
683
|
|
|
637
684
|
export type SessionRecordOnlyType = keyof typeof RECORD_ONLY_SCHEMAS
|
|
@@ -1006,8 +1053,21 @@ type EventOf<T extends SessionEventType> = Extract<SessionEvent, { type: T }>
|
|
|
1006
1053
|
*/
|
|
1007
1054
|
export type SessionEventRecord<T extends PersistedSessionEventType = PersistedSessionEventType> =
|
|
1008
1055
|
T extends PersistedSessionEventType
|
|
1009
|
-
? Omit<
|
|
1056
|
+
? Omit<
|
|
1057
|
+
EventOf<T>,
|
|
1058
|
+
| 'sessionId'
|
|
1059
|
+
| 'turnId'
|
|
1060
|
+
| 'lineage'
|
|
1061
|
+
| 'v'
|
|
1062
|
+
| 'seq'
|
|
1063
|
+
| 'generation'
|
|
1064
|
+
// The live settlement carries the outcome record; the log's does not.
|
|
1065
|
+
| (T extends 'turn_completed' | 'turn_failed' ? 'settlement' : never)
|
|
1066
|
+
> &
|
|
1010
1067
|
RecordEnvelope &
|
|
1068
|
+
(T extends 'turn_completed' | 'turn_failed'
|
|
1069
|
+
? { readonly settlement: TurnSettlement }
|
|
1070
|
+
: unknown) &
|
|
1011
1071
|
(T extends 'tool_completed'
|
|
1012
1072
|
? {
|
|
1013
1073
|
readonly structuredResultSpill?: z.infer<typeof structuredResultSpill>
|
|
@@ -1036,6 +1096,9 @@ export type AuditRecord = z.infer<typeof AuditRecordSchema>
|
|
|
1036
1096
|
export type BudgetBoundRecord = z.infer<typeof BudgetBoundRecordSchema>
|
|
1037
1097
|
export type AccountBoundRecord = z.infer<typeof AccountBoundRecordSchema>
|
|
1038
1098
|
export type LogRepairedRecord = z.infer<typeof LogRepairedRecordSchema>
|
|
1099
|
+
export type TurnOutcomeRecordedRecord = z.infer<typeof TurnOutcomeRecordedRecordSchema>
|
|
1100
|
+
export type ChildOutcomeRecordedRecord = z.infer<typeof ChildOutcomeRecordedRecordSchema>
|
|
1101
|
+
export type OutcomeProgressWrittenRecord = z.infer<typeof OutcomeProgressWrittenRecordSchema>
|
|
1039
1102
|
|
|
1040
1103
|
export type SessionRecordOnly =
|
|
1041
1104
|
| SessionStartedRecord
|
|
@@ -1053,6 +1116,9 @@ export type SessionRecordOnly =
|
|
|
1053
1116
|
| BudgetBoundRecord
|
|
1054
1117
|
| AccountBoundRecord
|
|
1055
1118
|
| LogRepairedRecord
|
|
1119
|
+
| TurnOutcomeRecordedRecord
|
|
1120
|
+
| ChildOutcomeRecordedRecord
|
|
1121
|
+
| OutcomeProgressWrittenRecord
|
|
1056
1122
|
|
|
1057
1123
|
/** One line of a session log. */
|
|
1058
1124
|
export type SessionRecord = SessionEventRecord | SessionRecordOnly
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
import type { Message } from '../message/index.js'
|
|
12
12
|
import type { ProviderErrorInfo } from '../provider/index.js'
|
|
13
13
|
import type { TurnConfig } from './config.js'
|
|
14
|
+
import type { TurnOutcome } from './outcome.js'
|
|
14
15
|
import type { StepResult } from './step.js'
|
|
15
16
|
import type { StopReason } from './stop-reason.js'
|
|
16
17
|
|
|
@@ -151,6 +152,22 @@ export interface TurnSettlement {
|
|
|
151
152
|
readonly abandonedJobIds: readonly string[]
|
|
152
153
|
}
|
|
153
154
|
|
|
155
|
+
/**
|
|
156
|
+
* The settlement a live `turn_completed` or `turn_failed` event carries: the
|
|
157
|
+
* persisted {@link TurnSettlement} plus the turn's outcome record. The record
|
|
158
|
+
* is in memory only here. The session log keeps it in its own records
|
|
159
|
+
* (`turn_outcome_recorded`), never in the settlement, so a release that
|
|
160
|
+
* validates the settlement strictly still reads the log.
|
|
161
|
+
*/
|
|
162
|
+
export interface LiveTurnSettlement extends TurnSettlement {
|
|
163
|
+
/**
|
|
164
|
+
* What the turn changed and what checked it, from its own tool calls. Absent
|
|
165
|
+
* for a turn that never ran the loop and one resumed from a checkpoint that
|
|
166
|
+
* did not keep the record.
|
|
167
|
+
*/
|
|
168
|
+
readonly outcome?: TurnOutcome
|
|
169
|
+
}
|
|
170
|
+
|
|
154
171
|
/** Metadata of one turn: who ran it, with what, and where it sits in the session tree. */
|
|
155
172
|
export interface TurnMetadata {
|
|
156
173
|
/** This turn's owner, independent of a shared ancestor token account. */
|
|
@@ -216,6 +233,8 @@ export interface Turn {
|
|
|
216
233
|
abandonedTaskIds?: readonly string[]
|
|
217
234
|
/** Background jobs the model awaited that were still running when this turn ended. */
|
|
218
235
|
abandonedJobIds?: readonly string[]
|
|
236
|
+
/** What the turn changed and what checked it; see {@link LiveTurnSettlement.outcome}. */
|
|
237
|
+
outcome?: TurnOutcome
|
|
219
238
|
/** Present on a child session's turn. */
|
|
220
239
|
parentSessionId?: SessionId
|
|
221
240
|
/** Present on a child session's turn. */
|
package/src/types/tool/index.ts
CHANGED
|
@@ -331,6 +331,25 @@ export interface FileReadTracker {
|
|
|
331
331
|
* chain is cleared. Pass ToolContext.toolUseId only after the edit succeeded.
|
|
332
332
|
*/
|
|
333
333
|
recordEdit?(key: string, content: string, callId: string): void
|
|
334
|
+
/**
|
|
335
|
+
* Optional: the fingerprint of the content the agent itself last put in
|
|
336
|
+
* the file at `key` through a full write or an edit, if it did. A file the
|
|
337
|
+
* agent only read, or never touched, has none. Shell redirection is not
|
|
338
|
+
* seen here: such a file is of unknown authorship. Used by the auto-mode
|
|
339
|
+
* classifier to tell a script the agent wrote from one it did not.
|
|
340
|
+
*/
|
|
341
|
+
authoredFingerprint?(key: string): string | undefined
|
|
342
|
+
/** Optional: when this ledger began, in milliseconds since the epoch. */
|
|
343
|
+
readonly startedAt?: number
|
|
344
|
+
/**
|
|
345
|
+
* Optional: the ledger a delegated child starts with. Its own read record,
|
|
346
|
+
* empty, because what a child has read is not what its parent or a sibling
|
|
347
|
+
* has, and the stale-write refusal compares the disk to the reader's own
|
|
348
|
+
* reads. What the family authored ({@link authoredFingerprint},
|
|
349
|
+
* {@link startedAt}) is shared with it. A tracker without this is not
|
|
350
|
+
* handed to a child.
|
|
351
|
+
*/
|
|
352
|
+
forChild?(): FileReadTracker
|
|
334
353
|
/**
|
|
335
354
|
* Optional witness of a read that returned the file WHOLE, with the
|
|
336
355
|
* fingerprint of the rendering it returned.
|
|
@@ -1364,6 +1383,17 @@ export interface ToolDefinition<TInput = unknown> extends ToolPresentation<TInpu
|
|
|
1364
1383
|
* explicitly still bounds this tool's result by it.
|
|
1365
1384
|
*/
|
|
1366
1385
|
selfLimitingOutput?: boolean
|
|
1386
|
+
/**
|
|
1387
|
+
* A tighter model-visible cap, in characters, for THIS tool's result.
|
|
1388
|
+
*
|
|
1389
|
+
* The turn's cap (`maxToolOutputChars`, 40,000 by default) still applies;
|
|
1390
|
+
* the smaller of the two wins, including when a host turned the turn cap
|
|
1391
|
+
* off with `0`. A result over it is kept in the session's tool-results
|
|
1392
|
+
* folder and shown as a head-and-tail preview that names the file, the same
|
|
1393
|
+
* way any other oversized result is. Use it for a tool whose results are
|
|
1394
|
+
* foreign text that should cost less of the window than a file read does.
|
|
1395
|
+
*/
|
|
1396
|
+
maxOutputChars?: number
|
|
1367
1397
|
}
|
|
1368
1398
|
|
|
1369
1399
|
/**
|
|
@@ -220,6 +220,12 @@ export type ToolFacts =
|
|
|
220
220
|
readonly reason: ToolFailureReason
|
|
221
221
|
/** What it was about: a path, or the tool's name for `unknown_tool`. */
|
|
222
222
|
readonly subject?: string
|
|
223
|
+
/**
|
|
224
|
+
* Why a refused call did not run, as one plain line the kernel wrote
|
|
225
|
+
* (a policy rule, the command guard). Absent when no reason was
|
|
226
|
+
* recorded; a host shows nothing for it rather than a guess.
|
|
227
|
+
*/
|
|
228
|
+
readonly note?: string
|
|
223
229
|
}
|
|
224
230
|
|
|
225
231
|
/** The same shapes, for what a call produced. */
|