@sema-agent/core 7.57.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 +385 -0
- package/dist/agents/subagent-steps.js +2 -4
- package/dist/brain/route-adjudicator.js +2 -1
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +23 -10
- package/dist/core/allow-entry.d.ts +2 -1
- package/dist/core/allow-entry.js +2 -1
- package/dist/core/ask-origin.d.ts +21 -2
- package/dist/core/ask-origin.js +5 -1
- package/dist/core/auto-compaction.d.ts +4 -0
- package/dist/core/auto-compaction.js +1 -1
- package/dist/core/auto-mode-directive.d.ts +29 -5
- package/dist/core/auto-mode-directive.js +38 -8
- package/dist/core/checkpoint-requirements.d.ts +7 -1
- package/dist/core/checkpoint-requirements.js +2 -0
- package/dist/core/checkpoint-store.d.ts +27 -11
- package/dist/core/checkpoint-store.js +13 -3
- package/dist/core/engine-notice.d.ts +1 -1
- 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 +11 -2
- 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 +4 -1
- 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/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-probe.d.ts +4 -0
- package/dist/core/mcp-probe.js +1 -1
- 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 +77 -37
- 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/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/present-plan-tool.d.ts +10 -1
- package/dist/core/present-plan-tool.js +46 -2
- package/dist/core/protocol-http-auth.d.ts +40 -29
- package/dist/core/protocol-http-auth.js +30 -32
- 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/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/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/compaction-restate.d.ts +15 -6
- package/dist/core/runner/compaction-restate.js +28 -2
- package/dist/core/runner/contracts.d.ts +13 -5
- package/dist/core/runner/gate-exit.d.ts +18 -4
- package/dist/core/runner/gate-exit.js +5 -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 +8 -5
- package/dist/core/runner/prepare-config-doors.js +12 -10
- 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 +7 -3
- package/dist/core/runner/prepare-hands-readface.js +4 -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-policy-chain.d.ts +4 -4
- package/dist/core/runner/prepare-policy-chain.js +2 -2
- 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.js +25 -12
- 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/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 +5 -1
- package/dist/core/runner/run-notification-lane.js +3 -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 +2 -2
- 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-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/steer-replay.d.ts +4 -2
- package/dist/core/steer-replay.js +2 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +17 -0
- 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-shared.d.ts +2 -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.js +1 -0
- package/dist/core/tool-result-store.d.ts +17 -10
- package/dist/core/tool-result-store.js +3 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/core/untrusted-egress.d.ts +0 -2
- package/dist/core/untrusted-egress.js +10 -14
- 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 +5 -0
- package/dist/engine/harness/agent-harness.js +2 -0
- 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/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 +13 -6
- package/dist/index.js +10 -4
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +2 -2
- package/dist/internal/harness.js +2 -2
- package/dist/stores/file/index.d.ts +4 -1
- package/dist/stores/file/index.js +4 -1
- package/dist/stores/file/session-store.d.ts +15 -8
- package/dist/stores/file/session-store.js +28 -13
- 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/safety.js +40 -8
- package/dist/tools/fs/search.js +6 -24
- package/dist/tools/fs/shell-read-check.d.ts +8 -1
- package/dist/tools/fs/shell-read-check.js +59 -15
- package/dist/tools/fs/shell-read-establish.js +2 -1
- package/dist/tools/fs/shell-read-identity.js +1 -1
- package/dist/tools/fs/shell-read-judge.d.ts +10 -1
- 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 +63 -1
- package/wire-changes/core-stores-sql@7.58.0.json +29 -0
- package/wire-changes/core@7.58.0.json +2188 -0
- package/wire-changes/mods-kernel@7.58.0.json +81 -0
- package/wire-changes/primitives@7.58.0.json +29 -0
- package/dist/primitives/credential-ref.d.ts +0 -89
- package/dist/primitives/credential-ref.js +0 -125
- package/dist/primitives/index.d.ts +0 -2
- package/dist/primitives/index.js +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { stripMarkedReminderBlocks } from "../core/reminder-mint.js";
|
|
2
2
|
import { renderContentBlock } from "../internal/llm.js";
|
|
3
3
|
import { egressText } from "../core/untrusted-egress.js";
|
|
4
|
+
import { eachRedactionMarkerSpan } from "../core/redaction-marks.js";
|
|
4
5
|
import { isProtectedWrite } from "../core/tool-registry.js";
|
|
5
6
|
import { writeTargetPath } from "../tools/fs/safety.js";
|
|
6
7
|
export const STEP_CAP = 10;
|
|
@@ -10,14 +11,11 @@ function firstLine(s) {
|
|
|
10
11
|
const nl = s.indexOf("\n");
|
|
11
12
|
return nl === -1 ? s : s.slice(0, nl);
|
|
12
13
|
}
|
|
13
|
-
const REDACTION_MARKER_RE = /\[redacted(?:-[a-z]+)?\]/g;
|
|
14
14
|
export function cutAt(line, max) {
|
|
15
15
|
if (line.length <= max)
|
|
16
16
|
return line;
|
|
17
17
|
let at = max;
|
|
18
|
-
for (const
|
|
19
|
-
const start = m.index;
|
|
20
|
-
const end = start + m[0].length;
|
|
18
|
+
for (const [start, end] of eachRedactionMarkerSpan(line)) {
|
|
21
19
|
if (start < at && at < end) {
|
|
22
20
|
at = start;
|
|
23
21
|
break;
|
|
@@ -3,8 +3,9 @@ import { BrainError } from "./errors.js";
|
|
|
3
3
|
import { reportCredentialOriginRefusal } from "./status-sink.js";
|
|
4
4
|
import { receiptRefusal, receiveOwnProperties } from "../core/own-property-receipt.js";
|
|
5
5
|
import { credentialHeaderValues, holdOwnCredentialValues, isCredentialHeaderName, isSchemedCredentialHeader } from "../core/secret-env.js";
|
|
6
|
+
import { REDACTION_MARKS } from "../core/redaction-marks.js";
|
|
6
7
|
const REDACTED_VALUE = "«redacted»";
|
|
7
|
-
const REDACTED_CREDENTIALS =
|
|
8
|
+
const REDACTED_CREDENTIALS = REDACTION_MARKS.credentials;
|
|
8
9
|
function servableParse(raw) {
|
|
9
10
|
let u;
|
|
10
11
|
try {
|
package/dist/core/a2a.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AgentTool } from "../internal/harness-types.js";
|
|
2
|
+
import { type PeerSeat } from "./peer-seat.js";
|
|
2
3
|
import { type HostFloor } from "./host-floor.js";
|
|
3
4
|
import type { A2aServerSpec, ToolEffect } from "./types.js";
|
|
4
5
|
/** The hard per-skill description bound (ruled 2026-08-03: ~2KiB). */
|
|
@@ -97,4 +98,4 @@ export declare class A2aRpcError extends Error {
|
|
|
97
98
|
* `allSettled` keeps it fail-open: one unreachable peer is a skipped peer with a warning, never a task
|
|
98
99
|
* that cannot start.
|
|
99
100
|
*/
|
|
100
|
-
export declare function materializeA2aTools(specs: readonly A2aServerSpec[], principal?: string, signal?: AbortSignal, hostFloor?: HostFloor): Promise<MaterializedA2a>;
|
|
101
|
+
export declare function materializeA2aTools(specs: readonly A2aServerSpec[], principal?: string, signal?: AbortSignal, hostFloor?: HostFloor, peerSeat?: PeerSeat): Promise<MaterializedA2a>;
|
package/dist/core/a2a.js
CHANGED
|
@@ -2,6 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import { A2A_TASK_STATES } from "./a2a-task-state.js";
|
|
4
4
|
import { assertEndpointBound, carriesDeclaredHeaders, resolveProtocolHttpHeaders, underDeclaredHeaders } from "./protocol-http-auth.js";
|
|
5
|
+
import { PeerCarrier, carriedHttpHeaders, peerSeatMissing } from "./peer-seat.js";
|
|
5
6
|
import { fetchFollowing, hopRefusal, HOST_FLOOR_REFUSED_CODE } from "./host-floor.js";
|
|
6
7
|
import { describeHttpTransportFailure } from "./mcp-failure.js";
|
|
7
8
|
import { findNamespacePrefixCollision, mintNamespacePrefix, mintNamespacedToolName } from "./protocol-naming.js";
|
|
@@ -147,18 +148,23 @@ async function requestJson(t, what, init) {
|
|
|
147
148
|
const doFetch = resolveFetch();
|
|
148
149
|
const deadline = withRequestDeadline(init.signal, init.timeoutMs);
|
|
149
150
|
const peerLabel = inlineUntrusted(t.peer, A2A_ID_MAX_CHARS);
|
|
151
|
+
const pieces = await t.carrier.next(init.signal, init.url);
|
|
152
|
+
const carried = carriedHttpHeaders(A2A_NAMESPACE.id, t.carrier, pieces, t.principalHeader, t.principal);
|
|
153
|
+
assertEndpointBound(A2A_NAMESPACE.id, t.peer, init.url, t.declared, carried === undefined ? undefined : { ...carried });
|
|
150
154
|
try {
|
|
151
155
|
const followed = await fetchFollowing(doFetch, new URL(init.url), {
|
|
152
156
|
method: init.method,
|
|
153
|
-
headers: underDeclaredHeaders({ accept: "application/json", "a2a-version": A2A_PROTOCOL_VERSION, ...(init.body !== undefined ? { "content-type": "application/json" } : {}) },
|
|
157
|
+
headers: underDeclaredHeaders({ accept: "application/json", "a2a-version": A2A_PROTOCOL_VERSION, ...(init.body !== undefined ? { "content-type": "application/json" } : {}) }, carried === undefined ? undefined : { ...carried }),
|
|
154
158
|
...(init.body !== undefined ? { body: init.body } : {}),
|
|
155
159
|
signal: deadline.signal,
|
|
156
|
-
}, { refusal: (url) => hopRefusal(url, t.floor, false), follows: () => !carriesDeclaredHeaders(
|
|
160
|
+
}, { refusal: (url) => hopRefusal(url, t.floor, false), follows: () => !carriesDeclaredHeaders(carried === undefined ? undefined : { ...carried }), maxRedirects: A2A_MAX_REDIRECTS });
|
|
157
161
|
if (followed.kind === "refused")
|
|
158
162
|
throw Object.assign(new Error(`a2a: ${what} on peer "${peerLabel}" is not sent — ${followed.reason}`), { code: HOST_FLOOR_REFUSED_CODE });
|
|
159
163
|
if (followed.kind === "too_many")
|
|
160
164
|
throw new Error(`a2a: ${what} on peer "${peerLabel}" was redirected more than ${A2A_MAX_REDIRECTS} times`);
|
|
161
165
|
const res = followed.res;
|
|
166
|
+
if (res.status === 401)
|
|
167
|
+
await t.carrier.rejected(pieces, init.signal, init.url);
|
|
162
168
|
const text = await readBoundedText(res, `${what} from A2A peer "${peerLabel}"`);
|
|
163
169
|
return { status: res.status, text };
|
|
164
170
|
}
|
|
@@ -559,16 +565,23 @@ function declaredPeerOf(declared, index) {
|
|
|
559
565
|
const judged = judgeEntryToolAxes(snapshot, "a2a");
|
|
560
566
|
return judged.ok ? { spec: judged.entry } : { spec: snapshot, refusal: judged.error };
|
|
561
567
|
}
|
|
562
|
-
async function materializePeer(peer, principal, lifecycle, signal, floor) {
|
|
568
|
+
async function materializePeer(peer, principal, lifecycle, signal, floor, seat) {
|
|
563
569
|
if ("refusal" in peer)
|
|
564
570
|
throw peer.refusal;
|
|
565
571
|
const { spec } = peer;
|
|
566
572
|
const declaredAxes = spec.toolAxes;
|
|
567
|
-
const
|
|
568
|
-
|
|
573
|
+
const missing = peerSeatMissing(`a2a: peer "${inlineUntrusted(spec.name, 120)}"`, spec.credentials, seat);
|
|
574
|
+
if (missing !== undefined)
|
|
575
|
+
throw missing;
|
|
576
|
+
resolveProtocolHttpHeaders(A2A_NAMESPACE.id, spec.principalHeader !== undefined ? { principalHeader: spec.principalHeader } : {}, principal);
|
|
577
|
+
const declared = spec.cardUrl === undefined ? [spec.url] : [spec.url, spec.cardUrl];
|
|
578
|
+
const identity = { protocol: "a2a", peer: spec.name, url: spec.url, ...(spec.cardUrl !== undefined ? { cardUrl: spec.cardUrl } : {}), destination: spec.url, ...(spec.credentials !== undefined ? { credentials: spec.credentials } : {}) };
|
|
579
|
+
const carrier = new PeerCarrier(seat, identity, principal, "a2a", spec.principalHeader !== undefined);
|
|
580
|
+
const asks = { carrier, principalHeader: spec.principalHeader, principal, declared, floor };
|
|
581
|
+
const discovery = { peer: spec.name, endpoint: spec.url, ...asks };
|
|
569
582
|
const card = readCard(spec.name, await discoverCardBody(spec, discovery, signal), spec.url);
|
|
570
|
-
assertEndpointBound(A2A_NAMESPACE.id, spec.name, card.endpoint,
|
|
571
|
-
const transport = { peer: spec.name, endpoint: card.endpoint,
|
|
583
|
+
assertEndpointBound(A2A_NAMESPACE.id, spec.name, card.endpoint, declared, carrier.last?.headers === undefined ? undefined : { ...carrier.last.headers });
|
|
584
|
+
const transport = { peer: spec.name, endpoint: card.endpoint, ...asks };
|
|
572
585
|
const tools = [];
|
|
573
586
|
const skillAxes = [];
|
|
574
587
|
for (const skill of card.skills) {
|
|
@@ -598,7 +611,7 @@ function asPeerWarning(spec, err) {
|
|
|
598
611
|
warning.code = "a2a.peer_unavailable";
|
|
599
612
|
return warning;
|
|
600
613
|
}
|
|
601
|
-
export async function materializeA2aTools(specs, principal, signal, hostFloor) {
|
|
614
|
+
export async function materializeA2aTools(specs, principal, signal, hostFloor, peerSeat) {
|
|
602
615
|
const peers = specs.map((spec, index) => declaredPeerOf(spec, index));
|
|
603
616
|
if (peers.length > 0) {
|
|
604
617
|
const collision = findNamespacePrefixCollision(A2A_NAMESPACE, peers.map((p) => p.spec.name));
|
|
@@ -616,7 +629,7 @@ export async function materializeA2aTools(specs, principal, signal, hostFloor) {
|
|
|
616
629
|
const toolAxes = [];
|
|
617
630
|
const warnings = [];
|
|
618
631
|
const statuses = [];
|
|
619
|
-
const settled = await Promise.allSettled(peers.map((peer) => materializePeer(peer, principal, lifecycle, signal, hostFloor)));
|
|
632
|
+
const settled = await Promise.allSettled(peers.map((peer) => materializePeer(peer, principal, lifecycle, signal, hostFloor, peerSeat)));
|
|
620
633
|
for (let i = 0; i < peers.length; i++) {
|
|
621
634
|
const spec = peers[i].spec;
|
|
622
635
|
const outcome = settled[i];
|
|
@@ -651,7 +664,7 @@ export async function materializeA2aTools(specs, principal, signal, hostFloor) {
|
|
|
651
664
|
}
|
|
652
665
|
const previous = statuses.find((s) => s.name === spec.name)?.toolNames ?? [];
|
|
653
666
|
try {
|
|
654
|
-
const fresh = await materializePeer(target, principal, lifecycle, signal, hostFloor);
|
|
667
|
+
const fresh = await materializePeer(target, principal, lifecycle, signal, hostFloor, peerSeat);
|
|
655
668
|
const names = fresh.tools.map((t) => t.name);
|
|
656
669
|
results.push({
|
|
657
670
|
peer: spec.name,
|
|
@@ -285,7 +285,7 @@ export type AccountedClass = "probe";
|
|
|
285
285
|
* Exported (frozen) so a host that renders the card's "why it cannot be cleared" half reads the engine's row, never a copy. */
|
|
286
286
|
export declare const SHADOW_REASON: Readonly<{
|
|
287
287
|
readonly content_question: "the call is the engine's own question to a person";
|
|
288
|
-
readonly hook: "
|
|
288
|
+
readonly hook: "an extension's screening asks about this call (a PreToolUse hook or a tool.check station) — the deployment's own screening is answered by a person";
|
|
289
289
|
readonly ancestor: "the task that delegated this one owns this question";
|
|
290
290
|
readonly dangerous_delete: "this removal targets a protected location (the filesystem root, a top-level directory, a home directory, or a workspace directory or one of its ancestors) — it is cleared by confirming this call, never by an allow rule";
|
|
291
291
|
readonly unverifiable_delete: "this removal could not be verified safe — it is cleared by confirming this call, never by an allow rule";
|
|
@@ -301,6 +301,7 @@ export declare const SHADOW_REASON: Readonly<{
|
|
|
301
301
|
readonly operator_forced: "this call arrived already marked as requiring confirmation (an earlier layer of this run, or the task that delegated it, judged it so) — it is cleared by confirming this call, never by a standing allow rule";
|
|
302
302
|
readonly shell_floor: "this deployment mandates per-call confirmation for shell commands (shellGate: always)";
|
|
303
303
|
readonly target_unresolved: "where this write leads on disk could not be determined (a link on the way could not be examined, or the environment could not resolve the target), so whether it lands on a guarded path is unknown — it is cleared by confirming this call: no standing rule and no automatic decider answers for it, though a wired approver seat can";
|
|
304
|
+
readonly write_protection_on_disk: "this write's target is on the deployment's write-protection table (the agent's own configuration is guarded one look per write) — it is cleared by confirming this call, never by a standing allow rule";
|
|
304
305
|
readonly write_protection: "this write's target is on the deployment's write-protection table (the agent's own configuration is guarded one look per write) — it is cleared by confirming this call, never by a standing allow rule";
|
|
305
306
|
readonly tool_marks_mcp: "this tool carries egress/irreversibility/interaction marks (a mandated confirmation a rule cannot clear)";
|
|
306
307
|
readonly tool_marks_a2a: "this tool carries egress/irreversibility/interaction marks (a mandated confirmation a rule cannot clear)";
|
package/dist/core/allow-entry.js
CHANGED
|
@@ -368,7 +368,7 @@ export function readAllowRuleShadows(value) {
|
|
|
368
368
|
}
|
|
369
369
|
export const SHADOW_REASON = Object.freeze({
|
|
370
370
|
content_question: "the call is the engine's own question to a person",
|
|
371
|
-
hook: "
|
|
371
|
+
hook: "an extension's screening asks about this call (a PreToolUse hook or a tool.check station) — the deployment's own screening is answered by a person",
|
|
372
372
|
ancestor: "the task that delegated this one owns this question",
|
|
373
373
|
dangerous_delete: "this removal targets a protected location (the filesystem root, a top-level directory, a home directory, or a workspace directory or one of its ancestors) — it is cleared by confirming this call, never by an allow rule",
|
|
374
374
|
unverifiable_delete: "this removal could not be verified safe — it is cleared by confirming this call, never by an allow rule",
|
|
@@ -384,6 +384,7 @@ export const SHADOW_REASON = Object.freeze({
|
|
|
384
384
|
operator_forced: "this call arrived already marked as requiring confirmation (an earlier layer of this run, or the task that delegated it, judged it so) — it is cleared by confirming this call, never by a standing allow rule",
|
|
385
385
|
shell_floor: MANDATE_DISCLOSURE.operator_always,
|
|
386
386
|
target_unresolved: MANDATE_DISCLOSURE.target_unresolved,
|
|
387
|
+
write_protection_on_disk: MANDATE_DISCLOSURE.write_protection,
|
|
387
388
|
write_protection: MANDATE_DISCLOSURE.write_protection,
|
|
388
389
|
tool_marks_mcp: MANDATE_DISCLOSURE.tool_marks,
|
|
389
390
|
tool_marks_a2a: MANDATE_DISCLOSURE.tool_marks,
|
|
@@ -426,6 +426,10 @@ export interface MandateMarks {
|
|
|
426
426
|
* for a shell command's written targets). A GATE fact like the org words: it rides the pass, not the decision, so no
|
|
427
427
|
* layer outside the engine declares it. */
|
|
428
428
|
writeProtected?: boolean;
|
|
429
|
+
/** The same judge's record that a written target met its table only where the path resolves on disk (its real target, a hop
|
|
430
|
+
* of its link chain) — the path as written names no row (`GatePass.writeProtectedOnDisk`; the two writers of
|
|
431
|
+
* `writeProtected`, the reading of each target being one or the other). A GATE fact like `writeProtected`. */
|
|
432
|
+
writeProtectedOnDisk?: boolean;
|
|
429
433
|
/** The gate's record that the READING of a written target could not say where it leads on disk (`GatePass.targetUnresolved`:
|
|
430
434
|
* a target a shell command's program writes, placed, whose destination the read station could not resolve) — a fact of
|
|
431
435
|
* the reading, never a judge's verdict. The write face's twin of `probeUnanswered`. */
|
|
@@ -526,8 +530,13 @@ export type ToolMarkSource = "deployment" | "mcp_annotation" | "a2a_default";
|
|
|
526
530
|
* row ({@link REMOVAL_BREAKER_ROW}).
|
|
527
531
|
* `rule_unreadable` is a rule that may govern the call and cannot be read for it: the organization's snapshot, a partition of
|
|
528
532
|
* the person's store, or this call against a deny / ask row (the lexer's word, a content row, the read station's rows).
|
|
533
|
+
* `write_protection` and `write_protection_on_disk` are the two readings of one table hit, judged per written target and never
|
|
534
|
+
* both for one target: the path AS WRITTEN names a row of the write-protection table (`write_protection` — the classifier may
|
|
535
|
+
* answer it), or only where the path resolves on disk does (`write_protection_on_disk` — its real target, or a link on the way:
|
|
536
|
+
* an innocent spelling the disk carries onto a guarded path, which the auto-mode classifier does not answer). A command
|
|
537
|
+
* writing several targets may carry both.
|
|
529
538
|
*/
|
|
530
|
-
export declare const ASK_CLASSES: readonly ["content_question", "hook", "ancestor", "dangerous_delete", "unverifiable_delete", "unverifiable_shell_text", "transcript_write", "org_rule", "rule_unreadable", "ask_rule", "denial_limit_fallback", "classifier_no_ruling", "requires_user_interaction", "cross_boundary", "operator_forced", "shell_floor", "target_unresolved", "probe", "write_protection", "tool_marks_mcp", "tool_marks_a2a", "policy_rra", "artifact_shared_read", "mode", "unstated", "ordinary"];
|
|
539
|
+
export declare const ASK_CLASSES: readonly ["content_question", "hook", "ancestor", "dangerous_delete", "unverifiable_delete", "unverifiable_shell_text", "transcript_write", "org_rule", "rule_unreadable", "ask_rule", "denial_limit_fallback", "classifier_no_ruling", "requires_user_interaction", "cross_boundary", "operator_forced", "shell_floor", "target_unresolved", "probe", "write_protection_on_disk", "write_protection", "tool_marks_mcp", "tool_marks_a2a", "policy_rra", "artifact_shared_read", "mode", "unstated", "ordinary"];
|
|
531
540
|
export type AskClass = (typeof ASK_CLASSES)[number];
|
|
532
541
|
/** Membership test for {@link AskClass} — the word crosses the wire on `tool_end.gate.disposition`. */
|
|
533
542
|
export declare function isAskClass(v: unknown): v is AskClass;
|
|
@@ -561,7 +570,10 @@ export interface ModeArbitrationRow {
|
|
|
561
570
|
* rule or a bypass mode clears it, auto mode's classifier answers it, and a sandbox admits nothing on its behalf (the
|
|
562
571
|
* tool's effect lands at a remote peer, outside any containment the leg declares). `hookAskFloor` marks the classes the reference's rule / safety check answers
|
|
563
572
|
* `ask` for — an ask rule, a question the tool needs a person for, a dangerous removal, a protected or unresolvable write
|
|
564
|
-
* target, the session transcript, another's shared artifact.
|
|
573
|
+
* target, the session transcript, another's shared artifact. `write_protection_on_disk` is `write_protection`'s row but for the
|
|
574
|
+
* classifier column: the reference implementation marks a protected-write question its classifier may not answer exactly when
|
|
575
|
+
* the requested path alone is safe and the target's resolution is what reaches the guarded name — every other column of the
|
|
576
|
+
* question is the table's.
|
|
565
577
|
* A row is a class's reading on every face but the ones {@link RELEASED_ON_SHELL_FACE} names: `target_unresolved`'s
|
|
566
578
|
* `bypassImmune` is the file face's (and every other face's) reading, and the shell face reads it released — folded where the
|
|
567
579
|
* ask's row is ({@link foldArbitrationRow}), listed per face by {@link releasableAskClassesFor}.
|
|
@@ -693,6 +705,13 @@ export declare const MODE_ARBITRATION: {
|
|
|
693
705
|
readonly ruleMayClear: false;
|
|
694
706
|
readonly hookAskFloor: false;
|
|
695
707
|
};
|
|
708
|
+
readonly write_protection_on_disk: {
|
|
709
|
+
readonly bypassImmune: false;
|
|
710
|
+
readonly classifierEligible: false;
|
|
711
|
+
readonly sandboxAdmission: true;
|
|
712
|
+
readonly ruleMayClear: false;
|
|
713
|
+
readonly hookAskFloor: true;
|
|
714
|
+
};
|
|
696
715
|
readonly write_protection: {
|
|
697
716
|
readonly bypassImmune: false;
|
|
698
717
|
readonly classifierEligible: true;
|
package/dist/core/ask-origin.js
CHANGED
|
@@ -145,7 +145,7 @@ export function persistedRuleMandateOf(marks) {
|
|
|
145
145
|
const word = irreversibilityMandateOf(marks);
|
|
146
146
|
if (word === "probe_mandate" || word === "probe_unanswered")
|
|
147
147
|
return word;
|
|
148
|
-
if (marks.writeProtected === true)
|
|
148
|
+
if (marks.writeProtected === true || marks.writeProtectedOnDisk === true)
|
|
149
149
|
return "write_protection";
|
|
150
150
|
return marks.egress === true || marks.requiresUserInteraction === true ? "tool_marks" : word;
|
|
151
151
|
}
|
|
@@ -205,6 +205,7 @@ export const ASK_CLASSES = Object.freeze([
|
|
|
205
205
|
"shell_floor",
|
|
206
206
|
"target_unresolved",
|
|
207
207
|
"probe",
|
|
208
|
+
"write_protection_on_disk",
|
|
208
209
|
"write_protection",
|
|
209
210
|
"tool_marks_mcp",
|
|
210
211
|
"tool_marks_a2a",
|
|
@@ -238,6 +239,7 @@ export const MODE_ARBITRATION = {
|
|
|
238
239
|
shell_floor: { bypassImmune: true, classifierEligible: true, sandboxAdmission: true, ruleMayClear: false, hookAskFloor: false },
|
|
239
240
|
target_unresolved: { bypassImmune: true, classifierEligible: false, sandboxAdmission: true, ruleMayClear: false, hookAskFloor: true },
|
|
240
241
|
probe: { bypassImmune: false, classifierEligible: true, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: false },
|
|
242
|
+
write_protection_on_disk: { bypassImmune: false, classifierEligible: false, sandboxAdmission: true, ruleMayClear: false, hookAskFloor: true },
|
|
241
243
|
write_protection: { bypassImmune: false, classifierEligible: true, sandboxAdmission: true, ruleMayClear: false, hookAskFloor: true },
|
|
242
244
|
tool_marks_mcp: { bypassImmune: false, classifierEligible: true, sandboxAdmission: true, ruleMayClear: false, hookAskFloor: false },
|
|
243
245
|
tool_marks_a2a: { bypassImmune: false, classifierEligible: true, sandboxAdmission: true, ruleMayClear: false, hookAskFloor: false },
|
|
@@ -369,6 +371,8 @@ export function classifyAsk(d, facts) {
|
|
|
369
371
|
classes.add("target_unresolved");
|
|
370
372
|
if (marks.writeProtected === true)
|
|
371
373
|
classes.add("write_protection");
|
|
374
|
+
if (marks.writeProtectedOnDisk === true)
|
|
375
|
+
classes.add("write_protection_on_disk");
|
|
372
376
|
if (facts.tightened === "unstated")
|
|
373
377
|
classes.add("unstated");
|
|
374
378
|
for (const c of facts.ancestorClasses ?? [])
|
|
@@ -424,6 +424,10 @@ export interface MaybeCompactOptions {
|
|
|
424
424
|
* context may have lost an engine frame the run still needs, and every reader of the new baseline
|
|
425
425
|
* (the next model request first) must see it restated. */
|
|
426
426
|
postureRestate?: () => Promise<void>;
|
|
427
|
+
/** The session plan file's post-compaction reference (`planFileRestateOption`, the runner's `compactionRestateOptions`):
|
|
428
|
+
* where the plan is and what it says, on a leg whose run admitted a plan file that holds one; runs right after
|
|
429
|
+
* `postureRestate`, under the same belt. */
|
|
430
|
+
planFileRestate?: () => Promise<void>;
|
|
427
431
|
/** The advisor tool's instructions' post-compaction restatement on a leg that mounts the tool (the runner's
|
|
428
432
|
* `compactionRestateOptions`): runs right after `postureRestate`, under the same belt, for the same reason. */
|
|
429
433
|
advisorRestate?: () => Promise<void>;
|
|
@@ -517,7 +517,7 @@ export async function maybeCompact(opts) {
|
|
|
517
517
|
catch {
|
|
518
518
|
}
|
|
519
519
|
}
|
|
520
|
-
for (const restate of [opts.postureRestate, opts.advisorRestate]) {
|
|
520
|
+
for (const restate of [opts.postureRestate, opts.planFileRestate, opts.advisorRestate]) {
|
|
521
521
|
if (restate === undefined)
|
|
522
522
|
continue;
|
|
523
523
|
try {
|
|
@@ -29,6 +29,21 @@ export declare const PLAN_MODE_NO_EXIT_SPARSE_DIRECTIVE: string;
|
|
|
29
29
|
* the child answers the request it was given (its final answer goes back to the agent that delegated to it). The
|
|
30
30
|
* reference has no sparse arm for a sub-agent, so a restatement of this row is this body. */
|
|
31
31
|
export declare const PLAN_MODE_CHILD_DIRECTIVE: string;
|
|
32
|
+
/** A frame that names the leg's session plan file: the text before the file, and the text after it. The file goes between
|
|
33
|
+
* them as the seat tells it (`planFileShown`, advertised-writable-dirs.ts — one line, verbatim); the fold recognizes the
|
|
34
|
+
* frame by its two halves. */
|
|
35
|
+
export interface PostureTemplate {
|
|
36
|
+
readonly head: string;
|
|
37
|
+
readonly tail: string;
|
|
38
|
+
}
|
|
39
|
+
/** The planning frame of a leg that keeps its plan in a FILE (`TaskSpec.planFile`, the reference's disk arm): the reference
|
|
40
|
+
* full reminder's disk-arm opening — the edit ban "with the exception of the plan file mentioned below" — and its
|
|
41
|
+
* `## Plan File Info:` section, with the file's existence left to the model (the reference words it two ways off a disk
|
|
42
|
+
* read; this frame names both actions), and the tail adapted to the engine's exit (the plan-exit tool reads the file, a
|
|
43
|
+
* human approves). */
|
|
44
|
+
export declare const PLAN_MODE_FILE_DIRECTIVE: PostureTemplate;
|
|
45
|
+
/** The file arm's sparse restatement — the reference sparse shape with its plan-file clause ("Read-only except plan file"). */
|
|
46
|
+
export declare const PLAN_MODE_FILE_SPARSE_DIRECTIVE: PostureTemplate;
|
|
32
47
|
/** The planning frame's exit — the reference exit renderer's text without its plan-file clause. Names no tool, so
|
|
33
48
|
* one exit retires every planning wording. */
|
|
34
49
|
export declare const PLAN_MODE_EXIT_DIRECTIVE: string;
|
|
@@ -50,6 +65,9 @@ export interface PostureLegFacts {
|
|
|
50
65
|
exitToolMounted: boolean;
|
|
51
66
|
/** This leg runs as a delegated child (every core spawn lane, a fork included). */
|
|
52
67
|
isChildLeg: boolean;
|
|
68
|
+
/** The session plan file the run admitted (`TaskSpec.planFile`), as the seat tells it to the model (`planFileShown`) —
|
|
69
|
+
* absent ⇒ the plan is the plan-exit tool's argument and no frame names a file. */
|
|
70
|
+
planFile?: string;
|
|
53
71
|
}
|
|
54
72
|
/** Every fact a row's `owedBy` reads: the mode facts and the leg's shape. */
|
|
55
73
|
export type PostureFacts = ApprovalPostureFacts & PostureLegFacts;
|
|
@@ -60,8 +78,8 @@ export interface PostureRow {
|
|
|
60
78
|
readonly family: PostureFamily;
|
|
61
79
|
/** Whether the leg's mode facts call for this row. */
|
|
62
80
|
readonly owedBy: (facts: PostureFacts) => boolean;
|
|
63
|
-
/** The frame that states the posture. */
|
|
64
|
-
readonly frame: string;
|
|
81
|
+
/** The frame that states the posture — a fixed text, or a frame that names the leg's plan file ({@link PostureTemplate}). */
|
|
82
|
+
readonly frame: string | PostureTemplate;
|
|
65
83
|
/** The frame that retires it. */
|
|
66
84
|
readonly exit: string;
|
|
67
85
|
/**
|
|
@@ -72,14 +90,17 @@ export interface PostureRow {
|
|
|
72
90
|
readonly cadence?: {
|
|
73
91
|
readonly everyTurns: number;
|
|
74
92
|
readonly fullEvery: number;
|
|
75
|
-
readonly sparse: string;
|
|
93
|
+
readonly sparse: string | PostureTemplate;
|
|
76
94
|
};
|
|
77
95
|
}
|
|
96
|
+
/** A frame's text for this leg: a fixed text as it stands, a template with the leg's plan file between its halves. */
|
|
97
|
+
export declare function postureText(text: string | PostureTemplate, facts: Pick<PostureFacts, "planFile">): string;
|
|
78
98
|
/**
|
|
79
99
|
* Every posture the engine states, in the order the owed row is chosen. `plan` first: it is the mode the leg
|
|
80
100
|
* was put in, and the bypass frame's shell-first instruction would contradict it. Within it the leg's shape picks the
|
|
81
|
-
* wording — a delegated child (the reference's sub-agent variant), else a leg with the plan-exit tool on its roster
|
|
82
|
-
* (the
|
|
101
|
+
* wording — a delegated child (the reference's sub-agent variant), else a leg with the plan-exit tool on its roster and a
|
|
102
|
+
* session plan file (the body that names both), else a leg with the plan-exit tool (the planning body that names it),
|
|
103
|
+
* else the body that names no tool. Then the reference
|
|
83
104
|
* implementation's own arm order for its one posture attachment: bypass (effective `bypassPermissions`, or — outside
|
|
84
105
|
* `dontAsk`, whose mode refuses every ask before any seat could answer — no person answers an ask), then auto (the
|
|
85
106
|
* classifier is armed — a requested auto mode the engine folded back is not stated, because the run is not operating
|
|
@@ -95,6 +116,9 @@ export interface StandingPosture {
|
|
|
95
116
|
readonly statements: number;
|
|
96
117
|
/** Assistant turns since the family's last frame (the cadence's due clock). */
|
|
97
118
|
readonly turnsSince: number;
|
|
119
|
+
/** The plan file the standing frame named, as rendered (a template frame only): a leg whose plan file reads otherwise
|
|
120
|
+
* is owed the full frame again — the frame's row is the same, what it states is not. */
|
|
121
|
+
readonly file?: string;
|
|
98
122
|
}
|
|
99
123
|
/** The standing families of a context, keyed by family, in the order they first stood. */
|
|
100
124
|
export type PostureStanding = ReadonlyMap<PostureFamily, StandingPosture>;
|
|
@@ -11,10 +11,22 @@ export const PLAN_MODE_SPARSE_DIRECTIVE = `Plan mode still active (see full inst
|
|
|
11
11
|
export const PLAN_MODE_NO_EXIT_DIRECTIVE = "Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system — every such call asks the user first, and is refused where nobody can answer. This supercedes any other instructions you have received. Instead, you should: research and analyze with read-only tools, and when you have formed a concrete plan, give it as your final answer and stop.";
|
|
12
12
|
export const PLAN_MODE_NO_EXIT_SPARSE_DIRECTIVE = "Plan mode still active (see full instructions earlier in conversation). Read-only: no edits, commits, or config changes. When your plan is ready, give it as your final answer and stop.";
|
|
13
13
|
export const PLAN_MODE_CHILD_DIRECTIVE = "Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system — every such call asks the user first, and is refused where nobody can answer. This supercedes any other instructions you have received. Instead, you should: research and analyze with read-only tools, and answer the request comprehensively — your final answer, carrying the plan, goes back to the agent that delegated to you.";
|
|
14
|
+
export const PLAN_MODE_FILE_DIRECTIVE = {
|
|
15
|
+
head: "Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits (with the exception of the plan file mentioned below), run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system — every such call asks the user first, and is refused where nobody can answer. This supercedes any other instructions you have received.\n\n## Plan File Info:\nYour plan file is ",
|
|
16
|
+
tail: `. If it does not exist yet, create your plan there using the Write tool; if it already exists, read it and make incremental edits using the Edit tool. You should build your plan incrementally by writing to or editing this file. NOTE that this is the only file you are allowed to edit - other than this you are only allowed to take READ-ONLY actions.\n\nWhen your plan is ready, call the ${PRESENT_PLAN_TOOL_NAME} tool: it reads the plan from that file and requests approval — never ask for approval via plain text.`,
|
|
17
|
+
};
|
|
18
|
+
export const PLAN_MODE_FILE_SPARSE_DIRECTIVE = {
|
|
19
|
+
head: "Plan mode still active (see full instructions earlier in conversation). Read-only except plan file (",
|
|
20
|
+
tail: `). When your plan is ready, call the ${PRESENT_PLAN_TOOL_NAME} tool — it reads the plan from that file. Never ask about plan approval via plain text.`,
|
|
21
|
+
};
|
|
14
22
|
export const PLAN_MODE_EXIT_DIRECTIVE = "## Exited Plan Mode\n\nYou have exited plan mode. You can now make edits, run tools, and take actions.";
|
|
23
|
+
export function postureText(text, facts) {
|
|
24
|
+
return typeof text === "string" ? text : `${text.head}${facts.planFile ?? ""}${text.tail}`;
|
|
25
|
+
}
|
|
15
26
|
const PLAN_CADENCE = { everyTurns: 5, fullEvery: 5, sparse: PLAN_MODE_SPARSE_DIRECTIVE };
|
|
16
27
|
export const POSTURE_TABLE = Object.freeze([
|
|
17
28
|
{ family: "plan", owedBy: (f) => f.mode === "plan" && f.isChildLeg, frame: PLAN_MODE_CHILD_DIRECTIVE, exit: PLAN_MODE_EXIT_DIRECTIVE, cadence: { ...PLAN_CADENCE, sparse: PLAN_MODE_CHILD_DIRECTIVE } },
|
|
29
|
+
{ family: "plan", owedBy: (f) => f.mode === "plan" && f.exitToolMounted && f.planFile !== undefined, frame: PLAN_MODE_FILE_DIRECTIVE, exit: PLAN_MODE_EXIT_DIRECTIVE, cadence: { ...PLAN_CADENCE, sparse: PLAN_MODE_FILE_SPARSE_DIRECTIVE } },
|
|
18
30
|
{ family: "plan", owedBy: (f) => f.mode === "plan" && f.exitToolMounted, frame: PLAN_MODE_DIRECTIVE, exit: PLAN_MODE_EXIT_DIRECTIVE, cadence: PLAN_CADENCE },
|
|
19
31
|
{ family: "plan", owedBy: (f) => f.mode === "plan", frame: PLAN_MODE_NO_EXIT_DIRECTIVE, exit: PLAN_MODE_EXIT_DIRECTIVE, cadence: { ...PLAN_CADENCE, sparse: PLAN_MODE_NO_EXIT_SPARSE_DIRECTIVE } },
|
|
20
32
|
{ family: "auto", owedBy: (f) => f.mode === "bypassPermissions" || (f.mode !== "dontAsk" && f.askEffective === "auto_allow"), frame: BYPASS_POSTURE_DIRECTIVE, exit: BYPASS_POSTURE_EXIT_DIRECTIVE },
|
|
@@ -28,15 +40,32 @@ const POSTURE_VOCABULARY = POSTURE_TABLE.flatMap((row) => [
|
|
|
28
40
|
[row.exit, { row, exit: true }],
|
|
29
41
|
...(row.cadence !== undefined ? [[row.cadence.sparse, { row, exit: false }]] : []),
|
|
30
42
|
]);
|
|
43
|
+
function vocabularyLengthAt(rest, text) {
|
|
44
|
+
if (typeof text === "string")
|
|
45
|
+
return rest.startsWith(text) ? text.length : undefined;
|
|
46
|
+
if (!rest.startsWith(text.head))
|
|
47
|
+
return undefined;
|
|
48
|
+
const end = rest.indexOf(text.tail, text.head.length);
|
|
49
|
+
if (end <= text.head.length || rest.slice(text.head.length, end).includes("\n"))
|
|
50
|
+
return undefined;
|
|
51
|
+
return end + text.tail.length;
|
|
52
|
+
}
|
|
31
53
|
function postureItemsOf(body) {
|
|
32
54
|
const out = [];
|
|
33
55
|
let rest = body;
|
|
34
56
|
while (rest.length > 0) {
|
|
35
|
-
|
|
36
|
-
|
|
57
|
+
let matched;
|
|
58
|
+
for (const [text, item] of POSTURE_VOCABULARY) {
|
|
59
|
+
const length = vocabularyLengthAt(rest, text);
|
|
60
|
+
if (length !== undefined && (length === rest.length || rest.startsWith("\n\n", length))) {
|
|
61
|
+
matched = { item: typeof text === "string" ? item : { ...item, file: rest.slice(text.head.length, length - text.tail.length) }, length };
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (matched === undefined)
|
|
37
66
|
return undefined;
|
|
38
|
-
out.push(
|
|
39
|
-
rest =
|
|
67
|
+
out.push(matched.item);
|
|
68
|
+
rest = matched.length === rest.length ? "" : rest.slice(matched.length + 2);
|
|
40
69
|
}
|
|
41
70
|
return out.length > 0 ? out : undefined;
|
|
42
71
|
}
|
|
@@ -54,7 +83,7 @@ export function postureStandingOf(messages, reminderMark) {
|
|
|
54
83
|
if (item.exit)
|
|
55
84
|
standing.delete(item.row.family);
|
|
56
85
|
else
|
|
57
|
-
standing.set(item.row.family, { row: item.row, statements: (standing.get(item.row.family)?.statements ?? 0) + 1, turnsSince: 0 });
|
|
86
|
+
standing.set(item.row.family, { row: item.row, statements: (standing.get(item.row.family)?.statements ?? 0) + 1, turnsSince: 0, ...(item.file !== undefined ? { file: item.file } : {}) });
|
|
58
87
|
}
|
|
59
88
|
}
|
|
60
89
|
}
|
|
@@ -70,10 +99,11 @@ export function composePostureFrames(facts, standing) {
|
|
|
70
99
|
if (owed === undefined)
|
|
71
100
|
return frames;
|
|
72
101
|
const s = standing.get(owed.family);
|
|
73
|
-
|
|
74
|
-
|
|
102
|
+
const fileMoved = s !== undefined && typeof owed.frame !== "string" && s.file !== (facts.planFile ?? "");
|
|
103
|
+
if (s === undefined || s.row !== owed || fileMoved)
|
|
104
|
+
frames.push(postureText(owed.frame, facts));
|
|
75
105
|
else if (owed.cadence !== undefined && s.turnsSince >= owed.cadence.everyTurns) {
|
|
76
|
-
frames.push((s.statements + 1) % owed.cadence.fullEvery === 1 ? owed.frame : owed.cadence.sparse);
|
|
106
|
+
frames.push(postureText((s.statements + 1) % owed.cadence.fullEvery === 1 ? owed.frame : owed.cadence.sparse, facts));
|
|
77
107
|
}
|
|
78
108
|
return frames;
|
|
79
109
|
}
|
|
@@ -6,7 +6,7 @@ import { type StoreFidelity, type Checkpoint, type CheckpointFeature, type Check
|
|
|
6
6
|
* had carried beside the one its word now names, and the members added after the table, each a capability a reader
|
|
7
7
|
* must have. Downstream reads them for display only (`CheckpointError.detail.requires`).
|
|
8
8
|
*/
|
|
9
|
-
export declare const REQUIREMENT_WORDS: readonly ["resource", "binding", "token", "orgAdmission", "f012", "realApproval", "face", "requirements_digest", "org_admission_inherited", "org_write_grant", "org_governed", "delegation_provenance", "skill_grants", "skill_card_binding", "hands_coordinates", "hands_home", "path_rule_anchors", "path_rule_installations", "permission_mode", "plan_mode_restore", "persisted_rule_mandate", "deployment_authored", "call_names", "write_face", "denial_limit_fallback", "leg_scope", "tool_ceiling", "tool_lists_judged", "own_tool_lists", "approval_targets", "approval_target_reads", "cross_boundary", "mount_site", "skill_scopes"];
|
|
9
|
+
export declare const REQUIREMENT_WORDS: readonly ["resource", "binding", "token", "orgAdmission", "f012", "realApproval", "face", "requirements_digest", "org_admission_inherited", "org_write_grant", "org_governed", "delegation_provenance", "skill_grants", "skill_card_binding", "hands_coordinates", "hands_home", "path_rule_anchors", "path_rule_installations", "permission_mode", "plan_mode_restore", "persisted_rule_mandate", "deployment_authored", "call_names", "write_face", "denial_limit_fallback", "leg_scope", "tool_ceiling", "tool_lists_judged", "own_tool_lists", "approval_targets", "approval_target_reads", "cross_boundary", "mount_site", "skill_scopes", "run_origin"];
|
|
10
10
|
export type RequirementWord = (typeof REQUIREMENT_WORDS)[number];
|
|
11
11
|
/** Runtime twin of {@link RequirementWord}. */
|
|
12
12
|
export declare function isRequirementWord(word: unknown): word is RequirementWord;
|
|
@@ -221,6 +221,9 @@ export declare const CHECKPOINT_STATE_REQUIREMENTS: {
|
|
|
221
221
|
readonly legScope: {
|
|
222
222
|
readonly word: "leg_scope";
|
|
223
223
|
};
|
|
224
|
+
readonly runOrigin: {
|
|
225
|
+
readonly word: "run_origin";
|
|
226
|
+
};
|
|
224
227
|
readonly toolCeiling: {
|
|
225
228
|
readonly word: "tool_ceiling";
|
|
226
229
|
};
|
|
@@ -591,6 +594,9 @@ export declare const CHECKPOINT_REQUIREMENTS: {
|
|
|
591
594
|
readonly legScope: {
|
|
592
595
|
readonly word: "leg_scope";
|
|
593
596
|
};
|
|
597
|
+
readonly runOrigin: {
|
|
598
|
+
readonly word: "run_origin";
|
|
599
|
+
};
|
|
594
600
|
readonly toolCeiling: {
|
|
595
601
|
readonly word: "tool_ceiling";
|
|
596
602
|
};
|
|
@@ -36,6 +36,7 @@ export const REQUIREMENT_WORDS = Object.freeze([
|
|
|
36
36
|
"cross_boundary",
|
|
37
37
|
"mount_site",
|
|
38
38
|
"skill_scopes",
|
|
39
|
+
"run_origin",
|
|
39
40
|
]);
|
|
40
41
|
export function isRequirementWord(word) {
|
|
41
42
|
return typeof word === "string" && REQUIREMENT_WORDS.includes(word);
|
|
@@ -95,6 +96,7 @@ export const CHECKPOINT_STATE_REQUIREMENTS = {
|
|
|
95
96
|
placementRootSessionId: DECISION_READ,
|
|
96
97
|
externalContentTarget: DECISION_READ,
|
|
97
98
|
legScope: { word: "leg_scope" },
|
|
99
|
+
runOrigin: { word: "run_origin" },
|
|
98
100
|
toolCeiling: { word: "tool_ceiling" },
|
|
99
101
|
toolListsJudged: { word: "tool_lists_judged" },
|
|
100
102
|
ownToolLists: { word: "own_tool_lists" },
|
|
@@ -13,6 +13,7 @@ import type { SessionPermissionRules } from "./session-policy-store.js";
|
|
|
13
13
|
import type { NestedUsageAccum, PermissionMode, ShellGateDoctrine, TaskResult } from "./types.js";
|
|
14
14
|
import type { ActiveWorktreeSession } from "../internal/harness-types.js";
|
|
15
15
|
import type { ReopenReason } from "./resume-startup-cause.js";
|
|
16
|
+
import { type RetentionDeclaration } from "./retention.js";
|
|
16
17
|
/**
|
|
17
18
|
* design/45 — the **durable-checkpoint** primitive: cross-process / resumable `suspend`/`resume`.
|
|
18
19
|
*
|
|
@@ -317,7 +318,7 @@ export declare const MAX_PENDING_STEER_ENTRIES: number;
|
|
|
317
318
|
* loud rejection instead of having its new field silently dropped on the parked leg. Consumers (other
|
|
318
319
|
* repos' backends) read it to assert they round-trip every field rather than hand-listing their own copy.
|
|
319
320
|
*/
|
|
320
|
-
export declare const PENDING_STEER_FROZEN_FIELDS: readonly ["text", "trusted", "actor", "seq", "inputId", "priority"];
|
|
321
|
+
export declare const PENDING_STEER_FROZEN_FIELDS: readonly ["text", "trusted", "actor", "seq", "inputId", "priority", "runOrigin"];
|
|
321
322
|
/**
|
|
322
323
|
* design/171 §6.1 — WHO a piece of human input came from, as an attribution label. ONE definition:
|
|
323
324
|
* the shape lives at its layering-legal home (`engine/llm/types.ts`, where `UserMessage.actor`
|
|
@@ -351,6 +352,9 @@ export interface PendingSteerEntry {
|
|
|
351
352
|
inputId: string;
|
|
352
353
|
/** Carried VERBATIM for the serving layer; it does NOT reorder the drain (drain is `seq` order). */
|
|
353
354
|
priority?: SystemInjectionPriority;
|
|
355
|
+
/** What brought this input, when its host says so ({@link import("./run-origin.js").RunOrigin}): its `human_input` frame
|
|
356
|
+
* reports it, and the newest input a wake hands over states the woken leg's word with it. Attribution only; absent = the host said nothing. */
|
|
357
|
+
runOrigin?: import("./run-origin.js").RunOrigin;
|
|
354
358
|
}
|
|
355
359
|
/** design/171 §6.3 — the caller-supplied half of a {@link PendingSteerEntry}: everything except `seq`,
|
|
356
360
|
* which only the store may mint. `inputId` is optional on the way in (minted when absent). */
|
|
@@ -360,6 +364,7 @@ export interface PendingSteerInput {
|
|
|
360
364
|
actor?: ActorAssertion;
|
|
361
365
|
inputId?: string;
|
|
362
366
|
priority?: SystemInjectionPriority;
|
|
367
|
+
runOrigin?: import("./run-origin.js").RunOrigin;
|
|
363
368
|
}
|
|
364
369
|
/** True ONLY for a PLAIN data record (not null / array / class-instance / proxy-with-odd-prototype) — the only
|
|
365
370
|
* shape we safely digest. Adversarial args (a proxy, a getter that throws) must never crash the mint, so this +
|
|
@@ -1367,6 +1372,12 @@ export interface CheckpointState {
|
|
|
1367
1372
|
* that hands no live seat restores it, so the resume config cannot move the leg's next row. Not {@link Checkpoint.scope}
|
|
1368
1373
|
* (where THIS row is filed — a resource slice's own declared scope). Absent ⇒ minted before the member: derived as before. */
|
|
1369
1374
|
legScope?: string;
|
|
1375
|
+
/** The word of the LEG that parked this row ({@link import("./run-origin.js").RunOrigin}: the word of the input that opened
|
|
1376
|
+
* that leg, read once at its config doors), stamped at every mint and continued by a leg a decision resumes (a wake opens
|
|
1377
|
+
* its leg with the input it hands over instead): an approved, resumed leg is still that leg's work. Absent ⇒ the host said
|
|
1378
|
+
* nothing (or the row was minted before the member). Attribution only. A reader that lacks the word would resume the leg with
|
|
1379
|
+
* its origin silently lost. */
|
|
1380
|
+
runOrigin?: import("./run-origin.js").RunOrigin;
|
|
1370
1381
|
/** The tool-selector layers this LEG was spawned under (`RunInternals.toolCeiling`), stamped at every mint: a resume that hands
|
|
1371
1382
|
* no live ceiling restores it, so a resumed child can never use a tool its spawning run could not. Absent ⇒ the leg had no
|
|
1372
1383
|
* ceiling (a root run) or the row was minted before the member. A reader that lacks the word would run the leg unbounded.
|
|
@@ -2098,6 +2109,11 @@ export interface CheckpointSummary {
|
|
|
2098
2109
|
* value is a member of the closed set ({@link import("./ask-origin.js").isAskOrigin}) — a bad value
|
|
2099
2110
|
* reads as absent, never as a word. OMITTED when the row carries none (a pre-existing row). */
|
|
2100
2111
|
origin?: import("./ask-origin.js").AskOrigin;
|
|
2112
|
+
/** What opened the leg that parked this row — the row's `state.runOrigin` (`"scheduled"`: the deployment's scheduler, not a
|
|
2113
|
+
* person submitting just now), for every gate kind, so an inbox shows it in the one listing call. Echoed only as a member of
|
|
2114
|
+
* {@link import("./run-origin.js").RUN_ORIGINS} (the resume's screen refuses any other value loudly; this projection never
|
|
2115
|
+
* invents one). OMITTED when the row carries none. ECHO-ONLY: attribution, never a gate input. */
|
|
2116
|
+
runOrigin?: import("./run-origin.js").RunOrigin;
|
|
2101
2117
|
/**
|
|
2102
2118
|
* PRESENCE ONLY — this pending `tool_approval` row's payload carries at least one DIRECTIONAL
|
|
2103
2119
|
* format control (the {@link import("./tool-policy.js").AskRequest.hasBidiControls} character class;
|
|
@@ -2216,7 +2232,7 @@ export type CheckpointErrorReason = "version_newer" | "env_factory_missing" | "g
|
|
|
2216
2232
|
* a skill's `baseDir` by its own reader, `config.skill_base_dir_invalid`). A door not entered here (the leg's model, its rebuilt
|
|
2217
2233
|
* roster, its answer face, the approval seat's value) still refuses after the claim, each for a stated reason (INTEGRATION-CORE, "A resume's two doors").
|
|
2218
2234
|
*/
|
|
2219
|
-
export declare const CHECKPOINT_CONFIG_REFUSAL_CODES: readonly ["config.spec_retired_key", "config.output_style_invalid", "config.permission_mode_invalid", "config.shell_gate_value_retired", "config.approval_reach_invalid", "config.user_invoked_skill_unknown", "config.skill_deny_unreadable", "config.user_attachment_invalid", "config.tool_face_control", "config.deps_retired_key", "config.peer_presence_invalid", "config.tool_model_gate_invalid", "config.microcompact_invalid", "config.prompt_selector_invalid", "resume_at.conflicts_resume", "resume_at.mode_without_target", "config.read_face_invalid", "config.write_face_invalid", "config.invalid_argument", "config.tool_face_invalid", "config.memory_delegation_evidence", "config.memory_provenance", "config.memory_capture_policy", "config.cross_boundary_posture", "config.advisor_tool_invalid", "config.advisor_model_invalid", "config.auto_consolidation", "config.unknown_role", "config.tool_materialize_invalid", "config.memory_persistence_invalid", "config.tool_materialize_unreachable", "config.locked_registry", "config.locked_key", "config.mcp_content_class", "config.skill_listing_budget_invalid", "config.limit_unknown_key", "config.limit_invalid", "config.attachment_invalid", "config.usage_window_invalid", "config.brain_call_guardrail_invalid", "config.retention_policy", "config.retention_capability", "config.invalid_checkpoint_store", "config.skill_base_dir_invalid", "config.host_floor_invalid"];
|
|
2235
|
+
export declare const CHECKPOINT_CONFIG_REFUSAL_CODES: readonly ["config.spec_retired_key", "config.output_style_invalid", "config.permission_mode_invalid", "config.shell_gate_value_retired", "config.approval_reach_invalid", "config.run_origin_invalid", "config.user_invoked_skill_unknown", "config.skill_deny_unreadable", "config.user_attachment_invalid", "config.tool_face_control", "config.deps_retired_key", "config.peer_presence_invalid", "config.tool_model_gate_invalid", "config.microcompact_invalid", "config.prompt_selector_invalid", "resume_at.conflicts_resume", "resume_at.mode_without_target", "config.read_face_invalid", "config.write_face_invalid", "config.invalid_argument", "config.tool_face_invalid", "config.memory_delegation_evidence", "config.memory_provenance", "config.memory_capture_policy", "config.cross_boundary_posture", "config.advisor_tool_invalid", "config.advisor_model_invalid", "config.auto_consolidation", "config.unknown_role", "config.tool_materialize_invalid", "config.memory_persistence_invalid", "config.tool_materialize_unreachable", "config.locked_registry", "config.locked_key", "config.mcp_content_class", "config.skill_listing_budget_invalid", "config.limit_unknown_key", "config.limit_invalid", "config.attachment_invalid", "config.usage_window_invalid", "config.brain_call_guardrail_invalid", "config.retention_policy", "config.retention_capability", "config.invalid_checkpoint_store", "config.skill_base_dir_invalid", "config.host_floor_invalid", "config.credential_in_declaration", "config.credential_ref_invalid", "config.peer_seat_missing"];
|
|
2220
2236
|
export type CheckpointConfigRefusalCode = (typeof CHECKPOINT_CONFIG_REFUSAL_CODES)[number];
|
|
2221
2237
|
export declare const isCheckpointConfigRefusalCode: (word: unknown) => word is CheckpointConfigRefusalCode;
|
|
2222
2238
|
/** The words of a {@link CheckpointError}'s optional `detail.field` (what each means: the `detail` member's doc). A CLOSED SET with one home, registered in
|
|
@@ -2750,13 +2766,12 @@ export declare function encodeAtFidelity(fidelity: StoreFidelity, value: unknown
|
|
|
2750
2766
|
};
|
|
2751
2767
|
export interface CheckpointStore {
|
|
2752
2768
|
/**
|
|
2753
|
-
* Managed-retention declaration (
|
|
2754
|
-
*
|
|
2755
|
-
* {@link reap} (
|
|
2756
|
-
*
|
|
2757
|
-
* with a LOCKED retention policy refuses to start over it. Declaration, never duck-typing.
|
|
2769
|
+
* Managed-retention declaration (retention.ts), stated by the party that runs the sweep: `"managed"` says this store's
|
|
2770
|
+
* rows are deleted on schedule by the deployment — an executor runs over them, closing the reap/unpin gap documented on
|
|
2771
|
+
* {@link reap} (its scheduled expiry DOES release the session pins). `"none"` (or ABSENT — read fail-closed as `"none"`)
|
|
2772
|
+
* says nothing deletes them on schedule; a deployment with a LOCKED retention policy refuses to start over it.
|
|
2758
2773
|
*/
|
|
2759
|
-
readonly retention?:
|
|
2774
|
+
readonly retention?: RetentionDeclaration;
|
|
2760
2775
|
/**
|
|
2761
2776
|
* design/173 §2.3 — durability declaration (see {@link StoreDurability}): whether checkpoints
|
|
2762
2777
|
* this store accepts survive a process restart. Same "declaration, never duck-typing" posture as
|
|
@@ -3166,9 +3181,9 @@ export type CheckpointFaultMode =
|
|
|
3166
3181
|
* {@link testInjectFault} simulates the crash-recovery races a real backend must survive.
|
|
3167
3182
|
*/
|
|
3168
3183
|
export declare class InMemoryCheckpointStore implements CheckpointStore {
|
|
3169
|
-
/**
|
|
3170
|
-
*
|
|
3171
|
-
readonly retention:
|
|
3184
|
+
/** Managed-retention declaration (retention.ts) — the `retention` option (default `"none"`, a third word refused), stated by
|
|
3185
|
+
* the party that runs the sweep. In-memory rows die with the process, which is not a schedule. */
|
|
3186
|
+
readonly retention: RetentionDeclaration;
|
|
3172
3187
|
/** design/173 §2.3 — honest declaration: in-memory rows die with the process. */
|
|
3173
3188
|
readonly durability: "process-local";
|
|
3174
3189
|
/** Honest declaration on the fidelity axis: `put`/`get` are `structuredClone`, so a row keeps the
|
|
@@ -3197,6 +3212,7 @@ export declare class InMemoryCheckpointStore implements CheckpointStore {
|
|
|
3197
3212
|
readonly owner: string | null;
|
|
3198
3213
|
} | undefined>;
|
|
3199
3214
|
holderIsCurrent?: HolderJudge;
|
|
3215
|
+
retention?: RetentionDeclaration;
|
|
3200
3216
|
});
|
|
3201
3217
|
put(token: CheckpointToken, cp: Checkpoint): Promise<void>;
|
|
3202
3218
|
get(token: CheckpointToken): Promise<Checkpoint | null>;
|