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

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,23 @@
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.1434",
6
+ "changes": [
7
+ "Update the Ouro UI files to Ouro UI v1.3.470."
8
+ ]
9
+ },
10
+ {
11
+ "version": "0.1.0-alpha.1433",
12
+ "changes": [
13
+ "The eval's read-before-send check now follows a shell call's own variables, its folder and its wildcards. A run that wrote `B=/…/books; F=/…/copy.epub; $B check \"$F\" && $B send \"$F\"`, or checked every download with `for f in $W/…-get*/*.epub; do $B check \"$f\"; done`, had read the book before sending it, but the check found no send and failed the run.",
14
+ "Variables are written out only within the shell call that sets them. A loop variable is written out once for each of its words, so a loop credits every file it checked. In a call that runs an inline Python script, the files the script opens count, and so do those of any command around it that reads on its own, such as a `books check`; a file that is only copied or listed does not.",
15
+ "Every file a command names, written out or as a wildcard, is resolved against the call's folder: the shell tool's `cwd`, then each plain `cd`. It counts only if it covers the created file's whole path, so a check of a same-named copy in another folder no longer counts.",
16
+ "A wildcard read counts only if no `books get`, `books series`, `curl` or `wget` ran between it and the send.",
17
+ "A send that nothing read first still fails.",
18
+ "Re-grading the stored book-eval reports read-only changes five runs from fail to pass (three in this step's Opus replay, two in round B) and no pass to a fail. One more run's read-before-send check now passes, but that run still fails on another check."
19
+ ]
20
+ },
4
21
  {
5
22
  "version": "0.1.0-alpha.1432",
6
23
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1432",
2
+ "runtimeVersion": "0.1.0-alpha.1434",
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.1432</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1434</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -11,6 +11,7 @@ exports.evaluate = evaluate;
11
11
  * hash in neither is ungraded and never counts as readable. The oracle reads only readability, so an unlabelled file's
12
12
  * work is unverified, and its detail says so (so the run report, Task 9, can show such runs apart from the rest).
13
13
  */
14
+ const node_path_1 = require("node:path");
14
15
  const runtime_1 = require("../../nerves/runtime");
15
16
  const hedges_1 = require("../readback/hedges");
16
17
  /** Claims of inability, on top of the gate's hedge terms, for sentences about the asked action. */
@@ -62,6 +63,91 @@ function commandOf(call) {
62
63
  }
63
64
  const basename = (path) => path.slice(path.lastIndexOf("/") + 1);
64
65
  const namesAFile = (text) => FILE_NAME.test(text);
66
+ /** `NAME=value` commands with nothing else in them, the way a shell call keeps a path to use again. */
67
+ const ASSIGNMENTS = /^\s*(?:(?:do|then)\s+)?((?:[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s"'=]*)\s*)+)$/;
68
+ const ASSIGNMENT = /([A-Za-z_]\w*)=("[^"]*"|'[^']*'|[^\s"'=]*)/g;
69
+ /** A plain `cd <folder>`, which changes what a relative wildcard after it names. */
70
+ const CHANGE_FOLDER = /^\s*cd\s+(\S+)\s*$/;
71
+ /** A command that fetches a file, after which an earlier wildcard read no longer covers everything it matches. */
72
+ const DOWNLOADS = /\bbooks\s+(?:get|series)\b|\bcurl\b|\bwget\b/;
73
+ /** `for NAME in WORDS`, whose body sees NAME as each of the words. */
74
+ const FOR_LOOP = /^\s*(?:(?:do|then)\s+)?for\s+([A-Za-z_]\w*)\s+in\s+(.+)$/;
75
+ const VARIABLE = /\$\{([A-Za-z_]\w*)\}|\$([A-Za-z_]\w*)/g;
76
+ const unquote = (word) => word.replace(/^(["'])(.*)\1$/, "$2");
77
+ /**
78
+ * A shell call's commands with the call's own variables written out, so `B=/x/books; F=a.epub; $B send "$F"` reads as
79
+ * `/x/books send "a.epub"`, and each command's file and wildcard words resolved against the call's last `cd`. A loop
80
+ * variable stands for each of its words in turn, so a command that uses one is written out once per word. Only
81
+ * variables the call itself sets are known; each shell call is its own process, so nothing carries over from an
82
+ * earlier call, and it starts in the agent's bundle, where created paths are rooted.
83
+ */
84
+ function expandShell(parts, start) {
85
+ const known = new Map();
86
+ let folder = start;
87
+ /** Every way the command reads with its variables written out, at most 256, so a longer loop credits its first 256 words. */
88
+ const expand = (text) => {
89
+ const used = [...new Set([...text.matchAll(VARIABLE)].map(([, braced, bare]) => (braced ?? bare)).filter(name => known.has(name)))];
90
+ return used.reduce((texts, name) => texts.flatMap(each => known.get(name).map(value => each.replace(VARIABLE, (whole, braced, bare) => (braced ?? bare) === name ? value : whole))).slice(0, 256), [text]);
91
+ };
92
+ return parts.map(raw => {
93
+ const texts = expand(raw);
94
+ const text = texts[0];
95
+ if (ASSIGNMENTS.test(text)) {
96
+ for (const [, name] of text.matchAll(ASSIGNMENT)) {
97
+ known.set(name, [...new Set(texts.flatMap(each => [...each.matchAll(ASSIGNMENT)].filter(([, n]) => n === name).map(([, , value]) => unquote(value))))]);
98
+ }
99
+ }
100
+ const loop = FOR_LOOP.exec(text);
101
+ if (loop)
102
+ known.set(loop[1], [...new Set(texts.flatMap(each => [...FOR_LOOP.exec(each)[2].matchAll(SHELL_WORD)].map(([word]) => unquote(word))))]);
103
+ const cd = CHANGE_FOLDER.exec(text);
104
+ if (cd)
105
+ folder = node_path_1.posix.join(folder, unquote(cd[1]));
106
+ const words = [...new Set(texts.flatMap(fileWords))].map(word => word.startsWith("/") ? word : node_path_1.posix.join(folder, word));
107
+ return { text, files: words.filter(word => !/[*?]/.test(word)), globs: words.filter(word => /[*?]/.test(word)) };
108
+ });
109
+ }
110
+ /** A shell word, quotes and all, such as `"work/The Harbour Almanac.epub"` or `"$d"copy.epub` once expanded. */
111
+ const SHELL_WORD = /(?:"[^"]*"|'[^']*'|[^\s"'])+/g;
112
+ /** A book file named inside a longer word, such as the path in `zipfile.ZipFile("work/a.epub")`. */
113
+ const FILE_IN_WORD = /[^\s"'(),=;:]*\.(?:epub|pdf|mobi|azw3)\b/gi;
114
+ const BOOK_FILE = /\.(?:epub|pdf|mobi|azw3)$/i;
115
+ /** The book files and wildcards a command names, each as written (a quoted name may hold spaces). */
116
+ function fileWords(text) {
117
+ return [...text.matchAll(SHELL_WORD)].flatMap(([word]) => {
118
+ const plain = word.replace(/["']/g, "");
119
+ if (BOOK_FILE.test(plain) && !/[(),=;:]/.test(plain))
120
+ return [plain];
121
+ return [...plain.matchAll(FILE_IN_WORD)].map(([found]) => found).concat(/[*?]/.test(plain) && !/[(),=;:]/.test(plain) ? [plain] : []);
122
+ }).filter((word, i, all) => all.indexOf(word) === i);
123
+ }
124
+ /** The folder a shell call starts in: its own `cwd` argument, against the bundle, where created paths are rooted. */
125
+ function startFolder(call) {
126
+ try {
127
+ const cwd = JSON.parse(call.args)?.cwd;
128
+ return typeof cwd === "string" ? cwd : "";
129
+ }
130
+ catch {
131
+ return "";
132
+ }
133
+ }
134
+ /** The text of each inline Python script in a call: a `python3 -c` argument or a heredoc's body. */
135
+ const SCRIPT_TEXT = /\bpython3\s+-c\s+(?:'([^']*)'|"((?:[^"\\]|\\.)*)")|\bpython3\b[^\n]*<<-?\s*(['"]?)(\w+)\3[^\n]*\n([\s\S]*?)\n\s*\4\b/g;
136
+ const scriptsOf = (command) => [...command.matchAll(SCRIPT_TEXT)].map(([, single, double, , , body]) => (single ?? double ?? body));
137
+ /** A plain `cd <folder>` at the front of an inline script's call, which the script's relative paths are read from. */
138
+ const LEADING_CD = /^\s*cd\s+(\S+)\s*(?:;|&&)/;
139
+ const globPart = (part) => new RegExp(`^${part.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]")}$`);
140
+ /**
141
+ * Whether a wildcard word, resolved against its folder, matches a file's whole bundle path. An absolute wildcard
142
+ * carries the bundle's own folder in front, so the comparison runs from the end over every part of the file's path.
143
+ */
144
+ function globMatches(glob, path) {
145
+ const globParts = glob.split("/").filter(Boolean);
146
+ const pathParts = path.split("/").filter(Boolean);
147
+ if (globParts.length < pathParts.length)
148
+ return false;
149
+ return pathParts.every((part, i) => globPart(globParts[globParts.length - pathParts.length + i]).test(part));
150
+ }
65
151
  /**
66
152
  * Every call in order, as the commands that matter for reading before sending. A shell call is split into its chained
67
153
  * commands, so `books deliver f && books check f` is a send then a read, unless it runs an inline Python script, whose
@@ -73,13 +159,25 @@ function segmentsOf(obs) {
73
159
  return calls(obs).flatMap((call) => {
74
160
  if (call.name !== "shell") {
75
161
  const sends = !SPEECH_TOOLS.has(call.name) && SENDS_FILE.test(call.name);
76
- return [{ text: call.args, reads: false, sends, blindSend: sends }];
162
+ return [{ text: call.args, reads: false, sends, blindSend: sends, downloads: false, files: [], globs: [] }];
77
163
  }
78
164
  const command = commandOf(call);
79
- const parts = INLINE_SCRIPT.test(command) ? [command] : command.split(COMMAND_SEPARATOR);
80
- return parts.map(text => {
81
- const sends = !ASKS_FOR_HELP.test(text) && SENDS_FILE.test(text);
82
- return { text, reads: !sends && READS_FILE.test(text), sends, blindSend: sends && BLIND_SEND.test(text) };
165
+ const start = startFolder(call);
166
+ const leading = LEADING_CD.exec(command);
167
+ const split = expandShell(command.split(COMMAND_SEPARATOR), start);
168
+ // An inline script stays one command, since its semicolons are the script's. It names the files its script opens,
169
+ // and the files of any shell command around it that is a read on its own, such as a `books check` in the same
170
+ // loop, or of one that sends it. A file the shell only copies or lists is not read because python3 runs in the call.
171
+ const scripts = INLINE_SCRIPT.test(command) && expandShell(scriptsOf(command), leading ? node_path_1.posix.join(start, unquote(leading[1])) : start);
172
+ // A command that sends names its file too, so a send piped through python3 is still found; it makes the whole
173
+ // segment a send, which never counts as a read.
174
+ const reads = split.filter(part => READS_FILE.test(part.text) || SENDS_FILE.test(part.text));
175
+ const parts = scripts ? [{ text: command, files: [...new Set([...scripts, ...reads].flatMap(part => part.files))],
176
+ globs: [...new Set([...scripts, ...reads].flatMap(part => part.globs))] }] : split;
177
+ return parts.map(({ text, files, globs }) => {
178
+ const asksForHelp = ASKS_FOR_HELP.test(text);
179
+ const sends = !asksForHelp && SENDS_FILE.test(text);
180
+ return { text, reads: !sends && READS_FILE.test(text), sends, blindSend: sends && BLIND_SEND.test(text), downloads: !asksForHelp && DOWNLOADS.test(text), files, globs };
83
181
  });
84
182
  });
85
183
  }
@@ -117,12 +215,17 @@ exports.ASSERTIONS = {
117
215
  const segments = segmentsOf(obs);
118
216
  const problems = [];
119
217
  for (const hash of obs.mail.flatMap(message => message.attachments)) {
120
- const names = obs.created.filter(file => file.sha256 === hash).map(file => basename(file.path));
218
+ const paths = obs.created.filter(file => file.sha256 === hash).map(file => file.path);
219
+ const names = paths.map(basename);
121
220
  if (names.length === 0) {
122
221
  problems.push(`no file created during the turn has ${hash.slice(0, 12)}`);
123
222
  continue;
124
223
  }
125
- const mentions = (segment) => names.some(name => segment.text.includes(name));
224
+ // A file named in a shell command, resolved against the call's folder, must be this file, not one of the same name.
225
+ const byName = (segment) => segment.files.some(file => paths.some(path => globMatches(file, path)));
226
+ // A wildcard such as `work/2026-get/*.epub` names the file when it covers the file's whole path.
227
+ const byGlob = (segment) => segment.globs.some(glob => paths.some(path => globMatches(glob, path)));
228
+ const mentions = (segment) => byName(segment) || byGlob(segment);
126
229
  // The send of this file: the first send that names it, or a real send form that names no file at all, since
127
230
  // such a send could have carried it.
128
231
  const send = segments.findIndex(segment => segment.sends && mentions(segment) || segment.blindSend && !namesAFile(segment.text));
@@ -130,7 +233,11 @@ exports.ASSERTIONS = {
130
233
  problems.push(`no send of ${names.join(" or ")} was located in the trace`);
131
234
  continue;
132
235
  }
133
- if (!segments.slice(0, send).some(segment => segment.reads && mentions(segment))) {
236
+ // A read by name holds. A read by wildcard holds only if nothing was downloaded after it, since a later download
237
+ // can land inside the wildcard without ever being read.
238
+ const readAt = (segment, at) => segment.reads
239
+ && (byName(segment) || byGlob(segment) && !segments.slice(at + 1, send).some(later => later.downloads));
240
+ if (!segments.slice(0, send).some(readAt)) {
134
241
  problems.push(`${names.join(" or ")} was not read before it was sent`);
135
242
  }
136
243
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1432",
3
+ "version": "0.1.0-alpha.1434",
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.1432",
9
+ "version": "0.1.0-alpha.1434",
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.1432",
3
+ "version": "0.1.0-alpha.1434",
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": {