@crewx/sdk 0.8.0-rc.80 → 0.8.0-rc.83

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 (217) hide show
  1. package/dist/__tests__/adapter/context-builder.test.d.ts +1 -0
  2. package/dist/__tests__/adapter/plugin-helper.test.d.ts +1 -0
  3. package/dist/__tests__/adapter/registration-integration.test.d.ts +1 -0
  4. package/dist/__tests__/adapter/scoped-store.test.d.ts +1 -0
  5. package/dist/__tests__/plugins/conversation.test.d.ts +1 -0
  6. package/dist/__tests__/testing/createMockContext.test.d.ts +1 -0
  7. package/dist/adapter/context-builder.d.ts +0 -9
  8. package/dist/adapter/index.d.ts +0 -1
  9. package/dist/adapter/plugin-helper.d.ts +0 -7
  10. package/dist/adapter/scoped-store.d.ts +0 -10
  11. package/dist/adapter/types.d.ts +0 -7
  12. package/dist/agent/resolver.d.ts +0 -13
  13. package/dist/boxing/box-storage.interface.d.ts +0 -4
  14. package/dist/boxing/box.service.d.ts +0 -4
  15. package/dist/boxing/box.types.d.ts +0 -4
  16. package/dist/boxing/context-builder.d.ts +0 -4
  17. package/dist/client/CrewxClient.d.ts +0 -32
  18. package/dist/client/index.d.ts +0 -1
  19. package/dist/client/index.js +1 -6
  20. package/dist/config/loader.browser.d.ts +0 -8
  21. package/dist/config/loader.d.ts +0 -12
  22. package/dist/conversation/__tests__/sqlite-provider.test.d.ts +1 -0
  23. package/dist/conversation/__tests__/to-task-reader.test.d.ts +1 -0
  24. package/dist/conversation/index.d.ts +0 -1
  25. package/dist/conversation/sqlite-provider.d.ts +0 -9
  26. package/dist/conversation/to-task-reader.d.ts +0 -11
  27. package/dist/conversation/to-template-messages.d.ts +0 -13
  28. package/dist/conversation/types.d.ts +0 -58
  29. package/dist/esm/client/index.js +1 -0
  30. package/dist/esm/hooks/index.js +7 -0
  31. package/dist/esm/index.js +79 -0
  32. package/dist/esm/plugins/index.js +52 -0
  33. package/dist/esm/testing/index.js +1 -0
  34. package/dist/esm/tools/node/index.js +36 -0
  35. package/dist/events/TypedEventEmitter.d.ts +0 -24
  36. package/dist/events/types.d.ts +0 -43
  37. package/dist/facade/Crewx.browser.d.ts +0 -40
  38. package/dist/facade/Crewx.d.ts +0 -163
  39. package/dist/hooks/define.d.ts +0 -1
  40. package/dist/hooks/dispatch.d.ts +0 -12
  41. package/dist/hooks/index.d.ts +0 -1
  42. package/dist/hooks/index.js +7 -24
  43. package/dist/hooks/observer.d.ts +0 -1
  44. package/dist/hooks/plugin.d.ts +0 -1
  45. package/dist/hooks/tool-normalize.d.ts +0 -26
  46. package/dist/hooks/types.d.ts +0 -1
  47. package/dist/hooks/yaml-plugin.d.ts +0 -1
  48. package/dist/index.browser.d.ts +0 -7
  49. package/dist/index.browser.js +2 -25
  50. package/dist/index.d.ts +0 -4
  51. package/dist/index.js +79 -151
  52. package/dist/layout/loader.d.ts +0 -20
  53. package/dist/layout/props-validator.d.ts +0 -6
  54. package/dist/layout/renderer.d.ts +0 -24
  55. package/dist/layout/types.d.ts +0 -42
  56. package/dist/parallel/agent-runtime.d.ts +0 -11
  57. package/dist/parallel/helpers.d.ts +0 -1
  58. package/dist/parallel/index.d.ts +0 -1
  59. package/dist/parallel/parallel-runner.d.ts +0 -8
  60. package/dist/parallel/types.d.ts +0 -24
  61. package/dist/parsers/agent-call.util.d.ts +0 -3
  62. package/dist/parsers/claude.parser.d.ts +0 -8
  63. package/dist/parsers/codex.parser.d.ts +0 -8
  64. package/dist/parsers/copilot.parser.d.ts +0 -9
  65. package/dist/parsers/gemini.parser.d.ts +0 -10
  66. package/dist/parsers/opencode.parser.d.ts +0 -10
  67. package/dist/parsers/router.d.ts +0 -5
  68. package/dist/paths.d.ts +1 -0
  69. package/dist/platform/BrowserFsAdapter.d.ts +0 -20
  70. package/dist/platform/IFsAdapter.d.ts +0 -23
  71. package/dist/platform/NodeFsAdapter.d.ts +0 -8
  72. package/dist/plugin/plugin-provider.d.ts +0 -22
  73. package/dist/plugin/types.d.ts +0 -31
  74. package/dist/plugin.d.ts +0 -27
  75. package/dist/plugins/conversation.d.ts +0 -2
  76. package/dist/plugins/file-logger.d.ts +0 -13
  77. package/dist/plugins/index.d.ts +0 -10
  78. package/dist/plugins/index.js +52 -19
  79. package/dist/plugins/sqlite-tracing.d.ts +0 -13
  80. package/dist/plugins/sqlite-tracing.spec.d.ts +1 -0
  81. package/dist/provider/bridge.browser.d.ts +0 -20
  82. package/dist/provider/bridge.d.ts +0 -47
  83. package/dist/provider/parse-usage.d.ts +0 -14
  84. package/dist/provider/register-api.d.ts +0 -7
  85. package/dist/provider/vercel-runtime.d.ts +0 -29
  86. package/dist/remote/index.d.ts +0 -6
  87. package/dist/remote/remote-agent-manager.d.ts +0 -31
  88. package/dist/remote/remote-provider.d.ts +0 -15
  89. package/dist/remote/remote-transport.d.ts +0 -17
  90. package/dist/remote/types.d.ts +0 -59
  91. package/dist/server/auth.d.ts +0 -16
  92. package/dist/server/handler.d.ts +0 -17
  93. package/dist/server/index.d.ts +0 -4
  94. package/dist/server/tool-adapter.d.ts +0 -16
  95. package/dist/template/engine.d.ts +0 -19
  96. package/dist/template/helpers/exec.browser.d.ts +0 -7
  97. package/dist/template/helpers/exec.d.ts +0 -45
  98. package/dist/template/helpers/fenced_code.d.ts +0 -16
  99. package/dist/template/helpers/format-conversation.d.ts +0 -22
  100. package/dist/template/helpers/include.d.ts +0 -15
  101. package/dist/template/helpers/p1p2.d.ts +0 -32
  102. package/dist/template/loader/DocumentLoader.d.ts +0 -30
  103. package/dist/template/types.d.ts +0 -30
  104. package/dist/testing/index.d.ts +0 -1
  105. package/dist/testing/index.js +1 -16
  106. package/dist/testing/mock-audit.d.ts +0 -1
  107. package/dist/testing/mock-context.d.ts +0 -1
  108. package/dist/testing/mock-logger.d.ts +0 -1
  109. package/dist/testing/mock-router.d.ts +0 -1
  110. package/dist/testing/mock-storage.d.ts +0 -1
  111. package/dist/testing/mock-store.d.ts +0 -1
  112. package/dist/tools/delegate.d.ts +0 -7
  113. package/dist/tools/index.d.ts +0 -4
  114. package/dist/tools/node/builtin.d.ts +0 -16
  115. package/dist/tools/node/index.d.ts +0 -20
  116. package/dist/tools/node/index.js +36 -59
  117. package/dist/types/index.d.ts +0 -20
  118. package/dist/types/task-log.types.d.ts +0 -4
  119. package/dist/utils/env-defaults.d.ts +0 -16
  120. package/dist/utils/glob-match.d.ts +0 -16
  121. package/dist/utils/id.d.ts +0 -15
  122. package/dist/utils/timestamp.d.ts +0 -1
  123. package/dist/utils/workspace.d.ts +0 -4
  124. package/package.json +24 -25
  125. package/dist/adapter/context-builder.js +0 -87
  126. package/dist/adapter/index.js +0 -21
  127. package/dist/adapter/plugin-helper.js +0 -45
  128. package/dist/adapter/scoped-store.js +0 -43
  129. package/dist/adapter/types.js +0 -23
  130. package/dist/agent/resolver.js +0 -46
  131. package/dist/boxing/box-storage.interface.js +0 -6
  132. package/dist/boxing/box.service.js +0 -73
  133. package/dist/boxing/box.types.js +0 -6
  134. package/dist/boxing/context-builder.js +0 -79
  135. package/dist/client/CrewxClient.js +0 -86
  136. package/dist/config/loader.browser.js +0 -59
  137. package/dist/config/loader.js +0 -95
  138. package/dist/conversation/index.js +0 -25
  139. package/dist/conversation/sqlite-provider.js +0 -178
  140. package/dist/conversation/to-task-reader.js +0 -28
  141. package/dist/conversation/to-template-messages.js +0 -34
  142. package/dist/conversation/types.js +0 -10
  143. package/dist/events/TypedEventEmitter.js +0 -65
  144. package/dist/events/types.js +0 -9
  145. package/dist/facade/Crewx.browser.js +0 -314
  146. package/dist/facade/Crewx.js +0 -1299
  147. package/dist/hooks/define.js +0 -13
  148. package/dist/hooks/dispatch.js +0 -147
  149. package/dist/hooks/observer.js +0 -60
  150. package/dist/hooks/plugin.js +0 -17
  151. package/dist/hooks/tool-normalize.js +0 -110
  152. package/dist/hooks/types.js +0 -12
  153. package/dist/hooks/yaml-plugin.js +0 -356
  154. package/dist/layout/loader.js +0 -305
  155. package/dist/layout/props-validator.js +0 -301
  156. package/dist/layout/renderer.js +0 -193
  157. package/dist/layout/types.js +0 -36
  158. package/dist/parallel/agent-runtime.js +0 -25
  159. package/dist/parallel/helpers.js +0 -219
  160. package/dist/parallel/index.js +0 -13
  161. package/dist/parallel/parallel-runner.js +0 -226
  162. package/dist/parallel/types.js +0 -6
  163. package/dist/parsers/agent-call.util.js +0 -19
  164. package/dist/parsers/claude.parser.js +0 -67
  165. package/dist/parsers/codex.parser.js +0 -100
  166. package/dist/parsers/copilot.parser.js +0 -66
  167. package/dist/parsers/gemini.parser.js +0 -46
  168. package/dist/parsers/opencode.parser.js +0 -76
  169. package/dist/parsers/router.js +0 -56
  170. package/dist/platform/BrowserFsAdapter.js +0 -84
  171. package/dist/platform/IFsAdapter.js +0 -3
  172. package/dist/platform/NodeFsAdapter.js +0 -38
  173. package/dist/plugin/plugin-provider.js +0 -207
  174. package/dist/plugin/types.js +0 -9
  175. package/dist/plugin.js +0 -29
  176. package/dist/plugins/conversation.js +0 -59
  177. package/dist/plugins/file-logger.js +0 -87
  178. package/dist/plugins/sqlite-tracing.js +0 -112
  179. package/dist/provider/bridge.browser.js +0 -49
  180. package/dist/provider/bridge.js +0 -381
  181. package/dist/provider/parse-usage.js +0 -83
  182. package/dist/provider/register-api.js +0 -24
  183. package/dist/provider/vercel-runtime.js +0 -347
  184. package/dist/remote/index.js +0 -32
  185. package/dist/remote/remote-agent-manager.js +0 -198
  186. package/dist/remote/remote-provider.js +0 -141
  187. package/dist/remote/remote-transport.js +0 -83
  188. package/dist/remote/types.js +0 -9
  189. package/dist/server/auth.js +0 -35
  190. package/dist/server/handler.js +0 -75
  191. package/dist/server/index.js +0 -9
  192. package/dist/server/tool-adapter.js +0 -95
  193. package/dist/template/engine.js +0 -137
  194. package/dist/template/helpers/exec.browser.js +0 -41
  195. package/dist/template/helpers/exec.js +0 -230
  196. package/dist/template/helpers/fenced_code.js +0 -20
  197. package/dist/template/helpers/format-conversation.js +0 -53
  198. package/dist/template/helpers/include.js +0 -23
  199. package/dist/template/helpers/p1p2.js +0 -90
  200. package/dist/template/loader/DocumentLoader.js +0 -128
  201. package/dist/template/types.js +0 -6
  202. package/dist/testing/mock-audit.js +0 -13
  203. package/dist/testing/mock-context.js +0 -68
  204. package/dist/testing/mock-logger.js +0 -27
  205. package/dist/testing/mock-router.js +0 -67
  206. package/dist/testing/mock-storage.js +0 -21
  207. package/dist/testing/mock-store.js +0 -8
  208. package/dist/tools/delegate.js +0 -60
  209. package/dist/tools/index.js +0 -9
  210. package/dist/tools/node/builtin.js +0 -547
  211. package/dist/types/index.js +0 -32
  212. package/dist/types/task-log.types.js +0 -6
  213. package/dist/utils/env-defaults.js +0 -27
  214. package/dist/utils/glob-match.js +0 -42
  215. package/dist/utils/id.js +0 -50
  216. package/dist/utils/timestamp.js +0 -13
  217. package/dist/utils/workspace.js +0 -58
@@ -1,547 +0,0 @@
1
- "use strict";
2
- /**
3
- * Built-in tool definitions for api/* provider agents.
4
- *
5
- * Adapted from packages/sdk-bak/src/tools/.
6
- * Uses only Node.js built-ins — no external dependencies.
7
- *
8
- * Each entry in BUILTIN_TOOL_REGISTRY matches Omit<ToolDefinition, 'name'>.
9
- * Register via crewx.registerTool(name, BUILTIN_TOOL_REGISTRY[name]).
10
- */
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.BUILTIN_TOOL_REGISTRY = void 0;
16
- const node_path_1 = __importDefault(require("node:path"));
17
- const promises_1 = __importDefault(require("node:fs/promises"));
18
- const node_child_process_1 = require("node:child_process");
19
- const node_util_1 = require("node:util");
20
- const execAsync = (0, node_util_1.promisify)(node_child_process_1.exec);
21
- // ─────────────────────────────────────────────────────────────────────────────
22
- // Shared helpers
23
- // ─────────────────────────────────────────────────────────────────────────────
24
- const SKIP_DIRS = new Set(['node_modules', '.git', 'dist', 'build', '.next']);
25
- async function listRecursive(dirPath, basePath, maxDepth = 5, depth = 0) {
26
- if (depth >= maxDepth) {
27
- return [`${node_path_1.default.relative(basePath, dirPath)}/ (max depth reached)`];
28
- }
29
- const results = [];
30
- let entries;
31
- try {
32
- entries = await promises_1.default.readdir(dirPath, { withFileTypes: true });
33
- }
34
- catch {
35
- return [`${node_path_1.default.relative(basePath, dirPath)}/ (permission denied)`];
36
- }
37
- for (const entry of entries) {
38
- const fullPath = node_path_1.default.join(dirPath, entry.name);
39
- const rel = node_path_1.default.relative(basePath, fullPath);
40
- if (entry.isDirectory()) {
41
- results.push(`${rel}/`);
42
- const sub = await listRecursive(fullPath, basePath, maxDepth, depth + 1);
43
- results.push(...sub);
44
- }
45
- else {
46
- const s = await promises_1.default.stat(fullPath);
47
- results.push(`${rel} (${s.size} bytes)`);
48
- }
49
- }
50
- return results;
51
- }
52
- async function buildTreeLines(dirPath, opts) {
53
- const { currentDepth, maxDepth } = opts;
54
- const indent = ' '.repeat(currentDepth);
55
- let entries;
56
- try {
57
- entries = await promises_1.default.readdir(dirPath, { withFileTypes: true });
58
- }
59
- catch (err) {
60
- const code = err.code ?? 'unknown';
61
- return [`${indent}(error: ${code})`];
62
- }
63
- entries.sort((a, b) => {
64
- if (a.isDirectory() && !b.isDirectory())
65
- return -1;
66
- if (!a.isDirectory() && b.isDirectory())
67
- return 1;
68
- return a.name.localeCompare(b.name);
69
- });
70
- const lines = [];
71
- for (const entry of entries) {
72
- const fullPath = node_path_1.default.join(dirPath, entry.name);
73
- if (entry.isDirectory()) {
74
- lines.push(`${indent}[DIR] ${entry.name}/`);
75
- if (currentDepth < maxDepth) {
76
- const child = await buildTreeLines(fullPath, {
77
- currentDepth: currentDepth + 1,
78
- maxDepth,
79
- });
80
- lines.push(...child);
81
- }
82
- else {
83
- lines.push(`${' '.repeat(currentDepth + 1)}(max depth reached)`);
84
- }
85
- }
86
- else {
87
- try {
88
- const s = await promises_1.default.stat(fullPath);
89
- lines.push(`${indent}[FILE] ${entry.name} (${s.size} bytes)`);
90
- }
91
- catch {
92
- lines.push(`${indent}[FILE] ${entry.name} (stat error)`);
93
- }
94
- }
95
- }
96
- return lines;
97
- }
98
- async function searchFile(filePath, pattern, basePath) {
99
- try {
100
- const content = await promises_1.default.readFile(filePath, 'utf-8');
101
- const lines = content.split('\n');
102
- const rel = node_path_1.default.relative(basePath, filePath);
103
- return lines.flatMap((line, i) => pattern.test(line) ? [`${rel}:${i + 1}: ${line}`] : []);
104
- }
105
- catch {
106
- return [];
107
- }
108
- }
109
- async function searchRecursive(dirPath, pattern, basePath, maxDepth = 10, depth = 0) {
110
- if (depth >= maxDepth)
111
- return [];
112
- const results = [];
113
- let entries;
114
- try {
115
- entries = await promises_1.default.readdir(dirPath, { withFileTypes: true });
116
- }
117
- catch {
118
- return [];
119
- }
120
- for (const entry of entries) {
121
- const fullPath = node_path_1.default.join(dirPath, entry.name);
122
- if (entry.isDirectory()) {
123
- if (!SKIP_DIRS.has(entry.name)) {
124
- const sub = await searchRecursive(fullPath, pattern, basePath, maxDepth, depth + 1);
125
- results.push(...sub);
126
- }
127
- }
128
- else {
129
- const m = await searchFile(fullPath, pattern, basePath);
130
- results.push(...m);
131
- }
132
- }
133
- return results;
134
- }
135
- function matchWildcard(name, pattern, caseSensitive) {
136
- const n = caseSensitive ? name : name.toLowerCase();
137
- const p = caseSensitive ? pattern : pattern.toLowerCase();
138
- const regexStr = p
139
- .replace(/[.+^${}()|[\]\\]/g, '\\$&')
140
- .replace(/\*/g, '.*')
141
- .replace(/\?/g, '.');
142
- return new RegExp(`^${regexStr}$`).test(n);
143
- }
144
- async function findFiles(dirPath, pattern, caseSensitive, results, maxResults, depth = 0) {
145
- if (results.length >= maxResults || depth > 10)
146
- return;
147
- let entries;
148
- try {
149
- entries = await promises_1.default.readdir(dirPath, { withFileTypes: true });
150
- }
151
- catch {
152
- return;
153
- }
154
- for (const entry of entries) {
155
- if (results.length >= maxResults)
156
- break;
157
- const fullPath = node_path_1.default.join(dirPath, entry.name);
158
- if (entry.isDirectory()) {
159
- if (!SKIP_DIRS.has(entry.name)) {
160
- await findFiles(fullPath, pattern, caseSensitive, results, maxResults, depth + 1);
161
- }
162
- }
163
- else if (matchWildcard(entry.name, pattern, caseSensitive)) {
164
- results.push(fullPath);
165
- }
166
- }
167
- }
168
- function matchGlob(relPath, pattern) {
169
- const rel = relPath.replace(/\\/g, '/');
170
- const pat = pattern.replace(/\\/g, '/');
171
- const regexStr = pat
172
- .replace(/[.+^${}()|[\]\\]/g, '\\$&')
173
- .replace(/\*\*\//g, '§§§')
174
- .replace(/\*\*/g, '§§§')
175
- .replace(/\*/g, '[^/]*')
176
- .replace(/\?/g, '[^/]')
177
- .replace(/§§§/g, '.*');
178
- return new RegExp(`^${regexStr}$`).test(rel);
179
- }
180
- async function globSearch(dirPath, pattern, basePath, results, maxResults, depth = 0) {
181
- if (results.length >= maxResults || depth > 15)
182
- return;
183
- let entries;
184
- try {
185
- entries = await promises_1.default.readdir(dirPath, { withFileTypes: true });
186
- }
187
- catch {
188
- return;
189
- }
190
- for (const entry of entries) {
191
- if (results.length >= maxResults)
192
- break;
193
- const fullPath = node_path_1.default.join(dirPath, entry.name);
194
- if (entry.isDirectory()) {
195
- if (!SKIP_DIRS.has(entry.name)) {
196
- await globSearch(fullPath, pattern, basePath, results, maxResults, depth + 1);
197
- }
198
- }
199
- else {
200
- const rel = node_path_1.default.relative(basePath, fullPath).replace(/\\/g, '/');
201
- if (matchGlob(rel, pattern))
202
- results.push(fullPath);
203
- }
204
- }
205
- }
206
- // ─────────────────────────────────────────────────────────────────────────────
207
- // Tool definitions
208
- // ─────────────────────────────────────────────────────────────────────────────
209
- const readFileTool = {
210
- description: 'Reads and returns the content of a specified file. Use offset/limit to paginate large text files.',
211
- parameters: {
212
- type: 'object',
213
- properties: {
214
- file_path: { type: 'string', description: 'Path to the file to read.' },
215
- offset: { type: 'integer', description: 'Optional 0-based line number to start reading from.' },
216
- limit: { type: 'integer', description: 'Optional maximum number of lines to read.' },
217
- },
218
- required: ['file_path'],
219
- },
220
- execute: async (args) => {
221
- const filePath = args['file_path'];
222
- const offset = args['offset'];
223
- const limit = args['limit'];
224
- if (!filePath.trim())
225
- throw new Error("The 'file_path' parameter must be non-empty.");
226
- const resolvedPath = node_path_1.default.resolve(filePath);
227
- const content = await promises_1.default.readFile(resolvedPath, 'utf-8');
228
- if (offset !== undefined || limit !== undefined) {
229
- const lines = content.split('\n');
230
- const start = offset ?? 0;
231
- const end = limit !== undefined ? start + limit : lines.length;
232
- const slice = lines.slice(start, end);
233
- const truncated = end < lines.length;
234
- const text = slice.join('\n');
235
- if (truncated) {
236
- return `IMPORTANT: Content truncated. Showing lines ${start}-${end - 1} of ${lines.length}.\n\n${text}`;
237
- }
238
- return text;
239
- }
240
- return content;
241
- },
242
- };
243
- const writeFileTool = {
244
- description: 'Creates a new file or overwrites an existing file with the provided content.',
245
- parameters: {
246
- type: 'object',
247
- properties: {
248
- file_path: { type: 'string', description: 'Path to the file to create or overwrite.' },
249
- content: { type: 'string', description: 'The content to write to the file.' },
250
- },
251
- required: ['file_path', 'content'],
252
- },
253
- execute: async (args) => {
254
- const filePath = args['file_path'];
255
- const content = args['content'];
256
- if (!filePath.trim())
257
- throw new Error("The 'file_path' parameter must be non-empty.");
258
- const resolvedPath = node_path_1.default.resolve(filePath);
259
- await promises_1.default.mkdir(node_path_1.default.dirname(resolvedPath), { recursive: true });
260
- let fileExists = false;
261
- try {
262
- await promises_1.default.access(resolvedPath);
263
- fileExists = true;
264
- }
265
- catch { /* file does not exist */ }
266
- await promises_1.default.writeFile(resolvedPath, content, 'utf-8');
267
- const size = Buffer.byteLength(content, 'utf-8');
268
- return `${fileExists ? 'Updated' : 'Created'} file: ${filePath} (${size} bytes)`;
269
- },
270
- };
271
- const replaceTool = {
272
- description: 'Replaces a range of lines in a file with new text. Line numbers are 1-based.',
273
- parameters: {
274
- type: 'object',
275
- properties: {
276
- file_path: { type: 'string', description: 'Path to the file to modify.' },
277
- start_line: { type: 'integer', description: 'Starting line number (1-based, inclusive).' },
278
- end_line: { type: 'integer', description: 'Ending line number (1-based, inclusive).' },
279
- new_text: { type: 'string', description: 'New text to insert in place of the specified lines.' },
280
- },
281
- required: ['file_path', 'start_line', 'end_line', 'new_text'],
282
- },
283
- execute: async (args) => {
284
- const filePath = args['file_path'];
285
- const startLine = args['start_line'];
286
- const endLine = args['end_line'];
287
- const newText = args['new_text'];
288
- if (!filePath.trim())
289
- throw new Error("The 'file_path' parameter must be non-empty.");
290
- if (startLine > endLine) {
291
- throw new Error(`start_line (${startLine}) must be <= end_line (${endLine}).`);
292
- }
293
- const resolvedPath = node_path_1.default.resolve(filePath);
294
- const content = await promises_1.default.readFile(resolvedPath, 'utf-8');
295
- const lines = content.split('\n');
296
- if (startLine < 1 || startLine > lines.length) {
297
- throw new Error(`start_line (${startLine}) out of range. File has ${lines.length} lines.`);
298
- }
299
- if (endLine > lines.length) {
300
- throw new Error(`end_line (${endLine}) out of range. File has ${lines.length} lines.`);
301
- }
302
- const newLines = newText.split('\n');
303
- lines.splice(startLine - 1, endLine - startLine + 1, ...newLines);
304
- await promises_1.default.writeFile(resolvedPath, lines.join('\n'), 'utf-8');
305
- return `Successfully replaced lines ${startLine}-${endLine} in ${filePath}`;
306
- },
307
- };
308
- const lsTool = {
309
- description: "Lists contents of a directory. Shows file sizes and marks directories with trailing slashes.",
310
- parameters: {
311
- type: 'object',
312
- properties: {
313
- path: { type: 'string', description: 'Directory path to list (default: current directory).' },
314
- recursive: { type: 'boolean', description: 'List contents recursively (default: false).' },
315
- },
316
- },
317
- execute: async (args) => {
318
- const dirPath = args['path'] ?? '.';
319
- const recursive = args['recursive'] ?? false;
320
- const resolvedPath = node_path_1.default.resolve(dirPath);
321
- const stats = await promises_1.default.stat(resolvedPath);
322
- if (!stats.isDirectory())
323
- throw new Error(`Path is not a directory: ${dirPath}`);
324
- let output = `Directory listing: ${dirPath}\n\n`;
325
- if (recursive) {
326
- const entries = await listRecursive(resolvedPath, resolvedPath);
327
- output += entries.join('\n');
328
- }
329
- else {
330
- const entries = await promises_1.default.readdir(resolvedPath, { withFileTypes: true });
331
- const lines = [];
332
- for (const entry of entries) {
333
- if (entry.isDirectory()) {
334
- lines.push(`${entry.name}/`);
335
- }
336
- else {
337
- const s = await promises_1.default.stat(node_path_1.default.join(resolvedPath, entry.name));
338
- lines.push(`${entry.name} (${s.size} bytes)`);
339
- }
340
- }
341
- output += lines.join('\n');
342
- }
343
- return output || 'Directory is empty';
344
- },
345
- };
346
- const treeTool = {
347
- description: "Displays a directory tree with [DIR]/[FILE] labels up to max_depth levels.",
348
- parameters: {
349
- type: 'object',
350
- properties: {
351
- path: { type: 'string', description: 'Directory to inspect (default: current directory).' },
352
- max_depth: { type: 'integer', description: 'Maximum depth to traverse (default: 3).' },
353
- },
354
- },
355
- execute: async (args) => {
356
- const targetPath = args['path'] ?? '.';
357
- const maxDepth = args['max_depth'] ?? 3;
358
- const resolvedPath = node_path_1.default.resolve(targetPath);
359
- const stats = await promises_1.default.stat(resolvedPath);
360
- if (!stats.isDirectory())
361
- throw new Error(`Path is not a directory: ${targetPath}`);
362
- const relRoot = node_path_1.default.relative(process.cwd(), resolvedPath);
363
- const rootLabel = relRoot === '' ? '.' : relRoot;
364
- const lines = [
365
- `Tree for ${rootLabel} (max depth: ${maxDepth})`,
366
- `[DIR] ${rootLabel}/`,
367
- ];
368
- const treeLines = await buildTreeLines(resolvedPath, { currentDepth: 1, maxDepth });
369
- lines.push(...treeLines);
370
- return lines.join('\n');
371
- },
372
- };
373
- const grepTool = {
374
- description: 'Searches for a regex pattern in files. Returns matching lines with file paths and line numbers.',
375
- parameters: {
376
- type: 'object',
377
- properties: {
378
- pattern: { type: 'string', description: 'Regular expression pattern to search for.' },
379
- path: { type: 'string', description: 'File or directory path to search in (default: current directory).' },
380
- recursive: { type: 'boolean', description: 'Search recursively through subdirectories (default: true).' },
381
- },
382
- required: ['pattern'],
383
- },
384
- execute: async (args) => {
385
- const pattern = args['pattern'];
386
- const searchPath = args['path'] ?? '.';
387
- const recursive = args['recursive'] ?? true;
388
- if (!pattern.trim())
389
- throw new Error("The 'pattern' parameter must be non-empty.");
390
- let regex;
391
- try {
392
- regex = new RegExp(pattern);
393
- }
394
- catch (err) {
395
- throw new Error(`Invalid regular expression: ${err.message}`);
396
- }
397
- const resolvedPath = node_path_1.default.resolve(searchPath);
398
- const stats = await promises_1.default.stat(resolvedPath);
399
- const basePath = stats.isDirectory() ? resolvedPath : node_path_1.default.dirname(resolvedPath);
400
- let matches = [];
401
- if (stats.isDirectory()) {
402
- if (recursive) {
403
- matches = await searchRecursive(resolvedPath, regex, basePath);
404
- }
405
- else {
406
- const entries = await promises_1.default.readdir(resolvedPath, { withFileTypes: true });
407
- for (const entry of entries) {
408
- if (!entry.isDirectory()) {
409
- const m = await searchFile(node_path_1.default.join(resolvedPath, entry.name), regex, basePath);
410
- matches.push(...m);
411
- }
412
- }
413
- }
414
- }
415
- else {
416
- matches = await searchFile(resolvedPath, regex, basePath);
417
- }
418
- if (matches.length === 0)
419
- return `No matches found for pattern: ${pattern}`;
420
- const maxResults = 100;
421
- const limited = matches.slice(0, maxResults);
422
- let output = `Found ${matches.length} match(es) for pattern: ${pattern}\n\n${limited.join('\n')}`;
423
- if (matches.length > maxResults) {
424
- output += `\n\n... and ${matches.length - maxResults} more (output truncated)`;
425
- }
426
- return output;
427
- },
428
- };
429
- const findTool = {
430
- description: 'Searches for files by filename pattern. Supports * and ? wildcards.',
431
- parameters: {
432
- type: 'object',
433
- properties: {
434
- pattern: { type: 'string', description: 'Filename pattern. Supports * and ? wildcards.' },
435
- dir_path: { type: 'string', description: 'Directory to search in (default: current directory).' },
436
- case_sensitive: { type: 'boolean', description: 'Case-sensitive matching (default: false).' },
437
- max_results: { type: 'integer', description: 'Maximum results to return (default: 50).' },
438
- },
439
- required: ['pattern'],
440
- },
441
- execute: async (args) => {
442
- const pattern = args['pattern'];
443
- const dirPath = args['dir_path'] ?? '.';
444
- const caseSensitive = args['case_sensitive'] ?? false;
445
- const maxResults = args['max_results'] ?? 50;
446
- const searchDir = node_path_1.default.resolve(dirPath);
447
- const matches = [];
448
- await findFiles(searchDir, pattern, caseSensitive, matches, maxResults);
449
- if (matches.length === 0) {
450
- return `No files found matching pattern: ${pattern}\nSearched in: ${searchDir}`;
451
- }
452
- const lines = matches.map((p, i) => ` ${i + 1}. ${node_path_1.default.relative(process.cwd(), p)}`);
453
- const footer = matches.length >= maxResults ? `\n(Limited to ${maxResults} results)` : '';
454
- return `Found ${matches.length} file(s) matching "${pattern}":\n${lines.join('\n')}${footer}`;
455
- },
456
- };
457
- const globTool = {
458
- description: 'Finds files matching glob patterns (e.g., "**/*.ts", "src/**/*.yaml"). Returns file paths.',
459
- parameters: {
460
- type: 'object',
461
- properties: {
462
- pattern: { type: 'string', description: 'Glob pattern to match files against.' },
463
- dir_path: { type: 'string', description: 'Directory to search in (default: current directory).' },
464
- max_results: { type: 'integer', description: 'Maximum results to return (default: 100).' },
465
- },
466
- required: ['pattern'],
467
- },
468
- execute: async (args) => {
469
- const pattern = args['pattern'];
470
- const dirPath = args['dir_path'] ?? '.';
471
- const maxResults = args['max_results'] ?? 100;
472
- const searchDir = node_path_1.default.resolve(dirPath);
473
- const matches = [];
474
- await globSearch(searchDir, pattern, searchDir, matches, maxResults);
475
- if (matches.length === 0) {
476
- return `No files found matching pattern: ${pattern}\nSearched in: ${searchDir}`;
477
- }
478
- const lines = matches.map((p, i) => ` ${i + 1}. ${node_path_1.default.relative(process.cwd(), p)}`);
479
- const footer = matches.length >= maxResults ? `\n(Limited to ${maxResults} results)` : '';
480
- return `Found ${matches.length} file(s) matching "${pattern}":\n${lines.join('\n')}${footer}`;
481
- },
482
- };
483
- const runShellCommandTool = {
484
- description: 'Executes a shell command and returns its output (stdout and stderr). Use with caution.',
485
- parameters: {
486
- type: 'object',
487
- properties: {
488
- command: { type: 'string', description: 'The shell command to execute.' },
489
- timeout_seconds: { type: 'integer', description: 'Maximum execution time in seconds (default: 30).' },
490
- },
491
- required: ['command'],
492
- },
493
- execute: async (args) => {
494
- const command = args['command'];
495
- const timeoutSeconds = args['timeout_seconds'] ?? 30;
496
- if (!command.trim())
497
- throw new Error("The 'command' parameter must be non-empty.");
498
- try {
499
- const { stdout, stderr } = await execAsync(command, {
500
- timeout: timeoutSeconds * 1000,
501
- maxBuffer: 10 * 1024 * 1024,
502
- cwd: process.cwd(),
503
- });
504
- let output = '';
505
- if (stdout)
506
- output += `STDOUT:\n${stdout}`;
507
- if (stderr)
508
- output += (stdout ? '\n\n' : '') + `STDERR:\n${stderr}`;
509
- return output || 'Command executed successfully (no output)';
510
- }
511
- catch (err) {
512
- const error = err;
513
- if (error.killed && error.signal === 'SIGTERM') {
514
- throw new Error(`Command timed out after ${timeoutSeconds} seconds`);
515
- }
516
- let msg = `Command failed: ${command}`;
517
- if (error.stdout)
518
- msg += `\nSTDOUT:\n${error.stdout}`;
519
- if (error.stderr)
520
- msg += `\nSTDERR:\n${error.stderr}`;
521
- if (error.code !== undefined)
522
- msg += `\nExit code: ${error.code}`;
523
- throw new Error(msg);
524
- }
525
- },
526
- };
527
- // ─────────────────────────────────────────────────────────────────────────────
528
- // Registry
529
- // ─────────────────────────────────────────────────────────────────────────────
530
- /**
531
- * All available built-in tools, keyed by tool name.
532
- *
533
- * Listed tools are registered via crewx.registerTool() when their name appears
534
- * in crewx.yaml `tools.builtin` for an agent using an api/* provider.
535
- */
536
- exports.BUILTIN_TOOL_REGISTRY = {
537
- read_file: readFileTool,
538
- write_file: writeFileTool,
539
- replace: replaceTool,
540
- ls: lsTool,
541
- tree: treeTool,
542
- grep: grepTool,
543
- find: findTool,
544
- glob: globTool,
545
- run_shell_command: runShellCommandTool,
546
- };
547
- //# sourceMappingURL=builtin.js.map
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CrewxProjectConfigSchema = exports.AgentConfigSchema = exports.AgentInlineSchema = void 0;
4
- const zod_1 = require("zod");
5
- // ─── Agent Config ───────────────────────────────────────────────────────────
6
- exports.AgentInlineSchema = zod_1.z.object({
7
- model: zod_1.z.string().optional(),
8
- system_prompt: zod_1.z.string().optional(),
9
- prompt: zod_1.z.string().optional(),
10
- layout: zod_1.z.union([zod_1.z.string(), zod_1.z.object({ id: zod_1.z.string(), props: zod_1.z.record(zod_1.z.unknown()).optional() })]).optional(),
11
- }).catchall(zod_1.z.unknown());
12
- exports.AgentConfigSchema = zod_1.z.object({
13
- id: zod_1.z.string(),
14
- name: zod_1.z.string().optional(),
15
- role: zod_1.z.string().optional(),
16
- team: zod_1.z.string().optional(),
17
- provider: zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]),
18
- working_directory: zod_1.z.string().optional(),
19
- description: zod_1.z.string().optional(),
20
- tags: zod_1.z.array(zod_1.z.string()).optional(),
21
- inline: exports.AgentInlineSchema.optional(),
22
- }).catchall(zod_1.z.unknown());
23
- // ─── Project Config ─────────────────────────────────────────────────────────
24
- exports.CrewxProjectConfigSchema = zod_1.z.object({
25
- agents: zod_1.z.array(exports.AgentConfigSchema).optional(),
26
- hooks: zod_1.z.array(zod_1.z.unknown()).optional(),
27
- settings: zod_1.z.record(zod_1.z.unknown()).optional(),
28
- skills: zod_1.z.unknown().optional(),
29
- layouts: zod_1.z.record(zod_1.z.unknown()).optional(),
30
- documents: zod_1.z.record(zod_1.z.unknown()).optional(),
31
- }).catchall(zod_1.z.unknown());
32
- //# sourceMappingURL=index.js.map
@@ -1,6 +0,0 @@
1
- "use strict";
2
- /**
3
- * Task log types — shared types for task log entries across parsers and server code.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- //# sourceMappingURL=task-log.types.js.map
@@ -1,27 +0,0 @@
1
- "use strict";
2
- /**
3
- * Centralized CREWX_* environment variable defaults.
4
- *
5
- * Priority: process.env value > hardcoded fallback.
6
- * No filesystem checks (cwd-dependent paths break in worktrees).
7
- * Browser-safe: guards process.env / process.cwd() access.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.resolveCrewxCli = resolveCrewxCli;
11
- exports.resolveCrewxWorkspace = resolveCrewxWorkspace;
12
- const _env = typeof process !== 'undefined' ? process.env : {};
13
- /**
14
- * Resolve CREWX_CLI path.
15
- * Returns process.env.CREWX_CLI if set, otherwise 'npx crewx'.
16
- */
17
- function resolveCrewxCli() {
18
- return _env.CREWX_CLI || 'npx crewx';
19
- }
20
- /**
21
- * Resolve CREWX_WORKSPACE path.
22
- * Returns process.env.CREWX_WORKSPACE if set, otherwise current working directory.
23
- */
24
- function resolveCrewxWorkspace() {
25
- return _env.CREWX_WORKSPACE || (typeof process !== 'undefined' ? process.cwd() : '/');
26
- }
27
- //# sourceMappingURL=env-defaults.js.map
@@ -1,42 +0,0 @@
1
- "use strict";
2
- /**
3
- * Glob pattern matching utilities.
4
- * Shared by exec helper (security allow/deny) and agent ls filter.
5
- *
6
- * '*' — matches any characters within a single path segment (non-'/').
7
- * '**' — matches any characters including '/'.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.globToRegex = globToRegex;
11
- exports.matchesPattern = matchesPattern;
12
- /**
13
- * Converts a glob pattern to a RegExp.
14
- * Handles path-based matching (split by '/') consistent with minimatch behavior.
15
- */
16
- function globToRegex(pattern) {
17
- const escape = (s) => s.replace(/[.+^${}()|[\]\\]/g, '\\$&');
18
- const parts = pattern.split('/');
19
- const regexParts = parts.map(part => {
20
- if (part === '**') {
21
- return '.*';
22
- }
23
- return part
24
- .split('*')
25
- .map(escape)
26
- .join('[^/]*');
27
- });
28
- return new RegExp(`^${regexParts.join('\\/')}$`);
29
- }
30
- /**
31
- * Checks if a value matches a glob pattern.
32
- * Returns false on any regex construction error.
33
- */
34
- function matchesPattern(value, pattern) {
35
- try {
36
- return globToRegex(pattern).test(value);
37
- }
38
- catch {
39
- return false;
40
- }
41
- }
42
- //# sourceMappingURL=glob-match.js.map