Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| df72988aab | |||
| 6ce1d9773c | |||
| 07a2ec3ab2 | |||
| b14bab5ed2 |
+76
-56
@@ -83,58 +83,6 @@ type CursorEvent =
|
|||||||
| CursorToolCallEvent
|
| CursorToolCallEvent
|
||||||
| CursorResultEvent;
|
| CursorResultEvent;
|
||||||
|
|
||||||
const messageHandlers = {
|
|
||||||
system: (_event: CursorSystemEvent) => {
|
|
||||||
// system init events - no logging needed
|
|
||||||
},
|
|
||||||
user: (_event: CursorUserEvent) => {
|
|
||||||
// user messages already logged in prompt box
|
|
||||||
},
|
|
||||||
thinking: (_event: CursorThinkingEvent) => {
|
|
||||||
// thinking events are internal - no logging needed
|
|
||||||
},
|
|
||||||
assistant: (event: CursorAssistantEvent) => {
|
|
||||||
// only log finalized messages (ones with model_call_id)
|
|
||||||
// cursor emits each message twice: once without model_call_id, then again with it
|
|
||||||
if (event.model_call_id) {
|
|
||||||
const text = event.message?.content?.[0]?.text;
|
|
||||||
if (text?.trim()) {
|
|
||||||
log.box(text.trim(), { title: "Cursor" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tool_call: (event: CursorToolCallEvent) => {
|
|
||||||
if (event.subtype === "started") {
|
|
||||||
// handle both MCP tools and built-in tools (bash, WebFetch, etc)
|
|
||||||
const mcpToolCall = event.tool_call?.mcpToolCall;
|
|
||||||
const builtinToolCall = (event.tool_call as any)?.builtinToolCall;
|
|
||||||
|
|
||||||
if (mcpToolCall?.args?.toolName && mcpToolCall?.args?.args) {
|
|
||||||
log.toolCall({
|
|
||||||
toolName: mcpToolCall.args.toolName,
|
|
||||||
input: mcpToolCall.args.args,
|
|
||||||
});
|
|
||||||
} else if (builtinToolCall?.args?.name && builtinToolCall?.args?.args) {
|
|
||||||
log.toolCall({
|
|
||||||
toolName: builtinToolCall.args.name,
|
|
||||||
input: builtinToolCall.args.args,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (event.subtype === "completed") {
|
|
||||||
const isError = event.tool_call?.mcpToolCall?.result?.success?.isError;
|
|
||||||
if (isError) {
|
|
||||||
log.warning("Tool call failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
result: async (event: CursorResultEvent) => {
|
|
||||||
if (event.subtype === "success" && event.duration_ms) {
|
|
||||||
const durationSec = (event.duration_ms / 1000).toFixed(1);
|
|
||||||
log.debug(`Cursor completed in ${durationSec}s`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export const cursor = agent({
|
export const cursor = agent({
|
||||||
name: "cursor",
|
name: "cursor",
|
||||||
install: async () => {
|
install: async () => {
|
||||||
@@ -146,6 +94,76 @@ export const cursor = agent({
|
|||||||
run: async ({ payload, apiKey, cliPath, mcpServers }) => {
|
run: async ({ payload, apiKey, cliPath, mcpServers }) => {
|
||||||
configureCursorMcpServers({ mcpServers, cliPath });
|
configureCursorMcpServers({ mcpServers, cliPath });
|
||||||
|
|
||||||
|
// track logged model_call_ids to avoid duplicates
|
||||||
|
// cursor emits each assistant message twice: once without model_call_id, then again with it
|
||||||
|
const loggedModelCallIds = new Set<string>();
|
||||||
|
|
||||||
|
const messageHandlers = {
|
||||||
|
system: (_event: CursorSystemEvent) => {
|
||||||
|
// system init events - no logging needed
|
||||||
|
},
|
||||||
|
user: (_event: CursorUserEvent) => {
|
||||||
|
// user messages already logged in prompt box
|
||||||
|
},
|
||||||
|
thinking: (_event: CursorThinkingEvent) => {
|
||||||
|
// thinking events are internal - no logging needed
|
||||||
|
},
|
||||||
|
assistant: (event: CursorAssistantEvent) => {
|
||||||
|
const text = event.message?.content?.[0]?.text?.trim();
|
||||||
|
if (!text) return;
|
||||||
|
|
||||||
|
if (event.model_call_id) {
|
||||||
|
// complete message with model_call_id - log it if we haven't seen this id before
|
||||||
|
// cursor emits each message twice: first without model_call_id, then with it
|
||||||
|
// we deduplicate by model_call_id to avoid logging the same message twice
|
||||||
|
if (!loggedModelCallIds.has(event.model_call_id)) {
|
||||||
|
loggedModelCallIds.add(event.model_call_id);
|
||||||
|
log.box(text, { title: "Cursor" });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// message without model_call_id - log it immediately
|
||||||
|
// this handles cases where:
|
||||||
|
// 1. the final summary message might only be emitted without model_call_id
|
||||||
|
// 2. messages that don't get re-emitted with model_call_id
|
||||||
|
// without this, the final comprehensive summary wouldn't print (as we discovered)
|
||||||
|
log.box(text, { title: "Cursor" });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tool_call: (event: CursorToolCallEvent) => {
|
||||||
|
if (event.subtype === "started") {
|
||||||
|
// handle both MCP tools and built-in tools (bash, WebFetch, etc)
|
||||||
|
const mcpToolCall = event.tool_call?.mcpToolCall;
|
||||||
|
const builtinToolCall = (event.tool_call as any)?.builtinToolCall;
|
||||||
|
|
||||||
|
if (mcpToolCall?.args?.toolName && mcpToolCall?.args?.args) {
|
||||||
|
log.toolCall({
|
||||||
|
toolName: mcpToolCall.args.toolName,
|
||||||
|
input: mcpToolCall.args.args,
|
||||||
|
});
|
||||||
|
} else if (builtinToolCall?.args?.name && builtinToolCall?.args?.args) {
|
||||||
|
log.toolCall({
|
||||||
|
toolName: builtinToolCall.args.name,
|
||||||
|
input: builtinToolCall.args.args,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (event.subtype === "completed") {
|
||||||
|
const isError = event.tool_call?.mcpToolCall?.result?.success?.isError;
|
||||||
|
if (isError) {
|
||||||
|
log.warning("Tool call failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
result: async (event: CursorResultEvent) => {
|
||||||
|
if (event.subtype === "success" && event.duration_ms) {
|
||||||
|
const durationSec = (event.duration_ms / 1000).toFixed(1);
|
||||||
|
log.debug(`Cursor completed in ${durationSec}s`);
|
||||||
|
// note: we don't log event.result here because it contains the full conversation
|
||||||
|
// concatenated together, which would duplicate all the individual assistant
|
||||||
|
// messages we've already logged. the individual assistant events are sufficient.
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const fullPrompt = addInstructions(payload);
|
const fullPrompt = addInstructions(payload);
|
||||||
|
|
||||||
@@ -161,7 +179,7 @@ export const cursor = agent({
|
|||||||
fullPrompt,
|
fullPrompt,
|
||||||
"--output-format",
|
"--output-format",
|
||||||
"stream-json",
|
"stream-json",
|
||||||
"--stream-partial-output",
|
// "--stream-partial-output",
|
||||||
"--approve-mcps",
|
"--approve-mcps",
|
||||||
"--force",
|
"--force",
|
||||||
],
|
],
|
||||||
@@ -188,14 +206,16 @@ export const cursor = agent({
|
|||||||
try {
|
try {
|
||||||
const event = JSON.parse(text) as CursorEvent;
|
const event = JSON.parse(text) as CursorEvent;
|
||||||
|
|
||||||
|
// skip empty thinking deltas
|
||||||
|
if (event.type === "thinking" && event.subtype === "delta" && !event.text) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// route to appropriate handler
|
// route to appropriate handler
|
||||||
const handler = messageHandlers[event.type as keyof typeof messageHandlers];
|
const handler = messageHandlers[event.type as keyof typeof messageHandlers];
|
||||||
if (handler) {
|
if (handler) {
|
||||||
await handler(event as never);
|
await handler(event as never);
|
||||||
}
|
}
|
||||||
|
|
||||||
// debug: log all events
|
|
||||||
log.debug(`[cursor event] ${JSON.stringify(event, null, 2)}`);
|
|
||||||
} catch {
|
} catch {
|
||||||
// ignore parse errors - might be formatted tool call logs from cursor cli
|
// ignore parse errors - might be formatted tool call logs from cursor cli
|
||||||
// our handlers log tool calls instead, so we don't need to display these
|
// our handlers log tool calls instead, so we don't need to display these
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ Before starting any work, you must first determine which mode to use by examinin
|
|||||||
|
|
||||||
Available modes:
|
Available modes:
|
||||||
|
|
||||||
${[...modes, ...payload.modes].map((w) => ` - "${w.name}": ${w.description}`).join("\n")}
|
${(payload.modes.length > 0 ? payload.modes : modes).map((w) => ` - "${w.name}": ${w.description}`).join("\n")}
|
||||||
|
|
||||||
**IMPORTANT**: The first thing you must do is:
|
**IMPORTANT**: The first thing you must do is:
|
||||||
1. Examine the user's request/prompt carefully
|
1. Examine the user's request/prompt carefully
|
||||||
|
|||||||
@@ -83859,7 +83859,7 @@ function query({
|
|||||||
// package.json
|
// package.json
|
||||||
var package_default = {
|
var package_default = {
|
||||||
name: "@pullfrog/action",
|
name: "@pullfrog/action",
|
||||||
version: "0.0.118",
|
version: "0.0.121",
|
||||||
type: "module",
|
type: "module",
|
||||||
files: [
|
files: [
|
||||||
"index.js",
|
"index.js",
|
||||||
@@ -92367,7 +92367,7 @@ Before starting any work, you must first determine which mode to use by examinin
|
|||||||
|
|
||||||
Available modes:
|
Available modes:
|
||||||
|
|
||||||
${[...modes, ...payload.modes].map((w) => ` - "${w.name}": ${w.description}`).join("\n")}
|
${(payload.modes.length > 0 ? payload.modes : modes).map((w) => ` - "${w.name}": ${w.description}`).join("\n")}
|
||||||
|
|
||||||
**IMPORTANT**: The first thing you must do is:
|
**IMPORTANT**: The first thing you must do is:
|
||||||
1. Examine the user's request/prompt carefully
|
1. Examine the user's request/prompt carefully
|
||||||
@@ -93390,50 +93390,6 @@ import { spawn as spawn3 } from "node:child_process";
|
|||||||
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
||||||
import { homedir as homedir2 } from "node:os";
|
import { homedir as homedir2 } from "node:os";
|
||||||
import { join as join6 } from "node:path";
|
import { join as join6 } from "node:path";
|
||||||
var messageHandlers3 = {
|
|
||||||
system: (_event) => {
|
|
||||||
},
|
|
||||||
user: (_event) => {
|
|
||||||
},
|
|
||||||
thinking: (_event) => {
|
|
||||||
},
|
|
||||||
assistant: (event) => {
|
|
||||||
if (event.model_call_id) {
|
|
||||||
const text = event.message?.content?.[0]?.text;
|
|
||||||
if (text?.trim()) {
|
|
||||||
log.box(text.trim(), { title: "Cursor" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tool_call: (event) => {
|
|
||||||
if (event.subtype === "started") {
|
|
||||||
const mcpToolCall = event.tool_call?.mcpToolCall;
|
|
||||||
const builtinToolCall = event.tool_call?.builtinToolCall;
|
|
||||||
if (mcpToolCall?.args?.toolName && mcpToolCall?.args?.args) {
|
|
||||||
log.toolCall({
|
|
||||||
toolName: mcpToolCall.args.toolName,
|
|
||||||
input: mcpToolCall.args.args
|
|
||||||
});
|
|
||||||
} else if (builtinToolCall?.args?.name && builtinToolCall?.args?.args) {
|
|
||||||
log.toolCall({
|
|
||||||
toolName: builtinToolCall.args.name,
|
|
||||||
input: builtinToolCall.args.args
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (event.subtype === "completed") {
|
|
||||||
const isError = event.tool_call?.mcpToolCall?.result?.success?.isError;
|
|
||||||
if (isError) {
|
|
||||||
log.warning("Tool call failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
result: async (event) => {
|
|
||||||
if (event.subtype === "success" && event.duration_ms) {
|
|
||||||
const durationSec = (event.duration_ms / 1e3).toFixed(1);
|
|
||||||
log.debug(`Cursor completed in ${durationSec}s`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var cursor = agent({
|
var cursor = agent({
|
||||||
name: "cursor",
|
name: "cursor",
|
||||||
install: async () => {
|
install: async () => {
|
||||||
@@ -93444,6 +93400,55 @@ var cursor = agent({
|
|||||||
},
|
},
|
||||||
run: async ({ payload, apiKey, cliPath, mcpServers }) => {
|
run: async ({ payload, apiKey, cliPath, mcpServers }) => {
|
||||||
configureCursorMcpServers({ mcpServers, cliPath });
|
configureCursorMcpServers({ mcpServers, cliPath });
|
||||||
|
const loggedModelCallIds = /* @__PURE__ */ new Set();
|
||||||
|
const messageHandlers4 = {
|
||||||
|
system: (_event) => {
|
||||||
|
},
|
||||||
|
user: (_event) => {
|
||||||
|
},
|
||||||
|
thinking: (_event) => {
|
||||||
|
},
|
||||||
|
assistant: (event) => {
|
||||||
|
const text = event.message?.content?.[0]?.text?.trim();
|
||||||
|
if (!text) return;
|
||||||
|
if (event.model_call_id) {
|
||||||
|
if (!loggedModelCallIds.has(event.model_call_id)) {
|
||||||
|
loggedModelCallIds.add(event.model_call_id);
|
||||||
|
log.box(text, { title: "Cursor" });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.box(text, { title: "Cursor" });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tool_call: (event) => {
|
||||||
|
if (event.subtype === "started") {
|
||||||
|
const mcpToolCall = event.tool_call?.mcpToolCall;
|
||||||
|
const builtinToolCall = event.tool_call?.builtinToolCall;
|
||||||
|
if (mcpToolCall?.args?.toolName && mcpToolCall?.args?.args) {
|
||||||
|
log.toolCall({
|
||||||
|
toolName: mcpToolCall.args.toolName,
|
||||||
|
input: mcpToolCall.args.args
|
||||||
|
});
|
||||||
|
} else if (builtinToolCall?.args?.name && builtinToolCall?.args?.args) {
|
||||||
|
log.toolCall({
|
||||||
|
toolName: builtinToolCall.args.name,
|
||||||
|
input: builtinToolCall.args.args
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (event.subtype === "completed") {
|
||||||
|
const isError = event.tool_call?.mcpToolCall?.result?.success?.isError;
|
||||||
|
if (isError) {
|
||||||
|
log.warning("Tool call failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
result: async (event) => {
|
||||||
|
if (event.subtype === "success" && event.duration_ms) {
|
||||||
|
const durationSec = (event.duration_ms / 1e3).toFixed(1);
|
||||||
|
log.debug(`Cursor completed in ${durationSec}s`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
const fullPrompt = addInstructions(payload);
|
const fullPrompt = addInstructions(payload);
|
||||||
log.info("Running Cursor CLI...");
|
log.info("Running Cursor CLI...");
|
||||||
@@ -93456,7 +93461,7 @@ var cursor = agent({
|
|||||||
fullPrompt,
|
fullPrompt,
|
||||||
"--output-format",
|
"--output-format",
|
||||||
"stream-json",
|
"stream-json",
|
||||||
"--stream-partial-output",
|
// "--stream-partial-output",
|
||||||
"--approve-mcps",
|
"--approve-mcps",
|
||||||
"--force"
|
"--force"
|
||||||
],
|
],
|
||||||
@@ -93479,11 +93484,13 @@ var cursor = agent({
|
|||||||
stdout += text;
|
stdout += text;
|
||||||
try {
|
try {
|
||||||
const event = JSON.parse(text);
|
const event = JSON.parse(text);
|
||||||
const handler2 = messageHandlers3[event.type];
|
if (event.type === "thinking" && event.subtype === "delta" && !event.text) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const handler2 = messageHandlers4[event.type];
|
||||||
if (handler2) {
|
if (handler2) {
|
||||||
await handler2(event);
|
await handler2(event);
|
||||||
}
|
}
|
||||||
log.debug(`[cursor event] ${JSON.stringify(event, null, 2)}`);
|
|
||||||
} catch {
|
} catch {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -93640,7 +93647,7 @@ async function spawn4(options) {
|
|||||||
|
|
||||||
// agents/gemini.ts
|
// agents/gemini.ts
|
||||||
var assistantMessageBuffer = "";
|
var assistantMessageBuffer = "";
|
||||||
var messageHandlers4 = {
|
var messageHandlers3 = {
|
||||||
init: (_event) => {
|
init: (_event) => {
|
||||||
assistantMessageBuffer = "";
|
assistantMessageBuffer = "";
|
||||||
},
|
},
|
||||||
@@ -93740,7 +93747,7 @@ var gemini = agent({
|
|||||||
log.debug(`[gemini stdout] ${trimmed}`);
|
log.debug(`[gemini stdout] ${trimmed}`);
|
||||||
try {
|
try {
|
||||||
const event = JSON.parse(trimmed);
|
const event = JSON.parse(trimmed);
|
||||||
const handler2 = messageHandlers4[event.type];
|
const handler2 = messageHandlers3[event.type];
|
||||||
if (handler2) {
|
if (handler2) {
|
||||||
await handler2(event);
|
await handler2(event);
|
||||||
}
|
}
|
||||||
@@ -121793,9 +121800,7 @@ var ReportProgressTool = tool({
|
|||||||
}
|
}
|
||||||
const issueNumber = ctx.payload.event.issue_number;
|
const issueNumber = ctx.payload.event.issue_number;
|
||||||
if (issueNumber === void 0) {
|
if (issueNumber === void 0) {
|
||||||
throw new Error(
|
return { suggess: true };
|
||||||
"cannot create progress comment: no issue_number found in the payload event"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
const result = await ctx.octokit.rest.issues.createComment({
|
const result = await ctx.octokit.rest.issues.createComment({
|
||||||
owner: ctx.owner,
|
owner: ctx.owner,
|
||||||
@@ -122737,7 +122742,7 @@ function parsePayload(inputs) {
|
|||||||
agent: null,
|
agent: null,
|
||||||
prompt: inputs.prompt,
|
prompt: inputs.prompt,
|
||||||
event: {
|
event: {
|
||||||
trigger: "workflow_dispatch"
|
trigger: "unknown"
|
||||||
},
|
},
|
||||||
modes
|
modes
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -135,6 +135,10 @@ export type PayloadEvent =
|
|||||||
| {
|
| {
|
||||||
trigger: "workflow_dispatch";
|
trigger: "workflow_dispatch";
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
trigger: "unknown";
|
||||||
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
// payload type for agent execution
|
// payload type for agent execution
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ function parsePayload(inputs: Inputs): Payload {
|
|||||||
agent: null,
|
agent: null,
|
||||||
prompt: inputs.prompt,
|
prompt: inputs.prompt,
|
||||||
event: {
|
event: {
|
||||||
trigger: "workflow_dispatch",
|
trigger: "unknown",
|
||||||
},
|
},
|
||||||
modes,
|
modes,
|
||||||
};
|
};
|
||||||
|
|||||||
+5
-3
@@ -166,9 +166,11 @@ export const ReportProgressTool = tool({
|
|||||||
// no existing comment - create one
|
// no existing comment - create one
|
||||||
const issueNumber = ctx.payload.event.issue_number;
|
const issueNumber = ctx.payload.event.issue_number;
|
||||||
if (issueNumber === undefined) {
|
if (issueNumber === undefined) {
|
||||||
throw new Error(
|
// fail silently
|
||||||
"cannot create progress comment: no issue_number found in the payload event"
|
return { suggess: true };
|
||||||
);
|
// throw new Error(
|
||||||
|
// "cannot create progress comment: no issue_number found in the payload event"
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await ctx.octokit.rest.issues.createComment({
|
const result = await ctx.octokit.rest.issues.createComment({
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pullfrog/action",
|
"name": "@pullfrog/action",
|
||||||
"version": "0.0.118",
|
"version": "0.0.121",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
"index.js",
|
"index.js",
|
||||||
|
|||||||
Reference in New Issue
Block a user