@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 +7 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/daemon/sanctuary-telegram-test-driver.js +29 -7
- package/dist/repertoire/unraid-restart.js +6 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
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,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.
|
|
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
|
|
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
|
-
|
|
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") <=
|
|
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 };
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
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.
|
|
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",
|