@sema-agent/core 7.58.0 → 7.59.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 +776 -0
- package/README.md +6 -4
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +5 -3
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/send-message-tool.js +21 -12
- package/dist/agents/subagent.js +33 -34
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +87 -21
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +62 -5
- package/dist/brain/timeout.js +93 -6
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/allow-entry.d.ts +18 -6
- package/dist/core/allow-entry.js +16 -8
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/auto-compaction.js +1 -1
- package/dist/core/background-agent-store.d.ts +16 -3
- package/dist/core/checkpoint-requirements.d.ts +13 -1
- package/dist/core/checkpoint-requirements.js +3 -1
- package/dist/core/checkpoint-store.d.ts +58 -12
- package/dist/core/checkpoint-store.js +18 -6
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/compliance.js +1 -1
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +98 -8
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/gate-fold.js +1 -1
- package/dist/core/gate-lanes.js +8 -4
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/governance-codes.d.ts +9 -1
- package/dist/core/governance-codes.js +13 -0
- package/dist/core/hooks.d.ts +31 -3
- package/dist/core/hooks.js +5 -6
- package/dist/core/image-admission.d.ts +6 -5
- package/dist/core/image-admission.js +18 -14
- package/dist/core/locked-config.d.ts +5 -2
- package/dist/core/locked-config.js +2 -1
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-failure.d.ts +114 -18
- package/dist/core/mcp-failure.js +63 -5
- package/dist/core/mcp-server-link.d.ts +22 -1
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp.d.ts +12 -8
- package/dist/core/mcp.js +42 -25
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- package/dist/core/memory-engine/sync-client.d.ts +9 -1
- package/dist/core/memory-engine/sync-client.js +31 -8
- package/dist/core/memory-engine/sync.d.ts +5 -0
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.js +2 -1
- package/dist/core/mods/kernel/events.d.ts +2 -1
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/registration.d.ts +4 -0
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/stations.d.ts +31 -10
- package/dist/core/mods/stations.js +44 -10
- package/dist/core/mods/tool-call.js +1 -1
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +6 -0
- package/dist/core/peer-seat.d.ts +70 -8
- package/dist/core/peer-seat.js +143 -11
- package/dist/core/permission-rule-consent.js +10 -4
- package/dist/core/permission-rule-model.d.ts +16 -0
- package/dist/core/permission-rule-model.js +1 -1
- package/dist/core/present-plan-tool.d.ts +11 -3
- package/dist/core/present-plan-tool.js +2 -2
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/rewrite-rejudge.d.ts +1 -0
- package/dist/core/rewrite-rejudge.js +2 -2
- package/dist/core/roles.d.ts +34 -2
- package/dist/core/roles.js +43 -4
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/call-hook-stations.js +2 -2
- package/dist/core/runner/contracts.d.ts +20 -16
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/gate-exit.d.ts +12 -4
- package/dist/core/runner/gate-exit.js +10 -7
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.js +3 -3
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -0
- package/dist/core/runner/prepare-config-doors.js +2 -0
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +4 -0
- package/dist/core/runner/prepare-delegation-surface.js +1 -0
- package/dist/core/runner/prepare-hands-readface.d.ts +4 -0
- package/dist/core/runner/prepare-hands-readface.js +5 -0
- package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
- package/dist/core/runner/prepare-inherited-gate.js +14 -27
- package/dist/core/runner/prepare-memory.js +10 -17
- package/dist/core/runner/prepare-park-ask.d.ts +1 -1
- package/dist/core/runner/prepare-park-ask.js +2 -1
- package/dist/core/runner/prepare-policy-chain.d.ts +3 -3
- package/dist/core/runner/prepare-policy-chain.js +16 -13
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
- package/dist/core/runner/prepare-prompt-inputs.js +8 -19
- package/dist/core/runner/prepare-protocol-tools.js +9 -1
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-task.js +4 -2
- package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -1
- package/dist/core/runner/prepare-wiring-manifest.js +2 -1
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +4 -2
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-brain-sinks.js +2 -0
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +5 -4
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +37 -28
- package/dist/core/runner/run-stop-and-final-verify.js +2 -2
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +77 -70
- package/dist/core/runner/runtask.d.ts +1 -1
- package/dist/core/runner/runtask.js +2 -2
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +10 -0
- package/dist/core/runner/tool-end-body.js +2 -2
- package/dist/core/runner/tool-occurrence.d.ts +1 -1
- package/dist/core/runner/tool-occurrence.js +2 -2
- package/dist/core/runner/turn-attachments.d.ts +26 -22
- package/dist/core/runner/turn-attachments.js +24 -26
- package/dist/core/runner-deps.d.ts +1 -1
- package/dist/core/secret-env.d.ts +32 -2
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +3 -3
- package/dist/core/session-policy-store.d.ts +3 -1
- package/dist/core/session-policy-store.js +13 -9
- package/dist/core/session-store.d.ts +2 -5
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +8 -5
- package/dist/core/skill-grant.js +6 -6
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +32 -8
- package/dist/core/task-notification.js +16 -10
- package/dist/core/task-registry-agent.js +1 -0
- package/dist/core/task-registry-shared.d.ts +5 -0
- package/dist/core/task-spec.d.ts +12 -1
- package/dist/core/terminal-cause.d.ts +10 -0
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-policy.d.ts +16 -0
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +3 -1
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.js +1 -1
- package/dist/core/user-attachment.js +1 -1
- package/dist/core/wiring-manifest.d.ts +6 -3
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/node-execution-env.js +9 -12
- package/dist/engine/harness/agent-harness.d.ts +25 -2
- package/dist/engine/harness/agent-harness.js +41 -12
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +8 -0
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +18 -7
- package/dist/engine/loop/agent-loop.d.ts +8 -0
- package/dist/engine/loop/agent-loop.js +52 -15
- package/dist/engine/loop/types.d.ts +3 -1
- package/dist/engine/session/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/storage-base.js +4 -21
- package/dist/index.d.ts +16 -10
- package/dist/index.js +11 -7
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -0
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.js +739 -489
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/mailbox-store.js +6 -10
- package/dist/tools/fs/fs-bash.d.ts +6 -0
- package/dist/tools/fs/fs-bash.js +6 -3
- package/dist/tools/fs/index.js +6 -2
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +19 -0
- package/dist/tools/fs/read-floor.js +23 -0
- package/dist/tools/fs/shell-read-check.d.ts +1 -1
- package/dist/tools/fs/shell-read-check.js +2 -1
- package/dist/tools/fs/shell-read-judge.d.ts +16 -8
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +4 -0
- package/dist/tools/monitor.js +2 -0
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +87 -1
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { strict as assert } from "node:assert";
|
|
2
2
|
import { STALE_RUNNING_REAP_ATTRIBUTION, } from "../background-agent-store.js";
|
|
3
|
+
import { CLAMP_SEATS, CLAMP_SET } from "../child-clamp-seats.js";
|
|
3
4
|
import { beginContract } from "./contract-harness.js";
|
|
4
5
|
export const BACKGROUND_AGENT_CONTRACT_SCOPE = "tenant-A";
|
|
5
6
|
function record(over = {}) {
|
|
@@ -72,6 +73,32 @@ export async function backgroundAgentStoreContract(mk, runAssertion) {
|
|
|
72
73
|
assert.deepEqual(afterCas.admittedOrgScopes, ["org:acme"]);
|
|
73
74
|
assert.equal(afterCas.admittedOrgWriteScope, null);
|
|
74
75
|
});
|
|
76
|
+
run("the birth floor round-trips verbatim — `{}` stays `{}`, ABSENT stays absent, a CAS carries it", async (make) => {
|
|
77
|
+
const store = make();
|
|
78
|
+
const restricting = Object.fromEntries(CLAMP_SEATS.flatMap((seat) => {
|
|
79
|
+
const row = CLAMP_SET[seat];
|
|
80
|
+
if (row.law !== "restricting")
|
|
81
|
+
return [];
|
|
82
|
+
const field = row.field;
|
|
83
|
+
return [[seat, field === undefined ? row.value : { [field]: row.value }]];
|
|
84
|
+
}));
|
|
85
|
+
const floor = { ...restricting, readDenyPatterns: [".ssh", { pattern: "Secrets", caseSensitive: true }] };
|
|
86
|
+
await store.put(record({ handle: "a1", policyFloor: floor }));
|
|
87
|
+
assert.deepEqual((await held(store, "a1")).policyFloor, floor);
|
|
88
|
+
await store.put(record({ handle: "a2", policyFloor: {} }));
|
|
89
|
+
assert.deepEqual((await held(store, "a2")).policyFloor, {}, "an empty floor is a statement — it must not read back absent");
|
|
90
|
+
await store.put(record({ handle: "a3" }));
|
|
91
|
+
const untouched = await held(store, "a3");
|
|
92
|
+
assert.equal(untouched.policyFloor, undefined, "a row that states no floor must not read back with one");
|
|
93
|
+
for (const handle of ["a1", "a2"]) {
|
|
94
|
+
const before = await held(store, handle);
|
|
95
|
+
assert.equal(await store.update(handle, S, { ...before, status: "completed", settledAt: 2_000 }, { rev: before.rev }), true, `a CAS on a floor-bearing row (${handle}) must land`);
|
|
96
|
+
const after = await held(store, handle);
|
|
97
|
+
assert.equal(after.status, "completed");
|
|
98
|
+
assert.equal(after.rev, before.rev + 1);
|
|
99
|
+
assert.deepEqual(after.policyFloor, before.policyFloor, `a CAS update must carry the floor it did not change (${handle})`);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
75
102
|
run("put refuses a scopeless row (a row with no tenant partition would be world-readable)", async (make) => {
|
|
76
103
|
const store = make();
|
|
77
104
|
await assert.rejects(store.put(record({ scope: "" })), "an empty scope must be refused loudly, not stored");
|
|
@@ -308,7 +308,7 @@ export async function checkpointStoreContract(make, runAssertion, options = {})
|
|
|
308
308
|
const stored = (await store.get(bitless.token)).pendingAction;
|
|
309
309
|
assert.equal("hasBidiControls" in stored, false, "projection backfill must not write back to the row");
|
|
310
310
|
});
|
|
311
|
-
run("the approval object's members: a row's identity + face group and its targets (capabilityId/contractId/shapeDigest/implementationRevision + family/pathTarget/hostTarget/names + targets + targetReads + engineMounted) survive the round-trip verbatim; an absent group stays absent", async () => {
|
|
311
|
+
run("the approval object's members: a row's identity + face group and its targets (capabilityId/contractId/shapeDigest/implementationRevision + family/pathTarget/hostTarget/names + targets + targetReads + engineMounted + declarationDigest) survive the round-trip verbatim; an absent group stays absent", async () => {
|
|
312
312
|
const store = make();
|
|
313
313
|
const carried = createCheckpointFixture({ token: mintCheckpointToken(), sessionId: "id-carried" });
|
|
314
314
|
const group = {
|
|
@@ -322,6 +322,7 @@ export async function checkpointStoreContract(make, runAssertion, options = {})
|
|
|
322
322
|
targets: { protective: "/srv/work/out.txt", declared: "/srv/work/out.txt" },
|
|
323
323
|
targetReads: { ["0123456789abcdef".repeat(4)]: "fedcba9876543210".repeat(4) },
|
|
324
324
|
engineMounted: true,
|
|
325
|
+
declarationDigest: "0123456789abcdef".repeat(4),
|
|
325
326
|
};
|
|
326
327
|
Object.assign(carried.pendingAction, group);
|
|
327
328
|
const bare = createCheckpointFixture({ token: mintCheckpointToken(), sessionId: "id-bare" });
|
|
@@ -332,7 +333,7 @@ export async function checkpointStoreContract(make, runAssertion, options = {})
|
|
|
332
333
|
assert.deepEqual(back[k], v, `the row's ${k} must survive the round-trip verbatim (a whitelisting serializer that drops it makes every resume-edit recheck judge by the catalog's slot for the NAME)`);
|
|
333
334
|
const bareBack = (await store.get(bare.token)).pendingAction;
|
|
334
335
|
for (const k of Object.keys(group))
|
|
335
|
-
assert.equal(k in bareBack, false, `an absent ${k} must stay OMITTED (a
|
|
336
|
+
assert.equal(k in bareBack, false, `an absent ${k} must stay OMITTED (a row without its tool member binds no tool, never a partial one)`);
|
|
336
337
|
const fetchRow = createCheckpointFixture({ token: mintCheckpointToken(), sessionId: "id-host" });
|
|
337
338
|
Object.assign(fetchRow.pendingAction, { ...group, family: "web", pathTarget: undefined, targets: undefined, hostTarget: { param: "url" } });
|
|
338
339
|
delete fetchRow.pendingAction.pathTarget;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { strict as assert } from "node:assert";
|
|
2
|
-
import { MAILBOX_INVALID_PEER_META_CODE, MAILBOX_INVALID_DECISION_MOVE_CODE, MAILBOX_TOMBSTONED_RECIPIENT_CODE } from "../mailbox-store.js";
|
|
2
|
+
import { MAILBOX_DUPLICATE_RECORD_ID_CODE, MAILBOX_INVALID_PEER_META_CODE, MAILBOX_INVALID_DECISION_MOVE_CODE, MAILBOX_INVALID_RECORD_ID_CODE, MAILBOX_TOMBSTONED_RECIPIENT_CODE } from "../mailbox-store.js";
|
|
3
3
|
import { beginContract } from "./contract-harness.js";
|
|
4
4
|
import { PRINCIPAL_INBOX_HANDLE } from "../../agents/cross-session-ref.js";
|
|
5
5
|
import { mintCrossPrincipalRecord } from "../../agents/org-delivery-gate.js";
|
|
@@ -50,6 +50,36 @@ export async function mailboxStoreContract(mk, runAssertion) {
|
|
|
50
50
|
await s.ack(S, "a1", "w3", 1);
|
|
51
51
|
assert.equal(await s.append(S, "a1", msg("m2")), 2);
|
|
52
52
|
});
|
|
53
|
+
run("记录身份:箱持有同 id 时 append = 同记录回原 seq 零写 / 异记录点名拒;坏 id 零副作用拒;id 往返;ack 后 id 自由", async (make) => {
|
|
54
|
+
const s = make();
|
|
55
|
+
const codeOf = async (p) => {
|
|
56
|
+
try {
|
|
57
|
+
await p;
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
return e.code;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const rec = { id: "frame-1", from: "w", content: "m1", sentAt: 1000, hopChain: ["h"], peerMeta: { kind: "peer_message", fromRoot: "root" } };
|
|
65
|
+
assert.equal(await s.append(S, "a1", rec), 1);
|
|
66
|
+
assert.equal(await s.append(S, "a1", { ...rec, sentAt: 5000 }), 1, "同记录再写(写入时刻不同)= 重放,回原 seq");
|
|
67
|
+
assert.equal(await s.peekCount(S, "a1"), 1, "重放零写");
|
|
68
|
+
for (const changed of [{ content: "m1'" }, { from: "x" }, { hopChain: [] }, { peerMeta: undefined }]) {
|
|
69
|
+
assert.equal(await codeOf(s.append(S, "a1", { ...rec, ...changed })), MAILBOX_DUPLICATE_RECORD_ID_CODE, JSON.stringify(changed));
|
|
70
|
+
}
|
|
71
|
+
for (const bad of ["", 7, null]) {
|
|
72
|
+
const raw = JSON.parse(JSON.stringify({ id: bad, content: "c", sentAt: 1 }));
|
|
73
|
+
assert.equal(await codeOf(s.append(S, "a1", raw)), MAILBOX_INVALID_RECORD_ID_CODE, String(bad));
|
|
74
|
+
}
|
|
75
|
+
assert.equal(await s.peekCount(S, "a1"), 1, "被拒的调用零副作用");
|
|
76
|
+
assert.equal(await s.append(S, "a1", msg("plain")), 2, "无 id = 新记录");
|
|
77
|
+
assert.equal(await s.append(S, "a2", rec), 1, "同 id 在别的箱 = 别的记录");
|
|
78
|
+
const lease = await s.claimLease(S, "a1", "w1", 60_000, 10_000);
|
|
79
|
+
assert.deepEqual(lease.messages.map((m) => m.id), ["frame-1", undefined], "id 往返,缺席仍缺席");
|
|
80
|
+
await s.ack(S, "a1", "w1", lease.maxSeq);
|
|
81
|
+
assert.equal(await s.append(S, "a1", rec), 3, "箱只为它持有的记录作答:ack 后同 id 是新记录");
|
|
82
|
+
});
|
|
53
83
|
run("lease 窗内 append:后到消息在下次 claim 时可见(lease 只覆盖 claim 时刻快照)", async (make) => {
|
|
54
84
|
const s = make();
|
|
55
85
|
await s.append(S, "a1", msg("m1"));
|
|
@@ -2,6 +2,7 @@ import { callTargetReadingOf } from "./effective-path-target.js";
|
|
|
2
2
|
import { advertisedWritableRootsSeat, attestationOf, describeThrown, exemptRootsSeat, refuseOutOfContractDecision } from "./tool-policy.js";
|
|
3
3
|
import { ownedClearanceFacts, ruleClearanceOf } from "./ask-origin.js";
|
|
4
4
|
import { skillRowRefusal } from "./skill-grant.js";
|
|
5
|
+
import { NOT_BINDABLE } from "./skill-grant-binding.js";
|
|
5
6
|
import { applyPersistedTightening } from "./persisted-rule-arms.js";
|
|
6
7
|
import { readOrgRuleLane, readPersistedRuleLane } from "./rule-lane-reads.js";
|
|
7
8
|
import { ORG_ADJUDICATION_TIMEOUT_MS, settleOrgVerdictWithin } from "./permission-rule-org.js";
|
|
@@ -79,7 +80,7 @@ function createProbeJudge(layers, kind) {
|
|
|
79
80
|
return async (unstated, budget) => {
|
|
80
81
|
const deadlineAt = budget?.deadlineAt ?? Date.now() + ORG_ADJUDICATION_TIMEOUT_MS;
|
|
81
82
|
const left = () => Math.max(0, Math.min(ORG_ADJUDICATION_TIMEOUT_MS, deadlineAt - Date.now()));
|
|
82
|
-
const probe = { ...unstated, approvalReach: "none" };
|
|
83
|
+
const probe = { ...unstated, approvalReach: "none", ...NOT_BINDABLE };
|
|
83
84
|
const probedArgs = structuredClone(probe.args);
|
|
84
85
|
const stamped = layers.stampCallTarget?.(probe, layers.signal);
|
|
85
86
|
const req = stamped !== undefined ? await stamped : probe;
|
|
@@ -153,6 +153,23 @@ export interface BrainStatus {
|
|
|
153
153
|
* first-byte window before headers, the armed first-token watchdog after — so a consumer can render
|
|
154
154
|
* "45s of 300s". Absent on every other phase. */
|
|
155
155
|
timeoutMs?: number;
|
|
156
|
+
/**
|
|
157
|
+
* On a `waiting_first_token` frame: WHICH wait it is. `response_headers` — the `fetch()` call to the
|
|
158
|
+
* response headers (connecting, sending the request body, and whatever the gateway does before it starts
|
|
159
|
+
* answering; the engine cannot see these apart, they happen inside the transport); `first_token` — the
|
|
160
|
+
* headers to the first content delta (a thinking delta counts). Present on every `waiting_first_token`
|
|
161
|
+
* frame, absent on every other phase.
|
|
162
|
+
*/
|
|
163
|
+
waitSegment?: "response_headers" | "first_token";
|
|
164
|
+
/**
|
|
165
|
+
* On a retry-wait frame (`phase: "reconnecting"`, `errClass: "stall"`) for an attempt this process ended
|
|
166
|
+
* because the HOST WAS SUSPENDED across the wait — the machine slept, or the process was stopped — how long,
|
|
167
|
+
* ms: the sum of the gaps longer than five seconds between the engine's once-a-second readings of the wall
|
|
168
|
+
* clock, from the start of the wait the attempt was in (response headers, first token, or the silence
|
|
169
|
+
* between deltas). The attempt is ended at the first reading where this exceeds half of that wait's window,
|
|
170
|
+
* and is re-sent on a fresh connection. Absent on every other frame — a stall a deadline cut carries none.
|
|
171
|
+
*/
|
|
172
|
+
sleptMs?: number;
|
|
156
173
|
/** 1-based index of the attempt that just failed (the wait precedes attempt `attempt + 1`);
|
|
157
174
|
* same numbering as the `brain.retry` telemetry frame. Absent on frames that are not a retry wait. */
|
|
158
175
|
attempt?: number;
|
|
@@ -597,6 +614,12 @@ export type TaskEvent = ({
|
|
|
597
614
|
* evidence. The persisted `toolResult` row repeats the frame's mark as `details.notExecuted: true` (a live
|
|
598
615
|
* leg's rows, the resumed leg's and the reconcile's appended close) — the engine's key alone: a tool's own
|
|
599
616
|
* value under that name is dropped from the row.
|
|
617
|
+
* It is also set on a call whose gate LET IT GO and which the loop itself then refused before the body started:
|
|
618
|
+
* the arguments the gate cleared failed the loop's own re-validation or re-reading (a rewrite the tool's input
|
|
619
|
+
* check refuses, a form the tool would read as other bytes), or the run was aborted in that gap. Such a frame
|
|
620
|
+
* reads `gate.disposition` allowed, `isError` (with an `errorCode` when the refusal carries one), this mark — and, when the gate replaced the
|
|
621
|
+
* arguments, {@link rewrite} beside them. A call refused before any gate saw it (an unknown tool, arguments the
|
|
622
|
+
* model's own call got wrong) carries no mark: nothing there says whether the loop got that far.
|
|
600
623
|
* ABSENT means only that no such evidence exists — never "it ran": a call closed with its outcome unknown
|
|
601
624
|
* (a reconcile at the next process start, a call interrupted mid-execution) carries no mark, because
|
|
602
625
|
* telling a consumer it did not run could invite a replay of a write that already took effect.
|
|
@@ -613,14 +636,15 @@ export type TaskEvent = ({
|
|
|
613
636
|
/**
|
|
614
637
|
* @contract tool_end.rewrite — the gate let the call go with arguments other than the ones it took: `input` is what it
|
|
615
638
|
* let the call go with, `by` who replaced them. Whether the body then ran is the frame's other members' to say (`isError`
|
|
616
|
-
* with `errorCode`, as for a tool's refusal of those arguments) — this member is never evidence that
|
|
617
|
-
* exactly when the gate's allow exit let the call go,
|
|
618
|
-
* the call go with differ from those it took at its entry (both as the tool reads them —
|
|
619
|
-
* and schema coercion are no rewrite, so the comparison is never against `tool_start.args`,
|
|
620
|
-
* own). Absent on a call refused before it was let go, on a parked or answered-in-place call, and
|
|
621
|
-
* were replaced and then set back; a refusal recorded after the call was let go (the shell read
|
|
622
|
-
*
|
|
623
|
-
* `toolResult` row does not repeat it. A resumed leg's
|
|
639
|
+
* with `errorCode`, as for a tool's refusal of those arguments; {@link notExecuted}) — this member is never evidence that
|
|
640
|
+
* it did. Present exactly when the gate's allow exit let the call go, no extension answered for the call in place of its
|
|
641
|
+
* body, and the arguments it let the call go with differ from those it took at its entry (both as the tool reads them —
|
|
642
|
+
* the loop's argument preparation and schema coercion are no rewrite, so the comparison is never against `tool_start.args`,
|
|
643
|
+
* which stays the model's own). Absent on a call refused before it was let go, on a parked or answered-in-place call, and
|
|
644
|
+
* on one whose arguments were replaced and then set back; a refusal recorded after the call was let go (the shell read
|
|
645
|
+
* admission inside the execution, the loop's own refusal of the arguments the gate cleared) leaves it beside that refusal
|
|
646
|
+
* — the call was let go with them. On the frame only: the persisted `toolResult` row does not repeat it. A resumed leg's
|
|
647
|
+
* frames do not carry it.
|
|
624
648
|
*/
|
|
625
649
|
rewrite?: ToolInputRewrite;
|
|
626
650
|
/** The same member as the paired `tool_start`'s: an extension's own call, and who asked for it. */
|
|
@@ -262,6 +262,7 @@ function malformedFacet(f) {
|
|
|
262
262
|
}
|
|
263
263
|
export function engineFrameRecordOf(payload, priority, box) {
|
|
264
264
|
return {
|
|
265
|
+
id: taskNotificationDedupKey(payload),
|
|
265
266
|
content: encodeEngineFrame(payload, priority),
|
|
266
267
|
sentAt: Date.now(),
|
|
267
268
|
peerMeta: { fromRoot: box.sessionId, kind: "engine_frame" },
|
|
@@ -514,20 +515,24 @@ export function routeOrParkNotification(store, sessionId, payload, priority, onD
|
|
|
514
515
|
if (box !== undefined && durable) {
|
|
515
516
|
store.noteDurablePark(sessionId, dedupKey);
|
|
516
517
|
const record = carrier !== undefined ? sessionBoxRecordOf({ ...payload, agentMessage: carrier }, box) : engineFrameRecordOf(payload, priority, box);
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
518
|
+
const ask = () => {
|
|
519
|
+
try {
|
|
520
|
+
return Promise.resolve(box.mailbox.append(box.scope, box.handle, record));
|
|
521
|
+
}
|
|
522
|
+
catch (e) {
|
|
523
|
+
return Promise.reject(e);
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
const appended = ask().catch((first) => {
|
|
526
527
|
try {
|
|
527
|
-
box.onError?.(
|
|
528
|
+
box.onError?.(first);
|
|
528
529
|
}
|
|
529
530
|
catch {
|
|
530
531
|
}
|
|
532
|
+
return ask();
|
|
533
|
+
});
|
|
534
|
+
const settled = appended.then(() => onDisposition?.("parked_durably"), () => {
|
|
535
|
+
store.forgetDurablePark(sessionId, dedupKey);
|
|
531
536
|
store.pend(sessionId, payload, priority);
|
|
532
537
|
onDisposition?.("parked");
|
|
533
538
|
});
|
|
@@ -544,6 +549,7 @@ export function routeOrParkNotification(store, sessionId, payload, priority, onD
|
|
|
544
549
|
export function sessionBoxRecordOf(payload, box) {
|
|
545
550
|
const peer = payload.peer;
|
|
546
551
|
return {
|
|
552
|
+
id: taskNotificationDedupKey(payload),
|
|
547
553
|
from: payload.agentMessage.from,
|
|
548
554
|
content: payload.agentMessage.body,
|
|
549
555
|
sentAt: Date.now(),
|
|
@@ -426,6 +426,7 @@ export function registerBackgroundAgentLane(core, input) {
|
|
|
426
426
|
...(input.agentType !== undefined ? { agentType: input.agentType } : {}),
|
|
427
427
|
...(input.description !== undefined ? { description: input.description } : {}),
|
|
428
428
|
...(input.model !== undefined ? { model: input.model } : {}),
|
|
429
|
+
...(input.policyFloor !== undefined ? { policyFloor: input.policyFloor } : {}),
|
|
429
430
|
writerId: core.writerId,
|
|
430
431
|
writerEpoch: 1,
|
|
431
432
|
spawnedAt: now,
|
|
@@ -989,6 +989,11 @@ export interface RegisterBackgroundAgentInput extends TaskAccess {
|
|
|
989
989
|
* force at WAKE time; only a spawn that carried a Model OBJECT records that object's id. Same
|
|
990
990
|
* value and same rule as the roster row's `model` column. */
|
|
991
991
|
model?: string;
|
|
992
|
+
/** The tighten-only floor the child is born under — the clamp table's projection of its spawn spec — written onto the
|
|
993
|
+
* durable row ({@link import("./background-agent-store.js").BackgroundAgentRecord.policyFloor}); `{}` when nothing is
|
|
994
|
+
* clamped. A row registered without one states no floor and is never revived. A seeded (revival) registration ignores it:
|
|
995
|
+
* the claimed row keeps the floor it was born with. */
|
|
996
|
+
policyFloor?: import("./child-clamp-seats.js").ClampValues;
|
|
992
997
|
toolUseId?: string;
|
|
993
998
|
abort: AbortController;
|
|
994
999
|
now?: number;
|
package/dist/core/task-spec.d.ts
CHANGED
|
@@ -1076,6 +1076,17 @@ export interface TaskSpec {
|
|
|
1076
1076
|
* Persists on the checkpoint's data half (`CheckpointState.inheritedGate.permissionMode`), re-judged on every leg.
|
|
1077
1077
|
*/
|
|
1078
1078
|
permissionMode?: PermissionMode;
|
|
1079
|
+
/**
|
|
1080
|
+
* In `auto` mode, let no shell allow entry clear a call — the classifier judges it (the reference's
|
|
1081
|
+
* `autoMode.classifyAllShell`). `true` ⇒ while the mode is `auto` (read per call), the whole shell tool, a name that reaches
|
|
1082
|
+
* it and every `Bash(…)` rule whatever it names stand down — in stored rules, a skill's `allowed-tools`, {@link allowedTools}
|
|
1083
|
+
* and the deployment's list alike. Absent / `false` ⇒ only the entries that hand over arbitrary code stand down. Narrows only;
|
|
1084
|
+
* outside `auto`, and for deny / ask rules, a hook's allow, non-shell entries and a read-only command, nothing changes. Which settings planes may set it is the host's
|
|
1085
|
+
* reading (the reference: user, flag and managed settings, never a repository's own); the host sends its allow lists
|
|
1086
|
+
* unchanged beside it. Tighten-only: `tightenTaskSpec` keeps a baseline's `true`, an engine-built child inherits it. A
|
|
1087
|
+
* present non-boolean refuses the run (`config.invalid_argument`).
|
|
1088
|
+
*/
|
|
1089
|
+
classifyAllShell?: boolean;
|
|
1079
1090
|
/** Task-scoped MCP servers, materialized into tools then disposed. */
|
|
1080
1091
|
mcp?: McpServerSpec[];
|
|
1081
1092
|
/** Task-scoped A2A peers (remote agents), whose advertised skills mount as `a2a__<peer>__<skill>`
|
|
@@ -1115,7 +1126,7 @@ export interface TaskSpec {
|
|
|
1115
1126
|
* deployment's {@link import("./runner-deps.js").RunnerDeps.allowedTools}, under the same predicate: deny and ask rules
|
|
1116
1127
|
* still win, and a question no allow rule clears (a mandated, governance, hook or plan question) is still put to a person,
|
|
1117
1128
|
* with the entry disclosed on the card. In `auto` mode an entry that hands over arbitrary code (the whole shell, an
|
|
1118
|
-
* interpreter or launcher prefix) is left to the classifier.
|
|
1129
|
+
* interpreter or launcher prefix) is left to the classifier — every shell entry, under {@link classifyAllShell}.
|
|
1119
1130
|
*
|
|
1120
1131
|
* Lives for this run — the steers it takes in included; a delegated child holds the entries until it ends; a resumed leg
|
|
1121
1132
|
* holds them only when its spec supplies them again (they are not written into a checkpoint). An entry this grammar
|
|
@@ -141,6 +141,16 @@ export type TerminalCause = {
|
|
|
141
141
|
* Absent on pre-identity checkpoints.
|
|
142
142
|
*/
|
|
143
143
|
checkpointId?: string;
|
|
144
|
+
/**
|
|
145
|
+
* The id of the tool call that asked for this plan_review pause — the call that PRESENTED the plan (the
|
|
146
|
+
* `ExitPlanMode` call for the first-party plan tool), so a card can join the pause to that call by id instead of
|
|
147
|
+
* by adjacency. PRESENT only on a `plan_review` pause whose requester carried a call id; ABSENT on every other
|
|
148
|
+
* pause and on a plan_review pause whose requester had none (a row a deployment minted itself, a revive context). It
|
|
149
|
+
* is provenance, not a binding: the pause gates no call, so no `tool_approval` field rides beside it, and the
|
|
150
|
+
* resume never reads it. Echo of the committed row's {@link import("./checkpoint-store.js").PendingAction}
|
|
151
|
+
* `plan_review.requestedByCallId` — one write, at the park mint.
|
|
152
|
+
*/
|
|
153
|
+
requestedByCallId?: string;
|
|
144
154
|
/**
|
|
145
155
|
* HOW the paused task's remote workspace will come back, present whenever the pause captured a
|
|
146
156
|
* remote workspace. The two modes bill and behave very differently:
|
|
@@ -5,17 +5,17 @@ import { failedHandlerClause } from "./mods/stations.js";
|
|
|
5
5
|
const STANDS = Object.freeze({ kind: "stands" });
|
|
6
6
|
function readToolCheck(heard, standing, call, mayClear) {
|
|
7
7
|
const { toolName } = call;
|
|
8
|
-
const refused = (message) => ({ kind: "denied", deny: refusalOf({ action: "deny", message, decisionReason: "hook" }, call.judged) });
|
|
8
|
+
const refused = (message, by) => ({ kind: "denied", deny: refusalOf({ action: "deny", message, decisionReason: "hook" }, call.judged), ...(by !== undefined ? { by } : {}) });
|
|
9
9
|
if (heard.kind === "aborted")
|
|
10
10
|
return refused(`the task was cancelled while a tool.check handler was still checking this call to "${toolName}"; the call was NOT executed (fail-closed)`);
|
|
11
11
|
if (heard.kind === "failed")
|
|
12
|
-
return refused(`a tool.check handler ${failedHandlerClause(heard)} while checking this call to "${toolName}"; the call was NOT executed (fail-closed)
|
|
12
|
+
return refused(`a tool.check handler ${failedHandlerClause(heard)} while checking this call to "${toolName}"; the call was NOT executed (fail-closed)`, heard.registration);
|
|
13
13
|
if (heard.by === undefined && heard.decision === standing.action)
|
|
14
14
|
return STANDS;
|
|
15
15
|
const { who, why } = speakerOf(heard);
|
|
16
16
|
const rewritten = call.rewrite !== undefined ? { updatedInput: call.rewrite } : {};
|
|
17
17
|
if (heard.decision === "deny")
|
|
18
|
-
return refused(`tool "${toolName}" denied by ${who}${why}
|
|
18
|
+
return refused(`tool "${toolName}" denied by ${who}${why}`, heard.by);
|
|
19
19
|
if (heard.decision === "ask") {
|
|
20
20
|
return standing.action === "ask"
|
|
21
21
|
? { kind: "asked", ask: { ...standing, decisionReason: "hook", ...(heard.reason !== undefined ? { message: heard.reason } : {}) }, minted: false }
|
|
@@ -158,6 +158,22 @@ export interface ToolCallRequest {
|
|
|
158
158
|
* Read-only.
|
|
159
159
|
*/
|
|
160
160
|
approvalReach?: import("./wiring-manifest.js").ApprovalReach;
|
|
161
|
+
/**
|
|
162
|
+
* What answering this call grants beyond the call — the binding words every card of the call carries ({@link AskRequest.boundGrantDigest} /
|
|
163
|
+
* {@link AskRequest.boundGrants} / {@link AskRequest.boundGrantAbsence}), minted by the same factory over THIS request's `args`: a call to the
|
|
164
|
+
* engine's `Skill` tool on a leg that loads skills carries the digest and the value it hashes, every other call `not_bindable`. Exactly one
|
|
165
|
+
* arm on every request a Runner hands a policy (the gate's adjudication, the resume belt, the park's stored-shape re-check, the pre-claim
|
|
166
|
+
* edit re-check, the synthetic probes, and every copy a policy fold makes over moved args — the copy carries the answer for ITS args);
|
|
167
|
+
* absent on a bare request (a host driving a policy outside a Runner), which a reader takes as a binding it cannot read. `unreadable` on a
|
|
168
|
+
* request = it binds a grant and what it binds over these args cannot be read here (a copy over moved args whose digest the engine did
|
|
169
|
+
* not mint for this call — `withArgsBinding`). A policy that keeps an answer by tool name reads these words, never the tool name.
|
|
170
|
+
* Read-only metadata: no engine judgment reads them (a parked approval is judged by its row's digest).
|
|
171
|
+
*/
|
|
172
|
+
boundGrantDigest?: string;
|
|
173
|
+
/** The value {@link boundGrantDigest} hashes; same presence (see there). Deployment text — render with contextual escaping. */
|
|
174
|
+
boundGrants?: import("./skill-grant-binding.js").BoundSkillGrants;
|
|
175
|
+
/** Why this request carries no {@link boundGrantDigest} — the closed set `BOUND_GRANT_ABSENCES` (see there). */
|
|
176
|
+
boundGrantAbsence?: import("./skill-grant-binding.js").BoundGrantAbsence;
|
|
161
177
|
/**
|
|
162
178
|
* design/80 D-E-core: read-only per-run budget snapshot so a STATELESS policy can self-limit against
|
|
163
179
|
* state that survives suspend/resume (a fresh in-memory counter would reset every leg — the supervisor
|
|
@@ -316,7 +316,7 @@ export declare function approvalCardMemberOf(call: {
|
|
|
316
316
|
export declare function toolCallFaceOf(roster: ToolRoster | undefined, toolName: string): import("./tool-policy.js").ToolCallFace | undefined;
|
|
317
317
|
/** design/388 B18 — the identity members a park row carries (the tool member of its approval object,
|
|
318
318
|
* `approval-object.ts`), read off a roster snapshot by name; an empty object when the name is not on the snapshot
|
|
319
|
-
* (the row then
|
|
319
|
+
* (the row then carries no tool member, and the claim refuses its approval: no tool is bound by a name alone). */
|
|
320
320
|
export declare function parkedToolIdentity(roster: ToolRoster | undefined, toolName: string): Partial<ToolIdentity>;
|
|
321
321
|
/** design/388 B6 × B18 — the FACE members a park row carries beside its identity: the display family, the declared
|
|
322
322
|
* path target or URL slot, and the names the parked call was judged under. `names` is copied from the face the gate stamped on the
|
|
@@ -325,8 +325,8 @@ export declare function parkedToolIdentity(roster: ToolRoster | undefined, toolN
|
|
|
325
325
|
* beside it are: a fact of the tool, not of the call, and never read off the request's face, which the policy that judges the call
|
|
326
326
|
* can write. A recheck that runs before the leg's roster exists (the pre-CAS resume-edit
|
|
327
327
|
* re-adjudication) rebuilds the call face from the row through {@link parkedCallFaceOf}, so it judges the members the row
|
|
328
|
-
* recorded (identity, family, targets, names, mount site) — not the live face's rule name values or approval card. An empty object
|
|
329
|
-
*
|
|
328
|
+
* recorded (identity, family, targets, names, mount site) — not the live face's rule name values or approval card. An empty object
|
|
329
|
+
* when the name is not on the snapshot (no tool member: the claim refuses the row's approval before any recheck). */
|
|
330
330
|
export declare function parkedToolFace(roster: ToolRoster | undefined, req: {
|
|
331
331
|
readonly toolName: string;
|
|
332
332
|
readonly face?: {
|
|
@@ -337,6 +337,7 @@ export declare function parkedToolFace(roster: ToolRoster | undefined, req: {
|
|
|
337
337
|
pathTarget?: ToolRosterEntry["pathTarget"];
|
|
338
338
|
hostTarget?: ToolHostTarget;
|
|
339
339
|
names?: readonly string[];
|
|
340
|
+
declarationDigest?: string;
|
|
340
341
|
engineMounted?: true;
|
|
341
342
|
};
|
|
342
343
|
/** The live face a resumed park row is re-judged under: minted under the row's recorded spelling (`names[0]`) when that
|
|
@@ -347,8 +348,8 @@ export declare function parkedRowLiveFace(roster: ToolRoster | undefined, row: {
|
|
|
347
348
|
readonly names?: readonly string[];
|
|
348
349
|
}): import("./tool-policy.js").ToolCallFace | undefined;
|
|
349
350
|
/** The call face a park row carries — present iff the row was minted with BOTH its face members and its four
|
|
350
|
-
* identity members (one mint writes all of them; a row missing any
|
|
351
|
-
*
|
|
351
|
+
* identity members (one mint writes all of them; a row missing any yields undefined, never a partial face, and its
|
|
352
|
+
* approval is refused at the claim before any recheck reads it). This is the face every recheck of the row judges under, roster or no roster. */
|
|
352
353
|
export declare function parkedCallFaceOf(pending: {
|
|
353
354
|
family?: ToolFamily;
|
|
354
355
|
pathTarget?: ToolRosterPathTarget;
|
|
@@ -372,6 +373,112 @@ export interface ToolIdentity {
|
|
|
372
373
|
implementationRevision: string;
|
|
373
374
|
}
|
|
374
375
|
export declare function toolIdentityOf(entry: ToolRosterEntry): ToolIdentity;
|
|
376
|
+
/** How a parked approval binds one member of the roster row it was asked under: `identity` (the row member that carries it —
|
|
377
|
+
* a live row that differs is another tool, the row reopens), `face` (carried by value — a face that differs vetoes the call),
|
|
378
|
+
* `declaration` (hashed into the row's `declarationDigest` — a declaration that differs vetoes the call), or `unbound` (why the
|
|
379
|
+
* approval does not cover it). */
|
|
380
|
+
export type RosterApprovalBinding = {
|
|
381
|
+
readonly identity: readonly (keyof ToolIdentity | "engineMounted")[];
|
|
382
|
+
} | "face" | "declaration" | {
|
|
383
|
+
readonly unbound: string;
|
|
384
|
+
};
|
|
385
|
+
/** THE classification of every roster member for the approval of a parked call (#639 / #2345): typed over every key of the row,
|
|
386
|
+
* so a member added to the row is a compile error here until it is classified, and two fences hold the approval object's judge
|
|
387
|
+
* to it (`approval-object.ts`: the identity carriers and the face members it compares are exactly the table's). */
|
|
388
|
+
export declare const ROSTER_APPROVAL_BINDING: Readonly<{
|
|
389
|
+
readonly name: {
|
|
390
|
+
readonly identity: readonly ["capabilityId"];
|
|
391
|
+
};
|
|
392
|
+
readonly aliases: {
|
|
393
|
+
readonly unbound: "the names a call answers to are the call's own (the row's `names`); a resumed belt judges under the live names";
|
|
394
|
+
};
|
|
395
|
+
readonly source: {
|
|
396
|
+
readonly identity: readonly ["capabilityId"];
|
|
397
|
+
};
|
|
398
|
+
readonly origin: {
|
|
399
|
+
readonly unbound: "the peer is the identity's (capabilityId); who declared the server is provenance no decision reads";
|
|
400
|
+
};
|
|
401
|
+
readonly contract: {
|
|
402
|
+
readonly identity: readonly ["contractId", "implementationRevision"];
|
|
403
|
+
};
|
|
404
|
+
readonly shapeDigest: {
|
|
405
|
+
readonly identity: readonly ["shapeDigest"];
|
|
406
|
+
};
|
|
407
|
+
readonly wireSchemaDigest: {
|
|
408
|
+
readonly unbound: "the schema with its description prose for the model; the shape a call is validated against is the identity's (shapeDigest)";
|
|
409
|
+
};
|
|
410
|
+
readonly cardId: {
|
|
411
|
+
readonly unbound: "derived from the source, peer, name and contract, all identity";
|
|
412
|
+
};
|
|
413
|
+
readonly capabilityId: {
|
|
414
|
+
readonly identity: readonly ["capabilityId"];
|
|
415
|
+
};
|
|
416
|
+
readonly inputKeys: {
|
|
417
|
+
readonly unbound: "derived from the schema, whose shape is the identity's (shapeDigest)";
|
|
418
|
+
};
|
|
419
|
+
readonly effect: "declaration";
|
|
420
|
+
readonly effectProvenance: "declaration";
|
|
421
|
+
readonly offload: {
|
|
422
|
+
readonly unbound: "where the engine keeps the call's result (the deployment's own store), not what the call does or reaches";
|
|
423
|
+
};
|
|
424
|
+
readonly offloadThresholdChars: {
|
|
425
|
+
readonly unbound: "where the engine keeps the call's result (the deployment's own store), not what the call does or reaches";
|
|
426
|
+
};
|
|
427
|
+
readonly compactable: {
|
|
428
|
+
readonly unbound: "how the transcript keeps the result, not what the call does";
|
|
429
|
+
};
|
|
430
|
+
readonly budgetExempt: {
|
|
431
|
+
readonly unbound: "how the result counts against the context budget, not what the call does";
|
|
432
|
+
};
|
|
433
|
+
readonly egress: "declaration";
|
|
434
|
+
readonly egressProvenance: {
|
|
435
|
+
readonly unbound: "where the egress value came from; the value is the declaration's (egress), no decision reads its provenance";
|
|
436
|
+
};
|
|
437
|
+
readonly irreversibility: "declaration";
|
|
438
|
+
readonly reversibilityProbe: "declaration";
|
|
439
|
+
readonly contentOrigin: "declaration";
|
|
440
|
+
readonly contentOriginProvenance: {
|
|
441
|
+
readonly unbound: "where the content-origin value came from; the value is the declaration's, no decision reads its provenance";
|
|
442
|
+
};
|
|
443
|
+
readonly family: "face";
|
|
444
|
+
readonly boundaryLegs: "declaration";
|
|
445
|
+
readonly pathTarget: "face";
|
|
446
|
+
readonly hostTarget: "face";
|
|
447
|
+
readonly ruleFace: "declaration";
|
|
448
|
+
readonly approvalPreview: {
|
|
449
|
+
readonly unbound: "whether the card had a preview, shown when it was asked";
|
|
450
|
+
};
|
|
451
|
+
readonly validateInput: {
|
|
452
|
+
readonly unbound: "the live tool validates the bytes it runs, whatever the row says";
|
|
453
|
+
};
|
|
454
|
+
readonly deferred: {
|
|
455
|
+
readonly unbound: "when the schema is loaded into the model's context, not what the call does";
|
|
456
|
+
};
|
|
457
|
+
readonly alwaysLoad: {
|
|
458
|
+
readonly unbound: "when the schema is loaded into the model's context, not what the call does";
|
|
459
|
+
};
|
|
460
|
+
readonly modelGate: "declaration";
|
|
461
|
+
readonly renderHints: {
|
|
462
|
+
readonly unbound: "display, shown when the card was asked";
|
|
463
|
+
};
|
|
464
|
+
readonly mountedBy: {
|
|
465
|
+
readonly identity: readonly ["engineMounted"];
|
|
466
|
+
};
|
|
467
|
+
}>;
|
|
468
|
+
type ApprovalTable = typeof ROSTER_APPROVAL_BINDING;
|
|
469
|
+
/** The roster members the table binds as the tool's FACE. */
|
|
470
|
+
export type RosterFaceMember = {
|
|
471
|
+
[K in keyof ApprovalTable]: ApprovalTable[K] extends "face" ? K : never;
|
|
472
|
+
}[keyof ApprovalTable];
|
|
473
|
+
/** The row members that carry the roster's IDENTITY members. */
|
|
474
|
+
export type RosterIdentityCarrier = {
|
|
475
|
+
[K in keyof ApprovalTable]: ApprovalTable[K] extends {
|
|
476
|
+
readonly identity: readonly (infer I)[];
|
|
477
|
+
} ? I : never;
|
|
478
|
+
}[keyof ApprovalTable];
|
|
479
|
+
/** The declaration a parked approval binds: the digest of the row's `declaration` members ({@link ROSTER_APPROVAL_BINDING}), each as
|
|
480
|
+
* the row carries it — one mint for the park row and for the live row it is compared with. */
|
|
481
|
+
export declare function toolDeclarationDigestOf(entry: ToolRosterEntry): string;
|
|
375
482
|
/** The engine-minted capability identity: a STRUCTURED tuple (never a joined string — `a:b`+`c` and `a`+`b:c`
|
|
376
483
|
* must not collide). Stable across legs for the same source/peer/name/contract. */
|
|
377
484
|
export declare function mintCapabilityId(t: {
|
package/dist/core/tool-roster.js
CHANGED
|
@@ -11,6 +11,7 @@ import { PRESENT_PLAN_TOOL_NAME } from "./present-plan-tool.js";
|
|
|
11
11
|
import { wireOf } from "./tool-name-readings.js";
|
|
12
12
|
import { BOUNDARY_LEGS, rosterBoundaryLegs } from "./cross-boundary-taint.js";
|
|
13
13
|
import { isPlainRecord, receive } from "./mods/kernel/receive.js";
|
|
14
|
+
import { boundInputHashOf } from "./canonical-json.js";
|
|
14
15
|
function lit(values) {
|
|
15
16
|
return Type.Union(values.map((v) => Type.Literal(v)));
|
|
16
17
|
}
|
|
@@ -140,7 +141,7 @@ export function parkedToolFace(roster, req) {
|
|
|
140
141
|
if (e === undefined)
|
|
141
142
|
return {};
|
|
142
143
|
const judged = req.face?.names;
|
|
143
|
-
return { family: e.family, ...(e.pathTarget !== undefined ? { pathTarget: e.pathTarget } : {}), ...(e.hostTarget !== undefined ? { hostTarget: e.hostTarget } : {}), names: judged !== undefined && judged.includes(req.toolName) ? [...judged] : namesResolvingTo(roster, e), ...(engineMountedRow(e) ? { engineMounted: true } : {}) };
|
|
144
|
+
return { family: e.family, ...(e.pathTarget !== undefined ? { pathTarget: e.pathTarget } : {}), ...(e.hostTarget !== undefined ? { hostTarget: e.hostTarget } : {}), names: judged !== undefined && judged.includes(req.toolName) ? [...judged] : namesResolvingTo(roster, e), declarationDigest: toolDeclarationDigestOf(e), ...(engineMountedRow(e) ? { engineMounted: true } : {}) };
|
|
144
145
|
}
|
|
145
146
|
export function parkedRowLiveFace(roster, row) {
|
|
146
147
|
const spelled = row.names?.[0];
|
|
@@ -168,6 +169,46 @@ export function callFaceSeat(face) {
|
|
|
168
169
|
export function toolIdentityOf(entry) {
|
|
169
170
|
return { capabilityId: entry.capabilityId, contractId: entry.contract.contractId, shapeDigest: entry.shapeDigest, implementationRevision: entry.contract.implementationRevision };
|
|
170
171
|
}
|
|
172
|
+
export const ROSTER_APPROVAL_BINDING = Object.freeze({
|
|
173
|
+
name: { identity: ["capabilityId"] },
|
|
174
|
+
aliases: { unbound: "the names a call answers to are the call's own (the row's `names`); a resumed belt judges under the live names" },
|
|
175
|
+
source: { identity: ["capabilityId"] },
|
|
176
|
+
origin: { unbound: "the peer is the identity's (capabilityId); who declared the server is provenance no decision reads" },
|
|
177
|
+
contract: { identity: ["contractId", "implementationRevision"] },
|
|
178
|
+
shapeDigest: { identity: ["shapeDigest"] },
|
|
179
|
+
wireSchemaDigest: { unbound: "the schema with its description prose for the model; the shape a call is validated against is the identity's (shapeDigest)" },
|
|
180
|
+
cardId: { unbound: "derived from the source, peer, name and contract, all identity" },
|
|
181
|
+
capabilityId: { identity: ["capabilityId"] },
|
|
182
|
+
inputKeys: { unbound: "derived from the schema, whose shape is the identity's (shapeDigest)" },
|
|
183
|
+
effect: "declaration",
|
|
184
|
+
effectProvenance: "declaration",
|
|
185
|
+
offload: { unbound: "where the engine keeps the call's result (the deployment's own store), not what the call does or reaches" },
|
|
186
|
+
offloadThresholdChars: { unbound: "where the engine keeps the call's result (the deployment's own store), not what the call does or reaches" },
|
|
187
|
+
compactable: { unbound: "how the transcript keeps the result, not what the call does" },
|
|
188
|
+
budgetExempt: { unbound: "how the result counts against the context budget, not what the call does" },
|
|
189
|
+
egress: "declaration",
|
|
190
|
+
egressProvenance: { unbound: "where the egress value came from; the value is the declaration's (egress), no decision reads its provenance" },
|
|
191
|
+
irreversibility: "declaration",
|
|
192
|
+
reversibilityProbe: "declaration",
|
|
193
|
+
contentOrigin: "declaration",
|
|
194
|
+
contentOriginProvenance: { unbound: "where the content-origin value came from; the value is the declaration's, no decision reads its provenance" },
|
|
195
|
+
family: "face",
|
|
196
|
+
boundaryLegs: "declaration",
|
|
197
|
+
pathTarget: "face",
|
|
198
|
+
hostTarget: "face",
|
|
199
|
+
ruleFace: "declaration",
|
|
200
|
+
approvalPreview: { unbound: "whether the card had a preview, shown when it was asked" },
|
|
201
|
+
validateInput: { unbound: "the live tool validates the bytes it runs, whatever the row says" },
|
|
202
|
+
deferred: { unbound: "when the schema is loaded into the model's context, not what the call does" },
|
|
203
|
+
alwaysLoad: { unbound: "when the schema is loaded into the model's context, not what the call does" },
|
|
204
|
+
modelGate: "declaration",
|
|
205
|
+
renderHints: { unbound: "display, shown when the card was asked" },
|
|
206
|
+
mountedBy: { identity: ["engineMounted"] },
|
|
207
|
+
});
|
|
208
|
+
const DECLARATION_MEMBERS = Object.keys(ROSTER_APPROVAL_BINDING).filter((k) => ROSTER_APPROVAL_BINDING[k] === "declaration");
|
|
209
|
+
export function toolDeclarationDigestOf(entry) {
|
|
210
|
+
return boundInputHashOf(Object.fromEntries(DECLARATION_MEMBERS.flatMap((k) => (entry[k] === undefined ? [] : [[k, entry[k]]]))));
|
|
211
|
+
}
|
|
171
212
|
function canonical(node) {
|
|
172
213
|
if (Array.isArray(node))
|
|
173
214
|
return `[${node.map(canonical).join(",")}]`;
|
package/dist/core/tool-spec.d.ts
CHANGED
|
@@ -1392,7 +1392,9 @@ export interface ToolExecuteContext {
|
|
|
1392
1392
|
* only when the deployment can actually pause (a `checkpointStore` is wired); otherwise the request is a silent
|
|
1393
1393
|
* no-op (read-only/headless degrade). The first-party `present_plan` tool (CC `ExitPlanMode` parity) is a thin
|
|
1394
1394
|
* caller of this; any tool may use it to gate a high-blast step on human review. Idempotent within a batch (the
|
|
1395
|
-
* first request wins; the suspend fires once at the boundary). The Runner fills it; not a tool arg.
|
|
1395
|
+
* first request wins; the suspend fires once at the boundary). The Runner fills it; not a tool arg. The Runner
|
|
1396
|
+
* binds the id of the calling tool call to the request (a tool cannot name another call): the parked `plan_review`
|
|
1397
|
+
* row and the paused cause carry it as `requestedByCallId` — which call asked for the pause.
|
|
1396
1398
|
*/
|
|
1397
1399
|
requestReview?: (opts?: {
|
|
1398
1400
|
reason?: string;
|
package/dist/core/types.d.ts
CHANGED
|
@@ -30,6 +30,6 @@ export { AUTO_MODE_DENY_SOURCES, isAutoModeDenySource } from "./runtime-caps.js"
|
|
|
30
30
|
export type { BackgroundChildEvent, BackgroundChildRow, DelegationLifecycleEvent } from "./delegation-frames.js";
|
|
31
31
|
export { __resetMalformedDelegationSeatAnnouncement, backgroundChildTerminal, deliverDelegationLifecycle, emitsChildRowFrames, taskStartedFrame } from "./delegation-frames.js";
|
|
32
32
|
export type { ProjectMemoryLoad, ResumePreflightInfo, ResumePreflightVerdict, RunnerDeps } from "./runner-deps.js";
|
|
33
|
-
export type { ApprovalCarryRefusal, EngineNotice, OwedUserInputAccount, UserInputUndrainedCause } from "./engine-notice.js";
|
|
34
|
-
export { __resetMalformedNoticeSeatAnnouncement, deliverEngineNotice, owedUserInputCounts, parentLegIds, settleOwedUserInput, undrainedUserInputNotices, USER_INPUT_UNDRAINED_CAUSES, USER_INPUT_UNDRAINED_FAMILIES } from "./engine-notice.js";
|
|
33
|
+
export type { ApprovalCarryRefusal, EngineNotice, HeldUserInputs, OwedInputIds, OwedUserInputAccount, UserInputUndrainedCause } from "./engine-notice.js";
|
|
34
|
+
export { __resetMalformedNoticeSeatAnnouncement, deliverEngineNotice, owedUserInputCounts, owedUserInputIds, parentLegIds, parkedInputIdsOf, settleOwedUserInput, undrainedUserInputNotices, USER_INPUT_UNDRAINED_CAUSES, USER_INPUT_UNDRAINED_FAMILIES } from "./engine-notice.js";
|
|
35
35
|
export type { AgentTool, Model, StreamFn, ThinkingLevel, ToolInputValidationContext, ToolInputVerdict };
|
package/dist/core/types.js
CHANGED
|
@@ -2,4 +2,4 @@ export { MODEL_ROLES } from "./model-seat.js";
|
|
|
2
2
|
export { DECLARATION_PATH_RULES, NO_DECLARATION_PATH_RULES, dataKind, declarationFaultOf, declarerWord, perToolEmptyName, perToolEntryRefusal, quotedName, readMcpToolAxes, readToolAxes, receiveDeclaration, receivePerToolDeclaration, toolAxesRefusal } from "./mcp-server-spec.js";
|
|
3
3
|
export { AUTO_MODE_DENY_SOURCES, isAutoModeDenySource } from "./runtime-caps.js";
|
|
4
4
|
export { __resetMalformedDelegationSeatAnnouncement, backgroundChildTerminal, deliverDelegationLifecycle, emitsChildRowFrames, taskStartedFrame } from "./delegation-frames.js";
|
|
5
|
-
export { __resetMalformedNoticeSeatAnnouncement, deliverEngineNotice, owedUserInputCounts, parentLegIds, settleOwedUserInput, undrainedUserInputNotices, USER_INPUT_UNDRAINED_CAUSES, USER_INPUT_UNDRAINED_FAMILIES } from "./engine-notice.js";
|
|
5
|
+
export { __resetMalformedNoticeSeatAnnouncement, deliverEngineNotice, owedUserInputCounts, owedUserInputIds, parentLegIds, parkedInputIdsOf, settleOwedUserInput, undrainedUserInputNotices, USER_INPUT_UNDRAINED_CAUSES, USER_INPUT_UNDRAINED_FAMILIES } from "./engine-notice.js";
|