@@ -9,6 +9,7 @@ import { beforeEach, vi } from "vite-plus/test";
99
1010import type {
1111 ElicitationRequest,
12+ ElicitationResult,
1213 Query as ClaudeQuery,
1314 SDKMessage,
1415 SDKResultMessage,
@@ -5703,6 +5704,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
57035704 options: [
57045705 { decision: "cancel", label: "Cancel" },
57055706 { decision: "decline", label: "Decline" },
5707+ { decision: "acceptForSession", label: "Always allow this session" },
57065708 { decision: "accept", label: "Approve" },
57075709 ],
57085710 });
@@ -5732,16 +5734,41 @@ describe("ClaudeAdapterV2 background wake turns", () => {
57325734 }).pipe(Effect.scoped, Effect.provide(testLayer)),
57335735 );
57345736
5735- it.effect.each(["acceptForSession", "acceptAlways"] as const)(
5736- "declines an unsupported %s decision",
5737- (decision) =>
5738- Effect.gen(function* () {
5739- const { harness, elicit, awaitCard } = yield* startElicitationTurn();
5740- const answer = yield* elicit(approvalOnly);
5741- const request = yield* awaitCard(1);
5742- yield* harness.runtime.respondToRuntimeRequest({ requestId: request.id, decision });
5743- assert.deepEqual(yield* Fiber.join(answer), { action: "decline" });
5744- }).pipe(Effect.scoped, Effect.provide(testLayer)),
5737+ it.effect("declines an unsupported acceptAlways decision", () =>
5738+ Effect.gen(function* () {
5739+ const { harness, elicit, awaitCard } = yield* startElicitationTurn();
5740+ const answer = yield* elicit(approvalOnly);
5741+ const request = yield* awaitCard(1);
5742+ yield* harness.runtime.respondToRuntimeRequest({
5743+ requestId: request.id,
5744+ decision: "acceptAlways",
5745+ });
5746+ assert.deepEqual(yield* Fiber.join(answer), { action: "decline" });
5747+ }).pipe(Effect.scoped, Effect.provide(testLayer)),
5748+ );
5749+
5750+ it.effect("answers a repeated prompt from a session grant without a card", () =>
5751+ Effect.gen(function* () {
5752+ const { harness, elicit, awaitCard, runtimeRequests } = yield* startElicitationTurn();
5753+ const first = yield* elicit(approvalOnly);
5754+ const request = yield* awaitCard(1);
5755+ yield* harness.runtime.respondToRuntimeRequest({
5756+ requestId: request.id,
5757+ decision: "acceptForSession",
5758+ });
5759+ const granted = { action: "accept", content: {} } satisfies ElicitationResult;
5760+ assert.deepEqual(yield* Fiber.join(first), granted);
5761+
5762+ assert.deepEqual(yield* Fiber.join(yield* elicit(approvalOnly)), granted);
5763+ assert.equal(runtimeRequests().length, 1);
5764+
5765+ const otherMessage = yield* elicit({ ...approvalOnly, message: "Deploy api?" });
5766+ yield* awaitCard(2);
5767+ const otherServer = yield* elicit({ ...approvalOnly, serverName: "builds" });
5768+ yield* awaitCard(3);
5769+ assert.isUndefined(otherMessage.pollUnsafe());
5770+ assert.isUndefined(otherServer.pollUnsafe());
5771+ }).pipe(Effect.scoped, Effect.provide(testLayer)),
57455772 );
57465773
57475774 it.effect("declines URL and value forms without a card", () =>
0 commit comments