@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.
- package/dist/__tests__/adapter/context-builder.test.d.ts +1 -0
- package/dist/__tests__/adapter/plugin-helper.test.d.ts +1 -0
- package/dist/__tests__/adapter/registration-integration.test.d.ts +1 -0
- package/dist/__tests__/adapter/scoped-store.test.d.ts +1 -0
- package/dist/__tests__/plugins/conversation.test.d.ts +1 -0
- package/dist/__tests__/testing/createMockContext.test.d.ts +1 -0
- package/dist/adapter/context-builder.d.ts +0 -9
- package/dist/adapter/index.d.ts +0 -1
- package/dist/adapter/plugin-helper.d.ts +0 -7
- package/dist/adapter/scoped-store.d.ts +0 -10
- package/dist/adapter/types.d.ts +0 -7
- package/dist/agent/resolver.d.ts +0 -13
- package/dist/boxing/box-storage.interface.d.ts +0 -4
- package/dist/boxing/box.service.d.ts +0 -4
- package/dist/boxing/box.types.d.ts +0 -4
- package/dist/boxing/context-builder.d.ts +0 -4
- package/dist/client/CrewxClient.d.ts +0 -32
- package/dist/client/index.d.ts +0 -1
- package/dist/client/index.js +1 -6
- package/dist/config/loader.browser.d.ts +0 -8
- package/dist/config/loader.d.ts +0 -12
- package/dist/conversation/__tests__/sqlite-provider.test.d.ts +1 -0
- package/dist/conversation/__tests__/to-task-reader.test.d.ts +1 -0
- package/dist/conversation/index.d.ts +0 -1
- package/dist/conversation/sqlite-provider.d.ts +0 -9
- package/dist/conversation/to-task-reader.d.ts +0 -11
- package/dist/conversation/to-template-messages.d.ts +0 -13
- package/dist/conversation/types.d.ts +0 -58
- package/dist/esm/client/index.js +1 -2
- package/dist/esm/hooks/index.js +7 -6
- package/dist/esm/index.js +79 -60
- package/dist/esm/plugins/index.js +52 -0
- package/dist/esm/testing/index.js +1 -0
- package/dist/esm/tools/node/index.js +36 -54
- package/dist/events/TypedEventEmitter.d.ts +0 -24
- package/dist/events/types.d.ts +0 -43
- package/dist/facade/Crewx.browser.d.ts +0 -40
- package/dist/facade/Crewx.d.ts +0 -163
- package/dist/hooks/define.d.ts +0 -1
- package/dist/hooks/dispatch.d.ts +0 -12
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.js +7 -24
- package/dist/hooks/observer.d.ts +0 -1
- package/dist/hooks/plugin.d.ts +0 -1
- package/dist/hooks/tool-normalize.d.ts +0 -26
- package/dist/hooks/types.d.ts +0 -1
- package/dist/hooks/yaml-plugin.d.ts +0 -1
- package/dist/index.browser.d.ts +0 -7
- package/dist/index.browser.js +2 -25
- package/dist/index.d.ts +0 -4
- package/dist/index.js +79 -151
- package/dist/layout/loader.d.ts +0 -20
- package/dist/layout/props-validator.d.ts +0 -6
- package/dist/layout/renderer.d.ts +0 -24
- package/dist/layout/types.d.ts +0 -42
- package/dist/parallel/agent-runtime.d.ts +0 -11
- package/dist/parallel/helpers.d.ts +0 -1
- package/dist/parallel/index.d.ts +0 -1
- package/dist/parallel/parallel-runner.d.ts +0 -8
- package/dist/parallel/types.d.ts +0 -24
- package/dist/parsers/agent-call.util.d.ts +0 -3
- package/dist/parsers/claude.parser.d.ts +0 -8
- package/dist/parsers/codex.parser.d.ts +0 -8
- package/dist/parsers/copilot.parser.d.ts +0 -9
- package/dist/parsers/gemini.parser.d.ts +0 -10
- package/dist/parsers/opencode.parser.d.ts +0 -10
- package/dist/parsers/router.d.ts +0 -5
- package/dist/paths.d.ts +1 -0
- package/dist/platform/BrowserFsAdapter.d.ts +0 -20
- package/dist/platform/IFsAdapter.d.ts +0 -23
- package/dist/platform/NodeFsAdapter.d.ts +0 -8
- package/dist/plugin/plugin-provider.d.ts +0 -22
- package/dist/plugin/types.d.ts +0 -31
- package/dist/plugin.d.ts +0 -27
- package/dist/plugins/conversation.d.ts +0 -2
- package/dist/plugins/file-logger.d.ts +0 -13
- package/dist/plugins/index.d.ts +0 -10
- package/dist/plugins/index.js +52 -19
- package/dist/plugins/sqlite-tracing.d.ts +0 -13
- package/dist/plugins/sqlite-tracing.spec.d.ts +1 -0
- package/dist/provider/bridge.browser.d.ts +0 -20
- package/dist/provider/bridge.d.ts +0 -47
- package/dist/provider/parse-usage.d.ts +0 -14
- package/dist/provider/register-api.d.ts +0 -7
- package/dist/provider/vercel-runtime.d.ts +0 -29
- package/dist/remote/index.d.ts +0 -6
- package/dist/remote/remote-agent-manager.d.ts +0 -31
- package/dist/remote/remote-provider.d.ts +0 -15
- package/dist/remote/remote-transport.d.ts +0 -17
- package/dist/remote/types.d.ts +0 -59
- package/dist/server/auth.d.ts +0 -16
- package/dist/server/handler.d.ts +0 -17
- package/dist/server/index.d.ts +0 -4
- package/dist/server/tool-adapter.d.ts +0 -16
- package/dist/template/engine.d.ts +0 -19
- package/dist/template/helpers/exec.browser.d.ts +0 -7
- package/dist/template/helpers/exec.d.ts +0 -45
- package/dist/template/helpers/fenced_code.d.ts +0 -16
- package/dist/template/helpers/format-conversation.d.ts +0 -22
- package/dist/template/helpers/include.d.ts +0 -15
- package/dist/template/helpers/p1p2.d.ts +0 -32
- package/dist/template/loader/DocumentLoader.d.ts +0 -30
- package/dist/template/types.d.ts +0 -30
- package/dist/testing/index.d.ts +0 -1
- package/dist/testing/index.js +1 -16
- package/dist/testing/mock-audit.d.ts +0 -1
- package/dist/testing/mock-context.d.ts +0 -1
- package/dist/testing/mock-logger.d.ts +0 -1
- package/dist/testing/mock-router.d.ts +0 -1
- package/dist/testing/mock-storage.d.ts +0 -1
- package/dist/testing/mock-store.d.ts +0 -1
- package/dist/tools/delegate.d.ts +0 -7
- package/dist/tools/index.d.ts +0 -4
- package/dist/tools/node/builtin.d.ts +0 -16
- package/dist/tools/node/index.d.ts +0 -20
- package/dist/tools/node/index.js +36 -59
- package/dist/types/index.d.ts +0 -20
- package/dist/types/task-log.types.d.ts +0 -4
- package/dist/utils/env-defaults.d.ts +0 -16
- package/dist/utils/glob-match.d.ts +0 -16
- package/dist/utils/id.d.ts +0 -15
- package/dist/utils/timestamp.d.ts +0 -1
- package/dist/utils/workspace.d.ts +0 -4
- package/package.json +24 -25
- package/dist/adapter/context-builder.js +0 -87
- package/dist/adapter/index.js +0 -21
- package/dist/adapter/plugin-helper.js +0 -45
- package/dist/adapter/scoped-store.js +0 -43
- package/dist/adapter/types.js +0 -23
- package/dist/agent/resolver.js +0 -46
- package/dist/boxing/box-storage.interface.js +0 -6
- package/dist/boxing/box.service.js +0 -73
- package/dist/boxing/box.types.js +0 -6
- package/dist/boxing/context-builder.js +0 -79
- package/dist/client/CrewxClient.js +0 -86
- package/dist/config/loader.browser.js +0 -59
- package/dist/config/loader.js +0 -95
- package/dist/conversation/index.js +0 -25
- package/dist/conversation/sqlite-provider.js +0 -178
- package/dist/conversation/to-task-reader.js +0 -28
- package/dist/conversation/to-template-messages.js +0 -34
- package/dist/conversation/types.js +0 -10
- package/dist/esm/agent/resolver.js +0 -41
- package/dist/esm/boxing/box-storage.interface.js +0 -5
- package/dist/esm/boxing/box.service.js +0 -69
- package/dist/esm/boxing/box.types.js +0 -5
- package/dist/esm/boxing/context-builder.js +0 -76
- package/dist/esm/client/CrewxClient.js +0 -82
- package/dist/esm/config/loader.browser.js +0 -54
- package/dist/esm/config/loader.js +0 -77
- package/dist/esm/events/TypedEventEmitter.js +0 -61
- package/dist/esm/events/types.js +0 -8
- package/dist/esm/facade/Crewx.browser.js +0 -310
- package/dist/esm/facade/Crewx.js +0 -941
- package/dist/esm/hooks/define.js +0 -10
- package/dist/esm/hooks/dispatch.js +0 -76
- package/dist/esm/hooks/observer.js +0 -56
- package/dist/esm/hooks/plugin.js +0 -12
- package/dist/esm/hooks/types.js +0 -9
- package/dist/esm/index.browser.js +0 -15
- package/dist/esm/layout/loader.js +0 -268
- package/dist/esm/layout/props-validator.js +0 -297
- package/dist/esm/layout/renderer.js +0 -180
- package/dist/esm/layout/types.js +0 -31
- package/dist/esm/parallel/agent-runtime.js +0 -21
- package/dist/esm/parallel/helpers.js +0 -214
- package/dist/esm/parallel/index.js +0 -5
- package/dist/esm/parallel/parallel-runner.js +0 -221
- package/dist/esm/parallel/types.js +0 -5
- package/dist/esm/parsers/agent-call.util.js +0 -15
- package/dist/esm/parsers/claude.parser.js +0 -64
- package/dist/esm/parsers/codex.parser.js +0 -97
- package/dist/esm/parsers/copilot.parser.js +0 -63
- package/dist/esm/parsers/gemini.parser.js +0 -43
- package/dist/esm/parsers/opencode.parser.js +0 -73
- package/dist/esm/parsers/router.js +0 -53
- package/dist/esm/platform/BrowserFsAdapter.js +0 -80
- package/dist/esm/platform/IFsAdapter.js +0 -2
- package/dist/esm/platform/NodeFsAdapter.js +0 -34
- package/dist/esm/plugin/plugin-provider.js +0 -202
- package/dist/esm/plugin/types.js +0 -8
- package/dist/esm/plugin.js +0 -25
- package/dist/esm/provider/bridge.browser.js +0 -43
- package/dist/esm/provider/bridge.js +0 -373
- package/dist/esm/provider/parse-usage.js +0 -80
- package/dist/esm/provider/register-api.js +0 -21
- package/dist/esm/provider/vercel-runtime.js +0 -310
- package/dist/esm/remote/index.js +0 -10
- package/dist/esm/remote/remote-agent-manager.js +0 -194
- package/dist/esm/remote/remote-provider.js +0 -98
- package/dist/esm/remote/remote-transport.js +0 -79
- package/dist/esm/remote/types.js +0 -8
- package/dist/esm/server/auth.js +0 -31
- package/dist/esm/server/handler.js +0 -72
- package/dist/esm/server/index.js +0 -5
- package/dist/esm/server/tool-adapter.js +0 -92
- package/dist/esm/template/engine.js +0 -100
- package/dist/esm/template/helpers/exec.browser.js +0 -31
- package/dist/esm/template/helpers/exec.js +0 -220
- package/dist/esm/template/helpers/fenced_code.js +0 -17
- package/dist/esm/template/helpers/include.js +0 -20
- package/dist/esm/template/helpers/p1p2.js +0 -83
- package/dist/esm/template/loader/DocumentLoader.js +0 -124
- package/dist/esm/template/types.js +0 -5
- package/dist/esm/tools/delegate.js +0 -57
- package/dist/esm/tools/index.js +0 -5
- package/dist/esm/tools/node/builtin.js +0 -541
- package/dist/esm/types/index.js +0 -27
- package/dist/esm/types/task-log.types.js +0 -5
- package/dist/esm/utils/env-defaults.js +0 -23
- package/dist/esm/utils/glob-match.js +0 -38
- package/dist/esm/utils/id.js +0 -46
- package/dist/esm/utils/workspace.js +0 -21
- package/dist/events/TypedEventEmitter.js +0 -65
- package/dist/events/types.js +0 -9
- package/dist/facade/Crewx.browser.js +0 -314
- package/dist/facade/Crewx.js +0 -1299
- package/dist/hooks/define.js +0 -13
- package/dist/hooks/dispatch.js +0 -147
- package/dist/hooks/observer.js +0 -60
- package/dist/hooks/plugin.js +0 -17
- package/dist/hooks/tool-normalize.js +0 -110
- package/dist/hooks/types.js +0 -12
- package/dist/hooks/yaml-plugin.js +0 -356
- package/dist/layout/loader.js +0 -305
- package/dist/layout/props-validator.js +0 -301
- package/dist/layout/renderer.js +0 -193
- package/dist/layout/types.js +0 -36
- package/dist/parallel/agent-runtime.js +0 -25
- package/dist/parallel/helpers.js +0 -219
- package/dist/parallel/index.js +0 -13
- package/dist/parallel/parallel-runner.js +0 -226
- package/dist/parallel/types.js +0 -6
- package/dist/parsers/agent-call.util.js +0 -19
- package/dist/parsers/api.parser.d.ts +0 -10
- package/dist/parsers/api.parser.js +0 -26
- package/dist/parsers/claude.parser.js +0 -67
- package/dist/parsers/codex.parser.js +0 -100
- package/dist/parsers/copilot.parser.js +0 -66
- package/dist/parsers/gemini.parser.js +0 -46
- package/dist/parsers/opencode.parser.js +0 -76
- package/dist/parsers/router.js +0 -56
- package/dist/platform/BrowserFsAdapter.js +0 -84
- package/dist/platform/IFsAdapter.js +0 -3
- package/dist/platform/NodeFsAdapter.js +0 -38
- package/dist/plugin/plugin-provider.js +0 -207
- package/dist/plugin/types.js +0 -9
- package/dist/plugin.js +0 -29
- package/dist/plugins/conversation.js +0 -59
- package/dist/plugins/file-logger.js +0 -87
- package/dist/plugins/sqlite-tracing.js +0 -112
- package/dist/provider/bridge.browser.js +0 -49
- package/dist/provider/bridge.js +0 -381
- package/dist/provider/mastra-runtime.d.ts +0 -45
- package/dist/provider/mastra-runtime.js +0 -208
- package/dist/provider/parse-usage.js +0 -83
- package/dist/provider/register-api.js +0 -24
- package/dist/provider/vercel-runtime.js +0 -347
- package/dist/remote/index.js +0 -32
- package/dist/remote/remote-agent-manager.js +0 -198
- package/dist/remote/remote-provider.js +0 -141
- package/dist/remote/remote-transport.js +0 -83
- package/dist/remote/types.js +0 -9
- package/dist/server/auth.js +0 -35
- package/dist/server/handler.js +0 -75
- package/dist/server/index.js +0 -9
- package/dist/server/tool-adapter.js +0 -95
- package/dist/template/engine.js +0 -137
- package/dist/template/helpers/exec.browser.js +0 -41
- package/dist/template/helpers/exec.js +0 -230
- package/dist/template/helpers/fenced_code.js +0 -20
- package/dist/template/helpers/format-conversation.js +0 -53
- package/dist/template/helpers/include.js +0 -23
- package/dist/template/helpers/p1p2.js +0 -90
- package/dist/template/loader/DocumentLoader.js +0 -128
- package/dist/template/types.js +0 -6
- package/dist/testing/mock-audit.js +0 -13
- package/dist/testing/mock-context.js +0 -68
- package/dist/testing/mock-logger.js +0 -27
- package/dist/testing/mock-router.js +0 -67
- package/dist/testing/mock-storage.js +0 -21
- package/dist/testing/mock-store.js +0 -8
- package/dist/tools/delegate.js +0 -60
- package/dist/tools/index.js +0 -9
- package/dist/tools/node/builtin.js +0 -547
- package/dist/types/index.js +0 -32
- package/dist/types/task-log.types.js +0 -6
- package/dist/utils/env-defaults.js +0 -27
- package/dist/utils/glob-match.js +0 -42
- package/dist/utils/id.js +0 -50
- package/dist/utils/timestamp.js +0 -13
- 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, '{{').replace(/\}\}/g, '}}');
|
|
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,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
|