@mantyx/sdk 0.14.0 → 0.15.1
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 +14 -0
- package/dist/a2a-server.cjs.map +1 -1
- package/dist/a2a-server.d.cts +1 -1
- package/dist/a2a-server.d.ts +1 -1
- package/dist/a2a-server.js +1 -1
- package/dist/{chunk-XENCO3EF.js → chunk-YXTU725K.js} +103 -31
- package/dist/chunk-YXTU725K.js.map +1 -0
- package/dist/{client-Ct6G4TVc.d.cts → client-fu11V4HX.d.cts} +73 -16
- package/dist/{client-Ct6G4TVc.d.ts → client-fu11V4HX.d.ts} +73 -16
- package/dist/index.cjs +105 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/docs/agent-runs-protocol.md +79 -17
- package/docs/wire-protocol.md +56 -21
- package/package.json +1 -1
- package/dist/chunk-XENCO3EF.js.map +0 -1
|
@@ -673,6 +673,56 @@ declare function isLocalA2ATool(t: ToolRef): t is LocalA2ATool;
|
|
|
673
673
|
declare function isLocalMcpServer(t: ToolRef): t is LocalMcpServer;
|
|
674
674
|
|
|
675
675
|
declare const DEFAULT_BASE_URL = "https://app.mantyx.io";
|
|
676
|
+
/** Inline file bytes for a user message (base64, no data-URL prefix). */
|
|
677
|
+
interface InputFileAttachment {
|
|
678
|
+
type: "input_file";
|
|
679
|
+
mimeType: string;
|
|
680
|
+
filename: string;
|
|
681
|
+
data: string;
|
|
682
|
+
}
|
|
683
|
+
/** HTTPS URL the provider fetches as a user-message file input. */
|
|
684
|
+
interface InputFileUrlAttachment {
|
|
685
|
+
type: "input_file_url";
|
|
686
|
+
url: string;
|
|
687
|
+
mimeType?: string;
|
|
688
|
+
filename?: string;
|
|
689
|
+
}
|
|
690
|
+
/** File input attached to a user message on `POST /agent-runs` or session turns. */
|
|
691
|
+
type MessageAttachment = InputFileAttachment | InputFileUrlAttachment;
|
|
692
|
+
/** Metadata for an inline file on replay-only `user_message` frames (no bytes). */
|
|
693
|
+
interface InputFileAttachmentMetadata {
|
|
694
|
+
type: "input_file";
|
|
695
|
+
mimeType: string;
|
|
696
|
+
filename: string;
|
|
697
|
+
size: number;
|
|
698
|
+
}
|
|
699
|
+
/** Metadata for a URL file on replay-only `user_message` frames. */
|
|
700
|
+
interface InputFileUrlAttachmentMetadata {
|
|
701
|
+
type: "input_file_url";
|
|
702
|
+
url: string;
|
|
703
|
+
mimeType?: string;
|
|
704
|
+
filename?: string;
|
|
705
|
+
}
|
|
706
|
+
/** Attachment metadata on session-event `user_message` replay frames. */
|
|
707
|
+
type AttachmentMetadata = InputFileAttachmentMetadata | InputFileUrlAttachmentMetadata;
|
|
708
|
+
/** One entry in a multi-role `messages` array. */
|
|
709
|
+
interface ConversationMessage {
|
|
710
|
+
role: "user" | "assistant" | "system";
|
|
711
|
+
content: string;
|
|
712
|
+
attachments?: MessageAttachment[];
|
|
713
|
+
}
|
|
714
|
+
/** Build an inline file attachment for the last user message in a run. */
|
|
715
|
+
declare function inputFileAttachment(opts: {
|
|
716
|
+
mimeType: string;
|
|
717
|
+
filename: string;
|
|
718
|
+
data: string;
|
|
719
|
+
}): InputFileAttachment;
|
|
720
|
+
/** Build a URL file attachment for the last user message in a run. */
|
|
721
|
+
declare function inputFileUrlAttachment(opts: {
|
|
722
|
+
url: string;
|
|
723
|
+
mimeType?: string;
|
|
724
|
+
filename?: string;
|
|
725
|
+
}): InputFileUrlAttachment;
|
|
676
726
|
interface MantyxClientOptions {
|
|
677
727
|
/**
|
|
678
728
|
* Workspace API key (token prefix `mantyx_`) **or** a MANTYX OAuth 2.0
|
|
@@ -890,10 +940,14 @@ interface AgentSpecBase {
|
|
|
890
940
|
}
|
|
891
941
|
interface RunSpec extends AgentSpecBase {
|
|
892
942
|
prompt?: string;
|
|
893
|
-
messages?:
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
943
|
+
messages?: ConversationMessage[];
|
|
944
|
+
/**
|
|
945
|
+
* Shorthand for a single user turn with file inputs. When `prompt` is set
|
|
946
|
+
* and `messages` is omitted, the SDK builds a one-entry `messages` array.
|
|
947
|
+
* Ignored when `messages` is provided. See `docs/agent-runs-protocol.md`
|
|
948
|
+
* §4.0.1.
|
|
949
|
+
*/
|
|
950
|
+
attachments?: MessageAttachment[];
|
|
897
951
|
/** Receives streaming assistant text deltas. */
|
|
898
952
|
onAssistantDelta?: (delta: string) => void;
|
|
899
953
|
/** Receives raw events (assistant_message, local_tool_call, tool_result, ...) for advanced consumers. */
|
|
@@ -1374,6 +1428,8 @@ interface CancelledEvent extends RunEventBase {
|
|
|
1374
1428
|
interface UserMessageEvent extends RunEventBase {
|
|
1375
1429
|
type: "user_message";
|
|
1376
1430
|
text: string;
|
|
1431
|
+
/** Present on session-event replay when the user turn carried file inputs. */
|
|
1432
|
+
attachments?: AttachmentMetadata[];
|
|
1377
1433
|
}
|
|
1378
1434
|
type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | TaskPlanEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
|
|
1379
1435
|
type: string;
|
|
@@ -1387,10 +1443,7 @@ interface SessionInfo {
|
|
|
1387
1443
|
lastUsedAt: string;
|
|
1388
1444
|
endedAt: string | null;
|
|
1389
1445
|
agentSpec: AgentSpecBase;
|
|
1390
|
-
messages:
|
|
1391
|
-
role: "user" | "assistant" | "system";
|
|
1392
|
-
content: string;
|
|
1393
|
-
}>;
|
|
1446
|
+
messages: ConversationMessage[];
|
|
1394
1447
|
/** Metadata that was attached to the session at create time, returned for observability. */
|
|
1395
1448
|
metadata: Record<string, string>;
|
|
1396
1449
|
}
|
|
@@ -1547,9 +1600,15 @@ declare class AgentSession {
|
|
|
1547
1600
|
private readonly handlers;
|
|
1548
1601
|
private readonly tools;
|
|
1549
1602
|
constructor(client: MantyxClient, id: string, handlers: LocalHandlers, tools?: ToolRef[]);
|
|
1550
|
-
send(
|
|
1603
|
+
send(promptOrMessages: string | ConversationMessage[], opts?: {
|
|
1551
1604
|
onAssistantDelta?: (s: string) => void;
|
|
1552
1605
|
signal?: AbortSignal;
|
|
1606
|
+
/**
|
|
1607
|
+
* File inputs for a single `prompt` turn. Ignored when the first
|
|
1608
|
+
* argument is a `messages` array. See `docs/agent-runs-protocol.md`
|
|
1609
|
+
* §4.0.1.
|
|
1610
|
+
*/
|
|
1611
|
+
attachments?: MessageAttachment[];
|
|
1553
1612
|
/**
|
|
1554
1613
|
* Per-message metadata override. Server-side this is merged on top of
|
|
1555
1614
|
* the session's metadata at run-creation time (run-level keys win).
|
|
@@ -1589,8 +1648,9 @@ declare class AgentSession {
|
|
|
1589
1648
|
*/
|
|
1590
1649
|
plan?: PlanSpec;
|
|
1591
1650
|
}): Promise<RunResult>;
|
|
1592
|
-
stream(
|
|
1651
|
+
stream(promptOrMessages: string | ConversationMessage[], opts?: {
|
|
1593
1652
|
signal?: AbortSignal;
|
|
1653
|
+
attachments?: MessageAttachment[];
|
|
1594
1654
|
metadata?: Record<string, string>;
|
|
1595
1655
|
reasoningLevel?: ReasoningLevel;
|
|
1596
1656
|
outputSchema?: OutputSchema;
|
|
@@ -1603,7 +1663,7 @@ declare class AgentSession {
|
|
|
1603
1663
|
/**
|
|
1604
1664
|
* Plan-only session turn. Sugar for `send(prompt, { plan: planOnly(...) })`.
|
|
1605
1665
|
*/
|
|
1606
|
-
runPlan(
|
|
1666
|
+
runPlan(promptOrMessages: string | ConversationMessage[], opts?: {
|
|
1607
1667
|
onAssistantDelta?: (s: string) => void;
|
|
1608
1668
|
signal?: AbortSignal;
|
|
1609
1669
|
metadata?: Record<string, string>;
|
|
@@ -1615,10 +1675,7 @@ declare class AgentSession {
|
|
|
1615
1675
|
steps?: string[];
|
|
1616
1676
|
brief?: string;
|
|
1617
1677
|
}): Promise<RunResult>;
|
|
1618
|
-
history(): Promise<
|
|
1619
|
-
role: "user" | "assistant" | "system";
|
|
1620
|
-
content: string;
|
|
1621
|
-
}>>;
|
|
1678
|
+
history(): Promise<ConversationMessage[]>;
|
|
1622
1679
|
info(): Promise<SessionInfo>;
|
|
1623
1680
|
end(): Promise<void>;
|
|
1624
1681
|
}
|
|
@@ -1663,4 +1720,4 @@ interface LocalHandlers {
|
|
|
1663
1720
|
*/
|
|
1664
1721
|
declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
|
|
1665
1722
|
|
|
1666
|
-
export { type
|
|
1723
|
+
export { type ModelCatalog as $, type A2AToolRef as A, MantyxError as B, type CancelledEvent as C, DEFAULT_BASE_URL as D, type ErrorEvent as E, type MantyxMcpOptions as F, MantyxNetworkError as G, MantyxOAuthClient as H, type InputFileAttachment as I, type MantyxOAuthClientOptions as J, MantyxOAuthError as K, type LocalA2ATool as L, MantyxClient as M, MantyxParseError as N, type OutputSchema as O, type MantyxPluginToolRef as P, MantyxRunError as Q, type ReasoningLevel as R, type MantyxRunErrorInit as S, type ToolRef as T, type MantyxRunErrorModel as U, type MantyxRunErrorTokens as V, MantyxScopeError as W, MantyxToolError as X, type MantyxToolRef as Y, type McpToolRef as Z, type MessageAttachment as _, AgentSession as a, type ModelInfo as a0, type OAuthToken as a1, type OutputSchemaValue as a2, type PlanOptions as a3, type PlanSpec as a4, type RefreshOptions as a5, type RefreshTokenSourceOptions as a6, type ResultEvent as a7, type RevokeOptions as a8, type RunEvent as a9, defineLocalMcp as aA, defineLocalTool as aB, inputFileAttachment as aC, inputFileUrlAttachment as aD, isLocalA2ATool as aE, isLocalMcpServer as aF, isLocalTool as aG, mantyxA2A as aH, mantyxMcp as aI, mantyxPluginTool as aJ, mantyxTool as aK, parseRunOutput as aL, planOnly as aM, type RunEventBase as aa, type RunModelInfo as ab, type RunResult as ac, type RunSpec as ad, type RunTokenUsage as ae, type ServerToolResultEvent as af, type SessionInfo as ag, type SessionListResult as ah, type SessionSpec as ai, type SessionSummary as aj, type Supervisor as ak, type SupervisorAction as al, type SupervisorEvent as am, type TaskPlan as an, type TaskPlanEvent as ao, type TaskPlanStep as ap, type TaskPlanStepStatus as aq, type ThinkingDeltaEvent as ar, type TokenRequestReason as as, type TokenSource as at, type ToolBudget as au, type ToolBudgetExceededEvent as av, type ToolBudgets as aw, type UserMessageEvent as ax, type ZodLikeObject as ay, defineLocalA2A as az, type AgentSpecBase as b, type AssistantDeltaEvent as c, type AssistantMessageEvent as d, type AttachmentMetadata as e, type ConversationMessage as f, DEFAULT_OAUTH_BASE_URL as g, DEFAULT_REFRESH_SKEW_MS as h, type DefineLocalA2AOptions as i, type DefineLocalMcpOptions as j, type DefineLocalToolOptions as k, type InputFileAttachmentMetadata as l, type InputFileUrlAttachment as m, type InputFileUrlAttachmentMetadata as n, type LocalHandlers as o, type LocalMcpHttpTransport as p, type LocalMcpServer as q, type LocalMcpStdioTransport as r, type LocalTool as s, type LocalToolCallEvent as t, type LocalToolResultInEvent as u, type LoopDetectedEvent as v, type LoopDetection as w, type MantyxA2AOptions as x, MantyxAuthError as y, type MantyxClientOptions as z };
|
package/dist/index.cjs
CHANGED
|
@@ -48,6 +48,8 @@ __export(index_exports, {
|
|
|
48
48
|
defineLocalA2A: () => defineLocalA2A,
|
|
49
49
|
defineLocalMcp: () => defineLocalMcp,
|
|
50
50
|
defineLocalTool: () => defineLocalTool,
|
|
51
|
+
inputFileAttachment: () => inputFileAttachment,
|
|
52
|
+
inputFileUrlAttachment: () => inputFileUrlAttachment,
|
|
51
53
|
isLocalA2ATool: () => isLocalA2ATool,
|
|
52
54
|
isLocalMcpServer: () => isLocalMcpServer,
|
|
53
55
|
isLocalTool: () => isLocalTool,
|
|
@@ -579,7 +581,20 @@ function parseEventBlock(block) {
|
|
|
579
581
|
|
|
580
582
|
// src/zod-to-json-schema.ts
|
|
581
583
|
var import_zod = require("zod");
|
|
584
|
+
function isZodSchema(value) {
|
|
585
|
+
if (!value || typeof value !== "object") return false;
|
|
586
|
+
const o = value;
|
|
587
|
+
return typeof o._def !== "undefined" || typeof o._zod !== "undefined";
|
|
588
|
+
}
|
|
582
589
|
function zodToJsonSchema(schema) {
|
|
590
|
+
const instance = schema;
|
|
591
|
+
if (typeof instance.toJSONSchema === "function") {
|
|
592
|
+
try {
|
|
593
|
+
const out = instance.toJSONSchema();
|
|
594
|
+
if (out && typeof out === "object") return out;
|
|
595
|
+
} catch {
|
|
596
|
+
}
|
|
597
|
+
}
|
|
583
598
|
const builtIn = import_zod.z.toJSONSchema;
|
|
584
599
|
if (typeof builtIn === "function") {
|
|
585
600
|
try {
|
|
@@ -590,24 +605,40 @@ function zodToJsonSchema(schema) {
|
|
|
590
605
|
}
|
|
591
606
|
return convertNode(schema);
|
|
592
607
|
}
|
|
608
|
+
function schemaKind(def) {
|
|
609
|
+
if (!def) return void 0;
|
|
610
|
+
if (typeof def.typeName === "string") return def.typeName;
|
|
611
|
+
if (typeof def.type === "string") return def.type;
|
|
612
|
+
return void 0;
|
|
613
|
+
}
|
|
614
|
+
function isOptionalField(field) {
|
|
615
|
+
const kind = schemaKind(field._def);
|
|
616
|
+
return kind === "ZodOptional" || kind === "ZodDefault" || kind === "optional" || kind === "default";
|
|
617
|
+
}
|
|
593
618
|
function convertNode(schema) {
|
|
594
619
|
const def = schema._def;
|
|
595
|
-
const
|
|
596
|
-
switch (
|
|
620
|
+
const kind = schemaKind(def);
|
|
621
|
+
switch (kind) {
|
|
597
622
|
case "ZodString":
|
|
623
|
+
case "string":
|
|
598
624
|
return { type: "string" };
|
|
599
625
|
case "ZodNumber":
|
|
626
|
+
case "number":
|
|
600
627
|
return { type: "number" };
|
|
601
628
|
case "ZodBoolean":
|
|
629
|
+
case "boolean":
|
|
602
630
|
return { type: "boolean" };
|
|
603
631
|
case "ZodNull":
|
|
632
|
+
case "null":
|
|
604
633
|
return { type: "null" };
|
|
605
|
-
case "ZodLiteral":
|
|
606
|
-
|
|
634
|
+
case "ZodLiteral":
|
|
635
|
+
case "literal": {
|
|
636
|
+
const value = def?.value;
|
|
607
637
|
return { const: value, type: typeof value };
|
|
608
638
|
}
|
|
609
|
-
case "ZodEnum":
|
|
610
|
-
|
|
639
|
+
case "ZodEnum":
|
|
640
|
+
case "enum": {
|
|
641
|
+
const values = def?.values ?? [];
|
|
611
642
|
return { type: "string", enum: [...values] };
|
|
612
643
|
}
|
|
613
644
|
case "ZodArray": {
|
|
@@ -617,26 +648,35 @@ function convertNode(schema) {
|
|
|
617
648
|
items: inner ? convertNode(inner) : {}
|
|
618
649
|
};
|
|
619
650
|
}
|
|
651
|
+
case "array": {
|
|
652
|
+
const inner = def?.element;
|
|
653
|
+
return {
|
|
654
|
+
type: "array",
|
|
655
|
+
items: inner ? convertNode(inner) : {}
|
|
656
|
+
};
|
|
657
|
+
}
|
|
620
658
|
case "ZodOptional":
|
|
621
|
-
case "ZodNullable":
|
|
622
|
-
|
|
659
|
+
case "ZodNullable":
|
|
660
|
+
case "optional":
|
|
661
|
+
case "nullable": {
|
|
662
|
+
const inner = def?.innerType;
|
|
623
663
|
return inner ? convertNode(inner) : {};
|
|
624
664
|
}
|
|
625
|
-
case "ZodDefault":
|
|
626
|
-
|
|
665
|
+
case "ZodDefault":
|
|
666
|
+
case "default": {
|
|
667
|
+
const inner = def?.innerType;
|
|
627
668
|
return inner ? convertNode(inner) : {};
|
|
628
669
|
}
|
|
629
|
-
case "ZodObject":
|
|
630
|
-
|
|
670
|
+
case "ZodObject":
|
|
671
|
+
case "object": {
|
|
672
|
+
const shape = def?.shape;
|
|
631
673
|
const fields = typeof shape === "function" ? shape() : shape;
|
|
632
674
|
const properties = {};
|
|
633
675
|
const required = [];
|
|
634
676
|
if (fields) {
|
|
635
677
|
for (const [key, value] of Object.entries(fields)) {
|
|
636
678
|
properties[key] = convertNode(value);
|
|
637
|
-
|
|
638
|
-
const innerTypeName = innerDef?.typeName;
|
|
639
|
-
if (innerTypeName !== "ZodOptional" && innerTypeName !== "ZodDefault") {
|
|
679
|
+
if (!isOptionalField(value)) {
|
|
640
680
|
required.push(key);
|
|
641
681
|
}
|
|
642
682
|
}
|
|
@@ -651,7 +691,7 @@ function convertNode(schema) {
|
|
|
651
691
|
}
|
|
652
692
|
function toToolParametersWire(parameters) {
|
|
653
693
|
if (!parameters) return { type: "object", properties: {} };
|
|
654
|
-
if (
|
|
694
|
+
if (isZodSchema(parameters)) {
|
|
655
695
|
return zodToJsonSchema(parameters);
|
|
656
696
|
}
|
|
657
697
|
return parameters;
|
|
@@ -659,6 +699,12 @@ function toToolParametersWire(parameters) {
|
|
|
659
699
|
|
|
660
700
|
// src/client.ts
|
|
661
701
|
var DEFAULT_BASE_URL = "https://app.mantyx.io";
|
|
702
|
+
function inputFileAttachment(opts) {
|
|
703
|
+
return { type: "input_file", ...opts };
|
|
704
|
+
}
|
|
705
|
+
function inputFileUrlAttachment(opts) {
|
|
706
|
+
return { type: "input_file_url", ...opts };
|
|
707
|
+
}
|
|
662
708
|
function planOnly(options = {}) {
|
|
663
709
|
return {
|
|
664
710
|
planOnly: true,
|
|
@@ -719,7 +765,8 @@ var MantyxClient = class {
|
|
|
719
765
|
path: "/agent-runs",
|
|
720
766
|
body: serializeAgentSpec(spec, {
|
|
721
767
|
prompt: spec.prompt,
|
|
722
|
-
messages: spec.messages
|
|
768
|
+
messages: spec.messages,
|
|
769
|
+
attachments: spec.attachments
|
|
723
770
|
})
|
|
724
771
|
});
|
|
725
772
|
return await this.driveRun(created.runId, handlers, {
|
|
@@ -759,7 +806,8 @@ var MantyxClient = class {
|
|
|
759
806
|
path: "/agent-runs",
|
|
760
807
|
body: serializeAgentSpec(spec, {
|
|
761
808
|
prompt: spec.prompt,
|
|
762
|
-
messages: spec.messages
|
|
809
|
+
messages: spec.messages,
|
|
810
|
+
attachments: spec.attachments
|
|
763
811
|
})
|
|
764
812
|
});
|
|
765
813
|
yield* this.streamRunEvents(created.runId, handlers, spec.signal);
|
|
@@ -1153,27 +1201,32 @@ var AgentSession = class {
|
|
|
1153
1201
|
this.handlers = handlers;
|
|
1154
1202
|
this.tools = tools ?? [];
|
|
1155
1203
|
}
|
|
1156
|
-
async send(
|
|
1204
|
+
async send(promptOrMessages, opts = {}) {
|
|
1157
1205
|
const created = await this.client.request({
|
|
1158
1206
|
method: "POST",
|
|
1159
1207
|
path: `/agent-sessions/${encodeURIComponent(this.id)}/messages`,
|
|
1160
|
-
body: this.buildSessionMessageBody(
|
|
1208
|
+
body: this.buildSessionMessageBody(promptOrMessages, opts)
|
|
1161
1209
|
});
|
|
1162
1210
|
return this.client.driveRun(created.runId, this.handlers, {
|
|
1163
1211
|
...opts.onAssistantDelta ? { onAssistantDelta: opts.onAssistantDelta } : {},
|
|
1164
1212
|
...opts.signal ? { signal: opts.signal } : {}
|
|
1165
1213
|
});
|
|
1166
1214
|
}
|
|
1167
|
-
async *stream(
|
|
1215
|
+
async *stream(promptOrMessages, opts = {}) {
|
|
1168
1216
|
const created = await this.client.request({
|
|
1169
1217
|
method: "POST",
|
|
1170
1218
|
path: `/agent-sessions/${encodeURIComponent(this.id)}/messages`,
|
|
1171
|
-
body: this.buildSessionMessageBody(
|
|
1219
|
+
body: this.buildSessionMessageBody(promptOrMessages, opts)
|
|
1172
1220
|
});
|
|
1173
1221
|
yield* this.client.streamRunEvents(created.runId, this.handlers, opts.signal);
|
|
1174
1222
|
}
|
|
1175
|
-
buildSessionMessageBody(
|
|
1176
|
-
const body =
|
|
1223
|
+
buildSessionMessageBody(promptOrMessages, opts) {
|
|
1224
|
+
const body = serializeTurnInput(
|
|
1225
|
+
typeof promptOrMessages === "string" ? { prompt: promptOrMessages, attachments: opts.attachments } : { messages: promptOrMessages }
|
|
1226
|
+
);
|
|
1227
|
+
if (!("prompt" in body) && !("messages" in body)) {
|
|
1228
|
+
throw new MantyxError("Either `prompt` or `messages` is required");
|
|
1229
|
+
}
|
|
1177
1230
|
if (this.tools.length > 0) body.tools = serializeToolRefs(this.tools);
|
|
1178
1231
|
if (opts.metadata && Object.keys(opts.metadata).length > 0) body.metadata = opts.metadata;
|
|
1179
1232
|
if (opts.reasoningLevel !== void 0) {
|
|
@@ -1199,9 +1252,9 @@ var AgentSession = class {
|
|
|
1199
1252
|
/**
|
|
1200
1253
|
* Plan-only session turn. Sugar for `send(prompt, { plan: planOnly(...) })`.
|
|
1201
1254
|
*/
|
|
1202
|
-
async runPlan(
|
|
1255
|
+
async runPlan(promptOrMessages, opts = {}) {
|
|
1203
1256
|
const { steps, brief, ...rest } = opts;
|
|
1204
|
-
return this.send(
|
|
1257
|
+
return this.send(promptOrMessages, {
|
|
1205
1258
|
...rest,
|
|
1206
1259
|
plan: planOnly({
|
|
1207
1260
|
...steps !== void 0 ? { steps } : {},
|
|
@@ -1224,9 +1277,29 @@ var AgentSession = class {
|
|
|
1224
1277
|
}
|
|
1225
1278
|
}
|
|
1226
1279
|
};
|
|
1280
|
+
function serializeTurnInput(input) {
|
|
1281
|
+
if (input.messages !== void 0) {
|
|
1282
|
+
return { messages: input.messages };
|
|
1283
|
+
}
|
|
1284
|
+
if (input.prompt !== void 0) {
|
|
1285
|
+
if (input.attachments && input.attachments.length > 0) {
|
|
1286
|
+
return {
|
|
1287
|
+
messages: [{ role: "user", content: input.prompt, attachments: input.attachments }]
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
return { prompt: input.prompt };
|
|
1291
|
+
}
|
|
1292
|
+
return {};
|
|
1293
|
+
}
|
|
1294
|
+
function hasNonEmptySystemMessage(messages) {
|
|
1295
|
+
return messages?.some((m) => m.role === "system" && m.content.trim().length > 0) ?? false;
|
|
1296
|
+
}
|
|
1227
1297
|
function serializeAgentSpec(spec, extra = {}) {
|
|
1228
|
-
|
|
1229
|
-
|
|
1298
|
+
const messagesForIdentity = extra.messages ?? (extra.attachments?.length ? [{ role: "user", content: extra.prompt ?? "", attachments: extra.attachments }] : void 0);
|
|
1299
|
+
if (!spec.agentId && (typeof spec.systemPrompt !== "string" || spec.systemPrompt.length === 0) && !hasNonEmptySystemMessage(messagesForIdentity)) {
|
|
1300
|
+
throw new MantyxError(
|
|
1301
|
+
"Either `agentId`, `systemPrompt`, or a non-empty `system` message in `messages` is required"
|
|
1302
|
+
);
|
|
1230
1303
|
}
|
|
1231
1304
|
const body = {
|
|
1232
1305
|
tools: serializeToolRefs(spec.tools ?? [])
|
|
@@ -1255,8 +1328,7 @@ function serializeAgentSpec(spec, extra = {}) {
|
|
|
1255
1328
|
}
|
|
1256
1329
|
if (spec.budgets) body.budgets = spec.budgets;
|
|
1257
1330
|
if (spec.metadata && Object.keys(spec.metadata).length > 0) body.metadata = spec.metadata;
|
|
1258
|
-
|
|
1259
|
-
if (extra.messages !== void 0) body.messages = extra.messages;
|
|
1331
|
+
Object.assign(body, serializeTurnInput(extra));
|
|
1260
1332
|
return body;
|
|
1261
1333
|
}
|
|
1262
1334
|
function serializeToolRefs(tools) {
|
|
@@ -1881,7 +1953,7 @@ function normalizeScope(scope) {
|
|
|
1881
1953
|
}
|
|
1882
1954
|
|
|
1883
1955
|
// src/version.ts
|
|
1884
|
-
var SDK_VERSION = "0.
|
|
1956
|
+
var SDK_VERSION = "0.15.1";
|
|
1885
1957
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1886
1958
|
0 && (module.exports = {
|
|
1887
1959
|
AgentSession,
|
|
@@ -1902,6 +1974,8 @@ var SDK_VERSION = "0.14.0";
|
|
|
1902
1974
|
defineLocalA2A,
|
|
1903
1975
|
defineLocalMcp,
|
|
1904
1976
|
defineLocalTool,
|
|
1977
|
+
inputFileAttachment,
|
|
1978
|
+
inputFileUrlAttachment,
|
|
1905
1979
|
isLocalA2ATool,
|
|
1906
1980
|
isLocalMcpServer,
|
|
1907
1981
|
isLocalTool,
|