@ouro.bot/cli 0.1.0-alpha.1410 → 0.1.0-alpha.1411
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 +3 -2
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/a2a/approval-relay-forward.js +113 -0
- package/dist/a2a/server.js +37 -0
- package/dist/senses/telegram-approval-relay.js +5 -7
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
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
4
|
{
|
|
5
|
-
"version": "0.1.0-alpha.
|
|
5
|
+
"version": "0.1.0-alpha.1411",
|
|
6
6
|
"changes": [
|
|
7
|
-
"npm run eval runs the replay eval's cases on a real model (GitHub Copilot or MiniMax) against one bundle, in the sandbox locally or on another Docker host over ssh. Every run reserves its worst-case spend first, in premium requests and in credits, refuses to start without a Copilot multiplier or, for a pay-per-token target, without a credits cap, stops on the first 402 or 429, and writes a private report with pass@1 and Wilson intervals."
|
|
7
|
+
"npm run eval runs the replay eval's cases on a real model (GitHub Copilot or MiniMax) against one bundle, in the sandbox locally or on another Docker host over ssh. Every run reserves its worst-case spend first, in premium requests and in credits, refuses to start without a Copilot multiplier or, for a pay-per-token target, without a credits cap, stops on the first 402 or 429, and writes a private report with pass@1 and Wilson intervals.",
|
|
8
|
+
"The Butler's A2A server passes Ari's relayed approval answers to the Telegram sense, unopened and without starting a model turn, and only from the owner route's peer."
|
|
8
9
|
]
|
|
9
10
|
},
|
|
10
11
|
{
|
|
@@ -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.1411</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,113 @@
|
|
|
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.MAX_RELAY_REPLY_BYTES = exports.RELAY_FORWARD_TIMEOUT_MS = exports.RELAY_REFUSED = exports.RELAY_TIMED_OUT = exports.RELAY_UNAVAILABLE = exports.RELAY_REPLY = void 0;
|
|
37
|
+
exports.approvalRelaySocketPath = approvalRelaySocketPath;
|
|
38
|
+
exports.forwardApprovalAnswer = forwardApprovalAnswer;
|
|
39
|
+
/**
|
|
40
|
+
* The A2A process's half of the approval relay. A verified sealed message that carries friends' signed `approvalAnswer`
|
|
41
|
+
* never becomes a model turn. Once the A2A server has verified it, the raw sealed message goes to the Telegram sense
|
|
42
|
+
* process over `state/approvals/relay/sock`, and that process opens it again, checks it and decides it beside the taps
|
|
43
|
+
* (security review H3, L4). This file is that one-line client.
|
|
44
|
+
*/
|
|
45
|
+
const net = __importStar(require("node:net"));
|
|
46
|
+
const path = __importStar(require("node:path"));
|
|
47
|
+
const runtime_1 = require("../nerves/runtime");
|
|
48
|
+
/** Where the Telegram sense listens for relayed answers: alone in a folder only this agent's user can enter. */
|
|
49
|
+
function approvalRelaySocketPath(agentRoot) {
|
|
50
|
+
return path.join(agentRoot, "state", "approvals", "relay", "sock");
|
|
51
|
+
}
|
|
52
|
+
/** What the sender hears back. The Telegram process answers one of these; anything else reads as unavailable. */
|
|
53
|
+
exports.RELAY_REPLY = /^(denied|already_decided|expired|not_pending|refused:[a-z0-9_]{1,64})$/;
|
|
54
|
+
exports.RELAY_UNAVAILABLE = "refused:relay_unavailable";
|
|
55
|
+
/**
|
|
56
|
+
* The Telegram process took the answer but didn't reply in time, usually because a tap holds the approval's lock. The
|
|
57
|
+
* deny may still land, so this is not a refusal: the sender should tell Ari to check the card.
|
|
58
|
+
*/
|
|
59
|
+
exports.RELAY_TIMED_OUT = "timed_out";
|
|
60
|
+
/** The one reply for a sender that isn't the owner route's peer, so nobody else learns how the relay is set up. */
|
|
61
|
+
exports.RELAY_REFUSED = "refused";
|
|
62
|
+
/** Deciding waits for the approval's lock, so give it time, but never hang a request. */
|
|
63
|
+
exports.RELAY_FORWARD_TIMEOUT_MS = 30_000;
|
|
64
|
+
/** A reply line is a few dozen bytes; anything longer than this isn't one. */
|
|
65
|
+
exports.MAX_RELAY_REPLY_BYTES = 1024;
|
|
66
|
+
async function forwardApprovalAnswer(input) {
|
|
67
|
+
const reply = await new Promise((resolve) => {
|
|
68
|
+
let data = "";
|
|
69
|
+
let sent = false;
|
|
70
|
+
let settled = false;
|
|
71
|
+
const finish = (value) => {
|
|
72
|
+
if (settled)
|
|
73
|
+
return;
|
|
74
|
+
settled = true;
|
|
75
|
+
socket.destroy();
|
|
76
|
+
resolve(value);
|
|
77
|
+
};
|
|
78
|
+
const socket = net.createConnection(input.socketPath);
|
|
79
|
+
socket.setEncoding("utf8");
|
|
80
|
+
/* v8 ignore next -- a local socket connects or fails at once, so a timeout before connect is a guard only @preserve */
|
|
81
|
+
socket.setTimeout(input.timeoutMs ?? exports.RELAY_FORWARD_TIMEOUT_MS, () => finish(sent ? exports.RELAY_TIMED_OUT : exports.RELAY_UNAVAILABLE));
|
|
82
|
+
socket.on("connect", () => { sent = true; socket.write(`${JSON.stringify({ message: input.message })}\n`); });
|
|
83
|
+
socket.on("data", (chunk) => {
|
|
84
|
+
data += chunk;
|
|
85
|
+
const newline = data.indexOf("\n");
|
|
86
|
+
if (newline < 0) {
|
|
87
|
+
if (data.length > exports.MAX_RELAY_REPLY_BYTES)
|
|
88
|
+
finish(exports.RELAY_UNAVAILABLE);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
let parsed;
|
|
92
|
+
try {
|
|
93
|
+
parsed = JSON.parse(data.slice(0, newline)).reply;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
parsed = undefined;
|
|
97
|
+
}
|
|
98
|
+
finish(typeof parsed === "string" && exports.RELAY_REPLY.test(parsed) ? parsed : exports.RELAY_UNAVAILABLE);
|
|
99
|
+
});
|
|
100
|
+
socket.on("close", () => finish(exports.RELAY_UNAVAILABLE));
|
|
101
|
+
socket.on("error", () => finish(exports.RELAY_UNAVAILABLE));
|
|
102
|
+
});
|
|
103
|
+
// The level is worked out first: the nerves source scanner reads a call's object only up to its first "})".
|
|
104
|
+
const level = reply === exports.RELAY_UNAVAILABLE || reply === exports.RELAY_TIMED_OUT ? "warn" : "info";
|
|
105
|
+
(0, runtime_1.emitNervesEvent)({
|
|
106
|
+
level,
|
|
107
|
+
component: "channels",
|
|
108
|
+
event: "channel.a2a_approval_answer_forwarded",
|
|
109
|
+
message: "forwarded a relayed approval answer to the Telegram sense",
|
|
110
|
+
meta: { reply },
|
|
111
|
+
});
|
|
112
|
+
return reply;
|
|
113
|
+
}
|
package/dist/a2a/server.js
CHANGED
|
@@ -37,6 +37,7 @@ exports.ESCALATION_CONFIRM_INTERVAL_MS = exports.A2A_TURN_TIMEOUT_MS = void 0;
|
|
|
37
37
|
exports.a2aChatRelationship = a2aChatRelationship;
|
|
38
38
|
exports.commandIdFor = commandIdFor;
|
|
39
39
|
exports.startA2AServer = startA2AServer;
|
|
40
|
+
const approval_relay_forward_1 = require("./approval-relay-forward");
|
|
40
41
|
const http = __importStar(require("node:http"));
|
|
41
42
|
const node_crypto_1 = require("node:crypto");
|
|
42
43
|
const a2a_client_1 = require("@ouro.bot/friends/a2a-client");
|
|
@@ -462,6 +463,38 @@ async function startA2AServer(options) {
|
|
|
462
463
|
};
|
|
463
464
|
// The message/send branch as one function, so a sealed message that arrives through the relay inbox runs exactly the
|
|
464
465
|
// path a direct POST runs. `req` is absent for a relayed message: there are no HTTP headers to take a sender hint from.
|
|
466
|
+
/**
|
|
467
|
+
* A verified message carrying a signed `approvalAnswer`: forward it to the Telegram sense, which opens and checks it
|
|
468
|
+
* again, and send back its one-word outcome, sealed to the sender. It is never journaled and never reaches a model
|
|
469
|
+
* (review L4). Only the owner route's peer is forwarded; anyone else hears one generic `refused`. Everything that
|
|
470
|
+
* could fail is checked before forwarding, so a sender always hears whether a forwarded deny landed.
|
|
471
|
+
*/
|
|
472
|
+
const answerRelayedApproval = async (rpcId, inbound, senderDid, conversationId, responseStyle) => {
|
|
473
|
+
// receiveShare pinned the sender before it reported the message as completed.
|
|
474
|
+
const pinned = inboundShareDeps.pinStore.get(senderDid);
|
|
475
|
+
let routeDid;
|
|
476
|
+
try {
|
|
477
|
+
routeDid = (options.approvalRelayPeerDid ?? (() => (0, identity_1.loadAgentConfig)({ agentName: options.agentName, agentRoot }).senses?.telegram.ownerNoticesTo?.did))();
|
|
478
|
+
}
|
|
479
|
+
catch {
|
|
480
|
+
routeDid = undefined;
|
|
481
|
+
}
|
|
482
|
+
const fromRoute = routeDid !== undefined && routeDid === senderDid;
|
|
483
|
+
if (!fromRoute)
|
|
484
|
+
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "channels", event: "channel.a2a_approval_answer_not_from_route", message: "refused an approval answer from a sender that isn't the owner route's peer", meta: { senderDid } });
|
|
485
|
+
const reply = fromRoute
|
|
486
|
+
? await (options.forwardApprovalAnswer ?? approval_relay_forward_1.forwardApprovalAnswer)({ socketPath: (0, approval_relay_forward_1.approvalRelaySocketPath)(agentRoot), message: inbound })
|
|
487
|
+
: approval_relay_forward_1.RELAY_REFUSED;
|
|
488
|
+
// The signed conversation id, never the outer contextId: friends has already held it to its length limit.
|
|
489
|
+
const responseParts = (0, sealed_chat_1.sealChatMessage)({
|
|
490
|
+
sodium: inboundShareDeps.sodium, from: options.identity, recipientDid: senderDid, recipientEd25519Pub: pinned.ed25519Pub,
|
|
491
|
+
text: reply, ...(conversationId ? { conversationId } : {}),
|
|
492
|
+
}).parts;
|
|
493
|
+
const accessToken = (0, node_crypto_1.randomUUID)();
|
|
494
|
+
const task = taskFor({ taskId: (0, node_crypto_1.randomUUID)(), accessTokenHash: accessTokenHash(accessToken), contextId: inbound.contextId ?? "default", inbound, state: "TASK_STATE_COMPLETED", response: reply, responseParts });
|
|
495
|
+
taskStore.put(task, accessTokenScope(accessToken));
|
|
496
|
+
return jsonResponse(rpcId, publicTask(task, accessToken, responseStyle, true));
|
|
497
|
+
};
|
|
465
498
|
const handleMessageSend = async (rpc, req, origin = "direct") => {
|
|
466
499
|
const responseStyle = rpc.method === "message/send" ? "legacy" : "latest";
|
|
467
500
|
const parsedInbound = messageFromParams(rpc.params);
|
|
@@ -518,6 +551,10 @@ async function startA2AServer(options) {
|
|
|
518
551
|
if (bridged.outcome === "completed") {
|
|
519
552
|
verifiedPeerAgentId = bridged.verifiedDid;
|
|
520
553
|
verifiedPeerName = bridged.verifiedDid;
|
|
554
|
+
if (bridged.message?.approvalAnswer) {
|
|
555
|
+
// An approval answer is never a turn: the Telegram sense, which owns the cards, checks and decides it.
|
|
556
|
+
return answerRelayedApproval(rpc.id, inbound, bridged.verifiedDid, bridged.message.conversationId, responseStyle);
|
|
557
|
+
}
|
|
521
558
|
if (bridged.message) {
|
|
522
559
|
// Authenticated chat: the signed, sealed text IS the turn.
|
|
523
560
|
verifiedShareText = bridged.message.text;
|
|
@@ -33,10 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.RELAY_SOCKET_IDLE_TIMEOUT_MS = exports.MAX_RELAY_CONNECTIONS = exports.MAX_SOCKET_PATH_BYTES = void 0;
|
|
36
|
+
exports.RELAY_SOCKET_IDLE_TIMEOUT_MS = exports.MAX_RELAY_CONNECTIONS = exports.MAX_SOCKET_PATH_BYTES = exports.approvalRelaySocketPath = void 0;
|
|
37
37
|
exports.relayAnswerSeenLedger = relayAnswerSeenLedger;
|
|
38
38
|
exports.handleRelayedApprovalAnswer = handleRelayedApprovalAnswer;
|
|
39
|
-
exports.approvalRelaySocketPath = approvalRelaySocketPath;
|
|
40
39
|
exports.startApprovalRelaySocket = startApprovalRelaySocket;
|
|
41
40
|
exports.createApprovalRelayDoor = createApprovalRelayDoor;
|
|
42
41
|
/**
|
|
@@ -59,6 +58,7 @@ const net = __importStar(require("node:net"));
|
|
|
59
58
|
const path = __importStar(require("node:path"));
|
|
60
59
|
const a2a_client_1 = require("@ouro.bot/friends/a2a-client");
|
|
61
60
|
const approval_relay_1 = require("../a2a/approval-relay");
|
|
61
|
+
const approval_relay_forward_1 = require("../a2a/approval-relay-forward");
|
|
62
62
|
const identity_1 = require("../a2a/identity");
|
|
63
63
|
const operator_trust_1 = require("../a2a/operator-trust");
|
|
64
64
|
const identity_2 = require("../heart/identity");
|
|
@@ -101,10 +101,8 @@ async function handleRelayedApprovalAnswer(deps, message) {
|
|
|
101
101
|
envelopeBindingId: opened.envelopeBindingId,
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
function
|
|
106
|
-
return path.join(agentRoot, "state", "approvals", "relay", "sock");
|
|
107
|
-
}
|
|
104
|
+
var approval_relay_forward_2 = require("../a2a/approval-relay-forward");
|
|
105
|
+
Object.defineProperty(exports, "approvalRelaySocketPath", { enumerable: true, get: function () { return approval_relay_forward_2.approvalRelaySocketPath; } });
|
|
108
106
|
const MAX_REQUEST_BYTES = 256 * 1024;
|
|
109
107
|
/** macOS takes a socket path of at most 104 bytes and mishandles a longer one, so a longer path is refused instead. */
|
|
110
108
|
exports.MAX_SOCKET_PATH_BYTES = 104;
|
|
@@ -232,7 +230,7 @@ function createApprovalRelayDoor(input) {
|
|
|
232
230
|
seen: relayAnswerSeenLedger(input.agentRoot),
|
|
233
231
|
};
|
|
234
232
|
server = await startApprovalRelaySocket({
|
|
235
|
-
socketPath: input.socketPath ?? approvalRelaySocketPath(input.agentRoot),
|
|
233
|
+
socketPath: input.socketPath ?? (0, approval_relay_forward_1.approvalRelaySocketPath)(input.agentRoot),
|
|
236
234
|
handle: (message) => handleRelayedApprovalAnswer(deps, message),
|
|
237
235
|
});
|
|
238
236
|
}
|
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.1411",
|
|
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.1411",
|
|
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.
|
|
3
|
+
"version": "0.1.0-alpha.1411",
|
|
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": {
|