@adhdev/daemon-core 0.9.82-rc.32 → 0.9.82-rc.321
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 +8 -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 +46 -2
- package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
- package/dist/cli-adapters/cli-state-engine.d.ts +198 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +115 -64
- package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
- package/dist/cli-adapters/provider-cli-runtime.d.ts +34 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +38 -0
- package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
- package/dist/cli-adapters/resolve-executable.d.ts +14 -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/cli-manager.d.ts +2 -1
- package/dist/commands/handler.d.ts +110 -0
- package/dist/commands/mesh-coordinator.d.ts +85 -1
- package/dist/commands/router.d.ts +229 -1
- package/dist/commands/upgrade-helper.d.ts +12 -0
- package/dist/config/chat-history.d.ts +9 -0
- package/dist/config/config.d.ts +5 -0
- package/dist/config/mesh-config.d.ts +72 -1
- package/dist/detection/ide-detector.d.ts +13 -0
- package/dist/detection/win32-ide-version.d.ts +37 -0
- package/dist/git/git-commands.d.ts +9 -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 +9 -0
- package/dist/git/git-types.d.ts +2 -50
- package/dist/index.d.ts +51 -12
- package/dist/index.js +35378 -11873
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38854 -15461
- 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 +46 -0
- package/dist/mesh/contracts.d.ts +164 -0
- package/dist/mesh/coordinator-prompt.d.ts +36 -0
- package/dist/mesh/coordinator-registry.d.ts +59 -0
- package/dist/mesh/mesh-active-work.d.ts +108 -0
- package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
- package/dist/mesh/mesh-events-coordinator.d.ts +169 -0
- package/dist/mesh/mesh-events-pending.d.ts +45 -0
- package/dist/mesh/mesh-events-stale.d.ts +40 -0
- package/dist/mesh/mesh-events-utils.d.ts +47 -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 -3
- package/dist/mesh/mesh-ledger.d.ts +77 -1
- package/dist/mesh/mesh-missions.d.ts +116 -0
- package/dist/mesh/mesh-reconcile-loop.d.ts +7 -0
- package/dist/mesh/mesh-refine-batch.d.ts +68 -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 +401 -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-work-queue.d.ts +204 -5
- package/dist/mesh/preview-freshness.d.ts +18 -0
- package/dist/mesh/refine-config.d.ts +215 -0
- package/dist/mesh/worktree-bootstrap-config.d.ts +135 -0
- package/dist/providers/acp-provider-instance.d.ts +2 -0
- package/dist/providers/approval-utils.d.ts +13 -0
- package/dist/providers/cli-provider-instance.d.ts +61 -3
- package/dist/providers/contracts.d.ts +130 -6
- package/dist/providers/external-sources.d.ts +71 -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/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 +13 -0
- package/dist/providers/provider-instance.d.ts +13 -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 +85 -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 +69 -0
- package/dist/providers/spec/cli-adapter.d.ts +217 -0
- package/dist/providers/spec/evaluator.d.ts +23 -0
- package/dist/providers/spec/fsm-driver.d.ts +278 -0
- package/dist/providers/spec/fsm-evaluator.d.ts +72 -0
- package/dist/providers/spec/fsm-loader.d.ts +14 -0
- package/dist/providers/spec/fsm-types.d.ts +128 -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 +180 -0
- 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 +277 -13
- package/dist/sessions/registry.d.ts +6 -0
- package/dist/shared-types-extra.d.ts +2 -4
- package/dist/shared-types.d.ts +42 -1
- 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 +1 -0
- package/dist/types.d.ts +5 -0
- package/package.json +7 -3
- package/src/agent-stream/poller.ts +2 -3
- package/src/boot/daemon-lifecycle.ts +55 -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 +1 -0
- package/src/cli-adapter-types.ts +47 -2
- package/src/cli-adapters/cli-script-runner.ts +421 -0
- package/src/cli-adapters/cli-state-engine.ts +1215 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +710 -1140
- package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
- package/src/cli-adapters/provider-cli-parse.ts +13 -0
- package/src/cli-adapters/provider-cli-runtime.ts +56 -7
- package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
- package/src/cli-adapters/provider-cli-shared.ts +85 -11
- package/src/cli-adapters/pty-transport.ts +2 -1
- package/src/cli-adapters/raw-terminal-io.ts +252 -0
- package/src/cli-adapters/resolve-executable.ts +90 -0
- package/src/cli-adapters/session-host-transport.ts +2 -1
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +53 -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.ts +1822 -61
- package/src/commands/cli-manager.ts +286 -14
- package/src/commands/handler.ts +809 -2
- package/src/commands/mesh-coordinator.ts +332 -122
- package/src/commands/router.ts +6369 -704
- package/src/commands/stream-commands.ts +8 -0
- package/src/commands/upgrade-helper.ts +81 -30
- package/src/config/chat-history.ts +483 -24
- package/src/config/config.ts +12 -0
- package/src/config/mesh-config.ts +320 -4
- package/src/config/recent-activity.ts +8 -2
- package/src/daemon/dev-auto-implement.ts +3 -2
- package/src/daemon/dev-cli-debug.ts +10 -1
- 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/git-commands.ts +42 -12
- package/src/git/git-diff.ts +53 -0
- package/src/git/git-executor.ts +12 -0
- package/src/git/git-status.ts +408 -43
- package/src/git/git-types.ts +14 -62
- package/src/git/git-worktree.ts +8 -1
- package/src/index.ts +145 -11
- 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/log-redactor.ts +100 -0
- package/src/logging/log-tail-reader.ts +220 -0
- package/src/logging/logger.ts +2 -1
- package/src/mesh/contracts.ts +329 -0
- package/src/mesh/coordinator-prompt.ts +234 -31
- package/src/mesh/coordinator-registry.ts +121 -0
- package/src/mesh/mesh-active-work.ts +469 -0
- package/src/mesh/mesh-delivery-policy.ts +315 -0
- package/src/mesh/mesh-events-coordinator.ts +2102 -0
- package/src/mesh/mesh-events-pending.ts +508 -0
- package/src/mesh/mesh-events-stale.ts +290 -0
- package/src/mesh/mesh-events-utils.ts +254 -0
- package/src/mesh/mesh-events.ts +30 -1035
- package/src/mesh/mesh-fast-forward.ts +839 -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 -5
- package/src/mesh/mesh-ledger.ts +589 -102
- package/src/mesh/mesh-missions.ts +248 -0
- package/src/mesh/mesh-reconcile-loop.ts +496 -0
- package/src/mesh/mesh-refine-batch.ts +197 -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 +1578 -0
- package/src/mesh/mesh-task-stats.ts +154 -0
- package/src/mesh/mesh-unresolved-forward-outbox.ts +185 -0
- package/src/mesh/mesh-work-queue.ts +663 -142
- package/src/mesh/preview-freshness.ts +118 -0
- package/src/mesh/refine-config.ts +403 -0
- package/src/mesh/worktree-bootstrap-config.ts +326 -0
- package/src/providers/acp-provider-instance.ts +19 -4
- package/src/providers/approval-utils.d.ts +4 -0
- package/src/providers/approval-utils.ts +47 -5
- package/src/providers/chat-message-normalization.ts +4 -11
- package/src/providers/cli-provider-instance.ts +958 -91
- package/src/providers/contracts.d.ts +55 -0
- package/src/providers/contracts.ts +141 -6
- package/src/providers/extension-provider-instance.ts +5 -1
- package/src/providers/external-sources.ts +218 -0
- package/src/providers/ide-provider-instance.ts +25 -6
- 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/dispatcher.ts +340 -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 +30 -0
- package/src/providers/provider-instance.ts +10 -1
- package/src/providers/provider-loader.ts +662 -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 +262 -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 +168 -0
- package/src/providers/spec/cli-adapter.ts +986 -0
- package/src/providers/spec/evaluator.ts +345 -0
- package/src/providers/spec/fsm-driver.ts +909 -0
- package/src/providers/spec/fsm-evaluator.ts +255 -0
- package/src/providers/spec/fsm-loader.ts +112 -0
- package/src/providers/spec/fsm-types.ts +222 -0
- package/src/providers/spec/native-history-executor.ts +1136 -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 +226 -0
- 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 +356 -13
- package/src/sessions/registry.ts +6 -0
- package/src/shared-types-extra.ts +2 -4
- package/src/shared-types.ts +45 -1
- package/src/status/builders.ts +26 -6
- package/src/status/normalize.ts +2 -0
- package/src/status/reporter.ts +15 -0
- package/src/status/snapshot.ts +84 -25
- package/src/system/host-memory.ts +29 -12
- 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
package/src/index.ts
CHANGED
|
@@ -85,9 +85,28 @@ export type {
|
|
|
85
85
|
InputMediaType,
|
|
86
86
|
} from './shared-types.js';
|
|
87
87
|
|
|
88
|
+
export type {
|
|
89
|
+
InteractivePrompt,
|
|
90
|
+
InteractiveQuestion,
|
|
91
|
+
InteractiveOption,
|
|
92
|
+
InteractivePromptResponse,
|
|
93
|
+
InteractiveAnswer,
|
|
94
|
+
} from './providers/types/interactive-prompt.js';
|
|
95
|
+
export {
|
|
96
|
+
normalizeInteractivePrompt,
|
|
97
|
+
normalizeInteractivePromptResponse,
|
|
98
|
+
buildClaudeInteractiveToolResult,
|
|
99
|
+
interactivePromptFromClaudeAskUserQuestion,
|
|
100
|
+
detectClaudeAskUserQuestionPromptFromJson,
|
|
101
|
+
} from './providers/types/interactive-prompt.js';
|
|
102
|
+
|
|
88
103
|
// ── Repo Mesh Types (cross-package) ──
|
|
89
104
|
export type {
|
|
90
105
|
RepoMesh,
|
|
106
|
+
RepoMeshDaemonRole,
|
|
107
|
+
RepoMeshHostMetadata,
|
|
108
|
+
RepoMeshHostPairingMetadata,
|
|
109
|
+
RepoMeshHostStatus,
|
|
91
110
|
RepoMeshNode,
|
|
92
111
|
RepoMeshNodeHealth,
|
|
93
112
|
RepoMeshPolicy,
|
|
@@ -103,6 +122,9 @@ export type {
|
|
|
103
122
|
LocalMeshNodeEntry,
|
|
104
123
|
RepoMeshStatus,
|
|
105
124
|
RepoMeshNodeStatus,
|
|
125
|
+
RepoMeshPeerConnectionStatus,
|
|
126
|
+
RepoMeshPeerConnectionState,
|
|
127
|
+
RepoMeshPeerConnectionTransport,
|
|
106
128
|
RepoMeshSessionStatus,
|
|
107
129
|
RepoMeshQueueTask,
|
|
108
130
|
RepoMeshQueueTaskStatus,
|
|
@@ -111,8 +133,20 @@ export type {
|
|
|
111
133
|
RepoMeshLedgerEntryStatus,
|
|
112
134
|
RepoMeshLedgerSummaryStatus,
|
|
113
135
|
RepoMeshLedgerStatus,
|
|
136
|
+
MeshAsyncJobLifecycle,
|
|
137
|
+
RepoMeshSchedulingStrategy,
|
|
138
|
+
} from './repo-mesh-types.js';
|
|
139
|
+
export {
|
|
140
|
+
DEFAULT_MESH_POLICY,
|
|
141
|
+
resolveDelegatedWorkerAutoApprove,
|
|
142
|
+
MESH_SCHEDULING_STRATEGIES,
|
|
143
|
+
DEFAULT_MESH_SCHEDULING_STRATEGY,
|
|
144
|
+
normalizeMeshSchedulingStrategy,
|
|
145
|
+
resolveNodeSchedulingPriority,
|
|
146
|
+
MESH_CONVERGE_REFINE_TAG,
|
|
147
|
+
MESH_CONVERGE_FAST_FORWARD_TAG,
|
|
148
|
+
resolveAutoConvergeCodeChange,
|
|
114
149
|
} from './repo-mesh-types.js';
|
|
115
|
-
export { DEFAULT_MESH_POLICY } from './repo-mesh-types.js';
|
|
116
150
|
|
|
117
151
|
// ── Git Surface ──
|
|
118
152
|
export * from './git/index.js';
|
|
@@ -138,7 +172,7 @@ export type RecentSessionBucket = 'needs_attention' | 'working' | 'task_complete
|
|
|
138
172
|
export type { IDaemonCore, DaemonCoreOptions } from './daemon-core.js';
|
|
139
173
|
|
|
140
174
|
// ── Config ──
|
|
141
|
-
export { loadConfig, saveConfig, resetConfig, isSetupComplete, markSetupComplete, updateConfig } from './config/config.js';
|
|
175
|
+
export { loadConfig, saveConfig, resetConfig, isSetupComplete, markSetupComplete, updateConfig, getDaemonDataDir } from './config/config.js';
|
|
142
176
|
export { getWorkspaceState } from './config/workspaces.js';
|
|
143
177
|
export { appendRecentActivity, getRecentActivity } from './config/recent-activity.js';
|
|
144
178
|
export type { RecentActivityEntry } from './config/recent-activity.js';
|
|
@@ -154,19 +188,59 @@ export type { CreateMeshOptions, UpdateMeshOptions, AddNodeOptions } from './con
|
|
|
154
188
|
|
|
155
189
|
// ── Mesh Coordinator ──
|
|
156
190
|
export { buildCoordinatorSystemPrompt } from './mesh/coordinator-prompt.js';
|
|
191
|
+
export { upsertMeshMission, getMeshMissions, getMeshMission, summarizeMissionTasks, summarizeMeshMission, getActiveMeshMissionSummaries, getMeshStatusMissionSummaries, listMeshMissionSummaries, buildMissionPromptSection, GOAL_PREVIEW_MAX, MESH_MISSION_STATUSES } from './mesh/mesh-missions.js';
|
|
192
|
+
export type { MeshMissionRecord, MeshMissionStatus, MeshMissionSummary, MeshMissionSlimSummary, MeshMissionTaskAggregate } from './mesh/mesh-missions.js';
|
|
193
|
+
export { computeMeshTaskStats, computeMeshMissionStats } from './mesh/mesh-task-stats.js';
|
|
194
|
+
export type { MeshTaskStats, MeshMissionStats } from './mesh/mesh-task-stats.js';
|
|
195
|
+
export { deriveMeshReviewInboxItems } from './mesh/mesh-review-inbox.js';
|
|
196
|
+
export type { MeshReviewInboxItem, MeshReviewInboxDerivation, MeshReviewInboxEvidence, MeshReviewInboxDiffSummary, MeshReviewInboxDiffFile, MeshReviewInboxReason, MeshReviewInboxConvergence } from './mesh/mesh-review-inbox.js';
|
|
157
197
|
export type { CoordinatorPromptContext } from './mesh/coordinator-prompt.js';
|
|
158
|
-
export {
|
|
159
|
-
export type {
|
|
198
|
+
export { loadMeshCoordinatorRegistry, registerMeshCoordinator, unregisterMeshCoordinator, getCoordinatorForSession, listCoordinatorsForWorkspace } from './mesh/coordinator-registry.js';
|
|
199
|
+
export type { CoordinatorRegistryEntry } from './mesh/coordinator-registry.js';
|
|
200
|
+
export {
|
|
201
|
+
MESH_REFINE_CONFIG_LOCATIONS,
|
|
202
|
+
MESH_REFINE_CONFIG_SCHEMA,
|
|
203
|
+
loadMeshRefineConfig,
|
|
204
|
+
resolveMeshRefineValidationPlan,
|
|
205
|
+
suggestMeshRefineConfig,
|
|
206
|
+
validateMeshRefineConfig,
|
|
207
|
+
} from './mesh/refine-config.js';
|
|
208
|
+
export {
|
|
209
|
+
MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS,
|
|
210
|
+
MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA,
|
|
211
|
+
loadMeshWorktreeBootstrapConfig,
|
|
212
|
+
runMeshWorktreeBootstrap,
|
|
213
|
+
validateMeshWorktreeBootstrapConfig,
|
|
214
|
+
type RepoMeshWorktreeBootstrapConfig,
|
|
215
|
+
type WorktreeBootstrapState,
|
|
216
|
+
} from './mesh/worktree-bootstrap-config.js';
|
|
217
|
+
export type {
|
|
218
|
+
MeshRefineValidationCategory,
|
|
219
|
+
MeshRefineValidationCommandPlan,
|
|
220
|
+
MeshRefineValidationPlan,
|
|
221
|
+
RepoMeshRefineConfig,
|
|
222
|
+
RepoMeshRefineValidationCommandConfig,
|
|
223
|
+
} from './mesh/refine-config.js';
|
|
160
224
|
|
|
161
225
|
// ── Mesh Task Ledger ──
|
|
162
|
-
export { appendLedgerEntry, appendRemoteLedgerEntries, readLedgerEntries, readLedgerSlice, getLedgerSummary, getLedgerDir, getSessionRecoveryContext, MAX_LEDGER_SLICE_LIMIT } from './mesh/mesh-ledger.js';
|
|
163
|
-
export type { AppendRemoteLedgerResult, MeshLedgerEntry, MeshLedgerKind, MeshLedgerSlice, MeshLedgerSummary, ReadLedgerOptions, ReadLedgerSliceOptions, SessionRecoveryContext } from './mesh/mesh-ledger.js';
|
|
226
|
+
export { appendLedgerEntry, appendRemoteLedgerEntries, buildTaskCompletionEvidence, normalizeMeshWorkerResult, readLedgerEntries, readLedgerSlice, readLedgerSliceFromStore, getLedgerSummary, getLedgerDir, getSessionRecoveryContext, MAX_LEDGER_SLICE_LIMIT } from './mesh/mesh-ledger.js';
|
|
227
|
+
export type { AppendRemoteLedgerResult, MeshLedgerEntry, MeshLedgerKind, MeshLedgerSlice, MeshLedgerSummary, ReadLedgerOptions, ReadLedgerSliceOptions, SessionRecoveryContext, MeshTaskCompletionEvidence, MeshWorkerResultArtifact, MeshProcessArtifact, MeshValidationResultArtifact } from './mesh/mesh-ledger.js';
|
|
228
|
+
export { fastForwardMeshNode } from './mesh/mesh-fast-forward.js';
|
|
229
|
+
export type { MeshFastForwardNodeArgs, MeshFastForwardPlannedStep, MeshFastForwardResult } from './mesh/mesh-fast-forward.js';
|
|
164
230
|
export { buildMeshLedgerReconciliationEvidence, buildMeshLedgerReplicaEvidence } from './mesh/mesh-ledger-reconciliation.js';
|
|
165
|
-
export type { MeshLedgerReconciliationEvidence, MeshLedgerReplicaEvidence, MeshLedgerReplicaStatus } from './mesh/mesh-ledger-reconciliation.js';
|
|
231
|
+
export type { AnyLedgerSlice, MeshLedgerReconciliationEvidence, MeshLedgerReplicaEvidence, MeshLedgerReplicaStatus } from './mesh/mesh-ledger-reconciliation.js';
|
|
166
232
|
|
|
167
233
|
// ── Mesh Work Queue (GUPP) ──
|
|
168
|
-
export { enqueueTask, getQueue, claimNextTask, updateTaskStatus, updateSessionTaskStatus, cancelTask, requeueTask, getMeshQueueStats } from './mesh/mesh-work-queue.js';
|
|
169
|
-
export type { MeshWorkQueueEntry, MeshTaskStatus, MeshWorkQueueStats } from './mesh/mesh-work-queue.js';
|
|
234
|
+
export { enqueueTask, recordDirectDispatchTask, getQueue, claimNextTask, updateTaskStatus, updateSessionTaskStatus, cancelTask, requeueTask, getMeshQueueStats, getMeshQueueRevision, normalizeMeshTaskMode, validateMeshTaskModeRequest, buildMeshNodeCapabilityTags, nodeSatisfiesRequiredTags, normalizeMeshCapabilityTags, resolveConvergeRequiredTags, insertDirectDispatch, getActiveDirectDispatches, updateDirectDispatchStatus, cleanupTerminalDirectDispatches, markStaleDirectDispatches, deleteDirectDispatchesByTaskId, recordMeshToolCall, assertNoDependencyCycle, hasPendingDependents, describeTaskDependencyState } from './mesh/mesh-work-queue.js';
|
|
235
|
+
export type { MeshWorkQueueEntry, MeshTaskStatus, MeshTaskMode, MeshWorkQueueStats, MeshQueueMutationOptions, MeshTaskModeValidationResult, DirectDispatchRecord, MeshToolCallRateResult } from './mesh/mesh-work-queue.js';
|
|
236
|
+
export { buildCompactStaleDirectWorkSummary, buildMeshActiveWork, buildMeshActiveWorkSummary, classifyStaleDirectForPrune, PRUNABLE_ORPHAN_STALE_REASONS } from './mesh/mesh-active-work.js';
|
|
237
|
+
export type { StaleDirectPruneClassification } from './mesh/mesh-active-work.js';
|
|
238
|
+
export type { MeshActiveWorkRecord, MeshActiveWorkStatus, MeshActiveWorkSummary, MeshActiveWorkSource, MeshStaleDirectWorkSummary } from './mesh/mesh-active-work.js';
|
|
239
|
+
export { buildMeshAsyncRefineJobs, summarizeMeshAsyncRefineJobs, STALE_TERMINAL_REFINE_WINDOW_MS, RECENT_TERMINAL_REFINE_CAP } from './mesh/mesh-refine-status.js';
|
|
240
|
+
export type { MeshAsyncRefineJobStatus, MeshAsyncRefineJobSummary, MeshAsyncRefineJobsSummary } from './mesh/mesh-refine-status.js';
|
|
241
|
+
|
|
242
|
+
// ── Mesh Host Ownership ──
|
|
243
|
+
export { buildMeshHostRequiredFailure, createDefaultMeshHostMetadata, isMeshHostOwner, normalizeMeshDaemonRole, requireMeshHostQueueOwner, resolveMeshHostStatus } from './mesh/mesh-host-ownership.js';
|
|
170
244
|
|
|
171
245
|
// ── Mesh Visualization ──
|
|
172
246
|
// buildMeshGraph and MeshGraph types moved to @adhdev/web-core to avoid
|
|
@@ -176,9 +250,13 @@ export type { MeshWorkQueueEntry, MeshTaskStatus, MeshWorkQueueStats } from './m
|
|
|
176
250
|
// export type { MeshGraph, MeshGraphNode, MeshGraphEdge, MeshGraphNodeType, MeshGraphEdgeType } from './mesh/mesh-visualization.js';
|
|
177
251
|
|
|
178
252
|
// ── Mesh Events ──
|
|
179
|
-
export { triggerMeshQueue, drainPendingMeshCoordinatorEvents, getPendingMeshCoordinatorEvents, clearPendingMeshCoordinatorEvents, queuePendingMeshCoordinatorEvent } from './mesh/mesh-events.js';
|
|
253
|
+
export { triggerMeshQueue, drainPendingMeshCoordinatorEvents, getPendingMeshCoordinatorEvents, clearPendingMeshCoordinatorEvents, queuePendingMeshCoordinatorEvent, reconcileDirectDispatchCompletionFromTranscript } from './mesh/mesh-events.js';
|
|
180
254
|
export type { PendingMeshCoordinatorEvent } from './mesh/mesh-events.js';
|
|
181
255
|
|
|
256
|
+
// ── Mesh Delivery Policy ──
|
|
257
|
+
export { resolveDeliveryDecision, createSessionDelivery, updateSessionDeliveryStatus, getActiveSessionDeliveries, markSessionDeliveriesTerminal, recordCompletionConflict, getRecentCompletionConflicts } from './mesh/mesh-delivery-policy.js';
|
|
258
|
+
export type { MeshSessionDeliveryStatus, MeshSessionDeliveryKind, MeshDeliveryDecision, MeshDeliveryPolicyResult, SessionDeliveryRecord } from './mesh/mesh-delivery-policy.js';
|
|
259
|
+
|
|
182
260
|
// ── Mesh P2P Relay Failure Classification ──
|
|
183
261
|
export {
|
|
184
262
|
P2pRelayFailureError,
|
|
@@ -222,7 +300,7 @@ export type { CdpInitializerConfig } from './cdp/initializer.js';
|
|
|
222
300
|
// ── Commands ──
|
|
223
301
|
export { DaemonCommandHandler } from './commands/handler.js';
|
|
224
302
|
export type { CommandResult, CommandContext } from './commands/handler.js';
|
|
225
|
-
export { DaemonCommandRouter } from './commands/router.js';
|
|
303
|
+
export { DaemonCommandRouter, readCachedInlineMeshActiveSessionDetails } from './commands/router.js';
|
|
226
304
|
export type { CommandRouterDeps, CommandRouterResult } from './commands/router.js';
|
|
227
305
|
export {
|
|
228
306
|
maybeRunDaemonUpgradeHelperFromEnv,
|
|
@@ -243,6 +321,8 @@ export type {
|
|
|
243
321
|
export { DaemonStatusReporter } from './status/reporter.js';
|
|
244
322
|
export { buildSessionEntries, findCdpManager, hasCdpManager, isCdpConnected } from './status/builders.js';
|
|
245
323
|
export { buildStatusSnapshot, buildMachineInfo } from './status/snapshot.js';
|
|
324
|
+
export { getDaemonBuildInfo } from './build-info.js';
|
|
325
|
+
export type { DaemonBuildInfo } from './build-info.js';
|
|
246
326
|
export { normalizeManagedStatus, isManagedStatusWorking, isManagedStatusWaiting, normalizeActiveChatData } from './status/normalize.js';
|
|
247
327
|
export type { ManagedStatus } from './status/normalize.js';
|
|
248
328
|
export type { StatusSnapshotOptions, StatusSnapshot } from './status/snapshot.js';
|
|
@@ -388,6 +468,13 @@ export type { CliAdapter } from './cli-adapter-types.js';
|
|
|
388
468
|
export { NodePtyTransportFactory } from './cli-adapters/pty-transport.js';
|
|
389
469
|
export type { PtyRuntimeTransport, PtyTransportFactory, PtySpawnOptions } from './cli-adapters/pty-transport.js';
|
|
390
470
|
export { SessionHostPtyTransportFactory } from './cli-adapters/session-host-transport.js';
|
|
471
|
+
export {
|
|
472
|
+
RawTerminalAttachment,
|
|
473
|
+
namedKeyToAnsi,
|
|
474
|
+
namedKeysToAnsi,
|
|
475
|
+
withRawTerminalAttachment,
|
|
476
|
+
} from './cli-adapters/raw-terminal-io.js';
|
|
477
|
+
export type { NamedKey, RawTerminalAttachmentOptions, RawTerminalSessionHostClient } from './cli-adapters/raw-terminal-io.js';
|
|
391
478
|
export type { HostedCliRuntimeDescriptor, CliTransportFactoryParams } from './commands/cli-manager.js';
|
|
392
479
|
export {
|
|
393
480
|
DEFAULT_SESSION_HOST_APP_NAME,
|
|
@@ -415,3 +502,50 @@ export type { ExtensionInfo as InstallerExtensionInfo } from './installer.js';
|
|
|
415
502
|
// ── Boot / Lifecycle ──
|
|
416
503
|
export { initDaemonComponents, startDaemonDevSupport, shutdownDaemonComponents } from './boot/daemon-lifecycle.js';
|
|
417
504
|
export type { DaemonInitConfig, DaemonComponents, DaemonDevSupportOptions } from './boot/daemon-lifecycle.js';
|
|
505
|
+
|
|
506
|
+
// ── Local IPC server (shared between cloud + standalone daemons) ──
|
|
507
|
+
export {
|
|
508
|
+
startLocalIpcServer,
|
|
509
|
+
buildIpcStatusHttpResponse,
|
|
510
|
+
type LocalIpcServerOptions,
|
|
511
|
+
type LocalIpcServerHandle,
|
|
512
|
+
type IpcCommandContext,
|
|
513
|
+
type IpcCommandResult,
|
|
514
|
+
type IpcStatusPayload,
|
|
515
|
+
} from './ipc/local-ipc-server.js';
|
|
516
|
+
|
|
517
|
+
// ── CLI Spec (adhdev:cli/spec@4) ──
|
|
518
|
+
export { createNativeHistoryDispatcher } from './providers/native-history/index.js';
|
|
519
|
+
export type { ReaderId } from './providers/native-history/index.js';
|
|
520
|
+
export {
|
|
521
|
+
readClaudeCliSession, readCodexCliSession,
|
|
522
|
+
readAntigravityCliSession, readHermesCliSession,
|
|
523
|
+
} from './providers/native-history/index.js';
|
|
524
|
+
export type {
|
|
525
|
+
ControlAction, Control,
|
|
526
|
+
NotificationRule, DelegateTrigger,
|
|
527
|
+
} from './providers/spec/types.js';
|
|
528
|
+
export type { TraceEntry } from './providers/spec/evaluator.js';
|
|
529
|
+
export { evaluateFsm } from './providers/spec/fsm-evaluator.js';
|
|
530
|
+
export type { FsmClock } from './providers/spec/fsm-evaluator.js';
|
|
531
|
+
export { validateFsmSpec } from './providers/spec/fsm-loader.js';
|
|
532
|
+
export { FsmDriver } from './providers/spec/fsm-driver.js';
|
|
533
|
+
export type { DashboardEvent, DashboardCommand, SpecDriverOpts, ISpecDriver } from './providers/spec/fsm-driver.js';
|
|
534
|
+
export { TerminalAdapter } from './providers/spec/adapter.js';
|
|
535
|
+
export type { TerminalAdapterOpts, TerminalAdapterHandlers } from './providers/spec/adapter.js';
|
|
536
|
+
|
|
537
|
+
// ── Provider SDK (v1) — selective re-exports for external tooling ──
|
|
538
|
+
// Tooling (registry publish, dashboard validators, the e2e harness) needs
|
|
539
|
+
// the manifest validator, the builder catalog, and the contract version.
|
|
540
|
+
// We don't re-export *everything* from the SDK to keep the public surface
|
|
541
|
+
// stable; consumers that need internal SDK types still import from the
|
|
542
|
+
// sdk/v1 subpath.
|
|
543
|
+
export {
|
|
544
|
+
validateCliProviderManifest,
|
|
545
|
+
formatManifestValidationIssues,
|
|
546
|
+
type ManifestValidationIssue,
|
|
547
|
+
type ManifestValidationResult,
|
|
548
|
+
V1_CONTRACT_VERSION,
|
|
549
|
+
V1_PRIMITIVE_CATALOG,
|
|
550
|
+
V1_ALL_PRIMITIVES,
|
|
551
|
+
} from './providers/sdk/v1/index.js';
|
package/src/installer.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export interface InstallResult {
|
|
|
31
31
|
/**
|
|
32
32
|
* Check if an extension is already installed
|
|
33
33
|
*/
|
|
34
|
-
export declare function isExtensionInstalled(ide: IDEInfo, marketplaceId: string): boolean
|
|
34
|
+
export declare function isExtensionInstalled(ide: IDEInfo, marketplaceId: string): Promise<boolean>;
|
|
35
35
|
/**
|
|
36
36
|
* Install a single extension
|
|
37
37
|
*/
|
package/src/installer.ts
CHANGED
|
@@ -122,20 +122,22 @@ export interface InstallResult {
|
|
|
122
122
|
/**
|
|
123
123
|
* Check if an extension is already installed
|
|
124
124
|
*/
|
|
125
|
-
|
|
125
|
+
import { promisify } from 'util';
|
|
126
|
+
const execAsync = promisify(exec);
|
|
127
|
+
|
|
128
|
+
export async function isExtensionInstalled(
|
|
126
129
|
ide: IDEInfo,
|
|
127
130
|
marketplaceId: string
|
|
128
|
-
): boolean {
|
|
131
|
+
): Promise<boolean> {
|
|
129
132
|
if (!ide.cliCommand) return false;
|
|
130
133
|
|
|
131
134
|
try {
|
|
132
|
-
const
|
|
135
|
+
const { stdout } = await execAsync(`"${ide.cliCommand}" --list-extensions`, {
|
|
133
136
|
encoding: 'utf-8',
|
|
134
137
|
timeout: 15000,
|
|
135
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
136
138
|
});
|
|
137
139
|
|
|
138
|
-
const installed =
|
|
140
|
+
const installed = stdout
|
|
139
141
|
.trim()
|
|
140
142
|
.split('\n')
|
|
141
143
|
.map((e) => e.trim().toLowerCase());
|
|
@@ -163,7 +165,7 @@ export async function installExtension(
|
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
// Check if already installed
|
|
166
|
-
const alreadyInstalled = isExtensionInstalled(ide, extension.marketplaceId);
|
|
168
|
+
const alreadyInstalled = await isExtensionInstalled(ide, extension.marketplaceId);
|
|
167
169
|
if (alreadyInstalled) {
|
|
168
170
|
return {
|
|
169
171
|
extensionId: extension.id,
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LocalIpcServer — generic HTTP + WebSocket IPC endpoint for daemon processes.
|
|
3
|
+
*
|
|
4
|
+
* Both daemon-cloud and daemon-standalone need a local IPC surface so
|
|
5
|
+
* external tools — the `adhdev mcp --mode ipc` MCP server and anything
|
|
6
|
+
* else that wants to issue commands without going through the cloud
|
|
7
|
+
* Worker — can connect over `ws://127.0.0.1:<port>/ipc`.
|
|
8
|
+
*
|
|
9
|
+
* Until now the implementation lived only in daemon-cloud. Standalone
|
|
10
|
+
* sessions therefore couldn't host MCP mesh tools — codex/claude config
|
|
11
|
+
* pointing at `--mode ipc` got `Cannot reach ipc daemon`. This module
|
|
12
|
+
* moves the transport into daemon-core so both daemons can mount it.
|
|
13
|
+
*
|
|
14
|
+
* The transport itself is daemon-agnostic. Cloud-specific behaviors
|
|
15
|
+
* (mesh relay, mandatory update gates) are injected via the caller's
|
|
16
|
+
* `handleCommand` hook; the IPC layer just frames/unframes JSON and
|
|
17
|
+
* routes messages.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { createServer, type IncomingMessage, type Server as HttpServer } from 'http';
|
|
21
|
+
import { WebSocketServer, WebSocket } from 'ws';
|
|
22
|
+
import { LOG } from '../logging/logger.js';
|
|
23
|
+
import { DAEMON_WS_PATH } from '../ipc-protocol.js';
|
|
24
|
+
|
|
25
|
+
/** Parameters passed to `handleCommand` for each incoming ext:command frame. */
|
|
26
|
+
export interface IpcCommandContext {
|
|
27
|
+
/** The raw `command` field from the message — caller decides routing. */
|
|
28
|
+
command: string;
|
|
29
|
+
/** Args provided by the client; may have been normalized by the caller. */
|
|
30
|
+
args: Record<string, unknown>;
|
|
31
|
+
/** Stable id correlating the request and the eventual ext:command_result. */
|
|
32
|
+
requestId: string;
|
|
33
|
+
/** The connected WebSocket — only needed if the caller wants to send extra events. */
|
|
34
|
+
ws: WebSocket;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Result reported back to the client. `result` is optional context for success. */
|
|
38
|
+
export interface IpcCommandResult {
|
|
39
|
+
success: boolean;
|
|
40
|
+
result?: unknown;
|
|
41
|
+
error?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Additional fields the caller wants merged into the response payload
|
|
44
|
+
* (e.g. the cloud daemon's mandatory-update-block fields). Reserved.
|
|
45
|
+
*/
|
|
46
|
+
extra?: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Status payload returned from GET / on the IPC HTTP port. */
|
|
50
|
+
export interface IpcStatusPayload {
|
|
51
|
+
ok: true;
|
|
52
|
+
pid: number;
|
|
53
|
+
wsPath: string;
|
|
54
|
+
port: number;
|
|
55
|
+
/** Arbitrary daemon-specific summary. Cloud daemon includes mesh state, etc. */
|
|
56
|
+
status: Record<string, unknown> | null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface LocalIpcServerOptions {
|
|
60
|
+
/** TCP port to listen on. 19222 is the conventional default. */
|
|
61
|
+
port: number;
|
|
62
|
+
/** Build the GET / status payload. Called on every health probe. */
|
|
63
|
+
buildStatusPayload: () => Record<string, unknown> | null;
|
|
64
|
+
/** Build the welcome message sent to a freshly-connected client. */
|
|
65
|
+
buildWelcomePayload: () => Record<string, unknown>;
|
|
66
|
+
/** Handle a single ext:command frame. Caller decides routing and returns the result. */
|
|
67
|
+
handleCommand: (ctx: IpcCommandContext) => Promise<IpcCommandResult>;
|
|
68
|
+
/** Optional notification when a new client connects (lets daemon track them for broadcasts). */
|
|
69
|
+
onClientConnected?: (ws: WebSocket) => void;
|
|
70
|
+
/** Optional notification when a client disconnects. */
|
|
71
|
+
onClientDisconnected?: (ws: WebSocket) => void;
|
|
72
|
+
/** Optional logger label (defaults to "IPC"). */
|
|
73
|
+
logCategory?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Returned controller for stopping the server and broadcasting to clients.
|
|
78
|
+
* Stored by the daemon and torn down at shutdown.
|
|
79
|
+
*/
|
|
80
|
+
export interface LocalIpcServerHandle {
|
|
81
|
+
/** True once `listen()` succeeded. */
|
|
82
|
+
isListening(): boolean;
|
|
83
|
+
/** Push a message to every connected client. */
|
|
84
|
+
broadcast(type: string, payload: unknown): void;
|
|
85
|
+
/** Close all client sockets + the HTTP server. */
|
|
86
|
+
close(): Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Build a JSON HTTP response describing the IPC endpoint. Exposed so caller
|
|
91
|
+
* code (and tests) can build the same shape without spinning a real server.
|
|
92
|
+
*/
|
|
93
|
+
export function buildIpcStatusHttpResponse(
|
|
94
|
+
method: string | undefined,
|
|
95
|
+
url: string | undefined,
|
|
96
|
+
payload: IpcStatusPayload,
|
|
97
|
+
): { statusCode: number; body: Record<string, unknown> } {
|
|
98
|
+
if (method && method.toUpperCase() !== 'GET') {
|
|
99
|
+
return { statusCode: 405, body: { ok: false, error: 'method not allowed' } };
|
|
100
|
+
}
|
|
101
|
+
// `/health` is the probe path used by the MCP IpcTransport ping —
|
|
102
|
+
// mirror cloud daemon behavior so `adhdev mcp --mode ipc` recognizes
|
|
103
|
+
// us as a live IPC host. `/` and `/status` return the same shape.
|
|
104
|
+
if (url && url !== '/' && url !== '/status' && url !== '/health') {
|
|
105
|
+
return { statusCode: 404, body: { ok: false, error: 'not found' } };
|
|
106
|
+
}
|
|
107
|
+
return { statusCode: 200, body: payload as unknown as Record<string, unknown> };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Start the local IPC server. Returns a handle the caller can use to broadcast
|
|
112
|
+
* events and tear down at shutdown.
|
|
113
|
+
*/
|
|
114
|
+
export async function startLocalIpcServer(opts: LocalIpcServerOptions): Promise<LocalIpcServerHandle> {
|
|
115
|
+
const logCategory = opts.logCategory || 'IPC';
|
|
116
|
+
const clients = new Set<WebSocket>();
|
|
117
|
+
let httpServer: HttpServer | null = null;
|
|
118
|
+
let wss: WebSocketServer | null = null;
|
|
119
|
+
let listening = false;
|
|
120
|
+
|
|
121
|
+
httpServer = createServer((req, res) => {
|
|
122
|
+
const payload: IpcStatusPayload = {
|
|
123
|
+
ok: true,
|
|
124
|
+
pid: process.pid,
|
|
125
|
+
wsPath: DAEMON_WS_PATH,
|
|
126
|
+
port: opts.port,
|
|
127
|
+
status: opts.buildStatusPayload(),
|
|
128
|
+
};
|
|
129
|
+
const response = buildIpcStatusHttpResponse(req.method, req.url, payload);
|
|
130
|
+
const body = JSON.stringify(response.body);
|
|
131
|
+
res.writeHead(response.statusCode, {
|
|
132
|
+
'Content-Type': 'application/json',
|
|
133
|
+
'Content-Length': Buffer.byteLength(body),
|
|
134
|
+
'Connection': 'close',
|
|
135
|
+
});
|
|
136
|
+
res.end(body);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
wss = new WebSocketServer({ noServer: true });
|
|
140
|
+
wss.on('connection', (ws) => handleConnection(ws));
|
|
141
|
+
|
|
142
|
+
httpServer.on('upgrade', (req: IncomingMessage, socket, head) => {
|
|
143
|
+
const wsUrl = new URL(req.url || '/', `http://${req.headers.host || '127.0.0.1'}`);
|
|
144
|
+
if (wsUrl.pathname !== DAEMON_WS_PATH) {
|
|
145
|
+
socket.write('HTTP/1.1 404 Not Found\r\n\r\n');
|
|
146
|
+
socket.destroy();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
wss!.handleUpgrade(req, socket, head, (ws) => {
|
|
150
|
+
wss!.emit('connection', ws, req);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
function handleConnection(ws: WebSocket): void {
|
|
155
|
+
clients.add(ws);
|
|
156
|
+
sendWelcome(ws);
|
|
157
|
+
opts.onClientConnected?.(ws);
|
|
158
|
+
|
|
159
|
+
ws.on('message', (raw) => {
|
|
160
|
+
void handleMessage(ws, raw.toString());
|
|
161
|
+
});
|
|
162
|
+
ws.on('close', () => {
|
|
163
|
+
clients.delete(ws);
|
|
164
|
+
opts.onClientDisconnected?.(ws);
|
|
165
|
+
});
|
|
166
|
+
ws.on('error', () => {
|
|
167
|
+
clients.delete(ws);
|
|
168
|
+
opts.onClientDisconnected?.(ws);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function sendWelcome(ws: WebSocket): void {
|
|
173
|
+
try {
|
|
174
|
+
ws.send(JSON.stringify({
|
|
175
|
+
type: 'daemon:welcome',
|
|
176
|
+
payload: opts.buildWelcomePayload(),
|
|
177
|
+
}));
|
|
178
|
+
} catch (error: any) {
|
|
179
|
+
LOG.warn(logCategory, `Failed to send welcome: ${error?.message || error}`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async function handleMessage(ws: WebSocket, raw: string): Promise<void> {
|
|
184
|
+
let msg: any;
|
|
185
|
+
try { msg = JSON.parse(raw); } catch { return; }
|
|
186
|
+
if (!msg || typeof msg !== 'object') return;
|
|
187
|
+
|
|
188
|
+
// Re-issue welcome on client request (used by reconnecting MCP servers).
|
|
189
|
+
if (msg.type === 'ext:register') {
|
|
190
|
+
sendWelcome(ws);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (msg.type !== 'ext:command') return;
|
|
194
|
+
|
|
195
|
+
const payload = msg.payload && typeof msg.payload === 'object' ? msg.payload : {};
|
|
196
|
+
const command = typeof payload.command === 'string' ? payload.command : '';
|
|
197
|
+
const args = payload.args && typeof payload.args === 'object'
|
|
198
|
+
? payload.args as Record<string, unknown>
|
|
199
|
+
: {};
|
|
200
|
+
const requestId = typeof payload.requestId === 'string'
|
|
201
|
+
? payload.requestId
|
|
202
|
+
: typeof payload.messageId === 'string'
|
|
203
|
+
? payload.messageId
|
|
204
|
+
: `ipc-${Date.now()}`;
|
|
205
|
+
|
|
206
|
+
if (!command) {
|
|
207
|
+
ws.send(JSON.stringify({
|
|
208
|
+
type: 'ext:command_result',
|
|
209
|
+
payload: { requestId, success: false, error: 'command required' },
|
|
210
|
+
}));
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
try {
|
|
215
|
+
const result = await opts.handleCommand({ command, args, requestId, ws });
|
|
216
|
+
ws.send(JSON.stringify({
|
|
217
|
+
type: 'ext:command_result',
|
|
218
|
+
payload: {
|
|
219
|
+
requestId,
|
|
220
|
+
success: result.success,
|
|
221
|
+
result: result.result,
|
|
222
|
+
error: result.error,
|
|
223
|
+
...(result.extra || {}),
|
|
224
|
+
},
|
|
225
|
+
}));
|
|
226
|
+
} catch (error: any) {
|
|
227
|
+
ws.send(JSON.stringify({
|
|
228
|
+
type: 'ext:command_result',
|
|
229
|
+
payload: {
|
|
230
|
+
requestId,
|
|
231
|
+
success: false,
|
|
232
|
+
error: error?.message || String(error),
|
|
233
|
+
},
|
|
234
|
+
}));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
await new Promise<void>((resolve, reject) => {
|
|
239
|
+
const onError = (error: Error) => {
|
|
240
|
+
httpServer?.off('listening', onListening);
|
|
241
|
+
reject(error);
|
|
242
|
+
};
|
|
243
|
+
const onListening = () => {
|
|
244
|
+
httpServer?.off('error', onError);
|
|
245
|
+
listening = true;
|
|
246
|
+
resolve();
|
|
247
|
+
};
|
|
248
|
+
httpServer!.once('error', onError);
|
|
249
|
+
httpServer!.once('listening', onListening);
|
|
250
|
+
httpServer!.listen(opts.port, '127.0.0.1');
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
LOG.info(logCategory, `Local IPC listening on ws://127.0.0.1:${opts.port}${DAEMON_WS_PATH}`);
|
|
254
|
+
|
|
255
|
+
return {
|
|
256
|
+
isListening: () => listening,
|
|
257
|
+
broadcast(type, payload) {
|
|
258
|
+
const message = JSON.stringify({ type, payload });
|
|
259
|
+
for (const client of clients) {
|
|
260
|
+
if (client.readyState !== WebSocket.OPEN) continue;
|
|
261
|
+
try { client.send(message); } catch { /* drop silently */ }
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
async close() {
|
|
265
|
+
for (const client of clients) {
|
|
266
|
+
try { client.close(); } catch { /* ignore */ }
|
|
267
|
+
}
|
|
268
|
+
clients.clear();
|
|
269
|
+
await new Promise<void>((resolve) => {
|
|
270
|
+
if (!httpServer) { resolve(); return; }
|
|
271
|
+
httpServer.close(() => resolve());
|
|
272
|
+
});
|
|
273
|
+
httpServer = null;
|
|
274
|
+
wss = null;
|
|
275
|
+
listening = false;
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
}
|
package/src/launch.d.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
/** Kill IDE process (graceful → force) */
|
|
19
19
|
export declare function killIdeProcess(ideId: string): Promise<boolean>;
|
|
20
20
|
/** Check if IDE process is running */
|
|
21
|
-
export declare function isIdeRunning(ideId: string): boolean
|
|
21
|
+
export declare function isIdeRunning(ideId: string): Promise<boolean>;
|
|
22
22
|
export interface LaunchOptions {
|
|
23
23
|
ideId?: string;
|
|
24
24
|
workspace?: string;
|