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,396 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Natural Language Postgres
|
|
4
|
+
*
|
|
5
|
+
* Provides NL->SQL capabilities for querying PostgreSQL databases.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.NLPostgresClient = void 0;
|
|
42
|
+
exports.createNLPostgres = createNLPostgres;
|
|
43
|
+
exports.createPostgresTool = createPostgresTool;
|
|
44
|
+
/**
|
|
45
|
+
* Create a Natural Language Postgres client.
|
|
46
|
+
*
|
|
47
|
+
* @example Basic usage
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { createNLPostgres } from 'praisonai/integrations/postgres';
|
|
50
|
+
*
|
|
51
|
+
* const db = await createNLPostgres({
|
|
52
|
+
* connectionUrl: process.env.DATABASE_URL!,
|
|
53
|
+
* readOnly: true
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* // Query with natural language
|
|
57
|
+
* const result = await db.query('Show me all users who signed up last month');
|
|
58
|
+
* console.log(result.rows);
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @example With schema introspection
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const db = await createNLPostgres({ connectionUrl: '...' });
|
|
64
|
+
*
|
|
65
|
+
* // Get schema information
|
|
66
|
+
* const schema = await db.getSchema();
|
|
67
|
+
* console.log('Tables:', schema.map(t => t.name));
|
|
68
|
+
*
|
|
69
|
+
* // Query with context
|
|
70
|
+
* const result = await db.query('How many orders were placed today?');
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
async function createNLPostgres(config) {
|
|
74
|
+
const client = new NLPostgresClient(config);
|
|
75
|
+
await client.connect();
|
|
76
|
+
return client;
|
|
77
|
+
}
|
|
78
|
+
class NLPostgresClient {
|
|
79
|
+
constructor(config) {
|
|
80
|
+
this.pool = null;
|
|
81
|
+
this.schema = [];
|
|
82
|
+
this.connected = false;
|
|
83
|
+
this.config = {
|
|
84
|
+
schema: 'public',
|
|
85
|
+
readOnly: true,
|
|
86
|
+
maxRows: 100,
|
|
87
|
+
timeout: 30000,
|
|
88
|
+
...config,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Connect to the database.
|
|
93
|
+
*/
|
|
94
|
+
async connect() {
|
|
95
|
+
if (this.connected)
|
|
96
|
+
return;
|
|
97
|
+
try {
|
|
98
|
+
// @ts-ignore - Optional dependency
|
|
99
|
+
const { Pool } = await Promise.resolve().then(() => __importStar(require('pg')));
|
|
100
|
+
this.pool = new Pool({
|
|
101
|
+
connectionString: this.config.connectionUrl,
|
|
102
|
+
statement_timeout: this.config.timeout,
|
|
103
|
+
});
|
|
104
|
+
// Test connection
|
|
105
|
+
await this.pool.query('SELECT 1');
|
|
106
|
+
this.connected = true;
|
|
107
|
+
// Load schema
|
|
108
|
+
await this.loadSchema();
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
throw new Error(`Failed to connect to PostgreSQL: ${error.message}. ` +
|
|
112
|
+
'Install with: npm install pg');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Disconnect from the database.
|
|
117
|
+
*/
|
|
118
|
+
async disconnect() {
|
|
119
|
+
if (this.pool) {
|
|
120
|
+
await this.pool.end();
|
|
121
|
+
this.connected = false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Load database schema.
|
|
126
|
+
*/
|
|
127
|
+
async loadSchema() {
|
|
128
|
+
const schemaQuery = `
|
|
129
|
+
SELECT
|
|
130
|
+
t.table_name,
|
|
131
|
+
c.column_name,
|
|
132
|
+
c.data_type,
|
|
133
|
+
c.is_nullable,
|
|
134
|
+
c.column_default,
|
|
135
|
+
pgd.description
|
|
136
|
+
FROM information_schema.tables t
|
|
137
|
+
JOIN information_schema.columns c
|
|
138
|
+
ON t.table_name = c.table_name
|
|
139
|
+
AND t.table_schema = c.table_schema
|
|
140
|
+
LEFT JOIN pg_catalog.pg_statio_all_tables st
|
|
141
|
+
ON st.relname = t.table_name
|
|
142
|
+
LEFT JOIN pg_catalog.pg_description pgd
|
|
143
|
+
ON pgd.objoid = st.relid
|
|
144
|
+
AND pgd.objsubid = c.ordinal_position
|
|
145
|
+
WHERE t.table_schema = $1
|
|
146
|
+
AND t.table_type = 'BASE TABLE'
|
|
147
|
+
ORDER BY t.table_name, c.ordinal_position
|
|
148
|
+
`;
|
|
149
|
+
const result = await this.pool.query(schemaQuery, [this.config.schema]);
|
|
150
|
+
const tableMap = new Map();
|
|
151
|
+
for (const row of result.rows) {
|
|
152
|
+
// Check allowed/blocked tables
|
|
153
|
+
if (this.config.allowedTables && !this.config.allowedTables.includes(row.table_name)) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (this.config.blockedTables && this.config.blockedTables.includes(row.table_name)) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (!tableMap.has(row.table_name)) {
|
|
160
|
+
tableMap.set(row.table_name, {
|
|
161
|
+
name: row.table_name,
|
|
162
|
+
columns: [],
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const table = tableMap.get(row.table_name);
|
|
166
|
+
table.columns.push({
|
|
167
|
+
name: row.column_name,
|
|
168
|
+
type: row.data_type,
|
|
169
|
+
nullable: row.is_nullable === 'YES',
|
|
170
|
+
defaultValue: row.column_default,
|
|
171
|
+
description: row.description,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
this.schema = Array.from(tableMap.values());
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Get the database schema.
|
|
178
|
+
*/
|
|
179
|
+
getSchema() {
|
|
180
|
+
return this.schema;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get schema as a string for LLM context.
|
|
184
|
+
*/
|
|
185
|
+
getSchemaContext() {
|
|
186
|
+
let context = 'Database Schema:\n\n';
|
|
187
|
+
for (const table of this.schema) {
|
|
188
|
+
context += `Table: ${table.name}\n`;
|
|
189
|
+
context += 'Columns:\n';
|
|
190
|
+
for (const col of table.columns) {
|
|
191
|
+
context += ` - ${col.name} (${col.type}${col.nullable ? ', nullable' : ''})`;
|
|
192
|
+
if (col.description) {
|
|
193
|
+
context += ` - ${col.description}`;
|
|
194
|
+
}
|
|
195
|
+
context += '\n';
|
|
196
|
+
}
|
|
197
|
+
context += '\n';
|
|
198
|
+
}
|
|
199
|
+
return context;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Execute a raw SQL query.
|
|
203
|
+
*/
|
|
204
|
+
async executeSQL(sql) {
|
|
205
|
+
if (!this.connected) {
|
|
206
|
+
throw new Error('Not connected to database');
|
|
207
|
+
}
|
|
208
|
+
// Safety check for read-only mode
|
|
209
|
+
if (this.config.readOnly) {
|
|
210
|
+
const normalizedSQL = sql.trim().toLowerCase();
|
|
211
|
+
const writeOperations = ['insert', 'update', 'delete', 'drop', 'alter', 'create', 'truncate'];
|
|
212
|
+
for (const op of writeOperations) {
|
|
213
|
+
if (normalizedSQL.startsWith(op)) {
|
|
214
|
+
throw new Error(`Write operation '${op}' not allowed in read-only mode`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// Add LIMIT if not present
|
|
219
|
+
const hasLimit = /\blimit\s+\d+/i.test(sql);
|
|
220
|
+
const finalSQL = hasLimit ? sql : `${sql} LIMIT ${this.config.maxRows}`;
|
|
221
|
+
const startTime = Date.now();
|
|
222
|
+
const result = await this.pool.query(finalSQL);
|
|
223
|
+
const executionTime = Date.now() - startTime;
|
|
224
|
+
return {
|
|
225
|
+
rows: result.rows,
|
|
226
|
+
rowCount: result.rowCount,
|
|
227
|
+
fields: result.fields?.map((f) => ({ name: f.name, type: f.dataTypeID?.toString() })) || [],
|
|
228
|
+
executionTime,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Query the database using natural language.
|
|
233
|
+
*/
|
|
234
|
+
async query(naturalLanguageQuery, options) {
|
|
235
|
+
const model = options?.model || 'gpt-4o-mini';
|
|
236
|
+
// Generate SQL from natural language
|
|
237
|
+
const { generateText } = await Promise.resolve().then(() => __importStar(require('../ai/generate-text')));
|
|
238
|
+
const schemaContext = this.getSchemaContext();
|
|
239
|
+
const prompt = `You are a SQL expert. Convert the following natural language query to PostgreSQL SQL.
|
|
240
|
+
|
|
241
|
+
${schemaContext}
|
|
242
|
+
|
|
243
|
+
Rules:
|
|
244
|
+
1. Only generate SELECT queries (read-only)
|
|
245
|
+
2. Use proper PostgreSQL syntax
|
|
246
|
+
3. Include appropriate JOINs when needed
|
|
247
|
+
4. Add reasonable LIMIT if not specified
|
|
248
|
+
5. Return ONLY the SQL query, no explanations
|
|
249
|
+
|
|
250
|
+
Natural language query: ${naturalLanguageQuery}
|
|
251
|
+
|
|
252
|
+
SQL:`;
|
|
253
|
+
const result = await generateText({
|
|
254
|
+
model,
|
|
255
|
+
prompt,
|
|
256
|
+
temperature: 0,
|
|
257
|
+
});
|
|
258
|
+
// Extract SQL from response
|
|
259
|
+
let sql = result.text.trim();
|
|
260
|
+
// Remove markdown code blocks if present
|
|
261
|
+
if (sql.startsWith('```')) {
|
|
262
|
+
sql = sql.replace(/```sql?\n?/g, '').replace(/```/g, '').trim();
|
|
263
|
+
}
|
|
264
|
+
// Execute the SQL
|
|
265
|
+
const queryResult = await this.executeSQL(sql);
|
|
266
|
+
return {
|
|
267
|
+
query: naturalLanguageQuery,
|
|
268
|
+
sql,
|
|
269
|
+
result: queryResult,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Chat with the database (conversational interface).
|
|
274
|
+
*/
|
|
275
|
+
async chat(message, options) {
|
|
276
|
+
const model = options?.model || 'gpt-4o-mini';
|
|
277
|
+
const history = options?.history || [];
|
|
278
|
+
const { generateText } = await Promise.resolve().then(() => __importStar(require('../ai/generate-text')));
|
|
279
|
+
const schemaContext = this.getSchemaContext();
|
|
280
|
+
const systemPrompt = `You are a helpful database assistant. You can query a PostgreSQL database to answer questions.
|
|
281
|
+
|
|
282
|
+
${schemaContext}
|
|
283
|
+
|
|
284
|
+
When the user asks a question that requires database data:
|
|
285
|
+
1. Generate a SQL query to get the data
|
|
286
|
+
2. Execute it using the query tool
|
|
287
|
+
3. Summarize the results in natural language
|
|
288
|
+
|
|
289
|
+
Always be helpful and explain your findings clearly.`;
|
|
290
|
+
const messages = [
|
|
291
|
+
{ role: 'system', content: systemPrompt },
|
|
292
|
+
...history.map(h => ({ role: h.role, content: h.content })),
|
|
293
|
+
{ role: 'user', content: message },
|
|
294
|
+
];
|
|
295
|
+
// Define the query tool
|
|
296
|
+
const tools = {
|
|
297
|
+
query_database: {
|
|
298
|
+
description: 'Execute a SQL query on the PostgreSQL database',
|
|
299
|
+
parameters: {
|
|
300
|
+
type: 'object',
|
|
301
|
+
properties: {
|
|
302
|
+
sql: {
|
|
303
|
+
type: 'string',
|
|
304
|
+
description: 'The SQL query to execute (SELECT only)',
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
required: ['sql'],
|
|
308
|
+
},
|
|
309
|
+
execute: async ({ sql }) => {
|
|
310
|
+
try {
|
|
311
|
+
const result = await this.executeSQL(sql);
|
|
312
|
+
return JSON.stringify({
|
|
313
|
+
rowCount: result.rowCount,
|
|
314
|
+
rows: result.rows.slice(0, 10), // Limit for context
|
|
315
|
+
hasMore: result.rowCount > 10,
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
catch (error) {
|
|
319
|
+
return JSON.stringify({ error: error.message });
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
};
|
|
324
|
+
const result = await generateText({
|
|
325
|
+
model,
|
|
326
|
+
messages,
|
|
327
|
+
tools,
|
|
328
|
+
maxSteps: 3,
|
|
329
|
+
});
|
|
330
|
+
return result.text;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Inspect the database structure.
|
|
334
|
+
*/
|
|
335
|
+
async inspect() {
|
|
336
|
+
const sampleData = {};
|
|
337
|
+
for (const table of this.schema) {
|
|
338
|
+
try {
|
|
339
|
+
const result = await this.executeSQL(`SELECT * FROM ${table.name} LIMIT 3`);
|
|
340
|
+
sampleData[table.name] = result.rows;
|
|
341
|
+
}
|
|
342
|
+
catch {
|
|
343
|
+
sampleData[table.name] = [];
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return {
|
|
347
|
+
tables: this.schema.length,
|
|
348
|
+
schema: this.schema,
|
|
349
|
+
sampleData,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
exports.NLPostgresClient = NLPostgresClient;
|
|
354
|
+
/**
|
|
355
|
+
* Create a tool for querying Postgres with natural language.
|
|
356
|
+
*
|
|
357
|
+
* @example Use with an agent
|
|
358
|
+
* ```typescript
|
|
359
|
+
* import { Agent } from 'praisonai';
|
|
360
|
+
* import { createPostgresTool } from 'praisonai/integrations/postgres';
|
|
361
|
+
*
|
|
362
|
+
* const dbTool = await createPostgresTool({
|
|
363
|
+
* connectionUrl: process.env.DATABASE_URL!
|
|
364
|
+
* });
|
|
365
|
+
*
|
|
366
|
+
* const agent = new Agent({
|
|
367
|
+
* instructions: 'You can query the database',
|
|
368
|
+
* tools: [dbTool]
|
|
369
|
+
* });
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
async function createPostgresTool(config) {
|
|
373
|
+
const client = await createNLPostgres(config);
|
|
374
|
+
return {
|
|
375
|
+
name: 'query_database',
|
|
376
|
+
description: `Query the PostgreSQL database using natural language. Available tables: ${client.getSchema().map(t => t.name).join(', ')}`,
|
|
377
|
+
parameters: {
|
|
378
|
+
type: 'object',
|
|
379
|
+
properties: {
|
|
380
|
+
query: {
|
|
381
|
+
type: 'string',
|
|
382
|
+
description: 'Natural language query describing what data you want',
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
required: ['query'],
|
|
386
|
+
},
|
|
387
|
+
execute: async ({ query }) => {
|
|
388
|
+
const result = await client.query(query);
|
|
389
|
+
return JSON.stringify({
|
|
390
|
+
sql: result.sql,
|
|
391
|
+
rowCount: result.result.rowCount,
|
|
392
|
+
rows: result.result.rows,
|
|
393
|
+
});
|
|
394
|
+
},
|
|
395
|
+
};
|
|
396
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slack Integration
|
|
3
|
+
*
|
|
4
|
+
* Provides Slack bot adapters for building AI-powered Slack bots.
|
|
5
|
+
*/
|
|
6
|
+
export interface SlackConfig {
|
|
7
|
+
/** Slack Bot Token (xoxb-...) */
|
|
8
|
+
botToken: string;
|
|
9
|
+
/** Slack App Token for Socket Mode (xapp-...) */
|
|
10
|
+
appToken?: string;
|
|
11
|
+
/** Slack Signing Secret for webhook verification */
|
|
12
|
+
signingSecret?: string;
|
|
13
|
+
/** Enable Socket Mode (default: false, uses webhooks) */
|
|
14
|
+
socketMode?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface SlackMessage {
|
|
17
|
+
/** Channel ID */
|
|
18
|
+
channel: string;
|
|
19
|
+
/** User ID */
|
|
20
|
+
user: string;
|
|
21
|
+
/** Message text */
|
|
22
|
+
text: string;
|
|
23
|
+
/** Thread timestamp (for replies) */
|
|
24
|
+
threadTs?: string;
|
|
25
|
+
/** Message timestamp */
|
|
26
|
+
ts: string;
|
|
27
|
+
/** Bot ID (if from a bot) */
|
|
28
|
+
botId?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface SlackResponse {
|
|
31
|
+
/** Response text */
|
|
32
|
+
text: string;
|
|
33
|
+
/** Blocks for rich formatting */
|
|
34
|
+
blocks?: any[];
|
|
35
|
+
/** Thread timestamp (to reply in thread) */
|
|
36
|
+
threadTs?: string;
|
|
37
|
+
/** Unfurl links */
|
|
38
|
+
unfurlLinks?: boolean;
|
|
39
|
+
/** Unfurl media */
|
|
40
|
+
unfurlMedia?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface SlackEventHandler {
|
|
43
|
+
/** Handle a message event */
|
|
44
|
+
onMessage: (message: SlackMessage) => Promise<SlackResponse | null>;
|
|
45
|
+
/** Handle an app mention event */
|
|
46
|
+
onAppMention?: (message: SlackMessage) => Promise<SlackResponse | null>;
|
|
47
|
+
/** Handle a reaction added event */
|
|
48
|
+
onReactionAdded?: (event: any) => Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Create a Slack bot adapter.
|
|
52
|
+
*
|
|
53
|
+
* @example Basic usage
|
|
54
|
+
* ```typescript
|
|
55
|
+
* import { createSlackBot } from 'praisonai/integrations/slack';
|
|
56
|
+
* import { Agent } from 'praisonai';
|
|
57
|
+
*
|
|
58
|
+
* const agent = new Agent({ instructions: 'You are a helpful Slack bot' });
|
|
59
|
+
*
|
|
60
|
+
* const bot = createSlackBot({
|
|
61
|
+
* botToken: process.env.SLACK_BOT_TOKEN!,
|
|
62
|
+
* signingSecret: process.env.SLACK_SIGNING_SECRET!
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* bot.onMessage(async (message) => {
|
|
66
|
+
* const response = await agent.chat(message.text);
|
|
67
|
+
* return { text: response, threadTs: message.ts };
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // Start webhook server
|
|
71
|
+
* bot.listen(3000);
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @example With Socket Mode
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const bot = createSlackBot({
|
|
77
|
+
* botToken: process.env.SLACK_BOT_TOKEN!,
|
|
78
|
+
* appToken: process.env.SLACK_APP_TOKEN!,
|
|
79
|
+
* socketMode: true
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* bot.onMessage(async (message) => {
|
|
83
|
+
* return { text: 'Hello!' };
|
|
84
|
+
* });
|
|
85
|
+
*
|
|
86
|
+
* await bot.start();
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function createSlackBot(config: SlackConfig): SlackBot;
|
|
90
|
+
export declare class SlackBot {
|
|
91
|
+
private config;
|
|
92
|
+
private messageHandler?;
|
|
93
|
+
private mentionHandler?;
|
|
94
|
+
private reactionHandler?;
|
|
95
|
+
private boltApp;
|
|
96
|
+
constructor(config: SlackConfig);
|
|
97
|
+
/**
|
|
98
|
+
* Set the message handler.
|
|
99
|
+
*/
|
|
100
|
+
onMessage(handler: (message: SlackMessage) => Promise<SlackResponse | null>): this;
|
|
101
|
+
/**
|
|
102
|
+
* Set the app mention handler.
|
|
103
|
+
*/
|
|
104
|
+
onAppMention(handler: (message: SlackMessage) => Promise<SlackResponse | null>): this;
|
|
105
|
+
/**
|
|
106
|
+
* Set the reaction handler.
|
|
107
|
+
*/
|
|
108
|
+
onReactionAdded(handler: (event: any) => Promise<void>): this;
|
|
109
|
+
/**
|
|
110
|
+
* Initialize the Bolt app (lazy load).
|
|
111
|
+
*/
|
|
112
|
+
private initBolt;
|
|
113
|
+
/**
|
|
114
|
+
* Start the bot (Socket Mode).
|
|
115
|
+
*/
|
|
116
|
+
start(): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Start webhook server.
|
|
119
|
+
*/
|
|
120
|
+
listen(port?: number): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Stop the bot.
|
|
123
|
+
*/
|
|
124
|
+
stop(): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Send a message to a channel.
|
|
127
|
+
*/
|
|
128
|
+
sendMessage(channel: string, text: string, options?: Partial<SlackResponse>): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Get an Express middleware for webhook handling.
|
|
131
|
+
*/
|
|
132
|
+
getExpressMiddleware(): any;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Verify Slack request signature.
|
|
136
|
+
*/
|
|
137
|
+
export declare function verifySlackSignature(signingSecret: string, signature: string, timestamp: string, body: string): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Parse Slack message text to extract mentions and links.
|
|
140
|
+
*/
|
|
141
|
+
export declare function parseSlackMessage(text: string): {
|
|
142
|
+
mentions: string[];
|
|
143
|
+
links: string[];
|
|
144
|
+
cleanText: string;
|
|
145
|
+
};
|