@geminixiang/mikan 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/CHANGELOG.md +324 -0
  2. package/LICENSE +22 -0
  3. package/README.md +297 -0
  4. package/dist/adapter.d.ts +134 -0
  5. package/dist/adapter.d.ts.map +1 -0
  6. package/dist/adapter.js +2 -0
  7. package/dist/adapter.js.map +1 -0
  8. package/dist/adapters/discord/bot.d.ts +63 -0
  9. package/dist/adapters/discord/bot.d.ts.map +1 -0
  10. package/dist/adapters/discord/bot.js +577 -0
  11. package/dist/adapters/discord/bot.js.map +1 -0
  12. package/dist/adapters/discord/context.d.ts +9 -0
  13. package/dist/adapters/discord/context.d.ts.map +1 -0
  14. package/dist/adapters/discord/context.js +245 -0
  15. package/dist/adapters/discord/context.js.map +1 -0
  16. package/dist/adapters/discord/index.d.ts +3 -0
  17. package/dist/adapters/discord/index.d.ts.map +1 -0
  18. package/dist/adapters/discord/index.js +3 -0
  19. package/dist/adapters/discord/index.js.map +1 -0
  20. package/dist/adapters/shared.d.ts +91 -0
  21. package/dist/adapters/shared.d.ts.map +1 -0
  22. package/dist/adapters/shared.js +191 -0
  23. package/dist/adapters/shared.js.map +1 -0
  24. package/dist/adapters/slack/bot.d.ts +139 -0
  25. package/dist/adapters/slack/bot.d.ts.map +1 -0
  26. package/dist/adapters/slack/bot.js +1272 -0
  27. package/dist/adapters/slack/bot.js.map +1 -0
  28. package/dist/adapters/slack/branch-manager.d.ts +28 -0
  29. package/dist/adapters/slack/branch-manager.d.ts.map +1 -0
  30. package/dist/adapters/slack/branch-manager.js +117 -0
  31. package/dist/adapters/slack/branch-manager.js.map +1 -0
  32. package/dist/adapters/slack/context.d.ts +12 -0
  33. package/dist/adapters/slack/context.d.ts.map +1 -0
  34. package/dist/adapters/slack/context.js +327 -0
  35. package/dist/adapters/slack/context.js.map +1 -0
  36. package/dist/adapters/slack/index.d.ts +3 -0
  37. package/dist/adapters/slack/index.d.ts.map +1 -0
  38. package/dist/adapters/slack/index.js +3 -0
  39. package/dist/adapters/slack/index.js.map +1 -0
  40. package/dist/adapters/slack/session.d.ts +38 -0
  41. package/dist/adapters/slack/session.d.ts.map +1 -0
  42. package/dist/adapters/slack/session.js +66 -0
  43. package/dist/adapters/slack/session.js.map +1 -0
  44. package/dist/adapters/slack/tools/attach.d.ts +12 -0
  45. package/dist/adapters/slack/tools/attach.d.ts.map +1 -0
  46. package/dist/adapters/slack/tools/attach.js +40 -0
  47. package/dist/adapters/slack/tools/attach.js.map +1 -0
  48. package/dist/adapters/telegram/bot.d.ts +51 -0
  49. package/dist/adapters/telegram/bot.d.ts.map +1 -0
  50. package/dist/adapters/telegram/bot.js +430 -0
  51. package/dist/adapters/telegram/bot.js.map +1 -0
  52. package/dist/adapters/telegram/context.d.ts +9 -0
  53. package/dist/adapters/telegram/context.d.ts.map +1 -0
  54. package/dist/adapters/telegram/context.js +190 -0
  55. package/dist/adapters/telegram/context.js.map +1 -0
  56. package/dist/adapters/telegram/html.d.ts +3 -0
  57. package/dist/adapters/telegram/html.d.ts.map +1 -0
  58. package/dist/adapters/telegram/html.js +98 -0
  59. package/dist/adapters/telegram/html.js.map +1 -0
  60. package/dist/adapters/telegram/index.d.ts +3 -0
  61. package/dist/adapters/telegram/index.d.ts.map +1 -0
  62. package/dist/adapters/telegram/index.js +3 -0
  63. package/dist/adapters/telegram/index.js.map +1 -0
  64. package/dist/agent.d.ts +36 -0
  65. package/dist/agent.d.ts.map +1 -0
  66. package/dist/agent.js +1147 -0
  67. package/dist/agent.js.map +1 -0
  68. package/dist/commands/auto-reply.d.ts +5 -0
  69. package/dist/commands/auto-reply.d.ts.map +1 -0
  70. package/dist/commands/auto-reply.js +79 -0
  71. package/dist/commands/auto-reply.js.map +1 -0
  72. package/dist/commands/index.d.ts +5 -0
  73. package/dist/commands/index.d.ts.map +1 -0
  74. package/dist/commands/index.js +18 -0
  75. package/dist/commands/index.js.map +1 -0
  76. package/dist/commands/login.d.ts +5 -0
  77. package/dist/commands/login.d.ts.map +1 -0
  78. package/dist/commands/login.js +91 -0
  79. package/dist/commands/login.js.map +1 -0
  80. package/dist/commands/model.d.ts +14 -0
  81. package/dist/commands/model.d.ts.map +1 -0
  82. package/dist/commands/model.js +110 -0
  83. package/dist/commands/model.js.map +1 -0
  84. package/dist/commands/new.d.ts +5 -0
  85. package/dist/commands/new.d.ts.map +1 -0
  86. package/dist/commands/new.js +24 -0
  87. package/dist/commands/new.js.map +1 -0
  88. package/dist/commands/parse.d.ts +7 -0
  89. package/dist/commands/parse.d.ts.map +1 -0
  90. package/dist/commands/parse.js +17 -0
  91. package/dist/commands/parse.js.map +1 -0
  92. package/dist/commands/registry.d.ts +4 -0
  93. package/dist/commands/registry.d.ts.map +1 -0
  94. package/dist/commands/registry.js +9 -0
  95. package/dist/commands/registry.js.map +1 -0
  96. package/dist/commands/sandbox.d.ts +10 -0
  97. package/dist/commands/sandbox.d.ts.map +1 -0
  98. package/dist/commands/sandbox.js +83 -0
  99. package/dist/commands/sandbox.js.map +1 -0
  100. package/dist/commands/session-view.d.ts +5 -0
  101. package/dist/commands/session-view.d.ts.map +1 -0
  102. package/dist/commands/session-view.js +62 -0
  103. package/dist/commands/session-view.js.map +1 -0
  104. package/dist/commands/types.d.ts +41 -0
  105. package/dist/commands/types.d.ts.map +1 -0
  106. package/dist/commands/types.js +2 -0
  107. package/dist/commands/types.js.map +1 -0
  108. package/dist/commands/utils.d.ts +8 -0
  109. package/dist/commands/utils.d.ts.map +1 -0
  110. package/dist/commands/utils.js +14 -0
  111. package/dist/commands/utils.js.map +1 -0
  112. package/dist/config.d.ts +59 -0
  113. package/dist/config.d.ts.map +1 -0
  114. package/dist/config.js +370 -0
  115. package/dist/config.js.map +1 -0
  116. package/dist/context.d.ts +17 -0
  117. package/dist/context.d.ts.map +1 -0
  118. package/dist/context.js +24 -0
  119. package/dist/context.js.map +1 -0
  120. package/dist/conversation-history.d.ts +16 -0
  121. package/dist/conversation-history.d.ts.map +1 -0
  122. package/dist/conversation-history.js +144 -0
  123. package/dist/conversation-history.js.map +1 -0
  124. package/dist/download.d.ts +2 -0
  125. package/dist/download.d.ts.map +1 -0
  126. package/dist/download.js +89 -0
  127. package/dist/download.js.map +1 -0
  128. package/dist/env.d.ts +3 -0
  129. package/dist/env.d.ts.map +1 -0
  130. package/dist/env.js +12 -0
  131. package/dist/env.js.map +1 -0
  132. package/dist/events.d.ts +85 -0
  133. package/dist/events.d.ts.map +1 -0
  134. package/dist/events.js +483 -0
  135. package/dist/events.js.map +1 -0
  136. package/dist/execution-resolver.d.ts +25 -0
  137. package/dist/execution-resolver.d.ts.map +1 -0
  138. package/dist/execution-resolver.js +167 -0
  139. package/dist/execution-resolver.js.map +1 -0
  140. package/dist/file-guards.d.ts +9 -0
  141. package/dist/file-guards.d.ts.map +1 -0
  142. package/dist/file-guards.js +56 -0
  143. package/dist/file-guards.js.map +1 -0
  144. package/dist/fs-atomic.d.ts +10 -0
  145. package/dist/fs-atomic.d.ts.map +1 -0
  146. package/dist/fs-atomic.js +45 -0
  147. package/dist/fs-atomic.js.map +1 -0
  148. package/dist/index.d.ts +10 -0
  149. package/dist/index.d.ts.map +1 -0
  150. package/dist/index.js +7 -0
  151. package/dist/index.js.map +1 -0
  152. package/dist/instrument.d.ts +2 -0
  153. package/dist/instrument.d.ts.map +1 -0
  154. package/dist/instrument.js +10 -0
  155. package/dist/instrument.js.map +1 -0
  156. package/dist/log.d.ts +36 -0
  157. package/dist/log.d.ts.map +1 -0
  158. package/dist/log.js +206 -0
  159. package/dist/log.js.map +1 -0
  160. package/dist/login/index.d.ts +42 -0
  161. package/dist/login/index.d.ts.map +1 -0
  162. package/dist/login/index.js +239 -0
  163. package/dist/login/index.js.map +1 -0
  164. package/dist/login/portal.d.ts +19 -0
  165. package/dist/login/portal.d.ts.map +1 -0
  166. package/dist/login/portal.js +1544 -0
  167. package/dist/login/portal.js.map +1 -0
  168. package/dist/login/session.d.ts +26 -0
  169. package/dist/login/session.d.ts.map +1 -0
  170. package/dist/login/session.js +56 -0
  171. package/dist/login/session.js.map +1 -0
  172. package/dist/main.d.ts +3 -0
  173. package/dist/main.d.ts.map +1 -0
  174. package/dist/main.js +366 -0
  175. package/dist/main.js.map +1 -0
  176. package/dist/provisioner.d.ts +83 -0
  177. package/dist/provisioner.d.ts.map +1 -0
  178. package/dist/provisioner.js +500 -0
  179. package/dist/provisioner.js.map +1 -0
  180. package/dist/runtime/conversation-orchestrator.d.ts +40 -0
  181. package/dist/runtime/conversation-orchestrator.d.ts.map +1 -0
  182. package/dist/runtime/conversation-orchestrator.js +183 -0
  183. package/dist/runtime/conversation-orchestrator.js.map +1 -0
  184. package/dist/runtime/index.d.ts +2 -0
  185. package/dist/runtime/index.d.ts.map +1 -0
  186. package/dist/runtime/index.js +2 -0
  187. package/dist/runtime/index.js.map +1 -0
  188. package/dist/runtime/session-runtime.d.ts +26 -0
  189. package/dist/runtime/session-runtime.d.ts.map +1 -0
  190. package/dist/runtime/session-runtime.js +221 -0
  191. package/dist/runtime/session-runtime.js.map +1 -0
  192. package/dist/sandbox/cloudflare.d.ts +15 -0
  193. package/dist/sandbox/cloudflare.d.ts.map +1 -0
  194. package/dist/sandbox/cloudflare.js +138 -0
  195. package/dist/sandbox/cloudflare.js.map +1 -0
  196. package/dist/sandbox/container.d.ts +16 -0
  197. package/dist/sandbox/container.d.ts.map +1 -0
  198. package/dist/sandbox/container.js +138 -0
  199. package/dist/sandbox/container.js.map +1 -0
  200. package/dist/sandbox/errors.d.ts +6 -0
  201. package/dist/sandbox/errors.d.ts.map +1 -0
  202. package/dist/sandbox/errors.js +11 -0
  203. package/dist/sandbox/errors.js.map +1 -0
  204. package/dist/sandbox/firecracker.d.ts +17 -0
  205. package/dist/sandbox/firecracker.d.ts.map +1 -0
  206. package/dist/sandbox/firecracker.js +212 -0
  207. package/dist/sandbox/firecracker.js.map +1 -0
  208. package/dist/sandbox/host.d.ts +11 -0
  209. package/dist/sandbox/host.d.ts.map +1 -0
  210. package/dist/sandbox/host.js +89 -0
  211. package/dist/sandbox/host.js.map +1 -0
  212. package/dist/sandbox/image.d.ts +5 -0
  213. package/dist/sandbox/image.d.ts.map +1 -0
  214. package/dist/sandbox/image.js +30 -0
  215. package/dist/sandbox/image.js.map +1 -0
  216. package/dist/sandbox/index.d.ts +22 -0
  217. package/dist/sandbox/index.d.ts.map +1 -0
  218. package/dist/sandbox/index.js +54 -0
  219. package/dist/sandbox/index.js.map +1 -0
  220. package/dist/sandbox/path-context.d.ts +4 -0
  221. package/dist/sandbox/path-context.d.ts.map +1 -0
  222. package/dist/sandbox/path-context.js +20 -0
  223. package/dist/sandbox/path-context.js.map +1 -0
  224. package/dist/sandbox/types.d.ts +67 -0
  225. package/dist/sandbox/types.d.ts.map +1 -0
  226. package/dist/sandbox/types.js +2 -0
  227. package/dist/sandbox/types.js.map +1 -0
  228. package/dist/sandbox/utils.d.ts +4 -0
  229. package/dist/sandbox/utils.d.ts.map +1 -0
  230. package/dist/sandbox/utils.js +51 -0
  231. package/dist/sandbox/utils.js.map +1 -0
  232. package/dist/sentry.d.ts +50 -0
  233. package/dist/sentry.d.ts.map +1 -0
  234. package/dist/sentry.js +257 -0
  235. package/dist/sentry.js.map +1 -0
  236. package/dist/session-view/command.d.ts +5 -0
  237. package/dist/session-view/command.d.ts.map +1 -0
  238. package/dist/session-view/command.js +7 -0
  239. package/dist/session-view/command.js.map +1 -0
  240. package/dist/session-view/portal.d.ts +16 -0
  241. package/dist/session-view/portal.d.ts.map +1 -0
  242. package/dist/session-view/portal.js +1822 -0
  243. package/dist/session-view/portal.js.map +1 -0
  244. package/dist/session-view/service.d.ts +34 -0
  245. package/dist/session-view/service.d.ts.map +1 -0
  246. package/dist/session-view/service.js +434 -0
  247. package/dist/session-view/service.js.map +1 -0
  248. package/dist/session-view/store.d.ts +18 -0
  249. package/dist/session-view/store.d.ts.map +1 -0
  250. package/dist/session-view/store.js +36 -0
  251. package/dist/session-view/store.js.map +1 -0
  252. package/dist/sessions/metadata.d.ts +15 -0
  253. package/dist/sessions/metadata.d.ts.map +1 -0
  254. package/dist/sessions/metadata.js +11 -0
  255. package/dist/sessions/metadata.js.map +1 -0
  256. package/dist/sessions/policy.d.ts +13 -0
  257. package/dist/sessions/policy.d.ts.map +1 -0
  258. package/dist/sessions/policy.js +23 -0
  259. package/dist/sessions/policy.js.map +1 -0
  260. package/dist/sessions/store.d.ts +103 -0
  261. package/dist/sessions/store.d.ts.map +1 -0
  262. package/dist/sessions/store.js +349 -0
  263. package/dist/sessions/store.js.map +1 -0
  264. package/dist/store.d.ts +58 -0
  265. package/dist/store.d.ts.map +1 -0
  266. package/dist/store.js +152 -0
  267. package/dist/store.js.map +1 -0
  268. package/dist/tool-diagnostics.d.ts +2 -0
  269. package/dist/tool-diagnostics.d.ts.map +1 -0
  270. package/dist/tool-diagnostics.js +7 -0
  271. package/dist/tool-diagnostics.js.map +1 -0
  272. package/dist/tools/bash.d.ts +10 -0
  273. package/dist/tools/bash.d.ts.map +1 -0
  274. package/dist/tools/bash.js +80 -0
  275. package/dist/tools/bash.js.map +1 -0
  276. package/dist/tools/edit.d.ts +11 -0
  277. package/dist/tools/edit.d.ts.map +1 -0
  278. package/dist/tools/edit.js +133 -0
  279. package/dist/tools/edit.js.map +1 -0
  280. package/dist/tools/event.d.ts +62 -0
  281. package/dist/tools/event.d.ts.map +1 -0
  282. package/dist/tools/event.js +138 -0
  283. package/dist/tools/event.js.map +1 -0
  284. package/dist/tools/index.d.ts +14 -0
  285. package/dist/tools/index.d.ts.map +1 -0
  286. package/dist/tools/index.js +23 -0
  287. package/dist/tools/index.js.map +1 -0
  288. package/dist/tools/read.d.ts +11 -0
  289. package/dist/tools/read.d.ts.map +1 -0
  290. package/dist/tools/read.js +136 -0
  291. package/dist/tools/read.js.map +1 -0
  292. package/dist/tools/truncate.d.ts +57 -0
  293. package/dist/tools/truncate.d.ts.map +1 -0
  294. package/dist/tools/truncate.js +184 -0
  295. package/dist/tools/truncate.js.map +1 -0
  296. package/dist/tools/write.d.ts +10 -0
  297. package/dist/tools/write.d.ts.map +1 -0
  298. package/dist/tools/write.js +33 -0
  299. package/dist/tools/write.js.map +1 -0
  300. package/dist/trigger.d.ts +31 -0
  301. package/dist/trigger.d.ts.map +1 -0
  302. package/dist/trigger.js +98 -0
  303. package/dist/trigger.js.map +1 -0
  304. package/dist/ui-copy.d.ts +12 -0
  305. package/dist/ui-copy.d.ts.map +1 -0
  306. package/dist/ui-copy.js +36 -0
  307. package/dist/ui-copy.js.map +1 -0
  308. package/dist/vault-routing.d.ts +4 -0
  309. package/dist/vault-routing.d.ts.map +1 -0
  310. package/dist/vault-routing.js +16 -0
  311. package/dist/vault-routing.js.map +1 -0
  312. package/dist/vault.d.ts +72 -0
  313. package/dist/vault.d.ts.map +1 -0
  314. package/dist/vault.js +281 -0
  315. package/dist/vault.js.map +1 -0
  316. package/package.json +83 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,324 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
7
+ once it leaves the 0.x line. While on `0.2.0-beta.*`, breaking changes may land in
8
+ any release.
9
+
10
+ ## [Unreleased]
11
+
12
+ ## [0.2.0] - 2026-05-23
13
+
14
+ ### Changed
15
+
16
+ - Renamed the project, CLI, npm package, GitHub repository, documentation, release skill, and sandbox image references to mikan.
17
+ - Changed platform credentials to unprefixed env vars (`SLACK_APP_TOKEN`, `SLACK_BOT_TOKEN`, `TELEGRAM_BOT_TOKEN`, `DISCORD_BOT_TOKEN`) while keeping `MIKAN_*` aliases as fallbacks.
18
+ - Changed runtime env vars such as `LINK_URL`, `LINK_PORT`, `STATE_DIR`, OAuth scope overrides, and Cloudflare sandbox settings to prefer unprefixed names with `MIKAN_*` fallbacks.
19
+ - Raised the minimum supported Node.js version to `>=22.19.0`.
20
+ - Updated internal variable, function, type, Docker label, sandbox image, and generated resource names to use mikan naming.
21
+ - Added manual dispatch support to the CI workflow.
22
+
23
+ ## [0.2.0-beta.25] - 2026-05-23
24
+
25
+ ### Changed
26
+
27
+ - Grouped session modules under a single directory.
28
+ - Centralized command parsing across adapters.
29
+ - Removed explicit `any` usage across the type surface.
30
+ - Cleaned unused dependencies.
31
+
32
+ ### Tests
33
+
34
+ - CI now enforces coverage thresholds.
35
+
36
+ ## [0.2.0-beta.24]
37
+
38
+ ### Fixed
39
+
40
+ - Session history writes now emit valid assistant messages.
41
+
42
+ ## [0.2.0-beta.23]
43
+
44
+ ### Fixed
45
+
46
+ - Refresh stale channel history before forking a thread.
47
+ - Separate history seeds from live sessions to prevent cross-contamination.
48
+ - Materialize channel history when the first thread is created.
49
+
50
+ ### Added
51
+
52
+ - Scripts to migrate session history and repair orphan thread sessions.
53
+
54
+ ## [0.2.0-beta.22]
55
+
56
+ ### Fixed
57
+
58
+ - Slack: fork bot response threads from the channel session so replies inherit context.
59
+ - Vault: preserve failures when the default shared vault cannot be applied.
60
+
61
+ ## [0.2.0-beta.21]
62
+
63
+ ### Added
64
+
65
+ - Vault: seed new sandboxes from a shared profile (`sandbox.defaultSharedVault`).
66
+
67
+ ## [0.2.0-beta.20]
68
+
69
+ ### Added
70
+
71
+ - Sentry: report user-facing failures.
72
+ - Auto-reply: surface configured rules in the status command.
73
+
74
+ ### Fixed
75
+
76
+ - Slack: anchor event-fork sessions correctly (#61).
77
+ - Slack: keep session ephemerals scoped to threads.
78
+ - Agent: require history search before answering unknown replies.
79
+ - Agent: keep quiet tool errors out of chat.
80
+
81
+ ### Changed
82
+
83
+ - Removed cloud-logging config — log to stdout/stderr and route via your process manager.
84
+
85
+ ## [0.2.0-beta.19]
86
+
87
+ ### Fixed
88
+
89
+ - Sandbox: bootstrap `gh` git credentials inside managed containers.
90
+
91
+ ## [0.2.0-beta.18]
92
+
93
+ ### Fixed
94
+
95
+ - Sandbox: update memory swap when applying CPU/memory limits.
96
+ - Slack: preserve long replies posted in threads.
97
+
98
+ ## [0.2.0-beta.17]
99
+
100
+ ### Added
101
+
102
+ - Sentry: store env values and write a `sentry-cli` config for richer error reports.
103
+
104
+ ### Changed
105
+
106
+ - Bumped `@earendil-works/pi-*` packages.
107
+
108
+ ## [0.2.0-beta.16]
109
+
110
+ ### Performance
111
+
112
+ - Slack: unblock startup while backfill is running.
113
+
114
+ ## [0.2.0-beta.15]
115
+
116
+ ### Added
117
+
118
+ - Config: validate JSON files with TypeBox schemas.
119
+ - Agent: attribute the trigger (mention/direct/auto-reply/…) in responses.
120
+
121
+ ## [0.2.0-beta.14]
122
+
123
+ ### Fixed
124
+
125
+ - Login: refresh the sandbox after copying a shared profile.
126
+
127
+ ### Changed
128
+
129
+ - Simplified command dispatch, token stores, and re-exports (#60).
130
+
131
+ ## [0.2.0-beta.13]
132
+
133
+ ### Added
134
+
135
+ - Login: gcloud OAuth support.
136
+
137
+ ## [0.2.0-beta.12]
138
+
139
+ ### Fixed
140
+
141
+ - Auto-reply: persist the resolved session key.
142
+
143
+ ## [0.2.0-beta.11]
144
+
145
+ ### Fixed
146
+
147
+ - Login: make Slack login ephemeral and refresh vault mounts after credentials change.
148
+
149
+ ### Changed
150
+
151
+ - Sandbox: update base image and tags.
152
+
153
+ ## [0.2.0-beta.10]
154
+
155
+ ### Added
156
+
157
+ - Auto-reply: channel trigger rules and a configurable judge model (`llm.autoReply`).
158
+ - Slack: native E2E smoke workflow under `e2e/`.
159
+
160
+ ### Fixed
161
+
162
+ - Auto-reply: use mom-compatible marker files; judge policy never throws and always logs.
163
+ - Events: validate one-shot times before scheduling; simplify fresh follow-up sessions.
164
+
165
+ ### Changed
166
+
167
+ - Onboard: default model is `claude-sonnet-4-6`.
168
+ - Separated runtime and control-plane paths.
169
+
170
+ ## [0.2.0-beta.9]
171
+
172
+ ### Added
173
+
174
+ - Session view: floating composer and per-message copy button.
175
+ - Docker sandbox: add `rg` and `fd` to the image.
176
+
177
+ ### Fixed
178
+
179
+ - Session view: ignore Enter during IME composition; preserve code-block contrast.
180
+
181
+ ## [0.2.0-beta.8]
182
+
183
+ ### Added
184
+
185
+ - Login: shared vault profiles.
186
+ - Session view: improved interactive chat console.
187
+ - Slack: harden socket connection and label the platform in the connect log.
188
+ - Agent: `ThinkingLevel` type on session parameters.
189
+
190
+ ### Changed
191
+
192
+ - Sandbox: store the image workspace mount in settings.
193
+ - Dropped `vault.json` metadata — directories are the only source of truth.
194
+ - Refactored agent runner orchestration into smaller modules.
195
+
196
+ ### Removed
197
+
198
+ - `UserBindingStore` and `bindings.json` plumbing.
199
+ - Log-to-session backfill.
200
+
201
+ ## [0.2.0-beta.7]
202
+
203
+ ### Added
204
+
205
+ - Sandbox: temporary `boost` command for one-off CPU/memory bumps.
206
+ - Slack: mute command summaries.
207
+
208
+ ### Changed
209
+
210
+ - Migrated `pi-*` packages to the `@earendil-works/` namespace.
211
+
212
+ ### Fixed
213
+
214
+ - Slack: log messages from external apps; hide bash tool diagnostics.
215
+ - Session: ignore history written before a reset.
216
+ - Agent: clarify runtime workspace paths in the system prompt.
217
+
218
+ ## [0.2.0-beta.6]
219
+
220
+ ### Added
221
+
222
+ - Commands: conversation model switch (`/pi-model …`) with `:thinking` shorthand.
223
+ - Config: onboarding flow for global settings (`mikan --onboard`).
224
+ - Docs: PM2 ecosystem config and production deploy guide.
225
+
226
+ ### Changed
227
+
228
+ - Config: nest settings schema; align chat platform commands.
229
+
230
+ ### Fixed
231
+
232
+ - Slack: strip only the bot's own mention from message text.
233
+
234
+ ## [0.2.0-beta.5]
235
+
236
+ ### Added
237
+
238
+ - Sandbox: Cloudflare sandbox bridge (experimental).
239
+ - Tests: unit coverage for `CommandRegistry` and command handlers.
240
+
241
+ ### Changed
242
+
243
+ - Env: renamed `MOM_*` env vars to `MIKAN_*` (breaking).
244
+ - Vault: conversation vault directories are now the source of truth; dropped platform prefix from the conversation vault key.
245
+ - Config: `--state-dir` is the single source for settings.
246
+ - Tightened command/runtime types and added a `postPrivate` capability.
247
+
248
+ ## [0.2.0-beta.4]
249
+
250
+ ### Changed
251
+
252
+ - Hardened core writes; unified adapter retry and log helpers.
253
+ - Eliminated duplication across adapters, vault, and Slack command factories (#53).
254
+ - Session forks now anchor to raw split points.
255
+ - Adapter-specific stop logic stays in adapters.
256
+
257
+ ### Fixed
258
+
259
+ - Slack: tighten thread reply triggers.
260
+
261
+ ## [0.2.0-beta.3]
262
+
263
+ ### Added
264
+
265
+ - Session view: Slack-aware session viewer with branching (#51).
266
+ - Login: built-in credential presets and a redesigned credential portal.
267
+ - Sandbox: image-mode container CPU/memory limits (#50), bridge network isolation, `ffmpeg` in the tools image.
268
+
269
+ ### Fixed
270
+
271
+ - Discord: normalize thread sessions; queue follow-up messages; persistent channel sessions; hide usage summary by default.
272
+ - Events: restore Slack synthetic notifications (#52).
273
+ - Attachments: wait for downloads before the agent accesses them.
274
+
275
+ ## [0.2.0-beta.2]
276
+
277
+ ### Added
278
+
279
+ - Per-user vault system for actor-scoped credential isolation (#24).
280
+ - Managed image sandbox (`--sandbox=image:<image>`) (#47).
281
+ - Login flow wired into the runtime; credential onboarding server (#32, #34).
282
+ - Slack: `/pi-new` and `/pi-login` DM commands.
283
+ - Events: actor-aware scheduling tool (#36, #39).
284
+
285
+ ### Changed
286
+
287
+ - Internal contracts unified around "conversation" naming across adapter, store, config, log, and UI layers (#38, #41, #42, #43, #44, #46).
288
+
289
+ ### Fixed
290
+
291
+ - Telegram: handle bare `stop` in shared chats; escape unsupported HTML entities.
292
+ - Slack: queue follow-up messages per session.
293
+
294
+ ## [0.2.0-beta.1]
295
+
296
+ ### Added
297
+
298
+ - File-backed credential vault (#31) and per-user vault routing (#33).
299
+ - OAuth: GitHub redirect flow, scope parity with `gh` CLI, gcloud OAuth.
300
+ - Sandbox: separate `stateDir` from `workspaceDir` to keep secrets out of sandboxes.
301
+
302
+ ### Security
303
+
304
+ - Hardened vault writes, file permissions, and login flow.
305
+ - Stopped leaking secrets in `docker exec` args.
306
+ - Enforced vault sandbox isolation policy.
307
+
308
+ ### Changed
309
+
310
+ - Renamed `docker` sandbox mode to `container` (breaking).
311
+ - Replaced `DockerProvisioner` with `DockerContainerManager` + idle stop.
312
+
313
+ ## [0.2.0-beta.0]
314
+
315
+ ### Added
316
+
317
+ - Sentry integration for error monitoring, tracing, and metrics (#21).
318
+ - Persistent session management with in-thread replies (#18).
319
+ - Telegram: native slash commands; private-chat session fix (#15).
320
+ - `pi-coding-agent` extension loading (#12).
321
+
322
+ ## Earlier releases
323
+
324
+ For releases prior to `0.2.0-beta.0` (i.e. the `0.1.x` line), see the [git tag history](https://github.com/geminixiang/mikan/tags).
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Original work Copyright (c) 2024 Mario Zechner
4
+ Modified work Copyright (c) 2025 geminixiang
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,297 @@
1
+ # mikan
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@geminixiang/mikan.svg)](https://www.npmjs.com/package/@geminixiang/mikan)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ A multi-platform AI coding agent for Slack, Telegram, and Discord.
7
+
8
+ ## Features
9
+
10
+ - **Multi-platform** — Slack, Telegram, Discord adapters
11
+ - **Concurrent conversations** — Slack threads, Discord replies/threads, and Telegram reply chains run as independent sessions
12
+ - **Sandbox execution** — host, shared container, per-user managed container, Firecracker (alpha), or Cloudflare bridge (experimental)
13
+ - **Credential vaults** — `/login` stores credentials under `--state-dir` and injects env into sandbox runs
14
+ - **Web session viewer** — read-only web view of the current session via `session` / `/session`
15
+ - **Persistent memory** — workspace-level and channel-level `MEMORY.md`
16
+ - **Skills** — drop CLI tools into `skills/`
17
+ - **Events** — schedule one-shot or recurring tasks via JSON files
18
+ - **Multi-provider** — any provider/model supported by `pi-ai`
19
+
20
+ ## Platform Session Model
21
+
22
+ | Platform | `sessionKey` Rule | Notes |
23
+ | -------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
24
+ | Slack | top-level / DM: `conversationId`; thread: `conversationId:threadTs` | thread inherits parent context at fork time only; branch changes do not merge back |
25
+ | Discord | DM: `channelId`; shared top-level: `channelId:messageId`; reply/thread: rooted id | replies in shared channels continue the root message session; DM replies do not fork |
26
+ | Telegram | private: `chatId`; shared top-level: `chatId:messageId`; reply chain: root reply | no native thread model; shared sessions are inferred from reply chains |
27
+
28
+ ## Requirements
29
+
30
+ - Node.js >= 22.19.0
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ npm install -g @geminixiang/mikan
36
+ ```
37
+
38
+ Or from source:
39
+
40
+ ```bash
41
+ npm install && npm run build
42
+ ```
43
+
44
+ ## Quick Start
45
+
46
+ All platforms share the same CLI:
47
+
48
+ ```bash
49
+ mikan [--state-dir=~/.mikan] [--sandbox=<mode>] <working-directory>
50
+ ```
51
+
52
+ Set the platform tokens you need (you can run multiple platforms at once):
53
+
54
+ ```bash
55
+ export SLACK_APP_TOKEN=xapp-...
56
+ export SLACK_BOT_TOKEN=xoxb-...
57
+ export TELEGRAM_BOT_TOKEN=123456:ABC-...
58
+ export DISCORD_BOT_TOKEN=MTI...
59
+ ```
60
+
61
+ ### Slack
62
+
63
+ Create a Socket Mode app with the scopes and event subscriptions listed in [docs/slack-bot-minimal-guide.md](docs/slack-bot-minimal-guide.md). The bot responds when `@mentioned` in channels and to all DMs.
64
+
65
+ ### Telegram
66
+
67
+ Create a bot via [@BotFather](https://t.me/BotFather) and copy the token. The bot responds to all private messages, and to `@mention` or reply chains in groups. Use `/login`, `/session`, `/new`, and `/stop` for controls.
68
+
69
+ ### Discord
70
+
71
+ Create an application in the [Discord Developer Portal](https://discord.com/developers/applications), enable **Message Content Intent**, and invite the bot with `Send Messages`, `Read Message History`, `Attach Files`. The bot responds to `@mentions` in servers and to all DMs.
72
+
73
+ ## Sandbox Modes
74
+
75
+ | Mode | Description |
76
+ | ---------------------------- | ---------------------------------------------------------------------- |
77
+ | `host` (default) | Run on host; no vault env injection |
78
+ | `container:<name>` | Run in an existing shared container; uses vault key `container-<name>` |
79
+ | `image:<image>` | Auto-provision one Docker container per resolved vault/user |
80
+ | `firecracker:<vm-id>:<path>` | Firecracker microVM (alpha; not recommended) |
81
+ | `cloudflare:<sandbox-id>` | Cloudflare Worker bridge (experimental; no auto workspace sync) |
82
+
83
+ Vault routing: `image`, `firecracker`, and `cloudflare` resolve a vault per platform userId. See [docs/sandbox.md](docs/sandbox.md) for the full matrix.
84
+
85
+ ### Managed per-user containers (`image:*`)
86
+
87
+ ```bash
88
+ docker pull ghcr.io/geminixiang/mikan-sandbox:latest
89
+ mikan --sandbox=image:ghcr.io/geminixiang/mikan-sandbox:latest /path/to/workspace
90
+ ```
91
+
92
+ Or build locally:
93
+
94
+ ```bash
95
+ docker build -f docker/mikan-sandbox.Dockerfile -t mikan-sandbox:tools .
96
+ ```
97
+
98
+ mikan creates one container per vault, attaches each to its own bridge network, mounts the workspace at `/workspace`, injects vault env, mounts declared credential files, and stops idle containers.
99
+
100
+ ### Firecracker / Cloudflare
101
+
102
+ See [docs/firecracker-setup.md](docs/firecracker-setup.md) and [examples/cloudflare-sandbox-bridge/README.md](examples/cloudflare-sandbox-bridge/README.md).
103
+
104
+ ## `/login` and Web Session Viewer
105
+
106
+ ```bash
107
+ export LINK_URL="https://mikan.example.com" # public base URL
108
+ export LINK_PORT=8181 # optional, defaults to 8181
109
+ ```
110
+
111
+ For local testing you can set just `LINK_PORT`; mikan will use `http://localhost:<port>`.
112
+
113
+ Every environment variable also supports a `MIKAN_` prefix for deployment-specific namespacing. For example, `MIKAN_SLACK_APP_TOKEN` and `MIKAN_LINK_URL` are accepted fallbacks. Unprefixed variables take precedence.
114
+
115
+ - `/login` / `/pi-login` (DM only) returns a 15-minute link to store API keys or run built-in OAuth flows ([GitHub](docs/oauth/github.md), [Google Workspace](docs/oauth/google-workspace.md), [Google Cloud SDK / gcloud](docs/oauth/google-cloud-sdk.md)).
116
+ - `session` / `/session` (DM only) returns a read-only link showing the current session timeline.
117
+ - `new` / `/new` (DM only) resets the current session and starts fresh.
118
+ - `model` / `/model` / `/pi-model provider/model[:thinking]` switches the LLM for the current conversation, e.g. `/pi-model anthropic/claude-sonnet-4-6:off`.
119
+ - `auto-reply` / `/pi-auto-reply on|off|status` controls group/channel auto-reply for the current conversation. Rules live in the conversation's `auto-reply` marker file.
120
+ - `stop` / `/stop` stops the current run. On Slack, use text commands so thread-local stop routing remains accurate.
121
+ - On Slack you can also register native commands like `/pi-login`, `/pi-session`, `/pi-model`, `/pi-auto-reply`, and `/pi-new`.
122
+
123
+ Credentials are stored under `<state-dir>/vaults` (default `~/.mikan/vaults`). Vault env is only injected in `container`, `image`, `firecracker`, and `cloudflare` modes.
124
+
125
+ Shared login profiles live under `<state-dir>/vaults/shared/<name>`. `/pi-login copy <name>` merge-copies that shared profile into the current conversation vault: shared env keys overwrite matching conversation env keys, conversation-only env keys are kept, and files from the shared profile overwrite files at the same relative path. To seed every new managed sandbox vault from a shared profile, fill in `sandbox.defaultSharedVault` in `<state-dir>/settings.json` (onboard creates it as an empty string), for example `{ "sandbox": { "defaultSharedVault": "claw" } }`. Empty string disables the default. The default profile is copied only when the target vault does not exist yet.
126
+
127
+ ## Configuration
128
+
129
+ mikan reads global settings from `<state-dir>/settings.json` (default `~/.mikan/settings.json`, override via `--state-dir` or `STATE_DIR`). This file is required and is created explicitly with `mikan --onboard`. Per-conversation settings live at `<workingDir>/<conversationId>/settings.json` and override global settings for that conversation.
130
+
131
+ ```json
132
+ {
133
+ "llm": {
134
+ "provider": "anthropic",
135
+ "model": "claude-sonnet-4-6",
136
+ "thinkingLevel": "off"
137
+ },
138
+ "sentry": {
139
+ "dsn": "https://examplePublicKey@o0.ingest.sentry.io/0"
140
+ },
141
+ "sandbox": {
142
+ "cpus": "0.5",
143
+ "memory": "512m",
144
+ "boost": {
145
+ "cpus": "2",
146
+ "memory": "4g"
147
+ }
148
+ }
149
+ }
150
+ ```
151
+
152
+ | Field | Default | Description |
153
+ | ---------------------- | ------------------- | ----------------------------------------------------- |
154
+ | `llm.provider` | `anthropic` | AI provider |
155
+ | `llm.model` | `claude-sonnet-4-6` | Model name |
156
+ | `llm.thinkingLevel` | `off` | `off` / `low` / `medium` / `high` |
157
+ | `sentry.dsn` | unset | Sentry DSN; sensitive prompt/tool content is redacted |
158
+ | `sandbox.cpus` | unset | CPU limit for managed containers |
159
+ | `sandbox.memory` | unset | Memory limit for managed containers |
160
+ | `sandbox.boost.cpus` | unset | Temporary CPU limit used by `/pi-sandbox boost` |
161
+ | `sandbox.boost.memory` | unset | Temporary memory limit used by `/pi-sandbox boost` |
162
+
163
+ `/pi-sandbox` shows the current managed-container CPU/memory limits. `/pi-sandbox boost` temporarily applies `sandbox.boost` to the current conversation; the boost ends when that sandbox container is stopped.
164
+
165
+ Conversation-local settings written by `/pi-model` use the same shape and usually only include the override:
166
+
167
+ ```json
168
+ {
169
+ "llm": {
170
+ "provider": "anthropic",
171
+ "model": "claude-sonnet-4-6",
172
+ "thinkingLevel": "off"
173
+ }
174
+ }
175
+ ```
176
+
177
+ mikan writes logs to stdout/stderr. Use your process manager or host platform (for example PM2, systemd, Docker, or a cloud logging agent) to route logs to your preferred backend.
178
+
179
+ ## Layout
180
+
181
+ ```
182
+ <state-dir>/
183
+ ├── settings.json
184
+ └── vaults/
185
+ └── <vault-id>/
186
+ ├── env
187
+ └── ... # credential files
188
+
189
+ <working-directory>/
190
+ ├── MEMORY.md # global memory
191
+ ├── SYSTEM.md # installed packages / env log
192
+ ├── skills/ # global skills
193
+ ├── events/ # scheduled events
194
+ └── <conversation-id>/
195
+ ├── MEMORY.md
196
+ ├── auto-reply[.disabled] # optional channel auto-reply rules
197
+ ├── log.jsonl
198
+ ├── attachments/
199
+ ├── scratch/
200
+ ├── skills/
201
+ └── sessions/
202
+ ```
203
+
204
+ ## Events
205
+
206
+ Drop JSON files into `<working-directory>/events/`:
207
+
208
+ ```json
209
+ // Immediate
210
+ {"type": "immediate", "platform": "slack", "conversationId": "C0123456789", "conversationKind": "shared", "text": "Deploy finished"}
211
+
212
+ // One-shot
213
+ {"type": "one-shot", "platform": "telegram", "conversationId": "574247312", "conversationKind": "direct", "text": "Standup", "at": "2025-12-15T09:00:00+08:00"}
214
+
215
+ // Periodic (cron)
216
+ {"type": "periodic", "platform": "discord", "conversationId": "1498975469343739948", "conversationKind": "shared", "text": "Check inbox", "schedule": "0 9 * * 1-5", "timezone": "Asia/Taipei"}
217
+ ```
218
+
219
+ ## Skills
220
+
221
+ ```
222
+ skills/my-tool/
223
+ ├── SKILL.md # name + description frontmatter, usage docs
224
+ └── run.sh
225
+ ```
226
+
227
+ ```yaml
228
+ ---
229
+ name: my-tool
230
+ description: Does something useful
231
+ ---
232
+
233
+ Usage: {baseDir}/run.sh <args>
234
+ ```
235
+
236
+ ## Slack: Download channel history
237
+
238
+ ```bash
239
+ mikan --download C0123456789
240
+ ```
241
+
242
+ ## Production deployment (PM2)
243
+
244
+ For long-running deployments, use [PM2](https://pm2.keymetrics.io/) as a process supervisor. It daemonizes mikan, restarts on crash, and survives reboots.
245
+
246
+ ```bash
247
+ # 1. Install mikan and pm2
248
+ npm i -g @geminixiang/mikan pm2
249
+
250
+ # 2. Start the sandbox container (long-lived; mikan execs into it)
251
+ docker pull ghcr.io/geminixiang/mikan-sandbox:latest
252
+
253
+ # 3. Grab the ecosystem file, edit args + env tokens, then start
254
+ curl -O https://raw.githubusercontent.com/geminixiang/mikan/main/deploy/pm2/ecosystem.config.cjs
255
+ pm2 start ecosystem.config.cjs
256
+ pm2 save
257
+ pm2 startup # run the printed command to enable boot autostart
258
+ ```
259
+
260
+ Upgrade flow:
261
+
262
+ ```bash
263
+ npm i -g @geminixiang/mikan && pm2 reload mikan
264
+ ```
265
+
266
+ `pm2 reload` sends SIGTERM and waits up to `kill_timeout` (60s in the shipped config) before SIGKILL. mikan's internal graceful shutdown drains in-flight LLM turns within that window, so reloads do not interrupt active conversations.
267
+
268
+ See [`deploy/pm2/ecosystem.config.cjs`](deploy/pm2/ecosystem.config.cjs) for all tunables.
269
+
270
+ ## Development
271
+
272
+ ```bash
273
+ npm run dev # build in watch mode
274
+ npm test # unit tests (vitest)
275
+ npm run lint # oxlint
276
+ npm run fmt:check # oxfmt (use `npm run fmt` to auto-fix)
277
+ npm run build # type check + emit dist/
278
+ ```
279
+
280
+ ### End-to-end tests
281
+
282
+ E2E suites under `e2e/` exercise real platform APIs and are kept off the default `npm test` run.
283
+
284
+ ```bash
285
+ npm run test:e2e # all platforms
286
+ npm run test:e2e:slack # Slack only
287
+ ```
288
+
289
+ Slack E2E requires `SLACK_QA_USER_TOKEN`, `SLACK_QA_CHANNEL_ID`, and `SLACK_QA_BOT_USER_ID` against a dedicated test workspace. See [`docs/slack-qa-test-plan.md`](docs/slack-qa-test-plan.md) for setup.
290
+
291
+ ## Contributing
292
+
293
+ PRs welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) for dev setup, commit style, and the testing checklist. Bug reports and feature requests go through the GitHub issue templates.
294
+
295
+ ## License
296
+
297
+ MIT — see [LICENSE](LICENSE).