diff --git a/.changeset/social-humans-hammer.md b/.changeset/social-humans-hammer.md deleted file mode 100644 index 4daa9646b..000000000 --- a/.changeset/social-humans-hammer.md +++ /dev/null @@ -1,217 +0,0 @@ ---- -"@voltagent/core": patch ---- - -feat: add workflow control steps (branch, foreach, loop, map, sleep) - -```ts -import { - createWorkflowChain, - andThen, - andBranch, - andForEach, - andDoWhile, - andDoUntil, - andMap, - andSleep, - andSleepUntil, -} from "@voltagent/core"; -import { z } from "zod"; -``` - -Branching: - -```ts -const workflow = createWorkflowChain({ - id: "branching-flow", - input: z.object({ amount: z.number() }), -}).andBranch({ - id: "rules", - branches: [ - { - condition: ({ data }) => data.amount > 1000, - step: andThen({ - id: "flag-large", - execute: async ({ data }) => ({ ...data, large: true }), - }), - }, - { - condition: ({ data }) => data.amount < 0, - step: andThen({ - id: "flag-invalid", - execute: async ({ data }) => ({ ...data, invalid: true }), - }), - }, - ], -}); -``` - -For-each and loops: - -```ts -createWorkflowChain({ - id: "batch-process", - input: z.array(z.number()), -}).andForEach({ - id: "double-each", - concurrency: 2, - step: andThen({ - id: "double", - execute: async ({ data }) => data * 2, - }), -}); - -createWorkflowChain({ - id: "looping-flow", - input: z.number(), -}) - .andDoWhile({ - id: "increment-until-3", - step: andThen({ - id: "increment", - execute: async ({ data }) => data + 1, - }), - condition: ({ data }) => data < 3, - }) - .andDoUntil({ - id: "increment-until-2", - step: andThen({ - id: "increment-until", - execute: async ({ data }) => data + 1, - }), - condition: ({ data }) => data >= 2, - }); -``` - -Data shaping: - -```ts -createWorkflowChain({ - id: "compose-result", - input: z.object({ userId: z.string() }), -}) - .andThen({ - id: "fetch-user", - execute: async ({ data }) => ({ name: "Ada", id: data.userId }), - }) - .andMap({ - id: "shape-output", - map: { - userId: { source: "data", path: "userId" }, - name: { source: "step", stepId: "fetch-user", path: "name" }, - region: { source: "context", key: "region" }, - constant: { source: "value", value: "ok" }, - }, - }); -``` - -Sleep: - -```ts -createWorkflowChain({ - id: "delayed-step", - input: z.object({ id: z.string() }), -}) - .andSleep({ - id: "pause", - duration: 500, - }) - .andSleepUntil({ - id: "wait-until", - date: () => new Date(Date.now() + 60_000), - }) - .andThen({ - id: "continue", - execute: async ({ data }) => ({ ...data, resumed: true }), - }); -``` - -Workflow-level retries: - -```ts -createWorkflowChain({ - id: "retry-defaults", - retryConfig: { attempts: 2, delayMs: 500 }, -}) - .andThen({ - id: "fetch-user", - execute: async ({ data }) => fetchUser(data.userId), - }) - .andThen({ - id: "no-retry-step", - retries: 0, - execute: async ({ data }) => data, - }); -``` - -Workflow hooks (finish/error/suspend): - -```ts -createWorkflowChain({ - id: "hooked-workflow", - hooks: { - onSuspend: async (info) => { - console.log("Suspended:", info.suspension?.reason); - }, - onError: async (info) => { - console.error("Failed:", info.error); - }, - onFinish: async (info) => { - console.log("Done:", info.status); - }, - onEnd: async (state, info) => { - if (info?.status === "completed") { - console.log("Result:", state.result); - console.log("Steps:", Object.keys(info.steps)); - } - }, - }, -}); -``` - -Workflow guardrails (input/output + step-level): - -```ts -import { - andGuardrail, - andThen, - createInputGuardrail, - createOutputGuardrail, - createWorkflowChain, -} from "@voltagent/core"; -import { z } from "zod"; - -const trimInput = createInputGuardrail({ - name: "trim", - handler: async ({ input }) => ({ - pass: true, - action: "modify", - modifiedInput: typeof input === "string" ? input.trim() : input, - }), -}); - -const redactOutput = createOutputGuardrail({ - name: "redact", - handler: async ({ output }) => ({ - pass: true, - action: "modify", - modifiedOutput: output.replace(/[0-9]/g, "*"), - }), -}); - -createWorkflowChain({ - id: "guarded-workflow", - input: z.string(), - result: z.string(), - inputGuardrails: [trimInput], - outputGuardrails: [redactOutput], -}) - .andGuardrail({ - id: "sanitize-step", - outputGuardrails: [redactOutput], - }) - .andThen({ - id: "finish", - execute: async ({ data }) => data, - }); -``` diff --git a/examples/base/package.json b/examples/base/package.json index bdcff5721..33ff1a961 100644 --- a/examples/base/package.json +++ b/examples/base/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/github-repo-analyzer/package.json b/examples/github-repo-analyzer/package.json index 02840d1ad..664072f0a 100644 --- a/examples/github-repo-analyzer/package.json +++ b/examples/github-repo-analyzer/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@octokit/rest": "^21.0.0", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/github-star-stories/package.json b/examples/github-star-stories/package.json index 7c19f78bd..ed07cf9e9 100644 --- a/examples/github-star-stories/package.json +++ b/examples/github-star-stories/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", "@voltagent/serverless-hono": "^2.0.5", diff --git a/examples/next-js-chatbot-starter-template/package.json b/examples/next-js-chatbot-starter-template/package.json index f1e1a807a..02fdd0bd2 100644 --- a/examples/next-js-chatbot-starter-template/package.json +++ b/examples/next-js-chatbot-starter-template/package.json @@ -20,7 +20,7 @@ "@radix-ui/react-tooltip": "^1.2.8", "@radix-ui/react-use-controllable-state": "^1.2.2", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/server-hono": "^2.0.3", "@xyflow/react": "^12.9.2", diff --git a/examples/with-a2a-server/package.json b/examples/with-a2a-server/package.json index 3cf1e84e7..046f46eb1 100644 --- a/examples/with-a2a-server/package.json +++ b/examples/with-a2a-server/package.json @@ -3,7 +3,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/a2a-server": "^2.0.2", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/internal": "^1.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-agent-tool/package.json b/examples/with-agent-tool/package.json index 2ce84b7f7..a35a0b3a2 100644 --- a/examples/with-agent-tool/package.json +++ b/examples/with-agent-tool/package.json @@ -5,7 +5,7 @@ "author": "", "dependencies": { "@ai-sdk/openai": "^3.0.0", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "ai": "^6.0.0", "zod": "^3.25.76" }, diff --git a/examples/with-airtable/package.json b/examples/with-airtable/package.json index 7e44522b4..c260b5717 100644 --- a/examples/with-airtable/package.json +++ b/examples/with-airtable/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/internal": "^1.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/sdk": "^2.0.2", diff --git a/examples/with-amazon-bedrock/package.json b/examples/with-amazon-bedrock/package.json index c4be3f230..676bacced 100644 --- a/examples/with-amazon-bedrock/package.json +++ b/examples/with-amazon-bedrock/package.json @@ -5,7 +5,7 @@ "@ai-sdk/amazon-bedrock": "^3.0.0", "@aws-sdk/credential-providers": "~3.799.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-anthropic/package.json b/examples/with-anthropic/package.json index 23a3c883d..1dfed80f3 100644 --- a/examples/with-anthropic/package.json +++ b/examples/with-anthropic/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/anthropic": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-auth/package.json b/examples/with-auth/package.json index 647aec6a8..d01720cda 100644 --- a/examples/with-auth/package.json +++ b/examples/with-auth/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-cerbos/package.json b/examples/with-cerbos/package.json index d79190412..410ac1a6a 100644 --- a/examples/with-cerbos/package.json +++ b/examples/with-cerbos/package.json @@ -6,7 +6,7 @@ "@cerbos/grpc": "^0.23.0", "@modelcontextprotocol/sdk": "^1.12.1", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/server-hono": "^2.0.3", "ai": "^6.0.0", "express": "^5.1.0", diff --git a/examples/with-chroma/package.json b/examples/with-chroma/package.json index 29532e57d..3cdff3dab 100644 --- a/examples/with-chroma/package.json +++ b/examples/with-chroma/package.json @@ -7,7 +7,7 @@ "@chroma-core/ollama": "^0.1.7", "@chroma-core/openai": "^0.1.7", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-client-side-tools/package.json b/examples/with-client-side-tools/package.json index 5b3769399..4d35774eb 100644 --- a/examples/with-client-side-tools/package.json +++ b/examples/with-client-side-tools/package.json @@ -5,7 +5,7 @@ "@ai-sdk/openai": "^3.0.0", "@ai-sdk/react": "^3.0.0", "@libsql/client": "^0.15.0", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/vercel-ai": "^1.0.0", "@voltagent/vercel-ui": "^1.0.1", "ai": "^6.0.0", diff --git a/examples/with-cloudflare-workers/package.json b/examples/with-cloudflare-workers/package.json index 2e5e45342..b027eb3e2 100644 --- a/examples/with-cloudflare-workers/package.json +++ b/examples/with-cloudflare-workers/package.json @@ -4,7 +4,7 @@ "version": "1.0.0", "dependencies": { "@ai-sdk/openai": "^3.0.0", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/serverless-hono": "^2.0.5", "ai": "^6.0.0", "hono": "^4.7.7", diff --git a/examples/with-composio-mcp/package.json b/examples/with-composio-mcp/package.json index 8b5ed8efa..1f5eebf5b 100644 --- a/examples/with-composio-mcp/package.json +++ b/examples/with-composio-mcp/package.json @@ -5,7 +5,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-custom-endpoints/package.json b/examples/with-custom-endpoints/package.json index eb239cc8e..059837ebc 100644 --- a/examples/with-custom-endpoints/package.json +++ b/examples/with-custom-endpoints/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-dynamic-parameters/package.json b/examples/with-dynamic-parameters/package.json index 0b738d951..0df7474f5 100644 --- a/examples/with-dynamic-parameters/package.json +++ b/examples/with-dynamic-parameters/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-dynamic-prompts/package.json b/examples/with-dynamic-prompts/package.json index f48b2c369..f57e538ce 100644 --- a/examples/with-dynamic-prompts/package.json +++ b/examples/with-dynamic-prompts/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-google-ai/package.json b/examples/with-google-ai/package.json index e8ef87834..5f79af8fd 100644 --- a/examples/with-google-ai/package.json +++ b/examples/with-google-ai/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/google": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-google-drive-mcp/server/package.json b/examples/with-google-drive-mcp/server/package.json index 8aa0f1a5b..52a215054 100644 --- a/examples/with-google-drive-mcp/server/package.json +++ b/examples/with-google-drive-mcp/server/package.json @@ -6,7 +6,7 @@ "@hono/node-server": "^1.14.0", "@libsql/client": "^0.15.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-google-vertex-ai/package.json b/examples/with-google-vertex-ai/package.json index 126b737b7..fd5077400 100644 --- a/examples/with-google-vertex-ai/package.json +++ b/examples/with-google-vertex-ai/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/google-vertex": "^3.0.25", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-groq-ai/package.json b/examples/with-groq-ai/package.json index c83b5d75f..d2fe86f68 100644 --- a/examples/with-groq-ai/package.json +++ b/examples/with-groq-ai/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/groq": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-guardrails/package.json b/examples/with-guardrails/package.json index 7db527fc2..b8d53efc7 100644 --- a/examples/with-guardrails/package.json +++ b/examples/with-guardrails/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", "ai": "^6.0.0" diff --git a/examples/with-hooks/package.json b/examples/with-hooks/package.json index f88a4eae1..678020f4c 100644 --- a/examples/with-hooks/package.json +++ b/examples/with-hooks/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-hugging-face-mcp/package.json b/examples/with-hugging-face-mcp/package.json index 438b0e94f..93d1a41fb 100644 --- a/examples/with-hugging-face-mcp/package.json +++ b/examples/with-hugging-face-mcp/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-langfuse/package.json b/examples/with-langfuse/package.json index 2e71b7bcc..4ddcb3c6b 100644 --- a/examples/with-langfuse/package.json +++ b/examples/with-langfuse/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/langfuse-exporter": "^2.0.2", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", diff --git a/examples/with-mcp-elicitation/package.json b/examples/with-mcp-elicitation/package.json index 36c064775..586b861f9 100644 --- a/examples/with-mcp-elicitation/package.json +++ b/examples/with-mcp-elicitation/package.json @@ -5,7 +5,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/logger": "^2.0.2", "@voltagent/mcp-server": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-mcp-server/package.json b/examples/with-mcp-server/package.json index 16009fd25..47a266861 100644 --- a/examples/with-mcp-server/package.json +++ b/examples/with-mcp-server/package.json @@ -2,7 +2,7 @@ "name": "voltagent-example-with-mcp-server", "dependencies": { "@ai-sdk/openai": "^3.0.0", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/logger": "^2.0.2", "@voltagent/mcp-server": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-mcp/package.json b/examples/with-mcp/package.json index b5011e2ee..5b043f2e4 100644 --- a/examples/with-mcp/package.json +++ b/examples/with-mcp/package.json @@ -5,7 +5,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-memory-rest-api/package.json b/examples/with-memory-rest-api/package.json index 2769997e0..724dea0cd 100644 --- a/examples/with-memory-rest-api/package.json +++ b/examples/with-memory-rest-api/package.json @@ -5,7 +5,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/logger": "^2.0.2", "@voltagent/postgres": "^2.0.2", "@voltagent/server-hono": "^2.0.3" diff --git a/examples/with-nestjs/package.json b/examples/with-nestjs/package.json index 05b9c33f1..9c217dcf9 100644 --- a/examples/with-nestjs/package.json +++ b/examples/with-nestjs/package.json @@ -7,7 +7,7 @@ "@nestjs/common": "^11.0.0", "@nestjs/core": "^11.0.0", "@nestjs/platform-express": "^11.0.0", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/server-core": "^2.1.2", "@voltagent/server-hono": "^2.0.3", "hono": "^4.7.7", diff --git a/examples/with-netlify-functions/package.json b/examples/with-netlify-functions/package.json index c3b59595f..9a681b038 100644 --- a/examples/with-netlify-functions/package.json +++ b/examples/with-netlify-functions/package.json @@ -4,7 +4,7 @@ "version": "1.0.0", "dependencies": { "@ai-sdk/openai": "^3.0.0", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/serverless-hono": "^2.0.5", "ai": "^6.0.0", "hono": "^4.7.7", diff --git a/examples/with-nextjs-resumable-stream/package.json b/examples/with-nextjs-resumable-stream/package.json index 0131748ed..17956ecb8 100644 --- a/examples/with-nextjs-resumable-stream/package.json +++ b/examples/with-nextjs-resumable-stream/package.json @@ -18,7 +18,7 @@ "@radix-ui/react-use-controllable-state": "^1.2.2", "@tavily/core": "^0.6.3", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/internal": "^1.0.2", "@voltagent/libsql": "^2.0.2", "@voltagent/resumable-streams": "^2.0.1", diff --git a/examples/with-nextjs/package.json b/examples/with-nextjs/package.json index 3e242808b..9d5ce9ef8 100644 --- a/examples/with-nextjs/package.json +++ b/examples/with-nextjs/package.json @@ -7,7 +7,7 @@ "@libsql/client": "^0.15.0", "@tailwindcss/postcss": "^4.1.4", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-nuxt/package.json b/examples/with-nuxt/package.json index 7b67a0b15..6fa2128b1 100644 --- a/examples/with-nuxt/package.json +++ b/examples/with-nuxt/package.json @@ -4,7 +4,7 @@ "@ai-sdk/openai": "^3.0.0", "@nuxt/eslint": "^1.9.0", "@nuxt/ui": "^4.0.0", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/server-hono": "^2.0.3", "ai": "^6.0.0", diff --git a/examples/with-offline-evals/package.json b/examples/with-offline-evals/package.json index 2a1f446d3..3b4fb225d 100644 --- a/examples/with-offline-evals/package.json +++ b/examples/with-offline-evals/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/evals": "^2.0.2", "@voltagent/scorers": "^2.0.2", "@voltagent/sdk": "^2.0.2", diff --git a/examples/with-ollama/package.json b/examples/with-ollama/package.json index 8216a1be5..bb9c49f47 100644 --- a/examples/with-ollama/package.json +++ b/examples/with-ollama/package.json @@ -2,7 +2,7 @@ "name": "voltagent-example-with-ollama", "dependencies": { "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", "ai": "^6.0.0", diff --git a/examples/with-peaka-mcp/package.json b/examples/with-peaka-mcp/package.json index f603f5340..3ce4adaf2 100644 --- a/examples/with-peaka-mcp/package.json +++ b/examples/with-peaka-mcp/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-pinecone/package.json b/examples/with-pinecone/package.json index f681185c5..b9c09625a 100644 --- a/examples/with-pinecone/package.json +++ b/examples/with-pinecone/package.json @@ -5,7 +5,7 @@ "@ai-sdk/openai": "^3.0.0", "@pinecone-database/pinecone": "^6.1.1", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-planagents/package.json b/examples/with-planagents/package.json index f8bb09c50..b12207ca5 100644 --- a/examples/with-planagents/package.json +++ b/examples/with-planagents/package.json @@ -6,7 +6,7 @@ "@ai-sdk/openai": "^3.0.0", "@tavily/core": "^0.6.3", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-playwright/package.json b/examples/with-playwright/package.json index f4f2274ee..b96b2cda5 100644 --- a/examples/with-playwright/package.json +++ b/examples/with-playwright/package.json @@ -8,7 +8,7 @@ "@playwright/browser-webkit": "1.51.1", "@playwright/test": "^1.51.1", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-postgres/package.json b/examples/with-postgres/package.json index 67aa3fb77..749c7625a 100644 --- a/examples/with-postgres/package.json +++ b/examples/with-postgres/package.json @@ -5,7 +5,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/logger": "^2.0.2", "@voltagent/postgres": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-qdrant/package.json b/examples/with-qdrant/package.json index 8a855f300..ed534d2b3 100644 --- a/examples/with-qdrant/package.json +++ b/examples/with-qdrant/package.json @@ -5,7 +5,7 @@ "@ai-sdk/openai": "^3.0.0", "@qdrant/js-client-rest": "^1.15.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-rag-chatbot/package.json b/examples/with-rag-chatbot/package.json index 156378628..f9ad761f3 100644 --- a/examples/with-rag-chatbot/package.json +++ b/examples/with-rag-chatbot/package.json @@ -5,7 +5,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-recipe-generator/package.json b/examples/with-recipe-generator/package.json index 72a0df50f..a27b693bb 100644 --- a/examples/with-recipe-generator/package.json +++ b/examples/with-recipe-generator/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", "ai": "^6.0.0", diff --git a/examples/with-research-assistant/package.json b/examples/with-research-assistant/package.json index b4cd8037c..30db06d3e 100644 --- a/examples/with-research-assistant/package.json +++ b/examples/with-research-assistant/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-resumable-streams/package.json b/examples/with-resumable-streams/package.json index bd8a9bd26..f448d1050 100644 --- a/examples/with-resumable-streams/package.json +++ b/examples/with-resumable-streams/package.json @@ -5,7 +5,7 @@ "author": "", "dependencies": { "@ai-sdk/openai": "^3.0.0", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/logger": "^2.0.2", "@voltagent/resumable-streams": "^2.0.1", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-retrieval/package.json b/examples/with-retrieval/package.json index cd6d76a5f..e84cf1556 100644 --- a/examples/with-retrieval/package.json +++ b/examples/with-retrieval/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-slack/package.json b/examples/with-slack/package.json index 7fa4cce5e..214439ec8 100644 --- a/examples/with-slack/package.json +++ b/examples/with-slack/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/sdk": "^2.0.2", diff --git a/examples/with-subagents/package.json b/examples/with-subagents/package.json index eda556b07..b79cc2b76 100644 --- a/examples/with-subagents/package.json +++ b/examples/with-subagents/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-supabase/package.json b/examples/with-supabase/package.json index 6e1037299..3565ef1f6 100644 --- a/examples/with-supabase/package.json +++ b/examples/with-supabase/package.json @@ -5,7 +5,7 @@ "@ai-sdk/openai": "^3.0.0", "@supabase/supabase-js": "^2.49.4", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", "@voltagent/supabase": "^2.0.2", diff --git a/examples/with-tavily-search/package.json b/examples/with-tavily-search/package.json index a167e5b7d..4cdeff0f4 100644 --- a/examples/with-tavily-search/package.json +++ b/examples/with-tavily-search/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-thinking-tool/package.json b/examples/with-thinking-tool/package.json index 79954fd42..b9b9fad0a 100644 --- a/examples/with-thinking-tool/package.json +++ b/examples/with-thinking-tool/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-tools/package.json b/examples/with-tools/package.json index 82c1b6d8a..1a2d95e4c 100644 --- a/examples/with-tools/package.json +++ b/examples/with-tools/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-turso/package.json b/examples/with-turso/package.json index e5f86714d..f196002d6 100644 --- a/examples/with-turso/package.json +++ b/examples/with-turso/package.json @@ -5,7 +5,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-vector-search/package.json b/examples/with-vector-search/package.json index 3d84f4280..ce0aff010 100644 --- a/examples/with-vector-search/package.json +++ b/examples/with-vector-search/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-vercel-ai/package.json b/examples/with-vercel-ai/package.json index c3a6a44a6..1688a7e15 100644 --- a/examples/with-vercel-ai/package.json +++ b/examples/with-vercel-ai/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-viteval/package.json b/examples/with-viteval/package.json index 265370c0b..cbeb263bf 100644 --- a/examples/with-viteval/package.json +++ b/examples/with-viteval/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-voice-elevenlabs/package.json b/examples/with-voice-elevenlabs/package.json index cd327b61d..58341f413 100644 --- a/examples/with-voice-elevenlabs/package.json +++ b/examples/with-voice-elevenlabs/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-voice-openai/package.json b/examples/with-voice-openai/package.json index a35e2894c..01c308743 100644 --- a/examples/with-voice-openai/package.json +++ b/examples/with-voice-openai/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-voice-xsai/package.json b/examples/with-voice-xsai/package.json index 75603d805..f051ab11f 100644 --- a/examples/with-voice-xsai/package.json +++ b/examples/with-voice-xsai/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-voltagent-actions/package.json b/examples/with-voltagent-actions/package.json index 49f2ace5a..823830884 100644 --- a/examples/with-voltagent-actions/package.json +++ b/examples/with-voltagent-actions/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/logger": "^2.0.2", "@voltagent/sdk": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-voltagent-exporter/package.json b/examples/with-voltagent-exporter/package.json index 55806c1f3..5eacad0ec 100644 --- a/examples/with-voltagent-exporter/package.json +++ b/examples/with-voltagent-exporter/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-voltagent-managed-memory/package.json b/examples/with-voltagent-managed-memory/package.json index eca6785e2..2302993cb 100644 --- a/examples/with-voltagent-managed-memory/package.json +++ b/examples/with-voltagent-managed-memory/package.json @@ -3,7 +3,7 @@ "author": "", "dependencies": { "@ai-sdk/openai": "^3.0.0", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", "@voltagent/voltagent-memory": "^1.0.2", diff --git a/examples/with-voltops-resumable-streams/package.json b/examples/with-voltops-resumable-streams/package.json index ccb936b7d..76cf07077 100644 --- a/examples/with-voltops-resumable-streams/package.json +++ b/examples/with-voltops-resumable-streams/package.json @@ -5,7 +5,7 @@ "author": "", "dependencies": { "@ai-sdk/openai": "^3.0.0", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/logger": "^2.0.2", "@voltagent/resumable-streams": "^2.0.1", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-voltops-retrieval/package.json b/examples/with-voltops-retrieval/package.json index 806189f86..654d63e35 100644 --- a/examples/with-voltops-retrieval/package.json +++ b/examples/with-voltops-retrieval/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-whatsapp/package.json b/examples/with-whatsapp/package.json index 99a6d2655..663507214 100644 --- a/examples/with-whatsapp/package.json +++ b/examples/with-whatsapp/package.json @@ -5,7 +5,7 @@ "@ai-sdk/openai": "^3.0.0", "@supabase/supabase-js": "^2.49.4", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-workflow/package.json b/examples/with-workflow/package.json index 82f95ccb0..8bccd5024 100644 --- a/examples/with-workflow/package.json +++ b/examples/with-workflow/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-working-memory/package.json b/examples/with-working-memory/package.json index faf7c0861..8fd457b0a 100644 --- a/examples/with-working-memory/package.json +++ b/examples/with-working-memory/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-youtube-to-blog/package.json b/examples/with-youtube-to-blog/package.json index 917cb06f2..b0c9e3ef7 100644 --- a/examples/with-youtube-to-blog/package.json +++ b/examples/with-youtube-to-blog/package.json @@ -4,7 +4,7 @@ "dependencies": { "@ai-sdk/openai": "^3.0.0", "@voltagent/cli": "^0.1.20", - "@voltagent/core": "^2.0.8", + "@voltagent/core": "^2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/examples/with-zapier-mcp/package.json b/examples/with-zapier-mcp/package.json index 6603773eb..6c4ad9c3d 100644 --- a/examples/with-zapier-mcp/package.json +++ b/examples/with-zapier-mcp/package.json @@ -6,7 +6,7 @@ "dependencies": { "@ai-sdk/amazon-bedrock": "^3.0.0", "@aws-sdk/credential-providers": "~3.799.0", - "@voltagent/core": "~2.0.8", + "@voltagent/core": "~2.0.9", "@voltagent/libsql": "^2.0.2", "@voltagent/logger": "^2.0.2", "@voltagent/server-hono": "^2.0.3", diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 75a204c7a..a0db08e3f 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,223 @@ # @voltagent/core +## 2.0.9 + +### Patch Changes + +- [#929](https://github.com/VoltAgent/voltagent/pull/929) [`78ff377`](https://github.com/VoltAgent/voltagent/commit/78ff377b200c48e90a2e3ab510d0d25ccca86c5a) Thanks [@omeraplak](https://github.com/omeraplak)! - feat: add workflow control steps (branch, foreach, loop, map, sleep) + + ```ts + import { + createWorkflowChain, + andThen, + andBranch, + andForEach, + andDoWhile, + andDoUntil, + andMap, + andSleep, + andSleepUntil, + } from "@voltagent/core"; + import { z } from "zod"; + ``` + + Branching: + + ```ts + const workflow = createWorkflowChain({ + id: "branching-flow", + input: z.object({ amount: z.number() }), + }).andBranch({ + id: "rules", + branches: [ + { + condition: ({ data }) => data.amount > 1000, + step: andThen({ + id: "flag-large", + execute: async ({ data }) => ({ ...data, large: true }), + }), + }, + { + condition: ({ data }) => data.amount < 0, + step: andThen({ + id: "flag-invalid", + execute: async ({ data }) => ({ ...data, invalid: true }), + }), + }, + ], + }); + ``` + + For-each and loops: + + ```ts + createWorkflowChain({ + id: "batch-process", + input: z.array(z.number()), + }).andForEach({ + id: "double-each", + concurrency: 2, + step: andThen({ + id: "double", + execute: async ({ data }) => data * 2, + }), + }); + + createWorkflowChain({ + id: "looping-flow", + input: z.number(), + }) + .andDoWhile({ + id: "increment-until-3", + step: andThen({ + id: "increment", + execute: async ({ data }) => data + 1, + }), + condition: ({ data }) => data < 3, + }) + .andDoUntil({ + id: "increment-until-2", + step: andThen({ + id: "increment-until", + execute: async ({ data }) => data + 1, + }), + condition: ({ data }) => data >= 2, + }); + ``` + + Data shaping: + + ```ts + createWorkflowChain({ + id: "compose-result", + input: z.object({ userId: z.string() }), + }) + .andThen({ + id: "fetch-user", + execute: async ({ data }) => ({ name: "Ada", id: data.userId }), + }) + .andMap({ + id: "shape-output", + map: { + userId: { source: "data", path: "userId" }, + name: { source: "step", stepId: "fetch-user", path: "name" }, + region: { source: "context", key: "region" }, + constant: { source: "value", value: "ok" }, + }, + }); + ``` + + Sleep: + + ```ts + createWorkflowChain({ + id: "delayed-step", + input: z.object({ id: z.string() }), + }) + .andSleep({ + id: "pause", + duration: 500, + }) + .andSleepUntil({ + id: "wait-until", + date: () => new Date(Date.now() + 60_000), + }) + .andThen({ + id: "continue", + execute: async ({ data }) => ({ ...data, resumed: true }), + }); + ``` + + Workflow-level retries: + + ```ts + createWorkflowChain({ + id: "retry-defaults", + retryConfig: { attempts: 2, delayMs: 500 }, + }) + .andThen({ + id: "fetch-user", + execute: async ({ data }) => fetchUser(data.userId), + }) + .andThen({ + id: "no-retry-step", + retries: 0, + execute: async ({ data }) => data, + }); + ``` + + Workflow hooks (finish/error/suspend): + + ```ts + createWorkflowChain({ + id: "hooked-workflow", + hooks: { + onSuspend: async (info) => { + console.log("Suspended:", info.suspension?.reason); + }, + onError: async (info) => { + console.error("Failed:", info.error); + }, + onFinish: async (info) => { + console.log("Done:", info.status); + }, + onEnd: async (state, info) => { + if (info?.status === "completed") { + console.log("Result:", state.result); + console.log("Steps:", Object.keys(info.steps)); + } + }, + }, + }); + ``` + + Workflow guardrails (input/output + step-level): + + ```ts + import { + andGuardrail, + andThen, + createInputGuardrail, + createOutputGuardrail, + createWorkflowChain, + } from "@voltagent/core"; + import { z } from "zod"; + + const trimInput = createInputGuardrail({ + name: "trim", + handler: async ({ input }) => ({ + pass: true, + action: "modify", + modifiedInput: typeof input === "string" ? input.trim() : input, + }), + }); + + const redactOutput = createOutputGuardrail({ + name: "redact", + handler: async ({ output }) => ({ + pass: true, + action: "modify", + modifiedOutput: output.replace(/[0-9]/g, "*"), + }), + }); + + createWorkflowChain({ + id: "guarded-workflow", + input: z.string(), + result: z.string(), + inputGuardrails: [trimInput], + outputGuardrails: [redactOutput], + }) + .andGuardrail({ + id: "sanitize-step", + outputGuardrails: [redactOutput], + }) + .andThen({ + id: "finish", + execute: async ({ data }) => data, + }); + ``` + ## 2.0.8 ### Patch Changes diff --git a/packages/core/package.json b/packages/core/package.json index d6a93ba94..0cd7dc6e8 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@voltagent/core", "description": "VoltAgent Core - AI agent framework for JavaScript", - "version": "2.0.8", + "version": "2.0.9", "dependencies": { "@modelcontextprotocol/sdk": "^1.12.1", "@opentelemetry/api": "^1.9.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9c1ae858e..8c6826d50 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -117,7 +117,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -154,7 +154,7 @@ importers: specifier: ^21.0.0 version: 21.1.1 '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -194,7 +194,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/logger': specifier: ^2.0.2 @@ -282,7 +282,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -403,7 +403,7 @@ importers: specifier: ^2.0.2 version: link:../../packages/a2a-server '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/internal': specifier: ^1.0.2 @@ -501,7 +501,7 @@ importers: specifier: ^3.0.0 version: 3.0.1(zod@3.25.76) '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core ai: specifier: ^6.0.0 @@ -529,7 +529,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/internal': specifier: ^1.0.2 @@ -572,7 +572,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -609,7 +609,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -752,7 +752,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -795,7 +795,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/server-hono': specifier: ^2.0.3 @@ -838,7 +838,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -881,7 +881,7 @@ importers: specifier: ^0.15.0 version: 0.15.10 '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/vercel-ai': specifier: ^1.0.0 @@ -924,7 +924,7 @@ importers: specifier: ^3.0.0 version: 3.0.1(zod@3.25.76) '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/serverless-hono': specifier: ^2.0.5 @@ -961,7 +961,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -1063,7 +1063,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -1100,7 +1100,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -1137,7 +1137,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -1174,7 +1174,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -1260,7 +1260,7 @@ importers: specifier: ^0.1.20 version: link:../../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -1303,7 +1303,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -1340,7 +1340,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -1377,7 +1377,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/logger': specifier: ^2.0.2 @@ -1408,7 +1408,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -1445,7 +1445,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -1522,7 +1522,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/langfuse-exporter': specifier: ^2.0.2 @@ -1590,7 +1590,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -1627,7 +1627,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/logger': specifier: ^2.0.2 @@ -1661,7 +1661,7 @@ importers: specifier: ^3.0.0 version: 3.0.1(zod@3.25.76) '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/logger': specifier: ^2.0.2 @@ -1698,7 +1698,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/logger': specifier: ^2.0.2 @@ -1735,7 +1735,7 @@ importers: specifier: ^11.0.0 version: 11.1.7(@nestjs/common@11.1.7)(@nestjs/core@11.1.7) '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/server-core': specifier: ^2.1.2 @@ -1784,7 +1784,7 @@ importers: specifier: ^3.0.0 version: 3.0.1(zod@3.25.76) '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/serverless-hono': specifier: ^2.0.5 @@ -1827,7 +1827,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -1933,7 +1933,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/internal': specifier: ^1.0.2 @@ -2051,7 +2051,7 @@ importers: specifier: ^4.0.0 version: 4.0.1(embla-carousel@8.6.0)(typescript@5.9.2)(vite@7.2.7)(vue-router@4.5.1)(vue@3.5.22)(zod@3.25.76) '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2088,7 +2088,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/evals': specifier: ^2.0.2 @@ -2122,7 +2122,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/logger': specifier: ^2.0.2 @@ -2159,7 +2159,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2199,7 +2199,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2242,7 +2242,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2291,7 +2291,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2340,7 +2340,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/logger': specifier: ^2.0.2 @@ -2380,7 +2380,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2420,7 +2420,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2457,7 +2457,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/logger': specifier: ^2.0.2 @@ -2491,7 +2491,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2522,7 +2522,7 @@ importers: specifier: ^3.0.0 version: 3.0.1(zod@4.2.1) '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/logger': specifier: ^2.0.2 @@ -2556,7 +2556,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2593,7 +2593,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2633,7 +2633,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2673,7 +2673,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/logger': specifier: ^2.0.2 @@ -2710,7 +2710,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2747,7 +2747,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2784,7 +2784,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2821,7 +2821,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2858,7 +2858,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2895,7 +2895,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2932,7 +2932,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -2987,7 +2987,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -3027,7 +3027,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -3073,7 +3073,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -3119,7 +3119,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/logger': specifier: ^2.0.2 @@ -3153,7 +3153,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -3187,7 +3187,7 @@ importers: specifier: ^3.0.0 version: 3.0.1(zod@3.25.76) '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/logger': specifier: ^2.0.2 @@ -3221,7 +3221,7 @@ importers: specifier: ^3.0.0 version: 3.0.1(zod@4.2.1) '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/logger': specifier: ^2.0.2 @@ -3255,7 +3255,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -3295,7 +3295,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -3335,7 +3335,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -3372,7 +3372,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -3409,7 +3409,7 @@ importers: specifier: ^0.1.20 version: link:../../packages/cli '@voltagent/core': - specifier: ^2.0.8 + specifier: ^2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2 @@ -3446,7 +3446,7 @@ importers: specifier: ~3.799.0 version: 3.799.0 '@voltagent/core': - specifier: ~2.0.8 + specifier: ~2.0.9 version: link:../../packages/core '@voltagent/libsql': specifier: ^2.0.2