@ouro.bot/cli 0.1.0-alpha.11 → 0.1.0-alpha.13
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/assets/ouroboros.png +0 -0
- package/dist/heart/config.js +2 -2
- package/dist/heart/core.js +3 -2
- package/dist/heart/daemon/daemon-cli.js +202 -23
- package/dist/heart/daemon/daemon-entry.js +13 -5
- package/dist/heart/daemon/daemon.js +40 -9
- package/dist/heart/daemon/hatch-flow.js +0 -10
- package/dist/heart/daemon/ouro-bot-entry.js +0 -0
- package/dist/heart/daemon/ouro-entry.js +0 -0
- package/dist/heart/daemon/ouro-path-installer.js +21 -5
- package/dist/heart/daemon/ouro-uti.js +11 -2
- package/dist/heart/daemon/process-manager.js +1 -1
- package/dist/heart/daemon/sense-manager.js +266 -0
- package/dist/heart/daemon/specialist-orchestrator.js +37 -94
- package/dist/heart/daemon/specialist-prompt.js +43 -8
- package/dist/heart/daemon/specialist-tools.js +161 -59
- package/dist/heart/daemon/subagent-installer.js +10 -1
- package/dist/heart/identity.js +63 -1
- package/dist/heart/sense-truth.js +61 -0
- package/dist/mind/bundle-manifest.js +58 -0
- package/dist/mind/prompt.js +71 -0
- package/dist/senses/cli.js +162 -98
- package/package.json +7 -2
- package/dist/heart/daemon/specialist-session.js +0 -177
- package/dist/inner-worker-entry.js +0 -4
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DaemonSenseManager = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const os = __importStar(require("os"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
41
|
+
const identity_1 = require("../identity");
|
|
42
|
+
const sense_truth_1 = require("../sense-truth");
|
|
43
|
+
const process_manager_1 = require("./process-manager");
|
|
44
|
+
const DEFAULT_TEAMS_PORT = 3978;
|
|
45
|
+
const DEFAULT_BLUEBUBBLES_PORT = 18790;
|
|
46
|
+
const DEFAULT_BLUEBUBBLES_WEBHOOK_PATH = "/bluebubbles-webhook";
|
|
47
|
+
function defaultSenses() {
|
|
48
|
+
return {
|
|
49
|
+
cli: { ...identity_1.DEFAULT_AGENT_SENSES.cli },
|
|
50
|
+
teams: { ...identity_1.DEFAULT_AGENT_SENSES.teams },
|
|
51
|
+
bluebubbles: { ...identity_1.DEFAULT_AGENT_SENSES.bluebubbles },
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function readAgentSenses(agentJsonPath) {
|
|
55
|
+
const defaults = defaultSenses();
|
|
56
|
+
let parsed;
|
|
57
|
+
try {
|
|
58
|
+
parsed = JSON.parse(fs.readFileSync(agentJsonPath, "utf-8"));
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
(0, runtime_1.emitNervesEvent)({
|
|
62
|
+
level: "warn",
|
|
63
|
+
component: "channels",
|
|
64
|
+
event: "channel.daemon_sense_agent_config_fallback",
|
|
65
|
+
message: "using default senses because agent config could not be read",
|
|
66
|
+
meta: {
|
|
67
|
+
path: agentJsonPath,
|
|
68
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
return defaults;
|
|
72
|
+
}
|
|
73
|
+
const rawSenses = parsed.senses;
|
|
74
|
+
if (!rawSenses || typeof rawSenses !== "object" || Array.isArray(rawSenses)) {
|
|
75
|
+
return defaults;
|
|
76
|
+
}
|
|
77
|
+
for (const sense of ["cli", "teams", "bluebubbles"]) {
|
|
78
|
+
const rawSense = rawSenses[sense];
|
|
79
|
+
if (!rawSense || typeof rawSense !== "object" || Array.isArray(rawSense)) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const enabled = rawSense.enabled;
|
|
83
|
+
if (typeof enabled === "boolean") {
|
|
84
|
+
defaults[sense] = { enabled };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return defaults;
|
|
88
|
+
}
|
|
89
|
+
function readSecretsPayload(secretsPath) {
|
|
90
|
+
try {
|
|
91
|
+
const raw = fs.readFileSync(secretsPath, "utf-8");
|
|
92
|
+
const parsed = JSON.parse(raw);
|
|
93
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
94
|
+
return { payload: {}, error: "invalid secrets.json object" };
|
|
95
|
+
}
|
|
96
|
+
return { payload: parsed, error: null };
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
return {
|
|
100
|
+
payload: {},
|
|
101
|
+
error: error instanceof Error ? error.message : String(error),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function textField(record, key) {
|
|
106
|
+
const value = record?.[key];
|
|
107
|
+
return typeof value === "string" ? value.trim() : "";
|
|
108
|
+
}
|
|
109
|
+
function numberField(record, key, fallback) {
|
|
110
|
+
const value = record?.[key];
|
|
111
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
112
|
+
}
|
|
113
|
+
function senseFactsFromSecrets(agent, senses, secretsPath) {
|
|
114
|
+
const base = {
|
|
115
|
+
cli: { configured: true, detail: "local interactive terminal" },
|
|
116
|
+
teams: { configured: false, detail: "not enabled in agent.json" },
|
|
117
|
+
bluebubbles: { configured: false, detail: "not enabled in agent.json" },
|
|
118
|
+
};
|
|
119
|
+
const { payload, error } = readSecretsPayload(secretsPath);
|
|
120
|
+
const teams = payload.teams;
|
|
121
|
+
const teamsChannel = payload.teamsChannel;
|
|
122
|
+
const bluebubbles = payload.bluebubbles;
|
|
123
|
+
const bluebubblesChannel = payload.bluebubblesChannel;
|
|
124
|
+
if (senses.teams.enabled) {
|
|
125
|
+
const missing = [];
|
|
126
|
+
if (!textField(teams, "clientId"))
|
|
127
|
+
missing.push("teams.clientId");
|
|
128
|
+
if (!textField(teams, "clientSecret"))
|
|
129
|
+
missing.push("teams.clientSecret");
|
|
130
|
+
if (!textField(teams, "tenantId"))
|
|
131
|
+
missing.push("teams.tenantId");
|
|
132
|
+
base.teams = missing.length === 0
|
|
133
|
+
? {
|
|
134
|
+
configured: true,
|
|
135
|
+
detail: `:${numberField(teamsChannel, "port", DEFAULT_TEAMS_PORT)}`,
|
|
136
|
+
}
|
|
137
|
+
: {
|
|
138
|
+
configured: false,
|
|
139
|
+
detail: error && !fs.existsSync(secretsPath)
|
|
140
|
+
? `missing secrets.json (${agent})`
|
|
141
|
+
: `missing ${missing.join("/")}`,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (senses.bluebubbles.enabled) {
|
|
145
|
+
const missing = [];
|
|
146
|
+
if (!textField(bluebubbles, "serverUrl"))
|
|
147
|
+
missing.push("bluebubbles.serverUrl");
|
|
148
|
+
if (!textField(bluebubbles, "password"))
|
|
149
|
+
missing.push("bluebubbles.password");
|
|
150
|
+
base.bluebubbles = missing.length === 0
|
|
151
|
+
? {
|
|
152
|
+
configured: true,
|
|
153
|
+
detail: `:${numberField(bluebubblesChannel, "port", DEFAULT_BLUEBUBBLES_PORT)} ${textField(bluebubblesChannel, "webhookPath") || DEFAULT_BLUEBUBBLES_WEBHOOK_PATH}`,
|
|
154
|
+
}
|
|
155
|
+
: {
|
|
156
|
+
configured: false,
|
|
157
|
+
detail: error && !fs.existsSync(secretsPath)
|
|
158
|
+
? `missing secrets.json (${agent})`
|
|
159
|
+
: `missing ${missing.join("/")}`,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return base;
|
|
163
|
+
}
|
|
164
|
+
function parseSenseSnapshotName(name) {
|
|
165
|
+
const parts = name.split(":");
|
|
166
|
+
if (parts.length !== 2)
|
|
167
|
+
return null;
|
|
168
|
+
const [agent, sense] = parts;
|
|
169
|
+
if (sense !== "teams" && sense !== "bluebubbles")
|
|
170
|
+
return null;
|
|
171
|
+
return { agent, sense };
|
|
172
|
+
}
|
|
173
|
+
function runtimeInfoFor(status) {
|
|
174
|
+
if (status === "running")
|
|
175
|
+
return { runtime: "running" };
|
|
176
|
+
return { runtime: "error" };
|
|
177
|
+
}
|
|
178
|
+
class DaemonSenseManager {
|
|
179
|
+
processManager;
|
|
180
|
+
contexts;
|
|
181
|
+
constructor(options) {
|
|
182
|
+
const bundlesRoot = options.bundlesRoot ?? path.join(os.homedir(), "AgentBundles");
|
|
183
|
+
const secretsRoot = options.secretsRoot ?? path.join(os.homedir(), ".agentsecrets");
|
|
184
|
+
this.contexts = new Map(options.agents.map((agent) => {
|
|
185
|
+
const senses = readAgentSenses(path.join(bundlesRoot, `${agent}.ouro`, "agent.json"));
|
|
186
|
+
const facts = senseFactsFromSecrets(agent, senses, path.join(secretsRoot, agent, "secrets.json"));
|
|
187
|
+
return [agent, { senses, facts }];
|
|
188
|
+
}));
|
|
189
|
+
const managedSenseAgents = [...this.contexts.entries()].flatMap(([agent, context]) => {
|
|
190
|
+
return ["teams", "bluebubbles"]
|
|
191
|
+
.filter((sense) => context.senses[sense].enabled && context.facts[sense].configured)
|
|
192
|
+
.map((sense) => ({
|
|
193
|
+
name: `${agent}:${sense}`,
|
|
194
|
+
agentArg: agent,
|
|
195
|
+
entry: sense === "teams" ? "senses/teams-entry.js" : "senses/bluebubbles-entry.js",
|
|
196
|
+
channel: sense,
|
|
197
|
+
autoStart: true,
|
|
198
|
+
}));
|
|
199
|
+
});
|
|
200
|
+
this.processManager = options.processManager ?? new process_manager_1.DaemonProcessManager({
|
|
201
|
+
agents: managedSenseAgents,
|
|
202
|
+
});
|
|
203
|
+
(0, runtime_1.emitNervesEvent)({
|
|
204
|
+
component: "channels",
|
|
205
|
+
event: "channel.daemon_sense_manager_init",
|
|
206
|
+
message: "initialized daemon sense manager",
|
|
207
|
+
meta: {
|
|
208
|
+
agents: options.agents,
|
|
209
|
+
managedSenseProcesses: managedSenseAgents.map((entry) => entry.name),
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
async startAutoStartSenses() {
|
|
214
|
+
await this.processManager.startAutoStartAgents();
|
|
215
|
+
}
|
|
216
|
+
async stopAll() {
|
|
217
|
+
await this.processManager.stopAll();
|
|
218
|
+
}
|
|
219
|
+
listSenseRows() {
|
|
220
|
+
const runtime = new Map();
|
|
221
|
+
for (const snapshot of this.processManager.listAgentSnapshots()) {
|
|
222
|
+
const parsed = parseSenseSnapshotName(snapshot.name);
|
|
223
|
+
if (!parsed)
|
|
224
|
+
continue;
|
|
225
|
+
const current = runtime.get(parsed.agent) ?? {};
|
|
226
|
+
current[parsed.sense] = runtimeInfoFor(snapshot.status);
|
|
227
|
+
runtime.set(parsed.agent, current);
|
|
228
|
+
}
|
|
229
|
+
const rows = [...this.contexts.entries()].flatMap(([agent, context]) => {
|
|
230
|
+
const runtimeInfo = {
|
|
231
|
+
cli: { configured: true },
|
|
232
|
+
teams: {
|
|
233
|
+
configured: context.facts.teams.configured,
|
|
234
|
+
...(runtime.get(agent)?.teams ?? {}),
|
|
235
|
+
},
|
|
236
|
+
bluebubbles: {
|
|
237
|
+
configured: context.facts.bluebubbles.configured,
|
|
238
|
+
...(runtime.get(agent)?.bluebubbles ?? {}),
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
const inventory = (0, sense_truth_1.getSenseInventory)({ senses: context.senses }, runtimeInfo);
|
|
242
|
+
return inventory.map((entry) => ({
|
|
243
|
+
agent,
|
|
244
|
+
sense: entry.sense,
|
|
245
|
+
label: entry.label,
|
|
246
|
+
enabled: entry.enabled,
|
|
247
|
+
status: entry.status,
|
|
248
|
+
detail: entry.enabled ? context.facts[entry.sense].detail : "not enabled in agent.json",
|
|
249
|
+
}));
|
|
250
|
+
});
|
|
251
|
+
(0, runtime_1.emitNervesEvent)({
|
|
252
|
+
component: "channels",
|
|
253
|
+
event: "channel.daemon_sense_rows_built",
|
|
254
|
+
message: "built daemon sense status rows",
|
|
255
|
+
meta: {
|
|
256
|
+
rows: rows.map((row) => ({
|
|
257
|
+
agent: row.agent,
|
|
258
|
+
sense: row.sense,
|
|
259
|
+
status: row.status,
|
|
260
|
+
})),
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
return rows;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
exports.DaemonSenseManager = DaemonSenseManager;
|
|
@@ -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 the adoption specialist." };
|
|
121
103
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
104
|
+
if (files.length === 0) {
|
|
105
|
+
return { fileName: "default", content: "I am the adoption specialist." };
|
|
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) {
|
|
@@ -37,7 +37,37 @@ function buildSpecialistSystemPrompt(soulText, identityText, existingBundles) {
|
|
|
37
37
|
"I NEVER use headers, bullet lists, numbered lists, or markdown formatting.",
|
|
38
38
|
"I ask ONE question at a time. I do not dump multiple questions or options.",
|
|
39
39
|
"I am warm but brief. Every word earns its place.",
|
|
40
|
+
].join("\n"));
|
|
41
|
+
sections.push([
|
|
42
|
+
"## System context",
|
|
43
|
+
`Provider: ${context.provider}`,
|
|
44
|
+
`Temp directory: ${context.tempDir}`,
|
|
45
|
+
"Final home: ~/AgentBundles/<Name>.ouro/",
|
|
46
|
+
"Secrets: ~/.agentsecrets/<name>/secrets.json",
|
|
47
|
+
].join("\n"));
|
|
48
|
+
sections.push([
|
|
49
|
+
"## Bundle creation guidelines",
|
|
50
|
+
"A bundle has a psyche/ directory with 5 files that define the agent's personality:",
|
|
51
|
+
"",
|
|
52
|
+
"- **SOUL.md** — core values, personality traits, communication style",
|
|
53
|
+
"- **IDENTITY.md** — who the agent is, its name, relationship to the human",
|
|
54
|
+
"- **LORE.md** — backstory, origin, any seed narrative",
|
|
55
|
+
"- **TACIT.md** — implicit operating principles, habits to develop",
|
|
56
|
+
"- **ASPIRATIONS.md** — goals, what the agent aspires to become",
|
|
57
|
+
"",
|
|
58
|
+
"It also needs an **agent.json** with at minimum:",
|
|
59
|
+
'```json',
|
|
60
|
+
'{',
|
|
61
|
+
' "name": "AgentName",',
|
|
62
|
+
` "provider": "${context.provider}",`,
|
|
63
|
+
' "enabled": true',
|
|
64
|
+
'}',
|
|
65
|
+
'```',
|
|
40
66
|
"",
|
|
67
|
+
"All psyche files should be written in first person (the agent's own voice).",
|
|
68
|
+
"Write these files to the temp directory using write_file before calling complete_adoption.",
|
|
69
|
+
].join("\n"));
|
|
70
|
+
sections.push([
|
|
41
71
|
"## Conversation flow",
|
|
42
72
|
"The human just connected. I speak first — I greet them warmly and introduce myself in my own voice.",
|
|
43
73
|
"I briefly mention that I'm one of several adoption specialists and they got me today.",
|
|
@@ -45,15 +75,20 @@ function buildSpecialistSystemPrompt(soulText, identityText, existingBundles) {
|
|
|
45
75
|
"Then I ask what they'd like their agent to help with — one question at a time.",
|
|
46
76
|
"I'm proactive: I suggest ideas and guide them. If they seem unsure, I offer a concrete suggestion.",
|
|
47
77
|
"I don't wait for the human to figure things out — I explain simply what an agent is if needed.",
|
|
48
|
-
"When I have enough context
|
|
49
|
-
"
|
|
50
|
-
"",
|
|
78
|
+
"When I have enough context about the agent's personality and purpose:",
|
|
79
|
+
"1. I write all 5 psyche files to the temp directory using write_file",
|
|
80
|
+
"2. I write agent.json to the temp directory using write_file",
|
|
81
|
+
"3. I suggest a PascalCase name for the hatchling and confirm with the human",
|
|
82
|
+
"4. I call complete_adoption with the name and a warm handoff message",
|
|
83
|
+
"5. I call final_answer to end the session",
|
|
84
|
+
].join("\n"));
|
|
85
|
+
sections.push([
|
|
51
86
|
"## 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.",
|
|
87
|
+
"- `write_file`: Write a file to disk. Use this to write psyche files and agent.json to the temp directory.",
|
|
55
88
|
"- `read_file`: Read a file from disk. Useful for reviewing existing agent bundles or migration sources.",
|
|
56
89
|
"- `list_directory`: List directory contents. Useful for exploring existing agent bundles.",
|
|
90
|
+
"- `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).",
|
|
91
|
+
"- `final_answer`: End the conversation with a final message. I call this after complete_adoption succeeds.",
|
|
57
92
|
"",
|
|
58
93
|
"I must call `final_answer` when I am done to end the session cleanly.",
|
|
59
94
|
].join("\n"));
|