@mastra/code-sdk 1.15.1-alpha.3 → 1.15.1-alpha.5

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.
Files changed (208) hide show
  1. package/dist/acp/agent.js +1 -2
  2. package/dist/acp/errors.js +1 -2
  3. package/dist/acp/event-mapper.js +1 -2
  4. package/dist/acp/index.js +1 -2
  5. package/dist/acp/runtime.js +1 -2
  6. package/dist/acp/server.js +1 -2
  7. package/dist/acp/skills.js +1 -2
  8. package/dist/agent-connections/messaging-processor.js +1 -2
  9. package/dist/agent-connections/ownership.js +1 -2
  10. package/dist/agent-connections/registry.js +1 -2
  11. package/dist/agent-connections/session-advertisement.js +1 -2
  12. package/dist/agent-connections/signal-provider.js +1 -2
  13. package/dist/agent-connections/state-processor.js +1 -2
  14. package/dist/agent-connections/thread-state.js +1 -2
  15. package/dist/agent-connections/tools.js +1 -2
  16. package/dist/agent-connections/types.js +1 -2
  17. package/dist/agent-connections/untrusted-text.js +1 -2
  18. package/dist/agents/background-completion-events.js +1 -2
  19. package/dist/agents/background-completion.js +1 -2
  20. package/dist/agents/context-audit.js +1 -2
  21. package/dist/agents/credential-resolver.js +1 -2
  22. package/dist/agents/custom-provider-source.js +1 -2
  23. package/dist/agents/instructions.js +1 -2
  24. package/dist/agents/mastracode-gateway.d.ts.map +1 -1
  25. package/dist/agents/mastracode-gateway.js +6 -5
  26. package/dist/agents/mastracode-gateway.js.map +1 -1
  27. package/dist/agents/memory.js +1 -2
  28. package/dist/agents/model.js +1 -2
  29. package/dist/agents/modes/build.js +1 -2
  30. package/dist/agents/modes/explore.js +1 -2
  31. package/dist/agents/modes/plan.js +1 -2
  32. package/dist/agents/prompts/agent-instructions.js +1 -2
  33. package/dist/agents/prompts/build.js +1 -2
  34. package/dist/agents/prompts/fast.js +1 -2
  35. package/dist/agents/prompts/index.js +1 -2
  36. package/dist/agents/prompts/model.js +1 -2
  37. package/dist/agents/prompts/plan.js +1 -2
  38. package/dist/agents/prompts/tool-guidance.js +1 -2
  39. package/dist/agents/sandbox-filesystem.d.ts.map +1 -1
  40. package/dist/agents/sandbox-filesystem.js +9 -7
  41. package/dist/agents/sandbox-filesystem.js.map +1 -1
  42. package/dist/agents/subagents/execute.js +1 -2
  43. package/dist/agents/subagents/explore.js +1 -2
  44. package/dist/agents/subagents/plan.js +1 -2
  45. package/dist/agents/thread-caveman-state.js +1 -2
  46. package/dist/agents/tool-availability.js +1 -2
  47. package/dist/agents/tools.js +1 -2
  48. package/dist/agents/workflow-builder-agent.js +1 -2
  49. package/dist/agents/workspace.js +1 -2
  50. package/dist/analytics.js +1 -2
  51. package/dist/auth/account-rotation-processor.js +1 -2
  52. package/dist/auth/account-routing-context.js +1 -2
  53. package/dist/auth/authorization-input.js +1 -2
  54. package/dist/auth/device-code.js +1 -2
  55. package/dist/auth/pkce.js +1 -2
  56. package/dist/auth/provider-auth-error.d.ts +2 -0
  57. package/dist/auth/provider-auth-error.d.ts.map +1 -1
  58. package/dist/auth/provider-auth-error.js +8 -3
  59. package/dist/auth/provider-auth-error.js.map +1 -1
  60. package/dist/auth/providers/anthropic.js +1 -2
  61. package/dist/auth/providers/github-copilot.js +1 -2
  62. package/dist/auth/providers/kimi-coding.js +1 -2
  63. package/dist/auth/providers/openai-codex.js +1 -2
  64. package/dist/auth/providers/xai.js +1 -2
  65. package/dist/auth/storage.js +1 -2
  66. package/dist/clipboard/index.js +1 -2
  67. package/dist/constants.js +1 -2
  68. package/dist/error-classification.js +1 -2
  69. package/dist/evals/context-builder.js +1 -2
  70. package/dist/evals/scorers/classify-command.d.ts +1 -2
  71. package/dist/evals/scorers/classify-command.d.ts.map +1 -1
  72. package/dist/evals/scorers/classify-command.js +7 -17
  73. package/dist/evals/scorers/classify-command.js.map +1 -1
  74. package/dist/evals/scorers/efficiency.js +1 -2
  75. package/dist/evals/scorers/extract-tools.js +1 -2
  76. package/dist/evals/scorers/outcome.d.ts.map +1 -1
  77. package/dist/evals/scorers/outcome.js +36 -22
  78. package/dist/evals/scorers/outcome.js.map +1 -1
  79. package/dist/experimental-agent.js +1 -2
  80. package/dist/factory/client.js +1 -2
  81. package/dist/factory/remote-controller.js +1 -2
  82. package/dist/factory/remote-session.js +1 -2
  83. package/dist/goal-manager.js +1 -2
  84. package/dist/goal-signal.js +1 -2
  85. package/dist/headless/cli.js +1 -2
  86. package/dist/headless/flags.js +1 -2
  87. package/dist/headless/format.js +1 -2
  88. package/dist/headless/policy.js +1 -2
  89. package/dist/headless/run-mc.js +1 -2
  90. package/dist/headless/types.js +1 -2
  91. package/dist/hooks/config.js +1 -2
  92. package/dist/hooks/executor.js +1 -2
  93. package/dist/hooks/manager.js +1 -2
  94. package/dist/hooks/types.js +1 -2
  95. package/dist/index.js +1 -2
  96. package/dist/ipc/ipc-reporter.js +1 -2
  97. package/dist/knowledge-inspector.js +1 -2
  98. package/dist/knowledge-scope.js +1 -2
  99. package/dist/lsp/client.d.ts.map +1 -1
  100. package/dist/lsp/client.js +1 -2
  101. package/dist/lsp/client.js.map +1 -1
  102. package/dist/lsp/language.js +1 -2
  103. package/dist/lsp/manager.js +1 -2
  104. package/dist/lsp/server.js +1 -2
  105. package/dist/lsp/workspace.js +1 -2
  106. package/dist/mcp/config.js +1 -2
  107. package/dist/mcp/manager.js +1 -2
  108. package/dist/mcp/state.js +1 -2
  109. package/dist/onboarding/custom-packs.js +1 -2
  110. package/dist/onboarding/custom-providers.js +1 -2
  111. package/dist/onboarding/om-settings.js +1 -2
  112. package/dist/onboarding/pack-activation.js +1 -2
  113. package/dist/onboarding/packs.js +1 -2
  114. package/dist/onboarding/settings.js +1 -2
  115. package/dist/permissions.js +1 -2
  116. package/dist/platform/index.js +1 -2
  117. package/dist/plugin.js +1 -2
  118. package/dist/plugins/dependencies.js +1 -2
  119. package/dist/plugins/install.js +1 -2
  120. package/dist/plugins/loader.js +1 -2
  121. package/dist/plugins/manager.js +1 -2
  122. package/dist/plugins/manifest.js +1 -2
  123. package/dist/plugins/package-link.js +1 -2
  124. package/dist/plugins/paths.js +1 -2
  125. package/dist/plugins/registry.js +1 -2
  126. package/dist/plugins/scaffold.js +1 -2
  127. package/dist/plugins/signal-lane.js +1 -2
  128. package/dist/process-memory-diagnostics.js +1 -2
  129. package/dist/processors/plan-rejection-abort.js +1 -2
  130. package/dist/providers/amazon-bedrock-gateway.js +1 -2
  131. package/dist/providers/amazon-bedrock.js +1 -2
  132. package/dist/providers/anthropic-prompt-cache.js +1 -2
  133. package/dist/providers/anthropic-thinking.js +1 -2
  134. package/dist/providers/claude-max.d.ts.map +1 -1
  135. package/dist/providers/claude-max.js +4 -4
  136. package/dist/providers/claude-max.js.map +1 -1
  137. package/dist/providers/github-copilot-gateway.js +1 -2
  138. package/dist/providers/github-copilot.d.ts.map +1 -1
  139. package/dist/providers/github-copilot.js +5 -5
  140. package/dist/providers/github-copilot.js.map +1 -1
  141. package/dist/providers/google-thinking.js +1 -2
  142. package/dist/providers/kimi-coding.d.ts.map +1 -1
  143. package/dist/providers/kimi-coding.js +8 -7
  144. package/dist/providers/kimi-coding.js.map +1 -1
  145. package/dist/providers/model-ids.js +1 -2
  146. package/dist/providers/openai-codex.d.ts +15 -0
  147. package/dist/providers/openai-codex.d.ts.map +1 -1
  148. package/dist/providers/openai-codex.js +50 -11
  149. package/dist/providers/openai-codex.js.map +1 -1
  150. package/dist/providers/provider-thinking.js +1 -2
  151. package/dist/providers/thinking-request.js +1 -2
  152. package/dist/providers/xai.d.ts.map +1 -1
  153. package/dist/providers/xai.js +5 -5
  154. package/dist/providers/xai.js.map +1 -1
  155. package/dist/schedules/interval.js +1 -2
  156. package/dist/schedules/prompt.js +1 -2
  157. package/dist/schedules/run-script.js +1 -2
  158. package/dist/schedules/scheduler.js +1 -2
  159. package/dist/schedules/tools.js +1 -2
  160. package/dist/schema.js +1 -2
  161. package/dist/theme-palette.js +1 -2
  162. package/dist/thinking-catalog.js +1 -2
  163. package/dist/thinking.js +1 -2
  164. package/dist/tool-names.js +1 -2
  165. package/dist/tools/request-sandbox-access.js +1 -2
  166. package/dist/tools/utils.js +1 -2
  167. package/dist/tools/web-search.js +1 -2
  168. package/dist/tools/workflows/create-workflow.js +1 -2
  169. package/dist/tools/workflows/delete-workflow.js +1 -2
  170. package/dist/tools/workflows/ephemeral-memory.js +1 -2
  171. package/dist/tools/workflows/extract-json-schema.js +1 -2
  172. package/dist/tools/workflows/get-workflow.js +1 -2
  173. package/dist/tools/workflows/list-available-agents.js +1 -2
  174. package/dist/tools/workflows/list-available-classifiers.js +1 -2
  175. package/dist/tools/workflows/list-available-tools.js +1 -2
  176. package/dist/tools/workflows/list-available-workflows.js +1 -2
  177. package/dist/tools/workflows/list-workflows.js +1 -2
  178. package/dist/tools/workflows/run-workflow.js +1 -2
  179. package/dist/tools/workflows/save-workflow.js +1 -2
  180. package/dist/tools/workflows/tool-ids.js +1 -2
  181. package/dist/utils/binaries.js +1 -2
  182. package/dist/utils/debug-log.js +1 -2
  183. package/dist/utils/discarding-scores-storage.js +1 -2
  184. package/dist/utils/errors.js +1 -2
  185. package/dist/utils/gateway-sync.js +1 -2
  186. package/dist/utils/local-observability.js +1 -2
  187. package/dist/utils/maintenance-lock.js +1 -2
  188. package/dist/utils/notification-dispatch.js +1 -2
  189. package/dist/utils/open-url.js +1 -2
  190. package/dist/utils/path-security.js +1 -2
  191. package/dist/utils/plan-diff.js +1 -2
  192. package/dist/utils/plans.js +1 -2
  193. package/dist/utils/project.js +1 -2
  194. package/dist/utils/prune-cli.js +1 -2
  195. package/dist/utils/signals-pubsub.js +1 -2
  196. package/dist/utils/slash-command-loader.js +1 -2
  197. package/dist/utils/slash-command-processor.js +1 -2
  198. package/dist/utils/stdin-pipe.js +1 -2
  199. package/dist/utils/storage-factory.js +1 -2
  200. package/dist/utils/storage-maintenance.js +1 -2
  201. package/dist/utils/thread-lock.js +1 -2
  202. package/dist/utils/token-estimator.js +1 -2
  203. package/dist/utils/update-check.js +1 -2
  204. package/dist/utils/wake-session.js +1 -2
  205. package/dist/voice/stt-registry.js +1 -2
  206. package/dist/workflows/register-primitives.js +1 -2
  207. package/dist/workflows/service.js +1 -2
  208. package/package.json +36 -32
@@ -1,5 +1,5 @@
1
1
  import { MC_TOOLS } from "../../tool-names.js";
2
- //#region src/agents/subagents/execute.ts
2
+ // src/agents/subagents/execute.ts
3
3
  const executeSubagent = {
4
4
  id: "execute",
5
5
  name: "Execute",
@@ -21,7 +21,6 @@ const executeSubagent = {
21
21
  MC_TOOLS.LSP_INSPECT
22
22
  ]
23
23
  };
24
- //#endregion
25
24
  export { executeSubagent };
26
25
 
27
26
  //# sourceMappingURL=execute.js.map
@@ -1,5 +1,5 @@
1
1
  import { MC_TOOLS } from "../../tool-names.js";
2
- //#region src/agents/subagents/explore.ts
2
+ // src/agents/subagents/explore.ts
3
3
  const exploreSubagent = {
4
4
  id: "explore",
5
5
  name: "Explore",
@@ -12,7 +12,6 @@ const exploreSubagent = {
12
12
  MC_TOOLS.FILE_STAT
13
13
  ]
14
14
  };
15
- //#endregion
16
15
  export { exploreSubagent };
17
16
 
18
17
  //# sourceMappingURL=explore.js.map
@@ -1,5 +1,5 @@
1
1
  import { MC_TOOLS } from "../../tool-names.js";
2
- //#region src/agents/subagents/plan.ts
2
+ // src/agents/subagents/plan.ts
3
3
  const planSubagent = {
4
4
  id: "plan",
5
5
  name: "Plan",
@@ -12,7 +12,6 @@ const planSubagent = {
12
12
  MC_TOOLS.FILE_STAT
13
13
  ]
14
14
  };
15
- //#endregion
16
15
  export { planSubagent };
17
16
 
18
17
  //# sourceMappingURL=plan.js.map
@@ -1,4 +1,4 @@
1
- //#region src/agents/thread-caveman-state.ts
1
+ // src/agents/thread-caveman-state.ts
2
2
  const THREAD_STATE_SETTINGS = [
3
3
  {
4
4
  key: "cavemanObservations",
@@ -101,7 +101,6 @@ async function restoreOMThreadStateForCurrentThread(session) {
101
101
  if (!threadId) return;
102
102
  await restoreSettingsForThread(session, threadId);
103
103
  }
104
- //#endregion
105
104
  export { attachOMThreadStatePersistence, restoreOMThreadStateForCurrentThread };
106
105
 
107
106
  //# sourceMappingURL=thread-caveman-state.js.map
@@ -1,7 +1,7 @@
1
1
  import { getLocalPlansRelativeDir, isPlanFilePath } from "../utils/plans.js";
2
2
  import { MC_TOOLS, TOOL_NAME_OVERRIDES } from "../tool-names.js";
3
3
  import { WORKSPACE_TOOLS } from "@mastra/core/workspace";
4
- //#region src/agents/tool-availability.ts
4
+ // src/agents/tool-availability.ts
5
5
  const PLAN_MODE_WRITE_TOOL_NAMES = /* @__PURE__ */ new Set([WORKSPACE_TOOLS.FILESYSTEM.WRITE_FILE, WORKSPACE_TOOLS.FILESYSTEM.EDIT_FILE]);
6
6
  function getRequestContextValue(requestContext, key) {
7
7
  if (!requestContext) return void 0;
@@ -123,7 +123,6 @@ const GOAL_JUDGE_READONLY_TOOLS = [
123
123
  MC_TOOLS.FILE_STAT,
124
124
  MC_TOOLS.LSP_INSPECT
125
125
  ];
126
- //#endregion
127
126
  export { EXPLORE_MODE_AVAILABLE_TOOLS, GOAL_JUDGE_READONLY_TOOLS, MASTRACODE_WORKSPACE_TOOLS, PLAN_MODE_AVAILABLE_TOOLS, createMastraCodeWorkspaceTools, guardPlanModePlanFileWrites };
128
127
 
129
128
  //# sourceMappingURL=tool-availability.js.map
@@ -11,7 +11,7 @@ import { WORKFLOW_MANAGEMENT_TOOL_IDS } from "../tools/workflows/tool-ids.js";
11
11
  import { createOpenAI } from "@ai-sdk/openai";
12
12
  import { NotificationsStorage, createNotificationInboxTool } from "@mastra/core/notifications";
13
13
  import { createAnthropic } from "@ai-sdk/anthropic";
14
- //#region src/agents/tools.ts
14
+ // src/agents/tools.ts
15
15
  function configurePluginTool(tool, backgroundToolsEnabled) {
16
16
  if (backgroundToolsEnabled || !tool.background) return tool;
17
17
  return {
@@ -131,7 +131,6 @@ function createDynamicTools(mcpManager, extraTools, disabledTools, storage, plug
131
131
  return resolveExtra();
132
132
  };
133
133
  }
134
- //#endregion
135
134
  export { LazyNotificationsStorage, createDynamicTools, createToolHooks };
136
135
 
137
136
  //# sourceMappingURL=tools.js.map
@@ -6,7 +6,7 @@ import { listAvailableToolsTool } from "../tools/workflows/list-available-tools.
6
6
  import { listAvailableWorkflowsTool } from "../tools/workflows/list-available-workflows.js";
7
7
  import { saveWorkflowTool } from "../tools/workflows/save-workflow.js";
8
8
  import { createWorkflowBuilderAgent } from "@mastra/core/workflows/builder";
9
- //#region src/agents/workflow-builder-agent.ts
9
+ // src/agents/workflow-builder-agent.ts
10
10
  /**
11
11
  * Workflow Builder sub-agent.
12
12
  *
@@ -76,7 +76,6 @@ Your fifth tool is \`save-workflow\`, which persists and live-registers a defini
76
76
  `,
77
77
  model: getDynamicModel
78
78
  });
79
- //#endregion
80
79
  export { workflowBuilderAgent };
81
80
 
82
81
  //# sourceMappingURL=workflow-builder-agent.js.map
@@ -8,7 +8,7 @@ import fs, { existsSync } from "fs";
8
8
  import os from "os";
9
9
  import { fileURLToPath } from "url";
10
10
  import { LocalFilesystem, LocalSandbox, Workspace, createWorkspaceTools } from "@mastra/core/workspace";
11
- //#region src/agents/workspace.ts
11
+ // src/agents/workspace.ts
12
12
  function buildSandboxEnv() {
13
13
  return {
14
14
  ...process.env,
@@ -204,7 +204,6 @@ async function getGoalJudgeTools({ requestContext, mastra }) {
204
204
  for (const name of GOAL_JUDGE_READONLY_TOOLS) if (allTools[name]) readonly[name] = allTools[name];
205
205
  return Object.keys(readonly).length > 0 ? readonly : void 0;
206
206
  }
207
- //#endregion
208
207
  export { buildSkillPaths, getDynamicWorkspace, getGoalJudgeTools };
209
208
 
210
209
  //# sourceMappingURL=workspace.js.map
package/dist/analytics.js CHANGED
@@ -2,7 +2,7 @@ import path from "path";
2
2
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
3
3
  import os from "os";
4
4
  import { PostHog } from "posthog-node";
5
- //#region src/analytics.ts
5
+ // src/analytics.ts
6
6
  const POSTHOG_API_KEY = "phc_SBLpZVAB6jmHOct9CABq3PF0Yn5FU3G2FgT4xUr2XrT";
7
7
  const POSTHOG_HOST = "https://us.posthog.com";
8
8
  const MASTRA_SOURCE = "mastracode";
@@ -156,7 +156,6 @@ function createMastraCodeAnalytics(options) {
156
156
  }
157
157
  return new PostHogMastraCodeAnalytics(options);
158
158
  }
159
- //#endregion
160
159
  export { createMastraCodeAnalytics, getMastraAnalyticsDistinctId, isTelemetryDisabled };
161
160
 
162
161
  //# sourceMappingURL=analytics.js.map
@@ -6,7 +6,7 @@ import { resolveCredentialStore } from "../agents/credential-resolver.js";
6
6
  import { getRequestAccountSelection, isRequestAccountRoutingExhausted, markRequestAccountRoutingExhausted, setRequestAccountSelection } from "./account-routing-context.js";
7
7
  import { resolveModel, resolveRequestThinkingLevel } from "../agents/model.js";
8
8
  import { TripWire } from "@mastra/core/agent";
9
- //#region src/auth/account-rotation-processor.ts
9
+ // src/auth/account-rotation-processor.ts
10
10
  /**
11
11
  * Error-driven rotation across a provider's OAuth account registry.
12
12
  *
@@ -605,7 +605,6 @@ var AccountStartNoticeProcessor = class {
605
605
  return args.messageList;
606
606
  }
607
607
  };
608
- //#endregion
609
608
  export { ACCOUNT_SWITCH_PART_TYPE, AccountRotationProcessor, AccountStartNoticeProcessor, MODEL_FALLBACK_PART_TYPE, MODEL_FALLBACK_STATE_KEY, PROVIDER_DISPLAY_NAMES, accountSwitchNoticeText, classifyRotationError, isAccountSwitchReason, isModelFallbackReason, modelFallbackNoticeText, providerFromError, providerFromModelId };
610
609
 
611
610
  //# sourceMappingURL=account-rotation-processor.js.map
@@ -1,4 +1,4 @@
1
- //#region src/auth/account-routing-context.ts
1
+ // src/auth/account-routing-context.ts
2
2
  const ACCOUNT_ROUTING_SELECTIONS_KEY = "mastracodeAccountRoutingSelections";
3
3
  function getSelections(requestContext) {
4
4
  const value = requestContext?.get(ACCOUNT_ROUTING_SELECTIONS_KEY);
@@ -35,7 +35,6 @@ function markRequestAccountRoutingExhausted(requestContext, providerId) {
35
35
  function isRequestAccountRoutingExhausted(requestContext, providerId) {
36
36
  return getExhaustedProviders(requestContext).includes(providerId);
37
37
  }
38
- //#endregion
39
38
  export { getRequestAccountSelection, isRequestAccountRoutingExhausted, markRequestAccountRoutingExhausted, setRequestAccountSelection };
40
39
 
41
40
  //# sourceMappingURL=account-routing-context.js.map
@@ -1,4 +1,4 @@
1
- //#region src/auth/authorization-input.ts
1
+ // src/auth/authorization-input.ts
2
2
  /**
3
3
  * Forgiving parser for user-pasted OAuth authorization input.
4
4
  *
@@ -36,7 +36,6 @@ function parseAuthorizationInput(input) {
36
36
  }
37
37
  return { code: value };
38
38
  }
39
- //#endregion
40
39
  export { parseAuthorizationInput };
41
40
 
42
41
  //# sourceMappingURL=authorization-input.js.map
@@ -1,4 +1,4 @@
1
- //#region src/auth/device-code.ts
1
+ // src/auth/device-code.ts
2
2
  /**
3
3
  * Generic RFC 8628 (OAuth 2.0 Device Authorization Grant) polling helpers.
4
4
  *
@@ -123,7 +123,6 @@ async function pollDeviceCodeUntilComplete(options) {
123
123
  if (step.status === "failed") throw new Error(step.error);
124
124
  }
125
125
  }
126
- //#endregion
127
126
  export { abortableSleep, createDeviceCodePollState, nextPollDelayMs, pollDeviceCodeUntilComplete, stepDeviceCodePoll };
128
127
 
129
128
  //# sourceMappingURL=device-code.js.map
package/dist/auth/pkce.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/auth/pkce.ts
1
+ // src/auth/pkce.ts
2
2
  /**
3
3
  * PKCE utilities using Web Crypto API.
4
4
  * Works in both Node.js 20+ and browsers.
@@ -26,7 +26,6 @@ async function generatePKCE() {
26
26
  challenge: base64urlEncode(new Uint8Array(hashBuffer))
27
27
  };
28
28
  }
29
- //#endregion
30
29
  export { generatePKCE };
31
30
 
32
31
  //# sourceMappingURL=pkce.js.map
@@ -8,6 +8,8 @@ export declare const PROVIDER_AUTH_REQUIRED_ERROR = "ProviderAuthRequiredError";
8
8
  */
9
9
  export declare class ProviderAuthRequiredError extends Error {
10
10
  readonly name = "ProviderAuthRequiredError";
11
+ static notSignedIn(providerName: string): ProviderAuthRequiredError;
12
+ static signInExpired(providerName: string): ProviderAuthRequiredError;
11
13
  }
12
14
  /**
13
15
  * A stored OAuth token the provider rejects (revoked, signed out elsewhere) is
@@ -1 +1 @@
1
- {"version":3,"file":"provider-auth-error.d.ts","sourceRoot":"","sources":["../../src/auth/provider-auth-error.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,eAAO,MAAM,4BAA4B,8BAA8B,CAAC;AAExE;;;;;GAKG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,IAAI,+BAAgC;CAC9C;AAiBD;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,QAAQ,EAClB,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACzE,OAAO,CAAC,QAAQ,CAAC,CAKnB"}
1
+ {"version":3,"file":"provider-auth-error.d.ts","sourceRoot":"","sources":["../../src/auth/provider-auth-error.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,eAAO,MAAM,4BAA4B,8BAA8B,CAAC;AAExE;;;;;GAKG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,IAAI,+BAAgC;IAE7C,MAAM,CAAC,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,yBAAyB;IAInE,MAAM,CAAC,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,yBAAyB;CAGtE;AAiBD;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,QAAQ,EAClB,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACzE,OAAO,CAAC,QAAQ,CAAC,CAKnB"}
@@ -1,4 +1,4 @@
1
- //#region src/auth/provider-auth-error.ts
1
+ // src/auth/provider-auth-error.ts
2
2
  /** Wire-stable `Error.name`: the server flattens errors to `{ name, message }`, so hosts match on this. */
3
3
  const PROVIDER_AUTH_REQUIRED_ERROR = "ProviderAuthRequiredError";
4
4
  /**
@@ -7,8 +7,14 @@ const PROVIDER_AUTH_REQUIRED_ERROR = "ProviderAuthRequiredError";
7
7
  * TUI, Settings → Models in the factory web UI), so no host advertises a
8
8
  * command another host doesn't have.
9
9
  */
10
- var ProviderAuthRequiredError = class extends Error {
10
+ var ProviderAuthRequiredError = class ProviderAuthRequiredError extends Error {
11
11
  name = PROVIDER_AUTH_REQUIRED_ERROR;
12
+ static notSignedIn(providerName) {
13
+ return new ProviderAuthRequiredError(`Not logged in to ${providerName}.`);
14
+ }
15
+ static signInExpired(providerName) {
16
+ return new ProviderAuthRequiredError(`${providerName} sign-in expired.`);
17
+ }
12
18
  };
13
19
  function providerErrorMessage(body) {
14
20
  try {
@@ -35,7 +41,6 @@ async function rejectUnauthorizedResponse(response, { providerName, requestUrl }
35
41
  requestUrl
36
42
  });
37
43
  }
38
- //#endregion
39
44
  export { PROVIDER_AUTH_REQUIRED_ERROR, ProviderAuthRequiredError, rejectUnauthorizedResponse };
40
45
 
41
46
  //# sourceMappingURL=provider-auth-error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider-auth-error.js","names":[],"sources":["../../src/auth/provider-auth-error.ts"],"sourcesContent":["/** Wire-stable `Error.name`: the server flattens errors to `{ name, message }`, so hosts match on this. */\nexport const PROVIDER_AUTH_REQUIRED_ERROR = 'ProviderAuthRequiredError';\n\n/**\n * A provider credential is missing or no longer usable. The message states the\n * fact only — how the user re-authenticates is the host's call (`/login` in the\n * TUI, Settings → Models in the factory web UI), so no host advertises a\n * command another host doesn't have.\n */\nexport class ProviderAuthRequiredError extends Error {\n readonly name = PROVIDER_AUTH_REQUIRED_ERROR;\n}\n\nfunction providerErrorMessage(body: string): string | undefined {\n try {\n const parsed = JSON.parse(body) as { message?: unknown; error?: unknown };\n const error = parsed.error;\n if (typeof error === 'object' && error !== null && 'message' in error && typeof error.message === 'string') {\n return error.message;\n }\n if (typeof error === 'string') return error;\n if (typeof parsed.message === 'string') return parsed.message;\n } catch {\n // Not JSON — fall through to the raw text.\n }\n return body.trim() || undefined;\n}\n\n/**\n * A stored OAuth token the provider rejects (revoked, signed out elsewhere) is\n * the same user-facing state as a missing one, so a 401 becomes\n * `ProviderAuthRequiredError`. `status` and `requestUrl` stay on the error:\n * account rotation reads them to force a refresh and attribute the provider.\n */\nexport async function rejectUnauthorizedResponse(\n response: Response,\n { providerName, requestUrl }: { providerName: string; requestUrl: string },\n): Promise<Response> {\n if (response.status !== 401) return response;\n const detail = providerErrorMessage(await response.text().catch(() => ''));\n const message = `${providerName} rejected the stored sign-in${detail ? `: ${detail}` : '.'}`;\n throw Object.assign(new ProviderAuthRequiredError(message), { status: 401, requestUrl });\n}\n"],"mappings":";;AACA,MAAa,+BAA+B;;;;;;;AAQ5C,IAAa,4BAAb,cAA+C,MAAM;CACnD,OAAgB;AAClB;AAEA,SAAS,qBAAqB,MAAkC;CAC9D,IAAI;EACF,MAAM,SAAS,KAAK,MAAM,IAAI;EAC9B,MAAM,QAAQ,OAAO;EACrB,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,aAAa,SAAS,OAAO,MAAM,YAAY,UAChG,OAAO,MAAM;EAEf,IAAI,OAAO,UAAU,UAAU,OAAO;EACtC,IAAI,OAAO,OAAO,YAAY,UAAU,OAAO,OAAO;CACxD,QAAQ,CAER;CACA,OAAO,KAAK,KAAK,KAAK,KAAA;AACxB;;;;;;;AAQA,eAAsB,2BACpB,UACA,EAAE,cAAc,cACG;CACnB,IAAI,SAAS,WAAW,KAAK,OAAO;CACpC,MAAM,SAAS,qBAAqB,MAAM,SAAS,KAAK,CAAC,CAAC,YAAY,EAAE,CAAC;CACzE,MAAM,UAAU,GAAG,aAAa,8BAA8B,SAAS,KAAK,WAAW;CACvF,MAAM,OAAO,OAAO,IAAI,0BAA0B,OAAO,GAAG;EAAE,QAAQ;EAAK;CAAW,CAAC;AACzF"}
1
+ {"version":3,"file":"provider-auth-error.js","names":[],"sources":["../../src/auth/provider-auth-error.ts"],"sourcesContent":["/** Wire-stable `Error.name`: the server flattens errors to `{ name, message }`, so hosts match on this. */\nexport const PROVIDER_AUTH_REQUIRED_ERROR = 'ProviderAuthRequiredError';\n\n/**\n * A provider credential is missing or no longer usable. The message states the\n * fact only — how the user re-authenticates is the host's call (`/login` in the\n * TUI, Settings → Models in the factory web UI), so no host advertises a\n * command another host doesn't have.\n */\nexport class ProviderAuthRequiredError extends Error {\n readonly name = PROVIDER_AUTH_REQUIRED_ERROR;\n\n static notSignedIn(providerName: string): ProviderAuthRequiredError {\n return new ProviderAuthRequiredError(`Not logged in to ${providerName}.`);\n }\n\n static signInExpired(providerName: string): ProviderAuthRequiredError {\n return new ProviderAuthRequiredError(`${providerName} sign-in expired.`);\n }\n}\n\nfunction providerErrorMessage(body: string): string | undefined {\n try {\n const parsed = JSON.parse(body) as { message?: unknown; error?: unknown };\n const error = parsed.error;\n if (typeof error === 'object' && error !== null && 'message' in error && typeof error.message === 'string') {\n return error.message;\n }\n if (typeof error === 'string') return error;\n if (typeof parsed.message === 'string') return parsed.message;\n } catch {\n // Not JSON — fall through to the raw text.\n }\n return body.trim() || undefined;\n}\n\n/**\n * A stored OAuth token the provider rejects (revoked, signed out elsewhere) is\n * the same user-facing state as a missing one, so a 401 becomes\n * `ProviderAuthRequiredError`. `status` and `requestUrl` stay on the error:\n * account rotation reads them to force a refresh and attribute the provider.\n */\nexport async function rejectUnauthorizedResponse(\n response: Response,\n { providerName, requestUrl }: { providerName: string; requestUrl: string },\n): Promise<Response> {\n if (response.status !== 401) return response;\n const detail = providerErrorMessage(await response.text().catch(() => ''));\n const message = `${providerName} rejected the stored sign-in${detail ? `: ${detail}` : '.'}`;\n throw Object.assign(new ProviderAuthRequiredError(message), { status: 401, requestUrl });\n}\n"],"mappings":";;AACA,MAAa,+BAA+B;;;;;;;AAQ5C,IAAa,4BAAb,MAAa,kCAAkC,MAAM;CACnD,OAAgB;CAEhB,OAAO,YAAY,cAAiD;EAClE,OAAO,IAAI,0BAA0B,oBAAoB,aAAa,EAAE;CAC1E;CAEA,OAAO,cAAc,cAAiD;EACpE,OAAO,IAAI,0BAA0B,GAAG,aAAa,kBAAkB;CACzE;AACF;AAEA,SAAS,qBAAqB,MAAkC;CAC9D,IAAI;EACF,MAAM,SAAS,KAAK,MAAM,IAAI;EAC9B,MAAM,QAAQ,OAAO;EACrB,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,aAAa,SAAS,OAAO,MAAM,YAAY,UAChG,OAAO,MAAM;EAEf,IAAI,OAAO,UAAU,UAAU,OAAO;EACtC,IAAI,OAAO,OAAO,YAAY,UAAU,OAAO,OAAO;CACxD,QAAQ,CAER;CACA,OAAO,KAAK,KAAK,KAAK,KAAA;AACxB;;;;;;;AAQA,eAAsB,2BACpB,UACA,EAAE,cAAc,cACG;CACnB,IAAI,SAAS,WAAW,KAAK,OAAO;CACpC,MAAM,SAAS,qBAAqB,MAAM,SAAS,KAAK,CAAC,CAAC,YAAY,EAAE,CAAC;CACzE,MAAM,UAAU,GAAG,aAAa,8BAA8B,SAAS,KAAK,WAAW;CACvF,MAAM,OAAO,OAAO,IAAI,0BAA0B,OAAO,GAAG;EAAE,QAAQ;EAAK;CAAW,CAAC;AACzF"}
@@ -1,6 +1,6 @@
1
1
  import { parseAuthorizationInput } from "../authorization-input.js";
2
2
  import { generatePKCE } from "../pkce.js";
3
- //#region src/auth/providers/anthropic.ts
3
+ // src/auth/providers/anthropic.ts
4
4
  /**
5
5
  * Anthropic OAuth flow (Claude Pro/Max)
6
6
  *
@@ -114,7 +114,6 @@ const anthropicOAuthProvider = {
114
114
  return credentials.access;
115
115
  }
116
116
  };
117
- //#endregion
118
117
  export { anthropicOAuthProvider, completeAnthropicLogin, loginAnthropic, refreshAnthropicToken, startAnthropicLogin };
119
118
 
120
119
  //# sourceMappingURL=anthropic.js.map
@@ -1,4 +1,4 @@
1
- //#region src/auth/providers/github-copilot.ts
1
+ // src/auth/providers/github-copilot.ts
2
2
  const decode = (s) => atob(s);
3
3
  const CLIENT_ID = decode("SXYxLmI1MDdhMDhjODdlY2ZlOTg=");
4
4
  const COPILOT_USER_AGENT = "GitHubCopilotChat/0.35.0";
@@ -356,7 +356,6 @@ const githubCopilotOAuthProvider = {
356
356
  }
357
357
  }
358
358
  };
359
- //#endregion
360
359
  export { COPILOT_HEADERS, COPILOT_USER_AGENT, copilotNextPollDelayMs, fetchCopilotModels, getGitHubCopilotBaseUrl, githubCopilotOAuthProvider, loginGitHubCopilot, normalizeDomain, pollGitHubCopilotDeviceLogin, refreshGitHubCopilotToken, startGitHubCopilotDeviceLogin };
361
360
 
362
361
  //# sourceMappingURL=github-copilot.js.map
@@ -1,7 +1,7 @@
1
1
  import { getCurrentVersion } from "../../utils/update-check.js";
2
2
  import { abortableSleep, createDeviceCodePollState, pollDeviceCodeUntilComplete, stepDeviceCodePoll } from "../device-code.js";
3
3
  import { arch, hostname, platform, release } from "os";
4
- //#region src/auth/providers/kimi-coding.ts
4
+ // src/auth/providers/kimi-coding.ts
5
5
  const CLIENT_ID = "17e5f671-d194-4dfb-9706-5516cb48c098";
6
6
  const OAUTH_HOST = "https://auth.kimi.com";
7
7
  const DEVICE_ID_PATTERN = /^[0-9a-f]{32}$/;
@@ -222,7 +222,6 @@ const kimiCodingOAuthProvider = {
222
222
  refreshToken: (credentials) => refreshKimiCodingToken(credentials.refresh, { deviceId: typeof credentials.deviceId === "string" ? credentials.deviceId : "" }),
223
223
  getApiKey: (credentials) => credentials.access
224
224
  };
225
- //#endregion
226
225
  export { createKimiCodingDeviceId, getKimiCodingDeviceHeaders, isKimiCodingDeviceId, kimiCodingOAuthProvider, loginKimiCoding, pollKimiCodingDeviceLogin, refreshKimiCodingToken, startKimiCodingDeviceLogin };
227
226
 
228
227
  //# sourceMappingURL=kimi-coding.js.map
@@ -1,6 +1,6 @@
1
1
  import { parseAuthorizationInput } from "../authorization-input.js";
2
2
  import { generatePKCE } from "../pkce.js";
3
- //#region src/auth/providers/openai-codex.ts
3
+ // src/auth/providers/openai-codex.ts
4
4
  /**
5
5
  * OpenAI Codex (ChatGPT OAuth) flow
6
6
  *
@@ -528,7 +528,6 @@ const openaiCodexOAuthProvider = {
528
528
  return typeof accountId === "string" && accountId.length > 0 ? accountId : void 0;
529
529
  }
530
530
  };
531
- //#endregion
532
531
  export { OPENAI_CODEX_AUTH_MODES, __testing, loginOpenAICodex, openaiCodexOAuthProvider, pollCodexDeviceLogin, refreshOpenAICodexToken, startCodexDeviceLogin };
533
532
 
534
533
  //# sourceMappingURL=openai-codex.js.map
@@ -1,5 +1,5 @@
1
1
  import { createDeviceCodePollState, pollDeviceCodeUntilComplete, stepDeviceCodePoll } from "../device-code.js";
2
- //#region src/auth/providers/xai.ts
2
+ // src/auth/providers/xai.ts
3
3
  /**
4
4
  * xAI OAuth flow (Grok)
5
5
  *
@@ -220,7 +220,6 @@ const xaiOAuthProvider = {
220
220
  return emailFromIdToken(credentials.idToken);
221
221
  }
222
222
  };
223
- //#endregion
224
223
  export { loginXAI, pollXAIDeviceLogin, refreshXAIToken, startXAIDeviceLogin, xaiOAuthProvider };
225
224
 
226
225
  //# sourceMappingURL=xai.js.map
@@ -7,7 +7,7 @@ import { xaiOAuthProvider } from "./providers/xai.js";
7
7
  import { dirname, join } from "path";
8
8
  import { createHash } from "crypto";
9
9
  import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "fs";
10
- //#region src/auth/storage.ts
10
+ // src/auth/storage.ts
11
11
  /**
12
12
  * Credential storage for API keys and OAuth tokens.
13
13
  * Handles loading, saving, and refreshing credentials from auth.json.
@@ -768,7 +768,6 @@ var AuthStorage = class {
768
768
  }
769
769
  }
770
770
  };
771
- //#endregion
772
771
  export { AuthStorage, PROVIDER_DEFAULT_MODELS, getOAuthProvider, getOAuthProviders };
773
772
 
774
773
  //# sourceMappingURL=storage.js.map
@@ -2,7 +2,7 @@ import { join } from "path";
2
2
  import { readFileSync, unlinkSync } from "fs";
3
3
  import { execSync } from "child_process";
4
4
  import { tmpdir } from "os";
5
- //#region src/clipboard/index.ts
5
+ // src/clipboard/index.ts
6
6
  /**
7
7
  * Platform-specific clipboard image extraction.
8
8
  *
@@ -221,7 +221,6 @@ function getLinuxClipboardImageWlPaste() {
221
221
  return null;
222
222
  }
223
223
  }
224
- //#endregion
225
224
  export { getClipboardImage, getClipboardText, setClipboardText };
226
225
 
227
226
  //# sourceMappingURL=index.js.map
package/dist/constants.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as path$1 from "path";
2
- //#region src/constants.ts
2
+ // src/constants.ts
3
3
  const DEFAULT_CONFIG_DIR = ".mastracode";
4
4
  /**
5
5
  * Validate that a configDirName is a safe single directory name.
@@ -14,7 +14,6 @@ const MODEL_ROUTE_MAX_FIELD_LENGTH = 512;
14
14
  const DEFAULT_OM_MODEL_ID = process.env.DEFAULT_OM_MODEL_ID ?? "google/gemini-3.5-flash";
15
15
  const DEFAULT_OBS_THRESHOLD = 3e4;
16
16
  const DEFAULT_REF_THRESHOLD = 4e4;
17
- //#endregion
18
17
  export { DEFAULT_CONFIG_DIR, DEFAULT_OBS_THRESHOLD, DEFAULT_OM_MODEL_ID, DEFAULT_REF_THRESHOLD, MODEL_ROUTE_MAX_ENTRIES, MODEL_ROUTE_MAX_FIELD_LENGTH, validateConfigDirName };
19
18
 
20
19
  //# sourceMappingURL=constants.js.map
@@ -1,4 +1,4 @@
1
- //#region src/error-classification.ts
1
+ // src/error-classification.ts
2
2
  /**
3
3
  * Checks whether an error is an ERR_STREAM_DESTROYED error, which is a
4
4
  * non-fatal condition that occurs when code writes to a stream after it
@@ -16,7 +16,6 @@ function isStreamDestroyedError(err, depth = 0) {
16
16
  if (Array.isArray(e.errors) && e.errors.some((inner) => isStreamDestroyedError(inner, depth + 1))) return true;
17
17
  return false;
18
18
  }
19
- //#endregion
20
19
  export { isStreamDestroyedError };
21
20
 
22
21
  //# sourceMappingURL=error-classification.js.map
@@ -1,5 +1,5 @@
1
1
  import { extractTrajectoryFromTrace } from "@mastra/core/evals";
2
- //#region src/evals/context-builder.ts
2
+ // src/evals/context-builder.ts
3
3
  /**
4
4
  * Build an evaluation context from a AgentController session.
5
5
  *
@@ -153,7 +153,6 @@ function buildRequestContext(session, threadId) {
153
153
  smartEditing: state.smartEditing
154
154
  };
155
155
  }
156
- //#endregion
157
156
  export { buildEvalContext };
158
157
 
159
158
  //# sourceMappingURL=context-builder.js.map
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * Shared command classification utilities for scoring.
3
3
  *
4
- * Used by both live scorers (outcome.ts) and offline scorers (outcome-match.ts)
5
- * to consistently identify build, test, and other command types.
4
+ * Used by scorers to consistently identify build, test, and other command types.
6
5
  */
7
6
  /**
8
7
  * Check if a command string is a build/typecheck command.
@@ -1 +1 @@
1
- {"version":3,"file":"classify-command.d.ts","sourceRoot":"","sources":["../../../src/evals/scorers/classify-command.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAUvD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAgB1D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAiBzE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGvE"}
1
+ {"version":3,"file":"classify-command.d.ts","sourceRoot":"","sources":["../../../src/evals/scorers/classify-command.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAUvD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAgB1D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAQzE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGvE"}
@@ -1,9 +1,8 @@
1
- //#region src/evals/scorers/classify-command.ts
1
+ // src/evals/scorers/classify-command.ts
2
2
  /**
3
3
  * Shared command classification utilities for scoring.
4
4
  *
5
- * Used by both live scorers (outcome.ts) and offline scorers (outcome-match.ts)
6
- * to consistently identify build, test, and other command types.
5
+ * Used by scorers to consistently identify build, test, and other command types.
7
6
  */
8
7
  /**
9
8
  * Check if a command string is a build/typecheck command.
@@ -30,7 +29,7 @@ function isTestCommand(command) {
30
29
  function getExitCode(result) {
31
30
  if (result == null) return null;
32
31
  if (typeof result === "string") {
33
- const exitMatch = result.match(/exit(?:ed)?\s+(?:with\s+)?(?:code\s+)?(\d+)/i);
32
+ const exitMatch = result.match(/(?:^|\n)(?:exit code\s*:?|process exited with code)\s*(-?\d+)\s*$/i);
34
33
  if (exitMatch) return parseInt(exitMatch[1], 10);
35
34
  return null;
36
35
  }
@@ -46,18 +45,10 @@ function getExitCode(result) {
46
45
  * Works with both structured result objects and string results.
47
46
  */
48
47
  function isSuccessResult(result, error) {
49
- if (error) return false;
50
- if (!result) return false;
51
- if (typeof result === "object") {
52
- const obj = result;
53
- const exitCode = obj.exitCode ?? obj.code;
54
- if (typeof exitCode === "number") return exitCode === 0;
55
- }
56
- if (typeof result === "string") {
57
- const exitMatch = result.match(/exit(?:ed)?\s+(?:with\s+)?(?:code\s+)?(\d+)/i);
58
- if (exitMatch) return exitMatch[1] === "0";
59
- }
60
- return false;
48
+ if (error || !result) return false;
49
+ const exitCode = getExitCode(result);
50
+ if (exitCode !== null) return exitCode === 0;
51
+ return typeof result === "string";
61
52
  }
62
53
  /**
63
54
  * Match a file path from tool output against an expected path.
@@ -67,7 +58,6 @@ function matchFilePath(actual, expected) {
67
58
  if (actual === expected) return true;
68
59
  return actual.endsWith(`/${expected}`) || expected.endsWith(`/${actual}`);
69
60
  }
70
- //#endregion
71
61
  export { getExitCode, isBuildCommand, isSuccessResult, isTestCommand, matchFilePath };
72
62
 
73
63
  //# sourceMappingURL=classify-command.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"classify-command.js","names":[],"sources":["../../../src/evals/scorers/classify-command.ts"],"sourcesContent":["/**\n * Shared command classification utilities for scoring.\n *\n * Used by both live scorers (outcome.ts) and offline scorers (outcome-match.ts)\n * to consistently identify build, test, and other command types.\n */\n\n/**\n * Check if a command string is a build/typecheck command.\n * Handles compound commands (e.g. `pnpm build && pnpm test`) by checking each segment.\n */\nexport function isBuildCommand(command: string): boolean {\n const segments = command.split(/\\s*(?:&&|\\|\\||;)\\s*/);\n return segments.some(seg => {\n const trimmed = seg.trim();\n if (!/\\b(tsc|typecheck|type-check|build)\\b/.test(trimmed)) return false;\n // Don't reject if \"test\" only appears as a substring (e.g. \"build-test-output\").\n // Only reject if a test runner is the primary verb of this segment.\n const primaryVerb = trimmed.replace(/^(?:pnpm|npm|yarn|npx|bunx?|turbo)\\s+(?:run\\s+)?/, '').split(/\\s/)[0] ?? '';\n return !/^(test|vitest|jest|mocha|pytest)$/.test(primaryVerb);\n });\n}\n\n/**\n * Check if a command string is a test command.\n */\nexport function isTestCommand(command: string): boolean {\n return /\\b(test|vitest|jest|mocha|pytest|spec)\\b/.test(command);\n}\n\n/**\n * Extract exit code from an `execute_command` result.\n * Only trusts explicit exitCode/code fields — no heuristic fallbacks.\n */\nexport function getExitCode(result: unknown): number | null {\n if (result == null) return null;\n\n if (typeof result === 'string') {\n const exitMatch = result.match(/exit(?:ed)?\\s+(?:with\\s+)?(?:code\\s+)?(\\d+)/i);\n if (exitMatch) return parseInt(exitMatch[1]!, 10);\n return null;\n }\n\n if (typeof result === 'object') {\n const obj = result as Record<string, unknown>;\n if ('exitCode' in obj && typeof obj.exitCode === 'number') return obj.exitCode;\n if ('code' in obj && typeof obj.code === 'number') return obj.code;\n }\n\n return null;\n}\n\n/**\n * Determine if a tool call result indicates success (exit code 0, no explicit error).\n * Works with both structured result objects and string results.\n */\nexport function isSuccessResult(result: unknown, error?: unknown): boolean {\n if (error) return false;\n if (!result) return false;\n\n if (typeof result === 'object') {\n const obj = result as Record<string, unknown>;\n const exitCode = (obj.exitCode as number | undefined) ?? (obj.code as number | undefined);\n if (typeof exitCode === 'number') return exitCode === 0;\n }\n\n if (typeof result === 'string') {\n const exitMatch = result.match(/exit(?:ed)?\\s+(?:with\\s+)?(?:code\\s+)?(\\d+)/i);\n if (exitMatch) return exitMatch[1] === '0';\n }\n\n // No explicit exit code — can't determine\n return false;\n}\n\n/**\n * Match a file path from tool output against an expected path.\n * Supports exact match and suffix match (e.g. \"src/foo.ts\" matches \"/abs/path/src/foo.ts\").\n */\nexport function matchFilePath(actual: string, expected: string): boolean {\n if (actual === expected) return true;\n return actual.endsWith(`/${expected}`) || expected.endsWith(`/${actual}`);\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAgB,eAAe,SAA0B;CAEvD,OADiB,QAAQ,MAAM,qBACjB,CAAC,CAAC,MAAK,QAAO;EAC1B,MAAM,UAAU,IAAI,KAAK;EACzB,IAAI,CAAC,uCAAuC,KAAK,OAAO,GAAG,OAAO;EAGlE,MAAM,cAAc,QAAQ,QAAQ,oDAAoD,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM;EAC9G,OAAO,CAAC,oCAAoC,KAAK,WAAW;CAC9D,CAAC;AACH;;;;AAKA,SAAgB,cAAc,SAA0B;CACtD,OAAO,2CAA2C,KAAK,OAAO;AAChE;;;;;AAMA,SAAgB,YAAY,QAAgC;CAC1D,IAAI,UAAU,MAAM,OAAO;CAE3B,IAAI,OAAO,WAAW,UAAU;EAC9B,MAAM,YAAY,OAAO,MAAM,8CAA8C;EAC7E,IAAI,WAAW,OAAO,SAAS,UAAU,IAAK,EAAE;EAChD,OAAO;CACT;CAEA,IAAI,OAAO,WAAW,UAAU;EAC9B,MAAM,MAAM;EACZ,IAAI,cAAc,OAAO,OAAO,IAAI,aAAa,UAAU,OAAO,IAAI;EACtE,IAAI,UAAU,OAAO,OAAO,IAAI,SAAS,UAAU,OAAO,IAAI;CAChE;CAEA,OAAO;AACT;;;;;AAMA,SAAgB,gBAAgB,QAAiB,OAA0B;CACzE,IAAI,OAAO,OAAO;CAClB,IAAI,CAAC,QAAQ,OAAO;CAEpB,IAAI,OAAO,WAAW,UAAU;EAC9B,MAAM,MAAM;EACZ,MAAM,WAAY,IAAI,YAAoC,IAAI;EAC9D,IAAI,OAAO,aAAa,UAAU,OAAO,aAAa;CACxD;CAEA,IAAI,OAAO,WAAW,UAAU;EAC9B,MAAM,YAAY,OAAO,MAAM,8CAA8C;EAC7E,IAAI,WAAW,OAAO,UAAU,OAAO;CACzC;CAGA,OAAO;AACT;;;;;AAMA,SAAgB,cAAc,QAAgB,UAA2B;CACvE,IAAI,WAAW,UAAU,OAAO;CAChC,OAAO,OAAO,SAAS,IAAI,UAAU,KAAK,SAAS,SAAS,IAAI,QAAQ;AAC1E"}
1
+ {"version":3,"file":"classify-command.js","names":[],"sources":["../../../src/evals/scorers/classify-command.ts"],"sourcesContent":["/**\n * Shared command classification utilities for scoring.\n *\n * Used by scorers to consistently identify build, test, and other command types.\n */\n\n/**\n * Check if a command string is a build/typecheck command.\n * Handles compound commands (e.g. `pnpm build && pnpm test`) by checking each segment.\n */\nexport function isBuildCommand(command: string): boolean {\n const segments = command.split(/\\s*(?:&&|\\|\\||;)\\s*/);\n return segments.some(seg => {\n const trimmed = seg.trim();\n if (!/\\b(tsc|typecheck|type-check|build)\\b/.test(trimmed)) return false;\n // Don't reject if \"test\" only appears as a substring (e.g. \"build-test-output\").\n // Only reject if a test runner is the primary verb of this segment.\n const primaryVerb = trimmed.replace(/^(?:pnpm|npm|yarn|npx|bunx?|turbo)\\s+(?:run\\s+)?/, '').split(/\\s/)[0] ?? '';\n return !/^(test|vitest|jest|mocha|pytest)$/.test(primaryVerb);\n });\n}\n\n/**\n * Check if a command string is a test command.\n */\nexport function isTestCommand(command: string): boolean {\n return /\\b(test|vitest|jest|mocha|pytest|spec)\\b/.test(command);\n}\n\n/**\n * Extract exit code from an `execute_command` result.\n * Only trusts explicit exitCode/code fields — no heuristic fallbacks.\n */\nexport function getExitCode(result: unknown): number | null {\n if (result == null) return null;\n\n if (typeof result === 'string') {\n const exitMatch = result.match(/(?:^|\\n)(?:exit code\\s*:?|process exited with code)\\s*(-?\\d+)\\s*$/i);\n if (exitMatch) return parseInt(exitMatch[1]!, 10);\n return null;\n }\n\n if (typeof result === 'object') {\n const obj = result as Record<string, unknown>;\n if ('exitCode' in obj && typeof obj.exitCode === 'number') return obj.exitCode;\n if ('code' in obj && typeof obj.code === 'number') return obj.code;\n }\n\n return null;\n}\n\n/**\n * Determine if a tool call result indicates success (exit code 0, no explicit error).\n * Works with both structured result objects and string results.\n */\nexport function isSuccessResult(result: unknown, error?: unknown): boolean {\n if (error || !result) return false;\n\n const exitCode = getExitCode(result);\n if (exitCode !== null) return exitCode === 0;\n\n // execute_command only appends an exit code when the command fails.\n return typeof result === 'string';\n}\n\n/**\n * Match a file path from tool output against an expected path.\n * Supports exact match and suffix match (e.g. \"src/foo.ts\" matches \"/abs/path/src/foo.ts\").\n */\nexport function matchFilePath(actual: string, expected: string): boolean {\n if (actual === expected) return true;\n return actual.endsWith(`/${expected}`) || expected.endsWith(`/${actual}`);\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,eAAe,SAA0B;CAEvD,OADiB,QAAQ,MAAM,qBACjB,CAAC,CAAC,MAAK,QAAO;EAC1B,MAAM,UAAU,IAAI,KAAK;EACzB,IAAI,CAAC,uCAAuC,KAAK,OAAO,GAAG,OAAO;EAGlE,MAAM,cAAc,QAAQ,QAAQ,oDAAoD,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM;EAC9G,OAAO,CAAC,oCAAoC,KAAK,WAAW;CAC9D,CAAC;AACH;;;;AAKA,SAAgB,cAAc,SAA0B;CACtD,OAAO,2CAA2C,KAAK,OAAO;AAChE;;;;;AAMA,SAAgB,YAAY,QAAgC;CAC1D,IAAI,UAAU,MAAM,OAAO;CAE3B,IAAI,OAAO,WAAW,UAAU;EAC9B,MAAM,YAAY,OAAO,MAAM,oEAAoE;EACnG,IAAI,WAAW,OAAO,SAAS,UAAU,IAAK,EAAE;EAChD,OAAO;CACT;CAEA,IAAI,OAAO,WAAW,UAAU;EAC9B,MAAM,MAAM;EACZ,IAAI,cAAc,OAAO,OAAO,IAAI,aAAa,UAAU,OAAO,IAAI;EACtE,IAAI,UAAU,OAAO,OAAO,IAAI,SAAS,UAAU,OAAO,IAAI;CAChE;CAEA,OAAO;AACT;;;;;AAMA,SAAgB,gBAAgB,QAAiB,OAA0B;CACzE,IAAI,SAAS,CAAC,QAAQ,OAAO;CAE7B,MAAM,WAAW,YAAY,MAAM;CACnC,IAAI,aAAa,MAAM,OAAO,aAAa;CAG3C,OAAO,OAAO,WAAW;AAC3B;;;;;AAMA,SAAgB,cAAc,QAAgB,UAA2B;CACvE,IAAI,WAAW,UAAU,OAAO;CAChC,OAAO,OAAO,SAAS,IAAI,UAAU,KAAK,SAAS,SAAS,IAAI,QAAQ;AAC1E"}
@@ -1,6 +1,6 @@
1
1
  import { extractToolCalls } from "./extract-tools.js";
2
2
  import { createScorer, filterRun } from "@mastra/core/evals";
3
- //#region src/evals/scorers/efficiency.ts
3
+ // src/evals/scorers/efficiency.ts
4
4
  /**
5
5
  * Dimension weights (must sum to 1.0).
6
6
  *
@@ -253,7 +253,6 @@ function createEfficiencyScorer() {
253
253
  return parts.join("\n");
254
254
  });
255
255
  }
256
- //#endregion
257
256
  export { createEfficiencyScorer };
258
257
 
259
258
  //# sourceMappingURL=efficiency.js.map
@@ -1,4 +1,4 @@
1
- //#region src/evals/scorers/extract-tools.ts
1
+ // src/evals/scorers/extract-tools.ts
2
2
  function isToolInvocationPart(part) {
3
3
  return "type" in part && part.type === "tool-invocation" && "toolInvocation" in part;
4
4
  }
@@ -54,7 +54,6 @@ function extractToolCalls(messages) {
54
54
  }
55
55
  return results;
56
56
  }
57
- //#endregion
58
57
  export { extractToolCalls };
59
58
 
60
59
  //# sourceMappingURL=extract-tools.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../../../src/evals/scorers/outcome.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAsDH,KAAK,eAAe,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC;AAuN9E,wBAAgB,mBAAmB;;;;;;;;;;;;;;;;;;6FAkFlC"}
1
+ {"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../../../src/evals/scorers/outcome.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAsDH,KAAK,eAAe,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC;AAmO9E,wBAAgB,mBAAmB;;;;;;;;;;;;;;;;;;6FAkFlC"}