@mantyx/sdk 2026.11.6 → 2026.11.8
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 +25 -0
- package/README.md +10 -59
- package/dist/a2a-server.cjs +2 -4
- package/dist/a2a-server.d.ts +5 -8
- package/dist/a2a-server.js +3 -5
- package/dist/{chunk-4WXIAVUB.js → chunk-HZGH34UW.js} +2 -198
- package/dist/client.d.ts +4 -199
- package/dist/decisions.d.ts +33 -4
- package/dist/index.cjs +3 -201
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2 -6
- package/dist/tools.d.ts +1 -13
- package/dist/version.d.ts +1 -1
- package/docs/agent-runs-protocol.md +97 -174
- package/docs/wire-protocol.md +37 -65
- package/package.json +2 -2
package/docs/wire-protocol.md
CHANGED
|
@@ -37,12 +37,12 @@ looks like for `mcp_local`, you're in the right place.
|
|
|
37
37
|
|
|
38
38
|
| Term | Meaning |
|
|
39
39
|
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
40
|
-
| **MANTYX** | The
|
|
40
|
+
| **MANTYX** | The MANTYX server (this repo). Owns LLM orchestration, tool execution for server-resolved tools, persistence. |
|
|
41
41
|
| **SDK** | Anything calling the public agent-runs API — typically `@mantyx/ts-sdk`, but also other-language SDKs and direct HTTP clients. |
|
|
42
42
|
| **Agent run** | A single LLM execution. Streams events; ends with a terminal `result` / `error` / `cancelled`. |
|
|
43
43
|
| **Spec** | The JSON object describing what the run does — model, prompt, tools, budgets, optional `reasoningLevel`. Sent in the `POST /agent-runs` (or `.../messages`) body. |
|
|
44
44
|
| **Tool ref** | One entry in `spec.tools[]`. A discriminated union keyed by `kind`. |
|
|
45
|
-
| **Server-resolved** | A tool MANTYX executes itself (`
|
|
45
|
+
| **Server-resolved** | A tool MANTYX executes itself (`a2a`, `mcp`). The SDK only sees informational `tool_result` events. |
|
|
46
46
|
| **Client-resolved** | A tool the SDK executes (`local`, `a2a_local`, `mcp_local`). MANTYX emits `local_tool_call`, the SDK does the work, the SDK posts back to `.../tool-results`. |
|
|
47
47
|
| **Resolution** | The act of turning an external resource (A2A peer, MCP server) into a self-contained JSON document the model can reason about. For `*_local` kinds, resolution is the **SDK's** responsibility. |
|
|
48
48
|
|
|
@@ -100,8 +100,8 @@ The lifecycle has three logical stages:
|
|
|
100
100
|
|
|
101
101
|
`POST /api/v1/workspaces/{slug}/agent-runs` accepts the spec body. Only the
|
|
102
102
|
new wire-protocol additions are documented in detail here; for the full
|
|
103
|
-
spec body shape (system prompt, tool budgets, sessions,
|
|
104
|
-
|
|
103
|
+
spec body shape (system prompt, tool budgets, sessions, etc.) see
|
|
104
|
+
`agent-runs-protocol.md` §4.
|
|
105
105
|
|
|
106
106
|
### 2.1 Spec body (top-level shape)
|
|
107
107
|
|
|
@@ -130,15 +130,14 @@ short-circuit, etc.) see `agent-runs-protocol.md` §4.
|
|
|
130
130
|
},
|
|
131
131
|
"toolBudgets": {
|
|
132
132
|
// optional; see §8
|
|
133
|
-
"
|
|
134
|
-
"hive_consult_ontology": { "maxCalls": 4 },
|
|
133
|
+
"search_docs": { "maxCalls": 4 },
|
|
135
134
|
},
|
|
136
135
|
"supervisor": {
|
|
137
136
|
// optional; see §8.4 — platform LLM judge on ephemeral runs
|
|
138
137
|
"interval": 5,
|
|
139
138
|
"modelId": "platform:demo",
|
|
140
139
|
},
|
|
141
|
-
"plan": true, // optional; see §8.5 —
|
|
140
|
+
"plan": true, // optional; see §8.5 — task plan (opt-in)
|
|
142
141
|
"metadata": { "customer": "acme" }, // optional, free-form k/v
|
|
143
142
|
}
|
|
144
143
|
```
|
|
@@ -190,7 +189,7 @@ created with.
|
|
|
190
189
|
|
|
191
190
|
## 3. Tool ref taxonomy
|
|
192
191
|
|
|
193
|
-
Every entry in `spec.tools[]` is one of the
|
|
192
|
+
Every entry in `spec.tools[]` is one of the five shapes below. The
|
|
194
193
|
_resolution column_ is the contract that drives everything else: **server**
|
|
195
194
|
means MANTYX runs the tool itself and the SDK only ever sees a
|
|
196
195
|
`tool_result` event; **client** means MANTYX is a transport and the SDK
|
|
@@ -198,8 +197,6 @@ must answer `local_tool_call` events.
|
|
|
198
197
|
|
|
199
198
|
| Kind | Resolution | Wire-payload contract |
|
|
200
199
|
| --------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
201
|
-
| `mantyx` | server | `{ id }` reference to a workspace `Tool` row. |
|
|
202
|
-
| `mantyx_plugin` | server | `{ name }` reference to a platform plugin tool. |
|
|
203
200
|
| `local` | client | `{ name, description?, parameters?, outputSchema?, longRunning? }` — `parameters` is **JSON Schema** (object schema with `properties`/`required`); forwarded verbatim to the LLM provider and validated against incoming tool-call args before execution. `outputSchema` (optional) is JSON Schema for the tool's structured return value, surfaced to providers that accept per-tool response schemas. `longRunning` (optional, default `false`) annotates the model-facing description with a "don't double-call while pending" hint so every provider treats the tool as long-running. |
|
|
204
201
|
| `a2a` | server | `{ name, agentCardUrl, headers?, contextId?, description? }`. |
|
|
205
202
|
| `a2a_local` | client | `{ name, agentCard }` — **resolved A2A Agent Card JSON content**. |
|
|
@@ -428,14 +425,14 @@ The vocabulary (`EphemeralEventType` in `bus.ts`):
|
|
|
428
425
|
| ---------------------- | --------- | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
429
426
|
| `assistant_delta` | M → SDK | Many | Streamed assistant text token / chunk. |
|
|
430
427
|
| `thinking_delta` | M → SDK | Many (iff `reasoningLevel > 0`) | Streamed extended-thinking text (provider redacts when policy requires). |
|
|
431
|
-
| `tool_result` | M → SDK | Per server-resolved tool call | Informational — tells the SDK that MANTYX ran a server-resolved tool (`
|
|
428
|
+
| `tool_result` | M → SDK | Per server-resolved tool call | Informational — tells the SDK that MANTYX ran a server-resolved tool (`a2a`, `mcp`) and got a result. The SDK does not need to act on it. |
|
|
432
429
|
| `tool_files` | M → SDK | Per server-resolved tool call that returns files | Informational metadata for files a server-resolved tool produced (see §4.2.1). Precedes the matching `tool_result`. Inline bytes are redacted from the stream; download via the admin route. |
|
|
433
430
|
| `local_tool_call` | M → SDK | Per client-resolved tool call | **Action required.** SDK must POST a tool-result. |
|
|
434
431
|
| `local_tool_result_in` | M → SDK | Per client-resolved tool call | Informational mirror of the tool-result the SDK just posted, persisted for observability. Re-emitted to late subscribers so they can replay the conversation. Any `files` carry only metadata on the wire (base64 `data` is redacted). |
|
|
435
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. |
|
|
436
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. |
|
|
437
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. |
|
|
438
|
-
| `task_plan` | M → SDK | 0–N× per run (iff `plan` set) | Observability for the
|
|
435
|
+
| `task_plan` | M → SDK | 0–N× per run (iff `plan` set) | Observability for the task plan (see §4.9 / §8.5). Emitted once after classify / caller-supplied plan, then again whenever the tracker advances step statuses. **Non-terminal.** For `planOnly` runs the final plan also rides on the terminal `result` under `data.plan`. |
|
|
439
436
|
| `assistant_message` | M → SDK | 1× per turn | Final assistant message for the turn (concatenated, persistence-ready). |
|
|
440
437
|
| `result` | M → SDK | 1× terminal | Successful completion. Carries the final assistant text and run summary. |
|
|
441
438
|
| `error` | M → SDK | 1× terminal | Failure. Carries `error` (message), `code` / `errorClass` (category), `finishReason`, and an optional `partialText` salvage payload. See §4.7. |
|
|
@@ -475,7 +472,7 @@ Purely informational. The SDK does not respond.
|
|
|
475
472
|
### 4.2.1 `tool_files` (server-resolved tool outputs)
|
|
476
473
|
|
|
477
474
|
Emitted when a **server-resolved** tool returns files alongside (or instead of)
|
|
478
|
-
text — e.g.
|
|
475
|
+
text — e.g. an `mcp` tool that renders a chart or exports a PDF. The bytes also
|
|
479
476
|
reach the model natively (as file parts), so this event is purely for
|
|
480
477
|
observability: it lets the Calls dashboard (and any SDK client that cares) list
|
|
481
478
|
and download a run's produced artifacts. It always precedes the matching
|
|
@@ -682,11 +679,11 @@ without depending on event ordering.
|
|
|
682
679
|
```jsonc
|
|
683
680
|
// soft nudge — pipeline injected a "finalize OR change strategy" user message
|
|
684
681
|
{ "seq": 13, "type": "loop_detected",
|
|
685
|
-
"data": { "consecutiveCount": 3, "hardCutoff": false, "tools": ["
|
|
682
|
+
"data": { "consecutiveCount": 3, "hardCutoff": false, "tools": ["search_docs"] } }
|
|
686
683
|
|
|
687
684
|
// hard cutoff — pipeline forced a tools-disabled finalise turn
|
|
688
685
|
{ "seq": 27, "type": "loop_detected",
|
|
689
|
-
"data": { "consecutiveCount": 6, "hardCutoff": true, "tools": ["
|
|
686
|
+
"data": { "consecutiveCount": 6, "hardCutoff": true, "tools": ["search_docs"] } }
|
|
690
687
|
```
|
|
691
688
|
|
|
692
689
|
| Field | Type | Notes |
|
|
@@ -709,7 +706,7 @@ See §8 for the wire-spec field that controls thresholds.
|
|
|
709
706
|
{
|
|
710
707
|
"seq": 14,
|
|
711
708
|
"type": "tool_budget_exceeded",
|
|
712
|
-
"data": { "tool": "
|
|
709
|
+
"data": { "tool": "search_docs", "maxCalls": 4, "callIndex": 5 },
|
|
713
710
|
}
|
|
714
711
|
```
|
|
715
712
|
|
|
@@ -722,7 +719,7 @@ See §8 for the wire-spec field that controls thresholds.
|
|
|
722
719
|
Observability only: the synthetic "budget exceeded — pivot or finalize"
|
|
723
720
|
tool-result lands on the normal `tool_result` channel before this event
|
|
724
721
|
fires, so the model already has the directive to pivot. SDK clients use
|
|
725
|
-
this event to render UI banners (`
|
|
722
|
+
this event to render UI banners (`search budget exhausted`, etc.) without
|
|
726
723
|
re-parsing tool-result bodies.
|
|
727
724
|
|
|
728
725
|
See §8 for the wire-spec field that defines budgets.
|
|
@@ -933,14 +930,6 @@ counts toward `turns` even when the engine throws. The terminal event
|
|
|
933
930
|
carries cumulative totals only; per-turn observability lives on
|
|
934
931
|
`assistant_message` events.
|
|
935
932
|
|
|
936
|
-
**A2A exposure.** The MANTYX-hosted A2A endpoint
|
|
937
|
-
(`POST /api/a2a/{workspaceSlug}/agents/{agentSlug}`) returns the same
|
|
938
|
-
triple under `result.metadata.mantyx`. The block is omitted entirely
|
|
939
|
-
against legacy runners that haven't implemented the optional
|
|
940
|
-
`runWithUsage` method on `AgentRunner` (see
|
|
941
|
-
`packages/ts-sdk/src/a2a/adapter.ts`); cross-platform A2A clients
|
|
942
|
-
should treat its absence as "no usage data" rather than as zero usage.
|
|
943
|
-
|
|
944
933
|
**SDK return-value exposure.** The TS SDK exposes the same triple via
|
|
945
934
|
the opt-in `runAgentWithUsage` (returning a `RunAgentResult` with
|
|
946
935
|
`text`, `tokens`, `turns`, `model`). The legacy `runAgent` still
|
|
@@ -973,7 +962,7 @@ non-breaking since those return types were already objects).
|
|
|
973
962
|
| `brief` | string | Optional one-line summary of the overall objective. |
|
|
974
963
|
| `steps` | array | Ordered checklist. Each `{ title, status }` where `status` is `"pending" \| "in_progress" \| "done"`. |
|
|
975
964
|
|
|
976
|
-
Observability for the
|
|
965
|
+
Observability for the **task plan** (see §8.5). Emitted only when
|
|
977
966
|
the run carries a `plan` spec field. **Non-terminal** — SDK clients render a
|
|
978
967
|
live checklist that advances as the run progresses; the terminal `result`
|
|
979
968
|
stays text-only for executed runs. For `planOnly` runs the run terminates
|
|
@@ -1031,7 +1020,7 @@ input shapes are accepted; both map to a numeric `0–100` internally.
|
|
|
1031
1020
|
|
|
1032
1021
|
| Form | Values | Notes |
|
|
1033
1022
|
| ---------- | -------------------------------------- | ---------------------------------------------------------- |
|
|
1034
|
-
| **String** | `"off"`, `"low"`, `"medium"`, `"high"` | Snaps to `0`, `30`, `50`, `80
|
|
1023
|
+
| **String** | `"off"`, `"low"`, `"medium"`, `"high"` | Snaps to `0`, `30`, `50`, `80`. |
|
|
1035
1024
|
| **Number** | integer `0`–`100` | Pass-through. `0` explicitly disables provider thinking. |
|
|
1036
1025
|
|
|
1037
1026
|
Per provider:
|
|
@@ -1152,10 +1141,8 @@ schema-conformant reply. Surfacing it (as a "truncated reply — JSON
|
|
|
1152
1141
|
likely incomplete" status note) is the recommended pattern; silently
|
|
1153
1142
|
falling back to it as the answer is not.
|
|
1154
1143
|
|
|
1155
|
-
`outputSchema`
|
|
1156
|
-
|
|
1157
|
-
`AgentSpec` it built. `outputSchema` is independent of `reasoningLevel`:
|
|
1158
|
-
the model can think extensively _and_ emit JSON.
|
|
1144
|
+
`outputSchema` is independent of `reasoningLevel`: the model can think
|
|
1145
|
+
extensively _and_ emit JSON.
|
|
1159
1146
|
|
|
1160
1147
|
---
|
|
1161
1148
|
|
|
@@ -1198,8 +1185,7 @@ thresholds capped at `100`; `hardCutoffThreshold` must exceed
|
|
|
1198
1185
|
`consecutiveThreshold`.
|
|
1199
1186
|
|
|
1200
1187
|
The runtime default — applied when the field is omitted — is
|
|
1201
|
-
`{ consecutiveThreshold: 3, hardCutoffThreshold: 6 }`.
|
|
1202
|
-
platform-driven runs inherit identical defaults.
|
|
1188
|
+
`{ consecutiveThreshold: 3, hardCutoffThreshold: 6 }`.
|
|
1203
1189
|
|
|
1204
1190
|
### 8.2 `toolBudgets`
|
|
1205
1191
|
|
|
@@ -1211,10 +1197,9 @@ loop and either changes strategy or finalises.
|
|
|
1211
1197
|
|
|
1212
1198
|
```jsonc
|
|
1213
1199
|
"toolBudgets": {
|
|
1214
|
-
"
|
|
1215
|
-
"
|
|
1216
|
-
"
|
|
1217
|
-
"scary_tool": { "maxCalls": 0 } // disables the tool for this run
|
|
1200
|
+
"search_docs": { "maxCalls": 4 },
|
|
1201
|
+
"fetch_page": { "maxCalls": 3 },
|
|
1202
|
+
"scary_tool": { "maxCalls": 0 } // disables the tool for this run
|
|
1218
1203
|
}
|
|
1219
1204
|
```
|
|
1220
1205
|
|
|
@@ -1223,8 +1208,8 @@ loop and either changes strategy or finalises.
|
|
|
1223
1208
|
| `<key>` | string (1–120 chars) | Logical tool name as the model sees it (`ResolvedTool.name`). The SDK + pipeline handle internal sanitisation. |
|
|
1224
1209
|
| `maxCalls` | integer ≥ 0 | Hard cap. `0` disables the tool entirely (the first attempt returns the synthetic body). |
|
|
1225
1210
|
|
|
1226
|
-
Budgets are **per-tool, not pooled** — `
|
|
1227
|
-
and `
|
|
1211
|
+
Budgets are **per-tool, not pooled** — `search_docs: { maxCalls: 5 }`
|
|
1212
|
+
and `search_tickets: { maxCalls: 5 }` give the agent five of each,
|
|
1228
1213
|
not five between them.
|
|
1229
1214
|
|
|
1230
1215
|
Validation (server-side, `400 invalid_request` on violation):
|
|
@@ -1235,21 +1220,10 @@ Validation (server-side, `400 invalid_request` on violation):
|
|
|
1235
1220
|
| `<key>` length | `1..120` |
|
|
1236
1221
|
| `maxCalls` upper bound | `1000` (functionally unlimited; `maxToolTurns: 100` fires first) |
|
|
1237
1222
|
|
|
1238
|
-
**Default budgets
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
| ---------------------------------------------------------------------------------------- | ------------------ |
|
|
1243
|
-
| `recall` (workspace memory hybrid search) | `4` |
|
|
1244
|
-
| `traverse` (memory graph BFS) | `3` |
|
|
1245
|
-
| `hive_consult_ontology` (per-hive ontology read; same name across both active hives) | `4` |
|
|
1246
|
-
| `hive_search_deals` / `_meetings` / `_companies` / `_people` (Sales Hive general search) | `5` |
|
|
1247
|
-
| `hive_search_tickets` / `_conversations` / `_accounts` (Customer Hive general search) | `5` |
|
|
1248
|
-
|
|
1249
|
-
Pass `"toolBudgets": {}` to start from a clean slate (no defaults applied
|
|
1250
|
-
on top — useful for runs that intentionally want unbounded research). When
|
|
1251
|
-
both the caller and the runtime defaults specify a budget for the same
|
|
1252
|
-
tool, **the caller's value wins**.
|
|
1223
|
+
**Default budgets.** No tool is capped by default: when the field is
|
|
1224
|
+
omitted, only the budgets you send apply (`loopDetection` still guards
|
|
1225
|
+
against repeated identical batches). `"toolBudgets": {}` is accepted and is
|
|
1226
|
+
equivalent to sending no budgets.
|
|
1253
1227
|
|
|
1254
1228
|
### 8.3 Observability
|
|
1255
1229
|
|
|
@@ -1324,14 +1298,13 @@ Reviews fire on two triggers:
|
|
|
1324
1298
|
**Model resolution.** When the supervisor is enabled, the judge model is chosen in order:
|
|
1325
1299
|
|
|
1326
1300
|
1. `supervisor.modelId` on this run (if set)
|
|
1327
|
-
2. Workspace `defaultSupervisorModelId`
|
|
1301
|
+
2. Workspace `defaultSupervisorModelId`
|
|
1328
1302
|
3. Workspace default model (same as omitting top-level `modelId`)
|
|
1329
1303
|
|
|
1330
1304
|
**Defaults.** When `supervisor` is **omitted** (or `false`), MANTYX does **not**
|
|
1331
1305
|
run the platform LLM judge on ephemeral API runs — same opt-in semantics as
|
|
1332
1306
|
`plan` (§8.5). Pass `"supervisor": true`, `"supervisor": {}`, or a config
|
|
1333
|
-
object to enable.
|
|
1334
|
-
runner.
|
|
1307
|
+
object to enable.
|
|
1335
1308
|
|
|
1336
1309
|
**SDK-only runs.** When a caller uses `@mantyx/ts-sdk` directly (not via
|
|
1337
1310
|
`POST /agent-runs`), the supervisor is **off unless explicitly configured**:
|
|
@@ -1344,10 +1317,9 @@ recorded under the `supervisor` usage surface for cost attribution.
|
|
|
1344
1317
|
|
|
1345
1318
|
### 8.5 `plan` (task plan / plan-only)
|
|
1346
1319
|
|
|
1347
|
-
The optional `plan` field turns on the
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
features add extra LLM calls.
|
|
1320
|
+
The optional `plan` field turns on the **task plan**, a live checklist the
|
|
1321
|
+
agent maintains as it works. It is **opt-in** on ephemeral runs, same as
|
|
1322
|
+
`supervisor` (§8.4), because both features add extra LLM calls.
|
|
1351
1323
|
|
|
1352
1324
|
```jsonc
|
|
1353
1325
|
"plan": true // auto: pre-flight classify, emit task_plan, track during the run
|
|
@@ -1589,10 +1561,10 @@ A reference SDK should:
|
|
|
1589
1561
|
JSON shape via the provider, but transient model errors can still
|
|
1590
1562
|
produce strings that fail to parse in rare cases.
|
|
1591
1563
|
- [ ] Accept `loopDetection`, `toolBudgets`, and `supervisor` from the caller
|
|
1592
|
-
and pass them through unchanged (see §8). `loopDetection`
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1564
|
+
and pass them through unchanged (see §8). Omitting `loopDetection`
|
|
1565
|
+
keeps the runtime defaults and `loopDetection: false` opts out;
|
|
1566
|
+
`toolBudgets` caps only the tools it names (omitted or `{}` means no
|
|
1567
|
+
caps). `supervisor` and `plan` are opt-in — omitting them
|
|
1596
1568
|
keeps both off; pass `supervisor: true` / `{}` / `{ interval?, modelId? }`
|
|
1597
1569
|
or `plan: true` / `{ … }` to enable. Do **not** translate to
|
|
1598
1570
|
vendor-specific knobs.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mantyx/sdk",
|
|
3
|
-
"version": "2026.11.
|
|
4
|
-
"description": "MANTYX as a hosted agent runtime: define
|
|
3
|
+
"version": "2026.11.8",
|
|
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",
|
|
7
7
|
"module": "./dist/index.js",
|