@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,4 +1,4 @@
|
|
|
1
|
-
import { CheckpointError, readPendingSteerQueue, refuseRetiredModeSeed, resolveCheckpointStore, validatePendingSteer } from "../checkpoint-store.js";
|
|
1
|
+
import { CheckpointError, judgeParkedSteerRepeat, readPendingSteerQueue, refuseRetiredModeSeed, resolveCheckpointStore, validatePendingSteer } from "../checkpoint-store.js";
|
|
2
2
|
import { assertResumeConfigRecord, checkpointStoreSeat, refuseResumeDoors } from "./prepare-config-doors.js";
|
|
3
3
|
import { asResumeConfigRefusal } from "../mode-policy.js";
|
|
4
4
|
import { describeSuppliedValue } from "./decide-continuation.js";
|
|
@@ -15,7 +15,7 @@ export async function resumeAdmission(input) {
|
|
|
15
15
|
const { token, outcome, taskConfig, runner, sessions, parentConstraintRegistry } = input;
|
|
16
16
|
let internals = input.internals;
|
|
17
17
|
if (outcome === null || typeof outcome !== "object") {
|
|
18
|
-
throw new CheckpointError("checkpoint.invalid_outcome", `resume outcome must be an object naming its gate (got ${outcome === null ? "null" : typeof outcome})
|
|
18
|
+
throw new CheckpointError("checkpoint.invalid_outcome", `resume outcome must be an object naming its gate (got ${outcome === null ? "null" : typeof outcome})`, { field: "outcome" });
|
|
19
19
|
}
|
|
20
20
|
asResumeConfigRefusal("taskConfig", () => assertResumeConfigRecord(taskConfig));
|
|
21
21
|
let config = { ...taskConfig, ...(Array.isArray(taskConfig.skills) ? { skills: detachSkillLists(taskConfig.skills) } : {}) };
|
|
@@ -80,6 +80,8 @@ export async function resumeAdmission(input) {
|
|
|
80
80
|
}
|
|
81
81
|
if (suppliedMessage !== undefined) {
|
|
82
82
|
wakeMessage = validatePendingSteer(suppliedMessage);
|
|
83
|
+
if (judgeParkedSteerRepeat(parkedSteers, wakeMessage) !== undefined)
|
|
84
|
+
wakeMessage = undefined;
|
|
83
85
|
}
|
|
84
86
|
else if (parkedSteers.length === 0) {
|
|
85
87
|
throw new CheckpointError("wake.nothing_to_deliver", "cannot wake: no message was supplied and the checkpoint holds no parked pendingSteer — an empty " +
|
|
@@ -4,6 +4,8 @@ import { chainPolicyOnLeg, chainTopAnchors } from "./child-tree.js";
|
|
|
4
4
|
import { mintHookInvocationIdentity } from "../hooks.js";
|
|
5
5
|
import { admitLegMods, classicEventBase, failedHandlerClause, screenUserPrompt } from "../mods/stations.js";
|
|
6
6
|
import { checkToolPolicyProjection, policyCannotAnswer, refuseOutOfContractDecision } from "../tool-policy.js";
|
|
7
|
+
import { requestGrantBinding } from "../skill-grant-binding.js";
|
|
8
|
+
import { skillGrantBindingMembers } from "../skill-grant.js";
|
|
7
9
|
import { callFaceSeat, parkedCallFaceOf } from "../tool-roster.js";
|
|
8
10
|
import { readCallTarget } from "../effective-path-target.js";
|
|
9
11
|
import { inlineUntrusted } from "../untrusted-text.js";
|
|
@@ -74,9 +76,11 @@ export async function resumeApply(input) {
|
|
|
74
76
|
p.then((v) => { editSignal.removeEventListener("abort", onAbort); resolve(v); }, (e) => { editSignal.removeEventListener("abort", onAbort); reject(e); });
|
|
75
77
|
});
|
|
76
78
|
};
|
|
79
|
+
const servedSkills = plainPolicyOutcome?.decision === "allow" && cp.pendingAction.kind === "tool_approval" ? skillsThatLoad(normalizeSkills(config.skills)) : [];
|
|
77
80
|
if (plainPolicyOutcome?.decision === "allow" && cp.pendingAction.kind === "tool_approval") {
|
|
78
|
-
const servedSkills = skillsThatLoad(normalizeSkills(config.skills));
|
|
79
81
|
const claimed = judgeApprovalObject(cp.pendingAction, { args: plainPolicyOutcome.updatedInput ?? cp.pendingAction.args, skills: servedSkills, skillToolName: SKILL_TOOL_NAME }, "claim");
|
|
82
|
+
if (claimed !== "match" && claimed.member === "tool")
|
|
83
|
+
throw new CheckpointError("checkpoint.unsupported_version", claimed.message, { reason: "tool_identity_missing" });
|
|
80
84
|
if (claimed !== "match")
|
|
81
85
|
throw new CheckpointError("checkpoint.invalid_outcome", claimed.message, { field: "boundGrantDigest" });
|
|
82
86
|
}
|
|
@@ -94,6 +98,7 @@ export async function resumeApply(input) {
|
|
|
94
98
|
toolName: cp.pendingAction.toolName,
|
|
95
99
|
args: editedArgs,
|
|
96
100
|
toolCallId: cp.pendingAction.toolCallId,
|
|
101
|
+
...requestGrantBinding((call, args) => skillGrantBindingMembers(call, args, servedSkills, SKILL_TOOL_NAME), cp.pendingAction, editedArgs),
|
|
97
102
|
budget: editBudget,
|
|
98
103
|
...callFaceSeat(parkedCallFaceOf(cp.pendingAction)),
|
|
99
104
|
...(cp.state.handsCwd !== undefined ? { cwd: cp.state.handsCwd } : {}),
|
|
@@ -33,17 +33,17 @@ export function resumePolicyOutcome(input) {
|
|
|
33
33
|
if (updatedInputRaw !== undefined) {
|
|
34
34
|
const captured = capturedJsonOf(updatedInputRaw);
|
|
35
35
|
if (!captured.ok)
|
|
36
|
-
throw new CheckpointError("checkpoint.invalid_outcome", bindingRefusalOf(cp.pendingAction.kind === "tool_approval" ? cp.pendingAction.toolName : "the parked call", updatedInputRaw, captured.fault));
|
|
36
|
+
throw new CheckpointError("checkpoint.invalid_outcome", bindingRefusalOf(cp.pendingAction.kind === "tool_approval" ? cp.pendingAction.toolName : "the parked call", updatedInputRaw, captured.fault), { field: "updatedInput" });
|
|
37
37
|
updatedInput = captured.value;
|
|
38
38
|
}
|
|
39
39
|
const decision = decide.decision;
|
|
40
40
|
if (decision !== "allow" && decision !== "deny") {
|
|
41
|
-
throw new CheckpointError("checkpoint.invalid_outcome", `resume decision "${describeSuppliedValue(decision)}" is outside the policy_ask domain — a decide is exactly "allow" or "deny"; refusing pre-CAS, the checkpoint stays pending
|
|
41
|
+
throw new CheckpointError("checkpoint.invalid_outcome", `resume decision "${describeSuppliedValue(decision)}" is outside the policy_ask domain — a decide is exactly "allow" or "deny"; refusing pre-CAS, the checkpoint stays pending`, { field: "decision" });
|
|
42
42
|
}
|
|
43
43
|
refuseSuppliedKeys(decide, REFUSED_DECIDE_KEYS);
|
|
44
44
|
const hostDecision = captureHostDecision(cp, decide.hostDecision, "policy_ask", { word: decision, allows: decision === "allow" });
|
|
45
45
|
const reason = decide.reason;
|
|
46
|
-
assertOutcomeText(reason, "reason");
|
|
46
|
+
assertOutcomeText(reason, "reason", { field: "reason" });
|
|
47
47
|
const feedback = decide.feedback;
|
|
48
48
|
assertOutcomeText(feedback, "feedback", { field: "feedback" });
|
|
49
49
|
plainPolicyOutcome = {
|
|
@@ -59,7 +59,7 @@ export function resumePolicyOutcome(input) {
|
|
|
59
59
|
};
|
|
60
60
|
refuseUnfitFeedback(plainPolicyOutcome);
|
|
61
61
|
if (plainPolicyOutcome.decision === "deny" && plainPolicyOutcome.reason && sanitizeUntrustedText(plainPolicyOutcome.reason) !== plainPolicyOutcome.reason) {
|
|
62
|
-
throw new CheckpointError("checkpoint.invalid_outcome", sentinelTagRefusal("resume deny/reject reason"));
|
|
62
|
+
throw new CheckpointError("checkpoint.invalid_outcome", sentinelTagRefusal("resume deny/reject reason"), { field: "reason" });
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
if (plainPolicyOutcome !== undefined) {
|
|
@@ -74,7 +74,7 @@ export function resumePolicyOutcome(input) {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
else if (checkpointVersionOf(cp) >= CHECKPOINT_FEATURES.binding.version) {
|
|
77
|
-
throw new CheckpointError("checkpoint.invalid_outcome", `resume of a binding-version (v${checkpointVersionOf(cp)}) checkpoint whose pending tool call has no persisted boundInputHash — refusing to resume an unbound binding-version checkpoint (corruption / downgrade guard)
|
|
77
|
+
throw new CheckpointError("checkpoint.invalid_outcome", `resume of a binding-version (v${checkpointVersionOf(cp)}) checkpoint whose pending tool call has no persisted boundInputHash — refusing to resume an unbound binding-version checkpoint (corruption / downgrade guard)`, { reason: "bound_input_hash_missing" });
|
|
78
78
|
}
|
|
79
79
|
if (cp.reopenReason === "env_failed") {
|
|
80
80
|
if (cp.resolvedOutcome === undefined) {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The person's account of a role seat the engine stands in for (`model.role_defaulted`).
|
|
3
|
+
*
|
|
4
|
+
* A role seat that names a model word the deployment's catalog does not hold supplies no model: the roles family reads it as an unset
|
|
5
|
+
* seat (`seatRead`, `src/core/roles.ts` — the tier default and the fallback chain follow; a subagent seat falls to the parent's model),
|
|
6
|
+
* so the run goes on instead of refusing at every prepare. That is only honest when it is said: this prepare-time phase names each such
|
|
7
|
+
* seat once per conversation, from the SAME role maps (the merged deployment-and-task map, and the deployment's own map that a delegated child's
|
|
8
|
+
* seat reads) and the SAME catalog the reads use (`unheldRoleSeats`), whether or not a
|
|
9
|
+
* later read of this leg reaches the seat. `default` (the main model's seat) and `classifier` (its own stand-in and line,
|
|
10
|
+
* `classifier.role_defaulted`) are never named here.
|
|
11
|
+
*
|
|
12
|
+
* Root legs only: a delegated child inherits the deployment's maps and would repeat the parent's line once per spawn.
|
|
13
|
+
*/
|
|
14
|
+
import { type EngineNotice } from "../engine-notice.js";
|
|
15
|
+
import { type ModelRoles, type UnheldRoleSeat } from "../roles.js";
|
|
16
|
+
import type { Model } from "../types.js";
|
|
17
|
+
import { type AnnounceOnceLedger } from "./announce-once-ledger.js";
|
|
18
|
+
export declare const ROLE_DEFAULTED = "model.role_defaulted";
|
|
19
|
+
/** The notice for one unheld seat. `word` is bounded and quoted as every refusal of this family quotes it. */
|
|
20
|
+
export declare function roleDefaultedNotice(u: UnheldRoleSeat, ids: {
|
|
21
|
+
sessionId: string;
|
|
22
|
+
runId?: string;
|
|
23
|
+
}): EngineNotice;
|
|
24
|
+
export interface AnnounceRoleSeatsInput {
|
|
25
|
+
/** borrowed-readonly — the rebound spec's role map (the task's own seats). */
|
|
26
|
+
spec: {
|
|
27
|
+
roles?: ModelRoles;
|
|
28
|
+
};
|
|
29
|
+
/** borrowed-readonly — the deployment's maps and the catalog the reads ask, and the notice sink. */
|
|
30
|
+
deps: {
|
|
31
|
+
models?: Record<string, Model>;
|
|
32
|
+
roles?: ModelRoles;
|
|
33
|
+
onNotice?: (notice: EngineNotice) => void;
|
|
34
|
+
};
|
|
35
|
+
/** borrowed-readonly — the once-per-session ledger the notice's dedupe rides. */
|
|
36
|
+
onceLedger: Pick<AnnounceOnceLedger, "oncePerSession">;
|
|
37
|
+
/** borrowed-readonly — true for the root leg of a conversation; a delegated child names nothing (its parent already did). */
|
|
38
|
+
rootLeg: boolean;
|
|
39
|
+
sessionId: string;
|
|
40
|
+
runId: string | undefined;
|
|
41
|
+
}
|
|
42
|
+
/** The phase: one line per unheld seat per conversation (the dedupe key is the seat and the word, so a seat re-pointed at another
|
|
43
|
+
* unknown word is said again). */
|
|
44
|
+
export declare function announceRoleSeatsDefaulted(input: AnnounceRoleSeatsInput): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { deliverEngineNotice } from "../engine-notice.js";
|
|
2
|
+
import { bindingShown, roleFallbackChain, unheldRoleSeats } from "../roles.js";
|
|
3
|
+
import { announceDigest } from "./announce-once-ledger.js";
|
|
4
|
+
export const ROLE_DEFAULTED = "model.role_defaulted";
|
|
5
|
+
const STANDS_IN = {
|
|
6
|
+
summarize: "the compaction summary runs on the conversation's own model (or the tier default for that role, when tiers are declared)",
|
|
7
|
+
subagent: "child runs go on the parent run's model",
|
|
8
|
+
verifier: "the verification gate runs on the main model",
|
|
9
|
+
consolidate: "memory consolidation runs on the summarize role's model, and is refused when that supplies none",
|
|
10
|
+
};
|
|
11
|
+
export function roleDefaultedNotice(u, ids) {
|
|
12
|
+
const shown = bindingShown(u.word);
|
|
13
|
+
return {
|
|
14
|
+
code: ROLE_DEFAULTED,
|
|
15
|
+
message: `${u.seat} names the model ${shown}, which this deployment's model catalog does not hold, so the seat is read as an unset one: ${STANDS_IN[u.role] ?? "its fallback chain decides"}. ` +
|
|
16
|
+
`Declare ${shown} in the catalog (RunnerDeps.models) or correct the seat. Said once per conversation for this seat.`,
|
|
17
|
+
detail: {
|
|
18
|
+
seat: u.seat,
|
|
19
|
+
role: u.role,
|
|
20
|
+
model: u.word.length > 80 ? `${u.word.slice(0, 80)}…` : u.word,
|
|
21
|
+
reason: "unknown_model_ref",
|
|
22
|
+
fallback: [...roleFallbackChain(u.role)],
|
|
23
|
+
sessionId: ids.sessionId,
|
|
24
|
+
...(ids.runId !== undefined ? { runId: ids.runId } : {}),
|
|
25
|
+
},
|
|
26
|
+
sessionId: ids.sessionId,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function announceRoleSeatsDefaulted(input) {
|
|
30
|
+
if (!input.rootLeg)
|
|
31
|
+
return;
|
|
32
|
+
const seen = new Set();
|
|
33
|
+
for (const u of [...unheldRoleSeats({}, input.deps), ...unheldRoleSeats(input.spec, input.deps)]) {
|
|
34
|
+
const key = `${u.seat}\n${u.word}`;
|
|
35
|
+
if (seen.has(key))
|
|
36
|
+
continue;
|
|
37
|
+
seen.add(key);
|
|
38
|
+
input.onceLedger.oncePerSession(announceDigest(ROLE_DEFAULTED, key), () => deliverEngineNotice(input.deps.onNotice, roleDefaultedNotice(u, { sessionId: input.sessionId, ...(input.runId !== undefined ? { runId: input.runId } : {}) })));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -19,6 +19,8 @@ export function runBrainSinks(input) {
|
|
|
19
19
|
...(s.retryAtMs !== undefined ? { retryAtMs: s.retryAtMs } : {}),
|
|
20
20
|
...(s.elapsedMs !== undefined ? { elapsedMs: s.elapsedMs } : {}),
|
|
21
21
|
...(s.timeoutMs !== undefined ? { timeoutMs: s.timeoutMs } : {}),
|
|
22
|
+
...(s.waitSegment !== undefined ? { waitSegment: s.waitSegment } : {}),
|
|
23
|
+
...(s.sleptMs !== undefined ? { sleptMs: s.sleptMs } : {}),
|
|
22
24
|
...(s.attempt !== undefined ? { attempt: s.attempt } : {}),
|
|
23
25
|
...(s.maxRetries !== undefined ? { maxRetries: s.maxRetries } : {}),
|
|
24
26
|
...(s.errClass !== undefined ? { errClass: s.errClass } : {}),
|
|
@@ -2,7 +2,7 @@ import type { PeerInboundChainRef } from "../../agents/peer-admission.js";
|
|
|
2
2
|
import { type SafeNotifier } from "../safe-notify.js";
|
|
3
3
|
import { type NotificationInjectionOutcome, type PendingSessionNotifications, type SystemInjectionPriority, type TaskNotificationPayload } from "../task-notification.js";
|
|
4
4
|
import type { PushQueue } from "../push-queue.js";
|
|
5
|
-
import type { TaskEvent, TaskSpec } from "../types.js";
|
|
5
|
+
import type { HeldUserInputs, TaskEvent, TaskSpec } from "../types.js";
|
|
6
6
|
import type { Stats } from "./assemble-result.js";
|
|
7
7
|
import { type CallerStopGate } from "./caller-stop-gate.js";
|
|
8
8
|
import type { CaptureOptOutRef, LiveHandle, ManualCompactRef, McpRedialRef, NotificationLaneBindings, NotifyRef, Prepared, RunInternals, RunnerDepsSeat, TaskIdRef } from "./contracts.js";
|
|
@@ -73,10 +73,7 @@ export interface RunIdentityWiringResult {
|
|
|
73
73
|
/** The held agent_end account, a READ FACE over this lane's own `let` (the undrained-inputs sink writes it
|
|
74
74
|
* when the run committed a durable park); the terminal-adoption lane settles it minus what the park carried. */
|
|
75
75
|
undrainedUserAtEnd: {
|
|
76
|
-
readonly current:
|
|
77
|
-
steer: number;
|
|
78
|
-
followUp: number;
|
|
79
|
-
} | undefined;
|
|
76
|
+
readonly current: HeldUserInputs | undefined;
|
|
80
77
|
};
|
|
81
78
|
/** The run's ONE isolation scope for the {@link RunInternals} observation sinks: minted here because
|
|
82
79
|
* the manifest sink below is the run's first call into one, and handed on to the harness-handlers lane
|
|
@@ -6,7 +6,7 @@ import { recordFrameReceipt, toolResultReceiptKey } from "../frame-settlement.js
|
|
|
6
6
|
import { discloseDroppedPending, renderTaskNotificationXml, taskNotificationDedupKey } from "../task-notification.js";
|
|
7
7
|
import { buildAppliedHumanInputEvent } from "../human-input-projection.js";
|
|
8
8
|
import { announceAcceptance, nextHumanInputSeq } from "./steer-admission.js";
|
|
9
|
-
import { deliverDelegationLifecycle, deliverEngineNotice, parentLegIds, undrainedUserInputNotices } from "../types.js";
|
|
9
|
+
import { deliverDelegationLifecycle, deliverEngineNotice, parentLegIds, parkedInputIdsOf, undrainedUserInputNotices } from "../types.js";
|
|
10
10
|
import { mintCallerStopGate } from "./caller-stop-gate.js";
|
|
11
11
|
export function runIdentityWiring(input) {
|
|
12
12
|
const { spec, queue, prepared, internals, taskIdRef, onReady, manualCompactRef, notifyRef, captureOptOutRef, mcpRedialRef, injectTaskNotification, deliveredAtTurnOpen, peerInboundChainRef, notificationLane, pendingSessionNotifications, runner } = input;
|
|
@@ -64,13 +64,14 @@ export function runIdentityWiring(input) {
|
|
|
64
64
|
prepared.harness.engineInjectionsHeld = () => prepared.batchHaltRef.current !== undefined;
|
|
65
65
|
let undrainedUserAtEnd;
|
|
66
66
|
let userInputLostAtEnd = false;
|
|
67
|
-
prepared.harness.onUndrainedUserInputs = (counts) => {
|
|
67
|
+
prepared.harness.onUndrainedUserInputs = (counts, parkRecords) => {
|
|
68
68
|
userInputLostAtEnd = counts.steer + counts.followUp > 0;
|
|
69
|
+
const inputIds = parkRecords !== undefined ? parkedInputIdsOf(parkRecords) : undefined;
|
|
69
70
|
if (prepared.pausedRef.current !== undefined || prepared.undeliveredContinuationRef.current.parkedSteers.length > 0) {
|
|
70
|
-
undrainedUserAtEnd = counts;
|
|
71
|
+
undrainedUserAtEnd = { steer: counts.steer, followUp: counts.followUp, ...(inputIds !== undefined ? { inputIds } : {}) };
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
|
-
for (const notice of undrainedUserInputNotices(counts, spec.taskId ?? prepared.sessionId, prepared.sessionId, prepared.runId, parentLegIds(internals))) {
|
|
74
|
+
for (const notice of undrainedUserInputNotices({ ...counts, ...(inputIds !== undefined ? { inputIds } : {}) }, spec.taskId ?? prepared.sessionId, prepared.sessionId, prepared.runId, parentLegIds(internals))) {
|
|
74
75
|
deliverEngineNotice(runner.deps.onNotice, notice);
|
|
75
76
|
}
|
|
76
77
|
};
|
|
@@ -40,6 +40,8 @@ export interface RunLegInput<R> {
|
|
|
40
40
|
rs: RunState;
|
|
41
41
|
/** borrowed-readonly — the API-boundary attribution snapshot of the objective's actor (the objective leg's speaker envelope). */
|
|
42
42
|
entryActor: ActorAssertion | undefined;
|
|
43
|
+
/** borrowed-readonly — `RunInternals.operatorObjective`: this delegated leg's objective carries a person's words. */
|
|
44
|
+
operatorObjective: boolean;
|
|
43
45
|
/** borrowed-readonly — the effective walltime window (undefined = unbounded): `<= 0` refuses the first turn. */
|
|
44
46
|
effectiveTimeoutMs: number | undefined;
|
|
45
47
|
/** borrowed-mutable — the hard walltime timer: claimed (`fired`) and cleared by the exhausted arms and the finally. */
|
|
@@ -5,14 +5,15 @@ import { CheckpointError, readPendingSteerQueue, realApprovalOrgFact, remainingB
|
|
|
5
5
|
import { normalizePersistedRuleHit } from "../rule-lane-reads.js";
|
|
6
6
|
import { decidersNote, SETTLEMENT_NOBODY_JUDGED } from "../gate-outcome.js";
|
|
7
7
|
import { formatHookFeedback } from "../hooks.js";
|
|
8
|
-
import { classicEventBase, failedHandlerClause, screenUserPrompt } from "../mods/stations.js";
|
|
8
|
+
import { classicEventBase, failedHandlerClause, legEventsOf, openSubagent, screenUserPrompt } from "../mods/stations.js";
|
|
9
9
|
import { buildAppliedHumanInputEvent, buildHumanInputEvent, projectHumanInput } from "../human-input-projection.js";
|
|
10
10
|
import { humanInputAttachmentsOf, readObjectiveAttachments, userAttachmentDeclarations } from "../user-attachment.js";
|
|
11
11
|
import { readToolCallArguments, uuidv7 } from "../../internal/harness.js";
|
|
12
12
|
import { ORG_ADJUDICATION_TIMEOUT_MS, settleOrgVerdictWithin } from "../permission-rule-org.js";
|
|
13
13
|
import { applyPersistedTightening, disclosedRuleSet } from "../persisted-rule-arms.js";
|
|
14
14
|
import { argsReadBy, stampArgsReading } from "../effective-path-target.js";
|
|
15
|
-
import { skillRowRefusal } from "../skill-grant.js";
|
|
15
|
+
import { skillGrantBindingMembers, skillRowRefusal } from "../skill-grant.js";
|
|
16
|
+
import { requestGrantBinding } from "../skill-grant-binding.js";
|
|
16
17
|
import { judgeApprovalObject } from "../approval-object.js";
|
|
17
18
|
import { SKILL_TOOL_NAME } from "./synthetic-tools.js";
|
|
18
19
|
import { computeCostMicroUsd } from "../pricing.js";
|
|
@@ -53,7 +54,7 @@ import { thrownMarksOf } from "../thrown-value.js";
|
|
|
53
54
|
import { egressThrownText, egressValue } from "../untrusted-egress.js";
|
|
54
55
|
import { ruleSourcePhrase } from "../rule-denial-sentence.js";
|
|
55
56
|
export async function runLeg(input) {
|
|
56
|
-
const { spec, queue, prepared, resume, rs, entryActor, effectiveTimeoutMs, timeout, pushContent, ident, emitCommitted, writeFamilyOf, startedToolCallIds, announceWorkspaceMove, withBrainSinks, flushGitMirror, loopLatch, notificationLane, unsubscribeTaskNotifications, unsubGitRetry, unsubBoundary, unsub, runner, next } = input;
|
|
57
|
+
const { spec, queue, prepared, resume, rs, entryActor, operatorObjective, effectiveTimeoutMs, timeout, pushContent, ident, emitCommitted, writeFamilyOf, startedToolCallIds, announceWorkspaceMove, withBrainSinks, flushGitMirror, loopLatch, notificationLane, unsubscribeTaskNotifications, unsubGitRetry, unsubBoundary, unsub, runner, next } = input;
|
|
57
58
|
let final;
|
|
58
59
|
let threw;
|
|
59
60
|
let abortedLive = false;
|
|
@@ -305,28 +306,36 @@ export async function runLeg(input) {
|
|
|
305
306
|
const projectedObjective = projectHumanInput({ text: spec.objective, actor: objectiveActor, source: "objective" });
|
|
306
307
|
let effectiveObjective = projectedObjective;
|
|
307
308
|
let promptBlocked = false;
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
309
|
+
const objectiveEvents = legEventsOf(prepared.hookIdentity, operatorObjective);
|
|
310
|
+
if (objectiveEvents.screen !== undefined) {
|
|
311
|
+
const screen = await screenUserPrompt(prepared.modBus, {
|
|
312
|
+
...classicEventBase(prepared.hookIdentity, prepared.permissionMode.observed),
|
|
313
|
+
prompt: spec.objective,
|
|
314
|
+
source: "objective",
|
|
315
|
+
...(objectiveActor !== undefined ? { actor: snapshotActorAssertion(objectiveActor) } : {}),
|
|
316
|
+
...(prepared.userAttachments !== undefined ? { userAttachments: userAttachmentDeclarations(prepared.userAttachments) } : {}),
|
|
317
|
+
}, prepared.abortController.signal);
|
|
318
|
+
if (screen?.kind === "aborted") {
|
|
319
|
+
holdPrompt(prepared.blockedRef, prepared.reminderMark, "cancelled", `the task was cancelled while the deployment's userPromptSubmit hook was still screening this prompt; ` +
|
|
320
|
+
`the prompt was NOT submitted (fail-closed)`);
|
|
321
|
+
promptBlocked = true;
|
|
322
|
+
}
|
|
323
|
+
else if (screen?.kind === "failed") {
|
|
324
|
+
holdPrompt(prepared.blockedRef, prepared.reminderMark, screen.cause === "timeout" ? "timeout" : "crashed", `the deployment's userPromptSubmit hook ${failedHandlerClause(screen)} while screening this prompt; the prompt was NOT submitted (fail-closed)`);
|
|
325
|
+
promptBlocked = true;
|
|
326
|
+
}
|
|
327
|
+
else if (screen?.block) {
|
|
328
|
+
holdPrompt(prepared.blockedRef, prepared.reminderMark, "block", screen.block);
|
|
329
|
+
promptBlocked = true;
|
|
330
|
+
}
|
|
331
|
+
else if (screen?.additionalContext) {
|
|
332
|
+
effectiveObjective = `${formatHookFeedback(screen.additionalContext, prepared.reminderMark)}\n\n${projectedObjective}`;
|
|
333
|
+
}
|
|
327
334
|
}
|
|
328
|
-
|
|
329
|
-
|
|
335
|
+
if (objectiveEvents.start !== undefined && !promptBlocked) {
|
|
336
|
+
const start = await openSubagent(prepared.modBus, prepared.hookIdentity, prepared.permissionMode.observed, prepared.abortController.signal);
|
|
337
|
+
if (start?.additionalContext)
|
|
338
|
+
effectiveObjective = `${formatHookFeedback(start.additionalContext, prepared.reminderMark)}\n\n${effectiveObjective}`;
|
|
330
339
|
}
|
|
331
340
|
const objectiveInputId = uuidv7();
|
|
332
341
|
const { frames: attachmentFrames, chars: attachmentChars } = await readObjectiveAttachments(prepared, objectiveInputId, promptBlocked, { overlay: () => legContextOverlayOption(prepared, runner).contextOverlay, objectiveChars: effectiveObjective.length });
|
|
@@ -600,9 +609,9 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
600
609
|
occurrences.gateRound(pendingAction.toolCallId, decidedGate, frozenInputSnapshot(resolvedArgs));
|
|
601
610
|
let notExecuted = false;
|
|
602
611
|
const resultRow = (text, isError) => withRowNotExecuted(toolResultMsg(pendingAction.toolCallId, pendingAction.toolName, text, isError), notExecuted);
|
|
603
|
-
const settleEnd = async (isError, result, refusedBy, neverRan) => {
|
|
612
|
+
const settleEnd = async (isError, result, refusedBy, neverRan, extension) => {
|
|
604
613
|
if (refusedBy !== undefined)
|
|
605
|
-
occurrences.refuse(pendingAction.toolCallId, refusedBy);
|
|
614
|
+
occurrences.refuse(pendingAction.toolCallId, refusedBy, extension);
|
|
606
615
|
const settled = emitSettled(occurrences, callStart, { result, isError, ...(neverRan ? { notExecuted: true } : {}) }, { push: emit, structured: prepared.structuredProjector, mediaByteCapBytes: runner.deps.mediaByteCapBytes });
|
|
607
616
|
notExecuted = settled.notExecuted === true;
|
|
608
617
|
const gate = settled.gate ?? decidedGate;
|
|
@@ -648,7 +657,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
648
657
|
const screened = await prepared.approvedCallScreen?.({ toolCallId: pendingAction.toolCallId, toolName: pendingAction.toolName, args: structuredClone(resolvedArgs), decidedBy: outcome.hostDecision.decidedBy });
|
|
649
658
|
if (screened !== undefined && "refused" in screened) {
|
|
650
659
|
const hookDenial = formatHookFeedback(screened.refused, prepared.reminderMark);
|
|
651
|
-
await settleEnd(true, { content: hookDenial }, "hook");
|
|
660
|
+
await settleEnd(true, { content: hookDenial }, "hook", undefined, screened.extension);
|
|
652
661
|
emitCommitted(await prepared.session.appendMessage(resultRow(hookDenial, true)), "toolResult", pendingAction.toolCallId);
|
|
653
662
|
return;
|
|
654
663
|
}
|
|
@@ -663,7 +672,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
663
672
|
const executedArgs = rescreened !== undefined ? rescreened.args : resolvedArgs;
|
|
664
673
|
const unseen = !licenseCovers(pendingAction.boundInputHash, executedArgs);
|
|
665
674
|
let beltReading;
|
|
666
|
-
const beltReq = () => ({ toolName: pendingAction.toolName, args: executedArgs, toolCallId: pendingAction.toolCallId, ...callFaceSeat(beltFace()), budget: beltBudget, ...(prepared.cwdRef !== undefined ? { cwd: prepared.cwdRef.current } : {}), ...(prepared.handsRoot !== undefined ? { root: prepared.handsRoot } : {}), ...advertisedWritableRootsSeat(prepared.advertisedWritableDirs), ...exemptRootsSeat(prepared.exemptRoots), ...(beltReading !== undefined ? { targetReading: beltReading } : {}) });
|
|
675
|
+
const beltReq = () => ({ toolName: pendingAction.toolName, args: executedArgs, toolCallId: pendingAction.toolCallId, ...callFaceSeat(beltFace()), budget: beltBudget, ...(prepared.cwdRef !== undefined ? { cwd: prepared.cwdRef.current } : {}), ...(prepared.handsRoot !== undefined ? { root: prepared.handsRoot } : {}), ...advertisedWritableRootsSeat(prepared.advertisedWritableDirs), ...exemptRootsSeat(prepared.exemptRoots), ...(beltReading !== undefined ? { targetReading: beltReading } : {}), ...requestGrantBinding((call, args) => skillGrantBindingMembers(call, args, prepared.skillSpecs, SKILL_TOOL_NAME), pendingAction, executedArgs) });
|
|
667
676
|
const unjudgeable = unseen ? chainCannotJudge(resume.cp.state.inheritedGate) : undefined;
|
|
668
677
|
if (unjudgeable !== undefined) {
|
|
669
678
|
const chainDenial = formatHookFeedback(`The approved tool call "${pendingAction.toolName}" was not executed: its input changed after the approval and the inherited ancestor chain cannot judge the changed input (${unjudgeable}). This approval is spent — the call has to be re-issued.`, prepared.reminderMark);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { openSystemReminder } from "../reminder-mint.js";
|
|
2
2
|
import { formatHookFeedback } from "../hooks.js";
|
|
3
|
-
import { classicEventBase, dispatchClassic,
|
|
3
|
+
import { classicEventBase, dispatchClassic, legEventsOf, stringMembersAnswer, stringMembersOf } from "../mods/stations.js";
|
|
4
4
|
import { asThrownError } from "../thrown-value.js";
|
|
5
5
|
const STOP_HOOK_BLOCK_CAP = 8;
|
|
6
6
|
export function runStopAndFinalVerify(input) {
|
|
7
7
|
const { spec, prepared, queue, rs, stats, ident, walltimeMonotonicDeadline, runner } = input;
|
|
8
|
-
const stopEvent =
|
|
8
|
+
const stopEvent = legEventsOf(prepared.hookIdentity).stop;
|
|
9
9
|
const stopArmed = prepared.modBus.hasHandlers(stopEvent);
|
|
10
10
|
const finalVerificationOn = spec.finalVerification === true;
|
|
11
11
|
const finalVerifyBudgetFill = () => {
|
|
@@ -19,7 +19,7 @@ import type { Model } from "../../internal/llm.js";
|
|
|
19
19
|
import { type MaybeCompactOptions } from "../auto-compaction.js";
|
|
20
20
|
import type { SessionStore } from "../session.js";
|
|
21
21
|
import type { PushQueue } from "../push-queue.js";
|
|
22
|
-
import type
|
|
22
|
+
import { type Brain, type HeldUserInputs, type OwedUserInputAccount, type TaskEvent, type TaskSpec } from "../types.js";
|
|
23
23
|
import { type Stats } from "./assemble-result.js";
|
|
24
24
|
import type { EndOfTaskCompaction, Prepared, RunnerDepsSeat, RunState } from "./contracts.js";
|
|
25
25
|
import type { CallerStopGate } from "./caller-stop-gate.js";
|
|
@@ -61,10 +61,7 @@ export interface RunTerminalAdoptionInput<R> {
|
|
|
61
61
|
windowSafetyOptions: (mainModel: Model) => Pick<MaybeCompactOptions, "fallbackBudget" | "onWindowSafety">;
|
|
62
62
|
/** borrowed-readonly — the held agent_end account, as the read face on the identity lane's Result. */
|
|
63
63
|
undrainedUserAtEnd: {
|
|
64
|
-
readonly current:
|
|
65
|
-
steer: number;
|
|
66
|
-
followUp: number;
|
|
67
|
-
} | undefined;
|
|
64
|
+
readonly current: HeldUserInputs | undefined;
|
|
68
65
|
};
|
|
69
66
|
/** borrowed-readonly — did the run end with a person's steer / follow-up still pending (the identity lane's read face)? Folded
|
|
70
67
|
* into the answer-settled verdict this lane evaluates once. */
|
|
@@ -2,6 +2,7 @@ import { compactionFailureReason, compactionPassReport, DEFAULT_COMPACTION_INSTR
|
|
|
2
2
|
import { eventDefaultOn } from "../../prompt-assembly/event-registry.js";
|
|
3
3
|
import { appendInterruptionMarker, reconcileInterruptedSession } from "../session-reconcile.js";
|
|
4
4
|
import { emitTrace } from "../trace.js";
|
|
5
|
+
import { parkedInputIdsOf } from "../types.js";
|
|
5
6
|
import { answerSettled } from "./assemble-result.js";
|
|
6
7
|
import { errorCodeOf } from "./terminal-account.js";
|
|
7
8
|
import { awaitChargeWithSlowDisclosure, discloseUnevaluableWindow } from "./clock-and-limits.js";
|
|
@@ -79,6 +80,7 @@ export async function runTerminalAdoption(input) {
|
|
|
79
80
|
}
|
|
80
81
|
let migratedParked = { steer: 0, followUp: 0 };
|
|
81
82
|
let carriedContinuation = 0;
|
|
83
|
+
const carriedContinuationInputIds = [];
|
|
82
84
|
let carriedApproval = 0;
|
|
83
85
|
let approvalRefusal;
|
|
84
86
|
if (committedPause !== undefined && runner.deps.checkpointStore !== undefined) {
|
|
@@ -101,8 +103,11 @@ export async function runTerminalAdoption(input) {
|
|
|
101
103
|
carried.push(live);
|
|
102
104
|
else if (approval)
|
|
103
105
|
carriedApproval += 1;
|
|
104
|
-
else
|
|
106
|
+
else {
|
|
105
107
|
carriedContinuation += 1;
|
|
108
|
+
if (typeof input.inputId === "string")
|
|
109
|
+
carriedContinuationInputIds.push(input.inputId);
|
|
110
|
+
}
|
|
106
111
|
}
|
|
107
112
|
catch (parkErr) {
|
|
108
113
|
runner.deps.onError?.(asThrownError(parkErr), {
|
|
@@ -118,9 +123,10 @@ export async function runTerminalAdoption(input) {
|
|
|
118
123
|
break;
|
|
119
124
|
}
|
|
120
125
|
}
|
|
121
|
-
|
|
126
|
+
const dropped = prepared.harness.dropParkedUserInputs(carried);
|
|
127
|
+
migratedParked = { steer: dropped.steer, followUp: dropped.followUp, inputIds: parkedInputIdsOf(dropped.records) };
|
|
122
128
|
}
|
|
123
|
-
const owedUserInput = { held: undrainedUserAtEnd.current, migrated: migratedParked, continuation: { frames: prepared.undeliveredContinuationRef.current.parkedSteers.filter((f) => !isApprovalWordsFrame(f)), carried: carriedContinuation, approval: { owed: prepared.undeliveredContinuationRef.current.parkedSteers.filter(isApprovalWordsFrame).length, carried: carriedApproval, ...(approvalRefusal !== undefined ? { refusal: approvalRefusal } : {}) } } };
|
|
129
|
+
const owedUserInput = { held: undrainedUserAtEnd.current, migrated: migratedParked, continuation: { frames: prepared.undeliveredContinuationRef.current.parkedSteers.filter((f) => !isApprovalWordsFrame(f)), carried: carriedContinuation, carriedInputIds: carriedContinuationInputIds, approval: { owed: prepared.undeliveredContinuationRef.current.parkedSteers.filter(isApprovalWordsFrame).length, carried: carriedApproval, ...(approvalRefusal !== undefined ? { refusal: approvalRefusal } : {}) } } };
|
|
124
130
|
if (rs.attach.attachState?.postCompactPending === true && (rs.attach.attachmentsCfg?.backgroundTasks ?? eventDefaultOn("background_tasks")) === true) {
|
|
125
131
|
emitTrace(rs.telemetry.tracer, () => ({ kind: "compaction.announce_dropped", version: 1, taskId: rs.telemetry.taskId, ts: Date.now() }));
|
|
126
132
|
}
|