@mantyx/sdk 0.13.0 → 0.14.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.
@@ -859,6 +859,22 @@ interface AgentSpecBase {
859
859
  * the verdict by the time the event arrives.
860
860
  */
861
861
  supervisor?: Supervisor | false;
862
+ /**
863
+ * In-product **task plan** — live checklist emitted as `task_plan` SSE
864
+ * events and (for `planOnly` runs) returned on the terminal `result`.
865
+ * Opt-in: every planned run pays for at least one classifier LLM call.
866
+ *
867
+ * - `true` — auto-classify; track step statuses during the run when warranted.
868
+ * - `{ steps?, brief? }` — caller-provided checklist (skips the classifier).
869
+ * - `{ planOnly: true, steps?, brief? }` — produce the plan and **stop**
870
+ * without executing the agent loop; read the final checklist from
871
+ * {@link RunResult.plan}.
872
+ * - `false` — no planning (default when omitted).
873
+ *
874
+ * See `docs/agent-runs-protocol.md` §4.9. Prefer {@link MantyxClient.runPlan}
875
+ * for plan-only runs.
876
+ */
877
+ plan?: PlanSpec;
862
878
  /**
863
879
  * Flat string→string KV carried alongside the run / session for
864
880
  * observability. Use it to tag runs with your own application identifiers
@@ -962,6 +978,44 @@ interface Supervisor {
962
978
  }
963
979
  /** Verdict from a run-supervisor review. */
964
980
  type SupervisorAction = "on_track" | "redirect" | "finalize";
981
+ /** Status of one step in an in-product task plan. */
982
+ type TaskPlanStepStatus = "pending" | "in_progress" | "done";
983
+ /** One checklist row in a {@link TaskPlan}. */
984
+ interface TaskPlanStep {
985
+ title: string;
986
+ status: TaskPlanStepStatus;
987
+ }
988
+ /**
989
+ * Structured task plan surfaced on `task_plan` events and (for plan-only runs)
990
+ * on {@link RunResult.plan}. See `docs/agent-runs-protocol.md` §4.9.
991
+ */
992
+ interface TaskPlan {
993
+ /** Optional one-line objective summary. */
994
+ brief?: string;
995
+ steps: TaskPlanStep[];
996
+ }
997
+ /**
998
+ * Caller-supplied plan options. Pass `true` / `false` at the top level via
999
+ * {@link PlanSpec} for auto-classify / disable.
1000
+ */
1001
+ interface PlanOptions {
1002
+ /** When `true`, produce the plan and terminate without executing the agent loop. */
1003
+ planOnly?: boolean;
1004
+ /** One-line objective for a caller-provided plan. Clamped server-side. */
1005
+ brief?: string;
1006
+ /** Caller-provided checklist titles. Omit to let the classifier decide. */
1007
+ steps?: string[];
1008
+ }
1009
+ /** `true` (auto-classify) | options object | `false` (disable). */
1010
+ type PlanSpec = boolean | PlanOptions;
1011
+ /**
1012
+ * Build a {@link PlanSpec} for plan-only runs. Equivalent to
1013
+ * `{ planOnly: true, steps?, brief? }`.
1014
+ */
1015
+ declare function planOnly(options?: {
1016
+ steps?: string[];
1017
+ brief?: string;
1018
+ }): PlanOptions;
965
1019
  /**
966
1020
  * Per-run token totals attached to terminal `result` / `error` events
967
1021
  * (and to the `GET /agent-runs/:runId` snapshot) by MANTYX ≥ 2026-09.
@@ -1058,6 +1112,12 @@ interface RunResult {
1058
1112
  turns?: number;
1059
1113
  /** Resolved model that executed the run. See {@link RunModelInfo}. */
1060
1114
  model?: RunModelInfo;
1115
+ /**
1116
+ * Final structured checklist for `planOnly` runs. Undefined for normal
1117
+ * executed runs (use `task_plan` events for live progress). See
1118
+ * `docs/agent-runs-protocol.md` §4.9.
1119
+ */
1120
+ plan?: TaskPlan;
1061
1121
  }
1062
1122
  interface RunEventBase {
1063
1123
  seq: number;
@@ -1225,11 +1285,22 @@ interface SupervisorEvent extends RunEventBase {
1225
1285
  */
1226
1286
  llmCalls: number;
1227
1287
  }
1288
+ /**
1289
+ * Live checklist update for an in-product task plan. Non-terminal — the run
1290
+ * continues until `result` / `error` / `cancelled`. See §4.9.
1291
+ */
1292
+ interface TaskPlanEvent extends RunEventBase {
1293
+ type: "task_plan";
1294
+ brief?: string;
1295
+ steps: TaskPlanStep[];
1296
+ }
1228
1297
  interface ResultEvent extends RunEventBase {
1229
1298
  type: "result";
1230
1299
  subtype: string;
1231
1300
  text?: string;
1232
1301
  error?: string;
1302
+ /** Present on plan-only terminal results. See {@link RunResult.plan}. */
1303
+ plan?: TaskPlan;
1233
1304
  /**
1234
1305
  * Per-run token totals. Present against MANTYX ≥ 2026-09 — see
1235
1306
  * {@link RunTokenUsage} and `docs/agent-runs-protocol.md` §7.1.
@@ -1304,7 +1375,7 @@ interface UserMessageEvent extends RunEventBase {
1304
1375
  type: "user_message";
1305
1376
  text: string;
1306
1377
  }
1307
- type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1378
+ type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | TaskPlanEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1308
1379
  type: string;
1309
1380
  [key: string]: unknown;
1310
1381
  });
@@ -1369,6 +1440,18 @@ declare class MantyxClient {
1369
1440
  constructor(opts: MantyxClientOptions);
1370
1441
  listModels(): Promise<ModelCatalog>;
1371
1442
  runAgent(spec: RunSpec): Promise<RunResult>;
1443
+ /**
1444
+ * Plan-only run: classify (or accept caller `steps`) and return the
1445
+ * structured checklist without executing the agent loop. Sugar for
1446
+ * `runAgent({ ..., plan: planOnly({ steps, brief }) })`.
1447
+ *
1448
+ * The final checklist is on {@link RunResult.plan}; intermediate
1449
+ * progress is available via `task_plan` events when streaming.
1450
+ */
1451
+ runPlan(spec: Omit<RunSpec, "plan"> & {
1452
+ steps?: string[];
1453
+ brief?: string;
1454
+ }): Promise<RunResult>;
1372
1455
  streamAgent(spec: RunSpec): AsyncGenerator<RunEvent, void, void>;
1373
1456
  /**
1374
1457
  * Internal registry of client-resolved tool handlers. Exposed for callers
@@ -1500,6 +1583,11 @@ declare class AgentSession {
1500
1583
  * disable the platform judge for this single turn.
1501
1584
  */
1502
1585
  supervisor?: Supervisor | false;
1586
+ /**
1587
+ * Per-message override for `plan`. Applies only to this run and does
1588
+ * not mutate the session's stored value. See {@link AgentSpecBase.plan}.
1589
+ */
1590
+ plan?: PlanSpec;
1503
1591
  }): Promise<RunResult>;
1504
1592
  stream(prompt: string, opts?: {
1505
1593
  signal?: AbortSignal;
@@ -1509,8 +1597,24 @@ declare class AgentSession {
1509
1597
  loopDetection?: LoopDetection | false;
1510
1598
  toolBudgets?: ToolBudgets;
1511
1599
  supervisor?: Supervisor | false;
1600
+ plan?: PlanSpec;
1512
1601
  }): AsyncGenerator<RunEvent, void, void>;
1513
1602
  private buildSessionMessageBody;
1603
+ /**
1604
+ * Plan-only session turn. Sugar for `send(prompt, { plan: planOnly(...) })`.
1605
+ */
1606
+ runPlan(prompt: string, opts?: {
1607
+ onAssistantDelta?: (s: string) => void;
1608
+ signal?: AbortSignal;
1609
+ metadata?: Record<string, string>;
1610
+ reasoningLevel?: ReasoningLevel;
1611
+ outputSchema?: OutputSchema;
1612
+ loopDetection?: LoopDetection | false;
1613
+ toolBudgets?: ToolBudgets;
1614
+ supervisor?: Supervisor | false;
1615
+ steps?: string[];
1616
+ brief?: string;
1617
+ }): Promise<RunResult>;
1514
1618
  history(): Promise<Array<{
1515
1619
  role: "user" | "assistant" | "system";
1516
1620
  content: string;
@@ -1559,4 +1663,4 @@ interface LocalHandlers {
1559
1663
  */
1560
1664
  declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
1561
1665
 
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 };
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 };
@@ -859,6 +859,22 @@ interface AgentSpecBase {
859
859
  * the verdict by the time the event arrives.
860
860
  */
861
861
  supervisor?: Supervisor | false;
862
+ /**
863
+ * In-product **task plan** — live checklist emitted as `task_plan` SSE
864
+ * events and (for `planOnly` runs) returned on the terminal `result`.
865
+ * Opt-in: every planned run pays for at least one classifier LLM call.
866
+ *
867
+ * - `true` — auto-classify; track step statuses during the run when warranted.
868
+ * - `{ steps?, brief? }` — caller-provided checklist (skips the classifier).
869
+ * - `{ planOnly: true, steps?, brief? }` — produce the plan and **stop**
870
+ * without executing the agent loop; read the final checklist from
871
+ * {@link RunResult.plan}.
872
+ * - `false` — no planning (default when omitted).
873
+ *
874
+ * See `docs/agent-runs-protocol.md` §4.9. Prefer {@link MantyxClient.runPlan}
875
+ * for plan-only runs.
876
+ */
877
+ plan?: PlanSpec;
862
878
  /**
863
879
  * Flat string→string KV carried alongside the run / session for
864
880
  * observability. Use it to tag runs with your own application identifiers
@@ -962,6 +978,44 @@ interface Supervisor {
962
978
  }
963
979
  /** Verdict from a run-supervisor review. */
964
980
  type SupervisorAction = "on_track" | "redirect" | "finalize";
981
+ /** Status of one step in an in-product task plan. */
982
+ type TaskPlanStepStatus = "pending" | "in_progress" | "done";
983
+ /** One checklist row in a {@link TaskPlan}. */
984
+ interface TaskPlanStep {
985
+ title: string;
986
+ status: TaskPlanStepStatus;
987
+ }
988
+ /**
989
+ * Structured task plan surfaced on `task_plan` events and (for plan-only runs)
990
+ * on {@link RunResult.plan}. See `docs/agent-runs-protocol.md` §4.9.
991
+ */
992
+ interface TaskPlan {
993
+ /** Optional one-line objective summary. */
994
+ brief?: string;
995
+ steps: TaskPlanStep[];
996
+ }
997
+ /**
998
+ * Caller-supplied plan options. Pass `true` / `false` at the top level via
999
+ * {@link PlanSpec} for auto-classify / disable.
1000
+ */
1001
+ interface PlanOptions {
1002
+ /** When `true`, produce the plan and terminate without executing the agent loop. */
1003
+ planOnly?: boolean;
1004
+ /** One-line objective for a caller-provided plan. Clamped server-side. */
1005
+ brief?: string;
1006
+ /** Caller-provided checklist titles. Omit to let the classifier decide. */
1007
+ steps?: string[];
1008
+ }
1009
+ /** `true` (auto-classify) | options object | `false` (disable). */
1010
+ type PlanSpec = boolean | PlanOptions;
1011
+ /**
1012
+ * Build a {@link PlanSpec} for plan-only runs. Equivalent to
1013
+ * `{ planOnly: true, steps?, brief? }`.
1014
+ */
1015
+ declare function planOnly(options?: {
1016
+ steps?: string[];
1017
+ brief?: string;
1018
+ }): PlanOptions;
965
1019
  /**
966
1020
  * Per-run token totals attached to terminal `result` / `error` events
967
1021
  * (and to the `GET /agent-runs/:runId` snapshot) by MANTYX ≥ 2026-09.
@@ -1058,6 +1112,12 @@ interface RunResult {
1058
1112
  turns?: number;
1059
1113
  /** Resolved model that executed the run. See {@link RunModelInfo}. */
1060
1114
  model?: RunModelInfo;
1115
+ /**
1116
+ * Final structured checklist for `planOnly` runs. Undefined for normal
1117
+ * executed runs (use `task_plan` events for live progress). See
1118
+ * `docs/agent-runs-protocol.md` §4.9.
1119
+ */
1120
+ plan?: TaskPlan;
1061
1121
  }
1062
1122
  interface RunEventBase {
1063
1123
  seq: number;
@@ -1225,11 +1285,22 @@ interface SupervisorEvent extends RunEventBase {
1225
1285
  */
1226
1286
  llmCalls: number;
1227
1287
  }
1288
+ /**
1289
+ * Live checklist update for an in-product task plan. Non-terminal — the run
1290
+ * continues until `result` / `error` / `cancelled`. See §4.9.
1291
+ */
1292
+ interface TaskPlanEvent extends RunEventBase {
1293
+ type: "task_plan";
1294
+ brief?: string;
1295
+ steps: TaskPlanStep[];
1296
+ }
1228
1297
  interface ResultEvent extends RunEventBase {
1229
1298
  type: "result";
1230
1299
  subtype: string;
1231
1300
  text?: string;
1232
1301
  error?: string;
1302
+ /** Present on plan-only terminal results. See {@link RunResult.plan}. */
1303
+ plan?: TaskPlan;
1233
1304
  /**
1234
1305
  * Per-run token totals. Present against MANTYX ≥ 2026-09 — see
1235
1306
  * {@link RunTokenUsage} and `docs/agent-runs-protocol.md` §7.1.
@@ -1304,7 +1375,7 @@ interface UserMessageEvent extends RunEventBase {
1304
1375
  type: "user_message";
1305
1376
  text: string;
1306
1377
  }
1307
- type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1378
+ type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | TaskPlanEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1308
1379
  type: string;
1309
1380
  [key: string]: unknown;
1310
1381
  });
@@ -1369,6 +1440,18 @@ declare class MantyxClient {
1369
1440
  constructor(opts: MantyxClientOptions);
1370
1441
  listModels(): Promise<ModelCatalog>;
1371
1442
  runAgent(spec: RunSpec): Promise<RunResult>;
1443
+ /**
1444
+ * Plan-only run: classify (or accept caller `steps`) and return the
1445
+ * structured checklist without executing the agent loop. Sugar for
1446
+ * `runAgent({ ..., plan: planOnly({ steps, brief }) })`.
1447
+ *
1448
+ * The final checklist is on {@link RunResult.plan}; intermediate
1449
+ * progress is available via `task_plan` events when streaming.
1450
+ */
1451
+ runPlan(spec: Omit<RunSpec, "plan"> & {
1452
+ steps?: string[];
1453
+ brief?: string;
1454
+ }): Promise<RunResult>;
1372
1455
  streamAgent(spec: RunSpec): AsyncGenerator<RunEvent, void, void>;
1373
1456
  /**
1374
1457
  * Internal registry of client-resolved tool handlers. Exposed for callers
@@ -1500,6 +1583,11 @@ declare class AgentSession {
1500
1583
  * disable the platform judge for this single turn.
1501
1584
  */
1502
1585
  supervisor?: Supervisor | false;
1586
+ /**
1587
+ * Per-message override for `plan`. Applies only to this run and does
1588
+ * not mutate the session's stored value. See {@link AgentSpecBase.plan}.
1589
+ */
1590
+ plan?: PlanSpec;
1503
1591
  }): Promise<RunResult>;
1504
1592
  stream(prompt: string, opts?: {
1505
1593
  signal?: AbortSignal;
@@ -1509,8 +1597,24 @@ declare class AgentSession {
1509
1597
  loopDetection?: LoopDetection | false;
1510
1598
  toolBudgets?: ToolBudgets;
1511
1599
  supervisor?: Supervisor | false;
1600
+ plan?: PlanSpec;
1512
1601
  }): AsyncGenerator<RunEvent, void, void>;
1513
1602
  private buildSessionMessageBody;
1603
+ /**
1604
+ * Plan-only session turn. Sugar for `send(prompt, { plan: planOnly(...) })`.
1605
+ */
1606
+ runPlan(prompt: string, opts?: {
1607
+ onAssistantDelta?: (s: string) => void;
1608
+ signal?: AbortSignal;
1609
+ metadata?: Record<string, string>;
1610
+ reasoningLevel?: ReasoningLevel;
1611
+ outputSchema?: OutputSchema;
1612
+ loopDetection?: LoopDetection | false;
1613
+ toolBudgets?: ToolBudgets;
1614
+ supervisor?: Supervisor | false;
1615
+ steps?: string[];
1616
+ brief?: string;
1617
+ }): Promise<RunResult>;
1514
1618
  history(): Promise<Array<{
1515
1619
  role: "user" | "assistant" | "system";
1516
1620
  content: string;
@@ -1559,4 +1663,4 @@ interface LocalHandlers {
1559
1663
  */
1560
1664
  declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
1561
1665
 
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 };
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 };
package/dist/index.cjs CHANGED
@@ -56,6 +56,7 @@ __export(index_exports, {
56
56
  mantyxPluginTool: () => mantyxPluginTool,
57
57
  mantyxTool: () => mantyxTool,
58
58
  parseRunOutput: () => parseRunOutput,
59
+ planOnly: () => planOnly,
59
60
  readSseStream: () => readSseStream,
60
61
  toToolParametersWire: () => toToolParametersWire,
61
62
  zodToJsonSchema: () => zodToJsonSchema
@@ -658,6 +659,13 @@ function toToolParametersWire(parameters) {
658
659
 
659
660
  // src/client.ts
660
661
  var DEFAULT_BASE_URL = "https://app.mantyx.io";
662
+ function planOnly(options = {}) {
663
+ return {
664
+ planOnly: true,
665
+ ...options.steps !== void 0 ? { steps: options.steps } : {},
666
+ ...options.brief !== void 0 ? { brief: options.brief } : {}
667
+ };
668
+ }
661
669
  function buildQueryString(query) {
662
670
  if (!query) return "";
663
671
  const parts = [];
@@ -723,6 +731,24 @@ var MantyxClient = class {
723
731
  await closeMcpRefs(tools);
724
732
  }
725
733
  }
734
+ /**
735
+ * Plan-only run: classify (or accept caller `steps`) and return the
736
+ * structured checklist without executing the agent loop. Sugar for
737
+ * `runAgent({ ..., plan: planOnly({ steps, brief }) })`.
738
+ *
739
+ * The final checklist is on {@link RunResult.plan}; intermediate
740
+ * progress is available via `task_plan` events when streaming.
741
+ */
742
+ async runPlan(spec) {
743
+ const { steps, brief, ...rest } = spec;
744
+ return this.runAgent({
745
+ ...rest,
746
+ plan: planOnly({
747
+ ...steps !== void 0 ? { steps } : {},
748
+ ...brief !== void 0 ? { brief } : {}
749
+ })
750
+ });
751
+ }
726
752
  async *streamAgent(spec) {
727
753
  const tools = spec.tools ?? [];
728
754
  await resolveLocalRefs(tools, { fetch: this.options.fetch });
@@ -837,6 +863,7 @@ var MantyxClient = class {
837
863
  let tokens;
838
864
  let turns;
839
865
  let modelInfo;
866
+ let plan;
840
867
  for await (const ev of this.streamRunEvents(runId, handlers, opts.signal)) {
841
868
  collected.push(ev);
842
869
  if (opts.onEvent) opts.onEvent(ev);
@@ -850,6 +877,10 @@ var MantyxClient = class {
850
877
  modelInfo = parseRunModel(r.model) ?? modelInfo;
851
878
  if (r.subtype === "success") {
852
879
  finalText = typeof r.text === "string" ? r.text : "";
880
+ const parsedPlan = parseTaskPlan(r.plan);
881
+ if (parsedPlan !== void 0) {
882
+ plan = parsedPlan;
883
+ }
853
884
  } else {
854
885
  const errInit = {};
855
886
  if (tokens !== void 0) errInit.tokens = tokens;
@@ -880,6 +911,7 @@ var MantyxClient = class {
880
911
  if (tokens !== void 0) result.tokens = tokens;
881
912
  if (turns !== void 0) result.turns = turns;
882
913
  if (modelInfo !== void 0) result.model = modelInfo;
914
+ if (plan !== void 0) result.plan = plan;
883
915
  return result;
884
916
  }
885
917
  async *streamRunEvents(runId, handlers, signal) {
@@ -1159,8 +1191,24 @@ var AgentSession = class {
1159
1191
  if (opts.supervisor !== void 0) {
1160
1192
  body.supervisor = normalizeSupervisor(opts.supervisor);
1161
1193
  }
1194
+ if (opts.plan !== void 0) {
1195
+ body.plan = normalizePlan(opts.plan);
1196
+ }
1162
1197
  return body;
1163
1198
  }
1199
+ /**
1200
+ * Plan-only session turn. Sugar for `send(prompt, { plan: planOnly(...) })`.
1201
+ */
1202
+ async runPlan(prompt, opts = {}) {
1203
+ const { steps, brief, ...rest } = opts;
1204
+ return this.send(prompt, {
1205
+ ...rest,
1206
+ plan: planOnly({
1207
+ ...steps !== void 0 ? { steps } : {},
1208
+ ...brief !== void 0 ? { brief } : {}
1209
+ })
1210
+ });
1211
+ }
1164
1212
  async history() {
1165
1213
  const info = await this.client.getSessionInfo(this.id);
1166
1214
  return info.messages;
@@ -1202,6 +1250,9 @@ function serializeAgentSpec(spec, extra = {}) {
1202
1250
  if (spec.supervisor !== void 0) {
1203
1251
  body.supervisor = normalizeSupervisor(spec.supervisor);
1204
1252
  }
1253
+ if (spec.plan !== void 0) {
1254
+ body.plan = normalizePlan(spec.plan);
1255
+ }
1205
1256
  if (spec.budgets) body.budgets = spec.budgets;
1206
1257
  if (spec.metadata && Object.keys(spec.metadata).length > 0) body.metadata = spec.metadata;
1207
1258
  if (extra.prompt !== void 0) body.prompt = extra.prompt;
@@ -1421,6 +1472,61 @@ function normalizeSupervisor(value) {
1421
1472
  }
1422
1473
  return out;
1423
1474
  }
1475
+ function normalizePlan(value) {
1476
+ if (value === true || value === false) return value;
1477
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
1478
+ throw new MantyxError(
1479
+ `plan must be \`true\`, \`false\`, or an object { planOnly?, brief?, steps? }, got ${JSON.stringify(value)}`
1480
+ );
1481
+ }
1482
+ const out = {};
1483
+ if (value.planOnly !== void 0) {
1484
+ if (typeof value.planOnly !== "boolean") {
1485
+ throw new MantyxError(`plan.planOnly must be a boolean, got ${JSON.stringify(value.planOnly)}`);
1486
+ }
1487
+ out.planOnly = value.planOnly;
1488
+ }
1489
+ if (value.brief !== void 0) {
1490
+ if (typeof value.brief !== "string") {
1491
+ throw new MantyxError(`plan.brief must be a string, got ${JSON.stringify(value.brief)}`);
1492
+ }
1493
+ out.brief = value.brief;
1494
+ }
1495
+ if (value.steps !== void 0) {
1496
+ if (!Array.isArray(value.steps)) {
1497
+ throw new MantyxError(`plan.steps must be an array of strings, got ${JSON.stringify(value.steps)}`);
1498
+ }
1499
+ const steps = [];
1500
+ for (let i = 0; i < value.steps.length; i++) {
1501
+ const step = value.steps[i];
1502
+ if (typeof step !== "string") {
1503
+ throw new MantyxError(`plan.steps[${i}] must be a string, got ${JSON.stringify(step)}`);
1504
+ }
1505
+ steps.push(step);
1506
+ }
1507
+ out.steps = steps;
1508
+ }
1509
+ return out;
1510
+ }
1511
+ function parseTaskPlan(raw) {
1512
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
1513
+ const obj = raw;
1514
+ const stepsRaw = obj.steps;
1515
+ if (!Array.isArray(stepsRaw)) return void 0;
1516
+ const steps = [];
1517
+ for (const entry of stepsRaw) {
1518
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
1519
+ const row = entry;
1520
+ const title = row.title;
1521
+ const status = row.status;
1522
+ if (typeof title !== "string" || typeof status !== "string") continue;
1523
+ if (status !== "pending" && status !== "in_progress" && status !== "done") continue;
1524
+ steps.push({ title, status });
1525
+ }
1526
+ const briefRaw = obj.brief;
1527
+ const brief = typeof briefRaw === "string" && briefRaw ? briefRaw : void 0;
1528
+ return { steps, ...brief !== void 0 ? { brief } : {} };
1529
+ }
1424
1530
  function normalizeToolBudgets(value) {
1425
1531
  if (!value || typeof value !== "object" || Array.isArray(value)) {
1426
1532
  throw new MantyxError(
@@ -1775,7 +1881,7 @@ function normalizeScope(scope) {
1775
1881
  }
1776
1882
 
1777
1883
  // src/version.ts
1778
- var SDK_VERSION = "0.13.0";
1884
+ var SDK_VERSION = "0.14.0";
1779
1885
  // Annotate the CommonJS export names for ESM import in node:
1780
1886
  0 && (module.exports = {
1781
1887
  AgentSession,
@@ -1804,6 +1910,7 @@ var SDK_VERSION = "0.13.0";
1804
1910
  mantyxPluginTool,
1805
1911
  mantyxTool,
1806
1912
  parseRunOutput,
1913
+ planOnly,
1807
1914
  readSseStream,
1808
1915
  toToolParametersWire,
1809
1916
  zodToJsonSchema