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,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Voice - Abstract class for voice/TTS integrations
|
|
3
|
+
* Matches mastra's MastraVoice pattern
|
|
4
|
+
*/
|
|
5
|
+
export interface VoiceConfig {
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
model?: string;
|
|
8
|
+
voice?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface SpeakOptions {
|
|
11
|
+
voice?: string;
|
|
12
|
+
speed?: number;
|
|
13
|
+
pitch?: number;
|
|
14
|
+
format?: 'mp3' | 'wav' | 'ogg' | 'opus';
|
|
15
|
+
}
|
|
16
|
+
export interface ListenOptions {
|
|
17
|
+
language?: string;
|
|
18
|
+
model?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface Speaker {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
language?: string;
|
|
24
|
+
gender?: 'male' | 'female' | 'neutral';
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Abstract base class for voice providers
|
|
28
|
+
*/
|
|
29
|
+
export declare abstract class BaseVoiceProvider {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
protected apiKey?: string;
|
|
32
|
+
protected defaultVoice?: string;
|
|
33
|
+
constructor(config: VoiceConfig & {
|
|
34
|
+
name?: string;
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Convert text to speech
|
|
38
|
+
*/
|
|
39
|
+
abstract speak(text: string, options?: SpeakOptions): Promise<Buffer | ReadableStream>;
|
|
40
|
+
/**
|
|
41
|
+
* Convert speech to text
|
|
42
|
+
*/
|
|
43
|
+
abstract listen(audio: Buffer | ReadableStream, options?: ListenOptions): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Get available voices/speakers
|
|
46
|
+
*/
|
|
47
|
+
abstract getSpeakers(): Promise<Speaker[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Check if provider is available
|
|
50
|
+
*/
|
|
51
|
+
abstract isAvailable(): Promise<boolean>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* OpenAI Voice Provider (TTS and Whisper)
|
|
55
|
+
*/
|
|
56
|
+
export declare class OpenAIVoiceProvider extends BaseVoiceProvider {
|
|
57
|
+
private baseUrl;
|
|
58
|
+
constructor(config?: VoiceConfig);
|
|
59
|
+
speak(text: string, options?: SpeakOptions): Promise<Buffer>;
|
|
60
|
+
listen(audio: Buffer | ReadableStream, options?: ListenOptions): Promise<string>;
|
|
61
|
+
getSpeakers(): Promise<Speaker[]>;
|
|
62
|
+
isAvailable(): Promise<boolean>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* ElevenLabs Voice Provider
|
|
66
|
+
*/
|
|
67
|
+
export declare class ElevenLabsVoiceProvider extends BaseVoiceProvider {
|
|
68
|
+
private baseUrl;
|
|
69
|
+
constructor(config?: VoiceConfig);
|
|
70
|
+
speak(text: string, options?: SpeakOptions): Promise<Buffer>;
|
|
71
|
+
listen(_audio: Buffer | ReadableStream, _options?: ListenOptions): Promise<string>;
|
|
72
|
+
getSpeakers(): Promise<Speaker[]>;
|
|
73
|
+
isAvailable(): Promise<boolean>;
|
|
74
|
+
}
|
|
75
|
+
export declare function createOpenAIVoice(config?: VoiceConfig): OpenAIVoiceProvider;
|
|
76
|
+
export declare function createElevenLabsVoice(config?: VoiceConfig): ElevenLabsVoiceProvider;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base Voice - Abstract class for voice/TTS integrations
|
|
4
|
+
* Matches mastra's MastraVoice pattern
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ElevenLabsVoiceProvider = exports.OpenAIVoiceProvider = exports.BaseVoiceProvider = void 0;
|
|
8
|
+
exports.createOpenAIVoice = createOpenAIVoice;
|
|
9
|
+
exports.createElevenLabsVoice = createElevenLabsVoice;
|
|
10
|
+
/**
|
|
11
|
+
* Abstract base class for voice providers
|
|
12
|
+
*/
|
|
13
|
+
class BaseVoiceProvider {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
this.name = config.name || 'VoiceProvider';
|
|
16
|
+
this.apiKey = config.apiKey;
|
|
17
|
+
this.defaultVoice = config.voice;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.BaseVoiceProvider = BaseVoiceProvider;
|
|
21
|
+
/**
|
|
22
|
+
* OpenAI Voice Provider (TTS and Whisper)
|
|
23
|
+
*/
|
|
24
|
+
class OpenAIVoiceProvider extends BaseVoiceProvider {
|
|
25
|
+
constructor(config = {}) {
|
|
26
|
+
super({ ...config, name: 'OpenAIVoice' });
|
|
27
|
+
this.apiKey = config.apiKey || process.env.OPENAI_API_KEY;
|
|
28
|
+
this.defaultVoice = config.voice || 'alloy';
|
|
29
|
+
this.baseUrl = 'https://api.openai.com/v1';
|
|
30
|
+
}
|
|
31
|
+
async speak(text, options) {
|
|
32
|
+
if (!this.apiKey) {
|
|
33
|
+
throw new Error('OpenAI API key required for TTS');
|
|
34
|
+
}
|
|
35
|
+
const response = await fetch(`${this.baseUrl}/audio/speech`, {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
headers: {
|
|
38
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
39
|
+
'Content-Type': 'application/json'
|
|
40
|
+
},
|
|
41
|
+
body: JSON.stringify({
|
|
42
|
+
model: 'tts-1',
|
|
43
|
+
input: text,
|
|
44
|
+
voice: options?.voice || this.defaultVoice,
|
|
45
|
+
speed: options?.speed || 1.0,
|
|
46
|
+
response_format: options?.format || 'mp3'
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
const error = await response.text();
|
|
51
|
+
throw new Error(`OpenAI TTS error: ${response.status} - ${error}`);
|
|
52
|
+
}
|
|
53
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
54
|
+
return Buffer.from(arrayBuffer);
|
|
55
|
+
}
|
|
56
|
+
async listen(audio, options) {
|
|
57
|
+
if (!this.apiKey) {
|
|
58
|
+
throw new Error('OpenAI API key required for Whisper');
|
|
59
|
+
}
|
|
60
|
+
const formData = new FormData();
|
|
61
|
+
// Convert Buffer to Blob
|
|
62
|
+
const audioBlob = audio instanceof Buffer
|
|
63
|
+
? new Blob([new Uint8Array(audio)], { type: 'audio/mp3' })
|
|
64
|
+
: audio;
|
|
65
|
+
formData.append('file', audioBlob, 'audio.mp3');
|
|
66
|
+
formData.append('model', options?.model || 'whisper-1');
|
|
67
|
+
if (options?.language) {
|
|
68
|
+
formData.append('language', options.language);
|
|
69
|
+
}
|
|
70
|
+
const response = await fetch(`${this.baseUrl}/audio/transcriptions`, {
|
|
71
|
+
method: 'POST',
|
|
72
|
+
headers: {
|
|
73
|
+
'Authorization': `Bearer ${this.apiKey}`
|
|
74
|
+
},
|
|
75
|
+
body: formData
|
|
76
|
+
});
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
const error = await response.text();
|
|
79
|
+
throw new Error(`OpenAI Whisper error: ${response.status} - ${error}`);
|
|
80
|
+
}
|
|
81
|
+
const result = await response.json();
|
|
82
|
+
return result.text;
|
|
83
|
+
}
|
|
84
|
+
async getSpeakers() {
|
|
85
|
+
return [
|
|
86
|
+
{ id: 'alloy', name: 'Alloy', gender: 'neutral' },
|
|
87
|
+
{ id: 'echo', name: 'Echo', gender: 'male' },
|
|
88
|
+
{ id: 'fable', name: 'Fable', gender: 'neutral' },
|
|
89
|
+
{ id: 'onyx', name: 'Onyx', gender: 'male' },
|
|
90
|
+
{ id: 'nova', name: 'Nova', gender: 'female' },
|
|
91
|
+
{ id: 'shimmer', name: 'Shimmer', gender: 'female' }
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
async isAvailable() {
|
|
95
|
+
return !!this.apiKey;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.OpenAIVoiceProvider = OpenAIVoiceProvider;
|
|
99
|
+
/**
|
|
100
|
+
* ElevenLabs Voice Provider
|
|
101
|
+
*/
|
|
102
|
+
class ElevenLabsVoiceProvider extends BaseVoiceProvider {
|
|
103
|
+
constructor(config = {}) {
|
|
104
|
+
super({ ...config, name: 'ElevenLabsVoice' });
|
|
105
|
+
this.apiKey = config.apiKey || process.env.ELEVENLABS_API_KEY;
|
|
106
|
+
this.baseUrl = 'https://api.elevenlabs.io/v1';
|
|
107
|
+
}
|
|
108
|
+
async speak(text, options) {
|
|
109
|
+
if (!this.apiKey) {
|
|
110
|
+
throw new Error('ElevenLabs API key required');
|
|
111
|
+
}
|
|
112
|
+
const voiceId = options?.voice || this.defaultVoice || '21m00Tcm4TlvDq8ikWAM'; // Rachel
|
|
113
|
+
const response = await fetch(`${this.baseUrl}/text-to-speech/${voiceId}`, {
|
|
114
|
+
method: 'POST',
|
|
115
|
+
headers: {
|
|
116
|
+
'xi-api-key': this.apiKey,
|
|
117
|
+
'Content-Type': 'application/json'
|
|
118
|
+
},
|
|
119
|
+
body: JSON.stringify({
|
|
120
|
+
text,
|
|
121
|
+
model_id: 'eleven_monolingual_v1',
|
|
122
|
+
voice_settings: {
|
|
123
|
+
stability: 0.5,
|
|
124
|
+
similarity_boost: 0.5
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
});
|
|
128
|
+
if (!response.ok) {
|
|
129
|
+
const error = await response.text();
|
|
130
|
+
throw new Error(`ElevenLabs error: ${response.status} - ${error}`);
|
|
131
|
+
}
|
|
132
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
133
|
+
return Buffer.from(arrayBuffer);
|
|
134
|
+
}
|
|
135
|
+
async listen(_audio, _options) {
|
|
136
|
+
throw new Error('ElevenLabs does not support speech-to-text');
|
|
137
|
+
}
|
|
138
|
+
async getSpeakers() {
|
|
139
|
+
if (!this.apiKey) {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
const response = await fetch(`${this.baseUrl}/voices`, {
|
|
143
|
+
headers: {
|
|
144
|
+
'xi-api-key': this.apiKey
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
if (!response.ok) {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
const data = await response.json();
|
|
151
|
+
return (data.voices || []).map((v) => ({
|
|
152
|
+
id: v.voice_id,
|
|
153
|
+
name: v.name,
|
|
154
|
+
gender: v.labels?.gender
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
async isAvailable() {
|
|
158
|
+
return !!this.apiKey;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
exports.ElevenLabsVoiceProvider = ElevenLabsVoiceProvider;
|
|
162
|
+
// Factory functions
|
|
163
|
+
function createOpenAIVoice(config) {
|
|
164
|
+
return new OpenAIVoiceProvider(config);
|
|
165
|
+
}
|
|
166
|
+
function createElevenLabsVoice(config) {
|
|
167
|
+
return new ElevenLabsVoiceProvider(config);
|
|
168
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Voice Integrations
|
|
4
|
+
* Provides adapters for TTS and STT services
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.createElevenLabsVoice = exports.createOpenAIVoice = void 0;
|
|
22
|
+
__exportStar(require("./base"), exports);
|
|
23
|
+
// Re-export factory functions
|
|
24
|
+
var base_1 = require("./base");
|
|
25
|
+
Object.defineProperty(exports, "createOpenAIVoice", { enumerable: true, get: function () { return base_1.createOpenAIVoice; } });
|
|
26
|
+
Object.defineProperty(exports, "createElevenLabsVoice", { enumerable: true, get: function () { return base_1.createElevenLabsVoice; } });
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chunking - Text chunking utilities for RAG
|
|
3
|
+
*/
|
|
4
|
+
export type ChunkStrategy = 'size' | 'sentence' | 'paragraph' | 'semantic';
|
|
5
|
+
export interface ChunkingConfig {
|
|
6
|
+
chunkSize?: number;
|
|
7
|
+
overlap?: number;
|
|
8
|
+
strategy?: ChunkStrategy;
|
|
9
|
+
separator?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface Chunk {
|
|
12
|
+
content: string;
|
|
13
|
+
index: number;
|
|
14
|
+
startOffset: number;
|
|
15
|
+
endOffset: number;
|
|
16
|
+
metadata?: Record<string, any>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Chunking class for splitting text into chunks
|
|
20
|
+
*/
|
|
21
|
+
export declare class Chunking {
|
|
22
|
+
private chunkSize;
|
|
23
|
+
private overlap;
|
|
24
|
+
private strategy;
|
|
25
|
+
private separator;
|
|
26
|
+
constructor(config?: ChunkingConfig);
|
|
27
|
+
/**
|
|
28
|
+
* Chunk text based on configured strategy
|
|
29
|
+
*/
|
|
30
|
+
chunk(text: string): Chunk[];
|
|
31
|
+
/**
|
|
32
|
+
* Chunk by fixed size with overlap
|
|
33
|
+
*/
|
|
34
|
+
chunkBySize(text: string): Chunk[];
|
|
35
|
+
/**
|
|
36
|
+
* Chunk by sentences
|
|
37
|
+
*/
|
|
38
|
+
chunkBySentence(text: string): Chunk[];
|
|
39
|
+
/**
|
|
40
|
+
* Chunk by paragraphs
|
|
41
|
+
*/
|
|
42
|
+
chunkByParagraph(text: string): Chunk[];
|
|
43
|
+
/**
|
|
44
|
+
* Chunk by semantic boundaries (simplified)
|
|
45
|
+
*/
|
|
46
|
+
chunkBySemantic(text: string): Chunk[];
|
|
47
|
+
/**
|
|
48
|
+
* Merge small chunks
|
|
49
|
+
*/
|
|
50
|
+
mergeSmallChunks(chunks: Chunk[], minSize?: number): Chunk[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create a Chunking instance
|
|
54
|
+
*/
|
|
55
|
+
export declare function createChunking(config?: ChunkingConfig): Chunking;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Chunking - Text chunking utilities for RAG
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Chunking = void 0;
|
|
7
|
+
exports.createChunking = createChunking;
|
|
8
|
+
/**
|
|
9
|
+
* Chunking class for splitting text into chunks
|
|
10
|
+
*/
|
|
11
|
+
class Chunking {
|
|
12
|
+
constructor(config = {}) {
|
|
13
|
+
this.chunkSize = config.chunkSize ?? 500;
|
|
14
|
+
this.overlap = config.overlap ?? 50;
|
|
15
|
+
this.strategy = config.strategy ?? 'size';
|
|
16
|
+
this.separator = config.separator ?? ' ';
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Chunk text based on configured strategy
|
|
20
|
+
*/
|
|
21
|
+
chunk(text) {
|
|
22
|
+
switch (this.strategy) {
|
|
23
|
+
case 'sentence':
|
|
24
|
+
return this.chunkBySentence(text);
|
|
25
|
+
case 'paragraph':
|
|
26
|
+
return this.chunkByParagraph(text);
|
|
27
|
+
case 'semantic':
|
|
28
|
+
return this.chunkBySemantic(text);
|
|
29
|
+
default:
|
|
30
|
+
return this.chunkBySize(text);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Chunk by fixed size with overlap
|
|
35
|
+
*/
|
|
36
|
+
chunkBySize(text) {
|
|
37
|
+
const chunks = [];
|
|
38
|
+
let startOffset = 0;
|
|
39
|
+
let index = 0;
|
|
40
|
+
while (startOffset < text.length) {
|
|
41
|
+
const endOffset = Math.min(startOffset + this.chunkSize, text.length);
|
|
42
|
+
const content = text.slice(startOffset, endOffset);
|
|
43
|
+
chunks.push({
|
|
44
|
+
content,
|
|
45
|
+
index,
|
|
46
|
+
startOffset,
|
|
47
|
+
endOffset
|
|
48
|
+
});
|
|
49
|
+
startOffset = endOffset - this.overlap;
|
|
50
|
+
if (startOffset >= text.length - this.overlap)
|
|
51
|
+
break;
|
|
52
|
+
index++;
|
|
53
|
+
}
|
|
54
|
+
return chunks;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Chunk by sentences
|
|
58
|
+
*/
|
|
59
|
+
chunkBySentence(text) {
|
|
60
|
+
const sentences = text.match(/[^.!?]+[.!?]+/g) || [text];
|
|
61
|
+
return sentences.map((content, index) => {
|
|
62
|
+
const startOffset = text.indexOf(content);
|
|
63
|
+
return {
|
|
64
|
+
content: content.trim(),
|
|
65
|
+
index,
|
|
66
|
+
startOffset,
|
|
67
|
+
endOffset: startOffset + content.length
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Chunk by paragraphs
|
|
73
|
+
*/
|
|
74
|
+
chunkByParagraph(text) {
|
|
75
|
+
const paragraphs = text.split(/\n\n+/).filter(p => p.trim().length > 0);
|
|
76
|
+
let offset = 0;
|
|
77
|
+
return paragraphs.map((content, index) => {
|
|
78
|
+
const startOffset = text.indexOf(content, offset);
|
|
79
|
+
offset = startOffset + content.length;
|
|
80
|
+
return {
|
|
81
|
+
content: content.trim(),
|
|
82
|
+
index,
|
|
83
|
+
startOffset,
|
|
84
|
+
endOffset: offset
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Chunk by semantic boundaries (simplified)
|
|
90
|
+
*/
|
|
91
|
+
chunkBySemantic(text) {
|
|
92
|
+
// Simplified semantic chunking - split on headers, lists, etc.
|
|
93
|
+
const patterns = [
|
|
94
|
+
/^#{1,6}\s+.+$/gm, // Headers
|
|
95
|
+
/^\s*[-*]\s+/gm, // List items
|
|
96
|
+
/^\d+\.\s+/gm // Numbered lists
|
|
97
|
+
];
|
|
98
|
+
let chunks = [];
|
|
99
|
+
let lastEnd = 0;
|
|
100
|
+
let index = 0;
|
|
101
|
+
// Find semantic boundaries
|
|
102
|
+
const boundaries = [0];
|
|
103
|
+
for (const pattern of patterns) {
|
|
104
|
+
let match;
|
|
105
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
106
|
+
boundaries.push(match.index);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
boundaries.push(text.length);
|
|
110
|
+
boundaries.sort((a, b) => a - b);
|
|
111
|
+
// Create chunks from boundaries
|
|
112
|
+
for (let i = 0; i < boundaries.length - 1; i++) {
|
|
113
|
+
const start = boundaries[i];
|
|
114
|
+
const end = boundaries[i + 1];
|
|
115
|
+
const content = text.slice(start, end).trim();
|
|
116
|
+
if (content.length > 0) {
|
|
117
|
+
chunks.push({
|
|
118
|
+
content,
|
|
119
|
+
index: index++,
|
|
120
|
+
startOffset: start,
|
|
121
|
+
endOffset: end
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return chunks.length > 0 ? chunks : this.chunkBySize(text);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Merge small chunks
|
|
129
|
+
*/
|
|
130
|
+
mergeSmallChunks(chunks, minSize = 100) {
|
|
131
|
+
const merged = [];
|
|
132
|
+
let current = null;
|
|
133
|
+
for (const chunk of chunks) {
|
|
134
|
+
if (!current) {
|
|
135
|
+
current = { ...chunk };
|
|
136
|
+
}
|
|
137
|
+
else if (current.content.length < minSize) {
|
|
138
|
+
current.content += '\n' + chunk.content;
|
|
139
|
+
current.endOffset = chunk.endOffset;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
merged.push(current);
|
|
143
|
+
current = { ...chunk };
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (current) {
|
|
147
|
+
merged.push(current);
|
|
148
|
+
}
|
|
149
|
+
return merged.map((c, i) => ({ ...c, index: i }));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.Chunking = Chunking;
|
|
153
|
+
/**
|
|
154
|
+
* Create a Chunking instance
|
|
155
|
+
*/
|
|
156
|
+
function createChunking(config) {
|
|
157
|
+
return new Chunking(config);
|
|
158
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graph RAG - Graph-based Retrieval Augmented Generation
|
|
3
|
+
* Inspired by mastra's graph-rag module
|
|
4
|
+
*/
|
|
5
|
+
export interface GraphNode {
|
|
6
|
+
id: string;
|
|
7
|
+
type: string;
|
|
8
|
+
content: string;
|
|
9
|
+
metadata?: Record<string, any>;
|
|
10
|
+
embedding?: number[];
|
|
11
|
+
}
|
|
12
|
+
export interface GraphEdge {
|
|
13
|
+
id: string;
|
|
14
|
+
source: string;
|
|
15
|
+
target: string;
|
|
16
|
+
type: string;
|
|
17
|
+
weight?: number;
|
|
18
|
+
metadata?: Record<string, any>;
|
|
19
|
+
}
|
|
20
|
+
export interface GraphQueryResult {
|
|
21
|
+
nodes: GraphNode[];
|
|
22
|
+
edges: GraphEdge[];
|
|
23
|
+
paths: GraphNode[][];
|
|
24
|
+
score: number;
|
|
25
|
+
}
|
|
26
|
+
export interface GraphRAGConfig {
|
|
27
|
+
maxDepth?: number;
|
|
28
|
+
maxNodes?: number;
|
|
29
|
+
minScore?: number;
|
|
30
|
+
includeEdges?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* In-memory Graph Store for Graph RAG
|
|
34
|
+
*/
|
|
35
|
+
export declare class GraphStore {
|
|
36
|
+
private nodes;
|
|
37
|
+
private edges;
|
|
38
|
+
private adjacencyList;
|
|
39
|
+
private reverseAdjacencyList;
|
|
40
|
+
/**
|
|
41
|
+
* Add a node to the graph
|
|
42
|
+
*/
|
|
43
|
+
addNode(node: GraphNode): void;
|
|
44
|
+
/**
|
|
45
|
+
* Add an edge to the graph
|
|
46
|
+
*/
|
|
47
|
+
addEdge(edge: GraphEdge): void;
|
|
48
|
+
/**
|
|
49
|
+
* Get a node by ID
|
|
50
|
+
*/
|
|
51
|
+
getNode(id: string): GraphNode | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Get all nodes
|
|
54
|
+
*/
|
|
55
|
+
getAllNodes(): GraphNode[];
|
|
56
|
+
/**
|
|
57
|
+
* Get neighbors of a node
|
|
58
|
+
*/
|
|
59
|
+
getNeighbors(nodeId: string, direction?: 'outgoing' | 'incoming' | 'both'): GraphNode[];
|
|
60
|
+
/**
|
|
61
|
+
* Get edges between two nodes
|
|
62
|
+
*/
|
|
63
|
+
getEdgesBetween(sourceId: string, targetId: string): GraphEdge[];
|
|
64
|
+
/**
|
|
65
|
+
* Find paths between two nodes using BFS
|
|
66
|
+
*/
|
|
67
|
+
findPaths(startId: string, endId: string, maxDepth?: number): GraphNode[][];
|
|
68
|
+
/**
|
|
69
|
+
* Get subgraph around a node
|
|
70
|
+
*/
|
|
71
|
+
getSubgraph(nodeId: string, depth?: number): {
|
|
72
|
+
nodes: GraphNode[];
|
|
73
|
+
edges: GraphEdge[];
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Clear the graph
|
|
77
|
+
*/
|
|
78
|
+
clear(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Get graph statistics
|
|
81
|
+
*/
|
|
82
|
+
getStats(): {
|
|
83
|
+
nodeCount: number;
|
|
84
|
+
edgeCount: number;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Graph RAG - Combines graph traversal with vector similarity
|
|
89
|
+
*/
|
|
90
|
+
export declare class GraphRAG {
|
|
91
|
+
private graphStore;
|
|
92
|
+
private embedFn?;
|
|
93
|
+
constructor(config?: {
|
|
94
|
+
embedFn?: (text: string) => Promise<number[]>;
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* Add a document as a node
|
|
98
|
+
*/
|
|
99
|
+
addDocument(doc: {
|
|
100
|
+
id: string;
|
|
101
|
+
content: string;
|
|
102
|
+
type?: string;
|
|
103
|
+
metadata?: Record<string, any>;
|
|
104
|
+
}): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Add a relationship between documents
|
|
107
|
+
*/
|
|
108
|
+
addRelationship(sourceId: string, targetId: string, type: string, weight?: number): void;
|
|
109
|
+
/**
|
|
110
|
+
* Query the graph with a natural language query
|
|
111
|
+
*/
|
|
112
|
+
query(query: string, config?: GraphRAGConfig): Promise<GraphQueryResult>;
|
|
113
|
+
/**
|
|
114
|
+
* Get context string from query results
|
|
115
|
+
*/
|
|
116
|
+
getContext(result: GraphQueryResult): string;
|
|
117
|
+
/**
|
|
118
|
+
* Get the underlying graph store
|
|
119
|
+
*/
|
|
120
|
+
getGraphStore(): GraphStore;
|
|
121
|
+
private cosineSimilarity;
|
|
122
|
+
}
|
|
123
|
+
export declare function createGraphRAG(config?: {
|
|
124
|
+
embedFn?: (text: string) => Promise<number[]>;
|
|
125
|
+
}): GraphRAG;
|