@mantyx/sdk 2026.11.11 → 2026.11.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +76 -4
- package/dist/a2a-server.cjs +4 -0
- package/dist/a2a-server.d.ts +5 -1
- package/dist/a2a-server.js +5 -1
- package/dist/{chunk-KPAGE6FD.js → chunk-EXTS5Q3T.js} +304 -68
- package/dist/client.d.ts +286 -58
- package/dist/index.cjs +305 -70
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -4
- package/dist/tools.d.ts +46 -10
- package/dist/version.d.ts +1 -1
- package/docs/agent-runs-protocol.md +57 -29
- package/docs/wire-protocol.md +9 -48
- package/package.json +5 -5
package/dist/client.d.ts
CHANGED
|
@@ -222,6 +222,27 @@ export interface AgentSpecBase {
|
|
|
222
222
|
/** Alternate model for provider outages; remains active for the session after switching. */
|
|
223
223
|
fallbackModelId?: string;
|
|
224
224
|
tools?: ToolRef[];
|
|
225
|
+
/**
|
|
226
|
+
* Opt in to **tool search**: tools not marked `alwaysLoaded` are deferred
|
|
227
|
+
* and the model searches for the ones it needs, instead of every tool
|
|
228
|
+
* definition going into every request. Native on direct OpenAI (Responses,
|
|
229
|
+
* GPT-5.4 and later), the Anthropic API, and Gemini 3 and later; other
|
|
230
|
+
* providers receive every tool as usual. Off by default.
|
|
231
|
+
*
|
|
232
|
+
* Pair it with `alwaysLoaded: true` on the few tools the agent uses on most
|
|
233
|
+
* turns, and with `namespace` (plus {@link toolNamespaces}) to group tools
|
|
234
|
+
* the search can find together. With tool search on, MCP tools default to
|
|
235
|
+
* their server's name as namespace.
|
|
236
|
+
*/
|
|
237
|
+
toolSearch?: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Model-facing descriptions of the namespaces the tools use (the
|
|
240
|
+
* `namespace` option on every tool helper). Optional: a namespace without
|
|
241
|
+
* a description is described by its tool names. `name` must match
|
|
242
|
+
* `^[a-zA-Z0-9_]{1,64}$`, `description` is 1–2000 characters, at most 64
|
|
243
|
+
* entries.
|
|
244
|
+
*/
|
|
245
|
+
toolNamespaces?: ToolNamespace[];
|
|
225
246
|
/**
|
|
226
247
|
* Provider thinking strength: a string anchor (`"off" | "low" | "medium" |
|
|
227
248
|
* "high"`) or an integer in `0..100` (where `0` explicitly disables provider
|
|
@@ -313,9 +334,32 @@ export interface AgentSpecBase {
|
|
|
313
334
|
* the verdict by the time the event arrives.
|
|
314
335
|
*/
|
|
315
336
|
supervisor?: Supervisor | boolean;
|
|
337
|
+
/**
|
|
338
|
+
* Sub-agents. When enabled the agent gets a built-in `spawn_subagent`
|
|
339
|
+
* tool: each call starts a child run with a fresh context that works on
|
|
340
|
+
* the task it was handed and reports back; the parent waits until its
|
|
341
|
+
* children have reported. Sub-agents cannot spawn sub-agents.
|
|
342
|
+
*
|
|
343
|
+
* - `true` — the agent may start copies of itself (`{ self: true }`).
|
|
344
|
+
* - `{ agents: [...] }` — named sub-agents ({@link SubagentDefinition}),
|
|
345
|
+
* each with its own instructions, model and tools (the copy of itself is
|
|
346
|
+
* off unless `self` is set).
|
|
347
|
+
* - `{ self, agents, maxPerRun, maxConcurrent }` — both, with limits.
|
|
348
|
+
* - `false` / omitted — no sub-agents.
|
|
349
|
+
*
|
|
350
|
+
* Accepted on runs and session creation (not on individual session
|
|
351
|
+
* messages). Local tools declared in `agents[].tools` are registered as
|
|
352
|
+
* local handlers like top-level ones. The parent stream carries
|
|
353
|
+
* `subagent_started` / `subagent_result` events
|
|
354
|
+
* ({@link SubagentStartedEvent}, {@link SubagentResultEvent}); a
|
|
355
|
+
* sub-agent's local tool calls arrive on it as ordinary `local_tool_call`
|
|
356
|
+
* events tagged with `subagentRunId`, and the SDK runs your handler and
|
|
357
|
+
* posts the result as usual.
|
|
358
|
+
*/
|
|
359
|
+
subagents?: Subagents | boolean;
|
|
316
360
|
/**
|
|
317
361
|
* In-product **task plan** — live checklist emitted as `task_plan` SSE
|
|
318
|
-
* events
|
|
362
|
+
* events.
|
|
319
363
|
* Opt-in: exposes the host `update_task_plan` tool so the executing agent
|
|
320
364
|
* owns the checklist (no separate classifier/tracker LLM on executed runs).
|
|
321
365
|
*
|
|
@@ -323,13 +367,9 @@ export interface AgentSpecBase {
|
|
|
323
367
|
* - `"required"` — agent must initialize a plan before substantive tools.
|
|
324
368
|
* - `{ mode?, steps?, brief? }` — caller-seeded checklist (`mode` defaults
|
|
325
369
|
* to `"auto"`; use `"required"` to enforce).
|
|
326
|
-
* - `{ planOnly: true, steps?, brief? }` — produce the plan and **stop**
|
|
327
|
-
* without executing the agent loop; read the final checklist from
|
|
328
|
-
* {@link RunResult.plan}.
|
|
329
370
|
* - `"off"` / `false` — no planning (default when omitted).
|
|
330
371
|
*
|
|
331
|
-
* See `docs/agent-runs-protocol.md` §4.9.
|
|
332
|
-
* for plan-only runs.
|
|
372
|
+
* See `docs/agent-runs-protocol.md` §4.9.
|
|
333
373
|
*/
|
|
334
374
|
plan?: PlanSpec;
|
|
335
375
|
/**
|
|
@@ -372,6 +412,13 @@ export interface RunSpec extends AgentSpecBase {
|
|
|
372
412
|
signal?: AbortSignal;
|
|
373
413
|
}
|
|
374
414
|
export type SessionSpec = AgentSpecBase;
|
|
415
|
+
/** A model-facing namespace description. See {@link AgentSpecBase.toolNamespaces}. */
|
|
416
|
+
export interface ToolNamespace {
|
|
417
|
+
/** Namespace name, as used on the tools' `namespace`. Must match `^[a-zA-Z0-9_]{1,64}$`. */
|
|
418
|
+
name: string;
|
|
419
|
+
/** What the namespace's tools are for, as the model should read it (1–2000 characters). */
|
|
420
|
+
description: string;
|
|
421
|
+
}
|
|
375
422
|
/**
|
|
376
423
|
* Either a Zod schema (auto-converted to JSON Schema by the SDK) or a
|
|
377
424
|
* pre-shaped JSON Schema object. Mirrors {@link LocalToolSchemaInput} and
|
|
@@ -456,6 +503,68 @@ export interface Supervisor {
|
|
|
456
503
|
/** Mid-turn reasoning trigger, or `false` to disable. */
|
|
457
504
|
reasoningTrigger?: ReasoningTrigger | false;
|
|
458
505
|
}
|
|
506
|
+
/**
|
|
507
|
+
* Sub-agent configuration. See {@link AgentSpecBase.subagents} for the full
|
|
508
|
+
* semantics. Every field is optional; omitted ones use the MANTYX defaults.
|
|
509
|
+
*/
|
|
510
|
+
export interface Subagents {
|
|
511
|
+
/**
|
|
512
|
+
* The agent's copy of itself: `true`, `false`, or overrides. Default: on
|
|
513
|
+
* when `agents` is omitted or empty, off otherwise.
|
|
514
|
+
*/
|
|
515
|
+
self?: SubagentSelf | boolean;
|
|
516
|
+
/** Named sub-agents the parent can delegate to (at most 20). */
|
|
517
|
+
agents?: SubagentDefinition[];
|
|
518
|
+
/** Sub-agents one run may spawn over its lifetime. Default `10`, range `1..50`. */
|
|
519
|
+
maxPerRun?: number;
|
|
520
|
+
/** Sub-agents that may run at the same time. Default `5`, range `1..20`. */
|
|
521
|
+
maxConcurrent?: number;
|
|
522
|
+
}
|
|
523
|
+
/** Overrides for the agent's copy of itself ({@link Subagents.self}). */
|
|
524
|
+
export interface SubagentSelf {
|
|
525
|
+
/** Model the copy runs on. Defaults to the parent's model. */
|
|
526
|
+
modelId?: string;
|
|
527
|
+
/** Reasoning level of the copy. Defaults to the parent's. */
|
|
528
|
+
reasoningLevel?: ReasoningLevel;
|
|
529
|
+
/** Tool-turn cap of the copy. Defaults to the parent's `budgets.maxToolTurns`; range `1..200`. */
|
|
530
|
+
maxToolTurns?: number;
|
|
531
|
+
/**
|
|
532
|
+
* Names of the parent's tools the copy may use (default: all of them). An
|
|
533
|
+
* empty list gives the copy no tools.
|
|
534
|
+
*/
|
|
535
|
+
tools?: string[];
|
|
536
|
+
/** Extra instructions appended to the copy's system prompt (≤ 8000 chars). */
|
|
537
|
+
instructions?: string;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* A named sub-agent ({@link Subagents.agents}): its own instructions, model
|
|
541
|
+
* and tools. The parent model picks it by `name`, guided by `description`.
|
|
542
|
+
*/
|
|
543
|
+
export interface SubagentDefinition {
|
|
544
|
+
/** Unique name matching `/^[a-zA-Z0-9_-]{1,64}$/`; `"self"` is reserved. */
|
|
545
|
+
name: string;
|
|
546
|
+
/** When to use this sub-agent (shown to the parent model, 1..1000 chars). */
|
|
547
|
+
description: string;
|
|
548
|
+
/** The sub-agent's system prompt (1..64000 chars). */
|
|
549
|
+
systemPrompt: string;
|
|
550
|
+
modelId?: string;
|
|
551
|
+
fallbackModelId?: string;
|
|
552
|
+
reasoningLevel?: ReasoningLevel;
|
|
553
|
+
/**
|
|
554
|
+
* A string names one of the parent's tools (reused as declared there); a
|
|
555
|
+
* tool object is a tool of the sub-agent's own. Local tools declared here
|
|
556
|
+
* run in this process like top-level ones.
|
|
557
|
+
*/
|
|
558
|
+
tools?: Array<string | ToolRef>;
|
|
559
|
+
budgets?: {
|
|
560
|
+
maxToolTurns?: number;
|
|
561
|
+
};
|
|
562
|
+
toolBudgets?: ToolBudgets;
|
|
563
|
+
/** Constrains the sub-agent's report to a JSON document. */
|
|
564
|
+
outputSchema?: OutputSchema;
|
|
565
|
+
}
|
|
566
|
+
/** Final status of a sub-agent run, reported on {@link SubagentResultEvent}. */
|
|
567
|
+
export type SubagentStatus = "succeeded" | "failed" | "cancelled";
|
|
459
568
|
/** Mid-turn supervisor review trigger (reasoning span length / duration). */
|
|
460
569
|
export interface ReasoningTrigger {
|
|
461
570
|
/** Reasoning characters per span before review. Default `3000`, max `50000`. */
|
|
@@ -479,8 +588,8 @@ export interface TaskPlanStep {
|
|
|
479
588
|
status: TaskPlanStepStatus;
|
|
480
589
|
}
|
|
481
590
|
/**
|
|
482
|
-
* Structured task plan surfaced on `task_plan` events
|
|
483
|
-
*
|
|
591
|
+
* Structured task plan surfaced on `task_plan` events. See
|
|
592
|
+
* `docs/agent-runs-protocol.md` §4.9.
|
|
484
593
|
*/
|
|
485
594
|
export interface TaskPlan {
|
|
486
595
|
/** Wire format version (`2` on agent-owned plans). */
|
|
@@ -509,8 +618,6 @@ export interface TaskPlanTransition {
|
|
|
509
618
|
export interface PlanOptions {
|
|
510
619
|
/** `off` | `auto` | `required`. Defaults to `auto`. */
|
|
511
620
|
mode?: PlanMode;
|
|
512
|
-
/** When `true`, produce the plan and terminate without executing the agent loop. */
|
|
513
|
-
planOnly?: boolean;
|
|
514
621
|
/** One-line objective for a caller-provided plan. Clamped server-side. */
|
|
515
622
|
brief?: string;
|
|
516
623
|
/** Caller-provided checklist titles. */
|
|
@@ -518,14 +625,6 @@ export interface PlanOptions {
|
|
|
518
625
|
}
|
|
519
626
|
/** `"off"` | `"auto"` | `"required"` | `true`/`false` aliases | options object. */
|
|
520
627
|
export type PlanSpec = boolean | PlanMode | PlanOptions;
|
|
521
|
-
/**
|
|
522
|
-
* Build a {@link PlanSpec} for plan-only runs. Equivalent to
|
|
523
|
-
* `{ planOnly: true, steps?, brief? }`.
|
|
524
|
-
*/
|
|
525
|
-
export declare function planOnly(options?: {
|
|
526
|
-
steps?: string[];
|
|
527
|
-
brief?: string;
|
|
528
|
-
}): PlanOptions;
|
|
529
628
|
/**
|
|
530
629
|
* Per-run token totals attached to terminal `result` / `error` events
|
|
531
630
|
* (and to the `GET /agent-runs/:runId` snapshot) by MANTYX ≥ 2026-09.
|
|
@@ -624,12 +723,6 @@ export interface RunResult {
|
|
|
624
723
|
model?: RunModelInfo;
|
|
625
724
|
/** Structured-output enforcement metadata, when reported by the server. */
|
|
626
725
|
structuredOutput?: StructuredOutputInfo;
|
|
627
|
-
/**
|
|
628
|
-
* Final structured checklist for `planOnly` runs. Undefined for normal
|
|
629
|
-
* executed runs (use `task_plan` events for live progress). See
|
|
630
|
-
* `docs/agent-runs-protocol.md` §4.9.
|
|
631
|
-
*/
|
|
632
|
-
plan?: TaskPlan;
|
|
633
726
|
}
|
|
634
727
|
export interface RunEventBase {
|
|
635
728
|
seq: number;
|
|
@@ -677,6 +770,11 @@ export interface AssistantMessageEvent extends RunEventBase {
|
|
|
677
770
|
name: string;
|
|
678
771
|
input: Record<string, unknown>;
|
|
679
772
|
}>;
|
|
773
|
+
/**
|
|
774
|
+
* Tokens of this one LLM call, so live views can add up usage before the
|
|
775
|
+
* terminal event carries the run's total. Omitted by older servers.
|
|
776
|
+
*/
|
|
777
|
+
usage?: RunTokenUsage;
|
|
680
778
|
}
|
|
681
779
|
export interface ServerToolResultEvent extends RunEventBase {
|
|
682
780
|
type: "tool_result";
|
|
@@ -733,6 +831,13 @@ export interface LocalToolCallEvent extends RunEventBase {
|
|
|
733
831
|
version?: string;
|
|
734
832
|
[k: string]: unknown;
|
|
735
833
|
};
|
|
834
|
+
/**
|
|
835
|
+
* Set when the call was made by a sub-agent of this run (its run id) and
|
|
836
|
+
* mirrored onto this stream. The SDK dispatches it to the same local
|
|
837
|
+
* handler and posts the result to the run it is streaming; the server
|
|
838
|
+
* forwards it to the sub-agent.
|
|
839
|
+
*/
|
|
840
|
+
subagentRunId?: string;
|
|
736
841
|
}
|
|
737
842
|
export interface LocalToolResultInEvent extends RunEventBase {
|
|
738
843
|
type: "local_tool_result_in";
|
|
@@ -807,6 +912,50 @@ export interface SupervisorEvent extends RunEventBase {
|
|
|
807
912
|
*/
|
|
808
913
|
phase?: SupervisorPhase;
|
|
809
914
|
}
|
|
915
|
+
/**
|
|
916
|
+
* A sub-agent started (the parent's `spawn_subagent` call `toolUseId`).
|
|
917
|
+
* Non-terminal. See {@link AgentSpecBase.subagents}.
|
|
918
|
+
*/
|
|
919
|
+
export interface SubagentStartedEvent extends RunEventBase {
|
|
920
|
+
type: "subagent_started";
|
|
921
|
+
/** The parent's `spawn_subagent` tool call this sub-agent answers. */
|
|
922
|
+
toolUseId: string;
|
|
923
|
+
/** The sub-agent's own run id. */
|
|
924
|
+
runId: string;
|
|
925
|
+
/** Which sub-agent: `"self"` (a copy of the agent) or a {@link SubagentDefinition.name}. */
|
|
926
|
+
agent?: string;
|
|
927
|
+
/** Short description of the task the parent handed the sub-agent. */
|
|
928
|
+
description: string;
|
|
929
|
+
/**
|
|
930
|
+
* `true` when the parent model passed an `outputSchema` for the report, so
|
|
931
|
+
* the sub-agent's result is a JSON document matching it.
|
|
932
|
+
*/
|
|
933
|
+
structured?: boolean;
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* A sub-agent finished and reported back to the parent. Non-terminal: the
|
|
937
|
+
* parent resumes once every sub-agent it waits for has reported.
|
|
938
|
+
*/
|
|
939
|
+
export interface SubagentResultEvent extends RunEventBase {
|
|
940
|
+
type: "subagent_result";
|
|
941
|
+
/** The parent's `spawn_subagent` tool call this sub-agent answered. */
|
|
942
|
+
toolUseId: string;
|
|
943
|
+
/** The sub-agent's own run id. */
|
|
944
|
+
runId: string;
|
|
945
|
+
status: SubagentStatus;
|
|
946
|
+
/** The sub-agent's final report (on `succeeded`). */
|
|
947
|
+
result?: string;
|
|
948
|
+
/** Failure or cancellation message. */
|
|
949
|
+
error?: string;
|
|
950
|
+
/** The sub-agent's token totals. */
|
|
951
|
+
tokens?: RunTokenUsage;
|
|
952
|
+
/** Model invocations the sub-agent made. */
|
|
953
|
+
turns?: number;
|
|
954
|
+
/** Model the sub-agent ran on. */
|
|
955
|
+
model?: RunModelInfo;
|
|
956
|
+
/** Wall-clock duration of the sub-agent run. */
|
|
957
|
+
durationMs?: number;
|
|
958
|
+
}
|
|
810
959
|
/**
|
|
811
960
|
* Live checklist update for an in-product task plan. Non-terminal — the run
|
|
812
961
|
* continues until `result` / `error` / `cancelled`. See §4.9.
|
|
@@ -834,8 +983,6 @@ export interface ResultEvent extends RunEventBase {
|
|
|
834
983
|
subtype: string;
|
|
835
984
|
text?: string;
|
|
836
985
|
error?: string;
|
|
837
|
-
/** Present on plan-only terminal results. See {@link RunResult.plan}. */
|
|
838
|
-
plan?: TaskPlan;
|
|
839
986
|
/**
|
|
840
987
|
* Per-run token totals. Present against MANTYX ≥ 2026-09 — see
|
|
841
988
|
* {@link RunTokenUsage} and `docs/agent-runs-protocol.md` §7.1.
|
|
@@ -927,7 +1074,7 @@ export interface ModelFallbackEvent extends RunEventBase {
|
|
|
927
1074
|
primaryModelId?: string | null;
|
|
928
1075
|
fallbackModelId: string;
|
|
929
1076
|
}
|
|
930
|
-
export type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | ModelFallbackEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | TaskPlanEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
|
|
1077
|
+
export type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | ModelFallbackEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | SubagentStartedEvent | SubagentResultEvent | TaskPlanEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
|
|
931
1078
|
type: string;
|
|
932
1079
|
[key: string]: unknown;
|
|
933
1080
|
});
|
|
@@ -966,6 +1113,98 @@ export interface SessionListResult {
|
|
|
966
1113
|
nextCursor?: string | null;
|
|
967
1114
|
sessions: SessionSummary[];
|
|
968
1115
|
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Run lifecycle status. `succeeded`, `failed` and `cancelled` are terminal;
|
|
1118
|
+
* treat unknown values as non-terminal.
|
|
1119
|
+
*/
|
|
1120
|
+
export type RunStatus = "queued" | "running" | "awaiting_local_tool" | "succeeded" | "failed" | "cancelled";
|
|
1121
|
+
/** Full run snapshot returned by {@link MantyxClient.getRun}. */
|
|
1122
|
+
export interface RunInfo {
|
|
1123
|
+
id: string;
|
|
1124
|
+
/** Session the run belongs to, `null` for a one-shot run. */
|
|
1125
|
+
sessionId: string | null;
|
|
1126
|
+
status: RunStatus | (string & {});
|
|
1127
|
+
/** The agent spec the run executed with. */
|
|
1128
|
+
agentSpec: Record<string, unknown> | null;
|
|
1129
|
+
prompt: string | null;
|
|
1130
|
+
/** Final assistant text, once the run finished. */
|
|
1131
|
+
finalText: string | null;
|
|
1132
|
+
error: string | null;
|
|
1133
|
+
failureReason: string | null;
|
|
1134
|
+
/** Token totals, `null` until the run finished. */
|
|
1135
|
+
tokens: RunTokenUsage | null;
|
|
1136
|
+
turns: number | null;
|
|
1137
|
+
model: RunModelInfo | null;
|
|
1138
|
+
/** Sequence number of the last event in the run's stream. */
|
|
1139
|
+
lastSeq: number;
|
|
1140
|
+
metadata: Record<string, string>;
|
|
1141
|
+
/** The run whose `spawn_subagent` call started this one; `null` for a top-level run. */
|
|
1142
|
+
parentRunId: string | null;
|
|
1143
|
+
/** The parent's `spawn_subagent` tool call this run answers. */
|
|
1144
|
+
parentToolUseId: string | null;
|
|
1145
|
+
/** Short task label the parent model gave the sub-agent. */
|
|
1146
|
+
subagentLabel: string | null;
|
|
1147
|
+
/** `"self"` or the name of a {@link SubagentDefinition}. */
|
|
1148
|
+
subagentAgent: string | null;
|
|
1149
|
+
/** Sub-agents this run started (list them with {@link MantyxClient.listSubagents}). */
|
|
1150
|
+
subagentCount: number;
|
|
1151
|
+
createdAt: string;
|
|
1152
|
+
updatedAt: string;
|
|
1153
|
+
startedAt: string | null;
|
|
1154
|
+
completedAt: string | null;
|
|
1155
|
+
}
|
|
1156
|
+
/** One compact row from {@link MantyxClient.listRuns}. */
|
|
1157
|
+
export interface RunSummary {
|
|
1158
|
+
id: string;
|
|
1159
|
+
sessionId: string | null;
|
|
1160
|
+
status: RunStatus | (string & {});
|
|
1161
|
+
specName: string | null;
|
|
1162
|
+
modelId: string | null;
|
|
1163
|
+
/** Truncated input; fetch the run with {@link MantyxClient.getRun} for the full prompt. */
|
|
1164
|
+
inputPreview: string | null;
|
|
1165
|
+
/** Truncated final text (at most 500 characters). */
|
|
1166
|
+
outputPreview: string | null;
|
|
1167
|
+
/** Truncated error (at most 500 characters). */
|
|
1168
|
+
error: string | null;
|
|
1169
|
+
tokens: RunTokenUsage | null;
|
|
1170
|
+
turns: number | null;
|
|
1171
|
+
durationMs: number | null;
|
|
1172
|
+
toolCallCount: number;
|
|
1173
|
+
metadata: Record<string, string>;
|
|
1174
|
+
parentRunId: string | null;
|
|
1175
|
+
subagentLabel: string | null;
|
|
1176
|
+
subagentAgent: string | null;
|
|
1177
|
+
subagentCount: number;
|
|
1178
|
+
createdAt: string;
|
|
1179
|
+
completedAt: string | null;
|
|
1180
|
+
}
|
|
1181
|
+
/** Filters and paging for {@link MantyxClient.listRuns}. */
|
|
1182
|
+
export interface ListRunsOptions {
|
|
1183
|
+
/** Page size (server default 50, max 200). */
|
|
1184
|
+
limit?: number;
|
|
1185
|
+
/** Opaque `nextCursor` returned by the previous page. */
|
|
1186
|
+
cursor?: string;
|
|
1187
|
+
status?: RunStatus;
|
|
1188
|
+
modelId?: string;
|
|
1189
|
+
/** Only runs whose metadata contains every key/value pair (AND-combined). */
|
|
1190
|
+
metadata?: Record<string, string>;
|
|
1191
|
+
/**
|
|
1192
|
+
* List the sub-agent runs this run started. Without it only top-level runs
|
|
1193
|
+
* are listed.
|
|
1194
|
+
*/
|
|
1195
|
+
parentRunId?: string;
|
|
1196
|
+
/** Ask the server for the exact `total` (otherwise `null`). */
|
|
1197
|
+
includeTotal?: boolean;
|
|
1198
|
+
}
|
|
1199
|
+
/** Paginated result of {@link MantyxClient.listRuns}. */
|
|
1200
|
+
export interface RunListResult {
|
|
1201
|
+
/** Exact count when `includeTotal` was set, otherwise `null`. */
|
|
1202
|
+
total: number | null;
|
|
1203
|
+
limit: number;
|
|
1204
|
+
/** Pass back as `cursor` for the next page; `null` on the last page. */
|
|
1205
|
+
nextCursor: string | null;
|
|
1206
|
+
runs: RunSummary[];
|
|
1207
|
+
}
|
|
969
1208
|
/** One bounded page from {@link MantyxClient.getSessionEventsPage}. */
|
|
970
1209
|
export interface SessionEventsPage {
|
|
971
1210
|
sessionId: string;
|
|
@@ -1017,18 +1256,6 @@ export declare class MantyxClient {
|
|
|
1017
1256
|
deleteDecisionRun(runId: string): Promise<void>;
|
|
1018
1257
|
listModels(): Promise<ModelCatalog>;
|
|
1019
1258
|
runAgent(spec: RunSpec): Promise<RunResult>;
|
|
1020
|
-
/**
|
|
1021
|
-
* Plan-only run: classify (or accept caller `steps`) and return the
|
|
1022
|
-
* structured checklist without executing the agent loop. Sugar for
|
|
1023
|
-
* `runAgent({ ..., plan: planOnly({ steps, brief }) })`.
|
|
1024
|
-
*
|
|
1025
|
-
* The final checklist is on {@link RunResult.plan}; intermediate
|
|
1026
|
-
* progress is available via `task_plan` events when streaming.
|
|
1027
|
-
*/
|
|
1028
|
-
runPlan(spec: Omit<RunSpec, "plan"> & {
|
|
1029
|
-
steps?: string[];
|
|
1030
|
-
brief?: string;
|
|
1031
|
-
}): Promise<RunResult>;
|
|
1032
1259
|
streamAgent(spec: RunSpec): AsyncGenerator<RunEvent, void, void>;
|
|
1033
1260
|
/**
|
|
1034
1261
|
* Internal registry of client-resolved tool handlers. Exposed for callers
|
|
@@ -1092,6 +1319,22 @@ export declare class MantyxClient {
|
|
|
1092
1319
|
error?: string;
|
|
1093
1320
|
files?: ToolResultFile[];
|
|
1094
1321
|
}): Promise<void>;
|
|
1322
|
+
/**
|
|
1323
|
+
* Fetch a run's snapshot: status, final text, token totals, model, and
|
|
1324
|
+
* for a sub-agent run its parent (`parentRunId`, `parentToolUseId`).
|
|
1325
|
+
*/
|
|
1326
|
+
getRun(runId: string): Promise<RunInfo>;
|
|
1327
|
+
/**
|
|
1328
|
+
* List runs, newest first, one page at a time (follow `nextCursor`).
|
|
1329
|
+
* Without `parentRunId` only top-level runs are listed; with it, the
|
|
1330
|
+
* sub-agent runs that run started.
|
|
1331
|
+
*/
|
|
1332
|
+
listRuns(opts?: ListRunsOptions): Promise<RunListResult>;
|
|
1333
|
+
/**
|
|
1334
|
+
* Every sub-agent run the given run started, newest first. Pages through
|
|
1335
|
+
* {@link listRuns} with `parentRunId` until the last page.
|
|
1336
|
+
*/
|
|
1337
|
+
listSubagents(runId: string): Promise<RunSummary[]>;
|
|
1095
1338
|
cancelRun(runId: string): Promise<void>;
|
|
1096
1339
|
/**
|
|
1097
1340
|
* Record thumbs up/down feedback on a run. Requires the `feedback:write`
|
|
@@ -1141,7 +1384,10 @@ export declare class AgentSession {
|
|
|
1141
1384
|
readonly client: MantyxClient;
|
|
1142
1385
|
private readonly handlers;
|
|
1143
1386
|
private readonly tools;
|
|
1144
|
-
|
|
1387
|
+
private readonly ownedTools;
|
|
1388
|
+
constructor(client: MantyxClient, id: string, handlers: LocalHandlers, tools?: ToolRef[],
|
|
1389
|
+
/** Every ref the session resolved (its tools plus sub-agent tools); closed by {@link end}. */
|
|
1390
|
+
ownedTools?: ToolRef[]);
|
|
1145
1391
|
send(promptOrMessages: string | ConversationMessage[], opts?: {
|
|
1146
1392
|
onAssistantDelta?: (s: string) => void;
|
|
1147
1393
|
signal?: AbortSignal;
|
|
@@ -1219,24 +1465,6 @@ export declare class AgentSession {
|
|
|
1219
1465
|
turnInstructionsAuthority?: TurnInstructionsAuthority;
|
|
1220
1466
|
}): AsyncGenerator<RunEvent, void, void>;
|
|
1221
1467
|
private buildSessionMessageBody;
|
|
1222
|
-
/**
|
|
1223
|
-
* Plan-only session turn. Sugar for `send(prompt, { plan: planOnly(...) })`.
|
|
1224
|
-
*/
|
|
1225
|
-
runPlan(promptOrMessages: string | ConversationMessage[], opts?: {
|
|
1226
|
-
onAssistantDelta?: (s: string) => void;
|
|
1227
|
-
signal?: AbortSignal;
|
|
1228
|
-
metadata?: Record<string, string>;
|
|
1229
|
-
reasoningLevel?: ReasoningLevel;
|
|
1230
|
-
openRouterProvider?: OpenRouterProviderPreferences;
|
|
1231
|
-
/** Override the execution mode for this message; omission inherits the session default. */
|
|
1232
|
-
newLoop?: boolean;
|
|
1233
|
-
outputSchema?: OutputSchema;
|
|
1234
|
-
loopDetection?: LoopDetection | false;
|
|
1235
|
-
toolBudgets?: ToolBudgets;
|
|
1236
|
-
supervisor?: Supervisor | boolean;
|
|
1237
|
-
steps?: string[];
|
|
1238
|
-
brief?: string;
|
|
1239
|
-
}): Promise<RunResult>;
|
|
1240
1468
|
history(): Promise<ConversationMessage[]>;
|
|
1241
1469
|
info(): Promise<SessionInfo>;
|
|
1242
1470
|
events(opts?: {
|