@ouro.bot/cli 0.1.0-alpha.1662 → 0.1.0-alpha.1664

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,13 +1,30 @@
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.1664",
6
+ "changes": [
7
+ "Internal only, with no change to how the Butler or the eval behaves: two more core harness files stop importing Butler code. The tool context keeps the Butler's root-host binding as an opaque value that only the Butler's root-host tool reads, and the eval's Telegram turn takes its fake house (agent, owner profile, answer checks and synthetic services) as an argument, with the synthetic Sanctuary supplying the default."
8
+ ]
9
+ },
10
+ {
11
+ "version": "0.1.0-alpha.1663",
12
+ "changes": [
13
+ "A letter now counts as seen when the person writes to the agent in the same one-to-one iMessage chat after the letter arrived there, even if their read receipts are off. Before, a letter was marked seen only from a read receipt, so for someone who doesn't send read receipts it stayed unseen even after they had replied."
14
+ ]
15
+ },
4
16
  {
5
17
  "version": "0.1.0-alpha.1662",
6
18
  "changes": [
7
- "The Butler's image may name a product module in `/opt/ouro/container-runtime.json`. The harness checks and loads it, and then asks it what that product adds. No image names one yet, so behaviour is unchanged. In the image the policy file is now owned by root and read-only, so the agent can't change which code it loads.",
8
19
  "Update the Ouro UI files to Ouro UI v1.3.599."
9
20
  ]
10
21
  },
22
+ {
23
+ "version": "0.1.0-alpha.1661",
24
+ "changes": [
25
+ "The Butler's image may name a product module in `/opt/ouro/container-runtime.json`. The harness checks and loads it, and then asks it what that product adds. No image names one yet, so behaviour is unchanged. In the image the policy file is now owned by root and read-only, so the agent can't change which code it loads."
26
+ ]
27
+ },
11
28
  {
12
29
  "version": "0.1.0-alpha.1660",
13
30
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1662",
2
+ "runtimeVersion": "0.1.0-alpha.1664",
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.1662</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1664</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createSyntheticSanctuary = createSyntheticSanctuary;
4
+ exports.syntheticSanctuaryHouse = syntheticSanctuaryHouse;
4
5
  const tools_unraid_1 = require("../../repertoire/tools-unraid");
5
6
  const sanctuary_container_policy_1 = require("../../repertoire/sanctuary-container-policy");
6
7
  const sanctuary_media_optimization_1 = require("../../senses/sanctuary-media-optimization");
8
+ const sanctuary_runtime_1 = require("../../senses/sanctuary-runtime");
7
9
  const runtime_1 = require("../../nerves/runtime");
8
10
  const OBSERVED_AT = "2026-01-15T12:00:00.000Z";
9
11
  const SERVER_ID = "eval:server";
@@ -109,3 +111,7 @@ function createSyntheticSanctuary() {
109
111
  restartContainer: async () => unavailable("The eval sandbox does not restart containers"),
110
112
  };
111
113
  }
114
+ /** The Butler's fake house for the eval Telegram turn: its bundle, its owner profile, its answer checks and the synthetic services. */
115
+ function syntheticSanctuaryHouse() {
116
+ return { agentName: "sanctuary", ownerProfileId: "sanctuary-owner", toolContext: { answerGates: sanctuary_runtime_1.SANCTUARY_ANSWER_GATES, sanctuary: createSyntheticSanctuary() } };
117
+ }
@@ -45,20 +45,18 @@ const friends_1 = require("@ouro.bot/friends");
45
45
  const identity_1 = require("../../heart/identity");
46
46
  const context_1 = require("../../mind/context");
47
47
  const runtime_1 = require("../../nerves/runtime");
48
- const sanctuary_runtime_1 = require("../../senses/sanctuary-runtime");
49
48
  const shared_turn_1 = require("../../senses/shared-turn");
50
49
  const telegram_1 = require("../../senses/telegram");
51
50
  const telegram_identity_key_1 = require("../../senses/telegram-identity-key");
52
51
  const synthetic_sanctuary_1 = require("./synthetic-sanctuary");
53
- const AGENT = "sanctuary";
54
52
  const BOT_ID = "7001";
55
53
  const OWNER_USER = "4242";
56
54
  const OWNER_FRIEND_ID = "eval-owner";
57
- async function writeOwner(agentRoot) {
55
+ async function writeOwner(agentRoot, capabilityProfileId) {
58
56
  const now = new Date().toISOString();
59
57
  await new friends_1.FileFriendStore(node_path_1.default.join(agentRoot, "friends")).put(OWNER_FRIEND_ID, {
60
58
  id: OWNER_FRIEND_ID, name: "Ari", trustLevel: "family", admissionState: "active", initiativePolicy: "proactive",
61
- capabilityProfileId: "sanctuary-owner",
59
+ capabilityProfileId,
62
60
  externalIds: [{ provider: "telegram-user", externalId: OWNER_USER, tenantId: BOT_ID, linkedAt: now }],
63
61
  tenantMemberships: [], toolPreferences: {}, notes: {}, totalTokens: 0, createdAt: now, updatedAt: now, schemaVersion: 1,
64
62
  });
@@ -138,14 +136,16 @@ function visibleText(html) {
138
136
  async function runTelegramTurn(input) {
139
137
  (0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.telegram_turn_start", message: "running one eval Telegram turn", meta: { steps: input.prefix.length } });
140
138
  try {
139
+ const house = input.house ?? (0, synthetic_sanctuary_1.syntheticSanctuaryHouse)();
140
+ const agent = house.agentName;
141
141
  const agentRoot = node_path_1.default.resolve(input.agentRoot);
142
- if (agentRoot !== (0, identity_1.getAgentRoot)(AGENT))
143
- throw new Error(`agentRoot must be the sanctuary bundle at ${(0, identity_1.getAgentRoot)(AGENT)}, where the turn reads it`);
144
- (0, identity_1.setAgentName)(AGENT);
145
- await writeOwner(agentRoot);
142
+ if (agentRoot !== (0, identity_1.getAgentRoot)(agent))
143
+ throw new Error(`agentRoot must be the ${agent} bundle at ${(0, identity_1.getAgentRoot)(agent)}, where the turn reads it`);
144
+ (0, identity_1.setAgentName)(agent);
145
+ await writeOwner(agentRoot, house.ownerProfileId);
146
146
  const identityKey = (0, telegram_identity_key_1.readOrCreateTelegramIdentityKey)(agentRoot);
147
147
  const sessionKey = `telegram:${(0, telegram_1.opaqueTelegramSubject)(identityKey, BOT_ID, OWNER_USER, OWNER_USER)}`;
148
- const sessionPath = (0, shared_turn_1.getSenseSessionPath)(AGENT, OWNER_FRIEND_ID, "telegram", sessionKey, agentRoot);
148
+ const sessionPath = (0, shared_turn_1.getSenseSessionPath)(agent, OWNER_FRIEND_ID, "telegram", sessionKey, agentRoot);
149
149
  node_fs_1.default.mkdirSync(node_path_1.default.dirname(sessionPath), { recursive: true });
150
150
  (0, context_1.saveSession)(sessionPath, [{ role: "system", content: "" }, ...input.prefix]);
151
151
  const timeline = [];
@@ -169,11 +169,11 @@ async function runTelegramTurn(input) {
169
169
  let turnError;
170
170
  let onMessage;
171
171
  const app = (0, telegram_1.createTelegramSenseApp)({
172
- agentName: AGENT,
172
+ agentName: agent,
173
173
  credentials,
174
174
  identityKey,
175
175
  _agentRoot: agentRoot,
176
- _toolContext: { agentRoot, answerGates: sanctuary_runtime_1.SANCTUARY_ANSWER_GATES, sanctuary: (0, synthetic_sanctuary_1.createSyntheticSanctuary)() },
176
+ _toolContext: { agentRoot, ...house.toolContext },
177
177
  api,
178
178
  createLongPoll: (options) => {
179
179
  onMessage = options.onMessage;
@@ -181,7 +181,7 @@ async function runTelegramTurn(input) {
181
181
  },
182
182
  _createInteractiveControl: (() => ({ socketPath: "unused", start: idle, stop: idle })),
183
183
  migrateIdentity: idle,
184
- ...(await (0, telegram_1.createProductionTelegramRelationshipComposition)(AGENT, credentials, agentRoot)),
184
+ ...(await (0, telegram_1.createProductionTelegramRelationshipComposition)(agent, credentials, agentRoot)),
185
185
  _runTurn: async (options) => {
186
186
  try {
187
187
  turn = await (0, shared_turn_1.runSenseTurn)({
@@ -39,6 +39,8 @@ exports.readAnsweredGuids = readAnsweredGuids;
39
39
  exports.addAnsweredGuid = addAnsweredGuid;
40
40
  exports.deliveryFloor = deliveryFloor;
41
41
  exports.answerProblem = answerProblem;
42
+ exports.seenFloor = seenFloor;
43
+ exports.replySeenProblem = replySeenProblem;
42
44
  exports.noteAnswerRefused = noteAnswerRefused;
43
45
  // How a person's own iMessage answers a letter (design §3.4, "How an answer is recorded"). Only the daemon records
44
46
  // an answer, from the BlueBubbles server's own copy of the message: the chat ingress hands it a message GUID and
@@ -163,6 +165,51 @@ function answerProblem(entry, message, answer, answered, floor) {
163
165
  return "no-such-option";
164
166
  return null;
165
167
  }
168
+ /**
169
+ * The time a message must come after to show the person has seen a letter: the server's own send time for it, or
170
+ * else the daemon's delivered time with no slack, since a plain message carries no code to tie it to the letter.
171
+ * Null when the letter isn't delivered.
172
+ */
173
+ async function seenFloor(entry, sentAt) {
174
+ const delivered = entry.events.find((event) => event.t === "delivered");
175
+ if (!delivered)
176
+ return null;
177
+ if (delivered.messageId && sentAt) {
178
+ const serverTime = await sentAt(delivered.messageId).catch(() => undefined);
179
+ if (serverTime !== undefined)
180
+ return serverTime;
181
+ }
182
+ return Date.parse(delivered.at);
183
+ }
184
+ /**
185
+ * Why a message the person sent doesn't show they have seen this letter, or null when it does: an iMessage from the
186
+ * letter's answering handle, in their one-to-one chat, sent after the letter landed there. Their read receipts may be
187
+ * off, but a person who writes in the chat after the letter arrived has had it on screen. `floor` is seenFloor.
188
+ */
189
+ function replySeenProblem(entry, message, floor) {
190
+ const letter = entry.letter;
191
+ const sentAfterExpiry = letter.expiresAt !== undefined && (message.dateCreated ?? Number.POSITIVE_INFINITY) >= Date.parse(letter.expiresAt);
192
+ if (entry.state !== "waiting" || sentAfterExpiry)
193
+ return "not-waiting";
194
+ if (entry.events.some((event) => event.t === "seen"))
195
+ return "already-seen";
196
+ if (!letter.answeringHandle)
197
+ return "no-answering-handle";
198
+ if (message.isFromMe !== false)
199
+ return "from-me";
200
+ if (message.service !== "iMessage")
201
+ return "not-imessage";
202
+ const sender = message.sender ? (0, answering_1.normalizeAnsweringHandle)(message.sender) : null;
203
+ if (!sender?.ok || sender.handle !== letter.answeringHandle)
204
+ return "wrong-sender";
205
+ if (message.chatGuids.length !== 1 || directChatHandle(message.chatGuids[0]) !== letter.answeringHandle)
206
+ return "wrong-chat";
207
+ if (floor === null)
208
+ return "not-delivered";
209
+ if (message.dateCreated === undefined || message.dateCreated <= floor)
210
+ return "before-delivery";
211
+ return null;
212
+ }
166
213
  /** Logs a message that looked like an answer and wasn't one, by its reason alone. */
167
214
  function noteAnswerRefused(reason) {
168
215
  (0, runtime_1.emitNervesEvent)({ level: "warn", component: "daemon", event: "letters.answer_refused", message: "a message in answer form didn't answer its letter", meta: { reason } });
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.answerLettersSeenCommand = answerLettersSeenCommand;
4
- // The daemon's `letters.seen` command: the BlueBubbles ingress names a message whose read receipt it saw, and the
5
- // daemon reads that message from the agent's own server and records that the person read the letter it delivered.
4
+ // The daemon's `letters.seen` command: the BlueBubbles ingress names a message whose read receipt it saw, or a message
5
+ // the person sent in a one-to-one chat, and the daemon reads that message from the agent's own server. A read receipt
6
+ // marks seen the letter that message delivered; the person's own message marks seen each letter that landed in their
7
+ // chat before they wrote, since their read receipts may be off.
6
8
  // Like `letters.answer`, the command carries only a GUID, so whoever sends it can only point at a real message.
7
9
  const runtime_1 = require("../../nerves/runtime");
8
10
  async function answerLettersSeenCommand(writer, command, sourceFor) {
@@ -13,8 +15,8 @@ async function answerLettersSeenCommand(writer, command, sourceFor) {
13
15
  return { ok: false, error: `No agent bundle ${command.agent}.ouro is on this machine.` };
14
16
  try {
15
17
  const guid = command.messageGuid.trim();
16
- // Most read receipts are for ordinary chat messages, so the index is asked before the server is.
17
- if (!writer.hasWaitingDelivery(command.agent, guid))
18
+ // Most read receipts and messages are ordinary chat, so the index is asked before the server is.
19
+ if (!writer.hasWaitingDelivery(command.agent, guid) && !writer.hasUnseenDelivery(command.agent))
18
20
  return { ok: true, data: { recorded: false, reason: "no-letter" } };
19
21
  const source = await sourceFor(command.agent);
20
22
  // The server password travels in the fetch's query string, so only a server nobody between can read is asked.
@@ -23,6 +25,10 @@ async function answerLettersSeenCommand(writer, command, sourceFor) {
23
25
  const message = await source.getServerMessage(guid);
24
26
  if (!message || message.guid !== guid)
25
27
  return { ok: true, data: { recorded: false, reason: "unknown-message" } };
28
+ if (message.isFromMe === false) {
29
+ const sentAt = async (sentGuid) => (await source.getServerMessage(sentGuid))?.dateCreated;
30
+ return { ok: true, data: await writer.recordSeenByReply(command.agent, message, sentAt) };
31
+ }
26
32
  return { ok: true, data: await writer.recordSeen(command.agent, message) };
27
33
  }
28
34
  catch (error) {
@@ -371,9 +371,40 @@ class LettersWriter {
371
371
  return { recorded: false, reason: problem };
372
372
  this.addEvent(letters, entry.letter.id, { t: "seen", at: new Date(message.dateRead).toISOString(), via: "chat" });
373
373
  (0, runtime_1.emitNervesEvent)({ component: "daemon", event: "letters.letter_seen", message: "the person read a letter", meta: { code: entry.letter.code } });
374
- return { recorded: true, code: entry.letter.code };
374
+ return { recorded: true, codes: [entry.letter.code] };
375
375
  });
376
376
  }
377
+ /**
378
+ * Records seen, at the message's send time, each waiting letter the person wrote after in the chat it landed in,
379
+ * from the server's own copy of their message. It is the seen for a person whose read receipts are off. `sentAt`
380
+ * reads the server's time for a letter's sent message, as for an answer.
381
+ */
382
+ async recordSeenByReply(agent, message, sentAt) {
383
+ const letters = this.open(agent, false);
384
+ // Every check but the floor runs first, from the index alone, and the floors are fetched outside the queue, so a
385
+ // slow server never holds up an answer to the same message that is waiting behind this.
386
+ const candidates = letters.index.list({}).filter((entry) => (0, answer_reader_1.replySeenProblem)(entry, message, Number.NEGATIVE_INFINITY) === null);
387
+ const floors = new Map();
388
+ for (const entry of candidates)
389
+ floors.set(entry.letter.id, await (0, answer_reader_1.seenFloor)(entry, sentAt));
390
+ return this.serial(letters, async () => {
391
+ const codes = [];
392
+ for (const candidate of candidates) {
393
+ // Read again inside the queue, since the letter may have been answered or seen meanwhile.
394
+ const entry = letters.index.get(candidate.letter.id);
395
+ if ((0, answer_reader_1.replySeenProblem)(entry, message, floors.get(entry.letter.id)) !== null)
396
+ continue;
397
+ this.addEvent(letters, entry.letter.id, { t: "seen", at: new Date(message.dateCreated).toISOString(), via: "chat" });
398
+ (0, runtime_1.emitNervesEvent)({ component: "daemon", event: "letters.letter_seen_by_reply", message: "the person wrote in the chat after a letter landed there", meta: { code: entry.letter.code } });
399
+ codes.push(entry.letter.code);
400
+ }
401
+ return codes.length > 0 ? { recorded: true, codes } : { recorded: false, reason: "no-letter" };
402
+ });
403
+ }
404
+ /** Whether any waiting letter is delivered and not yet seen, read from the index alone, so most chat needs no fetch. */
405
+ hasUnseenDelivery(agent) {
406
+ return this.open(agent, false).index.list({}).some((entry) => entry.events.some((event) => event.t === "delivered") && !entry.events.some((event) => event.t === "seen"));
407
+ }
377
408
  /**
378
409
  * Whether a waiting letter was delivered as this message, read from the index alone. The daemon asks it before it
379
410
  * fetches anything from the server, since most read receipts are for ordinary chat messages.
@@ -54,6 +54,10 @@ const selections = new WeakMap();
54
54
  class RootHostAuthorizationError extends Error {
55
55
  }
56
56
  exports.RootHostAuthorizationError = RootHostAuthorizationError;
57
+ /** Core keeps `rootHost.binding` opaque; only this file sets it, always to a RootHostBinding, so reading it back is exact. */
58
+ function boundBinding(ctx) {
59
+ return ctx?.rootHost?.binding;
60
+ }
57
61
  function requireOwner(condition) {
58
62
  if (!condition)
59
63
  throw new RootHostAuthorizationError((0, tools_base_1.withCode)("Sanctuary root host authorization denied", "root-host-denied"));
@@ -99,7 +103,7 @@ function observationAccepted(ctx) {
99
103
  && root.observation.targetHost === root.port.pins.expectedTargetHost;
100
104
  }
101
105
  async function authorizeRootHostContext(ctx, expected) {
102
- const previous = ctx.rootHost?.binding;
106
+ const previous = boundBinding(ctx);
103
107
  const provenance = previous && bindings.get(previous);
104
108
  if (previous)
105
109
  bindings.delete(previous);
@@ -187,7 +191,7 @@ function validateRootHostToolArguments(args, targetHost) {
187
191
  }
188
192
  function selectRootHostTool(ctx, capabilities) {
189
193
  try {
190
- const binding = ctx?.rootHost?.binding;
194
+ const binding = boundBinding(ctx);
191
195
  const provenance = binding && bindings.get(binding);
192
196
  if (!ctx || !binding || !provenance || provenance.port !== ctx.rootHost.port || !capabilities?.has("approval-continuation")
193
197
  || !(0, node_util_1.isDeepStrictEqual)(binding, currentCoordinates(ctx)) || (!provenance.recovery && !observationAccepted(ctx)))
@@ -1824,6 +1824,14 @@ async function handleBlueBubblesNormalizedEvent(event, resolvedDeps, source, opt
1824
1824
  return { handled: true, notifiedAgent: false, kind: event.kind, reason: "from_me" };
1825
1825
  }
1826
1826
  options.lifecycleSignal?.throwIfAborted();
1827
+ // Any message the person sends in a one-to-one chat shows they have had the letters that landed there on screen,
1828
+ // even with their read receipts off; the daemon checks it against the server's copy. Nothing waits on it.
1829
+ if (event.eventType === "new-message" && !event.chat.isGroup && event.fromMe !== true) {
1830
+ const messageGuid = event.messageGuid;
1831
+ resolvedDeps.letterSeen(agentName, messageGuid).catch((error) => {
1832
+ (0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.bluebubbles_letter_seen_unchecked", message: "couldn't tell the daemon a message was read", meta: { messageGuid, reason: error.message } });
1833
+ });
1834
+ }
1827
1835
  // A message in answer form ("L7 2") from a one-to-one chat may answer a letter. The daemon decides from the
1828
1836
  // server's copy; a recorded answer is the harness's, so it doesn't become a chat turn, and the daemon tells
1829
1837
  // the agent. Anything else, or a daemon that can't be asked, runs the turn as usual.
@@ -16,7 +16,7 @@ const SEEN_TIMEOUT_MS = 30_000;
16
16
  * Asks the daemon whether a message answers one of the agent's letters; true when it recorded an answer now or
17
17
  * before (a replay). Past the deadline the daemon records nothing, so a timed-out ask leaves the message a chat turn.
18
18
  */
19
- /** Tells the daemon the server reported a message read; it records `seen` if that message delivered a letter. */
19
+ /** Tells the daemon the server reported a message read, or that the person sent one; it records `seen` for the letters that shows they have read. */
20
20
  async function tellDaemonLetterSeen(agent, messageGuid, send = socket_client_1.sendDaemonCommand) {
21
21
  const answer = await send(socket_client_1.DEFAULT_DAEMON_SOCKET_PATH, { kind: "letters.seen", agent, messageGuid }, { timeoutMs: SEEN_TIMEOUT_MS });
22
22
  if (!answer.ok)
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1662",
3
+ "version": "0.1.0-alpha.1664",
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.1662",
9
+ "version": "0.1.0-alpha.1664",
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.1662",
3
+ "version": "0.1.0-alpha.1664",
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": {