@ouro.bot/cli 0.1.0-alpha.3 → 0.1.0-alpha.300

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 (289) hide show
  1. package/README.md +188 -190
  2. package/SerpentGuide.ouro/agent.json +82 -0
  3. package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/SOUL.md +6 -3
  4. package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +2 -2
  5. package/SerpentGuide.ouro/psyche/identities/python.md +31 -0
  6. package/assets/ouroboros.png +0 -0
  7. package/changelog.json +1888 -0
  8. package/dist/arc/attention-types.js +8 -0
  9. package/dist/arc/cares.js +140 -0
  10. package/dist/arc/episodes.js +117 -0
  11. package/dist/arc/intentions.js +133 -0
  12. package/dist/arc/json-store.js +117 -0
  13. package/dist/arc/obligations.js +237 -0
  14. package/dist/arc/packets.js +203 -0
  15. package/dist/arc/presence.js +185 -0
  16. package/dist/heart/active-work.js +832 -0
  17. package/dist/heart/agent-entry.js +37 -2
  18. package/dist/heart/attachments/image-normalize.js +194 -0
  19. package/dist/heart/attachments/materialize.js +230 -0
  20. package/dist/heart/attachments/render.js +29 -0
  21. package/dist/heart/attachments/store.js +103 -0
  22. package/dist/heart/attachments/types.js +138 -0
  23. package/dist/heart/auth/auth-flow.js +456 -0
  24. package/dist/heart/bridges/manager.js +358 -0
  25. package/dist/heart/bridges/state-machine.js +135 -0
  26. package/dist/heart/bridges/store.js +123 -0
  27. package/dist/heart/bundle-state.js +168 -0
  28. package/dist/heart/commitments.js +111 -0
  29. package/dist/heart/config-registry.js +304 -0
  30. package/dist/heart/config.js +123 -28
  31. package/dist/heart/core.js +738 -191
  32. package/dist/heart/cross-chat-delivery.js +131 -0
  33. package/dist/heart/daemon/agent-config-check.js +149 -0
  34. package/dist/heart/daemon/agent-discovery.js +157 -0
  35. package/dist/heart/daemon/agent-service.js +360 -0
  36. package/dist/heart/daemon/cadence.js +70 -0
  37. package/dist/heart/daemon/cli-defaults.js +574 -0
  38. package/dist/heart/daemon/cli-exec.js +1945 -0
  39. package/dist/heart/daemon/cli-parse.js +808 -0
  40. package/dist/heart/daemon/cli-render.js +503 -0
  41. package/dist/heart/daemon/cli-types.js +8 -0
  42. package/dist/heart/daemon/daemon-cli.js +29 -673
  43. package/dist/heart/daemon/daemon-entry.js +259 -8
  44. package/dist/heart/daemon/daemon-health.js +136 -0
  45. package/dist/heart/daemon/daemon-runtime-sync.js +231 -0
  46. package/dist/heart/daemon/daemon-tombstone.js +236 -0
  47. package/dist/heart/daemon/daemon.js +745 -18
  48. package/dist/heart/daemon/health-monitor.js +38 -0
  49. package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
  50. package/dist/heart/daemon/hooks/bundle-meta.js +206 -0
  51. package/dist/heart/daemon/inner-status.js +89 -0
  52. package/dist/heart/daemon/launchd.js +171 -0
  53. package/dist/heart/daemon/log-tailer.js +82 -12
  54. package/dist/heart/daemon/logs-prune.js +105 -0
  55. package/dist/heart/daemon/message-router.js +17 -8
  56. package/dist/heart/daemon/os-cron-deps.js +134 -0
  57. package/dist/heart/daemon/ouro-bot-entry.js +1 -1
  58. package/dist/heart/daemon/process-manager.js +181 -1
  59. package/dist/heart/daemon/pulse.js +463 -0
  60. package/dist/heart/daemon/run-hooks.js +39 -0
  61. package/dist/heart/daemon/runtime-logging.js +70 -15
  62. package/dist/heart/daemon/runtime-metadata.js +219 -0
  63. package/dist/heart/daemon/runtime-mode.js +67 -0
  64. package/dist/heart/daemon/safe-mode.js +161 -0
  65. package/dist/heart/daemon/sense-manager.js +335 -0
  66. package/dist/heart/daemon/session-id-resolver.js +131 -0
  67. package/dist/heart/daemon/skill-management-installer.js +94 -0
  68. package/dist/heart/daemon/socket-client.js +307 -0
  69. package/dist/heart/daemon/task-scheduler.js +3 -25
  70. package/dist/heart/daemon/thoughts.js +510 -0
  71. package/dist/heart/delegation.js +62 -0
  72. package/dist/heart/habits/habit-migration.js +181 -0
  73. package/dist/heart/habits/habit-parser.js +140 -0
  74. package/dist/heart/habits/habit-scheduler.js +371 -0
  75. package/dist/heart/hatch/hatch-animation.js +35 -0
  76. package/dist/heart/{daemon → hatch}/hatch-flow.js +31 -130
  77. package/dist/heart/{daemon → hatch}/hatch-specialist.js +7 -2
  78. package/dist/heart/hatch/specialist-orchestrator.js +129 -0
  79. package/dist/heart/hatch/specialist-prompt.js +101 -0
  80. package/dist/heart/hatch/specialist-tools.js +283 -0
  81. package/dist/heart/identity.js +241 -54
  82. package/dist/heart/kicks.js +2 -20
  83. package/dist/heart/mcp/mcp-server.js +653 -0
  84. package/dist/heart/migrate-config.js +127 -0
  85. package/dist/heart/model-capabilities.js +59 -0
  86. package/dist/heart/outlook/outlook-http.js +439 -0
  87. package/dist/heart/outlook/outlook-read.js +1618 -0
  88. package/dist/heart/outlook/outlook-render.js +1032 -0
  89. package/dist/heart/outlook/outlook-types.js +7 -0
  90. package/dist/heart/outlook/outlook-view.js +194 -0
  91. package/dist/heart/progress-story.js +42 -0
  92. package/dist/heart/provider-failover.js +88 -0
  93. package/dist/heart/provider-ping.js +162 -0
  94. package/dist/heart/providers/anthropic-token.js +163 -0
  95. package/dist/heart/providers/anthropic.js +181 -41
  96. package/dist/heart/providers/azure.js +98 -11
  97. package/dist/heart/providers/error-classification.js +63 -0
  98. package/dist/heart/providers/github-copilot.js +136 -0
  99. package/dist/heart/providers/minimax-vlm.js +189 -0
  100. package/dist/heart/providers/minimax.js +23 -5
  101. package/dist/heart/providers/openai-codex.js +33 -22
  102. package/dist/heart/sense-truth.js +61 -0
  103. package/dist/heart/session-activity.js +172 -0
  104. package/dist/heart/session-recall.js +216 -0
  105. package/dist/heart/start-of-turn-packet.js +339 -0
  106. package/dist/heart/streaming.js +120 -33
  107. package/dist/heart/sync.js +332 -0
  108. package/dist/heart/target-resolution.js +127 -0
  109. package/dist/heart/tempo.js +93 -0
  110. package/dist/heart/temporal-view.js +41 -0
  111. package/dist/heart/tool-activity-callbacks.js +36 -0
  112. package/dist/heart/tool-description.js +135 -0
  113. package/dist/heart/tool-friction.js +55 -0
  114. package/dist/heart/tool-loop.js +200 -0
  115. package/dist/heart/turn-context.js +358 -0
  116. package/dist/heart/turn-coordinator.js +28 -0
  117. package/dist/heart/versioning/ouro-bot-global-installer.js +128 -0
  118. package/dist/heart/{daemon → versioning}/ouro-bot-wrapper.js +5 -4
  119. package/dist/heart/versioning/ouro-path-installer.js +221 -0
  120. package/dist/heart/{daemon → versioning}/ouro-uti.js +11 -2
  121. package/dist/heart/versioning/ouro-version-manager.js +295 -0
  122. package/dist/heart/versioning/staged-restart.js +146 -0
  123. package/dist/heart/versioning/update-checker.js +113 -0
  124. package/dist/heart/versioning/update-hooks.js +142 -0
  125. package/dist/heart/versioning/wrapper-publish-guard.js +86 -0
  126. package/dist/mind/associative-recall.js +135 -66
  127. package/dist/mind/bundle-manifest.js +77 -1
  128. package/dist/mind/context.js +125 -14
  129. package/dist/mind/diary-integrity.js +60 -0
  130. package/dist/mind/{memory.js → diary.js} +84 -96
  131. package/dist/mind/embedding-provider.js +60 -0
  132. package/dist/mind/file-state.js +179 -0
  133. package/dist/mind/first-impressions.js +16 -2
  134. package/dist/mind/friends/channel.js +64 -0
  135. package/dist/mind/friends/group-context.js +144 -0
  136. package/dist/mind/friends/resolver.js +37 -0
  137. package/dist/mind/friends/store-file.js +58 -3
  138. package/dist/mind/friends/trust-explanation.js +74 -0
  139. package/dist/mind/friends/types.js +9 -1
  140. package/dist/mind/journal-index.js +161 -0
  141. package/dist/mind/obligation-steering.js +221 -0
  142. package/dist/mind/pending.js +76 -9
  143. package/dist/mind/phrases.js +1 -0
  144. package/dist/mind/prompt.js +1011 -107
  145. package/dist/mind/scrutiny.js +173 -0
  146. package/dist/mind/token-estimate.js +8 -12
  147. package/dist/nerves/cli-logging.js +22 -3
  148. package/dist/nerves/coverage/audit.js +1 -1
  149. package/dist/nerves/coverage/file-completeness.js +59 -5
  150. package/dist/nerves/coverage/run-artifacts.js +1 -1
  151. package/dist/nerves/event-buffer.js +111 -0
  152. package/dist/nerves/index.js +224 -4
  153. package/dist/nerves/observation.js +20 -0
  154. package/dist/nerves/redact.js +79 -0
  155. package/dist/nerves/runtime.js +5 -1
  156. package/dist/outlook-ui/assets/index-Ck8agNeO.js +61 -0
  157. package/dist/outlook-ui/assets/index-LwChZTgL.css +1 -0
  158. package/dist/outlook-ui/index.html +15 -0
  159. package/dist/repertoire/ado-client.js +17 -56
  160. package/dist/repertoire/ado-semantic.js +11 -10
  161. package/dist/repertoire/api-client.js +97 -0
  162. package/dist/repertoire/bitwarden-store.js +319 -0
  163. package/dist/repertoire/bundle-templates.js +72 -0
  164. package/dist/repertoire/bw-installer.js +79 -0
  165. package/dist/repertoire/coding/codex-jsonl.js +64 -0
  166. package/dist/repertoire/coding/context-pack.js +330 -0
  167. package/dist/repertoire/coding/feedback.js +301 -0
  168. package/dist/repertoire/coding/index.js +4 -1
  169. package/dist/repertoire/coding/manager.js +220 -13
  170. package/dist/repertoire/coding/spawner.js +58 -12
  171. package/dist/repertoire/coding/tools.js +209 -7
  172. package/dist/repertoire/commerce-errors.js +109 -0
  173. package/dist/repertoire/commerce-self-test.js +156 -0
  174. package/dist/repertoire/credential-access.js +527 -0
  175. package/dist/repertoire/data/ado-endpoints.json +188 -0
  176. package/dist/repertoire/duffel-client.js +185 -0
  177. package/dist/repertoire/github-client.js +14 -55
  178. package/dist/repertoire/graph-client.js +11 -52
  179. package/dist/repertoire/guardrails.js +375 -0
  180. package/dist/repertoire/mcp-client.js +255 -0
  181. package/dist/repertoire/mcp-manager.js +305 -0
  182. package/dist/repertoire/mcp-tools.js +63 -0
  183. package/dist/repertoire/shell-sessions.js +133 -0
  184. package/dist/repertoire/skills.js +14 -23
  185. package/dist/repertoire/stripe-client.js +131 -0
  186. package/dist/repertoire/tasks/board.js +43 -5
  187. package/dist/repertoire/tasks/fix.js +182 -0
  188. package/dist/repertoire/tasks/index.js +28 -10
  189. package/dist/repertoire/tasks/lifecycle.js +2 -2
  190. package/dist/repertoire/tasks/parser.js +3 -2
  191. package/dist/repertoire/tasks/scanner.js +194 -37
  192. package/dist/repertoire/tasks/transitions.js +11 -28
  193. package/dist/repertoire/tool-results.js +29 -0
  194. package/dist/repertoire/tools-attachments.js +316 -0
  195. package/dist/repertoire/tools-base.js +45 -707
  196. package/dist/repertoire/tools-bluebubbles.js +94 -0
  197. package/dist/repertoire/tools-bridge.js +141 -0
  198. package/dist/repertoire/tools-bundle.js +984 -0
  199. package/dist/repertoire/tools-config.js +185 -0
  200. package/dist/repertoire/tools-continuity.js +248 -0
  201. package/dist/repertoire/tools-credential.js +182 -0
  202. package/dist/repertoire/tools-files.js +342 -0
  203. package/dist/repertoire/tools-flight.js +224 -0
  204. package/dist/repertoire/tools-flow.js +105 -0
  205. package/dist/repertoire/tools-github.js +1 -7
  206. package/dist/repertoire/tools-memory.js +374 -0
  207. package/dist/repertoire/tools-session.js +739 -0
  208. package/dist/repertoire/tools-shell.js +120 -0
  209. package/dist/repertoire/tools-stripe.js +180 -0
  210. package/dist/repertoire/tools-surface.js +243 -0
  211. package/dist/repertoire/tools-teams.js +64 -61
  212. package/dist/repertoire/tools-travel.js +125 -0
  213. package/dist/repertoire/tools-user-profile.js +144 -0
  214. package/dist/repertoire/tools-vault.js +110 -0
  215. package/dist/repertoire/tools.js +149 -98
  216. package/dist/repertoire/travel-api-client.js +360 -0
  217. package/dist/repertoire/user-profile.js +118 -0
  218. package/dist/repertoire/vault-setup.js +241 -0
  219. package/dist/scripts/claude-code-hook.js +41 -0
  220. package/dist/scripts/claude-code-stop-hook.js +47 -0
  221. package/dist/senses/attention-queue.js +116 -0
  222. package/dist/senses/bluebubbles/attachment-cache.js +53 -0
  223. package/dist/senses/bluebubbles/attachment-download.js +137 -0
  224. package/dist/senses/bluebubbles/client.js +568 -0
  225. package/dist/senses/bluebubbles/entry.js +13 -0
  226. package/dist/senses/bluebubbles/inbound-log.js +113 -0
  227. package/dist/senses/bluebubbles/index.js +1427 -0
  228. package/dist/senses/bluebubbles/media.js +390 -0
  229. package/dist/senses/bluebubbles/model.js +282 -0
  230. package/dist/senses/bluebubbles/mutation-log.js +116 -0
  231. package/dist/senses/bluebubbles/replay.js +129 -0
  232. package/dist/senses/bluebubbles/runtime-state.js +109 -0
  233. package/dist/senses/bluebubbles/session-cleanup.js +72 -0
  234. package/dist/senses/cli/bracketed-paste.js +82 -0
  235. package/dist/senses/cli/image-paste.js +287 -0
  236. package/dist/senses/cli/image-ref-navigation.js +75 -0
  237. package/dist/senses/cli/ink-app.js +156 -0
  238. package/dist/senses/cli/inline-diff.js +64 -0
  239. package/dist/senses/cli/input-keys.js +174 -0
  240. package/dist/senses/cli/kill-ring.js +86 -0
  241. package/dist/senses/cli/message-list.js +51 -0
  242. package/dist/senses/cli/ouro-tui.js +595 -0
  243. package/dist/senses/cli/spinner-imperative.js +135 -0
  244. package/dist/senses/cli/spinner.js +101 -0
  245. package/dist/senses/cli/status-line.js +60 -0
  246. package/dist/senses/cli/streaming-markdown.js +526 -0
  247. package/dist/senses/cli/tool-display.js +83 -0
  248. package/dist/senses/cli/tool-render.js +85 -0
  249. package/dist/senses/cli/tui-store.js +240 -0
  250. package/dist/senses/cli/virtual-list.js +35 -0
  251. package/dist/senses/cli-entry.js +1 -1
  252. package/dist/senses/cli-layout.js +187 -0
  253. package/dist/senses/cli.js +772 -264
  254. package/dist/senses/commands.js +65 -1
  255. package/dist/senses/continuity.js +94 -0
  256. package/dist/senses/habit-turn-message.js +108 -0
  257. package/dist/senses/inner-dialog-worker.js +112 -19
  258. package/dist/senses/inner-dialog.js +633 -86
  259. package/dist/senses/pipeline.js +560 -0
  260. package/dist/senses/shared-turn.js +195 -0
  261. package/dist/senses/surface-tool.js +68 -0
  262. package/dist/senses/teams.js +814 -196
  263. package/dist/senses/trust-gate.js +112 -2
  264. package/package.json +25 -9
  265. package/skills/agent-commerce.md +106 -0
  266. package/skills/browser-navigation.md +110 -0
  267. package/skills/commerce-setup-guide.md +116 -0
  268. package/skills/commerce-setup.md +84 -0
  269. package/skills/configure-dev-tools.md +81 -0
  270. package/skills/travel-planning.md +138 -0
  271. package/AdoptionSpecialist.ouro/agent.json +0 -20
  272. package/AdoptionSpecialist.ouro/psyche/identities/python.md +0 -1
  273. package/dist/heart/daemon/subagent-installer.js +0 -125
  274. package/dist/inner-worker-entry.js +0 -4
  275. package/subagents/README.md +0 -73
  276. package/subagents/work-doer.md +0 -233
  277. package/subagents/work-merger.md +0 -624
  278. package/subagents/work-planner.md +0 -373
  279. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/basilisk.md +0 -0
  280. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jafar.md +0 -0
  281. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jormungandr.md +0 -0
  282. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/kaa.md +0 -0
  283. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/medusa.md +0 -0
  284. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/nagini.md +0 -0
  285. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/ouroboros.md +0 -0
  286. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/quetzalcoatl.md +0 -0
  287. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/sir-hiss.md +0 -0
  288. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +0 -0
  289. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-snake.md +0 -0
@@ -35,63 +35,91 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.loadConfig = loadConfig;
37
37
  exports.resetConfigCache = resetConfigCache;
38
- exports.setTestConfig = setTestConfig;
38
+ exports.patchRuntimeConfig = patchRuntimeConfig;
39
39
  exports.getAzureConfig = getAzureConfig;
40
40
  exports.getMinimaxConfig = getMinimaxConfig;
41
41
  exports.getAnthropicConfig = getAnthropicConfig;
42
42
  exports.getOpenAICodexConfig = getOpenAICodexConfig;
43
+ exports.getGithubCopilotConfig = getGithubCopilotConfig;
44
+ exports.getProviderConfig = getProviderConfig;
43
45
  exports.getTeamsConfig = getTeamsConfig;
46
+ exports.getTeamsSecondaryConfig = getTeamsSecondaryConfig;
44
47
  exports.getContextConfig = getContextConfig;
45
48
  exports.getOAuthConfig = getOAuthConfig;
49
+ exports.resolveOAuthForTenant = resolveOAuthForTenant;
46
50
  exports.getTeamsChannelConfig = getTeamsChannelConfig;
51
+ exports.getBlueBubblesConfig = getBlueBubblesConfig;
52
+ exports.getBlueBubblesChannelConfig = getBlueBubblesChannelConfig;
47
53
  exports.getIntegrationsConfig = getIntegrationsConfig;
54
+ exports.getSyncConfig = getSyncConfig;
48
55
  exports.getOpenAIEmbeddingsApiKey = getOpenAIEmbeddingsApiKey;
49
56
  exports.getLogsDir = getLogsDir;
57
+ exports.sanitizeKey = sanitizeKey;
58
+ exports.slugify = slugify;
59
+ exports.resolveSessionPath = resolveSessionPath;
50
60
  exports.sessionPath = sessionPath;
51
61
  exports.logPath = logPath;
52
62
  const fs = __importStar(require("fs"));
53
63
  const path = __importStar(require("path"));
54
- const os = __importStar(require("os"));
55
64
  const identity_1 = require("./identity");
56
65
  const runtime_1 = require("../nerves/runtime");
57
66
  const DEFAULT_SECRETS_TEMPLATE = {
58
67
  providers: {
59
- // Keep provider field ordering consistent: model first, then auth credentials,
60
- // then provider-specific transport fields.
61
68
  azure: {
62
- modelName: "",
63
69
  apiKey: "",
64
70
  endpoint: "",
65
71
  deployment: "",
66
72
  apiVersion: "2025-04-01-preview",
73
+ managedIdentityClientId: "",
67
74
  },
68
75
  minimax: {
69
- model: "",
70
76
  apiKey: "",
71
77
  },
72
78
  anthropic: {
73
- model: "claude-opus-4-6",
74
79
  setupToken: "",
75
80
  },
76
81
  "openai-codex": {
77
- model: "gpt-5.2",
78
82
  oauthAccessToken: "",
79
83
  },
84
+ "github-copilot": {
85
+ githubToken: "",
86
+ baseUrl: "",
87
+ },
80
88
  },
81
89
  teams: {
82
90
  clientId: "",
83
91
  clientSecret: "",
84
92
  tenantId: "",
93
+ managedIdentityClientId: "",
85
94
  },
86
95
  oauth: {
87
96
  graphConnectionName: "graph",
88
97
  adoConnectionName: "ado",
89
98
  githubConnectionName: "",
90
99
  },
100
+ teamsSecondary: {
101
+ clientId: "",
102
+ clientSecret: "",
103
+ tenantId: "",
104
+ managedIdentityClientId: "",
105
+ },
91
106
  teamsChannel: {
92
107
  skipConfirmation: true,
93
108
  port: 3978,
94
109
  },
110
+ bluebubbles: {
111
+ serverUrl: "",
112
+ password: "",
113
+ accountId: "default",
114
+ },
115
+ bluebubblesChannel: {
116
+ port: 18790,
117
+ webhookPath: "/bluebubbles-webhook",
118
+ requestTimeoutMs: 30000,
119
+ },
120
+ vault: {
121
+ masterPassword: "",
122
+ },
95
123
  integrations: {
96
124
  perplexityApiKey: "",
97
125
  openaiEmbeddingsApiKey: "",
@@ -104,15 +132,20 @@ function defaultRuntimeConfig() {
104
132
  minimax: { ...DEFAULT_SECRETS_TEMPLATE.providers.minimax },
105
133
  anthropic: { ...DEFAULT_SECRETS_TEMPLATE.providers.anthropic },
106
134
  "openai-codex": { ...DEFAULT_SECRETS_TEMPLATE.providers["openai-codex"] },
135
+ "github-copilot": { ...DEFAULT_SECRETS_TEMPLATE.providers["github-copilot"] },
107
136
  },
108
137
  teams: { ...DEFAULT_SECRETS_TEMPLATE.teams },
138
+ teamsSecondary: { ...DEFAULT_SECRETS_TEMPLATE.teamsSecondary },
109
139
  oauth: { ...DEFAULT_SECRETS_TEMPLATE.oauth },
110
140
  context: { ...identity_1.DEFAULT_AGENT_CONTEXT },
111
141
  teamsChannel: { ...DEFAULT_SECRETS_TEMPLATE.teamsChannel },
142
+ bluebubbles: { ...DEFAULT_SECRETS_TEMPLATE.bluebubbles },
143
+ bluebubblesChannel: { ...DEFAULT_SECRETS_TEMPLATE.bluebubblesChannel },
144
+ vault: { ...DEFAULT_SECRETS_TEMPLATE.vault },
112
145
  integrations: { ...DEFAULT_SECRETS_TEMPLATE.integrations },
113
146
  };
114
147
  }
115
- let _cachedConfig = null;
148
+ let _runtimeConfigOverride = null;
116
149
  let _testContextOverride = null;
117
150
  function resolveConfigPath() {
118
151
  return (0, identity_1.getAgentSecretsPath)();
@@ -134,15 +167,6 @@ function deepMerge(defaults, partial) {
134
167
  return result;
135
168
  }
136
169
  function loadConfig() {
137
- if (_cachedConfig) {
138
- (0, runtime_1.emitNervesEvent)({
139
- event: "config.load",
140
- component: "config/identity",
141
- message: "config loaded from cache",
142
- meta: { source: "cache" },
143
- });
144
- return _cachedConfig;
145
- }
146
170
  const configPath = resolveConfigPath();
147
171
  // Auto-create config directory if it doesn't exist
148
172
  const configDir = path.dirname(configPath);
@@ -203,7 +227,10 @@ function loadConfig() {
203
227
  },
204
228
  });
205
229
  }
206
- _cachedConfig = deepMerge(defaultRuntimeConfig(), sanitizedFileData);
230
+ const mergedConfig = deepMerge(defaultRuntimeConfig(), sanitizedFileData);
231
+ const config = _runtimeConfigOverride
232
+ ? deepMerge(mergedConfig, _runtimeConfigOverride)
233
+ : mergedConfig;
207
234
  (0, runtime_1.emitNervesEvent)({
208
235
  event: "config.load",
209
236
  component: "config/identity",
@@ -211,22 +238,22 @@ function loadConfig() {
211
238
  meta: {
212
239
  source: "disk",
213
240
  used_defaults_only: Object.keys(fileData).length === 0,
241
+ override_applied: _runtimeConfigOverride !== null,
214
242
  },
215
243
  });
216
- return _cachedConfig;
244
+ return config;
217
245
  }
218
246
  function resetConfigCache() {
219
- _cachedConfig = null;
247
+ _runtimeConfigOverride = null;
220
248
  _testContextOverride = null;
221
249
  }
222
- function setTestConfig(partial) {
223
- loadConfig(); // ensure _cachedConfig exists
250
+ function patchRuntimeConfig(partial) {
224
251
  const contextPatch = partial.context;
225
252
  if (contextPatch) {
226
253
  const base = _testContextOverride ?? identity_1.DEFAULT_AGENT_CONTEXT;
227
254
  _testContextOverride = deepMerge(base, contextPatch);
228
255
  }
229
- _cachedConfig = deepMerge(_cachedConfig, partial);
256
+ _runtimeConfigOverride = deepMerge((_runtimeConfigOverride ?? {}), partial);
230
257
  }
231
258
  function getAzureConfig() {
232
259
  const config = loadConfig();
@@ -244,10 +271,22 @@ function getOpenAICodexConfig() {
244
271
  const config = loadConfig();
245
272
  return { ...config.providers["openai-codex"] };
246
273
  }
274
+ function getGithubCopilotConfig() {
275
+ const config = loadConfig();
276
+ return { ...config.providers["github-copilot"] };
277
+ }
278
+ function getProviderConfig(provider) {
279
+ const config = loadConfig();
280
+ return { ...config.providers[provider] };
281
+ }
247
282
  function getTeamsConfig() {
248
283
  const config = loadConfig();
249
284
  return { ...config.teams };
250
285
  }
286
+ function getTeamsSecondaryConfig() {
287
+ const config = loadConfig();
288
+ return { ...config.teamsSecondary };
289
+ }
251
290
  function getContextConfig() {
252
291
  if (_testContextOverride) {
253
292
  return { ..._testContextOverride };
@@ -268,29 +307,85 @@ function getOAuthConfig() {
268
307
  const config = loadConfig();
269
308
  return { ...config.oauth };
270
309
  }
310
+ /** Resolve OAuth connection names for a specific tenant, falling back to defaults. */
311
+ function resolveOAuthForTenant(tenantId) {
312
+ const base = getOAuthConfig();
313
+ const overrides = tenantId ? base.tenantOverrides?.[tenantId] : undefined;
314
+ return {
315
+ graphConnectionName: overrides?.graphConnectionName ?? base.graphConnectionName,
316
+ adoConnectionName: overrides?.adoConnectionName ?? base.adoConnectionName,
317
+ githubConnectionName: overrides?.githubConnectionName ?? base.githubConnectionName,
318
+ };
319
+ }
271
320
  function getTeamsChannelConfig() {
272
321
  const config = loadConfig();
273
322
  const { skipConfirmation, flushIntervalMs, port } = config.teamsChannel;
274
323
  return { skipConfirmation, flushIntervalMs, port };
275
324
  }
325
+ function getBlueBubblesConfig() {
326
+ const config = loadConfig();
327
+ const { serverUrl, password, accountId } = config.bluebubbles;
328
+ if (!serverUrl.trim()) {
329
+ throw new Error("bluebubbles.serverUrl is required in secrets.json to run the BlueBubbles sense.");
330
+ }
331
+ if (!password.trim()) {
332
+ throw new Error("bluebubbles.password is required in secrets.json to run the BlueBubbles sense.");
333
+ }
334
+ return {
335
+ serverUrl: serverUrl.trim(),
336
+ password: password.trim(),
337
+ accountId: accountId.trim() || "default",
338
+ };
339
+ }
340
+ function getBlueBubblesChannelConfig() {
341
+ const config = loadConfig();
342
+ const { port, webhookPath, requestTimeoutMs } = config.bluebubblesChannel;
343
+ return { port, webhookPath, requestTimeoutMs };
344
+ }
276
345
  function getIntegrationsConfig() {
277
346
  const config = loadConfig();
278
347
  return { ...config.integrations };
279
348
  }
349
+ function getSyncConfig() {
350
+ try {
351
+ const agentConfig = (0, identity_1.loadAgentConfig)();
352
+ return {
353
+ enabled: agentConfig.sync?.enabled ?? false,
354
+ remote: agentConfig.sync?.remote ?? "origin",
355
+ };
356
+ }
357
+ catch {
358
+ /* v8 ignore next -- defensive: loadAgentConfig failure in test/bootstrap @preserve */
359
+ return { enabled: false, remote: "origin" };
360
+ }
361
+ }
280
362
  function getOpenAIEmbeddingsApiKey() {
281
363
  return getIntegrationsConfig().openaiEmbeddingsApiKey;
282
364
  }
283
365
  function getLogsDir() {
284
- return path.join(os.homedir(), ".agentstate", (0, identity_1.getAgentName)(), "logs");
366
+ return path.join((0, identity_1.getAgentRoot)(), "state", "logs");
285
367
  }
286
368
  function sanitizeKey(key) {
287
369
  return key.replace(/[/:]/g, "_");
288
370
  }
289
- function sessionPath(friendId, channel, key) {
290
- const dir = path.join(os.homedir(), ".agentstate", (0, identity_1.getAgentName)(), "sessions", friendId, channel);
291
- fs.mkdirSync(dir, { recursive: true });
371
+ function slugify(value) {
372
+ return value
373
+ .trim()
374
+ .toLowerCase()
375
+ .replace(/[^a-z0-9]+/g, "-")
376
+ .replace(/^-+/, "")
377
+ .replace(/-+$/, "");
378
+ }
379
+ function resolveSessionPath(friendId, channel, key, options) {
380
+ const dir = path.join((0, identity_1.getAgentRoot)(), "state", "sessions", friendId, channel);
381
+ if (options?.ensureDir) {
382
+ fs.mkdirSync(dir, { recursive: true });
383
+ }
292
384
  return path.join(dir, sanitizeKey(key) + ".json");
293
385
  }
386
+ function sessionPath(friendId, channel, key) {
387
+ return resolveSessionPath(friendId, channel, key, { ensureDir: true });
388
+ }
294
389
  function logPath(channel, key) {
295
390
  return path.join(getLogsDir(), channel, sanitizeKey(key) + ".ndjson");
296
391
  }