@ouro.bot/cli 0.1.0-alpha.32 → 0.1.0-alpha.320

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 (303) hide show
  1. package/README.md +188 -190
  2. package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/agent.json +3 -2
  3. package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/SOUL.md +1 -1
  4. package/changelog.json +1917 -0
  5. package/dist/arc/attention-types.js +8 -0
  6. package/dist/arc/cares.js +140 -0
  7. package/dist/arc/episodes.js +117 -0
  8. package/dist/arc/intentions.js +133 -0
  9. package/dist/arc/json-store.js +117 -0
  10. package/dist/arc/obligations.js +237 -0
  11. package/dist/arc/packets.js +193 -0
  12. package/dist/arc/presence.js +185 -0
  13. package/dist/arc/task-lifecycle.js +65 -0
  14. package/dist/heart/active-work.js +832 -0
  15. package/dist/heart/agent-entry.js +37 -2
  16. package/dist/heart/attachments/image-normalize.js +194 -0
  17. package/dist/heart/attachments/materialize.js +97 -0
  18. package/dist/heart/attachments/originals.js +88 -0
  19. package/dist/heart/attachments/render.js +29 -0
  20. package/dist/heart/attachments/sources/adapter.js +2 -0
  21. package/dist/heart/attachments/sources/bluebubbles.js +156 -0
  22. package/dist/heart/attachments/sources/cli-local-file.js +78 -0
  23. package/dist/heart/attachments/sources/index.js +16 -0
  24. package/dist/heart/attachments/store.js +103 -0
  25. package/dist/heart/attachments/types.js +93 -0
  26. package/dist/heart/auth/auth-flow.js +456 -0
  27. package/dist/heart/bridges/manager.js +358 -0
  28. package/dist/heart/bridges/state-machine.js +135 -0
  29. package/dist/heart/bridges/store.js +123 -0
  30. package/dist/heart/bundle-state.js +168 -0
  31. package/dist/heart/commitments.js +111 -0
  32. package/dist/heart/config-registry.js +304 -0
  33. package/dist/heart/config.js +63 -30
  34. package/dist/heart/core.js +669 -195
  35. package/dist/heart/cross-chat-delivery.js +131 -0
  36. package/dist/heart/daemon/agent-config-check.js +149 -0
  37. package/dist/heart/daemon/agent-discovery.js +79 -3
  38. package/dist/heart/daemon/agent-service.js +360 -0
  39. package/dist/heart/daemon/agentic-repair.js +170 -0
  40. package/dist/heart/daemon/cadence.js +70 -0
  41. package/dist/heart/daemon/cli-defaults.js +596 -0
  42. package/dist/heart/daemon/cli-exec.js +2238 -0
  43. package/dist/heart/daemon/cli-help.js +306 -0
  44. package/dist/heart/daemon/cli-parse.js +824 -0
  45. package/dist/heart/daemon/cli-render-doctor.js +57 -0
  46. package/dist/heart/daemon/cli-render.js +506 -0
  47. package/dist/heart/daemon/cli-types.js +8 -0
  48. package/dist/heart/daemon/daemon-cli.js +29 -1171
  49. package/dist/heart/daemon/daemon-entry.js +333 -3
  50. package/dist/heart/daemon/daemon-health.js +137 -0
  51. package/dist/heart/daemon/daemon-runtime-sync.js +153 -12
  52. package/dist/heart/daemon/daemon-tombstone.js +236 -0
  53. package/dist/heart/daemon/daemon.js +751 -58
  54. package/dist/heart/daemon/doctor-types.js +8 -0
  55. package/dist/heart/daemon/doctor.js +322 -0
  56. package/dist/heart/daemon/health-monitor.js +66 -0
  57. package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
  58. package/dist/heart/daemon/hooks/bundle-meta.js +115 -1
  59. package/dist/heart/daemon/http-health-probe.js +80 -0
  60. package/dist/heart/daemon/inner-status.js +89 -0
  61. package/dist/heart/daemon/interactive-repair.js +69 -0
  62. package/dist/heart/daemon/launchd.js +46 -9
  63. package/dist/heart/daemon/log-tailer.js +82 -12
  64. package/dist/heart/daemon/logs-prune.js +105 -0
  65. package/dist/heart/daemon/message-router.js +17 -8
  66. package/dist/heart/daemon/os-cron-deps.js +134 -0
  67. package/dist/heart/daemon/ouro-bot-entry.js +1 -1
  68. package/dist/heart/daemon/process-manager.js +201 -0
  69. package/dist/heart/daemon/provider-discovery.js +105 -0
  70. package/dist/heart/daemon/pulse.js +463 -0
  71. package/dist/heart/daemon/run-hooks.js +2 -0
  72. package/dist/heart/daemon/runtime-logging.js +67 -16
  73. package/dist/heart/daemon/runtime-metadata.js +101 -0
  74. package/dist/heart/daemon/runtime-mode.js +67 -0
  75. package/dist/heart/daemon/safe-mode.js +161 -0
  76. package/dist/heart/daemon/sense-manager.js +72 -3
  77. package/dist/heart/daemon/session-id-resolver.js +131 -0
  78. package/dist/heart/daemon/skill-management-installer.js +94 -0
  79. package/dist/heart/daemon/socket-client.js +307 -0
  80. package/dist/heart/daemon/stale-bundle-prune.js +96 -0
  81. package/dist/heart/daemon/startup-tui.js +227 -0
  82. package/dist/heart/daemon/task-scheduler.js +3 -25
  83. package/dist/heart/daemon/thoughts.js +510 -0
  84. package/dist/heart/daemon/up-progress.js +135 -0
  85. package/dist/heart/delegation.js +62 -0
  86. package/dist/heart/habits/habit-migration.js +181 -0
  87. package/dist/heart/habits/habit-parser.js +140 -0
  88. package/dist/heart/habits/habit-scheduler.js +371 -0
  89. package/dist/heart/{daemon → hatch}/hatch-flow.js +30 -120
  90. package/dist/heart/{daemon → hatch}/hatch-specialist.js +3 -3
  91. package/dist/heart/{daemon → hatch}/specialist-prompt.js +10 -7
  92. package/dist/heart/{daemon → hatch}/specialist-tools.js +49 -3
  93. package/dist/heart/identity.js +163 -60
  94. package/dist/heart/kicks.js +2 -20
  95. package/dist/heart/mcp/mcp-server.js +653 -0
  96. package/dist/heart/migrate-config.js +127 -0
  97. package/dist/heart/model-capabilities.js +59 -0
  98. package/dist/heart/outlook/outlook-http.js +439 -0
  99. package/dist/heart/outlook/outlook-read.js +1595 -0
  100. package/dist/heart/outlook/outlook-render.js +1032 -0
  101. package/dist/heart/outlook/outlook-types.js +27 -0
  102. package/dist/heart/outlook/outlook-view.js +194 -0
  103. package/dist/heart/progress-story.js +42 -0
  104. package/dist/heart/provider-failover.js +88 -0
  105. package/dist/heart/provider-ping.js +162 -0
  106. package/dist/heart/providers/anthropic-token.js +163 -0
  107. package/dist/heart/providers/anthropic.js +169 -46
  108. package/dist/heart/providers/azure.js +98 -11
  109. package/dist/heart/providers/error-classification.js +63 -0
  110. package/dist/heart/providers/github-copilot.js +136 -0
  111. package/dist/heart/providers/minimax-vlm.js +189 -0
  112. package/dist/heart/providers/minimax.js +23 -5
  113. package/dist/heart/providers/openai-codex.js +33 -22
  114. package/dist/heart/session-activity.js +190 -0
  115. package/dist/heart/session-events.js +726 -0
  116. package/dist/heart/session-recall.js +162 -0
  117. package/dist/heart/start-of-turn-packet.js +341 -0
  118. package/dist/heart/streaming.js +36 -27
  119. package/dist/heart/sync.js +332 -0
  120. package/dist/heart/target-resolution.js +127 -0
  121. package/dist/heart/tempo.js +93 -0
  122. package/dist/heart/temporal-view.js +41 -0
  123. package/dist/heart/tool-activity-callbacks.js +36 -0
  124. package/dist/heart/tool-description.js +135 -0
  125. package/dist/heart/tool-friction.js +55 -0
  126. package/dist/heart/tool-loop.js +200 -0
  127. package/dist/heart/turn-context.js +358 -0
  128. package/dist/heart/turn-coordinator.js +28 -0
  129. package/dist/heart/{daemon → versioning}/ouro-bot-global-installer.js +1 -1
  130. package/dist/heart/{daemon → versioning}/ouro-bot-wrapper.js +1 -1
  131. package/dist/heart/{daemon → versioning}/ouro-path-installer.js +78 -35
  132. package/dist/heart/versioning/ouro-version-manager.js +295 -0
  133. package/dist/heart/{daemon → versioning}/staged-restart.js +40 -8
  134. package/dist/heart/{daemon → versioning}/update-checker.js +12 -2
  135. package/dist/heart/{daemon → versioning}/update-hooks.js +63 -59
  136. package/dist/mind/associative-recall.js +137 -66
  137. package/dist/mind/bundle-manifest.js +8 -1
  138. package/dist/mind/context.js +89 -93
  139. package/dist/mind/diary-integrity.js +60 -0
  140. package/dist/mind/{memory.js → diary.js} +84 -96
  141. package/dist/mind/embedding-provider.js +60 -0
  142. package/dist/mind/file-state.js +179 -0
  143. package/dist/mind/first-impressions.js +14 -1
  144. package/dist/mind/friends/channel.js +56 -0
  145. package/dist/mind/friends/group-context.js +144 -0
  146. package/dist/mind/friends/resolver.js +37 -0
  147. package/dist/mind/friends/store-file.js +58 -3
  148. package/dist/mind/friends/trust-explanation.js +74 -0
  149. package/dist/mind/friends/types.js +8 -0
  150. package/dist/mind/journal-index.js +161 -0
  151. package/dist/mind/obligation-steering.js +221 -0
  152. package/dist/mind/pending.js +76 -9
  153. package/dist/mind/prompt.js +950 -113
  154. package/dist/mind/provenance-trust.js +26 -0
  155. package/dist/mind/scrutiny.js +173 -0
  156. package/dist/mind/token-estimate.js +8 -12
  157. package/dist/nerves/cli-logging.js +7 -1
  158. package/dist/nerves/coverage/audit.js +1 -1
  159. package/dist/nerves/coverage/file-completeness.js +76 -5
  160. package/dist/nerves/coverage/run-artifacts.js +1 -1
  161. package/dist/nerves/event-buffer.js +111 -0
  162. package/dist/nerves/index.js +224 -4
  163. package/dist/nerves/observation.js +20 -0
  164. package/dist/nerves/redact.js +79 -0
  165. package/dist/nerves/runtime.js +5 -1
  166. package/dist/outlook-ui/assets/index-IuR4F6y6.js +61 -0
  167. package/dist/outlook-ui/assets/index-LwChZTgL.css +1 -0
  168. package/dist/outlook-ui/index.html +15 -0
  169. package/dist/repertoire/ado-client.js +15 -56
  170. package/dist/repertoire/ado-semantic.js +11 -10
  171. package/dist/repertoire/api-client.js +97 -0
  172. package/dist/repertoire/bitwarden-store.js +319 -0
  173. package/dist/repertoire/bundle-templates.js +72 -0
  174. package/dist/repertoire/bw-installer.js +79 -0
  175. package/dist/repertoire/coding/codex-jsonl.js +64 -0
  176. package/dist/repertoire/coding/context-pack.js +330 -0
  177. package/dist/repertoire/coding/feedback.js +197 -30
  178. package/dist/repertoire/coding/manager.js +159 -11
  179. package/dist/repertoire/coding/spawner.js +55 -9
  180. package/dist/repertoire/coding/tools.js +170 -7
  181. package/dist/repertoire/commerce-errors.js +109 -0
  182. package/dist/repertoire/commerce-self-test.js +156 -0
  183. package/dist/repertoire/credential-access.js +527 -0
  184. package/dist/repertoire/duffel-client.js +185 -0
  185. package/dist/repertoire/github-client.js +14 -55
  186. package/dist/repertoire/graph-client.js +11 -52
  187. package/dist/repertoire/guardrails.js +375 -0
  188. package/dist/repertoire/mcp-client.js +255 -0
  189. package/dist/repertoire/mcp-manager.js +305 -0
  190. package/dist/repertoire/mcp-tools.js +63 -0
  191. package/dist/repertoire/shell-sessions.js +133 -0
  192. package/dist/repertoire/skills.js +14 -23
  193. package/dist/repertoire/stripe-client.js +131 -0
  194. package/dist/repertoire/tasks/board.js +43 -5
  195. package/dist/repertoire/tasks/fix.js +182 -0
  196. package/dist/repertoire/tasks/index.js +28 -10
  197. package/dist/repertoire/tasks/lifecycle.js +2 -2
  198. package/dist/repertoire/tasks/parser.js +3 -2
  199. package/dist/repertoire/tasks/scanner.js +194 -37
  200. package/dist/repertoire/tasks/transitions.js +16 -79
  201. package/dist/repertoire/tool-results.js +29 -0
  202. package/dist/repertoire/tools-attachments.js +316 -0
  203. package/dist/repertoire/tools-base.js +45 -771
  204. package/dist/repertoire/tools-bluebubbles.js +1 -0
  205. package/dist/repertoire/tools-bridge.js +141 -0
  206. package/dist/repertoire/tools-bundle.js +984 -0
  207. package/dist/repertoire/tools-config.js +185 -0
  208. package/dist/repertoire/tools-continuity.js +248 -0
  209. package/dist/repertoire/tools-credential.js +182 -0
  210. package/dist/repertoire/tools-files.js +342 -0
  211. package/dist/repertoire/tools-flight.js +224 -0
  212. package/dist/repertoire/tools-flow.js +105 -0
  213. package/dist/repertoire/tools-github.js +1 -7
  214. package/dist/repertoire/tools-memory.js +376 -0
  215. package/dist/repertoire/tools-session.js +739 -0
  216. package/dist/repertoire/tools-shell.js +120 -0
  217. package/dist/repertoire/tools-stripe.js +180 -0
  218. package/dist/repertoire/tools-surface.js +243 -0
  219. package/dist/repertoire/tools-teams.js +12 -62
  220. package/dist/repertoire/tools-travel.js +125 -0
  221. package/dist/repertoire/tools-user-profile.js +144 -0
  222. package/dist/repertoire/tools-vault.js +110 -0
  223. package/dist/repertoire/tools.js +144 -138
  224. package/dist/repertoire/travel-api-client.js +360 -0
  225. package/dist/repertoire/user-profile.js +118 -0
  226. package/dist/repertoire/vault-setup.js +241 -0
  227. package/dist/scripts/claude-code-hook.js +41 -0
  228. package/dist/scripts/claude-code-stop-hook.js +47 -0
  229. package/dist/senses/attention-queue.js +116 -0
  230. package/dist/senses/bluebubbles/attachment-cache.js +53 -0
  231. package/dist/senses/bluebubbles/attachment-download.js +137 -0
  232. package/dist/senses/{bluebubbles-client.js → bluebubbles/client.js} +143 -9
  233. package/dist/senses/bluebubbles/entry.js +13 -0
  234. package/dist/senses/bluebubbles/inbound-log.js +113 -0
  235. package/dist/senses/bluebubbles/index.js +1436 -0
  236. package/dist/senses/{bluebubbles-media.js → bluebubbles/media.js} +121 -70
  237. package/dist/senses/{bluebubbles-model.js → bluebubbles/model.js} +43 -12
  238. package/dist/senses/{bluebubbles-mutation-log.js → bluebubbles/mutation-log.js} +46 -6
  239. package/dist/senses/bluebubbles/replay.js +129 -0
  240. package/dist/senses/bluebubbles/runtime-state.js +109 -0
  241. package/dist/senses/{bluebubbles-session-cleanup.js → bluebubbles/session-cleanup.js} +1 -1
  242. package/dist/senses/cli/bracketed-paste.js +82 -0
  243. package/dist/senses/cli/image-paste.js +287 -0
  244. package/dist/senses/cli/image-ref-navigation.js +75 -0
  245. package/dist/senses/cli/ink-app.js +156 -0
  246. package/dist/senses/cli/inline-diff.js +64 -0
  247. package/dist/senses/cli/input-keys.js +174 -0
  248. package/dist/senses/cli/kill-ring.js +86 -0
  249. package/dist/senses/cli/message-list.js +51 -0
  250. package/dist/senses/cli/ouro-tui.js +605 -0
  251. package/dist/senses/cli/spinner-imperative.js +135 -0
  252. package/dist/senses/cli/spinner.js +101 -0
  253. package/dist/senses/cli/status-line.js +60 -0
  254. package/dist/senses/cli/streaming-markdown.js +526 -0
  255. package/dist/senses/cli/tool-display.js +83 -0
  256. package/dist/senses/cli/tool-render.js +85 -0
  257. package/dist/senses/cli/tui-store.js +240 -0
  258. package/dist/senses/cli/virtual-list.js +35 -0
  259. package/dist/senses/cli-entry.js +1 -1
  260. package/dist/senses/cli-layout.js +187 -0
  261. package/dist/senses/cli.js +595 -246
  262. package/dist/senses/commands.js +65 -1
  263. package/dist/senses/continuity.js +94 -0
  264. package/dist/senses/habit-turn-message.js +108 -0
  265. package/dist/senses/inner-dialog-worker.js +112 -19
  266. package/dist/senses/inner-dialog.js +633 -86
  267. package/dist/senses/pipeline.js +565 -0
  268. package/dist/senses/shared-turn.js +199 -0
  269. package/dist/senses/surface-tool.js +68 -0
  270. package/dist/senses/teams.js +666 -166
  271. package/dist/senses/trust-gate.js +112 -2
  272. package/package.json +27 -7
  273. package/skills/agent-commerce.md +106 -0
  274. package/skills/browser-navigation.md +110 -0
  275. package/skills/commerce-setup-guide.md +116 -0
  276. package/skills/commerce-setup.md +84 -0
  277. package/skills/configure-dev-tools.md +81 -0
  278. package/skills/travel-planning.md +138 -0
  279. package/dist/heart/daemon/subagent-installer.js +0 -134
  280. package/dist/senses/bluebubbles-entry.js +0 -11
  281. package/dist/senses/bluebubbles.js +0 -544
  282. package/dist/senses/debug-activity.js +0 -108
  283. package/subagents/README.md +0 -73
  284. package/subagents/work-doer.md +0 -235
  285. package/subagents/work-merger.md +0 -618
  286. package/subagents/work-planner.md +0 -382
  287. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/basilisk.md +0 -0
  288. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jafar.md +0 -0
  289. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jormungandr.md +0 -0
  290. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/kaa.md +0 -0
  291. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/medusa.md +0 -0
  292. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +0 -0
  293. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/nagini.md +0 -0
  294. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/ouroboros.md +0 -0
  295. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/python.md +0 -0
  296. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/quetzalcoatl.md +0 -0
  297. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/sir-hiss.md +0 -0
  298. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +0 -0
  299. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-snake.md +0 -0
  300. /package/dist/heart/{daemon → hatch}/hatch-animation.js +0 -0
  301. /package/dist/heart/{daemon → hatch}/specialist-orchestrator.js +0 -0
  302. /package/dist/heart/{daemon → versioning}/ouro-uti.js +0 -0
  303. /package/dist/heart/{daemon → versioning}/wrapper-publish-guard.js +0 -0
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ // v1 → v2 agent.json migration.
3
+ // Moves model from secrets.json into agent.json under humanFacing/agentFacing.
4
+ // Uses raw fs — NO import from config.ts (avoids circular dependency).
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.migrateAgentConfigV1ToV2 = migrateAgentConfigV1ToV2;
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ const runtime_1 = require("../nerves/runtime");
43
+ const MODEL_FIELD = {
44
+ azure: "modelName",
45
+ minimax: "model",
46
+ anthropic: "model",
47
+ "openai-codex": "model",
48
+ "github-copilot": "model",
49
+ };
50
+ function resolveSecretsPath(agentRoot, deps) {
51
+ const agentName = path.basename(agentRoot).replace(/\.ouro$/, "");
52
+ const secretsBase = deps?.secretsRoot ?? path.join(require("os").homedir(), ".agentsecrets");
53
+ return path.join(secretsBase, agentName, "secrets.json");
54
+ }
55
+ function migrateAgentConfigV1ToV2(agentRoot, deps) {
56
+ const configPath = path.join(agentRoot, "agent.json");
57
+ let raw;
58
+ try {
59
+ raw = fs.readFileSync(configPath, "utf-8");
60
+ }
61
+ catch {
62
+ return; // No agent.json — nothing to migrate
63
+ }
64
+ let config;
65
+ try {
66
+ config = JSON.parse(raw);
67
+ }
68
+ catch {
69
+ throw new Error(`Cannot parse agent.json at ${configPath} — invalid JSON`);
70
+ }
71
+ const version = typeof config.version === "number" ? config.version : 1;
72
+ if (version >= 2) {
73
+ (0, runtime_1.emitNervesEvent)({
74
+ component: "config/identity",
75
+ event: "config_identity.migrate_skip",
76
+ message: "agent config already v2, skipping migration",
77
+ meta: { agentRoot },
78
+ });
79
+ return;
80
+ }
81
+ (0, runtime_1.emitNervesEvent)({
82
+ component: "config/identity",
83
+ event: "config_identity.migrate_start",
84
+ message: "migrating agent config v1 → v2",
85
+ meta: { agentRoot },
86
+ });
87
+ const provider = config.provider;
88
+ let model = "";
89
+ if (provider) {
90
+ const secretsPath = resolveSecretsPath(agentRoot, deps);
91
+ try {
92
+ const secretsRaw = fs.readFileSync(secretsPath, "utf-8");
93
+ const secrets = JSON.parse(secretsRaw);
94
+ const providers = secrets.providers;
95
+ if (providers) {
96
+ const providerSecrets = providers[provider];
97
+ if (providerSecrets) {
98
+ /* v8 ignore next -- fallback: all known providers are in MODEL_FIELD @preserve */
99
+ const fieldName = MODEL_FIELD[provider] ?? "model";
100
+ const rawModel = providerSecrets[fieldName];
101
+ model = typeof rawModel === "string" ? rawModel : "";
102
+ // Strip model from secrets
103
+ delete providerSecrets[fieldName];
104
+ fs.writeFileSync(secretsPath, JSON.stringify(secrets, null, 2) + "\n", "utf-8");
105
+ }
106
+ }
107
+ }
108
+ catch {
109
+ // Missing or malformed secrets.json — leave model as empty string
110
+ }
111
+ }
112
+ // Write v2 config
113
+ const { provider: _removed, ...rest } = config;
114
+ const v2Config = {
115
+ ...rest,
116
+ version: 2,
117
+ humanFacing: { provider: provider ?? "anthropic", model },
118
+ agentFacing: { provider: provider ?? "anthropic", model },
119
+ };
120
+ fs.writeFileSync(configPath, JSON.stringify(v2Config, null, 2) + "\n", "utf-8");
121
+ (0, runtime_1.emitNervesEvent)({
122
+ component: "config/identity",
123
+ event: "config_identity.migrate_end",
124
+ message: "agent config migration complete",
125
+ meta: { agentRoot, provider: provider ?? "unknown", model },
126
+ });
127
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MODEL_CAPABILITIES = void 0;
4
+ exports.getModelCapabilities = getModelCapabilities;
5
+ const runtime_1 = require("../nerves/runtime");
6
+ exports.MODEL_CAPABILITIES = {
7
+ "claude-opus-4-6": {
8
+ reasoningEffort: ["low", "medium", "high", "max"],
9
+ thinkingFormat: "anthropic",
10
+ maxOutputTokens: 128000,
11
+ vision: true,
12
+ },
13
+ "claude-sonnet-4-6": {
14
+ reasoningEffort: ["low", "medium", "high"],
15
+ thinkingFormat: "anthropic",
16
+ maxOutputTokens: 64000,
17
+ vision: true,
18
+ },
19
+ "claude-opus-4.6": {
20
+ reasoningEffort: ["low", "medium", "high", "max"],
21
+ maxOutputTokens: 128000,
22
+ vision: true,
23
+ },
24
+ "claude-sonnet-4.6": {
25
+ reasoningEffort: ["low", "medium", "high"],
26
+ maxOutputTokens: 64000,
27
+ vision: true,
28
+ },
29
+ "gpt-5.4": {
30
+ reasoningEffort: ["low", "medium", "high"],
31
+ phase: true,
32
+ maxOutputTokens: 100000,
33
+ vision: true,
34
+ },
35
+ "gpt-5.3-codex": {
36
+ reasoningEffort: ["low", "medium", "high"],
37
+ phase: true,
38
+ maxOutputTokens: 100000,
39
+ },
40
+ "MiniMax-Text-01": {
41
+ vision: true,
42
+ },
43
+ "MiniMax-VL-01": {
44
+ vision: true,
45
+ },
46
+ };
47
+ const EMPTY_CAPABILITIES = Object.freeze({});
48
+ function getModelCapabilities(modelId) {
49
+ (0, runtime_1.emitNervesEvent)({
50
+ component: "engine",
51
+ event: "engine.model_capabilities_lookup",
52
+ message: `model capabilities lookup: ${modelId}`,
53
+ meta: { modelId, found: modelId in exports.MODEL_CAPABILITIES },
54
+ });
55
+ const entry = exports.MODEL_CAPABILITIES[modelId];
56
+ if (entry)
57
+ return entry;
58
+ return { ...EMPTY_CAPABILITIES };
59
+ }
@@ -0,0 +1,439 @@
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.startOutlookHttpServer = startOutlookHttpServer;
37
+ const fs = __importStar(require("fs"));
38
+ const http = __importStar(require("http"));
39
+ const path = __importStar(require("path"));
40
+ const runtime_1 = require("../../nerves/runtime");
41
+ const outlook_read_1 = require("./outlook-read");
42
+ function createSseBroadcaster() {
43
+ let nextId = 1;
44
+ const clients = new Set();
45
+ function add(response) {
46
+ const client = { id: nextId++, response };
47
+ clients.add(client);
48
+ response.on("close", () => clients.delete(client));
49
+ return client;
50
+ }
51
+ function broadcast(event, data = {}) {
52
+ const payload = `event: ${event}\ndata: ${JSON.stringify(data)}\n\n`;
53
+ for (const client of clients) {
54
+ try {
55
+ client.response.write(payload);
56
+ /* v8 ignore start */
57
+ }
58
+ catch {
59
+ clients.delete(client);
60
+ }
61
+ /* v8 ignore stop */
62
+ }
63
+ }
64
+ function disconnectAll() {
65
+ for (const client of clients) {
66
+ try {
67
+ client.response.end();
68
+ /* v8 ignore start */
69
+ }
70
+ catch {
71
+ /* already closed */
72
+ }
73
+ /* v8 ignore stop */
74
+ }
75
+ clients.clear();
76
+ }
77
+ return { add, broadcast, disconnectAll };
78
+ }
79
+ /* v8 ignore start — filesystem watcher, tested via integration */
80
+ function createBundleWatcher(bundlesRoot, onChange) {
81
+ const watchers = [];
82
+ let debounceTimer = null;
83
+ const DEBOUNCE_MS = 500;
84
+ function debouncedOnChange() {
85
+ if (debounceTimer)
86
+ clearTimeout(debounceTimer);
87
+ debounceTimer = setTimeout(onChange, DEBOUNCE_MS);
88
+ }
89
+ try {
90
+ if (fs.existsSync(bundlesRoot)) {
91
+ const watcher = fs.watch(bundlesRoot, { recursive: true }, debouncedOnChange);
92
+ watchers.push(watcher);
93
+ }
94
+ }
95
+ catch {
96
+ // watch not available — SSE will rely on manual broadcast
97
+ }
98
+ return {
99
+ stop() {
100
+ if (debounceTimer)
101
+ clearTimeout(debounceTimer);
102
+ for (const w of watchers)
103
+ try {
104
+ w.close();
105
+ }
106
+ catch { /* ignore */ }
107
+ watchers.length = 0;
108
+ },
109
+ };
110
+ }
111
+ /* v8 ignore stop */
112
+ function writeJson(response, statusCode, payload) {
113
+ response.writeHead(statusCode, { "content-type": "application/json; charset=utf-8" });
114
+ response.end(`${JSON.stringify(payload, null, 2)}\n`);
115
+ }
116
+ /* v8 ignore start — SPA static file serving infrastructure */
117
+ const MIME_TYPES = {
118
+ ".html": "text/html",
119
+ ".js": "application/javascript",
120
+ ".css": "text/css",
121
+ ".json": "application/json",
122
+ ".svg": "image/svg+xml",
123
+ ".png": "image/png",
124
+ ".ico": "image/x-icon",
125
+ ".woff2": "font/woff2",
126
+ };
127
+ function resolveSpaDistDir() {
128
+ // Look for the built SPA relative to this file's location
129
+ // In production: dist/heart/daemon/outlook-http.js -> ../../packages/outlook-ui/dist/
130
+ // In dev: packages/outlook-ui/dist/
131
+ const candidates = [
132
+ path.resolve(__dirname, "..", "..", "..", "packages", "outlook-ui", "dist"),
133
+ path.resolve(__dirname, "..", "..", "packages", "outlook-ui", "dist"),
134
+ path.resolve(__dirname, "..", "..", "..", "..", "packages", "outlook-ui", "dist"),
135
+ // npm-published layout: the SPA dist is copied to dist/outlook-ui/
136
+ path.resolve(__dirname, "..", "..", "outlook-ui"),
137
+ path.resolve(__dirname, "..", "outlook-ui"),
138
+ ];
139
+ for (const candidate of candidates) {
140
+ if (fs.existsSync(path.join(candidate, "index.html")))
141
+ return candidate;
142
+ }
143
+ return null;
144
+ }
145
+ function serveStaticFile(response, filePath) {
146
+ try {
147
+ if (!fs.existsSync(filePath))
148
+ return false;
149
+ const ext = path.extname(filePath);
150
+ const contentType = MIME_TYPES[ext] ?? "application/octet-stream";
151
+ const content = fs.readFileSync(filePath);
152
+ response.writeHead(200, {
153
+ "content-type": contentType,
154
+ "cache-control": ext === ".html" ? "no-cache" : "public, max-age=31536000, immutable",
155
+ });
156
+ response.end(content);
157
+ return true;
158
+ }
159
+ catch {
160
+ return false;
161
+ }
162
+ }
163
+ /* v8 ignore stop */
164
+ function normalizePath(urlValue = "/") {
165
+ const parsed = new URL(urlValue, "http://127.0.0.1");
166
+ const normalizedPath = parsed.pathname.replace(/\/+$/, "");
167
+ if (normalizedPath.length === 0)
168
+ return "/";
169
+ return normalizedPath;
170
+ }
171
+ async function startOutlookHttpServer(options = {}) {
172
+ const host = options.host ?? "127.0.0.1";
173
+ const port = options.port ?? 0;
174
+ const bundlesRoot = options.bundlesRoot;
175
+ const opts = bundlesRoot ? { bundlesRoot } : undefined;
176
+ const readMachineState = options.readMachineState ?? (() => (0, outlook_read_1.readOutlookMachineState)(opts));
177
+ const readMachineView = options.readMachineView;
178
+ /* v8 ignore start */
179
+ const readAgentState = options.readAgentState ?? ((agentName) => {
180
+ if (opts)
181
+ return (0, outlook_read_1.readOutlookAgentState)(agentName, opts);
182
+ return (0, outlook_read_1.readOutlookAgentState)(agentName);
183
+ });
184
+ /* v8 ignore stop */
185
+ const readAgentView = options.readAgentView;
186
+ /* v8 ignore start — default hook wiring, tested via integration */
187
+ const agentRoot = (agentName) => {
188
+ const base = bundlesRoot ?? "";
189
+ return path.join(base, `${agentName}.ouro`);
190
+ };
191
+ const hooks = {
192
+ readAgentSessions: options.readAgentSessions ?? ((agentName) => (0, outlook_read_1.readSessionInventory)(agentName, bundlesRoot ? { bundlesRoot } : undefined)),
193
+ readAgentTranscript: options.readAgentTranscript ?? ((agentName, friendId, channel, key) => (0, outlook_read_1.readSessionTranscript)(agentName, friendId, channel, key, bundlesRoot ? { bundlesRoot } : undefined)),
194
+ readAgentCoding: options.readAgentCoding ?? ((agentName) => (0, outlook_read_1.readCodingDeep)(agentRoot(agentName))),
195
+ readAgentAttention: options.readAgentAttention ?? ((agentName) => (0, outlook_read_1.readAttentionView)(agentName, bundlesRoot ? { bundlesRoot } : undefined)),
196
+ readAgentBridges: options.readAgentBridges ?? ((agentName) => (0, outlook_read_1.readBridgeInventory)(agentRoot(agentName))),
197
+ readAgentMemory: options.readAgentMemory ?? ((agentName) => (0, outlook_read_1.readMemoryView)(agentRoot(agentName))),
198
+ readAgentFriends: options.readAgentFriends ?? ((agentName) => (0, outlook_read_1.readFriendView)(agentName, bundlesRoot ? { bundlesRoot } : undefined)),
199
+ readAgentContinuity: options.readAgentContinuity ?? ((agentName) => (0, outlook_read_1.readOutlookContinuity)(agentRoot(agentName), agentName)),
200
+ readAgentOrientation: options.readAgentOrientation ?? ((agentName) => (0, outlook_read_1.readOrientationView)(agentRoot(agentName), agentName)),
201
+ readAgentObligations: options.readAgentObligations ?? ((agentName) => (0, outlook_read_1.readObligationDetailView)(agentRoot(agentName))),
202
+ readAgentChanges: options.readAgentChanges ?? ((agentName) => (0, outlook_read_1.readChangesView)(agentRoot(agentName))),
203
+ readAgentSelfFix: options.readAgentSelfFix ?? ((agentName) => (0, outlook_read_1.readSelfFixView)(agentRoot(agentName))),
204
+ readAgentMemoryDecisions: options.readAgentMemoryDecisions ?? ((agentName) => (0, outlook_read_1.readMemoryDecisionView)(agentRoot(agentName))),
205
+ readAgentHabits: options.readAgentHabits ?? ((agentName) => (0, outlook_read_1.readHabitView)(agentRoot(agentName))),
206
+ readDaemonHealth: options.readDaemonHealth ?? (() => (0, outlook_read_1.readDaemonHealthDeep)(options.healthPath)),
207
+ readLogs: options.readLogs ?? (() => (0, outlook_read_1.readLogView)(options.logPath ?? null)),
208
+ };
209
+ /* v8 ignore stop */
210
+ const sse = createSseBroadcaster();
211
+ /* v8 ignore start — watcher callback fires on filesystem changes */
212
+ const bundleWatcher = bundlesRoot ? createBundleWatcher(bundlesRoot, () => {
213
+ sse.broadcast("state-changed", { at: new Date().toISOString() });
214
+ }) : null;
215
+ /* v8 ignore stop */
216
+ const server = http.createServer((request, response) => {
217
+ let pathname = normalizePath(request.url);
218
+ const origin = `http://${host}:${server.address().port}`;
219
+ /* v8 ignore start — SPA static asset serving */
220
+ // Serve built SPA static assets: /assets/*
221
+ if (pathname.startsWith("/assets/")) {
222
+ const spaDir = resolveSpaDistDir();
223
+ if (spaDir) {
224
+ const assetPath = path.join(spaDir, pathname);
225
+ if (serveStaticFile(response, assetPath))
226
+ return;
227
+ }
228
+ writeJson(response, 404, { ok: false, error: "asset not found" });
229
+ return;
230
+ }
231
+ /* v8 ignore stop */
232
+ // Legacy /outlook route — redirect to root
233
+ if (pathname === "/outlook") {
234
+ response.writeHead(301, { location: "/" });
235
+ response.end();
236
+ return;
237
+ }
238
+ // Compatibility alias: /outlook/api/* → /api/*
239
+ /* v8 ignore start -- legacy compat path: tested via integration @preserve */
240
+ if (pathname.startsWith("/outlook/api/")) {
241
+ pathname = pathname.slice("/outlook".length);
242
+ }
243
+ else if (pathname === "/outlook/api") {
244
+ pathname = "/api";
245
+ }
246
+ /* v8 ignore stop */
247
+ // SSE event stream
248
+ if (pathname === "/api/events") {
249
+ response.writeHead(200, { "content-type": "text/event-stream", "cache-control": "no-cache", "connection": "keep-alive", "access-control-allow-origin": "*" });
250
+ response.write(":ok\n\n");
251
+ sse.add(response);
252
+ return;
253
+ }
254
+ if (pathname === "/api/machine") {
255
+ const machine = readMachineState();
256
+ const machineView = readMachineView?.({ origin, machine });
257
+ writeJson(response, 200, machineView ?? machine);
258
+ return;
259
+ }
260
+ if (pathname === "/api/machine/health") {
261
+ const health = hooks.readDaemonHealth();
262
+ writeJson(response, 200, health ?? { status: "unavailable" });
263
+ return;
264
+ }
265
+ if (pathname === "/api/machine/logs") {
266
+ writeJson(response, 200, hooks.readLogs());
267
+ return;
268
+ }
269
+ // Agent-level endpoints: /api/agents/:agent[/:surface[/:params...]]
270
+ const agentMatch = /^\/api\/agents\/([^/]+)(?:\/(.+))?$/.exec(pathname);
271
+ if (agentMatch) {
272
+ const agent = decodeURIComponent(agentMatch[1]);
273
+ const surface = agentMatch[2] ?? null;
274
+ if (!surface) {
275
+ const view = readAgentView?.(agent);
276
+ if (view) {
277
+ writeJson(response, 200, view);
278
+ return;
279
+ }
280
+ const state = readAgentState(agent);
281
+ if (!state) {
282
+ writeJson(response, 404, { ok: false, error: `unknown agent: ${agent}` });
283
+ return;
284
+ }
285
+ writeJson(response, 200, state);
286
+ return;
287
+ }
288
+ if (surface === "sessions") {
289
+ writeJson(response, 200, hooks.readAgentSessions(agent));
290
+ return;
291
+ }
292
+ const transcriptMatch = /^sessions\/([^/]+)\/([^/]+)\/([^/]+)$/.exec(surface);
293
+ if (transcriptMatch) {
294
+ const friendId = decodeURIComponent(transcriptMatch[1]);
295
+ const channel = decodeURIComponent(transcriptMatch[2]);
296
+ const key = decodeURIComponent(transcriptMatch[3]);
297
+ const transcript = hooks.readAgentTranscript(agent, friendId, channel, key);
298
+ if (!transcript) {
299
+ writeJson(response, 404, { ok: false, error: "session not found" });
300
+ return;
301
+ }
302
+ writeJson(response, 200, transcript);
303
+ return;
304
+ }
305
+ if (surface === "coding") {
306
+ writeJson(response, 200, hooks.readAgentCoding(agent));
307
+ return;
308
+ }
309
+ if (surface === "attention") {
310
+ writeJson(response, 200, hooks.readAgentAttention(agent));
311
+ return;
312
+ }
313
+ if (surface === "bridges") {
314
+ writeJson(response, 200, hooks.readAgentBridges(agent));
315
+ return;
316
+ }
317
+ if (surface === "memory") {
318
+ writeJson(response, 200, hooks.readAgentMemory(agent));
319
+ return;
320
+ }
321
+ if (surface === "friends") {
322
+ writeJson(response, 200, hooks.readAgentFriends(agent));
323
+ return;
324
+ }
325
+ if (surface === "continuity") {
326
+ writeJson(response, 200, hooks.readAgentContinuity(agent));
327
+ return;
328
+ }
329
+ if (surface === "orientation") {
330
+ writeJson(response, 200, hooks.readAgentOrientation(agent));
331
+ return;
332
+ }
333
+ if (surface === "obligations") {
334
+ writeJson(response, 200, hooks.readAgentObligations(agent));
335
+ return;
336
+ }
337
+ if (surface === "changes") {
338
+ writeJson(response, 200, hooks.readAgentChanges(agent));
339
+ return;
340
+ }
341
+ if (surface === "self-fix") {
342
+ writeJson(response, 200, hooks.readAgentSelfFix(agent));
343
+ return;
344
+ }
345
+ if (surface === "memory-decisions") {
346
+ writeJson(response, 200, hooks.readAgentMemoryDecisions(agent));
347
+ return;
348
+ }
349
+ /* v8 ignore start — desk prefs write + reads */
350
+ if (surface === "dismiss-obligation" && request.method === "POST") {
351
+ let body = "";
352
+ request.on("data", (chunk) => { body += chunk; });
353
+ request.on("end", () => {
354
+ try {
355
+ const { obligationId } = JSON.parse(body);
356
+ if (!obligationId) {
357
+ writeJson(response, 400, { ok: false, error: "obligationId required" });
358
+ return;
359
+ }
360
+ const prefsPath = path.join(agentRoot(agent), "state", "outlook-prefs.json");
361
+ let prefs = {};
362
+ try {
363
+ prefs = JSON.parse(fs.readFileSync(prefsPath, "utf-8"));
364
+ }
365
+ catch { /* new file */ }
366
+ const dismissed = Array.isArray(prefs.dismissedObligations) ? prefs.dismissedObligations : [];
367
+ if (!dismissed.includes(obligationId))
368
+ dismissed.push(obligationId);
369
+ prefs.dismissedObligations = dismissed;
370
+ fs.mkdirSync(path.dirname(prefsPath), { recursive: true });
371
+ fs.writeFileSync(prefsPath, JSON.stringify(prefs, null, 2) + "\n", "utf-8");
372
+ writeJson(response, 200, { ok: true, dismissed: dismissed.length });
373
+ }
374
+ catch (error) {
375
+ writeJson(response, 500, { ok: false, error: String(error) });
376
+ }
377
+ });
378
+ return;
379
+ }
380
+ if (surface === "desk-prefs") {
381
+ writeJson(response, 200, (0, outlook_read_1.readDeskPrefs)(agentRoot(agent)));
382
+ return;
383
+ }
384
+ if (surface === "needs-me") {
385
+ writeJson(response, 200, (0, outlook_read_1.readNeedsMeView)(agent, opts));
386
+ return;
387
+ }
388
+ /* v8 ignore stop */
389
+ if (surface === "habits") {
390
+ writeJson(response, 200, hooks.readAgentHabits(agent));
391
+ return;
392
+ }
393
+ if (surface === "inner-transcript") {
394
+ const transcript = hooks.readAgentTranscript(agent, "self", "inner", "dialog");
395
+ writeJson(response, 200, transcript ?? { messageCount: 0, messages: [] });
396
+ return;
397
+ }
398
+ writeJson(response, 404, { ok: false, error: `unknown agent surface: ${surface}` });
399
+ return;
400
+ }
401
+ /* v8 ignore start — SPA fallback for client-side routing @preserve */
402
+ const spaDir = resolveSpaDistDir();
403
+ if (spaDir) {
404
+ if (serveStaticFile(response, path.join(spaDir, "index.html")))
405
+ return;
406
+ }
407
+ writeJson(response, 404, { ok: false, error: `not found: ${pathname}` });
408
+ /* v8 ignore stop */
409
+ });
410
+ await new Promise((resolve, reject) => {
411
+ server.once("error", reject);
412
+ server.listen(port, host, () => resolve());
413
+ });
414
+ const address = server.address();
415
+ const origin = `http://${host}:${address.port}`;
416
+ (0, runtime_1.emitNervesEvent)({
417
+ component: "daemon",
418
+ event: "daemon.outlook_http_started",
419
+ message: "started Outlook HTTP server",
420
+ meta: { origin },
421
+ });
422
+ return {
423
+ origin,
424
+ broadcast(event, data) {
425
+ sse.broadcast(event, data);
426
+ },
427
+ async stop() {
428
+ bundleWatcher?.stop();
429
+ sse.disconnectAll();
430
+ await new Promise((resolve) => server.close(() => resolve()));
431
+ (0, runtime_1.emitNervesEvent)({
432
+ component: "daemon",
433
+ event: "daemon.outlook_http_stopped",
434
+ message: "stopped Outlook HTTP server",
435
+ meta: { origin },
436
+ });
437
+ },
438
+ };
439
+ }