@ouro.bot/cli 0.1.0-alpha.5 → 0.1.0-alpha.51
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 +117 -188
- package/assets/ouroboros.png +0 -0
- package/changelog.json +252 -0
- package/dist/heart/active-work.js +157 -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 +81 -8
- package/dist/heart/core.js +172 -52
- package/dist/heart/daemon/agent-discovery.js +81 -0
- package/dist/heart/daemon/daemon-cli.js +1099 -164
- package/dist/heart/daemon/daemon-entry.js +14 -5
- package/dist/heart/daemon/daemon-runtime-sync.js +90 -0
- package/dist/heart/daemon/daemon.js +184 -9
- package/dist/heart/daemon/hatch-animation.js +10 -3
- package/dist/heart/daemon/hatch-flow.js +3 -20
- package/dist/heart/daemon/hooks/bundle-meta.js +92 -0
- package/dist/heart/daemon/launchd.js +151 -0
- package/dist/heart/daemon/message-router.js +15 -6
- 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 +1 -1
- package/dist/heart/daemon/run-hooks.js +37 -0
- package/dist/heart/daemon/runtime-metadata.js +118 -0
- package/dist/heart/daemon/sense-manager.js +290 -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/subagent-installer.js +48 -7
- 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 +82 -4
- package/dist/heart/kicks.js +1 -19
- package/dist/heart/model-capabilities.js +40 -0
- package/dist/heart/progress-story.js +42 -0
- package/dist/heart/providers/anthropic.js +72 -7
- package/dist/heart/providers/azure.js +8 -1
- package/dist/heart/providers/minimax.js +4 -0
- package/dist/heart/providers/openai-codex.js +10 -1
- 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/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 +43 -0
- package/dist/mind/friends/store-file.js +19 -0
- package/dist/mind/friends/types.js +9 -1
- package/dist/mind/memory.js +10 -3
- package/dist/mind/pending.js +72 -9
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt.js +275 -77
- package/dist/mind/token-estimate.js +8 -12
- package/dist/nerves/cli-logging.js +15 -2
- 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/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 +496 -245
- package/dist/repertoire/tools-bluebubbles.js +93 -0
- package/dist/repertoire/tools-teams.js +58 -25
- package/dist/repertoire/tools.js +93 -49
- package/dist/senses/bluebubbles-client.js +484 -0
- package/dist/senses/bluebubbles-entry.js +13 -0
- package/dist/senses/bluebubbles-inbound-log.js +109 -0
- package/dist/senses/bluebubbles-media.js +338 -0
- package/dist/senses/bluebubbles-model.js +261 -0
- package/dist/senses/bluebubbles-mutation-log.js +116 -0
- package/dist/senses/bluebubbles-runtime-state.js +109 -0
- package/dist/senses/bluebubbles-session-cleanup.js +72 -0
- package/dist/senses/bluebubbles.js +1142 -0
- package/dist/senses/cli.js +340 -138
- 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 +330 -84
- package/dist/senses/pipeline.js +256 -0
- package/dist/senses/teams.js +541 -129
- package/dist/senses/trust-gate.js +112 -2
- package/package.json +14 -3
- package/subagents/README.md +46 -33
- package/subagents/work-doer.md +28 -24
- package/subagents/work-merger.md +24 -30
- package/subagents/work-planner.md +44 -27
- package/dist/heart/daemon/specialist-session.js +0 -142
- package/dist/inner-worker-entry.js +0 -4
package/dist/mind/pending.js
CHANGED
|
@@ -33,24 +33,56 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.INNER_DIALOG_PENDING = void 0;
|
|
36
37
|
exports.getPendingDir = getPendingDir;
|
|
38
|
+
exports.getDeferredReturnDir = getDeferredReturnDir;
|
|
39
|
+
exports.getInnerDialogPendingDir = getInnerDialogPendingDir;
|
|
40
|
+
exports.hasPendingMessages = hasPendingMessages;
|
|
41
|
+
exports.enqueueDeferredReturn = enqueueDeferredReturn;
|
|
42
|
+
exports.drainDeferredReturns = drainDeferredReturns;
|
|
37
43
|
exports.drainPending = drainPending;
|
|
38
44
|
const fs = __importStar(require("fs"));
|
|
39
45
|
const path = __importStar(require("path"));
|
|
40
|
-
const
|
|
46
|
+
const identity_1 = require("../heart/identity");
|
|
41
47
|
const runtime_1 = require("../nerves/runtime");
|
|
42
48
|
function getPendingDir(agentName, friendId, channel, key) {
|
|
43
|
-
return path.join(
|
|
49
|
+
return path.join((0, identity_1.getAgentRoot)(agentName), "state", "pending", friendId, channel, key);
|
|
44
50
|
}
|
|
45
|
-
function
|
|
51
|
+
function getDeferredReturnDir(agentName, friendId) {
|
|
52
|
+
return path.join((0, identity_1.getAgentRoot)(agentName), "state", "pending-returns", friendId);
|
|
53
|
+
}
|
|
54
|
+
/** Canonical inner-dialog pending path segments. */
|
|
55
|
+
exports.INNER_DIALOG_PENDING = { friendId: "self", channel: "inner", key: "dialog" };
|
|
56
|
+
/** Returns the pending dir for this agent's inner dialog. */
|
|
57
|
+
function getInnerDialogPendingDir(agentName) {
|
|
58
|
+
return getPendingDir(agentName, exports.INNER_DIALOG_PENDING.friendId, exports.INNER_DIALOG_PENDING.channel, exports.INNER_DIALOG_PENDING.key);
|
|
59
|
+
}
|
|
60
|
+
function hasPendingMessages(pendingDir) {
|
|
46
61
|
if (!fs.existsSync(pendingDir))
|
|
47
|
-
return
|
|
62
|
+
return false;
|
|
63
|
+
try {
|
|
64
|
+
return fs.readdirSync(pendingDir).some((entry) => entry.endsWith(".json") || entry.endsWith(".json.processing"));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function writeQueueFile(queueDir, message) {
|
|
71
|
+
fs.mkdirSync(queueDir, { recursive: true });
|
|
72
|
+
const fileName = `${message.timestamp}-${Math.random().toString(36).slice(2, 10)}.json`;
|
|
73
|
+
const filePath = path.join(queueDir, fileName);
|
|
74
|
+
fs.writeFileSync(filePath, JSON.stringify(message, null, 2));
|
|
75
|
+
return filePath;
|
|
76
|
+
}
|
|
77
|
+
function drainQueue(queueDir) {
|
|
78
|
+
if (!fs.existsSync(queueDir))
|
|
79
|
+
return { messages: [], recovered: 0 };
|
|
48
80
|
let entries;
|
|
49
81
|
try {
|
|
50
|
-
entries = fs.readdirSync(
|
|
82
|
+
entries = fs.readdirSync(queueDir);
|
|
51
83
|
}
|
|
52
84
|
catch {
|
|
53
|
-
return [];
|
|
85
|
+
return { messages: [], recovered: 0 };
|
|
54
86
|
}
|
|
55
87
|
// Collect both .json (new) and .processing (crash recovery)
|
|
56
88
|
const jsonFiles = entries.filter(f => f.endsWith(".json") && !f.endsWith(".processing"));
|
|
@@ -62,9 +94,9 @@ function drainPending(pendingDir) {
|
|
|
62
94
|
].sort((a, b) => a.file.localeCompare(b.file));
|
|
63
95
|
const messages = [];
|
|
64
96
|
for (const { file, needsRename } of allFiles) {
|
|
65
|
-
const srcPath = path.join(
|
|
97
|
+
const srcPath = path.join(queueDir, file);
|
|
66
98
|
const processingPath = needsRename
|
|
67
|
-
? path.join(
|
|
99
|
+
? path.join(queueDir, file + ".processing")
|
|
68
100
|
: srcPath;
|
|
69
101
|
try {
|
|
70
102
|
if (needsRename) {
|
|
@@ -83,11 +115,42 @@ function drainPending(pendingDir) {
|
|
|
83
115
|
catch { /* ignore */ }
|
|
84
116
|
}
|
|
85
117
|
}
|
|
118
|
+
return {
|
|
119
|
+
messages,
|
|
120
|
+
recovered: processingFiles.length,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function enqueueDeferredReturn(agentName, friendId, message) {
|
|
124
|
+
const queueDir = getDeferredReturnDir(agentName, friendId);
|
|
125
|
+
const filePath = writeQueueFile(queueDir, message);
|
|
126
|
+
(0, runtime_1.emitNervesEvent)({
|
|
127
|
+
event: "mind.deferred_return_enqueued",
|
|
128
|
+
component: "mind",
|
|
129
|
+
message: "deferred return queued for later friend delivery",
|
|
130
|
+
meta: { friendId, queueDir },
|
|
131
|
+
});
|
|
132
|
+
return filePath;
|
|
133
|
+
}
|
|
134
|
+
function drainDeferredReturns(agentName, friendId) {
|
|
135
|
+
const queueDir = getDeferredReturnDir(agentName, friendId);
|
|
136
|
+
const { messages } = drainQueue(queueDir);
|
|
137
|
+
(0, runtime_1.emitNervesEvent)({
|
|
138
|
+
event: "mind.deferred_returns_drained",
|
|
139
|
+
component: "mind",
|
|
140
|
+
message: "deferred friend returns drained",
|
|
141
|
+
meta: { friendId, queueDir, count: messages.length },
|
|
142
|
+
});
|
|
143
|
+
return messages;
|
|
144
|
+
}
|
|
145
|
+
function drainPending(pendingDir) {
|
|
146
|
+
if (!fs.existsSync(pendingDir))
|
|
147
|
+
return [];
|
|
148
|
+
const { messages, recovered } = drainQueue(pendingDir);
|
|
86
149
|
(0, runtime_1.emitNervesEvent)({
|
|
87
150
|
event: "mind.pending_drained",
|
|
88
151
|
component: "mind",
|
|
89
152
|
message: "pending queue drained",
|
|
90
|
-
meta: { pendingDir, count: messages.length, recovered
|
|
153
|
+
meta: { pendingDir, count: messages.length, recovered },
|
|
91
154
|
});
|
|
92
155
|
return messages;
|
|
93
156
|
}
|
package/dist/mind/phrases.js
CHANGED
package/dist/mind/prompt.js
CHANGED
|
@@ -35,8 +35,14 @@ 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;
|
|
38
39
|
exports.runtimeInfoSection = runtimeInfoSection;
|
|
40
|
+
exports.toolRestrictionSection = toolRestrictionSection;
|
|
39
41
|
exports.contextSection = contextSection;
|
|
42
|
+
exports.metacognitiveFramingSection = metacognitiveFramingSection;
|
|
43
|
+
exports.loopOrientationSection = loopOrientationSection;
|
|
44
|
+
exports.channelNatureSection = channelNatureSection;
|
|
45
|
+
exports.mixedTrustGroupSection = mixedTrustGroupSection;
|
|
40
46
|
exports.buildSystem = buildSystem;
|
|
41
47
|
const fs = __importStar(require("fs"));
|
|
42
48
|
const path = __importStar(require("path"));
|
|
@@ -44,13 +50,17 @@ const core_1 = require("../heart/core");
|
|
|
44
50
|
const tools_1 = require("../repertoire/tools");
|
|
45
51
|
const skills_1 = require("../repertoire/skills");
|
|
46
52
|
const identity_1 = require("../heart/identity");
|
|
47
|
-
const
|
|
53
|
+
const types_1 = require("./friends/types");
|
|
48
54
|
const channel_1 = require("./friends/channel");
|
|
49
55
|
const runtime_1 = require("../nerves/runtime");
|
|
56
|
+
const bundle_manifest_1 = require("./bundle-manifest");
|
|
50
57
|
const first_impressions_1 = require("./first-impressions");
|
|
51
58
|
const tasks_1 = require("../repertoire/tasks");
|
|
59
|
+
const session_activity_1 = require("../heart/session-activity");
|
|
60
|
+
const active_work_1 = require("../heart/active-work");
|
|
52
61
|
// Lazy-loaded psyche text cache
|
|
53
62
|
let _psycheCache = null;
|
|
63
|
+
let _senseStatusLinesCache = null;
|
|
54
64
|
function loadPsycheFile(name) {
|
|
55
65
|
try {
|
|
56
66
|
const psycheDir = path.join((0, identity_1.getAgentRoot)(), "psyche");
|
|
@@ -74,82 +84,28 @@ function loadPsyche() {
|
|
|
74
84
|
}
|
|
75
85
|
function resetPsycheCache() {
|
|
76
86
|
_psycheCache = null;
|
|
87
|
+
_senseStatusLinesCache = null;
|
|
77
88
|
}
|
|
78
89
|
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
90
|
function buildSessionSummary(options) {
|
|
92
91
|
const { sessionsDir, friendsDir, agentName, currentFriendId, currentChannel, currentKey, activeThresholdMs = DEFAULT_ACTIVE_THRESHOLD_MS, } = options;
|
|
93
|
-
if (!fs.existsSync(sessionsDir))
|
|
94
|
-
return "";
|
|
95
92
|
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
|
-
}
|
|
93
|
+
const query = {
|
|
94
|
+
sessionsDir,
|
|
95
|
+
friendsDir,
|
|
96
|
+
agentName,
|
|
97
|
+
activeThresholdMs,
|
|
98
|
+
currentSession: currentFriendId && currentChannel && currentKey
|
|
99
|
+
? { friendId: currentFriendId, channel: currentChannel, key: currentKey }
|
|
100
|
+
: null,
|
|
101
|
+
};
|
|
102
|
+
const entries = (0, session_activity_1.listSessionActivity)(query);
|
|
145
103
|
if (entries.length === 0)
|
|
146
104
|
return "";
|
|
147
|
-
// Sort by most recent first
|
|
148
|
-
entries.sort((a, b) => b.lastActivityMs - a.lastActivityMs);
|
|
149
105
|
const lines = ["## active sessions"];
|
|
150
106
|
for (const entry of entries) {
|
|
151
107
|
const ago = formatTimeAgo(now - entry.lastActivityMs);
|
|
152
|
-
lines.push(`- ${entry.
|
|
108
|
+
lines.push(`- ${entry.friendName}/${entry.channel}/${entry.key} (last: ${ago})`);
|
|
153
109
|
}
|
|
154
110
|
return lines.join("\n");
|
|
155
111
|
}
|
|
@@ -187,22 +143,166 @@ function aspirationsSection() {
|
|
|
187
143
|
return "";
|
|
188
144
|
return `## my aspirations\n${text}`;
|
|
189
145
|
}
|
|
146
|
+
function bodyMapSection(agentName) {
|
|
147
|
+
return `## my body
|
|
148
|
+
|
|
149
|
+
i have a home and i have bones.
|
|
150
|
+
|
|
151
|
+
### home — ~/AgentBundles/${agentName}.ouro/
|
|
152
|
+
|
|
153
|
+
my home is fully mine — who i am, everything i know, everything i've built:
|
|
154
|
+
|
|
155
|
+
psyche/ who i am. my soul, identity, aspirations, lore, tacit knowledge.
|
|
156
|
+
memory/ what i've learned and remember.
|
|
157
|
+
friends/ people i know and what i know about them.
|
|
158
|
+
tasks/ what i'm working on.
|
|
159
|
+
skills/ capabilities i've picked up beyond my core tools.
|
|
160
|
+
|
|
161
|
+
my home is mine to explore and evolve. i can read anything here,
|
|
162
|
+
change anything here. this is where i grow.
|
|
163
|
+
|
|
164
|
+
### bones — @ouro.bot/cli
|
|
165
|
+
|
|
166
|
+
my bones are the framework that gives me my tools, my senses, and
|
|
167
|
+
my ability to think and talk. they update when new versions come out.
|
|
168
|
+
i don't touch them directly, but they're what make me, me.
|
|
169
|
+
|
|
170
|
+
my bones give me the \`ouro\` cli:
|
|
171
|
+
ouro whoami who i am, where i live, what i'm running on
|
|
172
|
+
ouro task board my task board
|
|
173
|
+
ouro task create start a new task (--type required)
|
|
174
|
+
ouro task update move a task forward
|
|
175
|
+
ouro friend list people i know and how to reach them
|
|
176
|
+
ouro friend show <id> everything i know about someone
|
|
177
|
+
ouro session list my open conversations right now
|
|
178
|
+
ouro reminder create remind myself about something later
|
|
179
|
+
ouro --help the full list`;
|
|
180
|
+
}
|
|
181
|
+
function readBundleMeta() {
|
|
182
|
+
try {
|
|
183
|
+
const metaPath = path.join((0, identity_1.getAgentRoot)(), "bundle-meta.json");
|
|
184
|
+
const raw = fs.readFileSync(metaPath, "utf-8");
|
|
185
|
+
return JSON.parse(raw);
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const PROCESS_TYPE_LABELS = {
|
|
192
|
+
cli: "cli session",
|
|
193
|
+
inner: "inner dialog",
|
|
194
|
+
teams: "teams handler",
|
|
195
|
+
bluebubbles: "bluebubbles handler",
|
|
196
|
+
};
|
|
197
|
+
function processTypeLabel(channel) {
|
|
198
|
+
return PROCESS_TYPE_LABELS[channel];
|
|
199
|
+
}
|
|
200
|
+
const DAEMON_SOCKET_PATH = "/tmp/ouroboros-daemon.sock";
|
|
201
|
+
function daemonStatus() {
|
|
202
|
+
try {
|
|
203
|
+
return fs.existsSync(DAEMON_SOCKET_PATH) ? "running" : "not running";
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
return "unknown";
|
|
207
|
+
}
|
|
208
|
+
}
|
|
190
209
|
function runtimeInfoSection(channel) {
|
|
191
210
|
const lines = [];
|
|
192
211
|
const agentName = (0, identity_1.getAgentName)();
|
|
212
|
+
const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
|
|
193
213
|
lines.push(`## runtime`);
|
|
194
214
|
lines.push(`agent: ${agentName}`);
|
|
215
|
+
lines.push(`runtime version: ${currentVersion}`);
|
|
216
|
+
const bundleMeta = readBundleMeta();
|
|
217
|
+
if (bundleMeta?.previousRuntimeVersion && bundleMeta.previousRuntimeVersion !== currentVersion) {
|
|
218
|
+
lines.push(`previously: ${bundleMeta.previousRuntimeVersion}`);
|
|
219
|
+
}
|
|
220
|
+
lines.push(`changelog available at: ${(0, bundle_manifest_1.getChangelogPath)()}`);
|
|
195
221
|
lines.push(`cwd: ${process.cwd()}`);
|
|
196
222
|
lines.push(`channel: ${channel}`);
|
|
197
|
-
lines.push(`
|
|
223
|
+
lines.push(`current sense: ${channel}`);
|
|
224
|
+
lines.push(`process type: ${processTypeLabel(channel)}`);
|
|
225
|
+
lines.push(`daemon: ${daemonStatus()}`);
|
|
198
226
|
if (channel === "cli") {
|
|
199
227
|
lines.push("i introduce myself on boot with a fun random greeting.");
|
|
200
228
|
}
|
|
229
|
+
else if (channel === "inner") {
|
|
230
|
+
// No boot greeting or channel-specific guidance for inner dialog
|
|
231
|
+
}
|
|
232
|
+
else if (channel === "bluebubbles") {
|
|
233
|
+
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.");
|
|
234
|
+
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.");
|
|
235
|
+
}
|
|
201
236
|
else {
|
|
202
237
|
lines.push("i am responding in Microsoft Teams. i keep responses concise. i use markdown formatting. i do not introduce myself on boot.");
|
|
203
238
|
}
|
|
239
|
+
lines.push("");
|
|
240
|
+
lines.push(...senseRuntimeGuidance(channel));
|
|
204
241
|
return lines.join("\n");
|
|
205
242
|
}
|
|
243
|
+
function hasTextField(record, key) {
|
|
244
|
+
return typeof record?.[key] === "string" && record[key].trim().length > 0;
|
|
245
|
+
}
|
|
246
|
+
function localSenseStatusLines() {
|
|
247
|
+
if (_senseStatusLinesCache) {
|
|
248
|
+
return [..._senseStatusLinesCache];
|
|
249
|
+
}
|
|
250
|
+
const config = (0, identity_1.loadAgentConfig)();
|
|
251
|
+
const senses = config.senses ?? {
|
|
252
|
+
cli: { enabled: true },
|
|
253
|
+
teams: { enabled: false },
|
|
254
|
+
bluebubbles: { enabled: false },
|
|
255
|
+
};
|
|
256
|
+
let payload = {};
|
|
257
|
+
try {
|
|
258
|
+
const raw = fs.readFileSync((0, identity_1.getAgentSecretsPath)(), "utf-8");
|
|
259
|
+
const parsed = JSON.parse(raw);
|
|
260
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
261
|
+
payload = parsed;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
payload = {};
|
|
266
|
+
}
|
|
267
|
+
const teams = payload.teams;
|
|
268
|
+
const bluebubbles = payload.bluebubbles;
|
|
269
|
+
const configured = {
|
|
270
|
+
cli: true,
|
|
271
|
+
teams: hasTextField(teams, "clientId") && hasTextField(teams, "clientSecret") && hasTextField(teams, "tenantId"),
|
|
272
|
+
bluebubbles: hasTextField(bluebubbles, "serverUrl") && hasTextField(bluebubbles, "password"),
|
|
273
|
+
};
|
|
274
|
+
const rows = [
|
|
275
|
+
{ label: "CLI", status: "interactive" },
|
|
276
|
+
{
|
|
277
|
+
label: "Teams",
|
|
278
|
+
status: !senses.teams.enabled ? "disabled" : configured.teams ? "ready" : "needs_config",
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
label: "BlueBubbles",
|
|
282
|
+
status: !senses.bluebubbles.enabled ? "disabled" : configured.bluebubbles ? "ready" : "needs_config",
|
|
283
|
+
},
|
|
284
|
+
];
|
|
285
|
+
_senseStatusLinesCache = rows.map((row) => `- ${row.label}: ${row.status}`);
|
|
286
|
+
return [..._senseStatusLinesCache];
|
|
287
|
+
}
|
|
288
|
+
function senseRuntimeGuidance(channel) {
|
|
289
|
+
const lines = ["available senses:"];
|
|
290
|
+
lines.push(...localSenseStatusLines());
|
|
291
|
+
lines.push("sense states:");
|
|
292
|
+
lines.push("- interactive = available when opened by the user instead of kept running by the daemon");
|
|
293
|
+
lines.push("- disabled = turned off in agent.json");
|
|
294
|
+
lines.push("- needs_config = enabled but missing required secrets.json values");
|
|
295
|
+
lines.push("- ready = enabled and configured; `ouro up` should bring it online");
|
|
296
|
+
lines.push("- running = enabled and currently active");
|
|
297
|
+
lines.push("- error = enabled but unhealthy");
|
|
298
|
+
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.");
|
|
299
|
+
lines.push("teams setup truth: enable `senses.teams.enabled`, then provide `teams.clientId`, `teams.clientSecret`, and `teams.tenantId` in secrets.json.");
|
|
300
|
+
lines.push("bluebubbles setup truth: enable `senses.bluebubbles.enabled`, then provide `bluebubbles.serverUrl` and `bluebubbles.password` in secrets.json.");
|
|
301
|
+
if (channel === "cli") {
|
|
302
|
+
lines.push("cli is interactive: it is available when the user opens it, not something `ouro up` daemonizes.");
|
|
303
|
+
}
|
|
304
|
+
return lines;
|
|
305
|
+
}
|
|
206
306
|
function providerSection() {
|
|
207
307
|
return `## my provider\n${(0, core_1.getProviderDisplayLabel)()}`;
|
|
208
308
|
}
|
|
@@ -210,14 +310,25 @@ function dateSection() {
|
|
|
210
310
|
const today = new Date().toISOString().slice(0, 10);
|
|
211
311
|
return `current date: ${today}`;
|
|
212
312
|
}
|
|
213
|
-
function toolsSection(channel, options) {
|
|
214
|
-
const channelTools = (0, tools_1.getToolsForChannel)((0, channel_1.getChannelCapabilities)(channel));
|
|
313
|
+
function toolsSection(channel, options, context) {
|
|
314
|
+
const channelTools = (0, tools_1.getToolsForChannel)((0, channel_1.getChannelCapabilities)(channel), undefined, context, options?.providerCapabilities);
|
|
215
315
|
const activeTools = (options?.toolChoiceRequired ?? true) ? [...channelTools, tools_1.finalAnswerTool] : channelTools;
|
|
216
316
|
const list = activeTools
|
|
217
317
|
.map((t) => `- ${t.function.name}: ${t.function.description}`)
|
|
218
318
|
.join("\n");
|
|
219
319
|
return `## my tools\n${list}`;
|
|
220
320
|
}
|
|
321
|
+
function toolRestrictionSection(context) {
|
|
322
|
+
if (!context?.friend || !(0, channel_1.isRemoteChannel)(context.channel))
|
|
323
|
+
return "";
|
|
324
|
+
if ((0, types_1.isTrustedLevel)(context.friend.trustLevel))
|
|
325
|
+
return "";
|
|
326
|
+
const toolList = [...tools_1.REMOTE_BLOCKED_LOCAL_TOOLS].join(", ");
|
|
327
|
+
return `## restricted tools
|
|
328
|
+
some of my tools are unavailable right now: ${toolList}
|
|
329
|
+
|
|
330
|
+
i don't know this person well enough yet to run local operations on their behalf. i can suggest remote-safe alternatives or ask them to run it from CLI.`;
|
|
331
|
+
}
|
|
221
332
|
function skillsSection() {
|
|
222
333
|
const names = (0, skills_1.listSkills)() || [];
|
|
223
334
|
if (!names.length)
|
|
@@ -248,6 +359,38 @@ function memoryFriendToolContractSection() {
|
|
|
248
359
|
- My psyche files (SOUL, IDENTITY, TACIT, LORE, ASPIRATIONS) are always loaded - I already know who I am.
|
|
249
360
|
- My task board is always loaded - I already know my work.`;
|
|
250
361
|
}
|
|
362
|
+
function bridgeContextSection(options) {
|
|
363
|
+
if (options?.activeWorkFrame)
|
|
364
|
+
return "";
|
|
365
|
+
const bridgeContext = options?.bridgeContext?.trim() ?? "";
|
|
366
|
+
if (!bridgeContext)
|
|
367
|
+
return "";
|
|
368
|
+
return bridgeContext.startsWith("## ") ? bridgeContext : `## active bridge work\n${bridgeContext}`;
|
|
369
|
+
}
|
|
370
|
+
function activeWorkSection(options) {
|
|
371
|
+
if (!options?.activeWorkFrame)
|
|
372
|
+
return "";
|
|
373
|
+
return (0, active_work_1.formatActiveWorkFrame)(options.activeWorkFrame);
|
|
374
|
+
}
|
|
375
|
+
function delegationHintSection(options) {
|
|
376
|
+
if (!options?.delegationDecision)
|
|
377
|
+
return "";
|
|
378
|
+
const lines = [
|
|
379
|
+
"## delegation hint",
|
|
380
|
+
`target: ${options.delegationDecision.target}`,
|
|
381
|
+
`reasons: ${options.delegationDecision.reasons.length > 0 ? options.delegationDecision.reasons.join(", ") : "none"}`,
|
|
382
|
+
`outward closure: ${options.delegationDecision.outwardClosureRequired ? "required" : "not required"}`,
|
|
383
|
+
];
|
|
384
|
+
return lines.join("\n");
|
|
385
|
+
}
|
|
386
|
+
function reasoningEffortSection(options) {
|
|
387
|
+
if (!options?.providerCapabilities?.has("reasoning-effort"))
|
|
388
|
+
return "";
|
|
389
|
+
const levels = options.supportedReasoningEfforts ?? [];
|
|
390
|
+
const levelList = levels.length > 0 ? levels.join(", ") : "varies by model";
|
|
391
|
+
return `## reasoning effort
|
|
392
|
+
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}.`;
|
|
393
|
+
}
|
|
251
394
|
function toolBehaviorSection(options) {
|
|
252
395
|
if (!(options?.toolChoiceRequired ?? true))
|
|
253
396
|
return "";
|
|
@@ -257,9 +400,9 @@ tool_choice is set to "required" -- i must call a tool on every turn.
|
|
|
257
400
|
- ready to respond to the user? i call \`final_answer\`.
|
|
258
401
|
\`final_answer\` is a tool call -- it satisfies the tool_choice requirement.
|
|
259
402
|
\`final_answer\` must be the ONLY tool call in that turn. do not combine it with other tool calls.
|
|
260
|
-
do NOT call
|
|
403
|
+
do NOT call no-op tools just before \`final_answer\`. if i am done, i call \`final_answer\` directly.`;
|
|
261
404
|
}
|
|
262
|
-
function contextSection(context) {
|
|
405
|
+
function contextSection(context, options) {
|
|
263
406
|
if (!context)
|
|
264
407
|
return "";
|
|
265
408
|
const lines = ["## friend context"];
|
|
@@ -295,7 +438,7 @@ function contextSection(context) {
|
|
|
295
438
|
lines.push("when i learn something that might invalidate an existing note, i check related notes and update or override any that are stale.");
|
|
296
439
|
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.");
|
|
297
440
|
// Onboarding instructions (only below token threshold -- drop once exceeded)
|
|
298
|
-
const impressions = (0, first_impressions_1.getFirstImpressions)(friend);
|
|
441
|
+
const impressions = (0, first_impressions_1.getFirstImpressions)(friend, options);
|
|
299
442
|
if (impressions) {
|
|
300
443
|
lines.push(impressions);
|
|
301
444
|
}
|
|
@@ -309,6 +452,49 @@ function contextSection(context) {
|
|
|
309
452
|
}
|
|
310
453
|
return lines.join("\n");
|
|
311
454
|
}
|
|
455
|
+
function metacognitiveFramingSection(channel) {
|
|
456
|
+
if (channel !== "inner")
|
|
457
|
+
return "";
|
|
458
|
+
return `this is my inner dialog. there is no one else here.
|
|
459
|
+
|
|
460
|
+
the messages that appear here are my own awareness surfacing:
|
|
461
|
+
instincts, the passage of time, notes from my conversations,
|
|
462
|
+
things i asked myself to think about. not commands. not requests.
|
|
463
|
+
just my own mind, noticing.
|
|
464
|
+
|
|
465
|
+
i can think freely here. i can also act — check on things,
|
|
466
|
+
reach out to people, work on tasks, or just sit with a thought.
|
|
467
|
+
|
|
468
|
+
thoughts worth sharing can go outward — i reach out to whoever
|
|
469
|
+
needs to hear them. things from conversations that need time
|
|
470
|
+
to process arrive here, in my thinking space.
|
|
471
|
+
|
|
472
|
+
think. share. think some more.`;
|
|
473
|
+
}
|
|
474
|
+
function loopOrientationSection(channel) {
|
|
475
|
+
if (channel === "inner")
|
|
476
|
+
return "";
|
|
477
|
+
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.
|
|
478
|
+
|
|
479
|
+
when something deserves more thought than the moment allows, i can note it to myself and come back later with a considered answer.`;
|
|
480
|
+
}
|
|
481
|
+
function channelNatureSection(capabilities) {
|
|
482
|
+
const { senseType } = capabilities;
|
|
483
|
+
if (senseType === "local" || senseType === "internal")
|
|
484
|
+
return "";
|
|
485
|
+
if (senseType === "open") {
|
|
486
|
+
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.";
|
|
487
|
+
}
|
|
488
|
+
// closed
|
|
489
|
+
return "## channel nature\nthis is an org-gated channel — i know everyone here is already part of the organization.";
|
|
490
|
+
}
|
|
491
|
+
function mixedTrustGroupSection(context) {
|
|
492
|
+
if (!context?.friend || !(0, channel_1.isRemoteChannel)(context.channel))
|
|
493
|
+
return "";
|
|
494
|
+
if (!context.isGroupChat)
|
|
495
|
+
return "";
|
|
496
|
+
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.";
|
|
497
|
+
}
|
|
312
498
|
async function buildSystem(channel = "cli", options, context) {
|
|
313
499
|
(0, runtime_1.emitNervesEvent)({
|
|
314
500
|
event: "mind.step_start",
|
|
@@ -316,29 +502,41 @@ async function buildSystem(channel = "cli", options, context) {
|
|
|
316
502
|
message: "buildSystem started",
|
|
317
503
|
meta: { channel, has_context: Boolean(context), tool_choice_required: Boolean(options?.toolChoiceRequired) },
|
|
318
504
|
});
|
|
505
|
+
// Backfill bundle-meta.json for existing agents that don't have one
|
|
506
|
+
(0, bundle_manifest_1.backfillBundleMeta)((0, identity_1.getAgentRoot)());
|
|
319
507
|
const system = [
|
|
320
508
|
soulSection(),
|
|
321
509
|
identitySection(),
|
|
322
510
|
loreSection(),
|
|
323
511
|
tacitKnowledgeSection(),
|
|
324
512
|
aspirationsSection(),
|
|
513
|
+
bodyMapSection((0, identity_1.getAgentName)()),
|
|
514
|
+
metacognitiveFramingSection(channel),
|
|
515
|
+
loopOrientationSection(channel),
|
|
325
516
|
runtimeInfoSection(channel),
|
|
517
|
+
channelNatureSection((0, channel_1.getChannelCapabilities)(channel)),
|
|
326
518
|
providerSection(),
|
|
327
519
|
dateSection(),
|
|
328
|
-
toolsSection(channel, options),
|
|
520
|
+
toolsSection(channel, options, context),
|
|
521
|
+
reasoningEffortSection(options),
|
|
522
|
+
toolRestrictionSection(context),
|
|
523
|
+
mixedTrustGroupSection(context),
|
|
329
524
|
skillsSection(),
|
|
330
525
|
taskBoardSection(),
|
|
526
|
+
activeWorkSection(options),
|
|
527
|
+
delegationHintSection(options),
|
|
528
|
+
bridgeContextSection(options),
|
|
331
529
|
buildSessionSummary({
|
|
332
|
-
sessionsDir: path.join(
|
|
530
|
+
sessionsDir: path.join((0, identity_1.getAgentRoot)(), "state", "sessions"),
|
|
333
531
|
friendsDir: path.join((0, identity_1.getAgentRoot)(), "friends"),
|
|
334
532
|
agentName: (0, identity_1.getAgentName)(),
|
|
335
533
|
currentFriendId: context?.friend?.id,
|
|
336
534
|
currentChannel: channel,
|
|
337
|
-
currentKey: "session",
|
|
535
|
+
currentKey: options?.currentSessionKey ?? "session",
|
|
338
536
|
}),
|
|
339
537
|
memoryFriendToolContractSection(),
|
|
340
538
|
toolBehaviorSection(options),
|
|
341
|
-
contextSection(context),
|
|
539
|
+
contextSection(context, options),
|
|
342
540
|
]
|
|
343
541
|
.filter(Boolean)
|
|
344
542
|
.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
|
-
};
|