@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/claude.ts
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
2
|
+
import { AIProvider, AIMessage, AIResponse } from './base.js';
|
|
3
|
+
import { PluginTool } from '../plugins/manager.js';
|
|
4
|
+
|
|
5
|
+
export class ClaudeProvider extends AIProvider {
|
|
6
|
+
private client: Anthropic | null = null;
|
|
7
|
+
|
|
8
|
+
async initialize(apiKey: string): Promise<void> {
|
|
9
|
+
this.client = new Anthropic({ apiKey });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
getName(): string {
|
|
13
|
+
return 'Claude';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async complete(messages: AIMessage[], tools?: PluginTool[]): Promise<AIResponse> {
|
|
17
|
+
if (!this.client) throw new Error('Claude not initialized. Call initialize() first.');
|
|
18
|
+
|
|
19
|
+
const model = this.config.model || 'claude-3-5-sonnet-20241022';
|
|
20
|
+
|
|
21
|
+
const requestTools = tools?.map((t) => ({
|
|
22
|
+
name: t.name,
|
|
23
|
+
description: t.description,
|
|
24
|
+
input_schema: t.inputSchema as Anthropic.Tool.InputSchema,
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
// Separate system message from conversation messages
|
|
28
|
+
const anthropicMessages = messages
|
|
29
|
+
.filter((m) => m.role !== 'system')
|
|
30
|
+
.map((m) => {
|
|
31
|
+
if (m.role === 'tool') {
|
|
32
|
+
return {
|
|
33
|
+
role: 'user' as const,
|
|
34
|
+
content: [
|
|
35
|
+
{
|
|
36
|
+
type: 'tool_result' as const,
|
|
37
|
+
tool_use_id: m.tool_call_id!,
|
|
38
|
+
content: m.content,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
} else if (m.role === 'assistant' && m.tool_calls) {
|
|
43
|
+
const content: Anthropic.Messages.ContentBlockParam[] = [];
|
|
44
|
+
if (m.content) content.push({ type: 'text', text: m.content });
|
|
45
|
+
m.tool_calls.forEach((tc) => {
|
|
46
|
+
content.push({
|
|
47
|
+
type: 'tool_use',
|
|
48
|
+
id: tc.id,
|
|
49
|
+
name: tc.name,
|
|
50
|
+
input: tc.arguments,
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
return { role: 'assistant' as const, content };
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
role: m.role as 'user' | 'assistant',
|
|
57
|
+
content: m.content,
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const systemMessage = messages.find((m) => m.role === 'system');
|
|
62
|
+
|
|
63
|
+
const response = await this.client.messages.create({
|
|
64
|
+
model,
|
|
65
|
+
max_tokens: this.config.maxTokens || 4096,
|
|
66
|
+
system: systemMessage?.content,
|
|
67
|
+
messages: anthropicMessages as Anthropic.Messages.MessageParam[],
|
|
68
|
+
tools: requestTools,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const toolCalls = response.content
|
|
72
|
+
.filter((c): c is Anthropic.Messages.ToolUseBlock => c.type === 'tool_use')
|
|
73
|
+
.map((c) => ({
|
|
74
|
+
id: c.id,
|
|
75
|
+
name: c.name,
|
|
76
|
+
arguments: c.input as Record<string, unknown>,
|
|
77
|
+
}));
|
|
78
|
+
|
|
79
|
+
const textContent = response.content
|
|
80
|
+
.filter((c): c is Anthropic.Messages.TextBlock => c.type === 'text')
|
|
81
|
+
.map((c) => c.text)
|
|
82
|
+
.join('\n');
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
content: textContent,
|
|
86
|
+
model: response.model,
|
|
87
|
+
tokens_used: response.usage.input_tokens + response.usage.output_tokens,
|
|
88
|
+
finish_reason: response.stop_reason || undefined,
|
|
89
|
+
tool_calls: toolCalls.length > 0 ? toolCalls : undefined,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async *stream(messages: AIMessage[], tools?: PluginTool[]): AsyncGenerator<string> {
|
|
94
|
+
if (!this.client) throw new Error('Claude not initialized');
|
|
95
|
+
|
|
96
|
+
const model = this.config.model || 'claude-3-5-sonnet-20241022';
|
|
97
|
+
|
|
98
|
+
const requestTools = tools?.map((t) => ({
|
|
99
|
+
name: t.name,
|
|
100
|
+
description: t.description,
|
|
101
|
+
input_schema: t.inputSchema as Anthropic.Tool.InputSchema,
|
|
102
|
+
}));
|
|
103
|
+
|
|
104
|
+
const anthropicMessages = messages
|
|
105
|
+
.filter((m) => m.role !== 'system')
|
|
106
|
+
.map((m) => {
|
|
107
|
+
if (m.role === 'tool') {
|
|
108
|
+
return {
|
|
109
|
+
role: 'user' as const,
|
|
110
|
+
content: [
|
|
111
|
+
{
|
|
112
|
+
type: 'tool_result' as const,
|
|
113
|
+
tool_use_id: m.tool_call_id!,
|
|
114
|
+
content: m.content,
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
};
|
|
118
|
+
} else if (m.role === 'assistant' && m.tool_calls) {
|
|
119
|
+
const content: Anthropic.Messages.ContentBlockParam[] = [];
|
|
120
|
+
if (m.content) content.push({ type: 'text', text: m.content });
|
|
121
|
+
m.tool_calls.forEach((tc) => {
|
|
122
|
+
content.push({
|
|
123
|
+
type: 'tool_use',
|
|
124
|
+
id: tc.id,
|
|
125
|
+
name: tc.name,
|
|
126
|
+
input: tc.arguments,
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
return { role: 'assistant' as const, content };
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
role: m.role as 'user' | 'assistant',
|
|
133
|
+
content: m.content,
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const systemMessage = messages.find((m) => m.role === 'system');
|
|
138
|
+
|
|
139
|
+
const stream = await this.client.messages.stream({
|
|
140
|
+
model,
|
|
141
|
+
max_tokens: this.config.maxTokens || 4096,
|
|
142
|
+
system: systemMessage?.content,
|
|
143
|
+
messages: anthropicMessages as Anthropic.Messages.MessageParam[],
|
|
144
|
+
tools: requestTools,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
for await (const chunk of stream) {
|
|
148
|
+
if (chunk.type === 'content_block_delta' && chunk.delta.type === 'text_delta') {
|
|
149
|
+
yield chunk.delta.text;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async test(): Promise<boolean> {
|
|
155
|
+
try {
|
|
156
|
+
await this.complete([{ role: 'user', content: 'Say "OK" if you can hear me.' }]);
|
|
157
|
+
return true;
|
|
158
|
+
} catch {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
package/src/ai/gemini.ts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { GoogleGenerativeAI, type FunctionDeclaration, type Tool as GeminiTool } from '@google/generative-ai';
|
|
2
|
+
import { AIProvider, AIMessage, AIResponse } from './base.js';
|
|
3
|
+
import { PluginTool } from '../plugins/manager.js';
|
|
4
|
+
import { google } from 'googleapis';
|
|
5
|
+
import type { OAuth2Client } from 'google-auth-library';
|
|
6
|
+
import http from 'http';
|
|
7
|
+
import { URL } from 'url';
|
|
8
|
+
|
|
9
|
+
function convertToGeminiTools(tools?: PluginTool[]): GeminiTool[] {
|
|
10
|
+
if (!tools || tools.length === 0) return [];
|
|
11
|
+
|
|
12
|
+
const declarations: FunctionDeclaration[] = tools.map((t) => ({
|
|
13
|
+
name: t.name,
|
|
14
|
+
description: t.description,
|
|
15
|
+
parameters: t.inputSchema as unknown as FunctionDeclaration['parameters'],
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
return [{ functionDeclarations: declarations }];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class GeminiProvider extends AIProvider {
|
|
22
|
+
private client: GoogleGenerativeAI | null = null;
|
|
23
|
+
private oauth2Client: OAuth2Client | null = null;
|
|
24
|
+
|
|
25
|
+
getName(): string {
|
|
26
|
+
return 'Gemini';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async initialize(apiKey: string): Promise<void> {
|
|
30
|
+
if (!this.config) {
|
|
31
|
+
this.config = {};
|
|
32
|
+
}
|
|
33
|
+
this.config.model = this.config.model || 'gemini-2.0-flash-exp';
|
|
34
|
+
this.client = new GoogleGenerativeAI(apiKey);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async initializeWithOAuth(
|
|
38
|
+
clientId: string,
|
|
39
|
+
clientSecret: string,
|
|
40
|
+
redirectUri = 'http://localhost:3000/google/callback',
|
|
41
|
+
): Promise<string> {
|
|
42
|
+
this.oauth2Client = new google.auth.OAuth2(clientId, clientSecret, redirectUri);
|
|
43
|
+
|
|
44
|
+
const authUrl = this.oauth2Client.generateAuthUrl({
|
|
45
|
+
access_type: 'offline',
|
|
46
|
+
scope: ['https://www.googleapis.com/auth/generative-language'],
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return authUrl;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async completeOAuthFlow(code: string): Promise<void> {
|
|
53
|
+
if (!this.oauth2Client) throw new Error('OAuth not initialized');
|
|
54
|
+
|
|
55
|
+
const { tokens } = await this.oauth2Client.getToken(code);
|
|
56
|
+
this.oauth2Client.setCredentials(tokens);
|
|
57
|
+
|
|
58
|
+
this.client = new GoogleGenerativeAI(tokens.access_token as string);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async loginWithBrowser(): Promise<void> {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
const server = http.createServer(async (req, res) => {
|
|
64
|
+
const url = new URL(req.url || '', 'http://localhost:3000');
|
|
65
|
+
|
|
66
|
+
if (url.pathname === '/google/callback') {
|
|
67
|
+
const code = url.searchParams.get('code');
|
|
68
|
+
|
|
69
|
+
if (code) {
|
|
70
|
+
try {
|
|
71
|
+
await this.completeOAuthFlow(code);
|
|
72
|
+
|
|
73
|
+
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
74
|
+
res.end(`
|
|
75
|
+
<html>
|
|
76
|
+
<body style="font-family: sans-serif; text-align: center; padding: 50px;">
|
|
77
|
+
<h1>Success!</h1>
|
|
78
|
+
<p>You're logged in with Google.</p>
|
|
79
|
+
<p>You can close this window and return to terminal.</p>
|
|
80
|
+
</body>
|
|
81
|
+
</html>
|
|
82
|
+
`);
|
|
83
|
+
|
|
84
|
+
server.close();
|
|
85
|
+
resolve();
|
|
86
|
+
} catch {
|
|
87
|
+
res.writeHead(500, { 'Content-Type': 'text/html' });
|
|
88
|
+
res.end('<h1>Authentication failed</h1>');
|
|
89
|
+
server.close();
|
|
90
|
+
reject(new Error('OAuth flow failed'));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
server.listen(3000);
|
|
97
|
+
server.on('error', reject);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async complete(messages: AIMessage[], tools?: PluginTool[]): Promise<AIResponse> {
|
|
102
|
+
if (!this.client) throw new Error('Gemini not initialized');
|
|
103
|
+
|
|
104
|
+
const model = this.client.getGenerativeModel({
|
|
105
|
+
model: this.config.model || 'gemini-2.0-flash-exp',
|
|
106
|
+
tools: convertToGeminiTools(tools),
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const geminiMessages = messages
|
|
110
|
+
.filter((m) => m.role !== 'system')
|
|
111
|
+
.map((m) => ({
|
|
112
|
+
role: m.role === 'assistant' ? ('model' as const) : ('user' as const),
|
|
113
|
+
parts: [{ text: m.content }],
|
|
114
|
+
}));
|
|
115
|
+
|
|
116
|
+
const systemInstruction = messages.find((m) => m.role === 'system');
|
|
117
|
+
|
|
118
|
+
const chat = model.startChat({
|
|
119
|
+
history: geminiMessages.slice(0, -1),
|
|
120
|
+
systemInstruction: systemInstruction?.content,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const lastMessage = geminiMessages[geminiMessages.length - 1];
|
|
124
|
+
const result = await chat.sendMessage(lastMessage.parts[0].text);
|
|
125
|
+
const response = result.response;
|
|
126
|
+
|
|
127
|
+
// Check for function calls
|
|
128
|
+
const functionCalls = response.functionCalls();
|
|
129
|
+
if (functionCalls && functionCalls.length > 0) {
|
|
130
|
+
const fc = functionCalls[0];
|
|
131
|
+
return {
|
|
132
|
+
content: response.text() || '',
|
|
133
|
+
model: this.config.model || 'gemini-2.0-flash-exp',
|
|
134
|
+
tokens_used: response.usageMetadata?.totalTokenCount,
|
|
135
|
+
tool_calls: [
|
|
136
|
+
{
|
|
137
|
+
id: fc.name,
|
|
138
|
+
name: fc.name,
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
140
|
+
arguments: (fc.args ?? {}) as Record<string, any>,
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
content: response.text(),
|
|
148
|
+
model: this.config.model || 'gemini-2.0-flash-exp',
|
|
149
|
+
tokens_used: response.usageMetadata?.totalTokenCount,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async *stream(messages: AIMessage[], tools?: PluginTool[]): AsyncGenerator<string> {
|
|
154
|
+
if (!this.client) throw new Error('Gemini not initialized');
|
|
155
|
+
|
|
156
|
+
const model = this.client.getGenerativeModel({
|
|
157
|
+
model: this.config.model || 'gemini-2.0-flash-exp',
|
|
158
|
+
tools: convertToGeminiTools(tools),
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
const geminiMessages = messages
|
|
162
|
+
.filter((m) => m.role !== 'system')
|
|
163
|
+
.map((m) => ({
|
|
164
|
+
role: m.role === 'assistant' ? ('model' as const) : ('user' as const),
|
|
165
|
+
parts: [{ text: m.content }],
|
|
166
|
+
}));
|
|
167
|
+
|
|
168
|
+
const chat = model.startChat({
|
|
169
|
+
history: geminiMessages.slice(0, -1),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const lastMessage = geminiMessages[geminiMessages.length - 1];
|
|
173
|
+
const result = await chat.sendMessageStream(lastMessage.parts[0].text);
|
|
174
|
+
|
|
175
|
+
for await (const chunk of result.stream) {
|
|
176
|
+
yield chunk.text();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async test(): Promise<boolean> {
|
|
181
|
+
try {
|
|
182
|
+
await this.complete([{ role: 'user', content: 'Say "OK"' }]);
|
|
183
|
+
return true;
|
|
184
|
+
} catch {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { AIProvider, AIMessage, AIResponse } from './base.js';
|
|
2
|
+
import { PluginTool } from '../plugins/manager.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Maestro Provider — connects to a locally running Maestro model via Ollama.
|
|
6
|
+
* Maestro is a fine-tuned Qwen2.5-Coder 7B model by TheAlxLabs, optimized
|
|
7
|
+
* for coding assistance, bug fixing, documentation, and code explanation.
|
|
8
|
+
*/
|
|
9
|
+
export class MaestroProvider extends AIProvider {
|
|
10
|
+
private endpoint: string;
|
|
11
|
+
private modelName: string;
|
|
12
|
+
|
|
13
|
+
constructor(config: any) {
|
|
14
|
+
super(config);
|
|
15
|
+
this.endpoint = config.endpoint || 'http://localhost:11434';
|
|
16
|
+
this.modelName = config.model || 'maestro';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getName(): string {
|
|
20
|
+
return 'Maestro';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async initialize(): Promise<void> {
|
|
24
|
+
const isRunning = await this.test();
|
|
25
|
+
if (!isRunning) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
'Maestro is not running. Make sure Ollama is running and the Maestro model is pulled.\n' +
|
|
28
|
+
'Run: ollama pull thealxlabs/maestro',
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async complete(messages: AIMessage[], _tools?: PluginTool[]): Promise<AIResponse> {
|
|
34
|
+
const formattedMessages = this.formatMessages(messages);
|
|
35
|
+
|
|
36
|
+
const response = await fetch(`${this.endpoint}/api/chat`, {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers: { 'Content-Type': 'application/json' },
|
|
39
|
+
body: JSON.stringify({
|
|
40
|
+
model: this.modelName,
|
|
41
|
+
messages: formattedMessages,
|
|
42
|
+
stream: false,
|
|
43
|
+
options: {
|
|
44
|
+
temperature: 0.2, // Lower = more precise code output
|
|
45
|
+
top_p: 0.95,
|
|
46
|
+
repeat_penalty: 1.1,
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
throw new Error(`Maestro error: ${response.statusText}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const data = (await response.json()) as any;
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
content: data.message.content,
|
|
59
|
+
model: `maestro (${data.model})`,
|
|
60
|
+
tokens_used: data.eval_count,
|
|
61
|
+
finish_reason: data.done ? 'stop' : undefined,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async *stream(messages: AIMessage[], _tools?: PluginTool[]): AsyncGenerator<string> {
|
|
66
|
+
const formattedMessages = this.formatMessages(messages);
|
|
67
|
+
|
|
68
|
+
const response = await fetch(`${this.endpoint}/api/chat`, {
|
|
69
|
+
method: 'POST',
|
|
70
|
+
headers: { 'Content-Type': 'application/json' },
|
|
71
|
+
body: JSON.stringify({
|
|
72
|
+
model: this.modelName,
|
|
73
|
+
messages: formattedMessages,
|
|
74
|
+
stream: true,
|
|
75
|
+
options: {
|
|
76
|
+
temperature: 0.2,
|
|
77
|
+
top_p: 0.95,
|
|
78
|
+
repeat_penalty: 1.1,
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (!response.ok || !response.body) {
|
|
84
|
+
throw new Error(`Maestro stream error: ${response.statusText}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const reader = response.body.getReader();
|
|
88
|
+
const decoder = new TextDecoder();
|
|
89
|
+
|
|
90
|
+
while (true) {
|
|
91
|
+
const { done, value } = await reader.read();
|
|
92
|
+
if (done) break;
|
|
93
|
+
|
|
94
|
+
const chunk = decoder.decode(value);
|
|
95
|
+
const lines = chunk.split('\n').filter((l) => l.trim());
|
|
96
|
+
|
|
97
|
+
for (const line of lines) {
|
|
98
|
+
try {
|
|
99
|
+
const json = JSON.parse(line);
|
|
100
|
+
if (json.message?.content) {
|
|
101
|
+
yield json.message.content;
|
|
102
|
+
}
|
|
103
|
+
} catch {
|
|
104
|
+
// Skip invalid JSON fragments
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async test(): Promise<boolean> {
|
|
111
|
+
try {
|
|
112
|
+
// Check Ollama is running
|
|
113
|
+
const tagsResponse = await fetch(`${this.endpoint}/api/tags`);
|
|
114
|
+
if (!tagsResponse.ok) return false;
|
|
115
|
+
|
|
116
|
+
// Check Maestro model is available
|
|
117
|
+
const data = (await tagsResponse.json()) as any;
|
|
118
|
+
const models: string[] = data.models?.map((m: any) => m.name) || [];
|
|
119
|
+
const hasMaestro = models.some((m) => m.includes('maestro'));
|
|
120
|
+
|
|
121
|
+
if (!hasMaestro) {
|
|
122
|
+
console.warn('\n⚠️ Maestro model not found in Ollama.\n' + 'Pull it with: ollama pull thealxlabs/maestro\n');
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return true;
|
|
127
|
+
} catch {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Pull the Maestro model via Ollama */
|
|
133
|
+
async pullModel(): Promise<void> {
|
|
134
|
+
console.log('🎼 Pulling Maestro model from Ollama registry...');
|
|
135
|
+
const response = await fetch(`${this.endpoint}/api/pull`, {
|
|
136
|
+
method: 'POST',
|
|
137
|
+
headers: { 'Content-Type': 'application/json' },
|
|
138
|
+
body: JSON.stringify({ name: this.modelName, stream: false }),
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
if (!response.ok) {
|
|
142
|
+
throw new Error(`Failed to pull Maestro: ${response.statusText}`);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
console.log('✅ Maestro model ready!');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Format messages into Ollama-compatible format with Maestro system prompt */
|
|
149
|
+
private formatMessages(messages: AIMessage[]) {
|
|
150
|
+
const hasSytem = messages.some((m) => m.role === 'system');
|
|
151
|
+
|
|
152
|
+
const maestroSystem: AIMessage = {
|
|
153
|
+
role: 'system',
|
|
154
|
+
content:
|
|
155
|
+
'You are Maestro, an elite AI coding assistant by TheAlxLabs. ' +
|
|
156
|
+
'You specialize in writing clean, efficient, well-documented code across all languages. ' +
|
|
157
|
+
'You excel at fixing bugs, explaining complex code, and writing documentation. ' +
|
|
158
|
+
'Always provide accurate, working code. Be concise but thorough.',
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const allMessages = hasSytem ? messages : [maestroSystem, ...messages];
|
|
162
|
+
|
|
163
|
+
return allMessages.map((m) => ({
|
|
164
|
+
role: m.role,
|
|
165
|
+
content: m.content,
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
}
|