fix(acp): keep unknown approvals actionable (#5430)

Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
This commit is contained in:
t3-code[bot] authored and GitHub committed 2026-08-06 12:55:31 -04:00
1 parent ab3b55e29a
commit 99d91ddaa4
3 files changed
+68 -2

No files matched your search

@@ -68,6 +68,46 @@ describe("AcpCoreRuntimeEvents", () => {
});
});
it("maps generic ACP permission kinds to dynamic tool approvals", () => {
const stamp = { eventId: "event-1" as never, createdAt: "2026-03-27T00:00:00.000Z" };
for (const kind of ["search", "fetch", "other", "unknown", "future-tool-kind"]) {
const permissionRequest = { kind };
const request = {
stamp,
provider: ProviderDriverKind.make("cursor"),
threadId: "thread-1" as never,
turnId: TurnId.make("turn-1"),
requestId: RuntimeRequestId.make(`request-${kind}`),
permissionRequest,
};
expect(
makeAcpRequestOpenedEvent({
...request,
detail: kind,
args: {},
source: "acp.jsonrpc",
method: "session/request_permission",
rawPayload: { sessionId: "session-1" },
}),
).toMatchObject({
type: "request.opened",
payload: { requestType: "dynamic_tool_call" },
});
expect(
makeAcpRequestResolvedEvent({
...request,
decision: "accept",
}),
).toMatchObject({
type: "request.resolved",
payload: { requestType: "dynamic_tool_call" },
});
}
});
it("maps ACP core plan, tool-call, and content updates", () => {
const stamp = { eventId: "event-1" as never, createdAt: "2026-03-27T00:00:00.000Z" };
const turnId = TurnId.make("turn-1");
@@ -26,7 +26,7 @@ interface AcpEventStamp {
type AcpCanonicalRequestType = Extract<
CanonicalRequestType,
"exec_command_approval" | "file_read_approval" | "file_change_approval" | "unknown"
"exec_command_approval" | "file_read_approval" | "file_change_approval" | "dynamic_tool_call"
>;
function canonicalRequestTypeFromAcpKind(kind: string | "unknown"): AcpCanonicalRequestType {
@@ -40,7 +40,7 @@ function canonicalRequestTypeFromAcpKind(kind: string | "unknown"): AcpCanonical
case "move":
return "file_change_approval";
default:
return "unknown";
return "dynamic_tool_call";
}
}
+26
View File
@@ -130,6 +130,32 @@ describe("derivePendingApprovals", () => {
]);
});
it("derives dynamic tool requests as actionable generic approvals", () => {
const activities: OrchestrationThreadActivity[] = [
makeActivity({
id: "approval-open-dynamic-tool",
createdAt: "2026-02-23T00:00:01.000Z",
kind: "approval.requested",
summary: "Approval requested",
tone: "approval",
payload: {
requestId: "req-dynamic-tool",
requestType: "dynamic_tool_call",
detail: "Search the web",
},
}),
];
expect(derivePendingApprovals(activities)).toEqual([
{
requestId: "req-dynamic-tool",
requestKind: "command",
createdAt: "2026-02-23T00:00:01.000Z",
detail: "Search the web",
},
]);
});
it("clears stale pending approvals when provider reports unknown pending request", () => {
const activities: OrchestrationThreadActivity[] = [
makeActivity({