@kilnai/core 0.23.2 → 1.0.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 (297) hide show
  1. package/dist/agents/execution-identity.d.ts +15 -0
  2. package/dist/agents/execution-identity.d.ts.map +1 -0
  3. package/dist/agents/execution-identity.js +42 -0
  4. package/dist/agents/execution-identity.js.map +1 -0
  5. package/dist/agents/index.d.ts +6 -1
  6. package/dist/agents/index.d.ts.map +1 -1
  7. package/dist/agents/index.js +4 -1
  8. package/dist/agents/index.js.map +1 -1
  9. package/dist/agents/infrastructure/__tests__/codex-oauth-auth.test.d.ts +2 -0
  10. package/dist/agents/infrastructure/__tests__/codex-oauth-auth.test.d.ts.map +1 -0
  11. package/dist/agents/infrastructure/__tests__/codex-oauth-auth.test.js +313 -0
  12. package/dist/agents/infrastructure/__tests__/codex-oauth-auth.test.js.map +1 -0
  13. package/dist/agents/infrastructure/__tests__/codex-oauth.test.d.ts +2 -0
  14. package/dist/agents/infrastructure/__tests__/codex-oauth.test.d.ts.map +1 -0
  15. package/dist/agents/infrastructure/__tests__/codex-oauth.test.js +720 -0
  16. package/dist/agents/infrastructure/__tests__/codex-oauth.test.js.map +1 -0
  17. package/dist/agents/infrastructure/codex-oauth-auth.d.ts +41 -0
  18. package/dist/agents/infrastructure/codex-oauth-auth.d.ts.map +1 -0
  19. package/dist/agents/infrastructure/codex-oauth-auth.js +204 -0
  20. package/dist/agents/infrastructure/codex-oauth-auth.js.map +1 -0
  21. package/dist/agents/infrastructure/codex-oauth.d.ts +32 -0
  22. package/dist/agents/infrastructure/codex-oauth.d.ts.map +1 -0
  23. package/dist/agents/infrastructure/codex-oauth.js +371 -0
  24. package/dist/agents/infrastructure/codex-oauth.js.map +1 -0
  25. package/dist/agents/model-capability-registry.d.ts +2 -0
  26. package/dist/agents/model-capability-registry.d.ts.map +1 -1
  27. package/dist/agents/model-capability-registry.js +11 -2
  28. package/dist/agents/model-capability-registry.js.map +1 -1
  29. package/dist/agents/model-pricing.d.ts +2 -0
  30. package/dist/agents/model-pricing.d.ts.map +1 -1
  31. package/dist/agents/model-pricing.js +10 -0
  32. package/dist/agents/model-pricing.js.map +1 -1
  33. package/dist/cost/cost-tracker.d.ts +1 -0
  34. package/dist/cost/cost-tracker.d.ts.map +1 -1
  35. package/dist/cost/cost-tracker.js +6 -3
  36. package/dist/cost/cost-tracker.js.map +1 -1
  37. package/dist/cost/index.d.ts +2 -0
  38. package/dist/cost/index.d.ts.map +1 -1
  39. package/dist/cost/index.js +1 -0
  40. package/dist/cost/index.js.map +1 -1
  41. package/dist/cost/models-dev-client.d.ts +20 -0
  42. package/dist/cost/models-dev-client.d.ts.map +1 -0
  43. package/dist/cost/models-dev-client.js +91 -0
  44. package/dist/cost/models-dev-client.js.map +1 -0
  45. package/dist/domain/index.d.ts +1 -0
  46. package/dist/domain/index.d.ts.map +1 -1
  47. package/dist/domain/index.js.map +1 -1
  48. package/dist/engine/composites/team.d.ts +1 -1
  49. package/dist/engine/composites/team.d.ts.map +1 -1
  50. package/dist/engine/composites/team.js +1 -17
  51. package/dist/engine/composites/team.js.map +1 -1
  52. package/dist/engine/domain/cron.d.ts +3 -1
  53. package/dist/engine/domain/cron.d.ts.map +1 -1
  54. package/dist/engine/domain/cron.js +41 -10
  55. package/dist/engine/domain/cron.js.map +1 -1
  56. package/dist/engine/domain/tool-execution.d.ts +21 -0
  57. package/dist/engine/domain/tool-execution.d.ts.map +1 -1
  58. package/dist/engine/error-catalog.d.ts.map +1 -1
  59. package/dist/engine/error-catalog.js +8 -0
  60. package/dist/engine/error-catalog.js.map +1 -1
  61. package/dist/engine/errors.d.ts +2 -1
  62. package/dist/engine/errors.d.ts.map +1 -1
  63. package/dist/engine/errors.js +10 -0
  64. package/dist/engine/errors.js.map +1 -1
  65. package/dist/engine/index.d.ts +1 -1
  66. package/dist/engine/index.d.ts.map +1 -1
  67. package/dist/engine/index.js +1 -1
  68. package/dist/engine/index.js.map +1 -1
  69. package/dist/engine/loader/app-loader.js +1 -1
  70. package/dist/engine/loader/app-loader.js.map +1 -1
  71. package/dist/events/index.d.ts +18 -1
  72. package/dist/events/index.d.ts.map +1 -1
  73. package/dist/events/index.js +2 -0
  74. package/dist/events/index.js.map +1 -1
  75. package/dist/field/domain/field-config.d.ts +8 -0
  76. package/dist/field/domain/field-config.d.ts.map +1 -0
  77. package/dist/field/domain/field-config.js +7 -0
  78. package/dist/field/domain/field-config.js.map +1 -0
  79. package/dist/field/domain/field-store.d.ts +8 -0
  80. package/dist/field/domain/field-store.d.ts.map +1 -0
  81. package/dist/field/domain/field-store.js +2 -0
  82. package/dist/field/domain/field-store.js.map +1 -0
  83. package/dist/field/domain/field.d.ts +22 -0
  84. package/dist/field/domain/field.d.ts.map +1 -0
  85. package/dist/field/domain/field.js +2 -0
  86. package/dist/field/domain/field.js.map +1 -0
  87. package/dist/field/field-inhibitor.d.ts +17 -0
  88. package/dist/field/field-inhibitor.d.ts.map +1 -0
  89. package/dist/field/field-inhibitor.js +50 -0
  90. package/dist/field/field-inhibitor.js.map +1 -0
  91. package/dist/field/field-propagator.d.ts +19 -0
  92. package/dist/field/field-propagator.d.ts.map +1 -0
  93. package/dist/field/field-propagator.js +69 -0
  94. package/dist/field/field-propagator.js.map +1 -0
  95. package/dist/field/field-service.d.ts +18 -0
  96. package/dist/field/field-service.d.ts.map +1 -0
  97. package/dist/field/field-service.js +57 -0
  98. package/dist/field/field-service.js.map +1 -0
  99. package/dist/field/field-updater.d.ts +19 -0
  100. package/dist/field/field-updater.d.ts.map +1 -0
  101. package/dist/field/field-updater.js +64 -0
  102. package/dist/field/field-updater.js.map +1 -0
  103. package/dist/field/index.d.ts +15 -0
  104. package/dist/field/index.d.ts.map +1 -0
  105. package/dist/field/index.js +9 -0
  106. package/dist/field/index.js.map +1 -0
  107. package/dist/field/infrastructure/in-memory-field-store.d.ts +16 -0
  108. package/dist/field/infrastructure/in-memory-field-store.d.ts.map +1 -0
  109. package/dist/field/infrastructure/in-memory-field-store.js +72 -0
  110. package/dist/field/infrastructure/in-memory-field-store.js.map +1 -0
  111. package/dist/field/infrastructure/sqlite-field-store.d.ts +20 -0
  112. package/dist/field/infrastructure/sqlite-field-store.d.ts.map +1 -0
  113. package/dist/field/infrastructure/sqlite-field-store.js +107 -0
  114. package/dist/field/infrastructure/sqlite-field-store.js.map +1 -0
  115. package/dist/field/stability-monitor.d.ts +24 -0
  116. package/dist/field/stability-monitor.d.ts.map +1 -0
  117. package/dist/field/stability-monitor.js +72 -0
  118. package/dist/field/stability-monitor.js.map +1 -0
  119. package/dist/index.d.ts +5 -1
  120. package/dist/index.d.ts.map +1 -1
  121. package/dist/index.js +4 -1
  122. package/dist/index.js.map +1 -1
  123. package/dist/memory/context-budget.d.ts +17 -0
  124. package/dist/memory/context-budget.d.ts.map +1 -0
  125. package/dist/memory/context-budget.js +29 -0
  126. package/dist/memory/context-budget.js.map +1 -0
  127. package/dist/memory/context-cache.d.ts +23 -0
  128. package/dist/memory/context-cache.d.ts.map +1 -0
  129. package/dist/memory/context-cache.js +34 -0
  130. package/dist/memory/context-cache.js.map +1 -0
  131. package/dist/memory/index.d.ts +15 -3
  132. package/dist/memory/index.d.ts.map +1 -1
  133. package/dist/memory/index.js +5 -0
  134. package/dist/memory/index.js.map +1 -1
  135. package/dist/memory/memory-manager.d.ts +1 -1
  136. package/dist/memory/memory-manager.d.ts.map +1 -1
  137. package/dist/memory/memory-manager.js +2 -2
  138. package/dist/memory/memory-manager.js.map +1 -1
  139. package/dist/memory/project-store.js +1 -1
  140. package/dist/memory/project-store.js.map +1 -1
  141. package/dist/memory/resume-policy.d.ts +21 -0
  142. package/dist/memory/resume-policy.d.ts.map +1 -0
  143. package/dist/memory/resume-policy.js +70 -0
  144. package/dist/memory/resume-policy.js.map +1 -0
  145. package/dist/memory/resume-signals.d.ts +8 -0
  146. package/dist/memory/resume-signals.d.ts.map +1 -0
  147. package/dist/memory/resume-signals.js +8 -0
  148. package/dist/memory/resume-signals.js.map +1 -0
  149. package/dist/memory/sqlite-store.d.ts +6 -1
  150. package/dist/memory/sqlite-store.d.ts.map +1 -1
  151. package/dist/memory/sqlite-store.js +88 -11
  152. package/dist/memory/sqlite-store.js.map +1 -1
  153. package/dist/memory/task-shape.d.ts +2 -0
  154. package/dist/memory/task-shape.d.ts.map +1 -0
  155. package/dist/memory/task-shape.js +9 -0
  156. package/dist/memory/task-shape.js.map +1 -0
  157. package/dist/observability/span-mapper.d.ts.map +1 -1
  158. package/dist/observability/span-mapper.js +18 -0
  159. package/dist/observability/span-mapper.js.map +1 -1
  160. package/dist/orchestrator/chain-governor.d.ts +62 -0
  161. package/dist/orchestrator/chain-governor.d.ts.map +1 -0
  162. package/dist/orchestrator/chain-governor.js +80 -0
  163. package/dist/orchestrator/chain-governor.js.map +1 -0
  164. package/dist/orchestrator/demand-allocator.d.ts +64 -0
  165. package/dist/orchestrator/demand-allocator.d.ts.map +1 -0
  166. package/dist/orchestrator/demand-allocator.js +139 -0
  167. package/dist/orchestrator/demand-allocator.js.map +1 -0
  168. package/dist/orchestrator/demand-signal.d.ts +9 -0
  169. package/dist/orchestrator/demand-signal.d.ts.map +1 -0
  170. package/dist/orchestrator/demand-signal.js +23 -0
  171. package/dist/orchestrator/demand-signal.js.map +1 -0
  172. package/dist/orchestrator/index.d.ts +8 -2
  173. package/dist/orchestrator/index.d.ts.map +1 -1
  174. package/dist/orchestrator/index.js +8 -1
  175. package/dist/orchestrator/index.js.map +1 -1
  176. package/dist/orchestrator/orchestrator-checkpoint-support.d.ts +43 -0
  177. package/dist/orchestrator/orchestrator-checkpoint-support.d.ts.map +1 -0
  178. package/dist/orchestrator/orchestrator-checkpoint-support.js +147 -0
  179. package/dist/orchestrator/orchestrator-checkpoint-support.js.map +1 -0
  180. package/dist/orchestrator/orchestrator-dev-tool-support.d.ts +30 -0
  181. package/dist/orchestrator/orchestrator-dev-tool-support.d.ts.map +1 -0
  182. package/dist/orchestrator/orchestrator-dev-tool-support.js +125 -0
  183. package/dist/orchestrator/orchestrator-dev-tool-support.js.map +1 -0
  184. package/dist/orchestrator/orchestrator-interrupt-support.d.ts +22 -0
  185. package/dist/orchestrator/orchestrator-interrupt-support.d.ts.map +1 -0
  186. package/dist/orchestrator/orchestrator-interrupt-support.js +64 -0
  187. package/dist/orchestrator/orchestrator-interrupt-support.js.map +1 -0
  188. package/dist/orchestrator/orchestrator-memory-sync-support.d.ts +16 -0
  189. package/dist/orchestrator/orchestrator-memory-sync-support.d.ts.map +1 -0
  190. package/dist/orchestrator/orchestrator-memory-sync-support.js +25 -0
  191. package/dist/orchestrator/orchestrator-memory-sync-support.js.map +1 -0
  192. package/dist/orchestrator/orchestrator-verification-support.d.ts +17 -0
  193. package/dist/orchestrator/orchestrator-verification-support.d.ts.map +1 -0
  194. package/dist/orchestrator/orchestrator-verification-support.js +29 -0
  195. package/dist/orchestrator/orchestrator-verification-support.js.map +1 -0
  196. package/dist/orchestrator/orchestrator.d.ts +24 -16
  197. package/dist/orchestrator/orchestrator.d.ts.map +1 -1
  198. package/dist/orchestrator/orchestrator.js +106 -235
  199. package/dist/orchestrator/orchestrator.js.map +1 -1
  200. package/dist/orchestrator/strategies/index.d.ts +0 -1
  201. package/dist/orchestrator/strategies/index.d.ts.map +1 -1
  202. package/dist/orchestrator/strategies/index.js +1 -5
  203. package/dist/orchestrator/strategies/index.js.map +1 -1
  204. package/dist/orchestrator/task-registry.d.ts +94 -0
  205. package/dist/orchestrator/task-registry.d.ts.map +1 -0
  206. package/dist/orchestrator/task-registry.js +167 -0
  207. package/dist/orchestrator/task-registry.js.map +1 -0
  208. package/dist/safety/pii-scanner.d.ts.map +1 -1
  209. package/dist/safety/pii-scanner.js +7 -8
  210. package/dist/safety/pii-scanner.js.map +1 -1
  211. package/dist/safety/rails.d.ts.map +1 -1
  212. package/dist/safety/rails.js +9 -5
  213. package/dist/safety/rails.js.map +1 -1
  214. package/dist/security/dangerous-command-detector.d.ts +5 -0
  215. package/dist/security/dangerous-command-detector.d.ts.map +1 -0
  216. package/dist/security/dangerous-command-detector.js +92 -0
  217. package/dist/security/dangerous-command-detector.js.map +1 -0
  218. package/dist/security/index.d.ts +1 -0
  219. package/dist/security/index.d.ts.map +1 -1
  220. package/dist/security/index.js +1 -0
  221. package/dist/security/index.js.map +1 -1
  222. package/dist/security/prompt-scanner.d.ts.map +1 -1
  223. package/dist/security/prompt-scanner.js +117 -4
  224. package/dist/security/prompt-scanner.js.map +1 -1
  225. package/dist/skill/index.d.ts +4 -0
  226. package/dist/skill/index.d.ts.map +1 -1
  227. package/dist/skill/index.js +2 -0
  228. package/dist/skill/index.js.map +1 -1
  229. package/dist/skill/skill-capture.d.ts +46 -0
  230. package/dist/skill/skill-capture.d.ts.map +1 -0
  231. package/dist/skill/skill-capture.js +150 -0
  232. package/dist/skill/skill-capture.js.map +1 -0
  233. package/dist/skill/skill-generator.d.ts +20 -0
  234. package/dist/skill/skill-generator.d.ts.map +1 -0
  235. package/dist/skill/skill-generator.js +106 -0
  236. package/dist/skill/skill-generator.js.map +1 -0
  237. package/dist/tools/domain/tool-environment.d.ts +16 -0
  238. package/dist/tools/domain/tool-environment.d.ts.map +1 -0
  239. package/dist/tools/domain/tool-environment.js +94 -0
  240. package/dist/tools/domain/tool-environment.js.map +1 -0
  241. package/dist/tools/domain/tool-registry.d.ts +10 -0
  242. package/dist/tools/domain/tool-registry.d.ts.map +1 -0
  243. package/dist/tools/domain/tool-registry.js +23 -0
  244. package/dist/tools/domain/tool-registry.js.map +1 -0
  245. package/dist/tools/domain/tool.d.ts +29 -0
  246. package/dist/tools/domain/tool.d.ts.map +1 -0
  247. package/dist/tools/domain/tool.js +123 -0
  248. package/dist/tools/domain/tool.js.map +1 -0
  249. package/dist/tools/index.d.ts +18 -0
  250. package/dist/tools/index.d.ts.map +1 -0
  251. package/dist/tools/index.js +13 -0
  252. package/dist/tools/index.js.map +1 -0
  253. package/dist/tools/infrastructure/bash-tool.d.ts +20 -0
  254. package/dist/tools/infrastructure/bash-tool.d.ts.map +1 -0
  255. package/dist/tools/infrastructure/bash-tool.js +84 -0
  256. package/dist/tools/infrastructure/bash-tool.js.map +1 -0
  257. package/dist/tools/infrastructure/edit-tool.d.ts +9 -0
  258. package/dist/tools/infrastructure/edit-tool.d.ts.map +1 -0
  259. package/dist/tools/infrastructure/edit-tool.js +80 -0
  260. package/dist/tools/infrastructure/edit-tool.js.map +1 -0
  261. package/dist/tools/infrastructure/git-tool.d.ts +20 -0
  262. package/dist/tools/infrastructure/git-tool.d.ts.map +1 -0
  263. package/dist/tools/infrastructure/git-tool.js +85 -0
  264. package/dist/tools/infrastructure/git-tool.js.map +1 -0
  265. package/dist/tools/infrastructure/glob-tool.d.ts +23 -0
  266. package/dist/tools/infrastructure/glob-tool.d.ts.map +1 -0
  267. package/dist/tools/infrastructure/glob-tool.js +88 -0
  268. package/dist/tools/infrastructure/glob-tool.js.map +1 -0
  269. package/dist/tools/infrastructure/grep-tool.d.ts +23 -0
  270. package/dist/tools/infrastructure/grep-tool.d.ts.map +1 -0
  271. package/dist/tools/infrastructure/grep-tool.js +146 -0
  272. package/dist/tools/infrastructure/grep-tool.js.map +1 -0
  273. package/dist/tools/infrastructure/read-tool.d.ts +9 -0
  274. package/dist/tools/infrastructure/read-tool.d.ts.map +1 -0
  275. package/dist/tools/infrastructure/read-tool.js +45 -0
  276. package/dist/tools/infrastructure/read-tool.js.map +1 -0
  277. package/dist/tools/infrastructure/tool-helpers.d.ts +37 -0
  278. package/dist/tools/infrastructure/tool-helpers.d.ts.map +1 -0
  279. package/dist/tools/infrastructure/tool-helpers.js +145 -0
  280. package/dist/tools/infrastructure/tool-helpers.js.map +1 -0
  281. package/dist/tools/infrastructure/write-tool.d.ts +9 -0
  282. package/dist/tools/infrastructure/write-tool.d.ts.map +1 -0
  283. package/dist/tools/infrastructure/write-tool.js +38 -0
  284. package/dist/tools/infrastructure/write-tool.js.map +1 -0
  285. package/dist/tools/mcp/dev-tools-server.d.ts +37 -0
  286. package/dist/tools/mcp/dev-tools-server.d.ts.map +1 -0
  287. package/dist/tools/mcp/dev-tools-server.js +94 -0
  288. package/dist/tools/mcp/dev-tools-server.js.map +1 -0
  289. package/dist/tools/tool-executor.d.ts +34 -0
  290. package/dist/tools/tool-executor.d.ts.map +1 -0
  291. package/dist/tools/tool-executor.js +123 -0
  292. package/dist/tools/tool-executor.js.map +1 -0
  293. package/package.json +6 -5
  294. package/dist/orchestrator/strategies/swarm-strategy.d.ts +0 -36
  295. package/dist/orchestrator/strategies/swarm-strategy.d.ts.map +0 -1
  296. package/dist/orchestrator/strategies/swarm-strategy.js +0 -126
  297. package/dist/orchestrator/strategies/swarm-strategy.js.map +0 -1
@@ -0,0 +1,123 @@
1
+ // Engine domain: developer tool types for Phase 9a (native runtime)
2
+ export const TOOL_SCHEMAS = {
3
+ bash: {
4
+ name: "bash",
5
+ description: "Run a shell command.",
6
+ inputSchema: {
7
+ type: "object",
8
+ properties: {
9
+ command: { type: "string" },
10
+ timeout: { type: "number" },
11
+ cwd: { type: "string" },
12
+ },
13
+ required: ["command"],
14
+ },
15
+ annotations: {
16
+ destructive: true,
17
+ },
18
+ },
19
+ read: {
20
+ name: "read",
21
+ description: "Read file content from disk.",
22
+ inputSchema: {
23
+ type: "object",
24
+ properties: {
25
+ filePath: { type: "string" },
26
+ offset: { type: "number", description: "Line offset to start reading from (0-based)" },
27
+ limit: { type: "number", description: "Maximum number of lines to read" },
28
+ },
29
+ required: ["filePath"],
30
+ },
31
+ annotations: {
32
+ readOnly: true,
33
+ idempotent: true,
34
+ },
35
+ },
36
+ write: {
37
+ name: "write",
38
+ description: "Write full content to a file.",
39
+ inputSchema: {
40
+ type: "object",
41
+ properties: {
42
+ filePath: { type: "string" },
43
+ content: { type: "string" },
44
+ },
45
+ required: ["filePath", "content"],
46
+ },
47
+ annotations: {
48
+ destructive: true,
49
+ },
50
+ },
51
+ edit: {
52
+ name: "edit",
53
+ description: "Replace text content in a file.",
54
+ inputSchema: {
55
+ type: "object",
56
+ properties: {
57
+ filePath: { type: "string" },
58
+ oldString: { type: "string" },
59
+ newString: { type: "string" },
60
+ replaceAll: { type: "boolean" },
61
+ },
62
+ required: ["filePath", "oldString", "newString"],
63
+ },
64
+ annotations: {
65
+ destructive: false,
66
+ },
67
+ },
68
+ grep: {
69
+ name: "grep",
70
+ description: "Search file content by pattern.",
71
+ inputSchema: {
72
+ type: "object",
73
+ properties: {
74
+ pattern: { type: "string" },
75
+ path: { type: "string" },
76
+ glob: { type: "string" },
77
+ outputMode: {
78
+ enum: ["content", "files_with_matches", "count"],
79
+ },
80
+ },
81
+ required: ["pattern"],
82
+ },
83
+ annotations: {
84
+ readOnly: true,
85
+ idempotent: true,
86
+ },
87
+ },
88
+ glob: {
89
+ name: "glob",
90
+ description: "Match files by glob pattern.",
91
+ inputSchema: {
92
+ type: "object",
93
+ properties: {
94
+ pattern: { type: "string" },
95
+ path: { type: "string" },
96
+ },
97
+ required: ["pattern"],
98
+ },
99
+ annotations: {
100
+ readOnly: true,
101
+ idempotent: true,
102
+ },
103
+ },
104
+ git: {
105
+ name: "git",
106
+ description: "Run a git subcommand.",
107
+ inputSchema: {
108
+ type: "object",
109
+ properties: {
110
+ subcommand: { type: "string" },
111
+ args: {
112
+ type: "array",
113
+ items: { type: "string" },
114
+ },
115
+ },
116
+ required: ["subcommand"],
117
+ },
118
+ annotations: {
119
+ destructive: false,
120
+ },
121
+ },
122
+ };
123
+ //# sourceMappingURL=tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../src/tools/domain/tool.ts"],"names":[],"mappings":"AAAA,oEAAoE;AAoCpE,MAAM,CAAC,MAAM,YAAY,GAQrB;IACF,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,sBAAsB;QACnC,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC3B,OAAO,EA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,EAAE;oBACJ,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;iBAC1B;aACF;YACD,QAAQ,EAAE,CAAC,YAAY,CAAC;SACzB;QACD,WAAW,EAAE;YACX,WAAW,EAAE,KAAK;SACnB;KACF;CACF,CAAC"}
@@ -0,0 +1,18 @@
1
+ export type { DevTool, DevToolAnnotations, DevToolName, ToolInput, ToolResult, } from "./domain/tool.js";
2
+ export { TOOL_SCHEMAS } from "./domain/tool.js";
3
+ export { DevToolRegistry } from "./domain/tool-registry.js";
4
+ export type { BinaryInfo, ToolEnvironment, ToolEnvironmentOptions, } from "./domain/tool-environment.js";
5
+ export { clearToolEnvironmentCache, detectToolEnvironment, } from "./domain/tool-environment.js";
6
+ export type { ToolSandboxContext } from "./infrastructure/tool-helpers.js";
7
+ export { BashTool } from "./infrastructure/bash-tool.js";
8
+ export { ReadTool } from "./infrastructure/read-tool.js";
9
+ export { WriteTool } from "./infrastructure/write-tool.js";
10
+ export { EditTool } from "./infrastructure/edit-tool.js";
11
+ export { GrepTool } from "./infrastructure/grep-tool.js";
12
+ export { GlobTool } from "./infrastructure/glob-tool.js";
13
+ export { GitTool } from "./infrastructure/git-tool.js";
14
+ export type { DevToolExecutionBridgeOptions, DevToolAuthorizationDecision, DevToolExecutionRequest, DevToolExecutionResult, } from "./tool-executor.js";
15
+ export { DevToolExecutionBridge } from "./tool-executor.js";
16
+ export type { DevToolsMcpCallResult, DevToolsMcpServerOptions, DevToolsMcpToolSchema, } from "./mcp/dev-tools-server.js";
17
+ export { DevToolsMcpServer } from "./mcp/dev-tools-server.js";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,UAAU,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,YAAY,EACV,UAAU,EACV,eAAe,EACf,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,8BAA8B,CAAC;AAEtC,YAAY,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,YAAY,EACV,6BAA6B,EAC7B,4BAA4B,EAC5B,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,YAAY,EACV,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,13 @@
1
+ export { TOOL_SCHEMAS } from "./domain/tool.js";
2
+ export { DevToolRegistry } from "./domain/tool-registry.js";
3
+ export { clearToolEnvironmentCache, detectToolEnvironment, } from "./domain/tool-environment.js";
4
+ export { BashTool } from "./infrastructure/bash-tool.js";
5
+ export { ReadTool } from "./infrastructure/read-tool.js";
6
+ export { WriteTool } from "./infrastructure/write-tool.js";
7
+ export { EditTool } from "./infrastructure/edit-tool.js";
8
+ export { GrepTool } from "./infrastructure/grep-tool.js";
9
+ export { GlobTool } from "./infrastructure/glob-tool.js";
10
+ export { GitTool } from "./infrastructure/git-tool.js";
11
+ export { DevToolExecutionBridge } from "./tool-executor.js";
12
+ export { DevToolsMcpServer } from "./mcp/dev-tools-server.js";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAO5D,OAAO,EACL,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAOvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAO5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { type DevTool, type ToolInput, type ToolResult } from "../domain/tool.js";
2
+ type BashCommandResult = {
3
+ readonly stdout: string;
4
+ readonly stderr: string;
5
+ };
6
+ type BashCommandRunner = (command: string, cwd: string, timeoutMs: number) => Promise<BashCommandResult>;
7
+ export interface BashToolOptions {
8
+ readonly commandRunner?: BashCommandRunner;
9
+ }
10
+ export declare class BashTool implements DevTool {
11
+ readonly name = "bash";
12
+ readonly description: string;
13
+ readonly inputSchema: Record<string, unknown>;
14
+ readonly annotations: import("../domain/tool.js").DevToolAnnotations;
15
+ private readonly commandRunner;
16
+ constructor(options?: BashToolOptions);
17
+ execute(input: ToolInput, sandbox?: unknown): Promise<ToolResult>;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=bash-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash-tool.d.ts","sourceRoot":"","sources":["../../../src/tools/infrastructure/bash-tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAkBhG,KAAK,iBAAiB,GAAG;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,KAAK,iBAAiB,GAAG,CACvB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,KACd,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEhC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC;CAC5C;AAED,qBAAa,QAAS,YAAW,OAAO;IACtC,QAAQ,CAAC,IAAI,UAAU;IACvB,QAAQ,CAAC,WAAW,SAAiC;IACrD,QAAQ,CAAC,WAAW,0BAAiC;IACrD,QAAQ,CAAC,WAAW,iDAAiC;IAErD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAoB;gBAEtC,OAAO,GAAE,eAAoB;IAInC,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;CAuDxE"}
@@ -0,0 +1,84 @@
1
+ import { execFile as execFileCallback } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+ import { TOOL_SCHEMAS } from "../domain/tool.js";
4
+ import { getSandboxContext, optionalNumber, optionalString, requireString, resolvePath, toErrorResult, toSuccessResult, validateCommand, validateReadPath, } from "./tool-helpers.js";
5
+ const execFile = promisify(execFileCallback);
6
+ const DEFAULT_TIMEOUT_MS = 30_000;
7
+ const MAX_TIMEOUT_MS = 300_000;
8
+ const MAX_BUFFER = 2 * 1024 * 1024;
9
+ export class BashTool {
10
+ name = "bash";
11
+ description = TOOL_SCHEMAS.bash.description;
12
+ inputSchema = TOOL_SCHEMAS.bash.inputSchema;
13
+ annotations = TOOL_SCHEMAS.bash.annotations;
14
+ commandRunner;
15
+ constructor(options = {}) {
16
+ this.commandRunner = options.commandRunner ?? runBashCommand;
17
+ }
18
+ async execute(input, sandbox) {
19
+ const commandInput = requireString(input, "command");
20
+ if (!commandInput.ok) {
21
+ return commandInput.result;
22
+ }
23
+ const timeoutInput = parseTimeout(input);
24
+ if (!timeoutInput.ok) {
25
+ return toErrorResult(timeoutInput.message);
26
+ }
27
+ const sandboxContext = getSandboxContext(sandbox);
28
+ const cwd = resolvePath(optionalString(input, "cwd") ?? sandboxContext?.cwd ?? process.cwd(), sandbox);
29
+ // Validate cwd is within sandbox boundaries (read access implies path containment)
30
+ const cwdError = validateReadPath(cwd, sandbox);
31
+ if (cwdError) {
32
+ return toErrorResult(cwdError, { cwd });
33
+ }
34
+ const commandError = validateCommand(commandInput.value, cwd, sandbox);
35
+ if (commandError) {
36
+ return toErrorResult(commandError, { cwd, command: commandInput.value });
37
+ }
38
+ try {
39
+ const result = await this.commandRunner(commandInput.value, cwd, timeoutInput.value);
40
+ const output = [result.stdout, result.stderr].filter(Boolean).join("").trim();
41
+ return toSuccessResult(output, {
42
+ cwd,
43
+ command: commandInput.value,
44
+ timeoutMs: timeoutInput.value,
45
+ });
46
+ }
47
+ catch (error) {
48
+ const err = error;
49
+ const message = [err.stderr, err.stdout].filter(Boolean).join("").trim() ||
50
+ err.message ||
51
+ "bash command failed";
52
+ return toErrorResult(message, {
53
+ cwd,
54
+ command: commandInput.value,
55
+ timeoutMs: timeoutInput.value,
56
+ code: err.code,
57
+ signal: err.signal,
58
+ });
59
+ }
60
+ }
61
+ }
62
+ function parseTimeout(input) {
63
+ const timeout = optionalNumber(input, "timeout");
64
+ if (timeout === undefined) {
65
+ if (input.input["timeout"] !== undefined) {
66
+ return { ok: false, message: 'Invalid input: "timeout" must be a finite number' };
67
+ }
68
+ return { ok: true, value: DEFAULT_TIMEOUT_MS };
69
+ }
70
+ if (timeout <= 0) {
71
+ return { ok: false, message: 'Invalid input: "timeout" must be > 0' };
72
+ }
73
+ return { ok: true, value: Math.min(timeout, MAX_TIMEOUT_MS) };
74
+ }
75
+ async function runBashCommand(command, cwd, timeoutMs) {
76
+ const { stdout, stderr } = await execFile("bash", ["-c", command], {
77
+ cwd,
78
+ timeout: timeoutMs,
79
+ windowsHide: true,
80
+ maxBuffer: MAX_BUFFER,
81
+ });
82
+ return { stdout, stderr };
83
+ }
84
+ //# sourceMappingURL=bash-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash-tool.js","sourceRoot":"","sources":["../../../src/tools/infrastructure/bash-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAiD,MAAM,mBAAmB,CAAC;AAChG,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,aAAa,EACb,WAAW,EACX,aAAa,EACb,eAAe,EACf,eAAe,EACf,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,QAAQ,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAAC;AAC7C,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,cAAc,GAAG,OAAO,CAAC;AAC/B,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAiBnC,MAAM,OAAO,QAAQ;IACV,IAAI,GAAG,MAAM,CAAC;IAC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SAAS,EAAE,CAAC;YACzC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,kDAAkD,EAAE,CAAC;QACpF,CAAC;QAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC;IACjD,CAAC;IAED,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;QACjB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,sCAAsC,EAAE,CAAC;IACxE,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE,CAAC;AAChE,CAAC;AAED,KAAK,UAAU,cAAc,CAC3B,OAAe,EACf,GAAW,EACX,SAAiB;IAEjB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE;QACjE,GAAG;QACH,OAAO,EAAE,SAAS;QAClB,WAAW,EAAE,IAAI;QACjB,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { type DevTool, type ToolInput, type ToolResult } from "../domain/tool.js";
2
+ export declare class EditTool implements DevTool {
3
+ readonly name = "edit";
4
+ readonly description: string;
5
+ readonly inputSchema: Record<string, unknown>;
6
+ readonly annotations: import("../domain/tool.js").DevToolAnnotations;
7
+ execute(input: ToolInput, sandbox?: unknown): Promise<ToolResult>;
8
+ }
9
+ //# sourceMappingURL=edit-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit-tool.d.ts","sourceRoot":"","sources":["../../../src/tools/infrastructure/edit-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA0ChG,qBAAa,QAAS,YAAW,OAAO;IACtC,QAAQ,CAAC,IAAI,UAAU;IACvB,QAAQ,CAAC,WAAW,SAAiC;IACrD,QAAQ,CAAC,WAAW,0BAAiC;IACrD,QAAQ,CAAC,WAAW,iDAAiC;IAE/C,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;CAwDxE"}
@@ -0,0 +1,80 @@
1
+ import { readFile, writeFile } from "node:fs/promises";
2
+ import { TOOL_SCHEMAS } from "../domain/tool.js";
3
+ import { optionalBoolean, requireString, resolvePath, toErrorResult, toSuccessResult, validateReadPath, validateWritePath, } from "./tool-helpers.js";
4
+ function replaceSingle(source, oldString, newString) {
5
+ const index = source.indexOf(oldString);
6
+ if (index < 0) {
7
+ return { value: source, count: 0 };
8
+ }
9
+ const value = `${source.slice(0, index)}${newString}${source.slice(index + oldString.length)}`;
10
+ return { value, count: 1 };
11
+ }
12
+ function replaceAll(source, oldString, newString) {
13
+ let count = 0;
14
+ let cursor = 0;
15
+ let output = "";
16
+ while (cursor < source.length) {
17
+ const match = source.indexOf(oldString, cursor);
18
+ if (match < 0) {
19
+ output += source.slice(cursor);
20
+ break;
21
+ }
22
+ output += source.slice(cursor, match);
23
+ output += newString;
24
+ cursor = match + oldString.length;
25
+ count += 1;
26
+ }
27
+ return { value: output, count };
28
+ }
29
+ export class EditTool {
30
+ name = "edit";
31
+ description = TOOL_SCHEMAS.edit.description;
32
+ inputSchema = TOOL_SCHEMAS.edit.inputSchema;
33
+ annotations = TOOL_SCHEMAS.edit.annotations;
34
+ async execute(input, sandbox) {
35
+ const filePathInput = requireString(input, "filePath");
36
+ if (!filePathInput.ok) {
37
+ return filePathInput.result;
38
+ }
39
+ const oldStringInput = requireString(input, "oldString");
40
+ if (!oldStringInput.ok) {
41
+ return oldStringInput.result;
42
+ }
43
+ const newStringInput = requireString(input, "newString", { allowEmpty: true });
44
+ if (!newStringInput.ok) {
45
+ return newStringInput.result;
46
+ }
47
+ const absolutePath = resolvePath(filePathInput.value, sandbox);
48
+ const readError = validateReadPath(absolutePath, sandbox);
49
+ if (readError) {
50
+ return toErrorResult(readError, { filePath: absolutePath });
51
+ }
52
+ const writeError = validateWritePath(absolutePath, sandbox);
53
+ if (writeError) {
54
+ return toErrorResult(writeError, { filePath: absolutePath });
55
+ }
56
+ const replaceEveryMatch = optionalBoolean(input, "replaceAll") ?? false;
57
+ try {
58
+ const content = await readFile(absolutePath, "utf8");
59
+ const replacement = replaceEveryMatch
60
+ ? replaceAll(content, oldStringInput.value, newStringInput.value)
61
+ : replaceSingle(content, oldStringInput.value, newStringInput.value);
62
+ if (replacement.count === 0) {
63
+ return toErrorResult(`No match found for "${oldStringInput.value}"`, {
64
+ filePath: absolutePath,
65
+ });
66
+ }
67
+ await writeFile(absolutePath, replacement.value, "utf8");
68
+ return toSuccessResult(`Applied ${replacement.count} replacement${replacement.count === 1 ? "" : "s"} in ${absolutePath}`, {
69
+ filePath: absolutePath,
70
+ replacements: replacement.count,
71
+ replaceAll: replaceEveryMatch,
72
+ });
73
+ }
74
+ catch (error) {
75
+ const err = error;
76
+ return toErrorResult(err.message, { filePath: absolutePath, code: err.code });
77
+ }
78
+ }
79
+ }
80
+ //# sourceMappingURL=edit-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit-tool.js","sourceRoot":"","sources":["../../../src/tools/infrastructure/edit-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAiD,MAAM,mBAAmB,CAAC;AAChG,OAAO,EACL,eAAe,EACf,aAAa,EACb,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,SAAS,aAAa,CAAC,MAAc,EAAE,SAAiB,EAAE,SAAiB;I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,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;YACrD,MAAM,WAAW,GAAG,iBAAiB;gBACnC,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC;gBACjE,CAAC,CAAC,aAAa,CAAC,OAAO,EAAE,cAAc,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;YAEvE,IAAI,WAAW,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;gBAC5B,OAAO,aAAa,CAAC,uBAAuB,cAAc,CAAC,KAAK,GAAG,EAAE;oBACnE,QAAQ,EAAE,YAAY;iBACvB,CAAC,CAAC;YACL,CAAC;YAED,MAAM,SAAS,CAAC,YAAY,EAAE,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YAEzD,OAAO,eAAe,CACpB,WAAW,WAAW,CAAC,KAAK,eAAe,WAAW,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,YAAY,EAAE,EAClG;gBACE,QAAQ,EAAE,YAAY;gBACtB,YAAY,EAAE,WAAW,CAAC,KAAK;gBAC/B,UAAU,EAAE,iBAAiB;aAC9B,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,KAA8B,CAAC;YAC3C,OAAO,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import { type DevTool, type ToolInput, type ToolResult } from "../domain/tool.js";
2
+ type GitCommandResult = {
3
+ readonly stdout: string;
4
+ readonly stderr: string;
5
+ };
6
+ type GitCommandRunner = (args: readonly string[], cwd: string, timeoutMs: number) => Promise<GitCommandResult>;
7
+ export interface GitToolOptions {
8
+ readonly commandRunner?: GitCommandRunner;
9
+ }
10
+ export declare class GitTool implements DevTool {
11
+ readonly name = "git";
12
+ readonly description: string;
13
+ readonly inputSchema: Record<string, unknown>;
14
+ readonly annotations: import("../domain/tool.js").DevToolAnnotations;
15
+ private readonly commandRunner;
16
+ constructor(options?: GitToolOptions);
17
+ execute(input: ToolInput, sandbox?: unknown): Promise<ToolResult>;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=git-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-tool.d.ts","sourceRoot":"","sources":["../../../src/tools/infrastructure/git-tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAehG,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,KAAK,gBAAgB,GAAG,CACtB,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,KACd,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE/B,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,gBAAgB,CAAC;CAC3C;AAED,qBAAa,OAAQ,YAAW,OAAO;IACrC,QAAQ,CAAC,IAAI,SAAS;IACtB,QAAQ,CAAC,WAAW,SAAgC;IACpD,QAAQ,CAAC,WAAW,0BAAgC;IACpD,QAAQ,CAAC,WAAW,iDAAgC;IAEpD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAmB;gBAErC,OAAO,GAAE,cAAmB;IAIlC,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;CAuDxE"}
@@ -0,0 +1,85 @@
1
+ import { execFile as execFileCallback } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+ import { TOOL_SCHEMAS } from "../domain/tool.js";
4
+ import { getSandboxContext, resolvePath, requireString, toErrorResult, toSuccessResult, validateCommand, validateReadPath, } from "./tool-helpers.js";
5
+ const execFile = promisify(execFileCallback);
6
+ const DEFAULT_TIMEOUT_MS = 30_000;
7
+ const MAX_BUFFER = 2 * 1024 * 1024;
8
+ export class GitTool {
9
+ name = "git";
10
+ description = TOOL_SCHEMAS.git.description;
11
+ inputSchema = TOOL_SCHEMAS.git.inputSchema;
12
+ annotations = TOOL_SCHEMAS.git.annotations;
13
+ commandRunner;
14
+ constructor(options = {}) {
15
+ this.commandRunner = options.commandRunner ?? runGitCommand;
16
+ }
17
+ async execute(input, sandbox) {
18
+ const subcommandInput = requireString(input, "subcommand");
19
+ if (!subcommandInput.ok) {
20
+ return subcommandInput.result;
21
+ }
22
+ const argsInput = readArgs(input);
23
+ if (!argsInput.ok) {
24
+ return toErrorResult(argsInput.message);
25
+ }
26
+ const sandboxContext = getSandboxContext(sandbox);
27
+ const cwd = resolvePath(sandboxContext?.cwd ?? process.cwd(), sandbox);
28
+ const cwdError = validateReadPath(cwd, sandbox);
29
+ if (cwdError) {
30
+ return toErrorResult(cwdError, { cwd });
31
+ }
32
+ const commandString = toCommandString(subcommandInput.value, argsInput.value);
33
+ const commandError = validateCommand(commandString, cwd, sandbox);
34
+ if (commandError) {
35
+ return toErrorResult(commandError, { cwd, command: commandString });
36
+ }
37
+ const allArgs = [subcommandInput.value, ...argsInput.value];
38
+ try {
39
+ const result = await this.commandRunner(allArgs, cwd, DEFAULT_TIMEOUT_MS);
40
+ const output = [result.stdout, result.stderr].filter(Boolean).join("").trim();
41
+ return toSuccessResult(output, {
42
+ cwd,
43
+ command: commandString,
44
+ });
45
+ }
46
+ catch (error) {
47
+ const err = error;
48
+ const message = [err.stderr, err.stdout].filter(Boolean).join("").trim() ||
49
+ err.message ||
50
+ "git command failed";
51
+ return toErrorResult(message, {
52
+ cwd,
53
+ command: commandString,
54
+ code: err.code,
55
+ signal: err.signal,
56
+ });
57
+ }
58
+ }
59
+ }
60
+ function readArgs(input) {
61
+ const rawArgs = input.input["args"];
62
+ if (rawArgs === undefined) {
63
+ return { ok: true, value: [] };
64
+ }
65
+ if (!Array.isArray(rawArgs) || rawArgs.some((value) => typeof value !== "string")) {
66
+ return { ok: false, message: "Invalid input: \"args\" must be an array of strings" };
67
+ }
68
+ return { ok: true, value: [...rawArgs] };
69
+ }
70
+ function toCommandString(subcommand, args) {
71
+ if (args.length === 0) {
72
+ return `git ${subcommand}`;
73
+ }
74
+ return `git ${subcommand} ${args.join(" ")}`;
75
+ }
76
+ async function runGitCommand(args, cwd, timeoutMs) {
77
+ const { stdout, stderr } = await execFile("git", args, {
78
+ cwd,
79
+ timeout: timeoutMs,
80
+ windowsHide: true,
81
+ maxBuffer: MAX_BUFFER,
82
+ });
83
+ return { stdout, stderr };
84
+ }
85
+ //# sourceMappingURL=git-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-tool.js","sourceRoot":"","sources":["../../../src/tools/infrastructure/git-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAiD,MAAM,mBAAmB,CAAC;AAChG,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,EACf,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,QAAQ,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAAC;AAC7C,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAiBnC,MAAM,OAAO,OAAO;IACT,IAAI,GAAG,KAAK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AE,CAAC;IACjC,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,EAAE,CAAC;QAClF,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,qDAAqD,EAAE,CAAC;IACvF,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE,CAAC;AAC3C,CAAC;AAED,SAAS,eAAe,CAAC,UAAkB,EAAE,IAAuB;IAClE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,OAAO,UAAU,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,OAAO,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC/C,CAAC;AAED,KAAK,UAAU,aAAa,CAC1B,IAAuB,EACvB,GAAW,EACX,SAAiB;IAEjB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE;QACrD,GAAG;QACH,OAAO,EAAE,SAAS;QAClB,WAAW,EAAE,IAAI;QACjB,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { type ToolEnvironment } from "../domain/tool-environment.js";
2
+ import { type DevTool, type ToolInput, type ToolResult } from "../domain/tool.js";
3
+ import { type CommandResult } from "./tool-helpers.js";
4
+ type GlobCommandRunner = (binary: string, args: readonly string[], cwd: string, timeoutMs: number) => Promise<CommandResult>;
5
+ type EnvironmentProvider = () => Promise<ToolEnvironment>;
6
+ export interface GlobToolOptions {
7
+ readonly commandRunner?: GlobCommandRunner;
8
+ readonly environmentProvider?: EnvironmentProvider;
9
+ }
10
+ export declare class GlobTool implements DevTool {
11
+ readonly name = "glob";
12
+ readonly description: string;
13
+ readonly inputSchema: Record<string, unknown>;
14
+ readonly annotations: import("../domain/tool.js").DevToolAnnotations;
15
+ private readonly commandRunner;
16
+ private readonly environmentProvider;
17
+ constructor(options?: GlobToolOptions);
18
+ execute(input: ToolInput, sandbox?: unknown): Promise<ToolResult>;
19
+ private executeFastPath;
20
+ private executeFallback;
21
+ }
22
+ export {};
23
+ //# sourceMappingURL=glob-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob-tool.d.ts","sourceRoot":"","sources":["../../../src/tools/infrastructure/glob-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,aAAa,EAYnB,MAAM,mBAAmB,CAAC;AAI3B,KAAK,iBAAiB,GAAG,CACvB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,KACd,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5B,KAAK,mBAAmB,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAC3C,QAAQ,CAAC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CACpD;AAED,qBAAa,QAAS,YAAW,OAAO;IACtC,QAAQ,CAAC,IAAI,UAAU;IACvB,QAAQ,CAAC,WAAW,SAAiC;IACrD,QAAQ,CAAC,WAAW,0BAAiC;IACrD,QAAQ,CAAC,WAAW,iDAAiC;IAErD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAoB;IAClD,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAsB;gBAE9C,OAAO,GAAE,eAAoB;IAKnC,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;YA+BzD,eAAe;YA4Cf,eAAe;CA0B9B"}
@@ -0,0 +1,88 @@
1
+ import { basename, relative } from "node:path";
2
+ import { detectToolEnvironment, } from "../domain/tool-environment.js";
3
+ import { TOOL_SCHEMAS, } from "../domain/tool.js";
4
+ import { getSandboxContext, matchesGlob, normalizePath, optionalString, requireString, resolvePath, runCommand as defaultRunCommand, toErrorResult, toSuccessResult, validateReadPath, walkFiles, } from "./tool-helpers.js";
5
+ const DEFAULT_TIMEOUT_MS = 30_000;
6
+ export class GlobTool {
7
+ name = "glob";
8
+ description = TOOL_SCHEMAS.glob.description;
9
+ inputSchema = TOOL_SCHEMAS.glob.inputSchema;
10
+ annotations = TOOL_SCHEMAS.glob.annotations;
11
+ commandRunner;
12
+ environmentProvider;
13
+ constructor(options = {}) {
14
+ this.commandRunner = options.commandRunner ?? defaultRunCommand;
15
+ this.environmentProvider = options.environmentProvider ?? detectToolEnvironment;
16
+ }
17
+ async execute(input, sandbox) {
18
+ const patternInput = requireString(input, "pattern");
19
+ if (!patternInput.ok) {
20
+ return patternInput.result;
21
+ }
22
+ const sandboxContext = getSandboxContext(sandbox);
23
+ const searchRoot = resolvePath(optionalString(input, "path") ?? sandboxContext?.cwd ?? process.cwd(), sandbox);
24
+ const rootReadError = validateReadPath(searchRoot, sandbox);
25
+ if (rootReadError) {
26
+ return toErrorResult(rootReadError, { path: searchRoot });
27
+ }
28
+ try {
29
+ const environment = await this.environmentProvider();
30
+ const fdPath = environment.fd?.path;
31
+ if (fdPath) {
32
+ return await this.executeFastPath(fdPath, searchRoot, patternInput.value);
33
+ }
34
+ return await this.executeFallback(searchRoot, patternInput.value, sandbox);
35
+ }
36
+ catch (error) {
37
+ const err = error;
38
+ return toErrorResult(err.message, { path: searchRoot });
39
+ }
40
+ }
41
+ async executeFastPath(fdPath, searchRoot, pattern) {
42
+ const args = ["--glob", "--type", "f", pattern, "."];
43
+ try {
44
+ const result = await this.commandRunner(fdPath, args, searchRoot, DEFAULT_TIMEOUT_MS);
45
+ return toSuccessResult(result.stdout.trim(), {
46
+ path: searchRoot,
47
+ strategy: "fd",
48
+ });
49
+ }
50
+ catch (error) {
51
+ const err = error;
52
+ if (String(err.code) === "1") {
53
+ return toSuccessResult("", {
54
+ path: searchRoot,
55
+ strategy: "fd",
56
+ noMatches: true,
57
+ });
58
+ }
59
+ const message = [err.stderr, err.stdout].filter(Boolean).join("").trim() ||
60
+ err.message ||
61
+ "fd execution failed";
62
+ return toErrorResult(message, {
63
+ path: searchRoot,
64
+ strategy: "fd",
65
+ });
66
+ }
67
+ }
68
+ async executeFallback(searchRoot, pattern, sandbox) {
69
+ const files = await walkFiles(searchRoot);
70
+ const matches = [];
71
+ for (const filePath of files) {
72
+ const readError = validateReadPath(filePath, sandbox);
73
+ if (readError) {
74
+ continue;
75
+ }
76
+ const relativePath = normalizePath(relative(searchRoot, filePath) || basename(filePath));
77
+ if (matchesGlob(relativePath, pattern)) {
78
+ matches.push(relativePath);
79
+ }
80
+ }
81
+ return toSuccessResult(matches.join("\n"), {
82
+ path: searchRoot,
83
+ strategy: "fallback",
84
+ count: matches.length,
85
+ });
86
+ }
87
+ }
88
+ //# sourceMappingURL=glob-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob-tool.js","sourceRoot":"","sources":["../../../src/tools/infrastructure/glob-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EACL,qBAAqB,GAEtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,YAAY,GAIb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,cAAc,EACd,aAA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