@mastra/code-sdk 0.0.0-aggregate-trace-20261015182851
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/LICENSE.md +32 -0
- package/README.md +284 -0
- package/dist/acp/agent.d.ts +48 -0
- package/dist/acp/agent.d.ts.map +1 -0
- package/dist/acp/agent.js +416 -0
- package/dist/acp/agent.js.map +1 -0
- package/dist/acp/errors.d.ts +3 -0
- package/dist/acp/errors.d.ts.map +1 -0
- package/dist/acp/errors.js +14 -0
- package/dist/acp/errors.js.map +1 -0
- package/dist/acp/event-mapper.d.ts +28 -0
- package/dist/acp/event-mapper.d.ts.map +1 -0
- package/dist/acp/event-mapper.js +279 -0
- package/dist/acp/event-mapper.js.map +1 -0
- package/dist/acp/index.d.ts +9 -0
- package/dist/acp/index.d.ts.map +1 -0
- package/dist/acp/index.js +24 -0
- package/dist/acp/index.js.map +1 -0
- package/dist/acp/runtime.d.ts +5 -0
- package/dist/acp/runtime.d.ts.map +1 -0
- package/dist/acp/runtime.js +91 -0
- package/dist/acp/runtime.js.map +1 -0
- package/dist/acp/server.d.ts +4 -0
- package/dist/acp/server.d.ts.map +1 -0
- package/dist/acp/server.js +38 -0
- package/dist/acp/server.js.map +1 -0
- package/dist/acp/skills.d.ts +6 -0
- package/dist/acp/skills.d.ts.map +1 -0
- package/dist/acp/skills.js +33 -0
- package/dist/acp/skills.js.map +1 -0
- package/dist/acp.d.ts +2 -0
- package/dist/acp.d.ts.map +1 -0
- package/dist/acp.js +2 -0
- package/dist/agent-connections/messaging-processor.d.ts +17 -0
- package/dist/agent-connections/messaging-processor.d.ts.map +1 -0
- package/dist/agent-connections/messaging-processor.js +134 -0
- package/dist/agent-connections/messaging-processor.js.map +1 -0
- package/dist/agent-connections/ownership.d.ts +24 -0
- package/dist/agent-connections/ownership.d.ts.map +1 -0
- package/dist/agent-connections/ownership.js +99 -0
- package/dist/agent-connections/ownership.js.map +1 -0
- package/dist/agent-connections/registry.d.ts +20 -0
- package/dist/agent-connections/registry.d.ts.map +1 -0
- package/dist/agent-connections/registry.js +170 -0
- package/dist/agent-connections/registry.js.map +1 -0
- package/dist/agent-connections/session-advertisement.d.ts +27 -0
- package/dist/agent-connections/session-advertisement.d.ts.map +1 -0
- package/dist/agent-connections/session-advertisement.js +89 -0
- package/dist/agent-connections/session-advertisement.js.map +1 -0
- package/dist/agent-connections/signal-provider.d.ts +141 -0
- package/dist/agent-connections/signal-provider.d.ts.map +1 -0
- package/dist/agent-connections/signal-provider.js +38 -0
- package/dist/agent-connections/signal-provider.js.map +1 -0
- package/dist/agent-connections/state-processor.d.ts +23 -0
- package/dist/agent-connections/state-processor.d.ts.map +1 -0
- package/dist/agent-connections/state-processor.js +273 -0
- package/dist/agent-connections/state-processor.js.map +1 -0
- package/dist/agent-connections/thread-state.d.ts +41 -0
- package/dist/agent-connections/thread-state.d.ts.map +1 -0
- package/dist/agent-connections/thread-state.js +160 -0
- package/dist/agent-connections/thread-state.js.map +1 -0
- package/dist/agent-connections/tools.d.ts +133 -0
- package/dist/agent-connections/tools.d.ts.map +1 -0
- package/dist/agent-connections/tools.js +552 -0
- package/dist/agent-connections/tools.js.map +1 -0
- package/dist/agent-connections/types.d.ts +99 -0
- package/dist/agent-connections/types.d.ts.map +1 -0
- package/dist/agent-connections/types.js +7 -0
- package/dist/agent-connections/types.js.map +1 -0
- package/dist/agent-connections/untrusted-text.d.ts +5 -0
- package/dist/agent-connections/untrusted-text.d.ts.map +1 -0
- package/dist/agent-connections/untrusted-text.js +22 -0
- package/dist/agent-connections/untrusted-text.js.map +1 -0
- package/dist/agents/background-completion-events.d.ts +16 -0
- package/dist/agents/background-completion-events.d.ts.map +1 -0
- package/dist/agents/background-completion-events.js +19 -0
- package/dist/agents/background-completion-events.js.map +1 -0
- package/dist/agents/background-completion.d.ts +9 -0
- package/dist/agents/background-completion.d.ts.map +1 -0
- package/dist/agents/background-completion.js +59 -0
- package/dist/agents/background-completion.js.map +1 -0
- package/dist/agents/context-audit.d.ts +84 -0
- package/dist/agents/context-audit.d.ts.map +1 -0
- package/dist/agents/context-audit.js +118 -0
- package/dist/agents/context-audit.js.map +1 -0
- package/dist/agents/credential-resolver.d.ts +67 -0
- package/dist/agents/credential-resolver.d.ts.map +1 -0
- package/dist/agents/credential-resolver.js +136 -0
- package/dist/agents/credential-resolver.js.map +1 -0
- package/dist/agents/custom-provider-source.d.ts +35 -0
- package/dist/agents/custom-provider-source.d.ts.map +1 -0
- package/dist/agents/custom-provider-source.js +25 -0
- package/dist/agents/custom-provider-source.js.map +1 -0
- package/dist/agents/instructions.d.ts +40 -0
- package/dist/agents/instructions.d.ts.map +1 -0
- package/dist/agents/instructions.js +63 -0
- package/dist/agents/instructions.js.map +1 -0
- package/dist/agents/mastracode-gateway.d.ts +76 -0
- package/dist/agents/mastracode-gateway.d.ts.map +1 -0
- package/dist/agents/mastracode-gateway.js +434 -0
- package/dist/agents/mastracode-gateway.js.map +1 -0
- package/dist/agents/memory.d.ts +39 -0
- package/dist/agents/memory.d.ts.map +1 -0
- package/dist/agents/memory.js +266 -0
- package/dist/agents/memory.js.map +1 -0
- package/dist/agents/model.d.ts +123 -0
- package/dist/agents/model.d.ts.map +1 -0
- package/dist/agents/model.js +295 -0
- package/dist/agents/model.js.map +1 -0
- package/dist/agents/modes/build.d.ts +12 -0
- package/dist/agents/modes/build.d.ts.map +1 -0
- package/dist/agents/modes/build.js +36 -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 +28 -0
- package/dist/agents/modes/explore.js.map +1 -0
- package/dist/agents/modes/plan.d.ts +8 -0
- package/dist/agents/modes/plan.d.ts.map +1 -0
- package/dist/agents/modes/plan.js +46 -0
- package/dist/agents/modes/plan.js.map +1 -0
- package/dist/agents/prompts/agent-instructions.d.ts +99 -0
- package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
- package/dist/agents/prompts/agent-instructions.js +275 -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 +76 -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 +26 -0
- package/dist/agents/prompts/fast.js.map +1 -0
- package/dist/agents/prompts/index.d.ts +54 -0
- package/dist/agents/prompts/index.d.ts.map +1 -0
- package/dist/agents/prompts/index.js +127 -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 +23 -0
- package/dist/agents/prompts/model.js.map +1 -0
- package/dist/agents/prompts/plan.d.ts +8 -0
- package/dist/agents/prompts/plan.d.ts.map +1 -0
- package/dist/agents/prompts/plan.js +129 -0
- package/dist/agents/prompts/plan.js.map +1 -0
- package/dist/agents/prompts/tool-guidance.d.ts +18 -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 +151 -0
- package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
- package/dist/agents/sandbox-filesystem.js +581 -0
- package/dist/agents/sandbox-filesystem.js.map +1 -0
- package/dist/agents/subagents/execute.d.ts +3 -0
- package/dist/agents/subagents/execute.d.ts.map +1 -0
- package/dist/agents/subagents/execute.js +27 -0
- package/dist/agents/subagents/execute.js.map +1 -0
- package/dist/agents/subagents/explore.d.ts +3 -0
- package/dist/agents/subagents/explore.d.ts.map +1 -0
- package/dist/agents/subagents/explore.js +18 -0
- package/dist/agents/subagents/explore.js.map +1 -0
- package/dist/agents/subagents/plan.d.ts +3 -0
- package/dist/agents/subagents/plan.d.ts.map +1 -0
- package/dist/agents/subagents/plan.js +18 -0
- package/dist/agents/subagents/plan.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 +107 -0
- package/dist/agents/thread-caveman-state.js.map +1 -0
- package/dist/agents/tool-availability.d.ts +12 -0
- package/dist/agents/tool-availability.d.ts.map +1 -0
- package/dist/agents/tool-availability.js +129 -0
- package/dist/agents/tool-availability.js.map +1 -0
- package/dist/agents/tools.d.ts +37 -0
- package/dist/agents/tools.d.ts.map +1 -0
- package/dist/agents/tools.js +131 -0
- package/dist/agents/tools.js.map +1 -0
- package/dist/agents/workflow-builder-agent.d.ts +2 -0
- package/dist/agents/workflow-builder-agent.d.ts.map +1 -0
- package/dist/agents/workflow-builder-agent.js +82 -0
- package/dist/agents/workflow-builder-agent.js.map +1 -0
- package/dist/agents/workspace.d.ts +33 -0
- package/dist/agents/workspace.d.ts.map +1 -0
- package/dist/agents/workspace.js +208 -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 +162 -0
- package/dist/analytics.js.map +1 -0
- package/dist/auth/account-rotation-processor.d.ts +182 -0
- package/dist/auth/account-rotation-processor.d.ts.map +1 -0
- package/dist/auth/account-rotation-processor.js +609 -0
- package/dist/auth/account-rotation-processor.js.map +1 -0
- package/dist/auth/account-routing-context.d.ts +13 -0
- package/dist/auth/account-routing-context.d.ts.map +1 -0
- package/dist/auth/account-routing-context.js +41 -0
- package/dist/auth/account-routing-context.js.map +1 -0
- package/dist/auth/authorization-input.d.ts +16 -0
- package/dist/auth/authorization-input.d.ts.map +1 -0
- package/dist/auth/authorization-input.js +42 -0
- package/dist/auth/authorization-input.js.map +1 -0
- package/dist/auth/device-code.d.ts +93 -0
- package/dist/auth/device-code.d.ts.map +1 -0
- package/dist/auth/device-code.js +129 -0
- package/dist/auth/device-code.js.map +1 -0
- package/dist/auth/index.d.ts +13 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +9 -0
- package/dist/auth/pkce.d.ts +13 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +32 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/provider-auth-error.d.ts +12 -0
- package/dist/auth/provider-auth-error.d.ts.map +1 -0
- package/dist/auth/provider-auth-error.js +16 -0
- package/dist/auth/provider-auth-error.js.map +1 -0
- package/dist/auth/providers/anthropic.d.ts +40 -0
- package/dist/auth/providers/anthropic.d.ts.map +1 -0
- package/dist/auth/providers/anthropic.js +120 -0
- package/dist/auth/providers/anthropic.js.map +1 -0
- package/dist/auth/providers/github-copilot.d.ts +154 -0
- package/dist/auth/providers/github-copilot.d.ts.map +1 -0
- package/dist/auth/providers/github-copilot.js +362 -0
- package/dist/auth/providers/github-copilot.js.map +1 -0
- package/dist/auth/providers/kimi-coding.d.ts +38 -0
- package/dist/auth/providers/kimi-coding.d.ts.map +1 -0
- package/dist/auth/providers/kimi-coding.js +228 -0
- package/dist/auth/providers/kimi-coding.js.map +1 -0
- package/dist/auth/providers/openai-codex.d.ts +141 -0
- package/dist/auth/providers/openai-codex.d.ts.map +1 -0
- package/dist/auth/providers/openai-codex.js +533 -0
- package/dist/auth/providers/openai-codex.js.map +1 -0
- package/dist/auth/providers/xai.d.ts +64 -0
- package/dist/auth/providers/xai.d.ts.map +1 -0
- package/dist/auth/providers/xai.js +226 -0
- package/dist/auth/providers/xai.js.map +1 -0
- package/dist/auth/storage.d.ts +214 -0
- package/dist/auth/storage.d.ts.map +1 -0
- package/dist/auth/storage.js +774 -0
- package/dist/auth/storage.js.map +1 -0
- package/dist/auth/types.d.ts +164 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/clipboard/index.d.ts +26 -0
- package/dist/clipboard/index.d.ts.map +1 -0
- package/dist/clipboard/index.js +226 -0
- package/dist/clipboard/index.js.map +1 -0
- package/dist/constants.d.ts +12 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +20 -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 +22 -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 +161 -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 +5 -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 +73 -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 +259 -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 +60 -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 +3 -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 +347 -0
- package/dist/evals/scorers/outcome.js.map +1 -0
- package/dist/experimental-agent.d.ts +11 -0
- package/dist/experimental-agent.d.ts.map +1 -0
- package/dist/experimental-agent.js +36 -0
- package/dist/experimental-agent.js.map +1 -0
- package/dist/goal-manager.d.ts +114 -0
- package/dist/goal-manager.d.ts.map +1 -0
- package/dist/goal-manager.js +354 -0
- package/dist/goal-manager.js.map +1 -0
- package/dist/goal-signal.d.ts +14 -0
- package/dist/goal-signal.d.ts.map +1 -0
- package/dist/goal-signal.js +17 -0
- package/dist/goal-signal.js.map +1 -0
- package/dist/headless/cli.d.ts +48 -0
- package/dist/headless/cli.d.ts.map +1 -0
- package/dist/headless/cli.js +239 -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 +203 -0
- package/dist/headless/flags.js.map +1 -0
- package/dist/headless/format.d.ts +39 -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 +6 -0
- package/dist/headless/policy.d.ts +17 -0
- package/dist/headless/policy.d.ts.map +1 -0
- package/dist/headless/policy.js +42 -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 +408 -0
- package/dist/headless/run-mc.js.map +1 -0
- package/dist/headless/types.d.ts +174 -0
- package/dist/headless/types.d.ts.map +1 -0
- package/dist/headless/types.js +19 -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 +80 -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 +129 -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 +5 -0
- package/dist/hooks/manager.d.ts +54 -0
- package/dist/hooks/manager.d.ts.map +1 -0
- package/dist/hooks/manager.js +241 -0
- package/dist/hooks/manager.js.map +1 -0
- package/dist/hooks/types.d.ts +172 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +8 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +463 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1305 -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 +21 -0
- package/dist/ipc/ipc-reporter.js.map +1 -0
- package/dist/knowledge-inspector.d.ts +123 -0
- package/dist/knowledge-inspector.d.ts.map +1 -0
- package/dist/knowledge-inspector.js +516 -0
- package/dist/knowledge-inspector.js.map +1 -0
- package/dist/knowledge-scope.d.ts +35 -0
- package/dist/knowledge-scope.d.ts.map +1 -0
- package/dist/knowledge-scope.js +47 -0
- package/dist/knowledge-scope.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 +251 -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 +4 -0
- package/dist/lsp/language.d.ts +9 -0
- package/dist/lsp/language.d.ts.map +1 -0
- package/dist/lsp/language.js +44 -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 +82 -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 +159 -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 +55 -0
- package/dist/lsp/workspace.js.map +1 -0
- package/dist/mcp/config.d.ts +77 -0
- package/dist/mcp/config.d.ts.map +1 -0
- package/dist/mcp/config.js +316 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/manager.d.ts +102 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/manager.js +650 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/state.d.ts +35 -0
- package/dist/mcp/state.d.ts.map +1 -0
- package/dist/mcp/state.js +97 -0
- package/dist/mcp/state.js.map +1 -0
- package/dist/mcp/types.d.ts +139 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +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 +30 -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 +3 -0
- package/dist/onboarding/om-settings.d.ts +47 -0
- package/dist/onboarding/om-settings.d.ts.map +1 -0
- package/dist/onboarding/om-settings.js +83 -0
- package/dist/onboarding/om-settings.js.map +1 -0
- package/dist/onboarding/pack-activation.d.ts +52 -0
- package/dist/onboarding/pack-activation.d.ts.map +1 -0
- package/dist/onboarding/pack-activation.js +108 -0
- package/dist/onboarding/pack-activation.js.map +1 -0
- package/dist/onboarding/packs.d.ts +102 -0
- package/dist/onboarding/packs.d.ts.map +1 -0
- package/dist/onboarding/packs.js +278 -0
- package/dist/onboarding/packs.js.map +1 -0
- package/dist/onboarding/settings.d.ts +538 -0
- package/dist/onboarding/settings.d.ts.map +1 -0
- package/dist/onboarding/settings.js +1060 -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 +142 -0
- package/dist/permissions.js.map +1 -0
- package/dist/plugin.d.ts +156 -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/dependencies.d.ts +9 -0
- package/dist/plugins/dependencies.d.ts.map +1 -0
- package/dist/plugins/dependencies.js +87 -0
- package/dist/plugins/dependencies.js.map +1 -0
- package/dist/plugins/install.d.ts +21 -0
- package/dist/plugins/install.d.ts.map +1 -0
- package/dist/plugins/install.js +190 -0
- package/dist/plugins/install.js.map +1 -0
- package/dist/plugins/loader.d.ts +19 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +260 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/manager.d.ts +98 -0
- package/dist/plugins/manager.d.ts.map +1 -0
- package/dist/plugins/manager.js +456 -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 +50 -0
- package/dist/plugins/manifest.js.map +1 -0
- package/dist/plugins/package-link.d.ts +3 -0
- package/dist/plugins/package-link.d.ts.map +1 -0
- package/dist/plugins/package-link.js +61 -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 +25 -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 +112 -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 +116 -0
- package/dist/plugins/scaffold.js.map +1 -0
- package/dist/plugins/signal-lane.d.ts +58 -0
- package/dist/plugins/signal-lane.d.ts.map +1 -0
- package/dist/plugins/signal-lane.js +166 -0
- package/dist/plugins/signal-lane.js.map +1 -0
- package/dist/plugins/types.d.ts +81 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +1 -0
- package/dist/process-memory-diagnostics.d.ts +135 -0
- package/dist/process-memory-diagnostics.d.ts.map +1 -0
- package/dist/process-memory-diagnostics.js +499 -0
- package/dist/process-memory-diagnostics.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 +54 -0
- package/dist/processors/plan-rejection-abort.js.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.js +144 -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 +102 -0
- package/dist/providers/amazon-bedrock.js.map +1 -0
- package/dist/providers/anthropic-prompt-cache.d.ts +19 -0
- package/dist/providers/anthropic-prompt-cache.d.ts.map +1 -0
- package/dist/providers/anthropic-prompt-cache.js +11 -0
- package/dist/providers/anthropic-prompt-cache.js.map +1 -0
- package/dist/providers/anthropic-thinking.d.ts +5 -0
- package/dist/providers/anthropic-thinking.d.ts.map +1 -0
- package/dist/providers/anthropic-thinking.js +25 -0
- package/dist/providers/anthropic-thinking.js.map +1 -0
- package/dist/providers/claude-max.d.ts +67 -0
- package/dist/providers/claude-max.d.ts.map +1 -0
- package/dist/providers/claude-max.js +226 -0
- package/dist/providers/claude-max.js.map +1 -0
- package/dist/providers/github-copilot-gateway.d.ts +35 -0
- package/dist/providers/github-copilot-gateway.d.ts.map +1 -0
- package/dist/providers/github-copilot-gateway.js +61 -0
- package/dist/providers/github-copilot-gateway.js.map +1 -0
- package/dist/providers/github-copilot.d.ts +60 -0
- package/dist/providers/github-copilot.d.ts.map +1 -0
- package/dist/providers/github-copilot.js +318 -0
- package/dist/providers/github-copilot.js.map +1 -0
- package/dist/providers/google-thinking.d.ts +31 -0
- package/dist/providers/google-thinking.d.ts.map +1 -0
- package/dist/providers/google-thinking.js +67 -0
- package/dist/providers/google-thinking.js.map +1 -0
- package/dist/providers/kimi-coding.d.ts +14 -0
- package/dist/providers/kimi-coding.d.ts.map +1 -0
- package/dist/providers/kimi-coding.js +78 -0
- package/dist/providers/kimi-coding.js.map +1 -0
- package/dist/providers/model-ids.d.ts +30 -0
- package/dist/providers/model-ids.d.ts.map +1 -0
- package/dist/providers/model-ids.js +79 -0
- package/dist/providers/model-ids.js.map +1 -0
- package/dist/providers/openai-codex.d.ts +84 -0
- package/dist/providers/openai-codex.d.ts.map +1 -0
- package/dist/providers/openai-codex.js +347 -0
- package/dist/providers/openai-codex.js.map +1 -0
- package/dist/providers/provider-thinking.d.ts +23 -0
- package/dist/providers/provider-thinking.d.ts.map +1 -0
- package/dist/providers/provider-thinking.js +64 -0
- package/dist/providers/provider-thinking.js.map +1 -0
- package/dist/providers/thinking-request.d.ts +14 -0
- package/dist/providers/thinking-request.d.ts.map +1 -0
- package/dist/providers/thinking-request.js +90 -0
- package/dist/providers/thinking-request.js.map +1 -0
- package/dist/providers/xai.d.ts +33 -0
- package/dist/providers/xai.d.ts.map +1 -0
- package/dist/providers/xai.js +71 -0
- package/dist/providers/xai.js.map +1 -0
- package/dist/schedules/index.d.ts +10 -0
- package/dist/schedules/index.d.ts.map +1 -0
- package/dist/schedules/index.js +6 -0
- package/dist/schedules/interval.d.ts +49 -0
- package/dist/schedules/interval.d.ts.map +1 -0
- package/dist/schedules/interval.js +215 -0
- package/dist/schedules/interval.js.map +1 -0
- package/dist/schedules/prompt.d.ts +36 -0
- package/dist/schedules/prompt.d.ts.map +1 -0
- package/dist/schedules/prompt.js +39 -0
- package/dist/schedules/prompt.js.map +1 -0
- package/dist/schedules/run-script.d.ts +8 -0
- package/dist/schedules/run-script.d.ts.map +1 -0
- package/dist/schedules/run-script.js +83 -0
- package/dist/schedules/run-script.js.map +1 -0
- package/dist/schedules/scheduler.d.ts +101 -0
- package/dist/schedules/scheduler.d.ts.map +1 -0
- package/dist/schedules/scheduler.js +169 -0
- package/dist/schedules/scheduler.js.map +1 -0
- package/dist/schedules/tools.d.ts +57 -0
- package/dist/schedules/tools.d.ts.map +1 -0
- package/dist/schedules/tools.js +220 -0
- package/dist/schedules/tools.js.map +1 -0
- package/dist/schema.d.ts +499 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +134 -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 +21 -0
- package/dist/theme-palette.js.map +1 -0
- package/dist/thinking-catalog.d.ts +4 -0
- package/dist/thinking-catalog.d.ts.map +1 -0
- package/dist/thinking-catalog.js +13 -0
- package/dist/thinking-catalog.js.map +1 -0
- package/dist/thinking.d.ts +37 -0
- package/dist/thinking.d.ts.map +1 -0
- package/dist/thinking.js +137 -0
- package/dist/thinking.js.map +1 -0
- package/dist/tool-names.d.ts +77 -0
- package/dist/tool-names.d.ts.map +1 -0
- package/dist/tool-names.js +56 -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 +3 -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 +80 -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 +32 -0
- package/dist/tools/utils.js.map +1 -0
- package/dist/tools/web-search.d.ts +114 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +155 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tools/workflows/create-workflow.d.ts +7 -0
- package/dist/tools/workflows/create-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/create-workflow.js +81 -0
- package/dist/tools/workflows/create-workflow.js.map +1 -0
- package/dist/tools/workflows/delete-workflow.d.ts +7 -0
- package/dist/tools/workflows/delete-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/delete-workflow.js +21 -0
- package/dist/tools/workflows/delete-workflow.js.map +1 -0
- package/dist/tools/workflows/ephemeral-memory.d.ts +28 -0
- package/dist/tools/workflows/ephemeral-memory.d.ts.map +1 -0
- package/dist/tools/workflows/ephemeral-memory.js +44 -0
- package/dist/tools/workflows/ephemeral-memory.js.map +1 -0
- package/dist/tools/workflows/extract-json-schema.d.ts +12 -0
- package/dist/tools/workflows/extract-json-schema.d.ts.map +1 -0
- package/dist/tools/workflows/extract-json-schema.js +22 -0
- package/dist/tools/workflows/extract-json-schema.js.map +1 -0
- package/dist/tools/workflows/get-workflow.d.ts +11 -0
- package/dist/tools/workflows/get-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/get-workflow.js +34 -0
- package/dist/tools/workflows/get-workflow.js.map +1 -0
- package/dist/tools/workflows/list-available-agents.d.ts +8 -0
- package/dist/tools/workflows/list-available-agents.d.ts.map +1 -0
- package/dist/tools/workflows/list-available-agents.js +32 -0
- package/dist/tools/workflows/list-available-agents.js.map +1 -0
- package/dist/tools/workflows/list-available-classifiers.d.ts +19 -0
- package/dist/tools/workflows/list-available-classifiers.d.ts.map +1 -0
- package/dist/tools/workflows/list-available-classifiers.js +56 -0
- package/dist/tools/workflows/list-available-classifiers.js.map +1 -0
- package/dist/tools/workflows/list-available-tools.d.ts +9 -0
- package/dist/tools/workflows/list-available-tools.d.ts.map +1 -0
- package/dist/tools/workflows/list-available-tools.js +40 -0
- package/dist/tools/workflows/list-available-tools.js.map +1 -0
- package/dist/tools/workflows/list-available-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-available-workflows.d.ts.map +1 -0
- package/dist/tools/workflows/list-available-workflows.js +32 -0
- package/dist/tools/workflows/list-available-workflows.js.map +1 -0
- package/dist/tools/workflows/list-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-workflows.d.ts.map +1 -0
- package/dist/tools/workflows/list-workflows.js +33 -0
- package/dist/tools/workflows/list-workflows.js.map +1 -0
- package/dist/tools/workflows/run-workflow.d.ts +9 -0
- package/dist/tools/workflows/run-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/run-workflow.js +52 -0
- package/dist/tools/workflows/run-workflow.js.map +1 -0
- package/dist/tools/workflows/save-workflow.d.ts +1125 -0
- package/dist/tools/workflows/save-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/save-workflow.js +28 -0
- package/dist/tools/workflows/save-workflow.js.map +1 -0
- package/dist/tools/workflows/tool-ids.d.ts +16 -0
- package/dist/tools/workflows/tool-ids.d.ts.map +1 -0
- package/dist/tools/workflows/tool-ids.js +20 -0
- package/dist/tools/workflows/tool-ids.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 +78 -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 +59 -0
- package/dist/utils/debug-log.js.map +1 -0
- package/dist/utils/discarding-scores-storage.d.ts +33 -0
- package/dist/utils/discarding-scores-storage.d.ts.map +1 -0
- package/dist/utils/discarding-scores-storage.js +54 -0
- package/dist/utils/discarding-scores-storage.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 +196 -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 +61 -0
- package/dist/utils/gateway-sync.js.map +1 -0
- package/dist/utils/maintenance-lock.d.ts +42 -0
- package/dist/utils/maintenance-lock.d.ts.map +1 -0
- package/dist/utils/maintenance-lock.js +199 -0
- package/dist/utils/maintenance-lock.js.map +1 -0
- package/dist/utils/notification-dispatch.d.ts +59 -0
- package/dist/utils/notification-dispatch.d.ts.map +1 -0
- package/dist/utils/notification-dispatch.js +109 -0
- package/dist/utils/notification-dispatch.js.map +1 -0
- package/dist/utils/open-url.d.ts +10 -0
- package/dist/utils/open-url.d.ts.map +1 -0
- package/dist/utils/open-url.js +30 -0
- package/dist/utils/open-url.js.map +1 -0
- package/dist/utils/path-security.d.ts +2 -0
- package/dist/utils/path-security.d.ts.map +1 -0
- package/dist/utils/path-security.js +10 -0
- package/dist/utils/path-security.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 +62 -0
- package/dist/utils/plan-diff.js.map +1 -0
- package/dist/utils/plans.d.ts +59 -0
- package/dist/utils/plans.d.ts.map +1 -0
- package/dist/utils/plans.js +117 -0
- package/dist/utils/plans.js.map +1 -0
- package/dist/utils/project.d.ts +160 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +364 -0
- package/dist/utils/project.js.map +1 -0
- package/dist/utils/prune-cli.d.ts +24 -0
- package/dist/utils/prune-cli.d.ts.map +1 -0
- package/dist/utils/prune-cli.js +125 -0
- package/dist/utils/prune-cli.js.map +1 -0
- package/dist/utils/signals-pubsub.d.ts +101 -0
- package/dist/utils/signals-pubsub.d.ts.map +1 -0
- package/dist/utils/signals-pubsub.js +410 -0
- package/dist/utils/signals-pubsub.js.map +1 -0
- package/dist/utils/slash-command-loader.d.ts +52 -0
- package/dist/utils/slash-command-loader.d.ts.map +1 -0
- package/dist/utils/slash-command-loader.js +142 -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 +109 -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 +96 -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 +121 -0
- package/dist/utils/storage-factory.js.map +1 -0
- package/dist/utils/storage-maintenance.d.ts +121 -0
- package/dist/utils/storage-maintenance.d.ts.map +1 -0
- package/dist/utils/storage-maintenance.js +355 -0
- package/dist/utils/storage-maintenance.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 +112 -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 +151 -0
- package/dist/utils/update-check.d.ts.map +1 -0
- package/dist/utils/update-check.js +432 -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 +144 -0
- package/dist/voice/stt-registry.js.map +1 -0
- package/dist/workflows/register-primitives.d.ts +52 -0
- package/dist/workflows/register-primitives.d.ts.map +1 -0
- package/dist/workflows/register-primitives.js +40 -0
- package/dist/workflows/register-primitives.js.map +1 -0
- package/dist/workflows/service.d.ts +64 -0
- package/dist/workflows/service.d.ts.map +1 -0
- package/dist/workflows/service.js +53 -0
- package/dist/workflows/service.js.map +1 -0
- package/package.json +107 -0
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SignalProvider } from "@mastra/core/signals";
|
|
2
|
+
import { createTool } from "@mastra/core/tools";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { RequestContext } from "@mastra/core/di";
|
|
5
|
+
//#region src/plugin.ts
|
|
6
|
+
async function writeToolProgress(context, progress) {
|
|
7
|
+
const toolCallId = context?.agent?.toolCallId;
|
|
8
|
+
if (!toolCallId) return;
|
|
9
|
+
const chunk = {
|
|
10
|
+
type: "data-mastracode-tool-progress",
|
|
11
|
+
data: {
|
|
12
|
+
toolCallId,
|
|
13
|
+
progress
|
|
14
|
+
},
|
|
15
|
+
transient: true
|
|
16
|
+
};
|
|
17
|
+
const outputWriter = context.agent?.outputWriter;
|
|
18
|
+
if (outputWriter) {
|
|
19
|
+
await outputWriter(chunk);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
await context.writer?.custom(chunk);
|
|
23
|
+
}
|
|
24
|
+
function defineMastraCodePlugin(plugin) {
|
|
25
|
+
return plugin;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { RequestContext, SignalProvider, createTool, defineMastraCodePlugin, writeToolProgress, z };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import type { AgentController, Session } from '@mastra/core/agent-controller';\nimport type { InputProcessor, OutputProcessor } from '@mastra/core/processors';\nimport type { SignalProvider } from '@mastra/core/signals';\nimport type { MastraCompositeStore } from '@mastra/core/storage';\nimport type { Tool, ToolAction, ToolExecutionContext } from '@mastra/core/tools';\nimport type { MastraVector } from '@mastra/core/vector';\n\nimport type { MastraCodeState } from './schema.js';\n\nexport { createTool } from '@mastra/core/tools';\nexport { RequestContext } from '@mastra/core/di';\nexport type { InputProcessor, OutputProcessor } from '@mastra/core/processors';\nexport { SignalProvider } from '@mastra/core/signals';\nexport type { SignalProviderTarget, SignalSubscription } from '@mastra/core/signals';\nexport type { Tool, ToolAction, ToolExecutionContext } from '@mastra/core/tools';\nexport { z } from 'zod';\n\nexport type MastraCodeToolRenderConfig = {\n type: 'subagent';\n agentType?: string;\n modelId?: string;\n forked?: boolean;\n label?: string;\n maxActivityLines?: number;\n collapsedLines?: number;\n colors?: {\n border?: string;\n label?: string;\n agentType?: string;\n icon?: string;\n };\n icons?: {\n running?: string;\n success?: string;\n error?: string;\n };\n};\n\nexport type MastraCodeSubagentProgress =\n | {\n event: 'text';\n text: string;\n }\n | {\n event: 'tool_start';\n toolName: string;\n args?: unknown;\n }\n | {\n event: 'tool_end';\n toolName: string;\n result?: unknown;\n isError?: boolean;\n }\n | {\n event: 'finish';\n isError?: boolean;\n durationMs?: number;\n result?: string;\n };\n\nexport type MastraCodeToolProgress = string | { status?: string; detail?: string } | MastraCodeSubagentProgress;\n\nexport async function writeToolProgress(\n context: Pick<ToolExecutionContext, 'writer' | 'agent'> | undefined,\n progress: MastraCodeToolProgress,\n): Promise<void> {\n const toolCallId = context?.agent?.toolCallId;\n if (!toolCallId) return;\n\n const chunk = {\n type: 'data-mastracode-tool-progress',\n data: {\n toolCallId,\n progress,\n },\n transient: true,\n } as const;\n\n const outputWriter = (context.agent as { outputWriter?: (chunk: unknown) => Promise<void> } | undefined)\n ?.outputWriter;\n if (outputWriter) {\n await outputWriter(chunk);\n return;\n }\n\n await context.writer?.custom(chunk);\n}\n\nexport type MastraCodePluginConfigValue = string | boolean | undefined;\n\nexport type MastraCodePluginConfigOption = {\n type: 'model' | 'boolean' | 'string';\n label?: string;\n description?: string;\n default?: string | boolean;\n};\n\nexport type MastraCodePluginConfigSchema = Record<string, MastraCodePluginConfigOption>;\nexport type MastraCodePluginConfigValues = Record<string, MastraCodePluginConfigValue>;\n\n/** The running Mastra Code controller, as seen by a plugin. */\nexport type MastraCodePluginController = AgentController<MastraCodeState>;\n\n/** The session a plugin's contributions are running alongside. */\nexport type MastraCodePluginSession = Session<MastraCodeState>;\n\n/**\n * Lazy accessors for Mastra Code's runtime, handed to every plugin field resolver.\n *\n * Plugins are loaded before the controller and the session exist, so these are\n * accessors rather than instances: call them at the moment you need the value,\n * never during plugin load. Both return `undefined` until Mastra Code has\n * constructed the corresponding object.\n *\n * @experimental This is an evolving runtime API. It currently exposes the whole\n * controller so real plugins can be built against it; once we know what plugin\n * authors actually reach for, it may narrow to a smaller facade in a future\n * release.\n */\nexport type MastraCodePluginRuntime = {\n /**\n * The running controller, or `undefined` when it does not exist yet.\n * @experimental see {@link MastraCodePluginRuntime}\n */\n getController?: () => MastraCodePluginController | undefined;\n /**\n * The active session, or `undefined` before one has been created.\n * @experimental see {@link MastraCodePluginRuntime}\n */\n getActiveSession?: () => MastraCodePluginSession | undefined;\n /**\n * Borrow the host's persistence when booting a nested controller. Do not close\n * these instances or run storage maintenance on them; the host owns their lifetime.\n * Opening the same SQLite files with a plugin-local native library is unsafe.\n */\n getStorage?: () => {\n storage: MastraCompositeStore;\n storageBackend: 'libsql' | 'pg';\n vector?: MastraVector;\n };\n};\n\nexport type MastraCodePluginContext = MastraCodePluginRuntime & {\n cwd: string;\n scope: 'global' | 'project';\n pluginDir: string;\n config: MastraCodePluginConfigValues;\n};\n\nexport type MastraCodePluginTool = Tool | ToolAction<any, any, any, any, any, any, any>;\n\nexport type MastraCodePluginToolEntry = {\n tool: MastraCodePluginTool;\n render?: MastraCodeToolRenderConfig;\n};\n\nexport type MastraCodePluginTools = Record<string, MastraCodePluginTool>;\nexport type MastraCodePluginToolEntries = Record<string, MastraCodePluginToolEntry>;\nexport type MastraCodePluginInstructions = string | ((context: MastraCodePluginContext) => string | Promise<string>);\n\n/**\n * Processors a plugin contributes, split by lane.\n *\n * A bare array is shorthand for `{ input: [...] }`, since input processors are\n * the common case. Plugin processors run last in Mastra Code's own configured\n * processors — after the layers they customize, before the channel and memory\n * layers the agent appends. That slot is fixed and not configurable.\n */\nexport type MastraCodePluginProcessorEntries =\n | InputProcessor[]\n | {\n input?: InputProcessor[];\n output?: OutputProcessor[];\n };\n\n/**\n * Signal providers a plugin contributes.\n *\n * Mastra Code owns their lifecycle: it registers Mastra on them, connects them\n * to the coding agent, starts them polling, and stops them when the plugin is\n * updated, disabled or removed. Their `getInputProcessors()` /\n * `getOutputProcessors()` feed the same lanes as {@link MastraCodePluginProcessorEntries}.\n *\n * Note that `getTools()` is **ignored** for plugin-provided providers — inject\n * tools from inside a processor instead.\n */\nexport type MastraCodePluginSignalProviderEntries = SignalProvider<string>[];\n\nexport type MastraCodePlugin = {\n id: string;\n name?: string;\n version?: string;\n description?: string;\n config?: MastraCodePluginConfigSchema;\n instructions?: MastraCodePluginInstructions;\n tools?:\n | MastraCodePluginToolEntries\n | ((context: MastraCodePluginContext) => MastraCodePluginToolEntries | Promise<MastraCodePluginToolEntries>);\n processors?:\n | MastraCodePluginProcessorEntries\n | ((\n context: MastraCodePluginContext,\n ) => MastraCodePluginProcessorEntries | Promise<MastraCodePluginProcessorEntries>);\n signalProviders?:\n | MastraCodePluginSignalProviderEntries\n | ((\n context: MastraCodePluginContext,\n ) => MastraCodePluginSignalProviderEntries | Promise<MastraCodePluginSignalProviderEntries>);\n};\n\nexport function defineMastraCodePlugin<TPlugin extends MastraCodePlugin>(plugin: TPlugin): TPlugin {\n return plugin;\n}\n"],"mappings":";;;;;AA+DA,eAAsB,kBACpB,SACA,UACe;CACf,MAAM,aAAa,SAAS,OAAO;CACnC,IAAI,CAAC,YAAY;CAEjB,MAAM,QAAQ;EACZ,MAAM;EACN,MAAM;GACJ;GACA;EACF;EACA,WAAW;CACb;CAEA,MAAM,eAAgB,QAAQ,OAC1B;CACJ,IAAI,cAAc;EAChB,MAAM,aAAa,KAAK;EACxB;CACF;CAEA,MAAM,QAAQ,QAAQ,OAAO,KAAK;AACpC;AA4HA,SAAgB,uBAAyD,QAA0B;CACjG,OAAO;AACT"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type PluginInstallExecutionOptions = {
|
|
2
|
+
onOutput?: (chunk: Buffer | string) => void;
|
|
3
|
+
signal?: AbortSignal;
|
|
4
|
+
};
|
|
5
|
+
export declare function installPluginDependencies(pluginRoot: string, commandRoot?: string, options?: PluginInstallExecutionOptions): Promise<boolean>;
|
|
6
|
+
export declare function installPluginDependenciesForEntry(pluginRoot: string, entry: string, options?: PluginInstallExecutionOptions): Promise<void>;
|
|
7
|
+
export declare function getPluginDependencyRoots(pluginRoot: string, entry: string): string[];
|
|
8
|
+
export declare function getEntryPackageRoot(pluginRoot: string, entry: string): string;
|
|
9
|
+
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../src/plugins/dependencies.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,6BAA6B,GAAG;IAC1C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;IAC5C,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,EAClB,WAAW,SAAa,EACxB,OAAO,GAAE,6BAAkC,GAC1C,OAAO,CAAC,OAAO,CAAC,CAqClB;AAED,wBAAsB,iCAAiC,CACrD,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,6BAAkC,GAC1C,OAAO,CAAC,IAAI,CAAC,CAIf;AAED,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAOpF;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7E"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
//#region src/plugins/dependencies.ts
|
|
5
|
+
async function installPluginDependencies(pluginRoot, commandRoot = pluginRoot, options = {}) {
|
|
6
|
+
const packageJsonPath = path.join(pluginRoot, "package.json");
|
|
7
|
+
if (!fs.existsSync(packageJsonPath)) return false;
|
|
8
|
+
const packageJson = readPackageJson(pluginRoot);
|
|
9
|
+
const commandPackageJson = commandRoot === pluginRoot ? packageJson : readPackageJson(commandRoot);
|
|
10
|
+
const installCommand = getInstallCommand(pluginRoot, getPnpmSpec(pluginRoot, Object.hasOwn(packageJson, "packageManager") ? packageJson.packageManager : commandPackageJson.packageManager));
|
|
11
|
+
const child = execa(installCommand.command, installCommand.args, {
|
|
12
|
+
cwd: pluginRoot,
|
|
13
|
+
env: {
|
|
14
|
+
...process.env,
|
|
15
|
+
GIT_TERMINAL_PROMPT: "0"
|
|
16
|
+
},
|
|
17
|
+
stdout: options.onOutput ? "pipe" : "ignore",
|
|
18
|
+
stderr: options.onOutput ? "pipe" : "ignore",
|
|
19
|
+
cancelSignal: options.signal
|
|
20
|
+
});
|
|
21
|
+
if (options.onOutput) {
|
|
22
|
+
child.stdout?.on("data", options.onOutput);
|
|
23
|
+
child.stderr?.on("data", options.onOutput);
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
await child;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
if (isCommandNotFoundError(error)) throw new Error("Mastra Code requires Corepack to install GitHub plugin dependencies. Install it with \"npm install --global corepack\" and try again.", { cause: error });
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
async function installPluginDependenciesForEntry(pluginRoot, entry, options = {}) {
|
|
34
|
+
for (const dependencyRoot of getPluginDependencyRoots(pluginRoot, entry)) await installPluginDependencies(dependencyRoot, pluginRoot, options);
|
|
35
|
+
}
|
|
36
|
+
function getPluginDependencyRoots(pluginRoot, entry) {
|
|
37
|
+
const roots = fs.existsSync(path.join(pluginRoot, "package.json")) ? [pluginRoot] : [];
|
|
38
|
+
const entryPackageRoot = findEntryPackageRoot(pluginRoot, entry);
|
|
39
|
+
if (entryPackageRoot && entryPackageRoot !== pluginRoot) roots.push(entryPackageRoot);
|
|
40
|
+
return roots;
|
|
41
|
+
}
|
|
42
|
+
function getEntryPackageRoot(pluginRoot, entry) {
|
|
43
|
+
return findEntryPackageRoot(pluginRoot, entry) ?? pluginRoot;
|
|
44
|
+
}
|
|
45
|
+
function findEntryPackageRoot(pluginRoot, entry) {
|
|
46
|
+
const root = path.resolve(pluginRoot);
|
|
47
|
+
let current = path.dirname(path.resolve(pluginRoot, entry));
|
|
48
|
+
while (isInsideDirectory(current, root)) {
|
|
49
|
+
if (fs.existsSync(path.join(current, "package.json"))) return current;
|
|
50
|
+
if (current === root) break;
|
|
51
|
+
current = path.dirname(current);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function isInsideDirectory(targetPath, root) {
|
|
55
|
+
const resolvedTarget = path.resolve(targetPath);
|
|
56
|
+
const resolvedRoot = path.resolve(root);
|
|
57
|
+
return resolvedTarget === resolvedRoot || resolvedTarget.startsWith(resolvedRoot + path.sep);
|
|
58
|
+
}
|
|
59
|
+
const PNPM_SPEC_PATTERN = /^pnpm@\d+\.\d+\.\d+(?:\+sha(?:1|224|256|384|512)\.[0-9a-f]+)?$/;
|
|
60
|
+
function getPnpmSpec(pluginRoot, packageManager) {
|
|
61
|
+
if (typeof packageManager !== "string" || !PNPM_SPEC_PATTERN.test(packageManager)) throw new Error(`Plugin at ${pluginRoot} must declare an exact pnpm version in package.json using "packageManager": "pnpm@x.y.z".`);
|
|
62
|
+
return packageManager;
|
|
63
|
+
}
|
|
64
|
+
function getInstallCommand(pluginRoot, pnpmSpec) {
|
|
65
|
+
const installArgs = ["install", "--ignore-workspace"];
|
|
66
|
+
if (hasFile(pluginRoot, "pnpm-lock.yaml")) installArgs.push("--frozen-lockfile");
|
|
67
|
+
installArgs.push("--ignore-scripts");
|
|
68
|
+
return {
|
|
69
|
+
command: "corepack",
|
|
70
|
+
args: [pnpmSpec, ...installArgs]
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function isCommandNotFoundError(error) {
|
|
74
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
75
|
+
}
|
|
76
|
+
function readPackageJson(pluginRoot) {
|
|
77
|
+
const packageJsonPath = path.join(pluginRoot, "package.json");
|
|
78
|
+
if (!fs.existsSync(packageJsonPath)) return {};
|
|
79
|
+
return JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
80
|
+
}
|
|
81
|
+
function hasFile(pluginRoot, fileName) {
|
|
82
|
+
return fs.existsSync(path.join(pluginRoot, fileName));
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { getEntryPackageRoot, getPluginDependencyRoots, installPluginDependencies, installPluginDependenciesForEntry };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.js","names":[],"sources":["../../src/plugins/dependencies.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { execa } from 'execa';\n\ntype InstallCommand = {\n command: string;\n args: string[];\n};\n\nexport type PluginInstallExecutionOptions = {\n onOutput?: (chunk: Buffer | string) => void;\n signal?: AbortSignal;\n};\n\nexport async function installPluginDependencies(\n pluginRoot: string,\n commandRoot = pluginRoot,\n options: PluginInstallExecutionOptions = {},\n): Promise<boolean> {\n const packageJsonPath = path.join(pluginRoot, 'package.json');\n if (!fs.existsSync(packageJsonPath)) {\n return false;\n }\n\n const packageJson = readPackageJson(pluginRoot);\n const commandPackageJson = commandRoot === pluginRoot ? packageJson : readPackageJson(commandRoot);\n const packageManager = Object.hasOwn(packageJson, 'packageManager')\n ? packageJson.packageManager\n : commandPackageJson.packageManager;\n const pnpmSpec = getPnpmSpec(pluginRoot, packageManager);\n const installCommand = getInstallCommand(pluginRoot, pnpmSpec);\n\n const child = execa(installCommand.command, installCommand.args, {\n cwd: pluginRoot,\n env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },\n stdout: options.onOutput ? 'pipe' : 'ignore',\n stderr: options.onOutput ? 'pipe' : 'ignore',\n cancelSignal: options.signal,\n });\n if (options.onOutput) {\n child.stdout?.on('data', options.onOutput);\n child.stderr?.on('data', options.onOutput);\n }\n try {\n await child;\n } catch (error) {\n if (isCommandNotFoundError(error)) {\n throw new Error(\n 'Mastra Code requires Corepack to install GitHub plugin dependencies. Install it with \"npm install --global corepack\" and try again.',\n { cause: error },\n );\n }\n throw error;\n }\n return true;\n}\n\nexport async function installPluginDependenciesForEntry(\n pluginRoot: string,\n entry: string,\n options: PluginInstallExecutionOptions = {},\n): Promise<void> {\n for (const dependencyRoot of getPluginDependencyRoots(pluginRoot, entry)) {\n await installPluginDependencies(dependencyRoot, pluginRoot, options);\n }\n}\n\nexport function getPluginDependencyRoots(pluginRoot: string, entry: string): string[] {\n const roots = fs.existsSync(path.join(pluginRoot, 'package.json')) ? [pluginRoot] : [];\n const entryPackageRoot = findEntryPackageRoot(pluginRoot, entry);\n if (entryPackageRoot && entryPackageRoot !== pluginRoot) {\n roots.push(entryPackageRoot);\n }\n return roots;\n}\n\nexport function getEntryPackageRoot(pluginRoot: string, entry: string): string {\n return findEntryPackageRoot(pluginRoot, entry) ?? pluginRoot;\n}\n\nfunction findEntryPackageRoot(pluginRoot: string, entry: string): string | undefined {\n const root = path.resolve(pluginRoot);\n let current = path.dirname(path.resolve(pluginRoot, entry));\n\n while (isInsideDirectory(current, root)) {\n if (fs.existsSync(path.join(current, 'package.json'))) {\n return current;\n }\n if (current === root) break;\n current = path.dirname(current);\n }\n\n return undefined;\n}\n\nfunction 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\n// Accepts the optional Corepack integrity suffix (e.g. `+sha512.<hex>`) written by `corepack use`.\nconst PNPM_SPEC_PATTERN = /^pnpm@\\d+\\.\\d+\\.\\d+(?:\\+sha(?:1|224|256|384|512)\\.[0-9a-f]+)?$/;\n\nfunction getPnpmSpec(pluginRoot: string, packageManager: unknown): string {\n if (typeof packageManager !== 'string' || !PNPM_SPEC_PATTERN.test(packageManager)) {\n throw new Error(\n `Plugin at ${pluginRoot} must declare an exact pnpm version in package.json using \"packageManager\": \"pnpm@x.y.z\".`,\n );\n }\n return packageManager;\n}\n\nfunction getInstallCommand(pluginRoot: string, pnpmSpec: string): InstallCommand {\n const installArgs = ['install', '--ignore-workspace'];\n if (hasFile(pluginRoot, 'pnpm-lock.yaml')) installArgs.push('--frozen-lockfile');\n installArgs.push('--ignore-scripts');\n\n return {\n command: 'corepack',\n args: [pnpmSpec, ...installArgs],\n };\n}\n\nfunction isCommandNotFoundError(error: unknown): boolean {\n return typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT';\n}\n\nfunction readPackageJson(pluginRoot: string): { packageManager?: unknown } {\n const packageJsonPath = path.join(pluginRoot, 'package.json');\n if (!fs.existsSync(packageJsonPath)) return {};\n return JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) as { packageManager?: unknown };\n}\n\nfunction hasFile(pluginRoot: string, fileName: string): boolean {\n return fs.existsSync(path.join(pluginRoot, fileName));\n}\n"],"mappings":";;;;AAeA,eAAsB,0BACpB,YACA,cAAc,YACd,UAAyC,CAAC,GACxB;CAClB,MAAM,kBAAkB,KAAK,KAAK,YAAY,cAAc;CAC5D,IAAI,CAAC,GAAG,WAAW,eAAe,GAChC,OAAO;CAGT,MAAM,cAAc,gBAAgB,UAAU;CAC9C,MAAM,qBAAqB,gBAAgB,aAAa,cAAc,gBAAgB,WAAW;CAKjG,MAAM,iBAAiB,kBAAkB,YADxB,YAAY,YAHN,OAAO,OAAO,aAAa,gBAAgB,IAC9D,YAAY,iBACZ,mBAAmB,cAEqC,CAAC;CAE7D,MAAM,QAAQ,MAAM,eAAe,SAAS,eAAe,MAAM;EAC/D,KAAK;EACL,KAAK;GAAE,GAAG,QAAQ;GAAK,qBAAqB;EAAI;EAChD,QAAQ,QAAQ,WAAW,SAA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CACtC,OAAO,mBAAmB,gBAAgB,eAAe,WAAW,eAAe,KAAK,GAAG;AAC7F;AAGA,MAAM,oBAAoB;AAE1B,SAAS,YAAY,YAAoB,gBAAiC;CACxE,IAAI,OAAO,mBAAmB,YAAY,CAAC,kBAAkB,KAAK,cAAc,GAC9E,MAAM,IAAI,MACR,aAAa,WAAW,0FAC1B;CAEF,OAAO;AACT;AAEA,SAAS,kBAAkB,YAAoB,UAAkC;CAC/E,MAAM,cAAc,CAAC,WAAW,oBAAoB;CACpD,IAAI,QAAQ,YAAY,gBAAgB,GAAG,YAAY,KAAK,mBAAmB;CAC/E,YAAY,KAAK,kBAAkB;CAEnC,OAAO;EACL,SAAS;EACT,MAAM,CAAC,UAAU,GAAG,WAAW;CACjC;AACF;AAEA,SAAS,uBAAuB,OAAyB;CACvD,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,MAAM,SAAS;AAC1F;AAEA,SAAS,gBAAgB,YAAkD;CACzE,MAAM,kBAAkB,KAAK,KAAK,YAAY,cAAc;CAC5D,IAAI,CAAC,GAAG,WAAW,eAAe,GAAG,OAAO,CAAC;CAC7C,OAAO,KAAK,MAAM,GAAG,aAAa,iBAAiB,MAAM,CAAC;AAC5D;AAEA,SAAS,QAAQ,YAAoB,UAA2B;CAC9D,OAAO,GAAG,WAAW,KAAK,KAAK,YAAY,QAAQ,CAAC;AACtD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PluginInstallExecutionOptions } from './dependencies.js';
|
|
2
|
+
import type { PluginPathOptions } from './paths.js';
|
|
3
|
+
import type { PluginScope } from './types.js';
|
|
4
|
+
export type InstallPluginOptions = PluginPathOptions & PluginInstallExecutionOptions & {
|
|
5
|
+
entry?: string;
|
|
6
|
+
ref?: string;
|
|
7
|
+
githubCliPath?: string;
|
|
8
|
+
};
|
|
9
|
+
export type DiscoveredLocalPlugin = {
|
|
10
|
+
name: string;
|
|
11
|
+
path: string;
|
|
12
|
+
entry: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const NON_INTERACTIVE_GIT_ENV: {
|
|
15
|
+
GIT_TERMINAL_PROMPT: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function installLocalPlugin(localPath: string, scope: PluginScope, options: InstallPluginOptions): Promise<string>;
|
|
18
|
+
export declare function installGithubPlugin(url: string, scope: PluginScope, options: InstallPluginOptions): Promise<string>;
|
|
19
|
+
export declare function discoverLocalPlugins(searchRoot: string, options: PluginPathOptions): DiscoveredLocalPlugin[];
|
|
20
|
+
export declare function detectEntry(pluginDir: string, explicitEntry?: string): string;
|
|
21
|
+
//# sourceMappingURL=install.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/plugins/install.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAKvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,KAAK,EAAyB,WAAW,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,GAClD,6BAA6B,GAAG;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEJ,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAIF,eAAO,MAAM,uBAAuB;;CAA+C,CAAC;AAIpF,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAsBjB;AAED,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAyCjB;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,qBAAqB,EAAE,CAa5G;AA2BD,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAiC7E"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import "../constants.js";
|
|
2
|
+
import { getEntryPackageRoot, installPluginDependenciesForEntry } from "./dependencies.js";
|
|
3
|
+
import { getPluginRoot, getPluginScopePaths } from "./paths.js";
|
|
4
|
+
import { loadPluginRegistry, removePluginRecord, savePluginRegistry, setPluginRecord } from "./registry.js";
|
|
5
|
+
import { loadPluginFromEntry } from "./loader.js";
|
|
6
|
+
import { getSingleManifestPlugin } from "./manifest.js";
|
|
7
|
+
import { ensureMastraCodePackageLink } from "./package-link.js";
|
|
8
|
+
import path from "path";
|
|
9
|
+
import fs from "fs";
|
|
10
|
+
import { execa } from "execa";
|
|
11
|
+
//#region src/plugins/install.ts
|
|
12
|
+
const ENTRY_CANDIDATES = ["src/index.ts", "index.ts"];
|
|
13
|
+
const NON_INTERACTIVE_GIT_ENV = {
|
|
14
|
+
...process.env,
|
|
15
|
+
GIT_TERMINAL_PROMPT: "0"
|
|
16
|
+
};
|
|
17
|
+
const NON_INTERACTIVE_EXEC_OPTIONS = { env: NON_INTERACTIVE_GIT_ENV };
|
|
18
|
+
async function installLocalPlugin(localPath, scope, options) {
|
|
19
|
+
const sourcePath = path.resolve(options.projectRoot, localPath);
|
|
20
|
+
if (!fs.existsSync(sourcePath) || !fs.statSync(sourcePath).isDirectory()) throw new Error(`Local plugin path does not exist or is not a directory: ${localPath}`);
|
|
21
|
+
const entry = detectEntry(sourcePath, options.entry);
|
|
22
|
+
ensureMastraCodePackageLink(sourcePath);
|
|
23
|
+
const plugin = await loadPluginFromEntry(path.join(sourcePath, entry));
|
|
24
|
+
const registryPath = getPluginScopePaths(scope, options).registryPath;
|
|
25
|
+
const registry = removePluginRecord(loadPluginRegistry(registryPath), plugin.id);
|
|
26
|
+
const record = {
|
|
27
|
+
enabled: true,
|
|
28
|
+
source: "local",
|
|
29
|
+
specifier: localPath,
|
|
30
|
+
path: sourcePath,
|
|
31
|
+
entry,
|
|
32
|
+
...plugin.version ? { version: plugin.version } : {}
|
|
33
|
+
};
|
|
34
|
+
savePluginRegistry(registryPath, setPluginRecord(registry, plugin.id, record));
|
|
35
|
+
return plugin.id;
|
|
36
|
+
}
|
|
37
|
+
async function installGithubPlugin(url, scope, options) {
|
|
38
|
+
const parsed = parseGithubUrl(url);
|
|
39
|
+
const paths = getPluginScopePaths(scope, options);
|
|
40
|
+
const checkoutDir = path.join(paths.sourcesPath, "github", `${parsed.owner}-${parsed.repo}`);
|
|
41
|
+
const githubCli = options.githubCliPath ?? "gh";
|
|
42
|
+
await assertGithubCliAvailable(githubCli);
|
|
43
|
+
await assertGithubCliAuthenticated(githubCli);
|
|
44
|
+
fs.rmSync(checkoutDir, {
|
|
45
|
+
recursive: true,
|
|
46
|
+
force: true
|
|
47
|
+
});
|
|
48
|
+
fs.mkdirSync(path.dirname(checkoutDir), { recursive: true });
|
|
49
|
+
const ref = options.ref ?? parsed.ref;
|
|
50
|
+
await runPluginInstallCommand(githubCli, [
|
|
51
|
+
"repo",
|
|
52
|
+
"clone",
|
|
53
|
+
parsed.repoSpec,
|
|
54
|
+
checkoutDir,
|
|
55
|
+
...ref ? [] : [
|
|
56
|
+
"--",
|
|
57
|
+
"--depth",
|
|
58
|
+
"1"
|
|
59
|
+
]
|
|
60
|
+
], { env: NON_INTERACTIVE_GIT_ENV }, options);
|
|
61
|
+
if (ref) await runPluginInstallCommand("git", ["checkout", ref], {
|
|
62
|
+
cwd: checkoutDir,
|
|
63
|
+
env: NON_INTERACTIVE_GIT_ENV
|
|
64
|
+
}, options);
|
|
65
|
+
const entry = detectEntry(checkoutDir, options.entry);
|
|
66
|
+
await installPluginDependenciesForEntry(checkoutDir, entry, options);
|
|
67
|
+
ensureMastraCodePackageLink(getEntryPackageRoot(checkoutDir, entry));
|
|
68
|
+
const plugin = await loadPluginFromEntry(path.join(checkoutDir, entry));
|
|
69
|
+
const registry = removePluginRecord(loadPluginRegistry(paths.registryPath), plugin.id);
|
|
70
|
+
const record = {
|
|
71
|
+
enabled: true,
|
|
72
|
+
source: "github",
|
|
73
|
+
specifier: url,
|
|
74
|
+
path: path.relative(getPluginRoot(scope, options), checkoutDir),
|
|
75
|
+
entry,
|
|
76
|
+
...ref ? { ref } : {},
|
|
77
|
+
...plugin.version ? { version: plugin.version } : {}
|
|
78
|
+
};
|
|
79
|
+
savePluginRegistry(paths.registryPath, setPluginRecord(registry, plugin.id, record));
|
|
80
|
+
return plugin.id;
|
|
81
|
+
}
|
|
82
|
+
function discoverLocalPlugins(searchRoot, options) {
|
|
83
|
+
const root = path.resolve(options.projectRoot, searchRoot);
|
|
84
|
+
const localSourcesRoot = path.join(root, options.configDir ?? ".mastracode", "plugins", "sources", "local");
|
|
85
|
+
const scanRoot = isLocalSourcesDir(root) ? root : localSourcesRoot;
|
|
86
|
+
const seen = /* @__PURE__ */ new Set();
|
|
87
|
+
return discoverPluginDirs(scanRoot).filter((candidate) => {
|
|
88
|
+
if (seen.has(candidate.path)) return false;
|
|
89
|
+
seen.add(candidate.path);
|
|
90
|
+
return true;
|
|
91
|
+
}).sort((a, b) => a.name.localeCompare(b.name));
|
|
92
|
+
}
|
|
93
|
+
function isLocalSourcesDir(dir) {
|
|
94
|
+
return dir.split(path.sep).join("/").endsWith("/plugins/sources/local");
|
|
95
|
+
}
|
|
96
|
+
function discoverPluginDirs(root) {
|
|
97
|
+
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) return [];
|
|
98
|
+
return fs.readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).flatMap((entry) => {
|
|
99
|
+
const pluginDir = path.join(root, entry.name);
|
|
100
|
+
const detectedEntry = tryDetectEntry(pluginDir);
|
|
101
|
+
return detectedEntry ? [{
|
|
102
|
+
name: entry.name,
|
|
103
|
+
path: pluginDir,
|
|
104
|
+
entry: detectedEntry
|
|
105
|
+
}] : [];
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function tryDetectEntry(pluginDir) {
|
|
109
|
+
try {
|
|
110
|
+
return detectEntry(pluginDir);
|
|
111
|
+
} catch {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function detectEntry(pluginDir, explicitEntry) {
|
|
116
|
+
const root = path.resolve(pluginDir);
|
|
117
|
+
if (explicitEntry) {
|
|
118
|
+
const entryPath = path.resolve(pluginDir, explicitEntry);
|
|
119
|
+
if (!isInsideDirectory(entryPath, root)) throw new Error("Plugin entry must be inside the plugin directory");
|
|
120
|
+
if (fs.existsSync(entryPath) && fs.statSync(entryPath).isDirectory()) {
|
|
121
|
+
const nestedEntry = detectEntry(entryPath);
|
|
122
|
+
return path.relative(root, path.join(entryPath, nestedEntry));
|
|
123
|
+
}
|
|
124
|
+
if (path.extname(entryPath) !== ".ts") throw new Error("Plugin entry must be a .ts file");
|
|
125
|
+
if (!fs.existsSync(entryPath) || !fs.statSync(entryPath).isFile()) throw new Error(`Plugin entry file does not exist: ${explicitEntry}`);
|
|
126
|
+
return path.relative(root, entryPath);
|
|
127
|
+
}
|
|
128
|
+
const manifestPlugin = getSingleManifestPlugin(pluginDir);
|
|
129
|
+
if (manifestPlugin) return detectEntry(pluginDir, manifestPlugin.entry);
|
|
130
|
+
for (const candidate of ENTRY_CANDIDATES) {
|
|
131
|
+
const entryPath = path.join(pluginDir, candidate);
|
|
132
|
+
if (fs.existsSync(entryPath) && fs.statSync(entryPath).isFile()) return candidate;
|
|
133
|
+
}
|
|
134
|
+
throw new Error(`Could not find a plugin entry file. Tried: ${ENTRY_CANDIDATES.join(", ")}`);
|
|
135
|
+
}
|
|
136
|
+
function isInsideDirectory(targetPath, root) {
|
|
137
|
+
return targetPath === root || targetPath.startsWith(root + path.sep);
|
|
138
|
+
}
|
|
139
|
+
async function runPluginInstallCommand(command, args, execaOptions, options) {
|
|
140
|
+
const child = execa(command, args, {
|
|
141
|
+
...execaOptions,
|
|
142
|
+
stdout: options.onOutput ? "pipe" : "ignore",
|
|
143
|
+
stderr: options.onOutput ? "pipe" : "ignore",
|
|
144
|
+
cancelSignal: options.signal
|
|
145
|
+
});
|
|
146
|
+
if (options.onOutput) {
|
|
147
|
+
child.stdout?.on("data", options.onOutput);
|
|
148
|
+
child.stderr?.on("data", options.onOutput);
|
|
149
|
+
}
|
|
150
|
+
await child;
|
|
151
|
+
}
|
|
152
|
+
async function assertGithubCliAvailable(githubCli) {
|
|
153
|
+
try {
|
|
154
|
+
await execa(githubCli, ["--version"], NON_INTERACTIVE_EXEC_OPTIONS);
|
|
155
|
+
} catch {
|
|
156
|
+
throw new Error("GitHub CLI is required to install GitHub plugins. Install gh and run gh auth login.");
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async function assertGithubCliAuthenticated(githubCli) {
|
|
160
|
+
try {
|
|
161
|
+
await execa(githubCli, ["auth", "status"], NON_INTERACTIVE_EXEC_OPTIONS);
|
|
162
|
+
} catch {
|
|
163
|
+
throw new Error("GitHub CLI is not authenticated. Run gh auth login, then install the plugin again.");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function parseGithubUrl(specifier) {
|
|
167
|
+
const [urlPart, ref] = specifier.split("#", 2);
|
|
168
|
+
if (!urlPart) throw new Error(`Invalid GitHub URL: ${specifier}`);
|
|
169
|
+
let url;
|
|
170
|
+
try {
|
|
171
|
+
url = new URL(urlPart);
|
|
172
|
+
} catch {
|
|
173
|
+
throw new Error(`Invalid GitHub URL: ${specifier}`);
|
|
174
|
+
}
|
|
175
|
+
if (url.hostname !== "github.com") throw new Error("Only github.com plugin URLs are supported");
|
|
176
|
+
const [owner, rawRepo, ...rest] = url.pathname.split("/").filter(Boolean);
|
|
177
|
+
if (!owner || !rawRepo || rest.length > 0) throw new Error("GitHub plugin URL must be in the form https://github.com/owner/repo");
|
|
178
|
+
const repo = rawRepo.replace(/\.git$/, "");
|
|
179
|
+
if (!/^[A-Za-z0-9_.-]+$/.test(owner) || !/^[A-Za-z0-9_.-]+$/.test(repo)) throw new Error("GitHub owner and repo may only contain letters, numbers, dots, underscores, and dashes");
|
|
180
|
+
return {
|
|
181
|
+
owner,
|
|
182
|
+
repo,
|
|
183
|
+
repoSpec: `${owner}/${repo}`,
|
|
184
|
+
...ref ? { ref } : {}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
export { NON_INTERACTIVE_GIT_ENV, detectEntry, discoverLocalPlugins, installGithubPlugin, installLocalPlugin };
|
|
189
|
+
|
|
190
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.js","names":[],"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 { getEntryPackageRoot, installPluginDependenciesForEntry } from './dependencies.js';\nimport type { PluginInstallExecutionOptions } from './dependencies.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 PluginInstallExecutionOptions & {\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 const ref = options.ref ?? parsed.ref;\n const cloneArgs = ['repo', 'clone', parsed.repoSpec, checkoutDir, ...(ref ? [] : ['--', '--depth', '1'])];\n await runPluginInstallCommand(githubCli, cloneArgs, { env: NON_INTERACTIVE_GIT_ENV }, options);\n if (ref) {\n await runPluginInstallCommand(\n 'git',\n ['checkout', ref],\n { cwd: checkoutDir, env: NON_INTERACTIVE_GIT_ENV },\n options,\n );\n }\n\n const entry = detectEntry(checkoutDir, options.entry);\n await installPluginDependenciesForEntry(checkoutDir, entry, options);\n ensureMastraCodePackageLink(getEntryPackageRoot(checkoutDir, entry));\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 runPluginInstallCommand(\n command: string,\n args: string[],\n execaOptions: typeof NON_INTERACTIVE_EXEC_OPTIONS & { cwd?: string },\n options: PluginInstallExecutionOptions,\n): Promise<void> {\n const child = execa(command, args, {\n ...execaOptions,\n stdout: options.onOutput ? 'pipe' : 'ignore',\n stderr: options.onOutput ? 'pipe' : 'ignore',\n cancelSignal: options.signal,\n });\n if (options.onOutput) {\n child.stdout?.on('data', options.onOutput);\n child.stderr?.on('data', options.onOutput);\n }\n await child;\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":";;;;;;;;;;;AA6BA,MAAM,mBAAmB,CAAC,gBAAgB,UAAU;AAEpD,MAAa,0BAA0B;CAAE,GAAG,QAAQ;CAAK,qBAAqB;AAAI;AAElF,MAAM,+BAA+B,EAAE,KAAK,wBAAwB;AAEpE,eAAsB,mBACpB,WACA,OACA,SACiB;CACjB,MAAM,aAAa,KAAK,QAAQ,QAAQ,aAAa,SAAS;CAC9D,IAAI,CAAC,GAAG,WAAW,UAAU,KAAK,CAAC,GAAG,SAAS,UAAU,CAAC,CAAC,YAAY,GACrE,MAAM,IAAI,MAAM,2DAA2D,WAAW;CAGxF,MAAM,QAAQ,YAAY,YAAY,QAAQ,KAAK;CACnD,4BAA4B,U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,MAAM,OAAO,QAAQ,QAAQ,UAAU,EAAE;CACzC,IAAI,CAAC,oBAAoB,KAAK,KAAK,KAAK,CAAC,oBAAoB,KAAK,IAAI,GACpE,MAAM,IAAI,MAAM,wFAAwF;CAG1G,OAAO;EACL;EACA;EACA,UAAU,GAAG,MAAM,GAAG;EACtB,GAAI,MAAM,EAAE,IAAI,IAAI,CAAC;CACvB;AACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MastraCodePlugin, MastraCodePluginRuntime, MastraCodePluginTools } from '../plugin.js';
|
|
2
|
+
import type { PluginPathOptions } from './paths.js';
|
|
3
|
+
import type { LoadedPlugin, PluginRegistry, ScopedInstalledPluginRecord } from './types.js';
|
|
4
|
+
export type LoadPluginRecordOptions = PluginPathOptions & {
|
|
5
|
+
/** Lazy accessors for Mastra Code's runtime, passed on to plugin field resolvers. */
|
|
6
|
+
runtime?: MastraCodePluginRuntime;
|
|
7
|
+
};
|
|
8
|
+
export type LoadPluginsOptions = LoadPluginRecordOptions & {
|
|
9
|
+
globalRegistry?: PluginRegistry;
|
|
10
|
+
projectRegistry?: PluginRegistry;
|
|
11
|
+
};
|
|
12
|
+
export declare function loadPlugins(options: LoadPluginsOptions): Promise<LoadedPlugin[]>;
|
|
13
|
+
export declare function loadPluginRecord(record: ScopedInstalledPluginRecord, options: LoadPluginRecordOptions): Promise<LoadedPlugin>;
|
|
14
|
+
export declare function loadPluginFromEntry(entryPath: string): Promise<MastraCodePlugin>;
|
|
15
|
+
export declare function resolvePluginRoot(record: ScopedInstalledPluginRecord, options: PluginPathOptions): string;
|
|
16
|
+
export declare function resolvePluginEntryPath(record: ScopedInstalledPluginRecord, options: PluginPathOptions): string;
|
|
17
|
+
export declare function isInsideDirectory(targetPath: string, root: string): boolean;
|
|
18
|
+
export declare function collectActivePluginTools(plugins: LoadedPlugin[]): MastraCodePluginTools;
|
|
19
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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