@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
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @crewx/sdk/plugins — Optional plugins for advanced runtime features.
|
|
3
|
-
*
|
|
4
|
-
* These plugins depend on Node.js APIs (fs, path, sqlite) and are kept out
|
|
5
|
-
* of the main `@crewx/sdk` entry to avoid bundling them into browser builds.
|
|
6
|
-
* Consumers must explicitly import from this subpath:
|
|
7
|
-
*
|
|
8
|
-
* import { FileLoggerPlugin, SqliteTracingPlugin } from '@crewx/sdk/plugins';
|
|
9
|
-
*/
|
|
10
1
|
export { FileLoggerPlugin } from './file-logger';
|
|
11
2
|
export type { FileLoggerPluginOptions } from './file-logger';
|
|
12
3
|
export { SqliteTracingPlugin } from './sqlite-tracing';
|
|
13
4
|
export type { SqliteTracingPluginOptions } from './sqlite-tracing';
|
|
14
5
|
export { ConversationPlugin } from './conversation';
|
|
15
6
|
export type { ConversationPluginOptions } from './conversation';
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,19 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
'use strict';var fs=require('fs'),k=require('path'),os=require('os'),U=require('better-sqlite3'),crypto=require('crypto');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var k__namespace=/*#__PURE__*/_interopNamespace(k);var U__default=/*#__PURE__*/_interopDefault(U);var d=class{detach(s){}};function w(i){let s=t=>String(t).padStart(2,"0");return `${i.getFullYear()}${s(i.getMonth()+1)}${s(i.getDate())}T${s(i.getHours())}${s(i.getMinutes())}${s(i.getSeconds())}`}var f=class extends d{name="file-logger";unsubs=[];logFiles=new Map;logsDir;version;constructor(s){super(),this.logsDir=k.join(s?.workspaceRoot??process.cwd(),".crewx","logs"),this.version=s?.version??"unknown";}attach(s){this.unsubs.push(s.on("task:start",t=>{try{fs.existsSync(this.logsDir)||fs.mkdirSync(this.logsDir,{recursive:!0});let r=w(t.timestamp),a=k.join(this.logsDir,`${r}_${t.traceId}.log`);this.logFiles.set(t.traceId,a);let n=`=== TASK LOG: ${t.traceId} ===
|
|
2
|
+
CrewX Version: ${this.version}
|
|
3
|
+
Mode: ${t.mode}
|
|
4
|
+
Agent: ${t.agentRef}
|
|
5
|
+
Started: ${t.timestamp.toLocaleString()}
|
|
6
|
+
Message: ${t.message}
|
|
7
|
+
|
|
8
|
+
`;fs.writeFileSync(a,n,{encoding:"utf8",mode:384});}catch{}}),s.on("task:output",t=>{try{let r=this.logFiles.get(t.traceId);if(!r)return;let a=new Date().toISOString();fs.appendFileSync(r,`[${a}] STDOUT: ${t.output}
|
|
9
|
+
`,"utf8");}catch{}}),s.on("task:end",t=>{try{let r=this.logFiles.get(t.traceId);if(!r)return;let a=new Date().toLocaleString(),n=t.error?`failed: ${t.error.message}`:"completed successfully",c=`[${a}] INFO: Task ${n} in ${t.durationMs}ms
|
|
10
|
+
[${a}] INFO: Process closed with exit code: ${t.error?1:0}
|
|
11
|
+
`;fs.appendFileSync(r,c,"utf8"),this.logFiles.delete(t.traceId);}catch{}}));}detach(s){this.unsubs.forEach(t=>t()),this.unsubs=[],this.logFiles.clear();}};function R(i){let s=k__namespace.resolve(i);return process.platform==="win32"&&(s=s.replace(/\\/g,"/"),s=s.replace(/^([A-Z]):/,(t,r)=>`${r.toLowerCase()}:`)),s.length>1&&!/^[a-zA-Z]:\/$/.test(s)&&(s=s.replace(/\/+$/,"")),s}function x(i){let s=R(i);return crypto.createHash("sha256").update(s).digest("hex")}var E=class extends d{name="sqlite-tracing";db=null;unsubs=[];dbPath;version;constructor(s){super(),this.dbPath=k.join(s?.dbRoot??os.homedir(),".crewx","crewx.db"),this.version=s?.version??"unknown";}attach(s){let t=k.dirname(this.dbPath);fs.existsSync(t)||fs.mkdirSync(t,{recursive:true}),this.db=new U__default.default(this.dbPath);let r=this.db.prepare("PRAGMA table_info(tasks)").all(),a=e=>r.some(o=>o.name===e);a("parent_task_id")||this.db.exec("ALTER TABLE tasks ADD COLUMN parent_task_id TEXT"),a("caller_agent_id")||this.db.exec("ALTER TABLE tasks ADD COLUMN caller_agent_id TEXT"),a("trace_id")||this.db.exec("ALTER TABLE tasks ADD COLUMN trace_id TEXT");let n=process.cwd(),c=fs.existsSync(k.join(n,"crewx.yaml"))||fs.existsSync(k.join(n,"crewx.yml")),y=c?x(n):null,m=c?k.basename(n):null,g=process.argv.join(" ");this.unsubs.push(s.on("task:start",e=>{try{let o=process.env.CREWX_CALLER_AGENT_ID||null,p=process.env.CREWX_PARENT_TASK_ID||null,C=process.env.CREWX_TRACE_ID||e.traceId,v=e.metadata?JSON.stringify(e.metadata):JSON.stringify({provider:e.provider??"cli/claude"});this.db.prepare(`INSERT OR IGNORE INTO tasks
|
|
12
|
+
(id, agent_id, prompt, mode, status, pid, started_at,
|
|
13
|
+
crewx_version, platform,
|
|
14
|
+
model, rendered_prompt, command, coding_agent_command,
|
|
15
|
+
workspace_id, workspace_name,
|
|
16
|
+
caller_agent_id, parent_task_id, trace_id, metadata, thread_id)
|
|
17
|
+
VALUES (?, ?, ?, ?, 'running', ?, ?,
|
|
18
|
+
?, ?,
|
|
19
|
+
?, ?, ?, ?,
|
|
20
|
+
?, ?,
|
|
21
|
+
?, ?, ?, ?, ?)`).run(e.traceId,e.agentRef.replace(/^@/,""),e.message,e.mode,e.pid??null,e.timestamp.toISOString(),this.version,e.platform??"cli",e.model??null,e.renderedPrompt??null,g,e.codingAgentCommand??null,e.workspaceId??y,e.workspaceName??m,o,p,C,v,e.threadId??null);}catch{}}),s.on("task:output",e=>{try{let o=this.db.prepare("SELECT logs FROM tasks WHERE id=?").get(e.traceId),p=o?.logs?JSON.parse(o.logs):[];p.push({timestamp:e.timestamp.toISOString(),level:e.level??"stdout",message:e.output}),this.db.prepare("UPDATE tasks SET logs=? WHERE id=?").run(JSON.stringify(p),e.traceId);}catch{}}),s.on("task:end",e=>{try{let o=e.error?"failed":"success";this.db.prepare(`UPDATE tasks
|
|
22
|
+
SET status=?, result=?, error=?,
|
|
23
|
+
completed_at=?, duration_ms=?,
|
|
24
|
+
exit_code=?,
|
|
25
|
+
input_tokens=?, output_tokens=?, cached_input_tokens=?,
|
|
26
|
+
cost_usd=?,
|
|
27
|
+
model=COALESCE(?, model)
|
|
28
|
+
WHERE id=?`).run(o,e.result??null,e.error?JSON.stringify(e.error):null,e.timestamp.toISOString(),e.durationMs,e.exitCode??null,e.inputTokens??0,e.outputTokens??0,e.cachedInputTokens??0,e.costUsd??0,e.model??null,e.traceId);}catch{}}));}detach(s){this.unsubs.forEach(t=>t()),this.unsubs=[],this.db?.close(),this.db=null;}};var H=`
|
|
29
|
+
CREATE TABLE IF NOT EXISTS threads (
|
|
30
|
+
id TEXT PRIMARY KEY,
|
|
31
|
+
workspace_id TEXT,
|
|
32
|
+
platform TEXT NOT NULL DEFAULT 'cli',
|
|
33
|
+
title TEXT,
|
|
34
|
+
first_message TEXT,
|
|
35
|
+
last_message TEXT,
|
|
36
|
+
message_count INTEGER NOT NULL DEFAULT 0,
|
|
37
|
+
created_at TEXT NOT NULL,
|
|
38
|
+
updated_at TEXT NOT NULL,
|
|
39
|
+
metadata TEXT
|
|
40
|
+
)
|
|
41
|
+
`,X=["id","thread_id","prompt","result","started_at","trace_id","status","parent_task_id","agent_id"];function q(i){return i.replace(/<conversation_history[^>]*>[\s\S]*?<\/conversation_history>/g,"").split(`
|
|
42
|
+
`).filter(a=>!(a.startsWith("Loaded ")&&a.includes("layouts from")||a.includes("[dotenv@")||a.includes("[Nest]")&&a.includes("DEBUG")||a.startsWith("Registered custom layout:")||a.startsWith("Updated custom layout:"))).join(`
|
|
43
|
+
`).trim()}function j(i){if(!i)return "";let s=i;try{let t=JSON.parse(s);Array.isArray(t)?s=t.filter(r=>r?.type==="text"&&r?.text).map(r=>r.text).join(`
|
|
44
|
+
`):t&&typeof t=="object"&&t.result!==void 0&&(s=t.result||"");}catch{s=q(s);}return s}var u=class{db;constructor(s){let t=s??k.join(os.homedir(),".crewx","crewx.db");this.db=new U__default.default(t),this.init();}init(){this.db.pragma("journal_mode = WAL"),this.db.exec(H);}async ensureThread(s,t,r){let a=this.db.prepare("SELECT platform FROM threads WHERE id = ?").get(s);if(a){if(a.platform!==t)throw new Error(`Thread '${s}' already exists with platform '${a.platform}' \u2014 cannot change to '${t}' (platform is immutable)`);r&&this.db.prepare("UPDATE threads SET workspace_id = COALESCE(workspace_id, ?) WHERE id = ?").run(r,s);return}let n=new Date().toISOString();this.db.prepare("INSERT INTO threads (id, platform, workspace_id, message_count, created_at, updated_at) VALUES (?, ?, ?, 0, ?, ?)").run(s,t,r??null,n,n);}async fetchHistory(s,t){let r=t?.limit??100,a=["thread_id = ?","(parent_task_id IS NULL OR parent_task_id = '')","(status IN ('done', 'completed', 'success') OR status IS NULL)"],n=[s];t?.currentTraceId&&(a.push("trace_id != ?"),n.push(t.currentTraceId));let c=a.join(" AND "),m=`SELECT ${X.join(", ")} FROM tasks WHERE ${c} ORDER BY started_at ASC LIMIT ?`;n.push(r);let g=this.db.prepare(m).all(...n),e=this.db.prepare("SELECT platform, title, first_message, last_message, message_count, updated_at FROM threads WHERE id = ?").get(s),o=e?.platform??"cli",p=this.rowsToMessages(g);return {threadId:s,platform:o,messages:p,metadata:{title:e?.title??void 0,firstMessage:e?.first_message??void 0,lastMessage:e?.last_message??void 0,messageCount:e?.message_count??0,updatedAt:e?.updated_at?new Date(e.updated_at).getTime():void 0}}}async saveUserMessage(s,t,r,a){let n=new Date().toISOString();this.db.prepare(`UPDATE threads
|
|
45
|
+
SET first_message = COALESCE(first_message, ?),
|
|
46
|
+
last_message = ?,
|
|
47
|
+
message_count = message_count + 1,
|
|
48
|
+
updated_at = ?
|
|
49
|
+
WHERE id = ?`).run(t,t,n,s);}async saveAssistantMessage(s,t,r,a){let n=new Date().toISOString();this.db.prepare(`UPDATE threads
|
|
50
|
+
SET last_message = ?,
|
|
51
|
+
updated_at = ?
|
|
52
|
+
WHERE id = ?`).run(t,n,s);}close(){this.db.close();}rowsToMessages(s){let t=[];for(let r of s){r.prompt&&t.push({id:`${r.id}-user`,text:r.prompt,isAssistant:false,timestamp:new Date(r.started_at).getTime()});let a=j(r.result);a&&t.push({id:`${r.id}-assistant`,text:a,isAssistant:true,timestamp:new Date(r.started_at).getTime()});}return t}};var T=class extends d{name="conversation";_provider;unsubStart=null;unsubEnd=null;constructor(s){super(),this._provider=new u(s?.dbPath);}get conversationProvider(){return this._provider}attach(s){this.unsubStart=s.on("task:start",async t=>{if(!t.threadId)return;let r=t.platform??"cli";try{await this._provider.ensureThread(t.threadId,r,t.workspaceId),await this._provider.saveUserMessage(t.threadId,t.message??"");}catch{}}),this.unsubEnd=s.on("task:end",async t=>{if(!t.result)return;let r=t.metadata?.threadId;if(!r)return;let a=t.agentRef?.replace(/^@/,"")??"";try{await this._provider.saveAssistantMessage(r,t.result,a);}catch{}});}detach(s){this.unsubStart?.(),this.unsubStart=null,this.unsubEnd?.(),this.unsubEnd=null,this._provider.close?.();}};exports.ConversationPlugin=T;exports.FileLoggerPlugin=f;exports.SqliteTracingPlugin=E;
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SqliteTracingPlugin — records task execution data to ~/.crewx/crewx.db.
|
|
3
|
-
*
|
|
4
|
-
* Subscribes to task:start, task:output, and task:end events and persists
|
|
5
|
-
* full records to the global CrewX SQLite database. Matches the schema
|
|
6
|
-
* written by the global crewx CLI (0.8.x).
|
|
7
|
-
*
|
|
8
|
-
* DB location: {dbRoot}/.crewx/crewx.db
|
|
9
|
-
* (dbRoot defaults to os.homedir())
|
|
10
|
-
*/
|
|
11
1
|
import { CrewxPlugin } from '../plugin';
|
|
12
2
|
import type { Crewx } from '../facade/Crewx';
|
|
13
3
|
export interface SqliteTracingPluginOptions {
|
|
14
|
-
/** Root directory under which `.crewx/crewx.db` will be created. Defaults to `os.homedir()`. */
|
|
15
4
|
dbRoot?: string;
|
|
16
|
-
/** Caller-provided version string written into the `crewx_version` column. Defaults to `'unknown'`. */
|
|
17
5
|
version?: string;
|
|
18
6
|
}
|
|
19
7
|
export declare class SqliteTracingPlugin extends CrewxPlugin {
|
|
@@ -26,4 +14,3 @@ export declare class SqliteTracingPlugin extends CrewxPlugin {
|
|
|
26
14
|
attach(crewx: Crewx): void;
|
|
27
15
|
detach(_crewx: Crewx): void;
|
|
28
16
|
}
|
|
29
|
-
//# sourceMappingURL=sqlite-tracing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser-safe provider bridge.
|
|
3
|
-
* Registry pattern only — no child_process / CLI spawn.
|
|
4
|
-
*/
|
|
5
1
|
export declare class ProviderError extends Error {
|
|
6
2
|
readonly providerStr: string;
|
|
7
3
|
constructor(message: string, providerStr: string);
|
|
8
4
|
}
|
|
9
|
-
/** Factory function that creates a ProviderRuntime for a given provider id within a namespace. */
|
|
10
5
|
export type ProviderFactory = (id: string, providerStr: string) => ProviderRuntime;
|
|
11
|
-
/** Usage data extracted from provider output. */
|
|
12
6
|
export interface ProviderUsage {
|
|
13
7
|
inputTokens: number;
|
|
14
8
|
outputTokens: number;
|
|
@@ -31,19 +25,5 @@ export interface ProviderRuntime {
|
|
|
31
25
|
query(message: string, options?: ProviderQueryOptions): Promise<string>;
|
|
32
26
|
execute(message: string, options?: ProviderQueryOptions): Promise<string>;
|
|
33
27
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Register a provider factory for a given namespace.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* registerProviderFactory('api', (id, providerStr) => ({
|
|
39
|
-
* async query(message, options) { ... },
|
|
40
|
-
* async execute(message, options) { ... },
|
|
41
|
-
* }));
|
|
42
|
-
*/
|
|
43
28
|
export declare function registerProviderFactory(namespace: string, factory: ProviderFactory): void;
|
|
44
|
-
/**
|
|
45
|
-
* Create a provider runtime for the given provider string.
|
|
46
|
-
* Browser version — only supports registered factories (no CLI fallback).
|
|
47
|
-
*/
|
|
48
29
|
export declare function createProvider(providerStr: string): ProviderRuntime;
|
|
49
|
-
//# sourceMappingURL=bridge.browser.d.ts.map
|
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provider bridge: creates a runtime that can invoke AI providers.
|
|
3
|
-
*
|
|
4
|
-
* Supports a registry pattern — built-in cli/* providers are registered by default,
|
|
5
|
-
* and additional namespaces (e.g. api/*, webllm/*) can be added via registerProviderFactory().
|
|
6
|
-
*/
|
|
7
1
|
export declare function parseStreamJsonOutput(raw: string): string;
|
|
8
2
|
export declare function parseResultEventUsage(raw: string): ProviderUsage | null;
|
|
9
3
|
export declare class ProviderError extends Error {
|
|
10
4
|
readonly providerStr: string;
|
|
11
5
|
constructor(message: string, providerStr: string);
|
|
12
6
|
}
|
|
13
|
-
/** Describes a pending client-side tool call that requires external execution. */
|
|
14
7
|
export interface ClientToolCall {
|
|
15
8
|
toolCallId: string;
|
|
16
9
|
toolName: string;
|
|
17
10
|
args: Record<string, unknown>;
|
|
18
11
|
}
|
|
19
|
-
/** Opaque state needed to resume a conversation after a client tool call. */
|
|
20
12
|
export interface ContinuationState {
|
|
21
13
|
userMessage: string;
|
|
22
14
|
responseMessages: unknown[];
|
|
@@ -25,31 +17,14 @@ export interface ContinuationState {
|
|
|
25
17
|
systemPrompt?: string;
|
|
26
18
|
modelOverride?: string;
|
|
27
19
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Thrown by VercelProviderRuntime when generateText() encounters a tool without
|
|
30
|
-
* an execute function (client tool). The caller should return requires_action
|
|
31
|
-
* to the client, collect the tool result, and call continueWithToolResults().
|
|
32
|
-
*/
|
|
33
20
|
export declare class ClientToolCallRequiredError extends Error {
|
|
34
21
|
readonly toolCall: ClientToolCall;
|
|
35
22
|
readonly continuationState: ContinuationState;
|
|
36
23
|
readonly name = "ClientToolCallRequiredError";
|
|
37
24
|
constructor(toolCall: ClientToolCall, continuationState: ContinuationState);
|
|
38
25
|
}
|
|
39
|
-
/** Factory function that creates a ProviderRuntime for a given provider id within a namespace. */
|
|
40
26
|
export type ProviderFactory = (id: string, providerStr: string) => ProviderRuntime;
|
|
41
|
-
/**
|
|
42
|
-
* Register a provider factory for a given namespace.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* // Register an API-based provider namespace
|
|
46
|
-
* registerProviderFactory('api', (id, providerStr) => new MyApiProvider(id));
|
|
47
|
-
*
|
|
48
|
-
* // Now createProvider('api/claude') works
|
|
49
|
-
* const provider = createProvider('api/claude');
|
|
50
|
-
*/
|
|
51
27
|
export declare function registerProviderFactory(namespace: string, factory: ProviderFactory): void;
|
|
52
|
-
/** Usage data extracted from provider stream-json output. */
|
|
53
28
|
export interface ProviderUsage {
|
|
54
29
|
inputTokens: number;
|
|
55
30
|
outputTokens: number;
|
|
@@ -60,47 +35,25 @@ export interface ProviderQueryOptions {
|
|
|
60
35
|
model?: string;
|
|
61
36
|
context?: string;
|
|
62
37
|
systemPrompt?: string;
|
|
63
|
-
/** Provider-specific CLI args from agent config (e.g. ['exec', '--json'] for codex). Replaces hardcoded defaults when provided. */
|
|
64
38
|
additionalArgs?: string[];
|
|
65
|
-
/** Called with each completed output line from the provider process. */
|
|
66
39
|
onOutput?: (line: string, level: 'stdout' | 'stderr') => void;
|
|
67
|
-
/** Called once with the child process PID, right after spawn. */
|
|
68
40
|
onPid?: (pid: number) => void;
|
|
69
|
-
/** Called with the full CLI command string (e.g. "claude -p ... --output-format stream-json"). */
|
|
70
41
|
onCommand?: (command: string) => void;
|
|
71
|
-
/** Called with token usage once the result event is parsed. */
|
|
72
42
|
onUsage?: (usage: ProviderUsage) => void;
|
|
73
|
-
/** Called with the process exit code on close. */
|
|
74
43
|
onExitCode?: (code: number) => void;
|
|
75
|
-
/** Called with the actual model used (from result event's modelUsage key). */
|
|
76
44
|
onModel?: (model: string) => void;
|
|
77
|
-
/** CREWX_* env vars injected by facade for hook context propagation */
|
|
78
45
|
env?: Record<string, string>;
|
|
79
|
-
/** Working directory for CLI provider process (overrides process.cwd). Used by file:// remote delegation. */
|
|
80
46
|
cwd?: string;
|
|
81
|
-
/** Vercel AI SDK에 주입할 tools. registerTool()로 등록한 것 중 필터링된 목록. */
|
|
82
47
|
tools?: import('../facade/Crewx').ToolDefinition[];
|
|
83
|
-
/** Agent generate() 최대 반복 횟수. 기본값 10, 최대 50. */
|
|
84
48
|
maxSteps?: number;
|
|
85
49
|
}
|
|
86
50
|
export interface ProviderRuntime {
|
|
87
51
|
query(message: string, options?: ProviderQueryOptions): Promise<string>;
|
|
88
52
|
execute(message: string, options?: ProviderQueryOptions): Promise<string>;
|
|
89
|
-
/** Resume a conversation after providing client-side tool results. Only implemented by API providers. */
|
|
90
53
|
continueWithToolResults?(continuationState: ContinuationState, toolResults: Array<{
|
|
91
54
|
toolCallId: string;
|
|
92
55
|
toolName: string;
|
|
93
56
|
result: unknown;
|
|
94
57
|
}>, options?: ProviderQueryOptions): Promise<string>;
|
|
95
58
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Create a provider runtime for the given provider string.
|
|
98
|
-
*
|
|
99
|
-
* Looks up the namespace in the provider registry first.
|
|
100
|
-
* Falls back to built-in cli/* providers for backward compatibility.
|
|
101
|
-
*
|
|
102
|
-
* @param providerStr - Provider string in namespace/id format (e.g., 'cli/claude', 'api/claude')
|
|
103
|
-
* @throws ProviderError for unknown or unsupported providers
|
|
104
|
-
*/
|
|
105
59
|
export declare function createProvider(providerStr: string): ProviderRuntime;
|
|
106
|
-
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure function to extract token usage from provider CLI stdout.
|
|
3
|
-
* Supports Claude / Codex / Gemini / Copilot / OpenCode JSONL formats.
|
|
4
|
-
* Uses last-match semantics: if multiple usage events are found, the last one wins.
|
|
5
|
-
*/
|
|
6
1
|
export interface ParsedUsage {
|
|
7
2
|
inputTokens: number;
|
|
8
3
|
outputTokens: number;
|
|
9
|
-
/** Cached tokens (read from cache). */
|
|
10
4
|
cachedInputTokens: number;
|
|
11
5
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Parse token usage from a provider CLI stdout string.
|
|
14
|
-
*
|
|
15
|
-
* Accepts JSONL (one JSON object per line) or a single JSON document.
|
|
16
|
-
* Returns the **last** usage found (last-match semantics).
|
|
17
|
-
* Returns `undefined` if no usage data is present.
|
|
18
|
-
*/
|
|
19
6
|
export declare function parseUsage(stdout: string): ParsedUsage | undefined;
|
|
20
|
-
//# sourceMappingURL=parse-usage.d.ts.map
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* api/* namespace를 provider registry에 등록.
|
|
3
|
-
*
|
|
4
|
-
* crewx.yaml에서 provider: api/openrouter 등을 쓰면
|
|
5
|
-
* createProvider('api/openrouter') → VercelProviderRuntime 반환.
|
|
6
|
-
*/
|
|
7
1
|
export declare function registerApiProviders(globalConfig?: {
|
|
8
2
|
apiKeys?: Record<string, string>;
|
|
9
3
|
defaults?: {
|
|
@@ -11,4 +5,3 @@ export declare function registerApiProviders(globalConfig?: {
|
|
|
11
5
|
temperature?: number;
|
|
12
6
|
};
|
|
13
7
|
}): void;
|
|
14
|
-
//# sourceMappingURL=register-api.d.ts.map
|
|
@@ -1,24 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* VercelProviderRuntime — API 프로바이더를 위한 ProviderRuntime 구현.
|
|
3
|
-
*
|
|
4
|
-
* Vercel AI SDK의 generateText() + tool()을 직접 사용하여 tool calling loop를 처리한다.
|
|
5
|
-
* @ai-sdk/* 기반 모델 인스턴스를 생성하여 OpenRouter, OpenAI, Anthropic, Google 지원.
|
|
6
|
-
*/
|
|
7
1
|
import type { ProviderRuntime, ProviderQueryOptions, ContinuationState } from './bridge';
|
|
8
2
|
export interface VercelProviderConfig {
|
|
9
|
-
/** Provider string (e.g. 'api/openrouter', 'api/anthropic'). */
|
|
10
3
|
provider: string;
|
|
11
|
-
/** Model identifier (e.g. 'anthropic/claude-sonnet-4-20250514'). */
|
|
12
4
|
model: string;
|
|
13
|
-
/** API key — falls back to environment variable if not set. */
|
|
14
5
|
apiKey?: string;
|
|
15
|
-
/** Custom base URL (e.g. OpenRouter endpoint). */
|
|
16
6
|
baseURL?: string;
|
|
17
|
-
/** Sampling temperature. */
|
|
18
7
|
temperature?: number;
|
|
19
|
-
/** Max output tokens. */
|
|
20
8
|
maxTokens?: number;
|
|
21
|
-
/** Default max steps for tool loop. */
|
|
22
9
|
maxSteps?: number;
|
|
23
10
|
}
|
|
24
11
|
export declare class VercelProviderRuntime implements ProviderRuntime {
|
|
@@ -27,28 +14,12 @@ export declare class VercelProviderRuntime implements ProviderRuntime {
|
|
|
27
14
|
query(message: string, options?: ProviderQueryOptions): Promise<string>;
|
|
28
15
|
execute(message: string, options?: ProviderQueryOptions): Promise<string>;
|
|
29
16
|
private _run;
|
|
30
|
-
/**
|
|
31
|
-
* Resume a conversation after client-side tool results are provided.
|
|
32
|
-
* Reconstructs the message history and calls generateText() again.
|
|
33
|
-
*/
|
|
34
17
|
continueWithToolResults(state: ContinuationState, toolResults: Array<{
|
|
35
18
|
toolCallId: string;
|
|
36
19
|
toolName: string;
|
|
37
20
|
result: unknown;
|
|
38
21
|
}>, options?: ProviderQueryOptions): Promise<string>;
|
|
39
|
-
/**
|
|
40
|
-
* CrewX ToolDefinition[] → Vercel AI SDK tool Record 변환.
|
|
41
|
-
* execute가 없는 tool은 client tool로 처리 (Vercel AI SDK 네이티브 지원).
|
|
42
|
-
*/
|
|
43
22
|
private convertTools;
|
|
44
|
-
/**
|
|
45
|
-
* JSON Schema → Zod 간이 변환.
|
|
46
|
-
*/
|
|
47
23
|
private jsonSchemaToZod;
|
|
48
|
-
/**
|
|
49
|
-
* Vercel AI SDK model 인스턴스 생성.
|
|
50
|
-
* provider string에 따라 적절한 SDK 팩토리 사용.
|
|
51
|
-
*/
|
|
52
24
|
private createModel;
|
|
53
25
|
}
|
|
54
|
-
//# sourceMappingURL=vercel-runtime.d.ts.map
|
package/dist/remote/index.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Remote Agent Module
|
|
3
|
-
*
|
|
4
|
-
* SDK core module for remote agent communication via MCP protocol.
|
|
5
|
-
*/
|
|
6
1
|
export * from './types.js';
|
|
7
2
|
export { McpHttpTransport } from './remote-transport.js';
|
|
8
3
|
export type { McpHttpTransportOptions } from './remote-transport.js';
|
|
@@ -10,4 +5,3 @@ export { RemoteAgentManager } from './remote-agent-manager.js';
|
|
|
10
5
|
export type { RemoteAgentManagerOptions } from './remote-agent-manager.js';
|
|
11
6
|
export { RemoteProviderRuntime, createRemoteProviderFactory, resolveFileRemoteAgent } from './remote-provider.js';
|
|
12
7
|
export type { ProviderFactoryFn, FileRemoteResolution, FileRemoteResolver } from './remote-provider.js';
|
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,54 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Remote Agent Manager
|
|
3
|
-
*
|
|
4
|
-
* Manages communication with remote MCP agents.
|
|
5
|
-
* Migrated from sdk-bak/src/core/remote/remote-agent-manager.ts
|
|
6
|
-
* and adapted to use the new RemoteTransport interface.
|
|
7
|
-
*/
|
|
8
1
|
import type { RemoteAgentConfig, RemoteTransport, RemoteAgentQueryRequest, RemoteAgentExecuteRequest, RemoteAgentResponse, ToolNameMapping } from './types.js';
|
|
9
|
-
/** Options for creating a RemoteAgentManager. */
|
|
10
2
|
export interface RemoteAgentManagerOptions {
|
|
11
|
-
/** Optional logger function. */
|
|
12
3
|
logger?: (message: string, level?: 'debug' | 'info' | 'warn' | 'error') => void;
|
|
13
4
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Remote Agent Manager
|
|
16
|
-
*
|
|
17
|
-
* Manages communication with remote MCP agents.
|
|
18
|
-
* Each loaded agent config creates its own transport instance.
|
|
19
|
-
*/
|
|
20
5
|
export declare class RemoteAgentManager {
|
|
21
6
|
private readonly logger;
|
|
22
7
|
private readonly configs;
|
|
23
8
|
private readonly transports;
|
|
24
9
|
constructor(options?: RemoteAgentManagerOptions);
|
|
25
|
-
/**
|
|
26
|
-
* Load configuration for a remote agent.
|
|
27
|
-
* Creates a transport instance for the agent.
|
|
28
|
-
*/
|
|
29
10
|
loadConfig(agentId: string, config: RemoteAgentConfig): void;
|
|
30
|
-
/**
|
|
31
|
-
* Load configuration with a custom transport (e.g. for testing).
|
|
32
|
-
*/
|
|
33
11
|
loadConfigWithTransport(agentId: string, config: RemoteAgentConfig, transport: RemoteTransport): void;
|
|
34
|
-
/** Get configuration for a remote agent. */
|
|
35
12
|
getConfig(agentId: string): RemoteAgentConfig | undefined;
|
|
36
|
-
/** Check if an agent is configured as remote. */
|
|
37
13
|
isRemoteAgent(agentId: string): boolean;
|
|
38
|
-
/** Get all configured remote agent IDs. */
|
|
39
14
|
getRemoteAgentIds(): string[];
|
|
40
|
-
/** Query a remote agent. */
|
|
41
15
|
query(agentId: string, request: RemoteAgentQueryRequest): Promise<RemoteAgentResponse>;
|
|
42
|
-
/** Execute a task on a remote agent. */
|
|
43
16
|
execute(agentId: string, request: RemoteAgentExecuteRequest): Promise<RemoteAgentResponse>;
|
|
44
|
-
/** Map tool names for a remote agent. */
|
|
45
17
|
mapToolNames(agentId: string, mapping: Partial<ToolNameMapping>): void;
|
|
46
|
-
/** Clear all configurations and close transports. */
|
|
47
18
|
clearConfigs(): Promise<void>;
|
|
48
19
|
private requireConfig;
|
|
49
20
|
private callRemoteTool;
|
|
50
|
-
/** Normalize remote agent response to consistent format. */
|
|
51
21
|
normalizeResponse(result: unknown): RemoteAgentResponse;
|
|
52
22
|
private validateConfig;
|
|
53
23
|
}
|
|
54
|
-
//# sourceMappingURL=remote-agent-manager.d.ts.map
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Remote Provider Runtime
|
|
3
|
-
*
|
|
4
|
-
* Implements ProviderRuntime for remote agents via MCP-HTTP transport.
|
|
5
|
-
*
|
|
6
|
-
* Resolution path:
|
|
7
|
-
* - http(s):// → MCP-HTTP transport via RemoteAgentManager
|
|
8
|
-
*
|
|
9
|
-
* Note: file:// remote agents are handled at the CLI level by swapping the
|
|
10
|
-
* Crewx instance to the target crewx.yaml before calling query/execute.
|
|
11
|
-
* See packages/cli/src/commands/execute.ts and query.ts for details.
|
|
12
|
-
*/
|
|
13
1
|
import type { ProviderRuntime, ProviderQueryOptions } from '../provider/bridge.js';
|
|
14
2
|
import type { RemoteProviderConfig } from './types.js';
|
|
15
3
|
import type { AgentConfig } from '../types/index.js';
|
|
@@ -18,11 +6,9 @@ export interface FileRemoteResolution {
|
|
|
18
6
|
agent: AgentConfig;
|
|
19
7
|
provider: string;
|
|
20
8
|
}
|
|
21
|
-
/** Raw agent shape extracted from a remote crewx.yaml — minimal, lenient. */
|
|
22
9
|
interface RawAgent {
|
|
23
10
|
id: string;
|
|
24
11
|
provider?: string | string[];
|
|
25
|
-
/** Newer crewx.yaml format: provider may live inside inline. */
|
|
26
12
|
inline?: {
|
|
27
13
|
provider?: string | string[];
|
|
28
14
|
};
|
|
@@ -44,4 +30,3 @@ export declare class RemoteProviderRuntime implements ProviderRuntime {
|
|
|
44
30
|
}
|
|
45
31
|
export declare function createRemoteProviderFactory(remoteConfigs: Map<string, RemoteProviderConfig>, providerFactory?: ProviderFactoryFn): (id: string, providerStr: string) => ProviderRuntime;
|
|
46
32
|
export {};
|
|
47
|
-
//# sourceMappingURL=remote-provider.d.ts.map
|
|
@@ -1,26 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Remote Transport Implementations
|
|
3
|
-
*
|
|
4
|
-
* MCP-HTTP JSON-RPC 2.0 transport for communicating with remote MCP servers.
|
|
5
|
-
* Migrated from sdk-bak and adapted to the new RemoteTransport interface.
|
|
6
|
-
*/
|
|
7
1
|
import type { RemoteTransport, McpJsonRpcRequest, McpJsonRpcResponse } from './types.js';
|
|
8
|
-
/** Options for creating an McpHttpTransport. */
|
|
9
2
|
export interface McpHttpTransportOptions {
|
|
10
|
-
/** Base URL of the MCP server (e.g. "http://localhost:3030"). */
|
|
11
3
|
url: string;
|
|
12
|
-
/** Optional API key for Bearer authentication. */
|
|
13
4
|
apiKey?: string;
|
|
14
|
-
/** Optional custom headers. */
|
|
15
5
|
headers?: Record<string, string>;
|
|
16
|
-
/** Request timeout in milliseconds (default: 30000). */
|
|
17
6
|
timeoutMs?: number;
|
|
18
7
|
}
|
|
19
|
-
/**
|
|
20
|
-
* MCP-HTTP transport — sends JSON-RPC 2.0 requests over HTTP POST.
|
|
21
|
-
*
|
|
22
|
-
* Endpoint: `${baseUrl}/mcp`
|
|
23
|
-
*/
|
|
24
8
|
export declare class McpHttpTransport implements RemoteTransport {
|
|
25
9
|
private readonly endpoint;
|
|
26
10
|
private readonly headers;
|
|
@@ -29,4 +13,3 @@ export declare class McpHttpTransport implements RemoteTransport {
|
|
|
29
13
|
send(request: McpJsonRpcRequest): Promise<McpJsonRpcResponse>;
|
|
30
14
|
close(): Promise<void>;
|
|
31
15
|
}
|
|
32
|
-
//# sourceMappingURL=remote-transport.d.ts.map
|
package/dist/remote/types.d.ts
CHANGED
|
@@ -1,27 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Remote Agent Module — Type Definitions
|
|
3
|
-
*
|
|
4
|
-
* Types for remote agent communication via MCP (Model Context Protocol).
|
|
5
|
-
* Migrated from sdk-bak/src/core/remote/types.ts and adapted to SDK conventions.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Transport abstraction for remote MCP communication.
|
|
9
|
-
* Designed for future extension (WebSocket, gRPC, etc.).
|
|
10
|
-
*/
|
|
11
1
|
export interface RemoteTransport {
|
|
12
|
-
/** Send a JSON-RPC 2.0 request and receive a response. */
|
|
13
2
|
send(request: McpJsonRpcRequest): Promise<McpJsonRpcResponse>;
|
|
14
|
-
/** Release transport resources. */
|
|
15
3
|
close(): Promise<void>;
|
|
16
4
|
}
|
|
17
|
-
/** MCP JSON-RPC 2.0 Request */
|
|
18
5
|
export interface McpJsonRpcRequest {
|
|
19
6
|
jsonrpc: '2.0';
|
|
20
7
|
id: string;
|
|
21
8
|
method: string;
|
|
22
9
|
params?: Record<string, unknown>;
|
|
23
10
|
}
|
|
24
|
-
/** MCP JSON-RPC 2.0 Response */
|
|
25
11
|
export interface McpJsonRpcResponse<T = unknown> {
|
|
26
12
|
jsonrpc: '2.0';
|
|
27
13
|
id: string;
|
|
@@ -32,116 +18,71 @@ export interface McpJsonRpcResponse<T = unknown> {
|
|
|
32
18
|
data?: unknown;
|
|
33
19
|
};
|
|
34
20
|
}
|
|
35
|
-
/** Remote agent configuration (SDK-internal format). */
|
|
36
21
|
export interface RemoteAgentConfig {
|
|
37
|
-
/** Remote agent type (currently only mcp-http supported). */
|
|
38
22
|
type: 'mcp-http';
|
|
39
|
-
/** Base URL for the remote MCP server. */
|
|
40
23
|
url: string;
|
|
41
|
-
/** Optional API key for authentication. */
|
|
42
24
|
apiKey?: string;
|
|
43
|
-
/** Optional custom headers. */
|
|
44
25
|
headers?: Record<string, string>;
|
|
45
|
-
/** Optional timeout in milliseconds. */
|
|
46
26
|
timeoutMs?: number;
|
|
47
|
-
/** Remote agent ID (may differ from local agent ID). */
|
|
48
27
|
agentId?: string;
|
|
49
|
-
/** Tool name mappings (optional). */
|
|
50
28
|
tools?: {
|
|
51
29
|
query?: string;
|
|
52
30
|
execute?: string;
|
|
53
31
|
};
|
|
54
32
|
}
|
|
55
|
-
/** Remote provider config as defined in crewx.yaml `providers:` section. */
|
|
56
33
|
export interface RemoteProviderConfig {
|
|
57
|
-
/** Provider ID (e.g. "remote_cto"). */
|
|
58
34
|
id: string;
|
|
59
|
-
/** Provider type — must be "remote". */
|
|
60
35
|
type: 'remote';
|
|
61
|
-
/** Location of the remote agent (file:// or http(s)://). */
|
|
62
36
|
location: string;
|
|
63
|
-
/** Agent ID on the remote side. */
|
|
64
37
|
external_agent_id?: string;
|
|
65
|
-
/** Display name for UI. */
|
|
66
38
|
display_name?: string;
|
|
67
|
-
/** Description. */
|
|
68
39
|
description?: string;
|
|
69
|
-
/** Timeout per mode (ms). */
|
|
70
40
|
timeout?: {
|
|
71
41
|
query?: number;
|
|
72
42
|
execute?: number;
|
|
73
43
|
};
|
|
74
|
-
/** Optional API key for MCP-HTTP authentication. */
|
|
75
44
|
apiKey?: string;
|
|
76
|
-
/** Optional custom headers for MCP-HTTP. */
|
|
77
45
|
headers?: Record<string, string>;
|
|
78
46
|
}
|
|
79
|
-
/** Remote agent query request parameters. */
|
|
80
47
|
export interface RemoteAgentQueryRequest {
|
|
81
|
-
/** The agent ID to query. */
|
|
82
48
|
agentId: string;
|
|
83
|
-
/** The query text. */
|
|
84
49
|
query: string;
|
|
85
|
-
/** Optional context. */
|
|
86
50
|
context?: string;
|
|
87
|
-
/** Optional model override. */
|
|
88
51
|
model?: string;
|
|
89
|
-
/** Optional platform identifier. */
|
|
90
52
|
platform?: string;
|
|
91
|
-
/** Optional conversation messages. */
|
|
92
53
|
messages?: Array<{
|
|
93
54
|
text: string;
|
|
94
55
|
isAssistant: boolean;
|
|
95
56
|
metadata?: Record<string, unknown>;
|
|
96
57
|
}>;
|
|
97
58
|
}
|
|
98
|
-
/** Remote agent execute request parameters. */
|
|
99
59
|
export interface RemoteAgentExecuteRequest {
|
|
100
|
-
/** The agent ID to execute. */
|
|
101
60
|
agentId: string;
|
|
102
|
-
/** The task to execute. */
|
|
103
61
|
task: string;
|
|
104
|
-
/** Optional context. */
|
|
105
62
|
context?: string;
|
|
106
|
-
/** Optional model override. */
|
|
107
63
|
model?: string;
|
|
108
|
-
/** Optional platform identifier. */
|
|
109
64
|
platform?: string;
|
|
110
|
-
/** Optional conversation messages. */
|
|
111
65
|
messages?: Array<{
|
|
112
66
|
text: string;
|
|
113
67
|
isAssistant: boolean;
|
|
114
68
|
metadata?: Record<string, unknown>;
|
|
115
69
|
}>;
|
|
116
70
|
}
|
|
117
|
-
/** Remote agent response. */
|
|
118
71
|
export interface RemoteAgentResponse {
|
|
119
|
-
/** Response content blocks. */
|
|
120
72
|
content: Array<{
|
|
121
73
|
type: string;
|
|
122
74
|
text: string;
|
|
123
75
|
}>;
|
|
124
|
-
/** Success flag. */
|
|
125
76
|
success?: boolean;
|
|
126
|
-
/** Error message if failed. */
|
|
127
77
|
error?: string;
|
|
128
|
-
/** Additional metadata. */
|
|
129
78
|
[key: string]: unknown;
|
|
130
79
|
}
|
|
131
|
-
/** Tool name mapping for remote agents. */
|
|
132
80
|
export interface ToolNameMapping {
|
|
133
|
-
/** Tool name for query operations. */
|
|
134
81
|
query: string;
|
|
135
|
-
/** Tool name for execute operations. */
|
|
136
82
|
execute: string;
|
|
137
83
|
}
|
|
138
|
-
/** Remote agent descriptor containing configuration and metadata. */
|
|
139
84
|
export interface RemoteAgentDescriptor {
|
|
140
|
-
/** Local agent ID. */
|
|
141
85
|
localAgentId: string;
|
|
142
|
-
/** Remote agent ID (may differ). */
|
|
143
86
|
remoteAgentId: string;
|
|
144
|
-
/** Remote agent configuration. */
|
|
145
87
|
config: RemoteAgentConfig;
|
|
146
88
|
}
|
|
147
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/server/auth.d.ts
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Server authentication & Origin validation.
|
|
3
|
-
*
|
|
4
|
-
* - Origin header 검증 (DNS rebinding 방어, MCP 스펙 필수)
|
|
5
|
-
* - 커스텀 auth 콜백 래퍼
|
|
6
|
-
*/
|
|
7
1
|
export interface AuthOptions {
|
|
8
|
-
/** Custom auth callback. Return false to reject the request. */
|
|
9
2
|
auth?: (req: Request) => Promise<boolean>;
|
|
10
3
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Validate the Origin header is present (MCP spec requirement).
|
|
13
|
-
* Returns a 403 Response if validation fails, or null if ok.
|
|
14
|
-
*/
|
|
15
4
|
export declare function validateOrigin(req: Request): Response | null;
|
|
16
|
-
/**
|
|
17
|
-
* Run the custom auth callback if provided.
|
|
18
|
-
* Returns a 401 Response if auth fails, or null if ok.
|
|
19
|
-
*/
|
|
20
5
|
export declare function runAuthCallback(req: Request, auth?: (req: Request) => Promise<boolean>): Promise<Response | null>;
|
|
21
|
-
//# sourceMappingURL=auth.d.ts.map
|