@mantyx/sdk 0.23.0 → 0.25.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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MantyxError,
3
3
  MantyxRunError
4
- } from "./chunk-OUK6ZZ5H.js";
4
+ } from "./chunk-4EJRV6KZ.js";
5
5
 
6
6
  // src/a2a-server.ts
7
7
  var MantyxAgentExecutor = class {
@@ -65,6 +65,12 @@ var MantyxRunError = class extends MantyxError {
65
65
  turns;
66
66
  /** See {@link MantyxRunErrorInit.model}. */
67
67
  model;
68
+ /** Provider HTTP status associated with the failure, when available. */
69
+ apiStatus;
70
+ /** Provider-specific error code associated with the failure, when available. */
71
+ apiCode;
72
+ /** Structured-output enforcement metadata, when reported by the server. */
73
+ structuredOutput;
68
74
  constructor(runId, subtype, message, init = {}) {
69
75
  super(message, { code: subtype });
70
76
  this.name = "MantyxRunError";
@@ -77,6 +83,9 @@ var MantyxRunError = class extends MantyxError {
77
83
  this.tokens = init.tokens;
78
84
  this.turns = init.turns;
79
85
  this.model = init.model;
86
+ this.apiStatus = init.apiStatus;
87
+ this.apiCode = init.apiCode;
88
+ this.structuredOutput = init.structuredOutput;
80
89
  }
81
90
  };
82
91
  var MantyxParseError = class extends MantyxError {
@@ -896,6 +905,7 @@ var MantyxClient = class {
896
905
  let tokens;
897
906
  let turns;
898
907
  let modelInfo;
908
+ let structuredOutput;
899
909
  let plan;
900
910
  for await (const ev of this.streamRunEvents(runId, handlers, opts.signal)) {
901
911
  collected.push(ev);
@@ -908,6 +918,7 @@ var MantyxClient = class {
908
918
  tokens = parseRunTokens(r.tokens) ?? tokens;
909
919
  turns = parseRunTurns(r.turns) ?? turns;
910
920
  modelInfo = parseRunModel(r.model) ?? modelInfo;
921
+ structuredOutput = parseStructuredOutputInfo(r.structuredOutput) ?? structuredOutput;
911
922
  if (r.subtype === "success") {
912
923
  finalText = typeof r.text === "string" ? r.text : "";
913
924
  const parsedPlan = parseTaskPlan(r.plan);
@@ -919,6 +930,7 @@ var MantyxClient = class {
919
930
  if (tokens !== void 0) errInit.tokens = tokens;
920
931
  if (turns !== void 0) errInit.turns = turns;
921
932
  if (modelInfo !== void 0) errInit.model = modelInfo;
933
+ if (structuredOutput !== void 0) errInit.structuredOutput = structuredOutput;
922
934
  throw new MantyxRunError(runId, r.subtype, r.error ?? r.subtype, errInit);
923
935
  }
924
936
  } else if (ev.type === "error") {
@@ -929,12 +941,16 @@ var MantyxClient = class {
929
941
  if (e.finishReason !== void 0) errInit.finishReason = e.finishReason;
930
942
  if (typeof e.partialText === "string") errInit.partialText = e.partialText;
931
943
  if (typeof e.retryable === "boolean") errInit.retryable = e.retryable;
944
+ if (typeof e.apiStatus === "number") errInit.apiStatus = e.apiStatus;
945
+ if (typeof e.apiCode === "string") errInit.apiCode = e.apiCode;
932
946
  const errTokens = parseRunTokens(e.tokens);
933
947
  if (errTokens !== void 0) errInit.tokens = errTokens;
934
948
  const errTurns = parseRunTurns(e.turns);
935
949
  if (errTurns !== void 0) errInit.turns = errTurns;
936
950
  const errModel = parseRunModel(e.model);
937
951
  if (errModel !== void 0) errInit.model = errModel;
952
+ const errStructuredOutput = parseStructuredOutputInfo(e.structuredOutput);
953
+ if (errStructuredOutput !== void 0) errInit.structuredOutput = errStructuredOutput;
938
954
  throw new MantyxRunError(runId, subtype, e.error, errInit);
939
955
  } else if (ev.type === "cancelled") {
940
956
  throw new MantyxRunError(runId, "cancelled", "Run was cancelled");
@@ -944,6 +960,7 @@ var MantyxClient = class {
944
960
  if (tokens !== void 0) result.tokens = tokens;
945
961
  if (turns !== void 0) result.turns = turns;
946
962
  if (modelInfo !== void 0) result.model = modelInfo;
963
+ if (structuredOutput !== void 0) result.structuredOutput = structuredOutput;
947
964
  if (plan !== void 0) result.plan = plan;
948
965
  return result;
949
966
  }
@@ -1662,6 +1679,14 @@ function normalizeOutputSchema(value) {
1662
1679
  }
1663
1680
  out.name = value.name;
1664
1681
  }
1682
+ if (value.enforcement !== void 0) {
1683
+ if (value.enforcement !== "best_effort" && value.enforcement !== "strict") {
1684
+ throw new MantyxError(
1685
+ `outputSchema.enforcement must be "best_effort" or "strict", got ${JSON.stringify(value.enforcement)}`
1686
+ );
1687
+ }
1688
+ out.enforcement = value.enforcement;
1689
+ }
1665
1690
  const schema = toToolParametersWire(
1666
1691
  value.schema
1667
1692
  );
@@ -1972,6 +1997,20 @@ function parseRunTurns(value) {
1972
1997
  if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
1973
1998
  return Math.max(0, Math.trunc(value));
1974
1999
  }
2000
+ function parseStructuredOutputInfo(value) {
2001
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
2002
+ const v = value;
2003
+ const mechanism = v.enforcementMechanism;
2004
+ if (typeof v.schemaRequested !== "boolean" || typeof v.schemaEnforced !== "boolean" || mechanism !== "native_schema" && mechanism !== "synthetic_tool" && mechanism !== "none" || typeof v.unconstrainedFallbackOccurred !== "boolean") {
2005
+ return void 0;
2006
+ }
2007
+ return {
2008
+ schemaRequested: v.schemaRequested,
2009
+ schemaEnforced: v.schemaEnforced,
2010
+ enforcementMechanism: mechanism,
2011
+ unconstrainedFallbackOccurred: v.unconstrainedFallbackOccurred
2012
+ };
2013
+ }
1975
2014
  function parseRunModel(value) {
1976
2015
  if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
1977
2016
  const v = value;
@@ -2055,4 +2094,4 @@ export {
2055
2094
  taskPlanFromEventData,
2056
2095
  parseRunOutput
2057
2096
  };
2058
- //# sourceMappingURL=chunk-OUK6ZZ5H.js.map
2097
+ //# sourceMappingURL=chunk-4EJRV6KZ.js.map