@mantyx/sdk 0.13.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
@@ -859,6 +909,22 @@ interface AgentSpecBase {
859
909
  * the verdict by the time the event arrives.
860
910
  */
861
911
  supervisor?: Supervisor | false;
912
+ /**
913
+ * In-product **task plan** — live checklist emitted as `task_plan` SSE
914
+ * events and (for `planOnly` runs) returned on the terminal `result`.
915
+ * Opt-in: every planned run pays for at least one classifier LLM call.
916
+ *
917
+ * - `true` — auto-classify; track step statuses during the run when warranted.
918
+ * - `{ steps?, brief? }` — caller-provided checklist (skips the classifier).
919
+ * - `{ planOnly: true, steps?, brief? }` — produce the plan and **stop**
920
+ * without executing the agent loop; read the final checklist from
921
+ * {@link RunResult.plan}.
922
+ * - `false` — no planning (default when omitted).
923
+ *
924
+ * See `docs/agent-runs-protocol.md` §4.9. Prefer {@link MantyxClient.runPlan}
925
+ * for plan-only runs.
926
+ */
927
+ plan?: PlanSpec;
862
928
  /**
863
929
  * Flat string→string KV carried alongside the run / session for
864
930
  * observability. Use it to tag runs with your own application identifiers
@@ -874,10 +940,14 @@ interface AgentSpecBase {
874
940
  }
875
941
  interface RunSpec extends AgentSpecBase {
876
942
  prompt?: string;
877
- messages?: Array<{
878
- role: "user" | "assistant" | "system";
879
- content: string;
880
- }>;
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[];
881
951
  /** Receives streaming assistant text deltas. */
882
952
  onAssistantDelta?: (delta: string) => void;
883
953
  /** Receives raw events (assistant_message, local_tool_call, tool_result, ...) for advanced consumers. */
@@ -962,6 +1032,44 @@ interface Supervisor {
962
1032
  }
963
1033
  /** Verdict from a run-supervisor review. */
964
1034
  type SupervisorAction = "on_track" | "redirect" | "finalize";
1035
+ /** Status of one step in an in-product task plan. */
1036
+ type TaskPlanStepStatus = "pending" | "in_progress" | "done";
1037
+ /** One checklist row in a {@link TaskPlan}. */
1038
+ interface TaskPlanStep {
1039
+ title: string;
1040
+ status: TaskPlanStepStatus;
1041
+ }
1042
+ /**
1043
+ * Structured task plan surfaced on `task_plan` events and (for plan-only runs)
1044
+ * on {@link RunResult.plan}. See `docs/agent-runs-protocol.md` §4.9.
1045
+ */
1046
+ interface TaskPlan {
1047
+ /** Optional one-line objective summary. */
1048
+ brief?: string;
1049
+ steps: TaskPlanStep[];
1050
+ }
1051
+ /**
1052
+ * Caller-supplied plan options. Pass `true` / `false` at the top level via
1053
+ * {@link PlanSpec} for auto-classify / disable.
1054
+ */
1055
+ interface PlanOptions {
1056
+ /** When `true`, produce the plan and terminate without executing the agent loop. */
1057
+ planOnly?: boolean;
1058
+ /** One-line objective for a caller-provided plan. Clamped server-side. */
1059
+ brief?: string;
1060
+ /** Caller-provided checklist titles. Omit to let the classifier decide. */
1061
+ steps?: string[];
1062
+ }
1063
+ /** `true` (auto-classify) | options object | `false` (disable). */
1064
+ type PlanSpec = boolean | PlanOptions;
1065
+ /**
1066
+ * Build a {@link PlanSpec} for plan-only runs. Equivalent to
1067
+ * `{ planOnly: true, steps?, brief? }`.
1068
+ */
1069
+ declare function planOnly(options?: {
1070
+ steps?: string[];
1071
+ brief?: string;
1072
+ }): PlanOptions;
965
1073
  /**
966
1074
  * Per-run token totals attached to terminal `result` / `error` events
967
1075
  * (and to the `GET /agent-runs/:runId` snapshot) by MANTYX ≥ 2026-09.
@@ -1058,6 +1166,12 @@ interface RunResult {
1058
1166
  turns?: number;
1059
1167
  /** Resolved model that executed the run. See {@link RunModelInfo}. */
1060
1168
  model?: RunModelInfo;
1169
+ /**
1170
+ * Final structured checklist for `planOnly` runs. Undefined for normal
1171
+ * executed runs (use `task_plan` events for live progress). See
1172
+ * `docs/agent-runs-protocol.md` §4.9.
1173
+ */
1174
+ plan?: TaskPlan;
1061
1175
  }
1062
1176
  interface RunEventBase {
1063
1177
  seq: number;
@@ -1225,11 +1339,22 @@ interface SupervisorEvent extends RunEventBase {
1225
1339
  */
1226
1340
  llmCalls: number;
1227
1341
  }
1342
+ /**
1343
+ * Live checklist update for an in-product task plan. Non-terminal — the run
1344
+ * continues until `result` / `error` / `cancelled`. See §4.9.
1345
+ */
1346
+ interface TaskPlanEvent extends RunEventBase {
1347
+ type: "task_plan";
1348
+ brief?: string;
1349
+ steps: TaskPlanStep[];
1350
+ }
1228
1351
  interface ResultEvent extends RunEventBase {
1229
1352
  type: "result";
1230
1353
  subtype: string;
1231
1354
  text?: string;
1232
1355
  error?: string;
1356
+ /** Present on plan-only terminal results. See {@link RunResult.plan}. */
1357
+ plan?: TaskPlan;
1233
1358
  /**
1234
1359
  * Per-run token totals. Present against MANTYX ≥ 2026-09 — see
1235
1360
  * {@link RunTokenUsage} and `docs/agent-runs-protocol.md` §7.1.
@@ -1303,8 +1428,10 @@ interface CancelledEvent extends RunEventBase {
1303
1428
  interface UserMessageEvent extends RunEventBase {
1304
1429
  type: "user_message";
1305
1430
  text: string;
1431
+ /** Present on session-event replay when the user turn carried file inputs. */
1432
+ attachments?: AttachmentMetadata[];
1306
1433
  }
1307
- type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1434
+ type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | TaskPlanEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1308
1435
  type: string;
1309
1436
  [key: string]: unknown;
1310
1437
  });
@@ -1316,10 +1443,7 @@ interface SessionInfo {
1316
1443
  lastUsedAt: string;
1317
1444
  endedAt: string | null;
1318
1445
  agentSpec: AgentSpecBase;
1319
- messages: Array<{
1320
- role: "user" | "assistant" | "system";
1321
- content: string;
1322
- }>;
1446
+ messages: ConversationMessage[];
1323
1447
  /** Metadata that was attached to the session at create time, returned for observability. */
1324
1448
  metadata: Record<string, string>;
1325
1449
  }
@@ -1369,6 +1493,18 @@ declare class MantyxClient {
1369
1493
  constructor(opts: MantyxClientOptions);
1370
1494
  listModels(): Promise<ModelCatalog>;
1371
1495
  runAgent(spec: RunSpec): Promise<RunResult>;
1496
+ /**
1497
+ * Plan-only run: classify (or accept caller `steps`) and return the
1498
+ * structured checklist without executing the agent loop. Sugar for
1499
+ * `runAgent({ ..., plan: planOnly({ steps, brief }) })`.
1500
+ *
1501
+ * The final checklist is on {@link RunResult.plan}; intermediate
1502
+ * progress is available via `task_plan` events when streaming.
1503
+ */
1504
+ runPlan(spec: Omit<RunSpec, "plan"> & {
1505
+ steps?: string[];
1506
+ brief?: string;
1507
+ }): Promise<RunResult>;
1372
1508
  streamAgent(spec: RunSpec): AsyncGenerator<RunEvent, void, void>;
1373
1509
  /**
1374
1510
  * Internal registry of client-resolved tool handlers. Exposed for callers
@@ -1464,9 +1600,15 @@ declare class AgentSession {
1464
1600
  private readonly handlers;
1465
1601
  private readonly tools;
1466
1602
  constructor(client: MantyxClient, id: string, handlers: LocalHandlers, tools?: ToolRef[]);
1467
- send(prompt: string, opts?: {
1603
+ send(promptOrMessages: string | ConversationMessage[], opts?: {
1468
1604
  onAssistantDelta?: (s: string) => void;
1469
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[];
1470
1612
  /**
1471
1613
  * Per-message metadata override. Server-side this is merged on top of
1472
1614
  * the session's metadata at run-creation time (run-level keys win).
@@ -1500,21 +1642,40 @@ declare class AgentSession {
1500
1642
  * disable the platform judge for this single turn.
1501
1643
  */
1502
1644
  supervisor?: Supervisor | false;
1645
+ /**
1646
+ * Per-message override for `plan`. Applies only to this run and does
1647
+ * not mutate the session's stored value. See {@link AgentSpecBase.plan}.
1648
+ */
1649
+ plan?: PlanSpec;
1503
1650
  }): Promise<RunResult>;
1504
- stream(prompt: string, opts?: {
1651
+ stream(promptOrMessages: string | ConversationMessage[], opts?: {
1505
1652
  signal?: AbortSignal;
1653
+ attachments?: MessageAttachment[];
1506
1654
  metadata?: Record<string, string>;
1507
1655
  reasoningLevel?: ReasoningLevel;
1508
1656
  outputSchema?: OutputSchema;
1509
1657
  loopDetection?: LoopDetection | false;
1510
1658
  toolBudgets?: ToolBudgets;
1511
1659
  supervisor?: Supervisor | false;
1660
+ plan?: PlanSpec;
1512
1661
  }): AsyncGenerator<RunEvent, void, void>;
1513
1662
  private buildSessionMessageBody;
1514
- history(): Promise<Array<{
1515
- role: "user" | "assistant" | "system";
1516
- content: string;
1517
- }>>;
1663
+ /**
1664
+ * Plan-only session turn. Sugar for `send(prompt, { plan: planOnly(...) })`.
1665
+ */
1666
+ runPlan(promptOrMessages: string | ConversationMessage[], opts?: {
1667
+ onAssistantDelta?: (s: string) => void;
1668
+ signal?: AbortSignal;
1669
+ metadata?: Record<string, string>;
1670
+ reasoningLevel?: ReasoningLevel;
1671
+ outputSchema?: OutputSchema;
1672
+ loopDetection?: LoopDetection | false;
1673
+ toolBudgets?: ToolBudgets;
1674
+ supervisor?: Supervisor | false;
1675
+ steps?: string[];
1676
+ brief?: string;
1677
+ }): Promise<RunResult>;
1678
+ history(): Promise<ConversationMessage[]>;
1518
1679
  info(): Promise<SessionInfo>;
1519
1680
  end(): Promise<void>;
1520
1681
  }
@@ -1559,4 +1720,4 @@ interface LocalHandlers {
1559
1720
  */
1560
1721
  declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
1561
1722
 
1562
- export { type RevokeOptions 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 RefreshOptions as Y, type RefreshTokenSourceOptions as Z, type ResultEvent as _, AgentSession as a, type RunEvent as a0, type RunEventBase as a1, type RunModelInfo as a2, type RunResult as a3, type RunSpec as a4, type RunTokenUsage as a5, type ServerToolResultEvent as a6, type SessionInfo as a7, type SessionListResult as a8, type SessionSpec as a9, type SessionSummary as aa, type Supervisor as ab, type SupervisorAction as ac, type SupervisorEvent as ad, type ThinkingDeltaEvent as ae, type TokenRequestReason as af, type TokenSource as ag, type ToolBudget as ah, type ToolBudgetExceededEvent as ai, type ToolBudgets as aj, type UserMessageEvent as ak, type ZodLikeObject as al, defineLocalA2A as am, defineLocalMcp as an, defineLocalTool as ao, isLocalA2ATool as ap, isLocalMcpServer as aq, isLocalTool as ar, mantyxA2A as as, mantyxMcp as at, mantyxPluginTool as au, mantyxTool as av, parseRunOutput as aw, 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
@@ -859,6 +909,22 @@ interface AgentSpecBase {
859
909
  * the verdict by the time the event arrives.
860
910
  */
861
911
  supervisor?: Supervisor | false;
912
+ /**
913
+ * In-product **task plan** — live checklist emitted as `task_plan` SSE
914
+ * events and (for `planOnly` runs) returned on the terminal `result`.
915
+ * Opt-in: every planned run pays for at least one classifier LLM call.
916
+ *
917
+ * - `true` — auto-classify; track step statuses during the run when warranted.
918
+ * - `{ steps?, brief? }` — caller-provided checklist (skips the classifier).
919
+ * - `{ planOnly: true, steps?, brief? }` — produce the plan and **stop**
920
+ * without executing the agent loop; read the final checklist from
921
+ * {@link RunResult.plan}.
922
+ * - `false` — no planning (default when omitted).
923
+ *
924
+ * See `docs/agent-runs-protocol.md` §4.9. Prefer {@link MantyxClient.runPlan}
925
+ * for plan-only runs.
926
+ */
927
+ plan?: PlanSpec;
862
928
  /**
863
929
  * Flat string→string KV carried alongside the run / session for
864
930
  * observability. Use it to tag runs with your own application identifiers
@@ -874,10 +940,14 @@ interface AgentSpecBase {
874
940
  }
875
941
  interface RunSpec extends AgentSpecBase {
876
942
  prompt?: string;
877
- messages?: Array<{
878
- role: "user" | "assistant" | "system";
879
- content: string;
880
- }>;
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[];
881
951
  /** Receives streaming assistant text deltas. */
882
952
  onAssistantDelta?: (delta: string) => void;
883
953
  /** Receives raw events (assistant_message, local_tool_call, tool_result, ...) for advanced consumers. */
@@ -962,6 +1032,44 @@ interface Supervisor {
962
1032
  }
963
1033
  /** Verdict from a run-supervisor review. */
964
1034
  type SupervisorAction = "on_track" | "redirect" | "finalize";
1035
+ /** Status of one step in an in-product task plan. */
1036
+ type TaskPlanStepStatus = "pending" | "in_progress" | "done";
1037
+ /** One checklist row in a {@link TaskPlan}. */
1038
+ interface TaskPlanStep {
1039
+ title: string;
1040
+ status: TaskPlanStepStatus;
1041
+ }
1042
+ /**
1043
+ * Structured task plan surfaced on `task_plan` events and (for plan-only runs)
1044
+ * on {@link RunResult.plan}. See `docs/agent-runs-protocol.md` §4.9.
1045
+ */
1046
+ interface TaskPlan {
1047
+ /** Optional one-line objective summary. */
1048
+ brief?: string;
1049
+ steps: TaskPlanStep[];
1050
+ }
1051
+ /**
1052
+ * Caller-supplied plan options. Pass `true` / `false` at the top level via
1053
+ * {@link PlanSpec} for auto-classify / disable.
1054
+ */
1055
+ interface PlanOptions {
1056
+ /** When `true`, produce the plan and terminate without executing the agent loop. */
1057
+ planOnly?: boolean;
1058
+ /** One-line objective for a caller-provided plan. Clamped server-side. */
1059
+ brief?: string;
1060
+ /** Caller-provided checklist titles. Omit to let the classifier decide. */
1061
+ steps?: string[];
1062
+ }
1063
+ /** `true` (auto-classify) | options object | `false` (disable). */
1064
+ type PlanSpec = boolean | PlanOptions;
1065
+ /**
1066
+ * Build a {@link PlanSpec} for plan-only runs. Equivalent to
1067
+ * `{ planOnly: true, steps?, brief? }`.
1068
+ */
1069
+ declare function planOnly(options?: {
1070
+ steps?: string[];
1071
+ brief?: string;
1072
+ }): PlanOptions;
965
1073
  /**
966
1074
  * Per-run token totals attached to terminal `result` / `error` events
967
1075
  * (and to the `GET /agent-runs/:runId` snapshot) by MANTYX ≥ 2026-09.
@@ -1058,6 +1166,12 @@ interface RunResult {
1058
1166
  turns?: number;
1059
1167
  /** Resolved model that executed the run. See {@link RunModelInfo}. */
1060
1168
  model?: RunModelInfo;
1169
+ /**
1170
+ * Final structured checklist for `planOnly` runs. Undefined for normal
1171
+ * executed runs (use `task_plan` events for live progress). See
1172
+ * `docs/agent-runs-protocol.md` §4.9.
1173
+ */
1174
+ plan?: TaskPlan;
1061
1175
  }
1062
1176
  interface RunEventBase {
1063
1177
  seq: number;
@@ -1225,11 +1339,22 @@ interface SupervisorEvent extends RunEventBase {
1225
1339
  */
1226
1340
  llmCalls: number;
1227
1341
  }
1342
+ /**
1343
+ * Live checklist update for an in-product task plan. Non-terminal — the run
1344
+ * continues until `result` / `error` / `cancelled`. See §4.9.
1345
+ */
1346
+ interface TaskPlanEvent extends RunEventBase {
1347
+ type: "task_plan";
1348
+ brief?: string;
1349
+ steps: TaskPlanStep[];
1350
+ }
1228
1351
  interface ResultEvent extends RunEventBase {
1229
1352
  type: "result";
1230
1353
  subtype: string;
1231
1354
  text?: string;
1232
1355
  error?: string;
1356
+ /** Present on plan-only terminal results. See {@link RunResult.plan}. */
1357
+ plan?: TaskPlan;
1233
1358
  /**
1234
1359
  * Per-run token totals. Present against MANTYX ≥ 2026-09 — see
1235
1360
  * {@link RunTokenUsage} and `docs/agent-runs-protocol.md` §7.1.
@@ -1303,8 +1428,10 @@ interface CancelledEvent extends RunEventBase {
1303
1428
  interface UserMessageEvent extends RunEventBase {
1304
1429
  type: "user_message";
1305
1430
  text: string;
1431
+ /** Present on session-event replay when the user turn carried file inputs. */
1432
+ attachments?: AttachmentMetadata[];
1306
1433
  }
1307
- type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1434
+ type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | TaskPlanEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1308
1435
  type: string;
1309
1436
  [key: string]: unknown;
1310
1437
  });
@@ -1316,10 +1443,7 @@ interface SessionInfo {
1316
1443
  lastUsedAt: string;
1317
1444
  endedAt: string | null;
1318
1445
  agentSpec: AgentSpecBase;
1319
- messages: Array<{
1320
- role: "user" | "assistant" | "system";
1321
- content: string;
1322
- }>;
1446
+ messages: ConversationMessage[];
1323
1447
  /** Metadata that was attached to the session at create time, returned for observability. */
1324
1448
  metadata: Record<string, string>;
1325
1449
  }
@@ -1369,6 +1493,18 @@ declare class MantyxClient {
1369
1493
  constructor(opts: MantyxClientOptions);
1370
1494
  listModels(): Promise<ModelCatalog>;
1371
1495
  runAgent(spec: RunSpec): Promise<RunResult>;
1496
+ /**
1497
+ * Plan-only run: classify (or accept caller `steps`) and return the
1498
+ * structured checklist without executing the agent loop. Sugar for
1499
+ * `runAgent({ ..., plan: planOnly({ steps, brief }) })`.
1500
+ *
1501
+ * The final checklist is on {@link RunResult.plan}; intermediate
1502
+ * progress is available via `task_plan` events when streaming.
1503
+ */
1504
+ runPlan(spec: Omit<RunSpec, "plan"> & {
1505
+ steps?: string[];
1506
+ brief?: string;
1507
+ }): Promise<RunResult>;
1372
1508
  streamAgent(spec: RunSpec): AsyncGenerator<RunEvent, void, void>;
1373
1509
  /**
1374
1510
  * Internal registry of client-resolved tool handlers. Exposed for callers
@@ -1464,9 +1600,15 @@ declare class AgentSession {
1464
1600
  private readonly handlers;
1465
1601
  private readonly tools;
1466
1602
  constructor(client: MantyxClient, id: string, handlers: LocalHandlers, tools?: ToolRef[]);
1467
- send(prompt: string, opts?: {
1603
+ send(promptOrMessages: string | ConversationMessage[], opts?: {
1468
1604
  onAssistantDelta?: (s: string) => void;
1469
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[];
1470
1612
  /**
1471
1613
  * Per-message metadata override. Server-side this is merged on top of
1472
1614
  * the session's metadata at run-creation time (run-level keys win).
@@ -1500,21 +1642,40 @@ declare class AgentSession {
1500
1642
  * disable the platform judge for this single turn.
1501
1643
  */
1502
1644
  supervisor?: Supervisor | false;
1645
+ /**
1646
+ * Per-message override for `plan`. Applies only to this run and does
1647
+ * not mutate the session's stored value. See {@link AgentSpecBase.plan}.
1648
+ */
1649
+ plan?: PlanSpec;
1503
1650
  }): Promise<RunResult>;
1504
- stream(prompt: string, opts?: {
1651
+ stream(promptOrMessages: string | ConversationMessage[], opts?: {
1505
1652
  signal?: AbortSignal;
1653
+ attachments?: MessageAttachment[];
1506
1654
  metadata?: Record<string, string>;
1507
1655
  reasoningLevel?: ReasoningLevel;
1508
1656
  outputSchema?: OutputSchema;
1509
1657
  loopDetection?: LoopDetection | false;
1510
1658
  toolBudgets?: ToolBudgets;
1511
1659
  supervisor?: Supervisor | false;
1660
+ plan?: PlanSpec;
1512
1661
  }): AsyncGenerator<RunEvent, void, void>;
1513
1662
  private buildSessionMessageBody;
1514
- history(): Promise<Array<{
1515
- role: "user" | "assistant" | "system";
1516
- content: string;
1517
- }>>;
1663
+ /**
1664
+ * Plan-only session turn. Sugar for `send(prompt, { plan: planOnly(...) })`.
1665
+ */
1666
+ runPlan(promptOrMessages: string | ConversationMessage[], opts?: {
1667
+ onAssistantDelta?: (s: string) => void;
1668
+ signal?: AbortSignal;
1669
+ metadata?: Record<string, string>;
1670
+ reasoningLevel?: ReasoningLevel;
1671
+ outputSchema?: OutputSchema;
1672
+ loopDetection?: LoopDetection | false;
1673
+ toolBudgets?: ToolBudgets;
1674
+ supervisor?: Supervisor | false;
1675
+ steps?: string[];
1676
+ brief?: string;
1677
+ }): Promise<RunResult>;
1678
+ history(): Promise<ConversationMessage[]>;
1518
1679
  info(): Promise<SessionInfo>;
1519
1680
  end(): Promise<void>;
1520
1681
  }
@@ -1559,4 +1720,4 @@ interface LocalHandlers {
1559
1720
  */
1560
1721
  declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
1561
1722
 
1562
- export { type RevokeOptions 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 RefreshOptions as Y, type RefreshTokenSourceOptions as Z, type ResultEvent as _, AgentSession as a, type RunEvent as a0, type RunEventBase as a1, type RunModelInfo as a2, type RunResult as a3, type RunSpec as a4, type RunTokenUsage as a5, type ServerToolResultEvent as a6, type SessionInfo as a7, type SessionListResult as a8, type SessionSpec as a9, type SessionSummary as aa, type Supervisor as ab, type SupervisorAction as ac, type SupervisorEvent as ad, type ThinkingDeltaEvent as ae, type TokenRequestReason as af, type TokenSource as ag, type ToolBudget as ah, type ToolBudgetExceededEvent as ai, type ToolBudgets as aj, type UserMessageEvent as ak, type ZodLikeObject as al, defineLocalA2A as am, defineLocalMcp as an, defineLocalTool as ao, isLocalA2ATool as ap, isLocalMcpServer as aq, isLocalTool as ar, mantyxA2A as as, mantyxMcp as at, mantyxPluginTool as au, mantyxTool as av, parseRunOutput as aw, 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 };