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,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telemetry - Usage tracking and analytics
|
|
3
|
+
*/
|
|
4
|
+
export interface TelemetryEvent {
|
|
5
|
+
name: string;
|
|
6
|
+
timestamp: number;
|
|
7
|
+
properties?: Record<string, any>;
|
|
8
|
+
userId?: string;
|
|
9
|
+
sessionId?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface TelemetryConfig {
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
endpoint?: string;
|
|
14
|
+
batchSize?: number;
|
|
15
|
+
flushInterval?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Telemetry collector for tracking usage
|
|
19
|
+
*/
|
|
20
|
+
export declare class TelemetryCollector {
|
|
21
|
+
private events;
|
|
22
|
+
private enabled;
|
|
23
|
+
private endpoint?;
|
|
24
|
+
private batchSize;
|
|
25
|
+
private flushInterval;
|
|
26
|
+
private flushTimer?;
|
|
27
|
+
private userId?;
|
|
28
|
+
private sessionId;
|
|
29
|
+
constructor(config?: TelemetryConfig);
|
|
30
|
+
private checkEnabled;
|
|
31
|
+
/**
|
|
32
|
+
* Track an event
|
|
33
|
+
*/
|
|
34
|
+
track(name: string, properties?: Record<string, any>): void;
|
|
35
|
+
/**
|
|
36
|
+
* Track feature usage
|
|
37
|
+
*/
|
|
38
|
+
trackFeatureUsage(feature: string, metadata?: Record<string, any>): void;
|
|
39
|
+
/**
|
|
40
|
+
* Track agent execution
|
|
41
|
+
*/
|
|
42
|
+
trackAgentExecution(agentName: string, duration: number, success: boolean): void;
|
|
43
|
+
/**
|
|
44
|
+
* Track tool call
|
|
45
|
+
*/
|
|
46
|
+
trackToolCall(toolName: string, duration: number, success: boolean): void;
|
|
47
|
+
/**
|
|
48
|
+
* Track LLM call
|
|
49
|
+
*/
|
|
50
|
+
trackLLMCall(provider: string, model: string, tokens: number, duration: number): void;
|
|
51
|
+
/**
|
|
52
|
+
* Track error
|
|
53
|
+
*/
|
|
54
|
+
trackError(error: string, context?: Record<string, any>): void;
|
|
55
|
+
/**
|
|
56
|
+
* Set user ID
|
|
57
|
+
*/
|
|
58
|
+
setUserId(userId: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Flush events
|
|
61
|
+
*/
|
|
62
|
+
flush(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Enable telemetry
|
|
65
|
+
*/
|
|
66
|
+
enable(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Disable telemetry
|
|
69
|
+
*/
|
|
70
|
+
disable(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Check if telemetry is enabled
|
|
73
|
+
*/
|
|
74
|
+
isEnabled(): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Get pending events count
|
|
77
|
+
*/
|
|
78
|
+
getPendingCount(): number;
|
|
79
|
+
/**
|
|
80
|
+
* Cleanup resources
|
|
81
|
+
*/
|
|
82
|
+
cleanup(): void;
|
|
83
|
+
private startFlushTimer;
|
|
84
|
+
private stopFlushTimer;
|
|
85
|
+
private generateSessionId;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get global telemetry instance
|
|
89
|
+
*/
|
|
90
|
+
export declare function getTelemetry(): TelemetryCollector;
|
|
91
|
+
/**
|
|
92
|
+
* Enable telemetry
|
|
93
|
+
*/
|
|
94
|
+
export declare function enableTelemetry(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Disable telemetry
|
|
97
|
+
*/
|
|
98
|
+
export declare function disableTelemetry(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Cleanup telemetry resources
|
|
101
|
+
*/
|
|
102
|
+
export declare function cleanupTelemetry(): void;
|
|
103
|
+
/**
|
|
104
|
+
* AgentTelemetry - Agent-focused telemetry wrapper
|
|
105
|
+
*
|
|
106
|
+
* @example Simple usage (3 lines)
|
|
107
|
+
* ```typescript
|
|
108
|
+
* import { Agent } from 'praisonai';
|
|
109
|
+
*
|
|
110
|
+
* // Enable telemetry on agent
|
|
111
|
+
* const agent = new Agent({
|
|
112
|
+
* instructions: 'You are helpful',
|
|
113
|
+
* telemetry: true // Opt-in telemetry
|
|
114
|
+
* });
|
|
115
|
+
* await agent.chat('Hello!'); // Automatically tracked
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @example Manual tracking
|
|
119
|
+
* ```typescript
|
|
120
|
+
* import { AgentTelemetry } from 'praisonai';
|
|
121
|
+
*
|
|
122
|
+
* const telemetry = new AgentTelemetry('MyAgent');
|
|
123
|
+
* const result = await telemetry.trackChat(async () => {
|
|
124
|
+
* return await agent.chat('Hello!');
|
|
125
|
+
* });
|
|
126
|
+
* console.log(telemetry.getStats());
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export interface AgentStats {
|
|
130
|
+
totalChats: number;
|
|
131
|
+
successfulChats: number;
|
|
132
|
+
failedChats: number;
|
|
133
|
+
totalDuration: number;
|
|
134
|
+
avgDuration: number;
|
|
135
|
+
totalTokens: number;
|
|
136
|
+
toolCalls: number;
|
|
137
|
+
}
|
|
138
|
+
export declare class AgentTelemetry {
|
|
139
|
+
private agentName;
|
|
140
|
+
private collector;
|
|
141
|
+
private stats;
|
|
142
|
+
constructor(agentName: string, config?: TelemetryConfig);
|
|
143
|
+
/**
|
|
144
|
+
* Track a chat execution
|
|
145
|
+
*/
|
|
146
|
+
trackChat<T>(fn: () => Promise<T>): Promise<T>;
|
|
147
|
+
/**
|
|
148
|
+
* Track a tool call
|
|
149
|
+
*/
|
|
150
|
+
trackToolCall(toolName: string, duration: number, success: boolean): void;
|
|
151
|
+
/**
|
|
152
|
+
* Track token usage
|
|
153
|
+
*/
|
|
154
|
+
trackTokens(tokens: number): void;
|
|
155
|
+
/**
|
|
156
|
+
* Get agent statistics
|
|
157
|
+
*/
|
|
158
|
+
getStats(): AgentStats;
|
|
159
|
+
/**
|
|
160
|
+
* Reset statistics
|
|
161
|
+
*/
|
|
162
|
+
resetStats(): void;
|
|
163
|
+
/**
|
|
164
|
+
* Get success rate
|
|
165
|
+
*/
|
|
166
|
+
getSuccessRate(): number;
|
|
167
|
+
/**
|
|
168
|
+
* Print summary
|
|
169
|
+
*/
|
|
170
|
+
printSummary(): void;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Create agent telemetry
|
|
174
|
+
*/
|
|
175
|
+
export declare function createAgentTelemetry(agentName: string, config?: TelemetryConfig): AgentTelemetry;
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Telemetry - Usage tracking and analytics
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AgentTelemetry = exports.TelemetryCollector = void 0;
|
|
7
|
+
exports.getTelemetry = getTelemetry;
|
|
8
|
+
exports.enableTelemetry = enableTelemetry;
|
|
9
|
+
exports.disableTelemetry = disableTelemetry;
|
|
10
|
+
exports.cleanupTelemetry = cleanupTelemetry;
|
|
11
|
+
exports.createAgentTelemetry = createAgentTelemetry;
|
|
12
|
+
/**
|
|
13
|
+
* Telemetry collector for tracking usage
|
|
14
|
+
*/
|
|
15
|
+
class TelemetryCollector {
|
|
16
|
+
constructor(config = {}) {
|
|
17
|
+
this.events = [];
|
|
18
|
+
this.enabled = config.enabled ?? this.checkEnabled();
|
|
19
|
+
this.endpoint = config.endpoint;
|
|
20
|
+
this.batchSize = config.batchSize ?? 100;
|
|
21
|
+
this.flushInterval = config.flushInterval ?? 60000;
|
|
22
|
+
this.sessionId = this.generateSessionId();
|
|
23
|
+
if (this.enabled && this.flushInterval > 0) {
|
|
24
|
+
this.startFlushTimer();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
checkEnabled() {
|
|
28
|
+
const disabled = process.env.PRAISONAI_TELEMETRY_DISABLED === 'true' ||
|
|
29
|
+
process.env.PRAISONAI_DISABLE_TELEMETRY === 'true' ||
|
|
30
|
+
process.env.DO_NOT_TRACK === 'true';
|
|
31
|
+
return !disabled;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Track an event
|
|
35
|
+
*/
|
|
36
|
+
track(name, properties) {
|
|
37
|
+
if (!this.enabled)
|
|
38
|
+
return;
|
|
39
|
+
const event = {
|
|
40
|
+
name,
|
|
41
|
+
timestamp: Date.now(),
|
|
42
|
+
properties,
|
|
43
|
+
userId: this.userId,
|
|
44
|
+
sessionId: this.sessionId
|
|
45
|
+
};
|
|
46
|
+
this.events.push(event);
|
|
47
|
+
if (this.events.length >= this.batchSize) {
|
|
48
|
+
this.flush();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Track feature usage
|
|
53
|
+
*/
|
|
54
|
+
trackFeatureUsage(feature, metadata) {
|
|
55
|
+
this.track('feature_usage', { feature, ...metadata });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Track agent execution
|
|
59
|
+
*/
|
|
60
|
+
trackAgentExecution(agentName, duration, success) {
|
|
61
|
+
this.track('agent_execution', { agentName, duration, success });
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Track tool call
|
|
65
|
+
*/
|
|
66
|
+
trackToolCall(toolName, duration, success) {
|
|
67
|
+
this.track('tool_call', { toolName, duration, success });
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Track LLM call
|
|
71
|
+
*/
|
|
72
|
+
trackLLMCall(provider, model, tokens, duration) {
|
|
73
|
+
this.track('llm_call', { provider, model, tokens, duration });
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Track error
|
|
77
|
+
*/
|
|
78
|
+
trackError(error, context) {
|
|
79
|
+
this.track('error', { error, ...context });
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Set user ID
|
|
83
|
+
*/
|
|
84
|
+
setUserId(userId) {
|
|
85
|
+
this.userId = userId;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Flush events
|
|
89
|
+
*/
|
|
90
|
+
async flush() {
|
|
91
|
+
if (this.events.length === 0)
|
|
92
|
+
return;
|
|
93
|
+
const eventsToSend = [...this.events];
|
|
94
|
+
this.events = [];
|
|
95
|
+
if (this.endpoint) {
|
|
96
|
+
try {
|
|
97
|
+
await fetch(this.endpoint, {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
headers: { 'Content-Type': 'application/json' },
|
|
100
|
+
body: JSON.stringify({ events: eventsToSend })
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
// Silently fail - never break user applications
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Enable telemetry
|
|
110
|
+
*/
|
|
111
|
+
enable() {
|
|
112
|
+
this.enabled = true;
|
|
113
|
+
this.startFlushTimer();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Disable telemetry
|
|
117
|
+
*/
|
|
118
|
+
disable() {
|
|
119
|
+
this.enabled = false;
|
|
120
|
+
this.stopFlushTimer();
|
|
121
|
+
this.events = [];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Check if telemetry is enabled
|
|
125
|
+
*/
|
|
126
|
+
isEnabled() {
|
|
127
|
+
return this.enabled;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Get pending events count
|
|
131
|
+
*/
|
|
132
|
+
getPendingCount() {
|
|
133
|
+
return this.events.length;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Cleanup resources
|
|
137
|
+
*/
|
|
138
|
+
cleanup() {
|
|
139
|
+
this.stopFlushTimer();
|
|
140
|
+
this.flush();
|
|
141
|
+
}
|
|
142
|
+
startFlushTimer() {
|
|
143
|
+
if (this.flushTimer)
|
|
144
|
+
return;
|
|
145
|
+
this.flushTimer = setInterval(() => this.flush(), this.flushInterval);
|
|
146
|
+
}
|
|
147
|
+
stopFlushTimer() {
|
|
148
|
+
if (this.flushTimer) {
|
|
149
|
+
clearInterval(this.flushTimer);
|
|
150
|
+
this.flushTimer = undefined;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
generateSessionId() {
|
|
154
|
+
return `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.TelemetryCollector = TelemetryCollector;
|
|
158
|
+
// Global telemetry instance
|
|
159
|
+
let globalTelemetry = null;
|
|
160
|
+
/**
|
|
161
|
+
* Get global telemetry instance
|
|
162
|
+
*/
|
|
163
|
+
function getTelemetry() {
|
|
164
|
+
if (!globalTelemetry) {
|
|
165
|
+
globalTelemetry = new TelemetryCollector();
|
|
166
|
+
}
|
|
167
|
+
return globalTelemetry;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Enable telemetry
|
|
171
|
+
*/
|
|
172
|
+
function enableTelemetry() {
|
|
173
|
+
getTelemetry().enable();
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Disable telemetry
|
|
177
|
+
*/
|
|
178
|
+
function disableTelemetry() {
|
|
179
|
+
getTelemetry().disable();
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Cleanup telemetry resources
|
|
183
|
+
*/
|
|
184
|
+
function cleanupTelemetry() {
|
|
185
|
+
if (globalTelemetry) {
|
|
186
|
+
globalTelemetry.cleanup();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
class AgentTelemetry {
|
|
190
|
+
constructor(agentName, config) {
|
|
191
|
+
this.stats = {
|
|
192
|
+
totalChats: 0,
|
|
193
|
+
successfulChats: 0,
|
|
194
|
+
failedChats: 0,
|
|
195
|
+
totalDuration: 0,
|
|
196
|
+
avgDuration: 0,
|
|
197
|
+
totalTokens: 0,
|
|
198
|
+
toolCalls: 0
|
|
199
|
+
};
|
|
200
|
+
this.agentName = agentName;
|
|
201
|
+
this.collector = config ? new TelemetryCollector(config) : getTelemetry();
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Track a chat execution
|
|
205
|
+
*/
|
|
206
|
+
async trackChat(fn) {
|
|
207
|
+
const startTime = Date.now();
|
|
208
|
+
this.stats.totalChats++;
|
|
209
|
+
try {
|
|
210
|
+
const result = await fn();
|
|
211
|
+
const duration = Date.now() - startTime;
|
|
212
|
+
this.stats.successfulChats++;
|
|
213
|
+
this.stats.totalDuration += duration;
|
|
214
|
+
this.stats.avgDuration = this.stats.totalDuration / this.stats.totalChats;
|
|
215
|
+
this.collector.trackAgentExecution(this.agentName, duration, true);
|
|
216
|
+
return result;
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
const duration = Date.now() - startTime;
|
|
220
|
+
this.stats.failedChats++;
|
|
221
|
+
this.stats.totalDuration += duration;
|
|
222
|
+
this.stats.avgDuration = this.stats.totalDuration / this.stats.totalChats;
|
|
223
|
+
this.collector.trackAgentExecution(this.agentName, duration, false);
|
|
224
|
+
this.collector.trackError(String(error), { agent: this.agentName });
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Track a tool call
|
|
230
|
+
*/
|
|
231
|
+
trackToolCall(toolName, duration, success) {
|
|
232
|
+
this.stats.toolCalls++;
|
|
233
|
+
this.collector.trackToolCall(toolName, duration, success);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Track token usage
|
|
237
|
+
*/
|
|
238
|
+
trackTokens(tokens) {
|
|
239
|
+
this.stats.totalTokens += tokens;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Get agent statistics
|
|
243
|
+
*/
|
|
244
|
+
getStats() {
|
|
245
|
+
return { ...this.stats };
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Reset statistics
|
|
249
|
+
*/
|
|
250
|
+
resetStats() {
|
|
251
|
+
this.stats = {
|
|
252
|
+
totalChats: 0,
|
|
253
|
+
successfulChats: 0,
|
|
254
|
+
failedChats: 0,
|
|
255
|
+
totalDuration: 0,
|
|
256
|
+
avgDuration: 0,
|
|
257
|
+
totalTokens: 0,
|
|
258
|
+
toolCalls: 0
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Get success rate
|
|
263
|
+
*/
|
|
264
|
+
getSuccessRate() {
|
|
265
|
+
if (this.stats.totalChats === 0)
|
|
266
|
+
return 0;
|
|
267
|
+
return (this.stats.successfulChats / this.stats.totalChats) * 100;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Print summary
|
|
271
|
+
*/
|
|
272
|
+
printSummary() {
|
|
273
|
+
console.log(`\n📊 Agent Telemetry: ${this.agentName}`);
|
|
274
|
+
console.log(` Total chats: ${this.stats.totalChats}`);
|
|
275
|
+
console.log(` Success rate: ${this.getSuccessRate().toFixed(1)}%`);
|
|
276
|
+
console.log(` Avg duration: ${this.stats.avgDuration.toFixed(0)}ms`);
|
|
277
|
+
console.log(` Tool calls: ${this.stats.toolCalls}`);
|
|
278
|
+
console.log(` Total tokens: ${this.stats.totalTokens}`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
exports.AgentTelemetry = AgentTelemetry;
|
|
282
|
+
/**
|
|
283
|
+
* Create agent telemetry
|
|
284
|
+
*/
|
|
285
|
+
function createAgentTelemetry(agentName, config) {
|
|
286
|
+
return new AgentTelemetry(agentName, config);
|
|
287
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BaseTool } from './base';
|
|
2
|
+
export interface ArxivPaper {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
authors: string[];
|
|
6
|
+
summary: string;
|
|
7
|
+
published: string;
|
|
8
|
+
updated: string;
|
|
9
|
+
link: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class ArxivSearchTool extends BaseTool<{
|
|
12
|
+
query: string;
|
|
13
|
+
maxResults?: number;
|
|
14
|
+
}, ArxivPaper[]> {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
private parser;
|
|
18
|
+
constructor();
|
|
19
|
+
run(params: {
|
|
20
|
+
query: string;
|
|
21
|
+
maxResults?: number;
|
|
22
|
+
}): Promise<ArxivPaper[]>;
|
|
23
|
+
}
|
|
24
|
+
export declare class ArxivDownloadTool extends BaseTool<{
|
|
25
|
+
paperId: string;
|
|
26
|
+
}, Buffer> {
|
|
27
|
+
name: string;
|
|
28
|
+
description: string;
|
|
29
|
+
run(params: {
|
|
30
|
+
paperId: string;
|
|
31
|
+
}): Promise<Buffer>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ArxivDownloadTool = exports.ArxivSearchTool = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
9
|
+
const base_1 = require("./base");
|
|
10
|
+
class ArxivSearchTool extends base_1.BaseTool {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.name = 'arxiv-search';
|
|
14
|
+
this.description = 'Search for academic papers on arXiv';
|
|
15
|
+
this.parser = new fast_xml_parser_1.XMLParser({
|
|
16
|
+
ignoreAttributes: false,
|
|
17
|
+
attributeNamePrefix: '@_'
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async run(params) {
|
|
21
|
+
const { query, maxResults = 10 } = params;
|
|
22
|
+
try {
|
|
23
|
+
const response = await axios_1.default.get(`http://export.arxiv.org/api/query`, {
|
|
24
|
+
params: {
|
|
25
|
+
search_query: encodeURIComponent(query),
|
|
26
|
+
max_results: maxResults,
|
|
27
|
+
sortBy: 'lastUpdatedDate',
|
|
28
|
+
sortOrder: 'descending'
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const parsed = this.parser.parse(response.data);
|
|
32
|
+
const entries = parsed.feed.entry;
|
|
33
|
+
if (!entries) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
// Handle both single and multiple entries
|
|
37
|
+
const entriesArray = Array.isArray(entries) ? entries : [entries];
|
|
38
|
+
return entriesArray.map((entry) => ({
|
|
39
|
+
id: entry.id.split('/abs/')[1],
|
|
40
|
+
title: entry.title.replace(/\s+/g, ' ').trim(),
|
|
41
|
+
authors: Array.isArray(entry.author)
|
|
42
|
+
? entry.author.map((a) => a.name)
|
|
43
|
+
: [entry.author.name],
|
|
44
|
+
summary: entry.summary.replace(/\s+/g, ' ').trim(),
|
|
45
|
+
published: entry.published,
|
|
46
|
+
updated: entry.updated,
|
|
47
|
+
link: entry.id
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (error instanceof Error) {
|
|
52
|
+
throw new Error(`Failed to search arXiv: ${error.message}`);
|
|
53
|
+
}
|
|
54
|
+
throw new Error('Failed to search arXiv: Unknown error');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.ArxivSearchTool = ArxivSearchTool;
|
|
59
|
+
class ArxivDownloadTool extends base_1.BaseTool {
|
|
60
|
+
constructor() {
|
|
61
|
+
super(...arguments);
|
|
62
|
+
this.name = 'arxiv-download';
|
|
63
|
+
this.description = 'Download PDF of an arXiv paper';
|
|
64
|
+
}
|
|
65
|
+
async run(params) {
|
|
66
|
+
const { paperId } = params;
|
|
67
|
+
try {
|
|
68
|
+
const response = await axios_1.default.get(`https://arxiv.org/pdf/${paperId}.pdf`, {
|
|
69
|
+
responseType: 'arraybuffer'
|
|
70
|
+
});
|
|
71
|
+
return Buffer.from(response.data);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
if (error instanceof Error) {
|
|
75
|
+
throw new Error(`Failed to download paper: ${error.message}`);
|
|
76
|
+
}
|
|
77
|
+
throw new Error('Failed to download paper: Unknown error');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.ArxivDownloadTool = ArxivDownloadTool;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BaseTool - Abstract base class for creating custom tools (plugins)
|
|
3
|
+
*
|
|
4
|
+
* This provides the same extensibility pattern as Python's BaseTool.
|
|
5
|
+
* External developers can create plugins by extending BaseTool.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { BaseTool } from 'praisonai';
|
|
9
|
+
*
|
|
10
|
+
* class MyTool extends BaseTool {
|
|
11
|
+
* name = 'my_tool';
|
|
12
|
+
* description = 'Does something useful';
|
|
13
|
+
*
|
|
14
|
+
* async run(params: { query: string }): Promise<string> {
|
|
15
|
+
* return `Result for ${params.query}`;
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
export interface ToolResult<T = any> {
|
|
20
|
+
output: T;
|
|
21
|
+
success: boolean;
|
|
22
|
+
error?: string;
|
|
23
|
+
metadata?: Record<string, any>;
|
|
24
|
+
}
|
|
25
|
+
export declare class ToolValidationError extends Error {
|
|
26
|
+
constructor(message: string);
|
|
27
|
+
}
|
|
28
|
+
export interface ToolParameters {
|
|
29
|
+
type: 'object';
|
|
30
|
+
properties: Record<string, {
|
|
31
|
+
type: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
enum?: string[];
|
|
34
|
+
default?: any;
|
|
35
|
+
}>;
|
|
36
|
+
required?: string[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Abstract base class for all PraisonAI tools.
|
|
40
|
+
*
|
|
41
|
+
* Subclass this to create custom tools that can be:
|
|
42
|
+
* - Used directly by agents
|
|
43
|
+
* - Distributed as npm packages (plugins)
|
|
44
|
+
* - Auto-discovered via package.json
|
|
45
|
+
*/
|
|
46
|
+
export declare abstract class BaseTool<TParams = any, TResult = any> {
|
|
47
|
+
/** Unique identifier for the tool */
|
|
48
|
+
abstract name: string;
|
|
49
|
+
/** Human-readable description (used by LLM) */
|
|
50
|
+
abstract description: string;
|
|
51
|
+
/** Tool version string */
|
|
52
|
+
version: string;
|
|
53
|
+
/** JSON Schema for parameters */
|
|
54
|
+
parameters?: ToolParameters;
|
|
55
|
+
/**
|
|
56
|
+
* Execute the tool with given arguments.
|
|
57
|
+
* This method must be implemented by subclasses.
|
|
58
|
+
*/
|
|
59
|
+
abstract run(params: TParams): Promise<TResult> | TResult;
|
|
60
|
+
/**
|
|
61
|
+
* Allow tool to be called directly like a function.
|
|
62
|
+
*/
|
|
63
|
+
execute(params: TParams): Promise<TResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Execute tool with error handling, returning ToolResult.
|
|
66
|
+
*/
|
|
67
|
+
safeRun(params: TParams): Promise<ToolResult<TResult>>;
|
|
68
|
+
/**
|
|
69
|
+
* Get OpenAI-compatible function schema for this tool.
|
|
70
|
+
*/
|
|
71
|
+
getSchema(): {
|
|
72
|
+
type: 'function';
|
|
73
|
+
function: {
|
|
74
|
+
name: string;
|
|
75
|
+
description: string;
|
|
76
|
+
parameters: any;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Validate the tool configuration.
|
|
81
|
+
*/
|
|
82
|
+
validate(): boolean;
|
|
83
|
+
toString(): string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Validate any tool-like object.
|
|
87
|
+
*/
|
|
88
|
+
export declare function validateTool(tool: any): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Create a simple tool from a function (alternative to class-based approach)
|
|
91
|
+
*/
|
|
92
|
+
export declare function createTool<TParams = any, TResult = any>(config: {
|
|
93
|
+
name: string;
|
|
94
|
+
description: string;
|
|
95
|
+
parameters?: ToolParameters;
|
|
96
|
+
run: (params: TParams) => Promise<TResult> | TResult;
|
|
97
|
+
}): BaseTool<TParams, TResult>;
|