@mantyx/sdk 2026.9.3 → 2026.10.2

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 CHANGED
@@ -7,6 +7,9 @@ and new releases use calendar versions (`YYYY.M.RELEASE`). Historical versions r
7
7
 
8
8
  ### Added
9
9
 
10
+ - Configure a fallback model for ephemeral runs and sessions. MANTYX preserves
11
+ completed tool results during failover and keeps switched sessions on the fallback.
12
+
10
13
  - Cursor-based session pagination and bounded session event pages (SDK PR #9).
11
14
 
12
15
  ### Removed
@@ -15,6 +18,8 @@ and new releases use calendar versions (`YYYY.M.RELEASE`). Historical versions r
15
18
 
16
19
  ### Changed
17
20
 
21
+ - Upgrade the optional A2A peer to 1.3 (Node.js 20+ for A2A hosting). Agent cards and executor events now use A2A 1.0 types; legacy 0.3 JSON-RPC/REST requests remain supported. Replace the removed `MessageSendParams` type with `SendMessageRequest`.
22
+
18
23
  - Calendar versioning with automatic SDK publication after successful deployments when SDK code or build inputs change.
19
24
  - Develop and release SDKs from the private MANTYX platform repository.
20
25
  - Export `SessionEventsPage`; wait for eval local tool callbacks; reject null output schemas.
package/README.md CHANGED
@@ -180,6 +180,7 @@ agents can then discover it at `/.well-known/agent-card.json` and call
180
180
  estate consuming this one via `mantyxA2A` or `defineLocalA2A`.
181
181
 
182
182
  ```ts
183
+ import { AgentCard } from "@a2a-js/sdk";
183
184
  import { MantyxClient } from "@mantyx/sdk";
184
185
  import { serveAgentOverA2A } from "@mantyx/sdk/a2a-server";
185
186
 
@@ -189,23 +190,24 @@ const handle = await serveAgentOverA2A({
189
190
  client,
190
191
  agent: { agentId: "agent_cm6abc123" }, // or { systemPrompt, modelId, tools }
191
192
  port: 4000,
192
- agentCard: {
193
+ agentCard: AgentCard.fromJSON({
193
194
  name: "Acme Support",
194
195
  description: "Customer support questions.",
195
- protocolVersion: "0.3.0",
196
196
  version: "1.0.0",
197
- url: "http://localhost:4000",
197
+ supportedInterfaces: [{ url: "http://localhost:4000", protocolBinding: "JSONRPC", protocolVersion: "1.0" }],
198
198
  skills: [{ id: "support", name: "Support", tags: ["support"] }],
199
199
  capabilities: { streaming: true, pushNotifications: false },
200
200
  defaultInputModes: ["text"],
201
201
  defaultOutputModes: ["text"],
202
- },
202
+ }),
203
203
  });
204
204
 
205
205
  console.log(`A2A peer up on ${handle.url}`);
206
206
  // later: await handle.close();
207
207
  ```
208
208
 
209
+ A2A hosting requires Node.js 20+ and `@a2a-js/sdk` 1.3+. Agent cards use the A2A 1.0 shape; the server also accepts legacy 0.3 requests.
210
+
209
211
  `@a2a-js/sdk` and `express` are declared as **optional peer dependencies**,
210
212
  so apps that don't expose an A2A server pay zero bundle cost. Install them
211
213
  on demand:
@@ -34,6 +34,9 @@ __export(a2a_server_exports, {
34
34
  serveAgentOverA2A: () => serveAgentOverA2A
35
35
  });
36
36
  module.exports = __toCommonJS(a2a_server_exports);
37
+ var import_sdk = require("@a2a-js/sdk");
38
+ var import_v0_3 = require("@a2a-js/sdk/compat/v0_3");
39
+ var import_server = require("@a2a-js/sdk/server");
37
40
 
38
41
  // src/errors.ts
39
42
  var MantyxError = class extends Error {
@@ -126,17 +129,16 @@ var MantyxAgentExecutor = class {
126
129
  this.inFlight.set(taskId, abort);
127
130
  try {
128
131
  if (!task) {
129
- eventBus.publish({
130
- kind: "task",
132
+ eventBus.publish(import_server.AgentEvent.task(import_sdk.Task.fromJSON({
131
133
  id: taskId,
132
134
  contextId,
133
- status: { state: "submitted", timestamp: (/* @__PURE__ */ new Date()).toISOString() },
134
- history: [userMessage]
135
- });
135
+ status: { state: import_sdk.TaskState.TASK_STATE_SUBMITTED, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
136
+ history: [import_sdk.Message.toJSON(userMessage)]
137
+ })));
136
138
  }
137
- eventBus.publish(statusUpdate(taskId, contextId, "working", false));
139
+ eventBus.publish(import_server.AgentEvent.statusUpdate(statusUpdate(taskId, contextId, import_sdk.TaskState.TASK_STATE_WORKING)));
138
140
  if (this.cancelled.has(taskId)) {
139
- eventBus.publish(statusUpdate(taskId, contextId, "canceled", true));
141
+ eventBus.publish(import_server.AgentEvent.statusUpdate(statusUpdate(taskId, contextId, import_sdk.TaskState.TASK_STATE_CANCELED)));
140
142
  eventBus.finished();
141
143
  return;
142
144
  }
@@ -145,24 +147,24 @@ var MantyxAgentExecutor = class {
145
147
  this.onAssistantDelta(delta, requestContext, eventBus);
146
148
  return;
147
149
  }
148
- eventBus.publish(deltaStatusUpdate(taskId, contextId, delta));
150
+ eventBus.publish(import_server.AgentEvent.statusUpdate(deltaStatusUpdate(taskId, contextId, delta)));
149
151
  };
150
152
  let result;
151
153
  try {
152
154
  result = await this.runOnce(contextId, userText, onDelta, abort.signal);
153
155
  } catch (err) {
154
156
  eventBus.publish(
155
- completedStatusUpdate(
157
+ import_server.AgentEvent.statusUpdate(completedStatusUpdate(
156
158
  taskId,
157
159
  contextId,
158
- this.cancelled.has(taskId) ? "canceled" : "failed",
160
+ this.cancelled.has(taskId) ? import_sdk.TaskState.TASK_STATE_CANCELED : import_sdk.TaskState.TASK_STATE_FAILED,
159
161
  errorText(err)
160
- )
162
+ ))
161
163
  );
162
164
  eventBus.finished();
163
165
  return;
164
166
  }
165
- eventBus.publish(completedStatusUpdate(taskId, contextId, "completed", result.text ?? ""));
167
+ eventBus.publish(import_server.AgentEvent.statusUpdate(completedStatusUpdate(taskId, contextId, import_sdk.TaskState.TASK_STATE_COMPLETED, result.text ?? "")));
166
168
  eventBus.finished();
167
169
  } finally {
168
170
  this.inFlight.delete(taskId);
@@ -228,8 +230,10 @@ async function serveAgentOverA2A(options) {
228
230
  const a2a = await loadServerSdk();
229
231
  const expressMod = await loadExpress();
230
232
  const executor = new MantyxAgentExecutor(options);
233
+ const card = { ...options.agentCard };
234
+ card.supportedInterfaces = (0, import_v0_3.duplicateInterfacesForLegacy)(card.supportedInterfaces, ["JSONRPC", "HTTP+JSON"]);
231
235
  const requestHandler = new a2a.DefaultRequestHandler(
232
- options.agentCard,
236
+ card,
233
237
  new a2a.InMemoryTaskStore(),
234
238
  executor
235
239
  );
@@ -247,6 +251,7 @@ async function serveAgentOverA2A(options) {
247
251
  restPath,
248
252
  a2a.expressApp.restHandler({
249
253
  requestHandler,
254
+ legacyCompat: { enabled: true },
250
255
  userBuilder: a2a.expressApp.UserBuilder.noAuthentication
251
256
  })
252
257
  );
@@ -255,6 +260,7 @@ async function serveAgentOverA2A(options) {
255
260
  jsonRpcPath,
256
261
  a2a.expressApp.jsonRpcHandler({
257
262
  requestHandler,
263
+ legacyCompat: { enabled: true },
258
264
  userBuilder: a2a.expressApp.UserBuilder.noAuthentication
259
265
  })
260
266
  );
@@ -281,66 +287,35 @@ async function serveAgentOverA2A(options) {
281
287
  }
282
288
  };
283
289
  }
284
- function statusUpdate(taskId, contextId, state, final) {
285
- return {
286
- kind: "status-update",
287
- taskId,
288
- contextId,
289
- status: { state, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
290
- final
291
- };
292
- }
293
- function deltaStatusUpdate(taskId, contextId, delta) {
294
- return {
295
- kind: "status-update",
290
+ function statusUpdate(taskId, contextId, state, text) {
291
+ return import_sdk.TaskStatusUpdateEvent.fromJSON({
296
292
  taskId,
297
293
  contextId,
298
294
  status: {
299
- state: "working",
295
+ state,
300
296
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
301
- message: {
302
- kind: "message",
303
- messageId: randomMessageId(),
304
- role: "agent",
305
- parts: [{ kind: "text", text: delta }],
306
- contextId,
307
- taskId
297
+ ...text === void 0 ? {} : {
298
+ message: {
299
+ messageId: randomMessageId(),
300
+ role: import_sdk.Role.ROLE_AGENT,
301
+ parts: [{ text, mediaType: "text/plain" }],
302
+ contextId,
303
+ taskId
304
+ }
308
305
  }
309
- },
310
- final: false
311
- };
306
+ }
307
+ });
308
+ }
309
+ function deltaStatusUpdate(taskId, contextId, delta) {
310
+ return statusUpdate(taskId, contextId, import_sdk.TaskState.TASK_STATE_WORKING, delta);
312
311
  }
313
312
  function completedStatusUpdate(taskId, contextId, state, text) {
314
- return {
315
- kind: "status-update",
316
- taskId,
317
- contextId,
318
- status: {
319
- state,
320
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
321
- message: {
322
- kind: "message",
323
- messageId: randomMessageId(),
324
- role: "agent",
325
- parts: [{ kind: "text", text }],
326
- contextId,
327
- taskId
328
- }
329
- },
330
- final: true
331
- };
313
+ return statusUpdate(taskId, contextId, state, text);
332
314
  }
333
315
  function extractText(message) {
334
- if (!message) return "";
335
- const parts = message.parts ?? [];
336
- const out = [];
337
- for (const p of parts) {
338
- if (p.kind === "text") {
339
- const t = p.text;
340
- if (typeof t === "string") out.push(t);
341
- }
342
- }
343
- return out.join("\n");
316
+ return (message?.parts ?? []).flatMap(
317
+ (part) => part.content?.$case === "text" ? [part.content.value] : []
318
+ ).join("\n");
344
319
  }
345
320
  function specForRun(spec) {
346
321
  const out = {};
@@ -422,7 +397,7 @@ async function loadServerSdk() {
422
397
  express = await import("@a2a-js/sdk/server/express");
423
398
  } catch (err) {
424
399
  throw new MantyxError(
425
- "serveAgentOverA2A: `@a2a-js/sdk/server/express` could not be loaded; ensure the installed `@a2a-js/sdk` is at least v0.3."
400
+ "serveAgentOverA2A: `@a2a-js/sdk/server/express` could not be loaded; ensure the installed `@a2a-js/sdk` is at least v1.3."
426
401
  );
427
402
  }
428
403
  return {
@@ -9,6 +9,7 @@
9
9
  * npm install @a2a-js/sdk express
10
10
  *
11
11
  * @example
12
+ * import { AgentCard } from "@a2a-js/sdk";
12
13
  * import { MantyxClient } from "@mantyx/sdk";
13
14
  * import { serveAgentOverA2A } from "@mantyx/sdk/a2a-server";
14
15
  *
@@ -21,24 +22,23 @@
21
22
  * client,
22
23
  * port: 4000,
23
24
  * agent: { agentId: "agent_cm6abc123" },
24
- * agentCard: {
25
+ * agentCard: AgentCard.fromJSON({
25
26
  * name: "Acme Support",
26
27
  * description: "Answers billing and account questions.",
27
- * protocolVersion: "0.3.0",
28
28
  * version: "1.0.0",
29
- * url: "http://localhost:4000",
29
+ * supportedInterfaces: [{ url: "http://localhost:4000", protocolBinding: "JSONRPC", protocolVersion: "1.0" }],
30
30
  * skills: [{ id: "support", name: "Support", description: "Customer support",
31
31
  * tags: ["support"] }],
32
32
  * capabilities: { streaming: true, pushNotifications: false },
33
33
  * defaultInputModes: ["text"],
34
34
  * defaultOutputModes: ["text"],
35
- * },
35
+ * }),
36
36
  * });
37
37
  *
38
38
  * console.log(`Listening on ${server.url}`);
39
39
  */
40
- import type { AgentCard } from "@a2a-js/sdk";
41
- import type { AgentExecutor, ExecutionEventBus, RequestContext } from "@a2a-js/sdk/server";
40
+ import { AgentCard } from "@a2a-js/sdk";
41
+ import { type AgentExecutor, type ExecutionEventBus, type RequestContext } from "@a2a-js/sdk/server";
42
42
  import { type MantyxClient, type OutputSchema } from "./client.js";
43
43
  import type { ReasoningLevel, ToolRef } from "./tools.js";
44
44
  /**
@@ -96,7 +96,7 @@ export interface MantyxAgentExecutorOptions {
96
96
  maxSessions?: number;
97
97
  /**
98
98
  * Receives streaming MANTYX `assistant_delta` text. The default behaviour
99
- * forwards every delta as a `TaskStatusUpdateEvent` (state: "working")
99
+ * forwards every delta as a `TaskStatusUpdateEvent` (state: "TASK_STATE_WORKING")
100
100
  * containing the delta as a `text` part — this is what enables A2A
101
101
  * `message/stream` clients to see real-time tokens. Override only if you
102
102
  * need to swallow them or transform the wire shape.
@@ -168,5 +168,5 @@ export declare class MantyxAgentExecutor implements AgentExecutor {
168
168
  * deps with `npm install express @a2a-js/sdk`.
169
169
  */
170
170
  export declare function serveAgentOverA2A(options: ServeAgentOverA2AOptions): Promise<ServeAgentOverA2AHandle>;
171
- export type { AgentCard, Message, MessageSendParams, Task, TaskArtifactUpdateEvent, TaskStatusUpdateEvent, } from "@a2a-js/sdk";
171
+ export type { AgentCard, Message, SendMessageRequest, Task, TaskArtifactUpdateEvent, TaskStatusUpdateEvent, } from "@a2a-js/sdk";
172
172
  export type { AgentExecutor, ExecutionEventBus, RequestContext } from "@a2a-js/sdk/server";
@@ -1,9 +1,20 @@
1
1
  import {
2
2
  MantyxError,
3
3
  MantyxRunError
4
- } from "./chunk-G46SVM2Q.js";
4
+ } from "./chunk-ZGBSE23M.js";
5
5
 
6
6
  // src/a2a-server.ts
7
+ import {
8
+ Message,
9
+ Role,
10
+ TaskState,
11
+ Task,
12
+ TaskStatusUpdateEvent
13
+ } from "@a2a-js/sdk";
14
+ import { duplicateInterfacesForLegacy } from "@a2a-js/sdk/compat/v0_3";
15
+ import {
16
+ AgentEvent
17
+ } from "@a2a-js/sdk/server";
7
18
  var MantyxAgentExecutor = class {
8
19
  client;
9
20
  agent;
@@ -34,17 +45,16 @@ var MantyxAgentExecutor = class {
34
45
  this.inFlight.set(taskId, abort);
35
46
  try {
36
47
  if (!task) {
37
- eventBus.publish({
38
- kind: "task",
48
+ eventBus.publish(AgentEvent.task(Task.fromJSON({
39
49
  id: taskId,
40
50
  contextId,
41
- status: { state: "submitted", timestamp: (/* @__PURE__ */ new Date()).toISOString() },
42
- history: [userMessage]
43
- });
51
+ status: { state: TaskState.TASK_STATE_SUBMITTED, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
52
+ history: [Message.toJSON(userMessage)]
53
+ })));
44
54
  }
45
- eventBus.publish(statusUpdate(taskId, contextId, "working", false));
55
+ eventBus.publish(AgentEvent.statusUpdate(statusUpdate(taskId, contextId, TaskState.TASK_STATE_WORKING)));
46
56
  if (this.cancelled.has(taskId)) {
47
- eventBus.publish(statusUpdate(taskId, contextId, "canceled", true));
57
+ eventBus.publish(AgentEvent.statusUpdate(statusUpdate(taskId, contextId, TaskState.TASK_STATE_CANCELED)));
48
58
  eventBus.finished();
49
59
  return;
50
60
  }
@@ -53,24 +63,24 @@ var MantyxAgentExecutor = class {
53
63
  this.onAssistantDelta(delta, requestContext, eventBus);
54
64
  return;
55
65
  }
56
- eventBus.publish(deltaStatusUpdate(taskId, contextId, delta));
66
+ eventBus.publish(AgentEvent.statusUpdate(deltaStatusUpdate(taskId, contextId, delta)));
57
67
  };
58
68
  let result;
59
69
  try {
60
70
  result = await this.runOnce(contextId, userText, onDelta, abort.signal);
61
71
  } catch (err) {
62
72
  eventBus.publish(
63
- completedStatusUpdate(
73
+ AgentEvent.statusUpdate(completedStatusUpdate(
64
74
  taskId,
65
75
  contextId,
66
- this.cancelled.has(taskId) ? "canceled" : "failed",
76
+ this.cancelled.has(taskId) ? TaskState.TASK_STATE_CANCELED : TaskState.TASK_STATE_FAILED,
67
77
  errorText(err)
68
- )
78
+ ))
69
79
  );
70
80
  eventBus.finished();
71
81
  return;
72
82
  }
73
- eventBus.publish(completedStatusUpdate(taskId, contextId, "completed", result.text ?? ""));
83
+ eventBus.publish(AgentEvent.statusUpdate(completedStatusUpdate(taskId, contextId, TaskState.TASK_STATE_COMPLETED, result.text ?? "")));
74
84
  eventBus.finished();
75
85
  } finally {
76
86
  this.inFlight.delete(taskId);
@@ -136,8 +146,10 @@ async function serveAgentOverA2A(options) {
136
146
  const a2a = await loadServerSdk();
137
147
  const expressMod = await loadExpress();
138
148
  const executor = new MantyxAgentExecutor(options);
149
+ const card = { ...options.agentCard };
150
+ card.supportedInterfaces = duplicateInterfacesForLegacy(card.supportedInterfaces, ["JSONRPC", "HTTP+JSON"]);
139
151
  const requestHandler = new a2a.DefaultRequestHandler(
140
- options.agentCard,
152
+ card,
141
153
  new a2a.InMemoryTaskStore(),
142
154
  executor
143
155
  );
@@ -155,6 +167,7 @@ async function serveAgentOverA2A(options) {
155
167
  restPath,
156
168
  a2a.expressApp.restHandler({
157
169
  requestHandler,
170
+ legacyCompat: { enabled: true },
158
171
  userBuilder: a2a.expressApp.UserBuilder.noAuthentication
159
172
  })
160
173
  );
@@ -163,6 +176,7 @@ async function serveAgentOverA2A(options) {
163
176
  jsonRpcPath,
164
177
  a2a.expressApp.jsonRpcHandler({
165
178
  requestHandler,
179
+ legacyCompat: { enabled: true },
166
180
  userBuilder: a2a.expressApp.UserBuilder.noAuthentication
167
181
  })
168
182
  );
@@ -189,66 +203,35 @@ async function serveAgentOverA2A(options) {
189
203
  }
190
204
  };
191
205
  }
192
- function statusUpdate(taskId, contextId, state, final) {
193
- return {
194
- kind: "status-update",
195
- taskId,
196
- contextId,
197
- status: { state, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
198
- final
199
- };
200
- }
201
- function deltaStatusUpdate(taskId, contextId, delta) {
202
- return {
203
- kind: "status-update",
206
+ function statusUpdate(taskId, contextId, state, text) {
207
+ return TaskStatusUpdateEvent.fromJSON({
204
208
  taskId,
205
209
  contextId,
206
210
  status: {
207
- state: "working",
211
+ state,
208
212
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
209
- message: {
210
- kind: "message",
211
- messageId: randomMessageId(),
212
- role: "agent",
213
- parts: [{ kind: "text", text: delta }],
214
- contextId,
215
- taskId
213
+ ...text === void 0 ? {} : {
214
+ message: {
215
+ messageId: randomMessageId(),
216
+ role: Role.ROLE_AGENT,
217
+ parts: [{ text, mediaType: "text/plain" }],
218
+ contextId,
219
+ taskId
220
+ }
216
221
  }
217
- },
218
- final: false
219
- };
222
+ }
223
+ });
224
+ }
225
+ function deltaStatusUpdate(taskId, contextId, delta) {
226
+ return statusUpdate(taskId, contextId, TaskState.TASK_STATE_WORKING, delta);
220
227
  }
221
228
  function completedStatusUpdate(taskId, contextId, state, text) {
222
- return {
223
- kind: "status-update",
224
- taskId,
225
- contextId,
226
- status: {
227
- state,
228
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
229
- message: {
230
- kind: "message",
231
- messageId: randomMessageId(),
232
- role: "agent",
233
- parts: [{ kind: "text", text }],
234
- contextId,
235
- taskId
236
- }
237
- },
238
- final: true
239
- };
229
+ return statusUpdate(taskId, contextId, state, text);
240
230
  }
241
231
  function extractText(message) {
242
- if (!message) return "";
243
- const parts = message.parts ?? [];
244
- const out = [];
245
- for (const p of parts) {
246
- if (p.kind === "text") {
247
- const t = p.text;
248
- if (typeof t === "string") out.push(t);
249
- }
250
- }
251
- return out.join("\n");
232
+ return (message?.parts ?? []).flatMap(
233
+ (part) => part.content?.$case === "text" ? [part.content.value] : []
234
+ ).join("\n");
252
235
  }
253
236
  function specForRun(spec) {
254
237
  const out = {};
@@ -330,7 +313,7 @@ async function loadServerSdk() {
330
313
  express = await import("@a2a-js/sdk/server/express");
331
314
  } catch (err) {
332
315
  throw new MantyxError(
333
- "serveAgentOverA2A: `@a2a-js/sdk/server/express` could not be loaded; ensure the installed `@a2a-js/sdk` is at least v0.3."
316
+ "serveAgentOverA2A: `@a2a-js/sdk/server/express` could not be loaded; ensure the installed `@a2a-js/sdk` is at least v1.3."
334
317
  );
335
318
  }
336
319
  return {
@@ -1512,6 +1512,7 @@ function serializeAgentSpec(spec, extra = {}) {
1512
1512
  if (spec.agentId) body.agentId = spec.agentId;
1513
1513
  if (spec.name) body.name = spec.name;
1514
1514
  if (spec.modelId) body.modelId = spec.modelId;
1515
+ if (spec.fallbackModelId) body.fallbackModelId = spec.fallbackModelId;
1515
1516
  if (spec.reasoningLevel !== void 0) {
1516
1517
  body.reasoningLevel = normalizeReasoningLevel(spec.reasoningLevel);
1517
1518
  }
package/dist/client.d.ts CHANGED
@@ -341,6 +341,8 @@ export interface AgentSpecBase {
341
341
  /** Required unless `agentId` is set. */
342
342
  systemPrompt?: string;
343
343
  modelId?: string;
344
+ /** Alternate model for provider outages; remains active for the session after switching. */
345
+ fallbackModelId?: string;
344
346
  tools?: ToolRef[];
345
347
  /**
346
348
  * Provider thinking strength: a string anchor (`"off" | "low" | "medium" |
@@ -750,6 +752,8 @@ export interface ThinkingDeltaEvent extends RunEventBase {
750
752
  }
751
753
  export interface AssistantMessageEvent extends RunEventBase {
752
754
  type: "assistant_message";
755
+ /** Actual model that produced this invocation. */
756
+ model?: RunModelInfo;
753
757
  /**
754
758
  * Full assistant text for this turn (concatenation of every preceding
755
759
  * `assistant_delta` for the turn, plus any non-streaming snapshot the
@@ -1021,7 +1025,14 @@ export interface UserMessageEvent extends RunEventBase {
1021
1025
  /** Present on session-event replay when the user turn carried file inputs. */
1022
1026
  attachments?: AttachmentMetadata[];
1023
1027
  }
1024
- export type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | TaskPlanEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1028
+ export interface ModelFallbackEvent extends RunEventBase {
1029
+ type: "model_fallback";
1030
+ errorClass: string;
1031
+ model: RunModelInfo;
1032
+ primaryModelId?: string | null;
1033
+ fallbackModelId: string;
1034
+ }
1035
+ export type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | ModelFallbackEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | TaskPlanEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1025
1036
  type: string;
1026
1037
  [key: string]: unknown;
1027
1038
  });
@@ -1032,7 +1043,9 @@ export interface SessionInfo {
1032
1043
  createdAt: string;
1033
1044
  lastUsedAt: string;
1034
1045
  endedAt: string | null;
1035
- agentSpec: AgentSpecBase;
1046
+ agentSpec: AgentSpecBase & {
1047
+ activeModelId?: string;
1048
+ };
1036
1049
  messages: ConversationMessage[];
1037
1050
  /** Metadata that was attached to the session at create time, returned for observability. */
1038
1051
  metadata: Record<string, string>;
package/dist/index.cjs CHANGED
@@ -1586,6 +1586,7 @@ function serializeAgentSpec(spec, extra = {}) {
1586
1586
  if (spec.agentId) body.agentId = spec.agentId;
1587
1587
  if (spec.name) body.name = spec.name;
1588
1588
  if (spec.modelId) body.modelId = spec.modelId;
1589
+ if (spec.fallbackModelId) body.fallbackModelId = spec.fallbackModelId;
1589
1590
  if (spec.reasoningLevel !== void 0) {
1590
1591
  body.reasoningLevel = normalizeReasoningLevel(spec.reasoningLevel);
1591
1592
  }
@@ -2744,7 +2745,7 @@ async function runComputerUse(opts) {
2744
2745
  }
2745
2746
 
2746
2747
  // src/version.ts
2747
- var SDK_VERSION = "2026.9.3";
2748
+ var SDK_VERSION = "2026.10.2";
2748
2749
  // Annotate the CommonJS export names for ESM import in node:
2749
2750
  0 && (module.exports = {
2750
2751
  AgentSession,
package/dist/index.d.ts CHANGED
@@ -34,7 +34,7 @@
34
34
  * console.log(result.text);
35
35
  */
36
36
  export { MantyxClient, AgentSession, DEFAULT_BASE_URL, parseRunOutput, planOnly, taskPlanFromEventData, inputFileAttachment, inputFileUrlAttachment, } from "./client.js";
37
- export type { MantyxClientOptions, ModelInfo, ModelCatalog, AgentSpecBase, RunSpec, SessionSpec, OutputSchema, OutputSchemaValue, LoopDetection, ToolBudget, ToolBudgets, Supervisor, SupervisorAction, SupervisorPhase, ReasoningTrigger, PlanOptions, PlanMode, PlanSpec, TaskPlan, TaskPlanStep, TaskPlanStepStatus, TaskPlanTransition, RunResult, RunTokenUsage, RunModelInfo, RunEvent, RunEventBase, AssistantDeltaEvent, ThinkingDeltaEvent, AssistantMessageEvent, UserMessageEvent, InputFileAttachment, InputFileUrlAttachment, MessageAttachment, InputFileAttachmentMetadata, InputFileUrlAttachmentMetadata, AttachmentMetadata, ConversationMessage, ServerToolResultEvent, LocalToolCallEvent, LocalToolResultInEvent, LoopDetectedEvent, ToolBudgetExceededEvent, SupervisorEvent, TaskPlanEvent, ResultEvent, ErrorEvent, CancelledEvent, SessionInfo, SessionSummary, SessionListResult, SessionEventsPage, LocalHandlers, RunFeedbackVerdict, RunFeedbackInput, RunFeedbackResult, EvalRunStatus, InlineEvalCaseSpec, InlineEvalDatasetSpec, AgentEvalOverrides, CreateEvalRunRequest, EvalDatasetSummary, EvalDatasetList, EvalCase, EvalDatasetDetail, EvalRunAccepted, EvalRunSummary, EvalCaseResult, EvalRunDetail, EvalRunList, EvalRunCompareSide, EvalRunCompareCase, EvalRunCompare, EvalRunEvent, ListEvalRunsOptions, RunEvalOptions, } from "./client.js";
37
+ export type { MantyxClientOptions, ModelInfo, ModelCatalog, AgentSpecBase, RunSpec, SessionSpec, OutputSchema, OutputSchemaValue, LoopDetection, ToolBudget, ToolBudgets, Supervisor, SupervisorAction, SupervisorPhase, ReasoningTrigger, PlanOptions, PlanMode, PlanSpec, TaskPlan, TaskPlanStep, TaskPlanStepStatus, TaskPlanTransition, RunResult, RunTokenUsage, RunModelInfo, RunEvent, RunEventBase, AssistantDeltaEvent, ThinkingDeltaEvent, AssistantMessageEvent, ModelFallbackEvent, UserMessageEvent, InputFileAttachment, InputFileUrlAttachment, MessageAttachment, InputFileAttachmentMetadata, InputFileUrlAttachmentMetadata, AttachmentMetadata, ConversationMessage, ServerToolResultEvent, LocalToolCallEvent, LocalToolResultInEvent, LoopDetectedEvent, ToolBudgetExceededEvent, SupervisorEvent, TaskPlanEvent, ResultEvent, ErrorEvent, CancelledEvent, SessionInfo, SessionSummary, SessionListResult, SessionEventsPage, LocalHandlers, RunFeedbackVerdict, RunFeedbackInput, RunFeedbackResult, EvalRunStatus, InlineEvalCaseSpec, InlineEvalDatasetSpec, AgentEvalOverrides, CreateEvalRunRequest, EvalDatasetSummary, EvalDatasetList, EvalCase, EvalDatasetDetail, EvalRunAccepted, EvalRunSummary, EvalCaseResult, EvalRunDetail, EvalRunList, EvalRunCompareSide, EvalRunCompareCase, EvalRunCompare, EvalRunEvent, ListEvalRunsOptions, RunEvalOptions, } from "./client.js";
38
38
  export { defineLocalTool, mantyxTool, mantyxPluginTool, mantyxA2A, defineLocalA2A, mantyxMcp, defineLocalMcp, isLocalTool, isLocalA2ATool, isLocalMcpServer, } from "./tools.js";
39
39
  export type { LocalTool, LocalToolResult, LocalToolOutput, ToolResultFile, MantyxToolRef, MantyxPluginToolRef, ToolRef, ZodLikeObject, DefineLocalToolOptions, ReasoningLevel, A2AToolRef, LocalA2ATool, McpToolRef, LocalMcpServer, LocalMcpHttpTransport, LocalMcpStdioTransport, MantyxA2AOptions, DefineLocalA2AOptions, MantyxMcpOptions, DefineLocalMcpOptions, } from "./tools.js";
40
40
  export { MantyxError, MantyxAuthError, MantyxNetworkError, MantyxParseError, MantyxScopeError, MantyxToolError, MantyxRunError, } from "./errors.js";
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  taskPlanFromEventData,
28
28
  toToolParametersWire,
29
29
  zodToJsonSchema
30
- } from "./chunk-G46SVM2Q.js";
30
+ } from "./chunk-ZGBSE23M.js";
31
31
 
32
32
  // src/oauth.ts
33
33
  var DEFAULT_OAUTH_BASE_URL = "https://app.mantyx.io";
@@ -603,7 +603,7 @@ async function runComputerUse(opts) {
603
603
  }
604
604
 
605
605
  // src/version.ts
606
- var SDK_VERSION = "2026.9.3";
606
+ var SDK_VERSION = "2026.10.2";
607
607
  export {
608
608
  AgentSession,
609
609
  COMPUTER_USE_ACTIONS,
package/dist/version.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Release version — synced from sdk/VERSION (`pnpm run sync-version`).
3
3
  */
4
- export declare const SDK_VERSION = "2026.9.3";
4
+ export declare const SDK_VERSION = "2026.10.2";
@@ -462,6 +462,35 @@ not re-sent to the model (text only); only the current turn's files reach the
462
462
  LLM. Whether the model can interpret an accepted file depends on the selected
463
463
  model and provider.
464
464
 
465
+ ### 4.0.2 `fallbackModelId` (provider availability failover)
466
+
467
+ Set optional `fallbackModelId` on a run or session spec using the same model
468
+ selector grammar as `modelId`. TypeScript uses `fallbackModelId`, Python uses
469
+ `fallback_model_id`, and Go uses `FallbackModelID`. The fallback must resolve
470
+ to a different provider/model pair from the primary.
471
+
472
+ During agent execution (including approval and shutdown resumes), after normal
473
+ retries are exhausted, MANTYX switches the failed model invocation
474
+ for retryable overload, provider server, unreachable-provider, or upstream
475
+ timeout errors. It does not switch for authentication, invalid requests, quota
476
+ errors, cancellation, or after answer text has streamed from that invocation.
477
+ The fallback gets its own retry budget; there is no bounce back to the primary.
478
+
479
+ The same run and session continue with the system prompt, conversation, tools,
480
+ and completed tool results. Tools already executed are not replayed. Opaque
481
+ provider reasoning is removed and portable context compaction uses the fallback
482
+ model's context window. Native opaque compaction is disabled while failover is
483
+ configured.
484
+
485
+ A switched session stays on the fallback for later messages. New sessions start
486
+ with the primary. The original `agentSpec.modelId` and `fallbackModelId` remain
487
+ visible; server-owned `agentSpec.activeModelId` identifies the active selection.
488
+ Clients cannot set `activeModelId`. Terminal `model` identifies the actual model;
489
+ `assistant_message.model` identifies each completed model invocation. The
490
+ non-terminal `model_fallback` SSE event carries `{ errorClass, model,
491
+ primaryModelId, fallbackModelId }`. Session details expose each call's actual
492
+ `model`, including failed calls that switched.
493
+
465
494
  ### 4.1 Triggering a persisted MANTYX agent (`agentId`)
466
495
 
467
496
  Set `agentId` to the `id` of a workspace `Agent` to run that agent instead of
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantyx/sdk",
3
- "version": "2026.9.3",
3
+ "version": "2026.10.2",
4
4
  "description": "MANTYX as a hosted agent runtime: define ephemeral agents, mix server-side MANTYX tools with locally-executed tools, run them remotely.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -34,11 +34,11 @@
34
34
  "node": ">=18.17.0"
35
35
  },
36
36
  "dependencies": {
37
- "@modelcontextprotocol/sdk": "^1.30.0",
38
- "zod": "^4.6.5"
37
+ "@modelcontextprotocol/sdk": "^1.32.1",
38
+ "zod": "^4.6.7"
39
39
  },
40
40
  "peerDependencies": {
41
- "@a2a-js/sdk": "^0.3.0",
41
+ "@a2a-js/sdk": "^1.3.0",
42
42
  "express": "^4.0.0 || ^5.0.0",
43
43
  "playwright": "^1.40.0"
44
44
  },
@@ -54,14 +54,14 @@
54
54
  }
55
55
  },
56
56
  "devDependencies": {
57
- "@a2a-js/sdk": "^0.3.14",
57
+ "@a2a-js/sdk": "^1.3.0",
58
58
  "@types/express": "^5.0.6",
59
- "@types/node": "^26.6.1",
60
- "express": "^5.2.1",
61
- "playwright": "^1.61.1",
62
- "tsup": "^8.5.1",
59
+ "@types/node": "^26.6.5",
60
+ "express": "^5.3.0",
61
+ "playwright": "^1.64.1",
62
+ "tsup": "^9.0.0",
63
63
  "typescript": "~7.0.2",
64
- "vitest": "^4.1.11"
64
+ "vitest": "^5.0.5"
65
65
  },
66
66
  "keywords": [
67
67
  "mantyx",