@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.
- package/CHANGELOG.md +388 -0
- package/README.md +49 -16
- package/dist/adapter.d.ts +1 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js.map +1 -1
- package/dist/adapters/buffered-responder.d.ts +60 -0
- package/dist/adapters/buffered-responder.d.ts.map +1 -0
- package/dist/adapters/buffered-responder.js +201 -0
- package/dist/adapters/buffered-responder.js.map +1 -0
- package/dist/adapters/discord/bot.d.ts +1 -0
- package/dist/adapters/discord/bot.d.ts.map +1 -1
- package/dist/adapters/discord/bot.js +36 -67
- package/dist/adapters/discord/bot.js.map +1 -1
- package/dist/adapters/discord/context.d.ts.map +1 -1
- package/dist/adapters/discord/context.js +44 -204
- package/dist/adapters/discord/context.js.map +1 -1
- package/dist/adapters/github/bot.d.ts +86 -0
- package/dist/adapters/github/bot.d.ts.map +1 -0
- package/dist/adapters/github/bot.js +640 -0
- package/dist/adapters/github/bot.js.map +1 -0
- package/dist/adapters/github/client.d.ts +122 -0
- package/dist/adapters/github/client.d.ts.map +1 -0
- package/dist/adapters/github/client.js +314 -0
- package/dist/adapters/github/client.js.map +1 -0
- package/dist/adapters/github/cloudbuild.d.ts +24 -0
- package/dist/adapters/github/cloudbuild.d.ts.map +1 -0
- package/dist/adapters/github/cloudbuild.js +71 -0
- package/dist/adapters/github/cloudbuild.js.map +1 -0
- package/dist/adapters/github/context.d.ts +9 -0
- package/dist/adapters/github/context.d.ts.map +1 -0
- package/dist/adapters/github/context.js +103 -0
- package/dist/adapters/github/context.js.map +1 -0
- package/dist/adapters/github/gcp-auth.d.ts +31 -0
- package/dist/adapters/github/gcp-auth.d.ts.map +1 -0
- package/dist/adapters/github/gcp-auth.js +196 -0
- package/dist/adapters/github/gcp-auth.js.map +1 -0
- package/dist/adapters/github/github-ops.d.ts +90 -0
- package/dist/adapters/github/github-ops.d.ts.map +1 -0
- package/dist/adapters/github/github-ops.js +405 -0
- package/dist/adapters/github/github-ops.js.map +1 -0
- package/dist/adapters/github/ids.d.ts +34 -0
- package/dist/adapters/github/ids.d.ts.map +1 -0
- package/dist/adapters/github/ids.js +53 -0
- package/dist/adapters/github/ids.js.map +1 -0
- package/dist/adapters/github/repo.d.ts +32 -0
- package/dist/adapters/github/repo.d.ts.map +1 -0
- package/dist/adapters/github/repo.js +141 -0
- package/dist/adapters/github/repo.js.map +1 -0
- package/dist/adapters/github/tool-pack.d.ts +14 -0
- package/dist/adapters/github/tool-pack.d.ts.map +1 -0
- package/dist/adapters/github/tool-pack.js +56 -0
- package/dist/adapters/github/tool-pack.js.map +1 -0
- package/dist/adapters/github/tools/checks.d.ts +24 -0
- package/dist/adapters/github/tools/checks.d.ts.map +1 -0
- package/dist/adapters/github/tools/checks.js +105 -0
- package/dist/adapters/github/tools/checks.js.map +1 -0
- package/dist/adapters/github/tools/issue.d.ts +22 -0
- package/dist/adapters/github/tools/issue.d.ts.map +1 -0
- package/dist/adapters/github/tools/issue.js +48 -0
- package/dist/adapters/github/tools/issue.js.map +1 -0
- package/dist/adapters/github/tools/pr.d.ts +22 -0
- package/dist/adapters/github/tools/pr.d.ts.map +1 -0
- package/dist/adapters/github/tools/pr.js +48 -0
- package/dist/adapters/github/tools/pr.js.map +1 -0
- package/dist/adapters/github/tools/read.d.ts +22 -0
- package/dist/adapters/github/tools/read.d.ts.map +1 -0
- package/dist/adapters/github/tools/read.js +141 -0
- package/dist/adapters/github/tools/read.js.map +1 -0
- package/dist/adapters/github/tools/review-reply.d.ts +19 -0
- package/dist/adapters/github/tools/review-reply.d.ts.map +1 -0
- package/dist/adapters/github/tools/review-reply.js +38 -0
- package/dist/adapters/github/tools/review-reply.js.map +1 -0
- package/dist/adapters/github/tools/sync.d.ts +17 -0
- package/dist/adapters/github/tools/sync.d.ts.map +1 -0
- package/dist/adapters/github/tools/sync.js +34 -0
- package/dist/adapters/github/tools/sync.js.map +1 -0
- package/dist/adapters/github/types.d.ts +350 -0
- package/dist/adapters/github/types.d.ts.map +1 -0
- package/dist/adapters/github/types.js +2 -0
- package/dist/adapters/github/types.js.map +1 -0
- package/dist/adapters/intake.d.ts +16 -5
- package/dist/adapters/intake.d.ts.map +1 -1
- package/dist/adapters/intake.js +79 -22
- package/dist/adapters/intake.js.map +1 -1
- package/dist/adapters/slack/bot.d.ts +8 -6
- package/dist/adapters/slack/bot.d.ts.map +1 -1
- package/dist/adapters/slack/bot.js +82 -134
- package/dist/adapters/slack/bot.js.map +1 -1
- package/dist/adapters/slack/context.d.ts.map +1 -1
- package/dist/adapters/slack/context.js +3 -14
- package/dist/adapters/slack/context.js.map +1 -1
- package/dist/adapters/slack/response-lifecycle.d.ts.map +1 -1
- package/dist/adapters/slack/response-lifecycle.js +14 -17
- package/dist/adapters/slack/response-lifecycle.js.map +1 -1
- package/dist/adapters/slack/session.d.ts.map +1 -1
- package/dist/adapters/slack/session.js +5 -8
- package/dist/adapters/slack/session.js.map +1 -1
- package/dist/adapters/streaming.d.ts +4 -0
- package/dist/adapters/streaming.d.ts.map +1 -1
- package/dist/adapters/streaming.js +11 -0
- package/dist/adapters/streaming.js.map +1 -1
- package/dist/adapters/telegram/bot.d.ts +1 -2
- package/dist/adapters/telegram/bot.d.ts.map +1 -1
- package/dist/adapters/telegram/bot.js +27 -62
- package/dist/adapters/telegram/bot.js.map +1 -1
- package/dist/adapters/telegram/context.d.ts.map +1 -1
- package/dist/adapters/telegram/context.js +37 -174
- package/dist/adapters/telegram/context.js.map +1 -1
- package/dist/adapters/types.d.ts +28 -2
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/adapters/types.js.map +1 -1
- package/dist/agent.d.ts +37 -14
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +359 -229
- package/dist/agent.js.map +1 -1
- package/dist/cli/arg-grammar.d.ts +25 -0
- package/dist/cli/arg-grammar.d.ts.map +1 -0
- package/dist/cli/arg-grammar.js +59 -0
- package/dist/cli/arg-grammar.js.map +1 -0
- package/dist/cli/boot.d.ts +16 -0
- package/dist/cli/boot.d.ts.map +1 -0
- package/dist/cli/boot.js +119 -0
- package/dist/cli/boot.js.map +1 -0
- package/dist/cli/download.d.ts.map +1 -0
- package/dist/cli/download.js.map +1 -0
- package/dist/cli/ext-git.d.ts +22 -0
- package/dist/cli/ext-git.d.ts.map +1 -0
- package/dist/cli/ext-git.js +76 -0
- package/dist/cli/ext-git.js.map +1 -0
- package/dist/cli/ext.d.ts +2 -0
- package/dist/cli/ext.d.ts.map +1 -0
- package/dist/cli/ext.js +215 -0
- package/dist/cli/ext.js.map +1 -0
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +2 -1
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/auto-reply.d.ts.map +1 -1
- package/dist/commands/auto-reply.js +2 -6
- package/dist/commands/auto-reply.js.map +1 -1
- package/dist/commands/extensions.d.ts.map +1 -1
- package/dist/commands/extensions.js +18 -8
- package/dist/commands/extensions.js.map +1 -1
- package/dist/commands/login.d.ts +2 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +35 -3
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/manifest.d.ts +72 -0
- package/dist/commands/manifest.d.ts.map +1 -0
- package/dist/commands/manifest.js +121 -0
- package/dist/commands/manifest.js.map +1 -0
- package/dist/commands/model.d.ts.map +1 -1
- package/dist/commands/model.js +11 -9
- package/dist/commands/model.js.map +1 -1
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +2 -1
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/sandbox.d.ts.map +1 -1
- package/dist/commands/sandbox.js +23 -17
- package/dist/commands/sandbox.js.map +1 -1
- package/dist/commands/text.d.ts +2 -0
- package/dist/commands/text.d.ts.map +1 -0
- package/dist/commands/text.js +16 -0
- package/dist/commands/text.js.map +1 -0
- package/dist/commands/types.d.ts +14 -1
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/types.js.map +1 -1
- package/dist/config.d.ts +1 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +98 -95
- package/dist/config.js.map +1 -1
- package/dist/env-manifest.d.ts +35 -0
- package/dist/env-manifest.d.ts.map +1 -0
- package/dist/env-manifest.js +225 -0
- package/dist/env-manifest.js.map +1 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +9 -73
- package/dist/events.js.map +1 -1
- package/dist/execution-resolver.d.ts +4 -2
- package/dist/execution-resolver.d.ts.map +1 -1
- package/dist/execution-resolver.js +54 -41
- package/dist/execution-resolver.js.map +1 -1
- package/dist/harness/event-format.d.ts +66 -0
- package/dist/harness/event-format.d.ts.map +1 -0
- package/dist/harness/event-format.js +112 -0
- package/dist/harness/event-format.js.map +1 -0
- package/dist/harness/extensions/loader.d.ts +44 -11
- package/dist/harness/extensions/loader.d.ts.map +1 -1
- package/dist/harness/extensions/loader.js +273 -84
- package/dist/harness/extensions/loader.js.map +1 -1
- package/dist/harness/extensions/registry.d.ts +48 -1
- package/dist/harness/extensions/registry.d.ts.map +1 -1
- package/dist/harness/extensions/registry.js +146 -0
- package/dist/harness/extensions/registry.js.map +1 -1
- package/dist/harness/extensions/types.d.ts +165 -22
- package/dist/harness/extensions/types.d.ts.map +1 -1
- package/dist/harness/extensions/types.js.map +1 -1
- package/dist/harness/index.d.ts +6 -5
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +3 -2
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/models.d.ts +5 -0
- package/dist/harness/models.d.ts.map +1 -1
- package/dist/harness/models.js +10 -0
- package/dist/harness/models.js.map +1 -1
- package/dist/harness/runner.d.ts +37 -2
- package/dist/harness/runner.d.ts.map +1 -1
- package/dist/harness/runner.js +107 -23
- package/dist/harness/runner.js.map +1 -1
- package/dist/harness/session-store.d.ts +4 -1
- package/dist/harness/session-store.d.ts.map +1 -1
- package/dist/harness/session-store.js +11 -2
- package/dist/harness/session-store.js.map +1 -1
- package/dist/harness/subagent-runner.d.ts +34 -0
- package/dist/harness/subagent-runner.d.ts.map +1 -0
- package/dist/harness/subagent-runner.js +339 -0
- package/dist/harness/subagent-runner.js.map +1 -0
- package/dist/harness/types.d.ts +53 -0
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/harness/types.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/main.js +260 -109
- package/dist/main.js.map +1 -1
- package/dist/observability/instrument.js +6 -4
- package/dist/observability/instrument.js.map +1 -1
- package/dist/observability/sentry.d.ts.map +1 -1
- package/dist/observability/sentry.js +3 -2
- package/dist/observability/sentry.js.map +1 -1
- package/dist/provisioner.d.ts.map +1 -1
- package/dist/provisioner.js +2 -5
- package/dist/provisioner.js.map +1 -1
- package/dist/runtime/conversation-runtime.d.ts +1 -1
- package/dist/runtime/conversation-runtime.d.ts.map +1 -1
- package/dist/runtime/conversation-runtime.js +276 -43
- package/dist/runtime/conversation-runtime.js.map +1 -1
- package/dist/runtime/types.d.ts +36 -5
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/types.js.map +1 -1
- package/dist/sandbox/cloudflare.d.ts +3 -0
- package/dist/sandbox/cloudflare.d.ts.map +1 -1
- package/dist/sandbox/cloudflare.js +10 -0
- package/dist/sandbox/cloudflare.js.map +1 -1
- package/dist/sandbox/container.d.ts +4 -0
- package/dist/sandbox/container.d.ts.map +1 -1
- package/dist/sandbox/container.js +11 -2
- package/dist/sandbox/container.js.map +1 -1
- package/dist/sandbox/firecracker.d.ts +3 -0
- package/dist/sandbox/firecracker.d.ts.map +1 -1
- package/dist/sandbox/firecracker.js +10 -1
- package/dist/sandbox/firecracker.js.map +1 -1
- package/dist/sandbox/gondolin-bootstrap.d.ts +26 -0
- package/dist/sandbox/gondolin-bootstrap.d.ts.map +1 -0
- package/dist/sandbox/gondolin-bootstrap.js +27 -0
- package/dist/sandbox/gondolin-bootstrap.js.map +1 -0
- package/dist/sandbox/gondolin-contract.d.ts +125 -0
- package/dist/sandbox/gondolin-contract.d.ts.map +1 -0
- package/dist/sandbox/gondolin-contract.js +155 -0
- package/dist/sandbox/gondolin-contract.js.map +1 -0
- package/dist/sandbox/gondolin-fleet.d.ts +104 -0
- package/dist/sandbox/gondolin-fleet.d.ts.map +1 -0
- package/dist/sandbox/gondolin-fleet.js +330 -0
- package/dist/sandbox/gondolin-fleet.js.map +1 -0
- package/dist/sandbox/gondolin-gateway.d.ts +86 -0
- package/dist/sandbox/gondolin-gateway.d.ts.map +1 -0
- package/dist/sandbox/gondolin-gateway.js +407 -0
- package/dist/sandbox/gondolin-gateway.js.map +1 -0
- package/dist/sandbox/gondolin-inventory.d.ts +75 -0
- package/dist/sandbox/gondolin-inventory.d.ts.map +1 -0
- package/dist/sandbox/gondolin-inventory.js +257 -0
- package/dist/sandbox/gondolin-inventory.js.map +1 -0
- package/dist/sandbox/gondolin-join.d.ts +62 -0
- package/dist/sandbox/gondolin-join.d.ts.map +1 -0
- package/dist/sandbox/gondolin-join.js +261 -0
- package/dist/sandbox/gondolin-join.js.map +1 -0
- package/dist/sandbox/gondolin-nfs-advisory.d.ts +15 -0
- package/dist/sandbox/gondolin-nfs-advisory.d.ts.map +1 -0
- package/dist/sandbox/gondolin-nfs-advisory.js +60 -0
- package/dist/sandbox/gondolin-nfs-advisory.js.map +1 -0
- package/dist/sandbox/gondolin-placement.d.ts +30 -0
- package/dist/sandbox/gondolin-placement.d.ts.map +1 -0
- package/dist/sandbox/gondolin-placement.js +77 -0
- package/dist/sandbox/gondolin-placement.js.map +1 -0
- package/dist/sandbox/gondolin-recovery.d.ts +33 -0
- package/dist/sandbox/gondolin-recovery.d.ts.map +1 -0
- package/dist/sandbox/gondolin-recovery.js +39 -0
- package/dist/sandbox/gondolin-recovery.js.map +1 -0
- package/dist/sandbox/gondolin-remote.d.ts +70 -0
- package/dist/sandbox/gondolin-remote.d.ts.map +1 -0
- package/dist/sandbox/gondolin-remote.js +325 -0
- package/dist/sandbox/gondolin-remote.js.map +1 -0
- package/dist/sandbox/gondolin-worker-client.d.ts +135 -0
- package/dist/sandbox/gondolin-worker-client.d.ts.map +1 -0
- package/dist/sandbox/gondolin-worker-client.js +323 -0
- package/dist/sandbox/gondolin-worker-client.js.map +1 -0
- package/dist/sandbox/gondolin-worker-main.d.ts +2 -0
- package/dist/sandbox/gondolin-worker-main.d.ts.map +1 -0
- package/dist/sandbox/gondolin-worker-main.js +22 -0
- package/dist/sandbox/gondolin-worker-main.js.map +1 -0
- package/dist/sandbox/gondolin-worker.d.ts +17 -0
- package/dist/sandbox/gondolin-worker.d.ts.map +1 -0
- package/dist/sandbox/gondolin-worker.js +201 -0
- package/dist/sandbox/gondolin-worker.js.map +1 -0
- package/dist/sandbox/gondolin.d.ts +53 -0
- package/dist/sandbox/gondolin.d.ts.map +1 -0
- package/dist/sandbox/gondolin.js +429 -0
- package/dist/sandbox/gondolin.js.map +1 -0
- package/dist/sandbox/host.d.ts +3 -0
- package/dist/sandbox/host.d.ts.map +1 -1
- package/dist/sandbox/host.js +14 -0
- package/dist/sandbox/host.js.map +1 -1
- package/dist/sandbox/identity.d.ts +21 -0
- package/dist/sandbox/identity.d.ts.map +1 -0
- package/dist/sandbox/identity.js +36 -0
- package/dist/sandbox/identity.js.map +1 -0
- package/dist/sandbox/index.d.ts +13 -4
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/index.js +19 -3
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/types.d.ts +31 -1
- package/dist/sandbox/types.d.ts.map +1 -1
- package/dist/sandbox/types.js.map +1 -1
- package/dist/sandbox/utils.d.ts +12 -0
- package/dist/sandbox/utils.d.ts.map +1 -1
- package/dist/sandbox/utils.js +38 -0
- package/dist/sandbox/utils.js.map +1 -1
- package/dist/sessions/chat-history-sync.d.ts +32 -0
- package/dist/sessions/chat-history-sync.d.ts.map +1 -0
- package/dist/sessions/{agent-memory-file-manager.js → chat-history-sync.js} +40 -113
- package/dist/sessions/chat-history-sync.js.map +1 -0
- package/dist/sessions/conversation-log.d.ts +13 -0
- package/dist/sessions/conversation-log.d.ts.map +1 -0
- package/dist/sessions/conversation-log.js +47 -0
- package/dist/sessions/conversation-log.js.map +1 -0
- package/dist/sessions/history-line.d.ts +20 -0
- package/dist/sessions/history-line.d.ts.map +1 -0
- package/dist/sessions/history-line.js +24 -0
- package/dist/sessions/history-line.js.map +1 -0
- package/dist/sessions/policy.d.ts.map +1 -1
- package/dist/sessions/policy.js +5 -3
- package/dist/sessions/policy.js.map +1 -1
- package/dist/sessions/rotation.d.ts +2 -0
- package/dist/sessions/rotation.d.ts.map +1 -0
- package/dist/sessions/rotation.js +39 -0
- package/dist/sessions/rotation.js.map +1 -0
- package/dist/sessions/session-key.d.ts +31 -0
- package/dist/sessions/session-key.d.ts.map +1 -0
- package/dist/sessions/session-key.js +44 -0
- package/dist/sessions/session-key.js.map +1 -0
- package/dist/sessions/store.d.ts.map +1 -1
- package/dist/sessions/store.js +6 -12
- package/dist/sessions/store.js.map +1 -1
- package/dist/sessions/types.d.ts +2 -2
- package/dist/sessions/types.d.ts.map +1 -1
- package/dist/sessions/types.js.map +1 -1
- package/dist/settings-mutation.d.ts +23 -0
- package/dist/settings-mutation.d.ts.map +1 -0
- package/dist/settings-mutation.js +42 -0
- package/dist/settings-mutation.js.map +1 -0
- package/dist/tools/bash.d.ts +3 -1
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +24 -17
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/edit.d.ts.map +1 -1
- package/dist/tools/edit.js +9 -12
- package/dist/tools/edit.js.map +1 -1
- package/dist/tools/event.d.ts +1 -1
- package/dist/tools/event.d.ts.map +1 -1
- package/dist/tools/event.js +53 -43
- package/dist/tools/event.js.map +1 -1
- package/dist/tools/generate-image.d.ts +17 -0
- package/dist/tools/generate-image.d.ts.map +1 -0
- package/dist/tools/generate-image.js +63 -0
- package/dist/tools/generate-image.js.map +1 -0
- package/dist/tools/host-fn-tool.d.ts +21 -0
- package/dist/tools/host-fn-tool.d.ts.map +1 -0
- package/dist/tools/host-fn-tool.js +32 -0
- package/dist/tools/host-fn-tool.js.map +1 -0
- package/dist/tools/index.d.ts +17 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +28 -3
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/react.d.ts +15 -0
- package/dist/tools/react.d.ts.map +1 -0
- package/dist/tools/react.js +29 -0
- package/dist/tools/react.js.map +1 -0
- package/dist/tools/read.d.ts.map +1 -1
- package/dist/tools/read.js +7 -26
- package/dist/tools/read.js.map +1 -1
- package/dist/tools/sandbox.d.ts +2 -2
- package/dist/tools/sandbox.d.ts.map +1 -1
- package/dist/tools/sandbox.js +13 -9
- package/dist/tools/sandbox.js.map +1 -1
- package/dist/tools/subagent-slots.d.ts +28 -0
- package/dist/tools/subagent-slots.d.ts.map +1 -0
- package/dist/tools/subagent-slots.js +57 -0
- package/dist/tools/subagent-slots.js.map +1 -0
- package/dist/tools/subagent.d.ts +74 -0
- package/dist/tools/subagent.d.ts.map +1 -0
- package/dist/tools/subagent.js +335 -0
- package/dist/tools/subagent.js.map +1 -0
- package/dist/tools/types.d.ts +40 -6
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js.map +1 -1
- package/dist/tools/write.d.ts.map +1 -1
- package/dist/tools/write.js +1 -8
- package/dist/tools/write.js.map +1 -1
- package/dist/trigger.d.ts.map +1 -1
- package/dist/trigger.js +1 -2
- package/dist/trigger.js.map +1 -1
- package/dist/types.d.ts +144 -31
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/date.d.ts +1 -1
- package/dist/utils/date.js +1 -1
- package/dist/utils/date.js.map +1 -1
- package/dist/vault/disabled.d.ts +9 -0
- package/dist/vault/disabled.d.ts.map +1 -0
- package/dist/vault/disabled.js +22 -0
- package/dist/vault/disabled.js.map +1 -0
- package/dist/vault/index.d.ts +0 -2
- package/dist/vault/index.d.ts.map +1 -1
- package/dist/vault/index.js +1 -32
- package/dist/vault/index.js.map +1 -1
- package/dist/vault/injection.d.ts +20 -0
- package/dist/vault/injection.d.ts.map +1 -0
- package/dist/vault/injection.js +27 -0
- package/dist/vault/injection.js.map +1 -0
- package/dist/vault/policy.d.ts +20 -0
- package/dist/vault/policy.d.ts.map +1 -0
- package/dist/vault/policy.js +20 -0
- package/dist/vault/policy.js.map +1 -0
- package/dist/vault/types.d.ts +0 -2
- package/dist/vault/types.d.ts.map +1 -1
- package/dist/vault/types.js.map +1 -1
- package/dist/web/admin/portal.d.ts +27 -0
- package/dist/web/admin/portal.d.ts.map +1 -1
- package/dist/web/admin/portal.js +117 -154
- package/dist/web/admin/portal.js.map +1 -1
- package/dist/web/admin/types.d.ts +6 -0
- package/dist/web/admin/types.d.ts.map +1 -1
- package/dist/web/admin/types.js.map +1 -1
- package/dist/web/agent-events/portal.d.ts.map +1 -1
- package/dist/web/agent-events/portal.js +2 -1
- package/dist/web/agent-events/portal.js.map +1 -1
- package/dist/web/login/oauth.d.ts +2 -3
- package/dist/web/login/oauth.d.ts.map +1 -1
- package/dist/web/login/oauth.js +0 -31
- package/dist/web/login/oauth.js.map +1 -1
- package/dist/web/login/portal.js +1 -1
- package/dist/web/login/portal.js.map +1 -1
- package/dist/web/login/types.d.ts +0 -11
- package/dist/web/login/types.d.ts.map +1 -1
- package/dist/web/login/types.js.map +1 -1
- package/dist/web/portal-shell.d.ts +4 -0
- package/dist/web/portal-shell.d.ts.map +1 -0
- package/dist/{portal-shell.js → web/portal-shell.js} +2 -2
- package/dist/web/portal-shell.js.map +1 -0
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +7 -0
- package/dist/web/server.js.map +1 -1
- package/dist/web/session-view/command.d.ts.map +1 -1
- package/dist/web/session-view/command.js +4 -1
- package/dist/web/session-view/command.js.map +1 -1
- package/dist/web/session-view/portal.d.ts.map +1 -1
- package/dist/web/session-view/portal.js +4 -3
- package/dist/web/session-view/portal.js.map +1 -1
- package/dist/web/session-view/service.d.ts.map +1 -1
- package/dist/web/session-view/service.js +2 -1
- package/dist/web/session-view/service.js.map +1 -1
- package/dist/web/session-view/types.d.ts +2 -1
- package/dist/web/session-view/types.d.ts.map +1 -1
- package/dist/web/session-view/types.js.map +1 -1
- package/package.json +7 -4
- package/dist/download.d.ts.map +0 -1
- package/dist/download.js.map +0 -1
- package/dist/model-registry.d.ts +0 -4
- package/dist/model-registry.d.ts.map +0 -1
- package/dist/model-registry.js +0 -7
- package/dist/model-registry.js.map +0 -1
- package/dist/portal-shell.d.ts +0 -4
- package/dist/portal-shell.d.ts.map +0 -1
- package/dist/portal-shell.js.map +0 -1
- package/dist/runtime/agent-run-controller.d.ts +0 -31
- package/dist/runtime/agent-run-controller.d.ts.map +0 -1
- package/dist/runtime/agent-run-controller.js +0 -195
- package/dist/runtime/agent-run-controller.js.map +0 -1
- package/dist/sessions/agent-memory-file-manager.d.ts +0 -19
- package/dist/sessions/agent-memory-file-manager.d.ts.map +0 -1
- package/dist/sessions/agent-memory-file-manager.js.map +0 -1
- package/dist/vault/routing.d.ts +0 -3
- package/dist/vault/routing.d.ts.map +0 -1
- package/dist/vault/routing.js +0 -13
- package/dist/vault/routing.js.map +0 -1
- /package/dist/{download.d.ts → cli/download.d.ts} +0 -0
- /package/dist/{download.js → cli/download.js} +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { GithubClient } from "./client.js";
|
|
2
|
+
import type { GithubBotConfig, GithubCheckSummary, GithubConversationRef, GithubIssueRequest, GithubPrRequest, GithubPrResult, GithubReadRequest, GithubReadResult, PlatformGithubOps } from "./types.js";
|
|
3
|
+
/** Whether the conversation's issue is a PR, for callers where the triggering
|
|
4
|
+
* item didn't carry that knowledge. Errs toward plain issue. */
|
|
5
|
+
export declare function fetchIsPr(client: GithubClient, ref: GithubConversationRef): Promise<boolean>;
|
|
6
|
+
/**
|
|
7
|
+
* The PR's head branch name when it lives in this repo — that is the name
|
|
8
|
+
* the local checkout should carry, so committing on it and calling
|
|
9
|
+
* github_pr pushes back to the PR itself instead of opening a new one.
|
|
10
|
+
* Fork heads (unpushable with the repo-scoped token) and failed lookups
|
|
11
|
+
* return undefined; callers then fall back to the synthetic pr-<n>.
|
|
12
|
+
*/
|
|
13
|
+
export declare function fetchPrHeadBranch(client: GithubClient, ref: GithubConversationRef): Promise<string | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Host-side backend of the github_* tool pack (`PlatformGithubOps`),
|
|
16
|
+
* standalone from the messaging bot: it needs the API client, the
|
|
17
|
+
* conversation working dir, and optional Cloud Build access — not the poll
|
|
18
|
+
* loop, queues, or trigger gate. Tokens are minted per call, scoped to the
|
|
19
|
+
* conversation's repo, and never enter the sandbox.
|
|
20
|
+
*/
|
|
21
|
+
export declare class GithubOps implements PlatformGithubOps {
|
|
22
|
+
private readonly client;
|
|
23
|
+
private readonly config;
|
|
24
|
+
/** Cloud Build ids seen in getChecks summaries → their GCP project. */
|
|
25
|
+
private buildRef;
|
|
26
|
+
constructor(client: GithubClient, config: {
|
|
27
|
+
workingDir: string;
|
|
28
|
+
cloudBuild?: GithubBotConfig["cloudBuild"];
|
|
29
|
+
});
|
|
30
|
+
private repoDir;
|
|
31
|
+
/**
|
|
32
|
+
* Backs the `github_pr` tool: push a `pi/*` branch the agent prepared in
|
|
33
|
+
* the conversation's clone, then open a pull request as the App. The write
|
|
34
|
+
* token is minted per call, scoped to this one repo, and never enters the
|
|
35
|
+
* sandbox.
|
|
36
|
+
*/
|
|
37
|
+
pushAndCreatePr(conversationId: string, request: GithubPrRequest): Promise<GithubPrResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Backs the `github_checks` tool: CI check runs for a branch the agent
|
|
40
|
+
* pushed, or for the conversation's PR head when no branch is given.
|
|
41
|
+
*/
|
|
42
|
+
getChecks(conversationId: string, branch?: string): Promise<GithubCheckSummary[]>;
|
|
43
|
+
private rememberBuild;
|
|
44
|
+
/**
|
|
45
|
+
* Backs the Cloud Build log mode of `github_checks`. GCP credentials stay
|
|
46
|
+
* host-side (ADC via GOOGLE_APPLICATION_CREDENTIALS — e.g. a Workload
|
|
47
|
+
* Identity Federation external_account file); the build must have appeared
|
|
48
|
+
* in a github_checks summary first, which is also where its project is
|
|
49
|
+
* learned. Unreadable logs degrade to the console url, never a dead end.
|
|
50
|
+
*/
|
|
51
|
+
getBuildLog(conversationId: string, buildId: string): Promise<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Backs the `github_sync` tool: refresh the conversation's ./repo clone
|
|
54
|
+
* from origin with an ephemeral read token. Fetch-only when moving the
|
|
55
|
+
* checkout could lose agent work; the formatted report tells the agent
|
|
56
|
+
* what happened and what to do next.
|
|
57
|
+
*/
|
|
58
|
+
syncRepo(conversationId: string, branch?: string): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Backs the `github_read` tool: PR/issue metadata the ./repo clone cannot
|
|
61
|
+
* provide (diff stats, review state, other issues in the repo). Owner/repo
|
|
62
|
+
* always come from the conversation id, so reads never leave this repo.
|
|
63
|
+
*/
|
|
64
|
+
readGithub(conversationId: string, request: GithubReadRequest): Promise<GithubReadResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Backs the `github_issue` tool: labels, assignees, and open/closed state
|
|
67
|
+
* on any issue of this conversation's repo (triage). Same-repo by
|
|
68
|
+
* construction — owner/repo come from the conversation id; the action enum
|
|
69
|
+
* is closed, so lock/delete/transfer cannot be expressed at all.
|
|
70
|
+
*/
|
|
71
|
+
manageIssue(conversationId: string, request: GithubIssueRequest): Promise<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Backs the `github_review_reply` tool: answer inside one inline review
|
|
74
|
+
* thread of this conversation's PR. The comment id comes from an
|
|
75
|
+
* `[PR review comment rc-<id> …]` message; GitHub validates it belongs to
|
|
76
|
+
* this PR (404 otherwise, translated into agent-actionable guidance).
|
|
77
|
+
*/
|
|
78
|
+
replyToReviewThread(conversationId: string, commentId: number, body: string): Promise<{
|
|
79
|
+
url: string;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Backs the log mode of `github_checks`: the tail of one CI job's log so
|
|
83
|
+
* the agent can diagnose a failing check without sandbox credentials. Only
|
|
84
|
+
* GitHub Actions checks have logs on GitHub — external CI apps (e.g. Cloud
|
|
85
|
+
* Build) keep theirs on their own service, so a 404 here is translated
|
|
86
|
+
* into guidance instead of a dead end.
|
|
87
|
+
*/
|
|
88
|
+
getJobLog(conversationId: string, jobId: number): Promise<string>;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=github-ops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-ops.d.ts","sourceRoot":"","sources":["../../../src/adapters/github/github-ops.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,YAAY,EAA0C,MAAM,aAAa,CAAC;AAUnG,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAWpB;iEACiE;AACjE,wBAAsB,SAAS,CAC7B,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,qBAAqB,GACzB,OAAO,CAAC,OAAO,CAAC,CAOlB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,qBAAqB,GACzB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAS7B;AAED;;;;;;GAMG;AACH,qBAAa,SAAU,YAAW,iBAAiB;IAK/C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IALzB,uEAAuE;IACvE,OAAO,CAAC,QAAQ,CAA0C;IAE1D,YACmB,MAAM,EAAE,YAAY,EACpB,MAAM,EA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
3
|
+
import { GithubApiError, GITHUB_MAX_COMMENT_LENGTH, githubRetry } from "./client.js";
|
|
4
|
+
import { CLOUD_BUILD_APP_SLUG, CloudBuildLogUnavailableError, fetchCloudBuildLog, isCloudBuildId, projectFromDetailsUrl, } from "./cloudbuild.js";
|
|
5
|
+
import { parseGithubConversationId } from "./ids.js";
|
|
6
|
+
import { conversationRepoDir, GITHUB_PUSH_BRANCH_PATTERN, pushBranch, syncRepo } from "./repo.js";
|
|
7
|
+
/** Both CI log modes tail-truncate to this many characters. */
|
|
8
|
+
const MAX_LOG_CHARS = 20000;
|
|
9
|
+
function truncateLogTail(logText) {
|
|
10
|
+
return logText.length > MAX_LOG_CHARS
|
|
11
|
+
? `…(truncated to the last ${MAX_LOG_CHARS} chars)\n${logText.slice(-MAX_LOG_CHARS)}`
|
|
12
|
+
: logText;
|
|
13
|
+
}
|
|
14
|
+
/** Whether the conversation's issue is a PR, for callers where the triggering
|
|
15
|
+
* item didn't carry that knowledge. Errs toward plain issue. */
|
|
16
|
+
export async function fetchIsPr(client, ref) {
|
|
17
|
+
try {
|
|
18
|
+
const issue = await githubRetry(() => client.getIssue(ref.owner, ref.repo, ref.number));
|
|
19
|
+
return Boolean(issue.pull_request);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The PR's head branch name when it lives in this repo — that is the name
|
|
27
|
+
* the local checkout should carry, so committing on it and calling
|
|
28
|
+
* github_pr pushes back to the PR itself instead of opening a new one.
|
|
29
|
+
* Fork heads (unpushable with the repo-scoped token) and failed lookups
|
|
30
|
+
* return undefined; callers then fall back to the synthetic pr-<n>.
|
|
31
|
+
*/
|
|
32
|
+
export async function fetchPrHeadBranch(client, ref) {
|
|
33
|
+
try {
|
|
34
|
+
const pr = await githubRetry(() => client.getPullRequest(ref.owner, ref.repo, ref.number));
|
|
35
|
+
const sameRepo = pr.head?.repo?.full_name?.toLowerCase() === `${ref.owner}/${ref.repo}`.toLowerCase();
|
|
36
|
+
return sameRepo ? pr.head?.ref : undefined;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Host-side backend of the github_* tool pack (`PlatformGithubOps`),
|
|
44
|
+
* standalone from the messaging bot: it needs the API client, the
|
|
45
|
+
* conversation working dir, and optional Cloud Build access — not the poll
|
|
46
|
+
* loop, queues, or trigger gate. Tokens are minted per call, scoped to the
|
|
47
|
+
* conversation's repo, and never enter the sandbox.
|
|
48
|
+
*/
|
|
49
|
+
export class GithubOps {
|
|
50
|
+
constructor(client, config) {
|
|
51
|
+
this.client = client;
|
|
52
|
+
this.config = config;
|
|
53
|
+
/** Cloud Build ids seen in getChecks summaries → their GCP project. */
|
|
54
|
+
this.buildRef = new Map();
|
|
55
|
+
}
|
|
56
|
+
repoDir(conversationId) {
|
|
57
|
+
return conversationRepoDir(this.config.workingDir, conversationId);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Backs the `github_pr` tool: push a `pi/*` branch the agent prepared in
|
|
61
|
+
* the conversation's clone, then open a pull request as the App. The write
|
|
62
|
+
* token is minted per call, scoped to this one repo, and never enters the
|
|
63
|
+
* sandbox.
|
|
64
|
+
*/
|
|
65
|
+
async pushAndCreatePr(conversationId, request) {
|
|
66
|
+
const ref = parseGithubConversationId(conversationId);
|
|
67
|
+
const dir = this.repoDir(conversationId);
|
|
68
|
+
if (!existsSync(dir)) {
|
|
69
|
+
throw new Error("This conversation has no ./repo clone to push from.");
|
|
70
|
+
}
|
|
71
|
+
if (!GITHUB_PUSH_BRANCH_PATTERN.test(request.branch)) {
|
|
72
|
+
throw new Error(`Branch '${request.branch}' is not pushable: name it pi/<something> (e.g. pi/fix-${ref.number}).`);
|
|
73
|
+
}
|
|
74
|
+
const repository = await githubRetry(() => this.client.getRepository(ref.owner, ref.repo));
|
|
75
|
+
const base = request.base ?? repository.default_branch;
|
|
76
|
+
const token = await this.client.createScopedInstallationToken(ref.repo, {
|
|
77
|
+
contents: "write",
|
|
78
|
+
pull_requests: "write",
|
|
79
|
+
});
|
|
80
|
+
await pushBranch({ dir, branch: request.branch, token });
|
|
81
|
+
try {
|
|
82
|
+
const pr = await githubRetry(() => this.client.createPullRequest(ref.owner, ref.repo, {
|
|
83
|
+
title: request.title,
|
|
84
|
+
head: request.branch,
|
|
85
|
+
base,
|
|
86
|
+
body: request.body,
|
|
87
|
+
draft: request.draft,
|
|
88
|
+
}));
|
|
89
|
+
log.logInfo(`[${conversationId}] Opened PR #${pr.number}: ${pr.html_url}`);
|
|
90
|
+
return { number: pr.number, url: pr.html_url };
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
// Idempotency: pushing more commits to a branch that already has an
|
|
94
|
+
// open PR updates that PR; the create call then 422s. Surface the
|
|
95
|
+
// existing PR instead of failing the fix-CI-push-again loop.
|
|
96
|
+
if (err instanceof GithubApiError &&
|
|
97
|
+
err.status === 422 &&
|
|
98
|
+
/already exists/i.test(err.message)) {
|
|
99
|
+
const existing = await this.client.findOpenPullRequestByBranch(ref.owner, ref.repo, request.branch);
|
|
100
|
+
if (existing) {
|
|
101
|
+
log.logInfo(`[${conversationId}] Pushed to existing PR #${existing.number}: ${existing.html_url}`);
|
|
102
|
+
return { number: existing.number, url: existing.html_url, updatedExisting: true };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
throw err;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Backs the `github_checks` tool: CI check runs for a branch the agent
|
|
110
|
+
* pushed, or for the conversation's PR head when no branch is given.
|
|
111
|
+
*/
|
|
112
|
+
async getChecks(conversationId, branch) {
|
|
113
|
+
const ref = parseGithubConversationId(conversationId);
|
|
114
|
+
let target = branch;
|
|
115
|
+
if (!target) {
|
|
116
|
+
let pr;
|
|
117
|
+
try {
|
|
118
|
+
pr = await githubRetry(() => this.client.getPullRequest(ref.owner, ref.repo, ref.number));
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
pr = null;
|
|
122
|
+
}
|
|
123
|
+
if (!pr?.head) {
|
|
124
|
+
throw new Error("This conversation is not a pull request — pass the branch whose checks you want.");
|
|
125
|
+
}
|
|
126
|
+
target = pr.head.sha;
|
|
127
|
+
}
|
|
128
|
+
const runs = await githubRetry(() => this.client.listCheckRuns(ref.owner, ref.repo, target));
|
|
129
|
+
return runs.map((run) => {
|
|
130
|
+
const externalId = run.external_id?.trim() || null;
|
|
131
|
+
let buildLogAvailable = false;
|
|
132
|
+
// Cloud Build runs carry their build UUID in external_id and the GCP
|
|
133
|
+
// project in details_url. Remember project-by-build so getBuildLog only
|
|
134
|
+
// serves builds the agent actually saw on this repo's checks.
|
|
135
|
+
if (this.config.cloudBuild &&
|
|
136
|
+
run.app?.slug === CLOUD_BUILD_APP_SLUG &&
|
|
137
|
+
externalId &&
|
|
138
|
+
isCloudBuildId(externalId)) {
|
|
139
|
+
const project = projectFromDetailsUrl(run.details_url) ?? this.config.cloudBuild.projectFallback;
|
|
140
|
+
if (project) {
|
|
141
|
+
this.rememberBuild(externalId, project);
|
|
142
|
+
buildLogAvailable = true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
id: run.id,
|
|
147
|
+
name: run.name,
|
|
148
|
+
status: run.status,
|
|
149
|
+
conclusion: run.conclusion,
|
|
150
|
+
url: run.html_url,
|
|
151
|
+
appSlug: run.app?.slug ?? null,
|
|
152
|
+
outputSummary: run.output?.summary?.trim() ? run.output.summary.slice(0, 500) : null,
|
|
153
|
+
externalId,
|
|
154
|
+
buildLogAvailable,
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
rememberBuild(buildId, project) {
|
|
159
|
+
// Insertion-ordered Map as a small LRU: re-insert on touch, prune oldest.
|
|
160
|
+
this.buildRef.delete(buildId);
|
|
161
|
+
this.buildRef.set(buildId, { project });
|
|
162
|
+
if (this.buildRef.size > 200) {
|
|
163
|
+
const oldest = this.buildRef.keys().next().value;
|
|
164
|
+
if (oldest !== undefined)
|
|
165
|
+
this.buildRef.delete(oldest);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Backs the Cloud Build log mode of `github_checks`. GCP credentials stay
|
|
170
|
+
* host-side (ADC via GOOGLE_APPLICATION_CREDENTIALS — e.g. a Workload
|
|
171
|
+
* Identity Federation external_account file); the build must have appeared
|
|
172
|
+
* in a github_checks summary first, which is also where its project is
|
|
173
|
+
* learned. Unreadable logs degrade to the console url, never a dead end.
|
|
174
|
+
*/
|
|
175
|
+
async getBuildLog(conversationId, buildId) {
|
|
176
|
+
if (!this.config.cloudBuild) {
|
|
177
|
+
throw new Error("Cloud Build log access is not configured on this host (no GCP credentials).");
|
|
178
|
+
}
|
|
179
|
+
const known = this.buildRef.get(buildId);
|
|
180
|
+
if (!known) {
|
|
181
|
+
throw new Error(`Unknown build id ${buildId}: run github_checks first and take a [build …] id from ` +
|
|
182
|
+
`the summary.`);
|
|
183
|
+
}
|
|
184
|
+
let logText;
|
|
185
|
+
try {
|
|
186
|
+
logText = await fetchCloudBuildLog({
|
|
187
|
+
tokenProvider: this.config.cloudBuild.tokenProvider,
|
|
188
|
+
project: known.project,
|
|
189
|
+
buildId,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
catch (err) {
|
|
193
|
+
if (err instanceof CloudBuildLogUnavailableError) {
|
|
194
|
+
throw new Error(`${err.message}${err.consoleUrl ? ` Console: ${err.consoleUrl}` : ""} Use the check's ` +
|
|
195
|
+
`summary/url from github_checks, or reproduce the failure locally in ./repo.`, { cause: err });
|
|
196
|
+
}
|
|
197
|
+
throw err;
|
|
198
|
+
}
|
|
199
|
+
return truncateLogTail(logText);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Backs the `github_sync` tool: refresh the conversation's ./repo clone
|
|
203
|
+
* from origin with an ephemeral read token. Fetch-only when moving the
|
|
204
|
+
* checkout could lose agent work; the formatted report tells the agent
|
|
205
|
+
* what happened and what to do next.
|
|
206
|
+
*/
|
|
207
|
+
async syncRepo(conversationId, branch) {
|
|
208
|
+
const ref = parseGithubConversationId(conversationId);
|
|
209
|
+
const dir = this.repoDir(conversationId);
|
|
210
|
+
if (!existsSync(dir)) {
|
|
211
|
+
throw new Error("This conversation has no ./repo clone to sync.");
|
|
212
|
+
}
|
|
213
|
+
const token = await this.client.createScopedInstallationToken(ref.repo, {
|
|
214
|
+
contents: "read",
|
|
215
|
+
});
|
|
216
|
+
let prNumber;
|
|
217
|
+
let prHeadBranch;
|
|
218
|
+
let defaultBranch;
|
|
219
|
+
if (!branch) {
|
|
220
|
+
if (await fetchIsPr(this.client, ref)) {
|
|
221
|
+
prNumber = ref.number;
|
|
222
|
+
prHeadBranch = await fetchPrHeadBranch(this.client, ref);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
const repository = await githubRetry(() => this.client.getRepository(ref.owner, ref.repo));
|
|
226
|
+
defaultBranch = repository.default_branch;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const result = await syncRepo({ dir, token, branch, prNumber, prHeadBranch, defaultBranch });
|
|
230
|
+
if (result.updatedCheckout) {
|
|
231
|
+
return `Updated ./repo: branch ${result.target} is now at ${result.fetchedSha.slice(0, 12)}.`;
|
|
232
|
+
}
|
|
233
|
+
const reasons = [];
|
|
234
|
+
if (result.currentBranch !== result.target) {
|
|
235
|
+
reasons.push(`the checkout is on '${result.currentBranch}', not '${result.target}'`);
|
|
236
|
+
}
|
|
237
|
+
if (result.dirty) {
|
|
238
|
+
reasons.push("the working tree has uncommitted changes");
|
|
239
|
+
}
|
|
240
|
+
if (result.localCommits > 0) {
|
|
241
|
+
reasons.push(`'${result.target}' has ${result.localCommits} local commit(s) not on origin`);
|
|
242
|
+
}
|
|
243
|
+
return (`Fetched ${result.target} to FETCH_HEAD (${result.fetchedSha.slice(0, 12)}) but left the ` +
|
|
244
|
+
`checkout alone: ${reasons.join("; ")}. Merge or rebase FETCH_HEAD yourself ` +
|
|
245
|
+
`(e.g. git merge FETCH_HEAD), or commit your work to a pi/* branch first.`);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Backs the `github_read` tool: PR/issue metadata the ./repo clone cannot
|
|
249
|
+
* provide (diff stats, review state, other issues in the repo). Owner/repo
|
|
250
|
+
* always come from the conversation id, so reads never leave this repo.
|
|
251
|
+
*/
|
|
252
|
+
async readGithub(conversationId, request) {
|
|
253
|
+
const ref = parseGithubConversationId(conversationId);
|
|
254
|
+
const number = request.number ?? ref.number;
|
|
255
|
+
switch (request.action) {
|
|
256
|
+
case "pr": {
|
|
257
|
+
const pr = await githubRetry(() => this.client.getPullRequest(ref.owner, ref.repo, number));
|
|
258
|
+
return { kind: "pr", pr };
|
|
259
|
+
}
|
|
260
|
+
case "pr_files": {
|
|
261
|
+
const files = await githubRetry(() => this.client.listPullRequestFiles(ref.owner, ref.repo, number));
|
|
262
|
+
return { kind: "pr_files", files };
|
|
263
|
+
}
|
|
264
|
+
case "pr_reviews": {
|
|
265
|
+
const [reviews, threads] = await Promise.all([
|
|
266
|
+
githubRetry(() => this.client.listPullRequestReviews(ref.owner, ref.repo, number)),
|
|
267
|
+
githubRetry(() => this.client.listPullReviewComments(ref.owner, ref.repo, number)),
|
|
268
|
+
]);
|
|
269
|
+
return { kind: "pr_reviews", reviews, threads };
|
|
270
|
+
}
|
|
271
|
+
case "issue": {
|
|
272
|
+
const issue = await githubRetry(() => this.client.getIssue(ref.owner, ref.repo, number));
|
|
273
|
+
return { kind: "issue", issue };
|
|
274
|
+
}
|
|
275
|
+
case "comments": {
|
|
276
|
+
const comments = await githubRetry(() => this.client.listIssueComments(ref.owner, ref.repo, number));
|
|
277
|
+
return { kind: "comments", comments };
|
|
278
|
+
}
|
|
279
|
+
case "list": {
|
|
280
|
+
const issues = await githubRetry(() => this.client.listIssues(ref.owner, ref.repo, {
|
|
281
|
+
state: request.state,
|
|
282
|
+
labels: request.labels,
|
|
283
|
+
creator: request.creator,
|
|
284
|
+
}));
|
|
285
|
+
return { kind: "list", issues };
|
|
286
|
+
}
|
|
287
|
+
default:
|
|
288
|
+
throw new Error(`Unknown github_read action: ${String(request.action)}`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Backs the `github_issue` tool: labels, assignees, and open/closed state
|
|
293
|
+
* on any issue of this conversation's repo (triage). Same-repo by
|
|
294
|
+
* construction — owner/repo come from the conversation id; the action enum
|
|
295
|
+
* is closed, so lock/delete/transfer cannot be expressed at all.
|
|
296
|
+
*/
|
|
297
|
+
async manageIssue(conversationId, request) {
|
|
298
|
+
const ref = parseGithubConversationId(conversationId);
|
|
299
|
+
const number = request.number ?? ref.number;
|
|
300
|
+
try {
|
|
301
|
+
switch (request.action) {
|
|
302
|
+
case "add_labels": {
|
|
303
|
+
if (!request.labels?.length) {
|
|
304
|
+
throw new Error("add_labels requires a non-empty labels array.");
|
|
305
|
+
}
|
|
306
|
+
await githubRetry(() => this.client.addIssueLabels(ref.owner, ref.repo, number, request.labels));
|
|
307
|
+
return `Added label(s) ${request.labels.join(", ")} to #${number}.`;
|
|
308
|
+
}
|
|
309
|
+
case "remove_label": {
|
|
310
|
+
if (!request.label) {
|
|
311
|
+
throw new Error("remove_label requires a label name.");
|
|
312
|
+
}
|
|
313
|
+
await githubRetry(() => this.client.removeIssueLabel(ref.owner, ref.repo, number, request.label));
|
|
314
|
+
return `Removed label ${request.label} from #${number}.`;
|
|
315
|
+
}
|
|
316
|
+
case "add_assignees": {
|
|
317
|
+
if (!request.assignees?.length) {
|
|
318
|
+
throw new Error("add_assignees requires a non-empty assignees array.");
|
|
319
|
+
}
|
|
320
|
+
await githubRetry(() => this.client.addIssueAssignees(ref.owner, ref.repo, number, request.assignees));
|
|
321
|
+
return `Assigned ${request.assignees.map((login) => `@${login}`).join(", ")} to #${number}.`;
|
|
322
|
+
}
|
|
323
|
+
case "remove_assignees": {
|
|
324
|
+
if (!request.assignees?.length) {
|
|
325
|
+
throw new Error("remove_assignees requires a non-empty assignees array.");
|
|
326
|
+
}
|
|
327
|
+
await githubRetry(() => this.client.removeIssueAssignees(ref.owner, ref.repo, number, request.assignees));
|
|
328
|
+
return `Unassigned ${request.assignees.map((login) => `@${login}`).join(", ")} from #${number}.`;
|
|
329
|
+
}
|
|
330
|
+
case "close": {
|
|
331
|
+
await githubRetry(() => this.client.updateIssueState(ref.owner, ref.repo, number, "closed", request.state_reason));
|
|
332
|
+
return `Closed #${number}${request.state_reason ? ` as ${request.state_reason}` : ""}.`;
|
|
333
|
+
}
|
|
334
|
+
case "reopen": {
|
|
335
|
+
await githubRetry(() => this.client.updateIssueState(ref.owner, ref.repo, number, "open"));
|
|
336
|
+
return `Reopened #${number}.`;
|
|
337
|
+
}
|
|
338
|
+
default:
|
|
339
|
+
throw new Error(`Unknown github_issue action: ${String(request.action)}`);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
catch (err) {
|
|
343
|
+
if (err instanceof GithubApiError && err.status === 404) {
|
|
344
|
+
throw new Error(`Issue #${number} not found in ${ref.owner}/${ref.repo}.`, { cause: err });
|
|
345
|
+
}
|
|
346
|
+
throw err;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Backs the `github_review_reply` tool: answer inside one inline review
|
|
351
|
+
* thread of this conversation's PR. The comment id comes from an
|
|
352
|
+
* `[PR review comment rc-<id> …]` message; GitHub validates it belongs to
|
|
353
|
+
* this PR (404 otherwise, translated into agent-actionable guidance).
|
|
354
|
+
*/
|
|
355
|
+
async replyToReviewThread(conversationId, commentId, body) {
|
|
356
|
+
if (!Number.isInteger(commentId) || commentId <= 0) {
|
|
357
|
+
throw new Error("comment_id must be the numeric id from an [PR review comment rc-<id> …] message.");
|
|
358
|
+
}
|
|
359
|
+
const ref = parseGithubConversationId(conversationId);
|
|
360
|
+
const text = body.length > GITHUB_MAX_COMMENT_LENGTH
|
|
361
|
+
? `${body.slice(0, GITHUB_MAX_COMMENT_LENGTH)}\n…(truncated)`
|
|
362
|
+
: body;
|
|
363
|
+
try {
|
|
364
|
+
const reply = await githubRetry(() => this.client.replyToReviewComment(ref.owner, ref.repo, ref.number, commentId, text));
|
|
365
|
+
return {
|
|
366
|
+
url: `https://github.com/${ref.owner}/${ref.repo}/pull/${ref.number}#discussion_r${reply.id}`,
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
catch (err) {
|
|
370
|
+
if (err instanceof GithubApiError && err.status === 404) {
|
|
371
|
+
throw new Error(`Comment ${commentId} is not a review comment on this PR. Take the id from an ` +
|
|
372
|
+
`[PR review comment rc-<id> …] message in this conversation; do not guess ids.`, { cause: err });
|
|
373
|
+
}
|
|
374
|
+
throw err;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Backs the log mode of `github_checks`: the tail of one CI job's log so
|
|
379
|
+
* the agent can diagnose a failing check without sandbox credentials. Only
|
|
380
|
+
* GitHub Actions checks have logs on GitHub — external CI apps (e.g. Cloud
|
|
381
|
+
* Build) keep theirs on their own service, so a 404 here is translated
|
|
382
|
+
* into guidance instead of a dead end.
|
|
383
|
+
*/
|
|
384
|
+
async getJobLog(conversationId, jobId) {
|
|
385
|
+
if (!Number.isInteger(jobId) || jobId <= 0) {
|
|
386
|
+
throw new Error("job_id must be a positive Actions job id taken from a [job …] entry in the github_checks summary.");
|
|
387
|
+
}
|
|
388
|
+
const ref = parseGithubConversationId(conversationId);
|
|
389
|
+
let logText;
|
|
390
|
+
try {
|
|
391
|
+
logText = await githubRetry(() => this.client.getJobLog(ref.owner, ref.repo, jobId));
|
|
392
|
+
}
|
|
393
|
+
catch (err) {
|
|
394
|
+
if (err instanceof GithubApiError && err.status === 404) {
|
|
395
|
+
throw new Error(`No GitHub Actions log for job ${jobId}. Logs are only available for checks reported ` +
|
|
396
|
+
`by github-actions; external CI (e.g. Cloud Build) keeps logs on its own service — ` +
|
|
397
|
+
`use that check's summary/url from github_checks, or reproduce the failure locally ` +
|
|
398
|
+
`in ./repo instead. Do not retry with other ids.`, { cause: err });
|
|
399
|
+
}
|
|
400
|
+
throw err;
|
|
401
|
+
}
|
|
402
|
+
return truncateLogTail(logText);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
//# sourceMappingURL=github-ops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-ops.js","sourceRoot":"","sources":["../../../src/adapters/github/github-ops.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,cAAc,EAAgB,yBAAyB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EACL,oBAAoB,EACpB,6BAA6B,EAC7B,kBAAkB,EAClB,cAAc,EACd,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAalG,+DAA+D;AAC/D,MAAM,aAAa,GAAG,KAAK,CAAC;AAE5B,SAAS,eAAe,CAAC,OAAe;IACtC,OAAO,OAAO,CAAC,MAAM,GAAG,aAAa;QACnC,CAAC,CAAC,2BAA2B,aAAa,YAAY,OAAO,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,EAAE;QACrF,CAAC,CAAC,OAAO,CAAC;AACd,CAAC;AAED;iEACiE;AACjE,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAoB,EACpB,GAA0B;IAE1B,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,QA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AAE,CAAC;YACb,IAAI,GAAG,YAAY,cAAc,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACxD,MAAM,IAAI,KAAK,CACb,iCAAiC,KAAK,gDAAgD;oBACpF,oFAAoF;oBACpF,oFAAoF;oBACpF,iDAAiD,EACnD,EAAE,KAAK,EAAE,GAAG,EAAE,CACf,CAAC;YACJ,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;QACD,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;CACF","sourcesContent":["import { existsSync } from \"fs\";\nimport * as log from \"../../log.js\";\nimport { GithubApiError, GithubClient, GITHUB_MAX_COMMENT_LENGTH, githubRetry } from \"./client.js\";\nimport {\n CLOUD_BUILD_APP_SLUG,\n CloudBuildLogUnavailableError,\n fetchCloudBuildLog,\n isCloudBuildId,\n projectFromDetailsUrl,\n} from \"./cloudbuild.js\";\nimport { parseGithubConversationId } from \"./ids.js\";\nimport { conversationRepoDir, GITHUB_PUSH_BRANCH_PATTERN, pushBranch, syncRepo } from \"./repo.js\";\nimport type {\n GithubBotConfig,\n GithubCheckSummary,\n GithubConversationRef,\n GithubIssueRequest,\n GithubPrRequest,\n GithubPrResult,\n GithubReadRequest,\n GithubReadResult,\n PlatformGithubOps,\n} from \"./types.js\";\n\n/** Both CI log modes tail-truncate to this many characters. */\nconst MAX_LOG_CHARS = 20000;\n\nfunction truncateLogTail(logText: string): string {\n return logText.length > MAX_LOG_CHARS\n ? `…(truncated to the last ${MAX_LOG_CHARS} chars)\\n${logText.slice(-MAX_LOG_CHARS)}`\n : logText;\n}\n\n/** Whether the conversation's issue is a PR, for callers where the triggering\n * item didn't carry that knowledge. Errs toward plain issue. */\nexport async function fetchIsPr(\n client: GithubClient,\n ref: GithubConversationRef,\n): Promise<boolean> {\n try {\n const issue = await githubRetry(() => client.getIssue(ref.owner, ref.repo, ref.number));\n return Boolean(issue.pull_request);\n } catch {\n return false;\n }\n}\n\n/**\n * The PR's head branch name when it lives in this repo — that is the name\n * the local checkout should carry, so committing on it and calling\n * github_pr pushes back to the PR itself instead of opening a new one.\n * Fork heads (unpushable with the repo-scoped token) and failed lookups\n * return undefined; callers then fall back to the synthetic pr-<n>.\n */\nexport async function fetchPrHeadBranch(\n client: GithubClient,\n ref: GithubConversationRef,\n): Promise<string | undefined> {\n try {\n const pr = await githubRetry(() => client.getPullRequest(ref.owner, ref.repo, ref.number));\n const sameRepo =\n pr.head?.repo?.full_name?.toLowerCase() === `${ref.owner}/${ref.repo}`.toLowerCase();\n return sameRepo ? pr.head?.ref : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Host-side backend of the github_* tool pack (`PlatformGithubOps`),\n * standalone from the messaging bot: it needs the API client, the\n * conversation working dir, and optional Cloud Build access — not the poll\n * loop, queues, or trigger gate. Tokens are minted per call, scoped to the\n * conversation's repo, and never enter the sandbox.\n */\nexport class GithubOps implements PlatformGithubOps {\n /** Cloud Build ids seen in getChecks summaries → their GCP project. */\n private buildRef = new Map<string, { project: string }>();\n\n constructor(\n private readonly client: GithubClient,\n private readonly config: {\n workingDir: string;\n cloudBuild?: GithubBotConfig[\"cloudBuild\"];\n },\n ) {}\n\n private repoDir(conversationId: string): string {\n return conversationRepoDir(this.config.workingDir, conversationId);\n }\n\n /**\n * Backs the `github_pr` tool: push a `pi/*` branch the agent prepared in\n * the conversation's clone, then open a pull request as the App. The write\n * token is minted per call, scoped to this one repo, and never enters the\n * sandbox.\n */\n async pushAndCreatePr(conversationId: string, request: GithubPrRequest): Promise<GithubPrResult> {\n const ref = parseGithubConversationId(conversationId);\n const dir = this.repoDir(conversationId);\n if (!existsSync(dir)) {\n throw new Error(\"This conversation has no ./repo clone to push from.\");\n }\n if (!GITHUB_PUSH_BRANCH_PATTERN.test(request.branch)) {\n throw new Error(\n `Branch '${request.branch}' is not pushable: name it pi/<something> (e.g. pi/fix-${ref.number}).`,\n );\n }\n const repository = await githubRetry(() => this.client.getRepository(ref.owner, ref.repo));\n const base = request.base ?? repository.default_branch;\n const token = await this.client.createScopedInstallationToken(ref.repo, {\n contents: \"write\",\n pull_requests: \"write\",\n });\n await pushBranch({ dir, branch: request.branch, token });\n try {\n const pr = await githubRetry(() =>\n this.client.createPullRequest(ref.owner, ref.repo, {\n title: request.title,\n head: request.branch,\n base,\n body: request.body,\n draft: request.draft,\n }),\n );\n log.logInfo(`[${conversationId}] Opened PR #${pr.number}: ${pr.html_url}`);\n return { number: pr.number, url: pr.html_url };\n } catch (err) {\n // Idempotency: pushing more commits to a branch that already has an\n // open PR updates that PR; the create call then 422s. Surface the\n // existing PR instead of failing the fix-CI-push-again loop.\n if (\n err instanceof GithubApiError &&\n err.status === 422 &&\n /already exists/i.test(err.message)\n ) {\n const existing = await this.client.findOpenPullRequestByBranch(\n ref.owner,\n ref.repo,\n request.branch,\n );\n if (existing) {\n log.logInfo(\n `[${conversationId}] Pushed to existing PR #${existing.number}: ${existing.html_url}`,\n );\n return { number: existing.number, url: existing.html_url, updatedExisting: true };\n }\n }\n throw err;\n }\n }\n\n /**\n * Backs the `github_checks` tool: CI check runs for a branch the agent\n * pushed, or for the conversation's PR head when no branch is given.\n */\n async getChecks(conversationId: string, branch?: string): Promise<GithubCheckSummary[]> {\n const ref = parseGithubConversationId(conversationId);\n let target = branch;\n if (!target) {\n let pr;\n try {\n pr = await githubRetry(() => this.client.getPullRequest(ref.owner, ref.repo, ref.number));\n } catch {\n pr = null;\n }\n if (!pr?.head) {\n throw new Error(\n \"This conversation is not a pull request — pass the branch whose checks you want.\",\n );\n }\n target = pr.head.sha;\n }\n const runs = await githubRetry(() => this.client.listCheckRuns(ref.owner, ref.repo, target));\n return runs.map((run) => {\n const externalId = run.external_id?.trim() || null;\n let buildLogAvailable = false;\n // Cloud Build runs carry their build UUID in external_id and the GCP\n // project in details_url. Remember project-by-build so getBuildLog only\n // serves builds the agent actually saw on this repo's checks.\n if (\n this.config.cloudBuild &&\n run.app?.slug === CLOUD_BUILD_APP_SLUG &&\n externalId &&\n isCloudBuildId(externalId)\n ) {\n const project =\n projectFromDetailsUrl(run.details_url) ?? this.config.cloudBuild.projectFallback;\n if (project) {\n this.rememberBuild(externalId, project);\n buildLogAvailable = true;\n }\n }\n return {\n id: run.id,\n name: run.name,\n status: run.status,\n conclusion: run.conclusion,\n url: run.html_url,\n appSlug: run.app?.slug ?? null,\n outputSummary: run.output?.summary?.trim() ? run.output.summary.slice(0, 500) : null,\n externalId,\n buildLogAvailable,\n };\n });\n }\n\n private rememberBuild(buildId: string, project: string): void {\n // Insertion-ordered Map as a small LRU: re-insert on touch, prune oldest.\n this.buildRef.delete(buildId);\n this.buildRef.set(buildId, { project });\n if (this.buildRef.size > 200) {\n const oldest = this.buildRef.keys().next().value;\n if (oldest !== undefined) this.buildRef.delete(oldest);\n }\n }\n\n /**\n * Backs the Cloud Build log mode of `github_checks`. GCP credentials stay\n * host-side (ADC via GOOGLE_APPLICATION_CREDENTIALS — e.g. a Workload\n * Identity Federation external_account file); the build must have appeared\n * in a github_checks summary first, which is also where its project is\n * learned. Unreadable logs degrade to the console url, never a dead end.\n */\n async getBuildLog(conversationId: string, buildId: string): Promise<string> {\n if (!this.config.cloudBuild) {\n throw new Error(\n \"Cloud Build log access is not configured on this host (no GCP credentials).\",\n );\n }\n const known = this.buildRef.get(buildId);\n if (!known) {\n throw new Error(\n `Unknown build id ${buildId}: run github_checks first and take a [build …] id from ` +\n `the summary.`,\n );\n }\n let logText: string;\n try {\n logText = await fetchCloudBuildLog({\n tokenProvider: this.config.cloudBuild.tokenProvider,\n project: known.project,\n buildId,\n });\n } catch (err) {\n if (err instanceof CloudBuildLogUnavailableError) {\n throw new Error(\n `${err.message}${err.consoleUrl ? ` Console: ${err.consoleUrl}` : \"\"} Use the check's ` +\n `summary/url from github_checks, or reproduce the failure locally in ./repo.`,\n { cause: err },\n );\n }\n throw err;\n }\n return truncateLogTail(logText);\n }\n\n /**\n * Backs the `github_sync` tool: refresh the conversation's ./repo clone\n * from origin with an ephemeral read token. Fetch-only when moving the\n * checkout could lose agent work; the formatted report tells the agent\n * what happened and what to do next.\n */\n async syncRepo(conversationId: string, branch?: string): Promise<string> {\n const ref = parseGithubConversationId(conversationId);\n const dir = this.repoDir(conversationId);\n if (!existsSync(dir)) {\n throw new Error(\"This conversation has no ./repo clone to sync.\");\n }\n const token = await this.client.createScopedInstallationToken(ref.repo, {\n contents: \"read\",\n });\n let prNumber: number | undefined;\n let prHeadBranch: string | undefined;\n let defaultBranch: string | undefined;\n if (!branch) {\n if (await fetchIsPr(this.client, ref)) {\n prNumber = ref.number;\n prHeadBranch = await fetchPrHeadBranch(this.client, ref);\n } else {\n const repository = await githubRetry(() => this.client.getRepository(ref.owner, ref.repo));\n defaultBranch = repository.default_branch;\n }\n }\n const result = await syncRepo({ dir, token, branch, prNumber, prHeadBranch, defaultBranch });\n\n if (result.updatedCheckout) {\n return `Updated ./repo: branch ${result.target} is now at ${result.fetchedSha.slice(0, 12)}.`;\n }\n const reasons: string[] = [];\n if (result.currentBranch !== result.target) {\n reasons.push(`the checkout is on '${result.currentBranch}', not '${result.target}'`);\n }\n if (result.dirty) {\n reasons.push(\"the working tree has uncommitted changes\");\n }\n if (result.localCommits > 0) {\n reasons.push(`'${result.target}' has ${result.localCommits} local commit(s) not on origin`);\n }\n return (\n `Fetched ${result.target} to FETCH_HEAD (${result.fetchedSha.slice(0, 12)}) but left the ` +\n `checkout alone: ${reasons.join(\"; \")}. Merge or rebase FETCH_HEAD yourself ` +\n `(e.g. git merge FETCH_HEAD), or commit your work to a pi/* branch first.`\n );\n }\n\n /**\n * Backs the `github_read` tool: PR/issue metadata the ./repo clone cannot\n * provide (diff stats, review state, other issues in the repo). Owner/repo\n * always come from the conversation id, so reads never leave this repo.\n */\n async readGithub(conversationId: string, request: GithubReadRequest): Promise<GithubReadResult> {\n const ref = parseGithubConversationId(conversationId);\n const number = request.number ?? ref.number;\n switch (request.action) {\n case \"pr\": {\n const pr = await githubRetry(() => this.client.getPullRequest(ref.owner, ref.repo, number));\n return { kind: \"pr\", pr };\n }\n case \"pr_files\": {\n const files = await githubRetry(() =>\n this.client.listPullRequestFiles(ref.owner, ref.repo, number),\n );\n return { kind: \"pr_files\", files };\n }\n case \"pr_reviews\": {\n const [reviews, threads] = await Promise.all([\n githubRetry(() => this.client.listPullRequestReviews(ref.owner, ref.repo, number)),\n githubRetry(() => this.client.listPullReviewComments(ref.owner, ref.repo, number)),\n ]);\n return { kind: \"pr_reviews\", reviews, threads };\n }\n case \"issue\": {\n const issue = await githubRetry(() => this.client.getIssue(ref.owner, ref.repo, number));\n return { kind: \"issue\", issue };\n }\n case \"comments\": {\n const comments = await githubRetry(() =>\n this.client.listIssueComments(ref.owner, ref.repo, number),\n );\n return { kind: \"comments\", comments };\n }\n case \"list\": {\n const issues = await githubRetry(() =>\n this.client.listIssues(ref.owner, ref.repo, {\n state: request.state,\n labels: request.labels,\n creator: request.creator,\n }),\n );\n return { kind: \"list\", issues };\n }\n default:\n throw new Error(`Unknown github_read action: ${String(request.action)}`);\n }\n }\n\n /**\n * Backs the `github_issue` tool: labels, assignees, and open/closed state\n * on any issue of this conversation's repo (triage). Same-repo by\n * construction — owner/repo come from the conversation id; the action enum\n * is closed, so lock/delete/transfer cannot be expressed at all.\n */\n async manageIssue(conversationId: string, request: GithubIssueRequest): Promise<string> {\n const ref = parseGithubConversationId(conversationId);\n const number = request.number ?? ref.number;\n try {\n switch (request.action) {\n case \"add_labels\": {\n if (!request.labels?.length) {\n throw new Error(\"add_labels requires a non-empty labels array.\");\n }\n await githubRetry(() =>\n this.client.addIssueLabels(ref.owner, ref.repo, number, request.labels!),\n );\n return `Added label(s) ${request.labels.join(\", \")} to #${number}.`;\n }\n case \"remove_label\": {\n if (!request.label) {\n throw new Error(\"remove_label requires a label name.\");\n }\n await githubRetry(() =>\n this.client.removeIssueLabel(ref.owner, ref.repo, number, request.label!),\n );\n return `Removed label ${request.label} from #${number}.`;\n }\n case \"add_assignees\": {\n if (!request.assignees?.length) {\n throw new Error(\"add_assignees requires a non-empty assignees array.\");\n }\n await githubRetry(() =>\n this.client.addIssueAssignees(ref.owner, ref.repo, number, request.assignees!),\n );\n return `Assigned ${request.assignees.map((login) => `@${login}`).join(\", \")} to #${number}.`;\n }\n case \"remove_assignees\": {\n if (!request.assignees?.length) {\n throw new Error(\"remove_assignees requires a non-empty assignees array.\");\n }\n await githubRetry(() =>\n this.client.removeIssueAssignees(ref.owner, ref.repo, number, request.assignees!),\n );\n return `Unassigned ${request.assignees.map((login) => `@${login}`).join(\", \")} from #${number}.`;\n }\n case \"close\": {\n await githubRetry(() =>\n this.client.updateIssueState(\n ref.owner,\n ref.repo,\n number,\n \"closed\",\n request.state_reason,\n ),\n );\n return `Closed #${number}${request.state_reason ? ` as ${request.state_reason}` : \"\"}.`;\n }\n case \"reopen\": {\n await githubRetry(() =>\n this.client.updateIssueState(ref.owner, ref.repo, number, \"open\"),\n );\n return `Reopened #${number}.`;\n }\n default:\n throw new Error(`Unknown github_issue action: ${String(request.action)}`);\n }\n } catch (err) {\n if (err instanceof GithubApiError && err.status === 404) {\n throw new Error(`Issue #${number} not found in ${ref.owner}/${ref.repo}.`, { cause: err });\n }\n throw err;\n }\n }\n\n /**\n * Backs the `github_review_reply` tool: answer inside one inline review\n * thread of this conversation's PR. The comment id comes from an\n * `[PR review comment rc-<id> …]` message; GitHub validates it belongs to\n * this PR (404 otherwise, translated into agent-actionable guidance).\n */\n async replyToReviewThread(\n conversationId: string,\n commentId: number,\n body: string,\n ): Promise<{ url: string }> {\n if (!Number.isInteger(commentId) || commentId <= 0) {\n throw new Error(\n \"comment_id must be the numeric id from an [PR review comment rc-<id> …] message.\",\n );\n }\n const ref = parseGithubConversationId(conversationId);\n const text =\n body.length > GITHUB_MAX_COMMENT_LENGTH\n ? `${body.slice(0, GITHUB_MAX_COMMENT_LENGTH)}\\n…(truncated)`\n : body;\n try {\n const reply = await githubRetry(() =>\n this.client.replyToReviewComment(ref.owner, ref.repo, ref.number, commentId, text),\n );\n return {\n url: `https://github.com/${ref.owner}/${ref.repo}/pull/${ref.number}#discussion_r${reply.id}`,\n };\n } catch (err) {\n if (err instanceof GithubApiError && err.status === 404) {\n throw new Error(\n `Comment ${commentId} is not a review comment on this PR. Take the id from an ` +\n `[PR review comment rc-<id> …] message in this conversation; do not guess ids.`,\n { cause: err },\n );\n }\n throw err;\n }\n }\n\n /**\n * Backs the log mode of `github_checks`: the tail of one CI job's log so\n * the agent can diagnose a failing check without sandbox credentials. Only\n * GitHub Actions checks have logs on GitHub — external CI apps (e.g. Cloud\n * Build) keep theirs on their own service, so a 404 here is translated\n * into guidance instead of a dead end.\n */\n async getJobLog(conversationId: string, jobId: number): Promise<string> {\n if (!Number.isInteger(jobId) || jobId <= 0) {\n throw new Error(\n \"job_id must be a positive Actions job id taken from a [job …] entry in the github_checks summary.\",\n );\n }\n const ref = parseGithubConversationId(conversationId);\n let logText: string;\n try {\n logText = await githubRetry(() => this.client.getJobLog(ref.owner, ref.repo, jobId));\n } catch (err) {\n if (err instanceof GithubApiError && err.status === 404) {\n throw new Error(\n `No GitHub Actions log for job ${jobId}. Logs are only available for checks reported ` +\n `by github-actions; external CI (e.g. Cloud Build) keeps logs on its own service — ` +\n `use that check's summary/url from github_checks, or reproduce the failure locally ` +\n `in ./repo instead. Do not retry with other ids.`,\n { cause: err },\n );\n }\n throw err;\n }\n return truncateLogTail(logText);\n }\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { GithubConversationRef } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Conversation id for one issue/PR: `GH_<owner>_<repo>_<number>`.
|
|
4
|
+
*
|
|
5
|
+
* DESIGN.md originally proposed `gh:<owner>/<repo>#<number>`, but conversation
|
|
6
|
+
* ids are used verbatim as a single path segment (LAYOUT.md § Casing) and the
|
|
7
|
+
* conversation dir is bind-mounted with docker's `-v source:target` syntax in
|
|
8
|
+
* image mode — so the id can contain neither `/` nor `:`. `_` is the
|
|
9
|
+
* separator because it is the only inert character that also parses back
|
|
10
|
+
* unambiguously under GitHub's name grammar: owners allow `-` (so `-` would
|
|
11
|
+
* make the owner/repo boundary ambiguous) but never `_`, repos may contain
|
|
12
|
+
* `_` but the trailing number is pure digits — so the first `_` and the last
|
|
13
|
+
* `_` before the digits are always the real boundaries.
|
|
14
|
+
*
|
|
15
|
+
* Owner and repo are lowercased: GitHub names are case-insensitive (and this
|
|
16
|
+
* id has two spelling sources — the GITHUB_REPOS env var and API payloads),
|
|
17
|
+
* so per LAYOUT.md § Casing this is a mikan-derived slug, not a verbatim
|
|
18
|
+
* platform id, and derived slugs are lowercased to keep one issue from
|
|
19
|
+
* mapping to two conversation dirs on case-sensitive filesystems.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildGithubConversationId(ref: GithubConversationRef): string;
|
|
22
|
+
export declare function parseGithubConversationId(conversationId: string): GithubConversationRef;
|
|
23
|
+
/** Message ts used for the issue/PR body itself (comments use their comment id). */
|
|
24
|
+
export declare const GITHUB_ISSUE_BODY_TS = "issue";
|
|
25
|
+
/**
|
|
26
|
+
* Message ts for an inline PR review comment: `rc-<id>`. Review-comment ids
|
|
27
|
+
* live in a different id space than issue-comment ids, and several endpoints
|
|
28
|
+
* (reactions, edits) differ by family — the prefix makes routing a review id
|
|
29
|
+
* to an issue-comment endpoint structurally impossible.
|
|
30
|
+
*/
|
|
31
|
+
export declare function githubReviewCommentTs(commentId: number): string;
|
|
32
|
+
/** The review-comment id inside an `rc-<id>` ts, or null for other ts kinds. */
|
|
33
|
+
export declare function parseReviewCommentTs(ts: string): number | null;
|
|
34
|
+
//# sourceMappingURL=ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../../src/adapters/github/ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,qBAAqB,GAAG,MAAM,CAE5E;AAID,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,MAAM,GAAG,qBAAqB,CAYvF;AAED,oFAAoF;AACpF,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAE5C;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,gFAAgF;AAChF,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG9D"}
|