@mantyx/sdk 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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?: Array<{
894
- role: "user" | "assistant" | "system";
895
- content: string;
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: Array<{
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(prompt: string, opts?: {
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(prompt: string, opts?: {
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(prompt: string, opts?: {
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<Array<{
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 RefreshTokenSourceOptions as $, type A2AToolRef as A, MantyxOAuthError as B, type CancelledEvent as C, DEFAULT_BASE_URL as D, type ErrorEvent as E, MantyxParseError as F, type MantyxPluginToolRef as G, MantyxRunError as H, type MantyxRunErrorInit as I, type MantyxRunErrorModel as J, type MantyxRunErrorTokens as K, type LocalA2ATool as L, MantyxClient as M, MantyxScopeError as N, type OutputSchema as O, MantyxToolError as P, type MantyxToolRef as Q, type ReasoningLevel as R, type McpToolRef as S, type ToolRef as T, type ModelCatalog as U, type ModelInfo as V, type OAuthToken as W, type OutputSchemaValue as X, type PlanOptions as Y, type PlanSpec as Z, type RefreshOptions as _, AgentSession as a, type ResultEvent as a0, type RevokeOptions as a1, type RunEvent as a2, type RunEventBase as a3, type RunModelInfo as a4, type RunResult as a5, type RunSpec as a6, type RunTokenUsage as a7, type ServerToolResultEvent as a8, type SessionInfo as a9, mantyxPluginTool as aA, mantyxTool as aB, parseRunOutput as aC, planOnly as aD, type SessionListResult as aa, type SessionSpec as ab, type SessionSummary as ac, type Supervisor as ad, type SupervisorAction as ae, type SupervisorEvent as af, type TaskPlan as ag, type TaskPlanEvent as ah, type TaskPlanStep as ai, type TaskPlanStepStatus as aj, type ThinkingDeltaEvent as ak, type TokenRequestReason as al, type TokenSource as am, type ToolBudget as an, type ToolBudgetExceededEvent as ao, type ToolBudgets as ap, type UserMessageEvent as aq, type ZodLikeObject as ar, defineLocalA2A as as, defineLocalMcp as at, defineLocalTool as au, isLocalA2ATool as av, isLocalMcpServer as aw, isLocalTool as ax, mantyxA2A as ay, mantyxMcp as az, type AgentSpecBase as b, type AssistantDeltaEvent as c, type AssistantMessageEvent as d, DEFAULT_OAUTH_BASE_URL as e, DEFAULT_REFRESH_SKEW_MS as f, type DefineLocalA2AOptions as g, type DefineLocalMcpOptions as h, type DefineLocalToolOptions as i, type LocalHandlers as j, type LocalMcpHttpTransport as k, type LocalMcpServer as l, type LocalMcpStdioTransport as m, type LocalTool as n, type LocalToolCallEvent as o, type LocalToolResultInEvent as p, type LoopDetectedEvent as q, type LoopDetection as r, type MantyxA2AOptions as s, MantyxAuthError as t, type MantyxClientOptions as u, MantyxError as v, type MantyxMcpOptions as w, MantyxNetworkError as x, MantyxOAuthClient as y, type MantyxOAuthClientOptions as z };
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 };
@@ -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?: Array<{
894
- role: "user" | "assistant" | "system";
895
- content: string;
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: Array<{
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(prompt: string, opts?: {
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(prompt: string, opts?: {
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(prompt: string, opts?: {
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<Array<{
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 RefreshTokenSourceOptions as $, type A2AToolRef as A, MantyxOAuthError as B, type CancelledEvent as C, DEFAULT_BASE_URL as D, type ErrorEvent as E, MantyxParseError as F, type MantyxPluginToolRef as G, MantyxRunError as H, type MantyxRunErrorInit as I, type MantyxRunErrorModel as J, type MantyxRunErrorTokens as K, type LocalA2ATool as L, MantyxClient as M, MantyxScopeError as N, type OutputSchema as O, MantyxToolError as P, type MantyxToolRef as Q, type ReasoningLevel as R, type McpToolRef as S, type ToolRef as T, type ModelCatalog as U, type ModelInfo as V, type OAuthToken as W, type OutputSchemaValue as X, type PlanOptions as Y, type PlanSpec as Z, type RefreshOptions as _, AgentSession as a, type ResultEvent as a0, type RevokeOptions as a1, type RunEvent as a2, type RunEventBase as a3, type RunModelInfo as a4, type RunResult as a5, type RunSpec as a6, type RunTokenUsage as a7, type ServerToolResultEvent as a8, type SessionInfo as a9, mantyxPluginTool as aA, mantyxTool as aB, parseRunOutput as aC, planOnly as aD, type SessionListResult as aa, type SessionSpec as ab, type SessionSummary as ac, type Supervisor as ad, type SupervisorAction as ae, type SupervisorEvent as af, type TaskPlan as ag, type TaskPlanEvent as ah, type TaskPlanStep as ai, type TaskPlanStepStatus as aj, type ThinkingDeltaEvent as ak, type TokenRequestReason as al, type TokenSource as am, type ToolBudget as an, type ToolBudgetExceededEvent as ao, type ToolBudgets as ap, type UserMessageEvent as aq, type ZodLikeObject as ar, defineLocalA2A as as, defineLocalMcp as at, defineLocalTool as au, isLocalA2ATool as av, isLocalMcpServer as aw, isLocalTool as ax, mantyxA2A as ay, mantyxMcp as az, type AgentSpecBase as b, type AssistantDeltaEvent as c, type AssistantMessageEvent as d, DEFAULT_OAUTH_BASE_URL as e, DEFAULT_REFRESH_SKEW_MS as f, type DefineLocalA2AOptions as g, type DefineLocalMcpOptions as h, type DefineLocalToolOptions as i, type LocalHandlers as j, type LocalMcpHttpTransport as k, type LocalMcpServer as l, type LocalMcpStdioTransport as m, type LocalTool as n, type LocalToolCallEvent as o, type LocalToolResultInEvent as p, type LoopDetectedEvent as q, type LoopDetection as r, type MantyxA2AOptions as s, MantyxAuthError as t, type MantyxClientOptions as u, MantyxError as v, type MantyxMcpOptions as w, MantyxNetworkError as x, MantyxOAuthClient as y, type MantyxOAuthClientOptions as z };
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,
@@ -659,6 +661,12 @@ function toToolParametersWire(parameters) {
659
661
 
660
662
  // src/client.ts
661
663
  var DEFAULT_BASE_URL = "https://app.mantyx.io";
664
+ function inputFileAttachment(opts) {
665
+ return { type: "input_file", ...opts };
666
+ }
667
+ function inputFileUrlAttachment(opts) {
668
+ return { type: "input_file_url", ...opts };
669
+ }
662
670
  function planOnly(options = {}) {
663
671
  return {
664
672
  planOnly: true,
@@ -719,7 +727,8 @@ var MantyxClient = class {
719
727
  path: "/agent-runs",
720
728
  body: serializeAgentSpec(spec, {
721
729
  prompt: spec.prompt,
722
- messages: spec.messages
730
+ messages: spec.messages,
731
+ attachments: spec.attachments
723
732
  })
724
733
  });
725
734
  return await this.driveRun(created.runId, handlers, {
@@ -759,7 +768,8 @@ var MantyxClient = class {
759
768
  path: "/agent-runs",
760
769
  body: serializeAgentSpec(spec, {
761
770
  prompt: spec.prompt,
762
- messages: spec.messages
771
+ messages: spec.messages,
772
+ attachments: spec.attachments
763
773
  })
764
774
  });
765
775
  yield* this.streamRunEvents(created.runId, handlers, spec.signal);
@@ -1153,27 +1163,32 @@ var AgentSession = class {
1153
1163
  this.handlers = handlers;
1154
1164
  this.tools = tools ?? [];
1155
1165
  }
1156
- async send(prompt, opts = {}) {
1166
+ async send(promptOrMessages, opts = {}) {
1157
1167
  const created = await this.client.request({
1158
1168
  method: "POST",
1159
1169
  path: `/agent-sessions/${encodeURIComponent(this.id)}/messages`,
1160
- body: this.buildSessionMessageBody(prompt, opts)
1170
+ body: this.buildSessionMessageBody(promptOrMessages, opts)
1161
1171
  });
1162
1172
  return this.client.driveRun(created.runId, this.handlers, {
1163
1173
  ...opts.onAssistantDelta ? { onAssistantDelta: opts.onAssistantDelta } : {},
1164
1174
  ...opts.signal ? { signal: opts.signal } : {}
1165
1175
  });
1166
1176
  }
1167
- async *stream(prompt, opts = {}) {
1177
+ async *stream(promptOrMessages, opts = {}) {
1168
1178
  const created = await this.client.request({
1169
1179
  method: "POST",
1170
1180
  path: `/agent-sessions/${encodeURIComponent(this.id)}/messages`,
1171
- body: this.buildSessionMessageBody(prompt, opts)
1181
+ body: this.buildSessionMessageBody(promptOrMessages, opts)
1172
1182
  });
1173
1183
  yield* this.client.streamRunEvents(created.runId, this.handlers, opts.signal);
1174
1184
  }
1175
- buildSessionMessageBody(prompt, opts) {
1176
- const body = { prompt };
1185
+ buildSessionMessageBody(promptOrMessages, opts) {
1186
+ const body = serializeTurnInput(
1187
+ typeof promptOrMessages === "string" ? { prompt: promptOrMessages, attachments: opts.attachments } : { messages: promptOrMessages }
1188
+ );
1189
+ if (!("prompt" in body) && !("messages" in body)) {
1190
+ throw new MantyxError("Either `prompt` or `messages` is required");
1191
+ }
1177
1192
  if (this.tools.length > 0) body.tools = serializeToolRefs(this.tools);
1178
1193
  if (opts.metadata && Object.keys(opts.metadata).length > 0) body.metadata = opts.metadata;
1179
1194
  if (opts.reasoningLevel !== void 0) {
@@ -1199,9 +1214,9 @@ var AgentSession = class {
1199
1214
  /**
1200
1215
  * Plan-only session turn. Sugar for `send(prompt, { plan: planOnly(...) })`.
1201
1216
  */
1202
- async runPlan(prompt, opts = {}) {
1217
+ async runPlan(promptOrMessages, opts = {}) {
1203
1218
  const { steps, brief, ...rest } = opts;
1204
- return this.send(prompt, {
1219
+ return this.send(promptOrMessages, {
1205
1220
  ...rest,
1206
1221
  plan: planOnly({
1207
1222
  ...steps !== void 0 ? { steps } : {},
@@ -1224,9 +1239,29 @@ var AgentSession = class {
1224
1239
  }
1225
1240
  }
1226
1241
  };
1242
+ function serializeTurnInput(input) {
1243
+ if (input.messages !== void 0) {
1244
+ return { messages: input.messages };
1245
+ }
1246
+ if (input.prompt !== void 0) {
1247
+ if (input.attachments && input.attachments.length > 0) {
1248
+ return {
1249
+ messages: [{ role: "user", content: input.prompt, attachments: input.attachments }]
1250
+ };
1251
+ }
1252
+ return { prompt: input.prompt };
1253
+ }
1254
+ return {};
1255
+ }
1256
+ function hasNonEmptySystemMessage(messages) {
1257
+ return messages?.some((m) => m.role === "system" && m.content.trim().length > 0) ?? false;
1258
+ }
1227
1259
  function serializeAgentSpec(spec, extra = {}) {
1228
- if (!spec.agentId && (typeof spec.systemPrompt !== "string" || spec.systemPrompt.length === 0)) {
1229
- throw new MantyxError("Either `agentId` or `systemPrompt` is required");
1260
+ const messagesForIdentity = extra.messages ?? (extra.attachments?.length ? [{ role: "user", content: extra.prompt ?? "", attachments: extra.attachments }] : void 0);
1261
+ if (!spec.agentId && (typeof spec.systemPrompt !== "string" || spec.systemPrompt.length === 0) && !hasNonEmptySystemMessage(messagesForIdentity)) {
1262
+ throw new MantyxError(
1263
+ "Either `agentId`, `systemPrompt`, or a non-empty `system` message in `messages` is required"
1264
+ );
1230
1265
  }
1231
1266
  const body = {
1232
1267
  tools: serializeToolRefs(spec.tools ?? [])
@@ -1255,8 +1290,7 @@ function serializeAgentSpec(spec, extra = {}) {
1255
1290
  }
1256
1291
  if (spec.budgets) body.budgets = spec.budgets;
1257
1292
  if (spec.metadata && Object.keys(spec.metadata).length > 0) body.metadata = spec.metadata;
1258
- if (extra.prompt !== void 0) body.prompt = extra.prompt;
1259
- if (extra.messages !== void 0) body.messages = extra.messages;
1293
+ Object.assign(body, serializeTurnInput(extra));
1260
1294
  return body;
1261
1295
  }
1262
1296
  function serializeToolRefs(tools) {
@@ -1881,7 +1915,7 @@ function normalizeScope(scope) {
1881
1915
  }
1882
1916
 
1883
1917
  // src/version.ts
1884
- var SDK_VERSION = "0.14.0";
1918
+ var SDK_VERSION = "0.15.0";
1885
1919
  // Annotate the CommonJS export names for ESM import in node:
1886
1920
  0 && (module.exports = {
1887
1921
  AgentSession,
@@ -1902,6 +1936,8 @@ var SDK_VERSION = "0.14.0";
1902
1936
  defineLocalA2A,
1903
1937
  defineLocalMcp,
1904
1938
  defineLocalTool,
1939
+ inputFileAttachment,
1940
+ inputFileUrlAttachment,
1905
1941
  isLocalA2ATool,
1906
1942
  isLocalMcpServer,
1907
1943
  isLocalTool,