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,293 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Enhanced Agent - Agent with session management, provider abstraction, and tool support
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.EnhancedAgent = void 0;
|
|
7
|
+
const backend_resolver_1 = require("../llm/backend-resolver");
|
|
8
|
+
const session_1 = require("../session");
|
|
9
|
+
const decorator_1 = require("../tools/decorator");
|
|
10
|
+
const logger_1 = require("../utils/logger");
|
|
11
|
+
/**
|
|
12
|
+
* Enhanced Agent with full feature support
|
|
13
|
+
*/
|
|
14
|
+
class EnhancedAgent {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.provider = null;
|
|
17
|
+
this.providerPromise = null;
|
|
18
|
+
this.name = config.name || `Agent_${Math.random().toString(36).substr(2, 9)}`;
|
|
19
|
+
this.instructions = config.instructions;
|
|
20
|
+
this.verbose = config.verbose ?? true;
|
|
21
|
+
this.stream = config.stream ?? true;
|
|
22
|
+
this.maxToolCalls = config.maxToolCalls ?? 10;
|
|
23
|
+
this.temperature = config.temperature ?? 0.7;
|
|
24
|
+
this.maxTokens = config.maxTokens;
|
|
25
|
+
this.outputSchema = config.outputSchema;
|
|
26
|
+
// Store model string for lazy provider initialization
|
|
27
|
+
this.llmModel = config.llm || 'openai/gpt-4o-mini';
|
|
28
|
+
// Initialize session
|
|
29
|
+
if (config.session) {
|
|
30
|
+
this.session = config.session;
|
|
31
|
+
}
|
|
32
|
+
else if (config.sessionId) {
|
|
33
|
+
this.session = (0, session_1.getSessionManager)().getOrCreate(config.sessionId);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.session = (0, session_1.getSessionManager)().create();
|
|
37
|
+
}
|
|
38
|
+
this.sessionId = this.session.id;
|
|
39
|
+
// Initialize tool registry
|
|
40
|
+
this.toolRegistry = new decorator_1.ToolRegistry();
|
|
41
|
+
if (config.tools) {
|
|
42
|
+
this.registerTools(config.tools);
|
|
43
|
+
}
|
|
44
|
+
logger_1.Logger.setVerbose(this.verbose);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the LLM provider (lazy initialization with AI SDK backend)
|
|
48
|
+
*/
|
|
49
|
+
async getProvider() {
|
|
50
|
+
if (this.provider) {
|
|
51
|
+
return this.provider;
|
|
52
|
+
}
|
|
53
|
+
if (!this.providerPromise) {
|
|
54
|
+
this.providerPromise = (async () => {
|
|
55
|
+
const result = await (0, backend_resolver_1.resolveBackend)(this.llmModel, {
|
|
56
|
+
attribution: {
|
|
57
|
+
agentId: this.name,
|
|
58
|
+
sessionId: this.sessionId,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
this.provider = result.provider;
|
|
62
|
+
return result.provider;
|
|
63
|
+
})();
|
|
64
|
+
}
|
|
65
|
+
return this.providerPromise;
|
|
66
|
+
}
|
|
67
|
+
registerTools(tools) {
|
|
68
|
+
if (!tools)
|
|
69
|
+
return;
|
|
70
|
+
for (const t of tools) {
|
|
71
|
+
if (t instanceof decorator_1.FunctionTool) {
|
|
72
|
+
this.toolRegistry.register(t);
|
|
73
|
+
}
|
|
74
|
+
else if (typeof t === 'function') {
|
|
75
|
+
// Convert function to tool
|
|
76
|
+
const funcName = t.name || `function_${Math.random().toString(36).substr(2, 9)}`;
|
|
77
|
+
this.toolRegistry.register((0, decorator_1.tool)({
|
|
78
|
+
name: funcName,
|
|
79
|
+
description: `Function ${funcName}`,
|
|
80
|
+
execute: t,
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
else if (typeof t === 'object' && 'execute' in t) {
|
|
84
|
+
// Tool config object
|
|
85
|
+
this.toolRegistry.register((0, decorator_1.tool)({
|
|
86
|
+
name: t.name,
|
|
87
|
+
description: t.description,
|
|
88
|
+
parameters: t.parameters,
|
|
89
|
+
execute: t.execute,
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Add a tool to the agent
|
|
96
|
+
*/
|
|
97
|
+
addTool(t) {
|
|
98
|
+
if (t instanceof decorator_1.FunctionTool) {
|
|
99
|
+
this.toolRegistry.register(t);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.toolRegistry.register((0, decorator_1.tool)({
|
|
103
|
+
name: t.name,
|
|
104
|
+
description: t.description,
|
|
105
|
+
parameters: t.parameters,
|
|
106
|
+
execute: t.execute,
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Get all registered tools
|
|
113
|
+
*/
|
|
114
|
+
getTools() {
|
|
115
|
+
return this.toolRegistry.list();
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Chat with the agent
|
|
119
|
+
*/
|
|
120
|
+
async chat(prompt, options = {}) {
|
|
121
|
+
const run = this.session.createRun().start();
|
|
122
|
+
const trace = run.createTrace({ name: 'chat' }).start();
|
|
123
|
+
try {
|
|
124
|
+
// Add user message to session
|
|
125
|
+
this.session.addMessage({ role: 'user', content: prompt });
|
|
126
|
+
// Build messages array
|
|
127
|
+
const messages = [
|
|
128
|
+
{ role: 'system', content: this.instructions },
|
|
129
|
+
...this.session.getMessagesForLLM(),
|
|
130
|
+
];
|
|
131
|
+
// Get tool definitions
|
|
132
|
+
const tools = this.toolRegistry.list().length > 0
|
|
133
|
+
? this.toolRegistry.getDefinitions()
|
|
134
|
+
: undefined;
|
|
135
|
+
let result;
|
|
136
|
+
let fullText = '';
|
|
137
|
+
let allToolCalls = [];
|
|
138
|
+
let iterations = 0;
|
|
139
|
+
// Tool calling loop
|
|
140
|
+
while (iterations < this.maxToolCalls) {
|
|
141
|
+
iterations++;
|
|
142
|
+
if (options.stream && !tools && options.onToken) {
|
|
143
|
+
// Streaming without tools
|
|
144
|
+
const provider = await this.getProvider();
|
|
145
|
+
const stream = await provider.streamText({
|
|
146
|
+
messages,
|
|
147
|
+
temperature: options.temperature ?? this.temperature,
|
|
148
|
+
maxTokens: options.maxTokens ?? this.maxTokens,
|
|
149
|
+
onToken: options.onToken,
|
|
150
|
+
});
|
|
151
|
+
let usage = { promptTokens: 0, completionTokens: 0, totalTokens: 0 };
|
|
152
|
+
for await (const chunk of stream) {
|
|
153
|
+
if (chunk.text)
|
|
154
|
+
fullText += chunk.text;
|
|
155
|
+
if (chunk.usage)
|
|
156
|
+
usage = { ...usage, ...chunk.usage };
|
|
157
|
+
}
|
|
158
|
+
result = {
|
|
159
|
+
text: fullText,
|
|
160
|
+
usage,
|
|
161
|
+
finishReason: 'stop',
|
|
162
|
+
};
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
else if (options.outputSchema) {
|
|
166
|
+
// Structured output
|
|
167
|
+
const provider = await this.getProvider();
|
|
168
|
+
const objResult = await provider.generateObject({
|
|
169
|
+
messages,
|
|
170
|
+
schema: options.outputSchema ?? this.outputSchema,
|
|
171
|
+
temperature: options.temperature ?? this.temperature,
|
|
172
|
+
maxTokens: options.maxTokens ?? this.maxTokens,
|
|
173
|
+
});
|
|
174
|
+
result = {
|
|
175
|
+
text: JSON.stringify(objResult.object),
|
|
176
|
+
usage: objResult.usage,
|
|
177
|
+
finishReason: 'stop',
|
|
178
|
+
};
|
|
179
|
+
fullText = result.text;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
// Regular generation with potential tool calls
|
|
184
|
+
const provider = await this.getProvider();
|
|
185
|
+
result = await provider.generateText({
|
|
186
|
+
messages,
|
|
187
|
+
temperature: options.temperature ?? this.temperature,
|
|
188
|
+
maxTokens: options.maxTokens ?? this.maxTokens,
|
|
189
|
+
tools,
|
|
190
|
+
});
|
|
191
|
+
if (result.toolCalls && result.toolCalls.length > 0) {
|
|
192
|
+
allToolCalls.push(...result.toolCalls);
|
|
193
|
+
// Add assistant message with tool calls
|
|
194
|
+
messages.push({
|
|
195
|
+
role: 'assistant',
|
|
196
|
+
content: result.text || null,
|
|
197
|
+
tool_calls: result.toolCalls,
|
|
198
|
+
});
|
|
199
|
+
// Execute tool calls
|
|
200
|
+
for (const tc of result.toolCalls) {
|
|
201
|
+
const toolTrace = trace.createChild({ name: `tool:${tc.function.name}` }).start();
|
|
202
|
+
try {
|
|
203
|
+
const toolFn = this.toolRegistry.get(tc.function.name);
|
|
204
|
+
if (!toolFn) {
|
|
205
|
+
throw new Error(`Tool '${tc.function.name}' not found`);
|
|
206
|
+
}
|
|
207
|
+
const args = JSON.parse(tc.function.arguments);
|
|
208
|
+
const toolResult = await toolFn.execute(args, {
|
|
209
|
+
agentName: this.name,
|
|
210
|
+
sessionId: this.sessionId,
|
|
211
|
+
runId: run.id,
|
|
212
|
+
});
|
|
213
|
+
const resultStr = typeof toolResult === 'string'
|
|
214
|
+
? toolResult
|
|
215
|
+
: JSON.stringify(toolResult);
|
|
216
|
+
messages.push({
|
|
217
|
+
role: 'tool',
|
|
218
|
+
content: resultStr,
|
|
219
|
+
tool_call_id: tc.id,
|
|
220
|
+
});
|
|
221
|
+
toolTrace.complete({ result: resultStr });
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
messages.push({
|
|
225
|
+
role: 'tool',
|
|
226
|
+
content: `Error: ${error.message}`,
|
|
227
|
+
tool_call_id: tc.id,
|
|
228
|
+
});
|
|
229
|
+
toolTrace.fail(error);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// Continue loop to get final response
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
// No tool calls, we have our final response
|
|
236
|
+
fullText = result.text;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// Add assistant message to session
|
|
241
|
+
this.session.addMessage({
|
|
242
|
+
role: 'assistant',
|
|
243
|
+
content: fullText,
|
|
244
|
+
tool_calls: allToolCalls.length > 0 ? allToolCalls : undefined,
|
|
245
|
+
});
|
|
246
|
+
trace.complete({ responseLength: fullText.length });
|
|
247
|
+
run.complete();
|
|
248
|
+
// Parse structured output if schema was provided
|
|
249
|
+
let structured;
|
|
250
|
+
if (options.outputSchema) {
|
|
251
|
+
try {
|
|
252
|
+
structured = JSON.parse(fullText);
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
// Not valid JSON
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
text: fullText,
|
|
260
|
+
structured,
|
|
261
|
+
toolCalls: allToolCalls.length > 0 ? allToolCalls : undefined,
|
|
262
|
+
usage: result.usage,
|
|
263
|
+
runId: run.id,
|
|
264
|
+
sessionId: this.sessionId,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
trace.fail(error);
|
|
269
|
+
run.fail(error);
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Start method for compatibility
|
|
275
|
+
*/
|
|
276
|
+
async start(prompt, options) {
|
|
277
|
+
const result = await this.chat(prompt, options);
|
|
278
|
+
return result.text;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Get the session
|
|
282
|
+
*/
|
|
283
|
+
getSession() {
|
|
284
|
+
return this.session;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Clear conversation history
|
|
288
|
+
*/
|
|
289
|
+
clearHistory() {
|
|
290
|
+
this.session.clearMessages();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
exports.EnhancedAgent = EnhancedAgent;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Handoff - Transfer conversations between agents
|
|
3
|
+
*/
|
|
4
|
+
import type { EnhancedAgent } from './enhanced';
|
|
5
|
+
export interface HandoffConfig {
|
|
6
|
+
agent: EnhancedAgent;
|
|
7
|
+
name?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
condition?: (context: HandoffContext) => boolean;
|
|
10
|
+
transformContext?: (messages: any[]) => any[];
|
|
11
|
+
}
|
|
12
|
+
export interface HandoffContext {
|
|
13
|
+
messages: any[];
|
|
14
|
+
lastMessage: string;
|
|
15
|
+
topic?: string;
|
|
16
|
+
metadata?: Record<string, any>;
|
|
17
|
+
}
|
|
18
|
+
export interface HandoffResult {
|
|
19
|
+
handedOffTo: string;
|
|
20
|
+
response: string;
|
|
21
|
+
context: HandoffContext;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Handoff class - Represents a handoff target
|
|
25
|
+
*/
|
|
26
|
+
export declare class Handoff {
|
|
27
|
+
readonly targetAgent: EnhancedAgent;
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly description: string;
|
|
30
|
+
readonly condition?: (context: HandoffContext) => boolean;
|
|
31
|
+
readonly transformContext?: (messages: any[]) => any[];
|
|
32
|
+
constructor(config: HandoffConfig);
|
|
33
|
+
/**
|
|
34
|
+
* Check if handoff should be triggered
|
|
35
|
+
*/
|
|
36
|
+
shouldTrigger(context: HandoffContext): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Execute the handoff
|
|
39
|
+
*/
|
|
40
|
+
execute(context: HandoffContext): Promise<HandoffResult>;
|
|
41
|
+
/**
|
|
42
|
+
* Get tool definition for LLM
|
|
43
|
+
*/
|
|
44
|
+
getToolDefinition(): {
|
|
45
|
+
name: string;
|
|
46
|
+
description: string;
|
|
47
|
+
parameters: any;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Create a handoff configuration
|
|
52
|
+
*/
|
|
53
|
+
export declare function handoff(config: HandoffConfig): Handoff;
|
|
54
|
+
/**
|
|
55
|
+
* Handoff filters - Common condition functions
|
|
56
|
+
*/
|
|
57
|
+
export declare const handoffFilters: {
|
|
58
|
+
/**
|
|
59
|
+
* Trigger handoff based on topic keywords
|
|
60
|
+
*/
|
|
61
|
+
topic: (keywords: string | string[]) => (context: HandoffContext) => boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Trigger handoff based on metadata
|
|
64
|
+
*/
|
|
65
|
+
metadata: (key: string, value: any) => (context: HandoffContext) => boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Always trigger
|
|
68
|
+
*/
|
|
69
|
+
always: () => () => boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Never trigger (manual only)
|
|
72
|
+
*/
|
|
73
|
+
never: () => () => boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Combine multiple conditions with AND
|
|
76
|
+
*/
|
|
77
|
+
and: (...conditions: Array<(context: HandoffContext) => boolean>) => (context: HandoffContext) => boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Combine multiple conditions with OR
|
|
80
|
+
*/
|
|
81
|
+
or: (...conditions: Array<(context: HandoffContext) => boolean>) => (context: HandoffContext) => boolean;
|
|
82
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Agent Handoff - Transfer conversations between agents
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.handoffFilters = exports.Handoff = void 0;
|
|
7
|
+
exports.handoff = handoff;
|
|
8
|
+
/**
|
|
9
|
+
* Handoff class - Represents a handoff target
|
|
10
|
+
*/
|
|
11
|
+
class Handoff {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.targetAgent = config.agent;
|
|
14
|
+
this.name = config.name || `handoff_to_${config.agent.name}`;
|
|
15
|
+
this.description = config.description || `Transfer conversation to ${config.agent.name}`;
|
|
16
|
+
this.condition = config.condition;
|
|
17
|
+
this.transformContext = config.transformContext;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Check if handoff should be triggered
|
|
21
|
+
*/
|
|
22
|
+
shouldTrigger(context) {
|
|
23
|
+
if (this.condition) {
|
|
24
|
+
return this.condition(context);
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Execute the handoff
|
|
30
|
+
*/
|
|
31
|
+
async execute(context) {
|
|
32
|
+
let messages = context.messages;
|
|
33
|
+
if (this.transformContext) {
|
|
34
|
+
messages = this.transformContext(messages);
|
|
35
|
+
}
|
|
36
|
+
// Transfer context to target agent
|
|
37
|
+
const response = await this.targetAgent.chat(context.lastMessage);
|
|
38
|
+
return {
|
|
39
|
+
handedOffTo: this.targetAgent.name,
|
|
40
|
+
response: response.text,
|
|
41
|
+
context: {
|
|
42
|
+
...context,
|
|
43
|
+
messages,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get tool definition for LLM
|
|
49
|
+
*/
|
|
50
|
+
getToolDefinition() {
|
|
51
|
+
return {
|
|
52
|
+
name: this.name,
|
|
53
|
+
description: this.description,
|
|
54
|
+
parameters: {
|
|
55
|
+
type: 'object',
|
|
56
|
+
properties: {
|
|
57
|
+
reason: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
description: 'Reason for the handoff',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
required: [],
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.Handoff = Handoff;
|
|
68
|
+
/**
|
|
69
|
+
* Create a handoff configuration
|
|
70
|
+
*/
|
|
71
|
+
function handoff(config) {
|
|
72
|
+
return new Handoff(config);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Handoff filters - Common condition functions
|
|
76
|
+
*/
|
|
77
|
+
exports.handoffFilters = {
|
|
78
|
+
/**
|
|
79
|
+
* Trigger handoff based on topic keywords
|
|
80
|
+
*/
|
|
81
|
+
topic: (keywords) => {
|
|
82
|
+
const keywordList = Array.isArray(keywords) ? keywords : [keywords];
|
|
83
|
+
return (context) => {
|
|
84
|
+
const lastMessage = context.lastMessage.toLowerCase();
|
|
85
|
+
return keywordList.some(kw => lastMessage.includes(kw.toLowerCase()));
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* Trigger handoff based on metadata
|
|
90
|
+
*/
|
|
91
|
+
metadata: (key, value) => {
|
|
92
|
+
return (context) => {
|
|
93
|
+
return context.metadata?.[key] === value;
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
/**
|
|
97
|
+
* Always trigger
|
|
98
|
+
*/
|
|
99
|
+
always: () => {
|
|
100
|
+
return () => true;
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* Never trigger (manual only)
|
|
104
|
+
*/
|
|
105
|
+
never: () => {
|
|
106
|
+
return () => false;
|
|
107
|
+
},
|
|
108
|
+
/**
|
|
109
|
+
* Combine multiple conditions with AND
|
|
110
|
+
*/
|
|
111
|
+
and: (...conditions) => {
|
|
112
|
+
return (context) => {
|
|
113
|
+
return conditions.every(cond => cond(context));
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
/**
|
|
117
|
+
* Combine multiple conditions with OR
|
|
118
|
+
*/
|
|
119
|
+
or: (...conditions) => {
|
|
120
|
+
return (context) => {
|
|
121
|
+
return conditions.some(cond => cond(context));
|
|
122
|
+
};
|
|
123
|
+
},
|
|
124
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ImageAgent - Agent for image generation and analysis
|
|
3
|
+
*/
|
|
4
|
+
export interface ImageGenerationConfig {
|
|
5
|
+
prompt: string;
|
|
6
|
+
size?: '256x256' | '512x512' | '1024x1024' | '1792x1024' | '1024x1792';
|
|
7
|
+
quality?: 'standard' | 'hd';
|
|
8
|
+
style?: 'vivid' | 'natural';
|
|
9
|
+
n?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ImageAnalysisConfig {
|
|
12
|
+
imageUrl: string;
|
|
13
|
+
prompt?: string;
|
|
14
|
+
detail?: 'low' | 'high' | 'auto';
|
|
15
|
+
}
|
|
16
|
+
export interface ImageAgentConfig {
|
|
17
|
+
name?: string;
|
|
18
|
+
llm?: string;
|
|
19
|
+
imageModel?: string;
|
|
20
|
+
verbose?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* ImageAgent - Agent for image generation and analysis
|
|
24
|
+
*/
|
|
25
|
+
export declare class ImageAgent {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
private provider;
|
|
28
|
+
private providerPromise;
|
|
29
|
+
private llmModel;
|
|
30
|
+
private imageModel;
|
|
31
|
+
private verbose;
|
|
32
|
+
constructor(config?: ImageAgentConfig);
|
|
33
|
+
/**
|
|
34
|
+
* Get the LLM provider (lazy initialization with AI SDK backend)
|
|
35
|
+
*/
|
|
36
|
+
private getProvider;
|
|
37
|
+
/**
|
|
38
|
+
* Analyze an image
|
|
39
|
+
*/
|
|
40
|
+
analyze(config: ImageAnalysisConfig): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Generate an image (requires OpenAI DALL-E)
|
|
43
|
+
*/
|
|
44
|
+
generate(config: ImageGenerationConfig): Promise<string[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Chat with image context
|
|
47
|
+
*/
|
|
48
|
+
chat(prompt: string, imageUrl?: string): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Compare two images
|
|
51
|
+
*/
|
|
52
|
+
compare(imageUrl1: string, imageUrl2: string, prompt?: string): Promise<string>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create an ImageAgent
|
|
56
|
+
*/
|
|
57
|
+
export declare function createImageAgent(config?: ImageAgentConfig): ImageAgent;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ImageAgent - Agent for image generation and analysis
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ImageAgent = void 0;
|
|
7
|
+
exports.createImageAgent = createImageAgent;
|
|
8
|
+
const backend_resolver_1 = require("../llm/backend-resolver");
|
|
9
|
+
/**
|
|
10
|
+
* ImageAgent - Agent for image generation and analysis
|
|
11
|
+
*/
|
|
12
|
+
class ImageAgent {
|
|
13
|
+
constructor(config = {}) {
|
|
14
|
+
this.provider = null;
|
|
15
|
+
this.providerPromise = null;
|
|
16
|
+
this.name = config.name || `ImageAgent_${Math.random().toString(36).substr(2, 9)}`;
|
|
17
|
+
this.llmModel = config.llm || 'openai/gpt-4o-mini';
|
|
18
|
+
this.imageModel = config.imageModel || 'dall-e-3';
|
|
19
|
+
this.verbose = config.verbose ?? false;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the LLM provider (lazy initialization with AI SDK backend)
|
|
23
|
+
*/
|
|
24
|
+
async getProvider() {
|
|
25
|
+
if (this.provider) {
|
|
26
|
+
return this.provider;
|
|
27
|
+
}
|
|
28
|
+
if (!this.providerPromise) {
|
|
29
|
+
this.providerPromise = (async () => {
|
|
30
|
+
const result = await (0, backend_resolver_1.resolveBackend)(this.llmModel, {
|
|
31
|
+
attribution: { agentId: this.name },
|
|
32
|
+
});
|
|
33
|
+
this.provider = result.provider;
|
|
34
|
+
return result.provider;
|
|
35
|
+
})();
|
|
36
|
+
}
|
|
37
|
+
return this.providerPromise;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Analyze an image
|
|
41
|
+
*/
|
|
42
|
+
async analyze(config) {
|
|
43
|
+
const prompt = config.prompt || 'Describe this image in detail.';
|
|
44
|
+
const messages = [
|
|
45
|
+
{
|
|
46
|
+
role: 'user',
|
|
47
|
+
content: [
|
|
48
|
+
{ type: 'text', text: prompt },
|
|
49
|
+
{
|
|
50
|
+
type: 'image_url',
|
|
51
|
+
image_url: {
|
|
52
|
+
url: config.imageUrl,
|
|
53
|
+
detail: config.detail || 'auto'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
];
|
|
59
|
+
const provider = await this.getProvider();
|
|
60
|
+
const result = await provider.generateText({ messages });
|
|
61
|
+
if (this.verbose) {
|
|
62
|
+
console.log(`[ImageAgent] Analysis: ${result.text.substring(0, 100)}...`);
|
|
63
|
+
}
|
|
64
|
+
return result.text;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Generate an image (requires OpenAI DALL-E)
|
|
68
|
+
*/
|
|
69
|
+
async generate(config) {
|
|
70
|
+
// This would require direct OpenAI API call for image generation
|
|
71
|
+
// For now, return a placeholder
|
|
72
|
+
if (this.verbose) {
|
|
73
|
+
console.log(`[ImageAgent] Generating image: ${config.prompt}`);
|
|
74
|
+
}
|
|
75
|
+
throw new Error('Image generation requires direct OpenAI API integration. Use the OpenAI SDK directly for DALL-E.');
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Chat with image context
|
|
79
|
+
*/
|
|
80
|
+
async chat(prompt, imageUrl) {
|
|
81
|
+
if (imageUrl) {
|
|
82
|
+
return this.analyze({ imageUrl, prompt });
|
|
83
|
+
}
|
|
84
|
+
const provider = await this.getProvider();
|
|
85
|
+
const result = await provider.generateText({
|
|
86
|
+
messages: [{ role: 'user', content: prompt }]
|
|
87
|
+
});
|
|
88
|
+
return result.text;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Compare two images
|
|
92
|
+
*/
|
|
93
|
+
async compare(imageUrl1, imageUrl2, prompt) {
|
|
94
|
+
const comparePrompt = prompt || 'Compare these two images and describe the differences and similarities.';
|
|
95
|
+
const messages = [
|
|
96
|
+
{
|
|
97
|
+
role: 'user',
|
|
98
|
+
content: [
|
|
99
|
+
{ type: 'text', text: comparePrompt },
|
|
100
|
+
{ type: 'image_url', image_url: { url: imageUrl1 } },
|
|
101
|
+
{ type: 'image_url', image_url: { url: imageUrl2 } }
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
];
|
|
105
|
+
const provider = await this.getProvider();
|
|
106
|
+
const result = await provider.generateText({ messages });
|
|
107
|
+
return result.text;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.ImageAgent = ImageAgent;
|
|
111
|
+
/**
|
|
112
|
+
* Create an ImageAgent
|
|
113
|
+
*/
|
|
114
|
+
function createImageAgent(config) {
|
|
115
|
+
return new ImageAgent(config);
|
|
116
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Module - Core agent classes for PraisonAI
|
|
3
|
+
*
|
|
4
|
+
* The primary exports are:
|
|
5
|
+
* - Agent: Single agent with instructions, tools, and optional persistence
|
|
6
|
+
* - Agents: Multi-agent orchestration (alias for PraisonAIAgents)
|
|
7
|
+
* - Router: Simplified keyword/pattern-based routing
|
|
8
|
+
* - Workflow: Step-based workflow execution (from workflows module)
|
|
9
|
+
*/
|
|
10
|
+
export { Agent, PraisonAIAgents, Agents } from './simple';
|
|
11
|
+
export type { SimpleAgentConfig, PraisonAIAgentsConfig } from './simple';
|
|
12
|
+
export { Router, RouterAgent, createRouter, routeConditions } from './router';
|
|
13
|
+
export type { RouterConfig, RouteConfig, RouteContext, SimpleRouterConfig, SimpleRouteConfig } from './router';
|
|
14
|
+
export { Task } from './types';
|
|
15
|
+
export type { TaskConfig, AgentConfig as TaskAgentConfig } from './types';
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Task mode is no longer needed. Use Agent with role/goal/backstory instead.
|
|
18
|
+
*/
|
|
19
|
+
export declare function setTaskMode(enabled: boolean): void;
|