Skip to content

Commit 2634697

Browse files
fix(acp): keep unknown approvals actionable
1 parent de592a0 commit 2634697

3 files changed

Lines changed: 68 additions & 2 deletions

File tree

‎apps/server/src/provider/acp/AcpCoreRuntimeEvents.test.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,46 @@ describe("AcpCoreRuntimeEvents", () => {
6868
});
6969
});
7070

71+
it("maps generic ACP permission kinds to dynamic tool approvals", () => {
72+
const stamp = { eventId: "event-1" as never, createdAt: "2026-03-27T00:00:00.000Z" };
73+
74+
for (const kind of ["search", "fetch", "other", "unknown", "future-tool-kind"]) {
75+
const permissionRequest = { kind };
76+
const request = {
77+
stamp,
78+
provider: ProviderDriverKind.make("cursor"),
79+
threadId: "thread-1" as never,
80+
turnId: TurnId.make("turn-1"),
81+
requestId: RuntimeRequestId.make(`request-${kind}`),
82+
permissionRequest,
83+
};
84+
85+
expect(
86+
makeAcpRequestOpenedEvent({
87+
...request,
88+
detail: kind,
89+
args: {},
90+
source: "acp.jsonrpc",
91+
method: "session/request_permission",
92+
rawPayload: { sessionId: "session-1" },
93+
}),
94+
).toMatchObject({
95+
type: "request.opened",
96+
payload: { requestType: "dynamic_tool_call" },
97+
});
98+
99+
expect(
100+
makeAcpRequestResolvedEvent({
101+
...request,
102+
decision: "accept",
103+
}),
104+
).toMatchObject({
105+
type: "request.resolved",
106+
payload: { requestType: "dynamic_tool_call" },
107+
});
108+
}
109+
});
110+
71111
it("maps ACP core plan, tool-call, and content updates", () => {
72112
const stamp = { eventId: "event-1" as never, createdAt: "2026-03-27T00:00:00.000Z" };
73113
const turnId = TurnId.make("turn-1");

‎apps/server/src/provider/acp/AcpCoreRuntimeEvents.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface AcpEventStamp {
2626

2727
type AcpCanonicalRequestType = Extract<
2828
CanonicalRequestType,
29-
"exec_command_approval" | "file_read_approval" | "file_change_approval" | "unknown"
29+
"exec_command_approval" | "file_read_approval" | "file_change_approval" | "dynamic_tool_call"
3030
>;
3131

3232
function canonicalRequestTypeFromAcpKind(kind: string | "unknown"): AcpCanonicalRequestType {
@@ -40,7 +40,7 @@ function canonicalRequestTypeFromAcpKind(kind: string | "unknown"): AcpCanonical
4040
case "move":
4141
return "file_change_approval";
4242
default:
43-
return "unknown";
43+
return "dynamic_tool_call";
4444
}
4545
}
4646

‎apps/web/src/session-logic.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,32 @@ describe("derivePendingApprovals", () => {
117117
]);
118118
});
119119

120+
it("derives dynamic tool requests as actionable generic approvals", () => {
121+
const activities: OrchestrationThreadActivity[] = [
122+
makeActivity({
123+
id: "approval-open-dynamic-tool",
124+
createdAt: "2026-02-23T00:00:01.000Z",
125+
kind: "approval.requested",
126+
summary: "Approval requested",
127+
tone: "approval",
128+
payload: {
129+
requestId: "req-dynamic-tool",
130+
requestType: "dynamic_tool_call",
131+
detail: "Search the web",
132+
},
133+
}),
134+
];
135+
136+
expect(derivePendingApprovals(activities)).toEqual([
137+
{
138+
requestId: "req-dynamic-tool",
139+
requestKind: "command",
140+
createdAt: "2026-02-23T00:00:01.000Z",
141+
detail: "Search the web",
142+
},
143+
]);
144+
});
145+
120146
it("clears stale pending approvals when provider reports unknown pending request", () => {
121147
const activities: OrchestrationThreadActivity[] = [
122148
makeActivity({

0 commit comments

Comments
 (0)