@viewportai/daemon 0.1.0

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 (350) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +157 -0
  3. package/bin/vpd.js +3 -0
  4. package/dist/adapters/claude.d.ts +119 -0
  5. package/dist/adapters/claude.d.ts.map +1 -0
  6. package/dist/adapters/claude.js +621 -0
  7. package/dist/adapters/claude.js.map +1 -0
  8. package/dist/adapters/codex-event-normalizers.d.ts +10 -0
  9. package/dist/adapters/codex-event-normalizers.d.ts.map +1 -0
  10. package/dist/adapters/codex-event-normalizers.js +208 -0
  11. package/dist/adapters/codex-event-normalizers.js.map +1 -0
  12. package/dist/adapters/codex-sdk-loader.d.ts +47 -0
  13. package/dist/adapters/codex-sdk-loader.d.ts.map +1 -0
  14. package/dist/adapters/codex-sdk-loader.js +19 -0
  15. package/dist/adapters/codex-sdk-loader.js.map +1 -0
  16. package/dist/adapters/codex.d.ts +56 -0
  17. package/dist/adapters/codex.d.ts.map +1 -0
  18. package/dist/adapters/codex.js +267 -0
  19. package/dist/adapters/codex.js.map +1 -0
  20. package/dist/adapters/gemini-cli.d.ts +49 -0
  21. package/dist/adapters/gemini-cli.d.ts.map +1 -0
  22. package/dist/adapters/gemini-cli.js +181 -0
  23. package/dist/adapters/gemini-cli.js.map +1 -0
  24. package/dist/adapters/pty.d.ts +56 -0
  25. package/dist/adapters/pty.d.ts.map +1 -0
  26. package/dist/adapters/pty.js +223 -0
  27. package/dist/adapters/pty.js.map +1 -0
  28. package/dist/agents/aider.d.ts +9 -0
  29. package/dist/agents/aider.d.ts.map +1 -0
  30. package/dist/agents/aider.js +37 -0
  31. package/dist/agents/aider.js.map +1 -0
  32. package/dist/agents/built-in.d.ts +4 -0
  33. package/dist/agents/built-in.d.ts.map +1 -0
  34. package/dist/agents/built-in.js +6 -0
  35. package/dist/agents/built-in.js.map +1 -0
  36. package/dist/agents/claude.d.ts +12 -0
  37. package/dist/agents/claude.d.ts.map +1 -0
  38. package/dist/agents/claude.js +93 -0
  39. package/dist/agents/claude.js.map +1 -0
  40. package/dist/agents/codex.d.ts +6 -0
  41. package/dist/agents/codex.d.ts.map +1 -0
  42. package/dist/agents/codex.js +64 -0
  43. package/dist/agents/codex.js.map +1 -0
  44. package/dist/agents/command-detection.d.ts +6 -0
  45. package/dist/agents/command-detection.d.ts.map +1 -0
  46. package/dist/agents/command-detection.js +12 -0
  47. package/dist/agents/command-detection.js.map +1 -0
  48. package/dist/agents/gemini.d.ts +6 -0
  49. package/dist/agents/gemini.d.ts.map +1 -0
  50. package/dist/agents/gemini.js +36 -0
  51. package/dist/agents/gemini.js.map +1 -0
  52. package/dist/cli/agent-commands.d.ts +2 -0
  53. package/dist/cli/agent-commands.d.ts.map +1 -0
  54. package/dist/cli/agent-commands.js +87 -0
  55. package/dist/cli/agent-commands.js.map +1 -0
  56. package/dist/cli/args.d.ts +9 -0
  57. package/dist/cli/args.d.ts.map +1 -0
  58. package/dist/cli/args.js +34 -0
  59. package/dist/cli/args.js.map +1 -0
  60. package/dist/cli/command-shared.d.ts +53 -0
  61. package/dist/cli/command-shared.d.ts.map +1 -0
  62. package/dist/cli/command-shared.js +239 -0
  63. package/dist/cli/command-shared.js.map +1 -0
  64. package/dist/cli/commands.d.ts +20 -0
  65. package/dist/cli/commands.d.ts.map +1 -0
  66. package/dist/cli/commands.js +20 -0
  67. package/dist/cli/commands.js.map +1 -0
  68. package/dist/cli/daemon-client.d.ts +30 -0
  69. package/dist/cli/daemon-client.d.ts.map +1 -0
  70. package/dist/cli/daemon-client.js +161 -0
  71. package/dist/cli/daemon-client.js.map +1 -0
  72. package/dist/cli/daemon-lifecycle.d.ts +47 -0
  73. package/dist/cli/daemon-lifecycle.d.ts.map +1 -0
  74. package/dist/cli/daemon-lifecycle.js +262 -0
  75. package/dist/cli/daemon-lifecycle.js.map +1 -0
  76. package/dist/cli/daemon-settings.d.ts +9 -0
  77. package/dist/cli/daemon-settings.d.ts.map +1 -0
  78. package/dist/cli/daemon-settings.js +168 -0
  79. package/dist/cli/daemon-settings.js.map +1 -0
  80. package/dist/cli/directory-commands.d.ts +4 -0
  81. package/dist/cli/directory-commands.d.ts.map +1 -0
  82. package/dist/cli/directory-commands.js +190 -0
  83. package/dist/cli/directory-commands.js.map +1 -0
  84. package/dist/cli/hook-command.d.ts +14 -0
  85. package/dist/cli/hook-command.d.ts.map +1 -0
  86. package/dist/cli/hook-command.js +96 -0
  87. package/dist/cli/hook-command.js.map +1 -0
  88. package/dist/cli/install-command.d.ts +2 -0
  89. package/dist/cli/install-command.d.ts.map +1 -0
  90. package/dist/cli/install-command.js +91 -0
  91. package/dist/cli/install-command.js.map +1 -0
  92. package/dist/cli/lifecycle-commands.d.ts +10 -0
  93. package/dist/cli/lifecycle-commands.d.ts.map +1 -0
  94. package/dist/cli/lifecycle-commands.js +524 -0
  95. package/dist/cli/lifecycle-commands.js.map +1 -0
  96. package/dist/cli/listen-target.d.ts +13 -0
  97. package/dist/cli/listen-target.d.ts.map +1 -0
  98. package/dist/cli/listen-target.js +102 -0
  99. package/dist/cli/listen-target.js.map +1 -0
  100. package/dist/cli/orchestration-commands.d.ts +8 -0
  101. package/dist/cli/orchestration-commands.d.ts.map +1 -0
  102. package/dist/cli/orchestration-commands.js +340 -0
  103. package/dist/cli/orchestration-commands.js.map +1 -0
  104. package/dist/cli/permission-commands.d.ts +2 -0
  105. package/dist/cli/permission-commands.d.ts.map +1 -0
  106. package/dist/cli/permission-commands.js +138 -0
  107. package/dist/cli/permission-commands.js.map +1 -0
  108. package/dist/cli/runtime-toolchain.d.ts +35 -0
  109. package/dist/cli/runtime-toolchain.d.ts.map +1 -0
  110. package/dist/cli/runtime-toolchain.js +184 -0
  111. package/dist/cli/runtime-toolchain.js.map +1 -0
  112. package/dist/cli/service-commands.d.ts +19 -0
  113. package/dist/cli/service-commands.d.ts.map +1 -0
  114. package/dist/cli/service-commands.js +273 -0
  115. package/dist/cli/service-commands.js.map +1 -0
  116. package/dist/cli/session-commands.d.ts +3 -0
  117. package/dist/cli/session-commands.d.ts.map +1 -0
  118. package/dist/cli/session-commands.js +146 -0
  119. package/dist/cli/session-commands.js.map +1 -0
  120. package/dist/cli/setup-command.d.ts +12 -0
  121. package/dist/cli/setup-command.d.ts.map +1 -0
  122. package/dist/cli/setup-command.js +223 -0
  123. package/dist/cli/setup-command.js.map +1 -0
  124. package/dist/cli/supervisor-protocol.d.ts +20 -0
  125. package/dist/cli/supervisor-protocol.d.ts.map +1 -0
  126. package/dist/cli/supervisor-protocol.js +5 -0
  127. package/dist/cli/supervisor-protocol.js.map +1 -0
  128. package/dist/cli/supervisor.d.ts +10 -0
  129. package/dist/cli/supervisor.d.ts.map +1 -0
  130. package/dist/cli/supervisor.js +218 -0
  131. package/dist/cli/supervisor.js.map +1 -0
  132. package/dist/cli/worktree-commands.d.ts +2 -0
  133. package/dist/cli/worktree-commands.d.ts.map +1 -0
  134. package/dist/cli/worktree-commands.js +250 -0
  135. package/dist/cli/worktree-commands.js.map +1 -0
  136. package/dist/cli/ws-client.d.ts +20 -0
  137. package/dist/cli/ws-client.d.ts.map +1 -0
  138. package/dist/cli/ws-client.js +103 -0
  139. package/dist/cli/ws-client.js.map +1 -0
  140. package/dist/core/agent-registry.d.ts +128 -0
  141. package/dist/core/agent-registry.d.ts.map +1 -0
  142. package/dist/core/agent-registry.js +131 -0
  143. package/dist/core/agent-registry.js.map +1 -0
  144. package/dist/core/config-schema.d.ts +77 -0
  145. package/dist/core/config-schema.d.ts.map +1 -0
  146. package/dist/core/config-schema.js +66 -0
  147. package/dist/core/config-schema.js.map +1 -0
  148. package/dist/core/config.d.ts +111 -0
  149. package/dist/core/config.d.ts.map +1 -0
  150. package/dist/core/config.js +244 -0
  151. package/dist/core/config.js.map +1 -0
  152. package/dist/core/daemon.d.ts +113 -0
  153. package/dist/core/daemon.d.ts.map +1 -0
  154. package/dist/core/daemon.js +197 -0
  155. package/dist/core/daemon.js.map +1 -0
  156. package/dist/core/discovered-sessions.d.ts +7 -0
  157. package/dist/core/discovered-sessions.d.ts.map +1 -0
  158. package/dist/core/discovered-sessions.js +39 -0
  159. package/dist/core/discovered-sessions.js.map +1 -0
  160. package/dist/core/error-codes.d.ts +31 -0
  161. package/dist/core/error-codes.d.ts.map +1 -0
  162. package/dist/core/error-codes.js +30 -0
  163. package/dist/core/error-codes.js.map +1 -0
  164. package/dist/core/errors.d.ts +16 -0
  165. package/dist/core/errors.d.ts.map +1 -0
  166. package/dist/core/errors.js +43 -0
  167. package/dist/core/errors.js.map +1 -0
  168. package/dist/core/events.d.ts +183 -0
  169. package/dist/core/events.d.ts.map +1 -0
  170. package/dist/core/events.js +61 -0
  171. package/dist/core/events.js.map +1 -0
  172. package/dist/core/interfaces.d.ts +115 -0
  173. package/dist/core/interfaces.d.ts.map +1 -0
  174. package/dist/core/interfaces.js +9 -0
  175. package/dist/core/interfaces.js.map +1 -0
  176. package/dist/core/logger.d.ts +11 -0
  177. package/dist/core/logger.d.ts.map +1 -0
  178. package/dist/core/logger.js +17 -0
  179. package/dist/core/logger.js.map +1 -0
  180. package/dist/core/metrics.d.ts +24 -0
  181. package/dist/core/metrics.d.ts.map +1 -0
  182. package/dist/core/metrics.js +32 -0
  183. package/dist/core/metrics.js.map +1 -0
  184. package/dist/core/output.d.ts +13 -0
  185. package/dist/core/output.d.ts.map +1 -0
  186. package/dist/core/output.js +22 -0
  187. package/dist/core/output.js.map +1 -0
  188. package/dist/core/permission-coordinator.d.ts +67 -0
  189. package/dist/core/permission-coordinator.d.ts.map +1 -0
  190. package/dist/core/permission-coordinator.js +209 -0
  191. package/dist/core/permission-coordinator.js.map +1 -0
  192. package/dist/core/session-manager.d.ts +121 -0
  193. package/dist/core/session-manager.d.ts.map +1 -0
  194. package/dist/core/session-manager.js +354 -0
  195. package/dist/core/session-manager.js.map +1 -0
  196. package/dist/core/session-state-file.d.ts +20 -0
  197. package/dist/core/session-state-file.d.ts.map +1 -0
  198. package/dist/core/session-state-file.js +49 -0
  199. package/dist/core/session-state-file.js.map +1 -0
  200. package/dist/core/types.d.ts +250 -0
  201. package/dist/core/types.d.ts.map +1 -0
  202. package/dist/core/types.js +88 -0
  203. package/dist/core/types.js.map +1 -0
  204. package/dist/directories/manager.d.ts +32 -0
  205. package/dist/directories/manager.d.ts.map +1 -0
  206. package/dist/directories/manager.js +86 -0
  207. package/dist/directories/manager.js.map +1 -0
  208. package/dist/discovery/claude.d.ts +29 -0
  209. package/dist/discovery/claude.d.ts.map +1 -0
  210. package/dist/discovery/claude.js +55 -0
  211. package/dist/discovery/claude.js.map +1 -0
  212. package/dist/discovery/codex.d.ts +11 -0
  213. package/dist/discovery/codex.d.ts.map +1 -0
  214. package/dist/discovery/codex.js +365 -0
  215. package/dist/discovery/codex.js.map +1 -0
  216. package/dist/discovery/gemini.d.ts +15 -0
  217. package/dist/discovery/gemini.d.ts.map +1 -0
  218. package/dist/discovery/gemini.js +151 -0
  219. package/dist/discovery/gemini.js.map +1 -0
  220. package/dist/discovery/jsonl-reader.d.ts +122 -0
  221. package/dist/discovery/jsonl-reader.d.ts.map +1 -0
  222. package/dist/discovery/jsonl-reader.js +622 -0
  223. package/dist/discovery/jsonl-reader.js.map +1 -0
  224. package/dist/discovery/watcher.d.ts +29 -0
  225. package/dist/discovery/watcher.d.ts.map +1 -0
  226. package/dist/discovery/watcher.js +383 -0
  227. package/dist/discovery/watcher.js.map +1 -0
  228. package/dist/hooks/index.d.ts +10 -0
  229. package/dist/hooks/index.d.ts.map +1 -0
  230. package/dist/hooks/index.js +8 -0
  231. package/dist/hooks/index.js.map +1 -0
  232. package/dist/hooks/installers/base.d.ts +27 -0
  233. package/dist/hooks/installers/base.d.ts.map +1 -0
  234. package/dist/hooks/installers/base.js +9 -0
  235. package/dist/hooks/installers/base.js.map +1 -0
  236. package/dist/hooks/installers/claude.d.ts +18 -0
  237. package/dist/hooks/installers/claude.d.ts.map +1 -0
  238. package/dist/hooks/installers/claude.js +120 -0
  239. package/dist/hooks/installers/claude.js.map +1 -0
  240. package/dist/hooks/router.d.ts +63 -0
  241. package/dist/hooks/router.d.ts.map +1 -0
  242. package/dist/hooks/router.js +259 -0
  243. package/dist/hooks/router.js.map +1 -0
  244. package/dist/hooks/supervision.d.ts +27 -0
  245. package/dist/hooks/supervision.d.ts.map +1 -0
  246. package/dist/hooks/supervision.js +67 -0
  247. package/dist/hooks/supervision.js.map +1 -0
  248. package/dist/hooks/types.d.ts +171 -0
  249. package/dist/hooks/types.d.ts.map +1 -0
  250. package/dist/hooks/types.js +148 -0
  251. package/dist/hooks/types.js.map +1 -0
  252. package/dist/index.d.ts +17 -0
  253. package/dist/index.d.ts.map +1 -0
  254. package/dist/index.js +117 -0
  255. package/dist/index.js.map +1 -0
  256. package/dist/permissions/engine.d.ts +23 -0
  257. package/dist/permissions/engine.d.ts.map +1 -0
  258. package/dist/permissions/engine.js +43 -0
  259. package/dist/permissions/engine.js.map +1 -0
  260. package/dist/plugins/loader.d.ts +44 -0
  261. package/dist/plugins/loader.d.ts.map +1 -0
  262. package/dist/plugins/loader.js +177 -0
  263. package/dist/plugins/loader.js.map +1 -0
  264. package/dist/server/auth.d.ts +32 -0
  265. package/dist/server/auth.d.ts.map +1 -0
  266. package/dist/server/auth.js +78 -0
  267. package/dist/server/auth.js.map +1 -0
  268. package/dist/server/discovered-watch-key.d.ts +5 -0
  269. package/dist/server/discovered-watch-key.d.ts.map +1 -0
  270. package/dist/server/discovered-watch-key.js +31 -0
  271. package/dist/server/discovered-watch-key.js.map +1 -0
  272. package/dist/server/hello-builder.d.ts +17 -0
  273. package/dist/server/hello-builder.d.ts.map +1 -0
  274. package/dist/server/hello-builder.js +71 -0
  275. package/dist/server/hello-builder.js.map +1 -0
  276. package/dist/server/http-server.d.ts +30 -0
  277. package/dist/server/http-server.d.ts.map +1 -0
  278. package/dist/server/http-server.js +561 -0
  279. package/dist/server/http-server.js.map +1 -0
  280. package/dist/server/message-normalizers.d.ts +11 -0
  281. package/dist/server/message-normalizers.d.ts.map +1 -0
  282. package/dist/server/message-normalizers.js +104 -0
  283. package/dist/server/message-normalizers.js.map +1 -0
  284. package/dist/server/pairing-offers.d.ts +78 -0
  285. package/dist/server/pairing-offers.d.ts.map +1 -0
  286. package/dist/server/pairing-offers.js +502 -0
  287. package/dist/server/pairing-offers.js.map +1 -0
  288. package/dist/server/rate-limiter.d.ts +21 -0
  289. package/dist/server/rate-limiter.d.ts.map +1 -0
  290. package/dist/server/rate-limiter.js +61 -0
  291. package/dist/server/rate-limiter.js.map +1 -0
  292. package/dist/server/ring-buffer.d.ts +34 -0
  293. package/dist/server/ring-buffer.d.ts.map +1 -0
  294. package/dist/server/ring-buffer.js +73 -0
  295. package/dist/server/ring-buffer.js.map +1 -0
  296. package/dist/server/security.d.ts +22 -0
  297. package/dist/server/security.d.ts.map +1 -0
  298. package/dist/server/security.js +123 -0
  299. package/dist/server/security.js.map +1 -0
  300. package/dist/server/ws-command-handlers.d.ts +25 -0
  301. package/dist/server/ws-command-handlers.d.ts.map +1 -0
  302. package/dist/server/ws-command-handlers.js +218 -0
  303. package/dist/server/ws-command-handlers.js.map +1 -0
  304. package/dist/server/ws-daemon-event-bridge.d.ts +22 -0
  305. package/dist/server/ws-daemon-event-bridge.d.ts.map +1 -0
  306. package/dist/server/ws-daemon-event-bridge.js +321 -0
  307. package/dist/server/ws-daemon-event-bridge.js.map +1 -0
  308. package/dist/server/ws-limits.d.ts +2 -0
  309. package/dist/server/ws-limits.d.ts.map +1 -0
  310. package/dist/server/ws-limits.js +12 -0
  311. package/dist/server/ws-limits.js.map +1 -0
  312. package/dist/server/ws-protocol.d.ts +248 -0
  313. package/dist/server/ws-protocol.d.ts.map +1 -0
  314. package/dist/server/ws-protocol.js +157 -0
  315. package/dist/server/ws-protocol.js.map +1 -0
  316. package/dist/server/ws-server.d.ts +26 -0
  317. package/dist/server/ws-server.d.ts.map +1 -0
  318. package/dist/server/ws-server.js +290 -0
  319. package/dist/server/ws-server.js.map +1 -0
  320. package/dist/startup-agents.d.ts +6 -0
  321. package/dist/startup-agents.d.ts.map +1 -0
  322. package/dist/startup-agents.js +97 -0
  323. package/dist/startup-agents.js.map +1 -0
  324. package/dist/startup-prereqs.d.ts +29 -0
  325. package/dist/startup-prereqs.d.ts.map +1 -0
  326. package/dist/startup-prereqs.js +209 -0
  327. package/dist/startup-prereqs.js.map +1 -0
  328. package/dist/startup-watchers.d.ts +7 -0
  329. package/dist/startup-watchers.d.ts.map +1 -0
  330. package/dist/startup-watchers.js +196 -0
  331. package/dist/startup-watchers.js.map +1 -0
  332. package/dist/startup.d.ts +20 -0
  333. package/dist/startup.d.ts.map +1 -0
  334. package/dist/startup.js +335 -0
  335. package/dist/startup.js.map +1 -0
  336. package/dist/tracking/git-tracker.d.ts +52 -0
  337. package/dist/tracking/git-tracker.d.ts.map +1 -0
  338. package/dist/tracking/git-tracker.js +277 -0
  339. package/dist/tracking/git-tracker.js.map +1 -0
  340. package/dist/tracking/noop-tracker.d.ts +27 -0
  341. package/dist/tracking/noop-tracker.d.ts.map +1 -0
  342. package/dist/tracking/noop-tracker.js +42 -0
  343. package/dist/tracking/noop-tracker.js.map +1 -0
  344. package/docs/configuration.md +75 -0
  345. package/docs/developer-workflows.md +107 -0
  346. package/docs/protocol-matrix.json +155 -0
  347. package/docs/releasing.md +65 -0
  348. package/docs/security.md +48 -0
  349. package/docs/testing.md +112 -0
  350. package/package.json +84 -0
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # Viewport Daemon
2
+
3
+ Runtime supervision and orchestration layer for AI coding agents.
4
+
5
+ ## What it does
6
+
7
+ 1. Launches and manages agent sessions.
8
+ 2. Tracks lifecycle, permissions, and session state.
9
+ 3. Exposes local HTTP and WebSocket APIs for control and monitoring.
10
+ 4. Supports discovery and resume flows for existing sessions.
11
+
12
+ ## Requirements
13
+
14
+ 1. Node.js 20+
15
+ 2. npm 10+
16
+
17
+ ## One Command Install
18
+
19
+ ```bash
20
+ curl -fsSL https://raw.githubusercontent.com/viewportai/daemon/main/scripts/install.sh | bash
21
+ ```
22
+
23
+ This installs `@viewportai/daemon` globally, then runs `vpd setup`.
24
+
25
+ Local development install (from this repo, no npm publish needed):
26
+
27
+ ```bash
28
+ ./scripts/install-dev.sh --yes --no-service --no-prereqs --no-hooks
29
+ ```
30
+
31
+ Local development link mode:
32
+
33
+ ```bash
34
+ ./scripts/install-dev.sh --link --yes --no-service --no-prereqs --no-hooks
35
+ ```
36
+
37
+ Local uninstall/reinstall:
38
+
39
+ ```bash
40
+ npm run dev:uninstall # removes global package + launchd/systemd user service
41
+ npm run dev:uninstall:all # also removes daemon home/state
42
+ npm run dev:reinstall
43
+ ```
44
+
45
+ ## Quick start
46
+
47
+ ```bash
48
+ npm ci
49
+ npm run build
50
+ npm run test
51
+ npm run check
52
+ ```
53
+
54
+ Flag-driven test entry (single command surface):
55
+
56
+ ```bash
57
+ npm run test # unit suite (default)
58
+ npm run test --verify # setup/service-focused verification suite
59
+ npm run test --e2e # protocol e2e suite
60
+ npm run test --fullstack # localhost fullstack CLI e2e
61
+ npm run test --env # local environment verification
62
+ npm run test --service # local environment + service verification
63
+ ```
64
+
65
+ First-run onboarding:
66
+
67
+ ```bash
68
+ vpd setup
69
+ ```
70
+
71
+ Non-interactive recommended defaults:
72
+
73
+ ```bash
74
+ vpd setup --yes
75
+ ```
76
+
77
+ Custom choices:
78
+
79
+ ```bash
80
+ vpd setup --choose
81
+ ```
82
+
83
+ ## CLI
84
+
85
+ ```bash
86
+ npm run build
87
+ node dist/index.js --help
88
+ ```
89
+
90
+ Boot service setup (user-level):
91
+
92
+ ```bash
93
+ vpd service install
94
+ vpd service status
95
+ ```
96
+
97
+ Linux VPS note:
98
+ For user-level systemd service auto-start after reboot, enable linger once:
99
+
100
+ ```bash
101
+ sudo loginctl enable-linger "$USER"
102
+ ```
103
+
104
+ ## Quality gates
105
+
106
+ ```bash
107
+ npm run typecheck
108
+ npm run lint
109
+ npm run format:check
110
+ npm run test
111
+ npm run check
112
+ ```
113
+
114
+ ## Testing Setup Flow
115
+
116
+ ```bash
117
+ # fast setup-related tests
118
+ npm run test:setup
119
+
120
+ # full repository quality gate
121
+ npm run check
122
+
123
+ # manual verification test (no service or package installs)
124
+ VIEWPORT_HOME="$(mktemp -d)" vpd setup --yes --no-service --no-prereqs --no-hooks
125
+
126
+ # full local environment verification (isolated home + dedicated listen target)
127
+ npm run verify:env
128
+
129
+ # include OS service checks (launchd/systemd)
130
+ npm run verify:env:service
131
+
132
+ # package/install verification from local tarball in isolated prefix
133
+ npm run verify:install
134
+
135
+ # one-command verification gate
136
+ npm run verify:repo
137
+
138
+ # CI-aligned Linux verification path
139
+ npm run verify:linux:ci
140
+ ```
141
+
142
+ ## Repository standards
143
+
144
+ 1. Semantic commits (`feat:`, `fix:`, `refactor:`, `test:`, `docs:`, `chore:`).
145
+ 2. One logical change per commit.
146
+ 3. Changes to protocol or runtime behavior require matching tests.
147
+
148
+ ## Release
149
+
150
+ This package publishes as `@viewportai/daemon`.
151
+
152
+ 1. Merge semantic commits to `main`.
153
+ 2. CI must pass.
154
+ 3. Release workflow computes version (`feat` => minor, `fix` => patch, `BREAKING CHANGE` => major), tags, and publishes to npm using `NPM_TOKEN`.
155
+
156
+ See [docs/releasing.md](./docs/releasing.md) for setup and operations.
157
+ See [docs/testing.md](./docs/testing.md) and [docs/developer-workflows.md](./docs/developer-workflows.md) for local validation workflows.
package/bin/vpd.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ import '../dist/index.js';
@@ -0,0 +1,119 @@
1
+ /**
2
+ * ClaudeAdapter — bridges the Claude Agent SDK with the Viewport daemon.
3
+ *
4
+ * Uses the SDK's `query()` function to start/resume sessions, normalizes
5
+ * SDK messages into Viewport's SessionMessage format, and handles the
6
+ * permission flow by bridging SDK's `canUseTool` callback to the daemon's
7
+ * event-based permission system.
8
+ */
9
+ import { EventEmitter } from 'node:events';
10
+ import type { AgentAdapter, Session, SessionOptions, PermissionHandler } from '../core/interfaces.js';
11
+ import type { SessionState } from '../core/types.js';
12
+ /** Minimal shape of the SDK's query() return value. */
13
+ interface SDKQuery {
14
+ [Symbol.asyncIterator](): AsyncIterator<SDKRawMessage, void>;
15
+ interrupt(): Promise<void>;
16
+ close(): void;
17
+ }
18
+ /**
19
+ * Minimal shape of SDK messages we need to handle.
20
+ * The actual SDK has 22+ message types — we normalize the ones we care about.
21
+ */
22
+ interface SDKRawMessage {
23
+ type: string;
24
+ subtype?: string;
25
+ [key: string]: any;
26
+ }
27
+ /** SDK's canUseTool callback signature. */
28
+ type SDKCanUseTool = (toolName: string, input: Record<string, unknown>, options: {
29
+ signal: AbortSignal;
30
+ toolUseID: string;
31
+ decisionReason?: string;
32
+ blockedPath?: string;
33
+ agentID?: string;
34
+ }) => Promise<SDKPermissionResult>;
35
+ interface SDKPermissionResult {
36
+ behavior: 'allow' | 'deny';
37
+ updatedInput?: Record<string, unknown>;
38
+ message?: string;
39
+ }
40
+ /** Shape of query() function. */
41
+ export type QueryFn = (params: {
42
+ prompt: string;
43
+ options?: {
44
+ cwd?: string;
45
+ model?: string;
46
+ resume?: string;
47
+ sessionId?: string;
48
+ canUseTool?: SDKCanUseTool;
49
+ allowedTools?: string[];
50
+ maxTurns?: number;
51
+ maxBudgetUsd?: number;
52
+ abortController?: AbortController;
53
+ systemPrompt?: string;
54
+ permissionMode?: string;
55
+ persistSession?: boolean;
56
+ };
57
+ }) => SDKQuery;
58
+ export declare class ClaudeSession extends EventEmitter implements Session {
59
+ private queryFn;
60
+ private canUseTool?;
61
+ readonly id: string;
62
+ state: SessionState;
63
+ private query;
64
+ private abortController;
65
+ private drainPromise;
66
+ private cwd;
67
+ private resumedContext;
68
+ private pendingMessages;
69
+ private pendingFlushScheduled;
70
+ private endedForPoisonedHistory;
71
+ constructor(sessionId: string, queryFn: QueryFn, canUseTool?: PermissionHandler | undefined);
72
+ /** Start the session with an initial prompt. */
73
+ start(prompt: string, cwd: string, options?: SessionOptions): Promise<void>;
74
+ /** Resume an existing session. */
75
+ resume(sessionId: string, cwd: string, options?: SessionOptions): Promise<void>;
76
+ sendPrompt(text: string): Promise<void>;
77
+ kill(): Promise<void>;
78
+ private drainMessages;
79
+ /**
80
+ * Normalize SDK messages into Viewport SessionMessage types.
81
+ * Returns null for messages we don't care about.
82
+ */
83
+ private normalizeMessage;
84
+ private normalizeSystemMessage;
85
+ private normalizeAssistantMessage;
86
+ /**
87
+ * Normalize SDK 'user' messages — these carry tool results.
88
+ *
89
+ * The SDK sends tool execution results as user messages with a
90
+ * `tool_use_result` field containing the output, and the `message.content`
91
+ * array contains `tool_result` blocks.
92
+ */
93
+ private normalizeUserMessage;
94
+ /** Extract human-readable text from a tool_result content block. */
95
+ private extractToolResultText;
96
+ private normalizeStreamEvent;
97
+ private normalizeResultMessage;
98
+ private isPoisonedHistoryApiError;
99
+ private endPoisonedHistorySession;
100
+ private resultErrorDetail;
101
+ private wrapCanUseTool;
102
+ private emitLocalUserPrompt;
103
+ private emitSessionMessage;
104
+ private schedulePendingFlush;
105
+ private flushPendingMessages;
106
+ /** Valid state transitions — guards against concurrent setState calls. */
107
+ private static readonly VALID_TRANSITIONS;
108
+ private _transitioning;
109
+ private setState;
110
+ }
111
+ export declare class ClaudeAdapter implements AgentAdapter {
112
+ private queryFn;
113
+ readonly agentId = "claude";
114
+ constructor(queryFn: QueryFn);
115
+ startSession(cwd: string, options?: SessionOptions): Promise<Session>;
116
+ resumeSession(sessionId: string, cwd: string, options?: SessionOptions): Promise<Session>;
117
+ }
118
+ export {};
119
+ //# sourceMappingURL=claude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/adapters/claude.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EACV,YAAY,EACZ,OAAO,EACP,cAAc,EACd,iBAAiB,EAElB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,kBAAkB,CAAC;AAWrE,uDAAuD;AACvD,UAAU,QAAQ;IAChB,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IAC7D,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;GAGG;AACH,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,2CAA2C;AAC3C,KAAK,aAAa,GAAG,CACnB,QAAQ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