@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
|
@@ -86,6 +86,7 @@ export const CLAMP_SET = Object.freeze({
|
|
|
86
86
|
complianceAdditionalDenies: Object.freeze({ law: "addOnly", identity: complianceIdentity, entry: complianceCapabilityProblem, script: COMPLIANCE_SCRIPT_LAW, deploymentLayer: "compliancePostureResolver", carrier: "clamp" }),
|
|
87
87
|
oneShot: Object.freeze({ law: "restricting", value: true, script: true, carrier: "specSeat" }),
|
|
88
88
|
memoryPersistenceCapable: Object.freeze({ law: "restricting", value: false, script: true, carrier: "specSeat" }),
|
|
89
|
+
classifyAllShell: Object.freeze({ law: "restricting", value: true, script: true, carrier: "specSeat" }),
|
|
89
90
|
fileHistory: Object.freeze({ law: "restricting", value: "disabled", script: false, carrier: "specSeat" }),
|
|
90
91
|
projectMemory: Object.freeze({ law: "restricting", value: "disabled", script: false, carrier: "specSeat" }),
|
|
91
92
|
promptForm: Object.freeze({ law: "restricting", value: "minimal", script: false, carrier: "specSeat" }),
|
|
@@ -239,6 +240,57 @@ export function assertClampRecord(record, owner, carrier, extra = []) {
|
|
|
239
240
|
throw clampRecordError(`${owner} names ${unknown.map((k) => JSON.stringify(k)).join(", ")}, which the clamp table does not carry there — the legal seats are ${legal.join(", ")}. Refused rather than ignored: a seat nobody reads would read to the caller as wired.`);
|
|
240
241
|
}
|
|
241
242
|
}
|
|
243
|
+
export function readClampFloor(floor) {
|
|
244
|
+
if (floor === undefined)
|
|
245
|
+
return { ok: false, why: "the record states no policy floor (written before records carried one, or by a store that does not keep it)" };
|
|
246
|
+
let copy;
|
|
247
|
+
try {
|
|
248
|
+
copy = structuredClone(floor);
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
return { ok: false, why: "the record's policy floor is not plain data" };
|
|
252
|
+
}
|
|
253
|
+
const proto = typeof copy === "object" && copy !== null ? Object.getPrototypeOf(copy) : undefined;
|
|
254
|
+
if (copy === null || typeof copy !== "object" || Array.isArray(copy) || (proto !== Object.prototype && proto !== null)) {
|
|
255
|
+
return { ok: false, why: `the record's policy floor is not a record of clamp seats (got ${copy === null ? "null" : Array.isArray(copy) ? "an array" : typeof copy})` };
|
|
256
|
+
}
|
|
257
|
+
const stated = copy;
|
|
258
|
+
for (const [key, v] of Object.entries(stated)) {
|
|
259
|
+
if (v === undefined)
|
|
260
|
+
continue;
|
|
261
|
+
const row = CLAMP_SEATS.includes(key) ? CLAMP_SET[key] : undefined;
|
|
262
|
+
if (row === undefined)
|
|
263
|
+
return { ok: false, why: `the record's policy floor names ${describeStated(key)}, which this build's clamp table does not have` };
|
|
264
|
+
const seat = key;
|
|
265
|
+
if (row.law === "restricting") {
|
|
266
|
+
const field = fieldOf(row);
|
|
267
|
+
const exact = field === undefined ? v === row.value : typeof v === "object" && v !== null && !Array.isArray(v) && Object.keys(v).length === 1 && cellOf(row, v) === row.value;
|
|
268
|
+
if (!exact)
|
|
269
|
+
return { ok: false, why: `the record's policy floor states ${clampCellPath(seat)} as ${describeStated(v)}, which is not its restricting value ${describeStated(row.value)}` };
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (!Array.isArray(v) || v.length === 0)
|
|
273
|
+
return { ok: false, why: `the record's policy floor states ${seat} as ${Array.isArray(v) ? "an empty list" : describeStated(v)} — a floor's add-only seat is a non-empty list` };
|
|
274
|
+
const entries = v;
|
|
275
|
+
for (const e of entries) {
|
|
276
|
+
const problem = row.entry(e, `policyFloor.${seat}`);
|
|
277
|
+
if (problem !== undefined)
|
|
278
|
+
return { ok: false, why: problem };
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return { ok: true, floor: clampSeatsOf(stated) };
|
|
282
|
+
}
|
|
283
|
+
function describeStated(v) {
|
|
284
|
+
try {
|
|
285
|
+
const s = JSON.stringify(v);
|
|
286
|
+
if (s === undefined)
|
|
287
|
+
return typeof v;
|
|
288
|
+
return s.length > 80 ? `${s.slice(0, 77)}...` : s;
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
return typeof v;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
242
294
|
export function clampValuesOf(...records) {
|
|
243
295
|
return clampSeatsOf(foldClampSources(...records));
|
|
244
296
|
}
|
|
@@ -263,8 +315,11 @@ export const ENGINE_CHILD_SPEC_CONSTRUCTORS = Object.freeze([
|
|
|
263
315
|
"src/agents/verify.ts#fixLegSpec",
|
|
264
316
|
"src/orchestration/workflow-primitives.ts#workflowChildClamps",
|
|
265
317
|
]);
|
|
318
|
+
export function clampsReachNoPerson(clamps) {
|
|
319
|
+
return clamps.interactiveTools === false || clamps.approvalReach === "none";
|
|
320
|
+
}
|
|
266
321
|
export function postureUnderClamps(posture, clamps) {
|
|
267
|
-
return posture === "interactive" && (clamps
|
|
322
|
+
return posture === "interactive" && clampsReachNoPerson(clamps) ? "headless" : posture;
|
|
268
323
|
}
|
|
269
324
|
export function engineHeadlessLegSeats() {
|
|
270
325
|
return { interactiveTools: false, approvalReach: "none", interactionPosture: "headless" };
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
export type ComplianceProfile = "hipaa" | "zdr";
|
|
3
3
|
/** Closed capability set the ENGINE can veto end-to-end (see the module header for the entry-point
|
|
4
4
|
* map — a capability is admitted here only with its full interception story). */
|
|
5
|
-
export type ComplianceCapability = "mcp_servers" | "workflows" | "web_fetch" | "org_memory_mount";
|
|
5
|
+
export type ComplianceCapability = "mcp_servers" | "workflows" | "web_fetch" | "org_memory_mount" | "a2a_peers";
|
|
6
6
|
/** Every member of {@link ComplianceCapability} — the fail-closed "deny everything managed" set used
|
|
7
7
|
* when the posture resolver itself fails. `satisfies` keeps it in lockstep with the union. */
|
|
8
|
-
export declare const COMPLIANCE_CAPABILITIES: readonly ["mcp_servers", "workflows", "web_fetch", "org_memory_mount"];
|
|
8
|
+
export declare const COMPLIANCE_CAPABILITIES: readonly ["mcp_servers", "workflows", "web_fetch", "org_memory_mount", "a2a_peers"];
|
|
9
9
|
/**
|
|
10
10
|
* A principal's resolved compliance posture, supplied by the trusted deployment resolver. The
|
|
11
11
|
* effective deny set is `BUILTIN_COMPLIANCE_DENIES[profile] ∪ additionalDenies` — supply can only
|
package/dist/core/compliance.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describeRejectedValue } from "./tool-search-setting.js";
|
|
2
|
-
export const COMPLIANCE_CAPABILITIES = Object.freeze(["mcp_servers", "workflows", "web_fetch", "org_memory_mount"]);
|
|
2
|
+
export const COMPLIANCE_CAPABILITIES = Object.freeze(["mcp_servers", "workflows", "web_fetch", "org_memory_mount", "a2a_peers"]);
|
|
3
3
|
export const BUILTIN_COMPLIANCE_DENIES = {
|
|
4
4
|
hipaa: ["web_fetch", "org_memory_mount"],
|
|
5
5
|
zdr: ["org_memory_mount"],
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
import { canonicalizeTarget, type PathFamily, type PathIdentity, type Win32NamespaceRefusal } from "../tools/fs/safety.js";
|
|
49
49
|
import type { TargetViews } from "./path-guard-rows.js";
|
|
50
50
|
import type { ExecutionEnv } from "../internal/harness-types.js";
|
|
51
|
-
import type { ToolCallPathTarget } from "./tool-face.js";
|
|
51
|
+
import type { ToolCallPathTarget, ToolPathAbsence, ToolPathBase } from "./tool-face.js";
|
|
52
52
|
import { type ToolCallLike } from "./tool-registry.js";
|
|
53
53
|
/** The bases of ONE CALL a target resolves against: the task root, and the live tracked working directory
|
|
54
54
|
* (absent when no tracker moved or the caller keeps none). Facts of the call, never of the tool. The
|
|
@@ -64,6 +64,12 @@ export interface ToolPathBases {
|
|
|
64
64
|
* slot names nothing this reader can locate.
|
|
65
65
|
*/
|
|
66
66
|
export declare function pathTargetBaseOf(pt: Pick<ToolCallPathTarget, "base"> | undefined, bases: ToolPathBases): string | undefined;
|
|
67
|
+
/** A declared slot's resolution with its silences read: the base its relative spellings resolve against and what an empty slot
|
|
68
|
+
* reads — `cwd` and `none` for a declaration that states neither. The ONE place a declaration's silence becomes a resolution. */
|
|
69
|
+
export declare function pathTargetResolutionOf(pt: Pick<ToolCallPathTarget, "base" | "absent">): {
|
|
70
|
+
readonly base: ToolPathBase;
|
|
71
|
+
readonly absent: ToolPathAbsence;
|
|
72
|
+
};
|
|
67
73
|
/**
|
|
68
74
|
* design/116 批④ #8 — decompose an ABSOLUTE glob pattern into a base
|
|
69
75
|
* directory + relative pattern: cut at the last separator before the first glob metachar (`* ? [ {`); a
|
|
@@ -271,7 +277,7 @@ export declare function carryArgsReadFrom(original: unknown, copy: unknown): voi
|
|
|
271
277
|
* face). Every seat that rewrites a request's arguments and hands it on (a composition's rewrite cascade, a re-judgment of
|
|
272
278
|
* the final or an edited form) goes through here, so the next layer never judges a request its reading does not describe
|
|
273
279
|
* nor arguments the tool would run differently. `signal` is the CURRENT call's: a reading never carries one call's
|
|
274
|
-
* cancellation into another's.
|
|
280
|
+
* cancellation into another's. The request's grant-binding words follow the new args the same way ({@link withArgsBinding}).
|
|
275
281
|
*/
|
|
276
282
|
export declare function withArgsReading<R extends {
|
|
277
283
|
readonly args: unknown;
|
|
@@ -4,8 +4,12 @@ import { symlinkChainHops } from "./path-identity.js";
|
|
|
4
4
|
import { DEFAULT_GATE_AWAIT_TIMEOUT_MS, withGateTimeout } from "./gate-bounded-await.js";
|
|
5
5
|
import { thrownText } from "./thrown-value.js";
|
|
6
6
|
import { canonicalize } from "./canonical-json.js";
|
|
7
|
+
import { withArgsBinding } from "./skill-grant-binding.js";
|
|
7
8
|
export function pathTargetBaseOf(pt, bases) {
|
|
8
|
-
return (pt
|
|
9
|
+
return pathTargetResolutionOf(pt ?? {}).base === "root" ? bases.root : (bases.cwd ?? bases.root);
|
|
10
|
+
}
|
|
11
|
+
export function pathTargetResolutionOf(pt) {
|
|
12
|
+
return { base: pt.base ?? "cwd", absent: pt.absent ?? "none" };
|
|
9
13
|
}
|
|
10
14
|
export function splitAbsoluteGlobPattern(pattern, tree) {
|
|
11
15
|
const family = tree ?? familyFor("own", pattern);
|
|
@@ -44,7 +48,7 @@ export function effectivePathSpellingOf(call, pt, bases) {
|
|
|
44
48
|
const spelled = pathTargetValue(call.args, pt);
|
|
45
49
|
if (spelled !== undefined)
|
|
46
50
|
return { spelled, base: declaredBase };
|
|
47
|
-
if ((pt.absent
|
|
51
|
+
if (pathTargetResolutionOf(pt).absent === "none")
|
|
48
52
|
return undefined;
|
|
49
53
|
if (pt.patternParam !== undefined) {
|
|
50
54
|
const pattern = pathTargetValue(call.args, { param: pt.patternParam });
|
|
@@ -175,7 +179,8 @@ export async function withArgsReading(req, args, signal) {
|
|
|
175
179
|
const read = argsAsTheToolReads(req, args);
|
|
176
180
|
const reading = callTargetReadingOf(req);
|
|
177
181
|
const reread = reading === undefined ? undefined : REREAD.get(reading);
|
|
178
|
-
|
|
182
|
+
const moved = withArgsBinding(req, read);
|
|
183
|
+
return reread === undefined ? moved : { ...moved, targetReading: await reread(read, signal) };
|
|
179
184
|
}
|
|
180
185
|
function viewFrom(v) {
|
|
181
186
|
if (v.lexical === undefined)
|
|
@@ -167,6 +167,17 @@ export interface EngineNotice {
|
|
|
167
167
|
* DOWN, which only the operator can act on. Dedup unit: once per ATTEMPT — never folded per run,
|
|
168
168
|
* because two attempts on one server are two different answers and folding the second would hide
|
|
169
169
|
* the one that says the server is still down.
|
|
170
|
+
* - `"mcp.authorization_required"` — an MCP server the user must authorize before it serves them:
|
|
171
|
+
* the leg's dial failed `unauthorized`, or a request was refused so and that refusal is its answer
|
|
172
|
+
* (a repeat-safe call refused 401 and sent once more on a renewed credential announces only if that
|
|
173
|
+
* send is refused too). The SAME fact as the failure record's `authorization`
|
|
174
|
+
* (`McpAuthorization`). `detail: { server, reason, authorizeUrl?, principal?, sessionId, runId }` —
|
|
175
|
+
* `reason` is `rejected` (401) / `scope` (403 insufficient_scope) / `none` (the seat holds no
|
|
176
|
+
* authorization for this user), `authorizeUrl` the seat's own (never the endpoint's
|
|
177
|
+
* `resource_metadata`, which rides the record only). `"user"` audience: nobody but the user can
|
|
178
|
+
* authorize; `sessionId` REQUIRED at the mint. Dedup unit: once per (leg, server) — a resume is a new
|
|
179
|
+
* leg and may announce again. A deployment that waits for the authorization keys on this notice; the
|
|
180
|
+
* leg itself does not park on it.
|
|
170
181
|
* - `"mcp.injection_dropped"` (L-167) — an entry of the user's own request-lane MCP injection
|
|
171
182
|
* was NOT mounted for the leg. The HOST owns the drop sites and supplies the facts; CORE composes
|
|
172
183
|
* the notice ({@link import("./mcp-injection-drop.js").mcpInjectionDroppedNotice}, the one mint).
|
|
@@ -278,7 +289,8 @@ export interface EngineNotice {
|
|
|
278
289
|
* - `"route.credential_origin_mismatch"` (key↔URL pairing, `src/brain/route-adjudicator.ts`; announced by
|
|
279
290
|
* `src/core/runner/credential-origin-seat.ts`) — a request was REFUSED, nothing sent, because the per-model
|
|
280
291
|
* credential it would carry is bound to another origin: the law binds a per-model credential to the origin
|
|
281
|
-
* (scheme + host + port) of the first request sent carrying it
|
|
292
|
+
* (scheme + host + port) of the first request sent carrying it (or the one the host rebinds it to,
|
|
293
|
+
* `route.credential_rebound`), so an entry whose `baseUrl` moved to another
|
|
282
294
|
* host while its credential stayed the same is refused (same-origin path moves are not). The request's own
|
|
283
295
|
* failure carries the same code (`[invalid_request] route.credential_origin_mismatch: …`). Minted only for a
|
|
284
296
|
* request the gate refused (`routeRefusalError`): a pre-flight or read-face judgment reports nothing, and a derived
|
|
@@ -286,6 +298,14 @@ export interface EngineNotice {
|
|
|
286
298
|
* failed hears why; the operator hears it through the sink. `detail: { modelId, boundOrigin, requestOrigin,
|
|
287
299
|
* sessionId, runId }` — the two origins in display spelling, never a credential or a digest of one. Once per
|
|
288
300
|
* run per (modelId, boundOrigin, requestOrigin).
|
|
301
|
+
* - `"route.credential_rebound"` (`rebindCredentialOrigin`, `src/brain/route-adjudicator.ts`) — the HOST moved a
|
|
302
|
+
* per-model credential's binding, explicitly: every secret the credential carries is now bound to the origin the
|
|
303
|
+
* named entry sends to, and a request carrying it anywhere else (another entry still on the old host included) is
|
|
304
|
+
* refused. Minted by the verb's own call, outside any run, through the `onNotice` the host hands it (else the
|
|
305
|
+
* throat's `console.warn` arm); once per call that changed the table, never for one that found every secret already
|
|
306
|
+
* there. Audience `operator`. `detail: { modelId, origin, previous, occurrenceId }` — `origin` and each `previous`
|
|
307
|
+
* origin in display spelling, never a credential or a digest of one; `occurrenceId` is minted at delivery (the
|
|
308
|
+
* call has no run and no session to key it by, as `config.models_swapped`).
|
|
289
309
|
* - `"route.response_model_mismatch"` — the provider answered a turn naming a model that is NOT the id
|
|
290
310
|
* the request was sent with (an alias, a pool or a gateway-side substitution looks exactly like this),
|
|
291
311
|
* so it is advisory, never a refusal: the engine keeps asking for the catalog's id and reports the
|
|
@@ -304,7 +324,8 @@ export interface EngineNotice {
|
|
|
304
324
|
* or `"duplicate"` (a renamed later call); `rawLength` present for the two shape reasons only; never the raw
|
|
305
325
|
* bytes. Absent ⇒ no call of the run was folded.
|
|
306
326
|
* - `"route.finish_reason_unknown"` (#1457) — the provider ended a response with a stream-end word (an
|
|
307
|
-
* OpenAI-family `finish_reason`) the brain does not read
|
|
327
|
+
* OpenAI-family `finish_reason`) the brain does not read, or (#1529, either wire) with an ending seat holding no word
|
|
328
|
+
* at all (a number, `true`, an object — `?`). The turn is kept — its text and the stop its content
|
|
308
329
|
* implies — and the word rides `AssistantMessage.finishReasonUnknown` (and, when the run completes on that turn,
|
|
309
330
|
* `terminal.detail`); the notice is what keeps the keep from being a silent clean stop. ONCE PER LEG PER WORD.
|
|
310
331
|
* Audience `user` (the person reading the answer judges whether it is whole); `detail: { finishReason,
|
|
@@ -332,6 +353,15 @@ export interface EngineNotice {
|
|
|
332
353
|
* drop arm (`TaskResult.effectiveReasoning.dropped`) is that fact's face. ONCE PER SESSION PER (model, capability)
|
|
333
354
|
* (the session's announced record); one report per request also becomes the operator trace `vision.placeholder`.
|
|
334
355
|
* Audience `user`; `detail: { model, capability: "image", status: "declared_off", sessionId, runId }`.
|
|
356
|
+
* - `"model.role_defaulted"` (#2571; `src/core/runner/role-seat-defaulted.ts`) — a role seat of the merged deployment and task
|
|
357
|
+
* maps names a model word the catalog does not hold, so the roles family reads it as an UNSET seat (the tier default and the
|
|
358
|
+
* fallback chain follow; a `subagent` seat's children run on the parent's model) and the run goes on, where it used to be
|
|
359
|
+
* refused at every prepare. Never minted for `default` (the main model's seat: an unknown word there is still refused,
|
|
360
|
+
* `config.unknown_role` / `unknown_model_ref`) nor `classifier` (its own stand-in and its own line, `classifier.role_defaulted`).
|
|
361
|
+
* Named once per SESSION per (seat, word), whether or not a read of this leg reaches the seat; root legs only. Audience
|
|
362
|
+
* `operator`; `detail: { seat, role, model, reason: "unknown_model_ref", fallback, sessionId, runId? }` — `seat` the
|
|
363
|
+
* `roles.<role>` the refusal would have named, `model` the word written there (bounded at 80), `fallback` the roles the seat's
|
|
364
|
+
* chain would reach, nearest first.
|
|
335
365
|
* - `"context.tool_turn_repaired"` (#1224) — a provider request was built from a transcript that breaks the
|
|
336
366
|
* tool-turn law, and the request view restored it (`engine/llm/tool-turns.ts`; the transcript is never
|
|
337
367
|
* rewritten): a block after an assistant's tool calls moved ahead of them (`trailing_text`), a result recorded
|
|
@@ -345,6 +375,13 @@ export interface EngineNotice {
|
|
|
345
375
|
* the run proceeds on the repaired request. Audience `operator`; `detail: { repairs: [{ form, toolCallIds }],
|
|
346
376
|
* sessionId, runId }`. ONCE PER RUN PER (form, calls) — the same broken turn is repaired on every request of
|
|
347
377
|
* the run and announced on the first. Absent ⇒ every request of the run already had the structure.
|
|
378
|
+
* - `"context.image_removed"` (#2874) — the provider refused a request because an image in it could not be processed
|
|
379
|
+
* (the failed turn's `errorKind: "image_unprocessable"`), so the request view removed the images of the newest
|
|
380
|
+
* message still carrying any, each replaced by `[image N removed: rejected by provider: image_unprocessable]`
|
|
381
|
+
* (`engine/llm/rejected-images.ts`); the turn was re-sent without them and every later request of the session
|
|
382
|
+
* reads the same removal. The transcript keeps the images. Audience `user`; `detail: { images, sessionId, runId }`
|
|
383
|
+
* — `images` how many were removed from that message. ONCE PER RUN PER REFUSAL; a refusal recorded before the run
|
|
384
|
+
* began is not announced again.
|
|
348
385
|
* - `"task.tool_turn_incomplete"` (#1230) — the person's line for a tool turn the model was handed incomplete, beside
|
|
349
386
|
* the note the model itself reads. `detail.cause` (closed `TOOL_TURN_INCOMPLETE_CAUSES`): `truncated` — calls whose
|
|
350
387
|
* arguments were cut before they parsed, dropped (they did not run); `unnamed` — calls that arrived with no tool
|
|
@@ -527,7 +564,12 @@ export interface EngineNotice {
|
|
|
527
564
|
* (a returned row does not carry them: its next decide is fresh); when the pause tried to carry them forward and the parked-steer
|
|
528
565
|
* carrier refused, the row also names the store's refusal as `detail.carry` (`steering.invalid_content` | `steering.queue_full`) and
|
|
529
566
|
* its sentence says so (`cause` stays `leg_end`: the leg ended with them owed — the closed set has no carrier words);
|
|
530
|
-
* `detail: { <countKey>, cause, kind?, carry?, taskId?, sessionId?, runId? }` (
|
|
567
|
+
* `detail: { <countKey>, cause, inputIds?, kind?, carry?, taskId?, sessionId?, runId? }` (`inputIds` — on the `leg_end` rows of the two
|
|
568
|
+
* families: the id of EACH input the count stands for, in the order the run would have served them (queue order: an
|
|
569
|
+
* `immediate`-tier input leads the ones accepted before it), the same key value the live `human_input` frame
|
|
570
|
+
* carries as `inputId` and a parked entry as `inputId`; present only when the ids name exactly the counted inputs — a lane
|
|
571
|
+
* where any counted input carried none reports its count alone, never a partial list — and never on an `approval_feedback` row,
|
|
572
|
+
* whose words are no input; the `crashed` arm is the serving layer's and does not carry it) (the `code` and the `countKey` of each family are the
|
|
531
573
|
* table {@link USER_INPUT_UNDRAINED_FAMILIES}, keyed by the lane the input was queued on — `injectionLaneOf` — and the
|
|
532
574
|
* minter writes exactly those; `cause` on both rows, closed `USER_INPUT_UNDRAINED_CAUSES`: `"leg_end"` — this engine's arm, the
|
|
533
575
|
* leg ended with it still owed; `"crashed"` — minted by the SERVING LAYER, not this engine, before the
|
|
@@ -1051,21 +1093,23 @@ export declare function deliverEngineNotice(onNotice: ((notice: EngineNotice) =>
|
|
|
1051
1093
|
* ({@link settleOwedUserInput}). */
|
|
1052
1094
|
export interface OwedUserInputAccount {
|
|
1053
1095
|
/** The harness's at-agent_end snapshot, held because the tail still had something to say about it. */
|
|
1054
|
-
readonly held:
|
|
1055
|
-
|
|
1056
|
-
followUp: number;
|
|
1057
|
-
} | undefined;
|
|
1058
|
-
/** What a durable park's migration carried onto the new checkpoint, by family. */
|
|
1096
|
+
readonly held: HeldUserInputs | undefined;
|
|
1097
|
+
/** What a durable park's migration carried onto the new checkpoint, by family (`inputIds`: which inputs they were). */
|
|
1059
1098
|
readonly migrated: {
|
|
1060
1099
|
steer: number;
|
|
1061
1100
|
followUp: number;
|
|
1101
|
+
inputIds?: OwedInputIds;
|
|
1062
1102
|
};
|
|
1063
1103
|
/** The resumed leg's undelivered continuation frames, and how many of them the migration carried. */
|
|
1064
1104
|
readonly continuation: {
|
|
1105
|
+
/** `inputId`: the frame's own correlation key (a parked entry always carries one). */
|
|
1065
1106
|
frames: ReadonlyArray<{
|
|
1066
1107
|
seq?: number;
|
|
1108
|
+
inputId?: string;
|
|
1067
1109
|
}>;
|
|
1068
1110
|
carried: number;
|
|
1111
|
+
/** The `inputId`s of the frames counted in `carried`, when the migration recorded them. */
|
|
1112
|
+
carriedInputIds?: ReadonlyArray<string>;
|
|
1069
1113
|
/** The approving person's words (a `policy_ask` allow's `feedback`), counted APART from `frames`: owed, and how many the migration carried.
|
|
1070
1114
|
* They are on no row of their own, and a returned row (the compensation reopened it) does not carry them either — its next decide is a
|
|
1071
1115
|
* fresh one the host may re-supply them on — so, unlike the caller's own frames, they are not announced when the row came back (the row is
|
|
@@ -1078,6 +1122,28 @@ export interface OwedUserInputAccount {
|
|
|
1078
1122
|
};
|
|
1079
1123
|
};
|
|
1080
1124
|
}
|
|
1125
|
+
/** The ids of person inputs, per lane — each the `inputId` the input was accepted under (the same key value on the live
|
|
1126
|
+
* `human_input` frame and on a parked entry). */
|
|
1127
|
+
export interface OwedInputIds {
|
|
1128
|
+
readonly steer: ReadonlyArray<string>;
|
|
1129
|
+
readonly followUp: ReadonlyArray<string>;
|
|
1130
|
+
}
|
|
1131
|
+
/** The harness's at-agent_end count of person inputs still queued, per lane, with the ids of the ones that carried a park
|
|
1132
|
+
* record (a list shorter than its count names only some of them). */
|
|
1133
|
+
export interface HeldUserInputs {
|
|
1134
|
+
steer: number;
|
|
1135
|
+
followUp: number;
|
|
1136
|
+
inputIds?: OwedInputIds;
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* The ids of the person inputs a harness-side park-record list stands for: the `inputId` each record carries (the record is
|
|
1140
|
+
* the steer verb's own `PendingSteerInput`, opaque to the harness). Total — a record without a string id contributes none, so
|
|
1141
|
+
* its lane's list falls short of the count and {@link undrainedUserInputNotices} then leaves that lane's count without a list.
|
|
1142
|
+
*/
|
|
1143
|
+
export declare function parkedInputIdsOf(records: {
|
|
1144
|
+
readonly steer: ReadonlyArray<unknown>;
|
|
1145
|
+
readonly followUp: ReadonlyArray<unknown>;
|
|
1146
|
+
}): OwedInputIds;
|
|
1081
1147
|
/**
|
|
1082
1148
|
* What this leg still OWES a person, one count per family — the input to {@link undrainedUserInputNotices}.
|
|
1083
1149
|
* TWO lanes accept caller input and either can be holding some when a run ends: the harness's live queue
|
|
@@ -1103,6 +1169,26 @@ export declare function owedUserInputCounts(held: {
|
|
|
1103
1169
|
steer: number;
|
|
1104
1170
|
followUp: number;
|
|
1105
1171
|
};
|
|
1172
|
+
/**
|
|
1173
|
+
* WHICH inputs {@link owedUserInputCounts} counts — the same two lanes and the same rule, read as ids: the live queue's ids
|
|
1174
|
+
* less the ones the park migrated, plus the continuation frames the reopen did not bring back and the migration did not
|
|
1175
|
+
* carry (steer lane). The counts stay the authority: {@link undrainedUserInputNotices} puts a lane's list on its notice only
|
|
1176
|
+
* where the list names exactly that many inputs, so an input with no id, or a migration that recorded none, leaves that
|
|
1177
|
+
* lane's count without a list rather than with a wrong one.
|
|
1178
|
+
*/
|
|
1179
|
+
export declare function owedUserInputIds(held: HeldUserInputs | undefined, migrated: {
|
|
1180
|
+
steer: number;
|
|
1181
|
+
followUp: number;
|
|
1182
|
+
inputIds?: OwedInputIds;
|
|
1183
|
+
}, continuation: {
|
|
1184
|
+
frames: ReadonlyArray<{
|
|
1185
|
+
seq?: number;
|
|
1186
|
+
inputId?: string;
|
|
1187
|
+
}>;
|
|
1188
|
+
carried: number;
|
|
1189
|
+
carriedInputIds?: ReadonlyArray<string>;
|
|
1190
|
+
rowReturned: boolean;
|
|
1191
|
+
}): OwedInputIds;
|
|
1106
1192
|
/** Close the account — the ONE settlement point, called AFTER the reopen compensation with what that
|
|
1107
1193
|
* compensation actually did. Ordering is the whole rule: the counts are arithmetic, and the only fact they
|
|
1108
1194
|
* cannot be computed without is one the lane before this one does not have yet. EXACTLY ONCE per account,
|
|
@@ -1177,6 +1263,10 @@ export declare function parentLegIds(internals: {
|
|
|
1177
1263
|
export declare function undrainedUserInputNotices(counts: {
|
|
1178
1264
|
steer: number;
|
|
1179
1265
|
followUp: number;
|
|
1266
|
+
inputIds?: {
|
|
1267
|
+
steer?: ReadonlyArray<string>;
|
|
1268
|
+
followUp?: ReadonlyArray<string>;
|
|
1269
|
+
};
|
|
1180
1270
|
approvalFeedback?: number;
|
|
1181
1271
|
approvalCarry?: ApprovalCarryRefusal;
|
|
1182
1272
|
}, taskId?: string, sessionId?: string, runId?: string, parent?: ParentLegIds): EngineNotice[];
|
|
@@ -37,6 +37,10 @@ export function deliverEngineNotice(onNotice, notice) {
|
|
|
37
37
|
}
|
|
38
38
|
console.warn(notice.message);
|
|
39
39
|
}
|
|
40
|
+
export function parkedInputIdsOf(records) {
|
|
41
|
+
const ids = (lane) => lane.flatMap((r) => (typeof r === "object" && r !== null && typeof r.inputId === "string" ? [r.inputId] : []));
|
|
42
|
+
return { steer: ids(records.steer), followUp: ids(records.followUp) };
|
|
43
|
+
}
|
|
40
44
|
export function owedUserInputCounts(held, migrated, continuation) {
|
|
41
45
|
const owedContinuation = (continuation.rowReturned ? continuation.frames.filter((f) => f.seq === undefined).length : continuation.frames.length) - continuation.carried;
|
|
42
46
|
return {
|
|
@@ -44,16 +48,25 @@ export function owedUserInputCounts(held, migrated, continuation) {
|
|
|
44
48
|
followUp: Math.max(0, (held?.followUp ?? 0) - migrated.followUp),
|
|
45
49
|
};
|
|
46
50
|
}
|
|
51
|
+
export function owedUserInputIds(held, migrated, continuation) {
|
|
52
|
+
const gone = (lane) => new Set(migrated.inputIds?.[lane] ?? []);
|
|
53
|
+
const live = (lane) => (held?.inputIds?.[lane] ?? []).filter((id) => !gone(lane).has(id));
|
|
54
|
+
const carried = new Set(continuation.carriedInputIds ?? []);
|
|
55
|
+
const frames = (continuation.rowReturned ? continuation.frames.filter((f) => f.seq === undefined) : continuation.frames).filter((f) => !(typeof f.inputId === "string" && carried.has(f.inputId)));
|
|
56
|
+
const continuationIds = frames.flatMap((f) => (typeof f.inputId === "string" ? [f.inputId] : []));
|
|
57
|
+
return { steer: [...continuationIds, ...live("steer")], followUp: live("followUp") };
|
|
58
|
+
}
|
|
47
59
|
export function settleOwedUserInput(account, rowReturned, ids, onNotice) {
|
|
48
60
|
if (SETTLED_OWED_ACCOUNTS.has(account))
|
|
49
61
|
return;
|
|
50
62
|
SETTLED_OWED_ACCOUNTS.add(account);
|
|
51
63
|
try {
|
|
52
64
|
const owed = owedUserInputCounts(account.held, account.migrated, { ...account.continuation, rowReturned });
|
|
65
|
+
const inputIds = owedUserInputIds(account.held, account.migrated, { ...account.continuation, rowReturned });
|
|
53
66
|
const approval = account.continuation.approval;
|
|
54
67
|
const approvalFeedback = approval === undefined || rowReturned ? 0 : Math.max(0, approval.owed - approval.carried);
|
|
55
68
|
const approvalCarry = approvalFeedback > 0 ? approval?.refusal : undefined;
|
|
56
|
-
for (const notice of undrainedUserInputNotices({ ...owed, ...(approvalFeedback > 0 ? { approvalFeedback } : {}), ...(approvalCarry !== undefined ? { approvalCarry } : {}) }, ids.taskId, ids.sessionId, ids.runId, ids.parent))
|
|
69
|
+
for (const notice of undrainedUserInputNotices({ ...owed, inputIds, ...(approvalFeedback > 0 ? { approvalFeedback } : {}), ...(approvalCarry !== undefined ? { approvalCarry } : {}) }, ids.taskId, ids.sessionId, ids.runId, ids.parent))
|
|
57
70
|
deliverEngineNotice(onNotice, notice);
|
|
58
71
|
}
|
|
59
72
|
catch {
|
|
@@ -86,12 +99,13 @@ export function undrainedUserInputNotices(counts, taskId, sessionId, runId, pare
|
|
|
86
99
|
const own = [];
|
|
87
100
|
const copies = [];
|
|
88
101
|
const cause = "leg_end";
|
|
102
|
+
const inputIdsOf = (ids, counted) => (ids !== undefined && ids.length === counted ? { inputIds: [...ids] } : {});
|
|
89
103
|
if (counts.steer > 0) {
|
|
90
104
|
const message = `${counts.steer} user steer(s) ${tail}`;
|
|
91
105
|
const count = { [USER_INPUT_UNDRAINED_FAMILIES.steer.countKey]: counts.steer, cause };
|
|
92
|
-
own.push({ code: STEER_UNDRAINED, message, detail: { ...count, ...tid, ...sid, ...rid } });
|
|
106
|
+
own.push({ code: STEER_UNDRAINED, message, detail: { ...count, ...inputIdsOf(counts.inputIds?.steer, counts.steer), ...tid, ...sid, ...rid } });
|
|
93
107
|
if (toParent)
|
|
94
|
-
copies.push({ code: STEER_UNDRAINED, message: `${message}${copyTail}`, detail: { ...count, ...ptid, sessionId: parentSession, childSessionId: sessionId } });
|
|
108
|
+
copies.push({ code: STEER_UNDRAINED, message: `${message}${copyTail}`, detail: { ...count, ...inputIdsOf(counts.inputIds?.steer, counts.steer), ...ptid, sessionId: parentSession, childSessionId: sessionId } });
|
|
95
109
|
}
|
|
96
110
|
const approvalFeedback = counts.approvalFeedback ?? 0;
|
|
97
111
|
if (approvalFeedback > 0) {
|
|
@@ -109,9 +123,9 @@ export function undrainedUserInputNotices(counts, taskId, sessionId, runId, pare
|
|
|
109
123
|
if (counts.followUp > 0) {
|
|
110
124
|
const message = `${counts.followUp} user follow-up(s) ${tail}`;
|
|
111
125
|
const count = { [USER_INPUT_UNDRAINED_FAMILIES.followUp.countKey]: counts.followUp, cause };
|
|
112
|
-
own.push({ code: FOLLOWUP_UNDRAINED, message, detail: { ...count, ...tid, ...sid, ...rid } });
|
|
126
|
+
own.push({ code: FOLLOWUP_UNDRAINED, message, detail: { ...count, ...inputIdsOf(counts.inputIds?.followUp, counts.followUp), ...tid, ...sid, ...rid } });
|
|
113
127
|
if (toParent)
|
|
114
|
-
copies.push({ code: FOLLOWUP_UNDRAINED, message: `${message}${copyTail}`, detail: { ...count, ...ptid, sessionId: parentSession, childSessionId: sessionId } });
|
|
128
|
+
copies.push({ code: FOLLOWUP_UNDRAINED, message: `${message}${copyTail}`, detail: { ...count, ...inputIdsOf(counts.inputIds?.followUp, counts.followUp), ...ptid, sessionId: parentSession, childSessionId: sessionId } });
|
|
115
129
|
}
|
|
116
130
|
return [...own, ...copies];
|
|
117
131
|
}
|
package/dist/core/gate-fold.js
CHANGED
|
@@ -45,7 +45,7 @@ export async function runGateFold(pass) {
|
|
|
45
45
|
const second = await screenRewrite(pass.screening, pass.req, rewritten.form, `the rewritten call to "${toolName}"`);
|
|
46
46
|
if (second.kind === "refused") {
|
|
47
47
|
pass.currentInput = rewritten.form;
|
|
48
|
-
return second.by === "hook" ? hookDenyExit(pass, second.reason) : await engineFailClosedExit(pass, second.reason);
|
|
48
|
+
return second.by === "hook" ? hookDenyExit(pass, second.reason, second.extension) : await engineFailClosedExit(pass, second.reason, second.extension);
|
|
49
49
|
}
|
|
50
50
|
if (second.answer?.additionalContext)
|
|
51
51
|
pass.preToolContext.push(second.answer.additionalContext);
|
package/dist/core/gate-lanes.js
CHANGED
|
@@ -202,9 +202,10 @@ export async function runGateLanes(pass) {
|
|
|
202
202
|
};
|
|
203
203
|
return await readToolChecks(chains, standing, { toolName, judged: args, rewrite, request: Object.freeze({ ...pass.req, args }), signal }, project);
|
|
204
204
|
};
|
|
205
|
-
const refuseByExtension = (deny) => {
|
|
205
|
+
const refuseByExtension = (deny, by) => {
|
|
206
206
|
pass.decision = deny;
|
|
207
207
|
pass.deniedBy = settledRefusal?.deniedBy ?? "hook";
|
|
208
|
+
pass.deniedExtension = settledRefusal === undefined ? by : undefined;
|
|
208
209
|
pass.denyCause = settledRefusal?.cause;
|
|
209
210
|
};
|
|
210
211
|
if (pass.decision.action === "allow") {
|
|
@@ -212,7 +213,7 @@ export async function runGateLanes(pass) {
|
|
|
212
213
|
if (read !== undefined)
|
|
213
214
|
pass.toolCheckRaised = true;
|
|
214
215
|
if (read?.kind === "denied")
|
|
215
|
-
refuseByExtension(read.deny);
|
|
216
|
+
refuseByExtension(read.deny, read.by);
|
|
216
217
|
else if (read?.kind === "asked")
|
|
217
218
|
pass.decision = read.ask;
|
|
218
219
|
else if (read?.kind === "approved")
|
|
@@ -353,7 +354,7 @@ export async function runGateLanes(pass) {
|
|
|
353
354
|
if (pass.toolCheckRaised !== true && pass.decision.action !== "deny") {
|
|
354
355
|
const read = await checkTool(pass.decision, pass.currentInput, orgAnswer.org, pass.policyRewrite, allowMayClear);
|
|
355
356
|
if (read?.kind === "denied")
|
|
356
|
-
refuseByExtension(read.deny);
|
|
357
|
+
refuseByExtension(read.deny, read.by);
|
|
357
358
|
else if (read?.kind === "cleared")
|
|
358
359
|
pass.decision = await clearAs("hook", { entries: read.entries, clear: () => read.allow, afterClear: async () => undefined });
|
|
359
360
|
else if (read?.kind === "asked") {
|
|
@@ -587,6 +588,7 @@ export async function runGateLanes(pass) {
|
|
|
587
588
|
if (screened.kind === "refused") {
|
|
588
589
|
editDenied = { action: "deny", message: screened.reason };
|
|
589
590
|
pass.deniedBy = "hook";
|
|
591
|
+
pass.deniedExtension = screened.extension;
|
|
590
592
|
break;
|
|
591
593
|
}
|
|
592
594
|
const hr = screened.answer;
|
|
@@ -596,6 +598,7 @@ export async function runGateLanes(pass) {
|
|
|
596
598
|
if (hr.action === "deny") {
|
|
597
599
|
editDenied = { action: "deny", message: decisionText(hr) ?? `the approved edit for "${toolName}" was blocked by a PreToolUse hook` };
|
|
598
600
|
pass.deniedBy = "hook";
|
|
601
|
+
pass.deniedExtension = screened.answeredBy;
|
|
599
602
|
break;
|
|
600
603
|
}
|
|
601
604
|
if (hr.action === "ask") {
|
|
@@ -655,6 +658,7 @@ export async function runGateLanes(pass) {
|
|
|
655
658
|
if (second?.kind === "refused") {
|
|
656
659
|
editDenied = { action: "deny", message: second.reason };
|
|
657
660
|
pass.deniedBy = "hook";
|
|
661
|
+
pass.deniedExtension = second.extension;
|
|
658
662
|
break;
|
|
659
663
|
}
|
|
660
664
|
if (second?.kind === "stands") {
|
|
@@ -721,7 +725,7 @@ export async function runGateLanes(pass) {
|
|
|
721
725
|
}
|
|
722
726
|
const editRead = await checkTool(editDecision, editArgs, editOrg.org, undefined);
|
|
723
727
|
if (editRead?.kind === "denied") {
|
|
724
|
-
refuseByExtension(editRead.deny);
|
|
728
|
+
refuseByExtension(editRead.deny, editRead.by);
|
|
725
729
|
editDenied = editRead.deny;
|
|
726
730
|
break;
|
|
727
731
|
}
|
|
@@ -345,6 +345,24 @@ export declare const DENIED_BY_MAY_CARRY_CAUSE: {
|
|
|
345
345
|
};
|
|
346
346
|
/** Compile-time fence: `never` while every deny layer has a cause row. */
|
|
347
347
|
export type CauseTableCoversEveryDeniedBy = AssertAllKeysHandled<Exclude<DeniedBy, keyof typeof DENIED_BY_MAY_CARRY_CAUSE>>;
|
|
348
|
+
/** Which deny layers may name the extension whose handler ended the call ({@link GateDisposition}'s `extension`): the hook layer
|
|
349
|
+
* alone — an extension's `tool.check` answer or failure is a hook-layer refusal, and no other layer's verdict is an extension's.
|
|
350
|
+
* The mint reads it as the producer and the screen (invariant I12) as the archive: one table, two readers. Module-level only; not
|
|
351
|
+
* part of the package root. */
|
|
352
|
+
export declare const DENIED_BY_MAY_NAME_EXTENSION: {
|
|
353
|
+
readonly policy: false;
|
|
354
|
+
readonly hook: true;
|
|
355
|
+
readonly org: false;
|
|
356
|
+
readonly persisted_rule: false;
|
|
357
|
+
readonly classifier: false;
|
|
358
|
+
readonly compliance: false;
|
|
359
|
+
readonly write_protection: false;
|
|
360
|
+
readonly ask_resolution: false;
|
|
361
|
+
readonly read_boundary: false;
|
|
362
|
+
readonly mode: false;
|
|
363
|
+
};
|
|
364
|
+
/** Compile-time fence: `never` while every deny layer has an extension-naming row. */
|
|
365
|
+
export type ExtensionTableCoversEveryDeniedBy = AssertAllKeysHandled<Exclude<DeniedBy, keyof typeof DENIED_BY_MAY_NAME_EXTENSION>>;
|
|
348
366
|
/** The final disposition of a gate pass. `cause` is present exactly when the deny came out of an auto-mode
|
|
349
367
|
* classifier round that did not RULE ({@link ClassifierDenyCause}); a ruling block and every non-classifier
|
|
350
368
|
* deny carry none. Invariant I5 ({@link screenGateOutcome}): a cause stands only beside a layer word in
|
|
@@ -371,7 +389,15 @@ export type CauseTableCoversEveryDeniedBy = AssertAllKeysHandled<Exclude<DeniedB
|
|
|
371
389
|
* record is, with `positions` for a list member (the indices of those entries in the list the run received — a host maps them
|
|
372
390
|
* onto the declaration it sent for this run). Present exactly when an allow member cleared a standing ask and nobody answered
|
|
373
391
|
* it: absent on a call nothing asked about, a mode's release or acceptance, the read-only arm's, the classifier's or the
|
|
374
|
-
* sandbox's allow, and a person's yes. Additive. Invariant I9 ({@link screenGateOutcome}) screens its shape.
|
|
392
|
+
* sandbox's allow, and a person's yes. Additive. Invariant I9 ({@link screenGateOutcome}) screens its shape.
|
|
393
|
+
*
|
|
394
|
+
* `extension` — on the denied arm only: the registration name of the extension whose handler ended the call at the hook layer,
|
|
395
|
+
* by its `deny` answer (`tool.check`, `classic.PreToolUse`, `tool.call`) or by its failure (a throw, a budget overrun, an
|
|
396
|
+
* answer the station cannot take — the engine fails the call closed). Present exactly when `deniedBy` is `hook` and the
|
|
397
|
+
* refusing handler's registration is known; ABSENT beside every other layer word (an ancestor leg's screening reaches a
|
|
398
|
+
* descendant as a `policy` refusal, and a refusal an inherited installation's question settled is that question's), and beside
|
|
399
|
+
* a `hook` refusal that names no registration (the engine's own failed raise, a cancel). A display and audit fact: the call is
|
|
400
|
+
* refused whatever the name. Additive. Invariant I12 ({@link screenGateOutcome}) screens its shape. */
|
|
375
401
|
export type GateDisposition = {
|
|
376
402
|
kind: "allowed";
|
|
377
403
|
classifier?: AutoModeClassifierRound;
|
|
@@ -385,6 +411,7 @@ export type GateDisposition = {
|
|
|
385
411
|
mode?: ModeRefusal["mode"];
|
|
386
412
|
askClass?: AskClass;
|
|
387
413
|
classes?: readonly AskClass[];
|
|
414
|
+
extension?: string;
|
|
388
415
|
};
|
|
389
416
|
/**
|
|
390
417
|
* A permission MODE released a surviving ask — the allowed disposition's account of the question it did not put
|
|
@@ -443,6 +470,8 @@ export interface ModeRefusal {
|
|
|
443
470
|
* whole number when present, and `positions` — only on a list member (`request`, `deployment`) — a list of non-negative
|
|
444
471
|
* whole numbers;
|
|
445
472
|
* I10 `settlement.when` present ⇒ a finite number (epoch ms — the moment the wait ended is a value a reader can order);
|
|
473
|
+
* I12 `disposition.extension` present ⇒ the denied arm, a layer word {@link DENIED_BY_MAY_NAME_EXTENSION} admits (the hook layer),
|
|
474
|
+
* and a non-empty string (a registration's name);
|
|
446
475
|
* I11 a winner's `decision` stated beside the record (the caller reads a durable row: `winnerDecision`) ⇒ a word a winner holds,
|
|
447
476
|
* and its direction (allow: `allow` / `approve` / `edit`; refusal: `deny` / `reject`) is the direction of the record's
|
|
448
477
|
* settlement ({@link SETTLEMENT_IS_REFUSAL}) and of its disposition (`allowed` / `denied`) — one decision, one direction.
|
|
@@ -514,7 +543,7 @@ export declare function isRetiredMember<S extends MemberSet>(set: S, word: unkno
|
|
|
514
543
|
*/
|
|
515
544
|
export declare function releasePolicyDefects(g: unknown): string[];
|
|
516
545
|
/** The members only the denied arm of a {@link GateDisposition} carries. */
|
|
517
|
-
declare const DENY_ONLY_MEMBERS: readonly ["deniedBy", "cause", "mode", "askClass", "classes"];
|
|
546
|
+
declare const DENY_ONLY_MEMBERS: readonly ["deniedBy", "cause", "mode", "askClass", "classes", "extension"];
|
|
518
547
|
type DenyOnlyMember = Exclude<keyof Extract<GateDisposition, {
|
|
519
548
|
kind: "denied";
|
|
520
549
|
}>, keyof Extract<GateDisposition, {
|
|
@@ -523,7 +552,7 @@ type DenyOnlyMember = Exclude<keyof Extract<GateDisposition, {
|
|
|
523
552
|
/** Compile-time fence: `never` while the list is exactly the denied arm's own members. */
|
|
524
553
|
export type DenyOnlyMembersAreListed = AssertAllKeysHandled<Exclude<DenyOnlyMember, (typeof DENY_ONLY_MEMBERS)[number]> | Exclude<(typeof DENY_ONLY_MEMBERS)[number], DenyOnlyMember>>;
|
|
525
554
|
/**
|
|
526
|
-
* The one invariant screen for a {@link GateOutcome} (I1–
|
|
555
|
+
* The one invariant screen for a {@link GateOutcome} (I1–I12 above, plus the closed-set word each member carries). Two readings:
|
|
527
556
|
* - `"archive"` (the default) — a record read back from where it was kept (a replay, a ledger, a durable row): its shape, with
|
|
528
557
|
* every closed set read as its live members plus {@link RETIRED_MEMBERS}. A record lawful when minted is not a defect later.
|
|
529
558
|
* - `"producer"` — a record THIS engine is composing or publishing now: the live sets alone, and the engine's release law
|
|
@@ -119,6 +119,18 @@ export const DENIED_BY_MAY_CARRY_CAUSE = {
|
|
|
119
119
|
read_boundary: false,
|
|
120
120
|
mode: false,
|
|
121
121
|
};
|
|
122
|
+
export const DENIED_BY_MAY_NAME_EXTENSION = {
|
|
123
|
+
policy: false,
|
|
124
|
+
hook: true,
|
|
125
|
+
org: false,
|
|
126
|
+
persisted_rule: false,
|
|
127
|
+
classifier: false,
|
|
128
|
+
compliance: false,
|
|
129
|
+
write_protection: false,
|
|
130
|
+
ask_resolution: false,
|
|
131
|
+
read_boundary: false,
|
|
132
|
+
mode: false,
|
|
133
|
+
};
|
|
122
134
|
const retired = (word, retiredIn) => Object.freeze({ word, retiredIn });
|
|
123
135
|
export const RETIRED_MEMBERS = Object.freeze({
|
|
124
136
|
askClass: Object.freeze([retired("write_protection_unresolved", "7.49.0"), retired("governance_unavailable", "7.51.0")]),
|
|
@@ -189,7 +201,7 @@ function clearanceDefects(v, settled, released) {
|
|
|
189
201
|
}
|
|
190
202
|
return out;
|
|
191
203
|
}
|
|
192
|
-
const DENY_ONLY_MEMBERS = Object.freeze(["deniedBy", "cause", "mode", "askClass", "classes"]);
|
|
204
|
+
const DENY_ONLY_MEMBERS = Object.freeze(["deniedBy", "cause", "mode", "askClass", "classes", "extension"]);
|
|
193
205
|
function objectOf(v) {
|
|
194
206
|
return typeof v === "object" && v !== null && !Array.isArray(v) ? v : undefined;
|
|
195
207
|
}
|
|
@@ -303,6 +315,12 @@ export function screenGateOutcome(g, opts) {
|
|
|
303
315
|
}
|
|
304
316
|
if (modeRefusal && (denied.askClass === undefined || denied.classes === undefined))
|
|
305
317
|
defects.push("I8: a mode refusal carries askClass and classes");
|
|
318
|
+
if (denied.extension !== undefined) {
|
|
319
|
+
if (typeof denied.extension !== "string" || denied.extension === "")
|
|
320
|
+
defects.push(`I12: disposition.extension ${spelled(denied.extension)} is not a registration name (a non-empty string)`);
|
|
321
|
+
if (layer && !(isDeniedBy(denied.deniedBy) && DENIED_BY_MAY_NAME_EXTENSION[denied.deniedBy]))
|
|
322
|
+
defects.push(`I12: an extension cannot be named beside deniedBy "${String(denied.deniedBy)}"`);
|
|
323
|
+
}
|
|
306
324
|
if (denied.askClass !== undefined && !member("askClass", denied.askClass))
|
|
307
325
|
defects.push(outside("disposition.askClass", "askClass", denied.askClass));
|
|
308
326
|
if (denied.classes !== undefined && !classList(denied.classes))
|