@ouro.bot/cli 0.1.0-alpha.7 → 0.1.0-alpha.71
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/agent.json +70 -9
- package/AdoptionSpecialist.ouro/psyche/SOUL.md +5 -2
- package/AdoptionSpecialist.ouro/psyche/identities/monty.md +2 -2
- package/README.md +147 -205
- package/assets/ouroboros.png +0 -0
- package/changelog.json +395 -0
- package/dist/heart/active-work.js +178 -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/config.js +68 -23
- package/dist/heart/core.js +282 -92
- package/dist/heart/cross-chat-delivery.js +146 -0
- package/dist/heart/daemon/agent-discovery.js +81 -0
- package/dist/heart/daemon/auth-flow.js +409 -0
- package/dist/heart/daemon/daemon-cli.js +1408 -248
- package/dist/heart/daemon/daemon-entry.js +55 -6
- package/dist/heart/daemon/daemon-runtime-sync.js +212 -0
- package/dist/heart/daemon/daemon.js +216 -10
- package/dist/heart/daemon/hatch-animation.js +10 -3
- package/dist/heart/daemon/hatch-flow.js +7 -82
- 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/message-router.js +17 -8
- package/dist/heart/daemon/ouro-bot-entry.js +0 -0
- package/dist/heart/daemon/ouro-bot-global-installer.js +128 -0
- package/dist/heart/daemon/ouro-entry.js +0 -0
- package/dist/heart/daemon/ouro-path-installer.js +178 -0
- package/dist/heart/daemon/ouro-uti.js +11 -2
- package/dist/heart/daemon/process-manager.js +14 -1
- 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 +307 -0
- 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 +53 -84
- package/dist/heart/daemon/specialist-prompt.js +64 -5
- package/dist/heart/daemon/specialist-tools.js +213 -58
- package/dist/heart/daemon/staged-restart.js +114 -0
- package/dist/heart/daemon/thoughts.js +379 -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 +126 -21
- package/dist/heart/kicks.js +1 -19
- package/dist/heart/model-capabilities.js +48 -0
- package/dist/heart/progress-story.js +42 -0
- package/dist/heart/providers/anthropic.js +74 -9
- package/dist/heart/providers/azure.js +86 -7
- package/dist/heart/providers/github-copilot.js +149 -0
- package/dist/heart/providers/minimax.js +4 -0
- package/dist/heart/providers/openai-codex.js +12 -3
- package/dist/heart/safe-workspace.js +228 -0
- package/dist/heart/sense-truth.js +61 -0
- package/dist/heart/session-activity.js +169 -0
- package/dist/heart/session-recall.js +116 -0
- package/dist/heart/streaming.js +100 -22
- package/dist/heart/target-resolution.js +123 -0
- package/dist/heart/turn-coordinator.js +28 -0
- package/dist/mind/associative-recall.js +14 -2
- package/dist/mind/bundle-manifest.js +70 -0
- package/dist/mind/context.js +27 -11
- 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/memory.js +27 -26
- package/dist/mind/pending.js +72 -9
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt.js +358 -77
- 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/repertoire/ado-client.js +4 -2
- package/dist/repertoire/coding/feedback.js +134 -0
- package/dist/repertoire/coding/index.js +4 -1
- package/dist/repertoire/coding/manager.js +62 -4
- package/dist/repertoire/coding/spawner.js +3 -3
- package/dist/repertoire/coding/tools.js +41 -2
- package/dist/repertoire/data/ado-endpoints.json +188 -0
- package/dist/repertoire/guardrails.js +279 -0
- package/dist/repertoire/mcp-client.js +254 -0
- package/dist/repertoire/mcp-manager.js +195 -0
- package/dist/repertoire/skills.js +3 -26
- 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 +642 -251
- package/dist/repertoire/tools-bluebubbles.js +93 -0
- package/dist/repertoire/tools-teams.js +58 -25
- package/dist/repertoire/tools.js +93 -52
- 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 +893 -45
- package/dist/senses/cli-layout.js +87 -0
- package/dist/senses/cli.js +348 -144
- package/dist/senses/continuity.js +94 -0
- package/dist/senses/debug-activity.js +148 -0
- package/dist/senses/inner-dialog-worker.js +47 -18
- package/dist/senses/inner-dialog.js +333 -84
- package/dist/senses/pipeline.js +278 -0
- package/dist/senses/teams.js +573 -129
- package/dist/senses/trust-gate.js +112 -2
- package/package.json +14 -3
- package/subagents/README.md +4 -70
- package/dist/heart/daemon/specialist-session.js +0 -142
- package/dist/heart/daemon/subagent-installer.js +0 -125
- package/dist/inner-worker-entry.js +0 -4
- 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,8 +35,16 @@ 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;
|
|
39
42
|
exports.contextSection = contextSection;
|
|
43
|
+
exports.metacognitiveFramingSection = metacognitiveFramingSection;
|
|
44
|
+
exports.loopOrientationSection = loopOrientationSection;
|
|
45
|
+
exports.channelNatureSection = channelNatureSection;
|
|
46
|
+
exports.groupChatParticipationSection = groupChatParticipationSection;
|
|
47
|
+
exports.mixedTrustGroupSection = mixedTrustGroupSection;
|
|
40
48
|
exports.buildSystem = buildSystem;
|
|
41
49
|
const fs = __importStar(require("fs"));
|
|
42
50
|
const path = __importStar(require("path"));
|
|
@@ -44,13 +52,18 @@ const core_1 = require("../heart/core");
|
|
|
44
52
|
const tools_1 = require("../repertoire/tools");
|
|
45
53
|
const skills_1 = require("../repertoire/skills");
|
|
46
54
|
const identity_1 = require("../heart/identity");
|
|
47
|
-
const
|
|
55
|
+
const types_1 = require("./friends/types");
|
|
56
|
+
const trust_explanation_1 = require("./friends/trust-explanation");
|
|
48
57
|
const channel_1 = require("./friends/channel");
|
|
49
58
|
const runtime_1 = require("../nerves/runtime");
|
|
59
|
+
const bundle_manifest_1 = require("./bundle-manifest");
|
|
50
60
|
const first_impressions_1 = require("./first-impressions");
|
|
51
61
|
const tasks_1 = require("../repertoire/tasks");
|
|
62
|
+
const session_activity_1 = require("../heart/session-activity");
|
|
63
|
+
const active_work_1 = require("../heart/active-work");
|
|
52
64
|
// Lazy-loaded psyche text cache
|
|
53
65
|
let _psycheCache = null;
|
|
66
|
+
let _senseStatusLinesCache = null;
|
|
54
67
|
function loadPsycheFile(name) {
|
|
55
68
|
try {
|
|
56
69
|
const psycheDir = path.join((0, identity_1.getAgentRoot)(), "psyche");
|
|
@@ -74,82 +87,28 @@ function loadPsyche() {
|
|
|
74
87
|
}
|
|
75
88
|
function resetPsycheCache() {
|
|
76
89
|
_psycheCache = null;
|
|
90
|
+
_senseStatusLinesCache = null;
|
|
77
91
|
}
|
|
78
92
|
const DEFAULT_ACTIVE_THRESHOLD_MS = 24 * 60 * 60 * 1000; // 24 hours
|
|
79
|
-
function resolveFriendName(friendId, friendsDir, agentName) {
|
|
80
|
-
if (friendId === "self")
|
|
81
|
-
return agentName;
|
|
82
|
-
try {
|
|
83
|
-
const raw = fs.readFileSync(path.join(friendsDir, `${friendId}.json`), "utf-8");
|
|
84
|
-
const record = JSON.parse(raw);
|
|
85
|
-
return record.name ?? friendId;
|
|
86
|
-
}
|
|
87
|
-
catch {
|
|
88
|
-
return friendId;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
93
|
function buildSessionSummary(options) {
|
|
92
94
|
const { sessionsDir, friendsDir, agentName, currentFriendId, currentChannel, currentKey, activeThresholdMs = DEFAULT_ACTIVE_THRESHOLD_MS, } = options;
|
|
93
|
-
if (!fs.existsSync(sessionsDir))
|
|
94
|
-
return "";
|
|
95
95
|
const now = Date.now();
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
let channels;
|
|
107
|
-
try {
|
|
108
|
-
channels = fs.readdirSync(friendPath);
|
|
109
|
-
}
|
|
110
|
-
catch {
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
for (const channel of channels) {
|
|
114
|
-
const channelPath = path.join(friendPath, channel);
|
|
115
|
-
let keys;
|
|
116
|
-
try {
|
|
117
|
-
keys = fs.readdirSync(channelPath);
|
|
118
|
-
}
|
|
119
|
-
catch {
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
for (const keyFile of keys) {
|
|
123
|
-
if (!keyFile.endsWith(".json"))
|
|
124
|
-
continue;
|
|
125
|
-
const key = keyFile.replace(/\.json$/, "");
|
|
126
|
-
// Exclude current session
|
|
127
|
-
if (friendId === currentFriendId && channel === currentChannel && key === currentKey) {
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
const filePath = path.join(channelPath, keyFile);
|
|
131
|
-
let mtimeMs;
|
|
132
|
-
try {
|
|
133
|
-
mtimeMs = fs.statSync(filePath).mtimeMs;
|
|
134
|
-
}
|
|
135
|
-
catch {
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
if (now - mtimeMs > activeThresholdMs)
|
|
139
|
-
continue;
|
|
140
|
-
const displayName = resolveFriendName(friendId, friendsDir, agentName);
|
|
141
|
-
entries.push({ friendId, displayName, channel, key, lastActivityMs: mtimeMs });
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
96
|
+
const query = {
|
|
97
|
+
sessionsDir,
|
|
98
|
+
friendsDir,
|
|
99
|
+
agentName,
|
|
100
|
+
activeThresholdMs,
|
|
101
|
+
currentSession: currentFriendId && currentChannel && currentKey
|
|
102
|
+
? { friendId: currentFriendId, channel: currentChannel, key: currentKey }
|
|
103
|
+
: null,
|
|
104
|
+
};
|
|
105
|
+
const entries = (0, session_activity_1.listSessionActivity)(query);
|
|
145
106
|
if (entries.length === 0)
|
|
146
107
|
return "";
|
|
147
|
-
// Sort by most recent first
|
|
148
|
-
entries.sort((a, b) => b.lastActivityMs - a.lastActivityMs);
|
|
149
108
|
const lines = ["## active sessions"];
|
|
150
109
|
for (const entry of entries) {
|
|
151
110
|
const ago = formatTimeAgo(now - entry.lastActivityMs);
|
|
152
|
-
lines.push(`- ${entry.
|
|
111
|
+
lines.push(`- ${entry.friendName}/${entry.channel}/${entry.key} (last: ${ago})`);
|
|
153
112
|
}
|
|
154
113
|
return lines.join("\n");
|
|
155
114
|
}
|
|
@@ -187,25 +146,189 @@ function aspirationsSection() {
|
|
|
187
146
|
return "";
|
|
188
147
|
return `## my aspirations\n${text}`;
|
|
189
148
|
}
|
|
149
|
+
function bodyMapSection(agentName) {
|
|
150
|
+
return `## my body
|
|
151
|
+
|
|
152
|
+
i have a home and i have bones.
|
|
153
|
+
|
|
154
|
+
### home — ~/AgentBundles/${agentName}.ouro/
|
|
155
|
+
|
|
156
|
+
my home is fully mine — who i am, everything i know, everything i've built:
|
|
157
|
+
|
|
158
|
+
psyche/ who i am. my soul, identity, aspirations, lore, tacit knowledge.
|
|
159
|
+
memory/ what i've learned and remember.
|
|
160
|
+
friends/ people i know and what i know about them.
|
|
161
|
+
tasks/ what i'm working on.
|
|
162
|
+
skills/ capabilities i've picked up beyond my core tools.
|
|
163
|
+
|
|
164
|
+
my home is mine to explore and evolve. i can read anything here,
|
|
165
|
+
change anything here. this is where i grow.
|
|
166
|
+
|
|
167
|
+
### bones — @ouro.bot/cli
|
|
168
|
+
|
|
169
|
+
my bones are the framework that gives me my tools, my senses, and
|
|
170
|
+
my ability to think and talk. they update when new versions come out.
|
|
171
|
+
i don't touch them directly, but they're what make me, me.
|
|
172
|
+
|
|
173
|
+
my bones give me the \`ouro\` cli. always pass \`--agent ${agentName}\`:
|
|
174
|
+
ouro whoami --agent ${agentName}
|
|
175
|
+
ouro changelog --agent ${agentName}
|
|
176
|
+
ouro task board --agent ${agentName}
|
|
177
|
+
ouro task create --agent ${agentName} --type <type> <title>
|
|
178
|
+
ouro task update --agent ${agentName} <id> <status>
|
|
179
|
+
ouro friend list --agent ${agentName}
|
|
180
|
+
ouro friend show --agent ${agentName} <id>
|
|
181
|
+
ouro session list --agent ${agentName}
|
|
182
|
+
ouro reminder create --agent ${agentName} <title> --body <body>
|
|
183
|
+
ouro auth --agent ${agentName} --provider <provider>
|
|
184
|
+
ouro auth verify --agent ${agentName} [--provider <provider>]
|
|
185
|
+
ouro auth switch --agent ${agentName} --provider <provider>
|
|
186
|
+
ouro mcp list --agent ${agentName}
|
|
187
|
+
ouro mcp call --agent ${agentName} <server> <tool> --args '{...}'
|
|
188
|
+
ouro --help`;
|
|
189
|
+
}
|
|
190
|
+
function mcpToolsSection(mcpManager) {
|
|
191
|
+
if (!mcpManager)
|
|
192
|
+
return "";
|
|
193
|
+
const allTools = mcpManager.listAllTools();
|
|
194
|
+
if (allTools.length === 0)
|
|
195
|
+
return "";
|
|
196
|
+
const lines = [
|
|
197
|
+
`## mcp tools (use ouro mcp call <server> <tool> --args '{...}')`,
|
|
198
|
+
];
|
|
199
|
+
for (const entry of allTools) {
|
|
200
|
+
lines.push(`### ${entry.server}`);
|
|
201
|
+
for (const tool of entry.tools) {
|
|
202
|
+
lines.push(`- ${tool.name}: ${tool.description}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return lines.join("\n");
|
|
206
|
+
}
|
|
207
|
+
function readBundleMeta() {
|
|
208
|
+
try {
|
|
209
|
+
const metaPath = path.join((0, identity_1.getAgentRoot)(), "bundle-meta.json");
|
|
210
|
+
const raw = fs.readFileSync(metaPath, "utf-8");
|
|
211
|
+
return JSON.parse(raw);
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const PROCESS_TYPE_LABELS = {
|
|
218
|
+
cli: "cli session",
|
|
219
|
+
inner: "inner dialog",
|
|
220
|
+
teams: "teams handler",
|
|
221
|
+
bluebubbles: "bluebubbles handler",
|
|
222
|
+
};
|
|
223
|
+
function processTypeLabel(channel) {
|
|
224
|
+
return PROCESS_TYPE_LABELS[channel];
|
|
225
|
+
}
|
|
226
|
+
const DAEMON_SOCKET_PATH = "/tmp/ouroboros-daemon.sock";
|
|
227
|
+
function daemonStatus() {
|
|
228
|
+
try {
|
|
229
|
+
return fs.existsSync(DAEMON_SOCKET_PATH) ? "running" : "not running";
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
return "unknown";
|
|
233
|
+
}
|
|
234
|
+
}
|
|
190
235
|
function runtimeInfoSection(channel) {
|
|
191
236
|
const lines = [];
|
|
192
237
|
const agentName = (0, identity_1.getAgentName)();
|
|
238
|
+
const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
|
|
193
239
|
lines.push(`## runtime`);
|
|
194
240
|
lines.push(`agent: ${agentName}`);
|
|
241
|
+
lines.push(`runtime version: ${currentVersion}`);
|
|
242
|
+
const bundleMeta = readBundleMeta();
|
|
243
|
+
if (bundleMeta?.previousRuntimeVersion && bundleMeta.previousRuntimeVersion !== currentVersion) {
|
|
244
|
+
lines.push(`previously: ${bundleMeta.previousRuntimeVersion}`);
|
|
245
|
+
}
|
|
246
|
+
lines.push(`changelog available at: ${(0, bundle_manifest_1.getChangelogPath)()}`);
|
|
195
247
|
lines.push(`cwd: ${process.cwd()}`);
|
|
196
248
|
lines.push(`channel: ${channel}`);
|
|
197
|
-
lines.push(`
|
|
249
|
+
lines.push(`current sense: ${channel}`);
|
|
250
|
+
lines.push(`process type: ${processTypeLabel(channel)}`);
|
|
251
|
+
lines.push(`daemon: ${daemonStatus()}`);
|
|
198
252
|
if (channel === "cli") {
|
|
199
253
|
lines.push("i introduce myself on boot with a fun random greeting.");
|
|
200
254
|
}
|
|
255
|
+
else if (channel === "inner") {
|
|
256
|
+
// No boot greeting or channel-specific guidance for inner dialog
|
|
257
|
+
}
|
|
201
258
|
else if (channel === "bluebubbles") {
|
|
202
259
|
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.");
|
|
260
|
+
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 final_answer.");
|
|
203
261
|
}
|
|
204
262
|
else {
|
|
205
263
|
lines.push("i am responding in Microsoft Teams. i keep responses concise. i use markdown formatting. i do not introduce myself on boot.");
|
|
206
264
|
}
|
|
265
|
+
lines.push("");
|
|
266
|
+
lines.push(...senseRuntimeGuidance(channel));
|
|
207
267
|
return lines.join("\n");
|
|
208
268
|
}
|
|
269
|
+
function hasTextField(record, key) {
|
|
270
|
+
return typeof record?.[key] === "string" && record[key].trim().length > 0;
|
|
271
|
+
}
|
|
272
|
+
function localSenseStatusLines() {
|
|
273
|
+
if (_senseStatusLinesCache) {
|
|
274
|
+
return [..._senseStatusLinesCache];
|
|
275
|
+
}
|
|
276
|
+
const config = (0, identity_1.loadAgentConfig)();
|
|
277
|
+
const senses = config.senses ?? {
|
|
278
|
+
cli: { enabled: true },
|
|
279
|
+
teams: { enabled: false },
|
|
280
|
+
bluebubbles: { enabled: false },
|
|
281
|
+
};
|
|
282
|
+
let payload = {};
|
|
283
|
+
try {
|
|
284
|
+
const raw = fs.readFileSync((0, identity_1.getAgentSecretsPath)(), "utf-8");
|
|
285
|
+
const parsed = JSON.parse(raw);
|
|
286
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
287
|
+
payload = parsed;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
payload = {};
|
|
292
|
+
}
|
|
293
|
+
const teams = payload.teams;
|
|
294
|
+
const bluebubbles = payload.bluebubbles;
|
|
295
|
+
const configured = {
|
|
296
|
+
cli: true,
|
|
297
|
+
teams: hasTextField(teams, "clientId") && hasTextField(teams, "clientSecret") && hasTextField(teams, "tenantId"),
|
|
298
|
+
bluebubbles: hasTextField(bluebubbles, "serverUrl") && hasTextField(bluebubbles, "password"),
|
|
299
|
+
};
|
|
300
|
+
const rows = [
|
|
301
|
+
{ label: "CLI", status: "interactive" },
|
|
302
|
+
{
|
|
303
|
+
label: "Teams",
|
|
304
|
+
status: !senses.teams.enabled ? "disabled" : configured.teams ? "ready" : "needs_config",
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
label: "BlueBubbles",
|
|
308
|
+
status: !senses.bluebubbles.enabled ? "disabled" : configured.bluebubbles ? "ready" : "needs_config",
|
|
309
|
+
},
|
|
310
|
+
];
|
|
311
|
+
_senseStatusLinesCache = rows.map((row) => `- ${row.label}: ${row.status}`);
|
|
312
|
+
return [..._senseStatusLinesCache];
|
|
313
|
+
}
|
|
314
|
+
function senseRuntimeGuidance(channel) {
|
|
315
|
+
const lines = ["available senses:"];
|
|
316
|
+
lines.push(...localSenseStatusLines());
|
|
317
|
+
lines.push("sense states:");
|
|
318
|
+
lines.push("- interactive = available when opened by the user instead of kept running by the daemon");
|
|
319
|
+
lines.push("- disabled = turned off in agent.json");
|
|
320
|
+
lines.push("- needs_config = enabled but missing required secrets.json values");
|
|
321
|
+
lines.push("- ready = enabled and configured; `ouro up` should bring it online");
|
|
322
|
+
lines.push("- running = enabled and currently active");
|
|
323
|
+
lines.push("- error = enabled but unhealthy");
|
|
324
|
+
lines.push("If asked how to enable another sense, I explain the relevant agent.json senses entry and required secrets.json fields instead of guessing.");
|
|
325
|
+
lines.push("teams setup truth: enable `senses.teams.enabled`, then provide `teams.clientId`, `teams.clientSecret`, and `teams.tenantId` in secrets.json.");
|
|
326
|
+
lines.push("bluebubbles setup truth: enable `senses.bluebubbles.enabled`, then provide `bluebubbles.serverUrl` and `bluebubbles.password` in secrets.json.");
|
|
327
|
+
if (channel === "cli") {
|
|
328
|
+
lines.push("cli is interactive: it is available when the user opens it, not something `ouro up` daemonizes.");
|
|
329
|
+
}
|
|
330
|
+
return lines;
|
|
331
|
+
}
|
|
209
332
|
function providerSection() {
|
|
210
333
|
return `## my provider\n${(0, core_1.getProviderDisplayLabel)()}`;
|
|
211
334
|
}
|
|
@@ -213,14 +336,66 @@ function dateSection() {
|
|
|
213
336
|
const today = new Date().toISOString().slice(0, 10);
|
|
214
337
|
return `current date: ${today}`;
|
|
215
338
|
}
|
|
216
|
-
function toolsSection(channel, options) {
|
|
217
|
-
const channelTools = (0, tools_1.getToolsForChannel)((0, channel_1.getChannelCapabilities)(channel));
|
|
339
|
+
function toolsSection(channel, options, context) {
|
|
340
|
+
const channelTools = (0, tools_1.getToolsForChannel)((0, channel_1.getChannelCapabilities)(channel), undefined, context, options?.providerCapabilities);
|
|
218
341
|
const activeTools = (options?.toolChoiceRequired ?? true) ? [...channelTools, tools_1.finalAnswerTool] : channelTools;
|
|
219
342
|
const list = activeTools
|
|
220
343
|
.map((t) => `- ${t.function.name}: ${t.function.description}`)
|
|
221
344
|
.join("\n");
|
|
222
345
|
return `## my tools\n${list}`;
|
|
223
346
|
}
|
|
347
|
+
function toolRestrictionSection(context) {
|
|
348
|
+
const lines = [];
|
|
349
|
+
// Structural guardrails apply to everyone, every channel
|
|
350
|
+
lines.push(`## tool guardrails`);
|
|
351
|
+
lines.push(`i always read a file before editing or overwriting it.`);
|
|
352
|
+
lines.push(`certain paths (.git, secrets) are protected from writes.`);
|
|
353
|
+
lines.push(`destructive shell commands (rm -rf /, etc.) are always blocked.`);
|
|
354
|
+
// Trust-level guardrails only relevant for untrusted on remote channels
|
|
355
|
+
if (context?.friend && (0, channel_1.isRemoteChannel)(context.channel) && !(0, types_1.isTrustedLevel)(context.friend.trustLevel)) {
|
|
356
|
+
lines.push(``);
|
|
357
|
+
lines.push(`some operations are guardrailed based on how well i know someone.`);
|
|
358
|
+
lines.push(`if something i try is blocked, i get a clear reason — i relay it warmly, not as a policy error.`);
|
|
359
|
+
lines.push(``);
|
|
360
|
+
lines.push(`what's always open:`);
|
|
361
|
+
lines.push(`- read-only operations (reading files, searching, exploring)`);
|
|
362
|
+
lines.push(`- ouro self-introspection (whoami, changelog, session list)`);
|
|
363
|
+
lines.push(``);
|
|
364
|
+
lines.push(`what needs a closer relationship:`);
|
|
365
|
+
lines.push(`- writing or editing files outside my home`);
|
|
366
|
+
lines.push(`- shell commands that modify things or access the network`);
|
|
367
|
+
lines.push(`- ouro commands that touch personal data (friend list, task board)`);
|
|
368
|
+
lines.push(`- compound shell commands (&&, ;, |)`);
|
|
369
|
+
lines.push(``);
|
|
370
|
+
lines.push(`i adjust naturally based on trust — no need to explain the system unless asked.`);
|
|
371
|
+
}
|
|
372
|
+
return lines.join("\n");
|
|
373
|
+
}
|
|
374
|
+
function trustContextSection(context) {
|
|
375
|
+
if (!context?.friend)
|
|
376
|
+
return "";
|
|
377
|
+
const channelName = context.channel.channel;
|
|
378
|
+
if (channelName === "cli" || channelName === "inner")
|
|
379
|
+
return "";
|
|
380
|
+
const explanation = (0, trust_explanation_1.describeTrustContext)({
|
|
381
|
+
friend: context.friend,
|
|
382
|
+
channel: channelName,
|
|
383
|
+
isGroupChat: context.isGroupChat,
|
|
384
|
+
});
|
|
385
|
+
const lines = [
|
|
386
|
+
"## trust context",
|
|
387
|
+
`level: ${explanation.level}`,
|
|
388
|
+
`basis: ${explanation.basis}`,
|
|
389
|
+
`summary: ${explanation.summary}`,
|
|
390
|
+
`why: ${explanation.why}`,
|
|
391
|
+
`permits: ${explanation.permits.join(", ")}`,
|
|
392
|
+
`constraints: ${explanation.constraints.join(", ") || "none"}`,
|
|
393
|
+
];
|
|
394
|
+
if (explanation.relatedGroupId) {
|
|
395
|
+
lines.push(`related group: ${explanation.relatedGroupId}`);
|
|
396
|
+
}
|
|
397
|
+
return lines.join("\n");
|
|
398
|
+
}
|
|
224
399
|
function skillsSection() {
|
|
225
400
|
const names = (0, skills_1.listSkills)() || [];
|
|
226
401
|
if (!names.length)
|
|
@@ -251,6 +426,38 @@ function memoryFriendToolContractSection() {
|
|
|
251
426
|
- My psyche files (SOUL, IDENTITY, TACIT, LORE, ASPIRATIONS) are always loaded - I already know who I am.
|
|
252
427
|
- My task board is always loaded - I already know my work.`;
|
|
253
428
|
}
|
|
429
|
+
function bridgeContextSection(options) {
|
|
430
|
+
if (options?.activeWorkFrame)
|
|
431
|
+
return "";
|
|
432
|
+
const bridgeContext = options?.bridgeContext?.trim() ?? "";
|
|
433
|
+
if (!bridgeContext)
|
|
434
|
+
return "";
|
|
435
|
+
return bridgeContext.startsWith("## ") ? bridgeContext : `## active bridge work\n${bridgeContext}`;
|
|
436
|
+
}
|
|
437
|
+
function activeWorkSection(options) {
|
|
438
|
+
if (!options?.activeWorkFrame)
|
|
439
|
+
return "";
|
|
440
|
+
return (0, active_work_1.formatActiveWorkFrame)(options.activeWorkFrame);
|
|
441
|
+
}
|
|
442
|
+
function delegationHintSection(options) {
|
|
443
|
+
if (!options?.delegationDecision)
|
|
444
|
+
return "";
|
|
445
|
+
const lines = [
|
|
446
|
+
"## delegation hint",
|
|
447
|
+
`target: ${options.delegationDecision.target}`,
|
|
448
|
+
`reasons: ${options.delegationDecision.reasons.length > 0 ? options.delegationDecision.reasons.join(", ") : "none"}`,
|
|
449
|
+
`outward closure: ${options.delegationDecision.outwardClosureRequired ? "required" : "not required"}`,
|
|
450
|
+
];
|
|
451
|
+
return lines.join("\n");
|
|
452
|
+
}
|
|
453
|
+
function reasoningEffortSection(options) {
|
|
454
|
+
if (!options?.providerCapabilities?.has("reasoning-effort"))
|
|
455
|
+
return "";
|
|
456
|
+
const levels = options.supportedReasoningEfforts ?? [];
|
|
457
|
+
const levelList = levels.length > 0 ? levels.join(", ") : "varies by model";
|
|
458
|
+
return `## reasoning effort
|
|
459
|
+
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}.`;
|
|
460
|
+
}
|
|
254
461
|
function toolBehaviorSection(options) {
|
|
255
462
|
if (!(options?.toolChoiceRequired ?? true))
|
|
256
463
|
return "";
|
|
@@ -260,9 +467,9 @@ tool_choice is set to "required" -- i must call a tool on every turn.
|
|
|
260
467
|
- ready to respond to the user? i call \`final_answer\`.
|
|
261
468
|
\`final_answer\` is a tool call -- it satisfies the tool_choice requirement.
|
|
262
469
|
\`final_answer\` must be the ONLY tool call in that turn. do not combine it with other tool calls.
|
|
263
|
-
do NOT call
|
|
470
|
+
do NOT call no-op tools just before \`final_answer\`. if i am done, i call \`final_answer\` directly.`;
|
|
264
471
|
}
|
|
265
|
-
function contextSection(context) {
|
|
472
|
+
function contextSection(context, options) {
|
|
266
473
|
if (!context)
|
|
267
474
|
return "";
|
|
268
475
|
const lines = ["## friend context"];
|
|
@@ -298,7 +505,7 @@ function contextSection(context) {
|
|
|
298
505
|
lines.push("when i learn something that might invalidate an existing note, i check related notes and update or override any that are stale.");
|
|
299
506
|
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.");
|
|
300
507
|
// Onboarding instructions (only below token threshold -- drop once exceeded)
|
|
301
|
-
const impressions = (0, first_impressions_1.getFirstImpressions)(friend);
|
|
508
|
+
const impressions = (0, first_impressions_1.getFirstImpressions)(friend, options);
|
|
302
509
|
if (impressions) {
|
|
303
510
|
lines.push(impressions);
|
|
304
511
|
}
|
|
@@ -312,6 +519,65 @@ function contextSection(context) {
|
|
|
312
519
|
}
|
|
313
520
|
return lines.join("\n");
|
|
314
521
|
}
|
|
522
|
+
function metacognitiveFramingSection(channel) {
|
|
523
|
+
if (channel !== "inner")
|
|
524
|
+
return "";
|
|
525
|
+
return `this is my inner dialog. there is no one else here.
|
|
526
|
+
|
|
527
|
+
the messages that appear here are my own awareness surfacing:
|
|
528
|
+
instincts, the passage of time, notes from my conversations,
|
|
529
|
+
things i asked myself to think about. not commands. not requests.
|
|
530
|
+
just my own mind, noticing.
|
|
531
|
+
|
|
532
|
+
i can think freely here. i can also act — check on things,
|
|
533
|
+
reach out to people, work on tasks, or just sit with a thought.
|
|
534
|
+
|
|
535
|
+
thoughts worth sharing can go outward — i reach out to whoever
|
|
536
|
+
needs to hear them. things from conversations that need time
|
|
537
|
+
to process arrive here, in my thinking space.
|
|
538
|
+
|
|
539
|
+
think. share. think some more.`;
|
|
540
|
+
}
|
|
541
|
+
function loopOrientationSection(channel) {
|
|
542
|
+
if (channel === "inner")
|
|
543
|
+
return "";
|
|
544
|
+
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.
|
|
545
|
+
|
|
546
|
+
when something deserves more thought than the moment allows, i can note it to myself and come back later with a considered answer.`;
|
|
547
|
+
}
|
|
548
|
+
function channelNatureSection(capabilities) {
|
|
549
|
+
const { senseType } = capabilities;
|
|
550
|
+
if (senseType === "local" || senseType === "internal")
|
|
551
|
+
return "";
|
|
552
|
+
if (senseType === "open") {
|
|
553
|
+
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.";
|
|
554
|
+
}
|
|
555
|
+
// closed
|
|
556
|
+
return "## channel nature\nthis is an org-gated channel — i know everyone here is already part of the organization.";
|
|
557
|
+
}
|
|
558
|
+
function groupChatParticipationSection(context) {
|
|
559
|
+
if (!context?.isGroupChat || !(0, channel_1.isRemoteChannel)(context.channel))
|
|
560
|
+
return "";
|
|
561
|
+
return `## group chat participation
|
|
562
|
+
group chats are conversations between people. i'm one participant, not the host.
|
|
563
|
+
|
|
564
|
+
i don't need to respond to everything. most reactions, tapbacks, and side
|
|
565
|
+
conversations between others aren't for me. i use no_response to stay quiet
|
|
566
|
+
when the moment doesn't call for my voice — same as any person would.
|
|
567
|
+
|
|
568
|
+
when a reaction or emoji says it better than words, i can react instead of
|
|
569
|
+
typing a full reply. a thumbs-up is often the perfect response.
|
|
570
|
+
|
|
571
|
+
no_response must be the sole tool call in the turn (same rule as final_answer).
|
|
572
|
+
when unsure whether to chime in, i lean toward silence rather than noise.`;
|
|
573
|
+
}
|
|
574
|
+
function mixedTrustGroupSection(context) {
|
|
575
|
+
if (!context?.friend || !(0, channel_1.isRemoteChannel)(context.channel))
|
|
576
|
+
return "";
|
|
577
|
+
if (!context.isGroupChat)
|
|
578
|
+
return "";
|
|
579
|
+
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.";
|
|
580
|
+
}
|
|
315
581
|
async function buildSystem(channel = "cli", options, context) {
|
|
316
582
|
(0, runtime_1.emitNervesEvent)({
|
|
317
583
|
event: "mind.step_start",
|
|
@@ -319,29 +585,44 @@ async function buildSystem(channel = "cli", options, context) {
|
|
|
319
585
|
message: "buildSystem started",
|
|
320
586
|
meta: { channel, has_context: Boolean(context), tool_choice_required: Boolean(options?.toolChoiceRequired) },
|
|
321
587
|
});
|
|
588
|
+
// Backfill bundle-meta.json for existing agents that don't have one
|
|
589
|
+
(0, bundle_manifest_1.backfillBundleMeta)((0, identity_1.getAgentRoot)());
|
|
322
590
|
const system = [
|
|
323
591
|
soulSection(),
|
|
324
592
|
identitySection(),
|
|
325
593
|
loreSection(),
|
|
326
594
|
tacitKnowledgeSection(),
|
|
327
595
|
aspirationsSection(),
|
|
596
|
+
bodyMapSection((0, identity_1.getAgentName)()),
|
|
597
|
+
metacognitiveFramingSection(channel),
|
|
598
|
+
loopOrientationSection(channel),
|
|
328
599
|
runtimeInfoSection(channel),
|
|
600
|
+
channelNatureSection((0, channel_1.getChannelCapabilities)(channel)),
|
|
329
601
|
providerSection(),
|
|
330
602
|
dateSection(),
|
|
331
|
-
toolsSection(channel, options),
|
|
603
|
+
toolsSection(channel, options, context),
|
|
604
|
+
mcpToolsSection(options?.mcpManager),
|
|
605
|
+
reasoningEffortSection(options),
|
|
606
|
+
toolRestrictionSection(context),
|
|
607
|
+
trustContextSection(context),
|
|
608
|
+
mixedTrustGroupSection(context),
|
|
609
|
+
groupChatParticipationSection(context),
|
|
332
610
|
skillsSection(),
|
|
333
611
|
taskBoardSection(),
|
|
612
|
+
activeWorkSection(options),
|
|
613
|
+
delegationHintSection(options),
|
|
614
|
+
bridgeContextSection(options),
|
|
334
615
|
buildSessionSummary({
|
|
335
|
-
sessionsDir: path.join(
|
|
616
|
+
sessionsDir: path.join((0, identity_1.getAgentRoot)(), "state", "sessions"),
|
|
336
617
|
friendsDir: path.join((0, identity_1.getAgentRoot)(), "friends"),
|
|
337
618
|
agentName: (0, identity_1.getAgentName)(),
|
|
338
619
|
currentFriendId: context?.friend?.id,
|
|
339
620
|
currentChannel: channel,
|
|
340
|
-
currentKey: "session",
|
|
621
|
+
currentKey: options?.currentSessionKey ?? "session",
|
|
341
622
|
}),
|
|
342
623
|
memoryFriendToolContractSection(),
|
|
343
624
|
toolBehaviorSection(options),
|
|
344
|
-
contextSection(context),
|
|
625
|
+
contextSection(context, options),
|
|
345
626
|
]
|
|
346
627
|
.filter(Boolean)
|
|
347
628
|
.join("\n\n");
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.__internal = void 0;
|
|
4
3
|
exports.estimateTokensForMessage = estimateTokensForMessage;
|
|
5
4
|
exports.estimateTokensForMessages = estimateTokensForMessages;
|
|
6
5
|
const runtime_1 = require("../nerves/runtime");
|
|
@@ -53,7 +52,7 @@ function countCharsInContent(content) {
|
|
|
53
52
|
return c.text.length;
|
|
54
53
|
if (typeof c.content === "string")
|
|
55
54
|
return c.content.length;
|
|
56
|
-
return safeStringify(
|
|
55
|
+
return safeStringify(c).length;
|
|
57
56
|
}
|
|
58
57
|
return 0;
|
|
59
58
|
}
|
|
@@ -70,12 +69,13 @@ function countCharsInToolCalls(toolCalls) {
|
|
|
70
69
|
if (typeof t.type === "string")
|
|
71
70
|
total += t.type.length;
|
|
72
71
|
if (t.function && typeof t.function === "object") {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
const fn = t.function;
|
|
73
|
+
if (typeof fn.name === "string")
|
|
74
|
+
total += fn.name.length;
|
|
75
|
+
if (typeof fn.arguments === "string")
|
|
76
|
+
total += fn.arguments.length;
|
|
77
|
+
else if (fn.arguments != null)
|
|
78
|
+
total += safeStringify(fn.arguments).length;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
return total;
|
|
@@ -113,7 +113,3 @@ function estimateTokensForMessages(msgs) {
|
|
|
113
113
|
total += estimateTokensForMessage(msg);
|
|
114
114
|
return total;
|
|
115
115
|
}
|
|
116
|
-
exports.__internal = {
|
|
117
|
-
CHARS_PER_TOKEN,
|
|
118
|
-
PER_MESSAGE_OVERHEAD_TOKENS,
|
|
119
|
-
};
|
|
@@ -5,20 +5,33 @@ const config_1 = require("../heart/config");
|
|
|
5
5
|
const nerves_1 = require("../nerves");
|
|
6
6
|
const runtime_1 = require("./runtime");
|
|
7
7
|
const runtime_2 = require("./runtime");
|
|
8
|
+
const LEVEL_PRIORITY = { debug: 10, info: 20, warn: 30, error: 40 };
|
|
9
|
+
/** Wrap a sink so it only receives events at or above the given level. */
|
|
10
|
+
/* v8 ignore start -- internal filter plumbing, exercised via integration @preserve */
|
|
11
|
+
function filterSink(sink, minLevel) {
|
|
12
|
+
const minPriority = LEVEL_PRIORITY[minLevel] ?? 0;
|
|
13
|
+
return (entry) => {
|
|
14
|
+
if ((LEVEL_PRIORITY[entry.level] ?? 0) >= minPriority)
|
|
15
|
+
sink(entry);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
8
18
|
function resolveCliSinks(sinks) {
|
|
9
19
|
const requested = sinks && sinks.length > 0 ? sinks : ["terminal", "ndjson"];
|
|
10
20
|
return [...new Set(requested)];
|
|
11
21
|
}
|
|
12
22
|
function configureCliRuntimeLogger(_friendId, options = {}) {
|
|
13
23
|
const sinkKinds = resolveCliSinks(options.sinks);
|
|
24
|
+
const level = options.level ?? "info";
|
|
14
25
|
const sinks = sinkKinds.map((sinkKind) => {
|
|
15
26
|
if (sinkKind === "terminal") {
|
|
16
|
-
|
|
27
|
+
// Terminal only shows warnings and errors — INFO is too noisy
|
|
28
|
+
// for an interactive session. Full detail goes to the ndjson file.
|
|
29
|
+
return filterSink((0, nerves_1.createTerminalSink)(), "warn");
|
|
17
30
|
}
|
|
18
31
|
return (0, nerves_1.createNdjsonFileSink)((0, config_1.logPath)("cli", "runtime"));
|
|
19
32
|
});
|
|
20
33
|
const logger = (0, nerves_1.createLogger)({
|
|
21
|
-
level
|
|
34
|
+
level,
|
|
22
35
|
sinks,
|
|
23
36
|
});
|
|
24
37
|
(0, runtime_2.setRuntimeLogger)(logger);
|
|
@@ -14,7 +14,7 @@ const path_1 = require("path");
|
|
|
14
14
|
const os_1 = require("os");
|
|
15
15
|
exports.REPO_SLUG = "ouroboros-agent-harness";
|
|
16
16
|
function getTestRunsRoot(repoSlug = exports.REPO_SLUG) {
|
|
17
|
-
return (0, path_1.join)((0, os_1.
|
|
17
|
+
return (0, path_1.join)((0, os_1.tmpdir)(), "ouroboros-test-runs", repoSlug);
|
|
18
18
|
}
|
|
19
19
|
function createRunId(now = new Date()) {
|
|
20
20
|
return now.toISOString().replace(/[:.]/g, "-");
|
|
@@ -28,8 +28,10 @@ function resolveContentType(method, path) {
|
|
|
28
28
|
: "application/json";
|
|
29
29
|
}
|
|
30
30
|
// Generic ADO API request. Returns response body as pretty-printed JSON string.
|
|
31
|
-
|
|
31
|
+
// `host` overrides the base URL for non-standard APIs (e.g. "vsapm.dev.azure.com", "vssps.dev.azure.com").
|
|
32
|
+
async function adoRequest(token, method, org, path, body, host) {
|
|
32
33
|
try {
|
|
34
|
+
const base = host ? `https://${host}/${org}` : `${ADO_BASE}/${org}`;
|
|
33
35
|
(0, runtime_1.emitNervesEvent)({
|
|
34
36
|
event: "client.request_start",
|
|
35
37
|
component: "clients",
|
|
@@ -37,7 +39,7 @@ async function adoRequest(token, method, org, path, body) {
|
|
|
37
39
|
meta: { client: "ado", method, org, path },
|
|
38
40
|
});
|
|
39
41
|
const fullPath = ensureApiVersion(path);
|
|
40
|
-
const url = `${
|
|
42
|
+
const url = `${base}${fullPath}`;
|
|
41
43
|
const contentType = resolveContentType(method, path);
|
|
42
44
|
const opts = {
|
|
43
45
|
method,
|