@sema-agent/core 7.58.0 → 7.60.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 +1340 -0
- package/README.md +6 -4
- package/dist/agents/agent-definition.d.ts +7 -0
- package/dist/agents/agent-definition.js +12 -0
- package/dist/agents/agent-transcript-tool.d.ts +2 -1
- package/dist/agents/agent-transcript-tool.js +3 -1
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +9 -4
- package/dist/agents/cumulative-stats.js +0 -1
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +22 -0
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/retain-ledger.d.ts +11 -1
- package/dist/agents/retain-ledger.js +13 -2
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/roster-store.js +3 -1
- package/dist/agents/send-message-tool.d.ts +8 -19
- package/dist/agents/send-message-tool.js +32 -50
- package/dist/agents/subagent.d.ts +51 -17
- package/dist/agents/subagent.js +150 -112
- package/dist/agents/tool-filter.d.ts +1 -3
- package/dist/agents/tool-filter.js +4 -12
- package/dist/bench/metrics.d.ts +3 -5
- package/dist/bench/metrics.js +0 -1
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/degrading.js +3 -1
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +90 -22
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/status-sink.d.ts +7 -1
- package/dist/brain/status-sink.js +6 -0
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +65 -6
- package/dist/brain/timeout.js +111 -11
- package/dist/core/a2a.d.ts +15 -5
- package/dist/core/a2a.js +34 -19
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/agent-definition.d.ts +20 -0
- package/dist/core/allow-entry.d.ts +20 -6
- package/dist/core/allow-entry.js +17 -7
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/artifact-host.d.ts +0 -2
- package/dist/core/artifact-host.js +0 -1
- package/dist/core/auto-compaction.js +1 -1
- package/dist/core/auto-mode-defaults.d.ts +8 -0
- package/dist/core/auto-mode-defaults.js +1 -0
- package/dist/core/auto-mode-rebuild.d.ts +2 -1
- package/dist/core/auto-mode.d.ts +39 -4
- package/dist/core/auto-mode.js +63 -12
- package/dist/core/background-agent-store.d.ts +26 -4
- package/dist/core/background-agent-store.js +3 -2
- package/dist/core/background-shell.d.ts +12 -1
- package/dist/core/background-shell.js +12 -0
- package/dist/core/checkpoint-requirements.d.ts +13 -1
- package/dist/core/checkpoint-requirements.js +3 -1
- package/dist/core/checkpoint-store.d.ts +66 -25
- package/dist/core/checkpoint-store.js +22 -9
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +3 -3
- package/dist/core/compliance.js +1 -1
- package/dist/core/credential-echo.d.ts +52 -0
- package/dist/core/credential-echo.js +65 -0
- package/dist/core/credential-vocabulary.d.ts +13 -3
- package/dist/core/credential-vocabulary.js +12 -4
- package/dist/core/cross-boundary-taint.d.ts +4 -5
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +156 -23
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/frame-settlement.d.ts +5 -0
- package/dist/core/frame-settlement.js +4 -0
- package/dist/core/gate-fold.js +8 -6
- package/dist/core/gate-lanes.js +47 -12
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/governance-codes.d.ts +17 -1
- package/dist/core/governance-codes.js +25 -0
- package/dist/core/hands-band-screen.js +0 -1
- package/dist/core/hands-band.d.ts +0 -3
- package/dist/core/hooks.d.ts +70 -59
- package/dist/core/hooks.js +125 -80
- package/dist/core/image-admission.d.ts +106 -52
- package/dist/core/image-admission.js +184 -56
- package/dist/core/image-downsample.d.ts +36 -69
- package/dist/core/image-downsample.js +111 -73
- package/dist/core/integer-option.d.ts +21 -0
- package/dist/core/integer-option.js +13 -0
- package/dist/core/locked-config.d.ts +59 -5
- package/dist/core/locked-config.js +82 -50
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-call-meta.js +9 -10
- package/dist/core/mcp-failure.d.ts +122 -20
- package/dist/core/mcp-failure.js +73 -5
- package/dist/core/mcp-host-seat.d.ts +92 -0
- package/dist/core/mcp-host-seat.js +131 -0
- package/dist/core/mcp-probe.d.ts +7 -2
- package/dist/core/mcp-probe.js +7 -2
- package/dist/core/mcp-server-link.d.ts +22 -1
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp-server-spec.d.ts +38 -9
- package/dist/core/mcp-server-spec.js +55 -21
- package/dist/core/mcp.d.ts +27 -12
- package/dist/core/mcp.js +105 -76
- package/dist/core/memory-admission.d.ts +23 -6
- package/dist/core/memory-admission.js +19 -9
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/content-origin.d.ts +13 -0
- package/dist/core/memory-engine/content-origin.js +21 -3
- package/dist/core/memory-engine/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +3 -2
- package/dist/core/memory-engine/index.js +2 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- package/dist/core/memory-engine/scope-contract.d.ts +13 -3
- package/dist/core/memory-engine/scope-contract.js +2 -2
- package/dist/core/memory-engine/sync-client.d.ts +51 -9
- package/dist/core/memory-engine/sync-client.js +107 -13
- package/dist/core/memory-engine/sync-report.d.ts +103 -0
- package/dist/core/memory-engine/sync-report.js +119 -0
- package/dist/core/memory-engine/sync.d.ts +8 -1
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mode-policy.d.ts +9 -1
- package/dist/core/mode-policy.js +11 -1
- package/dist/core/model-receipt.d.ts +39 -0
- package/dist/core/model-receipt.js +139 -0
- package/dist/core/mods/agent-stations.d.ts +65 -0
- package/dist/core/mods/agent-stations.js +105 -0
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.js +6 -5
- package/dist/core/mods/kernel/events.d.ts +11 -4
- package/dist/core/mods/kernel/events.js +11 -7
- package/dist/core/mods/kernel/receive.d.ts +5 -0
- package/dist/core/mods/kernel/receive.js +10 -0
- package/dist/core/mods/kernel/registration.d.ts +4 -0
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/lifecycle-stations.d.ts +41 -0
- package/dist/core/mods/lifecycle-stations.js +35 -0
- package/dist/core/mods/stations.d.ts +73 -60
- package/dist/core/mods/stations.js +64 -40
- package/dist/core/mods/tool-call.d.ts +10 -4
- package/dist/core/mods/tool-call.js +28 -12
- package/dist/core/mounted-mcp.d.ts +5 -0
- package/dist/core/mounted-mcp.js +2 -2
- package/dist/core/namespaced-rule-name.d.ts +7 -1
- package/dist/core/namespaced-rule-name.js +13 -2
- package/dist/core/oracle-isolation.js +1 -1
- package/dist/core/own-property-receipt.d.ts +3 -0
- package/dist/core/own-property-receipt.js +3 -0
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +14 -8
- package/dist/core/peer-seat.d.ts +133 -16
- package/dist/core/peer-seat.js +319 -42
- package/dist/core/permission-rule-consent.d.ts +0 -21
- package/dist/core/permission-rule-consent.js +11 -6
- package/dist/core/permission-rule-model.d.ts +20 -2
- package/dist/core/permission-rule-model.js +8 -7
- package/dist/core/present-plan-tool.d.ts +11 -3
- package/dist/core/present-plan-tool.js +2 -2
- package/dist/core/protocol-http-auth.d.ts +14 -2
- package/dist/core/protocol-http-auth.js +16 -7
- package/dist/core/read-face-seats.d.ts +7 -5
- package/dist/core/read-face-seats.js +4 -1
- package/dist/core/redaction-marks.d.ts +4 -3
- package/dist/core/redaction-marks.js +2 -2
- package/dist/core/remote-env.d.ts +146 -98
- package/dist/core/remote-env.js +113 -14
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/retention.js +37 -12
- package/dist/core/retired-keys.d.ts +6 -1
- package/dist/core/retired-keys.js +4 -1
- package/dist/core/rewrite-rejudge.d.ts +13 -5
- package/dist/core/rewrite-rejudge.js +9 -5
- package/dist/core/roles.d.ts +69 -3
- package/dist/core/roles.js +167 -80
- package/dist/core/rule-owner.d.ts +3 -0
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/assemble-result.d.ts +0 -5
- package/dist/core/runner/assemble-result.js +0 -1
- package/dist/core/runner/call-hook-stations.d.ts +17 -10
- package/dist/core/runner/call-hook-stations.js +23 -12
- package/dist/core/runner/child-tree.d.ts +7 -8
- package/dist/core/runner/child-tree.js +6 -6
- package/dist/core/runner/classifier-ladder.d.ts +10 -2
- package/dist/core/runner/classifier-ladder.js +39 -8
- package/dist/core/runner/construction-doors.js +5 -0
- package/dist/core/runner/contracts.d.ts +82 -57
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
- package/dist/core/runner/cross-boundary-lane.js +11 -2
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/env-capability-census.d.ts +15 -20
- package/dist/core/runner/env-capability-census.js +25 -34
- package/dist/core/runner/file-history-request.d.ts +2 -2
- package/dist/core/runner/file-history-request.js +0 -8
- package/dist/core/runner/gate-exit.d.ts +87 -11
- package/dist/core/runner/gate-exit.js +30 -8
- package/dist/core/runner/git-status-frame.d.ts +5 -2
- package/dist/core/runner/git-status-frame.js +3 -4
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- package/dist/core/runner/image.d.ts +7 -2
- package/dist/core/runner/image.js +14 -8
- package/dist/core/runner/inline-image.d.ts +10 -8
- package/dist/core/runner/inline-image.js +11 -9
- package/dist/core/runner/memory-consolidation-driver.js +5 -5
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/permission-rule-lanes.js +1 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
- package/dist/core/runner/prepare-boundary-parks.js +5 -5
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -1
- package/dist/core/runner/prepare-config-doors.js +16 -9
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +9 -3
- package/dist/core/runner/prepare-delegation-surface.js +5 -4
- package/dist/core/runner/prepare-file-history.d.ts +10 -12
- package/dist/core/runner/prepare-file-history.js +3 -12
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -3
- package/dist/core/runner/prepare-gate-stations.js +4 -3
- package/dist/core/runner/prepare-hands-readface.d.ts +7 -1
- package/dist/core/runner/prepare-hands-readface.js +19 -6
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -7
- package/dist/core/runner/prepare-inherited-gate.js +22 -31
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.d.ts +2 -2
- package/dist/core/runner/prepare-memory.js +12 -19
- package/dist/core/runner/prepare-park-ask.d.ts +4 -6
- package/dist/core/runner/prepare-park-ask.js +5 -9
- package/dist/core/runner/prepare-policy-chain.d.ts +8 -7
- package/dist/core/runner/prepare-policy-chain.js +136 -121
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +10 -7
- package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -2
- package/dist/core/runner/prepare-prompt-inputs.js +10 -20
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
- package/dist/core/runner/prepare-protocol-tools.js +17 -2
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-suspend-saga.d.ts +0 -2
- package/dist/core/runner/prepare-suspend-saga.js +5 -7
- package/dist/core/runner/prepare-task.js +44 -28
- package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
- package/dist/core/runner/prepare-turn-wiring.js +7 -2
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -4
- package/dist/core/runner/prepare-wiring-manifest.js +34 -19
- package/dist/core/runner/prepare-workspace-restore.js +3 -3
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +4 -2
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-checkpoint-screen.js +4 -4
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/retired-runner-deps.js +4 -1
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-attachment-seats.js +3 -3
- package/dist/core/runner/run-brain-sinks.js +3 -0
- package/dist/core/runner/run-git-lane.d.ts +3 -1
- package/dist/core/runner/run-git-lane.js +1 -1
- package/dist/core/runner/run-harness-handlers.d.ts +3 -1
- package/dist/core/runner/run-harness-handlers.js +3 -1
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +6 -5
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +63 -56
- package/dist/core/runner/run-notification-lane.d.ts +3 -1
- package/dist/core/runner/run-notification-lane.js +16 -10
- package/dist/core/runner/run-settle-and-teardown.js +5 -1
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
- package/dist/core/runner/run-stop-and-final-verify.js +14 -6
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +89 -77
- package/dist/core/runner/runtask.d.ts +8 -5
- package/dist/core/runner/runtask.js +21 -13
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/skills-seat.js +2 -2
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +20 -7
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/tool-disclosure.js +0 -2
- package/dist/core/runner/tool-end-body.js +2 -2
- package/dist/core/runner/tool-face-overlay.d.ts +1 -1
- package/dist/core/runner/tool-face-overlay.js +26 -19
- package/dist/core/runner/tool-occurrence.d.ts +1 -1
- package/dist/core/runner/tool-occurrence.js +2 -2
- package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
- package/dist/core/runner/tool-result-media-seat.js +17 -1
- package/dist/core/runner/turn-attachments.d.ts +29 -27
- package/dist/core/runner/turn-attachments.js +27 -42
- package/dist/core/runner-deps.d.ts +32 -19
- package/dist/core/secret-env.d.ts +35 -4
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +3 -3
- package/dist/core/session-policy-store.d.ts +12 -3
- package/dist/core/session-policy-store.js +29 -10
- package/dist/core/session-store.d.ts +5 -7
- package/dist/core/session-store.js +50 -11
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +17 -5
- package/dist/core/skill-grant.js +24 -6
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +37 -0
- package/dist/core/stub-env.d.ts +5 -5
- package/dist/core/stub-env.js +11 -1
- package/dist/core/swappable-deps.d.ts +17 -43
- package/dist/core/swappable-deps.js +15 -5
- package/dist/core/synthetic-read-verdict.d.ts +1 -1
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +50 -10
- package/dist/core/task-notification.d.ts +88 -5
- package/dist/core/task-notification.js +146 -17
- package/dist/core/task-registry-agent.d.ts +18 -12
- package/dist/core/task-registry-agent.js +19 -6
- package/dist/core/task-registry-monitor.d.ts +7 -0
- package/dist/core/task-registry-monitor.js +28 -1
- package/dist/core/task-registry-shared.d.ts +43 -3
- package/dist/core/task-registry-shared.js +21 -7
- package/dist/core/task-registry-workflow.js +1 -1
- package/dist/core/task-registry.d.ts +50 -35
- package/dist/core/task-registry.js +64 -23
- package/dist/core/task-result.d.ts +3 -12
- package/dist/core/task-spec.d.ts +15 -7
- package/dist/core/task-stream.d.ts +1 -1
- package/dist/core/terminal-cause.d.ts +10 -0
- package/dist/core/tool-catalog-entries.js +1 -1
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-face-reader.d.ts +7 -6
- package/dist/core/tool-face-reader.js +4 -3
- package/dist/core/tool-name-aliases.d.ts +19 -0
- package/dist/core/tool-name-aliases.js +54 -2
- package/dist/core/tool-policy.d.ts +21 -4
- package/dist/core/tool-policy.js +1 -1
- package/dist/core/tool-registry.d.ts +5 -5
- package/dist/core/tool-registry.js +2 -2
- package/dist/core/tool-result-store.d.ts +88 -5
- package/dist/core/tool-result-store.js +51 -12
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +23 -5
- package/dist/core/trace.d.ts +0 -1
- package/dist/core/types.d.ts +5 -5
- package/dist/core/types.js +2 -2
- package/dist/core/untrusted-text.js +1 -1
- package/dist/core/user-attachment.d.ts +10 -5
- package/dist/core/user-attachment.js +15 -7
- package/dist/core/wiring-manifest.d.ts +6 -3
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +11 -5
- package/dist/engine/execution-env/node-execution-env.js +21 -13
- package/dist/engine/harness/agent-harness.d.ts +26 -3
- package/dist/engine/harness/agent-harness.js +49 -16
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +119 -28
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +18 -7
- package/dist/engine/loop/agent-loop.d.ts +20 -12
- package/dist/engine/loop/agent-loop.js +205 -36
- package/dist/engine/loop/types.d.ts +12 -3
- package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
- package/dist/engine/lsp/node-lsp-manager.js +32 -13
- package/dist/engine/session/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/storage-base.js +4 -21
- package/dist/index.d.ts +35 -21
- package/dist/index.js +26 -17
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -0
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/run-workflow-tool.d.ts +9 -3
- package/dist/orchestration/run-workflow-tool.js +59 -29
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-governance.js +2 -1
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.d.ts +4 -0
- package/dist/orchestration/workflow.js +762 -491
- package/dist/prompts/default.d.ts +1 -10
- package/dist/prompts/default.js +0 -2
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/background-agent-store.d.ts +1 -1
- package/dist/stores/file/background-agent-store.js +3 -1
- package/dist/stores/file/checkpoint-store.d.ts +127 -2
- package/dist/stores/file/checkpoint-store.js +19 -14
- package/dist/stores/file/file-history-store.d.ts +1 -1
- package/dist/stores/file/file-history-store.js +3 -1
- package/dist/stores/file/index.d.ts +4 -3
- package/dist/stores/file/index.js +17 -8
- package/dist/stores/file/mailbox-store.d.ts +1 -1
- package/dist/stores/file/mailbox-store.js +9 -11
- package/dist/stores/file/memory-store.d.ts +1 -1
- package/dist/stores/file/memory-store.js +3 -1
- package/dist/stores/file/session-policy-store.d.ts +1 -1
- package/dist/stores/file/session-policy-store.js +3 -1
- package/dist/stores/file/session-store.d.ts +1 -1
- package/dist/stores/file/session-store.js +3 -1
- package/dist/stores/file/shared-ledger.d.ts +26 -0
- package/dist/stores/file/shared-ledger.js +38 -9
- package/dist/stores/file/tool-result-store.d.ts +20 -2
- package/dist/stores/file/tool-result-store.js +74 -6
- package/dist/stores/file/usage-window-store.d.ts +1 -1
- package/dist/stores/file/usage-window-store.js +3 -1
- package/dist/stores/file/workflow-journal-store.d.ts +1 -11
- package/dist/stores/file/workflow-journal-store.js +3 -2
- package/dist/tools/fs/containment-face.d.ts +5 -0
- package/dist/tools/fs/encoding.d.ts +13 -4
- package/dist/tools/fs/encoding.js +17 -2
- package/dist/tools/fs/fs-bash-background-text.d.ts +7 -0
- package/dist/tools/fs/fs-bash-background-text.js +1 -0
- package/dist/tools/fs/fs-bash.d.ts +14 -4
- package/dist/tools/fs/fs-bash.js +29 -35
- package/dist/tools/fs/fs-pdf.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.js +26 -21
- package/dist/tools/fs/fs-read.d.ts +5 -4
- package/dist/tools/fs/fs-read.js +35 -18
- package/dist/tools/fs/fs-search-tools.js +4 -1
- package/dist/tools/fs/fs-shared.d.ts +11 -13
- package/dist/tools/fs/fs-shared.js +11 -7
- package/dist/tools/fs/fs-write.js +5 -5
- package/dist/tools/fs/index.d.ts +14 -8
- package/dist/tools/fs/index.js +13 -5
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +62 -0
- package/dist/tools/fs/read-floor.js +58 -0
- package/dist/tools/fs/removal-targets.d.ts +9 -4
- package/dist/tools/fs/removal-targets.js +17 -9
- package/dist/tools/fs/search.d.ts +3 -3
- package/dist/tools/fs/search.js +4 -4
- package/dist/tools/fs/shell-read-check.d.ts +1 -1
- package/dist/tools/fs/shell-read-check.js +2 -1
- package/dist/tools/fs/shell-read-judge.d.ts +16 -8
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +9 -4
- package/dist/tools/monitor.js +17 -8
- package/dist/tools/scheduler-tools.js +42 -4
- package/dist/tools/web.d.ts +0 -10
- package/dist/tools/web.js +1 -4
- package/package.json +5 -2
- package/test/export-surface.snapshot.json +161 -21
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core-stores-sql@7.60.0.json +30 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/core@7.60.0.json +3274 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/mods-kernel@7.60.0.json +62 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
- package/wire-changes/primitives@7.60.0.json +30 -0
package/dist/shell/lex.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shellWordsOf } from "./shell-words.js";
|
|
2
|
+
import { arithmeticCommandEnd, bracePassEnd, countingPassEnd, holdsHashFrom, passesFor, whileReading } from "./counting-pass.js";
|
|
2
3
|
export const SHELL_LEX_DIALECT = "bash";
|
|
3
4
|
export const QUOTE_KINDS = Object.freeze(["'", '"', "$'", '$"', "\\"]);
|
|
4
5
|
export const EXPANSION_KINDS = Object.freeze(["parameter", "command", "process", "arithmetic", "tilde", "brace", "glob"]);
|
|
@@ -23,6 +24,7 @@ export const PARSE_FAILURE_REASONS = Object.freeze([
|
|
|
23
24
|
"unterminated_arithmetic_expansion",
|
|
24
25
|
"unterminated_heredoc",
|
|
25
26
|
"undelimited_substitution",
|
|
27
|
+
"undelimited_substitution_heredoc",
|
|
26
28
|
"redirect_without_target",
|
|
27
29
|
"heredoc_without_delimiter",
|
|
28
30
|
"heredoc_delimiter_expands",
|
|
@@ -39,6 +41,7 @@ export const PARSE_FAILURE_SENTENCE = {
|
|
|
39
41
|
unterminated_arithmetic_expansion: "an arithmetic expansion never terminates",
|
|
40
42
|
unterminated_heredoc: "a here-document body never terminates",
|
|
41
43
|
undelimited_substitution: "a command substitution carries a construct this lexer cannot delimit",
|
|
44
|
+
undelimited_substitution_heredoc: "a here-document in a command substitution that shell versions end at different places — feed the text as stdin (`git commit -F -`) or reword it",
|
|
42
45
|
redirect_without_target: "a redirection names no target",
|
|
43
46
|
heredoc_without_delimiter: "a here-document operator names no delimiter",
|
|
44
47
|
heredoc_delimiter_expands: "a here-document delimiter is not a plain word",
|
|
@@ -149,7 +152,19 @@ function heredocHeaderOf(word, dash) {
|
|
|
149
152
|
return undefined;
|
|
150
153
|
return { delimiter: word.folded, quoted: /["'\\]/.test(word.raw), dash };
|
|
151
154
|
}
|
|
152
|
-
function
|
|
155
|
+
function documentLine(text, p, joined) {
|
|
156
|
+
let nl = text.indexOf("\n", p);
|
|
157
|
+
let line = nl < 0 ? text.slice(p) : text.slice(p, nl);
|
|
158
|
+
if (joined) {
|
|
159
|
+
while (nl >= 0 && /(?<!\\)(?:\\\\)*\\$/.test(line)) {
|
|
160
|
+
const after = text.indexOf("\n", nl + 1);
|
|
161
|
+
line = line.slice(0, -1) + (after < 0 ? text.slice(nl + 1) : text.slice(nl + 1, after));
|
|
162
|
+
nl = after;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return { line, nl };
|
|
166
|
+
}
|
|
167
|
+
function heredocBodies(text, from, headers, closer) {
|
|
153
168
|
const bodies = [];
|
|
154
169
|
let p = from;
|
|
155
170
|
for (const h of headers) {
|
|
@@ -157,21 +172,15 @@ function heredocBodies(text, from, headers, inSubstitution) {
|
|
|
157
172
|
for (;;) {
|
|
158
173
|
if (p > text.length)
|
|
159
174
|
return "unterminated";
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
while (nl >= 0 && /(?<!\\)(?:\\\\)*\\$/.test(line)) {
|
|
164
|
-
const after = text.indexOf("\n", nl + 1);
|
|
165
|
-
line = line.slice(0, -1) + (after < 0 ? text.slice(nl + 1) : text.slice(nl + 1, after));
|
|
166
|
-
nl = after;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
175
|
+
const { line, nl } = documentLine(text, p, !h.quoted);
|
|
176
|
+
if (closer !== undefined && text.slice(p, nl < 0 ? text.length : nl + 1).includes("\\\n"))
|
|
177
|
+
return "ambiguous";
|
|
169
178
|
const compared = h.dash ? line.replace(/^\t+/, "") : line;
|
|
170
179
|
if (compared === h.delimiter) {
|
|
171
180
|
p = nl < 0 ? text.length + 1 : nl + 1;
|
|
172
181
|
break;
|
|
173
182
|
}
|
|
174
|
-
if (
|
|
183
|
+
if (closer !== undefined && compared.startsWith(h.delimiter) && (closer === ")" ? compared.indexOf(")", h.delimiter.length) >= 0 : /^[ \t]*\}/.test(compared.slice(h.delimiter.length))))
|
|
175
184
|
return "ambiguous";
|
|
176
185
|
if (nl < 0)
|
|
177
186
|
return "unterminated";
|
|
@@ -231,7 +240,10 @@ function heredocHeaderAt(text, from, dash, op) {
|
|
|
231
240
|
return header === undefined ? fail("heredoc_delimiter_expands", start) : { ...header, end: j };
|
|
232
241
|
}
|
|
233
242
|
const BASH_READING = { heredoc: true, startComment: true };
|
|
234
|
-
const
|
|
243
|
+
const BASH32_PARSE = { heredoc: false, startComment: true };
|
|
244
|
+
const BASH32_EXPAND = { heredoc: false, startComment: false };
|
|
245
|
+
const NO_COMMENT_COUNT = { heredoc: false, startComment: false, noComments: true };
|
|
246
|
+
const BASH32_DOUBLE_QUOTED = { ...NO_COMMENT_COUNT };
|
|
235
247
|
const ARITHMETIC_READING = { heredoc: false, startComment: true, arithmetic: true };
|
|
236
248
|
const BODY_NESTING_MAX = 64;
|
|
237
249
|
function walkBody(text, open, reading, inDouble, level) {
|
|
@@ -308,10 +320,12 @@ function walkBody(text, open, reading, inDouble, level) {
|
|
|
308
320
|
word = "";
|
|
309
321
|
continue;
|
|
310
322
|
}
|
|
311
|
-
if (c === "#" && wordStart) {
|
|
323
|
+
if (c === "#" && wordStart && reading.noComments !== true) {
|
|
312
324
|
const nl = text.indexOf("\n", j);
|
|
313
325
|
if (nl < 0)
|
|
314
326
|
return "unterminated";
|
|
327
|
+
if (text[nl - 1] === "\\")
|
|
328
|
+
return "undelimited";
|
|
315
329
|
j = nl - 1;
|
|
316
330
|
word = "";
|
|
317
331
|
continue;
|
|
@@ -351,6 +365,8 @@ function walkBody(text, open, reading, inDouble, level) {
|
|
|
351
365
|
}
|
|
352
366
|
const dash = text[third] === "-";
|
|
353
367
|
const header = heredocHeaderAt(text, dash ? third + 1 : third, dash, j);
|
|
368
|
+
if (header === "undelimited")
|
|
369
|
+
return fail("undelimited_substitution_heredoc", j);
|
|
354
370
|
if (typeof header !== "object" || !("delimiter" in header))
|
|
355
371
|
return header;
|
|
356
372
|
owed.push(header);
|
|
@@ -390,17 +406,26 @@ function walkBody(text, open, reading, inDouble, level) {
|
|
|
390
406
|
continue;
|
|
391
407
|
}
|
|
392
408
|
if (c === "\n" && owed.length > 0) {
|
|
393
|
-
const read = heredocBodies(text, j + 1, owed,
|
|
409
|
+
const read = heredocBodies(text, j + 1, owed, ")");
|
|
394
410
|
if (read === "unterminated")
|
|
395
411
|
return fail("unterminated_heredoc", j + 1);
|
|
396
412
|
if (read === "ambiguous")
|
|
397
|
-
return "
|
|
413
|
+
return fail("undelimited_substitution_heredoc", j + 1);
|
|
398
414
|
owed.length = 0;
|
|
399
415
|
j = read.resume - 1;
|
|
400
416
|
wordStart = true;
|
|
401
417
|
word = "";
|
|
402
418
|
continue;
|
|
403
419
|
}
|
|
420
|
+
if (reading.heredoc && j > open && c === "(" && text[k] === "(") {
|
|
421
|
+
const end = arithmeticCommandEnd(text, k);
|
|
422
|
+
if (end !== undefined) {
|
|
423
|
+
j = end - 1;
|
|
424
|
+
wordStart = false;
|
|
425
|
+
word = "";
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
404
429
|
if (c === "(")
|
|
405
430
|
depth++;
|
|
406
431
|
else if (c === ")") {
|
|
@@ -408,7 +433,7 @@ function walkBody(text, open, reading, inDouble, level) {
|
|
|
408
433
|
if (depth === 1)
|
|
409
434
|
innerClose ??= j;
|
|
410
435
|
if (depth === 0)
|
|
411
|
-
return owed.length > 0 ? "
|
|
436
|
+
return owed.length > 0 ? fail("undelimited_substitution_heredoc", j) : { end: j + 1, heredoc, ...(innerClose !== undefined ? { innerClose } : {}) };
|
|
412
437
|
}
|
|
413
438
|
if (!reading.heredoc) {
|
|
414
439
|
wordStart = j === open ? reading.startComment && !inDouble && level === 0 : c === " " || c === "\t" || c === "\n";
|
|
@@ -422,21 +447,40 @@ function walkBody(text, open, reading, inDouble, level) {
|
|
|
422
447
|
}
|
|
423
448
|
return "unterminated";
|
|
424
449
|
}
|
|
425
|
-
function
|
|
450
|
+
function doubleQuotedWordHolds(text, from, to) {
|
|
451
|
+
let inDq = true;
|
|
452
|
+
for (let j = from; j < to; j++) {
|
|
453
|
+
const c = text[j];
|
|
454
|
+
if (c === "\"")
|
|
455
|
+
inDq = !inDq;
|
|
456
|
+
else if (inDq ? c === "`" || (c === "$" && "({[".includes(text[j + 1] ?? "")) : " \t\n;&|<>()'`$\\".includes(c))
|
|
457
|
+
return false;
|
|
458
|
+
else if (inDq && c === "\\")
|
|
459
|
+
j++;
|
|
460
|
+
}
|
|
461
|
+
return inDq;
|
|
462
|
+
}
|
|
463
|
+
function substitutionBodyEnd(text, open, inDouble, level, form = "command") {
|
|
426
464
|
const arithmetic = arithmeticWalk(text, open, inDouble, level);
|
|
427
|
-
|
|
428
|
-
return { end: arithmetic.end, arithmetic: true };
|
|
429
|
-
const read = walkBody(text, open, BASH_READING, inDouble, level);
|
|
465
|
+
const read = arithmetic ?? walkBody(text, open, BASH_READING, inDouble, level);
|
|
430
466
|
if (typeof read !== "object" || !("end" in read))
|
|
431
467
|
return read;
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
468
|
+
const refused = fail(read.heredoc ? "undelimited_substitution_heredoc" : "undelimited_substitution", open);
|
|
469
|
+
const doubled = text[past(text, open + 1)] === "(";
|
|
470
|
+
if (form !== "document")
|
|
471
|
+
for (const pass of passesFor(text, open)) {
|
|
472
|
+
const end = countingPassEnd(text, open, pass);
|
|
473
|
+
if (end !== read.end && end !== "unterminated")
|
|
474
|
+
return refused;
|
|
475
|
+
}
|
|
476
|
+
const counts = [...(form === "document" ? [] : [inDouble ? BASH32_DOUBLE_QUOTED : BASH32_PARSE]), BASH32_EXPAND, ...(doubled || form === "process" ? [NO_COMMENT_COUNT] : [])];
|
|
477
|
+
for (const reading of holdsHashFrom(text, open) ? counts : counts.slice(-1)) {
|
|
435
478
|
const counted = walkBody(text, open, reading, inDouble, level);
|
|
436
|
-
if (counted
|
|
437
|
-
|
|
479
|
+
if (counted === "unterminated" || (typeof counted === "object" && "end" in counted && (counted.end === read.end || (reading === BASH32_DOUBLE_QUOTED && counted.end < read.end && doubleQuotedWordHolds(text, counted.end, read.end)))))
|
|
480
|
+
continue;
|
|
481
|
+
return refused;
|
|
438
482
|
}
|
|
439
|
-
return { end: read.end, arithmetic:
|
|
483
|
+
return { end: read.end, arithmetic: arithmetic !== undefined };
|
|
440
484
|
}
|
|
441
485
|
function arithmeticWalk(text, open, inDouble, level) {
|
|
442
486
|
if (text[past(text, open + 1)] !== "(")
|
|
@@ -478,10 +522,17 @@ function currentShellSubstitutionEnd(text, open, level) {
|
|
|
478
522
|
if (level > BODY_NESTING_MAX)
|
|
479
523
|
return "undelimited";
|
|
480
524
|
const list = { from: open + (text[open + 1] === "|" ? 2 : 1), groups: 0 };
|
|
481
|
-
const
|
|
525
|
+
const segments = [firstSegment(text)];
|
|
526
|
+
const read = scan(text, false, segments, level, list);
|
|
482
527
|
if ("parseFailure" in read)
|
|
483
528
|
return read;
|
|
484
|
-
|
|
529
|
+
if (list.closed === undefined)
|
|
530
|
+
return "undelimited";
|
|
531
|
+
const closed = list.closed;
|
|
532
|
+
if (passesFor(text, open).some((pass) => { const end = bracePassEnd(text, open, pass); return end !== closed && end !== "unterminated"; })) {
|
|
533
|
+
return fail(segments.some((s) => s.tokens.some((t) => t.kind === "heredoc")) ? "undelimited_substitution_heredoc" : "undelimited_substitution", open);
|
|
534
|
+
}
|
|
535
|
+
return { end: closed, from: list.from };
|
|
485
536
|
}
|
|
486
537
|
function bracketExpansionEnd(text, open) {
|
|
487
538
|
let depth = 0;
|
|
@@ -587,6 +638,9 @@ function backtickBody(source, open) {
|
|
|
587
638
|
return undefined;
|
|
588
639
|
}
|
|
589
640
|
export function expansionsInHeredocBody(body) {
|
|
641
|
+
return whileReading(body, () => expansionsInBody(body));
|
|
642
|
+
}
|
|
643
|
+
function expansionsInBody(body) {
|
|
590
644
|
const out = [];
|
|
591
645
|
for (let i = 0; i < body.length; i++) {
|
|
592
646
|
const ch = body[i];
|
|
@@ -606,7 +660,7 @@ export function expansionsInHeredocBody(body) {
|
|
|
606
660
|
continue;
|
|
607
661
|
const open = body[i + 1];
|
|
608
662
|
if (open === "(") {
|
|
609
|
-
const close = substitutionBodyEnd(body, i + 1, true, 0);
|
|
663
|
+
const close = substitutionBodyEnd(body, i + 1, true, 0, "document");
|
|
610
664
|
if (typeof close !== "object" || !("end" in close))
|
|
611
665
|
return undefined;
|
|
612
666
|
out.push({ expansion: { kind: close.arithmetic ? "arithmetic" : "command", yields: "one", body: body.slice(i + 2, close.end - 1) } });
|
|
@@ -1151,6 +1205,9 @@ class WordBuilder {
|
|
|
1151
1205
|
}
|
|
1152
1206
|
}
|
|
1153
1207
|
function scan(source, connectorsAreText, segments, level, list) {
|
|
1208
|
+
return whileReading(source, () => scanText(source, connectorsAreText, segments, level, list));
|
|
1209
|
+
}
|
|
1210
|
+
function scanText(source, connectorsAreText, segments, level, list) {
|
|
1154
1211
|
const split = !connectorsAreText;
|
|
1155
1212
|
const current = () => segments[segments.length - 1];
|
|
1156
1213
|
const pendingHeredocs = [];
|
|
@@ -1278,7 +1335,9 @@ function scan(source, connectorsAreText, segments, level, list) {
|
|
|
1278
1335
|
return undefined;
|
|
1279
1336
|
};
|
|
1280
1337
|
const readHeredocBodies = (from) => {
|
|
1281
|
-
const read = heredocBodies(source, from, pendingHeredocs,
|
|
1338
|
+
const read = heredocBodies(source, from, pendingHeredocs, list === undefined ? undefined : "}");
|
|
1339
|
+
if (read === "ambiguous")
|
|
1340
|
+
return fail("undelimited_substitution_heredoc", from);
|
|
1282
1341
|
if (typeof read !== "object")
|
|
1283
1342
|
return fail("unterminated_heredoc", from);
|
|
1284
1343
|
pendingHeredocs.forEach((h, k) => { h.token.body = read.bodies[k]; });
|
|
@@ -1295,7 +1354,7 @@ function scan(source, connectorsAreText, segments, level, list) {
|
|
|
1295
1354
|
const ch = source[i];
|
|
1296
1355
|
if (list !== undefined && ch === "}" && list.groups === 0 && !inSingle && !inDouble && !w.started && acceptable && pendingRedirect === undefined && pendingHeredoc === undefined) {
|
|
1297
1356
|
if (pendingHeredocs.length > 0)
|
|
1298
|
-
return fail("
|
|
1357
|
+
return fail("undelimited_substitution_heredoc", i);
|
|
1299
1358
|
list.closed = i + 1;
|
|
1300
1359
|
return { command: { segments: [], substitutions: [] } };
|
|
1301
1360
|
}
|
|
@@ -1472,7 +1531,7 @@ function scan(source, connectorsAreText, segments, level, list) {
|
|
|
1472
1531
|
continue;
|
|
1473
1532
|
}
|
|
1474
1533
|
if ((ch === "<" || ch === ">") && source[n1] === "(") {
|
|
1475
|
-
const close = substitutionBodyEnd(source, n1, false, level);
|
|
1534
|
+
const close = substitutionBodyEnd(source, n1, false, level, "process");
|
|
1476
1535
|
if (typeof close !== "object" || !("end" in close))
|
|
1477
1536
|
return close === "unterminated" ? fail("unterminated_process_substitution", i) : close === "undelimited" ? fail("undelimited_substitution", i) : close;
|
|
1478
1537
|
substitution(i, close.end, source.slice(n1 + 1, close.end - 1), "process");
|
|
@@ -1535,7 +1594,7 @@ function scan(source, connectorsAreText, segments, level, list) {
|
|
|
1535
1594
|
if (ch === "(") {
|
|
1536
1595
|
if (arithParens > 0)
|
|
1537
1596
|
arithParens++;
|
|
1538
|
-
else if (split && source[next(i)] === "(")
|
|
1597
|
+
else if (split && source[next(i)] === "(" && arithmeticCommandEnd(source, next(i)) !== undefined)
|
|
1539
1598
|
arithParens = 1;
|
|
1540
1599
|
}
|
|
1541
1600
|
else if (arithParens > 0)
|
|
@@ -1544,7 +1603,7 @@ function scan(source, connectorsAreText, segments, level, list) {
|
|
|
1544
1603
|
resetPosition();
|
|
1545
1604
|
continue;
|
|
1546
1605
|
}
|
|
1547
|
-
if (ch === "<" || ch === ">" || (ch === "&" && source[n1] === ">")) {
|
|
1606
|
+
if (arithParens === 0 && (ch === "<" || ch === ">" || (ch === "&" && source[n1] === ">"))) {
|
|
1548
1607
|
let fd;
|
|
1549
1608
|
if (ch !== "&" && w.started && w.raw === w.folded && /^\d+$/.test(w.raw)) {
|
|
1550
1609
|
fd = Number(w.raw);
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*
|
|
26
26
|
* Pure data and a pure projection: this module imports nothing.
|
|
27
27
|
*/
|
|
28
|
-
export declare const SHELL_WORD_ROLES: readonly ["control_prefix", "group", "block", "compound_open", "loop_list_head", "loop_iterates", "loop_condition", "loop_end", "definition", "background", "case_arms", "timer", "scope_open", "scope_close", "scope_switch", "stripped_prefix", "stripped_standalone", "opaque", "rule_reserved", "base_mover", "stack_mover", "stack_editor"];
|
|
28
|
+
export declare const SHELL_WORD_ROLES: readonly ["control_prefix", "group", "block", "compound_open", "loop_list_head", "loop_iterates", "loop_condition", "loop_end", "definition", "background", "case_arms", "pass_keeps_reserved", "timer", "scope_open", "scope_close", "scope_switch", "stripped_prefix", "stripped_standalone", "opaque", "rule_reserved", "base_mover", "stack_mover", "stack_editor"];
|
|
29
29
|
export type ShellWordRole = (typeof SHELL_WORD_ROLES)[number];
|
|
30
30
|
/** Every word that plays `role`. The same set object on every call: a projection is a view, not a copy to edit. */
|
|
31
31
|
export declare function shellWordsOf(role: ShellWordRole): ReadonlySet<string>;
|
|
@@ -10,6 +10,7 @@ export const SHELL_WORD_ROLES = Object.freeze([
|
|
|
10
10
|
"definition",
|
|
11
11
|
"background",
|
|
12
12
|
"case_arms",
|
|
13
|
+
"pass_keeps_reserved",
|
|
13
14
|
"timer",
|
|
14
15
|
"scope_open",
|
|
15
16
|
"scope_close",
|
|
@@ -25,21 +26,21 @@ export const SHELL_WORD_ROLES = Object.freeze([
|
|
|
25
26
|
const ROWS = [
|
|
26
27
|
["!", "control_prefix", "stripped_prefix", "rule_reserved"],
|
|
27
28
|
["if", "control_prefix", "compound_open", "scope_open", "stripped_prefix", "rule_reserved"],
|
|
28
|
-
["then", "control_prefix", "stripped_prefix", "rule_reserved"],
|
|
29
|
-
["elif", "control_prefix", "scope_switch", "stripped_prefix", "rule_reserved"],
|
|
30
|
-
["else", "control_prefix", "scope_switch", "stripped_prefix", "rule_reserved"],
|
|
29
|
+
["then", "control_prefix", "stripped_prefix", "rule_reserved", "pass_keeps_reserved"],
|
|
30
|
+
["elif", "control_prefix", "scope_switch", "stripped_prefix", "rule_reserved", "pass_keeps_reserved"],
|
|
31
|
+
["else", "control_prefix", "scope_switch", "stripped_prefix", "rule_reserved", "pass_keeps_reserved"],
|
|
31
32
|
["while", "control_prefix", "compound_open", "loop_condition", "scope_open", "stripped_prefix", "rule_reserved"],
|
|
32
33
|
["until", "control_prefix", "compound_open", "loop_condition", "scope_open", "stripped_prefix", "rule_reserved"],
|
|
33
34
|
["do", "control_prefix", "stripped_prefix", "rule_reserved"],
|
|
34
|
-
["time", "control_prefix", "timer", "rule_reserved"],
|
|
35
|
+
["time", "control_prefix", "timer", "rule_reserved", "pass_keeps_reserved"],
|
|
35
36
|
["{", "group", "compound_open", "scope_open", "stripped_standalone", "rule_reserved"],
|
|
36
37
|
["}", "group", "scope_close", "stripped_standalone", "rule_reserved"],
|
|
37
38
|
["for", "block", "compound_open", "loop_list_head", "loop_iterates", "scope_open", "opaque", "rule_reserved"],
|
|
38
39
|
["select", "block", "compound_open", "loop_list_head", "scope_open", "opaque", "rule_reserved"],
|
|
39
40
|
["case", "block", "compound_open", "case_arms", "scope_open", "opaque", "rule_reserved"],
|
|
40
|
-
["esac", "block", "scope_close", "stripped_standalone", "rule_reserved"],
|
|
41
|
+
["esac", "block", "scope_close", "stripped_standalone", "rule_reserved", "pass_keeps_reserved"],
|
|
41
42
|
["fi", "block", "scope_close", "stripped_standalone", "rule_reserved"],
|
|
42
|
-
["done", "block", "loop_end", "scope_close", "stripped_standalone", "rule_reserved"],
|
|
43
|
+
["done", "block", "loop_end", "scope_close", "stripped_standalone", "rule_reserved", "pass_keeps_reserved"],
|
|
43
44
|
["function", "block", "definition", "opaque", "rule_reserved"],
|
|
44
45
|
["coproc", "block", "background", "opaque", "rule_reserved"],
|
|
45
46
|
["]]", "block", "stripped_standalone", "rule_reserved"],
|
|
@@ -17,7 +17,7 @@ export declare class FileBackgroundAgentStore implements BackgroundAgentStore {
|
|
|
17
17
|
/** RB-145: this instance's own close latch — the refcount belongs to the DIRECTORY, not to callers. */
|
|
18
18
|
private closed;
|
|
19
19
|
private get rows();
|
|
20
|
-
constructor(root: string,
|
|
20
|
+
constructor(root: string, options?: FileBackgroundAgentStoreOptions);
|
|
21
21
|
/**
|
|
22
22
|
* RB-60 (2026-07-25, red probe): the composite key must be INJECTIVE — `get`/`update` no longer re-check
|
|
23
23
|
* scope, so tenant isolation rests entirely on this function. A SPACE separator is not injective
|
|
@@ -3,6 +3,7 @@ import { BackgroundAgentStoreError, STALE_RUNNING_REAP_ATTRIBUTION, assertBackgr
|
|
|
3
3
|
import { SharedLedgerTable } from "./shared-ledger.js";
|
|
4
4
|
import { guardCorruptSink } from "./corrupt-read-sink.js";
|
|
5
5
|
import { assertAdoptionBootGate } from "./adoption/marker.js";
|
|
6
|
+
import { receiveOptions } from "../../core/own-property-receipt.js";
|
|
6
7
|
const isAgentRow = (x) => x !== null && typeof x === "object" && typeof x.handle === "string" && typeof x.scope === "string";
|
|
7
8
|
const agentLedgers = new SharedLedgerTable({
|
|
8
9
|
label: "background-agent ledger",
|
|
@@ -30,7 +31,8 @@ export class FileBackgroundAgentStore {
|
|
|
30
31
|
get rows() {
|
|
31
32
|
return this.ledger.rows;
|
|
32
33
|
}
|
|
33
|
-
constructor(root,
|
|
34
|
+
constructor(root, options) {
|
|
35
|
+
const opts = receiveOptions(options, "FileBackgroundAgentStore");
|
|
34
36
|
assertAdoptionBootGate(root, "FileBackgroundAgentStore");
|
|
35
37
|
this.fsyncEnabled = opts.fsync !== false;
|
|
36
38
|
this.compactEvery = opts.compactEvery ?? 1000;
|
|
@@ -1,9 +1,91 @@
|
|
|
1
1
|
import { type ExecutionOutcomeRecordWord } from "../../core/checkpoint-execution-record.js";
|
|
2
2
|
import { type HolderJudge } from "../../core/checkpoint-generation.js";
|
|
3
|
-
import { type Checkpoint, type PendingSteerInput, type CheckpointFaultMode, type CheckpointStore, type CheckpointSummary, type CheckpointToken, type ReopenReason, type ResolveExpectation, type ResumeOutcome } from "../../core/checkpoint-store.js";
|
|
3
|
+
import { type Checkpoint, type PendingSteerEntry, type PendingSteerInput, type CheckpointFaultMode, type CheckpointStore, type CheckpointSummary, type CheckpointToken, type ReopenReason, type ResolveExpectation, type ResumeOutcome } from "../../core/checkpoint-store.js";
|
|
4
4
|
import type { GateOutcome } from "../../core/gate-outcome.js";
|
|
5
5
|
import { type CheckpointDeleteGuard, type CheckpointOverdueCursor, type CheckpointOverdueQuery, type CheckpointPage, type CheckpointRowRead, type CheckpointSessionCursor, type CheckpointSessionQuery } from "../../core/checkpoint-queries.js";
|
|
6
|
+
import type { AssertAllKeysHandled } from "../../core/ask-origin.js";
|
|
6
7
|
import { type CorruptReadInfo } from "./corrupt-read-sink.js";
|
|
8
|
+
/**
|
|
9
|
+
* design/80 §2.4 — THE LOAD-BEARING file store: a {@link CheckpointStore} whose once-only CAS is
|
|
10
|
+
* behaviorally IDENTICAL to {@link import("../../core/checkpoint-store.js").InMemoryCheckpointStore}.
|
|
11
|
+
*
|
|
12
|
+
* **The decisive simplification (§2.4): the local binary is ONE process, one Node event loop.** So the
|
|
13
|
+
* multi-process file-locking literature (per-op `flock`, `O_EXCL` lockfiles) buys nothing — there is NO
|
|
14
|
+
* per-operation lock. Correctness instead rests on three things, exactly mirroring the in-memory store:
|
|
15
|
+
*
|
|
16
|
+
* 1. **In-process async mutex per token** — a `Map<token, Promise>` serialization chain (the SAME shape as
|
|
17
|
+
* `TtlSessionStore.pending`): `resolve`/`reopen`/`expire`/`setPendingSteer`/`put` on a given token chain
|
|
18
|
+
* behind one another, so no two interleaved async tasks can both read `pending` and both commit.
|
|
19
|
+
* 2. **Authoritative state = an in-memory `Map<token, Checkpoint>`**, rebuilt by replaying
|
|
20
|
+
* `checkpoints.jsonl` (+ a compacted `snapshot`) at boot, last-writer-wins by event order (the latest
|
|
21
|
+
* event's status / resolvedOutcome / reopenReason / rev win — the "authoritative fields outside the blob"
|
|
22
|
+
* rule Pg implements with columns).
|
|
23
|
+
* 3. **Commit ordering = appendLine the event + fsync BEFORE flipping the in-memory map** — so a crash can
|
|
24
|
+
* never leave "memory says resolved, disk says pending". A crash *before* the fsync'd append replays as
|
|
25
|
+
* `pending` (a retry can still win); a crash *after* replays as `resolved` (a retry is a no-op `false`).
|
|
26
|
+
* This matches the `testInjectFault` `resolve-before-commit` / `resolve-after-commit` contract exactly.
|
|
27
|
+
*
|
|
28
|
+
* The CAS predicate is byte-for-byte the in-memory one: `row && row.scope === scope && row.status ===
|
|
29
|
+
* 'pending'` plus the `expect.rev` OCC; `setPendingSteer` runs {@link validatePendingSteer} FIRST (before
|
|
30
|
+
* the row lookup); the winner comes from {@link winnerFromOutcome}. NO per-operation flock.
|
|
31
|
+
*
|
|
32
|
+
* **What makes premise 1 true (and what used to only assume it):** the CONSTRUCTOR takes a coarse
|
|
33
|
+
* cross-process writer fence on the ledger directory (`root/checkpoints/LOCK`, via
|
|
34
|
+
* {@link import("./fs-atomic.js").acquireStoreDirLock}) — a second OS process over the same data root is
|
|
35
|
+
* refused loudly ({@link import("./fs-atomic.js").FileStoreLockError}, code `store.dir_in_use`) instead
|
|
36
|
+
* of quietly replaying a private view. Instances INSIDE this process share that fence exactly as they
|
|
37
|
+
* share the authority (refcounted; the last {@link FileCheckpointStore.close} drops it), and a lock left
|
|
38
|
+
* by a dead pid is pruned as stale, so a crash never needs manual cleanup. Before this the doc named a
|
|
39
|
+
* fence this class never took — `FileStorageBackend`'s `root/LOCK` — which meant nothing at all for the
|
|
40
|
+
* direct construction the root export invites: two processes each won the once-only CAS on the same
|
|
41
|
+
* token (approval AND refusal both reported as the winner), and the process that had never loaded the
|
|
42
|
+
* other's rows erased them at its next compaction, with no error on either side.
|
|
43
|
+
*/
|
|
44
|
+
/** One persisted ledger event. The replay folds these in order into the authoritative map. */
|
|
45
|
+
type LedgerEvent = {
|
|
46
|
+
t: "put";
|
|
47
|
+
token: string;
|
|
48
|
+
cp: Checkpoint;
|
|
49
|
+
} | {
|
|
50
|
+
t: "resolve";
|
|
51
|
+
token: string;
|
|
52
|
+
rev: number;
|
|
53
|
+
resolvedOutcome?: Checkpoint["resolvedOutcome"];
|
|
54
|
+
} | {
|
|
55
|
+
t: "reopen";
|
|
56
|
+
token: string;
|
|
57
|
+
rev: number;
|
|
58
|
+
reason: ReopenReason;
|
|
59
|
+
}
|
|
60
|
+
/** The execution-outcome record (CheckpointRow.executionOutcome): written once per row by
|
|
61
|
+
* `recordExecutionOutcome`; the replay sets both columns together. A binary released before this kind
|
|
62
|
+
* refuses the replay at the discriminator fence below while the event is still in the live ledger;
|
|
63
|
+
* once compaction has folded it into a snapshot row, that older binary reads the row with a field it
|
|
64
|
+
* does not know and its `reopen` (the pre-record predicate) ignores it — the same rollback shape the
|
|
65
|
+
* queue event above documents, disclosed in the release notes rather than fenced here. */
|
|
66
|
+
| {
|
|
67
|
+
t: "execution";
|
|
68
|
+
token: string;
|
|
69
|
+
gate: GateOutcome;
|
|
70
|
+
atMs: number;
|
|
71
|
+
} | {
|
|
72
|
+
t: "expire";
|
|
73
|
+
token: string;
|
|
74
|
+
}
|
|
75
|
+
/** The row is gone (`deleteSessionCheckpoints`): the replay removes it from the map, and the next compaction writes no line for it. A
|
|
76
|
+
* binary released before this kind refuses the replay at the discriminator fence while the event is in the live ledger; once a
|
|
77
|
+
* compaction has folded it away the directory reads on that binary again — the store-format note the release carries. */
|
|
78
|
+
| {
|
|
79
|
+
t: "delete";
|
|
80
|
+
token: string;
|
|
81
|
+
}
|
|
82
|
+
/** design/171 §5.3 — one APPENDED queue entry, carrying the `seq` the append minted so the replay is
|
|
83
|
+
* deterministic and never re-runs the bound checks an already-committed append passed. */
|
|
84
|
+
| {
|
|
85
|
+
t: "steer_append";
|
|
86
|
+
token: string;
|
|
87
|
+
entry: PendingSteerEntry;
|
|
88
|
+
};
|
|
7
89
|
export interface FileCheckpointStoreOptions {
|
|
8
90
|
/** This store's half of {@link import("./shared-ledger.js").LedgerPaths.onCorruptRead}. */
|
|
9
91
|
onCorruptRead?: (info: CorruptReadInfo) => void;
|
|
@@ -21,6 +103,48 @@ export interface FileCheckpointStoreOptions {
|
|
|
21
103
|
/** The judge of a resolve's claim holder ({@link HolderJudge}); with it the store declares `fence = { holder: true }`. */
|
|
22
104
|
holderIsCurrent?: HolderJudge;
|
|
23
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Every event kind this reader understands — the ledger's CLOSED SET, exported so a program that reads a `checkpoints.jsonl` itself judges
|
|
108
|
+
* a line against the words the store folds, not a copy of them. Kept as a VALUE (not just the type union) because the fence below judges
|
|
109
|
+
* DECODED JSON, which no compile-time union can vouch for.
|
|
110
|
+
*
|
|
111
|
+
* Total BOTH ways at compile time ({@link CheckpointLedgerKindsAreTheEventUnion}): a plain `Set<LedgerEvent["t"]>` would have accepted a list
|
|
112
|
+
* that silently forgot a member, and the failure shape of that drift is worse than the bug the fence fixes — a future release adding a
|
|
113
|
+
* supported kind (union arm, switch case, writer) but not this list would DURABLY append the event and only then have the replay refuse
|
|
114
|
+
* it: the write is on disk, memory is stale, and every later replay of that directory refuses the store. Forgetting a word, or listing
|
|
115
|
+
* one the union does not have, fails to compile.
|
|
116
|
+
*/
|
|
117
|
+
export declare const CHECKPOINT_LEDGER_EVENT_KINDS: readonly ["put", "resolve", "reopen", "execution", "expire", "delete", "steer_append"];
|
|
118
|
+
export type CheckpointLedgerEventKind = (typeof CHECKPOINT_LEDGER_EVENT_KINDS)[number];
|
|
119
|
+
/** The fence over {@link CHECKPOINT_LEDGER_EVENT_KINDS}: `never` while the list and the event union name the same words. */
|
|
120
|
+
export type CheckpointLedgerKindsAreTheEventUnion = AssertAllKeysHandled<Exclude<LedgerEvent["t"], CheckpointLedgerEventKind> | Exclude<CheckpointLedgerEventKind, LedgerEvent["t"]>>;
|
|
121
|
+
export interface ReadCheckpointLedgerOptions {
|
|
122
|
+
/** This reader's half of {@link FileCheckpointStoreOptions.onCorruptRead}: told of every snapshot row / ledger event dropped as damage. */
|
|
123
|
+
onCorruptRead?: (info: CorruptReadInfo) => void;
|
|
124
|
+
}
|
|
125
|
+
/** What {@link readCheckpointLedger} answers: the rows the ledger folds to, or no reading at all. */
|
|
126
|
+
export type CheckpointLedgerReading = {
|
|
127
|
+
/** The directory held still for one whole read. */
|
|
128
|
+
readonly settled: true;
|
|
129
|
+
/** token → row, folded exactly as a store would fold it: fresh objects, owned by the caller, shared with no store. */
|
|
130
|
+
readonly rows: ReadonlyMap<string, Checkpoint>;
|
|
131
|
+
/** Ledger events folded over the snapshot (zero right after a compaction). */
|
|
132
|
+
readonly events: number;
|
|
133
|
+
} | {
|
|
134
|
+
/** The snapshot kept being replaced under the read (a writer compacting, three reads running): no verdict — the last read is not offered in its place. */
|
|
135
|
+
readonly settled: false;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Read a data root's checkpoint ledger WITHOUT opening the store — for a program that must know what the ledger holds beside (or instead of) a
|
|
139
|
+
* running worker: a drain check asking whether a parked row still needs this engine's rows, an operator tool. It takes no writer fence
|
|
140
|
+
* (`checkpoints/LOCK` is neither created nor consulted, so it neither contends with a live store nor is refused by one), opens no append
|
|
141
|
+
* handle, and creates nothing — not the directory either: a root with no ledger reads as no rows. The fold is the store's own
|
|
142
|
+
* (`applyCheckpointEvent` through the same discriminator fence), so a ledger event kind this binary does not know refuses the read exactly as
|
|
143
|
+
* it refuses the store's replay (`checkpoint.unsupported_version`, `detail.reason` `ledger_event_unknown`); {@link CHECKPOINT_LEDGER_EVENT_KINDS}
|
|
144
|
+
* is the word list that fence judges by. A root whose adoption is in flight is refused as the store refuses it. Beside a compacting writer
|
|
145
|
+
* the read is bracketed (see {@link readLedgerSettled}) and is `settled: false` rather than a view that never existed.
|
|
146
|
+
*/
|
|
147
|
+
export declare function readCheckpointLedger(root: string, opts?: ReadCheckpointLedgerOptions): CheckpointLedgerReading;
|
|
24
148
|
export declare class FileCheckpointStore implements CheckpointStore {
|
|
25
149
|
/** design/173 §2.3 — honest declaration on the restart-survival axis the vocabulary claims: rows
|
|
26
150
|
* live on disk (fsync'd append log) and survive a process restart. Multi-replica coordination is
|
|
@@ -57,7 +181,7 @@ export declare class FileCheckpointStore implements CheckpointStore {
|
|
|
57
181
|
private readonly ledgerPath;
|
|
58
182
|
/** Present exactly when the store was built with a session head read (`FileCheckpointStoreOptions.sessionHeadOf`). */
|
|
59
183
|
readonly deleteSessionCheckpoints?: (sessionId: string, guard: CheckpointDeleteGuard) => Promise<number>;
|
|
60
|
-
constructor(root: string,
|
|
184
|
+
constructor(root: string, options?: FileCheckpointStoreOptions);
|
|
61
185
|
/** Serialize an op behind any in-flight op on the same token (the in-process per-token async mutex). */
|
|
62
186
|
private withLock;
|
|
63
187
|
/**
|
|
@@ -106,3 +230,4 @@ export declare class FileCheckpointStore implements CheckpointStore {
|
|
|
106
230
|
*/
|
|
107
231
|
close(): void;
|
|
108
232
|
}
|
|
233
|
+
export {};
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { assertAdoptionBootGate } from "./adoption/marker.js";
|
|
3
|
+
import { receiveOptions } from "../../core/own-property-receipt.js";
|
|
3
4
|
import { checkpointExecutionRecorded, executionRecordDisposition, ExecutionOutcomeConflictError, } from "../../core/checkpoint-execution-record.js";
|
|
4
5
|
import { checkpointHolderMatches, checkpointOccMatches, checkpointRevOf } from "../../core/checkpoint-generation.js";
|
|
5
6
|
import { appendPendingSteer, CheckpointError, checkpointRowMatches, encodeAtFidelity, summarizeCheckpoint, validatePendingSteer, winnerFromOutcome, } from "../../core/checkpoint-store.js";
|
|
6
7
|
import { checkpointDeadlinePassed, deleteSessionRowsAtStart, readCheckpointOverdueQuery, readCheckpointSessionQuery, selectOverduePage, selectSessionPage, } from "../../core/checkpoint-queries.js";
|
|
7
|
-
import { SharedLedgerTable } from "./shared-ledger.js";
|
|
8
|
+
import { readLedgerSettled, SharedLedgerTable } from "./shared-ledger.js";
|
|
8
9
|
import { guardCorruptSink } from "./corrupt-read-sink.js";
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
resolve: true,
|
|
12
|
-
reopen: true,
|
|
13
|
-
execution: true,
|
|
14
|
-
expire: true,
|
|
15
|
-
delete: true,
|
|
16
|
-
steer_append: true,
|
|
17
|
-
};
|
|
18
|
-
const KNOWN_CHECKPOINT_LEDGER_EVENTS = new Set(Object.keys(CHECKPOINT_LEDGER_EVENT_REGISTRY));
|
|
10
|
+
export const CHECKPOINT_LEDGER_EVENT_KINDS = Object.freeze(["put", "resolve", "reopen", "execution", "expire", "delete", "steer_append"]);
|
|
11
|
+
const KNOWN_CHECKPOINT_LEDGER_EVENTS = new Set(CHECKPOINT_LEDGER_EVENT_KINDS);
|
|
19
12
|
function applyCheckpointEvent(cps, ev) {
|
|
20
13
|
if (!KNOWN_CHECKPOINT_LEDGER_EVENTS.has(ev.t)) {
|
|
21
14
|
throw new CheckpointError("checkpoint.unsupported_version", `file checkpoint ledger: unrecognised event kind "${String(ev.t)}" — ` +
|
|
@@ -69,7 +62,7 @@ const isCheckpointRow = (x) => x !== null &&
|
|
|
69
62
|
typeof x.token === "string" &&
|
|
70
63
|
typeof x.scope === "string" &&
|
|
71
64
|
typeof x.status === "string";
|
|
72
|
-
const
|
|
65
|
+
const checkpointLedgerModel = {
|
|
73
66
|
label: "checkpoint ledger",
|
|
74
67
|
keyOf: (cp) => cp.token,
|
|
75
68
|
apply: applyCheckpointEvent,
|
|
@@ -84,7 +77,18 @@ const checkpointLedgers = new SharedLedgerTable({
|
|
|
84
77
|
return false;
|
|
85
78
|
return ev.t === "put" ? isCheckpointRow(ev.cp) : true;
|
|
86
79
|
},
|
|
87
|
-
}
|
|
80
|
+
};
|
|
81
|
+
const checkpointLedgers = new SharedLedgerTable(checkpointLedgerModel);
|
|
82
|
+
export function readCheckpointLedger(root, opts = {}) {
|
|
83
|
+
assertAdoptionBootGate(root, "readCheckpointLedger");
|
|
84
|
+
const dir = join(root, "checkpoints");
|
|
85
|
+
const read = readLedgerSettled({
|
|
86
|
+
ledgerPath: join(dir, "checkpoints.jsonl"),
|
|
87
|
+
snapshotPath: join(dir, "checkpoints.snapshot.jsonl"),
|
|
88
|
+
...(opts.onCorruptRead !== undefined ? { onCorruptRead: guardCorruptSink(opts.onCorruptRead) } : {}),
|
|
89
|
+
}, checkpointLedgerModel);
|
|
90
|
+
return read.settled ? { settled: true, rows: read.rows, events: read.events } : { settled: false };
|
|
91
|
+
}
|
|
88
92
|
export class FileCheckpointStore {
|
|
89
93
|
durability = "durable";
|
|
90
94
|
fidelity = "json";
|
|
@@ -100,7 +104,8 @@ export class FileCheckpointStore {
|
|
|
100
104
|
fault = null;
|
|
101
105
|
discloseCorrupt;
|
|
102
106
|
ledgerPath;
|
|
103
|
-
constructor(root,
|
|
107
|
+
constructor(root, options) {
|
|
108
|
+
const opts = receiveOptions(options, "FileCheckpointStore");
|
|
104
109
|
assertAdoptionBootGate(root, "FileCheckpointStore");
|
|
105
110
|
this.fsyncEnabled = opts.fsync !== false;
|
|
106
111
|
this.holderIsCurrent = opts.holderIsCurrent;
|
|
@@ -173,7 +173,7 @@ export declare class FileFileHistoryStore implements FileHistoryStore {
|
|
|
173
173
|
* A tie is then decided by the entry id, which IS commit order for engine-minted uuidv7 ids.
|
|
174
174
|
*/
|
|
175
175
|
private nextCommittedAt;
|
|
176
|
-
constructor(root: string,
|
|
176
|
+
constructor(root: string, options?: FileFileHistoryStoreOptions);
|
|
177
177
|
/**
|
|
178
178
|
* The RETENTION pass, run after a boundary file is published (design/381 §片2 — see
|
|
179
179
|
* {@link FileHistoryStore.reap} for why the backend owns this rather than the host).
|
|
@@ -8,6 +8,7 @@ import { atomicWriteFile, ensureDir, sanitizePathComponent, sanitizeScope, write
|
|
|
8
8
|
import { guardCorruptSink } from "./corrupt-read-sink.js";
|
|
9
9
|
import { isAbsoluteForFamily } from "../../tools/fs/safety.js";
|
|
10
10
|
import { assertAdoptionBootGate } from "./adoption/marker.js";
|
|
11
|
+
import { receiveOptions } from "../../core/own-property-receipt.js";
|
|
11
12
|
function trackedDigest(rows) {
|
|
12
13
|
const canonical = [...rows]
|
|
13
14
|
.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0))
|
|
@@ -155,7 +156,8 @@ export class FileFileHistoryStore {
|
|
|
155
156
|
this.lastCommittedAt = Math.max(Date.now(), this.lastCommittedAt + 1);
|
|
156
157
|
return this.lastCommittedAt;
|
|
157
158
|
}
|
|
158
|
-
constructor(root,
|
|
159
|
+
constructor(root, options) {
|
|
160
|
+
const opts = receiveOptions(options, "FileFileHistoryStore");
|
|
159
161
|
assertAdoptionBootGate(root, "FileFileHistoryStore");
|
|
160
162
|
this.boundaryKeep = resolveFileHistoryRetention("FileFileHistoryStore", opts?.retention);
|
|
161
163
|
this.base = join(root, "file-history");
|
|
@@ -15,13 +15,14 @@ import type { SessionPolicyStore } from "../../core/session-policy-store.js";
|
|
|
15
15
|
import type { WorkflowJournalStore } from "../../core/workflow-journal-store.js";
|
|
16
16
|
import type { UsageWindowStore } from "../../core/usage-window-store.js";
|
|
17
17
|
import type { EngineStorageBackend } from "../../core/engine-storage-backend.js";
|
|
18
|
-
export { FileCheckpointStore, type FileCheckpointStoreOptions } from "./checkpoint-store.js";
|
|
18
|
+
export { FileCheckpointStore, CHECKPOINT_LEDGER_EVENT_KINDS, readCheckpointLedger, type CheckpointLedgerEventKind, type CheckpointLedgerReading, type FileCheckpointStoreOptions, type ReadCheckpointLedgerOptions, } from "./checkpoint-store.js";
|
|
19
19
|
export { FileMemoryStore } from "./memory-store.js";
|
|
20
20
|
export { FileSessionRepo, type FileSessionRepoOptions } from "./session-store.js";
|
|
21
21
|
export { FileToolResultStore } from "./tool-result-store.js";
|
|
22
22
|
export { FileSessionPolicyStore, type FileSessionPolicyStoreOptions, type SessionPolicyCorruptReadInfo } from "./session-policy-store.js";
|
|
23
23
|
export { FileFileHistoryStore, type FileFileHistoryStoreOptions } from "./file-history-store.js";
|
|
24
|
-
export { FileWorkflowJournalStore
|
|
24
|
+
export { FileWorkflowJournalStore } from "./workflow-journal-store.js";
|
|
25
|
+
export { MAX_JOURNAL_RESULT_BYTES, oversizeJournalResult } from "../../core/workflow-journal-store.js";
|
|
25
26
|
export { FileUsageWindowStore, type FileUsageWindowStoreOptions } from "./usage-window-store.js";
|
|
26
27
|
export { resolveDataRoot, sanitizeScope, sanitizePathComponent, createFileConsolidationLock } from "./fs-atomic.js";
|
|
27
28
|
export { FileStoreLockError, type FileStoreLockErrorCode } from "./fs-atomic.js";
|
|
@@ -184,7 +185,7 @@ export declare class FileStorageBackend implements EngineStorageBackend {
|
|
|
184
185
|
* descriptors) this backend joined; `TtlSessionStore.dispose()` only clears the sweep timer. */
|
|
185
186
|
private readonly fileSessions;
|
|
186
187
|
private readonly fileWorkflowJournal;
|
|
187
|
-
constructor(
|
|
188
|
+
constructor(options?: FileStorageBackendOptions);
|
|
188
189
|
/**
|
|
189
190
|
* The data-dir boot lock could not be handed back — a root that turned read-only under a running
|
|
190
191
|
* process, an unreadable lock file. Teardown here is best-effort by contract, but best-effort must not
|