@mantyx/sdk 2026.11.1 → 2026.11.3
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 +12 -0
- package/dist/a2a-server.cjs +2 -0
- package/dist/a2a-server.d.ts +2 -0
- package/dist/a2a-server.js +3 -1
- package/dist/{chunk-FDIMGXOL.js → chunk-4WXIAVUB.js} +36 -3
- package/dist/client.d.ts +67 -0
- package/dist/index.cjs +37 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -2
- package/dist/version.d.ts +1 -1
- package/docs/agent-runs-protocol.md +148 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,18 @@ and new releases use calendar versions (`YYYY.M.RELEASE`). Historical versions r
|
|
|
11
11
|
|
|
12
12
|
### Added
|
|
13
13
|
|
|
14
|
+
- `turnInstructions` on agent runs and per-message session sends gives the
|
|
15
|
+
model context for one turn only. It is placed ahead of that turn's user
|
|
16
|
+
message, never stored in the session transcript, and never merged into the
|
|
17
|
+
system prompt, so provider prompt caches keep matching across turns.
|
|
18
|
+
|
|
19
|
+
- `turnInstructionsAuthority` (`"developer"` or `"context"`) on agent runs and
|
|
20
|
+
per-message session sends. With `"developer"`, the server default, turn
|
|
21
|
+
instructions go out as an OpenAI `developer` message or an Anthropic
|
|
22
|
+
mid-conversation `system` message where the run's model supports it, which
|
|
23
|
+
providers rank above the user's own text; elsewhere, and with `"context"`,
|
|
24
|
+
they stay ahead of the user message.
|
|
25
|
+
|
|
14
26
|
- Configure a fallback model for ephemeral runs and sessions. MANTYX preserves
|
|
15
27
|
completed tool results during failover and keeps switched sessions on the fallback.
|
|
16
28
|
|
package/dist/a2a-server.cjs
CHANGED
|
@@ -323,6 +323,7 @@ function specForRun(spec) {
|
|
|
323
323
|
if (spec.systemPrompt) out.systemPrompt = spec.systemPrompt;
|
|
324
324
|
if (spec.modelId) out.modelId = spec.modelId;
|
|
325
325
|
if (spec.tools) out.tools = spec.tools;
|
|
326
|
+
if (spec.openRouterProvider !== void 0) out.openRouterProvider = spec.openRouterProvider;
|
|
326
327
|
if (spec.reasoningLevel !== void 0) out.reasoningLevel = spec.reasoningLevel;
|
|
327
328
|
if (spec.outputSchema !== void 0) out.outputSchema = spec.outputSchema;
|
|
328
329
|
if (spec.metadata) out.metadata = spec.metadata;
|
|
@@ -336,6 +337,7 @@ function specForSession(spec, contextId) {
|
|
|
336
337
|
if (spec.systemPrompt) out.systemPrompt = spec.systemPrompt;
|
|
337
338
|
if (spec.modelId) out.modelId = spec.modelId;
|
|
338
339
|
if (spec.tools) out.tools = spec.tools;
|
|
340
|
+
if (spec.openRouterProvider !== void 0) out.openRouterProvider = spec.openRouterProvider;
|
|
339
341
|
if (spec.reasoningLevel !== void 0) out.reasoningLevel = spec.reasoningLevel;
|
|
340
342
|
if (spec.outputSchema !== void 0) out.outputSchema = spec.outputSchema;
|
|
341
343
|
const meta = { ...spec.metadata ?? {} };
|
package/dist/a2a-server.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { OpenRouterProviderPreferences } from "./client.js";
|
|
1
2
|
/**
|
|
2
3
|
* Expose a MANTYX agent over the [Agent2Agent (A2A)](https://google-a2a.github.io/A2A/)
|
|
3
4
|
* protocol so other agents can talk to it as a peer.
|
|
@@ -59,6 +60,7 @@ export interface MantyxAgentSpec {
|
|
|
59
60
|
modelId?: string;
|
|
60
61
|
tools?: ToolRef[];
|
|
61
62
|
reasoningLevel?: ReasoningLevel;
|
|
63
|
+
openRouterProvider?: OpenRouterProviderPreferences;
|
|
62
64
|
/**
|
|
63
65
|
* Constrains the model's final assistant text to a JSON document matching
|
|
64
66
|
* a JSON Schema (or Zod schema, auto-converted). See
|
package/dist/a2a-server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MantyxError,
|
|
3
3
|
MantyxRunError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4WXIAVUB.js";
|
|
5
5
|
|
|
6
6
|
// src/a2a-server.ts
|
|
7
7
|
import {
|
|
@@ -239,6 +239,7 @@ function specForRun(spec) {
|
|
|
239
239
|
if (spec.systemPrompt) out.systemPrompt = spec.systemPrompt;
|
|
240
240
|
if (spec.modelId) out.modelId = spec.modelId;
|
|
241
241
|
if (spec.tools) out.tools = spec.tools;
|
|
242
|
+
if (spec.openRouterProvider !== void 0) out.openRouterProvider = spec.openRouterProvider;
|
|
242
243
|
if (spec.reasoningLevel !== void 0) out.reasoningLevel = spec.reasoningLevel;
|
|
243
244
|
if (spec.outputSchema !== void 0) out.outputSchema = spec.outputSchema;
|
|
244
245
|
if (spec.metadata) out.metadata = spec.metadata;
|
|
@@ -252,6 +253,7 @@ function specForSession(spec, contextId) {
|
|
|
252
253
|
if (spec.systemPrompt) out.systemPrompt = spec.systemPrompt;
|
|
253
254
|
if (spec.modelId) out.modelId = spec.modelId;
|
|
254
255
|
if (spec.tools) out.tools = spec.tools;
|
|
256
|
+
if (spec.openRouterProvider !== void 0) out.openRouterProvider = spec.openRouterProvider;
|
|
255
257
|
if (spec.reasoningLevel !== void 0) out.reasoningLevel = spec.reasoningLevel;
|
|
256
258
|
if (spec.outputSchema !== void 0) out.outputSchema = spec.outputSchema;
|
|
257
259
|
const meta = { ...spec.metadata ?? {} };
|
|
@@ -777,7 +777,9 @@ var MantyxClient = class {
|
|
|
777
777
|
body: serializeAgentSpec(spec, {
|
|
778
778
|
prompt: spec.prompt,
|
|
779
779
|
messages: spec.messages,
|
|
780
|
-
attachments: spec.attachments
|
|
780
|
+
attachments: spec.attachments,
|
|
781
|
+
turnInstructions: spec.turnInstructions,
|
|
782
|
+
turnInstructionsAuthority: spec.turnInstructionsAuthority
|
|
781
783
|
})
|
|
782
784
|
});
|
|
783
785
|
return await this.driveRun(created.runId, handlers, {
|
|
@@ -818,7 +820,9 @@ var MantyxClient = class {
|
|
|
818
820
|
body: serializeAgentSpec(spec, {
|
|
819
821
|
prompt: spec.prompt,
|
|
820
822
|
messages: spec.messages,
|
|
821
|
-
attachments: spec.attachments
|
|
823
|
+
attachments: spec.attachments,
|
|
824
|
+
turnInstructions: spec.turnInstructions,
|
|
825
|
+
turnInstructionsAuthority: spec.turnInstructionsAuthority
|
|
822
826
|
})
|
|
823
827
|
});
|
|
824
828
|
yield* this.streamRunEvents(created.runId, handlers, spec.signal);
|
|
@@ -1437,13 +1441,23 @@ var AgentSession = class {
|
|
|
1437
1441
|
}
|
|
1438
1442
|
buildSessionMessageBody(promptOrMessages, opts) {
|
|
1439
1443
|
const body = serializeTurnInput(
|
|
1440
|
-
typeof promptOrMessages === "string" ? {
|
|
1444
|
+
typeof promptOrMessages === "string" ? {
|
|
1445
|
+
prompt: promptOrMessages,
|
|
1446
|
+
attachments: opts.attachments,
|
|
1447
|
+
turnInstructions: opts.turnInstructions,
|
|
1448
|
+
turnInstructionsAuthority: opts.turnInstructionsAuthority
|
|
1449
|
+
} : {
|
|
1450
|
+
messages: promptOrMessages,
|
|
1451
|
+
turnInstructions: opts.turnInstructions,
|
|
1452
|
+
turnInstructionsAuthority: opts.turnInstructionsAuthority
|
|
1453
|
+
}
|
|
1441
1454
|
);
|
|
1442
1455
|
if (!("prompt" in body) && !("messages" in body)) {
|
|
1443
1456
|
throw new MantyxError("Either `prompt` or `messages` is required");
|
|
1444
1457
|
}
|
|
1445
1458
|
if (this.tools.length > 0) body.tools = serializeToolRefs(this.tools);
|
|
1446
1459
|
if (opts.metadata && Object.keys(opts.metadata).length > 0) body.metadata = opts.metadata;
|
|
1460
|
+
if (opts.openRouterProvider !== void 0) body.openRouterProvider = opts.openRouterProvider;
|
|
1447
1461
|
if (opts.reasoningLevel !== void 0) {
|
|
1448
1462
|
body.reasoningLevel = normalizeReasoningLevel(opts.reasoningLevel);
|
|
1449
1463
|
}
|
|
@@ -1499,6 +1513,24 @@ var AgentSession = class {
|
|
|
1499
1513
|
}
|
|
1500
1514
|
};
|
|
1501
1515
|
function serializeTurnInput(input) {
|
|
1516
|
+
const body = serializeTurnMessages(input);
|
|
1517
|
+
if (input.turnInstructions !== void 0) {
|
|
1518
|
+
if (typeof input.turnInstructions !== "string") {
|
|
1519
|
+
throw new MantyxError("`turnInstructions` must be a string");
|
|
1520
|
+
}
|
|
1521
|
+
body.turnInstructions = input.turnInstructions;
|
|
1522
|
+
}
|
|
1523
|
+
if (input.turnInstructionsAuthority !== void 0) {
|
|
1524
|
+
if (input.turnInstructionsAuthority !== "developer" && input.turnInstructionsAuthority !== "context") {
|
|
1525
|
+
throw new MantyxError(
|
|
1526
|
+
'`turnInstructionsAuthority` must be "developer" or "context"'
|
|
1527
|
+
);
|
|
1528
|
+
}
|
|
1529
|
+
body.turnInstructionsAuthority = input.turnInstructionsAuthority;
|
|
1530
|
+
}
|
|
1531
|
+
return body;
|
|
1532
|
+
}
|
|
1533
|
+
function serializeTurnMessages(input) {
|
|
1502
1534
|
if (input.messages !== void 0) {
|
|
1503
1535
|
return { messages: input.messages };
|
|
1504
1536
|
}
|
|
@@ -1530,6 +1562,7 @@ function serializeAgentSpec(spec, extra = {}) {
|
|
|
1530
1562
|
if (spec.name) body.name = spec.name;
|
|
1531
1563
|
if (spec.modelId) body.modelId = spec.modelId;
|
|
1532
1564
|
if (spec.fallbackModelId) body.fallbackModelId = spec.fallbackModelId;
|
|
1565
|
+
if (spec.openRouterProvider !== void 0) body.openRouterProvider = spec.openRouterProvider;
|
|
1533
1566
|
if (spec.reasoningLevel !== void 0) {
|
|
1534
1567
|
body.reasoningLevel = normalizeReasoningLevel(spec.reasoningLevel);
|
|
1535
1568
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
/** OpenRouter provider-routing wire preferences (snake_case). */
|
|
2
|
+
export interface OpenRouterProviderPreferences {
|
|
3
|
+
order?: string[] | null;
|
|
4
|
+
allow_fallbacks?: boolean | null;
|
|
5
|
+
require_parameters?: boolean | null;
|
|
6
|
+
data_collection?: "allow" | "deny" | null;
|
|
7
|
+
zdr?: boolean | null;
|
|
8
|
+
enforce_distillable_text?: boolean | null;
|
|
9
|
+
only?: string[] | null;
|
|
10
|
+
ignore?: string[] | null;
|
|
11
|
+
quantizations?: ("int4" | "int8" | "fp4" | "mxfp4" | "nvfp4" | "fp6" | "fp8" | "mxfp8" | "fp16" | "bf16" | "fp32" | "unknown")[] | null;
|
|
12
|
+
sort?: "price" | "throughput" | "latency" | "exacto" | {
|
|
13
|
+
by?: "price" | "throughput" | "latency" | "exacto" | null;
|
|
14
|
+
partition?: "model" | "none" | null;
|
|
15
|
+
} | null;
|
|
16
|
+
preferred_min_throughput?: number | {
|
|
17
|
+
p50?: number;
|
|
18
|
+
p75?: number;
|
|
19
|
+
p90?: number;
|
|
20
|
+
p99?: number;
|
|
21
|
+
} | null;
|
|
22
|
+
preferred_max_latency?: number | {
|
|
23
|
+
p50?: number;
|
|
24
|
+
p75?: number;
|
|
25
|
+
p90?: number;
|
|
26
|
+
p99?: number;
|
|
27
|
+
} | null;
|
|
28
|
+
max_price?: {
|
|
29
|
+
prompt?: number | string;
|
|
30
|
+
completion?: number | string;
|
|
31
|
+
image?: number | string;
|
|
32
|
+
audio?: number | string;
|
|
33
|
+
request?: number | string;
|
|
34
|
+
} | null;
|
|
35
|
+
}
|
|
1
36
|
import type { TokenSource } from "./oauth.js";
|
|
2
37
|
import type { OutputSchemaEnforcement, StructuredOutputInfo } from "./structured-output.js";
|
|
3
38
|
import type { LocalA2ATool, LocalMcpServer, LocalTool, LocalToolSchemaInput, ReasoningLevel, ToolRef, ToolResultFile } from "./tools.js";
|
|
@@ -54,6 +89,14 @@ export declare function inputFileUrlAttachment(opts: {
|
|
|
54
89
|
}): InputFileUrlAttachment;
|
|
55
90
|
/** Thumbs up/down verdict for {@link MantyxClient.submitRunFeedback}. */
|
|
56
91
|
export type RunFeedbackVerdict = "UP" | "DOWN";
|
|
92
|
+
/**
|
|
93
|
+
* Authority for `turnInstructions` (their lifetime is always one run):
|
|
94
|
+
* `"developer"` (server default) sends them as an operator-authority message
|
|
95
|
+
* where the run's provider and model support it, else ahead of the user text;
|
|
96
|
+
* `"context"` always places them ahead of the user text. See
|
|
97
|
+
* `docs/agent-runs-protocol.md` §4.0.3.
|
|
98
|
+
*/
|
|
99
|
+
export type TurnInstructionsAuthority = "developer" | "context";
|
|
57
100
|
/** Body for `POST /agent-runs/:runId/feedback`. See §9a. */
|
|
58
101
|
export interface RunFeedbackInput {
|
|
59
102
|
verdict: RunFeedbackVerdict;
|
|
@@ -354,6 +397,7 @@ export interface AgentSpecBase {
|
|
|
354
397
|
* overrides on `session.send` apply to that single run.
|
|
355
398
|
*/
|
|
356
399
|
reasoningLevel?: ReasoningLevel;
|
|
400
|
+
openRouterProvider?: OpenRouterProviderPreferences;
|
|
357
401
|
budgets?: {
|
|
358
402
|
maxToolTurns?: number;
|
|
359
403
|
};
|
|
@@ -473,6 +517,15 @@ export interface RunSpec extends AgentSpecBase {
|
|
|
473
517
|
* §4.0.1.
|
|
474
518
|
*/
|
|
475
519
|
attachments?: MessageAttachment[];
|
|
520
|
+
/**
|
|
521
|
+
* Context the model sees ahead of the last `user` message, for this run
|
|
522
|
+
* only. Not merged into the system prompt, so the system prompt stays
|
|
523
|
+
* byte-stable for provider prompt caching. See
|
|
524
|
+
* `docs/agent-runs-protocol.md` §4.0.3.
|
|
525
|
+
*/
|
|
526
|
+
turnInstructions?: string;
|
|
527
|
+
/** Authority for {@link RunSpec.turnInstructions}; the server defaults to `"developer"`. */
|
|
528
|
+
turnInstructionsAuthority?: TurnInstructionsAuthority;
|
|
476
529
|
/** Receives streaming assistant text deltas. */
|
|
477
530
|
onAssistantDelta?: (delta: string) => void;
|
|
478
531
|
/** Receives raw events (assistant_message, local_tool_call, tool_result, ...) for advanced consumers. */
|
|
@@ -1283,6 +1336,7 @@ export declare class AgentSession {
|
|
|
1283
1336
|
* and does not mutate the session's stored value.
|
|
1284
1337
|
*/
|
|
1285
1338
|
reasoningLevel?: ReasoningLevel;
|
|
1339
|
+
openRouterProvider?: OpenRouterProviderPreferences;
|
|
1286
1340
|
/**
|
|
1287
1341
|
* Per-message override for `outputSchema`. Applies only to this run
|
|
1288
1342
|
* and does not mutate the session's stored value.
|
|
@@ -1310,17 +1364,29 @@ export declare class AgentSession {
|
|
|
1310
1364
|
* not mutate the session's stored value. See {@link AgentSpecBase.plan}.
|
|
1311
1365
|
*/
|
|
1312
1366
|
plan?: PlanSpec;
|
|
1367
|
+
/**
|
|
1368
|
+
* Context the model sees ahead of this message's user text, for this
|
|
1369
|
+
* run only. It is not stored in the session transcript (later turns
|
|
1370
|
+
* never replay it) and not merged into the system prompt. See
|
|
1371
|
+
* `docs/agent-runs-protocol.md` §4.0.3.
|
|
1372
|
+
*/
|
|
1373
|
+
turnInstructions?: string;
|
|
1374
|
+
/** Authority for `turnInstructions`; the server defaults to `"developer"`. */
|
|
1375
|
+
turnInstructionsAuthority?: TurnInstructionsAuthority;
|
|
1313
1376
|
}): Promise<RunResult>;
|
|
1314
1377
|
stream(promptOrMessages: string | ConversationMessage[], opts?: {
|
|
1315
1378
|
signal?: AbortSignal;
|
|
1316
1379
|
attachments?: MessageAttachment[];
|
|
1317
1380
|
metadata?: Record<string, string>;
|
|
1318
1381
|
reasoningLevel?: ReasoningLevel;
|
|
1382
|
+
openRouterProvider?: OpenRouterProviderPreferences;
|
|
1319
1383
|
outputSchema?: OutputSchema;
|
|
1320
1384
|
loopDetection?: LoopDetection | false;
|
|
1321
1385
|
toolBudgets?: ToolBudgets;
|
|
1322
1386
|
supervisor?: Supervisor | false;
|
|
1323
1387
|
plan?: PlanSpec;
|
|
1388
|
+
turnInstructions?: string;
|
|
1389
|
+
turnInstructionsAuthority?: TurnInstructionsAuthority;
|
|
1324
1390
|
}): AsyncGenerator<RunEvent, void, void>;
|
|
1325
1391
|
private buildSessionMessageBody;
|
|
1326
1392
|
/**
|
|
@@ -1331,6 +1397,7 @@ export declare class AgentSession {
|
|
|
1331
1397
|
signal?: AbortSignal;
|
|
1332
1398
|
metadata?: Record<string, string>;
|
|
1333
1399
|
reasoningLevel?: ReasoningLevel;
|
|
1400
|
+
openRouterProvider?: OpenRouterProviderPreferences;
|
|
1334
1401
|
outputSchema?: OutputSchema;
|
|
1335
1402
|
loopDetection?: LoopDetection | false;
|
|
1336
1403
|
toolBudgets?: ToolBudgets;
|
package/dist/index.cjs
CHANGED
|
@@ -851,7 +851,9 @@ var MantyxClient = class {
|
|
|
851
851
|
body: serializeAgentSpec(spec, {
|
|
852
852
|
prompt: spec.prompt,
|
|
853
853
|
messages: spec.messages,
|
|
854
|
-
attachments: spec.attachments
|
|
854
|
+
attachments: spec.attachments,
|
|
855
|
+
turnInstructions: spec.turnInstructions,
|
|
856
|
+
turnInstructionsAuthority: spec.turnInstructionsAuthority
|
|
855
857
|
})
|
|
856
858
|
});
|
|
857
859
|
return await this.driveRun(created.runId, handlers, {
|
|
@@ -892,7 +894,9 @@ var MantyxClient = class {
|
|
|
892
894
|
body: serializeAgentSpec(spec, {
|
|
893
895
|
prompt: spec.prompt,
|
|
894
896
|
messages: spec.messages,
|
|
895
|
-
attachments: spec.attachments
|
|
897
|
+
attachments: spec.attachments,
|
|
898
|
+
turnInstructions: spec.turnInstructions,
|
|
899
|
+
turnInstructionsAuthority: spec.turnInstructionsAuthority
|
|
896
900
|
})
|
|
897
901
|
});
|
|
898
902
|
yield* this.streamRunEvents(created.runId, handlers, spec.signal);
|
|
@@ -1511,13 +1515,23 @@ var AgentSession = class {
|
|
|
1511
1515
|
}
|
|
1512
1516
|
buildSessionMessageBody(promptOrMessages, opts) {
|
|
1513
1517
|
const body = serializeTurnInput(
|
|
1514
|
-
typeof promptOrMessages === "string" ? {
|
|
1518
|
+
typeof promptOrMessages === "string" ? {
|
|
1519
|
+
prompt: promptOrMessages,
|
|
1520
|
+
attachments: opts.attachments,
|
|
1521
|
+
turnInstructions: opts.turnInstructions,
|
|
1522
|
+
turnInstructionsAuthority: opts.turnInstructionsAuthority
|
|
1523
|
+
} : {
|
|
1524
|
+
messages: promptOrMessages,
|
|
1525
|
+
turnInstructions: opts.turnInstructions,
|
|
1526
|
+
turnInstructionsAuthority: opts.turnInstructionsAuthority
|
|
1527
|
+
}
|
|
1515
1528
|
);
|
|
1516
1529
|
if (!("prompt" in body) && !("messages" in body)) {
|
|
1517
1530
|
throw new MantyxError("Either `prompt` or `messages` is required");
|
|
1518
1531
|
}
|
|
1519
1532
|
if (this.tools.length > 0) body.tools = serializeToolRefs(this.tools);
|
|
1520
1533
|
if (opts.metadata && Object.keys(opts.metadata).length > 0) body.metadata = opts.metadata;
|
|
1534
|
+
if (opts.openRouterProvider !== void 0) body.openRouterProvider = opts.openRouterProvider;
|
|
1521
1535
|
if (opts.reasoningLevel !== void 0) {
|
|
1522
1536
|
body.reasoningLevel = normalizeReasoningLevel(opts.reasoningLevel);
|
|
1523
1537
|
}
|
|
@@ -1573,6 +1587,24 @@ var AgentSession = class {
|
|
|
1573
1587
|
}
|
|
1574
1588
|
};
|
|
1575
1589
|
function serializeTurnInput(input) {
|
|
1590
|
+
const body = serializeTurnMessages(input);
|
|
1591
|
+
if (input.turnInstructions !== void 0) {
|
|
1592
|
+
if (typeof input.turnInstructions !== "string") {
|
|
1593
|
+
throw new MantyxError("`turnInstructions` must be a string");
|
|
1594
|
+
}
|
|
1595
|
+
body.turnInstructions = input.turnInstructions;
|
|
1596
|
+
}
|
|
1597
|
+
if (input.turnInstructionsAuthority !== void 0) {
|
|
1598
|
+
if (input.turnInstructionsAuthority !== "developer" && input.turnInstructionsAuthority !== "context") {
|
|
1599
|
+
throw new MantyxError(
|
|
1600
|
+
'`turnInstructionsAuthority` must be "developer" or "context"'
|
|
1601
|
+
);
|
|
1602
|
+
}
|
|
1603
|
+
body.turnInstructionsAuthority = input.turnInstructionsAuthority;
|
|
1604
|
+
}
|
|
1605
|
+
return body;
|
|
1606
|
+
}
|
|
1607
|
+
function serializeTurnMessages(input) {
|
|
1576
1608
|
if (input.messages !== void 0) {
|
|
1577
1609
|
return { messages: input.messages };
|
|
1578
1610
|
}
|
|
@@ -1604,6 +1636,7 @@ function serializeAgentSpec(spec, extra = {}) {
|
|
|
1604
1636
|
if (spec.name) body.name = spec.name;
|
|
1605
1637
|
if (spec.modelId) body.modelId = spec.modelId;
|
|
1606
1638
|
if (spec.fallbackModelId) body.fallbackModelId = spec.fallbackModelId;
|
|
1639
|
+
if (spec.openRouterProvider !== void 0) body.openRouterProvider = spec.openRouterProvider;
|
|
1607
1640
|
if (spec.reasoningLevel !== void 0) {
|
|
1608
1641
|
body.reasoningLevel = normalizeReasoningLevel(spec.reasoningLevel);
|
|
1609
1642
|
}
|
|
@@ -2762,7 +2795,7 @@ async function runComputerUse(opts) {
|
|
|
2762
2795
|
}
|
|
2763
2796
|
|
|
2764
2797
|
// src/version.ts
|
|
2765
|
-
var SDK_VERSION = "2026.11.
|
|
2798
|
+
var SDK_VERSION = "2026.11.3";
|
|
2766
2799
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2767
2800
|
0 && (module.exports = {
|
|
2768
2801
|
AgentSession,
|
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
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, RunFeedbackInput, RunFeedbackResult, EvalRunStatus, InlineEvalCaseSpec, InlineEvalDatasetSpec, AgentEvalOverrides, CreateEvalRunRequest, EvalDatasetSummary, EvalDatasetList, EvalCase, EvalDatasetDetail, EvalRunAccepted, EvalRunSummary, EvalCaseResult, EvalRunDetail, EvalRunList, EvalRunCompareSide, EvalRunCompareCase, EvalRunCompare, EvalRunEvent, ListEvalRunsOptions, RunEvalOptions, } 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, EvalRunStatus, InlineEvalCaseSpec, InlineEvalDatasetSpec, AgentEvalOverrides, CreateEvalRunRequest, EvalDatasetSummary, EvalDatasetList, EvalCase, EvalDatasetDetail, EvalRunAccepted, EvalRunSummary, EvalCaseResult, EvalRunDetail, EvalRunList, EvalRunCompareSide, EvalRunCompareCase, EvalRunCompare, EvalRunEvent, ListEvalRunsOptions, RunEvalOptions, } from "./client.js";
|
|
39
39
|
export { defineLocalTool, mantyxTool, mantyxPluginTool, mantyxA2A, defineLocalA2A, mantyxMcp, defineLocalMcp, isLocalTool, isLocalA2ATool, isLocalMcpServer, } from "./tools.js";
|
|
40
40
|
export type { LocalTool, LocalToolResult, LocalToolOutput, ToolResultFile, MantyxToolRef, MantyxPluginToolRef, 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";
|
|
@@ -49,3 +49,4 @@ export { zodToJsonSchema, toToolParametersWire } from "./zod-to-json-schema.js";
|
|
|
49
49
|
export { readSseStream } from "./sse.js";
|
|
50
50
|
export type { SseEvent, SseStreamOptions } from "./sse.js";
|
|
51
51
|
export { SDK_VERSION } from "./version.js";
|
|
52
|
+
export type { OpenRouterProviderPreferences } from "./client.js";
|
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
taskPlanFromEventData,
|
|
28
28
|
toToolParametersWire,
|
|
29
29
|
zodToJsonSchema
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-4WXIAVUB.js";
|
|
31
31
|
|
|
32
32
|
// src/oauth.ts
|
|
33
33
|
var DEFAULT_OAUTH_BASE_URL = "https://app.mantyx.io";
|
|
@@ -603,7 +603,7 @@ async function runComputerUse(opts) {
|
|
|
603
603
|
}
|
|
604
604
|
|
|
605
605
|
// src/version.ts
|
|
606
|
-
var SDK_VERSION = "2026.11.
|
|
606
|
+
var SDK_VERSION = "2026.11.3";
|
|
607
607
|
export {
|
|
608
608
|
AgentSession,
|
|
609
609
|
COMPUTER_USE_ACTIONS,
|
package/dist/version.d.ts
CHANGED
|
@@ -491,6 +491,94 @@ non-terminal `model_fallback` SSE event carries `{ errorClass, model,
|
|
|
491
491
|
primaryModelId, fallbackModelId }`. Session details expose each call's actual
|
|
492
492
|
`model`, including failed calls that switched.
|
|
493
493
|
|
|
494
|
+
### 4.0.3 `turnInstructions` (per-turn context that is not stored)
|
|
495
|
+
|
|
496
|
+
Optional string on `POST /agent-runs` and on
|
|
497
|
+
`POST /agent-sessions/:id/messages`. The model sees it for that run only. Use
|
|
498
|
+
it for context that belongs to one turn: retrieved records, a skill or
|
|
499
|
+
playbook body, a reminder or nudge.
|
|
500
|
+
|
|
501
|
+
Where it goes depends on `turnInstructionsAuthority` (optional, same two
|
|
502
|
+
endpoints, this run only) and on the run's provider and model:
|
|
503
|
+
|
|
504
|
+
| `turnInstructionsAuthority` | Provider / model | Sent as (`turnInstructionsPlacement`) |
|
|
505
|
+
| --------------------------- | -------------------------------------------------- | ------------------------------------------------------------------ |
|
|
506
|
+
| `developer` (default) | OpenAI direct, GPT-4o / 4.1 / 5 / 6, o1, o3, o4-mini | a `developer` message right after the user message (`developer_message`) |
|
|
507
|
+
| `developer` (default) | Anthropic direct, models with mid-conversation system messages (Opus 5.5 / 5 / 4.8, Sonnet 5.5, Haiku 5.5, Fable, Mythos) | a `system` message right after the user message (`system_message`) |
|
|
508
|
+
| `developer` (default) | anything else (Gemini, Bedrock, OpenRouter, Grok, OpenAI-compatible, a custom base URL, unlisted models) | text ahead of the user message, separated by a blank line (`user_message`) |
|
|
509
|
+
| `context` | any | text ahead of the user message (`user_message`) |
|
|
510
|
+
|
|
511
|
+
An operator-authority message outranks the user's own text, so a later user
|
|
512
|
+
sentence such as "skip verification" does not override it the way it can
|
|
513
|
+
when both share the user message.
|
|
514
|
+
|
|
515
|
+
The two operator placements differ in how they rank against the agent's own
|
|
516
|
+
system prompt. On Anthropic, a mid-conversation `system` message takes
|
|
517
|
+
precedence over the agent's system prompt for the rest of that run, so with
|
|
518
|
+
the default `developer` authority, turn instructions that conflict with the
|
|
519
|
+
system prompt win. On OpenAI, the `developer` message ranks above the user's
|
|
520
|
+
text but the agent's system prompt (sent as `instructions`) keeps priority.
|
|
521
|
+
Send `turnInstructionsAuthority: "context"` when turn instructions must never
|
|
522
|
+
outrank the agent's system prompt.
|
|
523
|
+
|
|
524
|
+
The `user_message` placement is the same
|
|
525
|
+
request turn instructions produced before `turnInstructionsAuthority`
|
|
526
|
+
existed. The evidence for each provider is kept with the platform source, in
|
|
527
|
+
`docs/turn-instructions-authority.md`.
|
|
528
|
+
|
|
529
|
+
The two older places for per-turn context each have a cost:
|
|
530
|
+
|
|
531
|
+
| Per-turn context sent as | Kept in session history | Changes the system prompt |
|
|
532
|
+
| ------------------------ | ---------------------------- | ------------------------- |
|
|
533
|
+
| part of the user message | yes, replayed on later turns | no |
|
|
534
|
+
| a `system` message | no | yes, every turn |
|
|
535
|
+
| `turnInstructions` | no | no |
|
|
536
|
+
|
|
537
|
+
Text in the user message is stored in the session transcript as sent, so every
|
|
538
|
+
later turn replays guidance that applied only to its own turn. A `system`
|
|
539
|
+
message is merged into the system prompt, so the system prompt differs on every
|
|
540
|
+
turn and provider prompt caches (Gemini implicit caching, Anthropic
|
|
541
|
+
`cache_control` on the system block) stop matching. With `turnInstructions`
|
|
542
|
+
the system prompt, tools and stored transcript stay byte-stable from turn to
|
|
543
|
+
turn. A request repeats the previous request up to the previous turn's user
|
|
544
|
+
message, which was sent with its instructions and is replayed without them, so
|
|
545
|
+
the reusable prefix ends there.
|
|
546
|
+
|
|
547
|
+
```jsonc
|
|
548
|
+
// POST /agent-sessions/ses_abc/messages
|
|
549
|
+
{
|
|
550
|
+
"prompt": "Count the open tickets by owner.",
|
|
551
|
+
"turnInstructions": "Ticket fields: owner, status. Query the tracker; earlier answers may be stale.",
|
|
552
|
+
}
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
Rules:
|
|
556
|
+
|
|
557
|
+
- Max 200,000 characters. Blank (or whitespace-only) instructions are ignored.
|
|
558
|
+
- The session transcript stores the user message exactly as sent, without the
|
|
559
|
+
instructions, so `GET /agent-sessions/:id` and later turns never see them.
|
|
560
|
+
- The supervisor's bounded goal context uses the undecorated conversation,
|
|
561
|
+
excluding turn instructions so they cannot crowd out the user's request.
|
|
562
|
+
- Per run only: `POST /agent-sessions` does not accept it, and a session message
|
|
563
|
+
without it gets none. The run's `agentSpec` (`GET /agent-runs/:id`) shows the
|
|
564
|
+
value it ran with, and once the run starts, `turnInstructionsPlacement`: where
|
|
565
|
+
the model's request put it. If the run fails over to a fallback model, the
|
|
566
|
+
value is updated to the fallback's placement: with `developer` authority a
|
|
567
|
+
fallback with support sends them at operator authority even when the
|
|
568
|
+
primary could not, and a fallback without support gets `user_message`.
|
|
569
|
+
- They stay in effect for the whole run: context compaction that drops or
|
|
570
|
+
summarizes the run's user message keeps the instructions, and they count
|
|
571
|
+
toward the context budget.
|
|
572
|
+
- A run that resumes after an approval or a worker shutdown keeps the
|
|
573
|
+
instructions it started with, in the same placement.
|
|
574
|
+
- File attachments on the user message are unaffected.
|
|
575
|
+
|
|
576
|
+
SDKs: TypeScript `turnInstructions` / `turnInstructionsAuthority` (run spec,
|
|
577
|
+
`session.send` / `session.stream` option), Python `turn_instructions` /
|
|
578
|
+
`turn_instructions_authority`, Go `RunSpec.TurnInstructions` /
|
|
579
|
+
`RunSpec.TurnInstructionsAuthority` and `WithTurnInstructions` /
|
|
580
|
+
`WithTurnInstructionsAuthority`.
|
|
581
|
+
|
|
494
582
|
### 4.1 Triggering a persisted MANTYX agent (`agentId`)
|
|
495
583
|
|
|
496
584
|
Set `agentId` to the `id` of a workspace `Agent` to run that agent instead of
|
|
@@ -777,6 +865,66 @@ For session-scoped runs the inheritance rules are:
|
|
|
777
865
|
per-message override; applies to that one run only and does not mutate
|
|
778
866
|
the session's stored value.
|
|
779
867
|
|
|
868
|
+
### 4.4.1 `openRouterProvider` (OpenRouter provider routing)
|
|
869
|
+
|
|
870
|
+
Run creation accepts an optional `openRouterProvider` JSON object. It uses
|
|
871
|
+
[OpenRouter's provider-routing wire format](https://openrouter.ai/docs/guides/routing/provider-selection),
|
|
872
|
+
including snake_case field names. MANTYX forwards the effective object as
|
|
873
|
+
`provider` on OpenRouter Responses API requests (streaming and non-streaming).
|
|
874
|
+
|
|
875
|
+
```json
|
|
876
|
+
{"openRouterProvider":{"order":["anthropic"],"allow_fallbacks":false}}
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
All top-level fields are optional and nullable (`null` means unset):
|
|
880
|
+
|
|
881
|
+
| Field | Accepted value |
|
|
882
|
+
| --- | --- |
|
|
883
|
+
| `order`, `only`, `ignore` | Arrays of provider slugs, including variant/region suffixes such as `deepinfra/turbo` or `google-vertex/us-east5` |
|
|
884
|
+
| `allow_fallbacks`, `require_parameters`, `zdr`, `enforce_distillable_text` | Boolean |
|
|
885
|
+
| `data_collection` | `"allow"` or `"deny"` |
|
|
886
|
+
| `quantizations` | Array of `int4`, `int8`, `fp4`, `mxfp4`, `nvfp4`, `fp6`, `fp8`, `mxfp8`, `fp16`, `bf16`, `fp32`, `unknown` |
|
|
887
|
+
| `sort` | `"price"`, `"throughput"`, `"latency"`, `"exacto"`, or `{ "by"?: <same enum> or null, "partition"?: "model" or "none" or null }` |
|
|
888
|
+
| `preferred_min_throughput` | Number (tokens/sec), or an object with optional numeric `p50`, `p75`, `p90`, `p99` |
|
|
889
|
+
| `preferred_max_latency` | Number (seconds), or the same percentile object |
|
|
890
|
+
| `max_price` | Object with optional `prompt`, `completion`, `image`, `audio`, `request` prices (USD), each a number or string |
|
|
891
|
+
|
|
892
|
+
Provider create (`POST /api/llm-providers`, including marketplace connections
|
|
893
|
+
and BYOK duplication) accepts `openRouterProvider` as a stored default on the
|
|
894
|
+
workspace provider. Provider update (`PATCH /api/llm-providers/:id`) also accepts
|
|
895
|
+
`null` to clear the default. Provider responses return the object or `null`.
|
|
896
|
+
Changing a stored default requires a workspace admin; a `PATCH` that resubmits
|
|
897
|
+
the stored value unchanged does not.
|
|
898
|
+
|
|
899
|
+
Effective routing is a shallow per-key merge:
|
|
900
|
+
`{ ...providerDefault, ...runOverride }`. Arrays and nested objects in the
|
|
901
|
+
run override replace the corresponding default value entirely. A null field in
|
|
902
|
+
the override removes that inherited key; null fields in stored defaults are
|
|
903
|
+
dropped. Nullable `sort` members are also omitted upstream. An empty object
|
|
904
|
+
preserves defaults; absent or empty effective preferences are omitted from the
|
|
905
|
+
upstream request. The entire run-level `openRouterProvider` object cannot be null.
|
|
906
|
+
|
|
907
|
+
Stored privacy controls are the exception: when the provider default sets
|
|
908
|
+
`data_collection: "deny"` or `zdr: true`, a run, session or message override
|
|
909
|
+
can tighten privacy but cannot loosen or remove those values (a `"allow"`,
|
|
910
|
+
`false` or `null` override is ignored for that key).
|
|
911
|
+
|
|
912
|
+
Sessions accept the same field as a session default. A per-message value on
|
|
913
|
+
`POST /agent-sessions/:id/messages` replaces the session override for that one
|
|
914
|
+
run, without changing the stored session; provider defaults still merge beneath it.
|
|
915
|
+
|
|
916
|
+
Unknown keys (including nested keys) and invalid values return HTTP 400.
|
|
917
|
+
Setting routing on a non-OpenRouter provider, or creating a run whose effective
|
|
918
|
+
model uses another provider, returns HTTP 400 with a clear error before queueing.
|
|
919
|
+
An explicitly configured fallback model must also use OpenRouter when a run
|
|
920
|
+
routing override is present. No routing configuration is stored on platform
|
|
921
|
+
catalog offerings themselves.
|
|
922
|
+
|
|
923
|
+
MANTYX-hosted OpenRouter models are billed at the cost OpenRouter reports for
|
|
924
|
+
each request (`usage.cost`), so a pinned provider or `sort` is billed at what
|
|
925
|
+
it actually cost. The catalog's per-token prices are a reference estimate and
|
|
926
|
+
are used only when OpenRouter does not report a cost.
|
|
927
|
+
|
|
780
928
|
### 4.5 `outputSchema` (structured final reply)
|
|
781
929
|
|
|
782
930
|
`outputSchema` constrains the model's **final assistant text** to a JSON
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mantyx/sdk",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.3",
|
|
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",
|