@geminixiang/mikan 1.0.0-beta.2 → 1.0.0-beta.21

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 (497) hide show
  1. package/CHANGELOG.md +388 -0
  2. package/README.md +49 -16
  3. package/dist/adapter.d.ts +1 -1
  4. package/dist/adapter.d.ts.map +1 -1
  5. package/dist/adapter.js.map +1 -1
  6. package/dist/adapters/buffered-responder.d.ts +60 -0
  7. package/dist/adapters/buffered-responder.d.ts.map +1 -0
  8. package/dist/adapters/buffered-responder.js +201 -0
  9. package/dist/adapters/buffered-responder.js.map +1 -0
  10. package/dist/adapters/discord/bot.d.ts +1 -0
  11. package/dist/adapters/discord/bot.d.ts.map +1 -1
  12. package/dist/adapters/discord/bot.js +36 -67
  13. package/dist/adapters/discord/bot.js.map +1 -1
  14. package/dist/adapters/discord/context.d.ts.map +1 -1
  15. package/dist/adapters/discord/context.js +44 -204
  16. package/dist/adapters/discord/context.js.map +1 -1
  17. package/dist/adapters/github/bot.d.ts +86 -0
  18. package/dist/adapters/github/bot.d.ts.map +1 -0
  19. package/dist/adapters/github/bot.js +640 -0
  20. package/dist/adapters/github/bot.js.map +1 -0
  21. package/dist/adapters/github/client.d.ts +122 -0
  22. package/dist/adapters/github/client.d.ts.map +1 -0
  23. package/dist/adapters/github/client.js +314 -0
  24. package/dist/adapters/github/client.js.map +1 -0
  25. package/dist/adapters/github/cloudbuild.d.ts +24 -0
  26. package/dist/adapters/github/cloudbuild.d.ts.map +1 -0
  27. package/dist/adapters/github/cloudbuild.js +71 -0
  28. package/dist/adapters/github/cloudbuild.js.map +1 -0
  29. package/dist/adapters/github/context.d.ts +9 -0
  30. package/dist/adapters/github/context.d.ts.map +1 -0
  31. package/dist/adapters/github/context.js +103 -0
  32. package/dist/adapters/github/context.js.map +1 -0
  33. package/dist/adapters/github/gcp-auth.d.ts +31 -0
  34. package/dist/adapters/github/gcp-auth.d.ts.map +1 -0
  35. package/dist/adapters/github/gcp-auth.js +196 -0
  36. package/dist/adapters/github/gcp-auth.js.map +1 -0
  37. package/dist/adapters/github/github-ops.d.ts +90 -0
  38. package/dist/adapters/github/github-ops.d.ts.map +1 -0
  39. package/dist/adapters/github/github-ops.js +405 -0
  40. package/dist/adapters/github/github-ops.js.map +1 -0
  41. package/dist/adapters/github/ids.d.ts +34 -0
  42. package/dist/adapters/github/ids.d.ts.map +1 -0
  43. package/dist/adapters/github/ids.js +53 -0
  44. package/dist/adapters/github/ids.js.map +1 -0
  45. package/dist/adapters/github/repo.d.ts +32 -0
  46. package/dist/adapters/github/repo.d.ts.map +1 -0
  47. package/dist/adapters/github/repo.js +141 -0
  48. package/dist/adapters/github/repo.js.map +1 -0
  49. package/dist/adapters/github/tool-pack.d.ts +14 -0
  50. package/dist/adapters/github/tool-pack.d.ts.map +1 -0
  51. package/dist/adapters/github/tool-pack.js +56 -0
  52. package/dist/adapters/github/tool-pack.js.map +1 -0
  53. package/dist/adapters/github/tools/checks.d.ts +24 -0
  54. package/dist/adapters/github/tools/checks.d.ts.map +1 -0
  55. package/dist/adapters/github/tools/checks.js +105 -0
  56. package/dist/adapters/github/tools/checks.js.map +1 -0
  57. package/dist/adapters/github/tools/issue.d.ts +22 -0
  58. package/dist/adapters/github/tools/issue.d.ts.map +1 -0
  59. package/dist/adapters/github/tools/issue.js +48 -0
  60. package/dist/adapters/github/tools/issue.js.map +1 -0
  61. package/dist/adapters/github/tools/pr.d.ts +22 -0
  62. package/dist/adapters/github/tools/pr.d.ts.map +1 -0
  63. package/dist/adapters/github/tools/pr.js +48 -0
  64. package/dist/adapters/github/tools/pr.js.map +1 -0
  65. package/dist/adapters/github/tools/read.d.ts +22 -0
  66. package/dist/adapters/github/tools/read.d.ts.map +1 -0
  67. package/dist/adapters/github/tools/read.js +141 -0
  68. package/dist/adapters/github/tools/read.js.map +1 -0
  69. package/dist/adapters/github/tools/review-reply.d.ts +19 -0
  70. package/dist/adapters/github/tools/review-reply.d.ts.map +1 -0
  71. package/dist/adapters/github/tools/review-reply.js +38 -0
  72. package/dist/adapters/github/tools/review-reply.js.map +1 -0
  73. package/dist/adapters/github/tools/sync.d.ts +17 -0
  74. package/dist/adapters/github/tools/sync.d.ts.map +1 -0
  75. package/dist/adapters/github/tools/sync.js +34 -0
  76. package/dist/adapters/github/tools/sync.js.map +1 -0
  77. package/dist/adapters/github/types.d.ts +350 -0
  78. package/dist/adapters/github/types.d.ts.map +1 -0
  79. package/dist/adapters/github/types.js +2 -0
  80. package/dist/adapters/github/types.js.map +1 -0
  81. package/dist/adapters/intake.d.ts +16 -5
  82. package/dist/adapters/intake.d.ts.map +1 -1
  83. package/dist/adapters/intake.js +79 -22
  84. package/dist/adapters/intake.js.map +1 -1
  85. package/dist/adapters/slack/bot.d.ts +8 -6
  86. package/dist/adapters/slack/bot.d.ts.map +1 -1
  87. package/dist/adapters/slack/bot.js +82 -134
  88. package/dist/adapters/slack/bot.js.map +1 -1
  89. package/dist/adapters/slack/context.d.ts.map +1 -1
  90. package/dist/adapters/slack/context.js +3 -14
  91. package/dist/adapters/slack/context.js.map +1 -1
  92. package/dist/adapters/slack/response-lifecycle.d.ts.map +1 -1
  93. package/dist/adapters/slack/response-lifecycle.js +14 -17
  94. package/dist/adapters/slack/response-lifecycle.js.map +1 -1
  95. package/dist/adapters/slack/session.d.ts.map +1 -1
  96. package/dist/adapters/slack/session.js +5 -8
  97. package/dist/adapters/slack/session.js.map +1 -1
  98. package/dist/adapters/streaming.d.ts +4 -0
  99. package/dist/adapters/streaming.d.ts.map +1 -1
  100. package/dist/adapters/streaming.js +11 -0
  101. package/dist/adapters/streaming.js.map +1 -1
  102. package/dist/adapters/telegram/bot.d.ts +1 -2
  103. package/dist/adapters/telegram/bot.d.ts.map +1 -1
  104. package/dist/adapters/telegram/bot.js +27 -62
  105. package/dist/adapters/telegram/bot.js.map +1 -1
  106. package/dist/adapters/telegram/context.d.ts.map +1 -1
  107. package/dist/adapters/telegram/context.js +37 -174
  108. package/dist/adapters/telegram/context.js.map +1 -1
  109. package/dist/adapters/types.d.ts +28 -2
  110. package/dist/adapters/types.d.ts.map +1 -1
  111. package/dist/adapters/types.js.map +1 -1
  112. package/dist/agent.d.ts +37 -14
  113. package/dist/agent.d.ts.map +1 -1
  114. package/dist/agent.js +359 -229
  115. package/dist/agent.js.map +1 -1
  116. package/dist/cli/arg-grammar.d.ts +25 -0
  117. package/dist/cli/arg-grammar.d.ts.map +1 -0
  118. package/dist/cli/arg-grammar.js +59 -0
  119. package/dist/cli/arg-grammar.js.map +1 -0
  120. package/dist/cli/boot.d.ts +16 -0
  121. package/dist/cli/boot.d.ts.map +1 -0
  122. package/dist/cli/boot.js +119 -0
  123. package/dist/cli/boot.js.map +1 -0
  124. package/dist/cli/download.d.ts.map +1 -0
  125. package/dist/cli/download.js.map +1 -0
  126. package/dist/cli/ext-git.d.ts +22 -0
  127. package/dist/cli/ext-git.d.ts.map +1 -0
  128. package/dist/cli/ext-git.js +76 -0
  129. package/dist/cli/ext-git.js.map +1 -0
  130. package/dist/cli/ext.d.ts +2 -0
  131. package/dist/cli/ext.d.ts.map +1 -0
  132. package/dist/cli/ext.js +215 -0
  133. package/dist/cli/ext.js.map +1 -0
  134. package/dist/commands/admin.d.ts.map +1 -1
  135. package/dist/commands/admin.js +2 -1
  136. package/dist/commands/admin.js.map +1 -1
  137. package/dist/commands/auto-reply.d.ts.map +1 -1
  138. package/dist/commands/auto-reply.js +2 -6
  139. package/dist/commands/auto-reply.js.map +1 -1
  140. package/dist/commands/extensions.d.ts.map +1 -1
  141. package/dist/commands/extensions.js +18 -8
  142. package/dist/commands/extensions.js.map +1 -1
  143. package/dist/commands/login.d.ts +2 -1
  144. package/dist/commands/login.d.ts.map +1 -1
  145. package/dist/commands/login.js +35 -3
  146. package/dist/commands/login.js.map +1 -1
  147. package/dist/commands/manifest.d.ts +72 -0
  148. package/dist/commands/manifest.d.ts.map +1 -0
  149. package/dist/commands/manifest.js +121 -0
  150. package/dist/commands/manifest.js.map +1 -0
  151. package/dist/commands/model.d.ts.map +1 -1
  152. package/dist/commands/model.js +11 -9
  153. package/dist/commands/model.js.map +1 -1
  154. package/dist/commands/new.d.ts.map +1 -1
  155. package/dist/commands/new.js +2 -1
  156. package/dist/commands/new.js.map +1 -1
  157. package/dist/commands/sandbox.d.ts.map +1 -1
  158. package/dist/commands/sandbox.js +23 -17
  159. package/dist/commands/sandbox.js.map +1 -1
  160. package/dist/commands/text.d.ts +2 -0
  161. package/dist/commands/text.d.ts.map +1 -0
  162. package/dist/commands/text.js +16 -0
  163. package/dist/commands/text.js.map +1 -0
  164. package/dist/commands/types.d.ts +14 -1
  165. package/dist/commands/types.d.ts.map +1 -1
  166. package/dist/commands/types.js.map +1 -1
  167. package/dist/config.d.ts +1 -3
  168. package/dist/config.d.ts.map +1 -1
  169. package/dist/config.js +98 -95
  170. package/dist/config.js.map +1 -1
  171. package/dist/env-manifest.d.ts +35 -0
  172. package/dist/env-manifest.d.ts.map +1 -0
  173. package/dist/env-manifest.js +225 -0
  174. package/dist/env-manifest.js.map +1 -0
  175. package/dist/events.d.ts.map +1 -1
  176. package/dist/events.js +9 -73
  177. package/dist/events.js.map +1 -1
  178. package/dist/execution-resolver.d.ts +4 -2
  179. package/dist/execution-resolver.d.ts.map +1 -1
  180. package/dist/execution-resolver.js +54 -41
  181. package/dist/execution-resolver.js.map +1 -1
  182. package/dist/harness/event-format.d.ts +66 -0
  183. package/dist/harness/event-format.d.ts.map +1 -0
  184. package/dist/harness/event-format.js +112 -0
  185. package/dist/harness/event-format.js.map +1 -0
  186. package/dist/harness/extensions/loader.d.ts +44 -11
  187. package/dist/harness/extensions/loader.d.ts.map +1 -1
  188. package/dist/harness/extensions/loader.js +273 -84
  189. package/dist/harness/extensions/loader.js.map +1 -1
  190. package/dist/harness/extensions/registry.d.ts +48 -1
  191. package/dist/harness/extensions/registry.d.ts.map +1 -1
  192. package/dist/harness/extensions/registry.js +146 -0
  193. package/dist/harness/extensions/registry.js.map +1 -1
  194. package/dist/harness/extensions/types.d.ts +165 -22
  195. package/dist/harness/extensions/types.d.ts.map +1 -1
  196. package/dist/harness/extensions/types.js.map +1 -1
  197. package/dist/harness/index.d.ts +6 -5
  198. package/dist/harness/index.d.ts.map +1 -1
  199. package/dist/harness/index.js +3 -2
  200. package/dist/harness/index.js.map +1 -1
  201. package/dist/harness/models.d.ts +5 -0
  202. package/dist/harness/models.d.ts.map +1 -1
  203. package/dist/harness/models.js +10 -0
  204. package/dist/harness/models.js.map +1 -1
  205. package/dist/harness/runner.d.ts +37 -2
  206. package/dist/harness/runner.d.ts.map +1 -1
  207. package/dist/harness/runner.js +107 -23
  208. package/dist/harness/runner.js.map +1 -1
  209. package/dist/harness/session-store.d.ts +4 -1
  210. package/dist/harness/session-store.d.ts.map +1 -1
  211. package/dist/harness/session-store.js +11 -2
  212. package/dist/harness/session-store.js.map +1 -1
  213. package/dist/harness/subagent-runner.d.ts +34 -0
  214. package/dist/harness/subagent-runner.d.ts.map +1 -0
  215. package/dist/harness/subagent-runner.js +339 -0
  216. package/dist/harness/subagent-runner.js.map +1 -0
  217. package/dist/harness/types.d.ts +53 -0
  218. package/dist/harness/types.d.ts.map +1 -1
  219. package/dist/harness/types.js.map +1 -1
  220. package/dist/index.d.ts +3 -3
  221. package/dist/index.d.ts.map +1 -1
  222. package/dist/index.js +2 -2
  223. package/dist/index.js.map +1 -1
  224. package/dist/main.js +260 -109
  225. package/dist/main.js.map +1 -1
  226. package/dist/observability/instrument.js +6 -4
  227. package/dist/observability/instrument.js.map +1 -1
  228. package/dist/observability/sentry.d.ts.map +1 -1
  229. package/dist/observability/sentry.js +3 -2
  230. package/dist/observability/sentry.js.map +1 -1
  231. package/dist/provisioner.d.ts.map +1 -1
  232. package/dist/provisioner.js +2 -5
  233. package/dist/provisioner.js.map +1 -1
  234. package/dist/runtime/conversation-runtime.d.ts +1 -1
  235. package/dist/runtime/conversation-runtime.d.ts.map +1 -1
  236. package/dist/runtime/conversation-runtime.js +276 -43
  237. package/dist/runtime/conversation-runtime.js.map +1 -1
  238. package/dist/runtime/types.d.ts +36 -5
  239. package/dist/runtime/types.d.ts.map +1 -1
  240. package/dist/runtime/types.js.map +1 -1
  241. package/dist/sandbox/cloudflare.d.ts +3 -0
  242. package/dist/sandbox/cloudflare.d.ts.map +1 -1
  243. package/dist/sandbox/cloudflare.js +10 -0
  244. package/dist/sandbox/cloudflare.js.map +1 -1
  245. package/dist/sandbox/container.d.ts +4 -0
  246. package/dist/sandbox/container.d.ts.map +1 -1
  247. package/dist/sandbox/container.js +11 -2
  248. package/dist/sandbox/container.js.map +1 -1
  249. package/dist/sandbox/firecracker.d.ts +3 -0
  250. package/dist/sandbox/firecracker.d.ts.map +1 -1
  251. package/dist/sandbox/firecracker.js +10 -1
  252. package/dist/sandbox/firecracker.js.map +1 -1
  253. package/dist/sandbox/gondolin-bootstrap.d.ts +26 -0
  254. package/dist/sandbox/gondolin-bootstrap.d.ts.map +1 -0
  255. package/dist/sandbox/gondolin-bootstrap.js +27 -0
  256. package/dist/sandbox/gondolin-bootstrap.js.map +1 -0
  257. package/dist/sandbox/gondolin-contract.d.ts +125 -0
  258. package/dist/sandbox/gondolin-contract.d.ts.map +1 -0
  259. package/dist/sandbox/gondolin-contract.js +155 -0
  260. package/dist/sandbox/gondolin-contract.js.map +1 -0
  261. package/dist/sandbox/gondolin-fleet.d.ts +104 -0
  262. package/dist/sandbox/gondolin-fleet.d.ts.map +1 -0
  263. package/dist/sandbox/gondolin-fleet.js +330 -0
  264. package/dist/sandbox/gondolin-fleet.js.map +1 -0
  265. package/dist/sandbox/gondolin-gateway.d.ts +86 -0
  266. package/dist/sandbox/gondolin-gateway.d.ts.map +1 -0
  267. package/dist/sandbox/gondolin-gateway.js +407 -0
  268. package/dist/sandbox/gondolin-gateway.js.map +1 -0
  269. package/dist/sandbox/gondolin-inventory.d.ts +75 -0
  270. package/dist/sandbox/gondolin-inventory.d.ts.map +1 -0
  271. package/dist/sandbox/gondolin-inventory.js +257 -0
  272. package/dist/sandbox/gondolin-inventory.js.map +1 -0
  273. package/dist/sandbox/gondolin-join.d.ts +62 -0
  274. package/dist/sandbox/gondolin-join.d.ts.map +1 -0
  275. package/dist/sandbox/gondolin-join.js +261 -0
  276. package/dist/sandbox/gondolin-join.js.map +1 -0
  277. package/dist/sandbox/gondolin-nfs-advisory.d.ts +15 -0
  278. package/dist/sandbox/gondolin-nfs-advisory.d.ts.map +1 -0
  279. package/dist/sandbox/gondolin-nfs-advisory.js +60 -0
  280. package/dist/sandbox/gondolin-nfs-advisory.js.map +1 -0
  281. package/dist/sandbox/gondolin-placement.d.ts +30 -0
  282. package/dist/sandbox/gondolin-placement.d.ts.map +1 -0
  283. package/dist/sandbox/gondolin-placement.js +77 -0
  284. package/dist/sandbox/gondolin-placement.js.map +1 -0
  285. package/dist/sandbox/gondolin-recovery.d.ts +33 -0
  286. package/dist/sandbox/gondolin-recovery.d.ts.map +1 -0
  287. package/dist/sandbox/gondolin-recovery.js +39 -0
  288. package/dist/sandbox/gondolin-recovery.js.map +1 -0
  289. package/dist/sandbox/gondolin-remote.d.ts +70 -0
  290. package/dist/sandbox/gondolin-remote.d.ts.map +1 -0
  291. package/dist/sandbox/gondolin-remote.js +325 -0
  292. package/dist/sandbox/gondolin-remote.js.map +1 -0
  293. package/dist/sandbox/gondolin-worker-client.d.ts +135 -0
  294. package/dist/sandbox/gondolin-worker-client.d.ts.map +1 -0
  295. package/dist/sandbox/gondolin-worker-client.js +323 -0
  296. package/dist/sandbox/gondolin-worker-client.js.map +1 -0
  297. package/dist/sandbox/gondolin-worker-main.d.ts +2 -0
  298. package/dist/sandbox/gondolin-worker-main.d.ts.map +1 -0
  299. package/dist/sandbox/gondolin-worker-main.js +22 -0
  300. package/dist/sandbox/gondolin-worker-main.js.map +1 -0
  301. package/dist/sandbox/gondolin-worker.d.ts +17 -0
  302. package/dist/sandbox/gondolin-worker.d.ts.map +1 -0
  303. package/dist/sandbox/gondolin-worker.js +201 -0
  304. package/dist/sandbox/gondolin-worker.js.map +1 -0
  305. package/dist/sandbox/gondolin.d.ts +53 -0
  306. package/dist/sandbox/gondolin.d.ts.map +1 -0
  307. package/dist/sandbox/gondolin.js +429 -0
  308. package/dist/sandbox/gondolin.js.map +1 -0
  309. package/dist/sandbox/host.d.ts +3 -0
  310. package/dist/sandbox/host.d.ts.map +1 -1
  311. package/dist/sandbox/host.js +14 -0
  312. package/dist/sandbox/host.js.map +1 -1
  313. package/dist/sandbox/identity.d.ts +21 -0
  314. package/dist/sandbox/identity.d.ts.map +1 -0
  315. package/dist/sandbox/identity.js +36 -0
  316. package/dist/sandbox/identity.js.map +1 -0
  317. package/dist/sandbox/index.d.ts +13 -4
  318. package/dist/sandbox/index.d.ts.map +1 -1
  319. package/dist/sandbox/index.js +19 -3
  320. package/dist/sandbox/index.js.map +1 -1
  321. package/dist/sandbox/types.d.ts +31 -1
  322. package/dist/sandbox/types.d.ts.map +1 -1
  323. package/dist/sandbox/types.js.map +1 -1
  324. package/dist/sandbox/utils.d.ts +12 -0
  325. package/dist/sandbox/utils.d.ts.map +1 -1
  326. package/dist/sandbox/utils.js +38 -0
  327. package/dist/sandbox/utils.js.map +1 -1
  328. package/dist/sessions/chat-history-sync.d.ts +32 -0
  329. package/dist/sessions/chat-history-sync.d.ts.map +1 -0
  330. package/dist/sessions/{agent-memory-file-manager.js → chat-history-sync.js} +40 -113
  331. package/dist/sessions/chat-history-sync.js.map +1 -0
  332. package/dist/sessions/conversation-log.d.ts +13 -0
  333. package/dist/sessions/conversation-log.d.ts.map +1 -0
  334. package/dist/sessions/conversation-log.js +47 -0
  335. package/dist/sessions/conversation-log.js.map +1 -0
  336. package/dist/sessions/history-line.d.ts +20 -0
  337. package/dist/sessions/history-line.d.ts.map +1 -0
  338. package/dist/sessions/history-line.js +24 -0
  339. package/dist/sessions/history-line.js.map +1 -0
  340. package/dist/sessions/policy.d.ts.map +1 -1
  341. package/dist/sessions/policy.js +5 -3
  342. package/dist/sessions/policy.js.map +1 -1
  343. package/dist/sessions/rotation.d.ts +2 -0
  344. package/dist/sessions/rotation.d.ts.map +1 -0
  345. package/dist/sessions/rotation.js +39 -0
  346. package/dist/sessions/rotation.js.map +1 -0
  347. package/dist/sessions/session-key.d.ts +31 -0
  348. package/dist/sessions/session-key.d.ts.map +1 -0
  349. package/dist/sessions/session-key.js +44 -0
  350. package/dist/sessions/session-key.js.map +1 -0
  351. package/dist/sessions/store.d.ts.map +1 -1
  352. package/dist/sessions/store.js +6 -12
  353. package/dist/sessions/store.js.map +1 -1
  354. package/dist/sessions/types.d.ts +2 -2
  355. package/dist/sessions/types.d.ts.map +1 -1
  356. package/dist/sessions/types.js.map +1 -1
  357. package/dist/settings-mutation.d.ts +23 -0
  358. package/dist/settings-mutation.d.ts.map +1 -0
  359. package/dist/settings-mutation.js +42 -0
  360. package/dist/settings-mutation.js.map +1 -0
  361. package/dist/tools/bash.d.ts +3 -1
  362. package/dist/tools/bash.d.ts.map +1 -1
  363. package/dist/tools/bash.js +24 -17
  364. package/dist/tools/bash.js.map +1 -1
  365. package/dist/tools/edit.d.ts.map +1 -1
  366. package/dist/tools/edit.js +9 -12
  367. package/dist/tools/edit.js.map +1 -1
  368. package/dist/tools/event.d.ts +1 -1
  369. package/dist/tools/event.d.ts.map +1 -1
  370. package/dist/tools/event.js +53 -43
  371. package/dist/tools/event.js.map +1 -1
  372. package/dist/tools/generate-image.d.ts +17 -0
  373. package/dist/tools/generate-image.d.ts.map +1 -0
  374. package/dist/tools/generate-image.js +63 -0
  375. package/dist/tools/generate-image.js.map +1 -0
  376. package/dist/tools/host-fn-tool.d.ts +21 -0
  377. package/dist/tools/host-fn-tool.d.ts.map +1 -0
  378. package/dist/tools/host-fn-tool.js +32 -0
  379. package/dist/tools/host-fn-tool.js.map +1 -0
  380. package/dist/tools/index.d.ts +17 -2
  381. package/dist/tools/index.d.ts.map +1 -1
  382. package/dist/tools/index.js +28 -3
  383. package/dist/tools/index.js.map +1 -1
  384. package/dist/tools/react.d.ts +15 -0
  385. package/dist/tools/react.d.ts.map +1 -0
  386. package/dist/tools/react.js +29 -0
  387. package/dist/tools/react.js.map +1 -0
  388. package/dist/tools/read.d.ts.map +1 -1
  389. package/dist/tools/read.js +7 -26
  390. package/dist/tools/read.js.map +1 -1
  391. package/dist/tools/sandbox.d.ts +2 -2
  392. package/dist/tools/sandbox.d.ts.map +1 -1
  393. package/dist/tools/sandbox.js +13 -9
  394. package/dist/tools/sandbox.js.map +1 -1
  395. package/dist/tools/subagent-slots.d.ts +28 -0
  396. package/dist/tools/subagent-slots.d.ts.map +1 -0
  397. package/dist/tools/subagent-slots.js +57 -0
  398. package/dist/tools/subagent-slots.js.map +1 -0
  399. package/dist/tools/subagent.d.ts +74 -0
  400. package/dist/tools/subagent.d.ts.map +1 -0
  401. package/dist/tools/subagent.js +335 -0
  402. package/dist/tools/subagent.js.map +1 -0
  403. package/dist/tools/types.d.ts +40 -6
  404. package/dist/tools/types.d.ts.map +1 -1
  405. package/dist/tools/types.js.map +1 -1
  406. package/dist/tools/write.d.ts.map +1 -1
  407. package/dist/tools/write.js +1 -8
  408. package/dist/tools/write.js.map +1 -1
  409. package/dist/trigger.d.ts.map +1 -1
  410. package/dist/trigger.js +1 -2
  411. package/dist/trigger.js.map +1 -1
  412. package/dist/types.d.ts +144 -31
  413. package/dist/types.d.ts.map +1 -1
  414. package/dist/types.js.map +1 -1
  415. package/dist/utils/date.d.ts +1 -1
  416. package/dist/utils/date.js +1 -1
  417. package/dist/utils/date.js.map +1 -1
  418. package/dist/vault/disabled.d.ts +9 -0
  419. package/dist/vault/disabled.d.ts.map +1 -0
  420. package/dist/vault/disabled.js +22 -0
  421. package/dist/vault/disabled.js.map +1 -0
  422. package/dist/vault/index.d.ts +0 -2
  423. package/dist/vault/index.d.ts.map +1 -1
  424. package/dist/vault/index.js +1 -32
  425. package/dist/vault/index.js.map +1 -1
  426. package/dist/vault/injection.d.ts +20 -0
  427. package/dist/vault/injection.d.ts.map +1 -0
  428. package/dist/vault/injection.js +27 -0
  429. package/dist/vault/injection.js.map +1 -0
  430. package/dist/vault/policy.d.ts +20 -0
  431. package/dist/vault/policy.d.ts.map +1 -0
  432. package/dist/vault/policy.js +20 -0
  433. package/dist/vault/policy.js.map +1 -0
  434. package/dist/vault/types.d.ts +0 -2
  435. package/dist/vault/types.d.ts.map +1 -1
  436. package/dist/vault/types.js.map +1 -1
  437. package/dist/web/admin/portal.d.ts +27 -0
  438. package/dist/web/admin/portal.d.ts.map +1 -1
  439. package/dist/web/admin/portal.js +117 -154
  440. package/dist/web/admin/portal.js.map +1 -1
  441. package/dist/web/admin/types.d.ts +6 -0
  442. package/dist/web/admin/types.d.ts.map +1 -1
  443. package/dist/web/admin/types.js.map +1 -1
  444. package/dist/web/agent-events/portal.d.ts.map +1 -1
  445. package/dist/web/agent-events/portal.js +2 -1
  446. package/dist/web/agent-events/portal.js.map +1 -1
  447. package/dist/web/login/oauth.d.ts +2 -3
  448. package/dist/web/login/oauth.d.ts.map +1 -1
  449. package/dist/web/login/oauth.js +0 -31
  450. package/dist/web/login/oauth.js.map +1 -1
  451. package/dist/web/login/portal.js +1 -1
  452. package/dist/web/login/portal.js.map +1 -1
  453. package/dist/web/login/types.d.ts +0 -11
  454. package/dist/web/login/types.d.ts.map +1 -1
  455. package/dist/web/login/types.js.map +1 -1
  456. package/dist/web/portal-shell.d.ts +4 -0
  457. package/dist/web/portal-shell.d.ts.map +1 -0
  458. package/dist/{portal-shell.js → web/portal-shell.js} +2 -2
  459. package/dist/web/portal-shell.js.map +1 -0
  460. package/dist/web/server.d.ts.map +1 -1
  461. package/dist/web/server.js +7 -0
  462. package/dist/web/server.js.map +1 -1
  463. package/dist/web/session-view/command.d.ts.map +1 -1
  464. package/dist/web/session-view/command.js +4 -1
  465. package/dist/web/session-view/command.js.map +1 -1
  466. package/dist/web/session-view/portal.d.ts.map +1 -1
  467. package/dist/web/session-view/portal.js +4 -3
  468. package/dist/web/session-view/portal.js.map +1 -1
  469. package/dist/web/session-view/service.d.ts.map +1 -1
  470. package/dist/web/session-view/service.js +2 -1
  471. package/dist/web/session-view/service.js.map +1 -1
  472. package/dist/web/session-view/types.d.ts +2 -1
  473. package/dist/web/session-view/types.d.ts.map +1 -1
  474. package/dist/web/session-view/types.js.map +1 -1
  475. package/package.json +7 -4
  476. package/dist/download.d.ts.map +0 -1
  477. package/dist/download.js.map +0 -1
  478. package/dist/model-registry.d.ts +0 -4
  479. package/dist/model-registry.d.ts.map +0 -1
  480. package/dist/model-registry.js +0 -7
  481. package/dist/model-registry.js.map +0 -1
  482. package/dist/portal-shell.d.ts +0 -4
  483. package/dist/portal-shell.d.ts.map +0 -1
  484. package/dist/portal-shell.js.map +0 -1
  485. package/dist/runtime/agent-run-controller.d.ts +0 -31
  486. package/dist/runtime/agent-run-controller.d.ts.map +0 -1
  487. package/dist/runtime/agent-run-controller.js +0 -195
  488. package/dist/runtime/agent-run-controller.js.map +0 -1
  489. package/dist/sessions/agent-memory-file-manager.d.ts +0 -19
  490. package/dist/sessions/agent-memory-file-manager.d.ts.map +0 -1
  491. package/dist/sessions/agent-memory-file-manager.js.map +0 -1
  492. package/dist/vault/routing.d.ts +0 -3
  493. package/dist/vault/routing.d.ts.map +0 -1
  494. package/dist/vault/routing.js +0 -13
  495. package/dist/vault/routing.js.map +0 -1
  496. /package/dist/{download.d.ts → cli/download.d.ts} +0 -0
  497. /package/dist/{download.js → cli/download.js} +0 -0
@@ -0,0 +1,350 @@
1
+ import type { ConversationEvent } from "../../adapter.js";
2
+ import type { GcpTokenProvider } from "./gcp-auth.js";
3
+ export interface GithubEvent extends ConversationEvent {
4
+ type: "message" | "issue";
5
+ userName?: string;
6
+ }
7
+ export interface GithubBotConfig {
8
+ appId: string;
9
+ /** PEM-encoded GitHub App private key. */
10
+ privateKey: string;
11
+ installationId: string;
12
+ /** `owner/repo` entries to watch; empty = all installation repositories. */
13
+ repos: string[];
14
+ pollIntervalMs: number;
15
+ workingDir: string;
16
+ /**
17
+ * Where the poll watermark state (baseline + seen ids) is persisted. Lives
18
+ * under the host-only state dir: the workspace dir can be mounted into
19
+ * sandboxes, and sandboxed code must not be able to clear dedup state and
20
+ * re-trigger runs.
21
+ */
22
+ syncStatePath: string;
23
+ /**
24
+ * Present when the host has GCP credentials (GOOGLE_APPLICATION_CREDENTIALS):
25
+ * lets github_checks fetch Cloud Build logs. Credentials never enter the
26
+ * sandbox; absent, external-CI checks degrade to guidance text.
27
+ */
28
+ cloudBuild?: {
29
+ tokenProvider: GcpTokenProvider;
30
+ /** Project used when a check's details_url does not name one. */
31
+ projectFallback?: string;
32
+ };
33
+ }
34
+ /** Persisted per-repo poll watermark (DESIGN.md § Event source). */
35
+ interface GithubRepoSyncState {
36
+ /** Comments/issues created before this ISO instant never trigger. */
37
+ baseline: string;
38
+ /** Newest updated_at seen; polls fetch from (cursor - overlap). */
39
+ cursor: string;
40
+ seenComments: number[];
41
+ seenIssues: number[];
42
+ /** Optional so state files written before review-comment polling still load. */
43
+ seenReviewComments?: number[];
44
+ }
45
+ export interface GithubSyncState {
46
+ repos: Record<string, GithubRepoSyncState>;
47
+ }
48
+ export interface GithubRepoRef {
49
+ owner: string;
50
+ repo: string;
51
+ }
52
+ export interface GithubConversationRef extends GithubRepoRef {
53
+ number: number;
54
+ }
55
+ interface GithubUser {
56
+ login: string;
57
+ type: string;
58
+ }
59
+ export interface GithubIssue {
60
+ id: number;
61
+ number: number;
62
+ title: string;
63
+ body: string | null;
64
+ user: GithubUser;
65
+ created_at: string;
66
+ updated_at: string;
67
+ pull_request?: object;
68
+ /** open | closed */
69
+ state?: string;
70
+ labels?: {
71
+ name: string;
72
+ }[];
73
+ assignees?: {
74
+ login: string;
75
+ }[];
76
+ }
77
+ export interface GithubIssueComment {
78
+ id: number;
79
+ body: string;
80
+ user: GithubUser;
81
+ created_at: string;
82
+ updated_at: string;
83
+ /** API URL of the parent issue, e.g. …/repos/o/r/issues/42 */
84
+ issue_url: string;
85
+ }
86
+ /** An inline PR review comment (a comment on a diff line). */
87
+ export interface GithubReviewComment {
88
+ id: number;
89
+ body: string;
90
+ user: GithubUser;
91
+ created_at: string;
92
+ updated_at: string;
93
+ /** API URL of the parent PR, e.g. …/repos/o/r/pulls/42 */
94
+ pull_request_url: string;
95
+ /** File the comment is anchored to. */
96
+ path: string;
97
+ /** Line in the diff's right side; null when the anchor is outdated. */
98
+ line: number | null;
99
+ /** The diff excerpt the comment is anchored to. */
100
+ diff_hunk: string;
101
+ /** Set on replies: the id of the thread's root comment. */
102
+ in_reply_to_id?: number;
103
+ }
104
+ export interface GithubRepository {
105
+ name: string;
106
+ owner: GithubUser;
107
+ }
108
+ export interface GithubRepositoryDetails {
109
+ default_branch: string;
110
+ }
111
+ export interface GithubCollaboratorPermission {
112
+ /** Legacy field: admin | write | read | none (maintain→write, triage→read). */
113
+ permission: string;
114
+ /** Granular assigned role (admin/maintain/write/triage/read or a custom role). */
115
+ role_name?: string;
116
+ }
117
+ export interface GithubPullRequest {
118
+ number: number;
119
+ html_url: string;
120
+ /** head.repo is null when the fork a PR came from was deleted. */
121
+ head?: {
122
+ ref: string;
123
+ sha: string;
124
+ repo?: {
125
+ full_name?: string;
126
+ } | null;
127
+ };
128
+ base?: {
129
+ ref: string;
130
+ };
131
+ title?: string;
132
+ body?: string | null;
133
+ /** open | closed */
134
+ state?: string;
135
+ draft?: boolean;
136
+ merged?: boolean;
137
+ mergeable_state?: string;
138
+ changed_files?: number;
139
+ additions?: number;
140
+ deletions?: number;
141
+ user?: GithubUser;
142
+ }
143
+ /** One row of GET /pulls/{n}/files. */
144
+ export interface GithubPullRequestFile {
145
+ filename: string;
146
+ /** added | removed | modified | renamed | … */
147
+ status: string;
148
+ additions: number;
149
+ deletions: number;
150
+ }
151
+ /** One submitted review of GET /pulls/{n}/reviews. */
152
+ export interface GithubPullRequestReview {
153
+ id: number;
154
+ user: GithubUser;
155
+ body: string | null;
156
+ /** APPROVED | CHANGES_REQUESTED | COMMENTED | DISMISSED | PENDING */
157
+ state: string;
158
+ submitted_at?: string;
159
+ }
160
+ export interface GithubCheckRun {
161
+ /** Check-run id; for GitHub Actions this doubles as the job id (log fetch). */
162
+ id: number;
163
+ name: string;
164
+ /** queued | in_progress | completed */
165
+ status: string;
166
+ /** success | failure | neutral | cancelled | skipped | timed_out | action_required | null while running */
167
+ conclusion: string | null;
168
+ html_url: string | null;
169
+ /** The app that reported the check (github-actions vs external CI). */
170
+ app?: {
171
+ slug?: string;
172
+ } | null;
173
+ /** Whatever the reporting app posted about the run. */
174
+ output?: {
175
+ title?: string | null;
176
+ summary?: string | null;
177
+ } | null;
178
+ /** The reporting app's own id for the run; Cloud Build puts the build UUID here. */
179
+ external_id?: string | null;
180
+ /** The reporting app's own results page; Cloud Build encodes the GCP project here. */
181
+ details_url?: string | null;
182
+ }
183
+ /** Permission subset requestable on a scoped installation token. */
184
+ export type GithubTokenPermissions = Partial<Record<"contents" | "pull_requests" | "issues", "read" | "write">>;
185
+ export type GithubReactionContent = "+1" | "-1" | "laugh" | "confused" | "heart" | "hooray" | "rocket" | "eyes";
186
+ export interface CloneRepoOptions {
187
+ /** HTTPS remote, e.g. https://github.com/owner/repo.git (no credentials). */
188
+ url: string;
189
+ /** Destination directory (the conversation dir's `repo/`). */
190
+ dir: string;
191
+ /** Ephemeral scoped installation token; used per-invocation, never stored. */
192
+ token: string;
193
+ botLogin: string;
194
+ botEmail: string;
195
+ /** When the conversation is a PR: fetch and check out its head. */
196
+ prNumber?: number;
197
+ /**
198
+ * The PR's head branch name when it lives in this repo (not a fork): the
199
+ * checkout is named after it so committing there + github_pr updates the
200
+ * PR in place. Absent (fork/unknown), the checkout falls back to pr-<n>.
201
+ */
202
+ prHeadBranch?: string;
203
+ }
204
+ export interface PushBranchOptions {
205
+ dir: string;
206
+ branch: string;
207
+ token: string;
208
+ }
209
+ export interface SyncRepoOptions {
210
+ dir: string;
211
+ /** Ephemeral contents:read token; used per-invocation, never stored. */
212
+ token: string;
213
+ /** Explicit branch to fetch; wins over prNumber/defaultBranch. */
214
+ branch?: string;
215
+ /** PR conversations: fetch pull/<n>/head into the local PR checkout. */
216
+ prNumber?: number;
217
+ /** Same-repo PR head name; the local checkout target. Fallback: pr-<n>. */
218
+ prHeadBranch?: string;
219
+ /** Fallback target when neither branch nor prNumber applies. */
220
+ defaultBranch?: string;
221
+ }
222
+ export interface SyncRepoResult {
223
+ /** Local branch the fetch targets (the PR head name, pr-<n>, or the branch). */
224
+ target: string;
225
+ fetchedSha: string;
226
+ /** True when the checkout was moved to the fetched head. */
227
+ updatedCheckout: boolean;
228
+ /** Working tree had uncommitted changes (checkout left alone). */
229
+ dirty: boolean;
230
+ currentBranch: string;
231
+ /** Bot-committed (agent-made) commits on the target that origin lacks. */
232
+ localCommits: number;
233
+ }
234
+ export interface GithubClientOptions {
235
+ appId: string;
236
+ privateKey: string;
237
+ installationId: string;
238
+ /** Override the API root for tests; defaults to https://api.github.com */
239
+ baseUrl?: string;
240
+ fetchImpl?: typeof fetch;
241
+ }
242
+ /** Arguments for the host-side `github_pr` tool. */
243
+ export interface GithubPrRequest {
244
+ /** Local branch in the conversation's ./repo clone; must match pi/<name>. */
245
+ branch: string;
246
+ title: string;
247
+ body?: string;
248
+ /** Target branch; defaults to the repository's default branch. */
249
+ base?: string;
250
+ draft?: boolean;
251
+ }
252
+ export interface GithubPrResult {
253
+ number: number;
254
+ url: string;
255
+ /** True when the branch already had an open PR that this push updated. */
256
+ updatedExisting?: boolean;
257
+ }
258
+ /** Normalized check-run row for the host-side `github_checks` tool. */
259
+ export interface GithubCheckSummary {
260
+ /** Check-run id; for GitHub Actions checks it is also the job id for log fetch. */
261
+ id: number;
262
+ name: string;
263
+ /** queued | in_progress | completed */
264
+ status: string;
265
+ /** success | failure | … ; null while the run is still in progress */
266
+ conclusion: string | null;
267
+ url: string | null;
268
+ /** Slug of the reporting app; "github-actions" checks have fetchable logs. */
269
+ appSlug: string | null;
270
+ /** The reporting app's own summary of the run, when it posted one. */
271
+ outputSummary: string | null;
272
+ /** The reporting app's run id (Cloud Build: the build UUID). */
273
+ externalId: string | null;
274
+ /** True when this run's log is fetchable via build_id (Cloud Build + GCP creds). */
275
+ buildLogAvailable?: boolean;
276
+ }
277
+ /** Arguments for the host-side `github_read` tool. */
278
+ export interface GithubReadRequest {
279
+ action: "pr" | "pr_files" | "pr_reviews" | "issue" | "comments" | "list";
280
+ /** Issue/PR number; defaults to the conversation's own. */
281
+ number?: number;
282
+ /** list only: open | closed | all (default open). */
283
+ state?: string;
284
+ /** list only: comma-separated label names. */
285
+ labels?: string;
286
+ /** list only: filter by author login. */
287
+ creator?: string;
288
+ }
289
+ /** Typed payload of one `github_read` action; the tool renders it. */
290
+ export type GithubReadResult = {
291
+ kind: "pr";
292
+ pr: GithubPullRequest;
293
+ } | {
294
+ kind: "pr_files";
295
+ files: GithubPullRequestFile[];
296
+ } | {
297
+ kind: "pr_reviews";
298
+ reviews: GithubPullRequestReview[];
299
+ threads: GithubReviewComment[];
300
+ } | {
301
+ kind: "issue";
302
+ issue: GithubIssue;
303
+ } | {
304
+ kind: "comments";
305
+ comments: GithubIssueComment[];
306
+ } | {
307
+ kind: "list";
308
+ issues: GithubIssue[];
309
+ };
310
+ /** Arguments for the host-side `github_issue` tool. Deliberately a closed
311
+ * action set: lock/delete/transfer are not offered at all. */
312
+ export interface GithubIssueRequest {
313
+ action: "add_labels" | "remove_label" | "add_assignees" | "remove_assignees" | "close" | "reopen";
314
+ /** Issue/PR number; defaults to the conversation's own (triage may target others). */
315
+ number?: number;
316
+ /** add_labels */
317
+ labels?: string[];
318
+ /** remove_label */
319
+ label?: string;
320
+ /** add_assignees / remove_assignees */
321
+ assignees?: string[];
322
+ /** close */
323
+ state_reason?: "completed" | "not_planned";
324
+ }
325
+ /**
326
+ * Host-side GitHub operations for github_* tools. Wired in main.ts over the
327
+ * GitHub bot; tokens stay host-side. Consumed by `createGithubToolPack`.
328
+ */
329
+ export interface PlatformGithubOps {
330
+ /** Push a prepared pi/* branch and open (or update) a pull request. */
331
+ pushAndCreatePr(conversationId: string, request: GithubPrRequest): Promise<GithubPrResult>;
332
+ /** CI check runs for a branch, or for the conversation's PR head when omitted. */
333
+ getChecks(conversationId: string, branch?: string): Promise<GithubCheckSummary[]>;
334
+ /** Log text of one CI job (an Actions check-run id), tail-truncated. */
335
+ getJobLog(conversationId: string, jobId: number): Promise<string>;
336
+ /** Log text of one Cloud Build run (a [build …] uuid), tail-truncated. */
337
+ getBuildLog(conversationId: string, buildId: string): Promise<string>;
338
+ /** Reply inside one inline review thread of the conversation's PR. */
339
+ replyToReviewThread(conversationId: string, commentId: number, body: string): Promise<{
340
+ url: string;
341
+ }>;
342
+ /** Refresh the conversation's ./repo clone; returns a human-readable report. */
343
+ syncRepo(conversationId: string, branch?: string): Promise<string>;
344
+ /** Read PR/issue metadata the clone cannot provide; same repo only. */
345
+ readGithub(conversationId: string, request: GithubReadRequest): Promise<GithubReadResult>;
346
+ /** Label/assignee/state management on this repo's issues; returns a report. */
347
+ manageIssue(conversationId: string, request: GithubIssueRequest): Promise<string>;
348
+ }
349
+ export {};
350
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapters/github/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,WAAW,WAAY,SAAQ,iBAAiB;IACpD,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,4EAA4E;IAC5E,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,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;IAC/E,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACnF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/adapters/github/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ConversationEvent } from \"../../adapter.js\";\nimport type { GcpTokenProvider } from \"./gcp-auth.js\";\n\nexport interface GithubEvent extends ConversationEvent {\n type: \"message\" | \"issue\";\n userName?: string;\n}\n\nexport interface GithubBotConfig {\n appId: string;\n /** PEM-encoded GitHub App private key. */\n privateKey: string;\n installationId: string;\n /** `owner/repo` entries to watch; empty = all installation repositories. */\n repos: string[];\n pollIntervalMs: number;\n workingDir: string;\n /**\n * Where the poll watermark state (baseline + seen ids) is persisted. Lives\n * under the host-only state dir: the workspace dir can be mounted into\n * sandboxes, and sandboxed code must not be able to clear dedup state and\n * re-trigger runs.\n */\n syncStatePath: string;\n /**\n * Present when the host has GCP credentials (GOOGLE_APPLICATION_CREDENTIALS):\n * lets github_checks fetch Cloud Build logs. Credentials never enter the\n * sandbox; absent, external-CI checks degrade to guidance text.\n */\n cloudBuild?: {\n tokenProvider: GcpTokenProvider;\n /** Project used when a check's details_url does not name one. */\n projectFallback?: string;\n };\n}\n\n/** Persisted per-repo poll watermark (DESIGN.md § Event source). */\ninterface GithubRepoSyncState {\n /** Comments/issues created before this ISO instant never trigger. */\n baseline: string;\n /** Newest updated_at seen; polls fetch from (cursor - overlap). */\n cursor: string;\n seenComments: number[];\n seenIssues: number[];\n /** Optional so state files written before review-comment polling still load. */\n seenReviewComments?: number[];\n}\n\nexport interface GithubSyncState {\n repos: Record<string, GithubRepoSyncState>;\n}\n\nexport interface GithubRepoRef {\n owner: string;\n repo: string;\n}\n\nexport interface GithubConversationRef extends GithubRepoRef {\n number: number;\n}\n\n// ── GitHub REST payload shapes (only the fields mikan reads) ─────────────────\n\ninterface GithubUser {\n login: string;\n type: string;\n}\n\nexport interface GithubIssue {\n id: number;\n number: number;\n title: string;\n body: string | null;\n user: GithubUser;\n created_at: string;\n updated_at: string;\n pull_request?: object;\n /** open | closed */\n state?: string;\n labels?: { name: string }[];\n assignees?: { login: string }[];\n}\n\nexport interface GithubIssueComment {\n id: number;\n body: string;\n user: GithubUser;\n created_at: string;\n updated_at: string;\n /** API URL of the parent issue, e.g. …/repos/o/r/issues/42 */\n issue_url: string;\n}\n\n/** An inline PR review comment (a comment on a diff line). */\nexport interface GithubReviewComment {\n id: number;\n body: string;\n user: GithubUser;\n created_at: string;\n updated_at: string;\n /** API URL of the parent PR, e.g. …/repos/o/r/pulls/42 */\n pull_request_url: string;\n /** File the comment is anchored to. */\n path: string;\n /** Line in the diff's right side; null when the anchor is outdated. */\n line: number | null;\n /** The diff excerpt the comment is anchored to. */\n diff_hunk: string;\n /** Set on replies: the id of the thread's root comment. */\n in_reply_to_id?: number;\n}\n\nexport interface GithubRepository {\n name: string;\n owner: GithubUser;\n}\n\nexport interface GithubRepositoryDetails {\n default_branch: string;\n}\n\nexport interface GithubCollaboratorPermission {\n /** Legacy field: admin | write | read | none (maintain→write, triage→read). */\n permission: string;\n /** Granular assigned role (admin/maintain/write/triage/read or a custom role). */\n role_name?: string;\n}\n\nexport interface GithubPullRequest {\n number: number;\n html_url: string;\n /** head.repo is null when the fork a PR came from was deleted. */\n head?: { ref: string; sha: string; repo?: { full_name?: string } | null };\n base?: { ref: string };\n title?: string;\n body?: string | null;\n /** open | closed */\n state?: string;\n draft?: boolean;\n merged?: boolean;\n mergeable_state?: string;\n changed_files?: number;\n additions?: number;\n deletions?: number;\n user?: GithubUser;\n}\n\n/** One row of GET /pulls/{n}/files. */\nexport interface GithubPullRequestFile {\n filename: string;\n /** added | removed | modified | renamed | … */\n status: string;\n additions: number;\n deletions: number;\n}\n\n/** One submitted review of GET /pulls/{n}/reviews. */\nexport interface GithubPullRequestReview {\n id: number;\n user: GithubUser;\n body: string | null;\n /** APPROVED | CHANGES_REQUESTED | COMMENTED | DISMISSED | PENDING */\n state: string;\n submitted_at?: string;\n}\n\nexport interface GithubCheckRun {\n /** Check-run id; for GitHub Actions this doubles as the job id (log fetch). */\n id: number;\n name: string;\n /** queued | in_progress | completed */\n status: string;\n /** success | failure | neutral | cancelled | skipped | timed_out | action_required | null while running */\n conclusion: string | null;\n html_url: string | null;\n /** The app that reported the check (github-actions vs external CI). */\n app?: { slug?: string } | null;\n /** Whatever the reporting app posted about the run. */\n output?: { title?: string | null; summary?: string | null } | null;\n /** The reporting app's own id for the run; Cloud Build puts the build UUID here. */\n external_id?: string | null;\n /** The reporting app's own results page; Cloud Build encodes the GCP project here. */\n details_url?: string | null;\n}\n\n/** Permission subset requestable on a scoped installation token. */\nexport type GithubTokenPermissions = Partial<\n Record<\"contents\" | \"pull_requests\" | \"issues\", \"read\" | \"write\">\n>;\n\nexport type GithubReactionContent =\n | \"+1\"\n | \"-1\"\n | \"laugh\"\n | \"confused\"\n | \"heart\"\n | \"hooray\"\n | \"rocket\"\n | \"eyes\";\n\nexport interface CloneRepoOptions {\n /** HTTPS remote, e.g. https://github.com/owner/repo.git (no credentials). */\n url: string;\n /** Destination directory (the conversation dir's `repo/`). */\n dir: string;\n /** Ephemeral scoped installation token; used per-invocation, never stored. */\n token: string;\n botLogin: string;\n botEmail: string;\n /** When the conversation is a PR: fetch and check out its head. */\n prNumber?: number;\n /**\n * The PR's head branch name when it lives in this repo (not a fork): the\n * checkout is named after it so committing there + github_pr updates the\n * PR in place. Absent (fork/unknown), the checkout falls back to pr-<n>.\n */\n prHeadBranch?: string;\n}\n\nexport interface PushBranchOptions {\n dir: string;\n branch: string;\n token: string;\n}\n\nexport interface SyncRepoOptions {\n dir: string;\n /** Ephemeral contents:read token; used per-invocation, never stored. */\n token: string;\n /** Explicit branch to fetch; wins over prNumber/defaultBranch. */\n branch?: string;\n /** PR conversations: fetch pull/<n>/head into the local PR checkout. */\n prNumber?: number;\n /** Same-repo PR head name; the local checkout target. Fallback: pr-<n>. */\n prHeadBranch?: string;\n /** Fallback target when neither branch nor prNumber applies. */\n defaultBranch?: string;\n}\n\nexport interface SyncRepoResult {\n /** Local branch the fetch targets (the PR head name, pr-<n>, or the branch). */\n target: string;\n fetchedSha: string;\n /** True when the checkout was moved to the fetched head. */\n updatedCheckout: boolean;\n /** Working tree had uncommitted changes (checkout left alone). */\n dirty: boolean;\n currentBranch: string;\n /** Bot-committed (agent-made) commits on the target that origin lacks. */\n localCommits: number;\n}\n\nexport interface GithubClientOptions {\n appId: string;\n privateKey: string;\n installationId: string;\n /** Override the API root for tests; defaults to https://api.github.com */\n baseUrl?: string;\n fetchImpl?: typeof fetch;\n}\n\n// ── Host-side tool contracts (capability pack, not messaging core) ───────────\n\n/** Arguments for the host-side `github_pr` tool. */\nexport interface GithubPrRequest {\n /** Local branch in the conversation's ./repo clone; must match pi/<name>. */\n branch: string;\n title: string;\n body?: string;\n /** Target branch; defaults to the repository's default branch. */\n base?: string;\n draft?: boolean;\n}\n\nexport interface GithubPrResult {\n number: number;\n url: string;\n /** True when the branch already had an open PR that this push updated. */\n updatedExisting?: boolean;\n}\n\n/** Normalized check-run row for the host-side `github_checks` tool. */\nexport interface GithubCheckSummary {\n /** Check-run id; for GitHub Actions checks it is also the job id for log fetch. */\n id: number;\n name: string;\n /** queued | in_progress | completed */\n status: string;\n /** success | failure | … ; null while the run is still in progress */\n conclusion: string | null;\n url: string | null;\n /** Slug of the reporting app; \"github-actions\" checks have fetchable logs. */\n appSlug: string | null;\n /** The reporting app's own summary of the run, when it posted one. */\n outputSummary: string | null;\n /** The reporting app's run id (Cloud Build: the build UUID). */\n externalId: string | null;\n /** True when this run's log is fetchable via build_id (Cloud Build + GCP creds). */\n buildLogAvailable?: boolean;\n}\n\n/** Arguments for the host-side `github_read` tool. */\nexport interface GithubReadRequest {\n action: \"pr\" | \"pr_files\" | \"pr_reviews\" | \"issue\" | \"comments\" | \"list\";\n /** Issue/PR number; defaults to the conversation's own. */\n number?: number;\n /** list only: open | closed | all (default open). */\n state?: string;\n /** list only: comma-separated label names. */\n labels?: string;\n /** list only: filter by author login. */\n creator?: string;\n}\n\n/** Typed payload of one `github_read` action; the tool renders it. */\nexport type GithubReadResult =\n | { kind: \"pr\"; pr: GithubPullRequest }\n | { kind: \"pr_files\"; files: GithubPullRequestFile[] }\n | { kind: \"pr_reviews\"; reviews: GithubPullRequestReview[]; threads: GithubReviewComment[] }\n | { kind: \"issue\"; issue: GithubIssue }\n | { kind: \"comments\"; comments: GithubIssueComment[] }\n | { kind: \"list\"; issues: GithubIssue[] };\n\n/** Arguments for the host-side `github_issue` tool. Deliberately a closed\n * action set: lock/delete/transfer are not offered at all. */\nexport interface GithubIssueRequest {\n action: \"add_labels\" | \"remove_label\" | \"add_assignees\" | \"remove_assignees\" | \"close\" | \"reopen\";\n /** Issue/PR number; defaults to the conversation's own (triage may target others). */\n number?: number;\n /** add_labels */\n labels?: string[];\n /** remove_label */\n label?: string;\n /** add_assignees / remove_assignees */\n assignees?: string[];\n /** close */\n state_reason?: \"completed\" | \"not_planned\";\n}\n\n/**\n * Host-side GitHub operations for github_* tools. Wired in main.ts over the\n * GitHub bot; tokens stay host-side. Consumed by `createGithubToolPack`.\n */\nexport interface PlatformGithubOps {\n /** Push a prepared pi/* branch and open (or update) a pull request. */\n pushAndCreatePr(conversationId: string, request: GithubPrRequest): Promise<GithubPrResult>;\n /** CI check runs for a branch, or for the conversation's PR head when omitted. */\n getChecks(conversationId: string, branch?: string): Promise<GithubCheckSummary[]>;\n /** Log text of one CI job (an Actions check-run id), tail-truncated. */\n getJobLog(conversationId: string, jobId: number): Promise<string>;\n /** Log text of one Cloud Build run (a [build …] uuid), tail-truncated. */\n getBuildLog(conversationId: string, buildId: string): Promise<string>;\n /** Reply inside one inline review thread of the conversation's PR. */\n replyToReviewThread(\n conversationId: string,\n commentId: number,\n body: string,\n ): Promise<{ url: string }>;\n /** Refresh the conversation's ./repo clone; returns a human-readable report. */\n syncRepo(conversationId: string, branch?: string): Promise<string>;\n /** Read PR/issue metadata the clone cannot provide; same repo only. */\n readGithub(conversationId: string, request: GithubReadRequest): Promise<GithubReadResult>;\n /** Label/assignee/state management on this repo's issues; returns a report. */\n manageIssue(conversationId: string, request: GithubIssueRequest): Promise<string>;\n}\n"]}
@@ -1,11 +1,22 @@
1
1
  import type { ConversationEvent } from "../adapter.js";
2
- import type { MessageIntakeOptions } from "./types.js";
2
+ import type { MessageIntakeOptions, MessageIntakeOutcome } from "./types.js";
3
+ /**
4
+ * Recognize a magic word: a highest-priority chat control phrase that bypasses
5
+ * trigger policy and queueing (see CONTEXT.md). One grammar for every
6
+ * platform: optional leading slash, optional `@botname` suffix, any case.
7
+ */
8
+ export declare function matchMagicWord(text: string): "stop" | null;
3
9
  /**
4
10
  * Shared message ingress pipeline for platform adapters.
5
11
  *
6
- * Platform adapters still normalize SDK events and handle platform-specific stop
7
- * semantics. This module owns the common trigger/log/attachment/queue/handler
8
- * ordering for messages that may start an agent run.
12
+ * Platform adapters normalize SDK events; this module owns the ordering for
13
+ * messages that may start an agent run:
14
+ *
15
+ * magic word → trigger policy → attachments → log → busy policy → queue → dispatch
16
+ *
17
+ * Magic words are matched before the trigger gate — `stop` must never wait on
18
+ * an auto-reply judgment or queue behind a running agent turn. Adapters state
19
+ * platform policy as data (`magicWord`, `busyPolicy`) instead of callbacks.
9
20
  */
10
- export declare function processMessageIntake<TEvent extends ConversationEvent>(options: MessageIntakeOptions<TEvent>): Promise<void>;
21
+ export declare function processMessageIntake<TEvent extends ConversationEvent>(options: MessageIntakeOptions<TEvent>): Promise<MessageIntakeOutcome>;
11
22
  //# sourceMappingURL=intake.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"intake.d.ts","sourceRoot":"","sources":["../../src/adapters/intake.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,SAAS,iBAAiB,EACzE,OAAO,EAAE,oBAAoB,CAAC,MAAM,CAAC,GACpC,OAAO,CAAC,IAAI,CAAC,CAqCf"}
1
+ {"version":3,"file":"intake.d.ts","sourceRoot":"","sources":["../../src/adapters/intake.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAIvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE7E;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE1D;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,SAAS,iBAAiB,EACzE,OAAO,EAAE,oBAAoB,CAAC,MAAM,CAAC,GACpC,OAAO,CAAC,oBAAoB,CAAC,CAoD/B"}
@@ -1,42 +1,99 @@
1
+ import { formatAlreadyWorking, formatNothingRunning } from "../platform-messages.js";
1
2
  import { evaluateAutoReplyPolicy } from "../trigger.js";
3
+ import { resolveOnlyScopedStopTarget, resolveStopTarget } from "./shared.js";
4
+ /**
5
+ * Recognize a magic word: a highest-priority chat control phrase that bypasses
6
+ * trigger policy and queueing (see CONTEXT.md). One grammar for every
7
+ * platform: optional leading slash, optional `@botname` suffix, any case.
8
+ */
9
+ export function matchMagicWord(text) {
10
+ return /^\/?stop(?:@\w+)?$/i.test(text.trim()) ? "stop" : null;
11
+ }
2
12
  /**
3
13
  * Shared message ingress pipeline for platform adapters.
4
14
  *
5
- * Platform adapters still normalize SDK events and handle platform-specific stop
6
- * semantics. This module owns the common trigger/log/attachment/queue/handler
7
- * ordering for messages that may start an agent run.
15
+ * Platform adapters normalize SDK events; this module owns the ordering for
16
+ * messages that may start an agent run:
17
+ *
18
+ * magic word → trigger policy → attachments → log → busy policy → queue → dispatch
19
+ *
20
+ * Magic words are matched before the trigger gate — `stop` must never wait on
21
+ * an auto-reply judgment or queue behind a running agent turn. Adapters state
22
+ * platform policy as data (`magicWord`, `busyPolicy`) instead of callbacks.
8
23
  */
9
24
  export async function processMessageIntake(options) {
25
+ if (matchMagicWord(options.magicWord.text ?? options.eventBase.text) === "stop") {
26
+ options.log?.({ ...options.logEntryBase, attachments: [] });
27
+ await handleStopMagicWord(options);
28
+ return "magic-word";
29
+ }
10
30
  const triggerResult = options.isAutoReplyCandidate
11
31
  ? await evaluateAutoReplyPolicy({ event: options.eventBase, workingDir: options.workingDir })
12
32
  : { trigger: true, reason: "addressed" };
13
33
  if (!triggerResult.trigger) {
14
34
  options.log?.({ ...options.logEntryBase, attachments: [] });
15
- options.onNotTriggered?.();
16
- return;
35
+ return "not-triggered";
36
+ }
37
+ function prepareEvent(attachments) {
38
+ const event = { ...options.eventBase, attachments };
39
+ options.log?.({ ...options.logEntryBase, attachments });
40
+ return event;
41
+ }
42
+ async function rejectedWhileBusy() {
43
+ const sessionKey = options.eventBase.sessionKey ?? options.eventBase.conversationId;
44
+ if (!options.handler.isRunning(sessionKey))
45
+ return false;
46
+ await options.bot.postMessage(options.eventBase.conversationId, formatAlreadyWorking(options.bot, "/stop"));
47
+ return true;
48
+ }
49
+ function dispatch(event) {
50
+ const context = options.createContext(event);
51
+ return options.handler.handleEvent(event, options.bot, context);
17
52
  }
18
53
  if (options.deferAttachmentsUntilRun) {
54
+ // Busy rejection happens inside the queued work here, so the outcome is
55
+ // already "enqueued" by the time it is evaluated.
19
56
  options.enqueue(options.queueKey, async () => {
20
- const attachments = await options.processAttachments();
21
- const event = { ...options.eventBase, attachments };
22
- options.log?.({ ...options.logEntryBase, attachments });
23
- if (options.beforeEnqueue && !(await options.beforeEnqueue(event))) {
57
+ const event = prepareEvent(await options.processAttachments());
58
+ if (options.busyPolicy === "reject" && (await rejectedWhileBusy()))
24
59
  return;
25
- }
26
- const context = options.createContext(event);
27
- return options.handler.handleEvent(event, options.bot, context);
60
+ return dispatch(event);
28
61
  });
29
- return;
62
+ return "enqueued";
63
+ }
64
+ const event = prepareEvent(await options.processAttachments());
65
+ if (options.busyPolicy === "reject" && (await rejectedWhileBusy()))
66
+ return "rejected-busy";
67
+ options.enqueue(options.queueKey, () => dispatch(event));
68
+ return "enqueued";
69
+ }
70
+ /**
71
+ * Resolve and stop the session a magic-word `stop` targets. When nothing is
72
+ * running, reply only if the message addressed the bot — an unaddressed
73
+ * "stop" in a busy channel should never make the bot pipe up.
74
+ */
75
+ async function handleStopMagicWord(options) {
76
+ const { handler, bot, eventBase, magicWord } = options;
77
+ const conversationId = eventBase.conversationId;
78
+ const sessionKey = eventBase.sessionKey;
79
+ let target = resolveStopTarget({ handler, conversationId, sessionKey });
80
+ if (!target && widensToScopedSession(magicWord.scopeFallback, sessionKey, conversationId)) {
81
+ target = resolveOnlyScopedStopTarget(handler, conversationId);
30
82
  }
31
- const attachments = await options.processAttachments();
32
- const event = { ...options.eventBase, attachments };
33
- options.log?.({ ...options.logEntryBase, attachments });
34
- if (options.beforeEnqueue && !(await options.beforeEnqueue(event))) {
35
- return;
83
+ if (target) {
84
+ await handler.handleStop(target, conversationId, bot);
36
85
  }
37
- options.enqueue(options.queueKey, () => {
38
- const context = options.createContext(event);
39
- return options.handler.handleEvent(event, options.bot, context);
40
- });
86
+ else if (magicWord.addressed) {
87
+ await bot.postMessage(conversationId, formatNothingRunning(bot));
88
+ }
89
+ }
90
+ function widensToScopedSession(scopeFallback, sessionKey, conversationId) {
91
+ if (scopeFallback === "never")
92
+ return false;
93
+ if (scopeFallback === "always")
94
+ return true;
95
+ // "top-level": only a message aimed at the persistent conversation session
96
+ // may widen to the single running scoped session; thread messages stay put.
97
+ return sessionKey === undefined || sessionKey === conversationId;
41
98
  }
42
99
  //# sourceMappingURL=intake.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"intake.js","sourceRoot":"","sources":["../../src/adapters/intake.ts"],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GAAG,EAAE,OAAO,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,kBAAkB,EAAE,CAAC;IACvD,MAAM,KAAK,GAAG,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,WAAW,EAAY,CAAC;IAC9D,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,WAAW,EAAE,CAAC,CAAC;IAExD,IAAI,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACnE,OAAO;IACT,CAAC;IAED,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE;QACrC,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { ConversationEvent } from \"../adapter.js\";\nimport { evaluateAutoReplyPolicy } from \"../trigger.js\";\nimport type { MessageIntakeOptions } from \"./types.js\";\n\n/**\n * Shared message ingress pipeline for platform adapters.\n *\n * Platform adapters still normalize SDK events and handle platform-specific stop\n * semantics. This module owns the common trigger/log/attachment/queue/handler\n * ordering for messages that may start an agent run.\n */\nexport async function processMessageIntake<TEvent extends ConversationEvent>(\n options: MessageIntakeOptions<TEvent>,\n): Promise<void> {\n const triggerResult = options.isAutoReplyCandidate\n ? await evaluateAutoReplyPolicy({ event: options.eventBase, workingDir: options.workingDir })\n : ({ trigger: true, reason: \"addressed\" } as const);\n\n if (!triggerResult.trigger) {\n options.log?.({ ...options.logEntryBase, attachments: [] });\n options.onNotTriggered?.();\n return;\n }\n\n if (options.deferAttachmentsUntilRun) {\n options.enqueue(options.queueKey, async () => {\n const attachments = await options.processAttachments();\n const event = { ...options.eventBase, attachments } as TEvent;\n options.log?.({ ...options.logEntryBase, attachments });\n if (options.beforeEnqueue && !(await options.beforeEnqueue(event))) {\n return;\n }\n const context = options.createContext(event);\n return options.handler.handleEvent(event, options.bot, context);\n });\n return;\n }\n\n const attachments = await options.processAttachments();\n const event = { ...options.eventBase, attachments } as TEvent;\n options.log?.({ ...options.logEntryBase, attachments });\n\n if (options.beforeEnqueue && !(await options.beforeEnqueue(event))) {\n return;\n }\n\n options.enqueue(options.queueKey, () => {\n const context = options.createContext(event);\n return options.handler.handleEvent(event, options.bot, context);\n });\n}\n"]}
1
+ {"version":3,"file":"intake.js","sourceRoot":"","sources":["../../src/adapters/intake.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAG7E;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACjE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAAqC;IAErC,IAAI,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,IAAI,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,MAAM,EAAE,CAAC;QAChF,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5D,MAAM,mBAAmB,CAAC,OAAO,CAAC,CAAC;QACnC,OAAO,YAAY,CAAC;I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,EAAE,cAAc,CAAC,EAAE,CAAC;QAC1F,MAAM,GAAG,2BAA2B,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAChE,CAAC;IAED,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC;IACxD,CAAC;SAAM,IAAI,SAAS,CAAC,SAAS,EAAE,CAAC;QAC/B,MAAM,GAAG,CAAC,WAAW,CAAC,cAAc,EAAE,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAC5B,aAA+C,EAC/C,UAA8B,EAC9B,cAAsB;IAEtB,IAAI,aAAa,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,aAAa,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC5C,2EAA2E;IAC3E,4EAA4E;IAC5E,OAAO,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,cAAc,CAAC;AACnE,CAAC","sourcesContent":["import type { ConversationEvent } from \"../adapter.js\";\nimport { formatAlreadyWorking, formatNothingRunning } from \"../platform-messages.js\";\nimport { evaluateAutoReplyPolicy } from \"../trigger.js\";\nimport { resolveOnlyScopedStopTarget, resolveStopTarget } from \"./shared.js\";\nimport type { MessageIntakeOptions, MessageIntakeOutcome } from \"./types.js\";\n\n/**\n * Recognize a magic word: a highest-priority chat control phrase that bypasses\n * trigger policy and queueing (see CONTEXT.md). One grammar for every\n * platform: optional leading slash, optional `@botname` suffix, any case.\n */\nexport function matchMagicWord(text: string): \"stop\" | null {\n return /^\\/?stop(?:@\\w+)?$/i.test(text.trim()) ? \"stop\" : null;\n}\n\n/**\n * Shared message ingress pipeline for platform adapters.\n *\n * Platform adapters normalize SDK events; this module owns the ordering for\n * messages that may start an agent run:\n *\n * magic word → trigger policy → attachments → log → busy policy → queue → dispatch\n *\n * Magic words are matched before the trigger gate — `stop` must never wait on\n * an auto-reply judgment or queue behind a running agent turn. Adapters state\n * platform policy as data (`magicWord`, `busyPolicy`) instead of callbacks.\n */\nexport async function processMessageIntake<TEvent extends ConversationEvent>(\n options: MessageIntakeOptions<TEvent>,\n): Promise<MessageIntakeOutcome> {\n if (matchMagicWord(options.magicWord.text ?? options.eventBase.text) === \"stop\") {\n options.log?.({ ...options.logEntryBase, attachments: [] });\n await handleStopMagicWord(options);\n return \"magic-word\";\n }\n\n const triggerResult = options.isAutoReplyCandidate\n ? await evaluateAutoReplyPolicy({ event: options.eventBase, workingDir: options.workingDir })\n : ({ trigger: true, reason: \"addressed\" } as const);\n\n if (!triggerResult.trigger) {\n options.log?.({ ...options.logEntryBase, attachments: [] });\n return \"not-triggered\";\n }\n\n function prepareEvent(attachments: unknown[]): TEvent {\n const event = { ...options.eventBase, attachments } as TEvent;\n options.log?.({ ...options.logEntryBase, attachments });\n return event;\n }\n\n async function rejectedWhileBusy(): Promise<boolean> {\n const sessionKey = options.eventBase.sessionKey ?? options.eventBase.conversationId;\n if (!options.handler.isRunning(sessionKey)) return false;\n await options.bot.postMessage(\n options.eventBase.conversationId,\n formatAlreadyWorking(options.bot, \"/stop\"),\n );\n return true;\n }\n\n function dispatch(event: TEvent): Promise<void> {\n const context = options.createContext(event);\n return options.handler.handleEvent(event, options.bot, context);\n }\n\n if (options.deferAttachmentsUntilRun) {\n // Busy rejection happens inside the queued work here, so the outcome is\n // already \"enqueued\" by the time it is evaluated.\n options.enqueue(options.queueKey, async () => {\n const event = prepareEvent(await options.processAttachments());\n if (options.busyPolicy === \"reject\" && (await rejectedWhileBusy())) return;\n return dispatch(event);\n });\n return \"enqueued\";\n }\n\n const event = prepareEvent(await options.processAttachments());\n if (options.busyPolicy === \"reject\" && (await rejectedWhileBusy())) return \"rejected-busy\";\n options.enqueue(options.queueKey, () => dispatch(event));\n return \"enqueued\";\n}\n\n/**\n * Resolve and stop the session a magic-word `stop` targets. When nothing is\n * running, reply only if the message addressed the bot — an unaddressed\n * \"stop\" in a busy channel should never make the bot pipe up.\n */\nasync function handleStopMagicWord<TEvent extends ConversationEvent>(\n options: MessageIntakeOptions<TEvent>,\n): Promise<void> {\n const { handler, bot, eventBase, magicWord } = options;\n const conversationId = eventBase.conversationId;\n const sessionKey = eventBase.sessionKey;\n\n let target = resolveStopTarget({ handler, conversationId, sessionKey });\n if (!target && widensToScopedSession(magicWord.scopeFallback, sessionKey, conversationId)) {\n target = resolveOnlyScopedStopTarget(handler, conversationId);\n }\n\n if (target) {\n await handler.handleStop(target, conversationId, bot);\n } else if (magicWord.addressed) {\n await bot.postMessage(conversationId, formatNothingRunning(bot));\n }\n}\n\nfunction widensToScopedSession(\n scopeFallback: \"top-level\" | \"always\" | \"never\",\n sessionKey: string | undefined,\n conversationId: string,\n): boolean {\n if (scopeFallback === \"never\") return false;\n if (scopeFallback === \"always\") return true;\n // \"top-level\": only a message aimed at the persistent conversation session\n // may widen to the single running scoped session; thread messages stay put.\n return sessionKey === undefined || sessionKey === conversationId;\n}\n"]}
@@ -38,6 +38,7 @@ export declare class SlackMessagingBot implements MessagingBot {
38
38
  getAllChannels(): SlackChannel[];
39
39
  private stripOwnMention;
40
40
  postMessage(channel: string, text: string): Promise<string>;
41
+ addReaction(channel: string, messageTs: string, emoji: string): Promise<void>;
41
42
  postEphemeral(channel: string, user: string, text: string, threadTs?: string): Promise<void>;
42
43
  postEphemeralBlocks(channel: string, user: string, text: string, blocks: object[], threadTs?: string): Promise<void>;
43
44
  postMessageBlocks(channel: string, text: string, blocks: object[]): Promise<string>;
@@ -69,15 +70,16 @@ export declare class SlackMessagingBot implements MessagingBot {
69
70
  private hasKnownThreadSession;
70
71
  private processSlackMessageIntake;
71
72
  private buildHomeView;
72
- private resolveStopTarget;
73
- private isStopText;
74
73
  private createCommandAdapters;
75
74
  private buildSlashCommandEvent;
76
- private routeSlashLoginCommand;
75
+ /**
76
+ * Generic slash-command route: synthesize the command text per the
77
+ * manifest's SlackSlashRoute data and dispatch to the handler. `/pi-new`
78
+ * stays bespoke (routeSlashNewCommand) because it replies in 中文 and calls
79
+ * handleNewCommand directly.
80
+ */
81
+ private routeSlashCommand;
77
82
  private routeSlashNewCommand;
78
- private routeSlashModelCommand;
79
- private routeSlashSessionCommand;
80
- private routeSlashAdminCommand;
81
83
  private setupEventHandlers;
82
84
  private handleAppMention;
83
85
  private handleMessageEvent;