@ouro.bot/cli 0.1.0-alpha.2 → 0.1.0-alpha.21
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/assets/ouroboros.png +0 -0
- package/dist/heart/config.js +66 -4
- package/dist/heart/core.js +75 -2
- package/dist/heart/daemon/daemon-cli.js +523 -33
- package/dist/heart/daemon/daemon-entry.js +13 -5
- package/dist/heart/daemon/daemon-runtime-sync.js +90 -0
- package/dist/heart/daemon/daemon.js +42 -9
- package/dist/heart/daemon/hatch-animation.js +35 -0
- package/dist/heart/daemon/hatch-flow.js +2 -11
- package/dist/heart/daemon/hatch-specialist.js +6 -1
- package/dist/heart/daemon/ouro-bot-wrapper.js +4 -3
- 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/runtime-logging.js +9 -5
- 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 +98 -0
- package/dist/heart/daemon/specialist-tools.js +237 -0
- package/dist/heart/daemon/subagent-installer.js +10 -1
- package/dist/heart/daemon/wrapper-publish-guard.js +48 -0
- package/dist/heart/identity.js +77 -1
- package/dist/heart/providers/anthropic.js +19 -2
- package/dist/heart/sense-truth.js +61 -0
- package/dist/heart/streaming.js +99 -21
- package/dist/mind/bundle-manifest.js +58 -0
- package/dist/mind/friends/channel.js +8 -0
- package/dist/mind/friends/types.js +1 -1
- package/dist/mind/prompt.js +77 -3
- 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 +61 -2
- 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/tools-base.js +69 -5
- package/dist/repertoire/tools-teams.js +57 -4
- package/dist/repertoire/tools.js +44 -11
- package/dist/senses/bluebubbles-client.js +433 -0
- package/dist/senses/bluebubbles-entry.js +11 -0
- package/dist/senses/bluebubbles-media.js +244 -0
- package/dist/senses/bluebubbles-model.js +253 -0
- package/dist/senses/bluebubbles-mutation-log.js +76 -0
- package/dist/senses/bluebubbles.js +421 -0
- package/dist/senses/cli.js +293 -133
- package/dist/senses/debug-activity.js +107 -0
- package/dist/senses/teams.js +173 -54
- package/package.json +11 -4
- 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
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.ensureDaemonRunning = ensureDaemonRunning;
|
|
37
37
|
exports.parseOuroCommand = parseOuroCommand;
|
|
38
|
+
exports.discoverExistingCredentials = discoverExistingCredentials;
|
|
38
39
|
exports.createDefaultOuroCliDeps = createDefaultOuroCliDeps;
|
|
39
40
|
exports.runOuroCli = runOuroCli;
|
|
40
41
|
const child_process_1 = require("child_process");
|
|
@@ -47,15 +48,169 @@ const runtime_1 = require("../../nerves/runtime");
|
|
|
47
48
|
const store_file_1 = require("../../mind/friends/store-file");
|
|
48
49
|
const types_1 = require("../../mind/friends/types");
|
|
49
50
|
const ouro_uti_1 = require("./ouro-uti");
|
|
51
|
+
const ouro_path_installer_1 = require("./ouro-path-installer");
|
|
50
52
|
const subagent_installer_1 = require("./subagent-installer");
|
|
51
53
|
const hatch_flow_1 = require("./hatch-flow");
|
|
54
|
+
const specialist_orchestrator_1 = require("./specialist-orchestrator");
|
|
55
|
+
const specialist_prompt_1 = require("./specialist-prompt");
|
|
56
|
+
const specialist_tools_1 = require("./specialist-tools");
|
|
57
|
+
const runtime_metadata_1 = require("./runtime-metadata");
|
|
58
|
+
const daemon_runtime_sync_1 = require("./daemon-runtime-sync");
|
|
59
|
+
function stringField(value) {
|
|
60
|
+
return typeof value === "string" ? value : null;
|
|
61
|
+
}
|
|
62
|
+
function numberField(value) {
|
|
63
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
64
|
+
}
|
|
65
|
+
function booleanField(value) {
|
|
66
|
+
return typeof value === "boolean" ? value : null;
|
|
67
|
+
}
|
|
68
|
+
function parseStatusPayload(data) {
|
|
69
|
+
if (!data || typeof data !== "object" || Array.isArray(data))
|
|
70
|
+
return null;
|
|
71
|
+
const raw = data;
|
|
72
|
+
const overview = raw.overview;
|
|
73
|
+
const senses = raw.senses;
|
|
74
|
+
const workers = raw.workers;
|
|
75
|
+
if (!overview || typeof overview !== "object" || Array.isArray(overview))
|
|
76
|
+
return null;
|
|
77
|
+
if (!Array.isArray(senses) || !Array.isArray(workers))
|
|
78
|
+
return null;
|
|
79
|
+
const parsedOverview = {
|
|
80
|
+
daemon: stringField(overview.daemon) ?? "unknown",
|
|
81
|
+
health: stringField(overview.health) ?? "unknown",
|
|
82
|
+
socketPath: stringField(overview.socketPath) ?? "unknown",
|
|
83
|
+
version: stringField(overview.version) ?? "unknown",
|
|
84
|
+
lastUpdated: stringField(overview.lastUpdated) ?? "unknown",
|
|
85
|
+
workerCount: numberField(overview.workerCount) ?? 0,
|
|
86
|
+
senseCount: numberField(overview.senseCount) ?? 0,
|
|
87
|
+
};
|
|
88
|
+
const parsedSenses = senses.map((entry) => {
|
|
89
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
90
|
+
return null;
|
|
91
|
+
const row = entry;
|
|
92
|
+
const agent = stringField(row.agent);
|
|
93
|
+
const sense = stringField(row.sense);
|
|
94
|
+
const status = stringField(row.status);
|
|
95
|
+
const detail = stringField(row.detail);
|
|
96
|
+
const enabled = booleanField(row.enabled);
|
|
97
|
+
if (!agent || !sense || !status || detail === null || enabled === null)
|
|
98
|
+
return null;
|
|
99
|
+
return {
|
|
100
|
+
agent,
|
|
101
|
+
sense,
|
|
102
|
+
label: stringField(row.label) ?? undefined,
|
|
103
|
+
enabled,
|
|
104
|
+
status,
|
|
105
|
+
detail,
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
const parsedWorkers = workers.map((entry) => {
|
|
109
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
110
|
+
return null;
|
|
111
|
+
const row = entry;
|
|
112
|
+
const agent = stringField(row.agent);
|
|
113
|
+
const worker = stringField(row.worker);
|
|
114
|
+
const status = stringField(row.status);
|
|
115
|
+
const restartCount = numberField(row.restartCount);
|
|
116
|
+
const hasPid = Object.prototype.hasOwnProperty.call(row, "pid");
|
|
117
|
+
const pid = row.pid === null ? null : numberField(row.pid);
|
|
118
|
+
const pidInvalid = !hasPid || (row.pid !== null && pid === null);
|
|
119
|
+
if (!agent || !worker || !status || restartCount === null || pidInvalid)
|
|
120
|
+
return null;
|
|
121
|
+
return {
|
|
122
|
+
agent,
|
|
123
|
+
worker,
|
|
124
|
+
status,
|
|
125
|
+
pid,
|
|
126
|
+
restartCount,
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
if (parsedSenses.some((row) => row === null) || parsedWorkers.some((row) => row === null))
|
|
130
|
+
return null;
|
|
131
|
+
return {
|
|
132
|
+
overview: parsedOverview,
|
|
133
|
+
senses: parsedSenses,
|
|
134
|
+
workers: parsedWorkers,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function humanizeSenseName(sense, label) {
|
|
138
|
+
if (label)
|
|
139
|
+
return label;
|
|
140
|
+
if (sense === "cli")
|
|
141
|
+
return "CLI";
|
|
142
|
+
if (sense === "bluebubbles")
|
|
143
|
+
return "BlueBubbles";
|
|
144
|
+
if (sense === "teams")
|
|
145
|
+
return "Teams";
|
|
146
|
+
return sense;
|
|
147
|
+
}
|
|
148
|
+
function formatTable(headers, rows) {
|
|
149
|
+
const widths = headers.map((header, index) => Math.max(header.length, ...rows.map((row) => row[index].length)));
|
|
150
|
+
const renderRow = (row) => `| ${row.map((cell, index) => cell.padEnd(widths[index])).join(" | ")} |`;
|
|
151
|
+
const divider = `|-${widths.map((width) => "-".repeat(width)).join("-|-")}-|`;
|
|
152
|
+
return [
|
|
153
|
+
renderRow(headers),
|
|
154
|
+
divider,
|
|
155
|
+
...rows.map(renderRow),
|
|
156
|
+
].join("\n");
|
|
157
|
+
}
|
|
158
|
+
function formatDaemonStatusOutput(response, fallback) {
|
|
159
|
+
const payload = parseStatusPayload(response.data);
|
|
160
|
+
if (!payload)
|
|
161
|
+
return fallback;
|
|
162
|
+
const overviewRows = [
|
|
163
|
+
["Daemon", payload.overview.daemon],
|
|
164
|
+
["Socket", payload.overview.socketPath],
|
|
165
|
+
["Version", payload.overview.version],
|
|
166
|
+
["Last Updated", payload.overview.lastUpdated],
|
|
167
|
+
["Workers", String(payload.overview.workerCount)],
|
|
168
|
+
["Senses", String(payload.overview.senseCount)],
|
|
169
|
+
["Health", payload.overview.health],
|
|
170
|
+
];
|
|
171
|
+
const senseRows = payload.senses.map((row) => [
|
|
172
|
+
row.agent,
|
|
173
|
+
humanizeSenseName(row.sense, row.label),
|
|
174
|
+
row.enabled ? "ON" : "OFF",
|
|
175
|
+
row.status,
|
|
176
|
+
row.detail,
|
|
177
|
+
]);
|
|
178
|
+
const workerRows = payload.workers.map((row) => [
|
|
179
|
+
row.agent,
|
|
180
|
+
row.worker,
|
|
181
|
+
row.status,
|
|
182
|
+
row.pid === null ? "n/a" : String(row.pid),
|
|
183
|
+
String(row.restartCount),
|
|
184
|
+
]);
|
|
185
|
+
return [
|
|
186
|
+
"Overview",
|
|
187
|
+
formatTable(["Item", "Value"], overviewRows),
|
|
188
|
+
"",
|
|
189
|
+
"Senses",
|
|
190
|
+
formatTable(["Agent", "Sense", "Enabled", "State", "Detail"], senseRows),
|
|
191
|
+
"",
|
|
192
|
+
"Workers",
|
|
193
|
+
formatTable(["Agent", "Worker", "State", "PID", "Restarts"], workerRows),
|
|
194
|
+
].join("\n");
|
|
195
|
+
}
|
|
52
196
|
async function ensureDaemonRunning(deps) {
|
|
53
197
|
const alive = await deps.checkSocketAlive(deps.socketPath);
|
|
54
198
|
if (alive) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
199
|
+
const localRuntime = (0, runtime_metadata_1.getRuntimeMetadata)();
|
|
200
|
+
return (0, daemon_runtime_sync_1.ensureCurrentDaemonRuntime)({
|
|
201
|
+
socketPath: deps.socketPath,
|
|
202
|
+
localVersion: localRuntime.version,
|
|
203
|
+
fetchRunningVersion: async () => {
|
|
204
|
+
const status = await deps.sendCommand(deps.socketPath, { kind: "daemon.status" });
|
|
205
|
+
const payload = parseStatusPayload(status.data);
|
|
206
|
+
return payload?.overview.version ?? "unknown";
|
|
207
|
+
},
|
|
208
|
+
stopDaemon: async () => {
|
|
209
|
+
await deps.sendCommand(deps.socketPath, { kind: "daemon.stop" });
|
|
210
|
+
},
|
|
211
|
+
cleanupStaleSocket: deps.cleanupStaleSocket,
|
|
212
|
+
startDaemonProcess: deps.startDaemonProcess,
|
|
213
|
+
});
|
|
59
214
|
}
|
|
60
215
|
deps.cleanupStaleSocket(deps.socketPath);
|
|
61
216
|
const started = await deps.startDaemonProcess(deps.socketPath);
|
|
@@ -69,12 +224,49 @@ function usage() {
|
|
|
69
224
|
"Usage:",
|
|
70
225
|
" ouro [up]",
|
|
71
226
|
" ouro stop|status|logs|hatch",
|
|
227
|
+
" ouro -v|--version",
|
|
72
228
|
" ouro chat <agent>",
|
|
73
229
|
" ouro msg --to <agent> [--session <id>] [--task <ref>] <message>",
|
|
74
230
|
" ouro poke <agent> --task <task-id>",
|
|
75
231
|
" ouro link <agent> --friend <id> --provider <provider> --external-id <external-id>",
|
|
76
232
|
].join("\n");
|
|
77
233
|
}
|
|
234
|
+
function formatVersionOutput() {
|
|
235
|
+
return (0, runtime_metadata_1.getRuntimeMetadata)().version;
|
|
236
|
+
}
|
|
237
|
+
function buildStoppedStatusPayload(socketPath) {
|
|
238
|
+
const metadata = (0, runtime_metadata_1.getRuntimeMetadata)();
|
|
239
|
+
return {
|
|
240
|
+
overview: {
|
|
241
|
+
daemon: "stopped",
|
|
242
|
+
health: "warn",
|
|
243
|
+
socketPath,
|
|
244
|
+
version: metadata.version,
|
|
245
|
+
lastUpdated: metadata.lastUpdated,
|
|
246
|
+
workerCount: 0,
|
|
247
|
+
senseCount: 0,
|
|
248
|
+
},
|
|
249
|
+
senses: [],
|
|
250
|
+
workers: [],
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function daemonUnavailableStatusOutput(socketPath) {
|
|
254
|
+
return [
|
|
255
|
+
formatDaemonStatusOutput({
|
|
256
|
+
ok: true,
|
|
257
|
+
summary: "daemon not running",
|
|
258
|
+
data: buildStoppedStatusPayload(socketPath),
|
|
259
|
+
}, "daemon not running"),
|
|
260
|
+
"",
|
|
261
|
+
"daemon not running; run `ouro up`",
|
|
262
|
+
].join("\n");
|
|
263
|
+
}
|
|
264
|
+
function isDaemonUnavailableError(error) {
|
|
265
|
+
const code = typeof error === "object" && error !== null && "code" in error
|
|
266
|
+
? String(error.code ?? "")
|
|
267
|
+
: "";
|
|
268
|
+
return code === "ENOENT" || code === "ECONNREFUSED";
|
|
269
|
+
}
|
|
78
270
|
function parseMessageCommand(args) {
|
|
79
271
|
let to;
|
|
80
272
|
let sessionId;
|
|
@@ -433,7 +625,8 @@ function defaultListDiscoveredAgents() {
|
|
|
433
625
|
return discovered.sort((left, right) => left.localeCompare(right));
|
|
434
626
|
}
|
|
435
627
|
async function defaultLinkFriendIdentity(command) {
|
|
436
|
-
const
|
|
628
|
+
const fp = path.join((0, identity_1.getAgentBundlesRoot)(), `${command.agent}.ouro`, "friends");
|
|
629
|
+
const friendStore = new store_file_1.FileFriendStore(fp);
|
|
437
630
|
const current = await friendStore.get(command.friendId);
|
|
438
631
|
if (!current) {
|
|
439
632
|
return `friend not found: ${command.friendId}`;
|
|
@@ -457,6 +650,247 @@ async function defaultLinkFriendIdentity(command) {
|
|
|
457
650
|
});
|
|
458
651
|
return `linked ${command.provider}:${command.externalId} to ${command.friendId}`;
|
|
459
652
|
}
|
|
653
|
+
function discoverExistingCredentials(secretsRoot) {
|
|
654
|
+
const found = [];
|
|
655
|
+
let entries;
|
|
656
|
+
try {
|
|
657
|
+
entries = fs.readdirSync(secretsRoot, { withFileTypes: true });
|
|
658
|
+
}
|
|
659
|
+
catch {
|
|
660
|
+
return found;
|
|
661
|
+
}
|
|
662
|
+
for (const entry of entries) {
|
|
663
|
+
if (!entry.isDirectory())
|
|
664
|
+
continue;
|
|
665
|
+
const secretsPath = path.join(secretsRoot, entry.name, "secrets.json");
|
|
666
|
+
let raw;
|
|
667
|
+
try {
|
|
668
|
+
raw = fs.readFileSync(secretsPath, "utf-8");
|
|
669
|
+
}
|
|
670
|
+
catch {
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
let parsed;
|
|
674
|
+
try {
|
|
675
|
+
parsed = JSON.parse(raw);
|
|
676
|
+
}
|
|
677
|
+
catch {
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
if (!parsed.providers)
|
|
681
|
+
continue;
|
|
682
|
+
for (const [provName, provConfig] of Object.entries(parsed.providers)) {
|
|
683
|
+
if (provName === "anthropic" && provConfig.setupToken) {
|
|
684
|
+
found.push({ agentName: entry.name, provider: "anthropic", credentials: { setupToken: provConfig.setupToken }, providerConfig: { ...provConfig } });
|
|
685
|
+
}
|
|
686
|
+
else if (provName === "openai-codex" && provConfig.oauthAccessToken) {
|
|
687
|
+
found.push({ agentName: entry.name, provider: "openai-codex", credentials: { oauthAccessToken: provConfig.oauthAccessToken }, providerConfig: { ...provConfig } });
|
|
688
|
+
}
|
|
689
|
+
else if (provName === "minimax" && provConfig.apiKey) {
|
|
690
|
+
found.push({ agentName: entry.name, provider: "minimax", credentials: { apiKey: provConfig.apiKey }, providerConfig: { ...provConfig } });
|
|
691
|
+
}
|
|
692
|
+
else if (provName === "azure" && provConfig.apiKey && provConfig.endpoint && provConfig.deployment) {
|
|
693
|
+
found.push({ agentName: entry.name, provider: "azure", credentials: { apiKey: provConfig.apiKey, endpoint: provConfig.endpoint, deployment: provConfig.deployment }, providerConfig: { ...provConfig } });
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
// Deduplicate by provider+credential value (keep first seen)
|
|
698
|
+
const seen = new Set();
|
|
699
|
+
return found.filter((cred) => {
|
|
700
|
+
const key = `${cred.provider}:${JSON.stringify(cred.credentials)}`;
|
|
701
|
+
if (seen.has(key))
|
|
702
|
+
return false;
|
|
703
|
+
seen.add(key);
|
|
704
|
+
return true;
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
/* v8 ignore start -- integration: interactive terminal specialist session @preserve */
|
|
708
|
+
async function defaultRunAdoptionSpecialist() {
|
|
709
|
+
const { runCliSession } = await Promise.resolve().then(() => __importStar(require("../../senses/cli")));
|
|
710
|
+
const { patchRuntimeConfig } = await Promise.resolve().then(() => __importStar(require("../config")));
|
|
711
|
+
const { setAgentName, setAgentConfigOverride } = await Promise.resolve().then(() => __importStar(require("../identity")));
|
|
712
|
+
const readlinePromises = await Promise.resolve().then(() => __importStar(require("readline/promises")));
|
|
713
|
+
const crypto = await Promise.resolve().then(() => __importStar(require("crypto")));
|
|
714
|
+
// Phase 1: cold CLI — collect provider/credentials with a simple readline
|
|
715
|
+
const coldRl = readlinePromises.createInterface({ input: process.stdin, output: process.stdout });
|
|
716
|
+
const coldPrompt = async (q) => {
|
|
717
|
+
const answer = await coldRl.question(q);
|
|
718
|
+
return answer.trim();
|
|
719
|
+
};
|
|
720
|
+
let providerRaw;
|
|
721
|
+
let credentials = {};
|
|
722
|
+
let providerConfig = {};
|
|
723
|
+
const tempDir = path.join(os.tmpdir(), `ouro-hatch-${crypto.randomUUID()}`);
|
|
724
|
+
try {
|
|
725
|
+
const secretsRoot = path.join(os.homedir(), ".agentsecrets");
|
|
726
|
+
const discovered = discoverExistingCredentials(secretsRoot);
|
|
727
|
+
const existingBundleCount = (0, specialist_orchestrator_1.listExistingBundles)((0, identity_1.getAgentBundlesRoot)()).length;
|
|
728
|
+
const hatchVerb = existingBundleCount > 0 ? "let's hatch a new agent." : "let's hatch your first agent.";
|
|
729
|
+
// Default models per provider (used when entering new credentials)
|
|
730
|
+
const defaultModels = {
|
|
731
|
+
anthropic: "claude-opus-4-6",
|
|
732
|
+
minimax: "MiniMax-Text-01",
|
|
733
|
+
"openai-codex": "gpt-5.4",
|
|
734
|
+
azure: "",
|
|
735
|
+
};
|
|
736
|
+
if (discovered.length > 0) {
|
|
737
|
+
process.stdout.write(`\n\ud83d\udc0d welcome to ouroboros! ${hatchVerb}\n`);
|
|
738
|
+
process.stdout.write("i found existing API credentials:\n\n");
|
|
739
|
+
const unique = [...new Map(discovered.map((d) => [`${d.provider}`, d])).values()];
|
|
740
|
+
for (let i = 0; i < unique.length; i++) {
|
|
741
|
+
const model = unique[i].providerConfig.model || unique[i].providerConfig.deployment || "";
|
|
742
|
+
const modelLabel = model ? `, ${model}` : "";
|
|
743
|
+
process.stdout.write(` ${i + 1}. ${unique[i].provider}${modelLabel} (from ${unique[i].agentName})\n`);
|
|
744
|
+
}
|
|
745
|
+
process.stdout.write("\n");
|
|
746
|
+
const choice = await coldPrompt("use one of these? enter number, or 'new' for a different key: ");
|
|
747
|
+
const idx = parseInt(choice, 10) - 1;
|
|
748
|
+
if (idx >= 0 && idx < unique.length) {
|
|
749
|
+
providerRaw = unique[idx].provider;
|
|
750
|
+
credentials = unique[idx].credentials;
|
|
751
|
+
providerConfig = unique[idx].providerConfig;
|
|
752
|
+
}
|
|
753
|
+
else {
|
|
754
|
+
const pRaw = await coldPrompt("provider (anthropic/azure/minimax/openai-codex): ");
|
|
755
|
+
if (!isAgentProvider(pRaw)) {
|
|
756
|
+
process.stdout.write("unknown provider. run `ouro hatch` to try again.\n");
|
|
757
|
+
coldRl.close();
|
|
758
|
+
return null;
|
|
759
|
+
}
|
|
760
|
+
providerRaw = pRaw;
|
|
761
|
+
providerConfig = { model: defaultModels[providerRaw] };
|
|
762
|
+
if (providerRaw === "anthropic")
|
|
763
|
+
credentials.setupToken = await coldPrompt("API key: ");
|
|
764
|
+
if (providerRaw === "openai-codex")
|
|
765
|
+
credentials.oauthAccessToken = await coldPrompt("OAuth token: ");
|
|
766
|
+
if (providerRaw === "minimax")
|
|
767
|
+
credentials.apiKey = await coldPrompt("API key: ");
|
|
768
|
+
if (providerRaw === "azure") {
|
|
769
|
+
credentials.apiKey = await coldPrompt("API key: ");
|
|
770
|
+
credentials.endpoint = await coldPrompt("endpoint: ");
|
|
771
|
+
credentials.deployment = await coldPrompt("deployment: ");
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
else {
|
|
776
|
+
process.stdout.write(`\n\ud83d\udc0d welcome to ouroboros! ${hatchVerb}\n`);
|
|
777
|
+
process.stdout.write("i need an API key to power our conversation.\n\n");
|
|
778
|
+
const pRaw = await coldPrompt("provider (anthropic/azure/minimax/openai-codex): ");
|
|
779
|
+
if (!isAgentProvider(pRaw)) {
|
|
780
|
+
process.stdout.write("unknown provider. run `ouro hatch` to try again.\n");
|
|
781
|
+
coldRl.close();
|
|
782
|
+
return null;
|
|
783
|
+
}
|
|
784
|
+
providerRaw = pRaw;
|
|
785
|
+
providerConfig = { model: defaultModels[providerRaw] };
|
|
786
|
+
if (providerRaw === "anthropic")
|
|
787
|
+
credentials.setupToken = await coldPrompt("API key: ");
|
|
788
|
+
if (providerRaw === "openai-codex")
|
|
789
|
+
credentials.oauthAccessToken = await coldPrompt("OAuth token: ");
|
|
790
|
+
if (providerRaw === "minimax")
|
|
791
|
+
credentials.apiKey = await coldPrompt("API key: ");
|
|
792
|
+
if (providerRaw === "azure") {
|
|
793
|
+
credentials.apiKey = await coldPrompt("API key: ");
|
|
794
|
+
credentials.endpoint = await coldPrompt("endpoint: ");
|
|
795
|
+
credentials.deployment = await coldPrompt("deployment: ");
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
coldRl.close();
|
|
799
|
+
process.stdout.write("\n");
|
|
800
|
+
// Phase 2: configure runtime for adoption specialist
|
|
801
|
+
const bundleSourceDir = path.resolve(__dirname, "..", "..", "..", "AdoptionSpecialist.ouro");
|
|
802
|
+
const bundlesRoot = (0, identity_1.getAgentBundlesRoot)();
|
|
803
|
+
const secretsRoot2 = path.join(os.homedir(), ".agentsecrets");
|
|
804
|
+
// Suppress non-critical log noise during adoption (no secrets.json, etc.)
|
|
805
|
+
const { setRuntimeLogger } = await Promise.resolve().then(() => __importStar(require("../../nerves/runtime")));
|
|
806
|
+
const { createLogger } = await Promise.resolve().then(() => __importStar(require("../../nerves")));
|
|
807
|
+
setRuntimeLogger(createLogger({ level: "error" }));
|
|
808
|
+
// Configure runtime: set agent identity + config override so runAgent
|
|
809
|
+
// doesn't try to read from ~/AgentBundles/AdoptionSpecialist.ouro/
|
|
810
|
+
setAgentName("AdoptionSpecialist");
|
|
811
|
+
// Build specialist system prompt
|
|
812
|
+
const soulText = (0, specialist_orchestrator_1.loadSoulText)(bundleSourceDir);
|
|
813
|
+
const identitiesDir = path.join(bundleSourceDir, "psyche", "identities");
|
|
814
|
+
const identity = (0, specialist_orchestrator_1.pickRandomIdentity)(identitiesDir);
|
|
815
|
+
// Load identity-specific spinner phrases (falls back to DEFAULT_AGENT_PHRASES)
|
|
816
|
+
const { loadIdentityPhrases } = await Promise.resolve().then(() => __importStar(require("./specialist-orchestrator")));
|
|
817
|
+
const phrases = loadIdentityPhrases(bundleSourceDir, identity.fileName);
|
|
818
|
+
setAgentConfigOverride({
|
|
819
|
+
version: 1,
|
|
820
|
+
enabled: true,
|
|
821
|
+
provider: providerRaw,
|
|
822
|
+
phrases,
|
|
823
|
+
});
|
|
824
|
+
patchRuntimeConfig({
|
|
825
|
+
providers: {
|
|
826
|
+
[providerRaw]: { ...providerConfig, ...credentials },
|
|
827
|
+
},
|
|
828
|
+
});
|
|
829
|
+
const existingBundles = (0, specialist_orchestrator_1.listExistingBundles)(bundlesRoot);
|
|
830
|
+
const systemPrompt = (0, specialist_prompt_1.buildSpecialistSystemPrompt)(soulText, identity.content, existingBundles, {
|
|
831
|
+
tempDir,
|
|
832
|
+
provider: providerRaw,
|
|
833
|
+
});
|
|
834
|
+
// Build specialist tools
|
|
835
|
+
const specialistTools = (0, specialist_tools_1.getSpecialistTools)();
|
|
836
|
+
const specialistExecTool = (0, specialist_tools_1.createSpecialistExecTool)({
|
|
837
|
+
tempDir,
|
|
838
|
+
credentials,
|
|
839
|
+
provider: providerRaw,
|
|
840
|
+
bundlesRoot,
|
|
841
|
+
secretsRoot: secretsRoot2,
|
|
842
|
+
animationWriter: (text) => process.stdout.write(text),
|
|
843
|
+
});
|
|
844
|
+
// Run the adoption specialist session via runCliSession
|
|
845
|
+
const result = await runCliSession({
|
|
846
|
+
agentName: "AdoptionSpecialist",
|
|
847
|
+
tools: specialistTools,
|
|
848
|
+
execTool: specialistExecTool,
|
|
849
|
+
exitOnToolCall: "complete_adoption",
|
|
850
|
+
autoFirstTurn: true,
|
|
851
|
+
banner: false,
|
|
852
|
+
disableCommands: true,
|
|
853
|
+
skipSystemPromptRefresh: true,
|
|
854
|
+
messages: [
|
|
855
|
+
{ role: "system", content: systemPrompt },
|
|
856
|
+
{ role: "user", content: "hi" },
|
|
857
|
+
],
|
|
858
|
+
});
|
|
859
|
+
if (result.exitReason === "tool_exit" && result.toolResult) {
|
|
860
|
+
const parsed = typeof result.toolResult === "string" ? JSON.parse(result.toolResult) : result.toolResult;
|
|
861
|
+
if (parsed.success && parsed.agentName) {
|
|
862
|
+
return parsed.agentName;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
return null;
|
|
866
|
+
}
|
|
867
|
+
catch (err) {
|
|
868
|
+
process.stderr.write(`\nouro adoption error: ${err instanceof Error ? err.stack ?? err.message : String(err)}\n`);
|
|
869
|
+
coldRl.close();
|
|
870
|
+
return null;
|
|
871
|
+
}
|
|
872
|
+
finally {
|
|
873
|
+
// Clear specialist config/identity so the hatched agent gets its own
|
|
874
|
+
setAgentConfigOverride(null);
|
|
875
|
+
const { resetProviderRuntime } = await Promise.resolve().then(() => __importStar(require("../core")));
|
|
876
|
+
resetProviderRuntime();
|
|
877
|
+
const { resetConfigCache } = await Promise.resolve().then(() => __importStar(require("../config")));
|
|
878
|
+
resetConfigCache();
|
|
879
|
+
// Restore default logging
|
|
880
|
+
const { setRuntimeLogger: restoreLogger } = await Promise.resolve().then(() => __importStar(require("../../nerves/runtime")));
|
|
881
|
+
restoreLogger(null);
|
|
882
|
+
// Clean up temp dir if it still exists
|
|
883
|
+
try {
|
|
884
|
+
if (fs.existsSync(tempDir)) {
|
|
885
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
catch {
|
|
889
|
+
// Best effort cleanup
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
/* v8 ignore stop */
|
|
460
894
|
function createDefaultOuroCliDeps(socketPath = "/tmp/ouroboros-daemon.sock") {
|
|
461
895
|
return {
|
|
462
896
|
socketPath,
|
|
@@ -471,7 +905,9 @@ function createDefaultOuroCliDeps(socketPath = "/tmp/ouroboros-daemon.sock") {
|
|
|
471
905
|
listDiscoveredAgents: defaultListDiscoveredAgents,
|
|
472
906
|
runHatchFlow: hatch_flow_1.runHatchFlow,
|
|
473
907
|
promptInput: defaultPromptInput,
|
|
908
|
+
runAdoptionSpecialist: defaultRunAdoptionSpecialist,
|
|
474
909
|
registerOuroBundleType: ouro_uti_1.registerOuroBundleUti,
|
|
910
|
+
installOuroCommand: ouro_path_installer_1.installOuroCommand,
|
|
475
911
|
/* v8 ignore next 3 -- integration: launches interactive CLI session @preserve */
|
|
476
912
|
startChat: async (agentName) => {
|
|
477
913
|
const { main } = await Promise.resolve().then(() => __importStar(require("../../senses/cli")));
|
|
@@ -533,12 +969,49 @@ async function registerOuroBundleTypeNonBlocking(deps) {
|
|
|
533
969
|
});
|
|
534
970
|
}
|
|
535
971
|
}
|
|
972
|
+
async function performSystemSetup(deps) {
|
|
973
|
+
// Install ouro command to PATH (non-blocking)
|
|
974
|
+
if (deps.installOuroCommand) {
|
|
975
|
+
try {
|
|
976
|
+
deps.installOuroCommand();
|
|
977
|
+
}
|
|
978
|
+
catch (error) {
|
|
979
|
+
(0, runtime_1.emitNervesEvent)({
|
|
980
|
+
level: "warn",
|
|
981
|
+
component: "daemon",
|
|
982
|
+
event: "daemon.system_setup_ouro_cmd_error",
|
|
983
|
+
message: "failed to install ouro command to PATH",
|
|
984
|
+
meta: { error: error instanceof Error ? error.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(error) },
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
// Install subagents (claude/codex skills)
|
|
989
|
+
try {
|
|
990
|
+
await deps.installSubagents();
|
|
991
|
+
}
|
|
992
|
+
catch (error) {
|
|
993
|
+
(0, runtime_1.emitNervesEvent)({
|
|
994
|
+
level: "warn",
|
|
995
|
+
component: "daemon",
|
|
996
|
+
event: "daemon.subagent_install_error",
|
|
997
|
+
message: "subagent auto-install failed",
|
|
998
|
+
meta: { error: error instanceof Error ? error.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(error) },
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
// Register .ouro bundle type (UTI on macOS)
|
|
1002
|
+
await registerOuroBundleTypeNonBlocking(deps);
|
|
1003
|
+
}
|
|
536
1004
|
async function runOuroCli(args, deps = createDefaultOuroCliDeps()) {
|
|
537
1005
|
if (args.includes("--help") || args.includes("-h")) {
|
|
538
1006
|
const text = usage();
|
|
539
1007
|
deps.writeStdout(text);
|
|
540
1008
|
return text;
|
|
541
1009
|
}
|
|
1010
|
+
if (args.length === 1 && (args[0] === "-v" || args[0] === "--version")) {
|
|
1011
|
+
const text = formatVersionOutput();
|
|
1012
|
+
deps.writeStdout(text);
|
|
1013
|
+
return text;
|
|
1014
|
+
}
|
|
542
1015
|
let command;
|
|
543
1016
|
try {
|
|
544
1017
|
command = parseOuroCommand(args);
|
|
@@ -556,7 +1029,20 @@ async function runOuroCli(args, deps = createDefaultOuroCliDeps()) {
|
|
|
556
1029
|
}
|
|
557
1030
|
if (args.length === 0) {
|
|
558
1031
|
const discovered = await Promise.resolve(deps.listDiscoveredAgents ? deps.listDiscoveredAgents() : defaultListDiscoveredAgents());
|
|
559
|
-
if (discovered.length === 0) {
|
|
1032
|
+
if (discovered.length === 0 && deps.runAdoptionSpecialist) {
|
|
1033
|
+
// System setup first — ouro command, subagents, UTI — before the interactive specialist
|
|
1034
|
+
await performSystemSetup(deps);
|
|
1035
|
+
const hatchlingName = await deps.runAdoptionSpecialist();
|
|
1036
|
+
if (!hatchlingName) {
|
|
1037
|
+
return "";
|
|
1038
|
+
}
|
|
1039
|
+
await ensureDaemonRunning(deps);
|
|
1040
|
+
if (deps.startChat) {
|
|
1041
|
+
await deps.startChat(hatchlingName);
|
|
1042
|
+
}
|
|
1043
|
+
return "";
|
|
1044
|
+
}
|
|
1045
|
+
else if (discovered.length === 0) {
|
|
560
1046
|
command = { kind: "hatch.start" };
|
|
561
1047
|
}
|
|
562
1048
|
else if (discovered.length === 1) {
|
|
@@ -596,19 +1082,7 @@ async function runOuroCli(args, deps = createDefaultOuroCliDeps()) {
|
|
|
596
1082
|
meta: { kind: command.kind },
|
|
597
1083
|
});
|
|
598
1084
|
if (command.kind === "daemon.up") {
|
|
599
|
-
|
|
600
|
-
await deps.installSubagents();
|
|
601
|
-
}
|
|
602
|
-
catch (error) {
|
|
603
|
-
(0, runtime_1.emitNervesEvent)({
|
|
604
|
-
level: "warn",
|
|
605
|
-
component: "daemon",
|
|
606
|
-
event: "daemon.subagent_install_error",
|
|
607
|
-
message: "subagent auto-install failed",
|
|
608
|
-
meta: { error: error instanceof Error ? error.message : String(error) },
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
await registerOuroBundleTypeNonBlocking(deps);
|
|
1085
|
+
await performSystemSetup(deps);
|
|
612
1086
|
const daemonResult = await ensureDaemonRunning(deps);
|
|
613
1087
|
deps.writeStdout(daemonResult.message);
|
|
614
1088
|
return daemonResult.message;
|
|
@@ -624,6 +1098,21 @@ async function runOuroCli(args, deps = createDefaultOuroCliDeps()) {
|
|
|
624
1098
|
return message;
|
|
625
1099
|
}
|
|
626
1100
|
if (command.kind === "hatch.start") {
|
|
1101
|
+
// Route through adoption specialist when no explicit hatch args were provided
|
|
1102
|
+
const hasExplicitHatchArgs = !!(command.agentName || command.humanName || command.provider || command.credentials);
|
|
1103
|
+
if (deps.runAdoptionSpecialist && !hasExplicitHatchArgs) {
|
|
1104
|
+
// System setup first — ouro command, subagents, UTI — before the interactive specialist
|
|
1105
|
+
await performSystemSetup(deps);
|
|
1106
|
+
const hatchlingName = await deps.runAdoptionSpecialist();
|
|
1107
|
+
if (!hatchlingName) {
|
|
1108
|
+
return "";
|
|
1109
|
+
}
|
|
1110
|
+
await ensureDaemonRunning(deps);
|
|
1111
|
+
if (deps.startChat) {
|
|
1112
|
+
await deps.startChat(hatchlingName);
|
|
1113
|
+
}
|
|
1114
|
+
return "";
|
|
1115
|
+
}
|
|
627
1116
|
const hatchRunner = deps.runHatchFlow;
|
|
628
1117
|
if (!hatchRunner) {
|
|
629
1118
|
const response = await deps.sendCommand(deps.socketPath, { kind: "hatch.start" });
|
|
@@ -633,19 +1122,7 @@ async function runOuroCli(args, deps = createDefaultOuroCliDeps()) {
|
|
|
633
1122
|
}
|
|
634
1123
|
const hatchInput = await resolveHatchInput(command, deps);
|
|
635
1124
|
const result = await hatchRunner(hatchInput);
|
|
636
|
-
|
|
637
|
-
await deps.installSubagents();
|
|
638
|
-
}
|
|
639
|
-
catch (error) {
|
|
640
|
-
(0, runtime_1.emitNervesEvent)({
|
|
641
|
-
level: "warn",
|
|
642
|
-
component: "daemon",
|
|
643
|
-
event: "daemon.subagent_install_error",
|
|
644
|
-
message: "subagent auto-install failed",
|
|
645
|
-
meta: { error: error instanceof Error ? error.message : String(error) },
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
await registerOuroBundleTypeNonBlocking(deps);
|
|
1125
|
+
await performSystemSetup(deps);
|
|
649
1126
|
const daemonResult = await ensureDaemonRunning(deps);
|
|
650
1127
|
if (deps.startChat) {
|
|
651
1128
|
await deps.startChat(hatchInput.agentName);
|
|
@@ -667,9 +1144,22 @@ async function runOuroCli(args, deps = createDefaultOuroCliDeps()) {
|
|
|
667
1144
|
deps.writeStdout(message);
|
|
668
1145
|
return message;
|
|
669
1146
|
}
|
|
1147
|
+
if (command.kind === "daemon.status" && isDaemonUnavailableError(error)) {
|
|
1148
|
+
const message = daemonUnavailableStatusOutput(deps.socketPath);
|
|
1149
|
+
deps.writeStdout(message);
|
|
1150
|
+
return message;
|
|
1151
|
+
}
|
|
1152
|
+
if (command.kind === "daemon.stop" && isDaemonUnavailableError(error)) {
|
|
1153
|
+
const message = "daemon not running";
|
|
1154
|
+
deps.writeStdout(message);
|
|
1155
|
+
return message;
|
|
1156
|
+
}
|
|
670
1157
|
throw error;
|
|
671
1158
|
}
|
|
672
|
-
const
|
|
1159
|
+
const fallbackMessage = response.summary ?? response.message ?? (response.ok ? "ok" : `error: ${response.error ?? "unknown error"}`);
|
|
1160
|
+
const message = command.kind === "daemon.status"
|
|
1161
|
+
? formatDaemonStatusOutput(response, fallbackMessage)
|
|
1162
|
+
: fallbackMessage;
|
|
673
1163
|
deps.writeStdout(message);
|
|
674
1164
|
return message;
|
|
675
1165
|
}
|