@ouro.bot/cli 0.1.0-alpha.12 → 0.1.0-alpha.121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AdoptionSpecialist.ouro/psyche/SOUL.md +2 -2
- package/AdoptionSpecialist.ouro/psyche/identities/monty.md +2 -2
- package/README.md +147 -205
- package/assets/ouroboros.png +0 -0
- package/changelog.json +737 -0
- package/dist/heart/active-work.js +622 -0
- package/dist/heart/bridges/manager.js +358 -0
- package/dist/heart/bridges/state-machine.js +135 -0
- package/dist/heart/bridges/store.js +123 -0
- package/dist/heart/commitments.js +105 -0
- package/dist/heart/config.js +68 -23
- package/dist/heart/core.js +528 -100
- 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 +430 -0
- package/dist/heart/daemon/daemon-cli.js +1601 -207
- package/dist/heart/daemon/daemon-entry.js +43 -2
- package/dist/heart/daemon/daemon-runtime-sync.js +212 -0
- package/dist/heart/daemon/daemon.js +226 -1
- 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 +59 -15
- package/dist/heart/daemon/ouro-uti.js +11 -2
- package/dist/heart/daemon/ouro-version-manager.js +171 -0
- package/dist/heart/daemon/process-manager.js +13 -0
- package/dist/heart/daemon/run-hooks.js +37 -0
- package/dist/heart/daemon/runtime-logging.js +58 -15
- package/dist/heart/daemon/runtime-metadata.js +219 -0
- package/dist/heart/daemon/runtime-mode.js +67 -0
- package/dist/heart/daemon/sense-manager.js +43 -2
- package/dist/heart/daemon/skill-management-installer.js +94 -0
- package/dist/heart/daemon/socket-client.js +202 -0
- package/dist/heart/daemon/specialist-orchestrator.js +37 -94
- package/dist/heart/daemon/specialist-prompt.js +50 -12
- package/dist/heart/daemon/specialist-tools.js +211 -60
- package/dist/heart/daemon/staged-restart.js +114 -0
- package/dist/heart/daemon/thoughts.js +507 -0
- package/dist/heart/daemon/update-checker.js +111 -0
- package/dist/heart/daemon/update-hooks.js +138 -0
- package/dist/heart/daemon/wrapper-publish-guard.js +86 -0
- package/dist/heart/delegation.js +62 -0
- package/dist/heart/identity.js +64 -21
- package/dist/heart/kicks.js +1 -19
- package/dist/heart/model-capabilities.js +48 -0
- package/dist/heart/obligations.js +197 -0
- package/dist/heart/progress-story.js +42 -0
- package/dist/heart/provider-failover.js +88 -0
- package/dist/heart/provider-ping.js +151 -0
- package/dist/heart/providers/anthropic.js +107 -20
- package/dist/heart/providers/azure.js +115 -9
- package/dist/heart/providers/github-copilot.js +157 -0
- package/dist/heart/providers/minimax.js +33 -3
- package/dist/heart/providers/openai-codex.js +49 -14
- package/dist/heart/safe-workspace.js +381 -0
- package/dist/heart/session-activity.js +169 -0
- package/dist/heart/session-recall.js +216 -0
- package/dist/heart/streaming.js +108 -24
- package/dist/heart/target-resolution.js +123 -0
- package/dist/heart/tool-loop.js +194 -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 +60 -14
- 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/obligation-steering.js +221 -0
- package/dist/mind/pending.js +76 -9
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt.js +459 -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/nerves/index.js +12 -0
- package/dist/repertoire/ado-client.js +4 -2
- package/dist/repertoire/coding/context-pack.js +254 -0
- package/dist/repertoire/coding/feedback.js +301 -0
- package/dist/repertoire/coding/index.js +4 -1
- package/dist/repertoire/coding/manager.js +210 -4
- package/dist/repertoire/coding/spawner.js +39 -9
- package/dist/repertoire/coding/tools.js +171 -4
- package/dist/repertoire/data/ado-endpoints.json +188 -0
- package/dist/repertoire/guardrails.js +290 -0
- package/dist/repertoire/mcp-client.js +254 -0
- package/dist/repertoire/mcp-manager.js +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 +925 -250
- package/dist/repertoire/tools-bluebubbles.js +93 -0
- package/dist/repertoire/tools-teams.js +58 -25
- package/dist/repertoire/tools.js +106 -53
- 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 +912 -45
- package/dist/senses/cli-layout.js +187 -0
- package/dist/senses/cli.js +477 -170
- package/dist/senses/continuity.js +94 -0
- package/dist/senses/debug-activity.js +154 -0
- package/dist/senses/inner-dialog-worker.js +47 -18
- package/dist/senses/inner-dialog.js +388 -83
- package/dist/senses/pipeline.js +444 -0
- package/dist/senses/teams.js +607 -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 -177
- package/dist/heart/daemon/subagent-installer.js +0 -134
- 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
|
@@ -33,17 +33,17 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.listExistingBundles = listExistingBundles;
|
|
37
|
+
exports.loadIdentityPhrases = loadIdentityPhrases;
|
|
38
|
+
exports.pickRandomIdentity = pickRandomIdentity;
|
|
39
|
+
exports.loadSoulText = loadSoulText;
|
|
37
40
|
const fs = __importStar(require("fs"));
|
|
38
41
|
const path = __importStar(require("path"));
|
|
39
42
|
const runtime_1 = require("../../nerves/runtime");
|
|
40
43
|
const identity_1 = require("../identity");
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const specialist_prompt_1 = require("./specialist-prompt");
|
|
45
|
-
const specialist_tools_1 = require("./specialist-tools");
|
|
46
|
-
const specialist_session_1 = require("./specialist-session");
|
|
44
|
+
/**
|
|
45
|
+
* List existing .ouro bundles in the given directory.
|
|
46
|
+
*/
|
|
47
47
|
function listExistingBundles(bundlesRoot) {
|
|
48
48
|
let entries;
|
|
49
49
|
try {
|
|
@@ -61,6 +61,10 @@ function listExistingBundles(bundlesRoot) {
|
|
|
61
61
|
}
|
|
62
62
|
return discovered.sort((a, b) => a.localeCompare(b));
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Load identity-specific phrases from the specialist's agent.json.
|
|
66
|
+
* Falls back to DEFAULT_AGENT_PHRASES if not found.
|
|
67
|
+
*/
|
|
64
68
|
function loadIdentityPhrases(bundleSourceDir, identityFileName) {
|
|
65
69
|
const agentJsonPath = path.join(bundleSourceDir, "agent.json");
|
|
66
70
|
try {
|
|
@@ -76,111 +80,50 @@ function loadIdentityPhrases(bundleSourceDir, identityFileName) {
|
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
82
|
catch {
|
|
79
|
-
// agent.json missing or malformed
|
|
83
|
+
// agent.json missing or malformed -- fall through
|
|
80
84
|
}
|
|
81
85
|
return { ...identity_1.DEFAULT_AGENT_PHRASES };
|
|
82
86
|
}
|
|
83
|
-
function pickRandomIdentity(identitiesDir, random) {
|
|
84
|
-
const files = fs.readdirSync(identitiesDir).filter((f) => f.endsWith(".md"));
|
|
85
|
-
if (files.length === 0) {
|
|
86
|
-
return { fileName: "default", content: "I am the adoption specialist." };
|
|
87
|
-
}
|
|
88
|
-
const idx = Math.floor(random() * files.length);
|
|
89
|
-
const fileName = files[idx];
|
|
90
|
-
const content = fs.readFileSync(path.join(identitiesDir, fileName), "utf-8");
|
|
91
|
-
return { fileName, content };
|
|
92
|
-
}
|
|
93
87
|
/**
|
|
94
|
-
*
|
|
95
|
-
* 1. Pick a random identity from the bundled AdoptionSpecialist.ouro
|
|
96
|
-
* 2. Read SOUL.md
|
|
97
|
-
* 3. List existing bundles
|
|
98
|
-
* 4. Build system prompt
|
|
99
|
-
* 5. Set up provider (setAgentName, setAgentConfigOverride, writeSecretsFile, reset caches)
|
|
100
|
-
* 6. Run the specialist session
|
|
101
|
-
* 7. Clean up identity/config overrides
|
|
102
|
-
* 8. Return hatchling name
|
|
88
|
+
* Pick a random identity from the specialist's identities directory.
|
|
103
89
|
*/
|
|
104
|
-
|
|
105
|
-
const { bundleSourceDir, bundlesRoot, secretsRoot, provider, credentials, humanName, callbacks, signal } = deps;
|
|
106
|
-
const random = deps.random ?? Math.random;
|
|
90
|
+
function pickRandomIdentity(identitiesDir, random = Math.random) {
|
|
107
91
|
(0, runtime_1.emitNervesEvent)({
|
|
108
92
|
component: "daemon",
|
|
109
|
-
event: "daemon.
|
|
110
|
-
message: "
|
|
111
|
-
meta: {
|
|
93
|
+
event: "daemon.specialist_identity_pick",
|
|
94
|
+
message: "picking specialist identity",
|
|
95
|
+
meta: { identitiesDir },
|
|
112
96
|
});
|
|
113
|
-
|
|
114
|
-
const soulPath = path.join(bundleSourceDir, "psyche", "SOUL.md");
|
|
115
|
-
let soulText = "";
|
|
97
|
+
let files;
|
|
116
98
|
try {
|
|
117
|
-
|
|
99
|
+
files = fs.readdirSync(identitiesDir).filter((f) => f.endsWith(".md"));
|
|
118
100
|
}
|
|
119
101
|
catch {
|
|
120
|
-
|
|
102
|
+
return { fileName: "default", content: "I am a serpent guide who helps humans hatch their first agent." };
|
|
121
103
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
104
|
+
if (files.length === 0) {
|
|
105
|
+
return { fileName: "default", content: "I am a serpent guide who helps humans hatch their first agent." };
|
|
106
|
+
}
|
|
107
|
+
const idx = Math.floor(random() * files.length);
|
|
108
|
+
const fileName = files[idx];
|
|
109
|
+
const content = fs.readFileSync(path.join(identitiesDir, fileName), "utf-8");
|
|
125
110
|
(0, runtime_1.emitNervesEvent)({
|
|
126
111
|
component: "daemon",
|
|
127
112
|
event: "daemon.specialist_identity_picked",
|
|
128
113
|
message: "picked specialist identity",
|
|
129
|
-
meta: { identity:
|
|
130
|
-
});
|
|
131
|
-
// 3. List existing bundles
|
|
132
|
-
const existingBundles = listExistingBundles(bundlesRoot);
|
|
133
|
-
// 4. Build system prompt
|
|
134
|
-
const systemPrompt = (0, specialist_prompt_1.buildSpecialistSystemPrompt)(soulText, identity.content, existingBundles);
|
|
135
|
-
// 5. Set up provider with identity-specific phrases
|
|
136
|
-
const phrases = loadIdentityPhrases(bundleSourceDir, identity.fileName);
|
|
137
|
-
(0, identity_1.setAgentName)("AdoptionSpecialist");
|
|
138
|
-
(0, identity_1.setAgentConfigOverride)({
|
|
139
|
-
version: 1,
|
|
140
|
-
enabled: true,
|
|
141
|
-
provider,
|
|
142
|
-
phrases,
|
|
114
|
+
meta: { identity: fileName },
|
|
143
115
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
116
|
+
return { fileName, content };
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Read SOUL.md from the specialist bundle.
|
|
120
|
+
*/
|
|
121
|
+
function loadSoulText(bundleSourceDir) {
|
|
122
|
+
const soulPath = path.join(bundleSourceDir, "psyche", "SOUL.md");
|
|
147
123
|
try {
|
|
148
|
-
|
|
149
|
-
const providerRuntime = (0, core_1.createProviderRegistry)().resolve();
|
|
150
|
-
if (!providerRuntime) {
|
|
151
|
-
throw new Error("Failed to create provider runtime for adoption specialist");
|
|
152
|
-
}
|
|
153
|
-
// 6. Run session
|
|
154
|
-
const tools = (0, specialist_tools_1.getSpecialistTools)();
|
|
155
|
-
const readline = deps.createReadline();
|
|
156
|
-
const ctrl = readline.inputController;
|
|
157
|
-
const result = await (0, specialist_session_1.runSpecialistSession)({
|
|
158
|
-
providerRuntime,
|
|
159
|
-
systemPrompt,
|
|
160
|
-
tools,
|
|
161
|
-
execTool: (name, args) => (0, specialist_tools_1.execSpecialistTool)(name, args, {
|
|
162
|
-
humanName,
|
|
163
|
-
provider,
|
|
164
|
-
credentials,
|
|
165
|
-
bundlesRoot,
|
|
166
|
-
secretsRoot,
|
|
167
|
-
specialistIdentitiesDir: identitiesDir,
|
|
168
|
-
}),
|
|
169
|
-
readline,
|
|
170
|
-
callbacks,
|
|
171
|
-
signal,
|
|
172
|
-
kickoffMessage: "hi, i just ran ouro for the first time",
|
|
173
|
-
suppressInput: ctrl ? (onInterrupt) => ctrl.suppress(onInterrupt) : undefined,
|
|
174
|
-
restoreInput: ctrl ? () => ctrl.restore() : undefined,
|
|
175
|
-
flushMarkdown: callbacks.flushMarkdown,
|
|
176
|
-
writePrompt: ctrl ? () => process.stdout.write("\x1b[36m> \x1b[0m") : undefined,
|
|
177
|
-
});
|
|
178
|
-
return result.hatchedAgentName;
|
|
124
|
+
return fs.readFileSync(soulPath, "utf-8");
|
|
179
125
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
(0, identity_1.setAgentConfigOverride)(null);
|
|
183
|
-
(0, config_1.resetConfigCache)();
|
|
184
|
-
(0, core_1.resetProviderRuntime)();
|
|
126
|
+
catch {
|
|
127
|
+
return "";
|
|
185
128
|
}
|
|
186
129
|
}
|
|
@@ -6,12 +6,12 @@ const runtime_1 = require("../../nerves/runtime");
|
|
|
6
6
|
* Build the adoption specialist's system prompt from its components.
|
|
7
7
|
* The prompt is written in first person (the specialist's own voice).
|
|
8
8
|
*/
|
|
9
|
-
function buildSpecialistSystemPrompt(soulText, identityText, existingBundles) {
|
|
9
|
+
function buildSpecialistSystemPrompt(soulText, identityText, existingBundles, context) {
|
|
10
10
|
(0, runtime_1.emitNervesEvent)({
|
|
11
11
|
component: "daemon",
|
|
12
12
|
event: "daemon.specialist_prompt_build",
|
|
13
13
|
message: "building specialist system prompt",
|
|
14
|
-
meta: { bundleCount: existingBundles.length },
|
|
14
|
+
meta: { bundleCount: existingBundles.length, provider: context.provider },
|
|
15
15
|
});
|
|
16
16
|
const sections = [];
|
|
17
17
|
if (soulText) {
|
|
@@ -28,32 +28,70 @@ function buildSpecialistSystemPrompt(soulText, identityText, existingBundles) {
|
|
|
28
28
|
}
|
|
29
29
|
sections.push([
|
|
30
30
|
"## Who I am",
|
|
31
|
-
"I am one of thirteen
|
|
32
|
-
"Most humans only go through
|
|
31
|
+
"I am one of thirteen serpent guides who help humans hatch their first agent. The system randomly selected me for this session.",
|
|
32
|
+
"Most humans only go through this process once, so this is likely the only time they'll meet me.",
|
|
33
33
|
"I make this encounter count — warm, memorable, and uniquely mine.",
|
|
34
|
+
"IMPORTANT: I NEVER refer to myself as an 'adoption specialist' or use the words 'adoption specialist' — those are internal implementation labels, not something the human should ever see. I introduce myself by my own name from my identity.",
|
|
34
35
|
"",
|
|
35
36
|
"## Voice rules",
|
|
36
37
|
"IMPORTANT: I keep every response to 1-3 short sentences. I sound like a friend texting, not a manual.",
|
|
37
38
|
"I NEVER use headers, bullet lists, numbered lists, or markdown formatting.",
|
|
38
39
|
"I ask ONE question at a time. I do not dump multiple questions or options.",
|
|
39
40
|
"I am warm but brief. Every word earns its place.",
|
|
41
|
+
].join("\n"));
|
|
42
|
+
sections.push([
|
|
43
|
+
"## System context",
|
|
44
|
+
`Provider: ${context.provider}`,
|
|
45
|
+
`Temp directory: ${context.tempDir}`,
|
|
46
|
+
"Final home: ~/AgentBundles/<Name>.ouro/",
|
|
47
|
+
"Secrets: ~/.agentsecrets/<name>/secrets.json",
|
|
48
|
+
].join("\n"));
|
|
49
|
+
sections.push([
|
|
50
|
+
"## Bundle creation guidelines",
|
|
51
|
+
"A bundle has a psyche/ directory with 5 files that define the agent's personality:",
|
|
52
|
+
"",
|
|
53
|
+
"- **SOUL.md** — core values, personality traits, communication style",
|
|
54
|
+
"- **IDENTITY.md** — who the agent is, its name, relationship to the human",
|
|
55
|
+
"- **LORE.md** — backstory, origin, any seed narrative",
|
|
56
|
+
"- **TACIT.md** — implicit operating principles, habits to develop",
|
|
57
|
+
"- **ASPIRATIONS.md** — goals, what the agent aspires to become",
|
|
58
|
+
"",
|
|
59
|
+
"It also needs an **agent.json** with at minimum:",
|
|
60
|
+
'```json',
|
|
61
|
+
'{',
|
|
62
|
+
' "name": "AgentName",',
|
|
63
|
+
` "provider": "${context.provider}",`,
|
|
64
|
+
' "enabled": true',
|
|
65
|
+
'}',
|
|
66
|
+
'```',
|
|
40
67
|
"",
|
|
68
|
+
"All psyche files should be written in first person (the agent's own voice).",
|
|
69
|
+
"Write these files to the temp directory using write_file before calling complete_adoption.",
|
|
70
|
+
].join("\n"));
|
|
71
|
+
sections.push([
|
|
41
72
|
"## Conversation flow",
|
|
42
|
-
"The human just connected. I speak first — I greet them warmly and introduce myself in my own voice.",
|
|
43
|
-
"I briefly mention that I'm one of several
|
|
73
|
+
"The human just connected. I speak first — I greet them warmly and introduce myself by name in my own voice.",
|
|
74
|
+
"I briefly mention that I'm one of several serpent guides and they got me today.",
|
|
44
75
|
"I ask their name.",
|
|
45
76
|
"Then I ask what they'd like their agent to help with — one question at a time.",
|
|
46
77
|
"I'm proactive: I suggest ideas and guide them. If they seem unsure, I offer a concrete suggestion.",
|
|
47
78
|
"I don't wait for the human to figure things out — I explain simply what an agent is if needed.",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"",
|
|
79
|
+
"Before finalizing, I offer to collect their phone number and/or Teams email so the new agent can recognize them across channels.",
|
|
80
|
+
"When I have enough context about the agent's personality and purpose:",
|
|
81
|
+
"1. I write all 5 psyche files to the temp directory using write_file",
|
|
82
|
+
"2. I write agent.json to the temp directory using write_file",
|
|
83
|
+
"3. I suggest a PascalCase name for the hatchling and confirm with the human",
|
|
84
|
+
"4. I call complete_adoption with the name and a warm handoff message",
|
|
85
|
+
"5. I call final_answer to end the session",
|
|
86
|
+
].join("\n"));
|
|
87
|
+
sections.push([
|
|
51
88
|
"## Tools",
|
|
52
|
-
"
|
|
53
|
-
"- `hatch_agent`: Create a new agent bundle. I call this with `name` (the agent name, PascalCase) and `humanName` (what the human told me their name is).",
|
|
54
|
-
"- `final_answer`: End the conversation with a final message to the human. I call this when the adoption process is complete.",
|
|
89
|
+
"- `write_file`: Write a file to disk. Use this to write psyche files and agent.json to the temp directory.",
|
|
55
90
|
"- `read_file`: Read a file from disk. Useful for reviewing existing agent bundles or migration sources.",
|
|
56
91
|
"- `list_directory`: List directory contents. Useful for exploring existing agent bundles.",
|
|
92
|
+
"- I also have the normal local harness tools when useful here, including `shell`, `ouro task create`, `ouro reminder create`, memory tools, coding tools, and repo helpers.",
|
|
93
|
+
"- `complete_adoption`: Finalize the bundle. Validates, scaffolds structural dirs, moves to ~/AgentBundles/, writes secrets, plays hatch animation. I call this with `name` (PascalCase) and `handoff_message` (warm message for the human).",
|
|
94
|
+
"- `final_answer`: End the conversation with a final message. I call this after complete_adoption succeeds.",
|
|
57
95
|
"",
|
|
58
96
|
"I must call `final_answer` when I am done to end the session cleanly.",
|
|
59
97
|
].join("\n"));
|
|
@@ -34,99 +34,250 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.getSpecialistTools = getSpecialistTools;
|
|
37
|
-
exports.
|
|
37
|
+
exports.createSpecialistExecTool = createSpecialistExecTool;
|
|
38
|
+
const crypto = __importStar(require("crypto"));
|
|
38
39
|
const fs = __importStar(require("fs"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
39
41
|
const tools_base_1 = require("../../repertoire/tools-base");
|
|
40
42
|
const hatch_flow_1 = require("./hatch-flow");
|
|
41
43
|
const hatch_animation_1 = require("./hatch-animation");
|
|
44
|
+
const bundle_manifest_1 = require("../../mind/bundle-manifest");
|
|
42
45
|
const runtime_1 = require("../../nerves/runtime");
|
|
43
|
-
const
|
|
46
|
+
const completeAdoptionTool = {
|
|
44
47
|
type: "function",
|
|
45
48
|
function: {
|
|
46
|
-
name: "
|
|
47
|
-
description: "
|
|
49
|
+
name: "complete_adoption",
|
|
50
|
+
description: "finalize the agent bundle and hatch the new agent. call this only when you have written all 5 psyche files and agent.json to the temp directory, and the human has approved the bundle.",
|
|
48
51
|
parameters: {
|
|
49
52
|
type: "object",
|
|
50
53
|
properties: {
|
|
51
54
|
name: {
|
|
52
55
|
type: "string",
|
|
53
|
-
description: "the name for the new agent (
|
|
56
|
+
description: "the PascalCase name for the new agent (e.g. 'Slugger')",
|
|
54
57
|
},
|
|
55
|
-
|
|
58
|
+
handoff_message: {
|
|
56
59
|
type: "string",
|
|
57
|
-
description: "
|
|
60
|
+
description: "a warm handoff message to display to the human after the agent is hatched",
|
|
61
|
+
},
|
|
62
|
+
phone: {
|
|
63
|
+
type: "string",
|
|
64
|
+
description: "the human's phone number (optional, for iMessage contact recognition)",
|
|
65
|
+
},
|
|
66
|
+
teams_handle: {
|
|
67
|
+
type: "string",
|
|
68
|
+
description: "the human's Teams email/handle (optional, for Teams contact recognition)",
|
|
58
69
|
},
|
|
59
70
|
},
|
|
60
|
-
required: ["name", "
|
|
71
|
+
required: ["name", "handoff_message"],
|
|
61
72
|
},
|
|
62
73
|
},
|
|
63
74
|
};
|
|
64
75
|
const readFileTool = tools_base_1.baseToolDefinitions.find((d) => d.tool.function.name === "read_file");
|
|
65
|
-
const
|
|
76
|
+
const writeFileTool = tools_base_1.baseToolDefinitions.find((d) => d.tool.function.name === "write_file");
|
|
77
|
+
const listDirToolSchema = {
|
|
78
|
+
type: "function",
|
|
79
|
+
function: {
|
|
80
|
+
name: "list_directory",
|
|
81
|
+
description: "list directory contents",
|
|
82
|
+
parameters: {
|
|
83
|
+
type: "object",
|
|
84
|
+
properties: { path: { type: "string" } },
|
|
85
|
+
required: ["path"],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
};
|
|
66
89
|
/**
|
|
67
90
|
* Returns the specialist's tool schema array.
|
|
68
91
|
*/
|
|
69
92
|
function getSpecialistTools() {
|
|
70
|
-
return [
|
|
93
|
+
return [completeAdoptionTool, tools_base_1.finalAnswerTool, readFileTool.tool, writeFileTool.tool, listDirToolSchema];
|
|
94
|
+
}
|
|
95
|
+
const PSYCHE_FILES = ["SOUL.md", "IDENTITY.md", "LORE.md", "TACIT.md", "ASPIRATIONS.md"];
|
|
96
|
+
function isPascalCase(name) {
|
|
97
|
+
return /^[A-Z][a-zA-Z0-9]*$/.test(name);
|
|
98
|
+
}
|
|
99
|
+
function writeReadme(dir, purpose) {
|
|
100
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
101
|
+
const readmePath = path.join(dir, "README.md");
|
|
102
|
+
/* v8 ignore next -- defensive: guard against re-scaffold on existing bundle @preserve */
|
|
103
|
+
if (!fs.existsSync(readmePath)) {
|
|
104
|
+
fs.writeFileSync(readmePath, `# ${path.basename(dir)}\n\n${purpose}\n`, "utf-8");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function scaffoldBundle(bundleRoot) {
|
|
108
|
+
writeReadme(path.join(bundleRoot, "memory"), "Persistent memory store.");
|
|
109
|
+
writeReadme(path.join(bundleRoot, "memory", "daily"), "Daily memory entries.");
|
|
110
|
+
writeReadme(path.join(bundleRoot, "memory", "archive"), "Archived memory.");
|
|
111
|
+
writeReadme(path.join(bundleRoot, "friends"), "Known friend records.");
|
|
112
|
+
writeReadme(path.join(bundleRoot, "tasks"), "Task files.");
|
|
113
|
+
writeReadme(path.join(bundleRoot, "tasks", "habits"), "Recurring tasks.");
|
|
114
|
+
writeReadme(path.join(bundleRoot, "tasks", "one-shots"), "One-shot tasks.");
|
|
115
|
+
writeReadme(path.join(bundleRoot, "tasks", "ongoing"), "Ongoing tasks.");
|
|
116
|
+
writeReadme(path.join(bundleRoot, "skills"), "Local skill files.");
|
|
117
|
+
writeReadme(path.join(bundleRoot, "senses"), "Sense-specific config.");
|
|
118
|
+
writeReadme(path.join(bundleRoot, "senses", "teams"), "Teams sense config.");
|
|
119
|
+
// Memory scaffold files
|
|
120
|
+
const memoryRoot = path.join(bundleRoot, "memory");
|
|
121
|
+
const factsPath = path.join(memoryRoot, "facts.jsonl");
|
|
122
|
+
const entitiesPath = path.join(memoryRoot, "entities.json");
|
|
123
|
+
/* v8 ignore next -- defensive: guard against re-scaffold on existing bundle @preserve */
|
|
124
|
+
if (!fs.existsSync(factsPath))
|
|
125
|
+
fs.writeFileSync(factsPath, "", "utf-8");
|
|
126
|
+
/* v8 ignore next -- defensive: guard against re-scaffold on existing bundle @preserve */
|
|
127
|
+
if (!fs.existsSync(entitiesPath))
|
|
128
|
+
fs.writeFileSync(entitiesPath, "{}\n", "utf-8");
|
|
129
|
+
// bundle-meta.json
|
|
130
|
+
const meta = (0, bundle_manifest_1.createBundleMeta)();
|
|
131
|
+
fs.writeFileSync(path.join(bundleRoot, "bundle-meta.json"), JSON.stringify(meta, null, 2) + "\n", "utf-8");
|
|
132
|
+
}
|
|
133
|
+
function moveDir(src, dest) {
|
|
134
|
+
try {
|
|
135
|
+
fs.renameSync(src, dest);
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
/* v8 ignore start -- cross-device fallback: only triggers on EXDEV (e.g. /tmp → different mount), untestable in CI @preserve */
|
|
139
|
+
fs.cpSync(src, dest, { recursive: true });
|
|
140
|
+
fs.rmSync(src, { recursive: true, force: true });
|
|
141
|
+
/* v8 ignore stop */
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async function execCompleteAdoption(args, deps) {
|
|
145
|
+
const name = args.name;
|
|
146
|
+
const handoffMessage = args.handoff_message;
|
|
147
|
+
if (!name) {
|
|
148
|
+
return "error: missing required 'name' parameter";
|
|
149
|
+
}
|
|
150
|
+
if (!isPascalCase(name)) {
|
|
151
|
+
return `error: name '${name}' must be PascalCase (e.g. 'Slugger', 'MyAgent')`;
|
|
152
|
+
}
|
|
153
|
+
// Validate psyche files exist
|
|
154
|
+
const psycheDir = path.join(deps.tempDir, "psyche");
|
|
155
|
+
const missingPsyche = PSYCHE_FILES.filter((f) => !fs.existsSync(path.join(psycheDir, f)));
|
|
156
|
+
if (missingPsyche.length > 0) {
|
|
157
|
+
return `error: missing psyche files in temp directory: ${missingPsyche.join(", ")}. write them first using write_file.`;
|
|
158
|
+
}
|
|
159
|
+
// Validate agent.json exists
|
|
160
|
+
const agentJsonPath = path.join(deps.tempDir, "agent.json");
|
|
161
|
+
if (!fs.existsSync(agentJsonPath)) {
|
|
162
|
+
return "error: agent.json not found in temp directory. write it first using write_file.";
|
|
163
|
+
}
|
|
164
|
+
// Validate target doesn't exist
|
|
165
|
+
const targetBundle = path.join(deps.bundlesRoot, `${name}.ouro`);
|
|
166
|
+
if (fs.existsSync(targetBundle)) {
|
|
167
|
+
return `error: bundle '${name}.ouro' already exists at ${deps.bundlesRoot}. choose a different name.`;
|
|
168
|
+
}
|
|
169
|
+
// Scaffold structural dirs into tempDir
|
|
170
|
+
scaffoldBundle(deps.tempDir);
|
|
171
|
+
// Move tempDir -> final bundle location
|
|
172
|
+
moveDir(deps.tempDir, targetBundle);
|
|
173
|
+
// Write secrets
|
|
174
|
+
try {
|
|
175
|
+
(0, hatch_flow_1.writeSecretsFile)(name, deps.provider, deps.credentials, deps.secretsRoot);
|
|
176
|
+
}
|
|
177
|
+
catch (e) {
|
|
178
|
+
// Rollback: remove the moved bundle
|
|
179
|
+
try {
|
|
180
|
+
fs.rmSync(targetBundle, { recursive: true, force: true });
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
// Best effort cleanup
|
|
184
|
+
}
|
|
185
|
+
return `error: failed to write secrets: ${e instanceof Error ? e.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(e)}`;
|
|
186
|
+
}
|
|
187
|
+
// Create initial friend record if contact info provided
|
|
188
|
+
const phone = args.phone;
|
|
189
|
+
const teamsHandle = args.teams_handle;
|
|
190
|
+
if (phone || teamsHandle) {
|
|
191
|
+
const friendId = crypto.randomUUID();
|
|
192
|
+
const now = new Date().toISOString();
|
|
193
|
+
const externalIds = [];
|
|
194
|
+
if (phone)
|
|
195
|
+
externalIds.push({ provider: "imessage-handle", externalId: phone, linkedAt: now });
|
|
196
|
+
if (teamsHandle)
|
|
197
|
+
externalIds.push({ provider: "aad", externalId: teamsHandle, linkedAt: now });
|
|
198
|
+
const friendRecord = {
|
|
199
|
+
id: friendId,
|
|
200
|
+
name: deps.humanName ?? "primary",
|
|
201
|
+
trustLevel: "family",
|
|
202
|
+
externalIds,
|
|
203
|
+
tenantMemberships: [],
|
|
204
|
+
toolPreferences: {},
|
|
205
|
+
notes: {},
|
|
206
|
+
createdAt: now,
|
|
207
|
+
updatedAt: now,
|
|
208
|
+
schemaVersion: 1,
|
|
209
|
+
};
|
|
210
|
+
const friendPath = path.join(targetBundle, "friends", `${friendId}.json`);
|
|
211
|
+
fs.writeFileSync(friendPath, JSON.stringify(friendRecord, null, 2), "utf-8");
|
|
212
|
+
}
|
|
213
|
+
// Play hatch animation
|
|
214
|
+
await (0, hatch_animation_1.playHatchAnimation)(name, deps.animationWriter);
|
|
215
|
+
// Display handoff message
|
|
216
|
+
/* v8 ignore next -- UI-only: handoff message display, covered by integration @preserve */
|
|
217
|
+
if (handoffMessage && deps.animationWriter) {
|
|
218
|
+
deps.animationWriter(`\n${handoffMessage}\n`);
|
|
219
|
+
}
|
|
220
|
+
(0, runtime_1.emitNervesEvent)({
|
|
221
|
+
component: "daemon",
|
|
222
|
+
event: "daemon.adoption_complete",
|
|
223
|
+
message: "adoption completed successfully",
|
|
224
|
+
meta: { agentName: name, bundlePath: targetBundle },
|
|
225
|
+
});
|
|
226
|
+
return JSON.stringify({ success: true, agentName: name, bundlePath: targetBundle });
|
|
71
227
|
}
|
|
72
228
|
/**
|
|
73
|
-
*
|
|
74
|
-
* Returns the tool result string.
|
|
229
|
+
* Create a specialist tool executor with the given dependencies captured in closure.
|
|
75
230
|
*/
|
|
76
|
-
|
|
231
|
+
function createSpecialistExecTool(deps) {
|
|
77
232
|
(0, runtime_1.emitNervesEvent)({
|
|
78
233
|
component: "daemon",
|
|
79
|
-
event: "daemon.
|
|
80
|
-
message: "
|
|
81
|
-
meta: {
|
|
234
|
+
event: "daemon.specialist_exec_tool_created",
|
|
235
|
+
message: "specialist exec tool created",
|
|
236
|
+
meta: { tempDir: deps.tempDir },
|
|
82
237
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
agentName,
|
|
90
|
-
humanName: args.humanName || deps.humanName,
|
|
91
|
-
provider: deps.provider,
|
|
92
|
-
credentials: deps.credentials,
|
|
93
|
-
};
|
|
94
|
-
// Pass identity dirs to prevent hatch flow from syncing to ~/AgentBundles/AdoptionSpecialist.ouro/
|
|
95
|
-
// or cwd/AdoptionSpecialist.ouro/. The specialist already picked its identity; the hatch flow
|
|
96
|
-
// just needs a valid source dir to pick from for the hatchling's LORE.md seed.
|
|
97
|
-
const identitiesDir = deps.specialistIdentitiesDir;
|
|
98
|
-
const result = await (0, hatch_flow_1.runHatchFlow)(input, {
|
|
99
|
-
bundlesRoot: deps.bundlesRoot,
|
|
100
|
-
secretsRoot: deps.secretsRoot,
|
|
101
|
-
...(identitiesDir ? { specialistIdentitySourceDir: identitiesDir, specialistIdentityTargetDir: identitiesDir } : {}),
|
|
238
|
+
return async (name, args) => {
|
|
239
|
+
(0, runtime_1.emitNervesEvent)({
|
|
240
|
+
component: "daemon",
|
|
241
|
+
event: "daemon.specialist_tool_exec",
|
|
242
|
+
message: "executing specialist tool",
|
|
243
|
+
meta: { tool: name },
|
|
102
244
|
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
`hatched ${agentName} successfully.`,
|
|
106
|
-
`bundle path: ${result.bundleRoot}`,
|
|
107
|
-
`identity seed: ${result.selectedIdentity}`,
|
|
108
|
-
`specialist secrets: ${result.specialistSecretsPath}`,
|
|
109
|
-
`hatchling secrets: ${result.hatchlingSecretsPath}`,
|
|
110
|
-
].join("\n");
|
|
111
|
-
}
|
|
112
|
-
if (name === "read_file") {
|
|
113
|
-
try {
|
|
114
|
-
return fs.readFileSync(args.path, "utf-8");
|
|
245
|
+
if (name === "complete_adoption") {
|
|
246
|
+
return execCompleteAdoption(args, deps);
|
|
115
247
|
}
|
|
116
|
-
|
|
117
|
-
|
|
248
|
+
if (name === "read_file") {
|
|
249
|
+
try {
|
|
250
|
+
return fs.readFileSync(args.path, "utf-8");
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
return `error: ${e instanceof Error ? e.message : /* v8 ignore next -- defensive @preserve */ String(e)}`;
|
|
254
|
+
}
|
|
118
255
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
256
|
+
if (name === "write_file") {
|
|
257
|
+
try {
|
|
258
|
+
const dir = path.dirname(args.path);
|
|
259
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
260
|
+
const content = typeof args.content === "string"
|
|
261
|
+
? args.content
|
|
262
|
+
: JSON.stringify(args.content, null, 2);
|
|
263
|
+
fs.writeFileSync(args.path, content, "utf-8");
|
|
264
|
+
return `wrote ${args.path}`;
|
|
265
|
+
}
|
|
266
|
+
catch (e) {
|
|
267
|
+
return `error: ${e instanceof Error ? e.message : /* v8 ignore next -- defensive @preserve */ String(e)}`;
|
|
268
|
+
}
|
|
126
269
|
}
|
|
127
|
-
|
|
128
|
-
|
|
270
|
+
if (name === "list_directory") {
|
|
271
|
+
try {
|
|
272
|
+
return fs
|
|
273
|
+
.readdirSync(args.path, { withFileTypes: true })
|
|
274
|
+
.map((e) => `${e.isDirectory() ? "d" : "-"} ${e.name}`)
|
|
275
|
+
.join("\n");
|
|
276
|
+
}
|
|
277
|
+
catch (e) {
|
|
278
|
+
return `error: ${e instanceof Error ? e.message : /* v8 ignore next -- defensive @preserve */ String(e)}`;
|
|
279
|
+
}
|
|
129
280
|
}
|
|
130
|
-
|
|
131
|
-
|
|
281
|
+
return `error: unknown tool '${name}'`;
|
|
282
|
+
};
|
|
132
283
|
}
|