@adhdev/daemon-core 0.9.82-rc.43 → 0.9.82-rc.430
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/boot/daemon-lifecycle.d.ts +9 -0
- package/dist/boot/process-hardening.d.ts +50 -0
- package/dist/build-info.d.ts +37 -0
- package/dist/chat/source-machine.d.ts +166 -0
- package/dist/chat/source-resolver.d.ts +104 -0
- package/dist/chat/subscription-updates.d.ts +1 -0
- package/dist/cli-adapter-types.d.ts +68 -2
- package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
- package/dist/cli-adapters/cli-state-engine.d.ts +200 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +126 -64
- package/dist/cli-adapters/provider-cli-parse.d.ts +5 -0
- package/dist/cli-adapters/provider-cli-runtime.d.ts +34 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +74 -0
- package/dist/cli-adapters/pty-write-chunking.d.ts +34 -0
- package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
- package/dist/cli-adapters/resolve-executable.d.ts +69 -0
- package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +6 -3
- package/dist/cli-adapters/terminal-backends/types.d.ts +10 -2
- package/dist/cli-adapters/terminal-screen.d.ts +4 -11
- package/dist/commands/chat-commands-debug-bundle.d.ts +14 -0
- package/dist/commands/chat-commands-read.d.ts +7 -0
- package/dist/commands/chat-commands-scope.d.ts +39 -0
- package/dist/commands/chat-commands-shared.d.ts +33 -0
- package/dist/commands/chat-commands-write.d.ts +14 -0
- package/dist/commands/chat-commands.d.ts +10 -23
- package/dist/commands/cli-manager.d.ts +15 -1
- package/dist/commands/handler.d.ts +125 -0
- package/dist/commands/high-family/index.d.ts +3 -0
- package/dist/commands/high-family/mesh-coordinator-launch.d.ts +2 -0
- package/dist/commands/high-family/mesh-events.d.ts +2 -0
- package/dist/commands/high-family/mesh-status.d.ts +2 -0
- package/dist/commands/high-family/types.d.ts +60 -0
- package/dist/commands/low-family/coordinator-prompt.d.ts +9 -0
- package/dist/commands/low-family/daemon-lifecycle.d.ts +2 -0
- package/dist/commands/low-family/diagnostics.d.ts +2 -0
- package/dist/commands/low-family/index.d.ts +3 -0
- package/dist/commands/low-family/mesh-ledger.d.ts +10 -0
- package/dist/commands/low-family/mesh-node-logs.d.ts +2 -0
- package/dist/commands/low-family/notification.d.ts +2 -0
- package/dist/commands/low-family/refine-config.d.ts +2 -0
- package/dist/commands/low-family/session-host.d.ts +2 -0
- package/dist/commands/low-family/spec-providerdev.d.ts +11 -0
- package/dist/commands/low-family/status-meta.d.ts +2 -0
- package/dist/commands/low-family/types.d.ts +33 -0
- package/dist/commands/med-family/cli-agent.d.ts +2 -0
- package/dist/commands/med-family/fast-forward.d.ts +2 -0
- package/dist/commands/med-family/ide.d.ts +10 -0
- package/dist/commands/med-family/index.d.ts +3 -0
- package/dist/commands/med-family/mesh-crud.d.ts +29 -0
- package/dist/commands/med-family/mesh-host-pairing.d.ts +2 -0
- package/dist/commands/med-family/mesh-queue.d.ts +2 -0
- package/dist/commands/med-family/mesh-restart.d.ts +2 -0
- package/dist/commands/med-family/types.d.ts +142 -0
- package/dist/commands/mesh-coordinator.d.ts +85 -1
- package/dist/commands/router.d.ts +276 -2
- package/dist/commands/upgrade-helper.d.ts +41 -1
- package/dist/config/chat-history.d.ts +9 -0
- package/dist/config/config.d.ts +5 -0
- package/dist/config/mesh-config.d.ts +100 -1
- package/dist/config/mesh-json-config.d.ts +199 -0
- package/dist/config/repo-settings.d.ts +77 -0
- package/dist/daemon/dev-server.d.ts +0 -2
- package/dist/detection/ide-detector.d.ts +13 -0
- package/dist/detection/win32-ide-version.d.ts +37 -0
- package/dist/git/change-impact-config.d.ts +159 -0
- package/dist/git/git-commands.d.ts +11 -1
- package/dist/git/git-diff.d.ts +6 -0
- package/dist/git/git-executor.d.ts +11 -0
- package/dist/git/git-status.d.ts +57 -0
- package/dist/git/git-types.d.ts +2 -50
- package/dist/git/git-worktree.d.ts +71 -1
- package/dist/git/index.d.ts +3 -1
- package/dist/index.d.ts +64 -14
- package/dist/index.js +49391 -19228
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48574 -18570
- package/dist/index.mjs.map +1 -1
- package/dist/installer.d.ts +1 -4
- package/dist/ipc/local-ipc-server.d.ts +91 -0
- package/dist/launch.d.ts +1 -1
- package/dist/logging/async-batch-writer.d.ts +10 -0
- package/dist/logging/log-redactor.d.ts +24 -0
- package/dist/logging/log-tail-reader.d.ts +81 -0
- package/dist/logging/logger.d.ts +1 -1
- package/dist/mesh/contracts.d.ts +164 -0
- package/dist/mesh/coordinator-prompt.d.ts +89 -0
- package/dist/mesh/coordinator-registry.d.ts +59 -0
- package/dist/mesh/mesh-active-work.d.ts +174 -0
- package/dist/mesh/mesh-clone-grace.d.ts +8 -0
- package/dist/mesh/mesh-coordinator-config.d.ts +21 -0
- package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
- package/dist/mesh/mesh-event-classify.d.ts +5 -0
- package/dist/mesh/mesh-event-forwarding.d.ts +41 -0
- package/dist/mesh/mesh-event-trace.d.ts +21 -0
- package/dist/mesh/mesh-events-coordinator.d.ts +4 -0
- package/dist/mesh/mesh-events-pending.d.ts +69 -0
- package/dist/mesh/mesh-events-stale.d.ts +61 -0
- package/dist/mesh/mesh-events-utils.d.ts +75 -0
- package/dist/mesh/mesh-events.d.ts +6 -49
- package/dist/mesh/mesh-fast-forward.d.ts +81 -0
- package/dist/mesh/mesh-host-ownership.d.ts +9 -0
- package/dist/mesh/mesh-init.d.ts +86 -0
- package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -4
- package/dist/mesh/mesh-ledger.d.ts +77 -1
- package/dist/mesh/mesh-magi-status.d.ts +63 -0
- package/dist/mesh/mesh-missions.d.ts +189 -0
- package/dist/mesh/mesh-node-identity.d.ts +289 -0
- package/dist/mesh/mesh-queue-assignment.d.ts +113 -0
- package/dist/mesh/mesh-reconcile-loop.d.ts +65 -0
- package/dist/mesh/mesh-refine-batch.d.ts +68 -0
- package/dist/mesh/mesh-refine-gates.d.ts +428 -0
- package/dist/mesh/mesh-refine-status.d.ts +62 -0
- package/dist/mesh/mesh-review-inbox.d.ts +90 -0
- package/dist/mesh/mesh-routing.d.ts +70 -0
- package/dist/mesh/mesh-runtime-store.d.ts +450 -0
- package/dist/mesh/mesh-scheduling-runtime.d.ts +78 -0
- package/dist/mesh/mesh-task-inflight.d.ts +46 -0
- package/dist/mesh/mesh-task-stats.d.ts +49 -0
- package/dist/mesh/mesh-unresolved-forward-outbox.d.ts +30 -0
- package/dist/mesh/mesh-warmup-deadline.d.ts +68 -0
- package/dist/mesh/mesh-work-queue.d.ts +290 -5
- package/dist/mesh/preview-freshness.d.ts +18 -0
- package/dist/mesh/refine-config.d.ts +216 -0
- package/dist/mesh/worktree-bootstrap-config.d.ts +145 -0
- package/dist/providers/acp-provider-instance.d.ts +5 -0
- package/dist/providers/approval-utils.d.ts +20 -0
- package/dist/providers/chat-message-normalization.d.ts +31 -1
- package/dist/providers/cli-provider-instance.d.ts +221 -3
- package/dist/providers/contracts.d.ts +139 -6
- package/dist/providers/external-sources.d.ts +71 -0
- package/dist/providers/manual-attendance.d.ts +63 -0
- package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
- package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
- package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
- package/dist/providers/native-history/constants.d.ts +12 -0
- package/dist/providers/native-history/dispatcher.d.ts +27 -0
- package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
- package/dist/providers/native-history/index.d.ts +13 -0
- package/dist/providers/provider-instance-manager.d.ts +29 -0
- package/dist/providers/provider-instance.d.ts +23 -1
- package/dist/providers/provider-loader.d.ts +26 -4
- package/dist/providers/provider-trust.d.ts +31 -0
- package/dist/providers/read-chat-contract.d.ts +29 -0
- package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
- package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +86 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
- package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
- package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
- package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
- package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
- package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
- package/dist/providers/sdk/v1/index.d.ts +30 -0
- package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
- package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
- package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
- package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
- package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
- package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
- package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
- package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
- package/dist/providers/spec/adapter.d.ts +91 -0
- package/dist/providers/spec/cli-adapter.d.ts +223 -0
- package/dist/providers/spec/evaluator.d.ts +45 -0
- package/dist/providers/spec/fsm-driver.d.ts +422 -0
- package/dist/providers/spec/fsm-evaluator.d.ts +76 -0
- package/dist/providers/spec/fsm-loader.d.ts +14 -0
- package/dist/providers/spec/fsm-types.d.ts +174 -0
- package/dist/providers/spec/native-history-executor.d.ts +41 -0
- package/dist/providers/spec/pre-launch-trust.d.ts +16 -0
- package/dist/providers/spec/route.d.ts +4 -0
- package/dist/providers/spec/types.d.ts +222 -0
- package/dist/providers/status-monitor.d.ts +7 -7
- package/dist/providers/transcript-v2.d.ts +176 -0
- package/dist/providers/types/interactive-prompt.d.ts +84 -0
- package/dist/providers/working-dir.d.ts +17 -0
- package/dist/repo-mesh-types.d.ts +501 -13
- package/dist/runtime-defaults.d.ts +2 -0
- package/dist/sessions/registry.d.ts +6 -0
- package/dist/shared-types-extra.d.ts +2 -4
- package/dist/shared-types.d.ts +59 -2
- package/dist/status/normalize.d.ts +1 -1
- package/dist/status/normalize.js +1 -0
- package/dist/status/normalize.js.map +1 -1
- package/dist/status/normalize.mjs +1 -0
- package/dist/status/normalize.mjs.map +1 -1
- package/dist/status/reporter.d.ts +2 -0
- package/dist/status/snapshot.d.ts +26 -0
- package/dist/system/hash.d.ts +8 -0
- package/dist/system/load-better-sqlite3.d.ts +21 -0
- package/dist/types.d.ts +5 -0
- package/package.json +7 -3
- package/src/agent-stream/poller.ts +2 -3
- package/src/agent-stream/provider-adapter.ts +1 -1
- package/src/boot/daemon-lifecycle.ts +63 -12
- package/src/boot/process-hardening.ts +89 -0
- package/src/build-info.ts +73 -0
- package/src/chat/source-machine.ts +534 -0
- package/src/chat/source-resolver.ts +0 -0
- package/src/chat/subscription-updates.ts +20 -1
- package/src/cli-adapter-types.d.ts +3 -1
- package/src/cli-adapter-types.ts +68 -2
- package/src/cli-adapters/cli-script-runner.ts +421 -0
- package/src/cli-adapters/cli-state-engine.ts +1246 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +914 -1144
- package/src/cli-adapters/provider-cli-parse.d.ts +2 -0
- package/src/cli-adapters/provider-cli-parse.ts +19 -0
- package/src/cli-adapters/provider-cli-runtime.ts +56 -7
- package/src/cli-adapters/provider-cli-shared.d.ts +4 -0
- package/src/cli-adapters/provider-cli-shared.ts +121 -11
- package/src/cli-adapters/pty-transport.ts +2 -1
- package/src/cli-adapters/pty-write-chunking.ts +106 -0
- package/src/cli-adapters/raw-terminal-io.ts +252 -0
- package/src/cli-adapters/resolve-executable.ts +204 -0
- package/src/cli-adapters/session-host-transport.ts +2 -1
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +63 -29
- package/src/cli-adapters/terminal-backends/types.ts +10 -3
- package/src/cli-adapters/terminal-screen.ts +16 -81
- package/src/commands/WINDOWS-UPGRADE-LOCK-FAILURE.md +198 -0
- package/src/commands/chat-commands-debug-bundle.ts +398 -0
- package/src/commands/chat-commands-read.ts +2327 -0
- package/src/commands/chat-commands-scope.ts +54 -0
- package/src/commands/chat-commands-shared.ts +114 -0
- package/src/commands/chat-commands-write.ts +891 -0
- package/src/commands/chat-commands.ts +19 -1841
- package/src/commands/cli-manager.ts +544 -26
- package/src/commands/handler.ts +841 -2
- package/src/commands/high-family/index.ts +28 -0
- package/src/commands/high-family/mesh-coordinator-launch.ts +678 -0
- package/src/commands/high-family/mesh-events.ts +80 -0
- package/src/commands/high-family/mesh-status.ts +710 -0
- package/src/commands/high-family/types.ts +76 -0
- package/src/commands/low-family/coordinator-prompt.ts +72 -0
- package/src/commands/low-family/daemon-lifecycle.ts +107 -0
- package/src/commands/low-family/diagnostics.ts +57 -0
- package/src/commands/low-family/index.ts +37 -0
- package/src/commands/low-family/mesh-ledger.ts +62 -0
- package/src/commands/low-family/mesh-node-logs.ts +87 -0
- package/src/commands/low-family/notification.ts +116 -0
- package/src/commands/low-family/refine-config.ts +106 -0
- package/src/commands/low-family/session-host.ts +274 -0
- package/src/commands/low-family/spec-providerdev.ts +217 -0
- package/src/commands/low-family/status-meta.ts +112 -0
- package/src/commands/low-family/types.ts +39 -0
- package/src/commands/med-family/cli-agent.ts +238 -0
- package/src/commands/med-family/fast-forward.ts +230 -0
- package/src/commands/med-family/ide.ts +163 -0
- package/src/commands/med-family/index.ts +37 -0
- package/src/commands/med-family/mesh-crud.ts +1066 -0
- package/src/commands/med-family/mesh-host-pairing.ts +234 -0
- package/src/commands/med-family/mesh-queue.ts +167 -0
- package/src/commands/med-family/mesh-restart.ts +92 -0
- package/src/commands/med-family/types.ts +143 -0
- package/src/commands/mesh-coordinator.ts +334 -124
- package/src/commands/router.ts +2711 -3254
- package/src/commands/stream-commands.ts +8 -0
- package/src/commands/upgrade-helper.ts +310 -45
- package/src/config/chat-history.ts +483 -24
- package/src/config/config.ts +12 -0
- package/src/config/mesh-config.ts +495 -22
- package/src/config/mesh-json-config.ts +376 -0
- package/src/config/recent-activity.ts +8 -2
- package/src/config/repo-settings.ts +111 -0
- package/src/daemon/dev-auto-implement.ts +3 -2
- package/src/daemon/dev-cli-debug.ts +10 -1
- package/src/daemon/dev-server.ts +0 -541
- package/src/detection/cli-detector.ts +28 -9
- package/src/detection/ide-detector.ts +55 -16
- package/src/detection/win32-ide-version.ts +106 -0
- package/src/git/change-impact-config.ts +354 -0
- package/src/git/git-commands.ts +59 -15
- package/src/git/git-diff.ts +81 -11
- package/src/git/git-executor.ts +12 -0
- package/src/git/git-status.ts +767 -48
- package/src/git/git-types.ts +14 -62
- package/src/git/git-worktree.ts +261 -4
- package/src/git/index.ts +17 -0
- package/src/index.ts +194 -12
- package/src/installer.d.ts +1 -1
- package/src/installer.ts +8 -6
- package/src/ipc/local-ipc-server.ts +278 -0
- package/src/launch.d.ts +1 -1
- package/src/launch.ts +37 -28
- package/src/logging/async-batch-writer.ts +55 -0
- package/src/logging/command-log.ts +7 -5
- package/src/logging/log-redactor.ts +100 -0
- package/src/logging/log-tail-reader.ts +341 -0
- package/src/logging/logger.ts +14 -7
- package/src/mesh/contracts.ts +338 -0
- package/src/mesh/coordinator-prompt.ts +381 -33
- package/src/mesh/coordinator-registry.ts +121 -0
- package/src/mesh/mesh-active-work.ts +645 -0
- package/src/mesh/mesh-clone-grace.ts +68 -0
- package/src/mesh/mesh-coordinator-config.ts +97 -0
- package/src/mesh/mesh-delivery-policy.ts +315 -0
- package/src/mesh/mesh-event-classify.ts +51 -0
- package/src/mesh/mesh-event-forwarding.ts +1888 -0
- package/src/mesh/mesh-event-trace.ts +67 -0
- package/src/mesh/mesh-events-coordinator.ts +32 -0
- package/src/mesh/mesh-events-pending.ts +656 -0
- package/src/mesh/mesh-events-stale.ts +389 -0
- package/src/mesh/mesh-events-utils.ts +443 -0
- package/src/mesh/mesh-events.ts +33 -1035
- package/src/mesh/mesh-fast-forward.ts +843 -0
- package/src/mesh/mesh-host-ownership.ts +73 -0
- package/src/mesh/mesh-init.ts +260 -0
- package/src/mesh/mesh-ledger-reconciliation.ts +12 -7
- package/src/mesh/mesh-ledger.ts +656 -102
- package/src/mesh/mesh-magi-status.ts +223 -0
- package/src/mesh/mesh-missions.ts +449 -0
- package/src/mesh/mesh-node-identity.ts +1887 -0
- package/src/mesh/mesh-queue-assignment.ts +1918 -0
- package/src/mesh/mesh-reconcile-loop.ts +1780 -0
- package/src/mesh/mesh-refine-batch.ts +205 -0
- package/src/mesh/mesh-refine-gates.ts +1673 -0
- package/src/mesh/mesh-refine-status.ts +231 -0
- package/src/mesh/mesh-review-inbox.ts +307 -0
- package/src/mesh/mesh-routing.ts +291 -0
- package/src/mesh/mesh-runtime-store.ts +1853 -0
- package/src/mesh/mesh-scheduling-runtime.ts +198 -0
- package/src/mesh/mesh-task-inflight.ts +70 -0
- package/src/mesh/mesh-task-stats.ts +161 -0
- package/src/mesh/mesh-unresolved-forward-outbox.ts +185 -0
- package/src/mesh/mesh-warmup-deadline.ts +152 -0
- package/src/mesh/mesh-work-queue.ts +1243 -141
- package/src/mesh/preview-freshness.ts +118 -0
- package/src/mesh/refine-config.ts +423 -0
- package/src/mesh/worktree-bootstrap-config.ts +450 -0
- package/src/providers/acp-provider-instance.ts +43 -10
- package/src/providers/approval-utils.d.ts +5 -0
- package/src/providers/approval-utils.ts +57 -5
- package/src/providers/chat-message-normalization.ts +92 -4
- package/src/providers/cli-provider-instance.ts +1933 -104
- package/src/providers/contracts.d.ts +55 -0
- package/src/providers/contracts.ts +150 -6
- package/src/providers/extension-provider-instance.ts +12 -7
- package/src/providers/external-sources.ts +218 -0
- package/src/providers/ide-provider-instance.ts +35 -12
- package/src/providers/manual-attendance.ts +85 -0
- package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
- package/src/providers/native-history/claude-cli-transcript.ts +396 -0
- package/src/providers/native-history/codex-cli-transcript.ts +479 -0
- package/src/providers/native-history/constants.ts +19 -0
- package/src/providers/native-history/dispatcher.ts +339 -0
- package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
- package/src/providers/native-history/index.ts +30 -0
- package/src/providers/provider-instance-manager.ts +71 -0
- package/src/providers/provider-instance.ts +19 -1
- package/src/providers/provider-loader.ts +668 -50
- package/src/providers/provider-schema.ts +87 -14
- package/src/providers/provider-trust.ts +114 -0
- package/src/providers/read-chat-contract.ts +76 -16
- package/src/providers/sdk/README.md +49 -0
- package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
- package/src/providers/sdk/v1/builders/cli/detect-status.ts +313 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
- package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
- package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
- package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
- package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
- package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
- package/src/providers/sdk/v1/index.ts +152 -0
- package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
- package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
- package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
- package/src/providers/sdk/v1/schemas/cli/provider.schema.json +504 -0
- package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
- package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
- package/src/providers/sdk/v1/types/cli/index.ts +365 -0
- package/src/providers/sdk/v1/types/common/index.ts +229 -0
- package/src/providers/sdk/v1/validators/index.ts +19 -0
- package/src/providers/sdk/v1/validators/manifest.ts +110 -0
- package/src/providers/sdk/v1/validators/taint.ts +309 -0
- package/src/providers/spec/adapter.ts +235 -0
- package/src/providers/spec/cli-adapter.ts +1056 -0
- package/src/providers/spec/evaluator.ts +407 -0
- package/src/providers/spec/fsm-driver.ts +1410 -0
- package/src/providers/spec/fsm-evaluator.ts +272 -0
- package/src/providers/spec/fsm-loader.ts +120 -0
- package/src/providers/spec/fsm-types.ts +273 -0
- package/src/providers/spec/native-history-executor.ts +1128 -0
- package/src/providers/spec/pre-launch-trust.ts +104 -0
- package/src/providers/spec/route.ts +51 -0
- package/src/providers/spec/types.ts +262 -0
- package/src/providers/status-monitor.d.ts +7 -7
- package/src/providers/status-monitor.ts +37 -22
- package/src/providers/transcript-v2.ts +567 -0
- package/src/providers/types/interactive-prompt.ts +536 -0
- package/src/providers/version-archive.ts +64 -24
- package/src/providers/working-dir.ts +23 -0
- package/src/repo-mesh-types.ts +740 -14
- package/src/runtime-defaults.ts +39 -0
- package/src/sessions/registry.ts +6 -0
- package/src/shared-types-extra.ts +2 -4
- package/src/shared-types.d.ts +8 -0
- package/src/shared-types.ts +64 -1
- package/src/status/builders.ts +26 -6
- package/src/status/normalize.ts +2 -0
- package/src/status/reporter.ts +19 -1
- package/src/status/snapshot.ts +95 -26
- package/src/system/hash.ts +23 -0
- package/src/system/host-memory.ts +29 -12
- package/src/system/load-better-sqlite3.ts +68 -0
- package/src/types.ts +5 -0
- package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
- package/dist/mesh/mesh-sync.d.ts +0 -53
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
- package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
- package/src/mesh/mesh-sync.ts +0 -111
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER HIGH family — shared types for the extracted high-coupling command
|
|
3
|
+
* handlers. Like the LOW and MED families, each handler is a function of
|
|
4
|
+
* (context, args) that returns the exact CommandRouterResult the original
|
|
5
|
+
* `executeDaemonCommand` switch case returned, so the router facade is unchanged.
|
|
6
|
+
*
|
|
7
|
+
* HIGH handlers are the most router-coupled of the three families: in addition to
|
|
8
|
+
* the MED collaborators (mesh resolution, owner gating, inline-cache), they reach
|
|
9
|
+
* the router's aggregate-status memory cache and running-refine-job table — state
|
|
10
|
+
* the router owns and the `mesh_status` aggregate render and `get_mesh_review_inbox`
|
|
11
|
+
* re-entry both depend on. The router binds those onto HighFamilyContext at
|
|
12
|
+
* dispatch; they are NOT reachable from `deps`.
|
|
13
|
+
*
|
|
14
|
+
* Registry dispatch: DaemonCommandRouter.executeDaemonCommand looks up the cmd in
|
|
15
|
+
* highFamilyRegistry AFTER the LOW and MED registries and BEFORE its remaining
|
|
16
|
+
* switch; a hit returns the handler result, a miss falls through to the switch
|
|
17
|
+
* (and ultimately CommandHandler delegation).
|
|
18
|
+
*/
|
|
19
|
+
import type {
|
|
20
|
+
CommandRouterDeps,
|
|
21
|
+
CommandRouterResult,
|
|
22
|
+
MeshGitProbeCache,
|
|
23
|
+
MeshRefineJobHandle,
|
|
24
|
+
} from '../router.js';
|
|
25
|
+
import type { ResolvedMeshForCommand } from '../med-family/types.js';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Router-private collaborators injected at dispatch. Each is a bound method or
|
|
29
|
+
* field of DaemonCommandRouter; handlers that don't need a given collaborator
|
|
30
|
+
* simply ignore it. The router owns this instance state (inline-mesh cache,
|
|
31
|
+
* aggregate-status memory cache, running-refine-job table, git-probe cache), so
|
|
32
|
+
* it cannot be read from `deps` — the registry receives bound references instead.
|
|
33
|
+
*/
|
|
34
|
+
export interface HighFamilyContext {
|
|
35
|
+
deps: CommandRouterDeps;
|
|
36
|
+
|
|
37
|
+
/** Bound `DaemonCommandRouter.getMeshForCommand`. */
|
|
38
|
+
getMeshForCommand: (
|
|
39
|
+
meshId: string,
|
|
40
|
+
inlineMesh?: unknown,
|
|
41
|
+
options?: { preferInline?: boolean },
|
|
42
|
+
) => Promise<ResolvedMeshForCommand>;
|
|
43
|
+
|
|
44
|
+
/** Bound `DaemonCommandRouter.getCachedAggregateMeshStatus`. */
|
|
45
|
+
getCachedAggregateMeshStatus: (
|
|
46
|
+
meshId: string,
|
|
47
|
+
mesh?: any,
|
|
48
|
+
options?: { requireDirectPeerTruth?: boolean },
|
|
49
|
+
) => any | null;
|
|
50
|
+
|
|
51
|
+
/** Bound `DaemonCommandRouter.rememberAggregateMeshStatus`. */
|
|
52
|
+
rememberAggregateMeshStatus: (meshId: string, snapshot: any, refreshReason: string) => any;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Bound `DaemonCommandRouter.execute`. `get_mesh_review_inbox` re-enters the
|
|
56
|
+
* router with a `mesh_status` refresh to obtain computed node fields; this is
|
|
57
|
+
* the same self-call the inlined case made.
|
|
58
|
+
*/
|
|
59
|
+
execute: (cmd: string, args: any, source?: string) => Promise<CommandRouterResult>;
|
|
60
|
+
|
|
61
|
+
/** Router's aggregate-status memory cache (`.has()` probe in mesh_status). */
|
|
62
|
+
aggregateMeshStatusCache: Map<string, { builtAt: number; snapshot: any; queueRevision: string }>;
|
|
63
|
+
|
|
64
|
+
/** Router's running-refine-job table (surfaced as activeRefineJobs in mesh_status). */
|
|
65
|
+
runningRefineJobs: Map<string, MeshRefineJobHandle>;
|
|
66
|
+
|
|
67
|
+
/** Router's inline-mesh cache (launch_mesh_coordinator caches cloud inline mesh). */
|
|
68
|
+
inlineMeshCache: Map<string, any>;
|
|
69
|
+
|
|
70
|
+
/** Router's mesh git-probe cache (shared probe dedup for mesh_status). */
|
|
71
|
+
meshGitProbeCache: MeshGitProbeCache;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type HighFamilyHandler = (ctx: HighFamilyContext, args: any) => Promise<CommandRouterResult | null>;
|
|
75
|
+
|
|
76
|
+
export type HighFamilyRegistry = Map<string, HighFamilyHandler>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER LOW family — coordinator-prompt override/append file commands.
|
|
3
|
+
*
|
|
4
|
+
* Extracted verbatim from DaemonCommandRouter.executeDaemonCommand. Both handlers
|
|
5
|
+
* read/write only the on-disk ~/.adhdev/coordinator-prompts directory (no router
|
|
6
|
+
* instance state) and return the same CommandRouterResult the inlined cases did.
|
|
7
|
+
*/
|
|
8
|
+
import type { LowFamilyContext, LowFamilyHandler } from './types.js';
|
|
9
|
+
|
|
10
|
+
export const coordinatorPromptHandlers: Record<string, LowFamilyHandler> = {
|
|
11
|
+
list_coordinator_prompts: async (_ctx: LowFamilyContext, _args: any) => {
|
|
12
|
+
const fs = await import('node:fs');
|
|
13
|
+
const path = await import('node:path');
|
|
14
|
+
const os = await import('node:os');
|
|
15
|
+
const dir = path.join(os.homedir(), '.adhdev', 'coordinator-prompts');
|
|
16
|
+
const entries: Record<string, { override: string; append: string }> = {};
|
|
17
|
+
try {
|
|
18
|
+
if (fs.existsSync(dir)) {
|
|
19
|
+
for (const name of fs.readdirSync(dir)) {
|
|
20
|
+
// Bucket files into <key>.{md|append.md}; ignore others
|
|
21
|
+
// so a stray README or .DS_Store doesn't show up.
|
|
22
|
+
const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
|
|
23
|
+
const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
|
|
24
|
+
// append-pattern wins when both match (file is `.append.md`).
|
|
25
|
+
const m = matchAppend || matchOverride;
|
|
26
|
+
if (!m) continue;
|
|
27
|
+
const isAppend = !!matchAppend;
|
|
28
|
+
const key = m[1];
|
|
29
|
+
const full = path.join(dir, name);
|
|
30
|
+
let content = '';
|
|
31
|
+
try { content = fs.readFileSync(full, 'utf8'); } catch { /* skip */ }
|
|
32
|
+
if (!entries[key]) entries[key] = { override: '', append: '' };
|
|
33
|
+
if (isAppend) entries[key].append = content;
|
|
34
|
+
else entries[key].override = content;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
} catch (error: any) {
|
|
38
|
+
return { success: false, error: error?.message || String(error) };
|
|
39
|
+
}
|
|
40
|
+
return { success: true, dir, entries };
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
write_coordinator_prompt: async (_ctx: LowFamilyContext, args: any) => {
|
|
44
|
+
const fs = await import('node:fs');
|
|
45
|
+
const path = await import('node:path');
|
|
46
|
+
const os = await import('node:os');
|
|
47
|
+
const key = typeof args?.key === 'string' ? args.key.trim() : '';
|
|
48
|
+
const kind = args?.kind === 'append' ? 'append' : 'override';
|
|
49
|
+
const content = typeof args?.content === 'string' ? args.content : '';
|
|
50
|
+
// Whitelist key chars so a malicious caller can't write
|
|
51
|
+
// ../../etc/passwd. Same charset readUserPromptFile accepts.
|
|
52
|
+
if (!key || !/^[a-zA-Z0-9_.-]+$/.test(key)) {
|
|
53
|
+
return { success: false, error: 'key must match [a-zA-Z0-9_.-]+' };
|
|
54
|
+
}
|
|
55
|
+
const dir = path.join(os.homedir(), '.adhdev', 'coordinator-prompts');
|
|
56
|
+
const filename = kind === 'append' ? `${key}.append.md` : `${key}.md`;
|
|
57
|
+
const full = path.join(dir, filename);
|
|
58
|
+
try {
|
|
59
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
60
|
+
if (content.trim()) {
|
|
61
|
+
fs.writeFileSync(full, content, { encoding: 'utf8', mode: 0o600 });
|
|
62
|
+
} else if (fs.existsSync(full)) {
|
|
63
|
+
// Empty content = "reset to default" — delete the file
|
|
64
|
+
// so the daemon's readUserPromptFile path falls through.
|
|
65
|
+
fs.unlinkSync(full);
|
|
66
|
+
}
|
|
67
|
+
return { success: true, path: full, kind, key };
|
|
68
|
+
} catch (error: any) {
|
|
69
|
+
return { success: false, error: error?.message || String(error) };
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER LOW family — daemon self-upgrade + machine-settings commands.
|
|
3
|
+
*
|
|
4
|
+
* Extracted verbatim from DaemonCommandRouter.executeDaemonCommand. The
|
|
5
|
+
* release-channel helpers (ReleaseChannel / CHANNEL_* / normalizeReleaseChannel /
|
|
6
|
+
* resolveUpgradeChannel) were router module-locals used only by daemon_upgrade, so
|
|
7
|
+
* they are relocated here unchanged. Handlers read only ctx.deps.packageName /
|
|
8
|
+
* ctx.deps.statusVersion plus process-global config + npm/upgrade helpers, and
|
|
9
|
+
* return the same CommandRouterResult the inlined cases did.
|
|
10
|
+
*/
|
|
11
|
+
import { loadConfig, updateConfig } from '../../config/config.js';
|
|
12
|
+
import { execNpmCommandSync, resolveCurrentGlobalInstallSurface, spawnDetachedDaemonUpgradeHelper } from '../upgrade-helper.js';
|
|
13
|
+
import { LOG } from '../../logging/logger.js';
|
|
14
|
+
import type { LowFamilyContext, LowFamilyHandler } from './types.js';
|
|
15
|
+
|
|
16
|
+
type ReleaseChannel = 'stable' | 'preview';
|
|
17
|
+
const CHANNEL_NPM_TAG: Record<ReleaseChannel, 'latest' | 'next'> = { stable: 'latest', preview: 'next' };
|
|
18
|
+
const CHANNEL_SERVER_URL: Record<ReleaseChannel, string> = {
|
|
19
|
+
stable: 'https://api.adhf.dev',
|
|
20
|
+
preview: 'https://api-preview.adhf.dev',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function normalizeReleaseChannel(value: unknown): ReleaseChannel | null {
|
|
24
|
+
if (typeof value !== 'string') return null;
|
|
25
|
+
const normalized = value.trim().toLowerCase();
|
|
26
|
+
if (normalized === 'stable' || normalized === 'latest') return 'stable';
|
|
27
|
+
if (normalized === 'preview' || normalized === 'next') return 'preview';
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function resolveUpgradeChannel(args: any): ReleaseChannel {
|
|
32
|
+
return normalizeReleaseChannel(args?.channel)
|
|
33
|
+
|| normalizeReleaseChannel(args?.updatePolicy?.channel)
|
|
34
|
+
|| normalizeReleaseChannel(args?.npmTag)
|
|
35
|
+
|| normalizeReleaseChannel(loadConfig().updateChannel)
|
|
36
|
+
|| 'stable';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const daemonLifecycleHandlers: Record<string, LowFamilyHandler> = {
|
|
40
|
+
daemon_upgrade: async (ctx: LowFamilyContext, args: any) => {
|
|
41
|
+
LOG.info('Upgrade', 'Remote upgrade requested from dashboard');
|
|
42
|
+
try {
|
|
43
|
+
// Detect package name for upgrade
|
|
44
|
+
const isStandalone = ctx.deps.packageName === '@adhdev/daemon-standalone'
|
|
45
|
+
|| process.argv[1]?.includes('daemon-standalone');
|
|
46
|
+
const pkgName = isStandalone ? '@adhdev/daemon-standalone' : 'adhdev';
|
|
47
|
+
const npmSurface = resolveCurrentGlobalInstallSurface({ packageName: pkgName });
|
|
48
|
+
const channel = resolveUpgradeChannel(args);
|
|
49
|
+
const npmTag = CHANNEL_NPM_TAG[channel];
|
|
50
|
+
|
|
51
|
+
// Check channel-pinned dist-tag and resolve it to a concrete install version.
|
|
52
|
+
const latest = String(execNpmCommandSync(['view', `${pkgName}@${npmTag}`, 'version'], { encoding: 'utf-8', timeout: 10000 }, npmSurface)).trim();
|
|
53
|
+
LOG.info('Upgrade', `Latest ${pkgName}@${npmTag}: v${latest}`);
|
|
54
|
+
updateConfig({ updateChannel: channel, serverUrl: CHANNEL_SERVER_URL[channel] } as any);
|
|
55
|
+
let currentInstalled: string | null = null;
|
|
56
|
+
try {
|
|
57
|
+
const currentJson = String(execNpmCommandSync(['ls', '-g', pkgName, '--depth=0', '--json'], {
|
|
58
|
+
encoding: 'utf-8',
|
|
59
|
+
timeout: 10000,
|
|
60
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
61
|
+
}, npmSurface)).trim();
|
|
62
|
+
const parsed = JSON.parse(currentJson);
|
|
63
|
+
currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
|
|
64
|
+
} catch {
|
|
65
|
+
// ignore ls failures; upgrade can still proceed
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const runningVersion = typeof ctx.deps.statusVersion === 'string'
|
|
69
|
+
? ctx.deps.statusVersion.trim().replace(/^v/, '')
|
|
70
|
+
: null;
|
|
71
|
+
if (currentInstalled === latest && runningVersion === latest) {
|
|
72
|
+
LOG.info('Upgrade', `Already on ${channel} channel version v${latest}; skipping install`);
|
|
73
|
+
return { success: true, upgraded: false, alreadyLatest: true, version: latest, channel, npmTag };
|
|
74
|
+
}
|
|
75
|
+
if (currentInstalled === latest && runningVersion && runningVersion !== latest) {
|
|
76
|
+
LOG.info('Upgrade', `Installed package is v${latest}, but running daemon is v${runningVersion}; scheduling restart`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
spawnDetachedDaemonUpgradeHelper({
|
|
80
|
+
packageName: pkgName,
|
|
81
|
+
targetVersion: latest,
|
|
82
|
+
parentPid: process.pid,
|
|
83
|
+
restartArgv: process.argv.slice(1),
|
|
84
|
+
cwd: process.cwd(),
|
|
85
|
+
sessionHostAppName: process.env.ADHDEV_SESSION_HOST_NAME || 'adhdev',
|
|
86
|
+
});
|
|
87
|
+
LOG.info('Upgrade', `Scheduled detached ${channel} upgrade to v${latest}`);
|
|
88
|
+
|
|
89
|
+
// Exit after the command response has been sent so the helper can replace the package cleanly.
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
LOG.info('Upgrade', 'Exiting daemon so detached upgrader can continue...');
|
|
92
|
+
process.exit(0);
|
|
93
|
+
}, 3000);
|
|
94
|
+
|
|
95
|
+
return { success: true, upgraded: true, version: latest, restarting: true, channel, npmTag };
|
|
96
|
+
} catch (e: any) {
|
|
97
|
+
LOG.error('Upgrade', `Failed: ${e.message}`);
|
|
98
|
+
return { success: false, error: e.message };
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
set_machine_nickname: async (_ctx: LowFamilyContext, args: any) => {
|
|
103
|
+
const nickname = args?.nickname;
|
|
104
|
+
updateConfig({ machineNickname: nickname || null });
|
|
105
|
+
return { success: true };
|
|
106
|
+
},
|
|
107
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER LOW family — diagnostics read commands.
|
|
3
|
+
*
|
|
4
|
+
* Extracted verbatim from DaemonCommandRouter.executeDaemonCommand. Both handlers
|
|
5
|
+
* read only process-global logging buffers (ring buffer + file fallback + debug
|
|
6
|
+
* trace) — no router instance state — and return the same CommandRouterResult the
|
|
7
|
+
* inlined cases did.
|
|
8
|
+
*/
|
|
9
|
+
import * as fs from 'fs';
|
|
10
|
+
import { getRecentLogs, LOG_PATH } from '../../logging/logger.js';
|
|
11
|
+
import { getRecentDebugTrace } from '../../logging/debug-trace.js';
|
|
12
|
+
import type { LowFamilyContext, LowFamilyHandler } from './types.js';
|
|
13
|
+
|
|
14
|
+
export const diagnosticsHandlers: Record<string, LowFamilyHandler> = {
|
|
15
|
+
get_logs: async (_ctx: LowFamilyContext, args: any) => {
|
|
16
|
+
const count = parseInt(args?.count) || parseInt(args?.lines) || 100;
|
|
17
|
+
const minLevel = args?.minLevel || 'info';
|
|
18
|
+
const sinceTs = args?.since || 0;
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
// Priority 1: ring buffer (fast and structured)
|
|
22
|
+
let logs = getRecentLogs(count, minLevel);
|
|
23
|
+
if (sinceTs > 0) {
|
|
24
|
+
logs = logs.filter((l: any) => l.ts > sinceTs);
|
|
25
|
+
}
|
|
26
|
+
if (logs.length > 0) {
|
|
27
|
+
return { success: true, logs, totalBuffered: logs.length };
|
|
28
|
+
}
|
|
29
|
+
// Incremental polling must not fall back to unfiltered file text: the file
|
|
30
|
+
// format is not timestamp-filterable, and returning its tail makes the UI
|
|
31
|
+
// replace structured logs with old raw fallback lines when nothing new exists.
|
|
32
|
+
if (sinceTs > 0) {
|
|
33
|
+
return { success: true, logs: [], totalBuffered: 0 };
|
|
34
|
+
}
|
|
35
|
+
// Priority 2: file fallback
|
|
36
|
+
if (fs.existsSync(LOG_PATH)) {
|
|
37
|
+
const content = fs.readFileSync(LOG_PATH, 'utf-8');
|
|
38
|
+
const allLines = content.split('\n');
|
|
39
|
+
const recent = allLines.slice(-count).join('\n');
|
|
40
|
+
return { success: true, logs: recent, totalLines: allLines.length };
|
|
41
|
+
}
|
|
42
|
+
return { success: true, logs: [], totalBuffered: 0 };
|
|
43
|
+
} catch (e: any) {
|
|
44
|
+
return { success: false, error: e.message };
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
get_debug_trace: async (_ctx: LowFamilyContext, args: any) => {
|
|
49
|
+
const count = parseInt(args?.count) || parseInt(args?.limit) || 100;
|
|
50
|
+
const sinceTs = Number(args?.since) || 0;
|
|
51
|
+
const interactionId = typeof args?.interactionId === 'string' ? args.interactionId : undefined;
|
|
52
|
+
const category = typeof args?.category === 'string' ? args.category : undefined;
|
|
53
|
+
const trace = getRecentDebugTrace({ interactionId, category, limit: count })
|
|
54
|
+
.filter((entry) => !sinceTs || entry.ts > sinceTs);
|
|
55
|
+
return { success: true, trace, count: trace.length };
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER LOW family — command registry.
|
|
3
|
+
*
|
|
4
|
+
* Aggregates the low-coupling command handlers extracted from
|
|
5
|
+
* DaemonCommandRouter.executeDaemonCommand into a single cmd → handler map.
|
|
6
|
+
* The router consults this registry before its switch (registry hit → return the
|
|
7
|
+
* handler result; miss → fall through to the remaining switch / CommandHandler
|
|
8
|
+
* delegation), so the facade and dispatch semantics are unchanged.
|
|
9
|
+
*/
|
|
10
|
+
import { sessionHostHandlers } from './session-host.js';
|
|
11
|
+
import { specProviderDevHandlers } from './spec-providerdev.js';
|
|
12
|
+
import { refineConfigHandlers } from './refine-config.js';
|
|
13
|
+
import { diagnosticsHandlers } from './diagnostics.js';
|
|
14
|
+
import { statusMetaHandlers } from './status-meta.js';
|
|
15
|
+
import { coordinatorPromptHandlers } from './coordinator-prompt.js';
|
|
16
|
+
import { notificationHandlers } from './notification.js';
|
|
17
|
+
import { daemonLifecycleHandlers } from './daemon-lifecycle.js';
|
|
18
|
+
import { meshLedgerHandlers } from './mesh-ledger.js';
|
|
19
|
+
import { meshNodeLogsHandlers } from './mesh-node-logs.js';
|
|
20
|
+
import type { LowFamilyRegistry } from './types.js';
|
|
21
|
+
|
|
22
|
+
export type { LowFamilyContext, LowFamilyHandler, LowFamilyRegistry } from './types.js';
|
|
23
|
+
|
|
24
|
+
export const lowFamilyRegistry: LowFamilyRegistry = new Map(
|
|
25
|
+
Object.entries({
|
|
26
|
+
...sessionHostHandlers,
|
|
27
|
+
...specProviderDevHandlers,
|
|
28
|
+
...refineConfigHandlers,
|
|
29
|
+
...diagnosticsHandlers,
|
|
30
|
+
...statusMetaHandlers,
|
|
31
|
+
...coordinatorPromptHandlers,
|
|
32
|
+
...notificationHandlers,
|
|
33
|
+
...daemonLifecycleHandlers,
|
|
34
|
+
...meshLedgerHandlers,
|
|
35
|
+
...meshNodeLogsHandlers,
|
|
36
|
+
}),
|
|
37
|
+
);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER LOW family — mesh ledger read / slice / import commands.
|
|
3
|
+
*
|
|
4
|
+
* Extracted verbatim from DaemonCommandRouter.executeDaemonCommand. Each handler
|
|
5
|
+
* touches only the on-disk mesh ledger (dynamically imported mesh-ledger module)
|
|
6
|
+
* keyed by meshId — no router instance state — and returns the same
|
|
7
|
+
* CommandRouterResult the inlined cases did.
|
|
8
|
+
*/
|
|
9
|
+
import type { LowFamilyContext, LowFamilyHandler } from './types.js';
|
|
10
|
+
|
|
11
|
+
export const meshLedgerHandlers: Record<string, LowFamilyHandler> = {
|
|
12
|
+
get_mesh_ledger: async (_ctx: LowFamilyContext, args: any) => {
|
|
13
|
+
const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
|
|
14
|
+
if (!meshId) return { success: false, error: 'meshId required' };
|
|
15
|
+
try {
|
|
16
|
+
const { readLedgerEntries, getLedgerSummary } = await import('../../mesh/mesh-ledger.js');
|
|
17
|
+
const tail = typeof args?.tail === 'number' ? args.tail : 20;
|
|
18
|
+
const since = typeof args?.since === 'string' ? args.since : undefined;
|
|
19
|
+
const kind = Array.isArray(args?.kind) ? args.kind.filter((k: any) => typeof k === 'string') : undefined;
|
|
20
|
+
const entries = readLedgerEntries(meshId, { tail, since, kind });
|
|
21
|
+
const summary = getLedgerSummary(meshId);
|
|
22
|
+
return { success: true, entries, summary };
|
|
23
|
+
} catch (e: any) {
|
|
24
|
+
return { success: false, error: e.message };
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
get_mesh_ledger_slice: async (_ctx: LowFamilyContext, args: any) => {
|
|
29
|
+
const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
|
|
30
|
+
if (!meshId) return { success: false, error: 'meshId required' };
|
|
31
|
+
try {
|
|
32
|
+
const { readLedgerSlice } = await import('../../mesh/mesh-ledger.js');
|
|
33
|
+
const kind = Array.isArray(args?.kind) ? args.kind.filter((k: any) => typeof k === 'string') : undefined;
|
|
34
|
+
const slice = readLedgerSlice(meshId, {
|
|
35
|
+
afterId: typeof args?.afterId === 'string' ? args.afterId : undefined,
|
|
36
|
+
since: typeof args?.since === 'string' ? args.since : undefined,
|
|
37
|
+
kind,
|
|
38
|
+
limit: typeof args?.limit === 'number' ? args.limit : undefined,
|
|
39
|
+
});
|
|
40
|
+
return { success: true, slice };
|
|
41
|
+
} catch (e: any) {
|
|
42
|
+
return { success: false, error: e.message };
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
import_mesh_ledger_slice: async (_ctx: LowFamilyContext, args: any) => {
|
|
47
|
+
const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
|
|
48
|
+
if (!meshId) return { success: false, error: 'meshId required' };
|
|
49
|
+
try {
|
|
50
|
+
const { appendRemoteLedgerEntries, getLedgerSummary } = await import('../../mesh/mesh-ledger.js');
|
|
51
|
+
const entries = Array.isArray(args?.entries)
|
|
52
|
+
? args.entries as any[]
|
|
53
|
+
: Array.isArray(args?.slice?.entries)
|
|
54
|
+
? args.slice.entries as any[]
|
|
55
|
+
: [];
|
|
56
|
+
const result = appendRemoteLedgerEntries(meshId, entries as any);
|
|
57
|
+
return { success: true, result, summary: getLedgerSummary(meshId) };
|
|
58
|
+
} catch (e: any) {
|
|
59
|
+
return { success: false, error: e.message };
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER LOW family — coordinator-driven remote daemon log fetch.
|
|
3
|
+
*
|
|
4
|
+
* Extracted verbatim from DaemonCommandRouter.executeDaemonCommand. Unlike the
|
|
5
|
+
* other LOW handlers this one resolves a node's owning daemonId from the router's
|
|
6
|
+
* inline-mesh cache, so it consumes the router-bound `ctx.getMeshForCommand`
|
|
7
|
+
* helper (mesh state is router instance state, not reconstructable from deps). The
|
|
8
|
+
* forward/local-read/redact logic is otherwise unchanged; returns the same
|
|
9
|
+
* CommandRouterResult the inlined case did.
|
|
10
|
+
*/
|
|
11
|
+
import { daemonIdsEquivalent, meshNodeIdMatches } from '@adhdev/mesh-shared';
|
|
12
|
+
import { readDaemonLogTail, MAX_TAIL_BYTES } from '../../logging/log-tail-reader.js';
|
|
13
|
+
import { redactLogLines } from '../../logging/log-redactor.js';
|
|
14
|
+
import type { CommandRouterResult } from '../router.js';
|
|
15
|
+
import type { LowFamilyContext, LowFamilyHandler } from './types.js';
|
|
16
|
+
|
|
17
|
+
export const meshNodeLogsHandlers: Record<string, LowFamilyHandler> = {
|
|
18
|
+
get_mesh_node_logs: async (ctx: LowFamilyContext, args: any) => {
|
|
19
|
+
// Coordinator-driven remote log fetch: read a (possibly remote)
|
|
20
|
+
// daemon's recent log tail over P2P instead of opening a session
|
|
21
|
+
// and grepping the file by hand. Mirrors fast_forward_mesh_node's
|
|
22
|
+
// forward pattern — resolve the node, forward to its owning daemon
|
|
23
|
+
// when remote, otherwise read locally. The reply tail is HARD
|
|
24
|
+
// byte-bounded and secret-redacted before it leaves the machine.
|
|
25
|
+
const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
|
|
26
|
+
const nodeId = typeof args?.nodeId === 'string' ? args.nodeId.trim() : '';
|
|
27
|
+
let nodeDaemonId: string | undefined;
|
|
28
|
+
if (meshId && nodeId && ctx.getMeshForCommand) {
|
|
29
|
+
const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
30
|
+
const node = meshRecord?.mesh?.nodes?.find((n: any) => meshNodeIdMatches(n, nodeId));
|
|
31
|
+
nodeDaemonId = typeof node?.daemonId === 'string' ? node.daemonId.trim() : undefined;
|
|
32
|
+
}
|
|
33
|
+
// _meshDirectDispatch prevents re-forwarding (and P2P self-dial)
|
|
34
|
+
// once the call lands on the owning daemon — that daemon then reads
|
|
35
|
+
// its own logs even if the stored daemonId uses a legacy form.
|
|
36
|
+
const selfDaemonId = ctx.deps.statusInstanceId;
|
|
37
|
+
// daemonIdsEquivalent: a legacy-form daemonId resolving to this machine's core is
|
|
38
|
+
// local — read locally instead of forwarding. Equivalent → local.
|
|
39
|
+
const isRemote = nodeDaemonId && selfDaemonId && !daemonIdsEquivalent(nodeDaemonId, selfDaemonId);
|
|
40
|
+
if (isRemote && ctx.deps.dispatchMeshCommand && !args?._meshDirectDispatch) {
|
|
41
|
+
const forwarded = await ctx.deps.dispatchMeshCommand(nodeDaemonId!, 'get_mesh_node_logs', {
|
|
42
|
+
...(typeof args === 'object' && args !== null ? args as Record<string, unknown> : {}),
|
|
43
|
+
_meshDirectDispatch: true,
|
|
44
|
+
});
|
|
45
|
+
return (forwarded ?? { success: false, error: 'no response from remote node' }) as CommandRouterResult;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Local read on the owning daemon.
|
|
49
|
+
const rawTailBytes = Number(args?.tailBytes);
|
|
50
|
+
const tail = readDaemonLogTail({
|
|
51
|
+
date: typeof args?.date === 'string' ? args.date : undefined,
|
|
52
|
+
tailBytes: Number.isFinite(rawTailBytes) ? Math.min(rawTailBytes, MAX_TAIL_BYTES) : undefined,
|
|
53
|
+
grep: typeof args?.grep === 'string' ? args.grep : undefined,
|
|
54
|
+
sinceMs: Number.isFinite(Number(args?.sinceMs)) ? Number(args?.sinceMs) : undefined,
|
|
55
|
+
});
|
|
56
|
+
if (!tail.success) {
|
|
57
|
+
return {
|
|
58
|
+
success: false,
|
|
59
|
+
error: tail.error || 'failed to read daemon log tail',
|
|
60
|
+
nodeId,
|
|
61
|
+
logPath: tail.logPath,
|
|
62
|
+
platform: tail.platform,
|
|
63
|
+
} as CommandRouterResult;
|
|
64
|
+
}
|
|
65
|
+
// SECURITY: redact secrets from every line before returning over P2P.
|
|
66
|
+
const redactedLines = redactLogLines(tail.lines);
|
|
67
|
+
return {
|
|
68
|
+
success: true,
|
|
69
|
+
nodeId,
|
|
70
|
+
daemonId: selfDaemonId,
|
|
71
|
+
logPath: tail.logPath,
|
|
72
|
+
platform: tail.platform,
|
|
73
|
+
lines: redactedLines,
|
|
74
|
+
lineCount: redactedLines.length,
|
|
75
|
+
truncated: tail.truncated,
|
|
76
|
+
filtered: tail.filtered,
|
|
77
|
+
bytesReturned: tail.bytesReturned,
|
|
78
|
+
// Transparency meta — lets the coordinator see that a full-file grep
|
|
79
|
+
// ran past the recent tail window, and how much was scanned/excluded.
|
|
80
|
+
fullScan: tail.fullScan,
|
|
81
|
+
scannedBytes: tail.scannedBytes,
|
|
82
|
+
matchedLineCount: tail.matchedLineCount,
|
|
83
|
+
excludedByFilter: tail.excludedByFilter,
|
|
84
|
+
...(tail.grep ? { grep: tail.grep } : {}),
|
|
85
|
+
} as CommandRouterResult;
|
|
86
|
+
},
|
|
87
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER LOW family — session notification / seen-state commands.
|
|
3
|
+
*
|
|
4
|
+
* Extracted verbatim from DaemonCommandRouter.executeDaemonCommand. Each handler
|
|
5
|
+
* mutates only the persisted recent-activity state store (loadState/saveState) and
|
|
6
|
+
* fires ctx.deps.onStatusChange; session lookup is rebuilt from deps the router
|
|
7
|
+
* already holds. Returns the same CommandRouterResult the inlined cases did.
|
|
8
|
+
*/
|
|
9
|
+
import { loadState, saveState } from '../../config/state-store.js';
|
|
10
|
+
import { markSessionSeen, dismissSessionNotification, markSessionNotificationUnread } from '../../config/recent-activity.js';
|
|
11
|
+
import { buildSessionEntries } from '../../status/builders.js';
|
|
12
|
+
import { getSessionCompletionMarker } from '../../status/snapshot.js';
|
|
13
|
+
import { LOG } from '../../logging/logger.js';
|
|
14
|
+
import type { LowFamilyContext, LowFamilyHandler } from './types.js';
|
|
15
|
+
|
|
16
|
+
const READ_DEBUG_ENABLED = process.argv.includes('--dev') || process.env.ADHDEV_READ_DEBUG === '1';
|
|
17
|
+
|
|
18
|
+
export const notificationHandlers: Record<string, LowFamilyHandler> = {
|
|
19
|
+
mark_session_seen: async (ctx: LowFamilyContext, args: any) => {
|
|
20
|
+
const sessionId = args?.sessionId;
|
|
21
|
+
if (!sessionId || typeof sessionId !== 'string') {
|
|
22
|
+
return { success: false, error: 'sessionId is required' };
|
|
23
|
+
}
|
|
24
|
+
const currentState = loadState();
|
|
25
|
+
const prevSeenAt = currentState.sessionReads?.[sessionId] || 0;
|
|
26
|
+
const sessionEntries = buildSessionEntries(
|
|
27
|
+
ctx.deps.instanceManager.collectAllStates(),
|
|
28
|
+
ctx.deps.cdpManagers,
|
|
29
|
+
);
|
|
30
|
+
const targetSession = sessionEntries.find((entry) => entry.id === sessionId);
|
|
31
|
+
const requestedCompletionMarker = typeof args?.completionMarker === 'string'
|
|
32
|
+
? args.completionMarker.trim()
|
|
33
|
+
: '';
|
|
34
|
+
const completionMarker = requestedCompletionMarker || (targetSession ? getSessionCompletionMarker(targetSession) : '');
|
|
35
|
+
const requestedProviderSessionId = typeof args?.providerSessionId === 'string'
|
|
36
|
+
? args.providerSessionId.trim()
|
|
37
|
+
: '';
|
|
38
|
+
const providerSessionId = requestedProviderSessionId || targetSession?.providerSessionId;
|
|
39
|
+
const next = markSessionSeen(
|
|
40
|
+
currentState,
|
|
41
|
+
sessionId,
|
|
42
|
+
typeof args?.seenAt === 'number' ? args.seenAt : Date.now(),
|
|
43
|
+
completionMarker,
|
|
44
|
+
providerSessionId,
|
|
45
|
+
);
|
|
46
|
+
if (READ_DEBUG_ENABLED) {
|
|
47
|
+
LOG.info('RecentRead', `mark_session_seen sessionId=${sessionId} seenAt=${String(args?.seenAt || '')} prevSeenAt=${String(prevSeenAt)} nextSeenAt=${String(next.sessionReads?.[sessionId] || 0)} marker=${completionMarker || '-'}`);
|
|
48
|
+
}
|
|
49
|
+
saveState(next);
|
|
50
|
+
ctx.deps.onStatusChange?.();
|
|
51
|
+
return {
|
|
52
|
+
success: true,
|
|
53
|
+
sessionId,
|
|
54
|
+
seenAt: next.sessionReads?.[sessionId] || Date.now(),
|
|
55
|
+
completionMarker,
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
delete_notification: async (ctx: LowFamilyContext, args: any) => {
|
|
60
|
+
const sessionId = args?.sessionId;
|
|
61
|
+
const notificationId = typeof args?.notificationId === 'string' ? args.notificationId.trim() : '';
|
|
62
|
+
if (!sessionId || typeof sessionId !== 'string') {
|
|
63
|
+
return { success: false, error: 'sessionId is required' };
|
|
64
|
+
}
|
|
65
|
+
if (!notificationId) {
|
|
66
|
+
return { success: false, error: 'notificationId is required' };
|
|
67
|
+
}
|
|
68
|
+
const sessionEntries = buildSessionEntries(
|
|
69
|
+
ctx.deps.instanceManager.collectAllStates(),
|
|
70
|
+
ctx.deps.cdpManagers,
|
|
71
|
+
);
|
|
72
|
+
const targetSession = sessionEntries.find((entry) => entry.id === sessionId);
|
|
73
|
+
const next = dismissSessionNotification(
|
|
74
|
+
loadState(),
|
|
75
|
+
sessionId,
|
|
76
|
+
notificationId,
|
|
77
|
+
targetSession?.providerSessionId,
|
|
78
|
+
);
|
|
79
|
+
saveState(next);
|
|
80
|
+
ctx.deps.onStatusChange?.();
|
|
81
|
+
return {
|
|
82
|
+
success: true,
|
|
83
|
+
sessionId,
|
|
84
|
+
notificationId,
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
mark_notification_unread: async (ctx: LowFamilyContext, args: any) => {
|
|
89
|
+
const sessionId = args?.sessionId;
|
|
90
|
+
const notificationId = typeof args?.notificationId === 'string' ? args.notificationId.trim() : '';
|
|
91
|
+
if (!sessionId || typeof sessionId !== 'string') {
|
|
92
|
+
return { success: false, error: 'sessionId is required' };
|
|
93
|
+
}
|
|
94
|
+
if (!notificationId) {
|
|
95
|
+
return { success: false, error: 'notificationId is required' };
|
|
96
|
+
}
|
|
97
|
+
const sessionEntries = buildSessionEntries(
|
|
98
|
+
ctx.deps.instanceManager.collectAllStates(),
|
|
99
|
+
ctx.deps.cdpManagers,
|
|
100
|
+
);
|
|
101
|
+
const targetSession = sessionEntries.find((entry) => entry.id === sessionId);
|
|
102
|
+
const next = markSessionNotificationUnread(
|
|
103
|
+
loadState(),
|
|
104
|
+
sessionId,
|
|
105
|
+
notificationId,
|
|
106
|
+
targetSession?.providerSessionId,
|
|
107
|
+
);
|
|
108
|
+
saveState(next);
|
|
109
|
+
ctx.deps.onStatusChange?.();
|
|
110
|
+
return {
|
|
111
|
+
success: true,
|
|
112
|
+
sessionId,
|
|
113
|
+
notificationId,
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
};
|