@ouro.bot/cli 0.1.0-alpha.1140 → 0.1.0-alpha.1141

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,13 @@
1
1
  {
2
2
  "_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
3
3
  "versions": [
4
+ {
5
+ "version": "0.1.0-alpha.1141",
6
+ "changes": [
7
+ "The Butler can restart a container again after you approve it: the approval check now accepts Unraid's full container ids, which are longer than the old limit.",
8
+ "The Telegram test driver waits while the Butler holds its state lock, instead of failing midway through a turn."
9
+ ]
10
+ },
4
11
  {
5
12
  "version": "0.1.0-alpha.1140",
6
13
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1140",
2
+ "runtimeVersion": "0.1.0-alpha.1141",
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.1140</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1141</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -171,6 +171,9 @@ exports.SANCTUARY_TELEGRAM_TEST_DRIVER_USAGE = `usage: sanctuary-telegram-test-d
171
171
  tap --message-id <bot message id> --data <button callback data>
172
172
  log [--since <seq>]
173
173
  options for send/edit/react/tap: --wait <seconds> (default ${DEFAULT_WAIT_SECONDS}), --quiet <seconds> (default ${DEFAULT_QUIET_SECONDS}), --no-wait, --no-echo`;
174
+ function isBusyLease(error) {
175
+ return error instanceof Error && error.retryable === true;
176
+ }
174
177
  async function runSanctuaryTelegramTestDriver(argv, deps) {
175
178
  const now = deps.now ?? Date.now;
176
179
  const sleep = deps.sleep ?? ((milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)));
@@ -186,7 +189,24 @@ async function runSanctuaryTelegramTestDriver(argv, deps) {
186
189
  const chat = { id: Number(deps.ownerChatId), type: "private" };
187
190
  const from = { id: owner, is_bot: false, first_name: "Owner (test)" };
188
191
  const date = Math.floor(now() / 1_000);
189
- const updateId = deps.gateway.nextTestUpdateId();
192
+ const waitSeconds = flags.has("--wait") ? positiveInteger(flags.get("--wait"), "--wait") : DEFAULT_WAIT_SECONDS;
193
+ const quietSeconds = flags.has("--quiet") ? positiveInteger(flags.get("--quiet"), "--quiet") : DEFAULT_QUIET_SECONDS;
194
+ const startedAt = now();
195
+ const deadline = startedAt + waitSeconds * 1_000;
196
+ // The resident holds the authority's state lease while it works a turn; wait for it rather than crash.
197
+ const whenFree = async (operation) => {
198
+ for (;;) {
199
+ try {
200
+ return operation();
201
+ }
202
+ catch (error) {
203
+ if (!isBusyLease(error) || now() >= deadline)
204
+ throw error;
205
+ await sleep(1_000);
206
+ }
207
+ }
208
+ };
209
+ const updateId = await whenFree(() => deps.gateway.nextTestUpdateId());
190
210
  let update;
191
211
  let echo;
192
212
  if (command === "send") {
@@ -229,14 +249,11 @@ async function runSanctuaryTelegramTestDriver(argv, deps) {
229
249
  else {
230
250
  throw new Error(exports.SANCTUARY_TELEGRAM_TEST_DRIVER_USAGE);
231
251
  }
232
- const waitSeconds = flags.has("--wait") ? positiveInteger(flags.get("--wait"), "--wait") : DEFAULT_WAIT_SECONDS;
233
- const quietSeconds = flags.has("--quiet") ? positiveInteger(flags.get("--quiet"), "--quiet") : DEFAULT_QUIET_SECONDS;
234
- const startedAt = now();
235
252
  deps.log.arm(startedAt + (waitSeconds * 1_000) + WINDOW_GRACE_MS);
236
253
  if (!switches.has("--no-echo") && deps.echo)
237
254
  await deps.echo(echo);
238
255
  const seq = deps.log.append({ kind: "injected", command, updateId, update });
239
- deps.gateway.injectTestUpdate(update);
256
+ await whenFree(() => deps.gateway.injectTestUpdate(update));
240
257
  (0, runtime_1.emitNervesEvent)({ component: "daemon", event: "daemon.sanctuary_telegram_test_driver_injected", message: "Sanctuary test driver injected an owner update", meta: { updateId, command } });
241
258
  const injected = { updateId, ...(command === "send" ? { messageId: updateId } : {}), seq };
242
259
  if (switches.has("--no-wait")) {
@@ -244,14 +261,19 @@ async function runSanctuaryTelegramTestDriver(argv, deps) {
244
261
  return injected;
245
262
  }
246
263
  // Wait until the resident has settled the update and the bot has been quiet for a while, or the deadline passes.
247
- const deadline = startedAt + waitSeconds * 1_000;
248
264
  let settlement = "pending";
249
265
  let settledAt;
250
266
  let lastReplyAt = startedAt;
251
267
  let replies = [];
252
268
  let timedOut = false;
253
269
  for (;;) {
254
- settlement = deps.gateway.record(updateId)?.settlement ?? "missing";
270
+ try {
271
+ settlement = deps.gateway.record(updateId)?.settlement ?? "missing";
272
+ }
273
+ catch (error) {
274
+ if (!isBusyLease(error))
275
+ throw error;
276
+ }
255
277
  if (settlement !== "pending" && settledAt === undefined)
256
278
  settledAt = now();
257
279
  const current = deps.log.read().filter((entry) => entry.seq > seq && entry.kind === "outbound");
@@ -28,9 +28,12 @@ function exactTarget(result, name) {
28
28
  return failure("ambiguous", `container '${name}' is ambiguous`);
29
29
  return matches[0];
30
30
  }
31
- function validArgument(value) {
32
- return typeof value === "string" && value.length > 0 && Buffer.byteLength(value, "utf8") <= 128 && !value.includes("\uFFFD");
31
+ function validArgument(value, maxBytes = 128) {
32
+ return typeof value === "string" && value.length > 0 && Buffer.byteLength(value, "utf8") <= maxBytes && !value.includes("\uFFFD");
33
33
  }
34
+ // Unraid names a container by its server and Docker ids, two 64-hex halves joined by a colon (129 bytes);
35
+ // the container list already admits ids up to 256 bytes, so the approval check uses the same bound.
36
+ const MAX_CONTAINER_ID_BYTES = 256;
34
37
  async function currentRoutineAuthorization(authority) {
35
38
  let authorization;
36
39
  try {
@@ -76,7 +79,7 @@ function createApprovedUnraidRestartExecutor(options) {
76
79
  const routine = execution?.routine;
77
80
  const approvalInput = execution?.approval;
78
81
  if (execution && Object.hasOwn(execution, "approval") && (!approvalInput || typeof approvalInput.reauthorize !== "function"
79
- || !validArgument(approvalInput.target?.id) || approvalInput.target.id !== approvalInput.target.id.trim()
82
+ || !validArgument(approvalInput.target?.id, MAX_CONTAINER_ID_BYTES) || approvalInput.target.id !== approvalInput.target.id.trim()
80
83
  || approvalInput.target.name !== args.container))
81
84
  return failure("invalid_response", "restart approval authority is invalid");
82
85
  const approvalAuthority = approvalInput && { target: { ...approvalInput.target }, reauthorize: approvalInput.reauthorize };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1140",
3
+ "version": "0.1.0-alpha.1141",
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.1140",
9
+ "version": "0.1.0-alpha.1141",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.78.0",
12
12
  "@ouro.bot/friends": "0.1.0-alpha.18",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1140",
3
+ "version": "0.1.0-alpha.1141",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },