@adhdev/daemon-core 0.9.82-rc.46 → 0.9.82-rc.460
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boot/daemon-lifecycle.d.ts +9 -0
- package/dist/boot/process-hardening.d.ts +50 -0
- package/dist/build-info.d.ts +37 -0
- package/dist/chat/source-machine.d.ts +166 -0
- package/dist/chat/source-resolver.d.ts +104 -0
- package/dist/chat/subscription-updates.d.ts +1 -0
- package/dist/cli-adapter-types.d.ts +68 -2
- package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
- package/dist/cli-adapters/cli-state-engine.d.ts +200 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +126 -64
- package/dist/cli-adapters/provider-cli-parse.d.ts +5 -0
- package/dist/cli-adapters/provider-cli-runtime.d.ts +34 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +74 -0
- package/dist/cli-adapters/pty-write-chunking.d.ts +34 -0
- package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
- package/dist/cli-adapters/resolve-executable.d.ts +69 -0
- package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +6 -3
- package/dist/cli-adapters/terminal-backends/types.d.ts +10 -2
- package/dist/cli-adapters/terminal-screen.d.ts +4 -11
- package/dist/commands/chat-commands-debug-bundle.d.ts +14 -0
- package/dist/commands/chat-commands-read.d.ts +7 -0
- package/dist/commands/chat-commands-scope.d.ts +39 -0
- package/dist/commands/chat-commands-shared.d.ts +33 -0
- package/dist/commands/chat-commands-write.d.ts +14 -0
- package/dist/commands/chat-commands.d.ts +10 -23
- package/dist/commands/cli-manager.d.ts +25 -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-refine.d.ts +137 -0
- package/dist/commands/router-worktree-cleanup.d.ts +133 -0
- package/dist/commands/router.d.ts +241 -12
- package/dist/commands/upgrade-helper.d.ts +41 -1
- package/dist/config/chat-history.d.ts +9 -0
- package/dist/config/config.d.ts +19 -0
- package/dist/config/mesh-config.d.ts +129 -1
- 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/daemon/dev-server.d.ts +0 -2
- package/dist/detection/ide-detector.d.ts +13 -0
- package/dist/detection/win32-ide-version.d.ts +37 -0
- package/dist/git/change-impact-config.d.ts +159 -0
- package/dist/git/git-commands.d.ts +12 -1
- package/dist/git/git-diff.d.ts +6 -0
- package/dist/git/git-executor.d.ts +11 -0
- package/dist/git/git-status.d.ts +57 -0
- package/dist/git/git-types.d.ts +2 -50
- package/dist/git/git-worktree.d.ts +71 -1
- package/dist/git/index.d.ts +3 -1
- package/dist/index.d.ts +67 -15
- package/dist/index.js +57943 -25340
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57611 -25174
- 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 +230 -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 +174 -0
- package/dist/mesh/mesh-clone-grace.d.ts +8 -0
- package/dist/mesh/mesh-coordinator-config.d.ts +21 -0
- package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
- package/dist/mesh/mesh-event-classify.d.ts +7 -0
- package/dist/mesh/mesh-event-forwarding.d.ts +41 -0
- package/dist/mesh/mesh-event-trace.d.ts +21 -0
- package/dist/mesh/mesh-events-coordinator.d.ts +4 -0
- package/dist/mesh/mesh-events-pending.d.ts +113 -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 +29 -0
- 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 +133 -1
- package/dist/mesh/mesh-magi-status.d.ts +63 -0
- package/dist/mesh/mesh-missions.d.ts +189 -0
- package/dist/mesh/mesh-node-identity.d.ts +306 -0
- package/dist/mesh/mesh-queue-assignment.d.ts +158 -0
- package/dist/mesh/mesh-reconcile-loop.d.ts +80 -0
- package/dist/mesh/mesh-refine-batch.d.ts +68 -0
- package/dist/mesh/mesh-refine-gates.d.ts +428 -0
- package/dist/mesh/mesh-refine-status.d.ts +62 -0
- package/dist/mesh/mesh-review-inbox.d.ts +90 -0
- package/dist/mesh/mesh-routing.d.ts +70 -0
- package/dist/mesh/mesh-runtime-store.d.ts +476 -0
- package/dist/mesh/mesh-scheduling-runtime.d.ts +78 -0
- package/dist/mesh/mesh-task-inflight.d.ts +46 -0
- package/dist/mesh/mesh-task-stats.d.ts +49 -0
- package/dist/mesh/mesh-unresolved-forward-outbox.d.ts +30 -0
- package/dist/mesh/mesh-warmup-deadline.d.ts +68 -0
- package/dist/mesh/mesh-work-queue.d.ts +318 -5
- package/dist/mesh/preview-freshness.d.ts +28 -0
- package/dist/mesh/refine-config.d.ts +216 -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 +45 -0
- package/dist/providers/chat-message-normalization.d.ts +58 -1
- package/dist/providers/cli-provider-instance.d.ts +290 -3
- package/dist/providers/contracts.d.ts +149 -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 +28 -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 +31 -0
- package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
- package/dist/providers/native-history/index.d.ts +13 -0
- package/dist/providers/provider-instance-manager.d.ts +29 -0
- package/dist/providers/provider-instance.d.ts +30 -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 +222 -0
- package/dist/providers/status-monitor.d.ts +7 -7
- package/dist/providers/transcript-v2.d.ts +176 -0
- package/dist/providers/types/interactive-prompt.d.ts +84 -0
- package/dist/providers/working-dir.d.ts +17 -0
- package/dist/repo-mesh-types.d.ts +519 -13
- 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 +6 -0
- package/dist/shared-types-extra.d.ts +2 -4
- package/dist/shared-types.d.ts +86 -55
- package/dist/status/normalize.d.ts +1 -1
- package/dist/status/normalize.js +1 -0
- package/dist/status/normalize.js.map +1 -1
- package/dist/status/normalize.mjs +1 -0
- package/dist/status/normalize.mjs.map +1 -1
- package/dist/status/reporter.d.ts +2 -0
- package/dist/status/snapshot.d.ts +26 -0
- package/dist/system/hash.d.ts +8 -0
- package/dist/system/load-better-sqlite3.d.ts +21 -0
- package/dist/types.d.ts +5 -0
- package/package.json +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 +65 -12
- package/src/boot/process-hardening.ts +89 -0
- package/src/build-info.ts +73 -0
- package/src/chat/source-machine.ts +534 -0
- package/src/chat/source-resolver.ts +0 -0
- package/src/chat/subscription-updates.ts +20 -1
- package/src/cli-adapter-types.d.ts +3 -1
- package/src/cli-adapter-types.ts +68 -2
- package/src/cli-adapters/cli-script-runner.ts +421 -0
- package/src/cli-adapters/cli-state-engine.ts +1246 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +914 -1144
- package/src/cli-adapters/provider-cli-parse.d.ts +2 -0
- package/src/cli-adapters/provider-cli-parse.ts +19 -0
- package/src/cli-adapters/provider-cli-runtime.ts +56 -7
- package/src/cli-adapters/provider-cli-shared.d.ts +4 -0
- package/src/cli-adapters/provider-cli-shared.ts +121 -11
- package/src/cli-adapters/pty-transport.ts +2 -1
- package/src/cli-adapters/pty-write-chunking.ts +106 -0
- package/src/cli-adapters/raw-terminal-io.ts +252 -0
- package/src/cli-adapters/resolve-executable.ts +204 -0
- package/src/cli-adapters/session-host-transport.ts +2 -1
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +63 -29
- package/src/cli-adapters/terminal-backends/types.ts +10 -3
- package/src/cli-adapters/terminal-screen.ts +16 -81
- package/src/commands/chat-commands-debug-bundle.ts +398 -0
- package/src/commands/chat-commands-read.ts +2488 -0
- package/src/commands/chat-commands-scope.ts +54 -0
- package/src/commands/chat-commands-shared.ts +114 -0
- package/src/commands/chat-commands-write.ts +891 -0
- package/src/commands/chat-commands.ts +19 -1841
- package/src/commands/cli-manager.ts +596 -27
- package/src/commands/handler.ts +845 -2
- package/src/commands/high-family/index.ts +28 -0
- package/src/commands/high-family/mesh-coordinator-launch.ts +680 -0
- package/src/commands/high-family/mesh-events.ts +89 -0
- package/src/commands/high-family/mesh-status.ts +822 -0
- package/src/commands/high-family/types.ts +80 -0
- package/src/commands/low-family/coordinator-prompt.ts +72 -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 +274 -0
- package/src/commands/low-family/spec-providerdev.ts +217 -0
- package/src/commands/low-family/status-meta.ts +112 -0
- package/src/commands/low-family/types.ts +39 -0
- package/src/commands/med-family/cli-agent.ts +241 -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 +1287 -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-refine.ts +1711 -0
- package/src/commands/router-worktree-cleanup.ts +870 -0
- package/src/commands/router.ts +1025 -4070
- package/src/commands/stream-commands.ts +8 -0
- package/src/commands/upgrade-helper.ts +310 -45
- package/src/config/chat-history.ts +493 -24
- package/src/config/config.ts +30 -0
- package/src/config/mesh-config.ts +619 -23
- 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/daemon/dev-auto-implement.ts +3 -2
- package/src/daemon/dev-cli-debug.ts +10 -1
- package/src/daemon/dev-server.ts +0 -541
- package/src/detection/cli-detector.ts +28 -9
- package/src/detection/ide-detector.ts +55 -16
- package/src/detection/win32-ide-version.ts +106 -0
- package/src/git/change-impact-config.ts +354 -0
- package/src/git/git-commands.ts +78 -15
- package/src/git/git-diff.ts +81 -11
- package/src/git/git-executor.ts +12 -0
- package/src/git/git-status.ts +767 -48
- package/src/git/git-types.ts +14 -62
- package/src/git/git-worktree.ts +261 -4
- package/src/git/index.ts +17 -0
- package/src/index.ts +200 -12
- package/src/installer.d.ts +1 -1
- package/src/installer.ts +8 -6
- package/src/ipc/local-ipc-server.ts +278 -0
- package/src/launch.d.ts +1 -1
- package/src/launch.ts +37 -28
- package/src/logging/async-batch-writer.ts +55 -0
- package/src/logging/command-log.ts +7 -5
- package/src/logging/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 +469 -0
- package/src/mesh/coordinator-prompt.ts +536 -34
- package/src/mesh/coordinator-registry.ts +121 -0
- package/src/mesh/mesh-active-work.ts +656 -0
- package/src/mesh/mesh-clone-grace.ts +68 -0
- package/src/mesh/mesh-coordinator-config.ts +97 -0
- package/src/mesh/mesh-delivery-policy.ts +315 -0
- package/src/mesh/mesh-event-classify.ts +73 -0
- package/src/mesh/mesh-event-forwarding.ts +1932 -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 +766 -0
- package/src/mesh/mesh-events-stale.ts +440 -0
- package/src/mesh/mesh-events-utils.ts +443 -0
- package/src/mesh/mesh-events.ts +33 -1035
- package/src/mesh/mesh-fast-forward.ts +856 -0
- package/src/mesh/mesh-host-ownership.ts +111 -0
- package/src/mesh/mesh-init.ts +350 -0
- package/src/mesh/mesh-ledger-reconciliation.ts +12 -7
- package/src/mesh/mesh-ledger.ts +873 -102
- package/src/mesh/mesh-magi-status.ts +223 -0
- package/src/mesh/mesh-missions.ts +449 -0
- package/src/mesh/mesh-node-identity.ts +1994 -0
- package/src/mesh/mesh-queue-assignment.ts +2233 -0
- package/src/mesh/mesh-reconcile-loop.ts +2390 -0
- package/src/mesh/mesh-refine-batch.ts +205 -0
- package/src/mesh/mesh-refine-gates.ts +1686 -0
- package/src/mesh/mesh-refine-status.ts +231 -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 +2026 -0
- package/src/mesh/mesh-scheduling-runtime.ts +198 -0
- package/src/mesh/mesh-task-inflight.ts +70 -0
- package/src/mesh/mesh-task-stats.ts +161 -0
- package/src/mesh/mesh-unresolved-forward-outbox.ts +185 -0
- package/src/mesh/mesh-warmup-deadline.ts +152 -0
- package/src/mesh/mesh-work-queue.ts +1281 -141
- package/src/mesh/preview-freshness.ts +163 -0
- package/src/mesh/refine-config.ts +423 -0
- 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 +99 -5
- package/src/providers/chat-message-normalization.ts +126 -4
- package/src/providers/cli-provider-instance.ts +2456 -107
- package/src/providers/contracts.d.ts +55 -0
- package/src/providers/contracts.ts +160 -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 +131 -0
- package/src/providers/native-history/antigravity-cli-transcript.ts +1193 -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 +503 -0
- package/src/providers/native-history/hermes-cli-transcript.ts +260 -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 +87 -14
- package/src/providers/provider-trust.ts +114 -0
- package/src/providers/read-chat-contract.ts +76 -16
- package/src/providers/sdk/README.md +49 -0
- package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
- package/src/providers/sdk/v1/builders/cli/detect-status.ts +313 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval.ts +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 +509 -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 +1174 -0
- package/src/providers/spec/pre-launch-trust.ts +104 -0
- package/src/providers/spec/route.ts +51 -0
- package/src/providers/spec/types.ts +262 -0
- package/src/providers/status-monitor.d.ts +7 -7
- package/src/providers/status-monitor.ts +37 -22
- package/src/providers/transcript-v2.ts +567 -0
- package/src/providers/types/interactive-prompt.ts +536 -0
- package/src/providers/version-archive.ts +64 -24
- package/src/providers/working-dir.ts +23 -0
- package/src/repo-mesh-types.ts +758 -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 +6 -0
- package/src/shared-types-extra.ts +2 -4
- package/src/shared-types.d.ts +8 -0
- package/src/shared-types.ts +124 -55
- package/src/status/builders.ts +26 -6
- package/src/status/normalize.ts +2 -0
- package/src/status/reporter.ts +19 -1
- package/src/status/snapshot.ts +95 -26
- package/src/system/hash.ts +23 -0
- package/src/system/host-memory.ts +29 -12
- package/src/system/load-better-sqlite3.ts +68 -0
- package/src/types.ts +5 -0
- package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
- package/dist/mesh/mesh-sync.d.ts +0 -53
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
- package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
- package/src/mesh/mesh-sync.ts +0 -111
|
@@ -37,6 +37,12 @@ const KNOWN_PROVIDER_FIELDS = new Set<string>([
|
|
|
37
37
|
'approvalPositiveHints',
|
|
38
38
|
'sessionIdPattern',
|
|
39
39
|
'historyBehavior',
|
|
40
|
+
// v1 canonical field name. The loader fills this in for legacy v0
|
|
41
|
+
// manifests that ship the old `canonicalHistory` spelling.
|
|
42
|
+
'nativeHistory',
|
|
43
|
+
// Deprecated v0 alias for `nativeHistory`. Kept in the allowed-keys
|
|
44
|
+
// list so legacy provider.json manifests don't trip the unknown-key
|
|
45
|
+
// warning during the one-release deprecation window.
|
|
40
46
|
'canonicalHistory',
|
|
41
47
|
'autoFixProfile',
|
|
42
48
|
'ideLevelScripts',
|
|
@@ -64,6 +70,8 @@ const KNOWN_PROVIDER_FIELDS = new Set<string>([
|
|
|
64
70
|
'sendKey',
|
|
65
71
|
'submitStrategy',
|
|
66
72
|
'requirePromptEchoBeforeSubmit',
|
|
73
|
+
'requiresFinalAssistantBeforeIdle',
|
|
74
|
+
'augmentStaleSnapshot',
|
|
67
75
|
'timeouts',
|
|
68
76
|
'disableUpstream',
|
|
69
77
|
])
|
|
@@ -128,7 +136,7 @@ export function validateProviderDefinition(raw: unknown): ProviderValidationResu
|
|
|
128
136
|
}
|
|
129
137
|
|
|
130
138
|
validateCapabilities(provider as unknown as ProviderModule, controls, errors)
|
|
131
|
-
|
|
139
|
+
validateNativeHistory(provider.nativeHistory, errors)
|
|
132
140
|
validateMeshCoordinator(provider.meshCoordinator, errors)
|
|
133
141
|
|
|
134
142
|
for (const control of controls) {
|
|
@@ -228,33 +236,43 @@ function validateCapabilities(provider: ProviderModule, controls: ProviderContro
|
|
|
228
236
|
}
|
|
229
237
|
}
|
|
230
238
|
|
|
231
|
-
function
|
|
239
|
+
function validateNativeHistory(raw: unknown, errors: string[]): void {
|
|
232
240
|
if (raw === undefined) return
|
|
233
241
|
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
234
|
-
errors.push('
|
|
242
|
+
errors.push('nativeHistory must be an object')
|
|
235
243
|
return
|
|
236
244
|
}
|
|
237
245
|
|
|
238
|
-
const
|
|
239
|
-
const format =
|
|
246
|
+
const nativeHistory = raw as Record<string, unknown>
|
|
247
|
+
const format = nativeHistory.format
|
|
240
248
|
if (format !== undefined && (typeof format !== 'string' || !format.trim())) {
|
|
241
|
-
errors.push('
|
|
249
|
+
errors.push('nativeHistory.format must be a non-empty string when provided')
|
|
242
250
|
}
|
|
243
251
|
|
|
244
|
-
const watchPath =
|
|
252
|
+
const watchPath = nativeHistory.watchPath
|
|
245
253
|
if (watchPath !== undefined && (typeof watchPath !== 'string' || !watchPath.trim())) {
|
|
246
|
-
errors.push('
|
|
254
|
+
errors.push('nativeHistory.watchPath must be a non-empty string when provided')
|
|
247
255
|
}
|
|
248
256
|
|
|
249
|
-
const mode =
|
|
257
|
+
const mode = nativeHistory.mode
|
|
250
258
|
if (mode !== undefined && !['native-source', 'materialized-mirror', 'disabled'].includes(String(mode))) {
|
|
251
|
-
errors.push('
|
|
259
|
+
errors.push('nativeHistory.mode must be one of: native-source, materialized-mirror, disabled')
|
|
252
260
|
}
|
|
253
261
|
|
|
254
|
-
|
|
262
|
+
// Chat transcript contract version (transcript-v2.ts). Absent → treated as
|
|
263
|
+
// v1 by readDeclaredChatContractVersion(). A2 will reject unrecognised
|
|
264
|
+
// values at load time; A1 only validates the field shape.
|
|
265
|
+
const chatContractVersion = nativeHistory.contractVersion
|
|
266
|
+
if (chatContractVersion !== undefined
|
|
267
|
+
&& chatContractVersion !== '1.0'
|
|
268
|
+
&& chatContractVersion !== '2.0') {
|
|
269
|
+
errors.push(`nativeHistory.contractVersion must be '1.0' or '2.0' when provided (got ${JSON.stringify(chatContractVersion)})`)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const scripts = nativeHistory.scripts
|
|
255
273
|
if (scripts === undefined) return
|
|
256
274
|
if (!scripts || typeof scripts !== 'object' || Array.isArray(scripts)) {
|
|
257
|
-
errors.push('
|
|
275
|
+
errors.push('nativeHistory.scripts must be an object')
|
|
258
276
|
return
|
|
259
277
|
}
|
|
260
278
|
|
|
@@ -262,7 +280,7 @@ function validateCanonicalHistory(raw: unknown, errors: string[]): void {
|
|
|
262
280
|
for (const key of ['readSession', 'listSessions']) {
|
|
263
281
|
const value = scriptConfig[key]
|
|
264
282
|
if (typeof value !== 'string' || !value.trim()) {
|
|
265
|
-
errors.push(`
|
|
283
|
+
errors.push(`nativeHistory.scripts.${key} must be a non-empty string`)
|
|
266
284
|
}
|
|
267
285
|
}
|
|
268
286
|
}
|
|
@@ -282,7 +300,11 @@ function validateMeshCoordinator(raw: unknown, errors: string[]): void {
|
|
|
282
300
|
errors.push('meshCoordinator.reason must be a non-empty string when provided')
|
|
283
301
|
}
|
|
284
302
|
|
|
285
|
-
|
|
303
|
+
validateMeshCoordinatorMcpConfig(meshCoordinator.mcpConfig, errors)
|
|
304
|
+
validateMeshCoordinatorDelegatedWorkerIsolation(meshCoordinator.delegatedWorkerIsolation, errors)
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function validateMeshCoordinatorMcpConfig(mcpConfig: unknown, errors: string[]): void {
|
|
286
308
|
if (mcpConfig === undefined) return
|
|
287
309
|
if (!mcpConfig || typeof mcpConfig !== 'object' || Array.isArray(mcpConfig)) {
|
|
288
310
|
errors.push('meshCoordinator.mcpConfig must be an object')
|
|
@@ -330,6 +352,57 @@ function validateMeshCoordinator(raw: unknown, errors: string[]): void {
|
|
|
330
352
|
}
|
|
331
353
|
}
|
|
332
354
|
|
|
355
|
+
function validateMeshCoordinatorDelegatedWorkerIsolation(raw: unknown, errors: string[]): void {
|
|
356
|
+
if (raw === undefined) return
|
|
357
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
358
|
+
errors.push('meshCoordinator.delegatedWorkerIsolation must be an object')
|
|
359
|
+
return
|
|
360
|
+
}
|
|
361
|
+
const isolation = raw as Record<string, unknown>
|
|
362
|
+
const env = isolation.env
|
|
363
|
+
if (env !== undefined) {
|
|
364
|
+
if (!env || typeof env !== 'object' || Array.isArray(env)) {
|
|
365
|
+
errors.push('meshCoordinator.delegatedWorkerIsolation.env must be an object')
|
|
366
|
+
} else {
|
|
367
|
+
const unset = (env as Record<string, unknown>).unset
|
|
368
|
+
if (unset !== undefined && (!Array.isArray(unset) || unset.some((key) => typeof key !== 'string' || !key.trim()))) {
|
|
369
|
+
errors.push('meshCoordinator.delegatedWorkerIsolation.env.unset must be an array of non-empty strings')
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
const args = isolation.args
|
|
374
|
+
if (args === undefined) return
|
|
375
|
+
if (!Array.isArray(args)) {
|
|
376
|
+
errors.push('meshCoordinator.delegatedWorkerIsolation.args must be an array')
|
|
377
|
+
return
|
|
378
|
+
}
|
|
379
|
+
for (const [index, rule] of args.entries()) {
|
|
380
|
+
const prefix = `meshCoordinator.delegatedWorkerIsolation.args[${index}]`
|
|
381
|
+
if (!rule || typeof rule !== 'object' || Array.isArray(rule)) {
|
|
382
|
+
errors.push(`${prefix} must be an object`)
|
|
383
|
+
continue
|
|
384
|
+
}
|
|
385
|
+
const item = rule as Record<string, unknown>
|
|
386
|
+
const mode = item.mode
|
|
387
|
+
if (mode !== 'empty_mcp_config' && mode !== 'config_override') {
|
|
388
|
+
errors.push(`${prefix}.mode must be one of: empty_mcp_config, config_override`)
|
|
389
|
+
continue
|
|
390
|
+
}
|
|
391
|
+
for (const key of mode === 'empty_mcp_config' ? ['flag'] : ['flag', 'key', 'value']) {
|
|
392
|
+
const value = item[key]
|
|
393
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
394
|
+
errors.push(`${prefix}.${key} must be a non-empty string`)
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
for (const key of ['strictFlag', 'dedupeKey']) {
|
|
398
|
+
const value = item[key]
|
|
399
|
+
if (value !== undefined && (typeof value !== 'string' || !value.trim())) {
|
|
400
|
+
errors.push(`${prefix}.${key} must be a non-empty string when provided`)
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
333
406
|
function validateControl(control: ProviderControlDef, errors: string[]): void {
|
|
334
407
|
if (!control || typeof control !== 'object') {
|
|
335
408
|
errors.push('controls: each control must be an object')
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider trust classification.
|
|
3
|
+
*
|
|
4
|
+
* Each loaded provider gets a `trust` tag that the daemon and dashboard
|
|
5
|
+
* use to decide what to surface and what to gate behind a confirmation
|
|
6
|
+
* prompt. Trust is a function of *where* the provider came from
|
|
7
|
+
* (upstream / external / userDir) and the *shape of the manifest*
|
|
8
|
+
* (spec-only vs. carries JavaScript hooks).
|
|
9
|
+
*
|
|
10
|
+
* Rationale:
|
|
11
|
+
* - Spec-only manifests are static declarative configuration; the
|
|
12
|
+
* daemon's spec adapter walks the spec but never executes code
|
|
13
|
+
* authored by the provider.
|
|
14
|
+
* - Non-spec manifests ship JavaScript (tui-block builders consumed
|
|
15
|
+
* by the SDK, scriptDir overrides, or explicit `overrides.* .path`
|
|
16
|
+
* bindings). That code runs inside the daemon process with the
|
|
17
|
+
* same privileges as adhdev itself.
|
|
18
|
+
*
|
|
19
|
+
* Source × shape decides the trust label:
|
|
20
|
+
*
|
|
21
|
+
* layer | spec-only | non-spec
|
|
22
|
+
* ---------|---------------------|-----------------------
|
|
23
|
+
* user | user-custom | user-custom
|
|
24
|
+
* upstream | trusted | trusted-with-scripts
|
|
25
|
+
* external | external-safe | external-untrusted
|
|
26
|
+
*
|
|
27
|
+
* Dashboards should always show a badge for `trusted-with-scripts`
|
|
28
|
+
* (info — runs official JS), `external-safe` (info — declarative only,
|
|
29
|
+
* but 3rd-party), and `external-untrusted` (warning — runs JS from a
|
|
30
|
+
* 3rd-party). Activation of `external-untrusted` should require an
|
|
31
|
+
* explicit confirmation step that names the source URL.
|
|
32
|
+
*/
|
|
33
|
+
'use strict';
|
|
34
|
+
|
|
35
|
+
export type ProviderTrust =
|
|
36
|
+
| 'user-custom'
|
|
37
|
+
| 'trusted'
|
|
38
|
+
| 'trusted-with-scripts'
|
|
39
|
+
| 'external-safe'
|
|
40
|
+
| 'external-untrusted';
|
|
41
|
+
|
|
42
|
+
export type ProviderLayer = 'user' | 'upstream' | 'external';
|
|
43
|
+
|
|
44
|
+
export interface ProviderManifestShape {
|
|
45
|
+
/** Has a `tui` block — SDK builders consume it as code paths. */
|
|
46
|
+
hasTui: boolean;
|
|
47
|
+
/** Has a non-empty `overrides` object — JS override paths. */
|
|
48
|
+
hasOverrides: boolean;
|
|
49
|
+
/** compatibility[].scriptDir or defaultScriptDir is set — JS scripts dir. */
|
|
50
|
+
hasScriptDir: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Inspect a manifest to decide whether it ships JavaScript hooks.
|
|
55
|
+
* Cheap; pure; safe to call on every provider load.
|
|
56
|
+
*/
|
|
57
|
+
export function inspectManifestShape(manifest: Record<string, unknown>): ProviderManifestShape {
|
|
58
|
+
const hasTui = !!manifest.tui && typeof manifest.tui === 'object'
|
|
59
|
+
&& Object.keys(manifest.tui as Record<string, unknown>).length > 0;
|
|
60
|
+
const hasOverrides = !!manifest.overrides && typeof manifest.overrides === 'object'
|
|
61
|
+
&& !Array.isArray(manifest.overrides)
|
|
62
|
+
&& Object.keys(manifest.overrides as Record<string, unknown>).length > 0;
|
|
63
|
+
const compat = Array.isArray(manifest.compatibility) ? manifest.compatibility : [];
|
|
64
|
+
const compatHasScriptDir = compat.some((entry: any) => typeof entry?.scriptDir === 'string');
|
|
65
|
+
const hasScriptDir = compatHasScriptDir || typeof manifest.defaultScriptDir === 'string';
|
|
66
|
+
return { hasTui, hasOverrides, hasScriptDir };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Classify trust given the layer the provider was loaded from + the
|
|
71
|
+
* manifest's JS-hook footprint.
|
|
72
|
+
*/
|
|
73
|
+
export function classifyTrust(
|
|
74
|
+
layer: ProviderLayer,
|
|
75
|
+
shape: ProviderManifestShape,
|
|
76
|
+
): ProviderTrust {
|
|
77
|
+
const isSpecOnly = !shape.hasTui && !shape.hasOverrides && !shape.hasScriptDir;
|
|
78
|
+
switch (layer) {
|
|
79
|
+
case 'user':
|
|
80
|
+
return 'user-custom';
|
|
81
|
+
case 'upstream':
|
|
82
|
+
return isSpecOnly ? 'trusted' : 'trusted-with-scripts';
|
|
83
|
+
case 'external':
|
|
84
|
+
return isSpecOnly ? 'external-safe' : 'external-untrusted';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Returns true when activation should require an explicit user confirm.
|
|
90
|
+
* Today only `external-untrusted` qualifies; future trust levels may
|
|
91
|
+
* fold in here.
|
|
92
|
+
*/
|
|
93
|
+
export function requiresConfirmation(trust: ProviderTrust): boolean {
|
|
94
|
+
return trust === 'external-untrusted';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Render a short human-readable rationale for the trust tag. Used by
|
|
99
|
+
* the dashboard's confirmation modal and the provider catalog tooltip.
|
|
100
|
+
*/
|
|
101
|
+
export function describeTrust(trust: ProviderTrust): string {
|
|
102
|
+
switch (trust) {
|
|
103
|
+
case 'user-custom':
|
|
104
|
+
return 'Hand-authored in ~/.adhdev/providers/. Runs your own code.';
|
|
105
|
+
case 'trusted':
|
|
106
|
+
return 'Official, declarative-only manifest from the ADHDev registry.';
|
|
107
|
+
case 'trusted-with-scripts':
|
|
108
|
+
return 'Official manifest from the ADHDev registry. Ships JavaScript hooks executed by the daemon.';
|
|
109
|
+
case 'external-safe':
|
|
110
|
+
return 'Manifest from a 3rd-party git source you added. Declarative-only — the daemon never runs JS from this source.';
|
|
111
|
+
case 'external-untrusted':
|
|
112
|
+
return 'Manifest from a 3rd-party git source you added. Ships JavaScript that the daemon will execute. Treat as untrusted code — review the source before enabling.';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type { MessagePart, ModalInfo, ReadChatResult } from './contracts.js'
|
|
2
2
|
import { normalizeMessageParts } from './contracts.js'
|
|
3
3
|
import type { ChatBubbleState, ChatMessage } from '../types.js'
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
CHAT_CONTRACT_VERSION_V1,
|
|
6
|
+
CHAT_CONTRACT_VERSION_V2,
|
|
7
|
+
assertReadChatResultV2Payload,
|
|
8
|
+
isSupportedChatContractVersion,
|
|
9
|
+
type ChatContractVersion,
|
|
10
|
+
type ReadChatResultV2,
|
|
11
|
+
} from './transcript-v2.js'
|
|
12
|
+
|
|
13
|
+
const VALID_STATUSES = ['idle', 'generating', 'waiting_approval', 'error', 'panel_hidden', 'starting', 'streaming', 'no_progress', 'long_generating'] as const
|
|
6
14
|
const VALID_ROLES = ['user', 'assistant', 'system', 'human'] as const
|
|
7
15
|
const VALID_BUBBLE_STATES = ['draft', 'streaming', 'final', 'removed'] as const
|
|
8
16
|
const VALID_TURN_STATUSES = ['open', 'waiting_approval', 'complete', 'error'] as const
|
|
@@ -63,7 +71,7 @@ function validateMessage(message: unknown, source: string, index: number): ChatM
|
|
|
63
71
|
content: validateMessageContent(message.content, source, index),
|
|
64
72
|
}
|
|
65
73
|
|
|
66
|
-
if (typeof message.kind === 'string') normalized.kind = message.kind as
|
|
74
|
+
if (typeof message.kind === 'string') normalized.kind = message.kind as ChatMessage['kind']
|
|
67
75
|
if (typeof message.id === 'string') normalized.id = message.id
|
|
68
76
|
if (typeof message.bubbleId === 'string') normalized.bubbleId = message.bubbleId
|
|
69
77
|
if (typeof message.providerUnitKey === 'string') normalized.providerUnitKey = message.providerUnitKey
|
|
@@ -71,20 +79,23 @@ function validateMessage(message: unknown, source: string, index: number): ChatM
|
|
|
71
79
|
if (isFiniteNumber(message.index)) normalized.index = message.index
|
|
72
80
|
if (isFiniteNumber(message.timestamp)) normalized.timestamp = message.timestamp
|
|
73
81
|
if (isFiniteNumber(message.receivedAt)) normalized.receivedAt = message.receivedAt
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (
|
|
82
|
+
// (A2.3) sequence is the monotonic ordering key consumed by ChatSourceMachine.
|
|
83
|
+
// v1 producers omit it; the daemon derives it in normalizeNativeHistoryMessages.
|
|
84
|
+
if (isFiniteNumber(message.sequence)) normalized.sequence = message.sequence
|
|
85
|
+
if (typeof message._turnKey === 'string') normalized._turnKey = message._turnKey
|
|
86
|
+
if (Array.isArray(message.toolCalls)) normalized.toolCalls = message.toolCalls as ChatMessage['toolCalls']
|
|
87
|
+
if (isPlainObject(message.meta)) normalized.meta = message.meta as ChatMessage['meta']
|
|
77
88
|
if (typeof message.senderName === 'string') normalized.senderName = message.senderName
|
|
78
|
-
if (typeof
|
|
79
|
-
if (typeof
|
|
80
|
-
if (typeof
|
|
81
|
-
if (typeof
|
|
82
|
-
if (typeof
|
|
83
|
-
if (typeof
|
|
84
|
-
if (typeof
|
|
85
|
-
if (typeof
|
|
86
|
-
if (typeof
|
|
87
|
-
if (typeof
|
|
89
|
+
if (typeof message._type === 'string') normalized._type = message._type
|
|
90
|
+
if (typeof message._sub === 'string') normalized._sub = message._sub
|
|
91
|
+
if (typeof message.visibility === 'string') normalized.visibility = message.visibility
|
|
92
|
+
if (typeof message.transcriptVisibility === 'string') normalized.transcriptVisibility = message.transcriptVisibility
|
|
93
|
+
if (typeof message.audience === 'string') normalized.audience = message.audience
|
|
94
|
+
if (typeof message.source === 'string') normalized.source = message.source
|
|
95
|
+
if (typeof message.userFacing === 'boolean') normalized.userFacing = message.userFacing
|
|
96
|
+
if (typeof message.internal === 'boolean') normalized.internal = message.internal
|
|
97
|
+
if (typeof message.isInternal === 'boolean') normalized.isInternal = message.isInternal
|
|
98
|
+
if (typeof message.debug === 'boolean') normalized.debug = message.debug
|
|
88
99
|
|
|
89
100
|
return normalized
|
|
90
101
|
}
|
|
@@ -129,6 +140,55 @@ function validateControlValues(controlValues: unknown, source: string): Record<s
|
|
|
129
140
|
return normalized
|
|
130
141
|
}
|
|
131
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Read the producer-declared contract version from a raw read_chat payload.
|
|
145
|
+
* Returns v1 when absent or unrecognised, so legacy producers keep working
|
|
146
|
+
* through A1. A2 will tighten this to throw when an unsupported version is
|
|
147
|
+
* declared.
|
|
148
|
+
*/
|
|
149
|
+
export function readPayloadContractVersion(raw: unknown): ChatContractVersion {
|
|
150
|
+
if (!isPlainObject(raw)) return CHAT_CONTRACT_VERSION_V1
|
|
151
|
+
const declared = (raw as Record<string, unknown>).contractVersion
|
|
152
|
+
if (isSupportedChatContractVersion(declared)) return declared
|
|
153
|
+
return CHAT_CONTRACT_VERSION_V1
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Validate a v2 payload. Thin wrapper around assertReadChatResultV2Payload
|
|
158
|
+
* that prefixes the contract violation with the caller's source label.
|
|
159
|
+
*/
|
|
160
|
+
export function validateReadChatResultV2Payload(raw: unknown, source = 'read_chat'): ReadChatResultV2 {
|
|
161
|
+
try {
|
|
162
|
+
return assertReadChatResultV2Payload(raw)
|
|
163
|
+
} catch (err) {
|
|
164
|
+
if (err instanceof Error) {
|
|
165
|
+
err.message = `${source}: ${err.message}`
|
|
166
|
+
}
|
|
167
|
+
throw err
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Versioned entry point. Routes on the producer-declared contractVersion:
|
|
173
|
+
* - v2 → strict v2 validation (transcript-v2.ts invariants)
|
|
174
|
+
* - v1 (or absent) → legacy permissive validation
|
|
175
|
+
*
|
|
176
|
+
* Callers that have not yet been audited to handle v2 outputs should use
|
|
177
|
+
* validateReadChatResultPayload directly; that path stays bound to v1 shape
|
|
178
|
+
* during the A1 transition.
|
|
179
|
+
*/
|
|
180
|
+
export function validateReadChatResultPayloadVersioned(
|
|
181
|
+
raw: unknown,
|
|
182
|
+
source = 'read_chat',
|
|
183
|
+
): { version: typeof CHAT_CONTRACT_VERSION_V1; payload: ReadChatResult & Record<string, unknown> }
|
|
184
|
+
| { version: typeof CHAT_CONTRACT_VERSION_V2; payload: ReadChatResultV2 } {
|
|
185
|
+
const version = readPayloadContractVersion(raw)
|
|
186
|
+
if (version === CHAT_CONTRACT_VERSION_V2) {
|
|
187
|
+
return { version, payload: validateReadChatResultV2Payload(raw, source) }
|
|
188
|
+
}
|
|
189
|
+
return { version: CHAT_CONTRACT_VERSION_V1, payload: validateReadChatResultPayload(raw, source) }
|
|
190
|
+
}
|
|
191
|
+
|
|
132
192
|
export function validateReadChatResultPayload(raw: unknown, source = 'read_chat'): ReadChatResult & Record<string, unknown> {
|
|
133
193
|
if (!isPlainObject(raw)) {
|
|
134
194
|
throw new Error(`${source}: payload must be an object`)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Provider SDK
|
|
2
|
+
|
|
3
|
+
> Status: Phase 1 in progress · License of this directory: AGPL-3.0 (part of `oss/`) · See [marketplace plan](../../../../../../docs/design/v1.0.0-marketplace-plan.md).
|
|
4
|
+
|
|
5
|
+
This directory is the **Provider SDK** — the framework that lets external developers author CLI providers (and later IDE, Extension, ACP) against a versioned, typed contract.
|
|
6
|
+
|
|
7
|
+
It lives **inside daemon-core**, not as a separate package, by design:
|
|
8
|
+
|
|
9
|
+
- the contract definitions live next to the runtime that consumes them, eliminating version drift
|
|
10
|
+
- `adhdev provider *` CLI commands call straight into these modules
|
|
11
|
+
- two npm packages are extracted from this source at build time:
|
|
12
|
+
- `@adhdev/provider-types` (Apache 2.0) — TypeScript types for external authors
|
|
13
|
+
- `@adhdev/provider-schemas` (Apache 2.0) — JSON Schemas for editor support
|
|
14
|
+
|
|
15
|
+
## Layout
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
sdk/
|
|
19
|
+
v1/ ← contract version 1 (current)
|
|
20
|
+
types/ ← TypeScript types — extracted to @adhdev/provider-types
|
|
21
|
+
cli/ ← CLI category types
|
|
22
|
+
common/ ← shared types (settings, capabilities, auth, spawn)
|
|
23
|
+
schemas/ ← JSON Schemas — extracted to @adhdev/provider-schemas
|
|
24
|
+
cli/
|
|
25
|
+
provider.schema.json ← top-level provider.json (mirrors adhdev-providers/schemas/v1/cli/)
|
|
26
|
+
primitives/ ← per-primitive schemas, namespaced by category
|
|
27
|
+
common/
|
|
28
|
+
primitives/ ← daemon-side primitive implementations
|
|
29
|
+
cli/ ← TUI primitives, native-history adapters, capability handlers
|
|
30
|
+
builders/ ← functions that turn manifest blocks into runtime handlers
|
|
31
|
+
validators/ ← schema check, AST taint analysis, fixture replay
|
|
32
|
+
scaffolders/ ← `adhdev provider init` templates
|
|
33
|
+
fixture-tooling/ ← PTY capture + replay utilities
|
|
34
|
+
v2/ ← reserved for next contract major
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Primitive identifiers
|
|
38
|
+
|
|
39
|
+
Primitives are referenced by `$schema: adhdev:<category>/<id>@<version>` in provider manifests. See the audit-derived v1 catalog of 50 primitives at [`audit-cli-v1.md §5`](../../../../../../../adhdev-providers/docs/provider-contract/cli/audit-cli-v1.md#5-proposed-v1-primitive-set).
|
|
40
|
+
|
|
41
|
+
## Stability
|
|
42
|
+
|
|
43
|
+
`v1/` is unstable until SDK `1.0.0` is published. Breaking changes between SDK `0.x` releases are permitted during Phase 1-2 migration. After SDK `1.0.0`, breaking changes require an `engines.adhdev` major bump.
|
|
44
|
+
|
|
45
|
+
## Out of scope
|
|
46
|
+
|
|
47
|
+
- This SDK does not provide IDE, Extension, or ACP primitives in v1.0.0. They follow in v1.1+.
|
|
48
|
+
- This SDK does not include the registry server code — that lives in [`oss/packages/registry/`](../../../../../registry/) (not yet created).
|
|
49
|
+
- This SDK does not include the marketplace web UI — that lives separately.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* buildDetectStatusFromAcp
|
|
3
|
+
*
|
|
4
|
+
* Turns a declarative `acp/session-protocol@1` block into a runtime
|
|
5
|
+
* `(input: AcpStatusInput) => 'idle' | 'generating' | 'waiting_approval' | null`
|
|
6
|
+
* function.
|
|
7
|
+
*
|
|
8
|
+
* Dispatch order:
|
|
9
|
+
* 1. Not connected → null (no information available).
|
|
10
|
+
* 2. Error patterns — checked first; first match returns the declared verdict.
|
|
11
|
+
* 3. Generating pattern — `generating`.
|
|
12
|
+
* 4. Idle pattern — `idle`.
|
|
13
|
+
* 5. Default: `null` (no change — caller preserves last known status).
|
|
14
|
+
*
|
|
15
|
+
* All regex patterns are compiled once at builder time so the returned
|
|
16
|
+
* detector function is allocation-free on the hot path.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// ─── Spec shapes (mirror the JSON schema) ──────────────────────────────
|
|
20
|
+
|
|
21
|
+
interface AcpRegexPatternSpec {
|
|
22
|
+
regex: string;
|
|
23
|
+
flags?: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface AcpErrorPatternSpec extends AcpRegexPatternSpec {
|
|
28
|
+
verdict: 'idle' | 'generating' | 'waiting_approval';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface AcpSessionSpec {
|
|
32
|
+
$schema?: 'adhdev:acp/session-protocol@1';
|
|
33
|
+
/** Pattern that matches a line emitted when the agent is idle/ready. */
|
|
34
|
+
idlePattern?: AcpRegexPatternSpec;
|
|
35
|
+
/** Pattern that matches a line emitted while the agent is actively working. */
|
|
36
|
+
generatingPattern?: AcpRegexPatternSpec;
|
|
37
|
+
/**
|
|
38
|
+
* Error/edge-case patterns. Checked in order; first match returns the
|
|
39
|
+
* declared verdict. Useful for approval prompts, fatal errors, etc.
|
|
40
|
+
*/
|
|
41
|
+
errorPatterns?: AcpErrorPatternSpec[];
|
|
42
|
+
/** Wire format; informational only at the builder level — regex matching
|
|
43
|
+
* is identical regardless of promptStyle. */
|
|
44
|
+
promptStyle?: 'json-rpc' | 'plain-text' | 'mcp';
|
|
45
|
+
/** Message delimiter used to split incoming bytes (default: newline). */
|
|
46
|
+
messageDelimiter?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ─── Input shape ────────────────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
export interface AcpStatusInput {
|
|
52
|
+
/** The most recently received line from the stdio stream. */
|
|
53
|
+
lastLine: string;
|
|
54
|
+
/**
|
|
55
|
+
* A sliding window of recent output lines (newest last).
|
|
56
|
+
* Builders may check these when a single line is not enough for context.
|
|
57
|
+
*/
|
|
58
|
+
recentLines: string[];
|
|
59
|
+
/** Whether the ACP process is currently connected and running. */
|
|
60
|
+
isConnected: boolean;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ─── Output type ────────────────────────────────────────────────────────
|
|
64
|
+
|
|
65
|
+
export type AcpDetectedStatus = 'idle' | 'generating' | 'waiting_approval' | null;
|
|
66
|
+
|
|
67
|
+
// ─── Helpers ────────────────────────────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
function compile(re: string, flags?: string): RegExp {
|
|
70
|
+
try {
|
|
71
|
+
return new RegExp(re, flags ?? 'i');
|
|
72
|
+
} catch (e) {
|
|
73
|
+
throw new Error(`Invalid regex /${re}/${flags ?? 'i'}: ${(e as Error).message}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Safe `.test()` wrapper: resets `lastIndex` before each call so that
|
|
79
|
+
* regexes compiled with the `g` or `y` flag remain stateless across
|
|
80
|
+
* multiple detect invocations.
|
|
81
|
+
*/
|
|
82
|
+
function testRe(re: RegExp, text: string): boolean {
|
|
83
|
+
re.lastIndex = 0;
|
|
84
|
+
return re.test(text);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ─── Compiled internal representation ───────────────────────────────────
|
|
88
|
+
|
|
89
|
+
interface CompiledAcpSpec {
|
|
90
|
+
idle: RegExp | null;
|
|
91
|
+
generating: RegExp | null;
|
|
92
|
+
errors: Array<{ re: RegExp; verdict: AcpDetectedStatus }>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function compileSpec(spec: AcpSessionSpec): CompiledAcpSpec {
|
|
96
|
+
const idle = spec.idlePattern
|
|
97
|
+
? compile(spec.idlePattern.regex, spec.idlePattern.flags)
|
|
98
|
+
: null;
|
|
99
|
+
|
|
100
|
+
const generating = spec.generatingPattern
|
|
101
|
+
? compile(spec.generatingPattern.regex, spec.generatingPattern.flags)
|
|
102
|
+
: null;
|
|
103
|
+
|
|
104
|
+
const errors = (spec.errorPatterns ?? []).map((ep) => ({
|
|
105
|
+
re: compile(ep.regex, ep.flags),
|
|
106
|
+
verdict: ep.verdict as AcpDetectedStatus,
|
|
107
|
+
}));
|
|
108
|
+
|
|
109
|
+
return { idle, generating, errors };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// ─── Public builder ─────────────────────────────────────────────────────
|
|
113
|
+
|
|
114
|
+
export function buildDetectStatusFromAcp(
|
|
115
|
+
spec: AcpSessionSpec,
|
|
116
|
+
): (input: AcpStatusInput) => AcpDetectedStatus {
|
|
117
|
+
const compiled = compileSpec(spec);
|
|
118
|
+
|
|
119
|
+
return function detectAcpStatus(input: AcpStatusInput): AcpDetectedStatus {
|
|
120
|
+
// 1. No connection → no information.
|
|
121
|
+
if (!input.isConnected) return null;
|
|
122
|
+
|
|
123
|
+
const line = input.lastLine;
|
|
124
|
+
|
|
125
|
+
// 2. Error/edge-case patterns take priority.
|
|
126
|
+
for (const { re, verdict } of compiled.errors) {
|
|
127
|
+
if (testRe(re, line)) return verdict;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// 3. Generating pattern.
|
|
131
|
+
if (compiled.generating && testRe(compiled.generating, line)) return 'generating';
|
|
132
|
+
|
|
133
|
+
// 4. Idle pattern.
|
|
134
|
+
if (compiled.idle && testRe(compiled.idle, line)) return 'idle';
|
|
135
|
+
|
|
136
|
+
// 5. Nothing matched.
|
|
137
|
+
return null;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Internal exports for builder reuse + tests.
|
|
142
|
+
export const __internal = {
|
|
143
|
+
compileSpec,
|
|
144
|
+
};
|