@ouro.bot/cli 0.1.0-alpha.1477 → 0.1.0-alpha.1479

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.
package/changelog.json CHANGED
@@ -1,6 +1,18 @@
1
1
  {
2
2
  "_note": "Each pull request writes its own change note under changes/; the release job on main gives each landed change its version and adds the notes here (scripts/release-version.cjs). On main this file stops at the last version set by hand; the published package has every release. Agents read this file directly via read_file to understand what changed between versions.",
3
3
  "versions": [
4
+ {
5
+ "version": "0.1.0-alpha.1479",
6
+ "changes": [
7
+ "The blind-interview runner has optional hooks for products that aren't scored on the books household, so the component-kit product and the harness product can plug in without changing the runner again:",
8
+ "A product kit can supply its own job (`job`), its own verdict on a run (`grade`) and its own fidelity notes (`fidelity`).",
9
+ "A tool answer can end the user turn (`ends`), as a `finish` tool does, without an extra model call.",
10
+ "The guest picks each product's arms from a map of builders.",
11
+ "A guest's own grade comes back through the sandbox unchanged.",
12
+ "X works as before, and a regression test checks that.",
13
+ "Token usage now keeps the cached input tokens that a provider reports, as `cached_input_tokens`, from chat completions (`prompt_tokens_details.cached_tokens`) and from the Responses API (`input_tokens_details.cached_tokens`). It's left out when the provider doesn't report a number. Cached tokens are billed at a lower price, so an eval's report now has what it needs to price each call exactly. The eval's own budget still prices every input token at the full rate, which overstates cached calls."
14
+ ]
15
+ },
4
16
  {
5
17
  "version": "0.1.0-alpha.1477",
6
18
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1477",
2
+ "runtimeVersion": "0.1.0-alpha.1479",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0"?>
2
2
  <Container version="2">
3
3
  <Name>ouro-butler</Name>
4
- <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1477</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1479</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -57,12 +57,15 @@ async function runConversation(input) {
57
57
  timeline.push({ kind: "reply", text: content });
58
58
  break;
59
59
  }
60
+ let ended = null;
60
61
  for (const call of result.toolCalls) {
61
62
  let answer;
62
63
  try {
63
64
  const reply = await input.arm.call(call.name, call.arguments);
64
65
  // A failed call is marked the same way in every arm, as an MCP client shows `isError`.
65
66
  answer = scrub(reply.isError ? `Error: ${reply.text}` : reply.text);
67
+ if (reply.ends && !reply.isError && ended === null)
68
+ ended = answer;
66
69
  }
67
70
  catch (error) {
68
71
  answer = scrub(`error: ${messageOf(error)}`);
@@ -71,6 +74,12 @@ async function runConversation(input) {
71
74
  messages.push({ role: "tool", tool_call_id: call.id, content: answer });
72
75
  input.runtime.appendToolOutput(call.id, answer);
73
76
  }
77
+ // A call that ends the turn (a `finish` tool) ends it here, with no further model call; every call in the same
78
+ // answer has run and has its result, so a later turn follows a complete exchange.
79
+ if (ended !== null) {
80
+ turn.finalReply = ended;
81
+ break;
82
+ }
74
83
  }
75
84
  }
76
85
  (0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.interview_conversation_end", message: "finished a neutral-loop conversation", meta: { arm: input.arm.key, turns: turns.length } });
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PERSONA_FILES = void 0;
6
+ exports.ARM_BUILDERS = exports.PERSONA_FILES = void 0;
7
7
  exports.personaPrompt = personaPrompt;
8
8
  exports.runInterviewGuest = runInterviewGuest;
9
9
  /**
@@ -38,18 +38,35 @@ function readTurnFile(file) {
38
38
  }
39
39
  return value;
40
40
  }
41
+ /** Each product's arm builder in the guest; a product without one is refused. */
42
+ exports.ARM_BUILDERS = {
43
+ X: (arm, context) => (0, arms_1.buildArm)(arm, context.core ?? (0, books_core_1.booksCore)({ home: node_path_1.default.join(context.bundle, "books") })),
44
+ };
41
45
  async function runInterviewGuest(input) {
42
46
  (0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.interview_guest_start", message: "interview guest starting a conversation", meta: {} });
43
47
  const channel = (0, provider_proxy_1.createStreamChannel)(input.stdin, input.stdout);
44
48
  let outcome;
45
49
  try {
46
50
  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") }));
51
+ const builders = input.builders ?? exports.ARM_BUILDERS;
52
+ const builder = Object.hasOwn(builders, turn.product) ? builders[turn.product] : undefined;
53
+ if (!builder)
54
+ throw new Error(`no arms for product ${turn.product} in the guest`);
55
+ const arm = builder(turn.arm, { bundle: input.bundle, ...(input.core ? { core: input.core } : {}) });
48
56
  const runtime = await (0, provider_proxy_1.createProxyRuntime)(channel);
49
57
  const system = `${personaPrompt(input.bundle)}\n\n${turn.labelLine}`;
50
58
  const conversation = await (0, loop_1.runConversation)({ runtime, product: turn.product, system, prefix: turn.prefix, userTexts: [turn.userText, ...turn.followUps], arm });
51
59
  const job = conversation.turns[0];
52
- outcome = { ok: true, result: { timeline: conversation.timeline, finalReply: job.finalReply, outcome: job.outcome, turns: conversation.turns } };
60
+ // A product graded in the container grades once the whole conversation (the job and its debrief) has ended.
61
+ // A grader that fails is the job's failure, reported as the grade, not the loss of the conversation.
62
+ let grade;
63
+ try {
64
+ grade = arm.grade ? await arm.grade() : undefined;
65
+ }
66
+ catch (error) {
67
+ grade = { error: (0, loop_1.messageOf)(error) };
68
+ }
69
+ outcome = { ok: true, result: { timeline: conversation.timeline, finalReply: job.finalReply, outcome: job.outcome, turns: conversation.turns, ...(grade !== undefined ? { grade } : {}) } };
53
70
  (0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.interview_guest_end", message: "interview guest finished its conversation", meta: { turns: conversation.turns.length } });
54
71
  }
55
72
  catch (error) {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KNOWN_ARMS = exports.X_KIT = exports.NO_BOOKS = exports.NO_OPERATION = exports.FIDELITY = void 0;
4
4
  exports.canonicalX = canonicalX;
5
+ exports.fidelityOf = fidelityOf;
5
6
  exports.summarizeSessions = summarizeSessions;
6
7
  exports.runInterviews = runInterviews;
7
8
  exports.parseInterviewArgs = parseInterviewArgs;
@@ -72,11 +73,14 @@ const ZERO = { premium: 0, credits: 0 };
72
73
  const named = (hits) => [...new Set(hits.map((hit) => hit.toLowerCase()))].join(", ");
73
74
  const providerFailure = (outcome) => /^(provider-error|sandbox-error|trace-mismatch)/.test(outcome);
74
75
  function armRecord(input) {
75
- const { gaps: _gaps, followUps, ...raw } = input.obs;
76
+ const { gaps: _gaps, followUps, grade: _grade, ...raw } = input.obs;
76
77
  const observation = input.kit.canonical(input.arm.arm, raw);
77
- const graded = (0, assertions_1.evaluate)(input.c, observation);
78
+ const own = input.kit.grade ? ownGrade(input.kit.grade, input.obs, input.c) : undefined;
79
+ const graded = own ?? (0, assertions_1.evaluate)(input.c, observation);
78
80
  const refused = input.job.refused();
79
- const verdict = refused ? { passed: false, reason: `refused: ${refused}` } : (0, report_1.gradeRun)(observation, graded);
81
+ // A kit's verdict decides only a job whose conversation settled, as gradeRun does for a case.
82
+ const verdict = refused ? { passed: false, reason: `refused: ${refused}` } : !own ? (0, report_1.gradeRun)(observation, graded)
83
+ : observation.outcome !== "settled" ? { passed: false, reason: `outcome ${observation.outcome}` } : { passed: own.passed, reason: own.reason };
80
84
  const debrief = followUps?.[0];
81
85
  const note = debrief && debrief.outcome === "settled" ? debrief.finalReply : "";
82
86
  return {
@@ -85,6 +89,31 @@ function armRecord(input) {
85
89
  jobCalls: input.job.calls(), debriefCalls: input.debrief.calls(), observation,
86
90
  };
87
91
  }
92
+ /** A kit's verdict, or a failed one when it throws: the guest's grade is untrusted input. */
93
+ function ownGrade(grade, run, c) {
94
+ try {
95
+ return grade(run, c);
96
+ }
97
+ catch (error) {
98
+ return { passed: false, reason: `grade: ${(0, loop_1.messageOf)(error)}`, checks: [] };
99
+ }
100
+ }
101
+ /** The report's fidelity notes: X's, and those of each product kit with a session in this run. A kit may not restate one. */
102
+ function fidelityOf(kits, sessions) {
103
+ const out = { ...exports.FIDELITY };
104
+ for (const product of new Set(sessions.map((session) => session.product))) {
105
+ for (const [key, notes] of Object.entries(kits[product]?.fidelity ?? {})) {
106
+ if (Object.hasOwn(out, key))
107
+ throw new Error(`product ${product}'s kit restates the fidelity notes for ${key}`);
108
+ out[key] = notes;
109
+ }
110
+ }
111
+ return out;
112
+ }
113
+ /** A session's job: the product's own, or the case of that name in `--cases`. */
114
+ function caseOf(kit, cases, session) {
115
+ return kit.job?.(session.job) ?? cases.get(session.job);
116
+ }
88
117
  /** Runs one session. Returns its record; `stop` when the study must stop (402, 429 or a cap). */
89
118
  async function runSession(input) {
90
119
  const { session, latch } = input;
@@ -93,7 +122,7 @@ async function runSession(input) {
93
122
  labels: Object.fromEntries(session.arms.map((arm) => [arm.label, arm.arm])), status: "complete", ended: null, arms: [], final: null,
94
123
  ouroFirst: false, voidedBy: null, calls: [], spent: ZERO,
95
124
  };
96
- const c = input.cases.get(session.job);
125
+ const c = caseOf(input.kit, input.cases, session);
97
126
  const guard = (gateFor) => (0, latch_1.guardedRuntime)({
98
127
  inner: input.target.runtime, latch, ledger: input.ledger, pricing: input.pricing, gateFor,
99
128
  log: (entry) => input.log(JSON.stringify({ session: session.id, preregistrationVersion: input.version, ...entry })),
@@ -190,8 +219,9 @@ async function runInterviews(args, deps) {
190
219
  const missingKit = chosen.find((session) => !deps.kits[session.product]);
191
220
  if (missingKit)
192
221
  throw new Error(`session ${missingKit.id} is product ${missingKit.product}, which has no runner kit yet`);
222
+ const fidelity = fidelityOf(deps.kits, chosen);
193
223
  const cases = new Map(deps.loadCases(args.cases).map((c) => [c.id, c]));
194
- const missingCase = chosen.find((session) => !cases.has(session.job));
224
+ const missingCase = chosen.find((session) => !caseOf(deps.kits[session.product], cases, session));
195
225
  if (missingCase)
196
226
  throw new Error(`session ${missingCase.id} needs case ${missingCase.job}, which is not in ${args.cases}`);
197
227
  for (const file of [args.output, args.requestLog])
@@ -224,7 +254,7 @@ async function runInterviews(args, deps) {
224
254
  deps.writeReport(args.output, {
225
255
  schemaVersion: 1, kind: "blind-interviews", preregistrationVersion: version, target: args.target, harnessRef: args.harnessRef, reduced: args.reduced, account: target.account,
226
256
  premiumMultiplier: target.unitCost, multiplierSource: target.multiplierSource, caps: totals.caps, spent: totals.spent, calls: totals.calls, stopped, quota: { before, after: after ?? before },
227
- fidelity: exports.FIDELITY, pricing, sessions: records,
257
+ fidelity, pricing, sessions: records,
228
258
  });
229
259
  };
230
260
  let after = null;
@@ -175,7 +175,10 @@ function guestTurn(outcome) {
175
175
  if (!result || !Array.isArray(result.timeline) || typeof result.finalReply !== "string" || typeof result.outcome !== "string" || (result.turns !== undefined && !isTurns(result.turns))) {
176
176
  return { timeline: [], finalReply: "", outcome: "sandbox-error: the guest's result is malformed" };
177
177
  }
178
- return { timeline: result.timeline, finalReply: result.finalReply, outcome: result.outcome, ...(result.turns ? { turns: result.turns } : {}) };
178
+ return {
179
+ timeline: result.timeline, finalReply: result.finalReply, outcome: result.outcome, ...(result.turns ? { turns: result.turns } : {}),
180
+ ...(result.grade !== undefined ? { grade: result.grade } : {}),
181
+ };
179
182
  }
180
183
  /** The job's part of a merged timeline and the later turns, by where the guest said each turn starts. */
181
184
  function splitTurns(observation, turns) {
@@ -315,7 +318,11 @@ async function runSandboxed(input) {
315
318
  });
316
319
  const { observation, followUps } = splitTurns(assembled, turn.turns);
317
320
  (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 } });
318
- return { ...observation, gaps: [...gaps, ...(input.guest ? [] : declared_gaps_1.DECLARED_GAPS)], ...(input.guest ? { followUps } : {}) };
321
+ // A guest's own grade (a product scored in the container) goes back as it came, only from a turn read back whole.
322
+ return {
323
+ ...observation, gaps: [...gaps, ...(input.guest ? [] : declared_gaps_1.DECLARED_GAPS)], ...(input.guest ? { followUps } : {}),
324
+ ...(input.guest && turn.grade !== undefined ? { grade: turn.grade } : {}),
325
+ };
319
326
  }
320
327
  catch (error) {
321
328
  (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 } });
@@ -661,8 +661,11 @@ async function streamChatCompletion(client, createParams, callbacks, signal, eag
661
661
  // Capture usage from final chunk (sent when stream_options.include_usage is true)
662
662
  if (chunk.usage) {
663
663
  const u = chunk.usage;
664
+ const cached = u.prompt_tokens_details?.cached_tokens;
664
665
  usage = {
665
666
  input_tokens: u.prompt_tokens,
667
+ // Some OpenAI-compatible gateways send null; only a number is a reported count.
668
+ ...(typeof cached === "number" ? { cached_input_tokens: cached } : {}),
666
669
  output_tokens: u.completion_tokens,
667
670
  reasoning_tokens: u.completion_tokens_details?.reasoning_tokens ?? 0,
668
671
  total_tokens: u.total_tokens,
@@ -869,8 +872,10 @@ async function streamResponsesApi(client, createParams, callbacks, signal, eager
869
872
  incomplete = true;
870
873
  const u = event.response?.usage;
871
874
  if (u) {
875
+ const cached = u.input_tokens_details?.cached_tokens;
872
876
  usage = {
873
877
  input_tokens: u.input_tokens,
878
+ ...(typeof cached === "number" ? { cached_input_tokens: cached } : {}),
874
879
  output_tokens: u.output_tokens,
875
880
  reasoning_tokens: u.output_tokens_details?.reasoning_tokens ?? 0,
876
881
  total_tokens: u.total_tokens,
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1477",
3
+ "version": "0.1.0-alpha.1479",
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.1477",
9
+ "version": "0.1.0-alpha.1479",
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.1477",
3
+ "version": "0.1.0-alpha.1479",
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": {