@adhdev/daemon-core 0.9.82-rc.49 → 0.9.82-rc.490
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 +220 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +137 -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 +23 -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 +71 -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 +64 -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 +48 -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 +152 -0
- package/dist/commands/mesh-coordinator.d.ts +85 -1
- package/dist/commands/router-aggregate-status.d.ts +24 -0
- package/dist/commands/router-mesh-session-owner.d.ts +59 -0
- package/dist/commands/router-refine.d.ts +151 -0
- package/dist/commands/router-worktree-cleanup.d.ts +133 -0
- package/dist/commands/router.d.ts +203 -15
- package/dist/commands/upgrade-helper.d.ts +41 -1
- package/dist/config/chat-history.d.ts +11 -0
- package/dist/config/config.d.ts +19 -0
- package/dist/config/mesh-config.d.ts +65 -0
- package/dist/config/mesh-json-config.d.ts +199 -0
- package/dist/config/registry-resolver.d.ts +54 -0
- package/dist/config/repo-settings.d.ts +77 -0
- package/dist/config/state-store.d.ts +30 -0
- package/dist/daemon/dev-server.d.ts +0 -2
- package/dist/detection/cli-detector.d.ts +17 -0
- 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 +26 -2
- 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 +80 -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 +70 -17
- package/dist/index.js +53532 -19073
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53283 -18989
- 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/debug-config.d.ts +16 -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 +256 -0
- package/dist/mesh/coordinator-prompt.d.ts +76 -0
- package/dist/mesh/coordinator-registry.d.ts +59 -0
- package/dist/mesh/mesh-active-work.d.ts +203 -0
- package/dist/mesh/mesh-clone-grace.d.ts +8 -0
- package/dist/mesh/mesh-completion-synthesis.d.ts +4 -0
- package/dist/mesh/mesh-coordinator-config.d.ts +21 -0
- package/dist/mesh/mesh-delivery-policy.d.ts +104 -0
- package/dist/mesh/mesh-event-classify.d.ts +7 -0
- package/dist/mesh/mesh-event-forwarding.d.ts +58 -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 +258 -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 +21 -1
- package/dist/mesh/mesh-init.d.ts +128 -0
- package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -4
- package/dist/mesh/mesh-ledger.d.ts +139 -1
- package/dist/mesh/mesh-magi-status.d.ts +63 -0
- package/dist/mesh/mesh-missions.d.ts +281 -0
- package/dist/mesh/mesh-node-identity.d.ts +310 -0
- package/dist/mesh/mesh-queue-assignment.d.ts +162 -0
- package/dist/mesh/mesh-reconcile-acked-hold.d.ts +17 -0
- package/dist/mesh/mesh-reconcile-config.d.ts +6 -0
- package/dist/mesh/mesh-reconcile-identity.d.ts +6 -0
- package/dist/mesh/mesh-reconcile-loop.d.ts +84 -0
- package/dist/mesh/mesh-reconcile-v2-backstop.d.ts +16 -0
- package/dist/mesh/mesh-refine-batch.d.ts +68 -0
- package/dist/mesh/mesh-refine-gates.d.ts +457 -0
- package/dist/mesh/mesh-refine-status.d.ts +62 -0
- package/dist/mesh/mesh-remote-event-pull.d.ts +15 -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 +567 -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 +34 -0
- package/dist/mesh/mesh-warmup-deadline.d.ts +68 -0
- package/dist/mesh/mesh-work-queue.d.ts +392 -1
- package/dist/mesh/preview-freshness.d.ts +28 -0
- package/dist/mesh/refine-config.d.ts +97 -0
- package/dist/mesh/worktree-bootstrap-config.d.ts +219 -0
- package/dist/providers/acp-provider-instance.d.ts +5 -0
- package/dist/providers/approval-utils.d.ts +46 -0
- package/dist/providers/chat-message-normalization.d.ts +58 -1
- package/dist/providers/cli-provider-effect-format.d.ts +30 -0
- package/dist/providers/cli-provider-history-dedup.d.ts +17 -0
- package/dist/providers/cli-provider-input-prompt.d.ts +12 -0
- package/dist/providers/cli-provider-instance-types.d.ts +45 -0
- package/dist/providers/cli-provider-instance.d.ts +426 -30
- package/dist/providers/cli-provider-status-helpers.d.ts +46 -0
- package/dist/providers/cli-provider-transcript-merge.d.ts +7 -0
- package/dist/providers/contracts.d.ts +196 -6
- package/dist/providers/external-sources.d.ts +71 -0
- package/dist/providers/manual-attendance.d.ts +79 -0
- package/dist/providers/native-history/antigravity-claim-registry.d.ts +39 -0
- package/dist/providers/native-history/antigravity-cli-transcript.d.ts +137 -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 +44 -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 +30 -0
- package/dist/providers/provider-instance.d.ts +31 -1
- package/dist/providers/provider-loader.d.ts +42 -5
- 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 +98 -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 +449 -0
- package/dist/providers/spec/fsm-evaluator.d.ts +93 -0
- package/dist/providers/spec/fsm-loader.d.ts +14 -0
- package/dist/providers/spec/fsm-types.d.ts +202 -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 +244 -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 +616 -12
- package/dist/runtime-defaults.d.ts +2 -0
- package/dist/session-host/managed-host.d.ts +64 -0
- package/dist/session-host/runtime-surface.d.ts +10 -16
- package/dist/sessions/registry.d.ts +26 -0
- package/dist/shared-types-extra.d.ts +2 -4
- package/dist/shared-types.d.ts +110 -55
- package/dist/status/chat-tail-hot-sessions.d.ts +40 -0
- 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 +27 -0
- package/dist/system/hash.d.ts +8 -0
- package/dist/system/load-better-sqlite3.d.ts +21 -0
- package/dist/types.d.ts +20 -6
- package/package.json +11 -4
- package/src/agent-stream/poller.ts +2 -3
- package/src/agent-stream/provider-adapter.ts +1 -1
- package/src/boot/daemon-lifecycle.ts +80 -14
- 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 +1282 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +1048 -1143
- 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/chat-commands-debug-bundle.ts +398 -0
- package/src/commands/chat-commands-read.ts +2788 -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.d.ts +2 -0
- package/src/commands/cli-manager.ts +724 -27
- package/src/commands/handler.ts +865 -2
- package/src/commands/high-family/index.ts +28 -0
- package/src/commands/high-family/mesh-coordinator-launch.ts +696 -0
- package/src/commands/high-family/mesh-events.ts +102 -0
- package/src/commands/high-family/mesh-status.ts +857 -0
- package/src/commands/high-family/types.ts +80 -0
- package/src/commands/low-family/coordinator-prompt.ts +125 -0
- package/src/commands/low-family/daemon-lifecycle.ts +120 -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 +282 -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 +270 -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 +1268 -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 +153 -0
- package/src/commands/mesh-coordinator.ts +334 -124
- package/src/commands/router-aggregate-status.ts +209 -0
- package/src/commands/router-mesh-session-owner.ts +114 -0
- package/src/commands/router-refine.ts +1794 -0
- package/src/commands/router-worktree-cleanup.ts +870 -0
- package/src/commands/router.ts +567 -4149
- package/src/commands/stream-commands.ts +8 -0
- package/src/commands/upgrade-helper.ts +310 -45
- package/src/config/chat-history.ts +517 -24
- package/src/config/config.ts +30 -0
- package/src/config/mesh-config.ts +300 -24
- package/src/config/mesh-json-config.ts +376 -0
- package/src/config/recent-activity.ts +8 -2
- package/src/config/registry-resolver.ts +100 -0
- package/src/config/repo-settings.ts +111 -0
- package/src/config/state-store.ts +55 -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 +94 -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 +112 -16
- package/src/git/git-diff.ts +81 -11
- package/src/git/git-executor.ts +12 -0
- package/src/git/git-status.ts +822 -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 +190 -13
- 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/debug-config.ts +25 -0
- package/src/logging/debug-trace.ts +7 -2
- 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 +510 -0
- package/src/mesh/coordinator-prompt.ts +627 -34
- package/src/mesh/coordinator-registry.ts +121 -0
- package/src/mesh/mesh-active-work.ts +706 -0
- package/src/mesh/mesh-clone-grace.ts +68 -0
- package/src/mesh/mesh-completion-synthesis.ts +416 -0
- package/src/mesh/mesh-coordinator-config.ts +97 -0
- package/src/mesh/mesh-delivery-policy.ts +284 -0
- package/src/mesh/mesh-event-classify.ts +78 -0
- package/src/mesh/mesh-event-forwarding.ts +2030 -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 +1548 -0
- package/src/mesh/mesh-events-stale.ts +452 -0
- package/src/mesh/mesh-events-utils.ts +443 -0
- package/src/mesh/mesh-events.ts +43 -1035
- package/src/mesh/mesh-fast-forward.ts +856 -0
- package/src/mesh/mesh-host-ownership.ts +41 -3
- package/src/mesh/mesh-init.ts +350 -0
- package/src/mesh/mesh-ledger-reconciliation.ts +12 -7
- package/src/mesh/mesh-ledger.ts +897 -102
- package/src/mesh/mesh-magi-status.ts +223 -0
- package/src/mesh/mesh-missions.ts +695 -0
- package/src/mesh/mesh-node-identity.ts +2065 -0
- package/src/mesh/mesh-queue-assignment.ts +2498 -0
- package/src/mesh/mesh-reconcile-acked-hold.ts +230 -0
- package/src/mesh/mesh-reconcile-config.ts +66 -0
- package/src/mesh/mesh-reconcile-identity.ts +103 -0
- package/src/mesh/mesh-reconcile-loop.ts +1696 -0
- package/src/mesh/mesh-reconcile-v2-backstop.ts +62 -0
- package/src/mesh/mesh-refine-batch.ts +205 -0
- package/src/mesh/mesh-refine-gates.ts +1792 -0
- package/src/mesh/mesh-refine-status.ts +231 -0
- package/src/mesh/mesh-remote-event-pull.ts +279 -0
- package/src/mesh/mesh-review-inbox.ts +308 -0
- package/src/mesh/mesh-routing.ts +291 -0
- package/src/mesh/mesh-runtime-store.ts +2292 -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 +215 -0
- package/src/mesh/mesh-warmup-deadline.ts +152 -0
- package/src/mesh/mesh-work-queue.ts +1489 -145
- package/src/mesh/preview-freshness.ts +163 -0
- package/src/mesh/refine-config.ts +129 -12
- package/src/mesh/worktree-bootstrap-config.ts +599 -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 +100 -6
- package/src/providers/chat-message-normalization.ts +126 -4
- package/src/providers/cli-provider-effect-format.ts +53 -0
- package/src/providers/cli-provider-history-dedup.ts +75 -0
- package/src/providers/cli-provider-input-prompt.ts +133 -0
- package/src/providers/cli-provider-instance-types.ts +131 -0
- package/src/providers/cli-provider-instance.ts +2771 -499
- package/src/providers/cli-provider-status-helpers.ts +123 -0
- package/src/providers/cli-provider-transcript-merge.ts +114 -0
- package/src/providers/contracts.d.ts +55 -0
- package/src/providers/contracts.ts +207 -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 +105 -0
- package/src/providers/native-history/antigravity-claim-registry.ts +138 -0
- package/src/providers/native-history/antigravity-cli-transcript.ts +1275 -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 +617 -0
- package/src/providers/native-history/hermes-cli-transcript.ts +312 -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 +24 -1
- package/src/providers/provider-loader.ts +700 -55
- package/src/providers/provider-schema.ts +93 -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 +261 -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 +538 -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 +246 -0
- package/src/providers/spec/cli-adapter.ts +1064 -0
- package/src/providers/spec/evaluator.ts +407 -0
- package/src/providers/spec/fsm-driver.ts +1528 -0
- package/src/providers/spec/fsm-evaluator.ts +290 -0
- package/src/providers/spec/fsm-loader.ts +128 -0
- package/src/providers/spec/fsm-types.ts +301 -0
- package/src/providers/spec/native-history-executor.ts +1241 -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 +284 -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 +861 -14
- package/src/runtime-defaults.ts +39 -0
- package/src/session-host/managed-host.ts +218 -0
- package/src/session-host/runtime-surface.ts +20 -80
- package/src/sessions/registry.ts +44 -0
- package/src/shared-types-extra.ts +2 -4
- package/src/shared-types.d.ts +8 -0
- package/src/shared-types.ts +148 -55
- package/src/status/builders.ts +69 -6
- package/src/status/chat-tail-hot-sessions.ts +117 -2
- package/src/status/normalize.ts +2 -0
- package/src/status/reporter.ts +19 -1
- package/src/status/snapshot.ts +100 -27
- 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 +26 -6
- 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
package/src/launch.ts
CHANGED
|
@@ -16,7 +16,16 @@
|
|
|
16
16
|
* adhdev launch --workspace /path — Open specific workspace
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import {
|
|
19
|
+
import { exec, spawn, spawnSync } from 'child_process';
|
|
20
|
+
|
|
21
|
+
async function execQuiet(command: string, options: any = {}): Promise<string> {
|
|
22
|
+
return new Promise((resolve) => {
|
|
23
|
+
exec(command, options, (error, stdout) => {
|
|
24
|
+
if (error) return resolve('');
|
|
25
|
+
resolve(stdout.toString());
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
20
29
|
import * as net from 'net';
|
|
21
30
|
import * as os from 'os';
|
|
22
31
|
import * as path from 'path';
|
|
@@ -76,11 +85,11 @@ function getIdePathCandidates(ideId: string): string[] {
|
|
|
76
85
|
return getProviderLoader().getIdePathCandidates(ideId);
|
|
77
86
|
}
|
|
78
87
|
|
|
79
|
-
function getMacAppProcessPids(ideId: string): number[] {
|
|
88
|
+
async function getMacAppProcessPids(ideId: string): Promise<number[]> {
|
|
80
89
|
const appPaths = getIdePathCandidates(ideId);
|
|
81
90
|
if (appPaths.length === 0) return [];
|
|
82
91
|
try {
|
|
83
|
-
const output =
|
|
92
|
+
const output = await execQuiet('ps axww -o pid=,args=', {
|
|
84
93
|
encoding: 'utf-8',
|
|
85
94
|
timeout: 3000,
|
|
86
95
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
@@ -91,8 +100,8 @@ function getMacAppProcessPids(ideId: string): number[] {
|
|
|
91
100
|
}
|
|
92
101
|
}
|
|
93
102
|
|
|
94
|
-
function killMacAppPathProcesses(ideId: string, signal: NodeJS.Signals): boolean {
|
|
95
|
-
const pids = getMacAppProcessPids(ideId);
|
|
103
|
+
async function killMacAppPathProcesses(ideId: string, signal: NodeJS.Signals): Promise<boolean> {
|
|
104
|
+
const pids = (await getMacAppProcessPids(ideId));
|
|
96
105
|
let signalled = false;
|
|
97
106
|
for (const pid of pids) {
|
|
98
107
|
try {
|
|
@@ -163,49 +172,49 @@ export async function killIdeProcess(ideId: string): Promise<boolean> {
|
|
|
163
172
|
if (plat === 'darwin' && appName) {
|
|
164
173
|
// macOS: graceful quit via osascript
|
|
165
174
|
try {
|
|
166
|
-
|
|
175
|
+
await execQuiet(`osascript -e 'tell application "${escapeForAppleScript(appName)}" to quit' 2>/dev/null`, {
|
|
167
176
|
timeout: 5000,
|
|
168
177
|
});
|
|
169
178
|
} catch {
|
|
170
|
-
try {
|
|
179
|
+
try { await execQuiet(`pkill -x "${appName}" 2>/dev/null`, { timeout: 5000 }); } catch { }
|
|
171
180
|
}
|
|
172
|
-
killMacAppPathProcesses(ideId, 'SIGTERM');
|
|
181
|
+
await killMacAppPathProcesses(ideId, 'SIGTERM');
|
|
173
182
|
} else if (plat === 'win32' && winProcesses) {
|
|
174
183
|
// Windows: taskkill for each process name
|
|
175
184
|
for (const proc of winProcesses) {
|
|
176
185
|
try {
|
|
177
|
-
|
|
186
|
+
await execQuiet(`taskkill /IM "${proc}" /F 2>nul`, { timeout: 5000 });
|
|
178
187
|
} catch { }
|
|
179
188
|
}
|
|
180
189
|
// Process name may differ, so also try via WMIC
|
|
181
190
|
try {
|
|
182
191
|
const exeName = winProcesses[0].replace('.exe', '');
|
|
183
|
-
|
|
192
|
+
await execQuiet(`powershell -Command "Get-Process -Name '${exeName}' -ErrorAction SilentlyContinue | Stop-Process -Force"`, {
|
|
184
193
|
timeout: 10000,
|
|
185
194
|
});
|
|
186
195
|
} catch { }
|
|
187
196
|
} else {
|
|
188
|
-
try {
|
|
197
|
+
try { await execQuiet(`pkill -f "${ideId}" 2>/dev/null`); } catch { }
|
|
189
198
|
}
|
|
190
199
|
|
|
191
200
|
// Wait for process kill (max 15 seconds)
|
|
192
201
|
for (let i = 0; i < 30; i++) {
|
|
193
202
|
await new Promise(r => setTimeout(r, 500));
|
|
194
|
-
if (!isIdeRunning(ideId)) return true;
|
|
203
|
+
if (!(await isIdeRunning(ideId))) return true;
|
|
195
204
|
}
|
|
196
205
|
|
|
197
206
|
// Force terminate retry
|
|
198
207
|
if (plat === 'darwin' && appName) {
|
|
199
|
-
try {
|
|
200
|
-
killMacAppPathProcesses(ideId, 'SIGKILL');
|
|
208
|
+
try { await execQuiet(`pkill -9 -x "${appName}" 2>/dev/null`, { timeout: 5000 }); } catch { }
|
|
209
|
+
await killMacAppPathProcesses(ideId, 'SIGKILL');
|
|
201
210
|
} else if (plat === 'win32' && winProcesses) {
|
|
202
211
|
for (const proc of winProcesses) {
|
|
203
|
-
try {
|
|
212
|
+
try { await execQuiet(`taskkill /IM "${proc}" /F 2>nul`); } catch { }
|
|
204
213
|
}
|
|
205
214
|
}
|
|
206
215
|
|
|
207
216
|
await new Promise(r => setTimeout(r, 2000));
|
|
208
|
-
return !isIdeRunning(ideId);
|
|
217
|
+
return !(await isIdeRunning(ideId));
|
|
209
218
|
|
|
210
219
|
} catch {
|
|
211
220
|
return false;
|
|
@@ -213,15 +222,15 @@ export async function killIdeProcess(ideId: string): Promise<boolean> {
|
|
|
213
222
|
}
|
|
214
223
|
|
|
215
224
|
/** Check if IDE process is running */
|
|
216
|
-
export function isIdeRunning(ideId: string): boolean {
|
|
225
|
+
export async function isIdeRunning(ideId: string): Promise<boolean> {
|
|
217
226
|
const plat = os.platform();
|
|
218
227
|
|
|
219
228
|
try {
|
|
220
229
|
if (plat === 'darwin') {
|
|
221
230
|
const appName = getMacAppIdentifiers()[ideId];
|
|
222
|
-
if (!appName) return getMacAppProcessPids(ideId).length > 0;
|
|
231
|
+
if (!appName) return (await getMacAppProcessPids(ideId)).length > 0;
|
|
223
232
|
try {
|
|
224
|
-
const result =
|
|
233
|
+
const result = await execQuiet(`pgrep -x "${appName}" 2>/dev/null`, {
|
|
225
234
|
encoding: 'utf-8',
|
|
226
235
|
timeout: 3000,
|
|
227
236
|
});
|
|
@@ -229,7 +238,7 @@ export function isIdeRunning(ideId: string): boolean {
|
|
|
229
238
|
} catch { }
|
|
230
239
|
|
|
231
240
|
try {
|
|
232
|
-
const result =
|
|
241
|
+
const result = await execQuiet(
|
|
233
242
|
`osascript -e 'tell application "System Events" to count (every process whose name is "${escapeForAppleScript(appName)}")'`,
|
|
234
243
|
{
|
|
235
244
|
encoding: 'utf-8',
|
|
@@ -240,21 +249,21 @@ export function isIdeRunning(ideId: string): boolean {
|
|
|
240
249
|
if (Number.parseInt(result.trim() || '0', 10) > 0) return true;
|
|
241
250
|
} catch { }
|
|
242
251
|
|
|
243
|
-
return getMacAppProcessPids(ideId).length > 0;
|
|
252
|
+
return (await getMacAppProcessPids(ideId)).length > 0;
|
|
244
253
|
} else if (plat === 'win32') {
|
|
245
254
|
const winProcesses = getWinProcessNames()[ideId];
|
|
246
255
|
if (!winProcesses) return false;
|
|
247
256
|
// Check each process name
|
|
248
257
|
for (const proc of winProcesses) {
|
|
249
258
|
try {
|
|
250
|
-
const result =
|
|
259
|
+
const result = await execQuiet(`tasklist /FI "IMAGENAME eq ${proc}" /NH 2>nul`, { encoding: 'utf-8' });
|
|
251
260
|
if (result.includes(proc)) return true;
|
|
252
261
|
} catch { }
|
|
253
262
|
}
|
|
254
263
|
// Also check via PowerShell (when tasklist cannot find)
|
|
255
264
|
try {
|
|
256
265
|
const exeName = winProcesses[0].replace('.exe', '');
|
|
257
|
-
const result =
|
|
266
|
+
const result = await execQuiet(
|
|
258
267
|
`powershell -Command "(Get-Process -Name '${exeName}' -ErrorAction SilentlyContinue).Count"`,
|
|
259
268
|
{ encoding: 'utf-8', timeout: 5000 }
|
|
260
269
|
);
|
|
@@ -262,7 +271,7 @@ export function isIdeRunning(ideId: string): boolean {
|
|
|
262
271
|
} catch { }
|
|
263
272
|
return false;
|
|
264
273
|
} else {
|
|
265
|
-
const result =
|
|
274
|
+
const result = await execQuiet(`pgrep -f "${ideId}" 2>/dev/null`, { encoding: 'utf-8' });
|
|
266
275
|
return result.trim().length > 0;
|
|
267
276
|
}
|
|
268
277
|
} catch {
|
|
@@ -271,14 +280,14 @@ export function isIdeRunning(ideId: string): boolean {
|
|
|
271
280
|
}
|
|
272
281
|
|
|
273
282
|
/** Detect currently open workspace path */
|
|
274
|
-
function detectCurrentWorkspace(ideId: string): string | undefined {
|
|
283
|
+
async function detectCurrentWorkspace(ideId: string): Promise<string | undefined> {
|
|
275
284
|
const plat = os.platform();
|
|
276
285
|
|
|
277
286
|
if (plat === 'darwin') {
|
|
278
287
|
try {
|
|
279
288
|
const appName = getMacAppIdentifiers()[ideId];
|
|
280
289
|
if (!appName) return undefined;
|
|
281
|
-
const result =
|
|
290
|
+
const result = await execQuiet(
|
|
282
291
|
`lsof -c "${appName}" 2>/dev/null | grep cwd | head -1 | awk '{print $NF}'`,
|
|
283
292
|
{ encoding: 'utf-8', timeout: 3000 }
|
|
284
293
|
);
|
|
@@ -392,8 +401,8 @@ export async function launchWithCdp(options: LaunchOptions = {}): Promise<Launch
|
|
|
392
401
|
}
|
|
393
402
|
|
|
394
403
|
// 4. Check if IDE is currently running
|
|
395
|
-
const alreadyRunning = isIdeRunning(targetIde.id);
|
|
396
|
-
const workspace = options.workspace || (alreadyRunning ? detectCurrentWorkspace(targetIde.id) : undefined);
|
|
404
|
+
const alreadyRunning = await isIdeRunning(targetIde.id);
|
|
405
|
+
const workspace = options.workspace || (alreadyRunning ? await detectCurrentWorkspace(targetIde.id) : undefined);
|
|
397
406
|
|
|
398
407
|
// 5. If IDE is running, terminate it
|
|
399
408
|
if (alreadyRunning) {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
|
|
3
|
+
export class AsyncBatchWriter {
|
|
4
|
+
// Maps filePath -> string buffer
|
|
5
|
+
private static buffers: Map<string, string[]> = new Map();
|
|
6
|
+
private static writePromises: Map<string, Promise<void>> = new Map();
|
|
7
|
+
private static flushTimer: NodeJS.Timeout | null = null;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Queues data to be written to a file asynchronously in a batch.
|
|
11
|
+
*/
|
|
12
|
+
public static write(filePath: string, data: string) {
|
|
13
|
+
let buf = this.buffers.get(filePath);
|
|
14
|
+
if (!buf) {
|
|
15
|
+
buf = [];
|
|
16
|
+
this.buffers.set(filePath, buf);
|
|
17
|
+
}
|
|
18
|
+
buf.push(data);
|
|
19
|
+
|
|
20
|
+
if (!this.flushTimer) {
|
|
21
|
+
this.flushTimer = setTimeout(() => {
|
|
22
|
+
this.flushTimer = null;
|
|
23
|
+
this.flushAll();
|
|
24
|
+
}, 50);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private static async flushAll() {
|
|
29
|
+
const entries = Array.from(this.buffers.entries());
|
|
30
|
+
this.buffers.clear();
|
|
31
|
+
|
|
32
|
+
for (const [filePath, buffer] of entries) {
|
|
33
|
+
const dataToWrite = buffer.join('');
|
|
34
|
+
|
|
35
|
+
const doWrite = async () => {
|
|
36
|
+
try {
|
|
37
|
+
const prevPromise = this.writePromises.get(filePath);
|
|
38
|
+
if (prevPromise) await prevPromise;
|
|
39
|
+
await fs.promises.appendFile(filePath, dataToWrite, { encoding: 'utf-8', mode: 0o600 });
|
|
40
|
+
} catch {
|
|
41
|
+
// Logging must never create secondary failures or late console noise.
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const writePromise = doWrite();
|
|
46
|
+
this.writePromises.set(filePath, writePromise);
|
|
47
|
+
|
|
48
|
+
writePromise.finally(() => {
|
|
49
|
+
if (this.writePromises.get(filePath) === writePromise) {
|
|
50
|
+
this.writePromises.delete(filePath);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -15,11 +15,13 @@ import * as path from 'path';
|
|
|
15
15
|
import * as os from 'os';
|
|
16
16
|
|
|
17
17
|
// ─── Config ──────────────────────────────────
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
// Command history lives under the unified ADHDev home (~/.adhdev/logs/) next to
|
|
19
|
+
// the daemon log, on every platform. Honor ADHDEV_CONFIG_DIR for isolated homes.
|
|
20
|
+
// Keep this in sync with logger.ts LOG_DIR.
|
|
21
|
+
const ADHDEV_HOME = process.env.ADHDEV_CONFIG_DIR && process.env.ADHDEV_CONFIG_DIR.trim()
|
|
22
|
+
? process.env.ADHDEV_CONFIG_DIR.trim()
|
|
23
|
+
: path.join(os.homedir(), '.adhdev');
|
|
24
|
+
const LOG_DIR = path.join(ADHDEV_HOME, 'logs');
|
|
23
25
|
|
|
24
26
|
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
|
|
25
27
|
const MAX_DAYS = 7;
|
|
@@ -20,6 +20,26 @@ export interface DebugRuntimeConfig {
|
|
|
20
20
|
const NORMAL_TRACE_BUFFER_SIZE = 200
|
|
21
21
|
const DEV_TRACE_BUFFER_SIZE = 1000
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* ALWAYS-ON trace categories. These bypass the `collectDebugTrace` master switch
|
|
25
|
+
* (and category selection) so they are collected in production daemons where
|
|
26
|
+
* `--trace` is unset. They exist so mesh completion diagnostics — the FSM-transition
|
|
27
|
+
* and completion-gate snapshots that explain an early / missing agent:generating_completed
|
|
28
|
+
* notification — are retrievable via mesh_read_debug (chat_debug_bundle) without asking
|
|
29
|
+
* an operator to relaunch the daemon with tracing on.
|
|
30
|
+
*
|
|
31
|
+
* SAFETY: only add a category here after confirming every record() call site for it
|
|
32
|
+
* carries a content-free payload (statuses, epochs, timestamps, deltas, lengths, roles,
|
|
33
|
+
* enum-like reasons — never transcript / prompt / bubble text). Always-on collection makes
|
|
34
|
+
* such payloads unconditional, so a content-bearing field would leak into the ring buffer
|
|
35
|
+
* in production.
|
|
36
|
+
*/
|
|
37
|
+
export const ALWAYS_ON_TRACE_CATEGORIES: readonly string[] = ['completion-gate', 'fsm-transition']
|
|
38
|
+
|
|
39
|
+
export function isAlwaysOnTraceCategory(category?: string | null): boolean {
|
|
40
|
+
return !!category && ALWAYS_ON_TRACE_CATEGORIES.includes(category)
|
|
41
|
+
}
|
|
42
|
+
|
|
23
43
|
const DEFAULT_CONFIG: DebugRuntimeConfig = {
|
|
24
44
|
logLevel: 'info',
|
|
25
45
|
collectDebugTrace: false,
|
|
@@ -68,6 +88,11 @@ export function resetDebugRuntimeConfig(): void {
|
|
|
68
88
|
|
|
69
89
|
export function shouldCollectTraceCategory(category?: string | null): boolean {
|
|
70
90
|
const config = currentConfig
|
|
91
|
+
// Always-on categories are collected regardless of the collectDebugTrace master switch
|
|
92
|
+
// and regardless of any explicit traceCategories selection (they form a superset on top of
|
|
93
|
+
// whatever the operator requested), so an explicit --trace / --trace-categories run still
|
|
94
|
+
// includes them with its existing behavior unchanged.
|
|
95
|
+
if (isAlwaysOnTraceCategory(category)) return true
|
|
71
96
|
if (!config.collectDebugTrace) return false
|
|
72
97
|
if (!category) return true
|
|
73
98
|
if (config.traceCategories.length === 0) return true
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDebugRuntimeConfig, shouldCollectTraceCategory } from './debug-config.js'
|
|
1
|
+
import { getDebugRuntimeConfig, isAlwaysOnTraceCategory, shouldCollectTraceCategory } from './debug-config.js'
|
|
2
2
|
|
|
3
3
|
export type DebugTraceLevel = 'debug' | 'info' | 'warn' | 'error'
|
|
4
4
|
|
|
@@ -80,7 +80,12 @@ export function createDebugTraceStore(options: DebugTraceStoreOptions): DebugTra
|
|
|
80
80
|
|
|
81
81
|
return {
|
|
82
82
|
record(event: DebugTraceEvent): DebugTraceEntry | null {
|
|
83
|
-
|
|
83
|
+
// The store's `enabled` flag mirrors collectDebugTrace (set by configureDebugTraceStore),
|
|
84
|
+
// so it is false on a production daemon. Always-on categories must still land in the ring
|
|
85
|
+
// even then — otherwise the second gate here would swallow what shouldCollectTraceCategory
|
|
86
|
+
// just admitted. They share the same fixed-capacity buffer, so heavy always-on traffic can
|
|
87
|
+
// evict older opt-in entries; that is accepted (no separate ring).
|
|
88
|
+
if (!options.enabled && !isAlwaysOnTraceCategory(event.category)) return null
|
|
84
89
|
const entry = createEntry(event)
|
|
85
90
|
entries.push(entry)
|
|
86
91
|
if (entries.length > capacity) {
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log redactor — mask secrets before a raw daemon log line leaves the machine.
|
|
3
|
+
*
|
|
4
|
+
* Daemon logs can incidentally contain credentials: ADHDev API keys (adk_*),
|
|
5
|
+
* machine secrets (adm_*), provider keys (adp_*), bearer tokens, JWTs, TURN
|
|
6
|
+
* `username:credential` pairs, and `SECRET=...` style env dumps. The mesh
|
|
7
|
+
* `get_mesh_node_logs` command ships a log tail over P2P to the coordinator, so
|
|
8
|
+
* every line MUST pass through redactLogLine() first — otherwise a secret in a
|
|
9
|
+
* remote daemon's log is exfiltrated to whoever is driving the coordinator.
|
|
10
|
+
*
|
|
11
|
+
* Patterns are intentionally conservative: each masks the secret material while
|
|
12
|
+
* preserving enough surrounding shape that the line stays useful for debugging
|
|
13
|
+
* (e.g. `adk_••••1234`, `Bearer ••••redacted`). When in doubt, mask.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const MASK = '••••redacted';
|
|
17
|
+
|
|
18
|
+
/** Keep the last 4 chars of a token so logs stay correlatable without leaking it. */
|
|
19
|
+
function maskKeepTail(token: string): string {
|
|
20
|
+
if (token.length <= 8) return MASK;
|
|
21
|
+
return `${MASK}${token.slice(-4)}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface RedactionRule {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly pattern: RegExp;
|
|
27
|
+
readonly replace: (match: string, ...groups: string[]) => string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// NOTE: order matters — more specific rules (key=value, Bearer, TURN) run before
|
|
31
|
+
// the bare-token rules so the structured forms aren't half-masked by a greedy
|
|
32
|
+
// generic rule.
|
|
33
|
+
const RULES: RedactionRule[] = [
|
|
34
|
+
// `JWT_SECRET=...`, `TOKEN=...`, `API_KEY=...`, `password: ...` env/config dumps.
|
|
35
|
+
// Captures the key + delimiter and masks only the value.
|
|
36
|
+
{
|
|
37
|
+
name: 'key_value_secret',
|
|
38
|
+
pattern: /\b([A-Z0-9_]*(?:SECRET|TOKEN|API[_-]?KEY|PASSWORD|PASSWD|PRIVATE[_-]?KEY|CREDENTIAL|CLIENT[_-]?SECRET)[A-Z0-9_]*)(\s*[:=]\s*)(["']?)([^\s"',;]+)\3/gi,
|
|
39
|
+
replace: (_m, key: string, delim: string, quote: string) => `${key}${delim}${quote}${MASK}${quote}`,
|
|
40
|
+
},
|
|
41
|
+
// Authorization: Bearer <token>
|
|
42
|
+
{
|
|
43
|
+
name: 'bearer_token',
|
|
44
|
+
pattern: /\b(Bearer\s+)([A-Za-z0-9._\-+/=]{8,})/g,
|
|
45
|
+
replace: (_m, prefix: string, token: string) => `${prefix}${maskKeepTail(token)}`,
|
|
46
|
+
},
|
|
47
|
+
// ADHDev credential prefixes: API key (adk_), machine secret (adm_), provider key (adp_).
|
|
48
|
+
{
|
|
49
|
+
name: 'adhdev_prefixed_secret',
|
|
50
|
+
pattern: /\b(ad[kmp]_)([A-Za-z0-9]{6,})/g,
|
|
51
|
+
replace: (_m, prefix: string, token: string) => `${prefix}${maskKeepTail(prefix + token)}`,
|
|
52
|
+
},
|
|
53
|
+
// JWT: three base64url segments separated by dots, header starts with eyJ.
|
|
54
|
+
{
|
|
55
|
+
name: 'jwt',
|
|
56
|
+
pattern: /\beyJ[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{4,}/g,
|
|
57
|
+
replace: () => MASK,
|
|
58
|
+
},
|
|
59
|
+
// TURN credential: a long credential value following a `credential` key in
|
|
60
|
+
// any common shape — `credential: x`, `credential=x`, or `credential "x"`.
|
|
61
|
+
// Mask the credential value only, preserving the key + delimiter/quote.
|
|
62
|
+
{
|
|
63
|
+
name: 'turn_credential',
|
|
64
|
+
pattern: /\b(credential["']?\s*(?:[:=]\s*)?["']?)([^\s"',;]{6,})/gi,
|
|
65
|
+
replace: (_m, prefix: string) => `${prefix}${MASK}`,
|
|
66
|
+
},
|
|
67
|
+
// TURN REST username:credential of the form `<expiry-ts>:<base64hmac>`,
|
|
68
|
+
// where the hmac part is long base64. Mask the hmac.
|
|
69
|
+
{
|
|
70
|
+
name: 'turn_rest_pair',
|
|
71
|
+
pattern: /\b(\d{10,}:)([A-Za-z0-9+/]{20,}={0,2})\b/g,
|
|
72
|
+
replace: (_m, prefix: string) => `${prefix}${MASK}`,
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Mask secrets in a single log line. Idempotent-ish: re-running over an
|
|
78
|
+
* already-masked line leaves the MASK token in place (it contains no secret
|
|
79
|
+
* shape). Never throws — a redaction failure must not crash the log path.
|
|
80
|
+
*/
|
|
81
|
+
export function redactLogLine(line: string): string {
|
|
82
|
+
if (!line) return line;
|
|
83
|
+
let out = line;
|
|
84
|
+
for (const rule of RULES) {
|
|
85
|
+
try {
|
|
86
|
+
out = out.replace(rule.pattern, rule.replace as (substring: string, ...args: any[]) => string);
|
|
87
|
+
} catch {
|
|
88
|
+
// A pathological line must never break log shipping — skip this rule.
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Redact an array of log lines in place-safe fashion (returns a new array). */
|
|
95
|
+
export function redactLogLines(lines: string[]): string[] {
|
|
96
|
+
return lines.map((line) => redactLogLine(line));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Exposed for tests/introspection: the rule names applied, in order. */
|
|
100
|
+
export const LOG_REDACTION_RULE_NAMES: readonly string[] = RULES.map((r) => r.name);
|