@wingman-ai/gateway 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.wingman/agents/README.md +1 -0
- package/.wingman/agents/coding/agent.md +76 -14
- package/.wingman/agents/coding/implementor.md +25 -2
- package/README.md +310 -0
- package/dist/agent/config/agentConfig.cjs +29 -0
- package/dist/agent/config/agentConfig.js +29 -0
- package/dist/agent/tests/agentConfig.test.cjs +39 -0
- package/dist/agent/tests/agentConfig.test.js +39 -0
- package/dist/cli/core/agentInvoker.cjs +51 -4
- package/dist/cli/core/agentInvoker.d.ts +4 -1
- package/dist/cli/core/agentInvoker.js +51 -4
- package/dist/gateway/server.cjs +53 -1
- package/dist/gateway/server.d.ts +3 -0
- package/dist/gateway/server.js +53 -1
- package/dist/gateway/types.d.ts +4 -1
- package/dist/gateway/validation.cjs +1 -0
- package/dist/gateway/validation.d.ts +2 -0
- package/dist/gateway/validation.js +1 -0
- package/dist/tests/gateway.test.cjs +66 -1
- package/dist/tests/gateway.test.js +66 -1
- package/dist/webui/assets/index-CPhfGPHc.js +182 -0
- package/dist/webui/assets/index-DDsMIOTX.css +11 -0
- package/dist/webui/index.html +2 -2
- package/package.json +3 -1
- package/dist/webui/assets/index-BytPznA_.css +0 -1
- package/dist/webui/assets/index-u_5qlVip.js +0 -176
|
@@ -1,14 +1,51 @@
|
|
|
1
1
|
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { GatewayClient, GatewayServer } from "../gateway/index.js";
|
|
3
|
+
function _define_property(obj, key, value) {
|
|
4
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
5
|
+
value: value,
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
writable: true
|
|
9
|
+
});
|
|
10
|
+
else obj[key] = value;
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
3
13
|
const isBun = void 0 !== globalThis.Bun;
|
|
4
14
|
const describeIfBun = isBun ? describe : describe.skip;
|
|
5
15
|
vi.mock("@/cli/core/agentInvoker.js", ()=>({
|
|
6
16
|
AgentInvoker: class {
|
|
7
|
-
async invokeAgent() {
|
|
17
|
+
async invokeAgent(_agentId, _content, _sessionId, _attachments, options) {
|
|
18
|
+
const signal = options?.signal;
|
|
19
|
+
await new Promise((resolve)=>{
|
|
20
|
+
const timer = setTimeout(resolve, 75);
|
|
21
|
+
if (signal) {
|
|
22
|
+
const onAbort = ()=>{
|
|
23
|
+
clearTimeout(timer);
|
|
24
|
+
resolve();
|
|
25
|
+
};
|
|
26
|
+
if (signal.aborted) return void onAbort();
|
|
27
|
+
signal.addEventListener("abort", onAbort, {
|
|
28
|
+
once: true
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
if (signal?.aborted) {
|
|
33
|
+
this.outputManager?.emitAgentError?.("Request cancelled");
|
|
34
|
+
return {
|
|
35
|
+
cancelled: true
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
this.outputManager?.emitAgentComplete?.({
|
|
39
|
+
streaming: true
|
|
40
|
+
});
|
|
8
41
|
return {
|
|
9
42
|
streaming: true
|
|
10
43
|
};
|
|
11
44
|
}
|
|
45
|
+
constructor(options){
|
|
46
|
+
_define_property(this, "outputManager", void 0);
|
|
47
|
+
this.outputManager = options?.outputManager;
|
|
48
|
+
}
|
|
12
49
|
}
|
|
13
50
|
}));
|
|
14
51
|
describeIfBun("Gateway", ()=>{
|
|
@@ -294,6 +331,34 @@ describeIfBun("Gateway", ()=>{
|
|
|
294
331
|
desktopClient.close();
|
|
295
332
|
requester.close();
|
|
296
333
|
});
|
|
334
|
+
it("should cancel an in-flight agent request", async ()=>{
|
|
335
|
+
const requester = await connectClient("session-cancel-requester");
|
|
336
|
+
const requestId = "req-cancel-test";
|
|
337
|
+
requester.send(JSON.stringify({
|
|
338
|
+
type: "req:agent",
|
|
339
|
+
id: requestId,
|
|
340
|
+
payload: {
|
|
341
|
+
agentId: "main",
|
|
342
|
+
sessionKey: "session-cancel-test",
|
|
343
|
+
content: "cancel me"
|
|
344
|
+
},
|
|
345
|
+
timestamp: Date.now()
|
|
346
|
+
}));
|
|
347
|
+
requester.send(JSON.stringify({
|
|
348
|
+
type: "req:agent:cancel",
|
|
349
|
+
id: "cancel-req-cancel-test",
|
|
350
|
+
payload: {
|
|
351
|
+
requestId
|
|
352
|
+
},
|
|
353
|
+
timestamp: Date.now()
|
|
354
|
+
}));
|
|
355
|
+
const ack = await waitForMessage(requester, (msg)=>"ack" === msg.type && msg.payload?.action === "req:agent:cancel" && msg.payload?.requestId === requestId);
|
|
356
|
+
expect([
|
|
357
|
+
"cancelled",
|
|
358
|
+
"not_found"
|
|
359
|
+
]).toContain(ack.payload?.status);
|
|
360
|
+
requester.close();
|
|
361
|
+
});
|
|
297
362
|
it("should clear session messages via API", async ()=>{
|
|
298
363
|
const createRes = await fetch(`http://localhost:${port}/api/sessions`, {
|
|
299
364
|
method: "POST",
|