@mastra/code-sdk 1.21.0-alpha.5 → 1.21.0-alpha.7
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/dist/acp/agent.js +0 -2
- package/dist/acp/errors.js +0 -2
- package/dist/acp/event-mapper.js +0 -2
- package/dist/acp/index.js +0 -2
- package/dist/acp/runtime.js +0 -2
- package/dist/acp/server.js +0 -2
- package/dist/acp/skills.js +0 -2
- package/dist/agent-connections/messaging-processor.js +0 -2
- package/dist/agent-connections/ownership.js +0 -2
- package/dist/agent-connections/registry.js +0 -2
- package/dist/agent-connections/session-advertisement.js +0 -2
- package/dist/agent-connections/signal-provider.js +0 -2
- package/dist/agent-connections/state-processor.js +0 -2
- package/dist/agent-connections/thread-state.js +0 -2
- package/dist/agent-connections/tools.js +0 -2
- package/dist/agent-connections/types.js +0 -2
- package/dist/agent-connections/untrusted-text.js +0 -2
- package/dist/agents/background-completion-events.js +0 -2
- package/dist/agents/background-completion.js +0 -2
- package/dist/agents/context-audit.js +0 -2
- package/dist/agents/credential-resolver.js +0 -2
- package/dist/agents/custom-provider-source.js +0 -2
- package/dist/agents/fastembed-subprocess.d.ts +21 -0
- package/dist/agents/fastembed-subprocess.js +88 -8
- package/dist/agents/instructions.js +0 -2
- package/dist/agents/mastracode-gateway.js +0 -2
- package/dist/agents/memory.js +0 -2
- package/dist/agents/model.js +0 -2
- package/dist/agents/modes/build.js +0 -2
- package/dist/agents/modes/explore.js +0 -2
- package/dist/agents/modes/plan.js +0 -2
- package/dist/agents/prompts/agent-instructions.js +0 -2
- package/dist/agents/prompts/build.js +0 -2
- package/dist/agents/prompts/fast.js +0 -2
- package/dist/agents/prompts/index.js +0 -2
- package/dist/agents/prompts/model.js +0 -2
- package/dist/agents/prompts/plan.js +0 -2
- package/dist/agents/prompts/tool-guidance.js +0 -2
- package/dist/agents/sandbox-filesystem.js +0 -2
- package/dist/agents/subagents/execute.js +0 -2
- package/dist/agents/subagents/explore.js +0 -2
- package/dist/agents/subagents/index.js +0 -2
- package/dist/agents/subagents/plan.js +0 -2
- package/dist/agents/thread-caveman-state.js +0 -2
- package/dist/agents/tool-availability.js +0 -2
- package/dist/agents/tools.js +0 -2
- package/dist/agents/workflow-builder-agent.js +0 -2
- package/dist/agents/workspace.js +0 -2
- package/dist/analytics.js +0 -2
- package/dist/auth/account-rotation-processor.js +0 -2
- package/dist/auth/account-routing-context.js +0 -2
- package/dist/auth/authorization-input.js +0 -2
- package/dist/auth/device-code.js +0 -2
- package/dist/auth/pkce.js +0 -2
- package/dist/auth/provider-auth-error.js +0 -2
- package/dist/auth/providers/anthropic.js +0 -2
- package/dist/auth/providers/github-copilot.js +0 -2
- package/dist/auth/providers/kimi-coding.js +0 -2
- package/dist/auth/providers/openai-codex.js +0 -2
- package/dist/auth/providers/xai.js +0 -2
- package/dist/auth/storage.js +0 -2
- package/dist/clipboard/index.js +0 -2
- package/dist/constants.js +0 -2
- package/dist/error-classification.js +0 -2
- package/dist/evals/context-builder.js +0 -2
- package/dist/evals/scorers/classify-command.js +0 -2
- package/dist/evals/scorers/efficiency.js +0 -2
- package/dist/evals/scorers/extract-tools.js +0 -2
- package/dist/evals/scorers/outcome.js +0 -2
- package/dist/experimental-agent.js +0 -2
- package/dist/factory/client.js +0 -2
- package/dist/factory/remote-controller.js +0 -2
- package/dist/factory/remote-session.js +0 -2
- package/dist/goal-manager.js +0 -2
- package/dist/goal-signal.js +0 -2
- package/dist/headless/cli.js +5 -2
- package/dist/headless/flags.js +0 -2
- package/dist/headless/format.js +0 -2
- package/dist/headless/policy.js +0 -2
- package/dist/headless/run-mc.js +0 -2
- package/dist/headless/types.js +0 -2
- package/dist/hooks/config.js +0 -2
- package/dist/hooks/executor.js +0 -2
- package/dist/hooks/manager.js +0 -2
- package/dist/hooks/types.js +0 -2
- package/dist/index.js +0 -2
- package/dist/ipc/ipc-reporter.js +0 -2
- package/dist/knowledge-inspector.js +0 -2
- package/dist/knowledge-scope-id.js +0 -2
- package/dist/knowledge-scope.js +0 -2
- package/dist/lsp/client.js +0 -2
- package/dist/lsp/language.js +0 -2
- package/dist/lsp/manager.js +0 -2
- package/dist/lsp/server.js +0 -2
- package/dist/lsp/workspace.js +0 -2
- package/dist/mcp/config.js +0 -2
- package/dist/mcp/manager.js +0 -2
- package/dist/mcp/state.js +0 -2
- package/dist/onboarding/custom-packs.js +0 -2
- package/dist/onboarding/custom-providers.js +0 -2
- package/dist/onboarding/om-settings.js +0 -2
- package/dist/onboarding/pack-activation.js +0 -2
- package/dist/onboarding/packs.js +0 -2
- package/dist/onboarding/settings.js +0 -2
- package/dist/permissions.js +0 -2
- package/dist/platform/index.js +0 -2
- package/dist/plugin.js +0 -2
- package/dist/plugins/dependencies.js +0 -2
- package/dist/plugins/install.js +0 -2
- package/dist/plugins/loader.js +0 -2
- package/dist/plugins/manager.js +0 -2
- package/dist/plugins/manifest.js +0 -2
- package/dist/plugins/package-link.js +0 -2
- package/dist/plugins/paths.js +0 -2
- package/dist/plugins/registry.js +0 -2
- package/dist/plugins/scaffold.js +0 -2
- package/dist/plugins/signal-lane.js +0 -2
- package/dist/process-memory-diagnostics.js +0 -2
- package/dist/processors/plan-rejection-abort.js +0 -2
- package/dist/providers/amazon-bedrock-gateway.js +0 -2
- package/dist/providers/amazon-bedrock.js +0 -2
- package/dist/providers/anthropic-prompt-cache.js +0 -2
- package/dist/providers/anthropic-thinking.js +0 -2
- package/dist/providers/claude-max.js +0 -2
- package/dist/providers/github-copilot-gateway.js +0 -2
- package/dist/providers/github-copilot.js +0 -2
- package/dist/providers/google-thinking.js +0 -2
- package/dist/providers/google-vertex-gateway.js +0 -2
- package/dist/providers/google-vertex.js +0 -2
- package/dist/providers/kimi-coding.js +0 -2
- package/dist/providers/model-ids.js +0 -2
- package/dist/providers/openai-codex.js +0 -2
- package/dist/providers/provider-thinking.js +0 -2
- package/dist/providers/thinking-request.js +0 -2
- package/dist/providers/xai.js +0 -2
- package/dist/schedules/interval.js +0 -2
- package/dist/schedules/prompt.js +0 -2
- package/dist/schedules/run-script.js +0 -2
- package/dist/schedules/scheduler.js +0 -2
- package/dist/schedules/tools.js +0 -2
- package/dist/schema.js +0 -2
- package/dist/theme-palette.js +0 -2
- package/dist/thinking-catalog.js +0 -2
- package/dist/thinking.js +0 -2
- package/dist/tool-names.js +0 -2
- package/dist/tools/request-sandbox-access.js +0 -2
- package/dist/tools/utils.js +0 -2
- package/dist/tools/web-search.js +0 -2
- package/dist/tools/workflows/create-workflow.js +0 -2
- package/dist/tools/workflows/delete-workflow.js +0 -2
- package/dist/tools/workflows/ephemeral-memory.js +0 -2
- package/dist/tools/workflows/extract-json-schema.js +0 -2
- package/dist/tools/workflows/get-workflow.js +0 -2
- package/dist/tools/workflows/list-available-agents.js +0 -2
- package/dist/tools/workflows/list-available-classifiers.js +0 -2
- package/dist/tools/workflows/list-available-tools.js +0 -2
- package/dist/tools/workflows/list-available-workflows.js +0 -2
- package/dist/tools/workflows/list-workflows.js +0 -2
- package/dist/tools/workflows/run-workflow.js +0 -2
- package/dist/tools/workflows/save-workflow.js +0 -2
- package/dist/tools/workflows/tool-ids.js +0 -2
- package/dist/utils/binaries.js +0 -2
- package/dist/utils/debug-log.js +0 -2
- package/dist/utils/discarding-scores-storage.js +0 -2
- package/dist/utils/errors.js +0 -2
- package/dist/utils/gateway-sync.js +0 -2
- package/dist/utils/local-observability.js +0 -2
- package/dist/utils/maintenance-lock.js +0 -2
- package/dist/utils/notification-dispatch.js +0 -2
- package/dist/utils/open-url.js +0 -2
- package/dist/utils/path-security.js +0 -2
- package/dist/utils/plan-diff.js +0 -2
- package/dist/utils/plans.js +0 -2
- package/dist/utils/project.js +0 -2
- package/dist/utils/prune-cli.js +0 -2
- package/dist/utils/signals-pubsub.js +0 -2
- package/dist/utils/slash-command-loader.js +0 -2
- package/dist/utils/slash-command-processor.js +0 -2
- package/dist/utils/stdin-pipe.js +0 -2
- package/dist/utils/storage-factory.js +0 -2
- package/dist/utils/storage-maintenance.js +0 -2
- package/dist/utils/thread-lock.js +0 -2
- package/dist/utils/token-estimator.js +0 -2
- package/dist/utils/update-check.js +0 -2
- package/dist/utils/wake-session.js +0 -2
- package/dist/voice/stt-registry.js +0 -2
- package/dist/voice/transcribe.js +0 -2
- package/dist/workflows/register-primitives.js +0 -2
- package/dist/workflows/service.js +0 -2
- package/package.json +22 -21
- package/dist/acp/agent.d.ts.map +0 -1
- package/dist/acp/agent.js.map +0 -1
- package/dist/acp/errors.d.ts.map +0 -1
- package/dist/acp/errors.js.map +0 -1
- package/dist/acp/event-mapper.d.ts.map +0 -1
- package/dist/acp/event-mapper.js.map +0 -1
- package/dist/acp/index.d.ts.map +0 -1
- package/dist/acp/index.js.map +0 -1
- package/dist/acp/runtime.d.ts.map +0 -1
- package/dist/acp/runtime.js.map +0 -1
- package/dist/acp/server.d.ts.map +0 -1
- package/dist/acp/server.js.map +0 -1
- package/dist/acp/skills.d.ts.map +0 -1
- package/dist/acp/skills.js.map +0 -1
- package/dist/acp.d.ts.map +0 -1
- package/dist/agent-connections/messaging-processor.d.ts.map +0 -1
- package/dist/agent-connections/messaging-processor.js.map +0 -1
- package/dist/agent-connections/ownership.d.ts.map +0 -1
- package/dist/agent-connections/ownership.js.map +0 -1
- package/dist/agent-connections/registry.d.ts.map +0 -1
- package/dist/agent-connections/registry.js.map +0 -1
- package/dist/agent-connections/session-advertisement.d.ts.map +0 -1
- package/dist/agent-connections/session-advertisement.js.map +0 -1
- package/dist/agent-connections/signal-provider.d.ts.map +0 -1
- package/dist/agent-connections/signal-provider.js.map +0 -1
- package/dist/agent-connections/state-processor.d.ts.map +0 -1
- package/dist/agent-connections/state-processor.js.map +0 -1
- package/dist/agent-connections/thread-state.d.ts.map +0 -1
- package/dist/agent-connections/thread-state.js.map +0 -1
- package/dist/agent-connections/tools.d.ts.map +0 -1
- package/dist/agent-connections/tools.js.map +0 -1
- package/dist/agent-connections/types.d.ts.map +0 -1
- package/dist/agent-connections/types.js.map +0 -1
- package/dist/agent-connections/untrusted-text.d.ts.map +0 -1
- package/dist/agent-connections/untrusted-text.js.map +0 -1
- package/dist/agents/background-completion-events.d.ts.map +0 -1
- package/dist/agents/background-completion-events.js.map +0 -1
- package/dist/agents/background-completion.d.ts.map +0 -1
- package/dist/agents/background-completion.js.map +0 -1
- package/dist/agents/context-audit.d.ts.map +0 -1
- package/dist/agents/context-audit.js.map +0 -1
- package/dist/agents/credential-resolver.d.ts.map +0 -1
- package/dist/agents/credential-resolver.js.map +0 -1
- package/dist/agents/custom-provider-source.d.ts.map +0 -1
- package/dist/agents/custom-provider-source.js.map +0 -1
- package/dist/agents/fastembed-subprocess.d.ts.map +0 -1
- package/dist/agents/fastembed-subprocess.js.map +0 -1
- package/dist/agents/instructions.d.ts.map +0 -1
- package/dist/agents/instructions.js.map +0 -1
- package/dist/agents/mastracode-gateway.d.ts.map +0 -1
- package/dist/agents/mastracode-gateway.js.map +0 -1
- package/dist/agents/memory.d.ts.map +0 -1
- package/dist/agents/memory.js.map +0 -1
- package/dist/agents/model.d.ts.map +0 -1
- package/dist/agents/model.js.map +0 -1
- package/dist/agents/modes/build.d.ts.map +0 -1
- package/dist/agents/modes/build.js.map +0 -1
- package/dist/agents/modes/explore.d.ts.map +0 -1
- package/dist/agents/modes/explore.js.map +0 -1
- package/dist/agents/modes/plan.d.ts.map +0 -1
- package/dist/agents/modes/plan.js.map +0 -1
- package/dist/agents/prompts/agent-instructions.d.ts.map +0 -1
- package/dist/agents/prompts/agent-instructions.js.map +0 -1
- package/dist/agents/prompts/build.d.ts.map +0 -1
- package/dist/agents/prompts/build.js.map +0 -1
- package/dist/agents/prompts/fast.d.ts.map +0 -1
- package/dist/agents/prompts/fast.js.map +0 -1
- package/dist/agents/prompts/index.d.ts.map +0 -1
- package/dist/agents/prompts/index.js.map +0 -1
- package/dist/agents/prompts/model.d.ts.map +0 -1
- package/dist/agents/prompts/model.js.map +0 -1
- package/dist/agents/prompts/plan.d.ts.map +0 -1
- package/dist/agents/prompts/plan.js.map +0 -1
- package/dist/agents/prompts/tool-guidance.d.ts.map +0 -1
- package/dist/agents/prompts/tool-guidance.js.map +0 -1
- package/dist/agents/sandbox-filesystem.d.ts.map +0 -1
- package/dist/agents/sandbox-filesystem.js.map +0 -1
- package/dist/agents/subagents/execute.d.ts.map +0 -1
- package/dist/agents/subagents/execute.js.map +0 -1
- package/dist/agents/subagents/explore.d.ts.map +0 -1
- package/dist/agents/subagents/explore.js.map +0 -1
- package/dist/agents/subagents/index.d.ts.map +0 -1
- package/dist/agents/subagents/index.js.map +0 -1
- package/dist/agents/subagents/plan.d.ts.map +0 -1
- package/dist/agents/subagents/plan.js.map +0 -1
- package/dist/agents/thread-caveman-state.d.ts.map +0 -1
- package/dist/agents/thread-caveman-state.js.map +0 -1
- package/dist/agents/tool-availability.d.ts.map +0 -1
- package/dist/agents/tool-availability.js.map +0 -1
- package/dist/agents/tools.d.ts.map +0 -1
- package/dist/agents/tools.js.map +0 -1
- package/dist/agents/workflow-builder-agent.d.ts.map +0 -1
- package/dist/agents/workflow-builder-agent.js.map +0 -1
- package/dist/agents/workspace.d.ts.map +0 -1
- package/dist/agents/workspace.js.map +0 -1
- package/dist/analytics.d.ts.map +0 -1
- package/dist/analytics.js.map +0 -1
- package/dist/auth/account-rotation-processor.d.ts.map +0 -1
- package/dist/auth/account-rotation-processor.js.map +0 -1
- package/dist/auth/account-routing-context.d.ts.map +0 -1
- package/dist/auth/account-routing-context.js.map +0 -1
- package/dist/auth/authorization-input.d.ts.map +0 -1
- package/dist/auth/authorization-input.js.map +0 -1
- package/dist/auth/device-code.d.ts.map +0 -1
- package/dist/auth/device-code.js.map +0 -1
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/pkce.d.ts.map +0 -1
- package/dist/auth/pkce.js.map +0 -1
- package/dist/auth/provider-auth-error.d.ts.map +0 -1
- package/dist/auth/provider-auth-error.js.map +0 -1
- package/dist/auth/providers/anthropic.d.ts.map +0 -1
- package/dist/auth/providers/anthropic.js.map +0 -1
- package/dist/auth/providers/github-copilot.d.ts.map +0 -1
- package/dist/auth/providers/github-copilot.js.map +0 -1
- package/dist/auth/providers/kimi-coding.d.ts.map +0 -1
- package/dist/auth/providers/kimi-coding.js.map +0 -1
- package/dist/auth/providers/openai-codex.d.ts.map +0 -1
- package/dist/auth/providers/openai-codex.js.map +0 -1
- package/dist/auth/providers/xai.d.ts.map +0 -1
- package/dist/auth/providers/xai.js.map +0 -1
- package/dist/auth/storage.d.ts.map +0 -1
- package/dist/auth/storage.js.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/clipboard/index.d.ts.map +0 -1
- package/dist/clipboard/index.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/error-classification.d.ts.map +0 -1
- package/dist/error-classification.js.map +0 -1
- package/dist/evals/context-builder.d.ts.map +0 -1
- package/dist/evals/context-builder.js.map +0 -1
- package/dist/evals/index.d.ts.map +0 -1
- package/dist/evals/scorers/classify-command.d.ts.map +0 -1
- package/dist/evals/scorers/classify-command.js.map +0 -1
- package/dist/evals/scorers/efficiency.d.ts.map +0 -1
- package/dist/evals/scorers/efficiency.js.map +0 -1
- package/dist/evals/scorers/extract-tools.d.ts.map +0 -1
- package/dist/evals/scorers/extract-tools.js.map +0 -1
- package/dist/evals/scorers/index.d.ts.map +0 -1
- package/dist/evals/scorers/outcome.d.ts.map +0 -1
- package/dist/evals/scorers/outcome.js.map +0 -1
- package/dist/experimental-agent.d.ts.map +0 -1
- package/dist/experimental-agent.js.map +0 -1
- package/dist/factory/client.d.ts.map +0 -1
- package/dist/factory/client.js.map +0 -1
- package/dist/factory/remote-controller.d.ts.map +0 -1
- package/dist/factory/remote-controller.js.map +0 -1
- package/dist/factory/remote-session.d.ts.map +0 -1
- package/dist/factory/remote-session.js.map +0 -1
- package/dist/goal-manager.d.ts.map +0 -1
- package/dist/goal-manager.js.map +0 -1
- package/dist/goal-signal.d.ts.map +0 -1
- package/dist/goal-signal.js.map +0 -1
- package/dist/headless/cli.d.ts.map +0 -1
- package/dist/headless/cli.js.map +0 -1
- package/dist/headless/flags.d.ts.map +0 -1
- package/dist/headless/flags.js.map +0 -1
- package/dist/headless/format.d.ts.map +0 -1
- package/dist/headless/format.js.map +0 -1
- package/dist/headless/index.d.ts.map +0 -1
- package/dist/headless/policy.d.ts.map +0 -1
- package/dist/headless/policy.js.map +0 -1
- package/dist/headless/run-mc.d.ts.map +0 -1
- package/dist/headless/run-mc.js.map +0 -1
- package/dist/headless/types.d.ts.map +0 -1
- package/dist/headless/types.js.map +0 -1
- package/dist/hooks/config.d.ts.map +0 -1
- package/dist/hooks/config.js.map +0 -1
- package/dist/hooks/executor.d.ts.map +0 -1
- package/dist/hooks/executor.js.map +0 -1
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/manager.d.ts.map +0 -1
- package/dist/hooks/manager.js.map +0 -1
- package/dist/hooks/types.d.ts.map +0 -1
- package/dist/hooks/types.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/ipc/ipc-reporter.d.ts.map +0 -1
- package/dist/ipc/ipc-reporter.js.map +0 -1
- package/dist/knowledge-inspector.d.ts.map +0 -1
- package/dist/knowledge-inspector.js.map +0 -1
- package/dist/knowledge-scope-id.d.ts.map +0 -1
- package/dist/knowledge-scope-id.js.map +0 -1
- package/dist/knowledge-scope.d.ts.map +0 -1
- package/dist/knowledge-scope.js.map +0 -1
- package/dist/lsp/client.d.ts.map +0 -1
- package/dist/lsp/client.js.map +0 -1
- package/dist/lsp/index.d.ts.map +0 -1
- package/dist/lsp/language.d.ts.map +0 -1
- package/dist/lsp/language.js.map +0 -1
- package/dist/lsp/manager.d.ts.map +0 -1
- package/dist/lsp/manager.js.map +0 -1
- package/dist/lsp/server.d.ts.map +0 -1
- package/dist/lsp/server.js.map +0 -1
- package/dist/lsp/workspace.d.ts.map +0 -1
- package/dist/lsp/workspace.js.map +0 -1
- package/dist/mcp/config.d.ts.map +0 -1
- package/dist/mcp/config.js.map +0 -1
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/manager.d.ts.map +0 -1
- package/dist/mcp/manager.js.map +0 -1
- package/dist/mcp/state.d.ts.map +0 -1
- package/dist/mcp/state.js.map +0 -1
- package/dist/mcp/types.d.ts.map +0 -1
- package/dist/onboarding/custom-packs.d.ts.map +0 -1
- package/dist/onboarding/custom-packs.js.map +0 -1
- package/dist/onboarding/custom-providers.d.ts.map +0 -1
- package/dist/onboarding/custom-providers.js.map +0 -1
- package/dist/onboarding/index.d.ts.map +0 -1
- package/dist/onboarding/om-settings.d.ts.map +0 -1
- package/dist/onboarding/om-settings.js.map +0 -1
- package/dist/onboarding/pack-activation.d.ts.map +0 -1
- package/dist/onboarding/pack-activation.js.map +0 -1
- package/dist/onboarding/packs.d.ts.map +0 -1
- package/dist/onboarding/packs.js.map +0 -1
- package/dist/onboarding/settings.d.ts.map +0 -1
- package/dist/onboarding/settings.js.map +0 -1
- package/dist/permissions.d.ts.map +0 -1
- package/dist/permissions.js.map +0 -1
- package/dist/platform/index.d.ts.map +0 -1
- package/dist/platform/index.js.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plugin.js.map +0 -1
- package/dist/plugins/dependencies.d.ts.map +0 -1
- package/dist/plugins/dependencies.js.map +0 -1
- package/dist/plugins/install.d.ts.map +0 -1
- package/dist/plugins/install.js.map +0 -1
- package/dist/plugins/loader.d.ts.map +0 -1
- package/dist/plugins/loader.js.map +0 -1
- package/dist/plugins/manager.d.ts.map +0 -1
- package/dist/plugins/manager.js.map +0 -1
- package/dist/plugins/manifest.d.ts.map +0 -1
- package/dist/plugins/manifest.js.map +0 -1
- package/dist/plugins/package-link.d.ts.map +0 -1
- package/dist/plugins/package-link.js.map +0 -1
- package/dist/plugins/paths.d.ts.map +0 -1
- package/dist/plugins/paths.js.map +0 -1
- package/dist/plugins/registry.d.ts.map +0 -1
- package/dist/plugins/registry.js.map +0 -1
- package/dist/plugins/scaffold.d.ts.map +0 -1
- package/dist/plugins/scaffold.js.map +0 -1
- package/dist/plugins/signal-lane.d.ts.map +0 -1
- package/dist/plugins/signal-lane.js.map +0 -1
- package/dist/plugins/types.d.ts.map +0 -1
- package/dist/process-memory-diagnostics.d.ts.map +0 -1
- package/dist/process-memory-diagnostics.js.map +0 -1
- package/dist/processors/plan-rejection-abort.d.ts.map +0 -1
- package/dist/processors/plan-rejection-abort.js.map +0 -1
- package/dist/providers/amazon-bedrock-gateway.d.ts.map +0 -1
- package/dist/providers/amazon-bedrock-gateway.js.map +0 -1
- package/dist/providers/amazon-bedrock.d.ts.map +0 -1
- package/dist/providers/amazon-bedrock.js.map +0 -1
- package/dist/providers/anthropic-prompt-cache.d.ts.map +0 -1
- package/dist/providers/anthropic-prompt-cache.js.map +0 -1
- package/dist/providers/anthropic-thinking.d.ts.map +0 -1
- package/dist/providers/anthropic-thinking.js.map +0 -1
- package/dist/providers/claude-max.d.ts.map +0 -1
- package/dist/providers/claude-max.js.map +0 -1
- package/dist/providers/github-copilot-gateway.d.ts.map +0 -1
- package/dist/providers/github-copilot-gateway.js.map +0 -1
- package/dist/providers/github-copilot.d.ts.map +0 -1
- package/dist/providers/github-copilot.js.map +0 -1
- package/dist/providers/google-thinking.d.ts.map +0 -1
- package/dist/providers/google-thinking.js.map +0 -1
- package/dist/providers/google-vertex-gateway.d.ts.map +0 -1
- package/dist/providers/google-vertex-gateway.js.map +0 -1
- package/dist/providers/google-vertex.d.ts.map +0 -1
- package/dist/providers/google-vertex.js.map +0 -1
- package/dist/providers/kimi-coding.d.ts.map +0 -1
- package/dist/providers/kimi-coding.js.map +0 -1
- package/dist/providers/model-ids.d.ts.map +0 -1
- package/dist/providers/model-ids.js.map +0 -1
- package/dist/providers/openai-codex.d.ts.map +0 -1
- package/dist/providers/openai-codex.js.map +0 -1
- package/dist/providers/provider-thinking.d.ts.map +0 -1
- package/dist/providers/provider-thinking.js.map +0 -1
- package/dist/providers/thinking-request.d.ts.map +0 -1
- package/dist/providers/thinking-request.js.map +0 -1
- package/dist/providers/xai.d.ts.map +0 -1
- package/dist/providers/xai.js.map +0 -1
- package/dist/schedules/index.d.ts.map +0 -1
- package/dist/schedules/interval.d.ts.map +0 -1
- package/dist/schedules/interval.js.map +0 -1
- package/dist/schedules/prompt.d.ts.map +0 -1
- package/dist/schedules/prompt.js.map +0 -1
- package/dist/schedules/run-script.d.ts.map +0 -1
- package/dist/schedules/run-script.js.map +0 -1
- package/dist/schedules/scheduler.d.ts.map +0 -1
- package/dist/schedules/scheduler.js.map +0 -1
- package/dist/schedules/tools.d.ts.map +0 -1
- package/dist/schedules/tools.js.map +0 -1
- package/dist/schema.d.ts.map +0 -1
- package/dist/schema.js.map +0 -1
- package/dist/theme-palette.d.ts.map +0 -1
- package/dist/theme-palette.js.map +0 -1
- package/dist/thinking-catalog.d.ts.map +0 -1
- package/dist/thinking-catalog.js.map +0 -1
- package/dist/thinking.d.ts.map +0 -1
- package/dist/thinking.js.map +0 -1
- package/dist/tool-names.d.ts.map +0 -1
- package/dist/tool-names.js.map +0 -1
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/request-sandbox-access.d.ts.map +0 -1
- package/dist/tools/request-sandbox-access.js.map +0 -1
- package/dist/tools/utils.d.ts.map +0 -1
- package/dist/tools/utils.js.map +0 -1
- package/dist/tools/web-search.d.ts.map +0 -1
- package/dist/tools/web-search.js.map +0 -1
- package/dist/tools/workflows/create-workflow.d.ts.map +0 -1
- package/dist/tools/workflows/create-workflow.js.map +0 -1
- package/dist/tools/workflows/delete-workflow.d.ts.map +0 -1
- package/dist/tools/workflows/delete-workflow.js.map +0 -1
- package/dist/tools/workflows/ephemeral-memory.d.ts.map +0 -1
- package/dist/tools/workflows/ephemeral-memory.js.map +0 -1
- package/dist/tools/workflows/extract-json-schema.d.ts.map +0 -1
- package/dist/tools/workflows/extract-json-schema.js.map +0 -1
- package/dist/tools/workflows/get-workflow.d.ts.map +0 -1
- package/dist/tools/workflows/get-workflow.js.map +0 -1
- package/dist/tools/workflows/list-available-agents.d.ts.map +0 -1
- package/dist/tools/workflows/list-available-agents.js.map +0 -1
- package/dist/tools/workflows/list-available-classifiers.d.ts.map +0 -1
- package/dist/tools/workflows/list-available-classifiers.js.map +0 -1
- package/dist/tools/workflows/list-available-tools.d.ts.map +0 -1
- package/dist/tools/workflows/list-available-tools.js.map +0 -1
- package/dist/tools/workflows/list-available-workflows.d.ts.map +0 -1
- package/dist/tools/workflows/list-available-workflows.js.map +0 -1
- package/dist/tools/workflows/list-workflows.d.ts.map +0 -1
- package/dist/tools/workflows/list-workflows.js.map +0 -1
- package/dist/tools/workflows/run-workflow.d.ts.map +0 -1
- package/dist/tools/workflows/run-workflow.js.map +0 -1
- package/dist/tools/workflows/save-workflow.d.ts.map +0 -1
- package/dist/tools/workflows/save-workflow.js.map +0 -1
- package/dist/tools/workflows/tool-ids.d.ts.map +0 -1
- package/dist/tools/workflows/tool-ids.js.map +0 -1
- package/dist/utils/binaries.d.ts.map +0 -1
- package/dist/utils/binaries.js.map +0 -1
- package/dist/utils/debug-log.d.ts.map +0 -1
- package/dist/utils/debug-log.js.map +0 -1
- package/dist/utils/discarding-scores-storage.d.ts.map +0 -1
- package/dist/utils/discarding-scores-storage.js.map +0 -1
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/gateway-sync.d.ts.map +0 -1
- package/dist/utils/gateway-sync.js.map +0 -1
- package/dist/utils/local-observability.d.ts.map +0 -1
- package/dist/utils/local-observability.js.map +0 -1
- package/dist/utils/maintenance-lock.d.ts.map +0 -1
- package/dist/utils/maintenance-lock.js.map +0 -1
- package/dist/utils/notification-dispatch.d.ts.map +0 -1
- package/dist/utils/notification-dispatch.js.map +0 -1
- package/dist/utils/open-url.d.ts.map +0 -1
- package/dist/utils/open-url.js.map +0 -1
- package/dist/utils/path-security.d.ts.map +0 -1
- package/dist/utils/path-security.js.map +0 -1
- package/dist/utils/plan-diff.d.ts.map +0 -1
- package/dist/utils/plan-diff.js.map +0 -1
- package/dist/utils/plans.d.ts.map +0 -1
- package/dist/utils/plans.js.map +0 -1
- package/dist/utils/project.d.ts.map +0 -1
- package/dist/utils/project.js.map +0 -1
- package/dist/utils/prune-cli.d.ts.map +0 -1
- package/dist/utils/prune-cli.js.map +0 -1
- package/dist/utils/signals-pubsub.d.ts.map +0 -1
- package/dist/utils/signals-pubsub.js.map +0 -1
- package/dist/utils/slash-command-loader.d.ts.map +0 -1
- package/dist/utils/slash-command-loader.js.map +0 -1
- package/dist/utils/slash-command-processor.d.ts.map +0 -1
- package/dist/utils/slash-command-processor.js.map +0 -1
- package/dist/utils/stdin-pipe.d.ts.map +0 -1
- package/dist/utils/stdin-pipe.js.map +0 -1
- package/dist/utils/storage-factory.d.ts.map +0 -1
- package/dist/utils/storage-factory.js.map +0 -1
- package/dist/utils/storage-maintenance.d.ts.map +0 -1
- package/dist/utils/storage-maintenance.js.map +0 -1
- package/dist/utils/thread-lock.d.ts.map +0 -1
- package/dist/utils/thread-lock.js.map +0 -1
- package/dist/utils/token-estimator.d.ts.map +0 -1
- package/dist/utils/token-estimator.js.map +0 -1
- package/dist/utils/update-check.d.ts.map +0 -1
- package/dist/utils/update-check.js.map +0 -1
- package/dist/utils/wake-session.d.ts.map +0 -1
- package/dist/utils/wake-session.js.map +0 -1
- package/dist/voice/stt-registry.d.ts.map +0 -1
- package/dist/voice/stt-registry.js.map +0 -1
- package/dist/voice/transcribe.d.ts.map +0 -1
- package/dist/voice/transcribe.js.map +0 -1
- package/dist/workflows/register-primitives.d.ts.map +0 -1
- package/dist/workflows/register-primitives.js.map +0 -1
- package/dist/workflows/service.d.ts.map +0 -1
- package/dist/workflows/service.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-search.d.ts","sourceRoot":"","sources":["../../src/tools/web-search.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAwB1E;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED,wEAAwE;AACxE,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB;;;;;;;;;;;oIA+BxC;AAED;;;GAGG;AACH,wBAAsB,oBAAoB;;;;;;qIAyBzC;AAED;;;GAGG;AACH,wBAAsB,2BAA2B;;oIAwBhD;AAED;;;GAGG;AACH,wBAAsB,4BAA4B;;;;;;;;;;;;;;qIAyBjD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,GAAE,wBAAiC,GAC5C,QAAQ,GAAG,UAAU,GAAG,SAAS,CAQnC;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAYvC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-search.js","names":[],"sources":["../../src/tools/web-search.ts"],"sourcesContent":["import { createTool, isValidationError } from '@mastra/core/tools';\nimport type { ValidationError } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport { loadSettings } from '../onboarding/settings.js';\nimport type { WebSearchProviderSetting } from '../onboarding/settings.js';\nimport { truncateStringForTokenEstimate } from '../utils/token-estimator.js';\n\nconst MAX_WEB_SEARCH_TOKENS = 2_000;\nconst MAX_WEB_EXTRACT_TOKENS = 2_000;\n\nconst MIN_RELEVANCE_SCORE = 0.25;\n\nconst parallelWebSearchInputSchema = z.object({\n query: z.string().min(1).describe('The search query'),\n});\n\nfunction requireParallelOutput<T>(output: T | ValidationError | void, operation: 'search' | 'extract'): T {\n if (output === undefined) {\n throw new Error(`Parallel ${operation} returned no output`);\n }\n\n if (isValidationError(output)) {\n throw new Error(output.message);\n }\n\n return output;\n}\n\n/**\n * Check whether a Tavily API key is available in the environment.\n * Used to select model-independent web tools before falling back to\n * model-native web search.\n */\nexport function hasTavilyKey(): boolean {\n return !!process.env.TAVILY_API_KEY;\n}\n\n/** Check whether a Parallel API key is available in the environment. */\nexport function hasParallelKey(): boolean {\n return !!process.env.PARALLEL_API_KEY;\n}\n\n/**\n * Wraps the @mastra/tavily search tool with mastracode-specific behavior:\n * relevance filtering, markdown string formatting, and token truncation.\n * The underlying Tavily tool handles client init, input validation, and the API call.\n */\nexport async function createWebSearchTool() {\n const { createTavilySearchTool } = await import('@mastra/tavily');\n const tavilySearchTool = createTavilySearchTool();\n\n return createTool({\n id: 'web-search',\n description: tavilySearchTool.description!,\n inputSchema: tavilySearchTool.inputSchema!,\n execute: async (input, context) => {\n const output: any = await tavilySearchTool.execute!(input as any, context as any);\n\n const parts: string[] = [];\n\n if (output.answer) {\n parts.push(`Answer: ${output.answer}`);\n }\n\n const filtered = output.results.filter((r: any) => (r.score ?? 1) >= MIN_RELEVANCE_SCORE);\n for (const r of filtered) {\n parts.push(`## ${r.title}\\n${r.url}\\n${r.content}`);\n }\n\n const images = (output.images || []).map((img: any) => img.url).filter(Boolean);\n if (images.length > 0) {\n parts.push(`Images:\\n${images.join('\\n')}`);\n }\n\n const text = parts.join('\\n\\n');\n return truncateStringForTokenEstimate(text, MAX_WEB_SEARCH_TOKENS);\n },\n });\n}\n\n/**\n * Wraps the @mastra/tavily extract tool with mastracode-specific behavior:\n * markdown string formatting and token truncation.\n */\nexport async function createWebExtractTool() {\n const { createTavilyExtractTool } = await import('@mastra/tavily');\n const tavilyExtractTool = createTavilyExtractTool();\n\n return createTool({\n id: 'web-extract',\n description: tavilyExtractTool.description!,\n inputSchema: tavilyExtractTool.inputSchema!,\n execute: async (input, context) => {\n const output: any = await tavilyExtractTool.execute!(input as any, context as any);\n\n const parts: string[] = [];\n\n for (const r of output.results) {\n parts.push(`## ${r.url}\\n${r.rawContent}`);\n }\n\n for (const r of output.failedResults) {\n parts.push(`## ${r.url}\\nError: ${r.error}`);\n }\n\n const text = parts.join('\\n\\n');\n return truncateStringForTokenEstimate(text, MAX_WEB_EXTRACT_TOKENS);\n },\n });\n}\n\n/**\n * Wraps the @mastra/parallel search tool with Mastra Code's standard tool id,\n * markdown string output, and token truncation.\n */\nexport async function createParallelWebSearchTool() {\n const { createParallelSearchTool } = await import('@mastra/parallel');\n const parallelSearchTool = createParallelSearchTool();\n\n return createTool({\n id: 'web-search',\n description: parallelSearchTool.description!,\n inputSchema: parallelWebSearchInputSchema,\n execute: async (input, context) => {\n const output = requireParallelOutput(\n await parallelSearchTool.execute!({ searchQueries: [input.query] }, context),\n 'search',\n );\n const parts: string[] = [];\n\n for (const result of output.results) {\n const title = result.title || result.url;\n const excerpts = (result.excerpts || []).filter(Boolean).join('\\n');\n parts.push([`## ${title}`, result.url, excerpts].filter(Boolean).join('\\n'));\n }\n\n return truncateStringForTokenEstimate(parts.join('\\n\\n'), MAX_WEB_SEARCH_TOKENS);\n },\n });\n}\n\n/**\n * Wraps the @mastra/parallel extract tool with Mastra Code's standard tool id,\n * markdown string output, and token truncation.\n */\nexport async function createParallelWebExtractTool() {\n const { createParallelExtractTool } = await import('@mastra/parallel');\n const parallelExtractTool = createParallelExtractTool();\n\n return createTool({\n id: 'web-extract',\n description: parallelExtractTool.description!,\n inputSchema: parallelExtractTool.inputSchema!,\n execute: async (input, context) => {\n const output = requireParallelOutput(await parallelExtractTool.execute!(input, context), 'extract');\n const parts: string[] = [];\n\n for (const result of output.results) {\n const content = result.fullContent || (result.excerpts || []).filter(Boolean).join('\\n');\n parts.push([`## ${result.url}`, content].filter(Boolean).join('\\n'));\n }\n\n for (const error of output.errors) {\n const status = error.httpStatusCode ? ` (${error.httpStatusCode})` : '';\n parts.push([`## ${error.url}`, `Error: ${error.errorType}${status}`, error.content].filter(Boolean).join('\\n'));\n }\n\n return truncateStringForTokenEstimate(parts.join('\\n\\n'), MAX_WEB_EXTRACT_TOKENS);\n },\n });\n}\n\n/**\n * Resolve which model-independent web provider to use. An explicit user\n * preference wins while its API key is configured; otherwise `auto` picks the\n * first configured provider key (Tavily, then Parallel).\n */\nexport function resolveWebSearchProvider(\n preference: WebSearchProviderSetting = 'auto',\n): 'tavily' | 'parallel' | undefined {\n if (preference === 'tavily' && hasTavilyKey()) return 'tavily';\n if (preference === 'parallel' && hasParallelKey()) return 'parallel';\n\n // `auto`, or an explicit choice whose key is no longer configured.\n if (hasTavilyKey()) return 'tavily';\n if (hasParallelKey()) return 'parallel';\n return undefined;\n}\n\n/**\n * Create the configured model-independent web tools for the provider selected\n * via the `webSearchProvider` preference (set in the TUI settings panel).\n * Returns `undefined` synchronously when no provider key is configured, so the\n * provider SDK (Tavily pulls in tiktoken, ~15 MB) only loads when one is.\n */\nexport function createConfiguredWebTools() {\n const provider = resolveWebSearchProvider(loadSettings().preferences.webSearchProvider);\n\n if (provider === 'parallel') {\n return loadWebTools(createParallelWebSearchTool, createParallelWebExtractTool);\n }\n\n if (provider === 'tavily') {\n return loadWebTools(createWebSearchTool, createWebExtractTool);\n }\n\n return undefined;\n}\n\nasync function loadWebTools<S, E>(createSearch: () => Promise<S>, createExtract: () => Promise<E>) {\n return { web_search: await createSearch(), web_extract: await createExtract() };\n}\n"],"mappings":";;;;;AAQA,MAAM,wBAAwB;AAC9B,MAAM,yBAAyB;AAE/B,MAAM,sBAAsB;AAE5B,MAAM,+BAA+B,EAAE,OAAO,EAC5C,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,kBAAkB,EACtD,CAAC;AAED,SAAS,sBAAyB,QAAoC,WAAoC;CACxG,IAAI,WAAW,KAAA,GACb,MAAM,IAAI,MAAM,YAAY,UAAU,oBAAoB;CAG5D,IAAI,kBAAkB,MAAM,GAC1B,MAAM,IAAI,MAAM,OAAO,OAAO;CAGhC,OAAO;AACT;;;;;;AAOA,SAAgB,eAAwB;CACtC,OAAO,CAAC,CAAC,QAAQ,IAAI;AACvB;;AAGA,SAAgB,iBAA0B;CACxC,OAAO,CAAC,CAAC,QAAQ,IAAI;AACvB;;;;;;AAOA,eAAsB,sBAAsB;CAC1C,MAAM,EAAE,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AEA,KAAK,MAAM,SAAS,OAAO,QAAQ;IACjC,MAAM,SAAS,MAAM,iBAAiB,KAAK,MAAM,eAAe,KAAK;IACrE,MAAM,KAAK;KAAC,MAAM,MAAM;KAAO,UAAU,MAAM,YAAY;KAAU,MAAM;IAAO,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC;GAChH;GAEA,OAAO,+BAA+B,MAAM,KAAK,MAAM,GAAG,sBAAsB;EAClF;CACF,CAAC;AACH;;;;;;AAOA,SAAgB,yBACd,aAAuC,QACJ;CACnC,IAAI,eAAe,YAAY,aAAa,GAAG,OAAO;CACtD,IAAI,eAAe,cAAc,eAAe,GAAG,OAAO;CAG1D,IAAI,aAAa,GAAG,OAAO;CAC3B,IAAI,eAAe,GAAG,OAAO;AAE/B;;;;;;;AAQA,SAAgB,2BAA2B;CACzC,MAAM,WAAW,yBAAyB,aAAa,CAAC,CAAC,YAAY,iBAAiB;CAEtF,IAAI,aAAa,YACf,OAAO,aAAa,6BAA6B,4BAA4B;CAG/E,IAAI,aAAa,UACf,OAAO,aAAa,qBAAqB,oBAAoB;AAIjE;AAEA,eAAe,aAAmB,cAAgC,eAAiC;CACjG,OAAO;EAAE,YAAY,MAAM,aAAa;EAAG,aAAa,MAAM,cAAc;CAAE;AAChF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-workflow.d.ts","sourceRoot":"","sources":["../../../src/tools/workflows/create-workflow.ts"],"names":[],"mappings":"AA6BA,eAAO,MAAM,kBAAkB;;;;;8HA2G7B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-workflow.js","names":[],"sources":["../../../src/tools/workflows/create-workflow.ts"],"sourcesContent":["/**\n * Parent-mode tool: delegate workflow construction to the workflow-builder\n * sub-agent. The parent code-agent calls this with the user's request verbatim;\n * the sub-agent runs its own discovery → compose → save loop and returns a\n * one-paragraph summary the parent relays to the user.\n *\n * The split exists so the parent code-agent's system prompt stays focused on\n * coding and isn't polluted with the long workflow-authoring contract.\n */\nimport type { Mastra } from '@mastra/core/mastra';\nimport { MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY, RequestContext } from '@mastra/core/request-context';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\n/**\n * Coerce an unknown thrown value into a readable string. Sub-agent tool errors\n * come through the stream in various shapes (Error, plain object, string) —\n * normalise so the parent tool's error message is always useful.\n */\nfunction stringifyError(err: unknown): string {\n if (err instanceof Error) return err.message;\n if (typeof err === 'string') return err;\n try {\n return JSON.stringify(err) ?? String(err);\n } catch {\n return String(err);\n }\n}\n\nexport const createWorkflowTool = createTool({\n id: 'create-workflow',\n description:\n 'Build and save a Dynamic Workflow on behalf of the user. Pass the user request verbatim — a focused sub-agent handles discovery, construction, and persistence, then returns a summary. Use this whenever the user asks to \"build a workflow\", \"compose a workflow\", or similar. Do NOT try to construct workflows inline yourself.',\n inputSchema: z.object({\n request: z.string().describe('The user request, verbatim — do not paraphrase or summarise.'),\n }),\n outputSchema: z.object({\n summary: z.string().describe('Natural-language summary of what the sub-agent built. Relay this to the user.'),\n workflowId: z.string().optional().describe('The id of the saved workflow, if save-workflow returned ok.'),\n }),\n execute: async ({ request }, { mastra, requestContext }) => {\n if (!mastra) throw new Error('create-workflow requires a Mastra context.');\n const builder = (mastra as Mastra).getAgent('workflow-builder' as never);\n if (!builder) {\n throw new Error(\n 'The \"workflow-builder\" sub-agent is not registered on this Mastra instance. Cannot build workflows.',\n );\n }\n\n // Propagate the parent code-agent's requestContext so the sub-agent's\n // dynamic model resolver (getDynamicModel) sees controller.session.modelId.\n // Without this the sub-agent throws \"No model selected\" even when the user\n // has /models configured for the main code-agent.\n // Drop the reserved memory keys: they would bind the builder to the parent\n // run's thread, and the builder would wait on the run that is waiting on it.\n const builderRequestContext = requestContext ? new RequestContext(requestContext.entries()) : undefined;\n builderRequestContext?.delete(MASTRA_THREAD_ID_KEY);\n builderRequestContext?.delete(MASTRA_RESOURCE_ID_KEY);\n const stream = await builder.stream(request, { requestContext: builderRequestContext });\n\n // Sub-agent runs its own tool loop. We MUST verify save-workflow actually\n // ran and returned ok — otherwise the sub-agent's natural-language \"summary\"\n // is worthless (it will happily claim success without ever calling the tool,\n // or claim success after save-workflow threw). Surface every error the\n // sub-agent's tools produce so the caller sees them instead of a fake ok.\n let workflowId: string | undefined;\n let saveAttempted = false;\n let saveSucceeded = false;\n const toolErrors: Array<{ toolName: string; error: string }> = [];\n\n const reader = stream.fullStream.getReader();\n let streamCompleted = false;\n try {\n while (true) {\n const { value, done } = await reader.read();\n if (done) {\n streamCompleted = true;\n break;\n }\n if (value?.type === 'tool-call' && value.payload?.toolName === 'save-workflow') {\n saveAttempted = true;\n }\n if (value?.type === 'tool-result' && value.payload?.toolName === 'save-workflow') {\n const result = value.payload.result as { id?: string; ok?: boolean } | undefined;\n if (result && result.ok === true && typeof result.id === 'string') {\n workflowId = result.id;\n saveSucceeded = true;\n }\n }\n if (value?.type === 'tool-error' && typeof value.payload?.toolName === 'string') {\n toolErrors.push({ toolName: value.payload.toolName, error: stringifyError(value.payload.error) });\n }\n }\n } finally {\n if (!streamCompleted) {\n await reader.cancel().catch(() => undefined);\n }\n reader.releaseLock();\n }\n\n const summary = await stream.text;\n\n // If save-workflow errored, surface that error explicitly — do NOT return\n // the sub-agent's summary as if things were fine.\n const saveErrors = toolErrors.filter(e => e.toolName === 'save-workflow');\n if (saveErrors.length > 0 && !saveSucceeded) {\n throw new Error(\n `create-workflow failed: save-workflow threw ${saveErrors.length} error(s):\\n- ${saveErrors\n .map(e => e.error)\n .join('\\n- ')}\\n\\nSub-agent summary (unreliable, save did not succeed):\\n${summary}`,\n );\n }\n\n // If save-workflow was never called, the sub-agent gave up (or hallucinated\n // success). Fail loudly so the caller doesn't think a workflow exists.\n if (!saveAttempted) {\n const otherErrors = toolErrors.length\n ? `\\n\\nOther sub-agent tool errors:\\n- ${toolErrors.map(e => `${e.toolName}: ${e.error}`).join('\\n- ')}`\n : '';\n throw new Error(\n `create-workflow failed: the workflow-builder sub-agent never called save-workflow. No workflow was persisted.${otherErrors}\\n\\nSub-agent summary:\\n${summary}`,\n );\n }\n\n // Save was attempted but never returned ok (no tool-result with { ok: true, id }).\n if (!saveSucceeded) {\n const otherErrors = toolErrors.length\n ? `\\n\\nSub-agent tool errors:\\n- ${toolErrors.map(e => `${e.toolName}: ${e.error}`).join('\\n- ')}`\n : '';\n throw new Error(\n `create-workflow failed: save-workflow was called but did not return { ok: true }.${otherErrors}\\n\\nSub-agent summary:\\n${summary}`,\n );\n }\n\n return { summary, workflowId };\n },\n});\n"],"mappings":";;;;;;;;;AAmBA,SAAS,eAAe,KAAsB;CAC5C,IAAI,eAAe,OAAO,OAAO,IAAI;CACrC,IAAI,OAAO,QAAQ,UAAU,OAAO;CACpC,IAAI;EACF,OAAO,KAAK,UAAU,GAAG,KAAK,OAAO,GAAG;CAC1C,QAAQ;EACN,OAAO,OAAO,GAAG;CACnB;AACF;AAEA,MAAa,qBAAqB,WAAW;CAC3C,IAAI;CACJ,aACE;CACF,aAAa,EAAE,OAAO,EACpB,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,8DAA8D,EAC7F,CAAC;CACD,cAAc,EAAE,OAAO;EACrB,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,+EAA+E;EAC5G,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,6DAA6D;CAC1G,CAAC;CACD,SAAS,OAAO,EAAE,WAAW,EAAE,QAAQ,qBAAqB;EAC1D,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,4CAA4C;EACzE,MAAM,UAAW,OAAkB,SAAS,kBAA2B;EACvE,IAAI,CAAC,SACH,MAAM,IAAI,MACR,uGACF;EASF,MAAM,wBAAwB,iBAAiB,IAAI,eAAe,eAAe,QAAQ,CAAC,IAAI,KAAA;EAC9F,uBAAuB,OAAO,oBAAoB;EAClD,uBAAuB,OAAO,sBAAs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AC,KAAK,MAAM,MACnG;GACJ,MAAM,IAAI,MACR,gHAAgH,YAAY,0BAA0B,SACxJ;EACF;EAGA,IAAI,CAAC,eAAe;GAClB,MAAM,cAAc,WAAW,SAC3B,iCAAiC,WAAW,KAAI,MAAK,GAAG,EAAE,SAAS,IAAI,EAAE,OAAO,CAAC,CAAC,KAAK,MAAM,MAC7F;GACJ,MAAM,IAAI,MACR,oFAAoF,YAAY,0BAA0B,SAC5H;EACF;EAEA,OAAO;GAAE;GAAS;EAAW;CAC/B;AACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete-workflow.d.ts","sourceRoot":"","sources":["../../../src/tools/workflows/delete-workflow.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,kBAAkB;;;;;8HAe7B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete-workflow.js","names":[],"sources":["../../../src/tools/workflows/delete-workflow.ts"],"sourcesContent":["/**\n * Parent-mode tool: delete a saved workflow from storage and unregister the\n * live in-process Workflow instance so a subsequent save-workflow with the\n * same id re-registers cleanly.\n */\nimport type { Mastra } from '@mastra/core/mastra';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\nimport { deleteWorkflow } from '../../workflows/service.js';\n\nexport const deleteWorkflowTool = createTool({\n id: 'delete-workflow',\n description:\n 'Remove a saved workflow from storage and unregister the live in-process Workflow instance. Idempotent. Subsequent save-workflow calls with the same id re-register cleanly.',\n inputSchema: z.object({\n id: z.string().describe('The workflow id to delete.'),\n }),\n outputSchema: z.object({\n ok: z.literal(true),\n id: z.string(),\n }),\n execute: async ({ id }, { mastra }) => {\n if (!mastra) throw new Error('delete-workflow requires a Mastra context.');\n return deleteWorkflow(mastra as Mastra, id);\n },\n});\n"],"mappings":";;;;AAUA,MAAa,qBAAqB,WAAW;CAC3C,IAAI;CACJ,aACE;CACF,aAAa,EAAE,OAAO,EACpB,IAAI,EAAE,OAAO,CAAC,CAAC,SAAS,4BAA4B,EACtD,CAAC;CACD,cAAc,EAAE,OAAO;EACrB,IAAI,EAAE,QAAQ,IAAI;EAClB,IAAI,EAAE,OAAO;CACf,CAAC;CACD,SAAS,OAAO,EAAE,MAAM,EAAE,aAAa;EACrC,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,4CAA4C;EACzE,OAAO,eAAe,QAAkB,EAAE;CAC5C;AACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ephemeral-memory.d.ts","sourceRoot":"","sources":["../../../src/tools/workflows/ephemeral-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAgD,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE5G,UAAU,sBAAsB;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,cAAc,EAAE,cAAc,GAAG,SAAS,EAC1C,EAAE,EAAE,CAAC,cAAc,EAAE,cAAc,GAAG,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,EAC9D,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,CAAC,CAAC,CA6BZ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ephemeral-memory.js","names":[],"sources":["../../../src/tools/workflows/ephemeral-memory.ts"],"sourcesContent":["/**\n * Sub-invocations launched from a parent chat turn (workflow agent steps,\n * sub-agent tool calls) must run under a fresh isolated Mastra memory scope\n * so they don't:\n *\n * - write their prompts/responses into the parent chat thread's history, or\n * - contend with the parent turn's memory-dependent processors\n * (observational-memory, task-state, working-memory-state).\n *\n * `withEphemeralMemory` copies the caller's request context into a child,\n * replaces its MastraMemory with a fresh thread id and inherited resource id,\n * then passes that isolated child to `fn`. The parent context is never mutated,\n * so concurrent sub-invocations cannot overwrite or restore each other's\n * memory values. Isolation writes the ephemeral ids instead of scrubbing them:\n * inner agent invocations resolve their thread/resource via those reserved\n * keys, and leaving them unset causes downstream storage saves to throw\n * \"Thread ID is required\".\n *\n * Callers can override the ephemeral thread id (e.g. for tests) via\n * `options.threadId`.\n */\nimport { MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY, RequestContext } from '@mastra/core/request-context';\n\ninterface EphemeralMemoryOptions {\n threadId?: string;\n}\n\nexport async function withEphemeralMemory<T>(\n requestContext: RequestContext | undefined,\n fn: (requestContext: RequestContext | undefined) => Promise<T>,\n options: EphemeralMemoryOptions = {},\n): Promise<T> {\n if (!requestContext) return fn(undefined);\n\n const childRequestContext = new RequestContext(requestContext.entries());\n const mastraMemory = requestContext.get('MastraMemory') as\n | { thread?: { id?: string }; resourceId?: string; memoryConfig?: unknown }\n | undefined;\n const resourceId = requestContext.get(MASTRA_RESOURCE_ID_KEY) as string | undefined;\n const ephemeralThreadId = options.threadId ?? globalThis.crypto.randomUUID();\n const parentResourceId = mastraMemory?.resourceId ?? resourceId ?? '';\n\n childRequestContext.set('MastraMemory', {\n thread: { id: ephemeralThreadId },\n resourceId: parentResourceId,\n memoryConfig: undefined,\n });\n // Stamp the reserved thread/resource-key context values with the same\n // ephemeral ids. Inner agent invocations (workflow agent steps, sub-agent\n // tool calls) read these keys to resolve their runtime thread; leaving\n // MASTRA_THREAD_ID_KEY unset causes prepare-memory-step to build a\n // MessageList without a threadId, which storage rejects downstream.\n childRequestContext.set(MASTRA_THREAD_ID_KEY, ephemeralThreadId);\n if (parentResourceId) {\n childRequestContext.set(MASTRA_RESOURCE_ID_KEY, parentResourceId);\n } else {\n childRequestContext.delete(MASTRA_RESOURCE_ID_KEY);\n }\n\n return fn(childRequestContext);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2BA,eAAsB,oBACpB,gBACA,IACA,UAAkC,CAAC,GACvB;CACZ,IAAI,CAAC,gBAAgB,OAAO,GAAG,KAAA,CAAS;CAExC,MAAM,sBAAsB,IAAI,eAAe,eAAe,QAAQ,CAAC;CACvE,MAAM,eAAe,eAAe,IAAI,cAAc;CAGtD,MAAM,aAAa,eAAe,IAAI,sBAAsB;CAC5D,MAAM,oBAAoB,QAAQ,YAAY,WAAW,OAAO,WAAW;CAC3E,MAAM,mBAAmB,cAAc,cAAc,cAAc;CAEnE,oBAAoB,IAAI,gBAAgB;EACtC,QAAQ,EAAE,IAAI,kBAAkB;EAChC,YAAY;EACZ,cAAc,KAAA;CAChB,CAAC;CAMD,oBAAoB,IAAI,sBAAsB,iBAAiB;CAC/D,IAAI,kBACF,oBAAoB,IAAI,wBAAwB,gBAAgB;MAEhE,oBAAoB,OAAO,sBAAsB;CAGnD,OAAO,GAAG,mBAAmB;AAC/B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract-json-schema.d.ts","sourceRoot":"","sources":["../../../src/tools/workflows/extract-json-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAc1G"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract-json-schema.js","names":["s"],"sources":["../../../src/tools/workflows/extract-json-schema.ts"],"sourcesContent":["/**\n * Extract a JSON Schema from a Mastra tool's schema field. Tools created via\n * `createTool({...})` wrap their Zod schemas with `toStandardSchema`, exposing\n * `['~standard'].jsonSchema` as a `{ input(opts), output(opts) }` converter\n * (see packages/schema-compat/src/standard-schema/adapters/zod-v3.ts:110-119).\n * `direction` selects which side — pass 'input' for inputSchema, 'output' for\n * outputSchema. Returns undefined if the schema is missing or not\n * standard-schema-compliant — the workflow-builder agent then knows the tool's\n * shape is opaque and must reshape via mapping.\n */\nexport function extractJsonSchema(maybeSchema: unknown, direction: 'input' | 'output'): unknown | undefined {\n try {\n const s = maybeSchema as\n | {\n ['~standard']?: {\n jsonSchema?: { input?: (opts: unknown) => unknown; output?: (opts: unknown) => unknown };\n };\n }\n | undefined;\n const converter = s?.['~standard']?.jsonSchema;\n return converter?.[direction]?.({ target: 'draft-2020-12' });\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAgB,kBAAkB,aAAsB,WAAoD;CAC1G,IAAI;EASF,QADkBA,cAAI,YAAY,EAAE,WAAA,GACjB,UAAU,GAAG,EAAE,QAAQ,gBAAgB,CAAC;CAC7D,QAAQ;EACN;CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-workflow.d.ts","sourceRoot":"","sources":["../../../src/tools/workflows/get-workflow.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,eAAe;;;;;;;;;2HA2B1B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-workflow.js","names":[],"sources":["../../../src/tools/workflows/get-workflow.ts"],"sourcesContent":["/**\n * Parent-mode tool: inspect a saved workflow's full definition.\n */\nimport type { Mastra } from '@mastra/core/mastra';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\nimport { getWorkflow } from '../../workflows/service.js';\n\nexport const getWorkflowTool = createTool({\n id: 'get-workflow',\n description: 'Return the full stored definition of a workflow (input/output schemas + the step graph).',\n inputSchema: z.object({\n id: z.string().describe('The workflow id.'),\n }),\n outputSchema: z.object({\n id: z.string(),\n description: z.string().optional(),\n status: z.enum(['active', 'archived']),\n inputSchema: z.any().optional(),\n outputSchema: z.any().optional(),\n graph: z.array(z.any()).optional(),\n }),\n execute: async ({ id }, { mastra }) => {\n if (!mastra) throw new Error('get-workflow requires a Mastra context.');\n const def = await getWorkflow(mastra as Mastra, id);\n if (!def) throw new Error(`No workflow with id \"${id}\".`);\n return {\n id: def.id,\n description: def.description,\n status: def.status,\n inputSchema: def.inputSchema,\n outputSchema: def.outputSchema,\n graph: def.graph,\n };\n },\n});\n"],"mappings":";;;;AAQA,MAAa,kBAAkB,WAAW;CACxC,IAAI;CACJ,aAAa;CACb,aAAa,EAAE,OAAO,EACpB,IAAI,EAAE,OAAO,CAAC,CAAC,SAAS,kBAAkB,EAC5C,CAAC;CACD,cAAc,EAAE,OAAO;EACrB,IAAI,EAAE,OAAO;EACb,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;EACjC,QAAQ,EAAE,KAAK,CAAC,UAAU,UAAU,CAAC;EACrC,aAAa,EAAE,IAAI,CAAC,CAAC,SAAS;EAC9B,cAAc,EAAE,IAAI,CAAC,CAAC,SAAS;EAC/B,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS;CACnC,CAAC;CACD,SAAS,OAAO,EAAE,MAAM,EAAE,aAAa;EACrC,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,yCAAyC;EACtE,MAAM,MAAM,MAAM,YAAY,QAAkB,EAAE;EAClD,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,wBAAwB,GAAG,GAAG;EACxD,OAAO;GACL,IAAI,IAAI;GACR,aAAa,IAAI;GACjB,QAAQ,IAAI;GACZ,aAAa,IAAI;GACjB,cAAc,IAAI;GAClB,OAAO,IAAI;EACb;CACF;AACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-available-agents.d.ts","sourceRoot":"","sources":["../../../src/tools/workflows/list-available-agents.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,uBAAuB;;;;;;oIA8BlC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-available-agents.js","names":[],"sources":["../../../src/tools/workflows/list-available-agents.ts"],"sourcesContent":["/**\n * Sub-agent tool: list agents the workflow-builder can reference in agent-step\n * entries of a Dynamic Workflow graph. Read-only.\n */\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\n/** Self / management tools the workflow-builder shouldn't recursively try to compose. */\nconst WORKFLOW_BUILDER_NOISE_AGENTS = new Set(['workflow-builder']);\n\nexport const listAvailableAgentsTool = createTool({\n id: 'list-available-agents',\n description:\n 'Returns the agents currently registered on the Mastra instance. The agent ids returned here are the only valid values you can put in `{ type: \"agent\", agentId }` graph entries. `outputShape` describes the default text output; an entry-level `outputSchema` replaces that default with structured output.',\n inputSchema: z.object({}),\n outputSchema: z.object({\n agents: z.array(\n z.object({\n id: z.string(),\n description: z.string().optional(),\n // Human-readable string in v1. Could become a JSON Schema now that\n // structuredOutput round-trips through the rehydrator\n // (packages/core/src/workflows/rehydrate-workflow.ts).\n outputShape: z.string(),\n }),\n ),\n }),\n execute: async (_input, { mastra }) => {\n if (!mastra) throw new Error('list-available-agents requires a Mastra context.');\n const all = (mastra as { listAgents?: () => Record<string, unknown> }).listAgents?.() ?? {};\n return {\n agents: Object.entries(all)\n .filter(([id]) => !WORKFLOW_BUILDER_NOISE_AGENTS.has(id))\n .map(([id, a]) => ({\n id,\n description: (a as { description?: string } | undefined)?.description,\n outputShape: 'Default: { text: string }. An entry-level outputSchema produces that schema instead.',\n })),\n };\n },\n});\n"],"mappings":";;;;;;;;AAQA,MAAM,gDAAgC,IAAI,IAAI,CAAC,kBAAkB,CAAC;AAElE,MAAa,0BAA0B,WAAW;CAChD,IAAI;CACJ,aACE;CACF,aAAa,EAAE,OAAO,CAAC,CAAC;CACxB,cAAc,EAAE,OAAO,EACrB,QAAQ,EAAE,MACR,EAAE,OAAO;EACP,IAAI,EAAE,OAAO;EACb,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;EAIjC,aAAa,EAAE,OAAO;CACxB,CAAC,CACH,EACF,CAAC;CACD,SAAS,OAAO,QAAQ,EAAE,aAAa;EACrC,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,kDAAkD;EAC/E,MAAM,MAAO,OAA0D,aAAa,KAAK,CAAC;EAC1F,OAAO,EACL,QAAQ,OAAO,QAAQ,GAAG,CAAC,CACxB,QAAQ,CAAC,QAAQ,CAAC,8BAA8B,IAAI,EAAE,CAAC,CAAC,CACxD,KAAK,CAAC,IAAI,QAAQ;GACjB;GACA,aAAc,GAA4C;GAC1D,aAAa;EACf,EAAE,EACN;CACF;AACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-available-classifiers.d.ts","sourceRoot":"","sources":["../../../src/tools/workflows/list-available-classifiers.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;yIAiDvC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-available-classifiers.js","names":[],"sources":["../../../src/tools/workflows/list-available-classifiers.ts"],"sourcesContent":["/**\n * Sub-agent tool: list classifiers the workflow-builder can reference in\n * classifier entries of a Dynamic Workflow graph. Read-only.\n */\nimport type { ClassifierQuestions } from '@mastra/core/classifier';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nfunction describeQuestions(questions: ClassifierQuestions | undefined) {\n if (!questions) return undefined;\n\n return Object.entries(questions).map(([id, question]) => ({\n id,\n type: question.type,\n instructions: question.instructions,\n choices: question.type === 'choice' ? Object.keys(question.criteria) : undefined,\n criteria: question.criteria,\n answerPath: `inputData.answers.${id}`,\n routingPath: `inputData.answers.${id}.${\n question.type === 'choice' ? 'choice' : question.type === 'score' ? 'score' : 'probability'\n }`,\n }));\n}\n\nexport const listAvailableClassifiersTool = createTool({\n id: 'list-available-classifiers',\n description:\n 'Returns configured classifiers registered on the Mastra instance. The ids returned here are the only valid values for `{ type: \"classifier\", classifierId }`. Each row includes question metadata and stable output paths for routing with conditional entries.',\n inputSchema: z.object({}),\n outputSchema: z.object({\n classifiers: z.array(\n z.object({\n id: z.string(),\n questions: z\n .array(\n z.object({\n id: z.string(),\n type: z.enum(['choice', 'score', 'boolean']),\n instructions: z.any().optional(),\n choices: z.array(z.string()).optional(),\n criteria: z.any().optional(),\n answerPath: z.string(),\n routingPath: z.string(),\n }),\n )\n .optional(),\n outputPaths: z.object({\n answers: z.string(),\n usage: z.string(),\n }),\n }),\n ),\n }),\n execute: async (_input, { mastra }) => {\n if (!mastra) throw new Error('list-available-classifiers requires a Mastra context.');\n const all =\n (\n mastra as { listClassifiers?: () => Record<string, { questions?: ClassifierQuestions }> | undefined }\n ).listClassifiers?.() ?? {};\n\n return {\n classifiers: Object.entries(all)\n .filter(([, classifier]) => classifier.questions !== undefined)\n .map(([id, classifier]) => ({\n id,\n questions: describeQuestions(classifier.questions),\n outputPaths: {\n answers: 'inputData.answers.<question>',\n usage: 'inputData.usage',\n },\n })),\n };\n },\n});\n"],"mappings":";;;AAQA,SAAS,kBAAkB,WAA4C;CACrE,IAAI,CAAC,WAAW,OAAO,KAAA;CAEvB,OAAO,OAAO,QAAQ,SAAS,CAAC,CAAC,KAAK,CAAC,IAAI,eAAe;EACxD;EACA,MAAM,SAAS;EACf,cAAc,SAAS;EACvB,SAAS,SAAS,SAAS,WAAW,OAAO,KAAK,SAAS,QAAQ,IAAI,KAAA;EACvE,UAAU,SAAS;EACnB,YAAY,qBAAqB;EACjC,aAAa,qBAAqB,GAAG,GACnC,SAAS,SAAS,WAAW,WAAW,SAAS,SAAS,UAAU,UAAU;CAElF,EAAE;AACJ;AAEA,MAAa,+BAA+B,WAAW;CACrD,IAAI;CACJ,aACE;CACF,aAAa,EAAE,OAAO,CAAC,CAAC;CACxB,cAAc,EAAE,OAAO,EACrB,aAAa,EAAE,MACb,EAAE,OAAO;EACP,IAAI,EAAE,OAAO;EACb,WAAW,EACR,MACC,EAAE,OAAO;GACP,IAAI,EAAE,OAAO;GACb,MAAM,EAAE,KAAK;IAAC;IAAU;IAAS;GAAS,CAAC;GAC3C,cAAc,EAAE,IAAI,CAAC,CAAC,SAAS;GAC/B,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;GACtC,UAAU,EAAE,IAAI,CAAC,CAAC,SAAS;GAC3B,YAAY,EAAE,OAAO;GACrB,aAAa,EAAE,OAAO;EACxB,CAAC,CACH,CAAC,CACA,SAAS;EACZ,aAAa,EAAE,OAAO;GACpB,SAAS,EAAE,OAAO;GAClB,OAAO,EAAE,OAAO;EAClB,CAAC;CACH,CAAC,CACH,EACF,CAAC;CACD,SAAS,OAAO,QAAQ,EAAE,aAAa;EACrC,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,uDAAuD;EACpF,MAAM,MAEF,OACA,kBAAkB,KAAK,CAAC;EAE5B,OAAO,EACL,aAAa,OAAO,QAAQ,GAAG,CAAC,CAC7B,QAAQ,GAAG,gBAAgB,WAAW,cAAc,KAAA,CAAS,CAAC,CAC9D,KAAK,CAAC,IAAI,iBAAiB;GAC1B;GACA,WAAW,kBAAkB,WAAW,SAAS;GACjD,aAAa;IACX,SAAS;IACT,OAAO;GACT;EACF,EAAE,EACN;CACF;AACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-available-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/workflows/list-available-tools.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,sBAAsB;;;;;;;mIAgCjC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-available-tools.js","names":[],"sources":["../../../src/tools/workflows/list-available-tools.ts"],"sourcesContent":["/**\n * Sub-agent tool: list tools the workflow-builder can reference in tool-step\n * entries of a Dynamic Workflow graph. Returns JSON Schema for inputs/outputs\n * so the LLM has ground truth instead of guessing.\n */\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\nimport { extractJsonSchema } from './extract-json-schema.js';\nimport { WORKFLOW_BUILDER_NOISE_TOOL_IDS } from './tool-ids.js';\n\n/** Authoring and management tools are not valid workflow building blocks. */\nconst WORKFLOW_BUILDER_NOISE_TOOLS = new Set<string>(WORKFLOW_BUILDER_NOISE_TOOL_IDS);\n\nexport const listAvailableToolsTool = createTool({\n id: 'list-available-tools',\n description:\n 'Returns the tools currently registered on the Mastra instance. The tool ids returned here are the only valid values you can put in `{ type: \"tool\", toolId }` graph entries. Each row includes `inputSchema` and `outputSchema` as JSON Schema — read them to know what fields the tool accepts and emits; never invent field names.',\n inputSchema: z.object({}),\n outputSchema: z.object({\n tools: z.array(\n z.object({\n id: z.string(),\n description: z.string().optional(),\n inputSchema: z.any().optional(),\n outputSchema: z.any().optional(),\n }),\n ),\n }),\n execute: async (_input, { mastra }) => {\n if (!mastra) throw new Error('list-available-tools requires a Mastra context.');\n const all = (mastra as { listTools?: () => Record<string, unknown> }).listTools?.() ?? {};\n return {\n tools: Object.entries(all)\n .filter(([id]) => !WORKFLOW_BUILDER_NOISE_TOOLS.has(id))\n .map(([id, t]) => {\n const tool = t as { description?: string; inputSchema?: unknown; outputSchema?: unknown } | undefined;\n return {\n id,\n description: tool?.description,\n inputSchema: extractJsonSchema(tool?.inputSchema, 'input'),\n outputSchema: extractJsonSchema(tool?.outputSchema, 'output'),\n };\n }),\n };\n },\n});\n"],"mappings":";;;;;;;;;;;AAWA,MAAM,+BAA+B,IAAI,IAAY,+BAA+B;AAEpF,MAAa,yBAAyB,WAAW;CAC/C,IAAI;CACJ,aACE;CACF,aAAa,EAAE,OAAO,CAAC,CAAC;CACxB,cAAc,EAAE,OAAO,EACrB,OAAO,EAAE,MACP,EAAE,OAAO;EACP,IAAI,EAAE,OAAO;EACb,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;EACjC,aAAa,EAAE,IAAI,CAAC,CAAC,SAAS;EAC9B,cAAc,EAAE,IAAI,CAAC,CAAC,SAAS;CACjC,CAAC,CACH,EACF,CAAC;CACD,SAAS,OAAO,QAAQ,EAAE,aAAa;EACrC,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,iDAAiD;EAC9E,MAAM,MAAO,OAAyD,YAAY,KAAK,CAAC;EACxF,OAAO,EACL,OAAO,OAAO,QAAQ,GAAG,CAAC,CACvB,QAAQ,CAAC,QAAQ,CAAC,6BAA6B,IAAI,EAAE,CAAC,CAAC,CACvD,KAAK,CAAC,IAAI,OAAO;GAChB,MAAM,OAAO;GACb,OAAO;IACL;IACA,aAAa,MAAM;IACnB,aAAa,kBAAkB,MAAM,aAAa,OAAO;IACzD,cAAc,kBAAkB,MAAM,cAAc,QAAQ;GAC9D;EACF,CAAC,EACL;CACF;AACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-available-workflows.d.ts","sourceRoot":"","sources":["../../../src/tools/workflows/list-available-workflows.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,0BAA0B;;;;;;;uIA8BrC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-available-workflows.js","names":[],"sources":["../../../src/tools/workflows/list-available-workflows.ts"],"sourcesContent":["/**\n * Sub-agent tool: list workflows the workflow-builder can reference in\n * `{ type: \"workflow\", workflowId }` graph entries. Includes both code-defined\n * and Dynamic Workflows, so the builder can nest one workflow inside another.\n * The pre-flight validator rejects self-references and dependency cycles.\n */\nimport type { Mastra } from '@mastra/core/mastra';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\nimport { extractJsonSchema } from './extract-json-schema.js';\n\nexport const listAvailableWorkflowsTool = createTool({\n id: 'list-available-workflows',\n description:\n 'Returns the workflows currently registered on the Mastra instance (both code-defined and dynamic). The ids returned here are the only valid values you can put in `{ type: \"workflow\", workflowId }` graph entries. Each row includes `inputSchema` and `outputSchema` as JSON Schema — read them to know what shape the nested workflow expects and produces; never invent field names.',\n inputSchema: z.object({}),\n outputSchema: z.object({\n workflows: z.array(\n z.object({\n id: z.string(),\n description: z.string().optional(),\n inputSchema: z.any().optional(),\n outputSchema: z.any().optional(),\n }),\n ),\n }),\n execute: async (_input, { mastra }) => {\n if (!mastra) throw new Error('list-available-workflows requires a Mastra context.');\n const all = (mastra as Mastra).listWorkflows?.() ?? {};\n return {\n workflows: Object.entries(all).map(([id, wf]) => {\n const w = wf as { description?: string; inputSchema?: unknown; outputSchema?: unknown } | undefined;\n return {\n id,\n description: w?.description,\n inputSchema: extractJsonSchema(w?.inputSchema, 'input'),\n outputSchema: extractJsonSchema(w?.outputSchema, 'output'),\n };\n }),\n };\n },\n});\n"],"mappings":";;;;AAWA,MAAa,6BAA6B,WAAW;CACnD,IAAI;CACJ,aACE;CACF,aAAa,EAAE,OAAO,CAAC,CAAC;CACxB,cAAc,EAAE,OAAO,EACrB,WAAW,EAAE,MACX,EAAE,OAAO;EACP,IAAI,EAAE,OAAO;EACb,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;EACjC,aAAa,EAAE,IAAI,CAAC,CAAC,SAAS;EAC9B,cAAc,EAAE,IAAI,CAAC,CAAC,SAAS;CACjC,CAAC,CACH,EACF,CAAC;CACD,SAAS,OAAO,QAAQ,EAAE,aAAa;EACrC,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,qDAAqD;EAClF,MAAM,MAAO,OAAkB,gBAAgB,KAAK,CAAC;EACrD,OAAO,EACL,WAAW,OAAO,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,QAAQ;GAC/C,MAAM,IAAI;GACV,OAAO;IACL;IACA,aAAa,GAAG;IAChB,aAAa,kBAAkB,GAAG,aAAa,OAAO;IACtD,cAAc,kBAAkB,GAAG,cAAc,QAAQ;GAC3D;EACF,CAAC,EACH;CACF;AACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-workflows.d.ts","sourceRoot":"","sources":["../../../src/tools/workflows/list-workflows.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,iBAAiB;;;;;;;6HAsB5B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-workflows.js","names":[],"sources":["../../../src/tools/workflows/list-workflows.ts"],"sourcesContent":["/**\n * Parent-mode tool: list saved workflows. Read-only, available in all modes.\n */\nimport type { Mastra } from '@mastra/core/mastra';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\nimport { listWorkflows } from '../../workflows/service.js';\n\nexport const listWorkflowsTool = createTool({\n id: 'list-workflows',\n description: 'List active Dynamic Workflows persisted to storage. Returns id + description + status for each.',\n inputSchema: z.object({}),\n outputSchema: z.object({\n workflows: z.array(\n z.object({\n id: z.string(),\n description: z.string().optional(),\n status: z.enum(['active', 'archived']),\n }),\n ),\n total: z.number(),\n }),\n execute: async (_input, { mastra }) => {\n if (!mastra) throw new Error('list-workflows requires a Mastra context.');\n const { workflows, total } = await listWorkflows(mastra as Mastra);\n return {\n workflows: workflows.map(wf => ({ id: wf.id, description: wf.description, status: wf.status })),\n total,\n };\n },\n});\n"],"mappings":";;;;AAQA,MAAa,oBAAoB,WAAW;CAC1C,IAAI;CACJ,aAAa;CACb,aAAa,EAAE,OAAO,CAAC,CAAC;CACxB,cAAc,EAAE,OAAO;EACrB,WAAW,EAAE,MACX,EAAE,OAAO;GACP,IAAI,EAAE,OAAO;GACb,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;GACjC,QAAQ,EAAE,KAAK,CAAC,UAAU,UAAU,CAAC;EACvC,CAAC,CACH;EACA,OAAO,EAAE,OAAO;CAClB,CAAC;CACD,SAAS,OAAO,QAAQ,EAAE,aAAa;EACrC,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,2CAA2C;EACxE,MAAM,EAAE,WAAW,UAAU,MAAM,cAAc,MAAgB;EACjE,OAAO;GACL,WAAW,UAAU,KAAI,QAAO;IAAE,IAAI,GAAG;IAAI,aAAa,GAAG;IAAa,QAAQ,GAAG;GAAO,EAAE;GAC9F;EACF;CACF;AACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-workflow.d.ts","sourceRoot":"","sources":["../../../src/tools/workflows/run-workflow.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,eAAe;;;;;;;2HAkD1B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-workflow.js","names":[],"sources":["../../../src/tools/workflows/run-workflow.ts"],"sourcesContent":["/**\n * Parent-mode tool: run a saved workflow with input data. Returns the run\n * result inline so the parent agent can summarise / chain it.\n */\nimport type { Mastra } from '@mastra/core/mastra';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\nimport { runWorkflow } from '../../workflows/service.js';\nimport { withEphemeralMemory } from './ephemeral-memory.js';\n\nexport const runWorkflowTool = createTool({\n id: 'run-workflow',\n description:\n 'Run a saved workflow by id with the provided input data. Returns the run result inline. Use when the user asks you to \"run X\", \"execute X\", or asks for the outcome of a saved workflow.',\n inputSchema: z.object({\n workflowId: z.string().describe('The id of the saved workflow to run.'),\n inputData: z.any().describe('The input object the workflow consumes. Must match the workflow inputSchema.'),\n }),\n outputSchema: z.object({\n status: z.string(),\n result: z.any().optional(),\n error: z.any().optional(),\n }),\n execute: async ({ workflowId, inputData }, { mastra, requestContext }) => {\n if (!mastra) throw new Error('run-workflow requires a Mastra context.');\n // Forward the caller's requestContext so agent steps can resolve dynamic\n // model/tool bindings from session state, and swap the caller's chat\n // memory scope for a fresh isolated one for the duration of the run so\n // the workflow's agent step doesn't write into (or read from) the parent\n // chat thread. See ephemeral-memory.ts.\n return withEphemeralMemory(requestContext, async ephemeralRequestContext => {\n const result = await runWorkflow(mastra as Mastra, workflowId, inputData, ephemeralRequestContext);\n if (result.status === 'tripwire' && result.tripwire) {\n return {\n status: result.status,\n error: `Tripwire: ${result.tripwire.reason ?? 'unknown'} (processor: ${result.tripwire.processorId ?? 'unknown'})`,\n };\n }\n let errorText: string | undefined;\n if (result.error instanceof Error) {\n errorText = `${result.error.name}: ${result.error.message}`;\n const cause = (result.error as { cause?: unknown }).cause;\n if (cause) {\n try {\n errorText += ` | cause: ${JSON.stringify(cause, Object.getOwnPropertyNames(cause))}`;\n } catch {\n errorText += ` | cause: ${String(cause)}`;\n }\n }\n if (result.error.stack) errorText += `\\nstack: ${result.error.stack}`;\n } else if (result.error) {\n try {\n errorText = JSON.stringify(result.error, Object.getOwnPropertyNames(result.error));\n } catch {\n errorText = String(result.error);\n }\n }\n return { status: result.status, result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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4HAsB3B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"save-workflow.js","names":[],"sources":["../../../src/tools/workflows/save-workflow.ts"],"sourcesContent":["/**\n * Sub-agent tool: persist the Dynamic Workflow definition and live-register it.\n * Calls `mastra.addDynamicWorkflow()`. After this returns the workflow is\n * immediately runnable.\n *\n * The complete-definition authoring contract (graph families, mapping sources,\n * predicate DSL, and all model-facing guidance) is shared with Studio's\n * `submit-workflow-draft` and lives in `@mastra/core/workflows/builder`.\n */\nimport type { Mastra } from '@mastra/core/mastra';\nimport { createTool } from '@mastra/core/tools';\nimport { normalizeWorkflowBuilderDefinition, workflowBuilderDefinitionSchema } from '@mastra/core/workflows/builder';\nimport { z } from 'zod';\n\nexport { WORKFLOW_BUILDER_MAPPING_CONFIG_DESCRIPTION as MAPPING_CONFIG_DESCRIPTION } from '@mastra/core/workflows/builder';\n\nexport const workflowDefinitionInputSchema = z.preprocess(\n normalizeWorkflowBuilderDefinition,\n workflowBuilderDefinitionSchema,\n);\n\nexport const saveWorkflowTool = createTool({\n id: 'save-workflow',\n description:\n 'Persist a Dynamic Workflow definition and live-register it on the running Mastra instance. Supports all ten persisted graph families: agent, tool, mapping, nested workflow, parallel, foreach, sleep, sleepUntil, conditional, and loop. Conditional and loop entries require declarative predicates; JS closures cannot round-trip through storage. After this returns, the workflow is immediately runnable. Call it exactly once with the complete definition; there is no incremental save API.',\n inputSchema: workflowDefinitionInputSchema,\n outputSchema: z.object({\n ok: z.literal(true),\n id: z.string(),\n }),\n execute: async (def, { mastra }) => {\n if (!mastra) throw new Error('save-workflow requires a Mastra context.');\n const m = mastra as Mastra;\n const normalizedDefinition = normalizeWorkflowBuilderDefinition(def);\n\n // `mastra.addDynamicWorkflow` performs registry pre-flight — a mis-classified\n // agentId/toolId or unregistered id throws before rehydration with an\n // actionable message listing every offender. It also rejects JSON Schemas\n // that use keywords the storage-side converter can't rehydrate\n // (oneOf/anyOf/allOf/not/$ref/patternProperties/discriminator).\n await m.addDynamicWorkflow(normalizedDefinition as Parameters<Mastra['addDynamicWorkflow']>[0]);\n return { ok: true as const, id: normalizedDefinition.id };\n },\n});\n"],"mappings":";;;;AAgBA,MAAa,gCAAgC,EAAE,WAC7C,oCACA,+BACF;AAEA,MAAa,mBAAmB,WAAW;CACzC,IAAI;CACJ,aACE;CACF,aAAa;CACb,cAAc,EAAE,OAAO;EACrB,IAAI,EAAE,QAAQ,IAAI;EAClB,IAAI,EAAE,OAAO;CACf,CAAC;CACD,SAAS,OAAO,KAAK,EAAE,aAAa;EAClC,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,0CAA0C;EACvE,MAAM,IAAI;EACV,MAAM,uBAAuB,mCAAmC,GAAG;EAOnE,MAAM,EAAE,mBAAmB,oBAAmE;EAC9F,OAAO;GAAE,IAAI;GAAe,IAAI,qBAAqB;EAAG;CAC1D;AACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-ids.d.ts","sourceRoot":"","sources":["../../../src/tools/workflows/tool-ids.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B;aACtC,UAAU,EAAE,uBAAuB;aACnC,eAAe,EAAE,4BAA4B;aAC7C,SAAS,EAAE,sBAAsB;aACjC,aAAa,EAAE,0BAA0B;aACzC,YAAY,EAAE,eAAe;CACrB,CAAC;AAEX,eAAO,MAAM,4BAA4B;aACvC,cAAc,EAAE,iBAAiB;aACjC,aAAa,EAAE,gBAAgB;aAC/B,WAAW,EAAE,cAAc;aAC3B,WAAW,EAAE,cAAc;aAC3B,cAAc,EAAE,iBAAiB;CACzB,CAAC;AAEX,eAAO,MAAM,+BAA+B,0OAGlC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-ids.js","names":[],"sources":["../../../src/tools/workflows/tool-ids.ts"],"sourcesContent":["export const WORKFLOW_AUTHORING_TOOL_IDS = {\n listAgents: 'list-available-agents',\n listClassifiers: 'list-available-classifiers',\n listTools: 'list-available-tools',\n listWorkflows: 'list-available-workflows',\n saveWorkflow: 'save-workflow',\n} as const;\n\nexport const WORKFLOW_MANAGEMENT_TOOL_IDS = {\n createWorkflow: 'create-workflow',\n listWorkflows: 'list-workflows',\n getWorkflow: 'get-workflow',\n runWorkflow: 'run-workflow',\n deleteWorkflow: 'delete-workflow',\n} as const;\n\nexport const WORKFLOW_BUILDER_NOISE_TOOL_IDS = [\n ...Object.values(WORKFLOW_AUTHORING_TOOL_IDS),\n ...Object.values(WORKFLOW_MANAGEMENT_TOOL_IDS),\n] as const;\n"],"mappings":";AAAA,MAAa,8BAA8B;CACzC,YAAY;CACZ,iBAAiB;CACjB,WAAW;CACX,eAAe;CACf,cAAc;AAChB;AAEA,MAAa,+BAA+B;CAC1C,gBAAgB;CAChB,eAAe;CACf,aAAa;CACb,aAAa;CACb,gBAAgB;AAClB;AAEA,MAAa,kCAAkC,CAC7C,GAAG,OAAO,OAAO,2BAA2B,GAC5C,GAAG,OAAO,OAAO,4BAA4B,CAC/C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"binaries.d.ts","sourceRoot":"","sources":["../../src/utils/binaries.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAyED,wBAAgB,oBAAoB,IAAI,YAAY,EAAE,CAIrD;AAED,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAczE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"binaries.js","names":[],"sources":["../../src/utils/binaries.ts"],"sourcesContent":["import { execFile, execFileSync } from 'node:child_process';\nimport { realpathSync } from 'node:fs';\nimport { basename, dirname, join } from 'node:path';\n\nexport interface CommonBinary {\n name: string;\n path: string | null;\n}\n\nconst COMMON_BINARIES = [\n 'python',\n 'python3',\n 'node',\n 'npm',\n 'pnpm',\n 'yarn',\n 'bun',\n 'git',\n 'rg',\n 'fd',\n 'fdfind',\n 'curl',\n 'wget',\n 'docker',\n 'make',\n 'gcc',\n 'g++',\n 'go',\n 'rustc',\n 'cargo',\n] as const;\n\n/**\n * The directory the tool lives in, with the name `which` reported still on the end.\n *\n * Version managers can put a directory first on PATH whose name changes on every shell (`fnm` builds one per\n * shell, `fnm_multishells/<pid>_<epoch-ms>`). These paths are part of the system prompt, so a directory that\n * changes from launch to launch changes that text even when the tools have not. Resolving the whole\n * file instead would name the program behind a shim - `mise` points every tool at itself, BusyBox and\n * OrbStack do the same for some tools, and a Homebrew link names `Cellar/<version>` - which either does not\n * run the tool or changes on every upgrade. Resolving only the directory gives the stable installation and\n * keeps a name that runs the tool.\n */\nfunction stablePath(path: string | null): string | null {\n if (!path) return path;\n try {\n return join(realpathSync(dirname(path)), basename(path));\n } catch {\n return path;\n }\n}\n\nlet cachedBinaries: CommonBinary[] | null = null;\nlet inFlightPromise: Promise<CommonBinary[]> | null = null;\n\nfunction whichCommand(): string {\n return process.platform === 'win32' ? 'where' : 'which';\n}\n\nfunction reportedBinary(name: string): string | null {\n try {\n const output = execFileSync(whichCommand(), [name], { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();\n return output.split(/\\r?\\n/)[0] || null;\n } catch {\n return null;\n }\n}\n\nfunction reportedBinaryAsync(name: string): Promise<string | null> {\n return new Promise(resolve => {\n execFile(whichCommand(), [name], { encoding: 'utf-8' }, (err, stdout) => {\n if (err) {\n resolve(null);\n return;\n }\n resolve(stdout.trim().split(/\\r?\\n/)[0] || null);\n });\n });\n}\n\nexport function detectCommonBinaries(): CommonBinary[] {\n cachedBinaries ??= COMMON_BINARIES.map(name => ({ name, path: stablePath(reportedBinary(name)) }));\n\n return cachedBinaries;\n}\n\nexport async function detectCommonBinariesAsync(): Promise<CommonBinary[]> {\n if (cachedBinaries) return cachedBinaries;\n if (inFlightPromise) return inFlightPromise;\n\n inFlightPromise = Promise.all(\n COMMON_BINARIES.map(async name => ({ name, path: stablePath(await reportedBinaryAsync(name)) })),\n );\n\n try {\n cachedBinaries = await inFlightPromise;\n return cachedBinaries;\n } finally {\n inFlightPromise = null;\n }\n}\n"],"mappings":";;;;AASA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;AAaA,SAAS,WAAW,MAAoC;CACtD,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI;EACF,OAAO,KAAK,aAAa,QAAQ,IAAI,CAAC,GAAG,SAAS,IAAI,CAAC;CACzD,QAAQ;EACN,OAAO;CACT;AACF;AAEA,IAAI,iBAAwC;AAC5C,IAAI,kBAAkD;AAEtD,SAAS,eAAuB;CAC9B,OAAO,QAAQ,aAAa,UAAU,UAAU;AAClD;AAEA,SAAS,eAAe,MAA6B;CACnD,IAAI;EAEF,OADe,aAAa,aAAa,GAAG,CAAC,IAAI,GAAG;GAAE,UAAU;GAAS,OAAO;IAAC;IAAQ;IAAQ;GAAM;EAAE,CAAC,CAAC,CAAC,KAChG,CAAC,CAAC,MAAM,OAAO,CAAC,CAAC,MAAM;CACrC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,oBAAoB,MAAsC;CACjE,OAAO,IAAI,SAAQ,YAAW;EAC5B,SAAS,aAAa,GAAG,CAAC,IAAI,GAAG,EAAE,UAAU,QAAQ,IAAI,KAAK,WAAW;GACvE,IAAI,KAAK;IACP,QAAQ,IAAI;IACZ;GACF;GACA,QAAQ,OAAO,KAAK,CAAC,CAAC,MAAM,OAAO,CAAC,CAAC,MAAM,IAAI;EACjD,CAAC;CACH,CAAC;AACH;AAEA,SAAgB,uBAAuC;CACrD,mBAAmB,gBAAgB,KAAI,UAAS;EAAE;EAAM,MAAM,WAAW,eAAe,IAAI,CAAC;CAAE,EAAE;CAEjG,OAAO;AACT;AAEA,eAAsB,4BAAqD;CACzE,IAAI,gBAAgB,OAAO;CAC3B,IAAI,iBAAiB,OAAO;CAE5B,kBAAkB,QAAQ,IACxB,gBAAgB,IAAI,OAAM,UAAS;EAAE;EAAM,MAAM,WAAW,MAAM,oBAAoB,IAAI,CAAC;CAAE,EAAE,CACjG;CAEA,IAAI;EACF,iBAAiB,MAAM;EACvB,OAAO;CACT,UAAU;EACR,kBAAkB;CACpB;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debug-log.d.ts","sourceRoot":"","sources":["../../src/utils/debug-log.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAerD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CA4BxC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debug-log.js","names":["fs","path"],"sources":["../../src/utils/debug-log.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport { getAppDataDir } from './project.js';\n\nconst MAX_LOG_SIZE = 5 * 1024 * 1024; // 5 MB\nconst KEEP_SIZE = 4 * 1024 * 1024; // 4 MB\n\n/**\n * Truncate a log file to roughly {@link KEEP_SIZE} bytes if it exceeds\n * {@link MAX_LOG_SIZE}, cutting at the first newline so we don't start mid-line.\n */\nexport function truncateLogFile(logFile: string): void {\n try {\n const stat = fs.statSync(logFile);\n if (stat.size > MAX_LOG_SIZE) {\n const buf = Buffer.alloc(KEEP_SIZE);\n const fd = fs.openSync(logFile, 'r');\n fs.readSync(fd, buf, 0, KEEP_SIZE, stat.size - KEEP_SIZE);\n fs.closeSync(fd);\n const firstNewline = buf.indexOf(10);\n const trimmed = firstNewline >= 0 ? buf.subarray(firstNewline + 1) : buf;\n fs.writeFileSync(logFile, trimmed);\n }\n } catch {\n // File may not exist yet — that's fine\n }\n}\n\n/**\n * Set up debug logging. When {@link MASTRA_DEBUG} is `\"true\"`, redirects\n * `console.error` and `console.warn` to a log file (truncating it first if\n * oversized). Otherwise silences them to avoid corrupting the TUI.\n */\nexport function setupDebugLogging(): void {\n const debugEnabled = ['true', '1'].includes(process.env.MASTRA_DEBUG ?? '');\n\n if (debugEnabled) {\n const logFile = path.join(getAppDataDir(), 'debug.log');\n truncateLogFile(logFile);\n\n const logStream = fs.createWriteStream(logFile, { flags: 'a' });\n const fmt = (a: unknown): string => {\n if (typeof a === 'string') return a;\n if (a instanceof Error) return a.stack ?? `${a.name}: ${a.message}`;\n try {\n return JSON.stringify(a);\n } catch {\n return String(a);\n }\n };\n console.error = (...args: unknown[]) => {\n logStream.write(`[ERROR] ${new Date().toISOString()} ${args.map(fmt).join(' ')}\\n`);\n };\n console.warn = (...args: unknown[]) => {\n logStream.write(`[WARN] ${new Date().toISOString()} ${args.map(fmt).join(' ')}\\n`);\n };\n } else {\n const noop = () => {};\n console.error = noop;\n console.warn = noop;\n }\n}\n"],"mappings":";;;;AAKA,MAAM,eAAe;AACrB,MAAM,YAAY;;;;;AAMlB,SAAgB,gBAAgB,SAAuB;CACrD,IAAI;EACF,MAAM,OAAOA,KAAG,SAAS,OAAO;EAChC,IAAI,KA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 @@
|
|
|
1
|
-
{"version":3,"file":"discarding-scores-storage.d.ts","sourceRoot":"","sources":["../../src/utils/discarding-scores-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;;;;;;;;;GAUG;AACH,qBAAa,uBAAwB,SAAQ,aAAa;IAClD,YAAY,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAEjD;IAEK,SAAS,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,YAAY,CAAA;KAAE,CAAC,CAGzE;IAEK,oBAAoB,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,iBAAiB,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAEzG;IAEK,iBAAiB,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,iBAAiB,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAEtG;IAEK,oBAAoB,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,iBAAiB,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAEzG;IAEK,gBAAgB,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,iBAAiB,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAErG;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discarding-scores-storage.js","names":[],"sources":["../../src/utils/discarding-scores-storage.ts"],"sourcesContent":["import type { ListScoresResponse, SaveScorePayload, ScoreRowData } from '@mastra/core/evals';\nimport { ScoresStorage } from '@mastra/core/storage';\nimport type { StoragePagination } from '@mastra/core/storage';\n\n/**\n * A scores domain that accepts writes and keeps nothing.\n *\n * mastracode's `outcome` and `efficiency` scorers persist every result through\n * the scores domain (`validateAndSaveScore` → `getStore('scores')`), but nothing\n * in mastracode reads scores back. Writing them to libsql grew mastra.db without\n * bound, and an in-memory store would grow the heap for the life of the process\n * instead (each payload carries the system prompt, messages, input and output).\n * Disabling the domain is not an option: core throws\n * MASTRA_SCORES_STORAGE_NOT_AVAILABLE on every scorer run when it is missing.\n */\nexport class DiscardingScoresStorage extends ScoresStorage {\n async getScoreById(): Promise<ScoreRowData | null> {\n return null;\n }\n\n async saveScore(score: SaveScorePayload): Promise<{ score: ScoreRowData }> {\n const now = new Date();\n return { score: { ...score, id: score.id ?? crypto.randomUUID(), createdAt: now, updatedAt: now } as ScoreRowData };\n }\n\n async listScoresByScorerId({ pagination }: { pagination: StoragePagination }): Promise<ListScoresResponse> {\n return empty(pagination);\n }\n\n async listScoresByRunId({ pagination }: { pagination: StoragePagination }): Promise<ListScoresResponse> {\n return empty(pagination);\n }\n\n async listScoresByEntityId({ pagination }: { pagination: StoragePagination }): Promise<ListScoresResponse> {\n return empty(pagination);\n }\n\n async listScoresBySpan({ pagination }: { pagination: StoragePagination }): Promise<ListScoresResponse> {\n return empty(pagination);\n }\n}\n\nfunction empty(pagination: StoragePagination): ListScoresResponse {\n return { pagination: { total: 0, page: pagination.page, perPage: pagination.perPage, hasMore: false }, scores: [] };\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,IAAa,0BAAb,cAA6C,cAAc;CACzD,MAAM,eAA6C;EACjD,OAAO;CACT;CAEA,MAAM,UAAU,OAA2D;EACzE,MAAM,sBAAM,IAAI,KAAK;EACrB,OAAO,EAAE,OAAO;GAAE,GAAG;GAAO,IAAI,MAAM,MAAM,OAAO,WAAW;GAAG,WAAW;GAAK,WAAW;EAAI,EAAkB;CACpH;CAEA,MAAM,qBAAqB,EAAE,cAA8E;EACzG,OAAO,MAAM,UAAU;CACzB;CAEA,MAAM,kBAAk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AAO,GAAE;IACP,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD,GACL,OAAO,CAAC,CAAC,CAAC,CA6BZ"}
|
package/dist/utils/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":[],"sources":["../../src/utils/errors.ts"],"sourcesContent":["/**\n * Error handling utilities for the Mastra Code TUI.\n * Parses API errors and provides user-friendly messages.\n */\n\nimport { classifyProviderError } from '@mastra/core/error';\n\nimport { PROVIDER_AUTH_REQUIRED_ERROR } from '../auth/provider-auth-error.js';\n\nexport interface ParsedError {\n /** User-friendly error message */\n message: string;\n /** Extra diagnostic detail to surface to the user */\n detail?: string;\n /** Request URL involved in the failure, when available */\n requestUrl?: string;\n /** Error type for categorization */\n type: ErrorType;\n /** Whether this error is retryable */\n retryable: boolean;\n /** Suggested retry delay in ms (if retryable) */\n retryDelay?: number;\n /** Original error for debugging */\n originalError: Error;\n}\n\nexport type ErrorType =\n | 'rate_limit'\n | 'quota'\n | 'auth'\n | 'network'\n | 'timeout'\n | 'invalid_request'\n | 'server_error'\n | 'model_not_found'\n | 'context_length'\n | 'content_filter'\n | 'unknown';\n\n/**\n * Parse an error and return a user-friendly representation.\n */\nfunction summarizeErrorDetail(error: unknown): string | undefined {\n if (error instanceof Error) {\n if (error.cause instanceof Error && error.cause.message) {\n return error.cause.message;\n }\n\n if (typeof error.cause === 'string' && error.cause.trim().length > 0) {\n return error.cause;\n }\n\n if (error.message.trim().length > 0) {\n return error.message;\n }\n }\n\n if (typeof error === 'string' && error.trim().length > 0) {\n return error;\n }\n\n if (error && typeof error === 'object') {\n const errorObj = error as Record<string, unknown>;\n const candidates = [errorObj['message'], errorObj['cause'], errorObj['code'], errorObj['statusText']];\n\n for (const candidate of candidates) {\n if (typeof candidate === 'string' && candidate.trim().length > 0) {\n return candidate;\n }\n }\n }\n\n return undefined;\n}\n\nfunction extractRequestUrl(error: unknown): string | undefined {\n if (!error || typeof error !== 'object') {\n return undefined;\n }\n\n const candidates: unknown[] = [];\n const errorObj = error as Record<string, unknown>;\n candidates.push(errorObj['requestUrl'], errorObj['url']);\n\n if (errorObj['cause'] && typeof errorObj['cause'] === 'object') {\n const causeObj = errorObj['cause'] as Record<string, unknown>;\n candidates.push(causeObj['requestUrl'], causeObj['url']);\n }\n\n for (const candidate of candidates) {\n if (typeof candidate === 'string' && candidate.trim().length > 0) {\n return candidate;\n }\n }\n\n return undefined;\n}\n\n/** A flattened error crossing the wire: the server sends `{ name, message }`, not an `Error`. */\nfunction isSerializedError(value: unknown): value is { name: string; message: string } {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'name' in value &&\n typeof value.name === 'string' &&\n 'message' in value &&\n typeof value.message === 'string'\n );\n}\n\nfunction toError(error: unknown): Error {\n if (error instanceof Error) return error;\n if (!isSerializedError(error)) return new Error(String(error));\n const rebuilt = new Error(error.message);\n rebuilt.name = error.name;\n return rebuilt;\n}\n\nfunction errorTypeOf(error: unknown, message: string, status: unknown): ErrorType {\n const kind = classifyProviderError(typeof status === 'number' ? { statusCode: status, cause: error } : error);\n if (kind === 'quota') return 'quota';\n if (kind === 'rate_limited' || status === 429 || message.includes('429')) return 'rate_limit';\n if (\n kind === 'auth' ||\n status === 401 ||\n status === 403 ||\n (kind !== 'unavailable' &&\n (message.includes('unauthorized') || message.includes('authentication') || message.includes('api key')))\n ) {\n return 'auth';\n }\n if (\n message.includes('network') ||\n message.includes('econnrefused') ||\n message.includes('enotfound') ||\n message.includes('fetch failed') ||\n message.includes('connection')\n ) {\n return 'network';\n }\n if (kind === 'timeout') return 'timeout';\n if (kind === 'model_rejected' || message.includes('does not exist')) return 'model_not_found';\n if (\n kind === 'context_overflow' ||\n message.includes('context length') ||\n message.includes('too many tokens') ||\n message.includes('token limit')\n ) {\n return 'context_length';\n }\n if (\n message.includes('content filter') ||\n message.includes('content_filter') ||\n message.includes('content policy') ||\n message.includes('safety') ||\n message.includes('prohibited')\n ) {\n return 'content_filter';\n }\n if (kind === 'unavailable' || (typeof status === 'number' && status >= 500 && status < 600)) return 'server_error';\n if (\n kind === 'invalid_request' ||\n kind === 'tool_history_rejected' ||\n status === 400 ||\n message.includes('invalid request') ||\n message.includes('bad request')\n ) {\n return 'invalid_request';\n }\n return 'unknown';\n}\n\nexport function parseError(error: unknown): ParsedError {\n const err = toError(error);\n const errorObj = (typeof error === 'object' && error !== null ? error : {}) as Record<string, unknown>;\n const detail = summarizeErrorDetail(error);\n const requestUrl = extractRequestUrl(error);\n\n // Matched by name, not instance: the error may have crossed a serialization boundary.\n if (err.name === PROVIDER_AUTH_REQUIRED_ERROR) {\n return { message: err.message, detail, requestUrl, type: 'auth', retryable: false, originalError: err };\n }\n\n const message = err.message.toLowerCase();\n const type = errorTypeOf(error, message, errorObj.statusCode ?? errorObj.status);\n\n switch (type) {\n case 'quota':\n return {\n message: 'Usage quota exhausted for this provider account.',\n detail,\n requestUrl,\n type,\n retryable: false,\n originalError: err,\n };\n case 'rate_limit':\n return {\n message: 'Rate limited. Please wait a moment before trying again.',\n type,\n retryable: true,\n retryDelay: extractRetryAfter(errorObj) || 5000,\n originalError: err,\n };\n case 'auth':\n return {\n message:\n (errorObj.statusCode ?? errorObj.status) === 403\n ? 'Access denied. You may not have permission to use this model.'\n : 'Authentication failed. Check the credential configured for this provider.',\n detail,\n requestUrl,\n type,\n retryable: false,\n originalError: err,\n };\n case 'network':\n return {\n message: 'Network error while contacting the provider or gateway.',\n detail,\n requestUrl,\n type,\n retryable: true,\n retryDelay: 2000,\n originalError: err,\n };\n case 'timeout':\n return {\n message: 'Request timed out. The server may be overloaded.',\n type,\n retryable: true,\n retryDelay: 3000,\n originalError: err,\n };\n case 'model_not_found':\n return {\n message: 'Model not found. Please select a different model with /models.',\n type,\n retryable: false,\n originalError: err,\n };\n case 'context_length':\n return {\n message: 'Message too long. Try starting a new thread with /new.',\n type,\n retryable: false,\n originalError: err,\n };\n case 'content_filter':\n // Anthropic reports some safety rejections as a 400 for the entire request,\n // rather than as a refusal finish reason. Preserve that provider wording so\n // users can distinguish the rejection from a generated response being filtered.\n return {\n message:\n \"The provider's safety system blocked this request. This is often a false positive on code, security, or credential-like text.\",\n detail: err.message.trim() ? err.message : detail,\n requestUrl,\n type,\n retryable: false,\n originalError: err,\n };\n case 'server_error':\n return {\n message: 'Server error. The API may be experiencing issues.',\n type,\n retryable: true,\n retryDelay: 5000,\n originalError: err,\n };\n case 'invalid_request':\n return {\n message: `Invalid request: ${extractErrorDetail(err)}`,\n type,\n retryable: false,\n originalError: err,\n };\n case 'unknown':\n return {\n message: extractErrorDetail(err),\n type,\n retryable: false,\n originalError: err,\n };\n }\n}\n\n/**\n * Extract retry-after header value from error.\n */\nfunction extractRetryAfter(error: Record<string, unknown>): number | undefined {\n const headers = error.headers as Record<string, unknown> | undefined;\n const retryAfter = error.retryAfter || headers?.['retry-after'];\n if (typeof retryAfter === 'number') {\n return retryAfter * 1000; // Convert seconds to ms\n }\n if (typeof retryAfter === 'string') {\n const seconds = parseInt(retryAfter, 10);\n if (!isNaN(seconds)) {\n return seconds * 1000;\n }\n }\n return undefined;\n}\n\n/**\n * Extract a useful error detail from an error object.\n */\nfunction extractErrorDetail(error: Error): string {\n const errorObj = error as unknown as Record<string, unknown>;\n\n // Try to get a specific error message from common API error formats\n if (errorObj.error && typeof errorObj.error === 'object') {\n const apiError = errorObj.error as Record<string, unknown>;\n if (apiError.message) return String(apiError.message);\n }\n\n if (errorObj.message) return String(errorObj.message);\n if (errorObj.detail) return String(errorObj.detail);\n if (errorObj.reason) return String(errorObj.reason);\n\n // Clean up the error message\n let message = error.message;\n\n // Remove common prefixes\n message = message.replace(/^(error|exception|failed):\\s*/i, '');\n\n // Truncate very long messages\n if (message.length > 200) {\n message = message.substring(0, 200) + '...';\n }\n\n return message || 'An unknown error occurred';\n}\n\n/**\n * Sleep for a given number of milliseconds.\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n\n/**\n * Retry a function with exponential backoff.\n */\nexport async function withRetry<T>(\n fn: () => Promise<T>,\n options: {\n maxRetries?: number;\n initialDelay?: number;\n maxDelay?: number;\n onRetry?: (error: ParsedError, attempt: number) => void;\n } = {},\n): Promise<T> {\n const { maxRetries = 3, initialDelay = 1000, maxDelay = 30000, onRetry } = options;\n\n let lastError: ParsedError | undefined;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = parseError(error);\n\n // Don't retry non-retryable errors\n if (!lastError.retryable || attempt === maxRetries) {\n throw lastError.originalError;\n }\n\n // Calculate delay with exponential backoff\n const delay = Math.min(lastError.retryDelay || initialDelay * Math.pow(2, attempt), maxDelay);\n\n if (onRetry) {\n onRetry(lastError, attempt + 1);\n }\n\n await sleep(delay);\n }\n }\n\n // Should never reach here, but TypeScript needs this\n throw lastError?.originalError || new Error('Retry failed');\n}\n"],"mappings":";;;;;;;;;;AA0CA,SAAS,qBAAqB,OAAoC;CAChE,IAAI,iBAAiB,OAAO;EAC1B,IAAI,MAAM,iBAAiB,SAAS,MAAM,MAAM,SAC9C,OAAO,MAAM,MAAM;EAGrB,IAAI,OAAO,MAAM,UAAU,YAAY,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,GACjE,OAAO,MAAM;EAGf,IAAI,MAAM,QAAQ,KAAK,CAAC,CAAC,SAAS,GAChC,OAAO,MAAM;CAEjB;CAEA,IAAI,OAAO,UAAU,YAAY,MAAM,KAAK,CAAC,CAAC,SAAS,GACrD,OAAO;CAGT,IAAI,SAAS,OAAO,UAAU,UAAU;EACtC,MAAM,WAAW;EACjB,MAAM,aAAa;GAAC,SAAS;GAAY,SAAS;GAAU,SAAS;GAAS,SAAS;EAAa;EAEpG,KAAK,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AEG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAKtC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-sync.js","names":[],"sources":["../../src/utils/gateway-sync.ts"],"sourcesContent":["/**\n * Gateway sync utility for keeping the model registry up to date.\n *\n * This is a thin wrapper around `@mastra/core/llm`'s `GatewayRegistry` so\n * mastracode and `mastra dev` share a single implementation for fetching\n * providers, generating types, and writing to the global cache. Keep this\n * file small — provider/registry logic belongs in `@mastra/core`.\n */\n\nimport { GatewayRegistry } from '@mastra/core/llm';\n\nconst DEFAULT_SYNC_INTERVAL_MS = 5 * 60 * 1000;\n\nlet syncInterval: NodeJS.Timeout | null = null;\nlet isSyncing = false;\n\nfunction getRegistry(): GatewayRegistry {\n return GatewayRegistry.getInstance({ useDynamicLoading: true });\n}\n\n/**\n * Sync gateways and update the global cache via `@mastra/core`'s registry.\n *\n * Skips the sync if the global cache was refreshed within the last\n * `DEFAULT_SYNC_INTERVAL_MS`, unless `force` is set. Multiple calls in\n * the same process coalesce while a sync is in flight.\n */\nexport async function syncGateways(force = false): Promise<void> {\n if (isSyncing && !force) {\n return;\n }\n\n if (!force) {\n const lastSync = getRegistry().getLastRefreshTime();\n if (lastSync && Date.now() - lastSync.getTime() < DEFAULT_SYNC_INTERVAL_MS) {\n return;\n }\n }\n\n isSyncing = true;\n try {\n await getRegistry().syncGateways(true);\n } catch {\n // Silently ignore — the bundled registry already contains all model\n // data so a failed network fetch is non-critical.\n } finally {\n isSyncing = false;\n }\n}\n\n/**\n * Start periodic gateway sync.\n * @param intervalMs Sync interval in milliseconds (default: 5 minutes)\n */\nexport function startGatewaySync(intervalMs = DEFAULT_SYNC_INTERVAL_MS): void {\n if (syncInterval) {\n return;\n }\n\n // Do an initial sync (will skip if recently synced)\n syncGateways().catch(() => {});\n\n // Set up periodic sync\n syncInterval = setInterval(() => {\n syncGateways().catch(() => {});\n }, intervalMs);\n\n // Don't prevent process exit\n syncInterval.unref();\n}\n\n/**\n * Stop periodic gateway sync.\n */\nexport function stopGatewaySync(): void {\n if (syncInterval) {\n clearInterval(syncInterval);\n syncInterval = null;\n }\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAM,2BAA2B;AAEjC,IAAI,eAAsC;AAC1C,IAAI,YAAY;AAEhB,SAAS,cAA+B;CACtC,OAAO,gBAAgB,YAAY,EAAE,mBAAmB,KAAK,CAAC;AAChE;;;;;;;;AASA,eAAsB,aAAa,QAAQ,OAAsB;CAC/D,IAAI,aAAa,CAAC,OAChB;CAGF,IAAI,CAAC,OAAO;EACV,MAAM,WAAW,YAAY,CAAC,CAAC,mBAAmB;EAClD,IAAI,YAAY,KAAK,IAAI,IAAI,SAAS,QAAQ,IAAI,0BAChD;CAEJ;CAEA,YAAY;CACZ,IAAI;EACF,MAAM,YAAY,CAAC,CAAC,aAAa,IAAI;CACvC,QAAQ,CAGR,UAAU;EACR,YAAY;CACd;AACF;;;;;AAMA,SAAgB,iBAAiB,aAAa,0BAAgC;CAC5E,IAAI,cACF;CAIF,aAAa,CAAC,CAAC,YAAY,CAAC,CAAC;CAG7B,eAAe,kBAAkB;EAC/B,aAAa,CAAC,CAAC,YAAY,CAAC,CAAC;CAC/B,GAAG,UAAU;CAGb,aAAa,MAAM;AACrB;;;;AAKA,SAAgB,kBAAwB;CACtC,IAAI,cAAc;EAChB,cAAc,YAAY;EAC1B,eAAe;CACjB;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local-observability.d.ts","sourceRoot":"","sources":["../../src/utils/local-observability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,EAAE,eAQ3C,CAAC;AAqBF;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,MAAM,GACX,OAAO,CAAC;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;CAAE,CAAC,CAQjE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local-observability.js","names":[],"sources":["../../src/utils/local-observability.ts"],"sourcesContent":["import type { PruneResult, RetentionConfig } from '@mastra/core/storage';\nimport type { DuckDBStore } from '@mastra/duckdb';\n\n/**\n * Age limits for the local trace store: 14 days for spans, metrics and logs,\n * 30 days for scores and feedback. Spans, logs and scores use the same windows\n * as libsql's `DEFAULT_RETENTION`, which has no metrics or feedback entries.\n */\nexport const LOCAL_OBSERVABILITY_RETENTION: RetentionConfig = {\n observability: {\n spans: { maxAge: '14d' },\n metrics: { maxAge: '14d' },\n logs: { maxAge: '14d' },\n scores: { maxAge: '30d' },\n feedback: { maxAge: '30d' },\n },\n};\n\n/** Upper bound on rows deleted per table per session, so startup pruning never runs long. */\nconst MAX_ROWS_PER_OPEN = 50_000;\n\nconst OBSERVABILITY_TABLES = ['span_events', 'metric_events', 'log_events', 'score_events', 'feedback_events'];\n\n/**\n * Prune only when every observability table already exists. A brand-new file\n * has no tables until the session composite runs init(), and pruning it would\n * log a missing-table error from the storage layer for a file with nothing to delete.\n */\nasync function pruneExistingTables(store: DuckDBStore): Promise<PruneResult[]> {\n const existing = await store.db.query<{ table_name: string }>(\n `SELECT table_name FROM information_schema.tables WHERE table_name IN (${OBSERVABILITY_TABLES.map(() => '?').join(', ')})`,\n OBSERVABILITY_TABLES,\n );\n if (existing.length < OBSERVABILITY_TABLES.length) return [];\n return store.prune({ maxRows: MAX_ROWS_PER_OPEN, pauseMs: 10 });\n}\n\n/**\n * Open the local observability DuckDB file used when `/observability local on`.\n * Connects eagerly so a lock error surfaces now, not mid-session, then prunes\n * aged events in the background so the file cannot grow without bound.\n * `pruned` never rejects; anything left over is pruned on the next open.\n */\nexport async function openLocalObservabilityStore(\n path: string,\n): Promise<{ store: DuckDBStore; pruned: Promise<PruneResult[]> }> {\n // Loaded on demand: DuckDB's native binding adds ~25 MB to every session that never turns this on.\n const { DuckDBStore } = await import('@mastra/duckdb');\n const store = new DuckDBStore({ id: 'mastra-code-observability', path, retention: LOCAL_OBSERVABILITY_RETENTION });\n await store.db.query('SELECT 1');\n // No init() here: the session composite initializes the domain.\n const pruned = pruneExistingTables(store).catch(() => []);\n return { store, pruned };\n}\n"],"mappings":";;;;;;AAQA,MAAa,gCAAiD,EAC5D,eAAe;CACb,OAAO,EAAE,QAAQ,MAAM;CACvB,SAAS,EAAE,QAAQ,MAAM;CACzB,MAAM,EAAE,QAAQ,MAAM;CACtB,QAAQ,EAAE,QAAQ,MAAM;CACxB,UAAU,EAAE,QAAQ,MAAM;AAC5B,EACF;;AAGA,MAAM,oBAAoB;AAE1B,MAAM,uBAAuB;CAAC;CAAe;CAAiB;CAAc;CAAgB;AAAiB;;;;;;AAO7G,eAAe,oBAAoB,OAA4C;CAK7E,KAAI,MAJmB,MAAM,GAAG,MAC9B,yEAAyE,qBAAqB,UAAU,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,IACxH,oBACF,EAAA,CACa,SAAS,qBAAqB,QAAQ,OAAO,CAAC;CAC3D,OAAO,MAAM,MAAM;EAAE,SAAS;EAAmB,SAAS;CAAG,CAAC;AAChE;;;;;;;AAQA,eAAsB,4BACpB,MACiE;CAEjE,MAAM,EAAE,gBAAgB,MAAM,OAAO;CACrC,MAAM,QAAQ,IAAI,YAAY;EAAE,IAAI;EAA6B;EAAM,WAAW;CAA8B,CAAC;CACjH,MAAM,MAAM,GAAG,MAAM,UAAU;CAG/B,OAAO;EAAE;EAAO,QADD,oBAAoB,KAAK,CAAC,CAAC,YAAY,CAAC,CAClC;CAAE;AACzB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"maintenance-lock.d.ts","sourceRoot":"","sources":["../../src/utils/maintenance-lock.ts"],"names":[],"mappings":"AAiBA,qBAAa,oBAAqB,SAAQ,KAAK;aAG3B,SAAS,EAAE,MAAM,EAAE;IAFrC,YACE,OAAO,EAAE,MAAM,EACC,SAAS,EAAE,MAAM,EAAE,EAIpC;CACF;AAcD,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED,iFAAiF;AACjF,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,OAAQ,CAAC;AAuCjD;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,IAAI,CAgBvD;AAED,+EAA+E;AAC/E,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAmB7C;AAOD,yFAAyF;AACzF,wBAAgB,mCAAmC,IAAI,IAAI,CAG1D;AAYD,+FAA+F;AAC/F,wBAAgB,eAAe,IAAI,IAAI,CAStC;AAED,0DAA0D;AAC1D,wBAAgB,iBAAiB,IAAI,IAAI,CAIxC;AAED;;;;GAIG;AACH,wBAAsB,oCAAoC,CAAC,EACzD,SAAoB,EACpB,MAAY,EACZ,MAAM,GACP,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBnG;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,IAAI,CA0CnD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"maintenance-lock.js","names":[],"sources":["../../src/utils/maintenance-lock.ts"],"sourcesContent":["/**\n * Mutual exclusion between storage maintenance (`mastracode prune`) and running\n * mastracode sessions, using the same pid-file / stale-PID pattern as\n * thread-lock.ts.\n *\n * - Every process that opens storage registers a session pid file.\n * - `prune` holds `maintenance.lock` for its whole run.\n *\n * The checks are ordered so the race is closed both ways: `prune` acquires the\n * lock and THEN looks for live sessions; a starter registers and THEN looks for\n * the lock. Whichever acts second always sees the other.\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { getAppDataDir } from './project.js';\n\nexport class MaintenanceLockError extends Error {\n constructor(\n message: string,\n public readonly ownerPids: number[],\n ) {\n super(message);\n this.name = 'MaintenanceLockError';\n }\n}\n\nfunction getLocksDir(): string {\n const dir = path.join(getAppDataDir(), 'locks');\n fs.mkdirSync(dir, { recursive: true });\n return dir;\n}\n\nfunction getSessionsDir(): string {\n const dir = path.join(getLocksDir(), 'sessions');\n fs.mkdirSync(dir, { recursive: true });\n return dir;\n}\n\nexport function getMaintenanceLockPath(): string {\n return path.join(getLocksDir(), 'maintenance.lock');\n}\n\n/** Owner of a lock whose pid file is still being written (PID not known yet). */\nexport const UNKNOWN_OWNER = -1;\n\n/**\n * Creating a pid file (open, then write) is not atomic, so an empty or\n * unparseable file may belong to a process that is mid-write. Only treat it as\n * stale once it is older than this.\n */\nexport const MALFORMED_PID_FILE_GRACE_MS = 5_000;\n\nfunction isProcessAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n // Only ESRCH proves the process is gone; EPERM etc. mean it exists.\n return (error as NodeJS.ErrnoException).code !== 'ESRCH';\n }\n}\n\n/** Whether a pid file with no readable PID is old enough to reap. Missing files count as reapable. */\nfunction isMalformedPidFileStale(file: string): boolean {\n try {\n return Date.now() - fs.statSync(file).mtimeMs > MALFORMED_PID_FILE_GRACE_MS;\n } catch {\n return true;\n }\n}\n\nfunction describeOwners(pids: number[]): string {\n const known = pids.filter(pid => pid !== UNKNOWN_OWNER);\n return known.length > 0 ? ` (PID ${known.join(', ')})` : '';\n}\n\nfunction readPid(file: string): number | null {\n try {\n const pid = parseInt(fs.readFileSync(file, 'utf-8').trim(), 10);\n return isNaN(pid) ? null : pid;\n } catch {\n return null;\n }\n}\n\n// True while this process holds maintenance.lock, so an own-PID lock can be told\n// apart from a stale leftover whose PID we reused.\nlet lockHeld = false;\n\n/**\n * PID holding the maintenance lock, `UNKNOWN_OWNER` while its pid file is still\n * being written, or null. Stale locks are removed.\n */\nexport function getMaintenanceLockOwner(): number | null {\n const lockPath = getMaintenanceLockPath();\n if (!fs.existsSync(lockPath)) return null;\n const pid = readPid(lockPath);\n if (pid === process.pid) {\n // We hold it (e.g. a concurrent prune in this process): a live owner.\n if (lockHeld) return pid;\n // Otherwise it is a leftover from a dead process whose PID we reused.\n } else if (pid !== null && isProcessAlive(pid)) {\n return pid;\n }\n if (pid === null && !isMalformedPidFileStale(lockPath)) return UNKNOWN_OWNER;\n try {\n fs.unlinkSync(lockPath);\n } catch {}\n return null;\n}\n\n/** PIDs of other live registered sessions. Stale registrations are removed. */\nexport function getLiveSessionPids(): number[] {\n const dir = getSessionsDir();\n const live: number[] = [];\n for (const file of fs.readdirSync(dir)) {\n if (!file.endsWith('.pid')) continue;\n const filePath = path.join(dir, file);\n const pid = readPid(filePath);\n if (pid === process.pid) continue;\n if (pid !== null && isProcessAlive(pid)) {\n live.push(pid);\n } else if (pid === null && !isMalformedPidFileStale(filePath)) {\n live.push(UNKNOWN_OWNER);\n } else {\n try {\n fs.unlinkSync(filePath);\n } catch {}\n }\n }\n return live;\n}\n\n// Refcounted: one process may start several sessions (e.g. repeated\n// createMastraCode() calls). The pid file exists while the count is > 0.\nlet sessionRefs = 0;\nlet exitHookInstalled = false;\n\n/** Test-only: drop every registration held by this process and forget lock ownership. */\nexport function resetSessionRegistrationsForTesting(): void {\n while (sessionRefs > 0) unregisterSession();\n lockHeld = false;\n}\n\nfunction getSessionPidPath(): string {\n return path.join(getSessionsDir(), `${process.pid}.pid`);\n}\n\nfunction removeSessionPidFile(): void {\n try {\n fs.unlinkSync(getSessionPidPath());\n } catch {}\n}\n\n/** Register one running session in this process. Pair with exactly one unregisterSession(). */\nexport function registerSession(): void {\n if (sessionRefs === 0) {\n fs.writeFileSync(getSessionPidPath(), String(process.pid), { mode: 0o644 });\n }\n sessionRefs++;\n if (!exitHookInstalled) {\n exitHookInstalled = true;\n process.once('exit', removeSessionPidFile);\n }\n}\n\n/** Release one registration made by registerSession(). */\nexport function unregisterSession(): void {\n if (sessionRefs === 0) return;\n sessionRefs--;\n if (sessionRefs === 0) removeSessionPidFile();\n}\n\n/**\n * Register this session, then wait for any running maintenance to finish.\n * Waits indefinitely by default: a vacuum on a multi-GB database can take\n * minutes. With `timeoutMs`, throws after that long naming the holder.\n */\nexport async function registerSessionAndWaitForMaintenance({\n timeoutMs = Infinity,\n pollMs = 250,\n onWait,\n}: { timeoutMs?: number; pollMs?: number; onWait?: (ownerPid: number) => void } = {}): Promise<void> {\n registerSession();\n const deadline = Date.now() + timeoutMs;\n let notified = false;\n for (;;) {\n const owner = getMaintenanceLockOwner();\n if (owner === null) return;\n if (!notified) {\n notified = true;\n onWait?.(owner);\n }\n if (Date.now() >= deadline) {\n unregisterSession();\n throw new MaintenanceLockError(\n `Storage maintenance (mastracode prune${describeOwners([owner])}) is still running after ${Math.round(timeoutMs / 1000)}s. ` +\n `Wait for it to finish, or stop it, then start mastracode again.`,\n [owner],\n );\n }\n await new Promise(resolve => setTimeout(resolve, pollMs));\n }\n}\n\n/**\n * Acquire the maintenance lock, then refuse if any mastracode session is live.\n * Returns a release function.\n */\nexport function acquireMaintenanceLock(): () => void {\n const lockPath = getMaintenanceLockPath();\n for (let attempt = 0; ; attempt++) {\n try {\n // 'wx' makes creation atomic, so two prunes cannot both win.\n fs.writeFileSync(lockPath, String(process.pid), { flag: 'wx', mode: 0o644 });\n lockHeld = true;\n break;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error;\n // getMaintenanceLockOwner() removes a stale lock, so the retry can win.\n const owner = getMaintenanceLockOwner();\n if (owner !== null || attempt > 0) {\n throw new MaintenanceLockError(\n `Another mastracode prune is already running${owner === null ? '' : describeOwners([owner])}.`,\n owner === null ? [] : [owner],\n );\n }\n }\n }\n\n let released = false;\n const release = () => {\n if (released) return;\n released = true;\n lockHeld = false;\n if (readPid(lockPath) === process.pid) {\n try {\n fs.unlinkSync(lockPath);\n } catch {}\n }\n };\n\n const sessions = getLiveSessionPids();\n if (sessions.length > 0) {\n release();\n throw new MaintenanceLockError(\n `mastracode is running${describeOwners(sessions)}. Exit every mastracode session before running prune.`,\n sessions,\n );\n }\n return release;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,IAAa,uBAAb,cAA0C,MAAM;CAG5B;CAFlB,YACE,SACA,WACA;EACA,MAAM,OAAO;EAFG,KAAA,YAAA;EAGhB,KAAK,OAAO;CACd;AACF;AAEA,SAAS,cAAsB;CAC7B,MAAM,MAAM,KAAK,KAAK,cAAc,GAAG,OAAO;CAC9C,GAAG,UAAU,KAAK,EAAE,WAAW,KAAK,CAAC;CACrC,OAAO;AACT;AAEA,SAAS,iBAAyB;CAChC,MAAM,MAAM,KAAK,KAAK,YAAY,GAAG,UAAU;CAC/C,GAAG,UAAU,KAAK,EAAE,WAAW,KAAK,CAAC;CACrC,OAAO;AACT;AAEA,SAAgB,yBAAiC;CAC/C,OAAO,KAAK,KAAK,YAAY,GAAG,kBAAkB;AACpD;;AAGA,MAAa,gBAAgB;;;;;;AAO7B,MAAa,8BAA8B;AAE3C,SAAS,eAAe,KAAsB;CAC5C,IAAI;EACF,QAAQ,KAAK,KAAK,CAAC;EACnB,OAAO;CACT,SAAS,OAAO;EAEd,OAAQ,MAAgC,SAAS;CACnD;AACF;;AAGA,SAAS,wBAAwB,MAAuB;CACtD,IAAI;EACF,OAAO,KAAK,IAAI,IAAI,GAAG,SAAS,IAAI,CAAC,CAAC,UAAU;CAClD,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,eAAe,MAAwB;CAC9C,MAAM,QAAQ,KAAK,QAAO,QAAO,QAAA,EAAqB;CACtD,OAAO,MAAM,SAAS,IAAI,SAAS,MAAM,KAAK,IAAI,EAAE,KAAK;AAC3D;AAEA,SAAS,QAAQ,MAA6B;CAC5C,IAAI;EACF,MAAM,MAAM,SAAS,GAAG,aAAa,MAAM,O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ClD,SAAS,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACpC;;;OAGG;IACH,gBAAgB,EAAE,MAAM,QAAQ,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;IACjF;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,oCAAoC,CAAC,OAAO,EAAE,qCAAqC;sBA2EhF,OAAO;aAGb,IAAI;YAMC,OAAO,CAAC,IAAI,CAAC;IAM3B,iEAAiE;gBA1BlD,OAAO,CAAC,IAAI,CAAC;EA6B/B;AAED,MAAM,MAAM,8BAA8B,GAAG,UAAU,CAAC,OAAO,oCAAoC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notification-dispatch.js","names":[],"sources":["../../src/utils/notification-dispatch.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { LeaseProvider } from '@mastra/core/events';\nimport type { Mastra } from '@mastra/core/mastra';\nimport { dispatchDueNotifications } from '@mastra/core/notifications';\n\nimport { notificationDispatchLeaseKey } from './signals-pubsub.js';\n\nconst DEFAULT_INTERVAL_MS = 10_000;\nconst DEFAULT_LEASE_TTL_MS = 60_000;\n\n/**\n * The resource the current async context is dispatching notifications for,\n * and which of its dispatch leases this pass holds.\n */\nconst dispatching = new AsyncLocalStorage<{\n resourceId: string;\n /** The resource's own lease: its threads that carry no scope. */\n unscoped: boolean;\n /** The thread scopes whose leases this pass holds. */\n scopes: ReadonlySet<string>;\n}>();\n\n/**\n * Whether this call runs inside this process's own dispatch pass for\n * `resourceId`, holding the lease for threads of `scope` (or with no `scope`,\n * for threads that carry none), as opposed to the dispatch schedule every\n * process sharing the database takes turns running.\n */\nexport function isDispatchingNotificationsFor(resourceId: string, scope?: string): boolean {\n const pass = dispatching.getStore();\n if (pass?.resourceId !== resourceId) return false;\n return scope === undefined ? pass.unscoped : pass.scopes.has(scope);\n}\n\n/**\n * Whether a delivery-time policy should leave a due notification pending\n * (`hold`). Deliveries happen from this process's own dispatch pass for the\n * record's resource, under the lease that covers the record's thread. Anything\n * else holds: a thread no session here owns belongs to another process sharing\n * the database, and once this process's dispatcher runs, its own resources are\n * delivered by whichever process holds their dispatch lease, never by the\n * shared dispatch schedule.\n */\nexport function shouldHoldNotificationDelivery({\n resourceId,\n scope,\n ownedHere,\n dispatcher,\n}: {\n resourceId: string;\n /** The thread's scope (`WakeSession.scope`), unset for a thread that carries none. */\n scope?: string;\n /** Whether a session in this process owns the resource. */\n ownedHere: boolean;\n dispatcher: { readonly running: boolean };\n}): boolean {\n if (isDispatchingNotificationsFor(resourceId, scope)) return false;\n return !ownedHere || dispatcher.running;\n}\n\ntype SessionScope = { resourceId: string; scope?: string };\n\nexport type ResourceNotificationDispatcherOptions = {\n getMastra: () => Mastra | undefined;\n /**\n * The resources this process runs sessions for, each with the thread scope\n * (`threadScopeKey`) of a session serving it, unset when it has none.\n */\n getSessionScopes: () => Iterable<SessionScope> | Promise<Iterable<SessionScope>>;\n /**\n * Cross-process leases. When set, a resource's notifications are dispatched\n * only by the processes holding its dispatch leases, so two processes\n * serving the same resource never both deliver one: the threads of each\n * scope (each project, for processes in different directories) go to the\n * process holding that scope's lease, and threads with no scope to the one\n * holding the resource's own.\n */\n leases?: LeaseProvider;\n /** Unique to this process. */\n owner: string;\n intervalMs?: number;\n leaseTtlMs?: number;\n onError?: (error: unknown) => void;\n};\n\n/**\n * Delivers the due notifications of the resources this process serves, on a\n * timer of its own.\n *\n * Every Mastra Code process shares one database, so one notification store and\n * one dispatch schedule, and the scheduler gives each fire to whichever process\n * claims it first, usually the same one for as long as it runs. That process\n * cannot run another project's thread, so its delivery policy holds those\n * records. Each process therefore dispatches its own resources here.\n */\nexport function createResourceNotificationDispatcher(options: ResourceNotificationDispatcherOptions) {\n const intervalMs = options.intervalMs ?? DEFAULT_INTERVAL_MS;\n const leaseTtlMs = options.leaseTtlMs ?? DEFAULT_LEASE_TTL_MS;\n /** The dispatch lease keys this process holds. */\n const held = new Set<string>();\n let timer: ReturnType<typeof setInterval> | undefined;\n let ticking: Promise<void> | undefined;\n\n const release = async (key: string) => {\n held.delete(key);\n await options.leases?.releaseLease(key, options.owner).catch(options.onError);\n };\n\n const claim = async (key: string): Promise<boolean> => {\n if (!options.leases) return true;\n try {\n // Acquiring a lease this process already holds renews it.\n const { acquired } = await options.leases.acquireLease(key, options.owner, leaseTtlMs);\n if (acquired) held.add(key);\n else held.delete(key);\n return acquired;\n } catch (error) {\n options.onError?.(error);\n return false;\n }\n };\n\n const runTick = async () => {\n const mastra = options.getMastra();\n const storage = await mastra?.getStorage()?.getStore('notifications');\n if (!mastra || !storage) return;\n const scopesByResource = new Map<string, Set<string>>();\n for (const { resourceId, scope } of await options.getSessionScopes()) {\n const scopes = scopesByResource.get(resourceId) ?? new Set<string>();\n if (scope !== undefined) scopes.add(scope);\n scopesByResource.set(resourceId, scopes);\n }\n const wanted = new Set(\n [...scopesByResource].flatMap(([resourceId, scopes]) => [\n notificationDispatchLeaseKey(resourceId),\n ...[...scopes].map(scope => notificationDispatchLeaseKey(resourceId, scope)),\n ]),\n );\n for (const key of [...held]) {\n if (!wanted.has(key)) await release(key);\n }\n for (const [resourceId, scopes] of scopesByResource) {\n if (!timer) continue;\n const unscoped = await claim(notificationDispatchLeaseKey(resourceId));\n const heldScopes = new Set<string>();\n for (const scope of scopes) {\n if (await claim(notificationDispatchLeaseKey(resourceId, scope))) heldScopes.add(scope);\n }\n if (!unscoped && heldScopes.size === 0) continue;\n try {\n await dispatching.run({ resourceId, unscoped, scopes: heldScopes }, () =>\n dispatchDueNotifications({ mastra, storage, resourceId }),\n );\n } catch (error) {\n options.onError?.(error);\n }\n }\n };\n\n const tick = (): Promise<void> => {\n // Ticks run from a timer, so a failure must be reported, never left as an unhandled rejection.\n ticking ??= runTick()\n .catch(error => options.onError?.(error))\n .finally(() => {\n ticking = undefined;\n });\n return ticking;\n };\n\n return {\n get running(): boolean {\n return timer !== undefined;\n },\n start(): void {\n if (timer) return;\n timer = setInterval(() => void tick(), intervalMs);\n timer.unref?.();\n void tick();\n },\n async stop(): Promise<void> {\n if (timer) clearInterval(timer);\n timer = undefined;\n await ticking;\n await Promise.all([...held].map(release));\n },\n /** Runs one dispatch pass now. Only dispatches while started. */\n tick,\n };\n}\n\nexport type ResourceNotificationDispatcher = ReturnType<typeof createResourceNotificationDispatcher>;\n"],"mappings":";;;;AAQA,MAAM,sBAAsB;AAC5B,MAAM,uBAAuB;;;;;AAM7B,MAAM,cAAc,IAAI,kBAMrB;;;;;;;AAQH,SAAgB,8BAA8B,YAAoB,OAAyB;CACzF,MAAM,OAAO,YAAY,SAAS;CAClC,IAAI,MAAM,eAAe,YAAY,OAAO;CAC5C,OAAO,UAAU,KAAA,IAAY,KAAK,WAAW,KAAK,OAAO,IAAI,KAAK;AACpE;;;;;;;;;;AAWA,SAAgB,+BAA+B,EAC7C,YACA,OACA,WACA,cAQU;CACV,IAAI,8BAA8B,YAAY,KAAK,GAAG,OAAO;CAC7D,OAAO,CAAC,aAAa,WAAW;AAClC;;;;;;;;;;;AAqCA,SAAgB,qCAAqC,SAAgD;CACnG,MAAM,aAAa,QAAQ,cAAc;CACzC,MAAM,aAAa,QAAQ,cAAc;;CAEzC,MAAM,uBAAO,IAAI,IAAY;CAC7B,IAAI;CACJ,IAAI;CAEJ,MAAM,UAAU,OAAO,QAAgB;EACrC,KAAK,OAAO,GAAG;EACf,MAAM,QAAQ,QAAQ,aAAa,KAAK,QAAQ,KAAK,CAAC,CAAC,MAAM,QAAQ,OAAO;CAC9E;CAEA,MAAM,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K;GAExF,IAAI,CAAC,YAAY,WAAW,SAAS,GAAG;GACxC,IAAI;IACF,MAAM,YAAY,IAAI;KAAE;KAAY;KAAU,QAAQ;IAAW,SAC/D,yBAAyB;KAAE;KAAQ;KAAS;IAAW,CAAC,CAC1D;GACF,SAAS,OAAO;IACd,QAAQ,UAAU,KAAK;GACzB;EACF;CACF;CAEA,MAAM,aAA4B;EAEhC,YAAY,QAAQ,CAAC,CAClB,OAAM,UAAS,QAAQ,UAAU,KAAK,CAAC,CAAC,CACxC,cAAc;GACb,UAAU,KAAA;EACZ,CAAC;EACH,OAAO;CACT;CAEA,OAAO;EACL,IAAI,UAAmB;GACrB,OAAO,UAAU,KAAA;EACnB;EACA,QAAc;GACZ,IAAI,OAAO;GACX,QAAQ,kBAAkB,KAAK,KAAK,GAAG,UAAU;GACjD,MAAM,QAAQ;GACd,KAAU;EACZ;EACA,MAAM,OAAsB;GAC1B,IAAI,OAAO,cAAc,KAAK;GAC9B,QAAQ,KAAA;GACR,MAAM;GACN,MAAM,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC;EAC1C;;EAEA;CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open-url.d.ts","sourceRoot":"","sources":["../../src/utils/open-url.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAsBlD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open-url.js","names":[],"sources":["../../src/utils/open-url.ts"],"sourcesContent":["/**\n * Best-effort browser opening for OAuth and other login flows.\n */\n\nimport { spawn } from 'node:child_process';\n\n/**\n * Open a URL in the default browser without going through a shell.\n * Only well-formed http(s) URLs are opened; anything else is ignored\n * (the URL is still displayed for the user to open manually).\n */\nexport function openUrlInBrowser(url: string): void {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return;\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n return;\n }\n\n const [cmd, args]: [string, string[]] =\n process.platform === 'darwin'\n ? ['open', [url]]\n : process.platform === 'win32'\n ? ['rundll32', ['url.dll,FileProtocolHandler', url]]\n : ['xdg-open', [url]];\n\n const child = spawn(cmd, args, { stdio: 'ignore', detached: true });\n // Opening the browser is best-effort — the URL is shown to the user as well.\n child.on('error', () => {});\n child.unref();\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,iBAAiB,KAAmB;CAClD,IAAI;CACJ,IAAI;EACF,SAAS,IAAI,IAAI,GAAG;CACtB,QAAQ;EACN;CACF;CACA,IAAI,OAAO,aAAa,WAAW,OAAO,aAAa,UACrD;CAGF,MAAM,CAAC,KAAK,QACV,QAAQ,aAAa,WACjB,CAAC,QAAQ,CAAC,GAAG,CAAC,IACd,QAAQ,aAAa,UACnB,CAAC,YAAY,CAAC,+BAA+B,GAAG,CAAC,IACjD,CAAC,YAAY,CAAC,GAAG,CAAC;CAE1B,MAAM,QAAQ,MAAM,KAAK,MAAM;EAAE,OAAO;EAAU,UAAU;CAAK,CAAC;CAElE,MAAM,GAAG,eAAe,CAAC,CAAC;CAC1B,MAAM,MAAM;AACd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"path-security.d.ts","sourceRoot":"","sources":["../../src/utils/path-security.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMjF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"path-security.js","names":[],"sources":["../../src/utils/path-security.ts"],"sourcesContent":["import path from 'node:path';\n\nexport function isPathWithinRoot(candidatePath: string, rootPath: string): boolean {\n const relativePath = path.relative(rootPath, candidatePath);\n return (\n relativePath === '' ||\n (!relativePath.startsWith(`..${path.sep}`) && relativePath !== '..' && !path.isAbsolute(relativePath))\n );\n}\n"],"mappings":";;AAEA,SAAgB,iBAAiB,eAAuB,UAA2B;CACjF,MAAM,eAAe,KAAK,SAAS,UAAU,aAAa;CAC1D,OACE,iBAAiB,MAChB,CAAC,aAAa,WAAW,KAAK,KAAK,KAAK,KAAK,iBAAiB,QAAQ,CAAC,KAAK,WAAW,YAAY;AAExG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plan-diff.d.ts","sourceRoot":"","sources":["../../src/utils/plan-diff.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,CAkC9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,SAAM,GAAG,OAAO,CASjG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plan-diff.js","names":[],"sources":["../../src/utils/plan-diff.ts"],"sourcesContent":["/**\n * Line-level diffing for plan revisions.\n *\n * Uses a real LCS (longest common subsequence) diff so that inserting or deleting a few\n * lines doesn't mark everything after it as changed. Both the rendered approval diff and\n * the \"is a diff worth showing\" heuristic share this so the heuristic measures the actual\n * diff rather than predicting one.\n */\n\nexport interface DiffEntry {\n type: 'added' | 'removed' | 'context';\n text: string;\n}\n\n/** Produce structured diff entries between two plan texts using an LCS diff. */\nexport function generatePlanDiff(oldText: string, newText: string): DiffEntry[] {\n const oldLines = oldText.split(/\\r?\\n/);\n const newLines = newText.split(/\\r?\\n/);\n const n = oldLines.length;\n const m = newLines.length;\n\n // LCS length table.\n const lcs: number[][] = Array.from({ length: n + 1 }, () => new Array<number>(m + 1).fill(0));\n for (let i = n - 1; i >= 0; i--) {\n for (let j = m - 1; j >= 0; j--) {\n lcs[i]![j] = oldLines[i] === newLines[j] ? lcs[i + 1]![j + 1]! + 1 : Math.max(lcs[i + 1]![j]!, lcs[i]![j + 1]!);\n }\n }\n\n const entries: DiffEntry[] = [];\n let i = 0;\n let j = 0;\n while (i < n && j < m) {\n if (oldLines[i] === newLines[j]) {\n entries.push({ type: 'context', text: oldLines[i]! });\n i++;\n j++;\n } else if (lcs[i + 1]![j]! >= lcs[i]![j + 1]!) {\n entries.push({ type: 'removed', text: oldLines[i]! });\n i++;\n } else {\n entries.push({ type: 'added', text: newLines[j]! });\n j++;\n }\n }\n while (i < n) entries.push({ type: 'removed', text: oldLines[i++]! });\n while (j < m) entries.push({ type: 'added', text: newLines[j++]! });\n\n return entries;\n}\n\n/**\n * Decide whether a diff is worth rendering instead of just showing the full new plan.\n *\n * We generate the real diff and compare its size (added + removed lines) against the size\n * of the whole diff (added + removed + unchanged context). When most of the diff is changes\n * rather than shared context, the diff is no clearer than the full text, so callers fall\n * back to rendering the whole plan. A genuinely new plan (no previous text, or no shared\n * lines) is therefore shown in full.\n */\nexport function shouldShowDiff(previousPlan: string, plan: string, maxChangedRatio = 0.5): boolean {\n if (!previousPlan || previousPlan === plan) return false;\n\n const entries = generatePlanDiff(previousPlan, plan);\n const changed = entries.filter(e => e.type !== 'context').length;\n if (changed === 0) return false;\n\n // changed / total entries == diff size relative to the full plan view.\n return changed / Math.max(entries.length, 1) <= maxChangedRatio;\n}\n"],"mappings":";;AAeA,SAAgB,iBAAiB,SAAiB,SAA8B;CAC9E,MAAM,WAAW,QAAQ,MAAM,OAAO;CACtC,MAAM,WAAW,QAAQ,MAAM,OAAO;CACtC,MAAM,IAAI,SAAS;CACnB,MAAM,IAAI,SAAS;CAGnB,MAAM,MAAkB,MAAM,KAAK,EAAE,QAAQ,IAAI,EAAE,SAAS,IAAI,MAAc,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;CAC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ED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAc9B"}
|
package/dist/utils/plans.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plans.js","names":[],"sources":["../../src/utils/plans.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { DEFAULT_CONFIG_DIR } from '../constants.js';\nimport { getAppDataDir } from './project.js';\n\n/** Global plans directory for approved-plan archives. */\nexport function getPlansDir(): string {\n return process.env.MASTRA_PLANS_DIR ?? path.join(getAppDataDir(), 'plans');\n}\n\nexport interface LocalPlansOptions {\n factoryProjectId?: string | null;\n /** Host-configured workspace-relative plans directory; wins over the default. */\n plansDir?: string;\n}\n\n/** Workspace-relative directory the agent writes plan files into. */\nexport function getLocalPlansRelativeDir(options: LocalPlansOptions = {}): string {\n if (options.plansDir) {\n const dir = path.normalize(options.plansDir);\n let end = dir.length;\n while (end > 0 && (dir[end - 1] === '/' || dir[end - 1] === '\\\\')) end--;\n return dir.slice(0, end);\n }\n return options.factoryProjectId ? path.join('.artifacts', 'plans') : path.join(DEFAULT_CONFIG_DIR, 'plans');\n}\n\n/** Local (project-scoped) plans directory where the agent writes named plan files. */\nexport function getLocalPlansDir(projectPath: string, options: LocalPlansOptions = {}): string {\n return path.join(projectPath, getLocalPlansRelativeDir(options));\n}\n\nfunction slugify(str: string): string {\n const slug = str\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-|-$/g, '');\n return slug || 'untitled';\n}\n\n/** Derive a plan filename from a title (e.g. `add-dark-mode.md`). */\nexport function getPlanFilename(title: string): string {\n return `${slugify(title)}.md`;\n}\n\n/**\n * Suggested workspace-relative path for a new plan file, shown in plan-mode prompts.\n * Without a title we fall back to a generic name the agent can rename later.\n */\nexport function getSuggestedPlanRelativePath(title?: string, options: LocalPlansOptions = {}): string {\n const filename = title ? getPlanFilename(title) : 'plan.md';\n return path.join(getLocalPlansRelativeDir(options), filename);\n}\n\n/**\n * Resolve a plan path submitted by the agent (absolute or project-relative) to an\n * absolute path. Returns `undefined` when no usable path was provided.\n */\nexport function resolvePlanPath(projectPath: string, submittedPath: string): string | undefined {\n if (!submittedPath) return undefined;\n return path.isAbsolute(submittedPath) ? submittedPath : path.resolve(projectPath, submittedPath);\n}\n\n/**\n * Whether `targetPath` (absolute or project-relative) is a valid plan file: a `.md`\n * file located directly inside the project's configured plan directory. Used by the\n * plan-mode write guard so the agent can write any named plan file there, but nothing\n * outside that directory.\n */\nexport function isPlanFilePath(projectPath: string, targetPath: string, options: LocalPlansOptions = {}): boolean {\n const abs = resolvePlanPath(projectPath, targetPath);\n if (!abs) return false;\n if (path.extname(abs).toLowerCase() !== '.md') return false;\n\n const plansDir = path.resolve(getLocalPlansDir(projectPath, options));\n const rel = path.relative(plansDir, abs);\n // Must be directly inside the plans dir (no nested subdirectories, no escaping it).\n if (rel === '' || rel.startsWith('..') || path.isAbsolute(rel)) return false;\n return !rel.includes(path.sep);\n}\n\nexport async function savePlanToDisk(opts: {\n title: string;\n plan: string;\n resourceId: string;\n plansDir?: string;\n}): Promise<void> {\n const { title, plan, resourceId } = opts;\n const plansDir = opts.plansDir ?? getPlansDir();\n const baseDir = path.resolve(plansDir);\n const dir = path.resolve(baseDir, resourceId);\n const rel = path.relative(baseDir, dir);\n if (rel.startsWith('..') || path.isAbsolute(rel)) {\n throw new Error(`Invalid resourceId: ${resourceId}`);\n }\n\n await fs.mkdir(dir, { recursive: true });\n\n const now = new Date();\n const timestamp = now.toISOString().replace(/:/g, '-');\n const slug = slugify(title);\n const filename = `${timestamp}-${slug}.md`;\n\n const content = `# ${title}\\n\\nApproved: ${now.toISOString()}\\n\\n${plan}\\n`;\n\n await fs.writeFile(path.join(dir, filename), content, 'utf-8');\n}\n\n/**\n * Read a plan markdown file by absolute path.\n *\n * The leading `# <title>` heading (if present) is parsed as the title and the remaining\n * content is returned as the plan body. Returns `undefined` when the file does not exist.\n */\nexport async function readPlanFile(absPath: string): Promise<{ title: string; plan: string } | undefined> {\n let raw: string;\n try {\n raw = await fs.readFile(absPath, 'utf-8');\n } catch {\n return undefined;\n }\n\n const lines = raw.split(/\\r?\\n/);\n const headingIndex = lines.findIndex(line => line.trim().length > 0);\n const heading = headingIndex >= 0 ? lines[headingIndex] : undefined;\n if (heading?.startsWith('# ')) {\n const title = heading.slice(2).trim();\n const plan = lines\n .slice(headingIndex + 1)\n .join('\\n')\n .replace(/^\\n+/, '')\n .trimEnd();\n return { title, plan };\n }\n\n return { title: '', plan: raw.trimEnd() };\n}\n\n/**\n * Approve the plan file at `planPath`: write a timestamped copy to the global plans\n * archive so approved plans are findable later. The local named plan file is left in\n * place so the user can review every plan made over time.\n *\n * Returns the local plan filename (e.g. `add-dark-mode.md`), or `undefined` when there\n * was no plan file to approve.\n */\nexport async function approvePlanFile(opts: {\n planPath: string;\n title: string;\n resourceId: string;\n plansDir?: string;\n}): Promise<string | undefined> {\n const { planPath, title, resourceId, plansDir } = opts;\n\n const current = await readPlanFile(planPath);\n if (!current) {\n return undefined;\n }\n\n const resolvedTitle = title || current.title || 'Implementation Plan';\n\n // Global archive (timestamped, never overwritten) so approved plans are findable later.\n await savePlanToDisk({ title: resolvedTitle, plan: current.plan, resourceId, plansDir });\n\n return path.basename(planPath);\n}\n"],"mappings":";;;;;;AAMA,SAAgB,cAAsB;CACpC,OAAO,QAAQ,IAAI,oBAAoB,KAAK,KAAK,cAAc,GAAG,OAAO;AAC3E;;AASA,SAAgB,yBAAyB,UAA6B,CAAC,GAAW;CAChF,IAAI,QAAQ,UAAU;EACpB,MAAM,MAAM,KAAK,UAAU,QAAQ,QAAQ;EAC3C,IAAI,MAAM,IAAI;EACd,OAA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,GAAG,UAAU,CAAC;AAE5C;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,aAAa,SAAqB,GAAG,OAAO,CAmB3F;AAgBD;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,aAAa,SAAqB,GAAG,MAAM,GAAG,IAAI,CAiB5G"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project.js","names":[],"sources":["../../src/utils/project.ts"],"sourcesContent":["/**\n * Project detection utilities\n *\n * Detects project identity from git repo or filesystem path.\n * Handles git worktrees by finding the main repository.\n */\n\nimport { execFile, execSync } from 'node:child_process';\nimport { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { DEFAULT_CONFIG_DIR } from '../constants.js';\nexport interface ProjectInfo {\n /** Unique resource ID for this project (used for thread grouping) */\n resourceId: string;\n /** Human-readable project name */\n name: string;\n /** Absolute path to the project root */\n rootPath: string;\n /** Git remote URL if available */\n gitUrl?: string;\n /** Current git branch */\n gitBranch?: string;\n /** Whether this is a git worktree */\n isWorktree: boolean;\n /** Path to main git repo (different from rootPath if worktree) */\n mainRepoPath?: string;\n /** Whether the resourceId was explicitly overridden (env var or config) */\n resourceIdOverride?: boolean;\n}\n\n/**\n * Run a git command and return stdout, or undefined if it fails\n */\nfunction git(args: string, cwd: string): string | undefined {\n try {\n return execSync(`git ${args}`, {\n cwd,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n } catch {\n return undefined;\n }\n}\n\n/**\n * Slugify a string for use in IDs\n */\nfunction slugify(str: string): string {\n return str\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-|-$/g, '');\n}\n\n/**\n * Create a short hash of a string\n */\nfunction shortHash(str: string): string {\n return createHash('sha256').update(str).digest('hex').slice(0, 12);\n}\n\n/**\n * Normalize a git URL to a canonical form for comparison\n * - Removes .git suffix\n * - Converts SSH to HTTPS format for consistency\n * - Lowercases\n */\nfunction normalizeGitUrl(url: string): string {\n return url\n .replace(/\\.git$/, '')\n .replace(/^git@([^:]+):/, 'https://$1/')\n .replace(/^ssh:\\/\\/git@/, 'https://')\n .toLowerCase();\n}\n\n/**\n * Detect project info from a directory path\n */\nexport function detectProject(projectPath: string): ProjectInfo {\n const absolutePath = path.resolve(projectPath);\n\n // Check if this is a git repo\n const gitDir = git('rev-parse --git-dir', absolutePath);\n const isGitRepo = gitDir !== undefined;\n\n let rootPath = absolutePath;\n let gitUrl: string | undefined;\n let gitBranch: string | undefined;\n let isWorktree = false;\n let mainRepoPath: string | undefined;\n\n if (isGitRepo) {\n // Get the repo root (handles being in a subdirectory)\n rootPath = git('rev-parse --show-toplevel', absolutePath) || absolutePath;\n\n // Check for worktree - git-common-dir differs from git-dir in worktrees\n const commonDir = git('rev-parse --git-common-dir', absolutePath);\n if (commonDir && commonDir !== '.git' && commonDir !== gitDir) {\n isWorktree = true;\n // The common dir is inside the main repo's .git folder\n mainRepoPath = path.dirname(path.resolve(rootPath, commonDir));\n }\n\n // Get remote URL (prefer origin, fall back to first remote)\n gitUrl = git('remote get-url origin', absolutePath);\n if (!gitUrl) {\n const remotes = git('remote', absolutePath);\n if (remotes) {\n const firstRemote = remotes.split('\\n')[0];\n if (firstRemote) {\n gitUrl = git(`remote get-url ${firstRemote}`, absolutePath);\n }\n }\n }\n\n // Get current branch\n gitBranch = git('rev-parse --abbrev-ref HEAD', absolutePath);\n }\n\n // Generate resource ID\n // Priority: normalized git URL > main repo path (for worktrees) > absolute path\n let resourceIdSource: string;\n if (gitUrl) {\n resourceIdSource = normalizeGitUrl(gitUrl);\n } else if (mainRepoPath) {\n resourceIdSource = mainRepoPath;\n } else {\n resourceIdSource = rootPath;\n }\n\n // Create a readable but unique resource ID\n // Format: slugified-name-shorthash\n const baseName = gitUrl\n ? gitUrl\n .split('/')\n .pop()\n ?.replace(/\\.git$/, '') || 'project'\n : path.basename(rootPath);\n\n const resourceId = `${slugify(baseName)}-${shortHash(resourceIdSource)}`;\n\n return {\n resourceId,\n name: baseName,\n rootPath,\n gitUrl,\n gitBranch,\n isWorktree,\n mainRepoPath,\n };\n}\n\n/**\n * Get the current git branch for a given directory.\n * Lightweight alternative to detectProject() for refreshing just the branch.\n */\nexport function getCurrentGitBranch(cwd: string): string | undefined {\n return git('rev-parse --abbrev-ref HEAD', cwd);\n}\n\n/**\n * Async version of getCurrentGitBranch — avoids blocking the event loop\n * with execSync. Falls back to undefined on any failure.\n */\nexport function getCurrentGitBranchAsync(cwd: string): Promise<string | undefined> {\n return new Promise(resolve => {\n execFile('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd, encoding: 'utf-8' }, (err, stdout) => {\n if (err) {\n resolve(undefined);\n return;\n }\n const branch = stdout.trim();\n resolve(branch || undefined);\n });\n });\n}\n\n/**\n * Get the application data directory for mastracode\n * - macOS: ~/Library/Application Support/mastracode\n * - Linux: ~/.local/share/mastracode\n * - Windows: %APPDATA%/mastracode\n */\nexport function getAppDataDir(): string {\n if (process.env.MASTRA_APP_DATA_DIR) {\n fs.mkdirSync(process.env.MASTRA_APP_DATA_DIR, { recursive: true });\n return process.env.MASTRA_APP_DATA_DIR;\n }\n\n const platform = os.platform();\n let baseDir: string;\n\n if (platform === 'darwin') {\n baseDir = path.join(os.homedir(), 'Library', 'Application Support');\n } else if (platform === 'win32') {\n baseDir = process.env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming');\n } else {\n // Linux and others - follow XDG spec\n baseDir = process.env.XDG_DATA_HOME || path.join(os.homedir(), '.local', 'share');\n }\n\n const appDir = path.join(baseDir, 'mastracode');\n\n // Ensure directory exists\n if (!fs.existsSync(appDir)) {\n fs.mkdirSync(appDir, { recursive: true });\n }\n\n return appDir;\n}\n/**\n * Get the database path for mastracode\n * Can be overridden with the MASTRA_DB_PATH environment variable for debugging.\n */\nexport function getDatabasePath(): string {\n if (process.env.MASTRA_DB_PATH) {\n return process.env.MASTRA_DB_PATH;\n }\n return path.join(getAppDataDir(), 'mastra.db');\n}\n\n/**\n * Get the vector database path for mastracode.\n * Separate from the main DB to avoid bloating it with embedding data.\n */\nexport function getVectorDatabasePath(): string {\n return path.join(getAppDataDir(), 'mastra-vectors.db');\n}\n\n/**\n * Get the observability DuckDB database path for mastracode.\n * Separate from the main DB — DuckDB is used for OLAP-style trace/score/feedback queries.\n * Can be overridden with the MASTRA_OBSERVABILITY_DB_PATH environment variable.\n */\nexport function getObservabilityDatabasePath(): string {\n if (process.env.MASTRA_OBSERVABILITY_DB_PATH) {\n return process.env.MASTRA_OBSERVABILITY_DB_PATH;\n }\n return path.join(getAppDataDir(), 'observability.duckdb');\n}\n\nimport type { StorageBackend, StorageSettings } from '../onboarding/settings.js';\n\n/**\n * LibSQL storage configuration.\n */\nexport interface LibSQLStorageConfig {\n backend: 'libsql';\n url: string;\n authToken?: string;\n isRemote: boolean;\n /**\n * Optional explicit url for the recall vector DB. When omitted, the factory\n * uses the shared default vector file.\n */\n vectorUrl?: string;\n /** Auth token for the vector DB when `vectorUrl` points at a remote libSQL. */\n vectorAuthToken?: string;\n}\n\n/**\n * PostgreSQL storage configuration.\n */\nexport interface PgStorageConfig {\n backend: 'pg';\n connectionString?: string;\n host?: string;\n port?: number;\n database?: string;\n user?: string;\n password?: string;\n schemaName?: string;\n disableInit?: boolean;\n skipDefaultIndexes?: boolean;\n}\n\n/**\n * Resolved storage configuration for either backend.\n */\nexport type StorageConfig = LibSQLStorageConfig | PgStorageConfig;\n\n/**\n * Get the resolved storage configuration.\n *\n * Priority (highest to lowest):\n * 1. Environment variables: MASTRA_STORAGE_BACKEND + backend-specific vars\n * 2. Global settings (from /settings): settings.storage\n * 3. Legacy config files: .mastracode/database.json (LibSQL only)\n * 4. Local file database (LibSQL default)\n *\n * For PG, the env vars are:\n * MASTRA_STORAGE_BACKEND=pg\n * MASTRA_PG_CONNECTION_STRING or MASTRA_PG_HOST/PORT/DATABASE/USER/PASSWORD\n * MASTRA_PG_SCHEMA_NAME (optional)\n *\n * For LibSQL, the legacy env vars still work:\n * MASTRA_DB_URL + MASTRA_DB_AUTH_TOKEN\n */\nexport function getStorageConfig(\n projectDir?: string,\n storageSettings?: StorageSettings,\n configDirName = DEFAULT_CONFIG_DIR,\n): StorageConfig {\n // 1. Environment variable — explicit backend selection\n const envBackend = process.env.MASTRA_STORAGE_BACKEND as StorageBackend | undefined;\n\n if (envBackend === 'pg') {\n return resolvePgFromEnv();\n }\n\n // Legacy LibSQL env vars (MASTRA_DB_URL) — treat as explicit libsql\n if (envBackend === 'libsql' || process.env.MASTRA_DB_URL) {\n return resolveLibSQLFromEnv();\n }\n\n // 2. Global settings (from /settings)\n if (storageSettings && storageSettings.backend === 'pg') {\n return resolvePgFromSettings(storageSettings);\n }\n\n if (storageSettings && storageSettings.backend === 'libsql' && storageSettings.libsql.url) {\n return {\n backend: 'libsql',\n url: storageSettings.libsql.url,\n authToken: storageSettings.libsql.authToken,\n isRemote: !storageSettings.libsql.url.startsWith('file:'),\n };\n }\n\n // 3. Legacy project/global config files (.mastracode/database.json)\n if (projectDir) {\n const projectConfig = loadDatabaseConfig(path.join(projectDir, configDirName, 'database.json'));\n if (projectConfig) return projectConfig;\n }\n const globalConfig = loadDatabaseConfig(path.join(os.homedir(), configDirName, 'database.json'));\n if (globalConfig) return globalConfig;\n\n // 4. Default: local LibSQL file database\n return {\n backend: 'libsql',\n url: `file:${getDatabasePath()}`,\n isRemote: false,\n };\n}\n\nfunction resolveLibSQLFromEnv(): LibSQLStorageConfig {\n const url = process.env.MASTRA_DB_URL!;\n return {\n backend: 'libsql',\n url,\n authToken: process.env.MASTRA_DB_AUTH_TOKEN,\n isRemote: !url.startsWith('file:'),\n };\n}\n\nfunction resolvePgFromEnv(): PgStorageConfig {\n const connectionString = process.env.MASTRA_PG_CONNECTION_STRING;\n if (connectionString) {\n return {\n backend: 'pg',\n connectionString,\n schemaName: process.env.MASTRA_PG_SCHEMA_NAME,\n };\n }\n\n // Host/port style\n return {\n backend: 'pg',\n host: process.env.MASTRA_PG_HOST,\n port: process.env.MASTRA_PG_PORT ? parseInt(process.env.MASTRA_PG_PORT, 10) : undefined,\n database: process.env.MASTRA_PG_DATABASE,\n user: process.env.MASTRA_PG_USER,\n password: process.env.MASTRA_PG_PASSWORD,\n schemaName: process.env.MASTRA_PG_SCHEMA_NAME,\n };\n}\n\nfunction resolvePgFromSettings(settings: StorageSettings): PgStorageConfig {\n const pg = settings.pg;\n return {\n backend: 'pg',\n connectionString: pg.connectionString,\n host: pg.host,\n port: pg.port,\n database: pg.database,\n user: pg.user,\n password: pg.password,\n schemaName: pg.schemaName,\n disableInit: pg.disableInit,\n skipDefaultIndexes: pg.skipDefaultIndexes,\n };\n}\n\n/**\n * Load database config from a legacy JSON file.\n * Expected format: { \"url\": \"libsql://...\", \"authToken\": \"...\" }\n */\nfunction loadDatabaseConfig(filePath: string): LibSQLStorageConfig | null {\n try {\n if (!fs.existsSync(filePath)) return null;\n const raw = fs.readFileSync(filePath, 'utf-8');\n const parsed = JSON.parse(raw);\n if (typeof parsed?.url === 'string' && parsed.url) {\n return {\n backend: 'libsql',\n url: parsed.url,\n authToken: typeof parsed.authToken === 'string' ? parsed.authToken : undefined,\n isRemote: !parsed.url.startsWith('file:'),\n };\n }\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * Get the current user identity.\n *\n * Priority:\n * 1. MASTRA_USER_ID environment variable\n * 2. git config user.email (from project dir or global)\n * 3. OS username as fallback\n */\nexport function getUserId(projectDir?: string): string {\n // 1. Environment variable override\n if (process.env.MASTRA_USER_ID) {\n return process.env.MASTRA_USER_ID;\n }\n\n // 2. git user.email\n const cwd = projectDir || process.cwd();\n const email = git('config user.email', cwd);\n if (email) {\n return email;\n }\n\n // 3. OS username fallback\n return os.userInfo().username || 'unknown';\n}\n\n/**\n * Get the current user's display name.\n *\n * Priority:\n * 1. git config user.name\n * 2. OS username as fallback\n */\nexport function getUserName(projectDir?: string): string {\n const cwd = projectDir || process.cwd();\n const name = git('config user.name', cwd);\n if (name) {\n return name;\n }\n return os.userInfo().username || 'unknown';\n}\n\n/**\n * Observational memory scope: \"thread\" (per-conversation) or \"resource\" (shared across threads).\n */\nexport type OmScope = 'thread' | 'resource';\n\n/**\n * Get the configured observational memory scope.\n *\n * Priority:\n * 1. MASTRA_OM_SCOPE environment variable (\"thread\" or \"resource\")\n * 2. Project config: .mastracode/database.json → omScope\n * 3. Global config: ~/.mastracode/database.json → omScope\n * 4. Default: \"thread\"\n */\nexport function getOmScope(projectDir?: string, configDirName = DEFAULT_CONFIG_DIR): OmScope {\n // 1. Environment variable\n const envScope = process.env.MASTRA_OM_SCOPE;\n if (envScope === 'thread' || envScope === 'resource') {\n return envScope;\n }\n\n // 2. Project-level config\n if (projectDir) {\n const scope = loadOmScopeFromConfig(path.join(projectDir, configDirName, 'database.json'));\n if (scope) return scope;\n }\n\n // 3. Global config\n const scope = loadOmScopeFromConfig(path.join(os.homedir(), configDirName, 'database.json'));\n if (scope) return scope;\n\n // 4. Default\n return 'thread';\n}\n\nfunction loadOmScopeFromConfig(filePath: string): OmScope | null {\n try {\n if (!fs.existsSync(filePath)) return null;\n const raw = fs.readFileSync(filePath, 'utf-8');\n const parsed = JSON.parse(raw);\n if (parsed?.omScope === 'thread' || parsed?.omScope === 'resource') {\n return parsed.omScope;\n }\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * Get an explicit resource ID override, if configured.\n *\n * Resource IDs act as shared tags — two users who set the same resourceId\n * will share threads and observations for that resource.\n *\n * Priority:\n * 1. MASTRA_RESOURCE_ID environment variable\n * 2. Project config: .mastracode/database.json → resourceId\n * 3. Global config: ~/.mastracode/database.json → resourceId\n * 4. null (use auto-detected value)\n */\nexport function getResourceIdOverride(projectDir?: string, configDirName = DEFAULT_CONFIG_DIR): string | null {\n // 1. Environment variable\n if (process.env.MASTRA_RESOURCE_ID) {\n return process.env.MASTRA_RESOURCE_ID;\n }\n\n // 2. Project-level config\n if (projectDir) {\n const rid = loadStringField(path.join(projectDir, configDirName, 'database.json'), 'resourceId');\n if (rid) return rid;\n }\n\n // 3. Global config\n const rid = loadStringField(path.join(os.homedir(), configDirName, 'database.json'), 'resourceId');\n if (rid) return rid;\n\n return null;\n}\n\nfunction loadStringField(filePath: string, field: string): string | null {\n try {\n if (!fs.existsSync(filePath)) return null;\n const raw = fs.readFileSync(filePath, 'utf-8');\n const parsed = JSON.parse(raw);\n const value = parsed?.[field];\n if (typeof value === 'string' && value) {\n return value;\n }\n return null;\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmCA,SAAS,IAAI,MAAc,KAAiC;CAC1D,IAAI;EACF,OAAO,SAAS,OAAO,QAAQ;GAC7B;GACA,UAAU;GACV,OAAO;IAAC;IAAQ;IAAQ;GAAM;EAChC,CAAC,CAAC,CAAC,KAAK;CACV,QAAQ;EACN;CACF;AACF;;;;AAKA,SAAS,QAAQ,KAAqB;CACpC,OAAO,IACJ,YAAY,CAAC,CACb,QAAQ,eAAe,GAAG,CAAC,CAC3B,QAAQ,UAAU,EAAE;AACzB;;;;AAKA,SAAS,UAAU,KAAqB;CACtC,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,EAAE;AACnE;;;;;;;AAQA,SAAS,gBAAgB,KAAqB;CAC5C,OAAO,IACJ,QAAQ,UAAU,EAAE,CAAC,CACrB,QAAQ,iBAAiB,aAAa,CAAC,CACvC,QAAQ,iBAAiB,UAAU,CAAC,CACpC,YAAY;AACjB;;;;AAKA,SAAgB,cAAc,aAAkC;CAC9D,MAAM,eAAe,KAAK,QAAQ,WAAW;CAG7C,MAAM,SAAS,IAAI,uBAAuB,YAAY;CACtD,MAAM,YAAY,WAAW,KAAA;CAE7B,IAAI,WAAW;CACf,IAAI;CACJ,IAAI;CACJ,IAAI,aAAa;CACjB,IAAI;CA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