@geminixiang/mikan 1.0.0-beta.13 → 1.0.0-beta.14

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 (275) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +10 -10
  3. package/dist/adapters/discord/bot.d.ts.map +1 -1
  4. package/dist/adapters/discord/bot.js +26 -67
  5. package/dist/adapters/discord/bot.js.map +1 -1
  6. package/dist/adapters/discord/context.d.ts.map +1 -1
  7. package/dist/adapters/discord/context.js +17 -43
  8. package/dist/adapters/discord/context.js.map +1 -1
  9. package/dist/adapters/github/bot.d.ts +69 -1
  10. package/dist/adapters/github/bot.d.ts.map +1 -1
  11. package/dist/adapters/github/bot.js +428 -57
  12. package/dist/adapters/github/bot.js.map +1 -1
  13. package/dist/adapters/github/client.d.ts +32 -1
  14. package/dist/adapters/github/client.d.ts.map +1 -1
  15. package/dist/adapters/github/client.js +79 -0
  16. package/dist/adapters/github/client.js.map +1 -1
  17. package/dist/adapters/github/cloudbuild.d.ts +24 -0
  18. package/dist/adapters/github/cloudbuild.d.ts.map +1 -0
  19. package/dist/adapters/github/cloudbuild.js +71 -0
  20. package/dist/adapters/github/cloudbuild.js.map +1 -0
  21. package/dist/adapters/github/context.d.ts.map +1 -1
  22. package/dist/adapters/github/context.js +34 -31
  23. package/dist/adapters/github/context.js.map +1 -1
  24. package/dist/adapters/github/gcp-auth.d.ts +31 -0
  25. package/dist/adapters/github/gcp-auth.d.ts.map +1 -0
  26. package/dist/adapters/github/gcp-auth.js +196 -0
  27. package/dist/adapters/github/gcp-auth.js.map +1 -0
  28. package/dist/adapters/github/ids.d.ts +9 -0
  29. package/dist/adapters/github/ids.d.ts.map +1 -1
  30. package/dist/adapters/github/ids.js +14 -0
  31. package/dist/adapters/github/ids.js.map +1 -1
  32. package/dist/adapters/github/repo.d.ts +13 -2
  33. package/dist/adapters/github/repo.d.ts.map +1 -1
  34. package/dist/adapters/github/repo.js +80 -2
  35. package/dist/adapters/github/repo.js.map +1 -1
  36. package/dist/adapters/github/tool-pack.d.ts +3 -1
  37. package/dist/adapters/github/tool-pack.d.ts.map +1 -1
  38. package/dist/adapters/github/tool-pack.js +30 -4
  39. package/dist/adapters/github/tool-pack.js.map +1 -1
  40. package/dist/{tools/github-checks.d.ts → adapters/github/tools/checks.d.ts} +4 -2
  41. package/dist/adapters/github/tools/checks.d.ts.map +1 -0
  42. package/dist/{tools/github-checks.js → adapters/github/tools/checks.js} +28 -11
  43. package/dist/adapters/github/tools/checks.js.map +1 -0
  44. package/dist/adapters/github/tools/issue.d.ts +22 -0
  45. package/dist/adapters/github/tools/issue.d.ts.map +1 -0
  46. package/dist/adapters/github/tools/issue.js +59 -0
  47. package/dist/adapters/github/tools/issue.js.map +1 -0
  48. package/dist/{tools/github-pr.d.ts → adapters/github/tools/pr.d.ts} +2 -2
  49. package/dist/adapters/github/tools/pr.d.ts.map +1 -0
  50. package/dist/{tools/github-pr.js → adapters/github/tools/pr.js} +8 -4
  51. package/dist/adapters/github/tools/pr.js.map +1 -0
  52. package/dist/adapters/github/tools/read.d.ts +22 -0
  53. package/dist/adapters/github/tools/read.d.ts.map +1 -0
  54. package/dist/adapters/github/tools/read.js +152 -0
  55. package/dist/adapters/github/tools/read.js.map +1 -0
  56. package/dist/adapters/github/tools/review-reply.d.ts +19 -0
  57. package/dist/adapters/github/tools/review-reply.d.ts.map +1 -0
  58. package/dist/adapters/github/tools/review-reply.js +49 -0
  59. package/dist/adapters/github/tools/review-reply.js.map +1 -0
  60. package/dist/adapters/github/tools/sync.d.ts +17 -0
  61. package/dist/adapters/github/tools/sync.d.ts.map +1 -0
  62. package/dist/adapters/github/tools/sync.js +45 -0
  63. package/dist/adapters/github/tools/sync.js.map +1 -0
  64. package/dist/adapters/github/types.d.ts +174 -1
  65. package/dist/adapters/github/types.d.ts.map +1 -1
  66. package/dist/adapters/github/types.js.map +1 -1
  67. package/dist/adapters/intake.d.ts +16 -5
  68. package/dist/adapters/intake.d.ts.map +1 -1
  69. package/dist/adapters/intake.js +79 -22
  70. package/dist/adapters/intake.js.map +1 -1
  71. package/dist/adapters/slack/bot.d.ts +7 -6
  72. package/dist/adapters/slack/bot.d.ts.map +1 -1
  73. package/dist/adapters/slack/bot.js +65 -135
  74. package/dist/adapters/slack/bot.js.map +1 -1
  75. package/dist/adapters/slack/context.d.ts.map +1 -1
  76. package/dist/adapters/slack/context.js +3 -15
  77. package/dist/adapters/slack/context.js.map +1 -1
  78. package/dist/adapters/slack/response-lifecycle.d.ts.map +1 -1
  79. package/dist/adapters/slack/response-lifecycle.js +7 -16
  80. package/dist/adapters/slack/response-lifecycle.js.map +1 -1
  81. package/dist/adapters/slack/session.d.ts.map +1 -1
  82. package/dist/adapters/slack/session.js +5 -8
  83. package/dist/adapters/slack/session.js.map +1 -1
  84. package/dist/adapters/streaming.d.ts +4 -0
  85. package/dist/adapters/streaming.d.ts.map +1 -1
  86. package/dist/adapters/streaming.js +11 -0
  87. package/dist/adapters/streaming.js.map +1 -1
  88. package/dist/adapters/telegram/bot.d.ts +0 -2
  89. package/dist/adapters/telegram/bot.d.ts.map +1 -1
  90. package/dist/adapters/telegram/bot.js +16 -62
  91. package/dist/adapters/telegram/bot.js.map +1 -1
  92. package/dist/adapters/telegram/context.d.ts.map +1 -1
  93. package/dist/adapters/telegram/context.js +8 -28
  94. package/dist/adapters/telegram/context.js.map +1 -1
  95. package/dist/adapters/types.d.ts +28 -2
  96. package/dist/adapters/types.d.ts.map +1 -1
  97. package/dist/adapters/types.js.map +1 -1
  98. package/dist/agent.d.ts +21 -4
  99. package/dist/agent.d.ts.map +1 -1
  100. package/dist/agent.js +22 -9
  101. package/dist/agent.js.map +1 -1
  102. package/dist/commands/admin.d.ts.map +1 -1
  103. package/dist/commands/admin.js +2 -1
  104. package/dist/commands/admin.js.map +1 -1
  105. package/dist/commands/auto-reply.d.ts.map +1 -1
  106. package/dist/commands/auto-reply.js +2 -6
  107. package/dist/commands/auto-reply.js.map +1 -1
  108. package/dist/commands/extensions.d.ts.map +1 -1
  109. package/dist/commands/extensions.js +2 -1
  110. package/dist/commands/extensions.js.map +1 -1
  111. package/dist/commands/login.d.ts +2 -1
  112. package/dist/commands/login.d.ts.map +1 -1
  113. package/dist/commands/login.js +30 -1
  114. package/dist/commands/login.js.map +1 -1
  115. package/dist/commands/manifest.d.ts +72 -0
  116. package/dist/commands/manifest.d.ts.map +1 -0
  117. package/dist/commands/manifest.js +121 -0
  118. package/dist/commands/manifest.js.map +1 -0
  119. package/dist/commands/model.d.ts.map +1 -1
  120. package/dist/commands/model.js +2 -1
  121. package/dist/commands/model.js.map +1 -1
  122. package/dist/commands/new.d.ts.map +1 -1
  123. package/dist/commands/new.js +2 -1
  124. package/dist/commands/new.js.map +1 -1
  125. package/dist/commands/sandbox.d.ts.map +1 -1
  126. package/dist/commands/sandbox.js +3 -2
  127. package/dist/commands/sandbox.js.map +1 -1
  128. package/dist/commands/text.d.ts +2 -0
  129. package/dist/commands/text.d.ts.map +1 -0
  130. package/dist/commands/text.js +16 -0
  131. package/dist/commands/text.js.map +1 -0
  132. package/dist/commands/types.d.ts +12 -1
  133. package/dist/commands/types.d.ts.map +1 -1
  134. package/dist/commands/types.js.map +1 -1
  135. package/dist/config.d.ts +1 -1
  136. package/dist/config.d.ts.map +1 -1
  137. package/dist/config.js +49 -54
  138. package/dist/config.js.map +1 -1
  139. package/dist/events.d.ts +10 -0
  140. package/dist/events.d.ts.map +1 -1
  141. package/dist/events.js +14 -5
  142. package/dist/events.js.map +1 -1
  143. package/dist/execution-resolver.d.ts.map +1 -1
  144. package/dist/execution-resolver.js +3 -3
  145. package/dist/execution-resolver.js.map +1 -1
  146. package/dist/index.d.ts +1 -1
  147. package/dist/index.d.ts.map +1 -1
  148. package/dist/index.js.map +1 -1
  149. package/dist/main.js +25 -5
  150. package/dist/main.js.map +1 -1
  151. package/dist/provisioner.d.ts.map +1 -1
  152. package/dist/provisioner.js +2 -5
  153. package/dist/provisioner.js.map +1 -1
  154. package/dist/runtime/conversation-runtime.d.ts +1 -1
  155. package/dist/runtime/conversation-runtime.d.ts.map +1 -1
  156. package/dist/runtime/conversation-runtime.js +230 -37
  157. package/dist/runtime/conversation-runtime.js.map +1 -1
  158. package/dist/runtime/types.d.ts +19 -4
  159. package/dist/runtime/types.d.ts.map +1 -1
  160. package/dist/runtime/types.js.map +1 -1
  161. package/dist/sandbox/cloudflare.d.ts +2 -0
  162. package/dist/sandbox/cloudflare.d.ts.map +1 -1
  163. package/dist/sandbox/cloudflare.js +7 -0
  164. package/dist/sandbox/cloudflare.js.map +1 -1
  165. package/dist/sandbox/container.d.ts +2 -0
  166. package/dist/sandbox/container.d.ts.map +1 -1
  167. package/dist/sandbox/container.js +7 -1
  168. package/dist/sandbox/container.js.map +1 -1
  169. package/dist/sandbox/firecracker.d.ts +2 -0
  170. package/dist/sandbox/firecracker.d.ts.map +1 -1
  171. package/dist/sandbox/firecracker.js +7 -1
  172. package/dist/sandbox/firecracker.js.map +1 -1
  173. package/dist/sandbox/host.d.ts +2 -0
  174. package/dist/sandbox/host.d.ts.map +1 -1
  175. package/dist/sandbox/host.js +11 -0
  176. package/dist/sandbox/host.js.map +1 -1
  177. package/dist/sandbox/identity.d.ts +21 -0
  178. package/dist/sandbox/identity.d.ts.map +1 -0
  179. package/dist/sandbox/identity.js +35 -0
  180. package/dist/sandbox/identity.js.map +1 -0
  181. package/dist/sandbox/types.d.ts +12 -0
  182. package/dist/sandbox/types.d.ts.map +1 -1
  183. package/dist/sandbox/types.js.map +1 -1
  184. package/dist/sandbox/utils.d.ts +11 -0
  185. package/dist/sandbox/utils.d.ts.map +1 -1
  186. package/dist/sandbox/utils.js +35 -0
  187. package/dist/sandbox/utils.js.map +1 -1
  188. package/dist/sessions/agent-memory-file-manager.d.ts.map +1 -1
  189. package/dist/sessions/agent-memory-file-manager.js +16 -19
  190. package/dist/sessions/agent-memory-file-manager.js.map +1 -1
  191. package/dist/sessions/history-line.d.ts +20 -0
  192. package/dist/sessions/history-line.d.ts.map +1 -0
  193. package/dist/sessions/history-line.js +24 -0
  194. package/dist/sessions/history-line.js.map +1 -0
  195. package/dist/sessions/policy.d.ts.map +1 -1
  196. package/dist/sessions/policy.js +4 -3
  197. package/dist/sessions/policy.js.map +1 -1
  198. package/dist/sessions/session-key.d.ts +31 -0
  199. package/dist/sessions/session-key.d.ts.map +1 -0
  200. package/dist/sessions/session-key.js +44 -0
  201. package/dist/sessions/session-key.js.map +1 -0
  202. package/dist/sessions/store.d.ts.map +1 -1
  203. package/dist/sessions/store.js +2 -2
  204. package/dist/sessions/store.js.map +1 -1
  205. package/dist/tools/bash.d.ts +3 -1
  206. package/dist/tools/bash.d.ts.map +1 -1
  207. package/dist/tools/bash.js +24 -17
  208. package/dist/tools/bash.js.map +1 -1
  209. package/dist/tools/edit.d.ts.map +1 -1
  210. package/dist/tools/edit.js +9 -12
  211. package/dist/tools/edit.js.map +1 -1
  212. package/dist/tools/event.d.ts +1 -1
  213. package/dist/tools/event.d.ts.map +1 -1
  214. package/dist/tools/event.js +33 -4
  215. package/dist/tools/event.js.map +1 -1
  216. package/dist/tools/index.js +1 -1
  217. package/dist/tools/index.js.map +1 -1
  218. package/dist/tools/types.d.ts +6 -1
  219. package/dist/tools/types.d.ts.map +1 -1
  220. package/dist/tools/types.js.map +1 -1
  221. package/dist/tools/write.d.ts.map +1 -1
  222. package/dist/tools/write.js +1 -8
  223. package/dist/tools/write.js.map +1 -1
  224. package/dist/types.d.ts +13 -6
  225. package/dist/types.d.ts.map +1 -1
  226. package/dist/types.js.map +1 -1
  227. package/dist/vault/disabled.d.ts +9 -0
  228. package/dist/vault/disabled.d.ts.map +1 -0
  229. package/dist/vault/disabled.js +23 -0
  230. package/dist/vault/disabled.js.map +1 -0
  231. package/dist/vault/index.d.ts.map +1 -1
  232. package/dist/vault/index.js +2 -7
  233. package/dist/vault/index.js.map +1 -1
  234. package/dist/vault/routing.d.ts +1 -0
  235. package/dist/vault/routing.d.ts.map +1 -1
  236. package/dist/vault/routing.js +3 -10
  237. package/dist/vault/routing.js.map +1 -1
  238. package/dist/web/admin/portal.d.ts +27 -0
  239. package/dist/web/admin/portal.d.ts.map +1 -1
  240. package/dist/web/admin/portal.js +87 -126
  241. package/dist/web/admin/portal.js.map +1 -1
  242. package/dist/web/admin/types.d.ts +3 -0
  243. package/dist/web/admin/types.d.ts.map +1 -1
  244. package/dist/web/admin/types.js.map +1 -1
  245. package/dist/web/login/oauth.d.ts +2 -3
  246. package/dist/web/login/oauth.d.ts.map +1 -1
  247. package/dist/web/login/oauth.js +0 -31
  248. package/dist/web/login/oauth.js.map +1 -1
  249. package/dist/web/login/types.d.ts +0 -11
  250. package/dist/web/login/types.d.ts.map +1 -1
  251. package/dist/web/login/types.js.map +1 -1
  252. package/dist/web/server.d.ts.map +1 -1
  253. package/dist/web/server.js +7 -0
  254. package/dist/web/server.js.map +1 -1
  255. package/dist/web/session-view/command.d.ts.map +1 -1
  256. package/dist/web/session-view/command.js +4 -1
  257. package/dist/web/session-view/command.js.map +1 -1
  258. package/dist/web/session-view/portal.d.ts.map +1 -1
  259. package/dist/web/session-view/portal.js +3 -2
  260. package/dist/web/session-view/portal.js.map +1 -1
  261. package/dist/web/session-view/service.d.ts.map +1 -1
  262. package/dist/web/session-view/service.js +2 -1
  263. package/dist/web/session-view/service.js.map +1 -1
  264. package/dist/web/session-view/types.d.ts +2 -1
  265. package/dist/web/session-view/types.d.ts.map +1 -1
  266. package/dist/web/session-view/types.js.map +1 -1
  267. package/package.json +1 -1
  268. package/dist/runtime/agent-run-controller.d.ts +0 -31
  269. package/dist/runtime/agent-run-controller.d.ts.map +0 -1
  270. package/dist/runtime/agent-run-controller.js +0 -195
  271. package/dist/runtime/agent-run-controller.js.map +0 -1
  272. package/dist/tools/github-checks.d.ts.map +0 -1
  273. package/dist/tools/github-checks.js.map +0 -1
  274. package/dist/tools/github-pr.d.ts.map +0 -1
  275. package/dist/tools/github-pr.js.map +0 -1
@@ -5,8 +5,12 @@ const githubChecksSchema = Type.Object({
5
5
  "Omit in a pull-request conversation to read the PR head's checks.",
6
6
  })),
7
7
  job_id: Type.Optional(Type.Number({
8
- description: "A check's job id from the summary output — returns that CI job's log " +
9
- "(tail) instead of the summary, for diagnosing a failing check.",
8
+ description: "A [job …] id from the summary output (GitHub Actions checks) — returns that " +
9
+ "CI job's log (tail) instead of the summary, for diagnosing a failing check.",
10
+ })),
11
+ build_id: Type.Optional(Type.String({
12
+ description: "A [build …] uuid from the summary output (Cloud Build checks) — returns that " +
13
+ "build's log (tail) instead of the summary. Mutually exclusive with job_id.",
10
14
  })),
11
15
  });
12
16
  /** Conclusions that mean "this check did not pass and needs attention". */
@@ -20,12 +24,14 @@ function formatCheckLine(run) {
20
24
  : run.conclusion === "success"
21
25
  ? "✓"
22
26
  : "−";
23
- // Only GitHub Actions checks have logs fetchable via job_id; external CI
24
- // (Cloud Build & co.) keeps logs on its own service, so advertising an id
25
- // there would only invite doomed fetches.
27
+ // GitHub Actions logs fetch via job_id; Cloud Build logs via build_id when
28
+ // the host has GCP credentials. Other external CI keeps logs on its own
29
+ // service, so advertising an id there would only invite doomed fetches.
26
30
  const handle = run.appSlug === "github-actions"
27
31
  ? `[job ${run.id}]`
28
- : `[external CI: ${run.appSlug ?? "unknown"} — logs not on GitHub]`;
32
+ : run.buildLogAvailable && run.externalId
33
+ ? `[build ${run.externalId}]`
34
+ : `[external CI: ${run.appSlug ?? "unknown"} — logs not on GitHub]`;
29
35
  const line = `${marker} ${run.name}: ${state} ${handle}${run.url ? ` (${run.url})` : ""}`;
30
36
  const failed = run.conclusion !== null && FAILING_CONCLUSIONS.has(run.conclusion);
31
37
  return failed && run.outputSummary
@@ -44,10 +50,11 @@ export function createGithubChecksTool() {
44
50
  name: "github_checks",
45
51
  label: "github_checks",
46
52
  description: "Read CI status (check runs) for a branch you pushed with github_pr, or for this " +
47
- "conversation's pull request when branch is omitted. Pass job_id (a [job …] id from " +
48
- "the summary — GitHub Actions checks only) to fetch that job's log. External CI " +
49
- "checks (e.g. Cloud Build) keep logs on their own service: use their summary/url, or " +
50
- "reproduce the failure locally in ./repo. Only available in GitHub conversations.",
53
+ "conversation's pull request when branch is omitted. Pass job_id (a [job …] id, " +
54
+ "GitHub Actions) or build_id (a [build …] uuid, Cloud Build) from the summary to " +
55
+ "fetch that run's log. Other external CI checks keep logs on their own service: use " +
56
+ "their summary/url, or reproduce the failure locally in ./repo. Only available in " +
57
+ "GitHub conversations.",
51
58
  parameters: githubChecksSchema,
52
59
  execute: async (_toolCallId, args, signal) => {
53
60
  if (!checksFns) {
@@ -56,6 +63,9 @@ export function createGithubChecksTool() {
56
63
  if (signal?.aborted) {
57
64
  throw new Error("Operation aborted");
58
65
  }
66
+ if (args.job_id !== undefined && args.build_id !== undefined) {
67
+ throw new Error("Pass either job_id or build_id, not both.");
68
+ }
59
69
  if (args.job_id !== undefined) {
60
70
  const logText = await checksFns.getJobLog(args.job_id);
61
71
  return {
@@ -63,6 +73,13 @@ export function createGithubChecksTool() {
63
73
  details: undefined,
64
74
  };
65
75
  }
76
+ if (args.build_id !== undefined) {
77
+ const logText = await checksFns.getBuildLog(args.build_id);
78
+ return {
79
+ content: [{ type: "text", text: logText || "(empty log)" }],
80
+ details: undefined,
81
+ };
82
+ }
66
83
  const runs = await checksFns.getChecks(args.branch);
67
84
  if (runs.length === 0) {
68
85
  return {
@@ -96,4 +113,4 @@ export function createGithubChecksTool() {
96
113
  },
97
114
  };
98
115
  }
99
- //# sourceMappingURL=github-checks.js.map
116
+ //# 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;AAGzC,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC;IACrC,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC;QACV,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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;IAEF,OAAO;QACL,IAAI;QACJ,uBAAuB,EAAE,CAAC,GAAG,EAAE,EAAE;YAC/B,SAAS,GAAG,GAAG,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Type } from \"@sinclair/typebox\";\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 let checksFns: GithubChecksFns | null = null;\n\n const tool: AgentTool<typeof githubChecksSchema> = {\n name: \"github_checks\",\n label: \"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 execute: async (\n _toolCallId: string,\n args: { branch?: string; job_id?: number; build_id?: string },\n signal?: AbortSignal,\n ) => {\n if (!checksFns) {\n throw new Error(\"github_checks is only available in GitHub conversations.\");\n }\n if (signal?.aborted) {\n throw new Error(\"Operation aborted\");\n }\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 {\n tool,\n setGithubChecksFunction: (fns) => {\n checksFns = fns;\n },\n };\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;AAE/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,CAiCA"}
@@ -0,0 +1,59 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ const githubIssueSchema = Type.Object({
3
+ action: Type.Union([
4
+ Type.Literal("add_labels"),
5
+ Type.Literal("remove_label"),
6
+ Type.Literal("add_assignees"),
7
+ Type.Literal("remove_assignees"),
8
+ Type.Literal("close"),
9
+ Type.Literal("reopen"),
10
+ ], { description: "Issue management action." }),
11
+ number: Type.Optional(Type.Number({
12
+ description: "Issue/PR number in this repo; omit for this conversation's own.",
13
+ })),
14
+ labels: Type.Optional(Type.Array(Type.String(), { description: "add_labels: label names to add." })),
15
+ label: Type.Optional(Type.String({ description: "remove_label: the label name to remove." })),
16
+ assignees: Type.Optional(Type.Array(Type.String(), {
17
+ description: "add_assignees / remove_assignees: GitHub logins.",
18
+ })),
19
+ state_reason: Type.Optional(Type.Union([Type.Literal("completed"), Type.Literal("not_planned")], {
20
+ description: "close: why the issue is being closed.",
21
+ })),
22
+ });
23
+ /**
24
+ * The `github_issue` tool manages labels, assignees, and open/closed state of
25
+ * issues in the conversation's repo (any issue number — triage). Host-side as
26
+ * the App; wired per run and only for GitHub conversations.
27
+ */
28
+ export function createGithubIssueTool() {
29
+ let issueFn = null;
30
+ const tool = {
31
+ name: "github_issue",
32
+ label: "github_issue",
33
+ description: "Manage issues in this repo: add/remove labels, add/remove assignees, close " +
34
+ "(optionally with state_reason) or reopen. number defaults to this conversation's " +
35
+ "issue; any issue number in this repo works for triage. Only available in GitHub " +
36
+ "conversations.",
37
+ parameters: githubIssueSchema,
38
+ execute: async (_toolCallId, args, signal) => {
39
+ if (!issueFn) {
40
+ throw new Error("github_issue is only available in GitHub conversations.");
41
+ }
42
+ if (signal?.aborted) {
43
+ throw new Error("Operation aborted");
44
+ }
45
+ const report = await issueFn(args);
46
+ return {
47
+ content: [{ type: "text", text: report }],
48
+ details: undefined,
49
+ };
50
+ },
51
+ };
52
+ return {
53
+ tool,
54
+ setGithubIssueFunction: (fn) => {
55
+ issueFn = fn;
56
+ },
57
+ };
58
+ }
59
+ //# sourceMappingURL=issue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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AC,CAAC;AAIH;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IAInC,IAAI,OAAO,GAAyB,IAAI,CAAC;IAEzC,MAAM,IAAI,GAAwC;QAChD,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,cAAc;QACrB,WAAW,EACT,6EAA6E;YAC7E,mFAAmF;YACnF,kFAAkF;YAClF,gBAAgB;QAClB,UAAU,EAAE,iBAAiB;QAC7B,OAAO,EAAE,KAAK,EAAE,WAAmB,EAAE,IAAwB,EAAE,MAAoB,EAAE,EAAE;YACrF,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;YAC7E,CAAC;YACD,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACvC,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;YACnC,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;IAEF,OAAO;QACL,IAAI;QACJ,sBAAsB,EAAE,CAAC,EAAE,EAAE,EAAE;YAC7B,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Type } from \"@sinclair/typebox\";\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 let issueFn: GithubIssueFn | null = null;\n\n const tool: AgentTool<typeof githubIssueSchema> = {\n name: \"github_issue\",\n label: \"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 execute: async (_toolCallId: string, args: GithubIssueRequest, signal?: AbortSignal) => {\n if (!issueFn) {\n throw new Error(\"github_issue is only available in GitHub conversations.\");\n }\n if (signal?.aborted) {\n throw new Error(\"Operation aborted\");\n }\n const report = await issueFn(args);\n return {\n content: [{ type: \"text\" as const, text: report }],\n details: undefined,\n };\n },\n };\n\n return {\n tool,\n setGithubIssueFunction: (fn) => {\n issueFn = fn;\n },\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { AgentTool } from "@earendil-works/pi-agent-core";
2
- import type { GithubPrRequest, GithubPrResult } from "../adapters/github/types.js";
2
+ import type { GithubPrRequest, GithubPrResult } from "../types.js";
3
3
  declare const githubPrSchema: import("@sinclair/typebox").TObject<{
4
4
  branch: import("@sinclair/typebox").TString;
5
5
  title: import("@sinclair/typebox").TString;
@@ -19,4 +19,4 @@ export declare function createGithubPrTool(): {
19
19
  setGithubPrFunction: (fn: ((request: GithubPrRequest) => Promise<GithubPrResult>) | null) => void;
20
20
  };
21
21
  export {};
22
- //# sourceMappingURL=github-pr.d.ts.map
22
+ //# sourceMappingURL=pr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pr.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/pr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEnE,QAAA,MAAM,cAAc;;;;;;EAalB,CAAC;AAIH;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI;IACpC,IAAI,EAAE,SAAS,CAAC,OAAO,cAAc,CAAC,CAAC;IACvC,mBAAmB,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;CACnG,CAyCA"}
@@ -1,7 +1,9 @@
1
1
  import { Type } from "@sinclair/typebox";
2
2
  const githubPrSchema = Type.Object({
3
3
  branch: Type.String({
4
- description: 'Local branch inside ./repo to push. Must be named pi/<something> (e.g. "pi/fix-42"); the default branch is never pushable.',
4
+ description: 'Local branch inside ./repo to push. Must be named pi/<something> (e.g. "pi/fix-42"); ' +
5
+ "the default branch is never pushable. To update this conversation's own PR, pass its " +
6
+ "checked-out pi/* head branch.",
5
7
  }),
6
8
  title: Type.String({ description: "Pull request title." }),
7
9
  body: Type.Optional(Type.String({ description: "Pull request description (Markdown)." })),
@@ -21,8 +23,10 @@ export function createGithubPrTool() {
21
23
  name: "github_pr",
22
24
  label: "github_pr",
23
25
  description: "Push a pi/<name> branch you committed inside ./repo and open a GitHub pull request " +
24
- "(or draft) for it. Only available in GitHub issue/PR conversations. You cannot push " +
25
- "to the default branch and you cannot merge — humans review and merge the PR.",
26
+ "(or draft) for it. Pushing a branch that already has an open PR — including this " +
27
+ "conversation's own PR head — updates that PR instead of opening a new one. Only " +
28
+ "available in GitHub issue/PR conversations. You cannot push to the default branch " +
29
+ "and you cannot merge — humans review and merge the PR.",
26
30
  parameters: githubPrSchema,
27
31
  execute: async (_toolCallId, args, signal) => {
28
32
  if (!prFn) {
@@ -52,4 +56,4 @@ export function createGithubPrTool() {
52
56
  },
53
57
  };
54
58
  }
55
- //# sourceMappingURL=github-pr.js.map
59
+ //# sourceMappingURL=pr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pr.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/pr.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;QAClB,WAAW,EACT,uFAAuF;YACvF,uFAAuF;YACvF,+BAA+B;KAClC,CAAC;IACF,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;IAC1D,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC,CAAC;IACzF,IAAI,EAAE,IAAI,CAAC,QAAQ,CACjB,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,6DAA6D,EAAE,CAAC,CAC5F;IACD,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC,CAAC;CACrF,CAAC,CAAC;AAIH;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB;IAIhC,IAAI,IAAI,GAAmE,IAAI,CAAC;IAEhF,MAAM,IAAI,GAAqC;QAC7C,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,WAAW;QAClB,WAAW,EACT,qFAAqF;YACrF,mFAAmF;YACnF,kFAAkF;YAClF,oFAAoF;YACpF,wDAAwD;QAC1D,UAAU,EAAE,cAAc;QAC1B,OAAO,EAAE,KAAK,EAAE,WAAmB,EAAE,IAAkB,EAAE,MAAoB,EAAE,EAAE;YAC/E,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;YAC1E,CAAC;YACD,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACvC,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;YAChC,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,MAAM,CAAC,eAAe;4BAC1B,CAAC,CAAC,0BAA0B,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,GAAG,EAAE;4BAC1D,CAAC,CAAC,UAAU,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,GAAG,EAAE;qBAC9E;iBACF;gBACD,OAAO,EAAE,SAAS;aACnB,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,OAAO;QACL,IAAI;QACJ,mBAAmB,EAAE,CAAC,EAAE,EAAE,EAAE;YAC1B,IAAI,GAAG,EAAE,CAAC;QACZ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Type } from \"@sinclair/typebox\";\nimport type { GithubPrRequest, GithubPrResult } from \"../types.js\";\n\nconst githubPrSchema = Type.Object({\n branch: Type.String({\n description:\n 'Local branch inside ./repo to push. Must be named pi/<something> (e.g. \"pi/fix-42\"); ' +\n \"the default branch is never pushable. To update this conversation's own PR, pass its \" +\n \"checked-out pi/* head branch.\",\n }),\n title: Type.String({ description: \"Pull request title.\" }),\n body: Type.Optional(Type.String({ description: \"Pull request description (Markdown).\" })),\n base: Type.Optional(\n Type.String({ description: \"Target branch; defaults to the repository's default branch.\" }),\n ),\n draft: Type.Optional(Type.Boolean({ description: \"Open as a draft pull request.\" })),\n});\n\ntype GithubPrArgs = GithubPrRequest;\n\n/**\n * The `github_pr` tool pushes a branch the agent prepared in the\n * conversation's ./repo clone and opens a pull request as the GitHub App.\n * The push and API calls run host-side with an ephemeral repo-scoped token;\n * the sandbox never holds credentials. Wired per run via the setter, and only\n * for GitHub conversations.\n */\nexport function createGithubPrTool(): {\n tool: AgentTool<typeof githubPrSchema>;\n setGithubPrFunction: (fn: ((request: GithubPrRequest) => Promise<GithubPrResult>) | null) => void;\n} {\n let prFn: ((request: GithubPrRequest) => Promise<GithubPrResult>) | null = null;\n\n const tool: AgentTool<typeof githubPrSchema> = {\n name: \"github_pr\",\n label: \"github_pr\",\n description:\n \"Push a pi/<name> branch you committed inside ./repo and open a GitHub pull request \" +\n \"(or draft) for it. Pushing a branch that already has an open PR — including this \" +\n \"conversation's own PR head — updates that PR instead of opening a new one. Only \" +\n \"available in GitHub issue/PR conversations. You cannot push to the default branch \" +\n \"and you cannot merge — humans review and merge the PR.\",\n parameters: githubPrSchema,\n execute: async (_toolCallId: string, args: GithubPrArgs, signal?: AbortSignal) => {\n if (!prFn) {\n throw new Error(\"github_pr is only available in GitHub conversations.\");\n }\n if (signal?.aborted) {\n throw new Error(\"Operation aborted\");\n }\n const result = await prFn(args);\n return {\n content: [\n {\n type: \"text\" as const,\n text: result.updatedExisting\n ? `Pushed to existing PR #${result.number}: ${result.url}`\n : `Opened ${args.draft ? \"draft \" : \"\"}PR #${result.number}: ${result.url}`,\n },\n ],\n details: undefined,\n };\n },\n };\n\n return {\n tool,\n setGithubPrFunction: (fn) => {\n prFn = fn;\n },\n };\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import type { AgentTool } from "@earendil-works/pi-agent-core";
2
+ import type { GithubReadRequest, GithubReadResult } from "../types.js";
3
+ declare const githubReadSchema: import("@sinclair/typebox").TObject<{
4
+ action: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"pr">, import("@sinclair/typebox").TLiteral<"pr_files">, import("@sinclair/typebox").TLiteral<"pr_reviews">, import("@sinclair/typebox").TLiteral<"issue">, import("@sinclair/typebox").TLiteral<"comments">, import("@sinclair/typebox").TLiteral<"list">]>;
5
+ number: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
6
+ state: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
7
+ labels: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
8
+ creator: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
9
+ }>;
10
+ export type GithubReadFn = (request: GithubReadRequest) => Promise<GithubReadResult>;
11
+ /**
12
+ * The `github_read` tool reads what the ./repo clone cannot show: PR diff
13
+ * stats and changed files, review state with open inline threads, and other
14
+ * issues/PRs in this repo for triage. Read-only, host-side, same-repo by
15
+ * construction; wired per run and only for GitHub conversations.
16
+ */
17
+ export declare function createGithubReadTool(): {
18
+ tool: AgentTool<typeof githubReadSchema>;
19
+ setGithubReadFunction: (fn: GithubReadFn | null) => void;
20
+ };
21
+ export {};
22
+ //# sourceMappingURL=read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEvE,QAAA,MAAM,gBAAgB;;;;;;EA8BpB,CAAC;AAoGH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAErF;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI;IACtC,IAAI,EAAE,SAAS,CAAC,OAAO,gBAAgB,CAAC,CAAC;IACzC,qBAAqB,EAAE,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,KAAK,IAAI,CAAC;CAC1D,CAiCA"}
@@ -0,0 +1,152 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ const githubReadSchema = Type.Object({
3
+ action: Type.Union([
4
+ Type.Literal("pr"),
5
+ Type.Literal("pr_files"),
6
+ Type.Literal("pr_reviews"),
7
+ Type.Literal("issue"),
8
+ Type.Literal("comments"),
9
+ Type.Literal("list"),
10
+ ], {
11
+ description: "pr: PR metadata (state, base/head, diff stats). pr_files: changed files. " +
12
+ "pr_reviews: submitted reviews + open inline threads (with rc- ids for " +
13
+ "github_review_reply). issue: issue metadata. comments: recent conversation " +
14
+ "comments. list: issues/PRs in this repo.",
15
+ }),
16
+ number: Type.Optional(Type.Number({
17
+ description: "Issue/PR number to read; omit for this conversation's own.",
18
+ })),
19
+ state: Type.Optional(Type.String({ description: "list only: open | closed | all (default open)." })),
20
+ labels: Type.Optional(Type.String({ description: "list only: comma-separated label names to filter by." })),
21
+ creator: Type.Optional(Type.String({ description: "list only: filter by author login." })),
22
+ });
23
+ const MAX_BODY_CHARS = 1000;
24
+ const MAX_COMMENT_CHARS = 500;
25
+ const MAX_REVIEW_BODY_CHARS = 300;
26
+ function truncate(text, max) {
27
+ return text.length > max ? `${text.slice(0, max)}…` : text;
28
+ }
29
+ function formatResult(result) {
30
+ switch (result.kind) {
31
+ case "pr": {
32
+ const pr = result.pr;
33
+ const flags = [
34
+ pr.state ?? "unknown",
35
+ pr.draft ? "draft" : null,
36
+ pr.merged ? "merged" : null,
37
+ pr.mergeable_state ? `mergeable_state: ${pr.mergeable_state}` : null,
38
+ ].filter(Boolean);
39
+ return [
40
+ `PR #${pr.number}: ${pr.title ?? ""} [${flags.join(", ")}]`,
41
+ `${pr.head?.ref ?? "?"} → ${pr.base?.ref ?? "?"} | ${pr.changed_files ?? "?"} files, +${pr.additions ?? "?"} -${pr.deletions ?? "?"}`,
42
+ pr.user ? `author: @${pr.user.login}` : null,
43
+ pr.body ? truncate(pr.body, MAX_BODY_CHARS) : "(no description)",
44
+ ]
45
+ .filter(Boolean)
46
+ .join("\n");
47
+ }
48
+ case "pr_files": {
49
+ if (result.files.length === 0)
50
+ return "No changed files.";
51
+ const lines = result.files.map((file) => `${file.status.padEnd(8)} ${file.filename} +${file.additions} -${file.deletions}`);
52
+ return [`${result.files.length} changed file(s):`, ...lines].join("\n");
53
+ }
54
+ case "pr_reviews": {
55
+ const reviewLines = result.reviews
56
+ .filter((review) => review.state !== "PENDING")
57
+ .map((review) => {
58
+ const body = review.body?.trim()
59
+ ? ` — ${truncate(review.body, MAX_REVIEW_BODY_CHARS)}`
60
+ : "";
61
+ return `@${review.user.login}: ${review.state}${body}`;
62
+ });
63
+ // Thread roots only: replies belong to their root's thread. The rc- id
64
+ // is what github_review_reply takes.
65
+ const rootThreads = result.threads.filter((comment) => comment.in_reply_to_id === undefined);
66
+ const threadLines = rootThreads.map((comment) => {
67
+ const location = comment.line !== null ? `${comment.path}:${comment.line}` : comment.path;
68
+ const replies = result.threads.filter((reply) => reply.in_reply_to_id === comment.id);
69
+ const replyNote = replies.length > 0
70
+ ? ` (${replies.length} repl${replies.length === 1 ? "y" : "ies"})`
71
+ : "";
72
+ return `rc-${comment.id} ${location} @${comment.user.login}${replyNote}: ${truncate(comment.body, MAX_REVIEW_BODY_CHARS)}`;
73
+ });
74
+ return [
75
+ reviewLines.length > 0 ? `Reviews:\n${reviewLines.join("\n")}` : "No submitted reviews.",
76
+ threadLines.length > 0
77
+ ? `Inline threads (reply with github_review_reply):\n${threadLines.join("\n")}`
78
+ : "No inline review threads.",
79
+ ].join("\n\n");
80
+ }
81
+ case "issue": {
82
+ const issue = result.issue;
83
+ const labels = (issue.labels ?? []).map((label) => label.name).join(", ");
84
+ const assignees = (issue.assignees ?? []).map((assignee) => `@${assignee.login}`).join(", ");
85
+ return [
86
+ `#${issue.number}: ${issue.title} [${issue.state ?? "unknown"}${issue.pull_request ? ", PR" : ""}]`,
87
+ labels ? `labels: ${labels}` : null,
88
+ assignees ? `assignees: ${assignees}` : null,
89
+ `author: @${issue.user.login}`,
90
+ issue.body ? truncate(issue.body, MAX_BODY_CHARS) : "(no body)",
91
+ ]
92
+ .filter(Boolean)
93
+ .join("\n");
94
+ }
95
+ case "comments": {
96
+ if (result.comments.length === 0)
97
+ return "No comments.";
98
+ return result.comments
99
+ .map((comment) => `@${comment.user.login} (${comment.created_at}): ${truncate(comment.body, MAX_COMMENT_CHARS)}`)
100
+ .join("\n");
101
+ }
102
+ case "list": {
103
+ if (result.issues.length === 0)
104
+ return "No matching issues.";
105
+ return result.issues
106
+ .map((issue) => {
107
+ const labels = (issue.labels ?? []).map((label) => label.name).join(", ");
108
+ const kind = issue.pull_request ? "PR" : "issue";
109
+ return `#${issue.number} [${issue.state ?? "?"} ${kind}] ${issue.title}${labels ? ` (${labels})` : ""}`;
110
+ })
111
+ .join("\n");
112
+ }
113
+ }
114
+ }
115
+ /**
116
+ * The `github_read` tool reads what the ./repo clone cannot show: PR diff
117
+ * stats and changed files, review state with open inline threads, and other
118
+ * issues/PRs in this repo for triage. Read-only, host-side, same-repo by
119
+ * construction; wired per run and only for GitHub conversations.
120
+ */
121
+ export function createGithubReadTool() {
122
+ let readFn = null;
123
+ const tool = {
124
+ name: "github_read",
125
+ label: "github_read",
126
+ description: "Read GitHub metadata for this repo: PR state/diff stats (pr), changed files " +
127
+ "(pr_files), reviews and open inline threads (pr_reviews), issue metadata (issue), " +
128
+ "recent comments (comments), or a filtered issue/PR listing (list). number defaults " +
129
+ "to this conversation's issue/PR. Only available in GitHub conversations.",
130
+ parameters: githubReadSchema,
131
+ execute: async (_toolCallId, args, signal) => {
132
+ if (!readFn) {
133
+ throw new Error("github_read is only available in GitHub conversations.");
134
+ }
135
+ if (signal?.aborted) {
136
+ throw new Error("Operation aborted");
137
+ }
138
+ const result = await readFn(args);
139
+ return {
140
+ content: [{ type: "text", text: formatResult(result) }],
141
+ details: undefined,
142
+ };
143
+ },
144
+ };
145
+ return {
146
+ tool,
147
+ setGithubReadFunction: (fn) => {
148
+ readFn = fn;
149
+ },
150
+ };
151
+ }
152
+ //# sourceMappingURL=read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/read.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC;IACnC,MAAM,EAAE,IAAI,CAAC,KAAK,CAChB;QACE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QAC1B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;KACrB,EACD;QACE,WAAW,EACT,2EAA2E;YAC3E,wEAAwE;YACxE,6EAA6E;YAC7E,0CAA0C;KAC7C,CACF;IACD,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC;QACV,WAAW,EAAE,4DAA4D;KAC1E,CAAC,CACH;IACD,KAAK,EAAE,IAAI,CAAC,QAAQ,CAClB,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC,CAC/E;IACD,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,sDAAsD,EAAE,CAAC,CACrF;IACD,OAAO,EAAE,IAAI,CAAC,QA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ACT,8EAA8E;YAC9E,oFAAoF;YACpF,qFAAqF;YACrF,0EAA0E;QAC5E,UAAU,EAAE,gBAAgB;QAC5B,OAAO,EAAE,KAAK,EAAE,WAAmB,EAAE,IAAuB,EAAE,MAAoB,EAAE,EAAE;YACpF,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;YAC5E,CAAC;YACD,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACvC,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;YAClC,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;gBAChE,OAAO,EAAE,SAAS;aACnB,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,OAAO;QACL,IAAI;QACJ,qBAAqB,EAAE,CAAC,EAAE,EAAE,EAAE;YAC5B,MAAM,GAAG,EAAE,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Type } from \"@sinclair/typebox\";\nimport type { GithubReadRequest, GithubReadResult } from \"../types.js\";\n\nconst githubReadSchema = Type.Object({\n action: Type.Union(\n [\n Type.Literal(\"pr\"),\n Type.Literal(\"pr_files\"),\n Type.Literal(\"pr_reviews\"),\n Type.Literal(\"issue\"),\n Type.Literal(\"comments\"),\n Type.Literal(\"list\"),\n ],\n {\n description:\n \"pr: PR metadata (state, base/head, diff stats). pr_files: changed files. \" +\n \"pr_reviews: submitted reviews + open inline threads (with rc- ids for \" +\n \"github_review_reply). issue: issue metadata. comments: recent conversation \" +\n \"comments. list: issues/PRs in this repo.\",\n },\n ),\n number: Type.Optional(\n Type.Number({\n description: \"Issue/PR number to read; omit for this conversation's own.\",\n }),\n ),\n state: Type.Optional(\n Type.String({ description: \"list only: open | closed | all (default open).\" }),\n ),\n labels: Type.Optional(\n Type.String({ description: \"list only: comma-separated label names to filter by.\" }),\n ),\n creator: Type.Optional(Type.String({ description: \"list only: filter by author login.\" })),\n});\n\nconst MAX_BODY_CHARS = 1000;\nconst MAX_COMMENT_CHARS = 500;\nconst MAX_REVIEW_BODY_CHARS = 300;\n\nfunction truncate(text: string, max: number): string {\n return text.length > max ? `${text.slice(0, max)}…` : text;\n}\n\nfunction formatResult(result: GithubReadResult): string {\n switch (result.kind) {\n case \"pr\": {\n const pr = result.pr;\n const flags = [\n pr.state ?? \"unknown\",\n pr.draft ? \"draft\" : null,\n pr.merged ? \"merged\" : null,\n pr.mergeable_state ? `mergeable_state: ${pr.mergeable_state}` : null,\n ].filter(Boolean);\n return [\n `PR #${pr.number}: ${pr.title ?? \"\"} [${flags.join(\", \")}]`,\n `${pr.head?.ref ?? \"?\"} → ${pr.base?.ref ?? \"?\"} | ${pr.changed_files ?? \"?\"} files, +${pr.additions ?? \"?\"} -${pr.deletions ?? \"?\"}`,\n pr.user ? `author: @${pr.user.login}` : null,\n pr.body ? truncate(pr.body, MAX_BODY_CHARS) : \"(no description)\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n }\n case \"pr_files\": {\n if (result.files.length === 0) return \"No changed files.\";\n const lines = result.files.map(\n (file) => `${file.status.padEnd(8)} ${file.filename} +${file.additions} -${file.deletions}`,\n );\n return [`${result.files.length} changed file(s):`, ...lines].join(\"\\n\");\n }\n case \"pr_reviews\": {\n const reviewLines = result.reviews\n .filter((review) => review.state !== \"PENDING\")\n .map((review) => {\n const body = review.body?.trim()\n ? ` — ${truncate(review.body, MAX_REVIEW_BODY_CHARS)}`\n : \"\";\n return `@${review.user.login}: ${review.state}${body}`;\n });\n // Thread roots only: replies belong to their root's thread. The rc- id\n // is what github_review_reply takes.\n const rootThreads = result.threads.filter((comment) => comment.in_reply_to_id === undefined);\n const threadLines = rootThreads.map((comment) => {\n const location = comment.line !== null ? `${comment.path}:${comment.line}` : comment.path;\n const replies = result.threads.filter((reply) => reply.in_reply_to_id === comment.id);\n const replyNote =\n replies.length > 0\n ? ` (${replies.length} repl${replies.length === 1 ? \"y\" : \"ies\"})`\n : \"\";\n return `rc-${comment.id} ${location} @${comment.user.login}${replyNote}: ${truncate(comment.body, MAX_REVIEW_BODY_CHARS)}`;\n });\n return [\n reviewLines.length > 0 ? `Reviews:\\n${reviewLines.join(\"\\n\")}` : \"No submitted reviews.\",\n threadLines.length > 0\n ? `Inline threads (reply with github_review_reply):\\n${threadLines.join(\"\\n\")}`\n : \"No inline review threads.\",\n ].join(\"\\n\\n\");\n }\n case \"issue\": {\n const issue = result.issue;\n const labels = (issue.labels ?? []).map((label) => label.name).join(\", \");\n const assignees = (issue.assignees ?? []).map((assignee) => `@${assignee.login}`).join(\", \");\n return [\n `#${issue.number}: ${issue.title} [${issue.state ?? \"unknown\"}${issue.pull_request ? \", PR\" : \"\"}]`,\n labels ? `labels: ${labels}` : null,\n assignees ? `assignees: ${assignees}` : null,\n `author: @${issue.user.login}`,\n issue.body ? truncate(issue.body, MAX_BODY_CHARS) : \"(no body)\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n }\n case \"comments\": {\n if (result.comments.length === 0) return \"No comments.\";\n return result.comments\n .map(\n (comment) =>\n `@${comment.user.login} (${comment.created_at}): ${truncate(comment.body, MAX_COMMENT_CHARS)}`,\n )\n .join(\"\\n\");\n }\n case \"list\": {\n if (result.issues.length === 0) return \"No matching issues.\";\n return result.issues\n .map((issue) => {\n const labels = (issue.labels ?? []).map((label) => label.name).join(\", \");\n const kind = issue.pull_request ? \"PR\" : \"issue\";\n return `#${issue.number} [${issue.state ?? \"?\"} ${kind}] ${issue.title}${labels ? ` (${labels})` : \"\"}`;\n })\n .join(\"\\n\");\n }\n }\n}\n\nexport type GithubReadFn = (request: GithubReadRequest) => Promise<GithubReadResult>;\n\n/**\n * The `github_read` tool reads what the ./repo clone cannot show: PR diff\n * stats and changed files, review state with open inline threads, and other\n * issues/PRs in this repo for triage. Read-only, host-side, same-repo by\n * construction; wired per run and only for GitHub conversations.\n */\nexport function createGithubReadTool(): {\n tool: AgentTool<typeof githubReadSchema>;\n setGithubReadFunction: (fn: GithubReadFn | null) => void;\n} {\n let readFn: GithubReadFn | null = null;\n\n const tool: AgentTool<typeof githubReadSchema> = {\n name: \"github_read\",\n label: \"github_read\",\n description:\n \"Read GitHub metadata for this repo: PR state/diff stats (pr), changed files \" +\n \"(pr_files), reviews and open inline threads (pr_reviews), issue metadata (issue), \" +\n \"recent comments (comments), or a filtered issue/PR listing (list). number defaults \" +\n \"to this conversation's issue/PR. Only available in GitHub conversations.\",\n parameters: githubReadSchema,\n execute: async (_toolCallId: string, args: GithubReadRequest, signal?: AbortSignal) => {\n if (!readFn) {\n throw new Error(\"github_read is only available in GitHub conversations.\");\n }\n if (signal?.aborted) {\n throw new Error(\"Operation aborted\");\n }\n const result = await readFn(args);\n return {\n content: [{ type: \"text\" as const, text: formatResult(result) }],\n details: undefined,\n };\n },\n };\n\n return {\n tool,\n setGithubReadFunction: (fn) => {\n readFn = fn;\n },\n };\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import type { AgentTool } from "@earendil-works/pi-agent-core";
2
+ declare const githubReviewReplySchema: import("@sinclair/typebox").TObject<{
3
+ comment_id: import("@sinclair/typebox").TNumber;
4
+ body: import("@sinclair/typebox").TString;
5
+ }>;
6
+ export type GithubReviewReplyFn = (commentId: number, body: string) => Promise<{
7
+ url: string;
8
+ }>;
9
+ /**
10
+ * The `github_review_reply` tool answers inside one inline PR review thread
11
+ * (the responder's normal replies post as plain PR comments instead). Runs
12
+ * host-side as the App; wired per run and only for GitHub conversations.
13
+ */
14
+ export declare function createGithubReviewReplyTool(): {
15
+ tool: AgentTool<typeof githubReviewReplySchema>;
16
+ setGithubReviewReplyFunction: (fn: GithubReviewReplyFn | null) => void;
17
+ };
18
+ export {};
19
+ //# sourceMappingURL=review-reply.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-reply.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/review-reply.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,QAAA,MAAM,uBAAuB;;;EAO3B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEhG;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI;IAC7C,IAAI,EAAE,SAAS,CAAC,OAAO,uBAAuB,CAAC,CAAC;IAChD,4BAA4B,EAAE,CAAC,EAAE,EAAE,mBAAmB,GAAG,IAAI,KAAK,IAAI,CAAC;CACxE,CAyCA"}
@@ -0,0 +1,49 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ const githubReviewReplySchema = Type.Object({
3
+ comment_id: Type.Number({
4
+ description: "Numeric id from an [PR review comment rc-<id> …] message in this conversation " +
5
+ "(e.g. 8001 for rc-8001). The reply lands inside that comment's thread.",
6
+ }),
7
+ body: Type.String({ description: "Reply text (Markdown)." }),
8
+ });
9
+ /**
10
+ * The `github_review_reply` tool answers inside one inline PR review thread
11
+ * (the responder's normal replies post as plain PR comments instead). Runs
12
+ * host-side as the App; wired per run and only for GitHub conversations.
13
+ */
14
+ export function createGithubReviewReplyTool() {
15
+ let replyFn = null;
16
+ const tool = {
17
+ name: "github_review_reply",
18
+ label: "github_review_reply",
19
+ description: "Reply inside a specific PR review thread. Use the numeric id from an " +
20
+ "[PR review comment rc-<id> …] message as comment_id; a plain response would post " +
21
+ "as a normal PR comment instead of in-thread. Only available in GitHub PR conversations.",
22
+ parameters: githubReviewReplySchema,
23
+ execute: async (_toolCallId, args, signal) => {
24
+ if (!replyFn) {
25
+ throw new Error("github_review_reply is only available in GitHub conversations.");
26
+ }
27
+ if (signal?.aborted) {
28
+ throw new Error("Operation aborted");
29
+ }
30
+ const result = await replyFn(args.comment_id, args.body);
31
+ return {
32
+ content: [
33
+ {
34
+ type: "text",
35
+ text: `Replied in review thread rc-${args.comment_id}: ${result.url}`,
36
+ },
37
+ ],
38
+ details: undefined,
39
+ };
40
+ },
41
+ };
42
+ return {
43
+ tool,
44
+ setGithubReviewReplyFunction: (fn) => {
45
+ replyFn = fn;
46
+ },
47
+ };
48
+ }
49
+ //# sourceMappingURL=review-reply.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-reply.js","sourceRoot":"","sources":["../../../../src/adapters/github/tools/review-reply.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,MAAM,uBAAuB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1C,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC;QACtB,WAAW,EACT,gFAAgF;YAChF,wEAAwE;KAC3E,CAAC;IACF,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC;CAC7D,CAAC,CAAC;AAIH;;;;GAIG;AACH,MAAM,UAAU,2BAA2B;IAIzC,IAAI,OAAO,GAA+B,IAAI,CAAC;IAE/C,MAAM,IAAI,GAA8C;QACtD,IAAI,EAAE,qBAAqB;QAC3B,KAAK,EAAE,qBAAqB;QAC5B,WAAW,EACT,uEAAuE;YACvE,mFAAmF;YACnF,yFAAyF;QAC3F,UAAU,EAAE,uBAAuB;QACnC,OAAO,EAAE,KAAK,EACZ,WAAmB,EACnB,IAA0C,EAC1C,MAAoB,EACpB,EAAE;YACF,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;YACpF,CAAC;YACD,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACvC,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACzD,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,+BAA+B,IAAI,CAAC,UAAU,KAAK,MAAM,CAAC,GAAG,EAAE;qBACtE;iBACF;gBACD,OAAO,EAAE,SAAS;aACnB,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,OAAO;QACL,IAAI;QACJ,4BAA4B,EAAE,CAAC,EAAE,EAAE,EAAE;YACnC,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Type } from \"@sinclair/typebox\";\n\nconst githubReviewReplySchema = Type.Object({\n comment_id: Type.Number({\n description:\n \"Numeric id from an [PR review comment rc-<id> …] message in this conversation \" +\n \"(e.g. 8001 for rc-8001). The reply lands inside that comment's thread.\",\n }),\n body: Type.String({ description: \"Reply text (Markdown).\" }),\n});\n\nexport type GithubReviewReplyFn = (commentId: number, body: string) => Promise<{ url: string }>;\n\n/**\n * The `github_review_reply` tool answers inside one inline PR review thread\n * (the responder's normal replies post as plain PR comments instead). Runs\n * host-side as the App; wired per run and only for GitHub conversations.\n */\nexport function createGithubReviewReplyTool(): {\n tool: AgentTool<typeof githubReviewReplySchema>;\n setGithubReviewReplyFunction: (fn: GithubReviewReplyFn | null) => void;\n} {\n let replyFn: GithubReviewReplyFn | null = null;\n\n const tool: AgentTool<typeof githubReviewReplySchema> = {\n name: \"github_review_reply\",\n label: \"github_review_reply\",\n description:\n \"Reply inside a specific PR review thread. Use the numeric id from an \" +\n \"[PR review comment rc-<id> …] message as comment_id; a plain response would post \" +\n \"as a normal PR comment instead of in-thread. Only available in GitHub PR conversations.\",\n parameters: githubReviewReplySchema,\n execute: async (\n _toolCallId: string,\n args: { comment_id: number; body: string },\n signal?: AbortSignal,\n ) => {\n if (!replyFn) {\n throw new Error(\"github_review_reply is only available in GitHub conversations.\");\n }\n if (signal?.aborted) {\n throw new Error(\"Operation aborted\");\n }\n const result = await replyFn(args.comment_id, args.body);\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Replied in review thread rc-${args.comment_id}: ${result.url}`,\n },\n ],\n details: undefined,\n };\n },\n };\n\n return {\n tool,\n setGithubReviewReplyFunction: (fn) => {\n replyFn = fn;\n },\n };\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { AgentTool } from "@earendil-works/pi-agent-core";
2
+ declare const githubSyncSchema: import("@sinclair/typebox").TObject<{
3
+ branch: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
4
+ }>;
5
+ export type GithubSyncFn = (branch?: string) => Promise<string>;
6
+ /**
7
+ * The `github_sync` tool refreshes the conversation's ./repo clone — a
8
+ * first-contact snapshot the sandbox cannot update itself (no credentials).
9
+ * Host-side fetch with an ephemeral read token; it reports instead of moving
10
+ * the checkout whenever that could lose the agent's local work.
11
+ */
12
+ export declare function createGithubSyncTool(): {
13
+ tool: AgentTool<typeof githubSyncSchema>;
14
+ setGithubSyncFunction: (fn: GithubSyncFn | null) => void;
15
+ };
16
+ export {};
17
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../src/adapters/github/tools/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,QAAA,MAAM,gBAAgB;;EAQpB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI;IACtC,IAAI,EAAE,SAAS,CAAC,OAAO,gBAAgB,CAAC,CAAC;IACzC,qBAAqB,EAAE,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,KAAK,IAAI,CAAC;CAC1D,CAiCA"}