@mantyx/sdk 0.18.0 → 0.20.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 +14 -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-JRENMLOL.js → chunk-ZOFQ5AN6.js} +136 -2
- package/dist/chunk-ZOFQ5AN6.js.map +1 -0
- package/dist/{client-CLT46vp5.d.cts → client-D4-MQANp.d.cts} +202 -2
- package/dist/{client-CLT46vp5.d.ts → client-D4-MQANp.d.ts} +202 -2
- package/dist/{computer-use-CEiw-nJw.d.cts → computer-use-D4hBi1Tm.d.cts} +1 -1
- package/dist/{computer-use-CRcsRq8T.d.ts → computer-use-DUFbgsSU.d.ts} +1 -1
- package/dist/index.cjs +136 -2
- 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/docs/agent-runs-protocol.md +17 -8
- package/package.json +1 -1
- package/dist/chunk-JRENMLOL.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -175,6 +175,7 @@ function defineLocalTool(opts) {
|
|
|
175
175
|
outputSchema: opts.outputSchema,
|
|
176
176
|
longRunning: opts.longRunning ?? false,
|
|
177
177
|
readOnly: opts.readOnly ?? false,
|
|
178
|
+
retain: opts.retain ?? false,
|
|
178
179
|
execute: opts.execute
|
|
179
180
|
};
|
|
180
181
|
}
|
|
@@ -739,6 +740,7 @@ function inputFileUrlAttachment(opts) {
|
|
|
739
740
|
return { type: "input_file_url", ...opts };
|
|
740
741
|
}
|
|
741
742
|
var RUN_FEEDBACK_EXPLANATION_MAX = 8e3;
|
|
743
|
+
var EVAL_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "failed", "cancelled"]);
|
|
742
744
|
function planOnly(options = {}) {
|
|
743
745
|
return {
|
|
744
746
|
planOnly: true,
|
|
@@ -1128,6 +1130,113 @@ var MantyxClient = class {
|
|
|
1128
1130
|
body
|
|
1129
1131
|
});
|
|
1130
1132
|
}
|
|
1133
|
+
// --------------------------------------------------------------- Evals
|
|
1134
|
+
async listEvalDatasets() {
|
|
1135
|
+
return this.request({
|
|
1136
|
+
method: "GET",
|
|
1137
|
+
path: "/eval-datasets"
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
async getEvalDataset(datasetId) {
|
|
1141
|
+
return this.request({
|
|
1142
|
+
method: "GET",
|
|
1143
|
+
path: `/eval-datasets/${encodeURIComponent(datasetId)}`
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
async createEvalRun(spec) {
|
|
1147
|
+
return this.request({
|
|
1148
|
+
method: "POST",
|
|
1149
|
+
path: "/eval-runs",
|
|
1150
|
+
body: serializeCreateEvalRunRequest(spec)
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
async listEvalRuns(options = {}) {
|
|
1154
|
+
const params = new URLSearchParams();
|
|
1155
|
+
if (options.datasetId) params.set("datasetId", options.datasetId);
|
|
1156
|
+
if (options.agentId) params.set("agentId", options.agentId);
|
|
1157
|
+
if (options.status) params.set("status", options.status);
|
|
1158
|
+
if (options.limit !== void 0) params.set("limit", String(options.limit));
|
|
1159
|
+
if (options.offset !== void 0) params.set("offset", String(options.offset));
|
|
1160
|
+
const qs = params.toString();
|
|
1161
|
+
return this.request({
|
|
1162
|
+
method: "GET",
|
|
1163
|
+
path: qs ? `/eval-runs?${qs}` : "/eval-runs"
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
async compareEvalRuns(runA, runB) {
|
|
1167
|
+
const params = new URLSearchParams({ a: runA, b: runB });
|
|
1168
|
+
return this.request({
|
|
1169
|
+
method: "GET",
|
|
1170
|
+
path: `/eval-runs/compare?${params}`
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
async getEvalRun(runId) {
|
|
1174
|
+
return this.request({
|
|
1175
|
+
method: "GET",
|
|
1176
|
+
path: `/eval-runs/${encodeURIComponent(runId)}`
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
async *streamEvalRun(runId, signal) {
|
|
1180
|
+
const url = this.absoluteUrl(`/eval-runs/${encodeURIComponent(runId)}/stream`);
|
|
1181
|
+
const res = await this.openSseStream(url, 0, signal);
|
|
1182
|
+
try {
|
|
1183
|
+
for await (const frame of readSseStream(res.body, { signal })) {
|
|
1184
|
+
if (!frame.data) continue;
|
|
1185
|
+
let parsed;
|
|
1186
|
+
try {
|
|
1187
|
+
parsed = JSON.parse(frame.data);
|
|
1188
|
+
} catch (err) {
|
|
1189
|
+
throw new MantyxParseError(
|
|
1190
|
+
`invalid eval SSE JSON: ${frame.data.slice(0, 200)}`,
|
|
1191
|
+
frame.data,
|
|
1192
|
+
{ cause: err }
|
|
1193
|
+
);
|
|
1194
|
+
}
|
|
1195
|
+
yield parsed;
|
|
1196
|
+
if (parsed.type === "run_completed" || parsed.type === "run_error" || parsed.type === "run_cancelled") {
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
} finally {
|
|
1201
|
+
await res.body?.cancel().catch(() => void 0);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
async cancelEvalRun(runId) {
|
|
1205
|
+
return this.request({
|
|
1206
|
+
method: "POST",
|
|
1207
|
+
path: `/eval-runs/${encodeURIComponent(runId)}/cancel`
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* Start an eval run and block until it reaches a terminal status.
|
|
1212
|
+
* Tails the SSE stream for live `onEvent` callbacks while polling
|
|
1213
|
+
* `getEvalRun` until `status` is terminal.
|
|
1214
|
+
*/
|
|
1215
|
+
async runEval(spec, options = {}) {
|
|
1216
|
+
const accepted = await this.createEvalRun(spec);
|
|
1217
|
+
const pollMs = options.pollIntervalMs ?? 1e3;
|
|
1218
|
+
const streamDone = (async () => {
|
|
1219
|
+
try {
|
|
1220
|
+
for await (const ev of this.streamEvalRun(accepted.runId, options.signal)) {
|
|
1221
|
+
options.onEvent?.(ev);
|
|
1222
|
+
}
|
|
1223
|
+
} catch (err) {
|
|
1224
|
+
if (!(err instanceof MantyxNetworkError)) throw err;
|
|
1225
|
+
}
|
|
1226
|
+
})();
|
|
1227
|
+
try {
|
|
1228
|
+
while (true) {
|
|
1229
|
+
if (options.signal?.aborted) {
|
|
1230
|
+
throw new MantyxNetworkError("eval run wait aborted", { cause: options.signal.reason });
|
|
1231
|
+
}
|
|
1232
|
+
const detail = await this.getEvalRun(accepted.runId);
|
|
1233
|
+
if (EVAL_TERMINAL_STATUSES.has(detail.status)) return detail;
|
|
1234
|
+
await sleep(pollMs);
|
|
1235
|
+
}
|
|
1236
|
+
} finally {
|
|
1237
|
+
await streamDone.catch(() => void 0);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1131
1240
|
// -------------------------------------------------------------- HTTP
|
|
1132
1241
|
absoluteUrl(path) {
|
|
1133
1242
|
return `${this.options.baseUrl}/api/v1/workspaces/${encodeURIComponent(this.options.workspaceSlug)}${path}`;
|
|
@@ -1393,6 +1502,30 @@ function serializeAgentSpec(spec, extra = {}) {
|
|
|
1393
1502
|
Object.assign(body, serializeTurnInput(extra));
|
|
1394
1503
|
return body;
|
|
1395
1504
|
}
|
|
1505
|
+
function serializeCreateEvalRunRequest(spec) {
|
|
1506
|
+
const hasDataset = spec.datasetId !== void 0 || spec.dataset !== void 0;
|
|
1507
|
+
const hasAgent = spec.agentId !== void 0 || spec.agent !== void 0;
|
|
1508
|
+
if (!hasDataset) {
|
|
1509
|
+
throw new MantyxError("createEvalRun requires exactly one of `datasetId` or `dataset`");
|
|
1510
|
+
}
|
|
1511
|
+
if (spec.datasetId !== void 0 && spec.dataset !== void 0) {
|
|
1512
|
+
throw new MantyxError("createEvalRun accepts only one of `datasetId` or `dataset`");
|
|
1513
|
+
}
|
|
1514
|
+
if (!hasAgent) {
|
|
1515
|
+
throw new MantyxError("createEvalRun requires exactly one of `agentId` or `agent`");
|
|
1516
|
+
}
|
|
1517
|
+
if (spec.agentId !== void 0 && spec.agent !== void 0) {
|
|
1518
|
+
throw new MantyxError("createEvalRun accepts only one of `agentId` or `agent`");
|
|
1519
|
+
}
|
|
1520
|
+
const body = {};
|
|
1521
|
+
if (spec.datasetId) body.datasetId = spec.datasetId;
|
|
1522
|
+
if (spec.dataset) body.dataset = spec.dataset;
|
|
1523
|
+
if (spec.agentId) body.agentId = spec.agentId;
|
|
1524
|
+
if (spec.agent) body.agent = serializeAgentSpec(spec.agent);
|
|
1525
|
+
if (spec.modelId) body.modelId = spec.modelId;
|
|
1526
|
+
if (spec.overrides) body.overrides = spec.overrides;
|
|
1527
|
+
return body;
|
|
1528
|
+
}
|
|
1396
1529
|
function serializeToolRefs(tools) {
|
|
1397
1530
|
return tools.map((t) => {
|
|
1398
1531
|
switch (t.kind) {
|
|
@@ -1408,7 +1541,8 @@ function serializeToolRefs(tools) {
|
|
|
1408
1541
|
parameters: toToolParametersWire(t.parameters),
|
|
1409
1542
|
...t.outputSchema !== void 0 ? { outputSchema: toToolParametersWire(t.outputSchema) } : {},
|
|
1410
1543
|
...t.longRunning ? { longRunning: true } : {},
|
|
1411
|
-
...t.readOnly ? { readOnly: true } : {}
|
|
1544
|
+
...t.readOnly ? { readOnly: true } : {},
|
|
1545
|
+
...t.retain ? { retain: true } : {}
|
|
1412
1546
|
};
|
|
1413
1547
|
case "a2a":
|
|
1414
1548
|
return {
|
|
@@ -2399,7 +2533,7 @@ async function runComputerUse(opts) {
|
|
|
2399
2533
|
}
|
|
2400
2534
|
|
|
2401
2535
|
// src/version.ts
|
|
2402
|
-
var SDK_VERSION = "0.
|
|
2536
|
+
var SDK_VERSION = "0.20.0";
|
|
2403
2537
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2404
2538
|
0 && (module.exports = {
|
|
2405
2539
|
AgentSession,
|