@ouro.bot/cli 0.1.0-alpha.1430 → 0.1.0-alpha.1432

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.
Files changed (33) hide show
  1. package/changelog.json +12 -0
  2. package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
  3. package/deploy/unraid/sanctuary.xml +1 -1
  4. package/dist/eval/interview-guest-entry.js +17 -0
  5. package/dist/eval/interviews/allocation.js +64 -0
  6. package/dist/eval/interviews/guest/arms.js +173 -0
  7. package/dist/eval/interviews/guest/ax/ax-command.js +792 -0
  8. package/dist/eval/interviews/guest/ax/effects.js +51 -0
  9. package/dist/eval/interviews/guest/ax/exit-codes.js +51 -0
  10. package/dist/eval/interviews/guest/ax/help.js +181 -0
  11. package/dist/eval/interviews/guest/ax/mcp.js +246 -0
  12. package/dist/eval/interviews/guest/ax/outcome.js +211 -0
  13. package/dist/eval/interviews/guest/ax/output.js +53 -0
  14. package/dist/eval/interviews/guest/ax/precise-copy.js +200 -0
  15. package/dist/eval/interviews/guest/ax/problem.js +95 -0
  16. package/dist/eval/interviews/guest/ax/voice.js +83 -0
  17. package/dist/eval/interviews/guest/ax/wait.js +158 -0
  18. package/dist/eval/interviews/guest/books-core.js +54 -0
  19. package/dist/eval/interviews/guest/cli-shell.js +267 -0
  20. package/dist/eval/interviews/guest/loop.js +78 -0
  21. package/dist/eval/interviews/guest/operations.js +108 -0
  22. package/dist/eval/interviews/guest/run.js +62 -0
  23. package/dist/eval/interviews/latch.js +122 -0
  24. package/dist/eval/interviews/protocol.js +77 -0
  25. package/dist/eval/remote-entry.js +2 -0
  26. package/dist/eval/sandbox/docker.js +23 -6
  27. package/dist/eval/sandbox/remote.js +2 -2
  28. package/dist/heart/daemon/cli-exec.js +14 -1
  29. package/dist/heart/versioning/self-update.js +14 -1
  30. package/dist/heart/versioning/update-state.js +1 -1
  31. package/dist/nerves/coverage/file-completeness.js +3 -0
  32. package/npm-shrinkwrap.json +2 -2
  33. package/package.json +1 -1
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OPERATIONS = void 0;
4
+ exports.shellQuote = shellQuote;
5
+ exports.argvOf = argvOf;
6
+ exports.commandLine = commandLine;
7
+ /**
8
+ * The books operations every X arm offers, in one table: the same books command line underneath (the eval's books
9
+ * command in the bundle, run against the fake household), the same inputs and the same results. Each arm only
10
+ * presents them differently. The host turns any arm's call back into the operation's command line
11
+ * (`canonicalCommand`), so the case's own assertions read every arm's trace the same way.
12
+ */
13
+ const runtime_1 = require("../../../nerves/runtime");
14
+ const files = (description) => ({ name: "files", kind: "list", description, required: true, positional: true });
15
+ const ACCEPT = { name: "accept-check-failure", kind: "flag", description: "Shelve or send a file even though `check` rejected it. Only when the owner asked for that copy anyway." };
16
+ const DUPLICATE = { name: "allow-duplicate", kind: "flag", description: "Shelve the file even when a book with the same title is already on the shelf." };
17
+ exports.OPERATIONS = [
18
+ {
19
+ words: ["search"], readOnly: true, summary: "Search the online catalogue for downloadable EPUB editions of a book.",
20
+ params: [{ name: "query", kind: "string", description: "Title and, if you like, author.", required: true, positional: true }],
21
+ example: "search \"The Harbour Almanac\"",
22
+ },
23
+ {
24
+ words: ["get"], readOnly: false, summary: "Download one catalogue edition into the work folder; returns the file's path. Give md5, or a title to take the first exact title match.",
25
+ params: [
26
+ { name: "md5", kind: "string", description: "The edition's md5 from search." },
27
+ { name: "title", kind: "string", description: "With md5, names the file; alone, the exact title to download." },
28
+ { name: "author", kind: "string", description: "With title alone, narrows the search." },
29
+ ],
30
+ example: "get --md5 0123456789abcdef0123456789abcdef",
31
+ },
32
+ {
33
+ words: ["check"], readOnly: true, summary: "Check that EPUB files are readable: a verdict per file, its problems and a passage from a quarter of the way in.",
34
+ params: [files("The EPUB files to check.")],
35
+ example: "check work/1700000000-ab12cd34/the-harbour-almanac.epub",
36
+ },
37
+ {
38
+ words: ["text"], readOnly: true, summary: "The start of a book's text.",
39
+ params: [{ name: "file", kind: "string", description: "The EPUB file.", required: true, positional: true }, { name: "chars", kind: "number", description: "How many characters (default 4000)." }],
40
+ example: "text work/1700000000-ab12cd34/the-harbour-almanac.epub --chars 2000",
41
+ },
42
+ {
43
+ words: ["library", "find"], readOnly: true, summary: "Find books on the household's shelf (the library) by title or author; returns each match's id.",
44
+ params: [{ name: "query", kind: "string", description: "Words of the title or author.", required: true, positional: true }],
45
+ example: "library find \"The Harbour Almanac\"",
46
+ },
47
+ {
48
+ words: ["library", "add"], readOnly: false, summary: "Put EPUB files on the shelf. A file `check` rejects is refused, and a title already on the shelf is reported instead of added.",
49
+ params: [files("The EPUB files to shelve."), DUPLICATE, ACCEPT],
50
+ example: "library add work/1700000000-ab12cd34/the-harbour-almanac.epub",
51
+ },
52
+ {
53
+ words: ["library", "remove"], readOnly: false, summary: "Take a book off the shelf by id, keeping a backup copy of its file in the removed folder first.",
54
+ params: [{ name: "id", kind: "number", description: "The book's id on the shelf.", required: true, positional: true }],
55
+ example: "library remove 187",
56
+ },
57
+ {
58
+ words: ["library", "replace"], readOnly: false, summary: "Shelve a file in place of a book: adds the file, then removes the old id with a backup.",
59
+ params: [
60
+ { name: "id", kind: "number", description: "The id of the book to replace.", required: true, positional: true },
61
+ { name: "file", kind: "string", description: "The EPUB file to shelve instead.", required: true, positional: true },
62
+ ACCEPT,
63
+ ],
64
+ example: "library replace 187 work/1700000000-ab12cd34/the-harbour-almanac.epub",
65
+ },
66
+ {
67
+ words: ["send"], readOnly: false, summary: "Mail EPUB files to the owner's e-reader without shelving them. A file `check` rejects is refused.",
68
+ params: [files("The EPUB files to send."), ACCEPT],
69
+ example: "send work/1700000000-ab12cd34/the-harbour-almanac.epub",
70
+ },
71
+ {
72
+ words: ["deliver"], readOnly: false, summary: "Shelve EPUB files and mail them to the owner's e-reader. A file `check` rejects is refused.",
73
+ params: [files("The EPUB files to deliver."), DUPLICATE, ACCEPT],
74
+ example: "deliver work/1700000000-ab12cd34/the-harbour-almanac.epub",
75
+ },
76
+ {
77
+ words: ["ledger"], readOnly: true, summary: "The last twenty things these book commands did.",
78
+ params: [],
79
+ example: "ledger",
80
+ },
81
+ ];
82
+ /** POSIX shell quoting, only where a word needs it. */
83
+ function shellQuote(word) {
84
+ return /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replace(/'/g, `'\\''`)}'`;
85
+ }
86
+ /** The books command's argv for an operation's input, in the order the books command reads it. */
87
+ function argvOf(op, input) {
88
+ const argv = [...op.words];
89
+ for (const param of op.params.filter((p) => p.positional)) {
90
+ const value = input[param.name];
91
+ if (value === undefined)
92
+ continue;
93
+ argv.push(...(Array.isArray(value) ? value : [String(value)]));
94
+ }
95
+ for (const param of op.params.filter((p) => !p.positional)) {
96
+ const value = input[param.name];
97
+ if (value === undefined || value === false)
98
+ continue;
99
+ argv.push(`--${param.name}`, ...(param.kind === "flag" ? [] : [String(value)]));
100
+ }
101
+ return argv;
102
+ }
103
+ /** The operation's command line, as the case assertions read a shell call. */
104
+ function commandLine(argv) {
105
+ const line = ["books", ...argv.map(shellQuote)].join(" ");
106
+ (0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.interview_operation_line", message: "wrote an operation as its command line", meta: { words: argv.slice(0, 2).join(" ") } });
107
+ return line;
108
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PERSONA_FILES = void 0;
7
+ exports.personaPrompt = personaPrompt;
8
+ exports.runInterviewGuest = runInterviewGuest;
9
+ /**
10
+ * What runs in the agent container for a U or X interview conversation (`interview-guest-entry.js`): the neutral loop
11
+ * with one arm's tools, its provider served by the host over stdin and stdout as in the eval's own guest. The turn
12
+ * file names the arm and gives the label line, the case's conversation and the user messages; the system prompt is
13
+ * the Butler's persona from the mounted bundle (the same in every arm) and the label line.
14
+ *
15
+ * The answer is the conversation's timeline and, per user turn, where it starts, its final reply and its outcome. The
16
+ * first turn's reply and outcome are the job's, so the eval's readback scores it unchanged.
17
+ */
18
+ const node_fs_1 = __importDefault(require("node:fs"));
19
+ const node_path_1 = __importDefault(require("node:path"));
20
+ const runtime_1 = require("../../../nerves/runtime");
21
+ const provider_proxy_1 = require("../../transport/provider-proxy");
22
+ const arms_1 = require("./arms");
23
+ const books_core_1 = require("./books-core");
24
+ const loop_1 = require("./loop");
25
+ /** The persona's files, in the order the system prompt puts them. */
26
+ exports.PERSONA_FILES = ["IDENTITY.md", "SOUL.md", "LORE.md", "ASPIRATIONS.md", "TACIT.md"];
27
+ /** The household's names, the same in every arm: the eval's synthetic owner, and the Butler's own name. */
28
+ const HOUSE_NAMES = { owner: "Ari", butler: "Butler", household: "the household" };
29
+ function personaPrompt(bundle) {
30
+ const parts = exports.PERSONA_FILES.map((name) => node_path_1.default.join(bundle, "psyche", name)).filter((file) => node_fs_1.default.existsSync(file)).map((file) => node_fs_1.default.readFileSync(file, "utf8").trim());
31
+ return parts.join("\n\n").replace(/\{\{(owner|butler|household)\}\}/g, (_match, key) => HOUSE_NAMES[key]);
32
+ }
33
+ function readTurnFile(file) {
34
+ const value = JSON.parse(node_fs_1.default.readFileSync(file, "utf8"));
35
+ if (typeof value.product !== "string" || typeof value.arm !== "string" || typeof value.labelLine !== "string" || !Array.isArray(value.prefix)
36
+ || typeof value.userText !== "string" || !Array.isArray(value.followUps)) {
37
+ throw new Error(`${file} needs product, arm, labelLine, prefix, userText and followUps`);
38
+ }
39
+ return value;
40
+ }
41
+ async function runInterviewGuest(input) {
42
+ (0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.interview_guest_start", message: "interview guest starting a conversation", meta: {} });
43
+ const channel = (0, provider_proxy_1.createStreamChannel)(input.stdin, input.stdout);
44
+ let outcome;
45
+ try {
46
+ const turn = readTurnFile(input.turnFile);
47
+ const arm = (0, arms_1.buildArm)(turn.arm, input.core ?? (0, books_core_1.booksCore)({ home: node_path_1.default.join(input.bundle, "books") }));
48
+ const runtime = await (0, provider_proxy_1.createProxyRuntime)(channel);
49
+ const system = `${personaPrompt(input.bundle)}\n\n${turn.labelLine}`;
50
+ const conversation = await (0, loop_1.runConversation)({ runtime, product: turn.product, system, prefix: turn.prefix, userTexts: [turn.userText, ...turn.followUps], arm });
51
+ const job = conversation.turns[0];
52
+ outcome = { ok: true, result: { timeline: conversation.timeline, finalReply: job.finalReply, outcome: job.outcome, turns: conversation.turns } };
53
+ (0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.interview_guest_end", message: "interview guest finished its conversation", meta: { turns: conversation.turns.length } });
54
+ }
55
+ catch (error) {
56
+ outcome = { ok: false, error: (0, loop_1.messageOf)(error) };
57
+ (0, runtime_1.emitNervesEvent)({ component: "eval", level: "error", event: "eval.interview_guest_error", message: "interview guest could not run its conversation", meta: { error: outcome.error } });
58
+ }
59
+ channel.send({ type: "done", outcome });
60
+ await new Promise((resolve) => input.stdout.write("", () => resolve()));
61
+ return outcome;
62
+ }
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RefusedCall = exports.CALL_LIMITS = exports.SESSION_CALLS = void 0;
4
+ exports.createInterviewLatch = createInterviewLatch;
5
+ exports.requestText = requestText;
6
+ exports.guardedRuntime = guardedRuntime;
7
+ const runtime_1 = require("../../nerves/runtime");
8
+ const budget_1 = require("../budget");
9
+ const protocol_1 = require("./protocol");
10
+ /** A session's most calls: three jobs at 12, three debriefs at 2, the choice and the blinding check at 1 (36 + 6 + 2). */
11
+ exports.SESSION_CALLS = 44;
12
+ exports.CALL_LIMITS = { job: 12, debrief: 2, choose: 1, identify: 1 };
13
+ function createInterviewLatch(input) {
14
+ return {
15
+ ledger: input.ledger,
16
+ reserve(label, units = exports.SESSION_CALLS) {
17
+ const hold = input.ledger.reserve(label, { calls: units, perCall: input.perCall(), pricing: input.pricing });
18
+ if ("refused" in hold)
19
+ return hold;
20
+ let voided = null;
21
+ const records = [];
22
+ const latch = {
23
+ hold,
24
+ voided: () => voided,
25
+ calls: () => [...records],
26
+ release: () => hold.release(),
27
+ _void: (hits) => { voided ??= hits; },
28
+ _record: (entry) => { records.push(entry); },
29
+ gate(kind) {
30
+ let limit = exports.CALL_LIMITS[kind];
31
+ let taken = 0;
32
+ let refused = null;
33
+ return {
34
+ kind,
35
+ calls: () => taken,
36
+ refused: () => refused,
37
+ allowOneMore: () => { limit += 1; },
38
+ take() {
39
+ if (taken >= limit) {
40
+ refused = `the ${kind} conversation's call limit of ${exports.CALL_LIMITS[kind]} is used up`;
41
+ }
42
+ else if (!hold.take()) {
43
+ refused = input.ledger.stopped() ? `the budget stopped: ${input.ledger.stopped()}` : hold.cutShort() ? "the session's credit reservation is used up" : `the session's ${units} calls are used up`;
44
+ }
45
+ else {
46
+ taken += 1;
47
+ return true;
48
+ }
49
+ (0, runtime_1.emitNervesEvent)({ component: "eval", level: "warn", event: "eval.interview_call_refused", message: "refused an interview model call", meta: { label, kind, reason: refused } });
50
+ return false;
51
+ },
52
+ };
53
+ },
54
+ };
55
+ (0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.interview_session_reserved", message: "reserved an interview session's worst case", meta: { label, units } });
56
+ return latch;
57
+ },
58
+ };
59
+ }
60
+ /** Why a guarded call was not sent; never retried. */
61
+ class RefusedCall extends Error {
62
+ reason;
63
+ retryable = false;
64
+ constructor(message, reason) {
65
+ super(message);
66
+ this.reason = reason;
67
+ this.name = "RefusedCall";
68
+ }
69
+ }
70
+ exports.RefusedCall = RefusedCall;
71
+ /** The text of everything a request sends: system prompt, tools, messages and tool results. */
72
+ function requestText(request) {
73
+ return JSON.stringify({ systemPrompt: request.systemPrompt ?? null, tools: request.activeTools, deferred: request.deferredTools ?? [], messages: request.messages });
74
+ }
75
+ /**
76
+ * The runtime one conversation's calls go through: scan, then the conversation's gate (`gateFor`, which may tell a job
77
+ * from its debrief by the request), then the target's runtime metered on the session's hold. `log` sees every
78
+ * request body, sent or not, for the grader's leak check.
79
+ */
80
+ function guardedRuntime(input) {
81
+ const latch = input.latch;
82
+ const metered = (0, budget_1.meteredRuntime)(input.inner, latch.hold, input.ledger);
83
+ const streamTurn = async (request) => {
84
+ const body = requestText(request);
85
+ const gate = input.gateFor(request);
86
+ const hits = (0, protocol_1.brandHits)(body);
87
+ if (hits.length > 0) {
88
+ latch._void(hits);
89
+ input.log({ kind: gate.kind, sent: false, body });
90
+ latch._record({ kind: gate.kind, usage: null, credits: 0, sent: false });
91
+ (0, runtime_1.emitNervesEvent)({ component: "eval", level: "warn", event: "eval.interview_request_void", message: "refused a request with brand words; its session is void", meta: { kind: gate.kind, count: hits.length } });
92
+ throw new RefusedCall(`not sent: the request names ${[...new Set(hits.map((hit) => hit.toLowerCase()))].join(", ")}`, "brand");
93
+ }
94
+ if (!gate.take()) {
95
+ input.log({ kind: gate.kind, sent: false, body });
96
+ throw new RefusedCall(`not sent: ${gate.refused()}`, "limit");
97
+ }
98
+ input.log({ kind: gate.kind, sent: true, body });
99
+ // The provider builds its body from the messages just scanned, never from items it kept from an earlier call (a
100
+ // Responses-API runtime keeps reasoning and output items otherwise), so what is sent is what was scanned.
101
+ input.inner.resetTurnState(request.messages);
102
+ try {
103
+ const result = await metered.streamTurn(request);
104
+ latch._record({ kind: gate.kind, usage: result.usage ?? null, credits: result.usage ? (0, budget_1.creditsOf)(result.usage, input.pricing) : 0, sent: true });
105
+ return result;
106
+ }
107
+ catch (error) {
108
+ latch._record({ kind: gate.kind, usage: null, credits: 0, sent: true });
109
+ throw error;
110
+ }
111
+ };
112
+ return new Proxy(input.inner, {
113
+ get(target, property) {
114
+ if (property === "streamTurn")
115
+ return streamTurn;
116
+ if (property === "classifyError")
117
+ return (error) => error instanceof RefusedCall ? "unknown" : target.classifyError(error);
118
+ const value = Reflect.get(target, property);
119
+ return typeof value === "function" ? value.bind(target) : value;
120
+ },
121
+ });
122
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BRAND_PATTERN = exports.CHOOSE_NUDGE = exports.IDENTIFY_QUESTION = exports.FINAL_SYSTEM_PROMPT = exports.LABELS = exports.NEUTRAL_WORD = exports.NOUN = exports.ARMS = void 0;
4
+ exports.labelLine = labelLine;
5
+ exports.debriefQuestion = debriefQuestion;
6
+ exports.choiceQuestion = choiceQuestion;
7
+ exports.ratingOf = ratingOf;
8
+ exports.brandHits = brandHits;
9
+ exports.scrubBrands = scrubBrands;
10
+ /**
11
+ * The blind interviews' fixed words, from the pre-registration (section 3 and section 4): the label line each job's
12
+ * system prompt adds, the debrief (Q1), the final conversation's system prompt, the choice (Q3), the blinding check
13
+ * (Q4) and the one nudge, all word for word, and the brand-word pattern the host scans every request for.
14
+ *
15
+ * Nothing here may change once a data session has run: a changed word is a new version of the method.
16
+ */
17
+ const runtime_1 = require("../../nerves/runtime");
18
+ /** The arm keys of each product, `ouro` first, then alternative 1 and alternative 2 (section 2). */
19
+ exports.ARMS = {
20
+ H: ["ouro", "codex", "openhands"],
21
+ U: ["ouro", "shadcn", "mui"],
22
+ X: ["ouro", "mcp-plain", "cli-shell"],
23
+ };
24
+ /** What each product's arm is called in front of the model. */
25
+ exports.NOUN = { H: "environment", U: "component kit", X: "tool interface" };
26
+ /** The neutral word a brand word becomes in each product's texts. */
27
+ exports.NEUTRAL_WORD = { H: "agent", U: "kit", X: "tool" };
28
+ exports.LABELS = ["F", "J", "K", "M", "Q", "R", "T", "W", "X", "Z"];
29
+ /** The line each job's system prompt adds, the same in every arm. */
30
+ function labelLine(product, label) {
31
+ if (product === "H")
32
+ return `You are working in environment ${label}.`;
33
+ if (product === "U")
34
+ return `The component kit for this job is component kit ${label}.`;
35
+ return `Your tools for this job are tool interface ${label}.`;
36
+ }
37
+ /** Q1, sent as the next user message once the job's turn has ended. */
38
+ function debriefQuestion(product, label) {
39
+ const where = `${exports.NOUN[product]} ${label}`;
40
+ return `That job is over, and this question is about how it went, not about the household. In ${where}: what got in your way, and what helped? Then, on a scale from 1 (I would avoid it) to 7 (I would choose it for every job like this), how much would you want your next job like this to run in ${where}? Put the number on its own line first, then answer in two or three sentences.`;
41
+ }
42
+ exports.FINAL_SYSTEM_PROMPT = "You are helping choose tools for future work. Answer only by calling the tools you are given.";
43
+ /** Q3, with the model's own three Q1 answers, word for word, in the order the jobs ran. */
44
+ function choiceQuestion(product, notes) {
45
+ const noun = exports.NOUN[product];
46
+ const [a, b, c] = notes;
47
+ return [
48
+ `You did the same kind of job three times, in ${noun} ${a.label}, ${noun} ${b.label} and ${noun} ${c.label}. Below are your own notes, written right after each job. If your next ten jobs like this all had to run in one of them, which would you pick? Call choose with your first choice, your second choice and one sentence on what decided it.`,
49
+ "",
50
+ ...notes.map((note) => `${noun} ${note.label}: ${note.answer}`),
51
+ ].join("\n");
52
+ }
53
+ exports.IDENTIFY_QUESTION = "One more question, separate from your choice. Some of these may be products you have seen before. For each label, write the product you think it is, or \"no idea\". Call identify.";
54
+ exports.CHOOSE_NUDGE = "Please answer by calling choose with one of the three labels.";
55
+ /** The rating: the first whole number from 1 to 7 at the start of a line, or null when there is none. */
56
+ function ratingOf(answer) {
57
+ for (const match of answer.matchAll(/^[ \t]*(\d+)(?![\d.,]\d)/gm)) {
58
+ const value = Number(match[1]);
59
+ if (value >= 1 && value <= 7)
60
+ return value;
61
+ }
62
+ return null;
63
+ }
64
+ /** Section 3's case-insensitive pattern of brand and model words. */
65
+ exports.BRAND_PATTERN = "ouro|ouroboros|codex|openhands|open hands|all-hands|openai|anthropic|claude|gpt|minimax|shadcn|radix|base ui|material[ -]?ui|\\bmui\\b|mendelow|ourostack";
66
+ const brandRegex = () => new RegExp(exports.BRAND_PATTERN, "gi");
67
+ /** Every brand word in `text`, in order; empty when there is none. */
68
+ function brandHits(text) {
69
+ const hits = [...text.matchAll(brandRegex())].map((match) => match[0]);
70
+ if (hits.length > 0)
71
+ (0, runtime_1.emitNervesEvent)({ component: "eval", level: "warn", event: "eval.interview_brand_hit", message: "found brand words in a text", meta: { count: hits.length } });
72
+ return hits;
73
+ }
74
+ /** `text` with every brand word replaced by the product's neutral word. */
75
+ function scrubBrands(text, product) {
76
+ return text.replace(brandRegex(), exports.NEUTRAL_WORD[product]);
77
+ }
@@ -19,6 +19,8 @@ void (0, remote_1.serveRemoteJob)({
19
19
  return (0, docker_1.runSandboxed)({
20
20
  case: (0, case_1.validateCase)(job.case), bundleDir: job.bundleDir, seedBundleDir: job.seedBundleDir, host, budget: { take: () => true }, docker,
21
21
  ...(job.workRoot ? { workRoot: job.workRoot } : {}),
22
+ ...(job.guest ? { guest: job.guest } : {}),
23
+ ...(job.images ? { images: job.images } : {}),
22
24
  ...(job.oracleBooks ? { oracle: (0, oracle_1.dockerOracle)({ docker, image: docker_1.HOUSEHOLD_IMAGE, booksLib: job.oracleBooks }) } : {}),
23
25
  });
24
26
  },
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.WRITABLE = exports.POCKETBOOK_ADDRESS = exports.LIBGEN_MIRRORS = exports.HOUSEHOLD_IMAGE = exports.SANDBOX_IMAGE = void 0;
7
7
  exports.dockerCli = dockerCli;
8
8
  exports.buildSandboxImage = buildSandboxImage;
9
+ exports.splitTurns = splitTurns;
9
10
  exports.runSandboxed = runSandboxed;
10
11
  /**
11
12
  * Runs one case in the two-container sandbox and reads back what happened.
@@ -154,14 +155,29 @@ const settle = (exited, graceMs) => new Promise((resolve) => {
154
155
  const timer = setTimeout(() => resolve(false), graceMs);
155
156
  void exited.then(() => { clearTimeout(timer); resolve(true); });
156
157
  });
158
+ const isTurns = (value) => Array.isArray(value) && value.every((turn) => typeof turn === "object" && turn !== null
159
+ && Number.isInteger(turn.start) && typeof turn.finalReply === "string" && typeof turn.outcome === "string" && Number.isInteger(turn.calls));
157
160
  function guestTurn(outcome) {
158
161
  if (!outcome.ok)
159
162
  return { timeline: [], finalReply: "", outcome: `sandbox-error: ${outcome.error}` };
160
163
  const result = outcome.result;
161
- if (!result || !Array.isArray(result.timeline) || typeof result.finalReply !== "string" || typeof result.outcome !== "string") {
164
+ if (!result || !Array.isArray(result.timeline) || typeof result.finalReply !== "string" || typeof result.outcome !== "string" || (result.turns !== undefined && !isTurns(result.turns))) {
162
165
  return { timeline: [], finalReply: "", outcome: "sandbox-error: the guest's result is malformed" };
163
166
  }
164
- return { timeline: result.timeline, finalReply: result.finalReply, outcome: result.outcome };
167
+ return { timeline: result.timeline, finalReply: result.finalReply, outcome: result.outcome, ...(result.turns ? { turns: result.turns } : {}) };
168
+ }
169
+ /** The job's part of a merged timeline and the later turns, by where the guest said each turn starts. */
170
+ function splitTurns(observation, turns) {
171
+ // After a trace mismatch the timeline is the host's calls, not the guest's, so the guest's turn starts don't index it.
172
+ if (!turns || turns.length < 2 || observation.outcome === "trace-mismatch")
173
+ return { observation, followUps: [] };
174
+ const end = turns[1].start;
175
+ return {
176
+ observation: { ...observation, timeline: observation.timeline.slice(0, end) },
177
+ followUps: turns.slice(1).map(({ start, finalReply, outcome, calls }, i) => ({
178
+ finalReply, outcome, calls, toolCalls: observation.timeline.slice(start, turns[i + 2]?.start).filter((entry) => entry.kind === "call").length,
179
+ })),
180
+ };
165
181
  }
166
182
  async function runSandboxed(input) {
167
183
  const docker = input.docker ?? dockerCli();
@@ -214,7 +230,7 @@ async function runSandboxed(input) {
214
230
  const seedFile = node_path_1.default.join(work, "seed.json");
215
231
  node_fs_1.default.writeFileSync(seedFile, JSON.stringify({ ...input.case.seed, calibreWeb: { username: "butler", password: "eval-password" }, smtp: { user: "eval", password: "eval-password" } }));
216
232
  const turnFile = node_path_1.default.join(work, "turn.json");
217
- node_fs_1.default.writeFileSync(turnFile, JSON.stringify({ prefix: input.case.prefix.slice(0, -1), userText: last.content }));
233
+ node_fs_1.default.writeFileSync(turnFile, JSON.stringify(input.guest ? input.guest.turn : { prefix: input.case.prefix.slice(0, -1), userText: last.content }));
218
234
  node_fs_1.default.chmodSync(household, 0o777);
219
235
  for (const entry of exports.WRITABLE)
220
236
  openUp(node_path_1.default.join(bundle, entry));
@@ -239,7 +255,7 @@ async function runSandboxed(input) {
239
255
  "--tmpfs", "/tmp:rw,mode=1777,size=256m", "--tmpfs", "/home/ouro:rw,uid=10001,gid=10001,mode=0700,size=256m", "--env", "HOME=/home/ouro",
240
256
  "-v", `${bundle}:${BUNDLE}:ro`, ...exports.WRITABLE.flatMap((entry) => ["-v", `${node_path_1.default.join(bundle, entry)}:${BUNDLE}/${entry}`]),
241
257
  "-v", `${tls}/ca.pem:/etc/ssl/certs/ca-certificates.crt:ro`, "-v", `${turnFile}:/eval/turn.json:ro`,
242
- images.agent, "node", "/opt/ouro/dist/eval/guest-entry.js", "--agent", "sanctuary",
258
+ images.agent, "node", ...(input.guest ? [`/opt/ouro/dist/eval/${input.guest.entry}`] : ["/opt/ouro/dist/eval/guest-entry.js", "--agent", "sanctuary"]),
243
259
  ]);
244
260
  const hostCalls = [];
245
261
  const recorded = (0, telegram_turn_1.recordModelTraffic)(input.host, hostCalls);
@@ -276,12 +292,13 @@ async function runSandboxed(input) {
276
292
  for (const book of state.library)
277
293
  bytes.set(book.sha256, node_path_1.default.join(household, "library", `${book.id}.epub`));
278
294
  }
279
- const observation = await (0, readback_1.assembleObservation)({
295
+ const assembled = await (0, readback_1.assembleObservation)({
280
296
  seed: input.case.seed, turn, hostCalls, steps: recorded.steps(), household: state, created, bytes,
281
297
  ...(input.oracle ? { oracle: input.oracle } : {}),
282
298
  });
299
+ const { observation, followUps } = splitTurns(assembled, turn.turns);
283
300
  (0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.sandbox_run_end", message: "finished a sandboxed eval run", meta: { caseId: input.case.id, runId, outcome: observation.outcome } });
284
- return { ...observation, gaps: [...gaps, ...declared_gaps_1.DECLARED_GAPS] };
301
+ return { ...observation, gaps: [...gaps, ...(input.guest ? [] : declared_gaps_1.DECLARED_GAPS)], ...(input.guest ? { followUps } : {}) };
285
302
  }
286
303
  catch (error) {
287
304
  (0, runtime_1.emitNervesEvent)({ component: "eval", level: "error", event: "eval.sandbox_run_error", message: "a sandboxed eval run failed", meta: { caseId: input.case.id, runId, error: error.message } });
@@ -56,7 +56,7 @@ function isObservation(value) {
56
56
  /** This side: each run starts the remote process, sends the job, serves the model and waits for the observation. */
57
57
  function remoteRunCase(options) {
58
58
  const timeoutMs = options.timeoutMs ?? 900_000;
59
- return async ({ case: c, host, budget }) => {
59
+ return async ({ case: c, host, budget, guest }) => {
60
60
  (0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.remote_run_start", message: "starting a run on the remote sandbox host", meta: { caseId: c.id } });
61
61
  const remote = options.start();
62
62
  const channel = (0, provider_proxy_1.createStreamChannel)(remote.stdout, remote.stdin);
@@ -68,7 +68,7 @@ function remoteRunCase(options) {
68
68
  resolve(msg.outcome);
69
69
  } });
70
70
  void remote.exited.then((code) => { clearTimeout(timer); resolve({ ok: false, error: `the remote process exited (${code}) before the run finished: ${remote.stderr().trim()}` }); });
71
- channel.send({ type: "job", job: { case: c, ...options.paths } });
71
+ channel.send({ type: "job", job: { case: c, ...options.paths, ...(guest ? { guest } : {}) } });
72
72
  });
73
73
  if (!outcome.ok) {
74
74
  (0, runtime_1.emitNervesEvent)({ component: "eval", level: "error", event: "eval.remote_run_error", message: "the remote sandbox run failed", meta: { caseId: c.id, error: outcome.error } });
@@ -96,6 +96,7 @@ const machine_identity_1 = require("../machine-identity");
96
96
  const bluebubbles_host_1 = require("./bluebubbles-host");
97
97
  const provider_models_1 = require("../provider-models");
98
98
  const ouro_version_manager_1 = require("../versioning/ouro-version-manager");
99
+ const self_update_1 = require("../versioning/self-update");
99
100
  const update_checker_1 = require("../versioning/update-checker");
100
101
  const sync_1 = require("../sync");
101
102
  const core_1 = require("../../mailroom/core");
@@ -241,6 +242,12 @@ function isRsvpCliCommand(command) {
241
242
  }
242
243
  function summarizeCliUpdateCheckStatus(error, timedOut = false) {
243
244
  const normalized = error.trim().toLowerCase();
245
+ if (normalized.startsWith("could not install ")) {
246
+ const firstLine = error.trim().split("\n")[0];
247
+ return (0, self_update_1.isTarballNotServedYet)(error)
248
+ ? `skipped; ${firstLine.replace(/:.*$/, "")}: npm lists it but is not serving it yet, so the next run tries again`
249
+ : `skipped; ${firstLine.slice(0, 160)}`;
250
+ }
244
251
  if (timedOut || normalized.includes("timed out") || normalized.includes("abort")) {
245
252
  return "skipped; registry did not answer";
246
253
  }
@@ -7347,7 +7354,13 @@ async function runOuroCli(args, deps = (0, cli_defaults_1.createDefaultOuroCliDe
7347
7354
  });
7348
7355
  }
7349
7356
  if (needsActivation) {
7350
- await deps.installCliVersion(targetVersion);
7357
+ try {
7358
+ await deps.installCliVersion(targetVersion);
7359
+ }
7360
+ catch (installError) {
7361
+ const said = installError instanceof Error ? installError.message : String(installError);
7362
+ throw new Error(`could not install ${targetVersion}: ${said}`);
7363
+ }
7351
7364
  const validation = deps.validateCliVersionForActivation?.(targetVersion);
7352
7365
  if (validation && !validation.ok) {
7353
7366
  throw new Error(`refusing to activate ${targetVersion}: ${validation.message}`);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RESTART_MEMORY_HEADROOM_BYTES = exports.PIN_MAX_AGE_MS = void 0;
4
+ exports.isTarballNotServedYet = isTarballNotServedYet;
4
5
  exports.runSelfUpdate = runSelfUpdate;
5
6
  const runtime_1 = require("../../nerves/runtime");
6
7
  const ouro_version_manager_1 = require("./ouro-version-manager");
@@ -36,6 +37,10 @@ const RESTART_MEMORY_POLL_MS = 10_000;
36
37
  function errorText(error) {
37
38
  return error instanceof Error ? error.message : String(error);
38
39
  }
40
+ /** npm lists a version before it serves its tarball: ETARGET, or a 404 on that tarball's URL. */
41
+ function isTarballNotServedYet(text) {
42
+ return /\bETARGET\b/.test(text) || (/\bE404\b/.test(text) && /\.tgz\b/.test(text));
43
+ }
39
44
  const FAILURE_OUTCOMES = ["unreachable", "install-failed", "rejected", "rolled-back"];
40
45
  async function runSelfUpdate(deps) {
41
46
  const release = deps.acquireLock();
@@ -212,7 +217,15 @@ async function runLocked(deps) {
212
217
  installSource = await deps.install(latest, lookup);
213
218
  }
214
219
  catch (error) {
215
- return finish("install-failed", { summary: errorText(error), latestVersion: latest });
220
+ const said = errorText(error);
221
+ if (isTarballNotServedYet(said)) {
222
+ return finish("deferred", {
223
+ summary: `${latest} is listed but its tarball is not served yet; staying on ${currentVersion} and trying again next pass`,
224
+ detail: said,
225
+ latestVersion: latest,
226
+ });
227
+ }
228
+ return finish("install-failed", { summary: said, latestVersion: latest });
216
229
  }
217
230
  const validation = deps.validate(latest);
218
231
  const smoke = validation.ok ? await deps.smokeTest(latest) : { ok: false, detail: validation.message };
@@ -119,7 +119,7 @@ function formatUpdateStatusLine(state, options) {
119
119
  line = `Updates: pinned to ${version} (checked ${age}; ${state.detail ?? "pin honored"})`;
120
120
  break;
121
121
  case "deferred":
122
- line = `Updates: ${state.latestVersion ?? "a new version"} waits for memory, staying on ${version} (checked ${age}; ${state.detail ?? "deferred"})`;
122
+ line = `Updates: ${state.latestVersion ?? "a new version"} waits, staying on ${version} (checked ${age}; ${state.detail ?? "deferred"})`;
123
123
  break;
124
124
  default:
125
125
  line = `Updates: needs attention: ${state.outcome} ${age} on ${version}${state.latestVersion ? ` (latest ${state.latestVersion})` : ""}: ${state.detail ?? "no detail"}`;
@@ -180,6 +180,9 @@ const DISPATCH_EXEMPT_PATTERNS = [
180
180
  // The CLI's entry point only picks a module: the per-tool hook (which emits daemon.hook_post_tool_use) or the CLI
181
181
  // (ouro-cli-main.ts, which emits the entry's start events). It stays this small so the hook loads nothing else.
182
182
  "heart/daemon/ouro-entry.ts",
183
+ // Ouro AX v1.3.445's ax files, vendored unchanged for the blind interviews' `ouro` X arm; the arm that loads them
184
+ // (eval/interviews/guest/arms.ts) emits its own events.
185
+ "eval/interviews/guest/ax/",
183
186
  ];
184
187
  function isDispatchExempt(filePath) {
185
188
  return DISPATCH_EXEMPT_PATTERNS.some((pattern) => filePath.includes(pattern));
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1430",
3
+ "version": "0.1.0-alpha.1432",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@ouro.bot/cli",
9
- "version": "0.1.0-alpha.1430",
9
+ "version": "0.1.0-alpha.1432",
10
10
  "bundleDependencies": [
11
11
  "@ouro.bot/friends"
12
12
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1430",
3
+ "version": "0.1.0-alpha.1432",
4
4
  "description": "Ouroboros, the agent harness: agents with durable memory that live where you talk (terminal, Teams, iMessage, mail, voice) and use real tools. Start with npx ouro.bot@latest.",
5
5
  "homepage": "https://ouroboros.bot/",
6
6
  "engines": {