@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,71 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { getAvailableTools } from "../agent/config/toolRegistry.js";
|
|
3
|
-
import { createNodeNotifyTool, createNodeRunTool } from "../agent/tools/node_invoke.js";
|
|
4
|
-
describe("node tools", ()=>{
|
|
5
|
-
it("exposes node tools in available tool names", ()=>{
|
|
6
|
-
const tools = getAvailableTools();
|
|
7
|
-
expect(tools).toContain("node_notify");
|
|
8
|
-
expect(tools).toContain("node_run");
|
|
9
|
-
});
|
|
10
|
-
it("routes node_notify through the injected node invoker", async ()=>{
|
|
11
|
-
const nodeInvoker = vi.fn(async ()=>({
|
|
12
|
-
nodeId: "node-123",
|
|
13
|
-
payload: {
|
|
14
|
-
delivered: true
|
|
15
|
-
}
|
|
16
|
-
}));
|
|
17
|
-
const tool = createNodeNotifyTool({
|
|
18
|
-
nodeInvoker,
|
|
19
|
-
defaultTargetClientId: "desktop-abc"
|
|
20
|
-
});
|
|
21
|
-
const result = await tool.invoke({
|
|
22
|
-
body: "Build finished"
|
|
23
|
-
});
|
|
24
|
-
expect(result.ok).toBe(true);
|
|
25
|
-
expect(result.nodeId).toBe("node-123");
|
|
26
|
-
expect(result.delivered).toBe(true);
|
|
27
|
-
expect(nodeInvoker).toHaveBeenCalledWith(expect.objectContaining({
|
|
28
|
-
tool: "system.notify",
|
|
29
|
-
targetClientId: "desktop-abc"
|
|
30
|
-
}));
|
|
31
|
-
});
|
|
32
|
-
it("returns command result fields from node_run", async ()=>{
|
|
33
|
-
const nodeInvoker = vi.fn(async ()=>({
|
|
34
|
-
nodeId: "node-789",
|
|
35
|
-
payload: {
|
|
36
|
-
exitCode: 0,
|
|
37
|
-
stdout: "ok",
|
|
38
|
-
stderr: ""
|
|
39
|
-
}
|
|
40
|
-
}));
|
|
41
|
-
const tool = createNodeRunTool({
|
|
42
|
-
nodeInvoker
|
|
43
|
-
});
|
|
44
|
-
const result = await tool.invoke({
|
|
45
|
-
command: "/bin/echo",
|
|
46
|
-
args: [
|
|
47
|
-
"hello"
|
|
48
|
-
],
|
|
49
|
-
target: {
|
|
50
|
-
nodeId: "node-789"
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
expect(result.ok).toBe(true);
|
|
54
|
-
expect(result.nodeId).toBe("node-789");
|
|
55
|
-
expect(result.exitCode).toBe(0);
|
|
56
|
-
expect(result.stdout).toBe("ok");
|
|
57
|
-
expect(result.stderr).toBe("");
|
|
58
|
-
expect(nodeInvoker).toHaveBeenCalledWith(expect.objectContaining({
|
|
59
|
-
tool: "system.run",
|
|
60
|
-
targetNodeId: "node-789"
|
|
61
|
-
}));
|
|
62
|
-
});
|
|
63
|
-
it("returns an availability error outside gateway runtime", async ()=>{
|
|
64
|
-
const tool = createNodeRunTool();
|
|
65
|
-
const result = await tool.invoke({
|
|
66
|
-
command: "pwd"
|
|
67
|
-
});
|
|
68
|
-
expect(result.ok).toBe(false);
|
|
69
|
-
expect(result.error).toContain("only available");
|
|
70
|
-
});
|
|
71
|
-
});
|
|
@@ -1,86 +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_vitest_namespaceObject = require("vitest");
|
|
7
|
-
const nodes_cjs_namespaceObject = require("../gateway/http/nodes.cjs");
|
|
8
|
-
(0, external_vitest_namespaceObject.describe)("node approvals api", ()=>{
|
|
9
|
-
let tempDir = null;
|
|
10
|
-
(0, external_vitest_namespaceObject.afterEach)(()=>{
|
|
11
|
-
if (tempDir) {
|
|
12
|
-
(0, external_node_fs_namespaceObject.rmSync)(tempDir, {
|
|
13
|
-
recursive: true,
|
|
14
|
-
force: true
|
|
15
|
-
});
|
|
16
|
-
tempDir = null;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
(0, external_vitest_namespaceObject.it)("persists and updates node approval records", ()=>{
|
|
20
|
-
tempDir = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-node-store-"));
|
|
21
|
-
const store = (0, nodes_cjs_namespaceObject.createNodeApprovalStore)(()=>tempDir);
|
|
22
|
-
(0, external_vitest_namespaceObject.expect)(store.isEnabled("desktop-a")).toBe(false);
|
|
23
|
-
const enabled = store.setEnabled("desktop-a", true, "Desktop A", Date.now());
|
|
24
|
-
(0, external_vitest_namespaceObject.expect)(enabled.enabled).toBe(true);
|
|
25
|
-
(0, external_vitest_namespaceObject.expect)(store.isEnabled("desktop-a")).toBe(true);
|
|
26
|
-
const marked = store.markSeen("desktop-a", "Desktop A (Renamed)");
|
|
27
|
-
(0, external_vitest_namespaceObject.expect)(marked?.name).toBe("Desktop A (Renamed)");
|
|
28
|
-
(0, external_vitest_namespaceObject.expect)(marked?.lastSeenAt).toBeTypeOf("number");
|
|
29
|
-
const disabled = store.setEnabled("desktop-a", false);
|
|
30
|
-
(0, external_vitest_namespaceObject.expect)(disabled.enabled).toBe(false);
|
|
31
|
-
(0, external_vitest_namespaceObject.expect)(store.isEnabled("desktop-a")).toBe(false);
|
|
32
|
-
});
|
|
33
|
-
(0, external_vitest_namespaceObject.it)("enables and revokes nodes through the HTTP handler", async ()=>{
|
|
34
|
-
tempDir = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-node-api-"));
|
|
35
|
-
const store = (0, nodes_cjs_namespaceObject.createNodeApprovalStore)(()=>tempDir);
|
|
36
|
-
const activeNodes = [
|
|
37
|
-
{
|
|
38
|
-
id: "node-1",
|
|
39
|
-
name: "Desktop Node",
|
|
40
|
-
clientId: "desktop-a",
|
|
41
|
-
capabilities: [
|
|
42
|
-
"system.notify"
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
];
|
|
46
|
-
const nodeManager = {
|
|
47
|
-
getAllNodes: ()=>activeNodes,
|
|
48
|
-
getNodesByClientId: (clientId)=>activeNodes.filter((node)=>node.clientId === clientId),
|
|
49
|
-
unregisterNode: (nodeId)=>{
|
|
50
|
-
const index = activeNodes.findIndex((node)=>node.id === nodeId);
|
|
51
|
-
if (-1 === index) return false;
|
|
52
|
-
activeNodes.splice(index, 1);
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const enableResponse = await (0, nodes_cjs_namespaceObject.handleNodesApi)({}, nodeManager, store, new Request("http://localhost/api/nodes/desktop-a", {
|
|
57
|
-
method: "PUT",
|
|
58
|
-
headers: {
|
|
59
|
-
"Content-Type": "application/json"
|
|
60
|
-
},
|
|
61
|
-
body: JSON.stringify({
|
|
62
|
-
enabled: true,
|
|
63
|
-
name: "Desktop A"
|
|
64
|
-
})
|
|
65
|
-
}), new URL("http://localhost/api/nodes/desktop-a"));
|
|
66
|
-
(0, external_vitest_namespaceObject.expect)(enableResponse?.status).toBe(200);
|
|
67
|
-
const listResponse = await (0, nodes_cjs_namespaceObject.handleNodesApi)({}, nodeManager, store, new Request("http://localhost/api/nodes", {
|
|
68
|
-
method: "GET"
|
|
69
|
-
}), new URL("http://localhost/api/nodes"));
|
|
70
|
-
(0, external_vitest_namespaceObject.expect)(listResponse?.status).toBe(200);
|
|
71
|
-
const listed = await listResponse?.json();
|
|
72
|
-
(0, external_vitest_namespaceObject.expect)(listed.nodes[0]?.clientId).toBe("desktop-a");
|
|
73
|
-
(0, external_vitest_namespaceObject.expect)(listed.nodes[0]?.enabled).toBe(true);
|
|
74
|
-
(0, external_vitest_namespaceObject.expect)(listed.nodes[0]?.connected).toBe(true);
|
|
75
|
-
const revokeResponse = await (0, nodes_cjs_namespaceObject.handleNodesApi)({}, nodeManager, store, new Request("http://localhost/api/nodes/desktop-a", {
|
|
76
|
-
method: "DELETE"
|
|
77
|
-
}), new URL("http://localhost/api/nodes/desktop-a"));
|
|
78
|
-
(0, external_vitest_namespaceObject.expect)(revokeResponse?.status).toBe(200);
|
|
79
|
-
(0, external_vitest_namespaceObject.expect)(activeNodes.length).toBe(0);
|
|
80
|
-
(0, external_vitest_namespaceObject.expect)(store.isEnabled("desktop-a")).toBe(false);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
84
|
-
Object.defineProperty(exports, '__esModule', {
|
|
85
|
-
value: true
|
|
86
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { mkdtempSync, rmSync } from "node:fs";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { afterEach, describe, expect, it } from "vitest";
|
|
5
|
-
import { createNodeApprovalStore, handleNodesApi } from "../gateway/http/nodes.js";
|
|
6
|
-
describe("node approvals api", ()=>{
|
|
7
|
-
let tempDir = null;
|
|
8
|
-
afterEach(()=>{
|
|
9
|
-
if (tempDir) {
|
|
10
|
-
rmSync(tempDir, {
|
|
11
|
-
recursive: true,
|
|
12
|
-
force: true
|
|
13
|
-
});
|
|
14
|
-
tempDir = null;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
it("persists and updates node approval records", ()=>{
|
|
18
|
-
tempDir = mkdtempSync(join(tmpdir(), "wingman-node-store-"));
|
|
19
|
-
const store = createNodeApprovalStore(()=>tempDir);
|
|
20
|
-
expect(store.isEnabled("desktop-a")).toBe(false);
|
|
21
|
-
const enabled = store.setEnabled("desktop-a", true, "Desktop A", Date.now());
|
|
22
|
-
expect(enabled.enabled).toBe(true);
|
|
23
|
-
expect(store.isEnabled("desktop-a")).toBe(true);
|
|
24
|
-
const marked = store.markSeen("desktop-a", "Desktop A (Renamed)");
|
|
25
|
-
expect(marked?.name).toBe("Desktop A (Renamed)");
|
|
26
|
-
expect(marked?.lastSeenAt).toBeTypeOf("number");
|
|
27
|
-
const disabled = store.setEnabled("desktop-a", false);
|
|
28
|
-
expect(disabled.enabled).toBe(false);
|
|
29
|
-
expect(store.isEnabled("desktop-a")).toBe(false);
|
|
30
|
-
});
|
|
31
|
-
it("enables and revokes nodes through the HTTP handler", async ()=>{
|
|
32
|
-
tempDir = mkdtempSync(join(tmpdir(), "wingman-node-api-"));
|
|
33
|
-
const store = createNodeApprovalStore(()=>tempDir);
|
|
34
|
-
const activeNodes = [
|
|
35
|
-
{
|
|
36
|
-
id: "node-1",
|
|
37
|
-
name: "Desktop Node",
|
|
38
|
-
clientId: "desktop-a",
|
|
39
|
-
capabilities: [
|
|
40
|
-
"system.notify"
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
];
|
|
44
|
-
const nodeManager = {
|
|
45
|
-
getAllNodes: ()=>activeNodes,
|
|
46
|
-
getNodesByClientId: (clientId)=>activeNodes.filter((node)=>node.clientId === clientId),
|
|
47
|
-
unregisterNode: (nodeId)=>{
|
|
48
|
-
const index = activeNodes.findIndex((node)=>node.id === nodeId);
|
|
49
|
-
if (-1 === index) return false;
|
|
50
|
-
activeNodes.splice(index, 1);
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const enableResponse = await handleNodesApi({}, nodeManager, store, new Request("http://localhost/api/nodes/desktop-a", {
|
|
55
|
-
method: "PUT",
|
|
56
|
-
headers: {
|
|
57
|
-
"Content-Type": "application/json"
|
|
58
|
-
},
|
|
59
|
-
body: JSON.stringify({
|
|
60
|
-
enabled: true,
|
|
61
|
-
name: "Desktop A"
|
|
62
|
-
})
|
|
63
|
-
}), new URL("http://localhost/api/nodes/desktop-a"));
|
|
64
|
-
expect(enableResponse?.status).toBe(200);
|
|
65
|
-
const listResponse = await handleNodesApi({}, nodeManager, store, new Request("http://localhost/api/nodes", {
|
|
66
|
-
method: "GET"
|
|
67
|
-
}), new URL("http://localhost/api/nodes"));
|
|
68
|
-
expect(listResponse?.status).toBe(200);
|
|
69
|
-
const listed = await listResponse?.json();
|
|
70
|
-
expect(listed.nodes[0]?.clientId).toBe("desktop-a");
|
|
71
|
-
expect(listed.nodes[0]?.enabled).toBe(true);
|
|
72
|
-
expect(listed.nodes[0]?.connected).toBe(true);
|
|
73
|
-
const revokeResponse = await handleNodesApi({}, nodeManager, store, new Request("http://localhost/api/nodes/desktop-a", {
|
|
74
|
-
method: "DELETE"
|
|
75
|
-
}), new URL("http://localhost/api/nodes/desktop-a"));
|
|
76
|
-
expect(revokeResponse?.status).toBe(200);
|
|
77
|
-
expect(activeNodes.length).toBe(0);
|
|
78
|
-
expect(store.isEnabled("desktop-a")).toBe(false);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_exports__ = {};
|
|
3
|
-
const external_vitest_namespaceObject = require("vitest");
|
|
4
|
-
const outputManager_cjs_namespaceObject = require("../cli/core/outputManager.cjs");
|
|
5
|
-
(0, external_vitest_namespaceObject.describe)("OutputManager context summarized events", ()=>{
|
|
6
|
-
(0, external_vitest_namespaceObject.it)("emits context-summarizing metadata in interactive mode", ()=>{
|
|
7
|
-
const outputManager = new outputManager_cjs_namespaceObject.OutputManager("interactive");
|
|
8
|
-
const events = [];
|
|
9
|
-
outputManager.on("output-event", (event)=>{
|
|
10
|
-
events.push(event);
|
|
11
|
-
});
|
|
12
|
-
outputManager.emitContextSummarizing();
|
|
13
|
-
(0, external_vitest_namespaceObject.expect)(events).toHaveLength(1);
|
|
14
|
-
(0, external_vitest_namespaceObject.expect)(events[0]).toMatchObject({
|
|
15
|
-
type: "context-summarizing"
|
|
16
|
-
});
|
|
17
|
-
(0, external_vitest_namespaceObject.expect)(typeof events[0]?.timestamp).toBe("string");
|
|
18
|
-
});
|
|
19
|
-
(0, external_vitest_namespaceObject.it)("emits context-summarized metadata in interactive mode", ()=>{
|
|
20
|
-
const outputManager = new outputManager_cjs_namespaceObject.OutputManager("interactive");
|
|
21
|
-
const events = [];
|
|
22
|
-
outputManager.on("output-event", (event)=>{
|
|
23
|
-
events.push(event);
|
|
24
|
-
});
|
|
25
|
-
outputManager.emitContextSummarized({
|
|
26
|
-
inputTokens: 5400,
|
|
27
|
-
peakInputTokens: 11200,
|
|
28
|
-
thresholdTokens: 12000
|
|
29
|
-
});
|
|
30
|
-
(0, external_vitest_namespaceObject.expect)(events).toHaveLength(1);
|
|
31
|
-
(0, external_vitest_namespaceObject.expect)(events[0]).toMatchObject({
|
|
32
|
-
type: "context-summarized",
|
|
33
|
-
inputTokens: 5400,
|
|
34
|
-
peakInputTokens: 11200,
|
|
35
|
-
thresholdTokens: 12000
|
|
36
|
-
});
|
|
37
|
-
(0, external_vitest_namespaceObject.expect)(typeof events[0]?.timestamp).toBe("string");
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
41
|
-
Object.defineProperty(exports, '__esModule', {
|
|
42
|
-
value: true
|
|
43
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { OutputManager } from "../cli/core/outputManager.js";
|
|
3
|
-
describe("OutputManager context summarized events", ()=>{
|
|
4
|
-
it("emits context-summarizing metadata in interactive mode", ()=>{
|
|
5
|
-
const outputManager = new OutputManager("interactive");
|
|
6
|
-
const events = [];
|
|
7
|
-
outputManager.on("output-event", (event)=>{
|
|
8
|
-
events.push(event);
|
|
9
|
-
});
|
|
10
|
-
outputManager.emitContextSummarizing();
|
|
11
|
-
expect(events).toHaveLength(1);
|
|
12
|
-
expect(events[0]).toMatchObject({
|
|
13
|
-
type: "context-summarizing"
|
|
14
|
-
});
|
|
15
|
-
expect(typeof events[0]?.timestamp).toBe("string");
|
|
16
|
-
});
|
|
17
|
-
it("emits context-summarized metadata in interactive mode", ()=>{
|
|
18
|
-
const outputManager = new OutputManager("interactive");
|
|
19
|
-
const events = [];
|
|
20
|
-
outputManager.on("output-event", (event)=>{
|
|
21
|
-
events.push(event);
|
|
22
|
-
});
|
|
23
|
-
outputManager.emitContextSummarized({
|
|
24
|
-
inputTokens: 5400,
|
|
25
|
-
peakInputTokens: 11200,
|
|
26
|
-
thresholdTokens: 12000
|
|
27
|
-
});
|
|
28
|
-
expect(events).toHaveLength(1);
|
|
29
|
-
expect(events[0]).toMatchObject({
|
|
30
|
-
type: "context-summarized",
|
|
31
|
-
inputTokens: 5400,
|
|
32
|
-
peakInputTokens: 11200,
|
|
33
|
-
thresholdTokens: 12000
|
|
34
|
-
});
|
|
35
|
-
expect(typeof events[0]?.timestamp).toBe("string");
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,57 +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_vitest_namespaceObject = require("vitest");
|
|
7
|
-
const provider_cjs_namespaceObject = require("../cli/commands/provider.cjs");
|
|
8
|
-
const codex_cjs_namespaceObject = require("../providers/codex.cjs");
|
|
9
|
-
(0, external_vitest_namespaceObject.describe)("provider command codex login", ()=>{
|
|
10
|
-
let codexHome;
|
|
11
|
-
const originalCodexHome = process.env.CODEX_HOME;
|
|
12
|
-
(0, external_vitest_namespaceObject.beforeEach)(()=>{
|
|
13
|
-
codexHome = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-provider-codex-"));
|
|
14
|
-
process.env.CODEX_HOME = codexHome;
|
|
15
|
-
});
|
|
16
|
-
(0, external_vitest_namespaceObject.afterEach)(()=>{
|
|
17
|
-
if (void 0 === originalCodexHome) delete process.env.CODEX_HOME;
|
|
18
|
-
else process.env.CODEX_HOME = originalCodexHome;
|
|
19
|
-
if ((0, external_node_fs_namespaceObject.existsSync)(codexHome)) (0, external_node_fs_namespaceObject.rmSync)(codexHome, {
|
|
20
|
-
recursive: true,
|
|
21
|
-
force: true
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
(0, external_vitest_namespaceObject.it)("uses existing codex login without requiring a token", async ()=>{
|
|
25
|
-
const authPath = (0, codex_cjs_namespaceObject.getCodexAuthPath)();
|
|
26
|
-
(0, external_node_fs_namespaceObject.mkdirSync)((0, external_node_path_namespaceObject.dirname)(authPath), {
|
|
27
|
-
recursive: true
|
|
28
|
-
});
|
|
29
|
-
(0, external_node_fs_namespaceObject.writeFileSync)(authPath, JSON.stringify({
|
|
30
|
-
tokens: {
|
|
31
|
-
access_token: "codex-access-token",
|
|
32
|
-
account_id: "acct_123"
|
|
33
|
-
}
|
|
34
|
-
}, null, 2));
|
|
35
|
-
const exitSpy = external_vitest_namespaceObject.vi.spyOn(process, "exit").mockImplementation((code)=>{
|
|
36
|
-
throw new Error(`process.exit(${code ?? "undefined"})`);
|
|
37
|
-
});
|
|
38
|
-
try {
|
|
39
|
-
await (0, external_vitest_namespaceObject.expect)((0, provider_cjs_namespaceObject.executeProviderCommand)({
|
|
40
|
-
subcommand: "login",
|
|
41
|
-
args: [
|
|
42
|
-
"codex"
|
|
43
|
-
],
|
|
44
|
-
verbosity: "silent",
|
|
45
|
-
outputMode: "json",
|
|
46
|
-
options: {}
|
|
47
|
-
})).resolves.toBeUndefined();
|
|
48
|
-
(0, external_vitest_namespaceObject.expect)(exitSpy).not.toHaveBeenCalled();
|
|
49
|
-
} finally{
|
|
50
|
-
exitSpy.mockRestore();
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
55
|
-
Object.defineProperty(exports, '__esModule', {
|
|
56
|
-
value: true
|
|
57
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
4
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
-
import { executeProviderCommand } from "../cli/commands/provider.js";
|
|
6
|
-
import { getCodexAuthPath } from "../providers/codex.js";
|
|
7
|
-
describe("provider command codex login", ()=>{
|
|
8
|
-
let codexHome;
|
|
9
|
-
const originalCodexHome = process.env.CODEX_HOME;
|
|
10
|
-
beforeEach(()=>{
|
|
11
|
-
codexHome = mkdtempSync(join(tmpdir(), "wingman-provider-codex-"));
|
|
12
|
-
process.env.CODEX_HOME = codexHome;
|
|
13
|
-
});
|
|
14
|
-
afterEach(()=>{
|
|
15
|
-
if (void 0 === originalCodexHome) delete process.env.CODEX_HOME;
|
|
16
|
-
else process.env.CODEX_HOME = originalCodexHome;
|
|
17
|
-
if (existsSync(codexHome)) rmSync(codexHome, {
|
|
18
|
-
recursive: true,
|
|
19
|
-
force: true
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
it("uses existing codex login without requiring a token", async ()=>{
|
|
23
|
-
const authPath = getCodexAuthPath();
|
|
24
|
-
mkdirSync(dirname(authPath), {
|
|
25
|
-
recursive: true
|
|
26
|
-
});
|
|
27
|
-
writeFileSync(authPath, JSON.stringify({
|
|
28
|
-
tokens: {
|
|
29
|
-
access_token: "codex-access-token",
|
|
30
|
-
account_id: "acct_123"
|
|
31
|
-
}
|
|
32
|
-
}, null, 2));
|
|
33
|
-
const exitSpy = vi.spyOn(process, "exit").mockImplementation((code)=>{
|
|
34
|
-
throw new Error(`process.exit(${code ?? "undefined"})`);
|
|
35
|
-
});
|
|
36
|
-
try {
|
|
37
|
-
await expect(executeProviderCommand({
|
|
38
|
-
subcommand: "login",
|
|
39
|
-
args: [
|
|
40
|
-
"codex"
|
|
41
|
-
],
|
|
42
|
-
verbosity: "silent",
|
|
43
|
-
outputMode: "json",
|
|
44
|
-
options: {}
|
|
45
|
-
})).resolves.toBeUndefined();
|
|
46
|
-
expect(exitSpy).not.toHaveBeenCalled();
|
|
47
|
-
} finally{
|
|
48
|
-
exitSpy.mockRestore();
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_exports__ = {};
|
|
3
|
-
const external_vitest_namespaceObject = require("vitest");
|
|
4
|
-
const routines_cjs_namespaceObject = require("../gateway/http/routines.cjs");
|
|
5
|
-
const external_node_fs_namespaceObject = require("node:fs");
|
|
6
|
-
const external_node_os_namespaceObject = require("node:os");
|
|
7
|
-
const external_node_path_namespaceObject = require("node:path");
|
|
8
|
-
const isBunRuntime = void 0 !== globalThis.Bun;
|
|
9
|
-
const describeIfBun = isBunRuntime ? external_vitest_namespaceObject.describe : external_vitest_namespaceObject.describe.skip;
|
|
10
|
-
describeIfBun("routines API", ()=>{
|
|
11
|
-
let tempDir;
|
|
12
|
-
(0, external_vitest_namespaceObject.beforeEach)(()=>{
|
|
13
|
-
tempDir = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-routines-"));
|
|
14
|
-
const agentDir = (0, external_node_path_namespaceObject.join)(tempDir, "agents", "main");
|
|
15
|
-
(0, external_node_fs_namespaceObject.mkdirSync)(agentDir, {
|
|
16
|
-
recursive: true
|
|
17
|
-
});
|
|
18
|
-
(0, external_node_fs_namespaceObject.writeFileSync)((0, external_node_path_namespaceObject.join)(agentDir, "agent.json"), JSON.stringify({
|
|
19
|
-
name: "main",
|
|
20
|
-
description: "Main agent",
|
|
21
|
-
systemPrompt: "You are the main agent"
|
|
22
|
-
}, null, 2));
|
|
23
|
-
});
|
|
24
|
-
(0, external_vitest_namespaceObject.afterEach)(()=>{
|
|
25
|
-
(0, external_node_fs_namespaceObject.rmSync)(tempDir, {
|
|
26
|
-
recursive: true,
|
|
27
|
-
force: true
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
(0, external_vitest_namespaceObject.it)("creates, lists, and deletes routines", async ()=>{
|
|
31
|
-
const ctx = {
|
|
32
|
-
configDir: tempDir,
|
|
33
|
-
workspace: tempDir,
|
|
34
|
-
getWingmanConfig: ()=>({}),
|
|
35
|
-
getSessionManager: async ()=>{
|
|
36
|
-
throw new Error("SessionManager not used in this test");
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const store = (0, routines_cjs_namespaceObject.createRoutineStore)(()=>tempDir);
|
|
40
|
-
const createReq = new Request("http://localhost/api/routines", {
|
|
41
|
-
method: "POST",
|
|
42
|
-
headers: {
|
|
43
|
-
"Content-Type": "application/json"
|
|
44
|
-
},
|
|
45
|
-
body: JSON.stringify({
|
|
46
|
-
name: "Daily Check-in",
|
|
47
|
-
agentId: "main",
|
|
48
|
-
cron: "0 9 * * *",
|
|
49
|
-
prompt: "Summarize today's tasks.",
|
|
50
|
-
enabled: true
|
|
51
|
-
})
|
|
52
|
-
});
|
|
53
|
-
const createRes = await (0, routines_cjs_namespaceObject.handleRoutinesApi)(ctx, store, createReq, new URL(createReq.url));
|
|
54
|
-
(0, external_vitest_namespaceObject.expect)(createRes).not.toBeNull();
|
|
55
|
-
(0, external_vitest_namespaceObject.expect)(createRes?.ok).toBe(true);
|
|
56
|
-
const created = await createRes.json();
|
|
57
|
-
(0, external_vitest_namespaceObject.expect)(created.id).toMatch(/^routine-/);
|
|
58
|
-
const listReq = new Request("http://localhost/api/routines", {
|
|
59
|
-
method: "GET"
|
|
60
|
-
});
|
|
61
|
-
const listRes = await (0, routines_cjs_namespaceObject.handleRoutinesApi)(ctx, store, listReq, new URL(listReq.url));
|
|
62
|
-
(0, external_vitest_namespaceObject.expect)(listRes).not.toBeNull();
|
|
63
|
-
const list = await listRes.json();
|
|
64
|
-
(0, external_vitest_namespaceObject.expect)(list).toHaveLength(1);
|
|
65
|
-
(0, external_vitest_namespaceObject.expect)(list[0].id).toBe(created.id);
|
|
66
|
-
const deleteReq = new Request(`http://localhost/api/routines/${encodeURIComponent(created.id)}`, {
|
|
67
|
-
method: "DELETE"
|
|
68
|
-
});
|
|
69
|
-
const deleteRes = await (0, routines_cjs_namespaceObject.handleRoutinesApi)(ctx, store, deleteReq, new URL(deleteReq.url));
|
|
70
|
-
(0, external_vitest_namespaceObject.expect)(deleteRes).not.toBeNull();
|
|
71
|
-
(0, external_vitest_namespaceObject.expect)(deleteRes?.ok).toBe(true);
|
|
72
|
-
const listResAfter = await (0, routines_cjs_namespaceObject.handleRoutinesApi)(ctx, store, listReq, new URL(listReq.url));
|
|
73
|
-
const listAfter = await listResAfter.json();
|
|
74
|
-
(0, external_vitest_namespaceObject.expect)(listAfter).toHaveLength(0);
|
|
75
|
-
});
|
|
76
|
-
(0, external_vitest_namespaceObject.it)("rejects invalid cron expressions", async ()=>{
|
|
77
|
-
const ctx = {
|
|
78
|
-
configDir: tempDir,
|
|
79
|
-
workspace: tempDir,
|
|
80
|
-
getWingmanConfig: ()=>({}),
|
|
81
|
-
getSessionManager: async ()=>{
|
|
82
|
-
throw new Error("SessionManager not used in this test");
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
const store = (0, routines_cjs_namespaceObject.createRoutineStore)(()=>tempDir);
|
|
86
|
-
const createReq = new Request("http://localhost/api/routines", {
|
|
87
|
-
method: "POST",
|
|
88
|
-
headers: {
|
|
89
|
-
"Content-Type": "application/json"
|
|
90
|
-
},
|
|
91
|
-
body: JSON.stringify({
|
|
92
|
-
name: "Invalid Cron",
|
|
93
|
-
agentId: "main",
|
|
94
|
-
cron: "bad cron",
|
|
95
|
-
prompt: "Hello",
|
|
96
|
-
enabled: true
|
|
97
|
-
})
|
|
98
|
-
});
|
|
99
|
-
const createRes = await (0, routines_cjs_namespaceObject.handleRoutinesApi)(ctx, store, createReq, new URL(createReq.url));
|
|
100
|
-
(0, external_vitest_namespaceObject.expect)(createRes).not.toBeNull();
|
|
101
|
-
(0, external_vitest_namespaceObject.expect)(createRes?.status).toBe(400);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
105
|
-
Object.defineProperty(exports, '__esModule', {
|
|
106
|
-
value: true
|
|
107
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
2
|
-
import { createRoutineStore, handleRoutinesApi } from "../gateway/http/routines.js";
|
|
3
|
-
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
const isBunRuntime = void 0 !== globalThis.Bun;
|
|
7
|
-
const describeIfBun = isBunRuntime ? describe : describe.skip;
|
|
8
|
-
describeIfBun("routines API", ()=>{
|
|
9
|
-
let tempDir;
|
|
10
|
-
beforeEach(()=>{
|
|
11
|
-
tempDir = mkdtempSync(join(tmpdir(), "wingman-routines-"));
|
|
12
|
-
const agentDir = join(tempDir, "agents", "main");
|
|
13
|
-
mkdirSync(agentDir, {
|
|
14
|
-
recursive: true
|
|
15
|
-
});
|
|
16
|
-
writeFileSync(join(agentDir, "agent.json"), JSON.stringify({
|
|
17
|
-
name: "main",
|
|
18
|
-
description: "Main agent",
|
|
19
|
-
systemPrompt: "You are the main agent"
|
|
20
|
-
}, null, 2));
|
|
21
|
-
});
|
|
22
|
-
afterEach(()=>{
|
|
23
|
-
rmSync(tempDir, {
|
|
24
|
-
recursive: true,
|
|
25
|
-
force: true
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
it("creates, lists, and deletes routines", async ()=>{
|
|
29
|
-
const ctx = {
|
|
30
|
-
configDir: tempDir,
|
|
31
|
-
workspace: tempDir,
|
|
32
|
-
getWingmanConfig: ()=>({}),
|
|
33
|
-
getSessionManager: async ()=>{
|
|
34
|
-
throw new Error("SessionManager not used in this test");
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const store = createRoutineStore(()=>tempDir);
|
|
38
|
-
const createReq = new Request("http://localhost/api/routines", {
|
|
39
|
-
method: "POST",
|
|
40
|
-
headers: {
|
|
41
|
-
"Content-Type": "application/json"
|
|
42
|
-
},
|
|
43
|
-
body: JSON.stringify({
|
|
44
|
-
name: "Daily Check-in",
|
|
45
|
-
agentId: "main",
|
|
46
|
-
cron: "0 9 * * *",
|
|
47
|
-
prompt: "Summarize today's tasks.",
|
|
48
|
-
enabled: true
|
|
49
|
-
})
|
|
50
|
-
});
|
|
51
|
-
const createRes = await handleRoutinesApi(ctx, store, createReq, new URL(createReq.url));
|
|
52
|
-
expect(createRes).not.toBeNull();
|
|
53
|
-
expect(createRes?.ok).toBe(true);
|
|
54
|
-
const created = await createRes.json();
|
|
55
|
-
expect(created.id).toMatch(/^routine-/);
|
|
56
|
-
const listReq = new Request("http://localhost/api/routines", {
|
|
57
|
-
method: "GET"
|
|
58
|
-
});
|
|
59
|
-
const listRes = await handleRoutinesApi(ctx, store, listReq, new URL(listReq.url));
|
|
60
|
-
expect(listRes).not.toBeNull();
|
|
61
|
-
const list = await listRes.json();
|
|
62
|
-
expect(list).toHaveLength(1);
|
|
63
|
-
expect(list[0].id).toBe(created.id);
|
|
64
|
-
const deleteReq = new Request(`http://localhost/api/routines/${encodeURIComponent(created.id)}`, {
|
|
65
|
-
method: "DELETE"
|
|
66
|
-
});
|
|
67
|
-
const deleteRes = await handleRoutinesApi(ctx, store, deleteReq, new URL(deleteReq.url));
|
|
68
|
-
expect(deleteRes).not.toBeNull();
|
|
69
|
-
expect(deleteRes?.ok).toBe(true);
|
|
70
|
-
const listResAfter = await handleRoutinesApi(ctx, store, listReq, new URL(listReq.url));
|
|
71
|
-
const listAfter = await listResAfter.json();
|
|
72
|
-
expect(listAfter).toHaveLength(0);
|
|
73
|
-
});
|
|
74
|
-
it("rejects invalid cron expressions", async ()=>{
|
|
75
|
-
const ctx = {
|
|
76
|
-
configDir: tempDir,
|
|
77
|
-
workspace: tempDir,
|
|
78
|
-
getWingmanConfig: ()=>({}),
|
|
79
|
-
getSessionManager: async ()=>{
|
|
80
|
-
throw new Error("SessionManager not used in this test");
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
const store = createRoutineStore(()=>tempDir);
|
|
84
|
-
const createReq = new Request("http://localhost/api/routines", {
|
|
85
|
-
method: "POST",
|
|
86
|
-
headers: {
|
|
87
|
-
"Content-Type": "application/json"
|
|
88
|
-
},
|
|
89
|
-
body: JSON.stringify({
|
|
90
|
-
name: "Invalid Cron",
|
|
91
|
-
agentId: "main",
|
|
92
|
-
cron: "bad cron",
|
|
93
|
-
prompt: "Hello",
|
|
94
|
-
enabled: true
|
|
95
|
-
})
|
|
96
|
-
});
|
|
97
|
-
const createRes = await handleRoutinesApi(ctx, store, createReq, new URL(createReq.url));
|
|
98
|
-
expect(createRes).not.toBeNull();
|
|
99
|
-
expect(createRes?.status).toBe(400);
|
|
100
|
-
});
|
|
101
|
-
});
|