@ouro.bot/cli 0.1.0-alpha.1382 → 0.1.0-alpha.1384

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,19 @@
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.1384",
6
+ "changes": [
7
+ "A delegated command's audit notice is sent to the owner's own Telegram chat at once, or the command is refused: it no longer waits on the owner route, quiet hours, the daily cap or a handoff."
8
+ ]
9
+ },
10
+ {
11
+ "version": "0.1.0-alpha.1383",
12
+ "changes": [
13
+ "A bundle can declare its own MCP server's tools in a tools.json from Ouro UI core's ouro-actions-tools (agent.json mcpServers.<name>.tools); the harness then gives those tools the declared description, parameters and Ouro AX card, with risk from the card's effect.",
14
+ "Update the Ouro UI files to Ouro UI v1.3.458."
15
+ ]
16
+ },
4
17
  {
5
18
  "version": "0.1.0-alpha.1382",
6
19
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1382",
2
+ "runtimeVersion": "0.1.0-alpha.1384",
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.1382</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1384</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.parseDeclaredTools = parseDeclaredTools;
37
+ exports.loadDeclaredTools = loadDeclaredTools;
38
+ exports.declaredRiskProfile = declaredRiskProfile;
39
+ /**
40
+ * A bundle's declared tools: the `tools.json` an agent bundle ships for one of its own MCP servers (agent.json
41
+ * `mcpServers.<name>.tools`), written by Ouro UI core's ouro-actions-tools projection from the bundle's action
42
+ * declarations (ourostack/ouro-ui-core `src/actions-tools.mts`, release v1.11.0). Each entry is an OpenAI function tool
43
+ * with its Ouro AX card (`ax`, the census's DoorCard). The harness surfaces that server's tools with the declared
44
+ * description, parameters and card, so a bundle's tool schemas and its Ouro AX cards come from one declaration.
45
+ *
46
+ * An entry that isn't a whole declaration (no effect, no `when`, a consequential one with no confirm question) is left
47
+ * out, and its tool stays undeclared: it's handled as any MCP tool is, from what its server says, never from the broken entry.
48
+ */
49
+ const fs = __importStar(require("node:fs"));
50
+ const path = __importStar(require("node:path"));
51
+ const runtime_1 = require("../nerves/runtime");
52
+ const EFFECTS = new Set(["read", "write", "consequential", "person-only"]);
53
+ const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
54
+ const isLine = (v) => typeof v === "string" && v.trim() !== "" && !/[\r\n]/.test(v);
55
+ function errorCards(v) {
56
+ if (!Array.isArray(v))
57
+ return null;
58
+ const cards = [];
59
+ for (const e of v) {
60
+ if (!isObject(e) || !isLine(e.code) || !isLine(e.means) || !isLine(e.fix))
61
+ return null;
62
+ cards.push({ code: e.code, means: e.means, fix: e.fix });
63
+ }
64
+ return cards;
65
+ }
66
+ /** Why one entry isn't a whole declaration, or its declaration. */
67
+ function declaredTool(entry) {
68
+ if (!isObject(entry) || entry.type !== "function" || !isObject(entry.function) || typeof entry.function.name !== "string" || entry.function.name === "") {
69
+ return { problem: "an entry is not a function tool with a name" };
70
+ }
71
+ const name = entry.function.name;
72
+ const { description, parameters } = entry.function;
73
+ if (!isLine(description))
74
+ return { problem: `${name}: no one-line description` };
75
+ if (!isObject(parameters) || parameters.type !== "object")
76
+ return { problem: `${name}: parameters is not an object schema` };
77
+ const ax = entry.ax;
78
+ if (!isObject(ax))
79
+ return { problem: `${name}: no ax card` };
80
+ if (typeof ax.effect !== "string" || !EFFECTS.has(ax.effect))
81
+ return { problem: `${name}: the card has no effect` };
82
+ if (!isLine(ax.when))
83
+ return { problem: `${name}: the card has no when line` };
84
+ if (!isLine(ax.group))
85
+ return { problem: `${name}: the card has no group` };
86
+ const errors = errorCards(ax.errors);
87
+ if (errors === null)
88
+ return { problem: `${name}: the card's errors are not { code, means, fix } lines` };
89
+ if (ax.effect === "consequential" && !isLine(ax.confirm))
90
+ return { problem: `${name}: a consequential card has no confirm question` };
91
+ const card = {
92
+ id: `tool:${name}`, group: ax.group, when: ax.when, effect: ax.effect, errors,
93
+ ...(ax.destructive === true ? { destructive: true } : {}),
94
+ ...(ax.idempotent === true ? { idempotent: true } : {}),
95
+ ...(isLine(ax.confirm) ? { confirm: ax.confirm } : {}),
96
+ };
97
+ return { name, tool: { description, parameters, ax: card } };
98
+ }
99
+ /** The declared tools in a tools.json's content, and why any entry was left out. */
100
+ function parseDeclaredTools(json) {
101
+ const tools = new Map();
102
+ const problems = [];
103
+ if (!isObject(json) || !Array.isArray(json.tools))
104
+ return { tools, problems: ["it has no tools list"] };
105
+ for (const entry of json.tools) {
106
+ const result = declaredTool(entry);
107
+ if ("problem" in result)
108
+ problems.push(result.problem);
109
+ else if (tools.has(result.name))
110
+ problems.push(`${result.name}: declared twice`);
111
+ else
112
+ tools.set(result.name, result.tool);
113
+ }
114
+ return { tools, problems };
115
+ }
116
+ /**
117
+ * Reads a server's tools.json, a path inside the agent's bundle (relative to it, or absolute). Null, with a warning,
118
+ * when the path leaves the bundle or the file can't be read as JSON; the server's tools then stay undeclared.
119
+ */
120
+ function loadDeclaredTools(agentRoot, file, server) {
121
+ const root = path.resolve(agentRoot);
122
+ const target = path.resolve(root, file);
123
+ const warn = (reason) => {
124
+ (0, runtime_1.emitNervesEvent)({
125
+ level: "warn", event: "mcp.declared_tools_unreadable", component: "repertoire",
126
+ message: `the declared tools for MCP server ${server} can't be used`, meta: { server, reason },
127
+ });
128
+ return null;
129
+ };
130
+ if (target !== root && !target.startsWith(root + path.sep))
131
+ return warn("the tools path is outside the agent bundle");
132
+ let json;
133
+ try {
134
+ json = JSON.parse(fs.readFileSync(target, "utf8"));
135
+ }
136
+ catch (error) {
137
+ // readFileSync and JSON.parse throw only Errors.
138
+ return warn(error.message);
139
+ }
140
+ const { tools, problems } = parseDeclaredTools(json);
141
+ if (problems.length > 0) {
142
+ (0, runtime_1.emitNervesEvent)({
143
+ level: "warn", event: "mcp.declared_tools_incomplete", component: "repertoire",
144
+ message: `some declared tools for MCP server ${server} were left out`, meta: { server, problems },
145
+ });
146
+ }
147
+ return tools;
148
+ }
149
+ /** The risk the harness gives a declared tool, from its card's effect. */
150
+ function declaredRiskProfile(effect) {
151
+ if (effect === "read")
152
+ return { mutates: "none", risk: "low", reason: "declared read in the agent bundle's tools.json" };
153
+ if (effect === "write")
154
+ return { mutates: "durable_state_write", risk: "high", reason: "declared write in the agent bundle's tools.json" };
155
+ return { mutates: "external_side_effect", risk: "high", reason: `declared ${effect} in the agent bundle's tools.json` };
156
+ }
@@ -46,6 +46,7 @@ const credential_access_1 = require("./credential-access");
46
46
  const plugin_mcp_1 = require("./plugin-mcp");
47
47
  const tool_arguments_1 = require("./tool-arguments");
48
48
  const mcp_tools_1 = require("./mcp-tools");
49
+ const mcp_declared_tools_1 = require("./mcp-declared-tools");
49
50
  const MAX_RESTART_RETRIES = 5;
50
51
  const RESTART_DELAY_MS = 1000;
51
52
  function isOwner(value) {
@@ -266,11 +267,17 @@ class McpManager {
266
267
  && this.desiredGenerations.get(key) === entry.generation;
267
268
  }
268
269
  freezeView(owner) {
269
- const entries = this.ownedEntries(owner).filter((entry) => this.isCurrentEntry(entry)).map((entry) => Object.freeze({
270
- server: entry.name, source: entry.source, pluginId: entry.pluginId,
271
- configDigest: entry.configDigest, generation: entry.generation,
272
- tools: (0, tool_arguments_1.freezeToolValue)(structuredClone(entry.cachedTools)),
273
- }));
270
+ const entries = this.ownedEntries(owner).filter((entry) => this.isCurrentEntry(entry)).map((entry) => {
271
+ const declared = entry.source === "builtin" && typeof entry.config.tools === "string"
272
+ ? (0, mcp_declared_tools_1.loadDeclaredTools)(owner.agentRoot, entry.config.tools, entry.name)
273
+ : null;
274
+ return Object.freeze({
275
+ server: entry.name, source: entry.source, pluginId: entry.pluginId,
276
+ configDigest: entry.configDigest, generation: entry.generation,
277
+ tools: (0, tool_arguments_1.freezeToolValue)(structuredClone(entry.cachedTools)),
278
+ ...(declared ? { declared } : {}),
279
+ });
280
+ });
274
281
  return Object.freeze({ manager: this, owner, entries: Object.freeze(entries) });
275
282
  }
276
283
  matchesBinding(entry, binding, owner) {
@@ -11,6 +11,7 @@ exports.mcpToolsAsDefinitions = mcpToolsAsDefinitions;
11
11
  const runtime_1 = require("../nerves/runtime");
12
12
  const tool_arguments_1 = require("./tool-arguments");
13
13
  const mcp_write_guard_1 = require("./mcp-write-guard");
14
+ const mcp_declared_tools_1 = require("./mcp-declared-tools");
14
15
  class McpCallRejectedError extends Error {
15
16
  constructor(message) {
16
17
  super(message);
@@ -52,6 +53,10 @@ function mcpToolSchema(entry, tool) {
52
53
  },
53
54
  };
54
55
  }
56
+ /** The served schema with the bundle's declared description and parameters; its name stays the served one. */
57
+ function withDeclaration(served, declared) {
58
+ return { ...served, function: { ...served.function, description: declared.description, parameters: declared.parameters } };
59
+ }
55
60
  /**
56
61
  * An MCP tool's Ouro AX card, made from what its server says: the tool's first description sentence as its `when`
57
62
  * line, and a read effect only when the read-only hint is trusted (the agent's own servers), else a write.
@@ -83,82 +88,104 @@ function mcpToolCard(server, tool, surfacedName, readOnly) {
83
88
  function mcpToolsAsDefinitions(view) {
84
89
  if (!view)
85
90
  return [];
86
- return view.entries.flatMap((entry) => entry.tools.map((tool) => {
87
- const schema = mcpToolSchema(entry, tool);
88
- const binding = Object.freeze({
89
- manager: view.manager, ...view.owner, server: entry.server,
90
- rawName: tool.name, surfacedName: schema.function.name,
91
- source: entry.source, pluginId: entry.pluginId,
92
- configDigest: entry.configDigest, generation: entry.generation,
93
- schemaDigest: (0, tool_arguments_1.digestJson)(schema),
91
+ return view.entries.flatMap((entry) => {
92
+ if (entry.declared)
93
+ warnUnservedDeclarations(entry);
94
+ return entry.tools.flatMap((tool) => {
95
+ const served = mcpToolSchema(entry, tool);
96
+ // The bundle's own declaration, when it has one: the model sees the declared description, parameters and card.
97
+ const declared = entry.declared?.get(tool.name);
98
+ // A person-only action is never an agent's to call, so a declared one is not surfaced.
99
+ if (declared?.ax.effect === "person-only")
100
+ return [];
101
+ const schema = declared ? withDeclaration(served, declared) : served;
102
+ const binding = Object.freeze({
103
+ manager: view.manager, ...view.owner, server: entry.server,
104
+ rawName: tool.name, surfacedName: served.function.name,
105
+ source: entry.source, pluginId: entry.pluginId,
106
+ configDigest: entry.configDigest, generation: entry.generation,
107
+ // The served schema, which the manager checks the binding against; the declaration changes only what the model reads.
108
+ schemaDigest: (0, tool_arguments_1.digestJson)(served),
109
+ });
110
+ // A read-only hint is trusted only from the agent's own bundle (agent.json mcpServers),
111
+ // so an orientation hold still lets the agent inspect through those tools.
112
+ const trustedReadOnly = entry.source === "builtin" && tool.annotations?.readOnlyHint === true;
113
+ return [{
114
+ tool: schema,
115
+ ax: declared ? { ...declared.ax, id: `tool:${served.function.name}` } : mcpToolCard(entry.server, tool, served.function.name, trustedReadOnly),
116
+ riskProfile: declared ? (0, mcp_declared_tools_1.declaredRiskProfile)(declared.ax.effect) : trustedReadOnly
117
+ ? { mutates: "none", risk: "low", reason: "read-only tool from the agent's own MCP server" }
118
+ : {
119
+ mutates: "external_side_effect",
120
+ risk: "high",
121
+ reason: "MCP tools may mutate external systems",
122
+ },
123
+ handler: async (args, ctx) => {
124
+ if (ctx?.agentName !== binding.agentName || ctx.agentRoot !== binding.agentRoot) {
125
+ (0, runtime_1.emitNervesEvent)({
126
+ level: "warn", event: "mcp.tool_rejected", component: "repertoire",
127
+ message: "MCP tool owner does not match its caller", meta: { reason: "owner mismatch" },
128
+ });
129
+ throw new McpCallRejectedError("MCP tool owner does not match its caller");
130
+ }
131
+ (0, runtime_1.emitNervesEvent)({
132
+ event: "mcp.tool_start",
133
+ component: "repertoire",
134
+ message: `calling MCP tool ${entry.server}/${tool.name}`,
135
+ meta: { server: entry.server, tool: tool.name },
136
+ });
137
+ const guarded = (0, mcp_write_guard_1.guardMcpArgs)({ toolName: tool.name, declaresDryRun: Object.hasOwn((tool.inputSchema?.properties ?? {}), "dry_run"), args, ctx });
138
+ if (guarded.rejected !== undefined)
139
+ throw new McpCallRejectedError(guarded.rejected);
140
+ try {
141
+ const result = await view.manager.callTool(binding, guarded.args, { agentName: ctx.agentName, agentRoot: ctx.agentRoot });
142
+ const { text, images } = splitMcpContent(result.content);
143
+ if (result.isError === true) {
144
+ throw new McpToolExecutionError("handler_failed", `[mcp error] ${entry.server}/${tool.name}: ${text}`);
145
+ }
146
+ let output = text;
147
+ if (images.length > 0) {
148
+ if (ctx.attachToolImages)
149
+ ctx.attachToolImages(images);
150
+ else
151
+ output = `${text}${text ? "\n\n" : ""}[${images.length} image(s) returned, but this caller can't receive images]`;
152
+ }
153
+ (0, runtime_1.emitNervesEvent)({
154
+ event: "mcp.tool_end",
155
+ component: "repertoire",
156
+ message: `MCP tool ${entry.server}/${tool.name} completed`,
157
+ meta: { server: entry.server, tool: tool.name },
158
+ });
159
+ return output;
160
+ }
161
+ catch (error) {
162
+ const reason = error instanceof Error ? error.message : String(error);
163
+ (0, runtime_1.emitNervesEvent)({
164
+ level: "error",
165
+ event: "mcp.tool_error",
166
+ component: "repertoire",
167
+ message: `MCP tool ${entry.server}/${tool.name} failed: ${reason}`,
168
+ meta: { server: entry.server, tool: tool.name, reason },
169
+ });
170
+ if (error instanceof McpCallRejectedError || error instanceof McpToolExecutionError)
171
+ throw error;
172
+ throw new McpToolExecutionError("handler_indeterminate", `[mcp error] ${entry.server}/${tool.name}: ${reason}`);
173
+ }
174
+ },
175
+ mcpServer: entry.server,
176
+ mcpBinding: binding,
177
+ }];
94
178
  });
95
- // A read-only hint is trusted only from the agent's own bundle (agent.json mcpServers),
96
- // so an orientation hold still lets the agent inspect through those tools.
97
- const trustedReadOnly = entry.source === "builtin" && tool.annotations?.readOnlyHint === true;
98
- return {
99
- tool: schema,
100
- ax: mcpToolCard(entry.server, tool, schema.function.name, trustedReadOnly),
101
- riskProfile: trustedReadOnly
102
- ? { mutates: "none", risk: "low", reason: "read-only tool from the agent's own MCP server" }
103
- : {
104
- mutates: "external_side_effect",
105
- risk: "high",
106
- reason: "MCP tools may mutate external systems",
107
- },
108
- handler: async (args, ctx) => {
109
- if (ctx?.agentName !== binding.agentName || ctx.agentRoot !== binding.agentRoot) {
110
- (0, runtime_1.emitNervesEvent)({
111
- level: "warn", event: "mcp.tool_rejected", component: "repertoire",
112
- message: "MCP tool owner does not match its caller", meta: { reason: "owner mismatch" },
113
- });
114
- throw new McpCallRejectedError("MCP tool owner does not match its caller");
115
- }
116
- (0, runtime_1.emitNervesEvent)({
117
- event: "mcp.tool_start",
118
- component: "repertoire",
119
- message: `calling MCP tool ${entry.server}/${tool.name}`,
120
- meta: { server: entry.server, tool: tool.name },
121
- });
122
- const guarded = (0, mcp_write_guard_1.guardMcpArgs)({ toolName: tool.name, declaresDryRun: Object.hasOwn((tool.inputSchema?.properties ?? {}), "dry_run"), args, ctx });
123
- if (guarded.rejected !== undefined)
124
- throw new McpCallRejectedError(guarded.rejected);
125
- try {
126
- const result = await view.manager.callTool(binding, guarded.args, { agentName: ctx.agentName, agentRoot: ctx.agentRoot });
127
- const { text, images } = splitMcpContent(result.content);
128
- if (result.isError === true) {
129
- throw new McpToolExecutionError("handler_failed", `[mcp error] ${entry.server}/${tool.name}: ${text}`);
130
- }
131
- let output = text;
132
- if (images.length > 0) {
133
- if (ctx.attachToolImages)
134
- ctx.attachToolImages(images);
135
- else
136
- output = `${text}${text ? "\n\n" : ""}[${images.length} image(s) returned, but this caller can't receive images]`;
137
- }
138
- (0, runtime_1.emitNervesEvent)({
139
- event: "mcp.tool_end",
140
- component: "repertoire",
141
- message: `MCP tool ${entry.server}/${tool.name} completed`,
142
- meta: { server: entry.server, tool: tool.name },
143
- });
144
- return output;
145
- }
146
- catch (error) {
147
- const reason = error instanceof Error ? error.message : String(error);
148
- (0, runtime_1.emitNervesEvent)({
149
- level: "error",
150
- event: "mcp.tool_error",
151
- component: "repertoire",
152
- message: `MCP tool ${entry.server}/${tool.name} failed: ${reason}`,
153
- meta: { server: entry.server, tool: tool.name, reason },
154
- });
155
- if (error instanceof McpCallRejectedError || error instanceof McpToolExecutionError)
156
- throw error;
157
- throw new McpToolExecutionError("handler_indeterminate", `[mcp error] ${entry.server}/${tool.name}: ${reason}`);
158
- }
159
- },
160
- mcpServer: entry.server,
161
- mcpBinding: binding,
162
- };
163
- }));
179
+ });
180
+ }
181
+ /** A declared tool the server doesn't serve is not surfaced; say so, since the bundle promised it. */
182
+ function warnUnservedDeclarations(entry) {
183
+ const served = new Set(entry.tools.map((tool) => tool.name));
184
+ const missing = [...entry.declared.keys()].filter((name) => !served.has(name));
185
+ if (missing.length === 0)
186
+ return;
187
+ (0, runtime_1.emitNervesEvent)({
188
+ level: "warn", event: "mcp.declared_tool_unserved", component: "repertoire",
189
+ message: `MCP server ${entry.server} doesn't serve tools its bundle declares`, meta: { server: entry.server, missing },
190
+ });
164
191
  }
@@ -103,14 +103,14 @@ Promise.all([
103
103
  agentName,
104
104
  identity,
105
105
  // The Butler accepts delegated commands from explicitly granted peers; each
106
- // one is announced in the owner's Telegram chat before it runs.
106
+ // one is announced in the owner's own Telegram chat before it runs (never through the owner route, never held).
107
107
  ...(agentName === "sanctuary" ? {
108
108
  delegation: {
109
109
  principalProfileId: delegated_command_1.A2A_PRINCIPAL_PROFILE_ID,
110
110
  agentRoot: (0, identity_1.getAgentRoot)(agentName),
111
111
  notifyPrincipal: async (notice) => {
112
- const { sendTelegramOwnerNotice } = await Promise.resolve().then(() => __importStar(require("./telegram")));
113
- await sendTelegramOwnerNotice(agentName, { ...notice, signal: AbortSignal.timeout(30_000) });
112
+ const { sendTelegramDelegatedAuditNotice } = await Promise.resolve().then(() => __importStar(require("./telegram")));
113
+ await sendTelegramDelegatedAuditNotice(agentName, { ...notice, signal: AbortSignal.timeout(30_000) });
114
114
  },
115
115
  },
116
116
  } : {}),
@@ -52,6 +52,7 @@ exports.loadTelegramSenseCredentials = loadTelegramSenseCredentials;
52
52
  exports.createProductionTelegramRelationshipComposition = createProductionTelegramRelationshipComposition;
53
53
  exports.startTelegramSenseApp = startTelegramSenseApp;
54
54
  exports.sendTelegramExternalEventDecision = sendTelegramExternalEventDecision;
55
+ exports.sendTelegramDelegatedAuditNotice = sendTelegramDelegatedAuditNotice;
55
56
  exports.sendTelegramOwnerNotice = sendTelegramOwnerNotice;
56
57
  exports.createProactiveRepetitionGuard = createProactiveRepetitionGuard;
57
58
  exports.withTelegramTypingIndicator = withTelegramTypingIndicator;
@@ -1039,13 +1040,13 @@ function createTelegramSenseApp(options) {
1039
1040
  approvalReconciliationsInFlight.add(failsafe);
1040
1041
  }, delay);
1041
1042
  };
1042
- const deliverButlerEffect = async (text, idempotencyKey, signal, onMessageDelivered, exactDownloadCreditQuestion = false, replyToMessageId) => {
1043
+ const deliverButlerEffect = async (text, idempotencyKey, signal, onMessageDelivered, exactDownloadCreditQuestion = false, replyToMessageId, silent = false) => {
1043
1044
  const presentedText = (0, sanctuary_download_credit_presentation_1.presentSanctuaryDownloadCreditReply)(options.agentName, exactDownloadCreditQuestion, text);
1044
1045
  return executeAuthorizedEffect({
1045
1046
  idempotencyKey,
1046
1047
  target: configuredOwnerTarget(),
1047
1048
  authorClass: "butler",
1048
- effect: { kind: "text", text: presentedText, ...(replyToMessageId ? { replyToMessageId } : {}) },
1049
+ effect: { kind: "text", text: presentedText, ...(replyToMessageId ? { replyToMessageId } : {}), ...(silent ? { silent: true } : {}) },
1049
1050
  ...(signal ? { signal } : {}),
1050
1051
  ...(onMessageDelivered ? { onMessageDelivered } : {}),
1051
1052
  });
@@ -2069,6 +2070,8 @@ function createTelegramSenseApp(options) {
2069
2070
  const noticeId = requiredText(input.noticeId, "owner notice id");
2070
2071
  if (Buffer.byteLength(noticeId) > 512)
2071
2072
  throw new Error("Telegram owner notice id is invalid");
2073
+ if (noticeId.startsWith("delegated:"))
2074
+ return this.sendDelegatedAuditNotice({ ...input, noticeId });
2072
2075
  await runWithAcceptanceAuditOwner(async () => {
2073
2076
  const text = requiredText(input.text, "owner notice");
2074
2077
  const telegramText = await routeSelfStarted(text, `owner-notice:${noticeId}`, undefined, input.signal);
@@ -2083,6 +2086,25 @@ function createTelegramSenseApp(options) {
2083
2086
  await recordAcceptedEffects(sessionPath, [effect]);
2084
2087
  });
2085
2088
  },
2089
+ async sendDelegatedAuditNotice(input) {
2090
+ const noticeId = requiredText(input.noticeId, "delegated audit notice id");
2091
+ if (!noticeId.startsWith("delegated:") || Buffer.byteLength(noticeId) > 512)
2092
+ throw new Error("Telegram delegated audit notice id is invalid");
2093
+ const key = `owner-notice:${noticeId}`;
2094
+ await runWithAcceptanceAuditOwner(async () => {
2095
+ const text = requiredText(input.text, "delegated audit notice");
2096
+ if (ownerChatIsHandedOff()) {
2097
+ (0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.telegram_delegated_notice_refused", message: "refused a delegated command's audit notice while the owner's chat is handed to someone else", meta: { agentName: options.agentName, reason: "handed_off" } });
2098
+ throw new Error("the owner's Telegram chat is handed to someone else, so a delegated command's notice can't be sent");
2099
+ }
2100
+ const pacingReason = options.proactivePacing ? (0, telegram_handoff_1.proactiveHoldReason)(proactiveLedgerPath, new Date(), options.proactivePacing) : null;
2101
+ const silent = options.ownerRoute !== undefined || pacingReason === "quiet_hours";
2102
+ const effect = await deliverButlerEffect(text, key, input.signal, undefined, false, undefined, silent);
2103
+ (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.telegram_delegated_notice_sent", message: "sent a delegated command's audit notice to the owner's Telegram chat", meta: { agentName: options.agentName, silent } });
2104
+ const sessionPath = (0, shared_turn_1.getSenseSessionPath)(options.agentName, configuredOwnerFriendId, "telegram", configuredOwnerSessionKey, agentRoot);
2105
+ await recordAcceptedEffects(sessionPath, [effect]);
2106
+ });
2107
+ },
2086
2108
  stop() {
2087
2109
  if (stopPromise)
2088
2110
  return stopPromise;
@@ -2421,6 +2443,16 @@ async function sendTelegramExternalEventDecision(agentName, input) {
2421
2443
  await app.stop();
2422
2444
  }
2423
2445
  }
2446
+ /** Sends a delegated command's audit notice; see `sendDelegatedAuditNotice`. Throws when it can't be sent. */
2447
+ async function sendTelegramDelegatedAuditNotice(agentName, input) {
2448
+ const app = await startTelegramSenseApp(agentName);
2449
+ try {
2450
+ await app.sendDelegatedAuditNotice(input);
2451
+ }
2452
+ finally {
2453
+ await app.stop();
2454
+ }
2455
+ }
2424
2456
  async function sendTelegramOwnerNotice(agentName, input) {
2425
2457
  const app = await startTelegramSenseApp(agentName);
2426
2458
  try {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1382",
3
+ "version": "0.1.0-alpha.1384",
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.1382",
9
+ "version": "0.1.0-alpha.1384",
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.1382",
3
+ "version": "0.1.0-alpha.1384",
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": {