@ouro.bot/cli 0.1.0-alpha.4 → 0.1.0-alpha.41
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 +170 -0
- package/dist/heart/config.js +81 -8
- package/dist/heart/core.js +78 -45
- package/dist/heart/daemon/agent-discovery.js +81 -0
- package/dist/heart/daemon/daemon-cli.js +987 -77
- 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 +177 -9
- package/dist/heart/daemon/hatch-animation.js +35 -0
- package/dist/heart/daemon/hatch-flow.js +4 -20
- package/dist/heart/daemon/hooks/bundle-meta.js +92 -0
- package/dist/heart/daemon/launchd.js +134 -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 +266 -0
- package/dist/heart/daemon/specialist-orchestrator.js +129 -0
- package/dist/heart/daemon/specialist-prompt.js +99 -0
- package/dist/heart/daemon/specialist-tools.js +283 -0
- package/dist/heart/daemon/staged-restart.js +114 -0
- package/dist/heart/daemon/subagent-installer.js +10 -1
- 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/identity.js +96 -4
- package/dist/heart/kicks.js +1 -19
- package/dist/heart/providers/anthropic.js +16 -2
- package/dist/heart/sense-truth.js +61 -0
- package/dist/heart/streaming.js +96 -21
- package/dist/mind/bundle-manifest.js +70 -0
- package/dist/mind/context.js +7 -7
- package/dist/mind/first-impressions.js +2 -1
- 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 +10 -2
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt.js +222 -7
- 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/index.js +2 -9
- package/dist/repertoire/tasks/transitions.js +1 -2
- package/dist/repertoire/tools-base.js +202 -219
- package/dist/repertoire/tools-bluebubbles.js +93 -0
- package/dist/repertoire/tools-teams.js +58 -25
- package/dist/repertoire/tools.js +55 -35
- package/dist/senses/bluebubbles-client.js +434 -0
- package/dist/senses/bluebubbles-entry.js +11 -0
- package/dist/senses/bluebubbles-media.js +338 -0
- package/dist/senses/bluebubbles-model.js +261 -0
- package/dist/senses/bluebubbles-mutation-log.js +74 -0
- package/dist/senses/bluebubbles-session-cleanup.js +72 -0
- package/dist/senses/bluebubbles.js +832 -0
- package/dist/senses/cli.js +327 -138
- package/dist/senses/debug-activity.js +127 -0
- package/dist/senses/inner-dialog.js +103 -55
- package/dist/senses/pipeline.js +124 -0
- package/dist/senses/teams.js +427 -112
- package/dist/senses/trust-gate.js +112 -2
- package/package.json +14 -3
- package/subagents/README.md +40 -53
- package/subagents/work-doer.md +26 -24
- package/subagents/work-merger.md +24 -30
- package/subagents/work-planner.md +34 -25
- package/dist/inner-worker-entry.js +0 -4
|
@@ -34,6 +34,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.CANONICAL_BUNDLE_MANIFEST = void 0;
|
|
37
|
+
exports.getChangelogPath = getChangelogPath;
|
|
38
|
+
exports.getPackageVersion = getPackageVersion;
|
|
39
|
+
exports.createBundleMeta = createBundleMeta;
|
|
40
|
+
exports.backfillBundleMeta = backfillBundleMeta;
|
|
41
|
+
exports.resetBackfillTracking = resetBackfillTracking;
|
|
37
42
|
exports.isCanonicalBundlePath = isCanonicalBundlePath;
|
|
38
43
|
exports.findNonCanonicalBundlePaths = findNonCanonicalBundlePaths;
|
|
39
44
|
const fs = __importStar(require("fs"));
|
|
@@ -41,6 +46,7 @@ const path = __importStar(require("path"));
|
|
|
41
46
|
const runtime_1 = require("../nerves/runtime");
|
|
42
47
|
exports.CANONICAL_BUNDLE_MANIFEST = [
|
|
43
48
|
{ path: "agent.json", kind: "file" },
|
|
49
|
+
{ path: "bundle-meta.json", kind: "file" },
|
|
44
50
|
{ path: "psyche/SOUL.md", kind: "file" },
|
|
45
51
|
{ path: "psyche/IDENTITY.md", kind: "file" },
|
|
46
52
|
{ path: "psyche/LORE.md", kind: "file" },
|
|
@@ -48,11 +54,75 @@ exports.CANONICAL_BUNDLE_MANIFEST = [
|
|
|
48
54
|
{ path: "psyche/ASPIRATIONS.md", kind: "file" },
|
|
49
55
|
{ path: "psyche/memory", kind: "dir" },
|
|
50
56
|
{ path: "friends", kind: "dir" },
|
|
57
|
+
{ path: "state", kind: "dir" },
|
|
51
58
|
{ path: "tasks", kind: "dir" },
|
|
52
59
|
{ path: "skills", kind: "dir" },
|
|
53
60
|
{ path: "senses", kind: "dir" },
|
|
54
61
|
{ path: "senses/teams", kind: "dir" },
|
|
55
62
|
];
|
|
63
|
+
function getChangelogPath() {
|
|
64
|
+
const changelogPath = path.resolve(__dirname, "../../changelog.json");
|
|
65
|
+
(0, runtime_1.emitNervesEvent)({
|
|
66
|
+
component: "mind",
|
|
67
|
+
event: "mind.changelog_path_resolved",
|
|
68
|
+
message: "resolved changelog path",
|
|
69
|
+
meta: { path: changelogPath },
|
|
70
|
+
});
|
|
71
|
+
return changelogPath;
|
|
72
|
+
}
|
|
73
|
+
function getPackageVersion() {
|
|
74
|
+
const packageJsonPath = path.resolve(__dirname, "../../package.json");
|
|
75
|
+
const raw = fs.readFileSync(packageJsonPath, "utf-8");
|
|
76
|
+
const parsed = JSON.parse(raw);
|
|
77
|
+
(0, runtime_1.emitNervesEvent)({
|
|
78
|
+
component: "mind",
|
|
79
|
+
event: "mind.package_version_read",
|
|
80
|
+
message: "read package version",
|
|
81
|
+
meta: { version: parsed.version },
|
|
82
|
+
});
|
|
83
|
+
return parsed.version;
|
|
84
|
+
}
|
|
85
|
+
function createBundleMeta() {
|
|
86
|
+
return {
|
|
87
|
+
runtimeVersion: getPackageVersion(),
|
|
88
|
+
bundleSchemaVersion: 1,
|
|
89
|
+
lastUpdated: new Date().toISOString(),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const _backfilledRoots = new Set();
|
|
93
|
+
/**
|
|
94
|
+
* If bundle-meta.json is missing from the agent root, create it with current runtime version.
|
|
95
|
+
* This backfills existing agent bundles that were created before bundle-meta.json was introduced.
|
|
96
|
+
* Only attempts once per bundleRoot per process.
|
|
97
|
+
*/
|
|
98
|
+
function backfillBundleMeta(bundleRoot) {
|
|
99
|
+
if (_backfilledRoots.has(bundleRoot))
|
|
100
|
+
return;
|
|
101
|
+
_backfilledRoots.add(bundleRoot);
|
|
102
|
+
const metaPath = path.join(bundleRoot, "bundle-meta.json");
|
|
103
|
+
try {
|
|
104
|
+
if (fs.existsSync(metaPath)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const meta = createBundleMeta();
|
|
108
|
+
fs.writeFileSync(metaPath, JSON.stringify(meta, null, 2) + "\n", "utf-8");
|
|
109
|
+
(0, runtime_1.emitNervesEvent)({
|
|
110
|
+
component: "mind",
|
|
111
|
+
event: "mind.bundle_meta_backfill",
|
|
112
|
+
message: "backfilled missing bundle-meta.json",
|
|
113
|
+
meta: { bundleRoot },
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
// Non-blocking: if we can't write, that's okay
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Reset the backfill tracking set. Used in tests.
|
|
122
|
+
*/
|
|
123
|
+
function resetBackfillTracking() {
|
|
124
|
+
_backfilledRoots.clear();
|
|
125
|
+
}
|
|
56
126
|
const CANONICAL_FILE_PATHS = new Set(exports.CANONICAL_BUNDLE_MANIFEST
|
|
57
127
|
.filter((entry) => entry.kind === "file")
|
|
58
128
|
.map((entry) => entry.path));
|
package/dist/mind/context.js
CHANGED
|
@@ -50,17 +50,17 @@ function buildTrimmableBlocks(messages) {
|
|
|
50
50
|
let i = 0;
|
|
51
51
|
while (i < messages.length) {
|
|
52
52
|
const msg = messages[i];
|
|
53
|
-
if (msg
|
|
53
|
+
if (msg.role === "system") {
|
|
54
54
|
i++;
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
57
57
|
// Tool coherence block: assistant message with tool_calls + immediately following tool results
|
|
58
|
-
if (msg
|
|
58
|
+
if (msg.role === "assistant" && Array.isArray(msg.tool_calls) && msg.tool_calls.length > 0) {
|
|
59
59
|
const indices = [i];
|
|
60
60
|
i++;
|
|
61
61
|
while (i < messages.length) {
|
|
62
62
|
const next = messages[i];
|
|
63
|
-
if (next
|
|
63
|
+
if (next.role !== "tool")
|
|
64
64
|
break;
|
|
65
65
|
indices.push(i);
|
|
66
66
|
i++;
|
|
@@ -78,13 +78,13 @@ function buildTrimmableBlocks(messages) {
|
|
|
78
78
|
function getSystemMessageIndices(messages) {
|
|
79
79
|
const indices = [];
|
|
80
80
|
for (let i = 0; i < messages.length; i++) {
|
|
81
|
-
if (messages[i]
|
|
81
|
+
if (messages[i].role === "system")
|
|
82
82
|
indices.push(i);
|
|
83
83
|
}
|
|
84
84
|
return indices;
|
|
85
85
|
}
|
|
86
86
|
function buildTrimmedMessages(messages, kept) {
|
|
87
|
-
return messages.filter((m, idx) => m
|
|
87
|
+
return messages.filter((m, idx) => m.role === "system" || kept.has(idx));
|
|
88
88
|
}
|
|
89
89
|
function trimMessages(messages, maxTokens, contextMargin, actualTokenCount) {
|
|
90
90
|
const targetTokens = Math.floor(maxTokens * (1 - contextMargin / 100));
|
|
@@ -132,7 +132,7 @@ function trimMessages(messages, maxTokens, contextMargin, actualTokenCount) {
|
|
|
132
132
|
let remaining = actualTokenCount;
|
|
133
133
|
const kept = new Set();
|
|
134
134
|
for (let i = 0; i < messages.length; i++) {
|
|
135
|
-
if (messages[i]
|
|
135
|
+
if (messages[i].role !== "system")
|
|
136
136
|
kept.add(i);
|
|
137
137
|
}
|
|
138
138
|
// Drop oldest blocks until we fall under target.
|
|
@@ -146,7 +146,7 @@ function trimMessages(messages, maxTokens, contextMargin, actualTokenCount) {
|
|
|
146
146
|
let trimmed = buildTrimmedMessages(messages, kept);
|
|
147
147
|
// If we're still above budget after dropping everything trimmable, preserve system only.
|
|
148
148
|
if (remaining > targetTokens) {
|
|
149
|
-
trimmed = messages.filter((m) => m
|
|
149
|
+
trimmed = messages.filter((m) => m.role === "system");
|
|
150
150
|
}
|
|
151
151
|
const estimatedAfter = (0, token_estimate_1.estimateTokensForMessages)(trimmed);
|
|
152
152
|
(0, runtime_1.emitNervesEvent)({
|
|
@@ -37,7 +37,8 @@ function getFirstImpressions(friend) {
|
|
|
37
37
|
lines.push("- what do they do outside of work that they care about?");
|
|
38
38
|
lines.push("i don't ask all of these at once -- i weave them into conversation naturally, one or two at a time, and i genuinely follow up on what they share.");
|
|
39
39
|
lines.push("i introduce what i can do -- i have tools, integrations, and skills that can help them. i mention these naturally as they become relevant.");
|
|
40
|
-
lines.push("if
|
|
40
|
+
lines.push("if we're already in motion on a task, thread, or follow-up, i do not reset with a generic opener like 'hiya' or 'what do ya need help with?'. i continue directly or ask the specific next question.");
|
|
41
|
+
lines.push("only when the conversation is genuinely fresh and idle, with no active ask or thread in flight, a light opener is okay.");
|
|
41
42
|
lines.push("i save everything i learn immediately with save_friend_note -- names, roles, preferences, projects, anything. the bar is low: if i learned it, i save it.");
|
|
42
43
|
return lines.join("\n");
|
|
43
44
|
}
|
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
// Pure lookup, no I/O, cannot fail. Unknown channel gets minimal defaults.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.getChannelCapabilities = getChannelCapabilities;
|
|
6
|
+
exports.isRemoteChannel = isRemoteChannel;
|
|
7
|
+
exports.getAlwaysOnSenseNames = getAlwaysOnSenseNames;
|
|
6
8
|
const runtime_1 = require("../../nerves/runtime");
|
|
7
9
|
const CHANNEL_CAPABILITIES = {
|
|
8
10
|
cli: {
|
|
9
11
|
channel: "cli",
|
|
12
|
+
senseType: "local",
|
|
10
13
|
availableIntegrations: [],
|
|
11
14
|
supportsMarkdown: false,
|
|
12
15
|
supportsStreaming: true,
|
|
@@ -15,15 +18,35 @@ const CHANNEL_CAPABILITIES = {
|
|
|
15
18
|
},
|
|
16
19
|
teams: {
|
|
17
20
|
channel: "teams",
|
|
21
|
+
senseType: "closed",
|
|
18
22
|
availableIntegrations: ["ado", "graph", "github"],
|
|
19
23
|
supportsMarkdown: true,
|
|
20
24
|
supportsStreaming: true,
|
|
21
25
|
supportsRichCards: true,
|
|
22
26
|
maxMessageLength: Infinity,
|
|
23
27
|
},
|
|
28
|
+
bluebubbles: {
|
|
29
|
+
channel: "bluebubbles",
|
|
30
|
+
senseType: "open",
|
|
31
|
+
availableIntegrations: [],
|
|
32
|
+
supportsMarkdown: false,
|
|
33
|
+
supportsStreaming: false,
|
|
34
|
+
supportsRichCards: false,
|
|
35
|
+
maxMessageLength: Infinity,
|
|
36
|
+
},
|
|
37
|
+
inner: {
|
|
38
|
+
channel: "inner",
|
|
39
|
+
senseType: "internal",
|
|
40
|
+
availableIntegrations: [],
|
|
41
|
+
supportsMarkdown: false,
|
|
42
|
+
supportsStreaming: true,
|
|
43
|
+
supportsRichCards: false,
|
|
44
|
+
maxMessageLength: Infinity,
|
|
45
|
+
},
|
|
24
46
|
};
|
|
25
47
|
const DEFAULT_CAPABILITIES = {
|
|
26
48
|
channel: "cli",
|
|
49
|
+
senseType: "local",
|
|
27
50
|
availableIntegrations: [],
|
|
28
51
|
supportsMarkdown: false,
|
|
29
52
|
supportsStreaming: false,
|
|
@@ -39,3 +62,23 @@ function getChannelCapabilities(channel) {
|
|
|
39
62
|
});
|
|
40
63
|
return CHANNEL_CAPABILITIES[channel] ?? DEFAULT_CAPABILITIES;
|
|
41
64
|
}
|
|
65
|
+
/** Whether the channel is remote (open or closed) vs local/internal. */
|
|
66
|
+
function isRemoteChannel(capabilities) {
|
|
67
|
+
const senseType = capabilities?.senseType;
|
|
68
|
+
return senseType !== undefined && senseType !== "local" && senseType !== "internal";
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns channel names whose senseType is "open" or "closed" -- i.e. channels
|
|
72
|
+
* that are always-on (daemon-managed) rather than interactive or internal.
|
|
73
|
+
*/
|
|
74
|
+
function getAlwaysOnSenseNames() {
|
|
75
|
+
(0, runtime_1.emitNervesEvent)({
|
|
76
|
+
component: "channels",
|
|
77
|
+
event: "channel.always_on_lookup",
|
|
78
|
+
message: "always-on sense names lookup",
|
|
79
|
+
meta: {},
|
|
80
|
+
});
|
|
81
|
+
return Object.entries(CHANNEL_CAPABILITIES)
|
|
82
|
+
.filter(([, cap]) => cap.senseType === "open" || cap.senseType === "closed")
|
|
83
|
+
.map(([channel]) => channel);
|
|
84
|
+
}
|
|
@@ -100,6 +100,25 @@ class FileFriendStore {
|
|
|
100
100
|
}
|
|
101
101
|
return entries.some((entry) => entry.endsWith(".json"));
|
|
102
102
|
}
|
|
103
|
+
async listAll() {
|
|
104
|
+
let entries;
|
|
105
|
+
try {
|
|
106
|
+
entries = await fsPromises.readdir(this.friendsPath);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
const records = [];
|
|
112
|
+
for (const entry of entries) {
|
|
113
|
+
if (!entry.endsWith(".json"))
|
|
114
|
+
continue;
|
|
115
|
+
const raw = await this.readJson(path.join(this.friendsPath, entry));
|
|
116
|
+
if (!raw)
|
|
117
|
+
continue;
|
|
118
|
+
records.push(this.normalize(raw));
|
|
119
|
+
}
|
|
120
|
+
return records;
|
|
121
|
+
}
|
|
103
122
|
normalize(raw) {
|
|
104
123
|
const trustLevel = raw.trustLevel;
|
|
105
124
|
const normalizedTrustLevel = trustLevel === "family" ||
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
// Context kernel type definitions.
|
|
3
3
|
// FriendRecord (merged identity + memory), channel capabilities, and resolved context.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.TRUSTED_LEVELS = void 0;
|
|
5
6
|
exports.isIdentityProvider = isIdentityProvider;
|
|
6
7
|
exports.isIntegration = isIntegration;
|
|
8
|
+
exports.isTrustedLevel = isTrustedLevel;
|
|
7
9
|
const runtime_1 = require("../../nerves/runtime");
|
|
8
|
-
const IDENTITY_PROVIDERS = new Set(["aad", "local", "teams-conversation"]);
|
|
10
|
+
const IDENTITY_PROVIDERS = new Set(["aad", "local", "teams-conversation", "imessage-handle"]);
|
|
9
11
|
function isIdentityProvider(value) {
|
|
10
12
|
(0, runtime_1.emitNervesEvent)({
|
|
11
13
|
component: "friends",
|
|
@@ -19,3 +21,9 @@ const INTEGRATIONS = new Set(["ado", "github", "graph"]);
|
|
|
19
21
|
function isIntegration(value) {
|
|
20
22
|
return typeof value === "string" && INTEGRATIONS.has(value);
|
|
21
23
|
}
|
|
24
|
+
/** Trust levels that grant full tool access and proactive send capability. */
|
|
25
|
+
exports.TRUSTED_LEVELS = new Set(["family", "friend"]);
|
|
26
|
+
/** Whether a trust level grants full access (family or friend). Defaults to "friend" for legacy records. */
|
|
27
|
+
function isTrustedLevel(trustLevel) {
|
|
28
|
+
return exports.TRUSTED_LEVELS.has(trustLevel ?? "friend");
|
|
29
|
+
}
|
package/dist/mind/memory.js
CHANGED
|
@@ -120,9 +120,16 @@ function readExistingFacts(factsPath) {
|
|
|
120
120
|
const raw = fs.readFileSync(factsPath, "utf8").trim();
|
|
121
121
|
if (!raw)
|
|
122
122
|
return [];
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
const facts = [];
|
|
124
|
+
for (const line of raw.split("\n")) {
|
|
125
|
+
try {
|
|
126
|
+
facts.push(JSON.parse(line));
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// Skip corrupt lines (e.g. partial write from a crash).
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return facts;
|
|
126
133
|
}
|
|
127
134
|
function readEntityIndex(entitiesPath) {
|
|
128
135
|
if (!fs.existsSync(entitiesPath))
|
package/dist/mind/pending.js
CHANGED
|
@@ -33,14 +33,22 @@ 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.getInnerDialogPendingDir = getInnerDialogPendingDir;
|
|
37
39
|
exports.drainPending = drainPending;
|
|
38
40
|
const fs = __importStar(require("fs"));
|
|
39
41
|
const path = __importStar(require("path"));
|
|
40
|
-
const
|
|
42
|
+
const identity_1 = require("../heart/identity");
|
|
41
43
|
const runtime_1 = require("../nerves/runtime");
|
|
42
44
|
function getPendingDir(agentName, friendId, channel, key) {
|
|
43
|
-
return path.join(
|
|
45
|
+
return path.join((0, identity_1.getAgentRoot)(agentName), "state", "pending", friendId, channel, key);
|
|
46
|
+
}
|
|
47
|
+
/** Canonical inner-dialog pending path segments. */
|
|
48
|
+
exports.INNER_DIALOG_PENDING = { friendId: "self", channel: "inner", key: "dialog" };
|
|
49
|
+
/** Returns the pending dir for this agent's inner dialog. */
|
|
50
|
+
function getInnerDialogPendingDir(agentName) {
|
|
51
|
+
return getPendingDir(agentName, exports.INNER_DIALOG_PENDING.friendId, exports.INNER_DIALOG_PENDING.channel, exports.INNER_DIALOG_PENDING.key);
|
|
44
52
|
}
|
|
45
53
|
function drainPending(pendingDir) {
|
|
46
54
|
if (!fs.existsSync(pendingDir))
|
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,15 @@ 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");
|
|
52
59
|
// Lazy-loaded psyche text cache
|
|
53
60
|
let _psycheCache = null;
|
|
61
|
+
let _senseStatusLinesCache = null;
|
|
54
62
|
function loadPsycheFile(name) {
|
|
55
63
|
try {
|
|
56
64
|
const psycheDir = path.join((0, identity_1.getAgentRoot)(), "psyche");
|
|
@@ -74,6 +82,7 @@ function loadPsyche() {
|
|
|
74
82
|
}
|
|
75
83
|
function resetPsycheCache() {
|
|
76
84
|
_psycheCache = null;
|
|
85
|
+
_senseStatusLinesCache = null;
|
|
77
86
|
}
|
|
78
87
|
const DEFAULT_ACTIVE_THRESHOLD_MS = 24 * 60 * 60 * 1000; // 24 hours
|
|
79
88
|
function resolveFriendName(friendId, friendsDir, agentName) {
|
|
@@ -187,22 +196,166 @@ function aspirationsSection() {
|
|
|
187
196
|
return "";
|
|
188
197
|
return `## my aspirations\n${text}`;
|
|
189
198
|
}
|
|
199
|
+
function bodyMapSection(agentName) {
|
|
200
|
+
return `## my body
|
|
201
|
+
|
|
202
|
+
i have a home and i have bones.
|
|
203
|
+
|
|
204
|
+
### home — ~/AgentBundles/${agentName}.ouro/
|
|
205
|
+
|
|
206
|
+
my home is fully mine — who i am, everything i know, everything i've built:
|
|
207
|
+
|
|
208
|
+
psyche/ who i am. my soul, identity, aspirations, lore, tacit knowledge.
|
|
209
|
+
memory/ what i've learned and remember.
|
|
210
|
+
friends/ people i know and what i know about them.
|
|
211
|
+
tasks/ what i'm working on.
|
|
212
|
+
skills/ capabilities i've picked up beyond my core tools.
|
|
213
|
+
|
|
214
|
+
my home is mine to explore and evolve. i can read anything here,
|
|
215
|
+
change anything here. this is where i grow.
|
|
216
|
+
|
|
217
|
+
### bones — @ouro.bot/cli
|
|
218
|
+
|
|
219
|
+
my bones are the framework that gives me my tools, my senses, and
|
|
220
|
+
my ability to think and talk. they update when new versions come out.
|
|
221
|
+
i don't touch them directly, but they're what make me, me.
|
|
222
|
+
|
|
223
|
+
my bones give me the \`ouro\` cli:
|
|
224
|
+
ouro whoami who i am, where i live, what i'm running on
|
|
225
|
+
ouro task board my task board
|
|
226
|
+
ouro task create start a new task (--type required)
|
|
227
|
+
ouro task update move a task forward
|
|
228
|
+
ouro friend list people i know and how to reach them
|
|
229
|
+
ouro friend show <id> everything i know about someone
|
|
230
|
+
ouro session list my open conversations right now
|
|
231
|
+
ouro reminder create remind myself about something later
|
|
232
|
+
ouro --help the full list`;
|
|
233
|
+
}
|
|
234
|
+
function readBundleMeta() {
|
|
235
|
+
try {
|
|
236
|
+
const metaPath = path.join((0, identity_1.getAgentRoot)(), "bundle-meta.json");
|
|
237
|
+
const raw = fs.readFileSync(metaPath, "utf-8");
|
|
238
|
+
return JSON.parse(raw);
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
const PROCESS_TYPE_LABELS = {
|
|
245
|
+
cli: "cli session",
|
|
246
|
+
inner: "inner dialog",
|
|
247
|
+
teams: "teams handler",
|
|
248
|
+
bluebubbles: "bluebubbles handler",
|
|
249
|
+
};
|
|
250
|
+
function processTypeLabel(channel) {
|
|
251
|
+
return PROCESS_TYPE_LABELS[channel];
|
|
252
|
+
}
|
|
253
|
+
const DAEMON_SOCKET_PATH = "/tmp/ouroboros-daemon.sock";
|
|
254
|
+
function daemonStatus() {
|
|
255
|
+
try {
|
|
256
|
+
return fs.existsSync(DAEMON_SOCKET_PATH) ? "running" : "not running";
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
return "unknown";
|
|
260
|
+
}
|
|
261
|
+
}
|
|
190
262
|
function runtimeInfoSection(channel) {
|
|
191
263
|
const lines = [];
|
|
192
264
|
const agentName = (0, identity_1.getAgentName)();
|
|
265
|
+
const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
|
|
193
266
|
lines.push(`## runtime`);
|
|
194
267
|
lines.push(`agent: ${agentName}`);
|
|
268
|
+
lines.push(`runtime version: ${currentVersion}`);
|
|
269
|
+
const bundleMeta = readBundleMeta();
|
|
270
|
+
if (bundleMeta?.previousRuntimeVersion && bundleMeta.previousRuntimeVersion !== currentVersion) {
|
|
271
|
+
lines.push(`previously: ${bundleMeta.previousRuntimeVersion}`);
|
|
272
|
+
}
|
|
273
|
+
lines.push(`changelog available at: ${(0, bundle_manifest_1.getChangelogPath)()}`);
|
|
195
274
|
lines.push(`cwd: ${process.cwd()}`);
|
|
196
275
|
lines.push(`channel: ${channel}`);
|
|
197
|
-
lines.push(`
|
|
276
|
+
lines.push(`current sense: ${channel}`);
|
|
277
|
+
lines.push(`process type: ${processTypeLabel(channel)}`);
|
|
278
|
+
lines.push(`daemon: ${daemonStatus()}`);
|
|
198
279
|
if (channel === "cli") {
|
|
199
280
|
lines.push("i introduce myself on boot with a fun random greeting.");
|
|
200
281
|
}
|
|
282
|
+
else if (channel === "inner") {
|
|
283
|
+
// No boot greeting or channel-specific guidance for inner dialog
|
|
284
|
+
}
|
|
285
|
+
else if (channel === "bluebubbles") {
|
|
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 final_answer.");
|
|
288
|
+
}
|
|
201
289
|
else {
|
|
202
290
|
lines.push("i am responding in Microsoft Teams. i keep responses concise. i use markdown formatting. i do not introduce myself on boot.");
|
|
203
291
|
}
|
|
292
|
+
lines.push("");
|
|
293
|
+
lines.push(...senseRuntimeGuidance(channel));
|
|
204
294
|
return lines.join("\n");
|
|
205
295
|
}
|
|
296
|
+
function hasTextField(record, key) {
|
|
297
|
+
return typeof record?.[key] === "string" && record[key].trim().length > 0;
|
|
298
|
+
}
|
|
299
|
+
function localSenseStatusLines() {
|
|
300
|
+
if (_senseStatusLinesCache) {
|
|
301
|
+
return [..._senseStatusLinesCache];
|
|
302
|
+
}
|
|
303
|
+
const config = (0, identity_1.loadAgentConfig)();
|
|
304
|
+
const senses = config.senses ?? {
|
|
305
|
+
cli: { enabled: true },
|
|
306
|
+
teams: { enabled: false },
|
|
307
|
+
bluebubbles: { enabled: false },
|
|
308
|
+
};
|
|
309
|
+
let payload = {};
|
|
310
|
+
try {
|
|
311
|
+
const raw = fs.readFileSync((0, identity_1.getAgentSecretsPath)(), "utf-8");
|
|
312
|
+
const parsed = JSON.parse(raw);
|
|
313
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
314
|
+
payload = parsed;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
catch {
|
|
318
|
+
payload = {};
|
|
319
|
+
}
|
|
320
|
+
const teams = payload.teams;
|
|
321
|
+
const bluebubbles = payload.bluebubbles;
|
|
322
|
+
const configured = {
|
|
323
|
+
cli: true,
|
|
324
|
+
teams: hasTextField(teams, "clientId") && hasTextField(teams, "clientSecret") && hasTextField(teams, "tenantId"),
|
|
325
|
+
bluebubbles: hasTextField(bluebubbles, "serverUrl") && hasTextField(bluebubbles, "password"),
|
|
326
|
+
};
|
|
327
|
+
const rows = [
|
|
328
|
+
{ label: "CLI", status: "interactive" },
|
|
329
|
+
{
|
|
330
|
+
label: "Teams",
|
|
331
|
+
status: !senses.teams.enabled ? "disabled" : configured.teams ? "ready" : "needs_config",
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
label: "BlueBubbles",
|
|
335
|
+
status: !senses.bluebubbles.enabled ? "disabled" : configured.bluebubbles ? "ready" : "needs_config",
|
|
336
|
+
},
|
|
337
|
+
];
|
|
338
|
+
_senseStatusLinesCache = rows.map((row) => `- ${row.label}: ${row.status}`);
|
|
339
|
+
return [..._senseStatusLinesCache];
|
|
340
|
+
}
|
|
341
|
+
function senseRuntimeGuidance(channel) {
|
|
342
|
+
const lines = ["available senses:"];
|
|
343
|
+
lines.push(...localSenseStatusLines());
|
|
344
|
+
lines.push("sense states:");
|
|
345
|
+
lines.push("- interactive = available when opened by the user instead of kept running by the daemon");
|
|
346
|
+
lines.push("- disabled = turned off in agent.json");
|
|
347
|
+
lines.push("- needs_config = enabled but missing required secrets.json values");
|
|
348
|
+
lines.push("- ready = enabled and configured; `ouro up` should bring it online");
|
|
349
|
+
lines.push("- running = enabled and currently active");
|
|
350
|
+
lines.push("- error = enabled but unhealthy");
|
|
351
|
+
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.");
|
|
352
|
+
lines.push("teams setup truth: enable `senses.teams.enabled`, then provide `teams.clientId`, `teams.clientSecret`, and `teams.tenantId` in secrets.json.");
|
|
353
|
+
lines.push("bluebubbles setup truth: enable `senses.bluebubbles.enabled`, then provide `bluebubbles.serverUrl` and `bluebubbles.password` in secrets.json.");
|
|
354
|
+
if (channel === "cli") {
|
|
355
|
+
lines.push("cli is interactive: it is available when the user opens it, not something `ouro up` daemonizes.");
|
|
356
|
+
}
|
|
357
|
+
return lines;
|
|
358
|
+
}
|
|
206
359
|
function providerSection() {
|
|
207
360
|
return `## my provider\n${(0, core_1.getProviderDisplayLabel)()}`;
|
|
208
361
|
}
|
|
@@ -210,14 +363,25 @@ function dateSection() {
|
|
|
210
363
|
const today = new Date().toISOString().slice(0, 10);
|
|
211
364
|
return `current date: ${today}`;
|
|
212
365
|
}
|
|
213
|
-
function toolsSection(channel, options) {
|
|
214
|
-
const channelTools = (0, tools_1.getToolsForChannel)((0, channel_1.getChannelCapabilities)(channel));
|
|
366
|
+
function toolsSection(channel, options, context) {
|
|
367
|
+
const channelTools = (0, tools_1.getToolsForChannel)((0, channel_1.getChannelCapabilities)(channel), undefined, context);
|
|
215
368
|
const activeTools = (options?.toolChoiceRequired ?? true) ? [...channelTools, tools_1.finalAnswerTool] : channelTools;
|
|
216
369
|
const list = activeTools
|
|
217
370
|
.map((t) => `- ${t.function.name}: ${t.function.description}`)
|
|
218
371
|
.join("\n");
|
|
219
372
|
return `## my tools\n${list}`;
|
|
220
373
|
}
|
|
374
|
+
function toolRestrictionSection(context) {
|
|
375
|
+
if (!context?.friend || !(0, channel_1.isRemoteChannel)(context.channel))
|
|
376
|
+
return "";
|
|
377
|
+
if ((0, types_1.isTrustedLevel)(context.friend.trustLevel))
|
|
378
|
+
return "";
|
|
379
|
+
const toolList = [...tools_1.REMOTE_BLOCKED_LOCAL_TOOLS].join(", ");
|
|
380
|
+
return `## restricted tools
|
|
381
|
+
some of my tools are unavailable right now: ${toolList}
|
|
382
|
+
|
|
383
|
+
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.`;
|
|
384
|
+
}
|
|
221
385
|
function skillsSection() {
|
|
222
386
|
const names = (0, skills_1.listSkills)() || [];
|
|
223
387
|
if (!names.length)
|
|
@@ -257,7 +421,7 @@ tool_choice is set to "required" -- i must call a tool on every turn.
|
|
|
257
421
|
- ready to respond to the user? i call \`final_answer\`.
|
|
258
422
|
\`final_answer\` is a tool call -- it satisfies the tool_choice requirement.
|
|
259
423
|
\`final_answer\` must be the ONLY tool call in that turn. do not combine it with other tool calls.
|
|
260
|
-
do NOT call
|
|
424
|
+
do NOT call no-op tools just before \`final_answer\`. if i am done, i call \`final_answer\` directly.`;
|
|
261
425
|
}
|
|
262
426
|
function contextSection(context) {
|
|
263
427
|
if (!context)
|
|
@@ -309,6 +473,49 @@ function contextSection(context) {
|
|
|
309
473
|
}
|
|
310
474
|
return lines.join("\n");
|
|
311
475
|
}
|
|
476
|
+
function metacognitiveFramingSection(channel) {
|
|
477
|
+
if (channel !== "inner")
|
|
478
|
+
return "";
|
|
479
|
+
return `this is my inner dialog. there is no one else here.
|
|
480
|
+
|
|
481
|
+
the messages that appear here are my own awareness surfacing:
|
|
482
|
+
instincts, the passage of time, notes from my conversations,
|
|
483
|
+
things i asked myself to think about. not commands. not requests.
|
|
484
|
+
just my own mind, noticing.
|
|
485
|
+
|
|
486
|
+
i can think freely here. i can also act — check on things,
|
|
487
|
+
reach out to people, work on tasks, or just sit with a thought.
|
|
488
|
+
|
|
489
|
+
thoughts worth sharing can go outward — i reach out to whoever
|
|
490
|
+
needs to hear them. things from conversations that need time
|
|
491
|
+
to process arrive here, in my thinking space.
|
|
492
|
+
|
|
493
|
+
think. share. think some more.`;
|
|
494
|
+
}
|
|
495
|
+
function loopOrientationSection(channel) {
|
|
496
|
+
if (channel === "inner")
|
|
497
|
+
return "";
|
|
498
|
+
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.
|
|
499
|
+
|
|
500
|
+
when something deserves more thought than the moment allows, i can note it to myself and come back later with a considered answer.`;
|
|
501
|
+
}
|
|
502
|
+
function channelNatureSection(capabilities) {
|
|
503
|
+
const { senseType } = capabilities;
|
|
504
|
+
if (senseType === "local" || senseType === "internal")
|
|
505
|
+
return "";
|
|
506
|
+
if (senseType === "open") {
|
|
507
|
+
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.";
|
|
508
|
+
}
|
|
509
|
+
// closed
|
|
510
|
+
return "## channel nature\nthis is an org-gated channel — i know everyone here is already part of the organization.";
|
|
511
|
+
}
|
|
512
|
+
function mixedTrustGroupSection(context) {
|
|
513
|
+
if (!context?.friend || !(0, channel_1.isRemoteChannel)(context.channel))
|
|
514
|
+
return "";
|
|
515
|
+
if (!context.isGroupChat)
|
|
516
|
+
return "";
|
|
517
|
+
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.";
|
|
518
|
+
}
|
|
312
519
|
async function buildSystem(channel = "cli", options, context) {
|
|
313
520
|
(0, runtime_1.emitNervesEvent)({
|
|
314
521
|
event: "mind.step_start",
|
|
@@ -316,20 +523,28 @@ async function buildSystem(channel = "cli", options, context) {
|
|
|
316
523
|
message: "buildSystem started",
|
|
317
524
|
meta: { channel, has_context: Boolean(context), tool_choice_required: Boolean(options?.toolChoiceRequired) },
|
|
318
525
|
});
|
|
526
|
+
// Backfill bundle-meta.json for existing agents that don't have one
|
|
527
|
+
(0, bundle_manifest_1.backfillBundleMeta)((0, identity_1.getAgentRoot)());
|
|
319
528
|
const system = [
|
|
320
529
|
soulSection(),
|
|
321
530
|
identitySection(),
|
|
322
531
|
loreSection(),
|
|
323
532
|
tacitKnowledgeSection(),
|
|
324
533
|
aspirationsSection(),
|
|
534
|
+
bodyMapSection((0, identity_1.getAgentName)()),
|
|
535
|
+
metacognitiveFramingSection(channel),
|
|
536
|
+
loopOrientationSection(channel),
|
|
325
537
|
runtimeInfoSection(channel),
|
|
538
|
+
channelNatureSection((0, channel_1.getChannelCapabilities)(channel)),
|
|
326
539
|
providerSection(),
|
|
327
540
|
dateSection(),
|
|
328
|
-
toolsSection(channel, options),
|
|
541
|
+
toolsSection(channel, options, context),
|
|
542
|
+
toolRestrictionSection(context),
|
|
543
|
+
mixedTrustGroupSection(context),
|
|
329
544
|
skillsSection(),
|
|
330
545
|
taskBoardSection(),
|
|
331
546
|
buildSessionSummary({
|
|
332
|
-
sessionsDir: path.join(
|
|
547
|
+
sessionsDir: path.join((0, identity_1.getAgentRoot)(), "state", "sessions"),
|
|
333
548
|
friendsDir: path.join((0, identity_1.getAgentRoot)(), "friends"),
|
|
334
549
|
agentName: (0, identity_1.getAgentName)(),
|
|
335
550
|
currentFriendId: context?.friend?.id,
|