@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/a2a-server.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { AgentCard } from '@a2a-js/sdk';
|
|
|
2
2
|
export { AgentCard, Message, MessageSendParams, Task, TaskArtifactUpdateEvent, TaskStatusUpdateEvent } from '@a2a-js/sdk';
|
|
3
3
|
import { AgentExecutor, RequestContext, ExecutionEventBus } from '@a2a-js/sdk/server';
|
|
4
4
|
export { AgentExecutor, ExecutionEventBus, RequestContext } from '@a2a-js/sdk/server';
|
|
5
|
-
import { M as MantyxClient, T as ToolRef, R as ReasoningLevel, O as OutputSchema } from './client-
|
|
5
|
+
import { M as MantyxClient, T as ToolRef, R as ReasoningLevel, O as OutputSchema } from './client-D4-MQANp.cjs';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/a2a-server.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AgentCard } from '@a2a-js/sdk';
|
|
|
2
2
|
export { AgentCard, Message, MessageSendParams, Task, TaskArtifactUpdateEvent, TaskStatusUpdateEvent } from '@a2a-js/sdk';
|
|
3
3
|
import { AgentExecutor, RequestContext, ExecutionEventBus } from '@a2a-js/sdk/server';
|
|
4
4
|
export { AgentExecutor, ExecutionEventBus, RequestContext } from '@a2a-js/sdk/server';
|
|
5
|
-
import { M as MantyxClient, T as ToolRef, R as ReasoningLevel, O as OutputSchema } from './client-
|
|
5
|
+
import { M as MantyxClient, T as ToolRef, R as ReasoningLevel, O as OutputSchema } from './client-D4-MQANp.js';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/a2a-server.js
CHANGED
|
@@ -102,6 +102,7 @@ function defineLocalTool(opts) {
|
|
|
102
102
|
outputSchema: opts.outputSchema,
|
|
103
103
|
longRunning: opts.longRunning ?? false,
|
|
104
104
|
readOnly: opts.readOnly ?? false,
|
|
105
|
+
retain: opts.retain ?? false,
|
|
105
106
|
execute: opts.execute
|
|
106
107
|
};
|
|
107
108
|
}
|
|
@@ -666,6 +667,7 @@ function inputFileUrlAttachment(opts) {
|
|
|
666
667
|
return { type: "input_file_url", ...opts };
|
|
667
668
|
}
|
|
668
669
|
var RUN_FEEDBACK_EXPLANATION_MAX = 8e3;
|
|
670
|
+
var EVAL_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "failed", "cancelled"]);
|
|
669
671
|
function planOnly(options = {}) {
|
|
670
672
|
return {
|
|
671
673
|
planOnly: true,
|
|
@@ -1055,6 +1057,113 @@ var MantyxClient = class {
|
|
|
1055
1057
|
body
|
|
1056
1058
|
});
|
|
1057
1059
|
}
|
|
1060
|
+
// --------------------------------------------------------------- Evals
|
|
1061
|
+
async listEvalDatasets() {
|
|
1062
|
+
return this.request({
|
|
1063
|
+
method: "GET",
|
|
1064
|
+
path: "/eval-datasets"
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
async getEvalDataset(datasetId) {
|
|
1068
|
+
return this.request({
|
|
1069
|
+
method: "GET",
|
|
1070
|
+
path: `/eval-datasets/${encodeURIComponent(datasetId)}`
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
async createEvalRun(spec) {
|
|
1074
|
+
return this.request({
|
|
1075
|
+
method: "POST",
|
|
1076
|
+
path: "/eval-runs",
|
|
1077
|
+
body: serializeCreateEvalRunRequest(spec)
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
async listEvalRuns(options = {}) {
|
|
1081
|
+
const params = new URLSearchParams();
|
|
1082
|
+
if (options.datasetId) params.set("datasetId", options.datasetId);
|
|
1083
|
+
if (options.agentId) params.set("agentId", options.agentId);
|
|
1084
|
+
if (options.status) params.set("status", options.status);
|
|
1085
|
+
if (options.limit !== void 0) params.set("limit", String(options.limit));
|
|
1086
|
+
if (options.offset !== void 0) params.set("offset", String(options.offset));
|
|
1087
|
+
const qs = params.toString();
|
|
1088
|
+
return this.request({
|
|
1089
|
+
method: "GET",
|
|
1090
|
+
path: qs ? `/eval-runs?${qs}` : "/eval-runs"
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
async compareEvalRuns(runA, runB) {
|
|
1094
|
+
const params = new URLSearchParams({ a: runA, b: runB });
|
|
1095
|
+
return this.request({
|
|
1096
|
+
method: "GET",
|
|
1097
|
+
path: `/eval-runs/compare?${params}`
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
async getEvalRun(runId) {
|
|
1101
|
+
return this.request({
|
|
1102
|
+
method: "GET",
|
|
1103
|
+
path: `/eval-runs/${encodeURIComponent(runId)}`
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
async *streamEvalRun(runId, signal) {
|
|
1107
|
+
const url = this.absoluteUrl(`/eval-runs/${encodeURIComponent(runId)}/stream`);
|
|
1108
|
+
const res = await this.openSseStream(url, 0, signal);
|
|
1109
|
+
try {
|
|
1110
|
+
for await (const frame of readSseStream(res.body, { signal })) {
|
|
1111
|
+
if (!frame.data) continue;
|
|
1112
|
+
let parsed;
|
|
1113
|
+
try {
|
|
1114
|
+
parsed = JSON.parse(frame.data);
|
|
1115
|
+
} catch (err) {
|
|
1116
|
+
throw new MantyxParseError(
|
|
1117
|
+
`invalid eval SSE JSON: ${frame.data.slice(0, 200)}`,
|
|
1118
|
+
frame.data,
|
|
1119
|
+
{ cause: err }
|
|
1120
|
+
);
|
|
1121
|
+
}
|
|
1122
|
+
yield parsed;
|
|
1123
|
+
if (parsed.type === "run_completed" || parsed.type === "run_error" || parsed.type === "run_cancelled") {
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
} finally {
|
|
1128
|
+
await res.body?.cancel().catch(() => void 0);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
async cancelEvalRun(runId) {
|
|
1132
|
+
return this.request({
|
|
1133
|
+
method: "POST",
|
|
1134
|
+
path: `/eval-runs/${encodeURIComponent(runId)}/cancel`
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Start an eval run and block until it reaches a terminal status.
|
|
1139
|
+
* Tails the SSE stream for live `onEvent` callbacks while polling
|
|
1140
|
+
* `getEvalRun` until `status` is terminal.
|
|
1141
|
+
*/
|
|
1142
|
+
async runEval(spec, options = {}) {
|
|
1143
|
+
const accepted = await this.createEvalRun(spec);
|
|
1144
|
+
const pollMs = options.pollIntervalMs ?? 1e3;
|
|
1145
|
+
const streamDone = (async () => {
|
|
1146
|
+
try {
|
|
1147
|
+
for await (const ev of this.streamEvalRun(accepted.runId, options.signal)) {
|
|
1148
|
+
options.onEvent?.(ev);
|
|
1149
|
+
}
|
|
1150
|
+
} catch (err) {
|
|
1151
|
+
if (!(err instanceof MantyxNetworkError)) throw err;
|
|
1152
|
+
}
|
|
1153
|
+
})();
|
|
1154
|
+
try {
|
|
1155
|
+
while (true) {
|
|
1156
|
+
if (options.signal?.aborted) {
|
|
1157
|
+
throw new MantyxNetworkError("eval run wait aborted", { cause: options.signal.reason });
|
|
1158
|
+
}
|
|
1159
|
+
const detail = await this.getEvalRun(accepted.runId);
|
|
1160
|
+
if (EVAL_TERMINAL_STATUSES.has(detail.status)) return detail;
|
|
1161
|
+
await sleep(pollMs);
|
|
1162
|
+
}
|
|
1163
|
+
} finally {
|
|
1164
|
+
await streamDone.catch(() => void 0);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1058
1167
|
// -------------------------------------------------------------- HTTP
|
|
1059
1168
|
absoluteUrl(path) {
|
|
1060
1169
|
return `${this.options.baseUrl}/api/v1/workspaces/${encodeURIComponent(this.options.workspaceSlug)}${path}`;
|
|
@@ -1320,6 +1429,30 @@ function serializeAgentSpec(spec, extra = {}) {
|
|
|
1320
1429
|
Object.assign(body, serializeTurnInput(extra));
|
|
1321
1430
|
return body;
|
|
1322
1431
|
}
|
|
1432
|
+
function serializeCreateEvalRunRequest(spec) {
|
|
1433
|
+
const hasDataset = spec.datasetId !== void 0 || spec.dataset !== void 0;
|
|
1434
|
+
const hasAgent = spec.agentId !== void 0 || spec.agent !== void 0;
|
|
1435
|
+
if (!hasDataset) {
|
|
1436
|
+
throw new MantyxError("createEvalRun requires exactly one of `datasetId` or `dataset`");
|
|
1437
|
+
}
|
|
1438
|
+
if (spec.datasetId !== void 0 && spec.dataset !== void 0) {
|
|
1439
|
+
throw new MantyxError("createEvalRun accepts only one of `datasetId` or `dataset`");
|
|
1440
|
+
}
|
|
1441
|
+
if (!hasAgent) {
|
|
1442
|
+
throw new MantyxError("createEvalRun requires exactly one of `agentId` or `agent`");
|
|
1443
|
+
}
|
|
1444
|
+
if (spec.agentId !== void 0 && spec.agent !== void 0) {
|
|
1445
|
+
throw new MantyxError("createEvalRun accepts only one of `agentId` or `agent`");
|
|
1446
|
+
}
|
|
1447
|
+
const body = {};
|
|
1448
|
+
if (spec.datasetId) body.datasetId = spec.datasetId;
|
|
1449
|
+
if (spec.dataset) body.dataset = spec.dataset;
|
|
1450
|
+
if (spec.agentId) body.agentId = spec.agentId;
|
|
1451
|
+
if (spec.agent) body.agent = serializeAgentSpec(spec.agent);
|
|
1452
|
+
if (spec.modelId) body.modelId = spec.modelId;
|
|
1453
|
+
if (spec.overrides) body.overrides = spec.overrides;
|
|
1454
|
+
return body;
|
|
1455
|
+
}
|
|
1323
1456
|
function serializeToolRefs(tools) {
|
|
1324
1457
|
return tools.map((t) => {
|
|
1325
1458
|
switch (t.kind) {
|
|
@@ -1335,7 +1468,8 @@ function serializeToolRefs(tools) {
|
|
|
1335
1468
|
parameters: toToolParametersWire(t.parameters),
|
|
1336
1469
|
...t.outputSchema !== void 0 ? { outputSchema: toToolParametersWire(t.outputSchema) } : {},
|
|
1337
1470
|
...t.longRunning ? { longRunning: true } : {},
|
|
1338
|
-
...t.readOnly ? { readOnly: true } : {}
|
|
1471
|
+
...t.readOnly ? { readOnly: true } : {},
|
|
1472
|
+
...t.retain ? { retain: true } : {}
|
|
1339
1473
|
};
|
|
1340
1474
|
case "a2a":
|
|
1341
1475
|
return {
|
|
@@ -1781,4 +1915,4 @@ export {
|
|
|
1781
1915
|
AgentSession,
|
|
1782
1916
|
parseRunOutput
|
|
1783
1917
|
};
|
|
1784
|
-
//# sourceMappingURL=chunk-
|
|
1918
|
+
//# sourceMappingURL=chunk-ZOFQ5AN6.js.map
|