@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.
- 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 -0
- package/dist/esm/hooks/index.js +7 -0
- package/dist/esm/index.js +79 -0
- package/dist/esm/plugins/index.js +52 -0
- package/dist/esm/testing/index.js +1 -0
- package/dist/esm/tools/node/index.js +36 -0
- 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/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/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/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
package/dist/types/index.d.ts
CHANGED
|
@@ -719,9 +719,7 @@ export type CrewxProjectConfig = z.infer<typeof CrewxProjectConfigSchema>;
|
|
|
719
719
|
export interface CrewxOptions {
|
|
720
720
|
workspaceRoot?: string;
|
|
721
721
|
platform?: Platform;
|
|
722
|
-
/** Exec policy for the template engine's {{exec}} helper. */
|
|
723
722
|
execPolicy?: import('../template/types').ExecPolicy;
|
|
724
|
-
/** API provider configuration (api/* namespace). */
|
|
725
723
|
api?: {
|
|
726
724
|
apiKeys?: Record<string, string>;
|
|
727
725
|
defaults?: {
|
|
@@ -729,14 +727,6 @@ export interface CrewxOptions {
|
|
|
729
727
|
temperature?: number;
|
|
730
728
|
};
|
|
731
729
|
};
|
|
732
|
-
/**
|
|
733
|
-
* Bootstrap factory for file:// remote agents. When the caller invokes an
|
|
734
|
-
* agent whose provider is `remote/*` with `location: file://...`, the SDK
|
|
735
|
-
* uses this factory to construct the target Crewx instance (so the target
|
|
736
|
-
* inherits the same plugin/environment setup as the caller). Consumers pass
|
|
737
|
-
* their own bootstrap wrapper (e.g. createCliCrewx, createServerCrewx).
|
|
738
|
-
* If omitted, falls back to plain `Crewx.loadYaml(path)` without plugins.
|
|
739
|
-
*/
|
|
740
730
|
remoteFactory?: (configPath: string) => Promise<import('../facade/Crewx').Crewx>;
|
|
741
731
|
}
|
|
742
732
|
export interface QueryOptions {
|
|
@@ -744,25 +734,19 @@ export interface QueryOptions {
|
|
|
744
734
|
provider?: string;
|
|
745
735
|
context?: string;
|
|
746
736
|
metadata?: Record<string, unknown>;
|
|
747
|
-
/** Conversation thread ID (passed through to task:start event) */
|
|
748
737
|
threadId?: string;
|
|
749
|
-
/** Platform origin. Propagated to task:start event. */
|
|
750
738
|
platform?: Platform;
|
|
751
|
-
/** Caller-provided conversation history (WI-CONV-002). Takes priority over auto-fetch. */
|
|
752
739
|
messages?: import('../conversation/types').TemplateMessage[];
|
|
753
740
|
}
|
|
754
741
|
export interface QueryResult {
|
|
755
742
|
ok: boolean;
|
|
756
743
|
data: string;
|
|
757
|
-
/** 'complete' when the agent finished, 'requires_action' when a client tool needs execution. */
|
|
758
744
|
status?: 'complete' | 'requires_action';
|
|
759
|
-
/** Pending client tool call — present when status is 'requires_action'. */
|
|
760
745
|
toolCall?: {
|
|
761
746
|
toolCallId: string;
|
|
762
747
|
toolName: string;
|
|
763
748
|
args: Record<string, unknown>;
|
|
764
749
|
};
|
|
765
|
-
/** Thread ID for continuing the conversation — present when status is 'requires_action'. */
|
|
766
750
|
threadId?: string;
|
|
767
751
|
error?: {
|
|
768
752
|
code: string;
|
|
@@ -780,11 +764,8 @@ export interface ExecuteOptions {
|
|
|
780
764
|
provider?: string;
|
|
781
765
|
context?: string;
|
|
782
766
|
metadata?: Record<string, unknown>;
|
|
783
|
-
/** Conversation thread ID (passed through to task:start event) */
|
|
784
767
|
threadId?: string;
|
|
785
|
-
/** Platform origin. Propagated to task:start event. */
|
|
786
768
|
platform?: Platform;
|
|
787
|
-
/** Caller-provided conversation history (WI-CONV-002). Takes priority over auto-fetch. */
|
|
788
769
|
messages?: import('../conversation/types').TemplateMessage[];
|
|
789
770
|
}
|
|
790
771
|
export interface ExecuteResult {
|
|
@@ -801,4 +782,3 @@ export interface ExecuteResult {
|
|
|
801
782
|
durationMs: number;
|
|
802
783
|
};
|
|
803
784
|
}
|
|
804
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Task log types — shared types for task log entries across parsers and server code.
|
|
3
|
-
*/
|
|
4
1
|
export type TaskLogEntryType = 'text' | 'tool_use' | 'tool_result' | 'error' | 'info' | 'agent_call';
|
|
5
2
|
export interface TaskLogEntry {
|
|
6
3
|
timestamp: string;
|
|
@@ -15,4 +12,3 @@ export interface TaskLogEntry {
|
|
|
15
12
|
targetTaskId?: string;
|
|
16
13
|
errorMessage?: string;
|
|
17
14
|
}
|
|
18
|
-
//# sourceMappingURL=task-log.types.d.ts.map
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Centralized CREWX_* environment variable defaults.
|
|
3
|
-
*
|
|
4
|
-
* Priority: process.env value > hardcoded fallback.
|
|
5
|
-
* No filesystem checks (cwd-dependent paths break in worktrees).
|
|
6
|
-
* Browser-safe: guards process.env / process.cwd() access.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Resolve CREWX_CLI path.
|
|
10
|
-
* Returns process.env.CREWX_CLI if set, otherwise 'npx crewx'.
|
|
11
|
-
*/
|
|
12
1
|
export declare function resolveCrewxCli(): string;
|
|
13
|
-
/**
|
|
14
|
-
* Resolve CREWX_WORKSPACE path.
|
|
15
|
-
* Returns process.env.CREWX_WORKSPACE if set, otherwise current working directory.
|
|
16
|
-
*/
|
|
17
2
|
export declare function resolveCrewxWorkspace(): string;
|
|
18
|
-
//# sourceMappingURL=env-defaults.d.ts.map
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Glob pattern matching utilities.
|
|
3
|
-
* Shared by exec helper (security allow/deny) and agent ls filter.
|
|
4
|
-
*
|
|
5
|
-
* '*' — matches any characters within a single path segment (non-'/').
|
|
6
|
-
* '**' — matches any characters including '/'.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Converts a glob pattern to a RegExp.
|
|
10
|
-
* Handles path-based matching (split by '/') consistent with minimatch behavior.
|
|
11
|
-
*/
|
|
12
1
|
export declare function globToRegex(pattern: string): RegExp;
|
|
13
|
-
/**
|
|
14
|
-
* Checks if a value matches a glob pattern.
|
|
15
|
-
* Returns false on any regex construction error.
|
|
16
|
-
*/
|
|
17
2
|
export declare function matchesPattern(value: string, pattern: string): boolean;
|
|
18
|
-
//# sourceMappingURL=glob-match.d.ts.map
|
package/dist/utils/id.d.ts
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ID generation utilities.
|
|
3
|
-
* Backward-compatible with packages that import generateId from @crewx/sdk.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Valid entity prefixes for generated IDs.
|
|
7
|
-
*/
|
|
8
1
|
export type EntityPrefix = 'tsk' | 'thd' | 'msg' | 'box' | 'prj' | 'mem' | 'spn' | 'cron' | 'wbs' | 'job' | 'tcl' | 'req' | 'ws' | 'wfr';
|
|
9
2
|
export type PrefixedId<P extends EntityPrefix> = `${P}_${string}`;
|
|
10
|
-
/**
|
|
11
|
-
* Generate a random prefixed ID.
|
|
12
|
-
* @example generateId('tsk') // → "tsk_V1StGXR8"
|
|
13
|
-
*/
|
|
14
3
|
export declare function generateId<P extends EntityPrefix>(prefix: P): PrefixedId<P>;
|
|
15
|
-
/**
|
|
16
|
-
* Generate a deterministic fingerprint ID from a string input.
|
|
17
|
-
*/
|
|
18
4
|
export declare function generateFingerprint<P extends EntityPrefix>(prefix: P, input: string): PrefixedId<P>;
|
|
19
|
-
//# sourceMappingURL=id.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewx/sdk",
|
|
3
|
-
"version": "0.8.0-rc.
|
|
3
|
+
"version": "0.8.0-rc.83",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.19.0"
|
|
@@ -12,39 +12,40 @@
|
|
|
12
12
|
"types": "dist/index.d.ts",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
15
16
|
"import": "./dist/index.js",
|
|
16
|
-
"require": "./dist/index.js"
|
|
17
|
-
"types": "./dist/index.d.ts"
|
|
17
|
+
"require": "./dist/index.js"
|
|
18
18
|
},
|
|
19
19
|
"./browser": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
20
|
+
"types": "./dist/index.browser.d.ts",
|
|
21
|
+
"import": "./dist/index.browser.js"
|
|
22
22
|
},
|
|
23
23
|
"./client": {
|
|
24
|
+
"types": "./dist/client/index.d.ts",
|
|
24
25
|
"import": "./dist/client/index.js",
|
|
25
|
-
"require": "./dist/client/index.js"
|
|
26
|
-
"types": "./dist/client/index.d.ts"
|
|
26
|
+
"require": "./dist/client/index.js"
|
|
27
27
|
},
|
|
28
28
|
"./tools/node": {
|
|
29
|
+
"types": "./dist/tools/node/index.d.ts",
|
|
29
30
|
"import": "./dist/tools/node/index.js",
|
|
30
|
-
"require": "./dist/tools/node/index.js"
|
|
31
|
-
"types": "./dist/tools/node/index.d.ts"
|
|
31
|
+
"require": "./dist/tools/node/index.js"
|
|
32
32
|
},
|
|
33
33
|
"./hooks": {
|
|
34
|
+
"types": "./dist/hooks/index.d.ts",
|
|
34
35
|
"import": "./dist/hooks/index.js",
|
|
35
|
-
"require": "./dist/hooks/index.js"
|
|
36
|
-
"types": "./dist/hooks/index.d.ts"
|
|
36
|
+
"require": "./dist/hooks/index.js"
|
|
37
37
|
},
|
|
38
38
|
"./testing": {
|
|
39
|
+
"types": "./dist/testing/index.d.ts",
|
|
39
40
|
"import": "./dist/testing/index.js",
|
|
40
|
-
"require": "./dist/testing/index.js"
|
|
41
|
-
"types": "./dist/testing/index.d.ts"
|
|
41
|
+
"require": "./dist/testing/index.js"
|
|
42
42
|
},
|
|
43
43
|
"./plugins": {
|
|
44
|
+
"types": "./dist/plugins/index.d.ts",
|
|
44
45
|
"import": "./dist/plugins/index.js",
|
|
45
|
-
"require": "./dist/plugins/index.js"
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
"require": "./dist/plugins/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./package.json": "./package.json"
|
|
48
49
|
},
|
|
49
50
|
"browser": {
|
|
50
51
|
"./dist/template/helpers/exec.js": "./dist/template/helpers/exec.browser.js",
|
|
@@ -58,12 +59,7 @@
|
|
|
58
59
|
"dist",
|
|
59
60
|
"templates",
|
|
60
61
|
"src/schemas/**/*.json",
|
|
61
|
-
"README.md"
|
|
62
|
-
"!**/__tests__",
|
|
63
|
-
"!**/*.test.*",
|
|
64
|
-
"!**/*.spec.*",
|
|
65
|
-
"!**/*.js.map",
|
|
66
|
-
"!**/*.d.ts.map"
|
|
62
|
+
"README.md"
|
|
67
63
|
],
|
|
68
64
|
"dependencies": {
|
|
69
65
|
"@modelcontextprotocol/sdk": "^1.27.0",
|
|
@@ -86,13 +82,16 @@
|
|
|
86
82
|
"@types/js-yaml": "^4.0.9",
|
|
87
83
|
"@types/node": "^22.0.0",
|
|
88
84
|
"better-sqlite3": "^12.8.0",
|
|
85
|
+
"tsup": "^8.5.1",
|
|
89
86
|
"typescript": "^5.4.0",
|
|
90
87
|
"vitest": "^3.1.1"
|
|
91
88
|
},
|
|
92
89
|
"scripts": {
|
|
93
|
-
"build": "
|
|
94
|
-
"build:esm": "
|
|
95
|
-
"build:
|
|
90
|
+
"build:cjs": "npx tsup --config tsup.cjs.js",
|
|
91
|
+
"build:esm": "npx tsup --config tsup.esm.js",
|
|
92
|
+
"build:browser": "npx tsup --config tsup.browser.js",
|
|
93
|
+
"build:dts": "tsc -p tsconfig.dts.json",
|
|
94
|
+
"build": "pnpm run build:cjs && pnpm run build:esm && pnpm run build:browser && pnpm run build:dts",
|
|
96
95
|
"test": "vitest run --config ./vitest.config.ts",
|
|
97
96
|
"test:watch": "vitest --config ./vitest.config.ts",
|
|
98
97
|
"lint": "echo 'SDK lint pending' && exit 0"
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* createAdapterContext — builds an AdapterContext for an adapter instance.
|
|
4
|
-
*
|
|
5
|
-
* M1: respondSync uses AsyncLocalStorage to bind the current HTTP response.
|
|
6
|
-
* When called inside a registerRoute handler (sync window), respondSync writes
|
|
7
|
-
* to the HTTP res. When called outside the sync window, it performs graceful
|
|
8
|
-
* degradation: logs a warning instead of throwing (PoC correction #3).
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.getSyncWindowStore = getSyncWindowStore;
|
|
12
|
-
exports.runInSyncWindow = runInSyncWindow;
|
|
13
|
-
exports.createAdapterContext = createAdapterContext;
|
|
14
|
-
const async_hooks_1 = require("async_hooks");
|
|
15
|
-
const syncWindowStore = new async_hooks_1.AsyncLocalStorage();
|
|
16
|
-
function getSyncWindowStore() {
|
|
17
|
-
return syncWindowStore;
|
|
18
|
-
}
|
|
19
|
-
function runInSyncWindow(window, fn) {
|
|
20
|
-
return syncWindowStore.run(window, fn);
|
|
21
|
-
}
|
|
22
|
-
function createAdapterContext(opts) {
|
|
23
|
-
const log = opts.log ?? opts.logger ?? {
|
|
24
|
-
debug: () => { },
|
|
25
|
-
info: () => { },
|
|
26
|
-
warn: () => { },
|
|
27
|
-
error: () => { },
|
|
28
|
-
};
|
|
29
|
-
const agentRunner = opts.agentRunner ?? {
|
|
30
|
-
run: async () => ({ output: '' }),
|
|
31
|
-
};
|
|
32
|
-
const db = opts.db ?? {
|
|
33
|
-
get: async () => undefined,
|
|
34
|
-
set: async () => { },
|
|
35
|
-
delete: async () => false,
|
|
36
|
-
list: async () => [],
|
|
37
|
-
};
|
|
38
|
-
const storage = opts.storage ?? {
|
|
39
|
-
put: async () => '',
|
|
40
|
-
get: async () => undefined,
|
|
41
|
-
delete: async () => false,
|
|
42
|
-
};
|
|
43
|
-
const audit = opts.audit ?? {
|
|
44
|
-
log: async () => { },
|
|
45
|
-
};
|
|
46
|
-
const inbound = opts.onInbound ?? (async () => ({ accepted: true }));
|
|
47
|
-
const emitEventFn = opts.onEmitEvent ?? (async () => ({ accepted: true }));
|
|
48
|
-
const updateMessage = opts.onUpdateMessage ?? (async () => { });
|
|
49
|
-
const resolveUser = opts.onResolveUser ?? (async (userId) => ({
|
|
50
|
-
userId,
|
|
51
|
-
displayName: userId,
|
|
52
|
-
}));
|
|
53
|
-
const respondSync = async (payload) => {
|
|
54
|
-
const window = syncWindowStore.getStore();
|
|
55
|
-
if (!window) {
|
|
56
|
-
log.warn('respondSync called outside sync window — graceful degradation (no-op)', {
|
|
57
|
-
textPreview: typeof payload === 'object' && 'text' in payload ? payload.text.slice(0, 80) : undefined,
|
|
58
|
-
});
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const text = 'text' in payload ? payload.text : '';
|
|
62
|
-
window.res.status(200).json({ text });
|
|
63
|
-
};
|
|
64
|
-
const httpRouter = opts.httpRouter ?? {
|
|
65
|
-
registerRoute: () => {
|
|
66
|
-
log.warn('httpRouter not configured — registerRoute is a no-op');
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
return {
|
|
70
|
-
instanceId: opts.instanceId,
|
|
71
|
-
config: opts.config,
|
|
72
|
-
capabilities: opts.capabilities,
|
|
73
|
-
log,
|
|
74
|
-
agentRunner,
|
|
75
|
-
db,
|
|
76
|
-
storage,
|
|
77
|
-
audit,
|
|
78
|
-
abortSignal: opts.abortSignal ?? new AbortController().signal,
|
|
79
|
-
httpRouter,
|
|
80
|
-
inbound,
|
|
81
|
-
emitEvent: emitEventFn,
|
|
82
|
-
updateMessage,
|
|
83
|
-
resolveUser,
|
|
84
|
-
respondSync,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=context-builder.js.map
|
package/dist/adapter/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
18
|
-
__exportStar(require("./plugin-helper"), exports);
|
|
19
|
-
__exportStar(require("./scoped-store"), exports);
|
|
20
|
-
__exportStar(require("./context-builder"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Plugin helpers for defining channel adapters.
|
|
4
|
-
*
|
|
5
|
-
* defineChannelAdapter — type-safe identity function for IChannelAdapter.
|
|
6
|
-
* defineChannelAdapterPlugin — wraps an adapter as a CrewxPlugin (§3.3).
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.defineChannelAdapter = defineChannelAdapter;
|
|
10
|
-
exports.defineChannelAdapterPlugin = defineChannelAdapterPlugin;
|
|
11
|
-
function defineChannelAdapter(spec) {
|
|
12
|
-
return spec;
|
|
13
|
-
}
|
|
14
|
-
function defineChannelAdapterPlugin(spec) {
|
|
15
|
-
return {
|
|
16
|
-
name: spec.name,
|
|
17
|
-
async attach(crewx) {
|
|
18
|
-
const config = await spec.configFactory(crewx);
|
|
19
|
-
const anyCrewx = crewx;
|
|
20
|
-
const registerFn = anyCrewx['registerChannelAdapter'];
|
|
21
|
-
const instanceId = spec.instanceId ?? spec.name;
|
|
22
|
-
if (registerFn) {
|
|
23
|
-
await registerFn({
|
|
24
|
-
adapter: spec.adapter,
|
|
25
|
-
instanceId,
|
|
26
|
-
config,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
if (spec.onAttach) {
|
|
30
|
-
await spec.onAttach(crewx);
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
async detach(crewx) {
|
|
34
|
-
const anyCrewx = crewx;
|
|
35
|
-
const unregisterFn = anyCrewx['unregisterChannelAdapter'];
|
|
36
|
-
if (unregisterFn) {
|
|
37
|
-
await unregisterFn(spec.instanceId ?? spec.name);
|
|
38
|
-
}
|
|
39
|
-
if (spec.onDetach) {
|
|
40
|
-
await spec.onDetach(crewx);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=plugin-helper.js.map
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ScopedAdapterStore — adapter key-value store with mandatory instanceId prefix.
|
|
4
|
-
*
|
|
5
|
-
* Security: Uses Map closure pattern (RT-1 defense).
|
|
6
|
-
* The internal Map is captured in a function closure — no public or private
|
|
7
|
-
* property on the returned AdapterStore object holds the raw Map reference.
|
|
8
|
-
* Reflect / Object.getPrototypeOf / (ctx.db as any)['_rawStore'] all fail
|
|
9
|
-
* because the Map only exists in the createScopedAdapterStore function scope.
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createScopedAdapterStore = createScopedAdapterStore;
|
|
13
|
-
function createScopedAdapterStore(instanceId) {
|
|
14
|
-
const store = new Map();
|
|
15
|
-
const prefixKey = (key) => {
|
|
16
|
-
if (key.startsWith(`${instanceId}::`))
|
|
17
|
-
return key;
|
|
18
|
-
return `${instanceId}::${key}`;
|
|
19
|
-
};
|
|
20
|
-
return {
|
|
21
|
-
async get(key) {
|
|
22
|
-
const entry = store.get(prefixKey(key));
|
|
23
|
-
return entry ? entry.value : undefined;
|
|
24
|
-
},
|
|
25
|
-
async set(key, value) {
|
|
26
|
-
store.set(prefixKey(key), { value });
|
|
27
|
-
},
|
|
28
|
-
async delete(key) {
|
|
29
|
-
return store.delete(prefixKey(key));
|
|
30
|
-
},
|
|
31
|
-
async list(prefix) {
|
|
32
|
-
const fullPrefix = prefix ? prefixKey(prefix) : `${instanceId}::`;
|
|
33
|
-
const keys = [];
|
|
34
|
-
for (const k of store.keys()) {
|
|
35
|
-
if (k.startsWith(fullPrefix)) {
|
|
36
|
-
keys.push(k.slice(instanceId.length + 2));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return keys;
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=scoped-store.js.map
|
package/dist/adapter/types.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Adapter Platform v0.4 — core types.
|
|
4
|
-
* PoC corrections applied:
|
|
5
|
-
* 1. AdapterError: class only (interface removed)
|
|
6
|
-
* 2. kind: added 'config' for configuration errors
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.AdapterError = void 0;
|
|
10
|
-
class AdapterError extends Error {
|
|
11
|
-
code;
|
|
12
|
-
kind;
|
|
13
|
-
retryAfterMs;
|
|
14
|
-
constructor(code, kind, retryAfterMs) {
|
|
15
|
-
super(`AdapterError: ${code}`);
|
|
16
|
-
this.name = 'AdapterError';
|
|
17
|
-
this.code = code;
|
|
18
|
-
this.kind = kind;
|
|
19
|
-
this.retryAfterMs = retryAfterMs;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.AdapterError = AdapterError;
|
|
23
|
-
//# sourceMappingURL=types.js.map
|
package/dist/agent/resolver.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Agent resolver: looks up an agent from a list by ref.
|
|
4
|
-
* Supports both bare id ('claude') and @mention format ('@claude').
|
|
5
|
-
* Falls back to built-in provider shorthands (claude, gemini, copilot, codex).
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.AgentNotFoundError = void 0;
|
|
9
|
-
exports.resolveAgent = resolveAgent;
|
|
10
|
-
class AgentNotFoundError extends Error {
|
|
11
|
-
constructor(agentRef, availableIds) {
|
|
12
|
-
const available = availableIds.length > 0
|
|
13
|
-
? ` Available: ${availableIds.join(', ')}`
|
|
14
|
-
: '';
|
|
15
|
-
super(`Agent not found: "${agentRef}".${available}`);
|
|
16
|
-
this.name = 'AgentNotFoundError';
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.AgentNotFoundError = AgentNotFoundError;
|
|
20
|
-
/** Built-in provider shorthands that can be used without a crewx.yaml entry. */
|
|
21
|
-
const BUILTIN_PROVIDERS = {
|
|
22
|
-
claude: { id: 'claude', provider: 'cli/claude' },
|
|
23
|
-
gemini: { id: 'gemini', provider: 'cli/gemini' },
|
|
24
|
-
copilot: { id: 'copilot', provider: 'cli/copilot' },
|
|
25
|
-
codex: { id: 'codex', provider: 'cli/codex' },
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Resolve an agent by reference.
|
|
29
|
-
* @param agentRef - Agent reference: '@claude', 'claude', '@my_agent', etc.
|
|
30
|
-
* @param agents - List of available agent configs.
|
|
31
|
-
* @returns The matching AgentConfig.
|
|
32
|
-
* @throws AgentNotFoundError when no match is found.
|
|
33
|
-
*/
|
|
34
|
-
function resolveAgent(agentRef, agents) {
|
|
35
|
-
const agentId = agentRef.startsWith('@') ? agentRef.slice(1) : agentRef;
|
|
36
|
-
// 1. Look in YAML-defined agents first
|
|
37
|
-
const agent = agents.find(a => a.id === agentId);
|
|
38
|
-
if (agent)
|
|
39
|
-
return agent;
|
|
40
|
-
// 2. Fall back to built-in provider shorthands
|
|
41
|
-
const builtin = BUILTIN_PROVIDERS[agentId];
|
|
42
|
-
if (builtin)
|
|
43
|
-
return builtin;
|
|
44
|
-
throw new AgentNotFoundError(agentRef, agents.map(a => a.id));
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=resolver.js.map
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* SdkBoxService — manages box creation, retrieval, and listing.
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SdkBoxService = void 0;
|
|
7
|
-
const id_1 = require("../utils/id");
|
|
8
|
-
const ID_PATTERN = /^[a-zA-Z0-9._-]+$/;
|
|
9
|
-
class SdkBoxService {
|
|
10
|
-
storage;
|
|
11
|
-
constructor(storage) {
|
|
12
|
-
this.storage = storage;
|
|
13
|
-
}
|
|
14
|
-
listBoxes(threadId) {
|
|
15
|
-
this.validateId(threadId);
|
|
16
|
-
const rows = this.storage.listBoxes(threadId);
|
|
17
|
-
const boxes = rows.map((row) => this.toBoxResponse(row));
|
|
18
|
-
return { boxes, total: boxes.length };
|
|
19
|
-
}
|
|
20
|
-
getBox(threadId, boxId) {
|
|
21
|
-
this.validateId(threadId);
|
|
22
|
-
this.validateId(boxId);
|
|
23
|
-
const row = this.storage.findBox(threadId, boxId);
|
|
24
|
-
if (!row)
|
|
25
|
-
return null;
|
|
26
|
-
return this.toBoxResponse(row);
|
|
27
|
-
}
|
|
28
|
-
createBox(threadId, params) {
|
|
29
|
-
this.validateId(threadId);
|
|
30
|
-
const id = this.generateBoxId();
|
|
31
|
-
const createdAt = new Date().toISOString();
|
|
32
|
-
const row = this.storage.insertBox(threadId, {
|
|
33
|
-
id,
|
|
34
|
-
seq: params.seq,
|
|
35
|
-
firstTaskId: params.firstTaskId,
|
|
36
|
-
midTaskId: params.midTaskId,
|
|
37
|
-
lastTaskId: params.lastTaskId,
|
|
38
|
-
taskCount: params.taskCount,
|
|
39
|
-
summary: params.summary ?? null,
|
|
40
|
-
sourceTokens: params.sourceTokens,
|
|
41
|
-
summaryTokens: params.summaryTokens ?? null,
|
|
42
|
-
createdAt,
|
|
43
|
-
});
|
|
44
|
-
return this.toBoxResponse(row);
|
|
45
|
-
}
|
|
46
|
-
toBoxResponse(row) {
|
|
47
|
-
return {
|
|
48
|
-
id: row.id,
|
|
49
|
-
threadId: row.thread_id,
|
|
50
|
-
seq: row.seq,
|
|
51
|
-
firstTaskId: row.first_task_id,
|
|
52
|
-
lastTaskId: row.last_task_id,
|
|
53
|
-
taskCount: row.task_count,
|
|
54
|
-
sourceTokens: row.source_tokens,
|
|
55
|
-
summaryTokens: row.summary_tokens,
|
|
56
|
-
summary: row.summary,
|
|
57
|
-
previewFirst: this.storage.getTaskPreview(row.first_task_id, 200),
|
|
58
|
-
previewMid: this.storage.getTaskPreview(row.mid_task_id, 200),
|
|
59
|
-
previewLast: this.storage.getTaskPreview(row.last_task_id, 200),
|
|
60
|
-
createdAt: row.created_at,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
validateId(id) {
|
|
64
|
-
if (!ID_PATTERN.test(id)) {
|
|
65
|
-
throw new Error(`Invalid ID format: ${id}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
generateBoxId() {
|
|
69
|
-
return (0, id_1.generateId)('box');
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.SdkBoxService = SdkBoxService;
|
|
73
|
-
//# sourceMappingURL=box.service.js.map
|