@wingman-ai/gateway 0.5.3 → 0.5.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/dist/agent/config/agentConfig.cjs +4 -0
- package/dist/agent/config/agentConfig.d.ts +12 -0
- package/dist/agent/config/agentConfig.js +4 -0
- package/dist/agent/config/toolRegistry.cjs +75 -1
- package/dist/agent/config/toolRegistry.d.ts +3 -0
- package/dist/agent/config/toolRegistry.js +75 -1
- package/dist/agent/middleware/large-tool-results.cjs +207 -0
- package/dist/agent/middleware/large-tool-results.d.ts +16 -0
- package/dist/agent/middleware/large-tool-results.js +173 -0
- package/dist/agent/tools/browser_control.cjs +9 -1231
- package/dist/agent/tools/browser_control.d.ts +126 -234
- package/dist/agent/tools/browser_control.js +7 -1226
- package/dist/agent/tools/browser_runtime.cjs +1189 -0
- package/dist/agent/tools/browser_runtime.d.ts +560 -0
- package/dist/agent/tools/browser_runtime.js +1122 -0
- package/dist/agent/tools/browser_session.cjs +153 -0
- package/dist/agent/tools/browser_session.d.ts +741 -0
- package/dist/agent/tools/browser_session.js +110 -0
- package/dist/agent/tools/browser_session_manager.cjs +202 -0
- package/dist/agent/tools/browser_session_manager.d.ts +64 -0
- package/dist/agent/tools/browser_session_manager.js +165 -0
- package/dist/cli/commands/init.cjs +5 -1
- package/dist/cli/commands/init.js +5 -1
- package/dist/cli/config/loader.cjs +0 -5
- package/dist/cli/config/loader.js +0 -5
- package/dist/cli/config/schema.cjs +3 -7
- package/dist/cli/config/schema.d.ts +6 -6
- package/dist/cli/config/schema.js +3 -7
- package/dist/cli/core/agentInvoker.cjs +86 -22
- package/dist/cli/core/agentInvoker.d.ts +10 -3
- package/dist/cli/core/agentInvoker.js +86 -25
- package/dist/cli/core/outputManager.cjs +7 -2
- package/dist/cli/core/outputManager.d.ts +2 -2
- package/dist/cli/core/outputManager.js +7 -2
- package/dist/cli/types.d.ts +2 -1
- package/dist/webui/assets/index-XrEnkZiq.css +11 -0
- package/dist/webui/assets/index-mDs6HbKM.js +215 -0
- package/dist/webui/index.html +2 -2
- package/package.json +10 -10
- package/templates/agents/README.md +2 -1
- package/templates/agents/coding/agent.md +6 -13
- package/templates/agents/coding-v2/agent.md +6 -1
- package/templates/agents/game-dev/agent.md +8 -2
- package/templates/agents/game-dev/game-designer.md +4 -0
- package/templates/agents/game-dev/scene-engineer.md +4 -0
- package/templates/agents/main/agent.md +5 -0
- package/templates/agents/researcher/agent.md +11 -0
- package/templates/agents/stock-trader/agent.md +4 -0
- package/dist/agent/tests/agentConfig.test.cjs +0 -224
- package/dist/agent/tests/agentConfig.test.d.ts +0 -1
- package/dist/agent/tests/agentConfig.test.js +0 -218
- package/dist/agent/tests/agentLoader.test.cjs +0 -335
- package/dist/agent/tests/agentLoader.test.d.ts +0 -1
- package/dist/agent/tests/agentLoader.test.js +0 -329
- package/dist/agent/tests/backgroundTerminal.test.cjs +0 -70
- package/dist/agent/tests/backgroundTerminal.test.d.ts +0 -1
- package/dist/agent/tests/backgroundTerminal.test.js +0 -64
- package/dist/agent/tests/browserControlHelpers.test.cjs +0 -35
- package/dist/agent/tests/browserControlHelpers.test.d.ts +0 -1
- package/dist/agent/tests/browserControlHelpers.test.js +0 -29
- package/dist/agent/tests/browserControlTool.test.cjs +0 -2117
- package/dist/agent/tests/browserControlTool.test.d.ts +0 -1
- package/dist/agent/tests/browserControlTool.test.js +0 -2111
- package/dist/agent/tests/commandExecuteTool.test.cjs +0 -29
- package/dist/agent/tests/commandExecuteTool.test.d.ts +0 -1
- package/dist/agent/tests/commandExecuteTool.test.js +0 -23
- package/dist/agent/tests/internet_search.test.cjs +0 -107
- package/dist/agent/tests/internet_search.test.d.ts +0 -1
- package/dist/agent/tests/internet_search.test.js +0 -101
- package/dist/agent/tests/mcpClientManager.test.cjs +0 -290
- package/dist/agent/tests/mcpClientManager.test.d.ts +0 -1
- package/dist/agent/tests/mcpClientManager.test.js +0 -284
- package/dist/agent/tests/mcpResourceTools.test.cjs +0 -101
- package/dist/agent/tests/mcpResourceTools.test.d.ts +0 -1
- package/dist/agent/tests/mcpResourceTools.test.js +0 -95
- package/dist/agent/tests/modelFactory.test.cjs +0 -190
- package/dist/agent/tests/modelFactory.test.d.ts +0 -1
- package/dist/agent/tests/modelFactory.test.js +0 -184
- package/dist/agent/tests/terminalSessionManager.test.cjs +0 -121
- package/dist/agent/tests/terminalSessionManager.test.d.ts +0 -1
- package/dist/agent/tests/terminalSessionManager.test.js +0 -115
- package/dist/agent/tests/test-agent-loader.cjs +0 -33
- package/dist/agent/tests/test-agent-loader.d.ts +0 -1
- package/dist/agent/tests/test-agent-loader.js +0 -27
- package/dist/agent/tests/test-subagent-loading.cjs +0 -99
- package/dist/agent/tests/test-subagent-loading.d.ts +0 -1
- package/dist/agent/tests/test-subagent-loading.js +0 -93
- package/dist/agent/tests/toolRegistry.test.cjs +0 -147
- package/dist/agent/tests/toolRegistry.test.d.ts +0 -1
- package/dist/agent/tests/toolRegistry.test.js +0 -141
- package/dist/agent/tests/uiRegistryTools.test.cjs +0 -114
- package/dist/agent/tests/uiRegistryTools.test.d.ts +0 -1
- package/dist/agent/tests/uiRegistryTools.test.js +0 -105
- package/dist/agent/tests/xaiImageModel.test.cjs +0 -194
- package/dist/agent/tests/xaiImageModel.test.d.ts +0 -1
- package/dist/agent/tests/xaiImageModel.test.js +0 -188
- package/dist/tests/additionalMessageMiddleware.test.cjs +0 -216
- package/dist/tests/additionalMessageMiddleware.test.d.ts +0 -1
- package/dist/tests/additionalMessageMiddleware.test.js +0 -188
- package/dist/tests/agent-config-voice.test.cjs +0 -25
- package/dist/tests/agent-config-voice.test.d.ts +0 -1
- package/dist/tests/agent-config-voice.test.js +0 -19
- package/dist/tests/agentInvokerAttachments.test.cjs +0 -190
- package/dist/tests/agentInvokerAttachments.test.d.ts +0 -1
- package/dist/tests/agentInvokerAttachments.test.js +0 -184
- package/dist/tests/agentInvokerSummarization.test.cjs +0 -613
- package/dist/tests/agentInvokerSummarization.test.d.ts +0 -1
- package/dist/tests/agentInvokerSummarization.test.js +0 -607
- package/dist/tests/agentInvokerTokenUsage.test.cjs +0 -124
- package/dist/tests/agentInvokerTokenUsage.test.d.ts +0 -1
- package/dist/tests/agentInvokerTokenUsage.test.js +0 -118
- package/dist/tests/agentInvokerWorkdir.test.cjs +0 -150
- package/dist/tests/agentInvokerWorkdir.test.d.ts +0 -1
- package/dist/tests/agentInvokerWorkdir.test.js +0 -122
- package/dist/tests/agents-api.test.cjs +0 -324
- package/dist/tests/agents-api.test.d.ts +0 -1
- package/dist/tests/agents-api.test.js +0 -318
- package/dist/tests/attachments-utils.test.cjs +0 -46
- package/dist/tests/attachments-utils.test.d.ts +0 -1
- package/dist/tests/attachments-utils.test.js +0 -40
- package/dist/tests/browser-command.test.cjs +0 -264
- package/dist/tests/browser-command.test.d.ts +0 -1
- package/dist/tests/browser-command.test.js +0 -258
- package/dist/tests/browser-relay-server.test.cjs +0 -20
- package/dist/tests/browser-relay-server.test.d.ts +0 -1
- package/dist/tests/browser-relay-server.test.js +0 -14
- package/dist/tests/bunSqliteAdapter.test.cjs +0 -265
- package/dist/tests/bunSqliteAdapter.test.d.ts +0 -1
- package/dist/tests/bunSqliteAdapter.test.js +0 -259
- package/dist/tests/candleRange.test.cjs +0 -48
- package/dist/tests/candleRange.test.d.ts +0 -1
- package/dist/tests/candleRange.test.js +0 -42
- package/dist/tests/cli-config-loader.test.cjs +0 -532
- package/dist/tests/cli-config-loader.test.d.ts +0 -1
- package/dist/tests/cli-config-loader.test.js +0 -526
- package/dist/tests/cli-config-warnings.test.cjs +0 -94
- package/dist/tests/cli-config-warnings.test.d.ts +0 -1
- package/dist/tests/cli-config-warnings.test.js +0 -88
- package/dist/tests/cli-init.test.cjs +0 -225
- package/dist/tests/cli-init.test.d.ts +0 -1
- package/dist/tests/cli-init.test.js +0 -219
- package/dist/tests/cli-workspace-root.test.cjs +0 -114
- package/dist/tests/cli-workspace-root.test.d.ts +0 -1
- package/dist/tests/cli-workspace-root.test.js +0 -108
- package/dist/tests/codex-credentials-precedence.test.cjs +0 -94
- package/dist/tests/codex-credentials-precedence.test.d.ts +0 -1
- package/dist/tests/codex-credentials-precedence.test.js +0 -88
- package/dist/tests/codex-provider.test.cjs +0 -383
- package/dist/tests/codex-provider.test.d.ts +0 -1
- package/dist/tests/codex-provider.test.js +0 -377
- package/dist/tests/config-json-schema.test.cjs +0 -37
- package/dist/tests/config-json-schema.test.d.ts +0 -1
- package/dist/tests/config-json-schema.test.js +0 -31
- package/dist/tests/discord-adapter.test.cjs +0 -89
- package/dist/tests/discord-adapter.test.d.ts +0 -1
- package/dist/tests/discord-adapter.test.js +0 -83
- package/dist/tests/falRuntime.test.cjs +0 -78
- package/dist/tests/falRuntime.test.d.ts +0 -1
- package/dist/tests/falRuntime.test.js +0 -72
- package/dist/tests/falSummary.test.cjs +0 -51
- package/dist/tests/falSummary.test.d.ts +0 -1
- package/dist/tests/falSummary.test.js +0 -45
- package/dist/tests/fs-api.test.cjs +0 -138
- package/dist/tests/fs-api.test.d.ts +0 -1
- package/dist/tests/fs-api.test.js +0 -132
- package/dist/tests/gateway-command-workspace.test.cjs +0 -150
- package/dist/tests/gateway-command-workspace.test.d.ts +0 -1
- package/dist/tests/gateway-command-workspace.test.js +0 -144
- package/dist/tests/gateway-http-security.test.cjs +0 -318
- package/dist/tests/gateway-http-security.test.d.ts +0 -1
- package/dist/tests/gateway-http-security.test.js +0 -312
- package/dist/tests/gateway-node-mode.test.cjs +0 -174
- package/dist/tests/gateway-node-mode.test.d.ts +0 -1
- package/dist/tests/gateway-node-mode.test.js +0 -168
- package/dist/tests/gateway-origin-policy.test.cjs +0 -82
- package/dist/tests/gateway-origin-policy.test.d.ts +0 -1
- package/dist/tests/gateway-origin-policy.test.js +0 -76
- package/dist/tests/gateway-request-execution-overrides.test.cjs +0 -42
- package/dist/tests/gateway-request-execution-overrides.test.d.ts +0 -1
- package/dist/tests/gateway-request-execution-overrides.test.js +0 -36
- package/dist/tests/gateway.test.cjs +0 -700
- package/dist/tests/gateway.test.d.ts +0 -1
- package/dist/tests/gateway.test.js +0 -694
- package/dist/tests/hooks-matcher.test.cjs +0 -309
- package/dist/tests/hooks-matcher.test.d.ts +0 -1
- package/dist/tests/hooks-matcher.test.js +0 -303
- package/dist/tests/hooks-merger.test.cjs +0 -528
- package/dist/tests/hooks-merger.test.d.ts +0 -1
- package/dist/tests/hooks-merger.test.js +0 -522
- package/dist/tests/imagePersistence.test.cjs +0 -169
- package/dist/tests/imagePersistence.test.d.ts +0 -1
- package/dist/tests/imagePersistence.test.js +0 -163
- package/dist/tests/integration/agent-invocation.integration.test.cjs +0 -264
- package/dist/tests/integration/agent-invocation.integration.test.d.ts +0 -1
- package/dist/tests/integration/agent-invocation.integration.test.js +0 -258
- package/dist/tests/integration/finnhub-candles.integration.test.cjs +0 -98
- package/dist/tests/integration/finnhub-candles.integration.test.d.ts +0 -1
- package/dist/tests/integration/finnhub-candles.integration.test.js +0 -92
- package/dist/tests/integration/summarization-e2e.integration.test.cjs +0 -127
- package/dist/tests/integration/summarization-e2e.integration.test.d.ts +0 -1
- package/dist/tests/integration/summarization-e2e.integration.test.js +0 -121
- package/dist/tests/logger.test.cjs +0 -353
- package/dist/tests/logger.test.d.ts +0 -1
- package/dist/tests/logger.test.js +0 -347
- package/dist/tests/mediaCompatibilityMiddleware.test.cjs +0 -106
- package/dist/tests/mediaCompatibilityMiddleware.test.d.ts +0 -1
- package/dist/tests/mediaCompatibilityMiddleware.test.js +0 -100
- package/dist/tests/node-tools.test.cjs +0 -77
- package/dist/tests/node-tools.test.d.ts +0 -1
- package/dist/tests/node-tools.test.js +0 -71
- package/dist/tests/nodes-api.test.cjs +0 -86
- package/dist/tests/nodes-api.test.d.ts +0 -1
- package/dist/tests/nodes-api.test.js +0 -80
- package/dist/tests/outputManagerContextSummarized.test.cjs +0 -43
- package/dist/tests/outputManagerContextSummarized.test.d.ts +0 -1
- package/dist/tests/outputManagerContextSummarized.test.js +0 -37
- package/dist/tests/provider-command-codex.test.cjs +0 -57
- package/dist/tests/provider-command-codex.test.d.ts +0 -1
- package/dist/tests/provider-command-codex.test.js +0 -51
- package/dist/tests/routines-api.test.cjs +0 -107
- package/dist/tests/routines-api.test.d.ts +0 -1
- package/dist/tests/routines-api.test.js +0 -101
- package/dist/tests/run-terminal-bench-official-script.test.cjs +0 -61
- package/dist/tests/run-terminal-bench-official-script.test.d.ts +0 -1
- package/dist/tests/run-terminal-bench-official-script.test.js +0 -55
- package/dist/tests/sessionManager-uionly.test.cjs +0 -50
- package/dist/tests/sessionManager-uionly.test.d.ts +0 -1
- package/dist/tests/sessionManager-uionly.test.js +0 -44
- package/dist/tests/sessionMessageAttachments.test.cjs +0 -197
- package/dist/tests/sessionMessageAttachments.test.d.ts +0 -1
- package/dist/tests/sessionMessageAttachments.test.js +0 -191
- package/dist/tests/sessionMessageRole.test.cjs +0 -44
- package/dist/tests/sessionMessageRole.test.d.ts +0 -1
- package/dist/tests/sessionMessageRole.test.js +0 -38
- package/dist/tests/sessionStateMessages.test.cjs +0 -236
- package/dist/tests/sessionStateMessages.test.d.ts +0 -1
- package/dist/tests/sessionStateMessages.test.js +0 -230
- package/dist/tests/sessions-api.test.cjs +0 -250
- package/dist/tests/sessions-api.test.d.ts +0 -1
- package/dist/tests/sessions-api.test.js +0 -244
- package/dist/tests/skill-activation.test.cjs +0 -86
- package/dist/tests/skill-activation.test.d.ts +0 -1
- package/dist/tests/skill-activation.test.js +0 -80
- package/dist/tests/skill-metadata.test.cjs +0 -119
- package/dist/tests/skill-metadata.test.d.ts +0 -1
- package/dist/tests/skill-metadata.test.js +0 -113
- package/dist/tests/skill-repository.test.cjs +0 -469
- package/dist/tests/skill-repository.test.d.ts +0 -1
- package/dist/tests/skill-repository.test.js +0 -463
- package/dist/tests/skill-security-scanner.test.cjs +0 -126
- package/dist/tests/skill-security-scanner.test.d.ts +0 -1
- package/dist/tests/skill-security-scanner.test.js +0 -120
- package/dist/tests/sms-api.test.cjs +0 -183
- package/dist/tests/sms-api.test.d.ts +0 -1
- package/dist/tests/sms-api.test.js +0 -177
- package/dist/tests/sms-commands.test.cjs +0 -90
- package/dist/tests/sms-commands.test.d.ts +0 -1
- package/dist/tests/sms-commands.test.js +0 -84
- package/dist/tests/sms-policy-store.test.cjs +0 -69
- package/dist/tests/sms-policy-store.test.d.ts +0 -1
- package/dist/tests/sms-policy-store.test.js +0 -63
- package/dist/tests/teams-adapter.test.cjs +0 -58
- package/dist/tests/teams-adapter.test.d.ts +0 -1
- package/dist/tests/teams-adapter.test.js +0 -52
- package/dist/tests/technicalIndicators.test.cjs +0 -82
- package/dist/tests/technicalIndicators.test.d.ts +0 -1
- package/dist/tests/technicalIndicators.test.js +0 -76
- package/dist/tests/terminal-bench-adapters-helpers.test.cjs +0 -64
- package/dist/tests/terminal-bench-adapters-helpers.test.d.ts +0 -1
- package/dist/tests/terminal-bench-adapters-helpers.test.js +0 -58
- package/dist/tests/terminal-bench-cleanup.test.cjs +0 -93
- package/dist/tests/terminal-bench-cleanup.test.d.ts +0 -1
- package/dist/tests/terminal-bench-cleanup.test.js +0 -87
- package/dist/tests/terminal-bench-config.test.cjs +0 -62
- package/dist/tests/terminal-bench-config.test.d.ts +0 -1
- package/dist/tests/terminal-bench-config.test.js +0 -56
- package/dist/tests/terminal-bench-official.test.cjs +0 -194
- package/dist/tests/terminal-bench-official.test.d.ts +0 -1
- package/dist/tests/terminal-bench-official.test.js +0 -188
- package/dist/tests/terminal-bench-runner.test.cjs +0 -82
- package/dist/tests/terminal-bench-runner.test.d.ts +0 -1
- package/dist/tests/terminal-bench-runner.test.js +0 -76
- package/dist/tests/terminal-bench-scoring.test.cjs +0 -128
- package/dist/tests/terminal-bench-scoring.test.d.ts +0 -1
- package/dist/tests/terminal-bench-scoring.test.js +0 -122
- package/dist/tests/terminalProbe.test.cjs +0 -45
- package/dist/tests/terminalProbe.test.d.ts +0 -1
- package/dist/tests/terminalProbe.test.js +0 -39
- package/dist/tests/terminalProbeAuth.test.cjs +0 -85
- package/dist/tests/terminalProbeAuth.test.d.ts +0 -1
- package/dist/tests/terminalProbeAuth.test.js +0 -79
- package/dist/tests/toolDisplayHelpers.test.cjs +0 -46
- package/dist/tests/toolDisplayHelpers.test.d.ts +0 -1
- package/dist/tests/toolDisplayHelpers.test.js +0 -40
- package/dist/tests/uv.test.cjs +0 -47
- package/dist/tests/uv.test.d.ts +0 -1
- package/dist/tests/uv.test.js +0 -41
- package/dist/tests/voice-config.test.cjs +0 -35
- package/dist/tests/voice-config.test.d.ts +0 -1
- package/dist/tests/voice-config.test.js +0 -29
- package/dist/tests/websocket-transport.test.cjs +0 -31
- package/dist/tests/websocket-transport.test.d.ts +0 -1
- package/dist/tests/websocket-transport.test.js +0 -25
- package/dist/tests/yahooCandles.test.cjs +0 -111
- package/dist/tests/yahooCandles.test.d.ts +0 -1
- package/dist/tests/yahooCandles.test.js +0 -105
- package/dist/tools/finance/optionsAnalytics.test.cjs +0 -128
- package/dist/tools/finance/optionsAnalytics.test.d.ts +0 -1
- package/dist/tools/finance/optionsAnalytics.test.js +0 -122
- package/dist/webui/assets/index-BMf95nv5.js +0 -215
- package/dist/webui/assets/index-DhJQ8Mbn.css +0 -11
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_exports__ = {};
|
|
3
|
-
const external_node_fs_namespaceObject = require("node:fs");
|
|
4
|
-
const external_node_os_namespaceObject = require("node:os");
|
|
5
|
-
const external_node_path_namespaceObject = require("node:path");
|
|
6
|
-
const external_js_yaml_namespaceObject = require("js-yaml");
|
|
7
|
-
const external_vitest_namespaceObject = require("vitest");
|
|
8
|
-
const agents_cjs_namespaceObject = require("../gateway/http/agents.cjs");
|
|
9
|
-
const isBunRuntime = void 0 !== globalThis.Bun;
|
|
10
|
-
const describeIfBun = isBunRuntime ? external_vitest_namespaceObject.describe : external_vitest_namespaceObject.describe.skip;
|
|
11
|
-
const parseMarkdownAgent = (raw)=>{
|
|
12
|
-
const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/;
|
|
13
|
-
const match = raw.match(frontmatterRegex);
|
|
14
|
-
if (!match) throw new Error("Agent markdown is missing frontmatter");
|
|
15
|
-
const metadata = external_js_yaml_namespaceObject.load(match[1]) || {};
|
|
16
|
-
return {
|
|
17
|
-
metadata,
|
|
18
|
-
prompt: match[2].trim()
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
describeIfBun("agents API", ()=>{
|
|
22
|
-
let tempDir;
|
|
23
|
-
let config;
|
|
24
|
-
let ctx;
|
|
25
|
-
(0, external_vitest_namespaceObject.beforeEach)(()=>{
|
|
26
|
-
tempDir = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-agents-api-"));
|
|
27
|
-
config = {
|
|
28
|
-
agents: {
|
|
29
|
-
list: [],
|
|
30
|
-
bindings: []
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
ctx = {
|
|
34
|
-
workspace: tempDir,
|
|
35
|
-
configDir: tempDir,
|
|
36
|
-
getWingmanConfig: ()=>config,
|
|
37
|
-
setWingmanConfig: (next)=>{
|
|
38
|
-
config = next;
|
|
39
|
-
},
|
|
40
|
-
persistWingmanConfig: ()=>{},
|
|
41
|
-
router: {},
|
|
42
|
-
setRouter: ()=>{},
|
|
43
|
-
resolveConfigDirPath: ()=>tempDir,
|
|
44
|
-
getBuiltInTools: ()=>[]
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
(0, external_vitest_namespaceObject.afterEach)(()=>{
|
|
48
|
-
(0, external_node_fs_namespaceObject.rmSync)(tempDir, {
|
|
49
|
-
recursive: true,
|
|
50
|
-
force: true
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
(0, external_vitest_namespaceObject.it)("creates agent markdown with promptTraining and subAgents", async ()=>{
|
|
54
|
-
const createReq = new Request("http://localhost/api/agents", {
|
|
55
|
-
method: "POST",
|
|
56
|
-
headers: {
|
|
57
|
-
"Content-Type": "application/json"
|
|
58
|
-
},
|
|
59
|
-
body: JSON.stringify({
|
|
60
|
-
id: "orchestrator",
|
|
61
|
-
displayName: "Orchestrator",
|
|
62
|
-
description: "Delegates work",
|
|
63
|
-
tools: [
|
|
64
|
-
"think",
|
|
65
|
-
"not_real_tool"
|
|
66
|
-
],
|
|
67
|
-
prompt: "You are the orchestrator.",
|
|
68
|
-
reasoningEffort: "high",
|
|
69
|
-
promptTraining: {
|
|
70
|
-
enabled: true,
|
|
71
|
-
instructionsPath: "/memories/agents/orchestrator/instructions.md"
|
|
72
|
-
},
|
|
73
|
-
subAgents: [
|
|
74
|
-
{
|
|
75
|
-
id: "planner",
|
|
76
|
-
description: "Plans tasks",
|
|
77
|
-
tools: [
|
|
78
|
-
"think",
|
|
79
|
-
"not_real_tool"
|
|
80
|
-
],
|
|
81
|
-
prompt: "Plan tasks in detail.",
|
|
82
|
-
reasoningEffort: "low",
|
|
83
|
-
promptTraining: true
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
id: "executor",
|
|
87
|
-
description: "Executes tasks",
|
|
88
|
-
tools: [
|
|
89
|
-
"command_execute"
|
|
90
|
-
],
|
|
91
|
-
prompt: "Execute planned tasks.",
|
|
92
|
-
thinkingEffort: "minimal"
|
|
93
|
-
}
|
|
94
|
-
]
|
|
95
|
-
})
|
|
96
|
-
});
|
|
97
|
-
const createRes = await (0, agents_cjs_namespaceObject.handleAgentsApi)(ctx, createReq, new URL(createReq.url));
|
|
98
|
-
(0, external_vitest_namespaceObject.expect)(createRes).not.toBeNull();
|
|
99
|
-
(0, external_vitest_namespaceObject.expect)(createRes?.ok).toBe(true);
|
|
100
|
-
const created = await createRes.json();
|
|
101
|
-
(0, external_vitest_namespaceObject.expect)(created.promptTraining).toEqual({
|
|
102
|
-
enabled: true,
|
|
103
|
-
instructionsPath: "/memories/agents/orchestrator/instructions.md"
|
|
104
|
-
});
|
|
105
|
-
(0, external_vitest_namespaceObject.expect)(created.reasoningEffort).toBe("high");
|
|
106
|
-
(0, external_vitest_namespaceObject.expect)(created.promptRefinement).toEqual(created.promptTraining);
|
|
107
|
-
(0, external_vitest_namespaceObject.expect)(created.subAgents).toHaveLength(2);
|
|
108
|
-
(0, external_vitest_namespaceObject.expect)(created.subAgents[0].promptTraining).toBe(true);
|
|
109
|
-
(0, external_vitest_namespaceObject.expect)(created.subAgents[0].tools).toEqual([
|
|
110
|
-
"think"
|
|
111
|
-
]);
|
|
112
|
-
(0, external_vitest_namespaceObject.expect)(created.subAgents[0].reasoningEffort).toBe("low");
|
|
113
|
-
(0, external_vitest_namespaceObject.expect)(created.subAgents[1].reasoningEffort).toBe("minimal");
|
|
114
|
-
const agentPath = (0, external_node_path_namespaceObject.join)(tempDir, "agents", "orchestrator", "agent.md");
|
|
115
|
-
const parsed = parseMarkdownAgent((0, external_node_fs_namespaceObject.readFileSync)(agentPath, "utf-8"));
|
|
116
|
-
(0, external_vitest_namespaceObject.expect)(parsed.prompt).toBe("You are the orchestrator.");
|
|
117
|
-
(0, external_vitest_namespaceObject.expect)(parsed.metadata.promptRefinement).toEqual({
|
|
118
|
-
enabled: true,
|
|
119
|
-
instructionsPath: "/memories/agents/orchestrator/instructions.md"
|
|
120
|
-
});
|
|
121
|
-
(0, external_vitest_namespaceObject.expect)(parsed.metadata.reasoningEffort).toBe("high");
|
|
122
|
-
(0, external_vitest_namespaceObject.expect)(parsed.metadata.subAgents).toHaveLength(2);
|
|
123
|
-
(0, external_vitest_namespaceObject.expect)(parsed.metadata.subAgents[0].name).toBe("planner");
|
|
124
|
-
(0, external_vitest_namespaceObject.expect)(parsed.metadata.subAgents[0].reasoningEffort).toBe("low");
|
|
125
|
-
(0, external_vitest_namespaceObject.expect)(parsed.metadata.subAgents[0].promptRefinement).toBe(true);
|
|
126
|
-
(0, external_vitest_namespaceObject.expect)(parsed.metadata.subAgents[0].systemPrompt).toBe("Plan tasks in detail.");
|
|
127
|
-
(0, external_vitest_namespaceObject.expect)(parsed.metadata.subAgents[1].reasoningEffort).toBe("minimal");
|
|
128
|
-
const detailReq = new Request("http://localhost/api/agents/orchestrator", {
|
|
129
|
-
method: "GET"
|
|
130
|
-
});
|
|
131
|
-
const detailRes = await (0, agents_cjs_namespaceObject.handleAgentsApi)(ctx, detailReq, new URL(detailReq.url));
|
|
132
|
-
(0, external_vitest_namespaceObject.expect)(detailRes).not.toBeNull();
|
|
133
|
-
(0, external_vitest_namespaceObject.expect)(detailRes?.ok).toBe(true);
|
|
134
|
-
const detail = await detailRes.json();
|
|
135
|
-
(0, external_vitest_namespaceObject.expect)(detail.promptTraining).toEqual(created.promptTraining);
|
|
136
|
-
(0, external_vitest_namespaceObject.expect)(detail.promptRefinement).toEqual(created.promptTraining);
|
|
137
|
-
(0, external_vitest_namespaceObject.expect)(detail.reasoningEffort).toBe("high");
|
|
138
|
-
(0, external_vitest_namespaceObject.expect)(detail.subAgents).toHaveLength(2);
|
|
139
|
-
(0, external_vitest_namespaceObject.expect)(detail.subAgents[0].id).toBe("planner");
|
|
140
|
-
(0, external_vitest_namespaceObject.expect)(detail.subAgents[0].prompt).toBe("Plan tasks in detail.");
|
|
141
|
-
(0, external_vitest_namespaceObject.expect)(detail.subAgents[0].reasoningEffort).toBe("low");
|
|
142
|
-
});
|
|
143
|
-
(0, external_vitest_namespaceObject.it)("updates promptTraining and subAgents in markdown", async ()=>{
|
|
144
|
-
const createReq = new Request("http://localhost/api/agents", {
|
|
145
|
-
method: "POST",
|
|
146
|
-
headers: {
|
|
147
|
-
"Content-Type": "application/json"
|
|
148
|
-
},
|
|
149
|
-
body: JSON.stringify({
|
|
150
|
-
id: "editor-agent",
|
|
151
|
-
tools: [
|
|
152
|
-
"think"
|
|
153
|
-
],
|
|
154
|
-
prompt: "Original prompt",
|
|
155
|
-
reasoningEffort: "low",
|
|
156
|
-
promptTraining: true,
|
|
157
|
-
subAgents: [
|
|
158
|
-
{
|
|
159
|
-
id: "planner",
|
|
160
|
-
description: "Plans",
|
|
161
|
-
tools: [
|
|
162
|
-
"think"
|
|
163
|
-
],
|
|
164
|
-
prompt: "Original planner prompt",
|
|
165
|
-
reasoningEffort: "minimal"
|
|
166
|
-
}
|
|
167
|
-
]
|
|
168
|
-
})
|
|
169
|
-
});
|
|
170
|
-
const createRes = await (0, agents_cjs_namespaceObject.handleAgentsApi)(ctx, createReq, new URL(createReq.url));
|
|
171
|
-
(0, external_vitest_namespaceObject.expect)(createRes?.ok).toBe(true);
|
|
172
|
-
const updateReq = new Request("http://localhost/api/agents/editor-agent", {
|
|
173
|
-
method: "PUT",
|
|
174
|
-
headers: {
|
|
175
|
-
"Content-Type": "application/json"
|
|
176
|
-
},
|
|
177
|
-
body: JSON.stringify({
|
|
178
|
-
reasoningEffort: "high",
|
|
179
|
-
promptTraining: false,
|
|
180
|
-
subAgents: [
|
|
181
|
-
{
|
|
182
|
-
id: "reviewer",
|
|
183
|
-
description: "Reviews output",
|
|
184
|
-
tools: [
|
|
185
|
-
"git_status"
|
|
186
|
-
],
|
|
187
|
-
prompt: "Review carefully.",
|
|
188
|
-
thinkingEffort: "medium",
|
|
189
|
-
promptTraining: {
|
|
190
|
-
enabled: true,
|
|
191
|
-
instructionsPath: "/memories/reviewer.md"
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
]
|
|
195
|
-
})
|
|
196
|
-
});
|
|
197
|
-
const updateRes = await (0, agents_cjs_namespaceObject.handleAgentsApi)(ctx, updateReq, new URL(updateReq.url));
|
|
198
|
-
(0, external_vitest_namespaceObject.expect)(updateRes).not.toBeNull();
|
|
199
|
-
if (updateRes && !updateRes.ok) throw new Error(await updateRes.text());
|
|
200
|
-
(0, external_vitest_namespaceObject.expect)(updateRes?.ok).toBe(true);
|
|
201
|
-
const updated = await updateRes.json();
|
|
202
|
-
(0, external_vitest_namespaceObject.expect)(updated.promptTraining).toBe(false);
|
|
203
|
-
(0, external_vitest_namespaceObject.expect)(updated.promptRefinement).toBe(false);
|
|
204
|
-
(0, external_vitest_namespaceObject.expect)(updated.reasoningEffort).toBe("high");
|
|
205
|
-
(0, external_vitest_namespaceObject.expect)(updated.subAgents).toHaveLength(1);
|
|
206
|
-
(0, external_vitest_namespaceObject.expect)(updated.subAgents[0].id).toBe("reviewer");
|
|
207
|
-
(0, external_vitest_namespaceObject.expect)(updated.subAgents[0].reasoningEffort).toBe("medium");
|
|
208
|
-
(0, external_vitest_namespaceObject.expect)(updated.subAgents[0].promptTraining).toEqual({
|
|
209
|
-
enabled: true,
|
|
210
|
-
instructionsPath: "/memories/reviewer.md"
|
|
211
|
-
});
|
|
212
|
-
const agentPath = (0, external_node_path_namespaceObject.join)(tempDir, "agents", "editor-agent", "agent.md");
|
|
213
|
-
const parsed = parseMarkdownAgent((0, external_node_fs_namespaceObject.readFileSync)(agentPath, "utf-8"));
|
|
214
|
-
(0, external_vitest_namespaceObject.expect)(parsed.metadata.promptRefinement).toBe(false);
|
|
215
|
-
(0, external_vitest_namespaceObject.expect)(parsed.metadata.reasoningEffort).toBe("high");
|
|
216
|
-
(0, external_vitest_namespaceObject.expect)(parsed.metadata.subAgents).toHaveLength(1);
|
|
217
|
-
(0, external_vitest_namespaceObject.expect)(parsed.metadata.subAgents[0].name).toBe("reviewer");
|
|
218
|
-
(0, external_vitest_namespaceObject.expect)(parsed.metadata.subAgents[0].reasoningEffort).toBe("medium");
|
|
219
|
-
(0, external_vitest_namespaceObject.expect)(parsed.metadata.subAgents[0].promptRefinement).toEqual({
|
|
220
|
-
enabled: true,
|
|
221
|
-
instructionsPath: "/memories/reviewer.md"
|
|
222
|
-
});
|
|
223
|
-
(0, external_vitest_namespaceObject.expect)(parsed.metadata.subAgents[0].systemPrompt).toBe("Review carefully.");
|
|
224
|
-
});
|
|
225
|
-
(0, external_vitest_namespaceObject.it)("accepts legacy promptRefinement input as promptTraining", async ()=>{
|
|
226
|
-
const createReq = new Request("http://localhost/api/agents", {
|
|
227
|
-
method: "POST",
|
|
228
|
-
headers: {
|
|
229
|
-
"Content-Type": "application/json"
|
|
230
|
-
},
|
|
231
|
-
body: JSON.stringify({
|
|
232
|
-
id: "legacy-agent",
|
|
233
|
-
tools: [
|
|
234
|
-
"think"
|
|
235
|
-
],
|
|
236
|
-
prompt: "Legacy prompt",
|
|
237
|
-
promptRefinement: true
|
|
238
|
-
})
|
|
239
|
-
});
|
|
240
|
-
const createRes = await (0, agents_cjs_namespaceObject.handleAgentsApi)(ctx, createReq, new URL(createReq.url));
|
|
241
|
-
(0, external_vitest_namespaceObject.expect)(createRes).not.toBeNull();
|
|
242
|
-
(0, external_vitest_namespaceObject.expect)(createRes?.ok).toBe(true);
|
|
243
|
-
const created = await createRes.json();
|
|
244
|
-
(0, external_vitest_namespaceObject.expect)(created.promptTraining).toBe(true);
|
|
245
|
-
(0, external_vitest_namespaceObject.expect)(created.promptRefinement).toBe(true);
|
|
246
|
-
});
|
|
247
|
-
(0, external_vitest_namespaceObject.it)("accepts legacy thinkingEffort input as reasoningEffort", async ()=>{
|
|
248
|
-
const createReq = new Request("http://localhost/api/agents", {
|
|
249
|
-
method: "POST",
|
|
250
|
-
headers: {
|
|
251
|
-
"Content-Type": "application/json"
|
|
252
|
-
},
|
|
253
|
-
body: JSON.stringify({
|
|
254
|
-
id: "legacy-thinking-agent",
|
|
255
|
-
tools: [
|
|
256
|
-
"think"
|
|
257
|
-
],
|
|
258
|
-
prompt: "Legacy thinking prompt",
|
|
259
|
-
thinkingEffort: "medium"
|
|
260
|
-
})
|
|
261
|
-
});
|
|
262
|
-
const createRes = await (0, agents_cjs_namespaceObject.handleAgentsApi)(ctx, createReq, new URL(createReq.url));
|
|
263
|
-
(0, external_vitest_namespaceObject.expect)(createRes).not.toBeNull();
|
|
264
|
-
(0, external_vitest_namespaceObject.expect)(createRes?.ok).toBe(true);
|
|
265
|
-
const created = await createRes.json();
|
|
266
|
-
(0, external_vitest_namespaceObject.expect)(created.reasoningEffort).toBe("medium");
|
|
267
|
-
});
|
|
268
|
-
(0, external_vitest_namespaceObject.it)("includes effective MCP server names in list and detail responses", async ()=>{
|
|
269
|
-
config = {
|
|
270
|
-
...config,
|
|
271
|
-
mcp: {
|
|
272
|
-
servers: [
|
|
273
|
-
{
|
|
274
|
-
name: "global-finance",
|
|
275
|
-
transport: "sse",
|
|
276
|
-
url: "http://localhost:8900/mcp"
|
|
277
|
-
}
|
|
278
|
-
]
|
|
279
|
-
},
|
|
280
|
-
agents: {
|
|
281
|
-
list: [
|
|
282
|
-
{
|
|
283
|
-
id: "mcp-agent",
|
|
284
|
-
name: "MCP Agent"
|
|
285
|
-
}
|
|
286
|
-
],
|
|
287
|
-
bindings: []
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
const agentDir = (0, external_node_path_namespaceObject.join)(tempDir, "agents", "mcp-agent");
|
|
291
|
-
(0, external_node_fs_namespaceObject.mkdirSync)(agentDir, {
|
|
292
|
-
recursive: true
|
|
293
|
-
});
|
|
294
|
-
(0, external_node_fs_namespaceObject.writeFileSync)((0, external_node_path_namespaceObject.join)(agentDir, "agent.md"), "---\nname: mcp-agent\ndescription: MCP aware\ntools:\n - think\nmcp:\n servers:\n - name: local-fal\n transport: sse\n url: http://localhost:8800/mcp\n - name: global-finance\n transport: sse\n url: http://localhost:8900/mcp\nmcpUseGlobal: true\n---\n\nYou are MCP aware.\n");
|
|
295
|
-
const listReq = new Request("http://localhost/api/agents", {
|
|
296
|
-
method: "GET"
|
|
297
|
-
});
|
|
298
|
-
const listRes = await (0, agents_cjs_namespaceObject.handleAgentsApi)(ctx, listReq, new URL(listReq.url));
|
|
299
|
-
(0, external_vitest_namespaceObject.expect)(listRes?.ok).toBe(true);
|
|
300
|
-
const listPayload = await listRes.json();
|
|
301
|
-
const listed = listPayload.agents.find((agent)=>"mcp-agent" === agent.id);
|
|
302
|
-
(0, external_vitest_namespaceObject.expect)(listed).toBeTruthy();
|
|
303
|
-
(0, external_vitest_namespaceObject.expect)(listed?.mcpUseGlobal).toBe(true);
|
|
304
|
-
(0, external_vitest_namespaceObject.expect)(listed?.mcpServers).toEqual([
|
|
305
|
-
"local-fal",
|
|
306
|
-
"global-finance"
|
|
307
|
-
]);
|
|
308
|
-
const detailReq = new Request("http://localhost/api/agents/mcp-agent", {
|
|
309
|
-
method: "GET"
|
|
310
|
-
});
|
|
311
|
-
const detailRes = await (0, agents_cjs_namespaceObject.handleAgentsApi)(ctx, detailReq, new URL(detailReq.url));
|
|
312
|
-
(0, external_vitest_namespaceObject.expect)(detailRes?.ok).toBe(true);
|
|
313
|
-
const detail = await detailRes.json();
|
|
314
|
-
(0, external_vitest_namespaceObject.expect)(detail.mcpUseGlobal).toBe(true);
|
|
315
|
-
(0, external_vitest_namespaceObject.expect)(detail.mcpServers).toEqual([
|
|
316
|
-
"local-fal",
|
|
317
|
-
"global-finance"
|
|
318
|
-
]);
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
322
|
-
Object.defineProperty(exports, '__esModule', {
|
|
323
|
-
value: true
|
|
324
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { load } from "js-yaml";
|
|
5
|
-
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
6
|
-
import { handleAgentsApi } from "../gateway/http/agents.js";
|
|
7
|
-
const isBunRuntime = void 0 !== globalThis.Bun;
|
|
8
|
-
const describeIfBun = isBunRuntime ? describe : describe.skip;
|
|
9
|
-
const parseMarkdownAgent = (raw)=>{
|
|
10
|
-
const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/;
|
|
11
|
-
const match = raw.match(frontmatterRegex);
|
|
12
|
-
if (!match) throw new Error("Agent markdown is missing frontmatter");
|
|
13
|
-
const metadata = load(match[1]) || {};
|
|
14
|
-
return {
|
|
15
|
-
metadata,
|
|
16
|
-
prompt: match[2].trim()
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
describeIfBun("agents API", ()=>{
|
|
20
|
-
let tempDir;
|
|
21
|
-
let config;
|
|
22
|
-
let ctx;
|
|
23
|
-
beforeEach(()=>{
|
|
24
|
-
tempDir = mkdtempSync(join(tmpdir(), "wingman-agents-api-"));
|
|
25
|
-
config = {
|
|
26
|
-
agents: {
|
|
27
|
-
list: [],
|
|
28
|
-
bindings: []
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
ctx = {
|
|
32
|
-
workspace: tempDir,
|
|
33
|
-
configDir: tempDir,
|
|
34
|
-
getWingmanConfig: ()=>config,
|
|
35
|
-
setWingmanConfig: (next)=>{
|
|
36
|
-
config = next;
|
|
37
|
-
},
|
|
38
|
-
persistWingmanConfig: ()=>{},
|
|
39
|
-
router: {},
|
|
40
|
-
setRouter: ()=>{},
|
|
41
|
-
resolveConfigDirPath: ()=>tempDir,
|
|
42
|
-
getBuiltInTools: ()=>[]
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
afterEach(()=>{
|
|
46
|
-
rmSync(tempDir, {
|
|
47
|
-
recursive: true,
|
|
48
|
-
force: true
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
it("creates agent markdown with promptTraining and subAgents", async ()=>{
|
|
52
|
-
const createReq = new Request("http://localhost/api/agents", {
|
|
53
|
-
method: "POST",
|
|
54
|
-
headers: {
|
|
55
|
-
"Content-Type": "application/json"
|
|
56
|
-
},
|
|
57
|
-
body: JSON.stringify({
|
|
58
|
-
id: "orchestrator",
|
|
59
|
-
displayName: "Orchestrator",
|
|
60
|
-
description: "Delegates work",
|
|
61
|
-
tools: [
|
|
62
|
-
"think",
|
|
63
|
-
"not_real_tool"
|
|
64
|
-
],
|
|
65
|
-
prompt: "You are the orchestrator.",
|
|
66
|
-
reasoningEffort: "high",
|
|
67
|
-
promptTraining: {
|
|
68
|
-
enabled: true,
|
|
69
|
-
instructionsPath: "/memories/agents/orchestrator/instructions.md"
|
|
70
|
-
},
|
|
71
|
-
subAgents: [
|
|
72
|
-
{
|
|
73
|
-
id: "planner",
|
|
74
|
-
description: "Plans tasks",
|
|
75
|
-
tools: [
|
|
76
|
-
"think",
|
|
77
|
-
"not_real_tool"
|
|
78
|
-
],
|
|
79
|
-
prompt: "Plan tasks in detail.",
|
|
80
|
-
reasoningEffort: "low",
|
|
81
|
-
promptTraining: true
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
id: "executor",
|
|
85
|
-
description: "Executes tasks",
|
|
86
|
-
tools: [
|
|
87
|
-
"command_execute"
|
|
88
|
-
],
|
|
89
|
-
prompt: "Execute planned tasks.",
|
|
90
|
-
thinkingEffort: "minimal"
|
|
91
|
-
}
|
|
92
|
-
]
|
|
93
|
-
})
|
|
94
|
-
});
|
|
95
|
-
const createRes = await handleAgentsApi(ctx, createReq, new URL(createReq.url));
|
|
96
|
-
expect(createRes).not.toBeNull();
|
|
97
|
-
expect(createRes?.ok).toBe(true);
|
|
98
|
-
const created = await createRes.json();
|
|
99
|
-
expect(created.promptTraining).toEqual({
|
|
100
|
-
enabled: true,
|
|
101
|
-
instructionsPath: "/memories/agents/orchestrator/instructions.md"
|
|
102
|
-
});
|
|
103
|
-
expect(created.reasoningEffort).toBe("high");
|
|
104
|
-
expect(created.promptRefinement).toEqual(created.promptTraining);
|
|
105
|
-
expect(created.subAgents).toHaveLength(2);
|
|
106
|
-
expect(created.subAgents[0].promptTraining).toBe(true);
|
|
107
|
-
expect(created.subAgents[0].tools).toEqual([
|
|
108
|
-
"think"
|
|
109
|
-
]);
|
|
110
|
-
expect(created.subAgents[0].reasoningEffort).toBe("low");
|
|
111
|
-
expect(created.subAgents[1].reasoningEffort).toBe("minimal");
|
|
112
|
-
const agentPath = join(tempDir, "agents", "orchestrator", "agent.md");
|
|
113
|
-
const parsed = parseMarkdownAgent(readFileSync(agentPath, "utf-8"));
|
|
114
|
-
expect(parsed.prompt).toBe("You are the orchestrator.");
|
|
115
|
-
expect(parsed.metadata.promptRefinement).toEqual({
|
|
116
|
-
enabled: true,
|
|
117
|
-
instructionsPath: "/memories/agents/orchestrator/instructions.md"
|
|
118
|
-
});
|
|
119
|
-
expect(parsed.metadata.reasoningEffort).toBe("high");
|
|
120
|
-
expect(parsed.metadata.subAgents).toHaveLength(2);
|
|
121
|
-
expect(parsed.metadata.subAgents[0].name).toBe("planner");
|
|
122
|
-
expect(parsed.metadata.subAgents[0].reasoningEffort).toBe("low");
|
|
123
|
-
expect(parsed.metadata.subAgents[0].promptRefinement).toBe(true);
|
|
124
|
-
expect(parsed.metadata.subAgents[0].systemPrompt).toBe("Plan tasks in detail.");
|
|
125
|
-
expect(parsed.metadata.subAgents[1].reasoningEffort).toBe("minimal");
|
|
126
|
-
const detailReq = new Request("http://localhost/api/agents/orchestrator", {
|
|
127
|
-
method: "GET"
|
|
128
|
-
});
|
|
129
|
-
const detailRes = await handleAgentsApi(ctx, detailReq, new URL(detailReq.url));
|
|
130
|
-
expect(detailRes).not.toBeNull();
|
|
131
|
-
expect(detailRes?.ok).toBe(true);
|
|
132
|
-
const detail = await detailRes.json();
|
|
133
|
-
expect(detail.promptTraining).toEqual(created.promptTraining);
|
|
134
|
-
expect(detail.promptRefinement).toEqual(created.promptTraining);
|
|
135
|
-
expect(detail.reasoningEffort).toBe("high");
|
|
136
|
-
expect(detail.subAgents).toHaveLength(2);
|
|
137
|
-
expect(detail.subAgents[0].id).toBe("planner");
|
|
138
|
-
expect(detail.subAgents[0].prompt).toBe("Plan tasks in detail.");
|
|
139
|
-
expect(detail.subAgents[0].reasoningEffort).toBe("low");
|
|
140
|
-
});
|
|
141
|
-
it("updates promptTraining and subAgents in markdown", async ()=>{
|
|
142
|
-
const createReq = new Request("http://localhost/api/agents", {
|
|
143
|
-
method: "POST",
|
|
144
|
-
headers: {
|
|
145
|
-
"Content-Type": "application/json"
|
|
146
|
-
},
|
|
147
|
-
body: JSON.stringify({
|
|
148
|
-
id: "editor-agent",
|
|
149
|
-
tools: [
|
|
150
|
-
"think"
|
|
151
|
-
],
|
|
152
|
-
prompt: "Original prompt",
|
|
153
|
-
reasoningEffort: "low",
|
|
154
|
-
promptTraining: true,
|
|
155
|
-
subAgents: [
|
|
156
|
-
{
|
|
157
|
-
id: "planner",
|
|
158
|
-
description: "Plans",
|
|
159
|
-
tools: [
|
|
160
|
-
"think"
|
|
161
|
-
],
|
|
162
|
-
prompt: "Original planner prompt",
|
|
163
|
-
reasoningEffort: "minimal"
|
|
164
|
-
}
|
|
165
|
-
]
|
|
166
|
-
})
|
|
167
|
-
});
|
|
168
|
-
const createRes = await handleAgentsApi(ctx, createReq, new URL(createReq.url));
|
|
169
|
-
expect(createRes?.ok).toBe(true);
|
|
170
|
-
const updateReq = new Request("http://localhost/api/agents/editor-agent", {
|
|
171
|
-
method: "PUT",
|
|
172
|
-
headers: {
|
|
173
|
-
"Content-Type": "application/json"
|
|
174
|
-
},
|
|
175
|
-
body: JSON.stringify({
|
|
176
|
-
reasoningEffort: "high",
|
|
177
|
-
promptTraining: false,
|
|
178
|
-
subAgents: [
|
|
179
|
-
{
|
|
180
|
-
id: "reviewer",
|
|
181
|
-
description: "Reviews output",
|
|
182
|
-
tools: [
|
|
183
|
-
"git_status"
|
|
184
|
-
],
|
|
185
|
-
prompt: "Review carefully.",
|
|
186
|
-
thinkingEffort: "medium",
|
|
187
|
-
promptTraining: {
|
|
188
|
-
enabled: true,
|
|
189
|
-
instructionsPath: "/memories/reviewer.md"
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
]
|
|
193
|
-
})
|
|
194
|
-
});
|
|
195
|
-
const updateRes = await handleAgentsApi(ctx, updateReq, new URL(updateReq.url));
|
|
196
|
-
expect(updateRes).not.toBeNull();
|
|
197
|
-
if (updateRes && !updateRes.ok) throw new Error(await updateRes.text());
|
|
198
|
-
expect(updateRes?.ok).toBe(true);
|
|
199
|
-
const updated = await updateRes.json();
|
|
200
|
-
expect(updated.promptTraining).toBe(false);
|
|
201
|
-
expect(updated.promptRefinement).toBe(false);
|
|
202
|
-
expect(updated.reasoningEffort).toBe("high");
|
|
203
|
-
expect(updated.subAgents).toHaveLength(1);
|
|
204
|
-
expect(updated.subAgents[0].id).toBe("reviewer");
|
|
205
|
-
expect(updated.subAgents[0].reasoningEffort).toBe("medium");
|
|
206
|
-
expect(updated.subAgents[0].promptTraining).toEqual({
|
|
207
|
-
enabled: true,
|
|
208
|
-
instructionsPath: "/memories/reviewer.md"
|
|
209
|
-
});
|
|
210
|
-
const agentPath = join(tempDir, "agents", "editor-agent", "agent.md");
|
|
211
|
-
const parsed = parseMarkdownAgent(readFileSync(agentPath, "utf-8"));
|
|
212
|
-
expect(parsed.metadata.promptRefinement).toBe(false);
|
|
213
|
-
expect(parsed.metadata.reasoningEffort).toBe("high");
|
|
214
|
-
expect(parsed.metadata.subAgents).toHaveLength(1);
|
|
215
|
-
expect(parsed.metadata.subAgents[0].name).toBe("reviewer");
|
|
216
|
-
expect(parsed.metadata.subAgents[0].reasoningEffort).toBe("medium");
|
|
217
|
-
expect(parsed.metadata.subAgents[0].promptRefinement).toEqual({
|
|
218
|
-
enabled: true,
|
|
219
|
-
instructionsPath: "/memories/reviewer.md"
|
|
220
|
-
});
|
|
221
|
-
expect(parsed.metadata.subAgents[0].systemPrompt).toBe("Review carefully.");
|
|
222
|
-
});
|
|
223
|
-
it("accepts legacy promptRefinement input as promptTraining", async ()=>{
|
|
224
|
-
const createReq = new Request("http://localhost/api/agents", {
|
|
225
|
-
method: "POST",
|
|
226
|
-
headers: {
|
|
227
|
-
"Content-Type": "application/json"
|
|
228
|
-
},
|
|
229
|
-
body: JSON.stringify({
|
|
230
|
-
id: "legacy-agent",
|
|
231
|
-
tools: [
|
|
232
|
-
"think"
|
|
233
|
-
],
|
|
234
|
-
prompt: "Legacy prompt",
|
|
235
|
-
promptRefinement: true
|
|
236
|
-
})
|
|
237
|
-
});
|
|
238
|
-
const createRes = await handleAgentsApi(ctx, createReq, new URL(createReq.url));
|
|
239
|
-
expect(createRes).not.toBeNull();
|
|
240
|
-
expect(createRes?.ok).toBe(true);
|
|
241
|
-
const created = await createRes.json();
|
|
242
|
-
expect(created.promptTraining).toBe(true);
|
|
243
|
-
expect(created.promptRefinement).toBe(true);
|
|
244
|
-
});
|
|
245
|
-
it("accepts legacy thinkingEffort input as reasoningEffort", async ()=>{
|
|
246
|
-
const createReq = new Request("http://localhost/api/agents", {
|
|
247
|
-
method: "POST",
|
|
248
|
-
headers: {
|
|
249
|
-
"Content-Type": "application/json"
|
|
250
|
-
},
|
|
251
|
-
body: JSON.stringify({
|
|
252
|
-
id: "legacy-thinking-agent",
|
|
253
|
-
tools: [
|
|
254
|
-
"think"
|
|
255
|
-
],
|
|
256
|
-
prompt: "Legacy thinking prompt",
|
|
257
|
-
thinkingEffort: "medium"
|
|
258
|
-
})
|
|
259
|
-
});
|
|
260
|
-
const createRes = await handleAgentsApi(ctx, createReq, new URL(createReq.url));
|
|
261
|
-
expect(createRes).not.toBeNull();
|
|
262
|
-
expect(createRes?.ok).toBe(true);
|
|
263
|
-
const created = await createRes.json();
|
|
264
|
-
expect(created.reasoningEffort).toBe("medium");
|
|
265
|
-
});
|
|
266
|
-
it("includes effective MCP server names in list and detail responses", async ()=>{
|
|
267
|
-
config = {
|
|
268
|
-
...config,
|
|
269
|
-
mcp: {
|
|
270
|
-
servers: [
|
|
271
|
-
{
|
|
272
|
-
name: "global-finance",
|
|
273
|
-
transport: "sse",
|
|
274
|
-
url: "http://localhost:8900/mcp"
|
|
275
|
-
}
|
|
276
|
-
]
|
|
277
|
-
},
|
|
278
|
-
agents: {
|
|
279
|
-
list: [
|
|
280
|
-
{
|
|
281
|
-
id: "mcp-agent",
|
|
282
|
-
name: "MCP Agent"
|
|
283
|
-
}
|
|
284
|
-
],
|
|
285
|
-
bindings: []
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
const agentDir = join(tempDir, "agents", "mcp-agent");
|
|
289
|
-
mkdirSync(agentDir, {
|
|
290
|
-
recursive: true
|
|
291
|
-
});
|
|
292
|
-
writeFileSync(join(agentDir, "agent.md"), "---\nname: mcp-agent\ndescription: MCP aware\ntools:\n - think\nmcp:\n servers:\n - name: local-fal\n transport: sse\n url: http://localhost:8800/mcp\n - name: global-finance\n transport: sse\n url: http://localhost:8900/mcp\nmcpUseGlobal: true\n---\n\nYou are MCP aware.\n");
|
|
293
|
-
const listReq = new Request("http://localhost/api/agents", {
|
|
294
|
-
method: "GET"
|
|
295
|
-
});
|
|
296
|
-
const listRes = await handleAgentsApi(ctx, listReq, new URL(listReq.url));
|
|
297
|
-
expect(listRes?.ok).toBe(true);
|
|
298
|
-
const listPayload = await listRes.json();
|
|
299
|
-
const listed = listPayload.agents.find((agent)=>"mcp-agent" === agent.id);
|
|
300
|
-
expect(listed).toBeTruthy();
|
|
301
|
-
expect(listed?.mcpUseGlobal).toBe(true);
|
|
302
|
-
expect(listed?.mcpServers).toEqual([
|
|
303
|
-
"local-fal",
|
|
304
|
-
"global-finance"
|
|
305
|
-
]);
|
|
306
|
-
const detailReq = new Request("http://localhost/api/agents/mcp-agent", {
|
|
307
|
-
method: "GET"
|
|
308
|
-
});
|
|
309
|
-
const detailRes = await handleAgentsApi(ctx, detailReq, new URL(detailReq.url));
|
|
310
|
-
expect(detailRes?.ok).toBe(true);
|
|
311
|
-
const detail = await detailRes.json();
|
|
312
|
-
expect(detail.mcpUseGlobal).toBe(true);
|
|
313
|
-
expect(detail.mcpServers).toEqual([
|
|
314
|
-
"local-fal",
|
|
315
|
-
"global-finance"
|
|
316
|
-
]);
|
|
317
|
-
});
|
|
318
|
-
});
|