@sema-agent/core 5.57.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 +48 -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 +2 -2
- package/dist/agents/subagent-steps.d.ts +1 -1
- package/dist/agents/subagent.d.ts +13 -13
- package/dist/agents/team.d.ts +5 -5
- 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/degrading.d.ts +1 -1
- package/dist/brain/errors.d.ts +3 -3
- package/dist/brain/reasoning.d.ts +2 -2
- package/dist/brain/repetition.d.ts +1 -1
- 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/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 +47 -3
- package/dist/core/memory-engine/engine.js +37 -3
- 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 +185 -36
- package/dist/core/permission-rule-consent.js +219 -44
- package/dist/core/permission-rule-model.d.ts +194 -31
- package/dist/core/permission-rule-model.js +93 -35
- 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 +21 -14
- package/dist/core/runner/prepare-workspace-restore.d.ts +2 -2
- package/dist/core/runner/runtask.d.ts +11 -11
- 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 +5 -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 +2 -2
- 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 +123 -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/messages.d.ts +1 -1
- package/dist/engine/harness/types.d.ts +10 -10
- package/dist/engine/llm/types.d.ts +14 -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 +5 -4
- package/dist/index.js +3 -2
- 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 +8 -8
- 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 +1 -1
- 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/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/task-list.d.ts +2 -2
- package/dist/tools/web.d.ts +4 -4
- package/dist/tools/worktree.d.ts +5 -5
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +56 -3
|
@@ -75,7 +75,7 @@ export declare function readDegradation(msg: {
|
|
|
75
75
|
diagnostics?: AssistantMessageDiagnostic[];
|
|
76
76
|
} | undefined): DegradationInfo | undefined;
|
|
77
77
|
/**
|
|
78
|
-
* design/131
|
|
78
|
+
* design/131 — resilience-standdown pass-through: forward one brain's stream
|
|
79
79
|
* verbatim, but keep the decorator discipline that a REJECTING inner brain (throw instead of an
|
|
80
80
|
* error event) still leaves a terminal on the returned stream — otherwise `result()` never
|
|
81
81
|
* resolves and the harness hangs (the same class as the degradation-brain blocker).
|
package/dist/brain/errors.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare const ZERO_USAGE: Usage;
|
|
|
12
12
|
/** The single source of truth for brain error codes — the type, the `[code]` parser, and the prefix
|
|
13
13
|
* stripper all derive from this one list, so adding a code can't silently diverge across call sites.
|
|
14
14
|
*
|
|
15
|
-
* The last three are IN-BAND terminal-output codes
|
|
15
|
+
* The last three are IN-BAND terminal-output codes: stamped on errored assistant MESSAGES
|
|
16
16
|
* (never thrown as BrainError) so `TaskResult.errorCode` covers the error family end-to-end and
|
|
17
17
|
* downstream consumers can bucket without string-matching. Deliberately behavior-neutral everywhere
|
|
18
18
|
* else: the circuit breaker's default countCodes excludes them (model-output problems, not provider
|
|
@@ -27,7 +27,7 @@ export type BrainErrorCode = (typeof BRAIN_ERROR_CODES)[number];
|
|
|
27
27
|
* tool-errors.ts must classify every member — a code added here but missed there folds to "unknown"). */
|
|
28
28
|
export declare const ALL_BRAIN_ERROR_CODES: readonly BrainErrorCode[];
|
|
29
29
|
/** The in-band terminal-output subset (see the list doc above). The circuit breaker collapses these
|
|
30
|
-
* to the legacy `"http"` bucket before counting
|
|
30
|
+
* to the legacy `"http"` bucket before counting: its taxonomy is TRANSPORT-level,
|
|
31
31
|
* and before these codes existed the same failures reached it as the unprefixed→"http" fallback — a
|
|
32
32
|
* custom `countCodes: ["http"]` policy must keep counting them exactly as it always did. */
|
|
33
33
|
export declare const IN_BAND_OUTPUT_CODES: ReadonlySet<BrainErrorCode>;
|
|
@@ -65,7 +65,7 @@ export declare function stripErrorCodePrefix(errorMessage: string): string;
|
|
|
65
65
|
*/
|
|
66
66
|
export type ConnectFailureClass = "deterministic" | "indeterminate";
|
|
67
67
|
export declare function classifyConnectFailure(e: unknown): ConnectFailureClass;
|
|
68
|
-
/** RB-386③
|
|
68
|
+
/** RB-386③ — render a transport-level error WITHOUT folding away its cause chain. undici's
|
|
69
69
|
* `fetch` rejects with `TypeError("fetch failed", { cause })` where the CAUSE carries the actually
|
|
70
70
|
* actionable fact (`connect ECONNREFUSED …` / `getaddrinfo ENOTFOUND …` / `SocketError: other side
|
|
71
71
|
* closed` with a `code`); `String(e)` / `e.message` alone collapsed ALL THREE network-failure shapes
|
|
@@ -92,7 +92,7 @@ export interface ReasoningResolution {
|
|
|
92
92
|
* the cap-wins predicate below and the brain's budget-window math read ONE constant. */
|
|
93
93
|
export declare const MIN_THINKING_TOKENS = 1024;
|
|
94
94
|
/**
|
|
95
|
-
* The anthropic BUDGET path's cap-wins arm (#346, single-sourced; design/119 #2 review
|
|
95
|
+
* The anthropic BUDGET path's cap-wins arm (#346, single-sourced; design/119 #2 review):
|
|
96
96
|
* a HARD per-request output cap (an engine-imposed override or the caller's explicit
|
|
97
97
|
* `options.maxTokens` — the two lanes the brain refuses to raise) too small to host a legal thinking
|
|
98
98
|
* budget (≥ {@link MIN_THINKING_TOKENS}) plus answer room means the CAP WINS and thinking is skipped
|
|
@@ -276,7 +276,7 @@ export interface ReasoningProfileFlags {
|
|
|
276
276
|
}
|
|
277
277
|
/**
|
|
278
278
|
* design/96 §D (S4) — map a named {@link ReasoningTier} to its engine {@link ReasoningProfileFlags} (default
|
|
279
|
-
* mapping). G2
|
|
279
|
+
* mapping). G2: the intensity→capability mapping is PROFILE-layer data — core gives this primitive +
|
|
280
280
|
* a sane default; a profile/scenario layer calls it (and may override the table) to set a task's `thinking` +
|
|
281
281
|
* prompt flags. Core never forces it. Returns a fresh COPY (callers may mutate).
|
|
282
282
|
*/
|
|
@@ -36,7 +36,7 @@ export declare const DEGENERATE_MESSAGE = "degenerate repetition detected \u2014
|
|
|
36
36
|
* One detector hit — either the event that CUT a stream (`degenerate`) or a repetition that landed in
|
|
37
37
|
* a detection window but was SPARED by a 2e1c161 structural allowance (code-line shape / divider run).
|
|
38
38
|
* Spared events are the RSI raw material for judging whether the allowance is too wide or too narrow
|
|
39
|
-
* (
|
|
39
|
+
* (2026-07-10: the detector must report counts AND the detected segment, not just a boolean).
|
|
40
40
|
*/
|
|
41
41
|
export interface RepetitionEvent {
|
|
42
42
|
/** Which rule's window the repetition landed in: rule 1 (`char-run`) or rule 2 (`unit-loop`). */
|
|
@@ -18,7 +18,7 @@ export declare function runWithStatusSink<T>(emit: (s: BrainStatus) => void, fn:
|
|
|
18
18
|
*/
|
|
19
19
|
export declare function emitBrainStatus(status: BrainStatus): void;
|
|
20
20
|
/**
|
|
21
|
-
* Silent-fallback telemetry (
|
|
21
|
+
* Silent-fallback telemetry (C1/C4/C5/C6) — the brain→runner TELEMETRY channel, a
|
|
22
22
|
* SECOND ALS sink parallel to the status one. Statuses are user-facing liveness frames (wire
|
|
23
23
|
* `status` events); telemetry is operator-facing fallback accounting the Runner bridges to trace
|
|
24
24
|
* events (`brain.failover` / `breaker.transition` / `brain.retry` / `vision.placeholder`). Kept
|
|
@@ -52,7 +52,7 @@ export type BrainTelemetry = {
|
|
|
52
52
|
}
|
|
53
53
|
/** PDF read: a `document` content block was substituted with a text placeholder because the serving
|
|
54
54
|
* API/model cannot take native document input (openai brain always; anthropic brain when the model
|
|
55
|
-
* declares no vision). Silent quality loss → frame (same
|
|
55
|
+
* declares no vision). Silent quality loss → frame (same C4 discipline as vision_placeholder). */
|
|
56
56
|
| {
|
|
57
57
|
kind: "document_placeholder";
|
|
58
58
|
count: number;
|
|
@@ -35,7 +35,7 @@ export interface RepetitionPoll {
|
|
|
35
35
|
readonly spared: RepetitionEvent[];
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* Repetition telemetry (
|
|
38
|
+
* Repetition telemetry (2026-07-10): the cut event + allowance-spared hits for THIS stream.
|
|
39
39
|
* Polls re-inspect the same growing text every ~64 chars — dedupe spared by rule+segment so one
|
|
40
40
|
* boot block doesn't log once per poll. Attached to the final message as `repetition`.
|
|
41
41
|
*/
|
package/dist/config/catalog.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Config catalog (
|
|
2
|
+
* Config catalog (ruled 2026-07-19) — the SINGLE machine-readable source for the engineering
|
|
3
3
|
* configuration scale across every client (server / cli / TB harness / future shells).
|
|
4
4
|
*
|
|
5
5
|
* Why this exists: the same knob was found carrying FIVE different values across layers (maxTurns:
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* nothing) or overrides it and DECLARES the override (`TaskSpec.configOverrides`, with a
|
|
13
13
|
* reason). Declared overrides ride the `config.assembled` trace, so every run self-reports its
|
|
14
14
|
* true knobs and their provenance — "who set 80" becomes a trace read, not archaeology.
|
|
15
|
-
* 3. **Announced change discipline
|
|
16
|
-
* changing one (or overriding persistently) posts the change to the shared
|
|
15
|
+
* 3. **Announced change discipline**: the recommendations are a living baseline — any repo
|
|
16
|
+
* changing one (or overriding persistently) posts the change to the shared config record so the
|
|
17
17
|
* scale evolves deliberately, together.
|
|
18
18
|
*
|
|
19
19
|
* v1 scope: the cross-client TASK-LAUNCH knobs (the chaos surface). Internal engine tuning
|
|
@@ -62,12 +62,12 @@ export interface EffectiveConfigField {
|
|
|
62
62
|
value: number | boolean | string | null;
|
|
63
63
|
provenance: ConfigProvenance;
|
|
64
64
|
}
|
|
65
|
-
/** Declaration bounds
|
|
65
|
+
/** Declaration bounds: host strings ride the trace stream — bounded and sanitized, never
|
|
66
66
|
* free-form. Beyond `MAX_OVERRIDE_DECLARATIONS` entries are dropped (count-capped, first-N kept). */
|
|
67
67
|
export declare const MAX_OVERRIDE_DECLARATIONS = 32;
|
|
68
68
|
/**
|
|
69
69
|
* Build the effective task-launch config + provenance from a spec's launch fields. Pure. The
|
|
70
|
-
* manifest must mirror ENGINE truth, not the spec's surface
|
|
70
|
+
* manifest must mirror ENGINE truth, not the spec's surface: `maxOutputTokens` falls back
|
|
71
71
|
* to the model's own cap (provenance `derived`) before "provider default".
|
|
72
72
|
*/
|
|
73
73
|
export declare function resolveEffectiveConfig(spec: {
|
|
@@ -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
|