@ouro.bot/cli 0.1.0-alpha.1393 → 0.1.0-alpha.1394
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,12 @@
|
|
|
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.1394",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Groundwork for relaying Ari's approval answers: the relay token, the trust-folder switch and a store method for a relayed deny. Nothing uses them yet."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
4
10
|
{
|
|
5
11
|
"version": "0.1.0-alpha.1393",
|
|
6
12
|
"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.1394</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,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MIN_RELAY_KEY_LENGTH = exports.APPROVAL_RELAY_FILE = void 0;
|
|
4
|
+
exports.approvalRelayToken = approvalRelayToken;
|
|
5
|
+
exports.relayTokensEqual = relayTokensEqual;
|
|
6
|
+
exports.checkRelayedDecision = checkRelayedDecision;
|
|
7
|
+
exports.readApprovalRelaySwitch = readApprovalRelaySwitch;
|
|
8
|
+
/**
|
|
9
|
+
* The approval relay: Ari answers a tool approval by replying to his primary agent (the owner route's peer) instead of
|
|
10
|
+
* tapping the Telegram card, and that agent's harness sends the answer back as a signed `approvalAnswer`.
|
|
11
|
+
*
|
|
12
|
+
* This file holds the pieces that do no I/O beyond reading the operator's switch:
|
|
13
|
+
* - the relay token, which binds an answer to one approval and one route DID;
|
|
14
|
+
* - the trust-folder switch, which turns the relay on;
|
|
15
|
+
* - the v1 rule that only `deny` is relayed.
|
|
16
|
+
*
|
|
17
|
+
* Design: desk sanctuary-server/butler-productionization/ouroboros/2026-11-23-signed-relay-design-v3.md.
|
|
18
|
+
*/
|
|
19
|
+
const node_crypto_1 = require("node:crypto");
|
|
20
|
+
const runtime_1 = require("../nerves/runtime");
|
|
21
|
+
const operator_trust_1 = require("./operator-trust");
|
|
22
|
+
const trusted_files_1 = require("./trusted-files");
|
|
23
|
+
/** The Butler's switch, in its operator trust folder. Root-owned, so neither the agent nor its shell can turn it on. */
|
|
24
|
+
exports.APPROVAL_RELAY_FILE = "approval-relay.json";
|
|
25
|
+
const DOMAIN = "ouro.approval-relay.v1\0";
|
|
26
|
+
/** A decision token is 32 random bytes in base64url (43 characters); anything under 32 characters isn't one. */
|
|
27
|
+
exports.MIN_RELAY_KEY_LENGTH = 32;
|
|
28
|
+
const DID = /^did:[a-z0-9]+:[A-Za-z0-9._:%-]{1,512}$/;
|
|
29
|
+
const ISO = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?Z$/;
|
|
30
|
+
/**
|
|
31
|
+
* `HMAC-SHA256(decisionToken, "ouro.approval-relay.v1\0" || approvalId || "\0" || routeDid)`, base64url. The decision
|
|
32
|
+
* token is the approval's own secret, so only the Butler can compute it, and the route DID means an outstanding token
|
|
33
|
+
* stops matching once the route rotates. It refuses to compute with an empty or short key (a settled approval has no
|
|
34
|
+
* token, and a short one isn't a decision token).
|
|
35
|
+
* Never log it.
|
|
36
|
+
*/
|
|
37
|
+
function approvalRelayToken(input) {
|
|
38
|
+
const parts = [input.decisionToken, input.approvalId, input.routeDid];
|
|
39
|
+
if (parts.some((part) => typeof part !== "string" || part.length === 0 || part.includes("\0"))
|
|
40
|
+
|| input.decisionToken.length < exports.MIN_RELAY_KEY_LENGTH) {
|
|
41
|
+
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.approval_relay_token_refused", message: "refused to compute an approval relay token without a decision token, approval id and route DID", meta: { reason: "missing_input" } });
|
|
42
|
+
throw new Error("approval relay token needs a decision token, an approval id and a route DID");
|
|
43
|
+
}
|
|
44
|
+
return (0, node_crypto_1.createHmac)("sha256", input.decisionToken).update(`${DOMAIN}${input.approvalId}\0${input.routeDid}`).digest("base64url");
|
|
45
|
+
}
|
|
46
|
+
/** Constant-time comparison of two relay tokens. Empty or non-string never matches. */
|
|
47
|
+
function relayTokensEqual(a, b) {
|
|
48
|
+
if (typeof a !== "string" || typeof b !== "string" || a.length === 0)
|
|
49
|
+
return false;
|
|
50
|
+
const left = Buffer.from(a);
|
|
51
|
+
const right = Buffer.from(b);
|
|
52
|
+
return left.length === right.length && (0, node_crypto_1.timingSafeEqual)(left, right);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* v1 relays `deny` only. Approve is refused here in code, before any switch or list is read, so allowing it later means
|
|
56
|
+
* changing code (and friends, whose `approvalAnswer` also takes deny only), not editing a file.
|
|
57
|
+
*/
|
|
58
|
+
function checkRelayedDecision(decision) {
|
|
59
|
+
if (decision === "deny")
|
|
60
|
+
return { ok: true, decision: "deny" };
|
|
61
|
+
const reason = decision === "approve" ? "approve_not_in_v1" : "unknown_decision";
|
|
62
|
+
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.approval_relay_decision_refused", message: "refused a relayed approval decision v1 does not relay", meta: { reason } });
|
|
63
|
+
return { ok: false, reason };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Reads `{ schemaVersion: 1, did, expiresAt, approveTools, source }` from the operator trust folder. Missing,
|
|
67
|
+
* untrusted, malformed or expired is off. `approveTools` must be a list of names but is never returned: v1 relays deny
|
|
68
|
+
* only, whatever it lists. A copy anywhere under the bundle is never read.
|
|
69
|
+
*/
|
|
70
|
+
function readApprovalRelaySwitch(agentRoot, now = new Date()) {
|
|
71
|
+
const raw = (0, trusted_files_1.inspectTrustedJson)((0, operator_trust_1.operatorTrustFile)(agentRoot, exports.APPROVAL_RELAY_FILE));
|
|
72
|
+
if (raw.state === "missing")
|
|
73
|
+
return { on: false, reason: "missing" };
|
|
74
|
+
if (raw.state === "untrusted")
|
|
75
|
+
return off("untrusted", raw.reason);
|
|
76
|
+
const value = raw.value;
|
|
77
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
78
|
+
return off("malformed");
|
|
79
|
+
const v = value;
|
|
80
|
+
const valid = Object.keys(v).sort().join(",") === "approveTools,did,expiresAt,schemaVersion,source"
|
|
81
|
+
&& v.schemaVersion === 1
|
|
82
|
+
&& typeof v.did === "string" && DID.test(v.did)
|
|
83
|
+
&& typeof v.expiresAt === "string" && ISO.test(v.expiresAt) && Number.isFinite(Date.parse(v.expiresAt))
|
|
84
|
+
&& Array.isArray(v.approveTools) && v.approveTools.every((tool) => typeof tool === "string")
|
|
85
|
+
&& typeof v.source === "string" && v.source.trim().length > 0;
|
|
86
|
+
if (!valid)
|
|
87
|
+
return off("malformed");
|
|
88
|
+
if (now.getTime() >= Date.parse(v.expiresAt))
|
|
89
|
+
return off("expired");
|
|
90
|
+
return { on: true, did: v.did, expiresAt: v.expiresAt, source: v.source };
|
|
91
|
+
}
|
|
92
|
+
function off(reason, detail) {
|
|
93
|
+
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.approval_relay_switch_off", message: "the approval relay switch is off because its trust-folder file can't be used", meta: { reason, ...(detail ? { detail } : {}) } });
|
|
94
|
+
return { on: false, reason, ...(detail ? { detail } : {}) };
|
|
95
|
+
}
|
|
@@ -123,7 +123,9 @@ function canonicalApprovalArguments(value) {
|
|
|
123
123
|
}
|
|
124
124
|
function hasExactKeys(value) {
|
|
125
125
|
const actual = Object.keys(value).sort();
|
|
126
|
-
const expected = [
|
|
126
|
+
const expected = [
|
|
127
|
+
...RECORD_KEYS, ...("ownerBinding" in value ? ["ownerBinding"] : []), ...("relayDecision" in value ? ["relayDecision"] : []),
|
|
128
|
+
].sort();
|
|
127
129
|
return actual.length === expected.length && actual.every((key, index) => key === expected[index]);
|
|
128
130
|
}
|
|
129
131
|
function validOwnerBinding(value) {
|
|
@@ -131,6 +133,10 @@ function validOwnerBinding(value) {
|
|
|
131
133
|
&& ["friendId", "requestId", "sessionEventId", "sessionKey"].every((key) => isNonEmpty(value[key]) && value[key] === value[key].trim())
|
|
132
134
|
&& typeof value.profileVersion === "number" && Number.isSafeInteger(value.profileVersion) && value.profileVersion > 0;
|
|
133
135
|
}
|
|
136
|
+
function validRelayDecision(value) {
|
|
137
|
+
return isObject(value) && Object.keys(value).sort().join(",") === "actor,decidedAt,envelopeBindingId,senderDid"
|
|
138
|
+
&& value.actor === "owner-via-relay" && isNonEmpty(value.senderDid) && isNonEmpty(value.envelopeBindingId) && isTimestamp(value.decidedAt);
|
|
139
|
+
}
|
|
134
140
|
function validStateShape(record) {
|
|
135
141
|
const hasOwner = isNonEmpty(record.ownerId);
|
|
136
142
|
const hasAttempt = isTimestamp(record.attemptedAt);
|
|
@@ -200,6 +206,8 @@ function parseApprovalRecord(value) {
|
|
|
200
206
|
fail("corrupt_record");
|
|
201
207
|
if ("ownerBinding" in value && !validOwnerBinding(value.ownerBinding))
|
|
202
208
|
fail("corrupt_record");
|
|
209
|
+
if ("relayDecision" in value && (!validRelayDecision(value.relayDecision) || value.state !== "denied"))
|
|
210
|
+
fail("corrupt_record");
|
|
203
211
|
const record = value;
|
|
204
212
|
if (!UUID.test(record.approvalId))
|
|
205
213
|
fail("corrupt_record");
|
|
@@ -325,6 +333,17 @@ function observeDecide(operation) {
|
|
|
325
333
|
throw error;
|
|
326
334
|
}
|
|
327
335
|
}
|
|
336
|
+
function observeDecideRelayed(operation) {
|
|
337
|
+
try {
|
|
338
|
+
const result = operation();
|
|
339
|
+
(0, runtime_1.emitNervesEvent)({ component: "heart", event: "approval.store_decide_relayed", message: "relayed approval decision completed", meta: { operation: "decide_relayed", outcome: "success" } });
|
|
340
|
+
return result;
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
(0, runtime_1.emitNervesEvent)({ level: "error", component: "heart", event: "approval.store_decide_relayed", message: "relayed approval decision failed", meta: operationErrorMeta("decide_relayed", error) });
|
|
344
|
+
throw error;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
328
347
|
function observeExpire(operation) {
|
|
329
348
|
try {
|
|
330
349
|
const result = operation();
|
|
@@ -691,6 +710,30 @@ function openApprovalStore(options) {
|
|
|
691
710
|
return cas(previous, { ...previous, state: "claimed", ownerId: input.ownerId, epoch: previous.epoch + 1, updatedAt: timestamp() });
|
|
692
711
|
});
|
|
693
712
|
},
|
|
713
|
+
decideRelayed(input) {
|
|
714
|
+
return observeDecideRelayed(() => {
|
|
715
|
+
if (input.decision !== "deny")
|
|
716
|
+
fail("relay_decision_not_allowed");
|
|
717
|
+
if (!isNonEmpty(input.senderDid) || !isNonEmpty(input.envelopeBindingId))
|
|
718
|
+
fail("invalid_relay_decision");
|
|
719
|
+
const previous = requireRecord(input.approvalId);
|
|
720
|
+
const decisionAt = now().getTime();
|
|
721
|
+
if (!tokenMatches(input.decisionToken, previous.decisionTokenDigest))
|
|
722
|
+
fail("decision_binding_mismatch");
|
|
723
|
+
if (previous.state === "denied" && previous.relayDecision?.envelopeBindingId === input.envelopeBindingId
|
|
724
|
+
&& previous.relayDecision.senderDid === input.senderDid)
|
|
725
|
+
return previous;
|
|
726
|
+
if (previous.state !== "proposed")
|
|
727
|
+
fail("decision_not_eligible");
|
|
728
|
+
if (decisionAt >= Date.parse(previous.expiresAt)) {
|
|
729
|
+
return cas(previous, { ...previous, state: "expired", updatedAt: timestamp() });
|
|
730
|
+
}
|
|
731
|
+
const relayDecision = {
|
|
732
|
+
actor: "owner-via-relay", senderDid: input.senderDid, envelopeBindingId: input.envelopeBindingId, decidedAt: timestamp(),
|
|
733
|
+
};
|
|
734
|
+
return cas(previous, { ...previous, state: "denied", relayDecision, updatedAt: timestamp() });
|
|
735
|
+
});
|
|
736
|
+
},
|
|
694
737
|
expire(input) {
|
|
695
738
|
return observeExpire(() => {
|
|
696
739
|
const previous = requireRecord(input.approvalId);
|
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.1394",
|
|
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.1394",
|
|
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.1394",
|
|
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": {
|