@andrew.ng/symbion 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 (417) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +125 -0
  3. package/apps/daemon/dist/boot/menu.d.ts +11 -0
  4. package/apps/daemon/dist/boot/menu.d.ts.map +1 -0
  5. package/apps/daemon/dist/boot/menu.js +32 -0
  6. package/apps/daemon/dist/boot/menu.js.map +1 -0
  7. package/apps/daemon/dist/fs/folderPick.d.ts +13 -0
  8. package/apps/daemon/dist/fs/folderPick.d.ts.map +1 -0
  9. package/apps/daemon/dist/fs/folderPick.js +4 -0
  10. package/apps/daemon/dist/fs/folderPick.js.map +1 -0
  11. package/apps/daemon/dist/fs/listDir.d.ts +13 -0
  12. package/apps/daemon/dist/fs/listDir.d.ts.map +1 -0
  13. package/apps/daemon/dist/fs/listDir.js +121 -0
  14. package/apps/daemon/dist/fs/listDir.js.map +1 -0
  15. package/apps/daemon/dist/fs/readTargetFiles.d.ts +20 -0
  16. package/apps/daemon/dist/fs/readTargetFiles.d.ts.map +1 -0
  17. package/apps/daemon/dist/fs/readTargetFiles.js +76 -0
  18. package/apps/daemon/dist/fs/readTargetFiles.js.map +1 -0
  19. package/apps/daemon/dist/fs/writeFiles.d.ts +32 -0
  20. package/apps/daemon/dist/fs/writeFiles.d.ts.map +1 -0
  21. package/apps/daemon/dist/fs/writeFiles.js +93 -0
  22. package/apps/daemon/dist/fs/writeFiles.js.map +1 -0
  23. package/apps/daemon/dist/git/status.d.ts +11 -0
  24. package/apps/daemon/dist/git/status.d.ts.map +1 -0
  25. package/apps/daemon/dist/git/status.js +30 -0
  26. package/apps/daemon/dist/git/status.js.map +1 -0
  27. package/apps/daemon/dist/index.d.ts +2 -0
  28. package/apps/daemon/dist/index.d.ts.map +1 -0
  29. package/apps/daemon/dist/index.js +69 -0
  30. package/apps/daemon/dist/index.js.map +1 -0
  31. package/apps/daemon/dist/llm/anthropicProvider.d.ts +26 -0
  32. package/apps/daemon/dist/llm/anthropicProvider.d.ts.map +1 -0
  33. package/apps/daemon/dist/llm/anthropicProvider.js +90 -0
  34. package/apps/daemon/dist/llm/anthropicProvider.js.map +1 -0
  35. package/apps/daemon/dist/llm/geminiProvider.d.ts +25 -0
  36. package/apps/daemon/dist/llm/geminiProvider.d.ts.map +1 -0
  37. package/apps/daemon/dist/llm/geminiProvider.js +89 -0
  38. package/apps/daemon/dist/llm/geminiProvider.js.map +1 -0
  39. package/apps/daemon/dist/llm/installInstructions.d.ts +40 -0
  40. package/apps/daemon/dist/llm/installInstructions.d.ts.map +1 -0
  41. package/apps/daemon/dist/llm/installInstructions.js +80 -0
  42. package/apps/daemon/dist/llm/installInstructions.js.map +1 -0
  43. package/apps/daemon/dist/llm/ollamaProvider.d.ts +55 -0
  44. package/apps/daemon/dist/llm/ollamaProvider.d.ts.map +1 -0
  45. package/apps/daemon/dist/llm/ollamaProvider.js +213 -0
  46. package/apps/daemon/dist/llm/ollamaProvider.js.map +1 -0
  47. package/apps/daemon/dist/llm/openaiProvider.d.ts +25 -0
  48. package/apps/daemon/dist/llm/openaiProvider.d.ts.map +1 -0
  49. package/apps/daemon/dist/llm/openaiProvider.js +90 -0
  50. package/apps/daemon/dist/llm/openaiProvider.js.map +1 -0
  51. package/apps/daemon/dist/llm/providerStatus.d.ts +60 -0
  52. package/apps/daemon/dist/llm/providerStatus.d.ts.map +1 -0
  53. package/apps/daemon/dist/llm/providerStatus.js +88 -0
  54. package/apps/daemon/dist/llm/providerStatus.js.map +1 -0
  55. package/apps/daemon/dist/llm/registry.d.ts +14 -0
  56. package/apps/daemon/dist/llm/registry.d.ts.map +1 -0
  57. package/apps/daemon/dist/llm/registry.js +35 -0
  58. package/apps/daemon/dist/llm/registry.js.map +1 -0
  59. package/apps/daemon/dist/llm/remoteProvider.d.ts +25 -0
  60. package/apps/daemon/dist/llm/remoteProvider.d.ts.map +1 -0
  61. package/apps/daemon/dist/llm/remoteProvider.js +88 -0
  62. package/apps/daemon/dist/llm/remoteProvider.js.map +1 -0
  63. package/apps/daemon/dist/llm/secrets.d.ts +55 -0
  64. package/apps/daemon/dist/llm/secrets.d.ts.map +1 -0
  65. package/apps/daemon/dist/llm/secrets.js +167 -0
  66. package/apps/daemon/dist/llm/secrets.js.map +1 -0
  67. package/apps/daemon/dist/llm/types.d.ts +50 -0
  68. package/apps/daemon/dist/llm/types.d.ts.map +1 -0
  69. package/apps/daemon/dist/llm/types.js +16 -0
  70. package/apps/daemon/dist/llm/types.js.map +1 -0
  71. package/apps/daemon/dist/net/findOpenPort.d.ts +26 -0
  72. package/apps/daemon/dist/net/findOpenPort.d.ts.map +1 -0
  73. package/apps/daemon/dist/net/findOpenPort.js +37 -0
  74. package/apps/daemon/dist/net/findOpenPort.js.map +1 -0
  75. package/apps/daemon/dist/rpc/contract.d.ts +10 -0
  76. package/apps/daemon/dist/rpc/contract.d.ts.map +1 -0
  77. package/apps/daemon/dist/rpc/contract.js +2 -0
  78. package/apps/daemon/dist/rpc/contract.js.map +1 -0
  79. package/apps/daemon/dist/rpc/guard.d.ts +18 -0
  80. package/apps/daemon/dist/rpc/guard.d.ts.map +1 -0
  81. package/apps/daemon/dist/rpc/guard.js +75 -0
  82. package/apps/daemon/dist/rpc/guard.js.map +1 -0
  83. package/apps/daemon/dist/rpc/handlers.d.ts +118 -0
  84. package/apps/daemon/dist/rpc/handlers.d.ts.map +1 -0
  85. package/apps/daemon/dist/rpc/handlers.js +694 -0
  86. package/apps/daemon/dist/rpc/handlers.js.map +1 -0
  87. package/apps/daemon/dist/rpc/pathStyle.d.ts +27 -0
  88. package/apps/daemon/dist/rpc/pathStyle.d.ts.map +1 -0
  89. package/apps/daemon/dist/rpc/pathStyle.js +43 -0
  90. package/apps/daemon/dist/rpc/pathStyle.js.map +1 -0
  91. package/apps/daemon/dist/rpc/rpcError.d.ts +13 -0
  92. package/apps/daemon/dist/rpc/rpcError.d.ts.map +1 -0
  93. package/apps/daemon/dist/rpc/rpcError.js +16 -0
  94. package/apps/daemon/dist/rpc/rpcError.js.map +1 -0
  95. package/apps/daemon/dist/server.d.ts +18 -0
  96. package/apps/daemon/dist/server.d.ts.map +1 -0
  97. package/apps/daemon/dist/server.js +208 -0
  98. package/apps/daemon/dist/server.js.map +1 -0
  99. package/apps/daemon/dist/store/publishLog.d.ts +6 -0
  100. package/apps/daemon/dist/store/publishLog.d.ts.map +1 -0
  101. package/apps/daemon/dist/store/publishLog.js +27 -0
  102. package/apps/daemon/dist/store/publishLog.js.map +1 -0
  103. package/apps/daemon/dist/store/store.d.ts +35 -0
  104. package/apps/daemon/dist/store/store.d.ts.map +1 -0
  105. package/apps/daemon/dist/store/store.js +129 -0
  106. package/apps/daemon/dist/store/store.js.map +1 -0
  107. package/apps/daemon/dist/templates/githubFetch.d.ts +49 -0
  108. package/apps/daemon/dist/templates/githubFetch.d.ts.map +1 -0
  109. package/apps/daemon/dist/templates/githubFetch.js +168 -0
  110. package/apps/daemon/dist/templates/githubFetch.js.map +1 -0
  111. package/apps/web/out/404.html +1 -0
  112. package/apps/web/out/_next/static/IIw50lkv8jQuwHOBZJifS/_buildManifest.js +1 -0
  113. package/apps/web/out/_next/static/IIw50lkv8jQuwHOBZJifS/_ssgManifest.js +1 -0
  114. package/apps/web/out/_next/static/chunks/1dd3208c-6a745fea7bd2124a.js +1 -0
  115. package/apps/web/out/_next/static/chunks/426-deb95a16531d3b4b.js +25 -0
  116. package/apps/web/out/_next/static/chunks/528-6e64508688610bfe.js +2 -0
  117. package/apps/web/out/_next/static/chunks/656-fd1628581ad77b01.js +1 -0
  118. package/apps/web/out/_next/static/chunks/777-d587bc7cc0fc6be8.js +1 -0
  119. package/apps/web/out/_next/static/chunks/990-f2445c68c17fa077.js +1 -0
  120. package/apps/web/out/_next/static/chunks/app/_not-found/page-e0d77774c4eb9aef.js +1 -0
  121. package/apps/web/out/_next/static/chunks/app/layout-e5023aba6634ce53.js +1 -0
  122. package/apps/web/out/_next/static/chunks/app/page-a545c902535ac2e3.js +1 -0
  123. package/apps/web/out/_next/static/chunks/app/settings/page-a68ed4ae2ccb8840.js +1 -0
  124. package/apps/web/out/_next/static/chunks/app/templates/page-e5f0cefb905e5b72.js +1 -0
  125. package/apps/web/out/_next/static/chunks/baeaa4ff-28d2e32e4dd119b9.js +1 -0
  126. package/apps/web/out/_next/static/chunks/eb0351e1-329719bc902eaf71.js +1 -0
  127. package/apps/web/out/_next/static/chunks/framework-3664cab31236a9fa.js +1 -0
  128. package/apps/web/out/_next/static/chunks/main-app-d515c42ecb17b8e8.js +1 -0
  129. package/apps/web/out/_next/static/chunks/main-ff24788874d4ec1b.js +1 -0
  130. package/apps/web/out/_next/static/chunks/pages/_app-10a93ab5b7c32eb3.js +1 -0
  131. package/apps/web/out/_next/static/chunks/pages/_error-2d792b2a41857be4.js +1 -0
  132. package/apps/web/out/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  133. package/apps/web/out/_next/static/chunks/webpack-ae7ee8fe97fdceba.js +1 -0
  134. package/apps/web/out/_next/static/css/0a42edcfc2beb916.css +3 -0
  135. package/apps/web/out/_next/static/css/a275cc2b185e04f8.css +1 -0
  136. package/apps/web/out/_next/static/media/011e180705008d6f-s.woff2 +0 -0
  137. package/apps/web/out/_next/static/media/20535187d867b7b9-s.woff2 +0 -0
  138. package/apps/web/out/_next/static/media/26d4368bf94c0ec4-s.p.woff2 +0 -0
  139. package/apps/web/out/_next/static/media/2801417b65625cf5-s.woff2 +0 -0
  140. package/apps/web/out/_next/static/media/28793f5c5e3d822d-s.woff2 +0 -0
  141. package/apps/web/out/_next/static/media/5356a6a4f2c8c8d8-s.woff2 +0 -0
  142. package/apps/web/out/_next/static/media/58f386aa6b1a2a92-s.woff2 +0 -0
  143. package/apps/web/out/_next/static/media/73cb51aac9c97f90-s.woff2 +0 -0
  144. package/apps/web/out/_next/static/media/7b19b489dc6743ba-s.woff2 +0 -0
  145. package/apps/web/out/_next/static/media/7ba5fb2a8c88521c-s.woff2 +0 -0
  146. package/apps/web/out/_next/static/media/92eeb95d069020cc-s.woff2 +0 -0
  147. package/apps/web/out/_next/static/media/98e207f02528a563-s.p.woff2 +0 -0
  148. package/apps/web/out/_next/static/media/99dcf268bda04fe5-s.woff2 +0 -0
  149. package/apps/web/out/_next/static/media/b3bf17a9041d9433-s.woff2 +0 -0
  150. package/apps/web/out/_next/static/media/c9c3823090ec8b55-s.woff2 +0 -0
  151. package/apps/web/out/_next/static/media/d26bbd13d6b70f89-s.woff2 +0 -0
  152. package/apps/web/out/_next/static/media/d29838c109ef09b4-s.woff2 +0 -0
  153. package/apps/web/out/_next/static/media/d3ebbfd689654d3a-s.p.woff2 +0 -0
  154. package/apps/web/out/_next/static/media/db96af6b531dc71f-s.p.woff2 +0 -0
  155. package/apps/web/out/_next/static/media/e40af3453d7c920a-s.woff2 +0 -0
  156. package/apps/web/out/_next/static/media/ef4d5661765d0e49-s.woff2 +0 -0
  157. package/apps/web/out/index.html +1 -0
  158. package/apps/web/out/index.txt +6 -0
  159. package/apps/web/out/settings.html +1 -0
  160. package/apps/web/out/settings.txt +6 -0
  161. package/apps/web/out/templates.html +1 -0
  162. package/apps/web/out/templates.txt +6 -0
  163. package/bin/symbion.mjs +41 -0
  164. package/node_modules/@symbion/core/dist/adapters/claude.d.ts +3 -0
  165. package/node_modules/@symbion/core/dist/adapters/claude.d.ts.map +1 -0
  166. package/node_modules/@symbion/core/dist/adapters/claude.js +43 -0
  167. package/node_modules/@symbion/core/dist/adapters/claude.js.map +1 -0
  168. package/node_modules/@symbion/core/dist/adapters/codex.d.ts +3 -0
  169. package/node_modules/@symbion/core/dist/adapters/codex.d.ts.map +1 -0
  170. package/node_modules/@symbion/core/dist/adapters/codex.js +58 -0
  171. package/node_modules/@symbion/core/dist/adapters/codex.js.map +1 -0
  172. package/node_modules/@symbion/core/dist/adapters/registry.d.ts +5 -0
  173. package/node_modules/@symbion/core/dist/adapters/registry.d.ts.map +1 -0
  174. package/node_modules/@symbion/core/dist/adapters/registry.js +14 -0
  175. package/node_modules/@symbion/core/dist/adapters/registry.js.map +1 -0
  176. package/node_modules/@symbion/core/dist/adapters/types.d.ts +34 -0
  177. package/node_modules/@symbion/core/dist/adapters/types.d.ts.map +1 -0
  178. package/node_modules/@symbion/core/dist/adapters/types.js +2 -0
  179. package/node_modules/@symbion/core/dist/adapters/types.js.map +1 -0
  180. package/node_modules/@symbion/core/dist/diff/conflict.d.ts +19 -0
  181. package/node_modules/@symbion/core/dist/diff/conflict.d.ts.map +1 -0
  182. package/node_modules/@symbion/core/dist/diff/conflict.js +20 -0
  183. package/node_modules/@symbion/core/dist/diff/conflict.js.map +1 -0
  184. package/node_modules/@symbion/core/dist/diff/diff.d.ts +44 -0
  185. package/node_modules/@symbion/core/dist/diff/diff.d.ts.map +1 -0
  186. package/node_modules/@symbion/core/dist/diff/diff.js +124 -0
  187. package/node_modules/@symbion/core/dist/diff/diff.js.map +1 -0
  188. package/node_modules/@symbion/core/dist/generate/bodyPrompt.d.ts +27 -0
  189. package/node_modules/@symbion/core/dist/generate/bodyPrompt.d.ts.map +1 -0
  190. package/node_modules/@symbion/core/dist/generate/bodyPrompt.js +55 -0
  191. package/node_modules/@symbion/core/dist/generate/bodyPrompt.js.map +1 -0
  192. package/node_modules/@symbion/core/dist/generate/description.d.ts +18 -0
  193. package/node_modules/@symbion/core/dist/generate/description.d.ts.map +1 -0
  194. package/node_modules/@symbion/core/dist/generate/description.js +164 -0
  195. package/node_modules/@symbion/core/dist/generate/description.js.map +1 -0
  196. package/node_modules/@symbion/core/dist/index.d.ts +23 -0
  197. package/node_modules/@symbion/core/dist/index.d.ts.map +1 -0
  198. package/node_modules/@symbion/core/dist/index.js +24 -0
  199. package/node_modules/@symbion/core/dist/index.js.map +1 -0
  200. package/node_modules/@symbion/core/dist/ir/refs.d.ts +11 -0
  201. package/node_modules/@symbion/core/dist/ir/refs.d.ts.map +1 -0
  202. package/node_modules/@symbion/core/dist/ir/refs.js +25 -0
  203. package/node_modules/@symbion/core/dist/ir/refs.js.map +1 -0
  204. package/node_modules/@symbion/core/dist/ir/types.d.ts +107 -0
  205. package/node_modules/@symbion/core/dist/ir/types.d.ts.map +1 -0
  206. package/node_modules/@symbion/core/dist/ir/types.js +19 -0
  207. package/node_modules/@symbion/core/dist/ir/types.js.map +1 -0
  208. package/node_modules/@symbion/core/dist/ir/validate.d.ts +13 -0
  209. package/node_modules/@symbion/core/dist/ir/validate.d.ts.map +1 -0
  210. package/node_modules/@symbion/core/dist/ir/validate.js +114 -0
  211. package/node_modules/@symbion/core/dist/ir/validate.js.map +1 -0
  212. package/node_modules/@symbion/core/dist/parse/scan.d.ts +47 -0
  213. package/node_modules/@symbion/core/dist/parse/scan.d.ts.map +1 -0
  214. package/node_modules/@symbion/core/dist/parse/scan.js +109 -0
  215. package/node_modules/@symbion/core/dist/parse/scan.js.map +1 -0
  216. package/node_modules/@symbion/core/dist/render/frontmatter.d.ts +29 -0
  217. package/node_modules/@symbion/core/dist/render/frontmatter.d.ts.map +1 -0
  218. package/node_modules/@symbion/core/dist/render/frontmatter.js +99 -0
  219. package/node_modules/@symbion/core/dist/render/frontmatter.js.map +1 -0
  220. package/node_modules/@symbion/core/dist/render/marker.d.ts +30 -0
  221. package/node_modules/@symbion/core/dist/render/marker.d.ts.map +1 -0
  222. package/node_modules/@symbion/core/dist/render/marker.js +48 -0
  223. package/node_modules/@symbion/core/dist/render/marker.js.map +1 -0
  224. package/node_modules/@symbion/core/dist/render/render.d.ts +12 -0
  225. package/node_modules/@symbion/core/dist/render/render.d.ts.map +1 -0
  226. package/node_modules/@symbion/core/dist/render/render.js +10 -0
  227. package/node_modules/@symbion/core/dist/render/render.js.map +1 -0
  228. package/node_modules/@symbion/core/dist/runcommand/render.d.ts +13 -0
  229. package/node_modules/@symbion/core/dist/runcommand/render.d.ts.map +1 -0
  230. package/node_modules/@symbion/core/dist/runcommand/render.js +19 -0
  231. package/node_modules/@symbion/core/dist/runcommand/render.js.map +1 -0
  232. package/node_modules/@symbion/core/dist/templates/authorSource.d.ts +55 -0
  233. package/node_modules/@symbion/core/dist/templates/authorSource.d.ts.map +1 -0
  234. package/node_modules/@symbion/core/dist/templates/authorSource.js +24 -0
  235. package/node_modules/@symbion/core/dist/templates/authorSource.js.map +1 -0
  236. package/node_modules/@symbion/core/dist/templates/matchAuthorFolders.d.ts +28 -0
  237. package/node_modules/@symbion/core/dist/templates/matchAuthorFolders.d.ts.map +1 -0
  238. package/node_modules/@symbion/core/dist/templates/matchAuthorFolders.js +54 -0
  239. package/node_modules/@symbion/core/dist/templates/matchAuthorFolders.js.map +1 -0
  240. package/node_modules/@symbion/core/dist/templates/parseTemplate.d.ts +42 -0
  241. package/node_modules/@symbion/core/dist/templates/parseTemplate.d.ts.map +1 -0
  242. package/node_modules/@symbion/core/dist/templates/parseTemplate.js +56 -0
  243. package/node_modules/@symbion/core/dist/templates/parseTemplate.js.map +1 -0
  244. package/node_modules/@symbion/core/dist/templates/templateListItem.d.ts +39 -0
  245. package/node_modules/@symbion/core/dist/templates/templateListItem.d.ts.map +1 -0
  246. package/node_modules/@symbion/core/dist/templates/templateListItem.js +2 -0
  247. package/node_modules/@symbion/core/dist/templates/templateListItem.js.map +1 -0
  248. package/node_modules/@symbion/core/dist/util/sha256.d.ts +9 -0
  249. package/node_modules/@symbion/core/dist/util/sha256.d.ts.map +1 -0
  250. package/node_modules/@symbion/core/dist/util/sha256.js +91 -0
  251. package/node_modules/@symbion/core/dist/util/sha256.js.map +1 -0
  252. package/node_modules/@symbion/core/dist/version/semver.d.ts +18 -0
  253. package/node_modules/@symbion/core/dist/version/semver.d.ts.map +1 -0
  254. package/node_modules/@symbion/core/dist/version/semver.js +53 -0
  255. package/node_modules/@symbion/core/dist/version/semver.js.map +1 -0
  256. package/node_modules/@symbion/core/package.json +14 -0
  257. package/node_modules/@symbion/rpc-types/dist/index.d.ts +444 -0
  258. package/node_modules/@symbion/rpc-types/dist/index.d.ts.map +1 -0
  259. package/node_modules/@symbion/rpc-types/dist/index.js +2 -0
  260. package/node_modules/@symbion/rpc-types/dist/index.js.map +1 -0
  261. package/node_modules/@symbion/rpc-types/package.json +11 -0
  262. package/node_modules/yaml/dist/cli.d.ts +8 -0
  263. package/node_modules/yaml/dist/cli.mjs +201 -0
  264. package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
  265. package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
  266. package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
  267. package/node_modules/yaml/dist/compose/compose-doc.js +45 -0
  268. package/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
  269. package/node_modules/yaml/dist/compose/compose-node.js +112 -0
  270. package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
  271. package/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
  272. package/node_modules/yaml/dist/compose/composer.d.ts +63 -0
  273. package/node_modules/yaml/dist/compose/composer.js +224 -0
  274. package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
  275. package/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
  276. package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
  277. package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
  278. package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
  279. package/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
  280. package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
  281. package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
  282. package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
  283. package/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
  284. package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
  285. package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +227 -0
  286. package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
  287. package/node_modules/yaml/dist/compose/resolve-props.js +148 -0
  288. package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
  289. package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
  290. package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
  291. package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
  292. package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
  293. package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
  294. package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
  295. package/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
  296. package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
  297. package/node_modules/yaml/dist/doc/Document.js +337 -0
  298. package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
  299. package/node_modules/yaml/dist/doc/anchors.js +76 -0
  300. package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
  301. package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
  302. package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
  303. package/node_modules/yaml/dist/doc/createNode.js +90 -0
  304. package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
  305. package/node_modules/yaml/dist/doc/directives.js +178 -0
  306. package/node_modules/yaml/dist/errors.d.ts +21 -0
  307. package/node_modules/yaml/dist/errors.js +62 -0
  308. package/node_modules/yaml/dist/index.d.ts +25 -0
  309. package/node_modules/yaml/dist/index.js +50 -0
  310. package/node_modules/yaml/dist/log.d.ts +3 -0
  311. package/node_modules/yaml/dist/log.js +19 -0
  312. package/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
  313. package/node_modules/yaml/dist/nodes/Alias.js +118 -0
  314. package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
  315. package/node_modules/yaml/dist/nodes/Collection.js +151 -0
  316. package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
  317. package/node_modules/yaml/dist/nodes/Node.js +40 -0
  318. package/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
  319. package/node_modules/yaml/dist/nodes/Pair.js +39 -0
  320. package/node_modules/yaml/dist/nodes/Scalar.d.ts +47 -0
  321. package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
  322. package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
  323. package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
  324. package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
  325. package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
  326. package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
  327. package/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
  328. package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
  329. package/node_modules/yaml/dist/nodes/identity.js +53 -0
  330. package/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
  331. package/node_modules/yaml/dist/nodes/toJS.js +39 -0
  332. package/node_modules/yaml/dist/options.d.ts +350 -0
  333. package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
  334. package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
  335. package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
  336. package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
  337. package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
  338. package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
  339. package/node_modules/yaml/dist/parse/cst.d.ts +109 -0
  340. package/node_modules/yaml/dist/parse/cst.js +112 -0
  341. package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
  342. package/node_modules/yaml/dist/parse/lexer.js +723 -0
  343. package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
  344. package/node_modules/yaml/dist/parse/line-counter.js +41 -0
  345. package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
  346. package/node_modules/yaml/dist/parse/parser.js +980 -0
  347. package/node_modules/yaml/dist/public-api.d.ts +44 -0
  348. package/node_modules/yaml/dist/public-api.js +107 -0
  349. package/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
  350. package/node_modules/yaml/dist/schema/Schema.js +39 -0
  351. package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
  352. package/node_modules/yaml/dist/schema/common/map.js +19 -0
  353. package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
  354. package/node_modules/yaml/dist/schema/common/null.js +17 -0
  355. package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
  356. package/node_modules/yaml/dist/schema/common/seq.js +19 -0
  357. package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
  358. package/node_modules/yaml/dist/schema/common/string.js +16 -0
  359. package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
  360. package/node_modules/yaml/dist/schema/core/bool.js +21 -0
  361. package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
  362. package/node_modules/yaml/dist/schema/core/float.js +47 -0
  363. package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
  364. package/node_modules/yaml/dist/schema/core/int.js +42 -0
  365. package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
  366. package/node_modules/yaml/dist/schema/core/schema.js +25 -0
  367. package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
  368. package/node_modules/yaml/dist/schema/json/schema.js +64 -0
  369. package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
  370. package/node_modules/yaml/dist/schema/tags.d.ts +48 -0
  371. package/node_modules/yaml/dist/schema/tags.js +99 -0
  372. package/node_modules/yaml/dist/schema/types.d.ts +92 -0
  373. package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
  374. package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
  375. package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
  376. package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
  377. package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
  378. package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
  379. package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
  380. package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
  381. package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
  382. package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
  383. package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
  384. package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
  385. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
  386. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
  387. package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
  388. package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
  389. package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
  390. package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
  391. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
  392. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
  393. package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
  394. package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
  395. package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
  396. package/node_modules/yaml/dist/stringify/stringify.js +132 -0
  397. package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
  398. package/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
  399. package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
  400. package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
  401. package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
  402. package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
  403. package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
  404. package/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
  405. package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
  406. package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
  407. package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
  408. package/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
  409. package/node_modules/yaml/dist/test-events.d.ts +4 -0
  410. package/node_modules/yaml/dist/test-events.js +134 -0
  411. package/node_modules/yaml/dist/util.d.ts +16 -0
  412. package/node_modules/yaml/dist/util.js +28 -0
  413. package/node_modules/yaml/dist/visit.d.ts +102 -0
  414. package/node_modules/yaml/dist/visit.js +236 -0
  415. package/node_modules/yaml/package.json +20 -0
  416. package/node_modules/yaml/util.js +2 -0
  417. package/package.json +39 -0
@@ -0,0 +1,30 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { existsSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ /**
5
+ * gitStatus — read-only `git status --porcelain` (git is advisory in v1: status only,
6
+ * never commits/branches, per STATE §8 #4 / CLAUDE.md).
7
+ */
8
+ export function gitStatus(repoPath) {
9
+ const isRepo = existsSync(join(repoPath, ".git"));
10
+ if (!isRepo) {
11
+ return { isRepo: false, clean: true, changedFiles: [] };
12
+ }
13
+ try {
14
+ const out = execFileSync("git", ["status", "--porcelain"], {
15
+ cwd: repoPath,
16
+ encoding: "utf-8",
17
+ });
18
+ const changedFiles = out
19
+ .split("\n")
20
+ .map((l) => l.trim())
21
+ .filter((l) => l.length > 0)
22
+ .map((l) => l.slice(3));
23
+ return { isRepo: true, clean: changedFiles.length === 0, changedFiles };
24
+ }
25
+ catch {
26
+ // git binary missing or command failed — treat as non-repo (advisory, never blocks).
27
+ return { isRepo: false, clean: true, changedFiles: [] };
28
+ }
29
+ }
30
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/git/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAA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ync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { startServer } from "./server.js";
5
+ import { showBootMenu } from "./boot/menu.js";
6
+ import { loadGlobalConfig, saveGlobalConfig } from "./store/store.js";
7
+ import { findOpenPort } from "./net/findOpenPort.js";
8
+ const VERSION = process.env.SYMBION_VERSION ?? "0.1.0";
9
+ function findWebStaticRoot() {
10
+ // apps/daemon/dist/index.js -> ../../web/out (apps/web/out, the Next static export).
11
+ const here = dirname(fileURLToPath(import.meta.url));
12
+ const candidate = join(here, "..", "..", "web", "out");
13
+ return existsSync(candidate) ? candidate : undefined;
14
+ }
15
+ async function main() {
16
+ const config = loadGlobalConfig();
17
+ const webStaticRoot = findWebStaticRoot();
18
+ let handle;
19
+ let port;
20
+ try {
21
+ const found = await findOpenPort(config.port, (candidatePort) => startServer({ port: candidatePort, version: VERSION, webStaticRoot }));
22
+ port = found.port;
23
+ handle = found.handle;
24
+ }
25
+ catch (err) {
26
+ console.error("Không tìm được cổng trống cho daemon.", err);
27
+ process.exit(1);
28
+ return;
29
+ }
30
+ if (port !== config.port) {
31
+ config.port = port;
32
+ saveGlobalConfig(config);
33
+ }
34
+ const url = `http://127.0.0.1:${handle.port}/?t=${handle.token}`;
35
+ console.log(`Symbion v${VERSION}`);
36
+ console.log(`Symbion daemon đang chạy: ${url}`);
37
+ let running = true;
38
+ while (running) {
39
+ const choice = await showBootMenu(url);
40
+ if (choice === "web") {
41
+ console.log(`Mở: ${url}`);
42
+ // best-effort open in default browser; not critical-path for headless/CI runs.
43
+ try {
44
+ const open = await import("node:child_process");
45
+ const platform = process.platform;
46
+ const cmd = platform === "darwin" ? "open" : platform === "win32" ? "start" : "xdg-open";
47
+ open.exec(`${cmd} "${url}"`);
48
+ }
49
+ catch {
50
+ // ignore — user can open the URL manually
51
+ }
52
+ }
53
+ else if (choice === "tray") {
54
+ console.log("Đã chuyển sang chạy nền (Hide to Tray). Server vẫn đang chạy.");
55
+ running = false; // detach menu loop; process keeps running via the HTTP server
56
+ }
57
+ else if (choice === "exit") {
58
+ console.log("Đang tắt daemon...");
59
+ await handle.close();
60
+ running = false;
61
+ process.exit(0);
62
+ }
63
+ }
64
+ }
65
+ main().catch((err) => {
66
+ console.error(err);
67
+ process.exit(1);
68
+ });
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,WAAW,EAA2B,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,OAAO,CAAC;AAEvD,SAAS,iBAAiB;IACxB,qFAAqF;IACrF,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACvD,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;IAClC,MAAM,aAAa,GAAG,iBAAiB,EAAE,CAAC;IAE1C,IAAI,MAA0B,CAAC;IAC/B,IAAI,IAAY,C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QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC;gBACzF,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC;YAC/B,CAAC;YAAC,MAAM,CAAC;gBACP,0CAA0C;YAC5C,CAAC;QACH,CAAC;aAAM,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAC;YAC7E,OAAO,GAAG,KAAK,CAAC,CAAC,8DAA8D;QACjF,CAAC;aAAM,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;YAClC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;YACrB,OAAO,GAAG,KAAK,CAAC;YAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * AnthropicProvider — renamed from RemoteProvider per
3
+ * docs/loops/multi-provider-settings-STATE.md §3.1: it already speaks the
4
+ * Anthropic Messages API shape (`x-api-key` header, `anthropic-version`,
5
+ * `/v1/messages` body shape, Claude model ids), so this is a rename + a
6
+ * change in key source (secrets.ts instead of process.env), not new business
7
+ * logic — the HTTP call shape is unchanged.
8
+ *
9
+ * The API key is read from the secrets store (apps/daemon/src/llm/secrets.ts)
10
+ * at construction time — never persisted by this class, never accepted as a
11
+ * request param, never read from apps/web. If unset, generate() throws
12
+ * LlmError("not-configured", ...) immediately, with NO network call attempted.
13
+ */
14
+ import { type LlmGenerateRequest, type LlmGenerateResult, type LlmModelOption, type LlmProvider } from "./types.js";
15
+ export interface AnthropicProviderOptions {
16
+ /** injectable for tests; defaults to the real Anthropic Messages endpoint. */
17
+ baseUrl?: string;
18
+ }
19
+ export declare class AnthropicProvider implements LlmProvider {
20
+ readonly id: "anthropic";
21
+ private readonly baseUrl;
22
+ constructor(opts?: AnthropicProviderOptions);
23
+ listModels(): Promise<LlmModelOption[]>;
24
+ generate(req: LlmGenerateRequest): Promise<LlmGenerateResult>;
25
+ }
26
+ //# sourceMappingURL=anthropicProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropicProvider.d.ts","sourceRoot":"","sources":["../../src/llm/anthropicProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAY,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAW9H,MAAM,WAAW,wBAAwB;IACvC,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,iBAAkB,YAAW,WAAW;IACnD,QAAQ,CAAC,EAAE,EAAG,WAAW,CAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,IAAI,GAAE,wBAA6B;IAIzC,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAIvC,QAAQ,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA6DpE"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * AnthropicProvider — renamed from RemoteProvider per
3
+ * docs/loops/multi-provider-settings-STATE.md §3.1: it already speaks the
4
+ * Anthropic Messages API shape (`x-api-key` header, `anthropic-version`,
5
+ * `/v1/messages` body shape, Claude model ids), so this is a rename + a
6
+ * change in key source (secrets.ts instead of process.env), not new business
7
+ * logic — the HTTP call shape is unchanged.
8
+ *
9
+ * The API key is read from the secrets store (apps/daemon/src/llm/secrets.ts)
10
+ * at construction time — never persisted by this class, never accepted as a
11
+ * request param, never read from apps/web. If unset, generate() throws
12
+ * LlmError("not-configured", ...) immediately, with NO network call attempted.
13
+ */
14
+ import { LlmError } from "./types.js";
15
+ import { loadProvidersConfig } from "./secrets.js";
16
+ const ANTHROPIC_DEFAULT_BASE_URL = "https://api.anthropic.com/v1/messages";
17
+ const ANTHROPIC_MODELS = [
18
+ { id: "claude-haiku-4-5", label: "Claude Haiku 4.5 (nhanh)", tier: "fast" },
19
+ { id: "claude-sonnet-4-5", label: "Claude Sonnet 4.5 (cân bằng)", tier: "balanced" },
20
+ { id: "claude-opus-4-1", label: "Claude Opus 4.1 (tốt nhất)", tier: "best" },
21
+ ];
22
+ export class AnthropicProvider {
23
+ id = "anthropic";
24
+ baseUrl;
25
+ constructor(opts = {}) {
26
+ this.baseUrl = opts.baseUrl ?? ANTHROPIC_DEFAULT_BASE_URL;
27
+ }
28
+ async listModels() {
29
+ return ANTHROPIC_MODELS;
30
+ }
31
+ async generate(req) {
32
+ const apiKey = loadProvidersConfig().providers.anthropic?.apiKey;
33
+ if (!apiKey) {
34
+ throw new LlmError("not-configured", "Chưa cấu hình API key cho Anthropic.");
35
+ }
36
+ const controller = new AbortController();
37
+ const timer = setTimeout(() => controller.abort(), req.timeoutMs);
38
+ try {
39
+ let res;
40
+ try {
41
+ res = await fetch(this.baseUrl, {
42
+ method: "POST",
43
+ headers: {
44
+ "Content-Type": "application/json",
45
+ "x-api-key": apiKey,
46
+ "anthropic-version": "2023-06-01",
47
+ },
48
+ body: JSON.stringify({
49
+ model: req.model,
50
+ system: req.systemPrompt,
51
+ max_tokens: req.maxTokens ?? 4096,
52
+ messages: [{ role: "user", content: req.userPrompt }],
53
+ }),
54
+ signal: controller.signal,
55
+ });
56
+ }
57
+ catch {
58
+ if (controller.signal.aborted) {
59
+ throw new LlmError("timeout", `Quá thời gian chờ (${req.timeoutMs}ms) khi gọi Anthropic.`);
60
+ }
61
+ throw new LlmError("network", "Lỗi mạng khi gọi Anthropic.");
62
+ }
63
+ if (res.status === 401 || res.status === 403) {
64
+ throw new LlmError("auth", "Thiếu hoặc sai cấu hình API key cho Anthropic.");
65
+ }
66
+ if (res.status === 429) {
67
+ throw new LlmError("rate-limit", "Bị giới hạn tần suất gọi — thử lại sau.");
68
+ }
69
+ if (!res.ok) {
70
+ throw new LlmError("invalid-response", `Anthropic trả về lỗi HTTP ${res.status}.`);
71
+ }
72
+ let json;
73
+ try {
74
+ json = (await res.json());
75
+ }
76
+ catch {
77
+ throw new LlmError("invalid-response", "Phản hồi không hợp lệ từ Anthropic (không phải JSON).");
78
+ }
79
+ const text = json.content?.[0]?.text;
80
+ if (typeof text !== "string") {
81
+ throw new LlmError("invalid-response", "Phản hồi không hợp lệ từ Anthropic.");
82
+ }
83
+ return { text };
84
+ }
85
+ finally {
86
+ clearTimeout(timer);
87
+ }
88
+ }
89
+ }
90
+ //# sourceMappingURL=anthropicProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropicProvider.js","sourceRoot":"","sources":["../../src/llm/anthropicProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,QAAQ,EAA0F,MAAM,YAAY,CAAC;AAC9H,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,0BAA0B,GAAG,uCAAuC,CAAC;AAE3E,MAAM,gBAAgB,GAAqB;IACzC,EAAE,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,0BAA0B,EAAE,IAAI,EAAE,MAAM,EAAE;IAC3E,EAAE,EAAE,EAAE,mBAAmB,EAAE,KAAK,EAAE,8BAA8B,EAAE,IAAI,EAAE,UAAU,EAAE;IACpF,EAAE,EAAE,EAAE,iBAAiB,EAAE,KAAK,EAAE,4BAA4B,EAAE,IAAI,EAAE,MAAM,EAAE;CAC7E,C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AC,CAAC;QACtB,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * GeminiProvider — LlmProvider implementation for Google Gemini, per
3
+ * docs/loops/multi-provider-settings-STATE.md §3.2. Reads its API key from
4
+ * the secrets store (apps/daemon/src/llm/secrets.ts) at construction time —
5
+ * never from process.env, never persisted by this class. Calls Gemini's
6
+ * documented simple-API-key `generateContent` REST endpoint with a `?key=`
7
+ * query param (no OAuth) — dev's call on exact endpoint per STATE §3.2.
8
+ *
9
+ * Model ids below are placeholder/dev-time content decisions (same framing
10
+ * as ollamaProvider.ts's model list) — Checker should independently verify
11
+ * these are reasonable current Gemini model ids at review time.
12
+ */
13
+ import { type LlmGenerateRequest, type LlmGenerateResult, type LlmModelOption, type LlmProvider } from "./types.js";
14
+ export interface GeminiProviderOptions {
15
+ /** injectable for tests; defaults to the real Gemini generateContent endpoint base. */
16
+ baseUrl?: string;
17
+ }
18
+ export declare class GeminiProvider implements LlmProvider {
19
+ readonly id: "gemini";
20
+ private readonly baseUrl;
21
+ constructor(opts?: GeminiProviderOptions);
22
+ listModels(): Promise<LlmModelOption[]>;
23
+ generate(req: LlmGenerateRequest): Promise<LlmGenerateResult>;
24
+ }
25
+ //# sourceMappingURL=geminiProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geminiProvider.d.ts","sourceRoot":"","sources":["../../src/llm/geminiProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAY,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAW9H,MAAM,WAAW,qBAAqB;IACpC,uFAAuF;IACvF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,cAAe,YAAW,WAAW;IAChD,QAAQ,CAAC,EAAE,EAAG,QAAQ,CAAU;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,IAAI,GAAE,qBAA0B;IAItC,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAIvC,QAAQ,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA+DpE"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * GeminiProvider — LlmProvider implementation for Google Gemini, per
3
+ * docs/loops/multi-provider-settings-STATE.md §3.2. Reads its API key from
4
+ * the secrets store (apps/daemon/src/llm/secrets.ts) at construction time —
5
+ * never from process.env, never persisted by this class. Calls Gemini's
6
+ * documented simple-API-key `generateContent` REST endpoint with a `?key=`
7
+ * query param (no OAuth) — dev's call on exact endpoint per STATE §3.2.
8
+ *
9
+ * Model ids below are placeholder/dev-time content decisions (same framing
10
+ * as ollamaProvider.ts's model list) — Checker should independently verify
11
+ * these are reasonable current Gemini model ids at review time.
12
+ */
13
+ import { LlmError } from "./types.js";
14
+ import { loadProvidersConfig } from "./secrets.js";
15
+ const GEMINI_DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/models";
16
+ const GEMINI_MODELS = [
17
+ { id: "gemini-1.5-flash", label: "Gemini 1.5 Flash (nhanh)", tier: "fast" },
18
+ { id: "gemini-1.5-pro", label: "Gemini 1.5 Pro (cân bằng)", tier: "balanced" },
19
+ { id: "gemini-2.0-pro", label: "Gemini 2.0 Pro (tốt nhất)", tier: "best" },
20
+ ];
21
+ export class GeminiProvider {
22
+ id = "gemini";
23
+ baseUrl;
24
+ constructor(opts = {}) {
25
+ this.baseUrl = opts.baseUrl ?? GEMINI_DEFAULT_BASE_URL;
26
+ }
27
+ async listModels() {
28
+ return GEMINI_MODELS;
29
+ }
30
+ async generate(req) {
31
+ const apiKey = loadProvidersConfig().providers.gemini?.apiKey;
32
+ if (!apiKey) {
33
+ throw new LlmError("not-configured", "Chưa cấu hình API key cho Gemini.");
34
+ }
35
+ const controller = new AbortController();
36
+ const timer = setTimeout(() => controller.abort(), req.timeoutMs);
37
+ try {
38
+ // Key in the query string is Gemini's documented simple-API-key auth shape — not a
39
+ // Symbion choice, the vendor's own published REST contract.
40
+ const url = `${this.baseUrl}/${encodeURIComponent(req.model)}:generateContent?key=${encodeURIComponent(apiKey)}`;
41
+ let res;
42
+ try {
43
+ res = await fetch(url, {
44
+ method: "POST",
45
+ headers: { "Content-Type": "application/json" },
46
+ body: JSON.stringify({
47
+ systemInstruction: { parts: [{ text: req.systemPrompt }] },
48
+ contents: [{ role: "user", parts: [{ text: req.userPrompt }] }],
49
+ ...(req.maxTokens != null
50
+ ? { generationConfig: { maxOutputTokens: req.maxTokens } }
51
+ : {}),
52
+ }),
53
+ signal: controller.signal,
54
+ });
55
+ }
56
+ catch {
57
+ if (controller.signal.aborted) {
58
+ throw new LlmError("timeout", `Quá thời gian chờ (${req.timeoutMs}ms) khi gọi Gemini.`);
59
+ }
60
+ throw new LlmError("network", "Lỗi mạng khi gọi Gemini.");
61
+ }
62
+ if (res.status === 401 || res.status === 403) {
63
+ throw new LlmError("auth", "Thiếu hoặc sai cấu hình API key cho Gemini.");
64
+ }
65
+ if (res.status === 429) {
66
+ throw new LlmError("rate-limit", "Bị giới hạn tần suất gọi — thử lại sau.");
67
+ }
68
+ if (!res.ok) {
69
+ throw new LlmError("invalid-response", `Gemini trả về lỗi HTTP ${res.status}.`);
70
+ }
71
+ let json;
72
+ try {
73
+ json = (await res.json());
74
+ }
75
+ catch {
76
+ throw new LlmError("invalid-response", "Phản hồi không hợp lệ từ Gemini (không phải JSON).");
77
+ }
78
+ const text = json.candidates?.[0]?.content?.parts?.[0]?.text;
79
+ if (typeof text !== "string") {
80
+ throw new LlmError("invalid-response", "Phản hồi không hợp lệ từ Gemini.");
81
+ }
82
+ return { text };
83
+ }
84
+ finally {
85
+ clearTimeout(timer);
86
+ }
87
+ }
88
+ }
89
+ //# sourceMappingURL=geminiProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geminiProvider.js","sourceRoot":"","sources":["../../src/llm/geminiProvider.ts"],"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,GAAG,EAAE,CAAC;gBACvB,MAAM,IAAI,QAAQ,CAAC,YAAY,EAAE,yCAAyC,CAAC,CAAC;YAC9E,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;gBACZ,MAAM,IAAI,QAAQ,CAAC,kBAAkB,EAAE,0BAA0B,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;YAClF,CAAC;YAED,IAAI,IAAgF,CAAC;YACrF,IAAI,CAAC;gBACH,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAEvB,CAAC;YACJ,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,IAAI,QAAQ,CAAC,kBAAkB,EAAE,oDAAoD,CAAC,CAAC;YAC/F,CAAC;YAED,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;YAC7D,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC7B,MAAM,IAAI,QAAQ,CAAC,kBAAkB,EAAE,kCAAkC,CAAC,CAAC;YAC7E,CAAC;YAED,OAAO,EAAE,IAAI,EAAE,CAAC;QAClB,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,40 @@
1
+ export interface HostEnvironment {
2
+ /** what the daemon believes its own host environment is, for install-command selection (EC-3). */
3
+ kind: "wsl" | "linux" | "macos" | "windows" | "unknown";
4
+ /** short human label shown verbatim in the panel's "phát hiện: …" line. */
5
+ label: string;
6
+ }
7
+ export interface InstallInstructions {
8
+ env: HostEnvironment;
9
+ /** true only when detection is confident enough to show ONE command block. */
10
+ confident: boolean;
11
+ /** one entry per OS variant to show. Length 1 when confident===true; length 4 (all
12
+ * known variants, labeled) when confident===false, per the design doc's default
13
+ * "(b) stacked labeled sections" fallback. */
14
+ variants: Array<{
15
+ label: string;
16
+ command: string;
17
+ }>;
18
+ }
19
+ /**
20
+ * detectHostEnvironment — total function: every `process.platform` value Node can
21
+ * report resolves to a well-formed `HostEnvironment`, never throws. `kind: "unknown"`
22
+ * is the explicit escape hatch for non-mainstream platforms (e.g. freebsd) — this never
23
+ * happens for the 4 platforms Symbion is documented to run on.
24
+ *
25
+ * WSL detection: WSL's kernel release string contains "microsoft" or "wsl"
26
+ * (case-insensitive) — e.g. "5.15.90.1-microsoft-standard-WSL2" or
27
+ * "6.6.87.2-microsoft-standard-WSL2" (this exact session's own env, per EC-3's
28
+ * must-not-mishandle case). This is the same heuristic the `is-wsl` npm package and
29
+ * most Node tooling already use — no /proc read needed since `os.release()` already
30
+ * exposes the `uname -r` string.
31
+ */
32
+ export declare function detectHostEnvironment(): HostEnvironment;
33
+ /**
34
+ * getOllamaInstallInstructions — `confident: true` (`kind !== "unknown"`) returns exactly
35
+ * 1 variant matching the detected OS. `confident: false` (`kind === "unknown"`) returns
36
+ * all 4 known variants, labeled, per the design doc's Open Question 2 default
37
+ * "(b) stacked labeled sections" — never silently guesses wrong.
38
+ */
39
+ export declare function getOllamaInstallInstructions(env: HostEnvironment): InstallInstructions;
40
+ //# sourceMappingURL=installInstructions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installInstructions.d.ts","sourceRoot":"","sources":["../../src/llm/installInstructions.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,eAAe;IAC9B,kGAAkG;IAClG,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IACxD,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,eAAe,CAAC;IACrB,8EAA8E;IAC9E,SAAS,EAAE,OAAO,CAAC;IACnB;;mDAE+C;IAC/C,QAAQ,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrD;AAOD;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CAYvD;AA2BD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,eAAe,GAAG,mBAAmB,CAKtF"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * installInstructions — pure OS detection + static install-command lookup table for the
3
+ * Ollama "connect provider" guided-setup panel (docs/loops/connect-providers-STATE.md
4
+ * §10.4). No fs-write, no network, no fs-read even — only `process.platform` (set at
5
+ * Node-process-launch time by the OS the daemon binary itself runs on) and
6
+ * `node:os`'s `release()` (kernel `uname -r` string, used for the WSL heuristic).
7
+ *
8
+ * Pure-data + pure-function shape on purpose: trivially unit-testable without mocking
9
+ * fs/network (Tier B in connect-providers-testplan.md §1), and must be a TOTAL function —
10
+ * every `NodeJS.Platform` value Node can report must produce a well-formed
11
+ * `HostEnvironment`, never throw.
12
+ */
13
+ import { release } from "node:os";
14
+ const UNIX_CURL_INSTALL_COMMAND = "curl -fsSL https://ollama.com/install.sh | sh && ollama serve";
15
+ const MACOS_BREW_INSTALL_COMMAND = "brew install ollama && ollama serve";
16
+ const WINDOWS_INSTALL_GUIDANCE = "Tải và chạy trình cài đặt tại https://ollama.com/download/windows, sau đó mở Ollama từ Start Menu.";
17
+ /**
18
+ * detectHostEnvironment — total function: every `process.platform` value Node can
19
+ * report resolves to a well-formed `HostEnvironment`, never throws. `kind: "unknown"`
20
+ * is the explicit escape hatch for non-mainstream platforms (e.g. freebsd) — this never
21
+ * happens for the 4 platforms Symbion is documented to run on.
22
+ *
23
+ * WSL detection: WSL's kernel release string contains "microsoft" or "wsl"
24
+ * (case-insensitive) — e.g. "5.15.90.1-microsoft-standard-WSL2" or
25
+ * "6.6.87.2-microsoft-standard-WSL2" (this exact session's own env, per EC-3's
26
+ * must-not-mishandle case). This is the same heuristic the `is-wsl` npm package and
27
+ * most Node tooling already use — no /proc read needed since `os.release()` already
28
+ * exposes the `uname -r` string.
29
+ */
30
+ export function detectHostEnvironment() {
31
+ const plat = process.platform;
32
+ if (plat === "darwin")
33
+ return { kind: "macos", label: "macOS" };
34
+ if (plat === "win32")
35
+ return { kind: "windows", label: "Windows" };
36
+ if (plat === "linux") {
37
+ const rel = release().toLowerCase();
38
+ if (rel.includes("microsoft") || rel.includes("wsl")) {
39
+ return { kind: "wsl", label: "WSL2 (Ubuntu trên Windows)" };
40
+ }
41
+ return { kind: "linux", label: "Linux" };
42
+ }
43
+ return { kind: "unknown", label: "Không xác định" };
44
+ }
45
+ /** All 4 known variants, labeled — shown together when detection is not confident. */
46
+ function allKnownVariants() {
47
+ return [
48
+ { label: "macOS", command: MACOS_BREW_INSTALL_COMMAND },
49
+ { label: "Linux", command: UNIX_CURL_INSTALL_COMMAND },
50
+ { label: "WSL2 (Ubuntu trên Windows)", command: UNIX_CURL_INSTALL_COMMAND },
51
+ { label: "Windows", command: WINDOWS_INSTALL_GUIDANCE },
52
+ ];
53
+ }
54
+ function commandForKind(kind) {
55
+ switch (kind) {
56
+ case "macos":
57
+ return MACOS_BREW_INSTALL_COMMAND;
58
+ case "linux":
59
+ case "wsl":
60
+ return UNIX_CURL_INSTALL_COMMAND;
61
+ case "windows":
62
+ return WINDOWS_INSTALL_GUIDANCE;
63
+ case "unknown":
64
+ default:
65
+ return UNIX_CURL_INSTALL_COMMAND;
66
+ }
67
+ }
68
+ /**
69
+ * getOllamaInstallInstructions — `confident: true` (`kind !== "unknown"`) returns exactly
70
+ * 1 variant matching the detected OS. `confident: false` (`kind === "unknown"`) returns
71
+ * all 4 known variants, labeled, per the design doc's Open Question 2 default
72
+ * "(b) stacked labeled sections" — never silently guesses wrong.
73
+ */
74
+ export function getOllamaInstallInstructions(env) {
75
+ if (env.kind === "unknown") {
76
+ return { env, confident: false, variants: allKnownVariants() };
77
+ }
78
+ return { env, confident: true, variants: [{ label: env.label, command: commandForKind(env.kind) }] };
79
+ }
80
+ //# sourceMappingURL=installInstructions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installInstructions.js","sourceRoot":"","sources":["../../src/llm/installInstructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAmBlC,MAAM,yBAAyB,GAAG,+DAA+D,CAAC;AAClG,MAAM,0BAA0B,GAAG,qCAAqC,CAAC;AACzE,MAAM,wBAAwB,GAC5B,oGAAoG,CAAC;AAEvG;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC;IAC9B,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAChE,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IACnE,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACrB,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC;QACpC,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACrD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,4BAA4B,EAAE,CAAC;QAC9D,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAC3C,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC;AACtD,CAAC;AAED,sFAAsF;AACtF,SAAS,gBAAgB;IACvB,OAAO;QACL,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,0BAA0B,EAAE;QACvD,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,yBAAyB,EAAE;QACtD,EAAE,KAAK,EAAE,4BAA4B,EAAE,OAAO,EAAE,yBAAyB,EAAE;QAC3E,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,wBAAwB,EAAE;KACxD,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,IAA6B;IACnD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,OAAO;YACV,OAAO,0BAA0B,CAAC;QACpC,KAAK,OAAO,CAAC;QACb,KAAK,KAAK;YACR,OAAO,yBAAyB,CAAC;QACnC,KAAK,SAAS;YACZ,OAAO,wBAAwB,CAAC;QAClC,KAAK,SAAS,CAAC;QACf;YACE,OAAO,yBAAyB,CAAC;IACrC,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,GAAoB;IAC/D,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,EAAE,CAAC;IACjE,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;AACvG,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * OllamaProvider — calls a local Ollama instance over HTTP using Node's native
3
+ * fetch + AbortController. No API key. The v1 default provider (STATE §9).
4
+ *
5
+ * listModels() queries the real local Ollama's `GET /api/tags` per
6
+ * docs/loops/ollama-dynamic-models-STATE.md §6.2 — the old hardcoded 3-entry
7
+ * placeholder constant has been removed entirely (no fallback to it on any
8
+ * failure path, per that STATE's §3 "never silently fail" constraint).
9
+ */
10
+ import { type LlmGenerateRequest, type LlmGenerateResult, type LlmModelOption, type LlmProvider } from "./types.js";
11
+ export declare const OLLAMA_DEFAULT_BASE_URL = "http://127.0.0.1:11434";
12
+ export interface OllamaProviderOptions {
13
+ /** injectable for tests (Tier A fake-provider, per testplan §0); defaults to the real local Ollama. */
14
+ baseUrl?: string;
15
+ }
16
+ /**
17
+ * resolveOllamaBaseUrl — the env-var/loopback-guard/default resolution logic that used to
18
+ * live inline in `OllamaProvider`'s constructor (extracted per
19
+ * docs/loops/connect-providers-STATE.md §10.3, a structure-only refactor, no behavior
20
+ * change). Exported so `providerStatus.ts`'s reachability check reuses the exact same
21
+ * SSRF-guarded resolution instead of re-implementing it — one implementation, not two.
22
+ *
23
+ * Throws `LlmError("provider-not-running", ...)` if `SYMBION_OLLAMA_BASE_URL` is set to a
24
+ * non-loopback host (see `isLoopbackUrl` doc comment for the threat this guards against).
25
+ */
26
+ export declare function resolveOllamaBaseUrl(): string;
27
+ export declare class OllamaProvider implements LlmProvider {
28
+ readonly id: "ollama";
29
+ private readonly baseUrl;
30
+ constructor(opts?: OllamaProviderOptions);
31
+ /**
32
+ * listModels — queries Ollama's real `GET /api/tags` (per
33
+ * docs/loops/ollama-dynamic-models-STATE.md §6.2), bounded by a 3000ms
34
+ * AbortController timeout (same convention as `checkOllamaReachable`). Uses
35
+ * `this.baseUrl`, already resolved through the SAME loopback-guarded
36
+ * `resolveOllamaBaseUrl()` the constructor uses — no second SSRF-guard
37
+ * implementation.
38
+ *
39
+ * Error mapping:
40
+ * - connection-refused / DNS failure / our own abort-on-timeout all collapse to
41
+ * `LlmError("provider-not-running", ...)` — both mean "ModelPicker cannot get a
42
+ * model list from Ollama right now," and AC4 only requires the existing
43
+ * "unreachable" shape be unregressed, not a distinct timeout code (STATE §9.1).
44
+ * - non-2xx HTTP status -> `LlmError("invalid-response", ...)`.
45
+ * - non-JSON body -> `LlmError("invalid-response", ...)`.
46
+ * - missing/wrong-type `models` field on an otherwise-200 response ->
47
+ * `LlmError("invalid-response", ...)` — distinct from "genuinely zero models,"
48
+ * which is a well-formed `{ models: [] }` that resolves normally (empty array,
49
+ * no throw) per STATE §3's "never silently fail ... not an empty array
50
+ * indistinguishable from genuinely zero" constraint.
51
+ */
52
+ listModels(): Promise<LlmModelOption[]>;
53
+ generate(req: LlmGenerateRequest): Promise<LlmGenerateResult>;
54
+ }
55
+ //# sourceMappingURL=ollamaProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ollamaProvider.d.ts","sourceRoot":"","sources":["../../src/llm/ollamaProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAY,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9H,eAAO,MAAM,uBAAuB,2BAA2B,CAAC;AA2ChE,MAAM,WAAW,qBAAqB;IACpC,uGAAuG;IACvG,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA0BD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAmB7C;AAED,qBAAa,cAAe,YAAW,WAAW;IAChD,QAAQ,CAAC,EAAE,EAAG,QAAQ,CAAU;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,IAAI,GAAE,qBAA0B;IAY5C;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAwCvC,QAAQ,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA2EpE"}