@wix/pathgrade 1.0.31 → 1.0.33
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/adapters/jest/invocation-adapter.d.ts +2 -2
- package/dist/adapters/jest/invocation-adapter.js +1 -1
- package/dist/adapters/jest/lifecycle.d.ts +3 -3
- package/dist/adapters/jest/lifecycle.js +1 -1
- package/dist/adapters/jest/metadata.d.ts +0 -1
- package/dist/adapters/jest/metadata.js +1 -1
- package/dist/adapters/jest/results.d.ts +3 -2
- package/dist/affected/format.d.ts +0 -23
- package/dist/affected/format.js +1 -1
- package/dist/affected/sidecar.d.ts +0 -1
- package/dist/affected/sidecar.js +1 -1
- package/dist/affected/types.d.ts +2 -17
- package/dist/agents/claude/ask-user-answer-store.d.ts +2 -1
- package/dist/agents/claude/tool-results.d.ts +1 -1
- package/dist/agents/claude/tool-results.js +1 -1
- package/dist/agents/claude.d.ts +2 -1
- package/dist/agents/codex-app-server/agent.js +24 -8
- package/dist/agents/codex-app-server/protocol/ClientRequest.d.ts +3 -2
- package/dist/agents/codex-app-server/protocol/DynamicToolCallParams.d.ts +2 -1
- package/dist/agents/codex-app-server/protocol/GetAccountTokenUsageParams.d.ts +3 -0
- package/dist/agents/codex-app-server/protocol/GetAccountTokenUsageParams.js +4 -0
- package/dist/agents/codex-app-server/protocol/GetAccountTokenUsageResponse.d.ts +6 -0
- package/dist/agents/codex-app-server/protocol/GetAccountTokenUsageResponse.js +4 -0
- package/dist/agents/codex-app-server/protocol/GrantedPermissionProfile.d.ts +3 -2
- package/dist/agents/codex-app-server/protocol/McpElicitationRequestParams.d.ts +3 -2
- package/dist/agents/codex-app-server/protocol/PermissionsRequestApprovalParams.d.ts +3 -2
- package/dist/agents/codex-app-server/protocol/ThreadStartParams.d.ts +7 -6
- package/dist/agents/codex-app-server/protocol/ThreadTokenUsage.d.ts +6 -0
- package/dist/agents/codex-app-server/protocol/ThreadTokenUsage.js +4 -0
- package/dist/agents/codex-app-server/protocol/ThreadTokenUsageUpdatedNotification.d.ts +6 -0
- package/dist/agents/codex-app-server/protocol/ThreadTokenUsageUpdatedNotification.js +4 -0
- package/dist/agents/codex-app-server/protocol/ThreadUsage.d.ts +7 -0
- package/dist/agents/codex-app-server/protocol/ThreadUsage.js +4 -0
- package/dist/agents/codex-app-server/protocol/ThreadUsageBreakdownGroup.d.ts +11 -0
- package/dist/agents/codex-app-server/protocol/ThreadUsageBreakdownGroup.js +4 -0
- package/dist/agents/codex-app-server/protocol/TokenUsageBreakdown.d.ts +8 -0
- package/dist/agents/codex-app-server/protocol/TokenUsageBreakdown.js +4 -0
- package/dist/agents/codex-app-server/protocol/TurnCompletedNotification.d.ts +2 -1
- package/dist/agents/codex-app-server/protocol/index.d.ts +7 -0
- package/dist/agents/codex-app-server/transport.d.ts +2 -2
- package/dist/agents/codex-app-server/turn-notifications.js +4 -0
- package/dist/agents/codex-app-server/turn-state.d.ts +3 -0
- package/dist/agents/codex-app-server/usage-accounting.d.ts +18 -0
- package/dist/agents/codex-app-server/usage-accounting.js +121 -0
- package/dist/commands/analyze.d.ts +0 -13
- package/dist/commands/report.d.ts +0 -7
- package/dist/commands/report.js +1 -1
- package/dist/core/generated-mcp-protocol.d.ts +0 -2
- package/dist/core/generated-mcp-protocol.js +2 -2
- package/dist/evals/discovery.d.ts +0 -1
- package/dist/evals/discovery.js +1 -1
- package/dist/internal/direct-mcp-v2/acp-client.d.ts +0 -8
- package/dist/internal/direct-mcp-v2/acp-direct-mcp.d.ts +2 -1
- package/dist/internal/direct-mcp-v2/claude-direct-mcp.d.ts +1 -1
- package/dist/internal/direct-mcp-v2/claude-profile.d.ts +0 -10
- package/dist/internal/direct-mcp-v2/claude-profile.js +3 -3
- package/dist/internal/direct-mcp-v2/codex-direct-mcp.d.ts +2 -1
- package/dist/internal/direct-mcp-v2/compiler.d.ts +0 -1
- package/dist/internal/direct-mcp-v2/compiler.js +1 -1
- package/dist/internal/direct-mcp-v2/json.d.ts +0 -2
- package/dist/internal/direct-mcp-v2/json.js +2 -2
- package/dist/internal/direct-mcp-v2/runtime-lock.d.ts +2 -1
- package/dist/internal/direct-mcp-v2/runtime-profile.d.ts +0 -1
- package/dist/internal/direct-mcp-v2/runtime-profile.js +1 -1
- package/dist/internal/direct-mcp-v2/types.d.ts +5 -4
- package/dist/openai-oauth/chatgpt-oauth-llm.js +12 -1
- package/dist/providers/mcp-config.d.ts +0 -2
- package/dist/providers/mcp-config.js +2 -2
- package/dist/providers/mcp-runtime-mounting.d.ts +1 -9
- package/dist/providers/sandbox-lifecycle.d.ts +0 -2
- package/dist/providers/sandbox-lifecycle.js +2 -2
- package/dist/providers/scripted-mcp-mock-host.d.ts +1 -1
- package/dist/providers/workspace.d.ts +0 -1
- package/dist/reporters/github-comment.d.ts +0 -11
- package/dist/reporters/github-comment.js +1 -1
- package/dist/reporters/verbose-emitter.d.ts +7 -19
- package/dist/reporters/verbose-emitter.js +5 -5
- package/dist/reporting/types.d.ts +2 -1
- package/dist/runners/adapter-loader.d.ts +0 -3
- package/dist/runners/model-validation.d.ts +2 -1
- package/dist/runners/repeated-attempts.d.ts +0 -5
- package/dist/runners/repeated-attempts.js +1 -1
- package/dist/runners/vitest-invocation.d.ts +2 -2
- package/dist/runners/vitest-invocation.js +1 -1
- package/dist/runners/vitest-lifecycle.d.ts +0 -2
- package/dist/runners/vitest-lifecycle.js +1 -1
- package/dist/sdk/agent.js +1 -3
- package/dist/sdk/ask-bus/handler.d.ts +3 -2
- package/dist/sdk/diagnostics.d.ts +4 -3
- package/dist/sdk/evaluate.js +3 -2
- package/dist/sdk/judge-tool-runner.d.ts +1 -2
- package/dist/sdk/lifecycle.js +4 -0
- package/dist/sdk/mcp-mock-approvals.d.ts +3 -2
- package/dist/sdk/reaction-loader.d.ts +1 -2
- package/dist/sdk/reaction-preview.d.ts +1 -4
- package/dist/sdk/reaction-preview.js +3 -3
- package/dist/sdk/run-scorer.d.ts +1 -4
- package/dist/sdk/run-scorer.js +3 -3
- package/dist/sdk/runtime-policy.d.ts +0 -1
- package/dist/sdk/runtime-policy.js +1 -1
- package/dist/tool-events.d.ts +0 -1
- package/dist/tool-events.js +1 -1
- package/dist/types.d.ts +10 -32
- package/dist/types.js +1 -1
- package/dist/utils/cli.d.ts +0 -15
- package/dist/utils/cli.js +4 -4
- package/dist/utils/llm-mocks.d.ts +3 -2
- package/dist/utils/llm-mocks.js +5 -0
- package/dist/utils/llm-providers/cli.d.ts +0 -1
- package/dist/utils/llm-providers/cli.js +1 -1
- package/dist/utils/llm-types.d.ts +7 -4
- package/dist/utils/llm.d.ts +2 -2
- package/dist/utils/llm.js +6 -1
- package/package.json +2 -2
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const TOKEN_KEYS = [
|
|
2
|
+
'totalTokens', 'inputTokens', 'cachedInputTokens',
|
|
3
|
+
'cacheWriteInputTokens', 'outputTokens', 'reasoningOutputTokens',
|
|
4
|
+
];
|
|
5
|
+
export const WIX_CODEX_USD_PER_CREDIT = 0.034;
|
|
6
|
+
const USAGE_READ_FALLBACK_TIMEOUT_MS = 5_000;
|
|
7
|
+
export class CodexTurnUsageAccounting {
|
|
8
|
+
baseline;
|
|
9
|
+
latest;
|
|
10
|
+
pending = [];
|
|
11
|
+
authorize(threadId, turnId) {
|
|
12
|
+
for (const value of this.pending.splice(0))
|
|
13
|
+
this.receive(value, threadId, turnId);
|
|
14
|
+
}
|
|
15
|
+
receive(value, threadId, turnId) {
|
|
16
|
+
const params = record(value);
|
|
17
|
+
if (threadId && !turnId) {
|
|
18
|
+
if (this.pending.length < 64)
|
|
19
|
+
this.pending.push(value);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (!threadId || !turnId || params?.threadId !== threadId || params.turnId !== turnId)
|
|
23
|
+
return;
|
|
24
|
+
const tokenUsage = record(params.tokenUsage);
|
|
25
|
+
const total = counters(tokenUsage?.total);
|
|
26
|
+
const last = counters(tokenUsage?.last);
|
|
27
|
+
if (!total || !last || !atLeast(total, last))
|
|
28
|
+
return;
|
|
29
|
+
if (!this.baseline) {
|
|
30
|
+
this.baseline = subtract(total, last);
|
|
31
|
+
this.latest = total;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (this.latest && !atLeast(total, this.latest))
|
|
35
|
+
return;
|
|
36
|
+
this.latest = total;
|
|
37
|
+
}
|
|
38
|
+
result() {
|
|
39
|
+
if (!this.baseline || !this.latest)
|
|
40
|
+
return {};
|
|
41
|
+
return {
|
|
42
|
+
inputTokens: this.latest.inputTokens - this.baseline.inputTokens,
|
|
43
|
+
outputTokens: this.latest.outputTokens - this.baseline.outputTokens,
|
|
44
|
+
cacheReadInputTokens: this.latest.cachedInputTokens - this.baseline.cachedInputTokens,
|
|
45
|
+
cacheCreationInputTokens: this.latest.cacheWriteInputTokens - this.baseline.cacheWriteInputTokens,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export class CodexThreadCostAccounting {
|
|
50
|
+
threadId;
|
|
51
|
+
cumulativeUsd = 0;
|
|
52
|
+
beginThread(threadId) {
|
|
53
|
+
if (this.threadId === threadId)
|
|
54
|
+
return;
|
|
55
|
+
this.threadId = threadId;
|
|
56
|
+
this.cumulativeUsd = 0;
|
|
57
|
+
}
|
|
58
|
+
receive(value, threadId) {
|
|
59
|
+
const response = record(value);
|
|
60
|
+
const usage = record(response?.threadUsage);
|
|
61
|
+
if (!usage || usage.threadId !== threadId || this.threadId !== threadId)
|
|
62
|
+
return undefined;
|
|
63
|
+
const usdValue = usage.estimatedUsageUsdMicros;
|
|
64
|
+
const current = usdValue !== undefined && usdValue !== null
|
|
65
|
+
? microsToUsd(usdValue)
|
|
66
|
+
: creditsToUsd(usage.estimatedUsageCreditsMicros);
|
|
67
|
+
if (current === undefined || current < this.cumulativeUsd)
|
|
68
|
+
return undefined;
|
|
69
|
+
const delta = current - this.cumulativeUsd;
|
|
70
|
+
this.cumulativeUsd = current;
|
|
71
|
+
return delta;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export async function readCodexThreadCost(transport, threadId, accounting, getRemainingMs) {
|
|
75
|
+
const remainingMs = getRemainingMs?.() ?? USAGE_READ_FALLBACK_TIMEOUT_MS;
|
|
76
|
+
if (remainingMs <= 0)
|
|
77
|
+
return undefined;
|
|
78
|
+
const controller = new AbortController();
|
|
79
|
+
const timer = Number.isFinite(remainingMs) ? setTimeout(() => controller.abort(), remainingMs) : undefined;
|
|
80
|
+
try {
|
|
81
|
+
const response = await transport.sendRequest('account/usage/read', { threadId }, {
|
|
82
|
+
signal: controller.signal,
|
|
83
|
+
});
|
|
84
|
+
return accounting.receive(response, threadId);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
if (timer)
|
|
91
|
+
clearTimeout(timer);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function record(value) {
|
|
95
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
96
|
+
? value
|
|
97
|
+
: undefined;
|
|
98
|
+
}
|
|
99
|
+
function counters(value) {
|
|
100
|
+
const source = record(value);
|
|
101
|
+
if (!source || !TOKEN_KEYS.every(key => Number.isSafeInteger(source[key]) && source[key] >= 0))
|
|
102
|
+
return undefined;
|
|
103
|
+
return Object.fromEntries(TOKEN_KEYS.map(key => [key, source[key]]));
|
|
104
|
+
}
|
|
105
|
+
function atLeast(value, floor) {
|
|
106
|
+
return TOKEN_KEYS.every(key => value[key] >= floor[key]);
|
|
107
|
+
}
|
|
108
|
+
function subtract(value, amount) {
|
|
109
|
+
return Object.fromEntries(TOKEN_KEYS.map(key => [key, value[key] - amount[key]]));
|
|
110
|
+
}
|
|
111
|
+
function optionalMicros(value) {
|
|
112
|
+
return Number.isSafeInteger(value) && value >= 0 ? value : undefined;
|
|
113
|
+
}
|
|
114
|
+
function microsToUsd(value) {
|
|
115
|
+
const micros = optionalMicros(value);
|
|
116
|
+
return micros === undefined ? undefined : micros / 1_000_000;
|
|
117
|
+
}
|
|
118
|
+
function creditsToUsd(value) {
|
|
119
|
+
const micros = optionalMicros(value);
|
|
120
|
+
return micros === undefined ? undefined : micros / 1_000_000 * WIX_CODEX_USD_PER_CREDIT;
|
|
121
|
+
}
|
|
@@ -2,19 +2,6 @@ export interface AnalyzeOptions {
|
|
|
2
2
|
skill?: string;
|
|
3
3
|
dir?: string;
|
|
4
4
|
}
|
|
5
|
-
export interface SkillAnalysis {
|
|
6
|
-
skillName: string;
|
|
7
|
-
description: string;
|
|
8
|
-
procedures: string[];
|
|
9
|
-
expectedOutputs: string[];
|
|
10
|
-
suggestedScorers: Array<{
|
|
11
|
-
type: 'check' | 'judge';
|
|
12
|
-
name: string;
|
|
13
|
-
hint: string;
|
|
14
|
-
}>;
|
|
15
|
-
workspaceHint: string;
|
|
16
|
-
hasFixtures: boolean;
|
|
17
|
-
}
|
|
18
5
|
/**
|
|
19
6
|
* Run the analyze command. Returns exit code (0 = success, 1 = error).
|
|
20
7
|
*/
|
|
@@ -33,13 +33,6 @@ export interface ReportOptions {
|
|
|
33
33
|
/** Skip a comment update when the pull request has advanced. */
|
|
34
34
|
expectedHeadSha?: string;
|
|
35
35
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Resolve the comment-id used for the dedup marker.
|
|
38
|
-
*
|
|
39
|
-
* Precedence: explicit `commentId` → `$GITHUB_WORKFLOW:$GITHUB_JOB` →
|
|
40
|
-
* `$GITHUB_WORKFLOW` → hard-coded literal `"default"`.
|
|
41
|
-
*/
|
|
42
|
-
export declare function resolveCommentId(explicit?: string): string;
|
|
43
36
|
/**
|
|
44
37
|
* Entry point for `pathgrade report`. The default display-only mode never
|
|
45
38
|
* fails CI. Strict mode is intended for orchestrators that own publication.
|
package/dist/commands/report.js
CHANGED
|
@@ -28,7 +28,7 @@ const DEFAULT_RESULTS_PATH = path.join('.pathgrade', 'results.json');
|
|
|
28
28
|
* Precedence: explicit `commentId` → `$GITHUB_WORKFLOW:$GITHUB_JOB` →
|
|
29
29
|
* `$GITHUB_WORKFLOW` → hard-coded literal `"default"`.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
function resolveCommentId(explicit) {
|
|
32
32
|
if (explicit && explicit.length > 0)
|
|
33
33
|
return explicit;
|
|
34
34
|
const workflow = process.env.GITHUB_WORKFLOW;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare const MCP_ANNOTATION_PROTOCOL_FLOOR = "2025-03-26";
|
|
2
|
-
export declare const MCP_LATEST_ANNOTATION_PROTOCOL = "2025-11-25";
|
|
3
2
|
export interface GeneratedMcpInitializeResult {
|
|
4
3
|
protocolVersion: string;
|
|
5
4
|
capabilities: {
|
|
@@ -11,7 +10,6 @@ export interface GeneratedMcpInitializeResult {
|
|
|
11
10
|
};
|
|
12
11
|
instructions?: string;
|
|
13
12
|
}
|
|
14
|
-
export declare function negotiateGeneratedMcpProtocol(requestedVersion: unknown): string;
|
|
15
13
|
export declare function buildGeneratedMcpInitializeResult(opts: {
|
|
16
14
|
requestedVersion: unknown;
|
|
17
15
|
serverName: string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export const MCP_ANNOTATION_PROTOCOL_FLOOR = '2025-03-26';
|
|
2
|
-
|
|
2
|
+
const MCP_LATEST_ANNOTATION_PROTOCOL = '2025-11-25';
|
|
3
3
|
const SUPPORTED_ANNOTATION_PROTOCOLS = new Set([
|
|
4
4
|
MCP_ANNOTATION_PROTOCOL_FLOOR,
|
|
5
5
|
'2025-06-18',
|
|
6
6
|
MCP_LATEST_ANNOTATION_PROTOCOL,
|
|
7
7
|
]);
|
|
8
|
-
|
|
8
|
+
function negotiateGeneratedMcpProtocol(requestedVersion) {
|
|
9
9
|
if (typeof requestedVersion !== 'string') {
|
|
10
10
|
throw new Error('MCP initialize requires a string protocolVersion');
|
|
11
11
|
}
|
package/dist/evals/discovery.js
CHANGED
|
@@ -44,7 +44,7 @@ export function discoverPathgradeEvalFiles(opts) {
|
|
|
44
44
|
results.sort();
|
|
45
45
|
return results;
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
function isPathgradeEval(absPath) {
|
|
48
48
|
const source = fs.readFileSync(absPath, 'utf8');
|
|
49
49
|
const sourceFile = ts.createSourceFile(absPath, source, ts.ScriptTarget.Latest,
|
|
50
50
|
/* setParentNodes */ false, ts.ScriptKind.TS);
|
|
@@ -2,14 +2,6 @@ import { type ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
|
2
2
|
import type { JsonObject, JsonValue } from './types.js';
|
|
3
3
|
export type JsonRpcMessage = JsonObject;
|
|
4
4
|
export type AcpNotificationCheckpoint = number;
|
|
5
|
-
export type AcpPermissionRequest = {
|
|
6
|
-
sessionId?: string;
|
|
7
|
-
toolCallId?: string;
|
|
8
|
-
options: readonly {
|
|
9
|
-
optionId: string;
|
|
10
|
-
kind: string;
|
|
11
|
-
}[];
|
|
12
|
-
};
|
|
13
5
|
export type AcpClientRequestHandler = (method: string, params: JsonValue) => Promise<JsonValue>;
|
|
14
6
|
export declare class AcpClientCore {
|
|
15
7
|
private readonly sendFrame;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawnAcpClient } from './acp-client.js';
|
|
2
2
|
import { type CleanupReport } from './cleanup.js';
|
|
3
3
|
import type { EvidenceEnvelope, RuntimeCapabilityProfile, ScenarioArtifact, ScenarioMachineV2 } from './types.js';
|
|
4
|
-
|
|
4
|
+
type AcpDirectMcpChecks = {
|
|
5
5
|
runtimeAdmitted: boolean;
|
|
6
6
|
secretFreeProject: boolean;
|
|
7
7
|
directCall: boolean;
|
|
@@ -36,3 +36,4 @@ export type AcpDirectMcpOptions = {
|
|
|
36
36
|
};
|
|
37
37
|
export declare function curateAcpProcessEnvironment(environment: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
38
38
|
export declare function runAcpDirectMcpTrial(options: AcpDirectMcpOptions): Promise<AcpDirectMcpTrialResult>;
|
|
39
|
+
export {};
|
|
@@ -4,7 +4,7 @@ import { type CleanupReport } from './cleanup.js';
|
|
|
4
4
|
import { type MaterializedProjection } from './materialize.js';
|
|
5
5
|
import type { AdmittedRuntimeProfile, EvidenceEnvelope, ScenarioArtifact, ScenarioMachineV2 } from './types.js';
|
|
6
6
|
export declare const CLAUDE_DIRECT_MCP_FLAG = "PATHGRADE_INTERNAL_CLAUDE_DIRECT_MCP_V2";
|
|
7
|
-
|
|
7
|
+
type ClaudeDirectMcpChecks = {
|
|
8
8
|
runtimeAdmitted: boolean;
|
|
9
9
|
secretFreeProject: boolean;
|
|
10
10
|
directCall: boolean;
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import type { RuntimeLock, RuntimeLockControlPlane } from './runtime-lock.js';
|
|
2
2
|
import type { JsonObject } from './types.js';
|
|
3
3
|
export declare const CLAUDE_DIRECT_MCP_NORMALIZED_HANDSHAKE: JsonObject;
|
|
4
|
-
export declare const CLAUDE_DIRECT_MCP_CAPABILITIES: {
|
|
5
|
-
readonly streamableHttp: true;
|
|
6
|
-
readonly controlPlaneHeaders: true;
|
|
7
|
-
readonly parentOwnedSdkMcp: true;
|
|
8
|
-
readonly cancellation: "abort-controller";
|
|
9
|
-
};
|
|
10
|
-
/** Code-owned relocatable identity lock captured by RFC 0006. */
|
|
11
|
-
export declare const CLAUDE_DIRECT_MCP_DARWIN_ARM64_LOCK: RuntimeLock;
|
|
12
|
-
/** Provisional Linux x64 glibc lock; CI re-verifies every artifact before admission. */
|
|
13
|
-
export declare const CLAUDE_DIRECT_MCP_LINUX_X64_GLIBC_LOCK: RuntimeLock;
|
|
14
4
|
export type ClaudeRuntimeTarget = {
|
|
15
5
|
id: 'darwin-arm64' | 'linux-x64-glibc';
|
|
16
6
|
platform: 'darwin' | 'linux';
|
|
@@ -13,7 +13,7 @@ export const CLAUDE_DIRECT_MCP_NORMALIZED_HANDSHAKE = {
|
|
|
13
13
|
cancellation: 'abort-controller',
|
|
14
14
|
sdkMethods: ['createSdkMcpServer', 'query'],
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
const CLAUDE_DIRECT_MCP_CAPABILITIES = {
|
|
17
17
|
streamableHttp: true,
|
|
18
18
|
controlPlaneHeaders: true,
|
|
19
19
|
parentOwnedSdkMcp: true,
|
|
@@ -45,14 +45,14 @@ function claudeLock(options) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
/** Code-owned relocatable identity lock captured by RFC 0006. */
|
|
48
|
-
|
|
48
|
+
const CLAUDE_DIRECT_MCP_DARWIN_ARM64_LOCK = claudeLock({
|
|
49
49
|
platform: 'darwin',
|
|
50
50
|
architecture: 'arm64',
|
|
51
51
|
packageName: '@anthropic-ai/claude-agent-sdk-darwin-arm64',
|
|
52
52
|
commandSha256: '31ac95bb19a33b1d0cddd3f3ff594bf8bfd2be5051cd2af7867109641cab705e',
|
|
53
53
|
});
|
|
54
54
|
/** Provisional Linux x64 glibc lock; CI re-verifies every artifact before admission. */
|
|
55
|
-
|
|
55
|
+
const CLAUDE_DIRECT_MCP_LINUX_X64_GLIBC_LOCK = claudeLock({
|
|
56
56
|
platform: 'linux',
|
|
57
57
|
architecture: 'x64',
|
|
58
58
|
packageName: '@anthropic-ai/claude-agent-sdk-linux-x64',
|
|
@@ -2,7 +2,7 @@ import { type CleanupReport } from './cleanup.js';
|
|
|
2
2
|
import { type AppServerSessionHandle } from '../../agents/codex-app-server/transport.js';
|
|
3
3
|
import type { EvidenceEnvelope, ScenarioArtifact, ScenarioMachineV2 } from './types.js';
|
|
4
4
|
export declare const CODEX_DIRECT_MCP_FLAG = "PATHGRADE_INTERNAL_CODEX_DIRECT_MCP_V2";
|
|
5
|
-
|
|
5
|
+
type CodexDirectMcpChecks = {
|
|
6
6
|
runtimeAdmitted: boolean;
|
|
7
7
|
secretFreeProject: boolean;
|
|
8
8
|
directCall: boolean;
|
|
@@ -39,3 +39,4 @@ export declare function runCodexDirectMcpTrial(options: {
|
|
|
39
39
|
}) => AppServerSessionHandle;
|
|
40
40
|
}): Promise<CodexDirectMcpTrialResult>;
|
|
41
41
|
export declare function mapCodexProviderEnvironment(environment: NodeJS.ProcessEnv, codexHome: string): NodeJS.ProcessEnv;
|
|
42
|
+
export {};
|
|
@@ -9,4 +9,3 @@ export type CompileScenarioResult = {
|
|
|
9
9
|
export declare function matchExpression(args: JsonObject, expression: MatchExpr): boolean;
|
|
10
10
|
export declare function compileScenario(source: unknown): CompileScenarioResult;
|
|
11
11
|
export declare function compileScenarioText(text: string): CompileScenarioResult;
|
|
12
|
-
export declare function isSha256(value: unknown): value is string;
|
|
@@ -444,6 +444,6 @@ export function compileScenarioText(text) {
|
|
|
444
444
|
return { ok: false, diagnostics: [{ code: 'INVALID_JSON_TEXT', path: '$', message: error instanceof Error ? error.message : String(error) }] };
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
|
-
|
|
447
|
+
function isSha256(value) {
|
|
448
448
|
return typeof value === 'string' && SHA256.test(value);
|
|
449
449
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { JsonValue } from './types.js';
|
|
2
|
-
export declare function assertJsonValue(value: unknown, path?: string, ancestors?: Set<object>): asserts value is JsonValue;
|
|
3
2
|
export declare function canonicalJson(value: unknown): string;
|
|
4
3
|
export declare function sha256Canonical(value: unknown): string;
|
|
5
|
-
export declare function escapePointerToken(token: string): string;
|
|
6
4
|
export declare function parsePointer(pointer: string): string[];
|
|
7
5
|
export declare const MISSING: unique symbol;
|
|
8
6
|
export declare function resolvePointer(value: JsonValue, pointer: string): JsonValue | typeof MISSING;
|
|
@@ -13,7 +13,7 @@ function assertValidString(value, path) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
function assertJsonValue(value, path = '$', ancestors = new Set()) {
|
|
17
17
|
if (value === null || typeof value === 'boolean')
|
|
18
18
|
return;
|
|
19
19
|
if (typeof value === 'string')
|
|
@@ -69,7 +69,7 @@ export function canonicalJson(value) {
|
|
|
69
69
|
export function sha256Canonical(value) {
|
|
70
70
|
return createHash('sha256').update(canonicalJson(value)).digest('hex');
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
function escapePointerToken(token) {
|
|
73
73
|
return token.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
74
74
|
}
|
|
75
75
|
export function parsePointer(pointer) {
|
|
@@ -32,7 +32,7 @@ export type RuntimeLockAdmissionContext<TControlPlane extends RuntimeLockControl
|
|
|
32
32
|
commandVersion?: (commandPath: string, args: readonly string[]) => Promise<string>;
|
|
33
33
|
initializeControlPlane(commandPath: string, args: readonly string[]): Promise<TControlPlane>;
|
|
34
34
|
};
|
|
35
|
-
|
|
35
|
+
type RuntimeLockIdentity = {
|
|
36
36
|
provider: RuntimeLock['provider'];
|
|
37
37
|
platform: string;
|
|
38
38
|
architecture: string;
|
|
@@ -49,3 +49,4 @@ export type RuntimeLockAdmission<TControlPlane extends RuntimeLockControlPlane =
|
|
|
49
49
|
controlPlane: TControlPlane;
|
|
50
50
|
};
|
|
51
51
|
export declare function admitRuntimeLock<TControlPlane extends RuntimeLockControlPlane>(rawLock: RuntimeLock, context: RuntimeLockAdmissionContext<TControlPlane>): Promise<RuntimeLockAdmission<TControlPlane>>;
|
|
52
|
+
export {};
|
|
@@ -24,5 +24,4 @@ export type RuntimeAdmissionResult = {
|
|
|
24
24
|
};
|
|
25
25
|
export declare function profileFingerprint(profile: Omit<RuntimeCapabilityProfile, 'profileFingerprint' | 'runtimeCapabilityFingerprint'>): string;
|
|
26
26
|
export declare function runtimeCapabilityFingerprint(normalizedHandshake: JsonObject): string;
|
|
27
|
-
export declare function parseRuntimeProfile(input: string | unknown): RuntimeCapabilityProfile;
|
|
28
27
|
export declare function admitRuntimeProfile(rawProfile: string | unknown, context: RuntimeAdmissionContext): Promise<RuntimeAdmissionResult>;
|
|
@@ -28,7 +28,7 @@ export function profileFingerprint(profile) {
|
|
|
28
28
|
export function runtimeCapabilityFingerprint(normalizedHandshake) {
|
|
29
29
|
return sha256Canonical(normalizedHandshake);
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
function parseRuntimeProfile(input) {
|
|
32
32
|
const value = typeof input === 'string' ? parseStrictJson(input) : input;
|
|
33
33
|
canonicalJson(value);
|
|
34
34
|
if (!object(value))
|
|
@@ -3,8 +3,8 @@ export type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
|
|
|
3
3
|
export type JsonObject = {
|
|
4
4
|
[key: string]: JsonValue;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
type Sha256 = string;
|
|
7
|
+
type HmacSha256 = string;
|
|
8
8
|
export type ProviderId = 'claude' | 'codex' | 'cursor' | 'opencode';
|
|
9
9
|
export type MatchPredicate = {
|
|
10
10
|
pointer: string;
|
|
@@ -72,7 +72,7 @@ export type ScenarioDiagnostic = {
|
|
|
72
72
|
path: string;
|
|
73
73
|
message: string;
|
|
74
74
|
};
|
|
75
|
-
|
|
75
|
+
type CompiledTool = {
|
|
76
76
|
qualifiedToolId: string;
|
|
77
77
|
serverId: string;
|
|
78
78
|
toolId: string;
|
|
@@ -80,7 +80,7 @@ export type CompiledTool = {
|
|
|
80
80
|
otherwise: ScenarioRejection;
|
|
81
81
|
effectful: boolean;
|
|
82
82
|
};
|
|
83
|
-
|
|
83
|
+
type ScenarioIR = {
|
|
84
84
|
version: 2;
|
|
85
85
|
scenarioId: string;
|
|
86
86
|
initialState: string;
|
|
@@ -231,3 +231,4 @@ export type ProviderCorroboration = {
|
|
|
231
231
|
phase: string;
|
|
232
232
|
order: number;
|
|
233
233
|
};
|
|
234
|
+
export {};
|
|
@@ -342,12 +342,23 @@ export function createChatGptOAuthJudgeLLMWithDependencies(options, dependencies
|
|
|
342
342
|
throw oauthError('OAUTH_PROTOCOL_RESPONSE_INVALID');
|
|
343
343
|
}
|
|
344
344
|
};
|
|
345
|
+
let costUsd = 0;
|
|
346
|
+
let costObserved = false;
|
|
345
347
|
const port = {
|
|
346
348
|
get tokenUsage() { return { inputTokens, outputTokens }; },
|
|
349
|
+
get costUsd() { return costUsd; },
|
|
350
|
+
get costObserved() { return costObserved; },
|
|
351
|
+
addCost(usd) {
|
|
352
|
+
if (!Number.isFinite(usd) || usd < 0)
|
|
353
|
+
return;
|
|
354
|
+
costUsd += usd;
|
|
355
|
+
costObserved = true;
|
|
356
|
+
},
|
|
347
357
|
get supportsToolUse() { return true; },
|
|
348
358
|
async measure(fn) {
|
|
349
359
|
const beforeInput = inputTokens;
|
|
350
360
|
const beforeOutput = outputTokens;
|
|
361
|
+
const beforeCost = costUsd;
|
|
351
362
|
const result = await fn();
|
|
352
363
|
return {
|
|
353
364
|
result,
|
|
@@ -355,7 +366,7 @@ export function createChatGptOAuthJudgeLLMWithDependencies(options, dependencies
|
|
|
355
366
|
inputTokens: inputTokens - beforeInput,
|
|
356
367
|
outputTokens: outputTokens - beforeOutput,
|
|
357
368
|
},
|
|
358
|
-
costUsd:
|
|
369
|
+
costUsd: costUsd - beforeCost,
|
|
359
370
|
};
|
|
360
371
|
},
|
|
361
372
|
async call(prompt, callOptions = {}) {
|
|
@@ -29,9 +29,7 @@ export type McpDeclaration = {
|
|
|
29
29
|
} | {
|
|
30
30
|
mock: MockMcpServerDescriptor | MockMcpServerDescriptor[];
|
|
31
31
|
};
|
|
32
|
-
export declare const MCP_CONFIG_FILENAME = ".pathgrade-mcp.json";
|
|
33
32
|
export declare function readStagedMcpServers(workspacePath: string, mcpConfigPath?: string): Promise<Record<string, McpConfigFileEntry> | undefined>;
|
|
34
|
-
export declare function missingMcpSecretReferences(mcpServers: Record<string, McpConfigFileEntry> | undefined, env: Record<string, string | undefined>): string[];
|
|
35
33
|
export declare function assertMcpSecretReferencesReady(opts: {
|
|
36
34
|
workspacePath: string;
|
|
37
35
|
mcpConfigPath?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
-
|
|
3
|
+
const MCP_CONFIG_FILENAME = '.pathgrade-mcp.json';
|
|
4
4
|
const GENERATED_MOCK_SERVER_FILENAME = '.pathgrade-mcp-mock-server.cjs';
|
|
5
5
|
function isRecord(value) {
|
|
6
6
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
@@ -76,7 +76,7 @@ export async function readStagedMcpServers(workspacePath, mcpConfigPath = MCP_CO
|
|
|
76
76
|
return undefined;
|
|
77
77
|
return readMcpServers(await fs.readJson(configPath));
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
function missingMcpSecretReferences(mcpServers, env) {
|
|
80
80
|
if (!mcpServers)
|
|
81
81
|
return [];
|
|
82
82
|
const missing = [];
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import type { McpStdioEntry } from './mcp-config.js';
|
|
2
2
|
import type { McpSafetyOptions } from '../sdk/mcp-safety.js';
|
|
3
|
-
|
|
3
|
+
type ClaudeSdkMcpServerEntry = McpStdioEntry | {
|
|
4
4
|
type: 'http';
|
|
5
5
|
url: string;
|
|
6
6
|
headers?: Record<string, string>;
|
|
7
7
|
};
|
|
8
8
|
/** Object form of MCP server entries the SDK driver passes to `Options.mcpServers`. */
|
|
9
9
|
export type McpServersObject = Record<string, ClaudeSdkMcpServerEntry>;
|
|
10
|
-
export type CodexMcpServerEntry = McpStdioEntry | {
|
|
11
|
-
url: string;
|
|
12
|
-
http_headers?: Record<string, string>;
|
|
13
|
-
env_http_headers?: Record<string, string>;
|
|
14
|
-
bearer_token_env_var?: string;
|
|
15
|
-
startup_timeout_sec?: number;
|
|
16
|
-
tool_timeout_sec?: number;
|
|
17
|
-
};
|
|
18
10
|
export interface CodexAppServerMcpConfig extends Record<string, unknown> {
|
|
19
11
|
mcp_servers: Record<string, unknown>;
|
|
20
12
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export declare const SANDBOX_PREFIX = "pathgrade-";
|
|
2
1
|
export declare const SANDBOX_MARKER = ".pathgrade-sandbox.json";
|
|
3
|
-
export declare const STALE_SANDBOX_AGE_MS: number;
|
|
4
2
|
interface RemoveSandboxRootOptions {
|
|
5
3
|
remove?: (target: string) => Promise<void>;
|
|
6
4
|
sleep?: (ms: number) => Promise<void>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import * as os from 'os';
|
|
3
3
|
import * as path from 'path';
|
|
4
|
-
|
|
4
|
+
const SANDBOX_PREFIX = 'pathgrade-';
|
|
5
5
|
export const SANDBOX_MARKER = '.pathgrade-sandbox.json';
|
|
6
|
-
|
|
6
|
+
const STALE_SANDBOX_AGE_MS = 24 * 60 * 60 * 1_000;
|
|
7
7
|
let startupCleanup;
|
|
8
8
|
const SANDBOX_REMOVE_RETRY_DELAYS_MS = [
|
|
9
9
|
50,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ToolEvent } from '../tool-events.js';
|
|
2
2
|
import { type CompiledMcpMockSession } from '../sdk/mcp-mock-approvals.js';
|
|
3
|
-
|
|
3
|
+
interface ScriptedMcpDecision {
|
|
4
4
|
decision: 'approve' | 'deny';
|
|
5
5
|
outcome: 'matched' | 'unmatched' | 'protocol_error';
|
|
6
6
|
reason: 'rule_match' | 'no_matching_rule' | 'protocol_error';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type SandboxConfig } from './sandbox.js';
|
|
2
2
|
import type { CommandResult, McpConfigOrigin } from '../types.js';
|
|
3
|
-
export type { McpDeclaration } from './mcp-config.js';
|
|
4
3
|
export interface Workspace {
|
|
5
4
|
readonly path: string;
|
|
6
5
|
readonly mcpConfigPath: string | undefined;
|
|
@@ -26,17 +26,6 @@ export declare function commentMarker(commentId: string): string;
|
|
|
26
26
|
* posted as a GitHub issue comment body.
|
|
27
27
|
*/
|
|
28
28
|
export declare function formatReportMarkdown(report: PathgradeReport, opts: FormatOptions): string;
|
|
29
|
-
/**
|
|
30
|
-
* Render the `### Selection` section for the PR comment. Pure: no fs,
|
|
31
|
-
* no network, no reporter side effects. Three variants:
|
|
32
|
-
*
|
|
33
|
-
* - `global_match` set → "global trigger fired" one-liner, no collapsible.
|
|
34
|
-
* - `skipped` empty + `selected` non-empty → "every eval had a matching
|
|
35
|
-
* change" one-liner.
|
|
36
|
-
* - otherwise → "Ran **X of Y**" line + `<details>` block listing
|
|
37
|
-
* skipped eval paths as inline code.
|
|
38
|
-
*/
|
|
39
|
-
export declare function formatSelectionSection(selection: PathgradeSelectionReport): string;
|
|
40
29
|
export interface PrContext {
|
|
41
30
|
owner: string;
|
|
42
31
|
repo: string;
|
|
@@ -114,7 +114,7 @@ export function formatReportMarkdown(report, opts) {
|
|
|
114
114
|
* - otherwise → "Ran **X of Y**" line + `<details>` block listing
|
|
115
115
|
* skipped eval paths as inline code.
|
|
116
116
|
*/
|
|
117
|
-
|
|
117
|
+
function formatSelectionSection(selection) {
|
|
118
118
|
const out = [];
|
|
119
119
|
out.push('### Selection');
|
|
120
120
|
const total = selection.selected.length + selection.skipped.length;
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/** Maximum characters retained in a prompt/reply preview before truncation. */
|
|
2
|
-
export declare const PREVIEW_MAX_CHARS = 80;
|
|
3
|
-
/** Maximum characters retained in a retry error message before truncation. */
|
|
4
|
-
export declare const RETRY_ERROR_MAX_CHARS = 120;
|
|
5
|
-
/** Ellipsis appended to truncated strings. */
|
|
6
|
-
export declare const TRUNCATION_SUFFIX = "\u2026";
|
|
7
|
-
/** Newline replacement in single-line previews. */
|
|
8
|
-
export declare const NEWLINE_REPLACEMENT = "\u23CE";
|
|
9
1
|
export interface VerboseSink {
|
|
10
2
|
write(line: string): void;
|
|
11
3
|
}
|
|
@@ -19,33 +11,33 @@ export interface VerboseEmitterOptions {
|
|
|
19
11
|
*/
|
|
20
12
|
testName?: string;
|
|
21
13
|
}
|
|
22
|
-
|
|
14
|
+
interface TurnStartArgs {
|
|
23
15
|
turn: number;
|
|
24
16
|
kind: 'agent_start' | 'user_reply';
|
|
25
17
|
message: string;
|
|
26
18
|
}
|
|
27
|
-
|
|
19
|
+
interface ToolEventArgs {
|
|
28
20
|
action: string;
|
|
29
21
|
summary: string;
|
|
30
22
|
}
|
|
31
|
-
|
|
23
|
+
interface TurnEndArgs {
|
|
32
24
|
turn: number;
|
|
33
25
|
durationMs: number;
|
|
34
26
|
outputLines: number;
|
|
35
27
|
messagePreview: string;
|
|
36
28
|
}
|
|
37
|
-
|
|
29
|
+
interface RetryArgs {
|
|
38
30
|
attempt: number;
|
|
39
31
|
maxAttempts: number;
|
|
40
32
|
errorMessage: string;
|
|
41
33
|
}
|
|
42
|
-
|
|
34
|
+
interface ReactionFiredArgs {
|
|
43
35
|
turn: number;
|
|
44
36
|
reactionIndex: number;
|
|
45
37
|
pattern: string;
|
|
46
38
|
reply: string;
|
|
47
39
|
}
|
|
48
|
-
|
|
40
|
+
interface ConversationEndArgs {
|
|
49
41
|
reason: string;
|
|
50
42
|
turns: number;
|
|
51
43
|
durationMs: number;
|
|
@@ -61,9 +53,5 @@ export interface VerboseEmitter {
|
|
|
61
53
|
reactionFired(args: ReactionFiredArgs): void;
|
|
62
54
|
conversationEnd(args: ConversationEndArgs): void;
|
|
63
55
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Build a preview string: strip newlines, truncate to a max length.
|
|
66
|
-
* `null` / `undefined` becomes an empty string so formatting never throws.
|
|
67
|
-
*/
|
|
68
|
-
export declare function preview(text: string | null | undefined, max?: number): string;
|
|
69
56
|
export declare function createVerboseEmitter(opts: VerboseEmitterOptions): VerboseEmitter;
|
|
57
|
+
export {};
|