@mantyx/sdk 0.12.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
@@ -886,6 +902,13 @@ interface RunSpec extends AgentSpecBase {
886
902
  signal?: AbortSignal;
887
903
  }
888
904
  type SessionSpec = AgentSpecBase;
905
+ /**
906
+ * Either a Zod schema (auto-converted to JSON Schema by the SDK) or a
907
+ * pre-shaped JSON Schema object. Mirrors {@link LocalToolSchemaInput} and
908
+ * Go's `OutputSchema.Schema any` (struct reflection) — pass your
909
+ * source-of-truth schema and the SDK serialises it for the wire.
910
+ */
911
+ type OutputSchemaValue = LocalToolSchemaInput;
889
912
  /**
890
913
  * Constrains the final assistant text to a JSON document matching a
891
914
  * JSON Schema. See {@link AgentSpecBase.outputSchema} for the full
@@ -894,8 +917,8 @@ type SessionSpec = AgentSpecBase;
894
917
  interface OutputSchema {
895
918
  /** Optional. Defaults to `"output"`. Must match `/^[a-zA-Z0-9_-]{1,64}$/`. */
896
919
  name?: string;
897
- /** Required. JSON Schema describing the final assistant text. Root must be a JSON object. */
898
- schema: Record<string, unknown>;
920
+ /** Required. Zod schema or JSON Schema describing the final assistant text. Root must be a JSON object. */
921
+ schema: OutputSchemaValue;
899
922
  }
900
923
  /**
901
924
  * Loop-detection thresholds. See {@link AgentSpecBase.loopDetection} for the
@@ -955,6 +978,44 @@ interface Supervisor {
955
978
  }
956
979
  /** Verdict from a run-supervisor review. */
957
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;
958
1019
  /**
959
1020
  * Per-run token totals attached to terminal `result` / `error` events
960
1021
  * (and to the `GET /agent-runs/:runId` snapshot) by MANTYX ≥ 2026-09.
@@ -1051,6 +1112,12 @@ interface RunResult {
1051
1112
  turns?: number;
1052
1113
  /** Resolved model that executed the run. See {@link RunModelInfo}. */
1053
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;
1054
1121
  }
1055
1122
  interface RunEventBase {
1056
1123
  seq: number;
@@ -1218,11 +1285,22 @@ interface SupervisorEvent extends RunEventBase {
1218
1285
  */
1219
1286
  llmCalls: number;
1220
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
+ }
1221
1297
  interface ResultEvent extends RunEventBase {
1222
1298
  type: "result";
1223
1299
  subtype: string;
1224
1300
  text?: string;
1225
1301
  error?: string;
1302
+ /** Present on plan-only terminal results. See {@link RunResult.plan}. */
1303
+ plan?: TaskPlan;
1226
1304
  /**
1227
1305
  * Per-run token totals. Present against MANTYX ≥ 2026-09 — see
1228
1306
  * {@link RunTokenUsage} and `docs/agent-runs-protocol.md` §7.1.
@@ -1287,7 +1365,17 @@ interface CancelledEvent extends RunEventBase {
1287
1365
  type: "cancelled";
1288
1366
  reason?: string;
1289
1367
  }
1290
- type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1368
+ /**
1369
+ * Replay/restore-only frame returned by {@link MantyxClient.getSessionEvents}
1370
+ * (and the `GET /agent-sessions/:id/events` endpoint). The live SSE stream
1371
+ * never emits this — the client already knows the prompt it sent — but
1372
+ * conversation restoration needs it to rebuild the user side of the thread.
1373
+ */
1374
+ interface UserMessageEvent extends RunEventBase {
1375
+ type: "user_message";
1376
+ text: string;
1377
+ }
1378
+ type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | TaskPlanEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1291
1379
  type: string;
1292
1380
  [key: string]: unknown;
1293
1381
  });
@@ -1306,6 +1394,25 @@ interface SessionInfo {
1306
1394
  /** Metadata that was attached to the session at create time, returned for observability. */
1307
1395
  metadata: Record<string, string>;
1308
1396
  }
1397
+ /** One row from {@link MantyxClient.listSessions}. */
1398
+ interface SessionSummary {
1399
+ sessionId: string;
1400
+ /** ISO 8601 creation timestamp. */
1401
+ creationDate: string;
1402
+ /** ISO 8601 timestamp of the most recent message run. */
1403
+ lastInteractionDate: string;
1404
+ /** Best-effort label derived from the first user prompt (sessions have no title). */
1405
+ summary: string;
1406
+ metadata: Record<string, string>;
1407
+ status: "active" | "ended";
1408
+ }
1409
+ /** Paginated result of {@link MantyxClient.listSessions}. */
1410
+ interface SessionListResult {
1411
+ total: number;
1412
+ limit: number;
1413
+ offset: number;
1414
+ sessions: SessionSummary[];
1415
+ }
1309
1416
  declare class MantyxClient {
1310
1417
  readonly options: Required<Pick<MantyxClientOptions, "workspaceSlug" | "baseUrl">> & {
1311
1418
  /**
@@ -1333,6 +1440,18 @@ declare class MantyxClient {
1333
1440
  constructor(opts: MantyxClientOptions);
1334
1441
  listModels(): Promise<ModelCatalog>;
1335
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>;
1336
1455
  streamAgent(spec: RunSpec): AsyncGenerator<RunEvent, void, void>;
1337
1456
  /**
1338
1457
  * Internal registry of client-resolved tool handlers. Exposed for callers
@@ -1350,6 +1469,29 @@ declare class MantyxClient {
1350
1469
  }): Promise<AgentSession>;
1351
1470
  endSession(sessionId: string): Promise<void>;
1352
1471
  getSessionInfo(sessionId: string): Promise<SessionInfo>;
1472
+ /**
1473
+ * List the workspace's sessions, most-recently-used first. Filter by the
1474
+ * metadata you attached at create time so you can find earlier sessions by
1475
+ * your own identifiers (customer id, environment, …). Multiple metadata
1476
+ * entries are AND-combined server-side.
1477
+ */
1478
+ listSessions(opts?: {
1479
+ metadata?: Record<string, string>;
1480
+ status?: "active" | "ended";
1481
+ limit?: number;
1482
+ offset?: number;
1483
+ }): Promise<SessionListResult>;
1484
+ /**
1485
+ * Fetch a session's conversation as realtime-style event frames so a UI can
1486
+ * restore the thread through the same handler it uses for the live stream.
1487
+ * Returns `user_message` / `assistant_message` frames (see the wire protocol
1488
+ * §6.2). Pass `lastMessages` to fetch only the most recent turns, or
1489
+ * `full: true` for the entire history (the default).
1490
+ */
1491
+ getSessionEvents(sessionId: string, opts?: {
1492
+ full?: boolean;
1493
+ lastMessages?: number;
1494
+ }): Promise<RunEvent[]>;
1353
1495
  /** Drive an existing run to completion (collect events, dispatch local tools). */
1354
1496
  driveRun(runId: string, handlers: LocalHandlers, opts?: {
1355
1497
  onAssistantDelta?: (delta: string) => void;
@@ -1389,6 +1531,11 @@ declare class MantyxClient {
1389
1531
  method: string;
1390
1532
  path: string;
1391
1533
  body?: unknown;
1534
+ /**
1535
+ * Optional query params. Array values are repeated (`?k=a&k=b`); `undefined`
1536
+ * entries are dropped. Used by the list endpoints (e.g. repeated `metadata`).
1537
+ */
1538
+ query?: Record<string, string | string[] | number | undefined>;
1392
1539
  timeoutMs?: number;
1393
1540
  }): Promise<T>;
1394
1541
  private requestWithRetry;
@@ -1436,6 +1583,11 @@ declare class AgentSession {
1436
1583
  * disable the platform judge for this single turn.
1437
1584
  */
1438
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;
1439
1591
  }): Promise<RunResult>;
1440
1592
  stream(prompt: string, opts?: {
1441
1593
  signal?: AbortSignal;
@@ -1445,8 +1597,24 @@ declare class AgentSession {
1445
1597
  loopDetection?: LoopDetection | false;
1446
1598
  toolBudgets?: ToolBudgets;
1447
1599
  supervisor?: Supervisor | false;
1600
+ plan?: PlanSpec;
1448
1601
  }): AsyncGenerator<RunEvent, void, void>;
1449
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>;
1450
1618
  history(): Promise<Array<{
1451
1619
  role: "user" | "assistant" | "system";
1452
1620
  content: string;
@@ -1495,4 +1663,4 @@ interface LocalHandlers {
1495
1663
  */
1496
1664
  declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
1497
1665
 
1498
- export { type RunEvent 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, MantyxToolError as O, type MantyxToolRef as P, type McpToolRef as Q, type ReasoningLevel as R, type ModelCatalog as S, type ToolRef as T, type ModelInfo as U, type OAuthToken as V, type OutputSchema as W, type RefreshOptions as X, type RefreshTokenSourceOptions as Y, type ResultEvent as Z, type RevokeOptions as _, AgentSession as a, type RunEventBase as a0, type RunModelInfo as a1, type RunResult as a2, type RunSpec as a3, type RunTokenUsage as a4, type ServerToolResultEvent as a5, type SessionInfo as a6, type SessionSpec as a7, type Supervisor as a8, type SupervisorAction as a9, type SupervisorEvent as aa, type ThinkingDeltaEvent as ab, type TokenRequestReason as ac, type TokenSource as ad, type ToolBudget as ae, type ToolBudgetExceededEvent as af, type ToolBudgets as ag, type ZodLikeObject as ah, defineLocalA2A as ai, defineLocalMcp as aj, defineLocalTool as ak, isLocalA2ATool as al, isLocalMcpServer as am, isLocalTool as an, mantyxA2A as ao, mantyxMcp as ap, mantyxPluginTool as aq, mantyxTool as ar, parseRunOutput as as, 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
@@ -886,6 +902,13 @@ interface RunSpec extends AgentSpecBase {
886
902
  signal?: AbortSignal;
887
903
  }
888
904
  type SessionSpec = AgentSpecBase;
905
+ /**
906
+ * Either a Zod schema (auto-converted to JSON Schema by the SDK) or a
907
+ * pre-shaped JSON Schema object. Mirrors {@link LocalToolSchemaInput} and
908
+ * Go's `OutputSchema.Schema any` (struct reflection) — pass your
909
+ * source-of-truth schema and the SDK serialises it for the wire.
910
+ */
911
+ type OutputSchemaValue = LocalToolSchemaInput;
889
912
  /**
890
913
  * Constrains the final assistant text to a JSON document matching a
891
914
  * JSON Schema. See {@link AgentSpecBase.outputSchema} for the full
@@ -894,8 +917,8 @@ type SessionSpec = AgentSpecBase;
894
917
  interface OutputSchema {
895
918
  /** Optional. Defaults to `"output"`. Must match `/^[a-zA-Z0-9_-]{1,64}$/`. */
896
919
  name?: string;
897
- /** Required. JSON Schema describing the final assistant text. Root must be a JSON object. */
898
- schema: Record<string, unknown>;
920
+ /** Required. Zod schema or JSON Schema describing the final assistant text. Root must be a JSON object. */
921
+ schema: OutputSchemaValue;
899
922
  }
900
923
  /**
901
924
  * Loop-detection thresholds. See {@link AgentSpecBase.loopDetection} for the
@@ -955,6 +978,44 @@ interface Supervisor {
955
978
  }
956
979
  /** Verdict from a run-supervisor review. */
957
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;
958
1019
  /**
959
1020
  * Per-run token totals attached to terminal `result` / `error` events
960
1021
  * (and to the `GET /agent-runs/:runId` snapshot) by MANTYX ≥ 2026-09.
@@ -1051,6 +1112,12 @@ interface RunResult {
1051
1112
  turns?: number;
1052
1113
  /** Resolved model that executed the run. See {@link RunModelInfo}. */
1053
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;
1054
1121
  }
1055
1122
  interface RunEventBase {
1056
1123
  seq: number;
@@ -1218,11 +1285,22 @@ interface SupervisorEvent extends RunEventBase {
1218
1285
  */
1219
1286
  llmCalls: number;
1220
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
+ }
1221
1297
  interface ResultEvent extends RunEventBase {
1222
1298
  type: "result";
1223
1299
  subtype: string;
1224
1300
  text?: string;
1225
1301
  error?: string;
1302
+ /** Present on plan-only terminal results. See {@link RunResult.plan}. */
1303
+ plan?: TaskPlan;
1226
1304
  /**
1227
1305
  * Per-run token totals. Present against MANTYX ≥ 2026-09 — see
1228
1306
  * {@link RunTokenUsage} and `docs/agent-runs-protocol.md` §7.1.
@@ -1287,7 +1365,17 @@ interface CancelledEvent extends RunEventBase {
1287
1365
  type: "cancelled";
1288
1366
  reason?: string;
1289
1367
  }
1290
- type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1368
+ /**
1369
+ * Replay/restore-only frame returned by {@link MantyxClient.getSessionEvents}
1370
+ * (and the `GET /agent-sessions/:id/events` endpoint). The live SSE stream
1371
+ * never emits this — the client already knows the prompt it sent — but
1372
+ * conversation restoration needs it to rebuild the user side of the thread.
1373
+ */
1374
+ interface UserMessageEvent extends RunEventBase {
1375
+ type: "user_message";
1376
+ text: string;
1377
+ }
1378
+ type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | TaskPlanEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1291
1379
  type: string;
1292
1380
  [key: string]: unknown;
1293
1381
  });
@@ -1306,6 +1394,25 @@ interface SessionInfo {
1306
1394
  /** Metadata that was attached to the session at create time, returned for observability. */
1307
1395
  metadata: Record<string, string>;
1308
1396
  }
1397
+ /** One row from {@link MantyxClient.listSessions}. */
1398
+ interface SessionSummary {
1399
+ sessionId: string;
1400
+ /** ISO 8601 creation timestamp. */
1401
+ creationDate: string;
1402
+ /** ISO 8601 timestamp of the most recent message run. */
1403
+ lastInteractionDate: string;
1404
+ /** Best-effort label derived from the first user prompt (sessions have no title). */
1405
+ summary: string;
1406
+ metadata: Record<string, string>;
1407
+ status: "active" | "ended";
1408
+ }
1409
+ /** Paginated result of {@link MantyxClient.listSessions}. */
1410
+ interface SessionListResult {
1411
+ total: number;
1412
+ limit: number;
1413
+ offset: number;
1414
+ sessions: SessionSummary[];
1415
+ }
1309
1416
  declare class MantyxClient {
1310
1417
  readonly options: Required<Pick<MantyxClientOptions, "workspaceSlug" | "baseUrl">> & {
1311
1418
  /**
@@ -1333,6 +1440,18 @@ declare class MantyxClient {
1333
1440
  constructor(opts: MantyxClientOptions);
1334
1441
  listModels(): Promise<ModelCatalog>;
1335
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>;
1336
1455
  streamAgent(spec: RunSpec): AsyncGenerator<RunEvent, void, void>;
1337
1456
  /**
1338
1457
  * Internal registry of client-resolved tool handlers. Exposed for callers
@@ -1350,6 +1469,29 @@ declare class MantyxClient {
1350
1469
  }): Promise<AgentSession>;
1351
1470
  endSession(sessionId: string): Promise<void>;
1352
1471
  getSessionInfo(sessionId: string): Promise<SessionInfo>;
1472
+ /**
1473
+ * List the workspace's sessions, most-recently-used first. Filter by the
1474
+ * metadata you attached at create time so you can find earlier sessions by
1475
+ * your own identifiers (customer id, environment, …). Multiple metadata
1476
+ * entries are AND-combined server-side.
1477
+ */
1478
+ listSessions(opts?: {
1479
+ metadata?: Record<string, string>;
1480
+ status?: "active" | "ended";
1481
+ limit?: number;
1482
+ offset?: number;
1483
+ }): Promise<SessionListResult>;
1484
+ /**
1485
+ * Fetch a session's conversation as realtime-style event frames so a UI can
1486
+ * restore the thread through the same handler it uses for the live stream.
1487
+ * Returns `user_message` / `assistant_message` frames (see the wire protocol
1488
+ * §6.2). Pass `lastMessages` to fetch only the most recent turns, or
1489
+ * `full: true` for the entire history (the default).
1490
+ */
1491
+ getSessionEvents(sessionId: string, opts?: {
1492
+ full?: boolean;
1493
+ lastMessages?: number;
1494
+ }): Promise<RunEvent[]>;
1353
1495
  /** Drive an existing run to completion (collect events, dispatch local tools). */
1354
1496
  driveRun(runId: string, handlers: LocalHandlers, opts?: {
1355
1497
  onAssistantDelta?: (delta: string) => void;
@@ -1389,6 +1531,11 @@ declare class MantyxClient {
1389
1531
  method: string;
1390
1532
  path: string;
1391
1533
  body?: unknown;
1534
+ /**
1535
+ * Optional query params. Array values are repeated (`?k=a&k=b`); `undefined`
1536
+ * entries are dropped. Used by the list endpoints (e.g. repeated `metadata`).
1537
+ */
1538
+ query?: Record<string, string | string[] | number | undefined>;
1392
1539
  timeoutMs?: number;
1393
1540
  }): Promise<T>;
1394
1541
  private requestWithRetry;
@@ -1436,6 +1583,11 @@ declare class AgentSession {
1436
1583
  * disable the platform judge for this single turn.
1437
1584
  */
1438
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;
1439
1591
  }): Promise<RunResult>;
1440
1592
  stream(prompt: string, opts?: {
1441
1593
  signal?: AbortSignal;
@@ -1445,8 +1597,24 @@ declare class AgentSession {
1445
1597
  loopDetection?: LoopDetection | false;
1446
1598
  toolBudgets?: ToolBudgets;
1447
1599
  supervisor?: Supervisor | false;
1600
+ plan?: PlanSpec;
1448
1601
  }): AsyncGenerator<RunEvent, void, void>;
1449
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>;
1450
1618
  history(): Promise<Array<{
1451
1619
  role: "user" | "assistant" | "system";
1452
1620
  content: string;
@@ -1495,4 +1663,4 @@ interface LocalHandlers {
1495
1663
  */
1496
1664
  declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
1497
1665
 
1498
- export { type RunEvent 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, MantyxToolError as O, type MantyxToolRef as P, type McpToolRef as Q, type ReasoningLevel as R, type ModelCatalog as S, type ToolRef as T, type ModelInfo as U, type OAuthToken as V, type OutputSchema as W, type RefreshOptions as X, type RefreshTokenSourceOptions as Y, type ResultEvent as Z, type RevokeOptions as _, AgentSession as a, type RunEventBase as a0, type RunModelInfo as a1, type RunResult as a2, type RunSpec as a3, type RunTokenUsage as a4, type ServerToolResultEvent as a5, type SessionInfo as a6, type SessionSpec as a7, type Supervisor as a8, type SupervisorAction as a9, type SupervisorEvent as aa, type ThinkingDeltaEvent as ab, type TokenRequestReason as ac, type TokenSource as ad, type ToolBudget as ae, type ToolBudgetExceededEvent as af, type ToolBudgets as ag, type ZodLikeObject as ah, defineLocalA2A as ai, defineLocalMcp as aj, defineLocalTool as ak, isLocalA2ATool as al, isLocalMcpServer as am, isLocalTool as an, mantyxA2A as ao, mantyxMcp as ap, mantyxPluginTool as aq, mantyxTool as ar, parseRunOutput as as, 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 };