@ouro.bot/cli 0.1.0-alpha.1450 → 0.1.0-alpha.1452

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.1452",
6
+ "changes": [
7
+ "The interviews command takes `--host-lock <holder>`, as the eval's run command does. It holds the remote Docker host's lock for the whole command and sends its token with every job, so a Butler upgrade on that host waits for the interviews. The interviews wait up to 30 minutes for an upgrade in progress, then refuse. The lock lasts at most 6 hours. On the Butler's host, where the sandbox checks the lock, a job that finds it gone stops the study before it marks another session started, so only that one session is lost. The command refuses `--host-lock` without a holder, with a holder that isn't one safe word, or without `--sandbox-ssh`."
8
+ ]
9
+ },
10
+ {
11
+ "version": "0.1.0-alpha.1451",
12
+ "changes": [
13
+ "The shelf-claim guard no longer puts \"I haven't checked the library\" in front of a reply that did check.",
14
+ "When an agent ran the books CLI through a shell variable that the same command sets, the guard didn't see the lookup. For example: `B=…/books; $B library find …`, `\"$B\"`, `${B}` or `export B=…`. So the guard added the hedge to a correct reply that a person reads.",
15
+ "Now the guard resolves each variable a command set earlier in itself before it looks for the books CLI.",
16
+ "A variable the command doesn't set is still not counted.",
17
+ "Neither is one set only after its use, an alias (the shell never uses one set in the same command), a variable that points at something other than the books CLI, or a run that only removed a copy.",
18
+ "So a reply that never looked still gets the hedge."
19
+ ]
20
+ },
4
21
  {
5
22
  "version": "0.1.0-alpha.1450",
6
23
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1450",
2
+ "runtimeVersion": "0.1.0-alpha.1452",
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.1450</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1452</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -8,15 +8,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  * from the pre-registration's Appendix B on one model target, writes the private report and the private request log
9
9
  * (both opened `wx`, mode 0600, under a 0700 folder) and prints a counts-only summary. With `--sandbox-ssh
10
10
  * <host>:<folder>` the sandbox runs on that Docker host, whose harness checkout is synced to `<folder>/harness`;
11
- * `--bundle` and `--seed-bundle` are then paths on that host. Model calls and credentials stay on this machine.
11
+ * `--bundle` and `--seed-bundle` are then paths on that host. `--host-lock <holder>` holds that host's lock
12
+ * (deploy/unraid/ouro-host-lock.mjs) for the whole command, as `run-entry` does, so the Butler's upgrade and rollback
13
+ * wait for it and the sandbox runs on the Butler's host only while it does. Model calls and credentials stay on this
14
+ * machine.
12
15
  */
13
16
  const node_fs_1 = __importDefault(require("node:fs"));
14
17
  const node_os_1 = __importDefault(require("node:os"));
15
18
  const node_path_1 = __importDefault(require("node:path"));
16
19
  const runtime_1 = require("../nerves/runtime");
20
+ const loop_1 = require("./interviews/guest/loop");
17
21
  const self_test_1 = require("./self-test");
18
22
  const report_1 = require("./report");
19
23
  const docker_1 = require("./sandbox/docker");
24
+ const host_lock_1 = require("./sandbox/host-lock");
20
25
  const remote_1 = require("./sandbox/remote");
21
26
  const targets_1 = require("./targets");
22
27
  const runner_1 = require("./interviews/runner");
@@ -27,16 +32,22 @@ function take(argv, flag) {
27
32
  return { value: undefined, rest: argv };
28
33
  return { value: argv[at + 1], rest: [...argv.slice(0, at), ...argv.slice(at + 2)] };
29
34
  }
30
- function runCaseFor(sandboxSsh, bundle, seedBundle, images) {
35
+ function sshTarget(spec) {
36
+ const split = spec.indexOf(":");
37
+ if (split < 1)
38
+ throw new Error("--sandbox-ssh must be <host>:<folder>");
39
+ return { host: spec.slice(0, split), root: spec.slice(split + 1) };
40
+ }
41
+ function runCaseFor(sandboxSsh, bundle, seedBundle, images, hostLockToken) {
31
42
  if (sandboxSsh) {
32
- const split = sandboxSsh.indexOf(":");
33
- if (split < 1)
34
- throw new Error("--sandbox-ssh must be <host>:<folder>");
35
- const host = sandboxSsh.slice(0, split);
36
- const root = sandboxSsh.slice(split + 1);
43
+ const { host, root } = sshTarget(sandboxSsh);
37
44
  return (0, remote_1.remoteRunCase)({
38
45
  start: (0, remote_1.sshStart)(host, `${root}/harness/dist/eval/remote-entry.js`),
39
- paths: { bundleDir: bundle, seedBundleDir: seedBundle ?? `${root}/harness/deploy/unraid/sanctuary.ouro`, workRoot: `${root}/work`, ...(images ? { images } : {}) },
46
+ paths: {
47
+ bundleDir: bundle, seedBundleDir: seedBundle ?? `${root}/harness/deploy/unraid/sanctuary.ouro`, workRoot: `${root}/work`,
48
+ ...(images ? { images } : {}),
49
+ ...(hostLockToken ? { hostLockToken } : {}),
50
+ },
40
51
  });
41
52
  }
42
53
  const docker = (0, docker_1.dockerCli)();
@@ -71,23 +82,75 @@ async function main() {
71
82
  const seed = take(bundle.rest, "--seed-bundle");
72
83
  // `--images <agent>,<household>`: image tags of this run's own, so a run never uses images another checkout built.
73
84
  const tags = take(seed.rest, "--images");
85
+ const hostLock = take(tags.rest, "--host-lock");
74
86
  if (!bundle.value)
75
87
  throw new Error("--bundle is required");
88
+ if (hostLock.rest.length !== tags.rest.length) {
89
+ if (!hostLock.value || hostLock.value.startsWith("--"))
90
+ throw new Error("--host-lock needs a holder, such as eval:<your run>");
91
+ // The holder goes to the host through ssh's remote shell, as in `run-command`.
92
+ if (!/^[\w.:@+-]+$/.test(hostLock.value))
93
+ throw new Error("--host-lock takes one word of letters, digits and . : @ + - _ (it is sent over ssh)");
94
+ if (!ssh.value)
95
+ throw new Error("--host-lock needs --sandbox-ssh");
96
+ }
76
97
  const [agent, household] = tags.value?.split(",") ?? [];
77
98
  if (tags.value && !(agent && household))
78
99
  throw new Error("--images must be <agent image>,<household image>");
79
100
  const images = agent && household ? { agent, household } : undefined;
80
- const args = (0, runner_1.parseInterviewArgs)(tags.rest);
101
+ const args = (0, runner_1.parseInterviewArgs)(hostLock.rest);
102
+ let lock;
103
+ if (hostLock.value && ssh.value) {
104
+ const { host, root } = sshTarget(ssh.value);
105
+ lock = await (0, host_lock_1.holdHostLock)((0, remote_1.sshNode)(host, [`${root}/harness/deploy/unraid/ouro-host-lock.mjs`, "hold", "--holder", hostLock.value, "--ttl", String(host_lock_1.HOST_LOCK_TTL_S), "--wait", String(host_lock_1.HOST_LOCK_WAIT_S)]));
106
+ }
107
+ try {
108
+ return await interviews(args, lock ? stopWhenLockLost(runCaseFor(ssh.value, bundle.value, seed.value, images, lock.token)) : { runCase: runCaseFor(ssh.value, bundle.value, seed.value, images, undefined), started: startedSessions() });
109
+ }
110
+ finally {
111
+ await lock?.release();
112
+ }
113
+ }
114
+ /**
115
+ * A study under a host lock stops once a job finds the lock gone (its ssh session dropped, or its 6 hours ran out):
116
+ * the next session is refused before it is marked started, so it can still run under a new lock. Only the session
117
+ * whose job found the lock gone is lost, as a crash.
118
+ */
119
+ function stopWhenLockLost(runCase) {
120
+ let lost = false;
121
+ const started = startedSessions();
122
+ return {
123
+ runCase: async (input) => {
124
+ try {
125
+ return await runCase(input);
126
+ }
127
+ catch (error) {
128
+ if (/no host lock/.test((0, loop_1.messageOf)(error)))
129
+ lost = true;
130
+ throw error;
131
+ }
132
+ },
133
+ started: {
134
+ has: (id) => started.has(id),
135
+ add: (id) => {
136
+ if (lost)
137
+ throw new Error(`the host lock was lost, so session ${id} was not started; name it and the later sessions with --session to run them under a new lock`);
138
+ started.add(id);
139
+ },
140
+ },
141
+ };
142
+ }
143
+ async function interviews(args, deps) {
81
144
  const { exitCode } = await (0, runner_1.runInterviews)(args, {
82
145
  readText: (file) => node_fs_1.default.readFileSync(file, "utf8"),
83
146
  loadCases: self_test_1.loadCases,
84
147
  resolveTarget: (spec, creds) => (0, targets_1.resolveTarget)(spec, creds),
85
- runCase: runCaseFor(ssh.value, bundle.value, seed.value, images),
148
+ runCase: deps.runCase,
86
149
  kits: { X: runner_1.X_KIT },
87
150
  outputExists: (file) => node_fs_1.default.existsSync(file),
88
151
  writeReport: report_1.writePrivateReport,
89
152
  openLog: openPrivateLog,
90
- started: startedSessions(),
153
+ started: deps.started,
91
154
  print: (text) => { process.stdout.write(`${text}\n`); },
92
155
  });
93
156
  return exitCode;
@@ -153,7 +153,7 @@ exports.ENTRY_POINT_COMMANDS = [
153
153
  ] } },
154
154
  { name: "node dist/eval/interview-entry.js", effect: "private", summary: "Run blind-interview sessions on a model.", ax: { id: "cli:node dist/eval/interview-entry.js", group: "diagnostics", effect: "consequential", confirm: "It spends model credits or premium requests on the account the flags name, up to the caps you pass, and a session it starts can never run again.", when: "Run the pre-registered blind-interview sessions on one model, writing a private report and request log; each session reserves its worst case first.", errors: [
155
155
  { code: "budget-stopped", means: "The study stopped: a session's reservation would pass a cap, or the provider answered 402 or 429. Later sessions are recorded as not run.", fix: "Read the counts on stdout; the study stays stopped, since a session that didn't run counts as ouro not chosen first." },
156
- { code: "eval-error", means: "The interviews refused to start (a bad flag, sandbox or target, or a session not allowed or already started) or failed after starting.", fix: "Read the `interviews:` line on stderr; the started file keeps every session it began, so a new run takes only sessions not yet in it." },
156
+ { code: "eval-error", means: "The interviews refused to start (a bad flag, sandbox or target, a host lock already held by another holder or lost mid-run, or a session not allowed or already started) or failed after starting.", fix: "Read the `interviews:` line on stderr; sessions it began are in the started file and can't run again, so name the others with --session." },
157
157
  ] } },
158
158
  { name: "node dist/senses/shepherd/judge-evaluation-entry.js", effect: "private", summary: "Evaluate Shepherd's judge on its cases.", ax: { id: "cli:node dist/senses/shepherd/judge-evaluation-entry.js", group: "diagnostics", effect: "write", when: "Measure how Shepherd's judge classifies its evaluation cases, writing a report; it never qualifies v1 on its own.", errors: [
159
159
  { code: "not-passed", means: "The Shepherd judge evaluation finished, but its classification didn't pass or closing its report threw.", fix: "Read the JSON summary on stdout and the report for the failing cases." },
@@ -21,6 +21,18 @@ const LIBRARY_LOOKUP_TOOLS = new Set(["media_search", "sanctuary_search_media_ca
21
21
  const MIN_TITLE_LENGTH = 3;
22
22
  /** The bundle's books CLI reading or changing the house book library: `./books get … --deliver`, `books library find …`. */
23
23
  const BOOKS_COMMAND = /(?:^|[\s;&|(])(?:[\w.~/-]*\/)?books\s+(?:get|deliver|library\s+(?:find|add))\b/;
24
+ /** `NAME=value` and `export NAME=value` in a command. A value is quoted or runs to a separator. */
25
+ const ASSIGNMENT = /(?:^|[\s;&|(])(?:export\s+)?([A-Za-z_]\w*)=("[^"\n]*"|'[^'\n]*'|[^\s;&|()]+)/g;
26
+ const VARIABLE = /"?\$(?:\{([A-Za-z_]\w*)\}|([A-Za-z_]\w*))"?/g;
27
+ /**
28
+ * The command with each variable it set earlier put back in place, so `B=…/books; $B library find …` reads as the
29
+ * books CLI. A variable is resolved only from an assignment before its use; one the command never sets stays as it is.
30
+ */
31
+ function resolveOwnVariables(command) {
32
+ const unquote = (value) => value.replace(/^(["'])(.*)\1$/, "$2");
33
+ const assignments = [...command.matchAll(ASSIGNMENT)].map((match) => ({ name: match[1], value: unquote(match[2]), end: match.index + match[0].length }));
34
+ return command.replace(VARIABLE, (whole, braced, bare, at) => assignments.filter((entry) => entry.name === (braced ?? bare) && entry.end <= at).at(-1)?.value ?? whole);
35
+ }
24
36
  /** A reply about the gate's own line ("sorry, that note was wrong"): it corrects a disclosure, so it gets none of its own. */
25
37
  const APOLOGY = /\b(?:sorry|apolog\w*|my\s+(?:mistake|bad)|ignore|disregard)\b|\bwas\s+wrong\b/i;
26
38
  const DISCLOSURE_REF = /\bha(?:ve|d)n['’]?t\s+checked\s+the\s+library\b|\bcan['’]?t\s+promise\s+it['’]?s\s+on\s+the\s+shelf\b|\b(?:that|the|this)\s+(?:line|note|disclaimer|disclosure|warning)\b/i;
@@ -64,7 +76,7 @@ function titlesFrom(records) {
64
76
  /** True when a books CLI run this turn succeeded and, if it was a search, found something: the book library backs the claim. */
65
77
  function bookLibraryBacked(records) {
66
78
  return records.some((record) => {
67
- if (record.name !== "shell" || !BOOKS_COMMAND.test(record.args.command ?? "") || /^error:/i.test(record.result.trim()))
79
+ if (record.name !== "shell" || !BOOKS_COMMAND.test(resolveOwnVariables(record.args.command ?? "")) || /^error:/i.test(record.result.trim()))
68
80
  return false;
69
81
  let parsed;
70
82
  try {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1450",
3
+ "version": "0.1.0-alpha.1452",
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.1450",
9
+ "version": "0.1.0-alpha.1452",
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.1450",
3
+ "version": "0.1.0-alpha.1452",
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": {