@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,14 @@
1
+ /**
2
+ * Match skills to the current turn. A skill matches when the platform
3
+ * allows it and at least one trigger (keyword or file-pattern) fires.
4
+ * When no triggers are declared the skill is considered ambient and
5
+ * always matches for its allowed platforms.
6
+ */
7
+ import type { Skill, SkillPlatform } from './loader.js';
8
+ export interface MatchContext {
9
+ platform: SkillPlatform;
10
+ userMessage?: string;
11
+ files?: string[];
12
+ explicit?: string[];
13
+ }
14
+ export declare function matchSkills(skills: Skill[], ctx: MatchContext): Skill[];
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Match skills to the current turn. A skill matches when the platform
3
+ * allows it and at least one trigger (keyword or file-pattern) fires.
4
+ * When no triggers are declared the skill is considered ambient and
5
+ * always matches for its allowed platforms.
6
+ */
7
+ export function matchSkills(skills, ctx) {
8
+ const out = [];
9
+ for (const skill of skills) {
10
+ if (!platformOk(skill, ctx.platform))
11
+ continue;
12
+ if (ctx.explicit?.includes(skill.meta.name)) {
13
+ out.push(skill);
14
+ continue;
15
+ }
16
+ if (triggersMatch(skill, ctx))
17
+ out.push(skill);
18
+ }
19
+ return out;
20
+ }
21
+ function platformOk(skill, platform) {
22
+ const allowed = skill.meta.platforms;
23
+ if (!allowed || allowed.length === 0)
24
+ return true;
25
+ return allowed.includes(platform);
26
+ }
27
+ function triggersMatch(skill, ctx) {
28
+ const triggers = skill.meta.triggers;
29
+ if (!triggers)
30
+ return false;
31
+ const keywords = triggers.keywords ?? [];
32
+ const filePatterns = triggers.filePatterns ?? [];
33
+ if (keywords.length === 0 && filePatterns.length === 0)
34
+ return false;
35
+ const message = (ctx.userMessage ?? '').toLowerCase();
36
+ for (const kw of keywords) {
37
+ if (message.includes(kw.toLowerCase()))
38
+ return true;
39
+ }
40
+ const files = ctx.files ?? [];
41
+ for (const pattern of filePatterns) {
42
+ const rx = globToRegex(pattern);
43
+ for (const f of files) {
44
+ if (rx.test(f))
45
+ return true;
46
+ }
47
+ }
48
+ return false;
49
+ }
50
+ function globToRegex(pattern) {
51
+ let rx = '^';
52
+ for (let i = 0; i < pattern.length; i++) {
53
+ const ch = pattern[i];
54
+ if (ch === '*') {
55
+ if (pattern[i + 1] === '*') {
56
+ rx += '.*';
57
+ i++;
58
+ }
59
+ else
60
+ rx += '[^/]*';
61
+ }
62
+ else if (ch === '?')
63
+ rx += '[^/]';
64
+ else if (/[.+^${}()|[\]\\]/.test(ch))
65
+ rx += `\\${ch}`;
66
+ else
67
+ rx += ch;
68
+ }
69
+ rx += '$';
70
+ return new RegExp(rx);
71
+ }
72
+ //# sourceMappingURL=matcher.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Skill runtime. Takes the matched skill set and renders them into a
3
+ * single user-role message that precedes the live user prompt. Skills
4
+ * are always injected as user content (not system) so that the provider
5
+ * cache boundary sits above them and per-turn changes do not invalidate
6
+ * the parent cache entry.
7
+ */
8
+ import type { Message } from '../kernel/types.js';
9
+ import type { Skill } from './loader.js';
10
+ export interface SkillInjectionOptions {
11
+ header?: string;
12
+ }
13
+ export declare function injectSkills(messages: Message[], skills: Skill[], opts?: SkillInjectionOptions): Message[];
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Skill runtime. Takes the matched skill set and renders them into a
3
+ * single user-role message that precedes the live user prompt. Skills
4
+ * are always injected as user content (not system) so that the provider
5
+ * cache boundary sits above them and per-turn changes do not invalidate
6
+ * the parent cache entry.
7
+ */
8
+ export function injectSkills(messages, skills, opts = {}) {
9
+ if (skills.length === 0)
10
+ return messages;
11
+ const header = opts.header
12
+ ?? `The following skills are active for this turn. Consult them as procedural guidance.`;
13
+ const body = [header, ''];
14
+ for (const skill of skills) {
15
+ body.push(renderSkill(skill));
16
+ body.push('');
17
+ }
18
+ const injection = {
19
+ role: 'user',
20
+ content: [{ type: 'text', text: body.join('\n').trimEnd() }],
21
+ };
22
+ const out = [];
23
+ let injected = false;
24
+ for (const msg of messages) {
25
+ if (!injected && msg.role === 'user') {
26
+ out.push(injection);
27
+ injected = true;
28
+ }
29
+ out.push(msg);
30
+ }
31
+ if (!injected)
32
+ out.push(injection);
33
+ return out;
34
+ }
35
+ function renderSkill(skill) {
36
+ const header = `<skill name="${skill.meta.name}"${skill.meta.version ? ` version="${skill.meta.version}"` : ''} source="${skill.source}">`;
37
+ const footer = '</skill>';
38
+ return `${header}\n${skill.body}\n${footer}`;
39
+ }
40
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Subagent delegation.
3
+ *
4
+ * Exposes a task executor that spawns an isolated agent-loop instance
5
+ * with its own session, its own event stream, and an optional restricted
6
+ * tool subset. The parent receives only the final text output; the full
7
+ * transcript is preserved in the child session for audit.
8
+ */
9
+ import type { Provider, UsageTotal, Message } from '../kernel/types.js';
10
+ import type { ToolRegistry } from '../tools/registry.js';
11
+ export interface SubagentRequest {
12
+ prompt: string;
13
+ system?: string;
14
+ toolAllowlist?: string[];
15
+ maxTurns?: number;
16
+ model?: string;
17
+ }
18
+ export interface SubagentResult {
19
+ output: string;
20
+ usage: UsageTotal;
21
+ transcript: Message[];
22
+ stopReason: string;
23
+ sessionId: string;
24
+ }
25
+ export interface DelegatorOptions {
26
+ registry: ToolRegistry;
27
+ provider: Provider;
28
+ defaultModel: string;
29
+ cwd: string;
30
+ parentSessionId: string;
31
+ }
32
+ export declare class SubagentDelegator {
33
+ private opts;
34
+ constructor(opts: DelegatorOptions);
35
+ delegate(req: SubagentRequest): Promise<SubagentResult>;
36
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Subagent delegation.
3
+ *
4
+ * Exposes a task executor that spawns an isolated agent-loop instance
5
+ * with its own session, its own event stream, and an optional restricted
6
+ * tool subset. The parent receives only the final text output; the full
7
+ * transcript is preserved in the child session for audit.
8
+ */
9
+ import { randomUUID } from 'node:crypto';
10
+ import { createEventStream } from '../kernel/event-stream.js';
11
+ import { runAgentLoop } from '../kernel/agent-loop.js';
12
+ import { extractText } from '../kernel/message.js';
13
+ import { createToolExecutor } from '../tools/exec.js';
14
+ export class SubagentDelegator {
15
+ opts;
16
+ constructor(opts) {
17
+ this.opts = opts;
18
+ }
19
+ async delegate(req) {
20
+ const sessionId = `${this.opts.parentSessionId}-sub-${randomUUID().slice(0, 8)}`;
21
+ const events = createEventStream();
22
+ const allowlist = req.toolAllowlist ? new Set(req.toolAllowlist) : undefined;
23
+ const filteredTools = allowlist
24
+ ? this.opts.registry.list().filter(t => allowlist.has(t.name))
25
+ : this.opts.registry.list();
26
+ const scoped = new Map();
27
+ for (const t of filteredTools)
28
+ scoped.set(t.name, t);
29
+ const scopedRegistry = createScopedRegistry(scoped);
30
+ const sanitized = scopedRegistry.sanitize({ descriptionLimit: 200 });
31
+ const executor = createToolExecutor({
32
+ registry: scopedRegistry,
33
+ cwd: this.opts.cwd,
34
+ sessionId,
35
+ });
36
+ const messages = [];
37
+ if (req.system)
38
+ messages.push({ role: 'system', content: req.system });
39
+ messages.push({ role: 'user', content: req.prompt });
40
+ const result = await runAgentLoop({
41
+ sessionId,
42
+ model: req.model ?? this.opts.defaultModel,
43
+ messages,
44
+ tools: sanitized.definitions,
45
+ maxTurns: req.maxTurns ?? 6,
46
+ provider: this.opts.provider,
47
+ toolExecutor: executor,
48
+ events,
49
+ });
50
+ const lastAssistant = [...result.messages].reverse().find(m => m.role === 'assistant');
51
+ return {
52
+ output: lastAssistant ? extractText(lastAssistant) : '',
53
+ usage: result.usage,
54
+ transcript: result.messages,
55
+ stopReason: result.stopReason,
56
+ sessionId,
57
+ };
58
+ }
59
+ }
60
+ function createScopedRegistry(tools) {
61
+ return {
62
+ register() { throw new Error('scoped registry is read-only'); },
63
+ unregister() { return false; },
64
+ has: (name) => tools.has(name),
65
+ get: (name) => tools.get(name),
66
+ list: () => [...tools.values()],
67
+ sanitize(opts) {
68
+ const limit = opts?.descriptionLimit ?? Number.POSITIVE_INFINITY;
69
+ const definitions = [];
70
+ const nameSet = new Set();
71
+ for (const tool of tools.values()) {
72
+ const description = tool.description.length > limit
73
+ ? `${tool.description.slice(0, limit - 3)}...`
74
+ : tool.description;
75
+ definitions.push({ name: tool.name, description, inputSchema: tool.inputSchema });
76
+ nameSet.add(tool.name);
77
+ }
78
+ return { definitions, nameSet };
79
+ },
80
+ };
81
+ }
82
+ //# sourceMappingURL=delegator.js.map
@@ -0,0 +1,2 @@
1
+ export * from './delegator.js';
2
+ export * from './pool.js';
@@ -0,0 +1,3 @@
1
+ export * from './delegator.js';
2
+ export * from './pool.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Bounded-concurrency pool for subagent delegations. Delegations beyond
3
+ * the concurrency cap are queued FIFO; the pool never drops requests.
4
+ */
5
+ import type { SubagentDelegator, SubagentRequest, SubagentResult } from './delegator.js';
6
+ export interface SubagentPoolOptions {
7
+ delegator: SubagentDelegator;
8
+ maxConcurrent?: number;
9
+ }
10
+ export declare class SubagentPool {
11
+ private opts;
12
+ private inflight;
13
+ private queue;
14
+ private readonly max;
15
+ constructor(opts: SubagentPoolOptions);
16
+ delegate(req: SubagentRequest): Promise<SubagentResult>;
17
+ private drain;
18
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Bounded-concurrency pool for subagent delegations. Delegations beyond
3
+ * the concurrency cap are queued FIFO; the pool never drops requests.
4
+ */
5
+ export class SubagentPool {
6
+ opts;
7
+ inflight = 0;
8
+ queue = [];
9
+ max;
10
+ constructor(opts) {
11
+ this.opts = opts;
12
+ this.max = Math.max(1, opts.maxConcurrent ?? 3);
13
+ }
14
+ delegate(req) {
15
+ return new Promise((resolve, reject) => {
16
+ this.queue.push({ req, resolver: { resolve, reject } });
17
+ this.drain();
18
+ });
19
+ }
20
+ drain() {
21
+ while (this.inflight < this.max && this.queue.length > 0) {
22
+ const item = this.queue.shift();
23
+ this.inflight++;
24
+ this.opts.delegator.delegate(item.req)
25
+ .then(result => item.resolver.resolve(result))
26
+ .catch(err => item.resolver.reject(err))
27
+ .finally(() => { this.inflight--; this.drain(); });
28
+ }
29
+ }
30
+ }
31
+ //# sourceMappingURL=pool.js.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Headless browser tool.
3
+ *
4
+ * Subcommands: goto, click, screenshot, content, close.
5
+ *
6
+ * Keeps a single Chromium instance + page alive across calls within the
7
+ * process so subsequent actions land on the same DOM. The shell owns the
8
+ * lifecycle: call the exported `closeBrowser()` at shutdown to release
9
+ * the child process and delete the tmp user-data-dir.
10
+ *
11
+ * Playwright is loaded lazily so the module's import graph stays light:
12
+ * if the runtime binary isn't installed, callers get a structured error
13
+ * from `execute()` rather than a crash at import time. The `playwright`
14
+ * package is resolvable in this workspace via pnpm — see the v1 browser
15
+ * tool for the older `agent-browser` shell-out implementation this tool
16
+ * supersedes.
17
+ */
18
+ import type { Tool } from './registry.js';
19
+ /**
20
+ * Shut down the browser instance and reset module state. Safe to call
21
+ * repeatedly; a no-op when no browser is running. The shell should call
22
+ * this from its exit handler so headless Chromium doesn't leak across
23
+ * process lifetimes.
24
+ */
25
+ export declare function closeBrowser(): Promise<void>;
26
+ export declare const browserTool: Tool;
27
+ export default browserTool;
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Headless browser tool.
3
+ *
4
+ * Subcommands: goto, click, screenshot, content, close.
5
+ *
6
+ * Keeps a single Chromium instance + page alive across calls within the
7
+ * process so subsequent actions land on the same DOM. The shell owns the
8
+ * lifecycle: call the exported `closeBrowser()` at shutdown to release
9
+ * the child process and delete the tmp user-data-dir.
10
+ *
11
+ * Playwright is loaded lazily so the module's import graph stays light:
12
+ * if the runtime binary isn't installed, callers get a structured error
13
+ * from `execute()` rather than a crash at import time. The `playwright`
14
+ * package is resolvable in this workspace via pnpm — see the v1 browser
15
+ * tool for the older `agent-browser` shell-out implementation this tool
16
+ * supersedes.
17
+ */
18
+ /* eslint-disable @typescript-eslint/no-explicit-any */
19
+ import { mkdir } from 'node:fs/promises';
20
+ import { homedir, tmpdir } from 'node:os';
21
+ import { join } from 'node:path';
22
+ const MAX_CONTENT_CHARS = 50_000;
23
+ const DEFAULT_TIMEOUT_MS = 30_000;
24
+ const SCREENSHOT_DIR = join(homedir(), '.dirgha', 'screenshots');
25
+ let browser;
26
+ let page;
27
+ async function ensureBrowser() {
28
+ if (page && browser && (browser.isConnected?.() ?? true))
29
+ return page;
30
+ let chromium;
31
+ try {
32
+ // Dynamic import — resolved at runtime so typecheck does not require
33
+ // the playwright package to live inside this tsconfig's rootDir.
34
+ const mod = await import('playwright');
35
+ chromium = mod.chromium ?? mod.default?.chromium;
36
+ if (!chromium || typeof chromium.launch !== 'function') {
37
+ throw new Error('playwright module shape unexpected (no chromium.launch)');
38
+ }
39
+ }
40
+ catch (err) {
41
+ throw new Error(`playwright is not available. Install with: pnpm add -w playwright && npx playwright install chromium. Underlying: ${err.message}`);
42
+ }
43
+ browser = await chromium.launch({
44
+ headless: true,
45
+ args: ['--no-sandbox', '--disable-dev-shm-usage'],
46
+ });
47
+ page = await browser.newPage();
48
+ return page;
49
+ }
50
+ function truncate(text, max = MAX_CONTENT_CHARS) {
51
+ if (text.length <= max)
52
+ return text;
53
+ return `${text.slice(0, max)}\n\n[truncated: ${text.length - max} more chars]`;
54
+ }
55
+ function ok(data, content) {
56
+ return { content, data, isError: false };
57
+ }
58
+ function fail(content) {
59
+ return { content, isError: true };
60
+ }
61
+ async function doGoto(input) {
62
+ if (!input.url)
63
+ return fail('url required for goto');
64
+ const p = await ensureBrowser();
65
+ await p.goto(input.url, {
66
+ waitUntil: input.waitUntil ?? 'domcontentloaded',
67
+ timeout: input.timeoutMs ?? DEFAULT_TIMEOUT_MS,
68
+ });
69
+ const title = await p.title().catch(() => '');
70
+ return ok({ action: 'goto', url: p.url(), title }, `navigated to ${p.url()}\ntitle: ${title || '(none)'}`);
71
+ }
72
+ async function doClick(input) {
73
+ if (!input.selector && !input.text) {
74
+ return fail('click requires selector or text');
75
+ }
76
+ const p = await ensureBrowser();
77
+ const timeout = input.timeoutMs ?? DEFAULT_TIMEOUT_MS;
78
+ if (input.selector) {
79
+ await p.click(input.selector, { timeout });
80
+ return ok({ action: 'click' }, `clicked selector: ${input.selector}`);
81
+ }
82
+ // Text-based click — pick the first match to avoid ambiguity.
83
+ const locator = p.getByText(input.text).first();
84
+ const count = await locator.count().catch(() => 0);
85
+ if (count === 0)
86
+ return fail(`no element contains text: ${input.text}`);
87
+ await locator.click({ timeout });
88
+ return ok({ action: 'click' }, `clicked text: ${input.text}`);
89
+ }
90
+ async function doScreenshot(input) {
91
+ const p = await ensureBrowser();
92
+ const outPath = input.path ?? join(SCREENSHOT_DIR, `shot-${Date.now()}.png`);
93
+ await mkdir(SCREENSHOT_DIR, { recursive: true }).catch(() => undefined);
94
+ await p.screenshot({ path: outPath, fullPage: input.fullPage ?? false });
95
+ return ok({ action: 'screenshot', path: outPath }, `screenshot saved: ${outPath}`);
96
+ }
97
+ async function doContent(input) {
98
+ const p = await ensureBrowser();
99
+ const text = await p.innerText('body').catch(async () => {
100
+ // Fallback to raw HTML stripped of tags if body isn't available yet.
101
+ const html = await p.content();
102
+ return html.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim();
103
+ });
104
+ const url = p.url();
105
+ const title = await p.title().catch(() => '');
106
+ const body = truncate(text);
107
+ return ok({ action: 'content', url, title }, `url: ${url}\ntitle: ${title}\n\n${body}`);
108
+ }
109
+ async function doClose() {
110
+ await closeBrowser();
111
+ return ok({ action: 'close' }, 'browser closed');
112
+ }
113
+ /**
114
+ * Shut down the browser instance and reset module state. Safe to call
115
+ * repeatedly; a no-op when no browser is running. The shell should call
116
+ * this from its exit handler so headless Chromium doesn't leak across
117
+ * process lifetimes.
118
+ */
119
+ export async function closeBrowser() {
120
+ const b = browser;
121
+ browser = undefined;
122
+ page = undefined;
123
+ if (!b)
124
+ return;
125
+ await b.close().catch(() => undefined);
126
+ }
127
+ export const browserTool = {
128
+ name: 'browser',
129
+ description: 'Control a headless Chromium browser. Actions: goto (url), click (selector or text), screenshot (path), content (returns page text), close. One page is kept alive across calls.',
130
+ inputSchema: {
131
+ type: 'object',
132
+ properties: {
133
+ action: {
134
+ type: 'string',
135
+ enum: ['goto', 'click', 'screenshot', 'content', 'close'],
136
+ },
137
+ url: { type: 'string', description: 'Target URL for goto.' },
138
+ selector: { type: 'string', description: 'CSS selector for click.' },
139
+ text: { type: 'string', description: 'Visible text for click fallback.' },
140
+ path: { type: 'string', description: 'Output path for screenshot.' },
141
+ fullPage: { type: 'boolean', description: 'Whole-page screenshot.' },
142
+ timeoutMs: { type: 'integer', minimum: 1000 },
143
+ waitUntil: {
144
+ type: 'string',
145
+ enum: ['load', 'domcontentloaded', 'networkidle'],
146
+ },
147
+ },
148
+ required: ['action'],
149
+ },
150
+ requiresApproval: (raw) => {
151
+ const input = raw;
152
+ // Approve network-touching or filesystem-writing actions. `content`
153
+ // and `close` reuse the already-approved page so they don't.
154
+ return input.action === 'goto' || input.action === 'screenshot';
155
+ },
156
+ async execute(rawInput, _ctx) {
157
+ const input = rawInput;
158
+ if (!input || typeof input.action !== 'string') {
159
+ return fail('action required');
160
+ }
161
+ try {
162
+ switch (input.action) {
163
+ case 'goto': return await doGoto(input);
164
+ case 'click': return await doClick(input);
165
+ case 'screenshot': return await doScreenshot(input);
166
+ case 'content': return await doContent(input);
167
+ case 'close': return await doClose();
168
+ default: return fail(`unknown action: ${String(input.action)}`);
169
+ }
170
+ }
171
+ catch (err) {
172
+ return fail(`browser ${input.action} failed: ${err.message}`);
173
+ }
174
+ },
175
+ };
176
+ // Silence unused-var warnings for the tmp dir import even if unused.
177
+ void tmpdir;
178
+ export default browserTool;
179
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Session checkpoint tool.
3
+ *
4
+ * Snapshots the current session (messages + cwd + timestamp) into
5
+ * `~/.dirgha/checkpoints/<sessionId>-<timestamp>.json` so a user can
6
+ * rewind to a known-good agent state. The v1 checkpoint tool used a
7
+ * shadow-git bare repo to snapshot project files on disk; v2 inverts
8
+ * that — the session log is the source of truth, so we snapshot the
9
+ * *conversation* and leave filesystem state to the user's own VCS.
10
+ *
11
+ * Subcommands:
12
+ * save — write a snapshot file, returns its id.
13
+ * restore — load a snapshot and re-emit its messages into the
14
+ * active session log as system entries so later replay
15
+ * picks them up. Does NOT rewrite history in place.
16
+ * list — enumerate snapshots for the active session, or all.
17
+ * delete — remove a snapshot file by id.
18
+ *
19
+ * Note: restore is additive (appends the snapshot back onto the live
20
+ * session log). The kernel decides whether to prune older turns on a
21
+ * subsequent compaction — we don't truncate files here.
22
+ */
23
+ import type { Tool } from './registry.js';
24
+ export declare const checkpointTool: Tool;
25
+ export default checkpointTool;