typeclaw 0.48.13 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/agent/attention-escalation.d.ts +18 -0
- package/dist/types/agent/auth.d.ts +7 -0
- package/dist/types/agent/compaction.d.ts +8 -0
- package/dist/types/agent/git-nudge.d.ts +6 -0
- package/dist/types/agent/guard-types.d.ts +25 -0
- package/dist/types/agent/guards.d.ts +7 -0
- package/dist/types/agent/idle-compaction.d.ts +7 -0
- package/dist/types/agent/index.d.ts +163 -0
- package/dist/types/agent/live-subagents.d.ts +113 -0
- package/dist/types/agent/llm-replay-sanitizer.d.ts +11 -0
- package/dist/types/agent/loop-guard.d.ts +67 -0
- package/dist/types/agent/model-fallback.d.ts +29 -0
- package/dist/types/agent/model-overrides.d.ts +8 -0
- package/dist/types/agent/multimodal/index.d.ts +2 -0
- package/dist/types/agent/multimodal/look-at.d.ts +60 -0
- package/dist/types/agent/multimodal/looker.d.ts +61 -0
- package/dist/types/agent/multimodal/read-redirect.d.ts +6 -0
- package/dist/types/agent/network/response-body.d.ts +1 -0
- package/dist/types/agent/network/safe-http.d.ts +46 -0
- package/dist/types/agent/plugin-tools.d.ts +129 -0
- package/dist/types/agent/proactive-next-step-nudge.d.ts +2 -0
- package/dist/types/agent/prompt-cache-key.d.ts +3 -0
- package/dist/types/agent/provider-error.d.ts +23 -0
- package/dist/types/agent/reload-tool.d.ts +10 -0
- package/dist/types/agent/restart/index.d.ts +31 -0
- package/dist/types/agent/restart-handoff/index.d.ts +32 -0
- package/dist/types/agent/restart-handoff/paths.d.ts +1 -0
- package/dist/types/agent/retry-same-ref.d.ts +41 -0
- package/dist/types/agent/reviewer-activity.d.ts +3 -0
- package/dist/types/agent/reviewer-bash-policy.d.ts +8 -0
- package/dist/types/agent/self.d.ts +1 -0
- package/dist/types/agent/session-meta.d.ts +28 -0
- package/dist/types/agent/session-origin.d.ts +65 -0
- package/dist/types/agent/subagent-cache-keepalive.d.ts +38 -0
- package/dist/types/agent/subagent-completion-reminder.d.ts +29 -0
- package/dist/types/agent/subagent-drain.d.ts +25 -0
- package/dist/types/agent/subagent-session.d.ts +3 -0
- package/dist/types/agent/subagents.d.ts +153 -0
- package/dist/types/agent/system-prompt.d.ts +7 -0
- package/dist/types/agent/throttle-circuit.d.ts +25 -0
- package/dist/types/agent/todo/continuation-policy.d.ts +54 -0
- package/dist/types/agent/todo/continuation-state.d.ts +11 -0
- package/dist/types/agent/todo/continuation-wiring.d.ts +32 -0
- package/dist/types/agent/todo/continuation.d.ts +21 -0
- package/dist/types/agent/todo/scope.d.ts +6 -0
- package/dist/types/agent/todo/store.d.ts +16 -0
- package/dist/types/agent/tool-error-remediation.d.ts +1 -0
- package/dist/types/agent/tool-file-safety.d.ts +78 -0
- package/dist/types/agent/tool-not-found-nudge.d.ts +9 -0
- package/dist/types/agent/tool-result-budget.d.ts +15 -0
- package/dist/types/agent/tools/channel-disengage.d.ts +18 -0
- package/dist/types/agent/tools/channel-edit.d.ts +19 -0
- package/dist/types/agent/tools/channel-fetch-attachment.d.ts +36 -0
- package/dist/types/agent/tools/channel-handoff.d.ts +13 -0
- package/dist/types/agent/tools/channel-history-render.d.ts +3 -0
- package/dist/types/agent/tools/channel-history.d.ts +25 -0
- package/dist/types/agent/tools/channel-log.d.ts +5 -0
- package/dist/types/agent/tools/channel-react.d.ts +23 -0
- package/dist/types/agent/tools/channel-read.d.ts +27 -0
- package/dist/types/agent/tools/channel-reply.d.ts +47 -0
- package/dist/types/agent/tools/channel-send.d.ts +42 -0
- package/dist/types/agent/tools/channel-session-search.d.ts +10 -0
- package/dist/types/agent/tools/curl-impersonate.d.ts +37 -0
- package/dist/types/agent/tools/ddg.d.ts +18 -0
- package/dist/types/agent/tools/grant-role.d.ts +25 -0
- package/dist/types/agent/tools/keyed-semaphore.d.ts +10 -0
- package/dist/types/agent/tools/post-github-review.d.ts +38 -0
- package/dist/types/agent/tools/restart.d.ts +25 -0
- package/dist/types/agent/tools/runtime-notice.d.ts +3 -0
- package/dist/types/agent/tools/search-retry.d.ts +16 -0
- package/dist/types/agent/tools/skip-response.d.ts +17 -0
- package/dist/types/agent/tools/spawn-subagent.d.ts +77 -0
- package/dist/types/agent/tools/stream-snapshot.d.ts +23 -0
- package/dist/types/agent/tools/subagent-access.d.ts +20 -0
- package/dist/types/agent/tools/subagent-cancel.d.ts +23 -0
- package/dist/types/agent/tools/subagent-output.d.ts +50 -0
- package/dist/types/agent/tools/todo/index.d.ts +14 -0
- package/dist/types/agent/tools/webfetch/adaptive-html.d.ts +29 -0
- package/dist/types/agent/tools/webfetch/fetch.d.ts +26 -0
- package/dist/types/agent/tools/webfetch/html-lexical.d.ts +27 -0
- package/dist/types/agent/tools/webfetch/index.d.ts +1 -0
- package/dist/types/agent/tools/webfetch/inline-style-visibility.d.ts +3 -0
- package/dist/types/agent/tools/webfetch/strategies/grep.d.ts +11 -0
- package/dist/types/agent/tools/webfetch/strategies/jq.d.ts +4 -0
- package/dist/types/agent/tools/webfetch/strategies/raw.d.ts +1 -0
- package/dist/types/agent/tools/webfetch/strategies/readability.d.ts +16 -0
- package/dist/types/agent/tools/webfetch/strategies/selector.d.ts +4 -0
- package/dist/types/agent/tools/webfetch/strategies/snapshot.d.ts +1 -0
- package/dist/types/agent/tools/webfetch/tool.d.ts +15 -0
- package/dist/types/agent/tools/webfetch/types.d.ts +32 -0
- package/dist/types/agent/tools/websearch.d.ts +17 -0
- package/dist/types/agent/tools/wikipedia.d.ts +7 -0
- package/dist/types/agent/tools-without-local-file-operands.d.ts +1 -0
- package/dist/types/agent/turn-runner.d.ts +36 -0
- package/dist/types/agent-messenger/config-dir.d.ts +19 -0
- package/dist/types/browser/dockerfile.d.ts +2 -0
- package/dist/types/browser/registry.d.ts +49 -0
- package/dist/types/bundled-plugins/bun-hygiene/policy.d.ts +18 -0
- package/dist/types/bundled-plugins/github-cli-auth/git-askpass.d.ts +5 -0
- package/dist/types/bundled-plugins/guard/keys.d.ts +6 -0
- package/dist/types/bundled-plugins/guard/policies/managed-config.d.ts +7 -0
- package/dist/types/bundled-plugins/guard/policies/memory-topics-delete.d.ts +11 -0
- package/dist/types/bundled-plugins/guard/policies/memory-topics-write.d.ts +7 -0
- package/dist/types/bundled-plugins/guard/policies/non-workspace-write.d.ts +9 -0
- package/dist/types/bundled-plugins/guard/policies/skill-authoring.d.ts +20 -0
- package/dist/types/bundled-plugins/guard/policies/uncommitted-changes.d.ts +12 -0
- package/dist/types/bundled-plugins/guard/policy.d.ts +11 -0
- package/dist/types/bundled-plugins/memory/secret-detector.d.ts +11 -0
- package/dist/types/bundled-plugins/memory/slug.d.ts +4 -0
- package/dist/types/bundled-plugins/security/permissions.d.ts +20 -0
- package/dist/types/bundled-plugins/security/policies/private-surface-read.d.ts +34 -0
- package/dist/types/bundled-plugins/security/policies/ssrf.d.ts +18 -0
- package/dist/types/bundled-plugins/security/policy.d.ts +4 -0
- package/dist/types/channels/adapter-namespace.d.ts +2 -0
- package/dist/types/channels/adapters/mention-hints.d.ts +12 -0
- package/dist/types/channels/adapters/webex-id-ref.d.ts +5 -0
- package/dist/types/channels/background-handoff.d.ts +56 -0
- package/dist/types/channels/background-obligations.d.ts +135 -0
- package/dist/types/channels/catch-up.d.ts +26 -0
- package/dist/types/channels/commands.d.ts +2 -0
- package/dist/types/channels/completion-claim.d.ts +20 -0
- package/dist/types/channels/continuation-willingness.d.ts +1 -0
- package/dist/types/channels/continuity-types.d.ts +75 -0
- package/dist/types/channels/describe-error.d.ts +1 -0
- package/dist/types/channels/engagement.d.ts +34 -0
- package/dist/types/channels/github-false-receipt.d.ts +20 -0
- package/dist/types/channels/github-repo.d.ts +2 -0
- package/dist/types/channels/github-rereview-guard.d.ts +24 -0
- package/dist/types/channels/github-review-check.d.ts +135 -0
- package/dist/types/channels/github-review-claim.d.ts +3 -0
- package/dist/types/channels/github-review-turn-ledger.d.ts +71 -0
- package/dist/types/channels/github-review-verdict-coordinator.d.ts +117 -0
- package/dist/types/channels/github-token-bridge.d.ts +20 -0
- package/dist/types/channels/github-verdict-activity.d.ts +12 -0
- package/dist/types/channels/inbound-journal.d.ts +272 -0
- package/dist/types/channels/last-alive.d.ts +3 -0
- package/dist/types/channels/membership-cache.d.ts +27 -0
- package/dist/types/channels/membership.d.ts +21 -0
- package/dist/types/channels/outbound-flood-filter.d.ts +7 -0
- package/dist/types/channels/participants.d.ts +4 -0
- package/dist/types/channels/persistence.d.ts +32 -0
- package/dist/types/channels/recovery-notice.d.ts +26 -0
- package/dist/types/channels/recovery-outbox.d.ts +58 -0
- package/dist/types/channels/router.d.ts +798 -0
- package/dist/types/channels/schema.d.ts +501 -0
- package/dist/types/channels/session-handoff.d.ts +58 -0
- package/dist/types/channels/session-search.d.ts +29 -0
- package/dist/types/channels/types.d.ts +414 -0
- package/dist/types/channels/waiting-reactions.d.ts +25 -0
- package/dist/types/cli/builtins.d.ts +2 -0
- package/dist/types/cli/command-meta.d.ts +9 -0
- package/dist/types/coding-agent/broker-body.d.ts +7 -0
- package/dist/types/coding-agent/broker.d.ts +22 -0
- package/dist/types/coding-agent/claude.d.ts +22 -0
- package/dist/types/coding-agent/codex.d.ts +19 -0
- package/dist/types/coding-agent/index.d.ts +71 -0
- package/dist/types/coding-agent/omo-state.d.ts +2 -0
- package/dist/types/coding-agent/omo-stream.d.ts +22 -0
- package/dist/types/coding-agent/omo.d.ts +133 -0
- package/dist/types/coding-agent/runner.d.ts +35 -0
- package/dist/types/coding-agent/tool.d.ts +27 -0
- package/dist/types/coding-agent/worktree.d.ts +22 -0
- package/dist/types/commands/index.d.ts +45 -0
- package/dist/types/config/config.d.ts +814 -0
- package/dist/types/config/index.d.ts +3 -0
- package/dist/types/config/model-overrides.d.ts +3 -0
- package/dist/types/config/providers.d.ts +1456 -0
- package/dist/types/config/reloadable.d.ts +9 -0
- package/dist/types/container/agent-operation-lock.d.ts +31 -0
- package/dist/types/container/build-cache.d.ts +39 -0
- package/dist/types/container/compose-project.d.ts +1 -0
- package/dist/types/container/controller.d.ts +25 -0
- package/dist/types/container/docker-app.d.ts +23 -0
- package/dist/types/container/exit-reason.d.ts +10 -0
- package/dist/types/container/index.d.ts +14 -0
- package/dist/types/container/log-archive.d.ts +68 -0
- package/dist/types/container/log-colors.d.ts +3 -0
- package/dist/types/container/log-timestamps.d.ts +9 -0
- package/dist/types/container/logs.d.ts +37 -0
- package/dist/types/container/memory-limit.d.ts +13 -0
- package/dist/types/container/memory-oversubscription.d.ts +20 -0
- package/dist/types/container/oom-events.d.ts +18 -0
- package/dist/types/container/port.d.ts +18 -0
- package/dist/types/container/require-running.d.ts +16 -0
- package/dist/types/container/restart.d.ts +32 -0
- package/dist/types/container/shared.d.ts +93 -0
- package/dist/types/container/shell.d.ts +35 -0
- package/dist/types/container/start.d.ts +144 -0
- package/dist/types/container/stats.d.ts +31 -0
- package/dist/types/container/status.d.ts +25 -0
- package/dist/types/container/stop.d.ts +24 -0
- package/dist/types/container/tool-oom-priority.d.ts +4 -0
- package/dist/types/container/verify-running.d.ts +49 -0
- package/dist/types/cron/consumer.d.ts +42 -0
- package/dist/types/cron/count-state.d.ts +24 -0
- package/dist/types/cron/index.d.ts +21 -0
- package/dist/types/cron/list.d.ts +33 -0
- package/dist/types/cron/reloadable.d.ts +11 -0
- package/dist/types/cron/scheduler.d.ts +51 -0
- package/dist/types/cron/schema.d.ts +108 -0
- package/dist/types/dependencies/bin-resolver.d.ts +28 -0
- package/dist/types/dependencies/bins.d.ts +22 -0
- package/dist/types/dependencies/index.d.ts +2 -0
- package/dist/types/git/bound-gc-config.d.ts +4 -0
- package/dist/types/git/hookless.d.ts +1 -0
- package/dist/types/git/reconcile-ignored.d.ts +13 -0
- package/dist/types/git/resolve-agent-git.d.ts +8 -0
- package/dist/types/git/resolve-identity.d.ts +10 -0
- package/dist/types/git/run.d.ts +24 -0
- package/dist/types/git/system-commit.d.ts +2 -0
- package/dist/types/hostd/client.d.ts +13 -0
- package/dist/types/hostd/models.d.ts +1 -0
- package/dist/types/hostd/paths.d.ts +17 -0
- package/dist/types/hostd/protocol.d.ts +93 -0
- package/dist/types/hostd/spawn.d.ts +17 -0
- package/dist/types/hostd/version.d.ts +18 -0
- package/dist/types/init/auto-upgrade.d.ts +41 -0
- package/dist/types/init/cli-version.d.ts +7 -0
- package/dist/types/init/dockerfile.d.ts +34 -0
- package/dist/types/init/ensure-deps.d.ts +17 -0
- package/dist/types/init/env-file.d.ts +3 -0
- package/dist/types/init/gitignore.d.ts +5 -0
- package/dist/types/init/local-source-stamp.d.ts +3 -0
- package/dist/types/init/packagejson.d.ts +7 -0
- package/dist/types/init/paths.d.ts +3 -0
- package/dist/types/init/reconcile-plugin-deps.d.ts +13 -0
- package/dist/types/init/run-bun-install.d.ts +16 -0
- package/dist/types/init/windows-dev-link.d.ts +8 -0
- package/dist/types/mcp/catalog.d.ts +7 -0
- package/dist/types/mcp/client.d.ts +58 -0
- package/dist/types/mcp/manager.d.ts +56 -0
- package/dist/types/mcp/tools.d.ts +23 -0
- package/dist/types/models/embedding-model.d.ts +20 -0
- package/dist/types/models/transformers-version.d.ts +1 -0
- package/dist/types/network/internal-destinations.d.ts +29 -0
- package/dist/types/operations/classify-tool-outcome.d.ts +35 -0
- package/dist/types/operations/incidents.d.ts +47 -0
- package/dist/types/operations/index.d.ts +3 -0
- package/dist/types/operations/remediations.d.ts +25 -0
- package/dist/types/path-safety/real-intended-path.d.ts +9 -0
- package/dist/types/permissions/builtins.d.ts +25 -0
- package/dist/types/permissions/grant.d.ts +19 -0
- package/dist/types/permissions/index.d.ts +6 -0
- package/dist/types/permissions/match-rule.d.ts +28 -0
- package/dist/types/permissions/permissions.d.ts +42 -0
- package/dist/types/permissions/resolve.d.ts +25 -0
- package/dist/types/permissions/schema.d.ts +14 -0
- package/dist/types/plugin/context.d.ts +20 -0
- package/dist/types/plugin/core-tool-names.d.ts +4 -0
- package/dist/types/plugin/define.d.ts +46 -0
- package/dist/types/plugin/hooks.d.ts +52 -0
- package/dist/types/plugin/index.d.ts +11 -0
- package/dist/types/plugin/load-skill.d.ts +14 -0
- package/dist/types/plugin/loader.d.ts +25 -0
- package/dist/types/plugin/manager.d.ts +42 -0
- package/dist/types/plugin/registry.d.ts +73 -0
- package/dist/types/plugin/skills.d.ts +11 -0
- package/dist/types/plugin/types.d.ts +336 -0
- package/dist/types/plugin/zod-introspect.d.ts +11 -0
- package/dist/types/reload/client.d.ts +11 -0
- package/dist/types/reload/docker-exec-client.d.ts +11 -0
- package/dist/types/reload/format.d.ts +2 -0
- package/dist/types/reload/index.d.ts +6 -0
- package/dist/types/reload/recover.d.ts +22 -0
- package/dist/types/reload/registry.d.ts +10 -0
- package/dist/types/reload/types.d.ts +25 -0
- package/dist/types/role-claim/client.d.ts +20 -0
- package/dist/types/role-claim/code.d.ts +4 -0
- package/dist/types/role-claim/controller.d.ts +59 -0
- package/dist/types/role-claim/index.d.ts +6 -0
- package/dist/types/role-claim/match-rule.d.ts +9 -0
- package/dist/types/role-claim/pending.d.ts +35 -0
- package/dist/types/role-claim/reload-after-claim.d.ts +16 -0
- package/dist/types/run/llm-fetch-observer.d.ts +50 -0
- package/dist/types/sandbox/availability.d.ts +21 -0
- package/dist/types/sandbox/build.d.ts +7 -0
- package/dist/types/sandbox/canonical-secrets.d.ts +8 -0
- package/dist/types/sandbox/coding-agent.d.ts +20 -0
- package/dist/types/sandbox/dependency-bins.d.ts +19 -0
- package/dist/types/sandbox/dev-source.d.ts +4 -0
- package/dist/types/sandbox/env-exposure.d.ts +1 -0
- package/dist/types/sandbox/errors.d.ts +20 -0
- package/dist/types/sandbox/hidden-paths.d.ts +11 -0
- package/dist/types/sandbox/index.d.ts +14 -0
- package/dist/types/sandbox/package-install.d.ts +1 -0
- package/dist/types/sandbox/policy.d.ts +71 -0
- package/dist/types/sandbox/privileged-runtime.d.ts +13 -0
- package/dist/types/sandbox/quote.d.ts +2 -0
- package/dist/types/sandbox/runtime-private.d.ts +1 -0
- package/dist/types/sandbox/session-tmp.d.ts +6 -0
- package/dist/types/sandbox/symlinks.d.ts +6 -0
- package/dist/types/sandbox/writable-zones.d.ts +15 -0
- package/dist/types/secrets/coding-agent-auth.d.ts +25 -0
- package/dist/types/secrets/defaults.d.ts +21 -0
- package/dist/types/secrets/export-github-cli-store.d.ts +22 -0
- package/dist/types/secrets/hydrate.d.ts +7 -0
- package/dist/types/secrets/index.d.ts +7 -0
- package/dist/types/secrets/provision-github-cli-store.d.ts +45 -0
- package/dist/types/secrets/refresh-provider-oauth.d.ts +22 -0
- package/dist/types/secrets/resolve.d.ts +14 -0
- package/dist/types/secrets/schema.d.ts +840 -0
- package/dist/types/secrets/storage.d.ts +56 -0
- package/dist/types/shared/host-locale.d.ts +1 -0
- package/dist/types/shared/index.d.ts +5 -0
- package/dist/types/shared/local-time.d.ts +4 -0
- package/dist/types/shared/platform.d.ts +2 -0
- package/dist/types/shared/protocol.d.ts +424 -0
- package/dist/types/shared/style-text.d.ts +3 -0
- package/dist/types/shared/wsl.d.ts +17 -0
- package/dist/types/stream/broker.d.ts +2 -0
- package/dist/types/stream/index.d.ts +2 -0
- package/dist/types/stream/types.d.ts +71 -0
- package/package.json +13 -6
- package/scripts/build-plugin-types.ts +105 -0
- package/scripts/check-plugin-sdk.ts +111 -0
- package/scripts/dump-system-prompt.ts +52 -110
- package/scripts/require-parallel.ts +5 -32
- package/src/agent/guard-types.ts +3 -0
- package/src/agent/guards.ts +4 -0
- package/src/agent/idle-compaction.ts +174 -0
- package/src/agent/index.ts +210 -80
- package/src/agent/live-sessions.ts +2 -2
- package/src/agent/live-subagents.ts +20 -0
- package/src/agent/multimodal/look-at.ts +22 -9
- package/src/agent/plugin-tools.ts +66 -12
- package/src/agent/prompt-cache-key.ts +42 -0
- package/src/agent/provider-error.ts +179 -10
- package/src/agent/restart-handoff/index.ts +7 -14
- package/src/agent/reviewer-activity.ts +68 -0
- package/src/agent/reviewer-bash-policy.ts +41 -1
- package/src/agent/session-origin.ts +58 -9
- package/src/agent/subagent-cache-keepalive.ts +198 -0
- package/src/agent/subagent-session.ts +6 -0
- package/src/agent/subagents.ts +59 -9
- package/src/agent/system-prompt.ts +68 -202
- package/src/agent/todo/continuation-policy.ts +12 -4
- package/src/agent/tool-file-safety.ts +119 -15
- package/src/agent/tool-not-found-nudge.ts +1 -1
- package/src/agent/tools/channel-edit.ts +20 -10
- package/src/agent/tools/channel-fetch-attachment.ts +12 -5
- package/src/agent/tools/channel-handoff.ts +72 -0
- package/src/agent/tools/channel-history-render.ts +2 -1
- package/src/agent/tools/channel-read.ts +57 -10
- package/src/agent/tools/channel-reply.ts +55 -30
- package/src/agent/tools/channel-send.ts +69 -19
- package/src/agent/tools/channel-session-search.ts +35 -0
- package/src/agent/tools/curl-impersonate.ts +22 -6
- package/src/agent/tools/ddg.ts +13 -5
- package/src/agent/tools/post-github-review.ts +77 -15
- package/src/agent/tools/skip-response.ts +2 -2
- package/src/agent/tools/spawn-subagent.ts +190 -23
- package/src/agent/tools/stream-snapshot.ts +15 -2
- package/src/agent/tools/subagent-access.ts +11 -4
- package/src/agent/tools/subagent-output.ts +8 -0
- package/src/browser/bsk-shim.mjs +74 -0
- package/src/browser/dockerfile.ts +84 -0
- package/src/browser/egress.ts +104 -0
- package/src/browser/managed-browser.ts +205 -0
- package/src/browser/registry.ts +110 -0
- package/src/browser/relay.ts +231 -0
- package/src/browser/sandbox-entry.ts +167 -0
- package/src/bundled-plugins/agent-browser/index.ts +2 -0
- package/src/bundled-plugins/backup/README.md +10 -9
- package/src/bundled-plugins/backup/runner.ts +140 -58
- package/src/bundled-plugins/backup/subagents.ts +58 -26
- package/src/bundled-plugins/browser-agent/browser-agent.ts +89 -0
- package/src/bundled-plugins/browser-agent/index.ts +12 -0
- package/src/bundled-plugins/doc-render/index.ts +0 -10
- package/src/bundled-plugins/doc-render/render.ts +83 -111
- package/src/bundled-plugins/doc-render/skills/typeclaw-render-pdf/SKILL.md +152 -257
- package/src/bundled-plugins/github-cli-auth/gh-command.ts +38 -2
- package/src/bundled-plugins/github-cli-auth/git-auth-diagnostic.ts +95 -0
- package/src/bundled-plugins/github-cli-auth/granted-push.ts +135 -0
- package/src/bundled-plugins/github-cli-auth/index.ts +158 -70
- package/src/bundled-plugins/github-cli-auth/review-account.ts +23 -0
- package/src/bundled-plugins/github-cli-auth/review-checkout.ts +9 -2
- package/src/bundled-plugins/github-cli-auth/review-recorder.ts +45 -7
- package/src/bundled-plugins/managed-browser/index.ts +74 -0
- package/src/bundled-plugins/managed-browser/skills/browser-use/browser-use/SKILL.md +27 -0
- package/src/bundled-plugins/managed-browser/skills/browserskill/browserskill/SKILL.md +28 -0
- package/src/bundled-plugins/managed-browser/skills/omowright/omowright/SKILL.md +40 -0
- package/src/bundled-plugins/operator/operator.ts +15 -4
- package/src/bundled-plugins/qa/index.ts +11 -0
- package/src/bundled-plugins/qa/qa.ts +160 -0
- package/src/bundled-plugins/qa/skills/qa-cli.ts +50 -0
- package/src/bundled-plugins/qa/skills/qa-general.ts +30 -0
- package/src/bundled-plugins/qa/skills/qa-http.ts +39 -0
- package/src/bundled-plugins/qa/skills/qa-pr.ts +51 -0
- package/src/bundled-plugins/qa/skills/qa-web.ts +49 -0
- package/src/bundled-plugins/reviewer/skills/code-review.ts +1 -1
- package/src/bundled-plugins/security/index.ts +103 -36
- package/src/bundled-plugins/security/policies/git-exfil.ts +24 -12
- package/src/bundled-plugins/security/policies/outbound-secret-scan.ts +1 -0
- package/src/channels/adapter-namespace.ts +13 -0
- package/src/channels/adapters/discord-bot-reactions.ts +18 -0
- package/src/channels/adapters/discord-bot.ts +219 -72
- package/src/channels/adapters/discord-reactions.ts +18 -0
- package/src/channels/adapters/discord.ts +114 -8
- package/src/channels/adapters/github/inbound.ts +103 -8
- package/src/channels/adapters/github/index.ts +267 -19
- package/src/channels/adapters/github/last-alive.ts +15 -0
- package/src/channels/adapters/github/outbound.ts +54 -18
- package/src/channels/adapters/github/pending-review-store.ts +141 -0
- package/src/channels/adapters/github/permission-guidance.ts +1 -0
- package/src/channels/adapters/github/reactions.ts +100 -0
- package/src/channels/adapters/github/reconcile-cooldown-store.ts +197 -67
- package/src/channels/adapters/github/reconcile-open-prs.ts +418 -33
- package/src/channels/adapters/github/recovery.ts +106 -0
- package/src/channels/adapters/github/review-check.ts +510 -0
- package/src/channels/adapters/github/review-submitter.ts +34 -2
- package/src/channels/adapters/instagram.ts +32 -14
- package/src/channels/adapters/kakaotalk.ts +22 -7
- package/src/channels/adapters/line.ts +18 -3
- package/src/channels/adapters/outbound-account.ts +20 -0
- package/src/channels/adapters/own-reactions.ts +66 -0
- package/src/channels/adapters/recovery-correlation.ts +214 -0
- package/src/channels/adapters/slack-attachment-download.ts +14 -3
- package/src/channels/adapters/slack-bot-author-resolver.ts +4 -3
- package/src/channels/adapters/slack-bot-channel-resolver.ts +9 -6
- package/src/channels/adapters/slack-bot-classify.ts +19 -11
- package/src/channels/adapters/slack-bot-dedupe.ts +111 -28
- package/src/channels/adapters/slack-bot-reactions.ts +18 -0
- package/src/channels/adapters/slack-bot-slash-commands.ts +3 -1
- package/src/channels/adapters/slack-bot.ts +424 -124
- package/src/channels/adapters/slack-classify.ts +26 -4
- package/src/channels/adapters/slack-inbound-revision.ts +96 -0
- package/src/channels/adapters/slack-reactions.ts +18 -0
- package/src/channels/adapters/slack-thread-ts.ts +6 -0
- package/src/channels/adapters/slack.ts +48 -3
- package/src/channels/adapters/teams.ts +14 -4
- package/src/channels/adapters/telegram-bot.ts +56 -10
- package/src/channels/adapters/webex-bot.ts +12 -2
- package/src/channels/adapters/webex.ts +12 -2
- package/src/channels/background-handoff.ts +434 -0
- package/src/channels/background-obligations.ts +893 -0
- package/src/channels/catch-up.ts +137 -0
- package/src/channels/continuation-willingness.ts +2 -2
- package/src/channels/continuity-types.ts +272 -0
- package/src/channels/engagement.ts +17 -1
- package/src/channels/github-false-receipt.ts +3 -3
- package/src/channels/github-rereview-guard.ts +9 -5
- package/src/channels/github-review-check.ts +598 -0
- package/src/channels/github-review-turn-ledger.ts +102 -28
- package/src/channels/github-review-verdict-coordinator.ts +72 -12
- package/src/channels/github-token-bridge.ts +35 -5
- package/src/channels/inbound-journal.ts +1738 -0
- package/src/channels/index.ts +6 -1
- package/src/channels/last-alive.ts +34 -0
- package/src/channels/manager.ts +25 -8
- package/src/channels/recovery-dispatcher.ts +264 -0
- package/src/channels/recovery-notice.ts +94 -0
- package/src/channels/recovery-outbox.ts +459 -0
- package/src/channels/router.ts +2951 -736
- package/src/channels/schema.ts +8 -1
- package/src/channels/session-handoff.fixture.ts +144 -0
- package/src/channels/session-handoff.ts +175 -0
- package/src/channels/session-search.ts +71 -0
- package/src/channels/subagent-completion-bridge.ts +17 -14
- package/src/channels/types.ts +133 -18
- package/src/channels/waiting-reactions.ts +664 -0
- package/src/cli/channel.ts +2 -3
- package/src/cli/compose.ts +7 -4
- package/src/cli/hostd.ts +49 -3
- package/src/cli/init.ts +2 -3
- package/src/cli/inspect.ts +11 -14
- package/src/cli/model.ts +132 -3
- package/src/coding-agent/broker-body.ts +38 -0
- package/src/coding-agent/broker.ts +290 -0
- package/src/coding-agent/claude.ts +95 -0
- package/src/coding-agent/codex.ts +104 -0
- package/src/coding-agent/index.ts +512 -0
- package/src/coding-agent/omo-state.ts +69 -0
- package/src/coding-agent/omo-stream.ts +138 -0
- package/src/coding-agent/omo.ts +192 -0
- package/src/coding-agent/runner.ts +285 -0
- package/src/coding-agent/tool.ts +62 -0
- package/src/coding-agent/worktree.ts +355 -0
- package/src/compose/restart.ts +10 -3
- package/src/compose/start.ts +20 -3
- package/src/config/config.ts +121 -25
- package/src/config/model-overrides.ts +59 -0
- package/src/config/models-mutation.ts +185 -2
- package/src/config/providers-mutation.ts +12 -4
- package/src/config/providers.ts +71 -9
- package/src/container/exit-reason.ts +44 -0
- package/src/container/index.ts +5 -0
- package/src/container/log-archive.ts +51 -13
- package/src/container/memory-limit.ts +1 -1
- package/src/container/memory-oversubscription.ts +36 -6
- package/src/container/oom-events.ts +86 -0
- package/src/container/restart.ts +2 -0
- package/src/container/shared.ts +8 -1
- package/src/container/start.ts +120 -17
- package/src/container/stop.ts +6 -2
- package/src/container/tool-oom-priority.ts +32 -0
- package/src/cron/consumer.ts +10 -4
- package/src/cron/reloadable.ts +23 -2
- package/src/doctor/checks.ts +22 -8
- package/src/hostd/daemon.ts +33 -11
- package/src/hostd/spawn.ts +106 -5
- package/src/hostd/version.ts +20 -0
- package/src/hostd/watchdog.ts +241 -0
- package/src/init/auto-upgrade.ts +7 -1
- package/src/init/dockerfile.ts +112 -602
- package/src/init/index.ts +6 -6
- package/src/init/local-source-stamp.ts +68 -0
- package/src/init/models-dev.ts +4 -0
- package/src/init/validate-api-key.ts +3 -0
- package/src/mcp/client.ts +3 -1
- package/src/operations/classify-tool-outcome.ts +45 -1
- package/src/operations/incidents.ts +10 -5
- package/src/permissions/builtins.ts +7 -0
- package/src/permissions/permissions.ts +18 -9
- package/src/permissions/resolve.ts +7 -1
- package/src/plugin/context.ts +2 -0
- package/src/plugin/core-tool-names.ts +1 -1
- package/src/plugin/define.ts +1 -0
- package/src/plugin/hooks.ts +137 -0
- package/src/plugin/index.ts +7 -0
- package/src/plugin/manager.ts +4 -0
- package/src/plugin/types.ts +66 -1
- package/src/run/background-handoff-boot.ts +86 -0
- package/src/run/bundled-plugins.ts +6 -0
- package/src/run/index.ts +107 -97
- package/src/run/llm-fetch-observer.ts +12 -15
- package/src/run/resource-sample.ts +19 -0
- package/src/sandbox/build.ts +4 -0
- package/src/sandbox/canonical-secrets.ts +4 -0
- package/src/sandbox/coding-agent.ts +214 -0
- package/src/sandbox/dev-source.ts +26 -0
- package/src/sandbox/hidden-paths.ts +16 -2
- package/src/sandbox/policy.ts +1 -0
- package/src/sandbox/runtime-private.ts +4 -1
- package/src/secrets/coding-agent-auth.ts +97 -0
- package/src/secrets/index.ts +0 -16
- package/src/secrets/storage.ts +13 -0
- package/src/server/command-runner.ts +6 -2
- package/src/server/index.ts +101 -40
- package/src/skills/typeclaw-channel-github/SKILL.md +15 -13
- package/src/skills/typeclaw-claude-code/SKILL.md +25 -260
- package/src/skills/typeclaw-claude-code/references/auth-flow.md +7 -23
- package/src/skills/typeclaw-claude-code/references/headless-sessions.md +11 -0
- package/src/skills/typeclaw-claude-code/references/results-and-worktrees.md +13 -0
- package/src/skills/typeclaw-codex-cli/SKILL.md +35 -270
- package/src/skills/typeclaw-codex-cli/references/auth-flow.md +13 -20
- package/src/skills/typeclaw-codex-cli/references/headless-sessions.md +26 -0
- package/src/skills/typeclaw-codex-cli/references/results-and-worktrees.md +28 -0
- package/src/skills/typeclaw-config/SKILL.md +60 -26
- package/src/skills/typeclaw-config/references/dockerfile.md +14 -13
- package/src/skills/typeclaw-cron/SKILL.md +1 -1
- package/src/skills/typeclaw-github-contributing/SKILL.md +3 -3
- package/src/skills/typeclaw-memory/SKILL.md +3 -3
- package/src/skills/typeclaw-monorepo/SKILL.md +1 -1
- package/src/skills/typeclaw-omo-cli/SKILL.md +52 -0
- package/src/skills/typeclaw-omo-cli/references/auth-flow.md +11 -0
- package/src/skills/typeclaw-omo-cli/references/headless-sessions.md +11 -0
- package/src/skills/typeclaw-omo-cli/references/results-and-worktrees.md +23 -0
- package/src/skills/typeclaw-permissions/SKILL.md +7 -7
- package/src/skills/typeclaw-plugins/SKILL.md +15 -15
- package/src/skills/typeclaw-skills/SKILL.md +19 -2
- package/src/skills/typeclaw-troubleshooting/SKILL.md +26 -2
- package/typeclaw.schema.json +448 -6
- package/src/bundled-plugins/doc-render/templates/lib.typ +0 -339
- package/src/bundled-plugins/github-cli-auth/gh-store.ts +0 -733
- package/src/secrets/claude-credentials-json.ts +0 -129
- package/src/secrets/codex-auth-json.ts +0 -102
- package/src/secrets/export-claude-credentials-file.ts +0 -270
- package/src/secrets/export-codex-auth-file.ts +0 -250
- package/src/skills/typeclaw-claude-code/references/stop-hook.md +0 -101
- package/src/skills/typeclaw-claude-code/references/tmux-driving.md +0 -243
- package/src/skills/typeclaw-codex-cli/references/stop-hook.md +0 -92
- package/src/skills/typeclaw-codex-cli/references/tmux-driving.md +0 -239
|
@@ -1,12 +1,22 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto'
|
|
2
|
+
|
|
3
|
+
import { githubReviewChecks } from '@/channels/github-review-check'
|
|
4
|
+
import { observeVerifiedDismissals } from '@/channels/github-review-turn-ledger'
|
|
1
5
|
import type { GithubTokenBridge } from '@/channels/github-token-bridge'
|
|
2
6
|
import type { ChannelRouter } from '@/channels/router'
|
|
3
7
|
import type { ChannelAdapterConfig, GithubAdapterConfig } from '@/channels/schema'
|
|
4
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
ChannelSelfIdentityResolver,
|
|
10
|
+
InboundMessage,
|
|
11
|
+
RecoveryAdapterCallbacks,
|
|
12
|
+
RouteReceipt,
|
|
13
|
+
} from '@/channels/types'
|
|
5
14
|
import { resolveSecret } from '@/secrets/resolve'
|
|
6
15
|
import type { GithubSecretsBlock } from '@/secrets/schema'
|
|
7
16
|
|
|
8
17
|
import { describeError } from '../../describe-error'
|
|
9
18
|
import { canonicalGithubRepo } from '../../github-repo'
|
|
19
|
+
import { withOutboundAccount } from '../outbound-account'
|
|
10
20
|
import { buildAuthStrategy, type GithubAuthContext } from './auth'
|
|
11
21
|
import { createGithubChannelNameResolver } from './channel-resolver'
|
|
12
22
|
import { createDeliveryDedup } from './dedup'
|
|
@@ -14,18 +24,28 @@ import { findPermissionGaps } from './event-permissions'
|
|
|
14
24
|
import { createGithubFetchAttachmentCallback } from './fetch-attachment'
|
|
15
25
|
import { createGithubHistoryCallback } from './history'
|
|
16
26
|
import { createGithubWebhookHandler, processVerifiedGithubDelivery, type GithubWebhookHandlerOptions } from './inbound'
|
|
27
|
+
import { readGithubLastAlive, writeGithubLastAlive } from './last-alive'
|
|
17
28
|
import { applyManagedPath, buildManagedPath, resolveAgentId } from './managed-path'
|
|
18
29
|
import { createGithubMembershipResolver } from './membership'
|
|
19
30
|
import { createGithubOutboundCallback } from './outbound'
|
|
31
|
+
import { loadPendingReviewStore, type PendingReviewStore } from './pending-review-store'
|
|
20
32
|
import {
|
|
21
33
|
buildAppPermissionPreflightGuidance,
|
|
22
34
|
buildPermissionGuidance,
|
|
23
35
|
parseListHooksPermissionStatus,
|
|
24
36
|
} from './permission-guidance'
|
|
25
37
|
import { createGithubReactionCallback, createGithubRemoveReactionCallback } from './reactions'
|
|
38
|
+
import { createGithubOwnReactionCallbacks } from './reactions'
|
|
26
39
|
import { loadReconcileCooldownStore, type ReconcileCooldownStore } from './reconcile-cooldown-store'
|
|
27
|
-
import { reconcileOpenPrs } from './reconcile-open-prs'
|
|
40
|
+
import { completePendingReview, reconcileOpenPrs, replayPendingReviews } from './reconcile-open-prs'
|
|
28
41
|
import { createRecoveredGuidLog, recoverFailedGithubDeliveries } from './recover-failed-deliveries'
|
|
42
|
+
import { createGithubRecoveryCallbacks } from './recovery'
|
|
43
|
+
import {
|
|
44
|
+
createGithubReviewCheckPublisher,
|
|
45
|
+
createReviewCheckLeaseStore,
|
|
46
|
+
reviewCheckDetails,
|
|
47
|
+
reviewCheckName,
|
|
48
|
+
} from './review-check'
|
|
29
49
|
import { createGithubReviewStateResolver } from './review-state'
|
|
30
50
|
import { createGithubReviewSubmitter } from './review-submitter'
|
|
31
51
|
import { createGithubReviewThreadResolver } from './review-thread-resolver'
|
|
@@ -132,6 +152,9 @@ export function createGithubAdapter(options: GithubAdapterOptions): GithubAdapte
|
|
|
132
152
|
let deliveryRecoveryTimer: { clear: () => void } | null = null
|
|
133
153
|
let reconcileTimer: { clear: () => void } | null = null
|
|
134
154
|
let reconcileCooldownStore: ReconcileCooldownStore | null = null
|
|
155
|
+
let pendingReviewStore: PendingReviewStore | null = null
|
|
156
|
+
let stopObservingDismissals: (() => void) | null = null
|
|
157
|
+
let lifecycleGeneration = 0
|
|
135
158
|
let unregisterTokenBridge: (() => void) | null = null
|
|
136
159
|
const workspaceByChat = new Map<string, string>()
|
|
137
160
|
const setIntervalFn =
|
|
@@ -151,10 +174,41 @@ export function createGithubAdapter(options: GithubAdapterOptions): GithubAdapte
|
|
|
151
174
|
// does NOT mutate process.env.GH_TOKEN. App credentials stay behind this
|
|
152
175
|
// repo-scoped resolver instead of entering the ambient process environment.
|
|
153
176
|
const authToken = (context?: GithubAuthContext) => auth.token(context)
|
|
154
|
-
|
|
177
|
+
// The boot reconcile pass re-admits review work a restart killed, so a restart notice for an
|
|
178
|
+
// interrupted review would wrongly tell the author it was dropped. Only a replay the router
|
|
179
|
+
// newly accepted counts: a duplicate may be the very admission that was interrupted.
|
|
180
|
+
let firstReconcilePending = true
|
|
181
|
+
const reconcileReplayedPrs = new Set<string>()
|
|
182
|
+
const recoveryCallbacks: RecoveryAdapterCallbacks = {
|
|
183
|
+
...createGithubRecoveryCallbacks(auth, fetchImpl, () => (selfId !== null ? `github:${selfId}` : undefined)),
|
|
184
|
+
redelivery: (record, eventKinds) => {
|
|
185
|
+
if (!eventKinds.every((kind) => REVIEW_TRIGGER_EVENT_KINDS.has(kind))) return 'not-redelivered'
|
|
186
|
+
const prNumber = /^pr:(\d+)$/.exec(record.target.chat)?.[1]
|
|
187
|
+
if (prNumber !== undefined && pendingReviewStore?.has(record.target.workspace, Number(prNumber)))
|
|
188
|
+
return 'redelivered'
|
|
189
|
+
// A fresh-review reconcile replay is runtime-synthesized: nobody asked, so a restart notice
|
|
190
|
+
// would only announce system state. The next periodic pass after the cooldown retries it.
|
|
191
|
+
// Held re-reviews (`pull_request:reconcile:rereview`) replay only on boot, so they keep the
|
|
192
|
+
// normal notice path below.
|
|
193
|
+
if (eventKinds.every((kind) => kind === 'pull_request:reconcile')) return 'redelivered'
|
|
194
|
+
if (reconcileReplayedPrs.has(prReplayKey(record.target.workspace, record.target.chat))) return 'redelivered'
|
|
195
|
+
return firstReconcilePending ? 'pending' : 'not-redelivered'
|
|
196
|
+
},
|
|
197
|
+
}
|
|
198
|
+
const outbound = withOutboundAccount(
|
|
199
|
+
createGithubOutboundCallback({
|
|
200
|
+
token: authToken,
|
|
201
|
+
authType: options.secrets.auth.type,
|
|
202
|
+
logger,
|
|
203
|
+
fetchImpl,
|
|
204
|
+
accountIdentity: recoveryCallbacks.accountIdentity,
|
|
205
|
+
}),
|
|
206
|
+
() => recoveryCallbacks.cachedAccountIdentity?.(),
|
|
207
|
+
)
|
|
208
|
+
const ownReaction = createGithubOwnReactionCallbacks({
|
|
155
209
|
token: authToken,
|
|
210
|
+
getSelf: () => auth.getSelf(),
|
|
156
211
|
authType: options.secrets.auth.type,
|
|
157
|
-
logger,
|
|
158
212
|
fetchImpl,
|
|
159
213
|
})
|
|
160
214
|
const reaction = createGithubReactionCallback({
|
|
@@ -184,9 +238,32 @@ export function createGithubAdapter(options: GithubAdapterOptions): GithubAdapte
|
|
|
184
238
|
approve: () => options.configRef().review.approve,
|
|
185
239
|
fetchImpl,
|
|
186
240
|
})
|
|
241
|
+
const reviewCheckPublisher = createGithubReviewCheckPublisher({
|
|
242
|
+
token: authToken,
|
|
243
|
+
authType: options.secrets.auth.type,
|
|
244
|
+
enabled: () => options.configRef().review.check,
|
|
245
|
+
checkName: () => reviewCheckName(selfLogin),
|
|
246
|
+
logger,
|
|
247
|
+
fetchImpl,
|
|
248
|
+
})
|
|
187
249
|
const reviewSubmitter = createGithubReviewSubmitter({
|
|
188
250
|
token: authToken,
|
|
189
251
|
allowApprove: () => options.configRef().review.approve,
|
|
252
|
+
accountIdentity: recoveryCallbacks.accountIdentity,
|
|
253
|
+
onReviewPosted: async (posted) => {
|
|
254
|
+
if (pendingReviewStore !== null) {
|
|
255
|
+
try {
|
|
256
|
+
await completePendingReview(pendingReviewStore, { ...posted, submittedAt: Date.now() }, authToken, fetchImpl)
|
|
257
|
+
} catch (error) {
|
|
258
|
+
logger.warn(`[github] pending review completion persist failed: ${describeError(error)}`)
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
void githubReviewChecks.reviewPosted(
|
|
262
|
+
{ repo: posted.repo, pullRequest: posted.prNumber, headSha: posted.headSha },
|
|
263
|
+
posted.state,
|
|
264
|
+
reviewCheckDetails(posted.reviewId, posted.comments),
|
|
265
|
+
)
|
|
266
|
+
},
|
|
190
267
|
fetchImpl,
|
|
191
268
|
})
|
|
192
269
|
const channelNameResolver = createGithubChannelNameResolver({ token: authToken, fetchImpl })
|
|
@@ -202,15 +279,32 @@ export function createGithubAdapter(options: GithubAdapterOptions): GithubAdapte
|
|
|
202
279
|
// Shared inbound entry. Both the live webhook handler and the startup
|
|
203
280
|
// reconciliation pass route through this so a replayed PR takes the exact
|
|
204
281
|
// same path a real delivery would.
|
|
205
|
-
const routeInbound = (message: InboundMessage):
|
|
282
|
+
const routeInbound = async (message: InboundMessage): Promise<RouteReceipt> => {
|
|
206
283
|
rememberWorkspace(message.workspace, message.chat)
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
284
|
+
const store = pendingReviewStore
|
|
285
|
+
const pending = message.githubPendingReview
|
|
286
|
+
const prNumber = /^pr:(\d+)$/.exec(message.chat)?.[1]
|
|
287
|
+
// The webhook handler schedules this outside its acknowledgment path.
|
|
288
|
+
return options.router.route(
|
|
289
|
+
{
|
|
290
|
+
...message,
|
|
291
|
+
accountIdentity: message.accountIdentity ?? (selfId === null ? undefined : `github:${selfId}`),
|
|
292
|
+
eventKind: message.eventKind ?? 'review-followup',
|
|
293
|
+
revision: message.revision ?? 'original',
|
|
294
|
+
},
|
|
295
|
+
store !== null && pending !== undefined && prNumber !== undefined
|
|
296
|
+
? () =>
|
|
297
|
+
store.record({
|
|
298
|
+
repo: message.workspace,
|
|
299
|
+
prNumber: Number(prNumber),
|
|
300
|
+
...pending,
|
|
301
|
+
admittedAt: Date.now(),
|
|
302
|
+
authorId: message.authorId,
|
|
303
|
+
authorName: message.authorName,
|
|
304
|
+
authorIsBot: message.authorIsBot,
|
|
305
|
+
})
|
|
306
|
+
: undefined,
|
|
307
|
+
)
|
|
214
308
|
}
|
|
215
309
|
const handlerOptions: GithubWebhookHandlerOptions = {
|
|
216
310
|
webhookSecret,
|
|
@@ -227,6 +321,12 @@ export function createGithubAdapter(options: GithubAdapterOptions): GithubAdapte
|
|
|
227
321
|
logger,
|
|
228
322
|
route: routeInbound,
|
|
229
323
|
abortGithubPrTurn: options.router.abortGithubPrTurn,
|
|
324
|
+
clearPendingReview: async (workspace, prNumber) => {
|
|
325
|
+
await pendingReviewStore?.clear(workspace, prNumber)
|
|
326
|
+
},
|
|
327
|
+
reviewSubmitted: async (review) => {
|
|
328
|
+
if (pendingReviewStore !== null) await completePendingReview(pendingReviewStore, review, authToken, fetchImpl)
|
|
329
|
+
},
|
|
230
330
|
clearReconcileCooldown: async (workspace, prId) => {
|
|
231
331
|
if (reconcileCooldownStore === null) return 'not-initialized'
|
|
232
332
|
await reconcileCooldownStore.clear(workspace, prId)
|
|
@@ -238,14 +338,41 @@ export function createGithubAdapter(options: GithubAdapterOptions): GithubAdapte
|
|
|
238
338
|
return {
|
|
239
339
|
async start(): Promise<void> {
|
|
240
340
|
if (started) return
|
|
341
|
+
firstReconcilePending = true
|
|
342
|
+
reconcileReplayedPrs.clear()
|
|
241
343
|
const self = await auth.getSelf()
|
|
242
344
|
selfId = String(self.id)
|
|
243
345
|
selfLogin = self.login
|
|
346
|
+
// Ready before binding HTTP: the first live webhook can create pending work.
|
|
347
|
+
const loadedPendingReviewStore = await loadPendingReviewStore(options.agentDir, logger)
|
|
348
|
+
pendingReviewStore = loadedPendingReviewStore
|
|
349
|
+
// Keep suppression through the boot even when API verification clears an
|
|
350
|
+
// entry as already completed or closed: there is no lost work to announce.
|
|
351
|
+
for (const pending of await loadedPendingReviewStore.list())
|
|
352
|
+
reconcileReplayedPrs.add(prReplayKey(pending.repo, `pr:${pending.prNumber}`))
|
|
353
|
+
stopObservingDismissals = observeVerifiedDismissals(async (dismissal) => {
|
|
354
|
+
if (dismissal.commitSha === undefined || dismissal.startedAt === undefined) return
|
|
355
|
+
const pending = (await loadedPendingReviewStore.list()).find(
|
|
356
|
+
(entry) =>
|
|
357
|
+
canonicalGithubRepo(entry.repo) === canonicalGithubRepo(dismissal.workspace) &&
|
|
358
|
+
entry.prNumber === dismissal.prNumber,
|
|
359
|
+
)
|
|
360
|
+
if (
|
|
361
|
+
pending?.kind !== 'rereview' ||
|
|
362
|
+
pending.headSha !== dismissal.commitSha ||
|
|
363
|
+
pending.admittedAt > dismissal.startedAt
|
|
364
|
+
)
|
|
365
|
+
return
|
|
366
|
+
await loadedPendingReviewStore.clear(pending.repo, pending.prNumber, pending)
|
|
367
|
+
})
|
|
244
368
|
// Register all callbacks before binding the HTTP listener so the router
|
|
245
369
|
// is fully wired before any webhook can arrive.
|
|
246
370
|
options.router.registerOutbound('github', outbound)
|
|
371
|
+
options.router.registerRecoveryAdapter('github', recoveryCallbacks)
|
|
247
372
|
options.router.registerReaction('github', reaction)
|
|
248
373
|
options.router.registerRemoveReaction('github', removeReaction)
|
|
374
|
+
options.router.registerPrepareOwnReaction('github', ownReaction.prepare)
|
|
375
|
+
options.router.registerRemoveOwnReaction('github', ownReaction.remove)
|
|
249
376
|
options.router.registerTyping('github', typing)
|
|
250
377
|
options.router.registerHistory('github', history)
|
|
251
378
|
options.router.registerMembership('github', membership)
|
|
@@ -258,11 +385,16 @@ export function createGithubAdapter(options: GithubAdapterOptions): GithubAdapte
|
|
|
258
385
|
try {
|
|
259
386
|
server = (options.httpListenImpl ?? listenWithBun)(options.configRef().webhookPort, handler)
|
|
260
387
|
} catch (err) {
|
|
388
|
+
stopObservingDismissals?.()
|
|
389
|
+
stopObservingDismissals = null
|
|
261
390
|
// Listener failed — roll back all registrations so stop() is a no-op
|
|
262
391
|
// and the manager can report the failure cleanly.
|
|
263
392
|
options.router.unregisterOutbound('github', outbound)
|
|
393
|
+
options.router.unregisterRecoveryAdapter('github', recoveryCallbacks)
|
|
264
394
|
options.router.unregisterReaction('github', reaction)
|
|
265
395
|
options.router.unregisterRemoveReaction('github', removeReaction)
|
|
396
|
+
options.router.unregisterPrepareOwnReaction('github', ownReaction.prepare)
|
|
397
|
+
options.router.unregisterRemoveOwnReaction('github', ownReaction.remove)
|
|
266
398
|
options.router.unregisterTyping('github', typing)
|
|
267
399
|
options.router.unregisterHistory('github', history)
|
|
268
400
|
options.router.unregisterMembership('github', membership)
|
|
@@ -295,6 +427,22 @@ export function createGithubAdapter(options: GithubAdapterOptions): GithubAdapte
|
|
|
295
427
|
}
|
|
296
428
|
tokenRefreshTimer = setIntervalFn(refresh, tokenRefreshIntervalMs)
|
|
297
429
|
}
|
|
430
|
+
// The channel PAT is the agent's own GitHub identity, so lend it to a git push
|
|
431
|
+
// for a configured repo instead of making the operator duplicate it in `.env`.
|
|
432
|
+
// repos[] is enforced here because this adapter owns it; the broker adds the
|
|
433
|
+
// role gate, so sandboxed roles still never receive the long-lived PAT.
|
|
434
|
+
if (options.githubTokenBridge !== undefined) {
|
|
435
|
+
unregisterTokenBridge = options.githubTokenBridge.registerPatResolver(async (repoSlug) => {
|
|
436
|
+
const allowed = new Set((options.configRef().repos ?? []).map(canonicalGithubRepo))
|
|
437
|
+
if (!allowed.has(canonicalGithubRepo(repoSlug))) {
|
|
438
|
+
throw new Error(
|
|
439
|
+
`repo \`${repoSlug}\` is not in this agent's configured \`channels.github.repos[]\`; ` +
|
|
440
|
+
'refusing to lend the GitHub channel PAT for it. Add it to `repos[]` if the agent is meant to push there.',
|
|
441
|
+
)
|
|
442
|
+
}
|
|
443
|
+
return { token: await auth.token() }
|
|
444
|
+
})
|
|
445
|
+
}
|
|
298
446
|
}
|
|
299
447
|
if (options.secrets.auth.type === 'app' && options.githubTokenBridge !== undefined) {
|
|
300
448
|
// Gate ad-hoc `gh` minting on the configured repos[]. The slug arrives
|
|
@@ -304,7 +452,9 @@ export function createGithubAdapter(options: GithubAdapterOptions): GithubAdapte
|
|
|
304
452
|
// on — a cross-tenant leak under a multi-owner App. Enforced here, not in
|
|
305
453
|
// the parser, because this adapter is the authority that owns repos[].
|
|
306
454
|
unregisterTokenBridge = options.githubTokenBridge.registerResolver(
|
|
307
|
-
(repoSlug) => {
|
|
455
|
+
async (repoSlug) => {
|
|
456
|
+
const capturedSelfId = selfId
|
|
457
|
+
if (capturedSelfId === null) throw new Error('GitHub authenticated account is unavailable')
|
|
308
458
|
const allowed = new Set((options.configRef().repos ?? []).map(canonicalGithubRepo))
|
|
309
459
|
if (!allowed.has(canonicalGithubRepo(repoSlug))) {
|
|
310
460
|
throw new Error(
|
|
@@ -313,17 +463,31 @@ export function createGithubAdapter(options: GithubAdapterOptions): GithubAdapte
|
|
|
313
463
|
'or add it to `repos[]` if the agent is meant to operate there.',
|
|
314
464
|
)
|
|
315
465
|
}
|
|
316
|
-
|
|
466
|
+
const token = await auth.token({ repoSlug })
|
|
467
|
+
return { token, accountIdentity: `github:${capturedSelfId}` }
|
|
317
468
|
},
|
|
318
469
|
() => selfLogin,
|
|
319
470
|
)
|
|
320
471
|
}
|
|
321
472
|
logger.info(`[github] webhook listening on port ${options.configRef().webhookPort} as @${self.login}`)
|
|
473
|
+
// Attach before any webhook can start a review, and close checks a
|
|
474
|
+
// previous process left in progress.
|
|
475
|
+
await githubReviewChecks.attach({
|
|
476
|
+
publisher: reviewCheckPublisher,
|
|
477
|
+
store: createReviewCheckLeaseStore(options.agentDir),
|
|
478
|
+
logger,
|
|
479
|
+
})
|
|
322
480
|
// Best-effort: App-only preflight that compares the installation's granted
|
|
323
481
|
// permissions against the configured eventAllowlist and warns about gaps.
|
|
324
482
|
// Catches the most common misconfiguration (App installed with the default
|
|
325
483
|
// metadata-only permission set) before any event fires a 403.
|
|
326
|
-
await runAppPermissionPreflight(
|
|
484
|
+
await runAppPermissionPreflight(
|
|
485
|
+
logger,
|
|
486
|
+
auth,
|
|
487
|
+
options.configRef().eventAllowlist,
|
|
488
|
+
options.configRef().repos ?? [],
|
|
489
|
+
options.configRef().review.check,
|
|
490
|
+
)
|
|
327
491
|
// Repository webhook registration is best-effort: failures are logged
|
|
328
492
|
// per-repo, the adapter stays up. A misconfigured PAT or App that
|
|
329
493
|
// can't manage hooks must not prevent the adapter from accepting
|
|
@@ -381,29 +545,80 @@ export function createGithubAdapter(options: GithubAdapterOptions): GithubAdapte
|
|
|
381
545
|
const loadedReconcileCooldownStore =
|
|
382
546
|
repos.length > 0 ? await loadReconcileCooldownStore(options.agentDir, logger) : null
|
|
383
547
|
reconcileCooldownStore = loadedReconcileCooldownStore
|
|
548
|
+
const bootAt = Date.now()
|
|
549
|
+
// First boot has no marker: only PRs opened from now on qualify, never the backlog.
|
|
550
|
+
const createdSince =
|
|
551
|
+
loadedReconcileCooldownStore !== null ? ((await readGithubLastAlive(options.agentDir)) ?? bootAt) : bootAt
|
|
552
|
+
const markAlive = (): Promise<void> =>
|
|
553
|
+
writeGithubLastAlive(options.agentDir, Date.now()).catch((err: unknown) => {
|
|
554
|
+
logger.warn(`[github] last-alive marker write failed: ${describeError(err)}`)
|
|
555
|
+
})
|
|
556
|
+
if (loadedReconcileCooldownStore !== null) await markAlive()
|
|
384
557
|
// Resolve review.on per call, not from the captured startup cfg: review.on
|
|
385
558
|
// is live-reloadable, so a periodic tick must honor a change to `off`
|
|
386
559
|
// (reconcileOpenPrs short-circuits on `off`) instead of scanning forever.
|
|
387
|
-
const
|
|
560
|
+
const reconcileGeneration = lifecycleGeneration
|
|
561
|
+
const replayId = randomUUID()
|
|
562
|
+
const routeReconcileReplay = async (message: InboundMessage): Promise<RouteReceipt> => {
|
|
563
|
+
const receipt = await routeInbound(message)
|
|
564
|
+
if (receipt.kind === 'accepted' && reconcileGeneration === lifecycleGeneration)
|
|
565
|
+
reconcileReplayedPrs.add(prReplayKey(message.workspace, message.chat))
|
|
566
|
+
return receipt
|
|
567
|
+
}
|
|
568
|
+
const runReconcile = (store: ReconcileCooldownStore, includeHeldReviews: boolean): Promise<unknown> =>
|
|
388
569
|
reconcileOpenPrs({
|
|
570
|
+
includeHeldReviews,
|
|
389
571
|
repos,
|
|
390
572
|
reviewOn: options.configRef().review.on,
|
|
391
573
|
selfLogin,
|
|
392
574
|
authType: options.secrets.auth.type,
|
|
393
575
|
token: authToken,
|
|
394
|
-
route:
|
|
576
|
+
route: routeReconcileReplay,
|
|
395
577
|
logger,
|
|
396
578
|
isBotInTeam,
|
|
397
579
|
fetchImpl,
|
|
398
580
|
cooldownStore: store,
|
|
581
|
+
pendingStore: loadedPendingReviewStore,
|
|
582
|
+
createdSince,
|
|
583
|
+
isCancelled: () => reconcileGeneration !== lifecycleGeneration,
|
|
399
584
|
}).catch((err: unknown) => {
|
|
400
585
|
logger.warn(`[github] reconcile pass failed: ${describeError(err)}`)
|
|
401
586
|
})
|
|
587
|
+
if (loadedReconcileCooldownStore === null) firstReconcilePending = false
|
|
402
588
|
if (loadedReconcileCooldownStore !== null) {
|
|
403
|
-
|
|
589
|
+
// Detached on purpose: the pass awaits each replay's router receipt, and
|
|
590
|
+
// routing can depend on boot progress that itself waits for this start()
|
|
591
|
+
// to resolve. Awaiting it here stalled boot before tunnels started, so
|
|
592
|
+
// webhooks never registered and no PR was reviewed.
|
|
593
|
+
// Only the boot pass re-checks held CHANGES_REQUESTED reviews: a restart
|
|
594
|
+
// is what kills an in-flight push follow-up, and a periodic tick could
|
|
595
|
+
// race a live one.
|
|
596
|
+
void replayPendingReviews({
|
|
597
|
+
repos,
|
|
598
|
+
reviewOn: options.configRef().review.on,
|
|
599
|
+
selfLogin,
|
|
600
|
+
authType: options.secrets.auth.type,
|
|
601
|
+
token: authToken,
|
|
602
|
+
route: routeReconcileReplay,
|
|
603
|
+
logger,
|
|
604
|
+
fetchImpl,
|
|
605
|
+
pendingStore: loadedPendingReviewStore,
|
|
606
|
+
replayId,
|
|
607
|
+
isCancelled: () => reconcileGeneration !== lifecycleGeneration,
|
|
608
|
+
})
|
|
609
|
+
.catch((error: unknown) => {
|
|
610
|
+
logger.warn(`[github] pending review replay failed: ${describeError(error)}`)
|
|
611
|
+
})
|
|
612
|
+
.then(() => runReconcile(loadedReconcileCooldownStore, true))
|
|
613
|
+
.finally(() => {
|
|
614
|
+
if (reconcileGeneration === lifecycleGeneration) firstReconcilePending = false
|
|
615
|
+
})
|
|
404
616
|
const reconcileIntervalMs = options.reconcileIntervalMs ?? DEFAULT_RECONCILE_INTERVAL_MS
|
|
405
617
|
if (reconcileIntervalMs > 0) {
|
|
406
|
-
reconcileTimer = setIntervalFn(() =>
|
|
618
|
+
reconcileTimer = setIntervalFn(() => {
|
|
619
|
+
void markAlive()
|
|
620
|
+
void runReconcile(loadedReconcileCooldownStore, false)
|
|
621
|
+
}, reconcileIntervalMs)
|
|
407
622
|
}
|
|
408
623
|
}
|
|
409
624
|
// Periodically recover inbound deliveries that failed at the tunnel and
|
|
@@ -438,6 +653,9 @@ export function createGithubAdapter(options: GithubAdapterOptions): GithubAdapte
|
|
|
438
653
|
async stop(): Promise<void> {
|
|
439
654
|
if (!started) return
|
|
440
655
|
started = false
|
|
656
|
+
lifecycleGeneration += 1
|
|
657
|
+
stopObservingDismissals?.()
|
|
658
|
+
stopObservingDismissals = null
|
|
441
659
|
// Stop the recovery sweep first: its async work outlives the synchronous
|
|
442
660
|
// unregister calls below, and a tick landing mid-teardown would query a
|
|
443
661
|
// hook we're about to deregister and could route during shutdown.
|
|
@@ -449,11 +667,19 @@ export function createGithubAdapter(options: GithubAdapterOptions): GithubAdapte
|
|
|
449
667
|
reconcileTimer.clear()
|
|
450
668
|
reconcileTimer = null
|
|
451
669
|
}
|
|
670
|
+
if (reconcileCooldownStore !== null)
|
|
671
|
+
await writeGithubLastAlive(options.agentDir, Date.now()).catch((err: unknown) => {
|
|
672
|
+
logger.warn(`[github] last-alive marker write failed: ${describeError(err)}`)
|
|
673
|
+
})
|
|
674
|
+
githubReviewChecks.detach(reviewCheckPublisher)
|
|
452
675
|
options.router.unregisterOutbound('github', outbound)
|
|
453
676
|
options.router.unregisterReaction('github', reaction)
|
|
454
677
|
options.router.unregisterRemoveReaction('github', removeReaction)
|
|
678
|
+
options.router.unregisterPrepareOwnReaction('github', ownReaction.prepare)
|
|
679
|
+
options.router.unregisterRemoveOwnReaction('github', ownReaction.remove)
|
|
455
680
|
options.router.unregisterTyping('github', typing)
|
|
456
681
|
options.router.unregisterHistory('github', history)
|
|
682
|
+
options.router.unregisterRecoveryAdapter('github', recoveryCallbacks)
|
|
457
683
|
options.router.unregisterMembership('github', membership)
|
|
458
684
|
options.router.unregisterChannelNameResolver('github', channelNameResolver)
|
|
459
685
|
options.router.unregisterSelfIdentity('github', selfIdentityResolver)
|
|
@@ -489,6 +715,7 @@ export function createGithubAdapter(options: GithubAdapterOptions): GithubAdapte
|
|
|
489
715
|
selfId = null
|
|
490
716
|
selfLogin = null
|
|
491
717
|
reconcileCooldownStore = null
|
|
718
|
+
pendingReviewStore = null
|
|
492
719
|
},
|
|
493
720
|
isConnected(): boolean {
|
|
494
721
|
return started && selfLogin !== null
|
|
@@ -578,6 +805,7 @@ async function runAppPermissionPreflight(
|
|
|
578
805
|
auth: ReturnType<typeof buildAuthStrategy>,
|
|
579
806
|
eventAllowlist: readonly string[],
|
|
580
807
|
repos: readonly string[],
|
|
808
|
+
reviewCheck: boolean,
|
|
581
809
|
): Promise<void> {
|
|
582
810
|
if (auth.getInstallationGrants === undefined) return
|
|
583
811
|
const getGrants = (context: GithubAuthContext | undefined) => auth.getInstallationGrants?.(context)
|
|
@@ -604,6 +832,13 @@ async function runAppPermissionPreflight(
|
|
|
604
832
|
if (grants === undefined) continue
|
|
605
833
|
const gaps = findPermissionGaps(eventAllowlist, grants.permissions)
|
|
606
834
|
if (gaps.length > 0) logger.warn(buildAppPermissionPreflightGuidance(gaps))
|
|
835
|
+
const checks = grants.permissions.checks
|
|
836
|
+
if (reviewCheck && checks !== 'write' && checks !== 'admin') {
|
|
837
|
+
logger.warn(
|
|
838
|
+
`[github] review check will be skipped for ${label}: the GitHub App lacks "Checks: Read and write". ` +
|
|
839
|
+
'Grant it in the App settings to show reviews as a PR check, or set channels.github.review.check to false.',
|
|
840
|
+
)
|
|
841
|
+
}
|
|
607
842
|
}
|
|
608
843
|
}
|
|
609
844
|
|
|
@@ -621,3 +856,16 @@ function logDeregistrationOutcome(
|
|
|
621
856
|
function defaultSleep(ms: number): Promise<void> {
|
|
622
857
|
return new Promise((resolve) => setTimeout(resolve, ms))
|
|
623
858
|
}
|
|
859
|
+
|
|
860
|
+
const REVIEW_TRIGGER_EVENT_KINDS: ReadonlySet<string> = new Set([
|
|
861
|
+
'pull_request:opened',
|
|
862
|
+
'pull_request:ready_for_review',
|
|
863
|
+
'pull_request:review_requested',
|
|
864
|
+
'pull_request:synchronize:review-followup',
|
|
865
|
+
'pull_request:reconcile',
|
|
866
|
+
'pull_request:reconcile:rereview',
|
|
867
|
+
])
|
|
868
|
+
|
|
869
|
+
function prReplayKey(workspace: string, chat: string): string {
|
|
870
|
+
return `${canonicalGithubRepo(workspace)}#${chat}`
|
|
871
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { readLastAlive, writeLastAlive } from '../../last-alive'
|
|
2
|
+
|
|
3
|
+
// When the GitHub adapter was last known alive. Reconcile replays only PRs
|
|
4
|
+
// opened since then: those are the deliveries a downtime or tunnel change could
|
|
5
|
+
// have dropped, while anything older was either seen live or predates the repo
|
|
6
|
+
// being watched.
|
|
7
|
+
|
|
8
|
+
export async function readGithubLastAlive(agentDir: string): Promise<number | null> {
|
|
9
|
+
// Preserve GitHub's best-effort boot behavior on an unreadable marker.
|
|
10
|
+
return readLastAlive(agentDir, 'github').catch(() => null)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function writeGithubLastAlive(agentDir: string, at: number): Promise<void> {
|
|
14
|
+
return writeLastAlive(agentDir, 'github', at)
|
|
15
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { OutboundCallback, OutboundMessage, SendResult } from '@/channels/types'
|
|
2
2
|
|
|
3
3
|
import { describeError } from '../../describe-error'
|
|
4
|
+
import { recoveryHttpFailure, recoveryMarker } from '../recovery-correlation'
|
|
4
5
|
import type { GithubAuthContext } from './auth'
|
|
5
6
|
import { GITHUB_API_BASE, githubJsonHeaders } from './auth-pat'
|
|
6
7
|
import {
|
|
@@ -17,12 +18,37 @@ export function createGithubOutboundCallback(deps: {
|
|
|
17
18
|
authType: GithubAuthType
|
|
18
19
|
logger: GithubOutboundLogger
|
|
19
20
|
fetchImpl?: typeof fetch
|
|
21
|
+
accountIdentity?: () => Promise<string | undefined>
|
|
20
22
|
}): OutboundCallback {
|
|
21
23
|
const fetchImpl = deps.fetchImpl ?? fetch
|
|
22
24
|
return async (msg: OutboundMessage): Promise<SendResult> => {
|
|
23
25
|
if (msg.adapter !== 'github') return { ok: false, error: `unknown adapter: ${msg.adapter}` }
|
|
24
26
|
if ((msg.attachments ?? []).length > 0) return { ok: false, error: 'github-bot-does-not-support-attachments' }
|
|
25
|
-
const
|
|
27
|
+
const recovery = msg.sendOptions?.accounting === 'recovery' ? msg.sendOptions : undefined
|
|
28
|
+
if (recovery && (await deps.accountIdentity?.()) !== recovery.expectedAccountIdentity)
|
|
29
|
+
return {
|
|
30
|
+
ok: false,
|
|
31
|
+
error: 'recovery-account-identity-changed',
|
|
32
|
+
recoveryFailure: { kind: 'identity', safeReason: 'Authenticated account changed' },
|
|
33
|
+
}
|
|
34
|
+
const body = (msg.text ?? '') + (recovery ? `\n\n${recoveryMarker(recovery.deliveryId)}` : '')
|
|
35
|
+
let recoveryResponse: Response | undefined
|
|
36
|
+
const transport: typeof fetch = recovery
|
|
37
|
+
? ((async (input, init) => {
|
|
38
|
+
const response = await fetchImpl(input, init)
|
|
39
|
+
recoveryResponse = response
|
|
40
|
+
return response
|
|
41
|
+
}) as typeof fetch)
|
|
42
|
+
: fetchImpl
|
|
43
|
+
const finish = (result: SendResult): SendResult =>
|
|
44
|
+
result.ok || !recovery
|
|
45
|
+
? result
|
|
46
|
+
: {
|
|
47
|
+
...result,
|
|
48
|
+
recoveryFailure: recoveryResponse
|
|
49
|
+
? recoveryHttpFailure(recoveryResponse)
|
|
50
|
+
: { kind: 'transient', safeReason: 'Recovery transport failed' },
|
|
51
|
+
}
|
|
26
52
|
if (body === '') return { ok: false, error: 'message has neither text nor attachments' }
|
|
27
53
|
|
|
28
54
|
const repo = parseRepo(msg.workspace)
|
|
@@ -31,31 +57,41 @@ export function createGithubOutboundCallback(deps: {
|
|
|
31
57
|
if (target === null) return { ok: false, error: `invalid GitHub chat: ${msg.chat}` }
|
|
32
58
|
|
|
33
59
|
const token = () => deps.token({ repoSlug: msg.workspace })
|
|
60
|
+
if (recovery && target.kind !== 'pr' && msg.thread !== undefined && msg.thread !== null)
|
|
61
|
+
return {
|
|
62
|
+
ok: false,
|
|
63
|
+
error: 'invalid-recovery-github-thread',
|
|
64
|
+
recoveryFailure: { kind: 'target', safeReason: 'Unsupported original GitHub target' },
|
|
65
|
+
}
|
|
34
66
|
|
|
35
67
|
if (target.kind === 'discussion') {
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
68
|
+
return finish(
|
|
69
|
+
await postDiscussionComment({
|
|
70
|
+
...deps,
|
|
71
|
+
token,
|
|
72
|
+
fetchImpl: transport,
|
|
73
|
+
repo,
|
|
74
|
+
discussionNumber: target.number,
|
|
75
|
+
body,
|
|
76
|
+
}),
|
|
77
|
+
)
|
|
44
78
|
}
|
|
45
79
|
|
|
46
80
|
const isPrReviewReply = target.kind === 'pr' && msg.thread !== null && msg.thread !== undefined && msg.thread !== ''
|
|
47
81
|
const endpoint = isPrReviewReply
|
|
48
82
|
? `${GITHUB_API_BASE}/repos/${repo.owner}/${repo.name}/pulls/${target.number}/comments/${encodeURIComponent(msg.thread ?? '')}/replies`
|
|
49
83
|
: `${GITHUB_API_BASE}/repos/${repo.owner}/${repo.name}/issues/${target.number}/comments`
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
84
|
+
return finish(
|
|
85
|
+
await postJson(
|
|
86
|
+
transport,
|
|
87
|
+
await token(),
|
|
88
|
+
endpoint,
|
|
89
|
+
{ body },
|
|
90
|
+
{
|
|
91
|
+
authType: deps.authType,
|
|
92
|
+
endpointKind: isPrReviewReply ? 'pr-review-reply' : 'issue-comment',
|
|
93
|
+
},
|
|
94
|
+
),
|
|
59
95
|
)
|
|
60
96
|
}
|
|
61
97
|
}
|