@agentrq/acp-gateway 0.2.28 → 0.2.30
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 +2 -2
- package/dist/__tests__/collections.test.js +76 -0
- package/dist/__tests__/collections.test.js.map +1 -0
- package/dist/__tests__/index.test.js +6 -6
- package/dist/__tests__/index.test.js.map +1 -1
- package/dist/acpClient.js +4 -1
- package/dist/acpClient.js.map +1 -1
- package/dist/collections.js +76 -0
- package/dist/collections.js.map +1 -0
- package/dist/index.js +23 -20
- package/dist/index.js.map +1 -1
- package/dist/mcpClient.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ npm install -g @agentrq/acp-gateway
|
|
|
37
37
|
|
|
38
38
|
## Current Version
|
|
39
39
|
|
|
40
|
-
`0.2.
|
|
40
|
+
`0.2.30`
|
|
41
41
|
|
|
42
42
|
## Usage
|
|
43
43
|
|
|
@@ -173,7 +173,7 @@ Credentials are never stored by the gateway; the agent keeps its own, exactly as
|
|
|
173
173
|
|
|
174
174
|
`acp-gateway` searches for `.mcp.json` starting in the current working directory and up to 3 parent directories.
|
|
175
175
|
|
|
176
|
-
`--list-models`, `--agent-info
|
|
176
|
+
`--list-models`, `--agent-info`, `--list-auth-methods`, `--login` and `--logout` only deal with the agent itself, so they do not need a workspace: they skip the search and run without a `.mcp.json`. They still read a config named with `--mcp-json`, but `--list-models` never connects to the workspace: it runs the agent in an empty temporary directory, so the agent does not pick up the workspace's `.mcp.json` and get taken for the workspace's agent.
|
|
177
177
|
|
|
178
178
|
`--mcp-json <path>` names a config directly, wherever it lives and whatever it is called. It is read *as well as* whatever the search finds, with the named file winning any name collision — so a gateway started from somewhere other than its workspace still connects to the right one.
|
|
179
179
|
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { BoundedMap, FifoQueue } from "../collections.js";
|
|
3
|
+
describe("BoundedMap", () => {
|
|
4
|
+
it("rejects a capacity that could hold nothing", () => {
|
|
5
|
+
expect(() => new BoundedMap(0)).toThrow(RangeError);
|
|
6
|
+
expect(() => new BoundedMap(1.5)).toThrow(RangeError);
|
|
7
|
+
});
|
|
8
|
+
it("evicts the least recently written entry once full", () => {
|
|
9
|
+
const map = new BoundedMap(2);
|
|
10
|
+
map.set("a", 1).set("b", 2).set("c", 3);
|
|
11
|
+
expect([...map.keys()]).toEqual(["b", "c"]);
|
|
12
|
+
});
|
|
13
|
+
it("treats rewriting a key as fresh use", () => {
|
|
14
|
+
const map = new BoundedMap(2);
|
|
15
|
+
map.set("a", 1).set("b", 2).set("a", 10).set("c", 3);
|
|
16
|
+
expect([...map.entries()]).toEqual([
|
|
17
|
+
["a", 10],
|
|
18
|
+
["c", 3],
|
|
19
|
+
]);
|
|
20
|
+
});
|
|
21
|
+
it("does not count reads as use", () => {
|
|
22
|
+
const map = new BoundedMap(2);
|
|
23
|
+
map.set("a", 1).set("b", 2);
|
|
24
|
+
map.get("a");
|
|
25
|
+
map.set("c", 3);
|
|
26
|
+
expect(map.has("a")).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
it("keeps the rest of the Map interface", () => {
|
|
29
|
+
const map = new BoundedMap(3);
|
|
30
|
+
map.set("a", 1);
|
|
31
|
+
expect(map).toBeInstanceOf(Map);
|
|
32
|
+
expect(map.delete("a")).toBe(true);
|
|
33
|
+
expect(map.size).toBe(0);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
describe("FifoQueue", () => {
|
|
37
|
+
it("returns undefined when empty", () => {
|
|
38
|
+
const queue = new FifoQueue();
|
|
39
|
+
expect(queue.length).toBe(0);
|
|
40
|
+
expect(queue.shift()).toBeUndefined();
|
|
41
|
+
});
|
|
42
|
+
it("hands items back in the order they arrived, across compactions", () => {
|
|
43
|
+
const queue = new FifoQueue();
|
|
44
|
+
const out = [];
|
|
45
|
+
for (let i = 0; i < 10; i++)
|
|
46
|
+
queue.push(i);
|
|
47
|
+
for (let i = 0; i < 7; i++)
|
|
48
|
+
out.push(queue.shift());
|
|
49
|
+
expect(queue.length).toBe(3);
|
|
50
|
+
for (let i = 10; i < 15; i++)
|
|
51
|
+
queue.push(i);
|
|
52
|
+
while (queue.length > 0)
|
|
53
|
+
out.push(queue.shift());
|
|
54
|
+
expect(out).toEqual(Array.from({ length: 15 }, (_, i) => i));
|
|
55
|
+
expect(queue.shift()).toBeUndefined();
|
|
56
|
+
});
|
|
57
|
+
it("is reusable after being drained", () => {
|
|
58
|
+
const queue = new FifoQueue();
|
|
59
|
+
queue.push("a");
|
|
60
|
+
expect(queue.shift()).toBe("a");
|
|
61
|
+
queue.push("b");
|
|
62
|
+
expect(queue.length).toBe(1);
|
|
63
|
+
expect(queue.shift()).toBe("b");
|
|
64
|
+
});
|
|
65
|
+
it("drains a large backlog in order", () => {
|
|
66
|
+
const queue = new FifoQueue();
|
|
67
|
+
const n = 200_000;
|
|
68
|
+
for (let i = 0; i < n; i++)
|
|
69
|
+
queue.push(i);
|
|
70
|
+
let sum = 0;
|
|
71
|
+
for (let i = 0; i < n; i++)
|
|
72
|
+
sum += queue.shift();
|
|
73
|
+
expect(sum).toBe((n * (n - 1)) / 2);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=collections.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.test.js","sourceRoot":"","sources":["../../src/__tests__/collections.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE1D,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,OAA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CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,KAAK,GAAG,IAAI,SAAS,EAAU,CAAC;QACtC,MAAM,CAAC,GAAG,OAAO,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1C,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YAAE,GAAG,IAAI,KAAK,CAAC,KAAK,EAAG,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -2663,10 +2663,10 @@ describe("index", () => {
|
|
|
2663
2663
|
writeFileSync(file, JSON.stringify({ mcpServers: { "agentrq-ws": { type: "http", url: "http://localhost:1/mcp" } } }));
|
|
2664
2664
|
return file;
|
|
2665
2665
|
}
|
|
2666
|
-
it("should name the commands that only
|
|
2667
|
-
expect([...WORKSPACE_OPTIONAL_COMMANDS].sort()).toEqual(["agent-info", "list-auth-methods", "list-models"]);
|
|
2666
|
+
it("should name the commands that only deal with the agent itself", () => {
|
|
2667
|
+
expect([...WORKSPACE_OPTIONAL_COMMANDS].sort()).toEqual(["agent-info", "list-auth-methods", "list-models", "login", "logout"]);
|
|
2668
2668
|
});
|
|
2669
|
-
it.each(["list-models", "agent-info", "list-auth-methods"])("should let --%s run without a .mcp.json", (command) => {
|
|
2669
|
+
it.each(["list-models", "agent-info", "list-auth-methods", "login", "logout"])("should let --%s run without a .mcp.json", (command) => {
|
|
2670
2670
|
const workspace = loadWorkspace(command, undefined, emptyWorkspaceDir());
|
|
2671
2671
|
expect(workspace.configs).toEqual([]);
|
|
2672
2672
|
expect(workspace.agentrqConfig.env).toEqual({});
|
|
@@ -2678,7 +2678,7 @@ describe("index", () => {
|
|
|
2678
2678
|
writeFileSync(join(dir, ".mcp.json"), "{ not json");
|
|
2679
2679
|
expect(loadWorkspace("list-models", undefined, dir).configs).toEqual([]);
|
|
2680
2680
|
});
|
|
2681
|
-
it.each(["agent-info", "list-auth-methods"])("should still use a config named with --mcp-json for --%s", (command) => {
|
|
2681
|
+
it.each(["agent-info", "list-auth-methods", "login", "logout"])("should still use a config named with --mcp-json for --%s", (command) => {
|
|
2682
2682
|
const file = writeMcpJson(emptyWorkspaceDir(), "servers.json");
|
|
2683
2683
|
const workspace = loadWorkspace(command, file, emptyWorkspaceDir());
|
|
2684
2684
|
expect(workspace.agentrqConfig.name).toBe("agentrq-ws");
|
|
@@ -2694,8 +2694,8 @@ describe("index", () => {
|
|
|
2694
2694
|
it("should still report a --mcp-json path that is wrong", () => {
|
|
2695
2695
|
expect(() => loadWorkspace("list-models", "/nowhere/servers.json", emptyWorkspaceDir())).toThrow();
|
|
2696
2696
|
});
|
|
2697
|
-
it
|
|
2698
|
-
expect(() => loadWorkspace(
|
|
2697
|
+
it("should still require a .mcp.json to run tasks", () => {
|
|
2698
|
+
expect(() => loadWorkspace("run", undefined, emptyWorkspaceDir())).toThrow("Could not find .mcp.json");
|
|
2699
2699
|
});
|
|
2700
2700
|
it("should connect running tasks to the workspace it finds", () => {
|
|
2701
2701
|
const dir = emptyWorkspaceDir();
|