overai 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +248 -0
- package/dist/agent/context.d.ts +74 -0
- package/dist/agent/context.js +140 -0
- package/dist/agent/enhanced.d.ts +98 -0
- package/dist/agent/enhanced.js +293 -0
- package/dist/agent/handoff.d.ts +82 -0
- package/dist/agent/handoff.js +124 -0
- package/dist/agent/image.d.ts +57 -0
- package/dist/agent/image.js +116 -0
- package/dist/agent/index.d.ts +19 -0
- package/dist/agent/index.js +38 -0
- package/dist/agent/prompt-expander.d.ts +43 -0
- package/dist/agent/prompt-expander.js +99 -0
- package/dist/agent/proxy.d.ts +26 -0
- package/dist/agent/proxy.js +173 -0
- package/dist/agent/query-rewriter.d.ts +41 -0
- package/dist/agent/query-rewriter.js +94 -0
- package/dist/agent/research.d.ts +55 -0
- package/dist/agent/research.js +134 -0
- package/dist/agent/router.d.ts +141 -0
- package/dist/agent/router.js +209 -0
- package/dist/agent/simple.d.ts +289 -0
- package/dist/agent/simple.js +696 -0
- package/dist/agent/types.d.ts +56 -0
- package/dist/agent/types.js +165 -0
- package/dist/ai/agent-loop.d.ts +177 -0
- package/dist/ai/agent-loop.js +313 -0
- package/dist/ai/devtools.d.ts +74 -0
- package/dist/ai/devtools.js +216 -0
- package/dist/ai/embed.d.ts +71 -0
- package/dist/ai/embed.js +154 -0
- package/dist/ai/generate-image.d.ts +66 -0
- package/dist/ai/generate-image.js +138 -0
- package/dist/ai/generate-object.d.ts +132 -0
- package/dist/ai/generate-object.js +206 -0
- package/dist/ai/generate-text.d.ts +201 -0
- package/dist/ai/generate-text.js +253 -0
- package/dist/ai/index.d.ts +27 -0
- package/dist/ai/index.js +140 -0
- package/dist/ai/mcp.d.ts +181 -0
- package/dist/ai/mcp.js +234 -0
- package/dist/ai/middleware.d.ts +110 -0
- package/dist/ai/middleware.js +186 -0
- package/dist/ai/models.d.ts +67 -0
- package/dist/ai/models.js +249 -0
- package/dist/ai/multimodal.d.ts +125 -0
- package/dist/ai/multimodal.js +270 -0
- package/dist/ai/nextjs.d.ts +122 -0
- package/dist/ai/nextjs.js +218 -0
- package/dist/ai/server.d.ts +126 -0
- package/dist/ai/server.js +336 -0
- package/dist/ai/speech.d.ts +135 -0
- package/dist/ai/speech.js +296 -0
- package/dist/ai/telemetry.d.ts +162 -0
- package/dist/ai/telemetry.js +311 -0
- package/dist/ai/tool-approval.d.ts +225 -0
- package/dist/ai/tool-approval.js +407 -0
- package/dist/ai/tools.d.ts +93 -0
- package/dist/ai/tools.js +89 -0
- package/dist/ai/types.d.ts +47 -0
- package/dist/ai/types.js +5 -0
- package/dist/ai/ui-message.d.ts +218 -0
- package/dist/ai/ui-message.js +291 -0
- package/dist/auto/index.d.ts +62 -0
- package/dist/auto/index.js +163 -0
- package/dist/cache/index.d.ts +78 -0
- package/dist/cache/index.js +235 -0
- package/dist/cli/commands/agent.d.ts +30 -0
- package/dist/cli/commands/agent.js +151 -0
- package/dist/cli/commands/agents.d.ts +24 -0
- package/dist/cli/commands/agents.js +166 -0
- package/dist/cli/commands/approval.d.ts +10 -0
- package/dist/cli/commands/approval.js +253 -0
- package/dist/cli/commands/auto.d.ts +12 -0
- package/dist/cli/commands/auto.js +109 -0
- package/dist/cli/commands/autonomy.d.ts +5 -0
- package/dist/cli/commands/autonomy.js +152 -0
- package/dist/cli/commands/benchmark.d.ts +19 -0
- package/dist/cli/commands/benchmark.js +484 -0
- package/dist/cli/commands/cache.d.ts +9 -0
- package/dist/cli/commands/cache.js +143 -0
- package/dist/cli/commands/chat.d.ts +14 -0
- package/dist/cli/commands/chat.js +127 -0
- package/dist/cli/commands/checkpoints.d.ts +5 -0
- package/dist/cli/commands/checkpoints.js +236 -0
- package/dist/cli/commands/context.d.ts +11 -0
- package/dist/cli/commands/context.js +182 -0
- package/dist/cli/commands/cost.d.ts +5 -0
- package/dist/cli/commands/cost.js +146 -0
- package/dist/cli/commands/db.d.ts +9 -0
- package/dist/cli/commands/db.js +149 -0
- package/dist/cli/commands/embed.d.ts +20 -0
- package/dist/cli/commands/embed.js +375 -0
- package/dist/cli/commands/eval.d.ts +17 -0
- package/dist/cli/commands/eval.js +247 -0
- package/dist/cli/commands/external-agents.d.ts +5 -0
- package/dist/cli/commands/external-agents.js +170 -0
- package/dist/cli/commands/fast-context.d.ts +5 -0
- package/dist/cli/commands/fast-context.js +126 -0
- package/dist/cli/commands/flow.d.ts +5 -0
- package/dist/cli/commands/flow.js +141 -0
- package/dist/cli/commands/git.d.ts +5 -0
- package/dist/cli/commands/git.js +178 -0
- package/dist/cli/commands/graph-rag.d.ts +9 -0
- package/dist/cli/commands/graph-rag.js +131 -0
- package/dist/cli/commands/guardrail.d.ts +11 -0
- package/dist/cli/commands/guardrail.js +156 -0
- package/dist/cli/commands/handoff.d.ts +9 -0
- package/dist/cli/commands/handoff.js +133 -0
- package/dist/cli/commands/help.d.ts +8 -0
- package/dist/cli/commands/help.js +139 -0
- package/dist/cli/commands/image.d.ts +13 -0
- package/dist/cli/commands/image.js +192 -0
- package/dist/cli/commands/interactive.d.ts +6 -0
- package/dist/cli/commands/interactive.js +79 -0
- package/dist/cli/commands/jobs.d.ts +5 -0
- package/dist/cli/commands/jobs.js +282 -0
- package/dist/cli/commands/knowledge.d.ts +9 -0
- package/dist/cli/commands/knowledge.js +226 -0
- package/dist/cli/commands/llm.d.ts +21 -0
- package/dist/cli/commands/llm.js +748 -0
- package/dist/cli/commands/mcp.d.ts +9 -0
- package/dist/cli/commands/mcp.js +243 -0
- package/dist/cli/commands/memory.d.ts +10 -0
- package/dist/cli/commands/memory.js +198 -0
- package/dist/cli/commands/n8n.d.ts +5 -0
- package/dist/cli/commands/n8n.js +137 -0
- package/dist/cli/commands/observability.d.ts +16 -0
- package/dist/cli/commands/observability.js +335 -0
- package/dist/cli/commands/planning.d.ts +9 -0
- package/dist/cli/commands/planning.js +167 -0
- package/dist/cli/commands/prompt-expand.d.ts +11 -0
- package/dist/cli/commands/prompt-expand.js +100 -0
- package/dist/cli/commands/providers.d.ts +17 -0
- package/dist/cli/commands/providers.js +386 -0
- package/dist/cli/commands/query-rewrite.d.ts +12 -0
- package/dist/cli/commands/query-rewrite.js +102 -0
- package/dist/cli/commands/repo-map.d.ts +5 -0
- package/dist/cli/commands/repo-map.js +151 -0
- package/dist/cli/commands/reranker.d.ts +10 -0
- package/dist/cli/commands/reranker.js +144 -0
- package/dist/cli/commands/research.d.ts +12 -0
- package/dist/cli/commands/research.js +108 -0
- package/dist/cli/commands/router.d.ts +11 -0
- package/dist/cli/commands/router.js +142 -0
- package/dist/cli/commands/run.d.ts +14 -0
- package/dist/cli/commands/run.js +111 -0
- package/dist/cli/commands/sandbox.d.ts +5 -0
- package/dist/cli/commands/sandbox.js +135 -0
- package/dist/cli/commands/scheduler.d.ts +5 -0
- package/dist/cli/commands/scheduler.js +260 -0
- package/dist/cli/commands/session.d.ts +9 -0
- package/dist/cli/commands/session.js +238 -0
- package/dist/cli/commands/skills.d.ts +9 -0
- package/dist/cli/commands/skills.js +256 -0
- package/dist/cli/commands/telemetry.d.ts +9 -0
- package/dist/cli/commands/telemetry.js +146 -0
- package/dist/cli/commands/tools.d.ts +19 -0
- package/dist/cli/commands/tools.js +576 -0
- package/dist/cli/commands/vector.d.ts +10 -0
- package/dist/cli/commands/vector.js +171 -0
- package/dist/cli/commands/version.d.ts +8 -0
- package/dist/cli/commands/version.js +40 -0
- package/dist/cli/commands/voice.d.ts +10 -0
- package/dist/cli/commands/voice.js +162 -0
- package/dist/cli/commands/workflow.d.ts +13 -0
- package/dist/cli/commands/workflow.js +184 -0
- package/dist/cli/config/index.d.ts +6 -0
- package/dist/cli/config/index.js +22 -0
- package/dist/cli/config/load.d.ts +20 -0
- package/dist/cli/config/load.js +229 -0
- package/dist/cli/config/resolve.d.ts +28 -0
- package/dist/cli/config/resolve.js +70 -0
- package/dist/cli/config/schema.d.ts +15 -0
- package/dist/cli/config/schema.js +65 -0
- package/dist/cli/features/autonomy-mode.d.ts +98 -0
- package/dist/cli/features/autonomy-mode.js +266 -0
- package/dist/cli/features/background-jobs.d.ts +155 -0
- package/dist/cli/features/background-jobs.js +416 -0
- package/dist/cli/features/checkpoints.d.ts +126 -0
- package/dist/cli/features/checkpoints.js +288 -0
- package/dist/cli/features/cost-tracker.d.ts +101 -0
- package/dist/cli/features/cost-tracker.js +212 -0
- package/dist/cli/features/external-agents.d.ts +117 -0
- package/dist/cli/features/external-agents.js +296 -0
- package/dist/cli/features/fast-context.d.ts +126 -0
- package/dist/cli/features/fast-context.js +310 -0
- package/dist/cli/features/flow-display.d.ts +100 -0
- package/dist/cli/features/flow-display.js +254 -0
- package/dist/cli/features/git-integration.d.ts +138 -0
- package/dist/cli/features/git-integration.js +374 -0
- package/dist/cli/features/index.d.ts +17 -0
- package/dist/cli/features/index.js +102 -0
- package/dist/cli/features/interactive-tui.d.ts +114 -0
- package/dist/cli/features/interactive-tui.js +326 -0
- package/dist/cli/features/n8n-integration.d.ts +111 -0
- package/dist/cli/features/n8n-integration.js +299 -0
- package/dist/cli/features/repo-map.d.ts +101 -0
- package/dist/cli/features/repo-map.js +350 -0
- package/dist/cli/features/sandbox-executor.d.ts +89 -0
- package/dist/cli/features/sandbox-executor.js +314 -0
- package/dist/cli/features/scheduler.d.ts +111 -0
- package/dist/cli/features/scheduler.js +298 -0
- package/dist/cli/features/slash-commands.d.ts +77 -0
- package/dist/cli/features/slash-commands.js +316 -0
- package/dist/cli/index.d.ts +24 -0
- package/dist/cli/index.js +214 -0
- package/dist/cli/output/errors.d.ts +23 -0
- package/dist/cli/output/errors.js +36 -0
- package/dist/cli/output/json.d.ts +27 -0
- package/dist/cli/output/json.js +31 -0
- package/dist/cli/output/pretty.d.ts +13 -0
- package/dist/cli/output/pretty.js +31 -0
- package/dist/cli/runtime/env.d.ts +12 -0
- package/dist/cli/runtime/env.js +55 -0
- package/dist/cli/runtime/exit.d.ts +11 -0
- package/dist/cli/runtime/exit.js +49 -0
- package/dist/cli/runtime/index.d.ts +6 -0
- package/dist/cli/runtime/index.js +22 -0
- package/dist/cli/runtime/lazy.d.ts +18 -0
- package/dist/cli/runtime/lazy.js +85 -0
- package/dist/cli/spec/cli-spec.d.ts +87 -0
- package/dist/cli/spec/cli-spec.js +551 -0
- package/dist/cli/spec/index.d.ts +4 -0
- package/dist/cli/spec/index.js +20 -0
- package/dist/db/index.d.ts +6 -0
- package/dist/db/index.js +75 -0
- package/dist/db/types.d.ts +42 -0
- package/dist/db/types.js +2 -0
- package/dist/eval/index.d.ts +61 -0
- package/dist/eval/index.js +157 -0
- package/dist/events/index.d.ts +84 -0
- package/dist/events/index.js +153 -0
- package/dist/guardrails/index.d.ts +82 -0
- package/dist/guardrails/index.js +202 -0
- package/dist/guardrails/llm-guardrail.d.ts +46 -0
- package/dist/guardrails/llm-guardrail.js +112 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.js +608 -0
- package/dist/integrations/computer-use.d.ts +182 -0
- package/dist/integrations/computer-use.js +356 -0
- package/dist/integrations/index.d.ts +7 -0
- package/dist/integrations/index.js +26 -0
- package/dist/integrations/observability/base.d.ts +123 -0
- package/dist/integrations/observability/base.js +183 -0
- package/dist/integrations/observability/index.d.ts +8 -0
- package/dist/integrations/observability/index.js +29 -0
- package/dist/integrations/observability/langfuse.d.ts +32 -0
- package/dist/integrations/observability/langfuse.js +174 -0
- package/dist/integrations/postgres.d.ts +162 -0
- package/dist/integrations/postgres.js +396 -0
- package/dist/integrations/slack.d.ts +145 -0
- package/dist/integrations/slack.js +270 -0
- package/dist/integrations/vector/base.d.ts +110 -0
- package/dist/integrations/vector/base.js +158 -0
- package/dist/integrations/vector/chroma.d.ts +25 -0
- package/dist/integrations/vector/chroma.js +143 -0
- package/dist/integrations/vector/index.d.ts +14 -0
- package/dist/integrations/vector/index.js +37 -0
- package/dist/integrations/vector/pinecone.d.ts +28 -0
- package/dist/integrations/vector/pinecone.js +172 -0
- package/dist/integrations/vector/qdrant.d.ts +25 -0
- package/dist/integrations/vector/qdrant.js +146 -0
- package/dist/integrations/vector/weaviate.d.ts +30 -0
- package/dist/integrations/vector/weaviate.js +206 -0
- package/dist/integrations/voice/base.d.ts +76 -0
- package/dist/integrations/voice/base.js +168 -0
- package/dist/integrations/voice/index.d.ts +6 -0
- package/dist/integrations/voice/index.js +26 -0
- package/dist/knowledge/chunking.d.ts +55 -0
- package/dist/knowledge/chunking.js +158 -0
- package/dist/knowledge/graph-rag.d.ts +125 -0
- package/dist/knowledge/graph-rag.js +289 -0
- package/dist/knowledge/index.d.ts +24 -0
- package/dist/knowledge/index.js +47 -0
- package/dist/knowledge/knowledge.d.ts +0 -0
- package/dist/knowledge/knowledge.js +1 -0
- package/dist/knowledge/rag.d.ts +80 -0
- package/dist/knowledge/rag.js +147 -0
- package/dist/knowledge/reranker.d.ts +86 -0
- package/dist/knowledge/reranker.js +196 -0
- package/dist/llm/backend-resolver.d.ts +77 -0
- package/dist/llm/backend-resolver.js +242 -0
- package/dist/llm/embeddings.d.ts +66 -0
- package/dist/llm/embeddings.js +294 -0
- package/dist/llm/index.d.ts +29 -0
- package/dist/llm/index.js +33 -0
- package/dist/llm/llm.d.ts +0 -0
- package/dist/llm/llm.js +1 -0
- package/dist/llm/openai.d.ts +39 -0
- package/dist/llm/openai.js +302 -0
- package/dist/llm/providers/ai-sdk/adapter.d.ts +121 -0
- package/dist/llm/providers/ai-sdk/adapter.js +399 -0
- package/dist/llm/providers/ai-sdk/backend.d.ts +49 -0
- package/dist/llm/providers/ai-sdk/backend.js +421 -0
- package/dist/llm/providers/ai-sdk/index.d.ts +69 -0
- package/dist/llm/providers/ai-sdk/index.js +200 -0
- package/dist/llm/providers/ai-sdk/middleware.d.ts +60 -0
- package/dist/llm/providers/ai-sdk/middleware.js +262 -0
- package/dist/llm/providers/ai-sdk/provider-map.d.ts +75 -0
- package/dist/llm/providers/ai-sdk/provider-map.js +258 -0
- package/dist/llm/providers/ai-sdk/types.d.ts +217 -0
- package/dist/llm/providers/ai-sdk/types.js +222 -0
- package/dist/llm/providers/anthropic.d.ts +33 -0
- package/dist/llm/providers/anthropic.js +291 -0
- package/dist/llm/providers/base.d.ts +25 -0
- package/dist/llm/providers/base.js +43 -0
- package/dist/llm/providers/google.d.ts +27 -0
- package/dist/llm/providers/google.js +275 -0
- package/dist/llm/providers/index.d.ts +107 -0
- package/dist/llm/providers/index.js +216 -0
- package/dist/llm/providers/openai.d.ts +18 -0
- package/dist/llm/providers/openai.js +203 -0
- package/dist/llm/providers/registry.d.ts +159 -0
- package/dist/llm/providers/registry.js +279 -0
- package/dist/llm/providers/types.d.ts +94 -0
- package/dist/llm/providers/types.js +5 -0
- package/dist/main.d.ts +0 -0
- package/dist/main.js +1 -0
- package/dist/memory/auto-memory.d.ts +136 -0
- package/dist/memory/auto-memory.js +301 -0
- package/dist/memory/file-memory.d.ts +88 -0
- package/dist/memory/file-memory.js +287 -0
- package/dist/memory/index.d.ts +26 -0
- package/dist/memory/index.js +41 -0
- package/dist/memory/memory.d.ts +92 -0
- package/dist/memory/memory.js +170 -0
- package/dist/observability/adapters/console.d.ts +33 -0
- package/dist/observability/adapters/console.js +71 -0
- package/dist/observability/adapters/external/arize.d.ts +20 -0
- package/dist/observability/adapters/external/arize.js +22 -0
- package/dist/observability/adapters/external/axiom.d.ts +20 -0
- package/dist/observability/adapters/external/axiom.js +22 -0
- package/dist/observability/adapters/external/braintrust.d.ts +20 -0
- package/dist/observability/adapters/external/braintrust.js +22 -0
- package/dist/observability/adapters/external/helicone.d.ts +20 -0
- package/dist/observability/adapters/external/helicone.js +22 -0
- package/dist/observability/adapters/external/laminar.d.ts +20 -0
- package/dist/observability/adapters/external/laminar.js +22 -0
- package/dist/observability/adapters/external/langfuse.d.ts +28 -0
- package/dist/observability/adapters/external/langfuse.js +186 -0
- package/dist/observability/adapters/external/langsmith.d.ts +21 -0
- package/dist/observability/adapters/external/langsmith.js +83 -0
- package/dist/observability/adapters/external/langwatch.d.ts +20 -0
- package/dist/observability/adapters/external/langwatch.js +22 -0
- package/dist/observability/adapters/external/maxim.d.ts +20 -0
- package/dist/observability/adapters/external/maxim.js +22 -0
- package/dist/observability/adapters/external/patronus.d.ts +20 -0
- package/dist/observability/adapters/external/patronus.js +22 -0
- package/dist/observability/adapters/external/scorecard.d.ts +20 -0
- package/dist/observability/adapters/external/scorecard.js +22 -0
- package/dist/observability/adapters/external/signoz.d.ts +20 -0
- package/dist/observability/adapters/external/signoz.js +22 -0
- package/dist/observability/adapters/external/traceloop.d.ts +20 -0
- package/dist/observability/adapters/external/traceloop.js +22 -0
- package/dist/observability/adapters/external/weave.d.ts +20 -0
- package/dist/observability/adapters/external/weave.js +22 -0
- package/dist/observability/adapters/index.d.ts +19 -0
- package/dist/observability/adapters/index.js +289 -0
- package/dist/observability/adapters/memory.d.ts +41 -0
- package/dist/observability/adapters/memory.js +190 -0
- package/dist/observability/adapters/noop.d.ts +25 -0
- package/dist/observability/adapters/noop.js +64 -0
- package/dist/observability/index.d.ts +47 -0
- package/dist/observability/index.js +115 -0
- package/dist/observability/types.d.ts +165 -0
- package/dist/observability/types.js +165 -0
- package/dist/planning/index.d.ts +253 -0
- package/dist/planning/index.js +475 -0
- package/dist/process/index.d.ts +25 -0
- package/dist/process/index.js +37 -0
- package/dist/process/process.d.ts +0 -0
- package/dist/process/process.js +1 -0
- package/dist/session/index.d.ts +111 -0
- package/dist/session/index.js +250 -0
- package/dist/skills/index.d.ts +70 -0
- package/dist/skills/index.js +233 -0
- package/dist/task/index.d.ts +25 -0
- package/dist/task/index.js +32 -0
- package/dist/task/task.d.ts +0 -0
- package/dist/task/task.js +1 -0
- package/dist/telemetry/index.d.ts +175 -0
- package/dist/telemetry/index.js +287 -0
- package/dist/tools/arxivTools.d.ts +32 -0
- package/dist/tools/arxivTools.js +81 -0
- package/dist/tools/base.d.ts +97 -0
- package/dist/tools/base.js +147 -0
- package/dist/tools/builtins/airweave.d.ts +32 -0
- package/dist/tools/builtins/airweave.js +119 -0
- package/dist/tools/builtins/bedrock-agentcore.d.ts +62 -0
- package/dist/tools/builtins/bedrock-agentcore.js +233 -0
- package/dist/tools/builtins/code-execution.d.ts +36 -0
- package/dist/tools/builtins/code-execution.js +136 -0
- package/dist/tools/builtins/code-mode.d.ts +54 -0
- package/dist/tools/builtins/code-mode.js +167 -0
- package/dist/tools/builtins/custom.d.ts +42 -0
- package/dist/tools/builtins/custom.js +195 -0
- package/dist/tools/builtins/exa.d.ts +53 -0
- package/dist/tools/builtins/exa.js +112 -0
- package/dist/tools/builtins/firecrawl.d.ts +56 -0
- package/dist/tools/builtins/firecrawl.js +158 -0
- package/dist/tools/builtins/index.d.ts +45 -0
- package/dist/tools/builtins/index.js +180 -0
- package/dist/tools/builtins/parallel.d.ts +30 -0
- package/dist/tools/builtins/parallel.js +113 -0
- package/dist/tools/builtins/perplexity.d.ts +32 -0
- package/dist/tools/builtins/perplexity.js +113 -0
- package/dist/tools/builtins/superagent.d.ts +66 -0
- package/dist/tools/builtins/superagent.js +187 -0
- package/dist/tools/builtins/tavily.d.ts +99 -0
- package/dist/tools/builtins/tavily.js +285 -0
- package/dist/tools/builtins/valyu.d.ts +65 -0
- package/dist/tools/builtins/valyu.js +193 -0
- package/dist/tools/decorator.d.ts +91 -0
- package/dist/tools/decorator.js +165 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.js +36 -0
- package/dist/tools/mcpSse.d.ts +43 -0
- package/dist/tools/mcpSse.js +110 -0
- package/dist/tools/registry/index.d.ts +9 -0
- package/dist/tools/registry/index.js +28 -0
- package/dist/tools/registry/middleware.d.ts +43 -0
- package/dist/tools/registry/middleware.js +220 -0
- package/dist/tools/registry/registry.d.ts +92 -0
- package/dist/tools/registry/registry.js +280 -0
- package/dist/tools/registry/types.d.ts +217 -0
- package/dist/tools/registry/types.js +49 -0
- package/dist/tools/test.d.ts +0 -0
- package/dist/tools/test.js +1 -0
- package/dist/tools/tools.d.ts +74 -0
- package/dist/tools/tools.js +133 -0
- package/dist/utils/logger.d.ts +25 -0
- package/dist/utils/logger.js +149 -0
- package/dist/utils/pretty-logger.d.ts +21 -0
- package/dist/utils/pretty-logger.js +248 -0
- package/dist/workflows/index.d.ts +118 -0
- package/dist/workflows/index.js +247 -0
- package/dist/workflows/loop.d.ts +0 -0
- package/dist/workflows/loop.js +1 -0
- package/dist/workflows/yaml-parser.d.ts +48 -0
- package/dist/workflows/yaml-parser.js +304 -0
- package/package.json +119 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generate Image - AI SDK Wrapper
|
|
4
|
+
*
|
|
5
|
+
* Provides generateImage function for image generation.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.generateImage = generateImage;
|
|
42
|
+
// Lazy load AI SDK
|
|
43
|
+
let aiSdk = null;
|
|
44
|
+
let aiSdkLoaded = false;
|
|
45
|
+
async function loadAISDK() {
|
|
46
|
+
if (aiSdkLoaded)
|
|
47
|
+
return aiSdk;
|
|
48
|
+
try {
|
|
49
|
+
aiSdk = await Promise.resolve().then(() => __importStar(require('ai')));
|
|
50
|
+
aiSdkLoaded = true;
|
|
51
|
+
return aiSdk;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Resolve model string to AI SDK image model instance
|
|
59
|
+
*/
|
|
60
|
+
async function resolveImageModel(modelString) {
|
|
61
|
+
let provider = 'openai';
|
|
62
|
+
let modelId = modelString;
|
|
63
|
+
if (modelString.includes('/')) {
|
|
64
|
+
const parts = modelString.split('/');
|
|
65
|
+
provider = parts[0].toLowerCase();
|
|
66
|
+
modelId = parts.slice(1).join('/');
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
if (modelString.startsWith('imagen'))
|
|
70
|
+
provider = 'google';
|
|
71
|
+
else if (modelString.startsWith('dall-e'))
|
|
72
|
+
provider = 'openai';
|
|
73
|
+
}
|
|
74
|
+
let providerModule;
|
|
75
|
+
try {
|
|
76
|
+
switch (provider) {
|
|
77
|
+
case 'openai':
|
|
78
|
+
providerModule = await Promise.resolve().then(() => __importStar(require('@ai-sdk/openai')));
|
|
79
|
+
return providerModule.openai.image(modelId);
|
|
80
|
+
case 'google':
|
|
81
|
+
providerModule = await Promise.resolve().then(() => __importStar(require('@ai-sdk/google')));
|
|
82
|
+
return providerModule.google.image(modelId);
|
|
83
|
+
default:
|
|
84
|
+
providerModule = await Promise.resolve().then(() => __importStar(require('@ai-sdk/openai')));
|
|
85
|
+
return providerModule.openai.image(modelId);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
throw new Error(`Failed to load image provider '${provider}': ${error.message}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Generate images using an image model.
|
|
94
|
+
*
|
|
95
|
+
* @example Generate with DALL-E
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const result = await generateImage({
|
|
98
|
+
* model: 'dall-e-3',
|
|
99
|
+
* prompt: 'A futuristic city at sunset',
|
|
100
|
+
* size: '1024x1024'
|
|
101
|
+
* });
|
|
102
|
+
*
|
|
103
|
+
* // Save the image
|
|
104
|
+
* fs.writeFileSync('image.png', result.images[0].uint8Array);
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @example Generate with Google Imagen
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const result = await generateImage({
|
|
110
|
+
* model: 'google/imagen-3',
|
|
111
|
+
* prompt: 'A beautiful landscape',
|
|
112
|
+
* aspectRatio: '16:9'
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
async function generateImage(options) {
|
|
117
|
+
const sdk = await loadAISDK();
|
|
118
|
+
if (!sdk) {
|
|
119
|
+
throw new Error('AI SDK not available. Install with: npm install ai @ai-sdk/openai');
|
|
120
|
+
}
|
|
121
|
+
const model = await resolveImageModel(options.model);
|
|
122
|
+
const result = await sdk.generateImage({
|
|
123
|
+
model,
|
|
124
|
+
prompt: options.prompt,
|
|
125
|
+
n: options.n,
|
|
126
|
+
size: options.size,
|
|
127
|
+
aspectRatio: options.aspectRatio,
|
|
128
|
+
seed: options.seed,
|
|
129
|
+
maxRetries: options.maxRetries,
|
|
130
|
+
abortSignal: options.abortSignal,
|
|
131
|
+
headers: options.headers,
|
|
132
|
+
providerOptions: options.providerOptions,
|
|
133
|
+
});
|
|
134
|
+
return {
|
|
135
|
+
images: result.images || [],
|
|
136
|
+
warnings: result.warnings,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate Object - AI SDK Wrapper
|
|
3
|
+
*
|
|
4
|
+
* Provides generateObject and streamObject functions for structured output generation.
|
|
5
|
+
*/
|
|
6
|
+
import type { Message } from './types';
|
|
7
|
+
export interface GenerateObjectOptions<T = unknown> {
|
|
8
|
+
/** Model to use */
|
|
9
|
+
model: string;
|
|
10
|
+
/** Schema for the output (Zod schema or JSON schema) */
|
|
11
|
+
schema: any;
|
|
12
|
+
/** Schema name for the output */
|
|
13
|
+
schemaName?: string;
|
|
14
|
+
/** Schema description */
|
|
15
|
+
schemaDescription?: string;
|
|
16
|
+
/** Output mode: 'object' | 'array' | 'enum' | 'no-schema' */
|
|
17
|
+
mode?: 'object' | 'array' | 'enum' | 'no-schema';
|
|
18
|
+
/** Simple text prompt */
|
|
19
|
+
prompt?: string;
|
|
20
|
+
/** Chat messages */
|
|
21
|
+
messages?: Message[];
|
|
22
|
+
/** System message */
|
|
23
|
+
system?: string;
|
|
24
|
+
/** Maximum tokens */
|
|
25
|
+
maxTokens?: number;
|
|
26
|
+
/** Temperature */
|
|
27
|
+
temperature?: number;
|
|
28
|
+
/** Top P */
|
|
29
|
+
topP?: number;
|
|
30
|
+
/** Maximum retries */
|
|
31
|
+
maxRetries?: number;
|
|
32
|
+
/** Abort signal */
|
|
33
|
+
abortSignal?: AbortSignal;
|
|
34
|
+
/** Additional headers */
|
|
35
|
+
headers?: Record<string, string>;
|
|
36
|
+
/** Callback on finish */
|
|
37
|
+
onFinish?: (result: GenerateObjectResult<T>) => void | Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
export interface GenerateObjectResult<T = unknown> {
|
|
40
|
+
/** Generated object */
|
|
41
|
+
object: T;
|
|
42
|
+
/** Token usage */
|
|
43
|
+
usage: {
|
|
44
|
+
promptTokens: number;
|
|
45
|
+
completionTokens: number;
|
|
46
|
+
totalTokens: number;
|
|
47
|
+
};
|
|
48
|
+
/** Finish reason */
|
|
49
|
+
finishReason: string;
|
|
50
|
+
/** Warnings */
|
|
51
|
+
warnings?: any[];
|
|
52
|
+
}
|
|
53
|
+
export interface StreamObjectOptions<T = unknown> extends GenerateObjectOptions<T> {
|
|
54
|
+
/** Callback for partial object updates */
|
|
55
|
+
onPartialObject?: (partial: Partial<T>) => void | Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
export interface StreamObjectResult<T = unknown> {
|
|
58
|
+
/** Async iterator for partial objects */
|
|
59
|
+
partialObjectStream: AsyncIterable<Partial<T>>;
|
|
60
|
+
/** Promise that resolves to the final object */
|
|
61
|
+
object: Promise<T>;
|
|
62
|
+
/** Promise that resolves to usage */
|
|
63
|
+
usage: Promise<{
|
|
64
|
+
promptTokens: number;
|
|
65
|
+
completionTokens: number;
|
|
66
|
+
totalTokens: number;
|
|
67
|
+
}>;
|
|
68
|
+
/** Promise that resolves to finish reason */
|
|
69
|
+
finishReason: Promise<string>;
|
|
70
|
+
/** Convert to Response for streaming */
|
|
71
|
+
toTextStreamResponse(options?: {
|
|
72
|
+
headers?: Record<string, string>;
|
|
73
|
+
}): Response;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Generate a structured object using a language model.
|
|
77
|
+
*
|
|
78
|
+
* @example With Zod schema
|
|
79
|
+
* ```typescript
|
|
80
|
+
* import { z } from 'zod';
|
|
81
|
+
*
|
|
82
|
+
* const result = await generateObject({
|
|
83
|
+
* model: 'gpt-4o',
|
|
84
|
+
* schema: z.object({
|
|
85
|
+
* name: z.string(),
|
|
86
|
+
* age: z.number()
|
|
87
|
+
* }),
|
|
88
|
+
* prompt: 'Generate a person'
|
|
89
|
+
* });
|
|
90
|
+
* console.log(result.object); // { name: 'John', age: 30 }
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @example With JSON schema
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const result = await generateObject({
|
|
96
|
+
* model: 'gpt-4o',
|
|
97
|
+
* schema: {
|
|
98
|
+
* type: 'object',
|
|
99
|
+
* properties: {
|
|
100
|
+
* name: { type: 'string' },
|
|
101
|
+
* age: { type: 'number' }
|
|
102
|
+
* },
|
|
103
|
+
* required: ['name', 'age']
|
|
104
|
+
* },
|
|
105
|
+
* prompt: 'Generate a person'
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare function generateObject<T = unknown>(options: GenerateObjectOptions<T>): Promise<GenerateObjectResult<T>>;
|
|
110
|
+
/**
|
|
111
|
+
* Stream a structured object using a language model.
|
|
112
|
+
*
|
|
113
|
+
* @example Streaming partial objects
|
|
114
|
+
* ```typescript
|
|
115
|
+
* import { z } from 'zod';
|
|
116
|
+
*
|
|
117
|
+
* const result = await streamObject({
|
|
118
|
+
* model: 'gpt-4o',
|
|
119
|
+
* schema: z.object({
|
|
120
|
+
* story: z.string(),
|
|
121
|
+
* characters: z.array(z.string())
|
|
122
|
+
* }),
|
|
123
|
+
* prompt: 'Write a short story',
|
|
124
|
+
* onPartialObject: (partial) => {
|
|
125
|
+
* console.log('Partial:', partial);
|
|
126
|
+
* }
|
|
127
|
+
* });
|
|
128
|
+
*
|
|
129
|
+
* const finalObject = await result.object;
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export declare function streamObject<T = unknown>(options: StreamObjectOptions<T>): Promise<StreamObjectResult<T>>;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generate Object - AI SDK Wrapper
|
|
4
|
+
*
|
|
5
|
+
* Provides generateObject and streamObject functions for structured output generation.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.generateObject = generateObject;
|
|
42
|
+
exports.streamObject = streamObject;
|
|
43
|
+
// Lazy load AI SDK
|
|
44
|
+
let aiSdk = null;
|
|
45
|
+
let aiSdkLoaded = false;
|
|
46
|
+
async function loadAISDK() {
|
|
47
|
+
if (aiSdkLoaded)
|
|
48
|
+
return aiSdk;
|
|
49
|
+
try {
|
|
50
|
+
aiSdk = await Promise.resolve().then(() => __importStar(require('ai')));
|
|
51
|
+
aiSdkLoaded = true;
|
|
52
|
+
return aiSdk;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolve model string to AI SDK model instance
|
|
60
|
+
*/
|
|
61
|
+
async function resolveModel(modelString) {
|
|
62
|
+
let provider = 'openai';
|
|
63
|
+
let modelId = modelString;
|
|
64
|
+
if (modelString.includes('/')) {
|
|
65
|
+
const parts = modelString.split('/');
|
|
66
|
+
provider = parts[0].toLowerCase();
|
|
67
|
+
modelId = parts.slice(1).join('/');
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
if (modelString.startsWith('claude'))
|
|
71
|
+
provider = 'anthropic';
|
|
72
|
+
else if (modelString.startsWith('gemini'))
|
|
73
|
+
provider = 'google';
|
|
74
|
+
}
|
|
75
|
+
let providerModule;
|
|
76
|
+
try {
|
|
77
|
+
switch (provider) {
|
|
78
|
+
case 'openai':
|
|
79
|
+
providerModule = await Promise.resolve().then(() => __importStar(require('@ai-sdk/openai')));
|
|
80
|
+
return providerModule.openai(modelId);
|
|
81
|
+
case 'anthropic':
|
|
82
|
+
providerModule = await Promise.resolve().then(() => __importStar(require('@ai-sdk/anthropic')));
|
|
83
|
+
return providerModule.anthropic(modelId);
|
|
84
|
+
case 'google':
|
|
85
|
+
providerModule = await Promise.resolve().then(() => __importStar(require('@ai-sdk/google')));
|
|
86
|
+
return providerModule.google(modelId);
|
|
87
|
+
default:
|
|
88
|
+
providerModule = await Promise.resolve().then(() => __importStar(require('@ai-sdk/openai')));
|
|
89
|
+
return providerModule.openai(modelId);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
throw new Error(`Failed to load provider '${provider}': ${error.message}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Generate a structured object using a language model.
|
|
98
|
+
*
|
|
99
|
+
* @example With Zod schema
|
|
100
|
+
* ```typescript
|
|
101
|
+
* import { z } from 'zod';
|
|
102
|
+
*
|
|
103
|
+
* const result = await generateObject({
|
|
104
|
+
* model: 'gpt-4o',
|
|
105
|
+
* schema: z.object({
|
|
106
|
+
* name: z.string(),
|
|
107
|
+
* age: z.number()
|
|
108
|
+
* }),
|
|
109
|
+
* prompt: 'Generate a person'
|
|
110
|
+
* });
|
|
111
|
+
* console.log(result.object); // { name: 'John', age: 30 }
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @example With JSON schema
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const result = await generateObject({
|
|
117
|
+
* model: 'gpt-4o',
|
|
118
|
+
* schema: {
|
|
119
|
+
* type: 'object',
|
|
120
|
+
* properties: {
|
|
121
|
+
* name: { type: 'string' },
|
|
122
|
+
* age: { type: 'number' }
|
|
123
|
+
* },
|
|
124
|
+
* required: ['name', 'age']
|
|
125
|
+
* },
|
|
126
|
+
* prompt: 'Generate a person'
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
async function generateObject(options) {
|
|
131
|
+
const sdk = await loadAISDK();
|
|
132
|
+
if (!sdk) {
|
|
133
|
+
throw new Error('AI SDK not available. Install with: npm install ai @ai-sdk/openai');
|
|
134
|
+
}
|
|
135
|
+
const model = await resolveModel(options.model);
|
|
136
|
+
const result = await sdk.generateObject({
|
|
137
|
+
model,
|
|
138
|
+
schema: options.schema,
|
|
139
|
+
schemaName: options.schemaName,
|
|
140
|
+
schemaDescription: options.schemaDescription,
|
|
141
|
+
mode: options.mode,
|
|
142
|
+
prompt: options.prompt,
|
|
143
|
+
messages: options.messages,
|
|
144
|
+
system: options.system,
|
|
145
|
+
maxTokens: options.maxTokens,
|
|
146
|
+
temperature: options.temperature,
|
|
147
|
+
topP: options.topP,
|
|
148
|
+
maxRetries: options.maxRetries,
|
|
149
|
+
abortSignal: options.abortSignal,
|
|
150
|
+
headers: options.headers,
|
|
151
|
+
onFinish: options.onFinish,
|
|
152
|
+
});
|
|
153
|
+
return {
|
|
154
|
+
object: result.object,
|
|
155
|
+
usage: result.usage || { promptTokens: 0, completionTokens: 0, totalTokens: 0 },
|
|
156
|
+
finishReason: result.finishReason || 'stop',
|
|
157
|
+
warnings: result.warnings,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Stream a structured object using a language model.
|
|
162
|
+
*
|
|
163
|
+
* @example Streaming partial objects
|
|
164
|
+
* ```typescript
|
|
165
|
+
* import { z } from 'zod';
|
|
166
|
+
*
|
|
167
|
+
* const result = await streamObject({
|
|
168
|
+
* model: 'gpt-4o',
|
|
169
|
+
* schema: z.object({
|
|
170
|
+
* story: z.string(),
|
|
171
|
+
* characters: z.array(z.string())
|
|
172
|
+
* }),
|
|
173
|
+
* prompt: 'Write a short story',
|
|
174
|
+
* onPartialObject: (partial) => {
|
|
175
|
+
* console.log('Partial:', partial);
|
|
176
|
+
* }
|
|
177
|
+
* });
|
|
178
|
+
*
|
|
179
|
+
* const finalObject = await result.object;
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
async function streamObject(options) {
|
|
183
|
+
const sdk = await loadAISDK();
|
|
184
|
+
if (!sdk) {
|
|
185
|
+
throw new Error('AI SDK not available. Install with: npm install ai @ai-sdk/openai');
|
|
186
|
+
}
|
|
187
|
+
const model = await resolveModel(options.model);
|
|
188
|
+
const result = sdk.streamObject({
|
|
189
|
+
model,
|
|
190
|
+
schema: options.schema,
|
|
191
|
+
schemaName: options.schemaName,
|
|
192
|
+
schemaDescription: options.schemaDescription,
|
|
193
|
+
mode: options.mode,
|
|
194
|
+
prompt: options.prompt,
|
|
195
|
+
messages: options.messages,
|
|
196
|
+
system: options.system,
|
|
197
|
+
maxTokens: options.maxTokens,
|
|
198
|
+
temperature: options.temperature,
|
|
199
|
+
topP: options.topP,
|
|
200
|
+
maxRetries: options.maxRetries,
|
|
201
|
+
abortSignal: options.abortSignal,
|
|
202
|
+
headers: options.headers,
|
|
203
|
+
onFinish: options.onFinish,
|
|
204
|
+
});
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate Text - AI SDK Wrapper
|
|
3
|
+
*
|
|
4
|
+
* Provides generateText and streamText functions that wrap the AI SDK.
|
|
5
|
+
* These are the primary text generation primitives.
|
|
6
|
+
*/
|
|
7
|
+
import type { Message } from './types';
|
|
8
|
+
export interface GenerateTextOptions {
|
|
9
|
+
/** Model to use (e.g., 'gpt-4o', 'claude-3-sonnet', 'openai/gpt-4o') */
|
|
10
|
+
model: string;
|
|
11
|
+
/** Simple text prompt */
|
|
12
|
+
prompt?: string;
|
|
13
|
+
/** Chat messages (alternative to prompt) */
|
|
14
|
+
messages?: Message[];
|
|
15
|
+
/** System message */
|
|
16
|
+
system?: string;
|
|
17
|
+
/** Tools available to the model */
|
|
18
|
+
tools?: Record<string, any>;
|
|
19
|
+
/** Tool choice strategy */
|
|
20
|
+
toolChoice?: 'auto' | 'none' | 'required' | {
|
|
21
|
+
type: 'tool';
|
|
22
|
+
toolName: string;
|
|
23
|
+
};
|
|
24
|
+
/** Maximum tokens to generate */
|
|
25
|
+
maxTokens?: number;
|
|
26
|
+
/** Temperature (0-2) */
|
|
27
|
+
temperature?: number;
|
|
28
|
+
/** Top P (0-1) */
|
|
29
|
+
topP?: number;
|
|
30
|
+
/** Top K */
|
|
31
|
+
topK?: number;
|
|
32
|
+
/** Presence penalty */
|
|
33
|
+
presencePenalty?: number;
|
|
34
|
+
/** Frequency penalty */
|
|
35
|
+
frequencyPenalty?: number;
|
|
36
|
+
/** Stop sequences */
|
|
37
|
+
stopSequences?: string[];
|
|
38
|
+
/** Seed for reproducibility */
|
|
39
|
+
seed?: number;
|
|
40
|
+
/** Maximum retries */
|
|
41
|
+
maxRetries?: number;
|
|
42
|
+
/** Abort signal */
|
|
43
|
+
abortSignal?: AbortSignal;
|
|
44
|
+
/** Additional headers */
|
|
45
|
+
headers?: Record<string, string>;
|
|
46
|
+
/** Maximum steps for tool calling */
|
|
47
|
+
maxSteps?: number;
|
|
48
|
+
/** Callback on step finish */
|
|
49
|
+
onStepFinish?: (step: StepResult) => void | Promise<void>;
|
|
50
|
+
/** Callback on finish */
|
|
51
|
+
onFinish?: (result: GenerateTextResult) => void | Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
export interface StepResult {
|
|
54
|
+
text: string;
|
|
55
|
+
toolCalls: ToolCall[];
|
|
56
|
+
toolResults: ToolResult[];
|
|
57
|
+
usage: TokenUsage;
|
|
58
|
+
finishReason: string;
|
|
59
|
+
}
|
|
60
|
+
export interface ToolCall {
|
|
61
|
+
toolCallId: string;
|
|
62
|
+
toolName: string;
|
|
63
|
+
args: any;
|
|
64
|
+
}
|
|
65
|
+
export interface ToolResult {
|
|
66
|
+
toolCallId: string;
|
|
67
|
+
toolName: string;
|
|
68
|
+
result: any;
|
|
69
|
+
}
|
|
70
|
+
export interface TokenUsage {
|
|
71
|
+
promptTokens: number;
|
|
72
|
+
completionTokens: number;
|
|
73
|
+
totalTokens: number;
|
|
74
|
+
}
|
|
75
|
+
export interface GenerateTextResult {
|
|
76
|
+
/** Generated text */
|
|
77
|
+
text: string;
|
|
78
|
+
/** Tool calls made */
|
|
79
|
+
toolCalls: ToolCall[];
|
|
80
|
+
/** Tool results */
|
|
81
|
+
toolResults: ToolResult[];
|
|
82
|
+
/** Token usage */
|
|
83
|
+
usage: TokenUsage;
|
|
84
|
+
/** Finish reason */
|
|
85
|
+
finishReason: string;
|
|
86
|
+
/** All steps (for multi-step) */
|
|
87
|
+
steps: StepResult[];
|
|
88
|
+
/** Response messages */
|
|
89
|
+
responseMessages: Message[];
|
|
90
|
+
/** Warnings */
|
|
91
|
+
warnings?: any[];
|
|
92
|
+
}
|
|
93
|
+
export interface StreamTextOptions extends GenerateTextOptions {
|
|
94
|
+
/** Callback for each text chunk */
|
|
95
|
+
onChunk?: (chunk: TextStreamPart) => void | Promise<void>;
|
|
96
|
+
}
|
|
97
|
+
export interface TextStreamPart {
|
|
98
|
+
type: 'text-delta' | 'tool-call' | 'tool-result' | 'finish' | 'error';
|
|
99
|
+
textDelta?: string;
|
|
100
|
+
toolCall?: ToolCall;
|
|
101
|
+
toolResult?: ToolResult;
|
|
102
|
+
finishReason?: string;
|
|
103
|
+
usage?: TokenUsage;
|
|
104
|
+
error?: Error;
|
|
105
|
+
}
|
|
106
|
+
export interface StreamTextResult {
|
|
107
|
+
/** Async iterator for text chunks */
|
|
108
|
+
textStream: AsyncIterable<string>;
|
|
109
|
+
/** Full text stream with all events */
|
|
110
|
+
fullStream: AsyncIterable<TextStreamPart>;
|
|
111
|
+
/** Promise that resolves to the final text */
|
|
112
|
+
text: Promise<string>;
|
|
113
|
+
/** Promise that resolves to tool calls */
|
|
114
|
+
toolCalls: Promise<ToolCall[]>;
|
|
115
|
+
/** Promise that resolves to tool results */
|
|
116
|
+
toolResults: Promise<ToolResult[]>;
|
|
117
|
+
/** Promise that resolves to usage */
|
|
118
|
+
usage: Promise<TokenUsage>;
|
|
119
|
+
/** Promise that resolves to finish reason */
|
|
120
|
+
finishReason: Promise<string>;
|
|
121
|
+
/** Promise that resolves to all steps */
|
|
122
|
+
steps: Promise<StepResult[]>;
|
|
123
|
+
/** Promise that resolves to response messages */
|
|
124
|
+
responseMessages: Promise<Message[]>;
|
|
125
|
+
/** Convert to Response object for streaming */
|
|
126
|
+
toDataStreamResponse(options?: {
|
|
127
|
+
headers?: Record<string, string>;
|
|
128
|
+
}): Response;
|
|
129
|
+
/** Pipe to a writable stream */
|
|
130
|
+
pipeDataStreamToResponse(response: any, options?: {
|
|
131
|
+
headers?: Record<string, string>;
|
|
132
|
+
}): void;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Generate text using a language model.
|
|
136
|
+
*
|
|
137
|
+
* @example Simple prompt
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const result = await generateText({
|
|
140
|
+
* model: 'gpt-4o',
|
|
141
|
+
* prompt: 'What is the capital of France?'
|
|
142
|
+
* });
|
|
143
|
+
* console.log(result.text);
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* @example Chat messages
|
|
147
|
+
* ```typescript
|
|
148
|
+
* const result = await generateText({
|
|
149
|
+
* model: 'claude-3-sonnet',
|
|
150
|
+
* messages: [
|
|
151
|
+
* { role: 'user', content: 'Hello!' }
|
|
152
|
+
* ]
|
|
153
|
+
* });
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @example With tools
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const result = await generateText({
|
|
159
|
+
* model: 'gpt-4o',
|
|
160
|
+
* prompt: 'What is the weather in Paris?',
|
|
161
|
+
* tools: {
|
|
162
|
+
* getWeather: {
|
|
163
|
+
* description: 'Get weather for a city',
|
|
164
|
+
* parameters: z.object({ city: z.string() }),
|
|
165
|
+
* execute: async ({ city }) => `Weather in ${city}: 20°C`
|
|
166
|
+
* }
|
|
167
|
+
* },
|
|
168
|
+
* maxSteps: 5
|
|
169
|
+
* });
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
export declare function generateText(options: GenerateTextOptions): Promise<GenerateTextResult>;
|
|
173
|
+
/**
|
|
174
|
+
* Stream text using a language model.
|
|
175
|
+
*
|
|
176
|
+
* @example Simple streaming
|
|
177
|
+
* ```typescript
|
|
178
|
+
* const result = await streamText({
|
|
179
|
+
* model: 'gpt-4o',
|
|
180
|
+
* prompt: 'Write a poem about AI'
|
|
181
|
+
* });
|
|
182
|
+
*
|
|
183
|
+
* for await (const chunk of result.textStream) {
|
|
184
|
+
* process.stdout.write(chunk);
|
|
185
|
+
* }
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @example With tools and multi-step
|
|
189
|
+
* ```typescript
|
|
190
|
+
* const result = await streamText({
|
|
191
|
+
* model: 'gpt-4o',
|
|
192
|
+
* prompt: 'Search for AI news and summarize',
|
|
193
|
+
* tools: { webSearch },
|
|
194
|
+
* maxSteps: 5,
|
|
195
|
+
* onChunk: (chunk) => console.log(chunk)
|
|
196
|
+
* });
|
|
197
|
+
*
|
|
198
|
+
* const text = await result.text;
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
export declare function streamText(options: StreamTextOptions): Promise<StreamTextResult>;
|