@wingman-ai/gateway 0.2.4 → 0.3.0
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/.wingman/agents/coding/agent.md +5 -0
- package/.wingman/agents/coding-v2/agent.md +58 -0
- package/.wingman/agents/game-dev/agent.md +94 -0
- package/.wingman/agents/game-dev/art-generation.md +37 -0
- package/.wingman/agents/game-dev/asset-refinement.md +17 -0
- package/.wingman/agents/game-dev/planning-idea.md +17 -0
- package/.wingman/agents/game-dev/ui-specialist.md +17 -0
- package/.wingman/agents/main/agent.md +2 -0
- package/README.md +1 -0
- package/dist/agent/config/agentConfig.d.ts +4 -0
- package/dist/agent/config/mcpClientManager.cjs +44 -10
- package/dist/agent/config/mcpClientManager.d.ts +6 -2
- package/dist/agent/config/mcpClientManager.js +44 -10
- package/dist/agent/config/toolRegistry.cjs +3 -1
- package/dist/agent/config/toolRegistry.js +3 -1
- package/dist/agent/tests/mcpClientManager.test.cjs +124 -0
- package/dist/agent/tests/mcpClientManager.test.d.ts +1 -0
- package/dist/agent/tests/mcpClientManager.test.js +118 -0
- package/dist/agent/tools/command_execute.cjs +1 -1
- package/dist/agent/tools/command_execute.js +1 -1
- package/dist/cli/config/schema.d.ts +2 -0
- package/dist/cli/core/agentInvoker.cjs +55 -66
- package/dist/cli/core/agentInvoker.d.ts +10 -13
- package/dist/cli/core/agentInvoker.js +42 -62
- package/dist/cli/core/imagePersistence.cjs +125 -0
- package/dist/cli/core/imagePersistence.d.ts +24 -0
- package/dist/cli/core/imagePersistence.js +85 -0
- package/dist/cli/core/sessionManager.cjs +297 -40
- package/dist/cli/core/sessionManager.d.ts +9 -0
- package/dist/cli/core/sessionManager.js +297 -40
- package/dist/debug/terminalProbe.cjs +57 -0
- package/dist/debug/terminalProbe.d.ts +10 -0
- package/dist/debug/terminalProbe.js +20 -0
- package/dist/debug/terminalProbeAuth.cjs +140 -0
- package/dist/debug/terminalProbeAuth.d.ts +20 -0
- package/dist/debug/terminalProbeAuth.js +97 -0
- package/dist/gateway/http/fs.cjs +19 -0
- package/dist/gateway/http/fs.js +19 -0
- package/dist/gateway/http/sessions.cjs +25 -5
- package/dist/gateway/http/sessions.js +25 -5
- package/dist/gateway/server.cjs +112 -11
- package/dist/gateway/server.d.ts +2 -0
- package/dist/gateway/server.js +112 -11
- package/dist/providers/codex.cjs +230 -37
- package/dist/providers/codex.d.ts +2 -0
- package/dist/providers/codex.js +231 -38
- package/dist/tests/agentInvokerSummarization.test.cjs +56 -37
- package/dist/tests/agentInvokerSummarization.test.js +58 -39
- package/dist/tests/agentInvokerWorkdir.test.cjs +50 -0
- package/dist/tests/agentInvokerWorkdir.test.js +52 -2
- package/dist/tests/cli-init.test.cjs +36 -0
- package/dist/tests/cli-init.test.js +36 -0
- package/dist/tests/codex-provider.test.cjs +173 -0
- package/dist/tests/codex-provider.test.js +174 -1
- package/dist/tests/falRuntime.test.cjs +78 -0
- package/dist/tests/falRuntime.test.d.ts +1 -0
- package/dist/tests/falRuntime.test.js +72 -0
- package/dist/tests/falSummary.test.cjs +51 -0
- package/dist/tests/falSummary.test.d.ts +1 -0
- package/dist/tests/falSummary.test.js +45 -0
- package/dist/tests/gateway.test.cjs +109 -1
- package/dist/tests/gateway.test.js +109 -1
- package/dist/tests/imagePersistence.test.cjs +143 -0
- package/dist/tests/imagePersistence.test.d.ts +1 -0
- package/dist/tests/imagePersistence.test.js +137 -0
- package/dist/tests/sessionMessageAttachments.test.cjs +30 -0
- package/dist/tests/sessionMessageAttachments.test.js +30 -0
- package/dist/tests/sessionStateMessages.test.cjs +126 -0
- package/dist/tests/sessionStateMessages.test.js +126 -0
- package/dist/tests/sessions-api.test.cjs +117 -3
- package/dist/tests/sessions-api.test.js +118 -4
- package/dist/tests/terminalProbe.test.cjs +45 -0
- package/dist/tests/terminalProbe.test.d.ts +1 -0
- package/dist/tests/terminalProbe.test.js +39 -0
- package/dist/tests/terminalProbeAuth.test.cjs +85 -0
- package/dist/tests/terminalProbeAuth.test.d.ts +1 -0
- package/dist/tests/terminalProbeAuth.test.js +79 -0
- package/dist/tools/fal/runtime.cjs +103 -0
- package/dist/tools/fal/runtime.d.ts +10 -0
- package/dist/tools/fal/runtime.js +60 -0
- package/dist/tools/fal/summary.cjs +78 -0
- package/dist/tools/fal/summary.d.ts +22 -0
- package/dist/tools/fal/summary.js +41 -0
- package/dist/tools/mcp-fal-ai.cjs +1041 -0
- package/dist/tools/mcp-fal-ai.d.ts +1 -0
- package/dist/tools/mcp-fal-ai.js +1025 -0
- package/dist/types/mcp.cjs +2 -0
- package/dist/types/mcp.d.ts +8 -0
- package/dist/types/mcp.js +3 -1
- package/dist/webui/assets/index-0nUBsUUq.js +278 -0
- package/dist/webui/assets/index-kk7OrD-G.css +11 -0
- package/dist/webui/index.html +2 -2
- package/package.json +16 -13
- package/dist/webui/assets/index-DVWQluit.css +0 -11
- package/dist/webui/assets/index-Dlyzwalc.js +0 -270
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_exports__ = {};
|
|
3
|
+
const external_vitest_namespaceObject = require("vitest");
|
|
4
|
+
const mcpClientManager_cjs_namespaceObject = require("../config/mcpClientManager.cjs");
|
|
5
|
+
const testLogger = {
|
|
6
|
+
debug: ()=>{},
|
|
7
|
+
info: ()=>{},
|
|
8
|
+
warn: ()=>{},
|
|
9
|
+
error: ()=>{}
|
|
10
|
+
};
|
|
11
|
+
const getClientConfig = (manager)=>manager.buildClientConfig();
|
|
12
|
+
(0, external_vitest_namespaceObject.describe)("MCPClientManager runtime env", ()=>{
|
|
13
|
+
(0, external_vitest_namespaceObject.it)("injects workdir for stdio servers", ()=>{
|
|
14
|
+
const executionWorkspace = "/tmp/wingman-workdir";
|
|
15
|
+
const configs = [
|
|
16
|
+
{
|
|
17
|
+
servers: [
|
|
18
|
+
{
|
|
19
|
+
name: "fal-ai",
|
|
20
|
+
transport: "stdio",
|
|
21
|
+
command: "bun",
|
|
22
|
+
args: [
|
|
23
|
+
"run",
|
|
24
|
+
"src/tools/mcp-fal-ai.ts"
|
|
25
|
+
],
|
|
26
|
+
env: {
|
|
27
|
+
EXISTING: "value"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
const manager = new mcpClientManager_cjs_namespaceObject.MCPClientManager(configs, testLogger, {
|
|
34
|
+
executionWorkspace
|
|
35
|
+
});
|
|
36
|
+
const clientConfig = getClientConfig(manager);
|
|
37
|
+
const env = clientConfig.mcpServers["fal-ai"].env;
|
|
38
|
+
(0, external_vitest_namespaceObject.expect)(env.EXISTING).toBe("value");
|
|
39
|
+
(0, external_vitest_namespaceObject.expect)(env.WINGMAN_WORKDIR).toBe(executionWorkspace);
|
|
40
|
+
});
|
|
41
|
+
(0, external_vitest_namespaceObject.it)("does not inject workdir when no execution workspace is provided", ()=>{
|
|
42
|
+
const configs = [
|
|
43
|
+
{
|
|
44
|
+
servers: [
|
|
45
|
+
{
|
|
46
|
+
name: "fal-ai",
|
|
47
|
+
transport: "stdio",
|
|
48
|
+
command: "bun",
|
|
49
|
+
args: [
|
|
50
|
+
"run",
|
|
51
|
+
"src/tools/mcp-fal-ai.ts"
|
|
52
|
+
],
|
|
53
|
+
env: {
|
|
54
|
+
EXISTING: "value"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
];
|
|
60
|
+
const manager = new mcpClientManager_cjs_namespaceObject.MCPClientManager(configs, testLogger);
|
|
61
|
+
const clientConfig = getClientConfig(manager);
|
|
62
|
+
const env = clientConfig.mcpServers["fal-ai"].env;
|
|
63
|
+
(0, external_vitest_namespaceObject.expect)(env.EXISTING).toBe("value");
|
|
64
|
+
(0, external_vitest_namespaceObject.expect)(env.WINGMAN_WORKDIR).toBeUndefined();
|
|
65
|
+
});
|
|
66
|
+
(0, external_vitest_namespaceObject.it)("resolves env placeholders", ()=>{
|
|
67
|
+
const original = process.env.FAL_API_KEY;
|
|
68
|
+
process.env.FAL_API_KEY = "test-key";
|
|
69
|
+
try {
|
|
70
|
+
const configs = [
|
|
71
|
+
{
|
|
72
|
+
servers: [
|
|
73
|
+
{
|
|
74
|
+
name: "fal-ai",
|
|
75
|
+
transport: "stdio",
|
|
76
|
+
command: "bun",
|
|
77
|
+
args: [
|
|
78
|
+
"run",
|
|
79
|
+
"src/tools/mcp-fal-ai.ts"
|
|
80
|
+
],
|
|
81
|
+
env: {
|
|
82
|
+
FAL_API_KEY: "${FAL_API_KEY}"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
];
|
|
88
|
+
const manager = new mcpClientManager_cjs_namespaceObject.MCPClientManager(configs, testLogger);
|
|
89
|
+
const clientConfig = getClientConfig(manager);
|
|
90
|
+
(0, external_vitest_namespaceObject.expect)(clientConfig.mcpServers["fal-ai"].env.FAL_API_KEY).toBe("test-key");
|
|
91
|
+
} finally{
|
|
92
|
+
if ("string" == typeof original) process.env.FAL_API_KEY = original;
|
|
93
|
+
else delete process.env.FAL_API_KEY;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
(0, external_vitest_namespaceObject.it)("passes through per-server default tool timeout", ()=>{
|
|
97
|
+
const configs = [
|
|
98
|
+
{
|
|
99
|
+
servers: [
|
|
100
|
+
{
|
|
101
|
+
name: "fal-ai",
|
|
102
|
+
transport: "stdio",
|
|
103
|
+
command: "bun",
|
|
104
|
+
args: [
|
|
105
|
+
"run",
|
|
106
|
+
"src/tools/mcp-fal-ai.ts"
|
|
107
|
+
],
|
|
108
|
+
defaultToolTimeout: 300000,
|
|
109
|
+
env: {
|
|
110
|
+
EXISTING: "value"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
];
|
|
116
|
+
const manager = new mcpClientManager_cjs_namespaceObject.MCPClientManager(configs, testLogger);
|
|
117
|
+
const clientConfig = getClientConfig(manager);
|
|
118
|
+
(0, external_vitest_namespaceObject.expect)(clientConfig.mcpServers["fal-ai"].defaultToolTimeout).toBe(300000);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
122
|
+
Object.defineProperty(exports, '__esModule', {
|
|
123
|
+
value: true
|
|
124
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { MCPClientManager } from "../config/mcpClientManager.js";
|
|
3
|
+
const testLogger = {
|
|
4
|
+
debug: ()=>{},
|
|
5
|
+
info: ()=>{},
|
|
6
|
+
warn: ()=>{},
|
|
7
|
+
error: ()=>{}
|
|
8
|
+
};
|
|
9
|
+
const getClientConfig = (manager)=>manager.buildClientConfig();
|
|
10
|
+
describe("MCPClientManager runtime env", ()=>{
|
|
11
|
+
it("injects workdir for stdio servers", ()=>{
|
|
12
|
+
const executionWorkspace = "/tmp/wingman-workdir";
|
|
13
|
+
const configs = [
|
|
14
|
+
{
|
|
15
|
+
servers: [
|
|
16
|
+
{
|
|
17
|
+
name: "fal-ai",
|
|
18
|
+
transport: "stdio",
|
|
19
|
+
command: "bun",
|
|
20
|
+
args: [
|
|
21
|
+
"run",
|
|
22
|
+
"src/tools/mcp-fal-ai.ts"
|
|
23
|
+
],
|
|
24
|
+
env: {
|
|
25
|
+
EXISTING: "value"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
const manager = new MCPClientManager(configs, testLogger, {
|
|
32
|
+
executionWorkspace
|
|
33
|
+
});
|
|
34
|
+
const clientConfig = getClientConfig(manager);
|
|
35
|
+
const env = clientConfig.mcpServers["fal-ai"].env;
|
|
36
|
+
expect(env.EXISTING).toBe("value");
|
|
37
|
+
expect(env.WINGMAN_WORKDIR).toBe(executionWorkspace);
|
|
38
|
+
});
|
|
39
|
+
it("does not inject workdir when no execution workspace is provided", ()=>{
|
|
40
|
+
const configs = [
|
|
41
|
+
{
|
|
42
|
+
servers: [
|
|
43
|
+
{
|
|
44
|
+
name: "fal-ai",
|
|
45
|
+
transport: "stdio",
|
|
46
|
+
command: "bun",
|
|
47
|
+
args: [
|
|
48
|
+
"run",
|
|
49
|
+
"src/tools/mcp-fal-ai.ts"
|
|
50
|
+
],
|
|
51
|
+
env: {
|
|
52
|
+
EXISTING: "value"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
];
|
|
58
|
+
const manager = new MCPClientManager(configs, testLogger);
|
|
59
|
+
const clientConfig = getClientConfig(manager);
|
|
60
|
+
const env = clientConfig.mcpServers["fal-ai"].env;
|
|
61
|
+
expect(env.EXISTING).toBe("value");
|
|
62
|
+
expect(env.WINGMAN_WORKDIR).toBeUndefined();
|
|
63
|
+
});
|
|
64
|
+
it("resolves env placeholders", ()=>{
|
|
65
|
+
const original = process.env.FAL_API_KEY;
|
|
66
|
+
process.env.FAL_API_KEY = "test-key";
|
|
67
|
+
try {
|
|
68
|
+
const configs = [
|
|
69
|
+
{
|
|
70
|
+
servers: [
|
|
71
|
+
{
|
|
72
|
+
name: "fal-ai",
|
|
73
|
+
transport: "stdio",
|
|
74
|
+
command: "bun",
|
|
75
|
+
args: [
|
|
76
|
+
"run",
|
|
77
|
+
"src/tools/mcp-fal-ai.ts"
|
|
78
|
+
],
|
|
79
|
+
env: {
|
|
80
|
+
FAL_API_KEY: "${FAL_API_KEY}"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
];
|
|
86
|
+
const manager = new MCPClientManager(configs, testLogger);
|
|
87
|
+
const clientConfig = getClientConfig(manager);
|
|
88
|
+
expect(clientConfig.mcpServers["fal-ai"].env.FAL_API_KEY).toBe("test-key");
|
|
89
|
+
} finally{
|
|
90
|
+
if ("string" == typeof original) process.env.FAL_API_KEY = original;
|
|
91
|
+
else delete process.env.FAL_API_KEY;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
it("passes through per-server default tool timeout", ()=>{
|
|
95
|
+
const configs = [
|
|
96
|
+
{
|
|
97
|
+
servers: [
|
|
98
|
+
{
|
|
99
|
+
name: "fal-ai",
|
|
100
|
+
transport: "stdio",
|
|
101
|
+
command: "bun",
|
|
102
|
+
args: [
|
|
103
|
+
"run",
|
|
104
|
+
"src/tools/mcp-fal-ai.ts"
|
|
105
|
+
],
|
|
106
|
+
defaultToolTimeout: 300000,
|
|
107
|
+
env: {
|
|
108
|
+
EXISTING: "value"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
];
|
|
114
|
+
const manager = new MCPClientManager(configs, testLogger);
|
|
115
|
+
const clientConfig = getClientConfig(manager);
|
|
116
|
+
expect(clientConfig.mcpServers["fal-ai"].defaultToolTimeout).toBe(300000);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
@@ -135,7 +135,7 @@ const createCommandExecuteTool = (workspace, envVariables, blockedCommands = DEF
|
|
|
135
135
|
}
|
|
136
136
|
}), {
|
|
137
137
|
name: "command_execute",
|
|
138
|
-
description: "Executes a command in a terminal and reports the output. Cannot execute potentially destructive commands like rm, mv, chmod, sudo, etc. Use for safe operations like running tests, builds, or other validation commands. Do not run long-running commands like dev servers. Commands run with a timeout in the active execution workspace context.",
|
|
138
|
+
description: "Executes a command in a terminal and reports the output. Cannot execute potentially destructive commands like rm, mv, chmod, sudo, etc. Use for safe operations like running tests, builds, or other validation commands. Not for image generation/editing requests when dedicated image tools are available. Do not run long-running commands like dev servers. Commands run with a timeout in the active execution workspace context.",
|
|
139
139
|
schema: external_zod_namespaceObject.object({
|
|
140
140
|
command: external_zod_namespaceObject.string().describe("The command to execute in the terminal")
|
|
141
141
|
})
|
|
@@ -106,7 +106,7 @@ const createCommandExecuteTool = (workspace, envVariables, blockedCommands = DEF
|
|
|
106
106
|
}
|
|
107
107
|
}), {
|
|
108
108
|
name: "command_execute",
|
|
109
|
-
description: "Executes a command in a terminal and reports the output. Cannot execute potentially destructive commands like rm, mv, chmod, sudo, etc. Use for safe operations like running tests, builds, or other validation commands. Do not run long-running commands like dev servers. Commands run with a timeout in the active execution workspace context.",
|
|
109
|
+
description: "Executes a command in a terminal and reports the output. Cannot execute potentially destructive commands like rm, mv, chmod, sudo, etc. Use for safe operations like running tests, builds, or other validation commands. Not for image generation/editing requests when dedicated image tools are available. Do not run long-running commands like dev servers. Commands run with a timeout in the active execution workspace context.",
|
|
110
110
|
schema: object({
|
|
111
111
|
command: string().describe("The command to execute in the terminal")
|
|
112
112
|
})
|
|
@@ -339,12 +339,14 @@ export declare const WingmanConfigSchema: z.ZodObject<{
|
|
|
339
339
|
servers: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
340
340
|
name: z.ZodString;
|
|
341
341
|
transport: z.ZodLiteral<"stdio">;
|
|
342
|
+
defaultToolTimeout: z.ZodOptional<z.ZodNumber>;
|
|
342
343
|
command: z.ZodString;
|
|
343
344
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
344
345
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
345
346
|
}, z.core.$strip>, z.ZodObject<{
|
|
346
347
|
name: z.ZodString;
|
|
347
348
|
transport: z.ZodLiteral<"sse">;
|
|
349
|
+
defaultToolTimeout: z.ZodOptional<z.ZodNumber>;
|
|
348
350
|
url: z.ZodString;
|
|
349
351
|
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
350
352
|
}, z.core.$strip>]>>>;
|
|
@@ -26,7 +26,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
resolveToolRetryMiddlewareSettings: ()=>resolveToolRetryMiddlewareSettings,
|
|
28
28
|
resolveSummarizationMiddlewareSettings: ()=>resolveSummarizationMiddlewareSettings,
|
|
29
|
+
resolveAgentMemorySources: ()=>resolveAgentMemorySources,
|
|
29
30
|
OUTPUT_VIRTUAL_PATH: ()=>OUTPUT_VIRTUAL_PATH,
|
|
31
|
+
emitCompletionAndContinuePostProcessing: ()=>emitCompletionAndContinuePostProcessing,
|
|
30
32
|
resolveExecutionWorkspace: ()=>resolveExecutionWorkspace,
|
|
31
33
|
buildUserContent: ()=>buildUserContent,
|
|
32
34
|
detectStreamErrorMessage: ()=>detectStreamErrorMessage,
|
|
@@ -34,15 +36,16 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
34
36
|
chunkHasAssistantText: ()=>chunkHasAssistantText,
|
|
35
37
|
resolveModelRetryMiddlewareSettings: ()=>resolveModelRetryMiddlewareSettings,
|
|
36
38
|
AgentInvoker: ()=>AgentInvoker,
|
|
37
|
-
WORKDIR_VIRTUAL_PATH: ()=>WORKDIR_VIRTUAL_PATH,
|
|
38
39
|
configureDeepAgentSummarizationMiddleware: ()=>configureDeepAgentSummarizationMiddleware,
|
|
40
|
+
WORKDIR_VIRTUAL_PATH: ()=>WORKDIR_VIRTUAL_PATH,
|
|
39
41
|
detectToolEventContext: ()=>detectToolEventContext,
|
|
40
42
|
resolveExternalOutputMount: ()=>resolveExternalOutputMount,
|
|
41
|
-
evaluateStreamingCompletion: ()=>evaluateStreamingCompletion,
|
|
42
43
|
resolveHumanInTheLoopSettings: ()=>resolveHumanInTheLoopSettings,
|
|
43
44
|
trackRootLangGraphRunId: ()=>trackRootLangGraphRunId,
|
|
44
45
|
isRootLangGraphTerminalEvent: ()=>isRootLangGraphTerminalEvent,
|
|
45
|
-
selectStreamingFallbackText: ()=>selectStreamingFallbackText
|
|
46
|
+
selectStreamingFallbackText: ()=>selectStreamingFallbackText,
|
|
47
|
+
AGENTS_MEMORY_VIRTUAL_PATHS: ()=>AGENTS_MEMORY_VIRTUAL_PATHS,
|
|
48
|
+
resolveAgentExecutionWorkspace: ()=>resolveAgentExecutionWorkspace
|
|
46
49
|
});
|
|
47
50
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
48
51
|
const external_node_path_namespaceObject = require("node:path");
|
|
@@ -70,6 +73,9 @@ function _define_property(obj, key, value) {
|
|
|
70
73
|
}
|
|
71
74
|
const WORKDIR_VIRTUAL_PATH = "/workdir/";
|
|
72
75
|
const OUTPUT_VIRTUAL_PATH = "/output/";
|
|
76
|
+
const AGENTS_MEMORY_VIRTUAL_PATHS = [
|
|
77
|
+
"/AGENTS.md"
|
|
78
|
+
];
|
|
73
79
|
const DEFAULT_DEEPAGENT_MODEL = "claude-sonnet-4-5-20250929";
|
|
74
80
|
const isPathWithinRoot = (targetPath, rootPath)=>{
|
|
75
81
|
const normalizedTarget = (0, external_node_path_namespaceObject.normalize)(targetPath);
|
|
@@ -81,6 +87,11 @@ const resolveExecutionWorkspace = (workspace, workdir)=>{
|
|
|
81
87
|
if ((0, external_node_path_namespaceObject.isAbsolute)(workdir)) return (0, external_node_path_namespaceObject.normalize)(workdir);
|
|
82
88
|
return (0, external_node_path_namespaceObject.normalize)((0, external_node_path_namespaceObject.join)(workspace, workdir));
|
|
83
89
|
};
|
|
90
|
+
const resolveAgentExecutionWorkspace = (workspace, workdir, defaultOutputDir)=>{
|
|
91
|
+
const preferredWorkdir = workdir || defaultOutputDir || null;
|
|
92
|
+
return resolveExecutionWorkspace(workspace, preferredWorkdir);
|
|
93
|
+
};
|
|
94
|
+
const resolveAgentMemorySources = (executionWorkspace)=>AGENTS_MEMORY_VIRTUAL_PATHS.filter((memoryPath)=>(0, external_node_fs_namespaceObject.existsSync)((0, external_node_path_namespaceObject.join)(executionWorkspace, memoryPath.replace(/^\/+/, ""))));
|
|
84
95
|
const toWorkspaceAliasVirtualPath = (absolutePath)=>{
|
|
85
96
|
const normalized = (0, external_node_path_namespaceObject.normalize)(absolutePath);
|
|
86
97
|
if (!(0, external_node_path_namespaceObject.isAbsolute)(normalized)) return null;
|
|
@@ -284,24 +295,19 @@ const trackRootLangGraphRunId = (currentRootLangGraphRunId, chunk)=>{
|
|
|
284
295
|
return extractEventRunId(eventRecord) || currentRootLangGraphRunId;
|
|
285
296
|
};
|
|
286
297
|
const isRootLangGraphTerminalEvent = (chunk, rootLangGraphRunId)=>{
|
|
287
|
-
if (!rootLangGraphRunId) return false;
|
|
288
298
|
const eventRecord = extractStreamEventRecord(chunk);
|
|
289
299
|
if (!eventRecord || !isRootLangGraphChainEvent(eventRecord, "on_chain_end")) return false;
|
|
300
|
+
if (!rootLangGraphRunId) return true;
|
|
290
301
|
const chunkRunId = extractEventRunId(eventRecord);
|
|
302
|
+
if (!chunkRunId) return true;
|
|
291
303
|
return Boolean(chunkRunId && chunkRunId === rootLangGraphRunId);
|
|
292
304
|
};
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
message
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
return {
|
|
303
|
-
status: "ok"
|
|
304
|
-
};
|
|
305
|
+
const emitCompletionAndContinuePostProcessing = (input)=>{
|
|
306
|
+
input.outputManager.emitAgentComplete(input.result);
|
|
307
|
+
if (!input.postProcess) return;
|
|
308
|
+
input.postProcess().catch((error)=>{
|
|
309
|
+
input.logger?.debug("Failed post-completion processing for streamed agent response", error);
|
|
310
|
+
});
|
|
305
311
|
};
|
|
306
312
|
class AgentInvoker {
|
|
307
313
|
findAllAgents() {
|
|
@@ -315,14 +321,11 @@ class AgentInvoker {
|
|
|
315
321
|
let cancellationHandled = false;
|
|
316
322
|
let activeToolName = null;
|
|
317
323
|
let lastToolName = null;
|
|
318
|
-
let sawAssistantText = false;
|
|
319
|
-
let streamErrorMessage;
|
|
320
324
|
let rootLangGraphRunId;
|
|
321
|
-
let preInvocationMessages = null;
|
|
322
325
|
const isCancelled = ()=>options?.signal?.aborted === true;
|
|
323
326
|
try {
|
|
324
327
|
const hookSessionId = sessionId || (0, external_uuid_namespaceObject.v4)();
|
|
325
|
-
const executionWorkspace =
|
|
328
|
+
const executionWorkspace = resolveAgentExecutionWorkspace(this.workspace, this.workdir, this.defaultOutputDir);
|
|
326
329
|
const effectiveWorkdir = this.workdir ? executionWorkspace : null;
|
|
327
330
|
const loader = new agentLoader_cjs_namespaceObject.AgentLoader(this.configDir, this.workspace, this.wingmanConfig, executionWorkspace, {
|
|
328
331
|
terminalOwnerId: `${agentName}:${hookSessionId}`,
|
|
@@ -341,7 +344,9 @@ class AgentInvoker {
|
|
|
341
344
|
if (targetAgent.mcpUseGlobal && this.wingmanConfig.mcp) mcpConfigs.push(this.wingmanConfig.mcp);
|
|
342
345
|
if (mcpConfigs.length > 0) {
|
|
343
346
|
this.logger.debug("Initializing MCP client for agent invocation");
|
|
344
|
-
this.mcpManager = new mcpClientManager_cjs_namespaceObject.MCPClientManager(mcpConfigs, this.logger
|
|
347
|
+
this.mcpManager = new mcpClientManager_cjs_namespaceObject.MCPClientManager(mcpConfigs, this.logger, {
|
|
348
|
+
executionWorkspace
|
|
349
|
+
});
|
|
345
350
|
await this.mcpManager.initialize();
|
|
346
351
|
const mcpTools = await this.mcpManager.getTools();
|
|
347
352
|
if (mcpTools.length > 0) {
|
|
@@ -358,6 +363,7 @@ class AgentInvoker {
|
|
|
358
363
|
const normalizedSkillsDirectory = skillsDirectory.replace(/^\/+|\/+$/g, "");
|
|
359
364
|
const skillsVirtualPath = `/${normalizedSkillsDirectory}/`;
|
|
360
365
|
const outputMount = resolveExternalOutputMount(executionWorkspace, effectiveWorkdir, this.defaultOutputDir);
|
|
366
|
+
const memorySources = resolveAgentMemorySources(executionWorkspace);
|
|
361
367
|
const middleware = [
|
|
362
368
|
(0, media_compat_cjs_namespaceObject.mediaCompatibilityMiddleware)({
|
|
363
369
|
model: targetAgent.model
|
|
@@ -442,6 +448,7 @@ class AgentInvoker {
|
|
|
442
448
|
middleware: middleware,
|
|
443
449
|
interruptOn: hitlSettings?.interruptOn,
|
|
444
450
|
skills: skillsSources,
|
|
451
|
+
memory: memorySources,
|
|
445
452
|
subagents: targetAgent.subagents || [],
|
|
446
453
|
checkpointer: checkpointer
|
|
447
454
|
});
|
|
@@ -450,15 +457,6 @@ class AgentInvoker {
|
|
|
450
457
|
const userContent = buildUserContent(prompt, attachments, targetAgent.model);
|
|
451
458
|
if (this.sessionManager && sessionId) {
|
|
452
459
|
this.logger.debug(`Using streaming with session: ${sessionId}`);
|
|
453
|
-
try {
|
|
454
|
-
const messages = await this.sessionManager.listMessages(sessionId);
|
|
455
|
-
preInvocationMessages = messages.map((message)=>({
|
|
456
|
-
role: message.role,
|
|
457
|
-
content: message.content
|
|
458
|
-
}));
|
|
459
|
-
} catch (stateError) {
|
|
460
|
-
this.logger.debug("Failed to capture pre-invocation session state", stateError);
|
|
461
|
-
}
|
|
462
460
|
const stream = await standaloneAgent.streamEvents({
|
|
463
461
|
messages: [
|
|
464
462
|
{
|
|
@@ -476,8 +474,6 @@ class AgentInvoker {
|
|
|
476
474
|
});
|
|
477
475
|
for await (const chunk of stream){
|
|
478
476
|
rootLangGraphRunId = trackRootLangGraphRunId(rootLangGraphRunId, chunk);
|
|
479
|
-
if (!sawAssistantText && chunkHasAssistantText(chunk)) sawAssistantText = true;
|
|
480
|
-
if (!streamErrorMessage) streamErrorMessage = detectStreamErrorMessage(chunk);
|
|
481
477
|
const toolEvent = detectToolEventContext(chunk);
|
|
482
478
|
if (toolEvent) {
|
|
483
479
|
lastToolName = toolEvent.toolName;
|
|
@@ -507,37 +503,15 @@ class AgentInvoker {
|
|
|
507
503
|
cancelled: true
|
|
508
504
|
};
|
|
509
505
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
this.logger
|
|
519
|
-
}
|
|
520
|
-
const completionOutcome = evaluateStreamingCompletion({
|
|
521
|
-
sawAssistantText,
|
|
522
|
-
fallbackText,
|
|
523
|
-
streamErrorMessage
|
|
524
|
-
});
|
|
525
|
-
if ("blocked" === completionOutcome.status) {
|
|
526
|
-
this.logger.warn(completionOutcome.message);
|
|
527
|
-
this.outputManager.emitAgentError(completionOutcome.message);
|
|
528
|
-
return {
|
|
529
|
-
blocked: true,
|
|
530
|
-
reason: completionOutcome.reason
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
this.logger.info("Agent streaming completed successfully", {
|
|
534
|
-
usedFallbackText: Boolean(fallbackText)
|
|
535
|
-
});
|
|
536
|
-
this.outputManager.emitAgentComplete({
|
|
537
|
-
streaming: true,
|
|
538
|
-
...fallbackText ? {
|
|
539
|
-
fallbackText
|
|
540
|
-
} : {}
|
|
506
|
+
this.logger.info("Agent streaming completed successfully");
|
|
507
|
+
const completionPayload = {
|
|
508
|
+
streaming: true
|
|
509
|
+
};
|
|
510
|
+
emitCompletionAndContinuePostProcessing({
|
|
511
|
+
outputManager: this.outputManager,
|
|
512
|
+
result: completionPayload,
|
|
513
|
+
postProcess: ()=>this.materializeSessionImages(sessionId),
|
|
514
|
+
logger: this.logger
|
|
541
515
|
});
|
|
542
516
|
return {
|
|
543
517
|
streaming: true
|
|
@@ -573,7 +547,12 @@ class AgentInvoker {
|
|
|
573
547
|
};
|
|
574
548
|
}
|
|
575
549
|
this.logger.info("Agent completed successfully");
|
|
576
|
-
|
|
550
|
+
emitCompletionAndContinuePostProcessing({
|
|
551
|
+
outputManager: this.outputManager,
|
|
552
|
+
result,
|
|
553
|
+
postProcess: ()=>this.materializeSessionImages(sessionId),
|
|
554
|
+
logger: this.logger
|
|
555
|
+
});
|
|
577
556
|
return result;
|
|
578
557
|
}
|
|
579
558
|
} catch (error) {
|
|
@@ -605,6 +584,10 @@ class AgentInvoker {
|
|
|
605
584
|
description: a.description
|
|
606
585
|
}));
|
|
607
586
|
}
|
|
587
|
+
async materializeSessionImages(sessionId) {
|
|
588
|
+
if (!this.sessionManager || !sessionId) return;
|
|
589
|
+
await this.sessionManager.listMessages(sessionId);
|
|
590
|
+
}
|
|
608
591
|
constructor(options){
|
|
609
592
|
_define_property(this, "loader", void 0);
|
|
610
593
|
_define_property(this, "outputManager", void 0);
|
|
@@ -815,6 +798,7 @@ function buildAttachmentPreview(attachments) {
|
|
|
815
798
|
if (hasImage) return "[image]";
|
|
816
799
|
return "";
|
|
817
800
|
}
|
|
801
|
+
exports.AGENTS_MEMORY_VIRTUAL_PATHS = __webpack_exports__.AGENTS_MEMORY_VIRTUAL_PATHS;
|
|
818
802
|
exports.AgentInvoker = __webpack_exports__.AgentInvoker;
|
|
819
803
|
exports.OUTPUT_VIRTUAL_PATH = __webpack_exports__.OUTPUT_VIRTUAL_PATH;
|
|
820
804
|
exports.WORKDIR_VIRTUAL_PATH = __webpack_exports__.WORKDIR_VIRTUAL_PATH;
|
|
@@ -823,8 +807,10 @@ exports.chunkHasAssistantText = __webpack_exports__.chunkHasAssistantText;
|
|
|
823
807
|
exports.configureDeepAgentSummarizationMiddleware = __webpack_exports__.configureDeepAgentSummarizationMiddleware;
|
|
824
808
|
exports.detectStreamErrorMessage = __webpack_exports__.detectStreamErrorMessage;
|
|
825
809
|
exports.detectToolEventContext = __webpack_exports__.detectToolEventContext;
|
|
826
|
-
exports.
|
|
810
|
+
exports.emitCompletionAndContinuePostProcessing = __webpack_exports__.emitCompletionAndContinuePostProcessing;
|
|
827
811
|
exports.isRootLangGraphTerminalEvent = __webpack_exports__.isRootLangGraphTerminalEvent;
|
|
812
|
+
exports.resolveAgentExecutionWorkspace = __webpack_exports__.resolveAgentExecutionWorkspace;
|
|
813
|
+
exports.resolveAgentMemorySources = __webpack_exports__.resolveAgentMemorySources;
|
|
828
814
|
exports.resolveExecutionWorkspace = __webpack_exports__.resolveExecutionWorkspace;
|
|
829
815
|
exports.resolveExternalOutputMount = __webpack_exports__.resolveExternalOutputMount;
|
|
830
816
|
exports.resolveHumanInTheLoopSettings = __webpack_exports__.resolveHumanInTheLoopSettings;
|
|
@@ -835,6 +821,7 @@ exports.selectStreamingFallbackText = __webpack_exports__.selectStreamingFallbac
|
|
|
835
821
|
exports.toWorkspaceAliasVirtualPath = __webpack_exports__.toWorkspaceAliasVirtualPath;
|
|
836
822
|
exports.trackRootLangGraphRunId = __webpack_exports__.trackRootLangGraphRunId;
|
|
837
823
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
824
|
+
"AGENTS_MEMORY_VIRTUAL_PATHS",
|
|
838
825
|
"AgentInvoker",
|
|
839
826
|
"OUTPUT_VIRTUAL_PATH",
|
|
840
827
|
"WORKDIR_VIRTUAL_PATH",
|
|
@@ -843,8 +830,10 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
843
830
|
"configureDeepAgentSummarizationMiddleware",
|
|
844
831
|
"detectStreamErrorMessage",
|
|
845
832
|
"detectToolEventContext",
|
|
846
|
-
"
|
|
833
|
+
"emitCompletionAndContinuePostProcessing",
|
|
847
834
|
"isRootLangGraphTerminalEvent",
|
|
835
|
+
"resolveAgentExecutionWorkspace",
|
|
836
|
+
"resolveAgentMemorySources",
|
|
848
837
|
"resolveExecutionWorkspace",
|
|
849
838
|
"resolveExternalOutputMount",
|
|
850
839
|
"resolveHumanInTheLoopSettings",
|
|
@@ -78,6 +78,7 @@ type UserContentPart = {
|
|
|
78
78
|
};
|
|
79
79
|
export declare const WORKDIR_VIRTUAL_PATH = "/workdir/";
|
|
80
80
|
export declare const OUTPUT_VIRTUAL_PATH = "/output/";
|
|
81
|
+
export declare const AGENTS_MEMORY_VIRTUAL_PATHS: readonly ["/AGENTS.md"];
|
|
81
82
|
export type ExternalOutputMount = {
|
|
82
83
|
virtualPath: string | null;
|
|
83
84
|
absolutePath: string | null;
|
|
@@ -105,6 +106,8 @@ export type HumanInTheLoopSettings = {
|
|
|
105
106
|
}>;
|
|
106
107
|
};
|
|
107
108
|
export declare const resolveExecutionWorkspace: (workspace: string, workdir?: string | null) => string;
|
|
109
|
+
export declare const resolveAgentExecutionWorkspace: (workspace: string, workdir?: string | null, defaultOutputDir?: string | null) => string;
|
|
110
|
+
export declare const resolveAgentMemorySources: (executionWorkspace: string) => string[];
|
|
108
111
|
export declare const toWorkspaceAliasVirtualPath: (absolutePath: string) => string | null;
|
|
109
112
|
export declare const resolveExternalOutputMount: (workspace: string, workdir?: string | null, defaultOutputDir?: string | null) => ExternalOutputMount;
|
|
110
113
|
export declare const resolveSummarizationMiddlewareSettings: (config: WingmanConfigType) => SummarizationMiddlewareSettings | null;
|
|
@@ -128,19 +131,12 @@ export declare const selectStreamingFallbackText: (previousMessages: Array<{
|
|
|
128
131
|
export declare const detectStreamErrorMessage: (chunk: unknown) => string | undefined;
|
|
129
132
|
export declare const trackRootLangGraphRunId: (currentRootLangGraphRunId: string | undefined, chunk: unknown) => string | undefined;
|
|
130
133
|
export declare const isRootLangGraphTerminalEvent: (chunk: unknown, rootLangGraphRunId?: string) => boolean;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
};
|
|
138
|
-
type EvaluateStreamingCompletionInput = {
|
|
139
|
-
sawAssistantText: boolean;
|
|
140
|
-
fallbackText?: string;
|
|
141
|
-
streamErrorMessage?: string;
|
|
142
|
-
};
|
|
143
|
-
export declare const evaluateStreamingCompletion: (input: EvaluateStreamingCompletionInput) => StreamingCompletionOutcome;
|
|
134
|
+
export declare const emitCompletionAndContinuePostProcessing: (input: {
|
|
135
|
+
outputManager: Pick<OutputManager, "emitAgentComplete">;
|
|
136
|
+
result: unknown;
|
|
137
|
+
postProcess?: () => Promise<void>;
|
|
138
|
+
logger?: Pick<Logger, "debug">;
|
|
139
|
+
}) => void;
|
|
144
140
|
export declare class AgentInvoker {
|
|
145
141
|
private loader;
|
|
146
142
|
private outputManager;
|
|
@@ -170,6 +166,7 @@ export declare class AgentInvoker {
|
|
|
170
166
|
name: string;
|
|
171
167
|
description: string;
|
|
172
168
|
}>;
|
|
169
|
+
private materializeSessionImages;
|
|
173
170
|
}
|
|
174
171
|
export declare function buildUserContent(prompt: string, attachments?: MediaAttachment[], model?: unknown): string | UserContentPart[];
|
|
175
172
|
export {};
|