diff --git a/bun.lockb b/bun.lockb index 4ee602c..a3cb5e8 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/src/agents/agent.test.ts b/src/agents/agent.test.ts index 5bd39b7..769a4ff 100644 --- a/src/agents/agent.test.ts +++ b/src/agents/agent.test.ts @@ -8,6 +8,7 @@ import { WorkflowAgents } from "."; import { tool } from "ai"; import { z } from "zod"; import { getAgentsApi } from "./task.test"; +import { WORKFLOW_PROTOCOL_VERSION } from "../constants"; describe("agents", () => { const openaiToken = nanoid(); @@ -105,6 +106,7 @@ describe("agents", () => { "upstash-callback-forward-upstash-workflow-stepid": "1", "upstash-callback-forward-upstash-workflow-stepname": "Call Agent my agent", "upstash-callback-forward-upstash-workflow-steptype": "Call", + "upstash-callback-forward-upstash-workflow-sdk-version": WORKFLOW_PROTOCOL_VERSION, "upstash-callback-workflow-calltype": "fromCallback", "upstash-callback-workflow-init": "false", "upstash-callback-workflow-runid": workflowRunId, @@ -172,6 +174,7 @@ describe("agents", () => { "upstash-callback-forward-upstash-workflow-stepid": "2", "upstash-callback-forward-upstash-workflow-stepname": "Call Agent my agent", "upstash-callback-forward-upstash-workflow-steptype": "Call", + "upstash-callback-forward-upstash-workflow-sdk-version": WORKFLOW_PROTOCOL_VERSION, "upstash-callback-retries": "5", "upstash-callback-workflow-calltype": "fromCallback", "upstash-callback-workflow-init": "false", @@ -238,6 +241,7 @@ describe("agents", () => { "upstash-callback-forward-upstash-workflow-stepid": "3", "upstash-callback-forward-upstash-workflow-stepname": "Call Agent manager llm", "upstash-callback-forward-upstash-workflow-steptype": "Call", + "upstash-callback-forward-upstash-workflow-sdk-version": WORKFLOW_PROTOCOL_VERSION, "upstash-callback-retries": "5", "upstash-callback-workflow-calltype": "fromCallback", "upstash-callback-workflow-init": "false", diff --git a/src/agents/task.test.ts b/src/agents/task.test.ts index baa6062..5ce4a15 100644 --- a/src/agents/task.test.ts +++ b/src/agents/task.test.ts @@ -7,6 +7,7 @@ import { WorkflowAgents } from "."; import { tool } from "ai"; import { z } from "zod"; import { DisabledWorkflowContext } from "../serve/authorization"; +import { WORKFLOW_PROTOCOL_VERSION } from "../constants"; import { createAnthropic } from "@ai-sdk/anthropic"; import { createOpenAI } from "@ai-sdk/openai"; @@ -118,6 +119,7 @@ describe("tasks", () => { "upstash-callback-forward-upstash-workflow-stepid": "1", "upstash-callback-forward-upstash-workflow-stepname": "Call Agent my agent", "upstash-callback-forward-upstash-workflow-steptype": "Call", + "upstash-callback-forward-upstash-workflow-sdk-version": WORKFLOW_PROTOCOL_VERSION, "upstash-callback-workflow-calltype": "fromCallback", "upstash-callback-workflow-init": "false", "upstash-callback-workflow-runid": workflowRunId, @@ -196,6 +198,7 @@ describe("tasks", () => { "upstash-callback-forward-upstash-workflow-stepid": "1", "upstash-callback-forward-upstash-workflow-stepname": "Call Agent Manager LLM", "upstash-callback-forward-upstash-workflow-steptype": "Call", + "upstash-callback-forward-upstash-workflow-sdk-version": WORKFLOW_PROTOCOL_VERSION, "upstash-callback-workflow-calltype": "fromCallback", "upstash-callback-workflow-init": "false", "upstash-callback-workflow-runid": workflowRunId, @@ -262,6 +265,7 @@ describe("tasks", () => { "upstash-callback-feature-set": "LazyFetch,InitialBody", "upstash-callback-forward-upstash-workflow-callback": "true", "upstash-callback-forward-upstash-workflow-concurrent": "1", + "upstash-callback-forward-upstash-workflow-sdk-version": "1", "upstash-callback-forward-upstash-workflow-contenttype": "application/json", "upstash-callback-forward-upstash-workflow-stepid": "1", "upstash-callback-forward-upstash-workflow-steptype": "Call", diff --git a/src/context/context.test.ts b/src/context/context.test.ts index d83bda8..d973b42 100644 --- a/src/context/context.test.ts +++ b/src/context/context.test.ts @@ -330,6 +330,7 @@ describe("context tests", () => { "application/x-www-form-urlencoded", "upstash-callback-forward-upstash-workflow-invoke-count": "7", "upstash-forward-upstash-workflow-invoke-count": "7", + "upstash-callback-forward-upstash-workflow-sdk-version": WORKFLOW_PROTOCOL_VERSION, "upstash-callback-forward-upstash-workflow-stepid": "1", "upstash-callback-forward-upstash-workflow-stepname": "my-step", "upstash-callback-forward-upstash-workflow-steptype": "Call", @@ -393,6 +394,7 @@ describe("context tests", () => { "upstash-callback-forward-upstash-workflow-callback": "true", "upstash-callback-forward-upstash-workflow-concurrent": "1", "upstash-callback-forward-upstash-workflow-contenttype": "application/json", + "upstash-callback-forward-upstash-workflow-sdk-version": WORKFLOW_PROTOCOL_VERSION, "upstash-callback-forward-upstash-workflow-stepid": "1", "upstash-callback-forward-upstash-workflow-stepname": "my-step", "upstash-callback-forward-upstash-workflow-steptype": "Call", @@ -557,6 +559,7 @@ describe("context tests", () => { "upstash-callback-forward-upstash-workflow-callback": "true", "upstash-callback-forward-upstash-workflow-concurrent": "1", "upstash-callback-forward-upstash-workflow-contenttype": "application/json", + "upstash-callback-forward-upstash-workflow-sdk-version": WORKFLOW_PROTOCOL_VERSION, "upstash-callback-forward-upstash-workflow-stepid": "1", "upstash-callback-forward-upstash-workflow-stepname": stepName, "upstash-callback-forward-upstash-workflow-steptype": "Call", @@ -640,11 +643,11 @@ describe("context tests", () => { "upstash-callback-forward-upstash-workflow-callback": "true", "upstash-callback-forward-upstash-workflow-concurrent": "1", "upstash-callback-forward-upstash-workflow-contenttype": "application/json", - "upstash-callback-forward-upstash-workflow-invoke-count": "5", - "upstash-forward-upstash-workflow-invoke-count": "5", + "upstash-callback-forward-upstash-workflow-sdk-version": WORKFLOW_PROTOCOL_VERSION, "upstash-callback-forward-upstash-workflow-stepid": "1", "upstash-callback-forward-upstash-workflow-stepname": stepName, "upstash-callback-forward-upstash-workflow-steptype": "Call", + "upstash-callback-forward-upstash-workflow-invoke-count": "5", "upstash-callback-retries": "2", "upstash-callback-workflow-calltype": "fromCallback", "upstash-callback-workflow-init": "false", @@ -653,6 +656,7 @@ describe("context tests", () => { "upstash-feature-set": "WF_NoDelete,InitialBody", "upstash-forward-authorization": `Bearer ${openAIToken}`, "upstash-forward-content-type": "application/json", + "upstash-forward-upstash-workflow-invoke-count": "5", "upstash-method": "POST", "upstash-retries": "0", "upstash-workflow-calltype": "toCallback", @@ -721,6 +725,7 @@ describe("context tests", () => { "upstash-callback-forward-upstash-workflow-callback": "true", "upstash-callback-forward-upstash-workflow-concurrent": "1", "upstash-callback-forward-upstash-workflow-contenttype": "application/json", + "upstash-callback-forward-upstash-workflow-sdk-version": WORKFLOW_PROTOCOL_VERSION, "upstash-callback-forward-upstash-workflow-stepid": "1", "upstash-callback-forward-upstash-workflow-stepname": stepName, "upstash-callback-forward-upstash-workflow-steptype": "Call", @@ -811,11 +816,11 @@ describe("context tests", () => { "upstash-callback-forward-upstash-workflow-callback": "true", "upstash-callback-forward-upstash-workflow-concurrent": "1", "upstash-callback-forward-upstash-workflow-contenttype": "application/json", - "upstash-callback-forward-upstash-workflow-invoke-count": "3", - "upstash-forward-upstash-workflow-invoke-count": "3", + "upstash-callback-forward-upstash-workflow-sdk-version": WORKFLOW_PROTOCOL_VERSION, "upstash-callback-forward-upstash-workflow-stepid": "1", "upstash-callback-forward-upstash-workflow-stepname": stepName, "upstash-callback-forward-upstash-workflow-steptype": "Call", + "upstash-callback-forward-upstash-workflow-invoke-count": "3", "upstash-callback-retries": "2", "upstash-callback-workflow-calltype": "fromCallback", "upstash-callback-workflow-init": "false", @@ -825,6 +830,7 @@ describe("context tests", () => { "upstash-forward-x-api-key": anthropicToken, "upstash-forward-anthropic-version": "2023-06-01", "upstash-forward-content-type": "application/json", + "upstash-forward-upstash-workflow-invoke-count": "3", "upstash-method": method, "upstash-retries": "0", "upstash-workflow-calltype": "toCallback", diff --git a/src/context/steps.ts b/src/context/steps.ts index ab185f2..799b654 100644 --- a/src/context/steps.ts +++ b/src/context/steps.ts @@ -19,7 +19,13 @@ import { WorkflowError } from "../error"; import { getWorkflowRunId } from "../utils"; import { WorkflowContext } from "./context"; import { getHeaders, prepareFlowControl } from "../qstash/headers"; -import { WORKFLOW_FEATURE_HEADER, WORKFLOW_INIT_HEADER, WORKFLOW_URL_HEADER } from "../constants"; +import { + WORKFLOW_FEATURE_HEADER, + WORKFLOW_INIT_HEADER, + WORKFLOW_PROTOCOL_VERSION, + WORKFLOW_PROTOCOL_VERSION_HEADER, + WORKFLOW_URL_HEADER, +} from "../constants"; import { getTelemetryHeaders, HeadersResponse } from "../workflow-requests"; type StepParams = { context: WorkflowContext } & Pick & @@ -450,6 +456,7 @@ export class LazyCallStep extends BaseLazySt "Upstash-Callback-Workflow-Url": context.url, "Upstash-Callback-Feature-Set": "LazyFetch,InitialBody", + [`Upstash-Callback-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`]: WORKFLOW_PROTOCOL_VERSION, "Upstash-Callback-Forward-Upstash-Workflow-Callback": "true", "Upstash-Callback-Forward-Upstash-Workflow-StepId": step.stepId.toString(), "Upstash-Callback-Forward-Upstash-Workflow-StepName": this.stepName, diff --git a/src/serve/serve-many.test.ts b/src/serve/serve-many.test.ts index a2a234d..d4adadb 100644 --- a/src/serve/serve-many.test.ts +++ b/src/serve/serve-many.test.ts @@ -279,6 +279,7 @@ describe("serveMany", () => { "upstash-callback-forward-upstash-workflow-stepid": "1", "upstash-callback-forward-upstash-workflow-stepname": "call other workflow", "upstash-callback-forward-upstash-workflow-steptype": "Call", + "upstash-callback-forward-upstash-workflow-sdk-version": "1", "upstash-callback-workflow-calltype": "fromCallback", "upstash-callback-workflow-init": "false", "upstash-callback-workflow-runid": "wfr_id", diff --git a/src/serve/serve.test.ts b/src/serve/serve.test.ts index ed7c446..7238e21 100644 --- a/src/serve/serve.test.ts +++ b/src/serve/serve.test.ts @@ -640,6 +640,7 @@ describe("serve", () => { "upstash-callback-forward-upstash-workflow-concurrent": "1", "upstash-callback-forward-upstash-workflow-contenttype": "application/json", "upstash-callback-forward-upstash-workflow-stepid": "1", + "upstash-callback-forward-upstash-workflow-sdk-version": "1", "upstash-callback-forward-upstash-workflow-stepname": "call step", "upstash-callback-forward-upstash-workflow-steptype": "Call", "upstash-callback-retries": "2", diff --git a/src/workflow-requests.test.ts b/src/workflow-requests.test.ts index 1baf733..df4e22b 100644 --- a/src/workflow-requests.test.ts +++ b/src/workflow-requests.test.ts @@ -563,6 +563,7 @@ describe("Workflow Requests", () => { "Upstash-Callback-Forward-Upstash-Workflow-StepId": stepId.toString(), "Upstash-Callback-Forward-Upstash-Workflow-StepName": stepName, "Upstash-Callback-Forward-Upstash-Workflow-StepType": "Call", + "Upstash-Callback-Forward-Upstash-Workflow-Sdk-Version": WORKFLOW_PROTOCOL_VERSION, "Upstash-Callback-Workflow-CallType": "fromCallback", "Upstash-Callback-Workflow-RunId": workflowRunId, "Upstash-Callback-Workflow-Init": "false",