@sema-agent/core 7.70.0 → 7.71.1
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 +740 -0
- package/dist/agents/agent-transcript-tool.js +43 -19
- package/dist/agents/inherited-tool-pool.d.ts +5 -1
- package/dist/agents/inherited-tool-pool.js +6 -0
- package/dist/agents/retain-ledger.js +2 -0
- package/dist/agents/send-message-tool.d.ts +12 -1
- package/dist/agents/send-message-tool.js +47 -9
- package/dist/agents/subagent.js +31 -10
- package/dist/agents/tool-filter.js +1 -2
- package/dist/agents/verify.js +13 -2
- package/dist/agents/yield-adoption.js +11 -1
- package/dist/brain/claude-model-id.d.ts +11 -0
- package/dist/brain/claude-model-id.js +3 -1
- package/dist/config/catalog.js +10 -1
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/defaults.js +1 -0
- package/dist/core/allow-entry.js +1 -2
- package/dist/core/ask-origin.d.ts +55 -21
- package/dist/core/ask-origin.js +19 -11
- package/dist/core/ask-question.d.ts +4 -7
- package/dist/core/ask-question.js +2 -4
- package/dist/core/ask-unresolvable-notice.d.ts +17 -3
- package/dist/core/ask-unresolvable-notice.js +18 -4
- package/dist/core/attachment-source.d.ts +1 -1
- package/dist/core/attachment-source.js +2 -0
- package/dist/core/auto-compaction.d.ts +14 -4
- package/dist/core/auto-compaction.js +3 -2
- package/dist/core/auto-strip.js +2 -0
- package/dist/core/caller-text.d.ts +2 -33
- package/dist/core/caller-text.js +2 -23
- package/dist/core/caller-tool-name.js +1 -2
- package/dist/core/canonical-json.d.ts +9 -0
- package/dist/core/canonical-json.js +6 -0
- package/dist/core/checkpoint-features.d.ts +43 -80
- package/dist/core/checkpoint-features.js +10 -20
- package/dist/core/checkpoint-generation.d.ts +89 -19
- package/dist/core/checkpoint-generation.js +89 -14
- package/dist/core/checkpoint-queries.d.ts +95 -15
- package/dist/core/checkpoint-queries.js +108 -7
- package/dist/core/checkpoint-rekey.d.ts +2 -1
- package/dist/core/checkpoint-rekey.js +2 -2
- package/dist/core/checkpoint-requirements.d.ts +21 -7
- package/dist/core/checkpoint-requirements.js +2 -5
- package/dist/core/checkpoint-row-verdict.d.ts +3 -4
- package/dist/core/checkpoint-row-verdict.js +20 -41
- package/dist/core/checkpoint-store.d.ts +69 -41
- package/dist/core/checkpoint-store.js +28 -14
- package/dist/core/command-sandbox.d.ts +5 -3
- package/dist/core/command-sandbox.js +17 -9
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/declaration-words.d.ts +2 -1
- package/dist/core/declaration-words.js +13 -2
- package/dist/core/effective-path-target.d.ts +23 -0
- package/dist/core/effective-path-target.js +15 -1
- package/dist/core/engine-attestation.d.ts +5 -1
- package/dist/core/engine-attestation.js +1 -0
- package/dist/core/engine-capabilities.d.ts +14 -9
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +62 -32
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +1 -1
- package/dist/core/entries-not-applied.js +1 -0
- package/dist/core/file-history-store.d.ts +95 -11
- package/dist/core/file-history-store.js +117 -19
- package/dist/core/gate-fold.js +13 -7
- package/dist/core/gate-lanes.js +9 -9
- package/dist/core/governance-codes.d.ts +56 -7
- package/dist/core/governance-codes.js +105 -7
- package/dist/core/grant-holder.d.ts +53 -0
- package/dist/core/grant-holder.js +80 -0
- package/dist/core/hooks.d.ts +7 -3
- package/dist/core/hooks.js +2 -2
- package/dist/core/locked-config.d.ts +7 -1
- package/dist/core/locked-config.js +9 -2
- package/dist/core/mcp-call-meta.d.ts +52 -7
- package/dist/core/mcp-call-meta.js +21 -2
- package/dist/core/mcp-host-read.d.ts +1 -1
- package/dist/core/mcp-server-spec.d.ts +18 -0
- package/dist/core/mcp-server-spec.js +1 -0
- package/dist/core/mcp.js +2 -2
- package/dist/core/member-outcome.d.ts +22 -1
- package/dist/core/member-outcome.js +18 -6
- package/dist/core/memory-engine/delegation-settlement.js +5 -5
- package/dist/core/memory-engine/engine.js +19 -19
- package/dist/core/memory-engine/file-backend.d.ts +7 -2
- package/dist/core/memory-engine/file-backend.js +14 -12
- package/dist/core/memory-engine/frontmatter.js +1 -1
- package/dist/core/memory-engine/index.d.ts +1 -0
- package/dist/core/memory-engine/index.js +1 -0
- package/dist/core/memory-engine/layout.d.ts +34 -9
- package/dist/core/memory-engine/layout.js +36 -19
- package/dist/core/memory-engine/memory-deployment.js +8 -8
- package/dist/core/memory-engine/mount-failed-notice.d.ts +8 -5
- package/dist/core/memory-engine/mount-failed-notice.js +5 -2
- package/dist/core/mode-policy.d.ts +5 -0
- package/dist/core/mode-policy.js +6 -0
- package/dist/core/mods/host.d.ts +2 -1
- package/dist/core/mods/host.js +7 -6
- package/dist/core/mods/kernel/index.d.ts +1 -1
- package/dist/core/mods/kernel/index.js +1 -1
- package/dist/core/mods/kernel/registration.d.ts +5 -2
- package/dist/core/mods/kernel/registration.js +19 -3
- package/dist/core/mods/package.d.ts +12 -1
- package/dist/core/mods/package.js +36 -9
- package/dist/core/mods/stations.d.ts +7 -1
- package/dist/core/mods/stations.js +17 -3
- package/dist/core/mods/teammate-stations.d.ts +4 -1
- package/dist/core/mods/teammate-stations.js +1 -1
- package/dist/core/native-signal.d.ts +13 -0
- package/dist/core/native-signal.js +18 -0
- package/dist/core/park-resumability.d.ts +16 -14
- package/dist/core/park-resumability.js +9 -4
- package/dist/core/path-rule-binding.js +1 -1
- package/dist/core/permission-rule-model.d.ts +11 -5
- package/dist/core/permission-rule-model.js +5 -3
- package/dist/core/permission-rule-org.js +1 -1
- package/dist/core/permission-rule-provider.d.ts +5 -1
- package/dist/core/permission-rule-provider.js +6 -1
- package/dist/core/permission-rule-session.d.ts +35 -5
- package/dist/core/permission-rule-session.js +32 -1
- package/dist/core/permission-rule-store.d.ts +5 -1
- package/dist/core/permission-rule-store.js +28 -5
- package/dist/core/permission-rules.d.ts +2 -2
- package/dist/core/permission-rules.js +2 -3
- package/dist/core/principal-name.d.ts +12 -0
- package/dist/core/principal-name.js +6 -2
- package/dist/core/read-root-grant-screen.d.ts +7 -6
- package/dist/core/read-root-grant-screen.js +7 -8
- package/dist/core/remote-env.d.ts +42 -8
- package/dist/core/resume-config-judge.js +1 -1
- package/dist/core/resume-startup-cause.d.ts +19 -4
- package/dist/core/resume-startup-cause.js +25 -6
- package/dist/core/rewind-conversation.d.ts +4 -0
- package/dist/core/rewrite-rejudge.d.ts +9 -1
- package/dist/core/rewrite-rejudge.js +11 -1
- package/dist/core/rule-offer-read.js +3 -2
- package/dist/core/runner/assemble-result.d.ts +21 -11
- package/dist/core/runner/assemble-result.js +24 -4
- package/dist/core/runner/boundary-reminders.d.ts +104 -0
- package/dist/core/runner/boundary-reminders.js +108 -0
- package/dist/core/runner/branch-writeback.d.ts +21 -7
- package/dist/core/runner/branch-writeback.js +44 -6
- package/dist/core/runner/command-sandbox-frame.js +2 -1
- package/dist/core/runner/compact-session.js +11 -4
- package/dist/core/runner/constraint-layers.d.ts +24 -5
- package/dist/core/runner/constraint-layers.js +21 -2
- package/dist/core/runner/continuation-gate.js +3 -1
- package/dist/core/runner/contracts.d.ts +83 -13
- package/dist/core/runner/cross-boundary-lane.js +2 -1
- package/dist/core/runner/delegation-owner.d.ts +246 -45
- package/dist/core/runner/delegation-owner.js +237 -63
- package/dist/core/runner/expire-settle.d.ts +17 -0
- package/dist/core/runner/expire-settle.js +8 -2
- package/dist/core/runner/file-history-request.d.ts +4 -3
- package/dist/core/runner/file-history-request.js +4 -1
- package/dist/core/runner/file-history-restore.d.ts +11 -3
- package/dist/core/runner/file-history-restore.js +11 -3
- package/dist/core/runner/gate-exit.d.ts +22 -1
- package/dist/core/runner/gate-exit.js +12 -14
- package/dist/core/runner/nested-memory-content.js +1 -1
- package/dist/core/runner/nested-memory-lane.d.ts +10 -2
- package/dist/core/runner/nested-memory-lane.js +29 -8
- package/dist/core/runner/own-model-money-door.d.ts +13 -0
- package/dist/core/runner/own-model-money-door.js +17 -0
- package/dist/core/runner/park-commit.d.ts +4 -2
- package/dist/core/runner/park-commit.js +2 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +4 -0
- package/dist/core/runner/permission-rule-lanes.js +7 -0
- package/dist/core/runner/person-path-rows.js +1 -1
- package/dist/core/runner/placement-fence.d.ts +8 -2
- package/dist/core/runner/placement-fence.js +8 -3
- package/dist/core/runner/policy-throw.d.ts +3 -2
- package/dist/core/runner/policy-throw.js +2 -2
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +23 -14
- package/dist/core/runner/prepare-acquire-reconcile.js +33 -15
- package/dist/core/runner/prepare-artifact.d.ts +14 -1
- package/dist/core/runner/prepare-artifact.js +7 -2
- package/dist/core/runner/prepare-ask-lane.d.ts +8 -0
- package/dist/core/runner/prepare-ask-lane.js +14 -5
- package/dist/core/runner/prepare-boundary-parks.js +5 -4
- package/dist/core/runner/prepare-config-doors.d.ts +9 -4
- package/dist/core/runner/prepare-config-doors.js +25 -8
- package/dist/core/runner/prepare-defer-classify.d.ts +8 -4
- package/dist/core/runner/prepare-defer-classify.js +6 -6
- package/dist/core/runner/prepare-execution-env.d.ts +4 -1
- package/dist/core/runner/prepare-execution-env.js +8 -3
- package/dist/core/runner/prepare-file-history.d.ts +26 -0
- package/dist/core/runner/prepare-file-history.js +15 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -3
- package/dist/core/runner/prepare-inherited-gate.js +9 -2
- package/dist/core/runner/prepare-leg-adoption.d.ts +2 -2
- package/dist/core/runner/prepare-park-ask.js +8 -5
- package/dist/core/runner/prepare-policy-chain.d.ts +5 -0
- package/dist/core/runner/prepare-policy-chain.js +18 -7
- package/dist/core/runner/prepare-prompt-assembly.d.ts +3 -0
- package/dist/core/runner/prepare-prompt-assembly.js +4 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +4 -1
- package/dist/core/runner/prepare-suspend-saga.js +19 -5
- package/dist/core/runner/prepare-task.d.ts +2 -5
- package/dist/core/runner/prepare-task.js +71 -26
- package/dist/core/runner/prepare-turn-wiring.js +7 -5
- package/dist/core/runner/prepare-workspace-restore.js +59 -28
- package/dist/core/runner/read-root-grant.d.ts +1 -0
- package/dist/core/runner/read-root-grant.js +1 -2
- package/dist/core/runner/resume-admission.d.ts +3 -0
- package/dist/core/runner/resume-admission.js +6 -4
- package/dist/core/runner/resume-apply.js +7 -5
- package/dist/core/runner/resume-claim.d.ts +2 -2
- package/dist/core/runner/resume-claim.js +4 -4
- package/dist/core/runner/resume-policy-outcome.d.ts +1 -1
- package/dist/core/runner/resume-policy-outcome.js +6 -4
- package/dist/core/runner/resume-preflight.d.ts +3 -0
- package/dist/core/runner/resume-preflight.js +10 -3
- package/dist/core/runner/rewind-conversation.js +11 -4
- package/dist/core/runner/rewind-files.js +29 -14
- package/dist/core/runner/rewind-outcome.d.ts +27 -0
- package/dist/core/runner/rewind-outcome.js +14 -0
- package/dist/core/runner/run-attachment-seats.js +2 -1
- package/dist/core/runner/run-clock-and-content.js +2 -0
- package/dist/core/runner/run-identity-wiring.js +2 -0
- package/dist/core/runner/run-leg.js +11 -1
- package/dist/core/runner/run-notification-lane.d.ts +3 -0
- package/dist/core/runner/run-notification-lane.js +2 -2
- package/dist/core/runner/run-settle-and-teardown.d.ts +4 -2
- package/dist/core/runner/run-settle-and-teardown.js +52 -40
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
- package/dist/core/runner/run-stop-and-final-verify.js +5 -4
- package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.js +3 -3
- package/dist/core/runner/run-turn-boundary.js +7 -0
- package/dist/core/runner/runtask.d.ts +7 -4
- package/dist/core/runner/runtask.js +18 -9
- package/dist/core/runner/session-call-grant-station.d.ts +64 -0
- package/dist/core/runner/session-call-grant-station.js +119 -0
- package/dist/core/runner/session-file-state-replay.js +2 -2
- package/dist/core/runner/session-prompt-seats.d.ts +95 -0
- package/dist/core/runner/session-prompt-seats.js +62 -0
- package/dist/core/runner/session-rule-policy.js +1 -1
- package/dist/core/runner/session-write-ledger.d.ts +8 -0
- package/dist/core/runner/session-write-ledger.js +16 -0
- package/dist/core/runner/side-call-account.js +5 -1
- package/dist/core/runner/stop-tail-notice.d.ts +7 -0
- package/dist/core/runner/stop-tail-notice.js +23 -8
- package/dist/core/runner/stream-reap.js +4 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -1
- package/dist/core/runner/stream-settle-backstop.js +17 -18
- package/dist/core/runner/terminal-account.js +17 -8
- package/dist/core/runner/terminal-projection.d.ts +3 -2
- package/dist/core/runner/terminal-projection.js +1 -1
- package/dist/core/runner/tool-turn-repair-seat.d.ts +2 -2
- package/dist/core/runner/tool-turn-repair-seat.js +12 -7
- package/dist/core/runner/turn-attachments.d.ts +22 -1
- package/dist/core/runner/turn-attachments.js +20 -3
- package/dist/core/runner-deps.d.ts +6 -2
- package/dist/core/secret-env.d.ts +26 -6
- package/dist/core/secret-env.js +6 -6
- package/dist/core/session-call-grant-screen.d.ts +58 -0
- package/dist/core/session-call-grant-screen.js +18 -0
- package/dist/core/session-call-grant.d.ts +93 -0
- package/dist/core/session-call-grant.js +524 -0
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +8 -3
- package/dist/core/session-policy-store.d.ts +14 -0
- package/dist/core/session-policy-store.js +16 -2
- package/dist/core/session-store.d.ts +18 -1
- package/dist/core/session-store.js +20 -4
- package/dist/core/session.d.ts +36 -4
- package/dist/core/shared-artifact-reads.d.ts +93 -0
- package/dist/core/shared-artifact-reads.js +94 -0
- package/dist/core/skill-grant.js +1 -1
- package/dist/core/skills-directory.d.ts +9 -45
- package/dist/core/skills-directory.js +9 -722
- package/dist/core/spend-account.js +3 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +22 -4
- package/dist/core/store-contracts/checkpoint-store-contract.js +363 -29
- package/dist/core/store-contracts/file-history-store-contract.d.ts +11 -3
- package/dist/core/store-contracts/file-history-store-contract.js +62 -2
- package/dist/core/store-contracts/grant-fixture.d.ts +52 -0
- package/dist/core/store-contracts/grant-fixture.js +84 -0
- package/dist/core/store-contracts/session-repo-contract.js +18 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -1
- package/dist/core/store-contracts/session-store-contract.js +211 -2
- package/dist/core/store-contracts/workflow-journal-store-contract.js +47 -8
- package/dist/core/suspend-lane-reasons.d.ts +13 -0
- package/dist/core/suspend-lane-reasons.js +5 -0
- package/dist/core/synthetic-read-verdict.d.ts +5 -3
- package/dist/core/synthetic-read-verdict.js +1 -1
- package/dist/core/task-limits.d.ts +15 -0
- package/dist/core/task-notification.d.ts +33 -7
- package/dist/core/task-notification.js +34 -9
- package/dist/core/task-registry-agent.d.ts +1 -1
- package/dist/core/task-registry-agent.js +18 -7
- package/dist/core/task-registry-shared.d.ts +29 -4
- package/dist/core/task-registry-shared.js +7 -0
- package/dist/core/task-registry.d.ts +21 -1
- package/dist/core/task-registry.js +36 -9
- package/dist/core/task-result.d.ts +55 -1
- package/dist/core/task-spec.d.ts +17 -3
- package/dist/core/terminal-cause.d.ts +68 -5
- package/dist/core/tool-catalog-entries.js +1 -1
- package/dist/core/tool-check-reading.js +2 -1
- package/dist/core/tool-errors.js +1 -0
- package/dist/core/tool-list-grammar.d.ts +0 -47
- package/dist/core/tool-list-grammar.js +1 -75
- package/dist/core/tool-model-gate.d.ts +7 -11
- package/dist/core/tool-model-gate.js +5 -8
- package/dist/core/tool-name-aliases.js +2 -3
- package/dist/core/tool-name-readings.d.ts +4 -0
- package/dist/core/tool-name-readings.js +1 -0
- package/dist/core/tool-policy.d.ts +46 -4
- package/dist/core/tool-policy.js +47 -18
- package/dist/core/tool-result-store.d.ts +0 -24
- package/dist/core/tool-result-store.js +1 -36
- package/dist/core/tool-spec.d.ts +8 -4
- package/dist/core/untrusted-egress.js +2 -2
- package/dist/core/untrusted-text.d.ts +8 -0
- package/dist/core/untrusted-text.js +14 -0
- package/dist/core/user-attachment.d.ts +16 -1
- package/dist/core/user-attachment.js +42 -18
- package/dist/core/wiring-manifest.d.ts +4 -9
- package/dist/core/wiring-manifest.js +1 -1
- package/dist/core/workflow-journal-store.d.ts +55 -8
- package/dist/core/workflow-journal-store.js +34 -10
- package/dist/core/workflow-run-store-contract.js +56 -1
- package/dist/core/workflow-run-store.d.ts +43 -19
- package/dist/core/workflow-run-store.js +17 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +3 -0
- package/dist/engine/execution-env/node-execution-env.js +4 -0
- package/dist/engine/harness/agent-harness.d.ts +10 -5
- package/dist/engine/harness/agent-harness.js +12 -4
- package/dist/engine/harness/types.d.ts +18 -0
- package/dist/engine/llm/tool-turns.d.ts +1 -1
- package/dist/engine/llm/types.d.ts +5 -4
- package/dist/engine/session/memory-repo.d.ts +15 -3
- package/dist/engine/session/memory-repo.js +21 -3
- package/dist/engine/session/memory-storage.d.ts +5 -0
- package/dist/engine/session/memory-storage.js +8 -3
- package/dist/engine/session/repo-utils.d.ts +9 -0
- package/dist/engine/session/repo-utils.js +14 -0
- package/dist/engine/session/storage-base.d.ts +20 -7
- package/dist/engine/session/storage-base.js +13 -1
- package/dist/index.d.ts +39 -21
- package/dist/index.js +32 -17
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +13 -1
- package/dist/orchestration/run-workflow-tool.js +101 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +309 -92
- package/dist/orchestration/workflow-park-adoption.js +588 -323
- package/dist/orchestration/workflow-tree-id.d.ts +66 -0
- package/dist/orchestration/workflow-tree-id.js +66 -0
- package/dist/orchestration/workflow-types.d.ts +90 -11
- package/dist/orchestration/workflow-types.js +10 -1
- package/dist/orchestration/workflow.d.ts +30 -4
- package/dist/orchestration/workflow.js +424 -114
- package/dist/prompt-assembly/catalog/constitution.js +5 -1
- package/dist/prompt-assembly/catalog/core-behavior.d.ts +3 -4
- package/dist/prompt-assembly/catalog/core-behavior.js +61 -22
- package/dist/prompt-assembly/catalog/environment.js +2 -2
- package/dist/prompt-assembly/catalog/events.d.ts +16 -0
- package/dist/prompt-assembly/catalog/events.js +2 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +72 -44
- package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.js +2 -2
- package/dist/prompt-assembly/catalog/locales/zh-Hans/events.js +2 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +5 -1
- package/dist/prompt-assembly/catalog/schema.js +2 -0
- package/dist/prompt-assembly/catalog/sections.js +3 -14
- package/dist/prompt-assembly/event-registry.js +2 -0
- package/dist/prompt-assembly/select.js +1 -0
- package/dist/prompt-assembly/tool-catalog.d.ts +10 -7
- package/dist/prompt-assembly/tool-catalog.js +21 -7
- package/dist/prompt-assembly/types.d.ts +3 -0
- package/dist/prompts/default.d.ts +4 -1
- package/dist/prompts/default.js +6 -0
- package/dist/stores/file/checkpoint-store.d.ts +11 -10
- package/dist/stores/file/checkpoint-store.js +36 -10
- package/dist/stores/file/file-history-store.d.ts +6 -0
- package/dist/stores/file/file-history-store.js +21 -4
- package/dist/stores/file/fs-atomic.d.ts +1 -1
- package/dist/stores/file/index.d.ts +14 -4
- package/dist/stores/file/index.js +21 -5
- package/dist/stores/file/process-anchor.d.ts +9 -1
- package/dist/stores/file/session-policy-store.js +2 -17
- package/dist/stores/file/session-store.d.ts +27 -0
- package/dist/stores/file/session-store.js +81 -9
- package/dist/stores/file/workflow-journal-store.d.ts +14 -4
- package/dist/stores/file/workflow-journal-store.js +32 -24
- package/dist/stores/file/workflow-run-store.d.ts +15 -4
- package/dist/stores/file/workflow-run-store.js +76 -0
- package/dist/tools/artifact/artifact-tool.d.ts +10 -3
- package/dist/tools/artifact/artifact-tool.js +16 -1
- package/dist/tools/fs/bash-program-position.d.ts +10 -4
- package/dist/tools/fs/bash-program-position.js +11 -8
- package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -1
- package/dist/tools/fs/bash-readonly-classifier.js +9 -2
- package/dist/tools/fs/find-actions.d.ts +30 -16
- package/dist/tools/fs/find-actions.js +272 -19
- package/dist/tools/fs/fs-bash.js +8 -5
- package/dist/tools/fs/fs-shared.d.ts +0 -29
- package/dist/tools/fs/fs-shared.js +0 -5
- package/dist/tools/fs/fs-write.js +2 -1
- package/dist/tools/fs/read-deny.d.ts +6 -1
- package/dist/tools/fs/read-deny.js +6 -1
- package/dist/tools/fs/read-floor.d.ts +6 -0
- package/dist/tools/fs/read-floor.js +5 -1
- package/dist/tools/fs/removal-actions.d.ts +43 -0
- package/dist/tools/fs/removal-actions.js +25 -0
- package/dist/tools/fs/removal-targets.d.ts +2 -21
- package/dist/tools/fs/removal-targets.js +2 -3
- package/dist/tools/fs/safety.d.ts +37 -1
- package/dist/tools/fs/safety.js +52 -0
- package/dist/tools/fs/shell-climb.d.ts +46 -0
- package/dist/tools/fs/shell-climb.js +79 -0
- package/dist/tools/fs/shell-read-check.js +47 -19
- package/dist/tools/fs/shell-read-establish.js +36 -22
- package/dist/tools/fs/shell-read-judge.d.ts +10 -2
- package/dist/tools/fs/shell-read-judge.js +4 -4
- package/dist/tools/fs/shell-read-plan.d.ts +3 -0
- package/dist/tools/fs/shell-read-plan.js +1 -1
- package/dist/tools/fs/shell-read-workdir.js +3 -2
- package/dist/tools/fs/shell-read-write-targets.d.ts +4 -3
- package/dist/tools/fs/shell-read-write-targets.js +3 -0
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +173 -15
- package/wire-changes/core-stores-sql@7.71.0.json +40 -0
- package/wire-changes/core-stores-sql@7.71.1.json +40 -0
- package/wire-changes/core@7.71.0.json +5827 -0
- package/wire-changes/core@7.71.1.json +118 -0
- package/wire-changes/mods-kernel@7.71.0.json +52 -0
- package/wire-changes/mods-kernel@7.71.1.json +40 -0
- package/wire-changes/primitives@7.71.0.json +473 -0
- package/wire-changes/primitives@7.71.1.json +40 -0
- package/wire-changes/wiki-gate@7.71.0.json +40 -0
- package/wire-changes/wiki-gate@7.71.1.json +40 -0
- package/dist/core/frontmatter-fence.d.ts +0 -10
- package/dist/core/frontmatter-fence.js +0 -6
- package/dist/core/permission-rule-syntax.d.ts +0 -46
- package/dist/core/permission-rule-syntax.js +0 -52
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { WorkflowRun } from "./workflow-types.js";
|
|
2
|
+
import { type WorkflowRunStore } from "../core/workflow-run-store.js";
|
|
3
|
+
import { type BoundedStoreRead } from "./workflow-park-adoption.js";
|
|
4
|
+
/**
|
|
5
|
+
* A workflow run's tree id ({@link WorkflowRun.treeId}) — where it comes from, read one way.
|
|
6
|
+
*
|
|
7
|
+
* The edge: run `b` continues run `a` ({@link isContinuationOf}) when `b`'s `resume.fromRunId` is `a`'s id and, when `b` recorded which
|
|
8
|
+
* creation of that id it read (`resume.fromCreationId`), `a` is that same creation. A record created again under a reused id is not
|
|
9
|
+
* the run a continuation continued, so it is not its source — the same answer as a source that is gone.
|
|
10
|
+
*
|
|
11
|
+
* The tree id of a record: its own `treeId` when it carries one; else, up the edges, the first record that carries one; else the top
|
|
12
|
+
* record's id (a record that names no run it resumed). An edge that does not hold on the way up (the source gone, created again, or
|
|
13
|
+
* out of the scope) leaves the record with no tree id; so does a record whose resume admission never completed (it is no member of a
|
|
14
|
+
* tree). The walk is the one reading of the rule; a resume's admission and the stamp of an older finished record
|
|
15
|
+
* ({@link workflowTreeIdStampOf}) both go through it.
|
|
16
|
+
*/
|
|
17
|
+
/** A stored record's tree id member: the member when it is a string, else none. */
|
|
18
|
+
export declare function workflowRunTreeIdOf(run: WorkflowRun): string | undefined;
|
|
19
|
+
/** What the walk answers: the tree id, `"no_tree"` (an edge up does not hold), `"unreadable"` (a read failed or did not answer, or the
|
|
20
|
+
* walk met a run twice) or `"over_bound"` (more runs than {@link WORKFLOW_TREE_RUNS_MAX}). */
|
|
21
|
+
export type WorkflowTreeIdAnswer = {
|
|
22
|
+
readonly treeId: string;
|
|
23
|
+
} | "no_tree" | "unreadable" | "over_bound";
|
|
24
|
+
/** One read the walk asks for: a run id; the driver answers the record in the scope, `null` for none there, or `"unreadable"`. */
|
|
25
|
+
export type WorkflowTreeIdRead = WorkflowRun | null | "unreadable";
|
|
26
|
+
/**
|
|
27
|
+
* The walk itself, as a generator so that one rule has two drivers: it yields each run id it needs read and is handed the answer
|
|
28
|
+
* ({@link WorkflowTreeIdRead}). {@link treeIdOf} drives it with a store's reads; a store whose rows are in hand drives it itself.
|
|
29
|
+
*/
|
|
30
|
+
export declare function treeIdWalk(run: WorkflowRun): Generator<string, WorkflowTreeIdAnswer, WorkflowTreeIdRead>;
|
|
31
|
+
/** {@link treeIdWalk} driven by a store's reads in `scope`, each bounded by `within`. */
|
|
32
|
+
export declare function treeIdOf(store: Pick<WorkflowRunStore, "get">, run: WorkflowRun, scope: string, within: BoundedStoreRead): Promise<WorkflowTreeIdAnswer>;
|
|
33
|
+
/**
|
|
34
|
+
* What {@link workflowTreeIdStampOf} answers for one stored record:
|
|
35
|
+
* - `stamp` — write `update(run.id, scope, { ...run, treeId }, expect, { cause })`: the record as read with the tree id added, compared
|
|
36
|
+
* on the rev and the creation read; a write that loses is asked again on a fresh `get`, or left for the next pass;
|
|
37
|
+
* - `skip` — nothing to write: `stamped` (it carries a tree id), `running` (its owner writes it whole, and only a finished record is
|
|
38
|
+
* stamped), `admission_incomplete` (a continuation whose admission never completed is no member of a tree), `no_tree` (an edge up
|
|
39
|
+
* its line does not hold — the source gone or created again);
|
|
40
|
+
* - `"unreadable"` (a read up the line failed or did not answer within its bound, or the line met a run twice) / `"over_bound"` (the
|
|
41
|
+
* line is more runs than the walks read): this record is not stamped this pass.
|
|
42
|
+
*/
|
|
43
|
+
export type WorkflowTreeIdStamp = {
|
|
44
|
+
readonly kind: "stamp";
|
|
45
|
+
readonly treeId: string;
|
|
46
|
+
readonly expect: {
|
|
47
|
+
readonly rev: number;
|
|
48
|
+
readonly creationId: string | null;
|
|
49
|
+
};
|
|
50
|
+
readonly cause: "tree_id_stamp";
|
|
51
|
+
} | {
|
|
52
|
+
readonly kind: "skip";
|
|
53
|
+
readonly why: "stamped" | "running" | "admission_incomplete" | "no_tree";
|
|
54
|
+
} | "unreadable" | "over_bound";
|
|
55
|
+
/** The stamp decision for one record — the one rule, a generator like {@link treeIdWalk} so a store holding its rows drives it in hand. */
|
|
56
|
+
export declare function treeIdStampWalk(run: WorkflowRun): Generator<string, WorkflowTreeIdStamp, WorkflowTreeIdRead>;
|
|
57
|
+
/**
|
|
58
|
+
* Whether a FINISHED record an older engine wrote (no {@link WorkflowRun.treeId}) is to be given its tree id, which one, and the write
|
|
59
|
+
* that gives it ({@link WorkflowTreeIdStamp}) — the one reading a host's own pass over its rows calls (a store whose rows outlive an
|
|
60
|
+
* upgrade runs one pass, as the bundled file store does when it opens). Reads up the record's line in `scope`, each read bounded by
|
|
61
|
+
* `WORKFLOW_STORE_WAIT_BOUND_MS`. A running record is never stamped: its owner writes it whole. A host may leave a record unstamped
|
|
62
|
+
* (this release reads no tree id): such a record simply has none.
|
|
63
|
+
*/
|
|
64
|
+
export declare function workflowTreeIdStampOf(store: Pick<WorkflowRunStore, "get">, run: WorkflowRun, scope: string): Promise<WorkflowTreeIdStamp>;
|
|
65
|
+
/** {@link treeIdStampWalk} driven in hand: `read` answers each run id at once. */
|
|
66
|
+
export declare function workflowTreeIdStampInHand(run: WorkflowRun, read: (id: string) => WorkflowTreeIdRead): WorkflowTreeIdStamp;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { resumedFromOf, workflowRunCreationIdOf } from "../core/workflow-run-store.js";
|
|
2
|
+
import { boundedStoreRead, isContinuationOf, readWorkflowRunIn, WORKFLOW_TREE_RUNS_MAX } from "./workflow-park-adoption.js";
|
|
3
|
+
import { WORKFLOW_STORE_WAIT_BOUND_MS } from "./workflow-types.js";
|
|
4
|
+
export function workflowRunTreeIdOf(run) {
|
|
5
|
+
const v = run.treeId;
|
|
6
|
+
return typeof v === "string" ? v : undefined;
|
|
7
|
+
}
|
|
8
|
+
export function* treeIdWalk(run) {
|
|
9
|
+
let cur = run;
|
|
10
|
+
const seen = new Set([run.id]);
|
|
11
|
+
for (;;) {
|
|
12
|
+
if (cur.resumeAdmissionIncomplete === true)
|
|
13
|
+
return "no_tree";
|
|
14
|
+
const own = workflowRunTreeIdOf(cur);
|
|
15
|
+
if (own !== undefined)
|
|
16
|
+
return { treeId: own };
|
|
17
|
+
const up = resumedFromOf(cur);
|
|
18
|
+
if (up === undefined)
|
|
19
|
+
return { treeId: cur.id };
|
|
20
|
+
const source = yield up;
|
|
21
|
+
if (source === "unreadable")
|
|
22
|
+
return "unreadable";
|
|
23
|
+
if (source === null || !isContinuationOf(source, cur))
|
|
24
|
+
return "no_tree";
|
|
25
|
+
if (seen.has(up))
|
|
26
|
+
return "unreadable";
|
|
27
|
+
if (seen.size >= WORKFLOW_TREE_RUNS_MAX)
|
|
28
|
+
return "over_bound";
|
|
29
|
+
seen.add(up);
|
|
30
|
+
cur = source;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export async function treeIdOf(store, run, scope, within) {
|
|
34
|
+
return driveAsync(treeIdWalk(run), (id) => readWorkflowRunIn(store, id, scope, within));
|
|
35
|
+
}
|
|
36
|
+
async function driveAsync(walk, read) {
|
|
37
|
+
let step = walk.next();
|
|
38
|
+
while (step.done !== true)
|
|
39
|
+
step = walk.next(await read(step.value));
|
|
40
|
+
return step.value;
|
|
41
|
+
}
|
|
42
|
+
export function* treeIdStampWalk(run) {
|
|
43
|
+
if (workflowRunTreeIdOf(run) !== undefined)
|
|
44
|
+
return { kind: "skip", why: "stamped" };
|
|
45
|
+
if (run.status !== "completed" && run.status !== "failed")
|
|
46
|
+
return { kind: "skip", why: "running" };
|
|
47
|
+
if (run.resumeAdmissionIncomplete === true)
|
|
48
|
+
return { kind: "skip", why: "admission_incomplete" };
|
|
49
|
+
const tree = yield* treeIdWalk(run);
|
|
50
|
+
if (tree === "no_tree")
|
|
51
|
+
return { kind: "skip", why: "no_tree" };
|
|
52
|
+
if (typeof tree === "string")
|
|
53
|
+
return tree;
|
|
54
|
+
return { kind: "stamp", treeId: tree.treeId, expect: { rev: typeof run.rev === "number" ? run.rev : 0, creationId: workflowRunCreationIdOf(run) }, cause: "tree_id_stamp" };
|
|
55
|
+
}
|
|
56
|
+
export function workflowTreeIdStampOf(store, run, scope) {
|
|
57
|
+
const within = boundedStoreRead(WORKFLOW_STORE_WAIT_BOUND_MS);
|
|
58
|
+
return driveAsync(treeIdStampWalk(run), (id) => readWorkflowRunIn(store, id, scope, within));
|
|
59
|
+
}
|
|
60
|
+
export function workflowTreeIdStampInHand(run, read) {
|
|
61
|
+
const walk = treeIdStampWalk(run);
|
|
62
|
+
let step = walk.next();
|
|
63
|
+
while (step.done !== true)
|
|
64
|
+
step = walk.next(read(step.value));
|
|
65
|
+
return step.value;
|
|
66
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TaskResult, TaskStatus, ToolActivity } from "../core/types.js";
|
|
2
|
+
import type { WorkflowRunTree } from "./workflow-park-adoption.js";
|
|
2
3
|
import { type MemberLedger, type MemberOutcome, type MemberOutcomeWord } from "../core/member-outcome.js";
|
|
3
4
|
/** How many decision marks one park entry keeps ({@link WorkflowRun.parks}`[].settledDecisions`), final and recoverable together.
|
|
4
5
|
* A full entry takes a final mark only by dropping its oldest recoverable one; with none to drop, and for a recoverable mark, the
|
|
@@ -423,13 +424,31 @@ export interface WorkflowRun {
|
|
|
423
424
|
createdAt: number;
|
|
424
425
|
/** Optimistic-concurrency revision for the store (S1b); unset for a pure in-memory run. */
|
|
425
426
|
rev?: number;
|
|
427
|
+
/**
|
|
428
|
+
* Which creation of this run id the record is: minted at random by the engine before the record is created, written by the
|
|
429
|
+
* create and never changed after. The engine names it on every write it makes of a record (`WorkflowRunStore.update`'s
|
|
430
|
+
* `expect.creationId`), so a write meant for one creation never lands on a record created again under the same id. Its own run
|
|
431
|
+
* never reads it back (it writes from the run it holds). Read only as a string: any other stored value is none. Absent on a
|
|
432
|
+
* record an older engine created. A store keeps it as written.
|
|
433
|
+
*/
|
|
434
|
+
creationId?: string;
|
|
435
|
+
/**
|
|
436
|
+
* The id of the workflow tree this record belongs to — the id of the run the tree started from. A fresh run writes its own id at
|
|
437
|
+
* its create; a continuation writes it when its resume admission completes, copied from the run it continues (or from the first
|
|
438
|
+
* run above it that carries one, else the top run's id), in the same write as {@link resume}; a finished record an older engine
|
|
439
|
+
* wrote may be given it afterwards (`workflowTreeIdStampOf`). Absent while a continuation's admission has not completed, on a
|
|
440
|
+
* continuation whose line up does not read whole (a run above it gone or created again), and on a record no engine has given it.
|
|
441
|
+
* Read only as a string. Nothing of this release reads it to decide anything; a store keeps it as written.
|
|
442
|
+
*/
|
|
443
|
+
treeId?: string;
|
|
426
444
|
/** Set when `status === "failed"`: the error the script threw. */
|
|
427
445
|
error?: string;
|
|
428
446
|
/** #688 C4 (additive) — the MACHINE code of the failure that ended the run, in the same vocabulary as
|
|
429
447
|
* {@link WorkflowAgentRun.errorCode} (`workflow.*` for the orchestration's own refusals, a task's terminal code
|
|
430
448
|
* for a child's failure), so a consumer branches here and never on `error`'s text. Attribution, in order:
|
|
431
449
|
* 1. the thrown value's own string `code` — the run SUSPENDED on a parked agent ⇒ `workflow.agent_parked`
|
|
432
|
-
* (whatever the body threw after the park)
|
|
450
|
+
* (whatever the body threw after the park) — and only then: a thrown value carrying that code while the run did not suspend on
|
|
451
|
+
* a park is passed over (the next rung answers), so the code is the park terminal's alone —, a refused spawn ⇒ `workflow.agent_blocked`, the budget /
|
|
433
452
|
* nesting / schema / stall / max-agents refusals ⇒ their `WorkflowBudgetExceededError`… codes, a body that
|
|
434
453
|
* re-threw a typed error ⇒ that error's code;
|
|
435
454
|
* 2. otherwise the FIRST failed agent record carrying a code (earliest `endedAt`, spawn order on a tie) —
|
|
@@ -494,6 +513,13 @@ export interface WorkflowRun {
|
|
|
494
513
|
* best-effort. */
|
|
495
514
|
resume?: {
|
|
496
515
|
fromRunId: string;
|
|
516
|
+
/** The {@link WorkflowRun.creationId} of the record `fromRunId` named when this continuation's admission read it — present when
|
|
517
|
+
* that record carried one. With it, this record continues `fromRunId` only while the record under that id is the same creation:
|
|
518
|
+
* one created again under the id is not the run this one continued. */
|
|
519
|
+
fromCreationId?: string;
|
|
520
|
+
/** The run the resume was named for, when it is not `fromRunId`: a resume carrying no decision that named a run already
|
|
521
|
+
* continued continues the last run of that run's line instead (`fromRunId`). Absent when the resume continues the run named. */
|
|
522
|
+
asked?: string;
|
|
497
523
|
journalEntries: number;
|
|
498
524
|
replayed: number;
|
|
499
525
|
divergedAtOrdinal?: number;
|
|
@@ -570,7 +596,7 @@ export interface WorkflowRun {
|
|
|
570
596
|
*
|
|
571
597
|
* `settledDecisions` lists the host's decisions for this park that the engine's continuation judged and told the person of —
|
|
572
598
|
* one mark per decision: each one's `decisionId`, the `reason` it was told with and that reason's `code`. A mark without
|
|
573
|
-
* `condition` is final (its `reason` a word of `
|
|
599
|
+
* `condition` is final (its `reason` a `WorkflowParkSettlingReason` — a word whose row of `WORKFLOW_PARK_UNUSED_REASON_CLASS` has a `spent` class; a reader counts no other word there): the engine
|
|
574
600
|
* will never use the decision. A mark with `condition` (#4833) is recoverable: the decision was not used in that state of the
|
|
575
601
|
* run — `condition` is an opaque, fixed-length digest of what the person was told (compare it, never parse it), `inputs` the
|
|
576
602
|
* fold inputs a `host_changed` named — and handed over again in the same state it is told nothing; in another state it is told
|
|
@@ -580,8 +606,10 @@ export interface WorkflowRun {
|
|
|
580
606
|
* {@link WORKFLOW_PARK_DECISION_MARK_BYTES_MAX} bytes per mark (past either a decision is not recorded; a full entry makes room
|
|
581
607
|
* for a final mark by dropping its oldest recoverable one). It rides with the park: a run that comes to hold the park (it re-parks the same card, or the park passes to it)
|
|
582
608
|
* carries its holder's list onto its own entry as it reads it then — a mark another leg writes on the earlier holder after that is on
|
|
583
|
-
* that record alone, so a reader reads the park's
|
|
584
|
-
* and an earlier holder's is not, that one holds the park again without what was recorded after it.
|
|
609
|
+
* that record alone, so a reader reads the park's tree. A mark lives as long as its record: when the latest holder's record is gone
|
|
610
|
+
* and an earlier holder's is not, that one holds the park again without what was recorded after it. How a reader counts a mark: a
|
|
611
|
+
* final mark belongs to the decision (the token) — on any entry of this token in the tree it counts; a recoverable mark belongs to
|
|
612
|
+
* the holder — it counts on the holder's own entry alone.
|
|
585
613
|
* `workflowParkDecisionOf` reads it; a decision a final mark names, handed over again, is told nothing and never carried. A store
|
|
586
614
|
* that does not keep the member costs only that: every hand-over is judged and told again, as before the member. A store that keeps
|
|
587
615
|
* a mark but drops its `condition` turns a `denied` or `card_unresumable` mark final (read `spent`; the run store contract kit holds
|
|
@@ -794,6 +822,43 @@ export declare class WorkflowAgentBlockedError extends Error {
|
|
|
794
822
|
* checkpoint's gate — an approval a person still has to decide, or a resource limit (a scheduler's yield among them,
|
|
795
823
|
* which a resume of the run continues with no decision). */
|
|
796
824
|
export declare const WORKFLOW_AGENT_PARKED_ERROR_CODE = "workflow.agent_parked";
|
|
825
|
+
/**
|
|
826
|
+
* #4760 — how a stop of ONE member of a workflow run answers ({@link WorkflowAgentStopReceipt}) — the closed set (a face that
|
|
827
|
+
* renders the answer keeps a row per word). The two refusal words about a card are the task stop face's own (a stop of a background
|
|
828
|
+
* agent answers with them for the same facts):
|
|
829
|
+
* - `stopped` — the member was stopped (by this call, or by an earlier stop: `stoppedBy` names the first; a member of a run whose
|
|
830
|
+
* own signal was already aborted names the run's stopper — `parent` for its cancel, `system` for its deadline — and, like every
|
|
831
|
+
* member the run's stop ended, runs again on a resume);
|
|
832
|
+
* - `already_terminal` — it had already ended; nothing was stopped (`status`: its outcome word, or `parked` for a member of a run
|
|
833
|
+
* that has suspended on its approvals — stopping that run is the run's stop, not a member's). A member whose leg outlived its
|
|
834
|
+
* run, stopped once the run's journal was sealed, answers this too (`status` `failed`, as the run's end wrote its row): it is not
|
|
835
|
+
* recorded as stopped, and a resume runs it again;
|
|
836
|
+
* - `not_found` — no member of the run has that call key (or no run the caller can see, through the task registry);
|
|
837
|
+
* - `not_local` — the run runs in another process: the member cannot be stopped from here (through the task registry);
|
|
838
|
+
* - `park_resume_won` — the member waits on an approval card and the card was taken first, read back no longer pending: a person's
|
|
839
|
+
* decision (it continues the member), or the card's own expiry (its deadline) — the stop did not take it;
|
|
840
|
+
* - `park_arbiter_unreachable` — the member waits on an approval card and the checkpoint store could not settle the stop: it did not
|
|
841
|
+
* answer in time, or it left the card pending without a decision (the run's grant on the card was superseded), or the row it read
|
|
842
|
+
* is not this park's — the member still waits; stop it again.
|
|
843
|
+
*/
|
|
844
|
+
export declare const WORKFLOW_AGENT_STOP_ANSWERS: readonly ["stopped", "already_terminal", "not_found", "not_local", "park_resume_won", "park_arbiter_unreachable"];
|
|
845
|
+
export type WorkflowAgentStopAnswer = (typeof WORKFLOW_AGENT_STOP_ANSWERS)[number];
|
|
846
|
+
/** A member stop's answer ({@link WORKFLOW_AGENT_STOP_ANSWERS}) and what it says beside its word. */
|
|
847
|
+
export type WorkflowAgentStopReceipt = {
|
|
848
|
+
readonly answer: "stopped"; /** Who stopped it: the caller's word (`parent` by default; a service passes `user` for a person). */
|
|
849
|
+
readonly stoppedBy: string;
|
|
850
|
+
} | {
|
|
851
|
+
readonly answer: "already_terminal";
|
|
852
|
+
readonly status: string;
|
|
853
|
+
} | {
|
|
854
|
+
readonly answer: "not_found";
|
|
855
|
+
} | {
|
|
856
|
+
readonly answer: "not_local";
|
|
857
|
+
} | {
|
|
858
|
+
readonly answer: "park_resume_won";
|
|
859
|
+
} | {
|
|
860
|
+
readonly answer: "park_arbiter_unreachable";
|
|
861
|
+
};
|
|
797
862
|
/** The agent rows that are PARKED — the one definition of "this row is parked" (the row's own word,
|
|
798
863
|
* {@link WorkflowItemStatus} `"parked"`). The `<usage>` block's `agents_parked` count and the run-level
|
|
799
864
|
* {@link runParkedOf} both read it, so the two can never disagree about which rows count.
|
|
@@ -804,6 +869,10 @@ export declare const WORKFLOW_AGENT_PARKED_ERROR_CODE = "workflow.agent_parked";
|
|
|
804
869
|
export declare function parkedAgentsOf<A extends {
|
|
805
870
|
readonly status: string;
|
|
806
871
|
}>(agents: ReadonlyArray<A>): A[];
|
|
872
|
+
/** The code of the first agent of a run that failed carrying one (earliest `endedAt`, spawn order on a tie) — the second rung of
|
|
873
|
+
* {@link WorkflowRun.errorCode}'s attribution, and one of the two codes a workflow's completion notification carries (an engine's
|
|
874
|
+
* word for a child's failure, never a script's own). */
|
|
875
|
+
export declare function firstFailedAgentCodeOf(agents: ReadonlyArray<Pick<WorkflowAgentRun, "status" | "errorCode" | "endedAt">>): string | undefined;
|
|
807
876
|
/**
|
|
808
877
|
* Run-level parked bit: this run is STILL RUNNING while at least one of its legs is parked (on any gate — what a leg
|
|
809
878
|
* waits on is its checkpoint's gate, never the run's) — something is being waited on, and the closed `status` word
|
|
@@ -849,7 +918,8 @@ export type WorkflowParkCardState = "pending" | "resolved" | "expired" | "absent
|
|
|
849
918
|
* (`workflowParkWaitOf`; the display, the poll face and a host's views read only it):
|
|
850
919
|
* - `waiting` — the run holds the park (the holder law names it, alone or in a fork) and its card is pending;
|
|
851
920
|
* - `moved_on` — a later run of the chain took the park up: it drove the parked step (its decision account has a `driven` row for that
|
|
852
|
-
* call),
|
|
921
|
+
* call), it parked the same call again on another card of its own while this card is still pending (#5183: the step was asked
|
|
922
|
+
* again — this card has no line waiting on it), or the holder law names it now (the park passed to it, or a later generation parked again); `runIds` — that run, or every
|
|
853
923
|
* run of a fork (sorted), never this one;
|
|
854
924
|
* - `lapsed` — the card no longer waits (`card`: decided elsewhere, expired, or removed) and no run of the chain drove it;
|
|
855
925
|
* - `unknown` — no answer: the card was not read (`card_unread`), or the records handed in hold no holder of the park
|
|
@@ -881,11 +951,18 @@ export type WorkflowParkHolder = {
|
|
|
881
951
|
/**
|
|
882
952
|
* The holder law of {@link WorkflowRun.parks}, as one function: among the records given, a record's run holds the park
|
|
883
953
|
* on `token` iff one of its entries for that token says `parkedBy === record.id` (with a generation); the holder is the
|
|
884
|
-
* one at the highest generation, a tie between runs is a fork, no such entry is nobody. Pure over the
|
|
954
|
+
* one at the highest generation, a tie between runs is a fork, no such entry is nobody. Pure over the tree — whether
|
|
885
955
|
* the card is still pending is the checkpoint store's word, never this. A host routes a decision by it and the engine's
|
|
886
|
-
* continuation checks the run a decision names against it, so the two read one judge
|
|
956
|
+
* continuation checks the run a decision names against it, so the two read one judge over one reading of the tree: it takes only
|
|
957
|
+
* what the tree reader (`readWorkflowRunTree`) answers — the run of any one card the host holds names the whole tree. The holder
|
|
958
|
+
* is where the engine writes what it records of a park's decisions; how those records count: a final mark belongs to the decision
|
|
959
|
+
* (the token) — on any entry of this token in the tree it counts; a recoverable mark belongs to the holder — it counts on the
|
|
960
|
+
* holder's own entry alone.
|
|
887
961
|
*/
|
|
888
|
-
export declare function workflowParkHolderOf(token: string,
|
|
962
|
+
export declare function workflowParkHolderOf(token: string, tree: WorkflowRunTree): WorkflowParkHolder;
|
|
963
|
+
/** {@link workflowParkHolderOf}'s law over records the engine holds itself (a tree it read, less the run that is reading it). Not
|
|
964
|
+
* at the package root: a host's judges take a tree. */
|
|
965
|
+
export declare function parkHolderAmong(token: string, records: ReadonlyArray<Pick<WorkflowRun, "id" | "parks"> | null | undefined>): WorkflowParkHolder;
|
|
889
966
|
/** What the record and the completion frame of a run say when the step it parked on is asked again — the same judgment as the
|
|
890
967
|
* card's `workflowStepAskedAgain`: the run it resumed had taken the step up (its card stopped waiting without a decision, or
|
|
891
968
|
* the step completed there and runs again because the replay stopped before it), and this run ran it live and it asked anew. */
|
|
@@ -928,9 +1005,11 @@ export declare class WorkflowAgentParkedError extends Error {
|
|
|
928
1005
|
* by the decision's position: `driving` (the parked child is driven on with it, the call continues), `settled` (its
|
|
929
1006
|
* checkpoint is no longer pending — the call returns failed, `workflow.park_not_pending`, its outcome unread),
|
|
930
1007
|
* `already_taken` (a decision for this token was accepted earlier in this run), `not_parked_here` (no park of this run
|
|
931
|
-
* waits on the token), `unreadable` (
|
|
932
|
-
*
|
|
933
|
-
*
|
|
1008
|
+
* waits on the token), `unreadable` (a store's word the delivery needs could not be read — the checkpoint store's for the park, or
|
|
1009
|
+
* the run store's records of the run's tree a decision that names itself is judged over — the park stands), `spent` (#5005: the
|
|
1010
|
+
* decision is already spent on this park — `workflowParkDecisionOf` over the run's tree, this run's own record as it holds it, reads it
|
|
1011
|
+
* `spent`, the reading the continuation's judge shares; it is not driven again, the park stands for a new decision; the run log names
|
|
1012
|
+
* the refusal's code). */
|
|
934
1013
|
export type WorkflowParkDeliveryResult = "driving" | "settled" | "already_taken" | "not_parked_here" | "unreadable" | "spent";
|
|
935
1014
|
/** #2561 — the answer to a delivery: `live` (the run is running here and took the decisions, per-decision
|
|
936
1015
|
* `results`); `suspending` (the run is ending in this process — suspended on its parks, or finishing; `ended`
|
|
@@ -81,14 +81,23 @@ export class WorkflowAgentBlockedError extends Error {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
export const WORKFLOW_AGENT_PARKED_ERROR_CODE = "workflow.agent_parked";
|
|
84
|
+
export const WORKFLOW_AGENT_STOP_ANSWERS = Object.freeze(["stopped", "already_terminal", "not_found", "not_local", "park_resume_won", "park_arbiter_unreachable"]);
|
|
84
85
|
export function parkedAgentsOf(agents) {
|
|
85
86
|
return agents.filter((a) => a.status === "parked");
|
|
86
87
|
}
|
|
88
|
+
export function firstFailedAgentCodeOf(agents) {
|
|
89
|
+
return agents
|
|
90
|
+
.filter((a) => a.status === "failed" && typeof a.errorCode === "string" && a.errorCode !== "")
|
|
91
|
+
.sort((a, b) => (a.endedAt ?? Number.POSITIVE_INFINITY) - (b.endedAt ?? Number.POSITIVE_INFINITY))[0]?.errorCode;
|
|
92
|
+
}
|
|
87
93
|
export function runParkedOf(run) {
|
|
88
94
|
return run.status === "running" && parkedAgentsOf(run.agents).length > 0;
|
|
89
95
|
}
|
|
90
96
|
export const WORKFLOW_STORE_WAIT_BOUND_MS = 10_000;
|
|
91
|
-
export function workflowParkHolderOf(token,
|
|
97
|
+
export function workflowParkHolderOf(token, tree) {
|
|
98
|
+
return parkHolderAmong(token, tree.records);
|
|
99
|
+
}
|
|
100
|
+
export function parkHolderAmong(token, records) {
|
|
92
101
|
let top = -1;
|
|
93
102
|
let runIds = [];
|
|
94
103
|
for (const r of records) {
|
|
@@ -4,10 +4,11 @@ import type { InheritedGate, RunInternals, RunnerSelfSeat } from "../core/runner
|
|
|
4
4
|
import type { CheckpointStore, CheckpointToken, ResumeOutcome } from "../core/checkpoint-store.js";
|
|
5
5
|
import type { AgentDefinition, TaskEvent, TaskSpec, ThinkingLevel } from "../core/types.js";
|
|
6
6
|
import { type ParentSpecSeat } from "../core/parent-spec-seat.js";
|
|
7
|
-
import type
|
|
7
|
+
import { type WorkflowRunStore } from "../core/workflow-run-store.js";
|
|
8
8
|
import type { WorkflowJournalStore, WorkflowLaunchRecord, ResumeClaimArgs } from "../core/workflow-journal-store.js";
|
|
9
9
|
import { type WorkflowAgentResult } from "./workflow-types.js";
|
|
10
|
-
import
|
|
10
|
+
import { type WorkflowClaimLapse } from "./workflow-park-adoption.js";
|
|
11
|
+
import type { WorkflowRun, WorkflowEvent, WorkflowAgentStopReceipt } from "./workflow-types.js";
|
|
11
12
|
import { type TaskArtifactSeat } from "../core/tool-result-store.js";
|
|
12
13
|
export * from "./workflow-types.js";
|
|
13
14
|
/** 198 `P0m` (pretty.js:447248) — prose state: the child's final text is the script-facing return value. */
|
|
@@ -158,6 +159,12 @@ export interface WorkflowInternals {
|
|
|
158
159
|
* definitions' servers, its registry's servers, what the tools it hands its agents carry — from this call until it can start no agent (it has ended and none
|
|
159
160
|
* of its calls is in flight). Looked up by identity: an object the engine did not mint carries nothing. */
|
|
160
161
|
launchingTool?: object;
|
|
162
|
+
/** The workflow's resume claim the launching Workflow tool already holds for this run (the root of its tree, as the tool walked to
|
|
163
|
+
* it before the run existed): the run's admission takes the claim under this same key, and refuses the resume when its own walk
|
|
164
|
+
* reaches another root — a resume holds one claim key. */
|
|
165
|
+
resumeClaimKey?: string;
|
|
166
|
+
/** The run the model named, when the launching Workflow tool continues the last run of that run's line instead (`resume.asked`). */
|
|
167
|
+
resumeAsked?: string;
|
|
161
168
|
}
|
|
162
169
|
export interface WorkflowBudget {
|
|
163
170
|
/** The token ceiling, or null when none was set (then `remaining()` is Infinity). */
|
|
@@ -255,6 +262,10 @@ export interface WorkflowAgentHandle {
|
|
|
255
262
|
/** Await the agent's {@link TaskResult} (the same value the eager recording used; idempotent) with the run's reading of how the
|
|
256
263
|
* member ended (`member`, the row's outcome). On a resume that replayed this call it is the journaled result, settled at once. */
|
|
257
264
|
result(): Promise<WorkflowAgentResult>;
|
|
265
|
+
/** #4760 — stop this member (by `parent`, the handle's holder): {@link WorkflowHandle.stopAgent} on its call key — its leg is
|
|
266
|
+
* signalled to stop and `result()` resolves with a `killed` member naming `parent`; the run goes on. Optional: a handle a host
|
|
267
|
+
* assembles itself need not answer. */
|
|
268
|
+
stop?(): Promise<WorkflowAgentStopReceipt>;
|
|
258
269
|
}
|
|
259
270
|
export interface WorkflowRunContext {
|
|
260
271
|
readonly runId: string;
|
|
@@ -716,6 +727,20 @@ export interface WorkflowHandle<T> {
|
|
|
716
727
|
* engine's own run record, nothing a script or a host provides. Optional: a handle a host assembles itself need not answer,
|
|
717
728
|
* and a reader treats anything but `true` as "not waiting". */
|
|
718
729
|
parked?(): boolean;
|
|
730
|
+
/** #4760 — stop ONE member by its call key (`WorkflowAgentRun.callKey`; `stoppedBy` defaults to `parent`): the member's agent is
|
|
731
|
+
* signalled to stop and its call RETURNS (to the script) a `killed` outcome naming `stoppedBy` — the run goes on; a member waiting
|
|
732
|
+
* on an approval card while the run runs has the card expired first (a decision that took it first continues it:
|
|
733
|
+
* `park_resume_won`). A resume replays a member this method stopped as stopped, without running it again — also one the run's
|
|
734
|
+
* end overtook while it unwound. Two answers say what that does not cover: a member of a run whose own signal is already
|
|
735
|
+
* aborted (its cancel or deadline) answers `stopped` naming the RUN's stopper (`parent` / `system`), not `stoppedBy` — the run's
|
|
736
|
+
* stop ended it, and a resume runs it again as for every member a run's cancel ended; a member that outlived the run, stopped
|
|
737
|
+
* after the run's journal was sealed (once `done` has settled), answers `already_terminal` — not stopped, and a resume runs it
|
|
738
|
+
* again. The answers: {@link WORKFLOW_AGENT_STOP_ANSWERS}. Stopping the whole run — one that waits on an approval included — is
|
|
739
|
+
* not this method's.
|
|
740
|
+
* Optional, like {@link parked}: a handle a host assembles itself need not answer. */
|
|
741
|
+
stopAgent?(callKey: string, opts?: {
|
|
742
|
+
stoppedBy?: string;
|
|
743
|
+
}): Promise<WorkflowAgentStopReceipt>;
|
|
719
744
|
/** #4851 — whether the run's record landed in its run store: `true` once the store took the create (or when no run store is
|
|
720
745
|
* wired: there is no record to land), `false` when it refused it or did not answer within the store wait. What is kept by the
|
|
721
746
|
* run's id and found through its record — the launch record, a copy of the script — is written only after `true`. Optional: a
|
|
@@ -814,8 +839,9 @@ export declare const workflowResumeClaimFallback: {
|
|
|
814
839
|
export interface WorkflowResumeClaimVerdict {
|
|
815
840
|
readonly granted: boolean;
|
|
816
841
|
readonly holder?: string;
|
|
817
|
-
/** On a refusal
|
|
818
|
-
|
|
842
|
+
/** On a refusal by the store: the remaining time it answered, read once as the refusal arrived ({@link claimRemainingOf}) — what
|
|
843
|
+
* every refusal sentence names of when the claim lapses. */
|
|
844
|
+
readonly lapse?: WorkflowClaimLapse;
|
|
819
845
|
readonly fallback: boolean;
|
|
820
846
|
}
|
|
821
847
|
/**
|