@ouro.bot/cli 0.1.0-alpha.5 → 0.1.0-alpha.50

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.
Files changed (102) hide show
  1. package/AdoptionSpecialist.ouro/agent.json +70 -9
  2. package/AdoptionSpecialist.ouro/psyche/SOUL.md +5 -2
  3. package/AdoptionSpecialist.ouro/psyche/identities/monty.md +2 -2
  4. package/README.md +117 -188
  5. package/assets/ouroboros.png +0 -0
  6. package/changelog.json +242 -0
  7. package/dist/heart/active-work.js +157 -0
  8. package/dist/heart/bridges/manager.js +358 -0
  9. package/dist/heart/bridges/state-machine.js +135 -0
  10. package/dist/heart/bridges/store.js +123 -0
  11. package/dist/heart/config.js +81 -8
  12. package/dist/heart/core.js +145 -50
  13. package/dist/heart/daemon/agent-discovery.js +81 -0
  14. package/dist/heart/daemon/daemon-cli.js +1099 -164
  15. package/dist/heart/daemon/daemon-entry.js +14 -5
  16. package/dist/heart/daemon/daemon-runtime-sync.js +90 -0
  17. package/dist/heart/daemon/daemon.js +184 -9
  18. package/dist/heart/daemon/hatch-animation.js +10 -3
  19. package/dist/heart/daemon/hatch-flow.js +3 -20
  20. package/dist/heart/daemon/hooks/bundle-meta.js +92 -0
  21. package/dist/heart/daemon/launchd.js +151 -0
  22. package/dist/heart/daemon/message-router.js +15 -6
  23. package/dist/heart/daemon/ouro-bot-entry.js +0 -0
  24. package/dist/heart/daemon/ouro-bot-global-installer.js +128 -0
  25. package/dist/heart/daemon/ouro-entry.js +0 -0
  26. package/dist/heart/daemon/ouro-path-installer.js +178 -0
  27. package/dist/heart/daemon/ouro-uti.js +11 -2
  28. package/dist/heart/daemon/process-manager.js +1 -1
  29. package/dist/heart/daemon/run-hooks.js +37 -0
  30. package/dist/heart/daemon/runtime-metadata.js +118 -0
  31. package/dist/heart/daemon/sense-manager.js +290 -0
  32. package/dist/heart/daemon/socket-client.js +202 -0
  33. package/dist/heart/daemon/specialist-orchestrator.js +53 -84
  34. package/dist/heart/daemon/specialist-prompt.js +64 -5
  35. package/dist/heart/daemon/specialist-tools.js +213 -58
  36. package/dist/heart/daemon/staged-restart.js +114 -0
  37. package/dist/heart/daemon/subagent-installer.js +48 -7
  38. package/dist/heart/daemon/thoughts.js +379 -0
  39. package/dist/heart/daemon/update-checker.js +111 -0
  40. package/dist/heart/daemon/update-hooks.js +138 -0
  41. package/dist/heart/daemon/wrapper-publish-guard.js +86 -0
  42. package/dist/heart/delegation.js +62 -0
  43. package/dist/heart/identity.js +82 -4
  44. package/dist/heart/kicks.js +1 -19
  45. package/dist/heart/progress-story.js +42 -0
  46. package/dist/heart/providers/anthropic.js +16 -2
  47. package/dist/heart/sense-truth.js +61 -0
  48. package/dist/heart/session-activity.js +169 -0
  49. package/dist/heart/session-recall.js +116 -0
  50. package/dist/heart/streaming.js +96 -21
  51. package/dist/heart/turn-coordinator.js +28 -0
  52. package/dist/mind/associative-recall.js +14 -2
  53. package/dist/mind/bundle-manifest.js +70 -0
  54. package/dist/mind/context.js +27 -11
  55. package/dist/mind/first-impressions.js +16 -2
  56. package/dist/mind/friends/channel.js +43 -0
  57. package/dist/mind/friends/store-file.js +19 -0
  58. package/dist/mind/friends/types.js +9 -1
  59. package/dist/mind/memory.js +10 -3
  60. package/dist/mind/pending.js +72 -9
  61. package/dist/mind/phrases.js +1 -0
  62. package/dist/mind/prompt.js +266 -77
  63. package/dist/mind/token-estimate.js +8 -12
  64. package/dist/nerves/cli-logging.js +15 -2
  65. package/dist/repertoire/ado-client.js +4 -2
  66. package/dist/repertoire/coding/feedback.js +134 -0
  67. package/dist/repertoire/coding/index.js +4 -1
  68. package/dist/repertoire/coding/manager.js +62 -4
  69. package/dist/repertoire/coding/spawner.js +3 -3
  70. package/dist/repertoire/coding/tools.js +41 -2
  71. package/dist/repertoire/data/ado-endpoints.json +188 -0
  72. package/dist/repertoire/tasks/board.js +12 -0
  73. package/dist/repertoire/tasks/index.js +23 -9
  74. package/dist/repertoire/tasks/transitions.js +1 -2
  75. package/dist/repertoire/tools-base.js +462 -245
  76. package/dist/repertoire/tools-bluebubbles.js +93 -0
  77. package/dist/repertoire/tools-teams.js +58 -25
  78. package/dist/repertoire/tools.js +57 -35
  79. package/dist/senses/bluebubbles-client.js +484 -0
  80. package/dist/senses/bluebubbles-entry.js +13 -0
  81. package/dist/senses/bluebubbles-inbound-log.js +109 -0
  82. package/dist/senses/bluebubbles-media.js +338 -0
  83. package/dist/senses/bluebubbles-model.js +261 -0
  84. package/dist/senses/bluebubbles-mutation-log.js +116 -0
  85. package/dist/senses/bluebubbles-runtime-state.js +109 -0
  86. package/dist/senses/bluebubbles-session-cleanup.js +72 -0
  87. package/dist/senses/bluebubbles.js +1142 -0
  88. package/dist/senses/cli.js +340 -138
  89. package/dist/senses/continuity.js +94 -0
  90. package/dist/senses/debug-activity.js +148 -0
  91. package/dist/senses/inner-dialog-worker.js +47 -18
  92. package/dist/senses/inner-dialog.js +330 -84
  93. package/dist/senses/pipeline.js +256 -0
  94. package/dist/senses/teams.js +541 -129
  95. package/dist/senses/trust-gate.js +112 -2
  96. package/package.json +14 -3
  97. package/subagents/README.md +46 -33
  98. package/subagents/work-doer.md +28 -24
  99. package/subagents/work-merger.md +24 -30
  100. package/subagents/work-planner.md +44 -27
  101. package/dist/heart/daemon/specialist-session.js +0 -142
  102. package/dist/inner-worker-entry.js +0 -4
@@ -8,6 +8,8 @@ const message_router_1 = require("./message-router");
8
8
  const health_monitor_1 = require("./health-monitor");
9
9
  const task_scheduler_1 = require("./task-scheduler");
10
10
  const runtime_logging_1 = require("./runtime-logging");
11
+ const sense_manager_1 = require("./sense-manager");
12
+ const agent_discovery_1 = require("./agent-discovery");
11
13
  function parseSocketPath(argv) {
12
14
  const socketIndex = argv.indexOf("--socket");
13
15
  if (socketIndex >= 0) {
@@ -25,16 +27,22 @@ const socketPath = parseSocketPath(process.argv);
25
27
  message: "starting daemon entrypoint",
26
28
  meta: { socketPath },
27
29
  });
30
+ const managedAgents = (0, agent_discovery_1.listEnabledBundleAgents)();
28
31
  const processManager = new process_manager_1.DaemonProcessManager({
29
- agents: [
30
- { name: "ouroboros", entry: "heart/agent-entry.js", channel: "cli", autoStart: true },
31
- { name: "slugger", entry: "heart/agent-entry.js", channel: "cli", autoStart: true },
32
- ],
32
+ agents: managedAgents.map((agent) => ({
33
+ name: agent,
34
+ entry: "heart/agent-entry.js",
35
+ channel: "inner-dialog",
36
+ autoStart: true,
37
+ })),
33
38
  });
34
39
  const scheduler = new task_scheduler_1.TaskDrivenScheduler({
35
- agents: ["ouroboros", "slugger"],
40
+ agents: [...managedAgents],
36
41
  });
37
42
  const router = new message_router_1.FileMessageRouter();
43
+ const senseManager = new sense_manager_1.DaemonSenseManager({
44
+ agents: [...managedAgents],
45
+ });
38
46
  const healthMonitor = new health_monitor_1.HealthMonitor({
39
47
  processManager,
40
48
  scheduler,
@@ -51,6 +59,7 @@ const healthMonitor = new health_monitor_1.HealthMonitor({
51
59
  const daemon = new daemon_1.OuroDaemon({
52
60
  socketPath,
53
61
  processManager,
62
+ senseManager,
54
63
  scheduler,
55
64
  healthMonitor,
56
65
  router,
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensureCurrentDaemonRuntime = ensureCurrentDaemonRuntime;
4
+ const runtime_1 = require("../../nerves/runtime");
5
+ function isKnownVersion(version) {
6
+ return version !== "unknown" && version.trim().length > 0;
7
+ }
8
+ function formatErrorReason(error) {
9
+ return error instanceof Error ? error.message : String(error);
10
+ }
11
+ async function ensureCurrentDaemonRuntime(deps) {
12
+ try {
13
+ const runningVersion = await deps.fetchRunningVersion();
14
+ let result;
15
+ if (isKnownVersion(deps.localVersion) &&
16
+ isKnownVersion(runningVersion) &&
17
+ runningVersion !== deps.localVersion) {
18
+ try {
19
+ await deps.stopDaemon();
20
+ }
21
+ catch (error) {
22
+ const reason = formatErrorReason(error);
23
+ result = {
24
+ alreadyRunning: true,
25
+ message: `daemon already running (${deps.socketPath}; could not replace stale daemon ${runningVersion} -> ${deps.localVersion}: ${reason})`,
26
+ };
27
+ (0, runtime_1.emitNervesEvent)({
28
+ level: "warn",
29
+ component: "daemon",
30
+ event: "daemon.runtime_sync_decision",
31
+ message: "evaluated daemon runtime sync outcome",
32
+ meta: { socketPath: deps.socketPath, localVersion: deps.localVersion, runningVersion, action: "stale_replace_failed", reason },
33
+ });
34
+ return result;
35
+ }
36
+ deps.cleanupStaleSocket(deps.socketPath);
37
+ const started = await deps.startDaemonProcess(deps.socketPath);
38
+ result = {
39
+ alreadyRunning: false,
40
+ message: `restarted stale daemon from ${runningVersion} to ${deps.localVersion} (pid ${started.pid ?? "unknown"})`,
41
+ };
42
+ (0, runtime_1.emitNervesEvent)({
43
+ component: "daemon",
44
+ event: "daemon.runtime_sync_decision",
45
+ message: "evaluated daemon runtime sync outcome",
46
+ meta: { socketPath: deps.socketPath, localVersion: deps.localVersion, runningVersion, action: "stale_restarted", pid: started.pid ?? null },
47
+ });
48
+ return result;
49
+ }
50
+ if (!isKnownVersion(deps.localVersion) || !isKnownVersion(runningVersion)) {
51
+ result = {
52
+ alreadyRunning: true,
53
+ message: `daemon already running (${deps.socketPath}; unable to verify version)`,
54
+ };
55
+ (0, runtime_1.emitNervesEvent)({
56
+ component: "daemon",
57
+ event: "daemon.runtime_sync_decision",
58
+ message: "evaluated daemon runtime sync outcome",
59
+ meta: { socketPath: deps.socketPath, localVersion: deps.localVersion, runningVersion, action: "unknown_version" },
60
+ });
61
+ return result;
62
+ }
63
+ }
64
+ catch (error) {
65
+ const reason = formatErrorReason(error);
66
+ const result = {
67
+ alreadyRunning: true,
68
+ message: `daemon already running (${deps.socketPath}; unable to verify version: ${reason})`,
69
+ };
70
+ (0, runtime_1.emitNervesEvent)({
71
+ level: "warn",
72
+ component: "daemon",
73
+ event: "daemon.runtime_sync_decision",
74
+ message: "evaluated daemon runtime sync outcome",
75
+ meta: { socketPath: deps.socketPath, localVersion: deps.localVersion, action: "status_lookup_failed", reason },
76
+ });
77
+ return result;
78
+ }
79
+ const result = {
80
+ alreadyRunning: true,
81
+ message: `daemon already running (${deps.socketPath})`,
82
+ };
83
+ (0, runtime_1.emitNervesEvent)({
84
+ component: "daemon",
85
+ event: "daemon.runtime_sync_decision",
86
+ message: "evaluated daemon runtime sync outcome",
87
+ meta: { socketPath: deps.socketPath, localVersion: deps.localVersion, action: "already_current" },
88
+ });
89
+ return result;
90
+ }
@@ -39,14 +39,37 @@ const net = __importStar(require("net"));
39
39
  const path = __importStar(require("path"));
40
40
  const identity_1 = require("../identity");
41
41
  const runtime_1 = require("../../nerves/runtime");
42
- function formatStatusSummary(snapshots) {
43
- if (snapshots.length === 0)
42
+ const runtime_metadata_1 = require("./runtime-metadata");
43
+ const update_hooks_1 = require("./update-hooks");
44
+ const bundle_meta_1 = require("./hooks/bundle-meta");
45
+ const bundle_manifest_1 = require("../../mind/bundle-manifest");
46
+ const update_checker_1 = require("./update-checker");
47
+ const staged_restart_1 = require("./staged-restart");
48
+ const child_process_1 = require("child_process");
49
+ const pending_1 = require("../../mind/pending");
50
+ const channel_1 = require("../../mind/friends/channel");
51
+ function buildWorkerRows(snapshots) {
52
+ return snapshots.map((snapshot) => ({
53
+ agent: snapshot.name,
54
+ worker: snapshot.channel,
55
+ status: snapshot.status,
56
+ pid: snapshot.pid,
57
+ restartCount: snapshot.restartCount,
58
+ startedAt: snapshot.startedAt,
59
+ }));
60
+ }
61
+ function formatStatusSummary(payload) {
62
+ if (payload.overview.workerCount === 0 && payload.overview.senseCount === 0) {
44
63
  return "no managed agents";
45
- return snapshots
46
- .map((snapshot) => {
47
- return `${snapshot.name}\t${snapshot.channel}\t${snapshot.status}\tpid=${snapshot.pid ?? "none"}\trestarts=${snapshot.restartCount}`;
48
- })
49
- .join("\n");
64
+ }
65
+ const rows = [
66
+ ...payload.workers.map((row) => `${row.agent}/${row.worker}:${row.status}`),
67
+ ...payload.senses
68
+ .filter((row) => row.enabled)
69
+ .map((row) => `${row.agent}/${row.sense}:${row.status}`),
70
+ ];
71
+ const detail = rows.length > 0 ? `\titems=${rows.join(",")}` : "";
72
+ return `daemon=${payload.overview.daemon}\tworkers=${payload.overview.workerCount}\tsenses=${payload.overview.senseCount}\thealth=${payload.overview.health}${detail}`;
50
73
  }
51
74
  function parseIncomingCommand(raw) {
52
75
  let parsed;
@@ -71,6 +94,7 @@ class OuroDaemon {
71
94
  scheduler;
72
95
  healthMonitor;
73
96
  router;
97
+ senseManager;
74
98
  bundlesRoot;
75
99
  server = null;
76
100
  constructor(options) {
@@ -79,6 +103,7 @@ class OuroDaemon {
79
103
  this.scheduler = options.scheduler;
80
104
  this.healthMonitor = options.healthMonitor;
81
105
  this.router = options.router;
106
+ this.senseManager = options.senseManager ?? null;
82
107
  this.bundlesRoot = options.bundlesRoot ?? (0, identity_1.getAgentBundlesRoot)();
83
108
  }
84
109
  async start() {
@@ -90,10 +115,50 @@ class OuroDaemon {
90
115
  message: "starting daemon server",
91
116
  meta: { socketPath: this.socketPath },
92
117
  });
118
+ // Register update hooks and apply pending updates before starting agents
119
+ (0, update_hooks_1.registerUpdateHook)(bundle_meta_1.bundleMetaHook);
120
+ const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
121
+ await (0, update_hooks_1.applyPendingUpdates)(this.bundlesRoot, currentVersion);
122
+ // Start periodic update checker (polls npm registry every 30 minutes)
123
+ const bundlesRoot = this.bundlesRoot;
124
+ const daemon = this;
125
+ (0, update_checker_1.startUpdateChecker)({
126
+ currentVersion,
127
+ deps: {
128
+ distTag: "alpha",
129
+ fetchRegistryJson: /* v8 ignore next -- integration: real HTTP fetch @preserve */ async () => {
130
+ const res = await fetch("https://registry.npmjs.org/@ouro.bot/cli");
131
+ return res.json();
132
+ },
133
+ },
134
+ onUpdate: /* v8 ignore start -- integration: real npm install + process spawn @preserve */ async (result) => {
135
+ if (!result.latestVersion)
136
+ return;
137
+ await (0, staged_restart_1.performStagedRestart)(result.latestVersion, {
138
+ execSync: (cmd) => (0, child_process_1.execSync)(cmd, { stdio: "inherit" }),
139
+ spawnSync: child_process_1.spawnSync,
140
+ resolveNewCodePath: (_version) => {
141
+ try {
142
+ const resolved = (0, child_process_1.execSync)(`node -e "console.log(require.resolve('@ouro.bot/cli/package.json'))"`, { encoding: "utf-8" }).trim();
143
+ return resolved ? path.dirname(resolved) : null;
144
+ }
145
+ catch {
146
+ return null;
147
+ }
148
+ },
149
+ gracefulShutdown: () => daemon.stop(),
150
+ nodePath: process.execPath,
151
+ bundlesRoot,
152
+ });
153
+ },
154
+ /* v8 ignore stop */
155
+ });
93
156
  await this.processManager.startAutoStartAgents();
157
+ await this.senseManager?.startAutoStartSenses();
94
158
  this.scheduler.start?.();
95
159
  await this.scheduler.reconcile?.();
96
160
  await this.drainPendingBundleMessages();
161
+ await this.drainPendingSenseMessages();
97
162
  if (fs.existsSync(this.socketPath)) {
98
163
  fs.unlinkSync(this.socketPath);
99
164
  }
@@ -169,6 +234,93 @@ class OuroDaemon {
169
234
  fs.writeFileSync(pendingPath, next, "utf-8");
170
235
  }
171
236
  }
237
+ /** Drains per-sense pending dirs for always-on senses across all agents. */
238
+ static ALWAYS_ON_SENSES = new Set((0, channel_1.getAlwaysOnSenseNames)());
239
+ async drainPendingSenseMessages() {
240
+ if (!fs.existsSync(this.bundlesRoot))
241
+ return;
242
+ let bundleDirs;
243
+ try {
244
+ bundleDirs = fs.readdirSync(this.bundlesRoot, { withFileTypes: true });
245
+ }
246
+ catch {
247
+ return;
248
+ }
249
+ for (const bundleDir of bundleDirs) {
250
+ if (!bundleDir.isDirectory() || !bundleDir.name.endsWith(".ouro"))
251
+ continue;
252
+ const agentName = bundleDir.name.replace(/\.ouro$/, "");
253
+ const pendingRoot = path.join(this.bundlesRoot, bundleDir.name, "state", "pending");
254
+ if (!fs.existsSync(pendingRoot))
255
+ continue;
256
+ let friendDirs;
257
+ try {
258
+ friendDirs = fs.readdirSync(pendingRoot, { withFileTypes: true });
259
+ }
260
+ catch {
261
+ continue;
262
+ }
263
+ for (const friendDir of friendDirs) {
264
+ if (!friendDir.isDirectory())
265
+ continue;
266
+ const friendPath = path.join(pendingRoot, friendDir.name);
267
+ let channelDirs;
268
+ try {
269
+ channelDirs = fs.readdirSync(friendPath, { withFileTypes: true });
270
+ }
271
+ catch {
272
+ continue;
273
+ }
274
+ for (const channelDir of channelDirs) {
275
+ if (!channelDir.isDirectory())
276
+ continue;
277
+ if (!OuroDaemon.ALWAYS_ON_SENSES.has(channelDir.name))
278
+ continue;
279
+ const channelPath = path.join(friendPath, channelDir.name);
280
+ let keyDirs;
281
+ try {
282
+ keyDirs = fs.readdirSync(channelPath, { withFileTypes: true });
283
+ }
284
+ catch {
285
+ continue;
286
+ }
287
+ for (const keyDir of keyDirs) {
288
+ if (!keyDir.isDirectory())
289
+ continue;
290
+ const leafDir = path.join(channelPath, keyDir.name);
291
+ const messages = (0, pending_1.drainPending)(leafDir);
292
+ for (const msg of messages) {
293
+ try {
294
+ await this.router.send({
295
+ from: msg.from,
296
+ to: agentName,
297
+ content: msg.content,
298
+ priority: "normal",
299
+ });
300
+ }
301
+ catch {
302
+ // Best-effort delivery — log and continue
303
+ }
304
+ }
305
+ if (messages.length > 0) {
306
+ (0, runtime_1.emitNervesEvent)({
307
+ component: "daemon",
308
+ event: "daemon.startup_sense_drain",
309
+ message: "drained pending sense messages on startup",
310
+ meta: {
311
+ agent: agentName,
312
+ channel: channelDir.name,
313
+ friendId: friendDir.name,
314
+ key: keyDir.name,
315
+ count: messages.length,
316
+ },
317
+ });
318
+ }
319
+ }
320
+ }
321
+ }
322
+ }
323
+ }
172
324
  async stop() {
173
325
  (0, runtime_1.emitNervesEvent)({
174
326
  component: "daemon",
@@ -176,8 +328,10 @@ class OuroDaemon {
176
328
  message: "stopping daemon server",
177
329
  meta: { socketPath: this.socketPath },
178
330
  });
331
+ (0, update_checker_1.stopUpdateChecker)();
179
332
  this.scheduler.stop?.();
180
333
  await this.processManager.stopAll();
334
+ await this.senseManager?.stopAll();
181
335
  if (this.server) {
182
336
  await new Promise((resolve) => {
183
337
  this.server?.close(() => resolve());
@@ -217,10 +371,24 @@ class OuroDaemon {
217
371
  return { ok: true, message: "daemon stopped" };
218
372
  case "daemon.status": {
219
373
  const snapshots = this.processManager.listAgentSnapshots();
374
+ const workers = buildWorkerRows(snapshots);
375
+ const senses = this.senseManager?.listSenseRows() ?? [];
376
+ const data = {
377
+ overview: {
378
+ daemon: "running",
379
+ health: workers.every((worker) => worker.status === "running") ? "ok" : "warn",
380
+ socketPath: this.socketPath,
381
+ ...(0, runtime_metadata_1.getRuntimeMetadata)(),
382
+ workerCount: workers.length,
383
+ senseCount: senses.length,
384
+ },
385
+ workers,
386
+ senses,
387
+ };
220
388
  return {
221
389
  ok: true,
222
- summary: formatStatusSummary(snapshots),
223
- data: snapshots,
390
+ summary: formatStatusSummary(data),
391
+ data,
224
392
  };
225
393
  }
226
394
  case "daemon.health": {
@@ -275,6 +443,13 @@ class OuroDaemon {
275
443
  data: messages,
276
444
  };
277
445
  }
446
+ case "inner.wake":
447
+ await this.processManager.startAgent(command.agent);
448
+ this.processManager.sendToAgent?.(command.agent, { type: "message" });
449
+ return {
450
+ ok: true,
451
+ message: `woke inner dialog for ${command.agent}`,
452
+ };
278
453
  case "chat.connect":
279
454
  await this.processManager.startAgent(command.agent);
280
455
  return {
@@ -20,9 +20,16 @@ async function playHatchAnimation(hatchlingName, writer) {
20
20
  meta: { hatchlingName },
21
21
  });
22
22
  const write = writer ?? ((text) => process.stderr.write(text));
23
+ // Total animation time randomized between 3–5 seconds
24
+ const totalMs = 3000 + Math.floor(Math.random() * 2000);
25
+ const eggPhase = Math.floor(totalMs * 0.4);
26
+ const dotsPhase = Math.floor(totalMs * 0.4);
27
+ const revealPause = totalMs - eggPhase - dotsPhase;
23
28
  write(`\n ${EGG}`);
24
- await wait(400);
29
+ await wait(eggPhase);
25
30
  write(DOTS);
26
- await wait(400);
27
- write(`${SNAKE} \x1b[1m${hatchlingName}\x1b[0m\n\n`);
31
+ await wait(dotsPhase);
32
+ write(`${SNAKE} \x1b[1m${hatchlingName}\x1b[0m`);
33
+ await wait(revealPause);
34
+ write("\n\n");
28
35
  }
@@ -39,6 +39,7 @@ const fs = __importStar(require("fs"));
39
39
  const os = __importStar(require("os"));
40
40
  const path = __importStar(require("path"));
41
41
  const identity_1 = require("../identity");
42
+ const config_1 = require("../config");
42
43
  const runtime_1 = require("../../nerves/runtime");
43
44
  const hatch_specialist_1 = require("./hatch-specialist");
44
45
  function requiredCredentialKeys(provider) {
@@ -85,7 +86,7 @@ function buildSecretsTemplate() {
85
86
  setupToken: "",
86
87
  },
87
88
  "openai-codex": {
88
- model: "gpt-5.2",
89
+ model: "gpt-5.4",
89
90
  oauthAccessToken: "",
90
91
  },
91
92
  },
@@ -138,14 +139,6 @@ function writeReadme(dir, purpose) {
138
139
  fs.writeFileSync(readmePath, `# ${path.basename(dir)}\n\n${purpose}\n`, "utf-8");
139
140
  }
140
141
  }
141
- function slugify(value) {
142
- const trimmed = value.trim().toLowerCase();
143
- const slug = trimmed
144
- .replace(/[^a-z0-9]+/g, "-")
145
- .replace(/^-+/, "")
146
- .replace(/-+$/, "");
147
- return slug || "friend";
148
- }
149
142
  function pad(value) {
150
143
  return String(value).padStart(2, "0");
151
144
  }
@@ -182,7 +175,7 @@ function writeFriendImprint(bundleRoot, humanName, now) {
182
175
  const friendsDir = path.join(bundleRoot, "friends");
183
176
  fs.mkdirSync(friendsDir, { recursive: true });
184
177
  const nowIso = now.toISOString();
185
- const id = `friend-${slugify(humanName)}`;
178
+ const id = `friend-${(0, config_1.slugify)(humanName) || "friend"}`;
186
179
  const localExternalId = `${os.userInfo().username}@${os.hostname()}`;
187
180
  const record = {
188
181
  id,
@@ -207,15 +200,6 @@ function writeFriendImprint(bundleRoot, humanName, now) {
207
200
  };
208
201
  fs.writeFileSync(path.join(friendsDir, `${id}.json`), `${JSON.stringify(record, null, 2)}\n`, "utf-8");
209
202
  }
210
- function writeHatchlingPsyche(bundleRoot, input, identityFileName) {
211
- const psycheDir = path.join(bundleRoot, "psyche");
212
- fs.mkdirSync(psycheDir, { recursive: true });
213
- fs.writeFileSync(path.join(psycheDir, "SOUL.md"), "# SOUL\n\nI am a practical, collaborative agent. I keep commitments and communicate clearly.\n", "utf-8");
214
- fs.writeFileSync(path.join(psycheDir, "IDENTITY.md"), `# IDENTITY\n\nI'm ${input.agentName}, newly hatched and ready to help ${input.humanName}.`, "utf-8");
215
- fs.writeFileSync(path.join(psycheDir, "LORE.md"), `# LORE\n\nHatched with specialist identity seed: ${identityFileName}.`, "utf-8");
216
- fs.writeFileSync(path.join(psycheDir, "TACIT.md"), "# TACIT\n\n- Save what I learn.\n- Keep tasks current.\n", "utf-8");
217
- fs.writeFileSync(path.join(psycheDir, "ASPIRATIONS.md"), "# ASPIRATIONS\n\n- Become a reliable partner for my primary friend.\n", "utf-8");
218
- }
219
203
  function writeMemoryScaffold(bundleRoot) {
220
204
  const memoryRoot = path.join(bundleRoot, "psyche", "memory");
221
205
  fs.mkdirSync(path.join(memoryRoot, "daily"), { recursive: true });
@@ -267,7 +251,6 @@ async function runHatchFlow(input, deps = {}) {
267
251
  writeReadme(path.join(bundleRoot, "senses"), "Sense-specific config.");
268
252
  writeReadme(path.join(bundleRoot, "senses", "teams"), "Teams sense config.");
269
253
  writeHatchlingAgentConfig(bundleRoot, input);
270
- writeHatchlingPsyche(bundleRoot, input, selected.fileName);
271
254
  writeMemoryScaffold(bundleRoot);
272
255
  writeFriendImprint(bundleRoot, input.humanName, now);
273
256
  writeHeartbeatTask(bundleRoot, now);
@@ -0,0 +1,92 @@
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.bundleMetaHook = bundleMetaHook;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const runtime_1 = require("../../../nerves/runtime");
40
+ async function bundleMetaHook(ctx) {
41
+ (0, runtime_1.emitNervesEvent)({
42
+ component: "daemon",
43
+ event: "daemon.bundle_meta_hook_start",
44
+ message: "running bundle-meta update hook",
45
+ meta: { agentRoot: ctx.agentRoot, currentVersion: ctx.currentVersion },
46
+ });
47
+ const metaPath = path.join(ctx.agentRoot, "bundle-meta.json");
48
+ let existing;
49
+ try {
50
+ if (fs.existsSync(metaPath)) {
51
+ const raw = fs.readFileSync(metaPath, "utf-8");
52
+ existing = JSON.parse(raw);
53
+ }
54
+ }
55
+ catch {
56
+ // Malformed JSON -- treat as missing, will overwrite with fresh
57
+ existing = undefined;
58
+ }
59
+ const updated = {
60
+ runtimeVersion: ctx.currentVersion,
61
+ bundleSchemaVersion: existing?.bundleSchemaVersion ?? 1,
62
+ lastUpdated: new Date().toISOString(),
63
+ };
64
+ // Save old runtimeVersion as previousRuntimeVersion (if there was one)
65
+ if (existing?.runtimeVersion) {
66
+ updated.previousRuntimeVersion = existing.runtimeVersion;
67
+ }
68
+ try {
69
+ fs.writeFileSync(metaPath, JSON.stringify(updated, null, 2) + "\n", "utf-8");
70
+ }
71
+ catch (err) {
72
+ const errorMessage = err instanceof Error ? err.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(err);
73
+ (0, runtime_1.emitNervesEvent)({
74
+ component: "daemon",
75
+ event: "daemon.bundle_meta_hook_error",
76
+ message: "bundle-meta hook write failed",
77
+ meta: { agentRoot: ctx.agentRoot, error: errorMessage },
78
+ });
79
+ return { ok: false, error: errorMessage };
80
+ }
81
+ (0, runtime_1.emitNervesEvent)({
82
+ component: "daemon",
83
+ event: "daemon.bundle_meta_hook_end",
84
+ message: "bundle-meta updated",
85
+ meta: {
86
+ agentRoot: ctx.agentRoot,
87
+ runtimeVersion: updated.runtimeVersion,
88
+ previousRuntimeVersion: updated.previousRuntimeVersion,
89
+ },
90
+ });
91
+ return { ok: true };
92
+ }