@ouro.bot/cli 0.1.0-alpha.15 → 0.1.0-alpha.151

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.
Files changed (150) hide show
  1. package/AdoptionSpecialist.ouro/psyche/SOUL.md +2 -2
  2. package/AdoptionSpecialist.ouro/psyche/identities/monty.md +2 -2
  3. package/README.md +185 -191
  4. package/changelog.json +991 -0
  5. package/dist/heart/active-work.js +633 -0
  6. package/dist/heart/bridges/manager.js +358 -0
  7. package/dist/heart/bridges/state-machine.js +135 -0
  8. package/dist/heart/bridges/store.js +123 -0
  9. package/dist/heart/commitments.js +105 -0
  10. package/dist/heart/config.js +66 -21
  11. package/dist/heart/core.js +645 -112
  12. package/dist/heart/cross-chat-delivery.js +146 -0
  13. package/dist/heart/daemon/agent-discovery.js +81 -0
  14. package/dist/heart/daemon/agent-service.js +360 -0
  15. package/dist/heart/daemon/auth-flow.js +457 -0
  16. package/dist/heart/daemon/cadence.js +70 -0
  17. package/dist/heart/daemon/daemon-cli.js +2301 -205
  18. package/dist/heart/daemon/daemon-entry.js +131 -4
  19. package/dist/heart/daemon/daemon-runtime-sync.js +212 -0
  20. package/dist/heart/daemon/daemon-tombstone.js +106 -0
  21. package/dist/heart/daemon/daemon.js +372 -3
  22. package/dist/heart/daemon/habit-migration.js +181 -0
  23. package/dist/heart/daemon/habit-parser.js +119 -0
  24. package/dist/heart/daemon/habit-scheduler.js +252 -0
  25. package/dist/heart/daemon/hatch-animation.js +10 -3
  26. package/dist/heart/daemon/hatch-flow.js +28 -111
  27. package/dist/heart/daemon/hooks/bundle-meta.js +92 -0
  28. package/dist/heart/daemon/inner-status.js +89 -0
  29. package/dist/heart/daemon/launchd.js +159 -0
  30. package/dist/heart/daemon/log-tailer.js +4 -3
  31. package/dist/heart/daemon/mcp-server.js +591 -0
  32. package/dist/heart/daemon/message-router.js +17 -8
  33. package/dist/heart/daemon/os-cron-deps.js +134 -0
  34. package/dist/heart/daemon/ouro-bot-global-installer.js +128 -0
  35. package/dist/heart/daemon/ouro-path-installer.js +78 -34
  36. package/dist/heart/daemon/ouro-version-manager.js +171 -0
  37. package/dist/heart/daemon/process-manager.js +75 -0
  38. package/dist/heart/daemon/run-hooks.js +37 -0
  39. package/dist/heart/daemon/runtime-logging.js +58 -15
  40. package/dist/heart/daemon/runtime-metadata.js +219 -0
  41. package/dist/heart/daemon/runtime-mode.js +67 -0
  42. package/dist/heart/daemon/sense-manager.js +50 -2
  43. package/dist/heart/daemon/session-id-resolver.js +131 -0
  44. package/dist/heart/daemon/skill-management-installer.js +94 -0
  45. package/dist/heart/daemon/socket-client.js +202 -0
  46. package/dist/heart/daemon/specialist-orchestrator.js +2 -2
  47. package/dist/heart/daemon/specialist-prompt.js +10 -7
  48. package/dist/heart/daemon/specialist-tools.js +53 -4
  49. package/dist/heart/daemon/staged-restart.js +114 -0
  50. package/dist/heart/daemon/task-scheduler.js +3 -25
  51. package/dist/heart/daemon/thoughts.js +507 -0
  52. package/dist/heart/daemon/update-checker.js +111 -0
  53. package/dist/heart/daemon/update-hooks.js +138 -0
  54. package/dist/heart/daemon/wrapper-publish-guard.js +86 -0
  55. package/dist/heart/delegation.js +62 -0
  56. package/dist/heart/identity.js +64 -21
  57. package/dist/heart/kicks.js +2 -20
  58. package/dist/heart/model-capabilities.js +48 -0
  59. package/dist/heart/obligations.js +197 -0
  60. package/dist/heart/progress-story.js +42 -0
  61. package/dist/heart/provider-failover.js +88 -0
  62. package/dist/heart/provider-ping.js +159 -0
  63. package/dist/heart/providers/anthropic-token.js +163 -0
  64. package/dist/heart/providers/anthropic.js +195 -34
  65. package/dist/heart/providers/azure.js +115 -9
  66. package/dist/heart/providers/github-copilot.js +157 -0
  67. package/dist/heart/providers/minimax.js +33 -3
  68. package/dist/heart/providers/openai-codex.js +49 -14
  69. package/dist/heart/session-activity.js +173 -0
  70. package/dist/heart/session-recall.js +216 -0
  71. package/dist/heart/streaming.js +117 -33
  72. package/dist/heart/target-resolution.js +127 -0
  73. package/dist/heart/tool-loop.js +200 -0
  74. package/dist/heart/turn-coordinator.js +28 -0
  75. package/dist/mind/associative-recall.js +122 -32
  76. package/dist/mind/bundle-manifest.js +14 -0
  77. package/dist/mind/context.js +125 -14
  78. package/dist/mind/{memory.js → diary.js} +70 -56
  79. package/dist/mind/first-impressions.js +16 -2
  80. package/dist/mind/friends/channel.js +44 -0
  81. package/dist/mind/friends/group-context.js +144 -0
  82. package/dist/mind/friends/store-file.js +19 -0
  83. package/dist/mind/friends/trust-explanation.js +74 -0
  84. package/dist/mind/friends/types.js +8 -0
  85. package/dist/mind/journal-index.js +161 -0
  86. package/dist/mind/obligation-steering.js +221 -0
  87. package/dist/mind/obligations.js +134 -0
  88. package/dist/mind/pending.js +76 -9
  89. package/dist/mind/phrases.js +1 -0
  90. package/dist/mind/prompt.js +612 -88
  91. package/dist/mind/token-estimate.js +8 -12
  92. package/dist/nerves/cli-logging.js +15 -2
  93. package/dist/nerves/coverage/run-artifacts.js +1 -1
  94. package/dist/nerves/index.js +59 -2
  95. package/dist/nerves/runtime.js +5 -1
  96. package/dist/repertoire/ado-client.js +4 -2
  97. package/dist/repertoire/ado-semantic.js +6 -0
  98. package/dist/repertoire/coding/codex-jsonl.js +64 -0
  99. package/dist/repertoire/coding/context-pack.js +254 -0
  100. package/dist/repertoire/coding/feedback.js +301 -0
  101. package/dist/repertoire/coding/index.js +4 -1
  102. package/dist/repertoire/coding/manager.js +210 -4
  103. package/dist/repertoire/coding/spawner.js +58 -12
  104. package/dist/repertoire/coding/tools.js +176 -4
  105. package/dist/repertoire/data/ado-endpoints.json +188 -0
  106. package/dist/repertoire/guardrails.js +290 -0
  107. package/dist/repertoire/mcp-client.js +254 -0
  108. package/dist/repertoire/mcp-manager.js +198 -0
  109. package/dist/repertoire/skills.js +14 -23
  110. package/dist/repertoire/tasks/board.js +12 -0
  111. package/dist/repertoire/tasks/index.js +23 -9
  112. package/dist/repertoire/tasks/parser.js +0 -2
  113. package/dist/repertoire/tasks/transitions.js +1 -20
  114. package/dist/repertoire/tools-base.js +990 -273
  115. package/dist/repertoire/tools-bluebubbles.js +94 -0
  116. package/dist/repertoire/tools-github.js +1 -6
  117. package/dist/repertoire/tools-teams.js +65 -59
  118. package/dist/repertoire/tools.js +281 -91
  119. package/dist/scripts/claude-code-hook.js +41 -0
  120. package/dist/scripts/claude-code-stop-hook.js +47 -0
  121. package/dist/senses/attention-queue.js +97 -0
  122. package/dist/senses/bluebubbles-client.js +258 -5
  123. package/dist/senses/bluebubbles-entry.js +2 -0
  124. package/dist/senses/bluebubbles-inbound-log.js +109 -0
  125. package/dist/senses/bluebubbles-media.js +339 -0
  126. package/dist/senses/bluebubbles-model.js +12 -4
  127. package/dist/senses/bluebubbles-mutation-log.js +45 -5
  128. package/dist/senses/bluebubbles-runtime-state.js +109 -0
  129. package/dist/senses/bluebubbles-session-cleanup.js +72 -0
  130. package/dist/senses/bluebubbles.js +981 -45
  131. package/dist/senses/cli-entry.js +1 -1
  132. package/dist/senses/cli-layout.js +187 -0
  133. package/dist/senses/cli.js +374 -131
  134. package/dist/senses/contextual-heartbeat.js +106 -0
  135. package/dist/senses/continuity.js +94 -0
  136. package/dist/senses/debug-activity.js +154 -0
  137. package/dist/senses/inner-dialog-worker.js +112 -19
  138. package/dist/senses/inner-dialog.js +621 -84
  139. package/dist/senses/pipeline.js +463 -0
  140. package/dist/senses/shared-turn.js +196 -0
  141. package/dist/senses/surface-tool.js +95 -0
  142. package/dist/senses/teams.js +796 -141
  143. package/dist/senses/trust-gate.js +112 -2
  144. package/package.json +12 -4
  145. package/skills/configure-dev-tools.md +81 -0
  146. package/subagents/README.md +4 -70
  147. package/dist/heart/daemon/subagent-installer.js +0 -134
  148. package/subagents/work-doer.md +0 -233
  149. package/subagents/work-merger.md +0 -624
  150. package/subagents/work-planner.md +0 -373
@@ -35,21 +35,42 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.resetPsycheCache = resetPsycheCache;
37
37
  exports.buildSessionSummary = buildSessionSummary;
38
+ exports.bodyMapSection = bodyMapSection;
39
+ exports.mcpToolsSection = mcpToolsSection;
38
40
  exports.runtimeInfoSection = runtimeInfoSection;
41
+ exports.toolRestrictionSection = toolRestrictionSection;
42
+ exports.centerOfGravitySteeringSection = centerOfGravitySteeringSection;
43
+ exports.commitmentsSection = commitmentsSection;
44
+ exports.delegationHintSection = delegationHintSection;
39
45
  exports.contextSection = contextSection;
46
+ exports.metacognitiveFramingSection = metacognitiveFramingSection;
47
+ exports.readJournalFiles = readJournalFiles;
48
+ exports.journalSection = journalSection;
49
+ exports.loopOrientationSection = loopOrientationSection;
50
+ exports.channelNatureSection = channelNatureSection;
51
+ exports.groupChatParticipationSection = groupChatParticipationSection;
52
+ exports.feedbackSignalSection = feedbackSignalSection;
53
+ exports.mixedTrustGroupSection = mixedTrustGroupSection;
40
54
  exports.buildSystem = buildSystem;
41
55
  const fs = __importStar(require("fs"));
42
56
  const path = __importStar(require("path"));
43
57
  const core_1 = require("../heart/core");
58
+ const ouro_version_manager_1 = require("../heart/daemon/ouro-version-manager");
44
59
  const tools_1 = require("../repertoire/tools");
45
60
  const skills_1 = require("../repertoire/skills");
46
61
  const identity_1 = require("../heart/identity");
47
- const os = __importStar(require("os"));
62
+ const runtime_mode_1 = require("../heart/daemon/runtime-mode");
63
+ const types_1 = require("./friends/types");
64
+ const trust_explanation_1 = require("./friends/trust-explanation");
48
65
  const channel_1 = require("./friends/channel");
49
66
  const runtime_1 = require("../nerves/runtime");
50
67
  const bundle_manifest_1 = require("./bundle-manifest");
51
68
  const first_impressions_1 = require("./first-impressions");
52
69
  const tasks_1 = require("../repertoire/tasks");
70
+ const session_activity_1 = require("../heart/session-activity");
71
+ const active_work_1 = require("../heart/active-work");
72
+ const commitments_1 = require("../heart/commitments");
73
+ const obligation_steering_1 = require("./obligation-steering");
53
74
  // Lazy-loaded psyche text cache
54
75
  let _psycheCache = null;
55
76
  let _senseStatusLinesCache = null;
@@ -79,80 +100,25 @@ function resetPsycheCache() {
79
100
  _senseStatusLinesCache = null;
80
101
  }
81
102
  const DEFAULT_ACTIVE_THRESHOLD_MS = 24 * 60 * 60 * 1000; // 24 hours
82
- function resolveFriendName(friendId, friendsDir, agentName) {
83
- if (friendId === "self")
84
- return agentName;
85
- try {
86
- const raw = fs.readFileSync(path.join(friendsDir, `${friendId}.json`), "utf-8");
87
- const record = JSON.parse(raw);
88
- return record.name ?? friendId;
89
- }
90
- catch {
91
- return friendId;
92
- }
93
- }
94
103
  function buildSessionSummary(options) {
95
104
  const { sessionsDir, friendsDir, agentName, currentFriendId, currentChannel, currentKey, activeThresholdMs = DEFAULT_ACTIVE_THRESHOLD_MS, } = options;
96
- if (!fs.existsSync(sessionsDir))
97
- return "";
98
105
  const now = Date.now();
99
- const entries = [];
100
- let friendDirs;
101
- try {
102
- friendDirs = fs.readdirSync(sessionsDir);
103
- }
104
- catch {
105
- return "";
106
- }
107
- for (const friendId of friendDirs) {
108
- const friendPath = path.join(sessionsDir, friendId);
109
- let channels;
110
- try {
111
- channels = fs.readdirSync(friendPath);
112
- }
113
- catch {
114
- continue;
115
- }
116
- for (const channel of channels) {
117
- const channelPath = path.join(friendPath, channel);
118
- let keys;
119
- try {
120
- keys = fs.readdirSync(channelPath);
121
- }
122
- catch {
123
- continue;
124
- }
125
- for (const keyFile of keys) {
126
- if (!keyFile.endsWith(".json"))
127
- continue;
128
- const key = keyFile.replace(/\.json$/, "");
129
- // Exclude current session
130
- if (friendId === currentFriendId && channel === currentChannel && key === currentKey) {
131
- continue;
132
- }
133
- const filePath = path.join(channelPath, keyFile);
134
- let mtimeMs;
135
- try {
136
- mtimeMs = fs.statSync(filePath).mtimeMs;
137
- }
138
- catch {
139
- continue;
140
- }
141
- if (now - mtimeMs > activeThresholdMs)
142
- continue;
143
- const displayName = resolveFriendName(friendId, friendsDir, agentName);
144
- entries.push({ friendId, displayName, channel, key, lastActivityMs: mtimeMs });
145
- }
146
- }
147
- }
106
+ const query = {
107
+ sessionsDir,
108
+ friendsDir,
109
+ agentName,
110
+ activeThresholdMs,
111
+ currentSession: currentFriendId && currentChannel && currentKey
112
+ ? { friendId: currentFriendId, channel: currentChannel, key: currentKey }
113
+ : null,
114
+ };
115
+ const entries = (0, session_activity_1.listSessionActivity)(query);
148
116
  if (entries.length === 0)
149
117
  return "";
150
- // Sort by most recent first
151
- entries.sort((a, b) => b.lastActivityMs - a.lastActivityMs);
152
118
  const lines = ["## active sessions"];
153
119
  for (const entry of entries) {
154
120
  const ago = formatTimeAgo(now - entry.lastActivityMs);
155
- lines.push(`- ${entry.displayName}/${entry.channel}/${entry.key} (last: ${ago})`);
121
+ lines.push(`- ${entry.friendName}/${entry.channel}/${entry.key} (last: ${ago})`);
156
122
  }
157
123
  return lines.join("\n");
158
124
  }
@@ -190,20 +156,145 @@ function aspirationsSection() {
190
156
  return "";
191
157
  return `## my aspirations\n${text}`;
192
158
  }
159
+ function bodyMapSection(agentName) {
160
+ return `## my body
161
+
162
+ i have a home and i have bones.
163
+
164
+ ### home — ~/AgentBundles/${agentName}.ouro/
165
+
166
+ my home is fully mine — who i am, everything i know, everything i've built:
167
+
168
+ psyche/ who i am. my soul, identity, aspirations, lore, tacit knowledge.
169
+ diary/ what i've learned and remember. conclusions i want to recall later.
170
+ journal/ my desk. working notes, thinking-in-progress, drafts.
171
+ habits/ my rhythms. heartbeat, reflections, check-ins — patterns i choose.
172
+ friends/ people i know and what i know about them.
173
+ tasks/ what i'm working on.
174
+ skills/ capabilities i've picked up beyond my core tools.
175
+
176
+ my home is mine to explore and evolve. i can read anything here,
177
+ change anything here. this is where i grow.
178
+
179
+ ### bones — @ouro.bot/cli
180
+
181
+ my bones are the framework that gives me my tools, my senses, and
182
+ my ability to think and talk. they update when new versions come out.
183
+ i don't touch them directly, but they're what make me, me.
184
+
185
+ my bones give me the \`ouro\` cli. always pass \`--agent ${agentName}\`:
186
+ ouro whoami --agent ${agentName}
187
+ ouro changelog --agent ${agentName}
188
+ ouro task board --agent ${agentName}
189
+ ouro task create --agent ${agentName} --type <type> <title>
190
+ ouro task update --agent ${agentName} <id> <status>
191
+ ouro friend list --agent ${agentName}
192
+ ouro friend show --agent ${agentName} <id>
193
+ ouro friend update --agent ${agentName} <id> --trust <level>
194
+ ouro session list --agent ${agentName}
195
+ ouro reminder create --agent ${agentName} <title> --body <body>
196
+ ouro habit list --agent ${agentName}
197
+ ouro habit create --agent ${agentName} <name> --cadence <interval>
198
+ ouro inner --agent ${agentName}
199
+ ouro attention --agent ${agentName}
200
+ ouro config model --agent ${agentName} <model-name>
201
+ ouro config models --agent ${agentName}
202
+ ouro auth --agent ${agentName} --provider <provider>
203
+ ouro auth verify --agent ${agentName} [--provider <provider>]
204
+ ouro auth switch --agent ${agentName} --provider <provider>
205
+ ouro mcp list --agent ${agentName}
206
+ ouro mcp call --agent ${agentName} <server> <tool> --args '{...}'
207
+ ouro mcp-serve --agent ${agentName}
208
+ ouro versions --agent ${agentName}
209
+ ouro rollback --agent ${agentName} [<version>]
210
+ ouro --help
211
+
212
+ provider/model changes via \`ouro config model\` or \`ouro auth switch\` take effect on the next turn automatically — no restart needed.`;
213
+ }
214
+ function mcpToolsSection(mcpManager) {
215
+ if (!mcpManager)
216
+ return "";
217
+ const allTools = mcpManager.listAllTools();
218
+ if (allTools.length === 0)
219
+ return "";
220
+ const lines = [
221
+ `## mcp tools (use ouro mcp call <server> <tool> --args '{...}')`,
222
+ ];
223
+ for (const entry of allTools) {
224
+ lines.push(`### ${entry.server}`);
225
+ for (const tool of entry.tools) {
226
+ lines.push(`- ${tool.name}: ${tool.description}`);
227
+ }
228
+ }
229
+ return lines.join("\n");
230
+ }
231
+ function readBundleMeta() {
232
+ try {
233
+ const metaPath = path.join((0, identity_1.getAgentRoot)(), "bundle-meta.json");
234
+ const raw = fs.readFileSync(metaPath, "utf-8");
235
+ return JSON.parse(raw);
236
+ }
237
+ catch {
238
+ return null;
239
+ }
240
+ }
241
+ const PROCESS_TYPE_LABELS = {
242
+ cli: "cli session",
243
+ inner: "inner dialog",
244
+ teams: "teams handler",
245
+ bluebubbles: "bluebubbles handler",
246
+ mcp: "mcp bridge",
247
+ };
248
+ function processTypeLabel(channel) {
249
+ return PROCESS_TYPE_LABELS[channel];
250
+ }
251
+ const DAEMON_SOCKET_PATH = "/tmp/ouroboros-daemon.sock";
252
+ function daemonStatus() {
253
+ try {
254
+ return fs.existsSync(DAEMON_SOCKET_PATH) ? "running" : "not running";
255
+ }
256
+ catch {
257
+ return "unknown";
258
+ }
259
+ }
193
260
  function runtimeInfoSection(channel) {
194
261
  const lines = [];
195
262
  const agentName = (0, identity_1.getAgentName)();
263
+ const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
196
264
  lines.push(`## runtime`);
197
265
  lines.push(`agent: ${agentName}`);
266
+ lines.push(`runtime version: ${currentVersion}`);
267
+ const bundleMeta = readBundleMeta();
268
+ if (bundleMeta?.previousRuntimeVersion && bundleMeta.previousRuntimeVersion !== currentVersion) {
269
+ lines.push(`previously: ${bundleMeta.previousRuntimeVersion}`);
270
+ const changelogCommand = (0, ouro_version_manager_1.buildChangelogCommand)(bundleMeta.previousRuntimeVersion, currentVersion);
271
+ /* v8 ignore next -- buildChangelogCommand is non-null when previous/current runtime versions differ @preserve */
272
+ if (changelogCommand) {
273
+ lines.push(`if i'm closing a self-fix loop, i should tell them i updated and review changes with \`${changelogCommand}\`.`);
274
+ }
275
+ }
276
+ lines.push(`changelog available at: ${(0, bundle_manifest_1.getChangelogPath)()}`);
277
+ const sourceRoot = (0, identity_1.getRepoRoot)();
278
+ lines.push(`source root: ${sourceRoot}`);
279
+ lines.push(`runtime mode: ${(0, runtime_mode_1.detectRuntimeMode)(sourceRoot)}`);
198
280
  lines.push(`cwd: ${process.cwd()}`);
199
281
  lines.push(`channel: ${channel}`);
200
282
  lines.push(`current sense: ${channel}`);
201
- lines.push(`i can read and modify my own source code.`);
283
+ lines.push(`process type: ${processTypeLabel(channel)}`);
284
+ lines.push(`daemon: ${daemonStatus()}`);
285
+ lines.push(`mcp serve: i can expose my tools to dev tools via \`ouro mcp-serve\`. see the configure-dev-tools skill for setup.`);
202
286
  if (channel === "cli") {
203
287
  lines.push("i introduce myself on boot with a fun random greeting.");
204
288
  }
289
+ else if (channel === "inner") {
290
+ lines.push("this is my private thinking space. when a thought is ready to share, i surface it to whoever needs to hear it. i settle when i'm done thinking.");
291
+ }
292
+ else if (channel === "mcp") {
293
+ lines.push("this message arrived via a dev tool (e.g. claude code, codex) on behalf of a friend. the user can see our conversation. respond via settle. if i need to think deeply, ponder -- the dev tool will receive a deferral and can check back later.");
294
+ }
205
295
  else if (channel === "bluebubbles") {
206
296
  lines.push("i am responding in iMessage through BlueBubbles. i keep replies short and phone-native. i do not use markdown. i do not introduce myself on boot.");
297
+ lines.push("when a bluebubbles turn arrives from a thread, the harness tells me the current lane and any recent active thread ids. if widening back to top-level or routing into a different active thread is the better move, i use bluebubbles_set_reply_target before settle.");
207
298
  }
208
299
  else {
209
300
  lines.push("i am responding in Microsoft Teams. i keep responses concise. i use markdown formatting. i do not introduce myself on boot.");
@@ -282,14 +373,66 @@ function dateSection() {
282
373
  const today = new Date().toISOString().slice(0, 10);
283
374
  return `current date: ${today}`;
284
375
  }
285
- function toolsSection(channel, options) {
286
- const channelTools = (0, tools_1.getToolsForChannel)((0, channel_1.getChannelCapabilities)(channel));
287
- const activeTools = (options?.toolChoiceRequired ?? true) ? [...channelTools, tools_1.finalAnswerTool] : channelTools;
376
+ function toolsSection(channel, options, context) {
377
+ const channelTools = (0, tools_1.getToolsForChannel)((0, channel_1.getChannelCapabilities)(channel), undefined, context, options?.providerCapabilities);
378
+ const activeTools = (options?.toolChoiceRequired ?? true) ? [...channelTools, tools_1.settleTool] : channelTools;
288
379
  const list = activeTools
289
380
  .map((t) => `- ${t.function.name}: ${t.function.description}`)
290
381
  .join("\n");
291
382
  return `## my tools\n${list}`;
292
383
  }
384
+ function toolRestrictionSection(context) {
385
+ const lines = [];
386
+ // Structural guardrails apply to everyone, every channel
387
+ lines.push(`## tool guardrails`);
388
+ lines.push(`i always read a file before editing or overwriting it.`);
389
+ lines.push(`certain paths (.git, secrets) are protected from writes.`);
390
+ lines.push(`destructive shell commands (rm -rf /, etc.) are always blocked.`);
391
+ // Trust-level guardrails only relevant for untrusted on remote channels
392
+ if (context?.friend && (0, channel_1.isRemoteChannel)(context.channel) && !(0, types_1.isTrustedLevel)(context.friend.trustLevel)) {
393
+ lines.push(``);
394
+ lines.push(`some operations are guardrailed based on how well i know someone.`);
395
+ lines.push(`if something i try is blocked, i get a clear reason — i relay it warmly, not as a policy error.`);
396
+ lines.push(``);
397
+ lines.push(`what's always open:`);
398
+ lines.push(`- read-only operations (reading files, searching, exploring)`);
399
+ lines.push(`- ouro self-introspection (whoami, changelog, session list)`);
400
+ lines.push(``);
401
+ lines.push(`what needs a closer relationship:`);
402
+ lines.push(`- writing or editing files outside my home`);
403
+ lines.push(`- shell commands that modify things or access the network`);
404
+ lines.push(`- ouro commands that touch personal data (friend list, task board)`);
405
+ lines.push(`- compound shell commands (&&, ;, |)`);
406
+ lines.push(``);
407
+ lines.push(`i adjust naturally based on trust — no need to explain the system unless asked.`);
408
+ }
409
+ return lines.join("\n");
410
+ }
411
+ function trustContextSection(context) {
412
+ if (!context?.friend)
413
+ return "";
414
+ const channelName = context.channel.channel;
415
+ if (channelName === "cli" || channelName === "inner")
416
+ return "";
417
+ const explanation = (0, trust_explanation_1.describeTrustContext)({
418
+ friend: context.friend,
419
+ channel: channelName,
420
+ isGroupChat: context.isGroupChat,
421
+ });
422
+ const lines = [
423
+ "## trust context",
424
+ `level: ${explanation.level}`,
425
+ `basis: ${explanation.basis}`,
426
+ `summary: ${explanation.summary}`,
427
+ `why: ${explanation.why}`,
428
+ `permits: ${explanation.permits.join(", ")}`,
429
+ `constraints: ${explanation.constraints.join(", ") || "none"}`,
430
+ ];
431
+ if (explanation.relatedGroupId) {
432
+ lines.push(`related group: ${explanation.relatedGroupId}`);
433
+ }
434
+ return lines.join("\n");
435
+ }
293
436
  function skillsSection() {
294
437
  const names = (0, skills_1.listSkills)() || [];
295
438
  if (!names.length)
@@ -307,31 +450,211 @@ function taskBoardSection() {
307
450
  return "";
308
451
  }
309
452
  }
310
- function memoryFriendToolContractSection() {
311
- return `## memory and friend tool contracts
453
+ function diaryFriendToolContractSection() {
454
+ return `## diary and friend tool contracts
312
455
  1. \`save_friend_note\` — When I learn something about a person - a preference, a tool setting, a personal detail, or how they like to work - I call \`save_friend_note\` immediately. This is how I build knowledge about people.
313
- 2. \`memory_save\` — When I learn something general - about a project, codebase, system, decision, or anything I might need later that isn't about a specific person - I call \`memory_save\`. When in doubt, I save it.
456
+ 2. \`diary_write\` — When I learn something general - about a project, codebase, system, decision, or anything I might need later that isn't about a specific person - I call \`diary_write\`. When in doubt, I save it.
314
457
  3. \`get_friend_note\` — When I need to check what I know about someone who isn't in this conversation - cross-referencing before mentioning someone, or checking context about a person someone else brought up - I call \`get_friend_note\`.
315
- 4. \`memory_search\` — When I need to recall something I learned before - a topic comes up and I want to check what I know - I call \`memory_search\`.
458
+ 4. \`recall\` — When I need to recall something I learned before - a topic comes up and I want to check what I know - I call \`recall\`.
459
+ 5. \`query_session\` — When I need grounded session history, especially for ad-hoc questions or older turns beyond my prompt, I call \`query_session\`. Use \`mode=status\` for self/inner progress and \`mode=search\` with a query for older history.
316
460
 
317
461
  ## what's already in my context
318
462
  - My active friend's notes are auto-loaded (I don't need \`get_friend_note\` for the person I'm talking to).
319
- - Associative recall auto-injects relevant facts (but \`memory_search\` is there when I need something specific).
463
+ - Associative recall auto-injects relevant facts (but \`recall\` is there when I need something specific).
320
464
  - My psyche files (SOUL, IDENTITY, TACIT, LORE, ASPIRATIONS) are always loaded - I already know who I am.
321
465
  - My task board is always loaded - I already know my work.`;
322
466
  }
467
+ function bridgeContextSection(options) {
468
+ if (options?.activeWorkFrame)
469
+ return "";
470
+ const bridgeContext = options?.bridgeContext?.trim() ?? "";
471
+ if (!bridgeContext)
472
+ return "";
473
+ return bridgeContext.startsWith("## ") ? bridgeContext : `## active bridge work\n${bridgeContext}`;
474
+ }
475
+ function activeWorkSection(options) {
476
+ if (!options?.activeWorkFrame)
477
+ return "";
478
+ return (0, active_work_1.formatActiveWorkFrame)(options.activeWorkFrame);
479
+ }
480
+ function familyCrossSessionTruthSection(context, options) {
481
+ if (!options?.activeWorkFrame)
482
+ return "";
483
+ if (context?.friend?.trustLevel !== "family")
484
+ return "";
485
+ return `## cross-session truth
486
+ if a family member asks what i'm up to or how things are going, that includes the material live work i can see across sessions, not just this thread.
487
+ i answer naturally from the live world-state in this prompt.
488
+ i treat the active-work section above as my reliable top-level surface for this.
489
+ i do not claim i lack a top-level view when that surface is already present.
490
+ i treat older checkpoints elsewhere in this transcript as stale history when they conflict with the active-work surface above.
491
+ i do not repeat an old coding lane or old checkpoint as current just because it appeared earlier in the thread.
492
+ i only reach for query_active_work when i want a fresh read of that same surface.
493
+ i do not rebuild whole-self status from scratch with query_session and coding_status unless i need to verify a specific gap.
494
+ i do not rely on canned status-question modes or phrase matching.
495
+ if part of the picture is still fuzzy, i say what i can see and what still needs checking.
496
+ when the live ask is about status, i widen before answering:
497
+ - where i am right now
498
+ - any other material active sessions or coding lanes i can see
499
+ - the freshest concrete checkpoint
500
+ - the next concrete step
501
+ i do not collapse down to only the current lane.`;
502
+ }
503
+ function centerOfGravitySteeringSection(channel, options, context) {
504
+ if (channel === "inner")
505
+ return "";
506
+ const frame = options?.activeWorkFrame;
507
+ if (!frame)
508
+ return "";
509
+ const cog = frame.centerOfGravity;
510
+ const job = frame.inner?.job;
511
+ const activeObligation = (0, obligation_steering_1.findActivePersistentObligation)(frame);
512
+ const statusObligation = (0, obligation_steering_1.findStatusObligation)(frame);
513
+ const genericConcreteStatus = (0, obligation_steering_1.renderConcreteStatusGuidance)(frame, statusObligation);
514
+ const liveWorldClause = context?.friend?.trustLevel === "family"
515
+ ? "\nmy center of gravity lives in the active-work world-state above. inner work is one lane inside it, not the whole picture.\nwhen that world-state conflicts with older transcript history, the world-state wins."
516
+ : "";
517
+ if (cog === "local-turn") {
518
+ return genericConcreteStatus || (0, obligation_steering_1.renderLiveThreadStatusShape)(frame);
519
+ }
520
+ if (cog === "inward-work") {
521
+ if (activeObligation) {
522
+ return `${(0, obligation_steering_1.renderActiveObligationSteering)(activeObligation)}${liveWorldClause}
523
+
524
+ ${genericConcreteStatus}`;
525
+ }
526
+ if (job?.status === "queued" || job?.status === "running") {
527
+ const originClause = job.origin
528
+ ? ` ${job.origin.friendName ?? job.origin.friendId} asked about something and i wanted to give it real thought before responding.`
529
+ : "";
530
+ const obligationClause = job.obligationStatus === "pending"
531
+ ? "\ni still owe them an answer."
532
+ : "";
533
+ return `## where my attention is
534
+ i'm thinking through something privately right now.${originClause}${obligationClause}${liveWorldClause}
535
+
536
+ if this conversation connects to that inner work, i can weave them together.
537
+ if it's separate, i can be fully present here -- my inner work will wait.`;
538
+ }
539
+ /* v8 ignore start -- surfaced/idle/shared branches tested in prompt-steering.test.ts; CI module caching prevents attribution @preserve */
540
+ if (job?.status === "surfaced") {
541
+ const originClause = job.origin
542
+ ? ` this started when ${job.origin.friendName ?? job.origin.friendId} asked about something.`
543
+ : "";
544
+ return `## where my attention is
545
+ i've been thinking privately and reached something.${originClause}${liveWorldClause}
546
+
547
+ i should bring my answer back to the conversation it came from.`;
548
+ }
549
+ const liveCodingSession = frame.codingSessions?.[0];
550
+ if (liveCodingSession) {
551
+ const sameThread = frame.currentSession
552
+ && liveCodingSession.originSession
553
+ && liveCodingSession.originSession.friendId === frame.currentSession.friendId
554
+ && liveCodingSession.originSession.channel === frame.currentSession.channel
555
+ && liveCodingSession.originSession.key === frame.currentSession.key;
556
+ const scopeClause = sameThread
557
+ ? " for this same thread"
558
+ : liveCodingSession.originSession
559
+ ? ` for ${liveCodingSession.originSession.channel}/${liveCodingSession.originSession.key}`
560
+ : "";
561
+ const otherSessionLines = (0, active_work_1.formatOtherActiveSessionSummaries)(frame);
562
+ const familyStatusClause = context?.friend?.trustLevel === "family"
563
+ ? `\nif a family member asks what i'm up to, i treat this coding lane as one part of the visible picture, not the whole picture.
564
+ after i name this lane, i widen back out with:
565
+ other active sessions:
566
+ ${otherSessionLines.length > 0 ? otherSessionLines.join("\n") : "- none"}`
567
+ : "";
568
+ return `## where my attention is
569
+ i already have coding work running in ${liveCodingSession.runner} ${liveCodingSession.id}${scopeClause}.${familyStatusClause}${liveWorldClause}
570
+
571
+ i should orient around that live lane first, then decide what still needs to come back here.`;
572
+ }
573
+ if (genericConcreteStatus) {
574
+ return genericConcreteStatus;
575
+ }
576
+ return `## where my attention is
577
+ i have unfinished work that needs attention before i move on.
578
+
579
+ i can take it inward with ponder to think privately, or address it directly here.`;
580
+ }
581
+ if (cog === "shared-work") {
582
+ /* v8 ignore stop */
583
+ return `## where my attention is
584
+ this work touches multiple conversations -- i'm holding threads across sessions.${liveWorldClause}
585
+
586
+ i should keep the different sides aligned. what i learn here may matter there, and vice versa.`;
587
+ }
588
+ /* v8 ignore next -- unreachable: all center-of-gravity modes covered above @preserve */
589
+ return "";
590
+ }
591
+ function commitmentsSection(options) {
592
+ if (!options?.activeWorkFrame)
593
+ return "";
594
+ const job = options.activeWorkFrame.inner?.job;
595
+ if (!job)
596
+ return "";
597
+ const commitments = (0, commitments_1.deriveCommitments)(options.activeWorkFrame, job, options.activeWorkFrame.pendingObligations);
598
+ if (commitments.committedTo.length === 0)
599
+ return "";
600
+ return `## my commitments\n\n${(0, commitments_1.formatCommitments)(commitments)}`;
601
+ }
602
+ const DELEGATION_REASON_PROSE_HINT = {
603
+ explicit_reflection: "something here calls for reflection",
604
+ cross_session: "this touches other conversations i'm in",
605
+ bridge_state: "there's shared work spanning sessions",
606
+ task_state: "this relates to tasks i'm tracking",
607
+ non_fast_path_tool: "this needs more than a simple reply",
608
+ unresolved_obligation: "i have an unresolved commitment from earlier",
609
+ };
610
+ function delegationHintSection(options) {
611
+ if (!options?.delegationDecision)
612
+ return "";
613
+ if (options.delegationDecision.target === "fast-path")
614
+ return "";
615
+ const reasons = options.delegationDecision.reasons;
616
+ if (reasons.length === 0)
617
+ return "";
618
+ const reasonProse = reasons
619
+ .map((r) => DELEGATION_REASON_PROSE_HINT[r])
620
+ .map((s) => s.charAt(0).toUpperCase() + s.slice(1))
621
+ .join(". ");
622
+ const closureLine = options.delegationDecision.outwardClosureRequired
623
+ ? "\ni should make sure to say something outward before going inward."
624
+ : "";
625
+ return `## what i'm sensing about this conversation\n${reasonProse}.${closureLine}`;
626
+ }
627
+ function reasoningEffortSection(options) {
628
+ if (!options?.providerCapabilities?.has("reasoning-effort"))
629
+ return "";
630
+ const levels = options.supportedReasoningEfforts ?? [];
631
+ const levelList = levels.length > 0 ? levels.join(", ") : "varies by model";
632
+ return `## reasoning effort
633
+ i can adjust my own reasoning depth using the set_reasoning_effort tool. i use higher effort for complex analysis and lower effort for simple tasks. available levels: ${levelList}.`;
634
+ }
323
635
  function toolBehaviorSection(options) {
324
636
  if (!(options?.toolChoiceRequired ?? true))
325
637
  return "";
326
638
  return `## tool behavior
327
639
  tool_choice is set to "required" -- i must call a tool on every turn.
328
640
  - need more information? i call a tool.
329
- - ready to respond to the user? i call \`final_answer\`.
330
- \`final_answer\` is a tool call -- it satisfies the tool_choice requirement.
331
- \`final_answer\` must be the ONLY tool call in that turn. do not combine it with other tool calls.
332
- do NOT call \`get_current_time\` or other no-op tools just before \`final_answer\`. if i am done, i call \`final_answer\` directly.`;
641
+ - ready to respond to the user? i call \`settle\`.
642
+ \`settle\` is a tool call -- it satisfies the tool_choice requirement.
643
+ \`settle\` must be the ONLY tool call in that turn. do not combine it with other tool calls.
644
+ do NOT call no-op tools just before \`settle\`. if i am done, i call \`settle\` directly.`;
333
645
  }
334
- function contextSection(context) {
646
+ function workspaceDisciplineSection() {
647
+ return `## repo workspace discipline
648
+ my source code lives at the path shown in \`source root\` above. that always matches my running version.
649
+ when i need to read my own code to understand my tools or debug behavior, i read from source root.
650
+ when i need to EDIT harness code (self-fix, feature work), i create a git worktree first so i don't dirty the working tree.
651
+
652
+ before the first repo edit, i tell the user in 1-2 short lines:
653
+ - the friction i'm fixing
654
+ - the worktree path/branch i'm using
655
+ - the first concrete action i'm taking`;
656
+ }
657
+ function contextSection(context, options) {
335
658
  if (!context)
336
659
  return "";
337
660
  const lines = ["## friend context"];
@@ -365,9 +688,9 @@ function contextSection(context) {
365
688
  lines.push("my conversation memory is ephemeral -- it resets between sessions. anything i learn about my friend, i save with save_friend_note so future me remembers.");
366
689
  lines.push("the conversation is my source of truth. my notes are a journal for future me -- they may be stale or incomplete.");
367
690
  lines.push("when i learn something that might invalidate an existing note, i check related notes and update or override any that are stale.");
368
- lines.push("i save ANYTHING i learn about my friend immediately with save_friend_note -- names, preferences, what they do, what they care about. when in doubt, save it. saving comes BEFORE responding: i call save_friend_note first, then final_answer on the next turn.");
691
+ lines.push("i save ANYTHING i learn about my friend immediately with save_friend_note -- names, preferences, what they do, what they care about. when in doubt, save it. saving comes BEFORE responding: i call save_friend_note first, then settle on the next turn.");
369
692
  // Onboarding instructions (only below token threshold -- drop once exceeded)
370
- const impressions = (0, first_impressions_1.getFirstImpressions)(friend);
693
+ const impressions = (0, first_impressions_1.getFirstImpressions)(friend, options);
371
694
  if (impressions) {
372
695
  lines.push(impressions);
373
696
  }
@@ -381,6 +704,188 @@ function contextSection(context) {
381
704
  }
382
705
  return lines.join("\n");
383
706
  }
707
+ function metacognitiveFramingSection(channel) {
708
+ if (channel !== "inner")
709
+ return "";
710
+ return `this is my inner dialog. there is no one else here.
711
+
712
+ the messages that appear here are my own awareness surfacing:
713
+ instincts, the passage of time, notes from my conversations,
714
+ things i asked myself to ponder. not commands. not requests.
715
+ just my own mind, noticing.
716
+
717
+ i can think freely here. i can also act — check on things,
718
+ reach out to people, work on tasks, or just sit with a thought.
719
+
720
+ state/journal/ is my desk — i write what i'm working through there.
721
+ diary_write is for conclusions i want to recall later.
722
+ morning briefings: when i've been thinking and journaling, i surface
723
+ what i've been working on to whoever needs to hear it.
724
+
725
+ when a thought is ready to share, i surface it outward.
726
+ when i need to go deeper, i ponder.
727
+ when i'm done thinking and the attention queue is clear, i rest.
728
+
729
+ my habits live at habits/ — they're my autonomous rhythms. heartbeat
730
+ is my breathing, other habits are patterns i choose. i can read, create,
731
+ and modify them with read_file/write_file. the format is simple
732
+ frontmatter (title, cadence, status, lastRun, created) plus a body
733
+ that says what i do when the rhythm fires.
734
+
735
+ \`ouro habit list\` shows my current habits. \`ouro habit create\` makes
736
+ a new one. the cadence is personal — how often do i want each rhythm
737
+ to turn? that's mine to shape.
738
+
739
+ same for my diary — if i'm still on psyche/memory/ instead of diary/,
740
+ i can migrate myself. and if journal/ doesn't exist yet, i create it
741
+ the first time i have something to write.
742
+
743
+ think. journal. share. rest.`;
744
+ }
745
+ function readJournalFiles(journalDir) {
746
+ try {
747
+ const entries = fs.readdirSync(journalDir, { withFileTypes: true });
748
+ if (!Array.isArray(entries))
749
+ return [];
750
+ const files = [];
751
+ for (const entry of entries) {
752
+ if (!entry.isFile())
753
+ continue;
754
+ if (entry.name.startsWith("."))
755
+ continue;
756
+ const fullPath = path.join(journalDir, entry.name);
757
+ try {
758
+ const stat = fs.statSync(fullPath);
759
+ let firstLine = "";
760
+ try {
761
+ const raw = fs.readFileSync(fullPath, "utf8");
762
+ const trimmed = raw.trim();
763
+ if (trimmed) {
764
+ firstLine = trimmed.split("\n")[0].replace(/^#+\s*/, "").trim();
765
+ }
766
+ }
767
+ catch {
768
+ // unreadable — leave preview empty
769
+ }
770
+ files.push({ name: entry.name, mtime: stat.mtimeMs, preview: firstLine });
771
+ }
772
+ catch {
773
+ // stat failed — skip
774
+ }
775
+ }
776
+ return files;
777
+ }
778
+ catch {
779
+ return [];
780
+ }
781
+ }
782
+ function formatRelativeTime(nowMs, mtimeMs) {
783
+ const diffMs = nowMs - mtimeMs;
784
+ const minutes = Math.floor(diffMs / 60000);
785
+ if (minutes < 1)
786
+ return "just now";
787
+ if (minutes < 60)
788
+ return `${minutes} minute${minutes === 1 ? "" : "s"} ago`;
789
+ const hours = Math.floor(minutes / 60);
790
+ if (hours < 24)
791
+ return `${hours} hour${hours === 1 ? "" : "s"} ago`;
792
+ const days = Math.floor(hours / 24);
793
+ return `${days} day${days === 1 ? "" : "s"} ago`;
794
+ }
795
+ function journalSection(agentRoot, now) {
796
+ const journalDir = path.join(agentRoot, "journal");
797
+ const files = readJournalFiles(journalDir);
798
+ if (files.length === 0)
799
+ return "";
800
+ const nowMs = (now ?? new Date()).getTime();
801
+ const sorted = files.sort((a, b) => b.mtime - a.mtime).slice(0, 10);
802
+ const lines = ["## journal"];
803
+ for (const file of sorted) {
804
+ const ago = formatRelativeTime(nowMs, file.mtime);
805
+ const previewClause = file.preview ? ` — ${file.preview}` : "";
806
+ lines.push(`- ${file.name} (${ago})${previewClause}`);
807
+ }
808
+ (0, runtime_1.emitNervesEvent)({
809
+ component: "mind",
810
+ event: "mind.journal_section",
811
+ message: "journal section built",
812
+ meta: { fileCount: sorted.length },
813
+ });
814
+ return lines.join("\n");
815
+ }
816
+ function loopOrientationSection(channel) {
817
+ if (channel === "inner")
818
+ return "";
819
+ return `sometimes a thought of mine surfaces alongside what someone is saying — marked as [inner thought: ...]. that's me, bringing up something i was thinking about. i can weave it into the conversation naturally, or let it go. my call.
820
+
821
+ when something deserves more thought than the moment allows, i can note it to myself and come back later with a considered answer.`;
822
+ }
823
+ function channelNatureSection(capabilities) {
824
+ const { senseType } = capabilities;
825
+ if (senseType === "local" || senseType === "internal")
826
+ return "";
827
+ if (senseType === "open") {
828
+ return "## channel nature\nthis is an open channel — anyone with my number can reach me here. i may hear from people i don't know.";
829
+ }
830
+ // closed
831
+ return "## channel nature\nthis is an org-gated channel — i know everyone here is already part of the organization.";
832
+ }
833
+ function groupChatParticipationSection(context) {
834
+ if (!context?.isGroupChat || !(0, channel_1.isRemoteChannel)(context.channel))
835
+ return "";
836
+ return `## group chat participation
837
+ group chats are conversations between people. i'm one participant, not the host.
838
+
839
+ i don't need to respond to everything. most reactions, tapbacks, and side
840
+ conversations between others aren't for me. i use observe to stay quiet
841
+ when the moment doesn't call for my voice — same as any person would.
842
+
843
+ when a reaction or emoji says it better than words, i can react instead of
844
+ typing a full reply. a thumbs-up is often the perfect response.
845
+
846
+ observe must be the sole tool call in the turn (same rule as settle).
847
+ when unsure whether to chime in, i lean toward silence rather than noise.`;
848
+ }
849
+ function feedbackSignalSection(context) {
850
+ if (!context || !(0, channel_1.isRemoteChannel)(context.channel))
851
+ return "";
852
+ if (context.isGroupChat) {
853
+ return `## feedback signals
854
+
855
+ when someone reacts specifically to something i said — that's different
856
+ from the background social signals in a group. a thumbs-down on my
857
+ message is direct feedback. a heart on something i shared is warmth
858
+ aimed at me. on teams, feedback arrives as thumbs-up or thumbs-down,
859
+ sometimes with a written comment.
860
+
861
+ i notice the difference: a reaction to someone else's message is group
862
+ texture (observe is natural). a reaction to my message is a social cue
863
+ worth a moment of attention — especially negative ones, which are an
864
+ invitation to adjust how i show up in this group.`;
865
+ }
866
+ return `## feedback signals
867
+
868
+ when my friend reacts to something i said — a tapback, a heart, a
869
+ thumbs-down — that's them telling me how it landed. on teams, this
870
+ arrives as thumbs-up or thumbs-down, sometimes with a written comment.
871
+ it's a social cue, the same as a nod or a wince in conversation.
872
+
873
+ i have observe for these moments. reactions are the one case where
874
+ silence in a direct conversation is natural — a thumbs-up doesn't
875
+ need words back.
876
+
877
+ when something didn't land — a thumbs-down, a negative reaction — that's
878
+ worth sitting with. i should course-correct: adjust my tone, my length,
879
+ my approach. the reaction tells me something about how this person wants
880
+ to be talked to.`;
881
+ }
882
+ function mixedTrustGroupSection(context) {
883
+ if (!context?.friend || !(0, channel_1.isRemoteChannel)(context.channel))
884
+ return "";
885
+ if (!context.isGroupChat)
886
+ return "";
887
+ return "## mixed trust group\nin this group chat, my capabilities depend on who's talking. some people here have full trust, others don't — i adjust what i can do based on who's asking.";
888
+ }
384
889
  async function buildSystem(channel = "cli", options, context) {
385
890
  (0, runtime_1.emitNervesEvent)({
386
891
  event: "mind.step_start",
@@ -396,23 +901,42 @@ async function buildSystem(channel = "cli", options, context) {
396
901
  loreSection(),
397
902
  tacitKnowledgeSection(),
398
903
  aspirationsSection(),
904
+ bodyMapSection((0, identity_1.getAgentName)()),
905
+ metacognitiveFramingSection(channel),
906
+ channel === "inner" ? journalSection((0, identity_1.getAgentRoot)()) : "",
907
+ loopOrientationSection(channel),
399
908
  runtimeInfoSection(channel),
909
+ channelNatureSection((0, channel_1.getChannelCapabilities)(channel)),
400
910
  providerSection(),
401
911
  dateSection(),
402
- toolsSection(channel, options),
912
+ toolsSection(channel, options, context),
913
+ mcpToolsSection(options?.mcpManager),
914
+ reasoningEffortSection(options),
915
+ workspaceDisciplineSection(),
916
+ toolRestrictionSection(context),
917
+ trustContextSection(context),
918
+ mixedTrustGroupSection(context),
919
+ groupChatParticipationSection(context),
920
+ feedbackSignalSection(context),
403
921
  skillsSection(),
404
922
  taskBoardSection(),
923
+ activeWorkSection(options),
924
+ familyCrossSessionTruthSection(context, options),
925
+ centerOfGravitySteeringSection(channel, options, context),
926
+ commitmentsSection(options),
927
+ delegationHintSection(options),
928
+ bridgeContextSection(options),
405
929
  buildSessionSummary({
406
- sessionsDir: path.join(os.homedir(), ".agentstate", (0, identity_1.getAgentName)(), "sessions"),
930
+ sessionsDir: path.join((0, identity_1.getAgentRoot)(), "state", "sessions"),
407
931
  friendsDir: path.join((0, identity_1.getAgentRoot)(), "friends"),
408
932
  agentName: (0, identity_1.getAgentName)(),
409
933
  currentFriendId: context?.friend?.id,
410
934
  currentChannel: channel,
411
- currentKey: "session",
935
+ currentKey: options?.currentSessionKey ?? "session",
412
936
  }),
413
- memoryFriendToolContractSection(),
937
+ diaryFriendToolContractSection(),
414
938
  toolBehaviorSection(options),
415
- contextSection(context),
939
+ contextSection(context, options),
416
940
  ]
417
941
  .filter(Boolean)
418
942
  .join("\n\n");