@mantyx/sdk 0.13.0 → 0.15.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.
- package/CHANGELOG.md +9 -2
- package/CONTRIBUTING.md +2 -8
- package/README.md +5 -0
- package/dist/a2a-server.cjs.map +1 -1
- package/dist/a2a-server.d.cts +1 -1
- package/dist/a2a-server.d.ts +1 -1
- package/dist/a2a-server.js +1 -1
- package/dist/{chunk-36QXU6NV.js → chunk-TLKXNZYY.js} +153 -13
- package/dist/chunk-TLKXNZYY.js.map +1 -0
- package/dist/{client-C-jl6_nH.d.cts → client-fu11V4HX.d.cts} +177 -16
- package/dist/{client-C-jl6_nH.d.ts → client-fu11V4HX.d.ts} +177 -16
- package/dist/index.cjs +156 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/docs/agent-runs-protocol.md +165 -26
- package/docs/wire-protocol.md +157 -26
- package/package.json +1 -1
- package/dist/chunk-36QXU6NV.js.map +0 -1
package/docs/wire-protocol.md
CHANGED
|
@@ -20,7 +20,7 @@ looks like for `mcp_local`, you're in the right place.
|
|
|
20
20
|
> **scopes** (`runs:read`, `runs:write`, `sessions:read`, `sessions:write`,
|
|
21
21
|
> `models:read`, `mantyx.identity:read`); see §2 of
|
|
22
22
|
> `agent-runs-protocol.md` for the per-endpoint scope table and
|
|
23
|
-
> `docs/oauth.md` for the registration / Authorization Code
|
|
23
|
+
> [`docs/oauth.md`](./oauth.md) for the registration / Authorization Code
|
|
24
24
|
>
|
|
25
25
|
> - PKCE flow.
|
|
26
26
|
|
|
@@ -137,17 +137,46 @@ short-circuit, etc.) see `agent-runs-protocol.md` §4.
|
|
|
137
137
|
"interval": 5,
|
|
138
138
|
"modelId": "platform:demo",
|
|
139
139
|
},
|
|
140
|
+
"plan": true, // optional; see §8.5 — in-product task plan (opt-in)
|
|
140
141
|
"metadata": { "customer": "acme" }, // optional, free-form k/v
|
|
141
142
|
}
|
|
142
143
|
```
|
|
143
144
|
|
|
145
|
+
### 2.1.1 `messages` and file inputs
|
|
146
|
+
|
|
147
|
+
Instead of `prompt`, send a `messages` array for multi-role input. Each entry
|
|
148
|
+
is `{ role: "user" | "assistant" | "system", content, attachments? }`. `system`
|
|
149
|
+
messages are merged after `systemPrompt`; the last non-system message must be a
|
|
150
|
+
`user` turn. The last user message may carry up to 20 `attachments`:
|
|
151
|
+
|
|
152
|
+
```jsonc
|
|
153
|
+
{
|
|
154
|
+
"type": "input_file",
|
|
155
|
+
"mimeType": "application/pdf",
|
|
156
|
+
"filename": "report.pdf",
|
|
157
|
+
"data": "<base64>", // inline bytes; total inline ≤ 5 MB per run
|
|
158
|
+
}
|
|
159
|
+
// — or —
|
|
160
|
+
{
|
|
161
|
+
"type": "input_file_url",
|
|
162
|
+
"url": "https://example.com/image.png", // https only; provider fetches it
|
|
163
|
+
"mimeType": "image/png", // optional
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
See [`agent-runs-protocol.md` §4.0.1](./agent-runs-protocol.md) for the full
|
|
168
|
+
rules (allowed MIME types, size caps, validation errors). On session-events
|
|
169
|
+
replay, `user_message` frames include `attachments` **metadata** (no bytes).
|
|
170
|
+
|
|
144
171
|
### 2.2 Sessions
|
|
145
172
|
|
|
146
|
-
Same body shape, posted to `POST /agent-sessions/:id/messages
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
173
|
+
Same body shape, posted to `POST /agent-sessions/:id/messages` (accepts either
|
|
174
|
+
`prompt` or `messages`, including file attachments — the messages are the new
|
|
175
|
+
turn(s) appended to the session). The session keeps the conversation history;
|
|
176
|
+
per-message `tools`, `reasoningLevel`, `outputSchema`, `loopDetection`,
|
|
177
|
+
`toolBudgets`, `supervisor`, and `plan` _replace_ the session's defaults for
|
|
178
|
+
that single run only — the next run falls back to whatever the session was
|
|
179
|
+
created with.
|
|
151
180
|
|
|
152
181
|
---
|
|
153
182
|
|
|
@@ -397,6 +426,7 @@ The vocabulary (`EphemeralEventType` in `bus.ts`):
|
|
|
397
426
|
| `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. |
|
|
398
427
|
| `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. |
|
|
399
428
|
| `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. |
|
|
429
|
+
| `task_plan` | M → SDK | 0–N× per run (iff `plan` set) | Observability for the in-product 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`. |
|
|
400
430
|
| `assistant_message` | M → SDK | 1× per turn | Final assistant message for the turn (concatenated, persistence-ready). |
|
|
401
431
|
| `result` | M → SDK | 1× terminal | Successful completion. Carries the final assistant text and run summary. |
|
|
402
432
|
| `error` | M → SDK | 1× terminal | Failure. Carries `error` (message), `code` / `errorClass` (category), `finishReason`, and an optional `partialText` salvage payload. See §4.7. |
|
|
@@ -681,9 +711,9 @@ appended (`redirect`) or the next turn was forced tools-disabled
|
|
|
681
711
|
(`finalize`). SDK clients should render a status note and **not** try to
|
|
682
712
|
steer the run themselves.
|
|
683
713
|
|
|
684
|
-
Pass `"supervisor":
|
|
685
|
-
for a run. Omission
|
|
686
|
-
ephemeral runs
|
|
714
|
+
Pass `"supervisor": true` or `"supervisor": {}` in the spec (§8.4) to enable
|
|
715
|
+
the platform judge for a run. Omission (or `"supervisor": false`) keeps the
|
|
716
|
+
supervisor **off** on ephemeral API runs.
|
|
687
717
|
|
|
688
718
|
### 4.8 Terminal events
|
|
689
719
|
|
|
@@ -828,6 +858,37 @@ returns just `string` for backward compatibility — see
|
|
|
828
858
|
directly on the existing `RunResult` struct/dataclass (additive,
|
|
829
859
|
non-breaking since those return types were already objects).
|
|
830
860
|
|
|
861
|
+
### 4.9 `task_plan`
|
|
862
|
+
|
|
863
|
+
```jsonc
|
|
864
|
+
// First emission — right after the pre-flight classifier (or a caller-supplied
|
|
865
|
+
// plan). The first step is marked in_progress for executed runs.
|
|
866
|
+
{ "seq": 4, "type": "task_plan",
|
|
867
|
+
"data": { "brief": "Compare Q3 vs Q4 revenue and summarize drivers.",
|
|
868
|
+
"steps": [ { "title": "Pull Q3 and Q4 revenue", "status": "in_progress" },
|
|
869
|
+
{ "title": "Compute deltas by segment", "status": "pending" },
|
|
870
|
+
{ "title": "Summarize the top drivers", "status": "pending" } ] } }
|
|
871
|
+
|
|
872
|
+
// Tracker advance — emitted whenever step statuses change during the run.
|
|
873
|
+
{ "seq": 18, "type": "task_plan",
|
|
874
|
+
"data": { "brief": "Compare Q3 vs Q4 revenue and summarize drivers.",
|
|
875
|
+
"steps": [ { "title": "Pull Q3 and Q4 revenue", "status": "done" },
|
|
876
|
+
{ "title": "Compute deltas by segment", "status": "in_progress" },
|
|
877
|
+
{ "title": "Summarize the top drivers", "status": "pending" } ] } }
|
|
878
|
+
```
|
|
879
|
+
|
|
880
|
+
| Field | Type | Notes |
|
|
881
|
+
| ------- | ------ | ----------------------------------------------------------------------------------------------------- |
|
|
882
|
+
| `brief` | string | Optional one-line summary of the overall objective. |
|
|
883
|
+
| `steps` | array | Ordered checklist. Each `{ title, status }` where `status` is `"pending" \| "in_progress" \| "done"`. |
|
|
884
|
+
|
|
885
|
+
Observability for the in-product **task plan** (see §8.5). Emitted only when
|
|
886
|
+
the run carries a `plan` spec field. **Non-terminal** — SDK clients render a
|
|
887
|
+
live checklist that advances as the run progresses; the terminal `result`
|
|
888
|
+
stays text-only for executed runs. For `planOnly` runs the run terminates
|
|
889
|
+
right after the plan and the final checklist also rides on the terminal
|
|
890
|
+
`result` under `data.plan` (§8.5).
|
|
891
|
+
|
|
831
892
|
---
|
|
832
893
|
|
|
833
894
|
## 5. SDK → MANTYX: tool-result POST
|
|
@@ -1077,6 +1138,8 @@ banners without re-parsing tool-result bodies:
|
|
|
1077
1138
|
- `tool_budget_exceeded` — fired each time a call is intercepted. See §4.6.
|
|
1078
1139
|
- `supervisor` — fired on every run-supervisor review (`on_track`,
|
|
1079
1140
|
`redirect`, or `finalize`). See §4.7.
|
|
1141
|
+
- `task_plan` — fired when a run carries a `plan` spec field: once after
|
|
1142
|
+
classify / caller-supplied plan, then on each tracker advance. See §4.9 / §8.5.
|
|
1080
1143
|
|
|
1081
1144
|
Both guard events (`loop_detected`, `tool_budget_exceeded`) are
|
|
1082
1145
|
observability-only: the server has already substituted the synthetic
|
|
@@ -1102,17 +1165,20 @@ measured at the bottom of tool-emitting rounds. Default interval is **5**
|
|
|
1102
1165
|
when the field is omitted.
|
|
1103
1166
|
|
|
1104
1167
|
```jsonc
|
|
1168
|
+
"supervisor": true // enable with platform defaults (interval 5, workspace judge model)
|
|
1169
|
+
|
|
1105
1170
|
"supervisor": {
|
|
1106
1171
|
"interval": 5, // optional — LLM calls between reviews; default 5
|
|
1107
1172
|
"modelId": "platform:demo" // optional — judge model; see resolution below
|
|
1108
1173
|
}
|
|
1109
1174
|
|
|
1110
1175
|
// or:
|
|
1111
|
-
"supervisor": false // explicitly disable
|
|
1176
|
+
"supervisor": false // explicitly disable (same as omitting the field)
|
|
1112
1177
|
```
|
|
1113
1178
|
|
|
1114
1179
|
| Field | Type | Notes |
|
|
1115
1180
|
| ---------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
1181
|
+
| (literal `true`) | `true` | Enables the run supervisor with platform defaults (`interval` 5, workspace judge model). |
|
|
1116
1182
|
| `interval` | integer ≥ 1 | Optional. Default **5** when omitted. Capped at **100** server-side. |
|
|
1117
1183
|
| `modelId` | string | Optional. Same selector grammar as top-level `modelId` (§2). When omitted, the platform resolves the judge model from the workspace default supervisor model, then the workspace default model. |
|
|
1118
1184
|
| (literal `false`) | `false` | Disables the run supervisor for this run. Loop detection and tool budgets still apply. |
|
|
@@ -1123,27 +1189,84 @@ when the field is omitted.
|
|
|
1123
1189
|
2. Workspace `defaultSupervisorModelId` (Settings → Workspace → General)
|
|
1124
1190
|
3. Workspace default model (same as omitting top-level `modelId`)
|
|
1125
1191
|
|
|
1126
|
-
**Defaults.** When `supervisor` is **omitted
|
|
1127
|
-
LLM judge on ephemeral runs
|
|
1128
|
-
|
|
1192
|
+
**Defaults.** When `supervisor` is **omitted** (or `false`), MANTYX does **not**
|
|
1193
|
+
run the platform LLM judge on ephemeral API runs — same opt-in semantics as
|
|
1194
|
+
`plan` (§8.5). Pass `"supervisor": true`, `"supervisor": {}`, or a config
|
|
1195
|
+
object to enable. Web chat enables the supervisor separately via the chat
|
|
1196
|
+
runner.
|
|
1129
1197
|
|
|
1130
1198
|
**SDK-only runs.** When a caller uses `@mantyx/ts-sdk` directly (not via
|
|
1131
1199
|
`POST /agent-runs`), the supervisor is **off unless explicitly configured**:
|
|
1132
1200
|
pass a `RunAgentSupervisor` object with a `review` callback to enable it, or
|
|
1133
|
-
|
|
1134
|
-
|
|
1201
|
+
omit the field to keep it disabled. The wire field above controls the
|
|
1202
|
+
**platform-hosted** judge on ephemeral API runs only.
|
|
1135
1203
|
|
|
1136
1204
|
Each review emits a SSE `supervisor` event (§4.7). Supervisor LLM usage is
|
|
1137
1205
|
recorded under the `supervisor` usage surface for cost attribution.
|
|
1138
1206
|
|
|
1139
|
-
### 8.5
|
|
1207
|
+
### 8.5 `plan` (task plan / plan-only)
|
|
1208
|
+
|
|
1209
|
+
The optional `plan` field turns on the in-product **task plan** — the same
|
|
1210
|
+
engine that drives the live checklist in MANTYX chat / Hive Mind. It is
|
|
1211
|
+
**opt-in** on ephemeral runs, same as `supervisor` (§8.4), because both
|
|
1212
|
+
features add extra LLM calls.
|
|
1213
|
+
|
|
1214
|
+
```jsonc
|
|
1215
|
+
"plan": true // auto: pre-flight classify, emit task_plan, track during the run
|
|
1216
|
+
|
|
1217
|
+
"plan": { // caller-provided checklist — skips the classifier
|
|
1218
|
+
"brief": "Migrate the billing tables and backfill", // optional
|
|
1219
|
+
"steps": ["Snapshot current schema", "Apply migration", "Backfill rows", "Verify counts"]
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
"plan": { "planOnly": true } // produce the plan, do NOT run the agent
|
|
1223
|
+
"plan": { "planOnly": true, "steps": ["…", "…"] } // plan-only with a caller-provided checklist
|
|
1224
|
+
|
|
1225
|
+
"plan": false // (or omit) no planning — a plain run
|
|
1226
|
+
```
|
|
1227
|
+
|
|
1228
|
+
| Form | Behavior |
|
|
1229
|
+
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1230
|
+
| omitted / `false` | No planning. Default. |
|
|
1231
|
+
| `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. |
|
|
1232
|
+
| `{ steps, brief? }` | Caller-provided checklist used verbatim — **skips** the classifier (and its `MIN_STEPS` gate). Injected + tracked like the auto case. |
|
|
1233
|
+
| `{ planOnly: true, steps? }` | Produce the plan (classifier when `steps` omitted, otherwise the provided checklist) and **terminate without executing the agent loop**. |
|
|
1234
|
+
|
|
1235
|
+
| Field | Type | Notes |
|
|
1236
|
+
| ---------- | -------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
1237
|
+
| `planOnly` | boolean | Optional. When `true`, the run stops after producing the plan; the terminal `result` carries it under `data.plan`. |
|
|
1238
|
+
| `brief` | string | Optional one-line objective for a caller-provided plan. Clamped server-side. |
|
|
1239
|
+
| `steps` | string[] | Optional caller-provided checklist titles. Empty/omitted ⇒ auto-classify. Count and per-step length clamped server-side. |
|
|
1240
|
+
| (literal `true`) | `true` | Auto pre-flight classifier + live tracking. |
|
|
1241
|
+
|
|
1242
|
+
**Plan-only terminal shape.** A `planOnly` run terminates with the normal
|
|
1243
|
+
terminal `result` event (§4.8), plus a structured `plan`:
|
|
1244
|
+
|
|
1245
|
+
```jsonc
|
|
1246
|
+
{ "seq": 5, "type": "result",
|
|
1247
|
+
"data": { "subtype": "success",
|
|
1248
|
+
"text": "Migrate the billing tables and backfill\n\n1. Snapshot current schema\n2. Apply migration\n3. Backfill rows\n4. Verify counts",
|
|
1249
|
+
"plan": { "brief": "Migrate the billing tables and backfill",
|
|
1250
|
+
"steps": [ { "title": "Snapshot current schema", "status": "pending" }, /* … */ ] },
|
|
1251
|
+
"tokens": { /* zeroed — classifier usage is metered separately */ },
|
|
1252
|
+
"turns": 0, "model": { "id": "…", "provider": "…", "vendorModelId": "…" } } }
|
|
1253
|
+
```
|
|
1254
|
+
|
|
1255
|
+
When the classifier declines in plan-only mode, `data.plan.steps` is `[]` and
|
|
1256
|
+
`data.text` explains that no multi-step plan was warranted. Plan-only runs do
|
|
1257
|
+
**not** append an assistant turn to a session (the plan is not the answer).
|
|
1258
|
+
|
|
1259
|
+
Planner LLM usage (the classifier and the per-run tracker) is metered under
|
|
1260
|
+
the `task_planning` usage surface for cost attribution.
|
|
1261
|
+
|
|
1262
|
+
### 8.6 Session inheritance
|
|
1140
1263
|
|
|
1141
|
-
Like `reasoningLevel` and `outputSchema`, the run-guard fields
|
|
1142
|
-
session-default + per-message override:
|
|
1264
|
+
Like `reasoningLevel` and `outputSchema`, the run-guard and `plan` fields
|
|
1265
|
+
support session-default + per-message override:
|
|
1143
1266
|
|
|
1144
|
-
- `POST /agent-sessions { loopDetection, toolBudgets, supervisor }` — sets
|
|
1145
|
-
session-default applied to every subsequent message run.
|
|
1146
|
-
- `POST /agent-sessions/:id/messages { loopDetection, toolBudgets, supervisor }` —
|
|
1267
|
+
- `POST /agent-sessions { loopDetection, toolBudgets, supervisor, plan }` — sets
|
|
1268
|
+
the session-default applied to every subsequent message run.
|
|
1269
|
+
- `POST /agent-sessions/:id/messages { loopDetection, toolBudgets, supervisor, plan }` —
|
|
1147
1270
|
optional per-message override. Applies to that one run only and does
|
|
1148
1271
|
not mutate the session's stored value.
|
|
1149
1272
|
|
|
@@ -1316,16 +1439,24 @@ A reference SDK should:
|
|
|
1316
1439
|
JSON shape via the provider, but transient model errors can still
|
|
1317
1440
|
produce strings that fail to parse in rare cases.
|
|
1318
1441
|
- [ ] Accept `loopDetection`, `toolBudgets`, and `supervisor` from the caller
|
|
1319
|
-
and pass them through unchanged (see §8).
|
|
1320
|
-
omitting them keeps the runtime defaults;
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1442
|
+
and pass them through unchanged (see §8). `loopDetection` and
|
|
1443
|
+
`toolBudgets` are additive — omitting them keeps the runtime defaults;
|
|
1444
|
+
passing `loopDetection: false` opts out; passing `toolBudgets: {}`
|
|
1445
|
+
clears the defaults. `supervisor` and `plan` are opt-in — omitting them
|
|
1446
|
+
keeps both off; pass `supervisor: true` / `{}` / `{ interval?, modelId? }`
|
|
1447
|
+
or `plan: true` / `{ … }` to enable. Do **not** translate to
|
|
1448
|
+
vendor-specific knobs.
|
|
1324
1449
|
- [ ] Treat `loop_detected`, `tool_budget_exceeded`, and `supervisor` SSE
|
|
1325
1450
|
events as observability-only (see §4.5 / §4.6 / §4.7). Surface them as
|
|
1326
1451
|
status notes / log lines / telemetry — the server already substituted
|
|
1327
1452
|
synthetic tool-results / steering nudges / supervisor verdicts, so the
|
|
1328
1453
|
SDK should keep consuming the stream until the terminal event lands.
|
|
1454
|
+
- [ ] Accept `plan` from the caller (`true` | `{ steps?, brief?, planOnly? }`
|
|
1455
|
+
| `false`) and pass it through unchanged (see §8.5). It is opt-in —
|
|
1456
|
+
omitting it (or `false`) means no planning. Render `task_plan` events
|
|
1457
|
+
(§4.9) as a live, non-terminal checklist; keep consuming the stream
|
|
1458
|
+
until the terminal event. For `planOnly` runs, read the final checklist
|
|
1459
|
+
from the terminal `result.data.plan`.
|
|
1329
1460
|
- [ ] Maintain three local-callback registries (or one tagged-union
|
|
1330
1461
|
registry), keyed by `name`: - generic local tools (`kind: "local"`), - local A2A peers (`kind: "a2a_local"`, indexed by some Agent Card
|
|
1331
1462
|
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": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
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",
|