@sema-agent/core 7.72.0 → 7.74.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 +565 -0
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +46 -2
- package/dist/agents/list-agents-tool.js +1 -1
- package/dist/agents/parked-resume-drive.d.ts +10 -0
- package/dist/agents/parked-resume-drive.js +9 -0
- package/dist/agents/retain-ledger.d.ts +3 -0
- package/dist/agents/retain-ledger.js +3 -3
- package/dist/agents/send-message-tool.js +5 -4
- package/dist/agents/send-user-message-tool.d.ts +12 -0
- package/dist/agents/send-user-message-tool.js +67 -0
- package/dist/agents/subagent-steps.d.ts +9 -0
- package/dist/agents/subagent-steps.js +38 -0
- package/dist/agents/subagent.d.ts +2 -0
- package/dist/agents/subagent.js +43 -12
- package/dist/agents/verify.js +23 -8
- package/dist/agents/yield-adoption.js +3 -1
- package/dist/brain/anthropic.d.ts +42 -1
- package/dist/brain/anthropic.js +68 -13
- package/dist/brain/failover.d.ts +5 -0
- package/dist/brain/failover.js +51 -22
- package/dist/brain/model-lane.d.ts +12 -3
- package/dist/brain/model-lane.js +5 -5
- package/dist/brain/open-responses.js +7 -8
- package/dist/brain/openai.js +31 -24
- package/dist/brain/route-adjudicator.d.ts +33 -4
- package/dist/brain/route-adjudicator.js +49 -12
- package/dist/brain/stream-engine.js +166 -156
- package/dist/brain/stream-shared.d.ts +4 -3
- package/dist/brain/stream-shared.js +2 -2
- package/dist/core/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/allow-entry.js +4 -4
- package/dist/core/ask-class.d.ts +2 -2
- package/dist/core/ask-headline.d.ts +1 -1
- package/dist/core/ask-origin.d.ts +44 -4
- package/dist/core/ask-origin.js +29 -10
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -8
- package/dist/core/background-agent-store.d.ts +1 -0
- package/dist/core/background-agent-store.js +49 -8
- package/dist/core/checkpoint-features.d.ts +3 -2
- package/dist/core/checkpoint-features.js +1 -1
- package/dist/core/checkpoint-rekey.d.ts +1 -1
- package/dist/core/checkpoint-rekey.js +6 -1
- package/dist/core/checkpoint-requirements.d.ts +23 -3
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -1
- package/dist/core/checkpoint-row-verdict.js +9 -3
- package/dist/core/checkpoint-store.d.ts +26 -2
- package/dist/core/checkpoint-store.js +9 -2
- package/dist/core/child-clamp-seats.d.ts +15 -0
- package/dist/core/child-clamp-seats.js +15 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/cron.js +9 -1
- package/dist/core/delegation-frames.d.ts +1 -0
- package/dist/core/delegation-frames.js +1 -1
- package/dist/core/deployment-shape.d.ts +7 -0
- package/dist/core/deployment-shape.js +19 -0
- package/dist/core/engine-capabilities.d.ts +13 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +41 -28
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +19 -7
- package/dist/core/entries-not-applied.js +33 -1
- package/dist/core/gate-fold.js +5 -4
- package/dist/core/gate-lanes.js +8 -12
- package/dist/core/gate-outcome.d.ts +8 -2
- package/dist/core/gate-outcome.js +10 -3
- package/dist/core/governance-codes.d.ts +14 -2
- package/dist/core/governance-codes.js +22 -6
- package/dist/core/hook-condition.d.ts +37 -0
- package/dist/core/hook-condition.js +567 -0
- package/dist/core/hooks.d.ts +5 -0
- package/dist/core/hooks.js +1 -0
- package/dist/core/host-instance.d.ts +23 -0
- package/dist/core/host-instance.js +69 -0
- package/dist/core/instruction-preview.d.ts +63 -0
- package/dist/core/instruction-preview.js +406 -0
- package/dist/core/leg-budget.d.ts +26 -0
- package/dist/core/leg-budget.js +9 -0
- package/dist/core/leg-identity.d.ts +51 -1
- package/dist/core/leg-identity.js +45 -2
- package/dist/core/manager-launch-check.d.ts +48 -0
- package/dist/core/manager-launch-check.js +64 -0
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-injection-drop.d.ts +20 -10
- package/dist/core/mcp-injection-drop.js +9 -3
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/member-outcome.d.ts +3 -2
- package/dist/core/member-outcome.js +1 -1
- package/dist/core/memory-engine/deletion-record.d.ts +46 -0
- package/dist/core/memory-engine/deletion-record.js +96 -0
- package/dist/core/memory-engine/engine.js +24 -16
- package/dist/core/memory-engine/file-backend.js +7 -5
- package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
- package/dist/core/memory-engine/projection-ledger.js +1 -1
- package/dist/core/memory-engine/scope-contract.d.ts +18 -13
- package/dist/core/memory-engine/scope-contract.js +18 -18
- package/dist/core/memory-engine/sync-client.js +26 -6
- package/dist/core/memory-engine/sync.d.ts +20 -2
- package/dist/core/memory-engine/sync.js +18 -17
- package/dist/core/mode-policy.d.ts +25 -6
- package/dist/core/mode-policy.js +33 -8
- package/dist/core/model-seat.d.ts +8 -5
- package/dist/core/model-shell.d.ts +129 -0
- package/dist/core/model-shell.js +249 -0
- package/dist/core/mods/kernel/digest.d.ts +4 -0
- package/dist/core/mods/kernel/digest.js +5 -0
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +15 -6
- package/dist/core/mods/kernel/events.d.ts +21 -5
- package/dist/core/mods/kernel/events.js +19 -10
- package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
- package/dist/core/mods/kernel/hash-mirror.js +55 -0
- package/dist/core/mods/kernel/index.d.ts +1 -0
- package/dist/core/mods/kernel/index.js +1 -0
- package/dist/core/mods/kernel/package-reader.d.ts +48 -0
- package/dist/core/mods/kernel/package-reader.js +149 -0
- package/dist/core/mods/kernel/site-rules.d.ts +4 -0
- package/dist/core/mods/kernel/site-rules.js +13 -0
- package/dist/core/mods/package.d.ts +7 -3
- package/dist/core/mods/package.js +47 -80
- package/dist/core/own-property-receipt.js +11 -4
- package/dist/core/parent-spec-seat.d.ts +13 -11
- package/dist/core/parent-spec-seat.js +13 -9
- package/dist/core/peer-seat.js +3 -3
- package/dist/core/peer-task-store.d.ts +365 -0
- package/dist/core/peer-task-store.js +682 -0
- package/dist/core/permission-rule-consent.js +6 -11
- package/dist/core/permission-rule-model.d.ts +27 -0
- package/dist/core/permission-rule-model.js +33 -5
- package/dist/core/permission-rule-org.js +13 -3
- package/dist/core/permission-rule-provider.d.ts +35 -33
- package/dist/core/permission-rule-provider.js +38 -295
- package/dist/core/permission-rule-store.d.ts +181 -8
- package/dist/core/permission-rule-store.js +420 -17
- package/dist/core/permission-rule-sync.js +15 -1
- package/dist/core/permission-rules.js +4 -1
- package/dist/core/project-seat.d.ts +55 -0
- package/dist/core/project-seat.js +96 -0
- package/dist/core/protocol-http-auth.d.ts +3 -2
- package/dist/core/protocol-http-auth.js +26 -18
- package/dist/core/remote-env.d.ts +4 -4
- package/dist/core/retain-seat.d.ts +42 -0
- package/dist/core/retain-seat.js +76 -0
- package/dist/core/retired-keys.js +1 -0
- package/dist/core/rewind-refusal-codes.d.ts +8 -0
- package/dist/core/rewind-refusal-codes.js +12 -0
- package/dist/core/roles.d.ts +2 -2
- package/dist/core/roles.js +15 -1
- package/dist/core/rule-offer-read.d.ts +1 -1
- package/dist/core/rule-offer-read.js +32 -4
- package/dist/core/rule-store-fault.d.ts +9 -7
- package/dist/core/rule-store-fault.js +8 -3
- package/dist/core/run-ledger-seat.d.ts +66 -0
- package/dist/core/run-ledger-seat.js +70 -0
- package/dist/core/run-ledger.d.ts +332 -0
- package/dist/core/run-ledger.js +550 -0
- package/dist/core/runner/checkpoint-scope.d.ts +14 -3
- package/dist/core/runner/checkpoint-scope.js +16 -6
- package/dist/core/runner/compact-session.js +1 -1
- package/dist/core/runner/construction-doors.js +8 -0
- package/dist/core/runner/contracts.d.ts +21 -5
- package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
- package/dist/core/runner/cross-boundary-lane.js +4 -0
- package/dist/core/runner/delegation-owner.d.ts +30 -0
- package/dist/core/runner/delegation-owner.js +20 -4
- package/dist/core/runner/finish-reason-seat.js +4 -2
- package/dist/core/runner/gate-exit.d.ts +7 -0
- package/dist/core/runner/gate-exit.js +2 -1
- package/dist/core/runner/leg-frame.js +3 -0
- package/dist/core/runner/model-lane-seat.d.ts +3 -0
- package/dist/core/runner/model-lane-seat.js +4 -0
- package/dist/core/runner/nested-memory-lane.d.ts +22 -5
- package/dist/core/runner/nested-memory-lane.js +91 -30
- package/dist/core/runner/person-path-rows.d.ts +27 -16
- package/dist/core/runner/person-path-rows.js +93 -15
- package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
- package/dist/core/runner/prepare-config-doors.d.ts +1 -0
- package/dist/core/runner/prepare-config-doors.js +13 -7
- package/dist/core/runner/prepare-context-lane.js +1 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +6 -0
- package/dist/core/runner/prepare-execution-env.d.ts +3 -3
- package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
- package/dist/core/runner/prepare-gate-stations.js +3 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
- package/dist/core/runner/prepare-hands-readface.js +15 -3
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
- package/dist/core/runner/prepare-inherited-gate.js +13 -5
- package/dist/core/runner/prepare-offload-wrappers.js +1 -1
- package/dist/core/runner/prepare-run-refs.d.ts +1 -1
- package/dist/core/runner/prepare-run-refs.js +3 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
- package/dist/core/runner/prepare-suspend-saga.js +4 -2
- package/dist/core/runner/prepare-task.js +42 -30
- package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
- package/dist/core/runner/prepare-wiring-manifest.js +8 -6
- package/dist/core/runner/resume-apply.js +11 -5
- package/dist/core/runner/resume-policy-outcome.js +5 -2
- package/dist/core/runner/resume-review-outcome.d.ts +3 -0
- package/dist/core/runner/resume-review-outcome.js +24 -1
- package/dist/core/runner/role-seat-defaulted.d.ts +3 -3
- package/dist/core/runner/role-seat-defaulted.js +1 -1
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
- package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
- package/dist/core/runner/run-harness-handlers.js +4 -1
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +5 -2
- package/dist/core/runner/run-notification-lane.js +20 -1
- package/dist/core/runner/run-settle-and-teardown.js +21 -12
- package/dist/core/runner/run-stop-and-final-verify.js +6 -0
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/runtask.d.ts +6 -2
- package/dist/core/runner/runtask.js +21 -9
- package/dist/core/runner/shell-env-withheld.d.ts +6 -4
- package/dist/core/runner/shell-env-withheld.js +25 -3
- package/dist/core/runner/stop-tail-notice.d.ts +10 -2
- package/dist/core/runner/stop-tail-notice.js +9 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/sub-agent-deny-lists.js +9 -5
- package/dist/core/runner/task-start-doors.js +6 -3
- package/dist/core/runner/terminal-account.d.ts +6 -1
- package/dist/core/runner/terminal-account.js +16 -1
- package/dist/core/runner/tool-end-body.d.ts +1 -1
- package/dist/core/runner/tool-not-executed.d.ts +27 -8
- package/dist/core/runner/tool-not-executed.js +22 -11
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner/write-protection-station.d.ts +1 -1
- package/dist/core/runner/write-protection-station.js +1 -1
- package/dist/core/runner-deps.d.ts +17 -10
- package/dist/core/secret-env.d.ts +61 -37
- package/dist/core/secret-env.js +49 -49
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +1 -0
- package/dist/core/session-store.d.ts +12 -6
- package/dist/core/session-store.js +26 -6
- package/dist/core/session.d.ts +31 -8
- package/dist/core/shell-read-silence.d.ts +40 -2
- package/dist/core/shell-read-silence.js +23 -4
- package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
- package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
- package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/session-store-contract.js +87 -3
- package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
- package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
- package/dist/core/task-event.d.ts +14 -7
- package/dist/core/task-notification.d.ts +96 -10
- package/dist/core/task-notification.js +135 -6
- package/dist/core/task-registry-agent.d.ts +1 -0
- package/dist/core/task-registry-agent.js +1 -1
- package/dist/core/task-registry-shared.d.ts +12 -1
- package/dist/core/task-registry-shared.js +3 -1
- package/dist/core/task-registry-workflow.d.ts +1 -1
- package/dist/core/task-registry-workflow.js +9 -1
- package/dist/core/task-registry.d.ts +40 -2
- package/dist/core/task-registry.js +80 -15
- package/dist/core/task-result.d.ts +18 -3
- package/dist/core/task-spec-members.d.ts +3 -1
- package/dist/core/task-spec-members.js +19 -3
- package/dist/core/task-spec.d.ts +48 -22
- package/dist/core/tool-catalog-entries.js +2 -0
- package/dist/core/tool-gate-phase.d.ts +6 -3
- package/dist/core/tool-gate-phase.js +1 -0
- package/dist/core/tool-mount-facts.d.ts +8 -4
- package/dist/core/tool-mount-facts.js +7 -2
- package/dist/core/tool-mount-plan.d.ts +3 -1
- package/dist/core/tool-mount-plan.js +10 -3
- package/dist/core/tool-mount-static.d.ts +1 -1
- package/dist/core/tool-mount-static.js +4 -2
- package/dist/core/tool-result-store.d.ts +56 -3
- package/dist/core/tool-result-store.js +219 -25
- package/dist/core/tool-spec.d.ts +9 -2
- package/dist/core/trace.d.ts +3 -3
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +14 -7
- package/dist/core/wiring-manifest.d.ts +26 -20
- package/dist/core/wiring-manifest.js +7 -3
- package/dist/core/workflow-journal-store.d.ts +53 -10
- package/dist/core/workflow-journal-store.js +27 -4
- package/dist/core/workflow-run-store-contract.js +16 -0
- package/dist/core/workflow-run-store.d.ts +9 -7
- package/dist/core/workflow-run-store.js +4 -1
- package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
- package/dist/engine/execution-env/node-execution-env.js +227 -13
- package/dist/engine/harness/types.d.ts +49 -1
- package/dist/engine/harness/types.js +10 -0
- package/dist/engine/llm/types.d.ts +13 -7
- package/dist/engine/llm/validation.d.ts +8 -1
- package/dist/engine/llm/validation.js +31 -2
- package/dist/engine/lsp/node-lsp-manager.js +2 -1
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +15 -2
- package/dist/engine/session/session.js +34 -4
- package/dist/host-env.d.ts +10 -0
- package/dist/host-env.js +1 -0
- package/dist/index.d.ts +28 -9
- package/dist/index.js +22 -6
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/orchestration/goal.js +1 -1
- package/dist/orchestration/run-workflow-tool.js +40 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
- package/dist/orchestration/workflow-park-adoption.js +47 -12
- package/dist/orchestration/workflow-primitives.js +10 -1
- package/dist/orchestration/workflow-script-runner.d.ts +2 -2
- package/dist/orchestration/workflow-stop.d.ts +128 -0
- package/dist/orchestration/workflow-stop.js +156 -0
- package/dist/orchestration/workflow.d.ts +31 -7
- package/dist/orchestration/workflow.js +119 -57
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- package/dist/shell/lex.d.ts +2 -2
- package/dist/shell/lex.js +1 -1
- package/dist/stores/file/permission-rule-store.d.ts +3 -1
- package/dist/stores/file/permission-rule-store.js +0 -1
- package/dist/stores/file/workflow-journal-store.d.ts +16 -3
- package/dist/stores/file/workflow-journal-store.js +93 -5
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/tools/fs/bash-model-shell.d.ts +23 -0
- package/dist/tools/fs/bash-model-shell.js +25 -0
- package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
- package/dist/tools/fs/bash-readonly-classifier.js +3 -0
- package/dist/tools/fs/file-write-check.js +9 -3
- package/dist/tools/fs/fs-bash.js +13 -11
- package/dist/tools/fs/index.d.ts +8 -7
- package/dist/tools/fs/index.js +4 -4
- package/dist/tools/fs/read-deny-home.d.ts +1 -1
- package/dist/tools/fs/read-deny-home.js +5 -5
- package/dist/tools/fs/read-deny.d.ts +33 -8
- package/dist/tools/fs/read-deny.js +114 -25
- package/dist/tools/fs/safety.d.ts +4 -1
- package/dist/tools/fs/safety.js +4 -2
- package/dist/tools/fs/shell-read-argv.js +1 -0
- package/dist/tools/fs/shell-read-check.d.ts +9 -2
- package/dist/tools/fs/shell-read-check.js +134 -22
- package/dist/tools/fs/shell-read-establish.d.ts +9 -0
- package/dist/tools/fs/shell-read-establish.js +21 -11
- package/dist/tools/fs/shell-read-judge.d.ts +13 -1
- package/dist/tools/fs/shell-read-judge.js +26 -7
- package/dist/tools/fs/shell-read-plan.d.ts +7 -3
- package/dist/tools/fs/shell-read-plan.js +8 -5
- package/dist/tools/fs/shell-read-word.d.ts +8 -0
- package/dist/tools/fs/shell-read-word.js +13 -4
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/dist/tools/monitor.js +12 -8
- package/dist/tools/scheduler-tools.d.ts +1 -0
- package/dist/tools/scheduler-tools.js +5 -2
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +192 -3
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/core@7.74.0.json +68 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/primitives@7.74.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core-stores-sql@7.74.0.json +143 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/core@7.74.0.json +2210 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/mods-kernel@7.74.0.json +421 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/primitives@7.74.0.json +174 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
- package/wire-changes/wiki-gate@7.74.0.json +145 -0
|
@@ -35,7 +35,7 @@ import { reviewSubjectOf } from "../agents/delegation-review-faces.js";
|
|
|
35
35
|
import { OUTPUT_TOOL_NAME, TOOL_CATALOG_ENTRIES } from "../core/tool-catalog-entries.js";
|
|
36
36
|
import { readDelegationReview } from "../core/classifier-unavailable-arm.js";
|
|
37
37
|
import { judgeHostToolCeiling, refuseUnusableDefinition } from "../core/runner/sub-agent-deny-lists.js";
|
|
38
|
-
import { definitionSelectorLayer,
|
|
38
|
+
import { announceShadowedDefinitionServers, definitionSelectorLayer, mergeDefinitionServers } from "../agents/inherited-tool-pool.js";
|
|
39
39
|
import { isToolSelectorLayer } from "../agents/tool-filter.js";
|
|
40
40
|
import { legRetiredNameView, selectorLayerUnderView } from "../core/tool-name-aliases.js";
|
|
41
41
|
import { snapshotToolNameList } from "../core/tool-name-list.js";
|
|
@@ -47,7 +47,8 @@ import { callerPlacementSeats } from "../core/runner/child-tree.js";
|
|
|
47
47
|
import { judgedOwnerSeat } from "../core/runner/delegation-owner.js";
|
|
48
48
|
import { WorkflowBudgetExceededError, WorkflowNestingError, WorkflowAgentBlockedError, WorkflowAgentParkedError, WorkflowAgentSchemaError, WorkflowAgentStalledError, WorkflowMaxAgentsError, WORKFLOW_SPAWN_BLOCKED_ERROR_CODE, WORKFLOW_AGENT_OUTLIVED_RUN_CODE, PARK_NOT_PENDING_STATUSES, WORKFLOW_AGENT_PARKED_ERROR_CODE, WORKFLOW_STORE_WAIT_BOUND_MS, firstFailedAgentCodeOf, parkHolderAmong, runParkedOf, workflowRowStatusOf } from "./workflow-types.js";
|
|
49
49
|
import { memberOutcomeOf, memberRefusalsOf } from "../core/member-outcome.js";
|
|
50
|
-
import { CLAIM_REMAINING_UNREADABLE_NOTE, claimRemainingOf, isAnswerRecordClaimHolder, readWorkflowRunTreeWithin, runThatDrove, storeErrorClassOf, workflowLineForkReason, workflowLineTailOf, workflowParkDecisionOf, workflowRunChildrenIn, workflowRunInTree, workflowRunsBelow, workflowRunTreeOfOne, WORKFLOW_TREE_OVER_BOUND_REASON } from "./workflow-park-adoption.js";
|
|
50
|
+
import { CLAIM_REMAINING_UNREADABLE_NOTE, claimRemainingOf, isAnswerRecordClaimHolder, parkBindingFault, readWorkflowRunTreeWithin, runThatDrove, sameClaimKeys, storeErrorClassOf, workflowClaimKeysOf, workflowLineForkReason, workflowLineTailOf, workflowParkDecisionOf, workflowRunChildrenIn, workflowRunInTree, workflowRunsBelow, workflowRunTreeOfOne, WORKFLOW_TREE_OVER_BOUND_REASON } from "./workflow-park-adoption.js";
|
|
51
|
+
import { dropLocalClaimHolder, holdLocalWorkflowRun, noteLocalClaimHolder, readWorkflowStopper, stopWorkflowTree } from "./workflow-stop.js";
|
|
51
52
|
import { WorkflowScriptError } from "./workflow-meta.js";
|
|
52
53
|
import { firstByteLaneKnobMs, STALL_FIRST_BYTE_MS, STALL_FIRST_TOKEN_MS } from "../brain/timeout.js";
|
|
53
54
|
import { asThrownError, codedRefusal, isErrorLike, readMember, thrownIs, thrownName, thrownText } from "../core/thrown-value.js";
|
|
@@ -69,7 +70,6 @@ const MAX_ACTIVITY = 30;
|
|
|
69
70
|
const MAX_REVIEWED_SCHEMA_BYTES = 4096;
|
|
70
71
|
const MAX_REVIEW_REASON_CHARS = 500;
|
|
71
72
|
const MAX_REVIEWED_PROMPT_CHARS = 2_000;
|
|
72
|
-
const MAX_MEMBER_STOPPER_CHARS = 256;
|
|
73
73
|
const MAX_SCHEMA_WALK_DEPTH = 32;
|
|
74
74
|
function isUsableSchema(v) {
|
|
75
75
|
if (v === true)
|
|
@@ -157,13 +157,18 @@ export function applyWorkflowAgentType(spec, agentType, registry) {
|
|
|
157
157
|
if (out.memoryPersistenceCapable === undefined && def.memoryPersistenceCapable !== undefined)
|
|
158
158
|
out.memoryPersistenceCapable = def.memoryPersistenceCapable;
|
|
159
159
|
const ownServers = def.mcp;
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
let droppedMcp;
|
|
161
|
+
if (ownServers !== undefined && ownServers.length > 0) {
|
|
162
|
+
const merged = mergeDefinitionServers(out.mcp !== undefined ? snapshotAndValidateMcpEntries(out.mcp) : undefined, ownServers);
|
|
163
|
+
out.mcp = merged.servers;
|
|
164
|
+
if (merged.dropped.length > 0)
|
|
165
|
+
droppedMcp = merged.dropped;
|
|
166
|
+
}
|
|
162
167
|
const lists = { allowTools: snapshotToolNameList(def.allowTools), denyTools: snapshotToolNameList(def.denyTools) };
|
|
163
168
|
if (lists.allowTools == null && lists.denyTools == null)
|
|
164
|
-
return { spec: out, agentType: def.name };
|
|
169
|
+
return { spec: out, agentType: def.name, ...(droppedMcp !== undefined ? { droppedMcp } : {}) };
|
|
165
170
|
refuseUnusableDefinition(def.name, lists);
|
|
166
|
-
return { spec: out, agentType: def.name, definitionToolLists: { agentType: def.name, layer: definitionSelectorLayer({ ...lists, ...(ownServers !== undefined ? { mcp: ownServers } : {}) }) } };
|
|
171
|
+
return { spec: out, agentType: def.name, definitionToolLists: { agentType: def.name, layer: definitionSelectorLayer({ ...lists, ...(ownServers !== undefined ? { mcp: ownServers } : {}) }) }, ...(droppedMcp !== undefined ? { droppedMcp } : {}) };
|
|
167
172
|
}
|
|
168
173
|
export function workflowAgentRegistry(opts) {
|
|
169
174
|
const deployment = (opts.agents ?? []).map(snapshotDefinitionLists);
|
|
@@ -340,6 +345,22 @@ function runStoreUnreadableRefusal(fromRunId, cause) {
|
|
|
340
345
|
const what = cause === undefined ? `no answer within ${WORKFLOW_STORE_WAIT_BOUND_MS}ms, or records that name each other in a loop` : storeErrorClassOf(cause.err);
|
|
341
346
|
return new WorkflowParkRefusal("workflow.park_truth_unreadable", `startWorkflow: resume from "${fromRunId}" was REFUSED — the prior run's record, or that of a run it was resumed from, could not be read from the run store (${what}), so its parks cannot be proven.`, { reason: "store_threw" });
|
|
342
347
|
}
|
|
348
|
+
function claimRefusalOf(what, decision) {
|
|
349
|
+
if (decision.stopped !== undefined) {
|
|
350
|
+
return new Error(`startWorkflow: ${what} was REFUSED — the workflow was stopped (workflow_stopped, by ${clampRunIdText(decision.stopped.by)}): no run of it starts another step. Nothing ran; to run the work again, start the workflow again.`);
|
|
351
|
+
}
|
|
352
|
+
const forAnswer = isAnswerRecordClaimHolder(decision.holder);
|
|
353
|
+
const holder = decision.holder !== undefined && !forAnswer ? clampRunIdText(decision.holder) : "";
|
|
354
|
+
const lapse = decision.lapse;
|
|
355
|
+
return new Error(`startWorkflow: ${what} was REFUSED — ` +
|
|
356
|
+
(forAnswer
|
|
357
|
+
? "another leg of the workflow holds the resume claim on it for a moment, to record a person's answer to continuing it (no run holds it): resume again once it gives the claim back. If that leg's process stopped without giving the claim back, "
|
|
358
|
+
: `another run already holds the resume claim on it${holder ? ` (holder: ${holder})` : " (holder unknown to the store)"}. ` +
|
|
359
|
+
"Two concurrent resumes of one source run fork its execution: both replay the same prefix and then " +
|
|
360
|
+
"re-run the whole suffix live, duplicating every side effect. Wait for the holder to reach a terminal " +
|
|
361
|
+
"state (or stop it) and resume again. If the holder's process stopped without giving the claim back, ") +
|
|
362
|
+
`the claim lapses ${lapse?.kind === "at" ? `at ${new Date(lapse.at).toISOString()} at the latest` : `when the journal store's expiry frees it${lapse?.kind === "unreadable" ? ` (${CLAIM_REMAINING_UNREADABLE_NOTE})` : ""}`}, and the same resume goes through then.`);
|
|
363
|
+
}
|
|
343
364
|
function journalStoreClaimRefusal(fromRunId, err) {
|
|
344
365
|
return new WorkflowParkRefusal("workflow.park_truth_unreadable", `startWorkflow: resume from "${fromRunId}" was REFUSED — the journal store threw while the workflow's resume claim was taken (${storeErrorClassOf(err)}), so nothing guards the resume against another one; nothing ran. Resume again once the journal store answers.`, { reason: "store_threw" });
|
|
345
366
|
}
|
|
@@ -601,9 +622,14 @@ export const workflowResumeClaimFallback = {
|
|
|
601
622
|
table.delete(key);
|
|
602
623
|
},
|
|
603
624
|
};
|
|
604
|
-
export function takeWorkflowResumeClaim(store, input) {
|
|
625
|
+
export function takeWorkflowResumeClaim(store, input, carriesDecision = false) {
|
|
626
|
+
const noted = (v) => {
|
|
627
|
+
if (v.granted)
|
|
628
|
+
noteLocalClaimHolder(input.newRunId, carriesDecision);
|
|
629
|
+
return v;
|
|
630
|
+
};
|
|
605
631
|
if (store.resumeClaim === undefined)
|
|
606
|
-
return Promise.resolve({ ...workflowResumeClaimFallback.acquire(store, input), fallback: true });
|
|
632
|
+
return Promise.resolve(noted({ ...workflowResumeClaimFallback.acquire(store, input), fallback: true }));
|
|
607
633
|
let asked;
|
|
608
634
|
try {
|
|
609
635
|
asked = Promise.resolve(store.resumeClaim(input));
|
|
@@ -614,10 +640,37 @@ export function takeWorkflowResumeClaim(store, input) {
|
|
|
614
640
|
return asked
|
|
615
641
|
.then((v) => {
|
|
616
642
|
const granted = Boolean(v.granted);
|
|
617
|
-
|
|
643
|
+
const by = granted ? undefined : v.stopped?.by;
|
|
644
|
+
return noted({ granted, ...(v.holder !== undefined ? { holder: v.holder } : {}), ...(granted ? {} : { lapse: claimRemainingOf(v, Date.now()) }), ...(typeof by === "string" ? { stopped: { by } } : {}), fallback: false });
|
|
618
645
|
});
|
|
619
646
|
}
|
|
647
|
+
export async function takeWorkflowResumeClaims(store, keys, newRunId, scope, carriesDecision = false) {
|
|
648
|
+
const taken = [];
|
|
649
|
+
const giveBack = () => Promise.all(taken.map((t) => releaseWorkflowResumeClaim(store, t.input, t.fallback)));
|
|
650
|
+
let last = { granted: true, fallback: store.resumeClaim === undefined };
|
|
651
|
+
for (const sourceRunId of keys) {
|
|
652
|
+
const input = { sourceRunId, newRunId, scope };
|
|
653
|
+
try {
|
|
654
|
+
last = await takeWorkflowResumeClaim(store, input, carriesDecision);
|
|
655
|
+
}
|
|
656
|
+
catch (err) {
|
|
657
|
+
await giveBack();
|
|
658
|
+
throw err;
|
|
659
|
+
}
|
|
660
|
+
if (!last.granted) {
|
|
661
|
+
await giveBack();
|
|
662
|
+
return last;
|
|
663
|
+
}
|
|
664
|
+
taken.push({ input, fallback: last.fallback });
|
|
665
|
+
}
|
|
666
|
+
return last;
|
|
667
|
+
}
|
|
668
|
+
export async function releaseWorkflowResumeClaims(store, keys, newRunId, scope, fallback) {
|
|
669
|
+
for (const sourceRunId of keys)
|
|
670
|
+
await releaseWorkflowResumeClaim(store, { sourceRunId, newRunId, scope }, fallback);
|
|
671
|
+
}
|
|
620
672
|
export async function releaseWorkflowResumeClaim(store, input, fallback) {
|
|
673
|
+
dropLocalClaimHolder(input.newRunId);
|
|
621
674
|
if (fallback)
|
|
622
675
|
return workflowResumeClaimFallback.release(store, input);
|
|
623
676
|
try {
|
|
@@ -1162,7 +1215,7 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
|
|
|
1162
1215
|
return observed;
|
|
1163
1216
|
};
|
|
1164
1217
|
const journalStore = opts.journalStore;
|
|
1165
|
-
|
|
1218
|
+
const resumeClaims = [];
|
|
1166
1219
|
const replayByOrdinal = [];
|
|
1167
1220
|
let divergence;
|
|
1168
1221
|
const recordedOrdinalOfPosition = new Map();
|
|
@@ -1490,8 +1543,9 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
|
|
|
1490
1543
|
const withoutToken = (text, token) => (token === "" ? text : text.split(token).join("<token>"));
|
|
1491
1544
|
const parkBindingBroken = (ordinal, why) => new WorkflowParkRefusal("workflow.park_binding_broken", `workflow resume: ordinal ${ordinal}'s park cannot be bound to its checkpoint (${why}) — the recorded park is inconsistent. Decide the checkpoint through the deployment's approval channel and start a fresh run.`, { ordinal });
|
|
1492
1545
|
const readParkTruth = async (seat, key, ordinal) => {
|
|
1493
|
-
|
|
1494
|
-
|
|
1546
|
+
const keyFault = parkBindingFault(key);
|
|
1547
|
+
if (keyFault !== undefined)
|
|
1548
|
+
throw parkBindingBroken(ordinal, keyFault);
|
|
1495
1549
|
const read = await finalizeWithin(timers, new Promise((resolve) => resolve(seat.get(key.token))).then((cp) => ({ cp }), (err) => ({ err })), "timeout");
|
|
1496
1550
|
if (read === "timeout" || "err" in read) {
|
|
1497
1551
|
throw new WorkflowParkRefusal("workflow.park_truth_unreadable", `workflow resume: ordinal ${ordinal} is recorded as PARKED and its checkpoint could not be read from the checkpoint store (${read === "timeout" ? `the read did not settle within ${WORKFLOW_STORE_WAIT_BOUND_MS}ms` : withoutToken(errText(read.err), key.token)}); the resume is refused rather than run beside a pinned child.`, { reason: "checkpoint_store_threw" });
|
|
@@ -1499,10 +1553,9 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
|
|
|
1499
1553
|
const cp = read.cp;
|
|
1500
1554
|
if (cp === null)
|
|
1501
1555
|
return { kind: "not_pending", key, status: "absent" };
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
throw parkBindingBroken(ordinal, "the checkpoint belongs to another session than the parked row");
|
|
1556
|
+
const rowFault = parkBindingFault(key, cp);
|
|
1557
|
+
if (rowFault !== undefined)
|
|
1558
|
+
throw parkBindingBroken(ordinal, rowFault);
|
|
1506
1559
|
if (cp.status !== "pending")
|
|
1507
1560
|
return { kind: "not_pending", key, status: cp.status, ...(cp.checkpointId !== undefined ? { checkpointId: cp.checkpointId } : {}) };
|
|
1508
1561
|
return { kind: "pending", key, cp };
|
|
@@ -2771,6 +2824,8 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
|
|
|
2771
2824
|
if (inheritedModelError !== undefined)
|
|
2772
2825
|
throw inheritedModelError;
|
|
2773
2826
|
const typed = applyWorkflowAgentType(spec, agentOpts.agentType, agentRegistry);
|
|
2827
|
+
if (typed.droppedMcp !== undefined)
|
|
2828
|
+
announceShadowedDefinitionServers({ runner, leg: bornChildSessionId, root: spawnAttribution, agent: typed.agentType, dropped: typed.droppedMcp });
|
|
2774
2829
|
const typedSpec0 = typed.spec;
|
|
2775
2830
|
const typedSpec = withWorkflowChildSeats(typedSpec0, inheritedModelSnap, inheritedThinkingSnap, runnerRoleMap(runner));
|
|
2776
2831
|
const seatedSpec = applyParentSpecSeat(withWorkflowChildPersona(typedSpec, agentOpts.schema ?? typedSpec.outputSchema), opts.parentSpecSeat);
|
|
@@ -2790,7 +2845,7 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
|
|
|
2790
2845
|
opts.onForwardEvent(e.type === "task_progress" || e.type === "task_started" ? memberStamp(e, callKey, label) : e);
|
|
2791
2846
|
}
|
|
2792
2847
|
: undefined;
|
|
2793
|
-
const baseInternals = { ...parkGapInherit(seatedSpec), ...(agentOpts.isolation ? { isolation: agentOpts.isolation } : {}), ...(opts.parentCwd !== undefined ? { parentCwd: opts.parentCwd } : {}), ...(opts.parentSpecSeat?.
|
|
2848
|
+
const baseInternals = { ...parkGapInherit(seatedSpec), ...(agentOpts.isolation ? { isolation: agentOpts.isolation } : {}), ...(opts.parentCwd !== undefined ? { parentCwd: opts.parentCwd } : {}), ...(opts.parentSpecSeat?.project !== undefined ? { parentProject: opts.parentSpecSeat.project } : {}), ...callerPlacementSeats(opts.parentCwd, opts.callerRoot), ...spawnAttribution, ...definitionSeats(typed), ...(await captureFloorSeatsNow()), ...(enrichedForward !== undefined ? { onForwardEvent: enrichedForward } : {}), delegationTaskType: "workflow", spendParent: memberSpendParent, agentName: label, ...memberSeat(callKey, label), onWorkspaceResolved: createWorkspaceObserver(rec) };
|
|
2794
2849
|
let attempts = 0;
|
|
2795
2850
|
let throttleRetried = false;
|
|
2796
2851
|
let throttleFirst;
|
|
@@ -3237,6 +3292,8 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
|
|
|
3237
3292
|
if (inheritedModelError !== undefined)
|
|
3238
3293
|
throw inheritedModelError;
|
|
3239
3294
|
const typed = applyWorkflowAgentType(spec, agentOpts.agentType, agentRegistry);
|
|
3295
|
+
if (typed.droppedMcp !== undefined)
|
|
3296
|
+
announceShadowedDefinitionServers({ runner, leg: childSessionId, root: spawnAttribution, agent: typed.agentType, dropped: typed.droppedMcp });
|
|
3240
3297
|
const typedSpec0 = typed.spec;
|
|
3241
3298
|
const typedSpec = withWorkflowChildSeats(typedSpec0, inheritedModelSnap, inheritedThinkingSnap, runnerRoleMap(runner));
|
|
3242
3299
|
const seatedSpec = applyParentSpecSeat(withWorkflowChildPersona(typedSpec, agentOpts.schema ?? typedSpec.outputSchema), opts.parentSpecSeat);
|
|
@@ -3266,7 +3323,7 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
|
|
|
3266
3323
|
...(drive === undefined && !spec.sessionId && childSessionId !== undefined ? { sessionIdMintedBySpawner: true } : {}),
|
|
3267
3324
|
...(agentOpts.isolation ? { isolation: agentOpts.isolation } : {}),
|
|
3268
3325
|
...(opts.parentCwd !== undefined ? { parentCwd: opts.parentCwd } : {}),
|
|
3269
|
-
...(opts.parentSpecSeat?.
|
|
3326
|
+
...(opts.parentSpecSeat?.project !== undefined ? { parentProject: opts.parentSpecSeat.project } : {}),
|
|
3270
3327
|
...callerPlacementSeats(opts.parentCwd, opts.callerRoot),
|
|
3271
3328
|
...spawnAttribution,
|
|
3272
3329
|
...definitionSeats(typed),
|
|
@@ -3637,8 +3694,31 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
|
|
|
3637
3694
|
emitRunLog(`launch: this run's launch record was not kept (${why}) — nothing could continue a card this run parked on, so its agents do not park on approvals.`);
|
|
3638
3695
|
}
|
|
3639
3696
|
}
|
|
3697
|
+
const takeRunClaim = async (keys, what, onThrow) => {
|
|
3698
|
+
const store = journalStore;
|
|
3699
|
+
const fallback = store.resumeClaim === undefined;
|
|
3700
|
+
for (const key of keys) {
|
|
3701
|
+
if (resumeClaims.some((c) => c.sourceRunId === key))
|
|
3702
|
+
continue;
|
|
3703
|
+
if (finalized)
|
|
3704
|
+
throw new Error("workflow run already finalized — its resume admission takes no claim after the run ended");
|
|
3705
|
+
const verdict = takeWorkflowResumeClaim(store, { sourceRunId: key, newRunId: runId, scope }, (parkedResume?.length ?? 0) > 0);
|
|
3706
|
+
resumeClaims.push({ sourceRunId: key, verdict, fallback });
|
|
3707
|
+
let decision;
|
|
3708
|
+
try {
|
|
3709
|
+
decision = await verdict;
|
|
3710
|
+
}
|
|
3711
|
+
catch (err) {
|
|
3712
|
+
throw onThrow(err);
|
|
3713
|
+
}
|
|
3714
|
+
if (!decision.granted)
|
|
3715
|
+
throw claimRefusalOf(what, decision);
|
|
3716
|
+
}
|
|
3717
|
+
};
|
|
3718
|
+
if (opts.resumeFromRunId === undefined && journalStore) {
|
|
3719
|
+
await takeRunClaim([runId], `run "${clampRunIdText(runId)}"`, (err) => new Error(`startWorkflow: run "${clampRunIdText(runId)}" was REFUSED — the journal store threw while the workflow's claim was taken (${storeErrorClassOf(err)}), so nothing guards the run against a continuation of it; nothing ran. Start it again once the journal store answers.`));
|
|
3720
|
+
}
|
|
3640
3721
|
if (opts.resumeFromRunId !== undefined && journalStore) {
|
|
3641
|
-
const usingFallback = journalStore.resumeClaim === undefined;
|
|
3642
3722
|
const named = opts.resumeFromRunId;
|
|
3643
3723
|
let walkThrew;
|
|
3644
3724
|
const walkWithin = (p) => storeWithin(p.catch((err) => ((walkThrew ??= { err }), Promise.reject(err))));
|
|
@@ -3657,38 +3737,18 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
|
|
|
3657
3737
|
const keyTree = store === undefined || heldKey !== undefined ? undefined : await readTree();
|
|
3658
3738
|
if (typeof keyTree === "string")
|
|
3659
3739
|
throw await treeRefusal(keyTree);
|
|
3660
|
-
const
|
|
3740
|
+
const firstKeys = heldKey !== undefined ? [heldKey] : keyTree === undefined ? [named] : workflowClaimKeysOf(keyTree).keys;
|
|
3661
3741
|
const otherRoot = () => new Error(`startWorkflow: resume from "${clampRunIdText(named)}" was REFUSED — the workflow's records now lead to another first run than the one its resume claim was taken for (a run of the workflow was removed or created again meanwhile), so its claim cannot hold it. Resume again.`);
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
const verdict = takeWorkflowResumeClaim(journalStore, { sourceRunId: root, newRunId: runId, scope });
|
|
3665
|
-
resumeClaim = { sourceRunId: root, verdict, fallback: usingFallback };
|
|
3666
|
-
let decision;
|
|
3667
|
-
try {
|
|
3668
|
-
decision = await verdict;
|
|
3669
|
-
}
|
|
3670
|
-
catch (err) {
|
|
3671
|
-
throw journalStoreClaimRefusal(clampRunIdText(named), err);
|
|
3672
|
-
}
|
|
3673
|
-
if (!decision.granted) {
|
|
3674
|
-
const forAnswer = isAnswerRecordClaimHolder(decision.holder);
|
|
3675
|
-
const holder = decision.holder !== undefined && !forAnswer ? clampRunIdText(decision.holder) : "";
|
|
3676
|
-
const lapse = decision.lapse;
|
|
3677
|
-
throw new Error(`startWorkflow: resume from "${clampRunIdText(named)}" was REFUSED — ` +
|
|
3678
|
-
(forAnswer
|
|
3679
|
-
? "another leg of the workflow holds the resume claim on it for a moment, to record a person's answer to continuing it (no run holds it): resume again once it gives the claim back. If that leg's process stopped without giving the claim back, "
|
|
3680
|
-
: `another run already holds the resume claim on it${holder ? ` (holder: ${holder})` : " (holder unknown to the store)"}. ` +
|
|
3681
|
-
"Two concurrent resumes of one source run fork its execution: both replay the same prefix and then " +
|
|
3682
|
-
"re-run the whole suffix live, duplicating every side effect. Wait for the holder to reach a terminal " +
|
|
3683
|
-
"state (or stop it) and resume again. If the holder's process stopped without giving the claim back, ") +
|
|
3684
|
-
`the claim lapses ${lapse?.kind === "at" ? `at ${new Date(lapse.at).toISOString()} at the latest` : `when the journal store's expiry frees it${lapse?.kind === "unreadable" ? ` (${CLAIM_REMAINING_UNREADABLE_NOTE})` : ""}`}, and the same resume goes through then.`);
|
|
3685
|
-
}
|
|
3742
|
+
const claimThrew = (err) => journalStoreClaimRefusal(clampRunIdText(named), err);
|
|
3743
|
+
await takeRunClaim(firstKeys, `resume from "${clampRunIdText(named)}"`, claimThrew);
|
|
3686
3744
|
if (store !== undefined) {
|
|
3687
3745
|
const tree = await readTree();
|
|
3688
3746
|
if (typeof tree === "string")
|
|
3689
3747
|
throw await treeRefusal(tree);
|
|
3690
|
-
|
|
3748
|
+
const keys = workflowClaimKeysOf(tree).keys;
|
|
3749
|
+
if (heldKey !== undefined ? keys[0] !== heldKey : !sameClaimKeys(keys, firstKeys))
|
|
3691
3750
|
throw otherRoot();
|
|
3751
|
+
await takeRunClaim(keys, `resume from "${clampRunIdText(named)}"`, claimThrew);
|
|
3692
3752
|
admissionTree = Promise.resolve(tree);
|
|
3693
3753
|
for (const e of parkedResume ?? []) {
|
|
3694
3754
|
const was = e.decisionId === undefined ? undefined : workflowParkDecisionOf(e.token, e.decisionId, tree);
|
|
@@ -3908,12 +3968,12 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
|
|
|
3908
3968
|
if (resumeRefusal !== undefined)
|
|
3909
3969
|
throw refusalTerminal(resumeRefusal);
|
|
3910
3970
|
if (maxResultChars !== undefined) {
|
|
3911
|
-
let size
|
|
3971
|
+
let size;
|
|
3912
3972
|
try {
|
|
3913
3973
|
size = JSON.stringify(result)?.length ?? 0;
|
|
3914
3974
|
}
|
|
3915
3975
|
catch {
|
|
3916
|
-
size =
|
|
3976
|
+
size = Number.POSITIVE_INFINITY;
|
|
3917
3977
|
}
|
|
3918
3978
|
if (size > maxResultChars)
|
|
3919
3979
|
throw new WorkflowResultTooLargeError(size, maxResultChars);
|
|
@@ -4008,7 +4068,7 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
|
|
|
4008
4068
|
answer();
|
|
4009
4069
|
}
|
|
4010
4070
|
awaitedAppends.clear();
|
|
4011
|
-
|
|
4071
|
+
for (const resumeClaim of resumeClaims) {
|
|
4012
4072
|
const granted = await finalizeWithin(timers, resumeClaim.verdict.then((v) => v.granted, () => false), false);
|
|
4013
4073
|
if (granted) {
|
|
4014
4074
|
if (resumeClaim.fallback) {
|
|
@@ -4025,6 +4085,7 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
|
|
|
4025
4085
|
}
|
|
4026
4086
|
}
|
|
4027
4087
|
}
|
|
4088
|
+
dropLocalClaimHolder(runId);
|
|
4028
4089
|
for (const row of [...bceLive.values()]) {
|
|
4029
4090
|
bceTerminal(row.callKey, "failed", "abandoned by run finalize", undefined);
|
|
4030
4091
|
}
|
|
@@ -4046,19 +4107,20 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
|
|
|
4046
4107
|
}
|
|
4047
4108
|
})();
|
|
4048
4109
|
bindSettledRun(done, run);
|
|
4049
|
-
|
|
4110
|
+
const cancel = (reason) => cancelController.abort(reason ? new Error(reason) : undefined);
|
|
4111
|
+
const handle = {
|
|
4050
4112
|
runId,
|
|
4051
4113
|
done,
|
|
4052
|
-
cancel
|
|
4114
|
+
cancel,
|
|
4053
4115
|
parked: () => runParkedOf(run),
|
|
4054
|
-
stopAgent: async (callKey, o) =>
|
|
4055
|
-
|
|
4056
|
-
if (by !== undefined && (typeof by !== "string" || by.trim() === "" || by.length > MAX_MEMBER_STOPPER_CHARS))
|
|
4057
|
-
throw new TypeError(`WorkflowHandle.stopAgent: stoppedBy must be a non-empty string of at most ${MAX_MEMBER_STOPPER_CHARS} characters`);
|
|
4058
|
-
return stopMember(callKey, by ?? "parent");
|
|
4059
|
-
},
|
|
4116
|
+
stopAgent: async (callKey, o) => stopMember(callKey, readWorkflowStopper(o?.stoppedBy, "WorkflowHandle.stopAgent")),
|
|
4117
|
+
stop: async (o) => stopWorkflowTree(runId, scope, readWorkflowStopper(o?.stoppedBy, "WorkflowHandle.stop"), seats, { self: run, own: local, keysWithoutTree: resumeClaims.length > 0 ? resumeClaims.map((c) => c.sourceRunId) : [opts.resumeFromRunId ?? runId] }),
|
|
4060
4118
|
recordLanded: () => recordLanded.then((o) => o.ok),
|
|
4061
4119
|
};
|
|
4120
|
+
const seats = { ...(store !== undefined ? { runStore: store } : {}), ...(journalStore !== undefined ? { journalStore } : {}), ...(parkSeat !== undefined ? { checkpointStore: parkSeat } : {}) };
|
|
4121
|
+
const local = { runId, creationId: () => creationId, cancel: (reason) => cancel(reason), done, handle };
|
|
4122
|
+
holdLocalWorkflowRun(local);
|
|
4123
|
+
return handle;
|
|
4062
4124
|
}
|
|
4063
4125
|
export async function runWorkflow(runner, fn, opts = {}, internals) {
|
|
4064
4126
|
return startWorkflow(runner, fn, opts, internals).done;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE MANAGER RECIPE: data and text a host composes into its own spec and agent definitions, not an engine mode — the coordinator
|
|
3
|
+
* role text (unchanged), `ownHandsReadOnly` (the manager's own hands only), `runLedger` (the member ledger, the report tool, the
|
|
4
|
+
* actions section, the launch check), and the duties on `appendSystemPrompt`. A worker's definition carries no delegation tool
|
|
5
|
+
* ({@link managerWorkerDefinition}); no agent-to-agent peer tool is mounted (a peer call waits in the call; a manager must not).
|
|
6
|
+
*/
|
|
7
|
+
import type { AgentDefinition } from "../core/agent-definition.js";
|
|
8
|
+
/** The duties the manager reads after its role text. */
|
|
9
|
+
export declare const MANAGER_DUTIES_ADDENDUM = "# Your duties as the manager of this work\n\nThe work you direct can be of any kind \u2014 code, research, analysis, operations, writing. Where the coordinator text above speaks of software engineering, read it for whatever this work is.\n\nYou do not change the work yourself. Your own hands read: files, searches, read-only commands, and your workers' full records (AgentTranscript). Every change goes through a worker. A manager who edits becomes a party to the work, with nobody left to check it.\n\nVerifying is your duty, not a suggestion. A worker's report says what it meant to do, not necessarily what it did. Before you tell the person that a result holds:\n- read what the worker actually did \u2014 the <actions> section of its notification, its record (AgentTranscript), the files it says it changed;\n- where checking needs something run, send a fresh verification worker (never the worker that did the work) and read its result;\n- when what a worker said and what it did disagree, say so plainly.\n\nReport to the person with SendUserMessage: when you start (the plan, and what it will cost), when a result is overturned, when you are blocked or need a decision, and at the end. For each conclusion about a worker, say what it rests on: \"verified\" only for a check made after that worker reported (cite your call id, or the verification worker's task id); \"relayed\" for what the worker said that you did not check; \"inferred\" for your own judgment. Beside every message the engine delivers its own ledger of the workers \u2014 how each ended, what each did, which ones nobody checked \u2014 so a report that claims more than was checked shows it.\n\nNever tell the person that everything passed while a worker failed, is still running, or was never checked.";
|
|
10
|
+
/** The manager's own task seats (spread into the host's spec; the host adds its objective, model, delegation tool and workers). */
|
|
11
|
+
export declare const MANAGER_RECIPE: Readonly<{
|
|
12
|
+
readonly promptRole: "coordinator";
|
|
13
|
+
readonly ownHandsReadOnly: true;
|
|
14
|
+
readonly runLedger: true;
|
|
15
|
+
readonly appendSystemPrompt: "# Your duties as the manager of this work\n\nThe work you direct can be of any kind — code, research, analysis, operations, writing. Where the coordinator text above speaks of software engineering, read it for whatever this work is.\n\nYou do not change the work yourself. Your own hands read: files, searches, read-only commands, and your workers' full records (AgentTranscript). Every change goes through a worker. A manager who edits becomes a party to the work, with nobody left to check it.\n\nVerifying is your duty, not a suggestion. A worker's report says what it meant to do, not necessarily what it did. Before you tell the person that a result holds:\n- read what the worker actually did — the <actions> section of its notification, its record (AgentTranscript), the files it says it changed;\n- where checking needs something run, send a fresh verification worker (never the worker that did the work) and read its result;\n- when what a worker said and what it did disagree, say so plainly.\n\nReport to the person with SendUserMessage: when you start (the plan, and what it will cost), when a result is overturned, when you are blocked or need a decision, and at the end. For each conclusion about a worker, say what it rests on: \"verified\" only for a check made after that worker reported (cite your call id, or the verification worker's task id); \"relayed\" for what the worker said that you did not check; \"inferred\" for your own judgment. Beside every message the engine delivers its own ledger of the workers — how each ended, what each did, which ones nobody checked — so a report that claims more than was checked shows it.\n\nNever tell the person that everything passed while a worker failed, is still running, or was never checked.";
|
|
16
|
+
}>;
|
|
17
|
+
/** A worker's definition under the recipe: the host's, with the delegation tool (mounted as `delegationToolName`) denied. */
|
|
18
|
+
export declare function managerWorkerDefinition(def: AgentDefinition, delegationToolName?: string): AgentDefinition;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const MANAGER_DUTIES_ADDENDUM = `# Your duties as the manager of this work
|
|
2
|
+
|
|
3
|
+
The work you direct can be of any kind — code, research, analysis, operations, writing. Where the coordinator text above speaks of software engineering, read it for whatever this work is.
|
|
4
|
+
|
|
5
|
+
You do not change the work yourself. Your own hands read: files, searches, read-only commands, and your workers' full records (AgentTranscript). Every change goes through a worker. A manager who edits becomes a party to the work, with nobody left to check it.
|
|
6
|
+
|
|
7
|
+
Verifying is your duty, not a suggestion. A worker's report says what it meant to do, not necessarily what it did. Before you tell the person that a result holds:
|
|
8
|
+
- read what the worker actually did — the <actions> section of its notification, its record (AgentTranscript), the files it says it changed;
|
|
9
|
+
- where checking needs something run, send a fresh verification worker (never the worker that did the work) and read its result;
|
|
10
|
+
- when what a worker said and what it did disagree, say so plainly.
|
|
11
|
+
|
|
12
|
+
Report to the person with SendUserMessage: when you start (the plan, and what it will cost), when a result is overturned, when you are blocked or need a decision, and at the end. For each conclusion about a worker, say what it rests on: "verified" only for a check made after that worker reported (cite your call id, or the verification worker's task id); "relayed" for what the worker said that you did not check; "inferred" for your own judgment. Beside every message the engine delivers its own ledger of the workers — how each ended, what each did, which ones nobody checked — so a report that claims more than was checked shows it.
|
|
13
|
+
|
|
14
|
+
Never tell the person that everything passed while a worker failed, is still running, or was never checked.`;
|
|
15
|
+
export const MANAGER_RECIPE = Object.freeze({
|
|
16
|
+
promptRole: "coordinator",
|
|
17
|
+
ownHandsReadOnly: true,
|
|
18
|
+
runLedger: true,
|
|
19
|
+
appendSystemPrompt: MANAGER_DUTIES_ADDENDUM,
|
|
20
|
+
});
|
|
21
|
+
export function managerWorkerDefinition(def, delegationToolName = "Agent") {
|
|
22
|
+
const denied = def.denyTools ?? [];
|
|
23
|
+
return denied.includes(delegationToolName) ? { ...def } : { ...def, denyTools: [...denied, delegationToolName] };
|
|
24
|
+
}
|
package/dist/shell/lex.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** The dialect this lexer reads
|
|
2
|
-
*
|
|
1
|
+
/** The dialect this lexer reads — the one model text runs in: an environment starts it only on a bash it declared and asked
|
|
2
|
+
* (`ExecutionEnv.modelShell`), never on `sh`. The engine's own commands (`ExecutionEnv.exec`) are not read by it. */
|
|
3
3
|
export declare const SHELL_LEX_DIALECT = "bash";
|
|
4
4
|
/** What holds a character quoted: the four quote forms and the backslash escape, one reason each. */
|
|
5
5
|
export declare const QUOTE_KINDS: readonly ["'", "\"", "$'", "$\"", "\\"];
|
package/dist/shell/lex.js
CHANGED
|
@@ -1557,7 +1557,7 @@ function scanText(source, connectorsAreText, segments, level, list, resumed) {
|
|
|
1557
1557
|
return undefined;
|
|
1558
1558
|
if (w.inSubscript())
|
|
1559
1559
|
return fail("unterminated_subscript", w.srcOfRaw[w.subscript.rawStart]);
|
|
1560
|
-
const word = w.finish(acceptable, pendingHeredoc === undefined);
|
|
1560
|
+
const word = w.finish(acceptable && pendingRedirect === undefined, pendingHeredoc === undefined);
|
|
1561
1561
|
const at = w.at;
|
|
1562
1562
|
w = new WordBuilder();
|
|
1563
1563
|
if (pendingHeredoc !== undefined) {
|
|
@@ -57,7 +57,9 @@
|
|
|
57
57
|
* A file that does not parse, or whose checksum does not match its contents, yields ZERO rules and a loud
|
|
58
58
|
* disclosure — never a partial load. Half a rule set is a set nobody reviewed. Note what the checksum is
|
|
59
59
|
* and is not: it detects corruption, and it does not detect an editor, because an editor recomputes it.
|
|
60
|
-
* For this backend the trust is host = user, exactly as for the settings file it mirrors.
|
|
60
|
+
* For this backend the trust is host = user, exactly as for the settings file it mirrors. So a RULE row
|
|
61
|
+
* in bytes that passed the check is what someone wrote: one that is no data is that row's fault alone,
|
|
62
|
+
* named by the one row reader every backend's rows go through — never a reason to drop the rows beside it.
|
|
61
63
|
*/
|
|
62
64
|
import type { PersistedRule, RuleTombstone } from "../../core/permission-rule-model.js";
|
|
63
65
|
import type { DurableRulePartition, DurableRulePartitionProvider, PermissionRuleWriter, QuarantinedRuleAdd, RuleSyncFrontier, StoredRules, WritableDurableRulePartition } from "../../core/permission-rule-store.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type WorkflowJournalEntry, type WorkflowJournalStore, type WorkflowLaunchRecord, type ResumeClaimArgs, type ResumeClaimAnswer } from "../../core/workflow-journal-store.js";
|
|
1
|
+
import { type WorkflowJournalEntry, type WorkflowJournalStore, type WorkflowLaunchRecord, type ResumeClaimArgs, type ResumeClaimAnswer, type StopResumeClaimArgs, type StopResumeClaimAnswer } from "../../core/workflow-journal-store.js";
|
|
2
2
|
import { type CorruptReadInfo } from "./corrupt-read-sink.js";
|
|
3
3
|
/**
|
|
4
4
|
* RB-242 — how long a resume claim survives WITHOUT an engine release. This is the backstop for an engine that
|
|
@@ -149,6 +149,12 @@ export declare class FileWorkflowJournalStore implements WorkflowJournalStore {
|
|
|
149
149
|
* and a release that could not create one must not leave the claim standing for its lease.
|
|
150
150
|
*/
|
|
151
151
|
private removeIfUnchanged;
|
|
152
|
+
/**
|
|
153
|
+
* Atomically replace a claim file IN PLACE with `payload` ONLY if the bytes on disk are still `judged`, under the same
|
|
154
|
+
* removal gate {@link removeIfUnchanged} uses. Unlike unlink + link, `rename` leaves no empty-file window where a concurrent
|
|
155
|
+
* `resumeClaim` could acquire the slot while arm (c)'s local holder is still running before cancel.
|
|
156
|
+
*/
|
|
157
|
+
private replaceIfUnchanged;
|
|
152
158
|
/**
|
|
153
159
|
* The removal gate of the claim at `path` judged as `judged` — or, given a gate file's own path, that gate. Its name is a fixed
|
|
154
160
|
* length (a digest of the claim file's name and the bytes, `<digest>.takeover`), never the claim's name with more appended: a
|
|
@@ -187,9 +193,16 @@ export declare class FileWorkflowJournalStore implements WorkflowJournalStore {
|
|
|
187
193
|
*/
|
|
188
194
|
resumeClaim(input: ResumeClaimArgs): Promise<ResumeClaimAnswer>;
|
|
189
195
|
/** RB-242 — release ONLY a claim this `newRunId` still holds in this process ({@link heldHere}). A claim that is already gone
|
|
190
|
-
* (TTL-reaped and possibly taken over), or one the same run id holds from another process, is a no-op: unlinking
|
|
191
|
-
* claim would re-open the very fork this prevents. */
|
|
196
|
+
* (TTL-reaped and possibly taken over), a tombstone, or one the same run id holds from another process, is a no-op: unlinking
|
|
197
|
+
* a successor's claim would re-open the very fork this prevents. */
|
|
192
198
|
releaseResumeClaim(input: ResumeClaimArgs): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* #5156 R1 — compare-and-write a permanent stop tombstone on `(sourceRunId, scope)`.
|
|
201
|
+
* Writes no `holderProcess` and sets finite `expiresAt = Number.MAX_SAFE_INTEGER` (never `Infinity`, which serializes to
|
|
202
|
+
* `null`), so pre-tombstone (v7.71.x) readers also refuse, never take over and never reap the tombstone. Arms (b) and (c)
|
|
203
|
+
* replace the existing claim atomically in place under its removal gate, dropping any old `holderProcess` with no empty window.
|
|
204
|
+
*/
|
|
205
|
+
stopResumeClaim(input: StopResumeClaimArgs): Promise<StopResumeClaimAnswer>;
|
|
193
206
|
/** Release ledger fds (graceful shutdown; parity with the other file stores' dispose).
|
|
194
207
|
* Refcounted: the fds are shared with any other instance on the same directory, so the LAST holder
|
|
195
208
|
* closes them. Idempotent — a second dispose() on the same instance must not decrement twice and pull
|