@mantyx/sdk 0.19.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 +18 -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-PRUOUTDL.js → chunk-QMUVI3Y3.js} +176 -1
- package/dist/chunk-QMUVI3Y3.js.map +1 -0
- package/dist/{client-IcPVJ_lf.d.cts → client-C7TzTpNW.d.cts} +191 -2
- package/dist/{client-IcPVJ_lf.d.ts → client-C7TzTpNW.d.ts} +191 -2
- package/dist/{computer-use-C037Wspg.d.cts → computer-use-1m6E_VIl.d.cts} +1 -1
- package/dist/{computer-use-vEaAPHfv.d.ts → computer-use-4QzI3lGU.d.ts} +1 -1
- package/dist/index.cjs +176 -1
- 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-PRUOUTDL.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-C7TzTpNW.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-C7TzTpNW.js';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/a2a-server.js
CHANGED
|
@@ -667,6 +667,7 @@ function inputFileUrlAttachment(opts) {
|
|
|
667
667
|
return { type: "input_file_url", ...opts };
|
|
668
668
|
}
|
|
669
669
|
var RUN_FEEDBACK_EXPLANATION_MAX = 8e3;
|
|
670
|
+
var EVAL_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "failed", "cancelled"]);
|
|
670
671
|
function planOnly(options = {}) {
|
|
671
672
|
return {
|
|
672
673
|
planOnly: true,
|
|
@@ -1056,6 +1057,138 @@ var MantyxClient = class {
|
|
|
1056
1057
|
body
|
|
1057
1058
|
});
|
|
1058
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
|
+
const tools = spec.tools ?? [];
|
|
1075
|
+
if (tools.length > 0) {
|
|
1076
|
+
await resolveLocalRefs(tools, { fetch: this.options.fetch });
|
|
1077
|
+
}
|
|
1078
|
+
return this.request({
|
|
1079
|
+
method: "POST",
|
|
1080
|
+
path: "/eval-runs",
|
|
1081
|
+
body: serializeCreateEvalRunRequest(spec)
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
async listEvalRuns(options = {}) {
|
|
1085
|
+
const params = new URLSearchParams();
|
|
1086
|
+
if (options.datasetId) params.set("datasetId", options.datasetId);
|
|
1087
|
+
if (options.agentId) params.set("agentId", options.agentId);
|
|
1088
|
+
if (options.status) params.set("status", options.status);
|
|
1089
|
+
if (options.limit !== void 0) params.set("limit", String(options.limit));
|
|
1090
|
+
if (options.offset !== void 0) params.set("offset", String(options.offset));
|
|
1091
|
+
const qs = params.toString();
|
|
1092
|
+
return this.request({
|
|
1093
|
+
method: "GET",
|
|
1094
|
+
path: qs ? `/eval-runs?${qs}` : "/eval-runs"
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
async compareEvalRuns(runA, runB) {
|
|
1098
|
+
const params = new URLSearchParams({ a: runA, b: runB });
|
|
1099
|
+
return this.request({
|
|
1100
|
+
method: "GET",
|
|
1101
|
+
path: `/eval-runs/compare?${params}`
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
async getEvalRun(runId) {
|
|
1105
|
+
return this.request({
|
|
1106
|
+
method: "GET",
|
|
1107
|
+
path: `/eval-runs/${encodeURIComponent(runId)}`
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
async *streamEvalRun(runId, signal) {
|
|
1111
|
+
const url = this.absoluteUrl(`/eval-runs/${encodeURIComponent(runId)}/stream`);
|
|
1112
|
+
const res = await this.openSseStream(url, 0, signal);
|
|
1113
|
+
try {
|
|
1114
|
+
for await (const frame of readSseStream(res.body, { signal })) {
|
|
1115
|
+
if (!frame.data) continue;
|
|
1116
|
+
let parsed;
|
|
1117
|
+
try {
|
|
1118
|
+
parsed = JSON.parse(frame.data);
|
|
1119
|
+
} catch (err) {
|
|
1120
|
+
throw new MantyxParseError(
|
|
1121
|
+
`invalid eval SSE JSON: ${frame.data.slice(0, 200)}`,
|
|
1122
|
+
frame.data,
|
|
1123
|
+
{ cause: err }
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
yield parsed;
|
|
1127
|
+
if (parsed.type === "run_completed" || parsed.type === "run_error" || parsed.type === "run_cancelled") {
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
} finally {
|
|
1132
|
+
await res.body?.cancel().catch(() => void 0);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
async cancelEvalRun(runId) {
|
|
1136
|
+
return this.request({
|
|
1137
|
+
method: "POST",
|
|
1138
|
+
path: `/eval-runs/${encodeURIComponent(runId)}/cancel`
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Start an eval run and block until it reaches a terminal status.
|
|
1143
|
+
* Tails the SSE stream for live `onEvent` callbacks while polling
|
|
1144
|
+
* `getEvalRun` until `status` is terminal.
|
|
1145
|
+
*/
|
|
1146
|
+
async runEval(spec, options = {}) {
|
|
1147
|
+
const tools = options.tools ?? spec.tools ?? [];
|
|
1148
|
+
if (tools.length > 0) {
|
|
1149
|
+
await resolveLocalRefs(tools, { fetch: this.options.fetch });
|
|
1150
|
+
}
|
|
1151
|
+
const handlers = collectLocalHandlers(tools);
|
|
1152
|
+
try {
|
|
1153
|
+
const accepted = await this.createEvalRun({
|
|
1154
|
+
...spec,
|
|
1155
|
+
...tools.length > 0 ? { tools } : {}
|
|
1156
|
+
});
|
|
1157
|
+
const pollMs = options.pollIntervalMs ?? 1e3;
|
|
1158
|
+
const streamDone = (async () => {
|
|
1159
|
+
try {
|
|
1160
|
+
for await (const ev of this.streamEvalRun(accepted.runId, options.signal)) {
|
|
1161
|
+
if (ev.type === "local_tool_call" && tools.length > 0) {
|
|
1162
|
+
const record = ev;
|
|
1163
|
+
const nested = typeof record.data === "object" && record.data !== null && !Array.isArray(record.data) ? record.data : void 0;
|
|
1164
|
+
const agentRunId = typeof record.agentRunId === "string" ? record.agentRunId : typeof nested?.agentRunId === "string" ? nested.agentRunId : "";
|
|
1165
|
+
if (agentRunId) {
|
|
1166
|
+
const localEv = evalEventToLocalToolCall(ev);
|
|
1167
|
+
void this.dispatchLocalTool(agentRunId, localEv, handlers).catch(() => void 0);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
options.onEvent?.(ev);
|
|
1171
|
+
}
|
|
1172
|
+
} catch (err) {
|
|
1173
|
+
if (!(err instanceof MantyxNetworkError)) throw err;
|
|
1174
|
+
}
|
|
1175
|
+
})();
|
|
1176
|
+
try {
|
|
1177
|
+
while (true) {
|
|
1178
|
+
if (options.signal?.aborted) {
|
|
1179
|
+
throw new MantyxNetworkError("eval run wait aborted", { cause: options.signal.reason });
|
|
1180
|
+
}
|
|
1181
|
+
const detail = await this.getEvalRun(accepted.runId);
|
|
1182
|
+
if (EVAL_TERMINAL_STATUSES.has(detail.status)) return detail;
|
|
1183
|
+
await sleep(pollMs);
|
|
1184
|
+
}
|
|
1185
|
+
} finally {
|
|
1186
|
+
await streamDone.catch(() => void 0);
|
|
1187
|
+
}
|
|
1188
|
+
} finally {
|
|
1189
|
+
await closeMcpRefs(tools);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1059
1192
|
// -------------------------------------------------------------- HTTP
|
|
1060
1193
|
absoluteUrl(path) {
|
|
1061
1194
|
return `${this.options.baseUrl}/api/v1/workspaces/${encodeURIComponent(this.options.workspaceSlug)}${path}`;
|
|
@@ -1321,6 +1454,48 @@ function serializeAgentSpec(spec, extra = {}) {
|
|
|
1321
1454
|
Object.assign(body, serializeTurnInput(extra));
|
|
1322
1455
|
return body;
|
|
1323
1456
|
}
|
|
1457
|
+
function serializeCreateEvalRunRequest(spec) {
|
|
1458
|
+
const hasDataset = spec.datasetId !== void 0 || spec.dataset !== void 0;
|
|
1459
|
+
const hasAgent = spec.agentId !== void 0 || spec.agent !== void 0;
|
|
1460
|
+
if (!hasDataset) {
|
|
1461
|
+
throw new MantyxError("createEvalRun requires exactly one of `datasetId` or `dataset`");
|
|
1462
|
+
}
|
|
1463
|
+
if (spec.datasetId !== void 0 && spec.dataset !== void 0) {
|
|
1464
|
+
throw new MantyxError("createEvalRun accepts only one of `datasetId` or `dataset`");
|
|
1465
|
+
}
|
|
1466
|
+
if (!hasAgent) {
|
|
1467
|
+
throw new MantyxError("createEvalRun requires exactly one of `agentId` or `agent`");
|
|
1468
|
+
}
|
|
1469
|
+
if (spec.agentId !== void 0 && spec.agent !== void 0) {
|
|
1470
|
+
throw new MantyxError("createEvalRun accepts only one of `agentId` or `agent`");
|
|
1471
|
+
}
|
|
1472
|
+
const body = {};
|
|
1473
|
+
if (spec.datasetId) body.datasetId = spec.datasetId;
|
|
1474
|
+
if (spec.dataset) body.dataset = spec.dataset;
|
|
1475
|
+
if (spec.agentId) body.agentId = spec.agentId;
|
|
1476
|
+
if (spec.agent) body.agent = serializeAgentSpec(spec.agent);
|
|
1477
|
+
if (spec.tools && spec.tools.length > 0 && spec.agentId) {
|
|
1478
|
+
body.tools = serializeToolRefs(spec.tools);
|
|
1479
|
+
}
|
|
1480
|
+
if (spec.modelId) body.modelId = spec.modelId;
|
|
1481
|
+
if (spec.overrides) body.overrides = spec.overrides;
|
|
1482
|
+
return body;
|
|
1483
|
+
}
|
|
1484
|
+
function evalEventToLocalToolCall(ev) {
|
|
1485
|
+
const data = ev.data && typeof ev.data === "object" && !Array.isArray(ev.data) ? ev.data : ev;
|
|
1486
|
+
return {
|
|
1487
|
+
type: "local_tool_call",
|
|
1488
|
+
seq: 0,
|
|
1489
|
+
toolUseId: String(data.toolUseId ?? ""),
|
|
1490
|
+
name: String(data.name ?? ""),
|
|
1491
|
+
args: data.args ?? {},
|
|
1492
|
+
...typeof data.kind === "string" ? { kind: data.kind } : {},
|
|
1493
|
+
...data.agentCard !== void 0 ? { agentCard: data.agentCard } : {},
|
|
1494
|
+
...typeof data.mcpServer === "string" ? { mcpServer: data.mcpServer } : {},
|
|
1495
|
+
...typeof data.mcpToolName === "string" ? { mcpToolName: data.mcpToolName } : {},
|
|
1496
|
+
...data.mcpServerInfo !== void 0 ? { mcpServerInfo: data.mcpServerInfo } : {}
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1324
1499
|
function serializeToolRefs(tools) {
|
|
1325
1500
|
return tools.map((t) => {
|
|
1326
1501
|
switch (t.kind) {
|
|
@@ -1783,4 +1958,4 @@ export {
|
|
|
1783
1958
|
AgentSession,
|
|
1784
1959
|
parseRunOutput
|
|
1785
1960
|
};
|
|
1786
|
-
//# sourceMappingURL=chunk-
|
|
1961
|
+
//# sourceMappingURL=chunk-QMUVI3Y3.js.map
|