@mantyx/sdk 0.22.1 → 0.24.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-STB4Z6F4.js";
4
+ } from "./chunk-OUK6ZZ5H.js";
5
5
 
6
6
  // src/a2a-server.ts
7
7
  var MantyxAgentExecutor = class {
@@ -968,7 +968,8 @@ var MantyxClient = class {
968
968
  const evType = sseEvent.event ?? data.type ?? "message";
969
969
  const seq = typeof data.seq === "number" ? data.seq : lastSeq;
970
970
  if (typeof seq === "number" && seq > lastSeq) lastSeq = seq;
971
- const ev = { seq, type: evType, ...data };
971
+ const payload = runEventPayload(data);
972
+ const ev = { seq, type: evType, ...payload };
972
973
  yield ev;
973
974
  if (evType === "local_tool_call") {
974
975
  const localEv = ev;
@@ -1774,14 +1775,41 @@ function normalizeSupervisor(value) {
1774
1775
  }
1775
1776
  return out;
1776
1777
  }
1778
+ var PLAN_MODES = /* @__PURE__ */ new Set(["off", "auto", "required"]);
1779
+ var TASK_PLAN_STEP_STATUSES = /* @__PURE__ */ new Set([
1780
+ "pending",
1781
+ "in_progress",
1782
+ "done",
1783
+ "blocked",
1784
+ "skipped"
1785
+ ]);
1786
+ function assertPlanMode(field, value) {
1787
+ if (typeof value !== "string" || !PLAN_MODES.has(value)) {
1788
+ throw new MantyxError(
1789
+ `${field} must be "off", "auto", or "required", got ${JSON.stringify(value)}`
1790
+ );
1791
+ }
1792
+ return value;
1793
+ }
1794
+ function runEventPayload(data) {
1795
+ const nested = data.data;
1796
+ if (nested && typeof nested === "object" && !Array.isArray(nested)) {
1797
+ return nested;
1798
+ }
1799
+ return data;
1800
+ }
1777
1801
  function normalizePlan(value) {
1778
1802
  if (value === true || value === false) return value;
1803
+ if (typeof value === "string") return assertPlanMode("plan", value);
1779
1804
  if (!value || typeof value !== "object" || Array.isArray(value)) {
1780
1805
  throw new MantyxError(
1781
- `plan must be \`true\`, \`false\`, or an object { planOnly?, brief?, steps? }, got ${JSON.stringify(value)}`
1806
+ `plan must be "off", "auto", "required", \`true\`, \`false\`, or an object { mode?, planOnly?, brief?, steps? }, got ${JSON.stringify(value)}`
1782
1807
  );
1783
1808
  }
1784
1809
  const out = {};
1810
+ if (value.mode !== void 0) {
1811
+ out.mode = assertPlanMode("plan.mode", value.mode);
1812
+ }
1785
1813
  if (value.planOnly !== void 0) {
1786
1814
  if (typeof value.planOnly !== "boolean") {
1787
1815
  throw new MantyxError(`plan.planOnly must be a boolean, got ${JSON.stringify(value.planOnly)}`);
@@ -1810,6 +1838,17 @@ function normalizePlan(value) {
1810
1838
  }
1811
1839
  return out;
1812
1840
  }
1841
+ function parseTaskPlanStep(entry) {
1842
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) return void 0;
1843
+ const row = entry;
1844
+ const title = row.title;
1845
+ const status = row.status;
1846
+ if (typeof title !== "string" || typeof status !== "string") return void 0;
1847
+ if (!TASK_PLAN_STEP_STATUSES.has(status)) return void 0;
1848
+ const step = { title, status };
1849
+ if (typeof row.id === "string" && row.id) step.id = row.id;
1850
+ return step;
1851
+ }
1813
1852
  function parseTaskPlan(raw) {
1814
1853
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
1815
1854
  const obj = raw;
@@ -1817,17 +1856,28 @@ function parseTaskPlan(raw) {
1817
1856
  if (!Array.isArray(stepsRaw)) return void 0;
1818
1857
  const steps = [];
1819
1858
  for (const entry of stepsRaw) {
1820
- if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
1821
- const row = entry;
1822
- const title = row.title;
1823
- const status = row.status;
1824
- if (typeof title !== "string" || typeof status !== "string") continue;
1825
- if (status !== "pending" && status !== "in_progress" && status !== "done") continue;
1826
- steps.push({ title, status });
1859
+ const step = parseTaskPlanStep(entry);
1860
+ if (step !== void 0) steps.push(step);
1861
+ }
1862
+ const out = { steps };
1863
+ if (typeof obj.v === "number") out.v = obj.v;
1864
+ if (typeof obj.planId === "string" && obj.planId) out.planId = obj.planId;
1865
+ if (typeof obj.revision === "number") out.revision = obj.revision;
1866
+ if (typeof obj.mode === "string" && PLAN_MODES.has(obj.mode)) {
1867
+ out.mode = obj.mode;
1827
1868
  }
1869
+ if (typeof obj.source === "string" && obj.source) out.source = obj.source;
1828
1870
  const briefRaw = obj.brief;
1829
- const brief = typeof briefRaw === "string" && briefRaw ? briefRaw : void 0;
1830
- return { steps, ...brief !== void 0 ? { brief } : {} };
1871
+ if (typeof briefRaw === "string" && briefRaw) out.brief = briefRaw;
1872
+ return out;
1873
+ }
1874
+ function taskPlanFromEventData(data) {
1875
+ const canonical = data.plan;
1876
+ if (canonical !== void 0) {
1877
+ const parsed = parseTaskPlan(canonical);
1878
+ if (parsed !== void 0) return parsed;
1879
+ }
1880
+ return parseTaskPlan(data);
1831
1881
  }
1832
1882
  function normalizeToolBudgets(value) {
1833
1883
  if (!value || typeof value !== "object" || Array.isArray(value)) {
@@ -2002,6 +2052,7 @@ export {
2002
2052
  planOnly,
2003
2053
  MantyxClient,
2004
2054
  AgentSession,
2055
+ taskPlanFromEventData,
2005
2056
  parseRunOutput
2006
2057
  };
2007
- //# sourceMappingURL=chunk-STB4Z6F4.js.map
2058
+ //# sourceMappingURL=chunk-OUK6ZZ5H.js.map