@ouro.bot/cli 0.1.0-alpha.1390 → 0.1.0-alpha.1393
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 +12 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/a2a/refusals.js +2 -0
- package/dist/a2a/server.js +268 -38
- package/dist/repertoire/guardrails.js +2 -0
- package/dist/senses/a2a-entry.js +6 -2
- package/dist/senses/inbound-journal.js +182 -0
- package/dist/senses/shared-turn.js +3 -1
- package/node_modules/@ouro.bot/friends/README.md +17 -4
- package/node_modules/@ouro.bot/friends/actions/generated/mcp.json +1105 -0
- package/node_modules/@ouro.bot/friends/changelog.json +72 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/adapter.d.ts +1 -1
- package/node_modules/@ouro.bot/friends/dist/a2a-client/envelope-binding.d.ts +2 -2
- package/node_modules/@ouro.bot/friends/dist/a2a-client/envelope-binding.js +12 -8
- package/node_modules/@ouro.bot/friends/dist/channel.d.ts +5 -0
- package/node_modules/@ouro.bot/friends/dist/channel.js +12 -1
- package/node_modules/@ouro.bot/friends/dist/connect.js +8 -8
- package/node_modules/@ouro.bot/friends/dist/grant-store-file.d.ts +3 -0
- package/node_modules/@ouro.bot/friends/dist/grant-store-file.js +30 -9
- package/node_modules/@ouro.bot/friends/dist/grants.d.ts +5 -1
- package/node_modules/@ouro.bot/friends/dist/grants.js +22 -6
- package/node_modules/@ouro.bot/friends/dist/index.d.ts +3 -3
- package/node_modules/@ouro.bot/friends/dist/index.js +5 -2
- package/node_modules/@ouro.bot/friends/dist/link-identity.js +9 -9
- package/node_modules/@ouro.bot/friends/dist/mcp/bin.js +2 -1
- package/node_modules/@ouro.bot/friends/dist/mcp/dispatch.js +211 -16
- package/node_modules/@ouro.bot/friends/dist/mcp/run-main.js +24 -13
- package/node_modules/@ouro.bot/friends/dist/mcp/schemas.js +9 -431
- package/node_modules/@ouro.bot/friends/dist/mcp/server.js +2 -1
- package/node_modules/@ouro.bot/friends/dist/message.d.ts +19 -1
- package/node_modules/@ouro.bot/friends/dist/message.js +31 -1
- package/node_modules/@ouro.bot/friends/dist/mission-result.d.ts +7 -0
- package/node_modules/@ouro.bot/friends/dist/mission-result.js +14 -7
- package/node_modules/@ouro.bot/friends/dist/mission-store-file.js +8 -0
- package/node_modules/@ouro.bot/friends/dist/missions.js +6 -5
- package/node_modules/@ouro.bot/friends/dist/notes.js +4 -4
- package/node_modules/@ouro.bot/friends/dist/outcomes.js +1 -1
- package/node_modules/@ouro.bot/friends/dist/share.d.ts +6 -1
- package/node_modules/@ouro.bot/friends/dist/share.js +40 -4
- package/node_modules/@ouro.bot/friends/dist/store-file.js +28 -13
- package/node_modules/@ouro.bot/friends/dist/tokens.d.ts +3 -1
- package/node_modules/@ouro.bot/friends/dist/tokens.js +5 -2
- package/node_modules/@ouro.bot/friends/dist/trust-mutation.js +2 -2
- package/node_modules/@ouro.bot/friends/dist/types.d.ts +12 -0
- package/node_modules/@ouro.bot/friends/dist/util/safe-id.d.ts +1 -0
- package/node_modules/@ouro.bot/friends/dist/util/safe-id.js +10 -0
- package/node_modules/@ouro.bot/friends/package.json +2 -1
- package/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
|
@@ -0,0 +1,182 @@
|
|
|
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.INBOUND_OUTCOME_RETENTION_MS = exports.MAX_INBOUND_ATTEMPTS = void 0;
|
|
37
|
+
exports.readInboundOutcome = readInboundOutcome;
|
|
38
|
+
exports.openInboundJournal = openInboundJournal;
|
|
39
|
+
const node_crypto_1 = require("node:crypto");
|
|
40
|
+
const fs = __importStar(require("node:fs"));
|
|
41
|
+
const path = __importStar(require("node:path"));
|
|
42
|
+
const atomic_file_1 = require("../heart/atomic-file");
|
|
43
|
+
const runtime_1 = require("../nerves/runtime");
|
|
44
|
+
/**
|
|
45
|
+
* The shared inbound rule every sense follows (the rule iMessage got on 2026-11-22): an inbound message is
|
|
46
|
+
* written here before its turn runs, and leaves only when its one outcome is recorded. A process that dies
|
|
47
|
+
* mid-turn leaves it pending, and the next process replays it or records why it can't. Each sense keeps a
|
|
48
|
+
* thin adapter that decides what "replay" means for its transport.
|
|
49
|
+
*/
|
|
50
|
+
/** How many turns a sense starts for one inbound before it records a failure instead of trying again. */
|
|
51
|
+
exports.MAX_INBOUND_ATTEMPTS = 3;
|
|
52
|
+
/** How long an inbound's recorded outcome is kept, so a late copy of it is not taken for a new message. */
|
|
53
|
+
exports.INBOUND_OUTCOME_RETENTION_MS = 30 * 24 * 60 * 60_000;
|
|
54
|
+
/** Counts inbounds recorded by this process; see PendingInbound.sequence. */
|
|
55
|
+
let recordSequence = 0;
|
|
56
|
+
function journalDir(agentRoot, sense) {
|
|
57
|
+
return path.join(agentRoot, "state", "senses", sense);
|
|
58
|
+
}
|
|
59
|
+
function fileName(id) {
|
|
60
|
+
return `${(0, node_crypto_1.createHash)("sha256").update(id).digest("hex")}.json`;
|
|
61
|
+
}
|
|
62
|
+
function readJson(filePath) {
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function listJson(dir) {
|
|
71
|
+
try {
|
|
72
|
+
return fs.readdirSync(dir).filter((name) => name.endsWith(".json")).map((name) => path.join(dir, name));
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** The recorded outcome of one inbound, or null when it has none (still pending, never seen, or past retention). */
|
|
79
|
+
function readInboundOutcome(agentRoot, sense, id) {
|
|
80
|
+
return readJson(path.join(journalDir(agentRoot, sense), "inbound-outcomes", fileName(id)));
|
|
81
|
+
}
|
|
82
|
+
function openInboundJournal(agentRoot, sense, options = {}) {
|
|
83
|
+
const now = options.now ?? Date.now;
|
|
84
|
+
const pendingDir = path.join(journalDir(agentRoot, sense), "pending-inbound");
|
|
85
|
+
const outcomesDir = path.join(journalDir(agentRoot, sense), "inbound-outcomes");
|
|
86
|
+
fs.mkdirSync(pendingDir, { recursive: true });
|
|
87
|
+
fs.mkdirSync(outcomesDir, { recursive: true });
|
|
88
|
+
const cutoff = now() - exports.INBOUND_OUTCOME_RETENTION_MS;
|
|
89
|
+
for (const file of listJson(outcomesDir)) {
|
|
90
|
+
const outcome = readJson(file);
|
|
91
|
+
if (!outcome || Date.parse(outcome.settledAt) < cutoff)
|
|
92
|
+
fs.rmSync(file, { force: true });
|
|
93
|
+
}
|
|
94
|
+
const pendingPath = (id) => path.join(pendingDir, fileName(id));
|
|
95
|
+
const outcomePath = (id) => path.join(outcomesDir, fileName(id));
|
|
96
|
+
const get = (id) => {
|
|
97
|
+
if (fs.existsSync(outcomePath(id)))
|
|
98
|
+
return null;
|
|
99
|
+
return readJson(pendingPath(id));
|
|
100
|
+
};
|
|
101
|
+
const update = (id, change) => {
|
|
102
|
+
const entry = get(id);
|
|
103
|
+
if (!entry)
|
|
104
|
+
return null;
|
|
105
|
+
const next = change(entry);
|
|
106
|
+
(0, atomic_file_1.writeJsonAtomicSync)(pendingPath(id), next);
|
|
107
|
+
return next;
|
|
108
|
+
};
|
|
109
|
+
const pending = () => {
|
|
110
|
+
const entries = [];
|
|
111
|
+
for (const file of listJson(pendingDir)) {
|
|
112
|
+
const entry = readJson(file);
|
|
113
|
+
if (!entry || typeof entry.id !== "string")
|
|
114
|
+
continue;
|
|
115
|
+
// Settled just before a crash: the outcome stands and the leftover pending copy goes.
|
|
116
|
+
if (fs.existsSync(outcomePath(entry.id))) {
|
|
117
|
+
fs.rmSync(file, { force: true });
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
entries.push(entry);
|
|
121
|
+
}
|
|
122
|
+
const sequenceOf = (entry) => entry.sequence ?? 0;
|
|
123
|
+
return entries.sort((a, b) => a.receivedAt.localeCompare(b.receivedAt) || sequenceOf(a) - sequenceOf(b));
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
record(id, payload) {
|
|
127
|
+
const existing = get(id);
|
|
128
|
+
if (existing)
|
|
129
|
+
return existing;
|
|
130
|
+
const settled = readJson(outcomePath(id));
|
|
131
|
+
if (settled) {
|
|
132
|
+
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.inbound_duplicate", message: "an inbound that already has an outcome arrived again; it is not run again", meta: { sense, id, outcome: settled.outcome } });
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
recordSequence += 1;
|
|
136
|
+
const entry = { id, sense, receivedAt: new Date(now()).toISOString(), sequence: recordSequence, attempts: 0, spoke: false, payload };
|
|
137
|
+
(0, atomic_file_1.writeJsonAtomicSync)(pendingPath(id), entry);
|
|
138
|
+
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.inbound_recorded", message: "recorded an inbound before its turn", meta: { sense, id } });
|
|
139
|
+
return entry;
|
|
140
|
+
},
|
|
141
|
+
get,
|
|
142
|
+
beginAttempt(id) {
|
|
143
|
+
return update(id, (entry) => ({ ...entry, attempts: entry.attempts + 1 }))?.attempts ?? 0;
|
|
144
|
+
},
|
|
145
|
+
refundAttempt(id) {
|
|
146
|
+
update(id, (entry) => ({ ...entry, attempts: Math.max(0, entry.attempts - 1) }));
|
|
147
|
+
},
|
|
148
|
+
markSpoke(id) {
|
|
149
|
+
update(id, (entry) => ({ ...entry, spoke: true }));
|
|
150
|
+
},
|
|
151
|
+
settle(id, outcome, detail) {
|
|
152
|
+
const entry = get(id);
|
|
153
|
+
if (!entry)
|
|
154
|
+
return false;
|
|
155
|
+
const record = {
|
|
156
|
+
id,
|
|
157
|
+
sense,
|
|
158
|
+
receivedAt: entry.receivedAt,
|
|
159
|
+
settledAt: new Date(now()).toISOString(),
|
|
160
|
+
outcome,
|
|
161
|
+
attempts: entry.attempts,
|
|
162
|
+
...(detail ? { detail } : {}),
|
|
163
|
+
};
|
|
164
|
+
// The outcome file is the record; the pending copy is removed only after it has landed.
|
|
165
|
+
(0, atomic_file_1.writeJsonAtomicSync)(outcomePath(id), record);
|
|
166
|
+
fs.rmSync(pendingPath(id), { force: true });
|
|
167
|
+
(0, runtime_1.emitNervesEvent)({
|
|
168
|
+
level: outcome === "failed" ? "error" : "info",
|
|
169
|
+
component: "senses",
|
|
170
|
+
event: "senses.inbound_settled",
|
|
171
|
+
message: outcome === "failed" ? "recorded a visible failure for an inbound" : "recorded an inbound's outcome",
|
|
172
|
+
meta: { sense, id, outcome, attempts: entry.attempts, ...(detail ? { detail } : {}) },
|
|
173
|
+
});
|
|
174
|
+
return true;
|
|
175
|
+
},
|
|
176
|
+
pending,
|
|
177
|
+
oldestPendingAgeMs() {
|
|
178
|
+
const oldest = pending()[0];
|
|
179
|
+
return oldest ? Math.max(0, now() - Date.parse(oldest.receivedAt)) : null;
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
@@ -356,7 +356,9 @@ function getSenseSessionPath(agentName, friendId, channel, sessionKey, agentRoot
|
|
|
356
356
|
*/
|
|
357
357
|
async function runSenseTurn(options) {
|
|
358
358
|
options = { ...options, ...(options.shepherdSession ? { shepherdSession: Object.freeze({ ...options.shepherdSession }) } : {}) };
|
|
359
|
+
const queueSignal = options.stopQueueWaitOnAbort ? options.signal : undefined;
|
|
359
360
|
return (0, turn_execution_lease_1.withTurnExecutionLease)(async () => {
|
|
361
|
+
options.onTurnStart?.();
|
|
360
362
|
const owner = Object.freeze({ agentName: options.agentName, agentRoot: (0, identity_1.getAgentRoot)(options.agentName) });
|
|
361
363
|
(0, identity_1.setAgentName)(owner.agentName);
|
|
362
364
|
try {
|
|
@@ -367,7 +369,7 @@ async function runSenseTurn(options) {
|
|
|
367
369
|
await releaseRuntimeMcpServersAfterTurn(owner);
|
|
368
370
|
}
|
|
369
371
|
}
|
|
370
|
-
});
|
|
372
|
+
}, queueSignal);
|
|
371
373
|
}
|
|
372
374
|
async function runSenseTurnExclusive(options, owner) {
|
|
373
375
|
const { channel, sessionKey, friendId } = options;
|
|
@@ -124,10 +124,23 @@ Because it is signed, a recipient who opens a message cannot re-seal the same si
|
|
|
124
124
|
third party, and a relabelled kind fails. `receiveShare` (and `checkEnvelopeBinding`, for hosts with
|
|
125
125
|
their own receive path) rejects with `signed_recipient_mismatch`, `signed_kind_mismatch`,
|
|
126
126
|
`malformed_binding` or `replayed` (same `mid:<sender>:<id>`). Every envelope must also be fresh:
|
|
127
|
-
`issuedAt` (ISO-8601 with a zone) at most 7 days old, and an envelope carrying `onBehalfOf`
|
|
128
|
-
10 minutes old (`stale_envelope` / `stale_delegation`
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
`issuedAt` (ISO-8601 with a zone) at most 7 days old, and an envelope carrying `onBehalfOf` or
|
|
128
|
+
`approvalAnswer` at most 10 minutes old (`stale_envelope` / `stale_delegation` /
|
|
129
|
+
`stale_approval_answer`), with 2 minutes of clock skew allowed. An envelope with no `binding` (an
|
|
130
|
+
older sender) is accepted with `bound: false` unless it is a delegated command
|
|
131
|
+
(`unbound_delegation`), an approval answer (`unbound_approval_answer`) or the host sets
|
|
132
|
+
`rejectUnboundEnvelopes` (`unbound_envelope`).
|
|
133
|
+
|
|
134
|
+
**Approval answers.** A message may carry a signed `approvalAnswer: { relayToken, decision }`, where
|
|
135
|
+
`relayToken` is 16 to 128 base64url characters and `decision` is `deny`, the only decision this
|
|
136
|
+
version accepts: a receiver refuses any other as malformed, so allowing `approve` takes a new
|
|
137
|
+
release. It is signed with the text, so a relay can neither add, strip nor change it, and it claims
|
|
138
|
+
nothing on its own: the recipient matches the token against an approval it routed to that sender.
|
|
139
|
+
`prepareMessage` refuses a malformed answer, or one combined with `onBehalfOf`, as
|
|
140
|
+
`invalid_approval_answer`; `receiveMessage` refuses the same as `malformed_message`, and refuses
|
|
141
|
+
any answer as `untrusted_source` when it is given no verifier or `tofuVerifier` (neither checks a signature).
|
|
142
|
+
`checkEnvelopeBinding` refuses an answer on any kind but `message` as `malformed_binding`. Only
|
|
143
|
+
harness code should set it, never a model-facing tool.
|
|
131
144
|
A completed result carries the signed `bindingId`. `checkEnvelopeBinding` is check-only: a host
|
|
132
145
|
with its own receive path must hold an in-memory claim across its own awaits, and mark the returned
|
|
133
146
|
`seenKey` (and its blob key) in the ledger only after the signature verifies. `receiveShare` does
|