@ouro.bot/cli 0.1.0-alpha.1531 → 0.1.0-alpha.1533
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 +24 -4
- package/deploy/unraid/sanctuary.ouro/agent.json +0 -1
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/arc/flight-recorder.js +0 -21
- package/dist/heart/auth/auth-flow.js +0 -1
- package/dist/heart/autonomy-budget.js +1 -53
- package/dist/heart/core.js +16 -35
- package/dist/heart/daemon/daemon.js +0 -1
- package/dist/heart/habits/habit-parser.js +0 -20
- package/dist/heart/habits/habit-session.js +50 -55
- package/dist/heart/identity.js +1 -6
- package/dist/repertoire/tools.js +2 -2
- package/dist/rsvp/habit-policy.js +1 -2
- package/dist/rsvp/habit-stage.js +0 -1
- package/dist/rsvp/native-habit-runner.js +0 -9
- package/dist/senses/private-runtime-worker.js +9 -46
- package/dist/senses/private-runtime.js +4 -48
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -2,21 +2,41 @@
|
|
|
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.1533",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Update the Ouro UI files to Ouro UI v1.3.520."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1532",
|
|
6
12
|
"changes": [
|
|
7
13
|
"Every agent's base prompt now carries the working habits one agent had been keeping in its own notes. A reply that says \"noted\", \"from now on\", \"standing order\", \"i'll remember\" or \"it's on\" makes the durable write in the same turn, and \"it's on\" means a run was seen doing it. Fixes go in the shared layer, and a wrong limit or rule is deleted rather than tuned. Finished work is reported straight away, without a timed check-back, and no time or cost estimate is given unmeasured.",
|
|
8
14
|
"A new \"talking with people\" section keeps the agent's own voice in chat and leaves report-speak to formal surfaces such as PRs, cards and docs. A notice is not the body of a reply. People are asked only for what only they can do (passkeys, 2FA, money, irreversible acts), and those asks go out together in one batch. \"Ready: <what>, at <where>\" goes out as soon as something lands, and a repeated item with the same dedupe key is dropped unless its ask changed, in which case the new ask replaces it.",
|
|
9
|
-
"`request_decision` and `report_blocker` now say what to include when the item needs the agent's human: urgency, the one-line ask, why only the human can do it, the steps, any deadline and a dedupe key."
|
|
15
|
+
"`request_decision` and `report_blocker` now say what to include when the item needs the agent's human: urgency, the one-line ask, why only the human can do it, the steps, any deadline and a dedupe key.",
|
|
16
|
+
"An agent's habits now run with its normal tools, the same as any of its other turns. The habit tool filter that denied every high-risk tool (shell, diary_write and others) is gone, and so is the habit file's `tools:` list. Only messaging outward is still bounded, by the habit's family, originator and extra recipients.",
|
|
17
|
+
"Habits no longer have a paid-turn allowance of their own: a habit's cadence sets its pace. `habitPaidTurnsPerDay` in `agent.json` is no longer read, and an agent that still sets it is unaffected. External-event turns still count against the agent's shared proactive allowance and storm breaker.",
|
|
18
|
+
"A habit with no origin no longer asks for an originator route, so its runs stop warning \"originator route requested but habit has no origin\".",
|
|
19
|
+
"When a habit cannot run, for example because its definition is broken, the agent hears about it once in its private runtime instead of the habit failing quietly on every tick. It hears again only if the reason changes."
|
|
10
20
|
]
|
|
11
21
|
},
|
|
12
22
|
{
|
|
13
23
|
"version": "0.1.0-alpha.1530",
|
|
14
24
|
"changes": [
|
|
15
|
-
"Update the Ouro UI files to Ouro UI v1.3.517.",
|
|
16
|
-
"Agents are now pointed at the shared rule for attaching images so they load on a recipient's phone.",
|
|
17
25
|
"Update the Ouro UI files to Ouro UI v1.3.519."
|
|
18
26
|
]
|
|
19
27
|
},
|
|
28
|
+
{
|
|
29
|
+
"version": "0.1.0-alpha.1529",
|
|
30
|
+
"changes": [
|
|
31
|
+
"Agents are now pointed at the shared rule for attaching images so they load on a recipient's phone."
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"version": "0.1.0-alpha.1528",
|
|
36
|
+
"changes": [
|
|
37
|
+
"Update the Ouro UI files to Ouro UI v1.3.517."
|
|
38
|
+
]
|
|
39
|
+
},
|
|
20
40
|
{
|
|
21
41
|
"version": "0.1.0-alpha.1527",
|
|
22
42
|
"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.1533</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -681,14 +681,6 @@ function isHabitPermissionEnvelope(value) {
|
|
|
681
681
|
&& isStringArray(value.deniedTools)
|
|
682
682
|
&& isStringArray(value.warnings);
|
|
683
683
|
}
|
|
684
|
-
function isHabitToolPolicy(value) {
|
|
685
|
-
if (!isPlainRecord(value))
|
|
686
|
-
return false;
|
|
687
|
-
return (value.requestedTools === null || isStringArray(value.requestedTools))
|
|
688
|
-
&& isStringArray(value.grantedTools)
|
|
689
|
-
&& isStringArray(value.deniedTools)
|
|
690
|
-
&& typeof value.outwardMessagingAllowed === "boolean";
|
|
691
|
-
}
|
|
692
684
|
function defaultHabitRunSummarySnapshot(receipt) {
|
|
693
685
|
const decisions = decisionsFromHabitRunTraceSteps(receipt.traceSteps);
|
|
694
686
|
if (receipt.errors.length > 0) {
|
|
@@ -765,7 +757,6 @@ function isHabitRunReceipt(value) {
|
|
|
765
757
|
&& (value.operationId === undefined || value.operationId === null || typeof value.operationId === "string")
|
|
766
758
|
&& (value.nextRunAt === null || typeof value.nextRunAt === "string")
|
|
767
759
|
&& isHabitPermissionEnvelope(value.permissionEnvelope)
|
|
768
|
-
&& isHabitToolPolicy(value.toolPolicy)
|
|
769
760
|
&& (value.summarySnapshot === undefined || isPlainRecord(value.summarySnapshot))
|
|
770
761
|
&& isProducedRefArray(value.producedRefs)
|
|
771
762
|
&& isHabitSurfaceAttemptArray(value.surfaceAttempts)
|
|
@@ -830,12 +821,6 @@ function normalizeLegacyHabitRunReceipt(receipt) {
|
|
|
830
821
|
deniedTools: sawSurface ? [] : ["send_message", "surface"],
|
|
831
822
|
warnings: ["legacy receipt normalized without habit permission envelope"],
|
|
832
823
|
},
|
|
833
|
-
toolPolicy: {
|
|
834
|
-
requestedTools: null,
|
|
835
|
-
grantedTools: sawSurface ? ["surface"] : [],
|
|
836
|
-
deniedTools: sawSurface ? [] : ["send_message", "surface"],
|
|
837
|
-
outwardMessagingAllowed: sawSurface,
|
|
838
|
-
},
|
|
839
824
|
summarySnapshot: defaultHabitRunSummarySnapshot(receipt),
|
|
840
825
|
producedRefs: receipt.producedRefs,
|
|
841
826
|
surfaceAttempts: receipt.surfaceAttempts,
|
|
@@ -908,12 +893,6 @@ function capHabitRunReceipt(receipt) {
|
|
|
908
893
|
deniedTools: cappedArray(receipt.permissionEnvelope.deniedTools),
|
|
909
894
|
warnings: cappedArray(receipt.permissionEnvelope.warnings),
|
|
910
895
|
},
|
|
911
|
-
toolPolicy: {
|
|
912
|
-
requestedTools: receipt.toolPolicy.requestedTools ? cappedArray(receipt.toolPolicy.requestedTools) : null,
|
|
913
|
-
grantedTools: cappedArray(receipt.toolPolicy.grantedTools),
|
|
914
|
-
deniedTools: cappedArray(receipt.toolPolicy.deniedTools),
|
|
915
|
-
outwardMessagingAllowed: receipt.toolPolicy.outwardMessagingAllowed,
|
|
916
|
-
},
|
|
917
896
|
summarySnapshot: normalizeHabitRunSummarySnapshot(receipt.summarySnapshot, fallbackSnapshot),
|
|
918
897
|
producedRefs: receipt.producedRefs.map((ref) => ({ ...ref, locator: (0, session_events_1.capStructuredRecordString)(ref.locator) })),
|
|
919
898
|
surfaceAttempts: receipt.surfaceAttempts.map((attempt) => ({
|
|
@@ -115,7 +115,6 @@ function readAgentConfigForAgent(agentName, bundlesRoot = (0, identity_1.getAgen
|
|
|
115
115
|
...parsed,
|
|
116
116
|
displayName: (0, agent_presentation_1.validateAgentDisplayName)(parsed.displayName),
|
|
117
117
|
senses: (0, identity_1.normalizeSenses)(parsed.senses, configPath),
|
|
118
|
-
habitPaidTurnsPerDay: (0, identity_1.normalizeHabitPaidTurnsPerDay)(agentName, parsed.habitPaidTurnsPerDay, configPath),
|
|
119
118
|
};
|
|
120
119
|
return {
|
|
121
120
|
configPath,
|
|
@@ -33,9 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
37
|
-
exports.normalizeHabitPaidTurnsPerDay = normalizeHabitPaidTurnsPerDay;
|
|
38
|
-
exports.resolveAutonomyBudgetPolicy = resolveAutonomyBudgetPolicy;
|
|
36
|
+
exports.AUTONOMY_BUDGET_DEFAULT_POLICY = void 0;
|
|
39
37
|
exports.autonomyBudgetStatePath = autonomyBudgetStatePath;
|
|
40
38
|
exports.autonomyReceiptsDir = autonomyReceiptsDir;
|
|
41
39
|
exports.readAutonomyBudgetState = readAutonomyBudgetState;
|
|
@@ -51,54 +49,12 @@ exports.AUTONOMY_BUDGET_DEFAULT_POLICY = {
|
|
|
51
49
|
agentProactivePaidTurnsPerDay: 40,
|
|
52
50
|
senseRecoveryPaidTurnsPer15m: 3,
|
|
53
51
|
senseRecoveryPaidTurnsPerDay: 12,
|
|
54
|
-
habitPaidTurnsPerDay: 4,
|
|
55
52
|
duplicateRecoveryTtlMs: 10 * 60 * 1000,
|
|
56
53
|
duplicateHabitTtlMs: 24 * 60 * 60 * 1000,
|
|
57
54
|
stormFailureThreshold: 3,
|
|
58
55
|
stormFailureWindowMs: 10 * 60 * 1000,
|
|
59
56
|
stormBlockMs: 30 * 60 * 1000,
|
|
60
57
|
};
|
|
61
|
-
exports.DEFAULT_HABIT_PAID_TURNS_PER_DAY = 4;
|
|
62
|
-
function normalizeHabitPaidTurnsPerDay(agentName, value, configFile) {
|
|
63
|
-
if (value === undefined) {
|
|
64
|
-
if (agentName === "sanctuary") {
|
|
65
|
-
throw new Error(`agent.json at ${configFile} must explicitly set habitPaidTurnsPerDay for Sanctuary.`);
|
|
66
|
-
}
|
|
67
|
-
return exports.DEFAULT_HABIT_PAID_TURNS_PER_DAY;
|
|
68
|
-
}
|
|
69
|
-
if (!Number.isInteger(value) || value < 0 || value > 96) {
|
|
70
|
-
(0, runtime_1.emitNervesEvent)({
|
|
71
|
-
level: "error",
|
|
72
|
-
event: "config_identity.error",
|
|
73
|
-
component: "config/identity",
|
|
74
|
-
message: "agent config has invalid habit paid-turn budget",
|
|
75
|
-
meta: { path: configFile, value },
|
|
76
|
-
});
|
|
77
|
-
throw new Error(`agent.json at ${configFile} habitPaidTurnsPerDay must be an integer from 0 through 96.`);
|
|
78
|
-
}
|
|
79
|
-
return value;
|
|
80
|
-
}
|
|
81
|
-
function resolveAutonomyBudgetPolicy(agentRoot, agentName, basePolicy = exports.AUTONOMY_BUDGET_DEFAULT_POLICY) {
|
|
82
|
-
const configPath = path.join(agentRoot, "agent.json");
|
|
83
|
-
let configured;
|
|
84
|
-
if (fs.existsSync(configPath)) {
|
|
85
|
-
let parsed;
|
|
86
|
-
try {
|
|
87
|
-
parsed = JSON.parse(fs.readFileSync(configPath, "utf8"));
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
throw new Error(`failed to read autonomy budget from ${configPath}: ${String(error)}`);
|
|
91
|
-
}
|
|
92
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
93
|
-
throw new Error(`agent.json at ${configPath} must be an object`);
|
|
94
|
-
}
|
|
95
|
-
configured = parsed.habitPaidTurnsPerDay;
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
...basePolicy,
|
|
99
|
-
habitPaidTurnsPerDay: normalizeHabitPaidTurnsPerDay(agentName, configured, configPath),
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
58
|
function autonomyRoot(agentRoot) {
|
|
103
59
|
return path.join(agentRoot, "state", "autonomy");
|
|
104
60
|
}
|
|
@@ -358,14 +314,6 @@ function budgetBlockReason(state, request, now, policy) {
|
|
|
358
314
|
if (recoveryToday >= policy.senseRecoveryPaidTurnsPerDay)
|
|
359
315
|
return "sense recovery paid turn budget exceeded for day";
|
|
360
316
|
}
|
|
361
|
-
if (request.triggerType === "habit") {
|
|
362
|
-
const habitToday = state.reservations.filter((row) => row.agent === request.agent
|
|
363
|
-
&& row.triggerType === "habit"
|
|
364
|
-
&& row.senseOrHabit === request.senseOrHabit
|
|
365
|
-
&& sameCivilDay(row.reservedAt, now)).length;
|
|
366
|
-
if (habitToday >= policy.habitPaidTurnsPerDay)
|
|
367
|
-
return "habit paid turn budget exceeded for day";
|
|
368
|
-
}
|
|
369
317
|
return null;
|
|
370
318
|
}
|
|
371
319
|
function reserveAutonomyBudget(agentRoot, request, policy = exports.AUTONOMY_BUDGET_DEFAULT_POLICY) {
|
package/dist/heart/core.js
CHANGED
|
@@ -508,13 +508,6 @@ function hasFreshPendingWork(options) {
|
|
|
508
508
|
return pendingMessages.some((message) => typeof message?.content === "string"
|
|
509
509
|
&& message.content.trim().length > 0);
|
|
510
510
|
}
|
|
511
|
-
const HABIT_CONTROL_TOOLS = new Set(["rest", "ponder", "observe"]);
|
|
512
|
-
function highRiskExternalMutation(profile) {
|
|
513
|
-
if (profile.risk !== "high")
|
|
514
|
-
return null;
|
|
515
|
-
const mutates = typeof profile.mutates === "string" ? [profile.mutates] : [...profile.mutates];
|
|
516
|
-
return mutates.includes("external_side_effect") ? mutates.join(", ") : null;
|
|
517
|
-
}
|
|
518
511
|
function recordBlockedHabitSurfaceAttempts(habitSession, toolCalls, reason) {
|
|
519
512
|
if (toolCalls.some((call) => call.name !== "send_message" && call.name !== "surface")) {
|
|
520
513
|
habitSession?.recordError?.(`blocked habit tool batch: ${reason}`);
|
|
@@ -536,39 +529,27 @@ function recordBlockedHabitSurfaceAttempts(habitSession, toolCalls, reason) {
|
|
|
536
529
|
});
|
|
537
530
|
}
|
|
538
531
|
}
|
|
539
|
-
async function habitToolBatchBlockReason(habitSession, toolCalls, delegatedOrigins
|
|
532
|
+
async function habitToolBatchBlockReason(habitSession, toolCalls, delegatedOrigins) {
|
|
540
533
|
if (!habitSession)
|
|
541
534
|
return null;
|
|
542
|
-
|
|
543
|
-
const denied = new Set(habitSession.toolPolicy.deniedTools);
|
|
535
|
+
// A habit has the agent's normal tools. Only messaging outward is bounded, by the habit's return routes.
|
|
544
536
|
for (const call of toolCalls) {
|
|
545
|
-
if (
|
|
546
|
-
return `habit tool '${call.name}' is denied by this habit session`;
|
|
547
|
-
if (HABIT_CONTROL_TOOLS.has(call.name))
|
|
537
|
+
if (call.name !== "send_message" && call.name !== "surface")
|
|
548
538
|
continue;
|
|
549
|
-
if (
|
|
550
|
-
return `habit tool '${call.name}'
|
|
539
|
+
if (habitSession.permissionEnvelope.deniedTools.includes(call.name))
|
|
540
|
+
return `habit tool '${call.name}' is denied by this habit session`;
|
|
551
541
|
// The canonical pre-batch schema gate guarantees object arguments here.
|
|
552
542
|
const args = JSON.parse(call.arguments);
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
envelope: habitSession.permissionEnvelope,
|
|
564
|
-
toolName: call.name,
|
|
565
|
-
args,
|
|
566
|
-
friendStore: habitSession.friendStore,
|
|
567
|
-
delegatedOrigins,
|
|
568
|
-
});
|
|
569
|
-
if (!route.allowed)
|
|
570
|
-
return route.reason;
|
|
571
|
-
}
|
|
543
|
+
const route = await (0, habit_session_1.resolveHabitReturnRoute)({
|
|
544
|
+
agentRoot: (0, identity_2.getAgentRoot)(),
|
|
545
|
+
envelope: habitSession.permissionEnvelope,
|
|
546
|
+
toolName: call.name,
|
|
547
|
+
args,
|
|
548
|
+
friendStore: habitSession.friendStore,
|
|
549
|
+
delegatedOrigins,
|
|
550
|
+
});
|
|
551
|
+
if (!route.allowed)
|
|
552
|
+
return route.reason;
|
|
572
553
|
}
|
|
573
554
|
return null;
|
|
574
555
|
}
|
|
@@ -2255,7 +2236,7 @@ async function runCountedTurn(turnTally, messages, callbacks, channel, signal, o
|
|
|
2255
2236
|
?? "rejected: another call in this batch failed current authorization; no handler was executed."));
|
|
2256
2237
|
continue;
|
|
2257
2238
|
}
|
|
2258
|
-
const habitBlockReason = await habitToolBatchBlockReason(habitSession, result.toolCalls, augmentedToolContext?.delegatedOrigins
|
|
2239
|
+
const habitBlockReason = await habitToolBatchBlockReason(habitSession, result.toolCalls, augmentedToolContext?.delegatedOrigins);
|
|
2259
2240
|
if (habitBlockReason) {
|
|
2260
2241
|
streamCallbackBuffer?.discard();
|
|
2261
2242
|
recordBlockedHabitSurfaceAttempts(habitSession, result.toolCalls, habitBlockReason);
|
|
@@ -2405,7 +2405,6 @@ class OuroDaemon {
|
|
|
2405
2405
|
endedAt,
|
|
2406
2406
|
operationId: occurrenceId,
|
|
2407
2407
|
permissionEnvelope: { schemaVersion: 1, canMessageOutward: true, returnRoutes: [], deniedTools: [], warnings: [] },
|
|
2408
|
-
toolPolicy: { requestedTools: null, grantedTools: [], deniedTools: [], outwardMessagingAllowed: true },
|
|
2409
2408
|
...(nativeResult.ok ? {} : { errors: [nativeResult.error ?? nativeResult.message ?? "native habit failed"] }),
|
|
2410
2409
|
});
|
|
2411
2410
|
}
|
|
@@ -44,22 +44,6 @@ const habit_policy_1 = require("../../rsvp/habit-policy");
|
|
|
44
44
|
function isHabitStatus(value) {
|
|
45
45
|
return value === "active" || value === "paused" || value === "cancelled";
|
|
46
46
|
}
|
|
47
|
-
function parseToolsField(raw) {
|
|
48
|
-
if (raw === undefined || raw === null)
|
|
49
|
-
return undefined;
|
|
50
|
-
// YAML dash-list: parseFrontmatter returns unknown[]
|
|
51
|
-
if (Array.isArray(raw)) {
|
|
52
|
-
return raw.filter((item) => typeof item === "string");
|
|
53
|
-
}
|
|
54
|
-
// Inline bracket format: parseFrontmatter returns string like "[a, b, c]"
|
|
55
|
-
if (typeof raw === "string" && raw.startsWith("[") && raw.endsWith("]")) {
|
|
56
|
-
const inner = raw.slice(1, -1);
|
|
57
|
-
if (inner.trim().length === 0)
|
|
58
|
-
return [];
|
|
59
|
-
return inner.split(",").map((s) => s.trim()).filter(Boolean);
|
|
60
|
-
}
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
47
|
function objectRecord(raw) {
|
|
64
48
|
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : null;
|
|
65
49
|
}
|
|
@@ -163,7 +147,6 @@ function createDegradedHabitFile(filePath, degradedReason, body = "", degradedDe
|
|
|
163
147
|
degradedDetail,
|
|
164
148
|
lastRun: null,
|
|
165
149
|
created: null,
|
|
166
|
-
tools: undefined,
|
|
167
150
|
origin: null,
|
|
168
151
|
surface: { family: false, originator: false, extra: [] },
|
|
169
152
|
continuity: { mode: "fresh" },
|
|
@@ -187,7 +170,6 @@ function parseHabitFile(content, filePath) {
|
|
|
187
170
|
status: "active",
|
|
188
171
|
lastRun: null,
|
|
189
172
|
created: null,
|
|
190
|
-
tools: undefined,
|
|
191
173
|
origin: null,
|
|
192
174
|
surface: { family: true, originator: true, extra: [] },
|
|
193
175
|
continuity: { mode: "fresh" },
|
|
@@ -223,7 +205,6 @@ function parseHabitFile(content, filePath) {
|
|
|
223
205
|
const degradedDetail = (0, habit_policy_1.rsvpHabitMetadataErrorDetail)(error);
|
|
224
206
|
return createDegradedHabitFile(filePath, "invalid_metadata", body, degradedDetail);
|
|
225
207
|
}
|
|
226
|
-
const tools = rsvp ? [...habit_policy_1.RSVP_HABIT_ALLOWED_TOOLS] : parseToolsField(frontmatter.tools);
|
|
227
208
|
const origin = parseOrigin(frontmatter.origin);
|
|
228
209
|
const surface = parseSurface(frontmatter.surface);
|
|
229
210
|
const continuity = parseContinuity(frontmatter.continuity);
|
|
@@ -234,7 +215,6 @@ function parseHabitFile(content, filePath) {
|
|
|
234
215
|
status,
|
|
235
216
|
lastRun,
|
|
236
217
|
created,
|
|
237
|
-
tools,
|
|
238
218
|
...(rsvp ? { rsvp } : {}),
|
|
239
219
|
origin,
|
|
240
220
|
surface,
|
|
@@ -38,15 +38,16 @@ exports.readLatestHabitSessionState = readLatestHabitSessionState;
|
|
|
38
38
|
exports.createHabitSessionPaths = createHabitSessionPaths;
|
|
39
39
|
exports.normalizeHabitPermissionEnvelope = normalizeHabitPermissionEnvelope;
|
|
40
40
|
exports.resolveHabitReturnRoute = resolveHabitReturnRoute;
|
|
41
|
-
exports.filterHabitToolsForEnvelope = filterHabitToolsForEnvelope;
|
|
42
41
|
exports.buildHabitRunReceipt = buildHabitRunReceipt;
|
|
43
42
|
exports.completeHabitRun = completeHabitRun;
|
|
43
|
+
exports.noteHabitRunBlocked = noteHabitRunBlocked;
|
|
44
44
|
const fs = __importStar(require("fs"));
|
|
45
45
|
const path = __importStar(require("path"));
|
|
46
46
|
const flight_recorder_1 = require("../../arc/flight-recorder");
|
|
47
47
|
const runtime_1 = require("../../nerves/runtime");
|
|
48
48
|
const cadence_1 = require("../daemon/cadence");
|
|
49
49
|
const habit_runtime_state_1 = require("./habit-runtime-state");
|
|
50
|
+
const pending_1 = require("../../mind/pending");
|
|
50
51
|
var flight_recorder_2 = require("../../arc/flight-recorder");
|
|
51
52
|
Object.defineProperty(exports, "isSafeHabitRunId", { enumerable: true, get: function () { return flight_recorder_2.isSafeHabitRunId; } });
|
|
52
53
|
function habitSessionRoot(agentRoot) {
|
|
@@ -275,18 +276,12 @@ async function normalizeHabitPermissionEnvelope(habit, options) {
|
|
|
275
276
|
if (habit.surface.family) {
|
|
276
277
|
returnRoutes.push(allowedRoute("family", "family"));
|
|
277
278
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
const warning = "originator route requested but habit has no origin";
|
|
287
|
-
returnRoutes.push(unresolvedRoute("originator", "originator", warning));
|
|
288
|
-
warnings.push(warning);
|
|
289
|
-
}
|
|
279
|
+
// A habit with no origin has no originator to return to, so it asks for no originator route.
|
|
280
|
+
if (habit.surface.originator && habit.origin) {
|
|
281
|
+
const resolved = await resolveExactRoute("originator", habit.origin.friendId, habit.origin.channel, habit.origin.key, options);
|
|
282
|
+
returnRoutes.push(resolved.route);
|
|
283
|
+
if (resolved.warning)
|
|
284
|
+
warnings.push(resolved.warning);
|
|
290
285
|
}
|
|
291
286
|
for (const spec of habit.surface.extra) {
|
|
292
287
|
const parsed = parseExtraRouteSpec(spec);
|
|
@@ -426,46 +421,6 @@ async function resolveHabitReturnRoute(input) {
|
|
|
426
421
|
});
|
|
427
422
|
return deniedRoute(`no habit return route allows ${friend.id}/${target.channel}/${target.key}`);
|
|
428
423
|
}
|
|
429
|
-
function toolName(definition) {
|
|
430
|
-
return definition.tool.function.name;
|
|
431
|
-
}
|
|
432
|
-
function isOutwardMessagingTool(name) {
|
|
433
|
-
return name === "send_message" || name === "surface";
|
|
434
|
-
}
|
|
435
|
-
function isHighRisk(profile) {
|
|
436
|
-
return profile.risk === "high";
|
|
437
|
-
}
|
|
438
|
-
function filterHabitToolsForEnvelope(definitions, requestedTools, envelope, riskClassifier) {
|
|
439
|
-
const requested = requestedTools ? new Set(requestedTools) : null;
|
|
440
|
-
const grantedTools = [];
|
|
441
|
-
const deniedTools = [];
|
|
442
|
-
for (const definition of definitions) {
|
|
443
|
-
const name = toolName(definition);
|
|
444
|
-
if (requested && !requested.has(name))
|
|
445
|
-
continue;
|
|
446
|
-
const deniedByEnvelope = envelope.deniedTools.includes(name);
|
|
447
|
-
const profile = riskClassifier(definition, name);
|
|
448
|
-
const allowedOutward = isOutwardMessagingTool(name) && envelope.canMessageOutward && !deniedByEnvelope;
|
|
449
|
-
if (deniedByEnvelope || (isHighRisk(profile) && !allowedOutward)) {
|
|
450
|
-
deniedTools.push(name);
|
|
451
|
-
continue;
|
|
452
|
-
}
|
|
453
|
-
grantedTools.push(name);
|
|
454
|
-
}
|
|
455
|
-
const policy = {
|
|
456
|
-
requestedTools: requestedTools ? [...requestedTools] : null,
|
|
457
|
-
grantedTools,
|
|
458
|
-
deniedTools,
|
|
459
|
-
outwardMessagingAllowed: envelope.canMessageOutward,
|
|
460
|
-
};
|
|
461
|
-
(0, runtime_1.emitNervesEvent)({
|
|
462
|
-
component: "daemon",
|
|
463
|
-
event: "daemon.habit_tool_policy_filtered",
|
|
464
|
-
message: "habit tool policy filtered",
|
|
465
|
-
meta: { requested: requestedTools?.length ?? null, granted: grantedTools.length, denied: deniedTools.length },
|
|
466
|
-
});
|
|
467
|
-
return policy;
|
|
468
|
-
}
|
|
469
424
|
function computeNextRunAt(habit, endedAt) {
|
|
470
425
|
if (habit.status !== "active" || !habit.cadence)
|
|
471
426
|
return null;
|
|
@@ -525,7 +480,6 @@ function buildHabitRunReceipt(input) {
|
|
|
525
480
|
operationId: input.operationId ?? null,
|
|
526
481
|
nextRunAt: input.nextRunAt ?? computeNextRunAt(input.habit, input.endedAt),
|
|
527
482
|
permissionEnvelope: input.permissionEnvelope,
|
|
528
|
-
toolPolicy: input.toolPolicy,
|
|
529
483
|
summarySnapshot: input.summarySnapshot ?? defaultSummarySnapshot(input),
|
|
530
484
|
producedRefs: input.producedRefs ?? [],
|
|
531
485
|
surfaceAttempts: input.surfaceAttempts ?? [],
|
|
@@ -594,7 +548,6 @@ function completeHabitRun(input) {
|
|
|
594
548
|
outcome,
|
|
595
549
|
operationId: input.operationId ?? null,
|
|
596
550
|
permissionEnvelope: input.permissionEnvelope,
|
|
597
|
-
toolPolicy: input.toolPolicy,
|
|
598
551
|
producedRefs,
|
|
599
552
|
surfaceAttempts: input.surfaceAttempts,
|
|
600
553
|
traceSteps: input.traceSteps,
|
|
@@ -641,3 +594,45 @@ function completeHabitRun(input) {
|
|
|
641
594
|
return { outcome, producedRefs, receiptWritten: true, runtimeStateRecorded: false };
|
|
642
595
|
}
|
|
643
596
|
}
|
|
597
|
+
/**
|
|
598
|
+
* Tell the agent once when a habit cannot run, instead of failing quietly on every tick. The note waits in the
|
|
599
|
+
* agent's private runtime queue; it is sent again only when the reason changes, and a run that is not blocked clears it.
|
|
600
|
+
*/
|
|
601
|
+
function noteHabitRunBlocked(agentRoot, agentName, habitName, reason) {
|
|
602
|
+
const markerPath = path.join(agentRoot, "state", "habits", `${habitName}.blocked-notice`);
|
|
603
|
+
try {
|
|
604
|
+
if (reason === null) {
|
|
605
|
+
fs.rmSync(markerPath, { force: true });
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
if (fs.existsSync(markerPath) && fs.readFileSync(markerPath, "utf-8") === reason)
|
|
609
|
+
return;
|
|
610
|
+
(0, pending_1.queuePendingMessageOnce)((0, pending_1.getPrivateRuntimePendingDir)(agentName, agentRoot), {
|
|
611
|
+
from: agentName,
|
|
612
|
+
friendId: "self",
|
|
613
|
+
channel: "inner",
|
|
614
|
+
key: "dialog",
|
|
615
|
+
content: `my habit ${habitName} could not run: ${reason}. its definition is habits/${habitName}.md. i'll hear this once; it stays blocked until i fix it.`,
|
|
616
|
+
timestamp: Date.now(),
|
|
617
|
+
packetId: `habit-blocked:${habitName}:${reason}`,
|
|
618
|
+
});
|
|
619
|
+
fs.mkdirSync(path.dirname(markerPath), { recursive: true });
|
|
620
|
+
fs.writeFileSync(markerPath, reason, "utf-8");
|
|
621
|
+
(0, runtime_1.emitNervesEvent)({
|
|
622
|
+
level: "warn",
|
|
623
|
+
component: "daemon",
|
|
624
|
+
event: "daemon.habit_blocked_noted",
|
|
625
|
+
message: "blocked habit run told to the agent once",
|
|
626
|
+
meta: { agentRoot, habitName, reason },
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
catch (error) {
|
|
630
|
+
(0, runtime_1.emitNervesEvent)({
|
|
631
|
+
level: "warn",
|
|
632
|
+
component: "daemon",
|
|
633
|
+
event: "daemon.habit_blocked_note_error",
|
|
634
|
+
message: "could not tell the agent about a blocked habit run",
|
|
635
|
+
meta: { agentRoot, habitName, error: String(error) },
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
}
|
package/dist/heart/identity.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.DESK_NAME = exports.HARNESS_CANONICAL_REPO_URL = exports.DEFAULT_AGENT_SENSES = exports.LEGACY_VAULT_SERVER_URL_ALIASES = exports.DEFAULT_VAULT_SERVER_URL = exports.DEFAULT_AGENT_PHRASES = exports.DEFAULT_AGENT_CONTEXT = exports.SHEPHERD_NOTICE_POLICIES = exports.PROVIDER_CREDENTIALS =
|
|
36
|
+
exports.DESK_NAME = exports.HARNESS_CANONICAL_REPO_URL = exports.DEFAULT_AGENT_SENSES = exports.LEGACY_VAULT_SERVER_URL_ALIASES = exports.DEFAULT_VAULT_SERVER_URL = exports.DEFAULT_AGENT_PHRASES = exports.DEFAULT_AGENT_CONTEXT = exports.SHEPHERD_NOTICE_POLICIES = exports.PROVIDER_CREDENTIALS = void 0;
|
|
37
37
|
exports.normalizeVaultServerUrl = normalizeVaultServerUrl;
|
|
38
38
|
exports.getVaultServerUrlCandidates = getVaultServerUrlCandidates;
|
|
39
39
|
exports.defaultStableVaultEmail = defaultStableVaultEmail;
|
|
@@ -65,11 +65,8 @@ const os = __importStar(require("os"));
|
|
|
65
65
|
const path = __importStar(require("path"));
|
|
66
66
|
const runtime_1 = require("../nerves/runtime");
|
|
67
67
|
const migrate_config_1 = require("./migrate-config");
|
|
68
|
-
const autonomy_budget_1 = require("./autonomy-budget");
|
|
69
68
|
const agent_presentation_1 = require("../senses/shepherd/agent-presentation");
|
|
70
69
|
const checkin_config_1 = require("../senses/shepherd/checkin-config");
|
|
71
|
-
var autonomy_budget_2 = require("./autonomy-budget");
|
|
72
|
-
Object.defineProperty(exports, "normalizeHabitPaidTurnsPerDay", { enumerable: true, get: function () { return autonomy_budget_2.normalizeHabitPaidTurnsPerDay; } });
|
|
73
70
|
/** Single source of truth for per-provider credential field names, env var mappings, and prompt labels. */
|
|
74
71
|
exports.PROVIDER_CREDENTIALS = {
|
|
75
72
|
anthropic: { required: ["setupToken"], alternativeRequired: [["apiKey"]], envVars: { ANTHROPIC_API_KEY: "setupToken" }, promptLabels: { setupToken: "Anthropic setup-token" } },
|
|
@@ -355,7 +352,6 @@ function buildDefaultAgentTemplate(_agentName) {
|
|
|
355
352
|
humanFacing: { provider: "anthropic", model: "claude-opus-5-5" },
|
|
356
353
|
agentFacing: { provider: "anthropic", model: "claude-opus-5-5" },
|
|
357
354
|
context: { contextMargin: exports.DEFAULT_AGENT_CONTEXT.contextMargin },
|
|
358
|
-
habitPaidTurnsPerDay: autonomy_budget_1.DEFAULT_HABIT_PAID_TURNS_PER_DAY,
|
|
359
355
|
senses: {
|
|
360
356
|
cli: { ...exports.DEFAULT_AGENT_SENSES.cli },
|
|
361
357
|
teams: { ...exports.DEFAULT_AGENT_SENSES.teams },
|
|
@@ -677,7 +673,6 @@ function loadAgentConfig(owner) {
|
|
|
677
673
|
agentFacing,
|
|
678
674
|
...(parsed.providerFallback !== undefined ? { providerFallback: validateProviderFallback(parsed.providerFallback, configFile) } : {}),
|
|
679
675
|
...(parsed.desks !== undefined ? { desks: validateDesks(parsed.desks, configFile) } : {}),
|
|
680
|
-
habitPaidTurnsPerDay: (0, autonomy_budget_1.normalizeHabitPaidTurnsPerDay)(owner === undefined ? getAgentName() : owner.agentName, parsed.habitPaidTurnsPerDay, configFile),
|
|
681
676
|
senses: normalizeSenses(parsed.senses, configFile),
|
|
682
677
|
phrases: parsed.phrases,
|
|
683
678
|
};
|
package/dist/repertoire/tools.js
CHANGED
|
@@ -234,9 +234,9 @@ function selectToolsForChannel(capabilities, toolPreferences, _context, provider
|
|
|
234
234
|
ordinary.push(...tools_house_care_1.houseCareToolDefinitions);
|
|
235
235
|
const habit = context?.habitSession;
|
|
236
236
|
if (inner) {
|
|
237
|
-
const canSend = habit?.
|
|
237
|
+
const canSend = habit?.permissionEnvelope.canMessageOutward === true;
|
|
238
238
|
ordinary = ordinary.filter((definition) => canSend || definition.tool.function.name !== "send_message");
|
|
239
|
-
if (!habit ||
|
|
239
|
+
if (!habit || canSend) {
|
|
240
240
|
ordinary.push(tools_surface_1.surfaceToolDefinition);
|
|
241
241
|
}
|
|
242
242
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DEFAULT_RSVP_HABIT_NAME = exports.RSVP_HABIT_POLICY_VERSION = void 0;
|
|
4
4
|
exports.isRsvpHabitName = isRsvpHabitName;
|
|
5
5
|
exports.rsvpHabitMetadataErrorDetail = rsvpHabitMetadataErrorDetail;
|
|
6
6
|
exports.parseRsvpHabitMetadata = parseRsvpHabitMetadata;
|
|
@@ -8,7 +8,6 @@ exports.rsvpHabitRuntimePolicy = rsvpHabitRuntimePolicy;
|
|
|
8
8
|
const runtime_1 = require("../nerves/runtime");
|
|
9
9
|
exports.RSVP_HABIT_POLICY_VERSION = "rsvp-habit/v1";
|
|
10
10
|
exports.DEFAULT_RSVP_HABIT_NAME = "rsvp-updates";
|
|
11
|
-
exports.RSVP_HABIT_ALLOWED_TOOLS = ["rsvp_query", "rsvp_summary"];
|
|
12
11
|
function isRecord(value) {
|
|
13
12
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
14
13
|
}
|
package/dist/rsvp/habit-stage.js
CHANGED
|
@@ -148,14 +148,6 @@ function permissionEnvelope(sendAllowed) {
|
|
|
148
148
|
warnings: [],
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
|
-
function toolPolicy(sendAllowed) {
|
|
152
|
-
return {
|
|
153
|
-
requestedTools: [...habit_policy_1.RSVP_HABIT_ALLOWED_TOOLS],
|
|
154
|
-
grantedTools: [...habit_policy_1.RSVP_HABIT_ALLOWED_TOOLS],
|
|
155
|
-
deniedTools: [],
|
|
156
|
-
outwardMessagingAllowed: sendAllowed,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
151
|
function stringField(record, key) {
|
|
160
152
|
const value = record[key];
|
|
161
153
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
@@ -577,7 +569,6 @@ async function runNativeRsvpHabit(input) {
|
|
|
577
569
|
endedAt,
|
|
578
570
|
operationId: `rsvp-native:${input.trigger}:${input.occurrenceId ?? runId}`,
|
|
579
571
|
permissionEnvelope: permissionEnvelope(effectiveSendAllowed),
|
|
580
|
-
toolPolicy: toolPolicy(effectiveSendAllowed),
|
|
581
572
|
producedRefs,
|
|
582
573
|
surfaceAttempts,
|
|
583
574
|
traceSteps,
|
|
@@ -50,9 +50,6 @@ const habit_session_1 = require("../heart/habits/habit-session");
|
|
|
50
50
|
const flight_recorder_1 = require("../arc/flight-recorder");
|
|
51
51
|
const habit_session_summary_1 = require("../heart/habits/habit-session-summary");
|
|
52
52
|
const friends_1 = require("@ouro.bot/friends");
|
|
53
|
-
const tools_base_1 = require("../repertoire/tools-base");
|
|
54
|
-
const tools_surface_1 = require("../repertoire/tools-surface");
|
|
55
|
-
const tools_1 = require("../repertoire/tools");
|
|
56
53
|
const habit_policy_1 = require("../rsvp/habit-policy");
|
|
57
54
|
const spend_ledger_1 = require("../rsvp/spend-ledger");
|
|
58
55
|
const run_ledger_1 = require("../heart/run-ledger");
|
|
@@ -145,34 +142,10 @@ function recordHabitRunLedger(habitRun, lifecycle, endedAt) {
|
|
|
145
142
|
}
|
|
146
143
|
}
|
|
147
144
|
}
|
|
148
|
-
function reserveHabitAutonomyBudget(habitRun, nowIso) {
|
|
149
|
-
const target = {
|
|
150
|
-
habitName: habitRun.habit.name,
|
|
151
|
-
runId: habitRun.runId,
|
|
152
|
-
trigger: habitRun.trigger,
|
|
153
|
-
operationId: habitRun.operationId,
|
|
154
|
-
};
|
|
155
|
-
if (habitRun.rsvpPolicy) {
|
|
156
|
-
target.rsvpSnapshotRef = habitRun.rsvpPolicy.snapshotRef;
|
|
157
|
-
target.rsvpBudgetRef = habitRun.rsvpPolicy.budgetRef;
|
|
158
|
-
target.rsvpIdempotencyRef = habitRun.rsvpPolicy.idempotencyRef;
|
|
159
|
-
}
|
|
160
|
-
const agentName = (0, identity_1.getAgentName)();
|
|
161
|
-
return (0, autonomy_budget_1.reserveAutonomyBudget)(habitRun.agentRoot, {
|
|
162
|
-
agent: agentName,
|
|
163
|
-
triggerType: "habit",
|
|
164
|
-
sourceKind: "private-runtime",
|
|
165
|
-
senseOrHabit: habitRun.habit.name,
|
|
166
|
-
target,
|
|
167
|
-
idempotencyKey: `habit:${habitRun.habit.name}:${habitRun.runId}`,
|
|
168
|
-
now: nowIso,
|
|
169
|
-
}, (0, autonomy_budget_1.resolveAutonomyBudgetPolicy)(habitRun.agentRoot, agentName));
|
|
170
|
-
}
|
|
171
145
|
/**
|
|
172
|
-
* External-event turns are paid model work, so they
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* for thirty minutes.
|
|
146
|
+
* External-event turns are paid model work, so they count against the agent's shared proactive
|
|
147
|
+
* allowance and share one storm breaker: three failed event turns within ten minutes pause event
|
|
148
|
+
* turns for thirty minutes. Habits draw on no allowance of their own: their cadence is their pace.
|
|
176
149
|
*/
|
|
177
150
|
const EXTERNAL_EVENT_BUDGET_NAME = "external-events";
|
|
178
151
|
function externalEventStorm(agentName) {
|
|
@@ -206,11 +179,11 @@ function reserveExternalEventAutonomyBudget(event, nowIso) {
|
|
|
206
179
|
idempotencyKey: `event:${event.recordPath}:${event.generation}:${event.claimOwner}`,
|
|
207
180
|
now: nowIso,
|
|
208
181
|
storm: externalEventStorm(agentName),
|
|
209
|
-
}
|
|
182
|
+
});
|
|
210
183
|
}
|
|
211
184
|
function recordExternalEventTurnFailure(nowIso) {
|
|
212
185
|
const agentRoot = (0, identity_1.getAgentRoot)();
|
|
213
|
-
(0, autonomy_budget_1.recordAutonomyFailure)(agentRoot, { ...externalEventStorm((0, identity_1.getAgentName)()), occurredAt: nowIso }
|
|
186
|
+
(0, autonomy_budget_1.recordAutonomyFailure)(agentRoot, { ...externalEventStorm((0, identity_1.getAgentName)()), occurredAt: nowIso });
|
|
214
187
|
}
|
|
215
188
|
/**
|
|
216
189
|
* Habit recursion detector thresholds. This protects against the *external*
|
|
@@ -355,8 +328,6 @@ async function prepareHabitRun(habitName, trigger, startedAt) {
|
|
|
355
328
|
const friendStore = new friends_1.FileFriendStore(path.join(agentRoot, "friends"));
|
|
356
329
|
const permissionEnvelope = await (0, habit_session_1.normalizeHabitPermissionEnvelope)(habit, { agentRoot, friendStore });
|
|
357
330
|
const rsvpPolicy = habit.rsvp ? (0, habit_policy_1.rsvpHabitRuntimePolicy)(habit.rsvp) : undefined;
|
|
358
|
-
const requestedTools = blockedReason ? [] : habit.rsvp ? [...habit_policy_1.RSVP_HABIT_ALLOWED_TOOLS] : habit.tools ?? null;
|
|
359
|
-
const toolPolicy = (0, habit_session_1.filterHabitToolsForEnvelope)([...tools_base_1.baseToolDefinitions, tools_surface_1.surfaceToolDefinition], requestedTools, permissionEnvelope, riskProfileForHabitPolicy);
|
|
360
331
|
return {
|
|
361
332
|
agentRoot,
|
|
362
333
|
habit,
|
|
@@ -367,7 +338,6 @@ async function prepareHabitRun(habitName, trigger, startedAt) {
|
|
|
367
338
|
priorSessionSummary,
|
|
368
339
|
paths,
|
|
369
340
|
permissionEnvelope,
|
|
370
|
-
toolPolicy,
|
|
371
341
|
...(rsvpPolicy ? { rsvpPolicy } : {}),
|
|
372
342
|
...(blockedReason ? { blockedReason } : {}),
|
|
373
343
|
friendStore,
|
|
@@ -377,10 +347,6 @@ async function prepareHabitRun(habitName, trigger, startedAt) {
|
|
|
377
347
|
surfaceAttempts: [],
|
|
378
348
|
};
|
|
379
349
|
}
|
|
380
|
-
function riskProfileForHabitPolicy(definition, name) {
|
|
381
|
-
const probeArgs = name === "shell" ? { command: "touch /tmp/habit-policy-probe" } : {};
|
|
382
|
-
return (0, tools_1.riskProfileForTool)(definition, name, probeArgs);
|
|
383
|
-
}
|
|
384
350
|
function readPriorSessionSummary(agentRoot, operationId) {
|
|
385
351
|
if (operationId === null)
|
|
386
352
|
return undefined;
|
|
@@ -429,12 +395,12 @@ function createPrivateRuntimeWorker(runTurn = (options) => (0, private_runtime_1
|
|
|
429
395
|
endedAt,
|
|
430
396
|
operationId: habitRun.operationId,
|
|
431
397
|
permissionEnvelope: habitRun.permissionEnvelope,
|
|
432
|
-
toolPolicy: habitRun.toolPolicy,
|
|
433
398
|
producedRefs: habitRun.producedRefs,
|
|
434
399
|
surfaceAttempts: habitRun.surfaceAttempts,
|
|
435
400
|
errors: habitRun.errors,
|
|
436
401
|
summarySnapshot: deriveHabitSummarySnapshot(habitRun),
|
|
437
402
|
});
|
|
403
|
+
(0, habit_session_1.noteHabitRunBlocked)(habitRun.agentRoot, (0, identity_1.getAgentName)(), habitRun.habit.name, habitRun.blockedReason ?? null);
|
|
438
404
|
}
|
|
439
405
|
function clearHeartbeatRestShield() {
|
|
440
406
|
heartbeatOkRestedAt = null;
|
|
@@ -580,11 +546,9 @@ function createPrivateRuntimeWorker(runTurn = (options) => (0, private_runtime_1
|
|
|
580
546
|
let blockedAutonomyTurn = false;
|
|
581
547
|
try {
|
|
582
548
|
const turnStartedAt = new Date(nowSource()).toISOString();
|
|
583
|
-
const autonomyDecision =
|
|
584
|
-
?
|
|
585
|
-
:
|
|
586
|
-
? reserveExternalEventAutonomyBudget(currentExternalEvent, turnStartedAt)
|
|
587
|
-
: null;
|
|
549
|
+
const autonomyDecision = currentExternalEvent
|
|
550
|
+
? reserveExternalEventAutonomyBudget(currentExternalEvent, turnStartedAt)
|
|
551
|
+
: null;
|
|
588
552
|
if (currentHabitRun)
|
|
589
553
|
recordHabitStartIfNeeded(currentHabitRun);
|
|
590
554
|
if (currentHabitRun?.blockedReason) {
|
|
@@ -630,7 +594,6 @@ function createPrivateRuntimeWorker(runTurn = (options) => (0, private_runtime_1
|
|
|
630
594
|
sessionPath: currentHabitRun.paths.sessionPath,
|
|
631
595
|
pendingDir: currentHabitRun.paths.pendingDir,
|
|
632
596
|
permissionEnvelope: currentHabitRun.permissionEnvelope,
|
|
633
|
-
toolPolicy: currentHabitRun.toolPolicy,
|
|
634
597
|
...(currentHabitRun.rsvpPolicy ? { rsvpPolicy: currentHabitRun.rsvpPolicy } : {}),
|
|
635
598
|
friendStore: currentHabitRun.friendStore,
|
|
636
599
|
recordProducedRef: (ref) => { currentHabitRun.producedRefs.push(ref); },
|
|
@@ -1007,21 +1007,12 @@ function buildHabitSurfacePolicy(origin, surface) {
|
|
|
1007
1007
|
lines.push("- family recipients are allowed by default.");
|
|
1008
1008
|
if (surface.originator && origin)
|
|
1009
1009
|
lines.push(`- the originator is allowed: ${origin.friendId} via ${origin.channel}/${origin.key}.`);
|
|
1010
|
-
if (surface.originator && !origin)
|
|
1011
|
-
lines.push("- originator messaging is enabled, but this habit has no origin metadata.");
|
|
1012
1010
|
if (surface.extra.length > 0)
|
|
1013
1011
|
lines.push(`- extra allowed recipients: ${surface.extra.join(", ")}.`);
|
|
1014
1012
|
lines.push("- use send_message for intentional contact; use surface only for a held return tied to an existing return obligation.");
|
|
1015
1013
|
return lines.join("\n");
|
|
1016
1014
|
}
|
|
1017
1015
|
function reduceHabitSessionToNoSend(habitSession) {
|
|
1018
|
-
const deniedTools = new Set([
|
|
1019
|
-
...(habitSession?.permissionEnvelope.deniedTools ?? []),
|
|
1020
|
-
...(habitSession?.toolPolicy.grantedTools ?? []),
|
|
1021
|
-
...(habitSession?.toolPolicy.deniedTools ?? []),
|
|
1022
|
-
"send_message",
|
|
1023
|
-
"surface",
|
|
1024
|
-
]);
|
|
1025
1016
|
return {
|
|
1026
1017
|
...habitSession,
|
|
1027
1018
|
noSend: true,
|
|
@@ -1029,15 +1020,9 @@ function reduceHabitSessionToNoSend(habitSession) {
|
|
|
1029
1020
|
schemaVersion: 1,
|
|
1030
1021
|
canMessageOutward: false,
|
|
1031
1022
|
returnRoutes: [],
|
|
1032
|
-
deniedTools: [
|
|
1023
|
+
deniedTools: ["send_message", "surface"],
|
|
1033
1024
|
warnings: [...(habitSession?.permissionEnvelope.warnings ?? [])],
|
|
1034
1025
|
},
|
|
1035
|
-
toolPolicy: {
|
|
1036
|
-
requestedTools: habitSession?.toolPolicy.requestedTools ?? null,
|
|
1037
|
-
grantedTools: [],
|
|
1038
|
-
deniedTools: [...deniedTools],
|
|
1039
|
-
outwardMessagingAllowed: false,
|
|
1040
|
-
},
|
|
1041
1026
|
};
|
|
1042
1027
|
}
|
|
1043
1028
|
/** Sanctuary tool context for a private turn: always for the sanctuary agent, and for sanctuary external events.
|
|
@@ -1104,8 +1089,6 @@ async function runPrivateRuntimeTurn(options) {
|
|
|
1104
1089
|
: false;
|
|
1105
1090
|
// ── Adapter concern: build user message ──────────────────────────
|
|
1106
1091
|
let userContent;
|
|
1107
|
-
let habitTools;
|
|
1108
|
-
let habitParsedSuccessfully = false;
|
|
1109
1092
|
let parsedAwait = null;
|
|
1110
1093
|
const isPayloadSpecificWake = !!options?.taskId
|
|
1111
1094
|
|| (reason === "habit" && !!options?.habitName)
|
|
@@ -1177,7 +1160,6 @@ async function runPrivateRuntimeTurn(options) {
|
|
|
1177
1160
|
habitBody = executableHabit.body || undefined;
|
|
1178
1161
|
habitTitle = executableHabit.title || habitName;
|
|
1179
1162
|
habitLastRun = executableHabit.lastRun;
|
|
1180
|
-
habitTools = executableHabit.tools;
|
|
1181
1163
|
habitOrigin = executableHabit.origin;
|
|
1182
1164
|
habitSurface = executableHabit.surface;
|
|
1183
1165
|
// If the habit file couldn't be read at all (no body, no title parsed), error message
|
|
@@ -1185,7 +1167,6 @@ async function runPrivateRuntimeTurn(options) {
|
|
|
1185
1167
|
userContent = `habit "${habitName}" could not be read (file not found or unreadable). check habits/${habitName}.md exists.`;
|
|
1186
1168
|
}
|
|
1187
1169
|
else {
|
|
1188
|
-
habitParsedSuccessfully = true;
|
|
1189
1170
|
// Unified path: gather context for ALL habits (heartbeat included)
|
|
1190
1171
|
const obligations = (0, obligations_1.listActiveReturnObligations)(agentName);
|
|
1191
1172
|
const nowMs = now().getTime();
|
|
@@ -1439,33 +1420,8 @@ async function runPrivateRuntimeTurn(options) {
|
|
|
1439
1420
|
if (externalEventRelationship)
|
|
1440
1421
|
userContent = `${userContent}\n\n${externalEventRelationship.ownerPresentationPreferences}`;
|
|
1441
1422
|
const userMessage = { role: "user", content: userContent };
|
|
1442
|
-
//
|
|
1443
|
-
|
|
1444
|
-
if (habitTools !== undefined) {
|
|
1445
|
-
const fullTools = (0, tools_1.getToolsForChannel)(innerCapabilities);
|
|
1446
|
-
habitToolsResolved = fullTools.filter((t) => habitTools.includes(t.function.name));
|
|
1447
|
-
(0, runtime_1.emitNervesEvent)({
|
|
1448
|
-
event: "habit.tools_restricted",
|
|
1449
|
-
component: "senses",
|
|
1450
|
-
message: "habit running with restricted tools",
|
|
1451
|
-
meta: {
|
|
1452
|
-
habitName: options?.habitName,
|
|
1453
|
-
declared: habitTools,
|
|
1454
|
-
resolved: habitToolsResolved.map((t) => t.function.name),
|
|
1455
|
-
},
|
|
1456
|
-
});
|
|
1457
|
-
}
|
|
1458
|
-
else if (reason === "habit" && options?.habitName && habitParsedSuccessfully) {
|
|
1459
|
-
(0, runtime_1.emitNervesEvent)({
|
|
1460
|
-
event: "habit.tools_unrestricted",
|
|
1461
|
-
component: "senses",
|
|
1462
|
-
message: "habit running with full tool repertoire",
|
|
1463
|
-
meta: { habitName: options.habitName },
|
|
1464
|
-
});
|
|
1465
|
-
}
|
|
1466
|
-
if (options?.noSend === true) {
|
|
1467
|
-
habitToolsResolved = [];
|
|
1468
|
-
}
|
|
1423
|
+
// A no-send habit turn gets no tools: it may only think and rest.
|
|
1424
|
+
const noSendTools = options?.noSend === true ? [] : undefined;
|
|
1469
1425
|
const externalEventExcludedTools = new Set(["rest", "settle", "speak"]);
|
|
1470
1426
|
const externalEventToolsResolved = options?.externalEvent
|
|
1471
1427
|
? (0, tools_1.getToolsForChannel)(innerCapabilities, undefined, undefined, undefined, undefined, undefined, {
|
|
@@ -1589,7 +1545,7 @@ async function runPrivateRuntimeTurn(options) {
|
|
|
1589
1545
|
...(options?.externalEvent
|
|
1590
1546
|
? { tools: externalEventToolsResolved }
|
|
1591
1547
|
: relationshipAwaitToolsResolved !== undefined ? { tools: relationshipAwaitToolsResolved }
|
|
1592
|
-
:
|
|
1548
|
+
: noSendTools !== undefined ? { tools: noSendTools } : {}),
|
|
1593
1549
|
toolContext: {
|
|
1594
1550
|
signin: async () => undefined,
|
|
1595
1551
|
delegatedOrigins: attentionQueue,
|
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.1533",
|
|
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.1533",
|
|
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.1533",
|
|
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": {
|