@mantyx/sdk 2026.11.6 → 2026.11.7
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 +23 -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 +1 -1
- package/dist/index.cjs +3 -201
- package/dist/index.d.ts +4 -4
- 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 +92 -169
- package/docs/wire-protocol.md +37 -65
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -112,178 +112,6 @@ export interface RunFeedbackResult {
|
|
|
112
112
|
targetKind: string;
|
|
113
113
|
agentRunId: string;
|
|
114
114
|
}
|
|
115
|
-
/** Terminal statuses for {@link EvalRunDetail} and {@link EvalRunSummary}. */
|
|
116
|
-
export type EvalRunStatus = "queued" | "running" | "succeeded" | "failed" | "cancelled";
|
|
117
|
-
/** One case in an inline eval dataset (`POST /eval-runs` `dataset`). */
|
|
118
|
-
export interface InlineEvalCaseSpec {
|
|
119
|
-
name?: string;
|
|
120
|
-
input: {
|
|
121
|
-
role?: "user";
|
|
122
|
-
content: string;
|
|
123
|
-
expected?: string | null;
|
|
124
|
-
};
|
|
125
|
-
scorers?: Record<string, unknown>[];
|
|
126
|
-
toolMocks?: Record<string, unknown>;
|
|
127
|
-
tags?: string[];
|
|
128
|
-
}
|
|
129
|
-
/** Inline eval dataset blob (`POST /eval-runs` `dataset`). */
|
|
130
|
-
export interface InlineEvalDatasetSpec {
|
|
131
|
-
name?: string;
|
|
132
|
-
toolMocks?: Record<string, unknown>;
|
|
133
|
-
cases: InlineEvalCaseSpec[];
|
|
134
|
-
}
|
|
135
|
-
/** Saved-agent overrides on `POST /eval-runs` (ignored for inline `agent`). */
|
|
136
|
-
export interface AgentEvalOverrides {
|
|
137
|
-
systemPrompt?: string;
|
|
138
|
-
systemPromptAppend?: string;
|
|
139
|
-
model?: string;
|
|
140
|
-
llmProviderId?: string;
|
|
141
|
-
reasoningLevel?: "low" | "medium" | "high";
|
|
142
|
-
disableTools?: boolean;
|
|
143
|
-
toolAllowlist?: string[];
|
|
144
|
-
disabledMocks?: string[];
|
|
145
|
-
}
|
|
146
|
-
/** Body for `POST /eval-runs`. Exactly one of `datasetId`/`dataset` and `agentId`/`agent`. */
|
|
147
|
-
export interface CreateEvalRunRequest {
|
|
148
|
-
datasetId?: string;
|
|
149
|
-
dataset?: InlineEvalDatasetSpec;
|
|
150
|
-
agentId?: string;
|
|
151
|
-
agent?: AgentSpecBase;
|
|
152
|
-
/** Client-resolved tools merged onto a saved `agentId` eval run. */
|
|
153
|
-
tools?: ToolRef[];
|
|
154
|
-
modelId?: string;
|
|
155
|
-
overrides?: AgentEvalOverrides;
|
|
156
|
-
}
|
|
157
|
-
export interface EvalDatasetSummary {
|
|
158
|
-
id: string;
|
|
159
|
-
name: string;
|
|
160
|
-
description: string | null;
|
|
161
|
-
caseCount: number;
|
|
162
|
-
runCount: number;
|
|
163
|
-
createdAt: string;
|
|
164
|
-
updatedAt: string;
|
|
165
|
-
}
|
|
166
|
-
export interface EvalDatasetList {
|
|
167
|
-
datasets: EvalDatasetSummary[];
|
|
168
|
-
}
|
|
169
|
-
export interface EvalCase {
|
|
170
|
-
id: string;
|
|
171
|
-
name: string;
|
|
172
|
-
input: Record<string, unknown>;
|
|
173
|
-
scorers: Record<string, unknown>[];
|
|
174
|
-
tags: string[];
|
|
175
|
-
toolMocks: Record<string, unknown> | null;
|
|
176
|
-
createdAt: string;
|
|
177
|
-
updatedAt: string;
|
|
178
|
-
}
|
|
179
|
-
export interface EvalDatasetDetail {
|
|
180
|
-
id: string;
|
|
181
|
-
name: string;
|
|
182
|
-
description: string | null;
|
|
183
|
-
toolMocks: Record<string, unknown> | null;
|
|
184
|
-
cases: EvalCase[];
|
|
185
|
-
createdAt: string;
|
|
186
|
-
updatedAt: string;
|
|
187
|
-
}
|
|
188
|
-
export interface EvalRunAccepted {
|
|
189
|
-
runId: string;
|
|
190
|
-
status: string;
|
|
191
|
-
streamUrl: string;
|
|
192
|
-
}
|
|
193
|
-
export interface EvalRunSummary {
|
|
194
|
-
id: string;
|
|
195
|
-
datasetId: string;
|
|
196
|
-
datasetName: string;
|
|
197
|
-
agentId: string | null;
|
|
198
|
-
inlineAgent: boolean;
|
|
199
|
-
status: EvalRunStatus;
|
|
200
|
-
totalCases: number;
|
|
201
|
-
completedCases: number;
|
|
202
|
-
passedCases: number;
|
|
203
|
-
score: number | null;
|
|
204
|
-
tokenUsage: Record<string, unknown> | null;
|
|
205
|
-
error: string | null;
|
|
206
|
-
agentOverrides: Record<string, unknown> | null;
|
|
207
|
-
startedAt: string | null;
|
|
208
|
-
finishedAt: string | null;
|
|
209
|
-
createdAt: string;
|
|
210
|
-
}
|
|
211
|
-
export interface EvalCaseResult {
|
|
212
|
-
id: string;
|
|
213
|
-
caseId: string;
|
|
214
|
-
case: EvalCase;
|
|
215
|
-
finalText: string | null;
|
|
216
|
-
toolCalls: Record<string, unknown>[];
|
|
217
|
-
scores: Record<string, unknown>[];
|
|
218
|
-
passed: boolean;
|
|
219
|
-
score: number;
|
|
220
|
-
tokens: Record<string, unknown> | null;
|
|
221
|
-
latencyMs: number | null;
|
|
222
|
-
error: string | null;
|
|
223
|
-
createdAt: string;
|
|
224
|
-
}
|
|
225
|
-
export interface EvalRunDetail extends EvalRunSummary {
|
|
226
|
-
inlineAgentSpec: Record<string, unknown> | null;
|
|
227
|
-
agentSpecSnapshot: Record<string, unknown> | null;
|
|
228
|
-
updatedAt: string;
|
|
229
|
-
results: EvalCaseResult[];
|
|
230
|
-
}
|
|
231
|
-
export interface EvalRunList {
|
|
232
|
-
runs: EvalRunSummary[];
|
|
233
|
-
limit: number;
|
|
234
|
-
offset: number;
|
|
235
|
-
}
|
|
236
|
-
export interface EvalRunCompareSide {
|
|
237
|
-
id: string;
|
|
238
|
-
agentId: string | null;
|
|
239
|
-
inlineAgent: boolean;
|
|
240
|
-
status: string;
|
|
241
|
-
totalCases: number;
|
|
242
|
-
completedCases: number;
|
|
243
|
-
passedCases: number;
|
|
244
|
-
score: number | null;
|
|
245
|
-
tokenUsage: Record<string, unknown> | null;
|
|
246
|
-
agentOverrides: Record<string, unknown> | null;
|
|
247
|
-
agentSpecSnapshot: Record<string, unknown> | null;
|
|
248
|
-
startedAt: string | null;
|
|
249
|
-
finishedAt: string | null;
|
|
250
|
-
createdAt: string;
|
|
251
|
-
}
|
|
252
|
-
export interface EvalRunCompareCase {
|
|
253
|
-
caseId: string;
|
|
254
|
-
caseName: string;
|
|
255
|
-
caseInput: Record<string, unknown> | null;
|
|
256
|
-
a: Record<string, unknown> | null;
|
|
257
|
-
b: Record<string, unknown> | null;
|
|
258
|
-
}
|
|
259
|
-
export interface EvalRunCompare {
|
|
260
|
-
datasetId: string;
|
|
261
|
-
datasetName: string;
|
|
262
|
-
runA: EvalRunCompareSide;
|
|
263
|
-
runB: EvalRunCompareSide;
|
|
264
|
-
cases: EvalRunCompareCase[];
|
|
265
|
-
}
|
|
266
|
-
/** One SSE frame from `GET /eval-runs/:runId/stream`. */
|
|
267
|
-
export interface EvalRunEvent {
|
|
268
|
-
type: string;
|
|
269
|
-
[key: string]: unknown;
|
|
270
|
-
}
|
|
271
|
-
export interface ListEvalRunsOptions {
|
|
272
|
-
datasetId?: string;
|
|
273
|
-
agentId?: string;
|
|
274
|
-
status?: EvalRunStatus | string;
|
|
275
|
-
limit?: number;
|
|
276
|
-
offset?: number;
|
|
277
|
-
}
|
|
278
|
-
export interface RunEvalOptions {
|
|
279
|
-
/** Client-resolved tools to register for the eval run. */
|
|
280
|
-
tools?: ToolRef[];
|
|
281
|
-
/** Called for each SSE frame while the run is in flight. */
|
|
282
|
-
onEvent?: (event: EvalRunEvent) => void;
|
|
283
|
-
/** Poll interval when SSE is unavailable or ends early. Default 1000ms. */
|
|
284
|
-
pollIntervalMs?: number;
|
|
285
|
-
signal?: AbortSignal;
|
|
286
|
-
}
|
|
287
115
|
export interface MantyxClientOptions {
|
|
288
116
|
/**
|
|
289
117
|
* Workspace API key (token prefix `mantyx_`) **or** a MANTYX OAuth 2.0
|
|
@@ -317,7 +145,7 @@ export interface MantyxClientOptions {
|
|
|
317
145
|
*
|
|
318
146
|
* OAuth tokens additionally enforce per-route **scopes**
|
|
319
147
|
* (`runs:read`, `runs:write`, `sessions:read`, `sessions:write`,
|
|
320
|
-
* `models:read`, `feedback:write`,
|
|
148
|
+
* `models:read`, `feedback:write`,
|
|
321
149
|
* `mantyx.identity:read`); see
|
|
322
150
|
* `docs/agent-runs-protocol.md` §2.2 for the table. Missing scopes
|
|
323
151
|
* land as {@link MantyxScopeError} so callers can route the user
|
|
@@ -372,16 +200,9 @@ export interface ModelCatalog {
|
|
|
372
200
|
export interface AgentSpecBase {
|
|
373
201
|
name?: string;
|
|
374
202
|
/**
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
* (memory, skills, plugin tools, …) from the Agent row at run time, and any
|
|
378
|
-
* `tools` you supply here are merged on top — typically `local` tools the
|
|
379
|
-
* SDK wants the agent to be able to call back into.
|
|
380
|
-
*
|
|
381
|
-
* Either `agentId` or `systemPrompt` must be set.
|
|
203
|
+
* The agent's system prompt. Required unless `messages` carries a
|
|
204
|
+
* non-empty `system` message.
|
|
382
205
|
*/
|
|
383
|
-
agentId?: string;
|
|
384
|
-
/** Required unless `agentId` is set. */
|
|
385
206
|
systemPrompt?: string;
|
|
386
207
|
modelId?: string;
|
|
387
208
|
/** Alternate model for provider outages; remains active for the session after switching. */
|
|
@@ -497,7 +318,7 @@ export interface AgentSpecBase {
|
|
|
497
318
|
/**
|
|
498
319
|
* Flat string→string KV carried alongside the run / session for
|
|
499
320
|
* observability. Use it to tag runs with your own application identifiers
|
|
500
|
-
* (customer id, environment,
|
|
321
|
+
* (customer id, environment, feature name, …) — the values are visible in
|
|
501
322
|
* the MANTYX dashboard and can be filtered there.
|
|
502
323
|
*
|
|
503
324
|
* Limits enforced server-side: max 16 entries; keys match
|
|
@@ -1260,22 +1081,6 @@ export declare class MantyxClient {
|
|
|
1260
1081
|
* the same response body. See `docs/agent-runs-protocol.md` §9a.
|
|
1261
1082
|
*/
|
|
1262
1083
|
submitRunFeedback(runId: string, input: RunFeedbackInput): Promise<RunFeedbackResult>;
|
|
1263
|
-
listEvalDatasets(): Promise<EvalDatasetList>;
|
|
1264
|
-
getEvalDataset(datasetId: string): Promise<EvalDatasetDetail>;
|
|
1265
|
-
createEvalRun(spec: CreateEvalRunRequest): Promise<EvalRunAccepted>;
|
|
1266
|
-
listEvalRuns(options?: ListEvalRunsOptions): Promise<EvalRunList>;
|
|
1267
|
-
compareEvalRuns(runA: string, runB: string): Promise<EvalRunCompare>;
|
|
1268
|
-
getEvalRun(runId: string): Promise<EvalRunDetail>;
|
|
1269
|
-
streamEvalRun(runId: string, signal?: AbortSignal): AsyncGenerator<EvalRunEvent, void, void>;
|
|
1270
|
-
cancelEvalRun(runId: string): Promise<{
|
|
1271
|
-
ok: boolean;
|
|
1272
|
-
}>;
|
|
1273
|
-
/**
|
|
1274
|
-
* Start an eval run and block until it reaches a terminal status.
|
|
1275
|
-
* Tails the SSE stream for live `onEvent` callbacks while polling
|
|
1276
|
-
* `getEvalRun` until `status` is terminal.
|
|
1277
|
-
*/
|
|
1278
|
-
runEval(spec: CreateEvalRunRequest, options?: RunEvalOptions): Promise<EvalRunDetail>;
|
|
1279
1084
|
private absoluteUrl;
|
|
1280
1085
|
/**
|
|
1281
1086
|
* Resolve the bearer credential to send on the next request. With a
|
package/dist/decisions.d.ts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -60,8 +60,6 @@ __export(index_exports, {
|
|
|
60
60
|
isLocalTool: () => isLocalTool,
|
|
61
61
|
mantyxA2A: () => mantyxA2A,
|
|
62
62
|
mantyxMcp: () => mantyxMcp,
|
|
63
|
-
mantyxPluginTool: () => mantyxPluginTool,
|
|
64
|
-
mantyxTool: () => mantyxTool,
|
|
65
63
|
parseRunOutput: () => parseRunOutput,
|
|
66
64
|
planOnly: () => planOnly,
|
|
67
65
|
readSseStream: () => readSseStream,
|
|
@@ -189,20 +187,6 @@ function defineLocalTool(opts) {
|
|
|
189
187
|
execute: opts.execute
|
|
190
188
|
};
|
|
191
189
|
}
|
|
192
|
-
function mantyxTool(id) {
|
|
193
|
-
if (typeof id !== "string" || id.length === 0) {
|
|
194
|
-
throw new Error("mantyxTool(id): id must be a non-empty string");
|
|
195
|
-
}
|
|
196
|
-
return { kind: "mantyx", id };
|
|
197
|
-
}
|
|
198
|
-
function mantyxPluginTool(name) {
|
|
199
|
-
if (typeof name !== "string" || !name.startsWith("@") || !name.includes("/")) {
|
|
200
|
-
throw new Error(
|
|
201
|
-
`mantyxPluginTool(name): expected "@plugin-slug/tool-name", got ${JSON.stringify(name)}`
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
return { kind: "mantyx_plugin", name };
|
|
205
|
-
}
|
|
206
190
|
function mantyxA2A(opts) {
|
|
207
191
|
assertToolName(opts.name);
|
|
208
192
|
if (typeof opts.agentCardUrl !== "string" || opts.agentCardUrl.length === 0) {
|
|
@@ -772,7 +756,6 @@ function inputFileUrlAttachment(opts) {
|
|
|
772
756
|
return { type: "input_file_url", ...opts };
|
|
773
757
|
}
|
|
774
758
|
var RUN_FEEDBACK_EXPLANATION_MAX = 8e3;
|
|
775
|
-
var EVAL_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "failed", "cancelled"]);
|
|
776
759
|
function planOnly(options = {}) {
|
|
777
760
|
return {
|
|
778
761
|
planOnly: true,
|
|
@@ -1227,138 +1210,6 @@ var MantyxClient = class {
|
|
|
1227
1210
|
body
|
|
1228
1211
|
});
|
|
1229
1212
|
}
|
|
1230
|
-
// --------------------------------------------------------------- Evals
|
|
1231
|
-
async listEvalDatasets() {
|
|
1232
|
-
return this.request({
|
|
1233
|
-
method: "GET",
|
|
1234
|
-
path: "/eval-datasets"
|
|
1235
|
-
});
|
|
1236
|
-
}
|
|
1237
|
-
async getEvalDataset(datasetId) {
|
|
1238
|
-
return this.request({
|
|
1239
|
-
method: "GET",
|
|
1240
|
-
path: `/eval-datasets/${encodeURIComponent(datasetId)}`
|
|
1241
|
-
});
|
|
1242
|
-
}
|
|
1243
|
-
async createEvalRun(spec) {
|
|
1244
|
-
const tools = spec.tools ?? [];
|
|
1245
|
-
if (tools.length > 0) {
|
|
1246
|
-
await resolveLocalRefs(tools, { fetch: this.options.fetch });
|
|
1247
|
-
}
|
|
1248
|
-
return this.request({
|
|
1249
|
-
method: "POST",
|
|
1250
|
-
path: "/eval-runs",
|
|
1251
|
-
body: serializeCreateEvalRunRequest(spec)
|
|
1252
|
-
});
|
|
1253
|
-
}
|
|
1254
|
-
async listEvalRuns(options = {}) {
|
|
1255
|
-
const params = new URLSearchParams();
|
|
1256
|
-
if (options.datasetId) params.set("datasetId", options.datasetId);
|
|
1257
|
-
if (options.agentId) params.set("agentId", options.agentId);
|
|
1258
|
-
if (options.status) params.set("status", options.status);
|
|
1259
|
-
if (options.limit !== void 0) params.set("limit", String(options.limit));
|
|
1260
|
-
if (options.offset !== void 0) params.set("offset", String(options.offset));
|
|
1261
|
-
const qs = params.toString();
|
|
1262
|
-
return this.request({
|
|
1263
|
-
method: "GET",
|
|
1264
|
-
path: qs ? `/eval-runs?${qs}` : "/eval-runs"
|
|
1265
|
-
});
|
|
1266
|
-
}
|
|
1267
|
-
async compareEvalRuns(runA, runB) {
|
|
1268
|
-
const params = new URLSearchParams({ a: runA, b: runB });
|
|
1269
|
-
return this.request({
|
|
1270
|
-
method: "GET",
|
|
1271
|
-
path: `/eval-runs/compare?${params}`
|
|
1272
|
-
});
|
|
1273
|
-
}
|
|
1274
|
-
async getEvalRun(runId) {
|
|
1275
|
-
return this.request({
|
|
1276
|
-
method: "GET",
|
|
1277
|
-
path: `/eval-runs/${encodeURIComponent(runId)}`
|
|
1278
|
-
});
|
|
1279
|
-
}
|
|
1280
|
-
async *streamEvalRun(runId, signal) {
|
|
1281
|
-
const url = this.absoluteUrl(`/eval-runs/${encodeURIComponent(runId)}/stream`);
|
|
1282
|
-
const res = await this.openSseStream(url, 0, signal);
|
|
1283
|
-
try {
|
|
1284
|
-
for await (const frame of readSseStream(res.body, { signal })) {
|
|
1285
|
-
if (!frame.data) continue;
|
|
1286
|
-
let parsed;
|
|
1287
|
-
try {
|
|
1288
|
-
parsed = JSON.parse(frame.data);
|
|
1289
|
-
} catch (err) {
|
|
1290
|
-
throw new MantyxParseError(
|
|
1291
|
-
`invalid eval SSE JSON: ${frame.data.slice(0, 200)}`,
|
|
1292
|
-
frame.data,
|
|
1293
|
-
{ cause: err }
|
|
1294
|
-
);
|
|
1295
|
-
}
|
|
1296
|
-
yield parsed;
|
|
1297
|
-
if (parsed.type === "run_completed" || parsed.type === "run_error" || parsed.type === "run_cancelled") {
|
|
1298
|
-
return;
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
} finally {
|
|
1302
|
-
await res.body?.cancel().catch(() => void 0);
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
async cancelEvalRun(runId) {
|
|
1306
|
-
return this.request({
|
|
1307
|
-
method: "POST",
|
|
1308
|
-
path: `/eval-runs/${encodeURIComponent(runId)}/cancel`
|
|
1309
|
-
});
|
|
1310
|
-
}
|
|
1311
|
-
/**
|
|
1312
|
-
* Start an eval run and block until it reaches a terminal status.
|
|
1313
|
-
* Tails the SSE stream for live `onEvent` callbacks while polling
|
|
1314
|
-
* `getEvalRun` until `status` is terminal.
|
|
1315
|
-
*/
|
|
1316
|
-
async runEval(spec, options = {}) {
|
|
1317
|
-
const tools = options.tools ?? spec.tools ?? [];
|
|
1318
|
-
if (tools.length > 0) {
|
|
1319
|
-
await resolveLocalRefs(tools, { fetch: this.options.fetch });
|
|
1320
|
-
}
|
|
1321
|
-
const handlers = collectLocalHandlers(tools);
|
|
1322
|
-
try {
|
|
1323
|
-
const accepted = await this.createEvalRun({
|
|
1324
|
-
...spec,
|
|
1325
|
-
...tools.length > 0 ? { tools } : {}
|
|
1326
|
-
});
|
|
1327
|
-
const pollMs = options.pollIntervalMs ?? 1e3;
|
|
1328
|
-
const streamDone = (async () => {
|
|
1329
|
-
try {
|
|
1330
|
-
for await (const ev of this.streamEvalRun(accepted.runId, options.signal)) {
|
|
1331
|
-
if (ev.type === "local_tool_call" && tools.length > 0) {
|
|
1332
|
-
const record = ev;
|
|
1333
|
-
const nested = typeof record.data === "object" && record.data !== null && !Array.isArray(record.data) ? record.data : void 0;
|
|
1334
|
-
const agentRunId = typeof record.agentRunId === "string" ? record.agentRunId : typeof nested?.agentRunId === "string" ? nested.agentRunId : "";
|
|
1335
|
-
if (agentRunId) {
|
|
1336
|
-
const localEv = evalEventToLocalToolCall(ev);
|
|
1337
|
-
await this.dispatchLocalTool(agentRunId, localEv, handlers);
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
options.onEvent?.(ev);
|
|
1341
|
-
}
|
|
1342
|
-
} catch (err) {
|
|
1343
|
-
if (!(err instanceof MantyxNetworkError)) throw err;
|
|
1344
|
-
}
|
|
1345
|
-
})();
|
|
1346
|
-
try {
|
|
1347
|
-
while (true) {
|
|
1348
|
-
if (options.signal?.aborted) {
|
|
1349
|
-
throw new MantyxNetworkError("eval run wait aborted", { cause: options.signal.reason });
|
|
1350
|
-
}
|
|
1351
|
-
const detail = await this.getEvalRun(accepted.runId);
|
|
1352
|
-
if (EVAL_TERMINAL_STATUSES.has(detail.status)) return detail;
|
|
1353
|
-
await sleep(pollMs);
|
|
1354
|
-
}
|
|
1355
|
-
} finally {
|
|
1356
|
-
await streamDone.catch(() => void 0);
|
|
1357
|
-
}
|
|
1358
|
-
} finally {
|
|
1359
|
-
await closeMcpRefs(tools);
|
|
1360
|
-
}
|
|
1361
|
-
}
|
|
1362
1213
|
// -------------------------------------------------------------- HTTP
|
|
1363
1214
|
absoluteUrl(path) {
|
|
1364
1215
|
return `${this.options.baseUrl}/api/v1/workspaces/${encodeURIComponent(this.options.workspaceSlug)}${path}`;
|
|
@@ -1623,16 +1474,15 @@ function hasNonEmptySystemMessage(messages) {
|
|
|
1623
1474
|
}
|
|
1624
1475
|
function serializeAgentSpec(spec, extra = {}) {
|
|
1625
1476
|
const messagesForIdentity = extra.messages ?? (extra.attachments?.length ? [{ role: "user", content: extra.prompt ?? "", attachments: extra.attachments }] : void 0);
|
|
1626
|
-
if (
|
|
1477
|
+
if ((typeof spec.systemPrompt !== "string" || spec.systemPrompt.length === 0) && !hasNonEmptySystemMessage(messagesForIdentity)) {
|
|
1627
1478
|
throw new MantyxError(
|
|
1628
|
-
"
|
|
1479
|
+
"`systemPrompt` or a non-empty `system` message in `messages` is required"
|
|
1629
1480
|
);
|
|
1630
1481
|
}
|
|
1631
1482
|
const body = {
|
|
1632
1483
|
tools: serializeToolRefs(spec.tools ?? [])
|
|
1633
1484
|
};
|
|
1634
1485
|
if (typeof spec.systemPrompt === "string") body.systemPrompt = spec.systemPrompt;
|
|
1635
|
-
if (spec.agentId) body.agentId = spec.agentId;
|
|
1636
1486
|
if (spec.name) body.name = spec.name;
|
|
1637
1487
|
if (spec.modelId) body.modelId = spec.modelId;
|
|
1638
1488
|
if (spec.fallbackModelId) body.fallbackModelId = spec.fallbackModelId;
|
|
@@ -1660,55 +1510,9 @@ function serializeAgentSpec(spec, extra = {}) {
|
|
|
1660
1510
|
Object.assign(body, serializeTurnInput(extra));
|
|
1661
1511
|
return body;
|
|
1662
1512
|
}
|
|
1663
|
-
function serializeCreateEvalRunRequest(spec) {
|
|
1664
|
-
const hasDataset = spec.datasetId !== void 0 || spec.dataset !== void 0;
|
|
1665
|
-
const hasAgent = spec.agentId !== void 0 || spec.agent !== void 0;
|
|
1666
|
-
if (!hasDataset) {
|
|
1667
|
-
throw new MantyxError("createEvalRun requires exactly one of `datasetId` or `dataset`");
|
|
1668
|
-
}
|
|
1669
|
-
if (spec.datasetId !== void 0 && spec.dataset !== void 0) {
|
|
1670
|
-
throw new MantyxError("createEvalRun accepts only one of `datasetId` or `dataset`");
|
|
1671
|
-
}
|
|
1672
|
-
if (!hasAgent) {
|
|
1673
|
-
throw new MantyxError("createEvalRun requires exactly one of `agentId` or `agent`");
|
|
1674
|
-
}
|
|
1675
|
-
if (spec.agentId !== void 0 && spec.agent !== void 0) {
|
|
1676
|
-
throw new MantyxError("createEvalRun accepts only one of `agentId` or `agent`");
|
|
1677
|
-
}
|
|
1678
|
-
const body = {};
|
|
1679
|
-
if (spec.datasetId) body.datasetId = spec.datasetId;
|
|
1680
|
-
if (spec.dataset) body.dataset = spec.dataset;
|
|
1681
|
-
if (spec.agentId) body.agentId = spec.agentId;
|
|
1682
|
-
if (spec.agent) body.agent = serializeAgentSpec(spec.agent);
|
|
1683
|
-
if (spec.tools && spec.tools.length > 0 && spec.agentId) {
|
|
1684
|
-
body.tools = serializeToolRefs(spec.tools);
|
|
1685
|
-
}
|
|
1686
|
-
if (spec.modelId) body.modelId = spec.modelId;
|
|
1687
|
-
if (spec.overrides) body.overrides = spec.overrides;
|
|
1688
|
-
return body;
|
|
1689
|
-
}
|
|
1690
|
-
function evalEventToLocalToolCall(ev) {
|
|
1691
|
-
const data = ev.data && typeof ev.data === "object" && !Array.isArray(ev.data) ? ev.data : ev;
|
|
1692
|
-
return {
|
|
1693
|
-
type: "local_tool_call",
|
|
1694
|
-
seq: 0,
|
|
1695
|
-
toolUseId: String(data.toolUseId ?? ""),
|
|
1696
|
-
name: String(data.name ?? ""),
|
|
1697
|
-
args: data.args ?? {},
|
|
1698
|
-
...typeof data.kind === "string" ? { kind: data.kind } : {},
|
|
1699
|
-
...data.agentCard !== void 0 ? { agentCard: data.agentCard } : {},
|
|
1700
|
-
...typeof data.mcpServer === "string" ? { mcpServer: data.mcpServer } : {},
|
|
1701
|
-
...typeof data.mcpToolName === "string" ? { mcpToolName: data.mcpToolName } : {},
|
|
1702
|
-
...data.mcpServerInfo !== void 0 ? { mcpServerInfo: data.mcpServerInfo } : {}
|
|
1703
|
-
};
|
|
1704
|
-
}
|
|
1705
1513
|
function serializeToolRefs(tools) {
|
|
1706
1514
|
return tools.map((t) => {
|
|
1707
1515
|
switch (t.kind) {
|
|
1708
|
-
case "mantyx":
|
|
1709
|
-
return { kind: "mantyx", id: t.id };
|
|
1710
|
-
case "mantyx_plugin":
|
|
1711
|
-
return { kind: "mantyx_plugin", name: t.name };
|
|
1712
1516
|
case "local":
|
|
1713
1517
|
return {
|
|
1714
1518
|
kind: "local",
|
|
@@ -2795,7 +2599,7 @@ async function runComputerUse(opts) {
|
|
|
2795
2599
|
}
|
|
2796
2600
|
|
|
2797
2601
|
// src/version.ts
|
|
2798
|
-
var SDK_VERSION = "2026.11.
|
|
2602
|
+
var SDK_VERSION = "2026.11.7";
|
|
2799
2603
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2800
2604
|
0 && (module.exports = {
|
|
2801
2605
|
AgentSession,
|
|
@@ -2828,8 +2632,6 @@ var SDK_VERSION = "2026.11.6";
|
|
|
2828
2632
|
isLocalTool,
|
|
2829
2633
|
mantyxA2A,
|
|
2830
2634
|
mantyxMcp,
|
|
2831
|
-
mantyxPluginTool,
|
|
2832
|
-
mantyxTool,
|
|
2833
2635
|
parseRunOutput,
|
|
2834
2636
|
planOnly,
|
|
2835
2637
|
readSseStream,
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Public surface:
|
|
5
5
|
*
|
|
6
|
-
* import { MantyxClient, defineLocalTool
|
|
6
|
+
* import { MantyxClient, defineLocalTool } from "@mantyx/sdk";
|
|
7
7
|
*
|
|
8
8
|
* // Workspace API key (token prefix `mantyx_`):
|
|
9
9
|
* const client = new MantyxClient({
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
*/
|
|
36
36
|
export type { DecisionQuestion, DecisionRequest, DecisionAnswer, DecisionResult, DecisionModelInfo, DecisionRunSummary, DecisionRunDetail, DecisionRunList } from "./decisions.js";
|
|
37
37
|
export { MantyxClient, AgentSession, DEFAULT_BASE_URL, parseRunOutput, planOnly, taskPlanFromEventData, inputFileAttachment, inputFileUrlAttachment, } from "./client.js";
|
|
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, ServerToolResultEvent, LocalToolCallEvent, LocalToolResultInEvent, LoopDetectedEvent, ToolBudgetExceededEvent, SupervisorEvent, TaskPlanEvent, ResultEvent, ErrorEvent, CancelledEvent, SessionInfo, SessionSummary, SessionListResult, SessionEventsPage, LocalHandlers, RunFeedbackVerdict, TurnInstructionsAuthority, RunFeedbackInput, RunFeedbackResult,
|
|
39
|
-
export { defineLocalTool,
|
|
40
|
-
export type { LocalTool, LocalToolResult, LocalToolOutput, ToolResultFile,
|
|
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, ServerToolResultEvent, LocalToolCallEvent, LocalToolResultInEvent, LoopDetectedEvent, ToolBudgetExceededEvent, SupervisorEvent, TaskPlanEvent, ResultEvent, ErrorEvent, CancelledEvent, SessionInfo, SessionSummary, SessionListResult, SessionEventsPage, LocalHandlers, RunFeedbackVerdict, TurnInstructionsAuthority, RunFeedbackInput, RunFeedbackResult, } from "./client.js";
|
|
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";
|
|
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
|
@@ -19,15 +19,13 @@ import {
|
|
|
19
19
|
isLocalTool,
|
|
20
20
|
mantyxA2A,
|
|
21
21
|
mantyxMcp,
|
|
22
|
-
mantyxPluginTool,
|
|
23
|
-
mantyxTool,
|
|
24
22
|
parseRunOutput,
|
|
25
23
|
planOnly,
|
|
26
24
|
readSseStream,
|
|
27
25
|
taskPlanFromEventData,
|
|
28
26
|
toToolParametersWire,
|
|
29
27
|
zodToJsonSchema
|
|
30
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-HZGH34UW.js";
|
|
31
29
|
|
|
32
30
|
// src/oauth.ts
|
|
33
31
|
var DEFAULT_OAUTH_BASE_URL = "https://app.mantyx.io";
|
|
@@ -603,7 +601,7 @@ async function runComputerUse(opts) {
|
|
|
603
601
|
}
|
|
604
602
|
|
|
605
603
|
// src/version.ts
|
|
606
|
-
var SDK_VERSION = "2026.11.
|
|
604
|
+
var SDK_VERSION = "2026.11.7";
|
|
607
605
|
export {
|
|
608
606
|
AgentSession,
|
|
609
607
|
COMPUTER_USE_ACTIONS,
|
|
@@ -635,8 +633,6 @@ export {
|
|
|
635
633
|
isLocalTool,
|
|
636
634
|
mantyxA2A,
|
|
637
635
|
mantyxMcp,
|
|
638
|
-
mantyxPluginTool,
|
|
639
|
-
mantyxTool,
|
|
640
636
|
parseRunOutput,
|
|
641
637
|
planOnly,
|
|
642
638
|
readSseStream,
|
package/dist/tools.d.ts
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
* Public tool helpers for the MANTYX SDK.
|
|
3
3
|
*
|
|
4
4
|
* Server-resolved (executed by MANTYX):
|
|
5
|
-
* mantyxTool(id) → existing workspace `Tool` row by id
|
|
6
|
-
* mantyxPluginTool(name) → built-in plugin tool by `@plugin/tool` name
|
|
7
5
|
* mantyxA2A({...}) → remote Agent2Agent peer, dialed by MANTYX
|
|
8
6
|
* mantyxMcp({...}) → remote MCP server (Streamable HTTP), proxied by MANTYX
|
|
9
7
|
*
|
|
@@ -162,16 +160,6 @@ export interface DefineLocalToolOptions<T extends ZodLikeObject | undefined> {
|
|
|
162
160
|
execute: (args: T extends ZodLikeObject ? z.infer<T> : Record<string, unknown>) => Promise<LocalToolOutput> | LocalToolOutput;
|
|
163
161
|
}
|
|
164
162
|
export declare function defineLocalTool<T extends ZodLikeObject | undefined>(opts: DefineLocalToolOptions<T>): LocalTool;
|
|
165
|
-
export interface MantyxToolRef {
|
|
166
|
-
readonly kind: "mantyx";
|
|
167
|
-
readonly id: string;
|
|
168
|
-
}
|
|
169
|
-
export interface MantyxPluginToolRef {
|
|
170
|
-
readonly kind: "mantyx_plugin";
|
|
171
|
-
readonly name: string;
|
|
172
|
-
}
|
|
173
|
-
export declare function mantyxTool(id: string): MantyxToolRef;
|
|
174
|
-
export declare function mantyxPluginTool(name: string): MantyxPluginToolRef;
|
|
175
163
|
/**
|
|
176
164
|
* Reference to a remote Agent2Agent peer reachable from MANTYX (server-resolved).
|
|
177
165
|
* MANTYX dials `agentCardUrl` over A2A's `message/send` RPC and forwards the
|
|
@@ -398,7 +386,7 @@ export interface DefineLocalMcpOptions {
|
|
|
398
386
|
cwd?: string;
|
|
399
387
|
}
|
|
400
388
|
export declare function defineLocalMcp(opts: DefineLocalMcpOptions): LocalMcpServer;
|
|
401
|
-
export type ToolRef =
|
|
389
|
+
export type ToolRef = LocalTool | A2AToolRef | LocalA2ATool | McpToolRef | LocalMcpServer;
|
|
402
390
|
export declare function isLocalTool(t: ToolRef): t is LocalTool;
|
|
403
391
|
export declare function isLocalA2ATool(t: ToolRef): t is LocalA2ATool;
|
|
404
392
|
export declare function isLocalMcpServer(t: ToolRef): t is LocalMcpServer;
|
package/dist/version.d.ts
CHANGED