@mantyx/sdk 0.15.0 → 0.16.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-fu11V4HX.cjs';
5
+ import { M as MantyxClient, T as ToolRef, R as ReasoningLevel, O as OutputSchema } from './client-DgBXj6Dh.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-fu11V4HX.js';
5
+ import { M as MantyxClient, T as ToolRef, R as ReasoningLevel, O as OutputSchema } from './client-DgBXj6Dh.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-TLKXNZYY.js";
4
+ } from "./chunk-EEVTNG4C.js";
5
5
 
6
6
  // src/a2a-server.ts
7
7
  var MantyxAgentExecutor = class {
@@ -295,7 +295,20 @@ function parseEventBlock(block) {
295
295
 
296
296
  // src/zod-to-json-schema.ts
297
297
  import { z } from "zod";
298
+ function isZodSchema(value) {
299
+ if (!value || typeof value !== "object") return false;
300
+ const o = value;
301
+ return typeof o._def !== "undefined" || typeof o._zod !== "undefined";
302
+ }
298
303
  function zodToJsonSchema(schema) {
304
+ const instance = schema;
305
+ if (typeof instance.toJSONSchema === "function") {
306
+ try {
307
+ const out = instance.toJSONSchema();
308
+ if (out && typeof out === "object") return out;
309
+ } catch {
310
+ }
311
+ }
299
312
  const builtIn = z.toJSONSchema;
300
313
  if (typeof builtIn === "function") {
301
314
  try {
@@ -306,24 +319,40 @@ function zodToJsonSchema(schema) {
306
319
  }
307
320
  return convertNode(schema);
308
321
  }
322
+ function schemaKind(def) {
323
+ if (!def) return void 0;
324
+ if (typeof def.typeName === "string") return def.typeName;
325
+ if (typeof def.type === "string") return def.type;
326
+ return void 0;
327
+ }
328
+ function isOptionalField(field) {
329
+ const kind = schemaKind(field._def);
330
+ return kind === "ZodOptional" || kind === "ZodDefault" || kind === "optional" || kind === "default";
331
+ }
309
332
  function convertNode(schema) {
310
333
  const def = schema._def;
311
- const typeName = def?.typeName;
312
- switch (typeName) {
334
+ const kind = schemaKind(def);
335
+ switch (kind) {
313
336
  case "ZodString":
337
+ case "string":
314
338
  return { type: "string" };
315
339
  case "ZodNumber":
340
+ case "number":
316
341
  return { type: "number" };
317
342
  case "ZodBoolean":
343
+ case "boolean":
318
344
  return { type: "boolean" };
319
345
  case "ZodNull":
346
+ case "null":
320
347
  return { type: "null" };
321
- case "ZodLiteral": {
322
- const value = def.value;
348
+ case "ZodLiteral":
349
+ case "literal": {
350
+ const value = def?.value;
323
351
  return { const: value, type: typeof value };
324
352
  }
325
- case "ZodEnum": {
326
- const values = def.values ?? [];
353
+ case "ZodEnum":
354
+ case "enum": {
355
+ const values = def?.values ?? [];
327
356
  return { type: "string", enum: [...values] };
328
357
  }
329
358
  case "ZodArray": {
@@ -333,26 +362,35 @@ function convertNode(schema) {
333
362
  items: inner ? convertNode(inner) : {}
334
363
  };
335
364
  }
365
+ case "array": {
366
+ const inner = def?.element;
367
+ return {
368
+ type: "array",
369
+ items: inner ? convertNode(inner) : {}
370
+ };
371
+ }
336
372
  case "ZodOptional":
337
- case "ZodNullable": {
338
- const inner = def.innerType;
373
+ case "ZodNullable":
374
+ case "optional":
375
+ case "nullable": {
376
+ const inner = def?.innerType;
339
377
  return inner ? convertNode(inner) : {};
340
378
  }
341
- case "ZodDefault": {
342
- const inner = def.innerType;
379
+ case "ZodDefault":
380
+ case "default": {
381
+ const inner = def?.innerType;
343
382
  return inner ? convertNode(inner) : {};
344
383
  }
345
- case "ZodObject": {
346
- const shape = def.shape;
384
+ case "ZodObject":
385
+ case "object": {
386
+ const shape = def?.shape;
347
387
  const fields = typeof shape === "function" ? shape() : shape;
348
388
  const properties = {};
349
389
  const required = [];
350
390
  if (fields) {
351
391
  for (const [key, value] of Object.entries(fields)) {
352
392
  properties[key] = convertNode(value);
353
- const innerDef = value._def;
354
- const innerTypeName = innerDef?.typeName;
355
- if (innerTypeName !== "ZodOptional" && innerTypeName !== "ZodDefault") {
393
+ if (!isOptionalField(value)) {
356
394
  required.push(key);
357
395
  }
358
396
  }
@@ -367,7 +405,7 @@ function convertNode(schema) {
367
405
  }
368
406
  function toToolParametersWire(parameters) {
369
407
  if (!parameters) return { type: "object", properties: {} };
370
- if (typeof parameters._def !== "undefined") {
408
+ if (isZodSchema(parameters)) {
371
409
  return zodToJsonSchema(parameters);
372
410
  }
373
411
  return parameters;
@@ -1409,23 +1447,24 @@ function normalizeLoopDetection(value) {
1409
1447
  }
1410
1448
  return out;
1411
1449
  }
1412
- function assertThreshold(label, value, min) {
1450
+ function assertThreshold(label, value, min, max = LOOP_DETECTION_THRESHOLD_MAX) {
1413
1451
  if (typeof value !== "number" || !Number.isFinite(value) || !Number.isInteger(value)) {
1414
1452
  throw new MantyxError(`${label} must be an integer, got ${JSON.stringify(value)}`);
1415
1453
  }
1416
1454
  if (value < min) {
1417
1455
  throw new MantyxError(`${label} must be >= ${min}, got ${value}`);
1418
1456
  }
1419
- if (value > LOOP_DETECTION_THRESHOLD_MAX) {
1420
- throw new MantyxError(
1421
- `${label} must be <= ${LOOP_DETECTION_THRESHOLD_MAX} (server-enforced), got ${value}`
1422
- );
1457
+ if (value > max) {
1458
+ throw new MantyxError(`${label} must be <= ${max} (server-enforced), got ${value}`);
1423
1459
  }
1424
1460
  return value;
1425
1461
  }
1426
1462
  var TOOL_BUDGETS_MAX_ENTRIES = 32;
1427
1463
  var TOOL_BUDGET_MAX_NAME_LEN = 120;
1428
1464
  var TOOL_BUDGET_MAX_CALLS = 1e3;
1465
+ var SUPERVISOR_INTERVAL_MAX = 100;
1466
+ var SUPERVISOR_REASONING_CHARS_MAX = 5e4;
1467
+ var SUPERVISOR_REASONING_MS_MAX = 6e5;
1429
1468
  function normalizeSupervisor(value) {
1430
1469
  if (value === false) return false;
1431
1470
  if (!value || typeof value !== "object" || Array.isArray(value)) {
@@ -1435,7 +1474,35 @@ function normalizeSupervisor(value) {
1435
1474
  }
1436
1475
  const out = {};
1437
1476
  if (value.interval !== void 0) {
1438
- out.interval = assertThreshold("supervisor.interval", value.interval, 1);
1477
+ out.interval = assertThreshold("supervisor.interval", value.interval, 1, SUPERVISOR_INTERVAL_MAX);
1478
+ }
1479
+ if (value.reasoningTrigger !== void 0) {
1480
+ if (value.reasoningTrigger === false) {
1481
+ out.reasoningTrigger = false;
1482
+ } else if (!value.reasoningTrigger || typeof value.reasoningTrigger !== "object" || Array.isArray(value.reasoningTrigger)) {
1483
+ throw new MantyxError(
1484
+ `supervisor.reasoningTrigger must be \`false\` or an object { chars?, ms? }, got ${JSON.stringify(value.reasoningTrigger)}`
1485
+ );
1486
+ } else {
1487
+ const rt = {};
1488
+ if (value.reasoningTrigger.chars !== void 0) {
1489
+ rt.chars = assertThreshold(
1490
+ "supervisor.reasoningTrigger.chars",
1491
+ value.reasoningTrigger.chars,
1492
+ 1,
1493
+ SUPERVISOR_REASONING_CHARS_MAX
1494
+ );
1495
+ }
1496
+ if (value.reasoningTrigger.ms !== void 0) {
1497
+ rt.ms = assertThreshold(
1498
+ "supervisor.reasoningTrigger.ms",
1499
+ value.reasoningTrigger.ms,
1500
+ 1,
1501
+ SUPERVISOR_REASONING_MS_MAX
1502
+ );
1503
+ }
1504
+ out.reasoningTrigger = rt;
1505
+ }
1439
1506
  }
1440
1507
  return out;
1441
1508
  }
@@ -1657,4 +1724,4 @@ export {
1657
1724
  AgentSession,
1658
1725
  parseRunOutput
1659
1726
  };
1660
- //# sourceMappingURL=chunk-TLKXNZYY.js.map
1727
+ //# sourceMappingURL=chunk-EEVTNG4C.js.map