| @@ -52,6 +52,7 @@ import { · 51 unmodified lines |
| 52 | 52 | buildPausedExecutionOutput, |
| 53 | 53 | parseInteractionPayload, |
| 54 | 54 | } from "./pending-interaction-output"; |
| 55 | +import { decideInteractionHandling } from "./interaction-handling"; |
| 55 | 56 | |
| 56 | 57 | const toError = (cause: unknown): Error => |
| 57 | 58 | cause instanceof Error ? cause : new Error(String(cause)); |
| @@ -1020,8 +1021,32 @@ const driveExecution = (input: { · 962 unmodified lines |
| 1020 | 1021 | } |
| 1021 | 1022 | |
| 1022 | 1023 | const parsed = parseInteractionPayload(pending); |
| 1023 | | − const isInteractiveTerminal = process.stdin.isTTY && process.stdout.isTTY; |
| 1024 | | − if (!isInteractiveTerminal) { |
| 1024 | + const handling = decideInteractionHandling({ |
| 1025 | + parsed, |
| 1026 | + isInteractiveTerminal: process.stdin.isTTY && process.stdout.isTTY, |
| 1027 | + }); |
| 1028 | + |
| 1029 | + if (handling === "url_interactive" && parsed?.mode === "url") { |
| 1030 | + yield* printUrlInteraction({ |
| 1031 | + message: parsed.message, |
| 1032 | + url: parsed.url ?? null, |
| 1033 | + shouldOpen: input.shouldOpenUrls, |
| 1034 | + }); |
| 1035 | + |
| 1036 | + current = yield* waitForExecutionProgress({ |
| 1037 | + client: input.client, |
| 1038 | + workspaceId: input.workspaceId, |
| 1039 | + executionId: current.execution.id, |
| 1040 | + pendingInteractionId: pending.id, |
| 1041 | + }); |
| 1042 | + continue; |
| 1043 | + } |
| 1044 | + |
| 1045 | + if (handling === "url_paused") { |
| 1046 | + if (input.shouldOpenUrls && parsed?.mode === "url" && parsed.url) { |
| 1047 | + yield* openUrlInBrowser(parsed.url); |
| 1048 | + } |
| 1049 | + |
| 1025 | 1050 | const paused = buildPausedExecutionOutput({ |
| 1026 | 1051 | executionId: current.execution.id, |
| 1027 | 1052 | interaction: pending, |
| @@ -1036,20 +1061,19 @@ const driveExecution = (input: { · 8 unmodified lines |
| 1036 | 1061 | return current; |
| 1037 | 1062 | } |
| 1038 | 1063 | |
| 1039 | | − if (parsed?.mode === "url") { |
| 1040 | | − yield* printUrlInteraction({ |
| 1041 | | − message: parsed.message, |
| 1042 | | − url: parsed.url ?? null, |
| 1043 | | − shouldOpen: input.shouldOpenUrls, |
| 1044 | | − }); |
| 1045 | | − |
| 1046 | | − current = yield* waitForExecutionProgress({ |
| 1047 | | − client: input.client, |
| 1048 | | − workspaceId: input.workspaceId, |
| 1064 | + if (handling === "form_paused") { |
| 1065 | + const paused = buildPausedExecutionOutput({ |
| 1049 | 1066 | executionId: current.execution.id, |
| 1050 | | − pendingInteractionId: pending.id, |
| 1067 | + interaction: pending, |
| 1068 | + baseUrl: input.baseUrl, |
| 1069 | + shouldOpenUrls: input.shouldOpenUrls, |
| 1070 | + cliName: CLI_NAME, |
| 1051 | 1071 | }); |
| 1052 | | − continue; |
| 1072 | + yield* Effect.sync(() => { |
| 1073 | + console.log(JSON.stringify(paused)); |
| 1074 | + process.exitCode = 20; |
| 1075 | + }); |
| 1076 | + return current; |
| 1053 | 1077 | } |
| 1054 | 1078 | |
| 1055 | 1079 | const responseJson = yield* promptInteraction({ |