@mastra/code-sdk 0.0.0-mastracode-cloud-20260706153555
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/CHANGELOG.md +22 -0
- package/LICENSE.md +30 -0
- package/README.md +50 -0
- package/dist/acp/agent.d.ts +35 -0
- package/dist/acp/agent.d.ts.map +1 -0
- package/dist/acp/agent.js +173 -0
- package/dist/acp/agent.js.map +1 -0
- package/dist/acp/event-mapper.d.ts +22 -0
- package/dist/acp/event-mapper.d.ts.map +1 -0
- package/dist/acp/event-mapper.js +166 -0
- package/dist/acp/event-mapper.js.map +1 -0
- package/dist/acp/index.d.ts +8 -0
- package/dist/acp/index.d.ts.map +1 -0
- package/dist/acp/index.js +54 -0
- package/dist/acp/index.js.map +1 -0
- package/dist/acp/server.d.ts +7 -0
- package/dist/acp/server.d.ts.map +1 -0
- package/dist/acp/server.js +34 -0
- package/dist/acp/server.js.map +1 -0
- package/dist/acp.d.ts +2 -0
- package/dist/acp.d.ts.map +1 -0
- package/dist/acp.js +5 -0
- package/dist/acp.js.map +1 -0
- package/dist/agents/instructions.d.ts +6 -0
- package/dist/agents/instructions.d.ts.map +1 -0
- package/dist/agents/instructions.js +41 -0
- package/dist/agents/instructions.js.map +1 -0
- package/dist/agents/mastracode-gateway.d.ts +65 -0
- package/dist/agents/mastracode-gateway.d.ts.map +1 -0
- package/dist/agents/mastracode-gateway.js +442 -0
- package/dist/agents/mastracode-gateway.js.map +1 -0
- package/dist/agents/memory.d.ts +13 -0
- package/dist/agents/memory.d.ts.map +1 -0
- package/dist/agents/memory.js +107 -0
- package/dist/agents/memory.js.map +1 -0
- package/dist/agents/model.d.ts +55 -0
- package/dist/agents/model.d.ts.map +1 -0
- package/dist/agents/model.js +115 -0
- package/dist/agents/model.js.map +1 -0
- package/dist/agents/modes/build.d.ts +10 -0
- package/dist/agents/modes/build.d.ts.map +1 -0
- package/dist/agents/modes/build.js +45 -0
- package/dist/agents/modes/build.js.map +1 -0
- package/dist/agents/modes/explore.d.ts +10 -0
- package/dist/agents/modes/explore.d.ts.map +1 -0
- package/dist/agents/modes/explore.js +38 -0
- package/dist/agents/modes/explore.js.map +1 -0
- package/dist/agents/modes/plan.d.ts +6 -0
- package/dist/agents/modes/plan.d.ts.map +1 -0
- package/dist/agents/modes/plan.js +38 -0
- package/dist/agents/modes/plan.js.map +1 -0
- package/dist/agents/prompts/agent-instructions.d.ts +20 -0
- package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
- package/dist/agents/prompts/agent-instructions.js +82 -0
- package/dist/agents/prompts/agent-instructions.js.map +1 -0
- package/dist/agents/prompts/build.d.ts +12 -0
- package/dist/agents/prompts/build.d.ts.map +1 -0
- package/dist/agents/prompts/build.js +73 -0
- package/dist/agents/prompts/build.js.map +1 -0
- package/dist/agents/prompts/fast.d.ts +5 -0
- package/dist/agents/prompts/fast.d.ts.map +1 -0
- package/dist/agents/prompts/fast.js +22 -0
- package/dist/agents/prompts/fast.js.map +1 -0
- package/dist/agents/prompts/index.d.ts +19 -0
- package/dist/agents/prompts/index.d.ts.map +1 -0
- package/dist/agents/prompts/index.js +57 -0
- package/dist/agents/prompts/index.js.map +1 -0
- package/dist/agents/prompts/model.d.ts +5 -0
- package/dist/agents/prompts/model.d.ts.map +1 -0
- package/dist/agents/prompts/model.js +22 -0
- package/dist/agents/prompts/model.js.map +1 -0
- package/dist/agents/prompts/plan.d.ts +6 -0
- package/dist/agents/prompts/plan.d.ts.map +1 -0
- package/dist/agents/prompts/plan.js +107 -0
- package/dist/agents/prompts/plan.js.map +1 -0
- package/dist/agents/prompts/tool-guidance.d.ts +13 -0
- package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
- package/dist/agents/prompts/tool-guidance.js +181 -0
- package/dist/agents/prompts/tool-guidance.js.map +1 -0
- package/dist/agents/sandbox-filesystem.d.ts +89 -0
- package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
- package/dist/agents/sandbox-filesystem.js +268 -0
- package/dist/agents/sandbox-filesystem.js.map +1 -0
- package/dist/agents/sandbox-reattach.d.ts +19 -0
- package/dist/agents/sandbox-reattach.d.ts.map +1 -0
- package/dist/agents/sandbox-reattach.js +17 -0
- package/dist/agents/sandbox-reattach.js.map +1 -0
- package/dist/agents/thread-caveman-state.d.ts +17 -0
- package/dist/agents/thread-caveman-state.d.ts.map +1 -0
- package/dist/agents/thread-caveman-state.js +96 -0
- package/dist/agents/thread-caveman-state.js.map +1 -0
- package/dist/agents/tool-availability.d.ts +10 -0
- package/dist/agents/tool-availability.d.ts.map +1 -0
- package/dist/agents/tool-availability.js +105 -0
- package/dist/agents/tool-availability.js.map +1 -0
- package/dist/agents/tools.d.ts +18 -0
- package/dist/agents/tools.d.ts.map +1 -0
- package/dist/agents/tools.js +126 -0
- package/dist/agents/tools.js.map +1 -0
- package/dist/agents/workspace.d.ts +22 -0
- package/dist/agents/workspace.d.ts.map +1 -0
- package/dist/agents/workspace.js +194 -0
- package/dist/agents/workspace.js.map +1 -0
- package/dist/analytics.d.ts +18 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +152 -0
- package/dist/analytics.js.map +1 -0
- package/dist/auth/index.d.ts +9 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +11 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/pkce.d.ts +13 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +21 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/providers/anthropic.d.ts +17 -0
- package/dist/auth/providers/anthropic.d.ts.map +1 -0
- package/dist/auth/providers/anthropic.js +94 -0
- package/dist/auth/providers/anthropic.js.map +1 -0
- package/dist/auth/providers/github-copilot.d.ts +100 -0
- package/dist/auth/providers/github-copilot.d.ts.map +1 -0
- package/dist/auth/providers/github-copilot.js +302 -0
- package/dist/auth/providers/github-copilot.js.map +1 -0
- package/dist/auth/providers/openai-codex.d.ts +95 -0
- package/dist/auth/providers/openai-codex.d.ts.map +1 -0
- package/dist/auth/providers/openai-codex.js +527 -0
- package/dist/auth/providers/openai-codex.js.map +1 -0
- package/dist/auth/storage.d.ts +91 -0
- package/dist/auth/storage.d.ts.map +1 -0
- package/dist/auth/storage.js +187 -0
- package/dist/auth/storage.js.map +1 -0
- package/dist/auth/types.d.ts +68 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/clipboard/index.d.ts +26 -0
- package/dist/clipboard/index.d.ts.map +1 -0
- package/dist/clipboard/index.js +192 -0
- package/dist/clipboard/index.js.map +1 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +23 -0
- package/dist/constants.js.map +1 -0
- package/dist/error-classification.d.ts +10 -0
- package/dist/error-classification.d.ts.map +1 -0
- package/dist/error-classification.js +14 -0
- package/dist/error-classification.js.map +1 -0
- package/dist/evals/context-builder.d.ts +41 -0
- package/dist/evals/context-builder.d.ts.map +1 -0
- package/dist/evals/context-builder.js +120 -0
- package/dist/evals/context-builder.js.map +1 -0
- package/dist/evals/index.d.ts +4 -0
- package/dist/evals/index.d.ts.map +1 -0
- package/dist/evals/index.js +8 -0
- package/dist/evals/index.js.map +1 -0
- package/dist/evals/scorers/classify-command.d.ts +31 -0
- package/dist/evals/scorers/classify-command.d.ts.map +1 -0
- package/dist/evals/scorers/classify-command.js +52 -0
- package/dist/evals/scorers/classify-command.js.map +1 -0
- package/dist/evals/scorers/efficiency.d.ts +44 -0
- package/dist/evals/scorers/efficiency.d.ts.map +1 -0
- package/dist/evals/scorers/efficiency.js +201 -0
- package/dist/evals/scorers/efficiency.js.map +1 -0
- package/dist/evals/scorers/extract-tools.d.ts +25 -0
- package/dist/evals/scorers/extract-tools.d.ts.map +1 -0
- package/dist/evals/scorers/extract-tools.js +56 -0
- package/dist/evals/scorers/extract-tools.js.map +1 -0
- package/dist/evals/scorers/index.d.ts +3 -0
- package/dist/evals/scorers/index.d.ts.map +1 -0
- package/dist/evals/scorers/index.js +7 -0
- package/dist/evals/scorers/index.js.map +1 -0
- package/dist/evals/scorers/outcome.d.ts +49 -0
- package/dist/evals/scorers/outcome.d.ts.map +1 -0
- package/dist/evals/scorers/outcome.js +238 -0
- package/dist/evals/scorers/outcome.js.map +1 -0
- package/dist/headless/cli.d.ts +42 -0
- package/dist/headless/cli.d.ts.map +1 -0
- package/dist/headless/cli.js +196 -0
- package/dist/headless/cli.js.map +1 -0
- package/dist/headless/flags.d.ts +33 -0
- package/dist/headless/flags.d.ts.map +1 -0
- package/dist/headless/flags.js +188 -0
- package/dist/headless/flags.js.map +1 -0
- package/dist/headless/format.d.ts +38 -0
- package/dist/headless/format.d.ts.map +1 -0
- package/dist/headless/format.js +85 -0
- package/dist/headless/format.js.map +1 -0
- package/dist/headless/index.d.ts +25 -0
- package/dist/headless/index.d.ts.map +1 -0
- package/dist/headless/index.js +32 -0
- package/dist/headless/index.js.map +1 -0
- package/dist/headless/policy.d.ts +17 -0
- package/dist/headless/policy.d.ts.map +1 -0
- package/dist/headless/policy.js +38 -0
- package/dist/headless/policy.js.map +1 -0
- package/dist/headless/run-mc.d.ts +7 -0
- package/dist/headless/run-mc.d.ts.map +1 -0
- package/dist/headless/run-mc.js +296 -0
- package/dist/headless/run-mc.js.map +1 -0
- package/dist/headless/types.d.ts +134 -0
- package/dist/headless/types.d.ts.map +1 -0
- package/dist/headless/types.js +9 -0
- package/dist/headless/types.js.map +1 -0
- package/dist/hooks/config.d.ts +11 -0
- package/dist/hooks/config.d.ts.map +1 -0
- package/dist/hooks/config.js +78 -0
- package/dist/hooks/config.js.map +1 -0
- package/dist/hooks/executor.d.ts +13 -0
- package/dist/hooks/executor.d.ts.map +1 -0
- package/dist/hooks/executor.js +125 -0
- package/dist/hooks/executor.js.map +1 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +16 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/manager.d.ts +47 -0
- package/dist/hooks/manager.d.ts.map +1 -0
- package/dist/hooks/manager.js +284 -0
- package/dist/hooks/manager.js.map +1 -0
- package/dist/hooks/types.d.ts +152 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +7 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +241 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +712 -0
- package/dist/index.js.map +1 -0
- package/dist/ipc/ipc-reporter.d.ts +14 -0
- package/dist/ipc/ipc-reporter.d.ts.map +1 -0
- package/dist/ipc/ipc-reporter.js +24 -0
- package/dist/ipc/ipc-reporter.js.map +1 -0
- package/dist/lsp/client.d.ts +56 -0
- package/dist/lsp/client.d.ts.map +1 -0
- package/dist/lsp/client.js +309 -0
- package/dist/lsp/client.js.map +1 -0
- package/dist/lsp/index.d.ts +4 -0
- package/dist/lsp/index.d.ts.map +1 -0
- package/dist/lsp/index.js +9 -0
- package/dist/lsp/index.js.map +1 -0
- package/dist/lsp/language.d.ts +9 -0
- package/dist/lsp/language.d.ts.map +1 -0
- package/dist/lsp/language.js +48 -0
- package/dist/lsp/language.js.map +1 -0
- package/dist/lsp/manager.d.ts +34 -0
- package/dist/lsp/manager.d.ts.map +1 -0
- package/dist/lsp/manager.js +97 -0
- package/dist/lsp/manager.js.map +1 -0
- package/dist/lsp/server.d.ts +27 -0
- package/dist/lsp/server.d.ts.map +1 -0
- package/dist/lsp/server.js +128 -0
- package/dist/lsp/server.js.map +1 -0
- package/dist/lsp/workspace.d.ts +9 -0
- package/dist/lsp/workspace.d.ts.map +1 -0
- package/dist/lsp/workspace.js +52 -0
- package/dist/lsp/workspace.js.map +1 -0
- package/dist/mcp/config.d.ts +34 -0
- package/dist/mcp/config.d.ts.map +1 -0
- package/dist/mcp/config.js +205 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +10 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/manager.d.ts +49 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/manager.js +374 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/types.d.ts +85 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +1 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/onboarding/custom-packs.d.ts +7 -0
- package/dist/onboarding/custom-packs.d.ts.map +1 -0
- package/dist/onboarding/custom-packs.js +20 -0
- package/dist/onboarding/custom-packs.js.map +1 -0
- package/dist/onboarding/custom-providers.d.ts +4 -0
- package/dist/onboarding/custom-providers.d.ts.map +1 -0
- package/dist/onboarding/custom-providers.js +28 -0
- package/dist/onboarding/custom-providers.js.map +1 -0
- package/dist/onboarding/index.d.ts +5 -0
- package/dist/onboarding/index.d.ts.map +1 -0
- package/dist/onboarding/index.js +21 -0
- package/dist/onboarding/index.js.map +1 -0
- package/dist/onboarding/om-settings.d.ts +20 -0
- package/dist/onboarding/om-settings.d.ts.map +1 -0
- package/dist/onboarding/om-settings.js +26 -0
- package/dist/onboarding/om-settings.js.map +1 -0
- package/dist/onboarding/packs.d.ts +48 -0
- package/dist/onboarding/packs.d.ts.map +1 -0
- package/dist/onboarding/packs.js +111 -0
- package/dist/onboarding/packs.js.map +1 -0
- package/dist/onboarding/settings.d.ts +323 -0
- package/dist/onboarding/settings.d.ts.map +1 -0
- package/dist/onboarding/settings.js +594 -0
- package/dist/onboarding/settings.js.map +1 -0
- package/dist/permissions.d.ts +55 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +119 -0
- package/dist/permissions.js.map +1 -0
- package/dist/plugin.d.ts +81 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +30 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugins/install.d.ts +20 -0
- package/dist/plugins/install.d.ts.map +1 -0
- package/dist/plugins/install.js +179 -0
- package/dist/plugins/install.js.map +1 -0
- package/dist/plugins/loader.d.ts +15 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +221 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/manager.d.ts +60 -0
- package/dist/plugins/manager.d.ts.map +1 -0
- package/dist/plugins/manager.js +369 -0
- package/dist/plugins/manager.js.map +1 -0
- package/dist/plugins/manifest.d.ts +14 -0
- package/dist/plugins/manifest.d.ts.map +1 -0
- package/dist/plugins/manifest.js +75 -0
- package/dist/plugins/manifest.js.map +1 -0
- package/dist/plugins/package-link.d.ts +2 -0
- package/dist/plugins/package-link.d.ts.map +1 -0
- package/dist/plugins/package-link.js +20 -0
- package/dist/plugins/package-link.js.map +1 -0
- package/dist/plugins/paths.d.ts +10 -0
- package/dist/plugins/paths.d.ts.map +1 -0
- package/dist/plugins/paths.js +26 -0
- package/dist/plugins/paths.js.map +1 -0
- package/dist/plugins/registry.d.ts +8 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +96 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/plugins/scaffold.d.ts +10 -0
- package/dist/plugins/scaffold.d.ts.map +1 -0
- package/dist/plugins/scaffold.js +152 -0
- package/dist/plugins/scaffold.js.map +1 -0
- package/dist/plugins/types.d.ts +45 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +1 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/processors/plan-rejection-abort.d.ts +12 -0
- package/dist/processors/plan-rejection-abort.d.ts.map +1 -0
- package/dist/processors/plan-rejection-abort.js +53 -0
- package/dist/processors/plan-rejection-abort.js.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts +40 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.js +79 -0
- package/dist/providers/amazon-bedrock-gateway.js.map +1 -0
- package/dist/providers/amazon-bedrock.d.ts +28 -0
- package/dist/providers/amazon-bedrock.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock.js +62 -0
- package/dist/providers/amazon-bedrock.js.map +1 -0
- package/dist/providers/claude-max.d.ts +50 -0
- package/dist/providers/claude-max.d.ts.map +1 -0
- package/dist/providers/claude-max.js +151 -0
- package/dist/providers/claude-max.js.map +1 -0
- package/dist/providers/github-copilot.d.ts +58 -0
- package/dist/providers/github-copilot.d.ts.map +1 -0
- package/dist/providers/github-copilot.js +263 -0
- package/dist/providers/github-copilot.js.map +1 -0
- package/dist/providers/openai-codex.d.ts +70 -0
- package/dist/providers/openai-codex.d.ts.map +1 -0
- package/dist/providers/openai-codex.js +291 -0
- package/dist/providers/openai-codex.js.map +1 -0
- package/dist/schema.d.ts +167 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +92 -0
- package/dist/schema.js.map +1 -0
- package/dist/theme-palette.d.ts +17 -0
- package/dist/theme-palette.d.ts.map +1 -0
- package/dist/theme-palette.js +17 -0
- package/dist/theme-palette.js.map +1 -0
- package/dist/tool-names.d.ts +73 -0
- package/dist/tool-names.d.ts.map +1 -0
- package/dist/tool-names.js +43 -0
- package/dist/tool-names.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +9 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/request-sandbox-access.d.ts +6 -0
- package/dist/tools/request-sandbox-access.d.ts.map +1 -0
- package/dist/tools/request-sandbox-access.js +88 -0
- package/dist/tools/request-sandbox-access.js.map +1 -0
- package/dist/tools/utils.d.ts +20 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +22 -0
- package/dist/tools/utils.js.map +1 -0
- package/dist/tools/web-search.d.ts +35 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +65 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/utils/binaries.d.ts +7 -0
- package/dist/utils/binaries.d.ts.map +1 -0
- package/dist/utils/binaries.js +74 -0
- package/dist/utils/binaries.js.map +1 -0
- package/dist/utils/debug-log.d.ts +12 -0
- package/dist/utils/debug-log.d.ts.map +1 -0
- package/dist/utils/debug-log.js +55 -0
- package/dist/utils/debug-log.js.map +1 -0
- package/dist/utils/errors.d.ts +36 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +207 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/gateway-sync.d.ts +26 -0
- package/dist/utils/gateway-sync.d.ts.map +1 -0
- package/dist/utils/gateway-sync.js +49 -0
- package/dist/utils/gateway-sync.js.map +1 -0
- package/dist/utils/plan-diff.d.ts +25 -0
- package/dist/utils/plan-diff.d.ts.map +1 -0
- package/dist/utils/plan-diff.js +43 -0
- package/dist/utils/plan-diff.js.map +1 -0
- package/dist/utils/plans.d.ts +56 -0
- package/dist/utils/plans.d.ts.map +1 -0
- package/dist/utils/plans.js +99 -0
- package/dist/utils/plans.js.map +1 -0
- package/dist/utils/project.d.ts +161 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +302 -0
- package/dist/utils/project.js.map +1 -0
- package/dist/utils/signals-pubsub.d.ts +41 -0
- package/dist/utils/signals-pubsub.d.ts.map +1 -0
- package/dist/utils/signals-pubsub.js +104 -0
- package/dist/utils/signals-pubsub.js.map +1 -0
- package/dist/utils/slash-command-loader.d.ts +48 -0
- package/dist/utils/slash-command-loader.d.ts.map +1 -0
- package/dist/utils/slash-command-loader.js +155 -0
- package/dist/utils/slash-command-loader.js.map +1 -0
- package/dist/utils/slash-command-processor.d.ts +14 -0
- package/dist/utils/slash-command-processor.d.ts.map +1 -0
- package/dist/utils/slash-command-processor.js +96 -0
- package/dist/utils/slash-command-processor.js.map +1 -0
- package/dist/utils/stdin-pipe.d.ts +33 -0
- package/dist/utils/stdin-pipe.d.ts.map +1 -0
- package/dist/utils/stdin-pipe.js +72 -0
- package/dist/utils/stdin-pipe.js.map +1 -0
- package/dist/utils/storage-factory.d.ts +50 -0
- package/dist/utils/storage-factory.d.ts.map +1 -0
- package/dist/utils/storage-factory.js +98 -0
- package/dist/utils/storage-factory.js.map +1 -0
- package/dist/utils/thread-lock.d.ts +26 -0
- package/dist/utils/thread-lock.d.ts.map +1 -0
- package/dist/utils/thread-lock.js +108 -0
- package/dist/utils/thread-lock.js.map +1 -0
- package/dist/utils/token-estimator.d.ts +3 -0
- package/dist/utils/token-estimator.d.ts.map +1 -0
- package/dist/utils/token-estimator.js +21 -0
- package/dist/utils/token-estimator.js.map +1 -0
- package/dist/utils/update-check.d.ts +52 -0
- package/dist/utils/update-check.d.ts.map +1 -0
- package/dist/utils/update-check.js +177 -0
- package/dist/utils/update-check.js.map +1 -0
- package/dist/voice/stt-registry.d.ts +64 -0
- package/dist/voice/stt-registry.d.ts.map +1 -0
- package/dist/voice/stt-registry.js +126 -0
- package/dist/voice/stt-registry.js.map +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
import { DEFAULT_CONFIG_DIR } from "../constants.js";
|
|
5
|
+
import { loadPluginFromEntry } from "./loader.js";
|
|
6
|
+
import { getSingleManifestPlugin } from "./manifest.js";
|
|
7
|
+
import { ensureMastraCodePackageLink } from "./package-link.js";
|
|
8
|
+
import { getPluginRoot, getPluginScopePaths } from "./paths.js";
|
|
9
|
+
import { loadPluginRegistry, removePluginRecord, savePluginRegistry, setPluginRecord } from "./registry.js";
|
|
10
|
+
const ENTRY_CANDIDATES = ["src/index.ts", "index.ts"];
|
|
11
|
+
const NON_INTERACTIVE_GIT_ENV = { ...process.env, GIT_TERMINAL_PROMPT: "0" };
|
|
12
|
+
const NON_INTERACTIVE_EXEC_OPTIONS = { env: NON_INTERACTIVE_GIT_ENV };
|
|
13
|
+
async function installLocalPlugin(localPath, scope, options) {
|
|
14
|
+
const sourcePath = path.resolve(options.projectRoot, localPath);
|
|
15
|
+
if (!fs.existsSync(sourcePath) || !fs.statSync(sourcePath).isDirectory()) {
|
|
16
|
+
throw new Error(`Local plugin path does not exist or is not a directory: ${localPath}`);
|
|
17
|
+
}
|
|
18
|
+
const entry = detectEntry(sourcePath, options.entry);
|
|
19
|
+
ensureMastraCodePackageLink(sourcePath);
|
|
20
|
+
const plugin = await loadPluginFromEntry(path.join(sourcePath, entry));
|
|
21
|
+
const registryPath = getPluginScopePaths(scope, options).registryPath;
|
|
22
|
+
const registry = removePluginRecord(loadPluginRegistry(registryPath), plugin.id);
|
|
23
|
+
const record = {
|
|
24
|
+
enabled: true,
|
|
25
|
+
source: "local",
|
|
26
|
+
specifier: localPath,
|
|
27
|
+
path: sourcePath,
|
|
28
|
+
entry,
|
|
29
|
+
...plugin.version ? { version: plugin.version } : {}
|
|
30
|
+
};
|
|
31
|
+
savePluginRegistry(registryPath, setPluginRecord(registry, plugin.id, record));
|
|
32
|
+
return plugin.id;
|
|
33
|
+
}
|
|
34
|
+
async function installGithubPlugin(url, scope, options) {
|
|
35
|
+
const parsed = parseGithubUrl(url);
|
|
36
|
+
const paths = getPluginScopePaths(scope, options);
|
|
37
|
+
const checkoutDir = path.join(paths.sourcesPath, "github", `${parsed.owner}-${parsed.repo}`);
|
|
38
|
+
const githubCli = options.githubCliPath ?? "gh";
|
|
39
|
+
await assertGithubCliAvailable(githubCli);
|
|
40
|
+
await assertGithubCliAuthenticated(githubCli);
|
|
41
|
+
fs.rmSync(checkoutDir, { recursive: true, force: true });
|
|
42
|
+
fs.mkdirSync(path.dirname(checkoutDir), { recursive: true });
|
|
43
|
+
await execa(githubCli, ["repo", "clone", parsed.repoSpec, checkoutDir], NON_INTERACTIVE_EXEC_OPTIONS);
|
|
44
|
+
const ref = options.ref ?? parsed.ref;
|
|
45
|
+
if (ref) {
|
|
46
|
+
await execa("git", ["checkout", ref], { cwd: checkoutDir, env: NON_INTERACTIVE_GIT_ENV });
|
|
47
|
+
}
|
|
48
|
+
const entry = detectEntry(checkoutDir, options.entry);
|
|
49
|
+
ensureMastraCodePackageLink(checkoutDir);
|
|
50
|
+
const plugin = await loadPluginFromEntry(path.join(checkoutDir, entry));
|
|
51
|
+
const registry = removePluginRecord(loadPluginRegistry(paths.registryPath), plugin.id);
|
|
52
|
+
const relativePath = path.relative(getPluginRoot(scope, options), checkoutDir);
|
|
53
|
+
const record = {
|
|
54
|
+
enabled: true,
|
|
55
|
+
source: "github",
|
|
56
|
+
specifier: url,
|
|
57
|
+
path: relativePath,
|
|
58
|
+
entry,
|
|
59
|
+
...ref ? { ref } : {},
|
|
60
|
+
...plugin.version ? { version: plugin.version } : {}
|
|
61
|
+
};
|
|
62
|
+
savePluginRegistry(paths.registryPath, setPluginRecord(registry, plugin.id, record));
|
|
63
|
+
return plugin.id;
|
|
64
|
+
}
|
|
65
|
+
function discoverLocalPlugins(searchRoot, options) {
|
|
66
|
+
const root = path.resolve(options.projectRoot, searchRoot);
|
|
67
|
+
const localSourcesRoot = path.join(root, options.configDir ?? DEFAULT_CONFIG_DIR, "plugins", "sources", "local");
|
|
68
|
+
const scanRoot = isLocalSourcesDir(root) ? root : localSourcesRoot;
|
|
69
|
+
const seen = /* @__PURE__ */ new Set();
|
|
70
|
+
return discoverPluginDirs(scanRoot).filter((candidate) => {
|
|
71
|
+
if (seen.has(candidate.path)) return false;
|
|
72
|
+
seen.add(candidate.path);
|
|
73
|
+
return true;
|
|
74
|
+
}).sort((a, b) => a.name.localeCompare(b.name));
|
|
75
|
+
}
|
|
76
|
+
function isLocalSourcesDir(dir) {
|
|
77
|
+
const normalized = dir.split(path.sep).join("/");
|
|
78
|
+
return normalized.endsWith("/plugins/sources/local");
|
|
79
|
+
}
|
|
80
|
+
function discoverPluginDirs(root) {
|
|
81
|
+
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) return [];
|
|
82
|
+
return fs.readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).flatMap((entry) => {
|
|
83
|
+
const pluginDir = path.join(root, entry.name);
|
|
84
|
+
const detectedEntry = tryDetectEntry(pluginDir);
|
|
85
|
+
return detectedEntry ? [{ name: entry.name, path: pluginDir, entry: detectedEntry }] : [];
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function tryDetectEntry(pluginDir) {
|
|
89
|
+
try {
|
|
90
|
+
return detectEntry(pluginDir);
|
|
91
|
+
} catch {
|
|
92
|
+
return void 0;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function detectEntry(pluginDir, explicitEntry) {
|
|
96
|
+
const root = path.resolve(pluginDir);
|
|
97
|
+
if (explicitEntry) {
|
|
98
|
+
const entryPath = path.resolve(pluginDir, explicitEntry);
|
|
99
|
+
if (!isInsideDirectory(entryPath, root)) {
|
|
100
|
+
throw new Error("Plugin entry must be inside the plugin directory");
|
|
101
|
+
}
|
|
102
|
+
if (fs.existsSync(entryPath) && fs.statSync(entryPath).isDirectory()) {
|
|
103
|
+
const nestedEntry = detectEntry(entryPath);
|
|
104
|
+
return path.relative(root, path.join(entryPath, nestedEntry));
|
|
105
|
+
}
|
|
106
|
+
if (path.extname(entryPath) !== ".ts") {
|
|
107
|
+
throw new Error("Plugin entry must be a .ts file");
|
|
108
|
+
}
|
|
109
|
+
if (!fs.existsSync(entryPath) || !fs.statSync(entryPath).isFile()) {
|
|
110
|
+
throw new Error(`Plugin entry file does not exist: ${explicitEntry}`);
|
|
111
|
+
}
|
|
112
|
+
return path.relative(root, entryPath);
|
|
113
|
+
}
|
|
114
|
+
const manifestPlugin = getSingleManifestPlugin(pluginDir);
|
|
115
|
+
if (manifestPlugin) {
|
|
116
|
+
return detectEntry(pluginDir, manifestPlugin.entry);
|
|
117
|
+
}
|
|
118
|
+
for (const candidate of ENTRY_CANDIDATES) {
|
|
119
|
+
const entryPath = path.join(pluginDir, candidate);
|
|
120
|
+
if (fs.existsSync(entryPath) && fs.statSync(entryPath).isFile()) {
|
|
121
|
+
return candidate;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
throw new Error(`Could not find a plugin entry file. Tried: ${ENTRY_CANDIDATES.join(", ")}`);
|
|
125
|
+
}
|
|
126
|
+
function isInsideDirectory(targetPath, root) {
|
|
127
|
+
return targetPath === root || targetPath.startsWith(root + path.sep);
|
|
128
|
+
}
|
|
129
|
+
async function assertGithubCliAvailable(githubCli) {
|
|
130
|
+
try {
|
|
131
|
+
await execa(githubCli, ["--version"], NON_INTERACTIVE_EXEC_OPTIONS);
|
|
132
|
+
} catch {
|
|
133
|
+
throw new Error("GitHub CLI is required to install GitHub plugins. Install gh and run gh auth login.");
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async function assertGithubCliAuthenticated(githubCli) {
|
|
137
|
+
try {
|
|
138
|
+
await execa(githubCli, ["auth", "status"], NON_INTERACTIVE_EXEC_OPTIONS);
|
|
139
|
+
} catch {
|
|
140
|
+
throw new Error("GitHub CLI is not authenticated. Run gh auth login, then install the plugin again.");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function parseGithubUrl(specifier) {
|
|
144
|
+
const [urlPart, ref] = specifier.split("#", 2);
|
|
145
|
+
if (!urlPart) {
|
|
146
|
+
throw new Error(`Invalid GitHub URL: ${specifier}`);
|
|
147
|
+
}
|
|
148
|
+
let url;
|
|
149
|
+
try {
|
|
150
|
+
url = new URL(urlPart);
|
|
151
|
+
} catch {
|
|
152
|
+
throw new Error(`Invalid GitHub URL: ${specifier}`);
|
|
153
|
+
}
|
|
154
|
+
if (url.hostname !== "github.com") {
|
|
155
|
+
throw new Error("Only github.com plugin URLs are supported");
|
|
156
|
+
}
|
|
157
|
+
const [owner, rawRepo, ...rest] = url.pathname.split("/").filter(Boolean);
|
|
158
|
+
if (!owner || !rawRepo || rest.length > 0) {
|
|
159
|
+
throw new Error("GitHub plugin URL must be in the form https://github.com/owner/repo");
|
|
160
|
+
}
|
|
161
|
+
const repo = rawRepo.replace(/\.git$/, "");
|
|
162
|
+
if (!/^[A-Za-z0-9_.-]+$/.test(owner) || !/^[A-Za-z0-9_.-]+$/.test(repo)) {
|
|
163
|
+
throw new Error("GitHub owner and repo may only contain letters, numbers, dots, underscores, and dashes");
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
owner,
|
|
167
|
+
repo,
|
|
168
|
+
repoSpec: `${owner}/${repo}`,
|
|
169
|
+
...ref ? { ref } : {}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
export {
|
|
173
|
+
NON_INTERACTIVE_GIT_ENV,
|
|
174
|
+
detectEntry,
|
|
175
|
+
discoverLocalPlugins,
|
|
176
|
+
installGithubPlugin,
|
|
177
|
+
installLocalPlugin
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/install.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { execa } from 'execa';\n\nimport { DEFAULT_CONFIG_DIR } from '../constants.js';\nimport { loadPluginFromEntry } from './loader.js';\nimport { getSingleManifestPlugin } from './manifest.js';\nimport { ensureMastraCodePackageLink } from './package-link.js';\nimport { getPluginRoot, getPluginScopePaths } from './paths.js';\nimport type { PluginPathOptions } from './paths.js';\nimport { loadPluginRegistry, removePluginRecord, savePluginRegistry, setPluginRecord } from './registry.js';\nimport type { InstalledPluginRecord, PluginScope } from './types.js';\n\nexport type InstallPluginOptions = PluginPathOptions & {\n entry?: string;\n ref?: string;\n githubCliPath?: string;\n};\n\nexport type DiscoveredLocalPlugin = {\n name: string;\n path: string;\n entry: string;\n};\n\nconst ENTRY_CANDIDATES = ['src/index.ts', 'index.ts'];\n\nexport const NON_INTERACTIVE_GIT_ENV = { ...process.env, GIT_TERMINAL_PROMPT: '0' };\n\nconst NON_INTERACTIVE_EXEC_OPTIONS = { env: NON_INTERACTIVE_GIT_ENV };\n\nexport async function installLocalPlugin(\n localPath: string,\n scope: PluginScope,\n options: InstallPluginOptions,\n): Promise<string> {\n const sourcePath = path.resolve(options.projectRoot, localPath);\n if (!fs.existsSync(sourcePath) || !fs.statSync(sourcePath).isDirectory()) {\n throw new Error(`Local plugin path does not exist or is not a directory: ${localPath}`);\n }\n\n const entry = detectEntry(sourcePath, options.entry);\n ensureMastraCodePackageLink(sourcePath);\n const plugin = await loadPluginFromEntry(path.join(sourcePath, entry));\n const registryPath = getPluginScopePaths(scope, options).registryPath;\n const registry = removePluginRecord(loadPluginRegistry(registryPath), plugin.id);\n const record: InstalledPluginRecord = {\n enabled: true,\n source: 'local',\n specifier: localPath,\n path: sourcePath,\n entry,\n ...(plugin.version ? { version: plugin.version } : {}),\n };\n\n savePluginRegistry(registryPath, setPluginRecord(registry, plugin.id, record));\n return plugin.id;\n}\n\nexport async function installGithubPlugin(\n url: string,\n scope: PluginScope,\n options: InstallPluginOptions,\n): Promise<string> {\n const parsed = parseGithubUrl(url);\n const paths = getPluginScopePaths(scope, options);\n const checkoutDir = path.join(paths.sourcesPath, 'github', `${parsed.owner}-${parsed.repo}`);\n\n const githubCli = options.githubCliPath ?? 'gh';\n await assertGithubCliAvailable(githubCli);\n await assertGithubCliAuthenticated(githubCli);\n\n fs.rmSync(checkoutDir, { recursive: true, force: true });\n fs.mkdirSync(path.dirname(checkoutDir), { recursive: true });\n await execa(githubCli, ['repo', 'clone', parsed.repoSpec, checkoutDir], NON_INTERACTIVE_EXEC_OPTIONS);\n const ref = options.ref ?? parsed.ref;\n if (ref) {\n await execa('git', ['checkout', ref], { cwd: checkoutDir, env: NON_INTERACTIVE_GIT_ENV });\n }\n\n const entry = detectEntry(checkoutDir, options.entry);\n ensureMastraCodePackageLink(checkoutDir);\n const plugin = await loadPluginFromEntry(path.join(checkoutDir, entry));\n const registry = removePluginRecord(loadPluginRegistry(paths.registryPath), plugin.id);\n const relativePath = path.relative(getPluginRoot(scope, options), checkoutDir);\n const record: InstalledPluginRecord = {\n enabled: true,\n source: 'github',\n specifier: url,\n path: relativePath,\n entry,\n ...(ref ? { ref } : {}),\n ...(plugin.version ? { version: plugin.version } : {}),\n };\n\n savePluginRegistry(paths.registryPath, setPluginRecord(registry, plugin.id, record));\n return plugin.id;\n}\n\nexport function discoverLocalPlugins(searchRoot: string, options: PluginPathOptions): DiscoveredLocalPlugin[] {\n const root = path.resolve(options.projectRoot, searchRoot);\n const localSourcesRoot = path.join(root, options.configDir ?? DEFAULT_CONFIG_DIR, 'plugins', 'sources', 'local');\n const scanRoot = isLocalSourcesDir(root) ? root : localSourcesRoot;\n\n const seen = new Set<string>();\n return discoverPluginDirs(scanRoot)\n .filter(candidate => {\n if (seen.has(candidate.path)) return false;\n seen.add(candidate.path);\n return true;\n })\n .sort((a, b) => a.name.localeCompare(b.name));\n}\n\nfunction isLocalSourcesDir(dir: string): boolean {\n const normalized = dir.split(path.sep).join('/');\n return normalized.endsWith('/plugins/sources/local');\n}\n\nfunction discoverPluginDirs(root: string): DiscoveredLocalPlugin[] {\n if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) return [];\n return fs\n .readdirSync(root, { withFileTypes: true })\n .filter(entry => entry.isDirectory())\n .flatMap(entry => {\n const pluginDir = path.join(root, entry.name);\n const detectedEntry = tryDetectEntry(pluginDir);\n return detectedEntry ? [{ name: entry.name, path: pluginDir, entry: detectedEntry }] : [];\n });\n}\n\nfunction tryDetectEntry(pluginDir: string): string | undefined {\n try {\n return detectEntry(pluginDir);\n } catch {\n return undefined;\n }\n}\n\nexport function detectEntry(pluginDir: string, explicitEntry?: string): string {\n const root = path.resolve(pluginDir);\n if (explicitEntry) {\n const entryPath = path.resolve(pluginDir, explicitEntry);\n if (!isInsideDirectory(entryPath, root)) {\n throw new Error('Plugin entry must be inside the plugin directory');\n }\n if (fs.existsSync(entryPath) && fs.statSync(entryPath).isDirectory()) {\n const nestedEntry = detectEntry(entryPath);\n return path.relative(root, path.join(entryPath, nestedEntry));\n }\n if (path.extname(entryPath) !== '.ts') {\n throw new Error('Plugin entry must be a .ts file');\n }\n if (!fs.existsSync(entryPath) || !fs.statSync(entryPath).isFile()) {\n throw new Error(`Plugin entry file does not exist: ${explicitEntry}`);\n }\n return path.relative(root, entryPath);\n }\n\n const manifestPlugin = getSingleManifestPlugin(pluginDir);\n if (manifestPlugin) {\n return detectEntry(pluginDir, manifestPlugin.entry);\n }\n\n for (const candidate of ENTRY_CANDIDATES) {\n const entryPath = path.join(pluginDir, candidate);\n if (fs.existsSync(entryPath) && fs.statSync(entryPath).isFile()) {\n return candidate;\n }\n }\n\n throw new Error(`Could not find a plugin entry file. Tried: ${ENTRY_CANDIDATES.join(', ')}`);\n}\n\nfunction isInsideDirectory(targetPath: string, root: string): boolean {\n return targetPath === root || targetPath.startsWith(root + path.sep);\n}\n\nasync function assertGithubCliAvailable(githubCli: string): Promise<void> {\n try {\n await execa(githubCli, ['--version'], NON_INTERACTIVE_EXEC_OPTIONS);\n } catch {\n throw new Error('GitHub CLI is required to install GitHub plugins. Install gh and run gh auth login.');\n }\n}\n\nasync function assertGithubCliAuthenticated(githubCli: string): Promise<void> {\n try {\n await execa(githubCli, ['auth', 'status'], NON_INTERACTIVE_EXEC_OPTIONS);\n } catch {\n throw new Error('GitHub CLI is not authenticated. Run gh auth login, then install the plugin again.');\n }\n}\n\nfunction parseGithubUrl(specifier: string): { owner: string; repo: string; repoSpec: string; ref?: string } {\n const [urlPart, ref] = specifier.split('#', 2);\n if (!urlPart) {\n throw new Error(`Invalid GitHub URL: ${specifier}`);\n }\n let url: URL;\n try {\n url = new URL(urlPart);\n } catch {\n throw new Error(`Invalid GitHub URL: ${specifier}`);\n }\n\n if (url.hostname !== 'github.com') {\n throw new Error('Only github.com plugin URLs are supported');\n }\n\n const [owner, rawRepo, ...rest] = url.pathname.split('/').filter(Boolean);\n if (!owner || !rawRepo || rest.length > 0) {\n throw new Error('GitHub plugin URL must be in the form https://github.com/owner/repo');\n }\n\n const repo = rawRepo.replace(/\\.git$/, '');\n if (!/^[A-Za-z0-9_.-]+$/.test(owner) || !/^[A-Za-z0-9_.-]+$/.test(repo)) {\n throw new Error('GitHub owner and repo may only contain letters, numbers, dots, underscores, and dashes');\n }\n\n return {\n owner,\n repo,\n repoSpec: `${owner}/${repo}`,\n ...(ref ? { ref } : {}),\n };\n}\n"],"mappings":"AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,SAAS,aAAa;AAEtB,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AACpC,SAAS,+BAA+B;AACxC,SAAS,mCAAmC;AAC5C,SAAS,eAAe,2BAA2B;AAEnD,SAAS,oBAAoB,oBAAoB,oBAAoB,uBAAuB;AAe5F,MAAM,mBAAmB,CAAC,gBAAgB,UAAU;AAE7C,MAAM,0BAA0B,EAAE,GAAG,QAAQ,KAAK,qBAAqB,IAAI;AAElF,MAAM,+BAA+B,EAAE,KAAK,wBAAwB;AAEpE,eAAsB,mBACpB,WACA,OACA,SACiB;AACjB,QAAM,aAAa,KAAK,QAAQ,QAAQ,aAAa,SAAS;AAC9D,MAAI,CAAC,GAAG,WAAW,UAAU,KAAK,CAAC,GAAG,SAAS,UAAU,EAAE,YAAY,GAAG;AACxE,UAAM,IAAI,MAAM,2DAA2D,SAAS,EAAE;AAAA,EACxF;AAEA,QAAM,QAAQ,YAAY,YAAY,QAAQ,KAAK;AACnD,8BAA4B,UAAU;AACtC,QAAM,SAAS,MAAM,oBAAoB,KAAK,KAAK,YAAY,KAAK,CAAC;AACrE,QAAM,eAAe,oBAAoB,OAAO,OAAO,EAAE;AACzD,QAAM,WAAW,mBAAmB,mBAAmB,YAAY,GAAG,OAAO,EAAE;AAC/E,QAAM,SAAgC;AAAA,IACpC,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,MAAM;AAAA,IACN;AAAA,IACA,GAAI,OAAO,UAAU,EAAE,SAAS,OAAO,QAAQ,IAAI,CAAC;AAAA,EACtD;AAEA,qBAAmB,cAAc,gBAAgB,UAAU,OAAO,IAAI,MAAM,CAAC;AAC7E,SAAO,OAA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,CAAC,QAAQ,QAAQ,GAAG,4BAA4B;AAAA,EACzE,QAAQ;AACN,UAAM,IAAI,MAAM,oFAAoF;AAAA,EACtG;AACF;AAEA,SAAS,eAAe,WAAoF;AAC1G,QAAM,CAAC,SAAS,GAAG,IAAI,UAAU,MAAM,KAAK,CAAC;AAC7C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,uBAAuB,SAAS,EAAE;AAAA,EACpD;AACA,MAAI;AACJ,MAAI;AACF,UAAM,IAAI,IAAI,OAAO;AAAA,EACvB,QAAQ;AACN,UAAM,IAAI,MAAM,uBAAuB,SAAS,EAAE;AAAA,EACpD;AAEA,MAAI,IAAI,aAAa,cAAc;AACjC,UAAM,IAAI,MAAM,2CAA2C;AAAA,EAC7D;AAEA,QAAM,CAAC,OAAO,SAAS,GAAG,IAAI,IAAI,IAAI,SAAS,MAAM,GAAG,EAAE,OAAO,OAAO;AACxE,MAAI,CAAC,SAAS,CAAC,WAAW,KAAK,SAAS,GAAG;AACzC,UAAM,IAAI,MAAM,qEAAqE;AAAA,EACvF;AAEA,QAAM,OAAO,QAAQ,QAAQ,UAAU,EAAE;AACzC,MAAI,CAAC,oBAAoB,KAAK,KAAK,KAAK,CAAC,oBAAoB,KAAK,IAAI,GAAG;AACvE,UAAM,IAAI,MAAM,wFAAwF;AAAA,EAC1G;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,UAAU,GAAG,KAAK,IAAI,IAAI;AAAA,IAC1B,GAAI,MAAM,EAAE,IAAI,IAAI,CAAC;AAAA,EACvB;AACF;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MastraCodePlugin, MastraCodePluginTools } from '../plugin.js';
|
|
2
|
+
import type { PluginPathOptions } from './paths.js';
|
|
3
|
+
import type { LoadedPlugin, PluginRegistry, ScopedInstalledPluginRecord } from './types.js';
|
|
4
|
+
export type LoadPluginsOptions = PluginPathOptions & {
|
|
5
|
+
globalRegistry?: PluginRegistry;
|
|
6
|
+
projectRegistry?: PluginRegistry;
|
|
7
|
+
};
|
|
8
|
+
export declare function loadPlugins(options: LoadPluginsOptions): Promise<LoadedPlugin[]>;
|
|
9
|
+
export declare function loadPluginRecord(record: ScopedInstalledPluginRecord, options: PluginPathOptions): Promise<LoadedPlugin>;
|
|
10
|
+
export declare function loadPluginFromEntry(entryPath: string): Promise<MastraCodePlugin>;
|
|
11
|
+
export declare function resolvePluginRoot(record: ScopedInstalledPluginRecord, options: PluginPathOptions): string;
|
|
12
|
+
export declare function resolvePluginEntryPath(record: ScopedInstalledPluginRecord, options: PluginPathOptions): string;
|
|
13
|
+
export declare function isInsideDirectory(targetPath: string, root: string): boolean;
|
|
14
|
+
export declare function collectActivePluginTools(plugins: LoadedPlugin[]): MastraCodePluginTools;
|
|
15
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/plugins/loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAKhB,qBAAqB,EAEtB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAE5F,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG;IACnD,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,eAAe,CAAC,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAsBtF;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,2BAA2B,EACnC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,YAAY,CAAC,CA6CvB;AAED,wBAAsB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAEtF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,2BAA2B,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAOzG;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,2BAA2B,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAO9G;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAI3E;AA6HD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,qBAAqB,CAWvF"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { getPluginRoot } from "./paths.js";
|
|
5
|
+
import { loadPluginRegistry, mergePluginRegistries } from "./registry.js";
|
|
6
|
+
async function loadPlugins(options) {
|
|
7
|
+
const globalRegistry = options.globalRegistry ?? loadPluginRegistry(path.join(getPluginRoot("global", options), "plugins.json"));
|
|
8
|
+
const projectRegistry = options.projectRegistry ?? loadPluginRegistry(path.join(getPluginRoot("project", options), "plugins.json"));
|
|
9
|
+
const records = mergePluginRegistries(globalRegistry, projectRegistry);
|
|
10
|
+
const loaded = [];
|
|
11
|
+
for (const record of records) {
|
|
12
|
+
if (record.blocked) {
|
|
13
|
+
loaded.push({ ...record, status: "blocked", tools: {}, toolNames: [] });
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (!record.enabled) {
|
|
17
|
+
loaded.push({ ...record, status: "inactive", tools: {}, toolNames: [] });
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
loaded.push(await loadPluginRecord(record, options));
|
|
21
|
+
}
|
|
22
|
+
return markToolConflicts(loaded);
|
|
23
|
+
}
|
|
24
|
+
async function loadPluginRecord(record, options) {
|
|
25
|
+
try {
|
|
26
|
+
const entryPath = resolvePluginEntryPath(record, options);
|
|
27
|
+
const plugin = await importPluginModule(entryPath);
|
|
28
|
+
if (plugin.id !== record.id) {
|
|
29
|
+
throw new Error(`Plugin id mismatch: registry has "${record.id}" but module exports "${plugin.id}"`);
|
|
30
|
+
}
|
|
31
|
+
const configSchema = validatePluginConfigSchema(plugin.config);
|
|
32
|
+
const configValues = resolvePluginConfigValues(configSchema, record.config);
|
|
33
|
+
const pluginDir = path.dirname(entryPath);
|
|
34
|
+
const pluginRoot = resolvePluginRoot(record, options);
|
|
35
|
+
const context = {
|
|
36
|
+
cwd: options.projectRoot,
|
|
37
|
+
scope: record.scope,
|
|
38
|
+
pluginDir,
|
|
39
|
+
config: configValues
|
|
40
|
+
};
|
|
41
|
+
const { tools, renderConfigs } = await resolvePluginTools(plugin, context);
|
|
42
|
+
const instructions = await resolvePluginInstructions(plugin, context);
|
|
43
|
+
return {
|
|
44
|
+
...record,
|
|
45
|
+
name: plugin.name,
|
|
46
|
+
version: plugin.version ?? record.version,
|
|
47
|
+
description: plugin.description,
|
|
48
|
+
instructions,
|
|
49
|
+
status: "active",
|
|
50
|
+
tools,
|
|
51
|
+
renderConfigs,
|
|
52
|
+
toolNames: Object.keys(tools).sort(),
|
|
53
|
+
skillPaths: resolveExistingAssetDirs(pluginRoot, "skills"),
|
|
54
|
+
commandPaths: resolveExistingAssetDirs(pluginRoot, "commands"),
|
|
55
|
+
configSchema,
|
|
56
|
+
configValues
|
|
57
|
+
};
|
|
58
|
+
} catch (error) {
|
|
59
|
+
return {
|
|
60
|
+
...record,
|
|
61
|
+
status: "load failed",
|
|
62
|
+
error: error instanceof Error ? error.message : String(error),
|
|
63
|
+
tools: {},
|
|
64
|
+
toolNames: []
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function loadPluginFromEntry(entryPath) {
|
|
69
|
+
return validatePluginExport(await importPluginModule(entryPath));
|
|
70
|
+
}
|
|
71
|
+
function resolvePluginRoot(record, options) {
|
|
72
|
+
const scopeRoot = path.resolve(getPluginRoot(record.scope, options));
|
|
73
|
+
const pluginRoot = path.resolve(path.isAbsolute(record.path) ? record.path : path.join(scopeRoot, record.path));
|
|
74
|
+
if (record.source === "github" && !isInsideDirectory(pluginRoot, scopeRoot)) {
|
|
75
|
+
throw new Error(`Plugin path for "${record.id}" must be inside the ${record.scope} plugin directory`);
|
|
76
|
+
}
|
|
77
|
+
return pluginRoot;
|
|
78
|
+
}
|
|
79
|
+
function resolvePluginEntryPath(record, options) {
|
|
80
|
+
const pluginRoot = resolvePluginRoot(record, options);
|
|
81
|
+
const entryPath = path.resolve(pluginRoot, record.entry);
|
|
82
|
+
if (!isInsideDirectory(entryPath, pluginRoot)) {
|
|
83
|
+
throw new Error(`Plugin entry for "${record.id}" must be inside the plugin directory`);
|
|
84
|
+
}
|
|
85
|
+
return entryPath;
|
|
86
|
+
}
|
|
87
|
+
function isInsideDirectory(targetPath, root) {
|
|
88
|
+
const resolvedTarget = path.resolve(targetPath);
|
|
89
|
+
const resolvedRoot = path.resolve(root);
|
|
90
|
+
return resolvedTarget === resolvedRoot || resolvedTarget.startsWith(resolvedRoot + path.sep);
|
|
91
|
+
}
|
|
92
|
+
function resolveExistingAssetDirs(pluginRoot, dirname) {
|
|
93
|
+
const dir = path.join(pluginRoot, dirname);
|
|
94
|
+
try {
|
|
95
|
+
return fs.statSync(dir).isDirectory() ? [dir] : [];
|
|
96
|
+
} catch {
|
|
97
|
+
return [];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function importPluginModule(entryPath) {
|
|
101
|
+
if (path.extname(entryPath) !== ".ts") {
|
|
102
|
+
throw new Error(
|
|
103
|
+
`Unsupported plugin entry extension "${path.extname(entryPath)}". V1 plugins must use .ts entries.`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
const url = pathToFileURL(entryPath);
|
|
107
|
+
const stat = fs.statSync(entryPath, { bigint: true });
|
|
108
|
+
url.searchParams.set("mtimeNs", stat.mtimeNs.toString());
|
|
109
|
+
url.searchParams.set("size", stat.size.toString());
|
|
110
|
+
const mod = await import(url.href);
|
|
111
|
+
return validatePluginExport(mod.default ?? mod.plugin);
|
|
112
|
+
}
|
|
113
|
+
function validatePluginExport(value) {
|
|
114
|
+
if (!value || typeof value !== "object") {
|
|
115
|
+
throw new Error('Plugin module must export a plugin object as default or named "plugin" export');
|
|
116
|
+
}
|
|
117
|
+
const plugin = value;
|
|
118
|
+
if (typeof plugin.id !== "string" || plugin.id.trim().length === 0) {
|
|
119
|
+
throw new Error("Plugin id must be a non-empty string");
|
|
120
|
+
}
|
|
121
|
+
if (plugin.tools !== void 0 && typeof plugin.tools !== "object" && typeof plugin.tools !== "function") {
|
|
122
|
+
throw new Error("Plugin tools must be an object or function");
|
|
123
|
+
}
|
|
124
|
+
return plugin;
|
|
125
|
+
}
|
|
126
|
+
async function resolvePluginTools(plugin, context) {
|
|
127
|
+
if (!plugin.tools) return { tools: {}, renderConfigs: {} };
|
|
128
|
+
const entries = typeof plugin.tools === "function" ? await plugin.tools(context) : plugin.tools;
|
|
129
|
+
if (!entries || typeof entries !== "object" || Array.isArray(entries)) {
|
|
130
|
+
throw new Error("Plugin tools function must return an object");
|
|
131
|
+
}
|
|
132
|
+
return normalizePluginToolEntries(entries);
|
|
133
|
+
}
|
|
134
|
+
async function resolvePluginInstructions(plugin, context) {
|
|
135
|
+
if (plugin.instructions === void 0) return void 0;
|
|
136
|
+
const instructions = typeof plugin.instructions === "function" ? await plugin.instructions(context) : plugin.instructions;
|
|
137
|
+
if (typeof instructions !== "string") {
|
|
138
|
+
throw new Error("Plugin instructions must be a string");
|
|
139
|
+
}
|
|
140
|
+
const trimmed = instructions.trim();
|
|
141
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
142
|
+
}
|
|
143
|
+
function normalizePluginToolEntries(entries) {
|
|
144
|
+
const tools = {};
|
|
145
|
+
const renderConfigs = {};
|
|
146
|
+
for (const [name, entry] of Object.entries(entries)) {
|
|
147
|
+
if (!isToolEntryObject(entry)) {
|
|
148
|
+
throw new Error(`Plugin tool "${name}" must be an object with a tool property`);
|
|
149
|
+
}
|
|
150
|
+
tools[name] = entry.tool;
|
|
151
|
+
if (entry.render) renderConfigs[name] = entry.render;
|
|
152
|
+
}
|
|
153
|
+
return { tools, renderConfigs };
|
|
154
|
+
}
|
|
155
|
+
function isToolEntryObject(entry) {
|
|
156
|
+
if (!entry || typeof entry !== "object" || !("tool" in entry)) return false;
|
|
157
|
+
const tool = entry.tool;
|
|
158
|
+
return !!tool && typeof tool === "object" && !Array.isArray(tool);
|
|
159
|
+
}
|
|
160
|
+
function validatePluginConfigSchema(schema) {
|
|
161
|
+
if (!schema || typeof schema !== "object" || Array.isArray(schema)) return void 0;
|
|
162
|
+
const validated = {};
|
|
163
|
+
for (const [key, option] of Object.entries(schema)) {
|
|
164
|
+
if (!option || typeof option !== "object" || Array.isArray(option)) continue;
|
|
165
|
+
const record = option;
|
|
166
|
+
if (record.type !== "model" && record.type !== "boolean" && record.type !== "string") continue;
|
|
167
|
+
validated[key] = {
|
|
168
|
+
type: record.type,
|
|
169
|
+
...typeof record.label === "string" ? { label: record.label } : {},
|
|
170
|
+
...typeof record.description === "string" ? { description: record.description } : {},
|
|
171
|
+
...typeof record.default === "string" || typeof record.default === "boolean" ? { default: record.default } : {}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
return Object.keys(validated).length > 0 ? validated : void 0;
|
|
175
|
+
}
|
|
176
|
+
function resolvePluginConfigValues(schema, recordValues) {
|
|
177
|
+
const values = {};
|
|
178
|
+
if (!schema) return values;
|
|
179
|
+
for (const [key, option] of Object.entries(schema)) {
|
|
180
|
+
const value = recordValues?.[key];
|
|
181
|
+
if (option.type === "boolean") {
|
|
182
|
+
values[key] = typeof value === "boolean" ? value : typeof option.default === "boolean" ? option.default : false;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
values[key] = typeof value === "string" ? value : typeof option.default === "string" ? option.default : void 0;
|
|
186
|
+
}
|
|
187
|
+
return values;
|
|
188
|
+
}
|
|
189
|
+
function collectActivePluginTools(plugins) {
|
|
190
|
+
const tools = {};
|
|
191
|
+
for (const plugin of plugins) {
|
|
192
|
+
if (plugin.status !== "active") continue;
|
|
193
|
+
for (const [name, tool] of Object.entries(plugin.tools)) {
|
|
194
|
+
if (!(name in tools)) {
|
|
195
|
+
tools[name] = tool;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return tools;
|
|
200
|
+
}
|
|
201
|
+
function markToolConflicts(plugins) {
|
|
202
|
+
const seen = /* @__PURE__ */ new Map();
|
|
203
|
+
return plugins.map((plugin) => {
|
|
204
|
+
if (plugin.status !== "active") return plugin;
|
|
205
|
+
const conflicts = plugin.toolNames.filter((toolName) => seen.has(toolName));
|
|
206
|
+
for (const toolName of plugin.toolNames) {
|
|
207
|
+
if (!seen.has(toolName)) seen.set(toolName, plugin.id);
|
|
208
|
+
}
|
|
209
|
+
return conflicts.length > 0 ? { ...plugin, status: "conflicted", conflicts } : plugin;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
export {
|
|
213
|
+
collectActivePluginTools,
|
|
214
|
+
isInsideDirectory,
|
|
215
|
+
loadPluginFromEntry,
|
|
216
|
+
loadPluginRecord,
|
|
217
|
+
loadPlugins,
|
|
218
|
+
resolvePluginEntryPath,
|
|
219
|
+
resolvePluginRoot
|
|
220
|
+
};
|
|
221
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/loader.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type {\n MastraCodePlugin,\n MastraCodePluginConfigSchema,\n MastraCodePluginConfigValues,\n MastraCodePluginContext,\n MastraCodePluginToolEntries,\n MastraCodePluginTools,\n MastraCodeToolRenderConfig,\n} from '../plugin.js';\nimport { getPluginRoot } from './paths.js';\nimport type { PluginPathOptions } from './paths.js';\nimport { loadPluginRegistry, mergePluginRegistries } from './registry.js';\nimport type { LoadedPlugin, PluginRegistry, ScopedInstalledPluginRecord } from './types.js';\n\nexport type LoadPluginsOptions = PluginPathOptions & {\n globalRegistry?: PluginRegistry;\n projectRegistry?: PluginRegistry;\n};\n\nexport async function loadPlugins(options: LoadPluginsOptions): Promise<LoadedPlugin[]> {\n const globalRegistry =\n options.globalRegistry ?? loadPluginRegistry(path.join(getPluginRoot('global', options), 'plugins.json'));\n const projectRegistry =\n options.projectRegistry ?? loadPluginRegistry(path.join(getPluginRoot('project', options), 'plugins.json'));\n const records = mergePluginRegistries(globalRegistry, projectRegistry);\n const loaded: LoadedPlugin[] = [];\n\n for (const record of records) {\n if (record.blocked) {\n loaded.push({ ...record, status: 'blocked', tools: {}, toolNames: [] });\n continue;\n }\n if (!record.enabled) {\n loaded.push({ ...record, status: 'inactive', tools: {}, toolNames: [] });\n continue;\n }\n\n loaded.push(await loadPluginRecord(record, options));\n }\n\n return markToolConflicts(loaded);\n}\n\nexport async function loadPluginRecord(\n record: ScopedInstalledPluginRecord,\n options: PluginPathOptions,\n): Promise<LoadedPlugin> {\n try {\n const entryPath = resolvePluginEntryPath(record, options);\n const plugin = await importPluginModule(entryPath);\n if (plugin.id !== record.id) {\n throw new Error(`Plugin id mismatch: registry has \"${record.id}\" but module exports \"${plugin.id}\"`);\n }\n\n const configSchema = validatePluginConfigSchema(plugin.config);\n const configValues = resolvePluginConfigValues(configSchema, record.config);\n const pluginDir = path.dirname(entryPath);\n const pluginRoot = resolvePluginRoot(record, options);\n const context: MastraCodePluginContext = {\n cwd: options.projectRoot,\n scope: record.scope,\n pluginDir,\n config: configValues,\n };\n const { tools, renderConfigs } = await resolvePluginTools(plugin, context);\n const instructions = await resolvePluginInstructions(plugin, context);\n\n return {\n ...record,\n name: plugin.name,\n version: plugin.version ?? record.version,\n description: plugin.description,\n instructions,\n status: 'active',\n tools,\n renderConfigs,\n toolNames: Object.keys(tools).sort(),\n skillPaths: resolveExistingAssetDirs(pluginRoot, 'skills'),\n commandPaths: resolveExistingAssetDirs(pluginRoot, 'commands'),\n configSchema,\n configValues,\n };\n } catch (error) {\n return {\n ...record,\n status: 'load failed',\n error: error instanceof Error ? error.message : String(error),\n tools: {},\n toolNames: [],\n };\n }\n}\n\nexport async function loadPluginFromEntry(entryPath: string): Promise<MastraCodePlugin> {\n return validatePluginExport(await importPluginModule(entryPath));\n}\n\nexport function resolvePluginRoot(record: ScopedInstalledPluginRecord, options: PluginPathOptions): string {\n const scopeRoot = path.resolve(getPluginRoot(record.scope, options));\n const pluginRoot = path.resolve(path.isAbsolute(record.path) ? record.path : path.join(scopeRoot, record.path));\n if (record.source === 'github' && !isInsideDirectory(pluginRoot, scopeRoot)) {\n throw new Error(`Plugin path for \"${record.id}\" must be inside the ${record.scope} plugin directory`);\n }\n return pluginRoot;\n}\n\nexport function resolvePluginEntryPath(record: ScopedInstalledPluginRecord, options: PluginPathOptions): string {\n const pluginRoot = resolvePluginRoot(record, options);\n const entryPath = path.resolve(pluginRoot, record.entry);\n if (!isInsideDirectory(entryPath, pluginRoot)) {\n throw new Error(`Plugin entry for \"${record.id}\" must be inside the plugin directory`);\n }\n return entryPath;\n}\n\nexport function isInsideDirectory(targetPath: string, root: string): boolean {\n const resolvedTarget = path.resolve(targetPath);\n const resolvedRoot = path.resolve(root);\n return resolvedTarget === resolvedRoot || resolvedTarget.startsWith(resolvedRoot + path.sep);\n}\n\nfunction resolveExistingAssetDirs(pluginRoot: string, dirname: 'skills' | 'commands'): string[] {\n const dir = path.join(pluginRoot, dirname);\n try {\n return fs.statSync(dir).isDirectory() ? [dir] : [];\n } catch {\n return [];\n }\n}\n\nasync function importPluginModule(entryPath: string): Promise<MastraCodePlugin> {\n if (path.extname(entryPath) !== '.ts') {\n throw new Error(\n `Unsupported plugin entry extension \"${path.extname(entryPath)}\". V1 plugins must use .ts entries.`,\n );\n }\n\n const url = pathToFileURL(entryPath);\n const stat = fs.statSync(entryPath, { bigint: true });\n url.searchParams.set('mtimeNs', stat.mtimeNs.toString());\n url.searchParams.set('size', stat.size.toString());\n const mod = (await import(url.href)) as { default?: unknown; plugin?: unknown };\n return validatePluginExport(mod.default ?? mod.plugin);\n}\n\nfunction validatePluginExport(value: unknown): MastraCodePlugin {\n if (!value || typeof value !== 'object') {\n throw new Error('Plugin module must export a plugin object as default or named \"plugin\" export');\n }\n\n const plugin = value as MastraCodePlugin;\n if (typeof plugin.id !== 'string' || plugin.id.trim().length === 0) {\n throw new Error('Plugin id must be a non-empty string');\n }\n\n if (plugin.tools !== undefined && typeof plugin.tools !== 'object' && typeof plugin.tools !== 'function') {\n throw new Error('Plugin tools must be an object or function');\n }\n\n return plugin;\n}\n\nasync function resolvePluginTools(\n plugin: MastraCodePlugin,\n context: MastraCodePluginContext,\n): Promise<{ tools: MastraCodePluginTools; renderConfigs: Record<string, MastraCodeToolRenderConfig> }> {\n if (!plugin.tools) return { tools: {}, renderConfigs: {} };\n const entries = typeof plugin.tools === 'function' ? await plugin.tools(context) : plugin.tools;\n if (!entries || typeof entries !== 'object' || Array.isArray(entries)) {\n throw new Error('Plugin tools function must return an object');\n }\n return normalizePluginToolEntries(entries);\n}\n\nasync function resolvePluginInstructions(\n plugin: MastraCodePlugin,\n context: MastraCodePluginContext,\n): Promise<string | undefined> {\n if (plugin.instructions === undefined) return undefined;\n const instructions =\n typeof plugin.instructions === 'function' ? await plugin.instructions(context) : plugin.instructions;\n if (typeof instructions !== 'string') {\n throw new Error('Plugin instructions must be a string');\n }\n const trimmed = instructions.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n}\n\nfunction normalizePluginToolEntries(entries: MastraCodePluginToolEntries): {\n tools: MastraCodePluginTools;\n renderConfigs: Record<string, MastraCodeToolRenderConfig>;\n} {\n const tools: MastraCodePluginTools = {};\n const renderConfigs: Record<string, MastraCodeToolRenderConfig> = {};\n for (const [name, entry] of Object.entries(entries)) {\n if (!isToolEntryObject(entry)) {\n throw new Error(`Plugin tool \"${name}\" must be an object with a tool property`);\n }\n tools[name] = entry.tool;\n if (entry.render) renderConfigs[name] = entry.render;\n }\n return { tools, renderConfigs };\n}\n\nfunction isToolEntryObject(entry: MastraCodePluginToolEntries[string]): entry is MastraCodePluginToolEntries[string] {\n if (!entry || typeof entry !== 'object' || !('tool' in entry)) return false;\n const tool = (entry as { tool?: unknown }).tool;\n return !!tool && typeof tool === 'object' && !Array.isArray(tool);\n}\n\nfunction validatePluginConfigSchema(schema: unknown): MastraCodePluginConfigSchema | undefined {\n if (!schema || typeof schema !== 'object' || Array.isArray(schema)) return undefined;\n const validated: MastraCodePluginConfigSchema = {};\n for (const [key, option] of Object.entries(schema)) {\n if (!option || typeof option !== 'object' || Array.isArray(option)) continue;\n const record = option as Record<string, unknown>;\n if (record.type !== 'model' && record.type !== 'boolean' && record.type !== 'string') continue;\n validated[key] = {\n type: record.type,\n ...(typeof record.label === 'string' ? { label: record.label } : {}),\n ...(typeof record.description === 'string' ? { description: record.description } : {}),\n ...(typeof record.default === 'string' || typeof record.default === 'boolean' ? { default: record.default } : {}),\n };\n }\n return Object.keys(validated).length > 0 ? validated : undefined;\n}\n\nfunction resolvePluginConfigValues(\n schema: MastraCodePluginConfigSchema | undefined,\n recordValues: Record<string, unknown> | undefined,\n): MastraCodePluginConfigValues {\n const values: MastraCodePluginConfigValues = {};\n if (!schema) return values;\n for (const [key, option] of Object.entries(schema)) {\n const value = recordValues?.[key];\n if (option.type === 'boolean') {\n values[key] = typeof value === 'boolean' ? value : typeof option.default === 'boolean' ? option.default : false;\n continue;\n }\n values[key] = typeof value === 'string' ? value : typeof option.default === 'string' ? option.default : undefined;\n }\n return values;\n}\n\nexport function collectActivePluginTools(plugins: LoadedPlugin[]): MastraCodePluginTools {\n const tools: MastraCodePluginTools = {};\n for (const plugin of plugins) {\n if (plugin.status !== 'active') continue;\n for (const [name, tool] of Object.entries(plugin.tools)) {\n if (!(name in tools)) {\n tools[name] = tool;\n }\n }\n }\n return tools;\n}\n\nfunction markToolConflicts(plugins: LoadedPlugin[]): LoadedPlugin[] {\n const seen = new Map<string, string>();\n return plugins.map(plugin => {\n if (plugin.status !== 'active') return plugin;\n const conflicts = plugin.toolNames.filter(toolName => seen.has(toolName));\n for (const toolName of plugin.toolNames) {\n if (!seen.has(toolName)) seen.set(toolName, plugin.id);\n }\n return conflicts.length > 0 ? { ...plugin, status: 'conflicted', conflicts } : plugin;\n });\n}\n"],"mappings":"AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAW9B,SAAS,qBAAqB;AAE9B,SAAS,oBAAoB,6BAA6B;AAQ1D,eAAsB,YAAY,SAAsD;AACtF,QAAM,iBACJ,QAAQ,kBAAkB,mBAAmB,KAAK,KAAK,cAAc,UAAU,OAAO,GAAG,cAAc,CAAC;AAC1G,QAAM,kBACJ,QAAQ,mBAAmB,mBAAmB,KAAK,KAAK,cAAc,WAAW,OAAO,GAAG,cAAc,CAAC;AAC5G,QAAM,UAAU,sBAAsB,gBAAgB,eAAe;AACrE,QAAM,SAAyB,CAAC;AAEhC,aAAW,UAAU,SAAS;AAC5B,QAAI,OAAO,SAAS;AAClB,aAAO,KAAK,EAAE,GAAG,QAAQ,QAAQ,WAAW,OAAO,CAAC,GAAG,WAAW,CAAC,EAAE,CAAC;AACtE;AAAA,IACF;AACA,QAAI,CAAC,OAAO,SAAS;AACnB,aAAO,KAAK,EAAE,GAAG,QAAQ,QAAQ,YAAY,OAAO,CAAC,GAAG,WAAW,CAAC,EAAE,CAAC;AACvE;AAAA,IACF;AAEA,WAAO,KAAK,MAAM,iBAAiB,QAAQ,OAAO,CAAC;AAAA,EACrD;AAEA,SAAO,kBAAkB,MAAM;AACjC;AAEA,eAAsB,iBACpB,QACA,SACuB;AACvB,MAAI;AACF,UAAM,YAAY,uBAAuB,QAAQ,OAAO;AACxD,UAAM,SAAS,MAAM,mBAAmB,SAAS;AACjD,QAAI,OAAO,OAAO,OAAO,IAAI;AAC3B,YAAM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;AACpB,aAAW,CAAC,KAAK,MAAM,KAAK,OAAO,QAAQ,MAAM,GAAG;AAClD,UAAM,QAAQ,eAAe,GAAG;AAChC,QAAI,OAAO,SAAS,WAAW;AAC7B,aAAO,GAAG,IAAI,OAAO,UAAU,YAAY,QAAQ,OAAO,OAAO,YAAY,YAAY,OAAO,UAAU;AAC1G;AAAA,IACF;AACA,WAAO,GAAG,IAAI,OAAO,UAAU,WAAW,QAAQ,OAAO,OAAO,YAAY,WAAW,OAAO,UAAU;AAAA,EAC1G;AACA,SAAO;AACT;AAEO,SAAS,yBAAyB,SAAgD;AACvF,QAAM,QAA+B,CAAC;AACtC,aAAW,UAAU,SAAS;AAC5B,QAAI,OAAO,WAAW,SAAU;AAChC,eAAW,CAAC,MAAM,IAAI,KAAK,OAAO,QAAQ,OAAO,KAAK,GAAG;AACvD,UAAI,EAAE,QAAQ,QAAQ;AACpB,cAAM,IAAI,IAAI;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,kBAAkB,SAAyC;AAClE,QAAM,OAAO,oBAAI,IAAoB;AACrC,SAAO,QAAQ,IAAI,YAAU;AAC3B,QAAI,OAAO,WAAW,SAAU,QAAO;AACvC,UAAM,YAAY,OAAO,UAAU,OAAO,cAAY,KAAK,IAAI,QAAQ,CAAC;AACxE,eAAW,YAAY,OAAO,WAAW;AACvC,UAAI,CAAC,KAAK,IAAI,QAAQ,EAAG,MAAK,IAAI,UAAU,OAAO,EAAE;AAAA,IACvD;AACA,WAAO,UAAU,SAAS,IAAI,EAAE,GAAG,QAAQ,QAAQ,cAAc,UAAU,IAAI;AAAA,EACjF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { MastraCodePluginConfigValue } from '../plugin.js';
|
|
2
|
+
import { discoverLocalPlugins } from './install.js';
|
|
3
|
+
import type { InstallPluginOptions } from './install.js';
|
|
4
|
+
import type { PluginPathOptions } from './paths.js';
|
|
5
|
+
import type { LoadedPlugin, PluginScope } from './types.js';
|
|
6
|
+
type PluginManagerOptions = PluginPathOptions & {
|
|
7
|
+
githubCliPath?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class PluginManager {
|
|
10
|
+
private readonly options;
|
|
11
|
+
private loadedPlugins;
|
|
12
|
+
private readonly pluginTools;
|
|
13
|
+
private readonly rawPluginTools;
|
|
14
|
+
private readonly toolRenderConfigs;
|
|
15
|
+
private readonly watchedLocalEntries;
|
|
16
|
+
private readonly localEntryVersions;
|
|
17
|
+
private githubPollTimer;
|
|
18
|
+
private githubPollInFlight;
|
|
19
|
+
private reloadInFlight;
|
|
20
|
+
private readonly reloadListeners;
|
|
21
|
+
constructor(options: PluginManagerOptions);
|
|
22
|
+
onReload(listener: (plugins: LoadedPlugin[]) => void | Promise<void>): () => void;
|
|
23
|
+
reload(): Promise<LoadedPlugin[]>;
|
|
24
|
+
listPlugins(): Promise<LoadedPlugin[]>;
|
|
25
|
+
getLoadedPlugins(): LoadedPlugin[];
|
|
26
|
+
getPluginTools(): import("../plugin.js").MastraCodePluginTools;
|
|
27
|
+
getToolRenderConfig(toolName: string): import("../plugin.js").MastraCodeToolRenderConfig | undefined;
|
|
28
|
+
getPluginSkillPaths(): string[];
|
|
29
|
+
getPluginCommandPaths(): string[];
|
|
30
|
+
getPluginInstructions(): string[];
|
|
31
|
+
private notifyReloadListeners;
|
|
32
|
+
private updatePluginRenderConfigs;
|
|
33
|
+
private updatePluginTools;
|
|
34
|
+
private createLiveToolProxy;
|
|
35
|
+
private syncLiveToolProxy;
|
|
36
|
+
private reloadChangedLocalPlugins;
|
|
37
|
+
private updateLocalEntryWatchers;
|
|
38
|
+
private updateGithubPoller;
|
|
39
|
+
pollGithubSourcesForUpdates(): Promise<boolean>;
|
|
40
|
+
private pollGithubSourcesForUpdatesOnce;
|
|
41
|
+
private refreshGithubCheckout;
|
|
42
|
+
private backupGitCheckout;
|
|
43
|
+
private resolveGitUpstream;
|
|
44
|
+
private readGitAheadBehind;
|
|
45
|
+
private hasGitWorkingTreeChanges;
|
|
46
|
+
private hasGitStagedChanges;
|
|
47
|
+
private restoreGitCheckout;
|
|
48
|
+
private readGitCurrentBranch;
|
|
49
|
+
private createGitBackupBranchName;
|
|
50
|
+
private resolvePluginSourcePath;
|
|
51
|
+
private readGitHead;
|
|
52
|
+
discoverLocal(searchRoot?: string): ReturnType<typeof discoverLocalPlugins>;
|
|
53
|
+
installLocal(localPath: string, scope: PluginScope, options?: Pick<InstallPluginOptions, 'entry'>): Promise<string>;
|
|
54
|
+
installGithub(url: string, scope: PluginScope, options?: Pick<InstallPluginOptions, 'entry' | 'ref'>): Promise<string>;
|
|
55
|
+
setEnabled(pluginId: string, scope: PluginScope, enabled: boolean): Promise<void>;
|
|
56
|
+
setConfigValue(pluginId: string, scope: PluginScope, key: string, value: MastraCodePluginConfigValue): Promise<void>;
|
|
57
|
+
uninstall(pluginId: string, scope: PluginScope): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/plugins/manager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAoE,MAAM,cAAc,CAAC;AACtH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAa5D,KAAK,oBAAoB,GAAG,iBAAiB,GAAG;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,qBAAa,aAAa;IAYZ,OAAO,CAAC,QAAQ,CAAC,OAAO;IAXpC,OAAO,CAAC,aAAa,CAAsB;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