@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/index.cjs
CHANGED
|
@@ -61,7 +61,6 @@ __export(index_exports, {
|
|
|
61
61
|
mantyxA2A: () => mantyxA2A,
|
|
62
62
|
mantyxMcp: () => mantyxMcp,
|
|
63
63
|
parseRunOutput: () => parseRunOutput,
|
|
64
|
-
planOnly: () => planOnly,
|
|
65
64
|
readSseStream: () => readSseStream,
|
|
66
65
|
runComputerUse: () => runComputerUse,
|
|
67
66
|
taskPlanFromEventData: () => taskPlanFromEventData,
|
|
@@ -184,6 +183,7 @@ function defineLocalTool(opts) {
|
|
|
184
183
|
longRunning: opts.longRunning ?? false,
|
|
185
184
|
readOnly: opts.readOnly ?? false,
|
|
186
185
|
retain: opts.retain ?? false,
|
|
186
|
+
...toolGrouping(opts),
|
|
187
187
|
execute: opts.execute
|
|
188
188
|
};
|
|
189
189
|
}
|
|
@@ -198,7 +198,8 @@ function mantyxA2A(opts) {
|
|
|
198
198
|
...opts.description !== void 0 ? { description: opts.description } : {},
|
|
199
199
|
agentCardUrl: opts.agentCardUrl,
|
|
200
200
|
...opts.headers ? { headers: { ...opts.headers } } : {},
|
|
201
|
-
...opts.contextId ? { contextId: opts.contextId } : {}
|
|
201
|
+
...opts.contextId ? { contextId: opts.contextId } : {},
|
|
202
|
+
...toolGrouping(opts)
|
|
202
203
|
};
|
|
203
204
|
}
|
|
204
205
|
function defineLocalA2A(opts) {
|
|
@@ -210,7 +211,8 @@ function defineLocalA2A(opts) {
|
|
|
210
211
|
kind: "a2a_local",
|
|
211
212
|
name: opts.name,
|
|
212
213
|
agentCardUrl: opts.agentCardUrl,
|
|
213
|
-
headers: opts.headers ? { ...opts.headers } : void 0
|
|
214
|
+
headers: opts.headers ? { ...opts.headers } : void 0,
|
|
215
|
+
...toolGrouping(opts)
|
|
214
216
|
};
|
|
215
217
|
}
|
|
216
218
|
function mantyxMcp(opts) {
|
|
@@ -223,7 +225,8 @@ function mantyxMcp(opts) {
|
|
|
223
225
|
name: opts.name,
|
|
224
226
|
url: opts.url,
|
|
225
227
|
...opts.headers ? { headers: { ...opts.headers } } : {},
|
|
226
|
-
...opts.toolFilter ? { toolFilter: [...opts.toolFilter] } : {}
|
|
228
|
+
...opts.toolFilter ? { toolFilter: [...opts.toolFilter] } : {},
|
|
229
|
+
...toolGrouping(opts)
|
|
227
230
|
};
|
|
228
231
|
}
|
|
229
232
|
function defineLocalMcp(opts) {
|
|
@@ -249,7 +252,8 @@ function defineLocalMcp(opts) {
|
|
|
249
252
|
url,
|
|
250
253
|
...opts.headers ? { headers: { ...opts.headers } } : {}
|
|
251
254
|
},
|
|
252
|
-
stdio: void 0
|
|
255
|
+
stdio: void 0,
|
|
256
|
+
...toolGrouping(opts)
|
|
253
257
|
};
|
|
254
258
|
}
|
|
255
259
|
const command = opts.command;
|
|
@@ -262,7 +266,8 @@ function defineLocalMcp(opts) {
|
|
|
262
266
|
...opts.args ? { args: [...opts.args] } : {},
|
|
263
267
|
...opts.env ? { env: { ...opts.env } } : {},
|
|
264
268
|
...opts.cwd ? { cwd: opts.cwd } : {}
|
|
265
|
-
}
|
|
269
|
+
},
|
|
270
|
+
...toolGrouping(opts)
|
|
266
271
|
};
|
|
267
272
|
}
|
|
268
273
|
function isLocalTool(t) {
|
|
@@ -282,6 +287,34 @@ function assertToolName(name) {
|
|
|
282
287
|
);
|
|
283
288
|
}
|
|
284
289
|
}
|
|
290
|
+
var TOOL_NAMESPACE_RE = /^[a-zA-Z0-9_]{1,64}$/;
|
|
291
|
+
function assertToolNamespace(namespace, label = "tool namespace") {
|
|
292
|
+
if (typeof namespace !== "string" || !TOOL_NAMESPACE_RE.test(namespace)) {
|
|
293
|
+
throw new Error(
|
|
294
|
+
`Invalid ${label} ${JSON.stringify(namespace)}: must match /^[a-zA-Z0-9_]{1,64}$/`
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function toolGrouping(opts) {
|
|
299
|
+
const out = {};
|
|
300
|
+
if (opts.namespace !== void 0) {
|
|
301
|
+
assertToolNamespace(opts.namespace);
|
|
302
|
+
out.namespace = opts.namespace;
|
|
303
|
+
}
|
|
304
|
+
if (opts.alwaysLoaded !== void 0) {
|
|
305
|
+
if (typeof opts.alwaysLoaded !== "boolean") {
|
|
306
|
+
throw new Error(`alwaysLoaded must be a boolean, got ${JSON.stringify(opts.alwaysLoaded)}`);
|
|
307
|
+
}
|
|
308
|
+
out.alwaysLoaded = opts.alwaysLoaded;
|
|
309
|
+
}
|
|
310
|
+
return out;
|
|
311
|
+
}
|
|
312
|
+
function toolGroupingWire(t) {
|
|
313
|
+
return {
|
|
314
|
+
...t.namespace !== void 0 ? { namespace: t.namespace } : {},
|
|
315
|
+
...t.alwaysLoaded !== void 0 ? { alwaysLoaded: t.alwaysLoaded } : {}
|
|
316
|
+
};
|
|
317
|
+
}
|
|
285
318
|
function prefixedMcpToolName(serverName, toolName) {
|
|
286
319
|
const prefix = `${serverName}_`;
|
|
287
320
|
return toolName.startsWith(prefix) ? toolName : `${prefix}${toolName}`;
|
|
@@ -756,13 +789,6 @@ function inputFileUrlAttachment(opts) {
|
|
|
756
789
|
return { type: "input_file_url", ...opts };
|
|
757
790
|
}
|
|
758
791
|
var RUN_FEEDBACK_EXPLANATION_MAX = 8e3;
|
|
759
|
-
function planOnly(options = {}) {
|
|
760
|
-
return {
|
|
761
|
-
planOnly: true,
|
|
762
|
-
...options.steps !== void 0 ? { steps: options.steps } : {},
|
|
763
|
-
...options.brief !== void 0 ? { brief: options.brief } : {}
|
|
764
|
-
};
|
|
765
|
-
}
|
|
766
792
|
function buildQueryString(query) {
|
|
767
793
|
if (!query) return "";
|
|
768
794
|
const parts = [];
|
|
@@ -824,7 +850,7 @@ var MantyxClient = class {
|
|
|
824
850
|
}
|
|
825
851
|
// ------------------------------------------------------------- One-shot
|
|
826
852
|
async runAgent(spec) {
|
|
827
|
-
const tools = spec.tools ?? [];
|
|
853
|
+
const tools = toolsWithSubagentTools(spec.tools ?? [], spec.subagents);
|
|
828
854
|
await resolveLocalRefs(tools, { fetch: this.options.fetch });
|
|
829
855
|
const handlers = collectLocalHandlers(tools);
|
|
830
856
|
try {
|
|
@@ -848,26 +874,8 @@ var MantyxClient = class {
|
|
|
848
874
|
await closeMcpRefs(tools);
|
|
849
875
|
}
|
|
850
876
|
}
|
|
851
|
-
/**
|
|
852
|
-
* Plan-only run: classify (or accept caller `steps`) and return the
|
|
853
|
-
* structured checklist without executing the agent loop. Sugar for
|
|
854
|
-
* `runAgent({ ..., plan: planOnly({ steps, brief }) })`.
|
|
855
|
-
*
|
|
856
|
-
* The final checklist is on {@link RunResult.plan}; intermediate
|
|
857
|
-
* progress is available via `task_plan` events when streaming.
|
|
858
|
-
*/
|
|
859
|
-
async runPlan(spec) {
|
|
860
|
-
const { steps, brief, ...rest } = spec;
|
|
861
|
-
return this.runAgent({
|
|
862
|
-
...rest,
|
|
863
|
-
plan: planOnly({
|
|
864
|
-
...steps !== void 0 ? { steps } : {},
|
|
865
|
-
...brief !== void 0 ? { brief } : {}
|
|
866
|
-
})
|
|
867
|
-
});
|
|
868
|
-
}
|
|
869
877
|
async *streamAgent(spec) {
|
|
870
|
-
const tools = spec.tools ?? [];
|
|
878
|
+
const tools = toolsWithSubagentTools(spec.tools ?? [], spec.subagents);
|
|
871
879
|
await resolveLocalRefs(tools, { fetch: this.options.fetch });
|
|
872
880
|
const handlers = collectLocalHandlers(tools);
|
|
873
881
|
try {
|
|
@@ -897,14 +905,15 @@ var MantyxClient = class {
|
|
|
897
905
|
// ------------------------------------------------------------- Sessions
|
|
898
906
|
async createSession(spec) {
|
|
899
907
|
const tools = spec.tools ?? [];
|
|
900
|
-
|
|
901
|
-
|
|
908
|
+
const ownedTools = toolsWithSubagentTools(tools, spec.subagents);
|
|
909
|
+
await resolveLocalRefs(ownedTools, { fetch: this.options.fetch });
|
|
910
|
+
const handlers = collectLocalHandlers(ownedTools);
|
|
902
911
|
const created = await this.request({
|
|
903
912
|
method: "POST",
|
|
904
913
|
path: "/agent-sessions",
|
|
905
914
|
body: serializeAgentSpec(spec)
|
|
906
915
|
});
|
|
907
|
-
return new AgentSession(this, created.sessionId, handlers, tools);
|
|
916
|
+
return new AgentSession(this, created.sessionId, handlers, tools, ownedTools);
|
|
908
917
|
}
|
|
909
918
|
/**
|
|
910
919
|
* Re-emit a `local_tool_call` event into the right local handler. Useful
|
|
@@ -1007,7 +1016,6 @@ var MantyxClient = class {
|
|
|
1007
1016
|
let turns;
|
|
1008
1017
|
let modelInfo;
|
|
1009
1018
|
let structuredOutput;
|
|
1010
|
-
let plan;
|
|
1011
1019
|
for await (const ev of this.streamRunEvents(runId, handlers, opts.signal)) {
|
|
1012
1020
|
collected.push(ev);
|
|
1013
1021
|
if (opts.onEvent) opts.onEvent(ev);
|
|
@@ -1022,10 +1030,6 @@ var MantyxClient = class {
|
|
|
1022
1030
|
structuredOutput = parseStructuredOutputInfo(r.structuredOutput) ?? structuredOutput;
|
|
1023
1031
|
if (r.subtype === "success") {
|
|
1024
1032
|
finalText = typeof r.text === "string" ? r.text : "";
|
|
1025
|
-
const parsedPlan = parseTaskPlan(r.plan);
|
|
1026
|
-
if (parsedPlan !== void 0) {
|
|
1027
|
-
plan = parsedPlan;
|
|
1028
|
-
}
|
|
1029
1033
|
} else {
|
|
1030
1034
|
const errInit = {};
|
|
1031
1035
|
if (tokens !== void 0) errInit.tokens = tokens;
|
|
@@ -1062,7 +1066,6 @@ var MantyxClient = class {
|
|
|
1062
1066
|
if (turns !== void 0) result.turns = turns;
|
|
1063
1067
|
if (modelInfo !== void 0) result.model = modelInfo;
|
|
1064
1068
|
if (structuredOutput !== void 0) result.structuredOutput = structuredOutput;
|
|
1065
|
-
if (plan !== void 0) result.plan = plan;
|
|
1066
1069
|
return result;
|
|
1067
1070
|
}
|
|
1068
1071
|
async *streamRunEvents(runId, handlers, signal) {
|
|
@@ -1178,6 +1181,59 @@ var MantyxClient = class {
|
|
|
1178
1181
|
}
|
|
1179
1182
|
}
|
|
1180
1183
|
}
|
|
1184
|
+
/**
|
|
1185
|
+
* Fetch a run's snapshot: status, final text, token totals, model, and
|
|
1186
|
+
* for a sub-agent run its parent (`parentRunId`, `parentToolUseId`).
|
|
1187
|
+
*/
|
|
1188
|
+
async getRun(runId) {
|
|
1189
|
+
return this.request({
|
|
1190
|
+
method: "GET",
|
|
1191
|
+
path: `/agent-runs/${encodeURIComponent(runId)}`
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* List runs, newest first, one page at a time (follow `nextCursor`).
|
|
1196
|
+
* Without `parentRunId` only top-level runs are listed; with it, the
|
|
1197
|
+
* sub-agent runs that run started.
|
|
1198
|
+
*/
|
|
1199
|
+
async listRuns(opts = {}) {
|
|
1200
|
+
const query = {};
|
|
1201
|
+
if (typeof opts.limit === "number") query.limit = opts.limit;
|
|
1202
|
+
if (opts.cursor) query.cursor = opts.cursor;
|
|
1203
|
+
if (opts.status) query.status = opts.status;
|
|
1204
|
+
if (opts.modelId) query.modelId = opts.modelId;
|
|
1205
|
+
if (opts.metadata) {
|
|
1206
|
+
const pairs = Object.entries(opts.metadata).map(([k, v]) => `${k}:${v}`);
|
|
1207
|
+
if (pairs.length > 0) query.metadata = pairs;
|
|
1208
|
+
}
|
|
1209
|
+
if (opts.parentRunId) query.parentRunId = opts.parentRunId;
|
|
1210
|
+
if (opts.includeTotal) query.includeTotal = "1";
|
|
1211
|
+
const res = await this.request({
|
|
1212
|
+
method: "GET",
|
|
1213
|
+
path: "/agent-runs",
|
|
1214
|
+
query
|
|
1215
|
+
});
|
|
1216
|
+
return {
|
|
1217
|
+
total: typeof res.total === "number" ? res.total : null,
|
|
1218
|
+
limit: res.limit ?? 0,
|
|
1219
|
+
nextCursor: res.nextCursor ?? null,
|
|
1220
|
+
runs: res.runs ?? []
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
/**
|
|
1224
|
+
* Every sub-agent run the given run started, newest first. Pages through
|
|
1225
|
+
* {@link listRuns} with `parentRunId` until the last page.
|
|
1226
|
+
*/
|
|
1227
|
+
async listSubagents(runId) {
|
|
1228
|
+
const runs = [];
|
|
1229
|
+
let cursor;
|
|
1230
|
+
do {
|
|
1231
|
+
const page = await this.listRuns({ parentRunId: runId, limit: 200, cursor });
|
|
1232
|
+
runs.push(...page.runs);
|
|
1233
|
+
cursor = page.nextCursor ?? void 0;
|
|
1234
|
+
} while (cursor);
|
|
1235
|
+
return runs;
|
|
1236
|
+
}
|
|
1181
1237
|
async cancelRun(runId) {
|
|
1182
1238
|
await this.request({
|
|
1183
1239
|
method: "POST",
|
|
@@ -1339,11 +1395,13 @@ var AgentSession = class {
|
|
|
1339
1395
|
client;
|
|
1340
1396
|
handlers;
|
|
1341
1397
|
tools;
|
|
1342
|
-
|
|
1398
|
+
ownedTools;
|
|
1399
|
+
constructor(client, id, handlers, tools, ownedTools) {
|
|
1343
1400
|
this.client = client;
|
|
1344
1401
|
this.id = id;
|
|
1345
1402
|
this.handlers = handlers;
|
|
1346
1403
|
this.tools = tools ?? [];
|
|
1404
|
+
this.ownedTools = ownedTools ?? this.tools;
|
|
1347
1405
|
}
|
|
1348
1406
|
async send(promptOrMessages, opts = {}) {
|
|
1349
1407
|
const created = await this.client.request({
|
|
@@ -1404,19 +1462,6 @@ var AgentSession = class {
|
|
|
1404
1462
|
}
|
|
1405
1463
|
return body;
|
|
1406
1464
|
}
|
|
1407
|
-
/**
|
|
1408
|
-
* Plan-only session turn. Sugar for `send(prompt, { plan: planOnly(...) })`.
|
|
1409
|
-
*/
|
|
1410
|
-
async runPlan(promptOrMessages, opts = {}) {
|
|
1411
|
-
const { steps, brief, ...rest } = opts;
|
|
1412
|
-
return this.send(promptOrMessages, {
|
|
1413
|
-
...rest,
|
|
1414
|
-
plan: planOnly({
|
|
1415
|
-
...steps !== void 0 ? { steps } : {},
|
|
1416
|
-
...brief !== void 0 ? { brief } : {}
|
|
1417
|
-
})
|
|
1418
|
-
});
|
|
1419
|
-
}
|
|
1420
1465
|
async history() {
|
|
1421
1466
|
const info = await this.client.getSessionInfo(this.id);
|
|
1422
1467
|
return info.messages;
|
|
@@ -1434,7 +1479,7 @@ var AgentSession = class {
|
|
|
1434
1479
|
try {
|
|
1435
1480
|
await this.client.endSession(this.id);
|
|
1436
1481
|
} finally {
|
|
1437
|
-
await closeMcpRefs(this.
|
|
1482
|
+
await closeMcpRefs(this.ownedTools);
|
|
1438
1483
|
}
|
|
1439
1484
|
}
|
|
1440
1485
|
};
|
|
@@ -1489,6 +1534,15 @@ function serializeAgentSpec(spec, extra = {}) {
|
|
|
1489
1534
|
if (spec.fallbackModelId) body.fallbackModelId = spec.fallbackModelId;
|
|
1490
1535
|
if (spec.openRouterProvider !== void 0) body.openRouterProvider = spec.openRouterProvider;
|
|
1491
1536
|
if (spec.newLoop !== void 0) body.newLoop = spec.newLoop;
|
|
1537
|
+
if (spec.toolSearch !== void 0) {
|
|
1538
|
+
if (typeof spec.toolSearch !== "boolean") {
|
|
1539
|
+
throw new MantyxError(`toolSearch must be a boolean, got ${JSON.stringify(spec.toolSearch)}`);
|
|
1540
|
+
}
|
|
1541
|
+
body.toolSearch = spec.toolSearch;
|
|
1542
|
+
}
|
|
1543
|
+
if (spec.toolNamespaces !== void 0) {
|
|
1544
|
+
body.toolNamespaces = normalizeToolNamespaces(spec.toolNamespaces);
|
|
1545
|
+
}
|
|
1492
1546
|
if (spec.reasoningLevel !== void 0) {
|
|
1493
1547
|
body.reasoningLevel = normalizeReasoningLevel(spec.reasoningLevel);
|
|
1494
1548
|
}
|
|
@@ -1504,6 +1558,9 @@ function serializeAgentSpec(spec, extra = {}) {
|
|
|
1504
1558
|
if (spec.supervisor !== void 0) {
|
|
1505
1559
|
body.supervisor = normalizeSupervisor(spec.supervisor);
|
|
1506
1560
|
}
|
|
1561
|
+
if (spec.subagents !== void 0) {
|
|
1562
|
+
body.subagents = normalizeSubagents(spec.subagents);
|
|
1563
|
+
}
|
|
1507
1564
|
if (spec.plan !== void 0) {
|
|
1508
1565
|
body.plan = normalizePlan(spec.plan);
|
|
1509
1566
|
}
|
|
@@ -1512,6 +1569,32 @@ function serializeAgentSpec(spec, extra = {}) {
|
|
|
1512
1569
|
Object.assign(body, serializeTurnInput(extra));
|
|
1513
1570
|
return body;
|
|
1514
1571
|
}
|
|
1572
|
+
var MAX_TOOL_NAMESPACES = 64;
|
|
1573
|
+
var MAX_TOOL_NAMESPACE_DESCRIPTION = 2e3;
|
|
1574
|
+
function normalizeToolNamespaces(value) {
|
|
1575
|
+
if (!Array.isArray(value)) {
|
|
1576
|
+
throw new MantyxError(`toolNamespaces must be an array, got ${JSON.stringify(value)}`);
|
|
1577
|
+
}
|
|
1578
|
+
if (value.length > MAX_TOOL_NAMESPACES) {
|
|
1579
|
+
throw new MantyxError(`toolNamespaces accepts at most ${MAX_TOOL_NAMESPACES} entries, got ${value.length}`);
|
|
1580
|
+
}
|
|
1581
|
+
return value.map((ns, i) => {
|
|
1582
|
+
if (!ns || typeof ns !== "object") {
|
|
1583
|
+
throw new MantyxError(`toolNamespaces[${i}] must be an object, got ${JSON.stringify(ns)}`);
|
|
1584
|
+
}
|
|
1585
|
+
try {
|
|
1586
|
+
assertToolNamespace(ns.name, `toolNamespaces[${i}].name`);
|
|
1587
|
+
} catch (err) {
|
|
1588
|
+
throw new MantyxError(err.message);
|
|
1589
|
+
}
|
|
1590
|
+
if (typeof ns.description !== "string" || ns.description.length < 1 || ns.description.length > MAX_TOOL_NAMESPACE_DESCRIPTION) {
|
|
1591
|
+
throw new MantyxError(
|
|
1592
|
+
`toolNamespaces[${i}].description must be a string of 1-${MAX_TOOL_NAMESPACE_DESCRIPTION} characters`
|
|
1593
|
+
);
|
|
1594
|
+
}
|
|
1595
|
+
return { name: ns.name, description: ns.description };
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1515
1598
|
function serializeToolRefs(tools) {
|
|
1516
1599
|
return tools.map((t) => {
|
|
1517
1600
|
switch (t.kind) {
|
|
@@ -1524,7 +1607,8 @@ function serializeToolRefs(tools) {
|
|
|
1524
1607
|
...t.outputSchema !== void 0 ? { outputSchema: toToolParametersWire(t.outputSchema) } : {},
|
|
1525
1608
|
...t.longRunning ? { longRunning: true } : {},
|
|
1526
1609
|
...t.readOnly ? { readOnly: true } : {},
|
|
1527
|
-
...t.retain ? { retain: true } : {}
|
|
1610
|
+
...t.retain ? { retain: true } : {},
|
|
1611
|
+
...toolGroupingWire(t)
|
|
1528
1612
|
};
|
|
1529
1613
|
case "a2a":
|
|
1530
1614
|
return {
|
|
@@ -1533,7 +1617,8 @@ function serializeToolRefs(tools) {
|
|
|
1533
1617
|
...t.description !== void 0 ? { description: t.description } : {},
|
|
1534
1618
|
agentCardUrl: t.agentCardUrl,
|
|
1535
1619
|
...t.headers ? { headers: { ...t.headers } } : {},
|
|
1536
|
-
...t.contextId ? { contextId: t.contextId } : {}
|
|
1620
|
+
...t.contextId ? { contextId: t.contextId } : {},
|
|
1621
|
+
...toolGroupingWire(t)
|
|
1537
1622
|
};
|
|
1538
1623
|
case "a2a_local": {
|
|
1539
1624
|
const card = t._resolvedCard;
|
|
@@ -1548,7 +1633,8 @@ function serializeToolRefs(tools) {
|
|
|
1548
1633
|
// The wire ships the resolved A2A Agent Card. Shallow-clone so
|
|
1549
1634
|
// consumers can mutate the input later without affecting the
|
|
1550
1635
|
// wire payload.
|
|
1551
|
-
agentCard: { ...card }
|
|
1636
|
+
agentCard: { ...card },
|
|
1637
|
+
...toolGroupingWire(t)
|
|
1552
1638
|
};
|
|
1553
1639
|
}
|
|
1554
1640
|
case "mcp":
|
|
@@ -1557,7 +1643,8 @@ function serializeToolRefs(tools) {
|
|
|
1557
1643
|
name: t.name,
|
|
1558
1644
|
url: t.url,
|
|
1559
1645
|
...t.headers ? { headers: { ...t.headers } } : {},
|
|
1560
|
-
...t.toolFilter ? { toolFilter: [...t.toolFilter] } : {}
|
|
1646
|
+
...t.toolFilter ? { toolFilter: [...t.toolFilter] } : {},
|
|
1647
|
+
...toolGroupingWire(t)
|
|
1561
1648
|
};
|
|
1562
1649
|
case "mcp_local": {
|
|
1563
1650
|
const resolved = t._resolved;
|
|
@@ -1579,7 +1666,8 @@ function serializeToolRefs(tools) {
|
|
|
1579
1666
|
kind: "mcp_local",
|
|
1580
1667
|
name: t.name,
|
|
1581
1668
|
serverInfo: { ...resolved.serverInfo },
|
|
1582
|
-
tools: tools2
|
|
1669
|
+
tools: tools2,
|
|
1670
|
+
...toolGroupingWire(t)
|
|
1583
1671
|
};
|
|
1584
1672
|
}
|
|
1585
1673
|
}
|
|
@@ -1772,6 +1860,157 @@ function normalizeSupervisor(value) {
|
|
|
1772
1860
|
}
|
|
1773
1861
|
return out;
|
|
1774
1862
|
}
|
|
1863
|
+
var SUBAGENTS_MAX_PER_RUN = 50;
|
|
1864
|
+
var SUBAGENTS_MAX_CONCURRENT = 20;
|
|
1865
|
+
var SUBAGENTS_MAX_TOOL_TURNS = 200;
|
|
1866
|
+
var SUBAGENTS_MODEL_ID_MAX = 200;
|
|
1867
|
+
var SUBAGENTS_TOOL_NAME_MAX = 128;
|
|
1868
|
+
var SUBAGENTS_INSTRUCTIONS_MAX = 8e3;
|
|
1869
|
+
var SUBAGENTS_MAX_DEFINITIONS = 20;
|
|
1870
|
+
var SUBAGENT_NAME_RE = /^[a-zA-Z0-9_-]{1,64}$/;
|
|
1871
|
+
var SUBAGENT_DESCRIPTION_MAX = 1e3;
|
|
1872
|
+
var SUBAGENT_SYSTEM_PROMPT_MAX = 64e3;
|
|
1873
|
+
function isPlainObject(value) {
|
|
1874
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1875
|
+
}
|
|
1876
|
+
function subagentModelId(label, value) {
|
|
1877
|
+
const modelId = typeof value === "string" ? value.trim() : value;
|
|
1878
|
+
if (typeof modelId !== "string" || modelId.length < 1 || modelId.length > SUBAGENTS_MODEL_ID_MAX) {
|
|
1879
|
+
throw new MantyxError(
|
|
1880
|
+
`${label} must be a 1..${SUBAGENTS_MODEL_ID_MAX}-char string, got ${JSON.stringify(value)}`
|
|
1881
|
+
);
|
|
1882
|
+
}
|
|
1883
|
+
return modelId;
|
|
1884
|
+
}
|
|
1885
|
+
function subagentToolName(label, value) {
|
|
1886
|
+
if (typeof value !== "string" || value.length < 1 || value.length > SUBAGENTS_TOOL_NAME_MAX) {
|
|
1887
|
+
throw new MantyxError(
|
|
1888
|
+
`${label} must be a 1..${SUBAGENTS_TOOL_NAME_MAX}-char tool name, got ${JSON.stringify(value)}`
|
|
1889
|
+
);
|
|
1890
|
+
}
|
|
1891
|
+
return value;
|
|
1892
|
+
}
|
|
1893
|
+
function normalizeSubagentSelf(value) {
|
|
1894
|
+
if (value === true || value === false) return value;
|
|
1895
|
+
if (!isPlainObject(value)) {
|
|
1896
|
+
throw new MantyxError(`subagents.self must be a boolean or an object, got ${JSON.stringify(value)}`);
|
|
1897
|
+
}
|
|
1898
|
+
const out = {};
|
|
1899
|
+
if (value.modelId !== void 0) out.modelId = subagentModelId("subagents.self.modelId", value.modelId);
|
|
1900
|
+
if (value.reasoningLevel !== void 0) out.reasoningLevel = normalizeReasoningLevel(value.reasoningLevel);
|
|
1901
|
+
if (value.maxToolTurns !== void 0) {
|
|
1902
|
+
out.maxToolTurns = assertThreshold("subagents.self.maxToolTurns", value.maxToolTurns, 1, SUBAGENTS_MAX_TOOL_TURNS);
|
|
1903
|
+
}
|
|
1904
|
+
if (value.tools !== void 0) {
|
|
1905
|
+
if (!Array.isArray(value.tools)) {
|
|
1906
|
+
throw new MantyxError(`subagents.self.tools must be an array of tool names, got ${JSON.stringify(value.tools)}`);
|
|
1907
|
+
}
|
|
1908
|
+
out.tools = value.tools.map((t, i) => subagentToolName(`subagents.self.tools[${i}]`, t));
|
|
1909
|
+
}
|
|
1910
|
+
if (value.instructions !== void 0) {
|
|
1911
|
+
if (typeof value.instructions !== "string" || value.instructions.length > SUBAGENTS_INSTRUCTIONS_MAX) {
|
|
1912
|
+
throw new MantyxError(`subagents.self.instructions must be a string of at most ${SUBAGENTS_INSTRUCTIONS_MAX} chars`);
|
|
1913
|
+
}
|
|
1914
|
+
out.instructions = value.instructions;
|
|
1915
|
+
}
|
|
1916
|
+
return out;
|
|
1917
|
+
}
|
|
1918
|
+
function normalizeSubagentDefinition(value, index) {
|
|
1919
|
+
const label = `subagents.agents[${index}]`;
|
|
1920
|
+
if (!isPlainObject(value)) {
|
|
1921
|
+
throw new MantyxError(`${label} must be an object, got ${JSON.stringify(value)}`);
|
|
1922
|
+
}
|
|
1923
|
+
if (typeof value.name !== "string" || !SUBAGENT_NAME_RE.test(value.name) || value.name.toLowerCase() === "self") {
|
|
1924
|
+
throw new MantyxError(
|
|
1925
|
+
`${label}.name must match /^[a-zA-Z0-9_-]{1,64}$/ and not be "self", got ${JSON.stringify(value.name)}`
|
|
1926
|
+
);
|
|
1927
|
+
}
|
|
1928
|
+
const description = typeof value.description === "string" ? value.description.trim() : "";
|
|
1929
|
+
if (description.length < 1 || description.length > SUBAGENT_DESCRIPTION_MAX) {
|
|
1930
|
+
throw new MantyxError(`${label}.description must be a 1..${SUBAGENT_DESCRIPTION_MAX}-char string`);
|
|
1931
|
+
}
|
|
1932
|
+
if (typeof value.systemPrompt !== "string" || value.systemPrompt.length < 1 || value.systemPrompt.length > SUBAGENT_SYSTEM_PROMPT_MAX) {
|
|
1933
|
+
throw new MantyxError(`${label}.systemPrompt must be a 1..${SUBAGENT_SYSTEM_PROMPT_MAX}-char string`);
|
|
1934
|
+
}
|
|
1935
|
+
const out = {
|
|
1936
|
+
name: value.name,
|
|
1937
|
+
description: value.description,
|
|
1938
|
+
systemPrompt: value.systemPrompt
|
|
1939
|
+
};
|
|
1940
|
+
if (value.modelId !== void 0) out.modelId = subagentModelId(`${label}.modelId`, value.modelId);
|
|
1941
|
+
if (value.fallbackModelId !== void 0) {
|
|
1942
|
+
out.fallbackModelId = subagentModelId(`${label}.fallbackModelId`, value.fallbackModelId);
|
|
1943
|
+
}
|
|
1944
|
+
if (value.reasoningLevel !== void 0) out.reasoningLevel = normalizeReasoningLevel(value.reasoningLevel);
|
|
1945
|
+
if (value.tools !== void 0) {
|
|
1946
|
+
if (!Array.isArray(value.tools)) {
|
|
1947
|
+
throw new MantyxError(`${label}.tools must be an array, got ${JSON.stringify(value.tools)}`);
|
|
1948
|
+
}
|
|
1949
|
+
out.tools = value.tools.map(
|
|
1950
|
+
(t, i) => typeof t === "string" ? subagentToolName(`${label}.tools[${i}]`, t) : serializeToolRefs([t])[0]
|
|
1951
|
+
);
|
|
1952
|
+
}
|
|
1953
|
+
if (value.budgets !== void 0) {
|
|
1954
|
+
if (!isPlainObject(value.budgets)) {
|
|
1955
|
+
throw new MantyxError(`${label}.budgets must be an object { maxToolTurns? }`);
|
|
1956
|
+
}
|
|
1957
|
+
const budgets = {};
|
|
1958
|
+
if (value.budgets.maxToolTurns !== void 0) {
|
|
1959
|
+
budgets.maxToolTurns = assertThreshold(
|
|
1960
|
+
`${label}.budgets.maxToolTurns`,
|
|
1961
|
+
value.budgets.maxToolTurns,
|
|
1962
|
+
1,
|
|
1963
|
+
SUBAGENTS_MAX_TOOL_TURNS
|
|
1964
|
+
);
|
|
1965
|
+
}
|
|
1966
|
+
out.budgets = budgets;
|
|
1967
|
+
}
|
|
1968
|
+
if (value.toolBudgets !== void 0) out.toolBudgets = normalizeToolBudgets(value.toolBudgets);
|
|
1969
|
+
if (value.outputSchema !== void 0) out.outputSchema = normalizeOutputSchema(value.outputSchema);
|
|
1970
|
+
return out;
|
|
1971
|
+
}
|
|
1972
|
+
function normalizeSubagents(value) {
|
|
1973
|
+
if (value === true || value === false) return value;
|
|
1974
|
+
if (!isPlainObject(value)) {
|
|
1975
|
+
throw new MantyxError(`subagents must be a boolean or an object, got ${JSON.stringify(value)}`);
|
|
1976
|
+
}
|
|
1977
|
+
const out = {};
|
|
1978
|
+
if (value.self !== void 0) out.self = normalizeSubagentSelf(value.self);
|
|
1979
|
+
if (value.agents !== void 0) {
|
|
1980
|
+
if (!Array.isArray(value.agents) || value.agents.length > SUBAGENTS_MAX_DEFINITIONS) {
|
|
1981
|
+
throw new MantyxError(`subagents.agents must be an array of at most ${SUBAGENTS_MAX_DEFINITIONS} definitions`);
|
|
1982
|
+
}
|
|
1983
|
+
const names = /* @__PURE__ */ new Set();
|
|
1984
|
+
out.agents = value.agents.map((a, i) => {
|
|
1985
|
+
const wire = normalizeSubagentDefinition(a, i);
|
|
1986
|
+
if (names.has(wire.name)) {
|
|
1987
|
+
throw new MantyxError(`subagents.agents: duplicate name ${JSON.stringify(wire.name)}`);
|
|
1988
|
+
}
|
|
1989
|
+
names.add(wire.name);
|
|
1990
|
+
return wire;
|
|
1991
|
+
});
|
|
1992
|
+
}
|
|
1993
|
+
if (value.maxPerRun !== void 0) {
|
|
1994
|
+
out.maxPerRun = assertThreshold("subagents.maxPerRun", value.maxPerRun, 1, SUBAGENTS_MAX_PER_RUN);
|
|
1995
|
+
}
|
|
1996
|
+
if (value.maxConcurrent !== void 0) {
|
|
1997
|
+
out.maxConcurrent = assertThreshold("subagents.maxConcurrent", value.maxConcurrent, 1, SUBAGENTS_MAX_CONCURRENT);
|
|
1998
|
+
}
|
|
1999
|
+
return out;
|
|
2000
|
+
}
|
|
2001
|
+
function toolsWithSubagentTools(tools, subagents) {
|
|
2002
|
+
if (!isPlainObject(subagents) || !Array.isArray(subagents.agents)) return tools;
|
|
2003
|
+
const all = [...tools];
|
|
2004
|
+
const seen = new Set(tools);
|
|
2005
|
+
for (const agent of subagents.agents) {
|
|
2006
|
+
for (const t of agent?.tools ?? []) {
|
|
2007
|
+
if (typeof t === "string" || seen.has(t)) continue;
|
|
2008
|
+
seen.add(t);
|
|
2009
|
+
all.push(t);
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
return all;
|
|
2013
|
+
}
|
|
1775
2014
|
var PLAN_MODES = /* @__PURE__ */ new Set(["off", "auto", "required"]);
|
|
1776
2015
|
var TASK_PLAN_STEP_STATUSES = /* @__PURE__ */ new Set([
|
|
1777
2016
|
"pending",
|
|
@@ -1800,18 +2039,15 @@ function normalizePlan(value) {
|
|
|
1800
2039
|
if (typeof value === "string") return assertPlanMode("plan", value);
|
|
1801
2040
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
1802
2041
|
throw new MantyxError(
|
|
1803
|
-
`plan must be "off", "auto", "required", \`true\`, \`false\`, or an object { mode?,
|
|
2042
|
+
`plan must be "off", "auto", "required", \`true\`, \`false\`, or an object { mode?, brief?, steps? }, got ${JSON.stringify(value)}`
|
|
1804
2043
|
);
|
|
1805
2044
|
}
|
|
1806
2045
|
const out = {};
|
|
1807
2046
|
if (value.mode !== void 0) {
|
|
1808
2047
|
out.mode = assertPlanMode("plan.mode", value.mode);
|
|
1809
2048
|
}
|
|
1810
|
-
if (value.planOnly
|
|
1811
|
-
|
|
1812
|
-
throw new MantyxError(`plan.planOnly must be a boolean, got ${JSON.stringify(value.planOnly)}`);
|
|
1813
|
-
}
|
|
1814
|
-
out.planOnly = value.planOnly;
|
|
2049
|
+
if (value.planOnly === true) {
|
|
2050
|
+
throw new MantyxError("plan.planOnly: plan-only runs are no longer supported");
|
|
1815
2051
|
}
|
|
1816
2052
|
if (value.brief !== void 0) {
|
|
1817
2053
|
if (typeof value.brief !== "string") {
|
|
@@ -2611,7 +2847,7 @@ async function runComputerUse(opts) {
|
|
|
2611
2847
|
}
|
|
2612
2848
|
|
|
2613
2849
|
// src/version.ts
|
|
2614
|
-
var SDK_VERSION = "2026.11.
|
|
2850
|
+
var SDK_VERSION = "2026.11.13";
|
|
2615
2851
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2616
2852
|
0 && (module.exports = {
|
|
2617
2853
|
AgentSession,
|
|
@@ -2645,7 +2881,6 @@ var SDK_VERSION = "2026.11.11";
|
|
|
2645
2881
|
mantyxA2A,
|
|
2646
2882
|
mantyxMcp,
|
|
2647
2883
|
parseRunOutput,
|
|
2648
|
-
planOnly,
|
|
2649
2884
|
readSseStream,
|
|
2650
2885
|
runComputerUse,
|
|
2651
2886
|
taskPlanFromEventData,
|
package/dist/index.d.ts
CHANGED
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
* console.log(result.text);
|
|
35
35
|
*/
|
|
36
36
|
export type { DecisionContent, DecisionQuestion, DecisionRequest, DecisionAnswer, DecisionResult, DecisionModelInfo, DecisionRunSummary, DecisionRunDetail, DecisionRunList } from "./decisions.js";
|
|
37
|
-
export { MantyxClient, AgentSession, DEFAULT_BASE_URL, parseRunOutput,
|
|
38
|
-
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, ToolInteraction, ServerToolResultEvent, LocalToolCallEvent, LocalToolResultInEvent, LoopDetectedEvent, ToolBudgetExceededEvent, SupervisorEvent, TaskPlanEvent, ResultEvent, ErrorEvent, CancelledEvent, SessionInfo, SessionSummary, SessionListResult, SessionEventsPage, LocalHandlers, RunFeedbackVerdict, TurnInstructionsAuthority, RunFeedbackInput, RunFeedbackResult, } from "./client.js";
|
|
37
|
+
export { MantyxClient, AgentSession, DEFAULT_BASE_URL, parseRunOutput, taskPlanFromEventData, inputFileAttachment, inputFileUrlAttachment, } from "./client.js";
|
|
38
|
+
export type { MantyxClientOptions, ModelInfo, ModelCatalog, AgentSpecBase, RunSpec, SessionSpec, ToolNamespace, OutputSchema, OutputSchemaValue, LoopDetection, ToolBudget, ToolBudgets, Supervisor, SupervisorAction, SupervisorPhase, ReasoningTrigger, Subagents, SubagentSelf, SubagentDefinition, SubagentStatus, PlanOptions, PlanMode, PlanSpec, TaskPlan, TaskPlanStep, TaskPlanStepStatus, TaskPlanTransition, RunResult, RunTokenUsage, RunModelInfo, RunEvent, RunEventBase, AssistantDeltaEvent, ThinkingDeltaEvent, AssistantMessageEvent, ModelFallbackEvent, UserMessageEvent, InputFileAttachment, InputFileUrlAttachment, MessageAttachment, InputFileAttachmentMetadata, InputFileUrlAttachmentMetadata, AttachmentMetadata, ConversationMessage, ToolInteraction, ServerToolResultEvent, LocalToolCallEvent, LocalToolResultInEvent, LoopDetectedEvent, ToolBudgetExceededEvent, SupervisorEvent, SubagentStartedEvent, SubagentResultEvent, TaskPlanEvent, ResultEvent, ErrorEvent, CancelledEvent, SessionInfo, SessionSummary, SessionListResult, SessionEventsPage, RunStatus, RunInfo, RunSummary, RunListResult, ListRunsOptions, LocalHandlers, RunFeedbackVerdict, TurnInstructionsAuthority, RunFeedbackInput, RunFeedbackResult, } from "./client.js";
|
|
39
39
|
export { defineLocalTool, mantyxA2A, defineLocalA2A, mantyxMcp, defineLocalMcp, isLocalTool, isLocalA2ATool, isLocalMcpServer, } from "./tools.js";
|
|
40
|
-
export type { LocalTool, LocalToolResult, LocalToolOutput, ToolResultFile, ToolRef, ZodLikeObject, DefineLocalToolOptions, ReasoningLevel, A2AToolRef, LocalA2ATool, McpToolRef, LocalMcpServer, LocalMcpHttpTransport, LocalMcpStdioTransport, MantyxA2AOptions, DefineLocalA2AOptions, MantyxMcpOptions, DefineLocalMcpOptions, } from "./tools.js";
|
|
40
|
+
export type { LocalTool, LocalToolResult, LocalToolOutput, ToolResultFile, ToolRef, ZodLikeObject, DefineLocalToolOptions, ReasoningLevel, A2AToolRef, LocalA2ATool, McpToolRef, LocalMcpServer, LocalMcpHttpTransport, LocalMcpStdioTransport, MantyxA2AOptions, DefineLocalA2AOptions, MantyxMcpOptions, DefineLocalMcpOptions, ToolGrouping, ToolGroupingOptions, } from "./tools.js";
|
|
41
41
|
export { MantyxError, MantyxAuthError, MantyxNetworkError, MantyxParseError, MantyxScopeError, MantyxToolError, MantyxRunError, } from "./errors.js";
|
|
42
42
|
export type { MantyxRunErrorInit, MantyxRunErrorTokens, MantyxRunErrorModel, } from "./errors.js";
|
|
43
43
|
export type { OutputSchemaEnforcement, StructuredOutputEnforcementMechanism, StructuredOutputInfo, } from "./structured-output.js";
|
package/dist/index.js
CHANGED
|
@@ -20,12 +20,11 @@ import {
|
|
|
20
20
|
mantyxA2A,
|
|
21
21
|
mantyxMcp,
|
|
22
22
|
parseRunOutput,
|
|
23
|
-
planOnly,
|
|
24
23
|
readSseStream,
|
|
25
24
|
taskPlanFromEventData,
|
|
26
25
|
toToolParametersWire,
|
|
27
26
|
zodToJsonSchema
|
|
28
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-EXTS5Q3T.js";
|
|
29
28
|
|
|
30
29
|
// src/oauth.ts
|
|
31
30
|
var DEFAULT_OAUTH_BASE_URL = "https://app.mantyx.io";
|
|
@@ -602,7 +601,7 @@ async function runComputerUse(opts) {
|
|
|
602
601
|
}
|
|
603
602
|
|
|
604
603
|
// src/version.ts
|
|
605
|
-
var SDK_VERSION = "2026.11.
|
|
604
|
+
var SDK_VERSION = "2026.11.13";
|
|
606
605
|
export {
|
|
607
606
|
AgentSession,
|
|
608
607
|
COMPUTER_USE_ACTIONS,
|
|
@@ -635,7 +634,6 @@ export {
|
|
|
635
634
|
mantyxA2A,
|
|
636
635
|
mantyxMcp,
|
|
637
636
|
parseRunOutput,
|
|
638
|
-
planOnly,
|
|
639
637
|
readSseStream,
|
|
640
638
|
runComputerUse,
|
|
641
639
|
taskPlanFromEventData,
|