@adhdev/daemon-core 0.9.82-rc.17 → 0.9.82-rc.171
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/process-hardening.d.ts +50 -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 +22 -2
- package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
- package/dist/cli-adapters/cli-state-engine.d.ts +178 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +106 -63
- package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +29 -0
- package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
- package/dist/commands/handler.d.ts +110 -0
- package/dist/commands/mesh-coordinator.d.ts +72 -1
- package/dist/commands/router.d.ts +22 -0
- package/dist/config/chat-history.d.ts +7 -0
- package/dist/config/config.d.ts +5 -0
- package/dist/config/mesh-config.d.ts +71 -1
- package/dist/git/git-commands.d.ts +5 -1
- package/dist/index.d.ts +35 -6
- package/dist/index.js +18634 -3760
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18538 -3732
- 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/mesh/beads-db.d.ts +72 -0
- package/dist/mesh/contracts.d.ts +164 -0
- package/dist/mesh/coordinator-prompt.d.ts +30 -0
- package/dist/mesh/coordinator-registry.d.ts +59 -0
- package/dist/mesh/mesh-active-work.d.ts +90 -0
- package/dist/mesh/mesh-events.d.ts +96 -5
- package/dist/mesh/mesh-fast-forward.d.ts +39 -0
- package/dist/mesh/mesh-host-ownership.d.ts +9 -0
- package/dist/mesh/mesh-ledger.d.ts +58 -1
- package/dist/mesh/mesh-refine-status.d.ts +26 -0
- package/dist/mesh/mesh-work-queue.d.ts +44 -5
- package/dist/mesh/preview-freshness.d.ts +18 -0
- package/dist/mesh/refine-config.d.ts +193 -0
- package/dist/mesh/worktree-bootstrap-config.d.ts +113 -0
- package/dist/providers/approval-utils.d.ts +13 -0
- package/dist/providers/cli-provider-instance.d.ts +9 -3
- package/dist/providers/contracts.d.ts +98 -5
- 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 +24 -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.d.ts +3 -0
- 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 +169 -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 +56 -0
- package/dist/providers/spec/cli-adapter.d.ts +95 -0
- package/dist/providers/spec/driver.d.ts +149 -0
- package/dist/providers/spec/evaluator.d.ts +47 -0
- package/dist/providers/spec/loader.d.ts +14 -0
- package/dist/providers/spec/native-history-executor.d.ts +39 -0
- package/dist/providers/spec/route.d.ts +4 -0
- package/dist/providers/spec/schema.gen.d.ts +511 -0
- package/dist/providers/spec/types.d.ts +212 -0
- package/dist/providers/transcript-v2.d.ts +176 -0
- package/dist/providers/types/interactive-prompt.d.ts +48 -0
- package/dist/repo-mesh-types.d.ts +100 -1
- package/dist/sessions/registry.d.ts +3 -0
- package/dist/shared-types.d.ts +42 -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 -2
- package/src/agent-stream/poller.ts +2 -3
- package/src/boot/daemon-lifecycle.ts +17 -10
- package/src/boot/process-hardening.ts +89 -0
- package/src/chat/source-machine.ts +534 -0
- package/src/chat/source-resolver.ts +0 -0
- package/src/chat/subscription-updates.ts +14 -1
- package/src/cli-adapter-types.d.ts +1 -0
- package/src/cli-adapter-types.ts +21 -2
- package/src/cli-adapters/cli-script-runner.ts +421 -0
- package/src/cli-adapters/cli-state-engine.ts +1086 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +670 -1137
- 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 +3 -1
- package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
- package/src/cli-adapters/provider-cli-shared.ts +59 -11
- package/src/cli-adapters/raw-terminal-io.ts +252 -0
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +17 -1
- package/src/cli-adapters/terminal-backends/xterm-backend.ts +8 -1
- package/src/commands/chat-commands.ts +1597 -60
- package/src/commands/cli-manager.ts +214 -3
- package/src/commands/handler.ts +809 -2
- package/src/commands/mesh-coordinator.ts +231 -127
- package/src/commands/router.ts +3574 -502
- package/src/config/chat-history.ts +87 -24
- package/src/config/config.ts +12 -0
- package/src/config/mesh-config.ts +264 -2
- package/src/config/recent-activity.ts +8 -2
- package/src/daemon/dev-cli-debug.ts +10 -1
- package/src/detection/ide-detector.ts +26 -16
- package/src/git/git-commands.ts +17 -5
- package/src/git/git-worktree.ts +8 -1
- package/src/index.ts +113 -5
- 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/logger.ts +2 -1
- package/src/mesh/beads-db.ts +479 -0
- package/src/mesh/contracts.ts +329 -0
- package/src/mesh/coordinator-prompt.ts +204 -30
- package/src/mesh/coordinator-registry.ts +121 -0
- package/src/mesh/mesh-active-work.ts +437 -0
- package/src/mesh/mesh-events.ts +879 -61
- package/src/mesh/mesh-fast-forward.ts +430 -0
- package/src/mesh/mesh-host-ownership.ts +73 -0
- package/src/mesh/mesh-ledger.ts +457 -104
- package/src/mesh/mesh-refine-status.ts +144 -0
- package/src/mesh/mesh-work-queue.ts +216 -158
- package/src/mesh/preview-freshness.ts +118 -0
- package/src/mesh/refine-config.ts +366 -0
- package/src/mesh/worktree-bootstrap-config.ts +247 -0
- 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 +456 -54
- package/src/providers/contracts.ts +105 -5
- package/src/providers/external-sources.ts +218 -0
- package/src/providers/ide-provider-instance.ts +19 -5
- 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 +419 -0
- package/src/providers/native-history/dispatcher.ts +227 -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.ts +3 -0
- package/src/providers/provider-loader.ts +585 -50
- package/src/providers/provider-schema.ts +31 -13
- 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 +458 -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 +210 -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 +430 -0
- package/src/providers/spec/driver.ts +502 -0
- package/src/providers/spec/evaluator.ts +298 -0
- package/src/providers/spec/loader.ts +130 -0
- package/src/providers/spec/native-history-executor.ts +623 -0
- package/src/providers/spec/route.ts +51 -0
- package/src/providers/spec/schema.gen.ts +511 -0
- package/src/providers/spec/schema.json +211 -0
- package/src/providers/spec/types.ts +231 -0
- package/src/providers/transcript-v2.ts +567 -0
- package/src/providers/types/interactive-prompt.ts +297 -0
- package/src/providers/version-archive.ts +38 -20
- package/src/repo-mesh-types.ts +110 -1
- package/src/sessions/registry.ts +3 -0
- package/src/shared-types.ts +45 -1
- package/src/status/builders.ts +24 -6
- 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
|
@@ -15,6 +15,14 @@ import type { ChatMessageKind } from './chat-message-normalization.js';
|
|
|
15
15
|
export type ReadChatTurnStatus = 'open' | 'waiting_approval' | 'complete' | 'error';
|
|
16
16
|
|
|
17
17
|
export interface ReadChatResult {
|
|
18
|
+
/**
|
|
19
|
+
* Declared chat contract version. Absent or `'1.0'` → legacy v1 payload
|
|
20
|
+
* (current shape). `'2.0'` → v2 payload conforming to transcript-v2.ts
|
|
21
|
+
* (ReadChatResultV2). Validators in read-chat-contract.ts route on this
|
|
22
|
+
* field. A1 only adds the field; A2 will make v2 the daemon-internal
|
|
23
|
+
* canonical form and reject unrecognised versions at provider load time.
|
|
24
|
+
*/
|
|
25
|
+
contractVersion?: import('./transcript-v2.js').ChatContractVersion;
|
|
18
26
|
messages: ChatMessage[];
|
|
19
27
|
status: AgentStatus;
|
|
20
28
|
activeModal?: ModalInfo | null;
|
|
@@ -385,8 +393,61 @@ export interface ProviderMeshCoordinatorConfig {
|
|
|
385
393
|
/** Copyable setup template. Supports {{meshId}}, {{adhdevMcpCommand}}, {{workspace}}, {{serverName}}. */
|
|
386
394
|
template?: string;
|
|
387
395
|
};
|
|
396
|
+
/**
|
|
397
|
+
* How the coordinator system prompt reaches the launched CLI. Replaces the
|
|
398
|
+
* old hard-coded `if (cliType === 'claude-cli') push --append-system-prompt`
|
|
399
|
+
* branches in router.ts: a new CLI now ships its injection rule in its
|
|
400
|
+
* provider.v1.json, no daemon code change needed. Users can override the
|
|
401
|
+
* rendered prompt or the injection mechanism per-provider; if omitted, no
|
|
402
|
+
* system prompt is injected (safe default — won't crash spawn with a flag
|
|
403
|
+
* the CLI doesn't recognize).
|
|
404
|
+
*/
|
|
405
|
+
systemPromptInjection?: MeshCoordinatorSystemPromptInjection;
|
|
388
406
|
}
|
|
389
407
|
|
|
408
|
+
/**
|
|
409
|
+
* Declarative description of how a CLI accepts a session-scoped system prompt.
|
|
410
|
+
*
|
|
411
|
+
* Modes:
|
|
412
|
+
* - cli_arg → push `flag` + prompt onto spawn args (Claude)
|
|
413
|
+
* - config_override → push `flag` + a templated key=value config override (Codex)
|
|
414
|
+
* - context_file → write prompt into a workspace markdown the CLI
|
|
415
|
+
* auto-loads as project context (Gemini, Antigravity)
|
|
416
|
+
* - env_var → expose prompt to the spawned process as $name (Hermes)
|
|
417
|
+
*
|
|
418
|
+
* The prompt text is templated with `{prompt}` (raw) or `{prompt_json}`
|
|
419
|
+
* (JSON-encoded for embedding inside config-override strings).
|
|
420
|
+
*/
|
|
421
|
+
export type MeshCoordinatorSystemPromptInjection =
|
|
422
|
+
| {
|
|
423
|
+
mode: 'cli_arg';
|
|
424
|
+
/** Spawn-args flag, e.g. '--append-system-prompt'. The prompt becomes the next argv. */
|
|
425
|
+
flag: string;
|
|
426
|
+
}
|
|
427
|
+
| {
|
|
428
|
+
mode: 'config_override';
|
|
429
|
+
/** Spawn-args flag, e.g. '-c'. Followed by `template` with placeholders rendered. */
|
|
430
|
+
flag: string;
|
|
431
|
+
/** Template using {prompt} or {prompt_json}, e.g. 'developer_instructions={prompt_json}'. */
|
|
432
|
+
template: string;
|
|
433
|
+
}
|
|
434
|
+
| {
|
|
435
|
+
mode: 'context_file';
|
|
436
|
+
/** Workspace-relative file path the CLI auto-loads, e.g. 'AGENTS.md' or 'GEMINI.md'. */
|
|
437
|
+
path: string;
|
|
438
|
+
/**
|
|
439
|
+
* Optional wrapper around the prompt. Use `{prompt}` placeholder. Existing
|
|
440
|
+
* wrapper-delimited blocks are replaced rather than duplicated, so re-launching
|
|
441
|
+
* a coordinator doesn't pile up copies. If omitted, the prompt is appended raw.
|
|
442
|
+
*/
|
|
443
|
+
wrapper?: string;
|
|
444
|
+
}
|
|
445
|
+
| {
|
|
446
|
+
mode: 'env_var';
|
|
447
|
+
/** Env-var name, e.g. 'HERMES_EPHEMERAL_SYSTEM_PROMPT'. */
|
|
448
|
+
name: string;
|
|
449
|
+
};
|
|
450
|
+
|
|
390
451
|
export interface ProviderCompatibilityEntry {
|
|
391
452
|
ideVersion: string;
|
|
392
453
|
scriptDir: string;
|
|
@@ -472,6 +533,14 @@ export interface ProviderModule {
|
|
|
472
533
|
extensionIdPattern_flags?: string;
|
|
473
534
|
compatibility?: ProviderCompatibilityEntry[];
|
|
474
535
|
defaultScriptDir?: string;
|
|
536
|
+
/**
|
|
537
|
+
* v1 declarative tui block (spinner/settledPrompt/modal/dispatchOrder/etc).
|
|
538
|
+
* When present, the daemon's CliScriptRunner builds canonical
|
|
539
|
+
* (input → verdict) functions from this and injects them into provider
|
|
540
|
+
* scripts as `sdk.declarativeDetectStatus` and `sdk.declarativeParseApproval`.
|
|
541
|
+
* v0 / verified-tier providers can omit this entirely.
|
|
542
|
+
*/
|
|
543
|
+
tui?: Record<string, unknown>;
|
|
475
544
|
/**
|
|
476
545
|
* Scripts that can run at the IDE main-page level (not just inside the extension webview session frame).
|
|
477
546
|
* Default: ['listModes', 'setMode', 'listModels', 'setModel'].
|
|
@@ -525,8 +594,16 @@ export interface ProviderModule {
|
|
|
525
594
|
/** History behavior config — controls message filtering and collapse during replay */
|
|
526
595
|
historyBehavior?: ProviderHistoryBehavior;
|
|
527
596
|
/**
|
|
528
|
-
*
|
|
529
|
-
* When set, daemon
|
|
597
|
+
* Native history config — for providers that maintain native history files.
|
|
598
|
+
* When set, daemon reads/lists provider-native transcripts directly. This is
|
|
599
|
+
* the canonical v1 field name; the legacy `canonicalHistory` field name is
|
|
600
|
+
* still accepted by the loader and aliased onto this field at load time.
|
|
601
|
+
*/
|
|
602
|
+
nativeHistory?: NativeHistoryConfig;
|
|
603
|
+
/**
|
|
604
|
+
* @deprecated Legacy v0 alias for {@link ProviderModule.nativeHistory}.
|
|
605
|
+
* Loader populates this from `nativeHistory` so existing internal readers
|
|
606
|
+
* keep working during the transition. Remove after one release.
|
|
530
607
|
*/
|
|
531
608
|
canonicalHistory?: ProviderCanonicalHistoryConfig;
|
|
532
609
|
/**
|
|
@@ -672,7 +749,7 @@ export interface ProviderHistoryBehavior {
|
|
|
672
749
|
* daemon-core. They let each provider own native transcript file discovery and
|
|
673
750
|
* parsing while daemon-core only validates/pages the normalized result.
|
|
674
751
|
*/
|
|
675
|
-
export interface
|
|
752
|
+
export interface NativeHistoryScriptsConfig {
|
|
676
753
|
/** Reads one native session. Default: 'readNativeHistory'. */
|
|
677
754
|
readSession?: string;
|
|
678
755
|
/** Lists native sessions with summary metadata. Default: 'listNativeHistory'. */
|
|
@@ -680,13 +757,19 @@ export interface ProviderCanonicalHistoryScriptsConfig {
|
|
|
680
757
|
}
|
|
681
758
|
|
|
682
759
|
/**
|
|
683
|
-
*
|
|
760
|
+
* @deprecated Use {@link NativeHistoryScriptsConfig}. Retained as an alias for
|
|
761
|
+
* one release so external consumers that referenced the old name keep compiling.
|
|
762
|
+
*/
|
|
763
|
+
export type ProviderCanonicalHistoryScriptsConfig = NativeHistoryScriptsConfig;
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Native history config — for providers that maintain their own native history files.
|
|
684
767
|
*
|
|
685
768
|
* Preferred mode is provider-owned scripts via `scripts`. `format` is now an
|
|
686
769
|
* opaque provider label retained for diagnostics/backward compatibility; daemon
|
|
687
770
|
* live paths must not branch on provider-specific format values.
|
|
688
771
|
*/
|
|
689
|
-
export interface
|
|
772
|
+
export interface NativeHistoryConfig {
|
|
690
773
|
/** Opaque provider-owned history format label. */
|
|
691
774
|
format?: string;
|
|
692
775
|
/** Optional native history glob/template for diagnostics only. */
|
|
@@ -702,8 +785,25 @@ export interface ProviderCanonicalHistoryConfig {
|
|
|
702
785
|
* Omitted mode defaults to 'native-source'.
|
|
703
786
|
*/
|
|
704
787
|
mode?: 'native-source' | 'materialized-mirror' | 'disabled';
|
|
788
|
+
/**
|
|
789
|
+
* Chat transcript contract version this provider's read_chat output
|
|
790
|
+
* conforms to. See transcript-v2.ts for the v2 invariants. Absent or `'1.0'`
|
|
791
|
+
* → legacy v1 payload (current behaviour). `'2.0'` → strict v2 payload
|
|
792
|
+
* (stable providerUnitKey/bubbleId/sequence, strict enums, honest coverage).
|
|
793
|
+
*
|
|
794
|
+
* A1 only surfaces this field; validators in read-chat-contract.ts route
|
|
795
|
+
* on it. A2 makes v2 the daemon-internal canonical form and rejects
|
|
796
|
+
* unrecognised values at provider load time.
|
|
797
|
+
*/
|
|
798
|
+
contractVersion?: import('./transcript-v2.js').ChatContractVersion;
|
|
705
799
|
}
|
|
706
800
|
|
|
801
|
+
/**
|
|
802
|
+
* @deprecated Use {@link NativeHistoryConfig}. Retained as an alias for one
|
|
803
|
+
* release so external consumers that referenced the old name keep compiling.
|
|
804
|
+
*/
|
|
805
|
+
export type ProviderCanonicalHistoryConfig = NativeHistoryConfig;
|
|
806
|
+
|
|
707
807
|
/**
|
|
708
808
|
* Auto-implement spawn config — controls how the provider is spawned for autonomous AI-driven
|
|
709
809
|
* provider script implementation (dev-auto-implement.ts).
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External provider sources — registry + active-selection state.
|
|
3
|
+
*
|
|
4
|
+
* A user can register one or more 3rd-party git URLs as provider sources.
|
|
5
|
+
* Each source clones into ~/.adhdev/external/<source-name>/, namespaced so
|
|
6
|
+
* that two sources can disk-coexist providing the same provider type.
|
|
7
|
+
*
|
|
8
|
+
* When two sources expose the same type, only one is "active" at a time.
|
|
9
|
+
* The active selection is persisted so a user's choice survives daemon
|
|
10
|
+
* restarts. When only one source provides a type, no explicit selection
|
|
11
|
+
* is needed and the loader falls through to that source.
|
|
12
|
+
*/
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
import * as fs from 'node:fs';
|
|
16
|
+
import * as os from 'node:os';
|
|
17
|
+
import * as path from 'node:path';
|
|
18
|
+
|
|
19
|
+
export interface ExternalSource {
|
|
20
|
+
/** Unique short identifier, e.g. "@vendor-x". User-supplied or derived from the URL. */
|
|
21
|
+
name: string;
|
|
22
|
+
/** Full git URL (https://, git@, …). */
|
|
23
|
+
url: string;
|
|
24
|
+
/** Branch / tag / commit-ish to track. Defaults to `main`. */
|
|
25
|
+
ref: string;
|
|
26
|
+
/** ISO timestamp when first registered. */
|
|
27
|
+
addedAt: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ExternalSourcesFile {
|
|
31
|
+
/** Schema version — bump if shape changes. */
|
|
32
|
+
schema: 1;
|
|
33
|
+
sources: ExternalSource[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Per-type active source selection. Only types reachable from more than
|
|
38
|
+
* one source need an entry — single-source types have no ambiguity.
|
|
39
|
+
*
|
|
40
|
+
* Shape: { active: { "<type>": "<source-name>" } }
|
|
41
|
+
*/
|
|
42
|
+
export interface ProvidersActiveFile {
|
|
43
|
+
schema: 1;
|
|
44
|
+
active: Record<string, string>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const SOURCES_FILENAME = 'providers-sources.json';
|
|
48
|
+
const ACTIVE_FILENAME = 'providers-active.json';
|
|
49
|
+
|
|
50
|
+
function adhdevDir(): string {
|
|
51
|
+
return path.join(os.homedir(), '.adhdev');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function externalRoot(): string {
|
|
55
|
+
return path.join(adhdevDir(), 'external');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function sourcesFilePath(): string {
|
|
59
|
+
return path.join(adhdevDir(), SOURCES_FILENAME);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function activeFilePath(): string {
|
|
63
|
+
return path.join(adhdevDir(), ACTIVE_FILENAME);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function ensureAdhdevDir(): void {
|
|
67
|
+
const d = adhdevDir();
|
|
68
|
+
if (!fs.existsSync(d)) fs.mkdirSync(d, { recursive: true });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function loadExternalSources(): ExternalSourcesFile {
|
|
72
|
+
const p = sourcesFilePath();
|
|
73
|
+
if (!fs.existsSync(p)) return { schema: 1, sources: [] };
|
|
74
|
+
try {
|
|
75
|
+
const raw = JSON.parse(fs.readFileSync(p, 'utf-8'));
|
|
76
|
+
if (!raw || typeof raw !== 'object') return { schema: 1, sources: [] };
|
|
77
|
+
const sources = Array.isArray(raw.sources) ? raw.sources.filter(isValidSource) : [];
|
|
78
|
+
return { schema: 1, sources };
|
|
79
|
+
} catch {
|
|
80
|
+
return { schema: 1, sources: [] };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function saveExternalSources(file: ExternalSourcesFile): void {
|
|
85
|
+
ensureAdhdevDir();
|
|
86
|
+
const tmp = sourcesFilePath() + '.tmp';
|
|
87
|
+
fs.writeFileSync(tmp, JSON.stringify(file, null, 2) + '\n', 'utf-8');
|
|
88
|
+
fs.renameSync(tmp, sourcesFilePath());
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function loadProvidersActive(): ProvidersActiveFile {
|
|
92
|
+
const p = activeFilePath();
|
|
93
|
+
if (!fs.existsSync(p)) return { schema: 1, active: {} };
|
|
94
|
+
try {
|
|
95
|
+
const raw = JSON.parse(fs.readFileSync(p, 'utf-8'));
|
|
96
|
+
if (!raw || typeof raw !== 'object') return { schema: 1, active: {} };
|
|
97
|
+
const active = raw.active && typeof raw.active === 'object' ? raw.active : {};
|
|
98
|
+
return { schema: 1, active };
|
|
99
|
+
} catch {
|
|
100
|
+
return { schema: 1, active: {} };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function saveProvidersActive(file: ProvidersActiveFile): void {
|
|
105
|
+
ensureAdhdevDir();
|
|
106
|
+
const tmp = activeFilePath() + '.tmp';
|
|
107
|
+
fs.writeFileSync(tmp, JSON.stringify(file, null, 2) + '\n', 'utf-8');
|
|
108
|
+
fs.renameSync(tmp, activeFilePath());
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function isValidSource(x: unknown): x is ExternalSource {
|
|
112
|
+
if (!x || typeof x !== 'object') return false;
|
|
113
|
+
const s = x as Record<string, unknown>;
|
|
114
|
+
return typeof s.name === 'string' && s.name.length > 0
|
|
115
|
+
&& typeof s.url === 'string' && s.url.length > 0
|
|
116
|
+
&& typeof s.ref === 'string' && s.ref.length > 0
|
|
117
|
+
&& typeof s.addedAt === 'string';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Derive a short identifier from a git URL when the user didn't supply one.
|
|
122
|
+
* https://github.com/vendor/extra-providers.git → "@vendor-extra-providers"
|
|
123
|
+
* git@github.com:vendor/extra-providers → "@vendor-extra-providers"
|
|
124
|
+
*
|
|
125
|
+
* Idempotent; safe to call before validation since it produces a string
|
|
126
|
+
* regardless of input shape.
|
|
127
|
+
*/
|
|
128
|
+
export function deriveSourceName(url: string): string {
|
|
129
|
+
const m = url.match(/[/:]([^/:]+)\/([^/]+?)(?:\.git)?$/);
|
|
130
|
+
if (!m) return '@source';
|
|
131
|
+
const owner = m[1].toLowerCase().replace(/[^a-z0-9_-]/g, '-');
|
|
132
|
+
const repo = m[2].toLowerCase().replace(/[^a-z0-9_-]/g, '-');
|
|
133
|
+
return `@${owner}-${repo}`;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Return the per-source category/type tree currently on disk under
|
|
138
|
+
* ~/.adhdev/external/<source>/. Used by the conflict detector and by
|
|
139
|
+
* list_provider_sources.
|
|
140
|
+
*/
|
|
141
|
+
export interface SourceInventoryEntry {
|
|
142
|
+
sourceName: string;
|
|
143
|
+
/** Map: category → list of provider types. */
|
|
144
|
+
providers: Record<string, string[]>;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function inventoryExternalSources(): SourceInventoryEntry[] {
|
|
148
|
+
const root = externalRoot();
|
|
149
|
+
if (!fs.existsSync(root)) return [];
|
|
150
|
+
const out: SourceInventoryEntry[] = [];
|
|
151
|
+
let entries: fs.Dirent[];
|
|
152
|
+
try { entries = fs.readdirSync(root, { withFileTypes: true }); }
|
|
153
|
+
catch { return []; }
|
|
154
|
+
for (const sourceEntry of entries) {
|
|
155
|
+
if (!sourceEntry.isDirectory()) continue;
|
|
156
|
+
const sourceName = sourceEntry.name;
|
|
157
|
+
const sourceDir = path.join(root, sourceName);
|
|
158
|
+
const providers: Record<string, string[]> = {};
|
|
159
|
+
let categoryEntries: fs.Dirent[];
|
|
160
|
+
try { categoryEntries = fs.readdirSync(sourceDir, { withFileTypes: true }); }
|
|
161
|
+
catch { continue; }
|
|
162
|
+
for (const categoryEntry of categoryEntries) {
|
|
163
|
+
if (!categoryEntry.isDirectory()) continue;
|
|
164
|
+
const category = categoryEntry.name;
|
|
165
|
+
const categoryDir = path.join(sourceDir, category);
|
|
166
|
+
let typeEntries: fs.Dirent[];
|
|
167
|
+
try { typeEntries = fs.readdirSync(categoryDir, { withFileTypes: true }); }
|
|
168
|
+
catch { continue; }
|
|
169
|
+
const types: string[] = [];
|
|
170
|
+
for (const typeEntry of typeEntries) {
|
|
171
|
+
if (!typeEntry.isDirectory()) continue;
|
|
172
|
+
// Only count it as a provider if a manifest file exists
|
|
173
|
+
const typeDir = path.join(categoryDir, typeEntry.name);
|
|
174
|
+
const hasV1 = fs.existsSync(path.join(typeDir, 'provider.v1.json'));
|
|
175
|
+
const hasV0 = fs.existsSync(path.join(typeDir, 'provider.json'));
|
|
176
|
+
if (hasV1 || hasV0) types.push(typeEntry.name);
|
|
177
|
+
}
|
|
178
|
+
if (types.length > 0) providers[category] = types;
|
|
179
|
+
}
|
|
180
|
+
out.push({ sourceName, providers });
|
|
181
|
+
}
|
|
182
|
+
return out;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* For a given category+type, list every source that currently exposes it.
|
|
187
|
+
* Returns source names in disk-walk order; callers can use the first one
|
|
188
|
+
* when no explicit active selection exists.
|
|
189
|
+
*/
|
|
190
|
+
export function sourcesProviding(category: string, type: string): string[] {
|
|
191
|
+
const inventory = inventoryExternalSources();
|
|
192
|
+
return inventory
|
|
193
|
+
.filter(s => (s.providers[category] || []).includes(type))
|
|
194
|
+
.map(s => s.sourceName);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Resolve which source should be active for a given category+type.
|
|
199
|
+
* - If exactly one source provides it → that source.
|
|
200
|
+
* - If multiple sources provide it → the one named in providers-active.json
|
|
201
|
+
* (when present) or null (ambiguous; loader should warn and pick
|
|
202
|
+
* the first deterministically so daemon doesn't refuse to boot).
|
|
203
|
+
* - If none → null.
|
|
204
|
+
*/
|
|
205
|
+
export function resolveActiveSource(
|
|
206
|
+
category: string,
|
|
207
|
+
type: string,
|
|
208
|
+
activeFile?: ProvidersActiveFile,
|
|
209
|
+
): { source: string | null; ambiguous: boolean; candidates: string[] } {
|
|
210
|
+
const candidates = sourcesProviding(category, type);
|
|
211
|
+
if (candidates.length === 0) return { source: null, ambiguous: false, candidates };
|
|
212
|
+
if (candidates.length === 1) return { source: candidates[0], ambiguous: false, candidates };
|
|
213
|
+
const explicit = (activeFile ?? loadProvidersActive()).active[type];
|
|
214
|
+
if (explicit && candidates.includes(explicit)) {
|
|
215
|
+
return { source: explicit, ambiguous: false, candidates };
|
|
216
|
+
}
|
|
217
|
+
return { source: candidates[0], ambiguous: true, candidates };
|
|
218
|
+
}
|
|
@@ -20,7 +20,7 @@ import { LOG } from '../logging/logger.js';
|
|
|
20
20
|
import { buildPersistedProviderEffectMessage, normalizeProviderEffects } from './control-effects.js';
|
|
21
21
|
import { validateReadChatResultPayload } from './read-chat-contract.js';
|
|
22
22
|
import type { ChatMessage } from '../types.js';
|
|
23
|
-
import { formatAutoApprovalMessage,
|
|
23
|
+
import { formatAutoApprovalMessage, pickAutoApprovalButton } from './approval-utils.js';
|
|
24
24
|
import { mergeProviderPatchState, resolveProviderStateSurface } from './provider-patch-state.js';
|
|
25
25
|
import { buildChatMessage, buildRuntimeSystemChatMessage, normalizeChatMessages, extractFinalSummaryFromMessages } from './chat-message-normalization.js';
|
|
26
26
|
import { getProviderSessionCapabilities, IDE_PROVIDER_SESSION_CAPABILITIES_BASE } from './open-panel-support.js';
|
|
@@ -43,6 +43,20 @@ type ReadChatPayload = {
|
|
|
43
43
|
[key: string]: unknown;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
+
async function withTimeout<T>(promise: Promise<T>, timeoutMs: number, label: string): Promise<T> {
|
|
47
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
48
|
+
try {
|
|
49
|
+
return await Promise.race([
|
|
50
|
+
promise,
|
|
51
|
+
new Promise<never>((_, reject) => {
|
|
52
|
+
timer = setTimeout(() => reject(new Error(`${label} timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
53
|
+
}),
|
|
54
|
+
]);
|
|
55
|
+
} finally {
|
|
56
|
+
if (timer) clearTimeout(timer);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
46
60
|
export class IdeProviderInstance implements ProviderInstance {
|
|
47
61
|
readonly type: string;
|
|
48
62
|
readonly category = 'ide' as const;
|
|
@@ -320,7 +334,7 @@ export class IdeProviderInstance implements ProviderInstance {
|
|
|
320
334
|
if (webviewScript) {
|
|
321
335
|
const matchText = this.provider.webviewMatchText;
|
|
322
336
|
const matchFn = matchText ? (body: string) => body.includes(matchText) : undefined;
|
|
323
|
-
const webviewRaw = await cdp.evaluateInWebviewFrame(webviewScript, matchFn);
|
|
337
|
+
const webviewRaw = await withTimeout(cdp.evaluateInWebviewFrame(webviewScript, matchFn), 30000, 'evaluateInWebviewFrame');
|
|
324
338
|
if (webviewRaw) {
|
|
325
339
|
raw = typeof webviewRaw === 'string' ? (() => { try { return JSON.parse(webviewRaw); } catch { return null; } })() : webviewRaw;
|
|
326
340
|
}
|
|
@@ -331,7 +345,7 @@ export class IdeProviderInstance implements ProviderInstance {
|
|
|
331
345
|
if (!raw) {
|
|
332
346
|
const readChatScript = this.getReadChatScript();
|
|
333
347
|
if (!readChatScript) return;
|
|
334
|
-
raw = await cdp.evaluate(readChatScript, 30000);
|
|
348
|
+
raw = await withTimeout(cdp.evaluate(readChatScript, 30000), 30000, 'evaluate.readChatScript');
|
|
335
349
|
if (typeof raw === 'string') {
|
|
336
350
|
try { raw = JSON.parse(raw); } catch { return; }
|
|
337
351
|
}
|
|
@@ -694,7 +708,7 @@ export class IdeProviderInstance implements ProviderInstance {
|
|
|
694
708
|
|
|
695
709
|
this.autoApproveBusy = true;
|
|
696
710
|
try {
|
|
697
|
-
const { label: targetButton } =
|
|
711
|
+
const { label: targetButton } = pickAutoApprovalButton(_chatData?.activeModal?.buttons);
|
|
698
712
|
|
|
699
713
|
const script = scriptFn({ action: 'approve', button: targetButton, buttonText: targetButton });
|
|
700
714
|
if (!script) return;
|
|
@@ -706,7 +720,7 @@ export class IdeProviderInstance implements ProviderInstance {
|
|
|
706
720
|
);
|
|
707
721
|
|
|
708
722
|
LOG.info('IdeInstance', `[IdeInstance:${this.type}] autoApprove: executing resolveAction for "${targetButton}"`);
|
|
709
|
-
let rawResult = await cdp.evaluate(script, 10000);
|
|
723
|
+
let rawResult = await withTimeout(cdp.evaluate(script, 10000), 10000, 'evaluate.autoApprove');
|
|
710
724
|
if (typeof rawResult === 'string') {
|
|
711
725
|
try { rawResult = JSON.parse(rawResult); } catch { }
|
|
712
726
|
}
|