@sema-agent/core 7.54.1 → 7.56.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 +950 -0
- package/dist/agents/agent-transcript-tool.js +2 -1
- package/dist/agents/builtin-agents.d.ts +12 -14
- package/dist/agents/cascade.js +1 -1
- package/dist/agents/cc-peer-directory.d.ts +36 -0
- package/dist/agents/cc-peer-directory.js +139 -0
- package/dist/agents/cc-peer-wire.d.ts +105 -0
- package/dist/agents/cc-peer-wire.js +98 -0
- package/dist/agents/cc-uds-peer-channel.d.ts +40 -0
- package/dist/agents/cc-uds-peer-channel.js +457 -0
- package/dist/agents/child-model-seat.d.ts +0 -11
- package/dist/agents/child-model-seat.js +0 -3
- package/dist/agents/cross-session-envelope.d.ts +4 -1
- package/dist/agents/cross-session-envelope.js +8 -1
- package/dist/agents/cross-session-judge.d.ts +2 -2
- package/dist/agents/list-agents-tool.d.ts +3 -1
- package/dist/agents/list-agents-tool.js +9 -8
- package/dist/agents/observer.d.ts +4 -5
- package/dist/agents/observer.js +2 -1
- package/dist/agents/peer-admission.d.ts +6 -0
- package/dist/agents/peer-admission.js +4 -1
- package/dist/agents/peer-directory.d.ts +65 -13
- package/dist/agents/peer-directory.js +90 -25
- package/dist/agents/peer-notices.d.ts +1 -1
- package/dist/agents/peer-session-drain.d.ts +3 -1
- package/dist/agents/peer-session-drain.js +3 -2
- package/dist/agents/read-inbox-tool.js +2 -1
- package/dist/agents/repair-loop.js +2 -2
- package/dist/agents/retain-ledger.d.ts +1 -1
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/send-message-tool.d.ts +10 -0
- package/dist/agents/send-message-tool.js +37 -8
- package/dist/agents/subagent.d.ts +39 -82
- package/dist/agents/subagent.js +109 -106
- package/dist/agents/tool-filter.d.ts +31 -46
- package/dist/agents/tool-filter.js +13 -33
- package/dist/agents/verify.d.ts +6 -5
- package/dist/agents/verify.js +3 -3
- package/dist/brain/anthropic.js +43 -81
- package/dist/brain/errors.d.ts +15 -0
- package/dist/brain/errors.js +10 -0
- package/dist/brain/media-degrade.d.ts +18 -7
- package/dist/brain/media-degrade.js +13 -2
- package/dist/brain/model-capability.d.ts +37 -0
- package/dist/brain/model-capability.js +34 -0
- package/dist/brain/model-presets.d.ts +6 -12
- package/dist/brain/model-presets.js +1 -6
- package/dist/brain/open-responses.js +27 -35
- package/dist/brain/openai.js +30 -98
- package/dist/brain/provider-dialect.d.ts +39 -3
- package/dist/brain/provider-dialect.js +28 -0
- package/dist/brain/reasoning-request.d.ts +96 -0
- package/dist/brain/reasoning-request.js +174 -0
- package/dist/brain/reasoning.d.ts +12 -12
- package/dist/brain/reasoning.js +4 -3
- package/dist/brain/request-params.d.ts +62 -9
- package/dist/brain/request-params.js +42 -7
- package/dist/brain/retry.d.ts +1 -1
- package/dist/brain/route-adjudicator.d.ts +15 -0
- package/dist/brain/route-adjudicator.js +15 -0
- package/dist/brain/status-sink.d.ts +20 -0
- package/dist/brain/status-sink.js +7 -0
- package/dist/brain/stream-engine.js +6 -5
- package/dist/brain/stream-shared.d.ts +1 -1
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +19 -13
- package/dist/core/advisor-verdict.d.ts +120 -0
- package/dist/core/advisor-verdict.js +92 -0
- package/dist/core/agent-definition.d.ts +17 -8
- package/dist/core/allow-entry.d.ts +69 -36
- package/dist/core/allow-entry.js +81 -52
- package/dist/core/allow-rule-shadow.d.ts +10 -3
- package/dist/core/approval-object.d.ts +2 -1
- package/dist/core/approval-object.js +6 -6
- package/dist/core/ask-origin.d.ts +127 -29
- package/dist/core/ask-origin.js +87 -25
- package/dist/core/ask-question.d.ts +51 -8
- package/dist/core/ask-question.js +12 -7
- package/dist/core/ask-unresolvable-notice.d.ts +8 -3
- package/dist/core/ask-unresolvable-notice.js +16 -2
- package/dist/core/auto-compaction.d.ts +11 -8
- package/dist/core/auto-compaction.js +4 -2
- package/dist/core/auto-mode-arming.d.ts +2 -2
- package/dist/core/auto-mode-defaults.d.ts +8 -8
- package/dist/core/auto-mode-prompt-assets.d.ts +3 -3
- package/dist/core/auto-mode-prompt.d.ts +1 -1
- package/dist/core/auto-mode.d.ts +17 -9
- package/dist/core/auto-mode.js +9 -6
- package/dist/core/background-agent-store.d.ts +3 -3
- package/dist/core/canonical-json.d.ts +1 -1
- package/dist/core/canonical-json.js +2 -2
- package/dist/core/checkpoint-generation.d.ts +53 -0
- package/dist/core/checkpoint-generation.js +35 -0
- package/dist/core/checkpoint-queries.d.ts +180 -0
- package/dist/core/checkpoint-queries.js +272 -0
- package/dist/core/checkpoint-requirements.d.ts +19 -4
- package/dist/core/checkpoint-requirements.js +8 -14
- package/dist/core/checkpoint-store.d.ts +165 -72
- package/dist/core/checkpoint-store.js +79 -82
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +3 -16
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/context-edit.d.ts +6 -7
- package/dist/core/cross-boundary-taint.d.ts +11 -4
- package/dist/core/cross-boundary-taint.js +3 -3
- package/dist/core/decision-receipt.d.ts +37 -3
- package/dist/core/decision-receipt.js +19 -19
- package/dist/core/delegation-not-started.d.ts +6 -0
- package/dist/core/delegation-not-started.js +17 -0
- package/dist/core/effective-path-target.d.ts +1 -1
- package/dist/core/engine-attestation.d.ts +93 -0
- package/dist/core/engine-attestation.js +70 -0
- package/dist/core/engine-capabilities.d.ts +4 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +45 -12
- package/dist/core/exec-output-tail.d.ts +1 -1
- package/dist/core/file-history-retention.d.ts +1 -1
- package/dist/core/file-history-store.d.ts +147 -21
- package/dist/core/file-history-store.js +58 -32
- package/dist/core/gate-fold.d.ts +1 -1
- package/dist/core/gate-fold.js +24 -11
- package/dist/core/gate-lanes.js +81 -68
- package/dist/core/gate-outcome.d.ts +40 -6
- package/dist/core/gate-outcome.js +56 -0
- package/dist/core/governance-codes.d.ts +17 -3
- package/dist/core/governance-codes.js +16 -0
- package/dist/core/hands-band.d.ts +1 -1
- package/dist/core/hooks.d.ts +21 -20
- package/dist/core/hooks.js +3 -1
- package/dist/core/host-floor.d.ts +128 -0
- package/dist/core/host-floor.js +206 -0
- package/dist/core/host-target.d.ts +84 -0
- package/dist/core/host-target.js +92 -0
- package/dist/core/image-downsample.d.ts +1 -1
- package/dist/core/lsp-diagnostics.d.ts +4 -4
- package/dist/core/lsp.d.ts +3 -3
- package/dist/core/mailbox-store.d.ts +4 -0
- package/dist/core/mcp-connection-pool.d.ts +18 -2
- package/dist/core/mcp-connection-pool.js +53 -6
- package/dist/core/mcp-failure.d.ts +23 -4
- package/dist/core/mcp-failure.js +26 -11
- package/dist/core/mcp-listing-drift.d.ts +10 -0
- package/dist/core/mcp-listing-drift.js +6 -0
- package/dist/core/mcp-server-link.d.ts +173 -0
- package/dist/core/mcp-server-link.js +127 -0
- package/dist/core/mcp-server-spec.d.ts +4 -2
- package/dist/core/mcp-session-end.d.ts +26 -0
- package/dist/core/mcp-session-end.js +29 -0
- package/dist/core/mcp-startup-request.d.ts +17 -0
- package/dist/core/mcp-startup-request.js +17 -0
- package/dist/core/mcp.d.ts +17 -13
- package/dist/core/mcp.js +240 -189
- package/dist/core/media-byte-cap.d.ts +1 -1
- package/dist/core/memory-engine/delegation-settlement.js +15 -24
- package/dist/core/memory-engine/engine.d.ts +9 -9
- package/dist/core/memory-engine/engine.js +4 -4
- package/dist/core/memory-engine/layout.d.ts +60 -8
- package/dist/core/memory-engine/layout.js +65 -6
- package/dist/core/memory-engine/provenance-wording.d.ts +1 -1
- package/dist/core/memory-engine/tools.js +4 -1
- package/dist/core/mode-policy.d.ts +1 -1
- package/dist/core/model-seat.d.ts +10 -3
- package/dist/core/mods/classic-events.d.ts +67 -0
- package/dist/core/mods/classic-events.js +1 -0
- package/dist/core/mods/dollar.d.ts +13 -0
- package/dist/core/mods/extension-call.d.ts +31 -0
- package/dist/core/mods/extension-call.js +43 -0
- package/dist/core/mods/kernel/dispatch.d.ts +20 -3
- package/dist/core/mods/kernel/dispatch.js +140 -69
- package/dist/core/mods/kernel/events.d.ts +47 -11
- package/dist/core/mods/kernel/events.js +66 -42
- package/dist/core/mods/kernel/index.d.ts +4 -4
- package/dist/core/mods/kernel/index.js +2 -2
- package/dist/core/mods/kernel/receive.d.ts +39 -5
- package/dist/core/mods/kernel/receive.js +290 -17
- package/dist/core/mods/kernel/registration.d.ts +33 -2
- package/dist/core/mods/kernel/registration.js +6 -7
- package/dist/core/mods/kernel/site-rules.d.ts +44 -16
- package/dist/core/mods/kernel/site-rules.js +24 -42
- package/dist/core/mods/spec-seats.d.ts +69 -0
- package/dist/core/mods/spec-seats.js +114 -0
- package/dist/core/mods/stations.d.ts +28 -8
- package/dist/core/mods/stations.js +29 -13
- package/dist/core/mods/tool-call.d.ts +79 -0
- package/dist/core/mods/tool-call.js +152 -0
- package/dist/core/namespaced-rule-name.d.ts +44 -24
- package/dist/core/namespaced-rule-name.js +50 -43
- package/dist/core/output-style.d.ts +1 -1
- package/dist/core/param-rule-reach.d.ts +15 -0
- package/dist/core/param-rule-reach.js +30 -0
- package/dist/core/parent-spec-seat.d.ts +13 -1
- package/dist/core/parent-spec-seat.js +6 -0
- package/dist/core/park-selfcheck.js +1 -0
- package/dist/core/pause-registry.d.ts +16 -5
- package/dist/core/pause-registry.js +6 -2
- package/dist/core/peer-channel.d.ts +70 -0
- package/dist/core/peer-channel.js +1 -0
- package/dist/core/permission-rule-consent.d.ts +30 -5
- package/dist/core/permission-rule-consent.js +147 -50
- package/dist/core/permission-rule-model.d.ts +245 -65
- package/dist/core/permission-rule-model.js +421 -107
- package/dist/core/permission-rule-org.d.ts +6 -2
- package/dist/core/permission-rule-org.js +7 -3
- package/dist/core/permission-rule-provider.d.ts +6 -2
- package/dist/core/permission-rule-provider.js +41 -11
- package/dist/core/permission-rule-store.d.ts +22 -26
- package/dist/core/permission-rule-store.js +12 -6
- package/dist/core/permission-rule-sync.d.ts +11 -2
- package/dist/core/permission-rule-sync.js +11 -3
- package/dist/core/permission-rule-syntax.d.ts +5 -4
- package/dist/core/permission-rule-syntax.js +2 -2
- package/dist/core/permission-rules.d.ts +53 -15
- package/dist/core/permission-rules.js +125 -100
- package/dist/core/persisted-rule-arms.d.ts +6 -4
- package/dist/core/persisted-rule-arms.js +10 -12
- package/dist/core/present-plan-tool.js +3 -1
- package/dist/core/principal-name.d.ts +20 -0
- package/dist/core/principal-name.js +22 -0
- package/dist/core/prompt-section-seat.js +4 -6
- package/dist/core/protocol-http-auth.d.ts +26 -5
- package/dist/core/protocol-http-auth.js +137 -4
- package/dist/core/protocol-naming.d.ts +2 -2
- package/dist/core/read-only-shell-table.d.ts +1 -1
- package/dist/core/read-only-shell.d.ts +1 -1
- package/dist/core/retired-keys.d.ts +16 -0
- package/dist/core/retired-keys.js +16 -4
- package/dist/core/rewrite-rejudge.d.ts +60 -0
- package/dist/core/rewrite-rejudge.js +36 -0
- package/dist/core/roles.d.ts +34 -3
- package/dist/core/roles.js +66 -53
- package/dist/core/rule-lane-reads.d.ts +20 -15
- package/dist/core/rule-lane-reads.js +45 -17
- package/dist/core/rule-offer-read.d.ts +53 -0
- package/dist/core/rule-offer-read.js +146 -0
- package/dist/core/rule-owner.d.ts +46 -0
- package/dist/core/rule-owner.js +29 -0
- package/dist/core/runner/advisor-instructions.d.ts +70 -0
- package/dist/core/runner/advisor-instructions.js +61 -0
- package/dist/core/runner/advisor-tool.d.ts +33 -0
- package/dist/core/runner/advisor-tool.js +112 -0
- package/dist/core/runner/announce-once-ledger.d.ts +18 -26
- package/dist/core/runner/announce-once-ledger.js +19 -46
- package/dist/core/runner/approval-feedback.js +6 -3
- package/dist/core/runner/assemble-result.d.ts +2 -1
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/call-hook-stations.d.ts +3 -2
- package/dist/core/runner/caller-roster.d.ts +21 -2
- package/dist/core/runner/caller-roster.js +38 -0
- package/dist/core/runner/capability-withheld-seat.d.ts +5 -0
- package/dist/core/runner/capability-withheld-seat.js +24 -0
- package/dist/core/runner/classifier-ladder.d.ts +33 -13
- package/dist/core/runner/classifier-ladder.js +15 -14
- package/dist/core/runner/compaction-restate.d.ts +10 -6
- package/dist/core/runner/compaction-restate.js +9 -3
- package/dist/core/runner/construction-doors.js +3 -0
- package/dist/core/runner/contracts.d.ts +40 -33
- package/dist/core/runner/conversation-segment.d.ts +28 -0
- package/dist/core/runner/conversation-segment.js +42 -0
- package/dist/core/runner/cross-boundary-lane.d.ts +21 -16
- package/dist/core/runner/cross-boundary-lane.js +58 -34
- package/dist/core/runner/decide-continuation.d.ts +7 -4
- package/dist/core/runner/decide-continuation.js +2 -2
- package/dist/core/runner/denial-limit-arms.d.ts +4 -4
- package/dist/core/runner/denial-limit-arms.js +1 -1
- package/dist/core/runner/derived-route-fallback.d.ts +24 -24
- package/dist/core/runner/derived-route-fallback.js +9 -7
- package/dist/core/runner/file-history-request.d.ts +18 -0
- package/dist/core/runner/file-history-request.js +21 -13
- package/dist/core/runner/file-history-restore.d.ts +45 -0
- package/dist/core/runner/file-history-restore.js +46 -0
- package/dist/core/runner/gate-exit.d.ts +9 -3
- package/dist/core/runner/gate-exit.js +11 -5
- package/dist/core/runner/image.d.ts +7 -17
- package/dist/core/runner/image.js +9 -60
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +6 -6
- package/dist/core/runner/permission-rule-lanes.js +38 -15
- package/dist/core/runner/person-path-rows.d.ts +12 -9
- package/dist/core/runner/person-path-rows.js +19 -8
- package/dist/core/runner/prepare-advisor.d.ts +63 -0
- package/dist/core/runner/prepare-advisor.js +77 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +2 -2
- package/dist/core/runner/prepare-ask-lane.js +5 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -6
- package/dist/core/runner/prepare-caps-and-workflow.js +5 -4
- package/dist/core/runner/prepare-config-doors.d.ts +31 -38
- package/dist/core/runner/prepare-config-doors.js +57 -34
- package/dist/core/runner/prepare-defer-classify.d.ts +4 -3
- package/dist/core/runner/prepare-defer-classify.js +7 -8
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +1 -1
- package/dist/core/runner/prepare-file-history.d.ts +48 -8
- package/dist/core/runner/prepare-file-history.js +41 -73
- package/dist/core/runner/prepare-gate-stations.d.ts +2 -5
- package/dist/core/runner/prepare-gate-stations.js +12 -8
- package/dist/core/runner/prepare-hands-readface.d.ts +2 -8
- package/dist/core/runner/prepare-hands-readface.js +15 -14
- package/dist/core/runner/prepare-inherited-gate.d.ts +11 -7
- package/dist/core/runner/prepare-inherited-gate.js +8 -6
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-park-ask.js +12 -12
- package/dist/core/runner/prepare-policy-chain.d.ts +7 -4
- package/dist/core/runner/prepare-policy-chain.js +68 -81
- package/dist/core/runner/prepare-project-context.d.ts +5 -2
- package/dist/core/runner/prepare-project-context.js +6 -3
- package/dist/core/runner/prepare-prompt-assembly.d.ts +5 -7
- package/dist/core/runner/prepare-prompt-assembly.js +10 -8
- package/dist/core/runner/prepare-prompt-inputs.d.ts +11 -9
- package/dist/core/runner/prepare-prompt-inputs.js +4 -6
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
- package/dist/core/runner/prepare-protocol-tools.js +5 -4
- package/dist/core/runner/prepare-safety-scan.d.ts +9 -12
- package/dist/core/runner/prepare-safety-scan.js +8 -23
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +5 -6
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +41 -35
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +7 -4
- package/dist/core/runner/prepare-tool-disclosure-mount.js +24 -18
- package/dist/core/runner/prepare-turn-wiring.d.ts +0 -4
- package/dist/core/runner/prepare-turn-wiring.js +2 -7
- package/dist/core/runner/prepare-wiring-manifest.d.ts +11 -4
- package/dist/core/runner/prepare-wiring-manifest.js +3 -3
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-apply.js +11 -12
- package/dist/core/runner/resume-checkpoint-screen.js +3 -0
- package/dist/core/runner/resume-claim.d.ts +4 -2
- package/dist/core/runner/resume-claim.js +15 -8
- package/dist/core/runner/resume-policy-outcome.js +1 -1
- package/dist/core/runner/retired-runner-deps.js +2 -1
- package/dist/core/runner/rewind-files.d.ts +15 -0
- package/dist/core/runner/rewind-files.js +132 -0
- package/dist/core/runner/run-attachment-seats.js +2 -2
- package/dist/core/runner/run-brain-sinks.d.ts +4 -1
- package/dist/core/runner/run-brain-sinks.js +4 -2
- package/dist/core/runner/run-compaction-machinery.d.ts +1 -1
- package/dist/core/runner/run-compaction-machinery.js +2 -12
- package/dist/core/runner/run-git-lane.d.ts +1 -0
- package/dist/core/runner/run-harness-handlers.js +14 -7
- package/dist/core/runner/run-leg.d.ts +1 -1
- package/dist/core/runner/run-leg.js +43 -18
- package/dist/core/runner/run-settle-and-teardown.js +3 -2
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/run-turn-boundary.d.ts +1 -0
- package/dist/core/runner/run-turn-boundary.js +15 -22
- package/dist/core/runner/runtask.d.ts +3 -0
- package/dist/core/runner/runtask.js +8 -9
- package/dist/core/runner/session-read-file-states.d.ts +15 -0
- package/dist/core/runner/session-read-file-states.js +28 -0
- package/dist/core/runner/session-rule-policy.d.ts +22 -21
- package/dist/core/runner/session-rule-policy.js +17 -31
- package/dist/core/runner/shell-env-withheld.d.ts +33 -0
- package/dist/core/runner/shell-env-withheld.js +51 -0
- package/dist/core/runner/side-call-account.d.ts +32 -8
- package/dist/core/runner/side-call-account.js +23 -1
- package/dist/core/runner/skills-seat.js +6 -2
- package/dist/core/runner/stream-settle-backstop.js +1 -1
- package/dist/core/runner/strict-output-schema.d.ts +1 -1
- package/dist/core/runner/sub-agent-deny-lists.js +4 -6
- package/dist/core/runner/synthetic-tools.d.ts +16 -13
- package/dist/core/runner/synthetic-tools.js +8 -3
- package/dist/core/runner/tool-disclosure.d.ts +10 -12
- package/dist/core/runner/tool-disclosure.js +3 -4
- package/dist/core/runner/tool-end-body.d.ts +1 -1
- package/dist/core/runner/tool-end-body.js +10 -9
- package/dist/core/runner/tool-face-overlay.d.ts +2 -1
- package/dist/core/runner/tool-face-overlay.js +17 -1
- package/dist/core/runner/tool-not-executed.d.ts +5 -0
- package/dist/core/runner/tool-not-executed.js +11 -0
- package/dist/core/runner/tool-occurrence.d.ts +8 -0
- package/dist/core/runner/tool-occurrence.js +7 -0
- package/dist/core/runner/tool-progress-lane.d.ts +2 -2
- package/dist/core/runner/tool-turn-repair-seat.d.ts +3 -2
- package/dist/core/runner/turn-attachments.d.ts +91 -80
- package/dist/core/runner/turn-attachments.js +62 -37
- package/dist/core/runner-deps.d.ts +42 -42
- package/dist/core/runtime-caps.d.ts +4 -4
- package/dist/core/safety-axis-vocab.d.ts +6 -4
- package/dist/core/safety-axis-vocab.js +6 -5
- package/dist/core/safety-merge-corpus.js +26 -2
- package/dist/core/same-plain-value.d.ts +40 -0
- package/dist/core/same-plain-value.js +49 -0
- package/dist/core/scheduler.d.ts +1 -1
- package/dist/core/secret-env.d.ts +26 -3
- package/dist/core/secret-env.js +44 -8
- package/dist/core/select-model.js +3 -3
- package/dist/core/sensitive-path-policy.d.ts +1 -1
- package/dist/core/sensitive-path-policy.js +1 -1
- package/dist/core/session-policy-store.d.ts +102 -35
- package/dist/core/session-policy-store.js +210 -48
- package/dist/core/session-reconcile.d.ts +2 -2
- package/dist/core/session-store.d.ts +106 -37
- package/dist/core/session-store.js +165 -91
- package/dist/core/session.d.ts +101 -57
- package/dist/core/session.js +53 -0
- package/dist/core/shared-memory/tools.js +3 -1
- package/dist/core/shared-memory/types.d.ts +1 -1
- package/dist/core/shell-read-silence.d.ts +11 -12
- package/dist/core/shell-read-silence.js +9 -5
- package/dist/core/shell-run-candidates.js +3 -1
- package/dist/core/shell-wrapper-projection.js +1 -1
- package/dist/core/shell-wrapper-table.d.ts +14 -7
- package/dist/core/shell-wrapper-table.js +5 -4
- package/dist/core/side-query.d.ts +10 -0
- package/dist/core/side-query.js +15 -1
- package/dist/core/skill-grant.d.ts +7 -2
- package/dist/core/skill-grant.js +5 -0
- package/dist/core/skills-directory.js +6 -2
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +11 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +168 -3
- package/dist/core/store-contracts/file-history-store-contract.js +74 -4
- package/dist/core/store-contracts/peer-directory-contract.d.ts +7 -2
- package/dist/core/store-contracts/peer-directory-contract.js +14 -2
- package/dist/core/store-contracts/session-policy-store-contract.d.ts +7 -0
- package/dist/core/store-contracts/session-policy-store-contract.js +130 -0
- package/dist/core/store-contracts/session-repo-contract.js +176 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +6 -8
- package/dist/core/store-contracts/session-store-contract.js +361 -51
- package/dist/core/store-contracts/workflow-journal-store-contract.js +26 -1
- package/dist/core/stub-env.d.ts +2 -0
- package/dist/core/stub-env.js +1 -0
- package/dist/core/surrogate-safe-slice.d.ts +3 -3
- package/dist/core/synthetic-read-verdict.js +3 -3
- package/dist/core/task-event.d.ts +42 -8
- package/dist/core/task-notification.d.ts +19 -15
- package/dist/core/task-registry-agent.d.ts +4 -4
- package/dist/core/task-registry-shared.d.ts +4 -4
- package/dist/core/task-registry-shared.js +1 -0
- package/dist/core/task-registry.d.ts +13 -4
- package/dist/core/task-registry.js +14 -2
- package/dist/core/task-result.d.ts +21 -3
- package/dist/core/task-spec.d.ts +69 -64
- package/dist/core/task-stream.d.ts +6 -6
- package/dist/core/task-tool-shape.d.ts +4 -4
- package/dist/core/tighten-task-spec.d.ts +1 -1
- package/dist/core/tighten-task-spec.js +2 -1
- package/dist/core/tool-catalog-entries.d.ts +36 -2
- package/dist/core/tool-catalog-entries.js +69 -43
- package/dist/core/tool-check-reading.d.ts +11 -0
- package/dist/core/tool-check-reading.js +11 -6
- package/dist/core/tool-conformance.js +1 -0
- package/dist/core/tool-errors.d.ts +2 -2
- package/dist/core/tool-face-reader.js +5 -3
- package/dist/core/tool-face.d.ts +21 -2
- package/dist/core/tool-face.js +1 -1
- package/dist/core/tool-model-gate.d.ts +5 -5
- package/dist/core/tool-name-aliases.d.ts +29 -8
- package/dist/core/tool-name-aliases.js +22 -4
- package/dist/core/tool-name-readings.d.ts +10 -43
- package/dist/core/tool-name-readings.js +2 -11
- package/dist/core/tool-policy.d.ts +85 -196
- package/dist/core/tool-policy.js +150 -175
- package/dist/core/tool-registry.d.ts +14 -7
- package/dist/core/tool-registry.js +17 -7
- package/dist/core/tool-result-store.js +5 -1
- package/dist/core/tool-roster.d.ts +57 -33
- package/dist/core/tool-roster.js +56 -68
- package/dist/core/tool-spec-members.js +8 -3
- package/dist/core/tool-spec.d.ts +53 -31
- package/dist/core/tools.js +51 -10
- package/dist/core/trace.d.ts +6 -2
- package/dist/core/types.d.ts +1 -1
- package/dist/core/untrusted-egress.d.ts +1 -1
- package/dist/core/untrusted-text.d.ts +1 -1
- package/dist/core/user-attachment.d.ts +8 -1
- package/dist/core/user-attachment.js +64 -4
- package/dist/core/warm-resume.d.ts +1 -1
- package/dist/core/wiring-manifest.d.ts +58 -0
- package/dist/core/wiring-manifest.js +14 -5
- package/dist/core/workflow-journal-store.d.ts +62 -0
- package/dist/core/workflow-journal-store.js +78 -2
- package/dist/core/workflow-run-store.d.ts +6 -0
- package/dist/core/workflow-run-store.js +2 -0
- package/dist/engine/compaction/compaction.d.ts +9 -9
- package/dist/engine/compaction/compaction.js +3 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +26 -8
- package/dist/engine/execution-env/node-execution-env.js +54 -24
- package/dist/engine/harness/agent-harness.d.ts +39 -9
- package/dist/engine/harness/agent-harness.js +87 -33
- package/dist/engine/harness/types.d.ts +58 -9
- package/dist/engine/harness/types.js +12 -1
- package/dist/engine/llm/types.d.ts +36 -19
- package/dist/engine/llm/validation.d.ts +4 -1
- package/dist/engine/llm/validation.js +13 -1
- package/dist/engine/loop/agent-loop.d.ts +23 -1
- package/dist/engine/loop/agent-loop.js +26 -34
- package/dist/engine/loop/types.d.ts +31 -19
- package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
- package/dist/engine/session/memory-repo.d.ts +18 -12
- package/dist/engine/session/memory-repo.js +24 -9
- package/dist/engine/session/parent-chain-guard.d.ts +3 -2
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/repo-utils.d.ts +32 -3
- package/dist/engine/session/repo-utils.js +50 -5
- package/dist/index.d.ts +47 -23
- package/dist/index.js +35 -17
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +3 -3
- package/dist/internal/harness.js +2 -2
- package/dist/internal/llm.d.ts +2 -2
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/goal.js +2 -2
- package/dist/orchestration/run-workflow-tool.d.ts +8 -6
- package/dist/orchestration/run-workflow-tool.js +10 -6
- package/dist/orchestration/workflow-size-guideline.d.ts +4 -4
- package/dist/orchestration/workflow-types.d.ts +18 -0
- package/dist/orchestration/workflow-types.js +6 -0
- package/dist/orchestration/workflow.d.ts +5 -13
- package/dist/orchestration/workflow.js +57 -49
- package/dist/prompt-assembly/artifact.d.ts +2 -2
- package/dist/prompt-assembly/artifact.js +5 -3
- package/dist/prompt-assembly/assemble.d.ts +3 -2
- package/dist/prompt-assembly/assemble.js +1 -1
- package/dist/prompt-assembly/catalog/schema.d.ts +43 -12
- package/dist/prompt-assembly/catalog/schema.js +34 -2
- package/dist/prompt-assembly/catalog/sections.js +0 -1
- package/dist/prompt-assembly/composer.d.ts +3 -1
- package/dist/prompt-assembly/composer.js +1 -1
- package/dist/prompt-assembly/event-registry.js +2 -0
- package/dist/prompt-assembly/overlay.js +3 -3
- package/dist/prompt-assembly/renderers.d.ts +1 -1
- package/dist/prompt-assembly/renderers.js +0 -3
- package/dist/prompt-assembly/role-base.d.ts +15 -0
- package/dist/prompt-assembly/role-base.js +9 -0
- package/dist/prompt-assembly/select.d.ts +39 -14
- package/dist/prompt-assembly/select.js +47 -16
- package/dist/prompt-assembly/sugar.d.ts +17 -11
- package/dist/prompt-assembly/sugar.js +8 -3
- package/dist/prompt-assembly/tool-catalog.d.ts +39 -2
- package/dist/prompt-assembly/tool-catalog.js +117 -4
- package/dist/prompt-assembly/turn-snapshot.d.ts +4 -10
- package/dist/prompt-assembly/turn-snapshot.js +0 -3
- package/dist/prompt-assembly/types.d.ts +0 -7
- package/dist/prompts/default.d.ts +14 -14
- package/dist/scenarios/full-body.d.ts +15 -15
- package/dist/scenarios/full-body.js +4 -3
- package/dist/shell/lex.js +10 -1
- package/dist/stores/file/adoption/adopt.d.ts +4 -3
- package/dist/stores/file/adoption/adopt.js +27 -33
- package/dist/stores/file/adoption/marker.d.ts +6 -13
- package/dist/stores/file/adoption/marker.js +9 -17
- package/dist/stores/file/checkpoint-store.d.ts +24 -0
- package/dist/stores/file/checkpoint-store.js +45 -7
- package/dist/stores/file/file-history-store.d.ts +20 -19
- package/dist/stores/file/file-history-store.js +157 -141
- package/dist/stores/file/fs-atomic.d.ts +15 -0
- package/dist/stores/file/fs-atomic.js +89 -14
- package/dist/stores/file/index.d.ts +1 -1
- package/dist/stores/file/index.js +2 -1
- package/dist/stores/file/mailbox-store.d.ts +3 -0
- package/dist/stores/file/mailbox-store.js +3 -1
- package/dist/stores/file/permission-rule-adopt.d.ts +1 -1
- package/dist/stores/file/permission-rule-adopt.js +18 -18
- package/dist/stores/file/permission-rule-store.d.ts +18 -2
- package/dist/stores/file/permission-rule-store.js +31 -18
- package/dist/stores/file/session-policy-store.d.ts +3 -3
- package/dist/stores/file/session-store.d.ts +54 -16
- package/dist/stores/file/session-store.js +114 -85
- package/dist/stores/file/workflow-journal-store.d.ts +10 -4
- package/dist/stores/file/workflow-journal-store.js +28 -13
- package/dist/tools/artifact/artifact-text.d.ts +1 -1
- package/dist/tools/artifact/artifact-tool.js +5 -3
- package/dist/tools/fs/bash-program-position.d.ts +19 -2
- package/dist/tools/fs/bash-program-position.js +56 -9
- package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -3
- package/dist/tools/fs/fs-bash.d.ts +2 -2
- package/dist/tools/fs/fs-bash.js +8 -6
- package/dist/tools/fs/fs-glob.d.ts +86 -0
- package/dist/tools/fs/fs-glob.js +226 -0
- package/dist/tools/fs/fs-read.js +14 -14
- package/dist/tools/fs/fs-search-tools.js +7 -7
- package/dist/tools/fs/fs-shared.d.ts +8 -8
- package/dist/tools/fs/gh-rate-limit.d.ts +1 -1
- package/dist/tools/fs/notebook.d.ts +2 -2
- package/dist/tools/fs/pattern-kill-guard.d.ts +22 -0
- package/dist/tools/fs/pattern-kill-guard.js +397 -0
- package/dist/tools/fs/pdf.d.ts +9 -6
- package/dist/tools/fs/pdf.js +3 -3
- package/dist/tools/fs/program-read-model.d.ts +57 -7
- package/dist/tools/fs/program-read-model.js +11 -1
- package/dist/tools/fs/program-read-model.rows.js +78 -21
- package/dist/tools/fs/read-deny-home.js +3 -2
- package/dist/tools/fs/read-deny.d.ts +29 -7
- package/dist/tools/fs/read-deny.js +63 -22
- package/dist/tools/fs/removal-targets.d.ts +18 -8
- package/dist/tools/fs/removal-targets.js +47 -20
- package/dist/tools/fs/safety.d.ts +9 -9
- package/dist/tools/fs/search.d.ts +16 -6
- package/dist/tools/fs/search.js +20 -26
- package/dist/tools/fs/shell-read-argv.js +89 -12
- package/dist/tools/fs/shell-read-bindings.d.ts +31 -0
- package/dist/tools/fs/shell-read-bindings.js +41 -0
- package/dist/tools/fs/shell-read-check.js +12 -20
- package/dist/tools/fs/shell-read-environment.d.ts +5 -1
- package/dist/tools/fs/shell-read-environment.js +3 -2
- package/dist/tools/fs/shell-read-establish.d.ts +15 -0
- package/dist/tools/fs/shell-read-establish.js +19 -20
- package/dist/tools/fs/shell-read-judge.d.ts +4 -0
- package/dist/tools/fs/shell-read-judge.js +5 -2
- package/dist/tools/fs/shell-read-plan.js +24 -16
- package/dist/tools/fs/shell-read-start.d.ts +6 -1
- package/dist/tools/fs/shell-read-write-targets.d.ts +5 -1
- package/dist/tools/fs/shell-read-write-targets.js +2 -3
- package/dist/tools/fs/shell-reentry-text.d.ts +9 -0
- package/dist/tools/fs/shell-reentry-text.js +40 -2
- package/dist/tools/loop-tick.d.ts +2 -2
- package/dist/tools/scheduler-tools.js +5 -1
- package/dist/tools/task-list.d.ts +7 -7
- package/dist/tools/task-list.js +5 -1
- package/dist/tools/todo.js +65 -64
- package/dist/tools/web.d.ts +20 -15
- package/dist/tools/web.js +55 -69
- package/dist/tools/worktree.d.ts +3 -3
- package/dist/tools/worktree.js +3 -1
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +5894 -5638
- package/wire-changes/core@7.55.0.json +3318 -0
- package/wire-changes/core@7.56.0.json +3891 -0
- package/wire-changes/mods-kernel@7.56.0.json +303 -0
- package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +0 -39
- package/dist/core/store-contracts/session-store-incarnation-contract.js +0 -95
|
@@ -92,13 +92,13 @@ export interface ReconcileReport {
|
|
|
92
92
|
*/
|
|
93
93
|
export declare function findOrphanToolCalls(messages: AgentMessage[], suspendedBatch?: ReadonlySet<string>): OrphanToolCall[];
|
|
94
94
|
/**
|
|
95
|
-
* backlog #389 伴生 (D-2) —
|
|
95
|
+
* backlog #389 伴生 (D-2) — the reference's interruption markers, as is (
|
|
96
96
|
* minted as a USER message by `Jce` @ `CC:640141-640154`). CC mints one on every abort whose reason is
|
|
97
97
|
* outside `{"interrupt","refusal-fallback-edit"}` — and the interactive Esc / remote cancel, which is
|
|
98
98
|
* what `TaskStream.interrupt()` corresponds to, is precisely on the minting side (`CC:1033698-1033733`).
|
|
99
99
|
* The suppressed reason is the one case where the user's own replacement message is already the context.
|
|
100
100
|
*
|
|
101
|
-
* Taken
|
|
101
|
+
* Taken as is rather than reworded: this string is an INPUT to later reasoning in CC (its own
|
|
102
102
|
* "interrupted then immediately retried the same action" rule reads it back), and the constitution's
|
|
103
103
|
* standing rule is that a question CC has answered is answered in CC's form.
|
|
104
104
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type SessionPlacementRecord, type SessionRepo } from "../internal/harness.js";
|
|
2
|
-
import { type AcquiredSession, type PlacedSessionRow, type SessionPlacement, type SessionStore, type SessionStoreSummary } from "./session.js";
|
|
1
|
+
import { type Session, type SessionHead, type SessionPlacementRecord, type SessionRepo } from "../internal/harness.js";
|
|
2
|
+
import { type AcquiredSession, type PlacedSessionRow, type SessionListQuery, type SessionPlacement, type SessionStore, type SessionStoreSummary } from "./session.js";
|
|
3
3
|
import type { StoreDurability } from "./checkpoint-store.js";
|
|
4
4
|
import { SESSION_DEFAULT_TTL_DAYS } from "../config/defaults.js";
|
|
5
5
|
export { SESSION_DEFAULT_TTL_DAYS };
|
|
@@ -117,29 +117,27 @@ export declare class TtlSessionStore implements SessionStore {
|
|
|
117
117
|
olderThanMs?: number;
|
|
118
118
|
scope?: string;
|
|
119
119
|
}) => Promise<PlacedSessionRow[]>;
|
|
120
|
+
/** The by-id head read ({@link SessionStore.headOf}): the repo's own, verbatim — the row is the repo's, never this cache's, and a read
|
|
121
|
+
* racing a delete answers either generation (it never waits on one). Present only when the backing repo answers it (absence means no
|
|
122
|
+
* by-id head read, and so no ownership pair for an authorizer). */
|
|
123
|
+
readonly headOf?: (sessionId: string) => Promise<SessionHead | undefined>;
|
|
124
|
+
/** The repo's head read as this store's own decisions read the row through it (the cache check, the existence check), held
|
|
125
|
+
* privately so the store's reading of its rows is the repo's whatever a host does with the face. */
|
|
126
|
+
private readonly repoHead?;
|
|
120
127
|
private repo;
|
|
121
128
|
private entries;
|
|
122
|
-
/** Session-ownership rows (the multi-tenant admission capability face — see SessionStore.ownerOf).
|
|
123
|
-
* Deliberately NOT part of `entries`: an evicted-but-durable session (`forget` / evict:"forget")
|
|
124
|
-
* still EXISTS, and its ownership row outliving the cache entry is what keeps a live session from
|
|
125
|
-
* reading as `undefined` (= re-claimable by anyone). Rows die only when the repo's history does. */
|
|
126
|
-
private owners;
|
|
127
129
|
/** In-flight acquisitions keyed by id, so concurrent acquire(sameId) share one session. */
|
|
128
130
|
private pending;
|
|
129
|
-
/** Subagent transcript persistence — placed ids whose durable deletion FAILED: the
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* append fd pre-rmSync)
|
|
133
|
-
* file still exists (append → log_closed, transcript revival broken until restart). The entry is
|
|
134
|
-
* dropped instead, so a re-acquire replays a FRESH authority from disk; success clears the row. */
|
|
131
|
+
/** Subagent transcript persistence — placed ids whose durable deletion FAILED. Not a reading of placement: the row is that
|
|
132
|
+
* (see `rowIsPlaced`). It makes a later cold `release` read the row whatever the repo or the store's declaration, and it is never
|
|
133
|
+
* believed in the row's place: a read that faults deletes nothing. No cache entry is retained instead, because the repo may have torn down the shared session
|
|
134
|
+
* authority before its removal failed (the File repo closes the append fd pre-rmSync): a retained entry would serve a closed log. */
|
|
135
135
|
private pendingPlacedDeletes;
|
|
136
|
-
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
|
|
141
|
-
* the delete's own settlement (both outcomes release it). */
|
|
142
|
-
private deletingPlaced;
|
|
136
|
+
/** Releases (and idle-sweep deletes) IN FLIGHT that may delete the row: acquire and register — the two that resolve or write the row —
|
|
137
|
+
* await the settlement, because the repo's delete tears down the shared session authority mid-flight — an acquire racing the await window could capture (or rebuild
|
|
138
|
+
* and then lose) an authority the delete is about to close, and the caller would hold a session whose first append answers
|
|
139
|
+
* log_closed while the file still exists. The gate is per-id and bounded by the release's own settlement (both outcomes release it). */
|
|
140
|
+
private releasing;
|
|
143
141
|
/** Sessions pinned by a design/45 checkpoint — skipped by idle sweep until unpinned (B6/§5). */
|
|
144
142
|
private pinned;
|
|
145
143
|
private defaultTtlMs;
|
|
@@ -151,6 +149,17 @@ export declare class TtlSessionStore implements SessionStore {
|
|
|
151
149
|
requireExisting?: boolean;
|
|
152
150
|
placement?: SessionPlacement;
|
|
153
151
|
}): Promise<AcquiredSession>;
|
|
152
|
+
/** The one judgement of "does this cached view still stand for this row": `shown` is the view's session metadata and `row` the row as
|
|
153
|
+
* a read of it answered (a listed row, or the repo's head; `undefined` = no row, or no read of one). A row naming the view's
|
|
154
|
+
* occupant (`compareOccupants`) stands for it; a row naming another does not; and a row naming a different owner does not either —
|
|
155
|
+
* the owner is recorded once, by the write that creates the row, so another owner's row is another row whatever it names. When
|
|
156
|
+
* the evidence says neither (unknown) the answer is the repo's: over one with a head read the row can always be read again, so a
|
|
157
|
+
* view without positive proof is dropped and the id resolved from the row; over one with no head read (it mints no occupant token)
|
|
158
|
+
* the cached view is the only evidence of the occupant, and it stands. */
|
|
159
|
+
private viewStandsFor;
|
|
160
|
+
/** Whether a cached view is still the occupant the row holds ({@link viewStandsFor}, over the row's head read in one read). Over a repo
|
|
161
|
+
* with no head read there is no row to read: the judge's answer for no row there is "stands", given without reading the view. */
|
|
162
|
+
private cachedViewStands;
|
|
154
163
|
/** The placement admission ({@link admitSessionPlacement}) for this store, judged on every resolution path. The
|
|
155
164
|
* partition declaration is a getter over this store's live field, so it is read where the admission judges the
|
|
156
165
|
* mirror direction (after the request's own members, and only then) — never captured at construction. */
|
|
@@ -159,16 +168,28 @@ export declare class TtlSessionStore implements SessionStore {
|
|
|
159
168
|
* `requireExisting`, in which case a genuinely-missing id fails loud instead — design/114 Phase3). */
|
|
160
169
|
private openOrCreate;
|
|
161
170
|
private createAndStore;
|
|
162
|
-
/** Refresh the idle timer for a session.
|
|
163
|
-
|
|
171
|
+
/** Refresh the idle timer for a session, and record the activity on its row through the repo ({@link SessionRepo.touch}, where the repo
|
|
172
|
+
* has it) — the time {@link list} orders by. A fault recording it rejects. */
|
|
173
|
+
touch(sessionId: string): Promise<void>;
|
|
164
174
|
/** Record the most recent task run on a cached session (the `/resume` `lastRunId`); also bumps the idle
|
|
165
175
|
* timer. Best-effort — a no-op if the session isn't cached here (the run will still be re-attachable via
|
|
166
176
|
* its checkpoint). */
|
|
167
177
|
noteTaskRun(sessionId: string, taskId: string, runId?: string): void;
|
|
168
|
-
/**
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
|
|
178
|
+
/**
|
|
179
|
+
* One page of the repo's sessions ({@link SessionStore.list}): the rows the repo lists — what a restart still finds, not this
|
|
180
|
+
* cache — each projected from the row and ordered by the activity the repo RECORDS for it (its writes, and the touches this store
|
|
181
|
+
* records through it): never by what this process saw, so a dropped cache, a restart or another replica pages the same order, and a
|
|
182
|
+
* cursor is never overtaken by a row whose time moved back. The cached view adds only what it alone holds — the run it recorded
|
|
183
|
+
* (`lastTaskId` / `lastTaskRunId`; after a restart, or once the view is evicted, a row lists without them) — and only while the view
|
|
184
|
+
* stands for the listed row ({@link viewStandsFor}, the judgement `acquire` serves the cached session by). Every row is read to order the page; the repo's listing cost is its own (the File repo: one header
|
|
185
|
+
* read per session).
|
|
186
|
+
*/
|
|
187
|
+
list(query?: SessionListQuery): Promise<SessionStoreSummary[]>;
|
|
188
|
+
/** A listed row's projection: the row's own cells, and the cached view's run while the view stands for the row
|
|
189
|
+
* ({@link viewStandsFor} — the row is read here, so a view of an occupant it names otherwise lends nothing). A row's activity is the
|
|
190
|
+
* repo's recorded time for it, else its creation — the view's own time is never read, so a repo that records none lists by creation;
|
|
191
|
+
* one whose times are both unreadable lists at 0 — at the end, never left out. */
|
|
192
|
+
private summaryOf;
|
|
172
193
|
/**
|
|
173
194
|
* design/110 (F3) — FORK a session: copy `sourceId`'s committed history into a NEW session and return its id
|
|
174
195
|
* (or `null` when the source doesn't exist). Delegates to the backing repo's `fork`, so a durable repo persists the
|
|
@@ -179,8 +200,34 @@ export declare class TtlSessionStore implements SessionStore {
|
|
|
179
200
|
* fork capability mounts (it was INERT before — the durable repo had `fork` but the store never exposed it).
|
|
180
201
|
*/
|
|
181
202
|
fork(sourceId: string, owner?: string | null): Promise<string | null>;
|
|
182
|
-
/** Drop a session from the live set. With a durable repo (`evict: "forget"`) the history is kept.
|
|
203
|
+
/** Drop a session from the live set. With a durable repo (`evict: "forget"`) the history is kept. A release that rejects leaves the
|
|
204
|
+
* session where it was: the store keeps no view of it and retries nothing on its own, and a placed row is found again by the
|
|
205
|
+
* partition-GC leg's `listPlaced` — except one whose header is damaged, which `listPlaced` skips and every release of it rejects
|
|
206
|
+
* (`corrupt_session`), so only manual cleanup removes it. */
|
|
183
207
|
release(sessionId: string): Promise<void>;
|
|
208
|
+
/** Run a release that may delete the row while it holds the id: the gate is set before the first await, after any release already in
|
|
209
|
+
* flight for the id, and `acquire` / `register` answer after it settles — no caller captures an authority the delete is about to tear
|
|
210
|
+
* down (the repo closes the shared authority before its removal can fail), or writes the row mid-decision. */
|
|
211
|
+
private holdingId;
|
|
212
|
+
/** The deciding half of {@link release}, under its gate. A delete goes through the cached view only while the row still stands for it
|
|
213
|
+
* (`cachedViewStands`); with no view, or a view of an occupant the row no longer holds (another writer deleted the row, or deleted and
|
|
214
|
+
* created it again), the row decides — its placement read cold ({@link rowIsPlaced}) — and an unplaced row nobody here holds is left
|
|
215
|
+
* as it is. Placement obligation 4: a placed row's release is a REAL deletion whatever the evict policy (the joint reap deletes the
|
|
216
|
+
* agent row first and then calls this to end the transcript; a forget would strand it). A delete runs only on a read that answered
|
|
217
|
+
* — the head read with the view still standing, or the row's own placement: a read that faults deletes nothing, and the release
|
|
218
|
+
* rejects with it. A placed release that fails (a read or the delete) leaves the tombstone, so the retry reads the row again —
|
|
219
|
+
* never a retained cache entry, which could serve a closed log; an unplaced view's release under `evict: "delete"` leaves nothing,
|
|
220
|
+
* so its retry after a failed read resolves and deletes nothing. */
|
|
221
|
+
private releaseRow;
|
|
222
|
+
/** The repo's placement probe, where it has one. */
|
|
223
|
+
private placementProbe;
|
|
224
|
+
/** Whether an uncached id's row is worth reading for its placement: through the probe on a store that declares placements, and by
|
|
225
|
+
* either means for an id whose placed deletion failed here. */
|
|
226
|
+
private rowReadMatters;
|
|
227
|
+
/** Whether the row standing under `sessionId` is placed: the repo's placement probe where it has one, else the row's own metadata,
|
|
228
|
+
* read where {@link rowReadMatters}. Its answer retires the tombstone. A read that FAULTS answers nothing: it rejects (the release
|
|
229
|
+
* deletes nothing and fails with it), and the tombstone stays for the next release to read the row again. */
|
|
230
|
+
private rowIsPlaced;
|
|
184
231
|
/** Drop only the cached view — the repo keeps the session regardless of `evictPolicy`, so a re-acquire
|
|
185
232
|
* re-opens the SAME history (B-17: the reconcile retry / prepare-throw paths must never delete). Cost
|
|
186
233
|
* on the default in-memory repo: ONE retained session object **per forgotten id** until process end
|
|
@@ -193,19 +240,41 @@ export declare class TtlSessionStore implements SessionStore {
|
|
|
193
240
|
pin(sessionId: string): void;
|
|
194
241
|
/** Release a design/45 pin (on resume or checkpoint expiry); the session resumes normal idle eviction. */
|
|
195
242
|
unpin(sessionId: string): void;
|
|
196
|
-
/**
|
|
197
|
-
*
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
* authorization decision — the authorizer re-reads {@link ownerOf} and judges there. */
|
|
243
|
+
/** The owner write of the ownership pair (see the SessionStore contract): an id with no row gets one — an ordinary row recording
|
|
244
|
+
* `owner` in its creating write, through the repo's create (the repo makes the creation first-write-wins); an id whose row exists is
|
|
245
|
+
* left exactly as it is, whatever this call carries. Makes no authorization decision — the authorizer re-reads {@link headOf}. The
|
|
246
|
+
* row is not cached here: it is resolved like any other row on the next `acquire`. */
|
|
201
247
|
register(sessionId: string, owner: string | null): Promise<void>;
|
|
202
|
-
/**
|
|
203
|
-
*
|
|
204
|
-
|
|
205
|
-
* `undefined`; any other repo failure rejects (a fault is not an answer). Never caches, never creates. */
|
|
206
|
-
incarnationOf(sessionId: string): Promise<string | undefined>;
|
|
248
|
+
/** Whether the repo holds a row for `sessionId` — its head read where it has one (no replay of the row's history), else an open. A
|
|
249
|
+
* fault rejects; it is not an answer. */
|
|
250
|
+
private hasRow;
|
|
207
251
|
/** Evict idle-expired sessions from the cache. Deletes durable history only when `evict: "delete"`. */
|
|
208
252
|
sweep(now?: number): void;
|
|
209
253
|
get size(): number;
|
|
210
254
|
dispose(): void;
|
|
211
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* design/110 (F4) — pick the fork point so a child does NOT inherit an in-flight (uncommitted) tool call.
|
|
258
|
+
*
|
|
259
|
+
* The agent loop commits the assistant turn (`message_end` → `appendMessage`) BEFORE it executes that turn's tool
|
|
260
|
+
* calls. So while the Fork tool's own `execute` runs, the source session's LEAF is the assistant message that carries
|
|
261
|
+
* the Fork tool-call (and any sibling parallel calls) with NO tool results behind it yet. Forking the whole log would
|
|
262
|
+
* copy that orphan call into the child, and the child's wake-time `reconcileInterruptedSession` would inject an
|
|
263
|
+
* `[INTERRUPTED]` result for it — polluting the inherited context ("I called Fork → it was interrupted").
|
|
264
|
+
*
|
|
265
|
+
* Detection: the latest assistant `message` on the leaf's chain (past the tool results behind it) has a `toolCall` block
|
|
266
|
+
* (the message shape — there is NO `toolCalls` field; tool calls are content blocks) that no tool result behind it answers —
|
|
267
|
+
* the loop's own reading of an open batch (`findUnansweredToolBatch`). When so, fork at the turn's PARENT (`position:"at"`
|
|
268
|
+
* includes the parent, excludes the assistant turn) — the correct fork semantics: "inherit my context up to, but not
|
|
269
|
+
* including, the spawn call". A settled leaf (a text-only turn, or a tool turn every call of which is answered), or an
|
|
270
|
+
* unsettled assistant that is somehow a root (no `parentId`, fail-safe), forks the whole log (`{}`).
|
|
271
|
+
*
|
|
272
|
+
* Exported at the package root: the bundled store's `fork` and any other store's `fork` are the same question and must give the same
|
|
273
|
+
* answer — a backend reads the source session (`SessionRepo.open`), asks this, and hands the answer to `SessionRepo.fork` with the id
|
|
274
|
+
* and owner it mints. Forking the whole log instead copies the in-flight turn. The walk is one of the parent-chain walks, so it takes the
|
|
275
|
+
* shared guard: a leaf on a loop of tool-result messages is refused `invalid_session` (the sentence of `getPathToRoot`) instead of followed.
|
|
276
|
+
*/
|
|
277
|
+
export declare function settledForkOptions(source: Session): Promise<{
|
|
278
|
+
entryId?: string;
|
|
279
|
+
position?: "at";
|
|
280
|
+
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InMemorySessionRepo, SessionError, uuidv7, } from "../internal/harness.js";
|
|
2
|
-
import { isSessionConflict } from "./session.js";
|
|
1
|
+
import { InMemorySessionRepo, ParentChainGuard, SessionError, findUnansweredToolBatch, compareOccupants, ownerCell, uuidv7, } from "../internal/harness.js";
|
|
2
|
+
import { isSessionConflict, readSessionListQuery } from "./session.js";
|
|
3
3
|
import { readMember } from "./thrown-value.js";
|
|
4
4
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
5
5
|
import { SESSION_DEFAULT_TTL_DAYS } from "../config/defaults.js";
|
|
@@ -23,12 +23,13 @@ export class TtlSessionStore {
|
|
|
23
23
|
durability;
|
|
24
24
|
placements;
|
|
25
25
|
listPlaced;
|
|
26
|
+
headOf;
|
|
27
|
+
repoHead;
|
|
26
28
|
repo;
|
|
27
29
|
entries = new Map();
|
|
28
|
-
owners = new Map();
|
|
29
30
|
pending = new Map();
|
|
30
31
|
pendingPlacedDeletes = new Set();
|
|
31
|
-
|
|
32
|
+
releasing = new Map();
|
|
32
33
|
pinned = new Set();
|
|
33
34
|
defaultTtlMs;
|
|
34
35
|
evictPolicy;
|
|
@@ -46,6 +47,11 @@ export class TtlSessionStore {
|
|
|
46
47
|
if (typeof repoListPlaced === "function") {
|
|
47
48
|
this.listPlaced = (kind, o) => repoListPlaced.call(this.repo, kind, o);
|
|
48
49
|
}
|
|
50
|
+
const repoHeadOf = this.repo.headOf;
|
|
51
|
+
if (typeof repoHeadOf === "function") {
|
|
52
|
+
this.repoHead = (sessionId) => repoHeadOf.call(this.repo, sessionId);
|
|
53
|
+
this.headOf = this.repoHead;
|
|
54
|
+
}
|
|
49
55
|
if (opts.sweepIntervalMs !== undefined && opts.sweepIntervalMs > 0) {
|
|
50
56
|
this.sweepTimer = setInterval(() => this.sweep(), opts.sweepIntervalMs);
|
|
51
57
|
this.sweepTimer.unref?.();
|
|
@@ -54,14 +60,18 @@ export class TtlSessionStore {
|
|
|
54
60
|
async acquire(sessionId, opts) {
|
|
55
61
|
this.sweep();
|
|
56
62
|
if (sessionId) {
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
await
|
|
63
|
+
const inflightRelease = this.releasing.get(sessionId);
|
|
64
|
+
if (inflightRelease !== undefined)
|
|
65
|
+
await inflightRelease;
|
|
60
66
|
const existing = this.entries.get(sessionId);
|
|
61
67
|
if (existing) {
|
|
62
|
-
this.
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
if (await this.cachedViewStands(sessionId, existing)) {
|
|
69
|
+
this.assertPlacementAdmission(sessionId, existing.placement, opts);
|
|
70
|
+
existing.lastActiveAt = Date.now();
|
|
71
|
+
return { session: existing.session, sessionId };
|
|
72
|
+
}
|
|
73
|
+
if (this.entries.get(sessionId) === existing)
|
|
74
|
+
this.entries.delete(sessionId);
|
|
65
75
|
}
|
|
66
76
|
if (opts?.requireExisting) {
|
|
67
77
|
return { session: await this.openOrCreate(sessionId, true), sessionId };
|
|
@@ -87,6 +97,20 @@ export class TtlSessionStore {
|
|
|
87
97
|
const meta = await session.getMetadata();
|
|
88
98
|
return { session, sessionId: meta.id };
|
|
89
99
|
}
|
|
100
|
+
viewStandsFor(shown, row) {
|
|
101
|
+
const verdict = compareOccupants(shown, row);
|
|
102
|
+
if (verdict !== "unknown")
|
|
103
|
+
return verdict === "same";
|
|
104
|
+
if (row !== undefined && (shown.owner ?? null) !== (row.owner ?? null))
|
|
105
|
+
return false;
|
|
106
|
+
return this.repoHead === undefined;
|
|
107
|
+
}
|
|
108
|
+
async cachedViewStands(sessionId, cached) {
|
|
109
|
+
if (this.repoHead === undefined)
|
|
110
|
+
return true;
|
|
111
|
+
const [shown, row] = await Promise.all([cached.session.getMetadata(), this.repoHead(sessionId)]);
|
|
112
|
+
return this.viewStandsFor(shown, row);
|
|
113
|
+
}
|
|
90
114
|
assertPlacementAdmission(sessionId, placement, opts) {
|
|
91
115
|
const store = this;
|
|
92
116
|
admitSessionPlacement(sessionId, placement, opts ?? {}, {
|
|
@@ -99,8 +123,6 @@ export class TtlSessionStore {
|
|
|
99
123
|
try {
|
|
100
124
|
const session = await this.repo.open({ id, createdAt: "" });
|
|
101
125
|
const meta = await session.getMetadata();
|
|
102
|
-
if (meta.placement === undefined)
|
|
103
|
-
this.pendingPlacedDeletes.delete(id);
|
|
104
126
|
this.entries.set(id, { session, lastActiveAt: Date.now(), createdAt: meta.createdAt, ...(meta.forkedFrom !== undefined ? { forkedFrom: meta.forkedFrom } : {}), ...(meta.placement !== undefined ? { placement: meta.placement } : {}) });
|
|
105
127
|
return session;
|
|
106
128
|
}
|
|
@@ -115,18 +137,25 @@ export class TtlSessionStore {
|
|
|
115
137
|
}
|
|
116
138
|
}
|
|
117
139
|
async createAndStore(id, placement) {
|
|
118
|
-
|
|
140
|
+
let session;
|
|
141
|
+
try {
|
|
142
|
+
session = await this.repo.create({ ...(id !== undefined ? { id } : {}), ...(placement !== undefined ? { placement } : {}) });
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
if (id === undefined || !isSessionConflict(err))
|
|
146
|
+
throw err;
|
|
147
|
+
session = await this.repo.open({ id, createdAt: "" });
|
|
148
|
+
}
|
|
119
149
|
const meta = await session.getMetadata();
|
|
120
|
-
if (meta.placement === undefined)
|
|
121
|
-
this.pendingPlacedDeletes.delete(meta.id);
|
|
122
150
|
this.entries.set(meta.id, { session, lastActiveAt: Date.now(), createdAt: meta.createdAt, ...(meta.forkedFrom !== undefined ? { forkedFrom: meta.forkedFrom } : {}), ...(meta.placement !== undefined ? { placement: meta.placement } : {}) });
|
|
123
151
|
return session;
|
|
124
152
|
}
|
|
125
|
-
touch(sessionId) {
|
|
153
|
+
async touch(sessionId) {
|
|
126
154
|
const e = this.entries.get(sessionId);
|
|
127
155
|
if (e) {
|
|
128
156
|
e.lastActiveAt = Date.now();
|
|
129
157
|
}
|
|
158
|
+
await this.repo.touch?.(sessionId);
|
|
130
159
|
}
|
|
131
160
|
noteTaskRun(sessionId, taskId, runId) {
|
|
132
161
|
const e = this.entries.get(sessionId);
|
|
@@ -139,18 +168,36 @@ export class TtlSessionStore {
|
|
|
139
168
|
e.lastActiveAt = Date.now();
|
|
140
169
|
}
|
|
141
170
|
}
|
|
142
|
-
async list() {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
171
|
+
async list(query) {
|
|
172
|
+
const q = readSessionListQuery(query);
|
|
173
|
+
const page = [];
|
|
174
|
+
for (const row of await this.repo.list()) {
|
|
175
|
+
if (row.placement !== undefined)
|
|
176
|
+
continue;
|
|
177
|
+
const owner = row.owner ?? null;
|
|
178
|
+
if (q.owner !== undefined && owner !== q.owner && !(q.includeUnowned && owner === null))
|
|
179
|
+
continue;
|
|
180
|
+
const summary = await this.summaryOf(row);
|
|
181
|
+
if (q.after !== undefined && newestFirst(q.after, summary) >= 0)
|
|
182
|
+
continue;
|
|
183
|
+
page.push(summary);
|
|
184
|
+
}
|
|
185
|
+
return page.sort(newestFirst).slice(0, q.limit);
|
|
186
|
+
}
|
|
187
|
+
async summaryOf(row) {
|
|
188
|
+
const cached = this.entries.get(row.id);
|
|
189
|
+
const view = cached !== undefined && this.viewStandsFor(await cached.session.getMetadata(), row) ? cached : undefined;
|
|
190
|
+
const recorded = row.lastActiveAt !== undefined && Number.isFinite(row.lastActiveAt) ? row.lastActiveAt : Date.parse(row.createdAt);
|
|
191
|
+
const lastActiveAt = Number.isFinite(recorded) ? recorded : 0;
|
|
192
|
+
const forkedFrom = row.forkedFrom ?? view?.forkedFrom;
|
|
193
|
+
return {
|
|
194
|
+
sessionId: row.id,
|
|
195
|
+
lastActiveAt,
|
|
196
|
+
...(row.createdAt !== "" ? { createdAt: row.createdAt } : {}),
|
|
197
|
+
...(view?.lastTaskId !== undefined ? { lastTaskId: view.lastTaskId } : {}),
|
|
198
|
+
...(view?.lastTaskRunId !== undefined ? { lastTaskRunId: view.lastTaskRunId } : {}),
|
|
199
|
+
...(forkedFrom !== undefined ? { forkedFrom } : {}),
|
|
200
|
+
};
|
|
154
201
|
}
|
|
155
202
|
async fork(sourceId, owner) {
|
|
156
203
|
let source;
|
|
@@ -164,17 +211,8 @@ export class TtlSessionStore {
|
|
|
164
211
|
throw err;
|
|
165
212
|
}
|
|
166
213
|
const forkOptions = await settledForkOptions(source);
|
|
167
|
-
const
|
|
168
|
-
if (owner != null) {
|
|
169
|
-
forkParams.owner = owner;
|
|
170
|
-
}
|
|
171
|
-
const forked = await this.repo.fork(await source.getMetadata(), forkParams);
|
|
214
|
+
const forked = await this.repo.fork(await source.getMetadata(), { ...forkOptions, id: uuidv7(), ...(owner !== undefined ? { owner } : {}) });
|
|
172
215
|
const meta = await forked.getMetadata();
|
|
173
|
-
const inherited = this.owners.has(sourceId) ? this.owners.get(sourceId) : undefined;
|
|
174
|
-
const forkOwner = owner ?? inherited;
|
|
175
|
-
if (forkOwner !== undefined && !this.owners.has(meta.id)) {
|
|
176
|
-
this.owners.set(meta.id, forkOwner);
|
|
177
|
-
}
|
|
178
216
|
this.entries.set(meta.id, {
|
|
179
217
|
session: forked,
|
|
180
218
|
lastActiveAt: Date.now(),
|
|
@@ -187,46 +225,66 @@ export class TtlSessionStore {
|
|
|
187
225
|
if (this.pinned.has(sessionId)) {
|
|
188
226
|
return;
|
|
189
227
|
}
|
|
190
|
-
const
|
|
191
|
-
if (
|
|
192
|
-
this.
|
|
193
|
-
|
|
194
|
-
if (!placed && e === undefined && this.placements !== undefined) {
|
|
195
|
-
const probe = this.repo.placementOf;
|
|
196
|
-
if (typeof probe === "function") {
|
|
197
|
-
try {
|
|
198
|
-
placed = (await probe.call(this.repo, sessionId)) !== undefined;
|
|
199
|
-
}
|
|
200
|
-
catch {
|
|
201
|
-
placed = false;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
if (!e && !placed) {
|
|
228
|
+
const cached = this.entries.get(sessionId);
|
|
229
|
+
if (cached !== undefined)
|
|
230
|
+
this.entries.delete(sessionId);
|
|
231
|
+
if (cached !== undefined && cached.placement === undefined && this.evictPolicy !== "delete")
|
|
206
232
|
return;
|
|
233
|
+
if (cached === undefined && !this.releasing.has(sessionId) && !this.rowReadMatters(sessionId))
|
|
234
|
+
return;
|
|
235
|
+
return this.holdingId(sessionId, () => this.releaseRow(sessionId, cached));
|
|
236
|
+
}
|
|
237
|
+
async holdingId(sessionId, work) {
|
|
238
|
+
const prior = this.releasing.get(sessionId);
|
|
239
|
+
let settle;
|
|
240
|
+
const gate = new Promise((r) => (settle = r));
|
|
241
|
+
this.releasing.set(sessionId, gate);
|
|
242
|
+
try {
|
|
243
|
+
if (prior !== undefined)
|
|
244
|
+
await prior;
|
|
245
|
+
await work();
|
|
207
246
|
}
|
|
208
|
-
|
|
247
|
+
finally {
|
|
248
|
+
if (this.releasing.get(sessionId) === gate)
|
|
249
|
+
this.releasing.delete(sessionId);
|
|
250
|
+
settle();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
async releaseRow(sessionId, cached) {
|
|
254
|
+
if (cached?.placement !== undefined)
|
|
209
255
|
this.pendingPlacedDeletes.add(sessionId);
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
try {
|
|
214
|
-
const meta = e !== undefined ? await e.session.getMetadata() : { id: sessionId, createdAt: "" };
|
|
215
|
-
await this.repo.delete(meta);
|
|
216
|
-
}
|
|
217
|
-
finally {
|
|
218
|
-
this.deletingPlaced.delete(sessionId);
|
|
219
|
-
settleGate();
|
|
220
|
-
}
|
|
221
|
-
this.pendingPlacedDeletes.delete(sessionId);
|
|
222
|
-
this.owners.delete(sessionId);
|
|
256
|
+
const view = cached !== undefined && (await this.cachedViewStands(sessionId, cached)) ? cached : undefined;
|
|
257
|
+
const placed = view !== undefined ? view.placement !== undefined : await this.rowIsPlaced(sessionId);
|
|
258
|
+
if (view === undefined && !placed)
|
|
223
259
|
return;
|
|
260
|
+
const meta = view !== undefined ? await view.session.getMetadata() : { id: sessionId, createdAt: "" };
|
|
261
|
+
if (!placed)
|
|
262
|
+
return this.repo.delete(meta);
|
|
263
|
+
this.pendingPlacedDeletes.add(sessionId);
|
|
264
|
+
await this.repo.delete(meta);
|
|
265
|
+
this.pendingPlacedDeletes.delete(sessionId);
|
|
266
|
+
}
|
|
267
|
+
placementProbe() {
|
|
268
|
+
const probe = this.repo.placementOf;
|
|
269
|
+
return typeof probe === "function" ? probe.bind(this.repo) : undefined;
|
|
270
|
+
}
|
|
271
|
+
rowReadMatters(sessionId) {
|
|
272
|
+
return this.pendingPlacedDeletes.has(sessionId) || (this.placements !== undefined && this.placementProbe() !== undefined);
|
|
273
|
+
}
|
|
274
|
+
async rowIsPlaced(sessionId) {
|
|
275
|
+
if (!this.rowReadMatters(sessionId))
|
|
276
|
+
return false;
|
|
277
|
+
const probe = this.placementProbe();
|
|
278
|
+
let placement;
|
|
279
|
+
try {
|
|
280
|
+
placement = probe !== undefined ? await probe(sessionId) : (await (await this.repo.open({ id: sessionId, createdAt: "" })).getMetadata()).placement;
|
|
224
281
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
this.owners.delete(sessionId);
|
|
282
|
+
catch (err) {
|
|
283
|
+
if (!isNotFound(err))
|
|
284
|
+
throw err;
|
|
229
285
|
}
|
|
286
|
+
this.pendingPlacedDeletes.delete(sessionId);
|
|
287
|
+
return placement !== undefined;
|
|
230
288
|
}
|
|
231
289
|
forget(sessionId) {
|
|
232
290
|
this.entries.delete(sessionId);
|
|
@@ -237,29 +295,36 @@ export class TtlSessionStore {
|
|
|
237
295
|
unpin(sessionId) {
|
|
238
296
|
this.pinned.delete(sessionId);
|
|
239
297
|
}
|
|
240
|
-
async ownerOf(sessionId) {
|
|
241
|
-
return this.owners.has(sessionId) ? this.owners.get(sessionId) : undefined;
|
|
242
|
-
}
|
|
243
298
|
async register(sessionId, owner) {
|
|
244
|
-
|
|
299
|
+
const inflightRelease = this.releasing.get(sessionId);
|
|
300
|
+
if (inflightRelease !== undefined)
|
|
301
|
+
await inflightRelease;
|
|
302
|
+
if (await this.hasRow(sessionId))
|
|
245
303
|
return;
|
|
304
|
+
if (owner === undefined)
|
|
305
|
+
throw new TypeError("SessionStore.register: owner must be a principal name or null (anonymous), got undefined");
|
|
306
|
+
ownerCell(owner);
|
|
307
|
+
try {
|
|
308
|
+
await this.repo.create({ id: sessionId, owner });
|
|
246
309
|
}
|
|
247
|
-
|
|
248
|
-
|
|
310
|
+
catch (err) {
|
|
311
|
+
if (isSessionConflict(err))
|
|
312
|
+
return;
|
|
313
|
+
throw err;
|
|
249
314
|
}
|
|
250
|
-
this.owners.set(sessionId, owner);
|
|
251
315
|
}
|
|
252
|
-
async
|
|
253
|
-
|
|
316
|
+
async hasRow(sessionId) {
|
|
317
|
+
if (this.repoHead !== undefined)
|
|
318
|
+
return (await this.repoHead(sessionId)) !== undefined;
|
|
254
319
|
try {
|
|
255
|
-
|
|
320
|
+
await this.repo.open({ id: sessionId, createdAt: "" });
|
|
321
|
+
return true;
|
|
256
322
|
}
|
|
257
323
|
catch (err) {
|
|
258
324
|
if (isNotFound(err))
|
|
259
|
-
return
|
|
325
|
+
return false;
|
|
260
326
|
throw err;
|
|
261
327
|
}
|
|
262
|
-
return (await session.getMetadata()).incarnation;
|
|
263
328
|
}
|
|
264
329
|
sweep(now = Date.now()) {
|
|
265
330
|
for (const [id, e] of this.entries) {
|
|
@@ -269,9 +334,10 @@ export class TtlSessionStore {
|
|
|
269
334
|
if (now - e.lastActiveAt > this.defaultTtlMs) {
|
|
270
335
|
this.entries.delete(id);
|
|
271
336
|
if (this.evictPolicy === "delete" && e.placement === undefined) {
|
|
272
|
-
void this.
|
|
273
|
-
this.
|
|
274
|
-
|
|
337
|
+
void this.holdingId(id, async () => {
|
|
338
|
+
if (await this.cachedViewStands(id, e))
|
|
339
|
+
await this.repo.delete({ id, createdAt: "" });
|
|
340
|
+
}).catch(() => { });
|
|
275
341
|
}
|
|
276
342
|
}
|
|
277
343
|
}
|
|
@@ -285,26 +351,34 @@ export class TtlSessionStore {
|
|
|
285
351
|
}
|
|
286
352
|
}
|
|
287
353
|
}
|
|
288
|
-
async function settledForkOptions(source) {
|
|
354
|
+
export async function settledForkOptions(source) {
|
|
289
355
|
const storage = source.getStorage();
|
|
290
356
|
let id = await storage.getLeafId();
|
|
357
|
+
const chain = new ParentChainGuard();
|
|
358
|
+
const answers = [];
|
|
291
359
|
while (id) {
|
|
360
|
+
chain.stepOnto(id);
|
|
292
361
|
const entry = await storage.getEntry(id);
|
|
293
362
|
if (!entry || entry.type !== "message") {
|
|
294
363
|
return {};
|
|
295
364
|
}
|
|
296
365
|
if (entry.message.role === "assistant") {
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
return hasToolCall && entry.parentId ? { entryId: entry.parentId, position: "at" } : {};
|
|
366
|
+
const open = findUnansweredToolBatch([entry.message, ...answers]) !== undefined;
|
|
367
|
+
return open && entry.parentId ? { entryId: entry.parentId, position: "at" } : {};
|
|
300
368
|
}
|
|
301
369
|
if (entry.message.role !== "toolResult") {
|
|
302
370
|
return {};
|
|
303
371
|
}
|
|
372
|
+
answers.push(entry.message);
|
|
304
373
|
id = entry.parentId;
|
|
305
374
|
}
|
|
306
375
|
return {};
|
|
307
376
|
}
|
|
377
|
+
function newestFirst(a, b) {
|
|
378
|
+
if (a.lastActiveAt !== b.lastActiveAt)
|
|
379
|
+
return b.lastActiveAt - a.lastActiveAt;
|
|
380
|
+
return a.sessionId < b.sessionId ? 1 : a.sessionId > b.sessionId ? -1 : 0;
|
|
381
|
+
}
|
|
308
382
|
function isNotFound(err) {
|
|
309
383
|
return readMember(err, "code") === "not_found";
|
|
310
384
|
}
|