@wingman-ai/gateway 0.4.2 → 0.4.3
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/README.md +14 -0
- package/dist/agent/config/mcpClientManager.cjs +104 -1
- package/dist/agent/config/mcpClientManager.d.ts +30 -0
- package/dist/agent/config/mcpClientManager.js +104 -1
- package/dist/agent/config/modelFactory.cjs +10 -0
- package/dist/agent/config/modelFactory.js +10 -0
- package/dist/agent/config/xaiImageModel.cjs +242 -0
- package/dist/agent/config/xaiImageModel.d.ts +33 -0
- package/dist/agent/config/xaiImageModel.js +202 -0
- package/dist/agent/tests/mcpClientManager.test.cjs +116 -0
- package/dist/agent/tests/mcpClientManager.test.js +117 -1
- package/dist/agent/tests/mcpResourceTools.test.cjs +101 -0
- package/dist/agent/tests/mcpResourceTools.test.d.ts +1 -0
- package/dist/agent/tests/mcpResourceTools.test.js +95 -0
- package/dist/agent/tests/modelFactory.test.cjs +16 -2
- package/dist/agent/tests/modelFactory.test.js +16 -2
- package/dist/agent/tests/xaiImageModel.test.cjs +194 -0
- package/dist/agent/tests/xaiImageModel.test.d.ts +1 -0
- package/dist/agent/tests/xaiImageModel.test.js +188 -0
- package/dist/agent/tools/mcp_resources.cjs +111 -0
- package/dist/agent/tools/mcp_resources.d.ts +3 -0
- package/dist/agent/tools/mcp_resources.js +77 -0
- package/dist/bench/adapters/commandAdapter.cjs +93 -0
- package/dist/bench/adapters/commandAdapter.d.ts +6 -0
- package/dist/bench/adapters/commandAdapter.js +59 -0
- package/dist/bench/adapters/helpers.cjs +170 -0
- package/dist/bench/adapters/helpers.d.ts +7 -0
- package/dist/bench/adapters/helpers.js +133 -0
- package/dist/bench/adapters/index.cjs +41 -0
- package/dist/bench/adapters/index.d.ts +2 -0
- package/dist/bench/adapters/index.js +7 -0
- package/dist/bench/adapters/wingmanCliAdapter.cjs +100 -0
- package/dist/bench/adapters/wingmanCliAdapter.d.ts +6 -0
- package/dist/bench/adapters/wingmanCliAdapter.js +66 -0
- package/dist/bench/cleanup.cjs +122 -0
- package/dist/bench/cleanup.d.ts +9 -0
- package/dist/bench/cleanup.js +85 -0
- package/dist/bench/config.cjs +190 -0
- package/dist/bench/config.d.ts +2 -0
- package/dist/bench/config.js +156 -0
- package/dist/bench/index.cjs +43 -0
- package/dist/bench/index.d.ts +3 -0
- package/dist/bench/index.js +3 -0
- package/dist/bench/official.cjs +616 -0
- package/dist/bench/official.d.ts +80 -0
- package/dist/bench/official.js +546 -0
- package/dist/bench/officialCli.cjs +204 -0
- package/dist/bench/officialCli.d.ts +5 -0
- package/dist/bench/officialCli.js +170 -0
- package/dist/bench/process.cjs +78 -0
- package/dist/bench/process.d.ts +14 -0
- package/dist/bench/process.js +44 -0
- package/dist/bench/runner.cjs +237 -0
- package/dist/bench/runner.d.ts +7 -0
- package/dist/bench/runner.js +197 -0
- package/dist/bench/scoring.cjs +171 -0
- package/dist/bench/scoring.d.ts +9 -0
- package/dist/bench/scoring.js +137 -0
- package/dist/bench/types.cjs +18 -0
- package/dist/bench/types.d.ts +200 -0
- package/dist/bench/types.js +0 -0
- package/dist/bench/validator.cjs +92 -0
- package/dist/bench/validator.d.ts +2 -0
- package/dist/bench/validator.js +58 -0
- package/dist/cli/config/schema.cjs +36 -1
- package/dist/cli/config/schema.d.ts +46 -0
- package/dist/cli/config/schema.js +36 -1
- package/dist/cli/config/warnings.cjs +119 -51
- package/dist/cli/config/warnings.js +119 -51
- package/dist/cli/core/agentInvoker.cjs +9 -2
- package/dist/cli/core/agentInvoker.d.ts +1 -0
- package/dist/cli/core/agentInvoker.js +9 -2
- package/dist/cli/core/imagePersistence.cjs +17 -1
- package/dist/cli/core/imagePersistence.d.ts +2 -0
- package/dist/cli/core/imagePersistence.js +13 -3
- package/dist/cli/core/sessionManager.cjs +2 -0
- package/dist/cli/core/sessionManager.js +3 -1
- package/dist/cli/types.d.ts +18 -0
- package/dist/gateway/adapters/teams.cjs +419 -0
- package/dist/gateway/adapters/teams.d.ts +47 -0
- package/dist/gateway/adapters/teams.js +361 -0
- package/dist/gateway/http/sms.cjs +286 -0
- package/dist/gateway/http/sms.d.ts +4 -0
- package/dist/gateway/http/sms.js +249 -0
- package/dist/gateway/server.cjs +54 -3
- package/dist/gateway/server.d.ts +2 -0
- package/dist/gateway/server.js +54 -3
- package/dist/gateway/sms/commands.cjs +116 -0
- package/dist/gateway/sms/commands.d.ts +15 -0
- package/dist/gateway/sms/commands.js +79 -0
- package/dist/gateway/sms/control.cjs +118 -0
- package/dist/gateway/sms/control.d.ts +18 -0
- package/dist/gateway/sms/control.js +84 -0
- package/dist/gateway/sms/policyStore.cjs +198 -0
- package/dist/gateway/sms/policyStore.d.ts +37 -0
- package/dist/gateway/sms/policyStore.js +161 -0
- package/dist/providers/registry.cjs +1 -0
- package/dist/providers/registry.js +1 -0
- package/dist/tests/cli-config-warnings.test.cjs +41 -0
- package/dist/tests/cli-config-warnings.test.js +41 -0
- package/dist/tests/cli-init.test.cjs +32 -26
- package/dist/tests/cli-init.test.js +32 -26
- package/dist/tests/gateway-http-security.test.cjs +21 -0
- package/dist/tests/gateway-http-security.test.js +21 -0
- package/dist/tests/gateway-origin-policy.test.cjs +22 -0
- package/dist/tests/gateway-origin-policy.test.js +22 -0
- package/dist/tests/gateway.test.cjs +57 -0
- package/dist/tests/gateway.test.js +57 -0
- package/dist/tests/imagePersistence.test.cjs +26 -0
- package/dist/tests/imagePersistence.test.js +27 -1
- package/dist/tests/run-terminal-bench-official-script.test.cjs +61 -0
- package/dist/tests/run-terminal-bench-official-script.test.d.ts +1 -0
- package/dist/tests/run-terminal-bench-official-script.test.js +55 -0
- package/dist/tests/sessions-api.test.cjs +69 -1
- package/dist/tests/sessions-api.test.js +70 -2
- package/dist/tests/sms-api.test.cjs +183 -0
- package/dist/tests/sms-api.test.d.ts +1 -0
- package/dist/tests/sms-api.test.js +177 -0
- package/dist/tests/sms-commands.test.cjs +90 -0
- package/dist/tests/sms-commands.test.d.ts +1 -0
- package/dist/tests/sms-commands.test.js +84 -0
- package/dist/tests/sms-policy-store.test.cjs +69 -0
- package/dist/tests/sms-policy-store.test.d.ts +1 -0
- package/dist/tests/sms-policy-store.test.js +63 -0
- package/dist/tests/teams-adapter.test.cjs +58 -0
- package/dist/tests/teams-adapter.test.d.ts +1 -0
- package/dist/tests/teams-adapter.test.js +52 -0
- package/dist/tests/terminal-bench-adapters-helpers.test.cjs +64 -0
- package/dist/tests/terminal-bench-adapters-helpers.test.d.ts +1 -0
- package/dist/tests/terminal-bench-adapters-helpers.test.js +58 -0
- package/dist/tests/terminal-bench-cleanup.test.cjs +93 -0
- package/dist/tests/terminal-bench-cleanup.test.d.ts +1 -0
- package/dist/tests/terminal-bench-cleanup.test.js +87 -0
- package/dist/tests/terminal-bench-config.test.cjs +62 -0
- package/dist/tests/terminal-bench-config.test.d.ts +1 -0
- package/dist/tests/terminal-bench-config.test.js +56 -0
- package/dist/tests/terminal-bench-official.test.cjs +194 -0
- package/dist/tests/terminal-bench-official.test.d.ts +1 -0
- package/dist/tests/terminal-bench-official.test.js +188 -0
- package/dist/tests/terminal-bench-runner.test.cjs +82 -0
- package/dist/tests/terminal-bench-runner.test.d.ts +1 -0
- package/dist/tests/terminal-bench-runner.test.js +76 -0
- package/dist/tests/terminal-bench-scoring.test.cjs +128 -0
- package/dist/tests/terminal-bench-scoring.test.d.ts +1 -0
- package/dist/tests/terminal-bench-scoring.test.js +122 -0
- package/dist/tools/mcp-fal-ai.cjs +1 -1
- package/dist/tools/mcp-fal-ai.js +1 -1
- package/dist/webui/assets/index-Cyg_Hs57.css +11 -0
- package/dist/webui/assets/{index-BMekSELC.js → index-DZXLLjaA.js} +109 -109
- package/dist/webui/index.html +2 -2
- package/package.json +11 -2
- package/templates/agents/game-dev/agent.md +122 -63
- package/templates/agents/game-dev/art-director.md +106 -0
- package/templates/agents/game-dev/game-designer.md +87 -0
- package/templates/agents/game-dev/scene-engineer.md +474 -0
- package/dist/webui/assets/index-Cwkg4DKj.css +0 -11
- package/templates/agents/game-dev/art-generation.md +0 -38
- package/templates/agents/game-dev/asset-refinement.md +0 -17
- package/templates/agents/game-dev/planning-idea.md +0 -17
- package/templates/agents/game-dev/ui-specialist.md +0 -17
|
@@ -0,0 +1,177 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
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 policyStore_cjs_namespaceObject = require("../gateway/sms/policyStore.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 store", ()=>{
|
|
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)("creates defaults for unknown targets without persisting", ()=>{
|
|
23
|
+
tempDir = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-sms-policy-"));
|
|
24
|
+
const store = (0, policyStore_cjs_namespaceObject.createSmsPolicyStore)(()=>requireTempDir(tempDir));
|
|
25
|
+
const record = store.resolve("sms-macos:+15555550000", 1000);
|
|
26
|
+
(0, external_vitest_namespaceObject.expect)(record.target).toBe("sms-macos:+15555550000");
|
|
27
|
+
(0, external_vitest_namespaceObject.expect)(record.paused).toBe(false);
|
|
28
|
+
(0, external_vitest_namespaceObject.expect)(record.stopEnabled).toBe(false);
|
|
29
|
+
(0, external_vitest_namespaceObject.expect)(store.list()).toHaveLength(0);
|
|
30
|
+
});
|
|
31
|
+
(0, external_vitest_namespaceObject.it)("persists updates and clears expired pauses on resolve", ()=>{
|
|
32
|
+
tempDir = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-sms-policy-"));
|
|
33
|
+
const store = (0, policyStore_cjs_namespaceObject.createSmsPolicyStore)(()=>requireTempDir(tempDir));
|
|
34
|
+
const target = "sms-macos:+15555550000";
|
|
35
|
+
const saved = store.upsert(target, {
|
|
36
|
+
paused: true,
|
|
37
|
+
pausedUntil: 50000,
|
|
38
|
+
stopEnabled: true
|
|
39
|
+
}, 1000);
|
|
40
|
+
(0, external_vitest_namespaceObject.expect)(saved.paused).toBe(true);
|
|
41
|
+
(0, external_vitest_namespaceObject.expect)(saved.pausedUntil).toBe(50000);
|
|
42
|
+
(0, external_vitest_namespaceObject.expect)(saved.stopEnabled).toBe(true);
|
|
43
|
+
const active = store.resolve(target, 49000);
|
|
44
|
+
(0, external_vitest_namespaceObject.expect)(active.paused).toBe(true);
|
|
45
|
+
const expired = store.resolve(target, 50000);
|
|
46
|
+
(0, external_vitest_namespaceObject.expect)(expired.paused).toBe(false);
|
|
47
|
+
(0, external_vitest_namespaceObject.expect)(expired.pausedUntil).toBeNull();
|
|
48
|
+
(0, external_vitest_namespaceObject.expect)(expired.stopEnabled).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
(0, external_vitest_namespaceObject.it)("resets policies back to defaults", ()=>{
|
|
51
|
+
tempDir = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-sms-policy-"));
|
|
52
|
+
const store = (0, policyStore_cjs_namespaceObject.createSmsPolicyStore)(()=>requireTempDir(tempDir));
|
|
53
|
+
const target = "sms-macos:+15555550000";
|
|
54
|
+
store.upsert(target, {
|
|
55
|
+
paused: true,
|
|
56
|
+
stopEnabled: true
|
|
57
|
+
}, 1000);
|
|
58
|
+
(0, external_vitest_namespaceObject.expect)(store.list()).toHaveLength(1);
|
|
59
|
+
store.reset(target);
|
|
60
|
+
(0, external_vitest_namespaceObject.expect)(store.list()).toHaveLength(0);
|
|
61
|
+
const defaultRecord = store.resolve(target, 2000);
|
|
62
|
+
(0, external_vitest_namespaceObject.expect)(defaultRecord.paused).toBe(false);
|
|
63
|
+
(0, external_vitest_namespaceObject.expect)(defaultRecord.stopEnabled).toBe(false);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
67
|
+
Object.defineProperty(exports, '__esModule', {
|
|
68
|
+
value: true
|
|
69
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
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 { createSmsPolicyStore } from "../gateway/sms/policyStore.js";
|
|
6
|
+
const requireTempDir = (value)=>{
|
|
7
|
+
if (!value) throw new Error("temp dir not initialized");
|
|
8
|
+
return value;
|
|
9
|
+
};
|
|
10
|
+
describe("sms policy store", ()=>{
|
|
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("creates defaults for unknown targets without persisting", ()=>{
|
|
21
|
+
tempDir = mkdtempSync(join(tmpdir(), "wingman-sms-policy-"));
|
|
22
|
+
const store = createSmsPolicyStore(()=>requireTempDir(tempDir));
|
|
23
|
+
const record = store.resolve("sms-macos:+15555550000", 1000);
|
|
24
|
+
expect(record.target).toBe("sms-macos:+15555550000");
|
|
25
|
+
expect(record.paused).toBe(false);
|
|
26
|
+
expect(record.stopEnabled).toBe(false);
|
|
27
|
+
expect(store.list()).toHaveLength(0);
|
|
28
|
+
});
|
|
29
|
+
it("persists updates and clears expired pauses on resolve", ()=>{
|
|
30
|
+
tempDir = mkdtempSync(join(tmpdir(), "wingman-sms-policy-"));
|
|
31
|
+
const store = createSmsPolicyStore(()=>requireTempDir(tempDir));
|
|
32
|
+
const target = "sms-macos:+15555550000";
|
|
33
|
+
const saved = store.upsert(target, {
|
|
34
|
+
paused: true,
|
|
35
|
+
pausedUntil: 50000,
|
|
36
|
+
stopEnabled: true
|
|
37
|
+
}, 1000);
|
|
38
|
+
expect(saved.paused).toBe(true);
|
|
39
|
+
expect(saved.pausedUntil).toBe(50000);
|
|
40
|
+
expect(saved.stopEnabled).toBe(true);
|
|
41
|
+
const active = store.resolve(target, 49000);
|
|
42
|
+
expect(active.paused).toBe(true);
|
|
43
|
+
const expired = store.resolve(target, 50000);
|
|
44
|
+
expect(expired.paused).toBe(false);
|
|
45
|
+
expect(expired.pausedUntil).toBeNull();
|
|
46
|
+
expect(expired.stopEnabled).toBe(true);
|
|
47
|
+
});
|
|
48
|
+
it("resets policies back to defaults", ()=>{
|
|
49
|
+
tempDir = mkdtempSync(join(tmpdir(), "wingman-sms-policy-"));
|
|
50
|
+
const store = createSmsPolicyStore(()=>requireTempDir(tempDir));
|
|
51
|
+
const target = "sms-macos:+15555550000";
|
|
52
|
+
store.upsert(target, {
|
|
53
|
+
paused: true,
|
|
54
|
+
stopEnabled: true
|
|
55
|
+
}, 1000);
|
|
56
|
+
expect(store.list()).toHaveLength(1);
|
|
57
|
+
store.reset(target);
|
|
58
|
+
expect(store.list()).toHaveLength(0);
|
|
59
|
+
const defaultRecord = store.resolve(target, 2000);
|
|
60
|
+
expect(defaultRecord.paused).toBe(false);
|
|
61
|
+
expect(defaultRecord.stopEnabled).toBe(false);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_exports__ = {};
|
|
3
|
+
const external_vitest_namespaceObject = require("vitest");
|
|
4
|
+
const teams_cjs_namespaceObject = require("../gateway/adapters/teams.cjs");
|
|
5
|
+
(0, external_vitest_namespaceObject.describe)("teams adapter helpers", ()=>{
|
|
6
|
+
(0, external_vitest_namespaceObject.it)("normalizes endpoint path and falls back to default", ()=>{
|
|
7
|
+
(0, external_vitest_namespaceObject.expect)((0, teams_cjs_namespaceObject.normalizeTeamsEndpointPath)(void 0)).toBe(teams_cjs_namespaceObject.DEFAULT_TEAMS_ENDPOINT_PATH);
|
|
8
|
+
(0, external_vitest_namespaceObject.expect)((0, teams_cjs_namespaceObject.normalizeTeamsEndpointPath)("")).toBe(teams_cjs_namespaceObject.DEFAULT_TEAMS_ENDPOINT_PATH);
|
|
9
|
+
(0, external_vitest_namespaceObject.expect)((0, teams_cjs_namespaceObject.normalizeTeamsEndpointPath)("api/teams")).toBe("/api/teams");
|
|
10
|
+
(0, external_vitest_namespaceObject.expect)((0, teams_cjs_namespaceObject.normalizeTeamsEndpointPath)("/api/teams")).toBe("/api/teams");
|
|
11
|
+
});
|
|
12
|
+
(0, external_vitest_namespaceObject.it)("extracts mention entities for the bot", ()=>{
|
|
13
|
+
const activity = {
|
|
14
|
+
recipient: {
|
|
15
|
+
name: "Wingman",
|
|
16
|
+
id: "bot-1"
|
|
17
|
+
},
|
|
18
|
+
entities: [
|
|
19
|
+
{
|
|
20
|
+
type: "mention",
|
|
21
|
+
text: "<at>Wingman</at>",
|
|
22
|
+
mentioned: {
|
|
23
|
+
id: "bot-1",
|
|
24
|
+
name: "Wingman"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
};
|
|
29
|
+
(0, external_vitest_namespaceObject.expect)((0, teams_cjs_namespaceObject.extractTeamsMentionTexts)(activity, "bot-1")).toEqual([
|
|
30
|
+
"<at>Wingman</at>"
|
|
31
|
+
]);
|
|
32
|
+
(0, external_vitest_namespaceObject.expect)((0, teams_cjs_namespaceObject.isTeamsBotMentioned)(activity, "bot-1")).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
(0, external_vitest_namespaceObject.it)("strips mention tags and mention text from messages", ()=>{
|
|
35
|
+
const text = "<at>Wingman</at> hello there";
|
|
36
|
+
(0, external_vitest_namespaceObject.expect)((0, teams_cjs_namespaceObject.stripTeamsBotMention)(text, [
|
|
37
|
+
"<at>Wingman</at>"
|
|
38
|
+
])).toBe("hello there");
|
|
39
|
+
});
|
|
40
|
+
(0, external_vitest_namespaceObject.it)("splits long responses into chunks", ()=>{
|
|
41
|
+
const input = "a".repeat(9500);
|
|
42
|
+
const chunks = (0, teams_cjs_namespaceObject.splitTeamsMessage)(input, 3500);
|
|
43
|
+
(0, external_vitest_namespaceObject.expect)(chunks.length).toBeGreaterThan(2);
|
|
44
|
+
for (const chunk of chunks)(0, external_vitest_namespaceObject.expect)(chunk.length).toBeLessThanOrEqual(3500);
|
|
45
|
+
(0, external_vitest_namespaceObject.expect)(chunks.join("")).toBe(input);
|
|
46
|
+
});
|
|
47
|
+
(0, external_vitest_namespaceObject.it)("resolves channel session mapping", ()=>{
|
|
48
|
+
const map = {
|
|
49
|
+
"19:channel:id": "agent:wingman:teams:channel"
|
|
50
|
+
};
|
|
51
|
+
(0, external_vitest_namespaceObject.expect)((0, teams_cjs_namespaceObject.resolveTeamsChannelSessionKey)("19:channel:id", map)).toBe("agent:wingman:teams:channel");
|
|
52
|
+
(0, external_vitest_namespaceObject.expect)((0, teams_cjs_namespaceObject.resolveTeamsChannelSessionKey)("missing", map)).toBeUndefined();
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
56
|
+
Object.defineProperty(exports, '__esModule', {
|
|
57
|
+
value: true
|
|
58
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { DEFAULT_TEAMS_ENDPOINT_PATH, extractTeamsMentionTexts, isTeamsBotMentioned, normalizeTeamsEndpointPath, resolveTeamsChannelSessionKey, splitTeamsMessage, stripTeamsBotMention } from "../gateway/adapters/teams.js";
|
|
3
|
+
describe("teams adapter helpers", ()=>{
|
|
4
|
+
it("normalizes endpoint path and falls back to default", ()=>{
|
|
5
|
+
expect(normalizeTeamsEndpointPath(void 0)).toBe(DEFAULT_TEAMS_ENDPOINT_PATH);
|
|
6
|
+
expect(normalizeTeamsEndpointPath("")).toBe(DEFAULT_TEAMS_ENDPOINT_PATH);
|
|
7
|
+
expect(normalizeTeamsEndpointPath("api/teams")).toBe("/api/teams");
|
|
8
|
+
expect(normalizeTeamsEndpointPath("/api/teams")).toBe("/api/teams");
|
|
9
|
+
});
|
|
10
|
+
it("extracts mention entities for the bot", ()=>{
|
|
11
|
+
const activity = {
|
|
12
|
+
recipient: {
|
|
13
|
+
name: "Wingman",
|
|
14
|
+
id: "bot-1"
|
|
15
|
+
},
|
|
16
|
+
entities: [
|
|
17
|
+
{
|
|
18
|
+
type: "mention",
|
|
19
|
+
text: "<at>Wingman</at>",
|
|
20
|
+
mentioned: {
|
|
21
|
+
id: "bot-1",
|
|
22
|
+
name: "Wingman"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
};
|
|
27
|
+
expect(extractTeamsMentionTexts(activity, "bot-1")).toEqual([
|
|
28
|
+
"<at>Wingman</at>"
|
|
29
|
+
]);
|
|
30
|
+
expect(isTeamsBotMentioned(activity, "bot-1")).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
it("strips mention tags and mention text from messages", ()=>{
|
|
33
|
+
const text = "<at>Wingman</at> hello there";
|
|
34
|
+
expect(stripTeamsBotMention(text, [
|
|
35
|
+
"<at>Wingman</at>"
|
|
36
|
+
])).toBe("hello there");
|
|
37
|
+
});
|
|
38
|
+
it("splits long responses into chunks", ()=>{
|
|
39
|
+
const input = "a".repeat(9500);
|
|
40
|
+
const chunks = splitTeamsMessage(input, 3500);
|
|
41
|
+
expect(chunks.length).toBeGreaterThan(2);
|
|
42
|
+
for (const chunk of chunks)expect(chunk.length).toBeLessThanOrEqual(3500);
|
|
43
|
+
expect(chunks.join("")).toBe(input);
|
|
44
|
+
});
|
|
45
|
+
it("resolves channel session mapping", ()=>{
|
|
46
|
+
const map = {
|
|
47
|
+
"19:channel:id": "agent:wingman:teams:channel"
|
|
48
|
+
};
|
|
49
|
+
expect(resolveTeamsChannelSessionKey("19:channel:id", map)).toBe("agent:wingman:teams:channel");
|
|
50
|
+
expect(resolveTeamsChannelSessionKey("missing", map)).toBeUndefined();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_exports__ = {};
|
|
3
|
+
const external_vitest_namespaceObject = require("vitest");
|
|
4
|
+
const helpers_cjs_namespaceObject = require("../bench/adapters/helpers.cjs");
|
|
5
|
+
(0, external_vitest_namespaceObject.describe)("parseWingmanJsonOutput", ()=>{
|
|
6
|
+
(0, external_vitest_namespaceObject.it)("extracts assistant text from ai-role messages", ()=>{
|
|
7
|
+
const output = JSON.stringify({
|
|
8
|
+
type: "agent-complete",
|
|
9
|
+
result: {
|
|
10
|
+
messages: [
|
|
11
|
+
{
|
|
12
|
+
role: "user",
|
|
13
|
+
content: "ignore"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
role: "ai",
|
|
17
|
+
content: "hello from ai role"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const parsed = (0, helpers_cjs_namespaceObject.parseWingmanJsonOutput)(output);
|
|
23
|
+
(0, external_vitest_namespaceObject.expect)(parsed.assistantText).toBe("hello from ai role");
|
|
24
|
+
});
|
|
25
|
+
(0, external_vitest_namespaceObject.it)("extracts assistant text from serialized AIMessage payloads", ()=>{
|
|
26
|
+
const output = JSON.stringify({
|
|
27
|
+
type: "agent-complete",
|
|
28
|
+
result: {
|
|
29
|
+
messages: [
|
|
30
|
+
{
|
|
31
|
+
id: [
|
|
32
|
+
"langchain_core",
|
|
33
|
+
"messages",
|
|
34
|
+
"AIMessage"
|
|
35
|
+
],
|
|
36
|
+
kwargs: {
|
|
37
|
+
content: [
|
|
38
|
+
{
|
|
39
|
+
type: "text",
|
|
40
|
+
text: "hello from kwargs content"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const parsed = (0, helpers_cjs_namespaceObject.parseWingmanJsonOutput)(output);
|
|
49
|
+
(0, external_vitest_namespaceObject.expect)(parsed.assistantText).toBe("hello from kwargs content");
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
(0, external_vitest_namespaceObject.describe)("detectAssistantFailureMessage", ()=>{
|
|
53
|
+
(0, external_vitest_namespaceObject.it)("detects provider bad request failures", ()=>{
|
|
54
|
+
const error = (0, helpers_cjs_namespaceObject.detectAssistantFailureMessage)("Model call failed after 3 attempts with BadRequestError: 400 status code (no body)");
|
|
55
|
+
(0, external_vitest_namespaceObject.expect)(error).toContain("BadRequestError");
|
|
56
|
+
});
|
|
57
|
+
(0, external_vitest_namespaceObject.it)("ignores normal assistant content", ()=>{
|
|
58
|
+
(0, external_vitest_namespaceObject.expect)((0, helpers_cjs_namespaceObject.detectAssistantFailureMessage)('{"state_analysis":"ok","commands":[],"is_task_complete":false}')).toBeUndefined();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
62
|
+
Object.defineProperty(exports, '__esModule', {
|
|
63
|
+
value: true
|
|
64
|
+
});
|