@songsid/agend 2.4.0-beta.26 → 2.4.0-beta.28
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/dist/agent-cli-instructions.md +2 -1
- package/dist/agent-cli.js +6 -0
- package/dist/agent-cli.js.map +1 -1
- package/dist/agent-endpoint.d.ts +1 -0
- package/dist/agent-endpoint.js +5 -0
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/agent-whats-new.js +4 -0
- package/dist/agent-whats-new.js.map +1 -1
- package/dist/backend/kiro-auth-store.d.ts +15 -2
- package/dist/backend/kiro-auth-store.js +64 -0
- package/dist/backend/kiro-auth-store.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/adapters/discord.js +4 -4
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/adapters/telegram.js +3 -3
- package/dist/channel/adapters/telegram.js.map +1 -1
- package/dist/channel/ipc-bridge.d.ts +7 -0
- package/dist/channel/ipc-bridge.js +45 -11
- package/dist/channel/ipc-bridge.js.map +1 -1
- package/dist/channel/mcp-server.js +3 -1
- package/dist/channel/mcp-server.js.map +1 -1
- package/dist/channel/mcp-tools.js +6 -4
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/claude-turn-boundaries.d.ts +15 -0
- package/dist/claude-turn-boundaries.js +88 -0
- package/dist/claude-turn-boundaries.js.map +1 -0
- package/dist/cli.js +35 -2
- package/dist/cli.js.map +1 -1
- package/dist/contact-auth-service.js +3 -0
- package/dist/contact-auth-service.js.map +1 -1
- package/dist/contact-auth-store.d.ts +16 -0
- package/dist/contact-auth-store.js +61 -1
- package/dist/contact-auth-store.js.map +1 -1
- package/dist/daemon.d.ts +76 -4
- package/dist/daemon.js +621 -115
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-outbox.d.ts +145 -7
- package/dist/delivery-outbox.js +373 -8
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/detached-fleet-stop.d.ts +40 -0
- package/dist/detached-fleet-stop.js +126 -0
- package/dist/detached-fleet-stop.js.map +1 -0
- package/dist/fleet-lock.d.ts +5 -0
- package/dist/fleet-lock.js +21 -2
- package/dist/fleet-lock.js.map +1 -1
- package/dist/fleet-manager.d.ts +499 -5
- package/dist/fleet-manager.js +2917 -217
- package/dist/fleet-manager.js.map +1 -1
- package/dist/fleet-windows-runtime.d.ts +39 -3
- package/dist/fleet-windows-runtime.js +208 -30
- package/dist/fleet-windows-runtime.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +5 -0
- package/dist/general-knowledge/skills/hub/SKILL.md +5 -1
- package/dist/general-knowledge/skills/task-board/SKILL.md +14 -0
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +96 -26
- package/dist/hub/admin-dashboard.js +1 -1
- package/dist/hub/admin-dashboard.js.map +1 -1
- package/dist/hub/agent-catalog.d.ts +1 -1
- package/dist/hub/agent-catalog.js +4 -3
- package/dist/hub/agent-catalog.js.map +1 -1
- package/dist/hub/agent-intro.d.ts +1 -1
- package/dist/hub/agent-intro.js +1 -1
- package/dist/hub/agent-intro.js.map +1 -1
- package/dist/hub/agent-pictures.d.ts +1 -1
- package/dist/hub/agent-pictures.js +4 -3
- package/dist/hub/agent-pictures.js.map +1 -1
- package/dist/hub/catalog.d.ts +2 -2
- package/dist/hub/catalog.js +16 -13
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/client.js +9 -2
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.js +8 -1
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.js +4 -2
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/fleet-updates.d.ts +2 -2
- package/dist/hub/fleet-updates.js +7 -5
- package/dist/hub/fleet-updates.js.map +1 -1
- package/dist/hub/fleet-versions.d.ts +1 -1
- package/dist/hub/fleet-versions.js +3 -2
- package/dist/hub/fleet-versions.js.map +1 -1
- package/dist/hub/http/compose.js +57 -30
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/schema.js +4 -1
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/join/service.d.ts +6 -0
- package/dist/hub/join/service.js +10 -0
- package/dist/hub/join/service.js.map +1 -1
- package/dist/hub/member/room-ask.js +2 -0
- package/dist/hub/member/room-ask.js.map +1 -1
- package/dist/hub/member/room-post.d.ts +4 -0
- package/dist/hub/member/room-post.js +26 -1
- package/dist/hub/member/room-post.js.map +1 -1
- package/dist/hub/protocol.d.ts +58 -0
- package/dist/hub/protocol.js +3 -2
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/quota.d.ts +2 -2
- package/dist/hub/quota.js +6 -4
- package/dist/hub/quota.js.map +1 -1
- package/dist/hub/read-statement.d.ts +6 -0
- package/dist/hub/read-statement.js +33 -0
- package/dist/hub/read-statement.js.map +1 -0
- package/dist/hub/recommendations.d.ts +1 -1
- package/dist/hub/recommendations.js +3 -2
- package/dist/hub/recommendations.js.map +1 -1
- package/dist/hub/representative.d.ts +2 -0
- package/dist/hub/representative.js +8 -4
- package/dist/hub/representative.js.map +1 -1
- package/dist/hub/roles/clock.d.ts +1 -1
- package/dist/hub/roles/clock.js +9 -7
- package/dist/hub/roles/clock.js.map +1 -1
- package/dist/hub/roles/read.d.ts +4 -0
- package/dist/hub/roles/read.js +37 -7
- package/dist/hub/roles/read.js.map +1 -1
- package/dist/hub/room-history-model.d.ts +87 -0
- package/dist/hub/room-history-model.js +14 -0
- package/dist/hub/room-history-model.js.map +1 -0
- package/dist/hub/rooms/agents.d.ts +1 -1
- package/dist/hub/rooms/agents.js +3 -2
- package/dist/hub/rooms/agents.js.map +1 -1
- package/dist/hub/rooms/history.d.ts +8 -0
- package/dist/hub/rooms/history.js +31 -0
- package/dist/hub/rooms/history.js.map +1 -0
- package/dist/hub/rooms/schema.d.ts +2 -0
- package/dist/hub/rooms/schema.js +4 -0
- package/dist/hub/rooms/schema.js.map +1 -1
- package/dist/hub/rooms/service.d.ts +35 -19
- package/dist/hub/rooms/service.js +105 -26
- package/dist/hub/rooms/service.js.map +1 -1
- package/dist/hub/server.js +10 -3
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/session-epoch.js +2 -1
- package/dist/hub/session-epoch.js.map +1 -1
- package/dist/hub/settings-directory-decision.js +14 -7
- package/dist/hub/settings-directory-decision.js.map +1 -1
- package/dist/hub/settings-member-address-decision.js +3 -2
- package/dist/hub/settings-member-address-decision.js.map +1 -1
- package/dist/hub/settings-web-address-decision.js +2 -1
- package/dist/hub/settings-web-address-decision.js.map +1 -1
- package/dist/hub/store.d.ts +5 -0
- package/dist/hub/store.js +28 -5
- package/dist/hub/store.js.map +1 -1
- package/dist/hub/types.d.ts +2 -2
- package/dist/hub-agent-incarnation-record.d.ts +24 -0
- package/dist/hub-agent-incarnation-record.js +46 -0
- package/dist/hub-agent-incarnation-record.js.map +1 -0
- package/dist/human-delivery-receipts.d.ts +16 -4
- package/dist/human-delivery-receipts.js +26 -5
- package/dist/human-delivery-receipts.js.map +1 -1
- package/dist/instance-lifecycle.d.ts +9 -3
- package/dist/instance-lifecycle.js +27 -10
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instructions.d.ts +1 -1
- package/dist/local-pane-endpoint.d.ts +14 -0
- package/dist/local-pane-endpoint.js +32 -0
- package/dist/local-pane-endpoint.js.map +1 -1
- package/dist/locale.js +68 -4
- package/dist/locale.js.map +1 -1
- package/dist/native-agent-admission.js +9 -0
- package/dist/native-agent-admission.js.map +1 -1
- package/dist/native-exec-context.d.ts +11 -0
- package/dist/native-exec-context.js +18 -0
- package/dist/native-exec-context.js.map +1 -0
- package/dist/native-exec-input.d.ts +56 -0
- package/dist/native-exec-input.js +89 -0
- package/dist/native-exec-input.js.map +1 -0
- package/dist/native-mcp.d.ts +9 -1
- package/dist/native-mcp.js +29 -7
- package/dist/native-mcp.js.map +1 -1
- package/dist/native-pane-lifecycle.d.ts +3 -0
- package/dist/native-pane-lifecycle.js +2 -0
- package/dist/native-pane-lifecycle.js.map +1 -1
- package/dist/native-pane-manager.d.ts +18 -0
- package/dist/native-pane-manager.js +85 -8
- package/dist/native-pane-manager.js.map +1 -1
- package/dist/needs-you.d.ts +2 -1
- package/dist/needs-you.js.map +1 -1
- package/dist/outbound-handlers.d.ts +1 -0
- package/dist/outbound-handlers.js +9 -3
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +8 -0
- package/dist/outbound-schemas.js +6 -2
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/public-web-gateway.js +3 -1
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/recover.cjs +1 -0
- package/dist/reply-buttons-controller.d.ts +1 -0
- package/dist/reply-buttons-controller.js +1 -1
- package/dist/reply-buttons-controller.js.map +1 -1
- package/dist/request-contact-gate.d.ts +2 -0
- package/dist/request-contact-gate.js +8 -3
- package/dist/request-contact-gate.js.map +1 -1
- package/dist/request-context-activation.d.ts +29 -0
- package/dist/request-context-activation.js +85 -0
- package/dist/request-context-activation.js.map +1 -0
- package/dist/request-context-admission.d.ts +22 -0
- package/dist/request-context-admission.js +12 -0
- package/dist/request-context-admission.js.map +1 -0
- package/dist/request-context-boot.d.ts +35 -0
- package/dist/request-context-boot.js +97 -0
- package/dist/request-context-boot.js.map +1 -0
- package/dist/request-context-call.d.ts +3 -0
- package/dist/request-context-call.js.map +1 -1
- package/dist/request-context-compatibility.js +10 -2
- package/dist/request-context-compatibility.js.map +1 -1
- package/dist/request-context-continuation.d.ts +6 -0
- package/dist/request-context-continuation.js +24 -0
- package/dist/request-context-continuation.js.map +1 -0
- package/dist/request-context-control-api.d.ts +119 -0
- package/dist/request-context-control-api.js +179 -0
- package/dist/request-context-control-api.js.map +1 -0
- package/dist/request-context-control-copy.d.ts +3 -0
- package/dist/request-context-control-copy.js +7 -0
- package/dist/request-context-control-copy.js.map +1 -0
- package/dist/request-context-controller.d.ts +44 -0
- package/dist/request-context-controller.js +129 -0
- package/dist/request-context-controller.js.map +1 -0
- package/dist/request-context-delivery-resolver.d.ts +13 -0
- package/dist/request-context-delivery-resolver.js +30 -0
- package/dist/request-context-delivery-resolver.js.map +1 -0
- package/dist/request-context-drain-projection.d.ts +8 -0
- package/dist/request-context-drain-projection.js +40 -0
- package/dist/request-context-drain-projection.js.map +1 -0
- package/dist/request-context-drain.d.ts +22 -0
- package/dist/request-context-drain.js +139 -7
- package/dist/request-context-drain.js.map +1 -1
- package/dist/request-context-enable-offer.d.ts +13 -0
- package/dist/request-context-enable-offer.js +31 -0
- package/dist/request-context-enable-offer.js.map +1 -0
- package/dist/request-context-exec-owner.d.ts +39 -0
- package/dist/request-context-exec-owner.js +128 -0
- package/dist/request-context-exec-owner.js.map +1 -0
- package/dist/request-context-go-back-view.d.ts +1 -0
- package/dist/request-context-go-back-view.js +17 -0
- package/dist/request-context-go-back-view.js.map +1 -0
- package/dist/request-context-helper-readiness.d.ts +14 -0
- package/dist/request-context-helper-readiness.js +23 -0
- package/dist/request-context-helper-readiness.js.map +1 -0
- package/dist/request-context-helper.d.ts +20 -0
- package/dist/request-context-helper.js +41 -0
- package/dist/request-context-helper.js.map +1 -0
- package/dist/request-context-hub-resolver.d.ts +29 -0
- package/dist/request-context-hub-resolver.js +90 -0
- package/dist/request-context-hub-resolver.js.map +1 -0
- package/dist/request-context-human-resolver.d.ts +20 -0
- package/dist/request-context-human-resolver.js +77 -0
- package/dist/request-context-human-resolver.js.map +1 -0
- package/dist/request-context-human.d.ts +112 -0
- package/dist/request-context-human.js +176 -0
- package/dist/request-context-human.js.map +1 -0
- package/dist/request-context-inputs.d.ts +21 -0
- package/dist/request-context-inputs.js +63 -0
- package/dist/request-context-inputs.js.map +1 -0
- package/dist/request-context-installation.d.ts +117 -0
- package/dist/request-context-installation.js +328 -0
- package/dist/request-context-installation.js.map +1 -0
- package/dist/request-context-knowledge.d.ts +5 -0
- package/dist/request-context-knowledge.js +32 -0
- package/dist/request-context-knowledge.js.map +1 -0
- package/dist/request-context-migration.d.ts +11 -0
- package/dist/request-context-migration.js +16 -3
- package/dist/request-context-migration.js.map +1 -1
- package/dist/request-context-native-human.d.ts +20 -0
- package/dist/request-context-native-human.js +91 -0
- package/dist/request-context-native-human.js.map +1 -0
- package/dist/request-context-native-output.d.ts +15 -0
- package/dist/request-context-native-output.js +46 -0
- package/dist/request-context-native-output.js.map +1 -0
- package/dist/request-context-native-result.d.ts +15 -0
- package/dist/request-context-native-result.js +46 -0
- package/dist/request-context-native-result.js.map +1 -0
- package/dist/request-context-off.d.ts +22 -0
- package/dist/request-context-off.js +77 -0
- package/dist/request-context-off.js.map +1 -0
- package/dist/request-context-outside-label.d.ts +5 -0
- package/dist/request-context-outside-label.js +28 -0
- package/dist/request-context-outside-label.js.map +1 -0
- package/dist/request-context-pane.d.ts +8 -0
- package/dist/request-context-pane.js +19 -0
- package/dist/request-context-pane.js.map +1 -1
- package/dist/request-context-pending-work.d.ts +11 -0
- package/dist/request-context-pending-work.js +43 -0
- package/dist/request-context-pending-work.js.map +1 -0
- package/dist/request-context-policy.d.ts +17 -1
- package/dist/request-context-policy.js +84 -6
- package/dist/request-context-policy.js.map +1 -1
- package/dist/request-context-readiness.d.ts +49 -0
- package/dist/request-context-readiness.js +64 -0
- package/dist/request-context-readiness.js.map +1 -0
- package/dist/request-context-recovery.d.ts +6 -2
- package/dist/request-context-recovery.js +25 -0
- package/dist/request-context-recovery.js.map +1 -1
- package/dist/request-context-relay.d.ts +2 -2
- package/dist/request-context-relay.js +10 -10
- package/dist/request-context-relay.js.map +1 -1
- package/dist/request-context-reply-pending.d.ts +16 -0
- package/dist/request-context-reply-pending.js +77 -0
- package/dist/request-context-reply-pending.js.map +1 -0
- package/dist/request-context-resolution.d.ts +35 -0
- package/dist/request-context-resolution.js +86 -0
- package/dist/request-context-resolution.js.map +1 -0
- package/dist/request-context-retirement.d.ts +21 -0
- package/dist/request-context-retirement.js +16 -0
- package/dist/request-context-retirement.js.map +1 -0
- package/dist/request-context-start.d.ts +15 -0
- package/dist/request-context-start.js +2 -0
- package/dist/request-context-start.js.map +1 -0
- package/dist/request-context-turns.d.ts +1 -1
- package/dist/request-context-turns.js +3 -2
- package/dist/request-context-turns.js.map +1 -1
- package/dist/request-context-unproved-label.d.ts +4 -0
- package/dist/request-context-unproved-label.js +25 -0
- package/dist/request-context-unproved-label.js.map +1 -0
- package/dist/request-context-update-guard.d.ts +15 -0
- package/dist/request-context-update-guard.js +54 -0
- package/dist/request-context-update-guard.js.map +1 -0
- package/dist/request-context-work.d.ts +50 -0
- package/dist/request-context-work.js +178 -0
- package/dist/request-context-work.js.map +1 -0
- package/dist/request-hub-context.d.ts +1 -0
- package/dist/request-hub-output.d.ts +2 -0
- package/dist/request-hub-output.js +12 -0
- package/dist/request-hub-output.js.map +1 -1
- package/dist/retained-human-control.d.ts +11 -0
- package/dist/retained-human-control.js +11 -0
- package/dist/retained-human-control.js.map +1 -0
- package/dist/runtime-build-info.js +1 -1
- package/dist/runtime-build-info.js.map +1 -1
- package/dist/runtime-cli.js +1 -1
- package/dist/runtime-cli.js.map +1 -1
- package/dist/runtime-client-store.js +7 -1
- package/dist/runtime-client-store.js.map +1 -1
- package/dist/runtime-client.js +15 -3
- package/dist/runtime-client.js.map +1 -1
- package/dist/runtime-coordinator.d.ts +23 -0
- package/dist/runtime-coordinator.js +103 -4
- package/dist/runtime-coordinator.js.map +1 -1
- package/dist/runtime-pane-mcp.d.ts +9 -0
- package/dist/runtime-pane-mcp.js +22 -2
- package/dist/runtime-pane-mcp.js.map +1 -1
- package/dist/runtime-protocol.d.ts +2 -0
- package/dist/runtime-protocol.js.map +1 -1
- package/dist/runtime-update-controller.js +1 -1
- package/dist/runtime-update-controller.js.map +1 -1
- package/dist/runtime-windows-bridge.d.ts +8 -0
- package/dist/runtime-windows-bridge.js +50 -3
- package/dist/runtime-windows-bridge.js.map +1 -1
- package/dist/scheduler/db.js +9 -0
- package/dist/scheduler/db.js.map +1 -1
- package/dist/scheduler/task-board-text.d.ts +3 -6
- package/dist/scheduler/task-board-text.js +15 -10
- package/dist/scheduler/task-board-text.js.map +1 -1
- package/dist/scheduler/task-board-unread.d.ts +90 -0
- package/dist/scheduler/task-board-unread.js +192 -0
- package/dist/scheduler/task-board-unread.js.map +1 -0
- package/dist/scheduler/task-board.d.ts +324 -6
- package/dist/scheduler/task-board.js +786 -47
- package/dist/scheduler/task-board.js.map +1 -1
- package/dist/service-install-handover.d.ts +52 -0
- package/dist/service-install-handover.js +50 -0
- package/dist/service-install-handover.js.map +1 -0
- package/dist/service-installer.d.ts +12 -0
- package/dist/service-installer.js +24 -10
- package/dist/service-installer.js.map +1 -1
- package/dist/settings-api.d.ts +2 -0
- package/dist/settings-api.js +4 -0
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-baseline.d.ts +1 -0
- package/dist/settings-baseline.js +5 -4
- package/dist/settings-baseline.js.map +1 -1
- package/dist/settings-confirmation.d.ts +2 -0
- package/dist/settings-confirmation.js +6 -0
- package/dist/settings-confirmation.js.map +1 -1
- package/dist/settings-effect.d.ts +2 -0
- package/dist/settings-effect.js +59 -1
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.d.ts +3 -0
- package/dist/settings-http-confirmation.js +29 -0
- package/dist/settings-http-confirmation.js.map +1 -1
- package/dist/settings-route-lifetime.d.ts +3 -1
- package/dist/settings-route-lifetime.js +15 -5
- package/dist/settings-route-lifetime.js.map +1 -1
- package/dist/settings-transaction.d.ts +3 -2
- package/dist/settings-transaction.js.map +1 -1
- package/dist/task-board-tool.js +24 -3
- package/dist/task-board-tool.js.map +1 -1
- package/dist/task-board-waker.d.ts +53 -2
- package/dist/task-board-waker.js +183 -12
- package/dist/task-board-waker.js.map +1 -1
- package/dist/tips.js +1 -1
- package/dist/tips.js.map +1 -1
- package/dist/tool-permissions.js +3 -3
- package/dist/tool-permissions.js.map +1 -1
- package/dist/tool-receipt-output.d.ts +6 -6
- package/dist/transcript-monitor.d.ts +6 -1
- package/dist/transcript-monitor.js +59 -4
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/transcript-turns.d.ts +3 -0
- package/dist/transcript-turns.js +5 -0
- package/dist/transcript-turns.js.map +1 -1
- package/dist/turn-reply-guard.d.ts +16 -1
- package/dist/turn-reply-guard.js +20 -2
- package/dist/turn-reply-guard.js.map +1 -1
- package/dist/ui/app.html +2 -2
- package/dist/ui/contact-auth-strings.js +6 -6
- package/dist/ui/contact-authorizations.js +19 -1
- package/dist/ui/contact-grant-editor.js +71 -11
- package/dist/ui/contact-needs.js +27 -8
- package/dist/ui/contact-permissions.js +25 -8
- package/dist/ui/contact-tool-groups.js +1 -1
- package/dist/ui/fleet-task-activity.js +164 -24
- package/dist/ui/fleet-task-card.js +77 -13
- package/dist/ui/fleet-task-common.js +14 -0
- package/dist/ui/fleet-task-flow.js +353 -0
- package/dist/ui/fleet-task-md.js +1 -1
- package/dist/ui/fleet-task-run.js +98 -22
- package/dist/ui/fleet-task-thread.js +245 -0
- package/dist/ui/fleet-task-unread.js +100 -0
- package/dist/ui/fleet-task-view.js +6 -5
- package/dist/ui/fleet-task-wake.js +140 -0
- package/dist/ui/fleet-tasks.js +13 -6
- package/dist/ui/hub-client.js +3 -0
- package/dist/ui/hub-room-members.js +4 -2
- package/dist/ui/hub-room-settings-strings.js +8 -0
- package/dist/ui/hub-room-settings.js +32 -0
- package/dist/ui/hub-room-thread.js +7 -1
- package/dist/ui/icons/hub-apple-touch-icon.png +0 -0
- package/dist/ui/icons/hub-favicon.ico +0 -0
- package/dist/ui/icons/hub-favicon.svg +10 -0
- package/dist/ui/icons/hub-icon-192.png +0 -0
- package/dist/ui/icons/hub-icon-512.png +0 -0
- package/dist/ui/icons/hub-icon-maskable-192.png +0 -0
- package/dist/ui/icons/hub-icon-maskable-512.png +0 -0
- package/dist/ui/icons/hub-maskable.svg +12 -0
- package/dist/ui/panel-hub.js +14 -3
- package/dist/ui/panel-needs.js +2 -1
- package/dist/ui/panel-settings.js +2 -1
- package/dist/ui/panel-windows-cli.js +2 -2
- package/dist/ui/request-contact-card.js +287 -0
- package/dist/ui/request-contact-client.js +83 -0
- package/dist/ui/request-contact-page.js +78 -0
- package/dist/ui/request-context-control.js +209 -0
- package/dist/ui/settings-registry.js +2 -0
- package/dist/ui/settings-update.js +3 -2
- package/dist/ui/shared/access-overview.css +1 -1
- package/dist/ui/shared/app-i18n.js +2 -2
- package/dist/ui/shared/app-install.js +2 -2
- package/dist/ui/shared/app-shell.js +17 -4
- package/dist/ui/shared/app-stream.js +4 -1
- package/dist/ui/shared/app-update.js +2 -1
- package/dist/ui/shared/app.css +101 -10
- package/dist/ui/shared/app.js +19 -2
- package/dist/ui/shared/task-board.css +164 -0
- package/dist/ui/shared/ui-icons.js +3 -0
- package/dist/ui/shared/ui-states.js +6 -0
- package/dist/ui/shared/update-card-ui.js +178 -11
- package/dist/ui/shared/view-strings.js +18 -0
- package/dist/ui/shared/web-authorize.js +1 -1
- package/dist/ui/task-unread.js +70 -0
- package/dist/ui/windows-cli-catalog.js +33 -6
- package/dist/update-card.d.ts +1 -1
- package/dist/update-card.js +7 -7
- package/dist/update-card.js.map +1 -1
- package/dist/update-fix.d.ts +66 -0
- package/dist/update-fix.js +67 -0
- package/dist/update-fix.js.map +1 -0
- package/dist/update-goback.js +15 -3
- package/dist/update-goback.js.map +1 -1
- package/dist/update-readiness.d.ts +2 -0
- package/dist/update-readiness.js +5 -1
- package/dist/update-readiness.js.map +1 -1
- package/dist/update-snapshot-scope.js +1 -0
- package/dist/update-snapshot-scope.js.map +1 -1
- package/dist/usage/i18n-keys.d.ts +1 -1
- package/dist/usage/i18n-keys.js +9 -0
- package/dist/usage/i18n-keys.js.map +1 -1
- package/dist/usage/providers.d.ts +3 -11
- package/dist/usage/providers.js +93 -131
- package/dist/usage/providers.js.map +1 -1
- package/dist/web-api.d.ts +49 -1
- package/dist/web-api.js +234 -13
- package/dist/web-api.js.map +1 -1
- package/dist/web-chat-history.d.ts +2 -0
- package/dist/web-chat-history.js.map +1 -1
- package/dist/web-icons.d.ts +9 -3
- package/dist/web-icons.js +62 -5
- package/dist/web-icons.js.map +1 -1
- package/dist/web-update.d.ts +9 -0
- package/dist/windows-agents.d.ts +24 -2
- package/dist/windows-agents.js +110 -4
- package/dist/windows-agents.js.map +1 -1
- package/dist/windows-cli-api.js +4 -2
- package/dist/windows-cli-api.js.map +1 -1
- package/dist/windows-cli-worker.js +9 -1
- package/dist/windows-cli-worker.js.map +1 -1
- package/dist/windows-cli.d.ts +55 -1
- package/dist/windows-cli.js +147 -17
- package/dist/windows-cli.js.map +1 -1
- package/dist/windows-shortcuts.d.ts +3 -22
- package/dist/windows-shortcuts.js +5 -45
- package/dist/windows-shortcuts.js.map +1 -1
- package/dist/workflow-templates/default.md +3 -2
- package/dist/wsl-host.d.ts +52 -0
- package/dist/wsl-host.js +97 -0
- package/dist/wsl-host.js.map +1 -0
- package/package.json +1 -1
package/dist/daemon.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { RequestContextPendingReplies } from "./request-context-reply-pending.js";
|
|
2
|
+
import { expandCompositeCall as expandReplyWaitCall } from "./channel/mcp-tools.js";
|
|
3
|
+
import { RequestContextHelperAdmission } from "./request-context-helper.js";
|
|
4
|
+
import { requestContextDigest } from "./request-context-store.js";
|
|
5
|
+
import { RequestContextPendingWork } from "./request-context-pending-work.js";
|
|
6
|
+
import { requestContextProcessGroupGone } from "./request-context-retirement.js";
|
|
1
7
|
import { ReplyDraft } from "./reply-draft.js";
|
|
2
|
-
import { requireRequestContextPolicy } from "./request-context-policy.js";
|
|
8
|
+
import { requireRequestContextPolicy, requestContextInstructionMode } from "./request-context-policy.js";
|
|
3
9
|
import { RequestContextReferenceMap } from "./request-context-fence.js";
|
|
4
10
|
import { managedClaudeBinding } from "./claude-credential-launch.js";
|
|
5
11
|
import { HUB_REPORT_TARGET } from "./hub-report-target.js";
|
|
@@ -74,7 +80,7 @@ import { PaneWriteLock } from "./pane-write-lock.js";
|
|
|
74
80
|
import { answerRemoteCard } from "./remote-card-answer.js";
|
|
75
81
|
import { tmuxPaneHost } from "./tmux-pane-host.js";
|
|
76
82
|
import { buildFleetInstructions, INBOUND_HEADER_RULE } from "./instructions.js";
|
|
77
|
-
import { formatHumanInboundMessage, prepareDeliveryWire, steerInboundEnvelope,
|
|
83
|
+
import { formatHumanInboundMessage, prepareDeliveryWire, steerInboundEnvelope, btwInboundEnvelope, humanBodyHash, humanOwnerObjectId } from "./human-delivery-receipts.js";
|
|
78
84
|
import { formatCrossInstanceInboundMessage, renderCrossInstanceHandoffMetadata, } from "./cross-instance-envelope.js";
|
|
79
85
|
import { agendMessageInInput, bottomRowIsReady, inputAreaText, inputShowsPastedText, pastedTextSignature, pasteLeftInInput, strandedAgendMessageInInput } from "./pane-input-residue.js";
|
|
80
86
|
import { TurnReplyGuard, formatReplyDropDetection, turnExpectsPersonReply } from "./turn-reply-guard.js";
|
|
@@ -124,7 +130,7 @@ const WEB_THEME_IPC = Object.freeze({
|
|
|
124
130
|
});
|
|
125
131
|
/** The largest picture any slot may take (a card slot's ceiling; the fleet checks the limit in force): read no more. */
|
|
126
132
|
const WEB_THEME_ASSET_MAX_BYTES = ASSET_UPLOAD_MAX_BYTES;
|
|
127
|
-
const CROSS_INSTANCE_TOOLS = new Set(["hub_set_intro", "hub_room_status", "hub_room_list", "hub_room_post", "hub_room_members", "hub_people_search", "send_to_instance", "broadcast", "list_instances", "start_instance", "restart_instance", "create_instance", "delete_instance", "replace_instance", "request_information", "delegate_task", "report_result", "delivery_status", "describe_instance"]);
|
|
133
|
+
const CROSS_INSTANCE_TOOLS = new Set(["hub_set_intro", "hub_room_status", "hub_room_list", "hub_room_post", "hub_room_history", "hub_room_members", "hub_people_search", "send_to_instance", "broadcast", "list_instances", "start_instance", "restart_instance", "create_instance", "delete_instance", "replace_instance", "request_information", "delegate_task", "report_result", "delivery_status", "describe_instance"]);
|
|
128
134
|
const SCHEDULE_TOOLS = new Set(["create_schedule", "list_schedules", "update_schedule", "delete_schedule"]);
|
|
129
135
|
const DECISION_TOOLS = new Set(["post_decision", "list_decisions", "update_decision"]);
|
|
130
136
|
const TASK_TOOL = "task";
|
|
@@ -1241,6 +1247,14 @@ export class Daemon extends EventEmitter {
|
|
|
1241
1247
|
}
|
|
1242
1248
|
guardian = null;
|
|
1243
1249
|
adapter = null;
|
|
1250
|
+
requestContextAdmission;
|
|
1251
|
+
/** Input fencing may attach to a legacy owner; it does not bind C or reinterpret an existing turn. */
|
|
1252
|
+
setRequestContextAdmission(port) {
|
|
1253
|
+
if (this.requestContextAdmission && this.requestContextAdmission !== port)
|
|
1254
|
+
throw Error("Request-context admission owner differs");
|
|
1255
|
+
this.requestContextAdmission = port;
|
|
1256
|
+
}
|
|
1257
|
+
requestContextPendingWork = new RequestContextPendingWork();
|
|
1244
1258
|
pendingIpcRequests = new Map();
|
|
1245
1259
|
/**
|
|
1246
1260
|
* Daemon-global request sequence. MCP request ids are only process-local:
|
|
@@ -2258,6 +2272,7 @@ export class Daemon extends EventEmitter {
|
|
|
2258
2272
|
guardGeneration: turn?.generation ?? null, guardPhase: turn?.phase ?? null }, "Native pane tool operation failed");
|
|
2259
2273
|
}
|
|
2260
2274
|
nativePaneCurrent() { return this.nativePaneLifecycle?.current() ?? false; }
|
|
2275
|
+
nativePaneRequestContextTransportCurrent() { return this.nativePaneLifecycle?.requestContextTransportCurrent?.() === true; }
|
|
2261
2276
|
nativeEnterHold = null;
|
|
2262
2277
|
/** Per-launch attention for a native delivery whose bounded input attempts were refused or uncertain, including non-outbox input. */
|
|
2263
2278
|
nativeDeliveryHold() {
|
|
@@ -2376,6 +2391,11 @@ export class Daemon extends EventEmitter {
|
|
|
2376
2391
|
bindRequestContextPolicy(policy) { if (this.requestContextPolicy || !this.requestContextLifecycle)
|
|
2377
2392
|
throw Error("request-context policy requires its owned turn binding"); this.requestContextPolicy = policy; }
|
|
2378
2393
|
requestContextCalls = new RequestContextReferenceMap(call => call.admission.coverage === "covered" ? call.admission.lease.snapshot.context.ref.rootContextId : null, call => `local-call:${call.id}`);
|
|
2394
|
+
requestContextQueuedWork = new RequestContextReferenceMap(row => row.root, (_row, id) => `queued-recovery:${id}`);
|
|
2395
|
+
get requestContextQueuedWorkDrainRevision() { return this.requestContextQueuedWork.revision; }
|
|
2396
|
+
requestContextQueuedWorkDrainView(rootId) { return this.requestContextQueuedWork.view(rootId); }
|
|
2397
|
+
requestContextPendingReplies = new RequestContextPendingReplies();
|
|
2398
|
+
requestContextHumanReplies = new Map();
|
|
2379
2399
|
requestContextInterruptedLaunch;
|
|
2380
2400
|
requestContextLaunch() { return JSON.stringify([this.bootId, this.spawnGeneration, this.nativePaneLifecycle?.snapshot?.()?.launchId ?? null]); }
|
|
2381
2401
|
/** First local owned hop only. No lookup at a later Fleet receipt may retag this call. */
|
|
@@ -2390,12 +2410,46 @@ export class Daemon extends EventEmitter {
|
|
|
2390
2410
|
const admission = snapshot && reason !== "interrupted-launch"
|
|
2391
2411
|
? { coverage: "covered", lease: captureRequestContextCall(snapshot, captured => this.requestContextTurnCurrent(captured)) }
|
|
2392
2412
|
: { coverage: "not-covered", reason };
|
|
2413
|
+
const reply = this.requestContextCapturedReply(admission);
|
|
2393
2414
|
const call = Object.freeze({ id: randomUUID(), admission: Object.freeze(admission),
|
|
2394
|
-
|
|
2415
|
+
get replyRoute() { return reply.route(); }, waitForReplyRoute: reply.wait,
|
|
2416
|
+
current: () => reply.current() && !this.deliveryWritesStopping && this.requestContextLaunch() === launch
|
|
2395
2417
|
&& (admission.coverage !== "covered" || admission.lease.current()) });
|
|
2396
2418
|
this.requestContextCalls.set(call.id, call);
|
|
2397
2419
|
return call;
|
|
2398
2420
|
}
|
|
2421
|
+
/** Capture the scheduling record now; waiting never looks up a newer input. */
|
|
2422
|
+
requestContextCapturedReply(admission) {
|
|
2423
|
+
const snapshot = admission.coverage === "covered" ? admission.lease.snapshot : null;
|
|
2424
|
+
let deadline = Infinity;
|
|
2425
|
+
let route = snapshot ? this.captureRequestContextReplyRoute(snapshot) : undefined;
|
|
2426
|
+
const pending = snapshot && !route ? this.requestContextPendingReplies.capture(snapshot) : undefined;
|
|
2427
|
+
return { route: () => route, current: () => performance.now() < deadline, wait: pending ? async (budgetMs) => {
|
|
2428
|
+
deadline = Math.min(deadline, performance.now() + budgetMs);
|
|
2429
|
+
const confirmed = await pending.wait(budgetMs);
|
|
2430
|
+
if (confirmed && snapshot && performance.now() < deadline && admission.coverage === "covered" && admission.lease.current()) {
|
|
2431
|
+
const checked = this.captureRequestContextReplyRoute(snapshot);
|
|
2432
|
+
if (checked && checked.generation === confirmed.generation && requestContextDigest(checked.target) === requestContextDigest(confirmed.target))
|
|
2433
|
+
route = Object.freeze({ ...checked, current: () => performance.now() < deadline && checked.current() });
|
|
2434
|
+
}
|
|
2435
|
+
} : undefined };
|
|
2436
|
+
}
|
|
2437
|
+
/** Bind the original call to a delivered target, with the original human admission rechecked at commit. */
|
|
2438
|
+
captureRequestContextReplyRoute(snapshot) {
|
|
2439
|
+
const route = this.turnReplyGuard?.captureReplyRoute(snapshot.token);
|
|
2440
|
+
if (!route)
|
|
2441
|
+
return;
|
|
2442
|
+
const current = () => {
|
|
2443
|
+
try {
|
|
2444
|
+
return route.current() && this.requestContextTurnCurrent(snapshot)
|
|
2445
|
+
&& requestContextDigest(this.requestContextLifecycle?.replyTarget?.(snapshot)) === requestContextDigest(route.target);
|
|
2446
|
+
}
|
|
2447
|
+
catch {
|
|
2448
|
+
return false;
|
|
2449
|
+
}
|
|
2450
|
+
};
|
|
2451
|
+
return current() ? Object.freeze({ ...route, current }) : undefined;
|
|
2452
|
+
}
|
|
2399
2453
|
/** Internal Fleet accessor, paired with the current daemon/IPC connection; returns original scope or nothing. */
|
|
2400
2454
|
requestContextCall(callId) {
|
|
2401
2455
|
const call = this.requestContextCalls.get(callId);
|
|
@@ -2404,8 +2458,21 @@ export class Daemon extends EventEmitter {
|
|
|
2404
2458
|
requestContextCallsRequired() { return this.requestContextLifecycle !== undefined; }
|
|
2405
2459
|
get requestContextCallDrainRevision() { return this.requestContextCalls.revision; }
|
|
2406
2460
|
requestContextCallDrainView(rootId) { return this.requestContextCalls.view(rootId); }
|
|
2407
|
-
requestContextTurnDrainView(rootId) {
|
|
2408
|
-
|
|
2461
|
+
requestContextTurnDrainView(rootId) {
|
|
2462
|
+
const view = this.requestContextLifecycle?.turns.drainView(rootId);
|
|
2463
|
+
if (!view)
|
|
2464
|
+
return null;
|
|
2465
|
+
const write = this.requestContextWrite;
|
|
2466
|
+
return { ...view, revision: this.requestContextTurnDrainRevision, references: [...view.references,
|
|
2467
|
+
...(write?.unknownEnd && write.snapshot.context.ref.rootContextId === rootId
|
|
2468
|
+
? [`unknown-end:${this.name}:${write.unknownEnd}`] : [])] };
|
|
2469
|
+
}
|
|
2470
|
+
get requestContextTurnDrainRevision() {
|
|
2471
|
+
return JSON.stringify([
|
|
2472
|
+
this.requestContextLifecycle?.turns.drainRevision ?? "unavailable",
|
|
2473
|
+
this.requestContextWrite?.unknownEnd ?? null
|
|
2474
|
+
]);
|
|
2475
|
+
}
|
|
2409
2476
|
handleOwnedToolCall(message, socket) {
|
|
2410
2477
|
let call;
|
|
2411
2478
|
try {
|
|
@@ -2418,17 +2485,193 @@ export class Daemon extends EventEmitter {
|
|
|
2418
2485
|
this.ipcServer?.send(socket, { requestId: message.requestId, result: null, error: "Request context call admission is unavailable" });
|
|
2419
2486
|
}
|
|
2420
2487
|
}
|
|
2421
|
-
|
|
2488
|
+
/** New replacement only; an old launch never acquires C by reseeding its counters. */
|
|
2489
|
+
seedRequestContextReplacement(previous) {
|
|
2490
|
+
if (this.tmux || this.ipcServer || this.nativePaneLifecycle || this.requestContextLifecycle
|
|
2491
|
+
|| ![previous.spawnGeneration, previous.launchFenceEpoch].every(n => Number.isSafeInteger(n) && n >= 0 && n < Number.MAX_SAFE_INTEGER)) {
|
|
2492
|
+
throw Error("Request-context replacement must be prepared before startup");
|
|
2493
|
+
}
|
|
2494
|
+
this.spawnGeneration = previous.spawnGeneration + 1;
|
|
2495
|
+
this.launchFenceEpoch = previous.launchFenceEpoch + 1;
|
|
2496
|
+
}
|
|
2497
|
+
/** Read-only first-On inventory. Idle alone is never a legacy-work drain proof. */
|
|
2498
|
+
requestContextLaunchObservation() {
|
|
2499
|
+
return Object.freeze({ daemonBootId: this.bootId, spawnGeneration: this.spawnGeneration,
|
|
2500
|
+
launchFenceEpoch: this.launchFenceEpoch, observation: this.getWorkingStateObservation(),
|
|
2501
|
+
pendingCalls: this.requestContextPendingWork.count(this.name), responseWaiters: this.pendingIpcRequests.size,
|
|
2502
|
+
paneWriteBusy: this.paneWriteLock.isBusy, queuedInputs: this.pasteQueueDepth,
|
|
2503
|
+
transcriptOpen: this.transcriptTurns.openSince() !== null,
|
|
2504
|
+
starting: this.spawning, stopping: this.deliveryWritesStopping || this.startupAborted,
|
|
2505
|
+
replacementRequired: !this.requestContextLifecycle || this.requestContextInterruptedLaunch === this.requestContextLaunch() });
|
|
2506
|
+
}
|
|
2507
|
+
requestContextHelper;
|
|
2508
|
+
requestContextStartupResources;
|
|
2509
|
+
/** Candidate-only physical resource receipt, installed before startup. Used even when startup rejects.
|
|
2510
|
+
* No stop result, timeout, removed metadata or empty supervisor map proves retirement.
|
|
2511
|
+
*/
|
|
2512
|
+
prepareRequestContextStartupRetirement() {
|
|
2513
|
+
if (this.tmux || this.ipcServer || this.nativePaneLifecycle || this.requestContextStartupResources)
|
|
2514
|
+
throw Error("Request startup retirement must precede launch");
|
|
2515
|
+
const resources = { pending: 0, unknown: false, windows: [], ipc: new Set(), native: [] };
|
|
2516
|
+
this.requestContextStartupResources = resources;
|
|
2517
|
+
return Object.freeze({ retired: async () => {
|
|
2518
|
+
try {
|
|
2519
|
+
if (this.requestContextStartupResources !== resources || !this.startupAborted && !this.deliveryWritesStopping || this.spawning
|
|
2520
|
+
|| resources.pending || resources.unknown || [...resources.ipc].some(ipc => !ipc.retired()))
|
|
2521
|
+
return false;
|
|
2522
|
+
for (const row of resources.native) {
|
|
2523
|
+
const snapshot = row.owner.snapshot?.();
|
|
2524
|
+
if (!snapshot || snapshot.state !== "exited" || JSON.stringify([snapshot.hostBootId, snapshot.paneId, snapshot.launchId, snapshot.agentId, snapshot.instance]) !== row.identity)
|
|
2525
|
+
return false;
|
|
2526
|
+
}
|
|
2527
|
+
for (const row of resources.windows) {
|
|
2528
|
+
const windows = await TmuxManager.listWindowsStrict(row.session);
|
|
2529
|
+
if (resources.pending || resources.unknown || windows.some(window => window.id === row.window) || !requestContextProcessGroupGone(row.pid))
|
|
2530
|
+
return false;
|
|
2531
|
+
}
|
|
2532
|
+
return this.requestContextStartupResources === resources && !resources.pending && !resources.unknown && [...resources.ipc].every(ipc => ipc.retired());
|
|
2533
|
+
}
|
|
2534
|
+
catch {
|
|
2535
|
+
return false;
|
|
2536
|
+
}
|
|
2537
|
+
} });
|
|
2538
|
+
}
|
|
2539
|
+
requestContextHelperReadiness() {
|
|
2540
|
+
if (!this.requestContextLifecycle)
|
|
2541
|
+
return null;
|
|
2542
|
+
if (this.nativePaneLifecycle) {
|
|
2543
|
+
const snapshot = this.nativePaneLifecycle.snapshot?.();
|
|
2544
|
+
if (!snapshot)
|
|
2545
|
+
return null;
|
|
2546
|
+
// Output/sequence changes are observations, not a new admitting launch. Bind the actual owner tuple.
|
|
2547
|
+
return { version: 1, generation: JSON.stringify([this.bootId, this.spawnGeneration, this.launchFenceEpoch, snapshot.hostBootId, snapshot.paneId, snapshot.launchId, snapshot.agentId]),
|
|
2548
|
+
ready: snapshot.state === "running" && this.nativePaneLifecycle.requestContextTransportCurrent?.() === true };
|
|
2549
|
+
}
|
|
2550
|
+
return this.requestContextHelper ? { version: 1, generation: `${this.bootId}:${this.requestContextHelper.revision}`, ready: this.requestContextHelper.ready() } : null;
|
|
2551
|
+
}
|
|
2552
|
+
getRequestContextLaunchSpec() {
|
|
2553
|
+
const kind = this.runtimeIdentity?.kind;
|
|
2554
|
+
if (kind !== "classic" && kind !== "fleet-topic")
|
|
2555
|
+
throw Error("Request launch kind unavailable");
|
|
2556
|
+
return Object.freeze({ config: this.getConfigSnapshot(), topicMode: this.topicMode, kind });
|
|
2557
|
+
}
|
|
2558
|
+
/** First-On uses a real bounded pane read, not the cached idle badge; admission must already be fenced. */
|
|
2559
|
+
async captureRequestContextIdle() {
|
|
2560
|
+
const admission = this.requestContextAdmission;
|
|
2561
|
+
if (!admission || admission.available())
|
|
2562
|
+
return null;
|
|
2563
|
+
// Capture before waiting for the write lock: a replaced/respawned owner cannot inherit this request.
|
|
2564
|
+
const tmux = this.tmux, ipc = this.ipcServer, owner = JSON.stringify(this.interactionOwner());
|
|
2565
|
+
const daemonBootId = this.bootId, spawnGeneration = this.spawnGeneration, launchFenceEpoch = this.launchFenceEpoch, deliveryEpoch = this.deliveryEpoch;
|
|
2566
|
+
const pendingRevision = this.requestContextPendingWork.revision, turn = this.turnReplyGuard.snapshot();
|
|
2567
|
+
return this.paneWriteLock.run(async () => {
|
|
2568
|
+
const stable = () => {
|
|
2569
|
+
const observed = this.requestContextLaunchObservation(), now = this.turnReplyGuard.snapshot();
|
|
2570
|
+
return this.requestContextAdmission === admission && !admission.available()
|
|
2571
|
+
&& this.tmux === tmux && this.ipcServer === ipc && JSON.stringify(this.interactionOwner()) === owner
|
|
2572
|
+
&& this.deliveryEpoch === deliveryEpoch && this.requestContextPendingWork.revision === pendingRevision
|
|
2573
|
+
&& observed.pendingCalls === 0 && observed.responseWaiters === 0 && observed.queuedInputs === 0
|
|
2574
|
+
&& !observed.transcriptOpen && !observed.starting && !observed.stopping && !this.runtimeMonitorsFrozen
|
|
2575
|
+
&& observed.observation.processStatus === "running" && observed.observation.executionState === "idle"
|
|
2576
|
+
&& (!this.backend?.backgroundWorkRunning || observed.observation.backgroundWork !== true)
|
|
2577
|
+
&& now?.generation === turn?.generation
|
|
2578
|
+
&& (!now || now.cancelledByUser || now.completionDelivered);
|
|
2579
|
+
};
|
|
2580
|
+
if (!tmux || !stable())
|
|
2581
|
+
return null;
|
|
2582
|
+
let pane;
|
|
2583
|
+
try {
|
|
2584
|
+
pane = await tmux.capturePane(2000);
|
|
2585
|
+
}
|
|
2586
|
+
catch {
|
|
2587
|
+
return null;
|
|
2588
|
+
}
|
|
2589
|
+
if (!stable() || !this.paneAuthoritativelyIdle(pane) || this.inputTransientInPane(pane)
|
|
2590
|
+
|| this.backend?.backgroundWorkRunning && this.backend.backgroundWorkRunning(pane) !== false)
|
|
2591
|
+
return null;
|
|
2592
|
+
// The owning gate still checks its durable rows and producer revision. A late handler, queue, turn,
|
|
2593
|
+
// IPC replacement or owner change invalidates this proof even if it later looks idle again.
|
|
2594
|
+
return Object.freeze({ daemonBootId, spawnGeneration, launchFenceEpoch, deliveryEpoch,
|
|
2595
|
+
current: () => !this.paneWriteLock.isBusy && stable() });
|
|
2596
|
+
});
|
|
2597
|
+
}
|
|
2598
|
+
/** Capture the exact old resources BEFORE stop removes metadata; this proof never kills or signals anything. */
|
|
2599
|
+
async captureRequestContextRetirement() {
|
|
2600
|
+
const tmux = this.tmux, windowId = tmux?.getWindowId(), native = this.nativePaneLifecycle, ipc = this.ipcServer;
|
|
2601
|
+
const spawnGeneration = this.spawnGeneration, launchFenceEpoch = this.launchFenceEpoch, daemonBootId = this.bootId;
|
|
2602
|
+
if (!tmux || !windowId)
|
|
2603
|
+
throw Error("Owned launch unavailable for retirement");
|
|
2604
|
+
const owned = () => this.bootId === daemonBootId && this.spawnGeneration === spawnGeneration
|
|
2605
|
+
&& this.tmux === tmux && tmux.getWindowId() === windowId && this.nativePaneLifecycle === native
|
|
2606
|
+
&& (this.ipcServer === ipc || this.ipcServer === null && ipc?.retired() === true);
|
|
2607
|
+
const captured = native?.snapshot?.();
|
|
2608
|
+
const panePid = native ? null : await this.paneHost.getPanePid(this.tmuxSessionName, windowId);
|
|
2609
|
+
if (!owned() || !native && (!panePid || !Number.isSafeInteger(panePid) || panePid <= 1)
|
|
2610
|
+
|| native && (!captured || captured.instance !== this.name || captured.paneId !== windowId))
|
|
2611
|
+
throw Error("Owned launch changed during retirement capture");
|
|
2612
|
+
let observedRetired = false;
|
|
2613
|
+
const retiredCurrent = () => {
|
|
2614
|
+
if (!observedRetired || !owned() || ipc && !ipc.retired())
|
|
2615
|
+
return false;
|
|
2616
|
+
if (native) {
|
|
2617
|
+
const now = native.snapshot?.();
|
|
2618
|
+
return !!now && now.state === "exited" && ["hostBootId", "paneId", "launchId", "agentId", "instance"].every(k => now[k] === captured[k]);
|
|
2619
|
+
}
|
|
2620
|
+
return requestContextProcessGroupGone(panePid);
|
|
2621
|
+
};
|
|
2622
|
+
return Object.freeze({ daemonBootId, spawnGeneration, launchFenceEpoch, windowId, panePid, retiredCurrent, retired: async () => {
|
|
2623
|
+
try {
|
|
2624
|
+
if (!owned() || ipc && !ipc.retired())
|
|
2625
|
+
return false;
|
|
2626
|
+
if (native) {
|
|
2627
|
+
const now = native.snapshot?.();
|
|
2628
|
+
const gone = !!now && now.state === "exited" && ["hostBootId", "paneId", "launchId", "agentId", "instance"].every(k => now[k] === captured[k]) && owned();
|
|
2629
|
+
if (gone)
|
|
2630
|
+
observedRetired = true;
|
|
2631
|
+
return gone;
|
|
2632
|
+
}
|
|
2633
|
+
const windows = await TmuxManager.listWindowsStrict(this.tmuxSessionName);
|
|
2634
|
+
const gone = owned() && (!ipc || ipc.retired()) && !windows.some(w => w.id === windowId) && requestContextProcessGroupGone(panePid);
|
|
2635
|
+
if (gone)
|
|
2636
|
+
observedRetired = true;
|
|
2637
|
+
return gone;
|
|
2638
|
+
}
|
|
2639
|
+
catch {
|
|
2640
|
+
return false;
|
|
2641
|
+
}
|
|
2642
|
+
} });
|
|
2643
|
+
}
|
|
2644
|
+
setRequestContextLocalLifecycle(turns, identity, newWork, replyTarget, continuation) {
|
|
2422
2645
|
if (this.tmux || this.ipcServer || this.requestContextLifecycle || this.nativePaneLifecycle && !this.nativePaneLifecycle.requestContextAvailable?.())
|
|
2423
2646
|
throw Error("Request context must be bound before a supported daemon startup");
|
|
2424
2647
|
this.requestContextCalls.installRegistration(turns.registrationGate ?? undefined);
|
|
2425
|
-
this.
|
|
2648
|
+
this.requestContextQueuedWork.installRegistration(turns.registrationGate ?? undefined);
|
|
2649
|
+
this.requestContextHelper = new RequestContextHelperAdmission();
|
|
2650
|
+
this.requestContextLifecycle = { turns, identity, newWork, replyTarget, continuation };
|
|
2651
|
+
}
|
|
2652
|
+
/** Authoritative fresh-launch boundary only; session discovery and a merely written clear command do not prove it. */
|
|
2653
|
+
requestContextNewWork(reason) {
|
|
2654
|
+
const lifecycle = this.requestContextLifecycle;
|
|
2655
|
+
if (!lifecycle?.newWork)
|
|
2656
|
+
return;
|
|
2657
|
+
const owner = this.requestContextOwner(), previous = owner ? lifecycle.turns.current(owner) : null;
|
|
2658
|
+
lifecycle.newWork(reason);
|
|
2659
|
+
if (owner && previous)
|
|
2660
|
+
lifecycle.turns.ended(previous, owner);
|
|
2661
|
+
this.requestContextWrite = undefined;
|
|
2662
|
+
this.requestContextPendingReplies.clear();
|
|
2663
|
+
this.requestContextHumanReplies.clear();
|
|
2426
2664
|
}
|
|
2427
2665
|
requestContextOwner() {
|
|
2428
2666
|
const lifecycle = this.requestContextLifecycle;
|
|
2429
2667
|
return lifecycle ? { ...lifecycle.identity(), instance: this.name, daemonBootId: this.bootId,
|
|
2430
2668
|
spawnGeneration: this.spawnGeneration, launchFenceEpoch: this.launchFenceEpoch, deliveryEpoch: this.deliveryEpoch } : null;
|
|
2431
2669
|
}
|
|
2670
|
+
/** Trusted installer/resolver observation only; no turn token or authority is granted. */
|
|
2671
|
+
captureRequestContextOwner() {
|
|
2672
|
+
const owner = this.requestContextOwner();
|
|
2673
|
+
return owner ? Object.freeze(owner) : null;
|
|
2674
|
+
}
|
|
2432
2675
|
requestContextTurnSnapshot() {
|
|
2433
2676
|
const owner = this.requestContextOwner();
|
|
2434
2677
|
return owner ? this.requestContextLifecycle.turns.current(owner) : null;
|
|
@@ -2464,13 +2707,30 @@ export class Daemon extends EventEmitter {
|
|
|
2464
2707
|
const deliveryId = /^delivery:([^:]+):[0-9]+$/.exec(id)?.[1];
|
|
2465
2708
|
const endAnchor = !!humanId && /^[A-Za-z0-9_-]+$/.test(humanId) && text.split("\n").some(line => line.startsWith(`[hid:${humanId}]`) || line.startsWith(`[agend-human-id:${humanId}]`))
|
|
2466
2709
|
|| !!deliveryId && text.startsWith(`[agend-delivery-id:${deliveryId}]\n`)
|
|
2710
|
+
|| /^hub-input:[a-f0-9-]{36}$/.test(id) && /^\[agend-room-input:hub-room-[a-f0-9-]{36}\]\n/.test(text)
|
|
2467
2711
|
|| /^[A-Za-z0-9:_-]+$/.test(id) && text.startsWith(`[agend-request-input:${id}]\n`);
|
|
2468
2712
|
this.requestContextWrite = { snapshot, text, at: Date.now(), ledger: new TranscriptTurnLedger(), endAnchor };
|
|
2469
2713
|
}
|
|
2470
2714
|
}
|
|
2715
|
+
/** A reset withdraws proof; it never silently retires C or admits the next root. */
|
|
2716
|
+
observeRequestContextTranscript(events) {
|
|
2717
|
+
const write = this.requestContextWrite;
|
|
2718
|
+
if (!write)
|
|
2719
|
+
return;
|
|
2720
|
+
for (const event of events) {
|
|
2721
|
+
if (event.kind !== "retract")
|
|
2722
|
+
continue;
|
|
2723
|
+
// Ask before withdrawing the row. A foreign transcript turn cannot turn
|
|
2724
|
+
// this owned input into an unknown-end blocker.
|
|
2725
|
+
if (write.ledger.matchesInputTurn(event.turnId, write.text, write.at))
|
|
2726
|
+
write.unknownEnd = event.reason ?? "reset";
|
|
2727
|
+
}
|
|
2728
|
+
write.ledger.observe(events, performance.now());
|
|
2729
|
+
this.settleRequestContextFromTranscript();
|
|
2730
|
+
}
|
|
2471
2731
|
settleRequestContextFromTranscript() {
|
|
2472
2732
|
const write = this.requestContextWrite, owner = this.requestContextOwner();
|
|
2473
|
-
if (!write || !write.endAnchor || !owner || !this.requestContextLifecycle.turns.isCurrent(write.snapshot, owner))
|
|
2733
|
+
if (!write || write.unknownEnd || !write.endAnchor || !owner || !this.requestContextLifecycle.turns.isCurrent(write.snapshot, owner))
|
|
2474
2734
|
return;
|
|
2475
2735
|
const verdict = write.ledger.verdict(write.text, write.at);
|
|
2476
2736
|
if (verdict === "ended" || verdict === "aborted" || verdict === "error") {
|
|
@@ -2478,6 +2738,7 @@ export class Daemon extends EventEmitter {
|
|
|
2478
2738
|
this.requestContextInterruptedLaunch = this.requestContextLaunch();
|
|
2479
2739
|
this.requestContextLifecycle.turns.ended(write.snapshot, owner);
|
|
2480
2740
|
this.requestContextWrite = undefined;
|
|
2741
|
+
this.requestContextPendingReplies.clear();
|
|
2481
2742
|
}
|
|
2482
2743
|
}
|
|
2483
2744
|
/** Internal lifecycle injection, before start. Native paths and provider files stay on their runner. */
|
|
@@ -2488,6 +2749,13 @@ export class Daemon extends EventEmitter {
|
|
|
2488
2749
|
this.backend = native.backend;
|
|
2489
2750
|
this.paneTransport = native.host;
|
|
2490
2751
|
this.controlClient = native.observation;
|
|
2752
|
+
if (this.requestContextStartupResources) {
|
|
2753
|
+
const snapshot = native.snapshot?.();
|
|
2754
|
+
if (!snapshot)
|
|
2755
|
+
this.requestContextStartupResources.unknown = true;
|
|
2756
|
+
else
|
|
2757
|
+
this.requestContextStartupResources.native.push({ owner: native, identity: JSON.stringify([snapshot.hostBootId, snapshot.paneId, snapshot.launchId, snapshot.agentId, snapshot.instance]) });
|
|
2758
|
+
}
|
|
2491
2759
|
}
|
|
2492
2760
|
constructor(name, config, instanceDir, topicMode = false, backend, controlClient, rootLogger, runtimeIdentity, spawnGate, stormWindow,
|
|
2493
2761
|
/** Fleet-level "is this CLI's backend down?" memory — see backend-outage.ts. */
|
|
@@ -2623,6 +2891,7 @@ export class Daemon extends EventEmitter {
|
|
|
2623
2891
|
if (this.deliveryWritesStopping)
|
|
2624
2892
|
return;
|
|
2625
2893
|
this.deliveryWritesStopping = true;
|
|
2894
|
+
this.requestContextAdmission?.changed();
|
|
2626
2895
|
this.deliveryEpoch++;
|
|
2627
2896
|
this.replyDraft.reset();
|
|
2628
2897
|
this.requestContextLifecycle?.turns.fence();
|
|
@@ -2713,7 +2982,13 @@ export class Daemon extends EventEmitter {
|
|
|
2713
2982
|
// not — a pre-write failure never gets here; it is retried before begin.
|
|
2714
2983
|
if (outcome !== "failed")
|
|
2715
2984
|
this.noteWorkActivity();
|
|
2716
|
-
this.deliveryOutbox?.complete(delivery.deliveryId, this.bootId, delivery.attemptNo, outcome, evidence);
|
|
2985
|
+
const accepted = this.deliveryOutbox?.complete(delivery.deliveryId, this.bootId, delivery.attemptNo, outcome, evidence);
|
|
2986
|
+
if (verdict?.pendingReply) {
|
|
2987
|
+
if (accepted && outcome === "delivered" && !["unverified", "output-edge", "unverifiable"].includes(verdict.proof ?? ""))
|
|
2988
|
+
verdict.pendingReply.confirm();
|
|
2989
|
+
else
|
|
2990
|
+
verdict.pendingReply.refuse();
|
|
2991
|
+
}
|
|
2717
2992
|
if (verdict && outcome !== "failed")
|
|
2718
2993
|
this.startConsumedWatch(delivery, verdict, outcome);
|
|
2719
2994
|
}
|
|
@@ -3422,6 +3697,14 @@ export class Daemon extends EventEmitter {
|
|
|
3422
3697
|
// 1. IPC server — bridge between MCP server (Claude's child) and daemon
|
|
3423
3698
|
const sockPath = join(this.instanceDir, "channel.sock");
|
|
3424
3699
|
this.ipcServer = new IpcServer(sockPath, this.logger);
|
|
3700
|
+
this.requestContextStartupResources?.ipc.add(this.ipcServer);
|
|
3701
|
+
if (this.requestContextHelper)
|
|
3702
|
+
this.ipcServer.setMessageAdmission((message, socket) => {
|
|
3703
|
+
const admitted = this.requestContextHelper.admit(message, socket);
|
|
3704
|
+
if (!admitted)
|
|
3705
|
+
this.logger.warn({ instance: this.name }, "old_launch_helper_refused");
|
|
3706
|
+
return admitted;
|
|
3707
|
+
});
|
|
3425
3708
|
// Forward IPC server errors as daemon events (prevents unhandled 'error' crash).
|
|
3426
3709
|
// Guard: only forward post-listen errors — startup errors are handled by listen() rejection.
|
|
3427
3710
|
let ipcListening = false;
|
|
@@ -3489,6 +3772,11 @@ export class Daemon extends EventEmitter {
|
|
|
3489
3772
|
// bounded dialog/readiness scan as local startup. An already-running reattachment may be busy: do not
|
|
3490
3773
|
// wait for that work to finish or inject a startup key into it.
|
|
3491
3774
|
if (acquired.disposition === "reattached") {
|
|
3775
|
+
// A surviving process predates this daemon's first-hop binding. Its queued helper bytes
|
|
3776
|
+
// cannot prove a turn, even after a later input installs a new proof on that launch.
|
|
3777
|
+
// Keep the one-contact approval fallback until a genuinely new process is launched.
|
|
3778
|
+
if (this.requestContextLifecycle)
|
|
3779
|
+
this.requestContextInterruptedLaunch = this.requestContextLaunch();
|
|
3492
3780
|
if (this.backend?.binaryName === "codex") {
|
|
3493
3781
|
const native = this.nativePaneLifecycle, spawn = this.spawnGeneration, fence = this.launchFenceEpoch, attempt = this.launchAttempt;
|
|
3494
3782
|
try {
|
|
@@ -3571,6 +3859,8 @@ export class Daemon extends EventEmitter {
|
|
|
3571
3859
|
}
|
|
3572
3860
|
if (nativeDisposition)
|
|
3573
3861
|
this.isNewSession = nativeDisposition === "fresh";
|
|
3862
|
+
if (nativeDisposition === "fresh")
|
|
3863
|
+
this.requestContextNewWork("fresh");
|
|
3574
3864
|
this.resetRoomConversation(nativeDisposition === "reattached");
|
|
3575
3865
|
this.settleHubAnswerTurnAtLaunch(nativeDisposition === "reattached");
|
|
3576
3866
|
// #1209: conditional continuation for the turn interrupted by the last
|
|
@@ -6098,6 +6388,7 @@ export class Daemon extends EventEmitter {
|
|
|
6098
6388
|
this.logger.info("Stopping daemon instance");
|
|
6099
6389
|
this.clearQuitRelaunchWatch();
|
|
6100
6390
|
this.fenceDeliveryWritesForStop();
|
|
6391
|
+
this.requestContextHelper?.revoke();
|
|
6101
6392
|
this.turnReplyGuard.reset();
|
|
6102
6393
|
this.clearReplyGuardConfirm();
|
|
6103
6394
|
this.sawBlockedInput = false;
|
|
@@ -6119,6 +6410,7 @@ export class Daemon extends EventEmitter {
|
|
|
6119
6410
|
this.healthCheckPaused = true;
|
|
6120
6411
|
this.saveSessionId();
|
|
6121
6412
|
await this.nativePaneLifecycle.release(options.nativePane ?? "detach");
|
|
6413
|
+
await this.ipcServer?.close();
|
|
6122
6414
|
try {
|
|
6123
6415
|
unlinkSync(join(this.instanceDir, "daemon.pid"));
|
|
6124
6416
|
}
|
|
@@ -6303,13 +6595,17 @@ export class Daemon extends EventEmitter {
|
|
|
6303
6595
|
/** Local system work: no user turn, channel reply target, wake or replay of an original request. */
|
|
6304
6596
|
async deliverWorkingRecovery(content, delivery, admitted) {
|
|
6305
6597
|
const tmux = this.tmux, owner = JSON.stringify(this.interactionOwner()), epoch = this.deliveryEpoch;
|
|
6306
|
-
|
|
6598
|
+
let begun = false;
|
|
6599
|
+
const current = () => (begun || !this.requestContextAdmission || this.requestContextAdmission.available()) && this.tmux === tmux && owner === JSON.stringify(this.interactionOwner())
|
|
6307
6600
|
&& this.deliveryEpoch === epoch && !this.deliveryWritesStopping && !this.runtimeMonitorsFrozen
|
|
6308
6601
|
&& !this.spawning && !this.startupAborted && !this.isPaused && !this.healthCheckPaused
|
|
6309
6602
|
&& this.processStatus === "running" && this.pasteQueueDepth === 0
|
|
6310
6603
|
&& (this.workingRecoveryInputOwner === owner || this.instanceState === "idle" && !this.recoveryNativeWork)
|
|
6311
6604
|
&& this.recoveryBootSettled && !this.recoveryCancelled && !this.isSessionOomStopped() && admitted();
|
|
6312
|
-
|
|
6605
|
+
const heldCurrent = () => this.tmux === tmux && owner === JSON.stringify(this.interactionOwner())
|
|
6606
|
+
&& this.deliveryEpoch === epoch && !this.deliveryWritesStopping && !this.startupAborted && admitted();
|
|
6607
|
+
if (this.requestContextAdmission && !await this.requestContextAdmission.wait(heldCurrent))
|
|
6608
|
+
return;
|
|
6313
6609
|
try {
|
|
6314
6610
|
await this.paneWriteLock.run(async () => {
|
|
6315
6611
|
if (!tmux || !current())
|
|
@@ -6523,7 +6819,11 @@ export class Daemon extends EventEmitter {
|
|
|
6523
6819
|
this.deferDurableDelivery(meta, "native channel owner changed before pane submission");
|
|
6524
6820
|
return;
|
|
6525
6821
|
}
|
|
6526
|
-
this.
|
|
6822
|
+
const inputId = this.requestContextLifecycle && isHubQuestionMeta(meta) && typeof msg.request_context_input_id === "string" ? msg.request_context_input_id : undefined;
|
|
6823
|
+
if (inputId)
|
|
6824
|
+
this.pushChannelMessage(msg.content, meta, targetSession, deliveryEpoch, inputId);
|
|
6825
|
+
else
|
|
6826
|
+
this.pushChannelMessage(msg.content, meta, targetSession, deliveryEpoch);
|
|
6527
6827
|
}).catch(err => {
|
|
6528
6828
|
this.deferDurableDelivery(meta, `target wake failed before pane submission: ${err.message}`);
|
|
6529
6829
|
this.logger.error({ err: err.message }, "Wake failed for inbound delivery");
|
|
@@ -7102,7 +7402,7 @@ export class Daemon extends EventEmitter {
|
|
|
7102
7402
|
* message can arrive mid-turn and sit queued, and marking at arrival would let
|
|
7103
7403
|
* the PREVIOUS turn's idle edge consume (and reset) the new turn's state.
|
|
7104
7404
|
*/
|
|
7105
|
-
markTurnStarted(meta, deliveredText, deliveryEpoch = this.deliveryEpoch, queuedHandoff = false) {
|
|
7405
|
+
markTurnStarted(meta, deliveredText, deliveryEpoch = this.deliveryEpoch, queuedHandoff = false, verdict) {
|
|
7106
7406
|
// Cancel may have interrupted an in-flight paste before its promise settled.
|
|
7107
7407
|
// Its late success must not re-arm the turn that the user just cancelled.
|
|
7108
7408
|
if (!this.isDeliveryEpochCurrent(deliveryEpoch))
|
|
@@ -7117,7 +7417,9 @@ export class Daemon extends EventEmitter {
|
|
|
7117
7417
|
// chat platform has no chat_id (its reply goes to the web chat through the
|
|
7118
7418
|
// fleet's web-only sink), but it is a person waiting for an answer all the
|
|
7119
7419
|
// same: the guard arms for it (alpha.2).
|
|
7120
|
-
|
|
7420
|
+
const requestContext = this.requestContextTurnSnapshot();
|
|
7421
|
+
const ownedReplyTarget = requestContext ? this.requestContextLifecycle?.replyTarget?.(requestContext) : null;
|
|
7422
|
+
if (!turnExpectsPersonReply(meta) && !ownedReplyTarget) {
|
|
7121
7423
|
this.logger.debug({
|
|
7122
7424
|
source: meta.source || null,
|
|
7123
7425
|
user: meta.user || null,
|
|
@@ -7137,13 +7439,20 @@ export class Daemon extends EventEmitter {
|
|
|
7137
7439
|
threadId: meta.thread_id || undefined,
|
|
7138
7440
|
messageId: meta.message_id || undefined,
|
|
7139
7441
|
correlationId: meta.correlation_id || undefined,
|
|
7442
|
+
...(ownedReplyTarget ?? {}),
|
|
7140
7443
|
inboundMarker,
|
|
7141
7444
|
deliveredText,
|
|
7142
7445
|
deliveredAt,
|
|
7143
|
-
}, this.pendingWork.lastInboundTimestamp());
|
|
7446
|
+
}, this.pendingWork.lastInboundTimestamp(), requestContext && ownedReplyTarget ? { binding: requestContext.token, target: ownedReplyTarget } : undefined);
|
|
7447
|
+
if (requestContext && verdict?.pendingReply) {
|
|
7448
|
+
const route = this.captureRequestContextReplyRoute(requestContext);
|
|
7449
|
+
if (route)
|
|
7450
|
+
verdict.pendingReply.arm(route);
|
|
7451
|
+
else
|
|
7452
|
+
verdict.pendingReply.refuse();
|
|
7453
|
+
}
|
|
7144
7454
|
const armed = this.turnReplyGuard.snapshot();
|
|
7145
7455
|
this.workingTurnDelivery = { generation: armed.generation, deliveryId: meta.delivery_id || null };
|
|
7146
|
-
const requestContext = this.requestContextTurnSnapshot();
|
|
7147
7456
|
this.workingTurnRequestContext = requestContext ? { generation: armed.generation, snapshot: requestContext } : null;
|
|
7148
7457
|
this.publishWorkingState("turn_started");
|
|
7149
7458
|
// #1209: persist the in-flight turn with a seam checkpoint. A marker
|
|
@@ -7665,7 +7974,7 @@ export class Daemon extends EventEmitter {
|
|
|
7665
7974
|
this.followLog.reset();
|
|
7666
7975
|
this.replyDraft.reset();
|
|
7667
7976
|
const modelLaunch = this.backend?.modelObservationLaunch?.();
|
|
7668
|
-
const monitor = new TranscriptMonitor(this.instanceDir, this.logger, source, () => modelLaunch);
|
|
7977
|
+
const monitor = new TranscriptMonitor(this.instanceDir, this.logger, source, () => modelLaunch, !!this.requestContextLifecycle);
|
|
7669
7978
|
let savedModel;
|
|
7670
7979
|
try {
|
|
7671
7980
|
const path = join(this.instanceDir, "claude-model-observation.json");
|
|
@@ -7732,8 +8041,11 @@ export class Daemon extends EventEmitter {
|
|
|
7732
8041
|
});
|
|
7733
8042
|
for (const event of ["reset", "workspace_reset", "context_reset"])
|
|
7734
8043
|
monitor.on(event, () => {
|
|
7735
|
-
if (this.transcriptMonitor === monitor)
|
|
8044
|
+
if (this.transcriptMonitor === monitor) {
|
|
7736
8045
|
this.replyDraft.reset();
|
|
8046
|
+
if (event !== "workspace_reset" && this.requestContextWrite)
|
|
8047
|
+
this.requestContextWrite.unknownEnd = "reset";
|
|
8048
|
+
}
|
|
7737
8049
|
});
|
|
7738
8050
|
this.transcriptTurns.reset();
|
|
7739
8051
|
this.transcriptActivityAt = 0;
|
|
@@ -7743,8 +8055,7 @@ export class Daemon extends EventEmitter {
|
|
|
7743
8055
|
this.transcriptTurns.observe(turns, performance.now());
|
|
7744
8056
|
touch();
|
|
7745
8057
|
if (this.transcriptMonitor === monitor && owner === launchIdentity(this.interactionOwner())) {
|
|
7746
|
-
this.
|
|
7747
|
-
this.settleRequestContextFromTranscript();
|
|
8058
|
+
this.observeRequestContextTranscript(turns);
|
|
7748
8059
|
}
|
|
7749
8060
|
});
|
|
7750
8061
|
// #3160: the files this turn reads, edits and searches, for the Files & changes panel's Follow (a few string checks;
|
|
@@ -7879,6 +8190,19 @@ export class Daemon extends EventEmitter {
|
|
|
7879
8190
|
const deliveryEpoch = this.deliveryEpoch;
|
|
7880
8191
|
const parent = this.workingTurnRequestContext?.generation === turn.generation ? this.workingTurnRequestContext.snapshot : null;
|
|
7881
8192
|
const recoveryInputId = `reply-recovery:${this.bootId}:${turn.generation}:${deliveryEpoch}`;
|
|
8193
|
+
const registered = parent && this.requestContextLifecycle ? { root: parent.context.ref.rootContextId } : null;
|
|
8194
|
+
if (registered) {
|
|
8195
|
+
if (this.requestContextQueuedWork.has(recoveryInputId))
|
|
8196
|
+
return;
|
|
8197
|
+
try {
|
|
8198
|
+
this.requestContextQueuedWork.set(recoveryInputId, registered);
|
|
8199
|
+
}
|
|
8200
|
+
catch {
|
|
8201
|
+
this.turnReplyGuard.complete(turn.generation);
|
|
8202
|
+
this.reportUnrecoveredReplyDrop(turn, "recovery_prompt_delivery_failed");
|
|
8203
|
+
return;
|
|
8204
|
+
}
|
|
8205
|
+
}
|
|
7882
8206
|
this.pasteQueueDepth++;
|
|
7883
8207
|
this.pasteLock = this.pasteLock.then(async () => {
|
|
7884
8208
|
try {
|
|
@@ -7921,7 +8245,8 @@ export class Daemon extends EventEmitter {
|
|
|
7921
8245
|
return;
|
|
7922
8246
|
this.turnReplyGuard.complete(turn.generation);
|
|
7923
8247
|
this.reportUnrecoveredReplyDrop(turn, "recovery_prompt_delivery_failed");
|
|
7924
|
-
})
|
|
8248
|
+
}).finally(() => { if (registered && this.requestContextQueuedWork.get(recoveryInputId) === registered)
|
|
8249
|
+
this.requestContextQueuedWork.delete(recoveryInputId); });
|
|
7925
8250
|
}
|
|
7926
8251
|
/** Recheck after queue waits and IO; cancellation must not become a failure notice. */
|
|
7927
8252
|
currentReplyRecovery(generation, deliveryEpoch) {
|
|
@@ -8011,6 +8336,10 @@ export class Daemon extends EventEmitter {
|
|
|
8011
8336
|
}
|
|
8012
8337
|
/** Context-bound reply path shared by dead-MCP and malformed-call recovery. */
|
|
8013
8338
|
deliverDaemonReply(body, requestPrefix, logLabel, target) {
|
|
8339
|
+
// System proxy text has no originating call lease. Until its final-output generation proof is
|
|
8340
|
+
// installed, it cannot borrow a live turn or lastChat; proven-parent model recovery uses C instead.
|
|
8341
|
+
if (this.requestContextLifecycle)
|
|
8342
|
+
return Promise.resolve(false);
|
|
8014
8343
|
const args = { text: body };
|
|
8015
8344
|
const chatId = target?.chatId ?? this.lastChatId;
|
|
8016
8345
|
const threadId = target?.threadId ?? this.lastThreadId;
|
|
@@ -8606,6 +8935,7 @@ export class Daemon extends EventEmitter {
|
|
|
8606
8935
|
this.cancelCapacityNudge("the instance was stopped, paused or respawned");
|
|
8607
8936
|
this.runtimeMonitorsFrozen = true;
|
|
8608
8937
|
this.launchFenceEpoch++;
|
|
8938
|
+
this.requestContextAdmission?.changed();
|
|
8609
8939
|
this.interactionObservation.reset(this.interactionOwner());
|
|
8610
8940
|
this.clearInteractionConfirmation();
|
|
8611
8941
|
if (this.healthCheckTimer) {
|
|
@@ -8976,7 +9306,7 @@ export class Daemon extends EventEmitter {
|
|
|
8976
9306
|
if (kind === "steer")
|
|
8977
9307
|
wire = Daemon.steerEnvelope(wire);
|
|
8978
9308
|
else if (kind === "btw")
|
|
8979
|
-
wire =
|
|
9309
|
+
wire = btwInboundEnvelope(wire, meta.delivery_id);
|
|
8980
9310
|
return prepareDeliveryWire(wire, kind === "raw_paste");
|
|
8981
9311
|
}
|
|
8982
9312
|
humanReceiptAttempt(meta, wire) {
|
|
@@ -9034,10 +9364,22 @@ export class Daemon extends EventEmitter {
|
|
|
9034
9364
|
if (meta.human_prepare_token)
|
|
9035
9365
|
this.humanPreparations.delete(meta.human_prepare_token);
|
|
9036
9366
|
this.humanReminderAttempts.delete(meta.human_receipt_id);
|
|
9367
|
+
const pending = this.requestContextHumanReplies?.get(meta.human_receipt_id);
|
|
9368
|
+
if (pending && !pending.accepted)
|
|
9369
|
+
pending.pending.refuse();
|
|
9370
|
+
this.requestContextHumanReplies?.delete(meta.human_receipt_id);
|
|
9037
9371
|
}
|
|
9038
9372
|
}
|
|
9039
9373
|
/** Synchronous acknowledgement from the manager after the existing receipt owner/authority checks. */
|
|
9040
9374
|
noteHumanReceiptSettlement(id, positive) {
|
|
9375
|
+
const pending = this.requestContextHumanReplies?.get(id);
|
|
9376
|
+
if (pending) {
|
|
9377
|
+
pending.accepted = positive;
|
|
9378
|
+
if (positive)
|
|
9379
|
+
pending.pending.confirm();
|
|
9380
|
+
else
|
|
9381
|
+
pending.pending.refuse();
|
|
9382
|
+
}
|
|
9041
9383
|
const stamp = this.humanReminderAttempts?.get(id);
|
|
9042
9384
|
if (!stamp || !positive || !this.humanReminders.current(stamp))
|
|
9043
9385
|
return;
|
|
@@ -9154,7 +9496,7 @@ export class Daemon extends EventEmitter {
|
|
|
9154
9496
|
})) {
|
|
9155
9497
|
delivered = true;
|
|
9156
9498
|
this.finishDurableSubmission(durableAttempt, verdict);
|
|
9157
|
-
this.markTurnStarted(meta, formatted, deliveryEpoch);
|
|
9499
|
+
this.markTurnStarted(meta, formatted, deliveryEpoch, false, verdict);
|
|
9158
9500
|
}
|
|
9159
9501
|
else if (durableAttempt && verdict.paneWriteStarted) {
|
|
9160
9502
|
this.finishDurableDelivery(durableAttempt, "uncertain", `${verdict.phase ?? "post-submit"}:${verdict.proof ?? "unproven"}`, verdict);
|
|
@@ -9208,37 +9550,75 @@ export class Daemon extends EventEmitter {
|
|
|
9208
9550
|
this.updateLastChat(meta.chat_id, meta.thread_id, meta.adapter_id);
|
|
9209
9551
|
this.pendingWork.recordInbound();
|
|
9210
9552
|
this.recordRecentUserMessage(content, meta);
|
|
9211
|
-
const formatted =
|
|
9553
|
+
const formatted = btwInboundEnvelope(this.formatInboundMessage(content, meta), meta.delivery_id);
|
|
9212
9554
|
const status = channelStatus(meta);
|
|
9555
|
+
const durableAttempt = this.durableDeliveryAttempt(meta, content);
|
|
9556
|
+
if (durableAttempt === false) {
|
|
9557
|
+
this.deferDurableDelivery(meta, "invalid durable delivery attempt metadata");
|
|
9558
|
+
return;
|
|
9559
|
+
}
|
|
9213
9560
|
this.steerLock = this.steerLock.then(async () => {
|
|
9214
9561
|
if (!this.isDeliveryEpochCurrent(deliveryEpoch)) {
|
|
9215
|
-
this.
|
|
9562
|
+
this.deferDurableDelivery(meta, "delivery epoch changed before steer began");
|
|
9216
9563
|
this.noteCancelledHuman(meta);
|
|
9217
9564
|
return;
|
|
9218
9565
|
}
|
|
9219
9566
|
await this.wake();
|
|
9220
9567
|
if (!this.isDeliveryEpochCurrent(deliveryEpoch)) {
|
|
9221
|
-
this.
|
|
9568
|
+
this.deferDurableDelivery(meta, "delivery epoch changed while waking for steer");
|
|
9222
9569
|
this.noteCancelledHuman(meta);
|
|
9223
9570
|
return;
|
|
9224
9571
|
}
|
|
9225
9572
|
const verdict = { reached: false, humanReceipt: this.humanReceiptAttempt(meta, formatted) };
|
|
9226
9573
|
let delivered = false;
|
|
9227
9574
|
try {
|
|
9228
|
-
if (await this.deliverMessage(formatted, status, {
|
|
9229
|
-
|
|
9575
|
+
if (await this.deliverMessage(formatted, status, {
|
|
9576
|
+
steer: true,
|
|
9577
|
+
deliveryEpoch,
|
|
9578
|
+
submissionId: meta.message_id,
|
|
9579
|
+
...(meta.verification_id ? { humanVerificationId: meta.verification_id, humanMeta: meta } : {}),
|
|
9580
|
+
verdict,
|
|
9581
|
+
durableAttempt: durableAttempt || undefined,
|
|
9582
|
+
})) {
|
|
9230
9583
|
delivered = true;
|
|
9231
|
-
this.
|
|
9584
|
+
this.finishDurableSubmission(durableAttempt, verdict);
|
|
9585
|
+
this.markTurnStarted(meta, formatted, deliveryEpoch, false, verdict);
|
|
9586
|
+
}
|
|
9587
|
+
else if (durableAttempt && verdict.paneWriteStarted) {
|
|
9588
|
+
this.finishDurableDelivery(durableAttempt, "uncertain", `${verdict.phase ?? "post-submit"}:${verdict.proof ?? "unproven"}`, verdict);
|
|
9589
|
+
}
|
|
9590
|
+
else if (durableAttempt && verdict.durableBeginCommitted) {
|
|
9591
|
+
this.abortDurableDelivery(durableAttempt, `${verdict.phase ?? "delivery"}:${verdict.proof ?? "no-pane-write"}`);
|
|
9592
|
+
}
|
|
9593
|
+
else if (durableAttempt) {
|
|
9594
|
+
this.retryDurableDeliveryBeforeBegin(durableAttempt, `${verdict.phase ?? "delivery"}:${verdict.proof ?? "deferred"}`);
|
|
9595
|
+
}
|
|
9596
|
+
else if (verdict.reached && this.isDeliveryEpochCurrent(deliveryEpoch)) {
|
|
9597
|
+
// Legacy non-outbox path retains its existing failure surface.
|
|
9598
|
+
this.reportCrossInstanceDeliveryFailure(meta, verdict);
|
|
9232
9599
|
}
|
|
9233
9600
|
}
|
|
9601
|
+
catch (err) {
|
|
9602
|
+
// The verdict goes along: a write that started and then threw is still a hand-off the CLI may consume (#1201).
|
|
9603
|
+
if (durableAttempt && verdict.paneWriteStarted)
|
|
9604
|
+
this.finishDurableDelivery(durableAttempt, "uncertain", err.message, verdict);
|
|
9605
|
+
else if (durableAttempt && verdict.durableBeginCommitted)
|
|
9606
|
+
this.abortDurableDelivery(durableAttempt, err.message);
|
|
9607
|
+
else if (durableAttempt)
|
|
9608
|
+
this.retryDurableDeliveryBeforeBegin(durableAttempt, err.message);
|
|
9609
|
+
throw err;
|
|
9610
|
+
}
|
|
9234
9611
|
finally {
|
|
9235
9612
|
this.finishHumanReceipt(meta, verdict);
|
|
9236
9613
|
if (!delivered && !verdict.paneWriteStarted && !this.isDeliveryEpochCurrent(deliveryEpoch))
|
|
9237
9614
|
this.noteCancelledHuman(meta);
|
|
9238
9615
|
}
|
|
9239
9616
|
}).catch(err => {
|
|
9240
|
-
this.
|
|
9617
|
+
this.deferDurableDelivery(meta, `target wake/side-question failed before pane submission: ${err.message}`);
|
|
9241
9618
|
this.logger.warn({ err: err.message }, "btw delivery error");
|
|
9619
|
+
if (!durableAttempt && this.isDeliveryEpochCurrent(deliveryEpoch)) {
|
|
9620
|
+
this.reportCrossInstanceDeliveryFailure(meta, undefined, err.message);
|
|
9621
|
+
}
|
|
9242
9622
|
});
|
|
9243
9623
|
}
|
|
9244
9624
|
/**
|
|
@@ -9246,7 +9626,9 @@ export class Daemon extends EventEmitter {
|
|
|
9246
9626
|
* If targetSession is provided, only send to the matching socket.
|
|
9247
9627
|
* Otherwise send to the instance's own session (this.name).
|
|
9248
9628
|
*/
|
|
9249
|
-
pushChannelMessage(content, meta, _targetSession, deliveryEpoch = this.deliveryEpoch) {
|
|
9629
|
+
pushChannelMessage(content, meta, _targetSession, deliveryEpoch = this.deliveryEpoch, requestContextInputId) {
|
|
9630
|
+
if (requestContextInputId && !/^hub-input:[a-f0-9-]{36}$/.test(requestContextInputId))
|
|
9631
|
+
throw Error("Hub request input id is unavailable");
|
|
9250
9632
|
if (!this.isDeliveryEpochCurrent(deliveryEpoch)) {
|
|
9251
9633
|
this.logger.info("Pending channel delivery dropped by user cancel");
|
|
9252
9634
|
this.deferDurableDelivery(meta, "delivery epoch changed before queue admission");
|
|
@@ -9336,7 +9718,8 @@ export class Daemon extends EventEmitter {
|
|
|
9336
9718
|
? this.currentWhatsNew(this.pendingWhatsNew) : null;
|
|
9337
9719
|
const body = whatsNew ? withWhatsNew(formatted, whatsNew.notice) : formatted;
|
|
9338
9720
|
const roomMarker = roomContextInputMarker(meta);
|
|
9339
|
-
const
|
|
9721
|
+
const unmarked = roomMarker ? `${roomMarker}\n${body}` : body;
|
|
9722
|
+
const pasted = requestContextInputId && !roomMarker ? `[agend-request-input:${requestContextInputId}]\n${unmarked}` : unmarked;
|
|
9340
9723
|
const status = channelStatus(meta);
|
|
9341
9724
|
// A fresh delivery begins a fresh turn — its bubble must not inherit
|
|
9342
9725
|
// the previous turn's tool list.
|
|
@@ -9369,6 +9752,7 @@ export class Daemon extends EventEmitter {
|
|
|
9369
9752
|
sent = await this.deliverMessage(pasted, status, {
|
|
9370
9753
|
deliveryEpoch,
|
|
9371
9754
|
submissionId: meta.message_id,
|
|
9755
|
+
...(requestContextInputId ? { requestContextInputId } : {}),
|
|
9372
9756
|
...(isHubQuestionMeta(meta) ? { hubQuestion: meta.correlation_id, hubContactLimit: meta.hub_contact_limit !== "off" } : {}),
|
|
9373
9757
|
...(meta.hub_room_context_generation ? { roomContextGeneration: meta.hub_room_context_generation } : {}),
|
|
9374
9758
|
...(meta.verification_id ? { humanVerificationId: meta.verification_id, humanMeta: meta } : {}),
|
|
@@ -9386,7 +9770,7 @@ export class Daemon extends EventEmitter {
|
|
|
9386
9770
|
if (sent) {
|
|
9387
9771
|
delivered = true;
|
|
9388
9772
|
this.finishDurableSubmission(durable, verdict);
|
|
9389
|
-
this.markTurnStarted(meta, formatted, deliveryEpoch, !!verdict.handoff);
|
|
9773
|
+
this.markTurnStarted(meta, formatted, deliveryEpoch, !!verdict.handoff, verdict);
|
|
9390
9774
|
}
|
|
9391
9775
|
else if (durableAttempt && verdict.paneWriteStarted) {
|
|
9392
9776
|
this.finishDurableDelivery(durable, "uncertain", `${verdict.phase ?? "post-submit"}:${verdict.proof ?? "unproven"}`, verdict);
|
|
@@ -9468,6 +9852,21 @@ export class Daemon extends EventEmitter {
|
|
|
9468
9852
|
|| (!!opts?.roomContextGeneration && opts.roomContextGeneration !== this.roomConversationGeneration());
|
|
9469
9853
|
if (cancelled() || this.stormWindow?.isStopped())
|
|
9470
9854
|
return false;
|
|
9855
|
+
const admittedReceiptId = opts?.humanMeta?.verification_id ?? opts?.humanVerificationId;
|
|
9856
|
+
const admittedInputId = opts?.requestContextInputId ?? (admittedReceiptId ? `human:${admittedReceiptId}` : opts?.durableAttempt ? `delivery:${opts.durableAttempt.deliveryId}:${opts.durableAttempt.attemptNo}` : null);
|
|
9857
|
+
// Captured once for this input, before waiting. An ended steer never turns into a fresh owner root.
|
|
9858
|
+
const continuation = this.requestContextLifecycle?.continuation?.(admittedInputId, opts?.requestContextRecovery);
|
|
9859
|
+
let heldOwner;
|
|
9860
|
+
const admissionCurrent = () => !cancelled() && !this.deliveryWritesStopping && !this.startupAborted
|
|
9861
|
+
&& (heldOwner === undefined || heldOwner === JSON.stringify(this.interactionOwner()));
|
|
9862
|
+
const waitAdmission = async () => {
|
|
9863
|
+
const port = this.requestContextAdmission;
|
|
9864
|
+
if (!port.available(continuation))
|
|
9865
|
+
heldOwner ??= JSON.stringify(this.interactionOwner());
|
|
9866
|
+
return await port.wait(admissionCurrent, continuation) && admissionCurrent();
|
|
9867
|
+
};
|
|
9868
|
+
if (this.requestContextAdmission && !await waitAdmission())
|
|
9869
|
+
return false;
|
|
9471
9870
|
formatted = prepareDeliveryWire(formatted, opts?.preserveExactBytes);
|
|
9472
9871
|
// Direct paths such as /steer, /btw, /raw and schedules do not pass the
|
|
9473
9872
|
// FleetManager idle gate. Hold them at the final common pane-write path so
|
|
@@ -9632,6 +10031,8 @@ export class Daemon extends EventEmitter {
|
|
|
9632
10031
|
const outcome = await this.paneWriteLock.run(async () => {
|
|
9633
10032
|
if (cancelled())
|
|
9634
10033
|
return false;
|
|
10034
|
+
if (this.requestContextAdmission && !this.requestContextAdmission.available(continuation) && !verdict.paneWriteStarted && !verdict.durableBeginCommitted)
|
|
10035
|
+
return "request-context-held";
|
|
9635
10036
|
// A spawn that started after the settle wait above invalidates the
|
|
9636
10037
|
// window id and every readiness verdict since: the pane about to be
|
|
9637
10038
|
// written may already belong to a replacement process. The same holds
|
|
@@ -9675,13 +10076,15 @@ export class Daemon extends EventEmitter {
|
|
|
9675
10076
|
// same process, a pause/stop/respawn is not (launchFenceEpoch moves even
|
|
9676
10077
|
// when a failed pause resumes the monitors).
|
|
9677
10078
|
const writeCurrent = () => !cancelled()
|
|
10079
|
+
&& (!this.requestContextAdmission || admissionCurrent() && (this.requestContextAdmission.available(continuation) || !!verdict.paneWriteStarted || !!verdict.durableBeginCommitted))
|
|
9678
10080
|
&& !this.staleAuthIssue()
|
|
9679
10081
|
&& !this.deliveryWritesStopping
|
|
9680
10082
|
&& !this.runtimeMonitorsFrozen
|
|
9681
10083
|
&& !this.spawning
|
|
9682
10084
|
&& settleGeneration === this.spawnGeneration
|
|
9683
10085
|
&& settleFence === this.launchFenceEpoch;
|
|
9684
|
-
const stale = () =>
|
|
10086
|
+
const stale = () => this.requestContextAdmission && !this.requestContextAdmission.available(continuation) && !verdict.paneWriteStarted && !verdict.durableBeginCommitted
|
|
10087
|
+
? "request-context-held" : this.spawning || settleGeneration !== this.spawnGeneration ? "spawn-started" : false;
|
|
9685
10088
|
const residue = await this.clearRestoredInputDraft(handingOffToNativeQueue, writeCurrent);
|
|
9686
10089
|
if (residue === "stale")
|
|
9687
10090
|
return stale();
|
|
@@ -9699,6 +10102,12 @@ export class Daemon extends EventEmitter {
|
|
|
9699
10102
|
const after = this.requestContextTurnSnapshot();
|
|
9700
10103
|
if (after && after !== prior)
|
|
9701
10104
|
newlyBound = after;
|
|
10105
|
+
if (after && inputId && (/^human:hmsg-/.test(inputId) || /^delivery:/.test(inputId))) {
|
|
10106
|
+
verdict.pendingReply = this.requestContextPendingReplies.stage(after, inputId, deliveryContentDigest(wireText), () => this.requestContextTurnCurrent(after));
|
|
10107
|
+
const humanId = opts?.humanMeta?.human_receipt_id;
|
|
10108
|
+
if (humanId && verdict.pendingReply)
|
|
10109
|
+
this.requestContextHumanReplies.set(humanId, { pending: verdict.pendingReply, accepted: false });
|
|
10110
|
+
}
|
|
9702
10111
|
if (!handingOffToNativeQueue)
|
|
9703
10112
|
this.hubAnswerTurnBegins(opts?.hubQuestion, opts?.hubContactLimit !== false);
|
|
9704
10113
|
opts?.beforePaneWrite?.();
|
|
@@ -9717,9 +10126,18 @@ export class Daemon extends EventEmitter {
|
|
|
9717
10126
|
// M-2267: the pane is in a tmux mode: nothing written — wait for readiness (it holds while the mode lasts), retry.
|
|
9718
10127
|
if (written === "pane-in-mode")
|
|
9719
10128
|
return "dialog";
|
|
10129
|
+
// A publication fence before input keeps this attempt at its producer; never turn the wait into failure.
|
|
10130
|
+
if (written === false && this.requestContextAdmission && !this.requestContextAdmission.available(continuation) && !verdict.paneWriteStarted && !verdict.durableBeginCommitted)
|
|
10131
|
+
return "request-context-held";
|
|
9720
10132
|
// Fenced before its first write: not attempted — redo after a spawn, else drop without a ❌.
|
|
9721
10133
|
return written === false && verdict.fenced ? stale() : written;
|
|
9722
10134
|
});
|
|
10135
|
+
if (outcome === "request-context-held") {
|
|
10136
|
+
if (!this.requestContextAdmission || !await waitAdmission())
|
|
10137
|
+
return false;
|
|
10138
|
+
round--;
|
|
10139
|
+
continue; // Waiting on admission consumes neither a dialog retry nor any input intent.
|
|
10140
|
+
}
|
|
9723
10141
|
if (outcome === "spawn-started") {
|
|
9724
10142
|
// The pane changed under this delivery: its queued paste must not land
|
|
9725
10143
|
// in the replacement process's first screen. Redo the whole delivery
|
|
@@ -11903,10 +12321,24 @@ export class Daemon extends EventEmitter {
|
|
|
11903
12321
|
verdict.roomInputQueued = handingOffToNativeQueue || steer;
|
|
11904
12322
|
const humanMode = rawPaste ? "raw_paste" : steer ? "steer"
|
|
11905
12323
|
: handingOffToNativeQueue ? "native_queue_handoff" : "idle_submit";
|
|
11906
|
-
|
|
12324
|
+
// Retained controls lead with the delivery marker for strict transcript/restart proof. That marker is
|
|
12325
|
+
// usable for a human receipt only through the outbox's exact control/receipt/owner/wire join, never text lookup.
|
|
12326
|
+
const controlMarker = durableAttempt ? `[agend-delivery-id:${durableAttempt.deliveryId}]` : null;
|
|
12327
|
+
const ownsControlReceipt = () => !!humanAttempt && !!durableAttempt && !rawPaste
|
|
12328
|
+
&& this.deliveryOutbox?.ownsHumanControlReceipt?.(durableAttempt.deliveryId, this.bootId, durableAttempt.attemptNo, humanAttempt.receiptId, humanAttempt.ownerKey, humanAttempt.expectedWireHash) === true;
|
|
12329
|
+
const controlAlias = !!controlMarker && !!humanAttempt
|
|
12330
|
+
&& [`${controlMarker}\n${humanAttempt.marker}\n`,
|
|
12331
|
+
Daemon.steerEnvelope(`${controlMarker}\n${humanAttempt.marker}\n`),
|
|
12332
|
+
btwInboundEnvelope(`${controlMarker}\n${humanAttempt.marker}\n`, durableAttempt.deliveryId)].some(prefix => formatted.startsWith(prefix))
|
|
12333
|
+
&& ownsControlReceipt();
|
|
12334
|
+
if (controlAlias) {
|
|
12335
|
+
signature.value = controlMarker.slice(1, -1);
|
|
12336
|
+
signature.takenMarker = controlMarker;
|
|
12337
|
+
}
|
|
12338
|
+
if (humanAttempt && signature.unique && (controlAlias || signature.value === humanReceiptMarker(humanAttempt.verificationId, humanDialect).slice(1, -1))
|
|
11907
12339
|
&& humanBodyHash(formatted) === humanAttempt.expectedWireHash) {
|
|
11908
12340
|
signature.humanPositive = tag => {
|
|
11909
|
-
if (!humanAttempt.current() || (stillCurrent && !stillCurrent()))
|
|
12341
|
+
if (!humanAttempt.current() || (stillCurrent && !stillCurrent()) || controlAlias && !ownsControlReceipt())
|
|
11910
12342
|
return;
|
|
11911
12343
|
humanAttempt.proof = {
|
|
11912
12344
|
receipt_id: humanAttempt.receiptId, verification_id: humanAttempt.verificationId,
|
|
@@ -12179,7 +12611,7 @@ export class Daemon extends EventEmitter {
|
|
|
12179
12611
|
if (!this.steerPasteIsOurs(before.pane, formatted))
|
|
12180
12612
|
return this.failDelivery(verdict, status, "steer-paste", "box-not-this-paste");
|
|
12181
12613
|
const shown = this.backend?.readSteerComposerText?.(before.pane)?.replace(/\s+/g, " ").trim();
|
|
12182
|
-
humanComposerOwned = !!humanAttempt && shown === (humanAttempt.marker ?? "[agend-human-id:" + humanAttempt.verificationId + "]");
|
|
12614
|
+
humanComposerOwned = !!humanAttempt && shown === (controlAlias ? controlMarker : humanAttempt.marker ?? "[agend-human-id:" + humanAttempt.verificationId + "]");
|
|
12183
12615
|
// …and so is the Enter: the key is sent only while the reading is still within it.
|
|
12184
12616
|
steerEnterDeadline = deadline;
|
|
12185
12617
|
}
|
|
@@ -12951,6 +13383,7 @@ export class Daemon extends EventEmitter {
|
|
|
12951
13383
|
// Grok cuts an echo to three rows, so the trailing message_id never shows after Enter; the marker always does.
|
|
12952
13384
|
// Placed after the strand checks: text of ours still in the box (or its collapsed paste) outranks it.
|
|
12953
13385
|
if (signature.takenMarker && after.inputReadable && this.backend?.readTakenMarkers?.(pane).includes(signature.takenMarker)) {
|
|
13386
|
+
signature.humanPositive?.("unique-id-pane");
|
|
12954
13387
|
return this.submittedProof();
|
|
12955
13388
|
}
|
|
12956
13389
|
// 2. Positive evidence. A unique signature needs no baseline: no earlier
|
|
@@ -13391,7 +13824,8 @@ export class Daemon extends EventEmitter {
|
|
|
13391
13824
|
const timer = setTimeout(() => finish({ result: null, error: "Pane tool result is unconfirmed; inspect its operation before retrying" }), daemonBudgetMs(input.tool) + 1000);
|
|
13392
13825
|
timer.unref?.();
|
|
13393
13826
|
try {
|
|
13394
|
-
|
|
13827
|
+
const reply = lease.requestContext ? this.requestContextCapturedReply(lease.requestContext) : undefined;
|
|
13828
|
+
call = lease.requestContext ? Object.freeze({ id: randomUUID(), admission: lease.requestContext, get replyRoute() { return reply?.route(); }, waitForReplyRoute: reply?.wait, current: () => current() && (!reply || reply.current()) }) : undefined;
|
|
13395
13829
|
if (call)
|
|
13396
13830
|
this.requestContextCalls.set(call.id, call);
|
|
13397
13831
|
this.handleToolCall({ ...input, requestId: ++this.fleetRequestSeq }, undefined, {
|
|
@@ -13427,6 +13861,25 @@ export class Daemon extends EventEmitter {
|
|
|
13427
13861
|
this.emit("mcp_tool_response_written", { operationId, daemonBootId: this.bootId });
|
|
13428
13862
|
}
|
|
13429
13863
|
handleToolCall(msg, socket, peer, originatingCall) {
|
|
13864
|
+
const finish = this.requestContextPendingWork?.begin(this.name);
|
|
13865
|
+
const dispatch = () => Daemon.prototype.handleTrackedToolCall.call(this, msg, socket, peer, originatingCall, finish);
|
|
13866
|
+
const expanded = originatingCall?.waitForReplyRoute ? expandReplyWaitCall(String(msg.tool), (msg.args ?? {})) : null;
|
|
13867
|
+
if (originatingCall?.waitForReplyRoute && expanded && !("error" in expanded) && ["reply", "edit_message", "react"].includes(expanded.name)) {
|
|
13868
|
+
// Submission proof progresses independently. No policy, adapter effect or
|
|
13869
|
+
// Fleet forward runs before this original call's delivery and arm settle.
|
|
13870
|
+
void originatingCall.waitForReplyRoute(daemonBudgetMs(expanded.name)).then(dispatch, dispatch).catch(() => finish?.());
|
|
13871
|
+
return;
|
|
13872
|
+
}
|
|
13873
|
+
try {
|
|
13874
|
+
dispatch();
|
|
13875
|
+
}
|
|
13876
|
+
catch (error) {
|
|
13877
|
+
finish?.();
|
|
13878
|
+
throw error;
|
|
13879
|
+
}
|
|
13880
|
+
}
|
|
13881
|
+
handleTrackedToolCall(msg, socket, peer, originatingCall, finish) {
|
|
13882
|
+
const runLocal = (work) => this.requestContextPendingWork ? this.requestContextPendingWork.run(this.name, work) : work();
|
|
13430
13883
|
const tool = msg.tool;
|
|
13431
13884
|
const args = (msg.args ?? {});
|
|
13432
13885
|
const requestId = msg.requestId;
|
|
@@ -13448,62 +13901,67 @@ export class Daemon extends EventEmitter {
|
|
|
13448
13901
|
: null;
|
|
13449
13902
|
// For now, log and respond. Full adapter routing will be wired in fleet manager.
|
|
13450
13903
|
const respond = (result, error, errorCode) => {
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
if (originatingCall)
|
|
13456
|
-
this.requestContextCalls.delete(originatingCall.id);
|
|
13457
|
-
// A message that verifiably went out stands down the dead-MCP proxy reply
|
|
13458
|
-
// for this turn: the agent proved it can still speak for itself.
|
|
13459
|
-
if (!error && result != null && TURN_OUTBOUND_TOOLS.has(tool)) {
|
|
13460
|
-
this.turnReplyGuard.settleToolAttempt(replyAttempt, true);
|
|
13461
|
-
// #1209 P2: the user got an answer — the turn is over for resume
|
|
13462
|
-
// purposes even before the idle edge completes the guard. Without
|
|
13463
|
-
// this, a restart in the reply-to-idle window would re-inject a
|
|
13464
|
-
// continuation for an already-answered turn.
|
|
13465
|
-
if (replyAttempt?.completionAction) {
|
|
13466
|
-
clearInFlightTurnMarker(this.instanceDir);
|
|
13467
|
-
this.publishWorkingState("completion_delivered");
|
|
13904
|
+
try {
|
|
13905
|
+
if (originatingCall && !originatingCall.current()) {
|
|
13906
|
+
result = null;
|
|
13907
|
+
error = `Tool outcome is unconfirmed. ${operationId ? `Inspect operation ${operationId}` : "Inspect the tool operation status"}; do not repeat it.`;
|
|
13468
13908
|
}
|
|
13469
|
-
|
|
13470
|
-
|
|
13471
|
-
//
|
|
13472
|
-
//
|
|
13473
|
-
|
|
13474
|
-
|
|
13475
|
-
|
|
13476
|
-
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
//
|
|
13484
|
-
|
|
13485
|
-
|
|
13486
|
-
|
|
13487
|
-
|
|
13909
|
+
if (originatingCall)
|
|
13910
|
+
this.requestContextCalls.delete(originatingCall.id);
|
|
13911
|
+
// A message that verifiably went out stands down the dead-MCP proxy reply
|
|
13912
|
+
// for this turn: the agent proved it can still speak for itself.
|
|
13913
|
+
if (!error && result != null && TURN_OUTBOUND_TOOLS.has(tool)) {
|
|
13914
|
+
this.turnReplyGuard.settleToolAttempt(replyAttempt, true);
|
|
13915
|
+
// #1209 P2: the user got an answer — the turn is over for resume
|
|
13916
|
+
// purposes even before the idle edge completes the guard. Without
|
|
13917
|
+
// this, a restart in the reply-to-idle window would re-inject a
|
|
13918
|
+
// continuation for an already-answered turn.
|
|
13919
|
+
if (replyAttempt?.completionAction) {
|
|
13920
|
+
clearInFlightTurnMarker(this.instanceDir);
|
|
13921
|
+
this.publishWorkingState("completion_delivered");
|
|
13922
|
+
}
|
|
13923
|
+
// #1377: a confirmed completion action (reply/react/edit_message) ends
|
|
13924
|
+
// the human-facing obligation immediately — the idle edge does not need
|
|
13925
|
+
// to confirm it. Clear any pending confirmation window so a later
|
|
13926
|
+
// cross-instance busy→idle cycle cannot re-arm and fire false recovery.
|
|
13927
|
+
// The guard itself completes on the next steady-idle tick via
|
|
13928
|
+
// maybeConfirmReplyGuardIdle (which checks completionDelivered when
|
|
13929
|
+
// replyGuardIdleConfirm is null) or at the next busy→idle edge.
|
|
13930
|
+
// Cancelled turns are excluded: their completion semantics are handled
|
|
13931
|
+
// by the idle edge's cancelledByUser check.
|
|
13932
|
+
// An older reply that satisfied an earlier obligation but not the latest
|
|
13933
|
+
// one (latestObligation > token.obligation) leaves completionDelivered
|
|
13934
|
+
// false and must not clear the window either.
|
|
13935
|
+
if (replyAttempt?.completionAction) {
|
|
13936
|
+
const snap = this.turnReplyGuard.snapshot();
|
|
13937
|
+
// generation 0 is a pre-arm token applied to the live generation (#2544).
|
|
13938
|
+
if (snap && (snap.generation === replyAttempt.generation || replyAttempt.generation === 0)
|
|
13939
|
+
&& snap.phase === "awaiting"
|
|
13940
|
+
&& snap.completionDelivered && !snap.cancelledByUser) {
|
|
13941
|
+
this.clearReplyGuardConfirm();
|
|
13942
|
+
}
|
|
13488
13943
|
}
|
|
13489
13944
|
}
|
|
13945
|
+
else if ((error || result == null) && replyAttempt?.reply && TURN_OUTBOUND_TOOLS.has(tool)) {
|
|
13946
|
+
// #1377: the adapter returned a definitive error — record this so the
|
|
13947
|
+
// confirm window can distinguish "in-flight" (unknown) from "known
|
|
13948
|
+
// failed" and report unknown immediately rather than starting recovery.
|
|
13949
|
+
this.turnReplyGuard.settleToolAttempt(replyAttempt, false);
|
|
13950
|
+
}
|
|
13951
|
+
const packet = { requestId, result, error, operationId, ...(errorCode !== undefined ? { errorCode } : {}) };
|
|
13952
|
+
const sent = peer ? peer.current() && peer.send(packet) : socket ? this.ipcServer?.send(socket, packet) ?? false : false;
|
|
13953
|
+
if (!sent) {
|
|
13954
|
+
if (peer)
|
|
13955
|
+
this.logger.debug({ tool, requestId }, "Native MCP result awaits transport-written confirmation");
|
|
13956
|
+
else
|
|
13957
|
+
this.logger.warn({ tool, requestId }, "Tool result could not be returned — originating MCP socket is closed");
|
|
13958
|
+
}
|
|
13959
|
+
else if (operationId) {
|
|
13960
|
+
this.emit("mcp_tool_response_written", { operationId, daemonBootId: this.bootId });
|
|
13961
|
+
}
|
|
13490
13962
|
}
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
// confirm window can distinguish "in-flight" (unknown) from "known
|
|
13494
|
-
// failed" and report unknown immediately rather than starting recovery.
|
|
13495
|
-
this.turnReplyGuard.settleToolAttempt(replyAttempt, false);
|
|
13496
|
-
}
|
|
13497
|
-
const packet = { requestId, result, error, operationId, ...(errorCode !== undefined ? { errorCode } : {}) };
|
|
13498
|
-
const sent = peer ? peer.current() && peer.send(packet) : socket ? this.ipcServer?.send(socket, packet) ?? false : false;
|
|
13499
|
-
if (!sent) {
|
|
13500
|
-
if (peer)
|
|
13501
|
-
this.logger.debug({ tool, requestId }, "Native MCP result awaits transport-written confirmation");
|
|
13502
|
-
else
|
|
13503
|
-
this.logger.warn({ tool, requestId }, "Tool result could not be returned — originating MCP socket is closed");
|
|
13504
|
-
}
|
|
13505
|
-
else if (operationId) {
|
|
13506
|
-
this.emit("mcp_tool_response_written", { operationId, daemonBootId: this.bootId });
|
|
13963
|
+
finally {
|
|
13964
|
+
finish?.();
|
|
13507
13965
|
}
|
|
13508
13966
|
};
|
|
13509
13967
|
const sendFleet = (message) => {
|
|
@@ -13520,7 +13978,7 @@ export class Daemon extends EventEmitter {
|
|
|
13520
13978
|
};
|
|
13521
13979
|
try {
|
|
13522
13980
|
if (this.requestContextPolicy)
|
|
13523
|
-
requireRequestContextPolicy(this, this.name, tool, args, originatingCall?.admission);
|
|
13981
|
+
requireRequestContextPolicy(this, this.name, tool, args, originatingCall?.admission, originatingCall?.replyRoute);
|
|
13524
13982
|
}
|
|
13525
13983
|
catch (error) {
|
|
13526
13984
|
respond(null, error.message);
|
|
@@ -13540,11 +13998,11 @@ export class Daemon extends EventEmitter {
|
|
|
13540
13998
|
return;
|
|
13541
13999
|
// Repo checkout — handled locally in daemon (no fleet-manager)
|
|
13542
14000
|
if (tool === "checkout_repo") {
|
|
13543
|
-
this.handleCheckoutRepo(args, respond);
|
|
14001
|
+
void runLocal(() => this.handleCheckoutRepo(args, respond));
|
|
13544
14002
|
return;
|
|
13545
14003
|
}
|
|
13546
14004
|
if (tool === "release_repo") {
|
|
13547
|
-
this.handleReleaseRepo(args, respond);
|
|
14005
|
+
void runLocal(() => this.handleReleaseRepo(args, respond));
|
|
13548
14006
|
return;
|
|
13549
14007
|
}
|
|
13550
14008
|
if (tool === "set_display_name" || tool === "set_description" || tool === "list_emojis" || tool === "set_persona_emoji" || tool === "preview_emojis"
|
|
@@ -13594,7 +14052,7 @@ export class Daemon extends EventEmitter {
|
|
|
13594
14052
|
});
|
|
13595
14053
|
sendFleet({ type: WEB_THEME_IPC[tool], payload, meta: { instance_name: this.name }, fleetRequestId: fleetReqId });
|
|
13596
14054
|
});
|
|
13597
|
-
void (async () => {
|
|
14055
|
+
void runLocal(async () => {
|
|
13598
14056
|
if (tool === "preview_web_appearance") {
|
|
13599
14057
|
// The fleet builds the SVGs (whole, or in parts); they are written here, in the working directory.
|
|
13600
14058
|
const first = await ask({ ...(args.modes !== undefined ? { modes: args.modes } : {}) });
|
|
@@ -13656,7 +14114,7 @@ export class Daemon extends EventEmitter {
|
|
|
13656
14114
|
return (r.result && typeof r.result === "object" ? r.result : {});
|
|
13657
14115
|
});
|
|
13658
14116
|
reply(failed ? null : answer, failed);
|
|
13659
|
-
})
|
|
14117
|
+
}).catch((err) => reply(null, `${tool} failed: ${err instanceof Error ? err.message : "error"}`));
|
|
13660
14118
|
return;
|
|
13661
14119
|
}
|
|
13662
14120
|
if (tool === TASK_TOOL) {
|
|
@@ -13680,13 +14138,13 @@ export class Daemon extends EventEmitter {
|
|
|
13680
14138
|
});
|
|
13681
14139
|
// files named in `attach` are read HERE, on the agent's side (its working directory, no symlink, size-capped),
|
|
13682
14140
|
// and staged on the fleet in parts; the write itself then carries their ids. The fleet never opens a workspace path.
|
|
13683
|
-
void (async () => {
|
|
14141
|
+
void runLocal(async () => {
|
|
13684
14142
|
const sent = await sendTaskWrite(args, { workspace: this.config.working_directory, configuredWorkspace: this.config.working_directory, stateDir: getAgendHome(), instance: this.name }, askTask);
|
|
13685
14143
|
if (sent.staging)
|
|
13686
14144
|
respond(null, sent.error);
|
|
13687
14145
|
else
|
|
13688
14146
|
respond(sent.answer.result, sent.answer.error);
|
|
13689
|
-
})
|
|
14147
|
+
}).catch((err) => respond(null, `task failed: ${err instanceof Error ? err.message : "error"}`));
|
|
13690
14148
|
return;
|
|
13691
14149
|
}
|
|
13692
14150
|
if (DECISION_TOOLS.has(tool)) {
|
|
@@ -13779,7 +14237,19 @@ export class Daemon extends EventEmitter {
|
|
|
13779
14237
|
// Context-bound routing: reply/react/edit_message always use the daemon's last known context.
|
|
13780
14238
|
// chat_id and thread_id are not exposed in the tool schema — daemon is solely responsible for routing.
|
|
13781
14239
|
// Must run before IPC forwarding so topic-mode (fleet manager) also receives the correct chat_id.
|
|
13782
|
-
|
|
14240
|
+
const ownedReplyRoute = this.requestContextPolicy && ["reply", "react", "edit_message"].includes(tool) ? originatingCall?.replyRoute : undefined;
|
|
14241
|
+
if (ownedReplyRoute) {
|
|
14242
|
+
if (!ownedReplyRoute.current()) {
|
|
14243
|
+
respond(null, "Originating request context is no longer current");
|
|
14244
|
+
return;
|
|
14245
|
+
}
|
|
14246
|
+
args.chat_id = ownedReplyRoute.target.chatId;
|
|
14247
|
+
if (ownedReplyRoute.target.threadId)
|
|
14248
|
+
args.thread_id = ownedReplyRoute.target.threadId;
|
|
14249
|
+
else
|
|
14250
|
+
delete args.thread_id;
|
|
14251
|
+
}
|
|
14252
|
+
if (!ownedReplyRoute && ["reply", "react", "edit_message"].includes(tool)) {
|
|
13783
14253
|
const adapters = this.messageBus.getAllAdapters();
|
|
13784
14254
|
const isTopicMode = adapters.length === 0;
|
|
13785
14255
|
if (!this.lastChatId && !isTopicMode) {
|
|
@@ -13830,15 +14300,16 @@ export class Daemon extends EventEmitter {
|
|
|
13830
14300
|
// Preserve the exact adapter world that supplied the chat context. An
|
|
13831
14301
|
// instance binding is only a fallback: persisted/runtime context can be
|
|
13832
14302
|
// from a secondary world, and message ids are not portable across bots.
|
|
13833
|
-
adapterId: this.lastAdapterId,
|
|
14303
|
+
adapterId: ownedReplyRoute ? ownedReplyRoute.target.adapterId : this.lastAdapterId,
|
|
13834
14304
|
});
|
|
13835
14305
|
return;
|
|
13836
14306
|
}
|
|
13837
14307
|
// Same rule as deliverDaemonReply: one adapter is unambiguous, several with
|
|
13838
14308
|
// no bound world is a routing failure rather than a first-wins guess.
|
|
13839
|
-
const
|
|
13840
|
-
|
|
13841
|
-
|
|
14309
|
+
const selectedAdapter = ownedReplyRoute ? ownedReplyRoute.target.adapterId : this.lastAdapterId;
|
|
14310
|
+
const adapter = selectedAdapter
|
|
14311
|
+
? this.messageBus.getAdapter(selectedAdapter) ?? (!ownedReplyRoute && adapters.length === 1 ? adapters[0] : undefined)
|
|
14312
|
+
: (!ownedReplyRoute && adapters.length === 1 ? adapters[0] : undefined);
|
|
13842
14313
|
if (!adapter) {
|
|
13843
14314
|
respond(null, "No channel world bound to this chat context — awaiting an inbound message to establish it");
|
|
13844
14315
|
return;
|
|
@@ -13861,7 +14332,8 @@ export class Daemon extends EventEmitter {
|
|
|
13861
14332
|
delete routed.buttons;
|
|
13862
14333
|
}
|
|
13863
14334
|
}
|
|
13864
|
-
if (!routeToolCall(adapter, tool, routed, this.lastThreadId, respond))
|
|
14335
|
+
if (!routeToolCall(adapter, tool, routed, ownedReplyRoute ? ownedReplyRoute.target.threadId : this.lastThreadId, respond, ownedReplyRoute ? { beforeSend: () => { if (!originatingCall?.current() || !ownedReplyRoute.current() || !selectedAdapter || this.messageBus.getAdapter(selectedAdapter) !== adapter)
|
|
14336
|
+
throw Error("Originating request context is no longer current"); } } : {})) {
|
|
13865
14337
|
respond(null, `Unknown tool: ${tool}`);
|
|
13866
14338
|
}
|
|
13867
14339
|
}
|
|
@@ -13967,6 +14439,9 @@ export class Daemon extends EventEmitter {
|
|
|
13967
14439
|
mcpEnv.AGEND_TOOL_SET = toolSet;
|
|
13968
14440
|
if (this.classicRestriction)
|
|
13969
14441
|
mcpEnv.AGEND_CLASSIC_ALLOWED_TOOLS = JSON.stringify(this.classicRestriction.allowedAgendTools);
|
|
14442
|
+
const helperLaunch = this.requestContextHelper?.environment();
|
|
14443
|
+
if (helperLaunch)
|
|
14444
|
+
mcpEnv.AGEND_LAUNCH_TOKEN = helperLaunch;
|
|
13970
14445
|
// The dashboard features the person switched off: out of the tool menu from this start (the fleet refuses them
|
|
13971
14446
|
// at once, whatever the menu still shows).
|
|
13972
14447
|
const dashboardOff = dashboardFeaturesOff(dashboardAccessOf(this.config));
|
|
@@ -14003,6 +14478,8 @@ export class Daemon extends EventEmitter {
|
|
|
14003
14478
|
}
|
|
14004
14479
|
catch { /* fallback to empty */ }
|
|
14005
14480
|
instructions = buildFleetInstructions({
|
|
14481
|
+
...(requestContextInstructionMode(this.requestContextPolicy) !== null && this.requestContextLifecycle && (!this.nativePaneLifecycle || this.nativePaneLifecycle.requestContextAvailable?.() === true)
|
|
14482
|
+
? { requestContextPolicyInstalled: true } : {}),
|
|
14006
14483
|
instanceName: this.name,
|
|
14007
14484
|
taskBoard: !dashboardOff.includes("task_board"),
|
|
14008
14485
|
workingDirectory: this.config.working_directory,
|
|
@@ -14020,6 +14497,8 @@ export class Daemon extends EventEmitter {
|
|
|
14020
14497
|
}
|
|
14021
14498
|
else {
|
|
14022
14499
|
instructions = buildFleetInstructions({
|
|
14500
|
+
...(requestContextInstructionMode(this.requestContextPolicy) !== null && this.requestContextLifecycle && (!this.nativePaneLifecycle || this.nativePaneLifecycle.requestContextAvailable?.() === true)
|
|
14501
|
+
? { requestContextPolicyInstalled: true } : {}),
|
|
14023
14502
|
instanceName: this.name,
|
|
14024
14503
|
taskBoard: !dashboardOff.includes("task_board"),
|
|
14025
14504
|
workingDirectory: this.config.working_directory,
|
|
@@ -14155,6 +14634,7 @@ export class Daemon extends EventEmitter {
|
|
|
14155
14634
|
this.humanReminderAttempts?.clear();
|
|
14156
14635
|
this.cliOomObservation = null;
|
|
14157
14636
|
this.spawnGeneration++;
|
|
14637
|
+
this.requestContextAdmission?.changed();
|
|
14158
14638
|
this.interactionObservation.reset(this.interactionOwner());
|
|
14159
14639
|
this.clearInteractionConfirmation();
|
|
14160
14640
|
this.inputTransientGuardGeneration = (this.backend?.getInputUnavailableTransients?.().length ?? 0) > 0
|
|
@@ -14536,6 +15016,8 @@ export class Daemon extends EventEmitter {
|
|
|
14536
15016
|
finally {
|
|
14537
15017
|
this.endSpawn();
|
|
14538
15018
|
}
|
|
15019
|
+
if (!resumedSuccessfully)
|
|
15020
|
+
this.requestContextNewWork("fresh");
|
|
14539
15021
|
return resumedSuccessfully;
|
|
14540
15022
|
}
|
|
14541
15023
|
/** The whole agent switch after a resume, on the monotonic clock (#906 §3). */
|
|
@@ -15003,6 +15485,7 @@ export class Daemon extends EventEmitter {
|
|
|
15003
15485
|
if (this.startupAborted)
|
|
15004
15486
|
return;
|
|
15005
15487
|
this.startupAborted = true;
|
|
15488
|
+
this.requestContextHelper?.revoke();
|
|
15006
15489
|
this.freezeRuntimeMonitors();
|
|
15007
15490
|
this.pendingIpcRequests.clear();
|
|
15008
15491
|
if (this.museUsageRelay) {
|
|
@@ -15429,6 +15912,7 @@ export class Daemon extends EventEmitter {
|
|
|
15429
15912
|
this.assertSessionOomAdmission();
|
|
15430
15913
|
admit();
|
|
15431
15914
|
const launchFence = this.launchFenceEpoch;
|
|
15915
|
+
const helperLaunch = this.requestContextHelper?.begin();
|
|
15432
15916
|
const backendConfig = this.buildBackendConfig(true);
|
|
15433
15917
|
if (this.classicRestrictionFailed)
|
|
15434
15918
|
throw Error("Restricted room policy is unavailable");
|
|
@@ -15558,20 +16042,42 @@ export class Daemon extends EventEmitter {
|
|
|
15558
16042
|
admit();
|
|
15559
16043
|
let windowId;
|
|
15560
16044
|
this.assertSessionOomAdmission();
|
|
15561
|
-
|
|
15562
|
-
|
|
15563
|
-
|
|
15564
|
-
|
|
16045
|
+
const retirementResources = this.requestContextStartupResources;
|
|
16046
|
+
if (retirementResources)
|
|
16047
|
+
retirementResources.pending++;
|
|
16048
|
+
try {
|
|
16049
|
+
if (reuseWindow) {
|
|
16050
|
+
this.controlClient?.unregisterWindow(this.tmux.getWindowId());
|
|
16051
|
+
await this.tmux.respawnWindow(cmd, resolvedCwd, repairAdmission ? admit : undefined);
|
|
16052
|
+
windowId = this.tmux.getWindowId();
|
|
16053
|
+
}
|
|
16054
|
+
else {
|
|
16055
|
+
// A crash respawn makes a brand new window. The dead one stays registered
|
|
16056
|
+
// unless we say so — the respawn branch above already does.
|
|
16057
|
+
const retired = this.tmux.getWindowId();
|
|
16058
|
+
windowId = await this.tmux.createWindow(cmd, resolvedCwd, this.name);
|
|
16059
|
+
if (retired && retired !== windowId)
|
|
16060
|
+
this.controlClient?.unregisterWindow(retired);
|
|
16061
|
+
}
|
|
16062
|
+
if (retirementResources) {
|
|
16063
|
+
const pid = await this.paneHost.getPanePid(this.tmuxSessionName, windowId);
|
|
16064
|
+
if (!pid || !Number.isSafeInteger(pid) || pid <= 1)
|
|
16065
|
+
throw Error("Request startup process identity unavailable");
|
|
16066
|
+
retirementResources.windows.push({ session: this.tmuxSessionName, window: windowId, pid });
|
|
16067
|
+
}
|
|
15565
16068
|
}
|
|
15566
|
-
|
|
15567
|
-
|
|
15568
|
-
|
|
15569
|
-
|
|
15570
|
-
|
|
15571
|
-
|
|
15572
|
-
|
|
16069
|
+
catch (error) {
|
|
16070
|
+
if (retirementResources)
|
|
16071
|
+
retirementResources.unknown = true;
|
|
16072
|
+
throw error;
|
|
16073
|
+
}
|
|
16074
|
+
finally {
|
|
16075
|
+
if (retirementResources)
|
|
16076
|
+
retirementResources.pending--;
|
|
15573
16077
|
}
|
|
15574
16078
|
admit();
|
|
16079
|
+
if (helperLaunch)
|
|
16080
|
+
this.requestContextHelper.confirm(helperLaunch);
|
|
15575
16081
|
this.writeWindowId(windowId);
|
|
15576
16082
|
// Enable remain-on-exit to capture exit codes on crash
|
|
15577
16083
|
await this.tmux.setRemainOnExit().catch(err => {
|