@mantyx/sdk 0.20.0 → 0.21.0
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/CHANGELOG.md +11 -0
- package/dist/a2a-server.cjs.map +1 -1
- package/dist/a2a-server.d.cts +1 -1
- package/dist/a2a-server.d.ts +1 -1
- package/dist/a2a-server.js +1 -1
- package/dist/{chunk-ZOFQ5AN6.js → chunk-QMUVI3Y3.js} +62 -19
- package/dist/chunk-QMUVI3Y3.js.map +1 -0
- package/dist/{client-D4-MQANp.d.cts → client-C7TzTpNW.d.cts} +4 -0
- package/dist/{client-D4-MQANp.d.ts → client-C7TzTpNW.d.ts} +4 -0
- package/dist/{computer-use-D4hBi1Tm.d.cts → computer-use-1m6E_VIl.d.cts} +1 -1
- package/dist/{computer-use-DUFbgsSU.d.ts → computer-use-4QzI3lGU.d.ts} +1 -1
- package/dist/index.cjs +62 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/playwright.d.cts +2 -2
- package/dist/playwright.d.ts +2 -2
- package/package.json +1 -1
- package/dist/chunk-ZOFQ5AN6.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1144,6 +1144,10 @@ var MantyxClient = class {
|
|
|
1144
1144
|
});
|
|
1145
1145
|
}
|
|
1146
1146
|
async createEvalRun(spec) {
|
|
1147
|
+
const tools = spec.tools ?? [];
|
|
1148
|
+
if (tools.length > 0) {
|
|
1149
|
+
await resolveLocalRefs(tools, { fetch: this.options.fetch });
|
|
1150
|
+
}
|
|
1147
1151
|
return this.request({
|
|
1148
1152
|
method: "POST",
|
|
1149
1153
|
path: "/eval-runs",
|
|
@@ -1213,28 +1217,49 @@ var MantyxClient = class {
|
|
|
1213
1217
|
* `getEvalRun` until `status` is terminal.
|
|
1214
1218
|
*/
|
|
1215
1219
|
async runEval(spec, options = {}) {
|
|
1216
|
-
const
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
options.onEvent?.(ev);
|
|
1222
|
-
}
|
|
1223
|
-
} catch (err) {
|
|
1224
|
-
if (!(err instanceof MantyxNetworkError)) throw err;
|
|
1225
|
-
}
|
|
1226
|
-
})();
|
|
1220
|
+
const tools = options.tools ?? spec.tools ?? [];
|
|
1221
|
+
if (tools.length > 0) {
|
|
1222
|
+
await resolveLocalRefs(tools, { fetch: this.options.fetch });
|
|
1223
|
+
}
|
|
1224
|
+
const handlers = collectLocalHandlers(tools);
|
|
1227
1225
|
try {
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1226
|
+
const accepted = await this.createEvalRun({
|
|
1227
|
+
...spec,
|
|
1228
|
+
...tools.length > 0 ? { tools } : {}
|
|
1229
|
+
});
|
|
1230
|
+
const pollMs = options.pollIntervalMs ?? 1e3;
|
|
1231
|
+
const streamDone = (async () => {
|
|
1232
|
+
try {
|
|
1233
|
+
for await (const ev of this.streamEvalRun(accepted.runId, options.signal)) {
|
|
1234
|
+
if (ev.type === "local_tool_call" && tools.length > 0) {
|
|
1235
|
+
const record = ev;
|
|
1236
|
+
const nested = typeof record.data === "object" && record.data !== null && !Array.isArray(record.data) ? record.data : void 0;
|
|
1237
|
+
const agentRunId = typeof record.agentRunId === "string" ? record.agentRunId : typeof nested?.agentRunId === "string" ? nested.agentRunId : "";
|
|
1238
|
+
if (agentRunId) {
|
|
1239
|
+
const localEv = evalEventToLocalToolCall(ev);
|
|
1240
|
+
void this.dispatchLocalTool(agentRunId, localEv, handlers).catch(() => void 0);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
options.onEvent?.(ev);
|
|
1244
|
+
}
|
|
1245
|
+
} catch (err) {
|
|
1246
|
+
if (!(err instanceof MantyxNetworkError)) throw err;
|
|
1247
|
+
}
|
|
1248
|
+
})();
|
|
1249
|
+
try {
|
|
1250
|
+
while (true) {
|
|
1251
|
+
if (options.signal?.aborted) {
|
|
1252
|
+
throw new MantyxNetworkError("eval run wait aborted", { cause: options.signal.reason });
|
|
1253
|
+
}
|
|
1254
|
+
const detail = await this.getEvalRun(accepted.runId);
|
|
1255
|
+
if (EVAL_TERMINAL_STATUSES.has(detail.status)) return detail;
|
|
1256
|
+
await sleep(pollMs);
|
|
1231
1257
|
}
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
await sleep(pollMs);
|
|
1258
|
+
} finally {
|
|
1259
|
+
await streamDone.catch(() => void 0);
|
|
1235
1260
|
}
|
|
1236
1261
|
} finally {
|
|
1237
|
-
await
|
|
1262
|
+
await closeMcpRefs(tools);
|
|
1238
1263
|
}
|
|
1239
1264
|
}
|
|
1240
1265
|
// -------------------------------------------------------------- HTTP
|
|
@@ -1522,10 +1547,28 @@ function serializeCreateEvalRunRequest(spec) {
|
|
|
1522
1547
|
if (spec.dataset) body.dataset = spec.dataset;
|
|
1523
1548
|
if (spec.agentId) body.agentId = spec.agentId;
|
|
1524
1549
|
if (spec.agent) body.agent = serializeAgentSpec(spec.agent);
|
|
1550
|
+
if (spec.tools && spec.tools.length > 0 && spec.agentId) {
|
|
1551
|
+
body.tools = serializeToolRefs(spec.tools);
|
|
1552
|
+
}
|
|
1525
1553
|
if (spec.modelId) body.modelId = spec.modelId;
|
|
1526
1554
|
if (spec.overrides) body.overrides = spec.overrides;
|
|
1527
1555
|
return body;
|
|
1528
1556
|
}
|
|
1557
|
+
function evalEventToLocalToolCall(ev) {
|
|
1558
|
+
const data = ev.data && typeof ev.data === "object" && !Array.isArray(ev.data) ? ev.data : ev;
|
|
1559
|
+
return {
|
|
1560
|
+
type: "local_tool_call",
|
|
1561
|
+
seq: 0,
|
|
1562
|
+
toolUseId: String(data.toolUseId ?? ""),
|
|
1563
|
+
name: String(data.name ?? ""),
|
|
1564
|
+
args: data.args ?? {},
|
|
1565
|
+
...typeof data.kind === "string" ? { kind: data.kind } : {},
|
|
1566
|
+
...data.agentCard !== void 0 ? { agentCard: data.agentCard } : {},
|
|
1567
|
+
...typeof data.mcpServer === "string" ? { mcpServer: data.mcpServer } : {},
|
|
1568
|
+
...typeof data.mcpToolName === "string" ? { mcpToolName: data.mcpToolName } : {},
|
|
1569
|
+
...data.mcpServerInfo !== void 0 ? { mcpServerInfo: data.mcpServerInfo } : {}
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1529
1572
|
function serializeToolRefs(tools) {
|
|
1530
1573
|
return tools.map((t) => {
|
|
1531
1574
|
switch (t.kind) {
|
|
@@ -2533,7 +2576,7 @@ async function runComputerUse(opts) {
|
|
|
2533
2576
|
}
|
|
2534
2577
|
|
|
2535
2578
|
// src/version.ts
|
|
2536
|
-
var SDK_VERSION = "0.
|
|
2579
|
+
var SDK_VERSION = "0.21.0";
|
|
2537
2580
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2538
2581
|
0 && (module.exports = {
|
|
2539
2582
|
AgentSession,
|