@sema-agent/core 5.56.0 → 5.58.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 +122 -0
- package/dist/agents/cascade.d.ts +1 -1
- package/dist/agents/cumulative-stats.d.ts +1 -1
- package/dist/agents/observer.d.ts +2 -2
- package/dist/agents/peer-admission.d.ts +1 -1
- package/dist/agents/retain-ledger.d.ts +2 -2
- package/dist/agents/roster-store.d.ts +8 -8
- package/dist/agents/send-message-tool.d.ts +13 -2
- package/dist/agents/send-message-tool.js +34 -12
- package/dist/agents/subagent-steps.d.ts +1 -1
- package/dist/agents/subagent.d.ts +13 -13
- package/dist/agents/team.d.ts +15 -6
- package/dist/agents/team.js +1 -0
- package/dist/agents/tool-filter.d.ts +2 -2
- package/dist/agents/verify.d.ts +1 -1
- package/dist/bench/metrics.d.ts +35 -35
- package/dist/brain/anthropic.js +15 -5
- package/dist/brain/circuit-breaker.js +2 -1
- package/dist/brain/degrading.d.ts +1 -1
- package/dist/brain/degrading.js +4 -1
- package/dist/brain/errors.d.ts +3 -3
- package/dist/brain/failover.js +16 -1
- package/dist/brain/open-responses.js +15 -5
- package/dist/brain/openai.js +16 -5
- package/dist/brain/reasoning.d.ts +2 -2
- package/dist/brain/repetition.d.ts +1 -1
- package/dist/brain/request-params.d.ts +30 -27
- package/dist/brain/request-params.js +1 -7
- package/dist/brain/route-adjudicator.d.ts +190 -0
- package/dist/brain/route-adjudicator.js +189 -0
- package/dist/brain/route-conformance.d.ts +55 -0
- package/dist/brain/route-conformance.js +136 -0
- package/dist/brain/routing.js +8 -3
- package/dist/brain/status-sink.d.ts +2 -2
- package/dist/brain/stream-shared.d.ts +1 -1
- package/dist/config/catalog.d.ts +5 -5
- package/dist/core/arg-summary.d.ts +4 -4
- package/dist/core/ask-class.d.ts +2 -2
- package/dist/core/ask-question.d.ts +1 -1
- package/dist/core/auto-compaction.d.ts +15 -15
- package/dist/core/auto-mode.d.ts +5 -5
- package/dist/core/background-agent-store.d.ts +20 -20
- package/dist/core/background-shell.d.ts +4 -4
- package/dist/core/checkpoint-store.d.ts +35 -27
- package/dist/core/context-edit.d.ts +1 -1
- package/dist/core/context-guard.d.ts +1 -1
- package/dist/core/exec-output-tail.d.ts +6 -6
- package/dist/core/file-snapshot-store.d.ts +8 -8
- package/dist/core/git-worktree-env.d.ts +3 -3
- package/dist/core/governance-codes.js +2 -0
- package/dist/core/hooks.d.ts +73 -33
- package/dist/core/hooks.js +87 -25
- package/dist/core/image-downsample.d.ts +1 -1
- package/dist/core/locked-config.d.ts +1 -1
- package/dist/core/lsp.d.ts +1 -1
- package/dist/core/mailbox-store.d.ts +1 -1
- package/dist/core/mcp.d.ts +3 -3
- package/dist/core/mcp.js +4 -4
- package/dist/core/memory-engine/consolidation-driver.d.ts +207 -0
- package/dist/core/memory-engine/consolidation-driver.js +378 -0
- package/dist/core/memory-engine/consolidation.d.ts +46 -2
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/data-plane.d.ts +1 -1
- package/dist/core/memory-engine/distiller.d.ts +550 -0
- package/dist/core/memory-engine/distiller.js +598 -0
- package/dist/core/memory-engine/dual-root.d.ts +1 -1
- package/dist/core/memory-engine/engine.d.ts +62 -8
- package/dist/core/memory-engine/engine.js +40 -4
- package/dist/core/memory-engine/file-backend.d.ts +1 -1
- package/dist/core/memory-engine/index.d.ts +4 -2
- package/dist/core/memory-engine/index.js +4 -2
- package/dist/core/memory-engine/origin-clearance.d.ts +1 -1
- package/dist/core/memory-engine/scope-contract.d.ts +4 -4
- package/dist/core/memory-engine/sync-client.d.ts +16 -16
- package/dist/core/memory-engine/sync.d.ts +4 -4
- package/dist/core/memory-recall.d.ts +1 -1
- package/dist/core/memory.d.ts +2 -2
- package/dist/core/permission-rule-consent.d.ts +230 -36
- package/dist/core/permission-rule-consent.js +258 -54
- package/dist/core/permission-rule-model.d.ts +295 -97
- package/dist/core/permission-rule-model.js +132 -41
- package/dist/core/permission-rules.d.ts +9 -9
- package/dist/core/remote-env.d.ts +8 -8
- package/dist/core/roles.d.ts +3 -3
- package/dist/core/roles.js +1 -0
- package/dist/core/runner/assemble-result.d.ts +2 -2
- package/dist/core/runner/compaction-call-options.d.ts +3 -3
- package/dist/core/runner/memory-consolidation-driver.d.ts +49 -0
- package/dist/core/runner/memory-consolidation-driver.js +60 -0
- package/dist/core/runner/memory-consolidation.d.ts +1 -1
- package/dist/core/runner/prepare-config-doors.d.ts +3 -3
- package/dist/core/runner/prepare-task.d.ts +21 -21
- package/dist/core/runner/prepare-task.js +54 -18
- package/dist/core/runner/prepare-workspace-restore.d.ts +2 -2
- package/dist/core/runner/runtask.d.ts +15 -12
- package/dist/core/runner/runtask.js +48 -0
- package/dist/core/runner/session-rule-policy.d.ts +1 -1
- package/dist/core/runner/teardown-bounded.d.ts +1 -1
- package/dist/core/runner/tool-disclosure.d.ts +2 -2
- package/dist/core/runner/turn-attachments.d.ts +11 -11
- package/dist/core/scheduler.d.ts +10 -5
- package/dist/core/secret-env.d.ts +1 -1
- package/dist/core/sensitive-path-policy.d.ts +1 -1
- package/dist/core/session-policy-store.d.ts +2 -2
- package/dist/core/session-reconcile.d.ts +2 -2
- package/dist/core/session-store.d.ts +3 -3
- package/dist/core/session.d.ts +1 -1
- package/dist/core/shutdown-debug.d.ts +2 -2
- package/dist/core/side-query.d.ts +14 -7
- package/dist/core/spec-contract.d.ts +1 -1
- package/dist/core/store-contracts/contract-harness.d.ts +2 -2
- package/dist/core/store-contracts/contract-kit-version.d.ts +2 -2
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/mailbox-store-contract.js +1 -1
- package/dist/core/task-notification.d.ts +5 -5
- package/dist/core/task-registry-agent.d.ts +12 -12
- package/dist/core/task-registry-monitor.d.ts +1 -1
- package/dist/core/task-registry-shared.d.ts +41 -41
- package/dist/core/task-registry.d.ts +12 -12
- package/dist/core/tool-detach.d.ts +2 -2
- package/dist/core/tool-errors.d.ts +3 -3
- package/dist/core/tool-policy.d.ts +55 -28
- package/dist/core/tool-result-budget.d.ts +1 -1
- package/dist/core/tool-result-store.d.ts +2 -2
- package/dist/core/tools.d.ts +1 -1
- package/dist/core/trace.d.ts +26 -23
- package/dist/core/types.d.ts +155 -70
- package/dist/core/untrusted-egress.d.ts +1 -1
- package/dist/core/untrusted-text.d.ts +7 -7
- package/dist/core/wiring-manifest.d.ts +5 -5
- package/dist/core/workflow-journal-store.d.ts +14 -14
- package/dist/core/workflow-run-store-contract.d.ts +1 -1
- package/dist/core/workflow-run-store-contract.js +1 -1
- package/dist/core/workflow-run-store.d.ts +4 -4
- package/dist/engine/compaction/compaction.d.ts +3 -3
- package/dist/engine/compaction/utils.d.ts +2 -2
- package/dist/engine/execution-env/kill-tree.d.ts +1 -1
- package/dist/engine/execution-env/node-execution-env.d.ts +8 -8
- package/dist/engine/harness/agent-harness.d.ts +6 -6
- package/dist/engine/harness/agent-harness.js +26 -1
- package/dist/engine/harness/messages.d.ts +1 -1
- package/dist/engine/harness/types.d.ts +15 -11
- package/dist/engine/llm/types.d.ts +79 -14
- package/dist/engine/loop/agent-loop.d.ts +3 -3
- package/dist/engine/loop/types.d.ts +4 -4
- package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
- package/dist/engine/session/import-validate.d.ts +1 -1
- package/dist/engine/session/log-digest.d.ts +1 -1
- package/dist/engine/session/memory-repo.d.ts +2 -2
- package/dist/engine/session/session.d.ts +4 -4
- package/dist/fixtures/index.d.ts +4 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +5 -2
- package/dist/internal/llm.d.ts +1 -1
- package/dist/orchestration/goal.d.ts +1 -1
- package/dist/orchestration/run-spec.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +12 -12
- package/dist/orchestration/workflow-governance.d.ts +4 -4
- package/dist/orchestration/workflow-observe.d.ts +1 -1
- package/dist/orchestration/workflow-script-runner.d.ts +1 -1
- package/dist/orchestration/workflow-script-store.d.ts +9 -9
- package/dist/orchestration/workflow-size-guideline.d.ts +1 -1
- package/dist/orchestration/workflow-types.d.ts +5 -5
- package/dist/orchestration/workflow.d.ts +10 -10
- package/dist/prompt-assembly/artifact-store.d.ts +1 -1
- package/dist/prompt-assembly/artifact.d.ts +1 -1
- package/dist/prompt-assembly/assemble.d.ts +1 -1
- package/dist/prompt-assembly/composer.d.ts +2 -2
- package/dist/prompt-assembly/epoch.d.ts +2 -2
- package/dist/prompt-assembly/event-registry.d.ts +1 -1
- package/dist/prompt-assembly/explain.d.ts +3 -3
- package/dist/prompt-assembly/tool-catalog.d.ts +1 -1
- package/dist/prompt-assembly/turn-snapshot.d.ts +4 -4
- package/dist/prompt-assembly/types.d.ts +12 -12
- package/dist/prompts/coordinator.d.ts +1 -1
- package/dist/prompts/default.d.ts +10 -10
- package/dist/prompts/default.js +2 -0
- package/dist/prompts/simple-sections.d.ts +3 -3
- package/dist/prompts/supervisor.d.ts +2 -2
- package/dist/scenarios/full-body.d.ts +3 -3
- package/dist/scenarios/scenario-registry.d.ts +6 -2
- package/dist/scenarios/scenario-registry.js +4 -2
- package/dist/stores/cc/sidecar-transcript.d.ts +3 -3
- package/dist/stores/file/fs-atomic.d.ts +2 -2
- package/dist/stores/file/index.d.ts +1 -1
- package/dist/stores/file/session-store.d.ts +2 -2
- package/dist/stores/file/workflow-journal-store.d.ts +4 -4
- package/dist/tools/fs/bash-readonly-classifier.d.ts +1 -1
- package/dist/tools/fs/encoding.d.ts +4 -4
- package/dist/tools/fs/fs-bash.d.ts +3 -3
- package/dist/tools/fs/fs-pdf.d.ts +1 -1
- package/dist/tools/fs/fs-shared.d.ts +6 -6
- package/dist/tools/fs/index.d.ts +2 -2
- package/dist/tools/fs/index.js +8 -1
- package/dist/tools/fs/notebook.d.ts +1 -1
- package/dist/tools/fs/pdf.d.ts +1 -1
- package/dist/tools/fs/read-deny.d.ts +1 -1
- package/dist/tools/fs/safety.d.ts +9 -9
- package/dist/tools/fs/search.d.ts +2 -2
- package/dist/tools/monitor.d.ts +3 -3
- package/dist/tools/scheduler-tools.js +28 -6
- package/dist/tools/task-list.d.ts +2 -2
- package/dist/tools/web.d.ts +19 -4
- package/dist/tools/web.js +8 -2
- package/dist/tools/worktree.d.ts +5 -5
- package/dist/tools/worktree.js +2 -2
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +74 -3
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* display (the MF-W workflow monitor's `Read(path)` / `Bash(grep …)` activity line; the MF-24 permission-denial
|
|
4
4
|
* ledger's denied-tool input). Shared so both the activity sink and the denial record scrub identically — a
|
|
5
5
|
* single audited boundary. NOT `redactHostLeaks` (that is for untrusted-LLM egress and over-redacts the very
|
|
6
|
-
* path the trusted owner-scoped monitor wants to show).
|
|
6
|
+
* path the trusted owner-scoped monitor wants to show). Reviewed: 3 blocker + 5 major findings closed.
|
|
7
7
|
*/
|
|
8
8
|
/** Known credential SHAPES + `secretKey=value` — redacted from the FINAL abbreviated string, the single scrub
|
|
9
|
-
* point before any store/SSE fan-out
|
|
10
|
-
/**
|
|
9
|
+
* point before any store/SSE fan-out. Conservative (real credential formats). */
|
|
10
|
+
/** every prefix is LEFT-ANCHORED with \`(?<![A-Za-z0-9])\` — without it, ordinary words whose
|
|
11
11
|
* TAIL spells a prefix were silently redacted (NETWORK-attached → NETWO[redacted], RTMARK-100,
|
|
12
12
|
* task_categories, monkey=abcd1234, MonkeyJumping…) while triggering unpredictably on suffix
|
|
13
13
|
* length. \`_\` is deliberately NOT in the anchor class: \`api_key=\`, \`STRIPE=sk_live_…\`-style glued
|
|
@@ -82,7 +82,7 @@ export declare const SECRET_PASSES: readonly RedactionPass[];
|
|
|
82
82
|
export declare function scrubSecrets(s: string, report?: RedactionReport): string;
|
|
83
83
|
/** A SHORT, SECRET-SCRUBBED primary-arg summary. Abbreviation REDUCES the surface; a final {@link scrubSecrets}
|
|
84
84
|
* pass is the leak boundary (the value is PERSISTED + SSE-forwarded and may be read by a platform operator in a
|
|
85
|
-
* multi-tenant deployment
|
|
85
|
+
* multi-tenant deployment). Rules:
|
|
86
86
|
* • command → the command NAME (skip leading `VAR=val` env-prefixes; bail to `undefined` on a quoted assignment
|
|
87
87
|
* or a lone assignment; basename a path-form command; `+ …` if it had args).
|
|
88
88
|
* • file path → BASENAME only (no host directory layout).
|
package/dist/core/ask-class.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* F-012 L2 — the ENGINE-INTERNAL ask-class envelope.
|
|
3
3
|
*
|
|
4
4
|
* An `ask` verdict's SEMANTIC CLASS decides whether a deployment-declared sandbox may auto-admit it
|
|
5
|
-
* (
|
|
5
|
+
* (the ruling: a declared sandbox admits everything inside it — the boundary crossings park to a
|
|
6
6
|
* human, escape prevention belongs to the sandbox, not to engine re-policing). The class deliberately
|
|
7
7
|
* lives OUTSIDE the public `PermissionResult`: a decision object is caller-supplied data, and a
|
|
8
8
|
* self-reported "this ask is sandbox-local" field would be the same trust hole as the
|
|
@@ -27,7 +27,7 @@ export type AskClass = "sandbox_local" | "external_authority" | "hook" | "mandat
|
|
|
27
27
|
/**
|
|
28
28
|
* Brand a built-in policy instance with its ask class (engine factories only — not exported from the
|
|
29
29
|
* package). The `check` binding is LOCKED as a non-writable, non-configurable DATA property before the
|
|
30
|
-
* policy is returned (
|
|
30
|
+
* policy is returned (falsification-style round 4, HIGH): reading `policy.check` and INVOKING it must
|
|
31
31
|
* name the same callable, atomically. A plain `===` re-read was TOCTOU-able by an accessor — a getter
|
|
32
32
|
* could return the branded function to `policyAskClassOf` and a deployment ask to the gate's
|
|
33
33
|
* invocation. Locking the property makes the callable un-swappable and un-redefinable, so the class
|
|
@@ -23,7 +23,7 @@ export declare const ASK_USER_QUESTION_TOOL_NAME = "AskUserQuestion";
|
|
|
23
23
|
* injection vector. So a `selected` value is echoed as a chosen option ONLY if it is one of the offered option
|
|
24
24
|
* labels (`selected ⊆ options` — the model's own text), and the operator's free-text (`note`, plus any off-list
|
|
25
25
|
* input) is wrapped in an untrusted-DATA fence so it can never be read as instructions. Abort while waiting is
|
|
26
|
-
* handled by the §9 interrupt path (the pending call is closed). Mounting (
|
|
26
|
+
* handled by the §9 interrupt path (the pending call is closed). Mounting (CC non-interactive `isEnabled`
|
|
27
27
|
* parity): only when a delivery face exists — a live `onQuestion`, or a durable park consumer (`checkpointStore`
|
|
28
28
|
* + `durableApproval`/`forceDurableGate`), or an explicit `TaskSpec.interactiveTools: true` — see that knob.
|
|
29
29
|
*/
|
|
@@ -103,7 +103,7 @@ export interface MaybeCompactOptions {
|
|
|
103
103
|
/** The session to compact. Typed on the INTERFACE face (typecheck 车 2026-07-24): every member this
|
|
104
104
|
* module touches lives on `Session` (the optional `getPromptEpoch` degrades honestly via `?.()`). */
|
|
105
105
|
session: Session;
|
|
106
|
-
/**
|
|
106
|
+
/** This run's provider-declared prompt sections (the epoch declaration axis):
|
|
107
107
|
* the compaction-boundary epoch restatement/advance must hash the SAME artifact identity as the
|
|
108
108
|
* prepare-time pin, or every compaction under a declaration-carrying run would flap the pin. */
|
|
109
109
|
epochDeclaredSections?: import("../prompt-assembly/epoch.js").EpochDeclaredSections;
|
|
@@ -113,12 +113,12 @@ export interface MaybeCompactOptions {
|
|
|
113
113
|
* runs ONLY after that append succeeded — a failed/blocked compaction must swap nothing. */
|
|
114
114
|
centerAdoption?: {
|
|
115
115
|
/** Absent together with `clear` ⇒ never happens; adoption carries the new digest, ROLLBACK
|
|
116
|
-
* (explicit center disable
|
|
116
|
+
* (explicit center disable) carries `clear:true` and no digest. */
|
|
117
117
|
centerArtifactDigest?: string;
|
|
118
118
|
sourceRevision?: string;
|
|
119
119
|
clear?: true;
|
|
120
120
|
declaredSections: import("../prompt-assembly/epoch.js").EpochDeclaredSections;
|
|
121
|
-
/**
|
|
121
|
+
/** the post-swap prompt overhead in the trigger estimate's coordinate: used for THIS
|
|
122
122
|
* compaction's post-measurement so PTL recovery/anti-thrash see the swapped prefix size. */
|
|
123
123
|
overheadTokensAfter: number;
|
|
124
124
|
apply: (committedArtifactDigest?: string) => void;
|
|
@@ -254,7 +254,7 @@ export interface MaybeCompactOptions {
|
|
|
254
254
|
/** Per-file char cap (≈4 chars/token). Default 16_000 (~4k tokens). */
|
|
255
255
|
maxCharsPerFile?: number;
|
|
256
256
|
/**
|
|
257
|
-
*
|
|
257
|
+
* CC-parity selection set: the files the task has READ, most recent
|
|
258
258
|
* first (CC 198's post-compact restore sorts readFileState by timestamp — the read set is wider
|
|
259
259
|
* than the modified set and includes reference files the model consulted). When provided and
|
|
260
260
|
* non-empty it WINS over `modifiedFilesByRecency`; absent/empty falls back to the modified set
|
|
@@ -272,7 +272,7 @@ export interface MaybeCompactOptions {
|
|
|
272
272
|
*/
|
|
273
273
|
instructionSourcePaths?: ReadonlyArray<string>;
|
|
274
274
|
/**
|
|
275
|
-
* RB-197②(独立复审 +
|
|
275
|
+
* RB-197②(独立复审 + 命中,已修): `recentlyReadFiles` yields CANONICAL keys (resolveKey
|
|
276
276
|
* output — the same coordinate `ReadFileState` is keyed in), but `instructionSourcePaths` and the
|
|
277
277
|
* kept-tail scan inside `maybeCompact` (which reads raw tool-call arguments via
|
|
278
278
|
* `extractFileOpsFromMessage`) do NOT share that coordinate — a model-typed relative path and its
|
|
@@ -287,7 +287,7 @@ export interface MaybeCompactOptions {
|
|
|
287
287
|
*/
|
|
288
288
|
normalizePath?: (raw: string) => Promise<string>;
|
|
289
289
|
/**
|
|
290
|
-
* RB-197②(
|
|
290
|
+
* RB-197②(交叉复审命中,已修) — a kept-tail Read tool-CALL's mere presence does not prove the
|
|
291
291
|
* file's real content is visible there: its toolRESULT may be a dedup stub ("unchanged since you
|
|
292
292
|
* last read it…") whose ORIGINAL full transmission sits in the summarized prefix THIS compaction is
|
|
293
293
|
* about to cut away — preserving read-state for such a path would leave both the kept tail and the
|
|
@@ -307,7 +307,7 @@ export interface MaybeCompactOptions {
|
|
|
307
307
|
* `workingFileAttachments` deliberately — the invalidation is owed even when attachments are disabled
|
|
308
308
|
* (an empty array then). Best-effort: a throwing callback must not fail the landed compaction.
|
|
309
309
|
*
|
|
310
|
-
* RB-197②(
|
|
310
|
+
* RB-197②(命中,已修;独立复审第二轮又命中一条同族缺口,已修) `preserveReadState`:
|
|
311
311
|
* canonical-coordinate paths (same shape as `normalizePath`'s output) whose read-state entry must
|
|
312
312
|
* survive the compaction's clear even though they are NOT in `attachedComplete` — every file
|
|
313
313
|
* `maybeCompact` deliberately skipped re-attaching, for EITHER exclusion reason (kept-tail-visible,
|
|
@@ -434,7 +434,7 @@ export interface MaybeCompactOptions {
|
|
|
434
434
|
*/
|
|
435
435
|
postCompact?: Hooks["postCompact"];
|
|
436
436
|
/**
|
|
437
|
-
* MF-18 修②
|
|
437
|
+
* MF-18 修② — observe-only: fired when a summary call's serialized conversation INPUT was
|
|
438
438
|
* truncated to fit the compaction model's context window (the ~300K-session shape that previously
|
|
439
439
|
* guaranteed a provider prompt-too-long throw at every boundary). The caller bridges it to the
|
|
440
440
|
* `compaction.input_truncated` trace frame (fidelity disclosure). Fired BEFORE the summary call, so
|
|
@@ -446,7 +446,7 @@ export interface MaybeCompactOptions {
|
|
|
446
446
|
keptChars: number;
|
|
447
447
|
}) => void;
|
|
448
448
|
/**
|
|
449
|
-
* RB-402
|
|
449
|
+
* RB-402 — the design/36 ToolSearch activation set LIVE at this pass (the
|
|
450
450
|
* runner threads `[...prepared.activeTools]` on all three lanes: boundary, PTL recovery, finish).
|
|
451
451
|
* Persisted into the landed compaction entry's details (`CompactionDetails.activeTools`) so the
|
|
452
452
|
* NEXT task boundary's re-derivation — whose transcript source (ToolSearch toolCall parts) this
|
|
@@ -478,11 +478,11 @@ export declare function maybeCompact(opts: MaybeCompactOptions): Promise<{
|
|
|
478
478
|
* (auto/manual triggers only — never on "forced"). NOT a failure: the caller must not count it
|
|
479
479
|
* toward the compaction breaker; the next boundary consults the callback again. */
|
|
480
480
|
blocked?: boolean;
|
|
481
|
-
/** MF-18
|
|
481
|
+
/** MF-18 修①: set (with `compacted:false`) when compaction is DISABLED by settings
|
|
482
482
|
* (`enabled:false`) — the request can never be honored this run. Lets the caller resolve a manual
|
|
483
483
|
* /compact with the honest `"disabled"` outcome (and trace frame) instead of a structural noop. */
|
|
484
484
|
disabled?: boolean;
|
|
485
|
-
/** RB-398-b
|
|
485
|
+
/** RB-398-b: set (with `compacted:false`) when the pass PASSED the trigger gate
|
|
486
486
|
* (natural or forced) but found nothing to summarize — no valid cut point / empty history. Was
|
|
487
487
|
* previously indistinguishable from the quiet under-threshold return, so a forced pass with
|
|
488
488
|
* nothing to do looked identical to one that never wanted to run; the caller's outcome event
|
|
@@ -502,7 +502,7 @@ export declare function maybeCompact(opts: MaybeCompactOptions): Promise<{
|
|
|
502
502
|
firstKeptEntryId?: string;
|
|
503
503
|
/** design/84 Seam C: true when this compaction reused a `summaryProvider` summary (no LLM call). */
|
|
504
504
|
reused?: boolean;
|
|
505
|
-
/**
|
|
505
|
+
/** The working files re-read into the summary, in attachment order —
|
|
506
506
|
* surfaced so the `compacted` wire event carries them and a shell renders CC's post-compact
|
|
507
507
|
* `Read {path} (…)` cards. Set only when `compacted` is true and attachments were added. */
|
|
508
508
|
attachedFiles?: Array<{
|
|
@@ -517,7 +517,7 @@ export declare function maybeCompact(opts: MaybeCompactOptions): Promise<{
|
|
|
517
517
|
* sanitized auto threshold — the "couldn't compact it down" signal {@link nextTrimForceBackoff}
|
|
518
518
|
* consumes. Set only when `compacted` and the post measurement succeeded. */
|
|
519
519
|
postOverThreshold?: boolean;
|
|
520
|
-
/** TB telemetry B4
|
|
520
|
+
/** TB telemetry B4: wall time of the whole compaction pass (context build → summary
|
|
521
521
|
* call → history rewrite → post measurement). Set only when `compacted` — the `compacted` wire event
|
|
522
522
|
* carries it so a consumer sees what a boundary pause actually cost. */
|
|
523
523
|
durationMs?: number;
|
|
@@ -536,7 +536,7 @@ export declare function maybeCompact(opts: MaybeCompactOptions): Promise<{
|
|
|
536
536
|
* batch that adds an additive passthrough next to runtask's existing
|
|
537
537
|
* `...(comp.durationMs !== undefined ? { durationMs: comp.durationMs } : {})` spread. */
|
|
538
538
|
phaseDurations?: CompactionPhaseDurations;
|
|
539
|
-
/**
|
|
539
|
+
/** C3: set (with `compacted:false`) when the pass was over the auto threshold but the
|
|
540
540
|
* anti-thrash floor (`minTokens`) suppressed it — the caller bridges this to `compaction.suppressed`. */
|
|
541
541
|
suppressedByFloor?: {
|
|
542
542
|
estTokens: number;
|
|
@@ -569,7 +569,7 @@ export declare function maybeCompact(opts: MaybeCompactOptions): Promise<{
|
|
|
569
569
|
modelId?: string;
|
|
570
570
|
};
|
|
571
571
|
/**
|
|
572
|
-
* RB-126
|
|
572
|
+
* RB-126 (2026-07-25): the trigger inputs THIS pass used, reported on
|
|
573
573
|
* EVERY return path — including the ordinary "nothing to do" one. A consumer rendering "how full is the
|
|
574
574
|
* context" was otherwise forced to re-derive the numerator itself, and a re-derivation that drifts from
|
|
575
575
|
* the engine's own is the projection-antipattern this repo keeps paying for: the displayed percentage
|
package/dist/core/auto-mode.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export type AutoModeVerdict = {
|
|
|
33
33
|
* optional): a free-scan lets a prompt-injected preamble seed the verdict; our contract-anchored
|
|
34
34
|
* parse costs only a fallback to the original human chain on the mismatch, never a silent allow.
|
|
35
35
|
*
|
|
36
|
-
* Strictness is polarity-asymmetric (
|
|
36
|
+
* Strictness is polarity-asymmetric (confirmed HIGH):
|
|
37
37
|
* - an ALLOW must be UNAMBIGUOUS: `<block>no</block>` followed by anything but whitespace —
|
|
38
38
|
* a second conflicting `<block>yes</block>`, trailing prose, any tail at all — violates the
|
|
39
39
|
* contract and maps to `parse_error` (the ask flows the original human chain, never a silent
|
|
@@ -55,17 +55,17 @@ export interface AutoModeClassifyInput {
|
|
|
55
55
|
askMessage?: string;
|
|
56
56
|
}
|
|
57
57
|
/** The pluggable model leg: given the classify input, return the model's raw text response.
|
|
58
|
-
* Deployment-injected (roster cheap tier per
|
|
58
|
+
* Deployment-injected (roster cheap tier per); MAY throw / reject — the decider fail-closes. */
|
|
59
59
|
export type AutoModeClassifyFn = (input: AutoModeClassifyInput, signal?: AbortSignal) => Promise<string>;
|
|
60
60
|
export interface AutoModeDeciderOptions {
|
|
61
61
|
classify: AutoModeClassifyFn;
|
|
62
62
|
/** Hard cap on one classification round-trip. Default 15_000 ms (sema 裁量 — CC's constant is not
|
|
63
63
|
* established; a permission gate must not stall the whole run on a slow classifier). */
|
|
64
64
|
timeoutMs?: number;
|
|
65
|
-
/** Consecutive-failure threshold that opens the session breaker (default 3
|
|
65
|
+
/** Consecutive-failure threshold that opens the session breaker (default 3 "连续 N 失败").
|
|
66
66
|
* Failures = unavailable(error|timeout) + parse_error. A successful round (allow/block) resets it. */
|
|
67
67
|
failureThreshold?: number;
|
|
68
|
-
/** Fired ONCE when the breaker opens (
|
|
68
|
+
/** Fired ONCE when the breaker opens ("本 session 退回非 auto + 一次性告警"). */
|
|
69
69
|
onBreakerOpen?: (info: {
|
|
70
70
|
consecutiveFailures: number;
|
|
71
71
|
lastCause: string;
|
|
@@ -74,7 +74,7 @@ export interface AutoModeDeciderOptions {
|
|
|
74
74
|
export interface AutoModeDecider {
|
|
75
75
|
/** Never rejects. Any internal failure surfaces as `unavailable`/`parse_error` (fail-closed). */
|
|
76
76
|
decide(input: AutoModeClassifyInput, signal?: AbortSignal): Promise<AutoModeVerdict>;
|
|
77
|
-
/** True once the session breaker has opened (it never half-opens:
|
|
77
|
+
/** True once the session breaker has opened (it never half-opens: is a SESSION fallback
|
|
78
78
|
* to non-auto, not a retry window — a flapping classifier must not oscillate the permission mode). */
|
|
79
79
|
breakerOpen(): boolean;
|
|
80
80
|
}
|
|
@@ -28,10 +28,10 @@ export interface BackgroundAgentRecord {
|
|
|
28
28
|
/** The child's store session id — the transcript / resume anchor. Absent at put (the child session
|
|
29
29
|
* is minted AFTER registration); bound via a follow-up CAS update. */
|
|
30
30
|
sessionId?: string;
|
|
31
|
-
/** Spawn-time root linkage
|
|
31
|
+
/** Spawn-time root linkage — the durable enumeration key for task-scoped rows
|
|
32
32
|
* ({@link BackgroundAgentStore.listBySession}) and the restart read leg of the access predicate. */
|
|
33
33
|
parentSessionId?: string;
|
|
34
|
-
/**
|
|
34
|
+
/** the ROOT host session of the delegation tree (fixed point down the internals
|
|
35
35
|
* chain; equals parentSessionId at depth 1). The recovery-face enumeration anchor: after a
|
|
36
36
|
* restart, intermediate spawner sessions are dead ends — "everything under this host session"
|
|
37
37
|
* keys on THIS field (listBySession matches it as a second arm), not on an alias walk. */
|
|
@@ -46,7 +46,7 @@ export interface BackgroundAgentRecord {
|
|
|
46
46
|
/** design/151 §3.1d (HIGH-3): the WRITING process instance id (random per registry instance). A
|
|
47
47
|
* fallback read of a `running` row whose writer is not the reading instance serves an HONEST
|
|
48
48
|
* "outcome unknown here" — never a fabricated "running" liveness claim.
|
|
49
|
-
* S3 revival ORDER OBLIGATION
|
|
49
|
+
* S3 revival ORDER OBLIGATION: a cross-process revival must first CAS this field
|
|
50
50
|
* over to the reviving instance's writerId (the claim), THEN register-with-id — a fresh lane's
|
|
51
51
|
* first write against a row still carrying the dead process's writerId reads back "foreign" and
|
|
52
52
|
* poisons itself by design. Claim-CAS first is the only sequence the adjudication admits. */
|
|
@@ -78,7 +78,7 @@ export interface BackgroundAgentRecord {
|
|
|
78
78
|
status: "running" | "parked" | "completed" | "failed" | "killed";
|
|
79
79
|
/** Open enum (task-registry `StopSource` mirror). */
|
|
80
80
|
stoppedBy?: string;
|
|
81
|
-
/**
|
|
81
|
+
/** The cross-channel completion correlation id
|
|
82
82
|
* (task-registry `SemaTaskHandle.completionId` mirror). Written alongside `status`/`settledAt` at
|
|
83
83
|
* the same durable terminal write that lands them, so a cross-restart fallback read (`TaskOutput`
|
|
84
84
|
* after the writing process is gone) REPLAYS this exact value — there is no second mint point here,
|
|
@@ -110,7 +110,7 @@ export interface BackgroundAgentRecord {
|
|
|
110
110
|
* to preserve. */
|
|
111
111
|
finalOutputFull?: string;
|
|
112
112
|
/** The child's failure text (registry `handle.error` mirror; the reap-stop sentinel never lands here).
|
|
113
|
-
* RB-237
|
|
113
|
+
* RB-237: the stale-running reap flip ALSO writes its attribution here (`??`-guarded) —
|
|
114
114
|
* `error` is the field the durable serving face renders (`serveDurableAgentRow`), while `summary`
|
|
115
115
|
* has no reader on that face, so an attribution written only to `summary` was invisible: a host
|
|
116
116
|
* crash read as a bare `failed` + "(no result text)". */
|
|
@@ -200,9 +200,9 @@ export declare class BackgroundAgentStoreError extends Error {
|
|
|
200
200
|
* legitimate owner (the spawn-time task ids are dead). The live registry still does not grant the
|
|
201
201
|
* parentSessionId leg (an intermediate session must not steer a sibling turn's running child);
|
|
202
202
|
* the ROOT arm, however, is now on BOTH faces — RB-236 (2026-07-29) aligned the live `canAccess`
|
|
203
|
-
* with this predicate's
|
|
203
|
+
* with this predicate's root-session arm, closing the "running grandchild is not_found to
|
|
204
204
|
* the session that owns the tree" window. Durable rows remain the settled/read/revive face.
|
|
205
|
-
* Cross-session same-scope reads stay not_found (
|
|
205
|
+
* Cross-session same-scope reads stay not_found (content-axis ruling).
|
|
206
206
|
*
|
|
207
207
|
* Scope is FAIL-CLOSED both ways (`undefined` never matches) — records are put with a real scope.
|
|
208
208
|
*/
|
|
@@ -232,24 +232,24 @@ export declare function canAccessAgentRecord(record: Pick<BackgroundAgentRecord,
|
|
|
232
232
|
* writer does not heartbeat — the child is durably suspended, silence is its normal state; the
|
|
233
233
|
* checkpoint-bound reconciliation sweep, not row age, owns its cleanup). With no options, reap is
|
|
234
234
|
* a no-op (retention is always an explicit policy).
|
|
235
|
-
* Sizing
|
|
235
|
+
* Sizing: a LIVE writer renews its running rows' `updatedAt` every
|
|
236
236
|
* `DURABLE_AGENT_HEARTBEAT_MS` (60s — task-registry writer lease), so row age measures SILENCE —
|
|
237
|
-
* of the WRITER PROCESS, specifically
|
|
237
|
+
* of the WRITER PROCESS, specifically: a wedged child inside a healthy
|
|
238
238
|
* process keeps renewing and never goes stale, by design (in-process supervision owns that case).
|
|
239
239
|
* Set `staleRunningMaxAgeMs` ≥ 10× the heartbeat (≥10min). A premature flip still self-heals:
|
|
240
240
|
* the live writer's settle reads the row back, adopts the bumped rev (writerId match) and
|
|
241
241
|
* re-CASes the real terminal truth over the reaper's guess.
|
|
242
242
|
* ⚠️ Row deletion does NOT release the child SESSION (the store cannot reach the session store) —
|
|
243
|
-
* the blessed reap path is the registry-side orchestration (design/151 §3.1 MED-7 +
|
|
243
|
+
* the blessed reap path is the registry-side orchestration (design/151 §3.1 MED-7 +
|
|
244
244
|
* C-2): it conditionally DELETES the row under its re-verified rev first, and only a WINNING
|
|
245
245
|
* delete releases the transcript session (release-first destroyed a live transcript when a
|
|
246
246
|
* concurrent revive won the CAS after the release). Calling raw `reap` alone strands transcripts.
|
|
247
|
-
* Cross-process caveat
|
|
247
|
+
* Cross-process caveat: a revive's durable `running` transition rides the async
|
|
248
248
|
* lane — between the in-memory revive and its flush, a DIFFERENT process's sweep still holds a
|
|
249
249
|
* terminal-looking row whose rev the flush has not yet bumped. In-process sweeps are gated on the
|
|
250
250
|
* live handle; cross-process revival (S3) must claim-CAS FIRST (see {@link BackgroundAgentRecord.writerId}).
|
|
251
251
|
*/
|
|
252
|
-
/** RB-237
|
|
252
|
+
/** RB-237: the stale-running reap flip's attribution, written to BOTH `summary` (legacy
|
|
253
253
|
* slot, kept for any out-of-repo reader) and `error` (the field {@link canAccessAgentRecord}-gated
|
|
254
254
|
* durable serving actually renders). One exported constant so the two store implementations (in-memory
|
|
255
255
|
* here, file twin) can never drift apart (RB-74/RB-111 family). Wording carries CC 2.1.220's three
|
|
@@ -307,29 +307,29 @@ export interface BackgroundAgentStore {
|
|
|
307
307
|
*/
|
|
308
308
|
updateIf(handle: string, scope: string, record: BackgroundAgentRecord, expect: BackgroundAgentUpdateIfExpect): Promise<boolean>;
|
|
309
309
|
/** Rows whose durable session anchor (`sessionScoped ? owner : parentSessionId`) OR root anchor
|
|
310
|
-
* (`rootSessionId
|
|
310
|
+
* (`rootSessionId` — the whole delegation tree under one host session) equals
|
|
311
311
|
* `sessionId`, newest-first by `spawnedAt`. Content-free projections (HIGH-1). `opts.status`
|
|
312
312
|
* filters one state; `opts.limit` keeps the newest N after the sort. */
|
|
313
313
|
listBySession(scope: string, sessionId: string, opts?: {
|
|
314
314
|
status?: BackgroundAgentRecord["status"];
|
|
315
315
|
limit?: number;
|
|
316
316
|
}): Promise<BackgroundAgentRowSummary[]>;
|
|
317
|
-
/**
|
|
317
|
+
/** ALL of a scope's rows (content-free, newest-first): the joint-reap orchestration's
|
|
318
318
|
* enumeration face (`TaskRegistry.reapDurableAgents` — conditional delete first, session release
|
|
319
|
-
* only after a winning delete
|
|
319
|
+
* only after a winning delete). Deployment-op context, not a model-serving face —
|
|
320
320
|
* model-facing reads stay behind {@link canAccessAgentRecord}. */
|
|
321
321
|
listByScope(scope: string, opts?: {
|
|
322
322
|
status?: BackgroundAgentRecord["status"];
|
|
323
323
|
limit?: number;
|
|
324
324
|
}): Promise<BackgroundAgentRowSummary[]>;
|
|
325
|
-
/**
|
|
326
|
-
*
|
|
325
|
+
/** row-precise removal (the joint-reap deletion arm). Returns false on a miss.
|
|
326
|
+
* `expect.rev` makes it CONDITIONAL — a live writer's concurrent revival (heartbeat
|
|
327
327
|
* adopt bumps rev) must beat the reaper's stale snapshot, so the joint reap always deletes with
|
|
328
328
|
* the rev it just re-verified. */
|
|
329
329
|
delete(handle: string, scope: string, expect?: {
|
|
330
330
|
rev: number;
|
|
331
331
|
}): Promise<boolean>;
|
|
332
|
-
/**
|
|
332
|
+
/** Enumerate the scopes that currently hold rows, so a deployment-op
|
|
333
333
|
* retention loop can drive {@link TaskRegistry.reapDurableAgents} per scope without external
|
|
334
334
|
* bookkeeping (a local backend under multi-tenant use otherwise grows principal-scoped rows
|
|
335
335
|
* forever). Optional: a store whose deployment tracks scopes elsewhere (pg: SELECT DISTINCT)
|
|
@@ -359,7 +359,7 @@ export interface BackgroundAgentStore {
|
|
|
359
359
|
* run after the owning process exits) to fire.
|
|
360
360
|
* Every write is a rev-CAS — a live writer's concurrent transition wins and the sweep just skips.
|
|
361
361
|
*
|
|
362
|
-
* SPLIT-BRAIN FENCE (件1
|
|
362
|
+
* SPLIT-BRAIN FENCE (件1): failing a row whose PARKING PROCESS is still alive would
|
|
363
363
|
* desynchronize its live handle (poll keeps saying parked, TaskStop mis-reports). An in-process
|
|
364
364
|
* deployment therefore calls {@link import("./task-registry.js").TaskRegistry.reconcileParkedAgents}
|
|
365
365
|
* (which handles ITS OWN handles live, then delegates here with `excludeWriterId` = its writerId);
|
|
@@ -388,7 +388,7 @@ export interface BackgroundAgentQuery {
|
|
|
388
388
|
scope: string;
|
|
389
389
|
/**
|
|
390
390
|
* Session-anchored enumeration: a row qualifies when its durable anchor
|
|
391
|
-
* (`sessionScoped ? owner : parentSessionId`) OR its `rootSessionId` (
|
|
391
|
+
* (`sessionScoped ? owner : parentSessionId`) OR its `rootSessionId` (the whole
|
|
392
392
|
* delegation tree under one host session) equals this. ABSENT ⇒ scope-wide enumeration.
|
|
393
393
|
*/
|
|
394
394
|
sessionId?: string;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* 这是一个 **env 上的可选能力**(非一种独立 env 类型),所以不 `extends ExecutionEnv` —— 用交叉类型挂到具体实现上,并经
|
|
7
7
|
* {@link hasBackgroundShell} 运行时检测(对齐 remote-env.ts 的 `hasDestroy`/`isRemoteExecutionEnv` 模式,零 vendor 接口改动)。
|
|
8
8
|
*
|
|
9
|
-
* 设计裁定(经
|
|
9
|
+
* 设计裁定(经 + workflow 5-lens 双轨证伪式复审收敛,design/103 v2):
|
|
10
10
|
* - **不跨 durable suspend**:后台进程在每条退出路径被 dispose;Runner 必须在 suspendVM **之前** 调
|
|
11
11
|
* {@link BackgroundShellCapability.disposeBackgroundShells}(detached job 不在 suspendVM 的 in-flight 契约射程内)。
|
|
12
12
|
* - **越界隔离**:`pollBackground`/`killBackground` 的 shellId MUST 被校验为本 env 自己 spawn 过的;非本 env 走 `not_found`。
|
|
@@ -83,7 +83,7 @@ export interface BackgroundShellCapability {
|
|
|
83
83
|
readonly defaultBgTimeoutSec: number;
|
|
84
84
|
/** 后台 timeout **硬上限**(秒)。fail-closed 到有限值 —— **绝不允许无界**(design/103 §3.6)。 */
|
|
85
85
|
readonly maxBgTimeoutSec: number;
|
|
86
|
-
/** design/116 detach(
|
|
86
|
+
/** design/116 detach([C]):env 是否支持把前台 exec 的运行中子进程「领养」为后台(exec options 的
|
|
87
87
|
* `detachSignal`)。缺省/false ⇒ detach 请求被忽略(exec 继续前台跑完)。 */
|
|
88
88
|
readonly supportsDetach?: boolean;
|
|
89
89
|
/** design/128 T1-1 留驻声明(TB 2026-07-08 翻红回归修):env 声明后台进程 **outlive the run** ——
|
|
@@ -116,7 +116,7 @@ export interface BackgroundShellCapability {
|
|
|
116
116
|
* review 必须在 `suspendVM` 之前**(design/103 §3.7;detached job 不在 suspendVM in-flight 契约内,不能指望 adapter 隐式处理)。
|
|
117
117
|
* Best-effort,MUST NOT throw(像 `cleanup`/`destroy`)。幂等。
|
|
118
118
|
*
|
|
119
|
-
*
|
|
119
|
+
* `except`(可选):这些 shellId **留活**(session 驻留 persistent Monitor 的进程 —— 它的全部意义
|
|
120
120
|
* 就是跨 turn 存活;run-end 全灭会留下「registry handle 活着、进程死了」的孤儿 watch)。不认识此参数的旧
|
|
121
121
|
* 实现照旧全灭 = 今天的行为(诚实降级,not silent corruption:watcher 会打出 env-death 终态通知)。
|
|
122
122
|
* suspend/review 前的 dispose **不带** except(挂起整个 VM,进程死亡是既有契约)。
|
|
@@ -133,7 +133,7 @@ export interface BackgroundShellCapability {
|
|
|
133
133
|
*/
|
|
134
134
|
export declare function hasBackgroundShell(env: ExecutionEnv): env is ExecutionEnv & BackgroundShellCapability;
|
|
135
135
|
/**
|
|
136
|
-
*
|
|
136
|
+
* RB-164 — the ONE way core runs an env-level background sweep.
|
|
137
137
|
*
|
|
138
138
|
* ## Why a single entry point
|
|
139
139
|
* `disposeBackgroundShells` lives in the execution-env layer and cannot reach the task registry, so the
|
|
@@ -256,7 +256,7 @@ export declare function riskSeverity(axes: {
|
|
|
256
256
|
irreversible?: boolean;
|
|
257
257
|
shell?: boolean;
|
|
258
258
|
}): 1 | 2 | 3 | 4 | 5;
|
|
259
|
-
/** design S1e
|
|
259
|
+
/** design S1e: the char cap for the {@link CheckpointSummary.toolInput} BOUNDED raw preview of a
|
|
260
260
|
* `tool_approval` pendingAction's `args` (`JSON.stringify`-ed). Caps the `listByScope` payload size; over-cap
|
|
261
261
|
* is truncated with a trailing `…`. Bounded raw (NOT neutralized) — redaction is the consumer's job (echo-only). */
|
|
262
262
|
export declare const MAX_TOOL_INPUT_PREVIEW_CHARS = 512;
|
|
@@ -340,8 +340,8 @@ export interface PendingSteerInput {
|
|
|
340
340
|
* NO clock/random, so the SAME call ⇒ an IDENTICAL descriptor (pinned by a test).
|
|
341
341
|
*
|
|
342
342
|
* **Determinism contract = plain-DATA args** (the real flow: model-JSON / hook-rewritten plain objects). A
|
|
343
|
-
* Proxy whose `ownKeys` trap returns a DIFFERENT key set per call is OUT OF CONTRACT — JS cannot detect a
|
|
344
|
-
*
|
|
343
|
+
* Proxy whose `ownKeys` trap returns a DIFFERENT key set per call is OUT OF CONTRACT — JS cannot detect a
|
|
344
|
+
* Proxy, so its (display-only) digest may vary. This NEVER affects a security/budget/mint
|
|
345
345
|
* decision: `riskDescriptor` is INERT (no core path reads it to gate), so an out-of-contract input can at worst
|
|
346
346
|
* degrade an inbox preview, never a permission outcome.
|
|
347
347
|
*
|
|
@@ -695,22 +695,30 @@ export type PendingAction = {
|
|
|
695
695
|
toolName: string;
|
|
696
696
|
/** Post-hook (design/37-rewritten) args to execute on `allow`. */
|
|
697
697
|
args: unknown;
|
|
698
|
-
/**
|
|
698
|
+
/** (additive) — the tool's approval display projection of `args`, minted alongside the
|
|
699
699
|
* row (see AgentTool.approvalPreview; control-char-sanitized + 16KiB-clamped at mint).
|
|
700
700
|
* **UNTRUSTED, ADVISORY**: inboxes must escape contextually and surface `args` alongside.
|
|
701
701
|
* NEVER read by the resume path (args + boundInputHash stay the sole execution contract). */
|
|
702
702
|
preview?: unknown;
|
|
703
|
-
/** design/179 §4
|
|
704
|
-
*
|
|
705
|
-
*
|
|
706
|
-
*
|
|
707
|
-
*
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
|
|
703
|
+
/** design/179 §4, re-formed by design/375 §3.1/§3.3 (BREAKING — replaces the retired
|
|
704
|
+
* `ruleSuggestions` seat; a pre-375 inbox reading a new row simply finds no offers and renders
|
|
705
|
+
* no "don't ask again" option, fail toward asking) — the persistable allow-rule OFFERS this
|
|
706
|
+
* parked call could be covered by, minted from the SAME post-hook args the row executes.
|
|
707
|
+
* Advisory display metadata for the approval inbox's "stop asking me this" option; never read
|
|
708
|
+
* by the resume path, and never a rule by itself (minting one goes through the approval-record
|
|
709
|
+
* protocol). Absent when no rule lane is armed, the command is one the lane cannot speak for,
|
|
710
|
+
* or the parked ask is one a persisted rule could not clear (mandated marks / a real-approval
|
|
711
|
+
* demand / a shadowed matching rule).
|
|
712
|
+
* CONTRACT (same as the synchronous `AskRequest.ruleOffers` — see
|
|
713
|
+
* {@link import("./permission-rule-model.js").RuleOffer}): at most 2 offers, the whole-string
|
|
714
|
+
* EXACT single always index 0 when present, the BATCH offer (choosing it is one yes to ALL of
|
|
715
|
+
* its 1..5 per-segment rules at once) always last; selection indices are keyed against this
|
|
716
|
+
* order (redemption TICKETS are keyed on the consent record's flat CANDIDATE list instead —
|
|
717
|
+
* a chosen offer is redeemed via `redeemRuleBatch`), per-element parse with single-row
|
|
718
|
+
* degrade on an unknown `kind` and
|
|
719
|
+
* original-index preservation. The park→resume redemption chain walks the same consent
|
|
720
|
+
* protocol as the synchronous card — there is no second form. */
|
|
721
|
+
ruleOffers?: readonly import("./permission-rule-model.js").RuleOffer[];
|
|
714
722
|
/**
|
|
715
723
|
* design/80 D-1 §2 (slice 1a.2): the server-minted **opaque** boundInputHash of {@link args} — a
|
|
716
724
|
* SHA-256 (hex) via {@link import("./canonical-json.js").boundInputHashOf}, computed ONCE here at
|
|
@@ -797,7 +805,7 @@ export interface CheckpointState {
|
|
|
797
805
|
pattern: string;
|
|
798
806
|
caseSensitive: boolean;
|
|
799
807
|
}>;
|
|
800
|
-
/**
|
|
808
|
+
/** REDUNDANT governance marker: `true` iff the row's gate was minted WITH a
|
|
801
809
|
* {@link RealApprovalGateBit}. v8's bit-required invariant was version-keyed and v9 (face)
|
|
802
810
|
* outranks v8 in the stamp, so without this a v9 GOVERNED row whose `gate.realApproval` member
|
|
803
811
|
* was dropped in storage would pass pre-CAS and be redeemable on an unwired worker — the exact
|
|
@@ -895,7 +903,7 @@ export interface CheckpointState {
|
|
|
895
903
|
* :707384-707399 under the `CLAUDE_CODE_RESUME_INTERRUPTED_TURN` gate — the cloud-worker restart
|
|
896
904
|
* leg, exactly sema's durable-resume shape): the background tasks (pending/running, this run's
|
|
897
905
|
* owner triple) still ALIVE at suspend. Background processes never survive a suspend (design/103
|
|
898
|
-
* §3.7 unconditional dispose +
|
|
906
|
+
* §3.7 unconditional dispose + killed receipts), so on resume any snapshot entry NOT
|
|
899
907
|
* alive in the resume leg's registry is an ORPHAN — aggregated into ONE CC-verbatim "The container
|
|
900
908
|
* was restarted…" reminder appended to the resume continuation (single message: header +
|
|
901
909
|
* `- description (task id)` list + re-create instruction; never a per-task barrage). A survivor
|
|
@@ -910,7 +918,7 @@ export interface CheckpointState {
|
|
|
910
918
|
description?: string;
|
|
911
919
|
}>;
|
|
912
920
|
/**
|
|
913
|
-
*
|
|
921
|
+
* the hands band's LOGICAL working directory at suspend (`handsCwdRef.current` —
|
|
914
922
|
* moved by `cd` and by EnterWorktree). Without it a resume silently reset the task cwd to the task root:
|
|
915
923
|
* relative Read/Edit/Write paths and Bash commands then operated somewhere else than the model believes.
|
|
916
924
|
* Absent when the task has no tracked cwd (no real shell / read-only hands). The directory itself is
|
|
@@ -918,7 +926,7 @@ export interface CheckpointState {
|
|
|
918
926
|
*/
|
|
919
927
|
handsCwd?: string;
|
|
920
928
|
/**
|
|
921
|
-
*
|
|
929
|
+
* the ACTIVE EnterWorktree session at suspend (worktree.ts keeps it in a shared
|
|
922
930
|
* serializable ref, not a closure-only var, precisely so it lands here). Without it a resume LOST the
|
|
923
931
|
* session: ExitWorktree became a no-op (the unchanged worktree could never be removed), a second
|
|
924
932
|
* EnterWorktree was wrongly accepted, and `handsCwd` pointed into a worktree the tooling no longer
|
|
@@ -1145,7 +1153,7 @@ export declare const TOKEN_CHECKPOINT_VERSION = 5;
|
|
|
1145
1153
|
*/
|
|
1146
1154
|
export declare const ORG_ADMISSION_CHECKPOINT_VERSION = 6;
|
|
1147
1155
|
/**
|
|
1148
|
-
* F-012 (2026-08-09 — the ORG_ADMISSION_CHECKPOINT_VERSION precedent replayed a fifth time
|
|
1156
|
+
* F-012 (2026-08-09 — the ORG_ADMISSION_CHECKPOINT_VERSION precedent replayed a fifth time
|
|
1149
1157
|
* falsification-style finding): the schema version a suspend stamps when its state carries the F-012 durable
|
|
1150
1158
|
* enforcement fields — `inheritedGate.constraintChain`/`constraintDigest` (the frozen ancestor
|
|
1151
1159
|
* projection chain the resume-edit re-adjudication executes) or `delegationProvenance` (the monotonic
|
|
@@ -1463,7 +1471,7 @@ export interface Checkpoint {
|
|
|
1463
1471
|
*/
|
|
1464
1472
|
rev?: number;
|
|
1465
1473
|
/**
|
|
1466
|
-
* design S1d (source-tag persistence
|
|
1474
|
+
* design S1d (source-tag persistence): the issuing task's session id, stamped at the
|
|
1467
1475
|
* APPROVAL suspend mint so a supervisor inbox can attribute a paused/awaiting checkpoint to the worker that
|
|
1468
1476
|
* raised it (the durable analog of {@link import("./tool-policy.js").AskRequest}.sourceTaskId — the durable
|
|
1469
1477
|
* suspend path does NOT invoke `onAsk`, so the synchronous source identity is captured here instead). It is
|
|
@@ -1546,14 +1554,14 @@ export interface CheckpointSummary {
|
|
|
1546
1554
|
* suspend — projected so the inbox shows WHICH call awaits a decision without an N+1 `getCheckpoint`.
|
|
1547
1555
|
* `undefined` for a non-`tool_approval` pendingAction (resource_limit / plan_review / task_done).
|
|
1548
1556
|
*
|
|
1549
|
-
* **ABSENCE SHAPE (contract
|
|
1557
|
+
* **ABSENCE SHAPE (contract)** — shared by every optional field on this projection: a
|
|
1550
1558
|
* tool-less park (`resource_limit` / `plan_review` / `task_done` — none of which binds a tool call)
|
|
1551
1559
|
* gets the key **OMITTED**, never `null` and never a present-but-`undefined` property. The
|
|
1552
1560
|
* `PendingAction` arms for those kinds declare no tool/binding fields at all, so there is nothing to
|
|
1553
1561
|
* project; `summarizeCheckpoint` spreads them conditionally for exactly this reason. A consumer
|
|
1554
1562
|
* therefore tests presence (`"toolCallId" in summary`), and a re-projecting service (BFF / SDK wire
|
|
1555
1563
|
* face) must not materialize the keys as `null` on the way out. Pinned in
|
|
1556
|
-
* `test/checkpoint-store.test.ts` ("
|
|
1564
|
+
* `test/checkpoint-store.test.ts` ("tool-less park …"). */
|
|
1557
1565
|
toolCallId?: string;
|
|
1558
1566
|
/** The pending tool's name ({@link PendingAction} `tool_approval.toolName`) when this is an approval suspend.
|
|
1559
1567
|
* OMITTED (not `null`) for a non-`tool_approval` pendingAction — see {@link toolCallId}'s absence-shape note. */
|
|
@@ -1565,13 +1573,13 @@ export interface CheckpointSummary {
|
|
|
1565
1573
|
* this lightweight `listByScope` projection). Deliberately NOT a new `content_ask` checkpoint gate kind (that
|
|
1566
1574
|
* would cross the durable-checkpoint once-only-winner / reaper-deadline / batch invariants — the DoR). */
|
|
1567
1575
|
contentKind?: "content_ask";
|
|
1568
|
-
/** design S1e
|
|
1576
|
+
/** design S1e: when the checkpoint was created ({@link Checkpoint.createdAt}, epoch ms) —
|
|
1569
1577
|
* projected so a supervisor inbox can sort/age pending entries (oldest-first triage) in ONE `listByScope`
|
|
1570
1578
|
* call, no N+1 `getCheckpoint`. ECHO-ONLY display/triage; always present (a Checkpoint always has a
|
|
1571
1579
|
* `createdAt`). */
|
|
1572
1580
|
createdAt?: number;
|
|
1573
1581
|
/**
|
|
1574
|
-
* design S1e
|
|
1582
|
+
* design S1e: a **BOUNDED, UNREDACTED** raw preview of the pending tool call's input
|
|
1575
1583
|
* ({@link PendingAction} `tool_approval.args` `JSON.stringify`-ed, truncated to {@link
|
|
1576
1584
|
* MAX_TOOL_INPUT_PREVIEW_CHARS} chars with a `…` marker when over) — projected so a supervisor inbox shows
|
|
1577
1585
|
* WHAT a paused tool call will do without an N+1 `getCheckpoint`. `undefined` for a non-`tool_approval`
|
|
@@ -1600,7 +1608,7 @@ export interface CheckpointSummary {
|
|
|
1600
1608
|
* workspace at all. ECHO-ONLY display/triage — nothing gates on it. Mirrors `TaskResult.workspaceRestoreMode`.
|
|
1601
1609
|
*/
|
|
1602
1610
|
restoreMode?: "snapshot" | "park_only";
|
|
1603
|
-
/**
|
|
1611
|
+
/** the tool's approval display projection ({@link PendingAction} `preview`),
|
|
1604
1612
|
* projected so the ONE-CALL inbox (`listByScope`) can render a rich confirmation without an N+1
|
|
1605
1613
|
* `get`. Same trust posture as `toolInput`: **UNTRUSTED, advisory display metadata** (strings are
|
|
1606
1614
|
* sanitized of control chars at mint but may still carry model-authored markdown — renderers must
|
|
@@ -2180,7 +2188,7 @@ export interface CheckpointStore {
|
|
|
2180
2188
|
*/
|
|
2181
2189
|
listByScope?(scope: string): Promise<CheckpointSummary[]>;
|
|
2182
2190
|
/**
|
|
2183
|
-
*
|
|
2191
|
+
* Deployment seam: the DISTINCT scopes that currently have at least one PENDING checkpoint — the
|
|
2184
2192
|
* enumeration face `listByScope` lacks. A host keeping its own scope registry (e.g. a sidecar file for a
|
|
2185
2193
|
* cross-scope inbox) can rebuild it from the data itself when the registry is lost/corrupt, instead of the
|
|
2186
2194
|
* enumeration silently going empty and pending approvals turning invisible. Scoped to PENDING deliberately:
|
|
@@ -118,7 +118,7 @@ export interface ContextEditOptions {
|
|
|
118
118
|
persist: (toolCallId: string, fullText: string) => string;
|
|
119
119
|
};
|
|
120
120
|
/**
|
|
121
|
-
* design/123 D3 (
|
|
121
|
+
* design/123 D3 (= fable-M5) — ANCHORED accounting start: `estimateContextTokens(messages,
|
|
122
122
|
* charsPerToken).tokens` for the SAME message array. When set, the trigger gate AND the internal
|
|
123
123
|
* bookkeeping start from this usage-anchored value instead of the pure structural sum (which
|
|
124
124
|
* underestimates code by ~25% and CJK by 60–75% — the defense would self-certify and pass
|
|
@@ -8,7 +8,7 @@ import type { Model } from "../internal/llm.js";
|
|
|
8
8
|
* budget, dropping older regular messages at a safe boundary (never starting on an orphan
|
|
9
9
|
* toolResult). Returns the original array when already within budget.
|
|
10
10
|
*
|
|
11
|
-
* design/123 D3 (
|
|
11
|
+
* design/123 D3 (= fable-M5) — anchored accounting: when `anchoredTotalTokens`
|
|
12
12
|
* (= `estimateContextTokens(messages, charsPerToken).tokens` for the SAME array) is provided, the
|
|
13
13
|
* trigger gate and the internal bookkeeping start from the usage-anchored value instead of the
|
|
14
14
|
* structural sum (which underestimates code/CJK and lets over-window requests through). Dropping a
|