Skip to content

Commit 66806d7

Browse files
refactor(approvals): defer external action wiring
1 parent f9d7f77 commit 66806d7

4 files changed

Lines changed: 1 addition & 78 deletions

File tree

src/infra/approval-view-model.test.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -90,32 +90,6 @@ describe("buildPendingApprovalView", () => {
9090
]);
9191
});
9292

93-
it("keeps external verification off generic native actions", () => {
94-
const request: PluginApprovalRequest = {
95-
id: "plugin:external-approval",
96-
createdAtMs: 1,
97-
expiresAtMs: 2,
98-
request: {
99-
title: "World verification",
100-
description: "Verify personhood before continuing.",
101-
pluginId: "agentkit",
102-
externalResolution: {
103-
label: "Verify with World",
104-
decisions: ["allow-once", "allow-always"],
105-
},
106-
},
107-
};
108-
109-
const view = buildPendingApprovalView(request);
110-
111-
expect(view.actions).toEqual([
112-
expect.objectContaining({
113-
command: "/approve plugin:external-approval deny",
114-
action: expect.objectContaining({ type: "approval", decision: "deny" }),
115-
}),
116-
]);
117-
});
118-
11993
it.each([
12094
{ request: {} },
12195
{ request: { command: "echo hi", title: "Ambiguous", description: "Ambiguous" } },

src/infra/plugin-approval-canonical-decisions.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ import { resolvePluginApprovalRequestAllowedDecisions } from "./plugin-approvals
55
/** Add the fail-closed deny verdict to the normalized plugin decision set. */
66
export function resolveCanonicalPluginApprovalRequestAllowedDecisions(params?: {
77
allowedDecisions?: readonly ExecApprovalDecision[] | readonly string[] | null;
8-
externalResolution?: unknown;
98
}): readonly ExecApprovalDecision[] {
10-
if (params?.externalResolution) {
11-
return ["deny"];
12-
}
139
const allowedDecisions = resolvePluginApprovalRequestAllowedDecisions(params);
1410
return allowedDecisions.includes("deny") ? allowedDecisions : [...allowedDecisions, "deny"];
1511
}

src/infra/plugin-approvals.test.ts

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import {
3-
buildPluginApprovalRequestMessage,
4-
normalizePluginExternalResolution,
5-
type PluginApprovalRequest,
6-
} from "./plugin-approvals.js";
2+
import { normalizePluginExternalResolution } from "./plugin-approvals.js";
73

84
describe("plugin external approval presentation", () => {
95
it("defaults external verification to allow-once", () => {
@@ -40,35 +36,4 @@ describe("plugin external approval presentation", () => {
4036
}),
4137
).toThrow("external approval label");
4238
});
43-
44-
it("emits the accepted text fallback without a generic allow command", () => {
45-
const request: PluginApprovalRequest = {
46-
id: "plugin:external-1",
47-
createdAtMs: 1_000,
48-
expiresAtMs: 61_000,
49-
request: {
50-
title: "World verification",
51-
description: "Verify personhood before continuing.",
52-
pluginId: "agentkit",
53-
toolName: "dangerous-tool",
54-
agentId: "main",
55-
externalResolution: {
56-
label: "Verify with World",
57-
decisions: ["allow-once", "allow-always"],
58-
},
59-
},
60-
};
61-
62-
expect(buildPluginApprovalRequestMessage(request, 1_000)).toContain(
63-
[
64-
"Verify with World",
65-
"Verify once: /approve plugin:external-1 external allow-once",
66-
"Verify and trust for session: /approve plugin:external-1 external allow-always",
67-
"Deny: /approve plugin:external-1 deny",
68-
].join("\n"),
69-
);
70-
expect(buildPluginApprovalRequestMessage(request, 1_000)).not.toContain(
71-
"/approve plugin:external-1 allow-once",
72-
);
73-
});
7439
});

src/infra/plugin-approvals.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,18 +176,6 @@ export function buildPluginApprovalRequestMessage(
176176
lines.push(`ID: ${request.id}`);
177177
const expiresIn = Math.max(0, Math.round((request.expiresAtMs - nowMsValue) / 1000));
178178
lines.push(`Expires in: ${expiresIn}s`);
179-
const externalResolution = normalizePluginExternalResolution(request.request.externalResolution);
180-
if (externalResolution) {
181-
lines.push(externalResolution.label);
182-
if (externalResolution.decisions?.includes("allow-once")) {
183-
lines.push(`Verify once: /approve ${request.id} external allow-once`);
184-
}
185-
if (externalResolution.decisions?.includes("allow-always")) {
186-
lines.push(`Verify and trust for session: /approve ${request.id} external allow-always`);
187-
}
188-
lines.push(`Deny: /approve ${request.id} deny`);
189-
return lines.join("\n");
190-
}
191179
lines.push(
192180
`Reply with: /approve ${request.id} ${resolvePluginApprovalRequestAllowedDecisions(
193181
request.request,

0 commit comments

Comments
 (0)