@ouro.bot/cli 0.1.0-alpha.1509 → 0.1.0-alpha.1510

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,14 @@
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.1510",
6
+ "changes": [
7
+ "Interviews: the brand scan, the grader's leak check and the replacement lists leave a provider's encrypted reasoning as it is: each `encrypted_content` string, and a reasoning item's `id`, which Copilot also returns as opaque base64. The scan can't read these strings, whose letters can spell a brand word by chance (that voided the 2026-11-23 H pilot), and rewriting them would corrupt them.",
8
+ "Interviews: in any other id (a call's, an item's or a response's), a brand word counts only as a whole segment between the value's start or end and `_`, `-`, `.`, `:` or `/`. So a random \"call_abGPTx9\" passes, while \"ouro_call_3\" and \"gpt-5\" still void. Readable fields, reasoning summaries included, keep the whole pattern.",
9
+ "Interviews: the H wire sends codex's reasoning items back to the model unchanged and each in its place, as real codex does and as the ouro arm keeps its own, instead of dropping them."
10
+ ]
11
+ },
4
12
  {
5
13
  "version": "0.1.0-alpha.1509",
6
14
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1509",
2
+ "runtimeVersion": "0.1.0-alpha.1510",
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.1509</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1510</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -13,7 +13,8 @@ exports.readRequestLog = readRequestLog;
13
13
  * runner's private reports and request logs and Appendix B. It runs no model and sends nothing. Its result is counts
14
14
  * and labels only (no trace text, notes or reasons), so it can be committed as the study's result.
15
15
  *
16
- * Section 3: no leak (the brand pattern over every logged request body, zero matches outside void sessions); no
16
+ * Section 3: no leak (the brand pattern over every logged request body, its provider ciphertext left out as the latch's
17
+ * scan leaves it out, zero matches outside void sessions); no
17
18
  * identification (a session is broken when Q4 names the `ouro` label with a product matching /ouro/i); a valid count
18
19
  * (at most 3 of 18 broken, or 1 of 9 in the reduced design). Section 6: k of n sessions with `ouro` first, where every
19
20
  * session of the design counts and one that is void, crashed, missing or not run counts as `ouro` not first; the three
@@ -36,6 +37,18 @@ function bars(reduced) {
36
37
  return reduced ? { n: 9, k: 7, broken: 1 } : { n: 18, k: 11, broken: 3 };
37
38
  }
38
39
  const brand = () => new RegExp(protocol_1.BRAND_PATTERN, "gi");
40
+ /** A logged body as the latch's scan read it: the provider's ciphertext left out of a JSON body; any other text as it is. */
41
+ function readable(body) {
42
+ let value;
43
+ try {
44
+ value = JSON.parse(body);
45
+ }
46
+ catch {
47
+ return body;
48
+ }
49
+ return (0, protocol_1.scannedText)(value);
50
+ }
51
+ const brandMatches = (body) => (readable(body).match(brand()) ?? []).length;
39
52
  /** Q4's guess for `label`, whether the model keyed it `K`, ` k ` or `tool interface K`. */
40
53
  function guessFor(guesses, label) {
41
54
  const want = label.toLowerCase();
@@ -77,10 +90,10 @@ function gradeStudy(input) {
77
90
  throw new Error(`session ${session.id}'s report gives labels other than Appendix B's`);
78
91
  }
79
92
  const voids = new Set(input.records.filter((record) => record.status === "void").map((record) => record.id));
80
- const leaking = input.requests.filter((request) => request.sent && (request.body.match(brand()) ?? []).length > 0);
93
+ const leaking = input.requests.filter((request) => request.sent && brandMatches(request.body) > 0);
81
94
  const leak = {
82
95
  requests: input.requests.length,
83
- matches: input.requests.reduce((sum, request) => sum + (request.body.match(brand()) ?? []).length, 0),
96
+ matches: input.requests.reduce((sum, request) => sum + brandMatches(request.body), 0),
84
97
  outsideVoid: leaking.filter((request) => !voids.has(request.session)).length,
85
98
  sessions: [...new Set(leaking.map((request) => request.session))],
86
99
  };
@@ -14,6 +14,7 @@ exports.H_OURO_FIDELITY = [
14
14
  "every arm's list rewrites the container's user name (ouro) and real paths in what the model sees, tool results included, so a rewritten name that is no path (the user agent, AGENT_HOME, ~/.agent) finds nothing when the model types it, nor does an id or file name with a brand word inside it; model names are in no list, so the host's scan voids a session that shows one",
15
15
  "the neutral home is a real folder under /tmp in every arm, with the bundle linked at /tmp/agent/AgentBundles/sanctuary.agent; in the ouro arm, the real home's entries are linked into it when the arm starts, and one the turn makes later is not",
16
16
  "skills aren't listed in the prompt: a skill reaches the model only when the agent reads its file, while the other arms list each skill's name and when-line",
17
+ "in every arm, the host's brand scan, the leak check and the replacement lists leave a provider's encrypted reasoning (each encrypted_content string, and a reasoning item's id, which Copilot also returns as opaque base64) as it is, since the scan can't read ciphertext and changing it would corrupt it; the provider decrypts it for the model, so a brand word in that reasoning goes unchecked, while its summary and every other field are scanned and rewritten; in an id (a call's, an item's or a response's), a brand word counts only as a whole segment, between the value's ends or _ - . : /, since most ids are random letters; a digit or a capital letter does not split a segment, so an arm's own id such as gpt4o_1 would pass, and no arm builds ids that way",
17
18
  ];
18
19
  exports.H_CODEX_FIDELITY = [
19
20
  "request_max_retries, stream_max_retries and unbounded_connection_retries are off: a retry would be a second metered call, and the H wire answers every failure with a 400 codex never retries",
@@ -26,6 +27,7 @@ exports.H_CODEX_FIDELITY = [
26
27
  "bundled skills are off ([skills.bundled] enabled = false): they are about codex itself, not the household",
27
28
  "analytics, the otel exporters (exporter, trace_exporter and metrics_exporter) and check_for_update_on_startup are off: the sandbox has no route off the host; the model sees no difference",
28
29
  "the request's own settings (tool_choice, parallel_tool_calls, reasoning, include, store, prompt_cache_key and the like) are not passed on: the host's runtime sets the model's settings, as it does for the ouro arm",
30
+ "on a Responses API target (Copilot), codex's reasoning items go back to the model between calls as codex sends them, ciphertext included and each in its place, as the ouro arm's own reasoning does; a chat-completions target (MiniMax) returns none, in every arm",
29
31
  "codex's leading developer messages become one system message, joined with a blank line, and a message's text parts are joined with a newline, since the harness's messages carry one string each",
30
32
  "codex doesn't know the model's name, so it runs as for any unknown model: its generic base prompt, no apply_patch tool, and output of each tool call cut at 10,000 bytes",
31
33
  "codex's base prompt is rewritten before the call reaches the model: its first sentences say a coding agent running in a terminal-based coding assistant, and the line on what Codex refers to is removed",
@@ -40,6 +42,7 @@ exports.H_OPENHANDS_FIDELITY = [
40
42
  "the agent's tools are the terminal and the file editor, as pre-registration v2 names, plus the SDK's own finish tool and, when a skill is installed, its invoke_skill tool; the SDK's default preset also gives the task tracker and the browser, and the browser couldn't reach anything in the sandbox",
41
43
  "no condenser: the default preset summarises a long history with extra model calls; these conversations are short",
42
44
  "load_user_skills = True: the bundle's skills are installed as user skills and listed in the prompt's skills block, as codex lists them; the default preset loads none",
45
+ "the model's reasoning is not sent back between calls: the H wire's chat answer carries none, while on a Responses API target (Copilot) the ouro and codex arms send theirs back",
43
46
  "the model is called through chat completions without streaming (api_mode chat, stream False), since the H wire answers chat only whole",
44
47
  "the request's own settings (max_completion_tokens, prompt_cache_key) are not passed on: the host's runtime sets the model's settings, as it does for the ouro arm",
45
48
  "the SDK doesn't know the model's name (openai/model), so it uses its defaults for an unknown model; LITELLM_LOCAL_MODEL_COST_MAP = True makes LiteLLM read the cost map it ships with instead of fetching one",
@@ -112,7 +112,11 @@ const RESPONSES_FIELDS = new Set([
112
112
  /**
113
113
  * A Responses body as the harness's request. The harness's instructions (its leading developer and system messages)
114
114
  * become the one system message; the case's conversation goes before the first user message; a call joins the
115
- * assistant message before it, and each output becomes its tool result. Reasoning items are not sent back.
115
+ * assistant message before it, and each output becomes its tool result. Reasoning items go back as real codex sends
116
+ * them: each one, unchanged and ciphertext included, rides on the assistant output after it as `_reasoning_items`,
117
+ * which the host's Responses path puts back into the input before that message's text and calls (as for the ouro
118
+ * arm's own turn), so every item keeps its place. Reasoning with no assistant output after it rides on an assistant
119
+ * message with no text. On a chat-completions target the provider returns no reasoning, so there is none to send back.
116
120
  */
117
121
  function responsesRequest(body, prefix) {
118
122
  if (!isRecord(body) || !Array.isArray(body.input))
@@ -127,11 +131,25 @@ function responsesRequest(body, prefix) {
127
131
  const leading = [];
128
132
  const rest = [];
129
133
  let prefixed = false;
134
+ let reasoning = [];
135
+ /** The reasoning items waiting for the assistant output after them, taken once. */
136
+ const takeReasoning = () => {
137
+ const taken = reasoning;
138
+ reasoning = [];
139
+ return taken.length > 0 ? { _reasoning_items: taken } : {};
140
+ };
130
141
  for (const item of body.input) {
131
142
  const type = typeOf(item);
132
143
  const value = item;
133
- if (type === "reasoning")
144
+ if (type === "reasoning") {
145
+ reasoning.push(item);
134
146
  continue;
147
+ }
148
+ // Reasoning with no assistant output after it (a turn that produced only reasoning) goes on an assistant message
149
+ // of its own, as the harness keeps such a turn, so it is sent back in its place.
150
+ const assistantOutput = type === "function_call" || (type === "message" && value.role === "assistant");
151
+ if (reasoning.length > 0 && !assistantOutput)
152
+ rest.push({ role: "assistant", content: null, ...takeReasoning() });
135
153
  if (Object.hasOwn(ITEM_FIELDS, type))
136
154
  checkFields(type, value, ITEM_FIELDS[type]);
137
155
  if (type === "message") {
@@ -150,7 +168,7 @@ function responsesRequest(body, prefix) {
150
168
  rest.push({ role: "user", content: text });
151
169
  }
152
170
  else if (role === "assistant") {
153
- rest.push({ role: "assistant", content: text });
171
+ rest.push({ role: "assistant", content: text, ...takeReasoning() });
154
172
  }
155
173
  else {
156
174
  throw new Error(`the H wire can't carry a message from ${role}`);
@@ -159,11 +177,14 @@ function responsesRequest(body, prefix) {
159
177
  else if (type === "function_call") {
160
178
  const call = { id: stringField(type, value, "call_id"), type: "function", function: { name: stringField(type, value, "name"), arguments: stringField(type, value, "arguments") } };
161
179
  const last = rest[rest.length - 1];
162
- if (last?.role === "assistant") {
180
+ // A call joins the assistant message before it, unless reasoning came between them: the host's Responses path
181
+ // puts a message's reasoning before its text and calls, so that reasoning opens a message of its own and keeps
182
+ // its place.
183
+ if (last?.role === "assistant" && reasoning.length === 0) {
163
184
  last.tool_calls = [...last.tool_calls ?? [], call];
164
185
  }
165
186
  else {
166
- rest.push({ role: "assistant", content: null, tool_calls: [call] });
187
+ rest.push({ role: "assistant", content: null, ...takeReasoning(), tool_calls: [call] });
167
188
  }
168
189
  }
169
190
  else if (type === "function_call_output") {
@@ -173,6 +194,8 @@ function responsesRequest(body, prefix) {
173
194
  throw new Error(`the H wire can't carry an input item of type ${type}`);
174
195
  }
175
196
  }
197
+ if (reasoning.length > 0)
198
+ rest.push({ role: "assistant", content: null, ...takeReasoning() });
176
199
  const tools = (body.tools ?? []);
177
200
  for (const tool of tools) {
178
201
  if (typeOf(tool) !== "function")
@@ -255,11 +278,17 @@ function chatAnswer(result, id) {
255
278
  },
256
279
  };
257
280
  }
258
- /** The events a Responses client reads for one answer: created, each output item done, then completed with usage. */
281
+ /**
282
+ * The events a Responses client reads for one answer: created, each output item done, then completed with usage. The
283
+ * model's reasoning items come first, exactly as the provider returned them, so codex keeps them and sends them back
284
+ * on its next request; the provider's other output items are the reply and calls the events already carry.
285
+ */
259
286
  function responsesEvents(result, id) {
260
287
  const usage = result.usage;
288
+ const reasoning = result.outputItems.filter((item) => typeOf(item) === "reasoning");
261
289
  return [
262
290
  { type: "response.created", response: { id } },
291
+ ...reasoning.map((item) => ({ type: "response.output_item.done", item })),
263
292
  ...(result.content ? [{ type: "response.output_item.done", item: { type: "message", role: "assistant", id: `${id}_msg`, content: [{ type: "output_text", text: result.content }] } }] : []),
264
293
  ...result.toolCalls.map((call, index) => ({ type: "response.output_item.done", item: { type: "function_call", id: `${id}_fc_${index}`, call_id: call.id, name: call.name, arguments: call.arguments } })),
265
294
  { type: "response.completed", response: { id, usage: {
@@ -77,10 +77,13 @@ exports.RefusedCall = RefusedCall;
77
77
  * some providers send as metadata. The rest (reasoning effort, tool choice) are the provider's own fixed words.
78
78
  */
79
79
  function requestText(request) {
80
- return JSON.stringify({
80
+ return JSON.stringify(requestFields(request));
81
+ }
82
+ function requestFields(request) {
83
+ return {
81
84
  systemPrompt: request.systemPrompt ?? null, tools: request.activeTools, deferred: request.deferredTools ?? [], messages: request.messages,
82
85
  ...(request.traceId !== undefined ? { traceId: request.traceId } : {}),
83
- });
86
+ };
84
87
  }
85
88
  /**
86
89
  * The runtime one conversation's calls go through: scan, then the conversation's gate (`gateFor`, which may tell a job
@@ -94,12 +97,14 @@ function guardedRuntime(input) {
94
97
  const gate = input.gateFor(own);
95
98
  const rewritten = input.replacements ? (0, rewrite_1.rewriteRequest)(own, input.replacements) : undefined;
96
99
  const request = rewritten?.request ?? own;
97
- const body = requestText(request);
100
+ const fields = requestFields(request);
101
+ const body = JSON.stringify(fields);
98
102
  const counted = rewritten ? { rewrites: rewritten.rewrites } : {};
99
103
  if (rewritten && input.rewrites)
100
104
  for (const [tier, n] of Object.entries(rewritten.rewrites))
101
105
  input.rewrites[tier] = (input.rewrites[tier] ?? 0) + n;
102
- const hits = (0, protocol_1.brandHits)(body);
106
+ // The log keeps the whole body; the scan reads it with the provider's ciphertext left out (`scannedText`).
107
+ const hits = (0, protocol_1.brandHits)((0, protocol_1.scannedText)(fields));
103
108
  if (hits.length > 0) {
104
109
  latch._void(hits);
105
110
  input.log({ kind: gate.kind, sent: false, body, ...counted });
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
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;
3
+ exports.ID_FIELDS = exports.OPAQUE_FIELDS = 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
4
  exports.labelLine = labelLine;
5
5
  exports.debriefQuestion = debriefQuestion;
6
6
  exports.choiceQuestion = choiceQuestion;
7
7
  exports.ratingOf = ratingOf;
8
8
  exports.brandHits = brandHits;
9
+ exports.isOpaque = isOpaque;
10
+ exports.scannedText = scannedText;
9
11
  exports.scrubBrands = scrubBrands;
10
12
  /**
11
13
  * The blind interviews' fixed words, from the pre-registration (section 3 and section 4): the label line each job's
@@ -71,6 +73,47 @@ function brandHits(text) {
71
73
  (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
74
  return hits;
73
75
  }
76
+ /**
77
+ * Fields whose string value is a provider's ciphertext: `encrypted_content`, the encrypted reasoning a Responses
78
+ * provider returns and takes back. The scan can't read it (base64's letters spell a brand word only by chance: the
79
+ * 2026-11-23 H pilot was voided on "GPT" inside one), and changing a letter of it would corrupt it, so the brand scan
80
+ * and the leak check leave it out and no replacement list rewrites it. The provider decrypts it for the model, so a
81
+ * brand word in the reasoning itself goes unchecked; its readable summary, and every other field, is scanned. A
82
+ * reasoning item's `id` is the same kind of string: Copilot's are opaque base64 of 416 to 456 characters (the H pilot's
83
+ * second run), so it is left out too. Every other id, a call's included, is scanned.
84
+ */
85
+ exports.OPAQUE_FIELDS = new Set(["encrypted_content"]);
86
+ /** Whether `holder[key]` is a provider's opaque string: an opaque field, or a reasoning item's id. */
87
+ function isOpaque(key, value, holder) {
88
+ if (typeof value !== "string")
89
+ return false;
90
+ if (exports.OPAQUE_FIELDS.has(key))
91
+ return true;
92
+ return key === "id" && typeof holder === "object" && holder !== null && holder.type === "reasoning";
93
+ }
94
+ /**
95
+ * The fields that hold an id: a call's, an item's or a response's. Most are random (a call id is "call_" and 24 base64
96
+ * letters, about 45 a session), so a brand word spelled inside one is chance; an id an arm builds from its own name
97
+ * ("ouro_call_3") is not. In an id a brand word counts only as a whole segment, between the value's start or end and
98
+ * `_`, `-`, `.`, `:` or `/`, so "call_abGPTx9" passes and "ouro_call_3" and "gpt-5" do not. Readable fields keep the
99
+ * whole pattern.
100
+ */
101
+ exports.ID_FIELDS = new Set(["id", "call_id", "tool_call_id", "response_id", "previous_response_id", "item_id"]);
102
+ // The segment's own bounds stand in for the pattern's \b around mui, which fails beside "_" (a word character).
103
+ const segmentRegex = () => new RegExp(`(?<=^|[_\\-.:/])(?:${exports.BRAND_PATTERN.replace("\\bmui\\b", "mui")})(?=$|[_\\-.:/])`, "gi");
104
+ /**
105
+ * `value` as the JSON the brand scan reads: every opaque string left out (as ""), each id as only the brand words that
106
+ * stand as whole segments of it, and everything else as it is.
107
+ */
108
+ function scannedText(value) {
109
+ return JSON.stringify(value, function (key, item) {
110
+ if (isOpaque(key, item, this))
111
+ return "";
112
+ if (typeof item === "string" && exports.ID_FIELDS.has(key))
113
+ return [...item.matchAll(segmentRegex())].map((match) => match[0]).join(" ");
114
+ return item;
115
+ });
116
+ }
74
117
  /** `text` with every brand word replaced by the product's neutral word. */
75
118
  function scrubBrands(text, product) {
76
119
  return text.replace(brandRegex(), exports.NEUTRAL_WORD[product]);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.replace = replace;
4
4
  exports.rewriteRequest = rewriteRequest;
5
5
  const runtime_1 = require("../../nerves/runtime");
6
+ const protocol_1 = require("./protocol");
6
7
  /** Applies the list in order to one text, adding each replacement's matches to `counts` when given. */
7
8
  function replace(text, list, counts) {
8
9
  return list.reduce((out, { pattern, with: by, tier = "list" }) => {
@@ -22,8 +23,9 @@ function deep(value, list, counts) {
22
23
  return replace(value, list, counts);
23
24
  if (Array.isArray(value))
24
25
  return value.map((item) => deep(item, list, counts));
26
+ // A provider's opaque string (ciphertext, a reasoning id) is kept as it was returned: rewriting it would corrupt it.
25
27
  if (value !== null && typeof value === "object")
26
- return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, deep(item, list, counts)]));
28
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, (0, protocol_1.isOpaque)(key, item, value) ? item : deep(item, list, counts)]));
27
29
  return value;
28
30
  }
29
31
  /**
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1509",
3
+ "version": "0.1.0-alpha.1510",
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.1509",
9
+ "version": "0.1.0-alpha.1510",
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.1509",
3
+ "version": "0.1.0-alpha.1510",
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": {