@adhdev/daemon-core 0.9.82-rc.16 → 0.9.82-rc.161

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.
Files changed (209) hide show
  1. package/dist/boot/process-hardening.d.ts +50 -0
  2. package/dist/chat/source-machine.d.ts +166 -0
  3. package/dist/chat/source-resolver.d.ts +104 -0
  4. package/dist/chat/subscription-updates.d.ts +1 -0
  5. package/dist/cli-adapter-types.d.ts +19 -2
  6. package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
  7. package/dist/cli-adapters/cli-state-engine.d.ts +178 -0
  8. package/dist/cli-adapters/provider-cli-adapter.d.ts +104 -63
  9. package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
  10. package/dist/cli-adapters/provider-cli-shared.d.ts +27 -0
  11. package/dist/commands/handler.d.ts +66 -0
  12. package/dist/commands/mesh-coordinator.d.ts +72 -1
  13. package/dist/commands/router.d.ts +22 -0
  14. package/dist/config/chat-history.d.ts +7 -0
  15. package/dist/config/config.d.ts +5 -0
  16. package/dist/config/mesh-config.d.ts +71 -1
  17. package/dist/git/git-commands.d.ts +5 -1
  18. package/dist/index.d.ts +31 -6
  19. package/dist/index.js +17210 -3575
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +17127 -3551
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/installer.d.ts +1 -4
  24. package/dist/ipc/local-ipc-server.d.ts +91 -0
  25. package/dist/launch.d.ts +1 -1
  26. package/dist/logging/async-batch-writer.d.ts +10 -0
  27. package/dist/mesh/beads-db.d.ts +72 -0
  28. package/dist/mesh/contracts.d.ts +164 -0
  29. package/dist/mesh/coordinator-prompt.d.ts +30 -0
  30. package/dist/mesh/coordinator-registry.d.ts +59 -0
  31. package/dist/mesh/mesh-active-work.d.ts +90 -0
  32. package/dist/mesh/mesh-events.d.ts +77 -5
  33. package/dist/mesh/mesh-fast-forward.d.ts +39 -0
  34. package/dist/mesh/mesh-host-ownership.d.ts +9 -0
  35. package/dist/mesh/mesh-ledger.d.ts +58 -1
  36. package/dist/mesh/mesh-refine-status.d.ts +26 -0
  37. package/dist/mesh/mesh-work-queue.d.ts +44 -5
  38. package/dist/mesh/preview-freshness.d.ts +18 -0
  39. package/dist/mesh/refine-config.d.ts +193 -0
  40. package/dist/mesh/worktree-bootstrap-config.d.ts +113 -0
  41. package/dist/providers/approval-utils.d.ts +9 -0
  42. package/dist/providers/cli-provider-instance.d.ts +7 -2
  43. package/dist/providers/contracts.d.ts +98 -5
  44. package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
  45. package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
  46. package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
  47. package/dist/providers/native-history/dispatcher.d.ts +24 -0
  48. package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
  49. package/dist/providers/native-history/index.d.ts +13 -0
  50. package/dist/providers/provider-loader.d.ts +19 -1
  51. package/dist/providers/read-chat-contract.d.ts +29 -0
  52. package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
  53. package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +85 -0
  54. package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
  55. package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +64 -0
  56. package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
  57. package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
  58. package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
  59. package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
  60. package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
  61. package/dist/providers/sdk/v1/index.d.ts +30 -0
  62. package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
  63. package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
  64. package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
  65. package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
  66. package/dist/providers/sdk/v1/types/common/index.d.ts +169 -0
  67. package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
  68. package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
  69. package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
  70. package/dist/providers/spec/adapter.d.ts +56 -0
  71. package/dist/providers/spec/cli-adapter.d.ts +76 -0
  72. package/dist/providers/spec/driver.d.ts +148 -0
  73. package/dist/providers/spec/evaluator.d.ts +47 -0
  74. package/dist/providers/spec/loader.d.ts +14 -0
  75. package/dist/providers/spec/native-history-executor.d.ts +39 -0
  76. package/dist/providers/spec/route.d.ts +4 -0
  77. package/dist/providers/spec/schema.gen.d.ts +507 -0
  78. package/dist/providers/spec/types.d.ts +211 -0
  79. package/dist/providers/transcript-v2.d.ts +176 -0
  80. package/dist/repo-mesh-types.d.ts +100 -1
  81. package/dist/sessions/registry.d.ts +3 -0
  82. package/dist/shared-types.d.ts +12 -0
  83. package/dist/status/reporter.d.ts +2 -0
  84. package/dist/status/snapshot.d.ts +1 -0
  85. package/dist/types.d.ts +5 -0
  86. package/package.json +7 -2
  87. package/src/boot/daemon-lifecycle.ts +17 -10
  88. package/src/boot/process-hardening.ts +89 -0
  89. package/src/chat/source-machine.ts +534 -0
  90. package/src/chat/source-resolver.ts +0 -0
  91. package/src/chat/subscription-updates.ts +14 -1
  92. package/src/cli-adapter-types.d.ts +1 -0
  93. package/src/cli-adapter-types.ts +18 -2
  94. package/src/cli-adapters/cli-script-runner.ts +421 -0
  95. package/src/cli-adapters/cli-state-engine.ts +1086 -0
  96. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  97. package/src/cli-adapters/provider-cli-adapter.ts +664 -1137
  98. package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
  99. package/src/cli-adapters/provider-cli-parse.ts +13 -0
  100. package/src/cli-adapters/provider-cli-runtime.ts +3 -1
  101. package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
  102. package/src/cli-adapters/provider-cli-shared.ts +57 -11
  103. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +17 -1
  104. package/src/cli-adapters/terminal-backends/xterm-backend.ts +8 -1
  105. package/src/commands/chat-commands.ts +1597 -60
  106. package/src/commands/cli-manager.ts +195 -3
  107. package/src/commands/handler.ts +547 -2
  108. package/src/commands/mesh-coordinator.ts +231 -127
  109. package/src/commands/router.ts +3547 -502
  110. package/src/config/chat-history.ts +87 -24
  111. package/src/config/config.ts +12 -0
  112. package/src/config/mesh-config.ts +264 -2
  113. package/src/config/recent-activity.ts +8 -2
  114. package/src/daemon/dev-cli-debug.ts +10 -1
  115. package/src/detection/ide-detector.ts +26 -16
  116. package/src/git/git-commands.ts +17 -5
  117. package/src/git/git-worktree.ts +8 -1
  118. package/src/index.ts +91 -5
  119. package/src/installer.d.ts +1 -1
  120. package/src/installer.ts +8 -6
  121. package/src/ipc/local-ipc-server.ts +278 -0
  122. package/src/launch.d.ts +1 -1
  123. package/src/launch.ts +37 -28
  124. package/src/logging/async-batch-writer.ts +55 -0
  125. package/src/logging/logger.ts +2 -1
  126. package/src/mesh/beads-db.ts +479 -0
  127. package/src/mesh/contracts.ts +329 -0
  128. package/src/mesh/coordinator-prompt.ts +204 -30
  129. package/src/mesh/coordinator-registry.ts +121 -0
  130. package/src/mesh/mesh-active-work.ts +437 -0
  131. package/src/mesh/mesh-events.ts +820 -61
  132. package/src/mesh/mesh-fast-forward.ts +430 -0
  133. package/src/mesh/mesh-host-ownership.ts +73 -0
  134. package/src/mesh/mesh-ledger.ts +457 -104
  135. package/src/mesh/mesh-refine-status.ts +144 -0
  136. package/src/mesh/mesh-work-queue.ts +216 -158
  137. package/src/mesh/preview-freshness.ts +118 -0
  138. package/src/mesh/refine-config.ts +366 -0
  139. package/src/mesh/worktree-bootstrap-config.ts +247 -0
  140. package/src/providers/approval-utils.ts +39 -5
  141. package/src/providers/chat-message-normalization.ts +4 -11
  142. package/src/providers/cli-provider-instance.ts +388 -47
  143. package/src/providers/contracts.ts +105 -5
  144. package/src/providers/ide-provider-instance.ts +17 -3
  145. package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
  146. package/src/providers/native-history/claude-cli-transcript.ts +396 -0
  147. package/src/providers/native-history/codex-cli-transcript.ts +419 -0
  148. package/src/providers/native-history/dispatcher.ts +227 -0
  149. package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
  150. package/src/providers/native-history/index.ts +30 -0
  151. package/src/providers/provider-loader.ts +420 -31
  152. package/src/providers/provider-schema.ts +31 -13
  153. package/src/providers/read-chat-contract.ts +76 -16
  154. package/src/providers/sdk/README.md +49 -0
  155. package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
  156. package/src/providers/sdk/v1/builders/cli/detect-status.ts +262 -0
  157. package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
  158. package/src/providers/sdk/v1/builders/cli/parse-approval.ts +245 -0
  159. package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
  160. package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
  161. package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
  162. package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
  163. package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
  164. package/src/providers/sdk/v1/index.ts +152 -0
  165. package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
  166. package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
  167. package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
  168. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +457 -0
  169. package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
  170. package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
  171. package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
  172. package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
  173. package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
  174. package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
  175. package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
  176. package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
  177. package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +119 -0
  178. package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
  179. package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
  180. package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
  181. package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
  182. package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
  183. package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
  184. package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
  185. package/src/providers/sdk/v1/types/cli/index.ts +365 -0
  186. package/src/providers/sdk/v1/types/common/index.ts +210 -0
  187. package/src/providers/sdk/v1/validators/index.ts +19 -0
  188. package/src/providers/sdk/v1/validators/manifest.ts +110 -0
  189. package/src/providers/sdk/v1/validators/taint.ts +309 -0
  190. package/src/providers/spec/adapter.ts +153 -0
  191. package/src/providers/spec/cli-adapter.ts +318 -0
  192. package/src/providers/spec/driver.ts +498 -0
  193. package/src/providers/spec/evaluator.ts +268 -0
  194. package/src/providers/spec/loader.ts +130 -0
  195. package/src/providers/spec/native-history-executor.ts +612 -0
  196. package/src/providers/spec/route.ts +51 -0
  197. package/src/providers/spec/schema.gen.ts +507 -0
  198. package/src/providers/spec/schema.json +210 -0
  199. package/src/providers/spec/types.ts +230 -0
  200. package/src/providers/transcript-v2.ts +567 -0
  201. package/src/providers/version-archive.ts +38 -20
  202. package/src/repo-mesh-types.ts +110 -1
  203. package/src/sessions/registry.ts +3 -0
  204. package/src/shared-types.ts +9 -0
  205. package/src/status/builders.ts +23 -6
  206. package/src/status/reporter.ts +15 -0
  207. package/src/status/snapshot.ts +35 -11
  208. package/src/system/host-memory.ts +29 -12
  209. package/src/types.ts +5 -0
@@ -10,6 +10,14 @@ import type { ProviderSummaryMetadata } from '../shared-types.js';
10
10
  import type { ChatMessageKind } from './chat-message-normalization.js';
11
11
  export type ReadChatTurnStatus = 'open' | 'waiting_approval' | 'complete' | 'error';
12
12
  export interface ReadChatResult {
13
+ /**
14
+ * Declared chat contract version. Absent or `'1.0'` → legacy v1 payload
15
+ * (current shape). `'2.0'` → v2 payload conforming to transcript-v2.ts
16
+ * (ReadChatResultV2). Validators in read-chat-contract.ts route on this
17
+ * field. A1 only adds the field; A2 will make v2 the daemon-internal
18
+ * canonical form and reject unrecognised versions at provider load time.
19
+ */
20
+ contractVersion?: import('./transcript-v2.js').ChatContractVersion;
13
21
  messages: ChatMessage[];
14
22
  status: AgentStatus;
15
23
  activeModal?: ModalInfo | null;
@@ -297,7 +305,55 @@ export interface ProviderMeshCoordinatorConfig {
297
305
  /** Copyable setup template. Supports {{meshId}}, {{adhdevMcpCommand}}, {{workspace}}, {{serverName}}. */
298
306
  template?: string;
299
307
  };
308
+ /**
309
+ * How the coordinator system prompt reaches the launched CLI. Replaces the
310
+ * old hard-coded `if (cliType === 'claude-cli') push --append-system-prompt`
311
+ * branches in router.ts: a new CLI now ships its injection rule in its
312
+ * provider.v1.json, no daemon code change needed. Users can override the
313
+ * rendered prompt or the injection mechanism per-provider; if omitted, no
314
+ * system prompt is injected (safe default — won't crash spawn with a flag
315
+ * the CLI doesn't recognize).
316
+ */
317
+ systemPromptInjection?: MeshCoordinatorSystemPromptInjection;
300
318
  }
319
+ /**
320
+ * Declarative description of how a CLI accepts a session-scoped system prompt.
321
+ *
322
+ * Modes:
323
+ * - cli_arg → push `flag` + prompt onto spawn args (Claude)
324
+ * - config_override → push `flag` + a templated key=value config override (Codex)
325
+ * - context_file → write prompt into a workspace markdown the CLI
326
+ * auto-loads as project context (Gemini, Antigravity)
327
+ * - env_var → expose prompt to the spawned process as $name (Hermes)
328
+ *
329
+ * The prompt text is templated with `{prompt}` (raw) or `{prompt_json}`
330
+ * (JSON-encoded for embedding inside config-override strings).
331
+ */
332
+ export type MeshCoordinatorSystemPromptInjection = {
333
+ mode: 'cli_arg';
334
+ /** Spawn-args flag, e.g. '--append-system-prompt'. The prompt becomes the next argv. */
335
+ flag: string;
336
+ } | {
337
+ mode: 'config_override';
338
+ /** Spawn-args flag, e.g. '-c'. Followed by `template` with placeholders rendered. */
339
+ flag: string;
340
+ /** Template using {prompt} or {prompt_json}, e.g. 'developer_instructions={prompt_json}'. */
341
+ template: string;
342
+ } | {
343
+ mode: 'context_file';
344
+ /** Workspace-relative file path the CLI auto-loads, e.g. 'AGENTS.md' or 'GEMINI.md'. */
345
+ path: string;
346
+ /**
347
+ * Optional wrapper around the prompt. Use `{prompt}` placeholder. Existing
348
+ * wrapper-delimited blocks are replaced rather than duplicated, so re-launching
349
+ * a coordinator doesn't pile up copies. If omitted, the prompt is appended raw.
350
+ */
351
+ wrapper?: string;
352
+ } | {
353
+ mode: 'env_var';
354
+ /** Env-var name, e.g. 'HERMES_EPHEMERAL_SYSTEM_PROMPT'. */
355
+ name: string;
356
+ };
301
357
  export interface ProviderCompatibilityEntry {
302
358
  ideVersion: string;
303
359
  scriptDir: string;
@@ -378,6 +434,14 @@ export interface ProviderModule {
378
434
  extensionIdPattern_flags?: string;
379
435
  compatibility?: ProviderCompatibilityEntry[];
380
436
  defaultScriptDir?: string;
437
+ /**
438
+ * v1 declarative tui block (spinner/settledPrompt/modal/dispatchOrder/etc).
439
+ * When present, the daemon's CliScriptRunner builds canonical
440
+ * (input → verdict) functions from this and injects them into provider
441
+ * scripts as `sdk.declarativeDetectStatus` and `sdk.declarativeParseApproval`.
442
+ * v0 / verified-tier providers can omit this entirely.
443
+ */
444
+ tui?: Record<string, unknown>;
381
445
  /**
382
446
  * Scripts that can run at the IDE main-page level (not just inside the extension webview session frame).
383
447
  * Default: ['listModes', 'setMode', 'listModels', 'setModel'].
@@ -429,8 +493,16 @@ export interface ProviderModule {
429
493
  /** History behavior config — controls message filtering and collapse during replay */
430
494
  historyBehavior?: ProviderHistoryBehavior;
431
495
  /**
432
- * Canonical history sync config — for providers that maintain native history files.
433
- * When set, daemon syncs from native format into ADHDev JSONL store on each tick.
496
+ * Native history config — for providers that maintain native history files.
497
+ * When set, daemon reads/lists provider-native transcripts directly. This is
498
+ * the canonical v1 field name; the legacy `canonicalHistory` field name is
499
+ * still accepted by the loader and aliased onto this field at load time.
500
+ */
501
+ nativeHistory?: NativeHistoryConfig;
502
+ /**
503
+ * @deprecated Legacy v0 alias for {@link ProviderModule.nativeHistory}.
504
+ * Loader populates this from `nativeHistory` so existing internal readers
505
+ * keep working during the transition. Remove after one release.
434
506
  */
435
507
  canonicalHistory?: ProviderCanonicalHistoryConfig;
436
508
  /**
@@ -561,20 +633,25 @@ export interface ProviderHistoryBehavior {
561
633
  * daemon-core. They let each provider own native transcript file discovery and
562
634
  * parsing while daemon-core only validates/pages the normalized result.
563
635
  */
564
- export interface ProviderCanonicalHistoryScriptsConfig {
636
+ export interface NativeHistoryScriptsConfig {
565
637
  /** Reads one native session. Default: 'readNativeHistory'. */
566
638
  readSession?: string;
567
639
  /** Lists native sessions with summary metadata. Default: 'listNativeHistory'. */
568
640
  listSessions?: string;
569
641
  }
570
642
  /**
571
- * Canonical history sync config for providers that maintain their own native history files.
643
+ * @deprecated Use {@link NativeHistoryScriptsConfig}. Retained as an alias for
644
+ * one release so external consumers that referenced the old name keep compiling.
645
+ */
646
+ export type ProviderCanonicalHistoryScriptsConfig = NativeHistoryScriptsConfig;
647
+ /**
648
+ * Native history config — for providers that maintain their own native history files.
572
649
  *
573
650
  * Preferred mode is provider-owned scripts via `scripts`. `format` is now an
574
651
  * opaque provider label retained for diagnostics/backward compatibility; daemon
575
652
  * live paths must not branch on provider-specific format values.
576
653
  */
577
- export interface ProviderCanonicalHistoryConfig {
654
+ export interface NativeHistoryConfig {
578
655
  /** Opaque provider-owned history format label. */
579
656
  format?: string;
580
657
  /** Optional native history glob/template for diagnostics only. */
@@ -590,7 +667,23 @@ export interface ProviderCanonicalHistoryConfig {
590
667
  * Omitted mode defaults to 'native-source'.
591
668
  */
592
669
  mode?: 'native-source' | 'materialized-mirror' | 'disabled';
670
+ /**
671
+ * Chat transcript contract version this provider's read_chat output
672
+ * conforms to. See transcript-v2.ts for the v2 invariants. Absent or `'1.0'`
673
+ * → legacy v1 payload (current behaviour). `'2.0'` → strict v2 payload
674
+ * (stable providerUnitKey/bubbleId/sequence, strict enums, honest coverage).
675
+ *
676
+ * A1 only surfaces this field; validators in read-chat-contract.ts route
677
+ * on it. A2 makes v2 the daemon-internal canonical form and rejects
678
+ * unrecognised values at provider load time.
679
+ */
680
+ contractVersion?: import('./transcript-v2.js').ChatContractVersion;
593
681
  }
682
+ /**
683
+ * @deprecated Use {@link NativeHistoryConfig}. Retained as an alias for one
684
+ * release so external consumers that referenced the old name keep compiling.
685
+ */
686
+ export type ProviderCanonicalHistoryConfig = NativeHistoryConfig;
594
687
  /**
595
688
  * Auto-implement spawn config — controls how the provider is spawned for autonomous AI-driven
596
689
  * provider script implementation (dev-auto-implement.ts).
@@ -0,0 +1,100 @@
1
+ /**
2
+ * antigravity-cli-transcript — Daemon-side built-in native history adapter for antigravity-cli.
3
+ *
4
+ * Antigravity CLI stores conversations in multiple complementary locations:
5
+ *
6
+ * 1. ~/.gemini/antigravity-cli/history.jsonl
7
+ * Lightweight index of user prompts, one row per turn:
8
+ * { conversationId: string, display: string, workspace: string, timestamp: number }
9
+ *
10
+ * 2. ~/.gemini/antigravity-cli/brain/<uuid>/.system_generated/logs/transcript*.jsonl
11
+ * Per-session full transcript, one row per agent step:
12
+ * { source: 'USER_EXPLICIT'|'MODEL', type: string, content: string, status: 'DONE'|..., created_at: number }
13
+ *
14
+ * 3. ~/.gemini/antigravity-cli/conversations/<uuid>.pb
15
+ * Protobuf binary — schema not publicly documented. Adapter extracts
16
+ * printable UTF-8 text runs as best-effort content (no proto library needed).
17
+ *
18
+ * This adapter provides:
19
+ * - Full coverage when a brain transcript exists (authoritative source).
20
+ * - Partial coverage (user prompts only) from history.jsonl as fallback.
21
+ * - Best-effort raw-string extraction from .pb files when no other source exists.
22
+ *
23
+ * watchPath (from provider.v1.json):
24
+ * ~/.gemini/antigravity-cli/history.jsonl
25
+ * ~/.gemini/antigravity-cli/brain/{uuid}/.system_generated/logs/transcript*.jsonl
26
+ * ~/.gemini/antigravity-cli/conversations/{uuid}.pb
27
+ *
28
+ * OSS code (AGPL-3.0). Must not import from packages/ (proprietary).
29
+ */
30
+ export type NativeHistoryRole = 'user' | 'assistant' | 'system';
31
+ export type NativeHistoryKind = 'standard' | 'tool' | 'session_start';
32
+ export interface NativeHistoryMessage {
33
+ ts: string;
34
+ receivedAt: number;
35
+ role: NativeHistoryRole;
36
+ content: string;
37
+ kind: NativeHistoryKind;
38
+ senderName?: string;
39
+ agent: 'antigravity-cli';
40
+ historySessionId: string;
41
+ workspace?: string;
42
+ /** Stable per-message identity (v2 contract). */
43
+ providerUnitKey?: string;
44
+ }
45
+ export interface NativeHistorySession {
46
+ messages: NativeHistoryMessage[];
47
+ providerSessionId: string;
48
+ source: 'provider-native';
49
+ sourcePath: string;
50
+ sourceMtimeMs: number;
51
+ /**
52
+ * 'full' — brain transcript was available and parsed.
53
+ * 'partial' — only history.jsonl user-prompts are available.
54
+ * 'best-effort' — .pb file bytes were used for raw text extraction.
55
+ */
56
+ nativeHistoryCoverage: 'full' | 'partial' | 'best-effort';
57
+ workspace?: string;
58
+ partialReason?: string;
59
+ }
60
+ export interface NativeHistorySessionMeta {
61
+ historySessionId: string;
62
+ sessionId: string;
63
+ sourcePath: string;
64
+ sourceMtimeMs: number;
65
+ messageCount: number;
66
+ firstMessageAt: number;
67
+ lastMessageAt: number;
68
+ sessionTitle?: string;
69
+ preview?: string;
70
+ workspace?: string;
71
+ agent: 'antigravity-cli';
72
+ source: 'provider-native';
73
+ nativeHistoryCoverage: 'full' | 'partial' | 'best-effort';
74
+ partialReason?: string;
75
+ }
76
+ /**
77
+ * Read a single Antigravity CLI session by its source file path.
78
+ *
79
+ * `sessionPath` is the absolute path to one of:
80
+ * - A brain transcript JSONL: ~/.gemini/antigravity-cli/brain/<uuid>/.system_generated/logs/transcript*.jsonl
81
+ * - The shared history.jsonl: ~/.gemini/antigravity-cli/history.jsonl
82
+ * - A conversation protobuf: ~/.gemini/antigravity-cli/conversations/<uuid>.pb
83
+ *
84
+ * The session UUID is inferred from the directory name (brain), filename (pb), or
85
+ * must be provided explicitly via `sessionId` for history.jsonl paths.
86
+ *
87
+ * Returns `null` when the file is missing, empty, or yields no parseable messages.
88
+ */
89
+ export declare function readSession(sessionPath: string, sessionId?: string, workspace?: string): NativeHistorySession | null;
90
+ /**
91
+ * List all Antigravity CLI sessions found across all watchPath locations.
92
+ *
93
+ * Priority:
94
+ * 1. Brain transcript sessions (full coverage) — preferred source.
95
+ * 2. History JSONL entries without a brain transcript (partial coverage).
96
+ * 3. .pb conversation files without any other source (best-effort).
97
+ *
98
+ * Returns summary metadata sorted by most recently updated first.
99
+ */
100
+ export declare function listSessions(_watchPath: string): Promise<NativeHistorySessionMeta[]>;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * claude-cli-transcript — Daemon-side built-in native history adapter for claude-cli.
3
+ *
4
+ * Reads Claude Code JSONL transcript files directly without shelling out to a JS override.
5
+ * The transcript format is one JSON object per line, where each line has:
6
+ * - type: 'user' | 'assistant'
7
+ * - message: { content: string | ContentBlock[] }
8
+ * - timestamp: number (ms epoch) | string (ISO)
9
+ * - sessionId?: string
10
+ * - cwd?: string
11
+ *
12
+ * OSS code (AGPL-3.0). Must not import from packages/ (proprietary).
13
+ */
14
+ export type NativeHistoryRole = 'user' | 'assistant' | 'system';
15
+ export type NativeHistoryKind = 'standard' | 'tool' | 'session_start';
16
+ export interface NativeHistoryMessage {
17
+ ts: string;
18
+ receivedAt: number;
19
+ role: NativeHistoryRole;
20
+ content: string;
21
+ kind: NativeHistoryKind;
22
+ senderName?: string;
23
+ agent: 'claude-cli';
24
+ historySessionId: string;
25
+ workspace?: string;
26
+ /** Stable per-message identity (v2 contract). */
27
+ providerUnitKey?: string;
28
+ }
29
+ export interface NativeHistorySession {
30
+ messages: NativeHistoryMessage[];
31
+ providerSessionId: string;
32
+ source: 'provider-native';
33
+ sourcePath: string;
34
+ sourceMtimeMs: number;
35
+ nativeHistoryCoverage: 'full';
36
+ workspace?: string;
37
+ }
38
+ export interface NativeHistorySessionMeta {
39
+ historySessionId: string;
40
+ sessionId: string;
41
+ sourcePath: string;
42
+ sourceMtimeMs: number;
43
+ messageCount: number;
44
+ firstMessageAt: number;
45
+ lastMessageAt: number;
46
+ sessionTitle?: string;
47
+ preview?: string;
48
+ workspace?: string;
49
+ agent: 'claude-cli';
50
+ source: 'provider-native';
51
+ nativeHistoryCoverage: 'full';
52
+ }
53
+ /**
54
+ * Read a single Claude Code session by its transcript file path.
55
+ *
56
+ * `sessionPath` is the absolute path to a `<uuid>.jsonl` file.
57
+ * Returns `null` when the file is missing, empty, or yields no parseable messages.
58
+ */
59
+ export declare function readSession(sessionPath: string): NativeHistorySession | null;
60
+ /**
61
+ * List all Claude Code sessions under the given glob-style watchPath base dir.
62
+ *
63
+ * `watchPath` is the pattern from provider.v1.json (`~/.claude/projects/**\/*.jsonl`).
64
+ * This implementation expands the home directory and scans `~/.claude/projects/`
65
+ * recursively, collecting all `.jsonl` files.
66
+ *
67
+ * Returns summary metadata for each session (no full message reads on this hot path;
68
+ * each file is opened only for lightweight scanning).
69
+ */
70
+ export declare function listSessions(watchPath: string): Promise<NativeHistorySessionMeta[]>;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * codex-cli-transcript — Daemon-side built-in native history adapter for codex-cli.
3
+ *
4
+ * Reads Codex CLI rollout JSONL session files directly without shelling out to a JS override.
5
+ * Files are stored at ~/.codex/sessions/<uuid>[-<slug>].jsonl.
6
+ *
7
+ * Format — each line is a JSON object of one of these types:
8
+ * { type: 'session_meta', timestamp: number, payload: { id: string, cwd: string, ... } }
9
+ * { type: 'response_item', timestamp: number, payload: { type: 'message', role: 'user'|'assistant', content: ... } }
10
+ * { type: 'response_item', timestamp: number, payload: { type: 'function_call' | 'custom_tool_call', name?: string, arguments?: string, input?: unknown } }
11
+ * { type: 'response_item', timestamp: number, payload: { type: 'function_call_output' | 'custom_tool_call_output', output?: string, result?: string } }
12
+ *
13
+ * watchPath (from provider.v1.json): ~/.codex/sessions
14
+ *
15
+ * OSS code (AGPL-3.0). Must not import from packages/ (proprietary).
16
+ */
17
+ export type NativeHistoryRole = 'user' | 'assistant' | 'system';
18
+ export type NativeHistoryKind = 'standard' | 'tool' | 'session_start';
19
+ export interface NativeHistoryMessage {
20
+ ts: string;
21
+ receivedAt: number;
22
+ role: NativeHistoryRole;
23
+ content: string;
24
+ kind: NativeHistoryKind;
25
+ senderName?: string;
26
+ agent: 'codex-cli';
27
+ historySessionId: string;
28
+ workspace?: string;
29
+ /** Stable per-message identity (v2 contract). */
30
+ providerUnitKey?: string;
31
+ }
32
+ export interface NativeHistorySession {
33
+ messages: NativeHistoryMessage[];
34
+ providerSessionId: string;
35
+ source: 'provider-native';
36
+ sourcePath: string;
37
+ sourceMtimeMs: number;
38
+ nativeHistoryCoverage: 'full';
39
+ workspace?: string;
40
+ }
41
+ export interface NativeHistorySessionMeta {
42
+ historySessionId: string;
43
+ sessionId: string;
44
+ sourcePath: string;
45
+ sourceMtimeMs: number;
46
+ messageCount: number;
47
+ firstMessageAt: number;
48
+ lastMessageAt: number;
49
+ sessionTitle?: string;
50
+ preview?: string;
51
+ workspace?: string;
52
+ agent: 'codex-cli';
53
+ source: 'provider-native';
54
+ nativeHistoryCoverage: 'full';
55
+ }
56
+ /**
57
+ * Read a single Codex CLI session by its JSONL file path.
58
+ *
59
+ * `sessionPath` is the absolute path to a `<uuid>[-<slug>].jsonl` file
60
+ * under ~/.codex/sessions/.
61
+ * Returns `null` when the file is missing, empty, or yields no parseable messages.
62
+ */
63
+ export declare function readSession(sessionPath: string): NativeHistorySession | null;
64
+ /**
65
+ * List all Codex CLI sessions under the given watchPath base dir.
66
+ *
67
+ * `watchPath` is the value from provider.v1.json (`~/.codex/sessions`).
68
+ * Expands the home directory and scans the directory recursively,
69
+ * collecting all `.jsonl` files.
70
+ *
71
+ * Returns summary metadata for each session, sorted by most recently updated first.
72
+ */
73
+ export declare function listSessions(watchPath: string): Promise<NativeHistorySessionMeta[]>;
@@ -0,0 +1,24 @@
1
+ export type ReaderId = 'claude-cli' | 'codex-cli' | 'antigravity-cli' | 'hermes-cli';
2
+ export interface NativeHistoryInput {
3
+ agentType?: string;
4
+ sessionId?: string;
5
+ providerSessionId?: string;
6
+ historySessionId?: string;
7
+ workspace?: string;
8
+ format?: string;
9
+ watchPath?: string;
10
+ args?: Record<string, unknown>;
11
+ }
12
+ export interface NativeHistoryResult {
13
+ messages: Array<{
14
+ role: string;
15
+ content: string;
16
+ receivedAt?: number;
17
+ kind?: string;
18
+ }>;
19
+ providerSessionId?: string;
20
+ sourcePath: string;
21
+ sourceMtimeMs: number;
22
+ nativeHistoryCoverage?: 'full' | 'partial' | 'best-effort';
23
+ }
24
+ export declare function createNativeHistoryDispatcher(reader: ReaderId): (input: NativeHistoryInput) => NativeHistoryResult | null;
@@ -0,0 +1,30 @@
1
+ export interface NativeHistoryMessage {
2
+ id: string;
3
+ role: 'user' | 'assistant' | 'system';
4
+ content: string;
5
+ receivedAt: number;
6
+ kind?: string;
7
+ }
8
+ export interface NativeHistorySession {
9
+ messages: NativeHistoryMessage[];
10
+ providerSessionId: string;
11
+ source: 'provider-native';
12
+ sourcePath: string;
13
+ sourceMtimeMs: number;
14
+ nativeHistoryCoverage: 'full';
15
+ workspace?: string;
16
+ }
17
+ export interface NativeHistorySessionMeta {
18
+ historySessionId: string;
19
+ sessionId: string;
20
+ sourcePath: string;
21
+ sourceMtimeMs: number;
22
+ messageCount: number;
23
+ firstMessageAt: number;
24
+ lastMessageAt: number;
25
+ sessionTitle?: string;
26
+ preview?: string;
27
+ workspace?: string;
28
+ }
29
+ export declare function readSession(sessionPath: string): NativeHistorySession | null;
30
+ export declare function listSessions(_watchPath: string): Promise<NativeHistorySessionMeta[]>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * native-history — Daemon-side built-in adapters for CLI provider native history.
3
+ *
4
+ * Each adapter reads conversation history directly from the CLI tool's on-disk
5
+ * storage without shelling out to a provider JS override script.
6
+ *
7
+ * OSS code (AGPL-3.0). Must not import from packages/ (proprietary).
8
+ */
9
+ export { readSession as readClaudeCliSession, listSessions as listClaudeCliSessions, } from './claude-cli-transcript.js';
10
+ export { readSession as readCodexCliSession, listSessions as listCodexCliSessions, } from './codex-cli-transcript.js';
11
+ export { readSession as readAntigravityCliSession, listSessions as listAntigravityCliSessions, } from './antigravity-cli-transcript.js';
12
+ export { readSession as readHermesCliSession, listSessions as listHermesCliSessions, } from './hermes-cli-transcript.js';
13
+ export { createNativeHistoryDispatcher, type ReaderId } from './dispatcher.js';
@@ -58,7 +58,9 @@ export declare class ProviderLoader {
58
58
  /** Inject VersionArchive so resolve() can auto-detect installed versions */
59
59
  setVersionArchive(archive: VersionArchive): void;
60
60
  private static readonly GITHUB_TARBALL_URL;
61
+ private static readonly REGISTRY_BASE_URL;
61
62
  private static readonly META_FILE;
63
+ private static readonly REGISTRY_META_FILE;
62
64
  private static readonly REPO_PROVIDER_DIRNAME;
63
65
  private static readonly SIBLING_MARKER_FILE;
64
66
  private static readonly SIBLING_ENV_VAR;
@@ -295,6 +297,22 @@ export declare class ProviderLoader {
295
297
  *
296
298
  * @returns Whether an update occurred
297
299
  */
300
+ /**
301
+ * Sync providers from the ADHDev registry (registry.adhf.dev).
302
+ *
303
+ * Downloads only providers whose server checksum differs from the locally
304
+ * cached checksum. Falls back gracefully to the GitHub tarball path if the
305
+ * registry is unreachable or returns an unexpected response.
306
+ *
307
+ * Returns `{ updated: true }` when at least one provider file changed on disk,
308
+ * `{ updated: false }` when everything is already current, or
309
+ * `{ updated: false, error }` when the registry couldn't be reached and we
310
+ * should proceed to the GitHub tarball fallback.
311
+ */
312
+ fetchFromRegistry(): Promise<{
313
+ updated: boolean;
314
+ error?: string;
315
+ }>;
298
316
  fetchLatest(): Promise<{
299
317
  updated: boolean;
300
318
  error?: string;
@@ -305,7 +323,7 @@ export declare class ProviderLoader {
305
323
  private copyDirRecursive;
306
324
  /** .meta.json save */
307
325
  private writeMeta;
308
- /** Count provider files (provider.js or provider.json) */
326
+ /** Count provider files (provider.v1.json or provider.json — at most one per dir). */
309
327
  private countProviders;
310
328
  /**
311
329
  * Get public settings schema for a provider (for dashboard UI rendering)
@@ -1,2 +1,31 @@
1
1
  import type { ReadChatResult } from './contracts.js';
2
+ import { CHAT_CONTRACT_VERSION_V1, CHAT_CONTRACT_VERSION_V2, type ChatContractVersion, type ReadChatResultV2 } from './transcript-v2.js';
3
+ /**
4
+ * Read the producer-declared contract version from a raw read_chat payload.
5
+ * Returns v1 when absent or unrecognised, so legacy producers keep working
6
+ * through A1. A2 will tighten this to throw when an unsupported version is
7
+ * declared.
8
+ */
9
+ export declare function readPayloadContractVersion(raw: unknown): ChatContractVersion;
10
+ /**
11
+ * Validate a v2 payload. Thin wrapper around assertReadChatResultV2Payload
12
+ * that prefixes the contract violation with the caller's source label.
13
+ */
14
+ export declare function validateReadChatResultV2Payload(raw: unknown, source?: string): ReadChatResultV2;
15
+ /**
16
+ * Versioned entry point. Routes on the producer-declared contractVersion:
17
+ * - v2 → strict v2 validation (transcript-v2.ts invariants)
18
+ * - v1 (or absent) → legacy permissive validation
19
+ *
20
+ * Callers that have not yet been audited to handle v2 outputs should use
21
+ * validateReadChatResultPayload directly; that path stays bound to v1 shape
22
+ * during the A1 transition.
23
+ */
24
+ export declare function validateReadChatResultPayloadVersioned(raw: unknown, source?: string): {
25
+ version: typeof CHAT_CONTRACT_VERSION_V1;
26
+ payload: ReadChatResult & Record<string, unknown>;
27
+ } | {
28
+ version: typeof CHAT_CONTRACT_VERSION_V2;
29
+ payload: ReadChatResultV2;
30
+ };
2
31
  export declare function validateReadChatResultPayload(raw: unknown, source?: string): ReadChatResult & Record<string, unknown>;
@@ -0,0 +1,68 @@
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
+ interface AcpRegexPatternSpec {
19
+ regex: string;
20
+ flags?: string;
21
+ description?: string;
22
+ }
23
+ interface AcpErrorPatternSpec extends AcpRegexPatternSpec {
24
+ verdict: 'idle' | 'generating' | 'waiting_approval';
25
+ }
26
+ export interface AcpSessionSpec {
27
+ $schema?: 'adhdev:acp/session-protocol@1';
28
+ /** Pattern that matches a line emitted when the agent is idle/ready. */
29
+ idlePattern?: AcpRegexPatternSpec;
30
+ /** Pattern that matches a line emitted while the agent is actively working. */
31
+ generatingPattern?: AcpRegexPatternSpec;
32
+ /**
33
+ * Error/edge-case patterns. Checked in order; first match returns the
34
+ * declared verdict. Useful for approval prompts, fatal errors, etc.
35
+ */
36
+ errorPatterns?: AcpErrorPatternSpec[];
37
+ /** Wire format; informational only at the builder level — regex matching
38
+ * is identical regardless of promptStyle. */
39
+ promptStyle?: 'json-rpc' | 'plain-text' | 'mcp';
40
+ /** Message delimiter used to split incoming bytes (default: newline). */
41
+ messageDelimiter?: string;
42
+ }
43
+ export interface AcpStatusInput {
44
+ /** The most recently received line from the stdio stream. */
45
+ lastLine: string;
46
+ /**
47
+ * A sliding window of recent output lines (newest last).
48
+ * Builders may check these when a single line is not enough for context.
49
+ */
50
+ recentLines: string[];
51
+ /** Whether the ACP process is currently connected and running. */
52
+ isConnected: boolean;
53
+ }
54
+ export type AcpDetectedStatus = 'idle' | 'generating' | 'waiting_approval' | null;
55
+ interface CompiledAcpSpec {
56
+ idle: RegExp | null;
57
+ generating: RegExp | null;
58
+ errors: Array<{
59
+ re: RegExp;
60
+ verdict: AcpDetectedStatus;
61
+ }>;
62
+ }
63
+ declare function compileSpec(spec: AcpSessionSpec): CompiledAcpSpec;
64
+ export declare function buildDetectStatusFromAcp(spec: AcpSessionSpec): (input: AcpStatusInput) => AcpDetectedStatus;
65
+ export declare const __internal: {
66
+ compileSpec: typeof compileSpec;
67
+ };
68
+ export {};