@mastra/code-sdk 1.13.1-alpha.0 → 1.14.0-alpha.2
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/agents/credential-resolver.d.ts +26 -22
- package/dist/agents/credential-resolver.d.ts.map +1 -1
- package/dist/agents/credential-resolver.js +54 -34
- package/dist/agents/credential-resolver.js.map +1 -1
- package/dist/agents/mastracode-gateway.d.ts.map +1 -1
- package/dist/agents/mastracode-gateway.js +18 -44
- package/dist/agents/mastracode-gateway.js.map +1 -1
- package/dist/agents/memory.d.ts.map +1 -1
- package/dist/agents/memory.js.map +1 -1
- package/dist/agents/model.d.ts +9 -5
- package/dist/agents/model.d.ts.map +1 -1
- package/dist/agents/model.js +42 -8
- package/dist/agents/model.js.map +1 -1
- package/dist/auth/account-rotation-processor.d.ts +2 -0
- package/dist/auth/account-rotation-processor.d.ts.map +1 -1
- package/dist/auth/account-rotation-processor.js +4 -3
- package/dist/auth/account-rotation-processor.js.map +1 -1
- package/dist/auth/storage.js +1 -1
- package/dist/auth/storage.js.map +1 -1
- package/dist/index.d.ts +14 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/providers/github-copilot-gateway.d.ts +35 -0
- package/dist/providers/github-copilot-gateway.d.ts.map +1 -0
- package/dist/providers/github-copilot-gateway.js +61 -0
- package/dist/providers/github-copilot-gateway.js.map +1 -0
- package/dist/providers/kimi-coding.d.ts +0 -1
- package/dist/providers/kimi-coding.d.ts.map +1 -1
- package/dist/providers/kimi-coding.js +1 -7
- package/dist/providers/kimi-coding.js.map +1 -1
- package/dist/providers/model-ids.d.ts +18 -0
- package/dist/providers/model-ids.d.ts.map +1 -1
- package/dist/providers/model-ids.js +39 -1
- package/dist/providers/model-ids.js.map +1 -1
- package/dist/providers/provider-thinking.d.ts +5 -0
- package/dist/providers/provider-thinking.d.ts.map +1 -1
- package/dist/providers/provider-thinking.js +32 -2
- package/dist/providers/provider-thinking.js.map +1 -1
- package/dist/providers/thinking-request.d.ts +14 -0
- package/dist/providers/thinking-request.d.ts.map +1 -0
- package/dist/providers/thinking-request.js +90 -0
- package/dist/providers/thinking-request.js.map +1 -0
- package/dist/providers/xai.d.ts +2 -2
- package/dist/providers/xai.d.ts.map +1 -1
- package/dist/providers/xai.js.map +1 -1
- package/dist/schema.d.ts +13 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +2 -0
- package/dist/schema.js.map +1 -1
- package/dist/thinking.d.ts +1 -0
- package/dist/thinking.d.ts.map +1 -1
- package/dist/thinking.js +23 -5
- package/dist/thinking.js.map +1 -1
- package/package.json +10 -10
- package/dist/providers/deepseek-thinking.d.ts +0 -4
- package/dist/providers/deepseek-thinking.d.ts.map +0 -1
- package/dist/providers/deepseek-thinking.js +0 -16
- package/dist/providers/deepseek-thinking.js.map +0 -1
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAExD,MAAM,MAAM,sBAAsB,GAAG;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG,sBAAsB,CAAC;AAE/E,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,a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AAG,mBAAmB,CAAC;QACxE,aAAa,EAAE,OAAO,CAAC;KACxB,CAAC;CACH;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+KnB,CAAC"}
|
package/dist/schema.js
CHANGED
|
@@ -19,6 +19,8 @@ const stateSchema = z.object({
|
|
|
19
19
|
projectPath: z.string().optional(),
|
|
20
20
|
projectName: z.string().optional(),
|
|
21
21
|
factoryProjectId: z.string().optional(),
|
|
22
|
+
factoryModelScope: z.enum(["factory", "user"]).optional(),
|
|
23
|
+
factoryOwnerUserId: z.string().optional(),
|
|
22
24
|
factoryOrgId: z.string().optional(),
|
|
23
25
|
factoryOrgUnresolved: z.boolean().optional(),
|
|
24
26
|
projectRepositoryId: z.string().optional(),
|
package/dist/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","names":[],"sources":["../src/schema.ts"],"sourcesContent":["import type { OMModel } from '@mastra/core/agent-controller';\nimport { z } from 'zod';\nimport { DEFAULT_CONFIG_DIR, MODEL_ROUTE_MAX_ENTRIES, MODEL_ROUTE_MAX_FIELD_LENGTH } from './constants.js';\nimport { THINKING_LEVEL_VALUES } from './thinking.js';\nimport type { ThinkingLevelSetting } from './thinking.js';\n\nexport type PermissionPolicy = 'allow' | 'ask' | 'deny';\n\nexport type MastraCodeSessionState = {\n currentModelId: string;\n modeId: string;\n};\n\nexport type MastraCodeComposedState = MastraCodeState & MastraCodeSessionState;\n\nexport interface ModelRouteEntry {\n id: string;\n label: string;\n modelId: string;\n accountId?: string;\n memoryModelId?: string;\n}\n\nexport interface ModelRoute {\n entries: ModelRouteEntry[];\n}\n\nexport interface PendingModelFallback {\n fromEntryId: string;\n toEntryId: string;\n toModelId: string;\n threadId?: string;\n reason: 'pool-exhausted' | 'persistent-outage';\n at: string;\n}\n\nexport interface MastraCodeState {\n [key: string]: unknown;\n [key: `subagentModelId_${string}`]: string | undefined;\n subagentModelId?: string;\n projectPath?: string;\n projectName?: string;\n /** Factory project that owns this session. */\n factoryProjectId?: string;\n /** Authoritative organization id seeded by factory at session construction. */\n factoryOrgId?: string;\n /**\n * Factory owns this session but could not resolve its organization. Knowledge\n * capture refuses rather than filing under a substituted identity; without the\n * marker a projectless factory session is indistinguishable from a local one.\n */\n factoryOrgUnresolved?: boolean;\n /** Linked repository used by this session when source-control execution is required. */\n projectRepositoryId?: string;\n /** Active feature branch checked out in the session workdir. */\n branch?: string;\n /**\n * The session's checkout contains third-party content (e.g. a PR branch\n * under review). Project-level instruction files (AGENTS.md, CLAUDE.md)\n * are attacker-writable there and must not be ingested into the system\n * prompt or injected as reminders.\n */\n untrustedCheckout?: boolean;\n /**\n * Trusted git ref (typically the PR's base branch) to serve project\n * instruction files from when the checkout is untrusted. Without it,\n * project-scope instruction files are skipped entirely.\n */\n baseRef?: string;\n /**\n * Skip the home-directory instruction files (~/.claude/AGENTS.md and\n * friends). Hosts running sessions for someone else set this so a run never\n * inherits the machine owner's personal configuration.\n */\n skipGlobalInstructions?: boolean;\n /**\n * Directories under the working directory whose project instruction files\n * (AGENTS.md, CLAUDE.md) load, the session's own checkout first. Hosts that\n * boot several checkouts under one working directory set it; unset, the\n * working directory itself is the only root.\n */\n instructionRoots?: string[];\n configDir: string;\n homeDir?: string;\n gitBranch?: string;\n lastCommand?: string;\n observerModelId?: string;\n reflectorModelId?: string;\n observerModelSelection: OMModel;\n reflectorModelSelection: OMModel;\n observationThreshold: number;\n reflectionThreshold: number;\n cavemanObservations: boolean;\n observeAttachments: 'auto' | boolean;\n omScope?: 'thread' | 'resource';\n /** Ordered host-supplied model and account fallback route for this thread. */\n modelRoute?: ModelRoute;\n /** One-hop fallback intent written by account rotation and consumed by the host. */\n mastracodePendingModelFallback?: PendingModelFallback | null;\n /**\n * Session-level reasoning-effort override. When unset, the effective level is\n * resolved at request time from settings (`models.modeThinkingDefaults[mode]`\n * falling back to `preferences.thinkingLevel`).\n */\n thinkingLevel?: ThinkingLevelSetting;\n yolo: boolean;\n permissionRules: {\n categories: Record<string, PermissionPolicy>;\n tools: Record<string, PermissionPolicy>;\n };\n smartEditing: boolean;\n notifications: 'bell' | 'system' | 'both' | 'off';\n tasks: Array<{\n id?: string;\n content: string;\n status: 'pending' | 'in_progress' | 'completed';\n activeForm: string;\n }>;\n sandboxAllowedPaths: string[];\n pluginSkillPaths: string[];\n pluginCommandPaths: string[];\n pluginInstructions: string[];\n activePlan: {\n title: string;\n plan: string;\n approvedAt: string;\n } | null;\n activeBrowserSettings?: {\n enabled: boolean;\n provider: 'stagehand' | 'agent-browser';\n headless?: boolean;\n viewport?: { width: number; height: number } | 'window';\n cdpUrl?: string;\n profile?: string;\n executablePath?: string;\n scope?: 'shared' | 'thread';\n stagehand?: {\n env: 'LOCAL' | 'BROWSERBASE';\n projectId?: string;\n model?: string;\n preserveUserDataDir?: boolean;\n };\n agentBrowser?: {\n storageState?: string;\n };\n };\n activeBrowserModel?: {\n modelName?: string;\n source: 'settings' | 'chat-model' | 'codex-oauth' | 'stagehand-default';\n viaCodexOAuth: boolean;\n };\n}\n\nexport const stateSchema = z\n .object({\n // Session-scoped selection. The controller validates state against this\n // schema, so these keys must be declared here — Zod strips unknown keys.\n currentModelId: z.string().optional(),\n modeId: z.string().optional(),\n modelRoute: z\n .object({\n entries: z\n .array(\n z.object({\n id: z.string().max(MODEL_ROUTE_MAX_FIELD_LENGTH),\n label: z.string().max(MODEL_ROUTE_MAX_FIELD_LENGTH),\n modelId: z.string().max(MODEL_ROUTE_MAX_FIELD_LENGTH),\n accountId: z.string().max(MODEL_ROUTE_MAX_FIELD_LENGTH).optional(),\n memoryModelId: z.string().max(MODEL_ROUTE_MAX_FIELD_LENGTH).optional(),\n }),\n )\n .max(MODEL_ROUTE_MAX_ENTRIES),\n })\n .optional(),\n subagentModelId: z.string().optional(),\n // Per-agentType subagent selections, written by session.subagents.model.set\n // (key shape: subagentModelId_<agentType>). Declared so state validation\n // keeps them — Zod strips unknown keys.\n subagentModelId_explore: z.string().optional(),\n subagentModelId_plan: z.string().optional(),\n subagentModelId_execute: z.string().optional(),\n projectPath: z.string().optional(),\n projectName: z.string().optional(),\n factoryProjectId: z.string().optional(),\n factoryOrgId: z.string().optional(),\n factoryOrgUnresolved: z.boolean().optional(),\n projectRepositoryId: z.string().optional(),\n branch: z.string().optional(),\n // Session operates on an untrusted checkout — suppress AGENTS.md ingestion.\n untrustedCheckout: z.boolean().optional(),\n // Trusted ref to serve instruction files from on untrusted checkouts.\n baseRef: z.string().optional(),\n // Skip the operator machine's home-directory instruction files.\n skipGlobalInstructions: z.boolean().optional(),\n // Checkouts whose instruction files load, the session's own first.\n instructionRoots: z.array(z.string()).optional(),\n configDir: z.string().default(DEFAULT_CONFIG_DIR),\n homeDir: z.string().optional(),\n gitBranch: z.string().optional(),\n lastCommand: z.string().optional(),\n // Observational Memory model settings. Concrete IDs are legacy/explicit\n // compatibility fields; fresh sessions preserve auto selection intent.\n observerModelId: z.string().optional(),\n reflectorModelId: z.string().optional(),\n observerModelSelection: z.string().optional(),\n reflectorModelSelection: z.string().optional(),\n // Observational Memory threshold settings\n observationThreshold: z.number().default(30_000),\n reflectionThreshold: z.number().default(40_000),\n // Whether observations and reflections use the terse caveman-style instruction.\n // Off by default — caveman style is opt-in via `/om` settings; observers and\n // reflectors fall back to their built-in (prose) behavior unless enabled.\n cavemanObservations: z.boolean().default(false),\n // Whether OM forwards image/file attachment parts to the Observer LLM.\n // 'auto' (default) checks the provider capabilities registry to decide.\n // true/false forces the setting regardless of model capabilities.\n observeAttachments: z.union([z.literal('auto'), z.boolean()]).default('auto'),\n // Observational Memory scope — 'thread' (per-conversation) or 'resource' (shared across threads)\n omScope: z.enum(['thread', 'resource']).optional(),\n // Thinking level for model reasoning effort. Optional: absent means \"no\n // session override\" — the effective level is resolved from settings\n // (per-mode defaults, then the global preference) at request time.\n thinkingLevel: z.preprocess(\n value => (value === null ? undefined : value),\n z.enum(THINKING_LEVEL_VALUES).optional(),\n ),\n // YOLO mode — auto-approve all tool calls\n yolo: z.boolean().default(false),\n // Permission rules — per-category and per-tool approval policies\n permissionRules: z\n .object({\n categories: z.record(z.string(), z.enum(['allow', 'ask', 'deny'])).default({}),\n tools: z.record(z.string(), z.enum(['allow', 'ask', 'deny'])).default({}),\n })\n .default({ categories: {}, tools: {} }),\n // Smart editing mode — use AST-based analysis for code edits\n smartEditing: z.boolean().default(true),\n // Notification mode — alert when TUI needs user attention\n notifications: z.enum(['bell', 'system', 'both', 'off']).default('off'),\n // Task list (ephemeral per-thread, cleared on thread switch/creation)\n tasks: z\n .array(\n z.object({\n id: z.string().optional(),\n content: z.string(),\n status: z.enum(['pending', 'in_progress', 'completed']),\n activeForm: z.string(),\n }),\n )\n .default([]),\n // Sandbox allowed paths (per-thread, absolute paths allowed in addition to project root)\n sandboxAllowedPaths: z.array(z.string()).default([]),\n // Pending route hop written by account rotation. The host consumes it on\n // `state_changed` to apply thread stickiness, then clears it back to null.\n mastracodePendingModelFallback: z\n .object({\n fromEntryId: z.string(),\n toEntryId: z.string(),\n toModelId: z.string(),\n threadId: z.string().optional(),\n reason: z.enum(['pool-exhausted', 'persistent-outage']),\n at: z.string(),\n })\n .nullish(),\n // Asset directories contributed by active plugins.\n pluginSkillPaths: z.array(z.string()).default([]),\n pluginCommandPaths: z.array(z.string()).default([]),\n pluginInstructions: z.array(z.string()).default([]),\n // Active plan (set when a plan is approved in Plan mode)\n activePlan: z\n .object({\n title: z.string(),\n plan: z.string(),\n approvedAt: z.string(),\n })\n .nullable()\n .default(null),\n // Active browser settings (tracks what's actually running vs. what's in the settings file)\n activeBrowserSettings: z\n .object({\n enabled: z.boolean(),\n provider: z.enum(['stagehand', 'agent-browser']),\n headless: z.boolean().optional(),\n viewport: z\n .union([\n z.object({\n width: z.number(),\n height: z.number(),\n }),\n z.literal('window'),\n ])\n .optional(),\n cdpUrl: z.string().optional(),\n profile: z.string().optional(),\n executablePath: z.string().optional(),\n scope: z.enum(['shared', 'thread']).optional(),\n stagehand: z\n .object({\n env: z.enum(['LOCAL', 'BROWSERBASE']),\n projectId: z.string().optional(),\n model: z.string().optional(),\n preserveUserDataDir: z.boolean().optional(),\n })\n .optional(),\n agentBrowser: z\n .object({\n storageState: z.string().optional(),\n })\n .optional(),\n })\n .optional(),\n // Model the active Stagehand browser was created with. Resolved once at\n // launch so /browser status reports what is really running even if the\n // user signs in/out of Codex afterwards.\n activeBrowserModel: z\n .object({\n modelName: z.string().optional(),\n source: z.enum(['settings', 'chat-model', 'codex-oauth', 'stagehand-default']),\n viaCodexOAuth: z.boolean(),\n })\n .optional(),\n })\n .transform(state => ({\n ...state,\n observerModelSelection: state.observerModelSelection ?? state.observerModelId ?? 'auto',\n reflectorModelSelection: state.reflectorModelSelection ?? state.reflectorModelId ?? 'auto',\n }));\n"],"mappings":";;;;AAyJA,MAAa,cAAc,EACxB,OAAO;CAGN,gBAAgB,EAAE,OAAO,CAAC,CAAC,SAAS;CACpC,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,YAAY,EACT,OAAO,EACN,SAAS,EACN,MACC,EAAE,OAAO;EACP,IAAI,EAAE,OAAO,CAAC,CAAC,IAAA,GAAgC;EAC/C,OAAO,EAAE,OAAO,CAAC,CAAC,IAAA,GAAgC;EAClD,SAAS,EAAE,OAAO,CAAC,CAAC,IAAA,GAAgC;EACpD,WAAW,EAAE,OAAO,CAAC,CA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C;GACpC,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;GAC/B,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;GAC3B,qBAAqB,EAAE,QAAQ,CAAC,CAAC,SAAS;EAC5C,CAAC,CAAC,CACD,SAAS;EACZ,cAAc,EACX,OAAO,EACN,cAAc,EAAE,OAAO,CAAC,CAAC,SAAS,EACpC,CAAC,CAAC,CACD,SAAS;CACd,CAAC,CAAC,CACD,SAAS;CAIZ,oBAAoB,EACjB,OAAO;EACN,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;EAC/B,QAAQ,EAAE,KAAK;GAAC;GAAY;GAAc;GAAe;EAAmB,CAAC;EAC7E,eAAe,EAAE,QAAQ;CAC3B,CAAC,CAAC,CACD,SAAS;AACd,CAAC,CAAC,CACD,WAAU,WAAU;CACnB,GAAG;CACH,wBAAwB,MAAM,0BAA0B,MAAM,mBAAmB;CACjF,yBAAyB,MAAM,2BAA2B,MAAM,oBAAoB;AACtF,EAAE"}
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../src/schema.ts"],"sourcesContent":["import type { OMModel } from '@mastra/core/agent-controller';\nimport { z } from 'zod';\nimport { DEFAULT_CONFIG_DIR, MODEL_ROUTE_MAX_ENTRIES, MODEL_ROUTE_MAX_FIELD_LENGTH } from './constants.js';\nimport { THINKING_LEVEL_VALUES } from './thinking.js';\nimport type { ThinkingLevelSetting } from './thinking.js';\n\nexport type PermissionPolicy = 'allow' | 'ask' | 'deny';\n\nexport type MastraCodeSessionState = {\n currentModelId: string;\n modeId: string;\n};\n\nexport type MastraCodeComposedState = MastraCodeState & MastraCodeSessionState;\n\nexport interface ModelRouteEntry {\n id: string;\n label: string;\n modelId: string;\n accountId?: string;\n memoryModelId?: string;\n}\n\nexport interface ModelRoute {\n entries: ModelRouteEntry[];\n}\n\nexport interface PendingModelFallback {\n fromEntryId: string;\n toEntryId: string;\n toModelId: string;\n threadId?: string;\n reason: 'pool-exhausted' | 'persistent-outage';\n at: string;\n}\n\nexport interface MastraCodeState {\n [key: string]: unknown;\n [key: `subagentModelId_${string}`]: string | undefined;\n subagentModelId?: string;\n projectPath?: string;\n projectName?: string;\n /** Factory project that owns this session. */\n factoryProjectId?: string;\n /** Whether this session uses organization or owner-scoped models and credentials. */\n factoryModelScope?: 'factory' | 'user';\n /** Stable user id of the Factory session owner. */\n factoryOwnerUserId?: string;\n /** Authoritative organization id seeded by factory at session construction. */\n factoryOrgId?: string;\n /**\n * Factory owns this session but could not resolve its organization. Knowledge\n * capture refuses rather than filing under a substituted identity; without the\n * marker a projectless factory session is indistinguishable from a local one.\n */\n factoryOrgUnresolved?: boolean;\n /** Linked repository used by this session when source-control execution is required. */\n projectRepositoryId?: string;\n /** Active feature branch checked out in the session workdir. */\n branch?: string;\n /**\n * The session's checkout contains third-party content (e.g. a PR branch\n * under review). Project-level instruction files (AGENTS.md, CLAUDE.md)\n * are attacker-writable there and must not be ingested into the system\n * prompt or injected as reminders.\n */\n untrustedCheckout?: boolean;\n /**\n * Trusted git ref (typically the PR's base branch) to serve project\n * instruction files from when the checkout is untrusted. Without it,\n * project-scope instruction files are skipped entirely.\n */\n baseRef?: string;\n /**\n * Skip the home-directory instruction files (~/.claude/AGENTS.md and\n * friends). Hosts running sessions for someone else set this so a run never\n * inherits the machine owner's personal configuration.\n */\n skipGlobalInstructions?: boolean;\n /**\n * Directories under the working directory whose project instruction files\n * (AGENTS.md, CLAUDE.md) load, the session's own checkout first. Hosts that\n * boot several checkouts under one working directory set it; unset, the\n * working directory itself is the only root.\n */\n instructionRoots?: string[];\n configDir: string;\n homeDir?: string;\n gitBranch?: string;\n lastCommand?: string;\n observerModelId?: string;\n reflectorModelId?: string;\n observerModelSelection: OMModel;\n reflectorModelSelection: OMModel;\n observationThreshold: number;\n reflectionThreshold: number;\n cavemanObservations: boolean;\n observeAttachments: 'auto' | boolean;\n omScope?: 'thread' | 'resource';\n /** Ordered host-supplied model and account fallback route for this thread. */\n modelRoute?: ModelRoute;\n /** One-hop fallback intent written by account rotation and consumed by the host. */\n mastracodePendingModelFallback?: PendingModelFallback | null;\n /**\n * Session-level reasoning-effort override. When unset, the effective level is\n * resolved at request time from settings (`models.modeThinkingDefaults[mode]`\n * falling back to `preferences.thinkingLevel`).\n */\n thinkingLevel?: ThinkingLevelSetting;\n yolo: boolean;\n permissionRules: {\n categories: Record<string, PermissionPolicy>;\n tools: Record<string, PermissionPolicy>;\n };\n smartEditing: boolean;\n notifications: 'bell' | 'system' | 'both' | 'off';\n tasks: Array<{\n id?: string;\n content: string;\n status: 'pending' | 'in_progress' | 'completed';\n activeForm: string;\n }>;\n sandboxAllowedPaths: string[];\n pluginSkillPaths: string[];\n pluginCommandPaths: string[];\n pluginInstructions: string[];\n activePlan: {\n title: string;\n plan: string;\n approvedAt: string;\n } | null;\n activeBrowserSettings?: {\n enabled: boolean;\n provider: 'stagehand' | 'agent-browser';\n headless?: boolean;\n viewport?: { width: number; height: number } | 'window';\n cdpUrl?: string;\n profile?: string;\n executablePath?: string;\n scope?: 'shared' | 'thread';\n stagehand?: {\n env: 'LOCAL' | 'BROWSERBASE';\n projectId?: string;\n model?: string;\n preserveUserDataDir?: boolean;\n };\n agentBrowser?: {\n storageState?: string;\n };\n };\n activeBrowserModel?: {\n modelName?: string;\n source: 'settings' | 'chat-model' | 'codex-oauth' | 'stagehand-default';\n viaCodexOAuth: boolean;\n };\n}\n\nexport const stateSchema = z\n .object({\n // Session-scoped selection. The controller validates state against this\n // schema, so these keys must be declared here — Zod strips unknown keys.\n currentModelId: z.string().optional(),\n modeId: z.string().optional(),\n modelRoute: z\n .object({\n entries: z\n .array(\n z.object({\n id: z.string().max(MODEL_ROUTE_MAX_FIELD_LENGTH),\n label: z.string().max(MODEL_ROUTE_MAX_FIELD_LENGTH),\n modelId: z.string().max(MODEL_ROUTE_MAX_FIELD_LENGTH),\n accountId: z.string().max(MODEL_ROUTE_MAX_FIELD_LENGTH).optional(),\n memoryModelId: z.string().max(MODEL_ROUTE_MAX_FIELD_LENGTH).optional(),\n }),\n )\n .max(MODEL_ROUTE_MAX_ENTRIES),\n })\n .optional(),\n subagentModelId: z.string().optional(),\n // Per-agentType subagent selections, written by session.subagents.model.set\n // (key shape: subagentModelId_<agentType>). Declared so state validation\n // keeps them — Zod strips unknown keys.\n subagentModelId_explore: z.string().optional(),\n subagentModelId_plan: z.string().optional(),\n subagentModelId_execute: z.string().optional(),\n projectPath: z.string().optional(),\n projectName: z.string().optional(),\n factoryProjectId: z.string().optional(),\n factoryModelScope: z.enum(['factory', 'user']).optional(),\n factoryOwnerUserId: z.string().optional(),\n factoryOrgId: z.string().optional(),\n factoryOrgUnresolved: z.boolean().optional(),\n projectRepositoryId: z.string().optional(),\n branch: z.string().optional(),\n // Session operates on an untrusted checkout — suppress AGENTS.md ingestion.\n untrustedCheckout: z.boolean().optional(),\n // Trusted ref to serve instruction files from on untrusted checkouts.\n baseRef: z.string().optional(),\n // Skip the operator machine's home-directory instruction files.\n skipGlobalInstructions: z.boolean().optional(),\n // Checkouts whose instruction files load, the session's own first.\n instructionRoots: z.array(z.string()).optional(),\n configDir: z.string().default(DEFAULT_CONFIG_DIR),\n homeDir: z.string().optional(),\n gitBranch: z.string().optional(),\n lastCommand: z.string().optional(),\n // Observational Memory model settings. Concrete IDs are legacy/explicit\n // compatibility fields; fresh sessions preserve auto selection intent.\n observerModelId: z.string().optional(),\n reflectorModelId: z.string().optional(),\n observerModelSelection: z.string().optional(),\n reflectorModelSelection: z.string().optional(),\n // Observational Memory threshold settings\n observationThreshold: z.number().default(30_000),\n reflectionThreshold: z.number().default(40_000),\n // Whether observations and reflections use the terse caveman-style instruction.\n // Off by default — caveman style is opt-in via `/om` settings; observers and\n // reflectors fall back to their built-in (prose) behavior unless enabled.\n cavemanObservations: z.boolean().default(false),\n // Whether OM forwards image/file attachment parts to the Observer LLM.\n // 'auto' (default) checks the provider capabilities registry to decide.\n // true/false forces the setting regardless of model capabilities.\n observeAttachments: z.union([z.literal('auto'), z.boolean()]).default('auto'),\n // Observational Memory scope — 'thread' (per-conversation) or 'resource' (shared across threads)\n omScope: z.enum(['thread', 'resource']).optional(),\n // Thinking level for model reasoning effort. Optional: absent means \"no\n // session override\" — the effective level is resolved from settings\n // (per-mode defaults, then the global preference) at request time.\n thinkingLevel: z.preprocess(\n value => (value === null ? undefined : value),\n z.enum(THINKING_LEVEL_VALUES).optional(),\n ),\n // YOLO mode — auto-approve all tool calls\n yolo: z.boolean().default(false),\n // Permission rules — per-category and per-tool approval policies\n permissionRules: z\n .object({\n categories: z.record(z.string(), z.enum(['allow', 'ask', 'deny'])).default({}),\n tools: z.record(z.string(), z.enum(['allow', 'ask', 'deny'])).default({}),\n })\n .default({ categories: {}, tools: {} }),\n // Smart editing mode — use AST-based analysis for code edits\n smartEditing: z.boolean().default(true),\n // Notification mode — alert when TUI needs user attention\n notifications: z.enum(['bell', 'system', 'both', 'off']).default('off'),\n // Task list (ephemeral per-thread, cleared on thread switch/creation)\n tasks: z\n .array(\n z.object({\n id: z.string().optional(),\n content: z.string(),\n status: z.enum(['pending', 'in_progress', 'completed']),\n activeForm: z.string(),\n }),\n )\n .default([]),\n // Sandbox allowed paths (per-thread, absolute paths allowed in addition to project root)\n sandboxAllowedPaths: z.array(z.string()).default([]),\n // Pending route hop written by account rotation. The host consumes it on\n // `state_changed` to apply thread stickiness, then clears it back to null.\n mastracodePendingModelFallback: z\n .object({\n fromEntryId: z.string(),\n toEntryId: z.string(),\n toModelId: z.string(),\n threadId: z.string().optional(),\n reason: z.enum(['pool-exhausted', 'persistent-outage']),\n at: z.string(),\n })\n .nullish(),\n // Asset directories contributed by active plugins.\n pluginSkillPaths: z.array(z.string()).default([]),\n pluginCommandPaths: z.array(z.string()).default([]),\n pluginInstructions: z.array(z.string()).default([]),\n // Active plan (set when a plan is approved in Plan mode)\n activePlan: z\n .object({\n title: z.string(),\n plan: z.string(),\n approvedAt: z.string(),\n })\n .nullable()\n .default(null),\n // Active browser settings (tracks what's actually running vs. what's in the settings file)\n activeBrowserSettings: z\n .object({\n enabled: z.boolean(),\n provider: z.enum(['stagehand', 'agent-browser']),\n headless: z.boolean().optional(),\n viewport: z\n .union([\n z.object({\n width: z.number(),\n height: z.number(),\n }),\n z.literal('window'),\n ])\n .optional(),\n cdpUrl: z.string().optional(),\n profile: z.string().optional(),\n executablePath: z.string().optional(),\n scope: z.enum(['shared', 'thread']).optional(),\n stagehand: z\n .object({\n env: z.enum(['LOCAL', 'BROWSERBASE']),\n projectId: z.string().optional(),\n model: z.string().optional(),\n preserveUserDataDir: z.boolean().optional(),\n })\n .optional(),\n agentBrowser: z\n .object({\n storageState: z.string().optional(),\n })\n .optional(),\n })\n .optional(),\n // Model the active Stagehand browser was created with. Resolved once at\n // launch so /browser status reports what is really running even if the\n // user signs in/out of Codex afterwards.\n activeBrowserModel: z\n .object({\n modelName: z.string().optional(),\n source: z.enum(['settings', 'chat-model', 'codex-oauth', 'stagehand-default']),\n viaCodexOAuth: z.boolean(),\n })\n .optional(),\n })\n .transform(state => ({\n ...state,\n observerModelSelection: state.observerModelSelection ?? state.observerModelId ?? 'auto',\n reflectorModelSelection: state.reflectorModelSelection ?? state.reflectorModelId ?? 'auto',\n }));\n"],"mappings":";;;;AA6JA,MAAa,cAAc,EACxB,OAAO;CAGN,gBAAgB,EAAE,OAAO,CAAC,CAAC,SAAS;CACpC,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,YAAY,EACT,OAAO,EACN,SAAS,EACN,MACC,EAAE,OAAO;EACP,IAAI,EAAE,OAAO,CAAC,CAAC,IAAA,GAAgC;EAC/C,OAAO,EAAE,OAAO,CAAC,CAAC,IAAA,GAAgC;EAClD,SAAS,EAAE,OAAO,CAAC,CAAC,IAAA,GAAgC;EACpD,WAAW,EAAE,OAAO,CAAC,CAAC,IAAA,GAAgC,CAAC,CAAC,SAAS;EACjE,eAAe,EAAE,OAAO,CAAC,CAAC,IAAA,GAAgC,CAAC,CAAC,SAAS;CACvE,CAAC,CACH,CAA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AAW,EAAE,OAAO,CAAC,CAAC,SAAS;GAC/B,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;GAC3B,qBAAqB,EAAE,QAAQ,CAAC,CAAC,SAAS;EAC5C,CAAC,CAAC,CACD,SAAS;EACZ,cAAc,EACX,OAAO,EACN,cAAc,EAAE,OAAO,CAAC,CAAC,SAAS,EACpC,CAAC,CAAC,CACD,SAAS;CACd,CAAC,CAAC,CACD,SAAS;CAIZ,oBAAoB,EACjB,OAAO;EACN,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;EAC/B,QAAQ,EAAE,KAAK;GAAC;GAAY;GAAc;GAAe;EAAmB,CAAC;EAC7E,eAAe,EAAE,QAAQ;CAC3B,CAAC,CAAC,CACD,SAAS;AACd,CAAC,CAAC,CACD,WAAU,WAAU;CACnB,GAAG;CACH,wBAAwB,MAAM,0BAA0B,MAAM,mBAAmB;CACjF,yBAAyB,MAAM,2BAA2B,MAAM,oBAAoB;AACtF,EAAE"}
|
package/dist/thinking.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export type ThinkCommandAction = {
|
|
|
26
26
|
};
|
|
27
27
|
export declare function isThinkingLevelSetting(value: unknown): value is ThinkingLevelSetting;
|
|
28
28
|
export declare function supportsMaxReasoningEffort(modelId: string): boolean;
|
|
29
|
+
export declare function requestableReasoningOptions(modelId: string, reasoningOptions: readonly ModelReasoningOption[] | undefined): readonly ModelReasoningOption[] | undefined;
|
|
29
30
|
export declare function runThinkingLevel(modelId: string, level: ThinkingLevelSetting, reasoningOptions: readonly ModelReasoningOption[] | undefined): ThinkingLevelSetting;
|
|
30
31
|
export declare function getAvailableThinkingLevelsForModel(modelId: string, reasoningOptions?: readonly ModelReasoningOption[]): ThinkingLevelSetting[];
|
|
31
32
|
export declare function parseThinkCommand(input: string, levels?: readonly ThinkingLevelSetting[]): ThinkCommandAction;
|
package/dist/thinking.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinking.d.ts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MAAM,EACf,gBAAgB,EAAE,SAAS,oBAAoB,EAAE,GAAG,SAAS,GAC5D,SAAS,oBAAoB,EAAE,GAAG,SAAS,CAY7C;AAwCD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,oBAAoB,EAC3B,gBAAgB,EAAE,SAAS,oBAAoB,EAAE,GAAG,SAAS,GAC5D,oBAAoB,CAatB;AAED,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,SAAS,oBAAoB,EAAE,GACjD,oBAAoB,EAAE,CAExB;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,SAAS,oBAAoB,EAA0B,GAC9D,kBAAkB,CAMpB;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GACnB;IAAE,KAAK,EAAE,oBAAoB,CAAC;IAAC,MAAM,EAAE,mBAAmB,CAAA;CAAE,CAG9D"}
|
package/dist/thinking.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ANTHROPIC_THINKING_BUDGET_TOKENS, getAnthropicThinkingCapability, supportsAnthropicXhighEffort } from "./providers/anthropic-thinking.js";
|
|
2
2
|
import { runGeminiThinkingLevel } from "./providers/google-thinking.js";
|
|
3
3
|
import { normalizeAnthropicModelId, stripMastraGatewayPrefix } from "./providers/model-ids.js";
|
|
4
|
+
import { isRoutedWithoutThinking, isThinkingAdapterProvider, thinkingRequestFormatFor } from "./providers/thinking-request.js";
|
|
4
5
|
//#region src/thinking.ts
|
|
5
6
|
const THINKING_LEVEL_VALUES = [
|
|
6
7
|
"off",
|
|
@@ -54,6 +55,22 @@ const TOGGLE_ON_LEVEL = "high";
|
|
|
54
55
|
function onlyTogglesThinking(reasoningOptions) {
|
|
55
56
|
return !!reasoningOptions?.length && reasoningOptions.every((option) => option.type === "toggle");
|
|
56
57
|
}
|
|
58
|
+
function requestableReasoningOptions(modelId, reasoningOptions) {
|
|
59
|
+
if (isRoutedWithoutThinking(modelId)) return [];
|
|
60
|
+
if (!reasoningOptions) return reasoningOptions;
|
|
61
|
+
const format = thinkingRequestFormatFor(modelId);
|
|
62
|
+
if (!format) return isThinkingAdapterProvider(splitProvider(modelId).provider) ? reasoningOptions : [];
|
|
63
|
+
const acceptedEfforts = format.sendEffort ? format.acceptedEfforts ?? ACTIVE_THINKING_LEVELS : [];
|
|
64
|
+
return reasoningOptions.flatMap((option) => {
|
|
65
|
+
if (option.type === "toggle") return format.enableThinking ? [option] : [];
|
|
66
|
+
if (option.type !== "effort") return [];
|
|
67
|
+
const values = option.values.filter((value) => acceptedEfforts.some((effort) => effort === value));
|
|
68
|
+
return values.length ? [{
|
|
69
|
+
type: "effort",
|
|
70
|
+
values
|
|
71
|
+
}] : [];
|
|
72
|
+
});
|
|
73
|
+
}
|
|
57
74
|
function closestOfferedEffort(level, reasoningOptions) {
|
|
58
75
|
const offered = offeredEffortLevels(reasoningOptions);
|
|
59
76
|
const requestedRank = ACTIVE_THINKING_LEVELS.indexOf(level);
|
|
@@ -81,10 +98,11 @@ function runThinkingLevel(modelId, level, reasoningOptions) {
|
|
|
81
98
|
const { provider, bareModelId } = splitProvider(modelId);
|
|
82
99
|
if (provider === "google") return runGeminiThinkingLevel(bareModelId, level);
|
|
83
100
|
if (provider === "anthropic") return runAnthropicThinkingLevel(normalizeAnthropicModelId(bareModelId), level, reasoningOptions);
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
if (
|
|
87
|
-
return
|
|
101
|
+
const requestable = requestableReasoningOptions(modelId, reasoningOptions);
|
|
102
|
+
if (requestable?.length === 0) return "off";
|
|
103
|
+
if (onlyTogglesThinking(requestable)) return TOGGLE_ON_LEVEL;
|
|
104
|
+
if (provider === "openai") return runOpenAIThinkingLevel(bareModelId, level, requestable);
|
|
105
|
+
return closestOfferedEffort(level, requestable) ?? level;
|
|
88
106
|
}
|
|
89
107
|
function getAvailableThinkingLevelsForModel(modelId, reasoningOptions) {
|
|
90
108
|
return THINKING_LEVEL_VALUES.filter((level) => runThinkingLevel(modelId, level, reasoningOptions) === level);
|
|
@@ -114,6 +132,6 @@ function resolveDefaultThinkingLevel(defaults, mode) {
|
|
|
114
132
|
};
|
|
115
133
|
}
|
|
116
134
|
//#endregion
|
|
117
|
-
export { THINKING_LEVEL_VALUES, THINK_COMMAND_DESCRIPTOR, getAvailableThinkingLevelsForModel, isThinkingLevelSetting, parseThinkCommand, resolveDefaultThinkingLevel, runThinkingLevel, supportsMaxReasoningEffort };
|
|
135
|
+
export { THINKING_LEVEL_VALUES, THINK_COMMAND_DESCRIPTOR, getAvailableThinkingLevelsForModel, isThinkingLevelSetting, parseThinkCommand, requestableReasoningOptions, resolveDefaultThinkingLevel, runThinkingLevel, supportsMaxReasoningEffort };
|
|
118
136
|
|
|
119
137
|
//# sourceMappingURL=thinking.js.map
|
package/dist/thinking.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinking.js","names":[],"sources":["../src/thinking.ts"],"sourcesContent":["import type { ModelReasoningOption } from '@mastra/core/llm';\nimport {\n ANTHROPIC_THINKING_BUDGET_TOKENS,\n getAnthropicThinkingCapability,\n supportsAnthropicXhighEffort,\n} from './providers/anthropic-thinking.js';\nimport { runGeminiThinkingLevel } from './providers/google-thinking.js';\nimport { normalizeAnthropicModelId, stripMastraGatewayPrefix } from './providers/model-ids.js';\n\nexport type ThinkingLevelSetting = 'off' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';\n\nexport type ActiveThinkingLevel = Exclude<ThinkingLevelSetting, 'off'>;\n\nexport type ThinkingLevelSource = 'mode-default' | 'global';\n\nexport interface ThinkingDefaults {\n globalDefault: ThinkingLevelSetting;\n modeDefaults: Readonly<Record<string, ThinkingLevelSetting>>;\n}\n\nexport const THINKING_LEVEL_VALUES: ThinkingLevelSetting[] = ['off', 'low', 'medium', 'high', 'xhigh', 'max'];\n\nconst ACTIVE_THINKING_LEVELS: ActiveThinkingLevel[] = ['low', 'medium', 'high', 'xhigh', 'max'];\n\nexport const THINK_COMMAND_DESCRIPTOR = {\n name: 'think',\n args: '[status|default|off|low|medium|high|xhigh|max]',\n description: 'Show or set session thinking level',\n};\n\nexport type ThinkCommandAction =\n | { kind: 'status' }\n | { kind: 'clear' }\n | { kind: 'set'; level: ThinkingLevelSetting }\n | { kind: 'invalid'; value: string; levels: readonly ThinkingLevelSetting[] };\n\nconst GPT_VERSION_RE = /^gpt-(\\d+)(?:\\.(\\d+))?/;\n\nexport function isThinkingLevelSetting(value: unknown): value is ThinkingLevelSetting {\n return typeof value === 'string' && THINKING_LEVEL_VALUES.some(level => level === value);\n}\n\nexport function supportsMaxReasoningEffort(modelId: string): boolean {\n const bareModelId = modelId.startsWith('openai/') ? modelId.slice('openai/'.length) : modelId;\n const match = GPT_VERSION_RE.exec(bareModelId);\n if (!match) return false;\n const major = Number(match[1]);\n const minor = Number(match[2] ?? 0);\n return major > 5 || (major === 5 && minor >= 6);\n}\n\nfunction splitProvider(modelId: string): { provider: string; bareModelId: string } {\n const routedModelId = stripMastraGatewayPrefix(modelId);\n const slash = routedModelId.indexOf('/');\n if (slash === -1) return { provider: '', bareModelId: routedModelId };\n return { provider: routedModelId.slice(0, slash), bareModelId: routedModelId.slice(slash + 1) };\n}\n\nfunction offeredEffortLevels(reasoningOptions: readonly ModelReasoningOption[] | undefined): ActiveThinkingLevel[] {\n const effortValues = reasoningOptions?.flatMap(option => (option.type === 'effort' ? option.values : [])) ?? [];\n return ACTIVE_THINKING_LEVELS.filter(level => effortValues.includes(level));\n}\n\nconst TOGGLE_ON_LEVEL: ActiveThinkingLevel = 'high';\n\nfunction onlyTogglesThinking(reasoningOptions: readonly ModelReasoningOption[] | undefined): boolean {\n return !!reasoningOptions?.length && reasoningOptions.every(option => option.type === 'toggle');\n}\n\nfunction closestOfferedEffort(\n level: ActiveThinkingLevel,\n reasoningOptions: readonly ModelReasoningOption[] | undefined,\n): ActiveThinkingLevel | undefined {\n const offered = offeredEffortLevels(reasoningOptions);\n const requestedRank = ACTIVE_THINKING_LEVELS.indexOf(level);\n const atOrBelow = offered.filter(candidate => ACTIVE_THINKING_LEVELS.indexOf(candidate) <= requestedRank);\n return atOrBelow.at(-1) ?? offered[0];\n}\n\nfunction lowestLevelWithSameBudget(level: ActiveThinkingLevel): ActiveThinkingLevel {\n const budget = ANTHROPIC_THINKING_BUDGET_TOKENS[level];\n return ACTIVE_THINKING_LEVELS.find(candidate => ANTHROPIC_THINKING_BUDGET_TOKENS[candidate] === budget) ?? level;\n}\n\nfunction runAnthropicThinkingLevel(\n modelId: string,\n level: ActiveThinkingLevel,\n reasoningOptions: readonly ModelReasoningOption[] | undefined,\n): ThinkingLevelSetting {\n const capability = getAnthropicThinkingCapability(modelId);\n if (capability === 'none') return 'off';\n if (capability === 'budget') return lowestLevelWithSameBudget(level);\n const offeredEffort = closestOfferedEffort(level, reasoningOptions);\n if (offeredEffort) return offeredEffort;\n return level === 'xhigh' && !supportsAnthropicXhighEffort(modelId) ? 'high' : level;\n}\n\nfunction runOpenAIThinkingLevel(\n modelId: string,\n level: ActiveThinkingLevel,\n reasoningOptions: readonly ModelReasoningOption[] | undefined,\n): ActiveThinkingLevel {\n const offeredEffort = closestOfferedEffort(level, reasoningOptions);\n if (offeredEffort) return offeredEffort;\n return level === 'max' && !supportsMaxReasoningEffort(modelId) ? 'xhigh' : level;\n}\n\nexport function runThinkingLevel(\n modelId: string,\n level: ThinkingLevelSetting,\n reasoningOptions: readonly ModelReasoningOption[] | undefined,\n): ThinkingLevelSetting {\n if (level === 'off') return 'off';\n const { provider, bareModelId } = splitProvider(modelId);\n if (provider === 'google') return runGeminiThinkingLevel(bareModelId, level);\n if (provider === 'anthropic') {\n return runAnthropicThinkingLevel(normalizeAnthropicModelId(bareModelId), level, reasoningOptions);\n }\n const listedWithoutReasoningControls = reasoningOptions?.length === 0;\n if (listedWithoutReasoningControls) return 'off';\n if (onlyTogglesThinking(reasoningOptions)) return TOGGLE_ON_LEVEL;\n if (provider === 'openai') return runOpenAIThinkingLevel(bareModelId, level, reasoningOptions);\n return closestOfferedEffort(level, reasoningOptions) ?? level;\n}\n\nexport function getAvailableThinkingLevelsForModel(\n modelId: string,\n reasoningOptions?: readonly ModelReasoningOption[],\n): ThinkingLevelSetting[] {\n return THINKING_LEVEL_VALUES.filter(level => runThinkingLevel(modelId, level, reasoningOptions) === level);\n}\n\nexport function parseThinkCommand(\n input: string,\n levels: readonly ThinkingLevelSetting[] = THINKING_LEVEL_VALUES,\n): ThinkCommandAction {\n const value = input.trim().toLowerCase();\n if (!value || value === 'status') return { kind: 'status' };\n if (value === 'default' || value === 'clear') return { kind: 'clear' };\n const level = levels.find(candidate => candidate === value);\n return level ? { kind: 'set', level } : { kind: 'invalid', value, levels };\n}\n\nexport function resolveDefaultThinkingLevel(\n defaults: ThinkingDefaults,\n mode?: string | null,\n): { level: ThinkingLevelSetting; source: ThinkingLevelSource } {\n const modeLevel = mode ? defaults.modeDefaults[mode] : undefined;\n return modeLevel ? { level: modeLevel, source: 'mode-default' } : { level: defaults.globalDefault, source: 'global' };\n}\n"],"mappings":";;;;AAoBA,MAAa,wBAAgD;CAAC;CAAO;CAAO;CAAU;CAAQ;CAAS;AAAK;AAE5G,MAAM,yBAAgD;CAAC;CAAO;CAAU;CAAQ;CAAS;AAAK;AAE9F,MAAa,2BAA2B;CACtC,MAAM;CACN,MAAM;CACN,aAAa;AACf;AAQA,MAAM,iBAAiB;AAEvB,SAAgB,uBAAuB,OAA+C;CACpF,OAAO,OAAO,UAAU,YAAY,sBAAsB,MAAK,UAAS,UAAU,KAAK;AACzF;AAEA,SAAgB,2BAA2B,SAA0B;CACnE,MAAM,cAAc,QAAQ,WAAW,SAAS,IAAI,QAAQ,MAAM,CAAgB,IAAI;CACtF,MAAM,QAAQ,eAAe,KAAK,WAAW;CAC7C,IAAI,CAAC,OAAO,OAAO;CACnB,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YAAY;EAAE,OAAO;EAAW,QAAQ;CAAe,IAAI;EAAE,OAAO,SAAS;EAAe,QAAQ;CAAS;AACtH"}
|
|
1
|
+
{"version":3,"file":"thinking.js","names":[],"sources":["../src/thinking.ts"],"sourcesContent":["import type { ModelReasoningOption } from '@mastra/core/llm';\nimport {\n ANTHROPIC_THINKING_BUDGET_TOKENS,\n getAnthropicThinkingCapability,\n supportsAnthropicXhighEffort,\n} from './providers/anthropic-thinking.js';\nimport { runGeminiThinkingLevel } from './providers/google-thinking.js';\nimport { normalizeAnthropicModelId, stripMastraGatewayPrefix } from './providers/model-ids.js';\nimport {\n isRoutedWithoutThinking,\n isThinkingAdapterProvider,\n thinkingRequestFormatFor,\n} from './providers/thinking-request.js';\n\nexport type ThinkingLevelSetting = 'off' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';\n\nexport type ActiveThinkingLevel = Exclude<ThinkingLevelSetting, 'off'>;\n\nexport type ThinkingLevelSource = 'mode-default' | 'global';\n\nexport interface ThinkingDefaults {\n globalDefault: ThinkingLevelSetting;\n modeDefaults: Readonly<Record<string, ThinkingLevelSetting>>;\n}\n\nexport const THINKING_LEVEL_VALUES: ThinkingLevelSetting[] = ['off', 'low', 'medium', 'high', 'xhigh', 'max'];\n\nconst ACTIVE_THINKING_LEVELS: ActiveThinkingLevel[] = ['low', 'medium', 'high', 'xhigh', 'max'];\n\nexport const THINK_COMMAND_DESCRIPTOR = {\n name: 'think',\n args: '[status|default|off|low|medium|high|xhigh|max]',\n description: 'Show or set session thinking level',\n};\n\nexport type ThinkCommandAction =\n | { kind: 'status' }\n | { kind: 'clear' }\n | { kind: 'set'; level: ThinkingLevelSetting }\n | { kind: 'invalid'; value: string; levels: readonly ThinkingLevelSetting[] };\n\nconst GPT_VERSION_RE = /^gpt-(\\d+)(?:\\.(\\d+))?/;\n\nexport function isThinkingLevelSetting(value: unknown): value is ThinkingLevelSetting {\n return typeof value === 'string' && THINKING_LEVEL_VALUES.some(level => level === value);\n}\n\nexport function supportsMaxReasoningEffort(modelId: string): boolean {\n const bareModelId = modelId.startsWith('openai/') ? modelId.slice('openai/'.length) : modelId;\n const match = GPT_VERSION_RE.exec(bareModelId);\n if (!match) return false;\n const major = Number(match[1]);\n const minor = Number(match[2] ?? 0);\n return major > 5 || (major === 5 && minor >= 6);\n}\n\nfunction splitProvider(modelId: string): { provider: string; bareModelId: string } {\n const routedModelId = stripMastraGatewayPrefix(modelId);\n const slash = routedModelId.indexOf('/');\n if (slash === -1) return { provider: '', bareModelId: routedModelId };\n return { provider: routedModelId.slice(0, slash), bareModelId: routedModelId.slice(slash + 1) };\n}\n\nfunction offeredEffortLevels(reasoningOptions: readonly ModelReasoningOption[] | undefined): ActiveThinkingLevel[] {\n const effortValues = reasoningOptions?.flatMap(option => (option.type === 'effort' ? option.values : [])) ?? [];\n return ACTIVE_THINKING_LEVELS.filter(level => effortValues.includes(level));\n}\n\nconst TOGGLE_ON_LEVEL: ActiveThinkingLevel = 'high';\n\nfunction onlyTogglesThinking(reasoningOptions: readonly ModelReasoningOption[] | undefined): boolean {\n return !!reasoningOptions?.length && reasoningOptions.every(option => option.type === 'toggle');\n}\n\nexport function requestableReasoningOptions(\n modelId: string,\n reasoningOptions: readonly ModelReasoningOption[] | undefined,\n): readonly ModelReasoningOption[] | undefined {\n if (isRoutedWithoutThinking(modelId)) return [];\n if (!reasoningOptions) return reasoningOptions;\n const format = thinkingRequestFormatFor(modelId);\n if (!format) return isThinkingAdapterProvider(splitProvider(modelId).provider) ? reasoningOptions : [];\n const acceptedEfforts = format.sendEffort ? (format.acceptedEfforts ?? ACTIVE_THINKING_LEVELS) : [];\n return reasoningOptions.flatMap((option): ModelReasoningOption[] => {\n if (option.type === 'toggle') return format.enableThinking ? [option] : [];\n if (option.type !== 'effort') return [];\n const values = option.values.filter(value => acceptedEfforts.some(effort => effort === value));\n return values.length ? [{ type: 'effort', values }] : [];\n });\n}\n\nfunction closestOfferedEffort(\n level: ActiveThinkingLevel,\n reasoningOptions: readonly ModelReasoningOption[] | undefined,\n): ActiveThinkingLevel | undefined {\n const offered = offeredEffortLevels(reasoningOptions);\n const requestedRank = ACTIVE_THINKING_LEVELS.indexOf(level);\n const atOrBelow = offered.filter(candidate => ACTIVE_THINKING_LEVELS.indexOf(candidate) <= requestedRank);\n return atOrBelow.at(-1) ?? offered[0];\n}\n\nfunction lowestLevelWithSameBudget(level: ActiveThinkingLevel): ActiveThinkingLevel {\n const budget = ANTHROPIC_THINKING_BUDGET_TOKENS[level];\n return ACTIVE_THINKING_LEVELS.find(candidate => ANTHROPIC_THINKING_BUDGET_TOKENS[candidate] === budget) ?? level;\n}\n\nfunction runAnthropicThinkingLevel(\n modelId: string,\n level: ActiveThinkingLevel,\n reasoningOptions: readonly ModelReasoningOption[] | undefined,\n): ThinkingLevelSetting {\n const capability = getAnthropicThinkingCapability(modelId);\n if (capability === 'none') return 'off';\n if (capability === 'budget') return lowestLevelWithSameBudget(level);\n const offeredEffort = closestOfferedEffort(level, reasoningOptions);\n if (offeredEffort) return offeredEffort;\n return level === 'xhigh' && !supportsAnthropicXhighEffort(modelId) ? 'high' : level;\n}\n\nfunction runOpenAIThinkingLevel(\n modelId: string,\n level: ActiveThinkingLevel,\n reasoningOptions: readonly ModelReasoningOption[] | undefined,\n): ActiveThinkingLevel {\n const offeredEffort = closestOfferedEffort(level, reasoningOptions);\n if (offeredEffort) return offeredEffort;\n return level === 'max' && !supportsMaxReasoningEffort(modelId) ? 'xhigh' : level;\n}\n\nexport function runThinkingLevel(\n modelId: string,\n level: ThinkingLevelSetting,\n reasoningOptions: readonly ModelReasoningOption[] | undefined,\n): ThinkingLevelSetting {\n if (level === 'off') return 'off';\n const { provider, bareModelId } = splitProvider(modelId);\n if (provider === 'google') return runGeminiThinkingLevel(bareModelId, level);\n if (provider === 'anthropic') {\n return runAnthropicThinkingLevel(normalizeAnthropicModelId(bareModelId), level, reasoningOptions);\n }\n const requestable = requestableReasoningOptions(modelId, reasoningOptions);\n const listedWithoutReasoningControls = requestable?.length === 0;\n if (listedWithoutReasoningControls) return 'off';\n if (onlyTogglesThinking(requestable)) return TOGGLE_ON_LEVEL;\n if (provider === 'openai') return runOpenAIThinkingLevel(bareModelId, level, requestable);\n return closestOfferedEffort(level, requestable) ?? level;\n}\n\nexport function getAvailableThinkingLevelsForModel(\n modelId: string,\n reasoningOptions?: readonly ModelReasoningOption[],\n): ThinkingLevelSetting[] {\n return THINKING_LEVEL_VALUES.filter(level => runThinkingLevel(modelId, level, reasoningOptions) === level);\n}\n\nexport function parseThinkCommand(\n input: string,\n levels: readonly ThinkingLevelSetting[] = THINKING_LEVEL_VALUES,\n): ThinkCommandAction {\n const value = input.trim().toLowerCase();\n if (!value || value === 'status') return { kind: 'status' };\n if (value === 'default' || value === 'clear') return { kind: 'clear' };\n const level = levels.find(candidate => candidate === value);\n return level ? { kind: 'set', level } : { kind: 'invalid', value, levels };\n}\n\nexport function resolveDefaultThinkingLevel(\n defaults: ThinkingDefaults,\n mode?: string | null,\n): { level: ThinkingLevelSetting; source: ThinkingLevelSource } {\n const modeLevel = mode ? defaults.modeDefaults[mode] : undefined;\n return modeLevel ? { level: modeLevel, source: 'mode-default' } : { level: defaults.globalDefault, source: 'global' };\n}\n"],"mappings":";;;;;AAyBA,MAAa,wBAAgD;CAAC;CAAO;CAAO;CAAU;CAAQ;CAAS;AAAK;AAE5G,MAAM,yBAAgD;CAAC;CAAO;CAAU;CAAQ;CAAS;AAAK;AAE9F,MAAa,2BAA2B;CACtC,MAAM;CACN,MAAM;CACN,aAAa;AACf;AAQA,MAAM,iBAAiB;AAEvB,SAAgB,uBAAuB,OAA+C;CACpF,OAAO,OAAO,UAAU,YAAY,sBAAsB,MAAK,UAAS,UAAU,KAAK;AACzF;AAEA,SAAgB,2BAA2B,SAA0B;CACnE,MAAM,cAAc,QAAQ,WAAW,SAAS,IAAI,QAAQ,MAAM,CAAgB,IAAI;CACtF,MAAM,QAAQ,eAAe,KAAK,WAAW;CAC7C,IAAI,CAAC,OAA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AAG,OAAO;CAC7C,IAAI,aAAa,UAAU,OAAO,uBAAuB,aAAa,OAAO,WAAW;CACxF,OAAO,qBAAqB,OAAO,WAAW,KAAK;AACrD;AAEA,SAAgB,mCACd,SACA,kBACwB;CACxB,OAAO,sBAAsB,QAAO,UAAS,iBAAiB,SAAS,OAAO,gBAAgB,MAAM,KAAK;AAC3G;AAEA,SAAgB,kBACd,OACA,SAA0C,uBACtB;CACpB,MAAM,QAAQ,MAAM,KAAK,CAAC,CAAC,YAAY;CACvC,IAAI,CAAC,SAAS,UAAU,UAAU,OAAO,EAAE,MAAM,SAAS;CAC1D,IAAI,UAAU,aAAa,UAAU,SAAS,OAAO,EAAE,MAAM,QAAQ;CACrE,MAAM,QAAQ,OAAO,MAAK,cAAa,cAAc,KAAK;CAC1D,OAAO,QAAQ;EAAE,MAAM;EAAO;CAAM,IAAI;EAAE,MAAM;EAAW;EAAO;CAAO;AAC3E;AAEA,SAAgB,4BACd,UACA,MAC8D;CAC9D,MAAM,YAAY,OAAO,SAAS,aAAa,QAAQ,KAAA;CACvD,OAAO,YAAY;EAAE,OAAO;EAAW,QAAQ;CAAe,IAAI;EAAE,OAAO,SAAS;EAAe,QAAQ;CAAS;AACtH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/code-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0-alpha.2",
|
|
4
4
|
"description": "Mastra Code SDK: the agent core behind Mastra Code (everything except the TUI) — build your own UIs and surfaces on top of it",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -64,18 +64,18 @@
|
|
|
64
64
|
"zod": "^4.6.4",
|
|
65
65
|
"@mastra/agent-browser": "0.5.3",
|
|
66
66
|
"@mastra/duckdb": "1.14.0",
|
|
67
|
+
"@mastra/core": "1.78.0-alpha.2",
|
|
68
|
+
"@mastra/fastembed": "1.3.3",
|
|
67
69
|
"@mastra/github-signals": "0.5.1",
|
|
68
|
-
"@mastra/
|
|
70
|
+
"@mastra/mcp": "2.4.1-alpha.0",
|
|
71
|
+
"@mastra/libsql": "1.26.2-alpha.0",
|
|
69
72
|
"@mastra/memory": "1.37.1",
|
|
70
|
-
"@mastra/
|
|
71
|
-
"@mastra/
|
|
73
|
+
"@mastra/observability": "1.20.1-alpha.1",
|
|
74
|
+
"@mastra/pg": "1.31.2-alpha.0",
|
|
72
75
|
"@mastra/parallel": "0.1.2",
|
|
73
|
-
"@mastra/observability": "1.20.0",
|
|
74
|
-
"@mastra/schema-compat": "1.3.14",
|
|
75
76
|
"@mastra/stagehand": "0.3.5",
|
|
76
77
|
"@mastra/tavily": "1.1.2",
|
|
77
|
-
"@mastra/
|
|
78
|
-
"@mastra/mcp": "2.4.0"
|
|
78
|
+
"@mastra/schema-compat": "1.3.14"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@libsql/client": "^0.18.0",
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"typescript-eslint": "^8.57.0",
|
|
88
88
|
"vitest": "4.1.11",
|
|
89
89
|
"@internal/lint": "0.0.143",
|
|
90
|
-
"@internal/
|
|
91
|
-
"@internal/
|
|
90
|
+
"@internal/types-builder": "0.0.118",
|
|
91
|
+
"@internal/workspace-test-utils": "0.0.87"
|
|
92
92
|
},
|
|
93
93
|
"engines": {
|
|
94
94
|
"node": ">=22.19.0"
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ThinkingLevelSetting } from '../thinking.js';
|
|
2
|
-
import type { ProviderThinkingOptions } from './provider-thinking.js';
|
|
3
|
-
export declare function deepseekThinkingOptions(routedModelId: string, level: ThinkingLevelSetting | undefined): ProviderThinkingOptions | undefined;
|
|
4
|
-
//# sourceMappingURL=deepseek-thinking.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deepseek-thinking.d.ts","sourceRoot":"","sources":["../../src/providers/deepseek-thinking.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEtE,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,oBAAoB,GAAG,SAAS,GACtC,uBAAuB,GAAG,SAAS,CASrC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { runCatalogThinkingLevel } from "../thinking-catalog.js";
|
|
2
|
-
//#region src/providers/deepseek-thinking.ts
|
|
3
|
-
function deepseekThinkingOptions(routedModelId, level) {
|
|
4
|
-
if (!level || level === "off") return void 0;
|
|
5
|
-
const reasoningEffort = runCatalogThinkingLevel(routedModelId, level);
|
|
6
|
-
if (reasoningEffort === "off") return void 0;
|
|
7
|
-
return {
|
|
8
|
-
optionsKey: "deepseek",
|
|
9
|
-
options: { reasoningEffort },
|
|
10
|
-
controlKeys: /* @__PURE__ */ new Set(["thinking", "reasoningEffort"])
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { deepseekThinkingOptions };
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=deepseek-thinking.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deepseek-thinking.js","names":[],"sources":["../../src/providers/deepseek-thinking.ts"],"sourcesContent":["import { runCatalogThinkingLevel } from '../thinking-catalog.js';\nimport type { ThinkingLevelSetting } from '../thinking.js';\nimport type { ProviderThinkingOptions } from './provider-thinking.js';\n\nexport function deepseekThinkingOptions(\n routedModelId: string,\n level: ThinkingLevelSetting | undefined,\n): ProviderThinkingOptions | undefined {\n if (!level || level === 'off') return undefined;\n const reasoningEffort = runCatalogThinkingLevel(routedModelId, level);\n if (reasoningEffort === 'off') return undefined;\n return {\n optionsKey: 'deepseek',\n options: { reasoningEffort },\n controlKeys: new Set(['thinking', 'reasoningEffort']),\n };\n}\n"],"mappings":";;AAIA,SAAgB,wBACd,eACA,OACqC;CACrC,IAAI,CAAC,SAAS,UAAU,OAAO,OAAO,KAAA;CACtC,MAAM,kBAAkB,wBAAwB,eAAe,KAAK;CACpE,IAAI,oBAAoB,OAAO,OAAO,KAAA;CACtC,OAAO;EACL,YAAY;EACZ,SAAS,EAAE,gBAAgB;EAC3B,6BAAa,IAAI,IAAI,CAAC,YAAY,iBAAiB,CAAC;CACtD;AACF"}
|