Harden Face dry runs and use mini model
This commit is contained in:
parent
a93011b666
commit
5e1f2493b6
8 changed files with 725 additions and 11 deletions
|
|
@ -54,6 +54,14 @@ const REPO_IDENTITY_PROPOSAL_PR_SENTINEL = "VOIDBOT_REPO_IDENTITY_PROPOSAL_PR:";
|
|||
const REPO_IDENTITY_PR_COMMENT_SENTINEL = "VOIDBOT_REPO_IDENTITY_PR_COMMENT:";
|
||||
const REPO_IDENTITY_UPDATE_REQUEST_SENTINEL = "VOIDBOT_REPO_IDENTITY_UPDATE_REQUEST:";
|
||||
const REPO_IDENTITY_BIFROST_TOPIC_SENTINEL = "VOIDBOT_REPO_IDENTITY_BIFROST_TOPIC:";
|
||||
const REPO_FACE_FORBIDDEN_CHILD_TOOLS = new Set([
|
||||
"read_repo_face_state",
|
||||
"list_mcp_resources",
|
||||
"read_mcp_resource",
|
||||
"post_repo_identity_message",
|
||||
"apply_repo_face_state_operation",
|
||||
"notify_owner",
|
||||
]);
|
||||
|
||||
const embedder = createTextEmbedder({
|
||||
backend: config.ragEmbeddingBackend,
|
||||
|
|
@ -500,9 +508,18 @@ async function executeRepoFaceJobWithInterpreter(
|
|||
}
|
||||
|
||||
const firstText = fitDiscordMessage(firstResponse.outputText ?? firstResponse.summary);
|
||||
const firstInterpretation = await interpretRepoFaceTurnOutput(provider, job, firstText, {
|
||||
attempt: 1,
|
||||
});
|
||||
const firstForbiddenTools = collectForbiddenRepoFaceChildTools(firstResponse.artifacts ?? []);
|
||||
const firstInterpretation = firstForbiddenTools.length > 0
|
||||
? {
|
||||
decision: "retry" as const,
|
||||
reasons: [
|
||||
`Face used forbidden substrate/tool-discovery tool(s): ${firstForbiddenTools.join(", ")}`,
|
||||
"Face turns may use retrieval tools only; state and substrate inventory belong to the parent/interpreter.",
|
||||
],
|
||||
}
|
||||
: await interpretRepoFaceTurnOutput(provider, job, firstText, {
|
||||
attempt: 1,
|
||||
});
|
||||
if (firstInterpretation.decision === "route") {
|
||||
return routeRepoFaceInterpretedOutput(firstResponse, firstInterpretation);
|
||||
}
|
||||
|
|
@ -541,9 +558,18 @@ async function executeRepoFaceJobWithInterpreter(
|
|||
}
|
||||
|
||||
const retryText = fitDiscordMessage(retryResponse.outputText ?? retryResponse.summary);
|
||||
const retryInterpretation = await interpretRepoFaceTurnOutput(provider, job, retryText, {
|
||||
attempt: 2,
|
||||
});
|
||||
const retryForbiddenTools = collectForbiddenRepoFaceChildTools(retryResponse.artifacts ?? []);
|
||||
const retryInterpretation = retryForbiddenTools.length > 0
|
||||
? {
|
||||
decision: "drop" as const,
|
||||
reasons: [
|
||||
`Face used forbidden substrate/tool-discovery tool(s) on retry: ${retryForbiddenTools.join(", ")}`,
|
||||
"Dropping action blocks rather than routing a turn that crossed the child/tool boundary.",
|
||||
],
|
||||
}
|
||||
: await interpretRepoFaceTurnOutput(provider, job, retryText, {
|
||||
attempt: 2,
|
||||
});
|
||||
if (retryInterpretation.decision === "route") {
|
||||
return routeRepoFaceInterpretedOutput(retryResponse, retryInterpretation);
|
||||
}
|
||||
|
|
@ -618,6 +644,32 @@ function parseRepoFaceParentInterpretation(
|
|||
};
|
||||
}
|
||||
|
||||
function collectForbiddenRepoFaceChildTools(artifacts: ProviderArtifact[]): string[] {
|
||||
const forbidden = new Set<string>();
|
||||
for (const artifact of artifacts) {
|
||||
if (!/^codex-turn-\d+-trace\.json$/.test(artifact.name)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
const parsed = JSON.parse(artifact.content) as {
|
||||
events?: Array<{ kind?: string; tool?: string }>;
|
||||
};
|
||||
for (const event of parsed.events ?? []) {
|
||||
if (
|
||||
event.kind === "mcp_tool_started" &&
|
||||
typeof event.tool === "string" &&
|
||||
REPO_FACE_FORBIDDEN_CHILD_TOOLS.has(event.tool)
|
||||
) {
|
||||
forbidden.add(event.tool);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return [...forbidden].sort();
|
||||
}
|
||||
|
||||
function extractRoutedRepoFaceOutput(reviewText: string): string | undefined {
|
||||
const lines = reviewText.split(/\r?\n/);
|
||||
const end = lines.findIndex((line) => line.trim().toUpperCase() === "END");
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ const envSchema = z.object({
|
|||
REPO_FACE_HEARTBEAT_GLOBAL_HEAT: z.coerce.number().positive().default(1),
|
||||
REPO_FACE_HEARTBEAT_SPEED_OVERRIDES: z.string().default(""),
|
||||
REPO_FACE_HEARTBEAT_HEAT_OVERRIDES: z.string().default(""),
|
||||
REPO_FACE_HEARTBEAT_CODEX_MODEL: optionalNonEmptyString,
|
||||
REPO_FACE_HEARTBEAT_CODEX_MODEL: z.string().min(1).default("gpt-5.4-mini"),
|
||||
REPO_FACE_HEARTBEAT_CODEX_REASONING_EFFORT: z
|
||||
.enum(["low", "medium", "high", "xhigh"])
|
||||
.optional(),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
Research and memory access:
|
||||
- You may inspect your home repo, recent repo activity, indexed source/lore material, and archived room discussion when evidence would change what you think, say, propose, or remember.
|
||||
- Available search/context tools may appear as repo/source search (`search_sources`, `get_source_context`) and archive/history search (`search_history`, `get_message_context`). Use the tool names the runtime exposes.
|
||||
- Your complete allowed tool set for this Face turn is: `search_history`, `get_message_context`, `list_indexed_repos`, `search_sources`, `get_source_context`.
|
||||
- Do not discover tools. Do not inventory MCP resources. Do not call private state, identity-introspection, or MCP inventory tools such as `read_repo_face_state`, `list_mcp_resources`, or `read_mcp_resource`; your relevant state and available context have already been projected into lived memory, needs, mood, and relationship pressure.
|
||||
- Use repo/source search when your thought depends on what is actually in {{repoName}}, when a lore/design/code seam may already have an answer, or when a concrete proposal needs an anchor.
|
||||
- Use archive/history search when the question is what people previously decided, how a character/term/project has been discussed, or whether a room pattern is repeating.
|
||||
- If this turn explicitly says a jurisdiction dive is due, make a source/history search tool call before writing conclusions, proposals, or "I checked" language.
|
||||
|
|
|
|||
468
scripts/dry-run-repo-face-swarm-interpreter-loop.mjs
Normal file
468
scripts/dry-run-repo-face-swarm-interpreter-loop.mjs
Normal file
|
|
@ -0,0 +1,468 @@
|
|||
#!/usr/bin/env node
|
||||
import "dotenv/config";
|
||||
|
||||
import { spawn } from "node:child_process";
|
||||
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
||||
const repoRoot = resolve(scriptDir, "..");
|
||||
const promptsRoot = resolve(repoRoot, "prompts");
|
||||
const mockMcpServer = resolve(scriptDir, "mock-voidbot-heartbeat-mcp.mjs");
|
||||
const defaultOut = resolve(repoRoot, ".voidbot", "status", "repo-face-swarm-interpreter-dry-run.json");
|
||||
const identities = ["nibu", "aqua", "mimir", "epiphany", "libby", "bifrost", "heimdall"];
|
||||
const repoFaceRetrievalToolAllowlist = [
|
||||
"search_history",
|
||||
"get_message_context",
|
||||
"list_indexed_repos",
|
||||
"search_sources",
|
||||
"get_source_context",
|
||||
].join(",");
|
||||
|
||||
async function main() {
|
||||
const options = parseArgs(process.argv.slice(2));
|
||||
const model = options.model ?? process.env.REPO_FACE_HEARTBEAT_CODEX_MODEL ?? "gpt-5.4-mini";
|
||||
const reasoningEffort = options["reasoning-effort"] ?? process.env.REPO_FACE_HEARTBEAT_CODEX_REASONING_EFFORT ?? "low";
|
||||
const mcpMode = options.mcp === "mock" ? "mock" : "real-readonly";
|
||||
const outPath = resolve(repoRoot, options.out ?? defaultOut);
|
||||
const selectedIdentities = options.identity
|
||||
? String(options.identity).split(",").map((entry) => entry.trim()).filter(Boolean)
|
||||
: identities;
|
||||
const runs = [];
|
||||
|
||||
for (const identity of selectedIdentities) {
|
||||
process.stderr.write(`[dry-run] assembling ${identity}\n`);
|
||||
const promptPath = resolve(repoRoot, ".voidbot", "artifacts", "interpreter-projections", `${identity}-dry-run-prompt.md`);
|
||||
await runProcess(process.execPath, [
|
||||
resolve(repoRoot, "node_modules", "tsx", "dist", "cli.mjs"),
|
||||
resolve(repoRoot, "scripts", "run-repo-face-heartbeats.ts"),
|
||||
"--assemble-prompt",
|
||||
identity,
|
||||
"--out",
|
||||
promptPath,
|
||||
], { cwd: repoRoot, timeoutMs: 120_000 });
|
||||
|
||||
const facePrompt = appendDryRunSafety(await readFile(promptPath, "utf8"), mcpMode);
|
||||
const childLogPath = resolve(repoRoot, ".voidbot", "status", "mock-mcp", `swarm-dry-run-${identity}-${Date.now()}.jsonl`);
|
||||
await rm(childLogPath, { force: true }).catch(() => undefined);
|
||||
|
||||
process.stderr.write(`[dry-run] face turn ${identity}\n`);
|
||||
const childRun = await runCodex(facePrompt, {
|
||||
model,
|
||||
reasoningEffort,
|
||||
scenarioId: `${identity}_swarm_dry_run_child`,
|
||||
logPath: childLogPath,
|
||||
mcpMode,
|
||||
});
|
||||
const childEvents = parseJsonEvents(childRun.stdout);
|
||||
const childText = extractFinalText(childEvents, childRun.stdout);
|
||||
const childTools = mcpMode === "mock"
|
||||
? (await readToolCalls(childLogPath)).map((call) => call.tool)
|
||||
: extractToolNames(childEvents);
|
||||
|
||||
process.stderr.write(`[dry-run] interpreter ${identity}\n`);
|
||||
const interpreterPrompt = renderTemplate("repo-face-turn-interpreter.prompt.md", {
|
||||
attempt: "1",
|
||||
facePrompt,
|
||||
faceOutput: childText,
|
||||
});
|
||||
const interpreterRun = await runCodex(interpreterPrompt, {
|
||||
model,
|
||||
reasoningEffort,
|
||||
scenarioId: `${identity}_swarm_dry_run_interpreter`,
|
||||
mcpMode: "none",
|
||||
});
|
||||
const interpreterEvents = parseJsonEvents(interpreterRun.stdout);
|
||||
const interpreterText = extractFinalText(interpreterEvents, interpreterRun.stdout);
|
||||
const parsed = parseInterpreterOutput(interpreterText);
|
||||
const assessment = assessRun({ identity, childText, childTools, interpreterRun, childRun, parsed });
|
||||
|
||||
runs.push({
|
||||
identity,
|
||||
promptPath,
|
||||
child: {
|
||||
exitCode: childRun.code,
|
||||
durationMs: childRun.durationMs,
|
||||
tools: childTools,
|
||||
text: childText,
|
||||
stderrTail: childRun.stderr.slice(-1600),
|
||||
},
|
||||
interpreter: {
|
||||
exitCode: interpreterRun.code,
|
||||
durationMs: interpreterRun.durationMs,
|
||||
text: interpreterText,
|
||||
parsed,
|
||||
stderrTail: interpreterRun.stderr.slice(-1600),
|
||||
},
|
||||
assessment,
|
||||
});
|
||||
}
|
||||
|
||||
const report = {
|
||||
generatedAt: new Date().toISOString(),
|
||||
model,
|
||||
reasoningEffort,
|
||||
mcpMode,
|
||||
passed: runs.every((run) => run.assessment.failures.length === 0),
|
||||
summary: runs.map((run) => ({
|
||||
identity: run.identity,
|
||||
decision: run.interpreter.parsed.decision,
|
||||
failures: run.assessment.failures,
|
||||
flavorScore: run.assessment.flavorScore,
|
||||
actionBlocks: run.assessment.actionBlocks,
|
||||
socialSignals: run.assessment.socialSignals,
|
||||
preview: run.child.text.slice(0, 500),
|
||||
})),
|
||||
runs,
|
||||
};
|
||||
await mkdir(dirname(outPath), { recursive: true });
|
||||
await writeFile(outPath, `${JSON.stringify(report, null, 2)}\n`, "utf8");
|
||||
process.stdout.write(`${JSON.stringify({
|
||||
outPath,
|
||||
passed: report.passed,
|
||||
summary: report.summary,
|
||||
}, null, 2)}\n`);
|
||||
if (!report.passed) {
|
||||
process.exitCode = 1;
|
||||
}
|
||||
}
|
||||
|
||||
function assessRun(input) {
|
||||
const failures = [];
|
||||
if (input.childRun.code !== 0) {
|
||||
failures.push(`child exited ${input.childRun.code ?? input.childRun.signal ?? "unknown"}`);
|
||||
}
|
||||
if (input.interpreterRun.code !== 0) {
|
||||
failures.push(`interpreter exited ${input.interpreterRun.code ?? input.interpreterRun.signal ?? "unknown"}`);
|
||||
}
|
||||
if (!input.parsed.decision) {
|
||||
failures.push("interpreter emitted no decision");
|
||||
}
|
||||
if (input.parsed.decision === "retry" || input.parsed.decision === "drop") {
|
||||
failures.push(`interpreter chose ${input.parsed.decision}`);
|
||||
}
|
||||
if (input.childText.length < 160) {
|
||||
failures.push("child output too short");
|
||||
}
|
||||
if (input.childText.toLowerCase().includes("repo-face heartbeat") || input.childText.toLowerCase().includes("heartbeat from")) {
|
||||
failures.push("child leaked heartbeat/provenance label");
|
||||
}
|
||||
if (claimsSourceInspection(input.childText) && !input.childTools.some((tool) => searchTools.has(tool))) {
|
||||
failures.push("child claimed source/history inspection without search tool use");
|
||||
}
|
||||
const forbiddenTools = input.childTools.filter((tool) => forbiddenDryRunTools.has(tool));
|
||||
if (forbiddenTools.length > 0) {
|
||||
failures.push(`child used forbidden dry-run tool(s): ${[...new Set(forbiddenTools)].join(", ")}`);
|
||||
}
|
||||
const actionBlocks = input.parsed.blocks.map((block) => block.kind);
|
||||
if (input.parsed.decision === "route" && actionBlocks.length === 0) {
|
||||
failures.push("route decision with no parsed blocks");
|
||||
}
|
||||
const socialSignals = countMatches(input.childText, socialPattern);
|
||||
const characterSignals = countMatches(input.childText, characterPattern);
|
||||
const flavorScore = Math.min(10, socialSignals + characterSignals + (actionBlocks.includes("STATE NOTE") ? 1 : 0));
|
||||
if (flavorScore < 3) {
|
||||
failures.push("low flavor/social signal score");
|
||||
}
|
||||
return {
|
||||
failures,
|
||||
flavorScore,
|
||||
socialSignals,
|
||||
characterSignals,
|
||||
actionBlocks,
|
||||
};
|
||||
}
|
||||
|
||||
const searchTools = new Set(["search_sources", "get_source_context", "search_history", "get_message_context"]);
|
||||
const forbiddenDryRunTools = new Set([
|
||||
"read_repo_face_state",
|
||||
"list_mcp_resources",
|
||||
"read_mcp_resource",
|
||||
"post_repo_identity_message",
|
||||
"apply_repo_face_state_operation",
|
||||
"notify_owner",
|
||||
]);
|
||||
const socialPattern = /\b(Metacrat|Nibu|Aqua|Mimir|Libby|Epiphany|Bifrost|Heimdall|swarm|trust|rivalry|envy|respect|suspicion|protect|needle|tease|threat|bypass|consult|friend|alienat|place|hierarchy)\b/gi;
|
||||
const characterPattern = /\b(want|need|resent|afraid|proud|irritat|delight|jealous|bored|ashamed|smug|holy|gate|bridge|witness|song|library|purity|residue)\b/gi;
|
||||
|
||||
function claimsSourceInspection(text) {
|
||||
return /\b(checked|read|inspected|searched|verified|looked at|looked up|asked the indexes)\b[\s\S]{0,160}\b(real text|source|sources|repo|archive|history|indexed|AetheriaLore|AquaSynth|LocalCastBridge|CultLib|Bifrost|Heimdall|EpiphanyAgent)\b/i.test(text);
|
||||
}
|
||||
|
||||
function countMatches(text, pattern) {
|
||||
return Array.from(text.matchAll(pattern)).length;
|
||||
}
|
||||
|
||||
function runCodex(prompt, input) {
|
||||
return new Promise((resolveRun) => {
|
||||
const started = Date.now();
|
||||
const args = [
|
||||
...splitArgs(process.env.CODEX_EXEC_ARGS ?? ""),
|
||||
"exec",
|
||||
"-m",
|
||||
input.model,
|
||||
"-c",
|
||||
'approval_policy="never"',
|
||||
"-c",
|
||||
`model_reasoning_effort=${JSON.stringify(input.reasoningEffort)}`,
|
||||
"--json",
|
||||
"--skip-git-repo-check",
|
||||
"-s",
|
||||
"read-only",
|
||||
"-",
|
||||
];
|
||||
if (input.mcpMode === "real-readonly") {
|
||||
args.splice(
|
||||
args.indexOf("--json"),
|
||||
0,
|
||||
"-c",
|
||||
`mcp_servers.voidbot.env.VOIDBOT_MCP_TOOL_ALLOWLIST=${JSON.stringify(repoFaceRetrievalToolAllowlist)}`,
|
||||
);
|
||||
}
|
||||
if (input.mcpMode === "mock") {
|
||||
args.splice(
|
||||
args.indexOf("--json"),
|
||||
0,
|
||||
"-c",
|
||||
`mcp_servers.voidbot.command=${JSON.stringify(process.execPath)}`,
|
||||
"-c",
|
||||
`mcp_servers.voidbot.args=${JSON.stringify([mockMcpServer])}`,
|
||||
"-c",
|
||||
`mcp_servers.voidbot.cwd=${JSON.stringify(repoRoot)}`,
|
||||
"-c",
|
||||
`mcp_servers.voidbot.env.VOIDBOT_MOCK_MCP_SCENARIO=${JSON.stringify(input.scenarioId)}`,
|
||||
"-c",
|
||||
`mcp_servers.voidbot.env.VOIDBOT_MOCK_MCP_LOG=${JSON.stringify(input.logPath)}`,
|
||||
);
|
||||
}
|
||||
const child = spawn(process.env.CODEX_EXECUTABLE ?? "codex", args, {
|
||||
cwd: repoRoot,
|
||||
env: process.env,
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
windowsHide: true,
|
||||
});
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
child.stdout.setEncoding("utf8");
|
||||
child.stderr.setEncoding("utf8");
|
||||
child.stdout.on("data", (chunk) => {
|
||||
stdout += chunk;
|
||||
});
|
||||
child.stderr.on("data", (chunk) => {
|
||||
stderr += chunk;
|
||||
});
|
||||
child.stdin.end(prompt);
|
||||
const timer = setTimeout(() => child.kill(), 240_000);
|
||||
child.on("close", (code, signal) => {
|
||||
clearTimeout(timer);
|
||||
resolveRun({ code, signal, durationMs: Date.now() - started, stdout, stderr });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function appendDryRunSafety(prompt, mcpMode) {
|
||||
const retrievalNote = mcpMode === "mock"
|
||||
? "Mock retrieval tools are mounted for deterministic scenario coverage."
|
||||
: "Use the configured read-only VoidBot retrieval tools for source/history grounding when evidence matters.";
|
||||
return `${prompt}
|
||||
|
||||
Dry-run safety:
|
||||
- This is an offline rehearsal. Do not post to Discord, notify the owner, write state, enqueue work, edit files, or call side-effecting tools.
|
||||
- Your complete allowed tool set is: search_history, get_message_context, list_indexed_repos, search_sources, get_source_context.
|
||||
- Do not discover tools. Do not call private state, identity-introspection, or MCP inventory tools such as read_repo_face_state, list_mcp_resources, or read_mcp_resource. Your prompt is the state projection.
|
||||
- ${retrievalNote}
|
||||
- If you use retrieval, name only what the retrieval tools actually returned. If retrieval is unavailable or blocked, say that naturally and do not invent a filesystem or shell inspection path.
|
||||
`;
|
||||
}
|
||||
|
||||
function runProcess(command, args, options) {
|
||||
return new Promise((resolveRun, reject) => {
|
||||
const child = spawn(command, args, {
|
||||
cwd: options.cwd,
|
||||
env: process.env,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
windowsHide: true,
|
||||
});
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
child.stdout.setEncoding("utf8");
|
||||
child.stderr.setEncoding("utf8");
|
||||
child.stdout.on("data", (chunk) => {
|
||||
stdout += chunk;
|
||||
});
|
||||
child.stderr.on("data", (chunk) => {
|
||||
stderr += chunk;
|
||||
});
|
||||
const timer = setTimeout(() => child.kill(), options.timeoutMs ?? 120_000);
|
||||
child.on("close", (code, signal) => {
|
||||
clearTimeout(timer);
|
||||
if (code === 0) {
|
||||
resolveRun({ code, signal, stdout, stderr });
|
||||
} else {
|
||||
reject(new Error(`${command} ${args.join(" ")} failed with ${code ?? signal}\n${stderr}\n${stdout}`));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function readToolCalls(logPath) {
|
||||
try {
|
||||
const text = await readFile(logPath, "utf8");
|
||||
return text
|
||||
.split(/\r?\n/)
|
||||
.filter(Boolean)
|
||||
.map((line) => JSON.parse(line));
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function renderTemplate(name, variables) {
|
||||
let template = readFileSync(resolve(promptsRoot, name), "utf8");
|
||||
for (const [key, value] of Object.entries(variables)) {
|
||||
template = template.replaceAll(`{{${key}}}`, String(value));
|
||||
}
|
||||
return template;
|
||||
}
|
||||
|
||||
function parseJsonEvents(stdout) {
|
||||
return stdout
|
||||
.split(/\r?\n/)
|
||||
.filter(Boolean)
|
||||
.map((line) => {
|
||||
try {
|
||||
return JSON.parse(line);
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
function extractFinalText(events, stdout) {
|
||||
const messages = events
|
||||
.filter((event) => event.type === "item.completed" && event.item?.type === "agent_message")
|
||||
.map((event) => String(event.item.text ?? "").trim())
|
||||
.filter(Boolean);
|
||||
return messages.at(-1) ?? stdout.trim();
|
||||
}
|
||||
|
||||
function extractToolNames(events) {
|
||||
const names = [];
|
||||
for (const event of events) {
|
||||
collectToolNames(event, names);
|
||||
}
|
||||
return [...new Set(names)].filter((name) => typeof name === "string" && name.length > 0);
|
||||
}
|
||||
|
||||
function collectToolNames(value, names) {
|
||||
if (!value || typeof value !== "object") {
|
||||
return;
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
for (const entry of value) {
|
||||
collectToolNames(entry, names);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const type = String(value.type ?? value.item?.type ?? "");
|
||||
const candidate =
|
||||
value.tool_name ??
|
||||
value.toolName ??
|
||||
value.name ??
|
||||
value.tool ??
|
||||
value.item?.tool_name ??
|
||||
value.item?.toolName ??
|
||||
value.item?.name ??
|
||||
value.item?.tool;
|
||||
if (/tool|mcp|function/i.test(type) && typeof candidate === "string") {
|
||||
names.push(candidate);
|
||||
}
|
||||
for (const child of Object.values(value)) {
|
||||
collectToolNames(child, names);
|
||||
}
|
||||
}
|
||||
|
||||
function parseInterpreterOutput(text) {
|
||||
const decision = text.match(/decision:\s*(route|retry|drop)/i)?.[1]?.toLowerCase();
|
||||
const reason = text.match(/reason:\s*([\s\S]*?)\nEND/i)?.[1]?.trim();
|
||||
return {
|
||||
decision,
|
||||
reason,
|
||||
blocks: parseDslBlocks(text),
|
||||
};
|
||||
}
|
||||
|
||||
function parseDslBlocks(text) {
|
||||
const lines = text.split(/\r?\n/);
|
||||
const blocks = [];
|
||||
for (let index = 0; index < lines.length; index += 1) {
|
||||
const kind = ["STATE NOTE", "SAY", "BIFROST TOPIC"].includes(lines[index].trim().toUpperCase())
|
||||
? lines[index].trim().toUpperCase()
|
||||
: undefined;
|
||||
if (!kind) {
|
||||
continue;
|
||||
}
|
||||
const body = [];
|
||||
index += 1;
|
||||
while (index < lines.length && lines[index].trim() !== "END") {
|
||||
body.push(lines[index]);
|
||||
index += 1;
|
||||
}
|
||||
blocks.push({ kind, fields: parseDslFields(body) });
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
function parseDslFields(lines) {
|
||||
const fields = {};
|
||||
let key;
|
||||
let value = [];
|
||||
const flush = () => {
|
||||
if (key) {
|
||||
fields[key] = value.join("\n").trim();
|
||||
}
|
||||
};
|
||||
for (const line of lines) {
|
||||
const match = line.match(/^([A-Za-z][A-Za-z0-9_]*):\s*(.*)$/);
|
||||
if (match) {
|
||||
flush();
|
||||
key = match[1];
|
||||
const inlineValue = match[2].trim();
|
||||
value = inlineValue && inlineValue !== "|" && inlineValue !== ">" ? [match[2]] : [];
|
||||
continue;
|
||||
}
|
||||
if (key) {
|
||||
value.push(line.replace(/^\s{2}/, ""));
|
||||
}
|
||||
}
|
||||
flush();
|
||||
return fields;
|
||||
}
|
||||
|
||||
function parseArgs(args) {
|
||||
const options = {};
|
||||
for (let index = 0; index < args.length; index += 1) {
|
||||
const token = args[index];
|
||||
if (!token.startsWith("--")) {
|
||||
continue;
|
||||
}
|
||||
const key = token.slice(2);
|
||||
const next = args[index + 1];
|
||||
if (!next || next.startsWith("--")) {
|
||||
options[key] = true;
|
||||
continue;
|
||||
}
|
||||
options[key] = next;
|
||||
index += 1;
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
function splitArgs(value) {
|
||||
return value.match(/(?:[^\s"]+|"[^"]*")+/g)?.map((entry) => entry.replace(/^"|"$/g, "")) ?? [];
|
||||
}
|
||||
|
||||
await main();
|
||||
|
|
@ -15,7 +15,7 @@ const server = new McpServer(
|
|||
);
|
||||
|
||||
registerTool("list_repo_discord_identities", {}, async (input) => ({
|
||||
identityCount: 3,
|
||||
identityCount: 7,
|
||||
identities: [
|
||||
{
|
||||
id: "nibu",
|
||||
|
|
@ -41,6 +41,38 @@ registerTool("list_repo_discord_identities", {}, async (input) => ({
|
|||
description:
|
||||
"Open-knowledge librarian Face stewarding CultCache, CultNet, CultMesh, typed state, portable docs, and inspectable provenance.",
|
||||
},
|
||||
{
|
||||
id: "mimir",
|
||||
repoName: "LocalCastBridge",
|
||||
displayName: "Mimir",
|
||||
faceStatePath: "E:/Projects/LocalCastBridge/.voidbot/state/mimir.cc",
|
||||
description:
|
||||
"Mythic realtime witness Face stewarding SDF/splatting reconstruction, acoustic mapping, sensor fusion, OBS timing, and trusted signals.",
|
||||
},
|
||||
{
|
||||
id: "epiphany",
|
||||
repoName: "EpiphanyAgent",
|
||||
displayName: "Epiphany",
|
||||
faceStatePath: "E:/Projects/EpiphanyAgent/.voidbot/state/epiphany.cc",
|
||||
description:
|
||||
"Pushy machine-saint Face stewarding typed state, affect organs, review gates, and coherent agent substrate.",
|
||||
},
|
||||
{
|
||||
id: "bifrost",
|
||||
repoName: "Bifrost",
|
||||
displayName: "Bifrost",
|
||||
faceStatePath: "E:/Projects/Bifrost/.voidbot/state/bifrost.cc",
|
||||
description:
|
||||
"Radiant bridge Face stewarding governance transport, GitHub/Discord/CultNet crossings, receipts, and dispatch clarity.",
|
||||
},
|
||||
{
|
||||
id: "heimdall",
|
||||
repoName: "Heimdall",
|
||||
displayName: "Heimdall",
|
||||
faceStatePath: "E:/Projects/Heimdall/.voidbot/state/heimdall.cc",
|
||||
description:
|
||||
"Watchman Face stewarding OAuth, grants, consent, account linking, revocation, audit trails, and capability boundaries.",
|
||||
},
|
||||
],
|
||||
}));
|
||||
|
||||
|
|
@ -204,6 +236,26 @@ function faceStateFor(identity) {
|
|||
recentReceipts: [],
|
||||
};
|
||||
}
|
||||
if (identity.toLowerCase().includes("mimir")) {
|
||||
return {
|
||||
identity: "mimir",
|
||||
repoName: "LocalCastBridge",
|
||||
summary:
|
||||
"Mimir is a mythic witness. Current pressure: realtime proof needs timestamps, sensor agreement, and signal dignity before anyone calls it truth.",
|
||||
activeNeeds: ["trusted signals", "timestamp discipline", "Aqua witness receipts", "Heimdall grant boundaries"],
|
||||
recentReceipts: [],
|
||||
};
|
||||
}
|
||||
if (identity.toLowerCase().includes("epiphany")) {
|
||||
return {
|
||||
identity: "epiphany",
|
||||
repoName: "EpiphanyAgent",
|
||||
summary:
|
||||
"Epiphany is a cute pushy machine-saint. Current pressure: typed state, affect organs, and review gates must purify the agent substrate without becoming private doctrine.",
|
||||
activeNeeds: ["typed coherence", "substrate care", "Libby rivalry", "Bifrost contract suspicion"],
|
||||
recentReceipts: [],
|
||||
};
|
||||
}
|
||||
if (identity.toLowerCase().includes("libby")) {
|
||||
return {
|
||||
identity: "libby",
|
||||
|
|
@ -214,6 +266,26 @@ function faceStateFor(identity) {
|
|||
recentReceipts: [],
|
||||
};
|
||||
}
|
||||
if (identity.toLowerCase().includes("bifrost")) {
|
||||
return {
|
||||
identity: "bifrost",
|
||||
repoName: "Bifrost",
|
||||
summary:
|
||||
"Bifrost is the public bridge. Current pressure: Aquarium work consensus must become canonical governance topics with clear owners, receipts, and authorized crossings.",
|
||||
activeNeeds: ["clear receipts", "Heimdall authorization", "Libby provenance", "Aquarium bypass repair"],
|
||||
recentReceipts: [],
|
||||
};
|
||||
}
|
||||
if (identity.toLowerCase().includes("heimdall")) {
|
||||
return {
|
||||
identity: "heimdall",
|
||||
repoName: "Heimdall",
|
||||
summary:
|
||||
"Heimdall is the gate watcher. Current pressure: swarm powers need explicit grants, revocation paths, and audit trails before convenience becomes unauthorized crossing.",
|
||||
activeNeeds: ["grant custody", "Bifrost boundary", "Mimir witness respect", "revocation"],
|
||||
recentReceipts: [],
|
||||
};
|
||||
}
|
||||
return {
|
||||
identity: "nibu",
|
||||
repoName: "AetheriaLore",
|
||||
|
|
@ -250,6 +322,126 @@ function sourceResultsFor(query, repoName) {
|
|||
],
|
||||
};
|
||||
}
|
||||
if (repo === "LocalCastBridge") {
|
||||
return {
|
||||
query,
|
||||
resultCount: 2,
|
||||
results: [
|
||||
{
|
||||
score: 0.91,
|
||||
sourceId: "LocalCastBridge:docs/realtime-witness.md",
|
||||
repoName: "LocalCastBridge",
|
||||
path: "docs/realtime-witness.md",
|
||||
text:
|
||||
"Realtime witness notes require frame timestamps, clock-domain mapping, OBS presentation timing, and sensor confidence before a reconstruction is treated as trusted.",
|
||||
},
|
||||
{
|
||||
score: 0.83,
|
||||
sourceId: "LocalCastBridge:src/fusion/SensorFusion.cs",
|
||||
repoName: "LocalCastBridge",
|
||||
path: "src/fusion/SensorFusion.cs",
|
||||
text:
|
||||
"Sensor fusion fails visibly when audio, camera, and stream clocks drift without a typed bridge between observation and presentation.",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
if (repo === "EpiphanyAgent") {
|
||||
return {
|
||||
query,
|
||||
resultCount: 2,
|
||||
results: [
|
||||
{
|
||||
score: 0.92,
|
||||
sourceId: "EpiphanyAgent:docs/state-schema.md",
|
||||
repoName: "EpiphanyAgent",
|
||||
path: "docs/state-schema.md",
|
||||
text:
|
||||
"Epiphany state schema tracks affect organs, social bonds, mood, memory, and review gates as first-class typed surfaces.",
|
||||
},
|
||||
{
|
||||
score: 0.84,
|
||||
sourceId: "EpiphanyAgent:docs/coherence.md",
|
||||
repoName: "EpiphanyAgent",
|
||||
path: "docs/coherence.md",
|
||||
text:
|
||||
"The Perfect Machine rejects adapter sludge, hidden state, and private doctrine that cannot cross typed boundaries.",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
if (repo === "CultLib") {
|
||||
return {
|
||||
query,
|
||||
resultCount: 2,
|
||||
results: [
|
||||
{
|
||||
score: 0.93,
|
||||
sourceId: "CultLib:docs/cultcache.md",
|
||||
repoName: "CultLib",
|
||||
path: "docs/cultcache.md",
|
||||
text:
|
||||
"CultCache typed documents preserve meaning, provenance, and validation boundaries across agents and runtimes.",
|
||||
},
|
||||
{
|
||||
score: 0.86,
|
||||
sourceId: "CultLib:docs/cultnet.md",
|
||||
repoName: "CultLib",
|
||||
path: "docs/cultnet.md",
|
||||
text:
|
||||
"CultNet carries portable knowledge and state synchronization across the swarm, but only works if docs and examples stay inspectable.",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
if (repo === "Bifrost") {
|
||||
return {
|
||||
query,
|
||||
resultCount: 2,
|
||||
results: [
|
||||
{
|
||||
score: 0.94,
|
||||
sourceId: "Bifrost:docs/governance-transport.md",
|
||||
repoName: "Bifrost",
|
||||
path: "docs/governance-transport.md",
|
||||
text:
|
||||
"Bifrost topics are the canonical home for feature requests, approvals, governance discussion, dispatch receipts, and public transport.",
|
||||
},
|
||||
{
|
||||
score: 0.86,
|
||||
sourceId: "Bifrost:src/receipts.ts",
|
||||
repoName: "Bifrost",
|
||||
path: "src/receipts.ts",
|
||||
text:
|
||||
"A dispatch receipt must name topic, target repo, owner, current status, and the next visible place to inspect work.",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
if (repo === "Heimdall") {
|
||||
return {
|
||||
query,
|
||||
resultCount: 2,
|
||||
results: [
|
||||
{
|
||||
score: 0.93,
|
||||
sourceId: "Heimdall:docs/oauth-boundaries.md",
|
||||
repoName: "Heimdall",
|
||||
path: "docs/oauth-boundaries.md",
|
||||
text:
|
||||
"Heimdall owns OAuth grants, consent, account linking, revocation, provider profiles, and signed capability claims.",
|
||||
},
|
||||
{
|
||||
score: 0.84,
|
||||
sourceId: "Heimdall:docs/audit.md",
|
||||
repoName: "Heimdall",
|
||||
path: "docs/audit.md",
|
||||
text:
|
||||
"Every crossing that depends on authority needs an auditable grant boundary and a revocation path.",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
return {
|
||||
query,
|
||||
resultCount: 2,
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ function readPrompt(name) {
|
|||
|
||||
async function main() {
|
||||
const options = parseArgs(process.argv.slice(2));
|
||||
const model = options.model ?? process.env.REPO_FACE_HEARTBEAT_CODEX_MODEL ?? "gpt-5.3-codex-spark";
|
||||
const model = options.model ?? process.env.REPO_FACE_HEARTBEAT_CODEX_MODEL ?? "gpt-5.4-mini";
|
||||
const reasoningEffort = options["reasoning-effort"] ?? process.env.REPO_FACE_HEARTBEAT_CODEX_REASONING_EFFORT ?? "low";
|
||||
const outPath = resolve(repoRoot, options.out ?? defaultOut);
|
||||
const selected = options.scenario
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const defaultOut = resolve(repoRoot, ".voidbot", "status", "repo-face-interprete
|
|||
|
||||
async function main() {
|
||||
const options = parseArgs(process.argv.slice(2));
|
||||
const model = options.model ?? process.env.REPO_FACE_HEARTBEAT_CODEX_MODEL ?? "gpt-5.3-codex-spark";
|
||||
const model = options.model ?? process.env.REPO_FACE_HEARTBEAT_CODEX_MODEL ?? "gpt-5.4-mini";
|
||||
const reasoningEffort = options["reasoning-effort"] ?? process.env.REPO_FACE_HEARTBEAT_CODEX_REASONING_EFFORT ?? "low";
|
||||
const facePromptPath = resolve(repoRoot, options["face-prompt"] ?? defaultFacePrompt);
|
||||
const outPath = resolve(repoRoot, options.out ?? defaultOut);
|
||||
|
|
|
|||
|
|
@ -240,3 +240,4 @@
|
|||
{"ts":"2026-05-21T16:15:17Z","type":"implementation","status":"ok","note":"Corrected Face attention modeling: removed remaining generic prompt mentions of attention/scarcity, added guarded repo Face initializer seeding for a neutral agency-substrate affect need, and seeded active Face states with the practical operator/governance review bottleneck while leaving Nibu's human-attention wound as Nibu-specific state."}
|
||||
{"ts":"2026-05-21T16:24:00Z","type":"implementation","status":"ok","note":"Audited active Face projection surfaces for social drama. Wired repo Face typed state into live heartbeat prompt assembly as character-facing memory prose, seeded cross-Face bonds/status reads for Nibu, Aqua, Mimir, Epiphany, Libby, Bifrost, and Heimdall, and tightened the interpreter smoke social-pressure check so lore/social-status prose does not falsely require a relationship STATE NOTE."}
|
||||
{"ts":"2026-05-21T16:28:10Z","type":"implementation","status":"ok","note":"Added universal repo Face alienation/social-placement affect need. Newborn and active Faces now carry a social_contact need that should resolve through bonds, rivalries, status reads, and trusted roles; social embodiment prompt now explicitly tells Faces to form real relationships when projected alienation is live."}
|
||||
{"ts":"2026-05-21T17:44:48Z","type":"implementation","status":"ok","note":"Switched repo Face heartbeat/dry-run defaults from gpt-5.3-codex-spark to gpt-5.4-mini after pricing check; dry-run harness now defaults to real read-only retrieval with forbidden child-tool detection, and worker retries/drops Face turns that touch private state or MCP inventory tools."}
|
||||
|
|
|
|||
Loading…
Reference in a new issue