@mastra/code-sdk 1.15.1-alpha.4 → 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.
- package/dist/acp/agent.js +1 -2
- package/dist/acp/errors.js +1 -2
- package/dist/acp/event-mapper.js +1 -2
- package/dist/acp/index.js +1 -2
- package/dist/acp/runtime.js +1 -2
- package/dist/acp/server.js +1 -2
- package/dist/acp/skills.js +1 -2
- package/dist/agent-connections/messaging-processor.js +1 -2
- package/dist/agent-connections/ownership.js +1 -2
- package/dist/agent-connections/registry.js +1 -2
- package/dist/agent-connections/session-advertisement.js +1 -2
- package/dist/agent-connections/signal-provider.js +1 -2
- package/dist/agent-connections/state-processor.js +1 -2
- package/dist/agent-connections/thread-state.js +1 -2
- package/dist/agent-connections/tools.js +1 -2
- package/dist/agent-connections/types.js +1 -2
- package/dist/agent-connections/untrusted-text.js +1 -2
- package/dist/agents/background-completion-events.js +1 -2
- package/dist/agents/background-completion.js +1 -2
- package/dist/agents/context-audit.js +1 -2
- package/dist/agents/credential-resolver.js +1 -2
- package/dist/agents/custom-provider-source.js +1 -2
- package/dist/agents/instructions.js +1 -2
- package/dist/agents/mastracode-gateway.js +1 -2
- package/dist/agents/memory.js +1 -2
- package/dist/agents/model.js +1 -2
- package/dist/agents/modes/build.js +1 -2
- package/dist/agents/modes/explore.js +1 -2
- package/dist/agents/modes/plan.js +1 -2
- package/dist/agents/prompts/agent-instructions.js +1 -2
- package/dist/agents/prompts/build.js +1 -2
- package/dist/agents/prompts/fast.js +1 -2
- package/dist/agents/prompts/index.js +1 -2
- package/dist/agents/prompts/model.js +1 -2
- package/dist/agents/prompts/plan.js +1 -2
- package/dist/agents/prompts/tool-guidance.js +1 -2
- package/dist/agents/sandbox-filesystem.d.ts.map +1 -1
- package/dist/agents/sandbox-filesystem.js +9 -7
- package/dist/agents/sandbox-filesystem.js.map +1 -1
- package/dist/agents/subagents/execute.js +1 -2
- package/dist/agents/subagents/explore.js +1 -2
- package/dist/agents/subagents/plan.js +1 -2
- package/dist/agents/thread-caveman-state.js +1 -2
- package/dist/agents/tool-availability.js +1 -2
- package/dist/agents/tools.js +1 -2
- package/dist/agents/workflow-builder-agent.js +1 -2
- package/dist/agents/workspace.js +1 -2
- package/dist/analytics.js +1 -2
- package/dist/auth/account-rotation-processor.js +1 -2
- package/dist/auth/account-routing-context.js +1 -2
- package/dist/auth/authorization-input.js +1 -2
- package/dist/auth/device-code.js +1 -2
- package/dist/auth/pkce.js +1 -2
- package/dist/auth/provider-auth-error.d.ts +2 -0
- package/dist/auth/provider-auth-error.d.ts.map +1 -1
- package/dist/auth/provider-auth-error.js +8 -3
- package/dist/auth/provider-auth-error.js.map +1 -1
- package/dist/auth/providers/anthropic.js +1 -2
- package/dist/auth/providers/github-copilot.js +1 -2
- package/dist/auth/providers/kimi-coding.js +1 -2
- package/dist/auth/providers/openai-codex.js +1 -2
- package/dist/auth/providers/xai.js +1 -2
- package/dist/auth/storage.js +1 -2
- package/dist/clipboard/index.js +1 -2
- package/dist/constants.js +1 -2
- package/dist/error-classification.js +1 -2
- package/dist/evals/context-builder.js +1 -2
- package/dist/evals/scorers/classify-command.d.ts +1 -2
- package/dist/evals/scorers/classify-command.d.ts.map +1 -1
- package/dist/evals/scorers/classify-command.js +7 -17
- package/dist/evals/scorers/classify-command.js.map +1 -1
- package/dist/evals/scorers/efficiency.js +1 -2
- package/dist/evals/scorers/extract-tools.js +1 -2
- package/dist/evals/scorers/outcome.d.ts.map +1 -1
- package/dist/evals/scorers/outcome.js +36 -22
- package/dist/evals/scorers/outcome.js.map +1 -1
- package/dist/experimental-agent.js +1 -2
- package/dist/factory/client.js +1 -2
- package/dist/factory/remote-controller.js +1 -2
- package/dist/factory/remote-session.js +1 -2
- package/dist/goal-manager.js +1 -2
- package/dist/goal-signal.js +1 -2
- package/dist/headless/cli.js +1 -2
- package/dist/headless/flags.js +1 -2
- package/dist/headless/format.js +1 -2
- package/dist/headless/policy.js +1 -2
- package/dist/headless/run-mc.js +1 -2
- package/dist/headless/types.js +1 -2
- package/dist/hooks/config.js +1 -2
- package/dist/hooks/executor.js +1 -2
- package/dist/hooks/manager.js +1 -2
- package/dist/hooks/types.js +1 -2
- package/dist/index.js +1 -2
- package/dist/ipc/ipc-reporter.js +1 -2
- package/dist/knowledge-inspector.js +1 -2
- package/dist/knowledge-scope.js +1 -2
- package/dist/lsp/client.d.ts.map +1 -1
- package/dist/lsp/client.js +1 -2
- package/dist/lsp/client.js.map +1 -1
- package/dist/lsp/language.js +1 -2
- package/dist/lsp/manager.js +1 -2
- package/dist/lsp/server.js +1 -2
- package/dist/lsp/workspace.js +1 -2
- package/dist/mcp/config.js +1 -2
- package/dist/mcp/manager.js +1 -2
- package/dist/mcp/state.js +1 -2
- package/dist/onboarding/custom-packs.js +1 -2
- package/dist/onboarding/custom-providers.js +1 -2
- package/dist/onboarding/om-settings.js +1 -2
- package/dist/onboarding/pack-activation.js +1 -2
- package/dist/onboarding/packs.js +1 -2
- package/dist/onboarding/settings.js +1 -2
- package/dist/permissions.js +1 -2
- package/dist/platform/index.js +1 -2
- package/dist/plugin.js +1 -2
- package/dist/plugins/dependencies.js +1 -2
- package/dist/plugins/install.js +1 -2
- package/dist/plugins/loader.js +1 -2
- package/dist/plugins/manager.js +1 -2
- package/dist/plugins/manifest.js +1 -2
- package/dist/plugins/package-link.js +1 -2
- package/dist/plugins/paths.js +1 -2
- package/dist/plugins/registry.js +1 -2
- package/dist/plugins/scaffold.js +1 -2
- package/dist/plugins/signal-lane.js +1 -2
- package/dist/process-memory-diagnostics.js +1 -2
- package/dist/processors/plan-rejection-abort.js +1 -2
- package/dist/providers/amazon-bedrock-gateway.js +1 -2
- package/dist/providers/amazon-bedrock.js +1 -2
- package/dist/providers/anthropic-prompt-cache.js +1 -2
- package/dist/providers/anthropic-thinking.js +1 -2
- package/dist/providers/claude-max.d.ts.map +1 -1
- package/dist/providers/claude-max.js +4 -4
- package/dist/providers/claude-max.js.map +1 -1
- package/dist/providers/github-copilot-gateway.js +1 -2
- package/dist/providers/github-copilot.d.ts.map +1 -1
- package/dist/providers/github-copilot.js +5 -5
- package/dist/providers/github-copilot.js.map +1 -1
- package/dist/providers/google-thinking.js +1 -2
- package/dist/providers/kimi-coding.d.ts.map +1 -1
- package/dist/providers/kimi-coding.js +8 -7
- package/dist/providers/kimi-coding.js.map +1 -1
- package/dist/providers/model-ids.js +1 -2
- package/dist/providers/openai-codex.d.ts.map +1 -1
- package/dist/providers/openai-codex.js +7 -7
- package/dist/providers/openai-codex.js.map +1 -1
- package/dist/providers/provider-thinking.js +1 -2
- package/dist/providers/thinking-request.js +1 -2
- package/dist/providers/xai.d.ts.map +1 -1
- package/dist/providers/xai.js +5 -5
- package/dist/providers/xai.js.map +1 -1
- package/dist/schedules/interval.js +1 -2
- package/dist/schedules/prompt.js +1 -2
- package/dist/schedules/run-script.js +1 -2
- package/dist/schedules/scheduler.js +1 -2
- package/dist/schedules/tools.js +1 -2
- package/dist/schema.js +1 -2
- package/dist/theme-palette.js +1 -2
- package/dist/thinking-catalog.js +1 -2
- package/dist/thinking.js +1 -2
- package/dist/tool-names.js +1 -2
- package/dist/tools/request-sandbox-access.js +1 -2
- package/dist/tools/utils.js +1 -2
- package/dist/tools/web-search.js +1 -2
- package/dist/tools/workflows/create-workflow.js +1 -2
- package/dist/tools/workflows/delete-workflow.js +1 -2
- package/dist/tools/workflows/ephemeral-memory.js +1 -2
- package/dist/tools/workflows/extract-json-schema.js +1 -2
- package/dist/tools/workflows/get-workflow.js +1 -2
- package/dist/tools/workflows/list-available-agents.js +1 -2
- package/dist/tools/workflows/list-available-classifiers.js +1 -2
- package/dist/tools/workflows/list-available-tools.js +1 -2
- package/dist/tools/workflows/list-available-workflows.js +1 -2
- package/dist/tools/workflows/list-workflows.js +1 -2
- package/dist/tools/workflows/run-workflow.js +1 -2
- package/dist/tools/workflows/save-workflow.js +1 -2
- package/dist/tools/workflows/tool-ids.js +1 -2
- package/dist/utils/binaries.js +1 -2
- package/dist/utils/debug-log.js +1 -2
- package/dist/utils/discarding-scores-storage.js +1 -2
- package/dist/utils/errors.js +1 -2
- package/dist/utils/gateway-sync.js +1 -2
- package/dist/utils/local-observability.js +1 -2
- package/dist/utils/maintenance-lock.js +1 -2
- package/dist/utils/notification-dispatch.js +1 -2
- package/dist/utils/open-url.js +1 -2
- package/dist/utils/path-security.js +1 -2
- package/dist/utils/plan-diff.js +1 -2
- package/dist/utils/plans.js +1 -2
- package/dist/utils/project.js +1 -2
- package/dist/utils/prune-cli.js +1 -2
- package/dist/utils/signals-pubsub.js +1 -2
- package/dist/utils/slash-command-loader.js +1 -2
- package/dist/utils/slash-command-processor.js +1 -2
- package/dist/utils/stdin-pipe.js +1 -2
- package/dist/utils/storage-factory.js +1 -2
- package/dist/utils/storage-maintenance.js +1 -2
- package/dist/utils/thread-lock.js +1 -2
- package/dist/utils/token-estimator.js +1 -2
- package/dist/utils/update-check.js +1 -2
- package/dist/utils/wake-session.js +1 -2
- package/dist/voice/stt-registry.js +1 -2
- package/dist/workflows/register-primitives.js +1 -2
- package/dist/workflows/service.js +1 -2
- package/package.json +36 -32
package/dist/auth/pkce.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
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;
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
package/dist/auth/storage.js
CHANGED
|
@@ -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
|
-
|
|
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
|
package/dist/clipboard/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
1
|
+
// src/evals/scorers/classify-command.ts
|
|
2
2
|
/**
|
|
3
3
|
* Shared command classification utilities for scoring.
|
|
4
4
|
*
|
|
5
|
-
* Used by
|
|
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(/
|
|
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
|
-
|
|
51
|
-
if (
|
|
52
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getExitCode, isBuildCommand, isTestCommand } from "./classify-command.js";
|
|
1
|
+
import { getExitCode, isBuildCommand, isSuccessResult, isTestCommand } from "./classify-command.js";
|
|
2
2
|
import { extractToolCalls } from "./extract-tools.js";
|
|
3
3
|
import { createScorer, filterRun } from "@mastra/core/evals";
|
|
4
|
-
|
|
4
|
+
// src/evals/scorers/outcome.ts
|
|
5
5
|
/**
|
|
6
6
|
* Dimension weights. Used to compute the weighted average of applicable dimensions.
|
|
7
7
|
* Dimensions that don't apply (e.g. no build ran) are excluded from the average.
|
|
@@ -48,11 +48,14 @@ function isBuildArgs(args) {
|
|
|
48
48
|
function isTestArgs(args) {
|
|
49
49
|
return isTestCommand(String(args.command ?? ""));
|
|
50
50
|
}
|
|
51
|
+
function isForegroundCommand(result) {
|
|
52
|
+
return result.args.background !== true;
|
|
53
|
+
}
|
|
51
54
|
/**
|
|
52
55
|
* Score build/typecheck outcome (final state).
|
|
53
56
|
*/
|
|
54
57
|
function scoreBuild(execResults) {
|
|
55
|
-
const builds = execResults.filter((r) => r.toolName === "execute_command" && isBuildArgs(r.args));
|
|
58
|
+
const builds = execResults.filter((r) => r.toolName === "execute_command" && isForegroundCommand(r) && isBuildArgs(r.args));
|
|
56
59
|
if (builds.length === 0) return {
|
|
57
60
|
score: 0,
|
|
58
61
|
detail: "No build/typecheck ran",
|
|
@@ -65,22 +68,27 @@ function scoreBuild(execResults) {
|
|
|
65
68
|
applicable: true
|
|
66
69
|
};
|
|
67
70
|
const exitCode = getExitCode(last.result);
|
|
68
|
-
if (exitCode === 0) return {
|
|
69
|
-
score: 1,
|
|
70
|
-
detail: "Build/typecheck passed",
|
|
71
|
-
applicable: true
|
|
72
|
-
};
|
|
73
71
|
if (exitCode !== null && exitCode !== 0) return {
|
|
74
72
|
score: 0,
|
|
75
73
|
detail: `Build failed (exit ${exitCode})`,
|
|
76
74
|
applicable: true
|
|
77
75
|
};
|
|
78
|
-
|
|
76
|
+
if (typeof last.result === "string") return {
|
|
77
|
+
score: 1,
|
|
78
|
+
detail: "Build/typecheck passed",
|
|
79
|
+
applicable: true
|
|
80
|
+
};
|
|
81
|
+
const text = JSON.stringify(last.result ?? "");
|
|
79
82
|
if (/error TS\d+|Cannot find module|is not assignable/i.test(text)) return {
|
|
80
83
|
score: 0,
|
|
81
84
|
detail: "Build failed (TypeScript errors in output)",
|
|
82
85
|
applicable: true
|
|
83
86
|
};
|
|
87
|
+
if (isSuccessResult(last.result)) return {
|
|
88
|
+
score: 1,
|
|
89
|
+
detail: "Build/typecheck passed",
|
|
90
|
+
applicable: true
|
|
91
|
+
};
|
|
84
92
|
return {
|
|
85
93
|
score: THRESHOLDS.ambiguousExitScore,
|
|
86
94
|
detail: "Build ran, outcome unclear",
|
|
@@ -91,7 +99,7 @@ function scoreBuild(execResults) {
|
|
|
91
99
|
* Score test outcome (final state).
|
|
92
100
|
*/
|
|
93
101
|
function scoreTests(execResults) {
|
|
94
|
-
const tests = execResults.filter((r) => r.toolName === "execute_command" && isTestArgs(r.args));
|
|
102
|
+
const tests = execResults.filter((r) => r.toolName === "execute_command" && isForegroundCommand(r) && isTestArgs(r.args));
|
|
95
103
|
if (tests.length === 0) return {
|
|
96
104
|
score: 0,
|
|
97
105
|
detail: "No tests ran",
|
|
@@ -104,25 +112,30 @@ function scoreTests(execResults) {
|
|
|
104
112
|
applicable: true
|
|
105
113
|
};
|
|
106
114
|
const exitCode = getExitCode(last.result);
|
|
107
|
-
if (exitCode
|
|
115
|
+
if (exitCode !== null && exitCode !== 0) return {
|
|
116
|
+
score: 0,
|
|
117
|
+
detail: `Tests failed (exit ${exitCode})`,
|
|
118
|
+
applicable: true
|
|
119
|
+
};
|
|
120
|
+
if (typeof last.result === "string") return {
|
|
108
121
|
score: 1,
|
|
109
122
|
detail: "Tests passed",
|
|
110
123
|
applicable: true
|
|
111
124
|
};
|
|
112
|
-
|
|
125
|
+
const text = JSON.stringify(last.result ?? "");
|
|
126
|
+
if (/\bFAIL\b|failed|✗|✘/i.test(text)) return {
|
|
113
127
|
score: 0,
|
|
114
|
-
detail:
|
|
128
|
+
detail: "Tests failed (inferred)",
|
|
115
129
|
applicable: true
|
|
116
130
|
};
|
|
117
|
-
const text = typeof last.result === "string" ? last.result : JSON.stringify(last.result ?? "");
|
|
118
131
|
if (/\d+ (?:tests? )?passed|✓|PASS/i.test(text) && !/\bfail(?:ed|ure)?\b|\berror\b/i.test(text)) return {
|
|
119
132
|
score: 1,
|
|
120
133
|
detail: "Tests passed (inferred)",
|
|
121
134
|
applicable: true
|
|
122
135
|
};
|
|
123
|
-
if (
|
|
124
|
-
score:
|
|
125
|
-
detail: "Tests
|
|
136
|
+
if (isSuccessResult(last.result)) return {
|
|
137
|
+
score: 1,
|
|
138
|
+
detail: "Tests passed",
|
|
126
139
|
applicable: true
|
|
127
140
|
};
|
|
128
141
|
return {
|
|
@@ -207,13 +220,15 @@ function scoreStuckLoops(results) {
|
|
|
207
220
|
function scoreRegression(execResults) {
|
|
208
221
|
const regressions = [];
|
|
209
222
|
for (const [label, filter] of [["Build", isBuildArgs], ["Tests", isTestArgs]]) {
|
|
210
|
-
const cmds = execResults.filter((r) => r.toolName === "execute_command" && filter(r.args));
|
|
223
|
+
const cmds = execResults.filter((r) => r.toolName === "execute_command" && isForegroundCommand(r) && filter(r.args));
|
|
211
224
|
if (cmds.length < 2) continue;
|
|
212
225
|
let sawPass = false;
|
|
213
226
|
let sawRegression = false;
|
|
214
227
|
for (const cmd of cmds) {
|
|
215
|
-
const
|
|
216
|
-
|
|
228
|
+
const exitCode = getExitCode(cmd.result);
|
|
229
|
+
const passed = isSuccessResult(cmd.result, cmd.isError);
|
|
230
|
+
const failed = cmd.isError || exitCode !== null && exitCode !== 0;
|
|
231
|
+
if (passed) {
|
|
217
232
|
if (sawRegression) {
|
|
218
233
|
regressions.push({
|
|
219
234
|
label,
|
|
@@ -223,7 +238,7 @@ function scoreRegression(execResults) {
|
|
|
223
238
|
}
|
|
224
239
|
sawPass = true;
|
|
225
240
|
}
|
|
226
|
-
if (sawPass &&
|
|
241
|
+
if (sawPass && failed) sawRegression = true;
|
|
227
242
|
}
|
|
228
243
|
if (sawRegression) regressions.push({
|
|
229
244
|
label,
|
|
@@ -342,7 +357,6 @@ function createOutcomeScorer() {
|
|
|
342
357
|
return parts.join("\n");
|
|
343
358
|
});
|
|
344
359
|
}
|
|
345
|
-
//#endregion
|
|
346
360
|
export { createOutcomeScorer };
|
|
347
361
|
|
|
348
362
|
//# sourceMappingURL=outcome.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.js","names":[],"sources":["../../../src/evals/scorers/outcome.ts"],"sourcesContent":["/**\n * MastraCode Outcome Scorer (Code-based, Agent type, always-on)\n *\n * Grades the objective outcome of a coding session by checking hard facts:\n * - Did the build/typecheck pass?\n * - Did tests pass?\n * - What was the tool error rate?\n * - Did the agent get stuck in a loop?\n * - Was there a regression (build passed earlier, failed later)?\n * - Did the agent use ask_user unnecessarily? (autonomy)\n *\n * This scorer is always-on (no sampling) because it's cheap — it only\n * reads exit codes and error states from tool results already in the messages.\n *\n * Scoring philosophy (from Anthropic's eval guidance):\n * \"Grade outcomes, not paths\" — we check what happened, not how.\n * Partial credit: a session that passes build but fails tests scores\n * higher than one that fails build entirely.\n *\n * Dimensions that don't apply to a session (e.g. build for a docs-only task)\n * are excluded from the weighted average, so sessions aren't penalized for\n * irrelevant criteria.\n */\n\nimport type { MastraDBMessage } from '@mastra/core/agent';\nimport { createScorer, filterRun } from '@mastra/core/evals';\n\nimport { isBuildCommand, isTestCommand, getExitCode } from './classify-command.js';\nimport type { ExtractedToolCall } from './extract-tools.js';\nimport { extractToolCalls } from './extract-tools.js';\n\n// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n// CONFIGURATION — Adjust weights and thresholds here\n// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n/**\n * Dimension weights. Used to compute the weighted average of applicable dimensions.\n * Dimensions that don't apply (e.g. no build ran) are excluded from the average.\n */\nconst WEIGHTS = {\n build: 0.3,\n tests: 0.25,\n toolErrors: 0.2,\n loops: 0.1,\n regression: 0.1,\n autonomy: 0.05,\n} as const;\n\n/**\n * Scoring thresholds and multipliers.\n */\nconst THRESHOLDS = {\n /** Multiplier for tool error rate penalty. Score = max(0, 1 - rate × this). */\n toolErrorPenaltyMultiplier: 1.0,\n\n /** How many consecutive identical calls (or same-error repeats) before it's a \"loop\". */\n loopMinRepetitions: 3,\n\n /** Score penalty per detected loop. */\n loopPenaltyPerOccurrence: 0.3,\n\n /** Score deducted per ask_user call. */\n autonomyPenaltyPerAsk: 0.25,\n\n /** Score when a command ran but exit code is ambiguous. */\n ambiguousExitScore: 0.75,\n\n /** Minimum tool calls required to produce a meaningful score. */\n minToolCalls: 1,\n\n /** Tool names whose errors are expected/benign (not penalized). */\n benignErrorTools: ['search_content', 'find_files', 'lsp_inspect'] as string[],\n} as const;\n\n// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\ntype DimensionResult = { score: number; detail: string; applicable: boolean };\n\n/**\n * Check if the primary verb of an execute_command is a build/typecheck command.\n * Splits compound commands (&&, ;) and checks the first segment.\n */\n/** Extract command string from tool call args, then delegate to shared classifier. */\nfunction isBuildArgs(args: Record<string, unknown>): boolean {\n return isBuildCommand(String(args.command ?? ''));\n}\n\nfunction isTestArgs(args: Record<string, unknown>): boolean {\n return isTestCommand(String(args.command ?? ''));\n}\n\n/**\n * Score build/typecheck outcome (final state).\n */\nfunction scoreBuild(execResults: ExtractedToolCall[]): DimensionResult {\n const builds = execResults.filter(r => r.toolName === 'execute_command' && isBuildArgs(r.args));\n if (builds.length === 0) return { score: 0, detail: 'No build/typecheck ran', applicable: false };\n\n const last = builds[builds.length - 1]!;\n if (last.isError) return { score: 0, detail: 'Build/typecheck tool errored', applicable: true };\n\n const exitCode = getExitCode(last.result);\n if (exitCode === 0) return { score: 1, detail: 'Build/typecheck passed', applicable: true };\n if (exitCode !== null && exitCode !== 0)\n return { score: 0, detail: `Build failed (exit ${exitCode})`, applicable: true };\n\n // Fallback: check result text for TS errors\n const text = typeof last.result === 'string' ? last.result : JSON.stringify(last.result ?? '');\n if (/error TS\\d+|Cannot find module|is not assignable/i.test(text)) {\n return { score: 0, detail: 'Build failed (TypeScript errors in output)', applicable: true };\n }\n\n return { score: THRESHOLDS.ambiguousExitScore, detail: 'Build ran, outcome unclear', applicable: true };\n}\n\n/**\n * Score test outcome (final state).\n */\nfunction scoreTests(execResults: ExtractedToolCall[]): DimensionResult {\n const tests = execResults.filter(r => r.toolName === 'execute_command' && isTestArgs(r.args));\n if (tests.length === 0) return { score: 0, detail: 'No tests ran', applicable: false };\n\n const last = tests[tests.length - 1]!;\n if (last.isError) return { score: 0, detail: 'Test command errored', applicable: true };\n\n const exitCode = getExitCode(last.result);\n if (exitCode === 0) return { score: 1, detail: 'Tests passed', applicable: true };\n if (exitCode !== null && exitCode !== 0)\n return { score: 0, detail: `Tests failed (exit ${exitCode})`, applicable: true };\n\n const text = typeof last.result === 'string' ? last.result : JSON.stringify(last.result ?? '');\n if (/\\d+ (?:tests? )?passed|✓|PASS/i.test(text) && !/\\bfail(?:ed|ure)?\\b|\\berror\\b/i.test(text)) {\n return { score: 1, detail: 'Tests passed (inferred)', applicable: true };\n }\n if (/\\bFAIL\\b|failed|✗|✘/i.test(text)) {\n return { score: 0, detail: 'Tests failed (inferred)', applicable: true };\n }\n\n return { score: THRESHOLDS.ambiguousExitScore, detail: 'Tests ran, outcome unclear', applicable: true };\n}\n\n/**\n * Score tool error rate, excluding benign errors from expected-to-fail tools.\n */\nfunction scoreToolErrors(results: ExtractedToolCall[]): DimensionResult {\n if (results.length === 0) return { score: 1, detail: 'No tool calls', applicable: false };\n\n // Only count errors from non-benign tools\n const nonBenign = results.filter(r => !THRESHOLDS.benignErrorTools.includes(r.toolName));\n if (nonBenign.length === 0) return { score: 1, detail: 'All tool calls are benign-error tools', applicable: true };\n\n const errors = nonBenign.filter(r => r.isError);\n const rate = errors.length / nonBenign.length;\n\n if (rate === 0) return { score: 1, detail: 'No tool errors', applicable: true };\n\n const score = Math.max(0, 1 - rate * THRESHOLDS.toolErrorPenaltyMultiplier);\n return {\n score,\n detail: `${errors.length}/${nonBenign.length} tools errored (${(rate * 100).toFixed(0)}%)`,\n applicable: true,\n };\n}\n\n/**\n * Detect stuck loops: same tool + same args appearing 3+ times consecutively,\n * or same tool + same args erroring 3+ times total.\n */\nfunction scoreStuckLoops(results: ExtractedToolCall[]): DimensionResult {\n if (results.length < 3) return { score: 1, detail: 'Too few calls for loop detection', applicable: true };\n\n const fingerprint = (r: ExtractedToolCall) => `${r.toolName}:${JSON.stringify(r.args)}`;\n\n // Check consecutive identical calls\n let maxConsecutive = 1;\n let currentRun = 1;\n for (let i = 1; i < results.length; i++) {\n if (fingerprint(results[i]!) === fingerprint(results[i - 1]!)) {\n currentRun++;\n maxConsecutive = Math.max(maxConsecutive, currentRun);\n } else {\n currentRun = 1;\n }\n }\n\n // Check repeated error fingerprints\n const errorCounts = new Map<string, number>();\n for (const r of results) {\n if (!r.isError) continue;\n const fp = fingerprint(r);\n errorCounts.set(fp, (errorCounts.get(fp) ?? 0) + 1);\n }\n const maxErrorRepeat = Math.max(0, ...[...errorCounts.values()]);\n\n const minReps = THRESHOLDS.loopMinRepetitions;\n const loopSeverity = Math.max(\n maxConsecutive >= minReps ? maxConsecutive - (minReps - 1) : 0,\n maxErrorRepeat >= minReps ? maxErrorRepeat - (minReps - 1) : 0,\n );\n\n if (loopSeverity === 0) return { score: 1, detail: 'No stuck loops', applicable: true };\n\n const score = Math.max(0, 1 - loopSeverity * THRESHOLDS.loopPenaltyPerOccurrence);\n const details: string[] = [];\n if (maxConsecutive >= minReps) details.push(`${maxConsecutive} consecutive identical calls`);\n if (maxErrorRepeat >= minReps) details.push(`same error repeated ${maxErrorRepeat}x`);\n return { score, detail: details.join('; '), applicable: true };\n}\n\n/**\n * Detect regressions: build/test passed at some point, then failed later.\n * Gives partial credit if the agent recovered (final state passes).\n */\nfunction scoreRegression(execResults: ExtractedToolCall[]): DimensionResult {\n const regressions: { label: string; recovered: boolean }[] = [];\n\n for (const [label, filter] of [\n ['Build', isBuildArgs],\n ['Tests', isTestArgs],\n ] as const) {\n const cmds = execResults.filter(r => r.toolName === 'execute_command' && filter(r.args));\n if (cmds.length < 2) continue;\n\n let sawPass = false;\n let sawRegression = false;\n for (const cmd of cmds) {\n const exit = getExitCode(cmd.result);\n if (exit === 0) {\n if (sawRegression) {\n // Recovered from regression\n regressions.push({ label, recovered: true });\n sawRegression = false;\n }\n sawPass = true;\n }\n if (sawPass && exit !== null && exit !== 0) {\n sawRegression = true;\n }\n }\n\n if (sawRegression) {\n // Regression persisted at end of session\n regressions.push({ label, recovered: false });\n }\n }\n\n if (regressions.length === 0) return { score: 1, detail: 'No regressions', applicable: true };\n\n // Persistent regressions are severe (0), recovered regressions get partial credit (0.5)\n const persistentCount = regressions.filter(r => !r.recovered).length;\n const recoveredCount = regressions.filter(r => r.recovered).length;\n const score = Math.max(0, 1 - persistentCount * 0.5 - recoveredCount * 0.1);\n const details = regressions.map(\n r => `${r.label} ${r.recovered ? 'regressed then recovered' : 'regressed (persisted)'}`,\n );\n return { score, detail: details.join('; '), applicable: true };\n}\n\n/**\n * Score autonomy: penalize ask_user calls.\n * 0 calls = 1.0, each call reduces by 0.25 (up to a floor of 0).\n */\nfunction scoreAutonomy(results: ExtractedToolCall[]): DimensionResult {\n const askUserCalls = results.filter(r => r.toolName === 'ask_user');\n const count = askUserCalls.length;\n\n if (count === 0) return { score: 1, detail: 'No ask_user calls (fully autonomous)', applicable: true };\n\n const score = Math.max(0, 1 - count * THRESHOLDS.autonomyPenaltyPerAsk);\n return { score, detail: `${count} ask_user call${count > 1 ? 's' : ''}`, applicable: true };\n}\n\n/**\n * Compute weighted average of only applicable dimensions.\n * Returns null if no dimensions are applicable.\n */\nfunction weightedAverage(dimensions: Record<string, DimensionResult>, weights: Record<string, number>): number | null {\n let totalWeight = 0;\n let weightedSum = 0;\n\n for (const [key, result] of Object.entries(dimensions)) {\n if (!result.applicable) continue;\n const weight = weights[key] ?? 0;\n totalWeight += weight;\n weightedSum += result.score * weight;\n }\n\n if (totalWeight === 0) return null;\n return weightedSum / totalWeight;\n}\n\nexport function createOutcomeScorer() {\n return createScorer({\n id: 'mastracode-outcome',\n name: 'MastraCode Outcome',\n description:\n 'Grades coding session outcomes: build/test pass, tool errors, stuck loops, regressions, autonomy. Always-on.',\n type: 'agent',\n prepareRun: filterRun({ partTypes: ['tool-invocation', 'text'] }),\n })\n .preprocess(async ({ run }) => {\n const messages = (run.output ?? []) as MastraDBMessage[];\n const allResults = extractToolCalls(messages);\n const totalCalls = allResults.length;\n\n // H1: Empty sessions or sessions with no tool calls → score 0\n if (totalCalls < THRESHOLDS.minToolCalls) {\n const empty: DimensionResult = { score: 0, detail: 'No tool calls', applicable: false };\n return {\n empty: true as const,\n build: empty,\n tests: empty,\n toolErrors: empty,\n loops: empty,\n regression: empty,\n autonomy: empty,\n totalCalls,\n };\n }\n\n const execResults = allResults.filter(r => r.toolName === 'execute_command');\n\n return {\n empty: false as const,\n build: scoreBuild(execResults),\n tests: scoreTests(execResults),\n toolErrors: scoreToolErrors(allResults),\n loops: scoreStuckLoops(allResults),\n regression: scoreRegression(execResults),\n autonomy: scoreAutonomy(allResults),\n totalCalls,\n };\n })\n .generateScore(({ results }) => {\n const p = results.preprocessStepResult;\n if (p.empty) return 0;\n\n const score = weightedAverage(\n {\n build: p.build,\n tests: p.tests,\n toolErrors: p.toolErrors,\n loops: p.loops,\n regression: p.regression,\n autonomy: p.autonomy,\n },\n WEIGHTS,\n );\n\n return score === null ? 0 : Math.round(score * 100) / 100;\n })\n .generateReason(({ results, score }) => {\n const p = results.preprocessStepResult;\n if (p.empty) {\n return `Score: 0 (${p.totalCalls} tool calls — below minimum threshold for scoring)`;\n }\n\n const pct = (w: number) => `${(w * 100).toFixed(0)}%`;\n const dimLine = (name: string, weight: number, r: DimensionResult) =>\n r.applicable\n ? `${name} (${pct(weight)}): ${r.detail} [${r.score}]`\n : `${name}: ${r.detail} [N/A — excluded from average]`;\n\n const parts: string[] = [`Score: ${score} (${p.totalCalls} tool calls total)`];\n parts.push(dimLine('Build', WEIGHTS.build, p.build));\n parts.push(dimLine('Tests', WEIGHTS.tests, p.tests));\n parts.push(dimLine('Tool errors', WEIGHTS.toolErrors, p.toolErrors));\n parts.push(dimLine('Loops', WEIGHTS.loops, p.loops));\n parts.push(dimLine('Regression', WEIGHTS.regression, p.regression));\n parts.push(dimLine('Autonomy', WEIGHTS.autonomy, p.autonomy));\n\n return parts.join('\\n');\n });\n}\n"],"mappings":";;;;;;;;AAuCA,MAAM,UAAU;CACd,OAAO;CACP,OAAO;CACP,YAAY;CACZ,OAAO;CACP,YAAY;CACZ,UAAU;AACZ;;;;AAKA,MAAM,aAAa;;CAEjB,4BAA4B;;CAG5B,oBAAoB;;CAGpB,0BAA0B;;CAG1B,uBAAuB;;CAGvB,oBAAoB;;CAGpB,cAAc;;CAGd,kBAAkB;EAAC;EAAkB;EAAc;CAAa;AAClE;;;;;;AAWA,SAAS,YAAY,MAAwC;CAC3D,OAAO,eAAe,OAAO,KAAK,WAAW,EAAE,CAAC;AAClD;AAEA,SAAS,WAAW,MAAwC;CAC1D,OAAO,cAAc,OAAO,KAAK,WAAW,EAAE,CAAC;AACjD;;;;AAKA,SAAS,WAAW,aAAmD;CACrE,MAAM,SAAS,YAAY,QAAO,MAAK,EAAE,aAAa,qBAAqB,YAAY,EAAE,IAAI,CAAC;CAC9F,IAAI,OAAO,WAAW,GAAG,OAAO;EAAE,OAAO;EAAG,QAAQ;EAA0B,YAAY;CAAM;CAEhG,MAAM,OAAO,OAAO,OAAO,SAAS;CACpC,IAAI,KAAK,SAAS,OAAO;EAAE,OAAO;EAAG,QAAQ;EAAgC,YAAY;CAAK;CAE9F,MAAM,WAAW,YAAY,KAAK,MAAM;CACxC,IAAI,aAAa,GAAG,OAAO;EAAE,OAAO;EAAG,QAAQ;EAA0B,YAAY;CAAK;CAC1F,IAAI,aAAa,QAAQ,aAAa,GACpC,OAAO;EAAE,OAAO;EAAG,QAAQ,sBAAsB,SAAS;EAAI,YAAY;CAAK;CAGjF,MAAM,OAAO,O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,KAAK,CAAC;EACnD,MAAM,KAAK,QAAQ,eAAe,QAAQ,YAAY,EAAE,UAAU,CAAC;EACnE,MAAM,KAAK,QAAQ,SAAS,QAAQ,OAAO,EAAE,KAAK,CAAC;EACnD,MAAM,KAAK,QAAQ,cAAc,QAAQ,YAAY,EAAE,UAAU,CAAC;EAClE,MAAM,KAAK,QAAQ,YAAY,QAAQ,UAAU,EAAE,QAAQ,CAAC;EAE5D,OAAO,MAAM,KAAK,IAAI;CACxB,CAAC;AACL"}
|
|
1
|
+
{"version":3,"file":"outcome.js","names":[],"sources":["../../../src/evals/scorers/outcome.ts"],"sourcesContent":["/**\n * MastraCode Outcome Scorer (Code-based, Agent type, always-on)\n *\n * Grades the objective outcome of a coding session by checking hard facts:\n * - Did the build/typecheck pass?\n * - Did tests pass?\n * - What was the tool error rate?\n * - Did the agent get stuck in a loop?\n * - Was there a regression (build passed earlier, failed later)?\n * - Did the agent use ask_user unnecessarily? (autonomy)\n *\n * This scorer is always-on (no sampling) because it's cheap — it only\n * reads exit codes and error states from tool results already in the messages.\n *\n * Scoring philosophy (from Anthropic's eval guidance):\n * \"Grade outcomes, not paths\" — we check what happened, not how.\n * Partial credit: a session that passes build but fails tests scores\n * higher than one that fails build entirely.\n *\n * Dimensions that don't apply to a session (e.g. build for a docs-only task)\n * are excluded from the weighted average, so sessions aren't penalized for\n * irrelevant criteria.\n */\n\nimport type { MastraDBMessage } from '@mastra/core/agent';\nimport { createScorer, filterRun } from '@mastra/core/evals';\n\nimport { isBuildCommand, isTestCommand, getExitCode, isSuccessResult } from './classify-command.js';\nimport type { ExtractedToolCall } from './extract-tools.js';\nimport { extractToolCalls } from './extract-tools.js';\n\n// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n// CONFIGURATION — Adjust weights and thresholds here\n// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n/**\n * Dimension weights. Used to compute the weighted average of applicable dimensions.\n * Dimensions that don't apply (e.g. no build ran) are excluded from the average.\n */\nconst WEIGHTS = {\n build: 0.3,\n tests: 0.25,\n toolErrors: 0.2,\n loops: 0.1,\n regression: 0.1,\n autonomy: 0.05,\n} as const;\n\n/**\n * Scoring thresholds and multipliers.\n */\nconst THRESHOLDS = {\n /** Multiplier for tool error rate penalty. Score = max(0, 1 - rate × this). */\n toolErrorPenaltyMultiplier: 1.0,\n\n /** How many consecutive identical calls (or same-error repeats) before it's a \"loop\". */\n loopMinRepetitions: 3,\n\n /** Score penalty per detected loop. */\n loopPenaltyPerOccurrence: 0.3,\n\n /** Score deducted per ask_user call. */\n autonomyPenaltyPerAsk: 0.25,\n\n /** Score when a command ran but exit code is ambiguous. */\n ambiguousExitScore: 0.75,\n\n /** Minimum tool calls required to produce a meaningful score. */\n minToolCalls: 1,\n\n /** Tool names whose errors are expected/benign (not penalized). */\n benignErrorTools: ['search_content', 'find_files', 'lsp_inspect'] as string[],\n} as const;\n\n// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\ntype DimensionResult = { score: number; detail: string; applicable: boolean };\n\n/**\n * Check if the primary verb of an execute_command is a build/typecheck command.\n * Splits compound commands (&&, ;) and checks the first segment.\n */\n/** Extract command string from tool call args, then delegate to shared classifier. */\nfunction isBuildArgs(args: Record<string, unknown>): boolean {\n return isBuildCommand(String(args.command ?? ''));\n}\n\nfunction isTestArgs(args: Record<string, unknown>): boolean {\n return isTestCommand(String(args.command ?? ''));\n}\n\nfunction isForegroundCommand(result: ExtractedToolCall): boolean {\n return result.args.background !== true;\n}\n\n/**\n * Score build/typecheck outcome (final state).\n */\nfunction scoreBuild(execResults: ExtractedToolCall[]): DimensionResult {\n const builds = execResults.filter(\n r => r.toolName === 'execute_command' && isForegroundCommand(r) && isBuildArgs(r.args),\n );\n if (builds.length === 0) return { score: 0, detail: 'No build/typecheck ran', applicable: false };\n\n const last = builds[builds.length - 1]!;\n if (last.isError) return { score: 0, detail: 'Build/typecheck tool errored', applicable: true };\n\n const exitCode = getExitCode(last.result);\n if (exitCode !== null && exitCode !== 0)\n return { score: 0, detail: `Build failed (exit ${exitCode})`, applicable: true };\n if (typeof last.result === 'string') return { score: 1, detail: 'Build/typecheck passed', applicable: true };\n\n const text = JSON.stringify(last.result ?? '');\n if (/error TS\\d+|Cannot find module|is not assignable/i.test(text)) {\n return { score: 0, detail: 'Build failed (TypeScript errors in output)', applicable: true };\n }\n if (isSuccessResult(last.result)) return { score: 1, detail: 'Build/typecheck passed', applicable: true };\n\n return { score: THRESHOLDS.ambiguousExitScore, detail: 'Build ran, outcome unclear', applicable: true };\n}\n\n/**\n * Score test outcome (final state).\n */\nfunction scoreTests(execResults: ExtractedToolCall[]): DimensionResult {\n const tests = execResults.filter(\n r => r.toolName === 'execute_command' && isForegroundCommand(r) && isTestArgs(r.args),\n );\n if (tests.length === 0) return { score: 0, detail: 'No tests ran', applicable: false };\n\n const last = tests[tests.length - 1]!;\n if (last.isError) return { score: 0, detail: 'Test command errored', applicable: true };\n\n const exitCode = getExitCode(last.result);\n if (exitCode !== null && exitCode !== 0)\n return { score: 0, detail: `Tests failed (exit ${exitCode})`, applicable: true };\n if (typeof last.result === 'string') return { score: 1, detail: 'Tests passed', applicable: true };\n\n const text = JSON.stringify(last.result ?? '');\n if (/\\bFAIL\\b|failed|✗|✘/i.test(text)) {\n return { score: 0, detail: 'Tests failed (inferred)', applicable: true };\n }\n if (/\\d+ (?:tests? )?passed|✓|PASS/i.test(text) && !/\\bfail(?:ed|ure)?\\b|\\berror\\b/i.test(text)) {\n return { score: 1, detail: 'Tests passed (inferred)', applicable: true };\n }\n if (isSuccessResult(last.result)) return { score: 1, detail: 'Tests passed', applicable: true };\n\n return { score: THRESHOLDS.ambiguousExitScore, detail: 'Tests ran, outcome unclear', applicable: true };\n}\n\n/**\n * Score tool error rate, excluding benign errors from expected-to-fail tools.\n */\nfunction scoreToolErrors(results: ExtractedToolCall[]): DimensionResult {\n if (results.length === 0) return { score: 1, detail: 'No tool calls', applicable: false };\n\n // Only count errors from non-benign tools\n const nonBenign = results.filter(r => !THRESHOLDS.benignErrorTools.includes(r.toolName));\n if (nonBenign.length === 0) return { score: 1, detail: 'All tool calls are benign-error tools', applicable: true };\n\n const errors = nonBenign.filter(r => r.isError);\n const rate = errors.length / nonBenign.length;\n\n if (rate === 0) return { score: 1, detail: 'No tool errors', applicable: true };\n\n const score = Math.max(0, 1 - rate * THRESHOLDS.toolErrorPenaltyMultiplier);\n return {\n score,\n detail: `${errors.length}/${nonBenign.length} tools errored (${(rate * 100).toFixed(0)}%)`,\n applicable: true,\n };\n}\n\n/**\n * Detect stuck loops: same tool + same args appearing 3+ times consecutively,\n * or same tool + same args erroring 3+ times total.\n */\nfunction scoreStuckLoops(results: ExtractedToolCall[]): DimensionResult {\n if (results.length < 3) return { score: 1, detail: 'Too few calls for loop detection', applicable: true };\n\n const fingerprint = (r: ExtractedToolCall) => `${r.toolName}:${JSON.stringify(r.args)}`;\n\n // Check consecutive identical calls\n let maxConsecutive = 1;\n let currentRun = 1;\n for (let i = 1; i < results.length; i++) {\n if (fingerprint(results[i]!) === fingerprint(results[i - 1]!)) {\n currentRun++;\n maxConsecutive = Math.max(maxConsecutive, currentRun);\n } else {\n currentRun = 1;\n }\n }\n\n // Check repeated error fingerprints\n const errorCounts = new Map<string, number>();\n for (const r of results) {\n if (!r.isError) continue;\n const fp = fingerprint(r);\n errorCounts.set(fp, (errorCounts.get(fp) ?? 0) + 1);\n }\n const maxErrorRepeat = Math.max(0, ...[...errorCounts.values()]);\n\n const minReps = THRESHOLDS.loopMinRepetitions;\n const loopSeverity = Math.max(\n maxConsecutive >= minReps ? maxConsecutive - (minReps - 1) : 0,\n maxErrorRepeat >= minReps ? maxErrorRepeat - (minReps - 1) : 0,\n );\n\n if (loopSeverity === 0) return { score: 1, detail: 'No stuck loops', applicable: true };\n\n const score = Math.max(0, 1 - loopSeverity * THRESHOLDS.loopPenaltyPerOccurrence);\n const details: string[] = [];\n if (maxConsecutive >= minReps) details.push(`${maxConsecutive} consecutive identical calls`);\n if (maxErrorRepeat >= minReps) details.push(`same error repeated ${maxErrorRepeat}x`);\n return { score, detail: details.join('; '), applicable: true };\n}\n\n/**\n * Detect regressions: build/test passed at some point, then failed later.\n * Gives partial credit if the agent recovered (final state passes).\n */\nfunction scoreRegression(execResults: ExtractedToolCall[]): DimensionResult {\n const regressions: { label: string; recovered: boolean }[] = [];\n\n for (const [label, filter] of [\n ['Build', isBuildArgs],\n ['Tests', isTestArgs],\n ] as const) {\n const cmds = execResults.filter(r => r.toolName === 'execute_command' && isForegroundCommand(r) && filter(r.args));\n if (cmds.length < 2) continue;\n\n let sawPass = false;\n let sawRegression = false;\n for (const cmd of cmds) {\n const exitCode = getExitCode(cmd.result);\n const passed = isSuccessResult(cmd.result, cmd.isError);\n const failed = cmd.isError || (exitCode !== null && exitCode !== 0);\n\n if (passed) {\n if (sawRegression) {\n // Recovered from regression\n regressions.push({ label, recovered: true });\n sawRegression = false;\n }\n sawPass = true;\n }\n if (sawPass && failed) {\n sawRegression = true;\n }\n }\n\n if (sawRegression) {\n // Regression persisted at end of session\n regressions.push({ label, recovered: false });\n }\n }\n\n if (regressions.length === 0) return { score: 1, detail: 'No regressions', applicable: true };\n\n // Persistent regressions are severe (0), recovered regressions get partial credit (0.5)\n const persistentCount = regressions.filter(r => !r.recovered).length;\n const recoveredCount = regressions.filter(r => r.recovered).length;\n const score = Math.max(0, 1 - persistentCount * 0.5 - recoveredCount * 0.1);\n const details = regressions.map(\n r => `${r.label} ${r.recovered ? 'regressed then recovered' : 'regressed (persisted)'}`,\n );\n return { score, detail: details.join('; '), applicable: true };\n}\n\n/**\n * Score autonomy: penalize ask_user calls.\n * 0 calls = 1.0, each call reduces by 0.25 (up to a floor of 0).\n */\nfunction scoreAutonomy(results: ExtractedToolCall[]): DimensionResult {\n const askUserCalls = results.filter(r => r.toolName === 'ask_user');\n const count = askUserCalls.length;\n\n if (count === 0) return { score: 1, detail: 'No ask_user calls (fully autonomous)', applicable: true };\n\n const score = Math.max(0, 1 - count * THRESHOLDS.autonomyPenaltyPerAsk);\n return { score, detail: `${count} ask_user call${count > 1 ? 's' : ''}`, applicable: true };\n}\n\n/**\n * Compute weighted average of only applicable dimensions.\n * Returns null if no dimensions are applicable.\n */\nfunction weightedAverage(dimensions: Record<string, DimensionResult>, weights: Record<string, number>): number | null {\n let totalWeight = 0;\n let weightedSum = 0;\n\n for (const [key, result] of Object.entries(dimensions)) {\n if (!result.applicable) continue;\n const weight = weights[key] ?? 0;\n totalWeight += weight;\n weightedSum += result.score * weight;\n }\n\n if (totalWeight === 0) return null;\n return weightedSum / totalWeight;\n}\n\nexport function createOutcomeScorer() {\n return createScorer({\n id: 'mastracode-outcome',\n name: 'MastraCode Outcome',\n description:\n 'Grades coding session outcomes: build/test pass, tool errors, stuck loops, regressions, autonomy. Always-on.',\n type: 'agent',\n prepareRun: filterRun({ partTypes: ['tool-invocation', 'text'] }),\n })\n .preprocess(async ({ run }) => {\n const messages = (run.output ?? []) as MastraDBMessage[];\n const allResults = extractToolCalls(messages);\n const totalCalls = allResults.length;\n\n // H1: Empty sessions or sessions with no tool calls → score 0\n if (totalCalls < THRESHOLDS.minToolCalls) {\n const empty: DimensionResult = { score: 0, detail: 'No tool calls', applicable: false };\n return {\n empty: true as const,\n build: empty,\n tests: empty,\n toolErrors: empty,\n loops: empty,\n regression: empty,\n autonomy: empty,\n totalCalls,\n };\n }\n\n const execResults = allResults.filter(r => r.toolName === 'execute_command');\n\n return {\n empty: false as const,\n build: scoreBuild(execResults),\n tests: scoreTests(execResults),\n toolErrors: scoreToolErrors(allResults),\n loops: scoreStuckLoops(allResults),\n regression: scoreRegression(execResults),\n autonomy: scoreAutonomy(allResults),\n totalCalls,\n };\n })\n .generateScore(({ results }) => {\n const p = results.preprocessStepResult;\n if (p.empty) return 0;\n\n const score = weightedAverage(\n {\n build: p.build,\n tests: p.tests,\n toolErrors: p.toolErrors,\n loops: p.loops,\n regression: p.regression,\n autonomy: p.autonomy,\n },\n WEIGHTS,\n );\n\n return score === null ? 0 : Math.round(score * 100) / 100;\n })\n .generateReason(({ results, score }) => {\n const p = results.preprocessStepResult;\n if (p.empty) {\n return `Score: 0 (${p.totalCalls} tool calls — below minimum threshold for scoring)`;\n }\n\n const pct = (w: number) => `${(w * 100).toFixed(0)}%`;\n const dimLine = (name: string, weight: number, r: DimensionResult) =>\n r.applicable\n ? `${name} (${pct(weight)}): ${r.detail} [${r.score}]`\n : `${name}: ${r.detail} [N/A — excluded from average]`;\n\n const parts: string[] = [`Score: ${score} (${p.totalCalls} tool calls total)`];\n parts.push(dimLine('Build', WEIGHTS.build, p.build));\n parts.push(dimLine('Tests', WEIGHTS.tests, p.tests));\n parts.push(dimLine('Tool errors', WEIGHTS.toolErrors, p.toolErrors));\n parts.push(dimLine('Loops', WEIGHTS.loops, p.loops));\n parts.push(dimLine('Regression', WEIGHTS.regression, p.regression));\n parts.push(dimLine('Autonomy', WEIGHTS.autonomy, p.autonomy));\n\n return parts.join('\\n');\n });\n}\n"],"mappings":";;;;;;;;AAuCA,MAAM,UAAU;CACd,OAAO;CACP,OAAO;CACP,YAAY;CACZ,OAAO;CACP,YAAY;CACZ,UAAU;AACZ;;;;AAKA,MAAM,aAAa;;CAEjB,4BAA4B;;CAG5B,oBAAoB;;CAGpB,0BAA0B;;CAG1B,uBAAuB;;CAGvB,oBAAoB;;CAGpB,cAAc;;CAGd,kBAAkB;EAAC;EAAkB;EAAc;CAAa;AAClE;;;;;;AAWA,SAAS,YAAY,MAAwC;CAC3D,OAAO,eAAe,OAAO,KAAK,WAAW,EAAE,CAAC;AAClD;AAEA,SAAS,WAAW,MAAwC;CAC1D,OAAO,cAAc,OAAO,KAAK,WAAW,EAAE,CAAC;AACjD;AAEA,SAAS,oBAA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