@ouro.bot/cli 0.1.0-alpha.1140 → 0.1.0-alpha.1142
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 +14 -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/heart/shelf-claims.js +8 -2
- package/dist/repertoire/unraid-restart.js +6 -3
- package/dist/senses/shared-turn.js +6 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
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.1142",
|
|
6
|
+
"changes": [
|
|
7
|
+
"When the Butler decides a message needs no reply, such as a heart reaction, it now stays quiet instead of sending an error note. A turn that really fails still tells you.",
|
|
8
|
+
"When a title isn't on the shelf, the Butler names it once instead of twice."
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"version": "0.1.0-alpha.1141",
|
|
13
|
+
"changes": [
|
|
14
|
+
"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.",
|
|
15
|
+
"The Telegram test driver waits while the Butler holds its state lock, instead of failing midway through a turn."
|
|
16
|
+
]
|
|
17
|
+
},
|
|
4
18
|
{
|
|
5
19
|
"version": "0.1.0-alpha.1140",
|
|
6
20
|
"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.1142</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");
|
|
@@ -22,8 +22,14 @@ function normalize(text) {
|
|
|
22
22
|
function titlesFrom(records) {
|
|
23
23
|
const onShelf = [];
|
|
24
24
|
const offShelf = [];
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
// A lookup can name one title in several places (a result and a candidate); keep it once so the reply names it once.
|
|
26
|
+
const add = (list, title) => {
|
|
27
|
+
if (typeof title !== "string" || normalize(title).trim().length < MIN_TITLE_LENGTH)
|
|
28
|
+
return;
|
|
29
|
+
const key = normalize(title);
|
|
30
|
+
if (!list.some((known) => known.key === key))
|
|
31
|
+
list.push({ name: title.trim(), key });
|
|
32
|
+
};
|
|
27
33
|
for (const record of records) {
|
|
28
34
|
if (!LIBRARY_LOOKUP_TOOLS.has(record.name))
|
|
29
35
|
continue;
|
|
@@ -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 };
|
|
@@ -753,8 +753,12 @@ async function runSenseTurnExclusive(options, owner) {
|
|
|
753
753
|
const finalDeliveryAttempt = finalDeliveryAttemptIndex === undefined ? undefined : deliveryAttempts[finalDeliveryAttemptIndex];
|
|
754
754
|
const responseDeliveryFailure = finalDeliveryAttempt && !finalDeliveryAttempt.delivered ? deliveryFailures.at(-1) : undefined;
|
|
755
755
|
const responseCausalSessionEventId = finalDeliveryAttempt && !finalDeliveryAttempt.delivered ? finalCausalCoordinate?.eventId : undefined;
|
|
756
|
+
// settle(answer: "", intent: "complete") is the agent choosing to say nothing, for example after a reaction.
|
|
757
|
+
// A settle whose answer held only <think> reasoning is not a choice, so it still gets the diagnostic below.
|
|
758
|
+
const deliberateSilence = turnResult.turnOutcome === "settled" && turnResult.completion?.intent === "complete"
|
|
759
|
+
&& typeof turnResult.completion.answer === "string" && turnResult.completion.answer.trim().length === 0;
|
|
756
760
|
if (committedResponseText.length === 0) {
|
|
757
|
-
if (!expectsOutwardResponse) {
|
|
761
|
+
if (!expectsOutwardResponse || deliberateSilence) {
|
|
758
762
|
finalResponse = "";
|
|
759
763
|
}
|
|
760
764
|
else {
|
|
@@ -774,7 +778,7 @@ async function runSenseTurnExclusive(options, owner) {
|
|
|
774
778
|
// came through and nothing else, surface a clear diagnostic message
|
|
775
779
|
// instead of a blank response so the operator knows what happened.
|
|
776
780
|
finalResponse = stripThinkBlocks(finalResponse);
|
|
777
|
-
if (finalResponse.length === 0 && expectsOutwardResponse) {
|
|
781
|
+
if (finalResponse.length === 0 && expectsOutwardResponse && !deliberateSilence) {
|
|
778
782
|
(0, runtime_1.emitNervesEvent)({
|
|
779
783
|
level: "warn",
|
|
780
784
|
component: "senses",
|
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.1142",
|
|
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.1142",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
12
12
|
"@ouro.bot/friends": "0.1.0-alpha.18",
|