@useconductor/conductor 1.0.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/.claude-plugin/marketplace.json +33 -0
- package/.claude-plugin/plugin.json +23 -0
- package/.eslintrc.json +23 -0
- package/.gitattributes +6 -0
- package/.github/FUNDING.yml +15 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +91 -0
- package/.github/ISSUE_TEMPLATE/config.yml +8 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +63 -0
- package/.github/ISSUE_TEMPLATE/plugin_request.yml +71 -0
- package/.github/README.md +13 -0
- package/.github/workflows/README.md +22 -0
- package/.github/workflows/auto-release.yml +112 -0
- package/.github/workflows/ci.yml +49 -0
- package/.github/workflows/claude-code-review.yml +44 -0
- package/.github/workflows/claude.yml +36 -0
- package/.github/workflows/sync-install.yml +47 -0
- package/.mcp.json +9 -0
- package/.prettierrc.json +7 -0
- package/C.png +0 -0
- package/CHANGELOG.md +74 -0
- package/CLAUDE.md +118 -0
- package/CONTRIBUTING.md +231 -0
- package/LICENSE +201 -0
- package/README.md +179 -0
- package/SECURITY.md +47 -0
- package/commands/conductor-setup.md +11 -0
- package/commands/conductor-status.md +7 -0
- package/dist/ai/base.d.ts +44 -0
- package/dist/ai/base.d.ts.map +1 -0
- package/dist/ai/base.js +47 -0
- package/dist/ai/base.js.map +1 -0
- package/dist/ai/claude.d.ts +11 -0
- package/dist/ai/claude.d.ts.map +1 -0
- package/dist/ai/claude.js +149 -0
- package/dist/ai/claude.js.map +1 -0
- package/dist/ai/gemini.d.ts +15 -0
- package/dist/ai/gemini.d.ts.map +1 -0
- package/dist/ai/gemini.js +156 -0
- package/dist/ai/gemini.js.map +1 -0
- package/dist/ai/maestro.d.ts +22 -0
- package/dist/ai/maestro.d.ts.map +1 -0
- package/dist/ai/maestro.js +142 -0
- package/dist/ai/maestro.js.map +1 -0
- package/dist/ai/manager.d.ts +47 -0
- package/dist/ai/manager.d.ts.map +1 -0
- package/dist/ai/manager.js +450 -0
- package/dist/ai/manager.js.map +1 -0
- package/dist/ai/ollama.d.ts +16 -0
- package/dist/ai/ollama.d.ts.map +1 -0
- package/dist/ai/ollama.js +151 -0
- package/dist/ai/ollama.js.map +1 -0
- package/dist/ai/openai.d.ts +11 -0
- package/dist/ai/openai.d.ts.map +1 -0
- package/dist/ai/openai.js +132 -0
- package/dist/ai/openai.js.map +1 -0
- package/dist/ai/openrouter.d.ts +11 -0
- package/dist/ai/openrouter.d.ts.map +1 -0
- package/dist/ai/openrouter.js +139 -0
- package/dist/ai/openrouter.js.map +1 -0
- package/dist/bot/slack.d.ts +17 -0
- package/dist/bot/slack.d.ts.map +1 -0
- package/dist/bot/slack.js +144 -0
- package/dist/bot/slack.js.map +1 -0
- package/dist/bot/telegram.d.ts +19 -0
- package/dist/bot/telegram.d.ts.map +1 -0
- package/dist/bot/telegram.js +157 -0
- package/dist/bot/telegram.js.map +1 -0
- package/dist/cli/commands/ai.d.ts +4 -0
- package/dist/cli/commands/ai.d.ts.map +1 -0
- package/dist/cli/commands/ai.js +161 -0
- package/dist/cli/commands/ai.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +18 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +213 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/init.d.ts +15 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +281 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/install.d.ts +16 -0
- package/dist/cli/commands/install.d.ts.map +1 -0
- package/dist/cli/commands/install.js +750 -0
- package/dist/cli/commands/install.js.map +1 -0
- package/dist/cli/commands/lifecycle.d.ts +4 -0
- package/dist/cli/commands/lifecycle.d.ts.map +1 -0
- package/dist/cli/commands/lifecycle.js +84 -0
- package/dist/cli/commands/lifecycle.js.map +1 -0
- package/dist/cli/commands/marketplace.d.ts +13 -0
- package/dist/cli/commands/marketplace.d.ts.map +1 -0
- package/dist/cli/commands/marketplace.js +197 -0
- package/dist/cli/commands/marketplace.js.map +1 -0
- package/dist/cli/commands/mcp.d.ts +6 -0
- package/dist/cli/commands/mcp.d.ts.map +1 -0
- package/dist/cli/commands/mcp.js +83 -0
- package/dist/cli/commands/mcp.js.map +1 -0
- package/dist/cli/commands/onboard.d.ts +10 -0
- package/dist/cli/commands/onboard.d.ts.map +1 -0
- package/dist/cli/commands/onboard.js +207 -0
- package/dist/cli/commands/onboard.js.map +1 -0
- package/dist/cli/commands/plugin-create.d.ts +13 -0
- package/dist/cli/commands/plugin-create.d.ts.map +1 -0
- package/dist/cli/commands/plugin-create.js +122 -0
- package/dist/cli/commands/plugin-create.js.map +1 -0
- package/dist/cli/commands/plugins.d.ts +5 -0
- package/dist/cli/commands/plugins.d.ts.map +1 -0
- package/dist/cli/commands/plugins.js +30 -0
- package/dist/cli/commands/plugins.js.map +1 -0
- package/dist/cli/commands/release.d.ts +13 -0
- package/dist/cli/commands/release.d.ts.map +1 -0
- package/dist/cli/commands/release.js +243 -0
- package/dist/cli/commands/release.js.map +1 -0
- package/dist/cli/commands/telegram.d.ts +3 -0
- package/dist/cli/commands/telegram.d.ts.map +1 -0
- package/dist/cli/commands/telegram.js +20 -0
- package/dist/cli/commands/telegram.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +402 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/oauth.d.ts +8 -0
- package/dist/config/oauth.d.ts.map +1 -0
- package/dist/config/oauth.js +13 -0
- package/dist/config/oauth.js.map +1 -0
- package/dist/core/audit.d.ts +91 -0
- package/dist/core/audit.d.ts.map +1 -0
- package/dist/core/audit.js +233 -0
- package/dist/core/audit.js.map +1 -0
- package/dist/core/circuit-breaker.d.ts +56 -0
- package/dist/core/circuit-breaker.d.ts.map +1 -0
- package/dist/core/circuit-breaker.js +107 -0
- package/dist/core/circuit-breaker.js.map +1 -0
- package/dist/core/conductor.d.ts +44 -0
- package/dist/core/conductor.d.ts.map +1 -0
- package/dist/core/conductor.js +200 -0
- package/dist/core/conductor.js.map +1 -0
- package/dist/core/config.d.ts +66 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +86 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/database.d.ts +59 -0
- package/dist/core/database.d.ts.map +1 -0
- package/dist/core/database.js +342 -0
- package/dist/core/database.js.map +1 -0
- package/dist/core/errors.d.ts +231 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +254 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/health.d.ts +72 -0
- package/dist/core/health.d.ts.map +1 -0
- package/dist/core/health.js +116 -0
- package/dist/core/health.js.map +1 -0
- package/dist/core/interfaces.d.ts +62 -0
- package/dist/core/interfaces.d.ts.map +1 -0
- package/dist/core/interfaces.js +8 -0
- package/dist/core/interfaces.js.map +1 -0
- package/dist/core/logger.d.ts +15 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +30 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/rbac.d.ts +132 -0
- package/dist/core/rbac.d.ts.map +1 -0
- package/dist/core/rbac.js +230 -0
- package/dist/core/rbac.js.map +1 -0
- package/dist/core/retry.d.ts +22 -0
- package/dist/core/retry.d.ts.map +1 -0
- package/dist/core/retry.js +41 -0
- package/dist/core/retry.js.map +1 -0
- package/dist/core/webhooks.d.ts +92 -0
- package/dist/core/webhooks.d.ts.map +1 -0
- package/dist/core/webhooks.js +176 -0
- package/dist/core/webhooks.js.map +1 -0
- package/dist/core/zero-config.d.ts +22 -0
- package/dist/core/zero-config.d.ts.map +1 -0
- package/dist/core/zero-config.js +59 -0
- package/dist/core/zero-config.js.map +1 -0
- package/dist/dashboard/cli.d.ts +6 -0
- package/dist/dashboard/cli.d.ts.map +1 -0
- package/dist/dashboard/cli.js +42 -0
- package/dist/dashboard/cli.js.map +1 -0
- package/dist/dashboard/index.html +3426 -0
- package/dist/dashboard/server.d.ts +7 -0
- package/dist/dashboard/server.d.ts.map +1 -0
- package/dist/dashboard/server.js +1427 -0
- package/dist/dashboard/server.js.map +1 -0
- package/dist/mcp/server.d.ts +27 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +380 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools/misc.d.ts +15 -0
- package/dist/mcp/tools/misc.d.ts.map +1 -0
- package/dist/mcp/tools/misc.js +49 -0
- package/dist/mcp/tools/misc.js.map +1 -0
- package/dist/plugins/builtin/calculator.d.ts +11 -0
- package/dist/plugins/builtin/calculator.d.ts.map +1 -0
- package/dist/plugins/builtin/calculator.js +166 -0
- package/dist/plugins/builtin/calculator.js.map +1 -0
- package/dist/plugins/builtin/colors.d.ts +15 -0
- package/dist/plugins/builtin/colors.d.ts.map +1 -0
- package/dist/plugins/builtin/colors.js +193 -0
- package/dist/plugins/builtin/colors.js.map +1 -0
- package/dist/plugins/builtin/cron.d.ts +40 -0
- package/dist/plugins/builtin/cron.d.ts.map +1 -0
- package/dist/plugins/builtin/cron.js +578 -0
- package/dist/plugins/builtin/cron.js.map +1 -0
- package/dist/plugins/builtin/crypto.d.ts +11 -0
- package/dist/plugins/builtin/crypto.d.ts.map +1 -0
- package/dist/plugins/builtin/crypto.js +83 -0
- package/dist/plugins/builtin/crypto.js.map +1 -0
- package/dist/plugins/builtin/database.d.ts +29 -0
- package/dist/plugins/builtin/database.d.ts.map +1 -0
- package/dist/plugins/builtin/database.js +230 -0
- package/dist/plugins/builtin/database.js.map +1 -0
- package/dist/plugins/builtin/docker.d.ts +12 -0
- package/dist/plugins/builtin/docker.d.ts.map +1 -0
- package/dist/plugins/builtin/docker.js +436 -0
- package/dist/plugins/builtin/docker.js.map +1 -0
- package/dist/plugins/builtin/fun.d.ts +11 -0
- package/dist/plugins/builtin/fun.d.ts.map +1 -0
- package/dist/plugins/builtin/fun.js +114 -0
- package/dist/plugins/builtin/fun.js.map +1 -0
- package/dist/plugins/builtin/gcal.d.ts +38 -0
- package/dist/plugins/builtin/gcal.d.ts.map +1 -0
- package/dist/plugins/builtin/gcal.js +280 -0
- package/dist/plugins/builtin/gcal.js.map +1 -0
- package/dist/plugins/builtin/gdrive.d.ts +26 -0
- package/dist/plugins/builtin/gdrive.d.ts.map +1 -0
- package/dist/plugins/builtin/gdrive.js +295 -0
- package/dist/plugins/builtin/gdrive.js.map +1 -0
- package/dist/plugins/builtin/github-actions.d.ts +38 -0
- package/dist/plugins/builtin/github-actions.d.ts.map +1 -0
- package/dist/plugins/builtin/github-actions.js +629 -0
- package/dist/plugins/builtin/github-actions.js.map +1 -0
- package/dist/plugins/builtin/github.d.ts +26 -0
- package/dist/plugins/builtin/github.d.ts.map +1 -0
- package/dist/plugins/builtin/github.js +800 -0
- package/dist/plugins/builtin/github.js.map +1 -0
- package/dist/plugins/builtin/gmail.d.ts +50 -0
- package/dist/plugins/builtin/gmail.d.ts.map +1 -0
- package/dist/plugins/builtin/gmail.js +445 -0
- package/dist/plugins/builtin/gmail.js.map +1 -0
- package/dist/plugins/builtin/hash.d.ts +11 -0
- package/dist/plugins/builtin/hash.d.ts.map +1 -0
- package/dist/plugins/builtin/hash.js +95 -0
- package/dist/plugins/builtin/hash.js.map +1 -0
- package/dist/plugins/builtin/homekit.d.ts +53 -0
- package/dist/plugins/builtin/homekit.d.ts.map +1 -0
- package/dist/plugins/builtin/homekit.js +341 -0
- package/dist/plugins/builtin/homekit.js.map +1 -0
- package/dist/plugins/builtin/index.d.ts +4 -0
- package/dist/plugins/builtin/index.d.ts.map +1 -0
- package/dist/plugins/builtin/index.js +96 -0
- package/dist/plugins/builtin/index.js.map +1 -0
- package/dist/plugins/builtin/jira.d.ts +50 -0
- package/dist/plugins/builtin/jira.d.ts.map +1 -0
- package/dist/plugins/builtin/jira.js +353 -0
- package/dist/plugins/builtin/jira.js.map +1 -0
- package/dist/plugins/builtin/linear.d.ts +35 -0
- package/dist/plugins/builtin/linear.d.ts.map +1 -0
- package/dist/plugins/builtin/linear.js +397 -0
- package/dist/plugins/builtin/linear.js.map +1 -0
- package/dist/plugins/builtin/lumen.d.ts +21 -0
- package/dist/plugins/builtin/lumen.d.ts.map +1 -0
- package/dist/plugins/builtin/lumen.js +404 -0
- package/dist/plugins/builtin/lumen.js.map +1 -0
- package/dist/plugins/builtin/memory.d.ts +22 -0
- package/dist/plugins/builtin/memory.d.ts.map +1 -0
- package/dist/plugins/builtin/memory.js +184 -0
- package/dist/plugins/builtin/memory.js.map +1 -0
- package/dist/plugins/builtin/n8n.d.ts +60 -0
- package/dist/plugins/builtin/n8n.d.ts.map +1 -0
- package/dist/plugins/builtin/n8n.js +519 -0
- package/dist/plugins/builtin/n8n.js.map +1 -0
- package/dist/plugins/builtin/network.d.ts +11 -0
- package/dist/plugins/builtin/network.d.ts.map +1 -0
- package/dist/plugins/builtin/network.js +88 -0
- package/dist/plugins/builtin/network.js.map +1 -0
- package/dist/plugins/builtin/notes.d.ts +47 -0
- package/dist/plugins/builtin/notes.d.ts.map +1 -0
- package/dist/plugins/builtin/notes.js +641 -0
- package/dist/plugins/builtin/notes.js.map +1 -0
- package/dist/plugins/builtin/notion.d.ts +47 -0
- package/dist/plugins/builtin/notion.d.ts.map +1 -0
- package/dist/plugins/builtin/notion.js +317 -0
- package/dist/plugins/builtin/notion.js.map +1 -0
- package/dist/plugins/builtin/shell.d.ts +12 -0
- package/dist/plugins/builtin/shell.d.ts.map +1 -0
- package/dist/plugins/builtin/shell.js +310 -0
- package/dist/plugins/builtin/shell.js.map +1 -0
- package/dist/plugins/builtin/slack.d.ts +31 -0
- package/dist/plugins/builtin/slack.d.ts.map +1 -0
- package/dist/plugins/builtin/slack.js +295 -0
- package/dist/plugins/builtin/slack.js.map +1 -0
- package/dist/plugins/builtin/spotify.d.ts +55 -0
- package/dist/plugins/builtin/spotify.d.ts.map +1 -0
- package/dist/plugins/builtin/spotify.js +623 -0
- package/dist/plugins/builtin/spotify.js.map +1 -0
- package/dist/plugins/builtin/stripe.d.ts +35 -0
- package/dist/plugins/builtin/stripe.d.ts.map +1 -0
- package/dist/plugins/builtin/stripe.js +376 -0
- package/dist/plugins/builtin/stripe.js.map +1 -0
- package/dist/plugins/builtin/system.d.ts +11 -0
- package/dist/plugins/builtin/system.d.ts.map +1 -0
- package/dist/plugins/builtin/system.js +91 -0
- package/dist/plugins/builtin/system.js.map +1 -0
- package/dist/plugins/builtin/text-tools.d.ts +11 -0
- package/dist/plugins/builtin/text-tools.d.ts.map +1 -0
- package/dist/plugins/builtin/text-tools.js +146 -0
- package/dist/plugins/builtin/text-tools.js.map +1 -0
- package/dist/plugins/builtin/timezone.d.ts +13 -0
- package/dist/plugins/builtin/timezone.d.ts.map +1 -0
- package/dist/plugins/builtin/timezone.js +164 -0
- package/dist/plugins/builtin/timezone.js.map +1 -0
- package/dist/plugins/builtin/todoist.d.ts +49 -0
- package/dist/plugins/builtin/todoist.d.ts.map +1 -0
- package/dist/plugins/builtin/todoist.js +540 -0
- package/dist/plugins/builtin/todoist.js.map +1 -0
- package/dist/plugins/builtin/translate.d.ts +11 -0
- package/dist/plugins/builtin/translate.d.ts.map +1 -0
- package/dist/plugins/builtin/translate.js +42 -0
- package/dist/plugins/builtin/translate.js.map +1 -0
- package/dist/plugins/builtin/url-tools.d.ts +11 -0
- package/dist/plugins/builtin/url-tools.d.ts.map +1 -0
- package/dist/plugins/builtin/url-tools.js +70 -0
- package/dist/plugins/builtin/url-tools.js.map +1 -0
- package/dist/plugins/builtin/vercel.d.ts +55 -0
- package/dist/plugins/builtin/vercel.d.ts.map +1 -0
- package/dist/plugins/builtin/vercel.js +514 -0
- package/dist/plugins/builtin/vercel.js.map +1 -0
- package/dist/plugins/builtin/weather.d.ts +13 -0
- package/dist/plugins/builtin/weather.d.ts.map +1 -0
- package/dist/plugins/builtin/weather.js +103 -0
- package/dist/plugins/builtin/weather.js.map +1 -0
- package/dist/plugins/builtin/x.d.ts +54 -0
- package/dist/plugins/builtin/x.d.ts.map +1 -0
- package/dist/plugins/builtin/x.js +402 -0
- package/dist/plugins/builtin/x.js.map +1 -0
- package/dist/plugins/manager.d.ts +77 -0
- package/dist/plugins/manager.d.ts.map +1 -0
- package/dist/plugins/manager.js +141 -0
- package/dist/plugins/manager.js.map +1 -0
- package/dist/plugins/validation.d.ts +18 -0
- package/dist/plugins/validation.d.ts.map +1 -0
- package/dist/plugins/validation.js +81 -0
- package/dist/plugins/validation.js.map +1 -0
- package/dist/security/auth.d.ts +23 -0
- package/dist/security/auth.d.ts.map +1 -0
- package/dist/security/auth.js +56 -0
- package/dist/security/auth.js.map +1 -0
- package/dist/security/keychain.d.ts +60 -0
- package/dist/security/keychain.d.ts.map +1 -0
- package/dist/security/keychain.js +213 -0
- package/dist/security/keychain.js.map +1 -0
- package/dist/utils/google-auth.d.ts +21 -0
- package/dist/utils/google-auth.d.ts.map +1 -0
- package/dist/utils/google-auth.js +135 -0
- package/dist/utils/google-auth.js.map +1 -0
- package/dist/utils/retry.d.ts +5 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +34 -0
- package/dist/utils/retry.js.map +1 -0
- package/docs/README.md +13 -0
- package/docs/api.md +210 -0
- package/docs/getting-started.md +100 -0
- package/docs/plugins.md +306 -0
- package/docs-site/.vitepress/config.ts +59 -0
- package/docs-site/README.md +12 -0
- package/docs-site/index.md +30 -0
- package/eslint.config.js +29 -0
- package/install.ps1 +334 -0
- package/install.sh +1119 -0
- package/local-install.sh +304 -0
- package/package.json +90 -0
- package/packages/README.md +11 -0
- package/packages/plugin-sdk/README.md +12 -0
- package/packages/plugin-sdk/package.json +22 -0
- package/packages/plugin-sdk/src/README.md +11 -0
- package/packages/plugin-sdk/src/index.ts +191 -0
- package/sdks/README.md +26 -0
- package/sdks/csharp/ConductorClient.cs +65 -0
- package/sdks/csharp/README.md +11 -0
- package/sdks/go/README.md +11 -0
- package/sdks/go/conductor.go +257 -0
- package/sdks/java/ConductorClient.java +27 -0
- package/sdks/java/README.md +11 -0
- package/sdks/php/README.md +11 -0
- package/sdks/php/src/Client.php +72 -0
- package/sdks/python/README.md +12 -0
- package/sdks/python/conductor/__init__.py +227 -0
- package/sdks/python/pyproject.toml +30 -0
- package/sdks/ruby/README.md +11 -0
- package/sdks/ruby/lib/conductor.rb +46 -0
- package/sdks/rust/Cargo.toml +14 -0
- package/sdks/rust/README.md +11 -0
- package/sdks/swift/README.md +11 -0
- package/sdks/swift/Sources/Conductor/ConductorClient.swift +65 -0
- package/skills/conductor-mcp/SKILL.md +38 -0
- package/src/README.md +20 -0
- package/src/ai/README.md +18 -0
- package/src/ai/base.ts +93 -0
- package/src/ai/claude.ts +162 -0
- package/src/ai/gemini.ts +188 -0
- package/src/ai/maestro.ts +168 -0
- package/src/ai/manager.ts +537 -0
- package/src/ai/ollama.ts +186 -0
- package/src/ai/openai.ts +147 -0
- package/src/ai/openrouter.ts +152 -0
- package/src/bot/README.md +12 -0
- package/src/bot/slack.ts +164 -0
- package/src/bot/telegram.ts +185 -0
- package/src/cli/README.md +24 -0
- package/src/cli/commands/README.md +20 -0
- package/src/cli/commands/ai.ts +170 -0
- package/src/cli/commands/doctor.ts +221 -0
- package/src/cli/commands/init.ts +348 -0
- package/src/cli/commands/install.ts +792 -0
- package/src/cli/commands/lifecycle.ts +95 -0
- package/src/cli/commands/marketplace.ts +253 -0
- package/src/cli/commands/mcp.ts +92 -0
- package/src/cli/commands/onboard.ts +248 -0
- package/src/cli/commands/plugin-create.ts +130 -0
- package/src/cli/commands/plugins.ts +36 -0
- package/src/cli/commands/release.ts +251 -0
- package/src/cli/commands/telegram.ts +25 -0
- package/src/cli/index.ts +450 -0
- package/src/config/README.md +11 -0
- package/src/config/oauth.ts +26 -0
- package/src/core/README.md +22 -0
- package/src/core/audit.ts +291 -0
- package/src/core/circuit-breaker.ts +129 -0
- package/src/core/conductor.ts +240 -0
- package/src/core/config.ts +149 -0
- package/src/core/database.ts +411 -0
- package/src/core/errors.ts +275 -0
- package/src/core/health.ts +159 -0
- package/src/core/interfaces.ts +75 -0
- package/src/core/logger.ts +33 -0
- package/src/core/rbac.ts +321 -0
- package/src/core/retry.ts +61 -0
- package/src/core/webhooks.ts +234 -0
- package/src/core/zero-config.ts +72 -0
- package/src/dashboard/README.md +15 -0
- package/src/dashboard/cli.ts +48 -0
- package/src/dashboard/index.html +3426 -0
- package/src/dashboard/server.ts +1544 -0
- package/src/mcp/README.md +20 -0
- package/src/mcp/server.ts +475 -0
- package/src/mcp/tools/README.md +11 -0
- package/src/mcp/tools/misc.ts +61 -0
- package/src/plugins/README.md +28 -0
- package/src/plugins/builtin/README.md +23 -0
- package/src/plugins/builtin/calculator.ts +178 -0
- package/src/plugins/builtin/colors.ts +201 -0
- package/src/plugins/builtin/cron.ts +649 -0
- package/src/plugins/builtin/crypto.ts +85 -0
- package/src/plugins/builtin/database.ts +235 -0
- package/src/plugins/builtin/docker.ts +426 -0
- package/src/plugins/builtin/fun.ts +118 -0
- package/src/plugins/builtin/gcal.ts +305 -0
- package/src/plugins/builtin/gdrive.ts +326 -0
- package/src/plugins/builtin/github-actions.ts +666 -0
- package/src/plugins/builtin/github.ts +912 -0
- package/src/plugins/builtin/gmail.ts +492 -0
- package/src/plugins/builtin/hash.ts +98 -0
- package/src/plugins/builtin/homekit.ts +389 -0
- package/src/plugins/builtin/index.ts +116 -0
- package/src/plugins/builtin/jira.ts +380 -0
- package/src/plugins/builtin/linear.ts +448 -0
- package/src/plugins/builtin/lumen.ts +497 -0
- package/src/plugins/builtin/memory.ts +200 -0
- package/src/plugins/builtin/n8n.ts +565 -0
- package/src/plugins/builtin/network.ts +92 -0
- package/src/plugins/builtin/notes.ts +689 -0
- package/src/plugins/builtin/notion.ts +348 -0
- package/src/plugins/builtin/shell.ts +334 -0
- package/src/plugins/builtin/slack.ts +327 -0
- package/src/plugins/builtin/spotify.ts +665 -0
- package/src/plugins/builtin/stripe.ts +388 -0
- package/src/plugins/builtin/system.ts +93 -0
- package/src/plugins/builtin/text-tools.ts +150 -0
- package/src/plugins/builtin/timezone.ts +173 -0
- package/src/plugins/builtin/todoist.ts +625 -0
- package/src/plugins/builtin/translate.ts +47 -0
- package/src/plugins/builtin/url-tools.ts +73 -0
- package/src/plugins/builtin/vercel.ts +546 -0
- package/src/plugins/builtin/weather.ts +112 -0
- package/src/plugins/builtin/x.ts +440 -0
- package/src/plugins/manager.ts +213 -0
- package/src/plugins/validation.ts +94 -0
- package/src/security/README.md +12 -0
- package/src/security/auth.ts +72 -0
- package/src/security/keychain.ts +226 -0
- package/src/utils/README.md +12 -0
- package/src/utils/google-auth.ts +159 -0
- package/src/utils/retry.ts +41 -0
- package/test-all.mjs +1256 -0
- package/test.mjs +633 -0
- package/tests/README.md +19 -0
- package/tests/calculator.test.ts +54 -0
- package/tests/docker.test.ts +42 -0
- package/tests/load.test.ts +129 -0
- package/tests/mcp.test.ts +14 -0
- package/tests/shell.test.ts +42 -0
- package/tsconfig.json +21 -0
- package/vitest.config.ts +14 -0
package/src/ai/ollama.ts
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { AIProvider, AIMessage, AIResponse } from './base.js';
|
|
2
|
+
import { PluginTool } from '../plugins/manager.js';
|
|
3
|
+
|
|
4
|
+
interface OllamaToolDefinition {
|
|
5
|
+
type: 'function';
|
|
6
|
+
function: {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
parameters: {
|
|
10
|
+
type: 'object';
|
|
11
|
+
properties: Record<string, unknown>;
|
|
12
|
+
required: string[];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function convertToOllamaTools(tools?: PluginTool[]): OllamaToolDefinition[] {
|
|
18
|
+
if (!tools || tools.length === 0) return [];
|
|
19
|
+
|
|
20
|
+
return tools.map((t) => ({
|
|
21
|
+
type: 'function' as const,
|
|
22
|
+
function: {
|
|
23
|
+
name: t.name,
|
|
24
|
+
description: t.description,
|
|
25
|
+
parameters: {
|
|
26
|
+
type: 'object' as const,
|
|
27
|
+
properties: (t.inputSchema.properties ?? {}) as Record<string, unknown>,
|
|
28
|
+
required: (t.inputSchema.required as string[]) ?? [],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class OllamaProvider extends AIProvider {
|
|
35
|
+
private endpoint: string;
|
|
36
|
+
|
|
37
|
+
constructor(config: Record<string, unknown>) {
|
|
38
|
+
super(config);
|
|
39
|
+
this.endpoint = (config.endpoint as string) || 'http://localhost:11434';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getName(): string {
|
|
43
|
+
return 'Ollama';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async initialize(): Promise<void> {
|
|
47
|
+
const isRunning = await this.test();
|
|
48
|
+
if (!isRunning) {
|
|
49
|
+
throw new Error('Ollama is not running. Start it with: ollama serve');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async complete(messages: AIMessage[], tools?: PluginTool[]): Promise<AIResponse> {
|
|
54
|
+
const model = (this.config.model as string) || 'llama3.2';
|
|
55
|
+
const ollamaTools = convertToOllamaTools(tools);
|
|
56
|
+
|
|
57
|
+
const body: Record<string, unknown> = {
|
|
58
|
+
model,
|
|
59
|
+
messages: messages.map((m) => ({ role: m.role, content: m.content })),
|
|
60
|
+
stream: false,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
if (ollamaTools.length > 0) {
|
|
64
|
+
body.tools = ollamaTools;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const response = await fetch(`${this.endpoint}/api/chat`, {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
headers: { 'Content-Type': 'application/json' },
|
|
70
|
+
body: JSON.stringify(body),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
if (!response.ok) {
|
|
74
|
+
throw new Error(`Ollama error: ${response.statusText}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
+
const data = (await response.json()) as any;
|
|
79
|
+
|
|
80
|
+
// Check for tool calls in the response
|
|
81
|
+
if (data.message?.tool_calls) {
|
|
82
|
+
const toolCall = data.message.tool_calls[0];
|
|
83
|
+
return {
|
|
84
|
+
content: data.message.content || '',
|
|
85
|
+
model: data.model,
|
|
86
|
+
tokens_used: data.eval_count,
|
|
87
|
+
tool_calls: [
|
|
88
|
+
{
|
|
89
|
+
id: toolCall.function?.name ?? 'unknown',
|
|
90
|
+
name: toolCall.function?.name ?? 'unknown',
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
+
arguments: (toolCall.function?.arguments ?? {}) as Record<string, any>,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
content: data.message?.content ?? '',
|
|
100
|
+
model: data.model,
|
|
101
|
+
tokens_used: data.eval_count,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async *stream(messages: AIMessage[], tools?: PluginTool[]): AsyncGenerator<string> {
|
|
106
|
+
const model = (this.config.model as string) || 'llama3.2';
|
|
107
|
+
const ollamaTools = convertToOllamaTools(tools);
|
|
108
|
+
|
|
109
|
+
const body: Record<string, unknown> = {
|
|
110
|
+
model,
|
|
111
|
+
messages: messages.map((m) => ({ role: m.role, content: m.content })),
|
|
112
|
+
stream: true,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
if (ollamaTools.length > 0) {
|
|
116
|
+
body.tools = ollamaTools;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const response = await fetch(`${this.endpoint}/api/chat`, {
|
|
120
|
+
method: 'POST',
|
|
121
|
+
headers: { 'Content-Type': 'application/json' },
|
|
122
|
+
body: JSON.stringify(body),
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
if (!response.ok || !response.body) {
|
|
126
|
+
throw new Error(`Ollama error: ${response.statusText}`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const reader = response.body.getReader();
|
|
130
|
+
const decoder = new TextDecoder();
|
|
131
|
+
|
|
132
|
+
while (true) {
|
|
133
|
+
const { done, value } = await reader.read();
|
|
134
|
+
if (done) break;
|
|
135
|
+
|
|
136
|
+
const chunk = decoder.decode(value);
|
|
137
|
+
const lines = chunk.split('\n').filter((l) => l.trim());
|
|
138
|
+
|
|
139
|
+
for (const line of lines) {
|
|
140
|
+
try {
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
|
+
const json = JSON.parse(line) as any;
|
|
143
|
+
if (json.message?.content) {
|
|
144
|
+
yield json.message.content;
|
|
145
|
+
}
|
|
146
|
+
} catch {
|
|
147
|
+
// Skip invalid JSON fragments
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async test(): Promise<boolean> {
|
|
154
|
+
try {
|
|
155
|
+
const response = await fetch(`${this.endpoint}/api/tags`);
|
|
156
|
+
return response.ok;
|
|
157
|
+
} catch {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** List available models. */
|
|
163
|
+
async listModels(): Promise<string[]> {
|
|
164
|
+
try {
|
|
165
|
+
const response = await fetch(`${this.endpoint}/api/tags`);
|
|
166
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
167
|
+
const data = (await response.json()) as any;
|
|
168
|
+
return (data.models ?? []).map((m: { name: string }) => m.name);
|
|
169
|
+
} catch {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Pull a model. */
|
|
175
|
+
async pullModel(model: string): Promise<void> {
|
|
176
|
+
const response = await fetch(`${this.endpoint}/api/pull`, {
|
|
177
|
+
method: 'POST',
|
|
178
|
+
headers: { 'Content-Type': 'application/json' },
|
|
179
|
+
body: JSON.stringify({ name: model, stream: false }),
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
if (!response.ok) {
|
|
183
|
+
throw new Error(`Failed to pull model: ${response.statusText}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
package/src/ai/openai.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { AIProvider, AIMessage, AIResponse } from './base.js';
|
|
2
|
+
import { PluginTool } from '../plugins/manager.js';
|
|
3
|
+
import OpenAI from 'openai';
|
|
4
|
+
import { ChatCompletionMessageParam, ChatCompletionTool } from 'openai/resources/chat/completions.js';
|
|
5
|
+
|
|
6
|
+
export class OpenAIProvider extends AIProvider {
|
|
7
|
+
private client: OpenAI | null = null;
|
|
8
|
+
|
|
9
|
+
async initialize(apiKey: string): Promise<void> {
|
|
10
|
+
this.client = new OpenAI({ apiKey });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getName(): string {
|
|
14
|
+
return 'OpenAI';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async complete(messages: AIMessage[], tools?: PluginTool[]): Promise<AIResponse> {
|
|
18
|
+
if (!this.client) throw new Error('OpenAI not initialized');
|
|
19
|
+
|
|
20
|
+
const model = this.config.model || 'gpt-4o';
|
|
21
|
+
|
|
22
|
+
const requestTools: ChatCompletionTool[] | undefined = tools?.length
|
|
23
|
+
? tools.map((t) => ({
|
|
24
|
+
type: 'function',
|
|
25
|
+
function: {
|
|
26
|
+
name: t.name,
|
|
27
|
+
description: t.description,
|
|
28
|
+
parameters: t.inputSchema as any,
|
|
29
|
+
},
|
|
30
|
+
}))
|
|
31
|
+
: undefined;
|
|
32
|
+
|
|
33
|
+
const formattedMessages: ChatCompletionMessageParam[] = messages.map((m) => {
|
|
34
|
+
if (m.role === 'tool') {
|
|
35
|
+
return {
|
|
36
|
+
role: 'tool',
|
|
37
|
+
content: m.content,
|
|
38
|
+
tool_call_id: m.tool_call_id!,
|
|
39
|
+
};
|
|
40
|
+
} else if (m.role === 'assistant' && m.tool_calls) {
|
|
41
|
+
return {
|
|
42
|
+
role: 'assistant',
|
|
43
|
+
content: m.content || null,
|
|
44
|
+
tool_calls: m.tool_calls.map((tc) => ({
|
|
45
|
+
id: tc.id,
|
|
46
|
+
type: 'function',
|
|
47
|
+
function: { name: tc.name, arguments: JSON.stringify(tc.arguments) },
|
|
48
|
+
})),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
role: m.role as 'user' | 'assistant' | 'system',
|
|
54
|
+
content: m.content,
|
|
55
|
+
...(m.name ? { name: m.name } : {}),
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const response = await this.client.chat.completions.create({
|
|
60
|
+
model,
|
|
61
|
+
messages: formattedMessages,
|
|
62
|
+
max_tokens: this.config.maxTokens || 4096,
|
|
63
|
+
tools: requestTools,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const choice = response.choices[0];
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
content: choice.message.content || '',
|
|
70
|
+
model: response.model,
|
|
71
|
+
tokens_used: response.usage?.total_tokens,
|
|
72
|
+
finish_reason: choice.finish_reason || undefined,
|
|
73
|
+
tool_calls: choice.message.tool_calls?.map((tc: any) => ({
|
|
74
|
+
id: tc.id,
|
|
75
|
+
name: tc.function.name,
|
|
76
|
+
arguments: JSON.parse(tc.function.arguments || '{}'),
|
|
77
|
+
})),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async *stream(messages: AIMessage[], tools?: PluginTool[]): AsyncGenerator<string> {
|
|
82
|
+
if (!this.client) throw new Error('OpenAI not initialized');
|
|
83
|
+
|
|
84
|
+
const model = this.config.model || 'gpt-4o';
|
|
85
|
+
|
|
86
|
+
const formattedMessages: ChatCompletionMessageParam[] = messages.map((m) => {
|
|
87
|
+
if (m.role === 'tool') {
|
|
88
|
+
return {
|
|
89
|
+
role: 'tool',
|
|
90
|
+
content: m.content,
|
|
91
|
+
tool_call_id: m.tool_call_id!,
|
|
92
|
+
};
|
|
93
|
+
} else if (m.role === 'assistant' && m.tool_calls) {
|
|
94
|
+
return {
|
|
95
|
+
role: 'assistant',
|
|
96
|
+
content: m.content || null,
|
|
97
|
+
tool_calls: m.tool_calls.map((tc) => ({
|
|
98
|
+
id: tc.id,
|
|
99
|
+
type: 'function',
|
|
100
|
+
function: { name: tc.name, arguments: JSON.stringify(tc.arguments) },
|
|
101
|
+
})),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
role: m.role as 'user' | 'assistant' | 'system',
|
|
107
|
+
content: m.content,
|
|
108
|
+
...(m.name ? { name: m.name } : {}),
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const requestTools: ChatCompletionTool[] | undefined = tools?.length
|
|
113
|
+
? tools.map((t) => ({
|
|
114
|
+
type: 'function',
|
|
115
|
+
function: {
|
|
116
|
+
name: t.name,
|
|
117
|
+
description: t.description,
|
|
118
|
+
parameters: t.inputSchema as any,
|
|
119
|
+
},
|
|
120
|
+
}))
|
|
121
|
+
: undefined;
|
|
122
|
+
|
|
123
|
+
const stream = await this.client.chat.completions.create({
|
|
124
|
+
model,
|
|
125
|
+
messages: formattedMessages,
|
|
126
|
+
max_tokens: this.config.maxTokens || 4096,
|
|
127
|
+
stream: true,
|
|
128
|
+
tools: requestTools,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
for await (const chunk of stream) {
|
|
132
|
+
const content = chunk.choices[0]?.delta?.content;
|
|
133
|
+
if (content) {
|
|
134
|
+
yield content;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async test(): Promise<boolean> {
|
|
140
|
+
try {
|
|
141
|
+
await this.complete([{ role: 'user', content: 'Say "OK"' }]);
|
|
142
|
+
return true;
|
|
143
|
+
} catch {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import OpenAI from 'openai';
|
|
2
|
+
import { AIProvider, AIMessage, AIResponse } from './base.js';
|
|
3
|
+
import { PluginTool } from '../plugins/manager.js';
|
|
4
|
+
import { ChatCompletionMessageParam, ChatCompletionTool } from 'openai/resources/chat/completions.js';
|
|
5
|
+
|
|
6
|
+
export class OpenRouterProvider extends AIProvider {
|
|
7
|
+
private client: OpenAI | null = null;
|
|
8
|
+
|
|
9
|
+
async initialize(apiKey: string): Promise<void> {
|
|
10
|
+
this.client = new OpenAI({
|
|
11
|
+
apiKey,
|
|
12
|
+
baseURL: 'https://openrouter.ai/api/v1',
|
|
13
|
+
defaultHeaders: {
|
|
14
|
+
'HTTP-Referer': 'https://github.com/thealxlabs/conductor',
|
|
15
|
+
'X-Title': 'Conductor',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getName(): string {
|
|
21
|
+
return 'OpenRouter';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async complete(messages: AIMessage[], tools?: PluginTool[]): Promise<AIResponse> {
|
|
25
|
+
if (!this.client) throw new Error('OpenRouter not initialized');
|
|
26
|
+
|
|
27
|
+
const model = this.config.model || 'openai/gpt-4o';
|
|
28
|
+
|
|
29
|
+
const requestTools: ChatCompletionTool[] | undefined = tools?.length
|
|
30
|
+
? tools.map((t) => ({
|
|
31
|
+
type: 'function',
|
|
32
|
+
function: {
|
|
33
|
+
name: t.name,
|
|
34
|
+
description: t.description,
|
|
35
|
+
parameters: t.inputSchema as any,
|
|
36
|
+
},
|
|
37
|
+
}))
|
|
38
|
+
: undefined;
|
|
39
|
+
|
|
40
|
+
const formattedMessages: ChatCompletionMessageParam[] = messages.map((m) => {
|
|
41
|
+
if (m.role === 'tool') {
|
|
42
|
+
return {
|
|
43
|
+
role: 'tool',
|
|
44
|
+
content: m.content,
|
|
45
|
+
tool_call_id: m.tool_call_id!,
|
|
46
|
+
};
|
|
47
|
+
} else if (m.role === 'assistant' && m.tool_calls) {
|
|
48
|
+
return {
|
|
49
|
+
role: 'assistant',
|
|
50
|
+
content: m.content || null,
|
|
51
|
+
tool_calls: m.tool_calls.map((tc) => ({
|
|
52
|
+
id: tc.id,
|
|
53
|
+
type: 'function',
|
|
54
|
+
function: { name: tc.name, arguments: JSON.stringify(tc.arguments) },
|
|
55
|
+
})),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
role: m.role as 'user' | 'assistant' | 'system',
|
|
60
|
+
content: m.content,
|
|
61
|
+
...(m.name ? { name: m.name } : {}),
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const response = await this.client.chat.completions.create({
|
|
66
|
+
model,
|
|
67
|
+
messages: formattedMessages,
|
|
68
|
+
max_tokens: this.config.maxTokens || 4096,
|
|
69
|
+
tools: requestTools,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const choice = response.choices[0];
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
content: choice.message.content || '',
|
|
76
|
+
model: response.model,
|
|
77
|
+
tokens_used: response.usage?.total_tokens,
|
|
78
|
+
finish_reason: choice.finish_reason || undefined,
|
|
79
|
+
tool_calls: choice.message.tool_calls?.map((tc: any) => ({
|
|
80
|
+
id: tc.id,
|
|
81
|
+
name: tc.function.name,
|
|
82
|
+
arguments: JSON.parse(tc.function.arguments || '{}'),
|
|
83
|
+
})),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async *stream(messages: AIMessage[], tools?: PluginTool[]): AsyncGenerator<string> {
|
|
88
|
+
if (!this.client) throw new Error('OpenRouter not initialized');
|
|
89
|
+
|
|
90
|
+
const model = this.config.model || 'openai/gpt-4o';
|
|
91
|
+
|
|
92
|
+
const requestTools: ChatCompletionTool[] | undefined = tools?.length
|
|
93
|
+
? tools.map((t) => ({
|
|
94
|
+
type: 'function',
|
|
95
|
+
function: {
|
|
96
|
+
name: t.name,
|
|
97
|
+
description: t.description,
|
|
98
|
+
parameters: t.inputSchema as any,
|
|
99
|
+
},
|
|
100
|
+
}))
|
|
101
|
+
: undefined;
|
|
102
|
+
|
|
103
|
+
const formattedMessages: ChatCompletionMessageParam[] = messages.map((m) => {
|
|
104
|
+
if (m.role === 'tool') {
|
|
105
|
+
return {
|
|
106
|
+
role: 'tool',
|
|
107
|
+
content: m.content,
|
|
108
|
+
tool_call_id: m.tool_call_id!,
|
|
109
|
+
};
|
|
110
|
+
} else if (m.role === 'assistant' && m.tool_calls) {
|
|
111
|
+
return {
|
|
112
|
+
role: 'assistant',
|
|
113
|
+
content: m.content || null,
|
|
114
|
+
tool_calls: m.tool_calls.map((tc) => ({
|
|
115
|
+
id: tc.id,
|
|
116
|
+
type: 'function',
|
|
117
|
+
function: { name: tc.name, arguments: JSON.stringify(tc.arguments) },
|
|
118
|
+
})),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
role: m.role as 'user' | 'assistant' | 'system',
|
|
123
|
+
content: m.content,
|
|
124
|
+
...(m.name ? { name: m.name } : {}),
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const stream = await this.client.chat.completions.create({
|
|
129
|
+
model,
|
|
130
|
+
messages: formattedMessages,
|
|
131
|
+
max_tokens: this.config.maxTokens || 4096,
|
|
132
|
+
stream: true,
|
|
133
|
+
tools: requestTools,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
for await (const chunk of stream) {
|
|
137
|
+
const content = chunk.choices[0]?.delta?.content;
|
|
138
|
+
if (content) {
|
|
139
|
+
yield content;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async test(): Promise<boolean> {
|
|
145
|
+
try {
|
|
146
|
+
await this.complete([{ role: 'user', content: 'Say "OK"' }]);
|
|
147
|
+
return true;
|
|
148
|
+
} catch {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# src/bot
|
|
2
|
+
|
|
3
|
+
Bot integrations for Conductor — Telegram bot and Slack Bolt app.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- `telegram.ts` - Telegram bot integration
|
|
8
|
+
- `slack.ts` - Slack Bolt integration
|
|
9
|
+
|
|
10
|
+
## Architecture
|
|
11
|
+
|
|
12
|
+
Both integrations share the same `Conductor` instance, giving them access to all plugins, AI providers, and tools. The proactive reasoning cycle runs on a timer, calling `plugin.getContext()` on each enabled plugin and feeding results to the AI manager for intelligent responses.
|
package/src/bot/slack.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import bolt from '@slack/bolt';
|
|
2
|
+
const { App } = bolt;
|
|
3
|
+
import { Conductor } from '../core/conductor.js';
|
|
4
|
+
import { Keychain } from '../security/keychain.js';
|
|
5
|
+
import { AIManager } from '../ai/manager.js';
|
|
6
|
+
|
|
7
|
+
export class SlackBot {
|
|
8
|
+
private conductor: Conductor;
|
|
9
|
+
private keychain: Keychain;
|
|
10
|
+
private app: bolt.App | null = null;
|
|
11
|
+
private aiManager: AIManager;
|
|
12
|
+
|
|
13
|
+
constructor(conductor: Conductor) {
|
|
14
|
+
this.conductor = conductor;
|
|
15
|
+
this.keychain = new Keychain(conductor.getConfig().getConfigDir());
|
|
16
|
+
this.aiManager = new AIManager(conductor);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Start the Slack bot. */
|
|
20
|
+
async start(): Promise<void> {
|
|
21
|
+
const botToken = await this.keychain.get('slack', 'bot_token');
|
|
22
|
+
const appToken = await this.keychain.get('slack', 'app_token');
|
|
23
|
+
|
|
24
|
+
if (!botToken || !appToken) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
'Slack tokens not found. Set them in keychain (slack.bot_token, slack.app_token) or run installer.',
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this.app = new App({
|
|
31
|
+
token: botToken,
|
|
32
|
+
appToken: appToken,
|
|
33
|
+
socketMode: true,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
this.registerHandlers();
|
|
37
|
+
|
|
38
|
+
process.stderr.write('Slack bot starting (Socket Mode)...\n');
|
|
39
|
+
await this.app.start();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Register message handlers. */
|
|
43
|
+
private registerHandlers(): void {
|
|
44
|
+
if (!this.app) return;
|
|
45
|
+
|
|
46
|
+
// Default: route text messages through AI
|
|
47
|
+
this.app.message(async ({ message, say }) => {
|
|
48
|
+
// Only respond to text messages
|
|
49
|
+
if (!('text' in message) || !message.text) return;
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const userId = 'user' in message ? String(message.user) : 'unknown-slack-user';
|
|
53
|
+
const agentResponse = await this.aiManager.handleConversation(userId, message.text);
|
|
54
|
+
|
|
55
|
+
await this.sendAgentResponse(say, agentResponse);
|
|
56
|
+
} catch (error: any) {
|
|
57
|
+
process.stderr.write(`Slack AI error: ${error.message}\n`);
|
|
58
|
+
await say(`❌ Error: ${error.message}`);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Handle approvals
|
|
63
|
+
this.app.action('approve_action', async ({ body, ack, say, respond }: any) => {
|
|
64
|
+
await ack();
|
|
65
|
+
await respond({ text: '⏳ Executing approved action...', blocks: [] });
|
|
66
|
+
|
|
67
|
+
const action = (body as any).actions[0];
|
|
68
|
+
const toolCallId = action.value;
|
|
69
|
+
const userId = body.user.id;
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
const agentResponse = await this.aiManager.executeApprovedTool(userId, toolCallId);
|
|
73
|
+
await this.sendAgentResponse(say, agentResponse);
|
|
74
|
+
} catch (error: any) {
|
|
75
|
+
process.stderr.write(`Slack execute error: ${error.message}\n`);
|
|
76
|
+
await say(`❌ Error: ${error.message}`);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Handle denials
|
|
81
|
+
this.app.action('deny_action', async ({ body, ack, say, respond }: any) => {
|
|
82
|
+
await ack();
|
|
83
|
+
await respond({ text: '🛑 Action denied. Informing AI...', blocks: [] });
|
|
84
|
+
|
|
85
|
+
const action = (body as any).actions[0];
|
|
86
|
+
const toolCallId = action.value;
|
|
87
|
+
const userId = body.user.id;
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
const agentResponse = await this.aiManager.denyTool(userId, toolCallId);
|
|
91
|
+
await this.sendAgentResponse(say, agentResponse);
|
|
92
|
+
} catch (error: any) {
|
|
93
|
+
process.stderr.write(`Slack deny error: ${error.message}\n`);
|
|
94
|
+
await say(`❌ Error: ${error.message}`);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Handle commands (Slash commands can be added here)
|
|
99
|
+
this.app.command('/conductor-status', async ({ command: _command, ack, say }) => {
|
|
100
|
+
await ack();
|
|
101
|
+
const config = this.conductor.getConfig();
|
|
102
|
+
const provider = config.get<string>('ai.provider') || 'none';
|
|
103
|
+
const plugins = config.get<string[]>('plugins.enabled') || [];
|
|
104
|
+
|
|
105
|
+
await say(
|
|
106
|
+
`📊 Status:\n` +
|
|
107
|
+
`AI: ${provider}\n` +
|
|
108
|
+
`Plugins: ${plugins.length > 0 ? plugins.join(', ') : 'none'}\n` +
|
|
109
|
+
`User: ${config.get<string>('user.name') || 'not set'}`,
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private async sendAgentResponse(say: any, res: any): Promise<void> {
|
|
115
|
+
if (res.approvalRequired) {
|
|
116
|
+
const { toolCallId, toolName, arguments: args } = res.approvalRequired;
|
|
117
|
+
const text = `*⚠️ Action Requires Approval*\n\nThe AI wants to use the \`${toolName}\` tool.\n\n*Arguments:*\n\`\`\`json\n${JSON.stringify(args, null, 2)}\n\`\`\`\n\n${res.text || 'Do you approve?'}`;
|
|
118
|
+
|
|
119
|
+
await say({
|
|
120
|
+
text: 'Action Requires Approval',
|
|
121
|
+
blocks: [
|
|
122
|
+
{
|
|
123
|
+
type: 'section',
|
|
124
|
+
text: { type: 'mrkdwn', text },
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
type: 'actions',
|
|
128
|
+
elements: [
|
|
129
|
+
{
|
|
130
|
+
type: 'button',
|
|
131
|
+
text: { type: 'plain_text', text: '✅ Approve' },
|
|
132
|
+
style: 'primary',
|
|
133
|
+
value: toolCallId,
|
|
134
|
+
action_id: 'approve_action',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
type: 'button',
|
|
138
|
+
text: { type: 'plain_text', text: '❌ Deny' },
|
|
139
|
+
style: 'danger',
|
|
140
|
+
value: toolCallId,
|
|
141
|
+
action_id: 'deny_action',
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
} else {
|
|
148
|
+
await say(res.text);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Send a proactive message to a specific channel or user. */
|
|
153
|
+
async sendMessage(channelId: string, text: string): Promise<void> {
|
|
154
|
+
if (!this.app) throw new Error('Slack app not started');
|
|
155
|
+
await this.app.client.chat.postMessage({
|
|
156
|
+
channel: channelId,
|
|
157
|
+
text: text,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async stop(): Promise<void> {
|
|
162
|
+
await this.app?.stop();
|
|
163
|
+
}
|
|
164
|
+
}
|