@adhdev/daemon-core 0.9.82-rc.21 → 0.9.82-rc.211

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 (269) hide show
  1. package/dist/boot/daemon-lifecycle.d.ts +1 -0
  2. package/dist/boot/process-hardening.d.ts +50 -0
  3. package/dist/chat/source-machine.d.ts +166 -0
  4. package/dist/chat/source-resolver.d.ts +104 -0
  5. package/dist/chat/subscription-updates.d.ts +1 -0
  6. package/dist/cli-adapter-types.d.ts +23 -2
  7. package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
  8. package/dist/cli-adapters/cli-state-engine.d.ts +178 -0
  9. package/dist/cli-adapters/provider-cli-adapter.d.ts +106 -63
  10. package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
  11. package/dist/cli-adapters/provider-cli-shared.d.ts +29 -0
  12. package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
  13. package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +3 -3
  14. package/dist/cli-adapters/terminal-backends/types.d.ts +1 -2
  15. package/dist/cli-adapters/terminal-screen.d.ts +2 -11
  16. package/dist/commands/cli-manager.d.ts +2 -1
  17. package/dist/commands/handler.d.ts +110 -0
  18. package/dist/commands/mesh-coordinator.d.ts +85 -1
  19. package/dist/commands/router.d.ts +32 -1
  20. package/dist/config/chat-history.d.ts +9 -0
  21. package/dist/config/config.d.ts +5 -0
  22. package/dist/config/mesh-config.d.ts +72 -1
  23. package/dist/git/git-commands.d.ts +9 -1
  24. package/dist/git/git-diff.d.ts +6 -0
  25. package/dist/git/git-types.d.ts +2 -0
  26. package/dist/index.d.ts +46 -11
  27. package/dist/index.js +35173 -15756
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +34880 -15556
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/installer.d.ts +1 -4
  32. package/dist/ipc/local-ipc-server.d.ts +91 -0
  33. package/dist/launch.d.ts +1 -1
  34. package/dist/logging/async-batch-writer.d.ts +10 -0
  35. package/dist/mesh/contracts.d.ts +164 -0
  36. package/dist/mesh/coordinator-prompt.d.ts +36 -0
  37. package/dist/mesh/coordinator-registry.d.ts +59 -0
  38. package/dist/mesh/mesh-active-work.d.ts +90 -0
  39. package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
  40. package/dist/mesh/mesh-events-coordinator.d.ts +151 -0
  41. package/dist/mesh/mesh-events-pending.d.ts +33 -0
  42. package/dist/mesh/mesh-events-stale.d.ts +40 -0
  43. package/dist/mesh/mesh-events-utils.d.ts +14 -0
  44. package/dist/mesh/mesh-events.d.ts +5 -40
  45. package/dist/mesh/mesh-fast-forward.d.ts +41 -0
  46. package/dist/mesh/mesh-host-ownership.d.ts +9 -0
  47. package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -3
  48. package/dist/mesh/mesh-ledger.d.ts +77 -1
  49. package/dist/mesh/mesh-missions.d.ts +58 -0
  50. package/dist/mesh/mesh-refine-status.d.ts +26 -0
  51. package/dist/mesh/mesh-review-inbox.d.ts +90 -0
  52. package/dist/mesh/mesh-runtime-store.d.ts +324 -0
  53. package/dist/mesh/mesh-task-stats.d.ts +49 -0
  54. package/dist/mesh/mesh-work-queue.d.ts +137 -6
  55. package/dist/mesh/preview-freshness.d.ts +18 -0
  56. package/dist/mesh/refine-config.d.ts +215 -0
  57. package/dist/mesh/worktree-bootstrap-config.d.ts +135 -0
  58. package/dist/providers/acp-provider-instance.d.ts +2 -0
  59. package/dist/providers/approval-utils.d.ts +13 -0
  60. package/dist/providers/cli-provider-instance.d.ts +39 -3
  61. package/dist/providers/contracts.d.ts +130 -6
  62. package/dist/providers/external-sources.d.ts +71 -0
  63. package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
  64. package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
  65. package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
  66. package/dist/providers/native-history/dispatcher.d.ts +27 -0
  67. package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
  68. package/dist/providers/native-history/index.d.ts +13 -0
  69. package/dist/providers/provider-instance-manager.d.ts +12 -0
  70. package/dist/providers/provider-instance.d.ts +13 -1
  71. package/dist/providers/provider-loader.d.ts +26 -4
  72. package/dist/providers/provider-trust.d.ts +31 -0
  73. package/dist/providers/read-chat-contract.d.ts +29 -0
  74. package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
  75. package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +85 -0
  76. package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
  77. package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
  78. package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
  79. package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
  80. package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
  81. package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
  82. package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
  83. package/dist/providers/sdk/v1/index.d.ts +30 -0
  84. package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
  85. package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
  86. package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
  87. package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
  88. package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
  89. package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
  90. package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
  91. package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
  92. package/dist/providers/spec/adapter.d.ts +52 -0
  93. package/dist/providers/spec/cli-adapter.d.ts +101 -0
  94. package/dist/providers/spec/driver.d.ts +225 -0
  95. package/dist/providers/spec/evaluator.d.ts +54 -0
  96. package/dist/providers/spec/loader.d.ts +15 -0
  97. package/dist/providers/spec/native-history-executor.d.ts +41 -0
  98. package/dist/providers/spec/route.d.ts +4 -0
  99. package/dist/providers/spec/schema.gen.d.ts +2025 -0
  100. package/dist/providers/spec/types.d.ts +302 -0
  101. package/dist/providers/transcript-v2.d.ts +176 -0
  102. package/dist/providers/types/interactive-prompt.d.ts +48 -0
  103. package/dist/repo-mesh-types.d.ts +109 -1
  104. package/dist/sessions/registry.d.ts +3 -0
  105. package/dist/shared-types-extra.d.ts +2 -4
  106. package/dist/shared-types.d.ts +42 -1
  107. package/dist/status/normalize.d.ts +1 -1
  108. package/dist/status/normalize.js +1 -0
  109. package/dist/status/normalize.js.map +1 -1
  110. package/dist/status/normalize.mjs +1 -0
  111. package/dist/status/normalize.mjs.map +1 -1
  112. package/dist/status/reporter.d.ts +2 -0
  113. package/dist/status/snapshot.d.ts +1 -0
  114. package/dist/types.d.ts +5 -0
  115. package/package.json +6 -3
  116. package/src/agent-stream/poller.ts +2 -3
  117. package/src/boot/daemon-lifecycle.ts +22 -10
  118. package/src/boot/process-hardening.ts +89 -0
  119. package/src/chat/source-machine.ts +534 -0
  120. package/src/chat/source-resolver.ts +0 -0
  121. package/src/chat/subscription-updates.ts +20 -1
  122. package/src/cli-adapter-types.d.ts +1 -0
  123. package/src/cli-adapter-types.ts +22 -2
  124. package/src/cli-adapters/cli-script-runner.ts +421 -0
  125. package/src/cli-adapters/cli-state-engine.ts +1138 -0
  126. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  127. package/src/cli-adapters/provider-cli-adapter.ts +673 -1139
  128. package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
  129. package/src/cli-adapters/provider-cli-parse.ts +13 -0
  130. package/src/cli-adapters/provider-cli-runtime.ts +3 -1
  131. package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
  132. package/src/cli-adapters/provider-cli-shared.ts +59 -11
  133. package/src/cli-adapters/raw-terminal-io.ts +252 -0
  134. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +35 -29
  135. package/src/cli-adapters/terminal-backends/types.ts +1 -3
  136. package/src/cli-adapters/terminal-screen.ts +11 -81
  137. package/src/commands/chat-commands.ts +1787 -60
  138. package/src/commands/cli-manager.ts +283 -14
  139. package/src/commands/handler.ts +809 -2
  140. package/src/commands/mesh-coordinator.ts +332 -122
  141. package/src/commands/router.ts +4198 -557
  142. package/src/config/chat-history.ts +95 -24
  143. package/src/config/config.ts +12 -0
  144. package/src/config/mesh-config.ts +280 -2
  145. package/src/config/recent-activity.ts +8 -2
  146. package/src/daemon/dev-auto-implement.ts +3 -2
  147. package/src/daemon/dev-cli-debug.ts +10 -1
  148. package/src/detection/ide-detector.ts +26 -16
  149. package/src/git/git-commands.ts +42 -12
  150. package/src/git/git-diff.ts +53 -0
  151. package/src/git/git-status.ts +35 -6
  152. package/src/git/git-types.ts +2 -0
  153. package/src/git/git-worktree.ts +8 -1
  154. package/src/index.ts +126 -10
  155. package/src/installer.d.ts +1 -1
  156. package/src/installer.ts +8 -6
  157. package/src/ipc/local-ipc-server.ts +278 -0
  158. package/src/launch.d.ts +1 -1
  159. package/src/launch.ts +37 -28
  160. package/src/logging/async-batch-writer.ts +55 -0
  161. package/src/logging/logger.ts +2 -1
  162. package/src/mesh/contracts.ts +329 -0
  163. package/src/mesh/coordinator-prompt.ts +218 -31
  164. package/src/mesh/coordinator-registry.ts +121 -0
  165. package/src/mesh/mesh-active-work.ts +437 -0
  166. package/src/mesh/mesh-delivery-policy.ts +315 -0
  167. package/src/mesh/mesh-events-coordinator.ts +1404 -0
  168. package/src/mesh/mesh-events-pending.ts +371 -0
  169. package/src/mesh/mesh-events-stale.ts +283 -0
  170. package/src/mesh/mesh-events-utils.ts +161 -0
  171. package/src/mesh/mesh-events.ts +24 -908
  172. package/src/mesh/mesh-fast-forward.ts +438 -0
  173. package/src/mesh/mesh-host-ownership.ts +73 -0
  174. package/src/mesh/mesh-ledger-reconciliation.ts +12 -5
  175. package/src/mesh/mesh-ledger.ts +587 -102
  176. package/src/mesh/mesh-missions.ts +151 -0
  177. package/src/mesh/mesh-refine-status.ts +144 -0
  178. package/src/mesh/mesh-review-inbox.ts +307 -0
  179. package/src/mesh/mesh-runtime-store.ts +1305 -0
  180. package/src/mesh/mesh-task-stats.ts +154 -0
  181. package/src/mesh/mesh-work-queue.ts +490 -166
  182. package/src/mesh/preview-freshness.ts +118 -0
  183. package/src/mesh/refine-config.ts +403 -0
  184. package/src/mesh/worktree-bootstrap-config.ts +326 -0
  185. package/src/providers/acp-provider-instance.ts +15 -1
  186. package/src/providers/approval-utils.d.ts +4 -0
  187. package/src/providers/approval-utils.ts +47 -5
  188. package/src/providers/chat-message-normalization.ts +4 -11
  189. package/src/providers/cli-provider-instance.ts +833 -64
  190. package/src/providers/contracts.d.ts +55 -0
  191. package/src/providers/contracts.ts +141 -6
  192. package/src/providers/external-sources.ts +218 -0
  193. package/src/providers/ide-provider-instance.ts +19 -5
  194. package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
  195. package/src/providers/native-history/claude-cli-transcript.ts +396 -0
  196. package/src/providers/native-history/codex-cli-transcript.ts +419 -0
  197. package/src/providers/native-history/dispatcher.ts +340 -0
  198. package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
  199. package/src/providers/native-history/index.ts +30 -0
  200. package/src/providers/provider-instance-manager.ts +30 -0
  201. package/src/providers/provider-instance.ts +10 -1
  202. package/src/providers/provider-loader.ts +582 -50
  203. package/src/providers/provider-schema.ts +87 -14
  204. package/src/providers/provider-trust.ts +114 -0
  205. package/src/providers/read-chat-contract.ts +76 -16
  206. package/src/providers/sdk/README.md +49 -0
  207. package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
  208. package/src/providers/sdk/v1/builders/cli/detect-status.ts +262 -0
  209. package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
  210. package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
  211. package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
  212. package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
  213. package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
  214. package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
  215. package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
  216. package/src/providers/sdk/v1/index.ts +152 -0
  217. package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
  218. package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
  219. package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
  220. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +504 -0
  221. package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
  222. package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
  223. package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
  224. package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
  225. package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
  226. package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
  227. package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
  228. package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
  229. package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
  230. package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
  231. package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
  232. package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
  233. package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
  234. package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
  235. package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
  236. package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
  237. package/src/providers/sdk/v1/types/cli/index.ts +365 -0
  238. package/src/providers/sdk/v1/types/common/index.ts +229 -0
  239. package/src/providers/sdk/v1/validators/index.ts +19 -0
  240. package/src/providers/sdk/v1/validators/manifest.ts +110 -0
  241. package/src/providers/sdk/v1/validators/taint.ts +309 -0
  242. package/src/providers/spec/adapter.ts +138 -0
  243. package/src/providers/spec/cli-adapter.ts +626 -0
  244. package/src/providers/spec/driver.ts +922 -0
  245. package/src/providers/spec/evaluator.ts +597 -0
  246. package/src/providers/spec/loader.ts +324 -0
  247. package/src/providers/spec/native-history-executor.ts +939 -0
  248. package/src/providers/spec/route.ts +51 -0
  249. package/src/providers/spec/schema.gen.ts +691 -0
  250. package/src/providers/spec/schema.json +341 -0
  251. package/src/providers/spec/types.ts +356 -0
  252. package/src/providers/transcript-v2.ts +567 -0
  253. package/src/providers/types/interactive-prompt.ts +425 -0
  254. package/src/providers/version-archive.ts +38 -20
  255. package/src/repo-mesh-types.ts +119 -1
  256. package/src/sessions/registry.ts +3 -0
  257. package/src/shared-types-extra.ts +2 -4
  258. package/src/shared-types.ts +45 -1
  259. package/src/status/builders.ts +24 -6
  260. package/src/status/normalize.ts +2 -0
  261. package/src/status/reporter.ts +15 -0
  262. package/src/status/snapshot.ts +84 -25
  263. package/src/system/host-memory.ts +29 -12
  264. package/src/types.ts +5 -0
  265. package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
  266. package/dist/mesh/mesh-sync.d.ts +0 -53
  267. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
  268. package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
  269. package/src/mesh/mesh-sync.ts +0 -111
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Shared types across provider categories.
3
+ *
4
+ * Extracted at build time into the Apache 2.0 npm package
5
+ * `@adhdev/provider-types`. External provider authors import from there;
6
+ * daemon-core imports from this file directly.
7
+ */
8
+ export interface BooleanSettingDef {
9
+ type: 'boolean';
10
+ default: boolean;
11
+ public?: boolean;
12
+ label?: string;
13
+ description?: string;
14
+ }
15
+ export interface NumberSettingDef {
16
+ type: 'number';
17
+ default: number;
18
+ public?: boolean;
19
+ label?: string;
20
+ description?: string;
21
+ min?: number;
22
+ max?: number;
23
+ }
24
+ export interface StringSettingDef {
25
+ type: 'string';
26
+ default: string;
27
+ public?: boolean;
28
+ label?: string;
29
+ description?: string;
30
+ }
31
+ export interface SelectSettingDef {
32
+ type: 'select';
33
+ default: string;
34
+ options: ReadonlyArray<string | {
35
+ value: string;
36
+ label?: string;
37
+ }>;
38
+ public?: boolean;
39
+ label?: string;
40
+ description?: string;
41
+ }
42
+ export type SettingDef = BooleanSettingDef | NumberSettingDef | StringSettingDef | SelectSettingDef;
43
+ export type SettingsDef = Readonly<Record<string, SettingDef>>;
44
+ export interface CapabilityInputDef {
45
+ multipart?: boolean;
46
+ mediaTypes?: ReadonlyArray<'text' | 'image' | 'audio' | string>;
47
+ strategies?: ReadonlyArray<{
48
+ mediaType: string;
49
+ strategies: ReadonlyArray<string>;
50
+ native?: boolean;
51
+ degradation?: ReadonlyArray<string>;
52
+ }>;
53
+ }
54
+ export interface CapabilityOutputDef {
55
+ richContent?: boolean;
56
+ mediaTypes?: ReadonlyArray<string>;
57
+ }
58
+ export interface CapabilityControlsDef {
59
+ typedResults?: boolean;
60
+ }
61
+ export interface CapabilitiesDef {
62
+ input?: CapabilityInputDef;
63
+ output?: CapabilityOutputDef;
64
+ controls?: CapabilityControlsDef;
65
+ }
66
+ export interface EnvVarAuthDef {
67
+ type: 'env_var';
68
+ id: string;
69
+ name: string;
70
+ vars: ReadonlyArray<{
71
+ name: string;
72
+ description?: string;
73
+ }>;
74
+ link?: string;
75
+ }
76
+ export interface CliCommandAuthDef {
77
+ type: 'cli_command';
78
+ id: string;
79
+ name: string;
80
+ command: string;
81
+ link?: string;
82
+ }
83
+ export type AuthDef = EnvVarAuthDef | CliCommandAuthDef;
84
+ export interface SpawnDef {
85
+ command: string;
86
+ args?: ReadonlyArray<string>;
87
+ shell?: boolean;
88
+ env?: Readonly<Record<string, string>>;
89
+ }
90
+ export interface TimeoutsDef {
91
+ /** Gap between writes before considering a chunk settled (ms). */
92
+ ptyFlush?: number;
93
+ /** Delay before sending an approval key (ms). */
94
+ dialogAccept?: number;
95
+ /** Window during which a freshly resolved modal is suppressed (ms). */
96
+ approvalCooldown?: number;
97
+ /** Fallback "still generating" assumption window (ms). */
98
+ generatingIdle?: number;
99
+ /** Grace before declaring generating→idle final (ms). */
100
+ idleFinish?: number;
101
+ /** Second-pass confirmation window (ms). */
102
+ idleFinishConfirm?: number;
103
+ /** PTY-quiet threshold before marking activity ended (ms). */
104
+ statusActivityHold?: number;
105
+ /** Hard upper bound on a single generation (ms). */
106
+ maxResponse?: number;
107
+ /** SIGTERM→SIGKILL window (ms). */
108
+ shutdownGrace?: number;
109
+ /** Post-write debounce (ms). */
110
+ outputSettle?: number;
111
+ }
112
+ export type StopStrategy = 'command' | 'ctrl_c' | 'signal';
113
+ export type SessionIdFormat = 'uuid' | 'free' | 'string';
114
+ export interface ResumeDef {
115
+ supported: boolean;
116
+ stopStrategy?: StopStrategy;
117
+ stopCommand?: string;
118
+ shutdownGraceMs?: number;
119
+ sessionIdFormat?: SessionIdFormat;
120
+ /** Args appended to spawn.args when starting a session under a daemon-issued id. `{{id}}` is replaced at launch. */
121
+ newSessionArgs?: ReadonlyArray<string>;
122
+ /** Args appended when resuming a specific session id. */
123
+ resumeSessionArgs?: ReadonlyArray<string>;
124
+ /** Args appended when "continue most recent" semantics are wanted. */
125
+ resumeArgs?: ReadonlyArray<string>;
126
+ }
127
+ export interface McpConfigDef {
128
+ mode: 'manual' | 'auto_import';
129
+ format?: string;
130
+ path?: string;
131
+ configPathCommand?: string;
132
+ serverName?: string;
133
+ requiresRestart?: boolean;
134
+ instructions?: string;
135
+ /** Template string used by daemon to render the actual config snippet at install time. */
136
+ template?: string;
137
+ }
138
+ export interface MeshCoordinatorDef {
139
+ supported: boolean;
140
+ mcpConfig?: McpConfigDef;
141
+ systemPromptInjection?: MeshCoordinatorSystemPromptInjectionDef;
142
+ delegatedWorkerIsolation?: MeshCoordinatorDelegatedWorkerIsolationDef;
143
+ }
144
+ export type MeshCoordinatorSystemPromptInjectionDef = {
145
+ mode: 'cli_arg';
146
+ flag: string;
147
+ } | {
148
+ mode: 'config_override';
149
+ flag: string;
150
+ template: string;
151
+ } | {
152
+ mode: 'context_file';
153
+ path: string;
154
+ wrapper?: string;
155
+ } | {
156
+ mode: 'env_var';
157
+ name: string;
158
+ };
159
+ export interface MeshCoordinatorDelegatedWorkerIsolationDef {
160
+ env?: {
161
+ unset?: ReadonlyArray<string>;
162
+ };
163
+ args?: ReadonlyArray<MeshCoordinatorDelegatedWorkerArgRuleDef>;
164
+ }
165
+ export type MeshCoordinatorDelegatedWorkerArgRuleDef = {
166
+ mode: 'empty_mcp_config';
167
+ flag: string;
168
+ strictFlag?: string;
169
+ } | {
170
+ mode: 'config_override';
171
+ flag: string;
172
+ key: string;
173
+ value: string;
174
+ dedupeKey?: string;
175
+ };
176
+ export interface CompatibilityEntryDef {
177
+ /** SemVer range against the agent's own version. Optional. */
178
+ ideVersion?: string;
179
+ /** Script subdirectory to load when this entry matches. e.g. "scripts/1.0". */
180
+ scriptDir: string;
181
+ }
182
+ export type ControlType = 'select' | 'action' | 'toggle';
183
+ export interface ControlDef {
184
+ id: string;
185
+ type: ControlType;
186
+ label: string;
187
+ icon?: string;
188
+ placement?: string;
189
+ order?: number;
190
+ dynamic?: boolean;
191
+ hidden?: boolean;
192
+ options?: ReadonlyArray<unknown>;
193
+ listScript?: string;
194
+ setScript?: string;
195
+ invokeScript?: string;
196
+ readFrom?: string;
197
+ resultDisplay?: string;
198
+ defaultValue?: unknown;
199
+ confirmTitle?: string;
200
+ confirmMessage?: string;
201
+ confirmLabel?: string;
202
+ }
203
+ export type ProviderLifecycleStatus = 'Stable' | 'Beta' | 'Experimental' | 'Deprecated';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Validators — public surface.
3
+ */
4
+ export { analyzeOverrideTaint, formatTaintResult, type TaintLevel, type TaintCategory, type TaintFinding, type TaintResult, } from './taint.js';
5
+ export { validateCliProviderManifest, formatManifestValidationIssues, type ManifestValidationIssue, type ManifestValidationResult, } from './manifest.js';
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Manifest validators — runtime JSON Schema check for v1 provider manifests.
3
+ *
4
+ * The schemas live under `schemas/{category}/provider.schema.json` and are
5
+ * the authoritative contract for what a v1 manifest may contain. Daemon
6
+ * code that loads a manifest at install or boot time runs it through
7
+ * `validateCliProviderManifest()` first; failures are reported back to
8
+ * the caller with structured paths so manifest authors can locate the
9
+ * offending field without guessing.
10
+ *
11
+ * Validation lives in the SDK layer (not in provider-loader) so dashboards,
12
+ * registry workers, and the provider publish flow can all reuse the
13
+ * same code path and produce identical error messages.
14
+ */
15
+ export interface ManifestValidationIssue {
16
+ /** JSON Pointer-style path into the manifest. Empty string for the root. */
17
+ path: string;
18
+ /** Schema-keyword that failed. */
19
+ keyword: string;
20
+ /** Human-readable explanation. */
21
+ message: string;
22
+ /** Allowed values when the failure is an `enum` / `const` / `additionalProperties`. */
23
+ allowed?: unknown;
24
+ }
25
+ export interface ManifestValidationResult {
26
+ ok: boolean;
27
+ issues: ManifestValidationIssue[];
28
+ }
29
+ /**
30
+ * Validate a CLI provider.v1.json manifest. Returns `{ ok: true, issues: [] }`
31
+ * on success and `{ ok: false, issues: [...] }` on failure with each issue
32
+ * pointing at the offending field. Never throws — manifest parse errors
33
+ * should be caught by the caller before this is called.
34
+ */
35
+ export declare function validateCliProviderManifest(manifest: unknown): ManifestValidationResult;
36
+ /**
37
+ * Render a list of validation issues as a single multi-line string,
38
+ * suitable for log lines or daemon command error fields.
39
+ */
40
+ export declare function formatManifestValidationIssues(issues: ManifestValidationIssue[]): string;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Static taint analyzer for extended-tier override JS.
3
+ *
4
+ * Goal: classify the override JS shipped with an extended-tier provider into
5
+ * one of three risk tiers, so the dashboard + daemon trust prompt can
6
+ * surface accurate language to the operator instead of a single generic
7
+ * "this provider contains JS" warning.
8
+ *
9
+ * - clean : no flagged APIs at all. The override looks like pure string
10
+ * manipulation. Still extended-tier, but the warning copy is
11
+ * "this provider contains JS; nothing dangerous was detected".
12
+ * - elevated : touches process / dynamic codegen / dynamic require / eval
13
+ * / Function constructor / child_process. The warning copy is
14
+ * explicit ("this provider can run shell commands / dynamically
15
+ * load code").
16
+ * - hostile : combines elevated APIs with network egress, AND uses obvious
17
+ * obfuscation (base64-decoded strings fed into Function / eval).
18
+ * The publish endpoint should reject these.
19
+ *
20
+ * Implementation note: this is a *static* analyzer — string + light AST scan
21
+ * via Node's built-in parser. It is intentionally fail-loud: anything that
22
+ * looks suspicious is flagged. False positives are fine; this exists to gate
23
+ * the trust prompt, not to be a real sandbox. The real sandbox lives in
24
+ * Phase 5 (isolated-vm).
25
+ *
26
+ * Used by:
27
+ * - `adhdev provider validate` (CLI tier classification)
28
+ * - registry publish endpoint static-check
29
+ * - daemon at provider-load time, to size the warning
30
+ */
31
+ export type TaintLevel = 'clean' | 'elevated' | 'hostile';
32
+ export interface TaintFinding {
33
+ /** What was found, e.g. "child_process.exec". */
34
+ api: string;
35
+ /** Coarse category. */
36
+ category: TaintCategory;
37
+ /** File the finding came from. */
38
+ file: string;
39
+ /** Line number (1-indexed) of the first character of the matched token. */
40
+ line: number;
41
+ /** The surrounding source excerpt, trimmed. */
42
+ excerpt: string;
43
+ }
44
+ export type TaintCategory = 'process-control' | 'shell-exec' | 'fs-write' | 'fs-read' | 'network' | 'dynamic-codegen' | 'dynamic-require' | 'obfuscation' | 'global-mutation';
45
+ export interface TaintResult {
46
+ level: TaintLevel;
47
+ findings: TaintFinding[];
48
+ files: string[];
49
+ }
50
+ export declare function analyzeOverrideTaint(manifestPath: string): TaintResult;
51
+ /** Format a result as a single CLI-friendly block. */
52
+ export declare function formatTaintResult(result: TaintResult): string;
@@ -0,0 +1,52 @@
1
+ import type { PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
2
+ export type { PtyTransportFactory };
3
+ export interface TerminalAdapterOpts {
4
+ binary: string;
5
+ args?: string[];
6
+ cwd?: string;
7
+ env?: Record<string, string>;
8
+ cols?: number;
9
+ rows?: number;
10
+ /** Coalesce screen snapshots: emit on_screen_changed at most this often. */
11
+ screenChangeDebounceMs?: number;
12
+ tickIntervalMs?: number;
13
+ transportFactory?: PtyTransportFactory;
14
+ }
15
+ export interface TerminalAdapterHandlers {
16
+ init?(info: {
17
+ pid: number;
18
+ }): void;
19
+ on_pty_data?(chunk: string): void;
20
+ on_screen_changed?(snapshot: string): void;
21
+ on_exit?(info: {
22
+ exitCode: number;
23
+ }): void;
24
+ tick?(): void;
25
+ }
26
+ export declare class TerminalAdapter {
27
+ private readonly opts;
28
+ private readonly handlers;
29
+ private rows;
30
+ private cols;
31
+ private readonly screenDebounceMs;
32
+ private readonly tickIntervalMs;
33
+ private readonly factory;
34
+ private screen;
35
+ private pty;
36
+ private screenTimer;
37
+ private tickTimer;
38
+ private lastScreen;
39
+ constructor(opts: TerminalAdapterOpts, handlers: TerminalAdapterHandlers);
40
+ start(): void;
41
+ resize(cols: number, rows: number): void;
42
+ snapshot(): string;
43
+ getCursorPosition(): {
44
+ row: number;
45
+ col: number;
46
+ };
47
+ send_keys(text: string): void;
48
+ kill(): void;
49
+ private onChunk;
50
+ private computeScreen;
51
+ private stopTimers;
52
+ }
@@ -0,0 +1,101 @@
1
+ import type { CliAdapter, CliAdapterStatus } from '../../cli-adapter-types.js';
2
+ import type { PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
3
+ import { type InteractivePromptResponse } from '../types/interactive-prompt.js';
4
+ export declare class SpecCliAdapter implements CliAdapter {
5
+ readonly cliType: string;
6
+ readonly cliName: string;
7
+ readonly workingDir: string;
8
+ /**
9
+ * Marker the daemon's finalization gate checks: `getStatus()` returns
10
+ * `messages: []` by design here (chat history lives in the daemon's
11
+ * native-history pipeline, not the adapter). Without this flag,
12
+ * cli-provider-instance's `missing_final_assistant` gate would stall
13
+ * every turn until the 30s safety timeout because it expects the
14
+ * adapter to surface the final assistant message.
15
+ */
16
+ readonly chatMessagesOwnedExternally: true;
17
+ private driver;
18
+ private spec;
19
+ private lastEvent;
20
+ private latestState;
21
+ private latestModal;
22
+ private statusCallback;
23
+ private ptyDataCallback;
24
+ private partialResponse;
25
+ private activeInteractivePrompt;
26
+ private interactivePromptTransport;
27
+ private claudeTuiPromptCaptureInFlight;
28
+ private jsonLineTail;
29
+ private exited;
30
+ private spawned;
31
+ private providerSessionId;
32
+ /** Wall clock at the moment spawn() ran. Used as the cutoff for
33
+ * native-history file selection so a prior session's transcript
34
+ * can't leak into this session before the agent has written its
35
+ * own records. */
36
+ private spawnedAtMs;
37
+ /** Env vars the daemon set on the spawned child. Mesh coordinator
38
+ * points hermes at a per-coordinator HERMES_HOME so the dashboard's
39
+ * native-history reader needs that override to find the right
40
+ * state.db; without it the reader sees ~/.hermes/state.db which
41
+ * the coordinator-launched hermes never writes to. The choice to
42
+ * redirect HERMES_HOME is a workaround for an unresolved hermes
43
+ * upstream feature gap (see hermes-agent#23130 — runtime-supplied
44
+ * MCP config), so this routing keeps the dashboard honest until
45
+ * hermes ships a runtime MCP override. */
46
+ private spawnedEnv;
47
+ constructor(specPath: string, workingDir: string, cliArgs: string[], extraEnv: Record<string, string>, transportFactory?: PtyTransportFactory);
48
+ spawn(): Promise<void>;
49
+ sendMessage(text: string): Promise<void>;
50
+ getStatus(): CliAdapterStatus;
51
+ private maybeRefreshNativeHistory;
52
+ getScriptParsedStatus(): unknown;
53
+ getPartialResponse(): string;
54
+ shutdown(): void;
55
+ cancel(): void;
56
+ isProcessing(): boolean;
57
+ isReady(): boolean;
58
+ setOnStatusChange(cb: () => void): void;
59
+ setOnPtyData(cb: (data: string) => void): void;
60
+ writeRaw(data: string): void;
61
+ resize(cols: number, rows: number): void;
62
+ resolveModal(buttonIndex: number): void;
63
+ resolveAction(data: unknown): Promise<void>;
64
+ setInteractivePromptResponse(response: InteractivePromptResponse): Promise<void>;
65
+ isApprovalRecentlyResolved(): boolean;
66
+ clearHistory(): void;
67
+ updateRuntimeSettings(): void;
68
+ setServerConn(): void;
69
+ /**
70
+ * Map an invokeScript(name, args) call onto a control_bar entry.
71
+ *
72
+ * scriptName is matched against control.id. The control's action.type
73
+ * drives the dispatch:
74
+ *
75
+ * send_keys → click_control (e.g. stop)
76
+ * open_picker → click_control then resolve when extract_choices
77
+ * surface; choice index comes from args.choiceIndex
78
+ * or args.choice (string label match), defaulting to 0
79
+ * attach_image → attach_image dispatch; expects args.blob (data url
80
+ * or base64) and args.mime
81
+ *
82
+ * Callers that pass an unknown control id get a { not_found } response.
83
+ * No control matched, no driver call — keeps the surface honest.
84
+ */
85
+ invokeScript(scriptName: string, args?: Record<string, unknown>): Promise<unknown>;
86
+ getDebugSnapshot(): unknown;
87
+ getRuntimeMetadata(): unknown;
88
+ updateRuntimeMeta(meta?: Record<string, unknown>): void;
89
+ refreshProviderDefinition(): void;
90
+ private handleEvent;
91
+ private detectInteractivePromptFromPtyChunk;
92
+ private readCurrentScreenSections;
93
+ private extractProviderSessionIdFromScreen;
94
+ private readClaudeScreenAssistantMessages;
95
+ private maybeCaptureClaudeTuiPrompt;
96
+ private readClaudeTuiHeaders;
97
+ private captureClaudeTuiPrompt;
98
+ getDebugState(): Record<string, any>;
99
+ getTraceState(limit?: number): Record<string, any>;
100
+ getProviderResolutionMeta(): Record<string, any>;
101
+ }
@@ -0,0 +1,225 @@
1
+ import type { PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
2
+ import { type SpecEvaluation, type TraceEntry } from './evaluator.js';
3
+ import type { CliSpec } from './types.js';
4
+ export type DashboardEvent = {
5
+ kind: 'pty_data';
6
+ chunk: string;
7
+ } | {
8
+ kind: 'state_changed';
9
+ state: {
10
+ id: string;
11
+ label: string;
12
+ title: string | null;
13
+ };
14
+ modal: {
15
+ title: string | null;
16
+ buttons: {
17
+ index: number;
18
+ label: string;
19
+ }[];
20
+ } | null;
21
+ controls: {
22
+ id: string;
23
+ label: string;
24
+ action_type: string;
25
+ }[];
26
+ } | {
27
+ kind: 'notification';
28
+ id: string;
29
+ title: string;
30
+ body: string;
31
+ } | {
32
+ kind: 'delegate';
33
+ id: string;
34
+ task: string;
35
+ } | {
36
+ kind: 'spec_trace';
37
+ entries: TraceEntry[];
38
+ } | {
39
+ kind: 'exit';
40
+ exit_code: number;
41
+ } | {
42
+ kind: 'spec_error';
43
+ errors: string[];
44
+ };
45
+ export type DashboardCommand = {
46
+ kind: 'send_message';
47
+ text: string;
48
+ } | {
49
+ kind: 'pty_write';
50
+ data: string;
51
+ } | {
52
+ kind: 'click_control';
53
+ control_id: string;
54
+ payload?: unknown;
55
+ } | {
56
+ kind: 'click_modal_button';
57
+ index: number;
58
+ } | {
59
+ kind: 'attach_image';
60
+ blob: string;
61
+ mime: string;
62
+ } | {
63
+ kind: 'resize';
64
+ cols: number;
65
+ rows: number;
66
+ } | {
67
+ kind: 'cancel';
68
+ } | {
69
+ kind: 'shutdown';
70
+ };
71
+ export interface SpecDriverOpts {
72
+ specPath: string;
73
+ workingDir: string;
74
+ extraEnv?: Record<string, string>;
75
+ cols?: number;
76
+ rows?: number;
77
+ /** Set false to skip the spec.json fs.watch. */
78
+ hotReload?: boolean;
79
+ /** Set true to forward trace entries on every state_changed. */
80
+ emitTrace?: boolean;
81
+ /** Inject the daemon's PTY transport (typically SessionHostPtyTransportFactory). */
82
+ transportFactory?: PtyTransportFactory;
83
+ /**
84
+ * Extra CLI args appended to spec.spawn_args. Used by the daemon to
85
+ * pass per-launch arguments like `--session-id <uuid>` so the agent
86
+ * uses the daemon's providerSessionId instead of generating its own.
87
+ */
88
+ extraCliArgs?: string[];
89
+ }
90
+ /**
91
+ * Pick the effective delay (ms) to wait between writing the prompt body and
92
+ * writing the submit_key. Exported for tests; production callers go through
93
+ * actuallySendMessage. Floors to SUBMIT_DELAY_FLOOR_MS so specs that omit
94
+ * delay_ms_before_submit (e.g. claude, antigravity) still get baseline
95
+ * protection against the paste→submit race. Adds line-count bonus so
96
+ * multi-line prompts get more settling time on TUIs that re-render per
97
+ * embedded `\n`.
98
+ */
99
+ export declare function resolveSubmitDelayMs(specBeforeSubmit: number | undefined, text: string): number;
100
+ export declare function matchesCompletionIdleRule(spec: CliSpec, ev: SpecEvaluation, screen: string): string | null;
101
+ export declare function matchesCompletionIdleTargetState(spec: CliSpec, ev: SpecEvaluation, screen: string, cursor?: {
102
+ row: number;
103
+ col: number;
104
+ }): boolean;
105
+ export declare class SpecDriver {
106
+ private readonly opts;
107
+ private spec;
108
+ private adapter;
109
+ private listeners;
110
+ private currentStateId;
111
+ /** Have we ever seen the spec's idle state *after* the startup grace
112
+ * window? Until we do, the agent's startup banner may still be
113
+ * painting and any send_message we forward to the PTY will be wiped
114
+ * when the banner clears the screen. Queue + drain on first valid
115
+ * idle. */
116
+ private idleSeenOnce;
117
+ private startedAtMs;
118
+ private pendingSends;
119
+ private currentEval;
120
+ private pickerInProgress;
121
+ private delegateTimers;
122
+ /** Timestamp of the last time the evaluator returned busy. Used to debounce
123
+ * the busy → idle transition (see reevaluate). */
124
+ private lastBusyAt;
125
+ /** The exact busy state object we last saw — held alongside lastBusyAt so
126
+ * the hold can re-emit the same { id: 'busy', label, title } payload the
127
+ * dashboard already learned about. currentEval can't fill this role
128
+ * because the evaluator already moved past busy by the time the hold
129
+ * kicks in. */
130
+ private lastBusyState;
131
+ /** Timestamp of the last time we entered a modal state (approval/picker or
132
+ * any non-busy non-idle state). Used to suppress brief busy blips that
133
+ * appear while the modal is still on screen — Claude Code streams body
134
+ * text that transiently shows a spinner even while an approval modal is
135
+ * visible, causing rapid approval→busy→approval flicker on the dashboard. */
136
+ private lastModalAt;
137
+ /** The modal state snapshot held across busy blips. */
138
+ private lastModalState;
139
+ /** Timestamp of when we last *exited* a modal state (approval/picker → idle
140
+ * or directly via completion_idle_after). Used to suppress completion_idle_after
141
+ * firings that were queued before the modal appeared and expire immediately
142
+ * after the modal is dismissed — without this the agent appears idle even
143
+ * though it is still generating. */
144
+ private lastModalExitAt;
145
+ private completionIdleFirstSeenAt;
146
+ private completionIdleKey;
147
+ /** Previous screen lines — passed to evaluate() for `changed` condition detection. */
148
+ private prevScreenLines;
149
+ /** Timer that re-runs evaluate() once the hold window expires. Needed
150
+ * because the PTY stops emitting once the agent finishes; without an
151
+ * explicit wake-up there's nothing to trigger the busy → idle
152
+ * downshift. */
153
+ private busyExpiryTimer;
154
+ /** Set true while reevaluate() is invoked from busyExpiryTimer callback. */
155
+ private busyExpiryFired;
156
+ /** Pending idle-commit timer. Armed when the evaluator first returns idle;
157
+ * fires after idle_hold_ms if no non-idle reading has cancelled it. */
158
+ private idleHoldTimer;
159
+ /** State snapshot captured when the idle hold was armed — emitted on commit. */
160
+ private pendingIdleState;
161
+ private specWatcher;
162
+ /** Ring buffer of committed state transitions (max 50). */
163
+ private stateHistory;
164
+ private prevStateAt;
165
+ constructor(opts: SpecDriverOpts);
166
+ /** Subscribe to outbound events. Returns an unsubscribe fn. */
167
+ subscribe(listener: (ev: DashboardEvent) => void): () => void;
168
+ start(): void;
169
+ dispatch(cmd: DashboardCommand): void;
170
+ snapshot(): string;
171
+ getCursorPosition(): {
172
+ row: number;
173
+ col: number;
174
+ };
175
+ shutdown(): void;
176
+ private cancelIdleHold;
177
+ private pushHistory;
178
+ getStateHistory(): ReadonlyArray<{
179
+ stateId: string;
180
+ label: string;
181
+ at: number;
182
+ durationMs: number;
183
+ reason: string;
184
+ matchedStateId?: string;
185
+ matchedRules?: string[];
186
+ debounceKind?: string;
187
+ idleHoldMs?: number;
188
+ busyHoldMs?: number;
189
+ }>;
190
+ getLastBusyAt(): number;
191
+ hasIdleHoldPending(): boolean;
192
+ getSpecPath(): string;
193
+ getCompletionIdleDebounceState(): {
194
+ active: boolean;
195
+ ageMs: number;
196
+ holdMs: number;
197
+ forceAfterMs: number;
198
+ } | null;
199
+ getScreen(): string;
200
+ getSections(): Array<{
201
+ id: string;
202
+ text: string;
203
+ }> | null;
204
+ private loadSpecOrThrow;
205
+ private buildAdapterOpts;
206
+ private armSpecWatcher;
207
+ private emitInitialState;
208
+ /** Re-arm the timer that wakes the driver up after BUSY_HOLD_MS so it
209
+ * can decide whether to downshift to idle. Always uses the most recent
210
+ * hold value so a spec hot-reload that shortens the hold takes effect
211
+ * on the next busy entry. Safe to call repeatedly; only the last call
212
+ * fires. */
213
+ private scheduleBusyExpiry;
214
+ private reevaluate;
215
+ private armOrCancelDelegateTimers;
216
+ private fireDelegate;
217
+ private handleSendMessage;
218
+ private actuallySendMessage;
219
+ private handleClickControl;
220
+ private handleClickModalButton;
221
+ private handleAttachImage;
222
+ private tryAdvancePicker;
223
+ private handleExit;
224
+ private emit;
225
+ }