Auto-retry ratelimited octokit requests

This commit is contained in:
Mateusz Burzyński
2026-01-07 17:10:13 +01:00
parent 0504fc42ff
commit a483711fee
9 changed files with 3759 additions and 2172 deletions
+4 -6
View File
@@ -1,11 +1,10 @@
import { Octokit } from "@octokit/rest";
import { type } from "arktype";
import type { Payload } from "../external.ts";
import { agentsManifest } from "../external.ts";
import type { ToolContext } from "../main.ts";
import { fetchWorkflowRunInfo } from "../utils/api.ts";
import { buildPullfrogFooter, stripExistingFooter } from "../utils/buildPullfrogFooter.ts";
import { getGitHubInstallationToken, parseRepoContext } from "../utils/github.ts";
import { createOctokit, getGitHubInstallationToken, parseRepoContext, type OctokitWithPlugins } from "../utils/github.ts";
import { execute, tool } from "./shared.ts";
/**
@@ -17,7 +16,7 @@ export const LEAPING_INTO_ACTION_PREFIX = "Leaping into action";
interface BuildCommentFooterParams {
payload: Payload;
octokit?: Octokit | undefined;
octokit?: OctokitWithPlugins | undefined;
customParts?: string[] | undefined;
}
@@ -80,7 +79,7 @@ function buildImplementPlanLink(
return `[Implement plan ➔](${apiUrl}/trigger/${owner}/${repo}/${issueNumber}?action=implement&comment_id=${commentId})`;
}
async function addFooter(body: string, payload: Payload, octokit?: Octokit): Promise<string> {
async function addFooter(body: string, payload: Payload, octokit?: OctokitWithPlugins): Promise<string> {
const bodyWithoutFooter = stripExistingFooter(body);
const footer = await buildCommentFooter({ payload, octokit });
return `${bodyWithoutFooter}${footer}`;
@@ -408,8 +407,7 @@ export async function ensureProgressCommentUpdated(payload?: Payload): Promise<v
// check if comment still says "leaping into action" - if it's been updated with an error, don't overwrite it
const repoContext = parseRepoContext();
const token = getGitHubInstallationToken();
const octokit = new Octokit({ auth: token });
const octokit = createOctokit(getGitHubInstallationToken());
try {
const existingComment = await octokit.rest.issues.getComment({