@dirgha/code 1.2.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 (360) hide show
  1. package/LICENSE +101 -0
  2. package/README.md +674 -0
  3. package/dist/dirgha.mjs +2185 -0
  4. package/dist_v2/acp/index.d.ts +1 -0
  5. package/dist_v2/acp/index.js +2 -0
  6. package/dist_v2/acp/server.d.ts +31 -0
  7. package/dist_v2/acp/server.js +137 -0
  8. package/dist_v2/cli/auth-cmd.d.ts +10 -0
  9. package/dist_v2/cli/auth-cmd.js +69 -0
  10. package/dist_v2/cli/config.d.ts +46 -0
  11. package/dist_v2/cli/config.js +70 -0
  12. package/dist_v2/cli/flags.d.ts +10 -0
  13. package/dist_v2/cli/flags.js +49 -0
  14. package/dist_v2/cli/flows/full-cycle.d.ts +30 -0
  15. package/dist_v2/cli/flows/full-cycle.js +39 -0
  16. package/dist_v2/cli/flows/index.d.ts +2 -0
  17. package/dist_v2/cli/flows/index.js +3 -0
  18. package/dist_v2/cli/flows/tarball.d.ts +10 -0
  19. package/dist_v2/cli/flows/tarball.js +47 -0
  20. package/dist_v2/cli/index.d.ts +4 -0
  21. package/dist_v2/cli/index.js +5 -0
  22. package/dist_v2/cli/interactive.d.ts +21 -0
  23. package/dist_v2/cli/interactive.js +207 -0
  24. package/dist_v2/cli/main.d.ts +10 -0
  25. package/dist_v2/cli/main.js +173 -0
  26. package/dist_v2/cli/models-cmd.d.ts +6 -0
  27. package/dist_v2/cli/models-cmd.js +50 -0
  28. package/dist_v2/cli/setup.d.ts +13 -0
  29. package/dist_v2/cli/setup.js +128 -0
  30. package/dist_v2/cli/slash/account.d.ts +10 -0
  31. package/dist_v2/cli/slash/account.js +59 -0
  32. package/dist_v2/cli/slash/clear.d.ts +8 -0
  33. package/dist_v2/cli/slash/clear.js +15 -0
  34. package/dist_v2/cli/slash/compact.d.ts +7 -0
  35. package/dist_v2/cli/slash/compact.js +13 -0
  36. package/dist_v2/cli/slash/config.d.ts +8 -0
  37. package/dist_v2/cli/slash/config.js +49 -0
  38. package/dist_v2/cli/slash/exit.d.ts +7 -0
  39. package/dist_v2/cli/slash/exit.js +16 -0
  40. package/dist_v2/cli/slash/fleet.d.ts +7 -0
  41. package/dist_v2/cli/slash/fleet.js +22 -0
  42. package/dist_v2/cli/slash/help.d.ts +9 -0
  43. package/dist_v2/cli/slash/help.js +31 -0
  44. package/dist_v2/cli/slash/history.d.ts +7 -0
  45. package/dist_v2/cli/slash/history.js +42 -0
  46. package/dist_v2/cli/slash/index.d.ts +30 -0
  47. package/dist_v2/cli/slash/index.js +52 -0
  48. package/dist_v2/cli/slash/init.d.ts +8 -0
  49. package/dist_v2/cli/slash/init.js +57 -0
  50. package/dist_v2/cli/slash/keys.d.ts +8 -0
  51. package/dist_v2/cli/slash/keys.js +101 -0
  52. package/dist_v2/cli/slash/login.d.ts +10 -0
  53. package/dist_v2/cli/slash/login.js +47 -0
  54. package/dist_v2/cli/slash/memory.d.ts +8 -0
  55. package/dist_v2/cli/slash/memory.js +101 -0
  56. package/dist_v2/cli/slash/mode.d.ts +8 -0
  57. package/dist_v2/cli/slash/mode.js +30 -0
  58. package/dist_v2/cli/slash/models.d.ts +8 -0
  59. package/dist_v2/cli/slash/models.js +73 -0
  60. package/dist_v2/cli/slash/resume.d.ts +8 -0
  61. package/dist_v2/cli/slash/resume.js +24 -0
  62. package/dist_v2/cli/slash/session.d.ts +8 -0
  63. package/dist_v2/cli/slash/session.js +74 -0
  64. package/dist_v2/cli/slash/setup.d.ts +8 -0
  65. package/dist_v2/cli/slash/setup.js +50 -0
  66. package/dist_v2/cli/slash/status.d.ts +7 -0
  67. package/dist_v2/cli/slash/status.js +37 -0
  68. package/dist_v2/cli/slash/theme.d.ts +9 -0
  69. package/dist_v2/cli/slash/theme.js +53 -0
  70. package/dist_v2/cli/slash/types.d.ts +14 -0
  71. package/dist_v2/cli/slash/types.js +9 -0
  72. package/dist_v2/cli/slash/upgrade.d.ts +9 -0
  73. package/dist_v2/cli/slash/upgrade.js +66 -0
  74. package/dist_v2/cli/slash.d.ts +72 -0
  75. package/dist_v2/cli/slash.js +77 -0
  76. package/dist_v2/cli/subcommands/ask.d.ts +17 -0
  77. package/dist_v2/cli/subcommands/ask.js +76 -0
  78. package/dist_v2/cli/subcommands/audit.d.ts +15 -0
  79. package/dist_v2/cli/subcommands/audit.js +128 -0
  80. package/dist_v2/cli/subcommands/chat.d.ts +13 -0
  81. package/dist_v2/cli/subcommands/chat.js +72 -0
  82. package/dist_v2/cli/subcommands/compact.d.ts +14 -0
  83. package/dist_v2/cli/subcommands/compact.js +114 -0
  84. package/dist_v2/cli/subcommands/doctor.d.ts +11 -0
  85. package/dist_v2/cli/subcommands/doctor.js +103 -0
  86. package/dist_v2/cli/subcommands/export-session.d.ts +10 -0
  87. package/dist_v2/cli/subcommands/export-session.js +60 -0
  88. package/dist_v2/cli/subcommands/import-session.d.ts +11 -0
  89. package/dist_v2/cli/subcommands/import-session.js +77 -0
  90. package/dist_v2/cli/subcommands/index.d.ts +40 -0
  91. package/dist_v2/cli/subcommands/index.js +38 -0
  92. package/dist_v2/cli/subcommands/init.d.ts +10 -0
  93. package/dist_v2/cli/subcommands/init.js +74 -0
  94. package/dist_v2/cli/subcommands/keys.d.ts +12 -0
  95. package/dist_v2/cli/subcommands/keys.js +136 -0
  96. package/dist_v2/cli/subcommands/login.d.ts +10 -0
  97. package/dist_v2/cli/subcommands/login.js +60 -0
  98. package/dist_v2/cli/subcommands/logout.d.ts +10 -0
  99. package/dist_v2/cli/subcommands/logout.js +21 -0
  100. package/dist_v2/cli/subcommands/models.d.ts +14 -0
  101. package/dist_v2/cli/subcommands/models.js +144 -0
  102. package/dist_v2/cli/subcommands/setup.d.ts +11 -0
  103. package/dist_v2/cli/subcommands/setup.js +107 -0
  104. package/dist_v2/cli/subcommands/stats.d.ts +13 -0
  105. package/dist_v2/cli/subcommands/stats.js +148 -0
  106. package/dist_v2/cli/subcommands/status.d.ts +14 -0
  107. package/dist_v2/cli/subcommands/status.js +91 -0
  108. package/dist_v2/cli/submit-paper.d.ts +15 -0
  109. package/dist_v2/cli/submit-paper.js +68 -0
  110. package/dist_v2/context/_fts.d.ts +62 -0
  111. package/dist_v2/context/_fts.js +195 -0
  112. package/dist_v2/context/branch.d.ts +18 -0
  113. package/dist_v2/context/branch.js +66 -0
  114. package/dist_v2/context/compaction.d.ts +26 -0
  115. package/dist_v2/context/compaction.js +120 -0
  116. package/dist_v2/context/index.d.ts +5 -0
  117. package/dist_v2/context/index.js +6 -0
  118. package/dist_v2/context/knowledge.d.ts +38 -0
  119. package/dist_v2/context/knowledge.js +146 -0
  120. package/dist_v2/context/memory.d.ts +80 -0
  121. package/dist_v2/context/memory.js +276 -0
  122. package/dist_v2/context/mode.d.ts +25 -0
  123. package/dist_v2/context/mode.js +81 -0
  124. package/dist_v2/context/session.d.ts +56 -0
  125. package/dist_v2/context/session.js +108 -0
  126. package/dist_v2/daemon/index.d.ts +2 -0
  127. package/dist_v2/daemon/index.js +3 -0
  128. package/dist_v2/daemon/protocol.d.ts +73 -0
  129. package/dist_v2/daemon/protocol.js +6 -0
  130. package/dist_v2/daemon/server.d.ts +35 -0
  131. package/dist_v2/daemon/server.js +191 -0
  132. package/dist_v2/eval/index.d.ts +5 -0
  133. package/dist_v2/eval/index.js +6 -0
  134. package/dist_v2/eval/regression.d.ts +14 -0
  135. package/dist_v2/eval/regression.js +106 -0
  136. package/dist_v2/eval/reporter.d.ts +7 -0
  137. package/dist_v2/eval/reporter.js +34 -0
  138. package/dist_v2/eval/swe-bench.d.ts +18 -0
  139. package/dist_v2/eval/swe-bench.js +23 -0
  140. package/dist_v2/eval/terminal-bench.d.ts +13 -0
  141. package/dist_v2/eval/terminal-bench.js +19 -0
  142. package/dist_v2/eval/types.d.ts +36 -0
  143. package/dist_v2/eval/types.js +5 -0
  144. package/dist_v2/fleet/apply-back.d.ts +27 -0
  145. package/dist_v2/fleet/apply-back.js +191 -0
  146. package/dist_v2/fleet/cli-command.d.ts +61 -0
  147. package/dist_v2/fleet/cli-command.js +329 -0
  148. package/dist_v2/fleet/index.d.ts +21 -0
  149. package/dist_v2/fleet/index.js +21 -0
  150. package/dist_v2/fleet/runner.d.ts +28 -0
  151. package/dist_v2/fleet/runner.js +347 -0
  152. package/dist_v2/fleet/tripleshot.d.ts +21 -0
  153. package/dist_v2/fleet/tripleshot.js +222 -0
  154. package/dist_v2/fleet/types.d.ts +193 -0
  155. package/dist_v2/fleet/types.js +24 -0
  156. package/dist_v2/fleet/worktree.d.ts +51 -0
  157. package/dist_v2/fleet/worktree.js +176 -0
  158. package/dist_v2/hooks/index.d.ts +1 -0
  159. package/dist_v2/hooks/index.js +2 -0
  160. package/dist_v2/hooks/registry.d.ts +21 -0
  161. package/dist_v2/hooks/registry.js +40 -0
  162. package/dist_v2/index.d.ts +12 -0
  163. package/dist_v2/index.js +11 -0
  164. package/dist_v2/integrations/arniko-client.d.ts +42 -0
  165. package/dist_v2/integrations/arniko-client.js +86 -0
  166. package/dist_v2/integrations/auth.d.ts +45 -0
  167. package/dist_v2/integrations/auth.js +54 -0
  168. package/dist_v2/integrations/billing.d.ts +71 -0
  169. package/dist_v2/integrations/billing.js +107 -0
  170. package/dist_v2/integrations/bucky-client.d.ts +105 -0
  171. package/dist_v2/integrations/bucky-client.js +76 -0
  172. package/dist_v2/integrations/deploy-client.d.ts +60 -0
  173. package/dist_v2/integrations/deploy-client.js +87 -0
  174. package/dist_v2/integrations/device-auth.d.ts +48 -0
  175. package/dist_v2/integrations/device-auth.js +192 -0
  176. package/dist_v2/integrations/entitlements.d.ts +34 -0
  177. package/dist_v2/integrations/entitlements.js +43 -0
  178. package/dist_v2/integrations/http.d.ts +22 -0
  179. package/dist_v2/integrations/http.js +114 -0
  180. package/dist_v2/integrations/index.d.ts +8 -0
  181. package/dist_v2/integrations/index.js +15 -0
  182. package/dist_v2/intelligence/cost.d.ts +28 -0
  183. package/dist_v2/intelligence/cost.js +58 -0
  184. package/dist_v2/intelligence/error-classifier.d.ts +8 -0
  185. package/dist_v2/intelligence/error-classifier.js +71 -0
  186. package/dist_v2/intelligence/index.d.ts +5 -0
  187. package/dist_v2/intelligence/index.js +6 -0
  188. package/dist_v2/intelligence/prices.d.ts +13 -0
  189. package/dist_v2/intelligence/prices.js +26 -0
  190. package/dist_v2/intelligence/smart-router.d.ts +21 -0
  191. package/dist_v2/intelligence/smart-router.js +59 -0
  192. package/dist_v2/intelligence/telemetry.d.ts +22 -0
  193. package/dist_v2/intelligence/telemetry.js +31 -0
  194. package/dist_v2/kernel/agent-loop.d.ts +32 -0
  195. package/dist_v2/kernel/agent-loop.js +151 -0
  196. package/dist_v2/kernel/event-stream.d.ts +18 -0
  197. package/dist_v2/kernel/event-stream.js +102 -0
  198. package/dist_v2/kernel/index.d.ts +4 -0
  199. package/dist_v2/kernel/index.js +5 -0
  200. package/dist_v2/kernel/message.d.ts +29 -0
  201. package/dist_v2/kernel/message.js +118 -0
  202. package/dist_v2/kernel/types.d.ts +206 -0
  203. package/dist_v2/kernel/types.js +9 -0
  204. package/dist_v2/mcp/client.d.ts +44 -0
  205. package/dist_v2/mcp/client.js +63 -0
  206. package/dist_v2/mcp/index.d.ts +3 -0
  207. package/dist_v2/mcp/index.js +4 -0
  208. package/dist_v2/mcp/tool-bridge.d.ts +11 -0
  209. package/dist_v2/mcp/tool-bridge.js +33 -0
  210. package/dist_v2/mcp/transport.d.ts +29 -0
  211. package/dist_v2/mcp/transport.js +73 -0
  212. package/dist_v2/parity/index.d.ts +3 -0
  213. package/dist_v2/parity/index.js +4 -0
  214. package/dist_v2/parity/mock-openai-compat.d.ts +15 -0
  215. package/dist_v2/parity/mock-openai-compat.js +35 -0
  216. package/dist_v2/parity/runner.d.ts +21 -0
  217. package/dist_v2/parity/runner.js +76 -0
  218. package/dist_v2/parity/scenarios.d.ts +20 -0
  219. package/dist_v2/parity/scenarios.js +70 -0
  220. package/dist_v2/providers/anthropic.d.ts +21 -0
  221. package/dist_v2/providers/anthropic.js +191 -0
  222. package/dist_v2/providers/dispatch.d.ts +11 -0
  223. package/dist_v2/providers/dispatch.js +45 -0
  224. package/dist_v2/providers/fireworks.d.ts +18 -0
  225. package/dist_v2/providers/fireworks.js +44 -0
  226. package/dist_v2/providers/gemini.d.ts +19 -0
  227. package/dist_v2/providers/gemini.js +188 -0
  228. package/dist_v2/providers/http.d.ts +41 -0
  229. package/dist_v2/providers/http.js +188 -0
  230. package/dist_v2/providers/iface.d.ts +18 -0
  231. package/dist_v2/providers/iface.js +18 -0
  232. package/dist_v2/providers/index.d.ts +39 -0
  233. package/dist_v2/providers/index.js +51 -0
  234. package/dist_v2/providers/nvidia.d.ts +27 -0
  235. package/dist_v2/providers/nvidia.js +142 -0
  236. package/dist_v2/providers/ollama.d.ts +15 -0
  237. package/dist_v2/providers/ollama.js +37 -0
  238. package/dist_v2/providers/openai-compat.d.ts +29 -0
  239. package/dist_v2/providers/openai-compat.js +239 -0
  240. package/dist_v2/providers/openai.d.ts +20 -0
  241. package/dist_v2/providers/openai.js +107 -0
  242. package/dist_v2/providers/openrouter.d.ts +24 -0
  243. package/dist_v2/providers/openrouter.js +69 -0
  244. package/dist_v2/safety/approval-bus.d.ts +26 -0
  245. package/dist_v2/safety/approval-bus.js +48 -0
  246. package/dist_v2/safety/audit-log.d.ts +27 -0
  247. package/dist_v2/safety/audit-log.js +71 -0
  248. package/dist_v2/safety/index.d.ts +4 -0
  249. package/dist_v2/safety/index.js +5 -0
  250. package/dist_v2/safety/policy.d.ts +32 -0
  251. package/dist_v2/safety/policy.js +131 -0
  252. package/dist_v2/safety/sandbox/bwrap.d.ts +11 -0
  253. package/dist_v2/safety/sandbox/bwrap.js +52 -0
  254. package/dist_v2/safety/sandbox/iface.d.ts +29 -0
  255. package/dist_v2/safety/sandbox/iface.js +8 -0
  256. package/dist_v2/safety/sandbox/index.d.ts +7 -0
  257. package/dist_v2/safety/sandbox/index.js +8 -0
  258. package/dist_v2/safety/sandbox/landlock.d.ts +17 -0
  259. package/dist_v2/safety/sandbox/landlock.js +26 -0
  260. package/dist_v2/safety/sandbox/noop.d.ts +12 -0
  261. package/dist_v2/safety/sandbox/noop.js +52 -0
  262. package/dist_v2/safety/sandbox/seatbelt.d.ts +11 -0
  263. package/dist_v2/safety/sandbox/seatbelt.js +49 -0
  264. package/dist_v2/safety/sandbox/select.d.ts +6 -0
  265. package/dist_v2/safety/sandbox/select.js +42 -0
  266. package/dist_v2/safety/sandbox/windows.d.ts +13 -0
  267. package/dist_v2/safety/sandbox/windows.js +22 -0
  268. package/dist_v2/skills/index.d.ts +3 -0
  269. package/dist_v2/skills/index.js +4 -0
  270. package/dist_v2/skills/loader.d.ts +38 -0
  271. package/dist_v2/skills/loader.js +102 -0
  272. package/dist_v2/skills/matcher.d.ts +14 -0
  273. package/dist_v2/skills/matcher.js +72 -0
  274. package/dist_v2/skills/runtime.d.ts +13 -0
  275. package/dist_v2/skills/runtime.js +40 -0
  276. package/dist_v2/subagents/delegator.d.ts +36 -0
  277. package/dist_v2/subagents/delegator.js +82 -0
  278. package/dist_v2/subagents/index.d.ts +2 -0
  279. package/dist_v2/subagents/index.js +3 -0
  280. package/dist_v2/subagents/pool.d.ts +18 -0
  281. package/dist_v2/subagents/pool.js +31 -0
  282. package/dist_v2/tools/browser.d.ts +27 -0
  283. package/dist_v2/tools/browser.js +179 -0
  284. package/dist_v2/tools/checkpoint.d.ts +25 -0
  285. package/dist_v2/tools/checkpoint.js +222 -0
  286. package/dist_v2/tools/cron.d.ts +32 -0
  287. package/dist_v2/tools/cron.js +160 -0
  288. package/dist_v2/tools/diff.d.ts +18 -0
  289. package/dist_v2/tools/diff.js +117 -0
  290. package/dist_v2/tools/exec.d.ts +19 -0
  291. package/dist_v2/tools/exec.js +49 -0
  292. package/dist_v2/tools/fs-edit.d.ts +11 -0
  293. package/dist_v2/tools/fs-edit.js +81 -0
  294. package/dist_v2/tools/fs-ls.d.ts +7 -0
  295. package/dist_v2/tools/fs-ls.js +57 -0
  296. package/dist_v2/tools/fs-read.d.ts +7 -0
  297. package/dist_v2/tools/fs-read.js +60 -0
  298. package/dist_v2/tools/fs-write.d.ts +8 -0
  299. package/dist_v2/tools/fs-write.js +46 -0
  300. package/dist_v2/tools/git.d.ts +8 -0
  301. package/dist_v2/tools/git.js +57 -0
  302. package/dist_v2/tools/index.d.ts +25 -0
  303. package/dist_v2/tools/index.js +39 -0
  304. package/dist_v2/tools/multimodal.d.ts +41 -0
  305. package/dist_v2/tools/multimodal.js +381 -0
  306. package/dist_v2/tools/permission.d.ts +27 -0
  307. package/dist_v2/tools/permission.js +43 -0
  308. package/dist_v2/tools/registry.d.ts +44 -0
  309. package/dist_v2/tools/registry.js +62 -0
  310. package/dist_v2/tools/search-glob.d.ts +7 -0
  311. package/dist_v2/tools/search-glob.js +98 -0
  312. package/dist_v2/tools/search-grep.d.ts +7 -0
  313. package/dist_v2/tools/search-grep.js +109 -0
  314. package/dist_v2/tools/shell.d.ts +10 -0
  315. package/dist_v2/tools/shell.js +76 -0
  316. package/dist_v2/tools/task.d.ts +8 -0
  317. package/dist_v2/tools/task.js +37 -0
  318. package/dist_v2/tui/approval.d.ts +7 -0
  319. package/dist_v2/tui/approval.js +55 -0
  320. package/dist_v2/tui/index.d.ts +4 -0
  321. package/dist_v2/tui/index.js +5 -0
  322. package/dist_v2/tui/ink/App.d.ts +39 -0
  323. package/dist_v2/tui/ink/App.js +206 -0
  324. package/dist_v2/tui/ink/components/AtFileComplete.d.ts +25 -0
  325. package/dist_v2/tui/ink/components/AtFileComplete.js +158 -0
  326. package/dist_v2/tui/ink/components/HelpOverlay.d.ts +24 -0
  327. package/dist_v2/tui/ink/components/HelpOverlay.js +130 -0
  328. package/dist_v2/tui/ink/components/InputBox.d.ts +35 -0
  329. package/dist_v2/tui/ink/components/InputBox.js +153 -0
  330. package/dist_v2/tui/ink/components/Logo.d.ts +12 -0
  331. package/dist_v2/tui/ink/components/Logo.js +27 -0
  332. package/dist_v2/tui/ink/components/ModelPicker.d.ts +26 -0
  333. package/dist_v2/tui/ink/components/ModelPicker.js +80 -0
  334. package/dist_v2/tui/ink/components/PasteCollapse.d.ts +36 -0
  335. package/dist_v2/tui/ink/components/PasteCollapse.js +59 -0
  336. package/dist_v2/tui/ink/components/StatusBar.d.ts +18 -0
  337. package/dist_v2/tui/ink/components/StatusBar.js +41 -0
  338. package/dist_v2/tui/ink/components/StreamingText.d.ts +14 -0
  339. package/dist_v2/tui/ink/components/StreamingText.js +11 -0
  340. package/dist_v2/tui/ink/components/ThinkingBlock.d.ts +13 -0
  341. package/dist_v2/tui/ink/components/ThinkingBlock.js +13 -0
  342. package/dist_v2/tui/ink/components/ToolBox.d.ts +20 -0
  343. package/dist_v2/tui/ink/components/ToolBox.js +63 -0
  344. package/dist_v2/tui/ink/components/vim-bindings.d.ts +43 -0
  345. package/dist_v2/tui/ink/components/vim-bindings.js +135 -0
  346. package/dist_v2/tui/ink/index.d.ts +39 -0
  347. package/dist_v2/tui/ink/index.js +47 -0
  348. package/dist_v2/tui/ink/use-event-projection.d.ts +51 -0
  349. package/dist_v2/tui/ink/use-event-projection.js +126 -0
  350. package/dist_v2/tui/ink/use-overlays.d.ts +24 -0
  351. package/dist_v2/tui/ink/use-overlays.js +50 -0
  352. package/dist_v2/tui/renderer.d.ts +19 -0
  353. package/dist_v2/tui/renderer.js +64 -0
  354. package/dist_v2/tui/status-bar.d.ts +12 -0
  355. package/dist_v2/tui/status-bar.js +16 -0
  356. package/dist_v2/tui/theme.d.ts +27 -0
  357. package/dist_v2/tui/theme.js +56 -0
  358. package/dist_v2/utils/json-repair.d.ts +7 -0
  359. package/dist_v2/utils/json-repair.js +45 -0
  360. package/package.json +113 -0
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Long-term memory store. File-backed, one directory per user.
3
+ *
4
+ * Two public APIs, both live on the same underlying store:
5
+ *
6
+ * 1. The original `MemoryStore` (list/get/upsert/remove/search) —
7
+ * structured records with type/name/description/body. Kept
8
+ * verbatim for backwards compatibility.
9
+ *
10
+ * 2. The canonical L3 context contract `KeyedMemoryStore`
11
+ * (save/load/search/list/delete) — key-addressed markdown notes
12
+ * with frontmatter tags. This is what the agent loop, CLI
13
+ * `memory` commands, and the `memory` tool all use going forward.
14
+ *
15
+ * Both APIs share the same on-disk layout: `~/.dirgha/memory/{key}.md`
16
+ * with YAML frontmatter. An optional SQLite FTS5 index at
17
+ * `~/.dirgha/memory/index.db` accelerates `search` when better-sqlite3
18
+ * is available; if not, we fall back to a substring scan.
19
+ */
20
+ export type MemoryType = 'user' | 'feedback' | 'project' | 'reference';
21
+ export interface MemoryEntry {
22
+ id: string;
23
+ type: MemoryType;
24
+ name: string;
25
+ description: string;
26
+ body: string;
27
+ createdAt: string;
28
+ updatedAt: string;
29
+ }
30
+ export interface MemoryStore {
31
+ list(): Promise<MemoryEntry[]>;
32
+ get(id: string): Promise<MemoryEntry | undefined>;
33
+ upsert(entry: MemoryEntry): Promise<void>;
34
+ remove(id: string): Promise<void>;
35
+ search(query: string): Promise<MemoryEntry[]>;
36
+ }
37
+ export interface MemoryHit {
38
+ key: string;
39
+ title: string;
40
+ snippet: string;
41
+ score: number;
42
+ }
43
+ export interface KeyedMemoryStore {
44
+ save(key: string, value: string, tags?: string[]): Promise<void>;
45
+ load(key: string): Promise<string | null>;
46
+ search(query: string, limit?: number): Promise<MemoryHit[]>;
47
+ list(): Promise<string[]>;
48
+ delete(key: string): Promise<void>;
49
+ }
50
+ export interface FileMemoryStoreOptions {
51
+ directory?: string;
52
+ /** Set to false to skip opening the FTS5 index (tests, read-only envs). */
53
+ useFtsIndex?: boolean;
54
+ }
55
+ /** Legacy factory — returns the structured-record API used by existing callers. */
56
+ export declare function createMemoryStore(opts?: FileMemoryStoreOptions): MemoryStore;
57
+ /**
58
+ * Canonical L3 factory — returns the key/value API described in the
59
+ * experience spec. Both factories wrap the same on-disk store, so
60
+ * callers may create either view safely.
61
+ */
62
+ export declare function createKeyedMemoryStore(opts?: FileMemoryStoreOptions): KeyedMemoryStore;
63
+ export declare class FileMemoryStore implements MemoryStore {
64
+ readonly dir: string;
65
+ readonly ftsEnabled: boolean;
66
+ private ftsPromise;
67
+ constructor(dir: string, ftsEnabled: boolean);
68
+ list(): Promise<MemoryEntry[]>;
69
+ get(id: string): Promise<MemoryEntry | undefined>;
70
+ upsert(entry: MemoryEntry): Promise<void>;
71
+ remove(id: string): Promise<void>;
72
+ search(query: string): Promise<MemoryEntry[]>;
73
+ /** Ranked hit search used by `KeyedMemoryStore.search`. */
74
+ searchHits(query: string, limit: number): Promise<MemoryHit[]>;
75
+ private pathFor;
76
+ private ensure;
77
+ private writeIndex;
78
+ private fts;
79
+ private reindex;
80
+ }
@@ -0,0 +1,276 @@
1
+ /**
2
+ * Long-term memory store. File-backed, one directory per user.
3
+ *
4
+ * Two public APIs, both live on the same underlying store:
5
+ *
6
+ * 1. The original `MemoryStore` (list/get/upsert/remove/search) —
7
+ * structured records with type/name/description/body. Kept
8
+ * verbatim for backwards compatibility.
9
+ *
10
+ * 2. The canonical L3 context contract `KeyedMemoryStore`
11
+ * (save/load/search/list/delete) — key-addressed markdown notes
12
+ * with frontmatter tags. This is what the agent loop, CLI
13
+ * `memory` commands, and the `memory` tool all use going forward.
14
+ *
15
+ * Both APIs share the same on-disk layout: `~/.dirgha/memory/{key}.md`
16
+ * with YAML frontmatter. An optional SQLite FTS5 index at
17
+ * `~/.dirgha/memory/index.db` accelerates `search` when better-sqlite3
18
+ * is available; if not, we fall back to a substring scan.
19
+ */
20
+ import { readFile, readdir, stat, writeFile, mkdir, unlink } from 'node:fs/promises';
21
+ import { join } from 'node:path';
22
+ import { homedir } from 'node:os';
23
+ import { openFtsIndex, fallbackSearch } from './_fts.js';
24
+ /** Legacy factory — returns the structured-record API used by existing callers. */
25
+ export function createMemoryStore(opts = {}) {
26
+ return buildStore(opts);
27
+ }
28
+ /**
29
+ * Canonical L3 factory — returns the key/value API described in the
30
+ * experience spec. Both factories wrap the same on-disk store, so
31
+ * callers may create either view safely.
32
+ */
33
+ export function createKeyedMemoryStore(opts = {}) {
34
+ return new KeyedAdapter(buildStore(opts));
35
+ }
36
+ function buildStore(opts) {
37
+ const dir = opts.directory ?? join(homedir(), '.dirgha', 'memory');
38
+ return new FileMemoryStore(dir, opts.useFtsIndex !== false);
39
+ }
40
+ export class FileMemoryStore {
41
+ dir;
42
+ ftsEnabled;
43
+ ftsPromise = null;
44
+ constructor(dir, ftsEnabled) {
45
+ this.dir = dir;
46
+ this.ftsEnabled = ftsEnabled;
47
+ }
48
+ async list() {
49
+ await this.ensure();
50
+ const names = await readdir(this.dir).catch(() => []);
51
+ const entries = [];
52
+ for (const name of names) {
53
+ if (!name.endsWith('.md') || name === 'MEMORY.md')
54
+ continue;
55
+ const id = name.replace(/\.md$/, '');
56
+ const entry = await this.get(id);
57
+ if (entry)
58
+ entries.push(entry);
59
+ }
60
+ entries.sort((a, b) => (a.updatedAt > b.updatedAt ? -1 : 1));
61
+ return entries;
62
+ }
63
+ async get(id) {
64
+ const abs = this.pathFor(id);
65
+ const text = await readFile(abs, 'utf8').catch(() => undefined);
66
+ if (!text)
67
+ return undefined;
68
+ return parseEntry(id, text);
69
+ }
70
+ async upsert(entry) {
71
+ await this.ensure();
72
+ const now = new Date().toISOString();
73
+ const complete = {
74
+ ...entry,
75
+ createdAt: entry.createdAt || now,
76
+ updatedAt: now,
77
+ };
78
+ await writeFile(this.pathFor(complete.id), renderEntry(complete), 'utf8');
79
+ await this.writeIndex();
80
+ await this.reindex(complete);
81
+ }
82
+ async remove(id) {
83
+ await unlink(this.pathFor(id)).catch(() => undefined);
84
+ await this.writeIndex();
85
+ const fts = await this.fts();
86
+ fts?.remove(id);
87
+ }
88
+ async search(query) {
89
+ const needle = query.toLowerCase();
90
+ const all = await this.list();
91
+ return all.filter(e => e.name.toLowerCase().includes(needle)
92
+ || e.description.toLowerCase().includes(needle)
93
+ || e.body.toLowerCase().includes(needle));
94
+ }
95
+ /** Ranked hit search used by `KeyedMemoryStore.search`. */
96
+ async searchHits(query, limit) {
97
+ const fts = await this.fts();
98
+ if (fts) {
99
+ const hits = fts.search(query, limit);
100
+ if (hits.length > 0) {
101
+ return hits.map(h => ({ key: h.id, title: h.title, snippet: h.snippet, score: h.score }));
102
+ }
103
+ }
104
+ const entries = await this.list();
105
+ const docs = entries.map(e => ({ id: e.id, title: e.name, body: e.body, tags: '' }));
106
+ return fallbackSearch(docs, query, limit).map(h => ({
107
+ key: h.id, title: h.title, snippet: h.snippet, score: h.score,
108
+ }));
109
+ }
110
+ pathFor(id) {
111
+ return join(this.dir, `${id}.md`);
112
+ }
113
+ async ensure() {
114
+ const info = await stat(this.dir).catch(() => undefined);
115
+ if (!info)
116
+ await mkdir(this.dir, { recursive: true });
117
+ }
118
+ async writeIndex() {
119
+ const entries = await this.list();
120
+ const lines = ['# Memory Index', ''];
121
+ for (const e of entries) {
122
+ lines.push(`- [${e.name}](${e.id}.md) — ${e.description}`);
123
+ }
124
+ await writeFile(join(this.dir, 'MEMORY.md'), `${lines.join('\n')}\n`, 'utf8');
125
+ }
126
+ fts() {
127
+ if (!this.ftsEnabled)
128
+ return Promise.resolve(null);
129
+ if (!this.ftsPromise) {
130
+ this.ftsPromise = openFtsIndex({
131
+ dbPath: join(this.dir, 'index.db'),
132
+ namespace: 'memory',
133
+ });
134
+ }
135
+ return this.ftsPromise;
136
+ }
137
+ async reindex(entry) {
138
+ const fts = await this.fts();
139
+ fts?.upsert({ id: entry.id, title: entry.name, body: entry.body, tags: '' });
140
+ }
141
+ }
142
+ /**
143
+ * Adapter that exposes a `FileMemoryStore` through the keyed contract
144
+ * (save/load/search/list/delete). Keeping the two interfaces on separate
145
+ * objects avoids method-name collisions (both contracts define `search`
146
+ * and `list` with different return shapes).
147
+ */
148
+ class KeyedAdapter {
149
+ inner;
150
+ constructor(inner) {
151
+ this.inner = inner;
152
+ }
153
+ async save(key, value, tags = []) {
154
+ assertValidKey(key);
155
+ const existing = await this.inner.get(key);
156
+ const title = firstHeading(value) ?? key;
157
+ await this.inner.upsert({
158
+ id: key,
159
+ type: inferType(key, existing?.type),
160
+ name: title,
161
+ description: firstParagraph(value) ?? '',
162
+ body: ensureTagsBlock(value, tags),
163
+ createdAt: existing?.createdAt ?? '',
164
+ updatedAt: '',
165
+ });
166
+ }
167
+ async load(key) {
168
+ const entry = await this.inner.get(key);
169
+ return entry?.body ?? null;
170
+ }
171
+ async search(query, limit = 10) {
172
+ return this.inner.searchHits(query, Math.max(1, limit));
173
+ }
174
+ async list() {
175
+ const entries = await this.inner.list();
176
+ return entries.map(e => e.id);
177
+ }
178
+ async delete(key) {
179
+ await this.inner.remove(key);
180
+ }
181
+ }
182
+ // ---------------------------------------------------------------------------
183
+ // Helpers.
184
+ // ---------------------------------------------------------------------------
185
+ function renderEntry(entry) {
186
+ const frontmatter = [
187
+ '---',
188
+ `id: ${entry.id}`,
189
+ `type: ${entry.type}`,
190
+ `name: ${escapeValue(entry.name)}`,
191
+ `description: ${escapeValue(entry.description)}`,
192
+ `createdAt: ${entry.createdAt}`,
193
+ `updatedAt: ${entry.updatedAt}`,
194
+ '---',
195
+ '',
196
+ ].join('\n');
197
+ return `${frontmatter}${entry.body}`;
198
+ }
199
+ function parseEntry(id, text) {
200
+ const match = text.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
201
+ if (!match)
202
+ return undefined;
203
+ const meta = {};
204
+ for (const line of match[1].split('\n')) {
205
+ const idx = line.indexOf(':');
206
+ if (idx < 0)
207
+ continue;
208
+ const key = line.slice(0, idx).trim();
209
+ const value = line.slice(idx + 1).trim();
210
+ meta[key] = unescapeValue(value);
211
+ }
212
+ const type = meta.type ?? 'user';
213
+ return {
214
+ id: meta.id ?? id,
215
+ type,
216
+ name: meta.name ?? id,
217
+ description: meta.description ?? '',
218
+ body: match[2],
219
+ createdAt: meta.createdAt ?? '',
220
+ updatedAt: meta.updatedAt ?? '',
221
+ };
222
+ }
223
+ function escapeValue(s) {
224
+ if (s.includes(':') || s.includes('\n'))
225
+ return JSON.stringify(s);
226
+ return s;
227
+ }
228
+ function unescapeValue(s) {
229
+ if (s.startsWith('"') && s.endsWith('"')) {
230
+ try {
231
+ return JSON.parse(s);
232
+ }
233
+ catch {
234
+ return s;
235
+ }
236
+ }
237
+ return s;
238
+ }
239
+ function assertValidKey(key) {
240
+ if (!key || !/^[a-zA-Z0-9][a-zA-Z0-9_\-\.]*$/.test(key)) {
241
+ throw new Error(`Invalid memory key "${key}". Use alphanumeric, dash, dot, underscore.`);
242
+ }
243
+ }
244
+ function firstHeading(text) {
245
+ const m = text.match(/^\s*#+\s+(.+?)\s*$/m);
246
+ return m ? m[1] : null;
247
+ }
248
+ function firstParagraph(text) {
249
+ const stripped = text.replace(/^\s*#+.*$/m, '').trim();
250
+ const first = stripped.split(/\n\s*\n/)[0]?.trim() ?? '';
251
+ return first || null;
252
+ }
253
+ function inferType(key, fallback) {
254
+ if (key.startsWith('project_'))
255
+ return 'project';
256
+ if (key.startsWith('feedback_'))
257
+ return 'feedback';
258
+ if (key.startsWith('reference_'))
259
+ return 'reference';
260
+ return fallback ?? 'user';
261
+ }
262
+ /**
263
+ * Append a hidden `<!-- tags: a, b, c -->` marker so tags survive on
264
+ * disk without polluting the visible frontmatter. On re-save we strip
265
+ * any prior marker so tags don't stack.
266
+ */
267
+ function ensureTagsBlock(body, tags) {
268
+ const stripped = body.replace(/\n?<!-- tags:[^>]*-->\s*$/s, '');
269
+ if (tags.length === 0)
270
+ return stripped;
271
+ const clean = tags.map(t => t.trim()).filter(Boolean);
272
+ if (clean.length === 0)
273
+ return stripped;
274
+ return `${stripped.trimEnd()}\n<!-- tags: ${clean.join(', ')} -->\n`;
275
+ }
276
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Execution mode for the agent loop. Each mode is a short preamble
3
+ * prepended to the system prompt; it doesn't change the tool set or
4
+ * the loop structure. Used by /mode slash and CLI flags.
5
+ */
6
+ export declare const MODES: readonly ["plan", "act", "verify"];
7
+ export type Mode = (typeof MODES)[number];
8
+ export declare const DEFAULT_MODE: Mode;
9
+ export declare function modePreamble(mode: Mode): string;
10
+ /**
11
+ * Prepend the mode preamble to an existing system prompt. If the
12
+ * caller already supplied one, the mode preamble is inserted first,
13
+ * separated by a blank line. If no prompt is supplied, the preamble
14
+ * stands on its own.
15
+ */
16
+ export declare function applyMode(systemPrompt: string | undefined, mode: Mode): string;
17
+ /**
18
+ * Resolve the active mode. Precedence:
19
+ * 1. process.env.DIRGHA_MODE (for one-off override)
20
+ * 2. ~/.dirgha/config.json's `mode` field
21
+ * 3. DEFAULT_MODE ('act')
22
+ */
23
+ export declare function resolveMode(): Promise<Mode>;
24
+ /** Persist the user's preferred mode. */
25
+ export declare function saveMode(mode: Mode): Promise<void>;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Execution mode for the agent loop. Each mode is a short preamble
3
+ * prepended to the system prompt; it doesn't change the tool set or
4
+ * the loop structure. Used by /mode slash and CLI flags.
5
+ */
6
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
7
+ import { homedir } from 'node:os';
8
+ import { join } from 'node:path';
9
+ export const MODES = ['plan', 'act', 'verify'];
10
+ export const DEFAULT_MODE = 'act';
11
+ const MODE_PREAMBLES = {
12
+ plan: [
13
+ 'Mode: PLAN.',
14
+ 'Produce a structured plan before acting. List the files you would read, the changes you would make, and the verification steps — but do NOT write files, run shell commands, or make git commits. Read-only tools (read_file, search_grep, search_glob, fs_ls, git_status) are fine. Ask for confirmation before leaving plan mode.',
15
+ ].join('\n'),
16
+ act: [
17
+ 'Mode: ACT.',
18
+ 'Execute the task end to end. Use tools as needed, write code, run shells, commit when asked. Report concisely on what you did.',
19
+ ].join('\n'),
20
+ verify: [
21
+ 'Mode: VERIFY.',
22
+ 'Treat the current state as a proposed change to audit. Read code, run tests and type-checkers, inspect git diffs — but do NOT modify files. Surface risks, test failures, and unverified assumptions. Return a pass/fail summary.',
23
+ ].join('\n'),
24
+ };
25
+ export function modePreamble(mode) {
26
+ return MODE_PREAMBLES[mode];
27
+ }
28
+ /**
29
+ * Prepend the mode preamble to an existing system prompt. If the
30
+ * caller already supplied one, the mode preamble is inserted first,
31
+ * separated by a blank line. If no prompt is supplied, the preamble
32
+ * stands on its own.
33
+ */
34
+ export function applyMode(systemPrompt, mode) {
35
+ const preamble = modePreamble(mode);
36
+ if (!systemPrompt || systemPrompt.trim().length === 0)
37
+ return preamble;
38
+ return `${preamble}\n\n${systemPrompt}`;
39
+ }
40
+ function configPath() {
41
+ return join(homedir(), '.dirgha', 'config.json');
42
+ }
43
+ async function readStoredConfig() {
44
+ const text = await readFile(configPath(), 'utf8').catch(() => '');
45
+ if (!text)
46
+ return {};
47
+ try {
48
+ const parsed = JSON.parse(text);
49
+ return (parsed && typeof parsed === 'object') ? parsed : {};
50
+ }
51
+ catch {
52
+ return {};
53
+ }
54
+ }
55
+ async function writeStoredConfig(patch) {
56
+ const current = await readStoredConfig();
57
+ const merged = { ...current, ...patch };
58
+ await mkdir(join(homedir(), '.dirgha'), { recursive: true });
59
+ await writeFile(configPath(), JSON.stringify(merged, null, 2) + '\n', 'utf8');
60
+ }
61
+ /**
62
+ * Resolve the active mode. Precedence:
63
+ * 1. process.env.DIRGHA_MODE (for one-off override)
64
+ * 2. ~/.dirgha/config.json's `mode` field
65
+ * 3. DEFAULT_MODE ('act')
66
+ */
67
+ export async function resolveMode() {
68
+ const fromEnv = process.env['DIRGHA_MODE'];
69
+ if (fromEnv && MODES.includes(fromEnv))
70
+ return fromEnv;
71
+ const cfg = await readStoredConfig();
72
+ if (cfg.mode && MODES.includes(cfg.mode))
73
+ return cfg.mode;
74
+ return DEFAULT_MODE;
75
+ }
76
+ /** Persist the user's preferred mode. */
77
+ export async function saveMode(mode) {
78
+ process.env['DIRGHA_MODE'] = mode;
79
+ await writeStoredConfig({ mode });
80
+ }
81
+ //# sourceMappingURL=mode.js.map
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Append-only session log, persisted as JSONL. Crash-safe: every append
3
+ * is a single fs.appendFile call; partial last lines on replay are
4
+ * ignored silently. A session is identified by its id; the canonical
5
+ * file path derives from the id plus the store's base directory.
6
+ */
7
+ import type { Message, UsageTotal } from '../kernel/types.js';
8
+ export type SessionEntry = {
9
+ type: 'message';
10
+ ts: string;
11
+ message: Message;
12
+ } | {
13
+ type: 'usage';
14
+ ts: string;
15
+ usage: UsageTotal;
16
+ } | {
17
+ type: 'model_change';
18
+ ts: string;
19
+ from: string;
20
+ to: string;
21
+ } | {
22
+ type: 'compaction';
23
+ ts: string;
24
+ keptFrom: string;
25
+ summary: string;
26
+ } | {
27
+ type: 'branch';
28
+ ts: string;
29
+ parentId: string;
30
+ name: string;
31
+ } | {
32
+ type: 'system';
33
+ ts: string;
34
+ event: string;
35
+ data?: Record<string, unknown>;
36
+ };
37
+ export interface Session {
38
+ readonly id: string;
39
+ readonly path: string;
40
+ append(entry: SessionEntry): Promise<void>;
41
+ replay(): AsyncIterable<SessionEntry>;
42
+ messages(): Promise<Message[]>;
43
+ }
44
+ export interface SessionStoreOptions {
45
+ directory?: string;
46
+ }
47
+ export declare class SessionStore {
48
+ private readonly dir;
49
+ constructor(dir?: string);
50
+ create(id: string): Promise<Session>;
51
+ open(id: string): Promise<Session | undefined>;
52
+ list(): Promise<string[]>;
53
+ private ensure;
54
+ }
55
+ export declare function createSessionStore(opts?: SessionStoreOptions): SessionStore;
56
+ export declare function streamJsonl(path: string, onLine: (entry: SessionEntry) => void): Promise<void>;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Append-only session log, persisted as JSONL. Crash-safe: every append
3
+ * is a single fs.appendFile call; partial last lines on replay are
4
+ * ignored silently. A session is identified by its id; the canonical
5
+ * file path derives from the id plus the store's base directory.
6
+ */
7
+ import { appendFile, mkdir, readFile, stat, writeFile } from 'node:fs/promises';
8
+ import { join } from 'node:path';
9
+ import { homedir } from 'node:os';
10
+ import { createReadStream } from 'node:fs';
11
+ export class SessionStore {
12
+ dir;
13
+ constructor(dir = join(homedir(), '.dirgha', 'sessions')) {
14
+ this.dir = dir;
15
+ }
16
+ async create(id) {
17
+ await this.ensure();
18
+ const path = join(this.dir, `${id}.jsonl`);
19
+ const exists = await stat(path).then(() => true).catch(() => false);
20
+ if (!exists)
21
+ await writeFile(path, '', 'utf8');
22
+ return new SessionImpl(id, path);
23
+ }
24
+ async open(id) {
25
+ const path = join(this.dir, `${id}.jsonl`);
26
+ const exists = await stat(path).then(() => true).catch(() => false);
27
+ if (!exists)
28
+ return undefined;
29
+ return new SessionImpl(id, path);
30
+ }
31
+ async list() {
32
+ await this.ensure();
33
+ const { readdir } = await import('node:fs/promises');
34
+ const names = await readdir(this.dir).catch(() => []);
35
+ return names.filter(n => n.endsWith('.jsonl')).map(n => n.replace(/\.jsonl$/, ''));
36
+ }
37
+ async ensure() {
38
+ const info = await stat(this.dir).catch(() => undefined);
39
+ if (!info)
40
+ await mkdir(this.dir, { recursive: true });
41
+ }
42
+ }
43
+ class SessionImpl {
44
+ id;
45
+ path;
46
+ constructor(id, path) {
47
+ this.id = id;
48
+ this.path = path;
49
+ }
50
+ async append(entry) {
51
+ await appendFile(this.path, `${JSON.stringify(entry)}\n`, 'utf8');
52
+ }
53
+ async *replay() {
54
+ const content = await readFile(this.path, 'utf8').catch(() => '');
55
+ for (const line of content.split('\n')) {
56
+ if (!line.trim())
57
+ continue;
58
+ try {
59
+ yield JSON.parse(line);
60
+ }
61
+ catch {
62
+ continue;
63
+ }
64
+ }
65
+ }
66
+ async messages() {
67
+ const out = [];
68
+ for await (const entry of this.replay()) {
69
+ if (entry.type === 'message')
70
+ out.push(entry.message);
71
+ }
72
+ return out;
73
+ }
74
+ }
75
+ export function createSessionStore(opts = {}) {
76
+ return new SessionStore(opts.directory);
77
+ }
78
+ export async function streamJsonl(path, onLine) {
79
+ return new Promise((resolve, reject) => {
80
+ const stream = createReadStream(path, { encoding: 'utf8' });
81
+ let buffer = '';
82
+ stream.on('data', (chunk) => {
83
+ buffer += typeof chunk === 'string' ? chunk : chunk.toString('utf8');
84
+ let idx;
85
+ while ((idx = buffer.indexOf('\n')) >= 0) {
86
+ const line = buffer.slice(0, idx);
87
+ buffer = buffer.slice(idx + 1);
88
+ if (!line.trim())
89
+ continue;
90
+ try {
91
+ onLine(JSON.parse(line));
92
+ }
93
+ catch { /* skip */ }
94
+ }
95
+ });
96
+ stream.on('end', () => {
97
+ if (buffer.trim()) {
98
+ try {
99
+ onLine(JSON.parse(buffer));
100
+ }
101
+ catch { /* skip */ }
102
+ }
103
+ resolve();
104
+ });
105
+ stream.on('error', reject);
106
+ });
107
+ }
108
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1,2 @@
1
+ export * from './protocol.js';
2
+ export * from './server.js';
@@ -0,0 +1,3 @@
1
+ export * from './protocol.js';
2
+ export * from './server.js';
3
+ //# sourceMappingURL=index.js.map