@ouro.bot/cli 0.1.0-alpha.20 → 0.1.0-alpha.201

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 (204) hide show
  1. package/README.md +187 -191
  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 +1254 -0
  5. package/dist/heart/active-work.js +832 -0
  6. package/dist/heart/bridges/manager.js +358 -0
  7. package/dist/heart/bridges/state-machine.js +135 -0
  8. package/dist/heart/bridges/store.js +123 -0
  9. package/dist/heart/cares.js +179 -0
  10. package/dist/heart/commitments.js +111 -0
  11. package/dist/heart/config.js +54 -30
  12. package/dist/heart/core.js +620 -124
  13. package/dist/heart/cross-chat-delivery.js +146 -0
  14. package/dist/heart/daemon/agent-config-check.js +149 -0
  15. package/dist/heart/daemon/agent-discovery.js +81 -0
  16. package/dist/heart/daemon/agent-service.js +360 -0
  17. package/dist/heart/daemon/auth-flow.js +477 -0
  18. package/dist/heart/daemon/cadence.js +70 -0
  19. package/dist/heart/daemon/daemon-cli.js +2444 -217
  20. package/dist/heart/daemon/daemon-entry.js +182 -4
  21. package/dist/heart/daemon/daemon-health.js +136 -0
  22. package/dist/heart/daemon/daemon-runtime-sync.js +231 -0
  23. package/dist/heart/daemon/daemon-tombstone.js +123 -0
  24. package/dist/heart/daemon/daemon.js +460 -18
  25. package/dist/heart/daemon/habit-migration.js +181 -0
  26. package/dist/heart/daemon/habit-parser.js +119 -0
  27. package/dist/heart/daemon/habit-scheduler.js +369 -0
  28. package/dist/heart/daemon/hatch-flow.js +31 -112
  29. package/dist/heart/daemon/hatch-specialist.js +3 -3
  30. package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
  31. package/dist/heart/daemon/hooks/bundle-meta.js +206 -0
  32. package/dist/heart/daemon/inner-status.js +89 -0
  33. package/dist/heart/daemon/launchd.js +165 -0
  34. package/dist/heart/daemon/log-tailer.js +4 -3
  35. package/dist/heart/daemon/mcp-server.js +591 -0
  36. package/dist/heart/daemon/message-router.js +17 -8
  37. package/dist/heart/daemon/os-cron-deps.js +134 -0
  38. package/dist/heart/daemon/ouro-bot-global-installer.js +128 -0
  39. package/dist/heart/daemon/ouro-path-installer.js +78 -34
  40. package/dist/heart/daemon/ouro-version-manager.js +171 -0
  41. package/dist/heart/daemon/outlook-http.js +439 -0
  42. package/dist/heart/daemon/outlook-read.js +1618 -0
  43. package/dist/heart/daemon/outlook-render.js +1032 -0
  44. package/dist/heart/daemon/outlook-types.js +7 -0
  45. package/dist/heart/daemon/outlook-view.js +194 -0
  46. package/dist/heart/daemon/process-manager.js +93 -0
  47. package/dist/heart/daemon/run-hooks.js +39 -0
  48. package/dist/heart/daemon/runtime-logging.js +58 -15
  49. package/dist/heart/daemon/runtime-metadata.js +101 -0
  50. package/dist/heart/daemon/runtime-mode.js +67 -0
  51. package/dist/heart/daemon/safe-mode.js +161 -0
  52. package/dist/heart/daemon/sense-manager.js +50 -2
  53. package/dist/heart/daemon/session-id-resolver.js +131 -0
  54. package/dist/heart/daemon/skill-management-installer.js +94 -0
  55. package/dist/heart/daemon/socket-client.js +202 -0
  56. package/dist/heart/daemon/specialist-prompt.js +10 -7
  57. package/dist/heart/daemon/specialist-tools.js +49 -3
  58. package/dist/heart/daemon/staged-restart.js +138 -0
  59. package/dist/heart/daemon/task-scheduler.js +3 -25
  60. package/dist/heart/daemon/thoughts.js +507 -0
  61. package/dist/heart/daemon/update-checker.js +111 -0
  62. package/dist/heart/daemon/update-hooks.js +138 -0
  63. package/dist/heart/daemon/wrapper-publish-guard.js +86 -0
  64. package/dist/heart/delegation.js +62 -0
  65. package/dist/heart/identity.js +147 -55
  66. package/dist/heart/intentions.js +173 -0
  67. package/dist/heart/kicks.js +2 -20
  68. package/dist/heart/migrate-config.js +127 -0
  69. package/dist/heart/model-capabilities.js +48 -0
  70. package/dist/heart/obligations.js +225 -0
  71. package/dist/heart/presence.js +185 -0
  72. package/dist/heart/progress-story.js +42 -0
  73. package/dist/heart/provider-failover.js +88 -0
  74. package/dist/heart/provider-ping.js +178 -0
  75. package/dist/heart/providers/anthropic-token.js +163 -0
  76. package/dist/heart/providers/anthropic.js +187 -41
  77. package/dist/heart/providers/azure.js +116 -10
  78. package/dist/heart/providers/github-copilot.js +157 -0
  79. package/dist/heart/providers/minimax.js +33 -3
  80. package/dist/heart/providers/openai-codex.js +51 -16
  81. package/dist/heart/session-activity.js +172 -0
  82. package/dist/heart/session-recall.js +216 -0
  83. package/dist/heart/start-of-turn-packet.js +232 -0
  84. package/dist/heart/streaming.js +36 -27
  85. package/dist/heart/sync.js +217 -0
  86. package/dist/heart/target-resolution.js +127 -0
  87. package/dist/heart/tempo.js +93 -0
  88. package/dist/heart/temporal-view.js +41 -0
  89. package/dist/heart/tool-activity-callbacks.js +36 -0
  90. package/dist/heart/tool-description.js +135 -0
  91. package/dist/heart/tool-loop.js +200 -0
  92. package/dist/heart/turn-coordinator.js +28 -0
  93. package/dist/mind/associative-recall.js +122 -32
  94. package/dist/mind/bundle-manifest.js +19 -1
  95. package/dist/mind/context.js +125 -14
  96. package/dist/mind/{memory.js → diary.js} +69 -56
  97. package/dist/mind/episodes.js +119 -0
  98. package/dist/mind/file-state.js +179 -0
  99. package/dist/mind/first-impressions.js +16 -2
  100. package/dist/mind/friends/channel.js +56 -0
  101. package/dist/mind/friends/group-context.js +144 -0
  102. package/dist/mind/friends/store-file.js +36 -0
  103. package/dist/mind/friends/trust-explanation.js +74 -0
  104. package/dist/mind/friends/types.js +8 -0
  105. package/dist/mind/journal-index.js +161 -0
  106. package/dist/mind/obligation-steering.js +221 -0
  107. package/dist/mind/obligations.js +138 -0
  108. package/dist/mind/pending.js +76 -9
  109. package/dist/mind/phrases.js +1 -0
  110. package/dist/mind/prompt.js +785 -103
  111. package/dist/mind/scrutiny.js +173 -0
  112. package/dist/mind/token-estimate.js +8 -12
  113. package/dist/nerves/coverage/audit.js +1 -1
  114. package/dist/nerves/coverage/run-artifacts.js +1 -1
  115. package/dist/nerves/event-buffer.js +111 -0
  116. package/dist/nerves/index.js +63 -3
  117. package/dist/nerves/observation.js +20 -0
  118. package/dist/nerves/runtime.js +5 -1
  119. package/dist/outlook-ui/assets/index-Ck8agNeO.js +61 -0
  120. package/dist/outlook-ui/assets/index-LwChZTgL.css +1 -0
  121. package/dist/outlook-ui/index.html +15 -0
  122. package/dist/repertoire/ado-semantic.js +11 -5
  123. package/dist/repertoire/coding/codex-jsonl.js +64 -0
  124. package/dist/repertoire/coding/context-pack.js +330 -0
  125. package/dist/repertoire/coding/feedback.js +197 -30
  126. package/dist/repertoire/coding/manager.js +149 -2
  127. package/dist/repertoire/coding/spawner.js +55 -9
  128. package/dist/repertoire/coding/tools.js +170 -7
  129. package/dist/repertoire/guardrails.js +291 -0
  130. package/dist/repertoire/mcp-client.js +254 -0
  131. package/dist/repertoire/mcp-manager.js +251 -0
  132. package/dist/repertoire/shell-sessions.js +133 -0
  133. package/dist/repertoire/skills.js +14 -23
  134. package/dist/repertoire/tasks/board.js +43 -5
  135. package/dist/repertoire/tasks/fix.js +182 -0
  136. package/dist/repertoire/tasks/index.js +28 -10
  137. package/dist/repertoire/tasks/lifecycle.js +2 -2
  138. package/dist/repertoire/tasks/parser.js +3 -2
  139. package/dist/repertoire/tasks/scanner.js +194 -37
  140. package/dist/repertoire/tasks/transitions.js +11 -28
  141. package/dist/repertoire/tools-base.js +1345 -320
  142. package/dist/repertoire/tools-bluebubbles.js +94 -0
  143. package/dist/repertoire/tools-github.js +1 -6
  144. package/dist/repertoire/tools-teams.js +12 -59
  145. package/dist/repertoire/tools.js +318 -124
  146. package/dist/scripts/claude-code-hook.js +41 -0
  147. package/dist/scripts/claude-code-stop-hook.js +47 -0
  148. package/dist/senses/attention-queue.js +97 -0
  149. package/dist/senses/bluebubbles-client.js +102 -3
  150. package/dist/senses/bluebubbles-entry.js +2 -0
  151. package/dist/senses/bluebubbles-inbound-log.js +109 -0
  152. package/dist/senses/bluebubbles-media.js +118 -23
  153. package/dist/senses/bluebubbles-model.js +12 -4
  154. package/dist/senses/bluebubbles-mutation-log.js +45 -5
  155. package/dist/senses/bluebubbles-runtime-state.js +109 -0
  156. package/dist/senses/bluebubbles-session-cleanup.js +72 -0
  157. package/dist/senses/bluebubbles.js +1008 -102
  158. package/dist/senses/cli/adapter.js +274 -0
  159. package/dist/senses/cli/ink-app.js +156 -0
  160. package/dist/senses/cli/inline-diff.js +64 -0
  161. package/dist/senses/cli/message-list.js +51 -0
  162. package/dist/senses/cli/ouro-tui.js +349 -0
  163. package/dist/senses/cli/spinner-imperative.js +135 -0
  164. package/dist/senses/cli/spinner.js +101 -0
  165. package/dist/senses/cli/status-line.js +60 -0
  166. package/dist/senses/cli/streaming-markdown.js +526 -0
  167. package/dist/senses/cli/tool-display.js +83 -0
  168. package/dist/senses/cli/tool-render.js +85 -0
  169. package/dist/senses/cli/tui-store.js +198 -0
  170. package/dist/senses/cli/virtual-list.js +35 -0
  171. package/dist/senses/cli-entry.js +1 -1
  172. package/dist/senses/cli-layout.js +187 -0
  173. package/dist/senses/cli.js +508 -243
  174. package/dist/senses/commands.js +65 -1
  175. package/dist/senses/continuity.js +94 -0
  176. package/dist/senses/habit-turn-message.js +108 -0
  177. package/dist/senses/inner-dialog-worker.js +112 -19
  178. package/dist/senses/inner-dialog.js +592 -84
  179. package/dist/senses/pipeline.js +693 -0
  180. package/dist/senses/shared-turn.js +196 -0
  181. package/dist/senses/surface-tool.js +95 -0
  182. package/dist/senses/teams.js +667 -120
  183. package/dist/senses/trust-gate.js +112 -2
  184. package/package.json +16 -6
  185. package/skills/configure-dev-tools.md +81 -0
  186. package/subagents/README.md +4 -70
  187. package/dist/heart/daemon/subagent-installer.js +0 -134
  188. package/dist/senses/debug-activity.js +0 -107
  189. package/subagents/work-doer.md +0 -235
  190. package/subagents/work-merger.md +0 -618
  191. package/subagents/work-planner.md +0 -382
  192. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/basilisk.md +0 -0
  193. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jafar.md +0 -0
  194. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jormungandr.md +0 -0
  195. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/kaa.md +0 -0
  196. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/medusa.md +0 -0
  197. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +0 -0
  198. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/nagini.md +0 -0
  199. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/ouroboros.md +0 -0
  200. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/python.md +0 -0
  201. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/quetzalcoatl.md +0 -0
  202. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/sir-hiss.md +0 -0
  203. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +0 -0
  204. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-snake.md +0 -0
@@ -0,0 +1,173 @@
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.captureIntention = captureIntention;
37
+ exports.readOpenIntentions = readOpenIntentions;
38
+ exports.resolveIntention = resolveIntention;
39
+ exports.dismissIntention = dismissIntention;
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ const runtime_1 = require("../nerves/runtime");
43
+ const sync_1 = require("./sync");
44
+ function intentionsDir(agentRoot) {
45
+ return path.join(agentRoot, "arc", "intentions");
46
+ }
47
+ function intentionFilePath(agentRoot, id) {
48
+ return path.join(intentionsDir(agentRoot), `${id}.json`);
49
+ }
50
+ function generateId() {
51
+ const timestamp = Date.now();
52
+ const random = Math.random().toString(36).slice(2, 10);
53
+ return `int-${timestamp}-${random}`;
54
+ }
55
+ const SALIENCE_ORDER = {
56
+ high: 3,
57
+ medium: 2,
58
+ low: 1,
59
+ };
60
+ function salienceRank(salience) {
61
+ if (!salience)
62
+ return 0;
63
+ return SALIENCE_ORDER[salience] ?? 0;
64
+ }
65
+ function captureIntention(agentRoot, input) {
66
+ const now = new Date().toISOString();
67
+ const id = generateId();
68
+ const intention = {
69
+ id,
70
+ content: input.content,
71
+ status: "open",
72
+ createdAt: now,
73
+ updatedAt: now,
74
+ ...(input.salience ? { salience: input.salience } : {}),
75
+ source: input.source,
76
+ ...(input.relatedFriendId ? { relatedFriendId: input.relatedFriendId } : {}),
77
+ ...(input.relatedObligationId ? { relatedObligationId: input.relatedObligationId } : {}),
78
+ ...(input.relatedCareId ? { relatedCareId: input.relatedCareId } : {}),
79
+ ...(input.nudgeAfter ? { nudgeAfter: input.nudgeAfter } : {}),
80
+ };
81
+ const dir = intentionsDir(agentRoot);
82
+ fs.mkdirSync(dir, { recursive: true });
83
+ const filePath = intentionFilePath(agentRoot, id);
84
+ fs.writeFileSync(filePath, JSON.stringify(intention, null, 2), "utf-8");
85
+ (0, sync_1.trackSyncWrite)(filePath);
86
+ (0, runtime_1.emitNervesEvent)({
87
+ component: "heart",
88
+ event: "heart.intention_captured",
89
+ message: `intention captured: ${input.content.slice(0, 60)}`,
90
+ meta: { intentionId: id, source: input.source, salience: input.salience },
91
+ });
92
+ return intention;
93
+ }
94
+ function readOpenIntentions(agentRoot, options) {
95
+ const dir = intentionsDir(agentRoot);
96
+ if (!fs.existsSync(dir)) {
97
+ (0, runtime_1.emitNervesEvent)({
98
+ component: "heart",
99
+ event: "heart.intentions_read",
100
+ message: "read intentions: directory missing, returning empty",
101
+ meta: { count: 0 },
102
+ });
103
+ return [];
104
+ }
105
+ const limit = options?.limit ?? 20;
106
+ const files = fs.readdirSync(dir).filter((f) => f.endsWith(".json"));
107
+ const intentions = [];
108
+ for (const file of files) {
109
+ try {
110
+ const content = fs.readFileSync(path.join(dir, file), "utf-8");
111
+ const intention = JSON.parse(content);
112
+ if (intention.status === "open") {
113
+ intentions.push(intention);
114
+ }
115
+ }
116
+ catch {
117
+ // Skip malformed JSON files
118
+ }
119
+ }
120
+ // Sort by salience descending, then createdAt descending
121
+ intentions.sort((a, b) => {
122
+ const salienceDiff = salienceRank(b.salience) - salienceRank(a.salience);
123
+ if (salienceDiff !== 0)
124
+ return salienceDiff;
125
+ return b.createdAt.localeCompare(a.createdAt);
126
+ });
127
+ const result = intentions.slice(0, limit);
128
+ (0, runtime_1.emitNervesEvent)({
129
+ component: "heart",
130
+ event: "heart.intentions_read",
131
+ message: `read ${result.length} open intentions`,
132
+ meta: { count: result.length, total: intentions.length, limit },
133
+ });
134
+ return result;
135
+ }
136
+ function readIntentionFile(agentRoot, id) {
137
+ const filePath = intentionFilePath(agentRoot, id);
138
+ if (!fs.existsSync(filePath)) {
139
+ throw new Error(`Intention not found: ${id}`);
140
+ }
141
+ return JSON.parse(fs.readFileSync(filePath, "utf-8"));
142
+ }
143
+ function writeIntentionFile(agentRoot, intention) {
144
+ const filePath = intentionFilePath(agentRoot, intention.id);
145
+ fs.writeFileSync(filePath, JSON.stringify(intention, null, 2), "utf-8");
146
+ (0, sync_1.trackSyncWrite)(filePath);
147
+ }
148
+ function resolveIntention(agentRoot, id) {
149
+ const intention = readIntentionFile(agentRoot, id);
150
+ intention.status = "done";
151
+ intention.updatedAt = new Date().toISOString();
152
+ writeIntentionFile(agentRoot, intention);
153
+ (0, runtime_1.emitNervesEvent)({
154
+ component: "heart",
155
+ event: "heart.intention_resolved",
156
+ message: `intention resolved: ${intention.content.slice(0, 60)}`,
157
+ meta: { intentionId: id },
158
+ });
159
+ return intention;
160
+ }
161
+ function dismissIntention(agentRoot, id) {
162
+ const intention = readIntentionFile(agentRoot, id);
163
+ intention.status = "dismissed";
164
+ intention.updatedAt = new Date().toISOString();
165
+ writeIntentionFile(agentRoot, intention);
166
+ (0, runtime_1.emitNervesEvent)({
167
+ component: "heart",
168
+ event: "heart.intention_dismissed",
169
+ message: `intention dismissed: ${intention.content.slice(0, 60)}`,
170
+ meta: { intentionId: id },
171
+ });
172
+ return intention;
173
+ }
@@ -1,28 +1,11 @@
1
1
  "use strict";
2
- // TODO: Kicks enforce "any action" but not "meaningful action". After a narration
3
- // kick, the model can satisfy the constraint by calling a no-op tool like
4
- // get_current_time({}). We need to detect trivial compliance and either re-kick
5
- // or discount the tool call. Ideally, the kick message would suggest a specific
6
- // tool call based on conversation context (what the user asked, what tools are
7
- // relevant) rather than just saying "call a tool". That's a bigger piece of work —
8
- // it requires the kick system to be context-aware.
9
- // See ouroboros' observation: "i'm not chickening out. i'm satisfying a crude
10
- // constraint. poorly."
11
- //
12
- // A kick is a self-correction. When the harness detects a malformed response,
13
- // it injects an assistant-role message as if the model caught its own mistake.
14
- //
15
- // Kicks are:
16
- // - assistant role (self-correction, not external rebuke)
17
- // - first person ("I" not "you")
18
- // - forward-looking (what I'm doing next, not what I did wrong)
19
- // - short (one sentence)
20
2
  Object.defineProperty(exports, "__esModule", { value: true });
21
3
  exports.hasToolIntent = hasToolIntent;
22
4
  exports.detectKick = detectKick;
5
+ const runtime_1 = require("../nerves/runtime");
23
6
  const KICK_MESSAGES = {
24
7
  empty: "I sent an empty message by accident — let me try again.",
25
- narration: "I narrated instead of acting. Using the tool now -- if done, calling final_answer.",
8
+ narration: "I narrated instead of acting. Using the tool now -- if done, calling settle.",
26
9
  tool_required: "tool-required is on — I need to call a tool. use /tool-required to turn it off.",
27
10
  };
28
11
  const TOOL_INTENT_PATTERNS = [
@@ -141,4 +124,3 @@ function detectKick(content, options) {
141
124
  }
142
125
  return null;
143
126
  }
144
- const runtime_1 = require("../nerves/runtime");
@@ -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,48 @@
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
+ },
12
+ "claude-sonnet-4-6": {
13
+ reasoningEffort: ["low", "medium", "high"],
14
+ thinkingFormat: "anthropic",
15
+ maxOutputTokens: 64000,
16
+ },
17
+ "claude-opus-4.6": {
18
+ reasoningEffort: ["low", "medium", "high", "max"],
19
+ maxOutputTokens: 128000,
20
+ },
21
+ "claude-sonnet-4.6": {
22
+ reasoningEffort: ["low", "medium", "high"],
23
+ maxOutputTokens: 64000,
24
+ },
25
+ "gpt-5.4": {
26
+ reasoningEffort: ["low", "medium", "high"],
27
+ phase: true,
28
+ maxOutputTokens: 100000,
29
+ },
30
+ "gpt-5.3-codex": {
31
+ reasoningEffort: ["low", "medium", "high"],
32
+ phase: true,
33
+ maxOutputTokens: 100000,
34
+ },
35
+ };
36
+ const EMPTY_CAPABILITIES = Object.freeze({});
37
+ function getModelCapabilities(modelId) {
38
+ (0, runtime_1.emitNervesEvent)({
39
+ component: "engine",
40
+ event: "engine.model_capabilities_lookup",
41
+ message: `model capabilities lookup: ${modelId}`,
42
+ meta: { modelId, found: modelId in exports.MODEL_CAPABILITIES },
43
+ });
44
+ const entry = exports.MODEL_CAPABILITIES[modelId];
45
+ if (entry)
46
+ return entry;
47
+ return { ...EMPTY_CAPABILITIES };
48
+ }
@@ -0,0 +1,225 @@
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.isOpenObligationStatus = isOpenObligationStatus;
37
+ exports.isOpenObligation = isOpenObligation;
38
+ exports.createObligation = createObligation;
39
+ exports.readObligations = readObligations;
40
+ exports.readPendingObligations = readPendingObligations;
41
+ exports.advanceObligation = advanceObligation;
42
+ exports.fulfillObligation = fulfillObligation;
43
+ exports.findPendingObligationForOrigin = findPendingObligationForOrigin;
44
+ exports.enrichObligation = enrichObligation;
45
+ const fs = __importStar(require("fs"));
46
+ const path = __importStar(require("path"));
47
+ const runtime_1 = require("../nerves/runtime");
48
+ const sync_1 = require("./sync");
49
+ function obligationsDir(agentRoot) {
50
+ return path.join(agentRoot, "arc", "obligations");
51
+ }
52
+ function obligationFilePath(agentRoot, id) {
53
+ return path.join(obligationsDir(agentRoot), `${id}.json`);
54
+ }
55
+ function generateId() {
56
+ const timestamp = Date.now();
57
+ const random = Math.random().toString(36).slice(2, 10);
58
+ return `${timestamp}-${random}`;
59
+ }
60
+ function isOpenObligationStatus(status) {
61
+ return status !== "fulfilled";
62
+ }
63
+ function isOpenObligation(obligation) {
64
+ return isOpenObligationStatus(obligation.status);
65
+ }
66
+ function createObligation(agentRoot, input) {
67
+ const now = new Date().toISOString();
68
+ const id = generateId();
69
+ const obligation = {
70
+ id,
71
+ origin: input.origin,
72
+ ...(input.bridgeId ? { bridgeId: input.bridgeId } : {}),
73
+ content: input.content,
74
+ status: "pending",
75
+ createdAt: now,
76
+ updatedAt: now,
77
+ };
78
+ const dir = obligationsDir(agentRoot);
79
+ fs.mkdirSync(dir, { recursive: true });
80
+ const filePath = obligationFilePath(agentRoot, id);
81
+ fs.writeFileSync(filePath, JSON.stringify(obligation, null, 2), "utf-8");
82
+ (0, sync_1.trackSyncWrite)(filePath);
83
+ (0, runtime_1.emitNervesEvent)({
84
+ component: "engine",
85
+ event: "engine.obligation_created",
86
+ message: "obligation created",
87
+ meta: {
88
+ obligationId: id,
89
+ friendId: input.origin.friendId,
90
+ channel: input.origin.channel,
91
+ key: input.origin.key,
92
+ },
93
+ });
94
+ return obligation;
95
+ }
96
+ function readObligations(agentRoot) {
97
+ const dir = obligationsDir(agentRoot);
98
+ if (!fs.existsSync(dir))
99
+ return [];
100
+ let entries;
101
+ try {
102
+ entries = fs.readdirSync(dir);
103
+ }
104
+ catch {
105
+ /* v8 ignore next -- defensive: readdirSync race after existsSync @preserve */
106
+ return [];
107
+ }
108
+ const jsonFiles = entries.filter((entry) => entry.endsWith(".json")).sort();
109
+ const obligations = [];
110
+ for (const file of jsonFiles) {
111
+ try {
112
+ const raw = fs.readFileSync(path.join(dir, file), "utf-8");
113
+ const parsed = JSON.parse(raw);
114
+ if (typeof parsed.id === "string" && typeof parsed.content === "string") {
115
+ obligations.push(parsed);
116
+ }
117
+ }
118
+ catch {
119
+ // skip malformed files
120
+ }
121
+ }
122
+ return obligations;
123
+ }
124
+ function readPendingObligations(agentRoot) {
125
+ return readObligations(agentRoot).filter(isOpenObligation);
126
+ }
127
+ function advanceObligation(agentRoot, obligationId, update) {
128
+ const filePath = obligationFilePath(agentRoot, obligationId);
129
+ let obligation;
130
+ try {
131
+ const raw = fs.readFileSync(filePath, "utf-8");
132
+ obligation = JSON.parse(raw);
133
+ }
134
+ catch {
135
+ return;
136
+ }
137
+ const previousStatus = obligation.status;
138
+ if (update.status) {
139
+ obligation.status = update.status;
140
+ if (update.status === "fulfilled") {
141
+ obligation.fulfilledAt = new Date().toISOString();
142
+ }
143
+ }
144
+ if (update.currentSurface) {
145
+ obligation.currentSurface = update.currentSurface;
146
+ }
147
+ if (typeof update.currentArtifact === "string") {
148
+ obligation.currentArtifact = update.currentArtifact;
149
+ }
150
+ if (typeof update.nextAction === "string") {
151
+ obligation.nextAction = update.nextAction;
152
+ }
153
+ if (typeof update.latestNote === "string") {
154
+ obligation.latestNote = update.latestNote;
155
+ }
156
+ obligation.updatedAt = new Date().toISOString();
157
+ fs.writeFileSync(filePath, JSON.stringify(obligation, null, 2), "utf-8");
158
+ (0, sync_1.trackSyncWrite)(filePath);
159
+ (0, runtime_1.emitNervesEvent)({
160
+ component: "engine",
161
+ event: "engine.obligation_advanced",
162
+ message: "obligation advanced",
163
+ meta: {
164
+ obligationId,
165
+ previousStatus,
166
+ status: obligation.status,
167
+ friendId: obligation.origin.friendId,
168
+ channel: obligation.origin.channel,
169
+ key: obligation.origin.key,
170
+ surfaceKind: obligation.currentSurface?.kind ?? null,
171
+ surfaceLabel: obligation.currentSurface?.label ?? null,
172
+ },
173
+ });
174
+ }
175
+ function fulfillObligation(agentRoot, obligationId) {
176
+ advanceObligation(agentRoot, obligationId, { status: "fulfilled" });
177
+ const filePath = obligationFilePath(agentRoot, obligationId);
178
+ let obligation;
179
+ try {
180
+ const raw = fs.readFileSync(filePath, "utf-8");
181
+ obligation = JSON.parse(raw);
182
+ }
183
+ catch {
184
+ return;
185
+ }
186
+ (0, runtime_1.emitNervesEvent)({
187
+ component: "engine",
188
+ event: "engine.obligation_fulfilled",
189
+ message: "obligation fulfilled",
190
+ meta: {
191
+ obligationId,
192
+ friendId: obligation.origin.friendId,
193
+ channel: obligation.origin.channel,
194
+ key: obligation.origin.key,
195
+ },
196
+ });
197
+ }
198
+ function findPendingObligationForOrigin(agentRoot, origin) {
199
+ return readPendingObligations(agentRoot).find((ob) => ob.origin.friendId === origin.friendId
200
+ && ob.origin.channel === origin.channel
201
+ && ob.origin.key === origin.key);
202
+ }
203
+ function enrichObligation(agentRoot, id, meaning) {
204
+ const filePath = obligationFilePath(agentRoot, id);
205
+ if (!fs.existsSync(filePath)) {
206
+ throw new Error(`Obligation not found: ${id}`);
207
+ }
208
+ const raw = fs.readFileSync(filePath, "utf-8");
209
+ const obligation = JSON.parse(raw);
210
+ obligation.meaning = meaning;
211
+ obligation.updatedAt = new Date().toISOString();
212
+ fs.writeFileSync(filePath, JSON.stringify(obligation, null, 2), "utf-8");
213
+ (0, sync_1.trackSyncWrite)(filePath);
214
+ (0, runtime_1.emitNervesEvent)({
215
+ component: "engine",
216
+ event: "engine.obligation_enriched",
217
+ message: "obligation enriched with meaning",
218
+ meta: {
219
+ obligationId: id,
220
+ salience: meaning.salience,
221
+ stalenessClass: meaning.stalenessClass,
222
+ },
223
+ });
224
+ return obligation;
225
+ }