@wingman-ai/gateway 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/backend/filtered-backend.cjs +130 -0
- package/dist/agent/backend/filtered-backend.d.ts +10 -0
- package/dist/agent/backend/filtered-backend.js +87 -0
- 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/additional-messages.cjs +4 -1
- package/dist/agent/middleware/additional-messages.js +4 -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 +1358 -0
- package/dist/agent/tools/browser_runtime.d.ts +617 -0
- package/dist/agent/tools/browser_runtime.js +1288 -0
- package/dist/agent/tools/browser_session.cjs +189 -0
- package/dist/agent/tools/browser_session.d.ts +686 -0
- package/dist/agent/tools/browser_session.js +146 -0
- package/dist/agent/tools/browser_session_manager.cjs +213 -0
- package/dist/agent/tools/browser_session_manager.d.ts +70 -0
- package/dist/agent/tools/browser_session_manager.js +176 -0
- package/dist/cli/commands/init.cjs +80 -98
- package/dist/cli/commands/init.js +80 -98
- 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 +88 -22
- package/dist/cli/core/agentInvoker.d.ts +10 -3
- package/dist/cli/core/agentInvoker.js +88 -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/core/sessionManager.cjs +208 -41
- package/dist/cli/core/sessionManager.d.ts +20 -0
- package/dist/cli/core/sessionManager.js +208 -41
- package/dist/cli/index.cjs +16 -1
- package/dist/cli/index.js +16 -1
- package/dist/cli/services/updateCheck.cjs +212 -0
- package/dist/cli/services/updateCheck.d.ts +26 -0
- package/dist/cli/services/updateCheck.js +166 -0
- package/dist/cli/types.d.ts +2 -1
- package/dist/gateway/server.cjs +7 -0
- package/dist/gateway/server.js +7 -0
- package/dist/webui/assets/index-D3x3G75t.css +11 -0
- package/dist/webui/assets/index-UpMmcU1f.js +215 -0
- package/dist/webui/index.html +2 -2
- package/package.json +12 -12
- package/templates/agents/README.md +3 -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 +9 -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 +7 -2
- package/templates/agents/researcher/agent.md +14 -3
- 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
- package/dist/webui/assets/wingman_logo-Cogyt3qm.webp +0 -0
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "node:events";
|
|
2
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
-
import { scanSkillDirectory } from "../cli/services/skillSecurityScanner.js";
|
|
4
|
-
const { mockSpawn, mockEnsureUvAvailableForFeature } = vi.hoisted(()=>({
|
|
5
|
-
mockSpawn: vi.fn(),
|
|
6
|
-
mockEnsureUvAvailableForFeature: vi.fn()
|
|
7
|
-
}));
|
|
8
|
-
vi.mock("node:child_process", ()=>({
|
|
9
|
-
spawn: mockSpawn
|
|
10
|
-
}));
|
|
11
|
-
vi.mock("@/utils/uv.js", ()=>({
|
|
12
|
-
ensureUvAvailableForFeature: mockEnsureUvAvailableForFeature
|
|
13
|
-
}));
|
|
14
|
-
const createMockChildProcess = (input)=>{
|
|
15
|
-
const child = new EventEmitter();
|
|
16
|
-
child.stdout = new EventEmitter();
|
|
17
|
-
child.stderr = new EventEmitter();
|
|
18
|
-
queueMicrotask(()=>{
|
|
19
|
-
if (input.stdout) child.stdout.emit("data", Buffer.from(input.stdout));
|
|
20
|
-
if (input.stderr) child.stderr.emit("data", Buffer.from(input.stderr));
|
|
21
|
-
child.emit("close", input.exitCode);
|
|
22
|
-
});
|
|
23
|
-
return child;
|
|
24
|
-
};
|
|
25
|
-
const createLogger = ()=>({
|
|
26
|
-
debug: vi.fn(),
|
|
27
|
-
info: vi.fn(),
|
|
28
|
-
warn: vi.fn(),
|
|
29
|
-
error: vi.fn()
|
|
30
|
-
});
|
|
31
|
-
describe("skill security scanner", ()=>{
|
|
32
|
-
beforeEach(()=>{
|
|
33
|
-
mockSpawn.mockReset();
|
|
34
|
-
mockEnsureUvAvailableForFeature.mockReset();
|
|
35
|
-
});
|
|
36
|
-
it("skips execution when scanOnInstall is disabled", async ()=>{
|
|
37
|
-
const logger = createLogger();
|
|
38
|
-
await scanSkillDirectory("/tmp/skill", logger, {
|
|
39
|
-
scanOnInstall: false
|
|
40
|
-
});
|
|
41
|
-
expect(mockEnsureUvAvailableForFeature).not.toHaveBeenCalled();
|
|
42
|
-
expect(mockSpawn).not.toHaveBeenCalled();
|
|
43
|
-
});
|
|
44
|
-
it("blocks installation when blocking issue codes are reported", async ()=>{
|
|
45
|
-
const logger = createLogger();
|
|
46
|
-
mockSpawn.mockReturnValue(createMockChildProcess({
|
|
47
|
-
exitCode: 0,
|
|
48
|
-
stdout: JSON.stringify({
|
|
49
|
-
"/tmp/skill": {
|
|
50
|
-
issues: [
|
|
51
|
-
{
|
|
52
|
-
code: "MCP501",
|
|
53
|
-
message: "dangerous behavior"
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
}));
|
|
59
|
-
await expect(scanSkillDirectory("/tmp/skill", logger, {
|
|
60
|
-
scannerCommand: "uvx",
|
|
61
|
-
scannerArgs: [
|
|
62
|
-
"scan",
|
|
63
|
-
"--json"
|
|
64
|
-
],
|
|
65
|
-
blockIssueCodes: [
|
|
66
|
-
"MCP501"
|
|
67
|
-
]
|
|
68
|
-
})).rejects.toThrow(/MCP501/);
|
|
69
|
-
expect(mockEnsureUvAvailableForFeature).toHaveBeenCalledWith("uvx", "skills.security.scanOnInstall");
|
|
70
|
-
expect(mockSpawn).toHaveBeenCalledWith("uvx", [
|
|
71
|
-
"scan",
|
|
72
|
-
"--json",
|
|
73
|
-
"/tmp/skill"
|
|
74
|
-
], expect.objectContaining({
|
|
75
|
-
stdio: [
|
|
76
|
-
"ignore",
|
|
77
|
-
"pipe",
|
|
78
|
-
"pipe"
|
|
79
|
-
]
|
|
80
|
-
}));
|
|
81
|
-
});
|
|
82
|
-
it("logs non-blocking issues and continues", async ()=>{
|
|
83
|
-
const logger = createLogger();
|
|
84
|
-
mockSpawn.mockReturnValue(createMockChildProcess({
|
|
85
|
-
exitCode: 0,
|
|
86
|
-
stdout: JSON.stringify({
|
|
87
|
-
"/tmp/skill": {
|
|
88
|
-
issues: [
|
|
89
|
-
{
|
|
90
|
-
code: "MCP999",
|
|
91
|
-
message: "informational"
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
}));
|
|
97
|
-
await expect(scanSkillDirectory("/tmp/skill", logger, {
|
|
98
|
-
blockIssueCodes: [
|
|
99
|
-
"MCP501"
|
|
100
|
-
]
|
|
101
|
-
})).resolves.toBeUndefined();
|
|
102
|
-
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining("MCP999"));
|
|
103
|
-
});
|
|
104
|
-
it("parses JSON output when scanner emits extra log lines", async ()=>{
|
|
105
|
-
const logger = createLogger();
|
|
106
|
-
mockSpawn.mockReturnValue(createMockChildProcess({
|
|
107
|
-
exitCode: 0,
|
|
108
|
-
stdout: "scanner starting\n{\"/tmp/skill\":{\"issues\":[]}}\nscanner complete"
|
|
109
|
-
}));
|
|
110
|
-
await expect(scanSkillDirectory("/tmp/skill", logger)).resolves.toBeUndefined();
|
|
111
|
-
});
|
|
112
|
-
it("fails when the scanner command exits non-zero", async ()=>{
|
|
113
|
-
const logger = createLogger();
|
|
114
|
-
mockSpawn.mockReturnValue(createMockChildProcess({
|
|
115
|
-
exitCode: 2,
|
|
116
|
-
stderr: "scan failed"
|
|
117
|
-
}));
|
|
118
|
-
await expect(scanSkillDirectory("/tmp/skill", logger)).rejects.toThrow(/exit code 2: scan failed/);
|
|
119
|
-
});
|
|
120
|
-
});
|
|
@@ -1,183 +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 sms_cjs_namespaceObject = require("../gateway/http/sms.cjs");
|
|
8
|
-
const requireTempDir = (value)=>{
|
|
9
|
-
if (!value) throw new Error("temp dir not initialized");
|
|
10
|
-
return value;
|
|
11
|
-
};
|
|
12
|
-
(0, external_vitest_namespaceObject.describe)("sms policy api", ()=>{
|
|
13
|
-
let tempDir = null;
|
|
14
|
-
(0, external_vitest_namespaceObject.afterEach)(()=>{
|
|
15
|
-
if (!tempDir) return;
|
|
16
|
-
(0, external_node_fs_namespaceObject.rmSync)(tempDir, {
|
|
17
|
-
recursive: true,
|
|
18
|
-
force: true
|
|
19
|
-
});
|
|
20
|
-
tempDir = null;
|
|
21
|
-
});
|
|
22
|
-
(0, external_vitest_namespaceObject.it)("updates, fetches, and resets policy records", async ()=>{
|
|
23
|
-
tempDir = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-sms-api-"));
|
|
24
|
-
const store = (0, sms_cjs_namespaceObject.createSmsPolicyStateStore)(()=>requireTempDir(tempDir));
|
|
25
|
-
const target = encodeURIComponent("sms-macos:+15555550000");
|
|
26
|
-
const ctx = {};
|
|
27
|
-
const updateReq = new Request(`http://localhost/api/sms/policies/${target}`, {
|
|
28
|
-
method: "PUT",
|
|
29
|
-
headers: {
|
|
30
|
-
"Content-Type": "application/json"
|
|
31
|
-
},
|
|
32
|
-
body: JSON.stringify({
|
|
33
|
-
stopEnabled: true,
|
|
34
|
-
pauseForMs: 120000,
|
|
35
|
-
alertMode: "all"
|
|
36
|
-
})
|
|
37
|
-
});
|
|
38
|
-
const updateRes = await (0, sms_cjs_namespaceObject.handleSmsApi)(ctx, store, updateReq, new URL(updateReq.url));
|
|
39
|
-
(0, external_vitest_namespaceObject.expect)(updateRes?.status).toBe(200);
|
|
40
|
-
const updated = await updateRes?.json();
|
|
41
|
-
(0, external_vitest_namespaceObject.expect)(updated.paused).toBe(true);
|
|
42
|
-
(0, external_vitest_namespaceObject.expect)(updated.pausedUntil).toBeTypeOf("number");
|
|
43
|
-
(0, external_vitest_namespaceObject.expect)(updated.stopEnabled).toBe(true);
|
|
44
|
-
(0, external_vitest_namespaceObject.expect)(updated.alertMode).toBe("all");
|
|
45
|
-
const getRes = await (0, sms_cjs_namespaceObject.handleSmsApi)(ctx, store, new Request(`http://localhost/api/sms/policies/${target}`, {
|
|
46
|
-
method: "GET"
|
|
47
|
-
}), new URL(`http://localhost/api/sms/policies/${target}`));
|
|
48
|
-
(0, external_vitest_namespaceObject.expect)(getRes?.status).toBe(200);
|
|
49
|
-
const listRes = await (0, sms_cjs_namespaceObject.handleSmsApi)(ctx, store, new Request("http://localhost/api/sms/policies", {
|
|
50
|
-
method: "GET"
|
|
51
|
-
}), new URL("http://localhost/api/sms/policies"));
|
|
52
|
-
(0, external_vitest_namespaceObject.expect)(listRes?.status).toBe(200);
|
|
53
|
-
const listPayload = await listRes?.json();
|
|
54
|
-
(0, external_vitest_namespaceObject.expect)(listPayload.policies).toHaveLength(1);
|
|
55
|
-
const deleteRes = await (0, sms_cjs_namespaceObject.handleSmsApi)(ctx, store, new Request(`http://localhost/api/sms/policies/${target}`, {
|
|
56
|
-
method: "DELETE"
|
|
57
|
-
}), new URL(`http://localhost/api/sms/policies/${target}`));
|
|
58
|
-
(0, external_vitest_namespaceObject.expect)(deleteRes?.status).toBe(200);
|
|
59
|
-
const reset = await deleteRes?.json();
|
|
60
|
-
(0, external_vitest_namespaceObject.expect)(reset.paused).toBe(false);
|
|
61
|
-
(0, external_vitest_namespaceObject.expect)(reset.stopEnabled).toBe(false);
|
|
62
|
-
});
|
|
63
|
-
(0, external_vitest_namespaceObject.it)("applies control commands and leaves non-commands as pass-through text", async ()=>{
|
|
64
|
-
tempDir = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-sms-api-"));
|
|
65
|
-
const store = (0, sms_cjs_namespaceObject.createSmsPolicyStateStore)(()=>requireTempDir(tempDir));
|
|
66
|
-
const target = encodeURIComponent("sms-macos:+15555550000");
|
|
67
|
-
const ctx = {
|
|
68
|
-
router: {
|
|
69
|
-
selectAgent: ()=>"main",
|
|
70
|
-
buildSessionKey: ()=>"agent:main:sms-macos:dm:+15555550000"
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
const pauseReq = new Request(`http://localhost/api/sms/policies/${target}/command`, {
|
|
74
|
-
method: "POST",
|
|
75
|
-
headers: {
|
|
76
|
-
"Content-Type": "application/json"
|
|
77
|
-
},
|
|
78
|
-
body: JSON.stringify({
|
|
79
|
-
text: "PAUSE 2h",
|
|
80
|
-
nowMs: 10000
|
|
81
|
-
})
|
|
82
|
-
});
|
|
83
|
-
const pauseRes = await (0, sms_cjs_namespaceObject.handleSmsApi)(ctx, store, pauseReq, new URL(pauseReq.url));
|
|
84
|
-
(0, external_vitest_namespaceObject.expect)(pauseRes?.status).toBe(200);
|
|
85
|
-
const pausedPayload = await pauseRes?.json();
|
|
86
|
-
(0, external_vitest_namespaceObject.expect)(pausedPayload.handled).toBe(true);
|
|
87
|
-
(0, external_vitest_namespaceObject.expect)(pausedPayload.command?.name).toBe("pause");
|
|
88
|
-
(0, external_vitest_namespaceObject.expect)(pausedPayload.policy.paused).toBe(true);
|
|
89
|
-
const textReq = new Request(`http://localhost/api/sms/policies/${target}/command`, {
|
|
90
|
-
method: "POST",
|
|
91
|
-
headers: {
|
|
92
|
-
"Content-Type": "application/json"
|
|
93
|
-
},
|
|
94
|
-
body: JSON.stringify({
|
|
95
|
-
text: "deploy this now"
|
|
96
|
-
})
|
|
97
|
-
});
|
|
98
|
-
const textRes = await (0, sms_cjs_namespaceObject.handleSmsApi)(ctx, store, textReq, new URL(textReq.url));
|
|
99
|
-
(0, external_vitest_namespaceObject.expect)(textRes?.status).toBe(200);
|
|
100
|
-
const textPayload = await textRes?.json();
|
|
101
|
-
(0, external_vitest_namespaceObject.expect)(textPayload.handled).toBe(false);
|
|
102
|
-
(0, external_vitest_namespaceObject.expect)(textPayload.passThroughText).toBe("deploy this now");
|
|
103
|
-
});
|
|
104
|
-
(0, external_vitest_namespaceObject.it)("normalizes inbound messages into command, stopped, or agent results", async ()=>{
|
|
105
|
-
tempDir = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-sms-api-"));
|
|
106
|
-
const store = (0, sms_cjs_namespaceObject.createSmsPolicyStateStore)(()=>requireTempDir(tempDir));
|
|
107
|
-
const ctx = {
|
|
108
|
-
router: {
|
|
109
|
-
selectAgent: ()=>"main",
|
|
110
|
-
buildSessionKey: ()=>"agent:main:sms-macos:dm:+15555550000"
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
const commandReq = new Request("http://localhost/api/sms/messages", {
|
|
114
|
-
method: "POST",
|
|
115
|
-
headers: {
|
|
116
|
-
"Content-Type": "application/json"
|
|
117
|
-
},
|
|
118
|
-
body: JSON.stringify({
|
|
119
|
-
target: "sms-macos:+15555550000",
|
|
120
|
-
text: "HELP"
|
|
121
|
-
})
|
|
122
|
-
});
|
|
123
|
-
const commandRes = await (0, sms_cjs_namespaceObject.handleSmsApi)(ctx, store, commandReq, new URL(commandReq.url));
|
|
124
|
-
(0, external_vitest_namespaceObject.expect)(commandRes?.status).toBe(200);
|
|
125
|
-
const commandPayload = await commandRes?.json();
|
|
126
|
-
(0, external_vitest_namespaceObject.expect)(commandPayload.kind).toBe("command");
|
|
127
|
-
(0, external_vitest_namespaceObject.expect)(commandPayload.handled).toBe(true);
|
|
128
|
-
const stopReq = new Request("http://localhost/api/sms/messages", {
|
|
129
|
-
method: "POST",
|
|
130
|
-
headers: {
|
|
131
|
-
"Content-Type": "application/json"
|
|
132
|
-
},
|
|
133
|
-
body: JSON.stringify({
|
|
134
|
-
target: "sms-macos:+15555550000",
|
|
135
|
-
text: "STOP"
|
|
136
|
-
})
|
|
137
|
-
});
|
|
138
|
-
const stopRes = await (0, sms_cjs_namespaceObject.handleSmsApi)(ctx, store, stopReq, new URL(stopReq.url));
|
|
139
|
-
(0, external_vitest_namespaceObject.expect)(stopRes?.status).toBe(200);
|
|
140
|
-
const blockedReq = new Request("http://localhost/api/sms/messages", {
|
|
141
|
-
method: "POST",
|
|
142
|
-
headers: {
|
|
143
|
-
"Content-Type": "application/json"
|
|
144
|
-
},
|
|
145
|
-
body: JSON.stringify({
|
|
146
|
-
target: "sms-macos:+15555550000",
|
|
147
|
-
text: "summarize my build failures"
|
|
148
|
-
})
|
|
149
|
-
});
|
|
150
|
-
const blockedRes = await (0, sms_cjs_namespaceObject.handleSmsApi)(ctx, store, blockedReq, new URL(blockedReq.url));
|
|
151
|
-
(0, external_vitest_namespaceObject.expect)(blockedRes?.status).toBe(200);
|
|
152
|
-
const blockedPayload = await blockedRes?.json();
|
|
153
|
-
(0, external_vitest_namespaceObject.expect)(blockedPayload.kind).toBe("stopped");
|
|
154
|
-
(0, external_vitest_namespaceObject.expect)(blockedPayload.responseText).toContain("stopped");
|
|
155
|
-
store.upsert("sms-macos:+15555550000", {
|
|
156
|
-
stopEnabled: false
|
|
157
|
-
});
|
|
158
|
-
const agentReq = new Request("http://localhost/api/sms/messages", {
|
|
159
|
-
method: "POST",
|
|
160
|
-
headers: {
|
|
161
|
-
"Content-Type": "application/json"
|
|
162
|
-
},
|
|
163
|
-
body: JSON.stringify({
|
|
164
|
-
target: "sms-macos:+15555550000",
|
|
165
|
-
text: "summarize my build failures",
|
|
166
|
-
queueIfBusy: true
|
|
167
|
-
})
|
|
168
|
-
});
|
|
169
|
-
const agentRes = await (0, sms_cjs_namespaceObject.handleSmsApi)(ctx, store, agentReq, new URL(agentReq.url));
|
|
170
|
-
(0, external_vitest_namespaceObject.expect)(agentRes?.status).toBe(200);
|
|
171
|
-
const agentPayload = await agentRes?.json();
|
|
172
|
-
(0, external_vitest_namespaceObject.expect)(agentPayload.kind).toBe("agent");
|
|
173
|
-
(0, external_vitest_namespaceObject.expect)(agentPayload.request.agentId).toBe("main");
|
|
174
|
-
(0, external_vitest_namespaceObject.expect)(agentPayload.request.content).toBe("summarize my build failures");
|
|
175
|
-
(0, external_vitest_namespaceObject.expect)(agentPayload.request.sessionKey).toBe("agent:main:sms-macos:dm:+15555550000");
|
|
176
|
-
(0, external_vitest_namespaceObject.expect)(agentPayload.request.routing?.channel).toBe("sms-macos");
|
|
177
|
-
(0, external_vitest_namespaceObject.expect)(agentPayload.request.queueIfBusy).toBe(true);
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
181
|
-
Object.defineProperty(exports, '__esModule', {
|
|
182
|
-
value: true
|
|
183
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,177 +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 { createSmsPolicyStateStore, handleSmsApi } from "../gateway/http/sms.js";
|
|
6
|
-
const requireTempDir = (value)=>{
|
|
7
|
-
if (!value) throw new Error("temp dir not initialized");
|
|
8
|
-
return value;
|
|
9
|
-
};
|
|
10
|
-
describe("sms policy api", ()=>{
|
|
11
|
-
let tempDir = null;
|
|
12
|
-
afterEach(()=>{
|
|
13
|
-
if (!tempDir) return;
|
|
14
|
-
rmSync(tempDir, {
|
|
15
|
-
recursive: true,
|
|
16
|
-
force: true
|
|
17
|
-
});
|
|
18
|
-
tempDir = null;
|
|
19
|
-
});
|
|
20
|
-
it("updates, fetches, and resets policy records", async ()=>{
|
|
21
|
-
tempDir = mkdtempSync(join(tmpdir(), "wingman-sms-api-"));
|
|
22
|
-
const store = createSmsPolicyStateStore(()=>requireTempDir(tempDir));
|
|
23
|
-
const target = encodeURIComponent("sms-macos:+15555550000");
|
|
24
|
-
const ctx = {};
|
|
25
|
-
const updateReq = new Request(`http://localhost/api/sms/policies/${target}`, {
|
|
26
|
-
method: "PUT",
|
|
27
|
-
headers: {
|
|
28
|
-
"Content-Type": "application/json"
|
|
29
|
-
},
|
|
30
|
-
body: JSON.stringify({
|
|
31
|
-
stopEnabled: true,
|
|
32
|
-
pauseForMs: 120000,
|
|
33
|
-
alertMode: "all"
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
const updateRes = await handleSmsApi(ctx, store, updateReq, new URL(updateReq.url));
|
|
37
|
-
expect(updateRes?.status).toBe(200);
|
|
38
|
-
const updated = await updateRes?.json();
|
|
39
|
-
expect(updated.paused).toBe(true);
|
|
40
|
-
expect(updated.pausedUntil).toBeTypeOf("number");
|
|
41
|
-
expect(updated.stopEnabled).toBe(true);
|
|
42
|
-
expect(updated.alertMode).toBe("all");
|
|
43
|
-
const getRes = await handleSmsApi(ctx, store, new Request(`http://localhost/api/sms/policies/${target}`, {
|
|
44
|
-
method: "GET"
|
|
45
|
-
}), new URL(`http://localhost/api/sms/policies/${target}`));
|
|
46
|
-
expect(getRes?.status).toBe(200);
|
|
47
|
-
const listRes = await handleSmsApi(ctx, store, new Request("http://localhost/api/sms/policies", {
|
|
48
|
-
method: "GET"
|
|
49
|
-
}), new URL("http://localhost/api/sms/policies"));
|
|
50
|
-
expect(listRes?.status).toBe(200);
|
|
51
|
-
const listPayload = await listRes?.json();
|
|
52
|
-
expect(listPayload.policies).toHaveLength(1);
|
|
53
|
-
const deleteRes = await handleSmsApi(ctx, store, new Request(`http://localhost/api/sms/policies/${target}`, {
|
|
54
|
-
method: "DELETE"
|
|
55
|
-
}), new URL(`http://localhost/api/sms/policies/${target}`));
|
|
56
|
-
expect(deleteRes?.status).toBe(200);
|
|
57
|
-
const reset = await deleteRes?.json();
|
|
58
|
-
expect(reset.paused).toBe(false);
|
|
59
|
-
expect(reset.stopEnabled).toBe(false);
|
|
60
|
-
});
|
|
61
|
-
it("applies control commands and leaves non-commands as pass-through text", async ()=>{
|
|
62
|
-
tempDir = mkdtempSync(join(tmpdir(), "wingman-sms-api-"));
|
|
63
|
-
const store = createSmsPolicyStateStore(()=>requireTempDir(tempDir));
|
|
64
|
-
const target = encodeURIComponent("sms-macos:+15555550000");
|
|
65
|
-
const ctx = {
|
|
66
|
-
router: {
|
|
67
|
-
selectAgent: ()=>"main",
|
|
68
|
-
buildSessionKey: ()=>"agent:main:sms-macos:dm:+15555550000"
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const pauseReq = new Request(`http://localhost/api/sms/policies/${target}/command`, {
|
|
72
|
-
method: "POST",
|
|
73
|
-
headers: {
|
|
74
|
-
"Content-Type": "application/json"
|
|
75
|
-
},
|
|
76
|
-
body: JSON.stringify({
|
|
77
|
-
text: "PAUSE 2h",
|
|
78
|
-
nowMs: 10000
|
|
79
|
-
})
|
|
80
|
-
});
|
|
81
|
-
const pauseRes = await handleSmsApi(ctx, store, pauseReq, new URL(pauseReq.url));
|
|
82
|
-
expect(pauseRes?.status).toBe(200);
|
|
83
|
-
const pausedPayload = await pauseRes?.json();
|
|
84
|
-
expect(pausedPayload.handled).toBe(true);
|
|
85
|
-
expect(pausedPayload.command?.name).toBe("pause");
|
|
86
|
-
expect(pausedPayload.policy.paused).toBe(true);
|
|
87
|
-
const textReq = new Request(`http://localhost/api/sms/policies/${target}/command`, {
|
|
88
|
-
method: "POST",
|
|
89
|
-
headers: {
|
|
90
|
-
"Content-Type": "application/json"
|
|
91
|
-
},
|
|
92
|
-
body: JSON.stringify({
|
|
93
|
-
text: "deploy this now"
|
|
94
|
-
})
|
|
95
|
-
});
|
|
96
|
-
const textRes = await handleSmsApi(ctx, store, textReq, new URL(textReq.url));
|
|
97
|
-
expect(textRes?.status).toBe(200);
|
|
98
|
-
const textPayload = await textRes?.json();
|
|
99
|
-
expect(textPayload.handled).toBe(false);
|
|
100
|
-
expect(textPayload.passThroughText).toBe("deploy this now");
|
|
101
|
-
});
|
|
102
|
-
it("normalizes inbound messages into command, stopped, or agent results", async ()=>{
|
|
103
|
-
tempDir = mkdtempSync(join(tmpdir(), "wingman-sms-api-"));
|
|
104
|
-
const store = createSmsPolicyStateStore(()=>requireTempDir(tempDir));
|
|
105
|
-
const ctx = {
|
|
106
|
-
router: {
|
|
107
|
-
selectAgent: ()=>"main",
|
|
108
|
-
buildSessionKey: ()=>"agent:main:sms-macos:dm:+15555550000"
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
const commandReq = new Request("http://localhost/api/sms/messages", {
|
|
112
|
-
method: "POST",
|
|
113
|
-
headers: {
|
|
114
|
-
"Content-Type": "application/json"
|
|
115
|
-
},
|
|
116
|
-
body: JSON.stringify({
|
|
117
|
-
target: "sms-macos:+15555550000",
|
|
118
|
-
text: "HELP"
|
|
119
|
-
})
|
|
120
|
-
});
|
|
121
|
-
const commandRes = await handleSmsApi(ctx, store, commandReq, new URL(commandReq.url));
|
|
122
|
-
expect(commandRes?.status).toBe(200);
|
|
123
|
-
const commandPayload = await commandRes?.json();
|
|
124
|
-
expect(commandPayload.kind).toBe("command");
|
|
125
|
-
expect(commandPayload.handled).toBe(true);
|
|
126
|
-
const stopReq = new Request("http://localhost/api/sms/messages", {
|
|
127
|
-
method: "POST",
|
|
128
|
-
headers: {
|
|
129
|
-
"Content-Type": "application/json"
|
|
130
|
-
},
|
|
131
|
-
body: JSON.stringify({
|
|
132
|
-
target: "sms-macos:+15555550000",
|
|
133
|
-
text: "STOP"
|
|
134
|
-
})
|
|
135
|
-
});
|
|
136
|
-
const stopRes = await handleSmsApi(ctx, store, stopReq, new URL(stopReq.url));
|
|
137
|
-
expect(stopRes?.status).toBe(200);
|
|
138
|
-
const blockedReq = new Request("http://localhost/api/sms/messages", {
|
|
139
|
-
method: "POST",
|
|
140
|
-
headers: {
|
|
141
|
-
"Content-Type": "application/json"
|
|
142
|
-
},
|
|
143
|
-
body: JSON.stringify({
|
|
144
|
-
target: "sms-macos:+15555550000",
|
|
145
|
-
text: "summarize my build failures"
|
|
146
|
-
})
|
|
147
|
-
});
|
|
148
|
-
const blockedRes = await handleSmsApi(ctx, store, blockedReq, new URL(blockedReq.url));
|
|
149
|
-
expect(blockedRes?.status).toBe(200);
|
|
150
|
-
const blockedPayload = await blockedRes?.json();
|
|
151
|
-
expect(blockedPayload.kind).toBe("stopped");
|
|
152
|
-
expect(blockedPayload.responseText).toContain("stopped");
|
|
153
|
-
store.upsert("sms-macos:+15555550000", {
|
|
154
|
-
stopEnabled: false
|
|
155
|
-
});
|
|
156
|
-
const agentReq = new Request("http://localhost/api/sms/messages", {
|
|
157
|
-
method: "POST",
|
|
158
|
-
headers: {
|
|
159
|
-
"Content-Type": "application/json"
|
|
160
|
-
},
|
|
161
|
-
body: JSON.stringify({
|
|
162
|
-
target: "sms-macos:+15555550000",
|
|
163
|
-
text: "summarize my build failures",
|
|
164
|
-
queueIfBusy: true
|
|
165
|
-
})
|
|
166
|
-
});
|
|
167
|
-
const agentRes = await handleSmsApi(ctx, store, agentReq, new URL(agentReq.url));
|
|
168
|
-
expect(agentRes?.status).toBe(200);
|
|
169
|
-
const agentPayload = await agentRes?.json();
|
|
170
|
-
expect(agentPayload.kind).toBe("agent");
|
|
171
|
-
expect(agentPayload.request.agentId).toBe("main");
|
|
172
|
-
expect(agentPayload.request.content).toBe("summarize my build failures");
|
|
173
|
-
expect(agentPayload.request.sessionKey).toBe("agent:main:sms-macos:dm:+15555550000");
|
|
174
|
-
expect(agentPayload.request.routing?.channel).toBe("sms-macos");
|
|
175
|
-
expect(agentPayload.request.queueIfBusy).toBe(true);
|
|
176
|
-
});
|
|
177
|
-
});
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_exports__ = {};
|
|
3
|
-
const external_vitest_namespaceObject = require("vitest");
|
|
4
|
-
const commands_cjs_namespaceObject = require("../gateway/sms/commands.cjs");
|
|
5
|
-
(0, external_vitest_namespaceObject.describe)("sms commands", ()=>{
|
|
6
|
-
(0, external_vitest_namespaceObject.it)("parses reserved commands as control commands", ()=>{
|
|
7
|
-
(0, external_vitest_namespaceObject.expect)((0, commands_cjs_namespaceObject.interpretSmsInboundMessage)("help")).toEqual({
|
|
8
|
-
type: "command",
|
|
9
|
-
command: {
|
|
10
|
-
name: "help"
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
(0, external_vitest_namespaceObject.expect)((0, commands_cjs_namespaceObject.interpretSmsInboundMessage)("STATUS")).toEqual({
|
|
14
|
-
type: "command",
|
|
15
|
-
command: {
|
|
16
|
-
name: "status"
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
(0, external_vitest_namespaceObject.expect)((0, commands_cjs_namespaceObject.interpretSmsInboundMessage)("resume")).toEqual({
|
|
20
|
-
type: "command",
|
|
21
|
-
command: {
|
|
22
|
-
name: "resume"
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
(0, external_vitest_namespaceObject.expect)((0, commands_cjs_namespaceObject.interpretSmsInboundMessage)("STOP")).toEqual({
|
|
26
|
-
type: "command",
|
|
27
|
-
command: {
|
|
28
|
-
name: "stop"
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
(0, external_vitest_namespaceObject.it)("parses pause commands with optional durations", ()=>{
|
|
33
|
-
(0, external_vitest_namespaceObject.expect)((0, commands_cjs_namespaceObject.interpretSmsInboundMessage)("pause")).toEqual({
|
|
34
|
-
type: "command",
|
|
35
|
-
command: {
|
|
36
|
-
name: "pause",
|
|
37
|
-
durationMs: null
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
(0, external_vitest_namespaceObject.expect)((0, commands_cjs_namespaceObject.interpretSmsInboundMessage)("pause 15m")).toEqual({
|
|
41
|
-
type: "command",
|
|
42
|
-
command: {
|
|
43
|
-
name: "pause",
|
|
44
|
-
durationMs: 900000
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
(0, external_vitest_namespaceObject.expect)((0, commands_cjs_namespaceObject.interpretSmsInboundMessage)("PAUSE 2 H")).toEqual({
|
|
48
|
-
type: "command",
|
|
49
|
-
command: {
|
|
50
|
-
name: "pause",
|
|
51
|
-
durationMs: 7200000
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
(0, external_vitest_namespaceObject.expect)((0, commands_cjs_namespaceObject.interpretSmsInboundMessage)("pause 1d")).toEqual({
|
|
55
|
-
type: "command",
|
|
56
|
-
command: {
|
|
57
|
-
name: "pause",
|
|
58
|
-
durationMs: 86400000
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
(0, external_vitest_namespaceObject.it)("treats invalid command forms as plain text", ()=>{
|
|
63
|
-
(0, external_vitest_namespaceObject.expect)((0, commands_cjs_namespaceObject.interpretSmsInboundMessage)("pause tomorrow")).toEqual({
|
|
64
|
-
type: "text",
|
|
65
|
-
content: "pause tomorrow"
|
|
66
|
-
});
|
|
67
|
-
(0, external_vitest_namespaceObject.expect)((0, commands_cjs_namespaceObject.interpretSmsInboundMessage)("pause 0m")).toEqual({
|
|
68
|
-
type: "text",
|
|
69
|
-
content: "pause 0m"
|
|
70
|
-
});
|
|
71
|
-
(0, external_vitest_namespaceObject.expect)((0, commands_cjs_namespaceObject.interpretSmsInboundMessage)("help me with deploy")).toEqual({
|
|
72
|
-
type: "text",
|
|
73
|
-
content: "help me with deploy"
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
(0, external_vitest_namespaceObject.it)("supports escaping reserved command words", ()=>{
|
|
77
|
-
(0, external_vitest_namespaceObject.expect)((0, commands_cjs_namespaceObject.interpretSmsInboundMessage)("\\pause")).toEqual({
|
|
78
|
-
type: "text",
|
|
79
|
-
content: "pause"
|
|
80
|
-
});
|
|
81
|
-
(0, external_vitest_namespaceObject.expect)((0, commands_cjs_namespaceObject.interpretSmsInboundMessage)("\\STATUS")).toEqual({
|
|
82
|
-
type: "text",
|
|
83
|
-
content: "STATUS"
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
88
|
-
Object.defineProperty(exports, '__esModule', {
|
|
89
|
-
value: true
|
|
90
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { interpretSmsInboundMessage } from "../gateway/sms/commands.js";
|
|
3
|
-
describe("sms commands", ()=>{
|
|
4
|
-
it("parses reserved commands as control commands", ()=>{
|
|
5
|
-
expect(interpretSmsInboundMessage("help")).toEqual({
|
|
6
|
-
type: "command",
|
|
7
|
-
command: {
|
|
8
|
-
name: "help"
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
expect(interpretSmsInboundMessage("STATUS")).toEqual({
|
|
12
|
-
type: "command",
|
|
13
|
-
command: {
|
|
14
|
-
name: "status"
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
expect(interpretSmsInboundMessage("resume")).toEqual({
|
|
18
|
-
type: "command",
|
|
19
|
-
command: {
|
|
20
|
-
name: "resume"
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
expect(interpretSmsInboundMessage("STOP")).toEqual({
|
|
24
|
-
type: "command",
|
|
25
|
-
command: {
|
|
26
|
-
name: "stop"
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
it("parses pause commands with optional durations", ()=>{
|
|
31
|
-
expect(interpretSmsInboundMessage("pause")).toEqual({
|
|
32
|
-
type: "command",
|
|
33
|
-
command: {
|
|
34
|
-
name: "pause",
|
|
35
|
-
durationMs: null
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
expect(interpretSmsInboundMessage("pause 15m")).toEqual({
|
|
39
|
-
type: "command",
|
|
40
|
-
command: {
|
|
41
|
-
name: "pause",
|
|
42
|
-
durationMs: 900000
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
expect(interpretSmsInboundMessage("PAUSE 2 H")).toEqual({
|
|
46
|
-
type: "command",
|
|
47
|
-
command: {
|
|
48
|
-
name: "pause",
|
|
49
|
-
durationMs: 7200000
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
expect(interpretSmsInboundMessage("pause 1d")).toEqual({
|
|
53
|
-
type: "command",
|
|
54
|
-
command: {
|
|
55
|
-
name: "pause",
|
|
56
|
-
durationMs: 86400000
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
it("treats invalid command forms as plain text", ()=>{
|
|
61
|
-
expect(interpretSmsInboundMessage("pause tomorrow")).toEqual({
|
|
62
|
-
type: "text",
|
|
63
|
-
content: "pause tomorrow"
|
|
64
|
-
});
|
|
65
|
-
expect(interpretSmsInboundMessage("pause 0m")).toEqual({
|
|
66
|
-
type: "text",
|
|
67
|
-
content: "pause 0m"
|
|
68
|
-
});
|
|
69
|
-
expect(interpretSmsInboundMessage("help me with deploy")).toEqual({
|
|
70
|
-
type: "text",
|
|
71
|
-
content: "help me with deploy"
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
it("supports escaping reserved command words", ()=>{
|
|
75
|
-
expect(interpretSmsInboundMessage("\\pause")).toEqual({
|
|
76
|
-
type: "text",
|
|
77
|
-
content: "pause"
|
|
78
|
-
});
|
|
79
|
-
expect(interpretSmsInboundMessage("\\STATUS")).toEqual({
|
|
80
|
-
type: "text",
|
|
81
|
-
content: "STATUS"
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
});
|