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