@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,53 @@
1
+ /**
2
+ * Conversation id for one issue/PR: `GH_<owner>_<repo>_<number>`.
3
+ *
4
+ * DESIGN.md originally proposed `gh:<owner>/<repo>#<number>`, but conversation
5
+ * ids are used verbatim as a single path segment (LAYOUT.md § Casing) and the
6
+ * conversation dir is bind-mounted with docker's `-v source:target` syntax in
7
+ * image mode — so the id can contain neither `/` nor `:`. `_` is the
8
+ * separator because it is the only inert character that also parses back
9
+ * unambiguously under GitHub's name grammar: owners allow `-` (so `-` would
10
+ * make the owner/repo boundary ambiguous) but never `_`, repos may contain
11
+ * `_` but the trailing number is pure digits — so the first `_` and the last
12
+ * `_` before the digits are always the real boundaries.
13
+ *
14
+ * Owner and repo are lowercased: GitHub names are case-insensitive (and this
15
+ * id has two spelling sources — the GITHUB_REPOS env var and API payloads),
16
+ * so per LAYOUT.md § Casing this is a mikan-derived slug, not a verbatim
17
+ * platform id, and derived slugs are lowercased to keep one issue from
18
+ * mapping to two conversation dirs on case-sensitive filesystems.
19
+ */
20
+ export function buildGithubConversationId(ref) {
21
+ return `GH_${ref.owner.toLowerCase()}_${ref.repo.toLowerCase()}_${ref.number}`;
22
+ }
23
+ const CONVERSATION_ID_PATTERN = /^GH_([A-Za-z0-9-]+)_(.+)_(\d+)$/;
24
+ export function parseGithubConversationId(conversationId) {
25
+ // The greedy repo group splits at the last `_` followed by digits-to-end,
26
+ // which is always the number boundary (repos may contain `_` themselves).
27
+ const match = CONVERSATION_ID_PATTERN.exec(conversationId);
28
+ if (!match) {
29
+ throw new Error(`Not a GitHub conversation id: ${conversationId}`);
30
+ }
31
+ return {
32
+ owner: match[1].toLowerCase(),
33
+ repo: match[2].toLowerCase(),
34
+ number: Number(match[3]),
35
+ };
36
+ }
37
+ /** Message ts used for the issue/PR body itself (comments use their comment id). */
38
+ export const GITHUB_ISSUE_BODY_TS = "issue";
39
+ /**
40
+ * Message ts for an inline PR review comment: `rc-<id>`. Review-comment ids
41
+ * live in a different id space than issue-comment ids, and several endpoints
42
+ * (reactions, edits) differ by family — the prefix makes routing a review id
43
+ * to an issue-comment endpoint structurally impossible.
44
+ */
45
+ export function githubReviewCommentTs(commentId) {
46
+ return `rc-${commentId}`;
47
+ }
48
+ /** The review-comment id inside an `rc-<id>` ts, or null for other ts kinds. */
49
+ export function parseReviewCommentTs(ts) {
50
+ const match = /^rc-(\d+)$/.exec(ts);
51
+ return match ? Number(match[1]) : null;
52
+ }
53
+ //# sourceMappingURL=ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.js","sourceRoot":"","sources":["../../../src/adapters/github/ids.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,yBAAyB,CAAC,GAA0B;IAClE,OAAO,MAAM,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;AACjF,CAAC;AAED,MAAM,uBAAuB,GAAG,iCAAiC,CAAC;AAElE,MAAM,UAAU,yBAAyB,CAAC,cAAsB;IAC9D,0EAA0E;IAC1E,0EAA0E;IAC1E,MAAM,KAAK,GAAG,uBAAuB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,iCAAiC,cAAc,EAAE,CAAC,CAAC;IACrE,CAAC;IACD,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;QAC7B,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;QAC5B,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACzB,CAAC;AACJ,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAiB;IACrD,OAAO,MAAM,SAAS,EAAE,CAAC;AAC3B,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,oBAAoB,CAAC,EAAU;IAC7C,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpC,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACzC,CAAC","sourcesContent":["import type { GithubConversationRef } from \"./types.js\";\n\n/**\n * Conversation id for one issue/PR: `GH_<owner>_<repo>_<number>`.\n *\n * DESIGN.md originally proposed `gh:<owner>/<repo>#<number>`, but conversation\n * ids are used verbatim as a single path segment (LAYOUT.md § Casing) and the\n * conversation dir is bind-mounted with docker's `-v source:target` syntax in\n * image mode — so the id can contain neither `/` nor `:`. `_` is the\n * separator because it is the only inert character that also parses back\n * unambiguously under GitHub's name grammar: owners allow `-` (so `-` would\n * make the owner/repo boundary ambiguous) but never `_`, repos may contain\n * `_` but the trailing number is pure digits — so the first `_` and the last\n * `_` before the digits are always the real boundaries.\n *\n * Owner and repo are lowercased: GitHub names are case-insensitive (and this\n * id has two spelling sources — the GITHUB_REPOS env var and API payloads),\n * so per LAYOUT.md § Casing this is a mikan-derived slug, not a verbatim\n * platform id, and derived slugs are lowercased to keep one issue from\n * mapping to two conversation dirs on case-sensitive filesystems.\n */\nexport function buildGithubConversationId(ref: GithubConversationRef): string {\n return `GH_${ref.owner.toLowerCase()}_${ref.repo.toLowerCase()}_${ref.number}`;\n}\n\nconst CONVERSATION_ID_PATTERN = /^GH_([A-Za-z0-9-]+)_(.+)_(\\d+)$/;\n\nexport function parseGithubConversationId(conversationId: string): GithubConversationRef {\n // The greedy repo group splits at the last `_` followed by digits-to-end,\n // which is always the number boundary (repos may contain `_` themselves).\n const match = CONVERSATION_ID_PATTERN.exec(conversationId);\n if (!match) {\n throw new Error(`Not a GitHub conversation id: ${conversationId}`);\n }\n return {\n owner: match[1].toLowerCase(),\n repo: match[2].toLowerCase(),\n number: Number(match[3]),\n };\n}\n\n/** Message ts used for the issue/PR body itself (comments use their comment id). */\nexport const GITHUB_ISSUE_BODY_TS = \"issue\";\n\n/**\n * Message ts for an inline PR review comment: `rc-<id>`. Review-comment ids\n * live in a different id space than issue-comment ids, and several endpoints\n * (reactions, edits) differ by family — the prefix makes routing a review id\n * to an issue-comment endpoint structurally impossible.\n */\nexport function githubReviewCommentTs(commentId: number): string {\n return `rc-${commentId}`;\n}\n\n/** The review-comment id inside an `rc-<id>` ts, or null for other ts kinds. */\nexport function parseReviewCommentTs(ts: string): number | null {\n const match = /^rc-(\\d+)$/.exec(ts);\n return match ? Number(match[1]) : null;\n}\n"]}
@@ -0,0 +1,32 @@
1
+ import type { CloneRepoOptions, PushBranchOptions, SyncRepoOptions, SyncRepoResult } from "./types.js";
2
+ /**
3
+ * Branches the bot may push: `pi/<name>`. Everything else — including the
4
+ * repo's default branch by construction — is refused, so a driven agent can
5
+ * only ever produce reviewable branches, never touch mainline directly.
6
+ */
7
+ export declare const GITHUB_PUSH_BRANCH_PATTERN: RegExp;
8
+ /** The conversation's clone location (bind-mounted into the sandbox as ./repo). */
9
+ export declare function conversationRepoDir(workingDir: string, conversationId: string): string;
10
+ /**
11
+ * Shallow-clone a repo into a conversation dir and preconfigure the bot's
12
+ * commit identity. For PR conversations, additionally fetch the PR head and
13
+ * check it out so the agent starts on the code under review — under its real
14
+ * branch name when the caller resolved one, which is what lets the agent push
15
+ * fixes back to the PR itself.
16
+ */
17
+ export declare function cloneRepo(options: CloneRepoOptions): Promise<void>;
18
+ /**
19
+ * Refresh a conversation clone from origin. Always fetches; only moves the
20
+ * checkout when that provably cannot lose agent work: the target branch is
21
+ * the one checked out, the tree is clean, and it has no commits of its own
22
+ * (`checkout -B` then handles fast-forward and force-pushed heads alike).
23
+ * Anything else stays fetch-only — FETCH_HEAD is left for the agent, which
24
+ * has full credential-less git inside the sandbox, to merge or rebase itself.
25
+ */
26
+ export declare function syncRepo(options: SyncRepoOptions): Promise<SyncRepoResult>;
27
+ /**
28
+ * Push one local branch to origin. Non-force by construction (plain refspec),
29
+ * and only `pi/*` branches are accepted.
30
+ */
31
+ export declare function pushBranch(options: PushBranchOptions): Promise<void>;
32
+ //# sourceMappingURL=repo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../../src/adapters/github/repo.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACf,MAAM,YAAY,CAAC;AAMpB;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,QAAwC,CAAC;AAEhF,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAEtF;AA0CD;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBxE;AAED;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CA8ChF;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAa1E"}
@@ -0,0 +1,141 @@
1
+ import { execFile } from "child_process";
2
+ import { join } from "path";
3
+ import { promisify } from "util";
4
+ const execFileAsync = promisify(execFile);
5
+ const GIT_TIMEOUT_MS = 120_000;
6
+ /**
7
+ * Branches the bot may push: `pi/<name>`. Everything else — including the
8
+ * repo's default branch by construction — is refused, so a driven agent can
9
+ * only ever produce reviewable branches, never touch mainline directly.
10
+ */
11
+ export const GITHUB_PUSH_BRANCH_PATTERN = /^pi\/[A-Za-z0-9._][A-Za-z0-9._/-]*$/;
12
+ /** The conversation's clone location (bind-mounted into the sandbox as ./repo). */
13
+ export function conversationRepoDir(workingDir, conversationId) {
14
+ return join(workingDir, conversationId, "repo");
15
+ }
16
+ /**
17
+ * Pass the ephemeral token as a per-invocation header, never in the remote
18
+ * URL: nothing credential-shaped may end up in `.git/config`, which lives in
19
+ * the conversation dir and is bind-mounted into the sandbox.
20
+ */
21
+ function gitAuthArgs(token) {
22
+ const basic = Buffer.from(`x-access-token:${token}`).toString("base64");
23
+ return ["-c", `http.extraheader=Authorization: basic ${basic}`];
24
+ }
25
+ async function git(args, token) {
26
+ const { stdout } = await execFileAsync("git", [...(token ? gitAuthArgs(token) : []), ...args], {
27
+ timeout: GIT_TIMEOUT_MS,
28
+ env: { ...process.env, GIT_TERMINAL_PROMPT: "0" },
29
+ });
30
+ return stdout;
31
+ }
32
+ /**
33
+ * Git itself rejects these ref shapes; the check just keeps an API-supplied
34
+ * branch name that would parse as a git option (leading dash) or an invalid
35
+ * ref out of argv entirely instead of surfacing as a git error mid-clone.
36
+ */
37
+ function isSafeBranchName(name) {
38
+ return (name.length > 0 && !name.startsWith("-") && !name.includes("..") && !/[\s~^:?*[\\]/.test(name));
39
+ }
40
+ /**
41
+ * Local checkout name for a PR conversation: the PR's real head branch when
42
+ * known (same-repo heads only — the caller resolves that), falling back to
43
+ * the synthetic `pr-<n>` for fork PRs, unresolvable heads, and unsafe names.
44
+ * Using the real name is what lets the agent update the PR in place: commit
45
+ * on a `pi/*` head and `github_pr` pushes back to the same branch.
46
+ */
47
+ function prCheckoutName(prNumber, prHeadBranch) {
48
+ return prHeadBranch && isSafeBranchName(prHeadBranch) ? prHeadBranch : `pr-${prNumber}`;
49
+ }
50
+ /**
51
+ * Shallow-clone a repo into a conversation dir and preconfigure the bot's
52
+ * commit identity. For PR conversations, additionally fetch the PR head and
53
+ * check it out so the agent starts on the code under review — under its real
54
+ * branch name when the caller resolved one, which is what lets the agent push
55
+ * fixes back to the PR itself.
56
+ */
57
+ export async function cloneRepo(options) {
58
+ await git(["clone", "--depth", "50", options.url, options.dir], options.token);
59
+ await git(["-C", options.dir, "config", "user.name", options.botLogin]);
60
+ await git(["-C", options.dir, "config", "user.email", options.botEmail]);
61
+ if (options.prNumber !== undefined) {
62
+ await git(["-C", options.dir, "fetch", "--depth", "50", "origin", `pull/${options.prNumber}/head`], options.token);
63
+ await git([
64
+ "-C",
65
+ options.dir,
66
+ "checkout",
67
+ "-B",
68
+ prCheckoutName(options.prNumber, options.prHeadBranch),
69
+ "FETCH_HEAD",
70
+ ]);
71
+ }
72
+ }
73
+ /**
74
+ * Refresh a conversation clone from origin. Always fetches; only moves the
75
+ * checkout when that provably cannot lose agent work: the target branch is
76
+ * the one checked out, the tree is clean, and it has no commits of its own
77
+ * (`checkout -B` then handles fast-forward and force-pushed heads alike).
78
+ * Anything else stays fetch-only — FETCH_HEAD is left for the agent, which
79
+ * has full credential-less git inside the sandbox, to merge or rebase itself.
80
+ */
81
+ export async function syncRepo(options) {
82
+ const { dir, token } = options;
83
+ let refspec;
84
+ let target;
85
+ if (options.branch) {
86
+ refspec = options.branch;
87
+ target = options.branch;
88
+ }
89
+ else if (options.prNumber !== undefined) {
90
+ refspec = `pull/${options.prNumber}/head`;
91
+ target = prCheckoutName(options.prNumber, options.prHeadBranch);
92
+ }
93
+ else if (options.defaultBranch) {
94
+ refspec = options.defaultBranch;
95
+ target = options.defaultBranch;
96
+ }
97
+ else {
98
+ throw new Error("syncRepo needs a branch, a PR number, or the default branch");
99
+ }
100
+ await git(["-C", dir, "fetch", "--depth", "50", "origin", refspec], token);
101
+ const fetchedSha = (await git(["-C", dir, "rev-parse", "FETCH_HEAD"])).trim();
102
+ const dirty = (await git(["-C", dir, "status", "--porcelain"])).trim().length > 0;
103
+ const currentBranch = (await git(["-C", dir, "rev-parse", "--abbrev-ref", "HEAD"])).trim();
104
+ // Clones made before the head branch name was resolvable sit on the
105
+ // synthetic pr-<n>; treat that as the same checkout so a clean sync
106
+ // migrates them to the real name instead of going fetch-only forever.
107
+ const legacyPrBranch = options.prNumber !== undefined ? `pr-${options.prNumber}` : undefined;
108
+ const onTarget = currentBranch === target || (legacyPrBranch !== undefined && currentBranch === legacyPrBranch);
109
+ let localCommits = 0;
110
+ if (onTarget) {
111
+ // Commits unique to HEAD split two ways: ones the agent committed here
112
+ // (the clone's preconfigured bot identity) are its work and must survive;
113
+ // ones committed by others were force-pushed away upstream and are safe
114
+ // to drop. Filter by the bot committer so a rebased PR head still syncs.
115
+ const botEmail = (await git(["-C", dir, "config", "user.email"])).trim();
116
+ localCommits = Number((await git(["-C", dir, "rev-list", "--count", `--committer=${botEmail}`, "FETCH_HEAD..HEAD"])).trim());
117
+ }
118
+ const updatedCheckout = onTarget && !dirty && localCommits === 0;
119
+ if (updatedCheckout) {
120
+ await git(["-C", dir, "checkout", "-B", target, "FETCH_HEAD"]);
121
+ }
122
+ return { target, fetchedSha, updatedCheckout, dirty, currentBranch, localCommits };
123
+ }
124
+ /**
125
+ * Push one local branch to origin. Non-force by construction (plain refspec),
126
+ * and only `pi/*` branches are accepted.
127
+ */
128
+ export async function pushBranch(options) {
129
+ const { dir, branch, token } = options;
130
+ if (!GITHUB_PUSH_BRANCH_PATTERN.test(branch)) {
131
+ throw new Error(`Refusing to push branch '${branch}': only branches matching pi/<name> may be pushed.`);
132
+ }
133
+ try {
134
+ await git(["-C", dir, "rev-parse", "--verify", "--quiet", `refs/heads/${branch}`]);
135
+ }
136
+ catch {
137
+ throw new Error(`Branch '${branch}' does not exist in the conversation's ./repo clone.`);
138
+ }
139
+ await git(["-C", dir, "push", "origin", `refs/heads/${branch}:refs/heads/${branch}`], token);
140
+ }
141
+ //# sourceMappingURL=repo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo.js","sourceRoot":"","sources":["../../../src/adapters/github/repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAQjC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,cAAc,GAAG,OAAO,CAAC;AAE/B;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,qCAAqC,CAAC;AAEhF,mFAAmF;AACnF,MAAM,UAAU,mBAAmB,CAAC,UAAkB,EAAE,cAAsB;IAC5E,OAAO,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,KAAa;IAChC,MAAM,KAA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IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,MAAM,eAAe,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;AAC/F,CAAC","sourcesContent":["import { execFile } from \"child_process\";\nimport { join } from \"path\";\nimport { promisify } from \"util\";\nimport type {\n CloneRepoOptions,\n PushBranchOptions,\n SyncRepoOptions,\n SyncRepoResult,\n} from \"./types.js\";\n\nconst execFileAsync = promisify(execFile);\n\nconst GIT_TIMEOUT_MS = 120_000;\n\n/**\n * Branches the bot may push: `pi/<name>`. Everything else — including the\n * repo's default branch by construction — is refused, so a driven agent can\n * only ever produce reviewable branches, never touch mainline directly.\n */\nexport const GITHUB_PUSH_BRANCH_PATTERN = /^pi\\/[A-Za-z0-9._][A-Za-z0-9._/-]*$/;\n\n/** The conversation's clone location (bind-mounted into the sandbox as ./repo). */\nexport function conversationRepoDir(workingDir: string, conversationId: string): string {\n return join(workingDir, conversationId, \"repo\");\n}\n\n/**\n * Pass the ephemeral token as a per-invocation header, never in the remote\n * URL: nothing credential-shaped may end up in `.git/config`, which lives in\n * the conversation dir and is bind-mounted into the sandbox.\n */\nfunction gitAuthArgs(token: string): string[] {\n const basic = Buffer.from(`x-access-token:${token}`).toString(\"base64\");\n return [\"-c\", `http.extraheader=Authorization: basic ${basic}`];\n}\n\nasync function git(args: string[], token?: string): Promise<string> {\n const { stdout } = await execFileAsync(\"git\", [...(token ? gitAuthArgs(token) : []), ...args], {\n timeout: GIT_TIMEOUT_MS,\n env: { ...process.env, GIT_TERMINAL_PROMPT: \"0\" },\n });\n return stdout;\n}\n\n/**\n * Git itself rejects these ref shapes; the check just keeps an API-supplied\n * branch name that would parse as a git option (leading dash) or an invalid\n * ref out of argv entirely instead of surfacing as a git error mid-clone.\n */\nfunction isSafeBranchName(name: string): boolean {\n return (\n name.length > 0 && !name.startsWith(\"-\") && !name.includes(\"..\") && !/[\\s~^:?*[\\\\]/.test(name)\n );\n}\n\n/**\n * Local checkout name for a PR conversation: the PR's real head branch when\n * known (same-repo heads only — the caller resolves that), falling back to\n * the synthetic `pr-<n>` for fork PRs, unresolvable heads, and unsafe names.\n * Using the real name is what lets the agent update the PR in place: commit\n * on a `pi/*` head and `github_pr` pushes back to the same branch.\n */\nfunction prCheckoutName(prNumber: number, prHeadBranch?: string): string {\n return prHeadBranch && isSafeBranchName(prHeadBranch) ? prHeadBranch : `pr-${prNumber}`;\n}\n\n/**\n * Shallow-clone a repo into a conversation dir and preconfigure the bot's\n * commit identity. For PR conversations, additionally fetch the PR head and\n * check it out so the agent starts on the code under review — under its real\n * branch name when the caller resolved one, which is what lets the agent push\n * fixes back to the PR itself.\n */\nexport async function cloneRepo(options: CloneRepoOptions): Promise<void> {\n await git([\"clone\", \"--depth\", \"50\", options.url, options.dir], options.token);\n await git([\"-C\", options.dir, \"config\", \"user.name\", options.botLogin]);\n await git([\"-C\", options.dir, \"config\", \"user.email\", options.botEmail]);\n if (options.prNumber !== undefined) {\n await git(\n [\"-C\", options.dir, \"fetch\", \"--depth\", \"50\", \"origin\", `pull/${options.prNumber}/head`],\n options.token,\n );\n await git([\n \"-C\",\n options.dir,\n \"checkout\",\n \"-B\",\n prCheckoutName(options.prNumber, options.prHeadBranch),\n \"FETCH_HEAD\",\n ]);\n }\n}\n\n/**\n * Refresh a conversation clone from origin. Always fetches; only moves the\n * checkout when that provably cannot lose agent work: the target branch is\n * the one checked out, the tree is clean, and it has no commits of its own\n * (`checkout -B` then handles fast-forward and force-pushed heads alike).\n * Anything else stays fetch-only — FETCH_HEAD is left for the agent, which\n * has full credential-less git inside the sandbox, to merge or rebase itself.\n */\nexport async function syncRepo(options: SyncRepoOptions): Promise<SyncRepoResult> {\n const { dir, token } = options;\n let refspec: string;\n let target: string;\n if (options.branch) {\n refspec = options.branch;\n target = options.branch;\n } else if (options.prNumber !== undefined) {\n refspec = `pull/${options.prNumber}/head`;\n target = prCheckoutName(options.prNumber, options.prHeadBranch);\n } else if (options.defaultBranch) {\n refspec = options.defaultBranch;\n target = options.defaultBranch;\n } else {\n throw new Error(\"syncRepo needs a branch, a PR number, or the default branch\");\n }\n\n await git([\"-C\", dir, \"fetch\", \"--depth\", \"50\", \"origin\", refspec], token);\n const fetchedSha = (await git([\"-C\", dir, \"rev-parse\", \"FETCH_HEAD\"])).trim();\n const dirty = (await git([\"-C\", dir, \"status\", \"--porcelain\"])).trim().length > 0;\n const currentBranch = (await git([\"-C\", dir, \"rev-parse\", \"--abbrev-ref\", \"HEAD\"])).trim();\n // Clones made before the head branch name was resolvable sit on the\n // synthetic pr-<n>; treat that as the same checkout so a clean sync\n // migrates them to the real name instead of going fetch-only forever.\n const legacyPrBranch = options.prNumber !== undefined ? `pr-${options.prNumber}` : undefined;\n const onTarget =\n currentBranch === target || (legacyPrBranch !== undefined && currentBranch === legacyPrBranch);\n let localCommits = 0;\n if (onTarget) {\n // Commits unique to HEAD split two ways: ones the agent committed here\n // (the clone's preconfigured bot identity) are its work and must survive;\n // ones committed by others were force-pushed away upstream and are safe\n // to drop. Filter by the bot committer so a rebased PR head still syncs.\n const botEmail = (await git([\"-C\", dir, \"config\", \"user.email\"])).trim();\n localCommits = Number(\n (\n await git([\"-C\", dir, \"rev-list\", \"--count\", `--committer=${botEmail}`, \"FETCH_HEAD..HEAD\"])\n ).trim(),\n );\n }\n\n const updatedCheckout = onTarget && !dirty && localCommits === 0;\n if (updatedCheckout) {\n await git([\"-C\", dir, \"checkout\", \"-B\", target, \"FETCH_HEAD\"]);\n }\n return { target, fetchedSha, updatedCheckout, dirty, currentBranch, localCommits };\n}\n\n/**\n * Push one local branch to origin. Non-force by construction (plain refspec),\n * and only `pi/*` branches are accepted.\n */\nexport async function pushBranch(options: PushBranchOptions): Promise<void> {\n const { dir, branch, token } = options;\n if (!GITHUB_PUSH_BRANCH_PATTERN.test(branch)) {\n throw new Error(\n `Refusing to push branch '${branch}': only branches matching pi/<name> may be pushed.`,\n );\n }\n try {\n await git([\"-C\", dir, \"rev-parse\", \"--verify\", \"--quiet\", `refs/heads/${branch}`]);\n } catch {\n throw new Error(`Branch '${branch}' does not exist in the conversation's ./repo clone.`);\n }\n await git([\"-C\", dir, \"push\", \"origin\", `refs/heads/${branch}:refs/heads/${branch}`], token);\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import type { PlatformToolPack } from "../../tools/types.js";
2
+ import type { PlatformGithubOps } from "./types.js";
3
+ /**
4
+ * GitHub host-side capability pack — one tool per module under `tools/`:
5
+ * github_pr, github_checks, github_review_reply, github_sync, github_read,
6
+ * github_issue.
7
+ *
8
+ * These tools never run in the sandbox; they call PlatformGithubOps which
9
+ * mints short-lived installation tokens on the host. The pack is only
10
+ * constructed when the GitHub bot is configured; bindRun enables the tools
11
+ * only for github-named conversations so multi-platform processes stay safe.
12
+ */
13
+ export declare function createGithubToolPack(ops: PlatformGithubOps): PlatformToolPack;
14
+ //# sourceMappingURL=tool-pack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-pack.d.ts","sourceRoot":"","sources":["../../../src/adapters/github/tool-pack.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,iBAAiB,GAAG,gBAAgB,CA0C7E"}
@@ -0,0 +1,56 @@
1
+ import { createGithubChecksTool } from "./tools/checks.js";
2
+ import { createGithubPrTool } from "./tools/pr.js";
3
+ import { createGithubIssueTool } from "./tools/issue.js";
4
+ import { createGithubReadTool } from "./tools/read.js";
5
+ import { createGithubReviewReplyTool } from "./tools/review-reply.js";
6
+ import { createGithubSyncTool } from "./tools/sync.js";
7
+ /**
8
+ * GitHub host-side capability pack — one tool per module under `tools/`:
9
+ * github_pr, github_checks, github_review_reply, github_sync, github_read,
10
+ * github_issue.
11
+ *
12
+ * These tools never run in the sandbox; they call PlatformGithubOps which
13
+ * mints short-lived installation tokens on the host. The pack is only
14
+ * constructed when the GitHub bot is configured; bindRun enables the tools
15
+ * only for github-named conversations so multi-platform processes stay safe.
16
+ */
17
+ export function createGithubToolPack(ops) {
18
+ const { tool: githubPrTool, setGithubPrFunction } = createGithubPrTool();
19
+ const { tool: githubChecksTool, setGithubChecksFunction } = createGithubChecksTool();
20
+ const { tool: githubReviewReplyTool, setGithubReviewReplyFunction } = createGithubReviewReplyTool();
21
+ const { tool: githubSyncTool, setGithubSyncFunction } = createGithubSyncTool();
22
+ const { tool: githubReadTool, setGithubReadFunction } = createGithubReadTool();
23
+ const { tool: githubIssueTool, setGithubIssueFunction } = createGithubIssueTool();
24
+ return {
25
+ tools: [
26
+ githubPrTool,
27
+ githubChecksTool,
28
+ githubReviewReplyTool,
29
+ githubSyncTool,
30
+ githubReadTool,
31
+ githubIssueTool,
32
+ ],
33
+ bindRun({ conversationId, platformName }) {
34
+ if (platformName !== "github") {
35
+ setGithubPrFunction(null);
36
+ setGithubChecksFunction(null);
37
+ setGithubReviewReplyFunction(null);
38
+ setGithubSyncFunction(null);
39
+ setGithubReadFunction(null);
40
+ setGithubIssueFunction(null);
41
+ return;
42
+ }
43
+ setGithubPrFunction((request) => ops.pushAndCreatePr(conversationId, request));
44
+ setGithubChecksFunction({
45
+ getChecks: (branch) => ops.getChecks(conversationId, branch),
46
+ getJobLog: (jobId) => ops.getJobLog(conversationId, jobId),
47
+ getBuildLog: (buildId) => ops.getBuildLog(conversationId, buildId),
48
+ });
49
+ setGithubReviewReplyFunction((commentId, body) => ops.replyToReviewThread(conversationId, commentId, body));
50
+ setGithubSyncFunction((branch) => ops.syncRepo(conversationId, branch));
51
+ setGithubReadFunction((request) => ops.readGithub(conversationId, request));
52
+ setGithubIssueFunction((request) => ops.manageIssue(conversationId, request));
53
+ },
54
+ };
55
+ }
56
+ //# sourceMappingURL=tool-pack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-pack.js","sourceRoot":"","s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,CAAC,CAAC;gBACnC,qBAAqB,CAAC,IAAI,CAAC,CAAC;gBAC5B,qBAAqB,CAAC,IAAI,CAAC,CAAC;gBAC5B,sBAAsB,CAAC,IAAI,CAAC,CAAC;gBAC7B,OAAO;YACT,CAAC;YACD,mBAAmB,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;YAC/E,uBAAuB,CAAC;gBACtB,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;gBAC5D,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,KAAK,CAAC;gBAC1D,WAAW,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,cAAc,EAAE,OAAO,CAAC;aACnE,CAAC,CAAC;YACH,4BAA4B,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAC/C,GAAG,CAAC,mBAAmB,CAAC,cAAc,EAAE,SAAS,EAAE,IAAI,CAAC,CACzD,CAAC;YACF,qBAAqB,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;YACxE,qBAAqB,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;YAC5E,sBAAsB,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;QAChF,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { createGithubChecksTool } from \"./tools/checks.js\";\nimport { createGithubPrTool } from \"./tools/pr.js\";\nimport { createGithubIssueTool } from \"./tools/issue.js\";\nimport { createGithubReadTool } from \"./tools/read.js\";\nimport { createGithubReviewReplyTool } from \"./tools/review-reply.js\";\nimport { createGithubSyncTool } from \"./tools/sync.js\";\nimport type { PlatformToolPack } from \"../../tools/types.js\";\nimport type { PlatformGithubOps } from \"./types.js\";\n\n/**\n * GitHub host-side capability pack — one tool per module under `tools/`:\n * github_pr, github_checks, github_review_reply, github_sync, github_read,\n * github_issue.\n *\n * These tools never run in the sandbox; they call PlatformGithubOps which\n * mints short-lived installation tokens on the host. The pack is only\n * constructed when the GitHub bot is configured; bindRun enables the tools\n * only for github-named conversations so multi-platform processes stay safe.\n */\nexport function createGithubToolPack(ops: PlatformGithubOps): PlatformToolPack {\n const { tool: githubPrTool, setGithubPrFunction } = createGithubPrTool();\n const { tool: githubChecksTool, setGithubChecksFunction } = createGithubChecksTool();\n const { tool: githubReviewReplyTool, setGithubReviewReplyFunction } =\n createGithubReviewReplyTool();\n const { tool: githubSyncTool, setGithubSyncFunction } = createGithubSyncTool();\n const { tool: githubReadTool, setGithubReadFunction } = createGithubReadTool();\n const { tool: githubIssueTool, setGithubIssueFunction } = createGithubIssueTool();\n\n return {\n tools: [\n githubPrTool,\n githubChecksTool,\n githubReviewReplyTool,\n githubSyncTool,\n githubReadTool,\n githubIssueTool,\n ],\n bindRun({ conversationId, platformName }) {\n if (platformName !== \"github\") {\n setGithubPrFunction(null);\n setGithubChecksFunction(null);\n setGithubReviewReplyFunction(null);\n setGithubSyncFunction(null);\n setGithubReadFunction(null);\n setGithubIssueFunction(null);\n return;\n }\n setGithubPrFunction((request) => ops.pushAndCreatePr(conversationId, request));\n setGithubChecksFunction({\n getChecks: (branch) => ops.getChecks(conversationId, branch),\n getJobLog: (jobId) => ops.getJobLog(conversationId, jobId),\n getBuildLog: (buildId) => ops.getBuildLog(conversationId, buildId),\n });\n setGithubReviewReplyFunction((commentId, body) =>\n ops.replyToReviewThread(conversationId, commentId, body),\n );\n setGithubSyncFunction((branch) => ops.syncRepo(conversationId, branch));\n setGithubReadFunction((request) => ops.readGithub(conversationId, request));\n setGithubIssueFunction((request) => ops.manageIssue(conversationId, request));\n },\n };\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import type { AgentTool } from "@earendil-works/pi-agent-core";
2
+ import type { GithubCheckSummary } from "../types.js";
3
+ declare const githubChecksSchema: import("@sinclair/typebox").TObject<{
4
+ branch: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
5
+ job_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
6
+ build_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
7
+ }>;
8
+ export interface GithubChecksFns {
9
+ getChecks: (branch?: string) => Promise<GithubCheckSummary[]>;
10
+ getJobLog: (jobId: number) => Promise<string>;
11
+ getBuildLog: (buildId: string) => Promise<string>;
12
+ }
13
+ /**
14
+ * The `github_checks` tool reads CI check runs (GitHub Actions and other
15
+ * check-reporting apps) for a branch or the conversation's PR head, and can
16
+ * fetch one job's log tail so the agent can diagnose failures and iterate.
17
+ * Read-only, host-side; wired per run and only for GitHub conversations.
18
+ */
19
+ export declare function createGithubChecksTool(): {
20
+ tool: AgentTool<typeof githubChecksSchema>;
21
+ setGithubChecksFunction: (fns: GithubChecksFns | null) => void;
22
+ };
23
+ export {};
24
+ //# sourceMappingURL=checks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/checks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,QAAA,MAAM,kBAAkB;;;;EAsBtB,CAAC;AA+BH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC9D,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9C,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACnD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI;IACxC,IAAI,EAAE,SAAS,CAAC,OAAO,kBAAkB,CAAC,CAAC;IAC3C,uBAAuB,EAAE,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,CAAC;CAChE,CA+DA"}
@@ -0,0 +1,105 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ import { defineHostFnTool } from "../../../tools/host-fn-tool.js";
3
+ const githubChecksSchema = Type.Object({
4
+ branch: Type.Optional(Type.String({
5
+ description: "Branch whose CI checks to read (e.g. a pi/<name> branch you pushed). " +
6
+ "Omit in a pull-request conversation to read the PR head's checks.",
7
+ })),
8
+ job_id: Type.Optional(Type.Number({
9
+ description: "A [job …] id from the summary output (GitHub Actions checks) — returns that " +
10
+ "CI job's log (tail) instead of the summary, for diagnosing a failing check.",
11
+ })),
12
+ build_id: Type.Optional(Type.String({
13
+ description: "A [build …] uuid from the summary output (Cloud Build checks) — returns that " +
14
+ "build's log (tail) instead of the summary. Mutually exclusive with job_id.",
15
+ })),
16
+ });
17
+ /** Conclusions that mean "this check did not pass and needs attention". */
18
+ const FAILING_CONCLUSIONS = new Set(["failure", "timed_out", "action_required", "cancelled"]);
19
+ function formatCheckLine(run) {
20
+ const state = run.status === "completed" ? (run.conclusion ?? "unknown") : run.status;
21
+ const marker = run.conclusion === null
22
+ ? "…"
23
+ : FAILING_CONCLUSIONS.has(run.conclusion)
24
+ ? "✗"
25
+ : run.conclusion === "success"
26
+ ? "✓"
27
+ : "−";
28
+ // GitHub Actions logs fetch via job_id; Cloud Build logs via build_id when
29
+ // the host has GCP credentials. Other external CI keeps logs on its own
30
+ // service, so advertising an id there would only invite doomed fetches.
31
+ const handle = run.appSlug === "github-actions"
32
+ ? `[job ${run.id}]`
33
+ : run.buildLogAvailable && run.externalId
34
+ ? `[build ${run.externalId}]`
35
+ : `[external CI: ${run.appSlug ?? "unknown"} — logs not on GitHub]`;
36
+ const line = `${marker} ${run.name}: ${state} ${handle}${run.url ? ` (${run.url})` : ""}`;
37
+ const failed = run.conclusion !== null && FAILING_CONCLUSIONS.has(run.conclusion);
38
+ return failed && run.outputSummary
39
+ ? `${line}\n ↳ ${run.outputSummary.replace(/\s*\n\s*/g, " ")}`
40
+ : line;
41
+ }
42
+ /**
43
+ * The `github_checks` tool reads CI check runs (GitHub Actions and other
44
+ * check-reporting apps) for a branch or the conversation's PR head, and can
45
+ * fetch one job's log tail so the agent can diagnose failures and iterate.
46
+ * Read-only, host-side; wired per run and only for GitHub conversations.
47
+ */
48
+ export function createGithubChecksTool() {
49
+ const { tool, setFn } = defineHostFnTool({
50
+ name: "github_checks",
51
+ description: "Read CI status (check runs) for a branch you pushed with github_pr, or for this " +
52
+ "conversation's pull request when branch is omitted. Pass job_id (a [job …] id, " +
53
+ "GitHub Actions) or build_id (a [build …] uuid, Cloud Build) from the summary to " +
54
+ "fetch that run's log. Other external CI checks keep logs on their own service: use " +
55
+ "their summary/url, or reproduce the failure locally in ./repo. Only available in " +
56
+ "GitHub conversations.",
57
+ parameters: githubChecksSchema,
58
+ unavailable: "github_checks is only available in GitHub conversations.",
59
+ run: async (checksFns, args) => {
60
+ if (args.job_id !== undefined && args.build_id !== undefined) {
61
+ throw new Error("Pass either job_id or build_id, not both.");
62
+ }
63
+ if (args.job_id !== undefined) {
64
+ const logText = await checksFns.getJobLog(args.job_id);
65
+ return {
66
+ content: [{ type: "text", text: logText || "(empty log)" }],
67
+ details: undefined,
68
+ };
69
+ }
70
+ if (args.build_id !== undefined) {
71
+ const logText = await checksFns.getBuildLog(args.build_id);
72
+ return {
73
+ content: [{ type: "text", text: logText || "(empty log)" }],
74
+ details: undefined,
75
+ };
76
+ }
77
+ const runs = await checksFns.getChecks(args.branch);
78
+ if (runs.length === 0) {
79
+ return {
80
+ content: [
81
+ {
82
+ type: "text",
83
+ text: "No check runs found — CI may not have started yet; try again shortly.",
84
+ },
85
+ ],
86
+ details: undefined,
87
+ };
88
+ }
89
+ const completed = runs.filter((run) => run.status === "completed");
90
+ const failing = completed.filter((run) => run.conclusion !== null && FAILING_CONCLUSIONS.has(run.conclusion));
91
+ const summary = `${runs.length} check(s): ${completed.length} completed, ${runs.length - completed.length} running, ${failing.length} failing`;
92
+ return {
93
+ content: [
94
+ {
95
+ type: "text",
96
+ text: [summary, ...runs.map(formatCheckLine)].join("\n"),
97
+ },
98
+ ],
99
+ details: undefined,
100
+ };
101
+ },
102
+ });
103
+ return { tool, setGithubChecksFunction: setFn };
104
+ }
105
+ //# sourceMappingURL=checks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checks.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/checks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGlE,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC;IACrC,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC;QACV,WAAW,EACT,uEAAuE;YACvE,mEAAmE;KACtE,CAAC,CACH;IACD,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC;QACV,WAAW,EACT,8EAA8E;YAC9E,6EAA6E;KAChF,CAAC,CACH;IACD,QAAQ,EAAE,IAAI,CAAC,QAAQ,CACrB,IAAI,CAAC,MAAM,CAAC;QACV,WAAW,EACT,+EAA+E;YAC/E,4EAA4E;KAC/E,CAAC,CACH;CACF,CAAC,CAAC;AAEH,2EAA2E;AAC3E,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE,WAAW,CAAC,CAAC,CAAC;AAE9F,SAAS,e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YACpD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACtB,OAAO;oBACL,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAe;4BACrB,IAAI,EAAE,uEAAuE;yBAC9E;qBACF;oBACD,OAAO,EAAE,SAAS;iBACnB,CAAC;YACJ,CAAC;YACD,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC;YACnE,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAC9B,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,KAAK,IAAI,IAAI,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAC5E,CAAC;YACF,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,MAAM,cAAc,SAAS,CAAC,MAAM,eAAe,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,aAAa,OAAO,CAAC,MAAM,UAAU,CAAC;YAC/I,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;qBACzD;iBACF;gBACD,OAAO,EAAE,SAAS;aACnB,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC;AAClD,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Type } from \"@sinclair/typebox\";\nimport { defineHostFnTool } from \"../../../tools/host-fn-tool.js\";\nimport type { GithubCheckSummary } from \"../types.js\";\n\nconst githubChecksSchema = Type.Object({\n branch: Type.Optional(\n Type.String({\n description:\n \"Branch whose CI checks to read (e.g. a pi/<name> branch you pushed). \" +\n \"Omit in a pull-request conversation to read the PR head's checks.\",\n }),\n ),\n job_id: Type.Optional(\n Type.Number({\n description:\n \"A [job …] id from the summary output (GitHub Actions checks) — returns that \" +\n \"CI job's log (tail) instead of the summary, for diagnosing a failing check.\",\n }),\n ),\n build_id: Type.Optional(\n Type.String({\n description:\n \"A [build …] uuid from the summary output (Cloud Build checks) — returns that \" +\n \"build's log (tail) instead of the summary. Mutually exclusive with job_id.\",\n }),\n ),\n});\n\n/** Conclusions that mean \"this check did not pass and needs attention\". */\nconst FAILING_CONCLUSIONS = new Set([\"failure\", \"timed_out\", \"action_required\", \"cancelled\"]);\n\nfunction formatCheckLine(run: GithubCheckSummary): string {\n const state = run.status === \"completed\" ? (run.conclusion ?? \"unknown\") : run.status;\n const marker =\n run.conclusion === null\n ? \"…\"\n : FAILING_CONCLUSIONS.has(run.conclusion)\n ? \"✗\"\n : run.conclusion === \"success\"\n ? \"✓\"\n : \"−\";\n // GitHub Actions logs fetch via job_id; Cloud Build logs via build_id when\n // the host has GCP credentials. Other external CI keeps logs on its own\n // service, so advertising an id there would only invite doomed fetches.\n const handle =\n run.appSlug === \"github-actions\"\n ? `[job ${run.id}]`\n : run.buildLogAvailable && run.externalId\n ? `[build ${run.externalId}]`\n : `[external CI: ${run.appSlug ?? \"unknown\"} — logs not on GitHub]`;\n const line = `${marker} ${run.name}: ${state} ${handle}${run.url ? ` (${run.url})` : \"\"}`;\n const failed = run.conclusion !== null && FAILING_CONCLUSIONS.has(run.conclusion);\n return failed && run.outputSummary\n ? `${line}\\n ↳ ${run.outputSummary.replace(/\\s*\\n\\s*/g, \" \")}`\n : line;\n}\n\nexport interface GithubChecksFns {\n getChecks: (branch?: string) => Promise<GithubCheckSummary[]>;\n getJobLog: (jobId: number) => Promise<string>;\n getBuildLog: (buildId: string) => Promise<string>;\n}\n\n/**\n * The `github_checks` tool reads CI check runs (GitHub Actions and other\n * check-reporting apps) for a branch or the conversation's PR head, and can\n * fetch one job's log tail so the agent can diagnose failures and iterate.\n * Read-only, host-side; wired per run and only for GitHub conversations.\n */\nexport function createGithubChecksTool(): {\n tool: AgentTool<typeof githubChecksSchema>;\n setGithubChecksFunction: (fns: GithubChecksFns | null) => void;\n} {\n const { tool, setFn } = defineHostFnTool<GithubChecksFns, typeof githubChecksSchema>({\n name: \"github_checks\",\n description:\n \"Read CI status (check runs) for a branch you pushed with github_pr, or for this \" +\n \"conversation's pull request when branch is omitted. Pass job_id (a [job …] id, \" +\n \"GitHub Actions) or build_id (a [build …] uuid, Cloud Build) from the summary to \" +\n \"fetch that run's log. Other external CI checks keep logs on their own service: use \" +\n \"their summary/url, or reproduce the failure locally in ./repo. Only available in \" +\n \"GitHub conversations.\",\n parameters: githubChecksSchema,\n unavailable: \"github_checks is only available in GitHub conversations.\",\n run: async (checksFns, args) => {\n if (args.job_id !== undefined && args.build_id !== undefined) {\n throw new Error(\"Pass either job_id or build_id, not both.\");\n }\n\n if (args.job_id !== undefined) {\n const logText = await checksFns.getJobLog(args.job_id);\n return {\n content: [{ type: \"text\" as const, text: logText || \"(empty log)\" }],\n details: undefined,\n };\n }\n\n if (args.build_id !== undefined) {\n const logText = await checksFns.getBuildLog(args.build_id);\n return {\n content: [{ type: \"text\" as const, text: logText || \"(empty log)\" }],\n details: undefined,\n };\n }\n\n const runs = await checksFns.getChecks(args.branch);\n if (runs.length === 0) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: \"No check runs found — CI may not have started yet; try again shortly.\",\n },\n ],\n details: undefined,\n };\n }\n const completed = runs.filter((run) => run.status === \"completed\");\n const failing = completed.filter(\n (run) => run.conclusion !== null && FAILING_CONCLUSIONS.has(run.conclusion),\n );\n const summary = `${runs.length} check(s): ${completed.length} completed, ${runs.length - completed.length} running, ${failing.length} failing`;\n return {\n content: [\n {\n type: \"text\" as const,\n text: [summary, ...runs.map(formatCheckLine)].join(\"\\n\"),\n },\n ],\n details: undefined,\n };\n },\n });\n\n return { tool, setGithubChecksFunction: setFn };\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import type { AgentTool } from "@earendil-works/pi-agent-core";
2
+ import type { GithubIssueRequest } from "../types.js";
3
+ declare const githubIssueSchema: import("@sinclair/typebox").TObject<{
4
+ action: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"add_labels">, import("@sinclair/typebox").TLiteral<"remove_label">, import("@sinclair/typebox").TLiteral<"add_assignees">, import("@sinclair/typebox").TLiteral<"remove_assignees">, import("@sinclair/typebox").TLiteral<"close">, import("@sinclair/typebox").TLiteral<"reopen">]>;
5
+ number: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
6
+ labels: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
7
+ label: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
8
+ assignees: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
9
+ state_reason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"completed">, import("@sinclair/typebox").TLiteral<"not_planned">]>>;
10
+ }>;
11
+ export type GithubIssueFn = (request: GithubIssueRequest) => Promise<string>;
12
+ /**
13
+ * The `github_issue` tool manages labels, assignees, and open/closed state of
14
+ * issues in the conversation's repo (any issue number — triage). Host-side as
15
+ * the App; wired per run and only for GitHub conversations.
16
+ */
17
+ export declare function createGithubIssueTool(): {
18
+ tool: AgentTool<typeof githubIssueSchema>;
19
+ setGithubIssueFunction: (fn: GithubIssueFn | null) => void;
20
+ };
21
+ export {};
22
+ //# sourceMappingURL=issue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"issue.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/issue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,QAAA,MAAM,iBAAiB;;;;;;;EA+BrB,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAE7E;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI;IACvC,IAAI,EAAE,SAAS,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAC1C,sBAAsB,EAAE,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI,KAAK,IAAI,CAAC;CAC5D,CAoBA"}
@@ -0,0 +1,48 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ import { defineHostFnTool } from "../../../tools/host-fn-tool.js";
3
+ const githubIssueSchema = Type.Object({
4
+ action: Type.Union([
5
+ Type.Literal("add_labels"),
6
+ Type.Literal("remove_label"),
7
+ Type.Literal("add_assignees"),
8
+ Type.Literal("remove_assignees"),
9
+ Type.Literal("close"),
10
+ Type.Literal("reopen"),
11
+ ], { description: "Issue management action." }),
12
+ number: Type.Optional(Type.Number({
13
+ description: "Issue/PR number in this repo; omit for this conversation's own.",
14
+ })),
15
+ labels: Type.Optional(Type.Array(Type.String(), { description: "add_labels: label names to add." })),
16
+ label: Type.Optional(Type.String({ description: "remove_label: the label name to remove." })),
17
+ assignees: Type.Optional(Type.Array(Type.String(), {
18
+ description: "add_assignees / remove_assignees: GitHub logins.",
19
+ })),
20
+ state_reason: Type.Optional(Type.Union([Type.Literal("completed"), Type.Literal("not_planned")], {
21
+ description: "close: why the issue is being closed.",
22
+ })),
23
+ });
24
+ /**
25
+ * The `github_issue` tool manages labels, assignees, and open/closed state of
26
+ * issues in the conversation's repo (any issue number — triage). Host-side as
27
+ * the App; wired per run and only for GitHub conversations.
28
+ */
29
+ export function createGithubIssueTool() {
30
+ const { tool, setFn } = defineHostFnTool({
31
+ name: "github_issue",
32
+ description: "Manage issues in this repo: add/remove labels, add/remove assignees, close " +
33
+ "(optionally with state_reason) or reopen. number defaults to this conversation's " +
34
+ "issue; any issue number in this repo works for triage. Only available in GitHub " +
35
+ "conversations.",
36
+ parameters: githubIssueSchema,
37
+ unavailable: "github_issue is only available in GitHub conversations.",
38
+ run: async (issueFn, args) => {
39
+ const report = await issueFn(args);
40
+ return {
41
+ content: [{ type: "text", text: report }],
42
+ details: undefined,
43
+ };
44
+ },
45
+ });
46
+ return { tool, setGithubIssueFunction: setFn };
47
+ }
48
+ //# sourceMappingURL=issue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"issue.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/issue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGlE,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC;IACpC,MAAM,EAAE,IAAI,CAAC,KAAK,CAChB;QACE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QAC1B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;QAC7B,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;KACvB,EACD,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAC5C;IACD,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC;QACV,WAAW,EAAE,iEAAiE;KAC/E,CAAC,CACH;IACD,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,iCAAiC,EAAE,CAAC,CAC9E;IACD,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC,CAAC;IAC7F,SAAS,EAAE,IAAI,CAAC,QAAQ,CACtB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE;QACxB,WAAW,EAAE,kDAAkD;KAChE,CAAC,CACH;IACD,YAAY,EAAE,IAAI,CAAC,QAAQ,CACzB,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE;QACnE,WAAW,EAAE,uCAAuC;KACrD,CAAC,CACH;CACF,CAAC,CAAC;AAIH;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IAInC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,gBAAgB,CAA0C;QAChF,IAAI,EAAE,cAAc;QACpB,WAAW,EACT,6EAA6E;YAC7E,mFAAmF;YACnF,kFAAkF;YAClF,gBAAgB;QAClB,UAAU,EAAE,iBAAiB;QAC7B,WAAW,EAAE,yDAAyD;QACtE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;YAC3B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAA0B,CAAC,CAAC;YACzD,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gBAClD,OAAO,EAAE,SAAS;aACnB,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAAC;AACjD,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Type } from \"@sinclair/typebox\";\nimport { defineHostFnTool } from \"../../../tools/host-fn-tool.js\";\nimport type { GithubIssueRequest } from \"../types.js\";\n\nconst githubIssueSchema = Type.Object({\n action: Type.Union(\n [\n Type.Literal(\"add_labels\"),\n Type.Literal(\"remove_label\"),\n Type.Literal(\"add_assignees\"),\n Type.Literal(\"remove_assignees\"),\n Type.Literal(\"close\"),\n Type.Literal(\"reopen\"),\n ],\n { description: \"Issue management action.\" },\n ),\n number: Type.Optional(\n Type.Number({\n description: \"Issue/PR number in this repo; omit for this conversation's own.\",\n }),\n ),\n labels: Type.Optional(\n Type.Array(Type.String(), { description: \"add_labels: label names to add.\" }),\n ),\n label: Type.Optional(Type.String({ description: \"remove_label: the label name to remove.\" })),\n assignees: Type.Optional(\n Type.Array(Type.String(), {\n description: \"add_assignees / remove_assignees: GitHub logins.\",\n }),\n ),\n state_reason: Type.Optional(\n Type.Union([Type.Literal(\"completed\"), Type.Literal(\"not_planned\")], {\n description: \"close: why the issue is being closed.\",\n }),\n ),\n});\n\nexport type GithubIssueFn = (request: GithubIssueRequest) => Promise<string>;\n\n/**\n * The `github_issue` tool manages labels, assignees, and open/closed state of\n * issues in the conversation's repo (any issue number — triage). Host-side as\n * the App; wired per run and only for GitHub conversations.\n */\nexport function createGithubIssueTool(): {\n tool: AgentTool<typeof githubIssueSchema>;\n setGithubIssueFunction: (fn: GithubIssueFn | null) => void;\n} {\n const { tool, setFn } = defineHostFnTool<GithubIssueFn, typeof githubIssueSchema>({\n name: \"github_issue\",\n description:\n \"Manage issues in this repo: add/remove labels, add/remove assignees, close \" +\n \"(optionally with state_reason) or reopen. number defaults to this conversation's \" +\n \"issue; any issue number in this repo works for triage. Only available in GitHub \" +\n \"conversations.\",\n parameters: githubIssueSchema,\n unavailable: \"github_issue is only available in GitHub conversations.\",\n run: async (issueFn, args) => {\n const report = await issueFn(args as GithubIssueRequest);\n return {\n content: [{ type: \"text\" as const, text: report }],\n details: undefined,\n };\n },\n });\n\n return { tool, setGithubIssueFunction: setFn };\n}\n"]}