@gt-fe/eap-runtime 0.0.27 → 0.0.28
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.
|
@@ -85,12 +85,14 @@ export function createDevRuntime(options) {
|
|
|
85
85
|
llmProvider = createDefaultLLMProvider(turnLog);
|
|
86
86
|
llmProviderKind = 'echo';
|
|
87
87
|
}
|
|
88
|
-
// ── Tool Executor(dev+mcp
|
|
88
|
+
// ── Tool Executor(dev+mcp:server MCP 走 Gateway,其余直连)──
|
|
89
89
|
// overlay 必须在此处捕获:SDK createAgent 返回后会恢复 process.env。
|
|
90
90
|
const overlayJail = captureOverlayJailOptions();
|
|
91
91
|
const needsHarnessWrap = toolExecutionMode === 'mcp' && deploymentContext === 'dev';
|
|
92
92
|
const innerExecutor = toolExecutionMode === 'mcp' && deploymentContext === 'dev'
|
|
93
|
-
? new DevToolExecutor(
|
|
93
|
+
? new DevToolExecutor({
|
|
94
|
+
foundationUrl: foundationConfigured ? foundationUrl : undefined,
|
|
95
|
+
})
|
|
94
96
|
: createToolExecutor({ foundationUrl, deploymentContext, jail: overlayJail });
|
|
95
97
|
const toolExecutor = needsHarnessWrap
|
|
96
98
|
? withHarnessPrimitives(innerExecutor, overlayJail)
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* 仅在 `EAP_TOOL_EXECUTION_MODE=mcp` 且 `deploymentContext=dev` 装配。
|
|
5
5
|
* 按清单分流,缺配置则失败,不回落 mock。
|
|
6
6
|
*
|
|
7
|
-
* - execution.protocol=mcp →
|
|
7
|
+
* - execution.protocol=mcp 且 toolRuntime=server → McpToolExecutor(FOUNDATION_SERVICE_URL)
|
|
8
|
+
* - 其余 execution.protocol=mcp → DevMcpExecutor(直连 server.url / stdio)
|
|
8
9
|
* - execution.protocol=http → DevHttpExecutor
|
|
9
10
|
* - 能解析出 code handler → LocalToolExecutor
|
|
10
11
|
* - 其余 → NOT_CONFIGURED
|
|
@@ -13,11 +14,14 @@ import { DevMcpExecutor } from './dev-mcp-executor.js';
|
|
|
13
14
|
import type { IToolExecutor, McpListedTool, ToolCallRequest, ToolCallResult } from './tool-executor.interface.js';
|
|
14
15
|
export interface DevToolExecutorOptions {
|
|
15
16
|
mcp?: ConstructorParameters<typeof DevMcpExecutor>[0];
|
|
17
|
+
/** 绝对 http(s)。仅 toolRuntime=server 的 MCP 使用;缺省不直连 server.url。 */
|
|
18
|
+
foundationUrl?: string;
|
|
16
19
|
}
|
|
17
20
|
export declare class DevToolExecutor implements IToolExecutor {
|
|
18
21
|
private readonly mcp;
|
|
19
22
|
private readonly http;
|
|
20
23
|
private readonly local;
|
|
24
|
+
private readonly gateway;
|
|
21
25
|
constructor(options?: DevToolExecutorOptions);
|
|
22
26
|
execute(request: ToolCallRequest): Promise<ToolCallResult>;
|
|
23
27
|
listTools(request: ToolCallRequest): Promise<McpListedTool[]>;
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* 仅在 `EAP_TOOL_EXECUTION_MODE=mcp` 且 `deploymentContext=dev` 装配。
|
|
5
5
|
* 按清单分流,缺配置则失败,不回落 mock。
|
|
6
6
|
*
|
|
7
|
-
* - execution.protocol=mcp →
|
|
7
|
+
* - execution.protocol=mcp 且 toolRuntime=server → McpToolExecutor(FOUNDATION_SERVICE_URL)
|
|
8
|
+
* - 其余 execution.protocol=mcp → DevMcpExecutor(直连 server.url / stdio)
|
|
8
9
|
* - execution.protocol=http → DevHttpExecutor
|
|
9
10
|
* - 能解析出 code handler → LocalToolExecutor
|
|
10
11
|
* - 其余 → NOT_CONFIGURED
|
|
@@ -13,16 +14,37 @@ import { EmptyInstallStore } from './create-tool-executor.js';
|
|
|
13
14
|
import { DevMcpExecutor } from './dev-mcp-executor.js';
|
|
14
15
|
import { LocalToolExecutor, resolveCodeExecutionFromRequest, } from './local-tool-executor.js';
|
|
15
16
|
import { DevHttpExecutor, resolveHttpExecutionFromRequest } from './dev-http-executor.js';
|
|
17
|
+
import { isAbsoluteHttpUrl, McpToolExecutor } from './mcp-tool-executor.js';
|
|
16
18
|
export class DevToolExecutor {
|
|
17
19
|
mcp;
|
|
18
20
|
http;
|
|
19
21
|
local;
|
|
22
|
+
gateway;
|
|
20
23
|
constructor(options = {}) {
|
|
21
24
|
this.mcp = new DevMcpExecutor(options.mcp);
|
|
22
25
|
this.http = new DevHttpExecutor();
|
|
23
26
|
this.local = new LocalToolExecutor({ installStore: new EmptyInstallStore() });
|
|
27
|
+
const foundationUrl = options.foundationUrl?.trim();
|
|
28
|
+
this.gateway = foundationUrl && isAbsoluteHttpUrl(foundationUrl)
|
|
29
|
+
? new McpToolExecutor({ baseUrl: foundationUrl })
|
|
30
|
+
: undefined;
|
|
24
31
|
}
|
|
25
32
|
async execute(request) {
|
|
33
|
+
if (hasMcpExecution(request.execution) && request.toolRuntime === 'server') {
|
|
34
|
+
if (!this.gateway) {
|
|
35
|
+
return {
|
|
36
|
+
toolCallId: request.toolCallId,
|
|
37
|
+
toolName: request.toolName,
|
|
38
|
+
content: '',
|
|
39
|
+
success: false,
|
|
40
|
+
error: `Dev MCP: tool "${request.toolName}" is toolRuntime=server and requires ` +
|
|
41
|
+
'FOUNDATION_SERVICE_URL (absolute http(s)); refusing to dial server.url',
|
|
42
|
+
errorCode: 'NOT_CONFIGURED',
|
|
43
|
+
runtime: 'local',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return this.gateway.execute(request);
|
|
47
|
+
}
|
|
26
48
|
if (hasMcpExecution(request.execution)) {
|
|
27
49
|
return this.mcp.execute(request);
|
|
28
50
|
}
|
|
@@ -48,6 +70,13 @@ export class DevToolExecutor {
|
|
|
48
70
|
};
|
|
49
71
|
}
|
|
50
72
|
async listTools(request) {
|
|
73
|
+
if (hasMcpExecution(request.execution) && request.toolRuntime === 'server') {
|
|
74
|
+
if (!this.gateway) {
|
|
75
|
+
throw new Error(`Dev MCP: tool "${request.toolName}" is toolRuntime=server and requires ` +
|
|
76
|
+
'FOUNDATION_SERVICE_URL (absolute http(s)); refusing to dial server.url');
|
|
77
|
+
}
|
|
78
|
+
return this.gateway.listTools(request);
|
|
79
|
+
}
|
|
51
80
|
if (hasMcpExecution(request.execution)) {
|
|
52
81
|
return this.mcp.listTools(request);
|
|
53
82
|
}
|