| 1068 | // Check if this was a task-augmented request that returned a task reference |
| 1069 | // The server returns { task: { taskId, status, ... } } when a task is created |
| 1070 | const isTaskResult = ( |
| 1071 | res: unknown, |
| 1072 | ): res is { |
| 1073 | task: { taskId: string; status: string; pollInterval: number }; |
| 1074 | } => |
| 1075 | !!res && |
| 1076 | typeof res === "object" && |
| 1077 | "task" in res && |
| 1078 | !!res.task && |
| 1079 | typeof res.task === "object" && |
| 1080 | "taskId" in res.task; |
| 1081 | |
| 1082 | if (runAsTask && isTaskResult(response)) { |
| 1083 | const taskId = response.task.taskId; |