fetchsandbox-mcp 0.7.10 → 0.7.12
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/README.md +19 -3
- package/dist/client.d.ts +8 -2
- package/dist/client.js +56 -8
- package/dist/client.js.map +1 -1
- package/dist/http.js +11 -1
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +23 -5
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/request_context.d.ts +2 -0
- package/dist/request_context.js.map +1 -1
- package/dist/signin.js +42 -15
- package/dist/signin.js.map +1 -1
- package/dist/tools/find_bugs.d.ts +4 -0
- package/dist/tools/find_bugs.js +4 -1
- package/dist/tools/find_bugs.js.map +1 -1
- package/dist/tools/fix_bug.d.ts +4 -0
- package/dist/tools/fix_bug.js +13 -9
- package/dist/tools/fix_bug.js.map +1 -1
- package/dist/tools/jobs.d.ts +31 -0
- package/dist/tools/jobs.js +59 -5
- package/dist/tools/jobs.js.map +1 -1
- package/dist/tools/list_workflows.d.ts +16 -0
- package/dist/tools/list_workflows.js +26 -6
- package/dist/tools/list_workflows.js.map +1 -1
- package/dist/tools/pack.js +6 -0
- package/dist/tools/pack.js.map +1 -1
- package/dist/tools/prove_fix.d.ts +4 -1
- package/dist/tools/prove_fix.js +12 -4
- package/dist/tools/prove_fix.js.map +1 -1
- package/dist/tools/quickrun.js +7 -4
- package/dist/tools/quickrun.js.map +1 -1
- package/dist/tools/validate_integration.d.ts +4 -4
- package/dist/tools/validate_integration.js +81 -11
- package/dist/tools/validate_integration.js.map +1 -1
- package/dist/tools/verify_behavior.d.ts +7 -0
- package/dist/tools/verify_behavior.js +2 -0
- package/dist/tools/verify_behavior.js.map +1 -1
- package/package.json +1 -1
package/dist/signin.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { buildHeaders, getBaseUrl, ToolError } from "./client.js";
|
|
17
17
|
import { installId, readCredentials, writeCredentials } from "./auth.js";
|
|
18
18
|
import { detectIde } from "./session.js";
|
|
19
|
-
import { isHosted } from "./request_context.js";
|
|
19
|
+
import { currentIdentity, isHosted } from "./request_context.js";
|
|
20
20
|
// Only ever used on a RETRY, when the human has already been shown the code and
|
|
21
21
|
// is mid-sign-in. Long enough to cover a browser round trip, short enough that
|
|
22
22
|
// an agent is never left hanging on someone who walked away.
|
|
@@ -130,20 +130,47 @@ export async function withSignIn(call) {
|
|
|
130
130
|
}
|
|
131
131
|
catch (e) {
|
|
132
132
|
if (e instanceof ToolError && e.status === 401) {
|
|
133
|
-
//
|
|
134
|
-
//
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
146
|
-
"
|
|
133
|
+
// Prefer bounded facts from the account-key gate. Older backends have
|
|
134
|
+
// no reason header, so retain the request-context-only diagnosis.
|
|
135
|
+
// Never echo a raw backend message or credential into hosted guidance.
|
|
136
|
+
const identity = currentIdentity();
|
|
137
|
+
const fallback = identity === undefined
|
|
138
|
+
? "FetchSandbox could not authenticate this hosted operation (HTTP 401). "
|
|
139
|
+
: identity.apiKey
|
|
140
|
+
? "A Bearer token reached the hosted FetchSandbox MCP endpoint and was forwarded, but the backend denied this operation (HTTP 401). The response does not identify the cause. "
|
|
141
|
+
: "No usable Bearer token reached the hosted FetchSandbox MCP endpoint. ";
|
|
142
|
+
const diagnoses = {
|
|
143
|
+
missing_authorization: "The FetchSandbox backend received no Authorization header for this operation. ",
|
|
144
|
+
malformed_authorization: "The FetchSandbox backend received an Authorization header without a usable Bearer token. ",
|
|
145
|
+
unsupported_bearer: "The Bearer token received by the FetchSandbox backend is not in FetchSandbox account API key format. ",
|
|
146
|
+
account_key_unrecognized: "The FetchSandbox backend could not resolve this account API key to a user. It may be unknown, revoked, or no longer linked to an account. ",
|
|
147
|
+
identity_lookup_failed: "FetchSandbox could not look up the account API key because of a server-side identity lookup failure. Keep the current connector authentication and retry after service recovery; replacing the key may not resolve this. ",
|
|
148
|
+
};
|
|
149
|
+
const diagnosis = e.authReason
|
|
150
|
+
? `${diagnoses[e.authReason]}Authentication diagnostic: ${e.authReason} (HTTP 401). `
|
|
151
|
+
: fallback;
|
|
152
|
+
// The transport deliberately forwards only a parsed Bearer token. A
|
|
153
|
+
// bare key/empty scheme therefore looks missing at the backend. Keep
|
|
154
|
+
// both observations so callers do not blame a dropped header or rotate
|
|
155
|
+
// a key when the real issue may be its connection-field format.
|
|
156
|
+
const ingress = identity?.authHeaderState
|
|
157
|
+
? `Hosted MCP authentication input: ${identity.authHeaderState}. ` +
|
|
158
|
+
(identity.authHeaderState === "malformed"
|
|
159
|
+
? "An Authorization header reached the hosted MCP endpoint, but it was not a usable Bearer header; no credential was forwarded. "
|
|
160
|
+
: identity.authHeaderState === "absent"
|
|
161
|
+
? "No Authorization header reached the hosted MCP endpoint on this request. Send it on every protected tool request, not only initialization. "
|
|
162
|
+
: "A usable Bearer header reached the hosted MCP endpoint. ")
|
|
163
|
+
: "";
|
|
164
|
+
const correlation = identity?.requestId && /^[a-f0-9]{8}$/.test(identity.requestId)
|
|
165
|
+
? `MCP request ID: ${identity.requestId}. ` : "";
|
|
166
|
+
const setup = e.authReason === "identity_lookup_failed" ? "" :
|
|
167
|
+
"Configure this hosted connector with Authorization: Bearer <FetchSandbox account API key>. " +
|
|
168
|
+
"If its Bearer authentication field adds the scheme, enter only the key there. " +
|
|
169
|
+
"Use your account key from https://fetchsandbox.com/keys, not a synthetic provider credential. " +
|
|
170
|
+
"FETCHSANDBOX_API_KEY is a local process environment variable, not a hosted HTTP authentication header. ";
|
|
171
|
+
throw new ToolError(diagnosis + ingress + correlation + setup +
|
|
172
|
+
"After authentication works, if your session was created anonymously, start a fresh owned validate_integration session; an existing anonymous session cannot be upgraded by signing in. " +
|
|
173
|
+
"If your session already has an owner, retry the same owned session and run after repairing authentication; do not create a replacement attempt.", 401, e.authReason);
|
|
147
174
|
}
|
|
148
175
|
throw e;
|
|
149
176
|
}
|
package/dist/signin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signin.js","sourceRoot":"","sources":["../src/signin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAoB,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"signin.js","sourceRoot":"","sources":["../src/signin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAoB,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEjE,gFAAgF;AAChF,+EAA+E;AAC/E,6DAA6D;AAC7D,MAAM,aAAa,GAAG,MAAM,CAAC;AAU7B,KAAK,UAAU,IAAI,CAAI,IAAY,EAAE,IAAa;IAChD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,UAAU,EAAE,GAAG,IAAI,EAAE,EAAE;QAChD,MAAM,EAAE,MAAM;QACd,0EAA0E;QAC1E,uEAAuE;QACvE,OAAO,EAAE,YAAY,CAAC,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;QAC7D,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC,CAAC;IACH,IAAI,IAAI,GAAY,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E,CAAC;YACZ,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;YAC7D,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,GAAG,IAAI,CAAC;gBACf,OAAO,MAAM,IAAI,EAAE,CAAC;YACtB,CAAC;YACD,MAAM,IAAI,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC;QACnD,CAAC;QAED,IAAI,OAA2B,CAAC;QAChC,IAAI,CAAC;YACH,OAAO,GAAG,MAAM,eAAe,EAAE,CAAC;QACpC,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,CAAC,CAAC,CAAC,yCAAyC;QACpD,CAAC;QACD,OAAO,GAAG,OAAO,CAAC;QAClB,MAAM,IAAI,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC;IACnD,CAAC;AACH,CAAC"}
|
|
@@ -26,6 +26,10 @@ export declare const findBugsTool: {
|
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
export declare function runFindBugs(input: FindBugsInput): Promise<{
|
|
29
|
+
status?: string;
|
|
30
|
+
job_id?: string;
|
|
31
|
+
next_tool_call?: unknown;
|
|
32
|
+
agent_guidance?: string;
|
|
29
33
|
available: boolean;
|
|
30
34
|
bugs: string | null;
|
|
31
35
|
next_actions?: unknown;
|
package/dist/tools/find_bugs.js
CHANGED
|
@@ -16,7 +16,8 @@ import { startAndPoll } from "./jobs.js";
|
|
|
16
16
|
import { packDirToBase64, resolveWorkspaceDir } from "./pack.js";
|
|
17
17
|
export const findBugsTool = {
|
|
18
18
|
name: "find_bugs",
|
|
19
|
-
description: "
|
|
19
|
+
description: "Long work returns status:running and next_tool_call:get_job within a short response. Follow that SAME job until done; never repeat this tool to poll. " +
|
|
20
|
+
"FIRST STEP for any API-integration bug — webhooks, payments, auth, email, " +
|
|
20
21
|
"SMS, subscriptions. Reach for this the moment a user reports a symptom in " +
|
|
21
22
|
"an app that talks to a provider: 'customers charged twice', 'the webhook " +
|
|
22
23
|
"fires but nothing happens', 'their balance is wrong', 'we keep emailing a " +
|
|
@@ -70,6 +71,8 @@ export async function runFindBugs(input) {
|
|
|
70
71
|
const raw = await startAndPoll("/api/mcp/find_bugs", body, {
|
|
71
72
|
maxMs: (timeout_s + 180) * 1000,
|
|
72
73
|
});
|
|
74
|
+
if (raw.status === "running")
|
|
75
|
+
return { ...raw, available: false, bugs: null, engine: "fetchsandbox", packed_bytes: bytes };
|
|
73
76
|
if (raw.status === "error") {
|
|
74
77
|
throw new ToolError(`FetchSandbox discovery failed: ${raw.error ?? "unknown error"}`);
|
|
75
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find_bugs.js","sourceRoot":"","sources":["../../src/tools/find_bugs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAejE,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,WAAW;IACjB,WAAW,EACT,4EAA4E;QAC5E,4EAA4E;QAC5E,2EAA2E;QAC3E,4EAA4E;QAC5E,yDAAyD;QACzD,yEAAyE;QACzE,6EAA6E;QAC7E,6EAA6E;QAC7E,4EAA4E;QAC5E,4EAA4E;QAC5E,yEAAyE;QACzE,4EAA4E;QAC5E,2EAA2E;QAC3E,wDAAwD;IAC1D,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,qEAAqE;oBACrE,iEAAiE;aACpE;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,E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KAAgB,IAAI,eAAe,EAAE,CAC/F,CAAC;IACJ,CAAC;IACD,OAAO;QACL,SAAS,EAAE,IAAI;QACf,IAAI,EAAG,GAAG,CAAC,IAAsB,IAAI,IAAI;QACzC,2EAA2E;QAC3E,0EAA0E;QAC1E,4EAA4E;QAC5E,2EAA2E;QAC3E,0EAA0E;QAC1E,wEAAwE;QACxE,qCAAqC;QACrC,EAAE;QACF,qEAAqE;QACrE,6EAA6E;QAC7E,wCAAwC;QACxC,YAAY,EAAE,GAAG,CAAC,YAAY,IAAI,SAAS;QAC3C,kEAAkE;QAClE,qEAAqE;QACrE,EAAE;QACF,yEAAyE;QACzE,qEAAqE;QACrE,iEAAiE;QACjE,yEAAyE;QACzE,gBAAgB,EAAG,GAAG,CAAC,gBAA2B,IAAI,SAAS;QAC/D,kBAAkB,EAAE,GAAG,CAAC,kBAAkB,IAAI,SAAS;QACvD,MAAM,EAAG,GAAG,CAAC,MAAiB,IAAI,cAAc;QAChD,YAAY,EAAE,KAAK;KACpB,CAAC;AACJ,CAAC"}
|
package/dist/tools/fix_bug.d.ts
CHANGED
|
@@ -37,6 +37,10 @@ export declare const fixBugTool: {
|
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
export declare function runFixBug(input: FixBugInput): Promise<{
|
|
40
|
+
status?: string;
|
|
41
|
+
job_id?: string;
|
|
42
|
+
next_tool_call?: unknown;
|
|
43
|
+
agent_guidance?: string;
|
|
40
44
|
/** Typed next step from the server. Every entry point carries the exit:
|
|
41
45
|
* a finding is a hypothesis until prove_fix measures it. */
|
|
42
46
|
next_actions?: unknown;
|
package/dist/tools/fix_bug.js
CHANGED
|
@@ -5,25 +5,27 @@
|
|
|
5
5
|
* ships the project to the FetchSandbox runtime, which authors a MINIMAL fix —
|
|
6
6
|
* grounded by the brain's remediation pattern for that failure class — and
|
|
7
7
|
* returns a `git diff` PROPOSAL. The user's working tree is never modified; the
|
|
8
|
-
* agent reviews the diff
|
|
8
|
+
* agent reviews the diff, proves it against the still-buggy project, then applies it.
|
|
9
9
|
*
|
|
10
|
-
* Calls POST /api/mcp/fix_bug. The diff is NOT a proof
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Calls POST /api/mcp/fix_bug. The diff is NOT a proof. Before applying it,
|
|
11
|
+
* call prove_fix so both the original and candidate execute under the same
|
|
12
|
+
* failure probe. FetchSandbox proposes; recorded execution determines the verdict.
|
|
13
13
|
*/
|
|
14
14
|
import { ToolError } from "../client.js";
|
|
15
15
|
import { startAndPoll } from "./jobs.js";
|
|
16
16
|
import { packDirToBase64, resolveWorkspaceDir } from "./pack.js";
|
|
17
17
|
export const fixBugTool = {
|
|
18
18
|
name: "fix_bug",
|
|
19
|
-
description: "
|
|
19
|
+
description: "Long work returns status:running and next_tool_call:get_job within a short response. Follow that SAME job until done; never repeat this tool to poll. " +
|
|
20
|
+
"FetchSandbox remediation: get a proposed fix for a specific bug in YOUR " +
|
|
20
21
|
"code. The 'fix' step after find_bugs. Ships the project to the " +
|
|
21
22
|
"FetchSandbox runtime, which authors a MINIMAL fix grounded in the known " +
|
|
22
23
|
"remediation for that failure class and returns a git diff — it does NOT " +
|
|
23
|
-
"modify your files
|
|
24
|
-
"the
|
|
25
|
-
"
|
|
26
|
-
"
|
|
24
|
+
"modify your files. Review the diff, then call prove_fix with the diff " +
|
|
25
|
+
"and the STILL-BUGGY project BEFORE applying it. Apply the patch only " +
|
|
26
|
+
"after inspecting that result. The diff is a proposal, not a proof; " +
|
|
27
|
+
"quickrun and verify_behavior on reference handlers do not prove this " +
|
|
28
|
+
"change on your application. Runs for up to a few minutes.",
|
|
27
29
|
inputSchema: {
|
|
28
30
|
type: "object",
|
|
29
31
|
properties: {
|
|
@@ -77,6 +79,8 @@ export async function runFixBug(input) {
|
|
|
77
79
|
const raw = await startAndPoll("/api/mcp/fix_bug", body, {
|
|
78
80
|
maxMs: (timeout_s + 180) * 1000,
|
|
79
81
|
});
|
|
82
|
+
if (raw.status === "running")
|
|
83
|
+
return { ...raw, available: false, diff: null, summary: null, engine: "fetchsandbox", packed_bytes: bytes };
|
|
80
84
|
if (raw.status === "error") {
|
|
81
85
|
throw new ToolError(`FetchSandbox remediation failed: ${raw.error ?? "unknown error"}`);
|
|
82
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fix_bug.js","sourceRoot":"","sources":["../../src/tools/fix_bug.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAkBjE,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,SAAS;IACf,WAAW,EACT,0EAA0E;QAC1E,iEAAiE;QACjE,0EAA0E;QAC1E,0EAA0E;QAC1E,
|
|
1
|
+
{"version":3,"file":"fix_bug.js","sourceRoot":"","sources":["../../src/tools/fix_bug.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAkBjE,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,SAAS;IACf,WAAW,EACT,wJAAwJ;QACxJ,0EAA0E;QAC1E,iEAAiE;QACjE,0EAA0E;QAC1E,0EAA0E;QAC1E,wEAAwE;QACxE,uEAAuE;QACvE,qEAAqE;QACrE,uEAAuE;QACvE,2DAA2D;IAC7D,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,GAAG,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,qEAAqE;oBACrE,2BAA2B;aAC9B;YACD,WAAW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@ -3,6 +3,37 @@ export interface JobStatus {
|
|
|
3
3
|
error?: string | null;
|
|
4
4
|
[k: string]: unknown;
|
|
5
5
|
}
|
|
6
|
+
export declare function withJobResponseBudget<T>(ms: number, action: () => Promise<T>): Promise<T>;
|
|
7
|
+
export interface PendingJob {
|
|
8
|
+
status: "running";
|
|
9
|
+
job_id: string;
|
|
10
|
+
next_tool_call: {
|
|
11
|
+
name: "get_job";
|
|
12
|
+
arguments: {
|
|
13
|
+
job_id: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
agent_guidance: string;
|
|
17
|
+
elapsed_s?: number;
|
|
18
|
+
job_kind?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function pendingJob(jobId: string, progress?: JobStatus): PendingJob;
|
|
21
|
+
export declare const getJobTool: {
|
|
22
|
+
readonly name: "get_job";
|
|
23
|
+
readonly description: "Retrieve the SAME running find_bugs, fix_bug, prove_fix or verify_behavior job. Follow next_tool_call until status is done or error. Never restart the original tool to poll. A running response is not proof; only the completed measured verdict and receipt can establish a pass.";
|
|
24
|
+
readonly inputSchema: {
|
|
25
|
+
readonly type: "object";
|
|
26
|
+
readonly properties: {
|
|
27
|
+
readonly job_id: {
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
readonly description: "Exact job_id returned by the original call.";
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
readonly required: readonly ["job_id"];
|
|
33
|
+
readonly additionalProperties: false;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export declare function runGetJob(jobId: string): Promise<JobStatus>;
|
|
6
37
|
export declare function startAndPoll(startPath: string, body: unknown, opts?: {
|
|
7
38
|
maxMs?: number;
|
|
8
39
|
intervalMs?: number;
|
package/dist/tools/jobs.js
CHANGED
|
@@ -5,12 +5,50 @@
|
|
|
5
5
|
* so we START a job (fast POST → job_id) then POLL a fast GET until it finishes.
|
|
6
6
|
* Every HTTP call is short, so nothing hits the CF timeout.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
|
+
import { getJson, postJsonLong, ToolError } from "../client.js";
|
|
10
|
+
// Bound each MCP response, not the existing backend task. Direct library users
|
|
11
|
+
// retain the existing blocking contract; concurrent requests have isolated budgets.
|
|
12
|
+
const responseBudget = new AsyncLocalStorage();
|
|
13
|
+
export function withJobResponseBudget(ms, action) {
|
|
14
|
+
return responseBudget.run(Math.min(responseBudget.getStore() ?? Infinity, Date.now() + ms), action);
|
|
15
|
+
}
|
|
16
|
+
export function pendingJob(jobId, progress) {
|
|
17
|
+
const elapsed = progress?.elapsed_s;
|
|
18
|
+
const facts = typeof elapsed === "number" && Number.isFinite(elapsed) && elapsed >= 0
|
|
19
|
+
? { elapsed_s: elapsed, ...(typeof progress?.job_kind === "string" && /^[a-z_]{1,40}$/.test(progress.job_kind) ? { job_kind: progress.job_kind } : {}) } : {};
|
|
20
|
+
return { status: "running", job_id: jobId,
|
|
21
|
+
next_tool_call: { name: "get_job", arguments: { job_id: jobId } },
|
|
22
|
+
...facts,
|
|
23
|
+
agent_guidance: "No completed result has been received for this SAME backend job. Call get_job with this job_id until done. Do not start another job, apply the proposed fix, or claim a pass while awaiting its result. Only elapsed_s is measured elapsed time; do not infer a timeout from poll count or model estimates." };
|
|
24
|
+
}
|
|
25
|
+
export const getJobTool = {
|
|
26
|
+
name: "get_job",
|
|
27
|
+
description: "Retrieve the SAME running find_bugs, fix_bug, prove_fix or verify_behavior job. Follow next_tool_call until status is done or error. Never restart the original tool to poll. A running response is not proof; only the completed measured verdict and receipt can establish a pass.",
|
|
28
|
+
inputSchema: { type: "object", properties: { job_id: { type: "string", description: "Exact job_id returned by the original call." } }, required: ["job_id"], additionalProperties: false },
|
|
29
|
+
};
|
|
30
|
+
export async function runGetJob(jobId) {
|
|
31
|
+
if (!/^[a-zA-Z0-9_-]{1,128}$/.test(jobId))
|
|
32
|
+
throw new ToolError("Invalid job_id");
|
|
33
|
+
return withJobResponseBudget(20_000, () => pollJob(jobId));
|
|
34
|
+
}
|
|
9
35
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
10
36
|
export async function startAndPoll(startPath, body, opts) {
|
|
11
37
|
const maxMs = opts?.maxMs ?? 15 * 60_000;
|
|
12
38
|
const intervalMs = opts?.intervalMs ?? 4000;
|
|
13
|
-
|
|
39
|
+
// Creating a task is not a read. A lost start response must not cause the
|
|
40
|
+
// HTTP helper to submit a second expensive task. Reuse its no-retry path.
|
|
41
|
+
let start;
|
|
42
|
+
try {
|
|
43
|
+
const remaining = (responseBudget.getStore() ?? Date.now() + 30_000) - Date.now();
|
|
44
|
+
if (remaining <= 0)
|
|
45
|
+
throw new ToolError("Response budget exhausted before job submission");
|
|
46
|
+
start = await postJsonLong(startPath, body, Math.min(30_000, remaining));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
const detail = error instanceof Error ? error.message : "request failed";
|
|
50
|
+
throw new ToolError(`Could not confirm job creation; do not automatically resubmit. ${detail}`, error instanceof ToolError ? error.status : undefined, error instanceof ToolError ? error.authReason : undefined);
|
|
51
|
+
}
|
|
14
52
|
if (!start.job_id) {
|
|
15
53
|
throw new ToolError(`Could not start job: ${start.error ?? "no job_id returned"}`);
|
|
16
54
|
}
|
|
@@ -27,13 +65,29 @@ export async function startAndPoll(startPath, body, opts) {
|
|
|
27
65
|
export async function pollJob(jobId, opts) {
|
|
28
66
|
const maxMs = opts?.maxMs ?? 15 * 60_000;
|
|
29
67
|
const intervalMs = opts?.intervalMs ?? 4000;
|
|
30
|
-
const
|
|
68
|
+
const budget = Math.min(maxMs, Math.max(0, (responseBudget.getStore() ?? Date.now() + maxMs) - Date.now()));
|
|
69
|
+
const deadline = Date.now() + budget;
|
|
70
|
+
let progress;
|
|
31
71
|
while (Date.now() < deadline) {
|
|
32
|
-
|
|
33
|
-
|
|
72
|
+
let st;
|
|
73
|
+
try {
|
|
74
|
+
st = await getJson(`/api/mcp/jobs/${jobId}`, { timeoutMs: Math.max(1, deadline - Date.now()) });
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
if (Date.now() >= deadline) {
|
|
78
|
+
if (budget < maxMs)
|
|
79
|
+
return { ...pendingJob(jobId, progress), poll_read_timed_out: true };
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
34
84
|
if (st.status !== "running")
|
|
35
85
|
return st;
|
|
86
|
+
progress = st;
|
|
87
|
+
await sleep(Math.min(intervalMs, Math.max(0, deadline - Date.now())));
|
|
36
88
|
}
|
|
89
|
+
if (budget < maxMs)
|
|
90
|
+
return { ...pendingJob(jobId, progress) };
|
|
37
91
|
throw new ToolError(`Timed out after ${Math.round(maxMs / 60000)}min waiting on ` +
|
|
38
92
|
`${opts?.startPath ?? "job " + jobId}.`);
|
|
39
93
|
}
|
package/dist/tools/jobs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../../src/tools/jobs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../../src/tools/jobs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAchE,+EAA+E;AAC/E,oFAAoF;AACpF,MAAM,cAAc,GAAG,IAAI,iBAAiB,EAAU,CAAC;AACvD,MAAM,UAAU,qBAAqB,CAAI,EAAU,EAAE,MAAwB;IAC3E,OAAO,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,QAAQ,EAAE,IAAI,CAAC,GAAG,EAA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E,CAAC;gBAC3B,IAAI,MAAM,GAAG,KAAK;oBAAE,OAAO,EAAC,GAAG,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,mBAAmB,EAAE,IAAI,EAAC,CAAC;gBACvF,MAAM;YACR,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;QACD,IAAI,EAAE,CAAC,MAAM,KAAK,SAAS;YAAE,OAAO,EAAE,CAAC;QACvC,QAAQ,GAAG,EAAE,CAAC;QACd,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC;IACD,IAAI,MAAM,GAAG,KAAK;QAAE,OAAO,EAAC,GAAG,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAC,CAAC;IAC5D,MAAM,IAAI,SAAS,CACjB,mBAAmB,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,iBAAiB;QAC3D,GAAG,IAAI,EAAE,SAAS,IAAI,MAAM,GAAG,KAAK,GAAG,CAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -3,8 +3,12 @@ export interface ListWorkflowsInput {
|
|
|
3
3
|
/** A human name like "resend". The backend's resolve_spec_id has always
|
|
4
4
|
* accepted these; only this client insisted on the hash. */
|
|
5
5
|
spec_slug?: string;
|
|
6
|
+
/** Inspect one exact catalog id or name without expanding every workflow. */
|
|
7
|
+
workflow_name?: string;
|
|
6
8
|
}
|
|
7
9
|
export interface WorkflowItem {
|
|
10
|
+
/** Keep provider-defined outcome and verification fields in detail mode. */
|
|
11
|
+
[field: string]: unknown;
|
|
8
12
|
id: string;
|
|
9
13
|
name: string;
|
|
10
14
|
description?: string;
|
|
@@ -15,13 +19,20 @@ export interface ScenarioItem {
|
|
|
15
19
|
description: string;
|
|
16
20
|
how_to_run: string;
|
|
17
21
|
}
|
|
22
|
+
export interface CrossServiceWorkflow {
|
|
23
|
+
workflow: string;
|
|
24
|
+
services: string[];
|
|
25
|
+
run_with: string;
|
|
26
|
+
}
|
|
18
27
|
export interface ListWorkflowsResponse {
|
|
19
28
|
spec_id: string;
|
|
20
29
|
workflows: Array<{
|
|
30
|
+
[field: string]: unknown;
|
|
21
31
|
id: string;
|
|
22
32
|
name: string;
|
|
23
33
|
description: string;
|
|
24
34
|
steps_count: number;
|
|
35
|
+
steps?: unknown[];
|
|
25
36
|
}>;
|
|
26
37
|
/** WHAT CAN GO WRONG, next to what can go right.
|
|
27
38
|
*
|
|
@@ -30,6 +41,7 @@ export interface ListWorkflowsResponse {
|
|
|
30
41
|
* asked for bounce-after-payment recovery by name. The failure modes were
|
|
31
42
|
* a separate tool nothing pointed at. */
|
|
32
43
|
scenarios: ScenarioItem[];
|
|
44
|
+
cross_service_available?: CrossServiceWorkflow[];
|
|
33
45
|
}
|
|
34
46
|
export declare const listWorkflowsTool: {
|
|
35
47
|
readonly name: "list_workflows";
|
|
@@ -45,6 +57,10 @@ export declare const listWorkflowsTool: {
|
|
|
45
57
|
readonly type: "string";
|
|
46
58
|
readonly description: string;
|
|
47
59
|
};
|
|
60
|
+
readonly workflow_name: {
|
|
61
|
+
readonly type: "string";
|
|
62
|
+
readonly description: "Exact workflow id or name returned by this catalog. Returns its full definition, including steps and outcome rules, without executing it; omit for summaries.";
|
|
63
|
+
};
|
|
48
64
|
};
|
|
49
65
|
readonly additionalProperties: false;
|
|
50
66
|
};
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { getJson, ToolError } from "../client.js";
|
|
2
2
|
export const listWorkflowsTool = {
|
|
3
3
|
name: "list_workflows",
|
|
4
|
-
description: "List the named, runnable workflows for a
|
|
4
|
+
description: "List the named, runnable workflows for a known provider slug or imported spec. " +
|
|
5
5
|
"Workflows are realistic multi-step API journeys (e.g. 'create customer " +
|
|
6
|
-
"→ attach payment method → create subscription').
|
|
7
|
-
"
|
|
6
|
+
"→ attach payment method → create subscription'). Known provider slugs need no import. " +
|
|
7
|
+
"Use this for exploration (\"what can I do?\", \"show me the flows\") " +
|
|
8
8
|
"OR before run_all_workflows when the user wants a SCOPED validation: " +
|
|
9
9
|
"list, filter by user intent (\"checkout\", \"webhooks\"), then pass the " +
|
|
10
10
|
"matching ids as `workflow_names` to run_all_workflows. " +
|
|
11
|
+
"Default results are summaries. Pass workflow_name with an exact returned id or name " +
|
|
12
|
+
"to inspect that workflow's full definition, including request bodies, assertions, outcomes and invariants; this does not execute it. " +
|
|
11
13
|
"Returns the workflows AND the failure scenarios this spec can " +
|
|
12
14
|
"simulate — each with a plain description and the exact call to run it. " +
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
+
"When cross_service_available is present, use each exact run_with invocation: " +
|
|
16
|
+
"cross-provider workflows use the returned namespace, not this provider's slug. " +
|
|
17
|
+
"These curated workflows exercise provider behavior; they do not verify the user's app. " +
|
|
18
|
+
"Choose relevant scenarios from the inspected workflow and user goal; ask only about ambiguous " +
|
|
19
|
+
"business requirements. Do not guess scenario names.",
|
|
15
20
|
inputSchema: {
|
|
16
21
|
type: "object",
|
|
17
22
|
properties: {
|
|
@@ -24,6 +29,10 @@ export const listWorkflowsTool = {
|
|
|
24
29
|
description: "A human name like 'resend' or 'stripe'. Use this when you do not " +
|
|
25
30
|
"have a spec_id — you do not need to look one up first.",
|
|
26
31
|
},
|
|
32
|
+
workflow_name: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "Exact workflow id or name returned by this catalog. Returns its full definition, including steps and outcome rules, without executing it; omit for summaries.",
|
|
35
|
+
},
|
|
27
36
|
},
|
|
28
37
|
additionalProperties: false,
|
|
29
38
|
},
|
|
@@ -33,9 +42,19 @@ export async function runListWorkflows(input) {
|
|
|
33
42
|
if (!ref)
|
|
34
43
|
throw new ToolError("Pass spec_id or spec_slug (e.g. 'resend').");
|
|
35
44
|
const raw = await getJson(`/api/specs/${encodeURIComponent(ref)}/workflows`);
|
|
45
|
+
let workflows = raw.workflows || [];
|
|
46
|
+
if (input.workflow_name !== undefined) {
|
|
47
|
+
const name = input.workflow_name.trim();
|
|
48
|
+
const selected = workflows.filter(w => w.id === name || w.name === name);
|
|
49
|
+
if (!name || selected.length === 0) {
|
|
50
|
+
throw new ToolError(`No workflow exactly matches ${JSON.stringify(name)} for ${ref}. Available workflow ids/names: ${JSON.stringify(workflows.map(w => ({ id: w.id, name: w.name })))}. Use an exact id or name from this catalog; cross-service workflows use their returned run_with invocation.`);
|
|
51
|
+
}
|
|
52
|
+
workflows = selected;
|
|
53
|
+
}
|
|
36
54
|
return {
|
|
37
55
|
spec_id: ref,
|
|
38
|
-
workflows:
|
|
56
|
+
workflows: workflows.map((w) => ({
|
|
57
|
+
...(input.workflow_name !== undefined ? w : {}),
|
|
39
58
|
id: w.id || w.name || "",
|
|
40
59
|
name: w.name || w.id || "",
|
|
41
60
|
description: w.description || "",
|
|
@@ -50,6 +69,7 @@ export async function runListWorkflows(input) {
|
|
|
50
69
|
description: s.description || "",
|
|
51
70
|
how_to_run: s.how_to_run || "",
|
|
52
71
|
})),
|
|
72
|
+
...(raw.cross_service_available ? { cross_service_available: raw.cross_service_available } : {}),
|
|
53
73
|
};
|
|
54
74
|
}
|
|
55
75
|
//# sourceMappingURL=list_workflows.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list_workflows.js","sourceRoot":"","sources":["../../src/tools/list_workflows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"list_workflows.js","sourceRoot":"","sources":["../../src/tools/list_workflows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AA0DlD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,iFAAiF;QACjF,yEAAyE;QACzE,wF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B,CAAC,CAAC;QACH,GAAG,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAC,uBAAuB,EAAE,GAAG,CAAC,uBAAuB,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/F,CAAC;AACJ,CAAC"}
|
package/dist/tools/pack.js
CHANGED
|
@@ -26,6 +26,11 @@ const EXCLUDES = [
|
|
|
26
26
|
"build",
|
|
27
27
|
"coverage",
|
|
28
28
|
".DS_Store",
|
|
29
|
+
// Claude's project MCP config can contain the caller's disposable or real
|
|
30
|
+
// API key. It is client configuration, never application source.
|
|
31
|
+
".mcp.json",
|
|
32
|
+
".mcp.*.json",
|
|
33
|
+
"mcp.json",
|
|
29
34
|
// AGENT INSTRUCTION FILES ARE NEVER SHIPPED.
|
|
30
35
|
//
|
|
31
36
|
// The analysis runtime runs its agent with cwd set to the unpacked
|
|
@@ -97,6 +102,7 @@ const MAX_TAR_BYTES = 40 * 1024 * 1024;
|
|
|
97
102
|
* left silently cannot.
|
|
98
103
|
*/
|
|
99
104
|
const SECRET_SHAPES = [
|
|
105
|
+
["FetchSandbox API key", /\bfsk_[A-Za-z0-9_-]{20,}\b/],
|
|
100
106
|
["AWS access key", /\bAKIA[0-9A-Z]{16}\b/],
|
|
101
107
|
["private key block", /-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----/],
|
|
102
108
|
["Stripe secret key (live)", /\bsk_live_[A-Za-z0-9]{20,}/],
|
package/dist/tools/pack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pack.js","sourceRoot":"","sources":["../../src/tools/pack.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,SAAS,EACT,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,MAAM,EACN,QAAQ,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAA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Ae,EAAE,GAAG,CAAC,CAAC;QAChC,IAAI,CAAC;YACH,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE;gBACxB,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE;gBAC9C,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC;aACpC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,MAAM,GAAI,CAAyB,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YACnE,MAAM,IAAI,SAAS,CACjB,6CAA6C,MAAM,IAAK,CAAW,CAAC,OAAO,EAAE,CAC9E,CAAC;QACJ,CAAC;QACD,qBAAqB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAEpC,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;QAClC,IAAI,GAAG,CAAC,MAAM,GAAG,aAAa,EAAE,CAAC;YAC/B,MAAM,IAAI,SAAS,CACjB,cAAc,CAAC,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAsB;gBACnE,GAAG,aAAa,GAAG,OAAO,6CAA6C;gBACvE,gEAAgE,CACnE,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;IAC5D,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -18,7 +18,7 @@ export declare const proveFixTool: {
|
|
|
18
18
|
};
|
|
19
19
|
readonly bug: {
|
|
20
20
|
readonly type: "string";
|
|
21
|
-
readonly description:
|
|
21
|
+
readonly description: string;
|
|
22
22
|
};
|
|
23
23
|
readonly scenario: {
|
|
24
24
|
readonly type: "string";
|
|
@@ -42,6 +42,9 @@ export declare const proveFixTool: {
|
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
44
|
export declare function runProveFix(input: ProveFixInput): Promise<{
|
|
45
|
+
status?: string;
|
|
46
|
+
job_id?: string;
|
|
47
|
+
next_tool_call?: unknown;
|
|
45
48
|
green_allowed: boolean;
|
|
46
49
|
state?: string;
|
|
47
50
|
reproduced?: boolean;
|
package/dist/tools/prove_fix.js
CHANGED
|
@@ -17,11 +17,14 @@ import { startAndPoll } from "./jobs.js";
|
|
|
17
17
|
import { packDirToBase64, resolveWorkspaceDir } from "./pack.js";
|
|
18
18
|
export const proveFixTool = {
|
|
19
19
|
name: "prove_fix",
|
|
20
|
-
description: "
|
|
21
|
-
"
|
|
20
|
+
description: "Long work returns status:running and next_tool_call:get_job within a short response. Follow that SAME job until done; never repeat this tool to poll. " +
|
|
21
|
+
"THE PROOF STEP. The only way to establish that a fix actually works, and " +
|
|
22
|
+
"produces an own-code proof receipt. " +
|
|
22
23
|
"Ship the STILL-BUGGY project plus your proposed diff: FetchSandbox applies " +
|
|
23
24
|
"the diff to a copy and runs the SAME failure probe against the buggy and " +
|
|
24
|
-
"the fixed tree
|
|
25
|
+
"the fixed tree. Inspect the receipt's provider modes: a recording double, " +
|
|
26
|
+
"a twin and an original provider are different evidence scopes. " +
|
|
27
|
+
"Green ONLY on a measured " +
|
|
25
28
|
"flip — the bug demonstrably present before, demonstrably gone after. " +
|
|
26
29
|
"CALL THIS BEFORE YOU WRITE THE FIX TO DISK. prove_fix needs the broken " +
|
|
27
30
|
"tree to reproduce against; applying the diff first makes a measured proof " +
|
|
@@ -38,7 +41,10 @@ export const proveFixTool = {
|
|
|
38
41
|
diff: { type: "string", description: "The unified diff returned by fix_bug." },
|
|
39
42
|
bug: {
|
|
40
43
|
type: "string",
|
|
41
|
-
description: "The finding being fixed
|
|
44
|
+
description: "The finding being fixed AND the user's acceptance criteria: required " +
|
|
45
|
+
"app operations, expected state, ownership boundaries, wire types/units " +
|
|
46
|
+
"and readback checks. Preserve the requested scope; do not reduce a " +
|
|
47
|
+
"workflow request to a single symptom. Used to select/generate the probe.",
|
|
42
48
|
},
|
|
43
49
|
scenario: {
|
|
44
50
|
type: "string",
|
|
@@ -108,6 +114,8 @@ export async function runProveFix(input) {
|
|
|
108
114
|
// (~5 min) + two probe runs (buggy + fixed). Returns as soon as it's done.
|
|
109
115
|
maxMs: (timeout_s * 3 + 360) * 1000,
|
|
110
116
|
});
|
|
117
|
+
if (raw.status === "running")
|
|
118
|
+
return { ...raw, green_allowed: false, state: "running", engine: "fetchsandbox" };
|
|
111
119
|
if (raw.status === "error") {
|
|
112
120
|
throw new ToolError(`FetchSandbox prove failed: ${raw.error ?? "unknown error"}`);
|
|
113
121
|
}
|