@geminixiang/mikan 1.0.0-beta.44 → 1.0.0-beta.46

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 (422) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +12 -19
  3. package/dist/adapter.d.ts +1 -1
  4. package/dist/adapter.d.ts.map +1 -1
  5. package/dist/adapter.js.map +1 -1
  6. package/dist/adapters/discord/bot.d.ts +3 -1
  7. package/dist/adapters/discord/bot.d.ts.map +1 -1
  8. package/dist/adapters/discord/bot.js +143 -141
  9. package/dist/adapters/discord/bot.js.map +1 -1
  10. package/dist/adapters/discord/context.d.ts +2 -8
  11. package/dist/adapters/discord/context.d.ts.map +1 -1
  12. package/dist/adapters/discord/context.js +1 -1
  13. package/dist/adapters/discord/context.js.map +1 -1
  14. package/dist/adapters/discord/format.d.ts.map +1 -1
  15. package/dist/adapters/discord/format.js +2 -4
  16. package/dist/adapters/discord/format.js.map +1 -1
  17. package/dist/adapters/github/bot.d.ts.map +1 -1
  18. package/dist/adapters/github/bot.js +1 -4
  19. package/dist/adapters/github/bot.js.map +1 -1
  20. package/dist/adapters/github/context.d.ts +2 -9
  21. package/dist/adapters/github/context.d.ts.map +1 -1
  22. package/dist/adapters/github/context.js.map +1 -1
  23. package/dist/adapters/github/github-ops.d.ts +4 -17
  24. package/dist/adapters/github/github-ops.d.ts.map +1 -1
  25. package/dist/adapters/github/github-ops.js +17 -86
  26. package/dist/adapters/github/github-ops.js.map +1 -1
  27. package/dist/adapters/github/tool-pack.d.ts.map +1 -1
  28. package/dist/adapters/github/tool-pack.js +0 -1
  29. package/dist/adapters/github/tool-pack.js.map +1 -1
  30. package/dist/adapters/github/tools/checks.d.ts +0 -1
  31. package/dist/adapters/github/tools/checks.d.ts.map +1 -1
  32. package/dist/adapters/github/tools/checks.js +3 -22
  33. package/dist/adapters/github/tools/checks.js.map +1 -1
  34. package/dist/adapters/github/types.d.ts +0 -33
  35. package/dist/adapters/github/types.d.ts.map +1 -1
  36. package/dist/adapters/github/types.js.map +1 -1
  37. package/dist/adapters/progressive-renderer.d.ts.map +1 -1
  38. package/dist/adapters/progressive-renderer.js +311 -318
  39. package/dist/adapters/progressive-renderer.js.map +1 -1
  40. package/dist/adapters/slack/blocks.d.ts.map +1 -1
  41. package/dist/adapters/slack/blocks.js +1 -4
  42. package/dist/adapters/slack/blocks.js.map +1 -1
  43. package/dist/adapters/slack/bot.d.ts +12 -0
  44. package/dist/adapters/slack/bot.d.ts.map +1 -1
  45. package/dist/adapters/slack/bot.js +158 -178
  46. package/dist/adapters/slack/bot.js.map +1 -1
  47. package/dist/adapters/slack/context.d.ts +2 -8
  48. package/dist/adapters/slack/context.d.ts.map +1 -1
  49. package/dist/adapters/slack/context.js +1 -1
  50. package/dist/adapters/slack/context.js.map +1 -1
  51. package/dist/adapters/slack/response-lifecycle.d.ts.map +1 -1
  52. package/dist/adapters/slack/response-lifecycle.js +135 -123
  53. package/dist/adapters/slack/response-lifecycle.js.map +1 -1
  54. package/dist/adapters/slack/stream-limits.d.ts +1 -1
  55. package/dist/adapters/slack/stream-limits.js +1 -1
  56. package/dist/adapters/slack/stream-limits.js.map +1 -1
  57. package/dist/adapters/slack/types.d.ts +4 -0
  58. package/dist/adapters/slack/types.d.ts.map +1 -1
  59. package/dist/adapters/slack/types.js.map +1 -1
  60. package/dist/adapters/telegram/context.d.ts +2 -8
  61. package/dist/adapters/telegram/context.d.ts.map +1 -1
  62. package/dist/adapters/telegram/context.js +1 -2
  63. package/dist/adapters/telegram/context.js.map +1 -1
  64. package/dist/adapters/types.d.ts +11 -5
  65. package/dist/adapters/types.d.ts.map +1 -1
  66. package/dist/adapters/types.js.map +1 -1
  67. package/dist/agent/catalog.d.ts +6 -18
  68. package/dist/agent/catalog.d.ts.map +1 -1
  69. package/dist/agent/catalog.js +19 -155
  70. package/dist/agent/catalog.js.map +1 -1
  71. package/dist/agent/execution.d.ts +0 -7
  72. package/dist/agent/execution.d.ts.map +1 -1
  73. package/dist/agent/execution.js +23 -21
  74. package/dist/agent/execution.js.map +1 -1
  75. package/dist/agent/presenter.d.ts +7 -9
  76. package/dist/agent/presenter.d.ts.map +1 -1
  77. package/dist/agent/presenter.js +355 -357
  78. package/dist/agent/presenter.js.map +1 -1
  79. package/dist/agent/prompt.d.ts +5 -12
  80. package/dist/agent/prompt.d.ts.map +1 -1
  81. package/dist/agent/prompt.js +56 -81
  82. package/dist/agent/prompt.js.map +1 -1
  83. package/dist/agent/runner.d.ts +0 -7
  84. package/dist/agent/runner.d.ts.map +1 -1
  85. package/dist/agent/runner.js +255 -308
  86. package/dist/agent/runner.js.map +1 -1
  87. package/dist/agent/types.d.ts +21 -17
  88. package/dist/agent/types.d.ts.map +1 -1
  89. package/dist/agent/types.js +0 -1
  90. package/dist/agent/types.js.map +1 -1
  91. package/dist/cli/boot.d.ts.map +1 -1
  92. package/dist/cli/boot.js +7 -10
  93. package/dist/cli/boot.js.map +1 -1
  94. package/dist/cli/onboard.d.ts +10 -0
  95. package/dist/cli/onboard.d.ts.map +1 -0
  96. package/dist/cli/onboard.js +237 -0
  97. package/dist/cli/onboard.js.map +1 -0
  98. package/dist/cli/types.d.ts +8 -3
  99. package/dist/cli/types.d.ts.map +1 -1
  100. package/dist/cli/types.js.map +1 -1
  101. package/dist/commands/auto-reply.d.ts.map +1 -1
  102. package/dist/commands/auto-reply.js +5 -12
  103. package/dist/commands/auto-reply.js.map +1 -1
  104. package/dist/commands/manifest.d.ts.map +1 -1
  105. package/dist/commands/manifest.js +9 -16
  106. package/dist/commands/manifest.js.map +1 -1
  107. package/dist/commands/new.d.ts.map +1 -1
  108. package/dist/commands/new.js +15 -10
  109. package/dist/commands/new.js.map +1 -1
  110. package/dist/commands/registry.d.ts.map +1 -1
  111. package/dist/commands/registry.js +0 -2
  112. package/dist/commands/registry.js.map +1 -1
  113. package/dist/commands/sandbox.d.ts.map +1 -1
  114. package/dist/commands/sandbox.js +89 -70
  115. package/dist/commands/sandbox.js.map +1 -1
  116. package/dist/commands/session-view.js +9 -2
  117. package/dist/commands/session-view.js.map +1 -1
  118. package/dist/commands/types.d.ts +4 -3
  119. package/dist/commands/types.d.ts.map +1 -1
  120. package/dist/commands/types.js.map +1 -1
  121. package/dist/config.d.ts +13 -17
  122. package/dist/config.d.ts.map +1 -1
  123. package/dist/config.js +39 -37
  124. package/dist/config.js.map +1 -1
  125. package/dist/dream/index.d.ts +20 -0
  126. package/dist/dream/index.d.ts.map +1 -0
  127. package/dist/dream/index.js +253 -0
  128. package/dist/dream/index.js.map +1 -0
  129. package/dist/dream/types.d.ts +30 -0
  130. package/dist/dream/types.d.ts.map +1 -0
  131. package/dist/dream/types.js.map +1 -0
  132. package/dist/env-manifest.d.ts.map +1 -1
  133. package/dist/env-manifest.js +2 -34
  134. package/dist/env-manifest.js.map +1 -1
  135. package/dist/execution-resolver.d.ts +9 -2
  136. package/dist/execution-resolver.d.ts.map +1 -1
  137. package/dist/execution-resolver.js +26 -27
  138. package/dist/execution-resolver.js.map +1 -1
  139. package/dist/harness/event-format.d.ts +1 -2
  140. package/dist/harness/event-format.d.ts.map +1 -1
  141. package/dist/harness/event-format.js +9 -15
  142. package/dist/harness/event-format.js.map +1 -1
  143. package/dist/harness/index.d.ts +1 -7
  144. package/dist/harness/index.d.ts.map +1 -1
  145. package/dist/harness/index.js +0 -4
  146. package/dist/harness/index.js.map +1 -1
  147. package/dist/harness/models.d.ts.map +1 -1
  148. package/dist/harness/models.js +15 -35
  149. package/dist/harness/models.js.map +1 -1
  150. package/dist/harness/runner.d.ts +7 -16
  151. package/dist/harness/runner.d.ts.map +1 -1
  152. package/dist/harness/runner.js +13 -131
  153. package/dist/harness/runner.js.map +1 -1
  154. package/dist/harness/session-store.d.ts +1 -1
  155. package/dist/harness/session-store.d.ts.map +1 -1
  156. package/dist/harness/session-store.js +1 -1
  157. package/dist/harness/session-store.js.map +1 -1
  158. package/dist/harness/subagent-runner.d.ts +2 -2
  159. package/dist/harness/subagent-runner.d.ts.map +1 -1
  160. package/dist/harness/subagent-runner.js +157 -162
  161. package/dist/harness/subagent-runner.js.map +1 -1
  162. package/dist/harness/types.d.ts +1 -13
  163. package/dist/harness/types.d.ts.map +1 -1
  164. package/dist/harness/types.js.map +1 -1
  165. package/dist/index.d.ts +3 -9
  166. package/dist/index.d.ts.map +1 -1
  167. package/dist/index.js +1 -5
  168. package/dist/index.js.map +1 -1
  169. package/dist/main.js +31 -212
  170. package/dist/main.js.map +1 -1
  171. package/dist/mcp/catalog.d.ts +5 -0
  172. package/dist/mcp/catalog.d.ts.map +1 -0
  173. package/dist/mcp/catalog.js +135 -0
  174. package/dist/mcp/catalog.js.map +1 -0
  175. package/dist/mcp/loader.d.ts.map +1 -1
  176. package/dist/mcp/loader.js +3 -6
  177. package/dist/mcp/loader.js.map +1 -1
  178. package/dist/mcp/types.d.ts +22 -0
  179. package/dist/mcp/types.d.ts.map +1 -1
  180. package/dist/mcp/types.js.map +1 -1
  181. package/dist/office/index.d.ts +136 -8
  182. package/dist/office/index.d.ts.map +1 -1
  183. package/dist/office/index.js +1050 -9
  184. package/dist/office/index.js.map +1 -1
  185. package/dist/office/types.d.ts +19 -1
  186. package/dist/office/types.d.ts.map +1 -1
  187. package/dist/office/types.js.map +1 -1
  188. package/dist/packages/index.d.ts +168 -5
  189. package/dist/packages/index.d.ts.map +1 -1
  190. package/dist/packages/index.js +749 -5
  191. package/dist/packages/index.js.map +1 -1
  192. package/dist/packages/types.d.ts +1 -5
  193. package/dist/packages/types.d.ts.map +1 -1
  194. package/dist/packages/types.js.map +1 -1
  195. package/dist/provisioner.d.ts +2 -9
  196. package/dist/provisioner.d.ts.map +1 -1
  197. package/dist/provisioner.js +3 -12
  198. package/dist/provisioner.js.map +1 -1
  199. package/dist/runtime/conversation-runtime.d.ts.map +1 -1
  200. package/dist/runtime/conversation-runtime.js +117 -380
  201. package/dist/runtime/conversation-runtime.js.map +1 -1
  202. package/dist/runtime/session-lifecycle.d.ts +32 -18
  203. package/dist/runtime/session-lifecycle.d.ts.map +1 -1
  204. package/dist/runtime/session-lifecycle.js +159 -46
  205. package/dist/runtime/session-lifecycle.js.map +1 -1
  206. package/dist/runtime/types.d.ts +4 -26
  207. package/dist/runtime/types.d.ts.map +1 -1
  208. package/dist/runtime/types.js.map +1 -1
  209. package/dist/sandbox/cloudflare.d.ts.map +1 -1
  210. package/dist/sandbox/cloudflare.js +2 -3
  211. package/dist/sandbox/cloudflare.js.map +1 -1
  212. package/dist/sandbox/container.d.ts +0 -1
  213. package/dist/sandbox/container.d.ts.map +1 -1
  214. package/dist/sandbox/container.js +2 -3
  215. package/dist/sandbox/container.js.map +1 -1
  216. package/dist/sandbox/host.d.ts.map +1 -1
  217. package/dist/sandbox/host.js +4 -2
  218. package/dist/sandbox/host.js.map +1 -1
  219. package/dist/sandbox/identity.d.ts +10 -19
  220. package/dist/sandbox/identity.d.ts.map +1 -1
  221. package/dist/sandbox/identity.js +8 -8
  222. package/dist/sandbox/identity.js.map +1 -1
  223. package/dist/sandbox/index.d.ts +7 -10
  224. package/dist/sandbox/index.d.ts.map +1 -1
  225. package/dist/sandbox/index.js +45 -16
  226. package/dist/sandbox/index.js.map +1 -1
  227. package/dist/sandbox/types.d.ts +13 -45
  228. package/dist/sandbox/types.d.ts.map +1 -1
  229. package/dist/sandbox/types.js.map +1 -1
  230. package/dist/sandbox/utils.d.ts +5 -0
  231. package/dist/sandbox/utils.d.ts.map +1 -1
  232. package/dist/sandbox/utils.js +10 -0
  233. package/dist/sandbox/utils.js.map +1 -1
  234. package/dist/sessions/chat-history-sync.d.ts +1 -3
  235. package/dist/sessions/chat-history-sync.d.ts.map +1 -1
  236. package/dist/sessions/chat-history-sync.js +58 -11
  237. package/dist/sessions/chat-history-sync.js.map +1 -1
  238. package/dist/sessions/migrate-v3.d.ts +2 -5
  239. package/dist/sessions/migrate-v3.d.ts.map +1 -1
  240. package/dist/sessions/migrate-v3.js +34 -4
  241. package/dist/sessions/migrate-v3.js.map +1 -1
  242. package/dist/sessions/store.d.ts +5 -6
  243. package/dist/sessions/store.d.ts.map +1 -1
  244. package/dist/sessions/store.js +62 -2
  245. package/dist/sessions/store.js.map +1 -1
  246. package/dist/sessions/types.d.ts +9 -0
  247. package/dist/sessions/types.d.ts.map +1 -1
  248. package/dist/sessions/types.js.map +1 -1
  249. package/dist/tools/bash.d.ts.map +1 -1
  250. package/dist/tools/bash.js +2 -10
  251. package/dist/tools/bash.js.map +1 -1
  252. package/dist/tools/read.js +2 -2
  253. package/dist/tools/read.js.map +1 -1
  254. package/dist/tools/sandbox.d.ts.map +1 -1
  255. package/dist/tools/sandbox.js +2 -3
  256. package/dist/tools/sandbox.js.map +1 -1
  257. package/dist/tools/subagent.d.ts +1 -1
  258. package/dist/tools/subagent.js.map +1 -1
  259. package/dist/types.d.ts +38 -127
  260. package/dist/types.d.ts.map +1 -1
  261. package/dist/types.js.map +1 -1
  262. package/dist/vault/index.d.ts +9 -2
  263. package/dist/vault/index.d.ts.map +1 -1
  264. package/dist/vault/index.js +29 -5
  265. package/dist/vault/index.js.map +1 -1
  266. package/dist/web/admin/portal.d.ts +12 -1
  267. package/dist/web/admin/portal.d.ts.map +1 -1
  268. package/dist/web/admin/portal.js +437 -422
  269. package/dist/web/admin/portal.js.map +1 -1
  270. package/dist/web/admin/types.d.ts +2 -2
  271. package/dist/web/admin/types.d.ts.map +1 -1
  272. package/dist/web/admin/types.js.map +1 -1
  273. package/dist/web/login/portal.d.ts +7 -1
  274. package/dist/web/login/portal.d.ts.map +1 -1
  275. package/dist/web/login/portal.js +143 -78
  276. package/dist/web/login/portal.js.map +1 -1
  277. package/dist/web/portal-shell.d.ts +1 -0
  278. package/dist/web/portal-shell.d.ts.map +1 -1
  279. package/dist/web/portal-shell.js +12 -1
  280. package/dist/web/portal-shell.js.map +1 -1
  281. package/dist/web/server.d.ts +3 -3
  282. package/dist/web/server.d.ts.map +1 -1
  283. package/dist/web/server.js.map +1 -1
  284. package/dist/web/session-view/portal.d.ts +8 -1
  285. package/dist/web/session-view/portal.d.ts.map +1 -1
  286. package/dist/web/session-view/portal.js +609 -132
  287. package/dist/web/session-view/portal.js.map +1 -1
  288. package/dist/web/session-view/types.d.ts +8 -0
  289. package/dist/web/session-view/types.d.ts.map +1 -1
  290. package/dist/web/session-view/types.js.map +1 -1
  291. package/dist/workspace-projection/index.d.ts +14 -2
  292. package/dist/workspace-projection/index.d.ts.map +1 -1
  293. package/dist/workspace-projection/index.js +102 -14
  294. package/dist/workspace-projection/index.js.map +1 -1
  295. package/dist/workspace-projection/types.d.ts +14 -1
  296. package/dist/workspace-projection/types.d.ts.map +1 -1
  297. package/dist/workspace-projection/types.js.map +1 -1
  298. package/package.json +3 -5
  299. package/dist/adapters/github/cloudbuild.d.ts +0 -19
  300. package/dist/adapters/github/cloudbuild.d.ts.map +0 -1
  301. package/dist/adapters/github/cloudbuild.js +0 -71
  302. package/dist/adapters/github/cloudbuild.js.map +0 -1
  303. package/dist/adapters/github/gcp-auth.d.ts +0 -28
  304. package/dist/adapters/github/gcp-auth.d.ts.map +0 -1
  305. package/dist/adapters/github/gcp-auth.js +0 -196
  306. package/dist/adapters/github/gcp-auth.js.map +0 -1
  307. package/dist/agent/index.d.ts +0 -9
  308. package/dist/agent/index.d.ts.map +0 -1
  309. package/dist/agent/index.js +0 -8
  310. package/dist/agent/index.js.map +0 -1
  311. package/dist/cli/ext-dev.d.ts +0 -2
  312. package/dist/cli/ext-dev.d.ts.map +0 -1
  313. package/dist/cli/ext-dev.js +0 -188
  314. package/dist/cli/ext-dev.js.map +0 -1
  315. package/dist/cli/ext.d.ts +0 -2
  316. package/dist/cli/ext.d.ts.map +0 -1
  317. package/dist/cli/ext.js +0 -324
  318. package/dist/cli/ext.js.map +0 -1
  319. package/dist/commands/extensions.d.ts +0 -26
  320. package/dist/commands/extensions.d.ts.map +0 -1
  321. package/dist/commands/extensions.js +0 -103
  322. package/dist/commands/extensions.js.map +0 -1
  323. package/dist/extension-schedules.d.ts +0 -31
  324. package/dist/extension-schedules.d.ts.map +0 -1
  325. package/dist/extension-schedules.js +0 -229
  326. package/dist/extension-schedules.js.map +0 -1
  327. package/dist/harness/auth.d.ts +0 -17
  328. package/dist/harness/auth.d.ts.map +0 -1
  329. package/dist/harness/auth.js +0 -92
  330. package/dist/harness/auth.js.map +0 -1
  331. package/dist/harness/extensions/loader.d.ts +0 -40
  332. package/dist/harness/extensions/loader.d.ts.map +0 -1
  333. package/dist/harness/extensions/loader.js +0 -723
  334. package/dist/harness/extensions/loader.js.map +0 -1
  335. package/dist/harness/extensions/registry.d.ts +0 -155
  336. package/dist/harness/extensions/registry.d.ts.map +0 -1
  337. package/dist/harness/extensions/registry.js +0 -420
  338. package/dist/harness/extensions/registry.js.map +0 -1
  339. package/dist/harness/extensions/types.d.ts +0 -665
  340. package/dist/harness/extensions/types.d.ts.map +0 -1
  341. package/dist/harness/extensions/types.js.map +0 -1
  342. package/dist/office/address.d.ts +0 -31
  343. package/dist/office/address.d.ts.map +0 -1
  344. package/dist/office/address.js +0 -113
  345. package/dist/office/address.js.map +0 -1
  346. package/dist/office/layout.d.ts +0 -27
  347. package/dist/office/layout.d.ts.map +0 -1
  348. package/dist/office/layout.js +0 -97
  349. package/dist/office/layout.js.map +0 -1
  350. package/dist/office/migration.d.ts +0 -44
  351. package/dist/office/migration.d.ts.map +0 -1
  352. package/dist/office/migration.js +0 -255
  353. package/dist/office/migration.js.map +0 -1
  354. package/dist/office/registry.d.ts +0 -75
  355. package/dist/office/registry.d.ts.map +0 -1
  356. package/dist/office/registry.js +0 -646
  357. package/dist/office/registry.js.map +0 -1
  358. package/dist/packages/admin.d.ts +0 -17
  359. package/dist/packages/admin.d.ts.map +0 -1
  360. package/dist/packages/admin.js +0 -98
  361. package/dist/packages/admin.js.map +0 -1
  362. package/dist/packages/inspect.d.ts +0 -11
  363. package/dist/packages/inspect.d.ts.map +0 -1
  364. package/dist/packages/inspect.js +0 -98
  365. package/dist/packages/inspect.js.map +0 -1
  366. package/dist/packages/materialize.d.ts +0 -40
  367. package/dist/packages/materialize.d.ts.map +0 -1
  368. package/dist/packages/materialize.js +0 -297
  369. package/dist/packages/materialize.js.map +0 -1
  370. package/dist/packages/resolve.d.ts +0 -25
  371. package/dist/packages/resolve.d.ts.map +0 -1
  372. package/dist/packages/resolve.js +0 -208
  373. package/dist/packages/resolve.js.map +0 -1
  374. package/dist/packages/source.d.ts +0 -39
  375. package/dist/packages/source.d.ts.map +0 -1
  376. package/dist/packages/source.js +0 -189
  377. package/dist/packages/source.js.map +0 -1
  378. package/dist/sandbox/errors.d.ts +0 -6
  379. package/dist/sandbox/errors.d.ts.map +0 -1
  380. package/dist/sandbox/errors.js +0 -11
  381. package/dist/sandbox/errors.js.map +0 -1
  382. package/dist/sandbox/firecracker.d.ts +0 -18
  383. package/dist/sandbox/firecracker.d.ts.map +0 -1
  384. package/dist/sandbox/firecracker.js +0 -223
  385. package/dist/sandbox/firecracker.js.map +0 -1
  386. package/dist/sandbox/gondolin.d.ts +0 -57
  387. package/dist/sandbox/gondolin.d.ts.map +0 -1
  388. package/dist/sandbox/gondolin.js +0 -764
  389. package/dist/sandbox/gondolin.js.map +0 -1
  390. package/dist/sandbox/image.d.ts +0 -3
  391. package/dist/sandbox/image.d.ts.map +0 -1
  392. package/dist/sandbox/image.js +0 -29
  393. package/dist/sandbox/image.js.map +0 -1
  394. package/dist/sessions/conversation-log.d.ts +0 -9
  395. package/dist/sessions/conversation-log.d.ts.map +0 -1
  396. package/dist/sessions/conversation-log.js +0 -50
  397. package/dist/sessions/conversation-log.js.map +0 -1
  398. package/dist/sessions/rotation.d.ts +0 -2
  399. package/dist/sessions/rotation.d.ts.map +0 -1
  400. package/dist/sessions/rotation.js +0 -41
  401. package/dist/sessions/rotation.js.map +0 -1
  402. package/dist/vault/disabled.d.ts +0 -9
  403. package/dist/vault/disabled.d.ts.map +0 -1
  404. package/dist/vault/disabled.js +0 -25
  405. package/dist/vault/disabled.js.map +0 -1
  406. package/dist/web/admin/store.d.ts +0 -13
  407. package/dist/web/admin/store.d.ts.map +0 -1
  408. package/dist/web/admin/store.js +0 -14
  409. package/dist/web/admin/store.js.map +0 -1
  410. package/dist/web/login/store.d.ts +0 -8
  411. package/dist/web/login/store.d.ts.map +0 -1
  412. package/dist/web/login/store.js +0 -15
  413. package/dist/web/login/store.js.map +0 -1
  414. package/dist/web/session-view/service.d.ts +0 -6
  415. package/dist/web/session-view/service.d.ts.map +0 -1
  416. package/dist/web/session-view/service.js +0 -517
  417. package/dist/web/session-view/service.js.map +0 -1
  418. package/dist/web/session-view/store.d.ts +0 -8
  419. package/dist/web/session-view/store.d.ts.map +0 -1
  420. package/dist/web/session-view/store.js +0 -15
  421. package/dist/web/session-view/store.js.map +0 -1
  422. /package/dist/{harness/extensions → dream}/types.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/office/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,cAAc,EACd,UAAU,EACV,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,wBAAwB,GAGzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AACjG,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,oBAAoB,GACrB,MAAM,gBAAgB,CAAC","sourcesContent":["/**\n * The Conversation office module: canonical identity (`address.ts`), the\n * Workspace/Office layout values (`layout.ts`), the durable registry journal\n * (`registry.ts`), and the boot-time legacy migration (`migration.ts`).\n * Everything outside `src/office/` imports from this barrel.\n */\nexport {\n assertConversationId,\n assertOfficeKey,\n assertPlatformName,\n createOfficeAddress,\n isOfficeKey,\n officeKey,\n officeStateDir,\n sameOffice,\n validateOfficeAddress,\n} from \"./address.js\";\nexport {\n createWorkspace,\n officeSessionsDir,\n RESERVED_WORKSPACE_NAMES,\n type Office,\n type Workspace,\n} from \"./layout.js\";\nexport { listRegisteredOffices, OfficeRegistry, resolveOwnedOfficeAddress } from \"./registry.js\";\nexport {\n buildContainerBindTranslator,\n formatUnmigratedOfficesError,\n migrateLegacyOffices,\n} from \"./migration.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/office/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EACL,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,MAAM,EACN,QAAQ,EACR,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAajC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAEjG,iFAAiF;AAEjF,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAC9C,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,cAAc,GAAG,IAAI,GAAG,CAAe,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AACzF,MAAM,kBAAkB,GACtB,4EAA4E,CAAC;AAE/E,wEAAwE;AACxE,MAAM,UAAU,mBAAmB,CAA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AAS,CAAC,IAAI,CAAC;YACb,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,+BAA+B,CAAC,KAAK,CAAC,CAAC;YACxE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,CAAC;SACtC,CAAC,CAAC;QACH,UAAU,CAAC,IAAI,CAAC,CAAC,cAAc,KAAK,EAAE,EAAE,cAAc,GAAG,EAAE,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,CAAC,QAAgB,EAAU,EAAE;QAClC,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACzD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,SAAS,KAAK,CAAC,CAAC;YAAE,OAAO,QAAQ,CAAC;QACtC,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC;QAClE,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QACpE,OAAO,GAAG,MAAM,IAAI,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACvD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The Conversation office module: canonical identity, the Workspace/Office\n * layout values, the durable registry journal, and the boot-time legacy\n * migration. Everything outside `src/office/` imports from this module;\n * exported types live in `types.ts` per module convention.\n */\nimport { createHash, randomBytes } from \"node:crypto\";\nimport {\n existsSync,\n lstatSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n renameSync,\n rmSync,\n statSync,\n writeFileSync,\n} from \"node:fs\";\nimport { isAbsolute, join, resolve } from \"node:path\";\nimport * as log from \"../log.js\";\nimport type {\n OfficeAddress,\n OfficeKey,\n OfficeMigrationPreparation,\n OfficeMigrationRecord,\n OfficeMigrationStatus,\n OfficeRecord,\n OfficeRegistryState,\n PlatformName,\n} from \"../types.js\";\nimport type { Office, OfficeMigrationRunSummary, Workspace } from \"./types.js\";\nexport type { Office, OfficeMigrationRunSummary, Workspace } from \"./types.js\";\nimport { parseGithubConversationId } from \"../adapters/github/ids.js\";\nimport { legacyConversationCredentialKey } from \"../sandbox/identity.js\";\nimport { migrateConversationVaultKeys } from \"../vault/index.js\";\nimport { atomicWritePrivateFile, isRecord, readTextFileIfExists } from \"../utils/file-guards.js\";\n\n// ── Office identity (address & keys) ──────────────────────────────────────────\n\nconst OFFICE_KEY_VERSION = \"v1\";\nconst OFFICE_KEY_DOMAIN = \"office-address-v1\";\nconst OFFICE_KEY_DIGEST_LENGTH = 16;\nconst READABLE_ID_LENGTH = 32;\nconst PLATFORM_NAMES = new Set<PlatformName>([\"slack\", \"discord\", \"telegram\", \"github\"]);\nconst OFFICE_KEY_PATTERN =\n /^v1-(slack|discord|telegram|github)-[a-z0-9]+(?:-[a-z0-9]+)*-[a-f0-9]{16}$/;\n\n/** Construct the canonical identity used by future office consumers. */\nexport function createOfficeAddress(platform: PlatformName, conversationId: string): OfficeAddress {\n assertPlatformName(platform);\n assertConversationId(conversationId);\n return Object.freeze({ platform, conversationId });\n}\n\n/** Validate an untrusted runtime value as a canonical office address. */\nexport function validateOfficeAddress(value: unknown): OfficeAddress {\n if (!isRecord(value)) throw new Error(\"Office address must be an object\");\n if (typeof value.platform !== \"string\") {\n throw new Error(\"Office address platform must be a string\");\n }\n if (typeof value.conversationId !== \"string\") {\n throw new Error(\"Office address conversation id must be a string\");\n }\n return createOfficeAddress(assertPlatformName(value.platform), value.conversationId);\n}\n\n/** Return true only for a supported platform name. */\nfunction isPlatformName(value: unknown): value is PlatformName {\n return typeof value === \"string\" && PLATFORM_NAMES.has(value as PlatformName);\n}\n\n/** Validate a platform name and return it for typed callers. */\nexport function assertPlatformName(value: string): PlatformName {\n if (!isPlatformName(value)) throw new Error(`Unsupported platform: ${JSON.stringify(value)}`);\n return value;\n}\n\n/** Validate a raw platform conversation identifier before it enters storage. */\nexport function assertConversationId(value: string): string {\n if (value.length === 0 || value === \".\" || value === \"..\") {\n throw new Error(\"Conversation id must be non-empty and not a path marker\");\n }\n for (const character of value) {\n const code = character.codePointAt(0) ?? 0;\n if (\n character === \"/\" ||\n character === \"\\\\\" ||\n code === 0 ||\n code <= 0x1f ||\n (code >= 0x7f && code <= 0x9f)\n ) {\n throw new Error(\"Conversation id must not contain path separators or control characters\");\n }\n }\n return value;\n}\n\n/** Derive a readable diagnostic key whose digest remains the identity authority. */\nexport function officeKey(address: OfficeAddress): OfficeKey {\n const normalized = validateOfficeAddress(address);\n const readable = readableConversationId(normalized.conversationId);\n const digest = createHash(\"sha256\")\n .update(`${OFFICE_KEY_DOMAIN}\\0${normalized.platform}\\0${normalized.conversationId}`)\n .digest(\"hex\")\n .slice(0, OFFICE_KEY_DIGEST_LENGTH);\n return `${OFFICE_KEY_VERSION}-${normalized.platform}-${readable}-${digest}` as OfficeKey;\n}\n\n/**\n * Resolve the persistent workspace directory for an office.\n * Module-internal: registry/migration record target paths with it. Callers\n * outside `src/office/` use the `Office` value's `dir` field instead.\n */\nexport function officeDir(workspaceRoot: string, address: OfficeAddress): string {\n return join(workspaceRoot, officeKey(address));\n}\n\n/**\n * Resolve the host-only state directory for an office.\n *\n * Transitional: settings/package callers that only hold a\n * `stateDir` string keep using this until their option bags carry an\n * `Office` value (which exposes the same path as `stateDir`).\n */\nexport function officeStateDir(stateDir: string, address: OfficeAddress): string {\n return join(stateDir, \"conversations\", officeKey(address));\n}\n\n/** Compare canonical office identities without relying on their readable key. */\nexport function sameOffice(left: OfficeAddress, right: OfficeAddress): boolean {\n const leftAddress = validateOfficeAddress(left);\n const rightAddress = validateOfficeAddress(right);\n return (\n leftAddress.platform === rightAddress.platform &&\n leftAddress.conversationId === rightAddress.conversationId\n );\n}\n\n/** Validate a persisted or externally supplied office key. */\nexport function assertOfficeKey(value: string): OfficeKey {\n if (!OFFICE_KEY_PATTERN.test(value)) {\n throw new Error(`Invalid office key: ${JSON.stringify(value)}`);\n }\n return value as OfficeKey;\n}\n\nexport function isOfficeKey(value: unknown): value is OfficeKey {\n return typeof value === \"string\" && OFFICE_KEY_PATTERN.test(value);\n}\n\nfunction readableConversationId(conversationId: string): string {\n const readable = conversationId\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .slice(0, READABLE_ID_LENGTH)\n .replace(/-+$/g, \"\");\n return readable || \"conversation\";\n}\n\n// ── Workspace/Office layout ───────────────────────────────────────────────────\n/**\n * Workspace-root entries that are shared infrastructure, never office dirs.\n * The single definition behind boot-time directory setup, the events\n * watcher, the workspace projection, and the migration's legacy-dir scan.\n */\nexport const RESERVED_WORKSPACE_NAMES: ReadonlySet<string> = Object.freeze(\n new Set([\"skills\", \"events\", \"agents\", \"MEMORY.md\"]),\n);\n\n/**\n * Construct the Workspace value for a deployment. One construction site per\n * process (main.ts for the daemon; CLI subcommands and tests build their\n * own). The value owns the registry instance and the recorded-office cache\n * that office materialization uses on hot paths, so there is no process-wide\n * registry state.\n */\n/**\n * An office's session files live in `<office dir>/sessions` — the one home of\n * that rule. String-based for surfaces that hold a conversation dir rather\n * than an `Office` value (mirrors `officeStateDir`); `Office.sessionsDir` is\n * derived from it. Pointer/thread-file semantics live in `sessions/store`.\n */\nexport function officeSessionsDir(dir: string): string {\n return join(dir, \"sessions\");\n}\n\nexport function createWorkspace(options: { root: string; stateDir: string }): Workspace {\n // Paths are joined as given (no resolve) so values match what callers\n // passing the same root/stateDir strings computed before this module.\n const { root, stateDir } = options;\n // Lazy: CLI surfaces construct a Workspace for path math without paying\n // for (or being allowed to create) the registry journal.\n let registry: OfficeRegistry | undefined;\n const recorded = new Set<string>();\n const offices = new Map<string, Office>();\n\n const workspace: Workspace = Object.freeze({\n root,\n stateDir,\n memoryPath: join(root, \"MEMORY.md\"),\n skillsDir: join(root, \"skills\"),\n eventsDir: join(root, \"events\"),\n agentsDir: join(root, \"agents\"),\n reservedNames: RESERVED_WORKSPACE_NAMES,\n office(address: OfficeAddress): Office {\n const normalized = validateOfficeAddress(address);\n const key = officeKey(normalized);\n const existing = offices.get(key);\n if (existing) return existing;\n\n const dir = join(root, key);\n const office: Office = Object.freeze({\n address: normalized,\n key,\n dir,\n memoryPath: join(dir, \"MEMORY.md\"),\n skillsDir: join(dir, \"skills\"),\n sessionsDir: officeSessionsDir(dir),\n attachmentsDir: join(dir, \"attachments\"),\n logPath: join(dir, \"log.jsonl\"),\n stateDir: join(stateDir, \"conversations\", key),\n workspace,\n ensure(): string {\n // Record-first ordering: a crash can leave a record without a\n // directory (harmless; recreated on the next message) but never an\n // anonymous office directory the registry cannot enumerate.\n if (!recorded.has(key)) {\n registry ??= new OfficeRegistry(stateDir);\n registry.recordOffice(normalized);\n recorded.add(key);\n }\n ensureRegularOfficeDirectory(dir);\n return dir;\n },\n });\n offices.set(key, office);\n return office;\n },\n });\n return workspace;\n}\n\n/** mkdir-if-missing with the same fail-closed type guard as projection roots. */\nfunction ensureRegularOfficeDirectory(dir: string): void {\n let stats;\n try {\n stats = lstatSync(dir);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") throw err;\n mkdirSync(dir, { recursive: true, mode: 0o700 });\n return;\n }\n if (stats.isSymbolicLink() || !stats.isDirectory()) {\n throw new Error(`Office directory must be a regular non-symlink directory: ${dir}`);\n }\n}\n\n// ── Office registry journal ───────────────────────────────────────────────────\nconst REGISTRY_VERSION = 1;\nconst REGISTRY_FILENAME = \"office-registry.json\";\nconst MIGRATION_STATUSES = new Set<OfficeMigrationStatus>([\n \"needs-owner\",\n \"prepared\",\n \"moving\",\n \"committed\",\n \"failed\",\n]);\nconst REGISTRY_LOCK_FILENAME = \".office-registry.lock\";\nconst REGISTRY_LOCK_RETRY_MS = 25;\nconst REGISTRY_LOCK_TIMEOUT_MS = 5_000;\nconst REGISTRY_LOCK_STALE_MS = 60_000;\n\n/**\n * Host-only office directory and migration journal.\n *\n * Office records are the durable raw-id ↔ (platform, office) mapping: the\n * ADR 0005 layout migration renamed workspace dirs to office keys, so dir\n * names carry no raw platform ids and enumeration/legacy-scope lookups\n * resolve through these records. Migration records track claiming legacy\n * raw-id directories. Office materialization lives in `layout.ts`; this\n * module owns only the durable record and its crash-safe transitions.\n */\ninterface OfficeRegistryOptions {\n writeState?: (path: string, content: string) => void;\n lockTimeoutMs?: number;\n}\n\nexport class OfficeRegistry {\n private readonly stateDir: string;\n private readonly registryPath: string;\n private readonly lockPath: string;\n private readonly writeState: (path: string, content: string) => void;\n private readonly lockTimeoutMs: number;\n private state: OfficeRegistryState;\n\n constructor(stateDir: string, options: OfficeRegistryOptions = {}) {\n this.stateDir = resolve(stateDir);\n mkdirSync(this.stateDir, { recursive: true, mode: 0o700 });\n assertRegularDirectory(this.stateDir, \"State directory\");\n this.registryPath = resolve(this.stateDir, REGISTRY_FILENAME);\n this.lockPath = join(this.stateDir, REGISTRY_LOCK_FILENAME);\n this.writeState = options.writeState ?? atomicWritePrivateFile;\n this.lockTimeoutMs = options.lockTimeoutMs ?? REGISTRY_LOCK_TIMEOUT_MS;\n this.state = this.readState();\n }\n\n /** Reload the atomic registry file after another host process changed it. */\n reload(): OfficeRegistryState {\n this.state = this.readState();\n return this.state;\n }\n\n getState(): OfficeRegistryState {\n return this.state;\n }\n\n getMigration(rawConversationId: string): OfficeMigrationRecord | undefined {\n assertConversationId(rawConversationId);\n return this.state.migrations.find((record) => record.rawConversationId === rawConversationId);\n }\n\n enablePlatform(platform: PlatformName): OfficeRegistryState {\n const validPlatform = assertPlatformName(platform);\n return this.withExclusiveLease(() => {\n if (this.state.enabledPlatforms.includes(validPlatform)) return this.state;\n\n const enabledPlatforms = [...this.state.enabledPlatforms, validPlatform].toSorted();\n this.replaceState(enabledPlatforms, this.state.offices, this.state.migrations);\n return this.state;\n });\n }\n\n /**\n * Record that an office exists. Idempotent: re-recording a known office is\n * a lock-free cache hit for callers that materialize directories per\n * message, so this sits safely on hot write paths.\n */\n recordOffice(address: OfficeAddress): OfficeRecord {\n const normalized = validateOfficeAddress(address);\n const existing = this.findOffice(normalized);\n if (existing) return existing;\n return this.withExclusiveLease(() => {\n const found = this.findOffice(normalized);\n if (found) return found;\n const record: OfficeRecord = Object.freeze({\n platform: normalized.platform,\n conversationId: normalized.conversationId,\n recordedAt: new Date().toISOString(),\n });\n this.replaceState(\n this.state.enabledPlatforms,\n [...this.state.offices, record],\n this.state.migrations,\n );\n return record;\n });\n }\n\n getOffices(): readonly OfficeRecord[] {\n return this.state.offices;\n }\n\n private findOffice(address: OfficeAddress): OfficeRecord | undefined {\n return this.state.offices.find(\n (record) =>\n record.platform === address.platform && record.conversationId === address.conversationId,\n );\n }\n\n /**\n * Validate and record a legacy directory. With exactly one enabled platform,\n * ownership is safe to infer. With zero or multiple platforms, the record\n * remains explicit `needs-owner` unless the caller supplies an owner.\n */\n prepareLegacyMigration(options: OfficeMigrationPreparation): OfficeMigrationRecord {\n const rawConversationId = assertConversationId(options.rawConversationId);\n const sourceDir = resolve(options.sourceDir);\n const workspaceRoot = resolve(options.workspaceRoot);\n return this.withExclusiveLease(() => {\n const existing = this.getMigration(rawConversationId);\n assertCanonicalSource(sourceDir, workspaceRoot, rawConversationId);\n if (existing) {\n assertSameMigrationInputs(existing, sourceDir, workspaceRoot);\n if (existing.status !== \"needs-owner\") return existing;\n }\n\n assertRegularDirectory(sourceDir, \"Legacy office source\");\n const ownerPlatform = this.resolveOwner(options.ownerPlatform, rawConversationId);\n if (!ownerPlatform) {\n const record = makeRecord({\n rawConversationId,\n sourceDir,\n workspaceRoot,\n status: \"needs-owner\",\n });\n this.replaceMigration(existing, record);\n return record;\n }\n\n const targetDir = officeDir(workspaceRoot, {\n platform: ownerPlatform,\n conversationId: rawConversationId,\n });\n if (pathExists(targetDir)) {\n const failed = makeRecord({\n rawConversationId,\n sourceDir,\n workspaceRoot,\n ownerPlatform,\n targetDir,\n status: \"failed\",\n error: \"Target office directory already exists\",\n });\n this.replaceMigration(existing, failed);\n throw new Error(`${failed.error}: ${targetDir}`);\n }\n\n const prepared = makeRecord({\n rawConversationId,\n sourceDir,\n workspaceRoot,\n ownerPlatform,\n targetDir,\n status: \"prepared\",\n });\n this.replaceMigration(existing, prepared);\n return prepared;\n });\n }\n\n markMoving(rawConversationId: string): OfficeMigrationRecord {\n return this.withExclusiveLease(() => {\n const record = this.requireMigration(rawConversationId);\n if (\n record.status === \"moving\" ||\n record.status === \"committed\" ||\n record.status === \"failed\"\n ) {\n return record;\n }\n if (record.status === \"needs-owner\") {\n throw new Error(`Legacy office ${JSON.stringify(rawConversationId)} still needs an owner`);\n }\n assertRegularDirectory(record.sourceDir, \"Legacy office source\");\n const targetDir = migrationTarget(record);\n if (!targetDir) throw new Error(\"Prepared office migration has no target directory\");\n if (pathExists(targetDir)) {\n const failed = this.failRecord(record, \"Target office directory appeared before moving\");\n throw new Error(`${failed.error}: ${targetDir}`);\n }\n\n const moving = transitionRecord(record, \"moving\");\n this.replaceMigration(record, moving);\n return moving;\n });\n }\n\n markCommitted(rawConversationId: string): OfficeMigrationRecord {\n return this.withExclusiveLease(() => {\n const record = this.requireMigration(rawConversationId);\n if (record.status === \"committed\" || record.status === \"failed\") return record;\n if (record.status !== \"moving\") {\n throw new Error(`Cannot commit office migration from ${record.status}`);\n }\n const targetDir = migrationTarget(record);\n if (!targetDir) throw new Error(\"Moving office migration has no target directory\");\n assertRegularDirectory(targetDir, \"Migrated office target\");\n assertPathAbsent(record.sourceDir, \"Legacy office source\");\n\n const committed = transitionRecord(record, \"committed\");\n this.replaceMigration(record, committed);\n return committed;\n });\n }\n\n markFailed(rawConversationId: string, error: string): OfficeMigrationRecord {\n return this.withExclusiveLease(() => {\n const record = this.requireMigration(rawConversationId);\n if (record.status === \"committed\") {\n throw new Error(\"A committed office migration cannot be marked failed\");\n }\n if (record.status === \"failed\") return record;\n return this.failRecord(record, error);\n });\n }\n\n private resolveOwner(\n ownerPlatform: PlatformName | undefined,\n rawConversationId: string,\n ): PlatformName | undefined {\n if (ownerPlatform !== undefined) {\n const validPlatform = assertPlatformName(ownerPlatform);\n if (!this.state.enabledPlatforms.includes(validPlatform)) {\n throw new Error(`Owner platform ${validPlatform} is not enabled`);\n }\n return validPlatform;\n }\n const candidates = platformsMatchingConversationIdFormat(\n rawConversationId,\n this.state.enabledPlatforms,\n );\n return candidates.length === 1 ? candidates[0] : undefined;\n }\n\n private requireMigration(rawConversationId: string): OfficeMigrationRecord {\n assertConversationId(rawConversationId);\n const record = this.getMigration(rawConversationId);\n if (!record) throw new Error(`No office migration registered for ${rawConversationId}`);\n return record;\n }\n\n private failRecord(record: OfficeMigrationRecord, error: string): OfficeMigrationRecord {\n const message = error.trim();\n if (!message) throw new Error(\"Office migration failure reason must not be empty\");\n const failed = transitionRecord(record, \"failed\", message);\n this.replaceMigration(record, failed);\n return failed;\n }\n\n private replaceMigration(\n previous: OfficeMigrationRecord | undefined,\n next: OfficeMigrationRecord,\n ): void {\n const migrations = [...this.state.migrations];\n const index = previous\n ? migrations.findIndex((record) => record.rawConversationId === previous.rawConversationId)\n : -1;\n if (index === -1) migrations.push(next);\n else migrations[index] = next;\n this.replaceState(this.state.enabledPlatforms, this.state.offices, migrations);\n }\n\n private replaceState(\n enabledPlatforms: readonly PlatformName[],\n offices: readonly OfficeRecord[],\n migrations: readonly OfficeMigrationRecord[],\n ): void {\n const candidate = freezeState({ enabledPlatforms, offices, migrations });\n this.writeState(this.registryPath, `${JSON.stringify(candidate, null, 2)}\\n`);\n this.state = candidate;\n }\n\n /**\n * Acquire the domain lease, reload while holding it, then perform one\n * read-modify-write. A future move transaction can retain the same lease\n * across its filesystem operation instead of splitting the transition.\n */\n private withExclusiveLease<T>(operation: () => T): T {\n const release = acquireRegistryLease(this.lockPath, this.lockTimeoutMs);\n try {\n this.state = this.readState();\n return operation();\n } finally {\n release();\n }\n }\n\n private readState(): OfficeRegistryState {\n assertRegistryFileSafe(this.registryPath);\n const raw = readTextFileIfExists(this.registryPath);\n if (raw === undefined) {\n return freezeState({ enabledPlatforms: [], offices: [], migrations: [] });\n }\n\n let value: unknown;\n try {\n value = JSON.parse(raw);\n } catch (error) {\n throw new Error(`Invalid office registry JSON at ${this.registryPath}`, { cause: error });\n }\n return parseState(value, this.registryPath);\n }\n}\n\ninterface RecordFields {\n rawConversationId: string;\n sourceDir: string;\n workspaceRoot: string;\n ownerPlatform?: PlatformName;\n targetDir?: string;\n status: OfficeMigrationStatus;\n error?: string;\n updatedAt?: string;\n}\n\nfunction makeRecord(fields: RecordFields): OfficeMigrationRecord {\n const record: OfficeMigrationRecord = {\n rawConversationId: fields.rawConversationId,\n sourceDir: fields.sourceDir,\n workspaceRoot: fields.workspaceRoot,\n ...(fields.ownerPlatform ? { ownerPlatform: fields.ownerPlatform } : {}),\n ...(fields.targetDir ? { targetDir: fields.targetDir } : {}),\n status: fields.status,\n ...(fields.error ? { error: fields.error } : {}),\n updatedAt: fields.updatedAt ?? new Date().toISOString(),\n };\n return Object.freeze(record);\n}\n\nfunction transitionRecord(\n record: OfficeMigrationRecord,\n status: OfficeMigrationStatus,\n error?: string,\n): OfficeMigrationRecord {\n const targetDir = migrationTarget(record);\n return makeRecord({\n rawConversationId: record.rawConversationId,\n sourceDir: record.sourceDir,\n workspaceRoot: record.workspaceRoot,\n ...(record.ownerPlatform ? { ownerPlatform: record.ownerPlatform } : {}),\n ...(targetDir ? { targetDir } : {}),\n status,\n ...(error ? { error } : {}),\n });\n}\n\nfunction migrationTarget(record: OfficeMigrationRecord): string | undefined {\n return record.ownerPlatform\n ? officeDir(record.workspaceRoot, {\n platform: record.ownerPlatform,\n conversationId: record.rawConversationId,\n })\n : undefined;\n}\n\nfunction freezeState(input: {\n enabledPlatforms: readonly PlatformName[];\n offices: readonly OfficeRecord[];\n migrations: readonly OfficeMigrationRecord[];\n}): OfficeRegistryState {\n return Object.freeze({\n version: REGISTRY_VERSION as 1,\n enabledPlatforms: Object.freeze([...input.enabledPlatforms]),\n offices: Object.freeze(input.offices.map((record) => Object.freeze({ ...record }))),\n migrations: Object.freeze(input.migrations.map((record) => Object.freeze({ ...record }))),\n });\n}\n\nfunction parseState(value: unknown, path: string): OfficeRegistryState {\n if (!isRecord(value) || value.version !== REGISTRY_VERSION) {\n throw new Error(`Invalid office registry version at ${path}`);\n }\n if (!Array.isArray(value.enabledPlatforms) || !Array.isArray(value.migrations)) {\n throw new Error(`Invalid office registry shape at ${path}`);\n }\n\n const enabledPlatforms = value.enabledPlatforms.map((platform) => {\n if (typeof platform !== \"string\") throw new Error(`Invalid enabled platform in ${path}`);\n return assertPlatformName(platform);\n });\n if (new Set(enabledPlatforms).size !== enabledPlatforms.length) {\n throw new Error(`Duplicate enabled platform in ${path}`);\n }\n\n // Files written before office records existed simply have no offices yet.\n const offices = (Array.isArray(value.offices) ? value.offices : []).map((entry) =>\n parseOfficeRecord(entry, path),\n );\n if (new Set(offices.map((record) => officeKey(record))).size !== offices.length) {\n throw new Error(`Duplicate office record in ${path}`);\n }\n\n const migrations = value.migrations.map((entry) => parseRecord(entry, path, enabledPlatforms));\n if (new Set(migrations.map((record) => record.rawConversationId)).size !== migrations.length) {\n throw new Error(`Duplicate office migration in ${path}`);\n }\n return freezeState({ enabledPlatforms, offices, migrations });\n}\n\nfunction parseOfficeRecord(value: unknown, path: string): OfficeRecord {\n if (!isRecord(value)) throw new Error(`Invalid office record in ${path}`);\n if (\n typeof value.platform !== \"string\" ||\n typeof value.conversationId !== \"string\" ||\n typeof value.recordedAt !== \"string\"\n ) {\n throw new Error(`Invalid office record fields in ${path}`);\n }\n return Object.freeze({\n platform: assertPlatformName(value.platform),\n conversationId: assertConversationId(value.conversationId),\n recordedAt: value.recordedAt,\n });\n}\n\nfunction parseRecord(\n value: unknown,\n path: string,\n enabledPlatforms: readonly PlatformName[],\n): OfficeMigrationRecord {\n if (!isRecord(value)) throw new Error(`Invalid office migration record in ${path}`);\n if (\n typeof value.rawConversationId !== \"string\" ||\n typeof value.sourceDir !== \"string\" ||\n typeof value.workspaceRoot !== \"string\" ||\n typeof value.status !== \"string\" ||\n typeof value.updatedAt !== \"string\"\n ) {\n throw new Error(`Invalid office migration fields in ${path}`);\n }\n assertConversationId(value.rawConversationId);\n if (!isAbsolute(value.sourceDir) || !isAbsolute(value.workspaceRoot)) {\n throw new Error(`Office migration paths must be absolute in ${path}`);\n }\n assertCanonicalSource(value.sourceDir, value.workspaceRoot, value.rawConversationId);\n if (!MIGRATION_STATUSES.has(value.status as OfficeMigrationStatus)) {\n throw new Error(`Invalid office migration status in ${path}`);\n }\n\n const ownerPlatform = optionalPlatform(value.ownerPlatform);\n const targetDir = optionalString(value.targetDir);\n const error = optionalString(value.error);\n if (ownerPlatform !== undefined && !enabledPlatforms.includes(ownerPlatform)) {\n throw new Error(`Office migration owner is not enabled in ${path}`);\n }\n if (value.status === \"needs-owner\" && (ownerPlatform !== undefined || targetDir !== undefined)) {\n throw new Error(`Needs-owner migration cannot have an owner or target in ${path}`);\n }\n if (\n value.status !== \"needs-owner\" &&\n value.status !== \"failed\" &&\n (ownerPlatform === undefined || targetDir === undefined)\n ) {\n throw new Error(`Prepared office migration is missing ownership in ${path}`);\n }\n if (ownerPlatform === undefined && targetDir !== undefined) {\n throw new Error(`Office migration target has no owner in ${path}`);\n }\n const expectedTargetDir = ownerPlatform\n ? officeDir(value.workspaceRoot, {\n platform: ownerPlatform,\n conversationId: value.rawConversationId,\n })\n : undefined;\n if (targetDir !== expectedTargetDir) {\n throw new Error(`Office migration target does not match its office address in ${path}`);\n }\n if (value.status === \"failed\" && !error) {\n throw new Error(`Failed office migration is missing an error in ${path}`);\n }\n\n return makeRecord({\n rawConversationId: value.rawConversationId,\n sourceDir: value.sourceDir,\n workspaceRoot: value.workspaceRoot,\n ...(ownerPlatform ? { ownerPlatform } : {}),\n ...(expectedTargetDir ? { targetDir: expectedTargetDir } : {}),\n status: value.status as OfficeMigrationStatus,\n ...(error ? { error } : {}),\n updatedAt: value.updatedAt,\n });\n}\n\nfunction optionalPlatform(value: unknown): PlatformName | undefined {\n return value === undefined\n ? undefined\n : typeof value === \"string\"\n ? assertPlatformName(value)\n : failOptional(\"platform\");\n}\n\nfunction optionalString(value: unknown): string | undefined {\n return value === undefined\n ? undefined\n : typeof value === \"string\"\n ? value\n : failOptional(\"string\");\n}\n\nfunction failOptional(label: string): never {\n throw new Error(`Invalid optional ${label} in office registry`);\n}\n\nfunction assertSameMigrationInputs(\n existing: OfficeMigrationRecord,\n sourceDir: string,\n workspaceRoot: string,\n): void {\n if (existing.sourceDir !== sourceDir || existing.workspaceRoot !== workspaceRoot) {\n throw new Error(`Legacy office migration inputs changed for ${existing.rawConversationId}`);\n }\n}\n\nfunction assertCanonicalSource(\n sourceDir: string,\n workspaceRoot: string,\n rawConversationId: string,\n): void {\n const expectedSourceDir = resolve(workspaceRoot, rawConversationId);\n if (sourceDir !== expectedSourceDir) {\n throw new Error(`Legacy office source must be ${expectedSourceDir}`);\n }\n assertRegularDirectory(workspaceRoot, \"Workspace root\");\n assertPathIfPresent(sourceDir, \"Legacy office source\");\n}\n\nfunction assertRegularDirectory(path: string, label: string): void {\n let stat;\n try {\n stat = lstatSync(path);\n } catch (error) {\n throw new Error(`${label} does not exist: ${path}`, { cause: error });\n }\n if (stat.isSymbolicLink() || !stat.isDirectory()) {\n throw new Error(`${label} must be a regular directory: ${path}`);\n }\n}\n\nfunction assertRegistryFileSafe(path: string): void {\n try {\n const stat = lstatSync(path);\n if (stat.isSymbolicLink() || !stat.isFile()) {\n throw new Error(`Office registry must be a regular file: ${path}`);\n }\n } catch (error) {\n if (isErrno(error, \"ENOENT\")) return;\n throw error;\n }\n}\n\nfunction assertPathIfPresent(path: string, label: string): void {\n try {\n const stat = lstatSync(path);\n if (stat.isSymbolicLink() || !stat.isDirectory()) {\n throw new Error(`${label} must be a regular directory: ${path}`);\n }\n } catch (error) {\n if (isErrno(error, \"ENOENT\")) return;\n throw error;\n }\n}\n\nfunction assertPathAbsent(path: string, label: string): void {\n try {\n lstatSync(path);\n } catch (error) {\n if (isErrno(error, \"ENOENT\")) return;\n throw error;\n }\n throw new Error(`${label} must be absent: ${path}`);\n}\n\nfunction pathExists(path: string): boolean {\n try {\n lstatSync(path);\n return true;\n } catch (error) {\n if (isErrno(error, \"ENOENT\")) return false;\n throw error;\n }\n}\n\nfunction acquireRegistryLease(lockPath: string, timeoutMs: number): () => void {\n const deadline = Date.now() + timeoutMs;\n const token = `${process.pid}:${randomBytes(8).toString(\"hex\")}`;\n\n for (;;) {\n try {\n mkdirSync(lockPath, { mode: 0o700 });\n try {\n writeFileSync(join(lockPath, \"owner\"), `${token}\\n`, { mode: 0o600 });\n } catch (error) {\n rmSync(lockPath, { recursive: true, force: true });\n throw error;\n }\n return () => releaseRegistryLease(lockPath, token);\n } catch (error) {\n if (!isErrno(error, \"EEXIST\")) throw error;\n if (registryLockIsStale(lockPath)) {\n rmSync(lockPath, { recursive: true, force: true });\n continue;\n }\n if (Date.now() >= deadline) {\n throw new Error(`Timed out acquiring office registry lock: ${lockPath}`, { cause: error });\n }\n sleepSync(REGISTRY_LOCK_RETRY_MS);\n }\n }\n}\n\nfunction releaseRegistryLease(lockPath: string, token: string): void {\n try {\n if (readFileSync(join(lockPath, \"owner\"), \"utf8\").trim() === token) {\n rmSync(lockPath, { recursive: true, force: true });\n }\n } catch (error) {\n if (!isErrno(error, \"ENOENT\")) throw error;\n }\n}\n\nfunction registryLockIsStale(lockPath: string): boolean {\n let ownerKnown = false;\n let ownerAlive = false;\n try {\n const owner = readFileSync(join(lockPath, \"owner\"), \"utf8\").trim();\n const pid = Number(owner.split(\":\", 1)[0]);\n if (Number.isInteger(pid) && pid > 0) {\n ownerKnown = true;\n try {\n process.kill(pid, 0);\n ownerAlive = true;\n } catch (error) {\n if (isErrno(error, \"EPERM\")) ownerAlive = true;\n }\n }\n } catch {\n // The owner file may not have been written before its process died.\n }\n try {\n const oldEnough = Date.now() - statSync(lockPath).mtimeMs >= REGISTRY_LOCK_STALE_MS;\n return ownerKnown ? !ownerAlive : oldEnough;\n } catch {\n return false;\n }\n}\n\nfunction sleepSync(milliseconds: number): void {\n Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds);\n}\n\n// ── raw-id lookups (cold paths: CLI, Admin enumeration) ──────────────────────\n\n/** Current office inventory, read fresh from disk for cross-process freshness. */\nexport function listRegisteredOffices(stateDir: string): readonly OfficeRecord[] {\n return new OfficeRegistry(stateDir).getOffices();\n}\n\n/**\n * Enabled platforms whose id format could have produced this raw\n * conversation id. Auto-claiming uses this as verification, not guessing:\n * every format below is one mikan itself writes (GitHub ids are mikan-derived\n * slugs; Slack/Telegram/Discord ids are the platforms' own grammars), and a\n * directory is only claimed when exactly one enabled platform's format\n * matches. Bare digits stay ambiguous while both Telegram and Discord are\n * enabled (negative ids are Telegram-only); anything matching no enabled\n * format fails closed to needs-owner.\n */\nfunction platformsMatchingConversationIdFormat(\n rawConversationId: string,\n enabledPlatforms: readonly PlatformName[],\n): PlatformName[] {\n return enabledPlatforms.filter((platform) => {\n switch (platform) {\n case \"github\":\n return isGithubConversationId(rawConversationId);\n case \"telegram\":\n return /^-?\\d+$/.test(rawConversationId);\n case \"discord\":\n return /^\\d+$/.test(rawConversationId);\n case \"slack\":\n return /^[A-Z][A-Z0-9]*$/.test(rawConversationId);\n }\n });\n}\n\nfunction isGithubConversationId(rawConversationId: string): boolean {\n try {\n parseGithubConversationId(rawConversationId);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction isErrno(error: unknown, code: string): error is NodeJS.ErrnoException {\n return error instanceof Error && \"code\" in error && error.code === code;\n}\n\n// ── Boot-time legacy migration ────────────────────────────────────────────────\n/**\n * Move every legacy raw-id office directory under the workspace root to the\n * canonical office-key layout, journaling each move through the office\n * registry so an interrupted run resumes instead of losing offices.\n *\n * The engine never guesses: with several enabled platforms an unowned raw\n * directory stays in place and is reported for `mikan office claim`. Callers\n * must treat a non-empty `unowned`/`failed` as fatal for daemon boot — after\n * the layout flip, an unmigrated legacy directory is invisible to the\n * runtime, which would silently present the conversation as empty.\n */\nexport function migrateLegacyOffices(options: {\n workspaceRoot: string;\n stateDir: string;\n enabledPlatforms: readonly PlatformName[];\n}): OfficeMigrationRunSummary {\n const registry = new OfficeRegistry(options.stateDir);\n for (const platform of options.enabledPlatforms) registry.enablePlatform(platform);\n\n const summary: OfficeMigrationRunSummary = {\n migrated: [],\n recovered: [],\n unowned: [],\n failed: [],\n vaultKeysMigrated: [],\n vaultConflicts: [],\n stateDirsMigrated: [],\n stateDirConflicts: [],\n };\n\n recoverInterruptedMoves(registry, summary);\n claimAndMoveLegacyDirs(registry, options.workspaceRoot, summary);\n\n // Credential vaults are keyed by office too; the registry inventory (which\n // the directory moves above just extended) drives the same rename.\n const vaults = migrateConversationVaultKeys({\n stateDir: options.stateDir,\n offices: registry.getOffices(),\n });\n summary.vaultKeysMigrated = vaults.migrated;\n summary.vaultConflicts = vaults.conflicts;\n for (const rawConversationId of vaults.migrated) {\n log.logInfo(`[office] Migrated vault key to office key: ${rawConversationId}`);\n }\n\n migrateConversationStateDirs(registry, options.stateDir, summary);\n\n for (const record of registry.getState().migrations) {\n if (record.status === \"needs-owner\") summary.unowned.push(record.rawConversationId);\n else if (record.status === \"failed\") summary.failed.push(record.rawConversationId);\n }\n return summary;\n}\n\n/** Complete or fail every move the journal says was interrupted mid-rename. */\nfunction recoverInterruptedMoves(\n registry: OfficeRegistry,\n summary: OfficeMigrationRunSummary,\n): void {\n for (const record of registry.getState().migrations) {\n if (record.status !== \"moving\") continue;\n const targetDir = record.targetDir;\n if (!targetDir) {\n registry.markFailed(record.rawConversationId, \"Moving record has no target directory\");\n continue;\n }\n const sourceExists = pathExists(record.sourceDir);\n const targetExists = pathExists(targetDir);\n if (sourceExists && targetExists) {\n registry.markFailed(\n record.rawConversationId,\n \"Both legacy source and office target exist; merge them manually\",\n );\n continue;\n }\n if (!sourceExists && !targetExists) {\n registry.markFailed(\n record.rawConversationId,\n \"Neither legacy source nor office target exists\",\n );\n continue;\n }\n if (sourceExists) renameSync(record.sourceDir, targetDir);\n registry.markCommitted(record.rawConversationId);\n recordMigratedOffice(registry, record);\n summary.recovered.push(record.rawConversationId);\n log.logInfo(`[office] Recovered interrupted migration: ${record.rawConversationId}`);\n }\n}\n\n/** Scan the workspace root and move every claimable legacy office directory. */\nfunction claimAndMoveLegacyDirs(\n registry: OfficeRegistry,\n workspaceRoot: string,\n summary: OfficeMigrationRunSummary,\n): void {\n for (const rawConversationId of listLegacyOfficeDirs(workspaceRoot)) {\n const existing = registry.getMigration(rawConversationId);\n if (existing?.status === \"committed\") {\n // The move already happened; a raw-id dir with this name reappearing\n // afterwards is a different (or resurrected) office the runtime can no\n // longer see. Refusing to boot beats silently ignoring its data.\n throw new Error(\n `Legacy office directory reappeared after migration: ${join(workspaceRoot, rawConversationId)}`,\n );\n }\n if (existing?.status === \"failed\") continue; // reported via summary.failed\n\n const record = registry.prepareLegacyMigration({\n rawConversationId,\n sourceDir: join(workspaceRoot, rawConversationId),\n workspaceRoot,\n });\n if (record.status === \"needs-owner\") continue; // reported via summary.unowned\n\n const moving = registry.markMoving(rawConversationId);\n const targetDir = moving.targetDir;\n if (!targetDir) throw new Error(\"Moving office migration has no target directory\");\n renameSync(moving.sourceDir, targetDir);\n registry.markCommitted(rawConversationId);\n recordMigratedOffice(registry, moving);\n summary.migrated.push(rawConversationId);\n log.logInfo(`[office] Migrated office directory: ${rawConversationId} -> ${targetDir}`);\n }\n}\n\n/**\n * Move each registered office's host state tree from\n * `conversations/<rawId>` to\n * `conversations/<officeKey>` in one rename. Conflicts are reported for\n * manual merge, never clobbered.\n */\nfunction migrateConversationStateDirs(\n registry: OfficeRegistry,\n stateDir: string,\n summary: OfficeMigrationRunSummary,\n): void {\n for (const office of registry.getOffices()) {\n const legacyDir = join(stateDir, \"conversations\", office.conversationId);\n if (!existsSync(legacyDir)) continue;\n const targetDir = officeStateDir(stateDir, office);\n if (existsSync(targetDir)) {\n summary.stateDirConflicts.push(office.conversationId);\n continue;\n }\n renameSync(legacyDir, targetDir);\n summary.stateDirsMigrated.push(office.conversationId);\n log.logInfo(`[office] Migrated host state dir to office key: ${office.conversationId}`);\n }\n}\n\n/** A migrated office is an existing office; keep the directory enumerable. */\nfunction recordMigratedOffice(registry: OfficeRegistry, record: OfficeMigrationRecord): void {\n if (!record.ownerPlatform) return;\n registry.recordOffice({\n platform: record.ownerPlatform,\n conversationId: record.rawConversationId,\n });\n}\n\n/**\n * Legacy office candidates: regular directories that are not reserved\n * infrastructure, not hidden, and not already office-key named. A symlink in\n * office position is refused outright — following it could move data from\n * outside the workspace root.\n *\n * A candidate must also look like a conversation office: every office that\n * ever saw a message has a `log.jsonl`, and every office that ran the agent\n * has `sessions/`. Trusted workspace roots legitimately accumulate other\n * directories — repos the agent cloned, build output — which are not offices\n * and must be neither renamed nor reported as unowned; they stay where they\n * are (an operator can still claim one explicitly via `mikan office claim`).\n */\nfunction listLegacyOfficeDirs(workspaceRoot: string): string[] {\n const candidates: string[] = [];\n for (const entry of readdirSync(workspaceRoot, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\")) continue;\n if (RESERVED_WORKSPACE_NAMES.has(entry.name)) continue;\n if (isOfficeKey(entry.name)) continue;\n if (entry.isSymbolicLink()) {\n throw new Error(`Workspace entry must not be a symlink: ${join(workspaceRoot, entry.name)}`);\n }\n if (!entry.isDirectory()) continue;\n if (!looksLikeConversationOffice(join(workspaceRoot, entry.name))) {\n log.logInfo(\n `[office] Skipping non-office workspace directory (no log.jsonl or sessions/): ${entry.name}`,\n );\n continue;\n }\n candidates.push(entry.name);\n }\n return candidates.toSorted();\n}\n\nfunction looksLikeConversationOffice(dir: string): boolean {\n return existsSync(join(dir, \"log.jsonl\")) || existsSync(join(dir, \"sessions\"));\n}\n\n/** Operator-facing boot failure for offices the engine may not move itself. */\nexport function formatUnmigratedOfficesError(summary: OfficeMigrationRunSummary): string {\n const lines = [\"Conversation office migration cannot complete:\"];\n if (summary.unowned.length > 0) {\n lines.push(\n \"\",\n \"These legacy conversation directories have no owning platform (several\",\n \"platforms are enabled, so ownership cannot be inferred):\",\n ...summary.unowned.map((id) => ` - ${id}`),\n \"\",\n \"Assign each one with:\",\n \" mikan office claim <conversationId> <platform>\",\n );\n }\n if (summary.failed.length > 0) {\n lines.push(\n \"\",\n \"These migrations previously failed and need manual repair (see\",\n \"office-registry.json in the state dir for each error):\",\n ...summary.failed.map((id) => ` - ${id}`),\n );\n }\n if (summary.vaultConflicts.length > 0) {\n lines.push(\n \"\",\n \"These conversations have credentials under both the legacy and the\",\n \"office-key vault directory; merge them manually under <state-dir>/vaults:\",\n ...summary.vaultConflicts.map((id) => ` - ${id}`),\n );\n }\n if (summary.stateDirConflicts.length > 0) {\n lines.push(\n \"\",\n \"These conversations have host state under both the legacy and the\",\n \"office-key directory; merge them manually under <state-dir>/conversations:\",\n ...summary.stateDirConflicts.map((id) => ` - ${id}`),\n );\n }\n return lines.join(\"\\n\");\n}\n\n/**\n * Bind-spec translator for the container layout migration: rewrites every\n * host path the office migration renamed — workspace dirs, per-conversation\n * state trees, conversation vaults — and the guest workspace segment, using\n * the registry's office inventory as the raw-id ↔ office mapping. Specs that\n * reference none of the renamed paths come back unchanged, which is also how\n * an already-migrated container is recognized.\n */\nfunction replacePrefix(path: string, pairs: Array<[string, string]>): string {\n for (const [oldPrefix, newPrefix] of pairs) {\n if (path === oldPrefix) return newPrefix;\n if (path.startsWith(`${oldPrefix}/`)) return newPrefix + path.slice(oldPrefix.length);\n }\n return path;\n}\n\nexport function buildContainerBindTranslator(options: {\n offices: readonly OfficeRecord[];\n workspaceRoot: string;\n stateDir: string;\n}): (bindSpec: string) => string {\n const hostPairs: Array<[string, string]> = [];\n const guestPairs: Array<[string, string]> = [];\n for (const office of options.offices) {\n const key = officeKey(office);\n const rawId = office.conversationId;\n hostPairs.push([join(options.workspaceRoot, rawId), join(options.workspaceRoot, key)]);\n hostPairs.push([\n join(options.stateDir, \"conversations\", rawId),\n officeStateDir(options.stateDir, office),\n ]);\n hostPairs.push([\n join(options.stateDir, \"vaults\", legacyConversationCredentialKey(rawId)),\n join(options.stateDir, \"vaults\", key),\n ]);\n guestPairs.push([`/workspace/${rawId}`, `/workspace/${key}`]);\n }\n\n return (bindSpec: string): string => {\n const readOnly = bindSpec.endsWith(\":ro\");\n const spec = readOnly ? bindSpec.slice(0, -3) : bindSpec;\n const separator = spec.indexOf(\":\");\n if (separator === -1) return bindSpec;\n const source = replacePrefix(spec.slice(0, separator), hostPairs);\n const target = replacePrefix(spec.slice(separator + 1), guestPairs);\n return `${source}:${target}${readOnly ? \":ro\" : \"\"}`;\n };\n}\n"]}
@@ -1,4 +1,22 @@
1
1
  import type { OfficeAddress, OfficeKey } from "../types.js";
2
+ export interface OfficeMigrationRunSummary {
3
+ /** Raw ids whose directories moved to the office-key layout this run. */
4
+ migrated: string[];
5
+ /** Raw ids whose interrupted moves were completed from the journal. */
6
+ recovered: string[];
7
+ /** Raw ids that still need an explicit owner (`mikan office claim`). */
8
+ unowned: string[];
9
+ /** Raw ids whose records are failed and need operator repair. */
10
+ failed: string[];
11
+ /** Raw ids whose conversation vault directories moved to office keys. */
12
+ vaultKeysMigrated: string[];
13
+ /** Raw ids whose legacy and office-key vault dirs both exist (manual merge). */
14
+ vaultConflicts: string[];
15
+ /** Raw ids whose host state directories moved. */
16
+ stateDirsMigrated: string[];
17
+ /** Raw ids whose legacy and office-key state dirs both exist (manual merge). */
18
+ stateDirConflicts: string[];
19
+ }
2
20
  /**
3
21
  * One mikan deployment's agent world on the host: the workspace root, the
4
22
  * workspace-global surfaces, and the factory for per-conversation offices.
@@ -9,7 +27,7 @@ export interface Workspace {
9
27
  /** Host workspace root directory. */
10
28
  readonly root: string;
11
29
  /**
12
- * Host-only state root (settings, credentials, extension code/data).
30
+ * Host-only state root (settings, credentials, package checkouts).
13
31
  * Not part of the Workspace projection; carried here so offices can
14
32
  * derive their state dirs and the registry knows where its journal lives.
15
33
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/office/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,qCAAqC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,iDAAiD;IACjD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,gFAAgF;IAChF,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5C;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAAC;CACxC;AAED;;;;;GAKG;AACH,MAAM,WAAW,MAAM;IACrB,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,8DAA8D;IAC9D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,WAAW,E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B,iDAAiD;IACjD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,gFAAgF;IAChF,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5C;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAAC;CACxC;AAED;;;;;GAKG;AACH,MAAM,WAAW,MAAM;IACrB,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,8DAA8D;IAC9D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2DAA2D;IAC3D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,4CAA4C;IAC5C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B;;;;;OAKG;IACH,MAAM,IAAI,MAAM,CAAC;CAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/office/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { OfficeAddress, OfficeKey } from \"../types.js\";\n\n/**\n * One mikan deployment's agent world on the host: the workspace root, the\n * workspace-global surfaces, and the factory for per-conversation offices.\n * Constructed once per process (`createWorkspace`); everything downstream\n * receives the value instead of re-deriving paths from root strings.\n */\nexport interface Workspace {\n /** Host workspace root directory. */\n readonly root: string;\n /**\n * Host-only state root (settings, credentials, extension code/data).\n * Not part of the Workspace projection; carried here so offices can\n * derive their state dirs and the registry knows where its journal lives.\n */\n readonly stateDir: string;\n /** Workspace-global memory file: `<root>/MEMORY.md`. */\n readonly memoryPath: string;\n /** Workspace-global skills directory: `<root>/skills`. */\n readonly skillsDir: string;\n /** The workspace scheduling bus: `<root>/events` (global by design). */\n readonly eventsDir: string;\n /** Subagent profile patches: `<root>/agents`. */\n readonly agentsDir: string;\n /** Workspace-root entries that are shared infrastructure, never office dirs. */\n readonly reservedNames: ReadonlySet<string>;\n /**\n * The Conversation office for an address. Values are memoized per address,\n * so repeated calls on hot paths cost one map lookup, not a hash.\n */\n office(address: OfficeAddress): Office;\n}\n\n/**\n * One Conversation office: canonical identity plus the office's host-side\n * directory layout. A frozen value — every field is precomputed at\n * construction. Fields exist only for paths that more than one module needs;\n * single-consumer subpaths stay `join(office.dir, …)` at their call site.\n */\nexport interface Office {\n /** Canonical identity: platform plus raw platform conversation id. */\n readonly address: OfficeAddress;\n /**\n * The office key — the collision-resistant directory segment, identical on\n * the host and inside sandbox runtimes, and the conversation vault key.\n */\n readonly key: OfficeKey;\n /** The office working directory: `<workspace root>/<key>`. */\n readonly dir: string;\n /** Conversation memory file: `<dir>/MEMORY.md`. */\n readonly memoryPath: string;\n /** Conversation skills directory: `<dir>/skills`. */\n readonly skillsDir: string;\n /** Persisted chat-session files: `<dir>/sessions`. */\n readonly sessionsDir: string;\n /** Downloaded message attachments: `<dir>/attachments`. */\n readonly attachmentsDir: string;\n /** Human-readable message history: `<dir>/log.jsonl`. */\n readonly logPath: string;\n /** Host-only per-office state: `<state dir>/conversations/<key>`. */\n readonly stateDir: string;\n /** The workspace this office belongs to. */\n readonly workspace: Workspace;\n /**\n * Materialize the office working directory: record the office in the\n * registry, then create the directory. Idempotent and safe on hot\n * per-message paths — recording is cached, the mkdir is a guarded check.\n * Returns `dir`.\n */\n ensure(): string;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/office/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { OfficeAddress, OfficeKey } from \"../types.js\";\n\nexport interface OfficeMigrationRunSummary {\n /** Raw ids whose directories moved to the office-key layout this run. */\n migrated: string[];\n /** Raw ids whose interrupted moves were completed from the journal. */\n recovered: string[];\n /** Raw ids that still need an explicit owner (`mikan office claim`). */\n unowned: string[];\n /** Raw ids whose records are failed and need operator repair. */\n failed: string[];\n /** Raw ids whose conversation vault directories moved to office keys. */\n vaultKeysMigrated: string[];\n /** Raw ids whose legacy and office-key vault dirs both exist (manual merge). */\n vaultConflicts: string[];\n /** Raw ids whose host state directories moved. */\n stateDirsMigrated: string[];\n /** Raw ids whose legacy and office-key state dirs both exist (manual merge). */\n stateDirConflicts: string[];\n}\n\n/**\n * One mikan deployment's agent world on the host: the workspace root, the\n * workspace-global surfaces, and the factory for per-conversation offices.\n * Constructed once per process (`createWorkspace`); everything downstream\n * receives the value instead of re-deriving paths from root strings.\n */\nexport interface Workspace {\n /** Host workspace root directory. */\n readonly root: string;\n /**\n * Host-only state root (settings, credentials, package checkouts).\n * Not part of the Workspace projection; carried here so offices can\n * derive their state dirs and the registry knows where its journal lives.\n */\n readonly stateDir: string;\n /** Workspace-global memory file: `<root>/MEMORY.md`. */\n readonly memoryPath: string;\n /** Workspace-global skills directory: `<root>/skills`. */\n readonly skillsDir: string;\n /** The workspace scheduling bus: `<root>/events` (global by design). */\n readonly eventsDir: string;\n /** Subagent profile patches: `<root>/agents`. */\n readonly agentsDir: string;\n /** Workspace-root entries that are shared infrastructure, never office dirs. */\n readonly reservedNames: ReadonlySet<string>;\n /**\n * The Conversation office for an address. Values are memoized per address,\n * so repeated calls on hot paths cost one map lookup, not a hash.\n */\n office(address: OfficeAddress): Office;\n}\n\n/**\n * One Conversation office: canonical identity plus the office's host-side\n * directory layout. A frozen value — every field is precomputed at\n * construction. Fields exist only for paths that more than one module needs;\n * single-consumer subpaths stay `join(office.dir, …)` at their call site.\n */\nexport interface Office {\n /** Canonical identity: platform plus raw platform conversation id. */\n readonly address: OfficeAddress;\n /**\n * The office key — the collision-resistant directory segment, identical on\n * the host and inside sandbox runtimes, and the conversation vault key.\n */\n readonly key: OfficeKey;\n /** The office working directory: `<workspace root>/<key>`. */\n readonly dir: string;\n /** Conversation memory file: `<dir>/MEMORY.md`. */\n readonly memoryPath: string;\n /** Conversation skills directory: `<dir>/skills`. */\n readonly skillsDir: string;\n /** Persisted chat-session files: `<dir>/sessions`. */\n readonly sessionsDir: string;\n /** Downloaded message attachments: `<dir>/attachments`. */\n readonly attachmentsDir: string;\n /** Human-readable message history: `<dir>/log.jsonl`. */\n readonly logPath: string;\n /** Host-only per-office state: `<state dir>/conversations/<key>`. */\n readonly stateDir: string;\n /** The workspace this office belongs to. */\n readonly workspace: Workspace;\n /**\n * Materialize the office working directory: record the office in the\n * registry, then create the directory. Idempotent and safe on hot\n * per-message paths — recording is cached, the mkdir is a guarded check.\n * Returns `dir`.\n */\n ensure(): string;\n}\n"]}
@@ -1,6 +1,169 @@
1
- export { formatSource, gitRepoPath, parseSource, sourceIdentity } from "./source.js";
2
- export { gitCloneDir, materializeSource, packageScopeDir } from "./materialize.js";
3
- export { conversationPackageSkillMounts, packageSkillRuntimeDir, resolveConversationPackages, } from "./resolve.js";
4
- export { inspectConversationPackages } from "./inspect.js";
5
- export { addPackage, refreshPackage, removePackage } from "./admin.js";
1
+ import type { MaterializeOptions, MaterializedPackage, PackageAdminContext, PackageIdentity, PackageInventory, PackageScope, PackageSourceString, PackageWriteResult, ParsedSource, ResolvePackagesOptions, ResolvedPackages } from "./types.js";
2
+ import type { OfficeAddress } from "../types.js";
3
+ /**
4
+ * Parse a source string. Throws with a user-facing message rather than
5
+ * returning undefined: every caller (portal, settings load, CLI) needs to tell
6
+ * the human what was wrong with what they typed.
7
+ */
8
+ export declare function parseSource(source: string): ParsedSource;
9
+ /**
10
+ * Identity of the package a source refers to — the key for deduplication and
11
+ * for letting a conversation's copy shadow the global one.
12
+ *
13
+ * Deliberate choices:
14
+ * - The ref is excluded: the same repo pinned to two refs in two scopes is one
15
+ * package installed twice, and the narrower scope wins.
16
+ * - The subpath is included: two skill packages living at different paths in one
17
+ * monorepo are two packages.
18
+ * - Transport is excluded: `git@github.com:o/r`, `https://github.com/o/r.git`
19
+ * and `ssh://git@github.com/o/r` all identify the same package, so mixing
20
+ * SSH and HTTPS spellings across scopes still dedups.
21
+ */
22
+ export declare function sourceIdentity(parsed: ParsedSource): PackageIdentity;
23
+ /**
24
+ * Transport-independent `<host>/<path>` of a git URL, lowercased host, no
25
+ * `.git` suffix, no credentials. It is the base of the on-disk clone layout,
26
+ * so it must stay free of anything that is not a safe path segment.
27
+ */
28
+ export declare function gitRepoPath(url: string): string;
29
+ /**
30
+ * Canonical string form, used when writing settings so the stored value is
31
+ * stable regardless of how the human spelled it.
32
+ */
33
+ export declare function formatSource(parsed: ParsedSource): string;
34
+ /**
35
+ * Turning a parsed source into a directory on the host.
36
+ *
37
+ * Materialization is an explicit, reported step — it happens when a human adds
38
+ * or updates a package, not lazily while a conversation is waiting for a
39
+ * reply. Failures (bad URL, missing ref, no such subpath) therefore surface in
40
+ * front of the person who typed the source instead of as a silently absent
41
+ * feature in a chat.
42
+ *
43
+ * Everything lands under the host-only state dir, never the workspace: this
44
+ * code is imported into the mikan process, so a mounted location would let
45
+ * sandboxed code write what the host executes.
46
+ */
47
+ export type { MaterializeOptions } from "./types.js";
48
+ /**
49
+ * How far materialization may go to produce the package's files.
50
+ *
51
+ * - `offline`: use what is already on disk; never touch the network. This is
52
+ * what a conversation load uses, so no chat reply can ever wait on a remote.
53
+ * - `fetch`: clone a package that is not on disk yet, reuse an existing clone
54
+ * when it already has the requested ref, or switch it to a new ref. What the
55
+ * portal uses when a source is added.
56
+ * - `refresh`: additionally re-fetch an existing clone, resetting and cleaning
57
+ * it first. What the portal's Update action uses.
58
+ *
59
+ * One mode rather than two booleans: "re-fetch an existing clone but refuse to
60
+ * create a missing one" is not a state any caller wants, and expressing it
61
+ * should not be possible.
62
+ */
63
+ /**
64
+ * Root of a scope's host-only assets: `<stateDir>/global` or
65
+ * `<stateDir>/conversations/<id>`. The two are isomorphic by design — both
66
+ * hold conversation-scoped settings and package checkouts.
67
+ */
68
+ export declare function packageScopeDir(scope: PackageScope, address: OfficeAddress | undefined, stateDir: string): string;
69
+ /**
70
+ * Where a git checkout lives.
71
+ *
72
+ * The unpinned checkout keeps the original path for compatibility. Explicit
73
+ * refs get a sibling keyed by the ref, so two refs can never reset each
74
+ * other's working tree; subpaths of one ref therefore still share a checkout.
75
+ */
76
+ export declare function gitCloneDir(url: string, scopeDir: string, ref?: string): string;
77
+ /**
78
+ * Materialize one source and return where its files ended up. Throws with a
79
+ * message meant to be shown to a human — callers render it next to the input
80
+ * that produced it.
81
+ */
82
+ export declare function materializeSource(source: PackageSourceString, options: MaterializeOptions): MaterializedPackage;
83
+ /**
84
+ * The administrator's view of a conversation's packages: what each scope
85
+ * declares, whether it is actually on disk, and what it contributes.
86
+ *
87
+ * Resolution answers "what loads"; inspection answers "why is this not
88
+ * loading", which is the question someone staring at the portal has. A source
89
+ * that failed to fetch, or one shadowed by the conversation's own copy, is
90
+ * absent from the resolved set — reporting only the survivors would leave the
91
+ * admin with a silently short list and nothing to act on.
92
+ */
93
+ export type { PackageInventory } from "./types.js";
94
+ /**
95
+ * Inventory both scopes for one conversation. Never throws and never fetches:
96
+ * the portal renders this on page load, so it reports the current on-disk
97
+ * truth rather than going to the network behind the admin's back.
98
+ */
99
+ export declare function inspectConversationPackages(options: ResolvePackagesOptions): Promise<PackageInventory>;
100
+ /**
101
+ * What a conversation actually loads: the two scopes' declared packages
102
+ * combined, collisions resolved, and each surviving package turned into the
103
+ * skill directories the runner consumes.
104
+ *
105
+ * Two rules do all the work here:
106
+ *
107
+ * - **Additive scopes.** `global` packages load for every conversation; a
108
+ * conversation's packages load on top. Neither list replaces the other.
109
+ * - **Narrower scope wins.** When both scopes declare the same package
110
+ * ({@link sourceIdentity}, which ignores the ref), only the conversation's
111
+ * copy loads. That is what makes "pin this one channel to v2 while everyone
112
+ * else stays on v1" work, and it is why the same package installed twice
113
+ * cannot activate twice.
114
+ *
115
+ * Resolution never throws. A conversation with one malformed or unfetchable
116
+ * source still loads every other package, and the failure is reported through
117
+ * {@link ResolvedPackages.errors} for the portal and the logs. The alternative
118
+ * — one bad string in settings taking a conversation offline — is a far worse
119
+ * failure mode than a missing feature.
120
+ */
121
+ export type { ResolvePackagesOptions, ResolvedPackages } from "./types.js";
122
+ /** Runtime path a package's skills directory is mounted at. */
123
+ export declare function packageSkillRuntimeDir(slug: string): string;
124
+ /**
125
+ * Read-only mounts exposing every resolved package's skills to the sandbox.
126
+ *
127
+ * Read-only rather than read-write because the host owns these files: the
128
+ * directory is a git checkout that an update replaces wholesale, so an agent
129
+ * edit would be silently discarded on the next refresh. Making the filesystem
130
+ * refuse the write turns a confusing data-loss bug into an obvious error.
131
+ *
132
+ * This pure step consumes an already resolved package set and never reaches the network.
133
+ */
134
+ export declare function conversationPackageSkillMounts(packages: ResolvedPackages): Array<{
135
+ source: string;
136
+ target: string;
137
+ readOnly: true;
138
+ }>;
139
+ /**
140
+ * Resolve the package set for one conversation. Reads both scopes' settings,
141
+ * dedups, and reports the directories to load from.
142
+ */
143
+ export declare function resolveConversationPackages(options: ResolvePackagesOptions): ResolvedPackages;
144
+ /**
145
+ * The write operations behind the admin portal's package panels.
146
+ *
147
+ * The ordering here is the whole point: **materialize first, persist second.**
148
+ * A source is fetched and validated while the person who typed it is still
149
+ * looking at the form, so a typo, a private repo, a bad `#subpath`, or a repo
150
+ * with no skills in it fails in front of them. Persisting first and
151
+ * fetching at load time would turn every one of those into "the bot just
152
+ * doesn't have the skill", discovered later and usually by someone else.
153
+ */
154
+ export type { PackageAdminContext, PackageWriteResult } from "./types.js";
155
+ /**
156
+ * Add a source to a scope, or move an existing one to a new ref. Fetches and
157
+ * validates before writing, and is idempotent: adding a source already present
158
+ * re-materializes it and leaves the list unchanged.
159
+ */
160
+ export declare function addPackage(scope: PackageScope, rawSource: string, context: PackageAdminContext): PackageWriteResult;
161
+ /**
162
+ * Drop a source from a scope's list. The materialized clone is left on disk —
163
+ * removal is a declaration change, and keeping the checkout makes re-adding
164
+ * instant and lets an admin undo a mistake without a network round trip.
165
+ */
166
+ export declare function removePackage(scope: PackageScope, rawSource: string, context: PackageAdminContext): boolean;
167
+ /** Re-fetch a package that is already declared, moving it to its ref's current tip. */
168
+ export declare function refreshPackage(scope: PackageScope, rawSource: string, context: PackageAdminContext): PackageWriteResult;
6
169
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/packages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EACL,8BAA8B,EAC9B,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/packages/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAEV,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EAEnB,eAAe,EACf,gBAAgB,EAChB,YAAY,EAEZ,mBAAmB,EAEnB,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAOpB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAuCjD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAsCxD;AA+CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,MAAM,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