uxnan-bridge 0.0.1-alpha.20260621

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 (255) hide show
  1. package/README.md +150 -0
  2. package/dist/src/account-status.d.ts +13 -0
  3. package/dist/src/account-status.js +78 -0
  4. package/dist/src/account-status.js.map +1 -0
  5. package/dist/src/adapters/base-adapter.d.ts +18 -0
  6. package/dist/src/adapters/base-adapter.js +15 -0
  7. package/dist/src/adapters/base-adapter.js.map +1 -0
  8. package/dist/src/adapters/claude-adapter.d.ts +102 -0
  9. package/dist/src/adapters/claude-adapter.js +486 -0
  10. package/dist/src/adapters/claude-adapter.js.map +1 -0
  11. package/dist/src/adapters/claude-tools.d.ts +25 -0
  12. package/dist/src/adapters/claude-tools.js +146 -0
  13. package/dist/src/adapters/claude-tools.js.map +1 -0
  14. package/dist/src/adapters/codex-adapter.d.ts +116 -0
  15. package/dist/src/adapters/codex-adapter.js +912 -0
  16. package/dist/src/adapters/codex-adapter.js.map +1 -0
  17. package/dist/src/adapters/codex-app-server.d.ts +74 -0
  18. package/dist/src/adapters/codex-app-server.js +225 -0
  19. package/dist/src/adapters/codex-app-server.js.map +1 -0
  20. package/dist/src/adapters/codex-approval.d.ts +88 -0
  21. package/dist/src/adapters/codex-approval.js +160 -0
  22. package/dist/src/adapters/codex-approval.js.map +1 -0
  23. package/dist/src/adapters/codex-tools.d.ts +18 -0
  24. package/dist/src/adapters/codex-tools.js +106 -0
  25. package/dist/src/adapters/codex-tools.js.map +1 -0
  26. package/dist/src/adapters/content-blocks.d.ts +68 -0
  27. package/dist/src/adapters/content-blocks.js +205 -0
  28. package/dist/src/adapters/content-blocks.js.map +1 -0
  29. package/dist/src/adapters/echo-agent-adapter.d.ts +23 -0
  30. package/dist/src/adapters/echo-agent-adapter.js +72 -0
  31. package/dist/src/adapters/echo-agent-adapter.js.map +1 -0
  32. package/dist/src/adapters/gemini-adapter.d.ts +87 -0
  33. package/dist/src/adapters/gemini-adapter.js +594 -0
  34. package/dist/src/adapters/gemini-adapter.js.map +1 -0
  35. package/dist/src/adapters/gemini-tools.d.ts +4 -0
  36. package/dist/src/adapters/gemini-tools.js +48 -0
  37. package/dist/src/adapters/gemini-tools.js.map +1 -0
  38. package/dist/src/adapters/opencode-adapter.d.ts +74 -0
  39. package/dist/src/adapters/opencode-adapter.js +418 -0
  40. package/dist/src/adapters/opencode-adapter.js.map +1 -0
  41. package/dist/src/adapters/opencode-tools.d.ts +2 -0
  42. package/dist/src/adapters/opencode-tools.js +41 -0
  43. package/dist/src/adapters/opencode-tools.js.map +1 -0
  44. package/dist/src/adapters/pi-adapter.d.ts +92 -0
  45. package/dist/src/adapters/pi-adapter.js +467 -0
  46. package/dist/src/adapters/pi-adapter.js.map +1 -0
  47. package/dist/src/adapters/pi-tools.d.ts +10 -0
  48. package/dist/src/adapters/pi-tools.js +72 -0
  49. package/dist/src/adapters/pi-tools.js.map +1 -0
  50. package/dist/src/adapters/process-agent-adapter.d.ts +24 -0
  51. package/dist/src/adapters/process-agent-adapter.js +111 -0
  52. package/dist/src/adapters/process-agent-adapter.js.map +1 -0
  53. package/dist/src/adapters/resolve-claude.d.ts +13 -0
  54. package/dist/src/adapters/resolve-claude.js +57 -0
  55. package/dist/src/adapters/resolve-claude.js.map +1 -0
  56. package/dist/src/adapters/resolve-codex.d.ts +13 -0
  57. package/dist/src/adapters/resolve-codex.js +48 -0
  58. package/dist/src/adapters/resolve-codex.js.map +1 -0
  59. package/dist/src/adapters/resolve-gemini.d.ts +13 -0
  60. package/dist/src/adapters/resolve-gemini.js +47 -0
  61. package/dist/src/adapters/resolve-gemini.js.map +1 -0
  62. package/dist/src/adapters/resolve-opencode.d.ts +11 -0
  63. package/dist/src/adapters/resolve-opencode.js +49 -0
  64. package/dist/src/adapters/resolve-opencode.js.map +1 -0
  65. package/dist/src/adapters/resolve-pi.d.ts +13 -0
  66. package/dist/src/adapters/resolve-pi.js +46 -0
  67. package/dist/src/adapters/resolve-pi.js.map +1 -0
  68. package/dist/src/adapters/run-options.d.ts +22 -0
  69. package/dist/src/adapters/run-options.js +48 -0
  70. package/dist/src/adapters/run-options.js.map +1 -0
  71. package/dist/src/adapters/spawn.d.ts +20 -0
  72. package/dist/src/adapters/spawn.js +16 -0
  73. package/dist/src/adapters/spawn.js.map +1 -0
  74. package/dist/src/agents/agent-manager.d.ts +98 -0
  75. package/dist/src/agents/agent-manager.js +433 -0
  76. package/dist/src/agents/agent-manager.js.map +1 -0
  77. package/dist/src/agents/attachments.d.ts +28 -0
  78. package/dist/src/agents/attachments.js +121 -0
  79. package/dist/src/agents/attachments.js.map +1 -0
  80. package/dist/src/bridge-context.d.ts +45 -0
  81. package/dist/src/bridge-context.js +2 -0
  82. package/dist/src/bridge-context.js.map +1 -0
  83. package/dist/src/bridge-status.d.ts +12 -0
  84. package/dist/src/bridge-status.js +17 -0
  85. package/dist/src/bridge-status.js.map +1 -0
  86. package/dist/src/bridge.d.ts +37 -0
  87. package/dist/src/bridge.js +446 -0
  88. package/dist/src/bridge.js.map +1 -0
  89. package/dist/src/cli.d.ts +2 -0
  90. package/dist/src/cli.js +194 -0
  91. package/dist/src/cli.js.map +1 -0
  92. package/dist/src/conversation/session-history.d.ts +27 -0
  93. package/dist/src/conversation/session-history.js +1082 -0
  94. package/dist/src/conversation/session-history.js.map +1 -0
  95. package/dist/src/conversation/thread-store.d.ts +74 -0
  96. package/dist/src/conversation/thread-store.js +366 -0
  97. package/dist/src/conversation/thread-store.js.map +1 -0
  98. package/dist/src/daemon-config.d.ts +123 -0
  99. package/dist/src/daemon-config.js +64 -0
  100. package/dist/src/daemon-config.js.map +1 -0
  101. package/dist/src/daemon-state.d.ts +27 -0
  102. package/dist/src/daemon-state.js +76 -0
  103. package/dist/src/daemon-state.js.map +1 -0
  104. package/dist/src/git/git-runner.d.ts +24 -0
  105. package/dist/src/git/git-runner.js +63 -0
  106. package/dist/src/git/git-runner.js.map +1 -0
  107. package/dist/src/git/git-service.d.ts +76 -0
  108. package/dist/src/git/git-service.js +435 -0
  109. package/dist/src/git/git-service.js.map +1 -0
  110. package/dist/src/handler-router.d.ts +34 -0
  111. package/dist/src/handler-router.js +67 -0
  112. package/dist/src/handler-router.js.map +1 -0
  113. package/dist/src/handlers/account-handler.d.ts +4 -0
  114. package/dist/src/handlers/account-handler.js +27 -0
  115. package/dist/src/handlers/account-handler.js.map +1 -0
  116. package/dist/src/handlers/agent-handler.d.ts +2 -0
  117. package/dist/src/handlers/agent-handler.js +8 -0
  118. package/dist/src/handlers/agent-handler.js.map +1 -0
  119. package/dist/src/handlers/bridge-control-handler.d.ts +2 -0
  120. package/dist/src/handlers/bridge-control-handler.js +64 -0
  121. package/dist/src/handlers/bridge-control-handler.js.map +1 -0
  122. package/dist/src/handlers/desktop-handler.d.ts +12 -0
  123. package/dist/src/handlers/desktop-handler.js +5 -0
  124. package/dist/src/handlers/desktop-handler.js.map +1 -0
  125. package/dist/src/handlers/git-handler.d.ts +2 -0
  126. package/dist/src/handlers/git-handler.js +82 -0
  127. package/dist/src/handlers/git-handler.js.map +1 -0
  128. package/dist/src/handlers/index.d.ts +8 -0
  129. package/dist/src/handlers/index.js +22 -0
  130. package/dist/src/handlers/index.js.map +1 -0
  131. package/dist/src/handlers/not-implemented.d.ts +10 -0
  132. package/dist/src/handlers/not-implemented.js +21 -0
  133. package/dist/src/handlers/not-implemented.js.map +1 -0
  134. package/dist/src/handlers/notifications-handler.d.ts +2 -0
  135. package/dist/src/handlers/notifications-handler.js +62 -0
  136. package/dist/src/handlers/notifications-handler.js.map +1 -0
  137. package/dist/src/handlers/params.d.ts +11 -0
  138. package/dist/src/handlers/params.js +72 -0
  139. package/dist/src/handlers/params.js.map +1 -0
  140. package/dist/src/handlers/project-handler.d.ts +2 -0
  141. package/dist/src/handlers/project-handler.js +6 -0
  142. package/dist/src/handlers/project-handler.js.map +1 -0
  143. package/dist/src/handlers/thread-context-handler.d.ts +2 -0
  144. package/dist/src/handlers/thread-context-handler.js +211 -0
  145. package/dist/src/handlers/thread-context-handler.js.map +1 -0
  146. package/dist/src/handlers/workspace-handler.d.ts +2 -0
  147. package/dist/src/handlers/workspace-handler.js +101 -0
  148. package/dist/src/handlers/workspace-handler.js.map +1 -0
  149. package/dist/src/hooks/claude-approval-hook.d.ts +7 -0
  150. package/dist/src/hooks/claude-approval-hook.js +95 -0
  151. package/dist/src/hooks/claude-approval-hook.js.map +1 -0
  152. package/dist/src/hooks/gemini-approval-hook.d.ts +7 -0
  153. package/dist/src/hooks/gemini-approval-hook.js +113 -0
  154. package/dist/src/hooks/gemini-approval-hook.js.map +1 -0
  155. package/dist/src/index.d.ts +62 -0
  156. package/dist/src/index.js +65 -0
  157. package/dist/src/index.js.map +1 -0
  158. package/dist/src/keyring-secret-store.d.ts +36 -0
  159. package/dist/src/keyring-secret-store.js +70 -0
  160. package/dist/src/keyring-secret-store.js.map +1 -0
  161. package/dist/src/lock-file.d.ts +18 -0
  162. package/dist/src/lock-file.js +60 -0
  163. package/dist/src/lock-file.js.map +1 -0
  164. package/dist/src/logger.d.ts +28 -0
  165. package/dist/src/logger.js +99 -0
  166. package/dist/src/logger.js.map +1 -0
  167. package/dist/src/pairing/pairing-code-service.d.ts +45 -0
  168. package/dist/src/pairing/pairing-code-service.js +183 -0
  169. package/dist/src/pairing/pairing-code-service.js.map +1 -0
  170. package/dist/src/projects/project-registry.d.ts +14 -0
  171. package/dist/src/projects/project-registry.js +60 -0
  172. package/dist/src/projects/project-registry.js.map +1 -0
  173. package/dist/src/push/push-sender.d.ts +21 -0
  174. package/dist/src/push/push-sender.js +96 -0
  175. package/dist/src/push/push-sender.js.map +1 -0
  176. package/dist/src/push/push-service.d.ts +122 -0
  177. package/dist/src/push/push-service.js +260 -0
  178. package/dist/src/push/push-service.js.map +1 -0
  179. package/dist/src/qr.d.ts +17 -0
  180. package/dist/src/qr.js +31 -0
  181. package/dist/src/qr.js.map +1 -0
  182. package/dist/src/secret-store.d.ts +23 -0
  183. package/dist/src/secret-store.js +27 -0
  184. package/dist/src/secret-store.js.map +1 -0
  185. package/dist/src/secure-device-state.d.ts +16 -0
  186. package/dist/src/secure-device-state.js +63 -0
  187. package/dist/src/secure-device-state.js.map +1 -0
  188. package/dist/src/service-installer.d.ts +57 -0
  189. package/dist/src/service-installer.js +254 -0
  190. package/dist/src/service-installer.js.map +1 -0
  191. package/dist/src/session-state.d.ts +14 -0
  192. package/dist/src/session-state.js +19 -0
  193. package/dist/src/session-state.js.map +1 -0
  194. package/dist/src/transport/crypto.d.ts +43 -0
  195. package/dist/src/transport/crypto.js +78 -0
  196. package/dist/src/transport/crypto.js.map +1 -0
  197. package/dist/src/transport/lan-server.d.ts +33 -0
  198. package/dist/src/transport/lan-server.js +105 -0
  199. package/dist/src/transport/lan-server.js.map +1 -0
  200. package/dist/src/transport/local-hosts.d.ts +17 -0
  201. package/dist/src/transport/local-hosts.js +30 -0
  202. package/dist/src/transport/local-hosts.js.map +1 -0
  203. package/dist/src/transport/mdns-advertiser.d.ts +83 -0
  204. package/dist/src/transport/mdns-advertiser.js +282 -0
  205. package/dist/src/transport/mdns-advertiser.js.map +1 -0
  206. package/dist/src/transport/message-io.d.ts +33 -0
  207. package/dist/src/transport/message-io.js +87 -0
  208. package/dist/src/transport/message-io.js.map +1 -0
  209. package/dist/src/transport/outbound-log.d.ts +24 -0
  210. package/dist/src/transport/outbound-log.js +78 -0
  211. package/dist/src/transport/outbound-log.js.map +1 -0
  212. package/dist/src/transport/relay-client.d.ts +19 -0
  213. package/dist/src/transport/relay-client.js +27 -0
  214. package/dist/src/transport/relay-client.js.map +1 -0
  215. package/dist/src/transport/secure-channel.d.ts +33 -0
  216. package/dist/src/transport/secure-channel.js +81 -0
  217. package/dist/src/transport/secure-channel.js.map +1 -0
  218. package/dist/src/transport/server-handshake.d.ts +49 -0
  219. package/dist/src/transport/server-handshake.js +137 -0
  220. package/dist/src/transport/server-handshake.js.map +1 -0
  221. package/dist/src/transport/session-handler.d.ts +19 -0
  222. package/dist/src/transport/session-handler.js +134 -0
  223. package/dist/src/transport/session-handler.js.map +1 -0
  224. package/dist/src/transport/session-registry.d.ts +58 -0
  225. package/dist/src/transport/session-registry.js +91 -0
  226. package/dist/src/transport/session-registry.js.map +1 -0
  227. package/dist/src/transport/trust-store.d.ts +23 -0
  228. package/dist/src/transport/trust-store.js +33 -0
  229. package/dist/src/transport/trust-store.js.map +1 -0
  230. package/dist/src/transport/ws-adapter.d.ts +7 -0
  231. package/dist/src/transport/ws-adapter.js +16 -0
  232. package/dist/src/transport/ws-adapter.js.map +1 -0
  233. package/dist/src/version.d.ts +1 -0
  234. package/dist/src/version.js +13 -0
  235. package/dist/src/version.js.map +1 -0
  236. package/dist/src/workspace/browse-service.d.ts +10 -0
  237. package/dist/src/workspace/browse-service.js +97 -0
  238. package/dist/src/workspace/browse-service.js.map +1 -0
  239. package/dist/src/workspace/checkpoint-service.d.ts +21 -0
  240. package/dist/src/workspace/checkpoint-service.js +219 -0
  241. package/dist/src/workspace/checkpoint-service.js.map +1 -0
  242. package/dist/src/workspace/path-guard.d.ts +7 -0
  243. package/dist/src/workspace/path-guard.js +51 -0
  244. package/dist/src/workspace/path-guard.js.map +1 -0
  245. package/dist/src/workspace/workspace-service.d.ts +8 -0
  246. package/dist/src/workspace/workspace-service.js +111 -0
  247. package/dist/src/workspace/workspace-service.js.map +1 -0
  248. package/package.json +46 -0
  249. package/scripts/extract-gemini-hook.mjs +16 -0
  250. package/scripts/fake-approval-bridge.mjs +23 -0
  251. package/scripts/install-service-linux.sh +38 -0
  252. package/scripts/install-service-macos.sh +38 -0
  253. package/scripts/install-service-windows.ps1 +26 -0
  254. package/scripts/test-gemini-hook-e2e.mjs +168 -0
  255. package/scripts/write-gemini-settings.mjs +31 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi-tools.js","sourceRoot":"","sources":["../../../src/adapters/pi-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,YAAY,EACZ,aAAa,EAC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AAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAC1F,CAAC;QACJ,CAAC;QACD,KAAK,OAAO,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC1D,iEAAiE;QACjE,wEAAwE;QACxE,iEAAiE;QACjE,KAAK,MAAM,CAAC;QACZ,KAAK,WAAW,CAAC;QACjB,KAAK,aAAa,CAAC;QACnB,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3C,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrB,OAAO,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACtF,CAAC;YACD,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACpE,CAAC;QACD;YACE,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;AACH,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { AgentCapabilities, AgentConfig, AgentId, AgentStreamEvent, SendTurnOptions } from '@uxnan/shared';
2
+ import { BaseAgentAdapter } from './base-adapter.js';
3
+ export interface ProcessAdapterOptions {
4
+ agentId: AgentId;
5
+ capabilities: AgentCapabilities;
6
+ /** Executable to spawn (resolved from PATH unless absolute). */
7
+ binaryPath: string;
8
+ /** Static args passed before any per-turn input. */
9
+ args?: string[];
10
+ }
11
+ export declare class ProcessAgentAdapter extends BaseAgentAdapter {
12
+ #private;
13
+ readonly agentId: AgentId;
14
+ readonly capabilities: AgentCapabilities;
15
+ constructor(options: ProcessAdapterOptions);
16
+ start(config: AgentConfig): Promise<void>;
17
+ stop(): Promise<void>;
18
+ sendTurn(options: SendTurnOptions): Promise<void>;
19
+ cancelTurn(threadId: string, turnId: string): Promise<void>;
20
+ /** Format the stdin payload for a turn. Override for real CLIs. */
21
+ protected formatTurn(options: SendTurnOptions): string;
22
+ /** Parse one stdout line into an event, or null to ignore. Override for real CLIs. */
23
+ protected parseLine(line: string): AgentStreamEvent | null;
24
+ }
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Generic agent adapter that drives an external CLI over stdio, exchanging
3
+ * newline-delimited JSON ("the bridge agent IPC").
4
+ *
5
+ * bridge → agent (stdin): {"type":"turn","threadId","turnId","text"}
6
+ * {"type":"cancel","threadId","turnId"}
7
+ * agent → bridge (stdout): {"type":"started"|"delta"|"completed"|"error",
8
+ * "threadId","turnId","text"?}
9
+ *
10
+ * Real CLIs (Codex, OpenCode, …) do NOT speak this protocol natively — a
11
+ * concrete subclass overrides {@link formatTurn}/{@link parseLine} to translate
12
+ * the real CLI's flags and stream format. See codex-adapter.ts / opencode-adapter.ts.
13
+ *
14
+ * Source: architecture/02a-system-architecture.md §5.8.2.
15
+ */
16
+ import { spawn } from 'node:child_process';
17
+ import { createInterface } from 'node:readline';
18
+ import { BaseAgentAdapter } from './base-adapter.js';
19
+ export class ProcessAgentAdapter extends BaseAgentAdapter {
20
+ agentId;
21
+ capabilities;
22
+ #binaryPath;
23
+ #args;
24
+ #child;
25
+ #reader;
26
+ constructor(options) {
27
+ super();
28
+ this.agentId = options.agentId;
29
+ this.capabilities = options.capabilities;
30
+ this.#binaryPath = options.binaryPath;
31
+ this.#args = options.args ?? [];
32
+ }
33
+ start(config) {
34
+ if (this.#child)
35
+ return Promise.resolve();
36
+ const child = spawn(this.#binaryPath, this.#args, {
37
+ cwd: config.cwd ?? process.cwd(),
38
+ stdio: ['pipe', 'pipe', 'pipe'],
39
+ windowsHide: true,
40
+ });
41
+ this.#child = child;
42
+ this.#reader = createInterface({ input: child.stdout });
43
+ this.#reader.on('line', (line) => {
44
+ const event = this.parseLine(line);
45
+ if (event)
46
+ this.emit(event);
47
+ });
48
+ return Promise.resolve();
49
+ }
50
+ stop() {
51
+ this.#reader?.close();
52
+ this.#reader = undefined;
53
+ if (this.#child) {
54
+ this.#child.kill();
55
+ this.#child = undefined;
56
+ }
57
+ return Promise.resolve();
58
+ }
59
+ sendTurn(options) {
60
+ this.#write(this.formatTurn(options));
61
+ return Promise.resolve();
62
+ }
63
+ cancelTurn(threadId, turnId) {
64
+ this.#write(JSON.stringify({ type: 'cancel', threadId, turnId }));
65
+ return Promise.resolve();
66
+ }
67
+ /** Format the stdin payload for a turn. Override for real CLIs. */
68
+ formatTurn(options) {
69
+ return JSON.stringify({
70
+ type: 'turn',
71
+ threadId: options.threadId,
72
+ turnId: options.turnId,
73
+ text: options.text,
74
+ });
75
+ }
76
+ /** Parse one stdout line into an event, or null to ignore. Override for real CLIs. */
77
+ parseLine(line) {
78
+ const trimmed = line.trim();
79
+ if (!trimmed)
80
+ return null;
81
+ let parsed;
82
+ try {
83
+ parsed = JSON.parse(trimmed);
84
+ }
85
+ catch {
86
+ return null;
87
+ }
88
+ const threadId = String(parsed['threadId'] ?? '');
89
+ const turnId = String(parsed['turnId'] ?? '');
90
+ const text = typeof parsed['text'] === 'string' ? parsed['text'] : undefined;
91
+ switch (parsed['type']) {
92
+ case 'started':
93
+ return { type: 'turn_started', threadId, turnId };
94
+ case 'delta':
95
+ return { type: 'delta', threadId, turnId, data: { text: text ?? '' } };
96
+ case 'completed':
97
+ return { type: 'turn_completed', threadId, turnId, data: { text: text ?? '' } };
98
+ case 'error':
99
+ return { type: 'turn_error', threadId, turnId, data: { text: text ?? 'agent error' } };
100
+ default:
101
+ return null;
102
+ }
103
+ }
104
+ #write(payload) {
105
+ if (!this.#child) {
106
+ throw new Error(`agent '${this.agentId}' is not started`);
107
+ }
108
+ this.#child.stdin.write(`${payload}\n`);
109
+ }
110
+ }
111
+ //# sourceMappingURL=process-agent-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-agent-adapter.js","sourceRoot":"","sources":["../../../src/adapters/process-agent-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,KAAK,EAAuC,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAkB,MAAM,eAAe,CAAC;AAQhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAWrD,MAAM,OAAO,mBAAoB,SAAQ,gBAAgB;IAC9C,OAAO,CAAU;IACjB,YAAY,CAAoB;IAChC,WAAW,CAAS;IACpB,KAAK,CAAW;IACzB,MAAM,CAA6C;IACnD,OAAO,CAAwB;IAE/B,YAAY,OAA8B;QACxC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;QACzC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;QACtC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,MAAmB;QACvB,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,EAAE;YAChD,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE;YAChC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;YAC/B,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;QACH,IAAI,CAAC,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,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,IAAI,aAAa,EAAE,EAAE,CAAC;YACzF;gBACE,OAAO,IAAI,CAAC;QAChB,CAAC;IACH,CAAC;IAED,MAAM,CAAC,OAAe;QACpB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,CAAC,OAAO,kBAAkB,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ export interface ResolvedClaude {
2
+ /** Executable to spawn (`shell:false`). For the npm `cli.js` case this is `process.execPath` (node). */
3
+ binaryPath: string;
4
+ /** Args prepended before the adapter's own args (e.g. `[cli.js]` when running via node). */
5
+ prependArgs: string[];
6
+ /** Whether the resolved target is known to exist on disk. */
7
+ available: boolean;
8
+ }
9
+ /**
10
+ * Resolve the Claude Code binary. An explicit `configured` path always wins; we
11
+ * only report availability for it. Otherwise we auto-detect a runnable target.
12
+ */
13
+ export declare function resolveClaudeBinary(configured?: string): ResolvedClaude;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Resolves the Claude Code executable to something `child_process.spawn` can run
3
+ * directly with `shell:false` (so the user prompt is never interpolated into a
4
+ * shell — no command injection).
5
+ *
6
+ * Claude Code ships two ways:
7
+ * - the native installer drops a real binary at `~/.local/bin/claude[.exe]`,
8
+ * which spawns directly; and
9
+ * - the npm package `@anthropic-ai/claude-code` exposes a `cli.js` behind a
10
+ * `.cmd`/shell shim that cannot be spawned with `shell:false`. For that case we
11
+ * spawn `node <cli.js>` instead, so the launch stays shell-free.
12
+ */
13
+ import { existsSync } from 'node:fs';
14
+ import { homedir } from 'node:os';
15
+ import { join } from 'node:path';
16
+ /** Native-installer binary location, identical layout on Windows and POSIX. */
17
+ function nativeBinaryPath() {
18
+ return join(homedir(), '.local', 'bin', process.platform === 'win32' ? 'claude.exe' : 'claude');
19
+ }
20
+ /** Candidate npm-global `cli.js` locations for `@anthropic-ai/claude-code`. */
21
+ function npmCliCandidates() {
22
+ const candidates = [];
23
+ const rel = join('@anthropic-ai', 'claude-code', 'cli.js');
24
+ if (process.platform === 'win32') {
25
+ const appData = process.env['APPDATA'];
26
+ if (appData)
27
+ candidates.push(join(appData, 'npm', 'node_modules', rel));
28
+ }
29
+ else {
30
+ candidates.push(join('/usr', 'local', 'lib', 'node_modules', rel));
31
+ candidates.push(join(homedir(), '.npm-global', 'lib', 'node_modules', rel));
32
+ }
33
+ return candidates;
34
+ }
35
+ /**
36
+ * Resolve the Claude Code binary. An explicit `configured` path always wins; we
37
+ * only report availability for it. Otherwise we auto-detect a runnable target.
38
+ */
39
+ export function resolveClaudeBinary(configured) {
40
+ if (configured && configured.length > 0) {
41
+ return { binaryPath: configured, prependArgs: [], available: existsSync(configured) };
42
+ }
43
+ const native = nativeBinaryPath();
44
+ if (existsSync(native)) {
45
+ return { binaryPath: native, prependArgs: [], available: true };
46
+ }
47
+ for (const cli of npmCliCandidates()) {
48
+ if (existsSync(cli)) {
49
+ return { binaryPath: process.execPath, prependArgs: [cli], available: true };
50
+ }
51
+ }
52
+ // Fall back to the launcher name; availability unknown (PATH lookup at spawn).
53
+ // On POSIX the `claude` launcher on PATH spawns directly; on Windows the shim
54
+ // would need a shell, so we report it as not available until configured.
55
+ return { binaryPath: 'claude', prependArgs: [], available: process.platform !== 'win32' };
56
+ }
57
+ //# sourceMappingURL=resolve-claude.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-claude.js","sourceRoot":"","sources":["../../../src/adapters/resolve-claude.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAA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AU,CAAC,MAAM,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAClE,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,gBAAgB,EAAE,EAAE,CAAC;QACrC,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACpB,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC/E,CAAC;IACH,CAAC;IACD,+EAA+E;IAC/E,8EAA8E;IAC9E,yEAAyE;IACzE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;AAC5F,CAAC"}
@@ -0,0 +1,13 @@
1
+ export interface ResolvedCodex {
2
+ /** Executable to spawn (`shell:false`). For the npm entry this is `process.execPath` (node). */
3
+ binaryPath: string;
4
+ /** Args prepended before the adapter args (e.g. `[codex.js]` when running via node). */
5
+ prependArgs: string[];
6
+ /** Whether the resolved target is known to exist on disk. */
7
+ available: boolean;
8
+ }
9
+ /**
10
+ * Resolve the Codex binary. An explicit `configured` path always wins; we only
11
+ * report availability for it. Otherwise we auto-detect a runnable target.
12
+ */
13
+ export declare function resolveCodexBinary(configured?: string): ResolvedCodex;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Resolves the Codex CLI to something `child_process.spawn` can run directly with
3
+ * `shell:false` (so the user prompt is never interpolated into a shell — no
4
+ * command injection).
5
+ *
6
+ * The npm package `@openai/codex` exposes a `bin/codex.js` Node entry behind a
7
+ * `.cmd`/`.ps1` shim that cannot be spawned with `shell:false`. The entry locates
8
+ * the right native binary for the platform itself, so we spawn `node <codex.js>`
9
+ * — robust across platforms without hard-coding the deep, arch-specific vendor
10
+ * path (`@openai/codex-win32-x64/.../bin/codex.exe`, etc.).
11
+ */
12
+ import { existsSync } from 'node:fs';
13
+ import { homedir } from 'node:os';
14
+ import { join } from 'node:path';
15
+ /** Candidate npm-global `bin/codex.js` locations for `@openai/codex`. */
16
+ function npmEntryCandidates() {
17
+ const candidates = [];
18
+ const rel = join('@openai', 'codex', 'bin', 'codex.js');
19
+ if (process.platform === 'win32') {
20
+ const appData = process.env['APPDATA'];
21
+ if (appData)
22
+ candidates.push(join(appData, 'npm', 'node_modules', rel));
23
+ }
24
+ else {
25
+ candidates.push(join('/usr', 'local', 'lib', 'node_modules', rel));
26
+ candidates.push(join(homedir(), '.npm-global', 'lib', 'node_modules', rel));
27
+ }
28
+ return candidates;
29
+ }
30
+ /**
31
+ * Resolve the Codex binary. An explicit `configured` path always wins; we only
32
+ * report availability for it. Otherwise we auto-detect a runnable target.
33
+ */
34
+ export function resolveCodexBinary(configured) {
35
+ if (configured && configured.length > 0) {
36
+ return { binaryPath: configured, prependArgs: [], available: existsSync(configured) };
37
+ }
38
+ for (const entry of npmEntryCandidates()) {
39
+ if (existsSync(entry)) {
40
+ return { binaryPath: process.execPath, prependArgs: [entry], available: true };
41
+ }
42
+ }
43
+ // Fall back to the launcher name; availability unknown (PATH lookup at spawn).
44
+ // On POSIX the `codex` npm bin spawns directly (node shebang); on Windows the
45
+ // shim would need a shell, so we report it as not available until configured.
46
+ return { binaryPath: 'codex', prependArgs: [], available: process.platform !== 'win32' };
47
+ }
48
+ //# sourceMappingURL=resolve-codex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-codex.js","sourceRoot":"","sources":["../../../src/adapters/resolve-codex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAWjC,yEAAyE;AACzE,SAAS,kB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AAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;AAC3F,CAAC"}
@@ -0,0 +1,13 @@
1
+ export interface ResolvedGemini {
2
+ /** Executable to spawn (`shell:false`). For the npm entry this is `process.execPath` (node). */
3
+ binaryPath: string;
4
+ /** Args prepended before the adapter args (e.g. `[gemini.js]` when running via node). */
5
+ prependArgs: string[];
6
+ /** Whether the resolved target is known to exist on disk. */
7
+ available: boolean;
8
+ }
9
+ /**
10
+ * Resolve the Gemini binary. An explicit `configured` path always wins; we only
11
+ * report availability for it. Otherwise we auto-detect a runnable target.
12
+ */
13
+ export declare function resolveGeminiBinary(configured?: string): ResolvedGemini;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Resolves the Gemini CLI (`@google/gemini-cli`) to something
3
+ * `child_process.spawn` can run directly with `shell:false` (so the user prompt
4
+ * is never interpolated into a shell — no command injection).
5
+ *
6
+ * The npm package ships a bundled Node entry at `bundle/gemini.js` behind a
7
+ * `.cmd`/`.ps1` shim that cannot be spawned with `shell:false`, so we spawn
8
+ * `node <bundle/gemini.js>` — robust across platforms (same approach as the Codex
9
+ * and pi adapters).
10
+ */
11
+ import { existsSync } from 'node:fs';
12
+ import { homedir } from 'node:os';
13
+ import { join } from 'node:path';
14
+ /** Candidate npm-global `bundle/gemini.js` locations for `@google/gemini-cli`. */
15
+ function npmEntryCandidates() {
16
+ const candidates = [];
17
+ const rel = join('@google', 'gemini-cli', 'bundle', 'gemini.js');
18
+ if (process.platform === 'win32') {
19
+ const appData = process.env['APPDATA'];
20
+ if (appData)
21
+ candidates.push(join(appData, 'npm', 'node_modules', rel));
22
+ }
23
+ else {
24
+ candidates.push(join('/usr', 'local', 'lib', 'node_modules', rel));
25
+ candidates.push(join(homedir(), '.npm-global', 'lib', 'node_modules', rel));
26
+ }
27
+ return candidates;
28
+ }
29
+ /**
30
+ * Resolve the Gemini binary. An explicit `configured` path always wins; we only
31
+ * report availability for it. Otherwise we auto-detect a runnable target.
32
+ */
33
+ export function resolveGeminiBinary(configured) {
34
+ if (configured && configured.length > 0) {
35
+ return { binaryPath: configured, prependArgs: [], available: existsSync(configured) };
36
+ }
37
+ for (const entry of npmEntryCandidates()) {
38
+ if (existsSync(entry)) {
39
+ return { binaryPath: process.execPath, prependArgs: [entry], available: true };
40
+ }
41
+ }
42
+ // Fall back to the launcher name; availability unknown (PATH lookup at spawn).
43
+ // On POSIX the `gemini` npm bin spawns directly (node shebang); on Windows the
44
+ // shim would need a shell, so we report it not available until configured.
45
+ return { binaryPath: 'gemini', prependArgs: [], available: process.platform !== 'win32' };
46
+ }
47
+ //# sourceMappingURL=resolve-gemini.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-gemini.js","sourceRoot":"","sources":["../../../src/adapters/resolve-gemini.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAWjC,kFAAkF;AAClF,SAAS,kBAAkB;IACzB,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IACjE,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvC,IAAI,OAAO;YAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC;IAC1E,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC;QACnE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAAmB;IACrD,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;IACxF,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,kBAAkB,EAAE,EAAE,CAAC;QACzC,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QACjF,CAAC;IACH,CAAC;IACD,+EAA+E;IAC/E,+EAA+E;IAC/E,2EAA2E;IAC3E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;AAC5F,CAAC"}
@@ -0,0 +1,11 @@
1
+ export interface ResolvedOpenCode {
2
+ /** Executable path to spawn (shell:false). */
3
+ binaryPath: string;
4
+ /** Whether the resolved path is known to exist on disk. */
5
+ available: boolean;
6
+ }
7
+ /**
8
+ * Resolve the OpenCode binary. An explicit `configured` path always wins; we only
9
+ * report availability for it. Otherwise we auto-detect a runnable executable.
10
+ */
11
+ export declare function resolveOpenCodeBinary(configured?: string): ResolvedOpenCode;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Resolves the OpenCode executable to a path that `child_process.spawn` can run
3
+ * directly with `shell:false` (so the user prompt is never interpolated into a
4
+ * shell — no command injection).
5
+ *
6
+ * On Windows the npm `opencode` shim is a `.cmd`/`.ps1` that cannot be spawned
7
+ * without a shell; it forwards to a native `opencode.exe` under
8
+ * `node_modules/opencode-ai/bin/`. We locate that `.exe` so we can spawn it
9
+ * directly. On macOS/Linux the `opencode` launcher on PATH spawns fine as-is.
10
+ */
11
+ import { existsSync } from 'node:fs';
12
+ import { join } from 'node:path';
13
+ /** Candidate `.exe` locations for the npm-global OpenCode on Windows. */
14
+ function windowsCandidates() {
15
+ const candidates = [];
16
+ const appData = process.env['APPDATA'];
17
+ if (appData) {
18
+ candidates.push(join(appData, 'npm', 'node_modules', 'opencode-ai', 'bin', 'opencode.exe'));
19
+ }
20
+ const programFiles = process.env['ProgramFiles'];
21
+ if (programFiles) {
22
+ candidates.push(join(programFiles, 'opencode', 'opencode.exe'));
23
+ }
24
+ const localAppData = process.env['LOCALAPPDATA'];
25
+ if (localAppData) {
26
+ candidates.push(join(localAppData, 'opencode', 'opencode.exe'));
27
+ }
28
+ return candidates;
29
+ }
30
+ /**
31
+ * Resolve the OpenCode binary. An explicit `configured` path always wins; we only
32
+ * report availability for it. Otherwise we auto-detect a runnable executable.
33
+ */
34
+ export function resolveOpenCodeBinary(configured) {
35
+ if (configured && configured.length > 0) {
36
+ return { binaryPath: configured, available: existsSync(configured) };
37
+ }
38
+ if (process.platform === 'win32') {
39
+ for (const candidate of windowsCandidates()) {
40
+ if (existsSync(candidate))
41
+ return { binaryPath: candidate, available: true };
42
+ }
43
+ // Fall back to the shim name; availability unknown (PATH lookup at spawn).
44
+ return { binaryPath: 'opencode', available: false };
45
+ }
46
+ // POSIX: the launcher on PATH spawns directly.
47
+ return { binaryPath: 'opencode', available: true };
48
+ }
49
+ //# sourceMappingURL=resolve-opencode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-opencode.js","sourceRoot":"","sources":["../../../src/adapters/resolve-opencode.ts"],"names":[],"mappings":"AAAA;;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,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC/E,CAAC;QACD,2EAA2E;QAC3E,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACtD,CAAC;IACD,+CAA+C;IAC/C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACrD,CAAC"}
@@ -0,0 +1,13 @@
1
+ export interface ResolvedPi {
2
+ /** Executable to spawn (`shell:false`). For the npm entry this is `process.execPath` (node). */
3
+ binaryPath: string;
4
+ /** Args prepended before the adapter args (e.g. `[cli.js]` when running via node). */
5
+ prependArgs: string[];
6
+ /** Whether the resolved target is known to exist on disk. */
7
+ available: boolean;
8
+ }
9
+ /**
10
+ * Resolve the pi binary. An explicit `configured` path always wins; we only
11
+ * report availability for it. Otherwise we auto-detect a runnable target.
12
+ */
13
+ export declare function resolvePiBinary(configured?: string): ResolvedPi;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Resolves the pi CLI (`@earendil-works/pi-coding-agent`) to something
3
+ * `child_process.spawn` can run directly with `shell:false` (so the user prompt
4
+ * is never interpolated into a shell — no command injection).
5
+ *
6
+ * The npm package exposes `dist/cli.js` (a Node entry) behind a `.cmd`/`.ps1`
7
+ * shim that cannot be spawned with `shell:false`, so we spawn `node <cli.js>` —
8
+ * robust across platforms (same approach as the Codex adapter).
9
+ */
10
+ import { existsSync } from 'node:fs';
11
+ import { homedir } from 'node:os';
12
+ import { join } from 'node:path';
13
+ /** Candidate npm-global `dist/cli.js` locations for `@earendil-works/pi-coding-agent`. */
14
+ function npmEntryCandidates() {
15
+ const candidates = [];
16
+ const rel = join('@earendil-works', 'pi-coding-agent', 'dist', 'cli.js');
17
+ if (process.platform === 'win32') {
18
+ const appData = process.env['APPDATA'];
19
+ if (appData)
20
+ candidates.push(join(appData, 'npm', 'node_modules', rel));
21
+ }
22
+ else {
23
+ candidates.push(join('/usr', 'local', 'lib', 'node_modules', rel));
24
+ candidates.push(join(homedir(), '.npm-global', 'lib', 'node_modules', rel));
25
+ }
26
+ return candidates;
27
+ }
28
+ /**
29
+ * Resolve the pi binary. An explicit `configured` path always wins; we only
30
+ * report availability for it. Otherwise we auto-detect a runnable target.
31
+ */
32
+ export function resolvePiBinary(configured) {
33
+ if (configured && configured.length > 0) {
34
+ return { binaryPath: configured, prependArgs: [], available: existsSync(configured) };
35
+ }
36
+ for (const entry of npmEntryCandidates()) {
37
+ if (existsSync(entry)) {
38
+ return { binaryPath: process.execPath, prependArgs: [entry], available: true };
39
+ }
40
+ }
41
+ // Fall back to the launcher name; availability unknown (PATH lookup at spawn).
42
+ // On POSIX the `pi` npm bin spawns directly (node shebang); on Windows the
43
+ // shim would need a shell, so we report it as not available until configured.
44
+ return { binaryPath: 'pi', prependArgs: [], available: process.platform !== 'win32' };
45
+ }
46
+ //# sourceMappingURL=resolve-pi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-pi.js","sourceRoot":"","sources":["../../../src/adapters/resolve-pi.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAWjC,0FAA0F;AAC1F,SAAS,kBAAkB;IACzB,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACzE,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvC,IAAI,OAAO;YAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC;IAC1E,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC;QACnE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,UAAmB;IACjD,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;IACxF,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,kBAAkB,EAAE,EAAE,CAAC;QACzC,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QACjF,CAAC;IACH,CAAC;IACD,+EAA+E;IAC/E,2EAA2E;IAC3E,8EAA8E;IAC9E,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;AACxF,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Helpers for per-model run options (the "knobs" advertised by `agent/models`
3
+ * and chosen on `turn/send`). Shared by the CLI adapters so each can translate
4
+ * the generic `reasoning` knob into its own flag.
5
+ */
6
+ import type { AgentModel, AgentModelOption, AgentModelOptionValue, SendTurnOptions } from '@uxnan/shared';
7
+ /** The generic key under which reasoning effort is advertised and sent. */
8
+ export declare const REASONING_KEY = "reasoning";
9
+ /**
10
+ * Resolve the chosen reasoning-effort value for a turn: the generic
11
+ * `options.reasoning` knob first, then the legacy flat `effort` (back-compat).
12
+ * Returns undefined when neither is set.
13
+ */
14
+ export declare function reasoningValue(options: SendTurnOptions): string | undefined;
15
+ /** Build a `reasoning` enum knob from the given selectable values. */
16
+ export declare function reasoningOption(values: AgentModelOptionValue[], defaultValue?: string): AgentModelOption;
17
+ /** Friendly label for a known reasoning-effort level (else Title-cased). */
18
+ export declare function effortLabel(value: string): string;
19
+ /** Build the selectable values for an effort knob from raw level strings. */
20
+ export declare function effortValues(levels: readonly string[]): AgentModelOptionValue[];
21
+ /** Attach `options` to every model (replacing any prior options). */
22
+ export declare function withOptions(models: AgentModel[], options: AgentModelOption[]): AgentModel[];
@@ -0,0 +1,48 @@
1
+ /** The generic key under which reasoning effort is advertised and sent. */
2
+ export const REASONING_KEY = 'reasoning';
3
+ /**
4
+ * Resolve the chosen reasoning-effort value for a turn: the generic
5
+ * `options.reasoning` knob first, then the legacy flat `effort` (back-compat).
6
+ * Returns undefined when neither is set.
7
+ */
8
+ export function reasoningValue(options) {
9
+ const knob = options.options?.[REASONING_KEY];
10
+ if (typeof knob === 'string' && knob.length > 0)
11
+ return knob;
12
+ return options.effort && options.effort.length > 0 ? options.effort : undefined;
13
+ }
14
+ /** Build a `reasoning` enum knob from the given selectable values. */
15
+ export function reasoningOption(values, defaultValue) {
16
+ return {
17
+ key: REASONING_KEY,
18
+ kind: 'enum',
19
+ label: 'Reasoning effort',
20
+ values,
21
+ ...(defaultValue !== undefined ? { default: defaultValue } : {}),
22
+ };
23
+ }
24
+ /** Friendly label for a known reasoning-effort level (else Title-cased). */
25
+ export function effortLabel(value) {
26
+ const known = {
27
+ minimal: 'Minimal',
28
+ low: 'Low',
29
+ medium: 'Medium',
30
+ high: 'High',
31
+ xhigh: 'Extra high',
32
+ max: 'Max',
33
+ };
34
+ if (known[value])
35
+ return known[value];
36
+ return value.length === 0 ? value : value[0].toUpperCase() + value.slice(1);
37
+ }
38
+ /** Build the selectable values for an effort knob from raw level strings. */
39
+ export function effortValues(levels) {
40
+ return levels.map((value) => ({ value, label: effortLabel(value) }));
41
+ }
42
+ /** Attach `options` to every model (replacing any prior options). */
43
+ export function withOptions(models, options) {
44
+ if (options.length === 0)
45
+ return models;
46
+ return models.map((model) => ({ ...model, options }));
47
+ }
48
+ //# sourceMappingURL=run-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-options.js","sourceRoot":"","sources":["../../../src/adapters/run-options.ts"],"names":[],"mappings":"AAYA,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AAEzC;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,OAAwB;IACrD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC;IAC9C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7D,OAAO,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAClF,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAC7B,MAA+B,EAC/B,YAAqB;IAErB,OAAO;QACL,GAAG,EAAE,aAAa;QAClB,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,kBAAkB;QACzB,MAAM;QACN,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACjE,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,MAAM,KAAK,GAA2B;QACpC,OAAO,EAAE,SAAS;QAClB,GAAG,EAAE,KAAK;QACV,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,YAAY;QACnB,GAAG,EAAE,KAAK;KACX,CAAC;IACF,IAAI,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,YAAY,CAAC,MAAyB;IACpD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,WAAW,CAAC,MAAoB,EAAE,OAA2B;IAC3E,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IACxC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,20 @@
1
+ /** Minimal child-process surface the adapters rely on (so it can be faked in tests). */
2
+ export interface SpawnedProcess {
3
+ stdout: NodeJS.ReadableStream;
4
+ /**
5
+ * Optional stderr stream. Most adapters read JSON from stdout, but some CLI
6
+ * sub-commands (e.g. `pi --list-models`) print their human-facing table to
7
+ * stderr, so adapters that need it read from here too.
8
+ */
9
+ stderr?: NodeJS.ReadableStream;
10
+ on(event: 'close', listener: (code: number | null) => void): unknown;
11
+ on(event: 'error', listener: (err: Error) => void): unknown;
12
+ kill(signal?: NodeJS.Signals): unknown;
13
+ }
14
+ /** Extra spawn options some adapters need (e.g. per-turn env for the approval hook). */
15
+ export interface SpawnExtra {
16
+ /** Additional environment variables, merged over the bridge's own `process.env`. */
17
+ env?: Record<string, string>;
18
+ }
19
+ export type SpawnFn = (command: string, args: string[], cwd: string, extra?: SpawnExtra) => SpawnedProcess;
20
+ export declare const defaultSpawn: SpawnFn;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Shared child-process surface for one-shot CLI agent adapters (OpenCode, Claude
3
+ * Code, …). Spawning with `shell:false` and the prompt passed as an argv element
4
+ * means the user prompt is never interpolated into a shell (no command injection).
5
+ * stdin is IGNORED (closed): these CLIs otherwise block waiting for stdin EOF.
6
+ */
7
+ import { spawn } from 'node:child_process';
8
+ export const defaultSpawn = (command, args, cwd, extra) => spawn(command, args, {
9
+ cwd,
10
+ // stdin IGNORED: the agent CLIs hang waiting for stdin EOF otherwise.
11
+ stdio: ['ignore', 'pipe', 'pipe'],
12
+ windowsHide: true,
13
+ shell: false,
14
+ ...(extra?.env ? { env: { ...process.env, ...extra.env } } : {}),
15
+ });
16
+ //# sourceMappingURL=spawn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn.js","sourceRoot":"","sources":["../../../src/adapters/spawn.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AA6B3C,MAAM,CAAC,MAAM,YAAY,GAAY,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CACjE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;IACnB,GAAG;IACH,sEAAsE;IACtE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;IACjC,WAAW,EAAE,IAAI;IACjB,KAAK,EAAE,KAAK;IACZ,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;CACjE,CAAC,CAAC"}