fix(discord): row 25 SetSpark key reaches pi and the connector (#1509)
resolveToolRoots dropped tools.setspark, so the record verbs never reached pi's --tools list and the connector never built its SetSpark client. The resolved config now carries only baseUrl, keyFile, principal and timeoutMs, the keys the extension's loadSetsparkConfig accepts; the extension restores the response cap. The connector's client uses the validated binding object, which keeps the cap. README: principal is required, timeoutMs is optional. Test (failing first): binding -> resolveToolRoots -> JSON -> loadToolsConfig gives the binding's config, and the verbs reach enabledToolNames. Eight suites green on an index export. Rocko approved (agents/rocko/work/row25-setspark-fix-review-2026-09-26.md, a28df89e). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -12,7 +12,7 @@ import {
|
||||
loadSetsparkConfig, readKey, idempotencyKey, connectorKey, callApi, renderRefusal, createSetsparkApi, renderRecord,
|
||||
} from "../src/setspark.mjs";
|
||||
import { loadToolsConfig, createToolSet, enabledToolNames } from "../src/tools.mjs";
|
||||
import { validateBinding } from "../src/binding.mjs";
|
||||
import { validateBinding, resolveToolRoots } from "../src/binding.mjs";
|
||||
import { makeRoot, rawBinding } from "./helpers.mjs";
|
||||
|
||||
const KEY_A = "ssk_" + "a".repeat(40);
|
||||
@@ -120,6 +120,24 @@ test("setspark config: reaches the tools config and the binding as a fixed key",
|
||||
assert.throws(() => validateBinding(rawBinding({ tools: { roots: [{ name: "docs", path: docs }], setspark: { baseUrl: "https://api.setspark.io", keyFile: kf, principal: "sage", nope: 1 } } })), /unknown key/);
|
||||
});
|
||||
|
||||
test("setspark config: the binding's key survives resolveToolRoots and the engine's JSON hand-off to the extension", () => {
|
||||
const root = makeRoot();
|
||||
const docs = join(root, "docs");
|
||||
mkdirSync(docs);
|
||||
const dataRoot = join(root, "data");
|
||||
mkdirSync(dataRoot);
|
||||
const kf = keyFile(root);
|
||||
const b = validateBinding(rawBinding({ tools: { roots: [{ name: "docs", path: docs }], setspark: { baseUrl: "https://api.setspark.io", keyFile: kf, principal: "sage", timeoutMs: 5000 } } }));
|
||||
const resolved = resolveToolRoots(b, { dataRoot });
|
||||
assert.deepEqual(resolved.setspark, { baseUrl: "https://api.setspark.io", keyFile: kf, principal: "sage", timeoutMs: 5000 });
|
||||
for (const name of SETSPARK_TOOL_NAMES) assert.ok(enabledToolNames(resolved).includes(name), `${name} reaches pi's --tools list`);
|
||||
const ext = loadToolsConfig(JSON.parse(JSON.stringify(resolved)));
|
||||
assert.deepEqual(ext.setspark, b.tools.setspark, "the extension rebuilds the same config, response cap included");
|
||||
const plain = resolveToolRoots(validateBinding(rawBinding({ tools: { roots: [{ name: "docs", path: docs }] } })), { dataRoot });
|
||||
assert.equal("setspark" in plain, false);
|
||||
assert.ok(!enabledToolNames(plain).some((n) => SETSPARK_TOOL_NAMES.includes(n)));
|
||||
});
|
||||
|
||||
test("setspark keys: read per call, one printable token per file, rotation without a restart", async () => {
|
||||
const root = makeRoot();
|
||||
const c = config(root);
|
||||
|
||||
Reference in New Issue
Block a user