Skip to content

Commit a18d965

Browse files
committed
fix: connect URL mismatch and paperclip connector crash on missing context
Found by fresh-agent zero-to-company test: Bug 1: `af paperclip connect` set adapter URL to /heartbeat but gateway serves /webhook/paperclip. Fixed default bridge URL. Bug 2: Paperclip connector crashed when payload.context was undefined (e.g. from wakeup with no issue assignment). Now handles missing/partial context gracefully. Both bugs prevented the primary flow (deploy → connect → wakeup → work) from working end-to-end. Now verified working.
1 parent 3b5dc79 commit a18d965

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

packages/cli/src/cli/gateway/connectors/paperclip.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ export class PaperclipConnector implements ChannelConnector {
2525
body: string,
2626
): Promise<InboundTask | null> {
2727
const payload = JSON.parse(body) as {
28-
agentId: string;
29-
runId: string;
30-
context: Record<string, unknown>;
28+
agentId?: string;
29+
runId?: string;
30+
context?: Record<string, unknown>;
3131
};
3232

33-
if (!payload.agentId) throw new Error("Missing agentId");
33+
if (!payload.agentId) throw new Error("Missing agentId in payload");
3434

3535
// Look up AF agent ID from Paperclip agent metadata
3636
const pcAgent = await this.pc.getAgent(payload.agentId);
@@ -42,9 +42,9 @@ export class PaperclipConnector implements ChannelConnector {
4242
throw new Error(`Agent ${payload.agentId} has no af_agent_id. Deploy via "af paperclip deploy" first.`);
4343
}
4444

45-
// Build message from Paperclip context — just pass the task info
46-
const ctx = payload.context;
47-
const issueId = (ctx.issueId ?? ctx.taskId) as string | undefined;
45+
// Build message from Paperclip context — handle missing/partial context
46+
const ctx = payload.context ?? {};
47+
const issueId = (ctx.issueId ?? ctx.taskId ?? ctx.taskKey) as string | undefined;
4848
const parts: string[] = [];
4949

5050
if (ctx.wakeReason) parts.push(`Reason: ${ctx.wakeReason}`);

packages/cli/src/cli/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4919,7 +4919,7 @@ export function createProgram(): Command {
49194919
pcOpts.both(paperclipCmd
49204920
.command("connect")
49214921
.description("Update all AF-deployed agents to route through the bridge webhook."))
4922-
.option("--bridge-url <url>", "Bridge URL", "http://localhost:4100/heartbeat")
4922+
.option("--bridge-url <url>", "Gateway webhook URL", "http://localhost:4100/webhook/paperclip")
49234923
.action(async (opts: Record<string, string>) => {
49244924
const { pc, companyId } = await pcContext(opts);
49254925
const agents = await pc.listAgents(companyId);

0 commit comments

Comments
 (0)