@mantyx/sdk 0.20.0 → 0.22.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-ZOFQ5AN6.js → chunk-5NKXV5XZ.js} +91 -24
- package/dist/chunk-5NKXV5XZ.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 +91 -24
- 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/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
|
@@ -1019,11 +1019,23 @@ var MantyxClient = class {
|
|
|
1019
1019
|
}
|
|
1020
1020
|
}
|
|
1021
1021
|
async postToolResult(runId, toolUseId, payload) {
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1022
|
+
const path = `/agent-runs/${encodeURIComponent(runId)}/tool-results`;
|
|
1023
|
+
const body = { toolUseId, ...payload };
|
|
1024
|
+
for (let attempt = 0; attempt < TOOL_RESULT_POST_MAX_ATTEMPTS; attempt++) {
|
|
1025
|
+
try {
|
|
1026
|
+
await this.request({
|
|
1027
|
+
method: "POST",
|
|
1028
|
+
path,
|
|
1029
|
+
body
|
|
1030
|
+
});
|
|
1031
|
+
return;
|
|
1032
|
+
} catch (err) {
|
|
1033
|
+
if (attempt === TOOL_RESULT_POST_MAX_ATTEMPTS - 1 || !isToolResultPostRetryable(err)) {
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
1036
|
+
await sleep(toolResultPostBackoffMs(attempt));
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1027
1039
|
}
|
|
1028
1040
|
async cancelRun(runId) {
|
|
1029
1041
|
await this.request({
|
|
@@ -1071,6 +1083,10 @@ var MantyxClient = class {
|
|
|
1071
1083
|
});
|
|
1072
1084
|
}
|
|
1073
1085
|
async createEvalRun(spec) {
|
|
1086
|
+
const tools = spec.tools ?? [];
|
|
1087
|
+
if (tools.length > 0) {
|
|
1088
|
+
await resolveLocalRefs(tools, { fetch: this.options.fetch });
|
|
1089
|
+
}
|
|
1074
1090
|
return this.request({
|
|
1075
1091
|
method: "POST",
|
|
1076
1092
|
path: "/eval-runs",
|
|
@@ -1140,28 +1156,49 @@ var MantyxClient = class {
|
|
|
1140
1156
|
* `getEvalRun` until `status` is terminal.
|
|
1141
1157
|
*/
|
|
1142
1158
|
async runEval(spec, options = {}) {
|
|
1143
|
-
const
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
options.onEvent?.(ev);
|
|
1149
|
-
}
|
|
1150
|
-
} catch (err) {
|
|
1151
|
-
if (!(err instanceof MantyxNetworkError)) throw err;
|
|
1152
|
-
}
|
|
1153
|
-
})();
|
|
1159
|
+
const tools = options.tools ?? spec.tools ?? [];
|
|
1160
|
+
if (tools.length > 0) {
|
|
1161
|
+
await resolveLocalRefs(tools, { fetch: this.options.fetch });
|
|
1162
|
+
}
|
|
1163
|
+
const handlers = collectLocalHandlers(tools);
|
|
1154
1164
|
try {
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1165
|
+
const accepted = await this.createEvalRun({
|
|
1166
|
+
...spec,
|
|
1167
|
+
...tools.length > 0 ? { tools } : {}
|
|
1168
|
+
});
|
|
1169
|
+
const pollMs = options.pollIntervalMs ?? 1e3;
|
|
1170
|
+
const streamDone = (async () => {
|
|
1171
|
+
try {
|
|
1172
|
+
for await (const ev of this.streamEvalRun(accepted.runId, options.signal)) {
|
|
1173
|
+
if (ev.type === "local_tool_call" && tools.length > 0) {
|
|
1174
|
+
const record = ev;
|
|
1175
|
+
const nested = typeof record.data === "object" && record.data !== null && !Array.isArray(record.data) ? record.data : void 0;
|
|
1176
|
+
const agentRunId = typeof record.agentRunId === "string" ? record.agentRunId : typeof nested?.agentRunId === "string" ? nested.agentRunId : "";
|
|
1177
|
+
if (agentRunId) {
|
|
1178
|
+
const localEv = evalEventToLocalToolCall(ev);
|
|
1179
|
+
void this.dispatchLocalTool(agentRunId, localEv, handlers).catch(() => void 0);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
options.onEvent?.(ev);
|
|
1183
|
+
}
|
|
1184
|
+
} catch (err) {
|
|
1185
|
+
if (!(err instanceof MantyxNetworkError)) throw err;
|
|
1186
|
+
}
|
|
1187
|
+
})();
|
|
1188
|
+
try {
|
|
1189
|
+
while (true) {
|
|
1190
|
+
if (options.signal?.aborted) {
|
|
1191
|
+
throw new MantyxNetworkError("eval run wait aborted", { cause: options.signal.reason });
|
|
1192
|
+
}
|
|
1193
|
+
const detail = await this.getEvalRun(accepted.runId);
|
|
1194
|
+
if (EVAL_TERMINAL_STATUSES.has(detail.status)) return detail;
|
|
1195
|
+
await sleep(pollMs);
|
|
1158
1196
|
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
await sleep(pollMs);
|
|
1197
|
+
} finally {
|
|
1198
|
+
await streamDone.catch(() => void 0);
|
|
1162
1199
|
}
|
|
1163
1200
|
} finally {
|
|
1164
|
-
await
|
|
1201
|
+
await closeMcpRefs(tools);
|
|
1165
1202
|
}
|
|
1166
1203
|
}
|
|
1167
1204
|
// -------------------------------------------------------------- HTTP
|
|
@@ -1449,10 +1486,28 @@ function serializeCreateEvalRunRequest(spec) {
|
|
|
1449
1486
|
if (spec.dataset) body.dataset = spec.dataset;
|
|
1450
1487
|
if (spec.agentId) body.agentId = spec.agentId;
|
|
1451
1488
|
if (spec.agent) body.agent = serializeAgentSpec(spec.agent);
|
|
1489
|
+
if (spec.tools && spec.tools.length > 0 && spec.agentId) {
|
|
1490
|
+
body.tools = serializeToolRefs(spec.tools);
|
|
1491
|
+
}
|
|
1452
1492
|
if (spec.modelId) body.modelId = spec.modelId;
|
|
1453
1493
|
if (spec.overrides) body.overrides = spec.overrides;
|
|
1454
1494
|
return body;
|
|
1455
1495
|
}
|
|
1496
|
+
function evalEventToLocalToolCall(ev) {
|
|
1497
|
+
const data = ev.data && typeof ev.data === "object" && !Array.isArray(ev.data) ? ev.data : ev;
|
|
1498
|
+
return {
|
|
1499
|
+
type: "local_tool_call",
|
|
1500
|
+
seq: 0,
|
|
1501
|
+
toolUseId: String(data.toolUseId ?? ""),
|
|
1502
|
+
name: String(data.name ?? ""),
|
|
1503
|
+
args: data.args ?? {},
|
|
1504
|
+
...typeof data.kind === "string" ? { kind: data.kind } : {},
|
|
1505
|
+
...data.agentCard !== void 0 ? { agentCard: data.agentCard } : {},
|
|
1506
|
+
...typeof data.mcpServer === "string" ? { mcpServer: data.mcpServer } : {},
|
|
1507
|
+
...typeof data.mcpToolName === "string" ? { mcpToolName: data.mcpToolName } : {},
|
|
1508
|
+
...data.mcpServerInfo !== void 0 ? { mcpServerInfo: data.mcpServerInfo } : {}
|
|
1509
|
+
};
|
|
1510
|
+
}
|
|
1456
1511
|
function serializeToolRefs(tools) {
|
|
1457
1512
|
return tools.map((t) => {
|
|
1458
1513
|
switch (t.kind) {
|
|
@@ -1819,6 +1874,18 @@ function parseRunOutput(result, validator) {
|
|
|
1819
1874
|
function sleep(ms) {
|
|
1820
1875
|
return new Promise((r) => setTimeout(r, ms));
|
|
1821
1876
|
}
|
|
1877
|
+
var TOOL_RESULT_POST_MAX_ATTEMPTS = 6;
|
|
1878
|
+
function toolResultPostBackoffMs(attempt) {
|
|
1879
|
+
return Math.min(500 * 2 ** attempt, 8e3);
|
|
1880
|
+
}
|
|
1881
|
+
function isToolResultPostRetryable(err) {
|
|
1882
|
+
if (err instanceof MantyxNetworkError) return true;
|
|
1883
|
+
if (err instanceof MantyxError && typeof err.status === "number") {
|
|
1884
|
+
if (err.status === 429) return true;
|
|
1885
|
+
if (err.status >= 500) return true;
|
|
1886
|
+
}
|
|
1887
|
+
return false;
|
|
1888
|
+
}
|
|
1822
1889
|
function parseRunTokens(value) {
|
|
1823
1890
|
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
1824
1891
|
const v = value;
|
|
@@ -1915,4 +1982,4 @@ export {
|
|
|
1915
1982
|
AgentSession,
|
|
1916
1983
|
parseRunOutput
|
|
1917
1984
|
};
|
|
1918
|
-
//# sourceMappingURL=chunk-
|
|
1985
|
+
//# sourceMappingURL=chunk-5NKXV5XZ.js.map
|