diff --git a/skyvern-frontend/src/api/AxiosClient.ts b/skyvern-frontend/src/api/AxiosClient.ts index 2d678870..4c62c89e 100644 --- a/skyvern-frontend/src/api/AxiosClient.ts +++ b/skyvern-frontend/src/api/AxiosClient.ts @@ -1,8 +1,19 @@ import { apiBaseUrl, artifactApiBaseUrl, envCredential } from "@/util/env"; import axios from "axios"; +const apiV1BaseUrl = apiBaseUrl; +const apiV2BaseUrl = apiBaseUrl.replace("v1", "v2"); + const client = axios.create({ - baseURL: apiBaseUrl, + baseURL: apiV1BaseUrl, + headers: { + "Content-Type": "application/json", + "x-api-key": envCredential, + }, +}); + +const v2Client = axios.create({ + baseURL: apiV2BaseUrl, headers: { "Content-Type": "application/json", "x-api-key": envCredential, @@ -15,35 +26,44 @@ const artifactApiClient = axios.create({ export function setAuthorizationHeader(token: string) { client.defaults.headers.common["Authorization"] = `Bearer ${token}`; + v2Client.defaults.headers.common["Authorization"] = `Bearer ${token}`; } export function removeAuthorizationHeader() { if (client.defaults.headers.common["Authorization"]) { delete client.defaults.headers.common["Authorization"]; + delete v2Client.defaults.headers.common["Authorization"]; } } export function setApiKeyHeader(apiKey: string) { client.defaults.headers.common["X-API-Key"] = apiKey; + v2Client.defaults.headers.common["X-API-Key"] = apiKey; } export function removeApiKeyHeader() { if (client.defaults.headers.common["X-API-Key"]) { delete client.defaults.headers.common["X-API-Key"]; } + if (v2Client.defaults.headers.common["X-API-Key"]) { + delete v2Client.defaults.headers.common["X-API-Key"]; + } } -async function getClient(credentialGetter: CredentialGetter | null) { +async function getClient( + credentialGetter: CredentialGetter | null, + version: string = "v1", +) { if (credentialGetter) { removeApiKeyHeader(); const credential = await credentialGetter(); if (!credential) { console.warn("No credential found"); - return client; + return version === "v1" ? client : v2Client; } setAuthorizationHeader(credential); } - return client; + return version === "v1" ? client : v2Client; } export type CredentialGetter = () => Promise; diff --git a/skyvern-frontend/src/api/types.ts b/skyvern-frontend/src/api/types.ts index 20ea1f98..8190a4f4 100644 --- a/skyvern-frontend/src/api/types.ts +++ b/skyvern-frontend/src/api/types.ts @@ -215,7 +215,7 @@ export type WorkflowRunStatusApiResponse = { downloaded_file_urls: Array | null; total_steps: number | null; total_cost: number | null; - observer_cruise: ObserverCruise | null; + observer_task: ObserverTask | null; }; export type TaskGenerationApiResponse = { @@ -242,8 +242,8 @@ export type ActionsApiResponse = { response: string | null; }; -export type ObserverCruise = { - observer_cruise_id: string; +export type ObserverTask = { + task_id: string; status: Status; workflow_run_id: string | null; workflow_id: string | null; diff --git a/skyvern-frontend/src/routes/tasks/create/PromptBox.tsx b/skyvern-frontend/src/routes/tasks/create/PromptBox.tsx index cd5f55c5..b8963c64 100644 --- a/skyvern-frontend/src/routes/tasks/create/PromptBox.tsx +++ b/skyvern-frontend/src/routes/tasks/create/PromptBox.tsx @@ -1,5 +1,5 @@ import { getClient } from "@/api/AxiosClient"; -import { ObserverCruise, TaskGenerationApiResponse } from "@/api/types"; +import { ObserverTask, TaskGenerationApiResponse } from "@/api/types"; import img from "@/assets/promptBoxBg.png"; import { AutoResizingTextarea } from "@/components/AutoResizingTextarea/AutoResizingTextarea"; import { CartIcon } from "@/components/icons/CartIcon"; @@ -128,9 +128,9 @@ function PromptBox() { const startObserverCruiseMutation = useMutation({ mutationFn: async (prompt: string) => { - const client = await getClient(credentialGetter); - return client.post<{ user_prompt: string }, { data: ObserverCruise }>( - "/cruise", + const client = await getClient(credentialGetter, "v2"); + return client.post<{ user_prompt: string }, { data: ObserverTask }>( + "/tasks", { user_prompt: prompt }, ); }, diff --git a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx index faaeb36c..08128e77 100644 --- a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx +++ b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx @@ -265,7 +265,7 @@ function WorkflowRun() { handleSetActiveItem("stream"); }} onObserverThoughtCardSelected={(item) => { - handleSetActiveItem(item.observer_thought_id); + handleSetActiveItem(item.thought_id); }} /> diff --git a/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts b/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts index 2f610553..5f11e1a7 100644 --- a/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts +++ b/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts @@ -11,7 +11,7 @@ export type WorkflowRunTimelineItemType = (typeof WorkflowRunTimelineItemTypes)[keyof typeof WorkflowRunTimelineItemTypes]; export type ObserverThought = { - observer_thought_id: string; + thought_id: string; user_input: string | null; observation: string | null; thought: string | null; @@ -123,7 +123,7 @@ export function isObserverThought(item: unknown): item is ObserverThought { return ( typeof item === "object" && item !== null && - "observer_thought_id" in item && + "thought_id" in item && "thought" in item ); } diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowPostRunParameters.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowPostRunParameters.tsx index 597e7b87..04ab392a 100644 --- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowPostRunParameters.tsx +++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowPostRunParameters.tsx @@ -140,7 +140,7 @@ function WorkflowPostRunParameters() { - {workflowRun.observer_cruise ? ( + {workflowRun.observer_task ? (

Observer Parameters

@@ -152,7 +152,7 @@ function WorkflowPostRunParameters() {
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOutput.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOutput.tsx index c38bff16..951d70b0 100644 --- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOutput.tsx +++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOutput.tsx @@ -77,7 +77,7 @@ function WorkflowRunOutput() { ? formatExtractedInformation(outputs) : outputs; const fileUrls = workflowRun?.downloaded_file_urls ?? []; - const observerOutput = workflowRun?.observer_cruise?.output; + const observerOutput = workflowRun?.observer_task?.output; return (
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOverview.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOverview.tsx index 9586d022..9bbba88b 100644 --- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOverview.tsx +++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOverview.tsx @@ -77,9 +77,7 @@ function WorkflowRunOverview() { /> )} {isObserverThought(selection) && ( - + )} ); diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx index 71e0dc02..ce608d65 100644 --- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx +++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimeline.tsx @@ -119,11 +119,10 @@ function WorkflowRunTimeline({ if (isThoughtItem(timelineItem)) { return (