Files
gori-agent/test/role-registry.test.ts
T
zenord 9ae2639660 feat: run confirmed proposals continuously until a real decision point
A proposal still needs one confirmation before it starts, but once it is
working the worker now treats that as a single grant to carry out
routine low-risk execution without step-by-step reconfirmation. It only
returns pending early for high-risk actions, key business decisions,
external blockers, or dirty/unexpected targets. Assistant/worker
bootstrap copy and docs now align with that execution model.
2026-08-22 00:05:40 +08:00

53 lines
2.6 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { parseConfig } from "../src/config.js";
import { BotProfileResolver } from "../src/roles/role-registry.js";
function resolvedBot(botOverrides: Record<string, unknown> = {}) {
const config = parseConfig({
configVersion: 3,
bot: {
id: "test-bot", workspace: "/tmp", persona: "Worker 人格:严格的安全/运维边界。",
agent: { id: "kimi", command: "kimi", args: ["acp"], env: {} },
skills: [], permissions: { mode: "deny" },
...botOverrides
},
gateway: { platform: { type: "webhook", secret: "secret" } },
runtime: {}
});
return new BotProfileResolver(config).bot;
}
test("assistant uses assistantPersona while worker keeps persona", () => {
const bot = resolvedBot({ assistantPersona: "Assistant 人格:像运维老同事一样说人话。" });
assert.match(bot.assistantBootstrap, /Assistant 人格:像运维老同事一样说人话。/);
assert.doesNotMatch(bot.assistantBootstrap, /Worker 人格:严格的安全\/运维边界。/);
assert.match(bot.workerBootstrap, /Worker 人格:严格的安全\/运维边界。/);
assert.doesNotMatch(bot.workerBootstrap, /Assistant 人格/);
});
test("assistant falls back to persona when assistantPersona is empty", () => {
const bot = resolvedBot();
assert.match(bot.assistantBootstrap, /Worker 人格:严格的安全\/运维边界。/);
assert.match(bot.workerBootstrap, /Worker 人格:严格的安全\/运维边界。/);
});
test("assistant bootstrap carries human speaking-style rules, worker bootstrap does not", () => {
const bot = resolvedBot({ assistantPersona: "Assistant 人格" });
assert.match(bot.assistantBootstrap, /reliable colleague/);
assert.match(bot.assistantBootstrap, /conclusion, then the reason, then the next step/);
assert.match(bot.assistantBootstrap, /2-4 sentences/);
assert.match(bot.assistantBootstrap, /actionable next step/);
assert.match(bot.assistantBootstrap, /proposal only starts after the user confirms/i);
assert.match(bot.assistantBootstrap, /do not ask the user to re-confirm ordinary low-risk next steps/i);
assert.match(bot.workerBootstrap, /single permission grant to carry out routine low-risk execution/i);
assert.match(bot.workerBootstrap, /Do not stop for step-by-step confirmation during ordinary low-risk work/i);
assert.doesNotMatch(bot.workerBootstrap, /reliable colleague/);
});
test("assistantPersona participates in the bot fingerprint", () => {
const base = resolvedBot();
const withPersona = resolvedBot({ assistantPersona: "Assistant 人格" });
assert.notEqual(base.fingerprint, withPersona.fingerprint);
});