@mastra/code-sdk 0.0.0-agent-tags-alpha-20261125185303
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +32 -0
- package/README.md +284 -0
- package/dist/acp/agent.d.ts +48 -0
- package/dist/acp/agent.js +414 -0
- package/dist/acp/errors.d.ts +3 -0
- package/dist/acp/errors.js +11 -0
- package/dist/acp/event-mapper.d.ts +28 -0
- package/dist/acp/event-mapper.js +274 -0
- package/dist/acp/index.d.ts +9 -0
- package/dist/acp/index.js +21 -0
- package/dist/acp/runtime.d.ts +5 -0
- package/dist/acp/runtime.js +91 -0
- package/dist/acp/server.d.ts +4 -0
- package/dist/acp/server.js +35 -0
- package/dist/acp/skills.d.ts +6 -0
- package/dist/acp/skills.js +30 -0
- package/dist/acp.d.ts +2 -0
- package/dist/acp.js +1 -0
- package/dist/agent-connections/messaging-processor.d.ts +17 -0
- package/dist/agent-connections/messaging-processor.js +131 -0
- package/dist/agent-connections/ownership.d.ts +24 -0
- package/dist/agent-connections/ownership.js +96 -0
- package/dist/agent-connections/registry.d.ts +20 -0
- package/dist/agent-connections/registry.js +167 -0
- package/dist/agent-connections/session-advertisement.d.ts +27 -0
- package/dist/agent-connections/session-advertisement.js +86 -0
- package/dist/agent-connections/signal-provider.d.ts +141 -0
- package/dist/agent-connections/signal-provider.js +35 -0
- package/dist/agent-connections/state-processor.d.ts +23 -0
- package/dist/agent-connections/state-processor.js +270 -0
- package/dist/agent-connections/thread-state.d.ts +41 -0
- package/dist/agent-connections/thread-state.js +157 -0
- package/dist/agent-connections/tools.d.ts +133 -0
- package/dist/agent-connections/tools.js +616 -0
- package/dist/agent-connections/types.d.ts +99 -0
- package/dist/agent-connections/types.js +4 -0
- package/dist/agent-connections/untrusted-text.d.ts +5 -0
- package/dist/agent-connections/untrusted-text.js +19 -0
- package/dist/agents/background-completion-events.d.ts +16 -0
- package/dist/agents/background-completion-events.js +16 -0
- package/dist/agents/background-completion.d.ts +22 -0
- package/dist/agents/background-completion.js +73 -0
- package/dist/agents/context-audit.d.ts +84 -0
- package/dist/agents/context-audit.js +115 -0
- package/dist/agents/credential-resolver.d.ts +74 -0
- package/dist/agents/credential-resolver.js +142 -0
- package/dist/agents/custom-provider-source.d.ts +35 -0
- package/dist/agents/custom-provider-source.js +22 -0
- package/dist/agents/fastembed-subprocess.d.ts +52 -0
- package/dist/agents/fastembed-subprocess.js +282 -0
- package/dist/agents/instructions.d.ts +42 -0
- package/dist/agents/instructions.js +69 -0
- package/dist/agents/mastracode-gateway.d.ts +85 -0
- package/dist/agents/mastracode-gateway.js +500 -0
- package/dist/agents/memory.d.ts +36 -0
- package/dist/agents/memory.js +248 -0
- package/dist/agents/model.d.ts +158 -0
- package/dist/agents/model.js +382 -0
- package/dist/agents/modes/build.d.ts +12 -0
- package/dist/agents/modes/build.js +33 -0
- package/dist/agents/modes/explore.d.ts +10 -0
- package/dist/agents/modes/explore.js +25 -0
- package/dist/agents/modes/plan.d.ts +8 -0
- package/dist/agents/modes/plan.js +43 -0
- package/dist/agents/prompts/agent-instructions.d.ts +122 -0
- package/dist/agents/prompts/agent-instructions.js +617 -0
- package/dist/agents/prompts/build.d.ts +12 -0
- package/dist/agents/prompts/build.js +73 -0
- package/dist/agents/prompts/fast.d.ts +5 -0
- package/dist/agents/prompts/fast.js +23 -0
- package/dist/agents/prompts/index.d.ts +61 -0
- package/dist/agents/prompts/index.js +141 -0
- package/dist/agents/prompts/model.d.ts +5 -0
- package/dist/agents/prompts/model.js +20 -0
- package/dist/agents/prompts/plan.d.ts +11 -0
- package/dist/agents/prompts/plan.js +132 -0
- package/dist/agents/prompts/tool-guidance.d.ts +18 -0
- package/dist/agents/prompts/tool-guidance.js +158 -0
- package/dist/agents/sandbox-filesystem.d.ts +232 -0
- package/dist/agents/sandbox-filesystem.js +851 -0
- package/dist/agents/subagents/execute.d.ts +3 -0
- package/dist/agents/subagents/execute.js +24 -0
- package/dist/agents/subagents/explore.d.ts +3 -0
- package/dist/agents/subagents/explore.js +15 -0
- package/dist/agents/subagents/index.d.ts +6 -0
- package/dist/agents/subagents/index.js +15 -0
- package/dist/agents/subagents/plan.d.ts +3 -0
- package/dist/agents/subagents/plan.js +15 -0
- package/dist/agents/thread-caveman-state.d.ts +17 -0
- package/dist/agents/thread-caveman-state.js +104 -0
- package/dist/agents/tool-availability.d.ts +17 -0
- package/dist/agents/tool-availability.js +134 -0
- package/dist/agents/tools.d.ts +37 -0
- package/dist/agents/tools.js +154 -0
- package/dist/agents/workflow-builder-agent.d.ts +2 -0
- package/dist/agents/workflow-builder-agent.js +79 -0
- package/dist/agents/workspace.d.ts +35 -0
- package/dist/agents/workspace.js +207 -0
- package/dist/analytics.d.ts +18 -0
- package/dist/analytics.js +159 -0
- package/dist/auth/account-rotation-processor.d.ts +210 -0
- package/dist/auth/account-rotation-processor.js +662 -0
- package/dist/auth/account-routing-context.d.ts +17 -0
- package/dist/auth/account-routing-context.js +38 -0
- package/dist/auth/authorization-input.d.ts +16 -0
- package/dist/auth/authorization-input.js +39 -0
- package/dist/auth/device-code.d.ts +93 -0
- package/dist/auth/device-code.js +126 -0
- package/dist/auth/index.d.ts +13 -0
- package/dist/auth/index.js +9 -0
- package/dist/auth/pkce.d.ts +13 -0
- package/dist/auth/pkce.js +29 -0
- package/dist/auth/provider-auth-error.d.ts +24 -0
- package/dist/auth/provider-auth-error.js +44 -0
- package/dist/auth/providers/anthropic.d.ts +40 -0
- package/dist/auth/providers/anthropic.js +117 -0
- package/dist/auth/providers/github-copilot.d.ts +154 -0
- package/dist/auth/providers/github-copilot.js +359 -0
- package/dist/auth/providers/kimi-coding.d.ts +38 -0
- package/dist/auth/providers/kimi-coding.js +225 -0
- package/dist/auth/providers/openai-codex.d.ts +141 -0
- package/dist/auth/providers/openai-codex.js +531 -0
- package/dist/auth/providers/xai.d.ts +64 -0
- package/dist/auth/providers/xai.js +223 -0
- package/dist/auth/storage.d.ts +222 -0
- package/dist/auth/storage.js +805 -0
- package/dist/auth/types.d.ts +164 -0
- package/dist/auth/types.js +1 -0
- package/dist/clipboard/index.d.ts +26 -0
- package/dist/clipboard/index.js +224 -0
- package/dist/constants.d.ts +29 -0
- package/dist/constants.js +34 -0
- package/dist/error-classification.d.ts +10 -0
- package/dist/error-classification.js +19 -0
- package/dist/evals/context-builder.d.ts +41 -0
- package/dist/evals/context-builder.js +156 -0
- package/dist/evals/index.d.ts +4 -0
- package/dist/evals/index.js +5 -0
- package/dist/evals/scorers/classify-command.d.ts +30 -0
- package/dist/evals/scorers/classify-command.js +61 -0
- package/dist/evals/scorers/efficiency.d.ts +44 -0
- package/dist/evals/scorers/efficiency.js +256 -0
- package/dist/evals/scorers/extract-tools.d.ts +25 -0
- package/dist/evals/scorers/extract-tools.js +57 -0
- package/dist/evals/scorers/index.d.ts +3 -0
- package/dist/evals/scorers/index.js +3 -0
- package/dist/evals/scorers/outcome.d.ts +49 -0
- package/dist/evals/scorers/outcome.js +360 -0
- package/dist/experimental-agent.d.ts +19 -0
- package/dist/experimental-agent.js +45 -0
- package/dist/factory/client.d.ts +44 -0
- package/dist/factory/client.js +110 -0
- package/dist/factory/remote-controller.d.ts +34 -0
- package/dist/factory/remote-controller.js +40 -0
- package/dist/factory/remote-session.d.ts +210 -0
- package/dist/factory/remote-session.js +415 -0
- package/dist/goal-manager.d.ts +114 -0
- package/dist/goal-manager.js +351 -0
- package/dist/goal-signal.d.ts +14 -0
- package/dist/goal-signal.js +14 -0
- package/dist/headless/cli.d.ts +55 -0
- package/dist/headless/cli.js +261 -0
- package/dist/headless/flags.d.ts +33 -0
- package/dist/headless/flags.js +207 -0
- package/dist/headless/format.d.ts +41 -0
- package/dist/headless/format.js +94 -0
- package/dist/headless/index.d.ts +25 -0
- package/dist/headless/index.js +6 -0
- package/dist/headless/policy.d.ts +17 -0
- package/dist/headless/policy.js +39 -0
- package/dist/headless/run-mc.d.ts +7 -0
- package/dist/headless/run-mc.js +438 -0
- package/dist/headless/types.d.ts +175 -0
- package/dist/headless/types.js +16 -0
- package/dist/hooks/config.d.ts +11 -0
- package/dist/hooks/config.js +77 -0
- package/dist/hooks/executor.d.ts +13 -0
- package/dist/hooks/executor.js +128 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/manager.d.ts +75 -0
- package/dist/hooks/manager.js +289 -0
- package/dist/hooks/types.d.ts +180 -0
- package/dist/hooks/types.js +5 -0
- package/dist/index.d.ts +537 -0
- package/dist/index.js +1399 -0
- package/dist/ipc/ipc-reporter.d.ts +14 -0
- package/dist/ipc/ipc-reporter.js +18 -0
- package/dist/knowledge-inspector.d.ts +139 -0
- package/dist/knowledge-inspector.js +533 -0
- package/dist/knowledge-scope-id.d.ts +7 -0
- package/dist/knowledge-scope-id.js +10 -0
- package/dist/knowledge-scope.d.ts +41 -0
- package/dist/knowledge-scope.js +85 -0
- package/dist/lsp/client.d.ts +56 -0
- package/dist/lsp/client.js +248 -0
- package/dist/lsp/index.d.ts +4 -0
- package/dist/lsp/index.js +4 -0
- package/dist/lsp/language.d.ts +9 -0
- package/dist/lsp/language.js +41 -0
- package/dist/lsp/manager.d.ts +34 -0
- package/dist/lsp/manager.js +79 -0
- package/dist/lsp/server.d.ts +27 -0
- package/dist/lsp/server.js +158 -0
- package/dist/lsp/workspace.d.ts +9 -0
- package/dist/lsp/workspace.js +52 -0
- package/dist/mcp/config.d.ts +77 -0
- package/dist/mcp/config.js +313 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/manager.d.ts +104 -0
- package/dist/mcp/manager.js +693 -0
- package/dist/mcp/state.d.ts +35 -0
- package/dist/mcp/state.js +94 -0
- package/dist/mcp/types.d.ts +139 -0
- package/dist/mcp/types.js +1 -0
- package/dist/onboarding/custom-packs.d.ts +7 -0
- package/dist/onboarding/custom-packs.js +17 -0
- package/dist/onboarding/custom-providers.d.ts +4 -0
- package/dist/onboarding/custom-providers.js +27 -0
- package/dist/onboarding/index.d.ts +5 -0
- package/dist/onboarding/index.js +3 -0
- package/dist/onboarding/om-settings.d.ts +47 -0
- package/dist/onboarding/om-settings.js +80 -0
- package/dist/onboarding/pack-activation.d.ts +43 -0
- package/dist/onboarding/pack-activation.js +105 -0
- package/dist/onboarding/packs.d.ts +106 -0
- package/dist/onboarding/packs.js +283 -0
- package/dist/onboarding/settings.d.ts +563 -0
- package/dist/onboarding/settings.js +1110 -0
- package/dist/permissions.d.ts +55 -0
- package/dist/permissions.js +139 -0
- package/dist/platform/index.d.ts +74 -0
- package/dist/platform/index.js +199 -0
- package/dist/plugin.d.ts +156 -0
- package/dist/plugin.js +27 -0
- package/dist/plugins/dependencies.d.ts +9 -0
- package/dist/plugins/dependencies.js +84 -0
- package/dist/plugins/install.d.ts +21 -0
- package/dist/plugins/install.js +187 -0
- package/dist/plugins/loader.d.ts +25 -0
- package/dist/plugins/loader.js +264 -0
- package/dist/plugins/manager.d.ts +115 -0
- package/dist/plugins/manager.js +507 -0
- package/dist/plugins/manifest.d.ts +14 -0
- package/dist/plugins/manifest.js +47 -0
- package/dist/plugins/package-link.d.ts +3 -0
- package/dist/plugins/package-link.js +58 -0
- package/dist/plugins/paths.d.ts +10 -0
- package/dist/plugins/paths.js +22 -0
- package/dist/plugins/registry.d.ts +8 -0
- package/dist/plugins/registry.js +109 -0
- package/dist/plugins/scaffold.d.ts +10 -0
- package/dist/plugins/scaffold.js +115 -0
- package/dist/plugins/signal-lane.d.ts +59 -0
- package/dist/plugins/signal-lane.js +163 -0
- package/dist/plugins/types.d.ts +95 -0
- package/dist/plugins/types.js +1 -0
- package/dist/process-memory-diagnostics.d.ts +136 -0
- package/dist/process-memory-diagnostics.js +497 -0
- package/dist/processors/plan-rejection-abort.d.ts +16 -0
- package/dist/processors/plan-rejection-abort.js +62 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
- package/dist/providers/amazon-bedrock-gateway.js +142 -0
- package/dist/providers/amazon-bedrock.d.ts +28 -0
- package/dist/providers/amazon-bedrock.js +99 -0
- package/dist/providers/anthropic-prompt-cache.d.ts +19 -0
- package/dist/providers/anthropic-prompt-cache.js +8 -0
- package/dist/providers/anthropic-thinking.d.ts +5 -0
- package/dist/providers/anthropic-thinking.js +22 -0
- package/dist/providers/claude-max.d.ts +67 -0
- package/dist/providers/claude-max.js +232 -0
- package/dist/providers/github-copilot-gateway.d.ts +35 -0
- package/dist/providers/github-copilot-gateway.js +58 -0
- package/dist/providers/github-copilot.d.ts +60 -0
- package/dist/providers/github-copilot.js +320 -0
- package/dist/providers/google-thinking.d.ts +31 -0
- package/dist/providers/google-thinking.js +64 -0
- package/dist/providers/google-vertex-gateway.d.ts +23 -0
- package/dist/providers/google-vertex-gateway.js +49 -0
- package/dist/providers/google-vertex.d.ts +6 -0
- package/dist/providers/google-vertex.js +51 -0
- package/dist/providers/kimi-coding.d.ts +14 -0
- package/dist/providers/kimi-coding.js +80 -0
- package/dist/providers/model-ids.d.ts +53 -0
- package/dist/providers/model-ids.js +132 -0
- package/dist/providers/openai-codex.d.ts +114 -0
- package/dist/providers/openai-codex.js +427 -0
- package/dist/providers/provider-thinking.d.ts +23 -0
- package/dist/providers/provider-thinking.js +61 -0
- package/dist/providers/thinking-request.d.ts +14 -0
- package/dist/providers/thinking-request.js +87 -0
- package/dist/providers/xai.d.ts +33 -0
- package/dist/providers/xai.js +72 -0
- package/dist/schedules/index.d.ts +10 -0
- package/dist/schedules/index.js +6 -0
- package/dist/schedules/interval.d.ts +49 -0
- package/dist/schedules/interval.js +212 -0
- package/dist/schedules/prompt.d.ts +36 -0
- package/dist/schedules/prompt.js +36 -0
- package/dist/schedules/run-script.d.ts +8 -0
- package/dist/schedules/run-script.js +80 -0
- package/dist/schedules/scheduler.d.ts +101 -0
- package/dist/schedules/scheduler.js +167 -0
- package/dist/schedules/tools.d.ts +57 -0
- package/dist/schedules/tools.js +217 -0
- package/dist/schema.d.ts +499 -0
- package/dist/schema.js +131 -0
- package/dist/theme-palette.d.ts +17 -0
- package/dist/theme-palette.js +18 -0
- package/dist/thinking-catalog.d.ts +4 -0
- package/dist/thinking-catalog.js +13 -0
- package/dist/thinking.d.ts +37 -0
- package/dist/thinking.js +134 -0
- package/dist/tool-names.d.ts +77 -0
- package/dist/tool-names.js +53 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/request-sandbox-access.d.ts +6 -0
- package/dist/tools/request-sandbox-access.js +80 -0
- package/dist/tools/utils.d.ts +20 -0
- package/dist/tools/utils.js +31 -0
- package/dist/tools/web-search.d.ts +116 -0
- package/dist/tools/web-search.js +158 -0
- package/dist/tools/workflows/create-workflow.d.ts +7 -0
- package/dist/tools/workflows/create-workflow.js +82 -0
- package/dist/tools/workflows/delete-workflow.d.ts +7 -0
- package/dist/tools/workflows/delete-workflow.js +18 -0
- package/dist/tools/workflows/ephemeral-memory.d.ts +28 -0
- package/dist/tools/workflows/ephemeral-memory.js +41 -0
- package/dist/tools/workflows/extract-json-schema.d.ts +12 -0
- package/dist/tools/workflows/extract-json-schema.js +19 -0
- package/dist/tools/workflows/get-workflow.d.ts +11 -0
- package/dist/tools/workflows/get-workflow.js +31 -0
- package/dist/tools/workflows/list-available-agents.d.ts +8 -0
- package/dist/tools/workflows/list-available-agents.js +29 -0
- package/dist/tools/workflows/list-available-classifiers.d.ts +19 -0
- package/dist/tools/workflows/list-available-classifiers.js +53 -0
- package/dist/tools/workflows/list-available-tools.d.ts +9 -0
- package/dist/tools/workflows/list-available-tools.js +37 -0
- package/dist/tools/workflows/list-available-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-available-workflows.js +29 -0
- package/dist/tools/workflows/list-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-workflows.js +30 -0
- package/dist/tools/workflows/run-workflow.d.ts +9 -0
- package/dist/tools/workflows/run-workflow.js +49 -0
- package/dist/tools/workflows/save-workflow.d.ts +1125 -0
- package/dist/tools/workflows/save-workflow.js +25 -0
- package/dist/tools/workflows/tool-ids.d.ts +16 -0
- package/dist/tools/workflows/tool-ids.js +17 -0
- package/dist/utils/binaries.d.ts +7 -0
- package/dist/utils/binaries.js +97 -0
- package/dist/utils/debug-log.d.ts +12 -0
- package/dist/utils/debug-log.js +56 -0
- package/dist/utils/discarding-scores-storage.d.ts +33 -0
- package/dist/utils/discarding-scores-storage.js +51 -0
- package/dist/utils/errors.d.ts +36 -0
- package/dist/utils/errors.js +215 -0
- package/dist/utils/gateway-sync.d.ts +26 -0
- package/dist/utils/gateway-sync.js +58 -0
- package/dist/utils/local-observability.d.ts +19 -0
- package/dist/utils/local-observability.js +54 -0
- package/dist/utils/maintenance-lock.d.ts +42 -0
- package/dist/utils/maintenance-lock.js +196 -0
- package/dist/utils/notification-dispatch.d.ts +74 -0
- package/dist/utils/notification-dispatch.js +128 -0
- package/dist/utils/open-url.d.ts +10 -0
- package/dist/utils/open-url.js +27 -0
- package/dist/utils/path-security.d.ts +2 -0
- package/dist/utils/path-security.js +7 -0
- package/dist/utils/plan-diff.d.ts +25 -0
- package/dist/utils/plan-diff.js +59 -0
- package/dist/utils/plans.d.ts +61 -0
- package/dist/utils/plans.js +120 -0
- package/dist/utils/project.d.ts +160 -0
- package/dist/utils/project.js +361 -0
- package/dist/utils/prune-cli.d.ts +24 -0
- package/dist/utils/prune-cli.js +124 -0
- package/dist/utils/signals-pubsub.d.ts +103 -0
- package/dist/utils/signals-pubsub.js +409 -0
- package/dist/utils/slash-command-loader.d.ts +52 -0
- package/dist/utils/slash-command-loader.js +139 -0
- package/dist/utils/slash-command-processor.d.ts +14 -0
- package/dist/utils/slash-command-processor.js +106 -0
- package/dist/utils/stdin-pipe.d.ts +33 -0
- package/dist/utils/stdin-pipe.js +93 -0
- package/dist/utils/storage-factory.d.ts +50 -0
- package/dist/utils/storage-factory.js +118 -0
- package/dist/utils/storage-maintenance.d.ts +121 -0
- package/dist/utils/storage-maintenance.js +352 -0
- package/dist/utils/thread-lock.d.ts +26 -0
- package/dist/utils/thread-lock.js +109 -0
- package/dist/utils/token-estimator.d.ts +3 -0
- package/dist/utils/token-estimator.js +19 -0
- package/dist/utils/update-check.d.ts +151 -0
- package/dist/utils/update-check.js +430 -0
- package/dist/utils/wake-session.d.ts +44 -0
- package/dist/utils/wake-session.js +83 -0
- package/dist/voice/stt-registry.d.ts +67 -0
- package/dist/voice/stt-registry.js +144 -0
- package/dist/voice/transcribe.d.ts +10 -0
- package/dist/voice/transcribe.js +75 -0
- package/dist/workflows/register-primitives.d.ts +52 -0
- package/dist/workflows/register-primitives.js +40 -0
- package/dist/workflows/service.d.ts +64 -0
- package/dist/workflows/service.js +50 -0
- package/package.json +117 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { MIN_OBSERVATION_THRESHOLD } from "../constants.js";
|
|
2
|
+
import { LOCAL_KNOWLEDGE_ORG_ID } from "../knowledge-scope.js";
|
|
3
|
+
import { MASTRACODE_AUTO_OM_MODELS, resolveAutoOMModelId } from "../onboarding/packs.js";
|
|
4
|
+
import { loadSettings } from "../onboarding/settings.js";
|
|
5
|
+
import "../providers/anthropic-prompt-cache.js";
|
|
6
|
+
import { getOmScope } from "../utils/project.js";
|
|
7
|
+
import { embedInSubprocess } from "./fastembed-subprocess.js";
|
|
8
|
+
import { canUseProvider, getActiveMemoryRoute, resolveModel } from "./model.js";
|
|
9
|
+
import { ModelRouterEmbeddingModel } from "@mastra/core/llm";
|
|
10
|
+
import { Memory } from "@mastra/memory";
|
|
11
|
+
// src/agents/memory.ts
|
|
12
|
+
/**
|
|
13
|
+
* `fastembed.small`, run in a reusable child process (see `FastembedWorker`) so ONNX Runtime and the model
|
|
14
|
+
* never load into the agent process.
|
|
15
|
+
*/
|
|
16
|
+
const lazyFastembedSmall = {
|
|
17
|
+
specificationVersion: "v3",
|
|
18
|
+
provider: "fastembed",
|
|
19
|
+
modelId: "bge-small-en-v1.5",
|
|
20
|
+
maxEmbeddingsPerCall: 256,
|
|
21
|
+
supportsParallelCalls: true,
|
|
22
|
+
doEmbed: (options) => embedInSubprocess(options)
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Resolve the active model route's memory models, starting at a same-thread
|
|
26
|
+
* pending fallback hop. Returns `'auto'` when the route's first memory model is
|
|
27
|
+
* Auto, and `undefined` when the route sets no memory model.
|
|
28
|
+
*/
|
|
29
|
+
function resolveRouteMemoryModels(state, threadId, resolve) {
|
|
30
|
+
const memoryRoute = getActiveMemoryRoute(state, threadId);
|
|
31
|
+
if (memoryRoute[0]?.memoryModelId === "auto") return "auto";
|
|
32
|
+
const seenModelIds = /* @__PURE__ */ new Set();
|
|
33
|
+
const appearances = /* @__PURE__ */ new Map();
|
|
34
|
+
const entries = [];
|
|
35
|
+
for (const entry of memoryRoute) {
|
|
36
|
+
if (!entry.memoryModelId || entry.memoryModelId === "auto" || seenModelIds.has(entry.memoryModelId)) continue;
|
|
37
|
+
seenModelIds.add(entry.memoryModelId);
|
|
38
|
+
const occurrence = (appearances.get(entry.id) ?? 0) + 1;
|
|
39
|
+
appearances.set(entry.id, occurrence);
|
|
40
|
+
try {
|
|
41
|
+
entries.push({
|
|
42
|
+
id: `${entry.id}:memory${occurrence === 1 ? "" : `#${occurrence}`}`,
|
|
43
|
+
model: resolve(entry.memoryModelId)
|
|
44
|
+
});
|
|
45
|
+
} catch {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return entries.length > 0 ? entries : void 0;
|
|
50
|
+
}
|
|
51
|
+
function getFactoryMemorySettingsContext(requestContext) {
|
|
52
|
+
return requestContext.get("mastra__factoryMemorySettings");
|
|
53
|
+
}
|
|
54
|
+
function isFactoryMemorySettingsUnavailable(settings) {
|
|
55
|
+
return settings !== null && typeof settings === "object" && "status" in settings && settings.status === "unavailable";
|
|
56
|
+
}
|
|
57
|
+
function getMainModelId(requestContext) {
|
|
58
|
+
const controller = requestContext.get("controller");
|
|
59
|
+
return controller?.session.modelId || controller?.getState()?.currentModelId;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolve one OM role's model for this invocation. Returns `'auto'` for Memory's
|
|
63
|
+
* auto policy, or a concrete model. Factory's DB row is authoritative for
|
|
64
|
+
* Factory sessions (an unreadable row falls back to auto). Otherwise the active
|
|
65
|
+
* model route's memory models win, then the per-role selection, then legacy
|
|
66
|
+
* concrete settings.
|
|
67
|
+
*/
|
|
68
|
+
function resolveOmRoleModelForRequest(role, requestContext, settingsPath, options) {
|
|
69
|
+
const controller = requestContext.get("controller");
|
|
70
|
+
const state = controller?.getState();
|
|
71
|
+
const resolveOptions = {
|
|
72
|
+
remapForCodexOAuth: true,
|
|
73
|
+
requestContext,
|
|
74
|
+
anthropicPromptCacheScope: "system"
|
|
75
|
+
};
|
|
76
|
+
const factorySettingsContext = getFactoryMemorySettingsContext(requestContext);
|
|
77
|
+
const isFactory = typeof state?.factoryProjectId === "string";
|
|
78
|
+
const useModel = (modelId) => {
|
|
79
|
+
requestContext.set(`om.${role}.selectionMode`, "model");
|
|
80
|
+
requestContext.set(`om.${role}.effectiveModelId`, modelId);
|
|
81
|
+
return resolveModel(modelId, resolveOptions);
|
|
82
|
+
};
|
|
83
|
+
const useAuto = () => {
|
|
84
|
+
requestContext.set(`om.${role}.selectionMode`, "auto");
|
|
85
|
+
requestContext.set(`om.${role}.effectiveModelId`, resolveAutoOMModelId(getMainModelId(requestContext), (providerId) => canUseProvider(providerId, { requestContext })));
|
|
86
|
+
return "auto";
|
|
87
|
+
};
|
|
88
|
+
if (isFactoryMemorySettingsUnavailable(factorySettingsContext) || factorySettingsContext === void 0 && isFactory) return useAuto();
|
|
89
|
+
if (factorySettingsContext !== void 0) {
|
|
90
|
+
const factoryModelId = factorySettingsContext?.[`${role}ModelId`];
|
|
91
|
+
return factoryModelId ? useModel(factoryModelId) : useAuto();
|
|
92
|
+
}
|
|
93
|
+
const settings = options?.disableSettingsOmSeed ? void 0 : loadSettings(settingsPath);
|
|
94
|
+
const routeMemory = resolveRouteMemoryModels(state, controller?.threadId, (modelId) => resolveModel(modelId, resolveOptions));
|
|
95
|
+
if (routeMemory === "auto") return useAuto();
|
|
96
|
+
if (routeMemory) {
|
|
97
|
+
requestContext.set(`om.${role}.selectionMode`, "model");
|
|
98
|
+
requestContext.set(`om.${role}.effectiveModelId`, routeMemory[0]?.model.modelId);
|
|
99
|
+
return routeMemory.length === 1 ? routeMemory[0].model : routeMemory;
|
|
100
|
+
}
|
|
101
|
+
const selection = state?.[`${role}ModelSelection`];
|
|
102
|
+
if (selection === "auto") return useAuto();
|
|
103
|
+
if (typeof selection === "string" && selection) return useModel(selection);
|
|
104
|
+
if (selection && typeof selection === "object" && "modelId" in selection && typeof selection.modelId === "string" && selection.modelId) return useModel(selection.modelId);
|
|
105
|
+
const roleOverride = role === "observer" ? settings?.models?.observerModelOverride : settings?.models?.reflectorModelOverride;
|
|
106
|
+
if (roleOverride) return useModel(roleOverride);
|
|
107
|
+
const legacyModelId = state?.[`${role}ModelId`];
|
|
108
|
+
if (typeof legacyModelId === "string" && legacyModelId) return useModel(legacyModelId);
|
|
109
|
+
return useAuto();
|
|
110
|
+
}
|
|
111
|
+
const DYNAMIC_AGENTS_MD_INSTRUCTION = "Messages wrapped in <system-reminder type=\"dynamic-agents-md\" ...>...</system-reminder> are ephemeral project-context instructions injected from files on disk. Do NOT observe or extract information from these messages — they are reloaded automatically when needed and should not be stored in memory.";
|
|
112
|
+
const CAVEMAN_OM_INSTRUCTION = `Respond terse like smart caveman. All technical substance stay. Only fluff die.
|
|
113
|
+
|
|
114
|
+
Use full caveman compression style.
|
|
115
|
+
|
|
116
|
+
Drop: articles (a/an/the), filler (just/really/basically/actually/simply), pleasantries (sure/certainly/of course/happy to), hedging. Fragments OK. Short synonyms (big not extensive, fix not "implement a solution for"). Technical terms exact. Code blocks unchanged. Errors quoted exact. Leave out the words "agent" and "assistant" at the start of each observation line, it is assumed each line is referring to the assistant unless it specifically says it was about the user. Leave out parenthesis and other text characters like * that would not contribute to understanding the observations.
|
|
117
|
+
|
|
118
|
+
Pattern: \`[thing] [action] [reason]. [next step]\`
|
|
119
|
+
|
|
120
|
+
Not: "Sure! I'd be happy to help you with that. The issue you're experiencing is likely caused by..."
|
|
121
|
+
Yes: "Bug in auth middleware. Token expiry check use < not <=. Fix:"
|
|
122
|
+
|
|
123
|
+
Example 1
|
|
124
|
+
🔴 14:31 user asks why React component rerenders
|
|
125
|
+
🟡 14:32 saw inline object prop create new ref each render, cause rerender
|
|
126
|
+
✅ 14:34 fixed render issue by wrap object in useMemo
|
|
127
|
+
|
|
128
|
+
Example 2
|
|
129
|
+
🟡 15:10 explained pool reuse DB connections, skip repeat handshake overhead
|
|
130
|
+
|
|
131
|
+
Don't say "Agent did x", say "did x". It will be assumed the agent did what was observed. The who should only be specified for the user or other third parties: "user asked x"
|
|
132
|
+
|
|
133
|
+
Drop caveman for: security warnings, irreversible action confirmations, multi-step sequences where fragment order risks misread, user asks to clarify or repeats question, and anything that requires remembering verbatim content. Resume caveman after clear part done`;
|
|
134
|
+
/**
|
|
135
|
+
* Mastra Code's own title instructions: session lists show one narrow line per
|
|
136
|
+
* title. They differ from Core's default in three ways: the title is 3 to 5
|
|
137
|
+
* words instead of up to 80 characters, it names the topic instead of
|
|
138
|
+
* summarising the message, and it does not end with a period.
|
|
139
|
+
*/
|
|
140
|
+
const TITLE_INSTRUCTIONS = `
|
|
141
|
+
- you will generate a short title based on a conversation transcript between a user and an assistant
|
|
142
|
+
- the transcript lines are prefixed with "User:" and "Assistant:" — never reply to, answer, or continue the transcript
|
|
143
|
+
- always produce a title, even when the transcript is only a greeting or trivial exchange
|
|
144
|
+
- the title must be 3 to 5 words long
|
|
145
|
+
- the title should name the topic of the user's message, not repeat or answer it
|
|
146
|
+
- do not use quotes or colons, and do not end with a period
|
|
147
|
+
- the entire text you return will be used as the title`;
|
|
148
|
+
/**
|
|
149
|
+
* Dynamic memory factory function.
|
|
150
|
+
* Reads OM thresholds from controller state via requestContext.
|
|
151
|
+
* Model functions also read from requestContext (no mutable bridge needed).
|
|
152
|
+
*/
|
|
153
|
+
function getDynamicMemory(storage, vector, settingsPath, options) {
|
|
154
|
+
const embedder = !vector ? void 0 : typeof options?.embedder === "string" ? new ModelRouterEmbeddingModel(options.embedder) : options?.embedder ?? lazyFastembedSmall;
|
|
155
|
+
let cachedMemory = null;
|
|
156
|
+
let cachedMemoryKey = null;
|
|
157
|
+
const retiredMemories = /* @__PURE__ */ new Set();
|
|
158
|
+
const getObserverModel = ({ requestContext }) => resolveOmRoleModelForRequest("observer", requestContext, settingsPath, options);
|
|
159
|
+
const getReflectorModel = ({ requestContext }) => resolveOmRoleModelForRequest("reflector", requestContext, settingsPath, options);
|
|
160
|
+
const resolveMemoryModel = (modelId, { requestContext }) => resolveModel(modelId, {
|
|
161
|
+
remapForCodexOAuth: true,
|
|
162
|
+
requestContext,
|
|
163
|
+
anthropicPromptCacheScope: "system"
|
|
164
|
+
});
|
|
165
|
+
const resolveMemory = ({ requestContext }) => {
|
|
166
|
+
const state = requestContext.get("controller")?.getState();
|
|
167
|
+
const factoryProjectId = state?.factoryProjectId;
|
|
168
|
+
const isFactory = typeof factoryProjectId === "string" && factoryProjectId.trim().length > 0;
|
|
169
|
+
const omScope = isFactory ? "thread" : state?.omScope ?? getOmScope(state?.projectPath);
|
|
170
|
+
const isResourceScope = omScope === "resource";
|
|
171
|
+
const factorySettingsContext = getFactoryMemorySettingsContext(requestContext);
|
|
172
|
+
const factorySettings = isFactoryMemorySettingsUnavailable(factorySettingsContext) || factorySettingsContext === void 0 && isFactory ? null : factorySettingsContext;
|
|
173
|
+
const storedObsThreshold = factorySettings !== void 0 ? factorySettings?.observationThreshold ?? 3e4 : state?.observationThreshold ?? 3e4;
|
|
174
|
+
const obsThreshold = isResourceScope ? storedObsThreshold : Math.max(storedObsThreshold, MIN_OBSERVATION_THRESHOLD);
|
|
175
|
+
const refThreshold = factorySettings !== void 0 ? factorySettings?.reflectionThreshold ?? 4e4 : state?.reflectionThreshold ?? 4e4;
|
|
176
|
+
const caveman = state?.cavemanObservations ?? false;
|
|
177
|
+
const observerPreviousObservationTokens = 1e3;
|
|
178
|
+
const observeAttachments = factorySettings !== void 0 ? factorySettings?.observeAttachments ?? "auto" : state?.observeAttachments;
|
|
179
|
+
const cacheKey = `${obsThreshold}:${refThreshold}:${omScope}:${observerPreviousObservationTokens}:${caveman ? 1 : 0}:${observeAttachments}:${isFactory ? 1 : 0}`;
|
|
180
|
+
if (cachedMemory && cachedMemoryKey === cacheKey) return cachedMemory;
|
|
181
|
+
const observerInstruction = caveman ? `${DYNAMIC_AGENTS_MD_INSTRUCTION}\n\n${CAVEMAN_OM_INSTRUCTION}` : DYNAMIC_AGENTS_MD_INSTRUCTION;
|
|
182
|
+
const reflectionInstruction = caveman ? CAVEMAN_OM_INSTRUCTION : void 0;
|
|
183
|
+
if (cachedMemory) {
|
|
184
|
+
const retired = cachedMemory;
|
|
185
|
+
retiredMemories.add(retired);
|
|
186
|
+
retired.settled().catch(() => {}).finally(() => retiredMemories.delete(retired));
|
|
187
|
+
}
|
|
188
|
+
cachedMemory = new Memory({
|
|
189
|
+
storage,
|
|
190
|
+
vector: vector || false,
|
|
191
|
+
embedder,
|
|
192
|
+
embedderOptions: options?.embedderOptions,
|
|
193
|
+
options: {
|
|
194
|
+
generateTitle: process.env.MASTRACODE_DISABLE_TITLE_GENERATION === "1" ? false : {
|
|
195
|
+
instructions: TITLE_INSTRUCTIONS,
|
|
196
|
+
model: ({ requestContext }) => {
|
|
197
|
+
const resolved = getObserverModel({ requestContext });
|
|
198
|
+
if (resolved === "auto") return resolveMemoryModel(resolveAutoOMModelId(getMainModelId(requestContext), (providerId) => canUseProvider(providerId, { requestContext })), { requestContext });
|
|
199
|
+
return Array.isArray(resolved) ? resolved[0].model : resolved;
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
observationalMemory: process.env.MASTRACODE_DISABLE_OBSERVATIONAL_MEMORY === "1" ? false : {
|
|
203
|
+
enabled: true,
|
|
204
|
+
autoModels: MASTRACODE_AUTO_OM_MODELS,
|
|
205
|
+
canUseProvider,
|
|
206
|
+
resolveModel: resolveMemoryModel,
|
|
207
|
+
temporalMarkers: true,
|
|
208
|
+
retrieval: vector ? { vector: true } : true,
|
|
209
|
+
scope: omScope,
|
|
210
|
+
activateAfterIdle: {
|
|
211
|
+
default: "auto",
|
|
212
|
+
anthropic: "1h"
|
|
213
|
+
},
|
|
214
|
+
activateOnProviderChange: true,
|
|
215
|
+
observation: {
|
|
216
|
+
bufferTokens: isResourceScope ? false : 1 / 5,
|
|
217
|
+
bufferActivation: isResourceScope ? void 0 : 2e3,
|
|
218
|
+
model: getObserverModel,
|
|
219
|
+
messageTokens: obsThreshold,
|
|
220
|
+
blockAfter: 2,
|
|
221
|
+
previousObserverTokens: observerPreviousObservationTokens,
|
|
222
|
+
threadTitle: true,
|
|
223
|
+
instruction: observerInstruction,
|
|
224
|
+
observeAttachments
|
|
225
|
+
},
|
|
226
|
+
reflection: {
|
|
227
|
+
bufferActivation: isResourceScope ? void 0 : 1 / 2,
|
|
228
|
+
blockAfter: 1.1,
|
|
229
|
+
model: getReflectorModel,
|
|
230
|
+
observationTokens: refThreshold,
|
|
231
|
+
instruction: reflectionInstruction
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
cachedMemoryKey = cacheKey;
|
|
237
|
+
return cachedMemory;
|
|
238
|
+
};
|
|
239
|
+
return Object.assign(resolveMemory, {
|
|
240
|
+
/**
|
|
241
|
+
* Wait for background memory work (buffered observations, reflections, indexing) in every
|
|
242
|
+
* instance this factory created. Await before closing storage.
|
|
243
|
+
*/
|
|
244
|
+
async settled() {
|
|
245
|
+
await Promise.allSettled([cachedMemory?.settled(), ...[...retiredMemories].map((memory) => memory.settled())]);
|
|
246
|
+
} });
|
|
247
|
+
}
|
|
248
|
+
export { LOCAL_KNOWLEDGE_ORG_ID, TITLE_INSTRUCTIONS, getDynamicMemory };
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { ModelWithRetries } from '@mastra/core/agent';
|
|
2
|
+
import { ModelRouterLanguageModel } from '@mastra/core/llm';
|
|
3
|
+
import type { GatewayLanguageModel, IdentifiedModelConfig, MastraModelGatewayInterface } from '@mastra/core/llm';
|
|
4
|
+
import { RequestContext } from '@mastra/core/request-context';
|
|
5
|
+
import type { RequestContextReader } from '../auth/account-routing-context.js';
|
|
6
|
+
import type { CredentialStore } from '../auth/types.js';
|
|
7
|
+
import type { AnthropicPromptCacheScope } from '../providers/anthropic-prompt-cache.js';
|
|
8
|
+
import type { ThinkingLevelSetting } from '../thinking.js';
|
|
9
|
+
import { MastraCodeGateway } from './mastracode-gateway.js';
|
|
10
|
+
import type { MastraCodeGatewayOptions } from './mastracode-gateway.js';
|
|
11
|
+
export { getAnthropicApiKey, getOpenAIApiKey, MASTRACODE_GATEWAY_ID, MastraCodeGateway, remapOpenAIModelForCodexOAuth, resolveAuth, } from './mastracode-gateway.js';
|
|
12
|
+
export type { MastraCodeCustomProvider, MastraCodeGatewayOptions } from './mastracode-gateway.js';
|
|
13
|
+
export { setCredentialStoreProvider, hasCredentialStoreProvider, resolveTenantFromRequestContext, } from './credential-resolver.js';
|
|
14
|
+
export type { CredentialTenant, CredentialStoreProvider } from './credential-resolver.js';
|
|
15
|
+
export { setCustomProvidersSource, hasCustomProvidersSource, resolveCustomProviders, } from './custom-provider-source.js';
|
|
16
|
+
export type { CustomProvidersSource } from './custom-provider-source.js';
|
|
17
|
+
type ResolvedModel = GatewayLanguageModel | ModelRouterLanguageModel;
|
|
18
|
+
export declare function createRequestScopedCredentialStore(base: CredentialStore, requestContext?: RequestContextReader): CredentialStore;
|
|
19
|
+
export declare function createMastraCodeGateway(options: MastraCodeGatewayOptions): MastraCodeGateway;
|
|
20
|
+
export declare function createMastraCodeModelCatalogProvider(gateway: MastraModelGatewayInterface): import("@mastra/core/harness").CustomModelCatalogProvider;
|
|
21
|
+
/**
|
|
22
|
+
* Placeholder for future model ID normalization.
|
|
23
|
+
* Currently returns the input unchanged, but exists as a seam
|
|
24
|
+
* for aliasing, casing fixes, or validation in the future.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveModelId(modelId: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Resolve a model ID to the correct provider instance.
|
|
29
|
+
* Shared by the main agent, observer, and reflector.
|
|
30
|
+
*
|
|
31
|
+
* - For anthropic/* models: Uses stored OAuth credentials when present, otherwise direct API key
|
|
32
|
+
* - For openai/* models: Uses OAuth when configured, otherwise direct API key from AuthStorage
|
|
33
|
+
* - For moonshotai/* models: Uses Moonshot AI Anthropic-compatible endpoint
|
|
34
|
+
* - For all other providers: Uses Mastra's model router (models.dev gateway)
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveModel(modelId: string, options?: {
|
|
37
|
+
thinkingLevel?: ThinkingLevelSetting;
|
|
38
|
+
remapForCodexOAuth?: boolean;
|
|
39
|
+
requestContext?: RequestContext;
|
|
40
|
+
anthropicPromptCacheScope?: AnthropicPromptCacheScope;
|
|
41
|
+
}): ResolvedModel;
|
|
42
|
+
/**
|
|
43
|
+
* Which provider-executed web search tool fits the transport a model resolves to:
|
|
44
|
+
* - `anthropic` / `openai`: the native provider API (direct keys, and Claude or
|
|
45
|
+
* Codex OAuth, which keep the native API even through the Mastra gateway).
|
|
46
|
+
* - `mastra-gateway`: a `mastra/` alias with a gateway key and no OAuth, which
|
|
47
|
+
* `resolveModelForRequest` sends to the gateway's OpenRouter chat endpoint.
|
|
48
|
+
* Other providers have no built-in search. Mirrors the routing in
|
|
49
|
+
* `resolveModelForRequest` and `MastraCodeGateway`, so the registered tool and
|
|
50
|
+
* the prompt guidance follow the request the model will actually make.
|
|
51
|
+
*/
|
|
52
|
+
export type ProviderWebSearchRoute = 'anthropic' | 'openai' | 'mastra-gateway';
|
|
53
|
+
/**
|
|
54
|
+
* Prepares tenant credential policy when the web search route depends on it and the
|
|
55
|
+
* request hasn't been prepared yet. Model resolution prepares its own context only when
|
|
56
|
+
* the model is invoked, after tools and instructions are built. Returns undefined when
|
|
57
|
+
* there is nothing to prepare, so callers can stay synchronous.
|
|
58
|
+
*/
|
|
59
|
+
export declare function prepareProviderWebSearchRoute(modelId: string | undefined, options?: {
|
|
60
|
+
requestContext?: RequestContextReader;
|
|
61
|
+
}): Promise<void> | undefined;
|
|
62
|
+
export declare function resolveProviderWebSearchRoute(modelId: string | undefined, options?: {
|
|
63
|
+
requestContext?: RequestContextReader;
|
|
64
|
+
}): ProviderWebSearchRoute | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Whether `resolveModel` can authenticate a provider for this request, using the
|
|
67
|
+
* same credential lookup: the tenant store in deployed Factory (no environment
|
|
68
|
+
* keys), otherwise local auth and then the provider's environment keys.
|
|
69
|
+
*/
|
|
70
|
+
export declare function canUseProvider(providerId: string, options?: {
|
|
71
|
+
requestContext?: RequestContext;
|
|
72
|
+
}): boolean;
|
|
73
|
+
export interface ThinkingRequestContext {
|
|
74
|
+
state?: {
|
|
75
|
+
thinkingLevel?: unknown;
|
|
76
|
+
};
|
|
77
|
+
session?: {
|
|
78
|
+
modeId?: string;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Resolve the effective thinking level for the current request.
|
|
83
|
+
*
|
|
84
|
+
* Precedence:
|
|
85
|
+
* 1. Session override (`state.thinkingLevel`, set via /think or the session
|
|
86
|
+
* settings panel).
|
|
87
|
+
* 2. The host's default for this request (`hostDefault`), when the host
|
|
88
|
+
* stores thinking defaults itself (the Factory keeps one per Factory).
|
|
89
|
+
* 3. Per-mode default from settings (`models.modeThinkingDefaults[mode]`),
|
|
90
|
+
* only when the context carries a session mode.
|
|
91
|
+
* 4. Global default (`preferences.thinkingLevel`).
|
|
92
|
+
*
|
|
93
|
+
* Resolved per-request (not seeded at session start) so configuration changes
|
|
94
|
+
* apply to the next request of every session — including automated
|
|
95
|
+
* (rule-driven) Factory runs that nobody ever opens interactively.
|
|
96
|
+
*/
|
|
97
|
+
export declare function resolveRequestThinkingLevel(agentControllerContext: ThinkingRequestContext | undefined, settingsPath?: string, hostDefault?: ThinkingLevelSetting): ThinkingLevelSetting;
|
|
98
|
+
/**
|
|
99
|
+
* Dynamic model function that reads the current model and optional ordered
|
|
100
|
+
* fallback route from controller state. Route entry ids are opaque host-owned
|
|
101
|
+
* identifiers; repeated ids receive occurrence suffixes because core tracks the
|
|
102
|
+
* active fallback index by id across agentic steps.
|
|
103
|
+
*/
|
|
104
|
+
export declare function getDynamicModel({ requestContext }: {
|
|
105
|
+
requestContext: RequestContext;
|
|
106
|
+
}, settingsPath?: string, { modeless, defaultThinkingLevel }?: {
|
|
107
|
+
modeless?: boolean;
|
|
108
|
+
defaultThinkingLevel?: ThinkingLevelSetting;
|
|
109
|
+
}): IdentifiedModelConfig | ModelWithRetries[];
|
|
110
|
+
type MemoryRouteState = {
|
|
111
|
+
modelRoute?: {
|
|
112
|
+
entries?: Array<{
|
|
113
|
+
id?: unknown;
|
|
114
|
+
memoryModelId?: unknown;
|
|
115
|
+
}>;
|
|
116
|
+
};
|
|
117
|
+
mastracodePendingModelFallback?: {
|
|
118
|
+
toEntryId?: unknown;
|
|
119
|
+
threadId?: unknown;
|
|
120
|
+
} | null;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* The active model route for memory: the session route, starting at a pending
|
|
124
|
+
* fallback hop captured for this thread.
|
|
125
|
+
*/
|
|
126
|
+
export declare function getActiveMemoryRoute<TEntry extends {
|
|
127
|
+
id?: unknown;
|
|
128
|
+
memoryModelId?: unknown;
|
|
129
|
+
}>(state: {
|
|
130
|
+
modelRoute?: {
|
|
131
|
+
entries?: TEntry[];
|
|
132
|
+
};
|
|
133
|
+
mastracodePendingModelFallback?: MemoryRouteState['mastracodePendingModelFallback'];
|
|
134
|
+
} | undefined, threadId?: string | null): TEntry[];
|
|
135
|
+
/**
|
|
136
|
+
* The memory model the active route applies to both OM roles: `'auto'`, the
|
|
137
|
+
* first concrete memory model, or `undefined` when the route sets none (both
|
|
138
|
+
* roles then follow their `/om` settings).
|
|
139
|
+
*/
|
|
140
|
+
export declare function getActiveRouteMemoryModelId(state: Readonly<Record<string, unknown>> | undefined, threadId?: string | null): string | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Goal judge model resolver for the agent's `goal.judge` config. Resolves the
|
|
143
|
+
* configured goal judge model through mastracode's gateway so provider
|
|
144
|
+
* credentials (stored in auth storage, not just env) are injected — a bare model
|
|
145
|
+
* id handed to core's default model router would fail to find the API key.
|
|
146
|
+
*
|
|
147
|
+
* Returns `undefined` when no judge model is configured, which keeps the goal
|
|
148
|
+
* step a complete no-op (the goal mechanism requires a judge to do anything).
|
|
149
|
+
*
|
|
150
|
+
* `settingsPath` must be the same source `createMastraCode()` reads from so the
|
|
151
|
+
* judge model and the goal budget (`goalMaxTurns`) come from one config — with a
|
|
152
|
+
* custom `settingsPath` a bare `loadSettings()` here could read a different file
|
|
153
|
+
* and silently turn the goal step into a no-op.
|
|
154
|
+
*/
|
|
155
|
+
export declare function getGoalJudgeModel({ requestContext }: {
|
|
156
|
+
requestContext: RequestContext;
|
|
157
|
+
}, settingsPath?: string): ResolvedModel | undefined;
|
|
158
|
+
//# sourceMappingURL=model.d.ts.map
|