@mantyx/sdk 2026.11.11 → 2026.11.13
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 +16 -0
- package/README.md +76 -4
- package/dist/a2a-server.cjs +4 -0
- package/dist/a2a-server.d.ts +5 -1
- package/dist/a2a-server.js +5 -1
- package/dist/{chunk-KPAGE6FD.js → chunk-EXTS5Q3T.js} +304 -68
- package/dist/client.d.ts +286 -58
- package/dist/index.cjs +305 -70
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -4
- package/dist/tools.d.ts +46 -10
- package/dist/version.d.ts +1 -1
- package/docs/agent-runs-protocol.md +57 -29
- package/docs/wire-protocol.md +9 -48
- package/package.json +5 -5
package/dist/tools.d.ts
CHANGED
|
@@ -79,13 +79,42 @@ export interface LocalToolResult {
|
|
|
79
79
|
* values are JSON-serialized by the SDK before being posted back.
|
|
80
80
|
*/
|
|
81
81
|
export type LocalToolOutput = string | LocalToolResult;
|
|
82
|
+
/**
|
|
83
|
+
* Grouping and tool-search options every tool helper accepts
|
|
84
|
+
* ({@link defineLocalTool}, {@link mantyxA2A}, {@link defineLocalA2A},
|
|
85
|
+
* {@link mantyxMcp}, {@link defineLocalMcp}). Both are optional and omitted
|
|
86
|
+
* from the wire when unset.
|
|
87
|
+
*/
|
|
88
|
+
export interface ToolGroupingOptions {
|
|
89
|
+
/**
|
|
90
|
+
* Group the tool belongs to; must match `^[a-zA-Z0-9_]{1,64}$`. Direct
|
|
91
|
+
* OpenAI receives native `namespace` tools; other providers see
|
|
92
|
+
* `[namespace]` at the start of the tool description. Describe namespaces
|
|
93
|
+
* for the model with the agent's `toolNamespaces`. On MCP refs it
|
|
94
|
+
* applies to every tool the server exposes; with `toolSearch` on, MCP tools
|
|
95
|
+
* default to the server's name as namespace.
|
|
96
|
+
*/
|
|
97
|
+
namespace?: string;
|
|
98
|
+
/**
|
|
99
|
+
* With the agent's `toolSearch` on, keep this
|
|
100
|
+
* tool's definition in every request instead of deferring it behind the
|
|
101
|
+
* search. Mark the few tools the agent uses on most turns. On MCP refs it
|
|
102
|
+
* applies to every tool the server exposes. No effect without `toolSearch`.
|
|
103
|
+
*/
|
|
104
|
+
alwaysLoaded?: boolean;
|
|
105
|
+
}
|
|
106
|
+
/** The grouping fields as carried on a tool ref. See {@link ToolGroupingOptions}. */
|
|
107
|
+
export interface ToolGrouping {
|
|
108
|
+
readonly namespace?: string;
|
|
109
|
+
readonly alwaysLoaded?: boolean;
|
|
110
|
+
}
|
|
82
111
|
/**
|
|
83
112
|
* Either a Zod schema (auto-converted to JSON Schema by the SDK) or a
|
|
84
113
|
* pre-shaped JSON Schema object. Used for both `parameters` and the new
|
|
85
114
|
* `outputSchema` field — same conversion path either way.
|
|
86
115
|
*/
|
|
87
116
|
export type LocalToolSchemaInput = ZodLikeObject | Record<string, unknown>;
|
|
88
|
-
export interface LocalTool<TArgs = Record<string, unknown>> {
|
|
117
|
+
export interface LocalTool<TArgs = Record<string, unknown>> extends ToolGrouping {
|
|
89
118
|
readonly kind: "local";
|
|
90
119
|
readonly name: string;
|
|
91
120
|
readonly description: string;
|
|
@@ -129,7 +158,7 @@ export interface LocalTool<TArgs = Record<string, unknown>> {
|
|
|
129
158
|
readonly retain: boolean;
|
|
130
159
|
readonly execute: (args: TArgs) => Promise<LocalToolOutput> | LocalToolOutput;
|
|
131
160
|
}
|
|
132
|
-
export interface DefineLocalToolOptions<T extends ZodLikeObject | undefined> {
|
|
161
|
+
export interface DefineLocalToolOptions<T extends ZodLikeObject | undefined> extends ToolGroupingOptions {
|
|
133
162
|
/** Lowercase alphanumeric + underscore, max 64 chars. */
|
|
134
163
|
name: string;
|
|
135
164
|
description?: string;
|
|
@@ -165,7 +194,7 @@ export declare function defineLocalTool<T extends ZodLikeObject | undefined>(opt
|
|
|
165
194
|
* MANTYX dials `agentCardUrl` over A2A's `message/send` RPC and forwards the
|
|
166
195
|
* remote agent's reply as the tool result.
|
|
167
196
|
*/
|
|
168
|
-
export interface A2AToolRef {
|
|
197
|
+
export interface A2AToolRef extends ToolGrouping {
|
|
169
198
|
readonly kind: "a2a";
|
|
170
199
|
readonly name: string;
|
|
171
200
|
readonly description?: string;
|
|
@@ -173,7 +202,7 @@ export interface A2AToolRef {
|
|
|
173
202
|
readonly headers?: Record<string, string>;
|
|
174
203
|
readonly contextId?: string;
|
|
175
204
|
}
|
|
176
|
-
export interface MantyxA2AOptions {
|
|
205
|
+
export interface MantyxA2AOptions extends ToolGroupingOptions {
|
|
177
206
|
/** Tool name surfaced to the model; must match `^[a-zA-Z0-9_]{1,64}$`. */
|
|
178
207
|
name: string;
|
|
179
208
|
description?: string;
|
|
@@ -199,7 +228,7 @@ export declare function mantyxA2A(opts: MantyxA2AOptions): A2AToolRef;
|
|
|
199
228
|
* the tool ref for the rest of the process lifetime. Re-construct the ref
|
|
200
229
|
* to force a refetch.
|
|
201
230
|
*/
|
|
202
|
-
export interface LocalA2ATool {
|
|
231
|
+
export interface LocalA2ATool extends ToolGrouping {
|
|
203
232
|
readonly kind: "a2a_local";
|
|
204
233
|
readonly name: string;
|
|
205
234
|
/** Where the SDK fetches the Agent Card from. Cached after the first hit. */
|
|
@@ -225,7 +254,7 @@ export interface ResolvedAgentCard {
|
|
|
225
254
|
/** Anything else the peer publishes; forwarded verbatim onto the wire. */
|
|
226
255
|
readonly [k: string]: unknown;
|
|
227
256
|
}
|
|
228
|
-
export interface DefineLocalA2AOptions {
|
|
257
|
+
export interface DefineLocalA2AOptions extends ToolGroupingOptions {
|
|
229
258
|
/** Tool name surfaced to the model. Must match `^[a-zA-Z0-9_]{1,64}$`. */
|
|
230
259
|
name: string;
|
|
231
260
|
/**
|
|
@@ -246,14 +275,14 @@ export declare function defineLocalA2A(opts: DefineLocalA2AOptions): LocalA2AToo
|
|
|
246
275
|
* Reference to a remote MCP server (Streamable HTTP) discovered + proxied by
|
|
247
276
|
* MANTYX. Each tool in the catalog is exposed to the model as `<name>_<tool>`.
|
|
248
277
|
*/
|
|
249
|
-
export interface McpToolRef {
|
|
278
|
+
export interface McpToolRef extends ToolGrouping {
|
|
250
279
|
readonly kind: "mcp";
|
|
251
280
|
readonly name: string;
|
|
252
281
|
readonly url: string;
|
|
253
282
|
readonly headers?: Record<string, string>;
|
|
254
283
|
readonly toolFilter?: string[];
|
|
255
284
|
}
|
|
256
|
-
export interface MantyxMcpOptions {
|
|
285
|
+
export interface MantyxMcpOptions extends ToolGroupingOptions {
|
|
257
286
|
/** Server label; used to prefix every discovered tool. */
|
|
258
287
|
name: string;
|
|
259
288
|
/** Streamable HTTP MCP endpoint. */
|
|
@@ -301,7 +330,7 @@ export interface LocalMcpStdioTransport {
|
|
|
301
330
|
* Connections are reused across runs and across messages within a session
|
|
302
331
|
* and closed on `runAgent` completion / `session.end()`.
|
|
303
332
|
*/
|
|
304
|
-
export interface LocalMcpServer {
|
|
333
|
+
export interface LocalMcpServer extends ToolGrouping {
|
|
305
334
|
readonly kind: "mcp_local";
|
|
306
335
|
readonly name: string;
|
|
307
336
|
/** One-of with {@link stdio} — the transport spec is mutually exclusive. */
|
|
@@ -357,7 +386,7 @@ export interface McpClientLike {
|
|
|
357
386
|
[k: string]: unknown;
|
|
358
387
|
}>;
|
|
359
388
|
}
|
|
360
|
-
export interface DefineLocalMcpOptions {
|
|
389
|
+
export interface DefineLocalMcpOptions extends ToolGroupingOptions {
|
|
361
390
|
/**
|
|
362
391
|
* Server label echoed back as `mcpServer` on every `local_tool_call`. The
|
|
363
392
|
* SDK auto-prefixes each discovered tool's wire-level `name` with
|
|
@@ -390,6 +419,13 @@ export type ToolRef = LocalTool | A2AToolRef | LocalA2ATool | McpToolRef | Local
|
|
|
390
419
|
export declare function isLocalTool(t: ToolRef): t is LocalTool;
|
|
391
420
|
export declare function isLocalA2ATool(t: ToolRef): t is LocalA2ATool;
|
|
392
421
|
export declare function isLocalMcpServer(t: ToolRef): t is LocalMcpServer;
|
|
422
|
+
/** @internal Throws when `namespace` is not a valid namespace name. */
|
|
423
|
+
export declare function assertToolNamespace(namespace: string, label?: string): void;
|
|
424
|
+
/** @internal The grouping fields of a tool ref as the wire names them; unset ones are left out. */
|
|
425
|
+
export declare function toolGroupingWire(t: ToolGrouping): {
|
|
426
|
+
namespace?: string;
|
|
427
|
+
alwaysLoaded?: boolean;
|
|
428
|
+
};
|
|
393
429
|
/**
|
|
394
430
|
* Compose the wire-level (model-facing) tool name for a `mcp_local` entry.
|
|
395
431
|
* The SDK auto-prefixes every discovered tool's bare name with the server
|
package/dist/version.d.ts
CHANGED
|
@@ -812,6 +812,36 @@ Per-run lifecycle:
|
|
|
812
812
|
Older SDKs that ignore the `kind` discriminator still see a normal
|
|
813
813
|
`local_tool_call` and can match on `name` alone.
|
|
814
814
|
|
|
815
|
+
### 4.3.1 Tool namespaces and tool search
|
|
816
|
+
|
|
817
|
+
Every tool ref kind accepts two optional fields, and the agent spec two more:
|
|
818
|
+
|
|
819
|
+
| Field | Where | Notes |
|
|
820
|
+
| --------------------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
821
|
+
| `namespace` | any tool ref | Group the tool belongs to (match `/^[a-zA-Z0-9_]{1,64}$/`). On an MCP ref it applies to every tool of the server. Direct OpenAI receives native `namespace` tools; every other provider sees `[namespace]` at the start of the tool's description. With `toolSearch`, MCP tools without a namespace use the server's `name`. |
|
|
822
|
+
| `alwaysLoaded` | any tool ref | With `toolSearch`, keep this tool's full definition in every request instead of deferring it. Mark the few tools the agent uses on most turns. On an MCP ref it applies to every tool of the server. Ignored without `toolSearch`. |
|
|
823
|
+
| `toolSearch` | agent spec | Opt in to tool search (default off). Tools not marked `alwaysLoaded` are deferred and the model searches for the ones it needs. `spawn_subagent` is always loaded. |
|
|
824
|
+
| `toolNamespaces` | agent spec | `[{ name, description }]` (up to 64): what each namespace is for, shown to the model. A namespace without one is described by its tool names. |
|
|
825
|
+
|
|
826
|
+
Where tool search runs:
|
|
827
|
+
|
|
828
|
+
| Provider (as MANTYX calls it) | Tool search | Namespaces |
|
|
829
|
+
| --------------------------------------------- | ---------------------------------------------------- | ---------------------------------- |
|
|
830
|
+
| OpenAI, direct (Responses API, GPT-5.4+) | Native: `tool_search` + `defer_loading` | Native `namespace` tools |
|
|
831
|
+
| Anthropic API | Native: `tool_search_tool_bm25` + `defer_loading` | In the description |
|
|
832
|
+
| Gemini 3+ (Interactions API) | Native (preview): `tool_search` + `defer_loading` | In the description |
|
|
833
|
+
| Gemini 2.5 and older, Bedrock, OpenRouter and other gateways | Not supported: every tool is sent as usual | In the description |
|
|
834
|
+
|
|
835
|
+
MANTYX calls Gemini 3 and later through Google's Interactions API, the only
|
|
836
|
+
Gemini API with tool retrieval. Older Gemini models are called through
|
|
837
|
+
`generateContent` and receive every tool.
|
|
838
|
+
|
|
839
|
+
A model that rejects tool search or namespaces is remembered for the worker
|
|
840
|
+
process and gets the plain tool list instead. On the loop benchmark with
|
|
841
|
+
about 150 tools, OpenAI tool search cut wrong-tool calls and input tokens
|
|
842
|
+
but completed slightly fewer goals: mark the tools an agent needs on most
|
|
843
|
+
turns `alwaysLoaded`.
|
|
844
|
+
|
|
815
845
|
### 4.4 `reasoningLevel` (provider thinking strength)
|
|
816
846
|
|
|
817
847
|
`reasoningLevel` controls how much extended-thinking / reasoning effort the
|
|
@@ -1063,10 +1093,6 @@ SDK result/error fields are optional so they remain compatible with older
|
|
|
1063
1093
|
servers. A strict compatibility test should require `schemaEnforced: true` and
|
|
1064
1094
|
`unconstrainedFallbackOccurred: false`.
|
|
1065
1095
|
|
|
1066
|
-
`plan: { planOnly: true }` skips the agent execution loop, so it cannot enforce
|
|
1067
|
-
a run-level output schema. Combining plan-only execution with strict
|
|
1068
|
-
enforcement terminates as `structured_output_not_supported`.
|
|
1069
|
-
|
|
1070
1096
|
**Inheritance for sessions:**
|
|
1071
1097
|
|
|
1072
1098
|
- `POST /agent-sessions { outputSchema }` — sets the session-default,
|
|
@@ -1259,7 +1285,7 @@ including `on_track` checks — so SDK clients can render supervisor activity.
|
|
|
1259
1285
|
When `action` is `redirect` or `finalize`, the pipeline has already applied
|
|
1260
1286
|
the verdict by the time the event arrives.
|
|
1261
1287
|
|
|
1262
|
-
### 4.9 `plan` (task plan
|
|
1288
|
+
### 4.9 `plan` (task plan)
|
|
1263
1289
|
|
|
1264
1290
|
`plan` turns on the **task plan**, a live checklist the agent maintains as
|
|
1265
1291
|
it works. It is **opt-in** on API/ephemeral runs,
|
|
@@ -1278,9 +1304,6 @@ separate tracker LLM call.
|
|
|
1278
1304
|
"steps": ["Snapshot current schema", "Apply migration", "Backfill rows", "Verify counts"]
|
|
1279
1305
|
}
|
|
1280
1306
|
|
|
1281
|
-
"plan": { "planOnly": true } // produce the plan, do NOT run the agent
|
|
1282
|
-
"plan": { "planOnly": true, "steps": ["…", "…"] } // plan-only with a caller-provided checklist
|
|
1283
|
-
|
|
1284
1307
|
"plan": false // (or omit) no planning — a plain run
|
|
1285
1308
|
```
|
|
1286
1309
|
|
|
@@ -1290,19 +1313,18 @@ separate tracker LLM call.
|
|
|
1290
1313
|
| `true` / `"auto"` | Exposes `update_task_plan`; the executing agent decides during its normal first turn whether multi-step tracking is useful. No separate planning LLM call. |
|
|
1291
1314
|
| `"required"` | Requires `update_task_plan` before substantive tools and rejects premature final answers while required steps remain unfinished (bounded continuation guard). |
|
|
1292
1315
|
| `{ mode?, steps, brief? }` | Seeds an authoritative checklist. `mode` defaults to `auto`; use `required` to enforce initialization/execution. |
|
|
1293
|
-
| `{ planOnly: true, steps? }` | Produce the plan (classifier when `steps` omitted, otherwise the provided checklist) and **terminate without executing the agent loop**. The terminal `result` carries `data.plan` (see §7). |
|
|
1294
1316
|
|
|
1295
1317
|
| Field | Type | Required | Notes |
|
|
1296
1318
|
| ---------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------- |
|
|
1297
|
-
| `planOnly` | boolean | no | When `true`, the run stops after producing the plan. |
|
|
1298
1319
|
| `mode` | string | no | `off`, `auto`, or `required`. Defaults to `auto`. |
|
|
1299
1320
|
| `brief` | string | no | One-line objective for a caller-provided plan. Clamped server-side. |
|
|
1300
1321
|
| `steps` | string[] | no | Caller-provided checklist titles. Empty/omitted ⇒ auto-classify. Count + per-step length clamped server-side. |
|
|
1301
1322
|
|
|
1302
|
-
Plan-only runs
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1323
|
+
Plan-only runs (`planOnly: true`, which produce a plan and stop without
|
|
1324
|
+
running the agent; the terminal `result` carries it under `data.plan`) are
|
|
1325
|
+
**deprecated**. Current SDKs no longer offer them; the server still honors
|
|
1326
|
+
the flag so older SDK versions keep working, and may drop it in a future
|
|
1327
|
+
protocol version.
|
|
1306
1328
|
|
|
1307
1329
|
**Inheritance for sessions.**
|
|
1308
1330
|
|
|
@@ -1311,6 +1333,21 @@ runs do not use the classifier/tracker path.
|
|
|
1311
1333
|
- `POST /agent-sessions/:id/messages { plan }` — optional per-message override;
|
|
1312
1334
|
applies to that one run only and does not mutate the session's stored value.
|
|
1313
1335
|
|
|
1336
|
+
### 4.9.1 `subagents` (delegate to sub-agents)
|
|
1337
|
+
|
|
1338
|
+
`subagents: true` lets the agent start copies of itself; `{ agents: [{ name,
|
|
1339
|
+
description, systemPrompt, modelId?, tools?, … }] }` defines named sub-agents
|
|
1340
|
+
with their own instructions, model and tools (`tools` entries are names of the
|
|
1341
|
+
parent's tools or full tool refs); `{ self, agents, maxPerRun, maxConcurrent }`
|
|
1342
|
+
combines both. The run gets a built-in `spawn_subagent({ agent?, description,
|
|
1343
|
+
prompt })` tool. Each call starts a linked child run on a fresh context and
|
|
1344
|
+
returns its final report as the tool result; children cannot spawn children.
|
|
1345
|
+
The parent stream gains `subagent_started` (with `agent`) and `subagent_result`
|
|
1346
|
+
events, and a sub-agent's local tool calls are mirrored onto it as
|
|
1347
|
+
`local_tool_call` with `subagentRunId` (post their results to the parent run as
|
|
1348
|
+
usual). Accepted on `POST /agent-runs` and `POST /agent-sessions`. Full
|
|
1349
|
+
reference: [`docs/subagents.md`](subagents.md).
|
|
1350
|
+
|
|
1314
1351
|
### 4.10 `metadata` (developer-supplied KV for filtering)
|
|
1315
1352
|
|
|
1316
1353
|
`metadata` is a flat string→string KV that is **persisted alongside the run /
|
|
@@ -1636,8 +1673,11 @@ data: <utf-8 JSON>
|
|
|
1636
1673
|
// Gemini `includeThoughts`, OpenAI `reasoning_content` on reasoning models).
|
|
1637
1674
|
{ "seq": 2, "type": "thinking_delta", "data": { "text": "First, I should…" } }
|
|
1638
1675
|
|
|
1639
|
-
// completed assistant message (text + any tool calls about to execute)
|
|
1640
|
-
|
|
1676
|
+
// completed assistant message (text + any tool calls about to execute).
|
|
1677
|
+
// `usage` is this LLM call's tokens (same shape as the terminal `tokens`), so a
|
|
1678
|
+
// live view can add up a run's usage before the terminal event carries the total.
|
|
1679
|
+
{ "seq": 3, "type": "assistant_message", "data": { "text": "...", "toolCalls": [...],
|
|
1680
|
+
"usage": { "inputTokens": 1200, "cachedTokens": 800, "reasoningTokens": 0, "outputTokens": 90 } } }
|
|
1641
1681
|
|
|
1642
1682
|
// server-side tool call/result (informational; SDK does not act on these)
|
|
1643
1683
|
{ "seq": 4, "type": "tool_call", "data": { "toolUseId": "...", "name": "...", "input": {...} } }
|
|
@@ -1733,17 +1773,6 @@ data: <utf-8 JSON>
|
|
|
1733
1773
|
"turns": 2,
|
|
1734
1774
|
"model": { "id": "platform:demo", "provider": "anthropic", "vendorModelId": "claude-opus-4-7" }
|
|
1735
1775
|
} }
|
|
1736
|
-
// plan-only terminal result (see §4.9): the agent loop did NOT run. `data.plan`
|
|
1737
|
-
// carries the structured checklist; `turns` is 0 and `tokens` are zeroed
|
|
1738
|
-
// (classifier usage is metered separately under the `task_planning` surface).
|
|
1739
|
-
{ "seq": 5, "type": "result", "data": {
|
|
1740
|
-
"subtype": "success",
|
|
1741
|
-
"text": "Compare Q3 vs Q4 revenue.\n\n1. Pull revenue\n2. Compute deltas",
|
|
1742
|
-
"plan": { "brief": "Compare Q3 vs Q4 revenue.", "steps": [ { "title": "Pull revenue", "status": "pending" }, { "title": "Compute deltas", "status": "pending" } ] },
|
|
1743
|
-
"tokens": { "inputTokens": 0, "cachedTokens": 0, "reasoningTokens": 0, "outputTokens": 0 },
|
|
1744
|
-
"turns": 0,
|
|
1745
|
-
"model": { "id": "platform:demo", "provider": "openai", "vendorModelId": "gpt-5.4-mini" }
|
|
1746
|
-
} }
|
|
1747
1776
|
{ "seq": 8, "type": "cancelled", "data": {} }
|
|
1748
1777
|
```
|
|
1749
1778
|
|
|
@@ -2024,11 +2053,10 @@ A reference SDK should:
|
|
|
2024
2053
|
log line, telemetry). Do **not** abort the run on these events; the run
|
|
2025
2054
|
continues through `result` / `error` / `cancelled` as usual.
|
|
2026
2055
|
- Accept `plan` from the caller (`off` / `auto` / `required`, the boolean
|
|
2027
|
-
compatibility aliases, or `{ mode?, steps?, brief
|
|
2056
|
+
compatibility aliases, or `{ mode?, steps?, brief? }`) and pass
|
|
2028
2057
|
it through unchanged (see §4.9). Render `task_plan.data.plan` as the
|
|
2029
2058
|
canonical checklist. Apply snapshots idempotently by `planId` + `revision`
|
|
2030
2059
|
and use run-event `seq` to order multiple transitions in one revision.
|
|
2031
|
-
For `planOnly` runs read the final checklist from `result.data.plan`.
|
|
2032
2060
|
- On terminal `result`, resolve the call. On `error` subtype, throw.
|
|
2033
2061
|
4. Re-emit assistant deltas/events as a stream/iterator for callers who care
|
|
2034
2062
|
about live output.
|
package/docs/wire-protocol.md
CHANGED
|
@@ -432,7 +432,7 @@ The vocabulary (`EphemeralEventType` in `bus.ts`):
|
|
|
432
432
|
| `loop_detected` | M → SDK | 0–2× per run (soft nudge + optional hard cutoff) | Observability for the loop-detection guard (see §8). The server already substituted the synthetic skip + steering nudge — SDK clients render a status note (`looping — nudged` / `looping — gave up`) and otherwise leave the run alone. |
|
|
433
433
|
| `tool_budget_exceeded` | M → SDK | Per intercepted tool call | Observability for per-tool call budgets (see §8). The synthetic `tool_result` carrying the "budget exceeded — pivot or finalize" body lands on the normal tool-result channel; this event is purely so SDK clients can surface a UI banner. |
|
|
434
434
|
| `supervisor` | M → SDK | 0–N× per run (every `interval` LLM calls) | Run-supervisor check (see §4.7 / §8.4). Fired on **every** review — including `on_track` — so SDK clients can render supervisor activity. When the judge steers the run (`redirect` / `finalize`), the pipeline has already injected the steering message or forced a tools-disabled finalize turn. |
|
|
435
|
-
| `task_plan` | M → SDK | 0–N× per run (iff `plan` set) | Observability for the task plan (see §4.9 / §8.5). Emitted when the plan is created (caller-supplied
|
|
435
|
+
| `task_plan` | M → SDK | 0–N× per run (iff `plan` set) | Observability for the task plan (see §4.9 / §8.5). Emitted when the plan is created (caller-supplied or agent-created), then again whenever the agent's `update_task_plan` call changes step statuses. **Non-terminal.** |
|
|
436
436
|
| `assistant_message` | M → SDK | 1× per turn | Final assistant message for the turn (concatenated, persistence-ready). |
|
|
437
437
|
| `result` | M → SDK | 1× terminal | Successful completion. Carries the final assistant text and run summary. |
|
|
438
438
|
| `error` | M → SDK | 1× terminal | Failure. Carries `error` (message), `code` / `errorClass` (category), `finishReason`, and an optional `partialText` salvage payload. See §4.7. |
|
|
@@ -964,9 +964,7 @@ non-breaking since those return types were already objects).
|
|
|
964
964
|
Observability for the **task plan** (see §8.5). Emitted only when
|
|
965
965
|
the run carries a `plan` spec field. **Non-terminal** — SDK clients render a
|
|
966
966
|
live checklist that advances as the run progresses; the terminal `result`
|
|
967
|
-
stays text-only
|
|
968
|
-
right after the plan and the final checklist also rides on the terminal
|
|
969
|
-
`result` under `data.plan` (§8.5).
|
|
967
|
+
stays text-only.
|
|
970
968
|
|
|
971
969
|
---
|
|
972
970
|
|
|
@@ -1100,10 +1098,6 @@ Every terminal `result` and `error` includes the `structuredOutput` block from
|
|
|
1100
1098
|
`unconstrainedFallbackOccurred` is `false`, and the mechanism is the expected
|
|
1101
1099
|
provider path.
|
|
1102
1100
|
|
|
1103
|
-
`plan: { planOnly: true }` does not execute the agent loop and therefore cannot
|
|
1104
|
-
enforce a run-level output schema. Combining it with strict enforcement
|
|
1105
|
-
terminates explicitly as `structured_output_not_supported`.
|
|
1106
|
-
|
|
1107
1101
|
Validation (server-side, `400 invalid_request` on violation):
|
|
1108
1102
|
|
|
1109
1103
|
| Constraint | Limit |
|
|
@@ -1317,7 +1311,7 @@ omit the field to keep it disabled. The wire field above controls the
|
|
|
1317
1311
|
Each review emits a SSE `supervisor` event (§4.7). Supervisor LLM usage is
|
|
1318
1312
|
recorded under the `supervisor` usage surface for cost attribution.
|
|
1319
1313
|
|
|
1320
|
-
### 8.5 `plan` (task plan
|
|
1314
|
+
### 8.5 `plan` (task plan)
|
|
1321
1315
|
|
|
1322
1316
|
The optional `plan` field turns on the **task plan**, a live checklist the
|
|
1323
1317
|
agent maintains as it works. It is **opt-in** on ephemeral runs, same as
|
|
@@ -1331,9 +1325,6 @@ agent maintains as it works. It is **opt-in** on ephemeral runs, same as
|
|
|
1331
1325
|
"steps": ["Snapshot current schema", "Apply migration", "Backfill rows", "Verify counts"]
|
|
1332
1326
|
}
|
|
1333
1327
|
|
|
1334
|
-
"plan": { "planOnly": true } // produce the plan, do NOT run the agent
|
|
1335
|
-
"plan": { "planOnly": true, "steps": ["…", "…"] } // plan-only with a caller-provided checklist
|
|
1336
|
-
|
|
1337
1328
|
"plan": false // (or omit) no planning — a plain run
|
|
1338
1329
|
```
|
|
1339
1330
|
|
|
@@ -1342,46 +1333,17 @@ agent maintains as it works. It is **opt-in** on ephemeral runs, same as
|
|
|
1342
1333
|
| omitted / `false` | No planning. Default. |
|
|
1343
1334
|
| `true` | Pre-flight classifier decides whether a multi-step plan is warranted. If so, a `task_plan` event is emitted, the checklist is injected into the user turn, and step statuses are tracked (advancing on tool activity and on each supervisor review) until the run ends. If the classifier declines, the run proceeds normally with no plan. |
|
|
1344
1335
|
| `{ steps, brief? }` | Caller-provided checklist used verbatim — **skips** the classifier (and its `MIN_STEPS` gate). Injected + tracked like the auto case. |
|
|
1345
|
-
| `{ planOnly: true, steps? }` | Produce the plan (classifier when `steps` omitted, otherwise the provided checklist) and **terminate without executing the agent loop**. |
|
|
1346
1336
|
|
|
1347
1337
|
| Field | Type | Notes |
|
|
1348
1338
|
| ---------------- | -------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
1349
|
-
| `planOnly` | boolean | Optional. When `true`, the run stops after producing the plan; the terminal `result` carries it under `data.plan`. |
|
|
1350
1339
|
| `brief` | string | Optional one-line objective for a caller-provided plan. Clamped server-side. |
|
|
1351
1340
|
| `steps` | string[] | Optional caller-provided checklist titles. Empty/omitted ⇒ auto-classify. Count and per-step length clamped server-side. |
|
|
1352
1341
|
| (literal `true`) | `true` | Auto pre-flight classifier + live tracking. |
|
|
1353
1342
|
|
|
1354
|
-
|
|
1355
|
-
terminal `result`
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
{
|
|
1359
|
-
"seq": 5,
|
|
1360
|
-
"type": "result",
|
|
1361
|
-
"data": {
|
|
1362
|
-
"subtype": "success",
|
|
1363
|
-
"text": "Migrate the billing tables and backfill\n\n1. Snapshot current schema\n2. Apply migration\n3. Backfill rows\n4. Verify counts",
|
|
1364
|
-
"plan": {
|
|
1365
|
-
"brief": "Migrate the billing tables and backfill",
|
|
1366
|
-
"steps": [
|
|
1367
|
-
{ "title": "Snapshot current schema", "status": "pending" } /* … */,
|
|
1368
|
-
],
|
|
1369
|
-
},
|
|
1370
|
-
"tokens": {
|
|
1371
|
-
/* zeroed — classifier usage is metered separately */
|
|
1372
|
-
},
|
|
1373
|
-
"turns": 0,
|
|
1374
|
-
"model": { "id": "…", "provider": "…", "vendorModelId": "…" },
|
|
1375
|
-
},
|
|
1376
|
-
}
|
|
1377
|
-
```
|
|
1378
|
-
|
|
1379
|
-
When the classifier declines in plan-only mode, `data.plan.steps` is `[]` and
|
|
1380
|
-
`data.text` explains that no multi-step plan was warranted. Plan-only runs do
|
|
1381
|
-
**not** append an assistant turn to a session (the plan is not the answer).
|
|
1382
|
-
|
|
1383
|
-
Planner LLM usage (the plan-only classifier) is metered under the
|
|
1384
|
-
`task_planning` usage surface for cost attribution.
|
|
1343
|
+
Plan-only runs (`planOnly: true`: produce the plan and stop without running
|
|
1344
|
+
the agent, with the plan on the terminal `result` under `data.plan`) are
|
|
1345
|
+
**deprecated**. Current SDKs no longer offer them; the server still honors
|
|
1346
|
+
the flag so older SDK versions keep working.
|
|
1385
1347
|
|
|
1386
1348
|
### 8.6 Session inheritance
|
|
1387
1349
|
|
|
@@ -1574,12 +1536,11 @@ A reference SDK should:
|
|
|
1574
1536
|
status notes / log lines / telemetry — the server already substituted
|
|
1575
1537
|
synthetic tool-results / steering nudges / supervisor verdicts, so the
|
|
1576
1538
|
SDK should keep consuming the stream until the terminal event lands.
|
|
1577
|
-
- [ ] Accept `plan` from the caller (`true` | `{ steps?, brief
|
|
1539
|
+
- [ ] Accept `plan` from the caller (`true` | `{ steps?, brief? }`
|
|
1578
1540
|
| `false`) and pass it through unchanged (see §8.5). It is opt-in —
|
|
1579
1541
|
omitting it (or `false`) means no planning. Render `task_plan` events
|
|
1580
1542
|
(§4.9) as a live, non-terminal checklist; keep consuming the stream
|
|
1581
|
-
until the terminal event.
|
|
1582
|
-
from the terminal `result.data.plan`.
|
|
1543
|
+
until the terminal event.
|
|
1583
1544
|
- [ ] Maintain three local-callback registries (or one tagged-union
|
|
1584
1545
|
registry), keyed by `name`: - generic local tools (`kind: "local"`), - local A2A peers (`kind: "a2a_local"`, indexed by some Agent Card
|
|
1585
1546
|
field — typically `agentCard.url`), - local MCP servers (`kind: "mcp_local"`, indexed by the SDK-side
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mantyx/sdk",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.13",
|
|
4
4
|
"description": "MANTYX as a hosted agent runtime: define agents inline, mix server-resolved MCP and A2A tools with locally-executed tools, run them remotely.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"LICENSE"
|
|
32
32
|
],
|
|
33
33
|
"engines": {
|
|
34
|
-
"node": ">=
|
|
34
|
+
"node": ">=22.0.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@a2a-js/sdk": "^1.3.0",
|
|
58
58
|
"@types/express": "^5.0.6",
|
|
59
|
-
"@types/node": "^26.6.
|
|
59
|
+
"@types/node": "^26.6.11",
|
|
60
60
|
"express": "^5.3.0",
|
|
61
61
|
"playwright": "^1.65.1",
|
|
62
|
-
"tsrs": "
|
|
62
|
+
"tsrs": "7.1.0-beta.tsrs5",
|
|
63
63
|
"tsup": "^9.0.0",
|
|
64
64
|
"typescript": "~7.0.2",
|
|
65
|
-
"vitest": "^5.1.
|
|
65
|
+
"vitest": "^5.1.2"
|
|
66
66
|
},
|
|
67
67
|
"keywords": [
|
|
68
68
|
"mantyx",
|