@di-code/coding-agent 0.1.7 → 0.1.8

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 (333) hide show
  1. package/README.md +104 -46
  2. package/compositions/base.yml +54 -0
  3. package/compositions/interactive.yml +14 -0
  4. package/compositions/json.yml +6 -0
  5. package/compositions/print.yml +5 -0
  6. package/compositions/rpc.yml +12 -0
  7. package/compositions/webui.yml +9 -0
  8. package/dist/cli.d.ts +22 -1
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/cli.js +97 -3
  11. package/dist/cli.js.map +1 -1
  12. package/dist/composition-loader-entry.d.ts +11 -0
  13. package/dist/composition-loader-entry.d.ts.map +1 -0
  14. package/dist/composition-loader-entry.js +12 -0
  15. package/dist/composition-loader-entry.js.map +1 -0
  16. package/dist/compositions.d.ts +32 -0
  17. package/dist/compositions.d.ts.map +1 -0
  18. package/dist/compositions.js +173 -0
  19. package/dist/compositions.js.map +1 -0
  20. package/dist/core/session/session-manager.d.ts +9 -2
  21. package/dist/core/session/session-manager.d.ts.map +1 -1
  22. package/dist/core/session/session-manager.js +28 -0
  23. package/dist/core/session/session-manager.js.map +1 -1
  24. package/dist/core/session/session-storage.d.ts.map +1 -1
  25. package/dist/core/session/session-storage.js +20 -3
  26. package/dist/core/session/session-storage.js.map +1 -1
  27. package/dist/core/session/types.d.ts +11 -2
  28. package/dist/core/session/types.d.ts.map +1 -1
  29. package/dist/core/session/types.js.map +1 -1
  30. package/dist/core/session-tools.d.ts +5 -0
  31. package/dist/core/session-tools.d.ts.map +1 -0
  32. package/dist/core/session-tools.js +17 -0
  33. package/dist/core/session-tools.js.map +1 -0
  34. package/dist/core/session.d.ts +19 -7
  35. package/dist/core/session.d.ts.map +1 -1
  36. package/dist/core/session.js +71 -39
  37. package/dist/core/session.js.map +1 -1
  38. package/dist/core/tools/bash.d.ts +1 -38
  39. package/dist/core/tools/bash.d.ts.map +1 -1
  40. package/dist/core/tools/bash.js +1 -207
  41. package/dist/core/tools/bash.js.map +1 -1
  42. package/dist/core/tools/edit-diff.d.ts +1 -24
  43. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  44. package/dist/core/tools/edit-diff.js +1 -135
  45. package/dist/core/tools/edit-diff.js.map +1 -1
  46. package/dist/core/tools/edit.d.ts +1 -26
  47. package/dist/core/tools/edit.d.ts.map +1 -1
  48. package/dist/core/tools/edit.js +1 -140
  49. package/dist/core/tools/edit.js.map +1 -1
  50. package/dist/core/tools/file-mutation-queue.d.ts +1 -1
  51. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  52. package/dist/core/tools/file-mutation-queue.js +1 -23
  53. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  54. package/dist/core/tools/file-search.d.ts +1 -13
  55. package/dist/core/tools/file-search.d.ts.map +1 -1
  56. package/dist/core/tools/file-search.js +1 -98
  57. package/dist/core/tools/file-search.js.map +1 -1
  58. package/dist/core/tools/glob.d.ts +1 -10
  59. package/dist/core/tools/glob.d.ts.map +1 -1
  60. package/dist/core/tools/glob.js +1 -43
  61. package/dist/core/tools/glob.js.map +1 -1
  62. package/dist/core/tools/grep.d.ts +1 -12
  63. package/dist/core/tools/grep.d.ts.map +1 -1
  64. package/dist/core/tools/grep.js +1 -66
  65. package/dist/core/tools/grep.js.map +1 -1
  66. package/dist/core/tools/load-skill.d.ts +1 -9
  67. package/dist/core/tools/load-skill.d.ts.map +1 -1
  68. package/dist/core/tools/load-skill.js +1 -21
  69. package/dist/core/tools/load-skill.js.map +1 -1
  70. package/dist/core/tools/path-boundary.d.ts +1 -4
  71. package/dist/core/tools/path-boundary.d.ts.map +1 -1
  72. package/dist/core/tools/path-boundary.js +1 -65
  73. package/dist/core/tools/path-boundary.js.map +1 -1
  74. package/dist/core/tools/read.d.ts +1 -16
  75. package/dist/core/tools/read.d.ts.map +1 -1
  76. package/dist/core/tools/read.js +1 -131
  77. package/dist/core/tools/read.js.map +1 -1
  78. package/dist/core/tools/write.d.ts +1 -16
  79. package/dist/core/tools/write.d.ts.map +1 -1
  80. package/dist/core/tools/write.js +1 -44
  81. package/dist/core/tools/write.js.map +1 -1
  82. package/dist/entry.js +30 -28
  83. package/dist/entry.js.map +1 -1
  84. package/dist/index.d.ts +6 -3
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +6 -3
  87. package/dist/index.js.map +1 -1
  88. package/dist/interactive/builtin.d.ts +17 -0
  89. package/dist/interactive/builtin.d.ts.map +1 -0
  90. package/dist/interactive/builtin.js +47 -0
  91. package/dist/interactive/builtin.js.map +1 -0
  92. package/dist/interactive/controller.d.ts +85 -0
  93. package/dist/interactive/controller.d.ts.map +1 -0
  94. package/dist/interactive/controller.js +211 -0
  95. package/dist/interactive/controller.js.map +1 -0
  96. package/dist/interactive/index.d.ts +3 -0
  97. package/dist/interactive/index.d.ts.map +1 -0
  98. package/dist/interactive/index.js +3 -0
  99. package/dist/interactive/index.js.map +1 -0
  100. package/dist/interactive-host-entry.d.ts +7 -0
  101. package/dist/interactive-host-entry.d.ts.map +1 -0
  102. package/dist/interactive-host-entry.js +123 -0
  103. package/dist/interactive-host-entry.js.map +1 -0
  104. package/dist/interactive-profile.d.ts +18 -0
  105. package/dist/interactive-profile.d.ts.map +1 -0
  106. package/dist/interactive-profile.js +290 -0
  107. package/dist/interactive-profile.js.map +1 -0
  108. package/dist/interactive-resources-entry.d.ts +7 -0
  109. package/dist/interactive-resources-entry.d.ts.map +1 -0
  110. package/dist/interactive-resources-entry.js +42 -0
  111. package/dist/interactive-resources-entry.js.map +1 -0
  112. package/dist/legacy-main.d.ts +39 -0
  113. package/dist/legacy-main.d.ts.map +1 -0
  114. package/dist/legacy-main.js +611 -0
  115. package/dist/legacy-main.js.map +1 -0
  116. package/dist/main.d.ts +15 -34
  117. package/dist/main.d.ts.map +1 -1
  118. package/dist/main.js +130 -518
  119. package/dist/main.js.map +1 -1
  120. package/dist/mcp/entries.d.ts +42 -0
  121. package/dist/mcp/entries.d.ts.map +1 -0
  122. package/dist/mcp/entries.js +98 -0
  123. package/dist/mcp/entries.js.map +1 -0
  124. package/dist/mcp-client-entry.d.ts +5 -0
  125. package/dist/mcp-client-entry.d.ts.map +1 -0
  126. package/dist/mcp-client-entry.js +6 -0
  127. package/dist/mcp-client-entry.js.map +1 -0
  128. package/dist/mcp-config-entry.d.ts +5 -0
  129. package/dist/mcp-config-entry.d.ts.map +1 -0
  130. package/dist/mcp-config-entry.js +6 -0
  131. package/dist/mcp-config-entry.js.map +1 -0
  132. package/dist/mcp-tools-entry.d.ts +5 -0
  133. package/dist/mcp-tools-entry.d.ts.map +1 -0
  134. package/dist/mcp-tools-entry.js +6 -0
  135. package/dist/mcp-tools-entry.js.map +1 -0
  136. package/dist/mcp-transport-entry.d.ts +5 -0
  137. package/dist/mcp-transport-entry.d.ts.map +1 -0
  138. package/dist/mcp-transport-entry.js +6 -0
  139. package/dist/mcp-transport-entry.js.map +1 -0
  140. package/dist/modes/interactive-entry.d.ts +18 -0
  141. package/dist/modes/interactive-entry.d.ts.map +1 -0
  142. package/dist/modes/interactive-entry.js +21 -0
  143. package/dist/modes/interactive-entry.js.map +1 -0
  144. package/dist/modes/interactive.d.ts +16 -6
  145. package/dist/modes/interactive.d.ts.map +1 -1
  146. package/dist/modes/interactive.js +81 -32
  147. package/dist/modes/interactive.js.map +1 -1
  148. package/dist/modes/json-entry.d.ts +13 -0
  149. package/dist/modes/json-entry.d.ts.map +1 -0
  150. package/dist/modes/json-entry.js +14 -0
  151. package/dist/modes/json-entry.js.map +1 -0
  152. package/dist/modes/json.d.ts +4 -1
  153. package/dist/modes/json.d.ts.map +1 -1
  154. package/dist/modes/json.js +3 -3
  155. package/dist/modes/json.js.map +1 -1
  156. package/dist/modes/print-entry.d.ts +10 -0
  157. package/dist/modes/print-entry.d.ts.map +1 -0
  158. package/dist/modes/print-entry.js +11 -0
  159. package/dist/modes/print-entry.js.map +1 -0
  160. package/dist/modes/tree-selector.d.ts.map +1 -1
  161. package/dist/modes/tree-selector.js +4 -0
  162. package/dist/modes/tree-selector.js.map +1 -1
  163. package/dist/plugin-dump-composition.d.ts +6 -0
  164. package/dist/plugin-dump-composition.d.ts.map +1 -0
  165. package/dist/plugin-dump-composition.js +7 -0
  166. package/dist/plugin-dump-composition.js.map +1 -0
  167. package/dist/plugin-inventory.d.ts +7 -0
  168. package/dist/plugin-inventory.d.ts.map +1 -0
  169. package/dist/plugin-inventory.js +8 -0
  170. package/dist/plugin-inventory.js.map +1 -0
  171. package/dist/plugin-manager.d.ts +6 -0
  172. package/dist/plugin-manager.d.ts.map +1 -0
  173. package/dist/plugin-manager.js +7 -0
  174. package/dist/plugin-manager.js.map +1 -0
  175. package/dist/plugin-trace.d.ts +6 -0
  176. package/dist/plugin-trace.d.ts.map +1 -0
  177. package/dist/plugin-trace.js +7 -0
  178. package/dist/plugin-trace.js.map +1 -0
  179. package/dist/plugins/dynamic-broker.d.ts +76 -0
  180. package/dist/plugins/dynamic-broker.d.ts.map +1 -0
  181. package/dist/plugins/dynamic-broker.js +852 -0
  182. package/dist/plugins/dynamic-broker.js.map +1 -0
  183. package/dist/plugins/profile.d.ts +15 -0
  184. package/dist/plugins/profile.d.ts.map +1 -0
  185. package/dist/plugins/profile.js +34 -0
  186. package/dist/plugins/profile.js.map +1 -0
  187. package/dist/plugins/runtime-host.d.ts +37 -0
  188. package/dist/plugins/runtime-host.d.ts.map +1 -0
  189. package/dist/plugins/runtime-host.js +95 -0
  190. package/dist/plugins/runtime-host.js.map +1 -0
  191. package/dist/plugins/trust.d.ts +8 -0
  192. package/dist/plugins/trust.d.ts.map +1 -0
  193. package/dist/plugins/trust.js +59 -0
  194. package/dist/plugins/trust.js.map +1 -0
  195. package/dist/project-trust-entry.d.ts +15 -0
  196. package/dist/project-trust-entry.d.ts.map +1 -0
  197. package/dist/project-trust-entry.js +15 -0
  198. package/dist/project-trust-entry.js.map +1 -0
  199. package/dist/rpc/client.d.ts +78 -6
  200. package/dist/rpc/client.d.ts.map +1 -1
  201. package/dist/rpc/client.js +172 -4
  202. package/dist/rpc/client.js.map +1 -1
  203. package/dist/rpc/dispatcher.d.ts +121 -0
  204. package/dist/rpc/dispatcher.d.ts.map +1 -0
  205. package/dist/rpc/dispatcher.js +994 -0
  206. package/dist/rpc/dispatcher.js.map +1 -0
  207. package/dist/rpc/index.d.ts +2 -0
  208. package/dist/rpc/index.d.ts.map +1 -1
  209. package/dist/rpc/index.js +2 -0
  210. package/dist/rpc/index.js.map +1 -1
  211. package/dist/rpc/lifecycle.d.ts +6 -0
  212. package/dist/rpc/lifecycle.d.ts.map +1 -0
  213. package/dist/rpc/lifecycle.js +24 -0
  214. package/dist/rpc/lifecycle.js.map +1 -0
  215. package/dist/rpc/protocol.d.ts +112 -31
  216. package/dist/rpc/protocol.d.ts.map +1 -1
  217. package/dist/rpc/protocol.js +569 -117
  218. package/dist/rpc/protocol.js.map +1 -1
  219. package/dist/rpc/server-service.d.ts +7 -0
  220. package/dist/rpc/server-service.d.ts.map +1 -0
  221. package/dist/rpc/server-service.js +3 -0
  222. package/dist/rpc/server-service.js.map +1 -0
  223. package/dist/rpc/server.d.ts +16 -19
  224. package/dist/rpc/server.d.ts.map +1 -1
  225. package/dist/rpc/server.js +59 -115
  226. package/dist/rpc/server.js.map +1 -1
  227. package/dist/rpc-client-sdk-entry.d.ts +12 -0
  228. package/dist/rpc-client-sdk-entry.d.ts.map +1 -0
  229. package/dist/rpc-client-sdk-entry.js +11 -0
  230. package/dist/rpc-client-sdk-entry.js.map +1 -0
  231. package/dist/rpc-entry.js +50 -18
  232. package/dist/rpc-entry.js.map +1 -1
  233. package/dist/rpc-server-entry.d.ts +8 -0
  234. package/dist/rpc-server-entry.d.ts.map +1 -0
  235. package/dist/rpc-server-entry.js +67 -0
  236. package/dist/rpc-server-entry.js.map +1 -0
  237. package/dist/runtime/attachment-store.d.ts +13 -0
  238. package/dist/runtime/attachment-store.d.ts.map +1 -0
  239. package/dist/runtime/attachment-store.js +93 -0
  240. package/dist/runtime/attachment-store.js.map +1 -0
  241. package/dist/runtime/bootstrap.d.ts +14 -0
  242. package/dist/runtime/bootstrap.d.ts.map +1 -0
  243. package/dist/runtime/bootstrap.js +29 -0
  244. package/dist/runtime/bootstrap.js.map +1 -0
  245. package/dist/runtime/interactive-host-service.d.ts +22 -0
  246. package/dist/runtime/interactive-host-service.d.ts.map +1 -0
  247. package/dist/runtime/interactive-host-service.js +2 -0
  248. package/dist/runtime/interactive-host-service.js.map +1 -0
  249. package/dist/runtime/interactive-resource-service.d.ts +11 -0
  250. package/dist/runtime/interactive-resource-service.d.ts.map +1 -0
  251. package/dist/runtime/interactive-resource-service.js +3 -0
  252. package/dist/runtime/interactive-resource-service.js.map +1 -0
  253. package/dist/runtime/plugin-inventory-entry.d.ts +5 -0
  254. package/dist/runtime/plugin-inventory-entry.d.ts.map +1 -0
  255. package/dist/runtime/plugin-inventory-entry.js +18 -0
  256. package/dist/runtime/plugin-inventory-entry.js.map +1 -0
  257. package/dist/runtime/plugin-inventory-service.d.ts +8 -0
  258. package/dist/runtime/plugin-inventory-service.d.ts.map +1 -0
  259. package/dist/runtime/plugin-inventory-service.js +3 -0
  260. package/dist/runtime/plugin-inventory-service.js.map +1 -0
  261. package/dist/runtime/plugin-manager-entry.d.ts +20 -0
  262. package/dist/runtime/plugin-manager-entry.d.ts.map +1 -0
  263. package/dist/runtime/plugin-manager-entry.js +96 -0
  264. package/dist/runtime/plugin-manager-entry.js.map +1 -0
  265. package/dist/runtime/plugin-observability-entry.d.ts +12 -0
  266. package/dist/runtime/plugin-observability-entry.d.ts.map +1 -0
  267. package/dist/runtime/plugin-observability-entry.js +73 -0
  268. package/dist/runtime/plugin-observability-entry.js.map +1 -0
  269. package/dist/runtime/product-host.d.ts +91 -0
  270. package/dist/runtime/product-host.d.ts.map +1 -0
  271. package/dist/runtime/product-host.js +529 -0
  272. package/dist/runtime/product-host.js.map +1 -0
  273. package/dist/runtime/session-factory.d.ts +17 -0
  274. package/dist/runtime/session-factory.d.ts.map +1 -0
  275. package/dist/runtime/session-factory.js +75 -0
  276. package/dist/runtime/session-factory.js.map +1 -0
  277. package/dist/runtime/session-host.d.ts +152 -0
  278. package/dist/runtime/session-host.d.ts.map +1 -0
  279. package/dist/runtime/session-host.js +895 -0
  280. package/dist/runtime/session-host.js.map +1 -0
  281. package/dist/runtime-core-entry.d.ts +11 -0
  282. package/dist/runtime-core-entry.d.ts.map +1 -0
  283. package/dist/runtime-core-entry.js +9 -0
  284. package/dist/runtime-core-entry.js.map +1 -0
  285. package/dist/session-factory-entry.d.ts +7 -0
  286. package/dist/session-factory-entry.d.ts.map +1 -0
  287. package/dist/session-factory-entry.js +9 -0
  288. package/dist/session-factory-entry.js.map +1 -0
  289. package/dist/session-store-jsonl-entry.d.ts +7 -0
  290. package/dist/session-store-jsonl-entry.d.ts.map +1 -0
  291. package/dist/session-store-jsonl-entry.js +33 -0
  292. package/dist/session-store-jsonl-entry.js.map +1 -0
  293. package/dist/startup.d.ts +12 -1
  294. package/dist/startup.d.ts.map +1 -1
  295. package/dist/startup.js +106 -15
  296. package/dist/startup.js.map +1 -1
  297. package/dist/subagents/index.d.ts +2 -0
  298. package/dist/subagents/index.d.ts.map +1 -0
  299. package/dist/subagents/index.js +2 -0
  300. package/dist/subagents/index.js.map +1 -0
  301. package/dist/subagents/service.d.ts +50 -0
  302. package/dist/subagents/service.d.ts.map +1 -0
  303. package/dist/subagents/service.js +521 -0
  304. package/dist/subagents/service.js.map +1 -0
  305. package/dist/ui-host.d.ts +125 -0
  306. package/dist/ui-host.d.ts.map +1 -0
  307. package/dist/ui-host.js +275 -0
  308. package/dist/ui-host.js.map +1 -0
  309. package/dist/web/assets/index-BwfuGMvv.css +1 -0
  310. package/dist/web/assets/index-DPUaJqFJ.js +41 -0
  311. package/dist/web/assets/index-DPUaJqFJ.js.map +1 -0
  312. package/dist/web/index.html +14 -0
  313. package/dist/web-command.d.ts +11 -0
  314. package/dist/web-command.d.ts.map +1 -0
  315. package/dist/web-command.js +114 -0
  316. package/dist/web-command.js.map +1 -0
  317. package/dist/web-frontend.d.ts +73 -0
  318. package/dist/web-frontend.d.ts.map +1 -0
  319. package/dist/web-frontend.js +249 -0
  320. package/dist/web-frontend.js.map +1 -0
  321. package/dist/web.d.ts +254 -0
  322. package/dist/web.d.ts.map +1 -0
  323. package/dist/web.js +740 -0
  324. package/dist/web.js.map +1 -0
  325. package/dist/webui-entry.d.ts +3 -0
  326. package/dist/webui-entry.d.ts.map +1 -0
  327. package/dist/webui-entry.js +73 -0
  328. package/dist/webui-entry.js.map +1 -0
  329. package/dist/webui.d.ts +91 -0
  330. package/dist/webui.d.ts.map +1 -0
  331. package/dist/webui.js +882 -0
  332. package/dist/webui.js.map +1 -0
  333. package/package.json +89 -8
@@ -1,132 +1,2 @@
1
- import { readFile } from "node:fs/promises";
2
- import { Type } from "@di-code/ai";
3
- import { resolveAllowedFilePath } from "./path-boundary.js";
4
- export const DEFAULT_READ_MAX_LINES = 2_000;
5
- export const DEFAULT_READ_MAX_BYTES = 50 * 1024;
6
- export const readParameters = Type.Object({
7
- path: Type.String({ minLength: 1 }),
8
- offset: Type.Optional(Type.Integer({ minimum: 1 })),
9
- limit: Type.Optional(Type.Integer({ minimum: 1 })),
10
- });
11
- function assertPositiveInteger(name, value) {
12
- if (value !== undefined && (!Number.isInteger(value) || value < 1)) {
13
- throw new Error(`${name} must be a positive integer`);
14
- }
15
- }
16
- function splitLines(text) {
17
- if (text.length === 0)
18
- return [];
19
- const lines = text.split("\n");
20
- if (text.endsWith("\n"))
21
- lines.pop();
22
- return lines;
23
- }
24
- function selectUserWindow(lines, offset, limit) {
25
- if (lines.length === 0) {
26
- if (offset > 1)
27
- throw new Error(`Offset ${offset} is beyond end of file (0 lines total)`);
28
- return { content: "", startLine: 1, endLine: 0, totalLines: 0, truncatedBy: null };
29
- }
30
- const startIndex = offset - 1;
31
- if (startIndex >= lines.length) {
32
- throw new Error(`Offset ${offset} is beyond end of file (${lines.length} lines total)`);
33
- }
34
- const available = lines.slice(startIndex);
35
- const selected = limit === undefined ? available : available.slice(0, limit);
36
- const endLine = offset + selected.length - 1;
37
- return {
38
- content: selected.join("\n"),
39
- startLine: offset,
40
- endLine,
41
- totalLines: lines.length,
42
- truncatedBy: limit !== undefined && selected.length < available.length ? "limit" : null,
43
- };
44
- }
45
- function applyOutputLimits(window, maxLines, maxBytes) {
46
- if (window.content === "")
47
- return window;
48
- const lines = window.content.split("\n");
49
- const selected = [];
50
- let bytes = 0;
51
- let truncatedBy = null;
52
- for (const line of lines) {
53
- if (selected.length >= maxLines) {
54
- truncatedBy = "lines";
55
- break;
56
- }
57
- const separatorBytes = selected.length === 0 ? 0 : 1;
58
- const nextBytes = bytes + separatorBytes + Buffer.byteLength(line, "utf8");
59
- if (nextBytes > maxBytes) {
60
- if (selected.length === 0)
61
- throw new Error("A single line exceeds the read byte limit");
62
- truncatedBy = "bytes";
63
- break;
64
- }
65
- selected.push(line);
66
- bytes = nextBytes;
67
- }
68
- if (truncatedBy === null && selected.length < lines.length)
69
- truncatedBy = "lines";
70
- if (truncatedBy === null)
71
- return window;
72
- return {
73
- ...window,
74
- content: selected.join("\n"),
75
- endLine: window.startLine + selected.length - 1,
76
- truncatedBy,
77
- };
78
- }
79
- function formatByteLimit(maxBytes) {
80
- if (maxBytes % 1024 === 0)
81
- return `${maxBytes / 1024} KiB`;
82
- return `${maxBytes} bytes`;
83
- }
84
- function appendContinuation(window, maxBytes) {
85
- if (window.truncatedBy === null)
86
- return window.content;
87
- const nextOffset = window.endLine + 1;
88
- if (window.truncatedBy === "limit") {
89
- const remaining = window.totalLines - window.endLine;
90
- return `${window.content}\n\n[${remaining} more lines in file. Use offset=${nextOffset} to continue.]`;
91
- }
92
- const reason = window.truncatedBy === "bytes" ? ` (${formatByteLimit(maxBytes)} limit)` : "";
93
- return `${window.content}\n\n[Showing lines ${window.startLine}-${window.endLine} of ${window.totalLines}${reason}. Use offset=${nextOffset} to continue.]`;
94
- }
95
- function containsNulByte(buffer) {
96
- const sampleLength = Math.min(buffer.length, 8 * 1024);
97
- for (let index = 0; index < sampleLength; index++) {
98
- if (buffer[index] === 0)
99
- return true;
100
- }
101
- return false;
102
- }
103
- export function createReadTool(allowedRoot, options = {}) {
104
- const maxLines = options.maxLines ?? DEFAULT_READ_MAX_LINES;
105
- const maxBytes = options.maxBytes ?? DEFAULT_READ_MAX_BYTES;
106
- assertPositiveInteger("maxLines", maxLines);
107
- assertPositiveInteger("maxBytes", maxBytes);
108
- return {
109
- name: "read",
110
- description: "Read a UTF-8 text file inside the allowed root. Use offset and limit for large files.",
111
- parameters: readParameters,
112
- async execute(_toolCallId, parameters, signal) {
113
- if (signal?.aborted)
114
- throw new Error("Operation aborted");
115
- if (parameters.path.length === 0)
116
- throw new Error("path must not be empty");
117
- assertPositiveInteger("offset", parameters.offset);
118
- assertPositiveInteger("limit", parameters.limit);
119
- const absolutePath = await resolveAllowedFilePath(parameters.path, allowedRoot);
120
- if (signal?.aborted)
121
- throw new Error("Operation aborted");
122
- const buffer = await readFile(absolutePath);
123
- if (containsNulByte(buffer)) {
124
- throw new Error("Binary files are not supported by read");
125
- }
126
- const userWindow = selectUserWindow(splitLines(buffer.toString("utf8")), parameters.offset ?? 1, parameters.limit);
127
- const boundedWindow = applyOutputLimits(userWindow, maxLines, maxBytes);
128
- return [{ type: "text", text: appendContinuation(boundedWindow, maxBytes) }];
129
- },
130
- };
131
- }
1
+ export * from "@di-code/builtins";
132
2
  //# sourceMappingURL=read.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAuC,IAAI,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAC5C,MAAM,CAAC,MAAM,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File } from \"node:fs/promises\";\nimport type { AgentTool } from \"@di-code/agent\";\nimport { type Static, type ToolResultContent, Type } from \"@di-code/ai\";\nimport { resolveAllowedFilePath } from \"./path-boundary.ts\";\n\nexport const DEFAULT_READ_MAX_LINES = 2_000;\nexport const DEFAULT_READ_MAX_BYTES = 50 * 1024;\n\nexport const readParameters = Type.Object({\n\tpath: Type.String({ minLength: 1 }),\n\toffset: Type.Optional(Type.Integer({ minimum: 1 })),\n\tlimit: Type.Optional(Type.Integer({ minimum: 1 })),\n});\n\nexport type ReadParameters = Static<typeof readParameters>;\n\nexport interface ReadToolOptions {\n\treadonly maxLines?: number;\n\treadonly maxBytes?: number;\n}\n\nexport type ReadTool = AgentTool<typeof readParameters, ToolResultContent[]>;\n\ninterface TextWindow {\n\treadonly content: string;\n\treadonly startLine: number;\n\treadonly endLine: number;\n\treadonly totalLines: number;\n\treadonly truncatedBy: \"limit\" | \"lines\" | \"bytes\" | null;\n}\n\nfunction assertPositiveInteger(name: string, value: number | undefined): void {\n\tif (value !== undefined && (!Number.isInteger(value) || value < 1)) {\n\t\tthrow new Error(`${name} must be a positive integer`);\n\t}\n}\n\nfunction splitLines(text: string): string[] {\n\tif (text.length === 0) return [];\n\tconst lines = text.split(\"\\n\");\n\tif (text.endsWith(\"\\n\")) lines.pop();\n\treturn lines;\n}\n\nfunction selectUserWindow(lines: readonly string[], offset: number, limit: number | undefined): TextWindow {\n\tif (lines.length === 0) {\n\t\tif (offset > 1) throw new Error(`Offset ${offset} is beyond end of file (0 lines total)`);\n\t\treturn { content: \"\", startLine: 1, endLine: 0, totalLines: 0, truncatedBy: null };\n\t}\n\n\tconst startIndex = offset - 1;\n\tif (startIndex >= lines.length) {\n\t\tthrow new Error(`Offset ${offset} is beyond end of file (${lines.length} lines total)`);\n\t}\n\n\tconst available = lines.slice(startIndex);\n\tconst selected = limit === undefined ? available : available.slice(0, limit);\n\tconst endLine = offset + selected.length - 1;\n\treturn {\n\t\tcontent: selected.join(\"\\n\"),\n\t\tstartLine: offset,\n\t\tendLine,\n\t\ttotalLines: lines.length,\n\t\ttruncatedBy: limit !== undefined && selected.length < available.length ? \"limit\" : null,\n\t};\n}\n\nfunction applyOutputLimits(window: TextWindow, maxLines: number, maxBytes: number): TextWindow {\n\tif (window.content === \"\") return window;\n\tconst lines = window.content.split(\"\\n\");\n\tconst selected: string[] = [];\n\tlet bytes = 0;\n\tlet truncatedBy: \"lines\" | \"bytes\" | null = null;\n\n\tfor (const line of lines) {\n\t\tif (selected.length >= maxLines) {\n\t\t\ttruncatedBy = \"lines\";\n\t\t\tbreak;\n\t\t}\n\t\tconst separatorBytes = selected.length === 0 ? 0 : 1;\n\t\tconst nextBytes = bytes + separatorBytes + Buffer.byteLength(line, \"utf8\");\n\t\tif (nextBytes > maxBytes) {\n\t\t\tif (selected.length === 0) throw new Error(\"A single line exceeds the read byte limit\");\n\t\t\ttruncatedBy = \"bytes\";\n\t\t\tbreak;\n\t\t}\n\t\tselected.push(line);\n\t\tbytes = nextBytes;\n\t}\n\n\tif (truncatedBy === null && selected.length < lines.length) truncatedBy = \"lines\";\n\tif (truncatedBy === null) return window;\n\treturn {\n\t\t...window,\n\t\tcontent: selected.join(\"\\n\"),\n\t\tendLine: window.startLine + selected.length - 1,\n\t\ttruncatedBy,\n\t};\n}\n\nfunction formatByteLimit(maxBytes: number): string {\n\tif (maxBytes % 1024 === 0) return `${maxBytes / 1024} KiB`;\n\treturn `${maxBytes} bytes`;\n}\n\nfunction appendContinuation(window: TextWindow, maxBytes: number): string {\n\tif (window.truncatedBy === null) return window.content;\n\tconst nextOffset = window.endLine + 1;\n\tif (window.truncatedBy === \"limit\") {\n\t\tconst remaining = window.totalLines - window.endLine;\n\t\treturn `${window.content}\\n\\n[${remaining} more lines in file. Use offset=${nextOffset} to continue.]`;\n\t}\n\tconst reason = window.truncatedBy === \"bytes\" ? ` (${formatByteLimit(maxBytes)} limit)` : \"\";\n\treturn `${window.content}\\n\\n[Showing lines ${window.startLine}-${window.endLine} of ${window.totalLines}${reason}. Use offset=${nextOffset} to continue.]`;\n}\n\nfunction containsNulByte(buffer: Buffer): boolean {\n\tconst sampleLength = Math.min(buffer.length, 8 * 1024);\n\tfor (let index = 0; index < sampleLength; index++) {\n\t\tif (buffer[index] === 0) return true;\n\t}\n\treturn false;\n}\n\nexport function createReadTool(allowedRoot: string, options: ReadToolOptions = {}): ReadTool {\n\tconst maxLines = options.maxLines ?? DEFAULT_READ_MAX_LINES;\n\tconst maxBytes = options.maxBytes ?? DEFAULT_READ_MAX_BYTES;\n\tassertPositiveInteger(\"maxLines\", maxLines);\n\tassertPositiveInteger(\"maxBytes\", maxBytes);\n\n\treturn {\n\t\tname: \"read\",\n\t\tdescription: \"Read a UTF-8 text file inside the allowed root. Use offset and limit for large files.\",\n\t\tparameters: readParameters,\n\t\tasync execute(_toolCallId, parameters, signal): Promise<ToolResultContent[]> {\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tif (parameters.path.length === 0) throw new Error(\"path must not be empty\");\n\t\t\tassertPositiveInteger(\"offset\", parameters.offset);\n\t\t\tassertPositiveInteger(\"limit\", parameters.limit);\n\t\t\tconst absolutePath = await resolveAllowedFilePath(parameters.path, allowedRoot);\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tconst buffer = await readFile(absolutePath);\n\t\t\tif (containsNulByte(buffer)) {\n\t\t\t\tthrow new Error(\"Binary files are not supported by read\");\n\t\t\t}\n\t\t\tconst userWindow = selectUserWindow(\n\t\t\t\tsplitLines(buffer.toString(\"utf8\")),\n\t\t\t\tparameters.offset ?? 1,\n\t\t\t\tparameters.limit,\n\t\t\t);\n\t\t\tconst boundedWindow = applyOutputLimits(userWindow, maxLines, maxBytes);\n\t\t\treturn [{ type: \"text\", text: appendContinuation(boundedWindow, maxBytes) }];\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC","sourcesContent":["export * from \"@di-code/builtins\";\n"]}
@@ -1,17 +1,2 @@
1
- import type { AgentTool } from "@di-code/agent";
2
- import { type Static, type ToolResultContent, Type } from "@di-code/ai";
3
- export declare const writeParameters: Type.TObject<{
4
- path: Type.TString;
5
- content: Type.TString;
6
- }>;
7
- export type WriteParameters = Static<typeof writeParameters>;
8
- export interface WriteOperations {
9
- mkdir(directory: string): Promise<void>;
10
- writeFile(filePath: string, content: string): Promise<void>;
11
- }
12
- export interface WriteToolOptions {
13
- readonly operations?: WriteOperations;
14
- }
15
- export type WriteTool = AgentTool<typeof writeParameters, ToolResultContent[]>;
16
- export declare function createWriteTool(allowedRoot: string, options?: WriteToolOptions): WriteTool;
1
+ export * from "@di-code/builtins";
17
2
  //# sourceMappingURL=write.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAIxE,eAAO,MAAM,eAAe;;;EAG1B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAE7D,MAAM,WAAW,eAAe;IAC/B,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC;CACtC;AAED,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,eAAe,EAAE,iBAAiB,EAAE,CAAC,CAAC;AAe/E,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,SAAS,CAwB9F"}
1
+ {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -1,45 +1,2 @@
1
- import { mkdir as fsMkdir, writeFile as fsWriteFile } from "node:fs/promises";
2
- import { dirname } from "node:path";
3
- import { Type } from "@di-code/ai";
4
- import { withFileMutationQueue } from "./file-mutation-queue.js";
5
- import { resolveAllowedMutationPath } from "./path-boundary.js";
6
- export const writeParameters = Type.Object({
7
- path: Type.String({ minLength: 1 }),
8
- content: Type.String(),
9
- });
10
- const defaultWriteOperations = {
11
- async mkdir(directory) {
12
- await fsMkdir(directory, { recursive: true });
13
- },
14
- async writeFile(filePath, content) {
15
- await fsWriteFile(filePath, content, "utf8");
16
- },
17
- };
18
- function throwIfAborted(signal) {
19
- if (signal?.aborted)
20
- throw new Error("Operation aborted");
21
- }
22
- export function createWriteTool(allowedRoot, options = {}) {
23
- const operations = options.operations ?? defaultWriteOperations;
24
- return {
25
- name: "write",
26
- description: "Create or completely overwrite a UTF-8 text file inside the allowed root.",
27
- parameters: writeParameters,
28
- async execute(_toolCallId, parameters, signal) {
29
- throwIfAborted(signal);
30
- if (parameters.path.length === 0)
31
- throw new Error("path must not be empty");
32
- const absolutePath = await resolveAllowedMutationPath(parameters.path, allowedRoot);
33
- return withFileMutationQueue(absolutePath, async () => {
34
- throwIfAborted(signal);
35
- await operations.mkdir(dirname(absolutePath));
36
- throwIfAborted(signal);
37
- await operations.writeFile(absolutePath, parameters.content);
38
- throwIfAborted(signal);
39
- const bytes = Buffer.byteLength(parameters.content, "utf8");
40
- return [{ type: "text", text: `Successfully wrote ${bytes} bytes to ${parameters.path}` }];
41
- });
42
- },
43
- };
44
- }
1
+ export * from "@di-code/builtins";
45
2
  //# sourceMappingURL=write.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"write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AC5C,cAAc,CAAC,MAAM,CAAC,CAAC;YACvB,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;YAC5E,MAAM,YAAY,GAAG,MAAM,0BAA0B,CAAC,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YAEpF,OAAO,qBAAqB,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;gBACrD,cAAc,CAAC,MAAM,CAAC,CAAC;gBACvB,MAAM,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;gBAC9C,cAAc,CAAC,MAAM,CAAC,CAAC;gBACvB,MAAM,UAAU,CAAC,SAAS,CAAC,YAAY,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;gBAC7D,cAAc,CAAC,MAAM,CAAC,CAAC;gBAEvB,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;gBAC5D,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAsB,KAAK,aAAa,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC5F,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { mkdir as fsMkdir, writeFile as fsWriteFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport type { AgentTool } from \"@di-code/agent\";\nimport { type Static, type ToolResultContent, Type } from \"@di-code/ai\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport { resolveAllowedMutationPath } from \"./path-boundary.ts\";\n\nexport const writeParameters = Type.Object({\n\tpath: Type.String({ minLength: 1 }),\n\tcontent: Type.String(),\n});\n\nexport type WriteParameters = Static<typeof writeParameters>;\n\nexport interface WriteOperations {\n\tmkdir(directory: string): Promise<void>;\n\twriteFile(filePath: string, content: string): Promise<void>;\n}\n\nexport interface WriteToolOptions {\n\treadonly operations?: WriteOperations;\n}\n\nexport type WriteTool = AgentTool<typeof writeParameters, ToolResultContent[]>;\n\nconst defaultWriteOperations: WriteOperations = {\n\tasync mkdir(directory) {\n\t\tawait fsMkdir(directory, { recursive: true });\n\t},\n\tasync writeFile(filePath, content) {\n\t\tawait fsWriteFile(filePath, content, \"utf8\");\n\t},\n};\n\nfunction throwIfAborted(signal: AbortSignal | undefined): void {\n\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n}\n\nexport function createWriteTool(allowedRoot: string, options: WriteToolOptions = {}): WriteTool {\n\tconst operations = options.operations ?? defaultWriteOperations;\n\n\treturn {\n\t\tname: \"write\",\n\t\tdescription: \"Create or completely overwrite a UTF-8 text file inside the allowed root.\",\n\t\tparameters: writeParameters,\n\t\tasync execute(_toolCallId, parameters, signal): Promise<ToolResultContent[]> {\n\t\t\tthrowIfAborted(signal);\n\t\t\tif (parameters.path.length === 0) throw new Error(\"path must not be empty\");\n\t\t\tconst absolutePath = await resolveAllowedMutationPath(parameters.path, allowedRoot);\n\n\t\t\treturn withFileMutationQueue(absolutePath, async () => {\n\t\t\t\tthrowIfAborted(signal);\n\t\t\t\tawait operations.mkdir(dirname(absolutePath));\n\t\t\t\tthrowIfAborted(signal);\n\t\t\t\tawait operations.writeFile(absolutePath, parameters.content);\n\t\t\t\tthrowIfAborted(signal);\n\n\t\t\t\tconst bytes = Buffer.byteLength(parameters.content, \"utf8\");\n\t\t\t\treturn [{ type: \"text\", text: `Successfully wrote ${bytes} bytes to ${parameters.path}` }];\n\t\t\t});\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC","sourcesContent":["export * from \"@di-code/builtins\";\n"]}
package/dist/entry.js CHANGED
@@ -1,16 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import { homedir } from "node:os";
3
- import { join } from "node:path";
4
2
  import { createInterface } from "node:readline/promises";
5
- import { ProcessTerminal } from "@di-code/tui";
3
+ import { redactSensitiveText } from "@di-code/plugin-runtime";
6
4
  import packageMetadata from "../package.json" with { type: "json" };
7
- import { runMain } from "./main.js";
8
- import { runProviderOnboarding, shouldStartProviderOnboarding } from "./provider-onboarding.js";
9
- import { loadStartupConfiguration, resolveStartupArgs, resolveStartupRuntime } from "./startup.js";
5
+ import { parseCliArgs } from "./cli.js";
6
+ import { runMinimalProfile } from "./main.js";
7
+ import { resolveStartupArgs } from "./startup.js";
8
+ import { runWebCommand } from "./web-command.js";
10
9
  async function promptProjectTrust(cwd) {
11
10
  const readline = createInterface({ input: process.stdin, output: process.stdout });
12
11
  try {
13
- const answer = await readline.question(`Trust project-local Skills, plugins, and extensions in ${cwd}? [y/N] `);
12
+ const answer = await readline.question(`Trust project-local Skills and MCP configuration in ${cwd}? [y/N] `);
14
13
  return /^(?:y|yes)$/i.test(answer.trim());
15
14
  }
16
15
  finally {
@@ -18,29 +17,32 @@ async function promptProjectTrust(cwd) {
18
17
  }
19
18
  }
20
19
  try {
21
- const configuration = await loadStartupConfiguration(process.cwd());
22
- process.exitCode = await runMain(resolveStartupArgs(process.argv.slice(2)), {
23
- version: packageMetadata.version,
24
- createRuntime: (command) => {
25
- const isInteractiveTerminal = Boolean(process.stdin.isTTY && process.stdout.isTTY);
26
- if (shouldStartProviderOnboarding(command, isInteractiveTerminal, configuration)) {
27
- return runProviderOnboarding({
28
- configuration,
29
- terminal: new ProcessTerminal(),
30
- agentDir: join(homedir(), ".di-code"),
31
- });
32
- }
33
- return resolveStartupRuntime(configuration.environment, configuration.providers, configuration.defaults);
34
- },
35
- startupConfiguration: configuration,
36
- isInteractiveTerminal: Boolean(process.stdin.isTTY && process.stdout.isTTY),
37
- promptProjectTrust,
38
- stdout: (text) => process.stdout.write(text),
39
- stderr: (text) => process.stderr.write(text),
40
- });
20
+ const rawArgs = process.argv.slice(2);
21
+ const args = resolveStartupArgs(rawArgs);
22
+ const command = parseCliArgs(args);
23
+ if (command.kind === "web") {
24
+ process.exitCode = await runWebCommand(command);
25
+ }
26
+ else {
27
+ const isInteractiveTerminal = Boolean(process.stdin.isTTY && process.stdout.isTTY);
28
+ process.exitCode = await runMinimalProfile(args, {
29
+ version: packageMetadata.version,
30
+ stdout: (text) => process.stdout.write(text),
31
+ stderr: (text) => process.stderr.write(text),
32
+ interactive: { isInteractiveTerminal, promptProjectTrust },
33
+ onRuntimeEvent: (event) => {
34
+ if (process.env.DI_CODE_TRACE_PLUGINS === "1")
35
+ process.stderr.write(`${JSON.stringify(event)}\n`);
36
+ },
37
+ onSessionDisposed: () => {
38
+ if (process.env.DI_CODE_TRACE_PLUGINS === "1")
39
+ process.stderr.write('{"type":"session_dispose"}\n');
40
+ },
41
+ });
42
+ }
41
43
  }
42
44
  catch (cause) {
43
- const message = cause instanceof Error ? cause.message : "Unknown startup error";
45
+ const message = redactSensitiveText(cause instanceof Error ? cause.message : "Unknown startup error");
44
46
  process.stderr.write(`${message}\n`);
45
47
  process.exitCode = 1;
46
48
  }
package/dist/entry.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,eAAe,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAChG,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AA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AAE,aAAa;QACnC,qBAAqB,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;QAC3E,kBAAkB;QAClB,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;QAC5C,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;KAC5C,CAAC,CAAC;AACJ,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IAChB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,uBAAuB,CAAC;IACjF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;IACrC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACtB,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { createInterface } from \"node:readline/promises\";\nimport { ProcessTerminal } from \"@di-code/tui\";\nimport packageMetadata from \"../package.json\" with { type: \"json\" };\nimport { runMain } from \"./main.ts\";\nimport { runProviderOnboarding, shouldStartProviderOnboarding } from \"./provider-onboarding.ts\";\nimport { loadStartupConfiguration, resolveStartupArgs, resolveStartupRuntime } from \"./startup.ts\";\n\nasync function promptProjectTrust(cwd: string): Promise<boolean> {\n\tconst readline = createInterface({ input: process.stdin, output: process.stdout });\n\ttry {\n\t\tconst answer = await readline.question(`Trust project-local Skills, plugins, and extensions in ${cwd}? [y/N] `);\n\t\treturn /^(?:y|yes)$/i.test(answer.trim());\n\t} finally {\n\t\treadline.close();\n\t}\n}\n\ntry {\n\tconst configuration = await loadStartupConfiguration(process.cwd());\n\tprocess.exitCode = await runMain(resolveStartupArgs(process.argv.slice(2)), {\n\t\tversion: packageMetadata.version,\n\t\tcreateRuntime: (command) => {\n\t\t\tconst isInteractiveTerminal = Boolean(process.stdin.isTTY && process.stdout.isTTY);\n\t\t\tif (shouldStartProviderOnboarding(command, isInteractiveTerminal, configuration)) {\n\t\t\t\treturn runProviderOnboarding({\n\t\t\t\t\tconfiguration,\n\t\t\t\t\tterminal: new ProcessTerminal(),\n\t\t\t\t\tagentDir: join(homedir(), \".di-code\"),\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn resolveStartupRuntime(configuration.environment, configuration.providers, configuration.defaults);\n\t\t},\n\t\tstartupConfiguration: configuration,\n\t\tisInteractiveTerminal: Boolean(process.stdin.isTTY && process.stdout.isTTY),\n\t\tpromptProjectTrust,\n\t\tstdout: (text) => process.stdout.write(text),\n\t\tstderr: (text) => process.stderr.write(text),\n\t});\n} catch (cause) {\n\tconst message = cause instanceof Error ? cause.message : \"Unknown startup error\";\n\tprocess.stderr.write(`${message}\\n`);\n\tprocess.exitCode = 1;\n}\n"]}
1
+ {"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,eAAe,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,KAAK,UAAU,kBAAkB,CAAC,GAAW;IAC5C,MAAM,QAAQ,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACnF,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AAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACnG,CAAC;YACD,iBAAiB,EAAE,GAAG,EAAE;gBACvB,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,GAAG;oBAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;YACrG,CAAC;SACD,CAAC,CAAC;IACJ,CAAC;AACF,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IAChB,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC;IACtG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;IACrC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACtB,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { createInterface } from \"node:readline/promises\";\nimport { redactSensitiveText } from \"@di-code/plugin-runtime\";\nimport packageMetadata from \"../package.json\" with { type: \"json\" };\nimport { parseCliArgs } from \"./cli.ts\";\nimport { runMinimalProfile } from \"./main.ts\";\nimport { resolveStartupArgs } from \"./startup.ts\";\nimport { runWebCommand } from \"./web-command.ts\";\n\nasync function promptProjectTrust(cwd: string): Promise<boolean> {\n\tconst readline = createInterface({ input: process.stdin, output: process.stdout });\n\ttry {\n\t\tconst answer = await readline.question(`Trust project-local Skills and MCP configuration in ${cwd}? [y/N] `);\n\t\treturn /^(?:y|yes)$/i.test(answer.trim());\n\t} finally {\n\t\treadline.close();\n\t}\n}\n\ntry {\n\tconst rawArgs = process.argv.slice(2);\n\tconst args = resolveStartupArgs(rawArgs);\n\tconst command = parseCliArgs(args);\n\tif (command.kind === \"web\") {\n\t\tprocess.exitCode = await runWebCommand(command);\n\t} else {\n\t\tconst isInteractiveTerminal = Boolean(process.stdin.isTTY && process.stdout.isTTY);\n\t\tprocess.exitCode = await runMinimalProfile(args, {\n\t\t\tversion: packageMetadata.version,\n\t\t\tstdout: (text) => process.stdout.write(text),\n\t\t\tstderr: (text) => process.stderr.write(text),\n\t\t\tinteractive: { isInteractiveTerminal, promptProjectTrust },\n\t\t\tonRuntimeEvent: (event) => {\n\t\t\t\tif (process.env.DI_CODE_TRACE_PLUGINS === \"1\") process.stderr.write(`${JSON.stringify(event)}\\n`);\n\t\t\t},\n\t\t\tonSessionDisposed: () => {\n\t\t\t\tif (process.env.DI_CODE_TRACE_PLUGINS === \"1\") process.stderr.write('{\"type\":\"session_dispose\"}\\n');\n\t\t\t},\n\t\t});\n\t}\n} catch (cause) {\n\tconst message = redactSensitiveText(cause instanceof Error ? cause.message : \"Unknown startup error\");\n\tprocess.stderr.write(`${message}\\n`);\n\tprocess.exitCode = 1;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -6,9 +6,12 @@ export * from "./core/session/session-storage.ts";
6
6
  export * from "./core/session/types.ts";
7
7
  export * from "./core/session.ts";
8
8
  export * from "./core/system-prompt.ts";
9
- export * from "./extensions/index.ts";
10
9
  export * from "./mcp/config.ts";
11
- export * from "./mcp/loader.ts";
10
+ export * from "./mcp/entries.ts";
12
11
  export * from "./mcp/tool-adapter.ts";
13
- export * from "./plugins/index.ts";
12
+ export { apiVersion as rpcClientSdkApiVersion, apply as rpcClientSdkApply, name as rpcClientSdkName, type RpcClientSdk, rpcClientSdkKey, version as rpcClientSdkVersion, } from "./rpc-client-sdk-entry.ts";
13
+ export { pluginInventory } from "./runtime/plugin-inventory-entry.ts";
14
+ export { type PluginInventoryService, pluginInventoryKey } from "./runtime/plugin-inventory-service.ts";
15
+ export { type PluginManagementAction, type PluginManagementCommand, type PluginManagerEntryConfig, type PluginManagerService, pluginManager, pluginManagerKey, } from "./runtime/plugin-manager-entry.ts";
16
+ export { type PluginObservationService, pluginDumpComposition, pluginDumpCompositionKey, pluginTrace, pluginTraceKey, } from "./runtime/plugin-observability-entry.ts";
14
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EACN,UAAU,IAAI,sBAAsB,EACpC,KAAK,IAAI,iBAAiB,EAC1B,IAAI,IAAI,gBAAgB,EACxB,KAAK,YAAY,EACjB,eAAe,EACf,OAAO,IAAI,mBAAmB,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,KAAK,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AACxG,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,aAAa,EACb,gBAAgB,GAChB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACN,KAAK,wBAAwB,EAC7B,qBAAqB,EACrB,wBAAwB,EACxB,WAAW,EACX,cAAc,GACd,MAAM,yCAAyC,CAAC"}
package/dist/index.js CHANGED
@@ -6,9 +6,12 @@ export * from "./core/session/session-storage.js";
6
6
  export * from "./core/session/types.js";
7
7
  export * from "./core/session.js";
8
8
  export * from "./core/system-prompt.js";
9
- export * from "./extensions/index.js";
10
9
  export * from "./mcp/config.js";
11
- export * from "./mcp/loader.js";
10
+ export * from "./mcp/entries.js";
12
11
  export * from "./mcp/tool-adapter.js";
13
- export * from "./plugins/index.js";
12
+ export { apiVersion as rpcClientSdkApiVersion, apply as rpcClientSdkApply, name as rpcClientSdkName, rpcClientSdkKey, version as rpcClientSdkVersion, } from "./rpc-client-sdk-entry.js";
13
+ export { pluginInventory } from "./runtime/plugin-inventory-entry.js";
14
+ export { pluginInventoryKey } from "./runtime/plugin-inventory-service.js";
15
+ export { pluginManager, pluginManagerKey, } from "./runtime/plugin-manager-entry.js";
16
+ export { pluginDumpComposition, pluginDumpCompositionKey, pluginTrace, pluginTraceKey, } from "./runtime/plugin-observability-entry.js";
14
17
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./cli.ts\";\nexport * from \"./core/context-builder.ts\";\nexport * from \"./core/resources/index.ts\";\nexport * from \"./core/session/session-manager.ts\";\nexport * from \"./core/session/session-storage.ts\";\nexport * from \"./core/session/types.ts\";\nexport * from \"./core/session.ts\";\nexport * from \"./core/system-prompt.ts\";\nexport * from \"./extensions/index.ts\";\nexport * from \"./mcp/config.ts\";\nexport * from \"./mcp/loader.ts\";\nexport * from \"./mcp/tool-adapter.ts\";\nexport * from \"./plugins/index.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EACN,UAAU,IAAI,sBAAsB,EACpC,KAAK,IAAI,iBAAiB,EAC1B,IAAI,IAAI,gBAAgB,EAExB,eAAe,EACf,OAAO,IAAI,mBAAmB,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAA+B,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AACxG,OAAO,EAKN,aAAa,EACb,gBAAgB,GAChB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAEN,qBAAqB,EACrB,wBAAwB,EACxB,WAAW,EACX,cAAc,GACd,MAAM,yCAAyC,CAAC","sourcesContent":["export * from \"./cli.ts\";\nexport * from \"./core/context-builder.ts\";\nexport * from \"./core/resources/index.ts\";\nexport * from \"./core/session/session-manager.ts\";\nexport * from \"./core/session/session-storage.ts\";\nexport * from \"./core/session/types.ts\";\nexport * from \"./core/session.ts\";\nexport * from \"./core/system-prompt.ts\";\nexport * from \"./mcp/config.ts\";\nexport * from \"./mcp/entries.ts\";\nexport * from \"./mcp/tool-adapter.ts\";\nexport {\n\tapiVersion as rpcClientSdkApiVersion,\n\tapply as rpcClientSdkApply,\n\tname as rpcClientSdkName,\n\ttype RpcClientSdk,\n\trpcClientSdkKey,\n\tversion as rpcClientSdkVersion,\n} from \"./rpc-client-sdk-entry.ts\";\nexport { pluginInventory } from \"./runtime/plugin-inventory-entry.ts\";\nexport { type PluginInventoryService, pluginInventoryKey } from \"./runtime/plugin-inventory-service.ts\";\nexport {\n\ttype PluginManagementAction,\n\ttype PluginManagementCommand,\n\ttype PluginManagerEntryConfig,\n\ttype PluginManagerService,\n\tpluginManager,\n\tpluginManagerKey,\n} from \"./runtime/plugin-manager-entry.ts\";\nexport {\n\ttype PluginObservationService,\n\tpluginDumpComposition,\n\tpluginDumpCompositionKey,\n\tpluginTrace,\n\tpluginTraceKey,\n} from \"./runtime/plugin-observability-entry.ts\";\n"]}
@@ -0,0 +1,17 @@
1
+ import type { PluginFrontendController, PluginTerminalFrontendHost } from "@di-code/plugin-runtime";
2
+ import { type InteractiveModeOptions } from "../modes/interactive.ts";
3
+ export interface BuiltinInteractiveFrontendOptions extends Omit<InteractiveModeOptions, "tui"> {
4
+ readonly initialPrompt?: string;
5
+ }
6
+ /** The default ANSI frontend. It owns only the terminal facade supplied by the host. */
7
+ export declare class BuiltinInteractiveFrontend {
8
+ readonly id: "builtin";
9
+ private readonly options;
10
+ private mode?;
11
+ private resolveStart?;
12
+ constructor(options: BuiltinInteractiveFrontendOptions);
13
+ start(_controller: PluginFrontendController, terminal: PluginTerminalFrontendHost): Promise<void>;
14
+ dispose(): Promise<void>;
15
+ }
16
+ export declare function createBuiltinInteractiveFrontend(options: BuiltinInteractiveFrontendOptions): BuiltinInteractiveFrontend;
17
+ //# sourceMappingURL=builtin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtin.d.ts","sourceRoot":"","sources":["../../src/interactive/builtin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAEpG,OAAO,EAAmB,KAAK,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEvF,MAAM,WAAW,iCAAkC,SAAQ,IAAI,CAAC,sBAAsB,EAAE,KAAK,CAAC;IAC7F,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,wFAAwF;AACxF,qBAAa,0BAA0B;IACtC,QAAQ,CAAC,EAAE,EAAG,SAAS,CAAU;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAC5D,OAAO,CAAC,IAAI,CAAC,CAAkB;IAC/B,OAAO,CAAC,YAAY,CAAC,CAAa;gBAEtB,OAAO,EAAE,iCAAiC;IAIhD,KAAK,CAAC,WAAW,EAAE,wBAAwB,EAAE,QAAQ,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBjG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAM9B;AAED,wBAAgB,gCAAgC,CAC/C,OAAO,EAAE,iCAAiC,GACxC,0BAA0B,CAE5B"}
@@ -0,0 +1,47 @@
1
+ import { TUI } from "@di-code/tui";
2
+ import { InteractiveMode } from "../modes/interactive.js";
3
+ /** The default ANSI frontend. It owns only the terminal facade supplied by the host. */
4
+ export class BuiltinInteractiveFrontend {
5
+ id = "builtin";
6
+ options;
7
+ mode;
8
+ resolveStart;
9
+ constructor(options) {
10
+ this.options = options;
11
+ }
12
+ async start(_controller, terminal) {
13
+ if (this.mode)
14
+ throw new Error("Builtin interactive frontend is already started.");
15
+ await new Promise((resolve, reject) => {
16
+ this.resolveStart = resolve;
17
+ const onExit = this.options.onExit;
18
+ this.mode = new InteractiveMode({
19
+ ...this.options,
20
+ tui: new TUI(terminal),
21
+ onExit: () => {
22
+ onExit?.();
23
+ this.resolveStart = undefined;
24
+ resolve();
25
+ },
26
+ });
27
+ try {
28
+ this.mode.start(this.options.initialPrompt);
29
+ }
30
+ catch (cause) {
31
+ this.mode = undefined;
32
+ this.resolveStart = undefined;
33
+ reject(cause);
34
+ }
35
+ });
36
+ }
37
+ async dispose() {
38
+ this.mode?.stop();
39
+ this.mode = undefined;
40
+ this.resolveStart?.();
41
+ this.resolveStart = undefined;
42
+ }
43
+ }
44
+ export function createBuiltinInteractiveFrontend(options) {
45
+ return new BuiltinInteractiveFrontend(options);
46
+ }
47
+ //# sourceMappingURL=builtin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtin.js","sourceRoot":"","sources":["../../src/interactive/builtin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,eAAe,EAA+B,MAAM,yBAAyB,CAAC;AAMvF,wFAAwF;AACxF,MAAM,OAAO,0BAA0B;IAC7B,EAAE,GAAG,SAAkB,CAAC;IAChB,OAAO,CAAoC;IACpD,IAAI,CAAmB;IACvB,YAAY,CAAc;IAElC,YAAY,OAA0C;QACrD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,WAAqC,EAAE,QAAoC;QACtF,IAAI,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACnF,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;YAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;YACnC,IAAI,CAAC,IAAI,GAAG,IAAI,eAAe,CAAC;gBAC/B,GAAG,IAAI,CAAC,OAAO;gBACf,GAAG,EAAE,IAAI,GAAG,CAAC,QAAQ,CAAC;gBACtB,MAAM,EAAE,GAAG,EAAE;oBACZ,MAAM,EAAE,EAAE,CAAC;oBACX,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;oBAC9B,OAAO,EAAE,CAAC;gBACX,CAAC;aACD,CAAC,CAAC;YACH,IAAI,CAAC;gBACJ,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;YAC7C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;gBACtB,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;gBAC9B,MAAM,CAAC,KAAK,CAAC,CAAC;YACf,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;IAC/B,CAAC;CACD;AAED,MAAM,UAAU,gCAAgC,CAC/C,OAA0C;IAE1C,OAAO,IAAI,0BAA0B,CAAC,OAAO,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type { PluginFrontendController, PluginTerminalFrontendHost } from \"@di-code/plugin-runtime\";\nimport { TUI } from \"@di-code/tui\";\nimport { InteractiveMode, type InteractiveModeOptions } from \"../modes/interactive.ts\";\n\nexport interface BuiltinInteractiveFrontendOptions extends Omit<InteractiveModeOptions, \"tui\"> {\n\treadonly initialPrompt?: string;\n}\n\n/** The default ANSI frontend. It owns only the terminal facade supplied by the host. */\nexport class BuiltinInteractiveFrontend {\n\treadonly id = \"builtin\" as const;\n\tprivate readonly options: BuiltinInteractiveFrontendOptions;\n\tprivate mode?: InteractiveMode;\n\tprivate resolveStart?: () => void;\n\n\tconstructor(options: BuiltinInteractiveFrontendOptions) {\n\t\tthis.options = options;\n\t}\n\n\tasync start(_controller: PluginFrontendController, terminal: PluginTerminalFrontendHost): Promise<void> {\n\t\tif (this.mode) throw new Error(\"Builtin interactive frontend is already started.\");\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tthis.resolveStart = resolve;\n\t\t\tconst onExit = this.options.onExit;\n\t\t\tthis.mode = new InteractiveMode({\n\t\t\t\t...this.options,\n\t\t\t\ttui: new TUI(terminal),\n\t\t\t\tonExit: () => {\n\t\t\t\t\tonExit?.();\n\t\t\t\t\tthis.resolveStart = undefined;\n\t\t\t\t\tresolve();\n\t\t\t\t},\n\t\t\t});\n\t\t\ttry {\n\t\t\t\tthis.mode.start(this.options.initialPrompt);\n\t\t\t} catch (cause) {\n\t\t\t\tthis.mode = undefined;\n\t\t\t\tthis.resolveStart = undefined;\n\t\t\t\treject(cause);\n\t\t\t}\n\t\t});\n\t}\n\n\tasync dispose(): Promise<void> {\n\t\tthis.mode?.stop();\n\t\tthis.mode = undefined;\n\t\tthis.resolveStart?.();\n\t\tthis.resolveStart = undefined;\n\t}\n}\n\nexport function createBuiltinInteractiveFrontend(\n\toptions: BuiltinInteractiveFrontendOptions,\n): BuiltinInteractiveFrontend {\n\treturn new BuiltinInteractiveFrontend(options);\n}\n"]}
@@ -0,0 +1,85 @@
1
+ import type { ImageContent } from "@di-code/ai";
2
+ import type { PluginUiContributions } from "@di-code/plugin-runtime";
3
+ import type { AgentSession, AgentSessionEvent } from "../core/session.ts";
4
+ import { type InteractiveState } from "../modes/interactive-state.ts";
5
+ import type { CodingAgentPluginHost } from "../plugins/runtime-host.ts";
6
+ export type InteractiveInput = string | {
7
+ readonly text: string;
8
+ readonly images?: readonly ImageContent[];
9
+ };
10
+ export interface InteractiveSessionChoice {
11
+ readonly id: string;
12
+ readonly label: string;
13
+ readonly description?: string;
14
+ open(): AgentSession | Promise<AgentSession>;
15
+ }
16
+ export interface InteractiveControllerState extends InteractiveState {
17
+ readonly model: string;
18
+ readonly provider: string;
19
+ readonly sessionId: string;
20
+ readonly streaming: boolean;
21
+ /** Child runs are host-owned and expose no Agent or Session internals to a frontend. */
22
+ readonly subagents: readonly {
23
+ readonly id: string;
24
+ readonly status: import("@di-code/plugin-runtime").SubagentStatus;
25
+ }[];
26
+ }
27
+ export type InteractiveViewEvent = {
28
+ readonly type: "state";
29
+ readonly state: InteractiveControllerState;
30
+ } | {
31
+ readonly type: "session_event";
32
+ readonly event: AgentSessionEvent;
33
+ } | {
34
+ readonly type: "diagnostic";
35
+ readonly message: string;
36
+ } | {
37
+ readonly type: "exit";
38
+ readonly reason: "user" | "error";
39
+ };
40
+ export type InteractiveControllerListener = (event: InteractiveViewEvent) => void;
41
+ export interface InteractiveControllerOptions {
42
+ readonly session: AgentSession;
43
+ readonly sessions?: readonly InteractiveSessionChoice[];
44
+ readonly runtimePluginHost?: CodingAgentPluginHost;
45
+ }
46
+ /** Product-layer controller shared by the builtin TUI and future frontends. */
47
+ export declare class InteractiveController {
48
+ private session;
49
+ private readonly sessionChoices;
50
+ private readonly runtimePluginHost?;
51
+ private readonly projection;
52
+ private readonly listeners;
53
+ private unsubscribeSession?;
54
+ private activeAbort?;
55
+ private promptActive;
56
+ private switching;
57
+ private compactionActive;
58
+ private queue;
59
+ private lastRetryInput?;
60
+ private disposed;
61
+ constructor(options: InteractiveControllerOptions);
62
+ get state(): InteractiveControllerState;
63
+ /** Restricted panel data and result formatters supplied by active plugin scopes. */
64
+ get ui(): PluginUiContributions;
65
+ subscribe(listener: InteractiveControllerListener): {
66
+ dispose(): void;
67
+ };
68
+ submit(input: InteractiveInput): Promise<void>;
69
+ steer(input: InteractiveInput): void;
70
+ cancel(): void;
71
+ retry(): Promise<void>;
72
+ runCommand(name: string, args: string): Promise<void>;
73
+ selectModel(modelId: string): void;
74
+ openSession(sessionId: string): Promise<void>;
75
+ createSession(): Promise<void>;
76
+ requestCompaction(): Promise<void>;
77
+ dispose(): void;
78
+ disposeSubagents(): Promise<void>;
79
+ private steerAsync;
80
+ private subscribeSession;
81
+ private emitState;
82
+ private emit;
83
+ private reportError;
84
+ }
85
+ //# sourceMappingURL=controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"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