@ouro.bot/cli 0.1.0-alpha.1315 → 0.1.0-alpha.1316
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 +6 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/repertoire/tools-habits.js +17 -9
- package/dist/repertoire/tools-runtime.js +29 -7
- package/dist/repertoire/tools-steward-policy.js +25 -15
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
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.1316",
|
|
6
|
+
"changes": [
|
|
7
|
+
"restart_runtime, revive_sense, habit_cancel and steward_policy_manage carry Ouro AX cards, and their errors end with a code the card explains."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
4
10
|
{
|
|
5
11
|
"version": "0.1.0-alpha.1315",
|
|
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.1316</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -5,21 +5,22 @@ const friends_1 = require("@ouro.bot/friends");
|
|
|
5
5
|
const runtime_1 = require("../nerves/runtime");
|
|
6
6
|
const habit_cancel_1 = require("../heart/habits/habit-cancel");
|
|
7
7
|
const semantic_receipts_1 = require("../senses/bluebubbles/semantic-receipts");
|
|
8
|
+
const tools_base_1 = require("./tools-base");
|
|
8
9
|
const CAPTURE_LOCATOR_PATTERN = /^capture:([a-f0-9]{64})$/;
|
|
9
10
|
const ACTOR_AUTHORITY_ERROR = "habit_cancel requires trusted current-ingress actor authority";
|
|
10
11
|
async function requireTrustedCurrentIngressActor(agentRoot, captureKeyHash, context) {
|
|
11
12
|
const capture = (0, semantic_receipts_1.readBlueBubblesSemanticCaptureAtRoot)(agentRoot, captureKeyHash);
|
|
12
13
|
const actor = capture?.event.actor;
|
|
13
14
|
if (!actor || !context?.friendStore)
|
|
14
|
-
throw new Error(ACTOR_AUTHORITY_ERROR);
|
|
15
|
+
throw new Error((0, tools_base_1.withCode)(ACTOR_AUTHORITY_ERROR, "actor-not-trusted"));
|
|
15
16
|
try {
|
|
16
17
|
const friend = await context.friendStore.findByExternalId(actor.provider, actor.externalId);
|
|
17
18
|
if (!friends_1.TRUSTED_LEVELS.has(friend?.trustLevel ?? "stranger")) {
|
|
18
|
-
throw new Error(ACTOR_AUTHORITY_ERROR);
|
|
19
|
+
throw new Error((0, tools_base_1.withCode)(ACTOR_AUTHORITY_ERROR, "actor-not-trusted"));
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
catch {
|
|
22
|
-
throw new Error(ACTOR_AUTHORITY_ERROR);
|
|
23
|
+
throw new Error((0, tools_base_1.withCode)(ACTOR_AUTHORITY_ERROR, "actor-not-trusted"));
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
exports.habitToolDefinitions = [
|
|
@@ -67,13 +68,13 @@ exports.habitToolDefinitions = [
|
|
|
67
68
|
const keys = Object.keys(args);
|
|
68
69
|
const unexpected = keys.find((key) => key !== "habit" && key !== "evidence");
|
|
69
70
|
if (unexpected)
|
|
70
|
-
throw new Error(`unexpected habit_cancel argument: ${unexpected}
|
|
71
|
+
throw new Error((0, tools_base_1.withCode)(`unexpected habit_cancel argument: ${unexpected}`, "bad-argument"));
|
|
71
72
|
if (keys.length !== 2 || typeof args.habit !== "string" || args.habit.trim().length === 0) {
|
|
72
|
-
throw new Error("habit_cancel requires exactly habit and evidence");
|
|
73
|
+
throw new Error((0, tools_base_1.withCode)("habit_cancel requires exactly habit and evidence", "bad-argument"));
|
|
73
74
|
}
|
|
74
75
|
const match = CAPTURE_LOCATOR_PATTERN.exec(args.evidence);
|
|
75
76
|
if (!match)
|
|
76
|
-
throw new Error("habit_cancel evidence must use capture:<sha256>");
|
|
77
|
+
throw new Error((0, tools_base_1.withCode)("habit_cancel evidence must use capture:<sha256>", "bad-argument"));
|
|
77
78
|
const currentIngressEvidence = context?.currentIngressEvidence;
|
|
78
79
|
if (!currentIngressEvidence
|
|
79
80
|
|| Object.keys(currentIngressEvidence).length !== 3
|
|
@@ -81,12 +82,12 @@ exports.habitToolDefinitions = [
|
|
|
81
82
|
|| currentIngressEvidence.schemaVersion !== 1
|
|
82
83
|
|| currentIngressEvidence.provider !== "bluebubbles"
|
|
83
84
|
|| !/^[a-f0-9]{64}$/.test(currentIngressEvidence.captureKeyHash))
|
|
84
|
-
throw new Error("habit_cancel requires authoritative current ingress evidence");
|
|
85
|
+
throw new Error((0, tools_base_1.withCode)("habit_cancel requires authoritative current ingress evidence", "no-ingress-evidence"));
|
|
85
86
|
if (currentIngressEvidence.captureKeyHash !== match[1]) {
|
|
86
|
-
throw new Error("habit_cancel evidence mismatch with current ingress evidence");
|
|
87
|
+
throw new Error((0, tools_base_1.withCode)("habit_cancel evidence mismatch with current ingress evidence", "evidence-mismatch"));
|
|
87
88
|
}
|
|
88
89
|
if (!context?.agentRoot)
|
|
89
|
-
throw new Error("habit_cancel requires an agent root");
|
|
90
|
+
throw new Error((0, tools_base_1.withCode)("habit_cancel requires an agent root", "no-agent-root"));
|
|
90
91
|
await requireTrustedCurrentIngressActor(context.agentRoot, currentIngressEvidence.captureKeyHash, context);
|
|
91
92
|
const receipt = await (0, habit_cancel_1.cancelHabit)({
|
|
92
93
|
agentRoot: context.agentRoot,
|
|
@@ -99,5 +100,12 @@ exports.habitToolDefinitions = [
|
|
|
99
100
|
});
|
|
100
101
|
return receipt.acknowledgement;
|
|
101
102
|
},
|
|
103
|
+
ax: { id: "tool:habit_cancel", group: "turn-habits", when: "Pick this when the message that started this turn asks to stop a named habit for good, citing that message's own capture.", effect: "write", destructive: true, errors: [
|
|
104
|
+
{ code: "bad-argument", means: "An argument other than habit and evidence was passed, habit is empty, or evidence isn't capture:<sha256>.", fix: "Call again with only habit and evidence, with evidence set to this turn's capture locator." },
|
|
105
|
+
{ code: "no-ingress-evidence", means: "This turn didn't start from a captured BlueBubbles message, so nobody's request can authorize it.", fix: "Don't retry; a habit is cancelled only from the person's own message asking for it." },
|
|
106
|
+
{ code: "evidence-mismatch", means: "evidence names a different capture from the message that started this turn.", fix: "Pass this turn's own capture locator; an older message can't authorize a cancel." },
|
|
107
|
+
{ code: "actor-not-trusted", means: "The person who sent the message isn't a trusted friend, or can't be found.", fix: "Don't retry; tell them a trusted friend has to ask for it." },
|
|
108
|
+
{ code: "no-agent-root", means: "The runtime gave this turn no agent home, so no habit can be found.", fix: "Report it to the owner; this is a runtime fault, not something to retry." },
|
|
109
|
+
] },
|
|
102
110
|
},
|
|
103
111
|
];
|
|
@@ -40,6 +40,7 @@ const node_crypto_1 = require("node:crypto");
|
|
|
40
40
|
const identity_1 = require("../heart/identity");
|
|
41
41
|
const runtime_1 = require("../nerves/runtime");
|
|
42
42
|
const socket_client_1 = require("../heart/daemon/socket-client");
|
|
43
|
+
const tools_base_1 = require("./tools-base");
|
|
43
44
|
exports.RESTART_COOLDOWN_MS = 6 * 60 * 60 * 1000;
|
|
44
45
|
function restartCooldownPath(agentName) {
|
|
45
46
|
return path.join((0, identity_1.getAgentStateRoot)(agentName), "daemon", "restart-runtime-cooldown.json");
|
|
@@ -68,7 +69,7 @@ function recordRestart(agentName, nowMs) {
|
|
|
68
69
|
}
|
|
69
70
|
async function restartRuntime(args, agentName, ctx) {
|
|
70
71
|
if (typeof args.reason !== "string" || args.reason.trim().length === 0) {
|
|
71
|
-
return JSON.stringify({ error: "reason is required (one-line audit string)" });
|
|
72
|
+
return JSON.stringify({ error: "reason is required (one-line audit string)", code: "missing-reason" });
|
|
72
73
|
}
|
|
73
74
|
const reason = args.reason.trim();
|
|
74
75
|
if (ctx?.autonomousTurnKind) {
|
|
@@ -80,7 +81,7 @@ async function restartRuntime(args, agentName, ctx) {
|
|
|
80
81
|
});
|
|
81
82
|
return JSON.stringify({
|
|
82
83
|
refused: true,
|
|
83
|
-
code: "
|
|
84
|
+
code: "autonomous-restart-refused",
|
|
84
85
|
error: `restart_runtime is not allowed from an autonomous ${ctx.autonomousTurnKind} turn: restarting the daemon kills in-flight work for every agent and habit. A tool error or missing capability is not evidence of a dead runtime. Record or report the problem (note it, surface it to the owner) instead of restarting.`,
|
|
85
86
|
});
|
|
86
87
|
}
|
|
@@ -89,7 +90,7 @@ async function restartRuntime(args, agentName, ctx) {
|
|
|
89
90
|
if (lastMs !== null && lastMs <= nowMs && nowMs - lastMs < exports.RESTART_COOLDOWN_MS) {
|
|
90
91
|
return JSON.stringify({
|
|
91
92
|
refused: true,
|
|
92
|
-
code: "
|
|
93
|
+
code: "restart-cooldown",
|
|
93
94
|
error: `a restart was already requested ${Math.round((nowMs - lastMs) / 60000)} minutes ago; agent-requested restarts are limited to one per 6 hours. Record or report the problem instead.`,
|
|
94
95
|
retryAfterMs: exports.RESTART_COOLDOWN_MS - (nowMs - lastMs),
|
|
95
96
|
});
|
|
@@ -118,19 +119,20 @@ async function restartRuntime(args, agentName, ctx) {
|
|
|
118
119
|
catch (error) {
|
|
119
120
|
return JSON.stringify({
|
|
120
121
|
error: "failed to reach daemon socket",
|
|
122
|
+
code: "daemon-unreachable",
|
|
121
123
|
detail: error instanceof Error ? error.message : String(error),
|
|
122
124
|
});
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
async function reviveSense(args, agentName) {
|
|
126
128
|
if (args.agent !== undefined) {
|
|
127
|
-
return "cross-agent revive is unsupported; revive_sense can only revive this agent's own senses.";
|
|
129
|
+
return (0, tools_base_1.withCode)("cross-agent revive is unsupported; revive_sense can only revive this agent's own senses.", "cross-agent-unsupported");
|
|
128
130
|
}
|
|
129
131
|
if (typeof args.sense !== "string" || args.sense.trim().length === 0) {
|
|
130
|
-
return JSON.stringify({ error: "sense is required (for example, 'bluebubbles')" });
|
|
132
|
+
return JSON.stringify({ error: "sense is required (for example, 'bluebubbles')", code: "missing-sense" });
|
|
131
133
|
}
|
|
132
134
|
if (typeof args.reason !== "string" || args.reason.trim().length === 0) {
|
|
133
|
-
return JSON.stringify({ error: "reason is required (one-line audit string)" });
|
|
135
|
+
return JSON.stringify({ error: "reason is required (one-line audit string)", code: "missing-reason" });
|
|
134
136
|
}
|
|
135
137
|
const sense = args.sense.trim();
|
|
136
138
|
const reason = args.reason.trim();
|
|
@@ -151,6 +153,7 @@ async function reviveSense(args, agentName) {
|
|
|
151
153
|
if (response.error === "Unknown daemon command kind 'daemon.sense_revive'.") {
|
|
152
154
|
return JSON.stringify({
|
|
153
155
|
error: "daemon does not support this command; try restart_runtime",
|
|
156
|
+
code: "revive-unsupported",
|
|
154
157
|
detail: response.error,
|
|
155
158
|
agent: agentName,
|
|
156
159
|
sense,
|
|
@@ -158,6 +161,7 @@ async function reviveSense(args, agentName) {
|
|
|
158
161
|
}
|
|
159
162
|
return JSON.stringify({
|
|
160
163
|
error: response.error ?? "daemon failed to revive sense",
|
|
164
|
+
code: "revive-failed",
|
|
161
165
|
agent: agentName,
|
|
162
166
|
sense,
|
|
163
167
|
});
|
|
@@ -173,12 +177,15 @@ async function reviveSense(args, agentName) {
|
|
|
173
177
|
catch (error) {
|
|
174
178
|
return JSON.stringify({
|
|
175
179
|
error: "failed to reach daemon socket",
|
|
180
|
+
code: "daemon-unreachable",
|
|
176
181
|
detail: error instanceof Error ? error.message : String(error),
|
|
177
182
|
agent: agentName,
|
|
178
183
|
sense,
|
|
179
184
|
});
|
|
180
185
|
}
|
|
181
186
|
}
|
|
187
|
+
const MISSING_REASON_ERROR = { code: "missing-reason", means: "reason is empty; every restart or revive needs a one-line reason for the audit log.", fix: "Call again with reason saying what is wedged and since when." };
|
|
188
|
+
const DAEMON_UNREACHABLE_ERROR = { code: "daemon-unreachable", means: "The daemon's socket didn't answer, so no command reached it.", fix: "Don't retry in a loop; note the problem for the owner, since the daemon may already be down or restarting." };
|
|
182
189
|
exports.runtimeToolDefinitions = [
|
|
183
190
|
{
|
|
184
191
|
tool: {
|
|
@@ -203,6 +210,12 @@ exports.runtimeToolDefinitions = [
|
|
|
203
210
|
return restartRuntime({ reason: args.reason }, agentName, ctx);
|
|
204
211
|
},
|
|
205
212
|
riskProfile: { mutates: "external_side_effect", risk: "high", reason: "restarts the hosting runtime" },
|
|
213
|
+
ax: { id: "tool:restart_runtime", group: "turn-runtime", when: "Pick this only when the daemon itself is wedged for every chat, such as a jammed recovery queue; never for one failing tool.", effect: "write", errors: [
|
|
214
|
+
MISSING_REASON_ERROR,
|
|
215
|
+
{ code: "autonomous-restart-refused", means: "This is an autonomous turn, such as a habit, and a restart would kill every agent's in-flight work.", fix: "Don't restart; note the problem and surface it to the owner, who can restart from a conversation." },
|
|
216
|
+
{ code: "restart-cooldown", means: "A restart was already requested in the last 6 hours; retryAfterMs says how long is left.", fix: "Don't restart again; note what is still wrong and report it to the owner instead." },
|
|
217
|
+
DAEMON_UNREACHABLE_ERROR,
|
|
218
|
+
] },
|
|
206
219
|
},
|
|
207
220
|
{
|
|
208
221
|
tool: {
|
|
@@ -228,11 +241,20 @@ exports.runtimeToolDefinitions = [
|
|
|
228
241
|
},
|
|
229
242
|
handler: async (args, ctx) => {
|
|
230
243
|
if (ctx?.context?.friend?.trustLevel !== "family") {
|
|
231
|
-
return "revive_sense requires family trust before I can revive runtime senses.";
|
|
244
|
+
return (0, tools_base_1.withCode)("revive_sense requires family trust before I can revive runtime senses.", "family-required");
|
|
232
245
|
}
|
|
233
246
|
const agentName = (0, identity_1.getAgentName)();
|
|
234
247
|
return reviveSense({ agent: args.agent, sense: args.sense, reason: args.reason }, agentName);
|
|
235
248
|
},
|
|
236
249
|
riskProfile: { mutates: "external_side_effect", risk: "high", reason: "revives a managed runtime sense" },
|
|
250
|
+
ax: { id: "tool:revive_sense", group: "turn-runtime", when: "Pick this when one of your own senses, such as bluebubbles, is stuck or failed while the rest of the daemon is fine.", effect: "write", errors: [
|
|
251
|
+
{ code: "family-required", means: "The person in this conversation isn't family, and only family may revive senses.", fix: "Don't retry; tell the person a family member has to ask for this." },
|
|
252
|
+
{ code: "cross-agent-unsupported", means: "agent was passed, but revive_sense only revives this agent's own senses.", fix: "Call again without agent; another agent's sense is revived from that agent." },
|
|
253
|
+
{ code: "missing-sense", means: "sense is empty.", fix: "Call again with the sense's name, such as bluebubbles." },
|
|
254
|
+
MISSING_REASON_ERROR,
|
|
255
|
+
{ code: "revive-unsupported", means: "The running daemon is too old to revive one sense.", fix: "Use restart_runtime instead, if a restart is justified." },
|
|
256
|
+
{ code: "revive-failed", means: "The daemon refused the revive; error gives its reason, such as no sense by that name.", fix: "Check the sense's name in the error and the daemon's status, then report it if the name is right." },
|
|
257
|
+
DAEMON_UNREACHABLE_ERROR,
|
|
258
|
+
] },
|
|
237
259
|
},
|
|
238
260
|
];
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stewardPolicyToolDefinition = void 0;
|
|
4
|
+
const tools_base_1 = require("./tools-base");
|
|
4
5
|
const steward_policy_1 = require("../heart/steward-policy");
|
|
5
6
|
const runtime_1 = require("../nerves/runtime");
|
|
6
7
|
function arrayArgument(raw, label) {
|
|
7
8
|
if (!raw)
|
|
8
|
-
throw new Error(`${label} is required
|
|
9
|
+
throw new Error((0, tools_base_1.withCode)(`${label} is required`, "bad-argument"));
|
|
9
10
|
const value = JSON.parse(raw);
|
|
10
11
|
if (!Array.isArray(value) || value.some((entry) => typeof entry !== "string"))
|
|
11
|
-
throw new Error(`${label} must be a JSON string array
|
|
12
|
+
throw new Error((0, tools_base_1.withCode)(`${label} must be a JSON string array`, "bad-argument"));
|
|
12
13
|
return value;
|
|
13
14
|
}
|
|
14
15
|
exports.stewardPolicyToolDefinition = {
|
|
@@ -42,9 +43,9 @@ exports.stewardPolicyToolDefinition = {
|
|
|
42
43
|
},
|
|
43
44
|
handler: (args, ctx) => {
|
|
44
45
|
if (!ctx?.agentRoot)
|
|
45
|
-
throw new Error("steward policy runtime is unavailable");
|
|
46
|
+
throw new Error((0, tools_base_1.withCode)("steward policy runtime is unavailable", "runtime-unavailable"));
|
|
46
47
|
if (!ctx.relationshipAuthorization)
|
|
47
|
-
throw new Error("steward policy access requires authenticated relationship authority");
|
|
48
|
+
throw new Error((0, tools_base_1.withCode)("steward policy access requires authenticated relationship authority", "relationship-authority-required"));
|
|
48
49
|
if (args.action === "read") {
|
|
49
50
|
(0, runtime_1.emitNervesEvent)({ component: "repertoire", event: "repertoire.steward_policy_tool_call", message: "read steward policy", meta: { action: "read" } });
|
|
50
51
|
return JSON.stringify((0, steward_policy_1.readStewardPolicy)(ctx.agentRoot));
|
|
@@ -52,7 +53,7 @@ exports.stewardPolicyToolDefinition = {
|
|
|
52
53
|
const relationship = ctx.relationshipAuthorization;
|
|
53
54
|
const actor = relationship.actor;
|
|
54
55
|
if (!actor)
|
|
55
|
-
throw new Error("steward policy mutation requires authenticated relationship authority");
|
|
56
|
+
throw new Error((0, tools_base_1.withCode)("steward policy mutation requires authenticated relationship authority", "relationship-authority-required"));
|
|
56
57
|
const { friendId, trustLevel, sessionEventId } = actor;
|
|
57
58
|
const { profileId, requestId } = relationship;
|
|
58
59
|
(0, steward_policy_1.assertNotReplayIdentity)(ctx.agentRoot, [friendId, ctx.delegatedCommand?.delegateFriendId]);
|
|
@@ -68,20 +69,20 @@ exports.stewardPolicyToolDefinition = {
|
|
|
68
69
|
if (trustLevel !== "family" || profileId !== "sanctuary-owner" || typeof requestId !== "string" || !requestId.trim()
|
|
69
70
|
|| typeof sessionKey !== "string" || !sessionKey.trim() || !sessionEventId.trim()
|
|
70
71
|
|| !sessionMatches() || ctx.currentExternalEvent) {
|
|
71
|
-
throw new Error(delegated
|
|
72
|
+
throw new Error((0, tools_base_1.withCode)(delegated
|
|
72
73
|
? "steward policy mutation requires a current admitted delegated owner command"
|
|
73
|
-
: "steward policy mutation requires a current authenticated owner Telegram request and session");
|
|
74
|
+
: "steward policy mutation requires a current authenticated owner Telegram request and session", "owner-request-required"));
|
|
74
75
|
}
|
|
75
76
|
const sourceFor = (raw) => delegated
|
|
76
77
|
? `${delegated.principalName} via ${delegated.delegateName} (delegated)${raw?.trim() ? `: ${raw.trim()}` : ""}`
|
|
77
78
|
: raw ?? "";
|
|
78
79
|
const expectedVersion = args.expectedVersion === undefined ? undefined : Number(args.expectedVersion);
|
|
79
80
|
if (expectedVersion !== undefined && (!Number.isSafeInteger(expectedVersion) || expectedVersion < 0))
|
|
80
|
-
throw new Error("expectedVersion must be a nonnegative integer");
|
|
81
|
+
throw new Error((0, tools_base_1.withCode)("expectedVersion must be a nonnegative integer", "bad-argument"));
|
|
81
82
|
let mutation;
|
|
82
83
|
if (args.action === "set_desired_state") {
|
|
83
84
|
if (args.provenance !== "stated" && args.provenance !== "observed" && args.provenance !== "default")
|
|
84
|
-
throw new Error("desired state provenance is invalid");
|
|
85
|
+
throw new Error((0, tools_base_1.withCode)("desired state provenance is invalid", "bad-argument"));
|
|
85
86
|
mutation = { kind: "set_desired_state", key: args.key ?? "", value: args.value ?? "", provenance: args.provenance, source: sourceFor(args.source), ...(args.expiresAt ? { expiresAt: args.expiresAt } : {}) };
|
|
86
87
|
}
|
|
87
88
|
else if (args.action === "correct_provenance") {
|
|
@@ -89,12 +90,12 @@ exports.stewardPolicyToolDefinition = {
|
|
|
89
90
|
}
|
|
90
91
|
else if (args.action === "grant_routine_action") {
|
|
91
92
|
if (args.provenance !== "stated" && args.provenance !== "installed_explicit_policy")
|
|
92
|
-
throw new Error("routine action provenance is invalid");
|
|
93
|
+
throw new Error((0, tools_base_1.withCode)("routine action provenance is invalid", "bad-argument"));
|
|
93
94
|
const targets = arrayArgument(args.targetsJson, "targetsJson");
|
|
94
95
|
const exclusions = arrayArgument(args.exclusionsJson, "exclusionsJson");
|
|
95
96
|
const verificationRequired = args.verificationRequired;
|
|
96
97
|
if (verificationRequired !== true)
|
|
97
|
-
throw new Error("verificationRequired must be true");
|
|
98
|
+
throw new Error((0, tools_base_1.withCode)("verificationRequired must be true", "bad-argument"));
|
|
98
99
|
mutation = {
|
|
99
100
|
kind: "grant_routine_action",
|
|
100
101
|
key: args.key ?? "",
|
|
@@ -109,18 +110,18 @@ exports.stewardPolicyToolDefinition = {
|
|
|
109
110
|
};
|
|
110
111
|
}
|
|
111
112
|
else
|
|
112
|
-
throw new Error("steward policy action is invalid");
|
|
113
|
+
throw new Error((0, tools_base_1.withCode)("steward policy action is invalid", "bad-argument"));
|
|
113
114
|
const agentRoot = ctx.agentRoot;
|
|
114
115
|
return Promise.resolve(relationship.authorizeTool("steward_policy_manage", args)).then((authorization) => {
|
|
115
116
|
if (!authorization.allowed)
|
|
116
|
-
throw new Error(`steward policy authorization denied: ${authorization.reason}
|
|
117
|
+
throw new Error((0, tools_base_1.withCode)(`steward policy authorization denied: ${authorization.reason}`, "authorization-denied"));
|
|
117
118
|
if (typeof authorization.profileVersion !== "number" || !Number.isSafeInteger(authorization.profileVersion) || authorization.profileVersion < 1 || !authorization.receiptId.trim()) {
|
|
118
|
-
throw new Error("steward policy owner authorization is not versioned");
|
|
119
|
+
throw new Error((0, tools_base_1.withCode)("steward policy owner authorization is not versioned", "authorization-unversioned"));
|
|
119
120
|
}
|
|
120
121
|
if (ctx.relationshipAuthorization !== relationship || relationship.profileId !== profileId || relationship.requestId !== requestId
|
|
121
122
|
|| relationship.actor?.friendId !== friendId || relationship.actor.trustLevel !== trustLevel || relationship.actor.sessionEventId !== sessionEventId
|
|
122
123
|
|| ctx.currentSession?.key !== sessionKey || !sessionMatches() || ctx.currentExternalEvent) {
|
|
123
|
-
throw new Error("steward policy owner authorization or session changed before mutation");
|
|
124
|
+
throw new Error((0, tools_base_1.withCode)("steward policy owner authorization or session changed before mutation", "authorization-changed"));
|
|
124
125
|
}
|
|
125
126
|
const versionBefore = (0, steward_policy_1.readStewardPolicy)(agentRoot).version;
|
|
126
127
|
const result = (0, steward_policy_1.updateStewardPolicy)(agentRoot, {
|
|
@@ -141,6 +142,15 @@ exports.stewardPolicyToolDefinition = {
|
|
|
141
142
|
return JSON.stringify(result);
|
|
142
143
|
});
|
|
143
144
|
},
|
|
145
|
+
ax: { id: "tool:steward_policy_manage", group: "turn-steward", when: "Pick this to read or change what the household steward keeps on or may restart, when the owner states it in this turn.", effect: "write", errors: [
|
|
146
|
+
{ code: "runtime-unavailable", means: "The runtime gave this turn no agent home, so there is no policy to open.", fix: "Report it to the owner; this is a runtime fault, not something to retry." },
|
|
147
|
+
{ code: "relationship-authority-required", means: "This turn has no authenticated relationship, such as the owner's Telegram chat, behind it.", fix: "Don't retry here; the policy is read or changed only in an authenticated owner conversation." },
|
|
148
|
+
{ code: "owner-request-required", means: "A change needs the owner's own current Telegram request, or an admitted delegated command, and this turn is neither.", fix: "Read the policy instead, or ask the owner to state the change in their Telegram chat." },
|
|
149
|
+
{ code: "bad-argument", means: "action, provenance, expectedVersion, a JSON list or verificationRequired isn't an allowed value; the text names it.", fix: "Correct the argument the text names; send targetsJson and exclusionsJson as JSON arrays of names." },
|
|
150
|
+
{ code: "authorization-denied", means: "The owner's authorization for this exact change was refused; the text gives the reason.", fix: "Tell the owner what was refused and why, and change nothing." },
|
|
151
|
+
{ code: "authorization-unversioned", means: "The authorization came back without a profile version or receipt, so the change can't be audited.", fix: "Report it to the owner; don't retry the change." },
|
|
152
|
+
{ code: "authorization-changed", means: "The owner's session or authorization changed while the change was being checked.", fix: "Read the policy again and redo the change in the owner's current turn." },
|
|
153
|
+
] },
|
|
144
154
|
riskProfile: (args) => args.action === "read"
|
|
145
155
|
? { mutates: "none", risk: "low" }
|
|
146
156
|
: { mutates: "durable_state_write", risk: "high", reason: "updates typed household steward policy under current authenticated owner authority" },
|
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.1316",
|
|
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.1316",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"@ouro.bot/friends"
|
|
12
12
|
],
|