ceulen 0.7.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 +83 -0
- package/extensions/lib/registry.test.ts +67 -0
- package/extensions/lib/registry.ts +24 -7
- 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/advisor/index.ts +20 -2
- package/extensions/modules/advisor/lib/watcher.ts +3 -1
- package/extensions/modules/advisor/test/module.test.ts +64 -1
- 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/munin/configPanel.ts +5 -2
- package/extensions/modules/munin/test/configPanel.test.ts +27 -2
- package/extensions/modules/router/configPanel.ts +24 -10
- package/extensions/modules/router/lib/client.ts +6 -4
- package/extensions/modules/router/test/unit.test.ts +83 -2
- package/extensions/modules/rules/index.ts +120 -0
- package/extensions/modules/rules/lib/rules.ts +348 -0
- package/extensions/modules/rules/test/lib.test.ts +263 -0
- package/extensions/modules/rules/test/module.test.ts +222 -0
- package/extensions/modules/subagent/index.ts +19 -6
- package/extensions/modules/subagent/lib/routing.ts +11 -6
- package/extensions/modules/subagent/lib/security.ts +12 -1
- package/extensions/modules/subagent/test/routing.test.ts +174 -0
- package/extensions/modules/todo/configPanel.ts +55 -0
- package/extensions/modules/todo/index.ts +511 -0
- 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 +528 -0
- package/extensions/modules/usage/index.ts +11 -0
- package/extensions/modules/usage/test/session-accumulators.test.ts +85 -0
- package/extensions/modules/web/configPanel.ts +38 -13
- package/extensions/modules/web/lib/settings.ts +11 -2
- package/extensions/modules/web/test/configPanel.test.ts +67 -1
- package/extensions/modules/zai/configPanel.ts +5 -2
- package/extensions/modules/zai/lib/signing.ts +4 -1
- package/extensions/modules/zai/test/configPanel.test.ts +23 -0
- package/extensions/modules/zai/test/signing.test.ts +19 -0
- package/package.json +2 -2
- package/skills/a2a/SKILL.md +63 -0
|
@@ -20,7 +20,8 @@ import {
|
|
|
20
20
|
} from "./lib/config.js";
|
|
21
21
|
import {
|
|
22
22
|
ENV_TO_SETTINGS_KEY,
|
|
23
|
-
|
|
23
|
+
readProjectWebSection,
|
|
24
|
+
sectionValue,
|
|
24
25
|
writeWebSection,
|
|
25
26
|
} from "./lib/settings.js";
|
|
26
27
|
|
|
@@ -146,6 +147,31 @@ export function buildWebGroups(working: Record<string, string>): PanelGroup[] {
|
|
|
146
147
|
|
|
147
148
|
const OWNED_PREFIX = "web.";
|
|
148
149
|
|
|
150
|
+
/** The save patch for the rows edited since the pre-edit snapshot. Number rows
|
|
151
|
+
* persist as numbers (timeoutMs semantics), strings as strings, and an empty
|
|
152
|
+
* string clears the key (writeWebSection semantics). Free text that is not a
|
|
153
|
+
* finite number is SKIPPED — writing 0 would clobber the stored cap with a
|
|
154
|
+
* value the consumer then clamps (or bricks the timeout loaders). Exported
|
|
155
|
+
* for tests. */
|
|
156
|
+
export function diffWebPatch(
|
|
157
|
+
working: Record<string, string>,
|
|
158
|
+
before: Record<string, string>,
|
|
159
|
+
): Record<string, string | number> {
|
|
160
|
+
const patch: Record<string, string | number> = {};
|
|
161
|
+
for (const spec of webRowSpecs()) {
|
|
162
|
+
if (working[spec.key] === before[spec.key]) continue;
|
|
163
|
+
const raw = working[spec.key] ?? "";
|
|
164
|
+
if (spec.kind === "number" && raw !== "") {
|
|
165
|
+
const n = Number.parseInt(raw, 10);
|
|
166
|
+
if (!Number.isFinite(n)) continue; // garbage → leave the stored value alone
|
|
167
|
+
patch[spec.key] = n;
|
|
168
|
+
} else {
|
|
169
|
+
patch[spec.key] = raw;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return patch;
|
|
173
|
+
}
|
|
174
|
+
|
|
149
175
|
/** web's ModuleConfig for the central /config panel. cwd/trust come from the
|
|
150
176
|
* save ctx (factories receive none); reads use process.cwd(), matching
|
|
151
177
|
* munin's panel pattern. */
|
|
@@ -165,24 +191,23 @@ export function webConfig(): ModuleConfig {
|
|
|
165
191
|
// Diff against the pre-edit effective values: only changed keys are
|
|
166
192
|
// written (masked rows start empty — an untouched masked row diffs to
|
|
167
193
|
// no change).
|
|
168
|
-
const patch
|
|
169
|
-
for (const spec of webRowSpecs()) {
|
|
170
|
-
if (working[spec.key] !== before[spec.key]) {
|
|
171
|
-
// number rows persist as numbers (timeoutMs semantics), strings as
|
|
172
|
-
// strings; empty string clears the key (writeWebSection semantics).
|
|
173
|
-
patch[spec.key] = spec.kind === "number" && working[spec.key] !== ""
|
|
174
|
-
? (Number.parseInt(working[spec.key], 10) || 0)
|
|
175
|
-
: working[spec.key];
|
|
176
|
-
}
|
|
177
|
-
}
|
|
194
|
+
const patch = diffWebPatch(working, before);
|
|
178
195
|
writeWebSection(patch, target);
|
|
179
196
|
const notes = [`Web config saved to ${target} — effective immediately (read per tool call).`];
|
|
180
197
|
// Disclose env vars that still override saved values, and a trusted
|
|
181
198
|
// project file that shadows a field.
|
|
182
199
|
const envOverrides = webRowSpecs().filter((s) => patch[s.key] !== undefined && process.env[s.envVar]).map((s) => s.envVar);
|
|
183
200
|
if (envOverrides.length) notes.push(`Still overridden by env: ${envOverrides.join(", ")}.`);
|
|
184
|
-
|
|
185
|
-
|
|
201
|
+
// Resolve through the SAME lookup the runtime uses, so a hand-written
|
|
202
|
+
// NESTED project entry (web.brave.apiKey as {brave:{apiKey}}) is
|
|
203
|
+
// disclosed instead of shadowing the save silently. The PROJECT layer
|
|
204
|
+
// alone — a merged read reports the just-written global key as a shadow.
|
|
205
|
+
const shadowed = ctx.isProjectTrusted?.() === true
|
|
206
|
+
? Object.keys(patch).filter((k) => {
|
|
207
|
+
const v = sectionValue(readProjectWebSection(ctx.cwd), k);
|
|
208
|
+
return v !== undefined && v !== null && v !== "";
|
|
209
|
+
})
|
|
210
|
+
: [];
|
|
186
211
|
if (shadowed.length) notes.push(`A trusted project .pi/settings.json web section shadows: ${shadowed.join(", ")}.`);
|
|
187
212
|
ctx.ui.notify(notes.join(" "), "info");
|
|
188
213
|
},
|
|
@@ -54,10 +54,19 @@ export function readWebSettings(cwd = process.cwd(), trusted = isProjectTrusted(
|
|
|
54
54
|
return { ...global, ...readSection(path.join(path.resolve(cwd), ".pi", "settings.json")) };
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/** The project `.pi/settings.json` `web` section ALONE (no global merge) — the
|
|
58
|
+
* only layer that can shadow a GLOBAL /config save. Used for shadow disclosure
|
|
59
|
+
* (a merged read would report the just-written global key as a shadow). */
|
|
60
|
+
export function readProjectWebSection(cwd: string): WebSettings {
|
|
61
|
+
return readSection(path.join(path.resolve(cwd), ".pi", "settings.json"));
|
|
62
|
+
}
|
|
63
|
+
|
|
57
64
|
/** Read one value from a `web` section by settings key. Accepts BOTH the
|
|
58
65
|
* flat panel form (`"brave.apiKey"`) and a nested form (`brave.apiKey` as
|
|
59
|
-
* { brave: { apiKey } } path) so hand-written settings of either shape work.
|
|
60
|
-
|
|
66
|
+
* { brave: { apiKey } } path) so hand-written settings of either shape work.
|
|
67
|
+
* Exported so the /config panel resolves shadow disclosure the same way the
|
|
68
|
+
* runtime does. */
|
|
69
|
+
export function sectionValue(section: WebSettings, key: string): unknown {
|
|
61
70
|
if (key in section) return section[key];
|
|
62
71
|
const parts = key.split(".");
|
|
63
72
|
let cur: unknown = section;
|
|
@@ -7,7 +7,7 @@ import fs from "node:fs";
|
|
|
7
7
|
import os from "node:os";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
|
|
10
|
-
import { buildWebGroups, readWebRowValues, webConfig } from "../configPanel";
|
|
10
|
+
import { buildWebGroups, diffWebPatch, readWebRowValues, webConfig } from "../configPanel";
|
|
11
11
|
import { writeWebSection } from "../lib/settings";
|
|
12
12
|
|
|
13
13
|
function tmpAgentDir(): string {
|
|
@@ -129,4 +129,70 @@ describe("web configPanel", () => {
|
|
|
129
129
|
delete process.env.PI_CODING_AGENT_DIR;
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
|
+
|
|
133
|
+
it("diffWebPatch: free-text garbage on a number row leaves the key untouched", () => {
|
|
134
|
+
// Live-found regression: parseInt('abc') || 0 wrote a 0 cap to disk, which
|
|
135
|
+
// the consumer then clamped — silently clobbering the user's real value.
|
|
136
|
+
const before = { "image.dailyCap": "20", "crawl4ai.timeoutMs": "60000", "brave.apiKey": "old" };
|
|
137
|
+
assert.deepEqual(diffWebPatch({ ...before, "image.dailyCap": "abc" }, before), {}, "garbage number row skipped, never 0");
|
|
138
|
+
// A real number still persists as a number; empty string still clears.
|
|
139
|
+
assert.deepEqual(diffWebPatch({ ...before, "crawl4ai.timeoutMs": "45000" }, before), { "crawl4ai.timeoutMs": 45000 });
|
|
140
|
+
assert.deepEqual(diffWebPatch({ ...before, "image.dailyCap": "" }, before), { "image.dailyCap": "" });
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("save keeps the stored cap when the panel edit is garbage ('abc' → no write)", async () => {
|
|
144
|
+
const dir = tmpAgentDir();
|
|
145
|
+
try {
|
|
146
|
+
writeWebSection({ "image.dailyCap": 20 }, path.join(dir, "settings.json"));
|
|
147
|
+
const cfg = webConfig();
|
|
148
|
+
cfg.groups()[0]!.rows.find((r) => r.key === "web.image.dailyCap")!.set("abc");
|
|
149
|
+
const ctx = { cwd: "/nonexistent", ui: { notify: () => {} }, isProjectTrusted: () => false } as never;
|
|
150
|
+
await cfg.save(new Set(["web.image.dailyCap"]), ctx);
|
|
151
|
+
const raw = JSON.parse(fs.readFileSync(path.join(dir, "settings.json"), "utf8"));
|
|
152
|
+
assert.equal(raw.web["image.dailyCap"], 20, "stored cap survives a garbage edit");
|
|
153
|
+
} finally {
|
|
154
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
155
|
+
delete process.env.PI_CODING_AGENT_DIR;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("discloses a NESTED project web entry that shadows the save", async () => {
|
|
160
|
+
const dir = tmpAgentDir();
|
|
161
|
+
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), "web-nested-"));
|
|
162
|
+
try {
|
|
163
|
+
// Hand-written nested shape: the flat panel key is NOT a top-level key.
|
|
164
|
+
fs.mkdirSync(path.join(cwd, ".pi"), { recursive: true });
|
|
165
|
+
fs.writeFileSync(path.join(cwd, ".pi", "settings.json"), JSON.stringify({ web: { brave: { apiKey: "nested-project-key" } } }));
|
|
166
|
+
const cfg = webConfig();
|
|
167
|
+
cfg.groups()[0]!.rows.find((r) => r.key === "web.brave.apiKey")!.set("panel-key");
|
|
168
|
+
const notifications: string[] = [];
|
|
169
|
+
const ctx = { cwd, ui: { notify: (m: string) => notifications.push(m) }, isProjectTrusted: () => true } as never;
|
|
170
|
+
await cfg.save(new Set(["web.brave.apiKey"]), ctx);
|
|
171
|
+
const note = notifications.join(" ");
|
|
172
|
+
assert.match(note, /shadows: brave\.apiKey/, note);
|
|
173
|
+
} finally {
|
|
174
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
175
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
176
|
+
delete process.env.PI_CODING_AGENT_DIR;
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("trusted save with no project web section reports no phantom shadow", async () => {
|
|
181
|
+
const dir = tmpAgentDir();
|
|
182
|
+
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), "web-noproj-"));
|
|
183
|
+
try {
|
|
184
|
+
const cfg = webConfig();
|
|
185
|
+
cfg.groups()[0]!.rows.find((r) => r.key === "web.brave.apiKey")!.set("panel-key");
|
|
186
|
+
const notifications: string[] = [];
|
|
187
|
+
const ctx = { cwd, ui: { notify: (m: string) => notifications.push(m) }, isProjectTrusted: () => true } as never;
|
|
188
|
+
await cfg.save(new Set(["web.brave.apiKey"]), ctx);
|
|
189
|
+
// Disclosure reads the PROJECT layer alone: a merged read would see the
|
|
190
|
+
// key just written to global and call it a shadow.
|
|
191
|
+
assert.doesNotMatch(notifications.join(" "), /shadows:/);
|
|
192
|
+
} finally {
|
|
193
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
194
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
195
|
+
delete process.env.PI_CODING_AGENT_DIR;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
132
198
|
});
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
12
|
-
import type
|
|
12
|
+
import { isProjectTrusted, type ModuleConfig } from "../../lib/registry.js";
|
|
13
13
|
import { row, type PanelGroup } from "../../lib/panel.js";
|
|
14
14
|
import { DEFAULT_BASE_URL, KNOWN_BASE_URLS } from "./lib/anthropic.js";
|
|
15
15
|
import { DEFAULT_MIN_INTERVAL_MS } from "./lib/throttle.js";
|
|
@@ -139,7 +139,10 @@ function changed(before: ZaiSettings, working: ZaiSettings, key: string): boolea
|
|
|
139
139
|
|
|
140
140
|
/** zai's ModuleConfig for the central /config panel. */
|
|
141
141
|
export function zaiConfig(pi: ExtensionAPI): ModuleConfig {
|
|
142
|
-
|
|
142
|
+
// Baseline = what the next request resolves: the factory gets no ctx, so the
|
|
143
|
+
// shared trust helper decides (same rule save-time ctx.isProjectTrusted
|
|
144
|
+
// applies) — an untrusted checkout must not show phantom project values.
|
|
145
|
+
const before = readZaiSettings(process.cwd(), isProjectTrusted(process.cwd()));
|
|
143
146
|
const working = structuredClone(before);
|
|
144
147
|
return {
|
|
145
148
|
groups: () => buildZaiGroups(working),
|
|
@@ -444,10 +444,13 @@ export class ClientSigningManager {
|
|
|
444
444
|
this.lastSignedKey = "";
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
-
/** Called on any non-401 response: a success between 401s keeps them from counting as consecutive.
|
|
447
|
+
/** Called on any non-401 response: a success between 401s keeps them from counting as consecutive.
|
|
448
|
+
* Also drops the pending signed-key marker — a later UNSIGNED request's 401 must not be
|
|
449
|
+
* attributed to the (successful) signed request before it. */
|
|
448
450
|
noteResponseOk(): void {
|
|
449
451
|
const state = this.states.get(this.lastSignedKey);
|
|
450
452
|
if (state) state.consecutive401s = 0;
|
|
453
|
+
this.lastSignedKey = "";
|
|
451
454
|
}
|
|
452
455
|
|
|
453
456
|
private async buildSignedHeaders(
|
|
@@ -204,4 +204,27 @@ describe("zaiConfig save", () => {
|
|
|
204
204
|
assert.equal(notifications[0]!.level, "info");
|
|
205
205
|
assert.match(notifications[0]!.message, /NOT trusted/);
|
|
206
206
|
});
|
|
207
|
+
|
|
208
|
+
it("baseline honors the trust helper (no phantom project values untrusted)", () => {
|
|
209
|
+
const agentDir = tempDir("zai-trust-agent-");
|
|
210
|
+
process.env.PI_CODING_AGENT_DIR = agentDir;
|
|
211
|
+
const cwd = tempDir("zai-trust-cwd-");
|
|
212
|
+
mkdirSync(join(cwd, ".pi"), { recursive: true });
|
|
213
|
+
writeFileSync(join(cwd, ".pi", "settings.json"), JSON.stringify({ zai: { baseUrl: "https://open.bigmodel.cn/api/anthropic" } }));
|
|
214
|
+
const trustFile = join(agentDir, "trust.json");
|
|
215
|
+
const prevCwd = process.cwd();
|
|
216
|
+
process.chdir(cwd);
|
|
217
|
+
try {
|
|
218
|
+
writeFileSync(trustFile, JSON.stringify({ [process.cwd()]: true }));
|
|
219
|
+
assert.equal(
|
|
220
|
+
zaiConfig(fakePi().pi).groups()[0]!.rows[0]!.value,
|
|
221
|
+
"https://open.bigmodel.cn/api/anthropic",
|
|
222
|
+
"trusted → project value shown",
|
|
223
|
+
);
|
|
224
|
+
writeFileSync(trustFile, JSON.stringify({ [process.cwd()]: false }));
|
|
225
|
+
assert.equal(zaiConfig(fakePi().pi).groups()[0]!.rows[0]!.value, DEFAULT_BASE_URL, "untrusted → project value ignored");
|
|
226
|
+
} finally {
|
|
227
|
+
process.chdir(prevCwd);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
207
230
|
});
|
|
@@ -302,6 +302,25 @@ describe("zcode-signing", () => {
|
|
|
302
302
|
await signedHeaders(manager, URL_ULTRA); // must still sign
|
|
303
303
|
});
|
|
304
304
|
|
|
305
|
+
it("401 ladder: a success clears the signed-request marker (later unsigned 401 is not attributed)", async () => {
|
|
306
|
+
const { fetchImpl, calls } = makeFetch({ gateEnabled: true });
|
|
307
|
+
const manager = new ClientSigningManager({ identity: IDENTITY, fetchImpl });
|
|
308
|
+
await signedHeaders(manager); // signed #1
|
|
309
|
+
manager.noteResponseOk(); // 200 — marker cleared
|
|
310
|
+
manager.noteResponse401(); // 401 on an UNSIGNED request: must be a no-op
|
|
311
|
+
// State untouched: the next sign reuses the handshake key (no re-handshake)
|
|
312
|
+
// and no bypass kicked in.
|
|
313
|
+
assert.equal(calls.handshakeCount, 1);
|
|
314
|
+
const headers = await signedHeaders(manager, URL_ULTRA);
|
|
315
|
+
assert.equal(calls.handshakeCount, 1, "no invalidation from the stale marker");
|
|
316
|
+
assert.ok(headers["X-Client-Sig"], "a stale marker must not invalidate the handshake key");
|
|
317
|
+
// And it did not count toward the ladder: two real signed 401s are still required.
|
|
318
|
+
manager.noteResponse401();
|
|
319
|
+
await signedHeaders(manager, URL_ULTRA); // re-handshake, count 1 → still signs
|
|
320
|
+
manager.noteResponse401(); // count 2 → bypass
|
|
321
|
+
assert.equal(await manager.sign(URL_ULTRA, baseHeaders(), CRED), false, "bypass needs two SIGNED 401s");
|
|
322
|
+
});
|
|
323
|
+
|
|
305
324
|
it("origin allowlist: non-z.ai base URL → unsigned, zero network (no credential egress)", async () => {
|
|
306
325
|
const { fetchImpl, calls } = makeFetch({ gateEnabled: true });
|
|
307
326
|
const manager = new ClientSigningManager({ identity: IDENTITY, fetchImpl });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ceulen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Ceulen — the Pi coding agent, fully dressed: one bundle extension carrying the full toolkit with a single /ceulen config command.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"homepage": "https://github.com/ceulen-dev/ceulen#readme",
|
|
41
41
|
"bugs": "https://github.com/ceulen-dev/ceulen/issues",
|
|
42
42
|
"scripts": {
|
|
43
|
-
"test": "node scripts/validate-themes.mjs && node --import tsx --test extensions/modules/router/test/unit.test.ts extensions/modules/router/test/guard.test.ts extensions/modules/classifier/test/*.test.ts extensions/modules/advisor/test/*.test.ts extensions/modules/usage/test/*.test.ts extensions/modules/ponytail/test/*.test.ts extensions/modules/ux/test/*.test.ts extensions/modules/config/test/*.test.ts extensions/modules/composer/test/*.test.ts extensions/modules/serena/test/*.test.ts extensions/modules/fff/test/*.test.ts extensions/modules/rtk/test/*.test.js extensions/modules/munin/test/*.test.ts extensions/modules/subagent/test/*.test.ts extensions/modules/zai/test/*.test.ts extensions/modules/repair/test/*.test.ts extensions/modules/steering/test/*.test.ts extensions/modules/plan/test/*.test.ts extensions/modules/web/test/*.test.ts",
|
|
43
|
+
"test": "node scripts/validate-themes.mjs && node --import tsx --test extensions/lib/registry.test.ts extensions/modules/router/test/unit.test.ts extensions/modules/router/test/guard.test.ts extensions/modules/classifier/test/*.test.ts extensions/modules/advisor/test/*.test.ts extensions/modules/usage/test/*.test.ts extensions/modules/ponytail/test/*.test.ts extensions/modules/ux/test/*.test.ts extensions/modules/config/test/*.test.ts extensions/modules/composer/test/*.test.ts extensions/modules/serena/test/*.test.ts extensions/modules/fff/test/*.test.ts extensions/modules/rtk/test/*.test.js extensions/modules/munin/test/*.test.ts extensions/modules/subagent/test/*.test.ts extensions/modules/zai/test/*.test.ts extensions/modules/repair/test/*.test.ts extensions/modules/steering/test/*.test.ts extensions/modules/plan/test/*.test.ts extensions/modules/todo/test/*.test.ts extensions/modules/web/test/*.test.ts extensions/modules/rules/test/*.test.ts extensions/modules/a2a/test/*.test.ts",
|
|
44
44
|
"typecheck": "tsc --noEmit"
|
|
45
45
|
},
|
|
46
46
|
"pi": {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: a2a
|
|
3
|
+
description: A2A (Agent2Agent) Protocol v1.0 bidirectional communication. Distribute tasks to remote agents (Hermes, ADK, LangChain, CrewAI, any A2A peer) and be called by them. Use when delegating work across agents/machines/frameworks, doing parallel multi-agent fan-out, or when another agent needs to call Pi. Trigger on "a2a", "agent-to-agent", "delegate to another agent", "ask agent X", "call remote agent", "multi-agent", "Hermes", "task distribution".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# A2A — Agent-to-Agent Protocol v1.0
|
|
7
|
+
|
|
8
|
+
Pi as a first-class A2A peer. [A2A](https://a2a-protocol.org) is the open
|
|
9
|
+
Linux Foundation standard for inter-agent communication (JSON-RPC 2.0 over
|
|
10
|
+
HTTP). This extension makes Pi bidirectional: it can **call other agents** and
|
|
11
|
+
**be called by them**.
|
|
12
|
+
|
|
13
|
+
## When to use
|
|
14
|
+
|
|
15
|
+
- **Delegating to a specialist** — a peer advertising `web_search`/`research`/
|
|
16
|
+
`coding` skills can be discovered and called mid-conversation.
|
|
17
|
+
- **Cross-machine collaboration** — hand a task to a Hermes on a server, each
|
|
18
|
+
with its own memory/tools/credentials.
|
|
19
|
+
- **Parallel fan-out** — send one task to every capable peer at once.
|
|
20
|
+
- **Being callable** — expose Pi so other frameworks' agents can send it tasks.
|
|
21
|
+
|
|
22
|
+
For same-machine, in-process delegation (cheaper, shared context) prefer the
|
|
23
|
+
`subagent` tool. A2A is for crossing process/machine/framework boundaries.
|
|
24
|
+
|
|
25
|
+
## Outbound — calling other agents (5 tools)
|
|
26
|
+
|
|
27
|
+
| Tool | Use |
|
|
28
|
+
|------|-----|
|
|
29
|
+
| `a2a_discover(url)` | Fetch a peer's Agent Card to learn its capabilities |
|
|
30
|
+
| `a2a_call(agent, message, context_id?)` | Send a task, get the reply; reuse `context_id` for multi-turn |
|
|
31
|
+
| `a2a_list()` | Configured peers, persisted conversations, metrics |
|
|
32
|
+
| `a2a_history(context_id)` | Recall a persisted conversation |
|
|
33
|
+
| `a2a_orchestrate(capability, message, mode?)` | Fan-out to all peers advertising a capability (`all`/`first`/`best`) |
|
|
34
|
+
|
|
35
|
+
`agent` is a configured peer name (from `a2a.peers` in settings.json) OR a full
|
|
36
|
+
`http(s)://` URL.
|
|
37
|
+
|
|
38
|
+
## Inbound — being callable (opt-in)
|
|
39
|
+
|
|
40
|
+
`/a2a-server start` serves an Agent Card + JSON-RPC endpoint. Each inbound task
|
|
41
|
+
spawns an isolated Pi agent session in the workspace and returns the reply as a
|
|
42
|
+
task artifact. **Localhost-only by default**; remote needs a token + explicit host.
|
|
43
|
+
|
|
44
|
+
## Commands
|
|
45
|
+
|
|
46
|
+
`/a2a-discover <url>` · `/a2a-agents` · `/a2a-send <agent> <msg>` ·
|
|
47
|
+
`/a2a-broadcast <msg> --agents a,b,c` · `/a2a-status` (also prints the config
|
|
48
|
+
summary) · `/a2a-server start|stop|status` · `/a2a-help`
|
|
49
|
+
|
|
50
|
+
## Security (on by default)
|
|
51
|
+
|
|
52
|
+
- No token ⇒ localhost-only bind; remote requires token + explicit host.
|
|
53
|
+
- Outbound text is scrubbed of credentials; inbound text is injection-filtered
|
|
54
|
+
and framed as untrusted peer input.
|
|
55
|
+
- Per-context anti-loop cap; append-only audit log at `<piDir>/a2a_audit.jsonl`.
|
|
56
|
+
|
|
57
|
+
## Configuration
|
|
58
|
+
|
|
59
|
+
Settings live in `/config` → Tasks → A2A (server, discovery, identity, peers
|
|
60
|
+
& gateways with add/remove action rows) — saved to the `a2a` key in
|
|
61
|
+
`~/.pi/agent/settings.json` and applied live. Env: `A2A_*` vars (security-
|
|
62
|
+
relevant keys are read from global settings/env only — never from repo-
|
|
63
|
+
controlled files). See the package README for the full schema.
|