@mantyx/sdk 0.19.0 → 0.20.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.
@@ -815,6 +815,174 @@ interface RunFeedbackResult {
815
815
  targetKind: string;
816
816
  agentRunId: string;
817
817
  }
818
+ /** Terminal statuses for {@link EvalRunDetail} and {@link EvalRunSummary}. */
819
+ type EvalRunStatus = "queued" | "running" | "succeeded" | "failed" | "cancelled";
820
+ /** One case in an inline eval dataset (`POST /eval-runs` `dataset`). */
821
+ interface InlineEvalCaseSpec {
822
+ name?: string;
823
+ input: {
824
+ role?: "user";
825
+ content: string;
826
+ expected?: string | null;
827
+ };
828
+ scorers?: Record<string, unknown>[];
829
+ toolMocks?: Record<string, unknown>;
830
+ tags?: string[];
831
+ }
832
+ /** Inline eval dataset blob (`POST /eval-runs` `dataset`). */
833
+ interface InlineEvalDatasetSpec {
834
+ name?: string;
835
+ toolMocks?: Record<string, unknown>;
836
+ cases: InlineEvalCaseSpec[];
837
+ }
838
+ /** Saved-agent overrides on `POST /eval-runs` (ignored for inline `agent`). */
839
+ interface AgentEvalOverrides {
840
+ systemPrompt?: string;
841
+ systemPromptAppend?: string;
842
+ model?: string;
843
+ llmProviderId?: string;
844
+ reasoningLevel?: "low" | "medium" | "high";
845
+ disableTools?: boolean;
846
+ toolAllowlist?: string[];
847
+ disabledMocks?: string[];
848
+ }
849
+ /** Body for `POST /eval-runs`. Exactly one of `datasetId`/`dataset` and `agentId`/`agent`. */
850
+ interface CreateEvalRunRequest {
851
+ datasetId?: string;
852
+ dataset?: InlineEvalDatasetSpec;
853
+ agentId?: string;
854
+ agent?: AgentSpecBase;
855
+ modelId?: string;
856
+ overrides?: AgentEvalOverrides;
857
+ }
858
+ interface EvalDatasetSummary {
859
+ id: string;
860
+ name: string;
861
+ description: string | null;
862
+ caseCount: number;
863
+ runCount: number;
864
+ createdAt: string;
865
+ updatedAt: string;
866
+ }
867
+ interface EvalDatasetList {
868
+ datasets: EvalDatasetSummary[];
869
+ }
870
+ interface EvalCase {
871
+ id: string;
872
+ name: string;
873
+ input: Record<string, unknown>;
874
+ scorers: Record<string, unknown>[];
875
+ tags: string[];
876
+ toolMocks: Record<string, unknown> | null;
877
+ createdAt: string;
878
+ updatedAt: string;
879
+ }
880
+ interface EvalDatasetDetail {
881
+ id: string;
882
+ name: string;
883
+ description: string | null;
884
+ toolMocks: Record<string, unknown> | null;
885
+ cases: EvalCase[];
886
+ createdAt: string;
887
+ updatedAt: string;
888
+ }
889
+ interface EvalRunAccepted {
890
+ runId: string;
891
+ status: string;
892
+ streamUrl: string;
893
+ }
894
+ interface EvalRunSummary {
895
+ id: string;
896
+ datasetId: string;
897
+ datasetName: string;
898
+ agentId: string | null;
899
+ inlineAgent: boolean;
900
+ status: EvalRunStatus;
901
+ totalCases: number;
902
+ completedCases: number;
903
+ passedCases: number;
904
+ score: number | null;
905
+ tokenUsage: Record<string, unknown> | null;
906
+ error: string | null;
907
+ agentOverrides: Record<string, unknown> | null;
908
+ startedAt: string | null;
909
+ finishedAt: string | null;
910
+ createdAt: string;
911
+ }
912
+ interface EvalCaseResult {
913
+ id: string;
914
+ caseId: string;
915
+ case: EvalCase;
916
+ finalText: string | null;
917
+ toolCalls: Record<string, unknown>[];
918
+ scores: Record<string, unknown>[];
919
+ passed: boolean;
920
+ score: number;
921
+ tokens: Record<string, unknown> | null;
922
+ latencyMs: number | null;
923
+ error: string | null;
924
+ createdAt: string;
925
+ }
926
+ interface EvalRunDetail extends EvalRunSummary {
927
+ inlineAgentSpec: Record<string, unknown> | null;
928
+ agentSpecSnapshot: Record<string, unknown> | null;
929
+ updatedAt: string;
930
+ results: EvalCaseResult[];
931
+ }
932
+ interface EvalRunList {
933
+ runs: EvalRunSummary[];
934
+ limit: number;
935
+ offset: number;
936
+ }
937
+ interface EvalRunCompareSide {
938
+ id: string;
939
+ agentId: string | null;
940
+ inlineAgent: boolean;
941
+ status: string;
942
+ totalCases: number;
943
+ completedCases: number;
944
+ passedCases: number;
945
+ score: number | null;
946
+ tokenUsage: Record<string, unknown> | null;
947
+ agentOverrides: Record<string, unknown> | null;
948
+ agentSpecSnapshot: Record<string, unknown> | null;
949
+ startedAt: string | null;
950
+ finishedAt: string | null;
951
+ createdAt: string;
952
+ }
953
+ interface EvalRunCompareCase {
954
+ caseId: string;
955
+ caseName: string;
956
+ caseInput: Record<string, unknown> | null;
957
+ a: Record<string, unknown> | null;
958
+ b: Record<string, unknown> | null;
959
+ }
960
+ interface EvalRunCompare {
961
+ datasetId: string;
962
+ datasetName: string;
963
+ runA: EvalRunCompareSide;
964
+ runB: EvalRunCompareSide;
965
+ cases: EvalRunCompareCase[];
966
+ }
967
+ /** One SSE frame from `GET /eval-runs/:runId/stream`. */
968
+ interface EvalRunEvent {
969
+ type: string;
970
+ [key: string]: unknown;
971
+ }
972
+ interface ListEvalRunsOptions {
973
+ datasetId?: string;
974
+ agentId?: string;
975
+ status?: EvalRunStatus | string;
976
+ limit?: number;
977
+ offset?: number;
978
+ }
979
+ interface RunEvalOptions {
980
+ /** Called for each SSE frame while the run is in flight. */
981
+ onEvent?: (event: EvalRunEvent) => void;
982
+ /** Poll interval when SSE is unavailable or ends early. Default 1000ms. */
983
+ pollIntervalMs?: number;
984
+ signal?: AbortSignal;
985
+ }
818
986
  interface MantyxClientOptions {
819
987
  /**
820
988
  * Workspace API key (token prefix `mantyx_`) **or** a MANTYX OAuth 2.0
@@ -848,7 +1016,8 @@ interface MantyxClientOptions {
848
1016
  *
849
1017
  * OAuth tokens additionally enforce per-route **scopes**
850
1018
  * (`runs:read`, `runs:write`, `sessions:read`, `sessions:write`,
851
- * `models:read`, `feedback:write`, `mantyx.identity:read`); see
1019
+ * `models:read`, `feedback:write`, `evals:read`, `evals:write`,
1020
+ * `mantyx.identity:read`); see
852
1021
  * `docs/agent-runs-protocol.md` §2.2 for the table. Missing scopes
853
1022
  * land as {@link MantyxScopeError} so callers can route the user
854
1023
  * back to a re-consent flow.
@@ -1679,6 +1848,22 @@ declare class MantyxClient {
1679
1848
  * the same response body. See `docs/agent-runs-protocol.md` §9a.
1680
1849
  */
1681
1850
  submitRunFeedback(runId: string, input: RunFeedbackInput): Promise<RunFeedbackResult>;
1851
+ listEvalDatasets(): Promise<EvalDatasetList>;
1852
+ getEvalDataset(datasetId: string): Promise<EvalDatasetDetail>;
1853
+ createEvalRun(spec: CreateEvalRunRequest): Promise<EvalRunAccepted>;
1854
+ listEvalRuns(options?: ListEvalRunsOptions): Promise<EvalRunList>;
1855
+ compareEvalRuns(runA: string, runB: string): Promise<EvalRunCompare>;
1856
+ getEvalRun(runId: string): Promise<EvalRunDetail>;
1857
+ streamEvalRun(runId: string, signal?: AbortSignal): AsyncGenerator<EvalRunEvent, void, void>;
1858
+ cancelEvalRun(runId: string): Promise<{
1859
+ ok: boolean;
1860
+ }>;
1861
+ /**
1862
+ * Start an eval run and block until it reaches a terminal status.
1863
+ * Tails the SSE stream for live `onEvent` callbacks while polling
1864
+ * `getEvalRun` until `status` is terminal.
1865
+ */
1866
+ runEval(spec: CreateEvalRunRequest, options?: RunEvalOptions): Promise<EvalRunDetail>;
1682
1867
  private absoluteUrl;
1683
1868
  /**
1684
1869
  * Resolve the bearer credential to send on the next request. With a
@@ -1841,4 +2026,4 @@ interface LocalHandlers {
1841
2026
  */
1842
2027
  declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
1843
2028
 
1844
- export { type McpToolRef as $, type A2AToolRef as A, MantyxAuthError as B, type CancelledEvent as C, DEFAULT_BASE_URL as D, type ErrorEvent as E, type MantyxClientOptions as F, MantyxError as G, type MantyxMcpOptions as H, type InputFileAttachment as I, MantyxNetworkError as J, MantyxOAuthClient as K, type LocalA2ATool as L, MantyxClient as M, type MantyxOAuthClientOptions as N, type OutputSchema as O, MantyxOAuthError as P, MantyxParseError as Q, type ReasoningLevel as R, type MantyxPluginToolRef as S, type ToolRef as T, MantyxRunError as U, type MantyxRunErrorInit as V, type MantyxRunErrorModel as W, type MantyxRunErrorTokens as X, MantyxScopeError as Y, MantyxToolError as Z, type MantyxToolRef as _, AgentSession as a, type MessageAttachment as a0, type ModelCatalog as a1, type ModelInfo as a2, type OAuthToken as a3, type OutputSchemaValue as a4, type PlanOptions as a5, type PlanSpec as a6, type ReasoningTrigger as a7, type RefreshOptions as a8, type RefreshTokenSourceOptions as a9, type TokenSource as aA, type ToolBudget as aB, type ToolBudgetExceededEvent as aC, type ToolBudgets as aD, type ToolResultFile as aE, type UserMessageEvent as aF, type ZodLikeObject as aG, defineLocalA2A as aH, defineLocalMcp as aI, defineLocalTool as aJ, inputFileAttachment as aK, inputFileUrlAttachment as aL, isLocalA2ATool as aM, isLocalMcpServer as aN, isLocalTool as aO, mantyxA2A as aP, mantyxMcp as aQ, mantyxPluginTool as aR, mantyxTool as aS, parseRunOutput as aT, planOnly as aU, type ResultEvent as aa, type RevokeOptions as ab, type RunEvent as ac, type RunEventBase as ad, type RunFeedbackInput as ae, type RunFeedbackResult as af, type RunFeedbackVerdict as ag, type RunModelInfo as ah, type RunResult as ai, type RunSpec as aj, type RunTokenUsage as ak, type ServerToolResultEvent as al, type SessionInfo as am, type SessionListResult as an, type SessionSpec as ao, type SessionSummary as ap, type Supervisor as aq, type SupervisorAction as ar, type SupervisorEvent as as, type SupervisorPhase as at, type TaskPlan as au, type TaskPlanEvent as av, type TaskPlanStep as aw, type TaskPlanStepStatus as ax, type ThinkingDeltaEvent as ay, type TokenRequestReason as az, type AgentSpecBase as b, type AssistantDeltaEvent as c, type AssistantMessageEvent as d, type AttachmentMetadata as e, type ConversationMessage as f, DEFAULT_OAUTH_BASE_URL as g, DEFAULT_REFRESH_SKEW_MS as h, type DefineLocalA2AOptions as i, type DefineLocalMcpOptions as j, type DefineLocalToolOptions as k, type InputFileAttachmentMetadata as l, type InputFileUrlAttachment as m, type InputFileUrlAttachmentMetadata as n, type LocalHandlers as o, type LocalMcpHttpTransport as p, type LocalMcpServer as q, type LocalMcpStdioTransport as r, type LocalTool as s, type LocalToolCallEvent as t, type LocalToolOutput as u, type LocalToolResult as v, type LocalToolResultInEvent as w, type LoopDetectedEvent as x, type LoopDetection as y, type MantyxA2AOptions as z };
2029
+ export { type LoopDetection as $, type A2AToolRef as A, type EvalRunSummary as B, type CancelledEvent as C, DEFAULT_BASE_URL as D, type ErrorEvent as E, type InlineEvalDatasetSpec as F, type InputFileAttachment as G, type InputFileAttachmentMetadata as H, type InlineEvalCaseSpec as I, type InputFileUrlAttachment as J, type InputFileUrlAttachmentMetadata as K, type ListEvalRunsOptions as L, MantyxClient as M, type LocalA2ATool as N, type OutputSchema as O, type LocalHandlers as P, type LocalMcpHttpTransport as Q, type ReasoningLevel as R, type LocalMcpServer as S, type ToolRef as T, type LocalMcpStdioTransport as U, type LocalTool as V, type LocalToolCallEvent as W, type LocalToolOutput as X, type LocalToolResult as Y, type LocalToolResultInEvent as Z, type LoopDetectedEvent as _, type AgentEvalOverrides as a, defineLocalA2A as a$, type MantyxA2AOptions as a0, MantyxAuthError as a1, type MantyxClientOptions as a2, MantyxError as a3, type MantyxMcpOptions as a4, MantyxNetworkError as a5, MantyxOAuthClient as a6, type MantyxOAuthClientOptions as a7, MantyxOAuthError as a8, MantyxParseError as a9, type RunFeedbackVerdict as aA, type RunModelInfo as aB, type RunResult as aC, type RunSpec as aD, type RunTokenUsage as aE, type ServerToolResultEvent as aF, type SessionInfo as aG, type SessionListResult as aH, type SessionSpec as aI, type SessionSummary as aJ, type Supervisor as aK, type SupervisorAction as aL, type SupervisorEvent as aM, type SupervisorPhase as aN, type TaskPlan as aO, type TaskPlanEvent as aP, type TaskPlanStep as aQ, type TaskPlanStepStatus as aR, type ThinkingDeltaEvent as aS, type TokenRequestReason as aT, type TokenSource as aU, type ToolBudget as aV, type ToolBudgetExceededEvent as aW, type ToolBudgets as aX, type ToolResultFile as aY, type UserMessageEvent as aZ, type ZodLikeObject as a_, type MantyxPluginToolRef as aa, MantyxRunError as ab, type MantyxRunErrorInit as ac, type MantyxRunErrorModel as ad, type MantyxRunErrorTokens as ae, MantyxScopeError as af, MantyxToolError as ag, type MantyxToolRef as ah, type McpToolRef as ai, type MessageAttachment as aj, type ModelCatalog as ak, type ModelInfo as al, type OAuthToken as am, type OutputSchemaValue as an, type PlanOptions as ao, type PlanSpec as ap, type ReasoningTrigger as aq, type RefreshOptions as ar, type RefreshTokenSourceOptions as as, type ResultEvent as at, type RevokeOptions as au, type RunEvalOptions as av, type RunEvent as aw, type RunEventBase as ax, type RunFeedbackInput as ay, type RunFeedbackResult as az, AgentSession as b, defineLocalMcp as b0, defineLocalTool as b1, inputFileAttachment as b2, inputFileUrlAttachment as b3, isLocalA2ATool as b4, isLocalMcpServer as b5, isLocalTool as b6, mantyxA2A as b7, mantyxMcp as b8, mantyxPluginTool as b9, mantyxTool as ba, parseRunOutput as bb, planOnly as bc, type AgentSpecBase as c, type AssistantDeltaEvent as d, type AssistantMessageEvent as e, type AttachmentMetadata as f, type ConversationMessage as g, type CreateEvalRunRequest as h, DEFAULT_OAUTH_BASE_URL as i, DEFAULT_REFRESH_SKEW_MS as j, type DefineLocalA2AOptions as k, type DefineLocalMcpOptions as l, type DefineLocalToolOptions as m, type EvalCase as n, type EvalCaseResult as o, type EvalDatasetDetail as p, type EvalDatasetList as q, type EvalDatasetSummary as r, type EvalRunAccepted as s, type EvalRunCompare as t, type EvalRunCompareCase as u, type EvalRunCompareSide as v, type EvalRunDetail as w, type EvalRunEvent as x, type EvalRunList as y, type EvalRunStatus as z };
@@ -815,6 +815,174 @@ interface RunFeedbackResult {
815
815
  targetKind: string;
816
816
  agentRunId: string;
817
817
  }
818
+ /** Terminal statuses for {@link EvalRunDetail} and {@link EvalRunSummary}. */
819
+ type EvalRunStatus = "queued" | "running" | "succeeded" | "failed" | "cancelled";
820
+ /** One case in an inline eval dataset (`POST /eval-runs` `dataset`). */
821
+ interface InlineEvalCaseSpec {
822
+ name?: string;
823
+ input: {
824
+ role?: "user";
825
+ content: string;
826
+ expected?: string | null;
827
+ };
828
+ scorers?: Record<string, unknown>[];
829
+ toolMocks?: Record<string, unknown>;
830
+ tags?: string[];
831
+ }
832
+ /** Inline eval dataset blob (`POST /eval-runs` `dataset`). */
833
+ interface InlineEvalDatasetSpec {
834
+ name?: string;
835
+ toolMocks?: Record<string, unknown>;
836
+ cases: InlineEvalCaseSpec[];
837
+ }
838
+ /** Saved-agent overrides on `POST /eval-runs` (ignored for inline `agent`). */
839
+ interface AgentEvalOverrides {
840
+ systemPrompt?: string;
841
+ systemPromptAppend?: string;
842
+ model?: string;
843
+ llmProviderId?: string;
844
+ reasoningLevel?: "low" | "medium" | "high";
845
+ disableTools?: boolean;
846
+ toolAllowlist?: string[];
847
+ disabledMocks?: string[];
848
+ }
849
+ /** Body for `POST /eval-runs`. Exactly one of `datasetId`/`dataset` and `agentId`/`agent`. */
850
+ interface CreateEvalRunRequest {
851
+ datasetId?: string;
852
+ dataset?: InlineEvalDatasetSpec;
853
+ agentId?: string;
854
+ agent?: AgentSpecBase;
855
+ modelId?: string;
856
+ overrides?: AgentEvalOverrides;
857
+ }
858
+ interface EvalDatasetSummary {
859
+ id: string;
860
+ name: string;
861
+ description: string | null;
862
+ caseCount: number;
863
+ runCount: number;
864
+ createdAt: string;
865
+ updatedAt: string;
866
+ }
867
+ interface EvalDatasetList {
868
+ datasets: EvalDatasetSummary[];
869
+ }
870
+ interface EvalCase {
871
+ id: string;
872
+ name: string;
873
+ input: Record<string, unknown>;
874
+ scorers: Record<string, unknown>[];
875
+ tags: string[];
876
+ toolMocks: Record<string, unknown> | null;
877
+ createdAt: string;
878
+ updatedAt: string;
879
+ }
880
+ interface EvalDatasetDetail {
881
+ id: string;
882
+ name: string;
883
+ description: string | null;
884
+ toolMocks: Record<string, unknown> | null;
885
+ cases: EvalCase[];
886
+ createdAt: string;
887
+ updatedAt: string;
888
+ }
889
+ interface EvalRunAccepted {
890
+ runId: string;
891
+ status: string;
892
+ streamUrl: string;
893
+ }
894
+ interface EvalRunSummary {
895
+ id: string;
896
+ datasetId: string;
897
+ datasetName: string;
898
+ agentId: string | null;
899
+ inlineAgent: boolean;
900
+ status: EvalRunStatus;
901
+ totalCases: number;
902
+ completedCases: number;
903
+ passedCases: number;
904
+ score: number | null;
905
+ tokenUsage: Record<string, unknown> | null;
906
+ error: string | null;
907
+ agentOverrides: Record<string, unknown> | null;
908
+ startedAt: string | null;
909
+ finishedAt: string | null;
910
+ createdAt: string;
911
+ }
912
+ interface EvalCaseResult {
913
+ id: string;
914
+ caseId: string;
915
+ case: EvalCase;
916
+ finalText: string | null;
917
+ toolCalls: Record<string, unknown>[];
918
+ scores: Record<string, unknown>[];
919
+ passed: boolean;
920
+ score: number;
921
+ tokens: Record<string, unknown> | null;
922
+ latencyMs: number | null;
923
+ error: string | null;
924
+ createdAt: string;
925
+ }
926
+ interface EvalRunDetail extends EvalRunSummary {
927
+ inlineAgentSpec: Record<string, unknown> | null;
928
+ agentSpecSnapshot: Record<string, unknown> | null;
929
+ updatedAt: string;
930
+ results: EvalCaseResult[];
931
+ }
932
+ interface EvalRunList {
933
+ runs: EvalRunSummary[];
934
+ limit: number;
935
+ offset: number;
936
+ }
937
+ interface EvalRunCompareSide {
938
+ id: string;
939
+ agentId: string | null;
940
+ inlineAgent: boolean;
941
+ status: string;
942
+ totalCases: number;
943
+ completedCases: number;
944
+ passedCases: number;
945
+ score: number | null;
946
+ tokenUsage: Record<string, unknown> | null;
947
+ agentOverrides: Record<string, unknown> | null;
948
+ agentSpecSnapshot: Record<string, unknown> | null;
949
+ startedAt: string | null;
950
+ finishedAt: string | null;
951
+ createdAt: string;
952
+ }
953
+ interface EvalRunCompareCase {
954
+ caseId: string;
955
+ caseName: string;
956
+ caseInput: Record<string, unknown> | null;
957
+ a: Record<string, unknown> | null;
958
+ b: Record<string, unknown> | null;
959
+ }
960
+ interface EvalRunCompare {
961
+ datasetId: string;
962
+ datasetName: string;
963
+ runA: EvalRunCompareSide;
964
+ runB: EvalRunCompareSide;
965
+ cases: EvalRunCompareCase[];
966
+ }
967
+ /** One SSE frame from `GET /eval-runs/:runId/stream`. */
968
+ interface EvalRunEvent {
969
+ type: string;
970
+ [key: string]: unknown;
971
+ }
972
+ interface ListEvalRunsOptions {
973
+ datasetId?: string;
974
+ agentId?: string;
975
+ status?: EvalRunStatus | string;
976
+ limit?: number;
977
+ offset?: number;
978
+ }
979
+ interface RunEvalOptions {
980
+ /** Called for each SSE frame while the run is in flight. */
981
+ onEvent?: (event: EvalRunEvent) => void;
982
+ /** Poll interval when SSE is unavailable or ends early. Default 1000ms. */
983
+ pollIntervalMs?: number;
984
+ signal?: AbortSignal;
985
+ }
818
986
  interface MantyxClientOptions {
819
987
  /**
820
988
  * Workspace API key (token prefix `mantyx_`) **or** a MANTYX OAuth 2.0
@@ -848,7 +1016,8 @@ interface MantyxClientOptions {
848
1016
  *
849
1017
  * OAuth tokens additionally enforce per-route **scopes**
850
1018
  * (`runs:read`, `runs:write`, `sessions:read`, `sessions:write`,
851
- * `models:read`, `feedback:write`, `mantyx.identity:read`); see
1019
+ * `models:read`, `feedback:write`, `evals:read`, `evals:write`,
1020
+ * `mantyx.identity:read`); see
852
1021
  * `docs/agent-runs-protocol.md` §2.2 for the table. Missing scopes
853
1022
  * land as {@link MantyxScopeError} so callers can route the user
854
1023
  * back to a re-consent flow.
@@ -1679,6 +1848,22 @@ declare class MantyxClient {
1679
1848
  * the same response body. See `docs/agent-runs-protocol.md` §9a.
1680
1849
  */
1681
1850
  submitRunFeedback(runId: string, input: RunFeedbackInput): Promise<RunFeedbackResult>;
1851
+ listEvalDatasets(): Promise<EvalDatasetList>;
1852
+ getEvalDataset(datasetId: string): Promise<EvalDatasetDetail>;
1853
+ createEvalRun(spec: CreateEvalRunRequest): Promise<EvalRunAccepted>;
1854
+ listEvalRuns(options?: ListEvalRunsOptions): Promise<EvalRunList>;
1855
+ compareEvalRuns(runA: string, runB: string): Promise<EvalRunCompare>;
1856
+ getEvalRun(runId: string): Promise<EvalRunDetail>;
1857
+ streamEvalRun(runId: string, signal?: AbortSignal): AsyncGenerator<EvalRunEvent, void, void>;
1858
+ cancelEvalRun(runId: string): Promise<{
1859
+ ok: boolean;
1860
+ }>;
1861
+ /**
1862
+ * Start an eval run and block until it reaches a terminal status.
1863
+ * Tails the SSE stream for live `onEvent` callbacks while polling
1864
+ * `getEvalRun` until `status` is terminal.
1865
+ */
1866
+ runEval(spec: CreateEvalRunRequest, options?: RunEvalOptions): Promise<EvalRunDetail>;
1682
1867
  private absoluteUrl;
1683
1868
  /**
1684
1869
  * Resolve the bearer credential to send on the next request. With a
@@ -1841,4 +2026,4 @@ interface LocalHandlers {
1841
2026
  */
1842
2027
  declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
1843
2028
 
1844
- export { type McpToolRef as $, type A2AToolRef as A, MantyxAuthError as B, type CancelledEvent as C, DEFAULT_BASE_URL as D, type ErrorEvent as E, type MantyxClientOptions as F, MantyxError as G, type MantyxMcpOptions as H, type InputFileAttachment as I, MantyxNetworkError as J, MantyxOAuthClient as K, type LocalA2ATool as L, MantyxClient as M, type MantyxOAuthClientOptions as N, type OutputSchema as O, MantyxOAuthError as P, MantyxParseError as Q, type ReasoningLevel as R, type MantyxPluginToolRef as S, type ToolRef as T, MantyxRunError as U, type MantyxRunErrorInit as V, type MantyxRunErrorModel as W, type MantyxRunErrorTokens as X, MantyxScopeError as Y, MantyxToolError as Z, type MantyxToolRef as _, AgentSession as a, type MessageAttachment as a0, type ModelCatalog as a1, type ModelInfo as a2, type OAuthToken as a3, type OutputSchemaValue as a4, type PlanOptions as a5, type PlanSpec as a6, type ReasoningTrigger as a7, type RefreshOptions as a8, type RefreshTokenSourceOptions as a9, type TokenSource as aA, type ToolBudget as aB, type ToolBudgetExceededEvent as aC, type ToolBudgets as aD, type ToolResultFile as aE, type UserMessageEvent as aF, type ZodLikeObject as aG, defineLocalA2A as aH, defineLocalMcp as aI, defineLocalTool as aJ, inputFileAttachment as aK, inputFileUrlAttachment as aL, isLocalA2ATool as aM, isLocalMcpServer as aN, isLocalTool as aO, mantyxA2A as aP, mantyxMcp as aQ, mantyxPluginTool as aR, mantyxTool as aS, parseRunOutput as aT, planOnly as aU, type ResultEvent as aa, type RevokeOptions as ab, type RunEvent as ac, type RunEventBase as ad, type RunFeedbackInput as ae, type RunFeedbackResult as af, type RunFeedbackVerdict as ag, type RunModelInfo as ah, type RunResult as ai, type RunSpec as aj, type RunTokenUsage as ak, type ServerToolResultEvent as al, type SessionInfo as am, type SessionListResult as an, type SessionSpec as ao, type SessionSummary as ap, type Supervisor as aq, type SupervisorAction as ar, type SupervisorEvent as as, type SupervisorPhase as at, type TaskPlan as au, type TaskPlanEvent as av, type TaskPlanStep as aw, type TaskPlanStepStatus as ax, type ThinkingDeltaEvent as ay, type TokenRequestReason as az, type AgentSpecBase as b, type AssistantDeltaEvent as c, type AssistantMessageEvent as d, type AttachmentMetadata as e, type ConversationMessage as f, DEFAULT_OAUTH_BASE_URL as g, DEFAULT_REFRESH_SKEW_MS as h, type DefineLocalA2AOptions as i, type DefineLocalMcpOptions as j, type DefineLocalToolOptions as k, type InputFileAttachmentMetadata as l, type InputFileUrlAttachment as m, type InputFileUrlAttachmentMetadata as n, type LocalHandlers as o, type LocalMcpHttpTransport as p, type LocalMcpServer as q, type LocalMcpStdioTransport as r, type LocalTool as s, type LocalToolCallEvent as t, type LocalToolOutput as u, type LocalToolResult as v, type LocalToolResultInEvent as w, type LoopDetectedEvent as x, type LoopDetection as y, type MantyxA2AOptions as z };
2029
+ export { type LoopDetection as $, type A2AToolRef as A, type EvalRunSummary as B, type CancelledEvent as C, DEFAULT_BASE_URL as D, type ErrorEvent as E, type InlineEvalDatasetSpec as F, type InputFileAttachment as G, type InputFileAttachmentMetadata as H, type InlineEvalCaseSpec as I, type InputFileUrlAttachment as J, type InputFileUrlAttachmentMetadata as K, type ListEvalRunsOptions as L, MantyxClient as M, type LocalA2ATool as N, type OutputSchema as O, type LocalHandlers as P, type LocalMcpHttpTransport as Q, type ReasoningLevel as R, type LocalMcpServer as S, type ToolRef as T, type LocalMcpStdioTransport as U, type LocalTool as V, type LocalToolCallEvent as W, type LocalToolOutput as X, type LocalToolResult as Y, type LocalToolResultInEvent as Z, type LoopDetectedEvent as _, type AgentEvalOverrides as a, defineLocalA2A as a$, type MantyxA2AOptions as a0, MantyxAuthError as a1, type MantyxClientOptions as a2, MantyxError as a3, type MantyxMcpOptions as a4, MantyxNetworkError as a5, MantyxOAuthClient as a6, type MantyxOAuthClientOptions as a7, MantyxOAuthError as a8, MantyxParseError as a9, type RunFeedbackVerdict as aA, type RunModelInfo as aB, type RunResult as aC, type RunSpec as aD, type RunTokenUsage as aE, type ServerToolResultEvent as aF, type SessionInfo as aG, type SessionListResult as aH, type SessionSpec as aI, type SessionSummary as aJ, type Supervisor as aK, type SupervisorAction as aL, type SupervisorEvent as aM, type SupervisorPhase as aN, type TaskPlan as aO, type TaskPlanEvent as aP, type TaskPlanStep as aQ, type TaskPlanStepStatus as aR, type ThinkingDeltaEvent as aS, type TokenRequestReason as aT, type TokenSource as aU, type ToolBudget as aV, type ToolBudgetExceededEvent as aW, type ToolBudgets as aX, type ToolResultFile as aY, type UserMessageEvent as aZ, type ZodLikeObject as a_, type MantyxPluginToolRef as aa, MantyxRunError as ab, type MantyxRunErrorInit as ac, type MantyxRunErrorModel as ad, type MantyxRunErrorTokens as ae, MantyxScopeError as af, MantyxToolError as ag, type MantyxToolRef as ah, type McpToolRef as ai, type MessageAttachment as aj, type ModelCatalog as ak, type ModelInfo as al, type OAuthToken as am, type OutputSchemaValue as an, type PlanOptions as ao, type PlanSpec as ap, type ReasoningTrigger as aq, type RefreshOptions as ar, type RefreshTokenSourceOptions as as, type ResultEvent as at, type RevokeOptions as au, type RunEvalOptions as av, type RunEvent as aw, type RunEventBase as ax, type RunFeedbackInput as ay, type RunFeedbackResult as az, AgentSession as b, defineLocalMcp as b0, defineLocalTool as b1, inputFileAttachment as b2, inputFileUrlAttachment as b3, isLocalA2ATool as b4, isLocalMcpServer as b5, isLocalTool as b6, mantyxA2A as b7, mantyxMcp as b8, mantyxPluginTool as b9, mantyxTool as ba, parseRunOutput as bb, planOnly as bc, type AgentSpecBase as c, type AssistantDeltaEvent as d, type AssistantMessageEvent as e, type AttachmentMetadata as f, type ConversationMessage as g, type CreateEvalRunRequest as h, DEFAULT_OAUTH_BASE_URL as i, DEFAULT_REFRESH_SKEW_MS as j, type DefineLocalA2AOptions as k, type DefineLocalMcpOptions as l, type DefineLocalToolOptions as m, type EvalCase as n, type EvalCaseResult as o, type EvalDatasetDetail as p, type EvalDatasetList as q, type EvalDatasetSummary as r, type EvalRunAccepted as s, type EvalRunCompare as t, type EvalRunCompareCase as u, type EvalRunCompareSide as v, type EvalRunDetail as w, type EvalRunEvent as x, type EvalRunList as y, type EvalRunStatus as z };
@@ -1,4 +1,4 @@
1
- import { ai as RunResult, M as MantyxClient, R as ReasoningLevel, s as LocalTool } from './client-IcPVJ_lf.cjs';
1
+ import { aC as RunResult, M as MantyxClient, R as ReasoningLevel, V as LocalTool } from './client-D4-MQANp.cjs';
2
2
 
3
3
  /** Scroll direction shared by `scroll_at` / `scroll_document`. */
4
4
  type ScrollDirection = "up" | "down" | "left" | "right";
@@ -1,4 +1,4 @@
1
- import { ai as RunResult, M as MantyxClient, R as ReasoningLevel, s as LocalTool } from './client-IcPVJ_lf.js';
1
+ import { aC as RunResult, M as MantyxClient, R as ReasoningLevel, V as LocalTool } from './client-D4-MQANp.js';
2
2
 
3
3
  /** Scroll direction shared by `scroll_at` / `scroll_document`. */
4
4
  type ScrollDirection = "up" | "down" | "left" | "right";
package/dist/index.cjs CHANGED
@@ -740,6 +740,7 @@ function inputFileUrlAttachment(opts) {
740
740
  return { type: "input_file_url", ...opts };
741
741
  }
742
742
  var RUN_FEEDBACK_EXPLANATION_MAX = 8e3;
743
+ var EVAL_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "failed", "cancelled"]);
743
744
  function planOnly(options = {}) {
744
745
  return {
745
746
  planOnly: true,
@@ -1129,6 +1130,113 @@ var MantyxClient = class {
1129
1130
  body
1130
1131
  });
1131
1132
  }
1133
+ // --------------------------------------------------------------- Evals
1134
+ async listEvalDatasets() {
1135
+ return this.request({
1136
+ method: "GET",
1137
+ path: "/eval-datasets"
1138
+ });
1139
+ }
1140
+ async getEvalDataset(datasetId) {
1141
+ return this.request({
1142
+ method: "GET",
1143
+ path: `/eval-datasets/${encodeURIComponent(datasetId)}`
1144
+ });
1145
+ }
1146
+ async createEvalRun(spec) {
1147
+ return this.request({
1148
+ method: "POST",
1149
+ path: "/eval-runs",
1150
+ body: serializeCreateEvalRunRequest(spec)
1151
+ });
1152
+ }
1153
+ async listEvalRuns(options = {}) {
1154
+ const params = new URLSearchParams();
1155
+ if (options.datasetId) params.set("datasetId", options.datasetId);
1156
+ if (options.agentId) params.set("agentId", options.agentId);
1157
+ if (options.status) params.set("status", options.status);
1158
+ if (options.limit !== void 0) params.set("limit", String(options.limit));
1159
+ if (options.offset !== void 0) params.set("offset", String(options.offset));
1160
+ const qs = params.toString();
1161
+ return this.request({
1162
+ method: "GET",
1163
+ path: qs ? `/eval-runs?${qs}` : "/eval-runs"
1164
+ });
1165
+ }
1166
+ async compareEvalRuns(runA, runB) {
1167
+ const params = new URLSearchParams({ a: runA, b: runB });
1168
+ return this.request({
1169
+ method: "GET",
1170
+ path: `/eval-runs/compare?${params}`
1171
+ });
1172
+ }
1173
+ async getEvalRun(runId) {
1174
+ return this.request({
1175
+ method: "GET",
1176
+ path: `/eval-runs/${encodeURIComponent(runId)}`
1177
+ });
1178
+ }
1179
+ async *streamEvalRun(runId, signal) {
1180
+ const url = this.absoluteUrl(`/eval-runs/${encodeURIComponent(runId)}/stream`);
1181
+ const res = await this.openSseStream(url, 0, signal);
1182
+ try {
1183
+ for await (const frame of readSseStream(res.body, { signal })) {
1184
+ if (!frame.data) continue;
1185
+ let parsed;
1186
+ try {
1187
+ parsed = JSON.parse(frame.data);
1188
+ } catch (err) {
1189
+ throw new MantyxParseError(
1190
+ `invalid eval SSE JSON: ${frame.data.slice(0, 200)}`,
1191
+ frame.data,
1192
+ { cause: err }
1193
+ );
1194
+ }
1195
+ yield parsed;
1196
+ if (parsed.type === "run_completed" || parsed.type === "run_error" || parsed.type === "run_cancelled") {
1197
+ return;
1198
+ }
1199
+ }
1200
+ } finally {
1201
+ await res.body?.cancel().catch(() => void 0);
1202
+ }
1203
+ }
1204
+ async cancelEvalRun(runId) {
1205
+ return this.request({
1206
+ method: "POST",
1207
+ path: `/eval-runs/${encodeURIComponent(runId)}/cancel`
1208
+ });
1209
+ }
1210
+ /**
1211
+ * Start an eval run and block until it reaches a terminal status.
1212
+ * Tails the SSE stream for live `onEvent` callbacks while polling
1213
+ * `getEvalRun` until `status` is terminal.
1214
+ */
1215
+ async runEval(spec, options = {}) {
1216
+ const accepted = await this.createEvalRun(spec);
1217
+ const pollMs = options.pollIntervalMs ?? 1e3;
1218
+ const streamDone = (async () => {
1219
+ try {
1220
+ for await (const ev of this.streamEvalRun(accepted.runId, options.signal)) {
1221
+ options.onEvent?.(ev);
1222
+ }
1223
+ } catch (err) {
1224
+ if (!(err instanceof MantyxNetworkError)) throw err;
1225
+ }
1226
+ })();
1227
+ try {
1228
+ while (true) {
1229
+ if (options.signal?.aborted) {
1230
+ throw new MantyxNetworkError("eval run wait aborted", { cause: options.signal.reason });
1231
+ }
1232
+ const detail = await this.getEvalRun(accepted.runId);
1233
+ if (EVAL_TERMINAL_STATUSES.has(detail.status)) return detail;
1234
+ await sleep(pollMs);
1235
+ }
1236
+ } finally {
1237
+ await streamDone.catch(() => void 0);
1238
+ }
1239
+ }
1132
1240
  // -------------------------------------------------------------- HTTP
1133
1241
  absoluteUrl(path) {
1134
1242
  return `${this.options.baseUrl}/api/v1/workspaces/${encodeURIComponent(this.options.workspaceSlug)}${path}`;
@@ -1394,6 +1502,30 @@ function serializeAgentSpec(spec, extra = {}) {
1394
1502
  Object.assign(body, serializeTurnInput(extra));
1395
1503
  return body;
1396
1504
  }
1505
+ function serializeCreateEvalRunRequest(spec) {
1506
+ const hasDataset = spec.datasetId !== void 0 || spec.dataset !== void 0;
1507
+ const hasAgent = spec.agentId !== void 0 || spec.agent !== void 0;
1508
+ if (!hasDataset) {
1509
+ throw new MantyxError("createEvalRun requires exactly one of `datasetId` or `dataset`");
1510
+ }
1511
+ if (spec.datasetId !== void 0 && spec.dataset !== void 0) {
1512
+ throw new MantyxError("createEvalRun accepts only one of `datasetId` or `dataset`");
1513
+ }
1514
+ if (!hasAgent) {
1515
+ throw new MantyxError("createEvalRun requires exactly one of `agentId` or `agent`");
1516
+ }
1517
+ if (spec.agentId !== void 0 && spec.agent !== void 0) {
1518
+ throw new MantyxError("createEvalRun accepts only one of `agentId` or `agent`");
1519
+ }
1520
+ const body = {};
1521
+ if (spec.datasetId) body.datasetId = spec.datasetId;
1522
+ if (spec.dataset) body.dataset = spec.dataset;
1523
+ if (spec.agentId) body.agentId = spec.agentId;
1524
+ if (spec.agent) body.agent = serializeAgentSpec(spec.agent);
1525
+ if (spec.modelId) body.modelId = spec.modelId;
1526
+ if (spec.overrides) body.overrides = spec.overrides;
1527
+ return body;
1528
+ }
1397
1529
  function serializeToolRefs(tools) {
1398
1530
  return tools.map((t) => {
1399
1531
  switch (t.kind) {
@@ -2401,7 +2533,7 @@ async function runComputerUse(opts) {
2401
2533
  }
2402
2534
 
2403
2535
  // src/version.ts
2404
- var SDK_VERSION = "0.19.0";
2536
+ var SDK_VERSION = "0.20.0";
2405
2537
  // Annotate the CommonJS export names for ESM import in node:
2406
2538
  0 && (module.exports = {
2407
2539
  AgentSession,