@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.
@@ -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-D4-MQANp.cjs';
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
  /**
@@ -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-D4-MQANp.js';
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
  /**
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MantyxError,
3
3
  MantyxRunError
4
- } from "./chunk-ZOFQ5AN6.js";
4
+ } from "./chunk-QMUVI3Y3.js";
5
5
 
6
6
  // src/a2a-server.ts
7
7
  var MantyxAgentExecutor = class {
@@ -1071,6 +1071,10 @@ var MantyxClient = class {
1071
1071
  });
1072
1072
  }
1073
1073
  async createEvalRun(spec) {
1074
+ const tools = spec.tools ?? [];
1075
+ if (tools.length > 0) {
1076
+ await resolveLocalRefs(tools, { fetch: this.options.fetch });
1077
+ }
1074
1078
  return this.request({
1075
1079
  method: "POST",
1076
1080
  path: "/eval-runs",
@@ -1140,28 +1144,49 @@ var MantyxClient = class {
1140
1144
  * `getEvalRun` until `status` is terminal.
1141
1145
  */
1142
1146
  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
- })();
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);
1154
1152
  try {
1155
- while (true) {
1156
- if (options.signal?.aborted) {
1157
- throw new MantyxNetworkError("eval run wait aborted", { cause: options.signal.reason });
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);
1158
1184
  }
1159
- const detail = await this.getEvalRun(accepted.runId);
1160
- if (EVAL_TERMINAL_STATUSES.has(detail.status)) return detail;
1161
- await sleep(pollMs);
1185
+ } finally {
1186
+ await streamDone.catch(() => void 0);
1162
1187
  }
1163
1188
  } finally {
1164
- await streamDone.catch(() => void 0);
1189
+ await closeMcpRefs(tools);
1165
1190
  }
1166
1191
  }
1167
1192
  // -------------------------------------------------------------- HTTP
@@ -1449,10 +1474,28 @@ function serializeCreateEvalRunRequest(spec) {
1449
1474
  if (spec.dataset) body.dataset = spec.dataset;
1450
1475
  if (spec.agentId) body.agentId = spec.agentId;
1451
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
+ }
1452
1480
  if (spec.modelId) body.modelId = spec.modelId;
1453
1481
  if (spec.overrides) body.overrides = spec.overrides;
1454
1482
  return body;
1455
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
+ }
1456
1499
  function serializeToolRefs(tools) {
1457
1500
  return tools.map((t) => {
1458
1501
  switch (t.kind) {
@@ -1915,4 +1958,4 @@ export {
1915
1958
  AgentSession,
1916
1959
  parseRunOutput
1917
1960
  };
1918
- //# sourceMappingURL=chunk-ZOFQ5AN6.js.map
1961
+ //# sourceMappingURL=chunk-QMUVI3Y3.js.map