mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-17 20:52:15 +03:00
* feat(a2a): conductor bridge core — event mapping with canceled->cancelled
* feat(a2a): incremental SSE parser for conductor bridge
* feat(a2a): conductor bridge connection loop with persisted cursor and backoff
* feat(a2a): start conductor bridge at boot behind CONDUCTOR_HUB_URL
* fix(a2a): conductor bridge parses the hub's real SSE wire format (id/type in frame, data={ts,payload})
* docs(reference): document CONDUCTOR_HUB_URL/TOKEN in ENVIRONMENT.md (env-doc-sync gate)
* feat(a2a): fleet skills derived from the Conductor hub for the agent card
* feat(a2a): agent card announces Conductor fleet skills
* feat(dashboard): server-side hub proxy for the Conductor panel (whitelisted shapes, fail-open)
* feat(dashboard): /api/conductor proxy routes (fleet, task detail, cancel) behind management auth
* feat(dashboard): Conductor panel — fleet live view, task detail and cancel over /api/conductor proxy
* feat(dashboard): /api/conductor/ask — server-side proxy to Faro (spokesperson) with whitelisted {text,pending}
* chore(env): CONDUCTOR_SPOKESPERSON_URL declared in schema, .env.example and ENVIRONMENT.md
* feat(dashboard): Faro chat with push-to-talk voice on the Conductor panel
---------
Co-authored-by: backryun <bakryun0718@proton.me>
62 lines
2.5 KiB
TypeScript
62 lines
2.5 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { askFaro } from "../../src/lib/conductor/faroProxy.ts";
|
|
|
|
function fakeFaro(body: unknown, status = 200) {
|
|
const calls: { url: string; auth: string | null; body: unknown }[] = [];
|
|
const impl = (async (url: string | URL | Request, init?: RequestInit) => {
|
|
calls.push({
|
|
url: String(url),
|
|
auth: (init?.headers as Record<string, string> | undefined)?.authorization ?? null,
|
|
body: JSON.parse(String(init?.body ?? "{}")),
|
|
});
|
|
return new Response(JSON.stringify(body), { status });
|
|
}) as typeof fetch;
|
|
return { impl, calls };
|
|
}
|
|
|
|
test.beforeEach(() => {
|
|
process.env.CONDUCTOR_SPOKESPERSON_URL = "http://faro.test:7920";
|
|
process.env.CONDUCTOR_HUB_TOKEN = "tok-hub";
|
|
});
|
|
|
|
test.after(() => {
|
|
delete process.env.CONDUCTOR_SPOKESPERSON_URL;
|
|
delete process.env.CONDUCTOR_HUB_TOKEN;
|
|
});
|
|
|
|
test("repassa a mensagem ao /ask com o token server-side e devolve text+pending", async () => {
|
|
const { impl, calls } = fakeFaro({ text: "frota ok", pending: { kind: "cancel_task" }, extra: "NÃO passa" });
|
|
const r = await askFaro("como está a frota?", { fetchImpl: impl });
|
|
assert.deepEqual(r, { ok: true, text: "frota ok", pending: { kind: "cancel_task" } });
|
|
assert.equal(calls[0].url, "http://faro.test:7920/ask");
|
|
assert.equal(calls[0].auth, "Bearer tok-hub");
|
|
assert.deepEqual(calls[0].body, { message: "como está a frota?" });
|
|
});
|
|
|
|
test("pending null passa como null (sem confirmação pendente)", async () => {
|
|
const { impl } = fakeFaro({ text: "oi", pending: null });
|
|
const r = await askFaro("oi", { fetchImpl: impl });
|
|
assert.deepEqual(r, { ok: true, text: "oi", pending: null });
|
|
});
|
|
|
|
test("Faro fora do ar / erro HTTP → degradado {ok:false} sem lançar nem vazar corpo", async () => {
|
|
const failing = (async () => {
|
|
throw new Error("ECONNREFUSED");
|
|
}) as unknown as typeof fetch;
|
|
const down = await askFaro("oi", { fetchImpl: failing });
|
|
assert.equal(down.ok, false);
|
|
const { impl } = fakeFaro({ error: "segredo interno" }, 401);
|
|
const denied = await askFaro("oi", { fetchImpl: impl });
|
|
assert.equal(denied.ok, false);
|
|
assert.ok(!JSON.stringify(denied).includes("segredo interno"));
|
|
});
|
|
|
|
test("URL default do Faro é loopback :7920 quando a env não está setada", async () => {
|
|
delete process.env.CONDUCTOR_SPOKESPERSON_URL;
|
|
const { impl, calls } = fakeFaro({ text: "x", pending: null });
|
|
await askFaro("oi", { fetchImpl: impl });
|
|
assert.equal(calls[0].url, "http://127.0.0.1:7920/ask");
|
|
});
|