@cursor/july 0.1.12 → 0.1.15
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/bin/agent-serve.js +32 -9
- package/dist/channels/github/api.d.ts.map +1 -1
- package/dist/channels/github/api.js +11 -4
- package/dist/channels/github/cursor-account.d.ts +21 -1
- package/dist/channels/github/cursor-account.d.ts.map +1 -1
- package/dist/channels/github/cursor-account.js +29 -1
- package/dist/channels/github/github-channel.d.ts.map +1 -1
- package/dist/channels/github/github-channel.js +1 -1
- package/dist/channels/slack/api.d.ts +9 -0
- package/dist/channels/slack/api.d.ts.map +1 -1
- package/dist/channels/slack/api.js +40 -7
- package/dist/channels/slack/eval-directive.d.ts +3 -0
- package/dist/channels/slack/eval-directive.d.ts.map +1 -1
- package/dist/channels/slack/eval-directive.js +20 -1
- package/dist/channels/slack/post-update-delivery.d.ts +85 -0
- package/dist/channels/slack/post-update-delivery.d.ts.map +1 -0
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +3 -3
- package/dist/docs/assets/{app.Dh_JkJjI.js → app.DpdGZTLe.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.D2d8CfFS.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.CptQNLkR.js → VPLocalSearchBox.IB-0QqIT.js} +1 -1
- package/dist/docs/assets/chunks/{theme.DWflH-LQ.js → theme.-fYBoNtR.js} +2 -2
- package/dist/docs/assets/{evals.md.DAgEc_hL.js → evals.md.DYOjkRCX.js} +10 -4
- package/dist/docs/assets/{evals.md.DAgEc_hL.lean.js → evals.md.DYOjkRCX.lean.js} +1 -1
- package/dist/docs/assets/{reference_cli.md.B74NrVzb.js → reference_cli.md.DnYfr5V2.js} +4 -1
- package/dist/docs/assets/{reference_http-api.md.Dx_nmDG6.js → reference_http-api.md.BncLd3PZ.js} +2 -2
- package/dist/docs/assets/{reference_http-api.md.Dx_nmDG6.lean.js → reference_http-api.md.BncLd3PZ.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +3 -3
- package/dist/docs/concepts.html +3 -3
- package/dist/docs/deployment.html +3 -3
- package/dist/docs/evals.html +13 -7
- package/dist/docs/example-agents/approval-buddy.html +3 -3
- package/dist/docs/example-agents/benny.html +3 -3
- package/dist/docs/example-agents/bugbot.html +3 -3
- package/dist/docs/example-agents/codebase-wiki.html +3 -3
- package/dist/docs/example-agents/codeowners-review.html +3 -3
- package/dist/docs/example-agents/concierge.html +3 -3
- package/dist/docs/example-agents/fsd.html +3 -3
- package/dist/docs/example-agents/index.html +3 -3
- package/dist/docs/example-agents/knowledge-base.html +3 -3
- package/dist/docs/example-agents/oncall.html +3 -3
- package/dist/docs/example-agents/security-reviewer.html +3 -3
- package/dist/docs/example-agents/slack-agent.html +3 -3
- package/dist/docs/example-agents/weather-agent.html +3 -3
- package/dist/docs/guides/agent-to-agent.html +3 -3
- package/dist/docs/guides/cloud-runtime.html +3 -3
- package/dist/docs/guides/github.html +3 -3
- package/dist/docs/guides/human-in-the-loop.html +3 -3
- package/dist/docs/guides/mcp-oauth.html +3 -3
- package/dist/docs/guides/slack.html +3 -3
- package/dist/docs/guides/webhooks.html +3 -3
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +3 -3
- package/dist/docs/index.html +3 -3
- package/dist/docs/quickstart.html +3 -3
- package/dist/docs/reference/agent-config.html +3 -3
- package/dist/docs/reference/channels.html +3 -3
- package/dist/docs/reference/cli.html +8 -5
- package/dist/docs/reference/connections.html +3 -3
- package/dist/docs/reference/hooks.html +3 -3
- package/dist/docs/reference/http-api.html +5 -5
- package/dist/docs/reference/instructions.html +3 -3
- package/dist/docs/reference/playground.html +3 -3
- package/dist/docs/reference/project-layout.html +3 -3
- package/dist/docs/reference/prompt.html +3 -3
- package/dist/docs/reference/schedules.html +3 -3
- package/dist/docs/reference/sessions.html +3 -3
- package/dist/docs/reference/skills.html +3 -3
- package/dist/docs/reference/subagents.html +3 -3
- package/dist/docs/reference/tools.html +3 -3
- package/dist/docs/scaffolding-agents.html +3 -3
- package/dist/docs/storage.html +3 -3
- package/dist/docs/troubleshooting.html +3 -3
- package/dist/evals.d.ts +49 -2
- package/dist/evals.d.ts.map +1 -1
- package/dist/evals.js +53 -16
- package/dist/internal/cli-ax.d.ts +4 -0
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +166 -33
- package/dist/internal/cli-deploy.d.ts +8 -0
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +92 -12
- package/dist/internal/cli-mcp-oauth.d.ts +14 -2
- package/dist/internal/cli-mcp-oauth.d.ts.map +1 -1
- package/dist/internal/cli-mcp-oauth.js +95 -2
- package/dist/internal/cursor/backend-client.d.ts +34 -0
- package/dist/internal/cursor/backend-client.d.ts.map +1 -1
- package/dist/internal/cursor/backend-client.js +73 -9
- package/dist/internal/cursor/credentials.d.ts +7 -1
- package/dist/internal/cursor/credentials.d.ts.map +1 -1
- package/dist/internal/cursor/credentials.js +9 -3
- package/dist/internal/cursor-account-mcp-auth.d.ts +55 -0
- package/dist/internal/cursor-account-mcp-auth.d.ts.map +1 -0
- package/dist/internal/cursor-account-mcp-auth.js +175 -0
- package/dist/internal/deploy-client.d.ts +6 -0
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +13 -0
- package/dist/internal/eval-run-store.d.ts +15 -0
- package/dist/internal/eval-run-store.d.ts.map +1 -1
- package/dist/internal/eval-run-store.js +94 -8
- package/dist/internal/eval-runner.d.ts +14 -0
- package/dist/internal/eval-runner.d.ts.map +1 -1
- package/dist/internal/eval-runner.js +111 -22
- package/dist/internal/evals-client.d.ts +9 -1
- package/dist/internal/evals-client.d.ts.map +1 -1
- package/dist/internal/evals-client.js +44 -1
- package/dist/internal/http-channel.d.ts.map +1 -1
- package/dist/internal/http-channel.js +74 -7
- package/dist/internal/map-pool.d.ts +6 -1
- package/dist/internal/map-pool.d.ts.map +1 -1
- package/dist/internal/map-pool.js +8 -1
- package/dist/internal/mcp-host.d.ts +13 -0
- package/dist/internal/mcp-host.d.ts.map +1 -1
- package/dist/internal/mcp-host.js +68 -13
- package/dist/internal/persistence-coordinator.d.ts +127 -0
- package/dist/internal/persistence-coordinator.d.ts.map +1 -0
- package/dist/internal/run-client.d.ts +5 -1
- package/dist/internal/run-client.d.ts.map +1 -1
- package/dist/internal/run-client.js +26 -5
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +57 -4
- package/dist/internal/session-engine.d.ts +13 -0
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +49 -0
- package/dist/internal/storage-coordinator.d.ts +7 -0
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +29 -4
- package/dist/persistence.d.ts +184 -0
- package/dist/persistence.d.ts.map +1 -0
- package/dist/playground/assets/{index-1dzluIcW.js → index-BVMOoiek.js} +44 -44
- package/dist/playground/assets/index-DYmP4b--.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/evals.md +46 -11
- package/docs/reference/cli.md +3 -0
- package/docs/reference/http-api.md +2 -1
- package/package.json +1 -1
- package/skills/evals/SKILL.md +10 -0
- package/src/bin/agent-serve.ts +38 -8
- package/src/channels/github/api.ts +12 -1
- package/src/channels/github/cursor-account.ts +51 -1
- package/src/channels/github/github-channel.ts +4 -1
- package/src/channels/slack/api.ts +57 -8
- package/src/channels/slack/eval-directive.ts +24 -1
- package/src/evals.ts +112 -25
- package/src/internal/cli-ax.ts +195 -16
- package/src/internal/cli-deploy.ts +140 -13
- package/src/internal/cli-mcp-oauth.ts +122 -3
- package/src/internal/cursor/backend-client.ts +104 -1
- package/src/internal/cursor/credentials.ts +10 -2
- package/src/internal/cursor-account-mcp-auth.ts +241 -0
- package/src/internal/deploy-client.ts +16 -0
- package/src/internal/eval-run-store.ts +97 -6
- package/src/internal/eval-runner.ts +129 -18
- package/src/internal/evals-client.ts +82 -0
- package/src/internal/http-channel.ts +87 -6
- package/src/internal/map-pool.ts +8 -1
- package/src/internal/mcp-host.ts +74 -16
- package/src/internal/run-client.ts +32 -1
- package/src/internal/server.ts +69 -2
- package/src/internal/session-engine.ts +58 -0
- package/src/internal/storage-coordinator.ts +32 -6
- package/src/types.ts +10 -0
- package/dist/docs/assets/chunks/@localSearchIndexroot.Er_R50vY.js +0 -1
- package/dist/internal/json-dir-store.js +0 -100
- package/dist/playground/assets/index-kZjeJs1v.css +0 -1
- /package/dist/docs/assets/{reference_cli.md.B74NrVzb.lean.js → reference_cli.md.DnYfr5V2.lean.js} +0 -0
|
@@ -139,27 +139,79 @@ export function runDiscoveredEvals(options) {
|
|
|
139
139
|
}
|
|
140
140
|
const maxConcurrency = resolveEvalMaxConcurrency(config);
|
|
141
141
|
const defaultTimeoutMs = (_c = (_b = options.timeoutMs) !== null && _b !== void 0 ? _b : config.timeoutMs) !== null && _c !== void 0 ? _c : 180000;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
// Iterations of the same authored datapoint share one concurrency slot and
|
|
143
|
+
// run sequentially. maxConcurrency is therefore the max number of distinct
|
|
144
|
+
// datapoints in flight, not datapoints × iterations.
|
|
145
|
+
const groups = groupEvalsForIterationSchedule(selected);
|
|
146
|
+
const nested = yield mapPool(groups, maxConcurrency, (group) => __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
var _a, _b, _c;
|
|
148
|
+
const results = [];
|
|
149
|
+
for (const discovered of group) {
|
|
150
|
+
if ((_a = options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
if (options.verbose) {
|
|
154
|
+
process.stderr.write(` eval ${discovered.id}…\n`);
|
|
155
|
+
}
|
|
156
|
+
(_b = options.onCaseStart) === null || _b === void 0 ? void 0 : _b.call(options, discovered.id);
|
|
157
|
+
const result = yield runOneEval(discovered, {
|
|
158
|
+
baseUrl: options.baseUrl,
|
|
159
|
+
defaultTimeoutMs,
|
|
160
|
+
bearerToken: options.bearerToken,
|
|
161
|
+
headers: options.headers,
|
|
162
|
+
verbose: Boolean(options.verbose),
|
|
163
|
+
signal: options.signal,
|
|
164
|
+
onEvent: (event) => {
|
|
165
|
+
var _a, _b;
|
|
166
|
+
(_a = options.onCaseEvent) === null || _a === void 0 ? void 0 : _a.call(options, discovered.id, event);
|
|
167
|
+
(_b = options.onEvent) === null || _b === void 0 ? void 0 : _b.call(options, event);
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
(_c = options.onCaseDone) === null || _c === void 0 ? void 0 : _c.call(options, result);
|
|
171
|
+
results.push(result);
|
|
146
172
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
173
|
+
return results;
|
|
174
|
+
}), { signal: options.signal });
|
|
175
|
+
return nested.flat();
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Schedule key for {@link groupEvalsForIterationSchedule}: iteration siblings
|
|
180
|
+
* (`weather/nyc/1`…`/3`) share a key; single-iteration ids keep their full id.
|
|
181
|
+
*/
|
|
182
|
+
export function iterationScheduleKey(discovered) {
|
|
183
|
+
var _a, _b;
|
|
184
|
+
const iterations = (_a = discovered.definition.iterations) !== null && _a !== void 0 ? _a : 1;
|
|
185
|
+
const iteration = (_b = discovered.definition.iteration) !== null && _b !== void 0 ? _b : 1;
|
|
186
|
+
if (iterations <= 1) {
|
|
187
|
+
return discovered.id;
|
|
188
|
+
}
|
|
189
|
+
const suffix = `/${iteration}`;
|
|
190
|
+
if (discovered.id.endsWith(suffix)) {
|
|
191
|
+
return discovered.id.slice(0, -suffix.length);
|
|
192
|
+
}
|
|
193
|
+
return discovered.id;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Group expanded iteration cases so each authored datapoint's iterations run
|
|
197
|
+
* back-to-back under one {@link mapPool} slot (sorted by iteration index).
|
|
198
|
+
*/
|
|
199
|
+
export function groupEvalsForIterationSchedule(evals) {
|
|
200
|
+
const groups = new Map();
|
|
201
|
+
const order = [];
|
|
202
|
+
for (const discovered of evals) {
|
|
203
|
+
const key = iterationScheduleKey(discovered);
|
|
204
|
+
let group = groups.get(key);
|
|
205
|
+
if (group === undefined) {
|
|
206
|
+
group = [];
|
|
207
|
+
groups.set(key, group);
|
|
208
|
+
order.push(key);
|
|
209
|
+
}
|
|
210
|
+
group.push(discovered);
|
|
211
|
+
}
|
|
212
|
+
return order.map((key) => {
|
|
213
|
+
const group = groups.get(key);
|
|
214
|
+
return group.sort((a, b) => { var _a, _b; return ((_a = a.definition.iteration) !== null && _a !== void 0 ? _a : 1) - ((_b = b.definition.iteration) !== null && _b !== void 0 ? _b : 1); });
|
|
163
215
|
});
|
|
164
216
|
}
|
|
165
217
|
function resolveEvalMaxConcurrency(config) {
|
|
@@ -173,16 +225,25 @@ function resolveEvalMaxConcurrency(config) {
|
|
|
173
225
|
function runOneEval(discovered, opts) {
|
|
174
226
|
return __awaiter(this, void 0, void 0, function* () {
|
|
175
227
|
var _a;
|
|
228
|
+
var _b;
|
|
176
229
|
const logs = [];
|
|
230
|
+
const metrics = {};
|
|
177
231
|
const assertions = [];
|
|
178
232
|
const def = discovered.definition;
|
|
179
|
-
const timeoutMs = (
|
|
233
|
+
const timeoutMs = (_b = def.timeoutMs) !== null && _b !== void 0 ? _b : opts.defaultTimeoutMs;
|
|
180
234
|
const startedAt = Date.now();
|
|
181
235
|
let sessionId;
|
|
182
236
|
let continuationToken;
|
|
183
237
|
const allEvents = [];
|
|
184
238
|
const inputs = [];
|
|
185
239
|
let reply = null;
|
|
240
|
+
if ((_a = opts.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
241
|
+
return Object.assign(Object.assign({ id: discovered.id, path: discovered.path }, (def.description === undefined
|
|
242
|
+
? {}
|
|
243
|
+
: { description: def.description })), { ok: false, assertions, error: "cancelled", logs,
|
|
244
|
+
metrics,
|
|
245
|
+
inputs, toolCalls: [], tools: [], durationMs: Date.now() - startedAt });
|
|
246
|
+
}
|
|
186
247
|
const record = (name, passed, detail) => {
|
|
187
248
|
assertions.push(Object.assign({ name,
|
|
188
249
|
passed }, (detail === undefined ? {} : { detail })));
|
|
@@ -199,6 +260,14 @@ function runOneEval(discovered, opts) {
|
|
|
199
260
|
get events() {
|
|
200
261
|
return allEvents;
|
|
201
262
|
},
|
|
263
|
+
get iteration() {
|
|
264
|
+
var _a;
|
|
265
|
+
return (_a = def.iteration) !== null && _a !== void 0 ? _a : 1;
|
|
266
|
+
},
|
|
267
|
+
get iterations() {
|
|
268
|
+
var _a;
|
|
269
|
+
return (_a = def.iterations) !== null && _a !== void 0 ? _a : 1;
|
|
270
|
+
},
|
|
202
271
|
send(message_1) {
|
|
203
272
|
return __awaiter(this, arguments, void 0, function* (message, options = {}) {
|
|
204
273
|
inputs.push(message);
|
|
@@ -213,7 +282,9 @@ function runOneEval(discovered, opts) {
|
|
|
213
282
|
headers: opts.headers,
|
|
214
283
|
workspaceDir: options.workspaceDir,
|
|
215
284
|
workspaceFiles: options.workspaceFiles,
|
|
285
|
+
cloud: options.cloud,
|
|
216
286
|
timeoutMs,
|
|
287
|
+
signal: opts.signal,
|
|
217
288
|
onEvent: opts.onEvent,
|
|
218
289
|
});
|
|
219
290
|
sessionId = result.sessionId;
|
|
@@ -258,6 +329,16 @@ function runOneEval(discovered, opts) {
|
|
|
258
329
|
process.stderr.write(` ${message}\n`);
|
|
259
330
|
}
|
|
260
331
|
},
|
|
332
|
+
metric(name, value) {
|
|
333
|
+
const key = name.trim();
|
|
334
|
+
if (key === "") {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
metrics[key] = value;
|
|
338
|
+
if (opts.verbose) {
|
|
339
|
+
process.stderr.write(` metric ${key}=${String(value)}\n`);
|
|
340
|
+
}
|
|
341
|
+
},
|
|
261
342
|
};
|
|
262
343
|
try {
|
|
263
344
|
yield def.test(t);
|
|
@@ -270,6 +351,7 @@ function runOneEval(discovered, opts) {
|
|
|
270
351
|
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ id: discovered.id, path: discovered.path }, (def.description === undefined
|
|
271
352
|
? {}
|
|
272
353
|
: { description: def.description })), { ok: false, assertions, error: message, logs,
|
|
354
|
+
metrics,
|
|
273
355
|
inputs, toolCalls: toolCallIo() }), (sessionId === undefined ? {} : { sessionId })), (reply === null ? {} : { finalText: reply })), { tools: toolsUsed(), durationMs: Date.now() - startedAt });
|
|
274
356
|
}
|
|
275
357
|
const traj = buildTrajectory(allEvents);
|
|
@@ -279,6 +361,7 @@ function runOneEval(discovered, opts) {
|
|
|
279
361
|
return Object.assign(Object.assign(Object.assign(Object.assign({ id: discovered.id, path: discovered.path }, (def.description === undefined ? {} : { description: def.description })), { ok,
|
|
280
362
|
assertions,
|
|
281
363
|
logs,
|
|
364
|
+
metrics,
|
|
282
365
|
inputs, toolCalls: toolCallIo() }), (sessionId === undefined ? {} : { sessionId })), { finalText: reply !== null && reply !== void 0 ? reply : traj.finalText, tools: toolsUsed(), durationMs: Date.now() - startedAt });
|
|
283
366
|
});
|
|
284
367
|
}
|
|
@@ -297,7 +380,13 @@ function matchExpectation(value, assertion) {
|
|
|
297
380
|
}
|
|
298
381
|
case "equals": {
|
|
299
382
|
const passed = deepEqual(value, assertion.value);
|
|
300
|
-
|
|
383
|
+
// Always attach a short detail so values like recall `40.0% (4/10)`
|
|
384
|
+
// show up on PASS lines / playground, not only on failure.
|
|
385
|
+
const rendered = typeof value === "string" ? value : JSON.stringify(value);
|
|
386
|
+
return {
|
|
387
|
+
passed,
|
|
388
|
+
detail: passed ? rendered : `got ${rendered}`,
|
|
389
|
+
};
|
|
301
390
|
}
|
|
302
391
|
case "satisfies": {
|
|
303
392
|
const passed = assertion.predicate(value);
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type { EvalRunSnapshot } from "../evals.js";
|
|
10
10
|
import type { EvalRunResult } from "./eval-runner.js";
|
|
11
11
|
import { type RequestAuth } from "./request-headers.js";
|
|
12
|
-
export type RemoteEvalErrorCode = "no_matching_evals" | "eval_run_in_progress" | "unknown_eval_run" | "start_failed" | "poll_failed" | "aborted";
|
|
12
|
+
export type RemoteEvalErrorCode = "no_matching_evals" | "eval_run_in_progress" | "eval_run_not_running" | "unknown_eval_run" | "start_failed" | "poll_failed" | "cancel_failed" | "aborted";
|
|
13
13
|
export declare class RemoteEvalError extends Error {
|
|
14
14
|
readonly status?: number | undefined;
|
|
15
15
|
readonly code?: RemoteEvalErrorCode | undefined;
|
|
@@ -65,6 +65,14 @@ export declare function startRemoteEvalRun(args: {
|
|
|
65
65
|
verbose?: boolean;
|
|
66
66
|
signal?: AbortSignal;
|
|
67
67
|
}): Promise<EvalRunSnapshot>;
|
|
68
|
+
/** Cancel a running batch via `POST /v1/dev/evals/runs/:runId/cancel`. */
|
|
69
|
+
export declare function cancelRemoteEvalRun(args: {
|
|
70
|
+
baseUrl: string;
|
|
71
|
+
runId: string;
|
|
72
|
+
auth?: RequestAuth;
|
|
73
|
+
fetchImpl?: typeof fetch;
|
|
74
|
+
signal?: AbortSignal;
|
|
75
|
+
}): Promise<EvalRunSnapshot>;
|
|
68
76
|
/** One-shot `GET /v1/dev/evals/runs/:runId` (no polling). */
|
|
69
77
|
export declare function getRemoteEvalRun(args: {
|
|
70
78
|
baseUrl: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evals-client.d.ts","sourceRoot":"","sources":["../../src/internal/evals-client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,EAA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C;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAyC7D;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;CAC9C,GAAG,OAAO,CAAC,eAAe,CAAC,CAoB3B;AAED,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,eAAe,GACxB,aAAa,EAAE,CAiBjB"}
|
|
@@ -162,6 +162,49 @@ export function startRemoteEvalRun(args) {
|
|
|
162
162
|
return json;
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
|
+
/** Cancel a running batch via `POST /v1/dev/evals/runs/:runId/cancel`. */
|
|
166
|
+
export function cancelRemoteEvalRun(args) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
var _a;
|
|
169
|
+
const baseUrl = args.baseUrl.replace(/\/$/, "");
|
|
170
|
+
const fetchImpl = (_a = args.fetchImpl) !== null && _a !== void 0 ? _a : fetch;
|
|
171
|
+
let resp;
|
|
172
|
+
try {
|
|
173
|
+
resp = yield fetchImpl(`${baseUrl}/v1/dev/evals/runs/${encodeURIComponent(args.runId)}/cancel`, {
|
|
174
|
+
method: "POST",
|
|
175
|
+
headers: mergeRequestHeaders(args.auth),
|
|
176
|
+
signal: args.signal,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
throw new RemoteEvalError(error instanceof Error ? error.message : "Could not cancel eval run.", undefined, "cancel_failed");
|
|
181
|
+
}
|
|
182
|
+
const json = (yield resp.json().catch(() => ({})));
|
|
183
|
+
if (resp.status === 404 || json.error === "unknown_eval_run") {
|
|
184
|
+
throw new RemoteEvalError(`Unknown eval run ${args.runId}.`, 404, "unknown_eval_run");
|
|
185
|
+
}
|
|
186
|
+
if (resp.status === 409 || json.error === "eval_run_not_running") {
|
|
187
|
+
const status = typeof json.status === "string" && json.status !== ""
|
|
188
|
+
? json.status
|
|
189
|
+
: "unknown";
|
|
190
|
+
throw new RemoteEvalError(typeof json.message === "string" && json.message !== ""
|
|
191
|
+
? json.message
|
|
192
|
+
: `Eval run ${args.runId} is not running (status: ${status}).`, 409, "eval_run_not_running");
|
|
193
|
+
}
|
|
194
|
+
if (!resp.ok) {
|
|
195
|
+
const detail = typeof json.message === "string" && json.message !== ""
|
|
196
|
+
? json.message
|
|
197
|
+
: typeof json.error === "string" && json.error !== ""
|
|
198
|
+
? json.error
|
|
199
|
+
: `HTTP ${resp.status}`;
|
|
200
|
+
throw new RemoteEvalError(`Could not cancel eval run: ${detail}`, resp.status, "cancel_failed");
|
|
201
|
+
}
|
|
202
|
+
if (typeof json.runId !== "string" || json.runId === "") {
|
|
203
|
+
throw new RemoteEvalError("Eval cancel response missing runId.", undefined, "cancel_failed");
|
|
204
|
+
}
|
|
205
|
+
return json;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
165
208
|
/** One-shot `GET /v1/dev/evals/runs/:runId` (no polling). */
|
|
166
209
|
export function getRemoteEvalRun(args) {
|
|
167
210
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -241,7 +284,7 @@ export function pollRemoteEvalRun(args) {
|
|
|
241
284
|
});
|
|
242
285
|
}
|
|
243
286
|
export function snapshotToEvalRunResults(snapshot) {
|
|
244
|
-
return snapshot.cases.map((c) => { var _a, _b, _c, _d; return (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ id: c.id, path: c.fileId }, (c.description === undefined ? {} : { description: c.description })), { ok: c.ok === true, assertions: (_a = c.assertions) !== null && _a !== void 0 ? _a : [] }), (c.sessionId === undefined ? {} : { sessionId: c.sessionId })), { inputs: (_b = c.inputs) !== null && _b !== void 0 ? _b : [] }), (c.finalText === undefined ? {} : { finalText: c.finalText })), (c.tools === undefined ? {} : { tools: c.tools })), (c.toolCalls === undefined ? {} : { toolCalls: c.toolCalls })), (c.error === undefined ? {} : { error: c.error })), { logs: (_c = c.logs) !== null && _c !== void 0 ? _c : [],
|
|
287
|
+
return snapshot.cases.map((c) => { var _a, _b, _c, _d, _e; return (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ id: c.id, path: c.fileId }, (c.description === undefined ? {} : { description: c.description })), { ok: c.ok === true, assertions: (_a = c.assertions) !== null && _a !== void 0 ? _a : [] }), (c.sessionId === undefined ? {} : { sessionId: c.sessionId })), { inputs: (_b = c.inputs) !== null && _b !== void 0 ? _b : [] }), (c.finalText === undefined ? {} : { finalText: c.finalText })), (c.tools === undefined ? {} : { tools: c.tools })), (c.toolCalls === undefined ? {} : { toolCalls: c.toolCalls })), (c.error === undefined ? {} : { error: c.error })), { logs: (_c = c.logs) !== null && _c !== void 0 ? _c : [], metrics: (_d = c.metrics) !== null && _d !== void 0 ? _d : {}, durationMs: (_e = c.durationMs) !== null && _e !== void 0 ? _e : 0 })); });
|
|
245
288
|
}
|
|
246
289
|
function sleep(ms, signal) {
|
|
247
290
|
return new Promise((resolve, reject) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-channel.d.ts","sourceRoot":"","sources":["../../src/internal/http-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"http-channel.d.ts","sourceRoot":"","sources":["../../src/internal/http-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAEV,WAAW,EACX,UAAU,EACV,qBAAqB,EAErB,aAAa,EACd,MAAM,aAAa,CAAC;AAQrB,OAAO,KAAK,EA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50
|
}
|
|
51
51
|
const message = yield transformMessage(body.message, ctx.auth);
|
|
52
52
|
const workspaceFiles = readWorkspaceFiles(body.workspaceFiles);
|
|
53
|
-
|
|
53
|
+
// Per-session cloud attach (create only). Eval harness uses this to pin
|
|
54
|
+
// fixture repos without putting them on the agent's default cloud.repos.
|
|
55
|
+
const cloud = readCloudOptions(body.cloud);
|
|
56
|
+
const session = yield engine.send(HTTP_CHANNEL_ID, message, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ auth: ctx.auth }, (body.state === undefined ? {} : { state: body.state })), (typeof body.title === "string" ? { title: body.title } : {})), (body.purpose === "eval" ? { purpose: "eval" } : {})), (workspaceFiles === undefined ? {} : { workspaceFiles })), (cloud === undefined ? {} : { cloud })));
|
|
54
57
|
return jsonResponse({
|
|
55
58
|
ok: true,
|
|
56
59
|
sessionId: session.id,
|
|
@@ -67,7 +70,7 @@ export function buildHttpChannelRoutes(args) {
|
|
|
67
70
|
handler: (request, ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
68
71
|
var _a;
|
|
69
72
|
const sessionId = (_a = ctx.params.sessionId) !== null && _a !== void 0 ? _a : "";
|
|
70
|
-
const record = yield engine.
|
|
73
|
+
const record = yield engine.getOrRestoreSession(sessionId);
|
|
71
74
|
if (record === undefined) {
|
|
72
75
|
return errorResponse(404, "session_not_found", `Unknown session ${sessionId}.`);
|
|
73
76
|
}
|
|
@@ -138,7 +141,9 @@ export function buildHttpChannelRoutes(args) {
|
|
|
138
141
|
// custom channels or schedules are observable here too when the caller
|
|
139
142
|
// matches the session's stored principal (or `--dev` relax). Follow-ups
|
|
140
143
|
// use the same ownership gate plus the session's continuation token.
|
|
141
|
-
|
|
144
|
+
// Lazy-restore by id so playground Open-trace works after redeploy
|
|
145
|
+
// when the session is durable but not in the local state root yet.
|
|
146
|
+
const record = yield engine.getOrRestoreSession(sessionId);
|
|
142
147
|
if (record === undefined) {
|
|
143
148
|
return errorResponse(404, "session_not_found", `Unknown session ${sessionId}.`);
|
|
144
149
|
}
|
|
@@ -175,7 +180,7 @@ export function buildHttpChannelRoutes(args) {
|
|
|
175
180
|
handler: (request, ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
176
181
|
var _a;
|
|
177
182
|
const sessionId = (_a = ctx.params.sessionId) !== null && _a !== void 0 ? _a : "";
|
|
178
|
-
const record = yield engine.
|
|
183
|
+
const record = yield engine.getOrRestoreSession(sessionId);
|
|
179
184
|
if (record === undefined) {
|
|
180
185
|
return errorResponse(404, "session_not_found", `Unknown session ${sessionId}.`);
|
|
181
186
|
}
|
|
@@ -216,7 +221,7 @@ export function buildHttpChannelRoutes(args) {
|
|
|
216
221
|
handler: (_request, ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
217
222
|
var _a;
|
|
218
223
|
const sessionId = (_a = ctx.params.sessionId) !== null && _a !== void 0 ? _a : "";
|
|
219
|
-
const record = yield engine.
|
|
224
|
+
const record = yield engine.getOrRestoreSession(sessionId);
|
|
220
225
|
if (record === undefined) {
|
|
221
226
|
return errorResponse(404, "session_not_found", `Unknown session ${sessionId}.`);
|
|
222
227
|
}
|
|
@@ -241,7 +246,7 @@ export function buildHttpChannelRoutes(args) {
|
|
|
241
246
|
var _b, _c;
|
|
242
247
|
const sessionId = (_b = ctx.params.sessionId) !== null && _b !== void 0 ? _b : "";
|
|
243
248
|
const callId = (_c = ctx.params.callId) !== null && _c !== void 0 ? _c : "";
|
|
244
|
-
const record = yield engine.
|
|
249
|
+
const record = yield engine.getOrRestoreSession(sessionId);
|
|
245
250
|
if (record === undefined) {
|
|
246
251
|
return errorResponse(404, "session_not_found", `Unknown session ${sessionId}.`);
|
|
247
252
|
}
|
|
@@ -296,7 +301,7 @@ export function buildHttpChannelRoutes(args) {
|
|
|
296
301
|
handler: (_request, ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
297
302
|
var _a;
|
|
298
303
|
const sessionId = (_a = ctx.params.sessionId) !== null && _a !== void 0 ? _a : "";
|
|
299
|
-
const record = yield engine.
|
|
304
|
+
const record = yield engine.getOrRestoreSession(sessionId);
|
|
300
305
|
if (record === undefined) {
|
|
301
306
|
return errorResponse(404, "session_not_found", `Unknown session ${sessionId}.`);
|
|
302
307
|
}
|
|
@@ -364,6 +369,68 @@ function readWorkspaceFiles(value) {
|
|
|
364
369
|
}
|
|
365
370
|
return Object.keys(files).length === 0 ? undefined : files;
|
|
366
371
|
}
|
|
372
|
+
function isRecord(value) {
|
|
373
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
374
|
+
}
|
|
375
|
+
/** Best-effort parse of {@link AgentCloudOptions} from a JSON body field. */
|
|
376
|
+
function readCloudOptions(value) {
|
|
377
|
+
if (!isRecord(value)) {
|
|
378
|
+
return undefined;
|
|
379
|
+
}
|
|
380
|
+
const cloud = {};
|
|
381
|
+
if (isRecord(value.env) && typeof value.env.type === "string") {
|
|
382
|
+
const name = typeof value.env.name === "string" ? value.env.name : undefined;
|
|
383
|
+
if (value.env.type === "cloud") {
|
|
384
|
+
cloud.env =
|
|
385
|
+
name === undefined ? { type: "cloud" } : { type: "cloud", name };
|
|
386
|
+
}
|
|
387
|
+
else if (value.env.type === "pool") {
|
|
388
|
+
cloud.env =
|
|
389
|
+
name === undefined ? { type: "pool" } : { type: "pool", name };
|
|
390
|
+
}
|
|
391
|
+
else if (value.env.type === "machine") {
|
|
392
|
+
cloud.env =
|
|
393
|
+
name === undefined ? { type: "machine" } : { type: "machine", name };
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
if (Array.isArray(value.repos)) {
|
|
397
|
+
const repos = [];
|
|
398
|
+
for (const entry of value.repos) {
|
|
399
|
+
if (!isRecord(entry) ||
|
|
400
|
+
typeof entry.url !== "string" ||
|
|
401
|
+
entry.url === "") {
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
repos.push(Object.assign(Object.assign({ url: entry.url }, (typeof entry.startingRef === "string"
|
|
405
|
+
? { startingRef: entry.startingRef }
|
|
406
|
+
: {})), (typeof entry.prUrl === "string" ? { prUrl: entry.prUrl } : {})));
|
|
407
|
+
}
|
|
408
|
+
if (repos.length > 0) {
|
|
409
|
+
cloud.repos = repos;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (typeof value.workOnCurrentBranch === "boolean") {
|
|
413
|
+
cloud.workOnCurrentBranch = value.workOnCurrentBranch;
|
|
414
|
+
}
|
|
415
|
+
if (typeof value.autoCreatePR === "boolean") {
|
|
416
|
+
cloud.autoCreatePR = value.autoCreatePR;
|
|
417
|
+
}
|
|
418
|
+
if (typeof value.skipReviewerRequest === "boolean") {
|
|
419
|
+
cloud.skipReviewerRequest = value.skipReviewerRequest;
|
|
420
|
+
}
|
|
421
|
+
if (isRecord(value.envVars)) {
|
|
422
|
+
const envVars = {};
|
|
423
|
+
for (const [key, envValue] of Object.entries(value.envVars)) {
|
|
424
|
+
if (typeof key === "string" && typeof envValue === "string") {
|
|
425
|
+
envVars[key] = envValue;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (Object.keys(envVars).length > 0) {
|
|
429
|
+
cloud.envVars = envVars;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return Object.keys(cloud).length === 0 ? undefined : cloud;
|
|
433
|
+
}
|
|
367
434
|
export function readJsonObject(request) {
|
|
368
435
|
return __awaiter(this, void 0, void 0, function* () {
|
|
369
436
|
try {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Run `fn` over `items` with at most `concurrency` in flight; preserve order
|
|
3
3
|
* of results (and of side-effect completion relative to index assignment).
|
|
4
|
+
*
|
|
5
|
+
* When `signal` aborts, workers stop claiming new items; in-flight `fn` calls
|
|
6
|
+
* are responsible for honoring the same signal.
|
|
4
7
|
*/
|
|
5
|
-
export declare function mapPool<T, R>(items: readonly T[], concurrency: number, fn: (item: T, index: number) => Promise<R
|
|
8
|
+
export declare function mapPool<T, R>(items: readonly T[], concurrency: number, fn: (item: T, index: number) => Promise<R>, options?: {
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
}): Promise<R[]>;
|
|
6
11
|
//# sourceMappingURL=map-pool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-pool.d.ts","sourceRoot":"","sources":["../../src/internal/map-pool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"map-pool.d.ts","sourceRoot":"","sources":["../../src/internal/map-pool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAAE,CAAC,EAChC,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,WAAW,EAAE,MAAM,EACnB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EAC1C,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GACjC,OAAO,CAAC,CAAC,EAAE,CAAC,CA0Bd"}
|
|
@@ -10,14 +10,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
/**
|
|
11
11
|
* Run `fn` over `items` with at most `concurrency` in flight; preserve order
|
|
12
12
|
* of results (and of side-effect completion relative to index assignment).
|
|
13
|
+
*
|
|
14
|
+
* When `signal` aborts, workers stop claiming new items; in-flight `fn` calls
|
|
15
|
+
* are responsible for honoring the same signal.
|
|
13
16
|
*/
|
|
14
|
-
export function mapPool(items, concurrency, fn) {
|
|
17
|
+
export function mapPool(items, concurrency, fn, options) {
|
|
15
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
19
|
const results = new Array(items.length);
|
|
17
20
|
let next = 0;
|
|
18
21
|
function worker() {
|
|
19
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
var _a;
|
|
20
24
|
for (;;) {
|
|
25
|
+
if ((_a = options === null || options === void 0 ? void 0 : options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
21
28
|
const index = next;
|
|
22
29
|
next += 1;
|
|
23
30
|
if (index >= items.length) {
|
|
@@ -22,7 +22,20 @@ export declare class McpHost implements HostMcpRegistry {
|
|
|
22
22
|
listTools(connectionName: string): Promise<HostMcpToolInfo[]>;
|
|
23
23
|
callTool(connectionName: string, toolName: string, args?: Record<string, unknown>): Promise<HostMcpCallResult>;
|
|
24
24
|
close(): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Run against a cached host MCP client, reconnecting once when the remote
|
|
27
|
+
* Streamable HTTP session is gone (`session_terminated` / HTTP 404).
|
|
28
|
+
*
|
|
29
|
+
* Anytool (and the MCP spec) return 404 for unknown/terminated
|
|
30
|
+
* `Mcp-Session-Id`s so clients can re-initialize. The SDK transport keeps
|
|
31
|
+
* the dead session id, so without this invalidation every later host.mcp
|
|
32
|
+
* call fails until the serve process restarts.
|
|
33
|
+
*/
|
|
34
|
+
private withClient;
|
|
25
35
|
private getClient;
|
|
36
|
+
private invalidateClient;
|
|
26
37
|
private connect;
|
|
27
38
|
}
|
|
39
|
+
/** Exported for unit tests. */
|
|
40
|
+
export declare function isStaleMcpSessionError(error: unknown): boolean;
|
|
28
41
|
//# sourceMappingURL=mcp-host.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-host.d.ts","sourceRoot":"","sources":["../../src/internal/mcp-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,eAAe,EAEhB,MAAM,aAAa,CAAC;AASrB,qBAAa,OAAQ,YAAW,eAAe;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAClE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgD;IAExE,YAAY,WAAW,EAAE,oBAAoB,EAAE,EAI9C;IAED;;;OAGG;IACH,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,IAAI,CAEpD;IAED,KAAK,IAAI,MAAM,EAAE,CAEhB;IAEK,SAAS,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"mcp-host.d.ts","sourceRoot":"","sources":["../../src/internal/mcp-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,eAAe,EAEhB,MAAM,aAAa,CAAC;AASrB,qBAAa,OAAQ,YAAW,eAAe;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAClE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgD;IAExE,YAAY,WAAW,EAAE,oBAAoB,EAAE,EAI9C;IAED;;;OAGG;IACH,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,IAAI,CAEpD;IAED,KAAK,IAAI,MAAM,EAAE,CAEhB;IAEK,SAAS,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAalE;IAEK,QAAQ,CACZ,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACjC,OAAO,CAAC,iBAAiB,CAAC,CAQ5B;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAU3B;IAED;;;;;;;;OAQG;YACW,UAAU;IAiBxB,OAAO,CAAC,SAAS;YAYH,gBAAgB;YAiBhB,OAAO;CAUtB;AAED,+BAA+B;AAC/B,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAU9D"}
|
|
@@ -44,23 +44,25 @@ export class McpHost {
|
|
|
44
44
|
}
|
|
45
45
|
listTools(connectionName) {
|
|
46
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
return this.withClient(connectionName, (client) => __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const listed = yield client.listTools();
|
|
49
|
+
return listed.tools.map((tool) => (Object.assign(Object.assign({ name: tool.name }, (tool.description === undefined
|
|
50
|
+
? {}
|
|
51
|
+
: { description: tool.description })), (tool.inputSchema === undefined
|
|
52
|
+
? {}
|
|
53
|
+
: { inputSchema: tool.inputSchema }))));
|
|
54
|
+
}));
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
57
|
callTool(connectionName_1, toolName_1) {
|
|
57
58
|
return __awaiter(this, arguments, void 0, function* (connectionName, toolName, args = {}) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
return this.withClient(connectionName, (client) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const result = yield client.callTool({
|
|
61
|
+
name: toolName,
|
|
62
|
+
arguments: args,
|
|
63
|
+
});
|
|
64
|
+
return normalizeCallResult(result);
|
|
65
|
+
}));
|
|
64
66
|
});
|
|
65
67
|
}
|
|
66
68
|
close() {
|
|
@@ -74,6 +76,31 @@ export class McpHost {
|
|
|
74
76
|
})));
|
|
75
77
|
});
|
|
76
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Run against a cached host MCP client, reconnecting once when the remote
|
|
81
|
+
* Streamable HTTP session is gone (`session_terminated` / HTTP 404).
|
|
82
|
+
*
|
|
83
|
+
* Anytool (and the MCP spec) return 404 for unknown/terminated
|
|
84
|
+
* `Mcp-Session-Id`s so clients can re-initialize. The SDK transport keeps
|
|
85
|
+
* the dead session id, so without this invalidation every later host.mcp
|
|
86
|
+
* call fails until the serve process restarts.
|
|
87
|
+
*/
|
|
88
|
+
withClient(name, run) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const opened = yield this.getClient(name);
|
|
91
|
+
try {
|
|
92
|
+
return yield run(opened.client);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
if (!isStaleMcpSessionError(error)) {
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
yield this.invalidateClient(name, opened);
|
|
99
|
+
const reopened = yield this.getClient(name);
|
|
100
|
+
return yield run(reopened.client);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
77
104
|
getClient(name) {
|
|
78
105
|
let pending = this.clients.get(name);
|
|
79
106
|
if (pending === undefined) {
|
|
@@ -85,6 +112,22 @@ export class McpHost {
|
|
|
85
112
|
}
|
|
86
113
|
return pending;
|
|
87
114
|
}
|
|
115
|
+
invalidateClient(name, opened) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const pending = this.clients.get(name);
|
|
118
|
+
if (pending !== undefined) {
|
|
119
|
+
try {
|
|
120
|
+
if ((yield pending) === opened) {
|
|
121
|
+
this.clients.delete(name);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (_a) {
|
|
125
|
+
this.clients.delete(name);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
yield opened.close();
|
|
129
|
+
});
|
|
130
|
+
}
|
|
88
131
|
connect(name) {
|
|
89
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
133
|
const connection = this.byName.get(name);
|
|
@@ -96,6 +139,18 @@ export class McpHost {
|
|
|
96
139
|
});
|
|
97
140
|
}
|
|
98
141
|
}
|
|
142
|
+
/** Exported for unit tests. */
|
|
143
|
+
export function isStaleMcpSessionError(error) {
|
|
144
|
+
if (!(error instanceof Error)) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
if (error.message.includes("session_terminated")) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
// StreamableHTTPError from the MCP SDK carries the HTTP status as `.code`.
|
|
151
|
+
const code = error.code;
|
|
152
|
+
return code === 404;
|
|
153
|
+
}
|
|
99
154
|
function openConnection(connection) {
|
|
100
155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
156
|
const client = new Client({
|