ceulen 0.8.0 → 0.9.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/CHANGELOG.md +35 -0
- package/extensions/lib/registry.ts +8 -1
- package/extensions/modules/a2a/configPanel.ts +435 -0
- package/extensions/modules/a2a/index.ts +1117 -0
- package/extensions/modules/a2a/lib/activity.ts +173 -0
- package/extensions/modules/a2a/lib/client.ts +1061 -0
- package/extensions/modules/a2a/lib/config.ts +920 -0
- package/extensions/modules/a2a/lib/discovery.ts +158 -0
- package/extensions/modules/a2a/lib/gateway.ts +889 -0
- package/extensions/modules/a2a/lib/mdns.ts +233 -0
- package/extensions/modules/a2a/lib/outcome.ts +48 -0
- package/extensions/modules/a2a/lib/persistence.ts +123 -0
- package/extensions/modules/a2a/lib/protocol.ts +506 -0
- package/extensions/modules/a2a/lib/registry.ts +146 -0
- package/extensions/modules/a2a/lib/retry.ts +86 -0
- package/extensions/modules/a2a/lib/security.ts +394 -0
- package/extensions/modules/a2a/lib/server.ts +1436 -0
- package/extensions/modules/a2a/test/activity.test.ts +138 -0
- package/extensions/modules/a2a/test/bridge.test.ts +101 -0
- package/extensions/modules/a2a/test/broadcast-parse.test.ts +31 -0
- package/extensions/modules/a2a/test/chai.ts +101 -0
- package/extensions/modules/a2a/test/client.test.ts +856 -0
- package/extensions/modules/a2a/test/completion-guard.test.ts +73 -0
- package/extensions/modules/a2a/test/config.test.ts +1396 -0
- package/extensions/modules/a2a/test/configPanel.test.ts +393 -0
- package/extensions/modules/a2a/test/discovery.test.ts +144 -0
- package/extensions/modules/a2a/test/extension.test.ts +135 -0
- package/extensions/modules/a2a/test/gateway.test.ts +1449 -0
- package/extensions/modules/a2a/test/helpers.ts +39 -0
- package/extensions/modules/a2a/test/mdns.test.ts +131 -0
- package/extensions/modules/a2a/test/outcome.test.ts +61 -0
- package/extensions/modules/a2a/test/persistence.test.ts +92 -0
- package/extensions/modules/a2a/test/protocol.test.ts +217 -0
- package/extensions/modules/a2a/test/registry.test.ts +114 -0
- package/extensions/modules/a2a/test/retry.test.ts +136 -0
- package/extensions/modules/a2a/test/security.test.ts +281 -0
- package/extensions/modules/a2a/test/server.test.ts +1966 -0
- package/extensions/modules/a2a/test/tmp.ts +59 -0
- package/extensions/modules/a2a/test/vendor.test.ts +57 -0
- package/extensions/modules/a2a/types/bonjour-service.d.ts +22 -0
- package/extensions/modules/a2a/vendor/VENDORED.md +18 -0
- package/extensions/modules/a2a/vendor/package.json +1 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/LICENSE +23 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/index.d.ts +14 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/index.js +57 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/KeyValue.d.ts +4 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/KeyValue.js +3 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/bonjour.d.ts +13 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/bonjour.js +50 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/browser.d.ts +41 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/browser.js +209 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/dns-txt.d.ts +9 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/dns-txt.js +42 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/mdns-server.d.ts +14 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/mdns-server.js +119 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/registry.d.ts +14 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/registry.js +142 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/service-types.d.ts +7 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/service-types.js +53 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/service.d.ts +58 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/service.js +130 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/dns-equal.d.ts +1 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/dns-equal.js +13 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/equal-txt.d.ts +1 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/equal-txt.js +17 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/filter-service.d.ts +4 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/filter-service.js +22 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/filter-txt.d.ts +3 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/filter-txt.js +6 -0
- package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/LICENSE +21 -0
- package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/classes.js +23 -0
- package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/index.js +1761 -0
- package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/opcodes.js +50 -0
- package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/optioncodes.js +59 -0
- package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/rcodes.js +50 -0
- package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/types.js +103 -0
- package/extensions/modules/a2a/vendor/vendored_deps/fast-deep-equal/LICENSE +21 -0
- package/extensions/modules/a2a/vendor/vendored_deps/fast-deep-equal/es6.js +73 -0
- package/extensions/modules/a2a/vendor/vendored_deps/fast-deep-equal/index.js +46 -0
- package/extensions/modules/a2a/vendor/vendored_deps/ip-codec/LICENSE +21 -0
- package/extensions/modules/a2a/vendor/vendored_deps/ip-codec/index.cjs +250 -0
- package/extensions/modules/a2a/vendor/vendored_deps/multicast-dns/LICENSE +21 -0
- package/extensions/modules/a2a/vendor/vendored_deps/multicast-dns/index.js +205 -0
- package/extensions/modules/a2a/vendor/vendored_deps/thunky/LICENSE +21 -0
- package/extensions/modules/a2a/vendor/vendored_deps/thunky/index.js +55 -0
- package/extensions/modules/composer/test/module.test.ts +2 -2
- package/extensions/modules/config/index.ts +2 -0
- package/extensions/modules/config/test/renderTools.test.ts +1 -1
- package/extensions/modules/todo/configPanel.ts +55 -0
- package/extensions/modules/todo/index.ts +46 -13
- package/extensions/modules/todo/lib/render.ts +271 -0
- package/extensions/modules/todo/lib/settings.ts +73 -0
- package/extensions/modules/todo/test/todo.test.ts +276 -0
- package/package.json +2 -2
- package/skills/a2a/SKILL.md +63 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { A2AConfig } from "../lib/config";
|
|
2
|
+
|
|
3
|
+
/** Fresh default config for tests (deep-ish copy — server is a nested object). */
|
|
4
|
+
export function DEFAULTS(): A2AConfig {
|
|
5
|
+
return {
|
|
6
|
+
peers: {},
|
|
7
|
+
selfIdentity: "",
|
|
8
|
+
server: {
|
|
9
|
+
enabled: false,
|
|
10
|
+
port: 9910,
|
|
11
|
+
portFallback: 10,
|
|
12
|
+
host: "127.0.0.1",
|
|
13
|
+
workspace: "",
|
|
14
|
+
maxConcurrent: 3,
|
|
15
|
+
replyTimeoutSec: 300,
|
|
16
|
+
asyncTimeoutSec: 86400,
|
|
17
|
+
agentName: "",
|
|
18
|
+
publicUrl: "",
|
|
19
|
+
sharedToken: "",
|
|
20
|
+
peerTokens: {},
|
|
21
|
+
trustedPeers: [],
|
|
22
|
+
allowAllUsers: false,
|
|
23
|
+
maxPingpongTurns: 5,
|
|
24
|
+
rateLimitPerMin: 60,
|
|
25
|
+
childTranscripts: true,
|
|
26
|
+
childTranscriptRetentionDays: 30,
|
|
27
|
+
skills: [],
|
|
28
|
+
},
|
|
29
|
+
timeouts: { send: 120000, async: 30000, stream: 120000 },
|
|
30
|
+
retryAttempts: 2,
|
|
31
|
+
verifySsl: true,
|
|
32
|
+
discovery: {
|
|
33
|
+
local: { enabled: true, heartbeatSec: 15, ttlSec: 60 },
|
|
34
|
+
mdns: { enabled: false, serviceType: "a2a" },
|
|
35
|
+
enrichCard: true,
|
|
36
|
+
},
|
|
37
|
+
ui: { transcript: true },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { assert } from "./chai.js";
|
|
2
|
+
|
|
3
|
+
import { startBroadcast, startDiscovery, txtRecord, mdnsPeerKey, mdnsInstanceName, mdnsInstanceHost } from "../lib/mdns";
|
|
4
|
+
import { describe, it, before, after, beforeEach, afterEach } from "node:test";
|
|
5
|
+
|
|
6
|
+
describe("mDNS", () => {
|
|
7
|
+
describe("startBroadcast / startDiscovery", () => {
|
|
8
|
+
// bonjour-service is an optional dep. Whether installed or not, the public
|
|
9
|
+
// API must return a handle and never throw.
|
|
10
|
+
//
|
|
11
|
+
// NOTE: these live-socket tests publish mDNS records. They stay off by
|
|
12
|
+
// default (opt in with MDNS_NETWORK_TESTS=1) because a naive publish
|
|
13
|
+
// would claim the OS local hostname and make macOS mDNSResponder rename
|
|
14
|
+
// the machine. When run, the pid-suffixed host claim is conflict-free
|
|
15
|
+
// (see mdnsInstanceHost tests).
|
|
16
|
+
const network = process.env.MDNS_NETWORK_TESTS === "1";
|
|
17
|
+
const each = network ? it : it.skip;
|
|
18
|
+
|
|
19
|
+
each("startBroadcast returns a handle without throwing", async () => {
|
|
20
|
+
const handle = await startBroadcast({
|
|
21
|
+
serviceType: "a2a",
|
|
22
|
+
name: "pi-test",
|
|
23
|
+
port: 49910, // bonjour-service only ADVERTISES the port; a nonzero value
|
|
24
|
+
// is required or the Service constructor throws and the test would
|
|
25
|
+
// silently exercise the graceful-degrade path instead of publishing.
|
|
26
|
+
txt: { url: "http://127.0.0.1:9910/", cwd: "/r", model: "anthropic/claude" },
|
|
27
|
+
});
|
|
28
|
+
assert.isOk(handle);
|
|
29
|
+
await handle.stop();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
each("startDiscovery returns a handle without throwing", async () => {
|
|
33
|
+
let fired = false;
|
|
34
|
+
const handle = await startDiscovery({
|
|
35
|
+
serviceType: "a2a",
|
|
36
|
+
onUp: () => {
|
|
37
|
+
fired = true;
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
assert.isOk(handle);
|
|
41
|
+
await handle.stop();
|
|
42
|
+
// We don't assert !fired — a real network may have peers. The contract
|
|
43
|
+
// is only "returns a handle, stop() is safe".
|
|
44
|
+
void fired;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
each("startDiscovery accepts an onDown callback without throwing", async () => {
|
|
48
|
+
const handle = await startDiscovery({
|
|
49
|
+
serviceType: "a2a",
|
|
50
|
+
onUp: () => {},
|
|
51
|
+
onDown: () => {},
|
|
52
|
+
});
|
|
53
|
+
assert.isOk(handle);
|
|
54
|
+
await handle.stop();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe("mdnsInstanceHost / mdnsInstanceName (hostname-claim guards)", () => {
|
|
59
|
+
it("claims a pid-suffixed name, never the OS hostname", () => {
|
|
60
|
+
assert.equal(mdnsInstanceHost("MBP-Sao.local", 1234), "mbp-sao-local-a2a-1234.local");
|
|
61
|
+
// Regression guard: announcing this host must NOT claim the OS name
|
|
62
|
+
// (that is what makes macOS rename the machine).
|
|
63
|
+
assert.notEqual(mdnsInstanceHost("MBP-Sao.local", 1234), "MBP-Sao.local");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("sanitizes to RFC 6762-safe labels and caps at 63 chars", () => {
|
|
67
|
+
const h = mdnsInstanceHost("Weird Host_Name!", 7);
|
|
68
|
+
assert.equal(h, "weird-host-name-a2a-7.local");
|
|
69
|
+
assert.isTrue(h.length <= 63, "label must fit a DNS label");
|
|
70
|
+
const long = mdnsInstanceHost("x".repeat(100), 1);
|
|
71
|
+
assert.isTrue(long.length <= 63);
|
|
72
|
+
assert.equal(mdnsInstanceHost("", 5), "pi-a2a-5.local");
|
|
73
|
+
// Instance names get the same suffix-aware cap (long agentName must not
|
|
74
|
+
// produce malformed >63-octet labels that peers silently reject).
|
|
75
|
+
assert.isTrue(mdnsInstanceName("x".repeat(100), 1234567).length <= 63);
|
|
76
|
+
assert.equal(mdnsInstanceName("a", 1), "a-1");
|
|
77
|
+
// Capping at a dash boundary must not produce a double hyphen.
|
|
78
|
+
// Inputs are tuned so the sanitized form is longer than the cap AND has
|
|
79
|
+
// a hyphen exactly at the slice cut (index 63 - suffix.length - 1).
|
|
80
|
+
const nameBoundary = "a".repeat(60) + "-b" + "c".repeat(10); // cut for pid 1 lands on the hyphen
|
|
81
|
+
const hostBoundary = "a".repeat(50) + "-b" + "c".repeat(10); // cut for host lands on the hyphen
|
|
82
|
+
assert.notMatch(mdnsInstanceName(nameBoundary, 1), /--/);
|
|
83
|
+
assert.notMatch(mdnsInstanceHost(hostBoundary, 1), /--/);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("makes per-session instance names unique (no probe collision)", () => {
|
|
87
|
+
assert.equal(mdnsInstanceName("My Pi!", 7), "my-pi-7");
|
|
88
|
+
assert.notEqual(mdnsInstanceName("same-agent", 100), mdnsInstanceName("same-agent", 200));
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe("mdnsPeerKey (dedup)", () => {
|
|
93
|
+
it("uses txt.url when present", () => {
|
|
94
|
+
assert.equal(
|
|
95
|
+
mdnsPeerKey({ name: "a", host: "h", port: 1, txt: { url: "http://1.2.3.4:9910//" } }),
|
|
96
|
+
"http://1.2.3.4:9910",
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
it("falls back to name:host:port when no txt.url", () => {
|
|
100
|
+
assert.equal(mdnsPeerKey({ name: "pi", host: "10.0.0.1", port: 9910 }), "pi:10.0.0.1:9910");
|
|
101
|
+
assert.equal(mdnsPeerKey({ name: "pi", host: "10.0.0.1", port: 9910, txt: {} }), "pi:10.0.0.1:9910");
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe("txtRecord", () => {
|
|
106
|
+
it("packs session essentials into a string map", () => {
|
|
107
|
+
const txt = txtRecord({ url: "http://1.2.3.4:9910/", cwd: "/repo", model: "anthropic/claude" });
|
|
108
|
+
assert.deepEqual(txt, {
|
|
109
|
+
url: "http://1.2.3.4:9910/",
|
|
110
|
+
cwd: "/repo",
|
|
111
|
+
model: "anthropic/claude",
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("caps every value at 255 UTF-8 bytes (RFC 1035 char-string limit)", () => {
|
|
116
|
+
const txt = txtRecord({
|
|
117
|
+
url: "http://x/" + "x".repeat(300),
|
|
118
|
+
cwd: "/" + "d".repeat(300),
|
|
119
|
+
model: "m".repeat(300),
|
|
120
|
+
});
|
|
121
|
+
for (const v of Object.values(txt)) {
|
|
122
|
+
assert.isAtMost(Buffer.byteLength(v, "utf-8"), 255, "TXT value must fit one byte length prefix");
|
|
123
|
+
}
|
|
124
|
+
// Cuts on a char boundary — multibyte input must not split a codepoint.
|
|
125
|
+
const unicode = "\u00e9".repeat(300); // é is 2 bytes in UTF-8
|
|
126
|
+
const capped = txtRecord({ url: unicode, cwd: "c", model: "m" }).url!;
|
|
127
|
+
assert.isAtMost(Buffer.byteLength(capped, "utf-8"), 255);
|
|
128
|
+
assert.equal([...capped].length * 2, Buffer.byteLength(capped, "utf-8"), "no split codepoints");
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, it } from "node:test";
|
|
2
|
+
import { assert } from "./chai.js";
|
|
3
|
+
import { stripInputRequired, terminalOutcomeError } from "../lib/outcome.js";
|
|
4
|
+
|
|
5
|
+
describe("terminal outcome (#314, #425)", () => {
|
|
6
|
+
it("a normal text ending is a success", () => {
|
|
7
|
+
assert.isNull(terminalOutcomeError({ stopReason: "stop", hadText: true, sawAssistant: true }));
|
|
8
|
+
});
|
|
9
|
+
it("a tool-use ending with text is a success", () => {
|
|
10
|
+
assert.isNull(terminalOutcomeError({ stopReason: "toolUse", hadText: true, sawAssistant: true }));
|
|
11
|
+
});
|
|
12
|
+
it("a provider error on the final turn fails, carrying the error", () => {
|
|
13
|
+
const e = terminalOutcomeError({ stopReason: "error", hadText: false, sawAssistant: true, errorMessage: '503: {"message":"no available channel"}' });
|
|
14
|
+
assert.match(e!, /model call failed on the final turn: 503/);
|
|
15
|
+
});
|
|
16
|
+
it("a provider error fails even when an earlier turn left text behind", () => {
|
|
17
|
+
assert.isNotNull(terminalOutcomeError({ stopReason: "error", hadText: true, sawAssistant: true }));
|
|
18
|
+
});
|
|
19
|
+
it("no assistant output at all fails", () => {
|
|
20
|
+
assert.match(terminalOutcomeError({ hadText: false, sawAssistant: false })!, /without any assistant output/);
|
|
21
|
+
});
|
|
22
|
+
it("a length stop with no text still fails (#314)", () => {
|
|
23
|
+
assert.match(terminalOutcomeError({ stopReason: "length", hadText: false, sawAssistant: true })!, /length stop/);
|
|
24
|
+
});
|
|
25
|
+
it("a length stop that produced text is a success", () => {
|
|
26
|
+
assert.isNull(terminalOutcomeError({ stopReason: "length", hadText: true, sawAssistant: true }));
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe("stripInputRequired (tail-anchored marker)", () => {
|
|
31
|
+
it("a marker at the trimmed tail flips the state and is stripped once", () => {
|
|
32
|
+
const r = stripInputRequired("need more info [INPUT_REQUIRED]");
|
|
33
|
+
assert.equal(r.text, "need more info");
|
|
34
|
+
assert.isTrue(r.inputRequired);
|
|
35
|
+
});
|
|
36
|
+
it("trailing whitespace after the marker still counts", () => {
|
|
37
|
+
const r = stripInputRequired("ok [INPUT_REQUIRED] \n");
|
|
38
|
+
assert.equal(r.text, "ok");
|
|
39
|
+
assert.isTrue(r.inputRequired);
|
|
40
|
+
});
|
|
41
|
+
it("a quoted marker mid-text neither flips the state nor mangles the text", () => {
|
|
42
|
+
const r = stripInputRequired("earlier log said [INPUT_REQUIRED] but we moved on");
|
|
43
|
+
assert.equal(r.text, "earlier log said [INPUT_REQUIRED] but we moved on");
|
|
44
|
+
assert.isFalse(r.inputRequired);
|
|
45
|
+
});
|
|
46
|
+
it("a marker as message prefix is content, not a signal", () => {
|
|
47
|
+
const r = stripInputRequired("[INPUT_REQUIRED] is the marker syntax");
|
|
48
|
+
assert.isFalse(r.inputRequired);
|
|
49
|
+
assert.equal(r.text, "[INPUT_REQUIRED] is the marker syntax");
|
|
50
|
+
});
|
|
51
|
+
it("a bare marker strips to empty text", () => {
|
|
52
|
+
const r = stripInputRequired("[INPUT_REQUIRED]");
|
|
53
|
+
assert.equal(r.text, "");
|
|
54
|
+
assert.isTrue(r.inputRequired);
|
|
55
|
+
});
|
|
56
|
+
it("matching is case-insensitive", () => {
|
|
57
|
+
const r = stripInputRequired("hi [input_required]");
|
|
58
|
+
assert.isTrue(r.inputRequired);
|
|
59
|
+
assert.equal(r.text, "hi");
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { assert } from "./chai.js";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { makeTempDir } from "./tmp";
|
|
5
|
+
import { persistMessage, loadConversation, listConversations, childTranscriptDir, sweepChildTranscripts } from "../lib/persistence";
|
|
6
|
+
import { describe, it, before, after, beforeEach, afterEach } from "node:test";
|
|
7
|
+
|
|
8
|
+
function tmpDir(): string {
|
|
9
|
+
return makeTempDir("pi-a2a-persist-");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe("persistence", () => {
|
|
13
|
+
it("round-trips messages to JSONL", () => {
|
|
14
|
+
const dir = tmpDir();
|
|
15
|
+
persistMessage({ piDir: dir, contextId: "ctx-1", role: "user", text: "hello" });
|
|
16
|
+
persistMessage({ piDir: dir, contextId: "ctx-1", role: "agent", text: "hi back" });
|
|
17
|
+
const msgs = loadConversation(dir, "ctx-1");
|
|
18
|
+
assert.lengthOf(msgs, 2);
|
|
19
|
+
assert.equal(msgs[0]!.role, "user");
|
|
20
|
+
assert.equal(msgs[0]!.text, "hello");
|
|
21
|
+
assert.equal(msgs[1]!.role, "agent");
|
|
22
|
+
assert.equal(msgs[1]!.text, "hi back");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("returns [] for an unknown context", () => {
|
|
26
|
+
const dir = tmpDir();
|
|
27
|
+
assert.deepEqual(loadConversation(dir, "nope"), []);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("respects the limit (last N)", () => {
|
|
31
|
+
const dir = tmpDir();
|
|
32
|
+
for (let i = 0; i < 10; i++) {
|
|
33
|
+
persistMessage({ piDir: dir, contextId: "ctx-2", role: "user", text: `m${i}` });
|
|
34
|
+
}
|
|
35
|
+
const msgs = loadConversation(dir, "ctx-2", 3);
|
|
36
|
+
assert.lengthOf(msgs, 3);
|
|
37
|
+
assert.equal(msgs[0]!.text, "m7");
|
|
38
|
+
assert.equal(msgs[2]!.text, "m9");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("lists conversations", () => {
|
|
42
|
+
const dir = tmpDir();
|
|
43
|
+
persistMessage({ piDir: dir, contextId: "ctx-a", role: "user", text: "x" });
|
|
44
|
+
persistMessage({ piDir: dir, contextId: "ctx-b", role: "user", text: "y" });
|
|
45
|
+
const list = listConversations(dir);
|
|
46
|
+
assert.includeMembers(list, ["ctx-a", "ctx-b"]);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe("child transcript sweep (#252)", () => {
|
|
51
|
+
function touch(dir: string, name: string, ageDays: number): string {
|
|
52
|
+
const p = path.join(dir, name);
|
|
53
|
+
fs.writeFileSync(p, "{}\n");
|
|
54
|
+
const t = new Date(Date.now() - ageDays * 86_400_000);
|
|
55
|
+
fs.utimesSync(p, t, t);
|
|
56
|
+
return p;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
it("childTranscriptDir sits under the pi dir", () => {
|
|
60
|
+
assert.equal(childTranscriptDir("/tmp/agent"), path.join("/tmp/agent", "a2a_sessions"));
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("deletes only transcripts older than the retention window", () => {
|
|
64
|
+
const dir = tmpDir();
|
|
65
|
+
fs.mkdirSync(path.join(dir, "a2a_sessions"), { recursive: true });
|
|
66
|
+
const sessions = path.join(dir, "a2a_sessions");
|
|
67
|
+
const old = touch(sessions, "20260101T000000_task-old.jsonl", 40);
|
|
68
|
+
const fresh = touch(sessions, "20260830T000000_task-new.jsonl", 1);
|
|
69
|
+
const removed = sweepChildTranscripts(sessions, 30);
|
|
70
|
+
assert.equal(removed, 1);
|
|
71
|
+
assert.isFalse(fs.existsSync(old), "past-retention transcript removed");
|
|
72
|
+
assert.isTrue(fs.existsSync(fresh), "within-retention transcript kept");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("ignores non-jsonl files", () => {
|
|
76
|
+
const dir = tmpDir();
|
|
77
|
+
const old = touch(dir, "notes.txt", 400);
|
|
78
|
+
assert.equal(sweepChildTranscripts(dir, 30), 0);
|
|
79
|
+
assert.isTrue(fs.existsSync(old));
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("retentionDays 0 keeps everything", () => {
|
|
83
|
+
const dir = tmpDir();
|
|
84
|
+
const old = touch(dir, "20260101T000000_task-old.jsonl", 400);
|
|
85
|
+
assert.equal(sweepChildTranscripts(dir, 0), 0);
|
|
86
|
+
assert.isTrue(fs.existsSync(old));
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("missing dir is a no-op, never a throw", () => {
|
|
90
|
+
assert.equal(sweepChildTranscripts(path.join(tmpDir(), "nope"), 30), 0);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { assert } from "./chai.js";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
PROTOCOL_VERSION,
|
|
5
|
+
PI_SESSION_EXTENSION_URI,
|
|
6
|
+
buildAgentCard,
|
|
7
|
+
buildTask,
|
|
8
|
+
extractText,
|
|
9
|
+
jsonrpcError,
|
|
10
|
+
jsonrpcResult,
|
|
11
|
+
normalizeRole,
|
|
12
|
+
normalizeState,
|
|
13
|
+
sendMessageResponse,
|
|
14
|
+
STATE_CANCELED,
|
|
15
|
+
STATE_COMPLETED,
|
|
16
|
+
STATE_FAILED,
|
|
17
|
+
STATE_INPUT_REQUIRED,
|
|
18
|
+
STATE_SUBMITTED,
|
|
19
|
+
STATE_WORKING,
|
|
20
|
+
TERMINAL_STATES,
|
|
21
|
+
textMessage,
|
|
22
|
+
textPart,
|
|
23
|
+
filePart,
|
|
24
|
+
dataPart,
|
|
25
|
+
unwrapSendMessageResponse,
|
|
26
|
+
ROLE_AGENT,
|
|
27
|
+
ROLE_USER,
|
|
28
|
+
} from "../lib/protocol";
|
|
29
|
+
import { describe, it, before, after, beforeEach, afterEach } from "node:test";
|
|
30
|
+
|
|
31
|
+
describe("protocol", () => {
|
|
32
|
+
describe("constants & states", () => {
|
|
33
|
+
it("pins protocol version to 1.0", () => {
|
|
34
|
+
assert.equal(PROTOCOL_VERSION, "1.0");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("marks the terminal states correctly", () => {
|
|
38
|
+
assert.isTrue(TERMINAL_STATES.has(STATE_COMPLETED));
|
|
39
|
+
assert.isTrue(TERMINAL_STATES.has(STATE_FAILED));
|
|
40
|
+
assert.isTrue(TERMINAL_STATES.has(STATE_CANCELED));
|
|
41
|
+
assert.isFalse(TERMINAL_STATES.has(STATE_WORKING));
|
|
42
|
+
assert.isFalse(TERMINAL_STATES.has(STATE_SUBMITTED));
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("normalizes v0.3 lowercase states to v1.0", () => {
|
|
46
|
+
assert.equal(normalizeState("completed"), STATE_COMPLETED);
|
|
47
|
+
assert.equal(normalizeState("working"), STATE_WORKING);
|
|
48
|
+
assert.equal(normalizeState("input_required"), STATE_INPUT_REQUIRED);
|
|
49
|
+
assert.equal(normalizeState("TASK_STATE_FAILED"), STATE_FAILED);
|
|
50
|
+
assert.equal(normalizeState(undefined), "");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("normalizes v0.3 roles to v1.0", () => {
|
|
54
|
+
assert.equal(normalizeRole("user"), ROLE_USER);
|
|
55
|
+
assert.equal(normalizeRole("agent"), ROLE_AGENT);
|
|
56
|
+
assert.equal(normalizeRole("assistant"), ROLE_AGENT);
|
|
57
|
+
assert.equal(normalizeRole("ROLE_USER"), ROLE_USER);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe("Agent Card", () => {
|
|
62
|
+
it("builds a v1.0 card with a JSONRPC interface", () => {
|
|
63
|
+
const card = buildAgentCard({
|
|
64
|
+
name: "pi",
|
|
65
|
+
url: "http://localhost:9910/",
|
|
66
|
+
});
|
|
67
|
+
assert.equal(card.name, "pi");
|
|
68
|
+
assert.equal(card.version, "1.0.0");
|
|
69
|
+
assert.equal(card.supportedInterfaces[0]?.protocolBinding, "JSONRPC");
|
|
70
|
+
assert.equal(card.supportedInterfaces[0]?.protocolVersion, PROTOCOL_VERSION);
|
|
71
|
+
assert.equal(card.supportedInterfaces[0]?.url, "http://localhost:9910/");
|
|
72
|
+
assert.isFalse(card.capabilities.streaming);
|
|
73
|
+
assert.isUndefined(card.securitySchemes);
|
|
74
|
+
assert.equal(card.defaultInputModes[0], "text/plain");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("advertises bearer auth when required", () => {
|
|
78
|
+
const card = buildAgentCard({ name: "pi", url: "http://x/", authRequired: true });
|
|
79
|
+
// A2A v1.0 shape (fleet task #427): oneof-wrapped scheme + securityRequirements with StringList scopes.
|
|
80
|
+
assert.deepEqual(card.securitySchemes, { bearer: { httpAuthSecurityScheme: { scheme: "bearer" } } });
|
|
81
|
+
assert.deepEqual(card.securityRequirements, [{ schemes: { bearer: { list: [] } } }]);
|
|
82
|
+
// v0.3 alias kept for hermes a2a_discover (eaef8e95).
|
|
83
|
+
assert.deepEqual(card.security, [{ bearer: [] }]);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("uses configured skills and caps", () => {
|
|
87
|
+
const card = buildAgentCard({
|
|
88
|
+
name: "pi",
|
|
89
|
+
url: "http://x/",
|
|
90
|
+
streaming: true,
|
|
91
|
+
pushNotifications: true,
|
|
92
|
+
skills: [{ id: "s1", name: "coding", description: "d" }],
|
|
93
|
+
});
|
|
94
|
+
assert.isTrue(card.capabilities.streaming);
|
|
95
|
+
assert.isTrue(card.capabilities.pushNotifications);
|
|
96
|
+
assert.equal(card.skills[0]?.id, "s1");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("omits extensions/metadata when no sessionMetadata provided", () => {
|
|
100
|
+
const card = buildAgentCard({ name: "pi", url: "http://x/" });
|
|
101
|
+
assert.isUndefined(card.capabilities.extensions);
|
|
102
|
+
assert.isUndefined(card.metadata);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("emits the pi-session extension + metadata when sessionMetadata provided", () => {
|
|
106
|
+
const card = buildAgentCard({
|
|
107
|
+
name: "pi",
|
|
108
|
+
url: "http://localhost:9910/",
|
|
109
|
+
sessionMetadata: {
|
|
110
|
+
pid: 12345,
|
|
111
|
+
cwd: "/repo",
|
|
112
|
+
model: { provider: "anthropic", id: "claude" },
|
|
113
|
+
tools: ["bash", "read"],
|
|
114
|
+
startedAt: "2026-01-01T00:00:00Z",
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
assert.isDefined(card.capabilities.extensions);
|
|
118
|
+
assert.lengthOf(card.capabilities.extensions!, 1);
|
|
119
|
+
assert.equal(card.capabilities.extensions![0]!.uri, PI_SESSION_EXTENSION_URI);
|
|
120
|
+
assert.isFalse(card.capabilities.extensions![0]!.required);
|
|
121
|
+
assert.deepEqual(card.metadata, {
|
|
122
|
+
pid: 12345,
|
|
123
|
+
cwd: "/repo",
|
|
124
|
+
model: { provider: "anthropic", id: "claude" },
|
|
125
|
+
tools: ["bash", "read"],
|
|
126
|
+
startedAt: "2026-01-01T00:00:00Z",
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
describe("JSON-RPC framing", () => {
|
|
132
|
+
it("wraps results and errors", () => {
|
|
133
|
+
assert.deepEqual(jsonrpcResult(1, { ok: true }), { jsonrpc: "2.0", id: 1, result: { ok: true } });
|
|
134
|
+
assert.deepEqual(jsonrpcError(2, -32001, "nope"), {
|
|
135
|
+
jsonrpc: "2.0",
|
|
136
|
+
id: 2,
|
|
137
|
+
error: { code: -32001, message: "nope" },
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("wraps a Task payload as {task}, a Message as {message}", () => {
|
|
142
|
+
const task = buildTask({ id: "t1", contextId: "c1" });
|
|
143
|
+
assert.deepEqual(sendMessageResponse(task), { task });
|
|
144
|
+
const msg = textMessage(ROLE_AGENT, "hi");
|
|
145
|
+
assert.deepEqual(sendMessageResponse(msg), { message: msg });
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("unwraps v1.0 {task}/{message} and passes legacy through", () => {
|
|
149
|
+
const task = { id: "t1", status: { state: STATE_COMPLETED } };
|
|
150
|
+
assert.deepEqual(unwrapSendMessageResponse({ task }), task);
|
|
151
|
+
assert.deepEqual(unwrapSendMessageResponse({ message: { x: 1 } }), { x: 1 });
|
|
152
|
+
// legacy bare payload passes through
|
|
153
|
+
assert.deepEqual(unwrapSendMessageResponse(task), task);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe("Parts — extractText (v1.0 + v0.3 tolerant)", () => {
|
|
158
|
+
it("extracts v1.0 text parts", () => {
|
|
159
|
+
const msg = { parts: [textPart("hello"), textPart("world")] };
|
|
160
|
+
assert.equal(extractText(msg), "hello\nworld");
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("renders v1.0 file parts with url", () => {
|
|
164
|
+
const msg = { parts: [filePart({ url: "http://x/f.txt", filename: "f.txt", mediaType: "text/plain" })] };
|
|
165
|
+
assert.equal(extractText(msg), "[file: f.txt] http://x/f.txt (text/plain)");
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("notes raw base64 file parts without decoding", () => {
|
|
169
|
+
const msg = { parts: [filePart({ raw: "AAAABBBBB", filename: "bin", mediaType: "image/png" })] };
|
|
170
|
+
assert.equal(extractText(msg), "[file: bin] 9 bytes base64-encoded (image/png)");
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it("renders v1.0 data parts as JSON", () => {
|
|
174
|
+
const msg = { parts: [dataPart({ a: 1 })] };
|
|
175
|
+
assert.equal(extractText(msg), JSON.stringify({ a: 1 }));
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it("accepts v0.3 kind:text parts", () => {
|
|
179
|
+
const msg = { parts: [{ kind: "text", text: "legacy" }] };
|
|
180
|
+
assert.equal(extractText(msg), "legacy");
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it("accepts v0.3 file with nested fileWithUri", () => {
|
|
184
|
+
const msg = {
|
|
185
|
+
parts: [{ file: { fileWithUri: "http://x/a.png", name: "a.png", mimeType: "image/png" } }],
|
|
186
|
+
};
|
|
187
|
+
assert.equal(extractText(msg), "[file: a.png] http://x/a.png (image/png)");
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it("pulls text from a Task result (artifacts first, then status.message)", () => {
|
|
191
|
+
const taskWithArtifact = {
|
|
192
|
+
artifacts: [{ parts: [textPart("artifact reply")] }],
|
|
193
|
+
};
|
|
194
|
+
assert.equal(extractText(taskWithArtifact), "artifact reply");
|
|
195
|
+
|
|
196
|
+
const taskWithStatusMsg = {
|
|
197
|
+
status: { message: { parts: [textPart("status reply")] } },
|
|
198
|
+
};
|
|
199
|
+
assert.equal(extractText(taskWithStatusMsg), "status reply");
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
describe("Task construction", () => {
|
|
204
|
+
it("builds a submitted task by default", () => {
|
|
205
|
+
const t = buildTask({ id: "t1", contextId: "c1" });
|
|
206
|
+
assert.equal(t.id, "t1");
|
|
207
|
+
assert.equal(t.contextId, "c1");
|
|
208
|
+
assert.equal(t.status.state, STATE_SUBMITTED);
|
|
209
|
+
assert.isString(t.status.timestamp);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("accepts an explicit state", () => {
|
|
213
|
+
const t = buildTask({ id: "t1", contextId: "c1", state: STATE_INPUT_REQUIRED });
|
|
214
|
+
assert.equal(t.status.state, STATE_INPUT_REQUIRED);
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { assert } from "./chai.js";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { makeTempDir } from "./tmp";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
heartbeat,
|
|
8
|
+
list,
|
|
9
|
+
register,
|
|
10
|
+
unregister,
|
|
11
|
+
type SessionDescriptor,
|
|
12
|
+
} from "../lib/registry";
|
|
13
|
+
import { describe, it, before, after, beforeEach, afterEach } from "node:test";
|
|
14
|
+
|
|
15
|
+
function tmpPiDir(): string {
|
|
16
|
+
return makeTempDir("pi-a2a-registry-");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function desc(pid: number, overrides: Partial<SessionDescriptor> = {}): SessionDescriptor {
|
|
20
|
+
return {
|
|
21
|
+
pid,
|
|
22
|
+
url: `http://127.0.0.1:9910/`,
|
|
23
|
+
port: 9910,
|
|
24
|
+
host: "127.0.0.1",
|
|
25
|
+
cwd: "/repo",
|
|
26
|
+
model: { provider: "anthropic", id: "claude", name: "Claude" },
|
|
27
|
+
agentName: "pi",
|
|
28
|
+
tools: ["bash", "read"],
|
|
29
|
+
skills: [],
|
|
30
|
+
startedAt: new Date().toISOString(),
|
|
31
|
+
mtime: Date.now(),
|
|
32
|
+
...overrides,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
describe("session registry", () => {
|
|
37
|
+
it("register → list roundtrip returns the descriptor", () => {
|
|
38
|
+
const dir = tmpPiDir();
|
|
39
|
+
register(desc(11111), dir);
|
|
40
|
+
const got = list({ piDir: dir, ttlSec: 60, aliveProbe: () => true });
|
|
41
|
+
assert.lengthOf(got, 1);
|
|
42
|
+
assert.strictEqual(got[0]!.pid, 11111);
|
|
43
|
+
assert.strictEqual(got[0]!.cwd, "/repo");
|
|
44
|
+
assert.strictEqual(got[0]!.model?.provider, "anthropic");
|
|
45
|
+
assert.deepEqual(got[0]!.tools, ["bash", "read"]);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("list ignores files that do not match <pid>.json", () => {
|
|
49
|
+
const dir = tmpPiDir();
|
|
50
|
+
register(desc(22222), dir);
|
|
51
|
+
// stray non-registry file in the dir
|
|
52
|
+
fs.writeFileSync(path.join(dir, "a2a_registry", "README.md"), "noise");
|
|
53
|
+
fs.writeFileSync(path.join(dir, "a2a_registry", "abc.json"), "{}");
|
|
54
|
+
const got = list({ piDir: dir, ttlSec: 60, aliveProbe: () => true });
|
|
55
|
+
assert.lengthOf(got, 1);
|
|
56
|
+
assert.strictEqual(got[0]!.pid, 22222);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("sweeps stale entries by mtime TTL", () => {
|
|
60
|
+
const dir = tmpPiDir();
|
|
61
|
+
const d = desc(33333, { mtime: Date.now() - 120_000 }); // 2 min ago
|
|
62
|
+
register(d, dir);
|
|
63
|
+
// Force the on-disk mtime into the past so the sweep triggers.
|
|
64
|
+
const p = path.join(dir, "a2a_registry", "33333.json");
|
|
65
|
+
const past = new Date(Date.now() - 120_000);
|
|
66
|
+
fs.utimesSync(p, past, past);
|
|
67
|
+
const got = list({ piDir: dir, ttlSec: 60, aliveProbe: () => true });
|
|
68
|
+
assert.lengthOf(got, 0, "stale entry should be swept");
|
|
69
|
+
// Self-heal: file removed.
|
|
70
|
+
assert.isFalse(fs.existsSync(p));
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("sweeps dead-pid entries via aliveProbe", () => {
|
|
74
|
+
const dir = tmpPiDir();
|
|
75
|
+
register(desc(44444), dir);
|
|
76
|
+
const got = list({ piDir: dir, ttlSec: 60, aliveProbe: () => false });
|
|
77
|
+
assert.lengthOf(got, 0, "dead-pid entry should be swept");
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("heartbeat refreshes mtime so a TTL sweep keeps the entry", () => {
|
|
81
|
+
const dir = tmpPiDir();
|
|
82
|
+
const d = desc(55555, { mtime: Date.now() - 120_000 });
|
|
83
|
+
heartbeat(d, dir); // bumps mtime to now
|
|
84
|
+
const got = list({ piDir: dir, ttlSec: 60, aliveProbe: () => true });
|
|
85
|
+
assert.lengthOf(got, 1);
|
|
86
|
+
assert.strictEqual(got[0]!.pid, 55555);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("unregister removes the file and is idempotent", () => {
|
|
90
|
+
const dir = tmpPiDir();
|
|
91
|
+
register(desc(66666), dir);
|
|
92
|
+
unregister(66666, dir);
|
|
93
|
+
assert.lengthOf(list({ piDir: dir, ttlSec: 60, aliveProbe: () => true }), 0);
|
|
94
|
+
// second unregister must not throw
|
|
95
|
+
unregister(66666, dir);
|
|
96
|
+
assert.lengthOf(list({ piDir: dir, ttlSec: 60, aliveProbe: () => true }), 0);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("list on a missing directory returns [] (no throw)", () => {
|
|
100
|
+
const dir = tmpPiDir();
|
|
101
|
+
fs.rmSync(path.join(dir, "a2a_registry"), { recursive: true, force: true });
|
|
102
|
+
assert.lengthOf(list({ piDir: dir }), 0);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("multiple live sessions coexist", () => {
|
|
106
|
+
const dir = tmpPiDir();
|
|
107
|
+
register(desc(100, { cwd: "/repo-a" }), dir);
|
|
108
|
+
register(desc(200, { cwd: "/repo-b" }), dir);
|
|
109
|
+
register(desc(300, { cwd: "/repo-c" }), dir);
|
|
110
|
+
const got = list({ piDir: dir, ttlSec: 60, aliveProbe: () => true }).sort((a, b) => a.pid - b.pid);
|
|
111
|
+
assert.lengthOf(got, 3);
|
|
112
|
+
assert.deepEqual(got.map((d) => d.cwd), ["/repo-a", "/repo-b", "/repo-c"]);
|
|
113
|
+
});
|
|
114
|
+
});
|