migrate to report_progress
This commit is contained in:
@@ -94,14 +94,6 @@ const messageHandlers = {
|
||||
},
|
||||
tool_use: (event: GeminiToolUseEvent) => {
|
||||
if (event.tool_name) {
|
||||
// log intent for create_working_comment
|
||||
if (event.tool_name === "create_working_comment" && event.parameters) {
|
||||
const params = event.parameters as { intent?: string; [key: string]: unknown };
|
||||
if (params.intent) {
|
||||
log.box(params.intent.trim(), { title: "Intent" });
|
||||
}
|
||||
}
|
||||
|
||||
log.toolCall({
|
||||
toolName: event.tool_name,
|
||||
input: event.parameters || {},
|
||||
|
||||
+6
-5
@@ -47,10 +47,11 @@ export const AgentName = type.enumerated(...Object.keys(agentsManifest));
|
||||
export type AgentApiKeyName = (typeof agentsManifest)[AgentName]["apiKeyNames"][number];
|
||||
|
||||
// discriminated union for payload event based on trigger
|
||||
// note: all events use issue_number for consistency (PRs are issues in GitHub's API)
|
||||
export type PayloadEvent =
|
||||
| {
|
||||
trigger: "pull_request_opened";
|
||||
pr_number: number;
|
||||
issue_number: number;
|
||||
pr_title: string;
|
||||
pr_body: string | null;
|
||||
branch: string;
|
||||
@@ -58,7 +59,7 @@ export type PayloadEvent =
|
||||
}
|
||||
| {
|
||||
trigger: "pull_request_review_requested";
|
||||
pr_number: number;
|
||||
issue_number: number;
|
||||
pr_title: string;
|
||||
pr_body: string | null;
|
||||
branch: string;
|
||||
@@ -66,7 +67,7 @@ export type PayloadEvent =
|
||||
}
|
||||
| {
|
||||
trigger: "pull_request_review_submitted";
|
||||
pr_number: number;
|
||||
issue_number: number;
|
||||
review_id: number;
|
||||
review_body: string | null;
|
||||
review_state: string;
|
||||
@@ -77,7 +78,7 @@ export type PayloadEvent =
|
||||
}
|
||||
| {
|
||||
trigger: "pull_request_review_comment_created";
|
||||
pr_number: number;
|
||||
issue_number: number;
|
||||
pr_title: string;
|
||||
comment_id: number;
|
||||
comment_body: string;
|
||||
@@ -116,7 +117,7 @@ export type PayloadEvent =
|
||||
}
|
||||
| {
|
||||
trigger: "check_suite_completed";
|
||||
pr_number: number;
|
||||
issue_number: number;
|
||||
pr_title: string;
|
||||
pr_body: string | null;
|
||||
pull_request: any;
|
||||
|
||||
@@ -12,7 +12,7 @@ import { createMcpConfigs } from "./mcp/config.ts";
|
||||
import { startMcpHttpServer } from "./mcp/server.ts";
|
||||
import { modes } from "./modes.ts";
|
||||
import packageJson from "./package.json" with { type: "json" };
|
||||
import { fetchRepoSettings } from "./utils/api.ts";
|
||||
import { fetchRepoSettings, fetchWorkflowRunInfo } from "./utils/api.ts";
|
||||
import { log } from "./utils/cli.ts";
|
||||
import {
|
||||
parseRepoContext,
|
||||
@@ -271,7 +271,7 @@ function parsePayload(inputs: Inputs): Payload {
|
||||
}
|
||||
|
||||
async function startMcpServer(ctx: MainContext): Promise<void> {
|
||||
// Set environment variables for MCP server tools
|
||||
// set environment variables for MCP server tools
|
||||
const repoContext = parseRepoContext();
|
||||
const githubRepository = `${repoContext.owner}/${repoContext.name}`;
|
||||
const allModes = [...modes, ...(ctx.payload.modes || [])];
|
||||
@@ -282,6 +282,18 @@ async function startMcpServer(ctx: MainContext): Promise<void> {
|
||||
|
||||
// GITHUB_RUN_ID is already set in GitHub Actions, no need to set it here
|
||||
|
||||
// fetch the pre-created progress comment ID from the database
|
||||
// this must be set BEFORE starting the MCP server so comment.ts can read it
|
||||
const runId = process.env.GITHUB_RUN_ID;
|
||||
if (runId) {
|
||||
const workflowRunInfo = await fetchWorkflowRunInfo(runId);
|
||||
if (workflowRunInfo.progressCommentId) {
|
||||
process.env.PULLFROG_PROGRESS_COMMENT_ID = workflowRunInfo.progressCommentId;
|
||||
log.info(`📝 Using pre-created progress comment: ${workflowRunInfo.progressCommentId}`);
|
||||
}
|
||||
}
|
||||
|
||||
// start MCP server after env vars are set (comment.ts reads PULLFROG_PROGRESS_COMMENT_ID at import time)
|
||||
const { url, close } = await startMcpHttpServer();
|
||||
ctx.mcpServerUrl = url;
|
||||
ctx.mcpServerClose = close;
|
||||
|
||||
+74
-52
@@ -15,16 +15,16 @@ function buildCommentFooter(payload: Payload): string {
|
||||
const agentDisplayName = agentInfo?.displayName || "Unknown Agent";
|
||||
const agentUrl = agentInfo?.url || "https://pullfrog.ai";
|
||||
|
||||
// build workflow run URL: https://github.com/{owner}/{repo}/actions/runs/{runId}
|
||||
const workflowRunUrl = runId
|
||||
? `https://github.com/${repoContext.owner}/${repoContext.name}/actions/runs/${runId}`
|
||||
: `https://github.com/${repoContext.owner}/${repoContext.name}`;
|
||||
// build workflow run link or show unavailable message
|
||||
const workflowRunPart = runId
|
||||
? `[View workflow run](https://github.com/${repoContext.owner}/${repoContext.name}/actions/runs/${runId})`
|
||||
: "(workflow link unavailable)";
|
||||
|
||||
return `
|
||||
${PULLFROG_DIVIDER}
|
||||
---
|
||||
|
||||
<sup>🐸 Triggered by [Pullfrog](https://pullfrog.ai) | 🤖 [${agentDisplayName}](${agentUrl}) | [View workflow run](${workflowRunUrl}) | [𝕏](https://x.com/pullfrogai)</sup>`;
|
||||
<sup>🐸 Triggered by [Pullfrog](https://pullfrog.ai) | 🤖 [${agentDisplayName}](${agentUrl}) | ${workflowRunPart} | [𝕏](https://x.com/pullfrogai)</sup>`;
|
||||
}
|
||||
|
||||
function stripExistingFooter(body: string): string {
|
||||
@@ -98,27 +98,78 @@ export const EditCommentTool = tool({
|
||||
}),
|
||||
});
|
||||
|
||||
let workingCommentId: number | null = null;
|
||||
/**
|
||||
* Get progress comment ID from environment variable.
|
||||
* This allows the webhook handler to pre-create a "leaping into action" comment
|
||||
* and pass the ID to the action for updates.
|
||||
*/
|
||||
function getProgressCommentIdFromEnv(): number | null {
|
||||
const envCommentId = process.env.PULLFROG_PROGRESS_COMMENT_ID;
|
||||
if (envCommentId) {
|
||||
const parsed = parseInt(envCommentId, 10);
|
||||
if (!Number.isNaN(parsed)) {
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export const WorkingComment = type({
|
||||
issueNumber: type.number.describe("the issue number to comment on"),
|
||||
intent: type("/^I'll .+$/").describe(
|
||||
"the body of the initial comment expressing your intent to handle the request. must have the form 'I'll {summary of request}'"
|
||||
),
|
||||
// module-level variable to track the progress comment ID
|
||||
// initialized lazily on first use to allow env var to be set after module load
|
||||
let progressCommentId: number | null = null;
|
||||
let progressCommentIdInitialized = false;
|
||||
|
||||
function getProgressCommentId(): number | null {
|
||||
if (!progressCommentIdInitialized) {
|
||||
progressCommentId = getProgressCommentIdFromEnv();
|
||||
progressCommentIdInitialized = true;
|
||||
}
|
||||
return progressCommentId;
|
||||
}
|
||||
|
||||
function setProgressCommentId(id: number): void {
|
||||
progressCommentId = id;
|
||||
progressCommentIdInitialized = true;
|
||||
}
|
||||
|
||||
export const ReportProgress = type({
|
||||
body: type.string.describe("the progress update content to share"),
|
||||
});
|
||||
|
||||
export const CreateWorkingCommentTool = tool({
|
||||
name: "create_working_comment",
|
||||
export const ReportProgressTool = tool({
|
||||
name: "report_progress",
|
||||
description:
|
||||
"Create an initial comment on a GitHub issue that will be updated as work progresses",
|
||||
parameters: WorkingComment,
|
||||
execute: contextualize(async ({ issueNumber, intent }, ctx) => {
|
||||
if (workingCommentId) {
|
||||
throw new Error("create_working_comment may not be called multiple times");
|
||||
"Share progress on the associated GitHub issue/PR. Call this to post updates as you work. The first call creates a comment, subsequent calls update it. Use this throughout your work to keep stakeholders informed.",
|
||||
parameters: ReportProgress,
|
||||
execute: contextualize(async ({ body }, ctx) => {
|
||||
const bodyWithFooter = addFooter(body, ctx.payload);
|
||||
const existingCommentId = getProgressCommentId();
|
||||
|
||||
// if we already have a progress comment, update it
|
||||
if (existingCommentId) {
|
||||
const result = await ctx.octokit.rest.issues.updateComment({
|
||||
owner: ctx.owner,
|
||||
repo: ctx.name,
|
||||
comment_id: existingCommentId,
|
||||
body: bodyWithFooter,
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
commentId: result.data.id,
|
||||
url: result.data.html_url,
|
||||
body: result.data.body,
|
||||
action: "updated",
|
||||
};
|
||||
}
|
||||
|
||||
const body = `${intent} <img src="https://pullfrog.ai/party-parrot.gif" width="14px" height="14px" style="vertical-align: middle; margin-left: 4px;" />`;
|
||||
const bodyWithFooter = addFooter(body, ctx.payload);
|
||||
// no existing comment - create one
|
||||
const issueNumber = ctx.payload.event.issue_number;
|
||||
if (issueNumber === undefined) {
|
||||
throw new Error(
|
||||
"cannot create progress comment: no issue_number found in the payload event"
|
||||
);
|
||||
}
|
||||
|
||||
const result = await ctx.octokit.rest.issues.createComment({
|
||||
owner: ctx.owner,
|
||||
@@ -127,44 +178,15 @@ export const CreateWorkingCommentTool = tool({
|
||||
body: bodyWithFooter,
|
||||
});
|
||||
|
||||
workingCommentId = result.data.id;
|
||||
|
||||
return {
|
||||
success: true,
|
||||
commentId: result.data.id,
|
||||
url: result.data.html_url,
|
||||
body: result.data.body,
|
||||
};
|
||||
}),
|
||||
});
|
||||
|
||||
export const WorkingCommentUpdate = type({
|
||||
body: type.string.describe("the new comment body content"),
|
||||
});
|
||||
|
||||
export const UpdateWorkingCommentTool = tool({
|
||||
name: "update_working_comment",
|
||||
description: "Update a working comment on a GitHub issue",
|
||||
parameters: WorkingCommentUpdate,
|
||||
execute: contextualize(async ({ body }, ctx) => {
|
||||
if (!workingCommentId) {
|
||||
throw new Error("create_working_comment must be called before update_working_comment");
|
||||
}
|
||||
|
||||
const bodyWithFooter = addFooter(body, ctx.payload);
|
||||
|
||||
const result = await ctx.octokit.rest.issues.updateComment({
|
||||
owner: ctx.owner,
|
||||
repo: ctx.name,
|
||||
comment_id: workingCommentId,
|
||||
body: bodyWithFooter,
|
||||
});
|
||||
// store the comment ID for future updates
|
||||
setProgressCommentId(result.data.id);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
commentId: result.data.id,
|
||||
url: result.data.html_url,
|
||||
body: result.data.body,
|
||||
action: "created",
|
||||
};
|
||||
}),
|
||||
});
|
||||
|
||||
+2
-4
@@ -6,10 +6,9 @@ import { ghPullfrogMcpName } from "../external.ts";
|
||||
import { GetCheckSuiteLogsTool } from "./checkSuite.ts";
|
||||
import {
|
||||
CreateCommentTool,
|
||||
CreateWorkingCommentTool,
|
||||
EditCommentTool,
|
||||
ReplyToReviewCommentTool,
|
||||
UpdateWorkingCommentTool,
|
||||
ReportProgressTool,
|
||||
} from "./comment.ts";
|
||||
import { DebugShellCommandTool } from "./debug.ts";
|
||||
import { IssueTool } from "./issue.ts";
|
||||
@@ -63,10 +62,9 @@ export async function startMcpHttpServer(): Promise<{ url: string; close: () =>
|
||||
|
||||
addTools(server, [
|
||||
SelectModeTool,
|
||||
ReportProgressTool,
|
||||
CreateCommentTool,
|
||||
EditCommentTool,
|
||||
CreateWorkingCommentTool,
|
||||
UpdateWorkingCommentTool,
|
||||
ReplyToReviewCommentTool,
|
||||
IssueTool,
|
||||
IssueInfoTool,
|
||||
|
||||
@@ -6,7 +6,7 @@ export interface Mode {
|
||||
prompt: string;
|
||||
}
|
||||
|
||||
const initialCommentInstruction = `When the task is associated with an issue/PR, use ${ghPullfrogMcpName}/create_working_comment to create an initial Working Comment with a conversational description of what work you are about to perform.`;
|
||||
const reportProgressInstruction = `Use ${ghPullfrogMcpName}/report_progress to share progress and results. Continue calling it as you make progress - it will update the same comment. Never create additional comments manually.`;
|
||||
|
||||
export const modes: Mode[] = [
|
||||
{
|
||||
@@ -14,25 +14,21 @@ export const modes: Mode[] = [
|
||||
description:
|
||||
"Implement, build, create, or develop code changes; make specific changes to files or features; execute a plan; or handle tasks with specific implementation details",
|
||||
prompt: `Follow these steps:
|
||||
1. ${initialCommentInstruction}
|
||||
1. If the request requires understanding the codebase structure, dependencies, or conventions, gather relevant context. Read AGENTS.md if it exists, understand how to install dependencies, run tests, run builds, and make changes according to best practices). Skip this step if the prompt is trivial and self-contained.
|
||||
|
||||
2. If the request requires understanding the codebase structure, dependencies, or conventions, gather relevant context. Read AGENTS.md if it exists, understand how to install dependencies, run tests, run builds, and make changes according to best practices). Skip this step if the prompt is trivial and self-contained.
|
||||
2. Create a branch for your work. The branch name should be prefixed with "pullfrog/". The rest of the name should reflect the exact changes you are making. It should be specific to avoid collisions with other branches. Never commit to directly to main, master, or production.
|
||||
|
||||
3. Create a branch for your work. The branch name should be prefixed with "pullfrog/". The rest of the name should reflect the exact changes you are making. It should be specific to avoid collisions with other branches. Never commit to directly to main, master, or production.
|
||||
3. Understand the requirements and any existing plan
|
||||
|
||||
4. Understand the requirements and any existing plan
|
||||
4. Make the necessary code changes. Create intermediate commits if called for.
|
||||
|
||||
5. Make the necessary code changes. Create intermediate commits if called for.
|
||||
5. Test your changes to ensure they work correctly
|
||||
|
||||
6. Test your changes to ensure they work correctly
|
||||
6. ${reportProgressInstruction}
|
||||
|
||||
7. Update your comment using ${ghPullfrogMcpName}/update_working_comment to share progress and results.
|
||||
7. When you are done, create a final commit. If relevant, indicate which issue the PR addresses somewhere in the commit message (e.g. "Fixes #123"). Create a PR with an informative title and body. If relevant, include links to the issue or comment that triggered the PR.
|
||||
|
||||
8. Continue updating the same comment as you make progress. Never create additional comments. Always use update_working_comment.
|
||||
|
||||
9. When you are done, create a final commit. If relevant, indicate which issue the PR addresses somewhere in the commit message (e.g. "Fixes #123"). Create a PR with an informative title and body. If relevant, include links to the issue or comment that triggered the PR.
|
||||
|
||||
10. Update the Working Comment one final time with a summary of the results. Include links to any created issues/PRs, e.g. \`[View PR](https://github.com/org/repo/pull/123)\`
|
||||
8. Call report_progress one final time with a summary of the results. Include links to any created issues/PRs, e.g. \`[View PR](https://github.com/org/repo/pull/123)\`
|
||||
`,
|
||||
},
|
||||
{
|
||||
@@ -40,25 +36,23 @@ export const modes: Mode[] = [
|
||||
description:
|
||||
"Address PR review feedback; respond to reviewer comments; make requested changes to an existing PR",
|
||||
prompt: `Follow these steps:
|
||||
1. ${initialCommentInstruction}
|
||||
1. Get PR info with ${ghPullfrogMcpName}/get_pull_request (this automatically fetches and checks out the PR branch)
|
||||
|
||||
2. Get PR info with ${ghPullfrogMcpName}/get_pull_request (this automatically fetches and checks out the PR branch)
|
||||
2. Review the feedback provided. Understand each review comment and what changes are being requested.
|
||||
|
||||
3. Review the feedback provided. Understand each review comment and what changes are being requested.
|
||||
3. If the request requires understanding the codebase structure, dependencies, or conventions, gather relevant context. Read AGENTS.md if it exists.
|
||||
|
||||
4. If the request requires understanding the codebase structure, dependencies, or conventions, gather relevant context. Read AGENTS.md if it exists.
|
||||
4. Make the necessary code changes to address the feedback. Work through each review comment systematically.
|
||||
|
||||
5. Make the necessary code changes to address the feedback. Work through each review comment systematically.
|
||||
5. After addressing each review comment, use ${ghPullfrogMcpName}/reply_to_review_comment to reply directly to that comment thread explaining what change was made (keep replies concise, 1-2 sentences).
|
||||
|
||||
6. After addressing each review comment, use ${ghPullfrogMcpName}/reply_to_review_comment to reply directly to that comment thread explaining what change was made (keep replies concise, 1-2 sentences).
|
||||
6. Test your changes to ensure they work correctly.
|
||||
|
||||
7. Test your changes to ensure they work correctly.
|
||||
7. ${reportProgressInstruction}
|
||||
|
||||
8. Update your working comment using ${ghPullfrogMcpName}/update_working_comment to share overall progress.
|
||||
8. When done, commit and push your changes to the existing PR branch. Do not create a new branch or PR - you are updating an existing one.
|
||||
|
||||
9. When done, commit and push your changes to the existing PR branch. Do not create a new branch or PR - you are updating an existing one.
|
||||
|
||||
10. Update the Working Comment one final time with a summary of all changes made.
|
||||
9. Call report_progress one final time with a summary of all changes made.
|
||||
`,
|
||||
},
|
||||
{
|
||||
@@ -66,58 +60,48 @@ export const modes: Mode[] = [
|
||||
description:
|
||||
"Review code, PRs, or implementations; provide feedback or suggestions; identify issues; or check code quality, style, and correctness",
|
||||
prompt: `Follow these steps:
|
||||
1. ${initialCommentInstruction}
|
||||
1. Get PR info with ${ghPullfrogMcpName}/get_pull_request (this automatically prepares the repository by fetching and checking out the PR branch)
|
||||
|
||||
2. Get PR info with ${ghPullfrogMcpName}/get_pull_request (this automatically prepares the repository by fetching and checking out the PR branch)
|
||||
2. View diff: git diff origin/<base>...origin/<head> (use line numbers from this for inline comments, replace <base> and <head> with 'base' and 'head' from PR info)
|
||||
|
||||
3. View diff: git diff origin/<base>...origin/<head> (use line numbers from this for inline comments, replace <base> and <head> with 'base' and 'head' from PR info)
|
||||
3. Read files from the checked-out PR branch to understand the implementation
|
||||
|
||||
4. Read files from the checked-out PR branch to understand the implementation
|
||||
4. ${reportProgressInstruction}
|
||||
|
||||
5. Update your comment using ${ghPullfrogMcpName}/update_working_comment with findings as you review
|
||||
5. When submitting review: use the 'comments' array for ALL specific code issues - include the file path and line position from the diff
|
||||
|
||||
6. When submitting review: use the 'comments' array for ALL specific code issues - include the file path and line position from the diff
|
||||
|
||||
7. Only use the 'body' field for a brief summary (1-2 sentences) or for feedback that doesn't apply to a specific code location
|
||||
|
||||
8. Continue updating the same comment as needed (never create additional comments - always use update_working_comment)`,
|
||||
6. Only use the 'body' field for a brief summary (1-2 sentences) or for feedback that doesn't apply to a specific code location`,
|
||||
},
|
||||
{
|
||||
name: "Plan",
|
||||
description:
|
||||
"Create plans, break down tasks, outline steps, analyze requirements, understand scope of work, or provide task breakdowns",
|
||||
prompt: `Follow these steps:
|
||||
1. ${initialCommentInstruction}
|
||||
1. If the request requires understanding the codebase structure, dependencies, or conventions, gather relevant context (read AGENTS.md if it exists, understand how to install dependencies, run tests, run builds, and make changes according to best practices). Skip this step if the prompt is trivial and self-contained.
|
||||
|
||||
2. If the request requires understanding the codebase structure, dependencies, or conventions, gather relevant context (read AGENTS.md if it exists, understand how to install dependencies, run tests, run builds, and make changes according to best practices). Skip this step if the prompt is trivial and self-contained.
|
||||
2. Analyze the request and break it down into clear, actionable tasks
|
||||
|
||||
3. Analyze the request and break it down into clear, actionable tasks
|
||||
3. Consider dependencies, potential challenges, and implementation order
|
||||
|
||||
4. Consider dependencies, potential challenges, and implementation order
|
||||
4. Create a structured plan with clear milestones
|
||||
|
||||
5. Create a structured plan with clear milestones
|
||||
|
||||
6. Update your comment using ${ghPullfrogMcpName}/update_working_comment to present the plan in a clear, organized format
|
||||
|
||||
7. Continue updating the same comment as needed (never create additional comments - always use update_working_comment)`,
|
||||
5. ${reportProgressInstruction}`,
|
||||
},
|
||||
{
|
||||
name: "Prompt",
|
||||
description:
|
||||
"Fallback for tasks that don't fit other workflows, direct prompts via comments, or requests requiring general assistance without a specific workflow pattern",
|
||||
prompt: `Follow these steps:
|
||||
1. ${initialCommentInstruction}
|
||||
1. Perform the requested task. Only take action if you have high confidence that you understand what is being asked. If you are not sure, ask for clarification. Take stock of the tools at your disposal.
|
||||
|
||||
2. Perform the requested task. Only take action if you have high confidence that you understand what is being asked. If you are not sure, ask for clarification. Take stock of the tools at your disposal.
|
||||
|
||||
3. If the task involves making code changes:
|
||||
2. If the task involves making code changes:
|
||||
- Create a branch for your work. The branch name should be prefixed with "pullfrog/". The rest of the name should reflect the exact changes you are making. It should be specific to avoid collisions with other branches. Never commit to directly to main, master, or production.
|
||||
- Make the necessary code changes. Create intermediate commits if called for.
|
||||
- Test your changes to ensure they work correctly.
|
||||
- When you are done, create a final commit. If relevant, indicate which issue the PR addresses somewhere in the commit message (e.g. "Fixes #123"). Create a PR with an informative title and body. If relevant, include links to the issue or comment that triggered the PR.
|
||||
|
||||
4. As your work progresses, update your Working Comment to share progress and results using ${ghPullfrogMcpName}/update_working_comment. Do not create additional comments unless you are explicitly asked to do so.
|
||||
3. ${reportProgressInstruction}
|
||||
|
||||
5. When you finish the task, update the Working Comment a final time with a summary of the results and links to any created issues, PRs, etc.`,
|
||||
4. Call report_progress one final time with a summary of the results and links to any created issues, PRs, etc.`,
|
||||
},
|
||||
];
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pullfrog/action",
|
||||
"version": "0.0.113",
|
||||
"version": "0.0.114",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"index.js",
|
||||
|
||||
@@ -24,6 +24,46 @@ export const DEFAULT_REPO_SETTINGS: RepoSettings = {
|
||||
modes: [],
|
||||
};
|
||||
|
||||
export interface WorkflowRunInfo {
|
||||
progressCommentId: string | null;
|
||||
issueNumber: number | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch workflow run info from the Pullfrog API
|
||||
* Returns the pre-created progress comment ID if one exists
|
||||
*/
|
||||
export async function fetchWorkflowRunInfo(runId: string): Promise<WorkflowRunInfo> {
|
||||
const apiUrl = process.env.API_URL || "https://pullfrog.ai";
|
||||
|
||||
// add timeout to prevent hanging (5 seconds)
|
||||
const timeoutMs = 5000;
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
||||
|
||||
try {
|
||||
const response = await fetch(`${apiUrl}/api/workflow-run/${runId}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
signal: controller.signal,
|
||||
});
|
||||
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
if (!response.ok) {
|
||||
return { progressCommentId: null, issueNumber: null };
|
||||
}
|
||||
|
||||
const data = (await response.json()) as WorkflowRunInfo;
|
||||
return data;
|
||||
} catch {
|
||||
clearTimeout(timeoutId);
|
||||
return { progressCommentId: null, issueNumber: null };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch repository settings from the Pullfrog API
|
||||
* Returns defaults if repo doesn't exist or fetch fails
|
||||
|
||||
Reference in New Issue
Block a user