@wingman-ai/gateway 0.2.2 → 0.2.4
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/README.md +7 -1
- package/.wingman/agents/coding/agent.md +299 -201
- package/.wingman/agents/coding-v2/agent.md +127 -0
- package/.wingman/agents/coding-v2/implementor.md +89 -0
- package/.wingman/agents/main/agent.md +4 -0
- package/README.md +1 -0
- package/dist/agent/config/agentConfig.cjs +31 -17
- package/dist/agent/config/agentConfig.d.ts +23 -1
- package/dist/agent/config/agentConfig.js +30 -19
- package/dist/agent/config/agentLoader.cjs +26 -8
- package/dist/agent/config/agentLoader.d.ts +4 -2
- package/dist/agent/config/agentLoader.js +26 -8
- package/dist/agent/config/modelFactory.cjs +95 -25
- package/dist/agent/config/modelFactory.d.ts +13 -1
- package/dist/agent/config/modelFactory.js +95 -25
- package/dist/agent/config/toolRegistry.cjs +19 -6
- package/dist/agent/config/toolRegistry.d.ts +5 -2
- package/dist/agent/config/toolRegistry.js +19 -6
- package/dist/agent/middleware/hooks/types.cjs +13 -13
- package/dist/agent/middleware/hooks/types.d.ts +1 -1
- package/dist/agent/middleware/hooks/types.js +14 -14
- package/dist/agent/tests/agentConfig.test.cjs +22 -2
- package/dist/agent/tests/agentConfig.test.js +22 -2
- package/dist/agent/tests/agentLoader.test.cjs +38 -1
- package/dist/agent/tests/agentLoader.test.js +38 -1
- package/dist/agent/tests/backgroundTerminal.test.cjs +70 -0
- package/dist/agent/tests/backgroundTerminal.test.d.ts +1 -0
- package/dist/agent/tests/backgroundTerminal.test.js +64 -0
- package/dist/agent/tests/commandExecuteTool.test.cjs +29 -0
- package/dist/agent/tests/commandExecuteTool.test.d.ts +1 -0
- package/dist/agent/tests/commandExecuteTool.test.js +23 -0
- package/dist/agent/tests/modelFactory.test.cjs +47 -5
- package/dist/agent/tests/modelFactory.test.js +47 -5
- package/dist/agent/tests/terminalSessionManager.test.cjs +121 -0
- package/dist/agent/tests/terminalSessionManager.test.d.ts +1 -0
- package/dist/agent/tests/terminalSessionManager.test.js +115 -0
- package/dist/agent/tests/toolRegistry.test.cjs +14 -2
- package/dist/agent/tests/toolRegistry.test.js +14 -2
- package/dist/agent/tools/background_terminal.cjs +128 -0
- package/dist/agent/tools/background_terminal.d.ts +41 -0
- package/dist/agent/tools/background_terminal.js +94 -0
- package/dist/agent/tools/code_search.cjs +6 -6
- package/dist/agent/tools/code_search.d.ts +1 -1
- package/dist/agent/tools/code_search.js +7 -7
- package/dist/agent/tools/command_execute.cjs +22 -7
- package/dist/agent/tools/command_execute.d.ts +3 -2
- package/dist/agent/tools/command_execute.js +23 -8
- package/dist/agent/tools/git_status.cjs +3 -3
- package/dist/agent/tools/git_status.d.ts +1 -1
- package/dist/agent/tools/git_status.js +4 -4
- package/dist/agent/tools/internet_search.cjs +6 -6
- package/dist/agent/tools/internet_search.d.ts +1 -1
- package/dist/agent/tools/internet_search.js +7 -7
- package/dist/agent/tools/terminal_session_manager.cjs +321 -0
- package/dist/agent/tools/terminal_session_manager.d.ts +77 -0
- package/dist/agent/tools/terminal_session_manager.js +284 -0
- package/dist/agent/tools/think.cjs +4 -4
- package/dist/agent/tools/think.d.ts +1 -1
- package/dist/agent/tools/think.js +5 -5
- package/dist/agent/tools/ui_registry.cjs +13 -13
- package/dist/agent/tools/ui_registry.d.ts +4 -4
- package/dist/agent/tools/ui_registry.js +14 -14
- package/dist/agent/tools/web_crawler.cjs +4 -4
- package/dist/agent/tools/web_crawler.d.ts +1 -1
- package/dist/agent/tools/web_crawler.js +5 -5
- package/dist/agent/utils.cjs +2 -1
- package/dist/agent/utils.js +2 -1
- package/dist/cli/commands/init.cjs +7 -6
- package/dist/cli/commands/init.js +7 -6
- package/dist/cli/commands/provider.cjs +17 -3
- package/dist/cli/commands/provider.js +17 -3
- package/dist/cli/config/loader.cjs +27 -0
- package/dist/cli/config/loader.js +27 -0
- package/dist/cli/config/schema.cjs +146 -68
- package/dist/cli/config/schema.d.ts +89 -1
- package/dist/cli/config/schema.js +134 -68
- package/dist/cli/core/agentInvoker.cjs +344 -17
- package/dist/cli/core/agentInvoker.d.ts +63 -3
- package/dist/cli/core/agentInvoker.js +303 -12
- package/dist/cli/core/sessionManager.cjs +32 -5
- package/dist/cli/core/sessionManager.js +32 -5
- package/dist/cli/core/streamParser.cjs +15 -0
- package/dist/cli/core/streamParser.js +15 -0
- package/dist/cli/index.cjs +6 -5
- package/dist/cli/index.js +6 -5
- package/dist/cli/types.d.ts +32 -0
- package/dist/cli/ui/toolDisplayHelpers.cjs +2 -0
- package/dist/cli/ui/toolDisplayHelpers.js +2 -0
- package/dist/gateway/hooks/registry.cjs +2 -1
- package/dist/gateway/hooks/registry.d.ts +1 -1
- package/dist/gateway/hooks/registry.js +2 -1
- package/dist/gateway/hooks/types.cjs +11 -11
- package/dist/gateway/hooks/types.d.ts +1 -1
- package/dist/gateway/hooks/types.js +12 -12
- package/dist/gateway/http/agents.cjs +67 -4
- package/dist/gateway/http/agents.js +67 -4
- package/dist/gateway/http/sessions.cjs +7 -7
- package/dist/gateway/http/sessions.js +7 -7
- package/dist/gateway/http/types.d.ts +5 -3
- package/dist/gateway/http/webhooks.cjs +6 -5
- package/dist/gateway/http/webhooks.js +6 -5
- package/dist/gateway/server.cjs +198 -41
- package/dist/gateway/server.d.ts +9 -1
- package/dist/gateway/server.js +198 -41
- package/dist/gateway/types.d.ts +1 -0
- package/dist/gateway/validation.cjs +39 -39
- package/dist/gateway/validation.d.ts +1 -1
- package/dist/gateway/validation.js +40 -40
- package/dist/providers/codex.cjs +167 -0
- package/dist/providers/codex.d.ts +15 -0
- package/dist/providers/codex.js +127 -0
- package/dist/providers/credentials.cjs +8 -0
- package/dist/providers/credentials.js +8 -0
- package/dist/providers/registry.cjs +11 -0
- package/dist/providers/registry.d.ts +1 -1
- package/dist/providers/registry.js +11 -0
- package/dist/tests/additionalMessageMiddleware.test.cjs +3 -0
- package/dist/tests/additionalMessageMiddleware.test.js +3 -0
- package/dist/tests/agentInvokerSummarization.test.cjs +455 -0
- package/dist/tests/agentInvokerSummarization.test.d.ts +1 -0
- package/dist/tests/agentInvokerSummarization.test.js +449 -0
- package/dist/tests/agents-api.test.cjs +45 -5
- package/dist/tests/agents-api.test.js +45 -5
- package/dist/tests/cli-config-loader.test.cjs +88 -0
- package/dist/tests/cli-config-loader.test.js +88 -0
- package/dist/tests/cli-init.test.cjs +27 -3
- package/dist/tests/cli-init.test.js +27 -3
- package/dist/tests/codex-credentials-precedence.test.cjs +94 -0
- package/dist/tests/codex-credentials-precedence.test.d.ts +1 -0
- package/dist/tests/codex-credentials-precedence.test.js +88 -0
- package/dist/tests/codex-provider.test.cjs +210 -0
- package/dist/tests/codex-provider.test.d.ts +1 -0
- package/dist/tests/codex-provider.test.js +204 -0
- package/dist/tests/gateway.test.cjs +115 -8
- package/dist/tests/gateway.test.js +115 -8
- package/dist/tests/provider-command-codex.test.cjs +57 -0
- package/dist/tests/provider-command-codex.test.d.ts +1 -0
- package/dist/tests/provider-command-codex.test.js +51 -0
- package/dist/tests/sessionStateMessages.test.cjs +38 -0
- package/dist/tests/sessionStateMessages.test.js +38 -0
- package/dist/tests/toolDisplayHelpers.test.cjs +3 -0
- package/dist/tests/toolDisplayHelpers.test.js +3 -0
- package/dist/tools/mcp-finance.cjs +48 -48
- package/dist/tools/mcp-finance.js +48 -48
- package/dist/types/mcp.cjs +15 -15
- package/dist/types/mcp.d.ts +1 -1
- package/dist/types/mcp.js +16 -16
- package/dist/types/voice.cjs +21 -21
- package/dist/types/voice.d.ts +1 -1
- package/dist/types/voice.js +22 -22
- package/dist/webui/assets/index-DVWQluit.css +11 -0
- package/dist/webui/assets/index-Dlyzwalc.js +270 -0
- package/dist/webui/favicon-32x32.png +0 -0
- package/dist/webui/favicon-64x64.png +0 -0
- package/dist/webui/favicon.webp +0 -0
- package/dist/webui/index.html +4 -2
- package/package.json +13 -12
- package/.wingman/agents/coding/implementor.md +0 -79
- package/dist/webui/assets/index-CPhfGPHc.js +0 -182
- package/dist/webui/assets/index-DDsMIOTX.css +0 -11
|
@@ -24,26 +24,40 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
resolveToolRetryMiddlewareSettings: ()=>resolveToolRetryMiddlewareSettings,
|
|
28
|
+
resolveSummarizationMiddlewareSettings: ()=>resolveSummarizationMiddlewareSettings,
|
|
29
29
|
OUTPUT_VIRTUAL_PATH: ()=>OUTPUT_VIRTUAL_PATH,
|
|
30
|
-
|
|
31
|
-
AgentInvoker: ()=>AgentInvoker,
|
|
30
|
+
resolveExecutionWorkspace: ()=>resolveExecutionWorkspace,
|
|
32
31
|
buildUserContent: ()=>buildUserContent,
|
|
33
|
-
|
|
32
|
+
detectStreamErrorMessage: ()=>detectStreamErrorMessage,
|
|
33
|
+
toWorkspaceAliasVirtualPath: ()=>toWorkspaceAliasVirtualPath,
|
|
34
|
+
chunkHasAssistantText: ()=>chunkHasAssistantText,
|
|
35
|
+
resolveModelRetryMiddlewareSettings: ()=>resolveModelRetryMiddlewareSettings,
|
|
36
|
+
AgentInvoker: ()=>AgentInvoker,
|
|
37
|
+
WORKDIR_VIRTUAL_PATH: ()=>WORKDIR_VIRTUAL_PATH,
|
|
38
|
+
configureDeepAgentSummarizationMiddleware: ()=>configureDeepAgentSummarizationMiddleware,
|
|
39
|
+
detectToolEventContext: ()=>detectToolEventContext,
|
|
40
|
+
resolveExternalOutputMount: ()=>resolveExternalOutputMount,
|
|
41
|
+
evaluateStreamingCompletion: ()=>evaluateStreamingCompletion,
|
|
42
|
+
resolveHumanInTheLoopSettings: ()=>resolveHumanInTheLoopSettings,
|
|
43
|
+
trackRootLangGraphRunId: ()=>trackRootLangGraphRunId,
|
|
44
|
+
isRootLangGraphTerminalEvent: ()=>isRootLangGraphTerminalEvent,
|
|
45
|
+
selectStreamingFallbackText: ()=>selectStreamingFallbackText
|
|
34
46
|
});
|
|
35
|
-
const external_deepagents_namespaceObject = require("deepagents");
|
|
36
47
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
37
48
|
const external_node_path_namespaceObject = require("node:path");
|
|
49
|
+
const external_deepagents_namespaceObject = require("deepagents");
|
|
50
|
+
const external_langchain_namespaceObject = require("langchain");
|
|
38
51
|
const external_uuid_namespaceObject = require("uuid");
|
|
39
|
-
const
|
|
40
|
-
const loader_cjs_namespaceObject = require("../config/loader.cjs");
|
|
52
|
+
const mcpClientManager_cjs_namespaceObject = require("../../agent/config/mcpClientManager.cjs");
|
|
41
53
|
const additional_messages_cjs_namespaceObject = require("../../agent/middleware/additional-messages.cjs");
|
|
42
|
-
const hooks_cjs_namespaceObject = require("../../agent/middleware/hooks.cjs");
|
|
43
54
|
const merger_cjs_namespaceObject = require("../../agent/middleware/hooks/merger.cjs");
|
|
55
|
+
const hooks_cjs_namespaceObject = require("../../agent/middleware/hooks.cjs");
|
|
44
56
|
const media_compat_cjs_namespaceObject = require("../../agent/middleware/media-compat.cjs");
|
|
45
|
-
const
|
|
57
|
+
const terminal_session_manager_cjs_namespaceObject = require("../../agent/tools/terminal_session_manager.cjs");
|
|
46
58
|
const uiRegistry_cjs_namespaceObject = require("../../agent/uiRegistry.cjs");
|
|
59
|
+
const agentLoader_cjs_namespaceObject = require("../../agent/config/agentLoader.cjs");
|
|
60
|
+
const loader_cjs_namespaceObject = require("../config/loader.cjs");
|
|
47
61
|
function _define_property(obj, key, value) {
|
|
48
62
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
49
63
|
value: value,
|
|
@@ -56,6 +70,7 @@ function _define_property(obj, key, value) {
|
|
|
56
70
|
}
|
|
57
71
|
const WORKDIR_VIRTUAL_PATH = "/workdir/";
|
|
58
72
|
const OUTPUT_VIRTUAL_PATH = "/output/";
|
|
73
|
+
const DEFAULT_DEEPAGENT_MODEL = "claude-sonnet-4-5-20250929";
|
|
59
74
|
const isPathWithinRoot = (targetPath, rootPath)=>{
|
|
60
75
|
const normalizedTarget = (0, external_node_path_namespaceObject.normalize)(targetPath);
|
|
61
76
|
const normalizedRoot = (0, external_node_path_namespaceObject.normalize)(rootPath);
|
|
@@ -88,6 +103,206 @@ const resolveExternalOutputMount = (workspace, workdir, defaultOutputDir)=>{
|
|
|
88
103
|
absolutePath: null
|
|
89
104
|
};
|
|
90
105
|
};
|
|
106
|
+
const resolveSummarizationMiddlewareSettings = (config)=>{
|
|
107
|
+
if (!config.summarization?.enabled) return null;
|
|
108
|
+
return {
|
|
109
|
+
maxTokensBeforeSummary: config.summarization.maxTokensBeforeSummary,
|
|
110
|
+
messagesToKeep: config.summarization.messagesToKeep
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
const resolveModelRetryMiddlewareSettings = (config)=>{
|
|
114
|
+
if (!config.modelRetry?.enabled) return null;
|
|
115
|
+
return {
|
|
116
|
+
maxRetries: config.modelRetry.maxRetries,
|
|
117
|
+
backoffFactor: config.modelRetry.backoffFactor,
|
|
118
|
+
initialDelayMs: config.modelRetry.initialDelayMs,
|
|
119
|
+
maxDelayMs: config.modelRetry.maxDelayMs,
|
|
120
|
+
jitter: config.modelRetry.jitter,
|
|
121
|
+
onFailure: config.modelRetry.onFailure
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
const resolveToolRetryMiddlewareSettings = (config)=>{
|
|
125
|
+
if (!config.toolRetry?.enabled) return null;
|
|
126
|
+
return {
|
|
127
|
+
maxRetries: config.toolRetry.maxRetries,
|
|
128
|
+
backoffFactor: config.toolRetry.backoffFactor,
|
|
129
|
+
initialDelayMs: config.toolRetry.initialDelayMs,
|
|
130
|
+
maxDelayMs: config.toolRetry.maxDelayMs,
|
|
131
|
+
jitter: config.toolRetry.jitter,
|
|
132
|
+
onFailure: config.toolRetry.onFailure,
|
|
133
|
+
...config.toolRetry.tools && config.toolRetry.tools.length > 0 ? {
|
|
134
|
+
tools: config.toolRetry.tools
|
|
135
|
+
} : {}
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
const resolveHumanInTheLoopSettings = (config)=>{
|
|
139
|
+
if (!config.humanInTheLoop?.enabled) return null;
|
|
140
|
+
const interruptOn = config.humanInTheLoop.interruptOn || {};
|
|
141
|
+
if (0 === Object.keys(interruptOn).length) return null;
|
|
142
|
+
return {
|
|
143
|
+
interruptOn
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
const configureDeepAgentSummarizationMiddleware = (agent, settings, model)=>{
|
|
147
|
+
const middleware = agent?.options?.middleware;
|
|
148
|
+
if (!Array.isArray(middleware)) return;
|
|
149
|
+
const index = middleware.findIndex((entry)=>entry?.name === "SummarizationMiddleware");
|
|
150
|
+
if (index < 0) return;
|
|
151
|
+
if (!settings) return void middleware.splice(index, 1);
|
|
152
|
+
middleware[index] = (0, external_langchain_namespaceObject.summarizationMiddleware)({
|
|
153
|
+
model: model || DEFAULT_DEEPAGENT_MODEL,
|
|
154
|
+
trigger: {
|
|
155
|
+
tokens: settings.maxTokensBeforeSummary
|
|
156
|
+
},
|
|
157
|
+
keep: {
|
|
158
|
+
messages: settings.messagesToKeep
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
const detectToolEventContext = (chunk)=>{
|
|
163
|
+
if (!chunk || "object" != typeof chunk || Array.isArray(chunk)) return null;
|
|
164
|
+
const eventChunk = chunk;
|
|
165
|
+
if ("on_tool_start" !== eventChunk.event && "on_tool_end" !== eventChunk.event && "on_tool_error" !== eventChunk.event) return null;
|
|
166
|
+
const toolName = "string" == typeof eventChunk.name && eventChunk.name.trim() ? eventChunk.name.trim() : "unknown";
|
|
167
|
+
return {
|
|
168
|
+
event: eventChunk.event,
|
|
169
|
+
toolName
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
const chunkHasAssistantText = (chunk)=>{
|
|
173
|
+
if (!chunk || "object" != typeof chunk || Array.isArray(chunk)) return false;
|
|
174
|
+
const eventChunk = chunk;
|
|
175
|
+
const eventName = "string" == typeof eventChunk.event ? eventChunk.event : void 0;
|
|
176
|
+
if ("on_chat_model_stream" === eventName) {
|
|
177
|
+
const data = eventChunk.data && "object" == typeof eventChunk.data ? eventChunk.data : null;
|
|
178
|
+
const messageChunk = data?.chunk || data?.message;
|
|
179
|
+
const content = messageChunk?.content;
|
|
180
|
+
if ("string" == typeof content) return content.length > 0;
|
|
181
|
+
if (Array.isArray(content)) return content.some((part)=>part && "object" == typeof part && "text" === part.type && "string" == typeof part.text && part.text.length > 0);
|
|
182
|
+
}
|
|
183
|
+
if ("on_llm_stream" === eventName) {
|
|
184
|
+
const data = eventChunk.data && "object" == typeof eventChunk.data ? eventChunk.data : null;
|
|
185
|
+
const llmChunk = data?.chunk && "object" == typeof data.chunk ? data.chunk : null;
|
|
186
|
+
return "string" == typeof llmChunk?.text && llmChunk.text.length > 0;
|
|
187
|
+
}
|
|
188
|
+
return false;
|
|
189
|
+
};
|
|
190
|
+
const selectStreamingFallbackText = (previousMessages, currentMessages)=>{
|
|
191
|
+
if (0 === currentMessages.length) return;
|
|
192
|
+
const previousAssistantCounts = new Map();
|
|
193
|
+
for (const message of previousMessages){
|
|
194
|
+
if (!message || "object" != typeof message) continue;
|
|
195
|
+
if ("assistant" !== message.role) continue;
|
|
196
|
+
if ("string" != typeof message.content) continue;
|
|
197
|
+
const content = message.content.trim();
|
|
198
|
+
if (content) previousAssistantCounts.set(content, (previousAssistantCounts.get(content) || 0) + 1);
|
|
199
|
+
}
|
|
200
|
+
let fallback;
|
|
201
|
+
for (const message of currentMessages){
|
|
202
|
+
if (!message || "object" != typeof message) continue;
|
|
203
|
+
if ("assistant" !== message.role) continue;
|
|
204
|
+
if ("string" != typeof message.content) continue;
|
|
205
|
+
const content = message.content.trim();
|
|
206
|
+
if (!content) continue;
|
|
207
|
+
const remaining = previousAssistantCounts.get(content) || 0;
|
|
208
|
+
if (remaining > 0) {
|
|
209
|
+
previousAssistantCounts.set(content, remaining - 1);
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
fallback = content;
|
|
213
|
+
}
|
|
214
|
+
return fallback;
|
|
215
|
+
};
|
|
216
|
+
const detectStreamErrorMessage = (chunk)=>{
|
|
217
|
+
if (!chunk || "object" != typeof chunk || Array.isArray(chunk)) return;
|
|
218
|
+
const eventChunk = chunk;
|
|
219
|
+
const eventName = "string" == typeof eventChunk.event ? eventChunk.event : void 0;
|
|
220
|
+
if (!eventName || !eventName.endsWith("_error")) return;
|
|
221
|
+
if ("on_tool_error" === eventName) return;
|
|
222
|
+
const data = eventChunk.data && "object" == typeof eventChunk.data ? eventChunk.data : null;
|
|
223
|
+
const errorPayload = data?.error || eventChunk.error || data?.output || data?.chunk;
|
|
224
|
+
if ("string" == typeof errorPayload && errorPayload.trim()) return errorPayload.trim();
|
|
225
|
+
if (errorPayload && "object" == typeof errorPayload) {
|
|
226
|
+
const record = errorPayload;
|
|
227
|
+
if ("string" == typeof record.message && record.message.trim()) return record.message.trim();
|
|
228
|
+
if ("string" == typeof record.error && record.error.trim()) return record.error.trim();
|
|
229
|
+
}
|
|
230
|
+
if (null != errorPayload) return String(errorPayload);
|
|
231
|
+
return eventName;
|
|
232
|
+
};
|
|
233
|
+
const extractStreamEventRecord = (chunk)=>{
|
|
234
|
+
if (!chunk || "object" != typeof chunk || Array.isArray(chunk)) return null;
|
|
235
|
+
const record = chunk;
|
|
236
|
+
return "string" == typeof record.event ? record : null;
|
|
237
|
+
};
|
|
238
|
+
const normalizeEventName = (value)=>{
|
|
239
|
+
if ("string" != typeof value) return;
|
|
240
|
+
const normalized = value.trim();
|
|
241
|
+
return normalized.length > 0 ? normalized.toLowerCase() : void 0;
|
|
242
|
+
};
|
|
243
|
+
const normalizeEventParentRunIds = (value)=>{
|
|
244
|
+
if (Array.isArray(value)) return value.filter((item)=>"string" == typeof item).map((item)=>item.trim()).filter(Boolean);
|
|
245
|
+
if ("string" == typeof value && value.trim()) return [
|
|
246
|
+
value.trim()
|
|
247
|
+
];
|
|
248
|
+
return [];
|
|
249
|
+
};
|
|
250
|
+
const extractEventParentRunIds = (eventRecord)=>{
|
|
251
|
+
const parentCandidates = [
|
|
252
|
+
eventRecord.parent_ids,
|
|
253
|
+
eventRecord.parentIds,
|
|
254
|
+
eventRecord.metadata?.parent_ids,
|
|
255
|
+
eventRecord.metadata?.parentIds,
|
|
256
|
+
eventRecord.data?.parent_ids,
|
|
257
|
+
eventRecord.data?.parentIds
|
|
258
|
+
];
|
|
259
|
+
for (const candidate of parentCandidates){
|
|
260
|
+
const parentIds = normalizeEventParentRunIds(candidate);
|
|
261
|
+
if (parentIds.length > 0) return parentIds;
|
|
262
|
+
}
|
|
263
|
+
return [];
|
|
264
|
+
};
|
|
265
|
+
const extractEventRunId = (eventRecord)=>{
|
|
266
|
+
const runCandidates = [
|
|
267
|
+
eventRecord.run_id,
|
|
268
|
+
eventRecord.runId,
|
|
269
|
+
eventRecord.data?.run_id,
|
|
270
|
+
eventRecord.data?.runId
|
|
271
|
+
];
|
|
272
|
+
for (const candidate of runCandidates)if ("string" == typeof candidate && candidate.trim()) return candidate.trim();
|
|
273
|
+
};
|
|
274
|
+
const isRootLangGraphChainEvent = (eventRecord, eventType)=>{
|
|
275
|
+
if (eventRecord.event !== eventType) return false;
|
|
276
|
+
const eventName = normalizeEventName(eventRecord.name);
|
|
277
|
+
if ("langgraph" !== eventName) return false;
|
|
278
|
+
return 0 === extractEventParentRunIds(eventRecord).length;
|
|
279
|
+
};
|
|
280
|
+
const trackRootLangGraphRunId = (currentRootLangGraphRunId, chunk)=>{
|
|
281
|
+
if (currentRootLangGraphRunId) return currentRootLangGraphRunId;
|
|
282
|
+
const eventRecord = extractStreamEventRecord(chunk);
|
|
283
|
+
if (!eventRecord || !isRootLangGraphChainEvent(eventRecord, "on_chain_start")) return currentRootLangGraphRunId;
|
|
284
|
+
return extractEventRunId(eventRecord) || currentRootLangGraphRunId;
|
|
285
|
+
};
|
|
286
|
+
const isRootLangGraphTerminalEvent = (chunk, rootLangGraphRunId)=>{
|
|
287
|
+
if (!rootLangGraphRunId) return false;
|
|
288
|
+
const eventRecord = extractStreamEventRecord(chunk);
|
|
289
|
+
if (!eventRecord || !isRootLangGraphChainEvent(eventRecord, "on_chain_end")) return false;
|
|
290
|
+
const chunkRunId = extractEventRunId(eventRecord);
|
|
291
|
+
return Boolean(chunkRunId && chunkRunId === rootLangGraphRunId);
|
|
292
|
+
};
|
|
293
|
+
const evaluateStreamingCompletion = (input)=>{
|
|
294
|
+
if (!input.sawAssistantText && !input.fallbackText) {
|
|
295
|
+
const message = input.streamErrorMessage ? `Model call failed: ${input.streamErrorMessage}` : "Model completed without a response. Check provider logs for request errors.";
|
|
296
|
+
return {
|
|
297
|
+
status: "blocked",
|
|
298
|
+
reason: input.streamErrorMessage ? "stream_error" : "empty_stream_response",
|
|
299
|
+
message
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
return {
|
|
303
|
+
status: "ok"
|
|
304
|
+
};
|
|
305
|
+
};
|
|
91
306
|
class AgentInvoker {
|
|
92
307
|
findAllAgents() {
|
|
93
308
|
const agentConfigs = this.loader.loadAllAgentConfigs();
|
|
@@ -98,11 +313,21 @@ class AgentInvoker {
|
|
|
98
313
|
}
|
|
99
314
|
async invokeAgent(agentName, prompt, sessionId, attachments, options) {
|
|
100
315
|
let cancellationHandled = false;
|
|
316
|
+
let activeToolName = null;
|
|
317
|
+
let lastToolName = null;
|
|
318
|
+
let sawAssistantText = false;
|
|
319
|
+
let streamErrorMessage;
|
|
320
|
+
let rootLangGraphRunId;
|
|
321
|
+
let preInvocationMessages = null;
|
|
101
322
|
const isCancelled = ()=>options?.signal?.aborted === true;
|
|
102
323
|
try {
|
|
324
|
+
const hookSessionId = sessionId || (0, external_uuid_namespaceObject.v4)();
|
|
103
325
|
const executionWorkspace = resolveExecutionWorkspace(this.workspace, this.workdir);
|
|
104
326
|
const effectiveWorkdir = this.workdir ? executionWorkspace : null;
|
|
105
|
-
const loader =
|
|
327
|
+
const loader = new agentLoader_cjs_namespaceObject.AgentLoader(this.configDir, this.workspace, this.wingmanConfig, executionWorkspace, {
|
|
328
|
+
terminalOwnerId: `${agentName}:${hookSessionId}`,
|
|
329
|
+
terminalSessionManager: this.terminalSessionManager
|
|
330
|
+
});
|
|
106
331
|
const targetAgent = await loader.loadAgent(agentName);
|
|
107
332
|
if (!targetAgent) throw new Error(`Agent "${agentName}" not found`);
|
|
108
333
|
this.logger.info(`Invoking agent: ${agentName}`);
|
|
@@ -111,7 +336,6 @@ class AgentInvoker {
|
|
|
111
336
|
this.logger.debug(`Found ${this.wingmanConfig.toolHooks ? "global hooks" : "no global hooks"}`);
|
|
112
337
|
this.logger.debug(`Found ${targetAgent.toolHooks ? "agent-specific hooks" : "no agent-specific hooks"}`);
|
|
113
338
|
const mergedHooks = (0, merger_cjs_namespaceObject.mergeHooks)(this.wingmanConfig.toolHooks, targetAgent.toolHooks);
|
|
114
|
-
const hookSessionId = sessionId || (0, external_uuid_namespaceObject.v4)();
|
|
115
339
|
const mcpConfigs = [];
|
|
116
340
|
if (targetAgent.mcpConfig) mcpConfigs.push(targetAgent.mcpConfig);
|
|
117
341
|
if (targetAgent.mcpUseGlobal && this.wingmanConfig.mcp) mcpConfigs.push(this.wingmanConfig.mcp);
|
|
@@ -147,6 +371,29 @@ class AgentInvoker {
|
|
|
147
371
|
skillsDirectory
|
|
148
372
|
})
|
|
149
373
|
];
|
|
374
|
+
const summarizationSettings = resolveSummarizationMiddlewareSettings(this.wingmanConfig);
|
|
375
|
+
const modelRetrySettings = resolveModelRetryMiddlewareSettings(this.wingmanConfig);
|
|
376
|
+
if (modelRetrySettings) middleware.push((0, external_langchain_namespaceObject.modelRetryMiddleware)({
|
|
377
|
+
maxRetries: modelRetrySettings.maxRetries,
|
|
378
|
+
backoffFactor: modelRetrySettings.backoffFactor,
|
|
379
|
+
initialDelayMs: modelRetrySettings.initialDelayMs,
|
|
380
|
+
maxDelayMs: modelRetrySettings.maxDelayMs,
|
|
381
|
+
jitter: modelRetrySettings.jitter,
|
|
382
|
+
onFailure: modelRetrySettings.onFailure
|
|
383
|
+
}));
|
|
384
|
+
const toolRetrySettings = resolveToolRetryMiddlewareSettings(this.wingmanConfig);
|
|
385
|
+
if (toolRetrySettings) middleware.push((0, external_langchain_namespaceObject.toolRetryMiddleware)({
|
|
386
|
+
maxRetries: toolRetrySettings.maxRetries,
|
|
387
|
+
backoffFactor: toolRetrySettings.backoffFactor,
|
|
388
|
+
initialDelayMs: toolRetrySettings.initialDelayMs,
|
|
389
|
+
maxDelayMs: toolRetrySettings.maxDelayMs,
|
|
390
|
+
jitter: toolRetrySettings.jitter,
|
|
391
|
+
onFailure: toolRetrySettings.onFailure,
|
|
392
|
+
...toolRetrySettings.tools ? {
|
|
393
|
+
tools: toolRetrySettings.tools
|
|
394
|
+
} : {}
|
|
395
|
+
}));
|
|
396
|
+
const hitlSettings = resolveHumanInTheLoopSettings(this.wingmanConfig);
|
|
150
397
|
if (mergedHooks) {
|
|
151
398
|
this.logger.debug(`Adding hooks middleware with ${mergedHooks.PreToolUse?.length || 0} PreToolUse hooks, ${mergedHooks.PostToolUse?.length || 0} PostToolUse hooks, and ${mergedHooks.Stop?.length || 0} Stop hooks`);
|
|
152
399
|
middleware.push((0, hooks_cjs_namespaceObject.createHooksMiddleware)(mergedHooks, executionWorkspace, hookSessionId, this.logger));
|
|
@@ -193,14 +440,25 @@ class AgentInvoker {
|
|
|
193
440
|
virtualMode: true
|
|
194
441
|
}), backendOverrides),
|
|
195
442
|
middleware: middleware,
|
|
443
|
+
interruptOn: hitlSettings?.interruptOn,
|
|
196
444
|
skills: skillsSources,
|
|
197
445
|
subagents: targetAgent.subagents || [],
|
|
198
446
|
checkpointer: checkpointer
|
|
199
447
|
});
|
|
448
|
+
configureDeepAgentSummarizationMiddleware(standaloneAgent, summarizationSettings, targetAgent.model);
|
|
200
449
|
this.logger.debug("Agent created, sending message");
|
|
201
450
|
const userContent = buildUserContent(prompt, attachments, targetAgent.model);
|
|
202
451
|
if (this.sessionManager && sessionId) {
|
|
203
452
|
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
|
+
}
|
|
204
462
|
const stream = await standaloneAgent.streamEvents({
|
|
205
463
|
messages: [
|
|
206
464
|
{
|
|
@@ -217,6 +475,15 @@ class AgentInvoker {
|
|
|
217
475
|
signal: options?.signal
|
|
218
476
|
});
|
|
219
477
|
for await (const chunk of stream){
|
|
478
|
+
rootLangGraphRunId = trackRootLangGraphRunId(rootLangGraphRunId, chunk);
|
|
479
|
+
if (!sawAssistantText && chunkHasAssistantText(chunk)) sawAssistantText = true;
|
|
480
|
+
if (!streamErrorMessage) streamErrorMessage = detectStreamErrorMessage(chunk);
|
|
481
|
+
const toolEvent = detectToolEventContext(chunk);
|
|
482
|
+
if (toolEvent) {
|
|
483
|
+
lastToolName = toolEvent.toolName;
|
|
484
|
+
if ("on_tool_start" === toolEvent.event) activeToolName = toolEvent.toolName;
|
|
485
|
+
else if (activeToolName === toolEvent.toolName) activeToolName = null;
|
|
486
|
+
}
|
|
220
487
|
if (isCancelled()) {
|
|
221
488
|
cancellationHandled = true;
|
|
222
489
|
this.logger.info("Agent invocation cancelled");
|
|
@@ -227,6 +494,10 @@ class AgentInvoker {
|
|
|
227
494
|
};
|
|
228
495
|
}
|
|
229
496
|
this.outputManager.emitAgentStream(chunk);
|
|
497
|
+
if (isRootLangGraphTerminalEvent(chunk, rootLangGraphRunId)) {
|
|
498
|
+
this.logger.debug("Detected root LangGraph on_chain_end event; finalizing stream without waiting for iterator shutdown");
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
230
501
|
}
|
|
231
502
|
if (isCancelled()) {
|
|
232
503
|
cancellationHandled = true;
|
|
@@ -236,9 +507,37 @@ class AgentInvoker {
|
|
|
236
507
|
cancelled: true
|
|
237
508
|
};
|
|
238
509
|
}
|
|
239
|
-
|
|
510
|
+
let fallbackText;
|
|
511
|
+
if (!sawAssistantText && this.sessionManager && sessionId && preInvocationMessages) try {
|
|
512
|
+
const sessionMessages = await this.sessionManager.listMessages(sessionId);
|
|
513
|
+
fallbackText = selectStreamingFallbackText(preInvocationMessages, sessionMessages.map((message)=>({
|
|
514
|
+
role: message.role,
|
|
515
|
+
content: message.content
|
|
516
|
+
})));
|
|
517
|
+
} catch (stateError) {
|
|
518
|
+
this.logger.debug("Failed to derive streaming fallback text from session state", stateError);
|
|
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
|
+
});
|
|
240
536
|
this.outputManager.emitAgentComplete({
|
|
241
|
-
streaming: true
|
|
537
|
+
streaming: true,
|
|
538
|
+
...fallbackText ? {
|
|
539
|
+
fallbackText
|
|
540
|
+
} : {}
|
|
242
541
|
});
|
|
243
542
|
return {
|
|
244
543
|
streaming: true
|
|
@@ -286,8 +585,10 @@ class AgentInvoker {
|
|
|
286
585
|
cancelled: true
|
|
287
586
|
};
|
|
288
587
|
}
|
|
289
|
-
this.logger.error(`Agent invocation failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
290
|
-
|
|
588
|
+
this.logger.error(`Agent invocation failed: ${error instanceof Error ? error.message : String(error)}${activeToolName ? ` (while running tool "${activeToolName}")` : lastToolName ? ` (last tool: "${lastToolName}")` : ""}`);
|
|
589
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
590
|
+
const errorWithToolContext = activeToolName ? `${errorMessage} (while running tool "${activeToolName}")` : lastToolName ? `${errorMessage} (last tool: "${lastToolName}")` : errorMessage;
|
|
591
|
+
this.outputManager.emitAgentError(errorWithToolContext);
|
|
291
592
|
throw error;
|
|
292
593
|
} finally{
|
|
293
594
|
if (this.mcpManager) {
|
|
@@ -313,6 +614,7 @@ class AgentInvoker {
|
|
|
313
614
|
_define_property(this, "wingmanConfig", void 0);
|
|
314
615
|
_define_property(this, "mcpManager", null);
|
|
315
616
|
_define_property(this, "sessionManager", null);
|
|
617
|
+
_define_property(this, "terminalSessionManager", void 0);
|
|
316
618
|
_define_property(this, "workdir", null);
|
|
317
619
|
_define_property(this, "defaultOutputDir", null);
|
|
318
620
|
this.outputManager = options.outputManager;
|
|
@@ -320,6 +622,7 @@ class AgentInvoker {
|
|
|
320
622
|
this.workspace = options.workspace || process.cwd();
|
|
321
623
|
this.configDir = options.configDir || ".wingman";
|
|
322
624
|
this.sessionManager = options.sessionManager || null;
|
|
625
|
+
this.terminalSessionManager = options.terminalSessionManager || (0, terminal_session_manager_cjs_namespaceObject.getSharedTerminalSessionManager)();
|
|
323
626
|
this.workdir = options.workdir || null;
|
|
324
627
|
this.defaultOutputDir = options.defaultOutputDir || null;
|
|
325
628
|
const configLoader = new loader_cjs_namespaceObject.WingmanConfigLoader(this.configDir, this.workspace);
|
|
@@ -516,17 +819,41 @@ exports.AgentInvoker = __webpack_exports__.AgentInvoker;
|
|
|
516
819
|
exports.OUTPUT_VIRTUAL_PATH = __webpack_exports__.OUTPUT_VIRTUAL_PATH;
|
|
517
820
|
exports.WORKDIR_VIRTUAL_PATH = __webpack_exports__.WORKDIR_VIRTUAL_PATH;
|
|
518
821
|
exports.buildUserContent = __webpack_exports__.buildUserContent;
|
|
822
|
+
exports.chunkHasAssistantText = __webpack_exports__.chunkHasAssistantText;
|
|
823
|
+
exports.configureDeepAgentSummarizationMiddleware = __webpack_exports__.configureDeepAgentSummarizationMiddleware;
|
|
824
|
+
exports.detectStreamErrorMessage = __webpack_exports__.detectStreamErrorMessage;
|
|
825
|
+
exports.detectToolEventContext = __webpack_exports__.detectToolEventContext;
|
|
826
|
+
exports.evaluateStreamingCompletion = __webpack_exports__.evaluateStreamingCompletion;
|
|
827
|
+
exports.isRootLangGraphTerminalEvent = __webpack_exports__.isRootLangGraphTerminalEvent;
|
|
519
828
|
exports.resolveExecutionWorkspace = __webpack_exports__.resolveExecutionWorkspace;
|
|
520
829
|
exports.resolveExternalOutputMount = __webpack_exports__.resolveExternalOutputMount;
|
|
830
|
+
exports.resolveHumanInTheLoopSettings = __webpack_exports__.resolveHumanInTheLoopSettings;
|
|
831
|
+
exports.resolveModelRetryMiddlewareSettings = __webpack_exports__.resolveModelRetryMiddlewareSettings;
|
|
832
|
+
exports.resolveSummarizationMiddlewareSettings = __webpack_exports__.resolveSummarizationMiddlewareSettings;
|
|
833
|
+
exports.resolveToolRetryMiddlewareSettings = __webpack_exports__.resolveToolRetryMiddlewareSettings;
|
|
834
|
+
exports.selectStreamingFallbackText = __webpack_exports__.selectStreamingFallbackText;
|
|
521
835
|
exports.toWorkspaceAliasVirtualPath = __webpack_exports__.toWorkspaceAliasVirtualPath;
|
|
836
|
+
exports.trackRootLangGraphRunId = __webpack_exports__.trackRootLangGraphRunId;
|
|
522
837
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
523
838
|
"AgentInvoker",
|
|
524
839
|
"OUTPUT_VIRTUAL_PATH",
|
|
525
840
|
"WORKDIR_VIRTUAL_PATH",
|
|
526
841
|
"buildUserContent",
|
|
842
|
+
"chunkHasAssistantText",
|
|
843
|
+
"configureDeepAgentSummarizationMiddleware",
|
|
844
|
+
"detectStreamErrorMessage",
|
|
845
|
+
"detectToolEventContext",
|
|
846
|
+
"evaluateStreamingCompletion",
|
|
847
|
+
"isRootLangGraphTerminalEvent",
|
|
527
848
|
"resolveExecutionWorkspace",
|
|
528
849
|
"resolveExternalOutputMount",
|
|
529
|
-
"
|
|
850
|
+
"resolveHumanInTheLoopSettings",
|
|
851
|
+
"resolveModelRetryMiddlewareSettings",
|
|
852
|
+
"resolveSummarizationMiddlewareSettings",
|
|
853
|
+
"resolveToolRetryMiddlewareSettings",
|
|
854
|
+
"selectStreamingFallbackText",
|
|
855
|
+
"toWorkspaceAliasVirtualPath",
|
|
856
|
+
"trackRootLangGraphRunId"
|
|
530
857
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
531
858
|
Object.defineProperty(exports, '__esModule', {
|
|
532
859
|
value: true
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import type { OutputManager } from "./outputManager.js";
|
|
2
|
-
import type { Logger } from "../../logger.js";
|
|
3
1
|
import type { WingmanAgentConfig } from "@/agent/config/agentConfig.js";
|
|
2
|
+
import { type TerminalSessionManager } from "@/agent/tools/terminal_session_manager.js";
|
|
4
3
|
import type { WingmanAgent } from "@/types/agents.js";
|
|
5
|
-
import {
|
|
4
|
+
import type { Logger } from "../../logger.js";
|
|
5
|
+
import type { WingmanConfigType } from "../config/schema.js";
|
|
6
|
+
import type { OutputManager } from "./outputManager.js";
|
|
7
|
+
import type { SessionManager } from "./sessionManager.js";
|
|
6
8
|
export interface AgentInvokerOptions {
|
|
7
9
|
workspace?: string;
|
|
8
10
|
configDir?: string;
|
|
9
11
|
outputManager: OutputManager;
|
|
10
12
|
logger: Logger;
|
|
11
13
|
sessionManager?: SessionManager;
|
|
14
|
+
terminalSessionManager?: TerminalSessionManager;
|
|
12
15
|
workdir?: string | null;
|
|
13
16
|
defaultOutputDir?: string | null;
|
|
14
17
|
}
|
|
@@ -79,9 +82,65 @@ export type ExternalOutputMount = {
|
|
|
79
82
|
virtualPath: string | null;
|
|
80
83
|
absolutePath: string | null;
|
|
81
84
|
};
|
|
85
|
+
export type SummarizationMiddlewareSettings = {
|
|
86
|
+
maxTokensBeforeSummary: number;
|
|
87
|
+
messagesToKeep: number;
|
|
88
|
+
};
|
|
89
|
+
export type ModelRetryMiddlewareSettings = {
|
|
90
|
+
maxRetries: number;
|
|
91
|
+
backoffFactor: number;
|
|
92
|
+
initialDelayMs: number;
|
|
93
|
+
maxDelayMs: number;
|
|
94
|
+
jitter: boolean;
|
|
95
|
+
onFailure: "continue" | "error";
|
|
96
|
+
};
|
|
97
|
+
export type ToolRetryMiddlewareSettings = ModelRetryMiddlewareSettings & {
|
|
98
|
+
tools?: string[];
|
|
99
|
+
};
|
|
100
|
+
export type HumanInTheLoopSettings = {
|
|
101
|
+
interruptOn: Record<string, boolean | {
|
|
102
|
+
allowedDecisions: Array<"approve" | "edit" | "reject">;
|
|
103
|
+
description?: string;
|
|
104
|
+
argsSchema?: Record<string, any>;
|
|
105
|
+
}>;
|
|
106
|
+
};
|
|
82
107
|
export declare const resolveExecutionWorkspace: (workspace: string, workdir?: string | null) => string;
|
|
83
108
|
export declare const toWorkspaceAliasVirtualPath: (absolutePath: string) => string | null;
|
|
84
109
|
export declare const resolveExternalOutputMount: (workspace: string, workdir?: string | null, defaultOutputDir?: string | null) => ExternalOutputMount;
|
|
110
|
+
export declare const resolveSummarizationMiddlewareSettings: (config: WingmanConfigType) => SummarizationMiddlewareSettings | null;
|
|
111
|
+
export declare const resolveModelRetryMiddlewareSettings: (config: WingmanConfigType) => ModelRetryMiddlewareSettings | null;
|
|
112
|
+
export declare const resolveToolRetryMiddlewareSettings: (config: WingmanConfigType) => ToolRetryMiddlewareSettings | null;
|
|
113
|
+
export declare const resolveHumanInTheLoopSettings: (config: WingmanConfigType) => HumanInTheLoopSettings | null;
|
|
114
|
+
export declare const configureDeepAgentSummarizationMiddleware: (agent: any, settings: SummarizationMiddlewareSettings | null, model?: any) => void;
|
|
115
|
+
type ToolEventContext = {
|
|
116
|
+
event: "on_tool_start" | "on_tool_end" | "on_tool_error";
|
|
117
|
+
toolName: string;
|
|
118
|
+
};
|
|
119
|
+
export declare const detectToolEventContext: (chunk: unknown) => ToolEventContext | null;
|
|
120
|
+
export declare const chunkHasAssistantText: (chunk: unknown) => boolean;
|
|
121
|
+
export declare const selectStreamingFallbackText: (previousMessages: Array<{
|
|
122
|
+
role?: unknown;
|
|
123
|
+
content?: unknown;
|
|
124
|
+
}>, currentMessages: Array<{
|
|
125
|
+
role?: unknown;
|
|
126
|
+
content?: unknown;
|
|
127
|
+
}>) => string | undefined;
|
|
128
|
+
export declare const detectStreamErrorMessage: (chunk: unknown) => string | undefined;
|
|
129
|
+
export declare const trackRootLangGraphRunId: (currentRootLangGraphRunId: string | undefined, chunk: unknown) => string | undefined;
|
|
130
|
+
export declare const isRootLangGraphTerminalEvent: (chunk: unknown, rootLangGraphRunId?: string) => boolean;
|
|
131
|
+
type StreamingCompletionOutcome = {
|
|
132
|
+
status: "blocked";
|
|
133
|
+
reason: "stream_error" | "empty_stream_response";
|
|
134
|
+
message: string;
|
|
135
|
+
} | {
|
|
136
|
+
status: "ok";
|
|
137
|
+
};
|
|
138
|
+
type EvaluateStreamingCompletionInput = {
|
|
139
|
+
sawAssistantText: boolean;
|
|
140
|
+
fallbackText?: string;
|
|
141
|
+
streamErrorMessage?: string;
|
|
142
|
+
};
|
|
143
|
+
export declare const evaluateStreamingCompletion: (input: EvaluateStreamingCompletionInput) => StreamingCompletionOutcome;
|
|
85
144
|
export declare class AgentInvoker {
|
|
86
145
|
private loader;
|
|
87
146
|
private outputManager;
|
|
@@ -91,6 +150,7 @@ export declare class AgentInvoker {
|
|
|
91
150
|
private wingmanConfig;
|
|
92
151
|
private mcpManager;
|
|
93
152
|
private sessionManager;
|
|
153
|
+
private terminalSessionManager;
|
|
94
154
|
private workdir;
|
|
95
155
|
private defaultOutputDir;
|
|
96
156
|
constructor(options: AgentInvokerOptions);
|