@crewx/sdk 0.8.0-rc.79 → 0.8.0-rc.82

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 (292) 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 -2
  30. package/dist/esm/hooks/index.js +7 -6
  31. package/dist/esm/index.js +79 -60
  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 -54
  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/esm/agent/resolver.js +0 -41
  144. package/dist/esm/boxing/box-storage.interface.js +0 -5
  145. package/dist/esm/boxing/box.service.js +0 -69
  146. package/dist/esm/boxing/box.types.js +0 -5
  147. package/dist/esm/boxing/context-builder.js +0 -76
  148. package/dist/esm/client/CrewxClient.js +0 -82
  149. package/dist/esm/config/loader.browser.js +0 -54
  150. package/dist/esm/config/loader.js +0 -77
  151. package/dist/esm/events/TypedEventEmitter.js +0 -61
  152. package/dist/esm/events/types.js +0 -8
  153. package/dist/esm/facade/Crewx.browser.js +0 -310
  154. package/dist/esm/facade/Crewx.js +0 -941
  155. package/dist/esm/hooks/define.js +0 -10
  156. package/dist/esm/hooks/dispatch.js +0 -76
  157. package/dist/esm/hooks/observer.js +0 -56
  158. package/dist/esm/hooks/plugin.js +0 -12
  159. package/dist/esm/hooks/types.js +0 -9
  160. package/dist/esm/index.browser.js +0 -15
  161. package/dist/esm/layout/loader.js +0 -268
  162. package/dist/esm/layout/props-validator.js +0 -297
  163. package/dist/esm/layout/renderer.js +0 -180
  164. package/dist/esm/layout/types.js +0 -31
  165. package/dist/esm/parallel/agent-runtime.js +0 -21
  166. package/dist/esm/parallel/helpers.js +0 -214
  167. package/dist/esm/parallel/index.js +0 -5
  168. package/dist/esm/parallel/parallel-runner.js +0 -221
  169. package/dist/esm/parallel/types.js +0 -5
  170. package/dist/esm/parsers/agent-call.util.js +0 -15
  171. package/dist/esm/parsers/claude.parser.js +0 -64
  172. package/dist/esm/parsers/codex.parser.js +0 -97
  173. package/dist/esm/parsers/copilot.parser.js +0 -63
  174. package/dist/esm/parsers/gemini.parser.js +0 -43
  175. package/dist/esm/parsers/opencode.parser.js +0 -73
  176. package/dist/esm/parsers/router.js +0 -53
  177. package/dist/esm/platform/BrowserFsAdapter.js +0 -80
  178. package/dist/esm/platform/IFsAdapter.js +0 -2
  179. package/dist/esm/platform/NodeFsAdapter.js +0 -34
  180. package/dist/esm/plugin/plugin-provider.js +0 -202
  181. package/dist/esm/plugin/types.js +0 -8
  182. package/dist/esm/plugin.js +0 -25
  183. package/dist/esm/provider/bridge.browser.js +0 -43
  184. package/dist/esm/provider/bridge.js +0 -373
  185. package/dist/esm/provider/parse-usage.js +0 -80
  186. package/dist/esm/provider/register-api.js +0 -21
  187. package/dist/esm/provider/vercel-runtime.js +0 -310
  188. package/dist/esm/remote/index.js +0 -10
  189. package/dist/esm/remote/remote-agent-manager.js +0 -194
  190. package/dist/esm/remote/remote-provider.js +0 -98
  191. package/dist/esm/remote/remote-transport.js +0 -79
  192. package/dist/esm/remote/types.js +0 -8
  193. package/dist/esm/server/auth.js +0 -31
  194. package/dist/esm/server/handler.js +0 -72
  195. package/dist/esm/server/index.js +0 -5
  196. package/dist/esm/server/tool-adapter.js +0 -92
  197. package/dist/esm/template/engine.js +0 -100
  198. package/dist/esm/template/helpers/exec.browser.js +0 -31
  199. package/dist/esm/template/helpers/exec.js +0 -220
  200. package/dist/esm/template/helpers/fenced_code.js +0 -17
  201. package/dist/esm/template/helpers/include.js +0 -20
  202. package/dist/esm/template/helpers/p1p2.js +0 -83
  203. package/dist/esm/template/loader/DocumentLoader.js +0 -124
  204. package/dist/esm/template/types.js +0 -5
  205. package/dist/esm/tools/delegate.js +0 -57
  206. package/dist/esm/tools/index.js +0 -5
  207. package/dist/esm/tools/node/builtin.js +0 -541
  208. package/dist/esm/types/index.js +0 -27
  209. package/dist/esm/types/task-log.types.js +0 -5
  210. package/dist/esm/utils/env-defaults.js +0 -23
  211. package/dist/esm/utils/glob-match.js +0 -38
  212. package/dist/esm/utils/id.js +0 -46
  213. package/dist/esm/utils/workspace.js +0 -21
  214. package/dist/events/TypedEventEmitter.js +0 -65
  215. package/dist/events/types.js +0 -9
  216. package/dist/facade/Crewx.browser.js +0 -314
  217. package/dist/facade/Crewx.js +0 -1299
  218. package/dist/hooks/define.js +0 -13
  219. package/dist/hooks/dispatch.js +0 -147
  220. package/dist/hooks/observer.js +0 -60
  221. package/dist/hooks/plugin.js +0 -17
  222. package/dist/hooks/tool-normalize.js +0 -110
  223. package/dist/hooks/types.js +0 -12
  224. package/dist/hooks/yaml-plugin.js +0 -356
  225. package/dist/layout/loader.js +0 -305
  226. package/dist/layout/props-validator.js +0 -301
  227. package/dist/layout/renderer.js +0 -193
  228. package/dist/layout/types.js +0 -36
  229. package/dist/parallel/agent-runtime.js +0 -25
  230. package/dist/parallel/helpers.js +0 -219
  231. package/dist/parallel/index.js +0 -13
  232. package/dist/parallel/parallel-runner.js +0 -226
  233. package/dist/parallel/types.js +0 -6
  234. package/dist/parsers/agent-call.util.js +0 -19
  235. package/dist/parsers/api.parser.d.ts +0 -10
  236. package/dist/parsers/api.parser.js +0 -26
  237. package/dist/parsers/claude.parser.js +0 -67
  238. package/dist/parsers/codex.parser.js +0 -100
  239. package/dist/parsers/copilot.parser.js +0 -66
  240. package/dist/parsers/gemini.parser.js +0 -46
  241. package/dist/parsers/opencode.parser.js +0 -76
  242. package/dist/parsers/router.js +0 -56
  243. package/dist/platform/BrowserFsAdapter.js +0 -84
  244. package/dist/platform/IFsAdapter.js +0 -3
  245. package/dist/platform/NodeFsAdapter.js +0 -38
  246. package/dist/plugin/plugin-provider.js +0 -207
  247. package/dist/plugin/types.js +0 -9
  248. package/dist/plugin.js +0 -29
  249. package/dist/plugins/conversation.js +0 -59
  250. package/dist/plugins/file-logger.js +0 -87
  251. package/dist/plugins/sqlite-tracing.js +0 -112
  252. package/dist/provider/bridge.browser.js +0 -49
  253. package/dist/provider/bridge.js +0 -381
  254. package/dist/provider/mastra-runtime.d.ts +0 -45
  255. package/dist/provider/mastra-runtime.js +0 -208
  256. package/dist/provider/parse-usage.js +0 -83
  257. package/dist/provider/register-api.js +0 -24
  258. package/dist/provider/vercel-runtime.js +0 -347
  259. package/dist/remote/index.js +0 -32
  260. package/dist/remote/remote-agent-manager.js +0 -198
  261. package/dist/remote/remote-provider.js +0 -141
  262. package/dist/remote/remote-transport.js +0 -83
  263. package/dist/remote/types.js +0 -9
  264. package/dist/server/auth.js +0 -35
  265. package/dist/server/handler.js +0 -75
  266. package/dist/server/index.js +0 -9
  267. package/dist/server/tool-adapter.js +0 -95
  268. package/dist/template/engine.js +0 -137
  269. package/dist/template/helpers/exec.browser.js +0 -41
  270. package/dist/template/helpers/exec.js +0 -230
  271. package/dist/template/helpers/fenced_code.js +0 -20
  272. package/dist/template/helpers/format-conversation.js +0 -53
  273. package/dist/template/helpers/include.js +0 -23
  274. package/dist/template/helpers/p1p2.js +0 -90
  275. package/dist/template/loader/DocumentLoader.js +0 -128
  276. package/dist/template/types.js +0 -6
  277. package/dist/testing/mock-audit.js +0 -13
  278. package/dist/testing/mock-context.js +0 -68
  279. package/dist/testing/mock-logger.js +0 -27
  280. package/dist/testing/mock-router.js +0 -67
  281. package/dist/testing/mock-storage.js +0 -21
  282. package/dist/testing/mock-store.js +0 -8
  283. package/dist/tools/delegate.js +0 -60
  284. package/dist/tools/index.js +0 -9
  285. package/dist/tools/node/builtin.js +0 -547
  286. package/dist/types/index.js +0 -32
  287. package/dist/types/task-log.types.js +0 -6
  288. package/dist/utils/env-defaults.js +0 -27
  289. package/dist/utils/glob-match.js +0 -42
  290. package/dist/utils/id.js +0 -50
  291. package/dist/utils/timestamp.js +0 -13
  292. package/dist/utils/workspace.js +0 -58
@@ -1,83 +0,0 @@
1
- /**
2
- * P1/P2 Handlebars helper implementations.
3
- *
4
- * P1: truncate, length, escapeHandlebars
5
- * P2: formatFileSize, formatTimestamp
6
- *
7
- * Ported from packages/cli-bak/src/utils/template-processor.ts.
8
- * formatConversation is intentionally excluded (user confirmed).
9
- */
10
- // ── P1 Helpers ────────────────────────────────────────────────────────────────
11
- /**
12
- * Truncate text to maxLength, appending remaining char count if truncated.
13
- * {{truncate text 500}} or {{{truncate text 500}}}
14
- */
15
- export function truncateHelper(text, maxLength) {
16
- if (!text)
17
- return '';
18
- if (text.length <= maxLength)
19
- return text;
20
- const remaining = text.length - maxLength;
21
- return `${text.substring(0, maxLength)} (...+${remaining} chars)`;
22
- }
23
- /**
24
- * Return the length of an array or string.
25
- * {{length array}} / {{length string}}
26
- */
27
- export function lengthHelper(value) {
28
- if (Array.isArray(value))
29
- return value.length;
30
- if (typeof value === 'string')
31
- return value.length;
32
- return 0;
33
- }
34
- /**
35
- * Escape Handlebars delimiters in user-provided content.
36
- * Prevents secondary template compilation of user content.
37
- * {{{escapeHandlebars text}}}
38
- */
39
- export function escapeHandlebarsHelper(text) {
40
- if (typeof text !== 'string')
41
- return '';
42
- return text.replace(/\{\{/g, '&#123;&#123;').replace(/\}\}/g, '&#125;&#125;');
43
- }
44
- // ── P2 Helpers ────────────────────────────────────────────────────────────────
45
- const FILE_SIZE_UNITS = ['B', 'KB', 'MB', 'GB'];
46
- /**
47
- * Format a byte count as a human-readable file size string.
48
- * {{formatFileSize bytes}}
49
- */
50
- export function formatFileSizeHelper(bytes) {
51
- if (bytes === 0)
52
- return '0 B';
53
- const i = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), FILE_SIZE_UNITS.length - 1);
54
- const value = Math.round((bytes / Math.pow(1024, i)) * 100) / 100;
55
- return `${value} ${FILE_SIZE_UNITS[i]}`;
56
- }
57
- /**
58
- * Format a Date or ISO timestamp string into a locale-aware display string.
59
- * Returns empty string for invalid or falsy input.
60
- * {{formatTimestamp timestamp}}
61
- */
62
- export function formatTimestampHelper(timestamp) {
63
- if (!timestamp)
64
- return '';
65
- try {
66
- const date = timestamp instanceof Date ? timestamp : new Date(timestamp);
67
- if (isNaN(date.getTime()))
68
- return '';
69
- return date.toLocaleString('ko-KR', {
70
- year: 'numeric',
71
- month: '2-digit',
72
- day: '2-digit',
73
- hour: '2-digit',
74
- minute: '2-digit',
75
- second: '2-digit',
76
- hour12: false,
77
- });
78
- }
79
- catch {
80
- return '';
81
- }
82
- }
83
- //# sourceMappingURL=p1p2.js.map
@@ -1,124 +0,0 @@
1
- /**
2
- * DocumentLoader — loads documents from crewx.yaml `documents:` section.
3
- *
4
- * Supports:
5
- * - Inline string: `notice: "Some text"`
6
- * - Inline object: `notice: { content: "Some text" }`
7
- * - File path (relative): `guide: { path: "docs/guide.md" }`
8
- * - File path (absolute): `guide: { path: "/abs/docs/guide.md" }`
9
- *
10
- * File I/O is delegated to IFsAdapter for testability and future WEB compat.
11
- */
12
- import { defaultFsAdapter } from '../../platform/NodeFsAdapter';
13
- // ── DocumentLoader ──────────────────────────────────────────────────────────
14
- export class DocumentLoader {
15
- docs = new Map();
16
- fs;
17
- constructor(fsAdapter) {
18
- this.fs = fsAdapter ?? defaultFsAdapter;
19
- }
20
- /**
21
- * Load all documents from the `documents:` section of crewx.yaml.
22
- *
23
- * @param sources - Record of document name → source (string, {path}, or {content})
24
- * @param projectRoot - Base directory for resolving relative file paths
25
- */
26
- async load(sources, projectRoot) {
27
- if (!sources)
28
- return;
29
- for (const [name, rawSource] of Object.entries(sources)) {
30
- const source = rawSource;
31
- if (typeof source === 'string') {
32
- // Case 1: inline string
33
- this.docs.set(name, { content: source });
34
- }
35
- else if (source && typeof source === 'object') {
36
- const src = source;
37
- if ('content' in src && typeof src['content'] === 'string') {
38
- // Case 2: inline object with content field
39
- this.docs.set(name, { content: src['content'] });
40
- }
41
- else if ('path' in src && typeof src['path'] === 'string') {
42
- // Case 3: file path
43
- await this.loadFromFile(name, src['path'], projectRoot);
44
- }
45
- else {
46
- console.warn(`[DocumentLoader] Skipping '${name}': unsupported format`);
47
- }
48
- }
49
- else {
50
- console.warn(`[DocumentLoader] Skipping '${name}': unsupported format`);
51
- }
52
- }
53
- }
54
- /** Get document text content by name. Returns undefined if not loaded. */
55
- async getContent(name) {
56
- return this.docs.get(name)?.content;
57
- }
58
- /**
59
- * Get a simple TOC (table of contents) for a markdown document.
60
- * Extracts headings (lines starting with `#`) and returns them as an indented list.
61
- * Returns undefined if there are no headings.
62
- */
63
- async getToc(name) {
64
- const doc = this.docs.get(name);
65
- if (!doc)
66
- return undefined;
67
- const headings = [];
68
- for (const line of doc.content.split('\n')) {
69
- const match = /^(#{1,6})\s+(.+)$/.exec(line.trim());
70
- if (match) {
71
- headings.push({ depth: match[1].length, text: match[2].trim() });
72
- }
73
- }
74
- if (headings.length === 0)
75
- return undefined;
76
- return headings
77
- .map(({ depth, text }) => `${' '.repeat(depth - 1)}- ${text}`)
78
- .join('\n');
79
- }
80
- /** Get the resolved absolute file path for a file-based document. */
81
- getPath(name) {
82
- return this.docs.get(name)?.path;
83
- }
84
- /** Get all loaded document names. */
85
- getNames() {
86
- return Array.from(this.docs.keys());
87
- }
88
- /**
89
- * Build a documents context object suitable for Handlebars template rendering.
90
- * Returns `{ docName: { content, toc, path? }, ... }`.
91
- */
92
- async buildContext() {
93
- const ctx = {};
94
- for (const name of this.docs.keys()) {
95
- const content = await this.getContent(name) ?? '';
96
- const toc = await this.getToc(name);
97
- const path = this.getPath(name);
98
- ctx[name] = { content, toc, ...(path ? { path } : {}) };
99
- }
100
- return ctx;
101
- }
102
- // ── Private ───────────────────────────────────────────────────────────────
103
- async loadFromFile(name, filePath, projectRoot) {
104
- try {
105
- const resolvedPath = this.resolve(filePath, projectRoot);
106
- const content = await this.fs.readFile(resolvedPath);
107
- this.docs.set(name, { content, path: resolvedPath });
108
- }
109
- catch (err) {
110
- const msg = err instanceof Error ? err.message : String(err);
111
- console.warn(`[DocumentLoader] Failed to load '${name}' from '${filePath}': ${msg}`);
112
- }
113
- }
114
- resolve(filePath, projectRoot) {
115
- if (this.fs.isAbsolute(filePath)) {
116
- return filePath;
117
- }
118
- if (projectRoot) {
119
- return this.fs.resolvePath(projectRoot, filePath);
120
- }
121
- return this.fs.resolvePath(filePath);
122
- }
123
- }
124
- //# sourceMappingURL=DocumentLoader.js.map
@@ -1,5 +0,0 @@
1
- /**
2
- * Type definitions for the CrewX template engine.
3
- */
4
- export {};
5
- //# sourceMappingURL=types.js.map
@@ -1,57 +0,0 @@
1
- /**
2
- * delegate_to_agent — 다른 에이전트에게 작업을 위임하는 빌트인 tool.
3
- *
4
- * PM → Dev처럼 에이전트 간 자동 위임을 가능하게 한다.
5
- * crewx 인스턴스를 클로저로 캡처하여 내부에서 query/execute 호출.
6
- */
7
- const MAX_DELEGATION_DEPTH = 3;
8
- let _delegationDepth = 0;
9
- export function createDelegateTool(crewx) {
10
- const agentIds = Array.from(crewx.agents.keys());
11
- return {
12
- name: 'delegate_to_agent',
13
- description: `Delegate a task to another agent. Available agents: ${agentIds.join(', ')}`,
14
- parameters: {
15
- type: 'object',
16
- properties: {
17
- agent: {
18
- type: 'string',
19
- description: `Agent ID to delegate to. One of: ${agentIds.join(', ')}`,
20
- },
21
- message: {
22
- type: 'string',
23
- description: 'Task description for the target agent',
24
- },
25
- mode: {
26
- type: 'string',
27
- description: 'Execution mode: "query" for questions, "execute" for actions. Default: query',
28
- },
29
- },
30
- required: ['agent', 'message'],
31
- },
32
- execute: async (args) => {
33
- if (_delegationDepth >= MAX_DELEGATION_DEPTH) {
34
- return `Error: Maximum delegation depth (${MAX_DELEGATION_DEPTH}) reached. Cannot delegate further.`;
35
- }
36
- const targetAgent = args.agent;
37
- const taskMessage = args.message;
38
- const mode = args.mode ?? 'query';
39
- if (!agentIds.includes(targetAgent)) {
40
- return `Error: Unknown agent "${targetAgent}". Available: ${agentIds.join(', ')}`;
41
- }
42
- _delegationDepth++;
43
- try {
44
- if (mode === 'execute') {
45
- const result = await crewx.execute(targetAgent, taskMessage);
46
- return result.ok ? result.data : `Error: ${result.error?.message ?? 'Unknown error'}`;
47
- }
48
- const result = await crewx.query(targetAgent, taskMessage);
49
- return result.ok ? result.data : `Error: ${result.error?.message ?? 'Unknown error'}`;
50
- }
51
- finally {
52
- _delegationDepth--;
53
- }
54
- },
55
- };
56
- }
57
- //# sourceMappingURL=delegate.js.map
@@ -1,5 +0,0 @@
1
- /**
2
- * @crewx/sdk/tools — 빌트인 tool exports.
3
- */
4
- export { createDelegateTool } from './delegate';
5
- //# sourceMappingURL=index.js.map