@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
@@ -0,0 +1,169 @@
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
+ }
142
+ export interface CompatibilityEntryDef {
143
+ /** SemVer range against the agent's own version. Optional. */
144
+ ideVersion?: string;
145
+ /** Script subdirectory to load when this entry matches. e.g. "scripts/1.0". */
146
+ scriptDir: string;
147
+ }
148
+ export type ControlType = 'select' | 'action' | 'toggle';
149
+ export interface ControlDef {
150
+ id: string;
151
+ type: ControlType;
152
+ label: string;
153
+ icon?: string;
154
+ placement?: string;
155
+ order?: number;
156
+ dynamic?: boolean;
157
+ hidden?: boolean;
158
+ options?: ReadonlyArray<unknown>;
159
+ listScript?: string;
160
+ setScript?: string;
161
+ invokeScript?: string;
162
+ readFrom?: string;
163
+ resultDisplay?: string;
164
+ defaultValue?: unknown;
165
+ confirmTitle?: string;
166
+ confirmMessage?: string;
167
+ confirmLabel?: string;
168
+ }
169
+ 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 marketplace 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 marketplace + 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,56 @@
1
+ import { type PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
2
+ export interface TerminalAdapterOpts {
3
+ binary: string;
4
+ args?: string[];
5
+ cwd: string;
6
+ env?: Record<string, string>;
7
+ cols?: number;
8
+ rows?: number;
9
+ /** Coalesce screen snapshots: emit on_screen_changed at most this often. */
10
+ screenChangeDebounceMs?: number;
11
+ /** tick() period. 0 disables ticks. */
12
+ tickIntervalMs?: number;
13
+ /**
14
+ * Optional PTY transport factory. When the daemon supplies a
15
+ * SessionHostPtyTransportFactory (standalone runs the PTY inside the
16
+ * session-host so the runtime/<sid>/snapshot endpoint can serve it),
17
+ * forward it here. Without it the PTY spawns locally inside the
18
+ * daemon process and the dashboard's terminal pane reports
19
+ * "Runtime terminal unavailable: Unknown session".
20
+ */
21
+ transportFactory?: PtyTransportFactory;
22
+ }
23
+ export interface TerminalAdapterHandlers {
24
+ init?(info: {
25
+ pid: number;
26
+ }): void;
27
+ on_pty_data?(chunk: string): void;
28
+ on_screen_changed?(snapshot: string): void;
29
+ tick?(): void;
30
+ on_exit?(info: {
31
+ exitCode: number;
32
+ }): void;
33
+ }
34
+ export declare class TerminalAdapter {
35
+ private readonly opts;
36
+ private readonly handlers;
37
+ private term;
38
+ private pty;
39
+ private factory;
40
+ private cols;
41
+ private rows;
42
+ private screenDebounceMs;
43
+ private tickIntervalMs;
44
+ private screenTimer;
45
+ private tickTimer;
46
+ private lastScreen;
47
+ constructor(opts: TerminalAdapterOpts, handlers: TerminalAdapterHandlers);
48
+ start(): void;
49
+ send_keys(s: string): void;
50
+ resize(cols: number, rows: number): void;
51
+ snapshot(): string;
52
+ kill(): void;
53
+ private onChunk;
54
+ private computeScreen;
55
+ private stopTimers;
56
+ }
@@ -0,0 +1,76 @@
1
+ import type { CliAdapter, CliAdapterStatus } from '../../cli-adapter-types.js';
2
+ import type { PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
3
+ export declare class SpecCliAdapter implements CliAdapter {
4
+ readonly cliType: string;
5
+ readonly cliName: string;
6
+ readonly workingDir: string;
7
+ private driver;
8
+ private spec;
9
+ private lastEvent;
10
+ private latestState;
11
+ private latestModal;
12
+ private statusCallback;
13
+ private ptyDataCallback;
14
+ private partialResponse;
15
+ private exited;
16
+ private spawned;
17
+ private providerSessionId;
18
+ /** Wall clock at the moment spawn() ran. Used as the cutoff for
19
+ * native-history file selection so a prior session's transcript
20
+ * can't leak into this session before the agent has written its
21
+ * own records. */
22
+ private spawnedAtMs;
23
+ /** Env vars the daemon set on the spawned child. Mesh coordinator
24
+ * points hermes at a per-coordinator HERMES_HOME so the dashboard's
25
+ * native-history reader needs that override to find the right
26
+ * state.db; without it the reader sees ~/.hermes/state.db which
27
+ * the coordinator-launched hermes never writes to. The choice to
28
+ * redirect HERMES_HOME is a workaround for an unresolved hermes
29
+ * upstream feature gap (see hermes-agent#23130 — runtime-supplied
30
+ * MCP config), so this routing keeps the dashboard honest until
31
+ * hermes ships a runtime MCP override. */
32
+ private spawnedEnv;
33
+ constructor(specPath: string, workingDir: string, cliArgs: string[], extraEnv: Record<string, string>, transportFactory?: PtyTransportFactory);
34
+ spawn(): Promise<void>;
35
+ sendMessage(text: string): Promise<void>;
36
+ getStatus(): CliAdapterStatus;
37
+ private maybeRefreshNativeHistory;
38
+ getScriptParsedStatus(): unknown;
39
+ getPartialResponse(): string;
40
+ shutdown(): void;
41
+ cancel(): void;
42
+ isProcessing(): boolean;
43
+ isReady(): boolean;
44
+ setOnStatusChange(cb: () => void): void;
45
+ setOnPtyData(cb: (data: string) => void): void;
46
+ writeRaw(data: string): void;
47
+ resize(cols: number, rows: number): void;
48
+ resolveModal(buttonIndex: number): void;
49
+ resolveAction(data: unknown): Promise<void>;
50
+ isApprovalRecentlyResolved(): boolean;
51
+ clearHistory(): void;
52
+ updateRuntimeSettings(): void;
53
+ setServerConn(): void;
54
+ /**
55
+ * Map an invokeScript(name, args) call onto a control_bar entry.
56
+ *
57
+ * scriptName is matched against control.id. The control's action.type
58
+ * drives the dispatch:
59
+ *
60
+ * send_keys → click_control (e.g. stop)
61
+ * open_picker → click_control then resolve when extract_choices
62
+ * surface; choice index comes from args.choiceIndex
63
+ * or args.choice (string label match), defaulting to 0
64
+ * attach_image → attach_image dispatch; expects args.blob (data url
65
+ * or base64) and args.mime
66
+ *
67
+ * Callers that pass an unknown control id get a { not_found } response.
68
+ * No control matched, no driver call — keeps the surface honest.
69
+ */
70
+ invokeScript(scriptName: string, args?: Record<string, unknown>): Promise<unknown>;
71
+ getDebugSnapshot(): unknown;
72
+ getRuntimeMetadata(): unknown;
73
+ updateRuntimeMeta(meta?: Record<string, unknown>): void;
74
+ refreshProviderDefinition(): void;
75
+ private handleEvent;
76
+ }
@@ -0,0 +1,148 @@
1
+ import type { PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
2
+ import { type TraceEntry } from './evaluator.js';
3
+ export type DashboardEvent = {
4
+ kind: 'pty_data';
5
+ chunk: string;
6
+ } | {
7
+ kind: 'state_changed';
8
+ state: {
9
+ id: string;
10
+ label: string;
11
+ title: string | null;
12
+ };
13
+ modal: {
14
+ title: string | null;
15
+ buttons: {
16
+ index: number;
17
+ label: string;
18
+ }[];
19
+ } | null;
20
+ controls: {
21
+ id: string;
22
+ label: string;
23
+ action_type: string;
24
+ }[];
25
+ } | {
26
+ kind: 'notification';
27
+ id: string;
28
+ title: string;
29
+ body: string;
30
+ } | {
31
+ kind: 'delegate';
32
+ id: string;
33
+ task: string;
34
+ } | {
35
+ kind: 'spec_trace';
36
+ entries: TraceEntry[];
37
+ } | {
38
+ kind: 'exit';
39
+ exit_code: number;
40
+ } | {
41
+ kind: 'spec_error';
42
+ errors: string[];
43
+ };
44
+ export type DashboardCommand = {
45
+ kind: 'send_message';
46
+ text: string;
47
+ } | {
48
+ kind: 'pty_write';
49
+ data: string;
50
+ } | {
51
+ kind: 'click_control';
52
+ control_id: string;
53
+ payload?: unknown;
54
+ } | {
55
+ kind: 'click_modal_button';
56
+ index: number;
57
+ } | {
58
+ kind: 'attach_image';
59
+ blob: string;
60
+ mime: string;
61
+ } | {
62
+ kind: 'resize';
63
+ cols: number;
64
+ rows: number;
65
+ } | {
66
+ kind: 'cancel';
67
+ } | {
68
+ kind: 'shutdown';
69
+ };
70
+ export interface SpecDriverOpts {
71
+ specPath: string;
72
+ workingDir: string;
73
+ extraEnv?: Record<string, string>;
74
+ cols?: number;
75
+ rows?: number;
76
+ /** Set false to skip the spec.json fs.watch. */
77
+ hotReload?: boolean;
78
+ /** Set true to forward trace entries on every state_changed. */
79
+ emitTrace?: boolean;
80
+ /** Inject the daemon's PTY transport (typically SessionHostPtyTransportFactory). */
81
+ transportFactory?: PtyTransportFactory;
82
+ /**
83
+ * Extra CLI args appended to spec.spawn_args. Used by the daemon to
84
+ * pass per-launch arguments like `--session-id <uuid>` so the agent
85
+ * uses the daemon's providerSessionId instead of generating its own.
86
+ */
87
+ extraCliArgs?: string[];
88
+ }
89
+ export declare class SpecDriver {
90
+ private readonly opts;
91
+ private spec;
92
+ private adapter;
93
+ private listeners;
94
+ private currentStateId;
95
+ /** Have we ever seen the spec's idle state *after* the startup grace
96
+ * window? Until we do, the agent's startup banner may still be
97
+ * painting and any send_message we forward to the PTY will be wiped
98
+ * when the banner clears the screen. Queue + drain on first valid
99
+ * idle. */
100
+ private idleSeenOnce;
101
+ private startedAtMs;
102
+ private pendingSends;
103
+ private currentEval;
104
+ private pickerInProgress;
105
+ private delegateTimers;
106
+ /** Timestamp of the last time the evaluator returned busy. Used to debounce
107
+ * the busy → idle transition (see reevaluate). */
108
+ private lastBusyAt;
109
+ /** The exact busy state object we last saw — held alongside lastBusyAt so
110
+ * the hold can re-emit the same { id: 'busy', label, title } payload the
111
+ * dashboard already learned about. currentEval can't fill this role
112
+ * because the evaluator already moved past busy by the time the hold
113
+ * kicks in. */
114
+ private lastBusyState;
115
+ /** Timer that re-runs evaluate() once the hold window expires. Needed
116
+ * because the PTY stops emitting once the agent finishes; without an
117
+ * explicit wake-up there's nothing to trigger the busy → idle
118
+ * downshift. */
119
+ private busyExpiryTimer;
120
+ private specWatcher;
121
+ constructor(opts: SpecDriverOpts);
122
+ /** Subscribe to outbound events. Returns an unsubscribe fn. */
123
+ subscribe(listener: (ev: DashboardEvent) => void): () => void;
124
+ start(): void;
125
+ dispatch(cmd: DashboardCommand): void;
126
+ shutdown(): void;
127
+ private loadSpecOrThrow;
128
+ private buildAdapterOpts;
129
+ private armSpecWatcher;
130
+ private emitInitialState;
131
+ /** Re-arm the timer that wakes the driver up after BUSY_HOLD_MS so it
132
+ * can decide whether to downshift to idle. Always uses the most recent
133
+ * hold value so a spec hot-reload that shortens the hold takes effect
134
+ * on the next busy entry. Safe to call repeatedly; only the last call
135
+ * fires. */
136
+ private scheduleBusyExpiry;
137
+ private reevaluate;
138
+ private armOrCancelDelegateTimers;
139
+ private fireDelegate;
140
+ private handleSendMessage;
141
+ private actuallySendMessage;
142
+ private handleClickControl;
143
+ private handleClickModalButton;
144
+ private handleAttachImage;
145
+ private tryAdvancePicker;
146
+ private handleExit;
147
+ private emit;
148
+ }
@@ -0,0 +1,47 @@
1
+ import type { CliSpec } from './types.js';
2
+ export interface ResolvedSection {
3
+ id: string;
4
+ fromLine: number;
5
+ toLine: number;
6
+ text: string;
7
+ }
8
+ export interface ModalSnapshot {
9
+ title: string | null;
10
+ buttons: {
11
+ index: number;
12
+ label: string;
13
+ key: string;
14
+ }[];
15
+ }
16
+ export interface VisibleControl {
17
+ id: string;
18
+ label: string;
19
+ actionType: 'send_keys' | 'open_picker' | 'attach_image';
20
+ }
21
+ export interface FiredNotification {
22
+ id: string;
23
+ title: string;
24
+ body: string;
25
+ }
26
+ export interface FiredDelegate {
27
+ id: string;
28
+ task: string;
29
+ }
30
+ export interface TraceEntry {
31
+ kind: 'section' | 'state_match' | 'state_skip' | 'modal' | 'control' | 'notification' | 'delegate';
32
+ text: string;
33
+ }
34
+ export interface SpecEvaluation {
35
+ state: {
36
+ id: string;
37
+ label: string;
38
+ title: string | null;
39
+ };
40
+ modal: ModalSnapshot | null;
41
+ controls: VisibleControl[];
42
+ notifications: FiredNotification[];
43
+ delegates: FiredDelegate[];
44
+ sections: ResolvedSection[];
45
+ trace: TraceEntry[];
46
+ }
47
+ export declare function evaluate(spec: CliSpec, screenText: string): SpecEvaluation;
@@ -0,0 +1,14 @@
1
+ import type { CliSpec } from './types.js';
2
+ export interface SpecLoadResult {
3
+ ok: true;
4
+ spec: CliSpec;
5
+ sourcePath: string;
6
+ }
7
+ export interface SpecLoadError {
8
+ ok: false;
9
+ errors: string[];
10
+ sourcePath: string;
11
+ }
12
+ export declare function loadSpec(sourcePath: string): SpecLoadResult | SpecLoadError;
13
+ /** Convenience: look up a provider's spec.json next to its provider dir. */
14
+ export declare function resolveSpecPath(providerDir: string): string;
@@ -0,0 +1,39 @@
1
+ import type { NativeHistoryConfig } from './types.js';
2
+ export interface NativeHistoryInput {
3
+ agentType?: string;
4
+ sessionId?: string;
5
+ providerSessionId?: string;
6
+ historySessionId?: string;
7
+ workspace?: string;
8
+ /** Daemon-side wall clock at the moment the session was registered.
9
+ * Native-history file lookups use this as the lower bound: any file
10
+ * whose mtime is before the current session started can't be from
11
+ * this session, so it's excluded from newest-recent matching. The
12
+ * caller (chat-history pipeline) populates this from the session
13
+ * registry; specs/executor never need to know how it's sourced. */
14
+ sessionStartedAtMs?: number;
15
+ /** Env overrides the daemon set on the spawned CLI. The mesh
16
+ * coordinator points hermes at a per-coordinator HERMES_HOME so
17
+ * the hermes process writes its state.db into a tmp directory
18
+ * instead of ~/.hermes. expandPath consults this map before
19
+ * process.env so the native-history reader follows the spawned
20
+ * child's view of HERMES_HOME / similar overrides; without it
21
+ * the reader would always look at ~/.hermes and miss every
22
+ * coordinator-session transcript. */
23
+ envOverrides?: Record<string, string>;
24
+ args?: Record<string, unknown>;
25
+ }
26
+ export interface NativeHistoryMessage {
27
+ role: 'user' | 'assistant' | 'system';
28
+ content: string;
29
+ receivedAt: number;
30
+ kind?: string;
31
+ }
32
+ export interface NativeHistoryResult {
33
+ messages: NativeHistoryMessage[];
34
+ providerSessionId?: string;
35
+ sourcePath: string;
36
+ sourceMtimeMs: number;
37
+ nativeHistoryCoverage?: 'full' | 'partial' | 'best-effort';
38
+ }
39
+ export declare function executeNativeHistory(cfg: NativeHistoryConfig, input: NativeHistoryInput): NativeHistoryResult | null;
@@ -0,0 +1,4 @@
1
+ import type { CliProviderModule } from '../../cli-adapters/provider-cli-adapter.js';
2
+ import type { PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
3
+ import type { CliAdapter } from '../../cli-adapter-types.js';
4
+ export declare function createCliAdapter(provider: CliProviderModule, workingDir: string, cliArgs: string[], extraEnv: Record<string, string>, transportFactory?: PtyTransportFactory): CliAdapter;