@geminixiang/mikan 1.0.0-beta.7 → 1.0.0-beta.71

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 (856) hide show
  1. package/CHANGELOG.md +1052 -0
  2. package/README.md +98 -38
  3. package/dist/adapters/commands/admin.d.ts.map +1 -0
  4. package/dist/{commands → adapters/commands}/admin.js +11 -8
  5. package/dist/adapters/commands/admin.js.map +1 -0
  6. package/dist/{commands → adapters/commands}/auto-reply.d.ts +0 -3
  7. package/dist/adapters/commands/auto-reply.d.ts.map +1 -0
  8. package/dist/adapters/commands/auto-reply.js +47 -0
  9. package/dist/adapters/commands/auto-reply.js.map +1 -0
  10. package/dist/adapters/commands/login.d.ts +6 -0
  11. package/dist/adapters/commands/login.d.ts.map +1 -0
  12. package/dist/adapters/commands/login.js +166 -0
  13. package/dist/adapters/commands/login.js.map +1 -0
  14. package/dist/adapters/commands/manifest.d.ts +37 -0
  15. package/dist/adapters/commands/manifest.d.ts.map +1 -0
  16. package/dist/adapters/commands/manifest.js +155 -0
  17. package/dist/adapters/commands/manifest.js.map +1 -0
  18. package/dist/adapters/commands/model.d.ts +15 -0
  19. package/dist/adapters/commands/model.d.ts.map +1 -0
  20. package/dist/adapters/commands/model.js +153 -0
  21. package/dist/adapters/commands/model.js.map +1 -0
  22. package/dist/adapters/commands/new.d.ts.map +1 -0
  23. package/dist/adapters/commands/new.js +41 -0
  24. package/dist/adapters/commands/new.js.map +1 -0
  25. package/dist/adapters/commands/registry.d.ts +5 -0
  26. package/dist/adapters/commands/registry.d.ts.map +1 -0
  27. package/dist/adapters/commands/registry.js +43 -0
  28. package/dist/adapters/commands/registry.js.map +1 -0
  29. package/dist/adapters/commands/sandbox.d.ts.map +1 -0
  30. package/dist/adapters/commands/sandbox.js +125 -0
  31. package/dist/adapters/commands/sandbox.js.map +1 -0
  32. package/dist/adapters/commands/session-view.d.ts.map +1 -0
  33. package/dist/{commands → adapters/commands}/session-view.js +23 -16
  34. package/dist/adapters/commands/session-view.js.map +1 -0
  35. package/dist/adapters/commands/types.d.ts +145 -0
  36. package/dist/adapters/commands/types.d.ts.map +1 -0
  37. package/dist/adapters/commands/types.js.map +1 -0
  38. package/dist/adapters/commands/utils.d.ts +14 -0
  39. package/dist/adapters/commands/utils.d.ts.map +1 -0
  40. package/dist/{commands → adapters/commands}/utils.js +18 -1
  41. package/dist/adapters/commands/utils.js.map +1 -0
  42. package/dist/adapters/discord/bot.d.ts +11 -8
  43. package/dist/adapters/discord/bot.d.ts.map +1 -1
  44. package/dist/adapters/discord/bot.js +223 -256
  45. package/dist/adapters/discord/bot.js.map +1 -1
  46. package/dist/adapters/discord/components.d.ts +28 -0
  47. package/dist/adapters/discord/components.d.ts.map +1 -0
  48. package/dist/adapters/discord/components.js +32 -0
  49. package/dist/adapters/discord/components.js.map +1 -0
  50. package/dist/adapters/discord/context.d.ts +2 -6
  51. package/dist/adapters/discord/context.d.ts.map +1 -1
  52. package/dist/adapters/discord/context.js +64 -218
  53. package/dist/adapters/discord/context.js.map +1 -1
  54. package/dist/adapters/discord/format.d.ts +3 -0
  55. package/dist/adapters/discord/format.d.ts.map +1 -0
  56. package/dist/adapters/discord/format.js +84 -0
  57. package/dist/adapters/discord/format.js.map +1 -0
  58. package/dist/adapters/discord/types.d.ts +8 -1
  59. package/dist/adapters/discord/types.d.ts.map +1 -1
  60. package/dist/adapters/discord/types.js.map +1 -1
  61. package/dist/adapters/github/bot.d.ts +102 -0
  62. package/dist/adapters/github/bot.d.ts.map +1 -0
  63. package/dist/adapters/github/bot.js +720 -0
  64. package/dist/adapters/github/bot.js.map +1 -0
  65. package/dist/adapters/github/client.d.ts +122 -0
  66. package/dist/adapters/github/client.d.ts.map +1 -0
  67. package/dist/adapters/github/client.js +301 -0
  68. package/dist/adapters/github/client.js.map +1 -0
  69. package/dist/adapters/github/context.d.ts +5 -0
  70. package/dist/adapters/github/context.d.ts.map +1 -0
  71. package/dist/adapters/github/context.js +101 -0
  72. package/dist/adapters/github/context.js.map +1 -0
  73. package/dist/adapters/github/github-ops.d.ts +78 -0
  74. package/dist/adapters/github/github-ops.d.ts.map +1 -0
  75. package/dist/adapters/github/github-ops.js +337 -0
  76. package/dist/adapters/github/github-ops.js.map +1 -0
  77. package/dist/adapters/github/ids.d.ts +34 -0
  78. package/dist/adapters/github/ids.d.ts.map +1 -0
  79. package/dist/adapters/github/ids.js +57 -0
  80. package/dist/adapters/github/ids.js.map +1 -0
  81. package/dist/adapters/github/repo.d.ts +33 -0
  82. package/dist/adapters/github/repo.d.ts.map +1 -0
  83. package/dist/adapters/github/repo.js +141 -0
  84. package/dist/adapters/github/repo.js.map +1 -0
  85. package/dist/adapters/github/tool-pack.d.ts +14 -0
  86. package/dist/adapters/github/tool-pack.d.ts.map +1 -0
  87. package/dist/adapters/github/tool-pack.js +55 -0
  88. package/dist/adapters/github/tool-pack.js.map +1 -0
  89. package/dist/adapters/github/tools/checks.d.ts +18 -0
  90. package/dist/adapters/github/tools/checks.d.ts.map +1 -0
  91. package/dist/adapters/github/tools/checks.js +86 -0
  92. package/dist/adapters/github/tools/checks.js.map +1 -0
  93. package/dist/adapters/github/tools/issue.d.ts +21 -0
  94. package/dist/adapters/github/tools/issue.d.ts.map +1 -0
  95. package/dist/adapters/github/tools/issue.js +48 -0
  96. package/dist/adapters/github/tools/issue.js.map +1 -0
  97. package/dist/adapters/github/tools/pr.d.ts +22 -0
  98. package/dist/adapters/github/tools/pr.d.ts.map +1 -0
  99. package/dist/adapters/github/tools/pr.js +48 -0
  100. package/dist/adapters/github/tools/pr.js.map +1 -0
  101. package/dist/adapters/github/tools/read.d.ts +21 -0
  102. package/dist/adapters/github/tools/read.d.ts.map +1 -0
  103. package/dist/adapters/github/tools/read.js +141 -0
  104. package/dist/adapters/github/tools/read.js.map +1 -0
  105. package/dist/adapters/github/tools/review-reply.d.ts +17 -0
  106. package/dist/adapters/github/tools/review-reply.d.ts.map +1 -0
  107. package/dist/adapters/github/tools/review-reply.js +38 -0
  108. package/dist/adapters/github/tools/review-reply.js.map +1 -0
  109. package/dist/adapters/github/tools/sync.d.ts +17 -0
  110. package/dist/adapters/github/tools/sync.d.ts.map +1 -0
  111. package/dist/adapters/github/tools/sync.js +34 -0
  112. package/dist/adapters/github/tools/sync.js.map +1 -0
  113. package/dist/adapters/github/types.d.ts +345 -0
  114. package/dist/adapters/github/types.d.ts.map +1 -0
  115. package/dist/adapters/github/types.js.map +1 -0
  116. package/dist/adapters/github/webhook.d.ts +20 -0
  117. package/dist/adapters/github/webhook.d.ts.map +1 -0
  118. package/dist/adapters/github/webhook.js +78 -0
  119. package/dist/adapters/github/webhook.js.map +1 -0
  120. package/dist/adapters/index.d.ts +12 -0
  121. package/dist/adapters/index.d.ts.map +1 -0
  122. package/dist/adapters/index.js +19 -0
  123. package/dist/adapters/index.js.map +1 -0
  124. package/dist/adapters/intake.d.ts +17 -6
  125. package/dist/adapters/intake.d.ts.map +1 -1
  126. package/dist/adapters/intake.js +96 -27
  127. package/dist/adapters/intake.js.map +1 -1
  128. package/dist/adapters/markdown-tables.d.ts +19 -0
  129. package/dist/adapters/markdown-tables.d.ts.map +1 -0
  130. package/dist/adapters/markdown-tables.js +152 -0
  131. package/dist/adapters/markdown-tables.js.map +1 -0
  132. package/dist/{platform-messages.d.ts → adapters/messages.d.ts} +3 -2
  133. package/dist/adapters/messages.d.ts.map +1 -0
  134. package/dist/{platform-messages.js → adapters/messages.js} +4 -1
  135. package/dist/adapters/messages.js.map +1 -0
  136. package/dist/adapters/progressive-renderer.d.ts +7 -0
  137. package/dist/adapters/progressive-renderer.d.ts.map +1 -0
  138. package/dist/adapters/progressive-renderer.js +443 -0
  139. package/dist/adapters/progressive-renderer.js.map +1 -0
  140. package/dist/adapters/shared.d.ts +37 -11
  141. package/dist/adapters/shared.d.ts.map +1 -1
  142. package/dist/adapters/shared.js +130 -24
  143. package/dist/adapters/shared.js.map +1 -1
  144. package/dist/adapters/slack/assistant.d.ts +73 -0
  145. package/dist/adapters/slack/assistant.d.ts.map +1 -0
  146. package/dist/adapters/slack/assistant.js +205 -0
  147. package/dist/adapters/slack/assistant.js.map +1 -0
  148. package/dist/adapters/slack/auto-reply-context.d.ts +21 -0
  149. package/dist/adapters/slack/auto-reply-context.d.ts.map +1 -0
  150. package/dist/adapters/slack/auto-reply-context.js +28 -0
  151. package/dist/adapters/slack/auto-reply-context.js.map +1 -0
  152. package/dist/adapters/slack/blocks.d.ts +14 -0
  153. package/dist/adapters/slack/blocks.d.ts.map +1 -1
  154. package/dist/adapters/slack/blocks.js +104 -148
  155. package/dist/adapters/slack/blocks.js.map +1 -1
  156. package/dist/adapters/slack/bot.d.ts +154 -21
  157. package/dist/adapters/slack/bot.d.ts.map +1 -1
  158. package/dist/adapters/slack/bot.js +1037 -484
  159. package/dist/adapters/slack/bot.js.map +1 -1
  160. package/dist/adapters/slack/context.d.ts +2 -6
  161. package/dist/adapters/slack/context.d.ts.map +1 -1
  162. package/dist/adapters/slack/context.js +11 -17
  163. package/dist/adapters/slack/context.js.map +1 -1
  164. package/dist/adapters/slack/jev-context.d.ts +30 -0
  165. package/dist/adapters/slack/jev-context.d.ts.map +1 -0
  166. package/dist/adapters/slack/jev-context.js +67 -0
  167. package/dist/adapters/slack/jev-context.js.map +1 -0
  168. package/dist/adapters/slack/markdown.d.ts +3 -0
  169. package/dist/adapters/slack/markdown.d.ts.map +1 -0
  170. package/dist/adapters/slack/markdown.js +48 -0
  171. package/dist/adapters/slack/markdown.js.map +1 -0
  172. package/dist/adapters/slack/persona.d.ts +15 -0
  173. package/dist/adapters/slack/persona.d.ts.map +1 -0
  174. package/dist/adapters/slack/persona.js +22 -0
  175. package/dist/adapters/slack/persona.js.map +1 -0
  176. package/dist/adapters/slack/response-lifecycle.d.ts +1 -1
  177. package/dist/adapters/slack/response-lifecycle.d.ts.map +1 -1
  178. package/dist/adapters/slack/response-lifecycle.js +261 -345
  179. package/dist/adapters/slack/response-lifecycle.js.map +1 -1
  180. package/dist/adapters/slack/session.d.ts.map +1 -1
  181. package/dist/adapters/slack/session.js +7 -11
  182. package/dist/adapters/slack/session.js.map +1 -1
  183. package/dist/adapters/slack/stream-limits.d.ts +35 -0
  184. package/dist/adapters/slack/stream-limits.d.ts.map +1 -0
  185. package/dist/adapters/slack/stream-limits.js +56 -0
  186. package/dist/adapters/slack/stream-limits.js.map +1 -0
  187. package/dist/adapters/slack/task-intent.d.ts +32 -0
  188. package/dist/adapters/slack/task-intent.d.ts.map +1 -0
  189. package/dist/adapters/slack/task-intent.js +72 -0
  190. package/dist/adapters/slack/task-intent.js.map +1 -0
  191. package/dist/adapters/slack/task-status.d.ts +7 -0
  192. package/dist/adapters/slack/task-status.d.ts.map +1 -0
  193. package/dist/adapters/slack/task-status.js +107 -0
  194. package/dist/adapters/slack/task-status.js.map +1 -0
  195. package/dist/adapters/slack/tool-pack.d.ts +11 -0
  196. package/dist/adapters/slack/tool-pack.d.ts.map +1 -0
  197. package/dist/adapters/slack/tool-pack.js +45 -0
  198. package/dist/adapters/slack/tool-pack.js.map +1 -0
  199. package/dist/adapters/slack/tools/blockkit.d.ts +14 -0
  200. package/dist/adapters/slack/tools/blockkit.d.ts.map +1 -0
  201. package/dist/adapters/slack/tools/blockkit.js +106 -0
  202. package/dist/adapters/slack/tools/blockkit.js.map +1 -0
  203. package/dist/adapters/slack/types.d.ts +73 -2
  204. package/dist/adapters/slack/types.d.ts.map +1 -1
  205. package/dist/adapters/slack/types.js.map +1 -1
  206. package/dist/adapters/slack/update-diagnostics.d.ts +14 -0
  207. package/dist/adapters/slack/update-diagnostics.d.ts.map +1 -0
  208. package/dist/adapters/slack/update-diagnostics.js +134 -0
  209. package/dist/adapters/slack/update-diagnostics.js.map +1 -0
  210. package/dist/adapters/telegram/bot.d.ts +10 -9
  211. package/dist/adapters/telegram/bot.d.ts.map +1 -1
  212. package/dist/adapters/telegram/bot.js +133 -202
  213. package/dist/adapters/telegram/bot.js.map +1 -1
  214. package/dist/adapters/telegram/context.d.ts +2 -6
  215. package/dist/adapters/telegram/context.d.ts.map +1 -1
  216. package/dist/adapters/telegram/context.js +53 -190
  217. package/dist/adapters/telegram/context.js.map +1 -1
  218. package/dist/adapters/telegram/types.d.ts +1 -1
  219. package/dist/adapters/telegram/types.d.ts.map +1 -1
  220. package/dist/adapters/telegram/types.js.map +1 -1
  221. package/dist/adapters/types.d.ts +144 -13
  222. package/dist/adapters/types.d.ts.map +1 -1
  223. package/dist/adapters/types.js.map +1 -1
  224. package/dist/adapters/web/admin/portal.d.ts +44 -0
  225. package/dist/adapters/web/admin/portal.d.ts.map +1 -0
  226. package/dist/adapters/web/admin/portal.js +3207 -0
  227. package/dist/adapters/web/admin/portal.js.map +1 -0
  228. package/dist/{web → adapters/web}/admin/provider-models.d.ts +1 -1
  229. package/dist/adapters/web/admin/provider-models.d.ts.map +1 -0
  230. package/dist/{web → adapters/web}/admin/provider-models.js +1 -1
  231. package/dist/adapters/web/admin/provider-models.js.map +1 -0
  232. package/dist/adapters/web/admin/types.d.ts +53 -0
  233. package/dist/adapters/web/admin/types.d.ts.map +1 -0
  234. package/dist/adapters/web/admin/types.js.map +1 -0
  235. package/dist/adapters/web/login/oauth.d.ts +5 -0
  236. package/dist/adapters/web/login/oauth.d.ts.map +1 -0
  237. package/dist/{web → adapters/web}/login/oauth.js +50 -85
  238. package/dist/adapters/web/login/oauth.js.map +1 -0
  239. package/dist/{web → adapters/web}/login/portal.d.ts +9 -3
  240. package/dist/adapters/web/login/portal.d.ts.map +1 -0
  241. package/dist/{web → adapters/web}/login/portal.js +161 -119
  242. package/dist/adapters/web/login/portal.js.map +1 -0
  243. package/dist/{web → adapters/web}/login/types.d.ts +1 -12
  244. package/dist/adapters/web/login/types.d.ts.map +1 -0
  245. package/dist/adapters/web/login/types.js.map +1 -0
  246. package/dist/adapters/web/portal-shell.d.ts +22 -0
  247. package/dist/adapters/web/portal-shell.d.ts.map +1 -0
  248. package/dist/{portal-shell.js → adapters/web/portal-shell.js} +78 -2
  249. package/dist/adapters/web/portal-shell.js.map +1 -0
  250. package/dist/{web → adapters/web}/server.d.ts +14 -8
  251. package/dist/adapters/web/server.d.ts.map +1 -0
  252. package/dist/{web → adapters/web}/server.js +14 -7
  253. package/dist/adapters/web/server.js.map +1 -0
  254. package/dist/adapters/web/session-view/portal.d.ts +20 -0
  255. package/dist/adapters/web/session-view/portal.d.ts.map +1 -0
  256. package/dist/{web → adapters/web}/session-view/portal.js +633 -162
  257. package/dist/adapters/web/session-view/portal.js.map +1 -0
  258. package/dist/{web → adapters/web}/session-view/types.d.ts +11 -6
  259. package/dist/adapters/web/session-view/types.d.ts.map +1 -0
  260. package/dist/adapters/web/session-view/types.js.map +1 -0
  261. package/dist/adapters/web/token-store.d.ts.map +1 -0
  262. package/dist/{web → adapters/web}/token-store.js +1 -1
  263. package/dist/adapters/web/token-store.js.map +1 -0
  264. package/dist/adapters/web/types.d.ts.map +1 -0
  265. package/dist/adapters/web/types.js.map +1 -0
  266. package/dist/cli/arg-grammar.d.ts +11 -0
  267. package/dist/cli/arg-grammar.d.ts.map +1 -0
  268. package/dist/cli/arg-grammar.js +50 -0
  269. package/dist/cli/arg-grammar.js.map +1 -0
  270. package/dist/cli/boot.d.ts +5 -0
  271. package/dist/cli/boot.d.ts.map +1 -0
  272. package/dist/cli/boot.js +90 -0
  273. package/dist/cli/boot.js.map +1 -0
  274. package/dist/cli/download.d.ts.map +1 -0
  275. package/dist/cli/download.js +88 -0
  276. package/dist/cli/download.js.map +1 -0
  277. package/dist/cli/office.d.ts +2 -0
  278. package/dist/cli/office.d.ts.map +1 -0
  279. package/dist/cli/office.js +181 -0
  280. package/dist/cli/office.js.map +1 -0
  281. package/dist/cli/onboard.d.ts +10 -0
  282. package/dist/cli/onboard.d.ts.map +1 -0
  283. package/dist/cli/onboard.js +225 -0
  284. package/dist/cli/onboard.js.map +1 -0
  285. package/dist/cli/process-lifecycle.d.ts +19 -0
  286. package/dist/cli/process-lifecycle.d.ts.map +1 -0
  287. package/dist/cli/process-lifecycle.js +67 -0
  288. package/dist/cli/process-lifecycle.js.map +1 -0
  289. package/dist/cli/sessions.d.ts +2 -0
  290. package/dist/cli/sessions.d.ts.map +1 -0
  291. package/dist/cli/sessions.js +88 -0
  292. package/dist/cli/sessions.js.map +1 -0
  293. package/dist/cli/types.d.ts +25 -0
  294. package/dist/cli/types.d.ts.map +1 -0
  295. package/dist/cli/types.js.map +1 -0
  296. package/dist/dream/index.d.ts +20 -0
  297. package/dist/dream/index.d.ts.map +1 -0
  298. package/dist/dream/index.js +264 -0
  299. package/dist/dream/index.js.map +1 -0
  300. package/dist/dream/types.d.ts +30 -0
  301. package/dist/dream/types.d.ts.map +1 -0
  302. package/dist/dream/types.js +2 -0
  303. package/dist/dream/types.js.map +1 -0
  304. package/dist/env-manifest.d.ts +38 -0
  305. package/dist/env-manifest.d.ts.map +1 -0
  306. package/dist/env-manifest.js +260 -0
  307. package/dist/env-manifest.js.map +1 -0
  308. package/dist/events/index.d.ts +172 -0
  309. package/dist/events/index.d.ts.map +1 -0
  310. package/dist/events/index.js +340 -0
  311. package/dist/events/index.js.map +1 -0
  312. package/dist/events/scheduler.d.ts +34 -0
  313. package/dist/events/scheduler.d.ts.map +1 -0
  314. package/dist/events/scheduler.js +231 -0
  315. package/dist/events/scheduler.js.map +1 -0
  316. package/dist/file-guards.d.ts +26 -0
  317. package/dist/file-guards.d.ts.map +1 -0
  318. package/dist/file-guards.js +133 -0
  319. package/dist/file-guards.js.map +1 -0
  320. package/dist/harness/execution-env.d.ts +19 -0
  321. package/dist/harness/execution-env.d.ts.map +1 -0
  322. package/dist/harness/execution-env.js +262 -0
  323. package/dist/harness/execution-env.js.map +1 -0
  324. package/dist/harness/execution-resolver.d.ts +25 -0
  325. package/dist/harness/execution-resolver.d.ts.map +1 -0
  326. package/dist/harness/execution-resolver.js +156 -0
  327. package/dist/harness/execution-resolver.js.map +1 -0
  328. package/dist/harness/index.d.ts +18 -13
  329. package/dist/harness/index.d.ts.map +1 -1
  330. package/dist/harness/index.js +11 -11
  331. package/dist/harness/index.js.map +1 -1
  332. package/dist/harness/jev.d.ts +86 -0
  333. package/dist/harness/jev.d.ts.map +1 -0
  334. package/dist/harness/jev.js +167 -0
  335. package/dist/harness/jev.js.map +1 -0
  336. package/dist/harness/mcp.d.ts +38 -0
  337. package/dist/harness/mcp.d.ts.map +1 -0
  338. package/dist/harness/mcp.js +304 -0
  339. package/dist/harness/mcp.js.map +1 -0
  340. package/dist/harness/models.d.ts +7 -4
  341. package/dist/harness/models.d.ts.map +1 -1
  342. package/dist/harness/models.js +54 -55
  343. package/dist/harness/models.js.map +1 -1
  344. package/dist/harness/open-connector.d.ts +25 -0
  345. package/dist/harness/open-connector.d.ts.map +1 -0
  346. package/dist/harness/open-connector.js +178 -0
  347. package/dist/harness/open-connector.js.map +1 -0
  348. package/dist/harness/presenter.d.ts +31 -0
  349. package/dist/harness/presenter.d.ts.map +1 -0
  350. package/dist/harness/presenter.js +859 -0
  351. package/dist/harness/presenter.js.map +1 -0
  352. package/dist/harness/prompt.d.ts +30 -0
  353. package/dist/harness/prompt.d.ts.map +1 -0
  354. package/dist/harness/prompt.js +420 -0
  355. package/dist/harness/prompt.js.map +1 -0
  356. package/dist/harness/runner.d.ts +2 -123
  357. package/dist/harness/runner.d.ts.map +1 -1
  358. package/dist/harness/runner.js +551 -416
  359. package/dist/harness/runner.js.map +1 -1
  360. package/dist/harness/session.d.ts +122 -0
  361. package/dist/harness/session.d.ts.map +1 -0
  362. package/dist/harness/session.js +581 -0
  363. package/dist/harness/session.js.map +1 -0
  364. package/dist/harness/skills.d.ts +17 -28
  365. package/dist/harness/skills.d.ts.map +1 -1
  366. package/dist/harness/skills.js +104 -39
  367. package/dist/harness/skills.js.map +1 -1
  368. package/dist/harness/subagent-profiles.d.ts +8 -0
  369. package/dist/harness/subagent-profiles.d.ts.map +1 -0
  370. package/dist/harness/subagent-profiles.js +293 -0
  371. package/dist/harness/subagent-profiles.js.map +1 -0
  372. package/dist/harness/subagent.d.ts +64 -0
  373. package/dist/harness/subagent.d.ts.map +1 -0
  374. package/dist/harness/subagent.js +687 -0
  375. package/dist/harness/subagent.js.map +1 -0
  376. package/dist/harness/tools/attach.d.ts.map +1 -0
  377. package/dist/{adapters/slack → harness}/tools/attach.js +1 -1
  378. package/dist/harness/tools/attach.js.map +1 -0
  379. package/dist/{tools → harness/tools}/event.d.ts +4 -33
  380. package/dist/harness/tools/event.d.ts.map +1 -0
  381. package/dist/harness/tools/event.js +175 -0
  382. package/dist/harness/tools/event.js.map +1 -0
  383. package/dist/harness/tools/generate-image.d.ts +23 -0
  384. package/dist/harness/tools/generate-image.d.ts.map +1 -0
  385. package/dist/harness/tools/generate-image.js +65 -0
  386. package/dist/harness/tools/generate-image.js.map +1 -0
  387. package/dist/harness/tools/host-fn-tool.d.ts +21 -0
  388. package/dist/harness/tools/host-fn-tool.d.ts.map +1 -0
  389. package/dist/harness/tools/host-fn-tool.js +32 -0
  390. package/dist/harness/tools/host-fn-tool.js.map +1 -0
  391. package/dist/harness/tools/index.d.ts +41 -0
  392. package/dist/harness/tools/index.d.ts.map +1 -0
  393. package/dist/harness/tools/index.js +51 -0
  394. package/dist/harness/tools/index.js.map +1 -0
  395. package/dist/harness/tools/jev.d.ts +21 -0
  396. package/dist/harness/tools/jev.d.ts.map +1 -0
  397. package/dist/harness/tools/jev.js +109 -0
  398. package/dist/harness/tools/jev.js.map +1 -0
  399. package/dist/harness/tools/pi-tools.d.ts +18 -0
  400. package/dist/harness/tools/pi-tools.d.ts.map +1 -0
  401. package/dist/harness/tools/pi-tools.js +84 -0
  402. package/dist/harness/tools/pi-tools.js.map +1 -0
  403. package/dist/harness/tools/react.d.ts.map +1 -0
  404. package/dist/{tools → harness/tools}/react.js +6 -17
  405. package/dist/harness/tools/react.js.map +1 -0
  406. package/dist/{tools → harness/tools}/sandbox.d.ts +4 -4
  407. package/dist/harness/tools/sandbox.d.ts.map +1 -0
  408. package/dist/{tools → harness/tools}/sandbox.js +12 -8
  409. package/dist/harness/tools/sandbox.js.map +1 -0
  410. package/dist/harness/tools/subagent.d.ts +85 -0
  411. package/dist/harness/tools/subagent.d.ts.map +1 -0
  412. package/dist/harness/tools/subagent.js +677 -0
  413. package/dist/harness/tools/subagent.js.map +1 -0
  414. package/dist/harness/tools/task.d.ts +20 -0
  415. package/dist/harness/tools/task.d.ts.map +1 -0
  416. package/dist/harness/tools/task.js +79 -0
  417. package/dist/harness/tools/task.js.map +1 -0
  418. package/dist/harness/tools/types.d.ts +29 -0
  419. package/dist/harness/tools/types.d.ts.map +1 -0
  420. package/dist/harness/tools/types.js +2 -0
  421. package/dist/harness/tools/types.js.map +1 -0
  422. package/dist/harness/types.d.ts +384 -25
  423. package/dist/harness/types.d.ts.map +1 -1
  424. package/dist/harness/types.js +1 -1
  425. package/dist/harness/types.js.map +1 -1
  426. package/dist/index.d.ts +33 -9
  427. package/dist/index.d.ts.map +1 -1
  428. package/dist/index.js +19 -6
  429. package/dist/index.js.map +1 -1
  430. package/dist/log.d.ts.map +1 -1
  431. package/dist/log.js +4 -1
  432. package/dist/log.js.map +1 -1
  433. package/dist/main.js +357 -198
  434. package/dist/main.js.map +1 -1
  435. package/dist/observability/index.d.ts +33 -0
  436. package/dist/observability/index.d.ts.map +1 -0
  437. package/dist/observability/index.js +257 -0
  438. package/dist/observability/index.js.map +1 -0
  439. package/dist/observability/instrument.js +14 -6
  440. package/dist/observability/instrument.js.map +1 -1
  441. package/dist/observability/otel.d.ts +10 -0
  442. package/dist/observability/otel.d.ts.map +1 -0
  443. package/dist/observability/otel.js +183 -0
  444. package/dist/observability/otel.js.map +1 -0
  445. package/dist/observability/sentry.d.ts +40 -7
  446. package/dist/observability/sentry.d.ts.map +1 -1
  447. package/dist/observability/sentry.js +176 -32
  448. package/dist/observability/sentry.js.map +1 -1
  449. package/dist/observability/types.d.ts +24 -3
  450. package/dist/observability/types.d.ts.map +1 -1
  451. package/dist/observability/types.js.map +1 -1
  452. package/dist/office/index.d.ts +139 -0
  453. package/dist/office/index.d.ts.map +1 -0
  454. package/dist/office/index.js +1084 -0
  455. package/dist/office/index.js.map +1 -0
  456. package/dist/office/projection.d.ts +42 -0
  457. package/dist/office/projection.d.ts.map +1 -0
  458. package/dist/office/projection.js +182 -0
  459. package/dist/office/projection.js.map +1 -0
  460. package/dist/office/types.d.ts +116 -0
  461. package/dist/office/types.d.ts.map +1 -0
  462. package/dist/office/types.js +2 -0
  463. package/dist/office/types.js.map +1 -0
  464. package/dist/runtime/conversation-runtime.d.ts +1 -1
  465. package/dist/runtime/conversation-runtime.d.ts.map +1 -1
  466. package/dist/runtime/conversation-runtime.js +423 -152
  467. package/dist/runtime/conversation-runtime.js.map +1 -1
  468. package/dist/runtime/session-lifecycle.d.ts +76 -0
  469. package/dist/runtime/session-lifecycle.d.ts.map +1 -0
  470. package/dist/runtime/session-lifecycle.js +404 -0
  471. package/dist/runtime/session-lifecycle.js.map +1 -0
  472. package/dist/runtime/types.d.ts +63 -15
  473. package/dist/runtime/types.d.ts.map +1 -1
  474. package/dist/runtime/types.js.map +1 -1
  475. package/dist/sandbox/cloudflare.d.ts +4 -0
  476. package/dist/sandbox/cloudflare.d.ts.map +1 -1
  477. package/dist/sandbox/cloudflare.js +54 -52
  478. package/dist/sandbox/cloudflare.js.map +1 -1
  479. package/dist/sandbox/container.d.ts +3 -0
  480. package/dist/sandbox/container.d.ts.map +1 -1
  481. package/dist/sandbox/container.js +19 -7
  482. package/dist/sandbox/container.js.map +1 -1
  483. package/dist/sandbox/host.d.ts +3 -0
  484. package/dist/sandbox/host.d.ts.map +1 -1
  485. package/dist/sandbox/host.js +44 -35
  486. package/dist/sandbox/host.js.map +1 -1
  487. package/dist/sandbox/identity.d.ts +42 -0
  488. package/dist/sandbox/identity.d.ts.map +1 -0
  489. package/dist/sandbox/identity.js +77 -0
  490. package/dist/sandbox/identity.js.map +1 -0
  491. package/dist/sandbox/index.d.ts +24 -6
  492. package/dist/sandbox/index.d.ts.map +1 -1
  493. package/dist/sandbox/index.js +77 -17
  494. package/dist/sandbox/index.js.map +1 -1
  495. package/dist/sandbox/provisioner.d.ts +139 -0
  496. package/dist/sandbox/provisioner.d.ts.map +1 -0
  497. package/dist/{provisioner.js → sandbox/provisioner.js} +378 -24
  498. package/dist/sandbox/provisioner.js.map +1 -0
  499. package/dist/sandbox/types.d.ts +43 -9
  500. package/dist/sandbox/types.d.ts.map +1 -1
  501. package/dist/sandbox/types.js.map +1 -1
  502. package/dist/sandbox/utils.d.ts +24 -0
  503. package/dist/sandbox/utils.d.ts.map +1 -1
  504. package/dist/sandbox/utils.js +92 -1
  505. package/dist/sandbox/utils.js.map +1 -1
  506. package/dist/sessions/chat-history-sync.d.ts +23 -0
  507. package/dist/sessions/chat-history-sync.d.ts.map +1 -0
  508. package/dist/sessions/{agent-memory-file-manager.js → chat-history-sync.js} +239 -175
  509. package/dist/sessions/chat-history-sync.js.map +1 -0
  510. package/dist/sessions/history-line.d.ts +29 -0
  511. package/dist/sessions/history-line.d.ts.map +1 -0
  512. package/dist/sessions/history-line.js +45 -0
  513. package/dist/sessions/history-line.js.map +1 -0
  514. package/dist/sessions/migrate-common.d.ts +43 -0
  515. package/dist/sessions/migrate-common.d.ts.map +1 -0
  516. package/dist/sessions/migrate-common.js +99 -0
  517. package/dist/sessions/migrate-common.js.map +1 -0
  518. package/dist/sessions/migrate-pi-084.d.ts +8 -0
  519. package/dist/sessions/migrate-pi-084.d.ts.map +1 -0
  520. package/dist/sessions/migrate-pi-084.js +302 -0
  521. package/dist/sessions/migrate-pi-084.js.map +1 -0
  522. package/dist/sessions/migrate-v3.d.ts +15 -0
  523. package/dist/sessions/migrate-v3.d.ts.map +1 -0
  524. package/dist/sessions/migrate-v3.js +419 -0
  525. package/dist/sessions/migrate-v3.js.map +1 -0
  526. package/dist/sessions/session-key.d.ts +33 -0
  527. package/dist/sessions/session-key.d.ts.map +1 -0
  528. package/dist/sessions/session-key.js +115 -0
  529. package/dist/sessions/session-key.js.map +1 -0
  530. package/dist/sessions/session-store.d.ts +61 -0
  531. package/dist/sessions/session-store.d.ts.map +1 -0
  532. package/dist/sessions/session-store.js +684 -0
  533. package/dist/sessions/session-store.js.map +1 -0
  534. package/dist/sessions/store.d.ts +17 -10
  535. package/dist/sessions/store.d.ts.map +1 -1
  536. package/dist/sessions/store.js +182 -47
  537. package/dist/sessions/store.js.map +1 -1
  538. package/dist/sessions/types.d.ts +74 -8
  539. package/dist/sessions/types.d.ts.map +1 -1
  540. package/dist/sessions/types.js +1 -1
  541. package/dist/sessions/types.js.map +1 -1
  542. package/dist/settings/apply.d.ts +16 -0
  543. package/dist/settings/apply.d.ts.map +1 -0
  544. package/dist/settings/apply.js +60 -0
  545. package/dist/settings/apply.js.map +1 -0
  546. package/dist/settings/index.d.ts +126 -0
  547. package/dist/settings/index.d.ts.map +1 -0
  548. package/dist/settings/index.js +422 -0
  549. package/dist/settings/index.js.map +1 -0
  550. package/dist/settings/migrate.d.ts +21 -0
  551. package/dist/settings/migrate.d.ts.map +1 -0
  552. package/dist/settings/migrate.js +86 -0
  553. package/dist/settings/migrate.js.map +1 -0
  554. package/dist/types.d.ts +330 -141
  555. package/dist/types.d.ts.map +1 -1
  556. package/dist/types.js +2 -2
  557. package/dist/types.js.map +1 -1
  558. package/dist/vault/index.d.ts +52 -2
  559. package/dist/vault/index.d.ts.map +1 -1
  560. package/dist/vault/index.js +218 -86
  561. package/dist/vault/index.js.map +1 -1
  562. package/dist/vault/types.d.ts +6 -2
  563. package/dist/vault/types.d.ts.map +1 -1
  564. package/dist/vault/types.js.map +1 -1
  565. package/package.json +79 -40
  566. package/dist/adapter.d.ts +0 -2
  567. package/dist/adapter.d.ts.map +0 -1
  568. package/dist/adapter.js +0 -2
  569. package/dist/adapter.js.map +0 -1
  570. package/dist/adapters/slack/tools/attach.d.ts.map +0 -1
  571. package/dist/adapters/slack/tools/attach.js.map +0 -1
  572. package/dist/adapters/streaming.d.ts +0 -18
  573. package/dist/adapters/streaming.d.ts.map +0 -1
  574. package/dist/adapters/streaming.js +0 -44
  575. package/dist/adapters/streaming.js.map +0 -1
  576. package/dist/adapters/telegram/html.d.ts +0 -3
  577. package/dist/adapters/telegram/html.d.ts.map +0 -1
  578. package/dist/adapters/telegram/html.js +0 -98
  579. package/dist/adapters/telegram/html.js.map +0 -1
  580. package/dist/agent-events.d.ts +0 -5
  581. package/dist/agent-events.d.ts.map +0 -1
  582. package/dist/agent-events.js +0 -26
  583. package/dist/agent-events.js.map +0 -1
  584. package/dist/agent.d.ts +0 -39
  585. package/dist/agent.d.ts.map +0 -1
  586. package/dist/agent.js +0 -1291
  587. package/dist/agent.js.map +0 -1
  588. package/dist/cli/ext-git.d.ts +0 -22
  589. package/dist/cli/ext-git.d.ts.map +0 -1
  590. package/dist/cli/ext-git.js +0 -76
  591. package/dist/cli/ext-git.js.map +0 -1
  592. package/dist/cli/ext.d.ts +0 -2
  593. package/dist/cli/ext.d.ts.map +0 -1
  594. package/dist/cli/ext.js +0 -217
  595. package/dist/cli/ext.js.map +0 -1
  596. package/dist/commands/admin.d.ts.map +0 -1
  597. package/dist/commands/admin.js.map +0 -1
  598. package/dist/commands/auto-reply.d.ts.map +0 -1
  599. package/dist/commands/auto-reply.js +0 -76
  600. package/dist/commands/auto-reply.js.map +0 -1
  601. package/dist/commands/extensions.d.ts +0 -14
  602. package/dist/commands/extensions.d.ts.map +0 -1
  603. package/dist/commands/extensions.js +0 -55
  604. package/dist/commands/extensions.js.map +0 -1
  605. package/dist/commands/login.d.ts +0 -5
  606. package/dist/commands/login.d.ts.map +0 -1
  607. package/dist/commands/login.js +0 -115
  608. package/dist/commands/login.js.map +0 -1
  609. package/dist/commands/model.d.ts +0 -10
  610. package/dist/commands/model.d.ts.map +0 -1
  611. package/dist/commands/model.js +0 -102
  612. package/dist/commands/model.js.map +0 -1
  613. package/dist/commands/new.d.ts.map +0 -1
  614. package/dist/commands/new.js +0 -25
  615. package/dist/commands/new.js.map +0 -1
  616. package/dist/commands/parse.d.ts +0 -7
  617. package/dist/commands/parse.d.ts.map +0 -1
  618. package/dist/commands/parse.js +0 -14
  619. package/dist/commands/parse.js.map +0 -1
  620. package/dist/commands/registry.d.ts +0 -5
  621. package/dist/commands/registry.d.ts.map +0 -1
  622. package/dist/commands/registry.js +0 -31
  623. package/dist/commands/registry.js.map +0 -1
  624. package/dist/commands/sandbox.d.ts.map +0 -1
  625. package/dist/commands/sandbox.js +0 -78
  626. package/dist/commands/sandbox.js.map +0 -1
  627. package/dist/commands/session-view.d.ts.map +0 -1
  628. package/dist/commands/session-view.js.map +0 -1
  629. package/dist/commands/types.d.ts +0 -66
  630. package/dist/commands/types.d.ts.map +0 -1
  631. package/dist/commands/types.js.map +0 -1
  632. package/dist/commands/utils.d.ts +0 -11
  633. package/dist/commands/utils.d.ts.map +0 -1
  634. package/dist/commands/utils.js.map +0 -1
  635. package/dist/config.d.ts +0 -78
  636. package/dist/config.d.ts.map +0 -1
  637. package/dist/config.js +0 -450
  638. package/dist/config.js.map +0 -1
  639. package/dist/download.d.ts.map +0 -1
  640. package/dist/download.js +0 -89
  641. package/dist/download.js.map +0 -1
  642. package/dist/events.d.ts +0 -43
  643. package/dist/events.d.ts.map +0 -1
  644. package/dist/events.js +0 -456
  645. package/dist/events.js.map +0 -1
  646. package/dist/execution-resolver.d.ts +0 -21
  647. package/dist/execution-resolver.d.ts.map +0 -1
  648. package/dist/execution-resolver.js +0 -170
  649. package/dist/execution-resolver.js.map +0 -1
  650. package/dist/harness/auth.d.ts +0 -16
  651. package/dist/harness/auth.d.ts.map +0 -1
  652. package/dist/harness/auth.js +0 -86
  653. package/dist/harness/auth.js.map +0 -1
  654. package/dist/harness/extensions/loader.d.ts +0 -86
  655. package/dist/harness/extensions/loader.d.ts.map +0 -1
  656. package/dist/harness/extensions/loader.js +0 -525
  657. package/dist/harness/extensions/loader.js.map +0 -1
  658. package/dist/harness/extensions/registry.d.ts +0 -23
  659. package/dist/harness/extensions/registry.d.ts.map +0 -1
  660. package/dist/harness/extensions/registry.js +0 -45
  661. package/dist/harness/extensions/registry.js.map +0 -1
  662. package/dist/harness/extensions/types.d.ts +0 -248
  663. package/dist/harness/extensions/types.d.ts.map +0 -1
  664. package/dist/harness/extensions/types.js.map +0 -1
  665. package/dist/harness/session-store.d.ts +0 -77
  666. package/dist/harness/session-store.d.ts.map +0 -1
  667. package/dist/harness/session-store.js +0 -248
  668. package/dist/harness/session-store.js.map +0 -1
  669. package/dist/harness/settings.d.ts +0 -47
  670. package/dist/harness/settings.d.ts.map +0 -1
  671. package/dist/harness/settings.js +0 -29
  672. package/dist/harness/settings.js.map +0 -1
  673. package/dist/model-registry.d.ts +0 -4
  674. package/dist/model-registry.d.ts.map +0 -1
  675. package/dist/model-registry.js +0 -7
  676. package/dist/model-registry.js.map +0 -1
  677. package/dist/platform-messages.d.ts.map +0 -1
  678. package/dist/platform-messages.js.map +0 -1
  679. package/dist/portal-shell.d.ts +0 -4
  680. package/dist/portal-shell.d.ts.map +0 -1
  681. package/dist/portal-shell.js.map +0 -1
  682. package/dist/provisioner.d.ts +0 -61
  683. package/dist/provisioner.d.ts.map +0 -1
  684. package/dist/provisioner.js.map +0 -1
  685. package/dist/runtime/agent-run-controller.d.ts +0 -31
  686. package/dist/runtime/agent-run-controller.d.ts.map +0 -1
  687. package/dist/runtime/agent-run-controller.js +0 -195
  688. package/dist/runtime/agent-run-controller.js.map +0 -1
  689. package/dist/sandbox/errors.d.ts +0 -6
  690. package/dist/sandbox/errors.d.ts.map +0 -1
  691. package/dist/sandbox/errors.js +0 -11
  692. package/dist/sandbox/errors.js.map +0 -1
  693. package/dist/sandbox/firecracker.d.ts +0 -15
  694. package/dist/sandbox/firecracker.d.ts.map +0 -1
  695. package/dist/sandbox/firecracker.js +0 -212
  696. package/dist/sandbox/firecracker.js.map +0 -1
  697. package/dist/sandbox/image.d.ts +0 -3
  698. package/dist/sandbox/image.d.ts.map +0 -1
  699. package/dist/sandbox/image.js +0 -27
  700. package/dist/sandbox/image.js.map +0 -1
  701. package/dist/sandbox/path-context.d.ts +0 -3
  702. package/dist/sandbox/path-context.d.ts.map +0 -1
  703. package/dist/sandbox/path-context.js +0 -20
  704. package/dist/sandbox/path-context.js.map +0 -1
  705. package/dist/sessions/agent-memory-file-manager.d.ts +0 -19
  706. package/dist/sessions/agent-memory-file-manager.d.ts.map +0 -1
  707. package/dist/sessions/agent-memory-file-manager.js.map +0 -1
  708. package/dist/sessions/metadata.d.ts +0 -3
  709. package/dist/sessions/metadata.d.ts.map +0 -1
  710. package/dist/sessions/metadata.js +0 -11
  711. package/dist/sessions/metadata.js.map +0 -1
  712. package/dist/sessions/policy.d.ts +0 -6
  713. package/dist/sessions/policy.d.ts.map +0 -1
  714. package/dist/sessions/policy.js +0 -23
  715. package/dist/sessions/policy.js.map +0 -1
  716. package/dist/store.d.ts +0 -46
  717. package/dist/store.d.ts.map +0 -1
  718. package/dist/store.js +0 -177
  719. package/dist/store.js.map +0 -1
  720. package/dist/tools/bash.d.ts +0 -10
  721. package/dist/tools/bash.d.ts.map +0 -1
  722. package/dist/tools/bash.js +0 -80
  723. package/dist/tools/bash.js.map +0 -1
  724. package/dist/tools/edit.d.ts +0 -11
  725. package/dist/tools/edit.d.ts.map +0 -1
  726. package/dist/tools/edit.js +0 -131
  727. package/dist/tools/edit.js.map +0 -1
  728. package/dist/tools/event.d.ts.map +0 -1
  729. package/dist/tools/event.js +0 -252
  730. package/dist/tools/event.js.map +0 -1
  731. package/dist/tools/index.d.ts +0 -24
  732. package/dist/tools/index.d.ts.map +0 -1
  733. package/dist/tools/index.js +0 -31
  734. package/dist/tools/index.js.map +0 -1
  735. package/dist/tools/react.d.ts.map +0 -1
  736. package/dist/tools/react.js.map +0 -1
  737. package/dist/tools/read.d.ts +0 -11
  738. package/dist/tools/read.d.ts.map +0 -1
  739. package/dist/tools/read.js +0 -134
  740. package/dist/tools/read.js.map +0 -1
  741. package/dist/tools/sandbox.d.ts.map +0 -1
  742. package/dist/tools/sandbox.js.map +0 -1
  743. package/dist/tools/truncate.d.ts +0 -33
  744. package/dist/tools/truncate.d.ts.map +0 -1
  745. package/dist/tools/truncate.js +0 -184
  746. package/dist/tools/truncate.js.map +0 -1
  747. package/dist/tools/types.d.ts +0 -54
  748. package/dist/tools/types.d.ts.map +0 -1
  749. package/dist/tools/types.js.map +0 -1
  750. package/dist/tools/write.d.ts +0 -10
  751. package/dist/tools/write.d.ts.map +0 -1
  752. package/dist/tools/write.js +0 -29
  753. package/dist/tools/write.js.map +0 -1
  754. package/dist/trigger.d.ts +0 -22
  755. package/dist/trigger.d.ts.map +0 -1
  756. package/dist/trigger.js +0 -100
  757. package/dist/trigger.js.map +0 -1
  758. package/dist/utils/date.d.ts +0 -10
  759. package/dist/utils/date.d.ts.map +0 -1
  760. package/dist/utils/date.js +0 -23
  761. package/dist/utils/date.js.map +0 -1
  762. package/dist/utils/env.d.ts +0 -3
  763. package/dist/utils/env.d.ts.map +0 -1
  764. package/dist/utils/env.js +0 -12
  765. package/dist/utils/env.js.map +0 -1
  766. package/dist/utils/file-guards.d.ts +0 -9
  767. package/dist/utils/file-guards.d.ts.map +0 -1
  768. package/dist/utils/file-guards.js +0 -59
  769. package/dist/utils/file-guards.js.map +0 -1
  770. package/dist/utils/fs-atomic.d.ts +0 -10
  771. package/dist/utils/fs-atomic.d.ts.map +0 -1
  772. package/dist/utils/fs-atomic.js +0 -45
  773. package/dist/utils/fs-atomic.js.map +0 -1
  774. package/dist/utils/html.d.ts +0 -2
  775. package/dist/utils/html.d.ts.map +0 -1
  776. package/dist/utils/html.js +0 -4
  777. package/dist/utils/html.js.map +0 -1
  778. package/dist/utils/http-body.d.ts +0 -10
  779. package/dist/utils/http-body.d.ts.map +0 -1
  780. package/dist/utils/http-body.js +0 -34
  781. package/dist/utils/http-body.js.map +0 -1
  782. package/dist/vault/routing.d.ts +0 -3
  783. package/dist/vault/routing.d.ts.map +0 -1
  784. package/dist/vault/routing.js +0 -13
  785. package/dist/vault/routing.js.map +0 -1
  786. package/dist/web/admin/portal.d.ts +0 -5
  787. package/dist/web/admin/portal.d.ts.map +0 -1
  788. package/dist/web/admin/portal.js +0 -2572
  789. package/dist/web/admin/portal.js.map +0 -1
  790. package/dist/web/admin/provider-models.d.ts.map +0 -1
  791. package/dist/web/admin/provider-models.js.map +0 -1
  792. package/dist/web/admin/store.d.ts +0 -13
  793. package/dist/web/admin/store.d.ts.map +0 -1
  794. package/dist/web/admin/store.js +0 -14
  795. package/dist/web/admin/store.js.map +0 -1
  796. package/dist/web/admin/types.d.ts +0 -30
  797. package/dist/web/admin/types.d.ts.map +0 -1
  798. package/dist/web/admin/types.js.map +0 -1
  799. package/dist/web/agent-events/portal.d.ts +0 -3
  800. package/dist/web/agent-events/portal.d.ts.map +0 -1
  801. package/dist/web/agent-events/portal.js +0 -18
  802. package/dist/web/agent-events/portal.js.map +0 -1
  803. package/dist/web/login/oauth.d.ts +0 -6
  804. package/dist/web/login/oauth.d.ts.map +0 -1
  805. package/dist/web/login/oauth.js.map +0 -1
  806. package/dist/web/login/portal.d.ts.map +0 -1
  807. package/dist/web/login/portal.js.map +0 -1
  808. package/dist/web/login/store.d.ts +0 -8
  809. package/dist/web/login/store.d.ts.map +0 -1
  810. package/dist/web/login/store.js +0 -15
  811. package/dist/web/login/store.js.map +0 -1
  812. package/dist/web/login/types.d.ts.map +0 -1
  813. package/dist/web/login/types.js.map +0 -1
  814. package/dist/web/request.d.ts +0 -3
  815. package/dist/web/request.d.ts.map +0 -1
  816. package/dist/web/request.js +0 -13
  817. package/dist/web/request.js.map +0 -1
  818. package/dist/web/server.d.ts.map +0 -1
  819. package/dist/web/server.js.map +0 -1
  820. package/dist/web/session-view/command.d.ts +0 -4
  821. package/dist/web/session-view/command.d.ts.map +0 -1
  822. package/dist/web/session-view/command.js +0 -7
  823. package/dist/web/session-view/command.js.map +0 -1
  824. package/dist/web/session-view/portal.d.ts +0 -13
  825. package/dist/web/session-view/portal.d.ts.map +0 -1
  826. package/dist/web/session-view/portal.js.map +0 -1
  827. package/dist/web/session-view/service.d.ts +0 -6
  828. package/dist/web/session-view/service.d.ts.map +0 -1
  829. package/dist/web/session-view/service.js +0 -498
  830. package/dist/web/session-view/service.js.map +0 -1
  831. package/dist/web/session-view/store.d.ts +0 -8
  832. package/dist/web/session-view/store.d.ts.map +0 -1
  833. package/dist/web/session-view/store.js +0 -15
  834. package/dist/web/session-view/store.js.map +0 -1
  835. package/dist/web/session-view/types.d.ts.map +0 -1
  836. package/dist/web/session-view/types.js.map +0 -1
  837. package/dist/web/token-store.d.ts.map +0 -1
  838. package/dist/web/token-store.js.map +0 -1
  839. package/dist/web/types.d.ts.map +0 -1
  840. package/dist/web/types.js.map +0 -1
  841. /package/dist/{commands → adapters/commands}/admin.d.ts +0 -0
  842. /package/dist/{commands → adapters/commands}/new.d.ts +0 -0
  843. /package/dist/{commands → adapters/commands}/sandbox.d.ts +0 -0
  844. /package/dist/{commands → adapters/commands}/session-view.d.ts +0 -0
  845. /package/dist/{commands → adapters/commands}/types.js +0 -0
  846. /package/dist/{harness/extensions → adapters/github}/types.js +0 -0
  847. /package/dist/{tools → adapters/web/admin}/types.js +0 -0
  848. /package/dist/{web/admin → adapters/web/login}/types.js +0 -0
  849. /package/dist/{web/login → adapters/web/session-view}/types.js +0 -0
  850. /package/dist/{web → adapters/web}/token-store.d.ts +0 -0
  851. /package/dist/{web → adapters/web}/types.d.ts +0 -0
  852. /package/dist/{web/session-view → adapters/web}/types.js +0 -0
  853. /package/dist/{download.d.ts → cli/download.d.ts} +0 -0
  854. /package/dist/{web → cli}/types.js +0 -0
  855. /package/dist/{adapters/slack → harness}/tools/attach.d.ts +0 -0
  856. /package/dist/{tools → harness/tools}/react.d.ts +0 -0
@@ -0,0 +1 @@
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;AAEtD,OAAO,EACL,UAAU,EACV,SAAS,EACT,SAA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AM,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 type { Dirent, Stats } from \"node:fs\";\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 \"../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/** Path separators and the C0/C1 control ranges are never allowed in an id. */\nfunction isUnsafeConversationIdChar(character: string): boolean {\n const code = character.codePointAt(0) ?? 0;\n return character === \"/\" || character === \"\\\\\" || code <= 0x1f || (code >= 0x7f && code <= 0x9f);\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 if ([...value].some(isUnsafeConversationIdChar)) {\n throw new Error(\"Conversation id must not contain path separators or control characters\");\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 * Settings and migration callers that only hold a `stateDir` string use this\n * when no materialized `Office` value is available.\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 workspace\n * projection, and the migration's legacy-dir scan. `events` stays reserved\n * for the legacy scheduling bus that `mikan office migrate-events` drains.\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 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\ninterface MigrationFields {\n rawConversationId: string;\n sourceDir: string;\n workspaceRoot: string;\n status: OfficeMigrationStatus;\n updatedAt: string;\n}\n\nfunction hasMigrationStrings(\n value: Record<string, unknown>,\n): value is Record<string, unknown> & Record<keyof MigrationFields, string> {\n return (\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}\n\n/** Validate the fields every stored migration record must carry. */\nfunction parseMigrationFields(value: Record<string, unknown>, path: string): MigrationFields {\n if (!hasMigrationStrings(value)) {\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 return {\n rawConversationId: value.rawConversationId,\n sourceDir: value.sourceDir,\n workspaceRoot: value.workspaceRoot,\n status: value.status as OfficeMigrationStatus,\n updatedAt: value.updatedAt,\n };\n}\n\n/**\n * Ownership rules by status: `needs-owner` must carry neither owner nor\n * target, `failed` may carry either, every other status must carry both.\n */\nfunction assertOwnershipMatchesStatus(\n status: OfficeMigrationStatus,\n ownerPlatform: PlatformName | undefined,\n targetDir: string | undefined,\n path: string,\n): void {\n const owned = ownerPlatform !== undefined;\n const targeted = targetDir !== undefined;\n if (status === \"needs-owner\" && (owned || targeted)) {\n throw new Error(`Needs-owner migration cannot have an owner or target in ${path}`);\n }\n if (status !== \"needs-owner\" && status !== \"failed\" && !(owned && targeted)) {\n throw new Error(`Prepared office migration is missing ownership in ${path}`);\n }\n if (!owned && targeted) {\n throw new Error(`Office migration target has no owner in ${path}`);\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 const fields = parseMigrationFields(value, path);\n const ownerPlatform = optionalPlatform(value.ownerPlatform);\n const targetDir = optionalString(value.targetDir);\n const error = optionalString(value.error);\n\n if (ownerPlatform !== undefined && !enabledPlatforms.includes(ownerPlatform)) {\n throw new Error(`Office migration owner is not enabled in ${path}`);\n }\n assertOwnershipMatchesStatus(fields.status, ownerPlatform, targetDir, path);\n\n const expectedTargetDir = ownerPlatform\n ? officeDir(fields.workspaceRoot, {\n platform: ownerPlatform,\n conversationId: fields.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 (fields.status === \"failed\" && !error) {\n throw new Error(`Failed office migration is missing an error in ${path}`);\n }\n\n return buildMigrationRecord(fields, ownerPlatform, expectedTargetDir, error);\n}\n\nfunction buildMigrationRecord(\n fields: MigrationFields,\n ownerPlatform: PlatformName | undefined,\n targetDir: string | undefined,\n error: string | undefined,\n): OfficeMigrationRecord {\n return makeRecord({\n rawConversationId: fields.rawConversationId,\n sourceDir: fields.sourceDir,\n workspaceRoot: fields.workspaceRoot,\n ...(ownerPlatform ? { ownerPlatform } : {}),\n ...(targetDir ? { targetDir } : {}),\n status: fields.status,\n ...(error ? { error } : {}),\n updatedAt: fields.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\n/** `lstat` that reports a missing path as undefined; other errors still throw. */\nfunction lstatIfExists(path: string): Stats | undefined {\n try {\n return lstatSync(path);\n } catch (error) {\n if (isErrno(error, \"ENOENT\")) return undefined;\n throw error;\n }\n}\n\nfunction assertRegistryFileSafe(path: string): void {\n const stat = lstatIfExists(path);\n if (stat && (stat.isSymbolicLink() || !stat.isFile())) {\n throw new Error(`Office registry must be a regular file: ${path}`);\n }\n}\n\nfunction assertPathIfPresent(path: string, label: string): void {\n const stat = lstatIfExists(path);\n if (stat && (stat.isSymbolicLink() || !stat.isDirectory())) {\n throw new Error(`${label} must be a regular directory: ${path}`);\n }\n}\n\nfunction assertPathAbsent(path: string, label: string): void {\n if (lstatIfExists(path)) throw new Error(`${label} must be absent: ${path}`);\n}\n\nfunction pathExists(path: string): boolean {\n return lstatIfExists(path) !== undefined;\n}\n\n/** Create the lock directory and stamp it with our token, unwinding on failure. */\nfunction claimRegistryLock(lockPath: string, token: string): void {\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}\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 claimRegistryLock(lockPath, token);\n return () => releaseRegistryLease(lockPath, token);\n } catch (error) {\n awaitFreeRegistryLock(lockPath, deadline, error);\n }\n }\n}\n\n/**\n * Handle one failed lock attempt: rethrow anything but a held lock, clear a\n * stale lock so the next attempt wins, else wait until the deadline passes.\n */\nfunction awaitFreeRegistryLock(lockPath: string, deadline: number, error: unknown): void {\n if (!isErrno(error, \"EEXIST\")) throw error;\n if (registryLockIsStale(lockPath)) {\n rmSync(lockPath, { recursive: true, force: true });\n return;\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\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 failure = finishInterruptedMove(record);\n if (failure) {\n registry.markFailed(record.rawConversationId, failure);\n continue;\n }\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/** Complete one interrupted rename; returns the failure reason when it cannot. */\nfunction finishInterruptedMove(record: OfficeMigrationRecord): string | undefined {\n const targetDir = record.targetDir;\n if (!targetDir) return \"Moving record has no target directory\";\n const sourceExists = pathExists(record.sourceDir);\n const targetExists = pathExists(targetDir);\n if (sourceExists && targetExists) {\n return \"Both legacy source and office target exist; merge them manually\";\n }\n if (!sourceExists && !targetExists) return \"Neither legacy source nor office target exists\";\n if (sourceExists) renameSync(record.sourceDir, targetDir);\n return undefined;\n}\n\n/**\n * A legacy directory is claimable unless it already failed (reported via\n * summary.failed). One that reappears after a committed move is a different\n * (or resurrected) office the runtime can no longer see, so refusing to boot\n * beats silently ignoring its data.\n */\nfunction isClaimableLegacyDir(\n registry: OfficeRegistry,\n workspaceRoot: string,\n rawConversationId: string,\n): boolean {\n const existing = registry.getMigration(rawConversationId);\n if (existing?.status === \"committed\") {\n throw new Error(\n `Legacy office directory reappeared after migration: ${join(workspaceRoot, rawConversationId)}`,\n );\n }\n return existing?.status !== \"failed\";\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 if (!isClaimableLegacyDir(registry, workspaceRoot, rawConversationId)) continue;\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 return readdirSync(workspaceRoot, { withFileTypes: true })\n .filter((entry) => isLegacyOfficeDir(workspaceRoot, entry))\n .map((entry) => entry.name)\n .toSorted();\n}\n\nfunction isLegacyOfficeDir(workspaceRoot: string, entry: Dirent): boolean {\n if (entry.name.startsWith(\".\")) return false;\n if (RESERVED_WORKSPACE_NAMES.has(entry.name)) return false;\n if (isOfficeKey(entry.name)) return false;\n if (entry.isSymbolicLink()) {\n throw new Error(`Workspace entry must not be a symlink: ${join(workspaceRoot, entry.name)}`);\n }\n if (!entry.isDirectory()) return false;\n if (looksLikeConversationOffice(join(workspaceRoot, entry.name))) return true;\n log.logInfo(\n `[office] Skipping non-office workspace directory (no log.jsonl or sessions/): ${entry.name}`,\n );\n return false;\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 lines.push(\n ...conflictSection(summary.failed, [\n \"These migrations previously failed and need manual repair (see\",\n \"office-registry.json in the state dir for each error):\",\n ]),\n ...conflictSection(summary.vaultConflicts, [\n \"These conversations have credentials under both the legacy and the\",\n \"office-key vault directory; merge them manually under <state-dir>/vaults:\",\n ]),\n ...conflictSection(summary.stateDirConflicts, [\n \"These conversations have host state under both the legacy and the\",\n \"office-key directory; merge them manually under <state-dir>/conversations:\",\n ]),\n );\n return lines.join(\"\\n\");\n}\n\n/** One blank-separated \"these need manual work\" block, empty when nothing does. */\nfunction conflictSection(ids: readonly string[], explanation: string[]): string[] {\n if (ids.length === 0) return [];\n return [\"\", ...explanation, ...ids.map((id) => ` - ${id}`)];\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"]}
@@ -0,0 +1,42 @@
1
+ import { type Office } from "./index.js";
2
+ import type { WorkspaceVisibility } from "../types.js";
3
+ import type { PlatformChannelKind, WorkspaceProjection } from "./types.js";
4
+ export type { PlatformChannelKind, WorkspaceProjection } from "./types.js";
5
+ /**
6
+ * Record the platform's own channel kind for this conversation, as observed
7
+ * by the adapter at message intake. Stored under the host-only office state
8
+ * dir (never the sandbox-mounted workspace), so sandboxed code cannot
9
+ * promote its own conversation into the shared pool. Written only on change;
10
+ * the value is a snapshot as of the last message, which is exactly the
11
+ * freshness the projection needs — a conversation that never speaks again
12
+ * never needs a fresher value.
13
+ */
14
+ export declare function recordPlatformChannelKind(office: Office, kind: PlatformChannelKind): void;
15
+ /** The recorded platform channel kind, or undefined when never observed. */
16
+ export declare function readPlatformChannelKind(office: Office): PlatformChannelKind | undefined;
17
+ /** Where an office's visibility came from; shown to operators instead of raw values. */
18
+ export interface OfficeVisibilityDecision {
19
+ visibility: WorkspaceVisibility;
20
+ source: "platform" | "override" | "unknown";
21
+ }
22
+ /**
23
+ * One dimension, derived from the platform (ADR 0008): Slack public channels
24
+ * are public; private channels, DMs, group DMs, and externally shared
25
+ * conversations are private; a Slack conversation whose kind has not been
26
+ * recorded yet fails closed to private. Every other platform is private by
27
+ * decision, not by omission — Telegram groups, Discord channels, and GitHub
28
+ * threads have no "visible to the whole workspace" notion that maps cleanly
29
+ * onto a shared office. An operator may narrow a public conversation to
30
+ * private, never the reverse.
31
+ */
32
+ export declare function resolveOfficeVisibility(office: Office): OfficeVisibilityDecision;
33
+ /**
34
+ * The single policy seam for a managed office. It both materializes the
35
+ * host-side roots and authorizes the prompt sources that describe them.
36
+ * Every office gets the same shape (ADR 0008): its own directory read-write,
37
+ * every other public office read-only under /workspace/public, and the
38
+ * workspace-global knowledge read-write for public offices or read-only for
39
+ * private ones. No layout mounts the workspace root.
40
+ */
41
+ export declare function resolveWorkspaceProjection(office: Office): WorkspaceProjection;
42
+ //# sourceMappingURL=projection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/office/projection.ts"],"names":[],"mappings":"AAIA,OAAO,EAAyB,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAEhE,OAAO,KAAK,EAAkB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE3E,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAU3E;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAIzF;AAED,4EAA4E;AAC5E,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAiBvF;AAED,wFAAwF;AACxF,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,mBAAmB,CAAC;IAChC,MAAM,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;CAC7C;AAKD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,wBAAwB,CAUhF;AAsBD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAmC9E"}
@@ -0,0 +1,182 @@
1
+ import { dirname, join } from "node:path";
2
+ import { lstatSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { atomicWritePrivateFile, ensureDirExists } from "../file-guards.js";
4
+ import { loadOfficeVisibilityOverride } from "../settings/index.js";
5
+ import { listRegisteredOffices } from "./index.js";
6
+ import * as log from "../log.js";
7
+ const CHANNEL_KIND_FILE = "channel-kind";
8
+ const CHANNEL_KINDS = [
9
+ "public_channel",
10
+ "private_channel",
11
+ "im",
12
+ "external",
13
+ ];
14
+ /**
15
+ * Record the platform's own channel kind for this conversation, as observed
16
+ * by the adapter at message intake. Stored under the host-only office state
17
+ * dir (never the sandbox-mounted workspace), so sandboxed code cannot
18
+ * promote its own conversation into the shared pool. Written only on change;
19
+ * the value is a snapshot as of the last message, which is exactly the
20
+ * freshness the projection needs — a conversation that never speaks again
21
+ * never needs a fresher value.
22
+ */
23
+ export function recordPlatformChannelKind(office, kind) {
24
+ if (readPlatformChannelKind(office) === kind)
25
+ return;
26
+ ensureDirExists(office.stateDir);
27
+ atomicWritePrivateFile(join(office.stateDir, CHANNEL_KIND_FILE), kind + "\n");
28
+ }
29
+ /** The recorded platform channel kind, or undefined when never observed. */
30
+ export function readPlatformChannelKind(office) {
31
+ const path = join(office.stateDir, CHANNEL_KIND_FILE);
32
+ let raw;
33
+ try {
34
+ raw = readFileSync(path, "utf-8");
35
+ }
36
+ catch (err) {
37
+ if (err.code === "ENOENT")
38
+ return undefined;
39
+ log.logWarning("Could not read platform channel kind; treating the office as private", `${path}: ${err instanceof Error ? err.message : String(err)}`);
40
+ return undefined;
41
+ }
42
+ const value = raw.trim();
43
+ return CHANNEL_KINDS.includes(value)
44
+ ? value
45
+ : undefined;
46
+ }
47
+ /** Platforms whose public conversations become public offices (ADR 0008). */
48
+ const PUBLIC_CAPABLE_PLATFORMS = new Set(["slack"]);
49
+ /**
50
+ * One dimension, derived from the platform (ADR 0008): Slack public channels
51
+ * are public; private channels, DMs, group DMs, and externally shared
52
+ * conversations are private; a Slack conversation whose kind has not been
53
+ * recorded yet fails closed to private. Every other platform is private by
54
+ * decision, not by omission — Telegram groups, Discord channels, and GitHub
55
+ * threads have no "visible to the whole workspace" notion that maps cleanly
56
+ * onto a shared office. An operator may narrow a public conversation to
57
+ * private, never the reverse.
58
+ */
59
+ export function resolveOfficeVisibility(office) {
60
+ if (loadOfficeVisibilityOverride(office) === "private") {
61
+ return { visibility: "private", source: "override" };
62
+ }
63
+ if (!PUBLIC_CAPABLE_PLATFORMS.has(office.address.platform)) {
64
+ return { visibility: "private", source: "platform" };
65
+ }
66
+ const kind = readPlatformChannelKind(office);
67
+ if (kind === undefined)
68
+ return { visibility: "private", source: "unknown" };
69
+ return { visibility: kind === "public_channel" ? "public" : "private", source: "platform" };
70
+ }
71
+ /**
72
+ * Every public office other than `self`, as read-only mounts under
73
+ * `/workspace/public/<key>`. Bind mounts rather than a symlink directory:
74
+ * symlinks would resolve against the container's own filesystem, where host
75
+ * paths do not exist. A public channel appearing or changing visibility
76
+ * changes the mount signature, so affected containers rebuild on their next
77
+ * message with contents preserved.
78
+ */
79
+ function publicOfficeMounts(self) {
80
+ const { workspace } = self;
81
+ const mounts = [];
82
+ for (const record of listRegisteredOffices(workspace.stateDir)) {
83
+ const other = workspace.office(record);
84
+ if (other.key === self.key || !exists(other.dir))
85
+ continue;
86
+ if (resolveOfficeVisibility(other).visibility !== "public")
87
+ continue;
88
+ mounts.push({ source: other.dir, target: `/workspace/public/${other.key}`, readOnly: true });
89
+ }
90
+ return mounts.toSorted((a, b) => a.target.localeCompare(b.target));
91
+ }
92
+ /**
93
+ * The single policy seam for a managed office. It both materializes the
94
+ * host-side roots and authorizes the prompt sources that describe them.
95
+ * Every office gets the same shape (ADR 0008): its own directory read-write,
96
+ * every other public office read-only under /workspace/public, and the
97
+ * workspace-global knowledge read-write for public offices or read-only for
98
+ * private ones. No layout mounts the workspace root.
99
+ */
100
+ export function resolveWorkspaceProjection(office) {
101
+ const { workspace } = office;
102
+ const decision = resolveOfficeVisibility(office);
103
+ const readOnlyKnowledge = decision.visibility === "private";
104
+ assertDirectory(workspace.root, "Host workspace root");
105
+ office.ensure();
106
+ ensureRegularFile(workspace.memoryPath, "Workspace memory");
107
+ ensureDirectoryRoot(workspace.skillsDir, "Workspace skills");
108
+ const ro = { readOnly: true };
109
+ return {
110
+ ...decision,
111
+ mounts: [
112
+ { source: office.dir, target: `/workspace/${office.key}` },
113
+ {
114
+ source: workspace.memoryPath,
115
+ target: "/workspace/MEMORY.md",
116
+ ...(readOnlyKnowledge ? ro : {}),
117
+ },
118
+ {
119
+ source: workspace.skillsDir,
120
+ target: "/workspace/skills",
121
+ ...(readOnlyKnowledge ? ro : {}),
122
+ },
123
+ ...publicOfficeMounts(office),
124
+ ],
125
+ promptSources: {
126
+ conversationDir: office.dir,
127
+ conversationMemoryPath: office.memoryPath,
128
+ conversationSkillsDir: office.skillsDir,
129
+ globalMemoryPath: workspace.memoryPath,
130
+ globalSkillsDir: workspace.skillsDir,
131
+ ...(readOnlyKnowledge ? { globalKnowledgeReadOnly: true } : {}),
132
+ },
133
+ };
134
+ }
135
+ function ensureDirectoryRoot(path, label) {
136
+ if (!exists(path)) {
137
+ mkdirSync(path, { recursive: true, mode: 0o700 });
138
+ return;
139
+ }
140
+ assertDirectory(path, label);
141
+ }
142
+ function ensureRegularFile(path, label) {
143
+ if (!exists(path)) {
144
+ ensureDirExists(dirname(path));
145
+ writeFileSync(path, "", { mode: 0o600, flag: "wx" });
146
+ return;
147
+ }
148
+ let stats;
149
+ try {
150
+ stats = lstatSync(path);
151
+ }
152
+ catch (err) {
153
+ throw new Error(`${label} cannot be inspected: ${path}`, { cause: err });
154
+ }
155
+ if (stats.isSymbolicLink() || !stats.isFile()) {
156
+ throw new Error(`${label} must be a regular non-symlink file: ${path}`);
157
+ }
158
+ }
159
+ function assertDirectory(path, label) {
160
+ let stats;
161
+ try {
162
+ stats = lstatSync(path);
163
+ }
164
+ catch (err) {
165
+ throw new Error(`${label} cannot be inspected: ${path}`, { cause: err });
166
+ }
167
+ if (stats.isSymbolicLink() || !stats.isDirectory()) {
168
+ throw new Error(`${label} must be a regular non-symlink directory: ${path}`);
169
+ }
170
+ }
171
+ function exists(path) {
172
+ try {
173
+ lstatSync(path);
174
+ return true;
175
+ }
176
+ catch (err) {
177
+ if (err.code === "ENOENT")
178
+ return false;
179
+ throw err;
180
+ }
181
+ }
182
+ //# sourceMappingURL=projection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection.js","sourceRoot":"","sources":["../../src/office/projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,mB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AC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,yBAAyB,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,wCAAwC,IAAI,EAAE,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,IAAY,EAAE,KAAa;IAClD,IAAI,KAAK,CAAC;IACV,IAAI,CAAC;QACH,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,yBAAyB,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,6CAA6C,IAAI,EAAE,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,IAAY;IAC1B,IAAI,CAAC;QACH,SAAS,CAAC,IAAI,CAAC,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QACnE,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC","sourcesContent":["import { dirname, join } from \"node:path\";\nimport { lstatSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { atomicWritePrivateFile, ensureDirExists } from \"../file-guards.js\";\nimport { loadOfficeVisibilityOverride } from \"../settings/index.js\";\nimport { listRegisteredOffices, type Office } from \"./index.js\";\nimport * as log from \"../log.js\";\nimport type { ContainerMount, WorkspaceVisibility } from \"../types.js\";\nimport type { PlatformChannelKind, WorkspaceProjection } from \"./types.js\";\n\nexport type { PlatformChannelKind, WorkspaceProjection } from \"./types.js\";\n\nconst CHANNEL_KIND_FILE = \"channel-kind\";\nconst CHANNEL_KINDS: readonly PlatformChannelKind[] = [\n \"public_channel\",\n \"private_channel\",\n \"im\",\n \"external\",\n];\n\n/**\n * Record the platform's own channel kind for this conversation, as observed\n * by the adapter at message intake. Stored under the host-only office state\n * dir (never the sandbox-mounted workspace), so sandboxed code cannot\n * promote its own conversation into the shared pool. Written only on change;\n * the value is a snapshot as of the last message, which is exactly the\n * freshness the projection needs — a conversation that never speaks again\n * never needs a fresher value.\n */\nexport function recordPlatformChannelKind(office: Office, kind: PlatformChannelKind): void {\n if (readPlatformChannelKind(office) === kind) return;\n ensureDirExists(office.stateDir);\n atomicWritePrivateFile(join(office.stateDir, CHANNEL_KIND_FILE), kind + \"\\n\");\n}\n\n/** The recorded platform channel kind, or undefined when never observed. */\nexport function readPlatformChannelKind(office: Office): PlatformChannelKind | undefined {\n const path = join(office.stateDir, CHANNEL_KIND_FILE);\n let raw: string;\n try {\n raw = readFileSync(path, \"utf-8\");\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n log.logWarning(\n \"Could not read platform channel kind; treating the office as private\",\n `${path}: ${err instanceof Error ? err.message : String(err)}`,\n );\n return undefined;\n }\n const value = raw.trim();\n return (CHANNEL_KINDS as readonly string[]).includes(value)\n ? (value as PlatformChannelKind)\n : undefined;\n}\n\n/** Where an office's visibility came from; shown to operators instead of raw values. */\nexport interface OfficeVisibilityDecision {\n visibility: WorkspaceVisibility;\n source: \"platform\" | \"override\" | \"unknown\";\n}\n\n/** Platforms whose public conversations become public offices (ADR 0008). */\nconst PUBLIC_CAPABLE_PLATFORMS: ReadonlySet<string> = new Set([\"slack\"]);\n\n/**\n * One dimension, derived from the platform (ADR 0008): Slack public channels\n * are public; private channels, DMs, group DMs, and externally shared\n * conversations are private; a Slack conversation whose kind has not been\n * recorded yet fails closed to private. Every other platform is private by\n * decision, not by omission — Telegram groups, Discord channels, and GitHub\n * threads have no \"visible to the whole workspace\" notion that maps cleanly\n * onto a shared office. An operator may narrow a public conversation to\n * private, never the reverse.\n */\nexport function resolveOfficeVisibility(office: Office): OfficeVisibilityDecision {\n if (loadOfficeVisibilityOverride(office) === \"private\") {\n return { visibility: \"private\", source: \"override\" };\n }\n if (!PUBLIC_CAPABLE_PLATFORMS.has(office.address.platform)) {\n return { visibility: \"private\", source: \"platform\" };\n }\n const kind = readPlatformChannelKind(office);\n if (kind === undefined) return { visibility: \"private\", source: \"unknown\" };\n return { visibility: kind === \"public_channel\" ? \"public\" : \"private\", source: \"platform\" };\n}\n\n/**\n * Every public office other than `self`, as read-only mounts under\n * `/workspace/public/<key>`. Bind mounts rather than a symlink directory:\n * symlinks would resolve against the container's own filesystem, where host\n * paths do not exist. A public channel appearing or changing visibility\n * changes the mount signature, so affected containers rebuild on their next\n * message with contents preserved.\n */\nfunction publicOfficeMounts(self: Office): ContainerMount[] {\n const { workspace } = self;\n const mounts: ContainerMount[] = [];\n for (const record of listRegisteredOffices(workspace.stateDir)) {\n const other = workspace.office(record);\n if (other.key === self.key || !exists(other.dir)) continue;\n if (resolveOfficeVisibility(other).visibility !== \"public\") continue;\n mounts.push({ source: other.dir, target: `/workspace/public/${other.key}`, readOnly: true });\n }\n return mounts.toSorted((a, b) => a.target.localeCompare(b.target));\n}\n\n/**\n * The single policy seam for a managed office. It both materializes the\n * host-side roots and authorizes the prompt sources that describe them.\n * Every office gets the same shape (ADR 0008): its own directory read-write,\n * every other public office read-only under /workspace/public, and the\n * workspace-global knowledge read-write for public offices or read-only for\n * private ones. No layout mounts the workspace root.\n */\nexport function resolveWorkspaceProjection(office: Office): WorkspaceProjection {\n const { workspace } = office;\n const decision = resolveOfficeVisibility(office);\n const readOnlyKnowledge = decision.visibility === \"private\";\n\n assertDirectory(workspace.root, \"Host workspace root\");\n office.ensure();\n ensureRegularFile(workspace.memoryPath, \"Workspace memory\");\n ensureDirectoryRoot(workspace.skillsDir, \"Workspace skills\");\n const ro = { readOnly: true as const };\n return {\n ...decision,\n mounts: [\n { source: office.dir, target: `/workspace/${office.key}` },\n {\n source: workspace.memoryPath,\n target: \"/workspace/MEMORY.md\",\n ...(readOnlyKnowledge ? ro : {}),\n },\n {\n source: workspace.skillsDir,\n target: \"/workspace/skills\",\n ...(readOnlyKnowledge ? ro : {}),\n },\n ...publicOfficeMounts(office),\n ],\n promptSources: {\n conversationDir: office.dir,\n conversationMemoryPath: office.memoryPath,\n conversationSkillsDir: office.skillsDir,\n globalMemoryPath: workspace.memoryPath,\n globalSkillsDir: workspace.skillsDir,\n ...(readOnlyKnowledge ? { globalKnowledgeReadOnly: true } : {}),\n },\n };\n}\n\nfunction ensureDirectoryRoot(path: string, label: string): void {\n if (!exists(path)) {\n mkdirSync(path, { recursive: true, mode: 0o700 });\n return;\n }\n assertDirectory(path, label);\n}\n\nfunction ensureRegularFile(path: string, label: string): void {\n if (!exists(path)) {\n ensureDirExists(dirname(path));\n writeFileSync(path, \"\", { mode: 0o600, flag: \"wx\" });\n return;\n }\n let stats;\n try {\n stats = lstatSync(path);\n } catch (err) {\n throw new Error(`${label} cannot be inspected: ${path}`, { cause: err });\n }\n if (stats.isSymbolicLink() || !stats.isFile()) {\n throw new Error(`${label} must be a regular non-symlink file: ${path}`);\n }\n}\n\nfunction assertDirectory(path: string, label: string): void {\n let stats;\n try {\n stats = lstatSync(path);\n } catch (err) {\n throw new Error(`${label} cannot be inspected: ${path}`, { cause: err });\n }\n if (stats.isSymbolicLink() || !stats.isDirectory()) {\n throw new Error(`${label} must be a regular non-symlink directory: ${path}`);\n }\n}\n\nfunction exists(path: string): boolean {\n try {\n lstatSync(path);\n return true;\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ENOENT\") return false;\n throw err;\n }\n}\n"]}
@@ -0,0 +1,116 @@
1
+ import type { ContainerMount, OfficeAddress, OfficeKey, WorkspaceVisibility } 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
+ }
20
+ /**
21
+ * One mikan deployment's agent world on the host: the workspace root, the
22
+ * workspace-global surfaces, and the factory for per-conversation offices.
23
+ * Constructed once per process (`createWorkspace`); everything downstream
24
+ * receives the value instead of re-deriving paths from root strings.
25
+ */
26
+ export interface Workspace {
27
+ /** Host workspace root directory. */
28
+ readonly root: string;
29
+ /**
30
+ * Host-only state root (settings, credentials, and office records).
31
+ * Not part of the Workspace projection; carried here so offices can
32
+ * derive their state dirs and the registry knows where its journal lives.
33
+ */
34
+ readonly stateDir: string;
35
+ /** Workspace-global memory file: `<root>/MEMORY.md`. */
36
+ readonly memoryPath: string;
37
+ /** Workspace-global skills directory: `<root>/skills`. */
38
+ readonly skillsDir: string;
39
+ /** Subagent profile patches: `<root>/agents`. */
40
+ readonly agentsDir: string;
41
+ /** Workspace-root entries that are shared infrastructure, never office dirs. */
42
+ readonly reservedNames: ReadonlySet<string>;
43
+ /**
44
+ * The Conversation office for an address. Values are memoized per address,
45
+ * so repeated calls on hot paths cost one map lookup, not a hash.
46
+ */
47
+ office(address: OfficeAddress): Office;
48
+ }
49
+ /**
50
+ * One Conversation office: canonical identity plus the office's host-side
51
+ * directory layout. A frozen value — every field is precomputed at
52
+ * construction. Fields exist only for paths that more than one module needs;
53
+ * single-consumer subpaths stay `join(office.dir, …)` at their call site.
54
+ */
55
+ export interface Office {
56
+ /** Canonical identity: platform plus raw platform conversation id. */
57
+ readonly address: OfficeAddress;
58
+ /**
59
+ * The office key — the collision-resistant directory segment, identical on
60
+ * the host and inside sandbox runtimes, and the conversation vault key.
61
+ */
62
+ readonly key: OfficeKey;
63
+ /** The office working directory: `<workspace root>/<key>`. */
64
+ readonly dir: string;
65
+ /** Conversation memory file: `<dir>/MEMORY.md`. */
66
+ readonly memoryPath: string;
67
+ /** Conversation skills directory: `<dir>/skills`. */
68
+ readonly skillsDir: string;
69
+ /** Persisted chat-session files: `<dir>/sessions`. */
70
+ readonly sessionsDir: string;
71
+ /** Downloaded message attachments: `<dir>/attachments`. */
72
+ readonly attachmentsDir: string;
73
+ /** Human-readable message history: `<dir>/log.jsonl`. */
74
+ readonly logPath: string;
75
+ /** Host-only per-office state: `<state dir>/conversations/<key>`. */
76
+ readonly stateDir: string;
77
+ /** The workspace this office belongs to. */
78
+ readonly workspace: Workspace;
79
+ /**
80
+ * Materialize the office working directory: record the office in the
81
+ * registry, then create the directory. Idempotent and safe on hot
82
+ * per-message paths — recording is cached, the mkdir is a guarded check.
83
+ * Returns `dir`.
84
+ */
85
+ ensure(): string;
86
+ }
87
+ /**
88
+ * The conversation's platform-native channel kind, using the platform's own
89
+ * vocabulary (Slack conversation types), not a mikan-invented one. Recorded
90
+ * at message intake and used to derive the workspace projection when no
91
+ * explicit workspace setting exists: public channels share workspace memory
92
+ * read-write, private channels read it without writing back, DMs and
93
+ * externally shared channels stay isolated.
94
+ */
95
+ export type PlatformChannelKind = "public_channel" | "private_channel" | "im" | "external";
96
+ interface WorkspacePromptSources {
97
+ conversationDir: string;
98
+ conversationMemoryPath: string;
99
+ conversationSkillsDir: string;
100
+ globalMemoryPath: string;
101
+ globalSkillsDir: string;
102
+ /** True for private offices: global MEMORY.md and skills are mounted read-only. */
103
+ globalKnowledgeReadOnly?: boolean;
104
+ }
105
+ export interface WorkspaceProjection {
106
+ visibility: WorkspaceVisibility;
107
+ /**
108
+ * Where the visibility came from, for operator display. `unknown` only
109
+ * occurs for a Slack conversation whose kind has not been recorded yet.
110
+ */
111
+ source: "platform" | "override" | "unknown";
112
+ mounts: ContainerMount[];
113
+ promptSources: WorkspacePromptSources;
114
+ }
115
+ export {};
116
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/office/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEjG,MAAM,WAAW,yBAAyB;IACxC,yEAAyE;IACzE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,uEAAuE;IACvE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,wEAAwE;IACxE,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,iEAAiE;IACjE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,yEAAyE;IACzE,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,gFAAgF;IAChF,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,kDAAkD;IAClD,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,gFAAgF;IAChF,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;;;;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,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EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,mBAAmB,CAAC;IAChC;;;OAGG;IACH,MAAM,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;IAC5C,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,aAAa,EAAE,sBAAsB,CAAC;CACvC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/office/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContainerMount, OfficeAddress, OfficeKey, WorkspaceVisibility } 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, and office records).\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 /** 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\n/**\n * The conversation's platform-native channel kind, using the platform's own\n * vocabulary (Slack conversation types), not a mikan-invented one. Recorded\n * at message intake and used to derive the workspace projection when no\n * explicit workspace setting exists: public channels share workspace memory\n * read-write, private channels read it without writing back, DMs and\n * externally shared channels stay isolated.\n */\nexport type PlatformChannelKind = \"public_channel\" | \"private_channel\" | \"im\" | \"external\";\n\ninterface WorkspacePromptSources {\n conversationDir: string;\n conversationMemoryPath: string;\n conversationSkillsDir: string;\n globalMemoryPath: string;\n globalSkillsDir: string;\n /** True for private offices: global MEMORY.md and skills are mounted read-only. */\n globalKnowledgeReadOnly?: boolean;\n}\n\nexport interface WorkspaceProjection {\n visibility: WorkspaceVisibility;\n /**\n * Where the visibility came from, for operator display. `unknown` only\n * occurs for a Slack conversation whose kind has not been recorded yet.\n */\n source: \"platform\" | \"override\" | \"unknown\";\n mounts: ContainerMount[];\n promptSources: WorkspacePromptSources;\n}\n"]}
@@ -1,4 +1,4 @@
1
- export type { CreateSessionSandboxOptions, RunSessionOptions, ConversationRuntime, ConversationRuntimeOptions, } from "./types.js";
1
+ export type { RunSessionOptions, ConversationRuntime, ConversationRuntimeOptions, } from "./types.js";
2
2
  import type { ConversationRuntime, ConversationRuntimeOptions } from "./types.js";
3
3
  export declare function createConversationRuntime(options: ConversationRuntimeOptions): ConversationRuntime;
4
4
  //# sourceMappingURL=conversation-runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"conversation-runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/conversation-runtime.ts"],"names":[],"mappings":"AAuBA,YAAY,EACV,2BAA2B,EAC3B,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAGV,mBAAmB,EACnB,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAiBpB,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,0BAA0B,GAClC,mBAAmB,CAErB"}
1
+ {"version":3,"file":"conversation-runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/conversation-runtime.ts"],"names":[],"mappings":"AAyDA,YAAY,EACV,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAEV,mBAAmB,EACnB,0BAA0B,EAE3B,MAAM,YAAY,CAAC;AAsDpB,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,0BAA0B,GAClC,mBAAmB,CAErB"}