@sema-agent/core 7.56.0 → 7.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 +926 -0
- package/LICENSE +1 -1
- package/dist/agents/org-delivery-gate.js +3 -4
- package/dist/agents/peer-held-queue.d.ts +69 -49
- package/dist/agents/peer-held-queue.js +255 -106
- package/dist/agents/peer-session-drain.js +63 -43
- package/dist/agents/send-message-tool.js +3 -2
- package/dist/agents/subagent-steps.js +2 -4
- package/dist/agents/subagent.js +8 -8
- package/dist/brain/anthropic.js +16 -8
- package/dist/brain/open-responses.js +10 -8
- package/dist/brain/openai.js +11 -9
- package/dist/brain/provider-dialect.d.ts +3 -2
- package/dist/brain/provider-dialect.js +2 -2
- package/dist/brain/request-params.d.ts +6 -0
- package/dist/brain/request-params.js +14 -1
- package/dist/brain/route-adjudicator.js +2 -1
- package/dist/brain/stream-engine.d.ts +9 -0
- package/dist/brain/stream-engine.js +24 -10
- package/dist/brain/stream-shared.d.ts +5 -4
- package/dist/brain/stream-shared.js +4 -4
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +23 -10
- package/dist/core/allow-entry.d.ts +5 -11
- package/dist/core/allow-entry.js +19 -26
- package/dist/core/approval-object.d.ts +21 -5
- package/dist/core/approval-object.js +44 -17
- package/dist/core/ask-origin.d.ts +23 -4
- package/dist/core/ask-origin.js +5 -1
- package/dist/core/auto-compaction.d.ts +75 -6
- package/dist/core/auto-compaction.js +43 -27
- package/dist/core/auto-mode-directive.d.ts +29 -5
- package/dist/core/auto-mode-directive.js +38 -8
- package/dist/core/background-agent-store.d.ts +6 -2
- package/dist/core/background-agent-store.js +1 -1
- package/dist/core/checkpoint-requirements.d.ts +13 -1
- package/dist/core/checkpoint-requirements.js +4 -0
- package/dist/core/checkpoint-store.d.ts +44 -40
- package/dist/core/checkpoint-store.js +32 -14
- package/dist/core/cross-boundary-taint.js +4 -2
- package/dist/core/engine-notice.d.ts +4 -3
- package/dist/core/engine-notice.js +6 -0
- package/dist/core/file-history-store.d.ts +14 -8
- package/dist/core/file-history-store.js +14 -4
- package/dist/core/fs-write-gate-policy.d.ts +4 -2
- package/dist/core/fs-write-gate-policy.js +7 -3
- package/dist/core/gate-fold.js +6 -3
- package/dist/core/gate-lanes.js +13 -5
- package/dist/core/git-worktree-env.d.ts +53 -11
- package/dist/core/git-worktree-env.js +96 -12
- package/dist/core/hooks.d.ts +6 -3
- package/dist/core/hooks.js +12 -5
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/locked-config.d.ts +15 -1
- package/dist/core/locked-config.js +38 -2
- package/dist/core/mailbox-store.d.ts +62 -1
- package/dist/core/mailbox-store.js +59 -0
- package/dist/core/mcp-call-meta.d.ts +66 -0
- package/dist/core/mcp-call-meta.js +103 -0
- package/dist/core/mcp-connection-pool.d.ts +3 -1
- package/dist/core/mcp-connection-pool.js +3 -1
- package/dist/core/mcp-failure.d.ts +7 -1
- package/dist/core/mcp-failure.js +10 -0
- package/dist/core/mcp-name-judge.d.ts +46 -0
- package/dist/core/mcp-name-judge.js +61 -0
- package/dist/core/mcp-probe.d.ts +5 -1
- package/dist/core/mcp-probe.js +3 -6
- package/dist/core/mcp-server-link.d.ts +5 -2
- package/dist/core/mcp-server-spec.d.ts +46 -18
- package/dist/core/mcp-server-spec.js +1 -18
- package/dist/core/mcp.d.ts +6 -14
- package/dist/core/mcp.js +85 -65
- package/dist/core/memory-engine/consolidation-driver.js +4 -3
- package/dist/core/memory-engine/distiller.js +26 -17
- package/dist/core/memory-engine/layout.js +5 -2
- package/dist/core/memory-engine/scope-contract.d.ts +45 -4
- package/dist/core/memory-engine/scope-contract.js +80 -11
- package/dist/core/mode-policy.d.ts +8 -5
- package/dist/core/mode-policy.js +5 -4
- package/dist/core/mods/host.js +1 -1
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +10 -8
- package/dist/core/mods/kernel/events.d.ts +5 -1
- package/dist/core/mods/kernel/events.js +1 -1
- package/dist/core/mods/kernel/registration.d.ts +5 -1
- package/dist/core/mods/kernel/site-rules.d.ts +3 -0
- package/dist/core/mods/kernel/site-rules.js +10 -0
- package/dist/core/mods/package.d.ts +23 -0
- package/dist/core/mods/package.js +118 -0
- package/dist/core/mods/stations.d.ts +2 -2
- package/dist/core/mods/stations.js +1 -1
- package/dist/core/mods/tool-call.d.ts +5 -1
- package/dist/core/mods/tool-call.js +12 -3
- package/dist/core/park-selfcheck.js +2 -0
- package/dist/core/path-guard-rows.d.ts +20 -0
- package/dist/core/path-guard-rows.js +11 -0
- package/dist/core/peer-seat.d.ts +186 -0
- package/dist/core/peer-seat.js +307 -0
- package/dist/core/permission-rule-consent.d.ts +5 -3
- package/dist/core/permission-rule-consent.js +20 -15
- package/dist/core/permission-rule-model.d.ts +43 -2
- package/dist/core/permission-rule-model.js +52 -8
- package/dist/core/permission-rule-org.js +1 -1
- package/dist/core/present-plan-tool.d.ts +10 -1
- package/dist/core/present-plan-tool.js +46 -2
- package/dist/core/protocol-http-auth.d.ts +56 -31
- package/dist/core/protocol-http-auth.js +71 -42
- package/dist/core/protocol-naming.d.ts +20 -0
- package/dist/core/protocol-naming.js +20 -3
- package/dist/core/read-only-shell.d.ts +20 -5
- package/dist/core/read-only-shell.js +29 -14
- package/dist/core/redaction-marks.d.ts +16 -0
- package/dist/core/redaction-marks.js +16 -0
- package/dist/core/redaction-passes.js +8 -9
- package/dist/core/remote-env.d.ts +37 -1
- package/dist/core/remote-env.js +11 -0
- package/dist/core/resume-startup-cause.d.ts +24 -2
- package/dist/core/resume-startup-cause.js +20 -1
- package/dist/core/retention.d.ts +41 -15
- package/dist/core/retention.js +59 -12
- package/dist/core/rewrite-rejudge.d.ts +37 -0
- package/dist/core/rewrite-rejudge.js +40 -0
- package/dist/core/roles.js +50 -7
- package/dist/core/run-origin.d.ts +40 -0
- package/dist/core/run-origin.js +37 -0
- package/dist/core/runner/advertised-writable-dirs.d.ts +57 -38
- package/dist/core/runner/advertised-writable-dirs.js +126 -0
- package/dist/core/runner/compact-session.d.ts +10 -0
- package/dist/core/runner/compact-session.js +202 -0
- package/dist/core/runner/compaction-call-options.d.ts +2 -2
- package/dist/core/runner/compaction-restate.d.ts +15 -6
- package/dist/core/runner/compaction-restate.js +28 -2
- package/dist/core/runner/compaction-seams.d.ts +21 -1
- package/dist/core/runner/compaction-seams.js +11 -8
- package/dist/core/runner/contracts.d.ts +36 -21
- package/dist/core/runner/derived-route-fallback.d.ts +13 -0
- package/dist/core/runner/derived-route-fallback.js +6 -0
- package/dist/core/runner/env-capability-census.d.ts +3 -2
- package/dist/core/runner/env-capability-census.js +9 -3
- package/dist/core/runner/gate-exit.d.ts +18 -4
- package/dist/core/runner/gate-exit.js +5 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +7 -7
- package/dist/core/runner/permission-rule-lanes.js +17 -11
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +3 -0
- package/dist/core/runner/prepare-acquire-reconcile.js +2 -1
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +1 -1
- package/dist/core/runner/prepare-config-doors.d.ts +14 -5
- package/dist/core/runner/prepare-config-doors.js +16 -13
- package/dist/core/runner/prepare-delegation-surface.d.ts +4 -0
- package/dist/core/runner/prepare-delegation-surface.js +15 -18
- package/dist/core/runner/prepare-gate-stations.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +10 -4
- package/dist/core/runner/prepare-hands-readface.js +6 -1
- package/dist/core/runner/prepare-memory.d.ts +3 -0
- package/dist/core/runner/prepare-memory.js +19 -23
- package/dist/core/runner/prepare-park-ask.d.ts +2 -0
- package/dist/core/runner/prepare-park-ask.js +2 -2
- package/dist/core/runner/prepare-policy-chain.d.ts +4 -4
- package/dist/core/runner/prepare-policy-chain.js +4 -6
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
- package/dist/core/runner/prepare-protocol-tools.js +3 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +2 -1
- package/dist/core/runner/prepare-task.d.ts +4 -1
- package/dist/core/runner/prepare-task.js +46 -37
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +13 -0
- package/dist/core/runner/prepare-tool-disclosure-mount.js +13 -7
- package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -0
- package/dist/core/runner/prepare-wiring-manifest.js +2 -2
- package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
- package/dist/core/runner/prepare-workspace-restore.js +4 -4
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-checkpoint-screen.js +2 -0
- package/dist/core/runner/rewind-files.d.ts +2 -5
- package/dist/core/runner/rewind-files.js +9 -51
- package/dist/core/runner/run-harness-handlers.d.ts +3 -4
- package/dist/core/runner/run-harness-handlers.js +1 -8
- package/dist/core/runner/run-identity-wiring.js +1 -0
- package/dist/core/runner/run-leg.js +15 -22
- package/dist/core/runner/run-notification-lane.d.ts +2 -0
- package/dist/core/runner/run-notification-lane.js +5 -2
- package/dist/core/runner/run-recovery-lanes.js +3 -4
- package/dist/core/runner/run-settle-and-teardown.js +5 -11
- package/dist/core/runner/run-terminal-adoption.js +3 -4
- package/dist/core/runner/run-turn-boundary.js +3 -5
- package/dist/core/runner/runtask.d.ts +8 -1
- package/dist/core/runner/runtask.js +28 -34
- package/dist/core/runner/send-message-continuation.js +1 -1
- package/dist/core/runner/session-verb-doors.d.ts +28 -0
- package/dist/core/runner/session-verb-doors.js +48 -0
- package/dist/core/runner/session-write-ledger.d.ts +30 -0
- package/dist/core/runner/session-write-ledger.js +101 -0
- package/dist/core/runner/stream-settle-backstop.js +11 -14
- package/dist/core/runner/sub-agent-deny-lists.d.ts +25 -3
- package/dist/core/runner/sub-agent-deny-lists.js +21 -10
- package/dist/core/runner/teardown-bounded.d.ts +1 -0
- package/dist/core/runner/teardown-bounded.js +1 -0
- package/dist/core/runner/terminal-account.js +3 -3
- package/dist/core/runner/tool-end-body.js +1 -0
- package/dist/core/runner/tool-occurrence.d.ts +4 -1
- package/dist/core/runner/tool-occurrence.js +2 -1
- package/dist/core/runner/write-protection-station.d.ts +8 -2
- package/dist/core/runner/write-protection-station.js +2 -0
- package/dist/core/runner-deps.d.ts +4 -4
- package/dist/core/secret-env.d.ts +4 -0
- package/dist/core/secret-env.js +3 -0
- package/dist/core/sensitive-path-policy.js +6 -7
- package/dist/core/session-log-transfer.d.ts +24 -0
- package/dist/core/session-log-transfer.js +166 -0
- package/dist/core/session-policy-store.d.ts +7 -2
- package/dist/core/session-policy-store.js +1 -1
- package/dist/core/session-store.d.ts +84 -19
- package/dist/core/session-store.js +162 -24
- package/dist/core/session.d.ts +92 -1
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/shell-wrapper-projection.d.ts +1 -1
- package/dist/core/steer-replay.d.ts +4 -2
- package/dist/core/steer-replay.js +2 -1
- package/dist/core/store-contracts/background-agent-store-contract.js +1 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +19 -1
- package/dist/core/store-contracts/file-history-store-contract.js +9 -0
- package/dist/core/store-contracts/mailbox-store-contract.js +49 -1
- package/dist/core/store-contracts/session-repo-contract.js +112 -5
- package/dist/core/store-contracts/session-store-contract.d.ts +4 -1
- package/dist/core/store-contracts/session-store-contract.js +236 -2
- package/dist/core/task-event.d.ts +68 -8
- package/dist/core/task-registry-agent.d.ts +8 -4
- package/dist/core/task-registry-agent.js +14 -8
- package/dist/core/task-registry-shared.d.ts +36 -6
- package/dist/core/task-registry-shared.js +11 -0
- package/dist/core/task-registry.d.ts +1 -1
- package/dist/core/task-registry.js +1 -1
- package/dist/core/task-spec.d.ts +37 -0
- package/dist/core/task-stream.d.ts +2 -1
- package/dist/core/terminal-cause.d.ts +1 -1
- package/dist/core/tool-catalog-entries.d.ts +6 -0
- package/dist/core/tool-catalog-entries.js +2 -0
- package/dist/core/tool-name-aliases.d.ts +32 -2
- package/dist/core/tool-name-aliases.js +23 -0
- package/dist/core/tool-name-readings.d.ts +4 -0
- package/dist/core/tool-name-readings.js +1 -0
- package/dist/core/tool-policy.d.ts +10 -6
- package/dist/core/tool-policy.js +4 -7
- package/dist/core/tool-result-store.d.ts +17 -10
- package/dist/core/tool-result-store.js +3 -1
- package/dist/core/trace.d.ts +4 -1
- package/dist/core/trace.js +2 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/core/untrusted-egress.d.ts +18 -0
- package/dist/core/untrusted-egress.js +82 -12
- package/dist/core/wiring-manifest.d.ts +12 -3
- package/dist/core/wiring-manifest.js +4 -3
- package/dist/core/workspace-snapshot.d.ts +44 -0
- package/dist/core/workspace-snapshot.js +34 -0
- package/dist/core/write-protect.d.ts +43 -3
- package/dist/core/write-protect.js +43 -16
- package/dist/engine/execution-env/node-execution-env.js +15 -11
- package/dist/engine/execution-env/symlink-chain.d.ts +7 -5
- package/dist/engine/harness/agent-harness.d.ts +12 -5
- package/dist/engine/harness/agent-harness.js +13 -2
- package/dist/engine/harness/types.d.ts +48 -7
- package/dist/engine/harness/types.js +5 -1
- package/dist/engine/llm/types.d.ts +12 -3
- package/dist/engine/llm/types.js +1 -1
- package/dist/engine/loop/agent-loop.d.ts +1 -4
- package/dist/engine/loop/agent-loop.js +26 -4
- package/dist/engine/session/import-validate.js +3 -0
- package/dist/engine/session/memory-repo.d.ts +17 -9
- package/dist/engine/session/memory-repo.js +44 -34
- package/dist/engine/session/repo-utils.d.ts +22 -4
- package/dist/engine/session/repo-utils.js +49 -1
- package/dist/engine/session/storage-base.d.ts +10 -1
- package/dist/engine/session/storage-base.js +7 -1
- package/dist/index.d.ts +23 -11
- package/dist/index.js +15 -6
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +4 -3
- package/dist/internal/harness.js +3 -2
- package/dist/stores/file/checkpoint-store.d.ts +0 -4
- package/dist/stores/file/checkpoint-store.js +0 -1
- package/dist/stores/file/file-history-store.js +12 -4
- package/dist/stores/file/index.d.ts +4 -1
- package/dist/stores/file/index.js +4 -1
- package/dist/stores/file/mailbox-store.d.ts +2 -1
- package/dist/stores/file/mailbox-store.js +26 -1
- package/dist/stores/file/session-store.d.ts +15 -8
- package/dist/stores/file/session-store.js +28 -13
- package/dist/tools/fs/bash-readonly-classifier.d.ts +15 -19
- package/dist/tools/fs/bash-readonly-classifier.js +5 -10
- package/dist/tools/fs/fs-bash.js +10 -3
- package/dist/tools/fs/fs-write.d.ts +6 -3
- package/dist/tools/fs/fs-write.js +8 -7
- package/dist/tools/fs/index.d.ts +3 -0
- package/dist/tools/fs/index.js +1 -1
- package/dist/tools/fs/pattern-kill-guard.d.ts +3 -2
- package/dist/tools/fs/pattern-kill-guard.js +68 -36
- package/dist/tools/fs/safety.js +40 -8
- package/dist/tools/fs/search.js +6 -24
- package/dist/tools/fs/shell-read-check.d.ts +18 -1
- package/dist/tools/fs/shell-read-check.js +66 -16
- package/dist/tools/fs/shell-read-establish.js +2 -1
- package/dist/tools/fs/shell-read-identity.d.ts +12 -9
- package/dist/tools/fs/shell-read-identity.js +10 -5
- package/dist/tools/fs/shell-read-judge.d.ts +10 -1
- package/dist/tools/web.js +9 -7
- package/dist/tools/worktree.d.ts +42 -15
- package/dist/tools/worktree.js +60 -32
- package/package.json +4 -2
- package/test/export-surface.snapshot.json +141 -3
- package/wire-changes/core-stores-sql@7.57.0.json +29 -0
- package/wire-changes/core-stores-sql@7.58.0.json +29 -0
- package/wire-changes/core@7.57.0.json +1487 -0
- package/wire-changes/core@7.58.0.json +2188 -0
- package/wire-changes/mods-kernel@7.57.0.json +29 -0
- package/wire-changes/mods-kernel@7.58.0.json +81 -0
- package/wire-changes/primitives@7.57.0.json +245 -0
- package/wire-changes/primitives@7.58.0.json +29 -0
|
@@ -234,7 +234,7 @@ export interface FrameReceipt {
|
|
|
234
234
|
text: string;
|
|
235
235
|
/** Which frame this receipt settles. No collector renders a frame whose receipt is still pending (the frame is on
|
|
236
236
|
* its way, not yet in the transcript) — the one reading is `frameCarried` (compaction-restate.ts). */
|
|
237
|
-
source: "git_status" | "agent_listing" | "skills_listing" | "date_change" | "output_style" | "mcp_unavailable" | "posture" | "
|
|
237
|
+
source: "git_status" | "agent_listing" | "skills_listing" | "date_change" | "output_style" | "mcp_unavailable" | "posture" | "advisor_tool";
|
|
238
238
|
/** Runs inside the `message_end` walk (synchronous, never awaited): advances the run-local record
|
|
239
239
|
* and parks any session write for the next serialization point. */
|
|
240
240
|
commit: (entryId: string) => void;
|
|
@@ -406,8 +406,10 @@ export interface Prepared {
|
|
|
406
406
|
* states are their own values); the seat is optional only so a Prepared shape without the phase
|
|
407
407
|
* cannot fabricate one. */
|
|
408
408
|
effectiveMemoryScopes?: import("../types.js").EffectiveMemoryScopes;
|
|
409
|
-
/** The per-task logical cwd ref when a real shell is mounted (else undefined);
|
|
409
|
+
/** The per-task logical cwd ref when a real shell is mounted (else undefined); the workspace frame reads it. */
|
|
410
410
|
cwdRef?: CwdRef;
|
|
411
|
+
/** The leg's `workspace_changed` seat (its one snapshot projection): the run binds the sink after `wiring_manifest` (the leg-start frame) and observes after each tool. */
|
|
412
|
+
workspaceFrame: import("../workspace-snapshot.js").WorkspaceFrameSeat;
|
|
411
413
|
/** The root the hand tools resolve root-relative spellings against (present with hands; read-only hands included). */
|
|
412
414
|
handsRoot?: string;
|
|
413
415
|
/** The leg's target-reading stamp (present with hands): the resume belts stamp the executed bytes' request with it. */
|
|
@@ -419,8 +421,8 @@ export interface Prepared {
|
|
|
419
421
|
toolProgressRef: {
|
|
420
422
|
current?: ToolProgressLane;
|
|
421
423
|
};
|
|
422
|
-
/** The run's advertised-writable-directory seat (present with hands): `roots` is what the prompt advertised as writable and the fence admitted. Read live wherever a policy is adjudicated off a resumed leg, so the write gate's exemption domain is that same list. */
|
|
423
|
-
advertisedWritableDirs?: Pick<import("./advertised-writable-dirs.js").AdvertisedWritableDirs, "roots">;
|
|
424
|
+
/** The run's advertised-writable-directory seat (present with hands): `roots` is what the prompt advertised as writable and the fence admitted. Read live wherever a policy is adjudicated off a resumed leg, so the write gate's exemption domain is that same list. `planFile` is the session plan file it admitted (`TaskSpec.planFile`) — the posture frames name it. */
|
|
425
|
+
advertisedWritableDirs?: Pick<import("./advertised-writable-dirs.js").AdvertisedWritableDirs, "roots" | "planFile" | "readPlanFile">;
|
|
424
426
|
/** The leg's ONE exempt root (its single resolution of `RunnerDeps.memoryEngineDir`), stamped wherever a policy is adjudicated off a resumed leg (`ToolCallRequest.exemptRoots`) — the same list the live gate stamps. */
|
|
425
427
|
exemptRoots: readonly string[];
|
|
426
428
|
/** The ACTIVE EnterWorktree session ref (mounted with the worktree tools; undefined without
|
|
@@ -480,6 +482,7 @@ export interface Prepared {
|
|
|
480
482
|
* admission died with that leg, so the resumed bytes are judged (and admitted for their pre-spawn re-establishment)
|
|
481
483
|
* on THIS leg — a deny row found now vetoes, an operator's edit is judged on the `rejudge` seat. */
|
|
482
484
|
shellReadCheck?: import("../../tools/fs/shell-read-check.js").ShellReadCheck;
|
|
485
|
+
shellReadLandings?: import("../../tools/fs/shell-read-check.js").ShellReadLandings;
|
|
483
486
|
crossBoundary?: {
|
|
484
487
|
readonly check: import("../cross-boundary-taint.js").CrossBoundaryCheck | undefined;
|
|
485
488
|
settle(owed: import("../cross-boundary-taint.js").OwedDeliveries): Promise<void>;
|
|
@@ -768,8 +771,8 @@ export interface Prepared {
|
|
|
768
771
|
current?: CommittedPause;
|
|
769
772
|
};
|
|
770
773
|
/** A resumed leg's continuation content that has NOT reached the transcript yet: EVERY input frame the
|
|
771
|
-
* prompt carries (parked steers, the
|
|
772
|
-
*
|
|
774
|
+
* prompt carries (parked steers, the wake message, the approver's words) and the orphans whose obituary rides it. Set
|
|
775
|
+
* before the prompt, emptied at the prompt's own receipt (never its hand-off); a re-park carries it forward (the saga folds the
|
|
773
776
|
* orphans in, the adoption re-parks the frames), and what no re-park carries the undrained account announces. */
|
|
774
777
|
undeliveredContinuationRef: {
|
|
775
778
|
current: UndeliveredContinuation;
|
|
@@ -1311,6 +1314,11 @@ export interface PrepareResume {
|
|
|
1311
1314
|
/** The decision this resume carries (the gate word and, for a review, approve / edit / reject) — read by the mode seed
|
|
1312
1315
|
* (`modeRequestAfterResume`: an approved or edited `plan_review` exits a recorded plan to its pre-plan word). Absent on a prepare that resumes nothing. */
|
|
1313
1316
|
outcome?: ResumeRun["outcome"];
|
|
1317
|
+
/** Present when the resume opens this leg with inputs it hands over — a wake: the newest of them (its message, else the parked
|
|
1318
|
+
* entry delivered last; `wakeOpening`): its run-origin word (absent = it said none) is the leg's word instead of the row's. */
|
|
1319
|
+
opening?: {
|
|
1320
|
+
readonly word: unknown;
|
|
1321
|
+
};
|
|
1314
1322
|
/** The leg's mods bus, when the resume entrance already admitted it (a wake message's screen raises
|
|
1315
1323
|
* `classic.UserPromptSubmit` before this leg prepares): prepare adopts it instead of admitting a second time. */
|
|
1316
1324
|
legMods?: LegMods;
|
|
@@ -2601,8 +2609,9 @@ export interface RunState {
|
|
|
2601
2609
|
* an internally-generated continuation, so both are omitted.
|
|
2602
2610
|
*/
|
|
2603
2611
|
/** A resume continues the suspended leg: it sends no new human message, so it takes neither an objective nor the
|
|
2604
|
-
* objective's attachments (a config that carries `userAttachments` anyway is
|
|
2605
|
-
|
|
2612
|
+
* objective's attachments nor the objective's run origin (a config that carries `userAttachments` or `runOrigin` anyway is
|
|
2613
|
+
* refused before the claim; a wake states its leg's word on the input it hands over). */
|
|
2614
|
+
export type ResumeTaskConfig = Omit<TaskSpec, "objective" | "sessionId" | "userAttachments" | "runOrigin">;
|
|
2606
2615
|
/** Resume plan threaded from {@link Runner.resume} into the shared run loop. */
|
|
2607
2616
|
export interface ResumeRun {
|
|
2608
2617
|
cp: Checkpoint;
|
|
@@ -2648,17 +2657,17 @@ export interface ResumeRun {
|
|
|
2648
2657
|
wakeMessageHookContext?: string;
|
|
2649
2658
|
/** The resumed leg's bus when the wake-message screen admitted it before the claim — prepare adopts it. */
|
|
2650
2659
|
legMods?: LegMods;
|
|
2651
|
-
/**
|
|
2652
|
-
*
|
|
2653
|
-
* the
|
|
2654
|
-
*
|
|
2655
|
-
*
|
|
2656
|
-
*
|
|
2657
|
-
*
|
|
2658
|
-
*
|
|
2659
|
-
|
|
2660
|
+
/** The claim's reversal, bound to THIS resume's token and scope by `resumeStream` — REQUIRED, as the store's
|
|
2661
|
+
* `reopen` is: called when the claimed leg ends before its approved action started (a failed restore, a
|
|
2662
|
+
* refusal at the leg's prepare, an abort, a leg that returned failed), it returns the row `resolved → pending`
|
|
2663
|
+
* under the failure's reason (`reopenReasonOf`), recorded on the row so the next re-resume validates per
|
|
2664
|
+
* reason — an `env_failed` reopen replays the persisted winner, the fresh-redecision reasons take a new
|
|
2665
|
+
* decision. Answers the store's own answer — `"reopened"` (it flipped the row) or `"declined"` (`reopen`
|
|
2666
|
+
* answered `false`) — and rejects only with what the store threw (the row's state is then unprovable);
|
|
2667
|
+
* every exit reads it through `compensateUnstarted` (resume-startup-cause.ts), the one reading. */
|
|
2668
|
+
reopenUnstarted: (reason: ReopenReason) => Promise<"reopened" | "declined">;
|
|
2660
2669
|
/** The row's execution-record verb, bound to THIS resume's token and scope by `resumeStream` (the
|
|
2661
|
-
* same closure form as {@link
|
|
2670
|
+
* same closure form as {@link reopenUnstarted}, and REQUIRED for the same reason: the store contract requires the
|
|
2662
2671
|
* verb, so there is no store this seat could be absent for). The pending-call resolver calls it
|
|
2663
2672
|
* exactly once per resolution, right after it emits the resolved call's `tool_end` frame, with the
|
|
2664
2673
|
* {@link import("../gate-outcome.js").GateOutcome} that frame carried — every disposition, the
|
|
@@ -2666,8 +2675,8 @@ export interface ResumeRun {
|
|
|
2666
2675
|
* allowed). The word it answers is read through `EXECUTION_RECORD_LEAVES_ROW_UNRECORDED`; a
|
|
2667
2676
|
* conflict throw propagates (an engine defect, not a store condition). */
|
|
2668
2677
|
recordExecutionOutcome: (gate: import("../gate-outcome.js").GateOutcome) => Promise<ExecutionOutcomeRecordWord>;
|
|
2669
|
-
/** Set
|
|
2670
|
-
* decision twin of `pendingActionStarted`. A reject/deny consumes its gate BY BEING DELIVERED, and
|
|
2678
|
+
/** Set right after `applyResumeDecision` completes (`policy_ask`), and at the continuation's own receipt for `plan_review` / `dry_run_review`
|
|
2679
|
+
* (its decision rides only that message): the negative-decision twin of `pendingActionStarted`. A reject/deny consumes its gate BY BEING DELIVERED, and
|
|
2671
2680
|
* this bit is the delivery fact — every throw-arm cause (prepare failure, `session_not_found`, a
|
|
2672
2681
|
* pre-delivery abort) and the walltime-exhausted settle fire BEFORE it is set, so an undelivered
|
|
2673
2682
|
* negative decision still reopens as `env_failed` (the retry replays the persisted decision; it
|
|
@@ -2869,7 +2878,13 @@ export interface RunnerSelfSeat {
|
|
|
2869
2878
|
*/
|
|
2870
2879
|
export type PrepareTaskFn = (spec: TaskSpec, deps: RunnerDeps, sessions: SessionStore, resume?: PrepareResume, internals?: RunInternals, runnerSelf?: RunnerSelfSeat, runIdSink?: {
|
|
2871
2880
|
runId?: string;
|
|
2872
|
-
}, holdSessionLock?: (sessionId: string) => Promise<void
|
|
2881
|
+
}, holdSessionLock?: (sessionId: string) => Promise<void>, legWrites?: LegWrites) => Promise<Prepared>;
|
|
2882
|
+
/** One leg's view of the Runner's session write ledger (`session-write-ledger.ts`): `issue` starts a write of the leg (`what` = the
|
|
2883
|
+
* entry type, for a report) or refuses it once `close` ran — the leg's hold ended; a write still in flight is reported when it settles. */
|
|
2884
|
+
export interface LegWrites {
|
|
2885
|
+
issue<T>(sessionId: string, what: string, start: () => Promise<T>): Promise<T>;
|
|
2886
|
+
close(): void;
|
|
2887
|
+
}
|
|
2873
2888
|
/**
|
|
2874
2889
|
* The Result of an INSTALLING phase: a lane whose every product is installed on a seat it borrowed
|
|
2875
2890
|
* (the harness's stop gate and recovery chain, the run state's counter groups, the stream's result setter, the claimed
|
|
@@ -14,6 +14,19 @@ export type DerivedSeatOutcome = {
|
|
|
14
14
|
readonly action: "fall_back" | "detach";
|
|
15
15
|
readonly cause: RouteRefusalCode;
|
|
16
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Whether the compaction-summary model is ROLE-derived — the only one whose route is pre-flighted (an EXPLICIT
|
|
19
|
+
* compaction model is a named leg and keeps the request gate's loud refusal). Synchronous: a caller awaits the
|
|
20
|
+
* pre-flight only when this holds, so a run with nothing to judge takes no suspension point at the seat.
|
|
21
|
+
*/
|
|
22
|
+
export declare function compactionSummaryIsDerived(explicit: boolean, compModel: Model | undefined): compModel is Model;
|
|
23
|
+
/**
|
|
24
|
+
* The compaction-summary seat after its route pre-flight: a derived summary model whose key↔URL pairing is broken must
|
|
25
|
+
* not sink the pass at the brain's request gate — it falls back to the primary (`undefined`: the pass then summarizes
|
|
26
|
+
* on the main model, the documented absent-model behavior) and the fallback is announced. The one reading for a run's
|
|
27
|
+
* prepare and the out-of-run compaction.
|
|
28
|
+
*/
|
|
29
|
+
export declare function compactionSummaryFallback(args: Omit<Parameters<typeof derivedRouteFallsBack>[0], "seat" | "onBrokenPairing">): Promise<Model | undefined>;
|
|
17
30
|
/**
|
|
18
31
|
* Judge the derived model where its route differs from the primary's, announce what a broken pairing means for THIS seat
|
|
19
32
|
* (`onBrokenPairing`), and ABSTAIN (keep) on ANY throw. The pre-flight is advisory — the brain's request gate re-runs the
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { adjudicateDerivedRoute, fallbackToPrimaryNotice, sameRouteIdentity, seatDetachedNotice, unroutableSeatNotice } from "../../brain/route-adjudicator.js";
|
|
2
2
|
import { deliverEngineNotice } from "../types.js";
|
|
3
|
+
export function compactionSummaryIsDerived(explicit, compModel) {
|
|
4
|
+
return !explicit && compModel !== undefined;
|
|
5
|
+
}
|
|
6
|
+
export async function compactionSummaryFallback(args) {
|
|
7
|
+
return (await derivedRouteFallsBack({ ...args, seat: "compaction-summary" })).action === "fall_back" ? undefined : args.derived;
|
|
8
|
+
}
|
|
3
9
|
export async function derivedRouteFallsBack(args) {
|
|
4
10
|
try {
|
|
5
11
|
if (sameRouteIdentity(args.derived, args.primary))
|
|
@@ -13,8 +13,9 @@ export interface MalformedCapabilityDeclaration {
|
|
|
13
13
|
* The probe is the VALUE, not membership, because the value is what the readers get: a `capabilities`
|
|
14
14
|
* that answers `has` and `get` differently (a Proxy) would otherwise hide from the census exactly the
|
|
15
15
|
* value a reader goes on to act on. `undefined` is where absence lands — an absent key and an explicit
|
|
16
|
-
* `undefined` are the same word to every reader, and both are the documented silent reading
|
|
17
|
-
*
|
|
16
|
+
* `undefined` are the same word to every reader, and both are the documented silent reading of every key
|
|
17
|
+
* outside {@link NO_ABSENT_READING} (and announced, alike, for a key inside it) — so one test covers both and
|
|
18
|
+
* the census needs no membership rule at all.
|
|
18
19
|
*
|
|
19
20
|
* TOTAL by construction: a diagnostic may not be the thing that fails a run. Every read of the adapter
|
|
20
21
|
* can throw on a getter or a Proxy trap — the structural probe, the block acquisition and each key —
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { isRemoteExecutionEnv } from "../remote-env.js";
|
|
2
2
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
3
|
-
const BOOLEAN_CAPABILITY_KEYS = ["isolation", "suspendable", "canonicalPathAuthoritative"];
|
|
3
|
+
const BOOLEAN_CAPABILITY_KEYS = ["isolation", "suspendable", "canonicalPathAuthoritative", "sharesProcessTable"];
|
|
4
|
+
const NO_ABSENT_READING = {
|
|
5
|
+
sharesProcessTable: "whether the commands it runs are processes on this engine's own process table has no default, so the Bash tool refuses every pattern kill that needs the question (`pkill`, `killall`, a `kill` fed by `pgrep`; `pkill -P $$`, the shell's own children, runs) on this environment until the adapter declares it — `true` when its commands run on a table that holds the engine (a host lane, or a PID namespace that contains the engine's), `false` only when they run where the engine is not (another machine, a PID namespace that does not contain it)",
|
|
6
|
+
};
|
|
4
7
|
const OPTIONAL_METHOD_KEYS = ["writeFileExclusive", "writeFileGuarded", "setFileMode", "readLink", "canonicalChain", "fileIdentity", "openBound"];
|
|
5
8
|
export function malformedCapabilityDeclarations(env) {
|
|
6
9
|
const out = [];
|
|
@@ -36,7 +39,7 @@ export function malformedCapabilityDeclarations(env) {
|
|
|
36
39
|
out.push({ key, valueType: "unreadable", expected: "boolean" });
|
|
37
40
|
continue;
|
|
38
41
|
}
|
|
39
|
-
if (value ===
|
|
42
|
+
if (typeof value === "boolean" || (value === undefined && NO_ABSENT_READING[key] === undefined))
|
|
40
43
|
continue;
|
|
41
44
|
out.push({ key, valueType: value === null ? "null" : typeof value, expected: "boolean" });
|
|
42
45
|
}
|
|
@@ -44,11 +47,14 @@ export function malformedCapabilityDeclarations(env) {
|
|
|
44
47
|
}
|
|
45
48
|
export function announceMalformedCapabilities(env, onNotice) {
|
|
46
49
|
for (const { key, valueType, expected } of malformedCapabilityDeclarations(env)) {
|
|
50
|
+
const noAbsentReading = NO_ABSENT_READING[key];
|
|
47
51
|
deliverEngineNotice(onNotice, {
|
|
48
52
|
code: "config.execution_env_capability_invalid",
|
|
49
53
|
message: expected === "function"
|
|
50
54
|
? `The execution environment declares ${key} as a ${valueType}, not a function. This seat is declared by being present as a callable method and undeclared by being absent, so every reader takes the absent reading — the reach the adapter meant to declare is silently the old one. Fix the adapter — this is a wiring fault, not a supported way to leave the seat unset.`
|
|
51
|
-
:
|
|
55
|
+
: noAbsentReading !== undefined
|
|
56
|
+
? `The execution environment ${valueType === "undefined" ? `does not declare capabilities.${key}` : `declares capabilities.${key} as a ${valueType}, not a boolean`}: ${noAbsentReading}. Fix the adapter — this is a wiring fault, not a supported way to leave the capability unset.`
|
|
57
|
+
: `The execution environment declares capabilities.${key} as a ${valueType}, not a boolean. What a reader makes of that is the reader's own business and differs between them — the containment readers take only the boolean, so this reads as undeclared, while the suspend reader takes any truthy value, so a non-empty string reads as TRUE. That is why a declaration of the wrong shape cannot pass quietly: the engine may act on something other than what the adapter meant. Fix the adapter — this is a wiring fault, not a supported way to leave the capability unset.`,
|
|
52
58
|
detail: { key, valueType },
|
|
53
59
|
});
|
|
54
60
|
}
|
|
@@ -26,6 +26,7 @@ import type { AllowRuleClearance } from "../allow-rule-shadow.js";
|
|
|
26
26
|
import type { AutoModeClassifierRound } from "../auto-mode.js";
|
|
27
27
|
import { type Arbitration, type AskClassification, type AskFace, type AskOrigin, type AskOriginFacts } from "../ask-origin.js";
|
|
28
28
|
import { type PermissionResult, type ResolvedAsk, type ToolCallRequest } from "../tool-policy.js";
|
|
29
|
+
import { type RewriteAccount } from "../rewrite-rejudge.js";
|
|
29
30
|
import type { SafeNotifier } from "../safe-notify.js";
|
|
30
31
|
import type { PermissionDeniedPayload, PreToolUseResult, ToolGateInput, ToolGateResult } from "../hooks.js";
|
|
31
32
|
/** The ask a gate pass settled, as the gate captured it at its resolution site: the settlement the
|
|
@@ -137,11 +138,13 @@ export declare function frozenInputSnapshot(input: unknown): unknown;
|
|
|
137
138
|
* engine's fail-closed refusal of the call with its sentence (a handler that failed or broke the site's contract,
|
|
138
139
|
* or a cancel). */
|
|
139
140
|
/** A screen's outcome; an answer names the registration whose answer the chain returned (`answeredBy`, absent when no
|
|
140
|
-
* handler spoke)
|
|
141
|
+
* handler spoke) and the extensions that authored its `updatedInput` (`rewrittenBy`, in the order they rewrote; absent
|
|
142
|
+
* when the answer carries no rewrite). */
|
|
141
143
|
export type PreToolUseScreen = {
|
|
142
144
|
readonly kind: "answered";
|
|
143
145
|
readonly answer: PreToolUseResult | undefined;
|
|
144
146
|
readonly answeredBy?: string;
|
|
147
|
+
readonly rewrittenBy?: readonly string[];
|
|
145
148
|
} | {
|
|
146
149
|
readonly kind: "refused";
|
|
147
150
|
readonly reason: string;
|
|
@@ -153,9 +156,12 @@ export type PreToolUseScreen = {
|
|
|
153
156
|
* event (an observe handler runs inside the screening too; it never decides).
|
|
154
157
|
*/
|
|
155
158
|
export interface PreToolUseScreening {
|
|
156
|
-
/** Raise `classic.PreToolUse` over `args`; `subject` names what is screened in a fail-closed sentence
|
|
157
|
-
*
|
|
158
|
-
|
|
159
|
+
/** Raise `classic.PreToolUse` over `args`; `subject` names what is screened in a fail-closed sentence; `readAs` is the call
|
|
160
|
+
* whose reading of its args the rewrite authors are compared under (absent ⇒ the values as given). What the gate does after
|
|
161
|
+
* the screen answers runs in the screen's own continuation. */
|
|
162
|
+
screen(args: unknown, subject: string, readAs?: {
|
|
163
|
+
readonly face?: object | undefined;
|
|
164
|
+
}): Promise<PreToolUseScreen>;
|
|
159
165
|
/** The model-facing text for the screen's OWN deny of this call (unwrapped; every exit wraps it with the leg's mark). */
|
|
160
166
|
deniedReason(answer: PreToolUseResult): string;
|
|
161
167
|
}
|
|
@@ -223,6 +229,9 @@ export interface GatePass {
|
|
|
223
229
|
* of a value nothing took ({@link untakenValueExit}), where it holds that value as given and only the deny exit's receipt
|
|
224
230
|
* reads it. Writers: the dispatch (phase 1), the lanes, the exits. */
|
|
225
231
|
currentInput: unknown;
|
|
232
|
+
/** borrowed-mutable — who replaced the args, against the bytes taken at the entry ({@link RewriteAccount}): every station that
|
|
233
|
+
* adopts other bytes names its author there; the allow exit reads it into the call's record. */
|
|
234
|
+
readonly rewrites: RewriteAccount;
|
|
226
235
|
/** borrowed-mutable — the adjudication request. Minted over the pass's args so the record is whole from
|
|
227
236
|
* the first station, and RE-MINTED by the adjudication station over the FINAL post-screen args (the
|
|
228
237
|
* pre-existing `const req` site); `args` is re-pointed at the policy rewrite on the ask path. Writers: the
|
|
@@ -318,6 +327,11 @@ export interface GatePass {
|
|
|
318
327
|
* on BOTH its arms (a write tool's target), and the fold's read station (a shell command's written targets,
|
|
319
328
|
* `ShellReadVerdict.writeProtected`). Reader: the lanes' mandate. */
|
|
320
329
|
writeProtected?: true;
|
|
330
|
+
/** borrowed-mutable — the same judge's table was met by a written target only where the path resolves on disk (the path as
|
|
331
|
+
* written names no row): the class the auto-mode classifier does not answer. Writers: the two writers of `writeProtected`
|
|
332
|
+
* (`writeProtectionReachOf` for a write tool's target, `ShellReadVerdict.writeProtectedOnDisk` for a command's). Reader: the
|
|
333
|
+
* lanes' mandate. */
|
|
334
|
+
writeProtectedOnDisk?: true;
|
|
321
335
|
/** borrowed-mutable — the READING of a written target could not say where it leads on disk (a target a shell command's
|
|
322
336
|
* program writes, placed, whose destination the read station could not resolve): no automatic lane may answer the ask.
|
|
323
337
|
* A fact of the reading, not of a judge. Writer: the fold's read station (`ShellReadVerdict.targetUnresolved`). Reader:
|
|
@@ -5,6 +5,7 @@ import { isProtectedWrite } from "../tool-registry.js";
|
|
|
5
5
|
import { attestationOf, decisionText, licenseCovers } from "../tool-policy.js";
|
|
6
6
|
import { pathDenialCardOf } from "../../tools/fs/safety.js";
|
|
7
7
|
import { argsAsTheToolReads } from "../effective-path-target.js";
|
|
8
|
+
import { rewriteRecordOf } from "../rewrite-rejudge.js";
|
|
8
9
|
import { askUnresolvableRemedySeat } from "../ask-unresolvable-notice.js";
|
|
9
10
|
import { inlineUntrusted } from "../untrusted-text.js";
|
|
10
11
|
import { formatHookFeedback } from "../reminder-mint.js";
|
|
@@ -319,10 +320,13 @@ export async function exitGate(pass) {
|
|
|
319
320
|
}
|
|
320
321
|
const release = pass.arbitration?.kind === "released" ? pass.arbitration : (() => { if (ledger.settled !== undefined)
|
|
321
322
|
return undefined; const a = pass.arbitration === undefined ? input.ancestorArbitrationOf?.(toolCallId) : undefined; return a?.kind === "released" ? a : undefined; })();
|
|
323
|
+
const finalInput = frozenInputSnapshot(pass.currentInput);
|
|
324
|
+
const rewrite = rewriteRecordOf(pass.rewrites, pass.req, pass.currentInput, finalInput);
|
|
322
325
|
return {
|
|
323
326
|
updatedInput: pass.currentInput,
|
|
324
327
|
gate: mintGateOutcome({ ...(ledger.settled !== undefined ? { settled: ledger.settled } : {}), ...(pass.classifierRound !== undefined ? { classifier: pass.classifierRound } : {}), ...(release !== undefined ? { released: releaseRecordOf(release) } : {}), ...(pass.clearedBy !== undefined && ledger.settled === undefined && release === undefined ? { clearedBy: pass.clearedBy } : {}) }),
|
|
325
|
-
finalInput
|
|
328
|
+
finalInput,
|
|
329
|
+
...(rewrite !== undefined ? { rewrite } : {}),
|
|
326
330
|
preToolContext: pass.preToolContext,
|
|
327
331
|
};
|
|
328
332
|
}
|
|
@@ -29,11 +29,8 @@ import { type OrgGateVerdict, type PersistedRuleAnswer, type PersistedRuleHit, t
|
|
|
29
29
|
import type { PersistedRule, PersistedRuleVerdict, RuleOffer, ScopeRootIdentity, SegmentCoverage } from "../permission-rule-model.js";
|
|
30
30
|
import { type PathRuleBases } from "../permission-rule-model.js";
|
|
31
31
|
import { type HeadLeads } from "../path-rule-binding.js";
|
|
32
|
-
import type { ToolCallLike } from "../tool-registry.js";
|
|
33
32
|
import { type OrgRuleResolution } from "../permission-rule-org.js";
|
|
34
33
|
import { type EffectivePermissionRules, type PermissionRuleStoreProvider, type PersonRowsRead } from "../permission-rule-provider.js";
|
|
35
|
-
/** The one SHELL tool the persisted-rule lane's COMMAND grammar speaks for (the rule-offer face mints for it, the name tools and the host tools); the other grammars' tools are derived (`ruleToolGrammarOf`). */
|
|
36
|
-
export declare const PERSISTED_RULE_TOOL = "Bash";
|
|
37
34
|
/**
|
|
38
35
|
* The evidence an INHERITED-lane ask carries.
|
|
39
36
|
*
|
|
@@ -203,9 +200,12 @@ interface RuleOffersAskFacts extends RuleClearanceFacts {
|
|
|
203
200
|
* approval-preview field is a standing example of what happens otherwise: it reached two of the
|
|
204
201
|
* five, so a delegated child's card was silently poorer than the top-level one).
|
|
205
202
|
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
203
|
+
* Silent (no offer and no reason) only where no rule speaks for the call: no lane armed, the anonymous floor,
|
|
204
|
+
* a call the lane never judges — offering an option that redemption would refuse is worse than offering none.
|
|
205
|
+
* Every other card offers the one rule its call's form mints ({@link cardRuleFormOf}: the shell card's
|
|
206
|
+
* command rules, a name or host tool's exact value rule, the whole-tool rule of a call no rule word speaks
|
|
207
|
+
* for) or names why it offers none (`lane_cannot_speak`: a compound, a redirection, a substitution, a path
|
|
208
|
+
* tool, a shell-face sibling, a tool answering to one of those under an alias).
|
|
209
209
|
*
|
|
210
210
|
* Empty, too, on any ask a persisted rule could never CLEAR — "allow rules silence the classifier's
|
|
211
211
|
* questions, never a mandated one". Two doors, matching the two halves of that boundary:
|
|
@@ -270,7 +270,7 @@ export declare function createRuleOffersOf(cfg: {
|
|
|
270
270
|
current: string;
|
|
271
271
|
} | undefined;
|
|
272
272
|
deniesDirectoryRead: ((directory: string) => boolean) | undefined;
|
|
273
|
-
}): (call: Pick<
|
|
273
|
+
}): (call: Pick<ToolCallRequest, "toolName" | "face">, args: unknown, ask: RuleOffersAskFacts | undefined) => {
|
|
274
274
|
ruleOffers?: readonly RuleOffer[];
|
|
275
275
|
ruleOffersAbsence?: RuleOffersAbsence;
|
|
276
276
|
execCwd?: string;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { persistedRuleMandateOf, ruleClearanceOf } from "../ask-origin.js";
|
|
2
2
|
import {} from "../hooks.js";
|
|
3
|
-
import { adjudicatePersistedDomainRules, adjudicatePersistedNameRules, adjudicatePersistedPathRules, adjudicatePersistedRules, callPathFaceOf, eligiblePersisted, escapeForDisclosure, faceRowsSpeakFor, parseRuleText, laneToolNamesOf, nameRuleSubjectOf, ruleToolGrammarOf, segmentCoverageOf, suggestRuleForHost, suggestRuleForName, suggestRulesForCommand } from "../permission-rule-model.js";
|
|
3
|
+
import { adjudicatePersistedDomainRules, adjudicatePersistedNameRules, adjudicatePersistedPathRules, adjudicatePersistedRules, adjudicatePersistedToolRules, callPathFaceOf, cardRuleFormOf, eligiblePersisted, escapeForDisclosure, faceRowsSpeakFor, parseRuleText, laneToolNamesOf, nameRuleSubjectOf, ruleToolGrammarOf, segmentCoverageOf, suggestRuleForHost, suggestRuleForName, suggestRuleForTool, suggestRulesForCommand, wholeToolRuleReaches } from "../permission-rule-model.js";
|
|
4
4
|
import { callHostTargetOf } from "../host-target.js";
|
|
5
5
|
import { callTargetViewsOf, validatePath } from "../effective-path-target.js";
|
|
6
6
|
import { bindPathRules, persistedRowAnchors, projectScopeIdentity } from "../path-rule-binding.js";
|
|
7
7
|
import { heldBy, seatOf, wireOf } from "../tool-name-readings.js";
|
|
8
8
|
import { describeUnreadableOrgRows, readOrgRules, settleOrgVerdictWithin } from "../permission-rule-org.js";
|
|
9
9
|
import { ASK_USER_QUESTION_TOOL_NAME } from "../ask-question.js";
|
|
10
|
+
import { routesContent } from "../tool-catalog-entries.js";
|
|
10
11
|
import { ownerStoreOf } from "../permission-rule-provider.js";
|
|
11
12
|
import { readPrincipal } from "../principal-name.js";
|
|
12
13
|
import { thrownText } from "../thrown-value.js";
|
|
13
14
|
import { strongestAnswer } from "../persisted-rule-arms.js";
|
|
14
15
|
import { ORG_ADJUDICATION_TIMEOUT_MS } from "../permission-rule-org.js";
|
|
15
|
-
export const PERSISTED_RULE_TOOL = "Bash";
|
|
16
16
|
const NO_LEADS = new Map();
|
|
17
17
|
export function inheritedAskRuleEvidence(provider) {
|
|
18
18
|
const org = provider?.partitions.org === true ? "not_adjudicated" : "not_wired";
|
|
@@ -123,21 +123,23 @@ export function createPermissionRuleLanes(cfg) {
|
|
|
123
123
|
if (!judged.some(([, g]) => g === "path") && faceRowsSpeakFor(callPathFaceOf(req)))
|
|
124
124
|
judged.push([req.toolName, "path"]);
|
|
125
125
|
const view = await reader.pin(req.toolCallId, req.args);
|
|
126
|
-
|
|
126
|
+
const ownRow = (r) => judged.some(([n]) => n === r.tool) || wholeToolRuleReaches(r.tool, req);
|
|
127
|
+
if (judged.length === 0 && !view.rules.some(ownRow))
|
|
127
128
|
return view.unreadable !== undefined ? { unreadable: true } : undefined;
|
|
128
129
|
try {
|
|
129
130
|
const stripped = view.rules.filter((r) => r.behavior !== "allow" || cfg.stripsAllow?.(r, req) !== true);
|
|
130
131
|
const judgesPath = judged.some(([, g]) => g === "path");
|
|
131
132
|
const noRule = [];
|
|
132
133
|
const table = stripped.filter((r) => {
|
|
133
|
-
const read =
|
|
134
|
+
const read = ownRow(r) || (judgesPath && (r.match === "path" || r.match === "subpath")) ? parseRuleText(r.rule, r.behavior) : undefined;
|
|
134
135
|
if (read !== undefined && "reject" in read)
|
|
135
136
|
noRule.push({ row: r, why: read.reject.message });
|
|
136
137
|
return read === undefined || !("reject" in read) || r.behavior !== "allow";
|
|
137
138
|
});
|
|
138
139
|
const leads = judgesPath ? await cfg.leads.resolve(bindPathRules(table.filter((r) => r.match === "path" || r.match === "subpath").map((r) => ({ parsed: r, ruleText: r.rule, rule: r })), (spec) => anchorsOf(spec.rule))) : NO_LEADS;
|
|
139
140
|
const scopeIdentity = await projectScopeIdentity(table, cfg.rootCanonical, cfg.leads);
|
|
140
|
-
const
|
|
141
|
+
const wholeTool = persistedRuleAnswerOf(adjudicatePersistedToolRules(table, { request: req, cwd: cfg.root, sessionId: cfg.sessionId, ...(scopeIdentity !== undefined ? { scopeIdentity } : {}) }));
|
|
142
|
+
const judgedAnswer = strongestAnswer([...judged.map(([n, grammar]) => judgeAgainst(table, { ...req, toolName: n }, grammar, leads, scopeIdentity)), wholeTool]);
|
|
141
143
|
const unjudged = noRule.find(({ row }) => (row.behavior === "deny" || row.behavior === "ask") && eligiblePersisted(row, { tool: row.tool, cwd: cfg.root, sessionId: cfg.sessionId, ...(scopeIdentity !== undefined ? { scopeIdentity } : {}) }, row.behavior));
|
|
142
144
|
const answer = unjudged !== undefined && !(judgedAnswer !== undefined && "behavior" in judgedAnswer && judgedAnswer.behavior === "deny") ? unjudgedRowAnswer(unjudged.row, unjudged.why, req.toolName) : judgedAnswer;
|
|
143
145
|
const stands = answer !== undefined && (("behavior" in answer && answer.behavior === "deny") || "unreadable" in answer);
|
|
@@ -180,11 +182,9 @@ export function createPermissionRuleLanes(cfg) {
|
|
|
180
182
|
export function createRuleOffersOf(cfg) {
|
|
181
183
|
return (call, args, ask) => {
|
|
182
184
|
const toolName = wireOf("offer.laneTool", call);
|
|
183
|
-
|
|
184
|
-
if (!cfg.laneArmed || (toolName !== PERSISTED_RULE_TOOL && grammar !== "name" && grammar !== "domain"))
|
|
185
|
-
return {};
|
|
186
|
-
if (readPrincipal(cfg.principal).kind === "absent" && !cfg.localOwnerDeclared)
|
|
185
|
+
if (!cfg.laneArmed || (readPrincipal(cfg.principal).kind === "absent" && !cfg.localOwnerDeclared) || routesContent(call.face))
|
|
187
186
|
return {};
|
|
187
|
+
const form = cardRuleFormOf(toolName, call);
|
|
188
188
|
const tierSeat = seatOf("offer.marks", cfg.irreversibilityTier, call);
|
|
189
189
|
const closedDoor = ruleClearanceOf(ask, {
|
|
190
190
|
egress: heldBy("offer.marks.egress", cfg.egressTools, call),
|
|
@@ -193,11 +193,17 @@ export function createRuleOffersOf(cfg) {
|
|
|
193
193
|
}).word;
|
|
194
194
|
if (closedDoor !== undefined)
|
|
195
195
|
return { ruleOffersAbsence: closedDoor };
|
|
196
|
-
if (
|
|
196
|
+
if (form === "tool") {
|
|
197
|
+
const offer = suggestRuleForTool(toolName);
|
|
198
|
+
return offer !== undefined ? { ruleOffers: [offer] } : { ruleOffersAbsence: "lane_cannot_speak" };
|
|
199
|
+
}
|
|
200
|
+
if (form === undefined)
|
|
201
|
+
return { ruleOffersAbsence: "lane_cannot_speak" };
|
|
202
|
+
if (form === "name") {
|
|
197
203
|
const offer = suggestRuleForName(toolName, nameRuleSubjectOf(toolName, args) ?? "");
|
|
198
204
|
return offer !== undefined ? { ruleOffers: [offer] } : { ruleOffersAbsence: "lane_cannot_speak" };
|
|
199
205
|
}
|
|
200
|
-
if (
|
|
206
|
+
if (form === "domain") {
|
|
201
207
|
const host = callHostTargetOf({ toolName: call.toolName, args, face: call.face }, "grant");
|
|
202
208
|
const offer = host !== undefined && "host" in host ? suggestRuleForHost(toolName, host.host) : undefined;
|
|
203
209
|
return offer !== undefined ? { ruleOffers: [offer] } : { ruleOffersAbsence: "lane_cannot_speak" };
|
|
@@ -24,6 +24,7 @@ import { type RecoveredOrphan } from "../session-reconcile.js";
|
|
|
24
24
|
import type { TaskSpec, ToolEffect } from "../types.js";
|
|
25
25
|
import type { PrepareResume } from "./contracts.js";
|
|
26
26
|
import { type ResumeAtBranch } from "./branch-writeback.js";
|
|
27
|
+
import { type LegWrites } from "./session-write-ledger.js";
|
|
27
28
|
export interface PrepareAcquireReconcileInput {
|
|
28
29
|
/** borrowed-mutable (service port) — the deployment's session store. This phase's verbs on it are
|
|
29
30
|
* the acquire/forget half of the session resource protocol: `acquire` per attempt, `forget` to
|
|
@@ -54,6 +55,8 @@ export interface PrepareAcquireReconcileInput {
|
|
|
54
55
|
durableParkGap?: string;
|
|
55
56
|
/** borrowed-readonly — the incident channel for this phase's own cleanup legs: a `resumeAt` branch it could not write back, a forget that did not settle. */
|
|
56
57
|
report?: (err: Error, sessionId: string) => void;
|
|
58
|
+
/** borrowed-mutable (the Runner's) — this leg's view of the session write ledger, every storage write issued through it ({@link writesThroughLeg}); absent for a standalone prepare. */
|
|
59
|
+
legWrites?: LegWrites;
|
|
57
60
|
}
|
|
58
61
|
/** The phase's outputs (four-class form). All six are fresh bindings —
|
|
59
62
|
* the driver destructures them into consts, so a consumer moved ahead of this call is a lexical
|
|
@@ -6,6 +6,7 @@ import { lastAttachmentFrameOf } from "../user-attachment.js";
|
|
|
6
6
|
import { reconcileInterruptedSession } from "../session-reconcile.js";
|
|
7
7
|
import { detectConflicts, settleBranchWriteBack } from "./branch-writeback.js";
|
|
8
8
|
import { settleTeardownLeg } from "./teardown-bounded.js";
|
|
9
|
+
import { writesThroughLeg } from "./session-write-ledger.js";
|
|
9
10
|
const RECONCILE_MAX_RETRIES = 3;
|
|
10
11
|
export async function prepareAcquireReconcile(input) {
|
|
11
12
|
const { sessions, spec, resume, wakeEffects } = input;
|
|
@@ -29,7 +30,7 @@ export async function prepareAcquireReconcile(input) {
|
|
|
29
30
|
}
|
|
30
31
|
conflictRef = { hit: false };
|
|
31
32
|
const own = { ids: undefined };
|
|
32
|
-
session = new StoredSession(detectConflicts(acquired.session.getStorage(), conflictRef, own));
|
|
33
|
+
session = new StoredSession(detectConflicts(input.legWrites !== undefined ? writesThroughLeg(acquired.session.getStorage(), input.legWrites, acquired.sessionId) : acquired.session.getStorage(), conflictRef, own));
|
|
33
34
|
if (!spec.sessionId) {
|
|
34
35
|
break;
|
|
35
36
|
}
|
|
@@ -29,6 +29,7 @@ import { type AutoModeDecider, type AutoModeDenialTracker } from "../auto-mode.j
|
|
|
29
29
|
import { type CheckpointSeat } from "../checkpoint-seat.js";
|
|
30
30
|
import { type ComplianceCapability } from "../compliance.js";
|
|
31
31
|
import type { LockedPreflight } from "../locked-config.js";
|
|
32
|
+
import { type PlanFileSource } from "../present-plan-tool.js";
|
|
32
33
|
import type { StoredSession } from "../session.js";
|
|
33
34
|
import type { RunnerDeps, RuntimeCaps, TaskEvent, ToolExecuteContext } from "../types.js";
|
|
34
35
|
import type { AutoModeArmFact } from "../wiring-manifest.js";
|
|
@@ -108,6 +109,7 @@ export interface PrepareCapsAndWorkflowInput {
|
|
|
108
109
|
requestReview: (opts?: {
|
|
109
110
|
reason?: string;
|
|
110
111
|
}) => void;
|
|
112
|
+
/** borrowed-readonly — the declared session plan file as ExitPlanMode's FILE arm reads it (absent ⇒ the parameter arm). */ planFileSource?: PlanFileSource;
|
|
111
113
|
/** borrowed-readonly — the plan-mode primitive the EnterPlanMode tool calls: a steer of the leg's mode seat into `plan`. */
|
|
112
114
|
enterPlanMode: () => Promise<void>;
|
|
113
115
|
/** borrowed-readonly — the leg's live permission-mode seat: the arming's first arm is `declared === "auto"`, and the
|
|
@@ -149,7 +149,7 @@ export async function prepareCapsAndWorkflow(input) {
|
|
|
149
149
|
if (spec.enablePlanMode === true && spec.interactiveTools !== false) {
|
|
150
150
|
const planReviewFace = checkpointStoreOfSeat(checkpointSeat) !== undefined;
|
|
151
151
|
if (spec.interactiveTools === true || planReviewFace) {
|
|
152
|
-
roster.mount(defineTool(createPresentPlanTool(requestReview)), { source: "builtin", mountedBy: "optional" });
|
|
152
|
+
roster.mount(defineTool(createPresentPlanTool(requestReview, input.planFileSource)), { source: "builtin", mountedBy: "optional" });
|
|
153
153
|
if (planReviewFace) {
|
|
154
154
|
roster.mount(defineTool(createEnterPlanModeTool(enterPlanMode)), { source: "builtin", mountedBy: "optional" });
|
|
155
155
|
}
|
|
@@ -24,7 +24,8 @@ import type { ThinkingLevel } from "../../internal/harness.js";
|
|
|
24
24
|
import { type MicroCompactMachine } from "../context-edit.js";
|
|
25
25
|
import { type CrossBoundaryPosture } from "../cross-boundary-taint.js";
|
|
26
26
|
import { type HostFloor } from "../host-floor.js";
|
|
27
|
-
import {
|
|
27
|
+
import { type CheckpointState } from "../checkpoint-store.js";
|
|
28
|
+
import { runOriginOfLeg, type RunOrigin } from "../run-origin.js";
|
|
28
29
|
import { type ConfigDoorEntry, type LockedPreflight } from "../locked-config.js";
|
|
29
30
|
import { type ResolvedRole } from "../roles.js";
|
|
30
31
|
import { type ResolvedSkillListingBudget } from "../skill-listing-budget.js";
|
|
@@ -36,6 +37,12 @@ import type { PrepareResume, RunInternals, ToolFaceLists } from "./contracts.js"
|
|
|
36
37
|
import { resolveHost } from "../../prompt-assembly/select.js";
|
|
37
38
|
import type { PromptTraitName } from "../../prompt-assembly/catalog/schema.js";
|
|
38
39
|
import { type RosterSpec } from "./caller-roster.js";
|
|
40
|
+
/**
|
|
41
|
+
* The model a compaction pass summarizes on: the explicit `compactionModel` wins (resolved at `seat`, the word a
|
|
42
|
+
* refusal names), else the `summarize` role when one is configured, else `undefined` — the pass then falls back to
|
|
43
|
+
* the main model inside `maybeCompact`. One reading for a run's prepare and the out-of-run `Runner.compactSession`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveCompactionModel(spec: Pick<TaskSpec, "compactionModel" | "roles">, deps: Pick<RunnerDeps, "models" | "roles">, seat: string): Model | undefined;
|
|
39
46
|
export declare function limitConfigError(code: string, message: string): Error & {
|
|
40
47
|
code?: string;
|
|
41
48
|
};
|
|
@@ -204,6 +211,7 @@ export interface PrepareConfigDoorsResult {
|
|
|
204
211
|
crossBoundaryPosture: CrossBoundaryPosture | undefined;
|
|
205
212
|
advisorTool: "disabled" | undefined;
|
|
206
213
|
hostFloor: HostFloor | undefined;
|
|
214
|
+
runOrigin: RunOrigin | undefined;
|
|
207
215
|
}
|
|
208
216
|
/** The microCompact knob door (坏值响亮度默认律, the sibling knob doors' form:
|
|
209
217
|
* interactionPosture / toolModelGate / staleToolResultOffload). Placement is load-bearing:
|
|
@@ -228,7 +236,7 @@ export declare const checkpointStoreSeat: (spec: {
|
|
|
228
236
|
export declare function assertResumeConfigRecord(config: unknown): void;
|
|
229
237
|
/** The spec the value doors read: a prepare's (its roster is faces) or a resume's re-supplied config (no objective, no session id). */
|
|
230
238
|
type ValueDoorSpec = Omit<TaskSpec, "tools" | "objective" | "sessionId" | "userAttachments"> & Partial<Pick<TaskSpec, "objective" | "sessionId">>;
|
|
231
|
-
type ConfigValueDoorsResult = Pick<PrepareConfigDoorsResult, "toolFaceLists" | "promptHost" | "promptBinding" | "lockedPreflight" | "microCompactKnob" | "memoryDelegationEvidence" | "memoryProvenance" | "memoryCapturePolicy" | "usageWindows" | "brainCallGuardrailMs" | "crossBoundaryPosture" | "advisorTool" | "promptLean" | "hostFloor"> & {
|
|
239
|
+
type ConfigValueDoorsResult = Pick<PrepareConfigDoorsResult, "toolFaceLists" | "promptHost" | "promptBinding" | "lockedPreflight" | "microCompactKnob" | "memoryDelegationEvidence" | "memoryProvenance" | "memoryCapturePolicy" | "usageWindows" | "brainCallGuardrailMs" | "crossBoundaryPosture" | "advisorTool" | "promptLean" | "hostFloor" | "runOrigin"> & {
|
|
232
240
|
skillListingSeats: {
|
|
233
241
|
fraction: unknown;
|
|
234
242
|
maxDescChars: unknown;
|
|
@@ -250,20 +258,21 @@ export declare function configValueDoors(input: {
|
|
|
250
258
|
resumeLeg: boolean;
|
|
251
259
|
sessions: SessionStore;
|
|
252
260
|
holder?: string | undefined;
|
|
261
|
+
resumedRow?: Parameters<typeof runOriginOfLeg>[1];
|
|
253
262
|
}, enter?: ConfigDoorEntry): ConfigValueDoorsResult;
|
|
254
263
|
/**
|
|
255
264
|
* The doors a RESUMED leg's prepare refuses at, run as one screen BEFORE the claim — prepare's own functions, so a refusal carries
|
|
256
265
|
* the very sentence and code prepare throws: the mode doors (`refusePermissionModeDoors`), the output-style seat, the approval
|
|
257
266
|
* reach, the skills invoked by name (the part no roster changes), the attachments (a resume sends no new human message, so any
|
|
258
267
|
* entry is refused), the leg declarations of the tools it re-supplies (this phase's first door), this phase's value doors over the config, the deployment's deps and the session store the Runner holds
|
|
259
|
-
* ({@link configValueDoors}, the retention capability door
|
|
260
|
-
* It leaves by the resume's ONE refusal channel (`asResumeConfigRefusal`:
|
|
268
|
+
* ({@link configValueDoors}, the retention capability door and the run-origin door over the row's recorded word included) and the mode
|
|
269
|
+
* words the row recorded (`recordedModeSeed`). It leaves by the resume's ONE refusal channel (`asResumeConfigRefusal`:
|
|
261
270
|
* `checkpoint.config_refused`, `detail.code` = prepare's code, `detail.field` = `"taskConfig"`, `"deps"` or `"inheritedGate"`)
|
|
262
271
|
* where prepare would end the leg `failed` after the claim — the row consumed on a store without `reopen`, replayed as a system
|
|
263
272
|
* retry on one with it, which a configuration fix cannot reach. Before the claim the row stays `pending` and byte-identical and the
|
|
264
273
|
* corrected resume redeems the same token. A throw that is none of prepare's codes leaves as it was thrown. Returns the config the
|
|
265
274
|
* leg is handed: the caller's, its MCP servers and A2A peers the frozen entries the lock layer judged (read once, dialed as judged).
|
|
266
275
|
*/
|
|
267
|
-
export declare function refuseResumeDoors<C extends ValueDoorSpec & Pick<TaskSpec, "userAttachments">>(config: C,
|
|
276
|
+
export declare function refuseResumeDoors<C extends ValueDoorSpec & Pick<TaskSpec, "userAttachments">>(config: C, recorded: Pick<CheckpointState, "inheritedGate" | "runOrigin"> | undefined, deps: RunnerDeps, sessions: SessionStore, holder?: string): C;
|
|
268
277
|
export declare function prepareConfigDoors(input: PrepareConfigDoorsInput): PrepareConfigDoorsResult;
|
|
269
278
|
export {};
|