@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
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit Logger — Stripe-grade audit trail for every action.
|
|
3
|
+
*
|
|
4
|
+
* Every tool call, config change, auth event, and plugin lifecycle event
|
|
5
|
+
* is logged with: timestamp, actor, action, resource, result, metadata.
|
|
6
|
+
*
|
|
7
|
+
* Logs are append-only, tamper-evident (SHA-256 chain), and queryable.
|
|
8
|
+
* Designed for SOC 2 compliance from day one.
|
|
9
|
+
*/
|
|
10
|
+
import fs from 'fs/promises';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import crypto from 'crypto';
|
|
13
|
+
export class AuditLogger {
|
|
14
|
+
logDir;
|
|
15
|
+
currentFile;
|
|
16
|
+
lastHash;
|
|
17
|
+
maxFileSize;
|
|
18
|
+
buffer;
|
|
19
|
+
flushTimer;
|
|
20
|
+
constructor(configDir, options) {
|
|
21
|
+
this.logDir = path.join(configDir, 'audit');
|
|
22
|
+
this.currentFile = path.join(this.logDir, 'audit.log');
|
|
23
|
+
this.lastHash = '0000000000000000000000000000000000000000000000000000000000000000';
|
|
24
|
+
this.maxFileSize = (options?.maxFileSizeMB ?? 100) * 1024 * 1024;
|
|
25
|
+
this.buffer = [];
|
|
26
|
+
this.flushTimer = null;
|
|
27
|
+
const flushInterval = options?.flushIntervalMs ?? 1000;
|
|
28
|
+
this.flushTimer = setInterval(() => this.flush().catch(() => { }), flushInterval);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Log an audit entry. Appends to buffer, flushes periodically.
|
|
32
|
+
*/
|
|
33
|
+
async log(entry) {
|
|
34
|
+
const timestamp = new Date().toISOString();
|
|
35
|
+
const content = JSON.stringify({ ...entry, timestamp, previousHash: '' });
|
|
36
|
+
const hash = crypto
|
|
37
|
+
.createHash('sha256')
|
|
38
|
+
.update(this.lastHash + content)
|
|
39
|
+
.digest('hex');
|
|
40
|
+
const fullEntry = {
|
|
41
|
+
...entry,
|
|
42
|
+
timestamp,
|
|
43
|
+
previousHash: this.lastHash,
|
|
44
|
+
hash,
|
|
45
|
+
};
|
|
46
|
+
this.buffer.push(fullEntry);
|
|
47
|
+
this.lastHash = hash;
|
|
48
|
+
// Flush immediately for security-critical events
|
|
49
|
+
if (entry.action === 'auth_login' || entry.action === 'auth_failure' || entry.action === 'config_set') {
|
|
50
|
+
await this.flush();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Convenience: log a tool call.
|
|
55
|
+
*/
|
|
56
|
+
async toolCall(actor, tool, input, result, metadata = {}) {
|
|
57
|
+
await this.log({
|
|
58
|
+
actor,
|
|
59
|
+
action: 'tool_call',
|
|
60
|
+
resource: tool,
|
|
61
|
+
result,
|
|
62
|
+
metadata: { input: this.redactSensitive(input), ...metadata },
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Convenience: log a config change.
|
|
67
|
+
*/
|
|
68
|
+
async configChange(actor, key, oldValue, newValue) {
|
|
69
|
+
await this.log({
|
|
70
|
+
actor,
|
|
71
|
+
action: 'config_set',
|
|
72
|
+
resource: key,
|
|
73
|
+
result: 'success',
|
|
74
|
+
metadata: { old_value: this.redactSensitive(oldValue), new_value: this.redactSensitive(newValue) },
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Convenience: log an auth event.
|
|
79
|
+
*/
|
|
80
|
+
async authEvent(actor, method, success, metadata = {}) {
|
|
81
|
+
await this.log({
|
|
82
|
+
actor,
|
|
83
|
+
action: success ? 'auth_login' : 'auth_failure',
|
|
84
|
+
resource: method,
|
|
85
|
+
result: success ? 'success' : 'failure',
|
|
86
|
+
metadata,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Convenience: log a plugin lifecycle event.
|
|
91
|
+
*/
|
|
92
|
+
async pluginEvent(actor, plugin, action, metadata = {}) {
|
|
93
|
+
await this.log({
|
|
94
|
+
actor,
|
|
95
|
+
action: `plugin_${action}`,
|
|
96
|
+
resource: plugin,
|
|
97
|
+
result: 'success',
|
|
98
|
+
metadata,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Query audit logs with filters.
|
|
103
|
+
*/
|
|
104
|
+
async query(options) {
|
|
105
|
+
const entries = [];
|
|
106
|
+
try {
|
|
107
|
+
const files = await fs.readdir(this.logDir);
|
|
108
|
+
const logFiles = files.filter((f) => f.endsWith('.log')).sort();
|
|
109
|
+
for (const file of logFiles) {
|
|
110
|
+
const content = await fs.readFile(path.join(this.logDir, file), 'utf-8');
|
|
111
|
+
for (const line of content.split('\n').filter((l) => l.trim())) {
|
|
112
|
+
try {
|
|
113
|
+
const entry = JSON.parse(line);
|
|
114
|
+
if (options?.actor && entry.actor !== options.actor)
|
|
115
|
+
continue;
|
|
116
|
+
if (options?.action && entry.action !== options.action)
|
|
117
|
+
continue;
|
|
118
|
+
if (options?.resource && entry.resource !== options.resource)
|
|
119
|
+
continue;
|
|
120
|
+
if (options?.result && entry.result !== options.result)
|
|
121
|
+
continue;
|
|
122
|
+
if (options?.since && entry.timestamp < options.since)
|
|
123
|
+
continue;
|
|
124
|
+
entries.push(entry);
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
// Skip malformed lines
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// No logs yet
|
|
134
|
+
}
|
|
135
|
+
const limit = options?.limit ?? 1000;
|
|
136
|
+
return entries.slice(-limit);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Verify the integrity of the audit log chain.
|
|
140
|
+
* Returns true if no tampering detected.
|
|
141
|
+
*/
|
|
142
|
+
async verifyIntegrity() {
|
|
143
|
+
try {
|
|
144
|
+
const content = await fs.readFile(this.currentFile, 'utf-8');
|
|
145
|
+
const lines = content.split('\n').filter((l) => l.trim());
|
|
146
|
+
let prevHash = '0000000000000000000000000000000000000000000000000000000000000000';
|
|
147
|
+
for (const line of lines) {
|
|
148
|
+
const entry = JSON.parse(line);
|
|
149
|
+
// Reconstruct what the hash should be
|
|
150
|
+
const expectedHash = crypto
|
|
151
|
+
.createHash('sha256')
|
|
152
|
+
.update(prevHash + JSON.stringify({ ...entry, previousHash: entry.previousHash }))
|
|
153
|
+
.digest('hex');
|
|
154
|
+
if (entry.hash !== expectedHash) {
|
|
155
|
+
return { valid: false, brokenAt: entry.timestamp };
|
|
156
|
+
}
|
|
157
|
+
prevHash = entry.hash;
|
|
158
|
+
}
|
|
159
|
+
return { valid: true };
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
return { valid: true }; // No logs = no tampering
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Flush the buffer to disk.
|
|
167
|
+
*/
|
|
168
|
+
async flush() {
|
|
169
|
+
if (this.buffer.length === 0)
|
|
170
|
+
return;
|
|
171
|
+
const entries = [...this.buffer];
|
|
172
|
+
this.buffer = [];
|
|
173
|
+
try {
|
|
174
|
+
await fs.mkdir(this.logDir, { recursive: true, mode: 0o700 });
|
|
175
|
+
// Rotate if file is too large
|
|
176
|
+
try {
|
|
177
|
+
const stat = await fs.stat(this.currentFile);
|
|
178
|
+
if (stat.size > this.maxFileSize) {
|
|
179
|
+
const rotated = `${this.currentFile}.${Date.now()}.log`;
|
|
180
|
+
await fs.rename(this.currentFile, rotated);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
// File doesn't exist yet
|
|
185
|
+
}
|
|
186
|
+
const lines = entries.map((e) => JSON.stringify(e)).join('\n') + '\n';
|
|
187
|
+
await fs.appendFile(this.currentFile, lines, { mode: 0o600 });
|
|
188
|
+
}
|
|
189
|
+
catch (err) {
|
|
190
|
+
// Put entries back in buffer on failure
|
|
191
|
+
this.buffer.unshift(...entries);
|
|
192
|
+
throw err;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Close the logger and flush remaining entries.
|
|
197
|
+
*/
|
|
198
|
+
async close() {
|
|
199
|
+
if (this.flushTimer) {
|
|
200
|
+
clearInterval(this.flushTimer);
|
|
201
|
+
this.flushTimer = null;
|
|
202
|
+
}
|
|
203
|
+
await this.flush();
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Redact sensitive values from metadata.
|
|
207
|
+
*/
|
|
208
|
+
redactSensitive(value) {
|
|
209
|
+
if (typeof value === 'string') {
|
|
210
|
+
// Redact anything that looks like a token, key, or password
|
|
211
|
+
if (/^(ghp_|xoxb_|xapp_|sk-|Bearer |token_|api_key_|password)/i.test(value)) {
|
|
212
|
+
return '[REDACTED]';
|
|
213
|
+
}
|
|
214
|
+
if (value.length > 1000) {
|
|
215
|
+
return `[truncated: ${value.length} chars]`;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (typeof value === 'object' && value !== null) {
|
|
219
|
+
const result = {};
|
|
220
|
+
for (const [k, v] of Object.entries(value)) {
|
|
221
|
+
if (/secret|token|key|password|auth/i.test(k)) {
|
|
222
|
+
result[k] = '[REDACTED]';
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
result[k] = v;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
230
|
+
return value;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/core/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAqB5B,MAAM,OAAO,WAAW;IACd,MAAM,CAAS;IACf,WAAW,CAAS;IACpB,QAAQ,CAAS;IACjB,WAAW,CAAS;IACpB,MAAM,CAAe;IACrB,UAAU,CAAwB;IAE1C,YAAY,SAAiB,EAAE,OAA8D;QAC3F,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QACvD,IAAI,CAAC,QAAQ,GAAG,kEAAkE,CAAC;QACnF,IAAI,CAAC,WAAW,GAAG,CAAC,OAAO,EAAE,aAAa,IAAI,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;QACjE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QAEvB,MAAM,aAAa,GAAG,OAAO,EAAE,eAAe,IAAI,IAAI,CAAC;QACvD,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,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C,UAAU,EAAE,CAAC;YACpB,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC/B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,CAAC;QACD,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED;;OAEG;IACK,eAAe,CAAC,KAAc;QACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,4DAA4D;YAC5D,IAAI,2DAA2D,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5E,OAAO,YAAY,CAAC;YACtB,CAAC;YACD,IAAI,KAAK,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC;gBACxB,OAAO,eAAe,KAAK,CAAC,MAAM,SAAS,CAAC;YAC9C,CAAC;QACH,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAChD,MAAM,MAAM,GAA4B,EAAE,CAAC;YAC3C,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3C,IAAI,iCAAiC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC9C,MAAM,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC;gBAC3B,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBAChB,CAAC;YACH,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Circuit Breaker — prevents cascading failures.
|
|
3
|
+
*
|
|
4
|
+
* When a tool or dependency fails repeatedly, the circuit opens and
|
|
5
|
+
* subsequent calls fail fast without hitting the failing service.
|
|
6
|
+
* After a cooldown period, the circuit half-opens to test recovery.
|
|
7
|
+
*
|
|
8
|
+
* States: CLOSED (normal) → OPEN (failing) → HALF_OPEN (testing) → CLOSED
|
|
9
|
+
*/
|
|
10
|
+
export type CircuitState = 'closed' | 'open' | 'half_open';
|
|
11
|
+
export interface CircuitBreakerOptions {
|
|
12
|
+
/** Number of failures before opening the circuit */
|
|
13
|
+
failureThreshold: number;
|
|
14
|
+
/** Time in ms before attempting recovery */
|
|
15
|
+
recoveryTimeout: number;
|
|
16
|
+
/** Number of successful calls in half_open to close the circuit */
|
|
17
|
+
successThreshold: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class CircuitBreaker {
|
|
20
|
+
private state;
|
|
21
|
+
private failures;
|
|
22
|
+
private successes;
|
|
23
|
+
private lastFailureAt;
|
|
24
|
+
private options;
|
|
25
|
+
constructor(options?: Partial<CircuitBreakerOptions>);
|
|
26
|
+
getState(): CircuitState;
|
|
27
|
+
/**
|
|
28
|
+
* Execute a function through the circuit breaker.
|
|
29
|
+
* Throws CircuitOpenError if the circuit is open.
|
|
30
|
+
*/
|
|
31
|
+
execute<T>(fn: () => Promise<T>): Promise<T>;
|
|
32
|
+
/**
|
|
33
|
+
* Record a successful call.
|
|
34
|
+
*/
|
|
35
|
+
private onSuccess;
|
|
36
|
+
/**
|
|
37
|
+
* Record a failed call.
|
|
38
|
+
*/
|
|
39
|
+
private onFailure;
|
|
40
|
+
/**
|
|
41
|
+
* Reset the circuit breaker to closed state.
|
|
42
|
+
*/
|
|
43
|
+
reset(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Get circuit breaker status for health checks.
|
|
46
|
+
*/
|
|
47
|
+
getStatus(): {
|
|
48
|
+
state: CircuitState;
|
|
49
|
+
failures: number;
|
|
50
|
+
successes: number;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export declare class CircuitOpenError extends Error {
|
|
54
|
+
constructor(message: string);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=circuit-breaker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circuit-breaker.d.ts","sourceRoot":"","sources":["../../src/core/circuit-breaker.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;AAE3D,MAAM,WAAW,qBAAqB;IACpC,oDAAoD;IACpD,gBAAgB,EAAE,MAAM,CAAC;IACzB,4CAA4C;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,mEAAmE;IACnE,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAQD,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,OAAO,CAAwB;gBAE3B,OAAO,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC;IAIpD,QAAQ,IAAI,YAAY;IAWxB;;;OAGG;IACG,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAiBlD;;OAEG;IACH,OAAO,CAAC,SAAS;IAYjB;;OAEG;IACH,OAAO,CAAC,SAAS;IAajB;;OAEG;IACH,KAAK,IAAI,IAAI;IAOb;;OAEG;IACH,SAAS,IAAI;QAAE,KAAK,EAAE,YAAY,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;CAO1E;AAED,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Circuit Breaker — prevents cascading failures.
|
|
3
|
+
*
|
|
4
|
+
* When a tool or dependency fails repeatedly, the circuit opens and
|
|
5
|
+
* subsequent calls fail fast without hitting the failing service.
|
|
6
|
+
* After a cooldown period, the circuit half-opens to test recovery.
|
|
7
|
+
*
|
|
8
|
+
* States: CLOSED (normal) → OPEN (failing) → HALF_OPEN (testing) → CLOSED
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULTS = {
|
|
11
|
+
failureThreshold: 5,
|
|
12
|
+
recoveryTimeout: 60_000,
|
|
13
|
+
successThreshold: 2,
|
|
14
|
+
};
|
|
15
|
+
export class CircuitBreaker {
|
|
16
|
+
state = 'closed';
|
|
17
|
+
failures = 0;
|
|
18
|
+
successes = 0;
|
|
19
|
+
lastFailureAt = 0;
|
|
20
|
+
options;
|
|
21
|
+
constructor(options) {
|
|
22
|
+
this.options = { ...DEFAULTS, ...options };
|
|
23
|
+
}
|
|
24
|
+
getState() {
|
|
25
|
+
if (this.state === 'open') {
|
|
26
|
+
// Check if recovery timeout has elapsed
|
|
27
|
+
if (Date.now() - this.lastFailureAt >= this.options.recoveryTimeout) {
|
|
28
|
+
this.state = 'half_open';
|
|
29
|
+
this.successes = 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return this.state;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Execute a function through the circuit breaker.
|
|
36
|
+
* Throws CircuitOpenError if the circuit is open.
|
|
37
|
+
*/
|
|
38
|
+
async execute(fn) {
|
|
39
|
+
const state = this.getState();
|
|
40
|
+
if (state === 'open') {
|
|
41
|
+
throw new CircuitOpenError('Circuit breaker is open — call rejected');
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const result = await fn();
|
|
45
|
+
this.onSuccess();
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
this.onFailure();
|
|
50
|
+
throw err;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Record a successful call.
|
|
55
|
+
*/
|
|
56
|
+
onSuccess() {
|
|
57
|
+
this.failures = 0;
|
|
58
|
+
if (this.state === 'half_open') {
|
|
59
|
+
this.successes++;
|
|
60
|
+
if (this.successes >= this.options.successThreshold) {
|
|
61
|
+
this.state = 'closed';
|
|
62
|
+
this.successes = 0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Record a failed call.
|
|
68
|
+
*/
|
|
69
|
+
onFailure() {
|
|
70
|
+
this.failures++;
|
|
71
|
+
this.lastFailureAt = Date.now();
|
|
72
|
+
if (this.state === 'half_open') {
|
|
73
|
+
// Any failure in half_open re-opens the circuit
|
|
74
|
+
this.state = 'open';
|
|
75
|
+
this.successes = 0;
|
|
76
|
+
}
|
|
77
|
+
else if (this.failures >= this.options.failureThreshold) {
|
|
78
|
+
this.state = 'open';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Reset the circuit breaker to closed state.
|
|
83
|
+
*/
|
|
84
|
+
reset() {
|
|
85
|
+
this.state = 'closed';
|
|
86
|
+
this.failures = 0;
|
|
87
|
+
this.successes = 0;
|
|
88
|
+
this.lastFailureAt = 0;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get circuit breaker status for health checks.
|
|
92
|
+
*/
|
|
93
|
+
getStatus() {
|
|
94
|
+
return {
|
|
95
|
+
state: this.getState(),
|
|
96
|
+
failures: this.failures,
|
|
97
|
+
successes: this.successes,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export class CircuitOpenError extends Error {
|
|
102
|
+
constructor(message) {
|
|
103
|
+
super(message);
|
|
104
|
+
this.name = 'CircuitOpenError';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=circuit-breaker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circuit-breaker.js","sourceRoot":"","sources":["../../src/core/circuit-breaker.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,MAAM,QAAQ,GAA0B;IACtC,gBAAgB,EAAE,CAAC;IACnB,eAAe,E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F"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ConfigManager } from './config.js';
|
|
2
|
+
import { DatabaseManager } from './database.js';
|
|
3
|
+
import { PluginManager } from '../plugins/manager.js';
|
|
4
|
+
import { AIManager } from '../ai/manager.js';
|
|
5
|
+
import type { ConductorNotification } from './interfaces.js';
|
|
6
|
+
export interface ConductorOptions {
|
|
7
|
+
/** Suppress stdout output (required for MCP mode where stdout is protocol). */
|
|
8
|
+
quiet?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class Conductor {
|
|
11
|
+
private config;
|
|
12
|
+
private db;
|
|
13
|
+
private plugins;
|
|
14
|
+
private ai;
|
|
15
|
+
private initialized;
|
|
16
|
+
private quiet;
|
|
17
|
+
private proactiveTimer?;
|
|
18
|
+
private notificationHandler?;
|
|
19
|
+
/** Prevents overlapping proactive reasoning cycles. */
|
|
20
|
+
private _cycleRunning;
|
|
21
|
+
constructor(configPath?: string, options?: ConductorOptions);
|
|
22
|
+
initialize(): Promise<void>;
|
|
23
|
+
getConfig(): ConfigManager;
|
|
24
|
+
getDatabase(): DatabaseManager;
|
|
25
|
+
isInitialized(): boolean;
|
|
26
|
+
shutdown(): Promise<void>;
|
|
27
|
+
getUserInfo(): Promise<unknown>;
|
|
28
|
+
getTelegramConfig(): Promise<unknown>;
|
|
29
|
+
getAIConfig(): Promise<unknown>;
|
|
30
|
+
getPlugins(): Promise<any[]>;
|
|
31
|
+
getRecentActivity(limit?: number): Promise<any[]>;
|
|
32
|
+
getPluginsManager(): PluginManager;
|
|
33
|
+
getAIManager(): AIManager;
|
|
34
|
+
/** Set a handler for proactive notifications (e.g. from the heartbeat loop). */
|
|
35
|
+
setNotificationHandler(handler: (notification: ConductorNotification) => Promise<void>): void;
|
|
36
|
+
/** Send a proactive notification to the user via the registered handler. */
|
|
37
|
+
notifyUser(notification: ConductorNotification): Promise<void>;
|
|
38
|
+
/** Start the proactive autonomous loop. */
|
|
39
|
+
startProactiveMode(intervalMinutes?: number): Promise<void>;
|
|
40
|
+
stopProactiveMode(): Promise<void>;
|
|
41
|
+
private gatherContext;
|
|
42
|
+
runReasoningCycle(): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=conductor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conductor.d.ts","sourceRoot":"","sources":["../../src/core/conductor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,gBAAgB;IAC/B,+EAA+E;IAC/E,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,EAAE,CAAkB;IAC5B,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,EAAE,CAAY;IACtB,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,cAAc,CAAC,CAAiB;IACxC,OAAO,CAAC,mBAAmB,CAAC,CAAyD;IACrF,uDAAuD;IACvD,OAAO,CAAC,aAAa,CAAS;gBAElB,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB;IAQrD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBjC,SAAS,IAAI,aAAa;IAI1B,WAAW,IAAI,eAAe;IAI9B,aAAa,IAAI,OAAO;IAIlB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAQzB,WAAW;IAIX,iBAAiB;IAIjB,WAAW;IAIX,UAAU;IAIV,iBAAiB,CAAC,KAAK,GAAE,MAAW;IAI1C,iBAAiB,IAAI,aAAa;IAIlC,YAAY,IAAI,SAAS;IAIzB,gFAAgF;IAChF,sBAAsB,CAAC,OAAO,EAAE,CAAC,YAAY,EAAE,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAI7F,4EAA4E;IACtE,UAAU,CAAC,YAAY,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpE,2CAA2C;IACrC,kBAAkB,CAAC,eAAe,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB/D,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;YAO1B,aAAa;IA+Cd,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;CAqDhD"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { ConfigManager } from './config.js';
|
|
2
|
+
import { DatabaseManager } from './database.js';
|
|
3
|
+
import { PluginManager } from '../plugins/manager.js';
|
|
4
|
+
import { AIManager } from '../ai/manager.js';
|
|
5
|
+
export class Conductor {
|
|
6
|
+
config;
|
|
7
|
+
db;
|
|
8
|
+
plugins;
|
|
9
|
+
ai;
|
|
10
|
+
initialized = false;
|
|
11
|
+
quiet;
|
|
12
|
+
proactiveTimer;
|
|
13
|
+
notificationHandler;
|
|
14
|
+
/** Prevents overlapping proactive reasoning cycles. */
|
|
15
|
+
_cycleRunning = false;
|
|
16
|
+
constructor(configPath, options) {
|
|
17
|
+
this.config = new ConfigManager(configPath);
|
|
18
|
+
this.db = new DatabaseManager(this.config.getConfigDir());
|
|
19
|
+
this.plugins = new PluginManager(this);
|
|
20
|
+
this.ai = new AIManager(this);
|
|
21
|
+
this.quiet = options?.quiet ?? false;
|
|
22
|
+
}
|
|
23
|
+
async initialize() {
|
|
24
|
+
if (this.initialized)
|
|
25
|
+
return;
|
|
26
|
+
if (!this.quiet) {
|
|
27
|
+
process.stderr.write('Initializing Conductor...\n');
|
|
28
|
+
}
|
|
29
|
+
await this.config.initialize();
|
|
30
|
+
await this.db.initialize();
|
|
31
|
+
await this.plugins.loadBuiltins();
|
|
32
|
+
this.initialized = true;
|
|
33
|
+
await this.db.logActivity('system', 'conductor_initialized');
|
|
34
|
+
}
|
|
35
|
+
getConfig() {
|
|
36
|
+
return this.config;
|
|
37
|
+
}
|
|
38
|
+
getDatabase() {
|
|
39
|
+
return this.db;
|
|
40
|
+
}
|
|
41
|
+
isInitialized() {
|
|
42
|
+
return this.initialized;
|
|
43
|
+
}
|
|
44
|
+
async shutdown() {
|
|
45
|
+
if (this.initialized) {
|
|
46
|
+
await this.db.logActivity('system', 'conductor_shutdown');
|
|
47
|
+
await this.db.close();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Quick access methods
|
|
51
|
+
async getUserInfo() {
|
|
52
|
+
return this.config.get('user');
|
|
53
|
+
}
|
|
54
|
+
async getTelegramConfig() {
|
|
55
|
+
return this.config.get('telegram');
|
|
56
|
+
}
|
|
57
|
+
async getAIConfig() {
|
|
58
|
+
return this.config.get('ai');
|
|
59
|
+
}
|
|
60
|
+
async getPlugins() {
|
|
61
|
+
return this.db.getPlugins();
|
|
62
|
+
}
|
|
63
|
+
async getRecentActivity(limit = 20) {
|
|
64
|
+
return this.db.getRecentActivity(limit);
|
|
65
|
+
}
|
|
66
|
+
getPluginsManager() {
|
|
67
|
+
return this.plugins;
|
|
68
|
+
}
|
|
69
|
+
getAIManager() {
|
|
70
|
+
return this.ai;
|
|
71
|
+
}
|
|
72
|
+
/** Set a handler for proactive notifications (e.g. from the heartbeat loop). */
|
|
73
|
+
setNotificationHandler(handler) {
|
|
74
|
+
this.notificationHandler = handler;
|
|
75
|
+
}
|
|
76
|
+
/** Send a proactive notification to the user via the registered handler. */
|
|
77
|
+
async notifyUser(notification) {
|
|
78
|
+
if (this.notificationHandler) {
|
|
79
|
+
await this.notificationHandler(notification);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
process.stderr.write(` [Proactive] ${notification.title}: ${notification.body}\n`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** Start the proactive autonomous loop. */
|
|
86
|
+
async startProactiveMode(intervalMinutes = 30) {
|
|
87
|
+
if (this.proactiveTimer)
|
|
88
|
+
return;
|
|
89
|
+
if (!this.quiet) {
|
|
90
|
+
process.stderr.write(`Starting proactive mode (every ${intervalMinutes}m)...\n`);
|
|
91
|
+
}
|
|
92
|
+
// Run once immediately
|
|
93
|
+
this.runReasoningCycle().catch((err) => {
|
|
94
|
+
process.stderr.write(`Proactive cycle error: ${err.message}\n`);
|
|
95
|
+
});
|
|
96
|
+
this.proactiveTimer = setInterval(() => {
|
|
97
|
+
this.runReasoningCycle().catch((err) => {
|
|
98
|
+
process.stderr.write(`Proactive cycle error: ${err.message}\n`);
|
|
99
|
+
});
|
|
100
|
+
}, intervalMinutes * 60 * 1000);
|
|
101
|
+
}
|
|
102
|
+
async stopProactiveMode() {
|
|
103
|
+
if (this.proactiveTimer) {
|
|
104
|
+
clearInterval(this.proactiveTimer);
|
|
105
|
+
this.proactiveTimer = undefined;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async gatherContext() {
|
|
109
|
+
const contextLines = [];
|
|
110
|
+
// System Info
|
|
111
|
+
try {
|
|
112
|
+
const sysPlugin = await this.plugins.getPlugin('system');
|
|
113
|
+
if (sysPlugin) {
|
|
114
|
+
const infoTool = sysPlugin.getTools().find((t) => t.name === 'system_info');
|
|
115
|
+
if (infoTool) {
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
117
|
+
const stats = (await infoTool.handler({}));
|
|
118
|
+
contextLines.push(`[SYSTEM] CPU: ${stats.cpu?.load || 'unknown'}%, RAM: ${stats.memory?.usedPercent || 'unknown'}%, Disk: ${stats.disk?.usedPercent || 'unknown'}%`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
/* plugin might be disabled */
|
|
124
|
+
}
|
|
125
|
+
// Recent Activity
|
|
126
|
+
const activity = await this.getRecentActivity(5);
|
|
127
|
+
if (activity.length > 0) {
|
|
128
|
+
contextLines.push('[RECENT ACTIVITY]');
|
|
129
|
+
activity.forEach((a) => contextLines.push(`- ${a.timestamp}: ${a.event_type} (${a.service})`));
|
|
130
|
+
}
|
|
131
|
+
// enabled plugins
|
|
132
|
+
const enabled = this.config.get('plugins.enabled') || [];
|
|
133
|
+
contextLines.push(`[PLUGINS] Enabled: ${enabled.join(', ')}`);
|
|
134
|
+
// Dynamic context from any enabled plugin that implements getContext()
|
|
135
|
+
for (const pluginName of enabled) {
|
|
136
|
+
try {
|
|
137
|
+
const plugin = await this.plugins.getPlugin(pluginName);
|
|
138
|
+
if (plugin && typeof plugin.getContext === 'function') {
|
|
139
|
+
const ctx = await plugin.getContext();
|
|
140
|
+
if (ctx)
|
|
141
|
+
contextLines.push(ctx);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
/* ignore — plugin context is best-effort */
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return contextLines.join('\n');
|
|
149
|
+
}
|
|
150
|
+
async runReasoningCycle() {
|
|
151
|
+
if (!this.initialized)
|
|
152
|
+
return;
|
|
153
|
+
if (this._cycleRunning) {
|
|
154
|
+
process.stderr.write('[Proactive] Skipping cycle — previous cycle still running\n');
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
this._cycleRunning = true;
|
|
158
|
+
await this.db.logActivity('system', 'proactive_cycle_start');
|
|
159
|
+
try {
|
|
160
|
+
const context = await this.gatherContext();
|
|
161
|
+
const provider = await this.ai.getCurrentProvider();
|
|
162
|
+
if (provider) {
|
|
163
|
+
const prompt = `You are running your autonomous periodic reasoning cycle.
|
|
164
|
+
Examine the context below. If there is a problem (like high CPU, or important unread emails), use your tools to take action or investigate further.
|
|
165
|
+
If everything is perfectly normal and no action is required, respond exactly with "No action needed."
|
|
166
|
+
|
|
167
|
+
CONTEXT:
|
|
168
|
+
${context}`;
|
|
169
|
+
const systemUserId = 'system-proactive';
|
|
170
|
+
const agentResponse = await this.ai.handleConversation(systemUserId, prompt);
|
|
171
|
+
await this.db.logActivity('system', 'proactive_reasoning_complete', agentResponse.text);
|
|
172
|
+
if (!this.quiet) {
|
|
173
|
+
process.stderr.write(` 🤖 [Proactive] ${agentResponse.text}\n`);
|
|
174
|
+
}
|
|
175
|
+
if (agentResponse.approvalRequired) {
|
|
176
|
+
const { toolName, arguments: args } = agentResponse.approvalRequired;
|
|
177
|
+
await this.notifyUser({
|
|
178
|
+
title: 'Approval Required',
|
|
179
|
+
body: `The AI attempted to use "${toolName}" autonomously. Reply to approve or deny.`,
|
|
180
|
+
codeBlock: JSON.stringify(args, null, 2),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
else if (agentResponse.text && !agentResponse.text.toLowerCase().includes('no action needed')) {
|
|
184
|
+
await this.notifyUser({
|
|
185
|
+
title: 'Autonomous Action',
|
|
186
|
+
body: agentResponse.text,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
process.stderr.write(` ✗ [Proactive Error] ${err.message}\n`);
|
|
193
|
+
}
|
|
194
|
+
finally {
|
|
195
|
+
this._cycleRunning = false;
|
|
196
|
+
await this.db.logActivity('system', 'proactive_cycle_end');
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=conductor.js.map
|