@mantyx/sdk 0.19.0 → 0.21.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,178 @@ 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
+ /** Client-resolved tools merged onto a saved `agentId` eval run. */
856
+ tools?: ToolRef[];
857
+ modelId?: string;
858
+ overrides?: AgentEvalOverrides;
859
+ }
860
+ interface EvalDatasetSummary {
861
+ id: string;
862
+ name: string;
863
+ description: string | null;
864
+ caseCount: number;
865
+ runCount: number;
866
+ createdAt: string;
867
+ updatedAt: string;
868
+ }
869
+ interface EvalDatasetList {
870
+ datasets: EvalDatasetSummary[];
871
+ }
872
+ interface EvalCase {
873
+ id: string;
874
+ name: string;
875
+ input: Record<string, unknown>;
876
+ scorers: Record<string, unknown>[];
877
+ tags: string[];
878
+ toolMocks: Record<string, unknown> | null;
879
+ createdAt: string;
880
+ updatedAt: string;
881
+ }
882
+ interface EvalDatasetDetail {
883
+ id: string;
884
+ name: string;
885
+ description: string | null;
886
+ toolMocks: Record<string, unknown> | null;
887
+ cases: EvalCase[];
888
+ createdAt: string;
889
+ updatedAt: string;
890
+ }
891
+ interface EvalRunAccepted {
892
+ runId: string;
893
+ status: string;
894
+ streamUrl: string;
895
+ }
896
+ interface EvalRunSummary {
897
+ id: string;
898
+ datasetId: string;
899
+ datasetName: string;
900
+ agentId: string | null;
901
+ inlineAgent: boolean;
902
+ status: EvalRunStatus;
903
+ totalCases: number;
904
+ completedCases: number;
905
+ passedCases: number;
906
+ score: number | null;
907
+ tokenUsage: Record<string, unknown> | null;
908
+ error: string | null;
909
+ agentOverrides: Record<string, unknown> | null;
910
+ startedAt: string | null;
911
+ finishedAt: string | null;
912
+ createdAt: string;
913
+ }
914
+ interface EvalCaseResult {
915
+ id: string;
916
+ caseId: string;
917
+ case: EvalCase;
918
+ finalText: string | null;
919
+ toolCalls: Record<string, unknown>[];
920
+ scores: Record<string, unknown>[];
921
+ passed: boolean;
922
+ score: number;
923
+ tokens: Record<string, unknown> | null;
924
+ latencyMs: number | null;
925
+ error: string | null;
926
+ createdAt: string;
927
+ }
928
+ interface EvalRunDetail extends EvalRunSummary {
929
+ inlineAgentSpec: Record<string, unknown> | null;
930
+ agentSpecSnapshot: Record<string, unknown> | null;
931
+ updatedAt: string;
932
+ results: EvalCaseResult[];
933
+ }
934
+ interface EvalRunList {
935
+ runs: EvalRunSummary[];
936
+ limit: number;
937
+ offset: number;
938
+ }
939
+ interface EvalRunCompareSide {
940
+ id: string;
941
+ agentId: string | null;
942
+ inlineAgent: boolean;
943
+ status: string;
944
+ totalCases: number;
945
+ completedCases: number;
946
+ passedCases: number;
947
+ score: number | null;
948
+ tokenUsage: Record<string, unknown> | null;
949
+ agentOverrides: Record<string, unknown> | null;
950
+ agentSpecSnapshot: Record<string, unknown> | null;
951
+ startedAt: string | null;
952
+ finishedAt: string | null;
953
+ createdAt: string;
954
+ }
955
+ interface EvalRunCompareCase {
956
+ caseId: string;
957
+ caseName: string;
958
+ caseInput: Record<string, unknown> | null;
959
+ a: Record<string, unknown> | null;
960
+ b: Record<string, unknown> | null;
961
+ }
962
+ interface EvalRunCompare {
963
+ datasetId: string;
964
+ datasetName: string;
965
+ runA: EvalRunCompareSide;
966
+ runB: EvalRunCompareSide;
967
+ cases: EvalRunCompareCase[];
968
+ }
969
+ /** One SSE frame from `GET /eval-runs/:runId/stream`. */
970
+ interface EvalRunEvent {
971
+ type: string;
972
+ [key: string]: unknown;
973
+ }
974
+ interface ListEvalRunsOptions {
975
+ datasetId?: string;
976
+ agentId?: string;
977
+ status?: EvalRunStatus | string;
978
+ limit?: number;
979
+ offset?: number;
980
+ }
981
+ interface RunEvalOptions {
982
+ /** Client-resolved tools to register for the eval run. */
983
+ tools?: ToolRef[];
984
+ /** Called for each SSE frame while the run is in flight. */
985
+ onEvent?: (event: EvalRunEvent) => void;
986
+ /** Poll interval when SSE is unavailable or ends early. Default 1000ms. */
987
+ pollIntervalMs?: number;
988
+ signal?: AbortSignal;
989
+ }
818
990
  interface MantyxClientOptions {
819
991
  /**
820
992
  * Workspace API key (token prefix `mantyx_`) **or** a MANTYX OAuth 2.0
@@ -848,7 +1020,8 @@ interface MantyxClientOptions {
848
1020
  *
849
1021
  * OAuth tokens additionally enforce per-route **scopes**
850
1022
  * (`runs:read`, `runs:write`, `sessions:read`, `sessions:write`,
851
- * `models:read`, `feedback:write`, `mantyx.identity:read`); see
1023
+ * `models:read`, `feedback:write`, `evals:read`, `evals:write`,
1024
+ * `mantyx.identity:read`); see
852
1025
  * `docs/agent-runs-protocol.md` §2.2 for the table. Missing scopes
853
1026
  * land as {@link MantyxScopeError} so callers can route the user
854
1027
  * back to a re-consent flow.
@@ -1679,6 +1852,22 @@ declare class MantyxClient {
1679
1852
  * the same response body. See `docs/agent-runs-protocol.md` §9a.
1680
1853
  */
1681
1854
  submitRunFeedback(runId: string, input: RunFeedbackInput): Promise<RunFeedbackResult>;
1855
+ listEvalDatasets(): Promise<EvalDatasetList>;
1856
+ getEvalDataset(datasetId: string): Promise<EvalDatasetDetail>;
1857
+ createEvalRun(spec: CreateEvalRunRequest): Promise<EvalRunAccepted>;
1858
+ listEvalRuns(options?: ListEvalRunsOptions): Promise<EvalRunList>;
1859
+ compareEvalRuns(runA: string, runB: string): Promise<EvalRunCompare>;
1860
+ getEvalRun(runId: string): Promise<EvalRunDetail>;
1861
+ streamEvalRun(runId: string, signal?: AbortSignal): AsyncGenerator<EvalRunEvent, void, void>;
1862
+ cancelEvalRun(runId: string): Promise<{
1863
+ ok: boolean;
1864
+ }>;
1865
+ /**
1866
+ * Start an eval run and block until it reaches a terminal status.
1867
+ * Tails the SSE stream for live `onEvent` callbacks while polling
1868
+ * `getEvalRun` until `status` is terminal.
1869
+ */
1870
+ runEval(spec: CreateEvalRunRequest, options?: RunEvalOptions): Promise<EvalRunDetail>;
1682
1871
  private absoluteUrl;
1683
1872
  /**
1684
1873
  * Resolve the bearer credential to send on the next request. With a
@@ -1841,4 +2030,4 @@ interface LocalHandlers {
1841
2030
  */
1842
2031
  declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
1843
2032
 
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 };
2033
+ 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,178 @@ 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
+ /** Client-resolved tools merged onto a saved `agentId` eval run. */
856
+ tools?: ToolRef[];
857
+ modelId?: string;
858
+ overrides?: AgentEvalOverrides;
859
+ }
860
+ interface EvalDatasetSummary {
861
+ id: string;
862
+ name: string;
863
+ description: string | null;
864
+ caseCount: number;
865
+ runCount: number;
866
+ createdAt: string;
867
+ updatedAt: string;
868
+ }
869
+ interface EvalDatasetList {
870
+ datasets: EvalDatasetSummary[];
871
+ }
872
+ interface EvalCase {
873
+ id: string;
874
+ name: string;
875
+ input: Record<string, unknown>;
876
+ scorers: Record<string, unknown>[];
877
+ tags: string[];
878
+ toolMocks: Record<string, unknown> | null;
879
+ createdAt: string;
880
+ updatedAt: string;
881
+ }
882
+ interface EvalDatasetDetail {
883
+ id: string;
884
+ name: string;
885
+ description: string | null;
886
+ toolMocks: Record<string, unknown> | null;
887
+ cases: EvalCase[];
888
+ createdAt: string;
889
+ updatedAt: string;
890
+ }
891
+ interface EvalRunAccepted {
892
+ runId: string;
893
+ status: string;
894
+ streamUrl: string;
895
+ }
896
+ interface EvalRunSummary {
897
+ id: string;
898
+ datasetId: string;
899
+ datasetName: string;
900
+ agentId: string | null;
901
+ inlineAgent: boolean;
902
+ status: EvalRunStatus;
903
+ totalCases: number;
904
+ completedCases: number;
905
+ passedCases: number;
906
+ score: number | null;
907
+ tokenUsage: Record<string, unknown> | null;
908
+ error: string | null;
909
+ agentOverrides: Record<string, unknown> | null;
910
+ startedAt: string | null;
911
+ finishedAt: string | null;
912
+ createdAt: string;
913
+ }
914
+ interface EvalCaseResult {
915
+ id: string;
916
+ caseId: string;
917
+ case: EvalCase;
918
+ finalText: string | null;
919
+ toolCalls: Record<string, unknown>[];
920
+ scores: Record<string, unknown>[];
921
+ passed: boolean;
922
+ score: number;
923
+ tokens: Record<string, unknown> | null;
924
+ latencyMs: number | null;
925
+ error: string | null;
926
+ createdAt: string;
927
+ }
928
+ interface EvalRunDetail extends EvalRunSummary {
929
+ inlineAgentSpec: Record<string, unknown> | null;
930
+ agentSpecSnapshot: Record<string, unknown> | null;
931
+ updatedAt: string;
932
+ results: EvalCaseResult[];
933
+ }
934
+ interface EvalRunList {
935
+ runs: EvalRunSummary[];
936
+ limit: number;
937
+ offset: number;
938
+ }
939
+ interface EvalRunCompareSide {
940
+ id: string;
941
+ agentId: string | null;
942
+ inlineAgent: boolean;
943
+ status: string;
944
+ totalCases: number;
945
+ completedCases: number;
946
+ passedCases: number;
947
+ score: number | null;
948
+ tokenUsage: Record<string, unknown> | null;
949
+ agentOverrides: Record<string, unknown> | null;
950
+ agentSpecSnapshot: Record<string, unknown> | null;
951
+ startedAt: string | null;
952
+ finishedAt: string | null;
953
+ createdAt: string;
954
+ }
955
+ interface EvalRunCompareCase {
956
+ caseId: string;
957
+ caseName: string;
958
+ caseInput: Record<string, unknown> | null;
959
+ a: Record<string, unknown> | null;
960
+ b: Record<string, unknown> | null;
961
+ }
962
+ interface EvalRunCompare {
963
+ datasetId: string;
964
+ datasetName: string;
965
+ runA: EvalRunCompareSide;
966
+ runB: EvalRunCompareSide;
967
+ cases: EvalRunCompareCase[];
968
+ }
969
+ /** One SSE frame from `GET /eval-runs/:runId/stream`. */
970
+ interface EvalRunEvent {
971
+ type: string;
972
+ [key: string]: unknown;
973
+ }
974
+ interface ListEvalRunsOptions {
975
+ datasetId?: string;
976
+ agentId?: string;
977
+ status?: EvalRunStatus | string;
978
+ limit?: number;
979
+ offset?: number;
980
+ }
981
+ interface RunEvalOptions {
982
+ /** Client-resolved tools to register for the eval run. */
983
+ tools?: ToolRef[];
984
+ /** Called for each SSE frame while the run is in flight. */
985
+ onEvent?: (event: EvalRunEvent) => void;
986
+ /** Poll interval when SSE is unavailable or ends early. Default 1000ms. */
987
+ pollIntervalMs?: number;
988
+ signal?: AbortSignal;
989
+ }
818
990
  interface MantyxClientOptions {
819
991
  /**
820
992
  * Workspace API key (token prefix `mantyx_`) **or** a MANTYX OAuth 2.0
@@ -848,7 +1020,8 @@ interface MantyxClientOptions {
848
1020
  *
849
1021
  * OAuth tokens additionally enforce per-route **scopes**
850
1022
  * (`runs:read`, `runs:write`, `sessions:read`, `sessions:write`,
851
- * `models:read`, `feedback:write`, `mantyx.identity:read`); see
1023
+ * `models:read`, `feedback:write`, `evals:read`, `evals:write`,
1024
+ * `mantyx.identity:read`); see
852
1025
  * `docs/agent-runs-protocol.md` §2.2 for the table. Missing scopes
853
1026
  * land as {@link MantyxScopeError} so callers can route the user
854
1027
  * back to a re-consent flow.
@@ -1679,6 +1852,22 @@ declare class MantyxClient {
1679
1852
  * the same response body. See `docs/agent-runs-protocol.md` §9a.
1680
1853
  */
1681
1854
  submitRunFeedback(runId: string, input: RunFeedbackInput): Promise<RunFeedbackResult>;
1855
+ listEvalDatasets(): Promise<EvalDatasetList>;
1856
+ getEvalDataset(datasetId: string): Promise<EvalDatasetDetail>;
1857
+ createEvalRun(spec: CreateEvalRunRequest): Promise<EvalRunAccepted>;
1858
+ listEvalRuns(options?: ListEvalRunsOptions): Promise<EvalRunList>;
1859
+ compareEvalRuns(runA: string, runB: string): Promise<EvalRunCompare>;
1860
+ getEvalRun(runId: string): Promise<EvalRunDetail>;
1861
+ streamEvalRun(runId: string, signal?: AbortSignal): AsyncGenerator<EvalRunEvent, void, void>;
1862
+ cancelEvalRun(runId: string): Promise<{
1863
+ ok: boolean;
1864
+ }>;
1865
+ /**
1866
+ * Start an eval run and block until it reaches a terminal status.
1867
+ * Tails the SSE stream for live `onEvent` callbacks while polling
1868
+ * `getEvalRun` until `status` is terminal.
1869
+ */
1870
+ runEval(spec: CreateEvalRunRequest, options?: RunEvalOptions): Promise<EvalRunDetail>;
1682
1871
  private absoluteUrl;
1683
1872
  /**
1684
1873
  * Resolve the bearer credential to send on the next request. With a
@@ -1841,4 +2030,4 @@ interface LocalHandlers {
1841
2030
  */
1842
2031
  declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
1843
2032
 
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 };
2033
+ 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-C7TzTpNW.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-C7TzTpNW.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,138 @@ 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
+ const tools = spec.tools ?? [];
1148
+ if (tools.length > 0) {
1149
+ await resolveLocalRefs(tools, { fetch: this.options.fetch });
1150
+ }
1151
+ return this.request({
1152
+ method: "POST",
1153
+ path: "/eval-runs",
1154
+ body: serializeCreateEvalRunRequest(spec)
1155
+ });
1156
+ }
1157
+ async listEvalRuns(options = {}) {
1158
+ const params = new URLSearchParams();
1159
+ if (options.datasetId) params.set("datasetId", options.datasetId);
1160
+ if (options.agentId) params.set("agentId", options.agentId);
1161
+ if (options.status) params.set("status", options.status);
1162
+ if (options.limit !== void 0) params.set("limit", String(options.limit));
1163
+ if (options.offset !== void 0) params.set("offset", String(options.offset));
1164
+ const qs = params.toString();
1165
+ return this.request({
1166
+ method: "GET",
1167
+ path: qs ? `/eval-runs?${qs}` : "/eval-runs"
1168
+ });
1169
+ }
1170
+ async compareEvalRuns(runA, runB) {
1171
+ const params = new URLSearchParams({ a: runA, b: runB });
1172
+ return this.request({
1173
+ method: "GET",
1174
+ path: `/eval-runs/compare?${params}`
1175
+ });
1176
+ }
1177
+ async getEvalRun(runId) {
1178
+ return this.request({
1179
+ method: "GET",
1180
+ path: `/eval-runs/${encodeURIComponent(runId)}`
1181
+ });
1182
+ }
1183
+ async *streamEvalRun(runId, signal) {
1184
+ const url = this.absoluteUrl(`/eval-runs/${encodeURIComponent(runId)}/stream`);
1185
+ const res = await this.openSseStream(url, 0, signal);
1186
+ try {
1187
+ for await (const frame of readSseStream(res.body, { signal })) {
1188
+ if (!frame.data) continue;
1189
+ let parsed;
1190
+ try {
1191
+ parsed = JSON.parse(frame.data);
1192
+ } catch (err) {
1193
+ throw new MantyxParseError(
1194
+ `invalid eval SSE JSON: ${frame.data.slice(0, 200)}`,
1195
+ frame.data,
1196
+ { cause: err }
1197
+ );
1198
+ }
1199
+ yield parsed;
1200
+ if (parsed.type === "run_completed" || parsed.type === "run_error" || parsed.type === "run_cancelled") {
1201
+ return;
1202
+ }
1203
+ }
1204
+ } finally {
1205
+ await res.body?.cancel().catch(() => void 0);
1206
+ }
1207
+ }
1208
+ async cancelEvalRun(runId) {
1209
+ return this.request({
1210
+ method: "POST",
1211
+ path: `/eval-runs/${encodeURIComponent(runId)}/cancel`
1212
+ });
1213
+ }
1214
+ /**
1215
+ * Start an eval run and block until it reaches a terminal status.
1216
+ * Tails the SSE stream for live `onEvent` callbacks while polling
1217
+ * `getEvalRun` until `status` is terminal.
1218
+ */
1219
+ async runEval(spec, options = {}) {
1220
+ const tools = options.tools ?? spec.tools ?? [];
1221
+ if (tools.length > 0) {
1222
+ await resolveLocalRefs(tools, { fetch: this.options.fetch });
1223
+ }
1224
+ const handlers = collectLocalHandlers(tools);
1225
+ try {
1226
+ const accepted = await this.createEvalRun({
1227
+ ...spec,
1228
+ ...tools.length > 0 ? { tools } : {}
1229
+ });
1230
+ const pollMs = options.pollIntervalMs ?? 1e3;
1231
+ const streamDone = (async () => {
1232
+ try {
1233
+ for await (const ev of this.streamEvalRun(accepted.runId, options.signal)) {
1234
+ if (ev.type === "local_tool_call" && tools.length > 0) {
1235
+ const record = ev;
1236
+ const nested = typeof record.data === "object" && record.data !== null && !Array.isArray(record.data) ? record.data : void 0;
1237
+ const agentRunId = typeof record.agentRunId === "string" ? record.agentRunId : typeof nested?.agentRunId === "string" ? nested.agentRunId : "";
1238
+ if (agentRunId) {
1239
+ const localEv = evalEventToLocalToolCall(ev);
1240
+ void this.dispatchLocalTool(agentRunId, localEv, handlers).catch(() => void 0);
1241
+ }
1242
+ }
1243
+ options.onEvent?.(ev);
1244
+ }
1245
+ } catch (err) {
1246
+ if (!(err instanceof MantyxNetworkError)) throw err;
1247
+ }
1248
+ })();
1249
+ try {
1250
+ while (true) {
1251
+ if (options.signal?.aborted) {
1252
+ throw new MantyxNetworkError("eval run wait aborted", { cause: options.signal.reason });
1253
+ }
1254
+ const detail = await this.getEvalRun(accepted.runId);
1255
+ if (EVAL_TERMINAL_STATUSES.has(detail.status)) return detail;
1256
+ await sleep(pollMs);
1257
+ }
1258
+ } finally {
1259
+ await streamDone.catch(() => void 0);
1260
+ }
1261
+ } finally {
1262
+ await closeMcpRefs(tools);
1263
+ }
1264
+ }
1132
1265
  // -------------------------------------------------------------- HTTP
1133
1266
  absoluteUrl(path) {
1134
1267
  return `${this.options.baseUrl}/api/v1/workspaces/${encodeURIComponent(this.options.workspaceSlug)}${path}`;
@@ -1394,6 +1527,48 @@ function serializeAgentSpec(spec, extra = {}) {
1394
1527
  Object.assign(body, serializeTurnInput(extra));
1395
1528
  return body;
1396
1529
  }
1530
+ function serializeCreateEvalRunRequest(spec) {
1531
+ const hasDataset = spec.datasetId !== void 0 || spec.dataset !== void 0;
1532
+ const hasAgent = spec.agentId !== void 0 || spec.agent !== void 0;
1533
+ if (!hasDataset) {
1534
+ throw new MantyxError("createEvalRun requires exactly one of `datasetId` or `dataset`");
1535
+ }
1536
+ if (spec.datasetId !== void 0 && spec.dataset !== void 0) {
1537
+ throw new MantyxError("createEvalRun accepts only one of `datasetId` or `dataset`");
1538
+ }
1539
+ if (!hasAgent) {
1540
+ throw new MantyxError("createEvalRun requires exactly one of `agentId` or `agent`");
1541
+ }
1542
+ if (spec.agentId !== void 0 && spec.agent !== void 0) {
1543
+ throw new MantyxError("createEvalRun accepts only one of `agentId` or `agent`");
1544
+ }
1545
+ const body = {};
1546
+ if (spec.datasetId) body.datasetId = spec.datasetId;
1547
+ if (spec.dataset) body.dataset = spec.dataset;
1548
+ if (spec.agentId) body.agentId = spec.agentId;
1549
+ if (spec.agent) body.agent = serializeAgentSpec(spec.agent);
1550
+ if (spec.tools && spec.tools.length > 0 && spec.agentId) {
1551
+ body.tools = serializeToolRefs(spec.tools);
1552
+ }
1553
+ if (spec.modelId) body.modelId = spec.modelId;
1554
+ if (spec.overrides) body.overrides = spec.overrides;
1555
+ return body;
1556
+ }
1557
+ function evalEventToLocalToolCall(ev) {
1558
+ const data = ev.data && typeof ev.data === "object" && !Array.isArray(ev.data) ? ev.data : ev;
1559
+ return {
1560
+ type: "local_tool_call",
1561
+ seq: 0,
1562
+ toolUseId: String(data.toolUseId ?? ""),
1563
+ name: String(data.name ?? ""),
1564
+ args: data.args ?? {},
1565
+ ...typeof data.kind === "string" ? { kind: data.kind } : {},
1566
+ ...data.agentCard !== void 0 ? { agentCard: data.agentCard } : {},
1567
+ ...typeof data.mcpServer === "string" ? { mcpServer: data.mcpServer } : {},
1568
+ ...typeof data.mcpToolName === "string" ? { mcpToolName: data.mcpToolName } : {},
1569
+ ...data.mcpServerInfo !== void 0 ? { mcpServerInfo: data.mcpServerInfo } : {}
1570
+ };
1571
+ }
1397
1572
  function serializeToolRefs(tools) {
1398
1573
  return tools.map((t) => {
1399
1574
  switch (t.kind) {
@@ -2401,7 +2576,7 @@ async function runComputerUse(opts) {
2401
2576
  }
2402
2577
 
2403
2578
  // src/version.ts
2404
- var SDK_VERSION = "0.19.0";
2579
+ var SDK_VERSION = "0.21.0";
2405
2580
  // Annotate the CommonJS export names for ESM import in node:
2406
2581
  0 && (module.exports = {
2407
2582
  AgentSession,