diff --git a/.changeset/blue-sloths-juggle.md b/.changeset/blue-sloths-juggle.md new file mode 100644 index 000000000..0fbce489d --- /dev/null +++ b/.changeset/blue-sloths-juggle.md @@ -0,0 +1,5 @@ +--- +"@workflow/ai": patch +--- + +Add AI provider step wrapper functions diff --git a/packages/ai/package.json b/packages/ai/package.json index 48f4d1c69..5de8850f1 100644 --- a/packages/ai/package.json +++ b/packages/ai/package.json @@ -29,6 +29,26 @@ "./agent": { "types": "./dist/agent/durable-agent.d.ts", "default": "./dist/agent/durable-agent.js" + }, + "./anthropic": { + "types": "./dist/providers/anthropic.d.ts", + "default": "./dist/providers/anthropic.js" + }, + "./gateway": { + "types": "./dist/providers/gateway.d.ts", + "default": "./dist/providers/gateway.js" + }, + "./google": { + "types": "./dist/providers/google.d.ts", + "default": "./dist/providers/google.js" + }, + "./openai": { + "types": "./dist/providers/openai.d.ts", + "default": "./dist/providers/openai.js" + }, + "./xai": { + "types": "./dist/providers/xai.d.ts", + "default": "./dist/providers/xai.js" } }, "scripts": { @@ -37,16 +57,21 @@ "test": "vitest run" }, "devDependencies": { - "workflow": "workspace:*", "@workflow/tsconfig": "workspace:*", - "ai": "catalog:" + "ai": "catalog:", + "workflow": "workspace:*" }, "peerDependencies": { - "workflow": "4.0.1-beta.22", - "ai": "^5" + "ai": "^5", + "workflow": "4.0.1-beta.22" }, "dependencies": { + "@ai-sdk/anthropic": "2.0.49", + "@ai-sdk/gateway": "2.0.15", + "@ai-sdk/google": "2.0.43", + "@ai-sdk/openai": "2.0.72", "@ai-sdk/provider": "2.0.0", + "@ai-sdk/xai": "2.0.37", "zod": "catalog:" } } diff --git a/packages/ai/src/providers/anthropic.ts b/packages/ai/src/providers/anthropic.ts new file mode 100644 index 000000000..b7a7ce546 --- /dev/null +++ b/packages/ai/src/providers/anthropic.ts @@ -0,0 +1,8 @@ +import { anthropic as anthropicProvider } from '@ai-sdk/anthropic'; + +export function anthropic(...args: Parameters) { + return async () => { + 'use step'; + return anthropicProvider(...args); + }; +} diff --git a/packages/ai/src/providers/gateway.ts b/packages/ai/src/providers/gateway.ts new file mode 100644 index 000000000..8a06d4b75 --- /dev/null +++ b/packages/ai/src/providers/gateway.ts @@ -0,0 +1,8 @@ +import { gateway as gatewayProvider } from '@ai-sdk/gateway'; + +export function gateway(...args: Parameters) { + return async () => { + 'use step'; + return gatewayProvider(...args); + }; +} diff --git a/packages/ai/src/providers/google.ts b/packages/ai/src/providers/google.ts new file mode 100644 index 000000000..9dae85141 --- /dev/null +++ b/packages/ai/src/providers/google.ts @@ -0,0 +1,8 @@ +import { google as googleProvider } from '@ai-sdk/google'; + +export function google(...args: Parameters) { + return async () => { + 'use step'; + return googleProvider(...args); + }; +} diff --git a/packages/ai/src/providers/openai.ts b/packages/ai/src/providers/openai.ts new file mode 100644 index 000000000..a0c42b7ed --- /dev/null +++ b/packages/ai/src/providers/openai.ts @@ -0,0 +1,8 @@ +import { openai as openaiProvider } from '@ai-sdk/openai'; + +export function openai(...args: Parameters) { + return async () => { + 'use step'; + return openaiProvider(...args); + }; +} diff --git a/packages/ai/src/providers/xai.ts b/packages/ai/src/providers/xai.ts new file mode 100644 index 000000000..fcdfcb118 --- /dev/null +++ b/packages/ai/src/providers/xai.ts @@ -0,0 +1,8 @@ +import { xai as xaiProvider } from '@ai-sdk/xai'; + +export function xai(...args: Parameters) { + return async () => { + 'use step'; + return xaiProvider(...args); + }; +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 86986b5e8..797a82b2f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -300,9 +300,24 @@ importers: packages/ai: dependencies: + '@ai-sdk/anthropic': + specifier: 2.0.49 + version: 2.0.49(zod@4.1.11) + '@ai-sdk/gateway': + specifier: 2.0.15 + version: 2.0.15(zod@4.1.11) + '@ai-sdk/google': + specifier: 2.0.43 + version: 2.0.43(zod@4.1.11) + '@ai-sdk/openai': + specifier: 2.0.72 + version: 2.0.72(zod@4.1.11) '@ai-sdk/provider': specifier: 2.0.0 version: 2.0.0 + '@ai-sdk/xai': + specifier: 2.0.37 + version: 2.0.37(zod@4.1.11) zod: specifier: 'catalog:' version: 4.1.11 @@ -1589,18 +1604,54 @@ importers: packages: + '@ai-sdk/anthropic@2.0.49': + resolution: {integrity: sha512-XedtHVHX6UOlR/aa8bDmlsDc/e+kjC+l6qBeqnZPF05np6Xs7YR8tfH7yARq0LDq3m+ysw7Qoy9M5KRL+1C8qA==} + engines: {node: '>=18'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + '@ai-sdk/gateway@2.0.0': resolution: {integrity: sha512-Gj0PuawK7NkZuyYgO/h5kDK/l6hFOjhLdTq3/Lli1FTl47iGmwhH1IZQpAL3Z09BeFYWakcwUmn02ovIm2wy9g==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 + '@ai-sdk/gateway@2.0.15': + resolution: {integrity: sha512-i1YVKzC1dg9LGvt+GthhD7NlRhz9J4+ZRj3KELU14IZ/MHPsOBiFeEoCCIDLR+3tqT8/+5nIsK3eZ7DFRfMfdw==} + engines: {node: '>=18'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + + '@ai-sdk/google@2.0.43': + resolution: {integrity: sha512-qO6giuoYCX/SdZScP/3VO5Xnbd392zm3HrTkhab/efocZU8J/VVEAcAUE1KJh0qOIAYllofRtpJIUGkRK8Q5rw==} + engines: {node: '>=18'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + + '@ai-sdk/openai-compatible@1.0.27': + resolution: {integrity: sha512-bpYruxVLhrTbVH6CCq48zMJNeHu6FmHtEedl9FXckEgcIEAi036idFhJlcRwC1jNCwlacbzb8dPD7OAH1EKJaQ==} + engines: {node: '>=18'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + + '@ai-sdk/openai@2.0.72': + resolution: {integrity: sha512-9j8Gdt9gFiUGFdQIjjynbC7+w8YQxkXje6dwAq1v2Pj17wmB3U0Td3lnEe/a+EnEysY3mdkc8dHPYc5BNev9NQ==} + engines: {node: '>=18'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + '@ai-sdk/provider-utils@3.0.12': resolution: {integrity: sha512-ZtbdvYxdMoria+2SlNarEk6Hlgyf+zzcznlD55EAl+7VZvJaSg2sqPvwArY7L6TfDEDJsnCq0fdhBSkYo0Xqdg==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 + '@ai-sdk/provider-utils@3.0.17': + resolution: {integrity: sha512-TR3Gs4I3Tym4Ll+EPdzRdvo/rc8Js6c4nVhFLuvGLX/Y4V9ZcQMa/HTiYsHEgmYrf1zVi6Q145UEZUfleOwOjw==} + engines: {node: '>=18'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + '@ai-sdk/provider@2.0.0': resolution: {integrity: sha512-6o7Y2SeO9vFKB8lArHXehNuusnpddKPk7xqL7T2/b+OvXMRIXUO1rR4wcv1hAFUAT9avGZshty3Wlua/XA7TvA==} engines: {node: '>=18'} @@ -1615,6 +1666,12 @@ packages: zod: optional: true + '@ai-sdk/xai@2.0.37': + resolution: {integrity: sha512-4Ah/+qWZP62eatMndykg44QBwDi9Rk4rS0UIWPLNX1eT02+RrCWXIGVu0147cNC0iMTEmnTNByqPFOWM6wifqw==} + engines: {node: '>=18'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + '@alloc/quick-lru@5.2.0': resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==} engines: {node: '>=10'} @@ -12448,6 +12505,12 @@ packages: snapshots: + '@ai-sdk/anthropic@2.0.49(zod@4.1.11)': + dependencies: + '@ai-sdk/provider': 2.0.0 + '@ai-sdk/provider-utils': 3.0.17(zod@4.1.11) + zod: 4.1.11 + '@ai-sdk/gateway@2.0.0(zod@4.1.11)': dependencies: '@ai-sdk/provider': 2.0.0 @@ -12455,6 +12518,31 @@ snapshots: '@vercel/oidc': 3.0.3 zod: 4.1.11 + '@ai-sdk/gateway@2.0.15(zod@4.1.11)': + dependencies: + '@ai-sdk/provider': 2.0.0 + '@ai-sdk/provider-utils': 3.0.17(zod@4.1.11) + '@vercel/oidc': 3.0.5 + zod: 4.1.11 + + '@ai-sdk/google@2.0.43(zod@4.1.11)': + dependencies: + '@ai-sdk/provider': 2.0.0 + '@ai-sdk/provider-utils': 3.0.17(zod@4.1.11) + zod: 4.1.11 + + '@ai-sdk/openai-compatible@1.0.27(zod@4.1.11)': + dependencies: + '@ai-sdk/provider': 2.0.0 + '@ai-sdk/provider-utils': 3.0.17(zod@4.1.11) + zod: 4.1.11 + + '@ai-sdk/openai@2.0.72(zod@4.1.11)': + dependencies: + '@ai-sdk/provider': 2.0.0 + '@ai-sdk/provider-utils': 3.0.17(zod@4.1.11) + zod: 4.1.11 + '@ai-sdk/provider-utils@3.0.12(zod@4.1.11)': dependencies: '@ai-sdk/provider': 2.0.0 @@ -12462,6 +12550,13 @@ snapshots: eventsource-parser: 3.0.6 zod: 4.1.11 + '@ai-sdk/provider-utils@3.0.17(zod@4.1.11)': + dependencies: + '@ai-sdk/provider': 2.0.0 + '@standard-schema/spec': 1.0.0 + eventsource-parser: 3.0.6 + zod: 4.1.11 + '@ai-sdk/provider@2.0.0': dependencies: json-schema: 0.4.0 @@ -12486,6 +12581,13 @@ snapshots: optionalDependencies: zod: 4.1.11 + '@ai-sdk/xai@2.0.37(zod@4.1.11)': + dependencies: + '@ai-sdk/openai-compatible': 1.0.27(zod@4.1.11) + '@ai-sdk/provider': 2.0.0 + '@ai-sdk/provider-utils': 3.0.17(zod@4.1.11) + zod: 4.1.11 + '@alloc/quick-lru@5.2.0': {} '@ampproject/remapping@2.3.0':