@amoree-code/ocean 2.22.0 → 3.0.0

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 (382) hide show
  1. package/README.md +46 -53
  2. package/dist/application/clients/bundles.js +220 -0
  3. package/dist/application/clients/chat-plugin.js +4 -42
  4. package/dist/application/clients/client-detect.js +291 -0
  5. package/dist/application/clients/clients.js +104 -25
  6. package/dist/application/clients/desktop-link.js +40 -0
  7. package/dist/application/clients/desktop-watcher.js +6 -4
  8. package/dist/application/clients/hook-trust.js +106 -0
  9. package/dist/application/clients/hooks.js +7 -1
  10. package/dist/application/clients/mcp-schema-cost.js +74 -0
  11. package/dist/application/clients/native.js +38 -2
  12. package/dist/application/clients/registry.js +51 -9
  13. package/dist/application/clients/status.js +7 -2
  14. package/dist/application/clients/zip.js +44 -0
  15. package/dist/application/gateway/webhook-gateway.js +1 -1
  16. package/dist/application/integrations/charter-copies.js +1 -1
  17. package/dist/application/integrations/engine-entry-repair.js +4 -3
  18. package/dist/application/integrations/skill-auto-sync.js +2 -2
  19. package/dist/application/integrations/skill-filter.js +1 -1
  20. package/dist/application/integrations/skill-router.js +134 -90
  21. package/dist/application/layout/layout-apply.js +1 -1
  22. package/dist/application/layout/workspace-template.js +1 -1
  23. package/dist/application/onboarding/steps.js +121 -30
  24. package/dist/application/profiles/profile-doctor.js +118 -0
  25. package/dist/application/profiles/profile-migration-service.js +208 -0
  26. package/dist/application/profiles/profile-suggestion.js +3 -7
  27. package/dist/application/profiles/profile-upgrade-service.js +98 -86
  28. package/dist/application/pull/history-index.js +1 -1
  29. package/dist/application/pull/project-match.js +3 -3
  30. package/dist/application/pull/pull.js +1 -1
  31. package/dist/application/pull/server-capture.js +92 -9
  32. package/dist/application/scheduler/local-scheduler.js +2 -2
  33. package/dist/application/spend/claude-prices.js +55 -0
  34. package/dist/application/spend/claude-spend.js +365 -0
  35. package/dist/application/uninstall/uninstall.js +25 -3
  36. package/dist/application/upkeep/nightly-upkeep.js +4 -4
  37. package/dist/composition/runtime.js +2 -2
  38. package/dist/infrastructure/desktop/claude-export.js +1 -1
  39. package/dist/infrastructure/desktop/desktop-chat.js +60 -13
  40. package/dist/infrastructure/desktop/indexeddb.js +4 -4
  41. package/dist/infrastructure/desktop/leveldb.js +2 -2
  42. package/dist/infrastructure/filesystem/profile-loader.js +3 -45
  43. package/dist/infrastructure/filesystem/runtime-config-loader.js +1 -1
  44. package/dist/infrastructure/observability/runtime-logger.js +1 -1
  45. package/dist/infrastructure/process/agent-tool-executor.js +3 -3
  46. package/dist/infrastructure/process/process-supervisor.js +1 -1
  47. package/dist/infrastructure/process/service.js +8 -8
  48. package/dist/infrastructure/providers/openai-compatible.js +2 -2
  49. package/dist/infrastructure/providers/provider-invocation.js +1 -1
  50. package/dist/infrastructure/providers/session-facts-completer.js +78 -5
  51. package/dist/interfaces/cli/auth-command.js +2 -2
  52. package/dist/interfaces/cli/brief-command.js +1 -1
  53. package/dist/interfaces/cli/browser-command.js +6 -6
  54. package/dist/interfaces/cli/browser-findings.js +6 -9
  55. package/dist/interfaces/cli/browser-settings.js +10 -10
  56. package/dist/interfaces/cli/capture-command.js +6 -6
  57. package/dist/interfaces/cli/client-test-command.js +3 -3
  58. package/dist/interfaces/cli/clients-command.js +55 -6
  59. package/dist/interfaces/cli/command-aliases.js +56 -0
  60. package/dist/interfaces/cli/command-registry.js +48 -1414
  61. package/dist/interfaces/cli/commands/browser.js +5 -0
  62. package/dist/interfaces/cli/commands/capture.js +19 -0
  63. package/dist/interfaces/cli/commands/catalog.js +9 -0
  64. package/dist/interfaces/cli/commands/client.js +135 -0
  65. package/dist/interfaces/cli/commands/clients.js +33 -0
  66. package/dist/interfaces/cli/commands/connectors.js +14 -0
  67. package/dist/interfaces/cli/commands/context.js +9 -0
  68. package/dist/interfaces/cli/commands/cost.js +15 -0
  69. package/dist/interfaces/cli/commands/daily.js +11 -0
  70. package/dist/interfaces/cli/commands/day.js +25 -0
  71. package/dist/interfaces/cli/commands/dispatch.js +31 -0
  72. package/dist/interfaces/cli/commands/doctor.js +60 -0
  73. package/dist/interfaces/cli/commands/env.js +5 -0
  74. package/dist/interfaces/cli/commands/gateway.js +16 -0
  75. package/dist/interfaces/cli/commands/handoff.js +11 -0
  76. package/dist/interfaces/cli/commands/health.js +17 -0
  77. package/dist/interfaces/cli/commands/hook.js +142 -0
  78. package/dist/interfaces/cli/commands/idea.js +11 -0
  79. package/dist/interfaces/cli/commands/install.js +31 -0
  80. package/dist/interfaces/cli/commands/intent.js +14 -0
  81. package/dist/interfaces/cli/commands/intercept.js +22 -0
  82. package/dist/interfaces/cli/commands/layout.js +11 -0
  83. package/dist/interfaces/cli/commands/lifecycle.js +5 -0
  84. package/dist/interfaces/cli/commands/loop.js +73 -0
  85. package/dist/interfaces/cli/commands/market.js +11 -0
  86. package/dist/interfaces/cli/commands/mcp.js +57 -0
  87. package/dist/interfaces/cli/commands/memory.js +5 -0
  88. package/dist/interfaces/cli/commands/migrate.js +5 -0
  89. package/dist/interfaces/cli/commands/observe.js +11 -0
  90. package/dist/interfaces/cli/commands/obsidian.js +111 -0
  91. package/dist/interfaces/cli/commands/operate.js +7 -0
  92. package/dist/interfaces/cli/commands/policy.js +16 -0
  93. package/dist/interfaces/cli/commands/project.js +207 -0
  94. package/dist/interfaces/cli/commands/repair.js +20 -0
  95. package/dist/interfaces/cli/commands/run.js +52 -0
  96. package/dist/interfaces/cli/commands/schedule.js +58 -0
  97. package/dist/interfaces/cli/commands/service.js +21 -0
  98. package/dist/interfaces/cli/commands/session.js +182 -0
  99. package/dist/interfaces/cli/commands/sessions.js +12 -0
  100. package/dist/interfaces/cli/commands/setup.js +21 -0
  101. package/dist/interfaces/cli/commands/skill.js +159 -0
  102. package/dist/interfaces/cli/commands/tasks.js +10 -0
  103. package/dist/interfaces/cli/commands/update-remove.js +25 -0
  104. package/dist/interfaces/cli/connectors-command.js +150 -0
  105. package/dist/interfaces/cli/context-command.js +39 -3
  106. package/dist/interfaces/cli/cost-command.js +104 -0
  107. package/dist/interfaces/cli/curator-command.js +1 -1
  108. package/dist/interfaces/cli/daily-command.js +7 -1
  109. package/dist/interfaces/cli/desktop-command.js +43 -7
  110. package/dist/interfaces/cli/distill-command.js +7 -2
  111. package/dist/interfaces/cli/express-command.js +1 -1
  112. package/dist/interfaces/cli/failures-command.js +4 -4
  113. package/dist/interfaces/cli/gateway-findings.js +2 -2
  114. package/dist/interfaces/cli/governance-command.js +23 -16
  115. package/dist/interfaces/cli/handoff-command.js +1 -1
  116. package/dist/interfaces/cli/harvest-command.js +2 -2
  117. package/dist/interfaces/cli/help-command.js +53 -169
  118. package/dist/interfaces/cli/hygiene-command.js +1 -1
  119. package/dist/interfaces/cli/idea-command.js +1 -1
  120. package/dist/interfaces/cli/intercept-command.js +8 -7
  121. package/dist/interfaces/cli/interests-command.js +1 -1
  122. package/dist/interfaces/cli/layout-command.js +2 -0
  123. package/dist/interfaces/cli/market-command.js +9 -9
  124. package/dist/interfaces/cli/mcp-gateway-command.js +124 -7
  125. package/dist/interfaces/cli/mcp-probe-command.js +186 -0
  126. package/dist/interfaces/cli/mcp-status-command.js +5 -5
  127. package/dist/interfaces/cli/memory-command.js +41 -7
  128. package/dist/interfaces/cli/migrate-command.js +2 -2
  129. package/dist/interfaces/cli/note-command.js +1 -1
  130. package/dist/interfaces/cli/onboard-command.js +14 -0
  131. package/dist/interfaces/cli/operate-command.js +5 -5
  132. package/dist/interfaces/cli/profiles-command.js +61 -1
  133. package/dist/interfaces/cli/rhythm-command.js +11 -5
  134. package/dist/interfaces/cli/running-server-findings.js +1 -1
  135. package/dist/interfaces/cli/scorecard-command.js +8 -8
  136. package/dist/interfaces/cli/session-facts-command.js +2 -2
  137. package/dist/interfaces/cli/sessions-command.js +145 -0
  138. package/dist/interfaces/cli/setup-command.js +15 -2
  139. package/dist/interfaces/cli/tasks-command.js +63 -13
  140. package/dist/interfaces/cli/telemetry-command.js +4 -4
  141. package/dist/interfaces/cli/uninstall-command.js +1 -1
  142. package/dist/interfaces/cli/week-failures.js +32 -0
  143. package/dist/main.js +12 -0
  144. package/node_modules/@ocean/brain/dist/{infrastructure/brain/brain-index.js → brain-index.js} +2 -2
  145. package/node_modules/@ocean/brain/dist/{brain/brain-markdown.js → brain-markdown.js} +1 -1
  146. package/node_modules/@ocean/brain/dist/{brain/brain-service.js → brain-service.js} +12 -2
  147. package/node_modules/@ocean/brain/dist/memory/brain-dump.js +92 -16
  148. package/node_modules/@ocean/brain/dist/memory/extraction-log.js +125 -0
  149. package/node_modules/@ocean/brain/dist/memory/extraction-retry.js +54 -0
  150. package/node_modules/@ocean/brain/dist/memory/fact-routing.js +44 -1
  151. package/node_modules/@ocean/brain/dist/memory/lesson-activation.js +2 -2
  152. package/node_modules/@ocean/brain/dist/memory/lesson-learning.js +2 -2
  153. package/node_modules/@ocean/brain/dist/memory/lessons.js +1 -1
  154. package/node_modules/@ocean/brain/dist/memory/memory-audit.js +2 -2
  155. package/node_modules/@ocean/brain/dist/memory/memory-harvest.js +1 -1
  156. package/node_modules/@ocean/brain/dist/memory/memory-paths.js +8 -0
  157. package/node_modules/@ocean/brain/dist/memory/memory-review.js +31 -3
  158. package/node_modules/@ocean/brain/dist/memory/memory-trash.js +29 -0
  159. package/node_modules/@ocean/brain/dist/memory/memory-write.js +4 -2
  160. package/node_modules/@ocean/brain/dist/memory/model-narrative.js +2 -2
  161. package/node_modules/@ocean/brain/dist/memory/profile-facts.js +1 -1
  162. package/node_modules/@ocean/brain/dist/memory/routing.json +6 -6
  163. package/node_modules/@ocean/{market/dist/skills → brain/dist/memory}/signal-detection.js +1 -1
  164. package/node_modules/@ocean/brain/dist/{memory → people}/people.js +1 -1
  165. package/node_modules/@ocean/brain/dist/sessions-capture/session-facts.js +625 -0
  166. package/node_modules/@ocean/brain/dist/{memory → sessions-capture}/session-promotion.js +7 -15
  167. package/node_modules/@ocean/brain/dist/{memory → sessions-capture}/session-summary.js +1 -1
  168. package/node_modules/@ocean/brain/dist/sessions-capture/session-triage.js +52 -0
  169. package/node_modules/@ocean/brain/package.json +1 -1
  170. package/node_modules/@ocean/connect/dist/connectors/connector-hub.js +173 -0
  171. package/node_modules/@ocean/{market → connect}/dist/install/default-marketplace.js +6 -2
  172. package/node_modules/@ocean/{market → connect}/dist/install/marketplace-service.js +1 -1
  173. package/node_modules/@ocean/connect/dist/mcp/mcp-gateway.js +987 -0
  174. package/node_modules/@ocean/{market → connect}/dist/mcp/mcp-launch.js +102 -5
  175. package/node_modules/@ocean/{market → connect}/dist/registry/official-registry.js +1 -1
  176. package/node_modules/@ocean/{market → connect}/dist/security/permissions.js +1 -1
  177. package/node_modules/@ocean/{market → connect}/dist/skills/skill-hub.js +104 -6
  178. package/node_modules/@ocean/{market → connect}/package.json +2 -2
  179. package/node_modules/@ocean/context/dist/{context/context-ladder.js → context-ladder.js} +3 -3
  180. package/node_modules/@ocean/context/dist/{context/context-references.js → context-references.js} +5 -4
  181. package/node_modules/@ocean/context/dist/{context/context-cost.js → context-size.js} +6 -6
  182. package/node_modules/@ocean/context/dist/{context/intent-router.js → intent-router.js} +1 -1
  183. package/node_modules/@ocean/context/dist/{context/resource-injection.js → resource-injection.js} +3 -1
  184. package/node_modules/@ocean/context/package.json +1 -1
  185. package/node_modules/@ocean/core/dist/domain/brain/brain-record.js +1 -1
  186. package/node_modules/@ocean/core/dist/domain/capabilities/capability-manifest.js +5 -5
  187. package/node_modules/@ocean/core/dist/domain/connector-entry.js +86 -0
  188. package/node_modules/@ocean/core/dist/domain/context/context.js +1 -1
  189. package/node_modules/@ocean/core/dist/domain/context/project-id.js +8 -2
  190. package/node_modules/@ocean/core/dist/domain/{evidence/evidence.js → evidence.js} +1 -1
  191. package/node_modules/@ocean/core/dist/domain/mcp/memory-contract.js +4 -1
  192. package/node_modules/@ocean/core/dist/domain/ports/brain-index-port.js +1 -1
  193. package/node_modules/@ocean/core/dist/domain/profiles/profile-markdown.js +40 -0
  194. package/node_modules/@ocean/core/dist/domain/profiles/profile-resolution.js +276 -0
  195. package/node_modules/@ocean/core/dist/domain/profiles/profile-selection.js +23 -60
  196. package/node_modules/@ocean/core/dist/domain/profiles/profile-upgrade.js +2 -2
  197. package/node_modules/@ocean/core/dist/domain/profiles/profile.js +66 -6
  198. package/node_modules/@ocean/core/dist/domain/profiles/runtime-config.js +1 -1
  199. package/node_modules/@ocean/core/dist/domain/runs/agent-tools.js +2 -2
  200. package/node_modules/@ocean/core/dist/domain/sessions/session-identity.js +53 -0
  201. package/node_modules/@ocean/core/dist/domain/sessions/session-metadata.js +208 -0
  202. package/node_modules/@ocean/core/dist/domain/{tasks/task-id.js → task-id.js} +2 -2
  203. package/node_modules/@ocean/core/dist/profiles/profile-files.js +57 -0
  204. package/node_modules/@ocean/core/dist/profiles/profile-loader.js +97 -0
  205. package/node_modules/@ocean/core/dist/profiles/project-profile-fill.js +33 -0
  206. package/node_modules/@ocean/core/dist/profiles/session-profile.js +158 -0
  207. package/node_modules/@ocean/core/dist/shared/charter.js +110 -0
  208. package/node_modules/@ocean/core/dist/shared/context-ack.js +1 -1
  209. package/node_modules/@ocean/core/dist/shared/context-triggers.js +67 -0
  210. package/node_modules/@ocean/core/dist/shared/paths.js +6 -6
  211. package/node_modules/@ocean/core/dist/shared/project-legacy.js +232 -0
  212. package/node_modules/@ocean/core/dist/shared/project-manifest.js +308 -0
  213. package/node_modules/@ocean/core/dist/shared/project-names.js +87 -0
  214. package/node_modules/@ocean/core/dist/shared/project-register.js +560 -0
  215. package/node_modules/@ocean/core/dist/shared/project-resolution.js +83 -861
  216. package/node_modules/@ocean/core/dist/shared/repo-signals.js +45 -0
  217. package/node_modules/@ocean/core/dist/shared/task-reference.js +1 -1
  218. package/node_modules/@ocean/core/dist/shared/text-tokens.js +37 -0
  219. package/node_modules/@ocean/core/dist/shared/tool-groups.js +224 -0
  220. package/node_modules/@ocean/core/package.json +4 -1
  221. package/node_modules/@ocean/services/dist/day/day.js +45 -3
  222. package/node_modules/@ocean/services/dist/{distill → day}/distill.js +29 -3
  223. package/node_modules/@ocean/services/dist/{harvest → day}/harvest.js +54 -14
  224. package/node_modules/@ocean/services/dist/{brief → day}/interest-discovery.js +3 -3
  225. package/node_modules/@ocean/services/dist/day/note.js +2 -2
  226. package/node_modules/@ocean/services/dist/{onboarding → day}/onboarding.js +1 -1
  227. package/node_modules/@ocean/services/dist/day/patterns.js +68 -0
  228. package/node_modules/@ocean/services/dist/{curator → health}/curator.js +5 -5
  229. package/node_modules/@ocean/services/dist/{journey → health}/failures.js +7 -5
  230. package/node_modules/@ocean/services/dist/{hygiene → health}/hygiene.js +2 -2
  231. package/node_modules/@ocean/services/dist/{journey → health}/lesson-effect.js +1 -1
  232. package/node_modules/@ocean/services/dist/{scorecard → health}/scorecard.js +3 -3
  233. package/node_modules/@ocean/services/dist/{upkeep → health}/upkeep.js +2 -2
  234. package/node_modules/@ocean/services/dist/{doctor → health}/workspace-doctor.js +57 -17
  235. package/node_modules/@ocean/services/dist/{browser → integrations/browser}/browser-session.js +1 -1
  236. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/call-ledger.js +3 -0
  237. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/mcp-client.js +19 -3
  238. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/obsidian-server.js +4 -4
  239. package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/ocean-server.js +423 -34
  240. package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/conflict-log.js +1 -1
  241. package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/folder-templates.js +8 -5
  242. package/node_modules/@ocean/services/dist/projects/project-doctor.js +173 -0
  243. package/node_modules/@ocean/services/dist/projects/project-snippet.js +9 -0
  244. package/node_modules/@ocean/services/dist/projects/projects-overview.js +2 -2
  245. package/node_modules/@ocean/services/package.json +1 -1
  246. package/node_modules/@ocean/{loop/dist/loops → work/dist/runs}/guard-runtime.js +3 -3
  247. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/memory-knowledge-operations.js +4 -12
  248. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/operation-contract.js +2 -2
  249. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/project-operations.js +2 -1
  250. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/task-operations.js +4 -4
  251. package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/write-guard.js +1 -1
  252. package/node_modules/@ocean/{loop → work}/dist/runs/prompt-assembly.js +2 -2
  253. package/node_modules/@ocean/{loop → work}/dist/runs/run-agent.js +4 -4
  254. package/node_modules/@ocean/{loop → work}/dist/runs/tool-loop.js +4 -4
  255. package/node_modules/@ocean/work/dist/sessions/hooks/desktop-facts.js +309 -0
  256. package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/session-end-hook.js +36 -5
  257. package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/session-facts-hook.js +144 -14
  258. package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/session-start-hook.js +129 -12
  259. package/node_modules/@ocean/work/dist/sessions/hooks/start-brief.js +110 -0
  260. package/node_modules/@ocean/work/dist/sessions/hooks/unlinked-warning.js +68 -0
  261. package/node_modules/@ocean/{loop → work}/dist/sessions/session-closeout.js +4 -4
  262. package/node_modules/@ocean/{loop → work}/dist/sessions/session-projects.js +13 -3
  263. package/node_modules/@ocean/work/dist/sessions/session-relink.js +300 -0
  264. package/node_modules/@ocean/{loop → work}/dist/sessions/session-retention.js +1 -1
  265. package/node_modules/@ocean/{loop → work}/dist/tasks/list-tasks.js +7 -2
  266. package/node_modules/@ocean/{loop → work}/dist/tasks/renumber-tasks.js +4 -2
  267. package/node_modules/@ocean/{loop → work}/dist/tasks/session-task.js +2 -2
  268. package/node_modules/@ocean/{loop → work}/dist/tasks/sync-task-prs.js +77 -7
  269. package/node_modules/@ocean/work/dist/tasks/task-git.js +63 -0
  270. package/node_modules/@ocean/{loop/dist/loops → work/dist/tasks}/task-loop.js +4 -4
  271. package/node_modules/@ocean/{loop → work}/dist/tasks/verification-readiness.js +1 -1
  272. package/node_modules/@ocean/{loop → work}/dist/tasks/verify-task.js +1 -1
  273. package/node_modules/@ocean/{loop → work}/package.json +2 -2
  274. package/ocean-marketplace.json +41 -41
  275. package/package.json +12 -11
  276. package/skills/core/daily-harvest/SKILL.md +1 -1
  277. package/skills/core/ocean-memory/SKILL.md +4 -0
  278. package/skills/core/use-browser/SKILL.md +30 -7
  279. package/skills/index.json +1 -1
  280. package/templates/profiles/default.md +44 -0
  281. package/templates/profiles/developer.md +45 -0
  282. package/templates/profiles/reviewer.md +44 -0
  283. package/templates/profiles/strategist.md +44 -0
  284. package/templates/profiles-v3/analysis.md +16 -0
  285. package/templates/profiles-v3/backend.md +16 -0
  286. package/templates/profiles-v3/base.md +57 -0
  287. package/templates/profiles-v3/code-review.md +16 -0
  288. package/templates/profiles-v3/devops.md +16 -0
  289. package/templates/profiles-v3/docs-office.md +16 -0
  290. package/templates/profiles-v3/frontend.md +16 -0
  291. package/templates/profiles-v3/learning.md +16 -0
  292. package/templates/profiles-v3/marketing-ads.md +16 -0
  293. package/templates/profiles-v3/marketing-content-seo.md +16 -0
  294. package/templates/profiles-v3/ocean-ops.md +16 -0
  295. package/templates/profiles-v3/product-strategy.md +16 -0
  296. package/templates/profiles-v3/qa-testing.md +16 -0
  297. package/templates/profiles-v3/security.md +16 -0
  298. package/templates/workspace/MANIFEST.json +1 -0
  299. package/templates/workspace/charter/core.md +22 -90
  300. package/templates/workspace/charter/policies/README.md +7 -1
  301. package/templates/workspace/charter/policies/claude-code-context.md +6 -1
  302. package/templates/workspace/charter/policies/concise-output.md +5 -0
  303. package/templates/workspace/charter/policies/context.md +5 -0
  304. package/templates/workspace/charter/policies/contracts/task.md +2 -2
  305. package/templates/workspace/charter/policies/git.md +5 -0
  306. package/templates/workspace/charter/policies/graph.md +6 -1
  307. package/templates/workspace/charter/policies/knowledge.md +11 -4
  308. package/templates/workspace/charter/policies/layout.md +23 -0
  309. package/templates/workspace/charter/policies/lifecycle.md +5 -0
  310. package/templates/workspace/charter/policies/memory.md +5 -0
  311. package/templates/workspace/charter/policies/minimal-change.md +5 -0
  312. package/templates/workspace/charter/policies/models.md +5 -0
  313. package/templates/workspace/charter/policies/response.md +5 -0
  314. package/templates/workspace/charter/policies/skill-observer.md +12 -0
  315. package/templates/workspace/charter/policies/stack.md +5 -0
  316. package/templates/workspace/charter/policies/task.md +17 -3
  317. package/templates/workspace/charter/policies/verification.md +5 -0
  318. package/node_modules/@ocean/brain/dist/evidence/verification-report.js +0 -13
  319. package/node_modules/@ocean/brain/dist/memory/daily-narrative.js +0 -142
  320. package/node_modules/@ocean/brain/dist/memory/session-facts.js +0 -283
  321. package/node_modules/@ocean/context/dist/context/context-compression.js +0 -66
  322. package/node_modules/@ocean/loop/dist/hooks/desktop-facts.js +0 -174
  323. package/node_modules/@ocean/loop/dist/operations/task-linker.js +0 -40
  324. package/node_modules/@ocean/loop/dist/sessions/session-pointer.js +0 -133
  325. package/node_modules/@ocean/loop/dist/tasks/task-git.js +0 -28
  326. package/node_modules/@ocean/market/dist/mcp/mcp-gateway.js +0 -533
  327. package/templates/profiles/default.json +0 -51
  328. package/templates/profiles/developer.json +0 -51
  329. package/templates/profiles/reviewer.json +0 -51
  330. package/templates/profiles/strategist.json +0 -51
  331. /package/node_modules/@ocean/brain/dist/{brain/brain-eval.js → brain-eval.js} +0 -0
  332. /package/node_modules/@ocean/brain/dist/{brain/brain-reindex.js → brain-reindex.js} +0 -0
  333. /package/node_modules/@ocean/brain/dist/{capture → sessions-capture}/inbox-sync.js +0 -0
  334. /package/node_modules/@ocean/{market → connect}/dist/adapters/mcp-adapter.js +0 -0
  335. /package/node_modules/@ocean/{market → connect}/dist/adapters/owned-directory.js +0 -0
  336. /package/node_modules/@ocean/{market → connect}/dist/adapters/plugin-adapter.js +0 -0
  337. /package/node_modules/@ocean/{market → connect}/dist/adapters/skill-adapter.js +0 -0
  338. /package/node_modules/@ocean/{market → connect}/dist/capability/adapter.js +0 -0
  339. /package/node_modules/@ocean/{market → connect}/dist/capability/catalog.js +0 -0
  340. /package/node_modules/@ocean/{market → connect}/dist/capability/content-digest.js +0 -0
  341. /package/node_modules/@ocean/{market → connect}/dist/capability/registry.js +0 -0
  342. /package/node_modules/@ocean/{market → connect}/dist/install/lock.js +0 -0
  343. /package/node_modules/@ocean/{market → connect}/dist/install/own-server.js +0 -0
  344. /package/node_modules/@ocean/{market → connect}/dist/mcp/chrome-debugging.js +0 -0
  345. /package/node_modules/@ocean/{market → connect}/dist/mcp/mcp-connection.js +0 -0
  346. /package/node_modules/@ocean/{market → connect}/dist/mcp/mcp-runner.js +0 -0
  347. /package/node_modules/@ocean/{market → connect}/dist/security/description-scan.js +0 -0
  348. /package/node_modules/@ocean/{market → connect}/dist/security/secrets.js +0 -0
  349. /package/node_modules/@ocean/{market → connect}/dist/skills/core-skill-sync.js +0 -0
  350. /package/node_modules/@ocean/context/dist/{context/context-packet.js → context-packet.js} +0 -0
  351. /package/node_modules/@ocean/core/dist/domain/{process/process-events.js → process-events.js} +0 -0
  352. /package/node_modules/@ocean/core/dist/domain/{redaction/redaction.js → redaction.js} +0 -0
  353. /package/node_modules/@ocean/services/dist/{brief → day}/brief.js +0 -0
  354. /package/node_modules/@ocean/services/dist/{express → day}/express.js +0 -0
  355. /package/node_modules/@ocean/services/dist/{brief → day}/source-registry.json +0 -0
  356. /package/node_modules/@ocean/services/dist/{journey → health}/telemetry.js +0 -0
  357. /package/node_modules/@ocean/services/dist/{browser → integrations/browser}/browser-service.js +0 -0
  358. /package/node_modules/@ocean/services/dist/{browser → integrations/browser}/browser-task-runner.js +0 -0
  359. /package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/mcp-session.js +0 -0
  360. /package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/server-version.js +0 -0
  361. /package/node_modules/@ocean/services/dist/{infrastructure → integrations}/mcp/tool-registry.js +0 -0
  362. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/inbox-promotion.js +0 -0
  363. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-discovery.js +0 -0
  364. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-ingestion.js +0 -0
  365. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-sync.js +0 -0
  366. /package/node_modules/@ocean/services/dist/{obsidian → integrations/obsidian}/vault-writer.js +0 -0
  367. /package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/operation-scope.js +0 -0
  368. /package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/record-io.js +0 -0
  369. /package/node_modules/@ocean/{loop/dist → work/dist/runs}/operations/record-operations.js +0 -0
  370. /package/node_modules/@ocean/{loop → work}/dist/runs/run-authorization.js +0 -0
  371. /package/node_modules/@ocean/{loop → work}/dist/runs/session-tokens.js +0 -0
  372. /package/node_modules/@ocean/{loop/dist/handoff → work/dist/sessions}/handoff-service.js +0 -0
  373. /package/node_modules/@ocean/{loop/dist → work/dist/sessions}/hooks/lifecycle-hooks.js +0 -0
  374. /package/node_modules/@ocean/{loop/dist/infrastructure/persistence → work/dist/sessions}/session-store.js +0 -0
  375. /package/node_modules/@ocean/{loop/dist/infrastructure/persistence → work/dist/sessions}/session-validator.js +0 -0
  376. /package/node_modules/@ocean/{loop → work}/dist/tasks/archive-tasks.js +0 -0
  377. /package/node_modules/@ocean/{loop → work}/dist/tasks/checkpoint-task.js +0 -0
  378. /package/node_modules/@ocean/{loop → work}/dist/tasks/claim-task.js +0 -0
  379. /package/node_modules/@ocean/{loop/dist/loops → work/dist/tasks}/iteration-graph.js +0 -0
  380. /package/node_modules/@ocean/{loop → work}/dist/tasks/new-task.js +0 -0
  381. /package/node_modules/@ocean/{loop/dist/loops → work/dist/tasks}/task-loop-record.js +0 -0
  382. /package/node_modules/@ocean/{loop → work}/dist/tasks/task-verification.js +0 -0
@@ -0,0 +1,55 @@
1
+ // What a Claude model call costs at API list price (T-340), per million tokens. A subscription
2
+ // is not billed this way; the figure is how heavy the use is, in one comparable unit. Prices
3
+ // change: update the table and PRICES_AS_OF together, from the provider's price page.
4
+ export const PRICES_AS_OF = "2026-11-29";
5
+ const price = (input, output, cacheRead) => ({
6
+ input,
7
+ output,
8
+ cacheRead,
9
+ cacheWrite5m: input * 1.25,
10
+ cacheWrite1h: input * 2,
11
+ });
12
+ // Most specific first: the first prefix a model id starts with wins. A bare alias
13
+ // ("sonnet", as the extraction log records it) means the current model of that line.
14
+ const TABLE = [
15
+ ["claude-fable-5-2", price(8, 40, 0.2)],
16
+ ["claude-mythos-5-2", price(8, 40, 0.2)],
17
+ ["claude-fable-5-1", price(10, 50, 0.25)],
18
+ ["claude-mythos-5-1", price(10, 50, 0.25)],
19
+ ["claude-fable", price(10, 50, 1)],
20
+ ["claude-mythos", price(10, 50, 1)],
21
+ ["claude-opus-5-5", price(4, 20, 0.2)],
22
+ ["claude-opus-5", price(5, 25, 0.5)],
23
+ ["claude-opus-4-8", price(5, 25, 0.5)],
24
+ ["claude-opus-4-7", price(5, 25, 0.5)],
25
+ ["claude-opus-4-6", price(5, 25, 0.5)],
26
+ ["claude-opus-4-5", price(5, 25, 0.5)],
27
+ ["claude-opus", price(15, 75, 1.5)],
28
+ ["claude-sonnet-5-5", price(2, 10, 0.1)],
29
+ ["claude-sonnet-5", price(2, 10, 0.2)],
30
+ ["claude-sonnet", price(3, 15, 0.3)],
31
+ ["claude-haiku-5-5", price(0.1, 0.5, 0.01)],
32
+ ["claude-haiku-4-5", price(1, 5, 0.1)],
33
+ ["claude-haiku", price(0.8, 4, 0.08)],
34
+ ["fable", price(8, 40, 0.2)],
35
+ ["opus", price(4, 20, 0.2)],
36
+ ["sonnet", price(2, 10, 0.1)],
37
+ ["haiku", price(0.1, 0.5, 0.01)],
38
+ ];
39
+ // The price for a model id, or null for one the table does not know (counted, not priced).
40
+ export function priceFor(model) {
41
+ const id = model.toLowerCase();
42
+ for (const [prefix, entry] of TABLE)
43
+ if (id.startsWith(prefix))
44
+ return entry;
45
+ return null;
46
+ }
47
+ export function costOf(usage, rate) {
48
+ return ((usage.input * rate.input +
49
+ usage.output * rate.output +
50
+ usage.cacheRead * rate.cacheRead +
51
+ usage.cacheWrite5m * rate.cacheWrite5m +
52
+ usage.cacheWrite1h * rate.cacheWrite1h) /
53
+ 1_000_000);
54
+ }
55
+ //# sourceMappingURL=claude-prices.js.map
@@ -0,0 +1,365 @@
1
+ import { readdir, readFile, stat } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { localDate } from "@ocean/core/shared/local-date.js";
4
+ import { costOf, PRICES_AS_OF, priceFor } from "./claude-prices.js";
5
+ const CAPTURE_DIR = /[\\/]state[\\/]memory[\\/]extract$/;
6
+ const tokens = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
7
+ // One transcript line as a spend record, or null when it is not a model reply, is synthetic,
8
+ // or was already counted (`seen` holds message id + request id).
9
+ export function parseTranscriptLine(line, seen) {
10
+ if (!line.includes('"usage"'))
11
+ return null;
12
+ let entry;
13
+ try {
14
+ entry = JSON.parse(line);
15
+ }
16
+ catch {
17
+ return null;
18
+ }
19
+ const message = entry.message;
20
+ const usage = message?.usage;
21
+ const model = typeof message?.model === "string" ? message.model : "";
22
+ if (!usage || !model || model.startsWith("<"))
23
+ return null;
24
+ const at = Date.parse(String(entry.timestamp ?? ""));
25
+ if (Number.isNaN(at))
26
+ return null;
27
+ const key = `${message?.id ?? ""}:${entry.requestId ?? ""}`;
28
+ if (key !== ":") {
29
+ if (seen.has(key))
30
+ return null;
31
+ seen.add(key);
32
+ }
33
+ const split = usage.cache_creation;
34
+ const written = tokens(usage.cache_creation_input_tokens);
35
+ const oneHour = tokens(split?.ephemeral_1h_input_tokens);
36
+ const fiveMinute = split
37
+ ? tokens(split.ephemeral_5m_input_tokens)
38
+ : written - oneHour;
39
+ const counted = {
40
+ input: tokens(usage.input_tokens),
41
+ output: tokens(usage.output_tokens),
42
+ cacheRead: tokens(usage.cache_read_input_tokens),
43
+ cacheWrite5m: Math.max(0, fiveMinute),
44
+ cacheWrite1h: oneHour,
45
+ };
46
+ const rate = priceFor(model);
47
+ const cwd = typeof entry.cwd === "string" ? entry.cwd : "";
48
+ return {
49
+ at,
50
+ session: typeof entry.sessionId === "string" ? entry.sessionId : "",
51
+ client: typeof entry.entrypoint === "string" ? entry.entrypoint : "unknown",
52
+ project: cwd ? path.basename(cwd) : "unknown",
53
+ kind: CAPTURE_DIR.test(cwd)
54
+ ? "capture"
55
+ : entry.isSidechain === true
56
+ ? "subagent"
57
+ : "interactive",
58
+ model,
59
+ usage: counted,
60
+ context: counted.input +
61
+ counted.cacheRead +
62
+ counted.cacheWrite5m +
63
+ counted.cacheWrite1h,
64
+ cost: rate ? costOf(counted, rate) : 0,
65
+ priced: rate !== null,
66
+ };
67
+ }
68
+ async function transcriptFiles(dir, since) {
69
+ let entries;
70
+ try {
71
+ entries = await readdir(dir, { withFileTypes: true });
72
+ }
73
+ catch {
74
+ return [];
75
+ }
76
+ const found = [];
77
+ for (const entry of entries) {
78
+ const full = path.join(dir, entry.name);
79
+ if (entry.isDirectory())
80
+ found.push(...(await transcriptFiles(full, since)));
81
+ else if (entry.name.endsWith(".jsonl")) {
82
+ // A file last written before the window holds nothing in it.
83
+ const info = await stat(full).catch(() => null);
84
+ if (info && info.mtimeMs >= since)
85
+ found.push(full);
86
+ }
87
+ }
88
+ return found;
89
+ }
90
+ // Every request in the transcripts under `root` made at or after `since` (epoch ms).
91
+ export async function scanTranscripts(root, since) {
92
+ const seen = new Set();
93
+ const records = [];
94
+ for (const file of await transcriptFiles(root, since)) {
95
+ const text = await readFile(file, "utf8").catch(() => "");
96
+ for (const line of text.split("\n")) {
97
+ const record = parseTranscriptLine(line, seen);
98
+ if (record && record.at >= since)
99
+ records.push(record);
100
+ }
101
+ }
102
+ return records.sort((a, b) => a.at - b.at);
103
+ }
104
+ export function parseMeter(text) {
105
+ let parsed;
106
+ try {
107
+ parsed = JSON.parse(text);
108
+ }
109
+ catch {
110
+ return [];
111
+ }
112
+ if (!Array.isArray(parsed.samples))
113
+ return [];
114
+ const rows = parsed.samples.filter((sample) => typeof sample?.t === "number" &&
115
+ typeof sample?.u?.fh === "number" &&
116
+ typeof sample?.u?.sd === "number");
117
+ // The organization sampled last is the one in use.
118
+ const org = rows.reduce((latest, row) => (!latest || row.t > latest.t ? row : latest), null)?.org;
119
+ return rows
120
+ .filter((row) => row.org === org)
121
+ .map((row) => ({ at: row.t, fiveHour: row.u.fh, weekly: row.u.sd }))
122
+ .sort((a, b) => a.at - b.at);
123
+ }
124
+ // Session capture's calls as spend records, from the tokens each one reported to the
125
+ // extraction log (T-340). Its calls stopped leaving transcripts, so the log is the only place
126
+ // they show; a call that did leave one (a capture record in `records` while it ran) is
127
+ // already counted and skipped. A line from before tokens were logged has no figures to price.
128
+ export function captureRecords(entries, records) {
129
+ const transcribed = records
130
+ .filter((record) => record.kind === "capture")
131
+ .map((record) => record.at);
132
+ const found = [];
133
+ for (const entry of entries) {
134
+ if (entry.outcome === "repeat")
135
+ continue;
136
+ const reported = [
137
+ entry.input_tokens,
138
+ entry.output_tokens,
139
+ entry.cache_read_tokens,
140
+ entry.cache_write_tokens,
141
+ ];
142
+ if (reported.every((value) => value === undefined))
143
+ continue;
144
+ const at = Date.parse(entry.at);
145
+ if (Number.isNaN(at))
146
+ continue;
147
+ if (transcribed.some((time) => time >= at - entry.ms - 60_000 && time <= at + 60_000))
148
+ continue;
149
+ const usage = {
150
+ input: tokens(entry.input_tokens),
151
+ output: tokens(entry.output_tokens),
152
+ cacheRead: tokens(entry.cache_read_tokens),
153
+ cacheWrite5m: 0,
154
+ // Claude Code writes its cache for an hour; a write is priced as that.
155
+ cacheWrite1h: tokens(entry.cache_write_tokens),
156
+ };
157
+ const rate = priceFor(entry.model);
158
+ found.push({
159
+ at,
160
+ session: `capture:${entry.session}`,
161
+ client: entry.client,
162
+ project: "session capture",
163
+ kind: "capture",
164
+ model: entry.model,
165
+ usage,
166
+ context: usage.input + usage.cacheRead + usage.cacheWrite1h,
167
+ cost: rate ? costOf(usage, rate) : 0,
168
+ priced: rate !== null,
169
+ });
170
+ }
171
+ return found;
172
+ }
173
+ export const GROUPS = [
174
+ "day",
175
+ "hour",
176
+ "client",
177
+ "project",
178
+ "model",
179
+ "session",
180
+ "kind",
181
+ ];
182
+ const LONG_CONTEXT = 100_000;
183
+ const SESSION_FLAG_COST = 15;
184
+ const IDLE_FLAG_COST = 0.5;
185
+ const FAILURE_RUN_FLAG = 5;
186
+ const pad = (value) => String(value).padStart(2, "0");
187
+ const hourOf = (at) => pad(new Date(at).getHours());
188
+ const dayOf = (at) => localDate(new Date(at));
189
+ function keyOf(record, by) {
190
+ switch (by) {
191
+ case "day":
192
+ return dayOf(record.at);
193
+ case "hour":
194
+ return hourOf(record.at);
195
+ case "client":
196
+ return record.client;
197
+ case "project":
198
+ return record.project;
199
+ case "model":
200
+ return record.model;
201
+ case "session":
202
+ return record.session;
203
+ case "kind":
204
+ return record.kind;
205
+ }
206
+ }
207
+ const empty = (key) => ({
208
+ key,
209
+ requests: 0,
210
+ cost: 0,
211
+ input: 0,
212
+ output: 0,
213
+ cacheRead: 0,
214
+ cacheWrite: 0,
215
+ });
216
+ function add(bucket, record) {
217
+ bucket.requests++;
218
+ bucket.cost += record.cost;
219
+ bucket.input += record.usage.input;
220
+ bucket.output += record.usage.output;
221
+ bucket.cacheRead += record.usage.cacheRead;
222
+ bucket.cacheWrite += record.usage.cacheWrite5m + record.usage.cacheWrite1h;
223
+ return bucket;
224
+ }
225
+ function bucketsBy(records, key) {
226
+ const buckets = new Map();
227
+ for (const record of records) {
228
+ const name = key(record);
229
+ let bucket = buckets.get(name);
230
+ if (!bucket) {
231
+ bucket = empty(name);
232
+ buckets.set(name, bucket);
233
+ }
234
+ add(bucket, record);
235
+ }
236
+ return buckets;
237
+ }
238
+ const median = (values) => {
239
+ const sorted = [...values].sort((a, b) => a - b);
240
+ const middle = Math.floor(sorted.length / 2);
241
+ return sorted.length % 2
242
+ ? sorted[middle]
243
+ : (sorted[middle - 1] + sorted[middle]) / 2;
244
+ };
245
+ const dollars = (value) => `$${value.toFixed(2)}`;
246
+ // The days of the window, oldest first, each with what it cost (a day with no use costs 0).
247
+ function dailyCosts(records, since, now) {
248
+ const costs = new Map();
249
+ for (let at = since; at <= now; at += 86_400_000)
250
+ costs.set(dayOf(at), 0);
251
+ costs.set(dayOf(now), costs.get(dayOf(now)) ?? 0);
252
+ for (const record of records) {
253
+ const day = dayOf(record.at);
254
+ costs.set(day, (costs.get(day) ?? 0) + record.cost);
255
+ }
256
+ return [...costs].sort(([a], [b]) => a.localeCompare(b));
257
+ }
258
+ export function summarizeSpend(records, options) {
259
+ const since = options.now - options.days * 86_400_000;
260
+ const all = [...records, ...captureRecords(options.capture ?? [], records)];
261
+ const inWindow = all.filter((record) => record.at >= since && record.at <= options.now);
262
+ const total = inWindow.reduce(add, empty("total"));
263
+ const byCost = (a, b) => b.cost - a.cost;
264
+ const groups = [...bucketsBy(inWindow, (r) => keyOf(r, options.by)).values()];
265
+ groups.sort(options.by === "day" || options.by === "hour"
266
+ ? (a, b) => a.key.localeCompare(b.key)
267
+ : byCost);
268
+ const sessions = bucketsBy(inWindow, (r) => r.session);
269
+ const firstOf = new Map();
270
+ for (const record of inWindow)
271
+ if (!firstOf.has(record.session))
272
+ firstOf.set(record.session, record);
273
+ const topSessions = [...sessions.values()]
274
+ .sort(byCost)
275
+ .slice(0, 5)
276
+ .map((bucket) => ({
277
+ ...bucket,
278
+ project: firstOf.get(bucket.key)?.project ?? "unknown",
279
+ client: firstOf.get(bucket.key)?.client ?? "unknown",
280
+ }));
281
+ const long = inWindow.filter((record) => record.context > LONG_CONTEXT);
282
+ // An hour with capture calls but no request of his own: the work ran while he was away.
283
+ const activeHours = new Set(inWindow
284
+ .filter((record) => record.kind !== "capture")
285
+ .map((record) => `${dayOf(record.at)} ${hourOf(record.at)}`));
286
+ const idleCost = inWindow
287
+ .filter((record) => record.kind === "capture" &&
288
+ !activeHours.has(`${dayOf(record.at)} ${hourOf(record.at)}`))
289
+ .reduce((sum, record) => sum + record.cost, 0);
290
+ const calls = (options.capture ?? [])
291
+ .filter((entry) => {
292
+ const at = Date.parse(entry.at);
293
+ return at >= since && at <= options.now;
294
+ })
295
+ .sort((a, b) => a.at.localeCompare(b.at));
296
+ const failures = {};
297
+ let run = 0;
298
+ let longestFailureRun = 0;
299
+ for (const entry of calls) {
300
+ if (entry.outcome === "failed") {
301
+ const reason = entry.reason ?? "no reason logged";
302
+ failures[reason] = (failures[reason] ?? 0) + 1;
303
+ longestFailureRun = Math.max(longestFailureRun, ++run);
304
+ }
305
+ else if (entry.outcome === "ok")
306
+ run = 0;
307
+ }
308
+ const samples = (options.meter ?? []).filter((sample) => sample.at >= since && sample.at <= options.now);
309
+ let weeklyRise = 0;
310
+ for (let index = 1; index < samples.length; index++)
311
+ weeklyRise += Math.max(0, samples[index].weekly - samples[index - 1].weekly);
312
+ const flags = [];
313
+ const days = dailyCosts(inWindow, since, options.now);
314
+ days.forEach(([day, cost], index) => {
315
+ const before = days.slice(Math.max(0, index - 7), index).map(([, c]) => c);
316
+ if (before.length < 3)
317
+ return;
318
+ const usual = median(before);
319
+ if (usual > 0 && cost > 2 * usual)
320
+ flags.push(`${day} cost ${dollars(cost)}, ${(cost / usual).toFixed(1)}x the median of the ${before.length} days before (${dollars(usual)})`);
321
+ });
322
+ for (const session of topSessions)
323
+ if (session.cost > SESSION_FLAG_COST)
324
+ flags.push(`session ${session.key.slice(0, 8)} (${session.project}, ${session.client}) cost ${dollars(session.cost)} over ${session.requests} requests`);
325
+ if (idleCost > IDLE_FLAG_COST)
326
+ flags.push(`session capture spent ${dollars(idleCost)} in hours with no session of yours`);
327
+ if (longestFailureRun >= FAILURE_RUN_FLAG)
328
+ flags.push(`session capture failed ${longestFailureRun} calls in a row (${Object.entries(failures)
329
+ .map(([reason, count]) => `${reason} ${count}`)
330
+ .join(", ")})`);
331
+ const unpricedModels = [
332
+ ...new Set(inWindow.filter((r) => !r.priced).map((r) => r.model)),
333
+ ];
334
+ if (unpricedModels.length)
335
+ flags.push(`no price for ${unpricedModels.join(", ")}: counted, not costed; add it to claude-prices.ts`);
336
+ return {
337
+ since: new Date(since).toISOString(),
338
+ until: new Date(options.now).toISOString(),
339
+ pricesAsOf: PRICES_AS_OF,
340
+ total,
341
+ unpricedModels,
342
+ by: options.by,
343
+ groups,
344
+ kinds: [...bucketsBy(inWindow, (r) => r.kind).values()].sort(byCost),
345
+ topSessions,
346
+ longContext: {
347
+ threshold: LONG_CONTEXT,
348
+ requests: long.length,
349
+ cost: long.reduce((sum, record) => sum + record.cost, 0),
350
+ },
351
+ capture: {
352
+ calls: calls.length,
353
+ ok: calls.filter((entry) => entry.outcome === "ok").length,
354
+ failed: calls.filter((entry) => entry.outcome === "failed").length,
355
+ repeats: calls.filter((entry) => entry.outcome === "repeat").length,
356
+ failures,
357
+ longestFailureRun,
358
+ idleCost,
359
+ },
360
+ meter: { latest: samples.at(-1) ?? null, weeklyRise },
361
+ flags,
362
+ notCounted: "claude.ai chats, Cowork tasks, scheduled cloud routines and Desktop chats leave no local transcript: the dollar figures leave them out, the plan meter counts them.",
363
+ };
364
+ }
365
+ //# sourceMappingURL=claude-spend.js.map
@@ -3,10 +3,11 @@ import { existsSync } from "node:fs";
3
3
  import { readFile, rm } from "node:fs/promises";
4
4
  import path from "node:path";
5
5
  import { promisify } from "node:util";
6
+ import { removeCoreSkills } from "@ocean/connect/skills/core-skill-sync.js";
6
7
  import { atomicWrite } from "@ocean/core/shared/fs-utils.js";
7
8
  import { liveEngineEntry, oceanRoot } from "@ocean/core/shared/paths.js";
8
- import { removeCoreSkills } from "@ocean/market/skills/core-skill-sync.js";
9
- import { defaultClientEnv, newBatch, readJournal, removeOceanEntries, restoreClients, } from "../clients/clients.js";
9
+ import { CLIENT_DETECT_FILE, CLIENT_DETECT_LABEL, restoreClientDetect, } from "../clients/client-detect.js";
10
+ import { backupPath, defaultClientEnv, newBatch, readJournal, removeBackups, removeOceanEntries, restoreClients, } from "../clients/clients.js";
10
11
  import { DESKTOP_WATCHER_FILE, DESKTOP_WATCHER_LABEL, restoreDesktopWatcher, } from "../clients/desktop-watcher.js";
11
12
  import { removeOceanHooks, restoreHooks } from "../clients/hooks.js";
12
13
  import { restoreNative } from "../clients/native.js";
@@ -80,6 +81,7 @@ function serviceFiles(ctx) {
80
81
  ctx.launchAgent(RUNTIME_LABEL),
81
82
  ctx.launchAgent(BRIDGE_LABEL),
82
83
  path.join(ctx.home, DESKTOP_WATCHER_FILE),
84
+ path.join(ctx.home, CLIENT_DETECT_FILE),
83
85
  ]
84
86
  : ctx.platform === "linux"
85
87
  ? [ctx.systemdUnit]
@@ -117,6 +119,15 @@ export async function planUninstall(options) {
117
119
  area: "clients",
118
120
  target: "remove any Ocean MCP entry and hook still in a client config",
119
121
  });
122
+ const backups = new Set((await readJournal())
123
+ .filter((entry) => !entry.restoreOf)
124
+ .map((entry) => backupPath(path.join(ctx.home, entry.file), entry.batch))
125
+ .filter((file) => existsSync(file)));
126
+ if (backups.size)
127
+ items.push({
128
+ area: "backups",
129
+ target: `${backups.size} config backup(s) Ocean wrote before editing (kept where a change cannot be undone cleanly)`,
130
+ });
120
131
  items.push({
121
132
  area: "skills",
122
133
  target: "Ocean's core skill copies, the charter copy in Codex and Gemini rules, the skills Ocean disabled",
@@ -136,7 +147,12 @@ export async function planUninstall(options) {
136
147
  }
137
148
  async function stopServices(ctx, report) {
138
149
  if (ctx.platform === "darwin") {
139
- for (const label of [DESKTOP_WATCHER_LABEL, BRIDGE_LABEL, RUNTIME_LABEL]) {
150
+ for (const label of [
151
+ CLIENT_DETECT_LABEL,
152
+ DESKTOP_WATCHER_LABEL,
153
+ BRIDGE_LABEL,
154
+ RUNTIME_LABEL,
155
+ ]) {
140
156
  const file = ctx.launchAgent(label);
141
157
  if (!existsSync(file))
142
158
  continue;
@@ -185,6 +201,7 @@ export async function runUninstall(options) {
185
201
  await restoreOpencodePlugin({ batch, env }),
186
202
  await restoreNative({ batch, env }),
187
203
  await restoreDesktopWatcher({ batch, env, run: ctx.run }),
204
+ await restoreClientDetect({ batch, env, run: ctx.run }),
188
205
  ];
189
206
  for (const result of results) {
190
207
  removed("clients", result.restored);
@@ -204,6 +221,11 @@ export async function runUninstall(options) {
204
221
  left("clients", [
205
222
  `${conflict} (changed since Ocean wrote it; check by hand)`,
206
223
  ]);
224
+ // The config backups apply wrote (T-328 P5) go too, except where a conflict above means the
225
+ // copy is still the owner's way back.
226
+ const backups = await removeBackups(ctx.home, await readJournal(), new Set([...conflicts].map((conflict) => conflict.split(":")[0])));
227
+ removed("backups", backups.removed);
228
+ left("backups", backups.kept.map((file) => `${file} (your config before Ocean edited it)`));
207
229
  // 3. Skills and rules Ocean copied into clients.
208
230
  const skills = await removeCoreSkills(ctx.home);
209
231
  removed("skills", skills.removed);
@@ -3,10 +3,10 @@ import { access, mkdir, readFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { atomicWrite, withFileLock } from "@ocean/core/shared/fs-utils.js";
5
5
  import { KNOWLEDGE_DIR, oceanPath, SYSTEM_DIR, } from "@ocean/core/shared/paths.js";
6
- import { listTaskLoops } from "@ocean/loop/loops/task-loop.js";
7
- import { hygieneFile } from "@ocean/services/hygiene/hygiene.js";
8
- import { scorecardFile, searchEvalFile, } from "@ocean/services/scorecard/scorecard.js";
9
- import { previousScorecard, renderDigest, runUpkeepJobs, scorecardMoves, writeDigest, } from "@ocean/services/upkeep/upkeep.js";
6
+ import { hygieneFile } from "@ocean/services/health/hygiene.js";
7
+ import { scorecardFile, searchEvalFile, } from "@ocean/services/health/scorecard.js";
8
+ import { previousScorecard, renderDigest, runUpkeepJobs, scorecardMoves, writeDigest, } from "@ocean/services/health/upkeep.js";
9
+ import { listTaskLoops } from "@ocean/work/tasks/task-loop.js";
10
10
  import { listSchedules } from "../scheduler/local-scheduler.js";
11
11
  // Nightly upkeep (T-322): each job is a child `ocean` process with a timeout; the results become
12
12
  // the morning digest in 01-daily/reports/digest/. Once a day through `ocean rhythm` (ifDue), and the
@@ -2,9 +2,9 @@
2
2
  // import infrastructure concretes: it wires them to the domain ports that the
3
3
  // application layer depends on. Dependencies point inward everywhere else —
4
4
  // application → domain ports, never application → infrastructure.
5
- import { brainIndexPort } from "@ocean/brain/infrastructure/brain/brain-index.js";
5
+ import { brainIndexPort } from "@ocean/brain/brain-index.js";
6
6
  import { selectActiveLessons } from "@ocean/brain/memory/lesson-activation.js";
7
- import { openSessionStore, SessionStore, } from "@ocean/loop/infrastructure/persistence/session-store.js";
7
+ import { openSessionStore, SessionStore, } from "@ocean/work/sessions/session-store.js";
8
8
  import { loadProfile } from "../infrastructure/filesystem/profile-loader.js";
9
9
  import { loadSkillIndex } from "../infrastructure/filesystem/skill-loader.js";
10
10
  import { appendRuntimeLog } from "../infrastructure/observability/runtime-logger.js";
@@ -28,7 +28,7 @@ function messageText(message) {
28
28
  }
29
29
  return typeof message.text === "string" ? message.text.trim() : "";
30
30
  }
31
- export function exportConversation(raw) {
31
+ function exportConversation(raw) {
32
32
  if (!isObject(raw) || typeof raw.uuid !== "string")
33
33
  return null;
34
34
  if (!Array.isArray(raw.chat_messages))
@@ -8,7 +8,7 @@ import { readIndexedDb } from "./indexeddb.js";
8
8
  // and may change with any app update, so any surprise ends in DesktopChatUnreadable, and a
9
9
  // record that does not decode is skipped. Read-only: the LevelDB folder is copied aside and the
10
10
  // copy is read; the app's LOCK is never taken and nothing in its folders is written.
11
- export const DESKTOP_CHAT_UNREADABLE = "DESKTOP_CHAT_UNREADABLE";
11
+ const DESKTOP_CHAT_UNREADABLE = "DESKTOP_CHAT_UNREADABLE";
12
12
  export class DesktopChatUnreadable extends Error {
13
13
  code = DESKTOP_CHAT_UNREADABLE;
14
14
  }
@@ -17,7 +17,7 @@ const TREES_STORE = "trees";
17
17
  const ROOT_PARENT = "00000000-0000-4000-8000-000000000000";
18
18
  const LEVELDB_FILE = /^(CURRENT|MANIFEST-\d+|\d+\.(log|ldb|sst))$/;
19
19
  // Where Claude Desktop keeps its IndexedDB: the app's user-data folder on each platform.
20
- export function desktopIndexedDbDir(home = os.homedir(), platform = process.platform) {
20
+ function desktopIndexedDbDir(home = os.homedir(), platform = process.platform) {
21
21
  if (platform === "win32")
22
22
  return path.join(process.env.APPDATA ?? path.join(home, "AppData", "Roaming"), "Claude", "IndexedDB");
23
23
  if (platform === "darwin")
@@ -34,18 +34,65 @@ function isoDate(value) {
34
34
  return value.toISOString();
35
35
  return null;
36
36
  }
37
- // The text of a message: its `text` blocks only. Thinking, tool calls, tool results and
38
- // attachments are left out.
39
- function messageText(content) {
37
+ // What a tool step keeps: its call's input and its result are cut to these lengths, so a long
38
+ // file read or search result does not crowd out the conversation (T-329).
39
+ const TOOL_INPUT_CHARS = 200;
40
+ export const TOOL_RESULT_CHARS = 600;
41
+ function clip(text, max) {
42
+ const flat = text.replace(/\s+/g, " ").trim();
43
+ return flat.length > max ? `${flat.slice(0, max)}…` : flat;
44
+ }
45
+ // "mcp__remote-devices__ocean__brain_search" → "brain_search".
46
+ const toolName = (name) => typeof name === "string" && name ? (name.split("__").at(-1) ?? name) : "tool";
47
+ function toolInput(input) {
48
+ if (typeof input === "string")
49
+ return clip(input, TOOL_INPUT_CHARS);
50
+ if (!isObject(input) || Object.keys(input).length === 0)
51
+ return "";
52
+ // The app keeps a one-line summary of the call's input where it has one.
53
+ if (typeof input.summary === "string" && Object.keys(input).length === 1)
54
+ return clip(input.summary, TOOL_INPUT_CHARS);
55
+ return clip(JSON.stringify(input), TOOL_INPUT_CHARS);
56
+ }
57
+ function toolResult(content) {
58
+ if (typeof content === "string")
59
+ return clip(content, TOOL_RESULT_CHARS);
60
+ if (!Array.isArray(content))
61
+ return "";
62
+ return clip(content
63
+ .filter((part) => isObject(part) &&
64
+ part.type === "text" &&
65
+ typeof part.text === "string")
66
+ .map((part) => part.text)
67
+ .join(" "), TOOL_RESULT_CHARS);
68
+ }
69
+ // The text of a message: its `text` blocks, and each tool call and result as one bracketed line
70
+ // (T-329: a capture without them missed what the assistant actually did and found). Thinking
71
+ // and attachments are left out.
72
+ export function messageText(content) {
40
73
  if (!Array.isArray(content))
41
74
  return "";
42
- return content
43
- .filter((block) => isObject(block) &&
44
- block.type === "text" &&
45
- typeof block.text === "string")
46
- .map((block) => block.text.trim())
47
- .filter(Boolean)
48
- .join("\n\n");
75
+ const parts = [];
76
+ for (const block of content) {
77
+ if (!isObject(block))
78
+ continue;
79
+ if (block.type === "text" && typeof block.text === "string") {
80
+ const text = block.text.trim();
81
+ if (text)
82
+ parts.push(text);
83
+ }
84
+ else if (block.type === "tool_use") {
85
+ const input = toolInput(block.input);
86
+ parts.push(`[tool ${toolName(block.name)}${input ? `: ${input}` : ""}]`);
87
+ }
88
+ else if (block.type === "tool_result") {
89
+ const result = toolResult(block.content);
90
+ const label = block.is_error === true ? "tool error" : "tool result";
91
+ if (result)
92
+ parts.push(`[${label}: ${result}]`);
93
+ }
94
+ }
95
+ return parts.join("\n\n");
49
96
  }
50
97
  function rawMessage(value) {
51
98
  if (!isObject(value))
@@ -68,7 +115,7 @@ function rawMessage(value) {
68
115
  }
69
116
  // An edited or retried message leaves sibling branches in the tree. The conversation is the
70
117
  // branch that ends at the newest leaf: highest index, then latest creation.
71
- export function currentBranch(all) {
118
+ function currentBranch(all) {
72
119
  const byUuid = new Map(all.map((message) => [message.uuid, message]));
73
120
  const parents = new Set(all.map((message) => message.parent));
74
121
  const leaves = all.filter((message) => !parents.has(message.uuid));
@@ -9,7 +9,7 @@ import { unsnappy, varint } from "./snappy.js";
9
9
  // Blink-serialized value or a wrapper: 0xFF 0x11 0x02 + raw Snappy of one, or 0xFF 0x11 0x01 +
10
10
  // size + blob index, meaning the bytes are in that blob file. A Blink value is 0xFF + version
11
11
  // (+ 0xFE and a 12-byte trailer from version 21), then V8's own serialization.
12
- export class IndexedDbFormatError extends Error {
12
+ class IndexedDbFormatError extends Error {
13
13
  }
14
14
  const OBJECT_STORE_DATA = 1;
15
15
  const BLOB_ENTRY = 3;
@@ -17,7 +17,7 @@ const OBJECT_STORE_META = 50;
17
17
  const WRAPPED = 0x11;
18
18
  const WRAPPED_IN_BLOB = 0x01;
19
19
  const WRAPPED_SNAPPY = 0x02;
20
- export function keyPrefix(key) {
20
+ function keyPrefix(key) {
21
21
  if (key.length < 4)
22
22
  return null;
23
23
  const first = key[0];
@@ -69,7 +69,7 @@ function blinkValue(bytes) {
69
69
  }
70
70
  // A record's blob list: per blob, is-file flag, blob number, MIME type, then size (a plain blob)
71
71
  // or name and modification time (a File). Only plain blobs are read.
72
- export function blobNumbers(value) {
72
+ function blobNumbers(value) {
73
73
  const numbers = [];
74
74
  let pos = 0;
75
75
  while (pos < value.length) {
@@ -86,7 +86,7 @@ export function blobNumbers(value) {
86
86
  }
87
87
  return numbers;
88
88
  }
89
- export function blobPath(blobDir, database, number) {
89
+ function blobPath(blobDir, database, number) {
90
90
  return path.join(blobDir, database.toString(16), (Math.floor(number / 256) % 256).toString(16).padStart(2, "0"), number.toString(16));
91
91
  }
92
92
  async function wireValue(bytes, blob, depth = 0) {