@meetkai/mka1 0.54.72 → 0.54.74

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.
Files changed (170) hide show
  1. package/README.md +307 -304
  2. package/bin/mcp-server.js +1682 -1477
  3. package/bin/mcp-server.js.map +21 -16
  4. package/dist/commonjs/funcs/llmEvalsMeasureSuiteTokens.d.ts +20 -0
  5. package/dist/commonjs/funcs/llmEvalsMeasureSuiteTokens.d.ts.map +1 -0
  6. package/dist/commonjs/funcs/llmEvalsMeasureSuiteTokens.js +137 -0
  7. package/dist/commonjs/funcs/llmEvalsMeasureSuiteTokens.js.map +1 -0
  8. package/dist/commonjs/lib/config.d.ts +2 -2
  9. package/dist/commonjs/lib/config.js +2 -2
  10. package/dist/commonjs/mcp-server/mcp-server.js +1 -1
  11. package/dist/commonjs/mcp-server/server.d.ts.map +1 -1
  12. package/dist/commonjs/mcp-server/server.js +3 -1
  13. package/dist/commonjs/mcp-server/server.js.map +1 -1
  14. package/dist/commonjs/mcp-server/tools/llmEvalsMeasureSuiteTokens.d.ts +8 -0
  15. package/dist/commonjs/mcp-server/tools/llmEvalsMeasureSuiteTokens.d.ts.map +1 -0
  16. package/dist/commonjs/mcp-server/tools/llmEvalsMeasureSuiteTokens.js +64 -0
  17. package/dist/commonjs/mcp-server/tools/llmEvalsMeasureSuiteTokens.js.map +1 -0
  18. package/dist/commonjs/models/components/declaration.d.ts +3 -12
  19. package/dist/commonjs/models/components/declaration.d.ts.map +1 -1
  20. package/dist/commonjs/models/components/declaration.js.map +1 -1
  21. package/dist/commonjs/models/components/evalsampleobject.d.ts +5 -0
  22. package/dist/commonjs/models/components/evalsampleobject.d.ts.map +1 -1
  23. package/dist/commonjs/models/components/evalsampleobject.js +4 -0
  24. package/dist/commonjs/models/components/evalsampleobject.js.map +1 -1
  25. package/dist/commonjs/models/components/evalsuitetokenmeasurement.d.ts +34 -0
  26. package/dist/commonjs/models/components/evalsuitetokenmeasurement.d.ts.map +1 -0
  27. package/dist/commonjs/models/components/evalsuitetokenmeasurement.js +81 -0
  28. package/dist/commonjs/models/components/evalsuitetokenmeasurement.js.map +1 -0
  29. package/dist/commonjs/models/components/generation.d.ts +3 -4
  30. package/dist/commonjs/models/components/generation.d.ts.map +1 -1
  31. package/dist/commonjs/models/components/generation.js.map +1 -1
  32. package/dist/commonjs/models/components/generationcreated.d.ts +3 -4
  33. package/dist/commonjs/models/components/generationcreated.d.ts.map +1 -1
  34. package/dist/commonjs/models/components/generationcreated.js.map +1 -1
  35. package/dist/commonjs/models/components/generatordetail.d.ts +3 -4
  36. package/dist/commonjs/models/components/generatordetail.d.ts.map +1 -1
  37. package/dist/commonjs/models/components/generatordetail.js.map +1 -1
  38. package/dist/commonjs/models/components/index.d.ts +2 -0
  39. package/dist/commonjs/models/components/index.d.ts.map +1 -1
  40. package/dist/commonjs/models/components/index.js +2 -0
  41. package/dist/commonjs/models/components/index.js.map +1 -1
  42. package/dist/commonjs/models/components/limits.d.ts +10 -6
  43. package/dist/commonjs/models/components/limits.d.ts.map +1 -1
  44. package/dist/commonjs/models/components/limits.js +2 -2
  45. package/dist/commonjs/models/components/limits.js.map +1 -1
  46. package/dist/commonjs/models/components/limitsrequest.d.ts +5 -0
  47. package/dist/commonjs/models/components/limitsrequest.d.ts.map +1 -1
  48. package/dist/commonjs/models/components/limitsrequest.js.map +1 -1
  49. package/dist/commonjs/models/components/measureevalsuitetokensbody.d.ts +20 -0
  50. package/dist/commonjs/models/components/measureevalsuitetokensbody.d.ts.map +1 -0
  51. package/dist/commonjs/models/components/measureevalsuitetokensbody.js +58 -0
  52. package/dist/commonjs/models/components/measureevalsuitetokensbody.js.map +1 -0
  53. package/dist/commonjs/models/components/quoteresponse.d.ts +3 -4
  54. package/dist/commonjs/models/components/quoteresponse.d.ts.map +1 -1
  55. package/dist/commonjs/models/components/quoteresponse.js.map +1 -1
  56. package/dist/commonjs/models/operations/index.d.ts +1 -0
  57. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  58. package/dist/commonjs/models/operations/index.js +1 -0
  59. package/dist/commonjs/models/operations/index.js.map +1 -1
  60. package/dist/commonjs/models/operations/measureevalsuitetokens.d.ts +25 -0
  61. package/dist/commonjs/models/operations/measureevalsuitetokens.d.ts.map +1 -0
  62. package/dist/commonjs/models/operations/measureevalsuitetokens.js +76 -0
  63. package/dist/commonjs/models/operations/measureevalsuitetokens.js.map +1 -0
  64. package/dist/commonjs/react-query/index.d.ts +1 -0
  65. package/dist/commonjs/react-query/index.d.ts.map +1 -1
  66. package/dist/commonjs/react-query/index.js +1 -0
  67. package/dist/commonjs/react-query/index.js.map +1 -1
  68. package/dist/commonjs/react-query/llmEvalsMeasureSuiteTokens.d.ts +29 -0
  69. package/dist/commonjs/react-query/llmEvalsMeasureSuiteTokens.d.ts.map +1 -0
  70. package/dist/commonjs/react-query/llmEvalsMeasureSuiteTokens.js +47 -0
  71. package/dist/commonjs/react-query/llmEvalsMeasureSuiteTokens.js.map +1 -0
  72. package/dist/commonjs/sdk/evals.d.ts +7 -0
  73. package/dist/commonjs/sdk/evals.d.ts.map +1 -1
  74. package/dist/commonjs/sdk/evals.js +10 -0
  75. package/dist/commonjs/sdk/evals.js.map +1 -1
  76. package/dist/esm/funcs/llmEvalsMeasureSuiteTokens.d.ts +20 -0
  77. package/dist/esm/funcs/llmEvalsMeasureSuiteTokens.d.ts.map +1 -0
  78. package/dist/esm/funcs/llmEvalsMeasureSuiteTokens.js +101 -0
  79. package/dist/esm/funcs/llmEvalsMeasureSuiteTokens.js.map +1 -0
  80. package/dist/esm/lib/config.d.ts +2 -2
  81. package/dist/esm/lib/config.js +2 -2
  82. package/dist/esm/mcp-server/mcp-server.js +1 -1
  83. package/dist/esm/mcp-server/server.d.ts.map +1 -1
  84. package/dist/esm/mcp-server/server.js +3 -1
  85. package/dist/esm/mcp-server/server.js.map +1 -1
  86. package/dist/esm/mcp-server/tools/llmEvalsMeasureSuiteTokens.d.ts +8 -0
  87. package/dist/esm/mcp-server/tools/llmEvalsMeasureSuiteTokens.d.ts.map +1 -0
  88. package/dist/esm/mcp-server/tools/llmEvalsMeasureSuiteTokens.js +28 -0
  89. package/dist/esm/mcp-server/tools/llmEvalsMeasureSuiteTokens.js.map +1 -0
  90. package/dist/esm/models/components/declaration.d.ts +3 -12
  91. package/dist/esm/models/components/declaration.d.ts.map +1 -1
  92. package/dist/esm/models/components/declaration.js.map +1 -1
  93. package/dist/esm/models/components/evalsampleobject.d.ts +5 -0
  94. package/dist/esm/models/components/evalsampleobject.d.ts.map +1 -1
  95. package/dist/esm/models/components/evalsampleobject.js +4 -0
  96. package/dist/esm/models/components/evalsampleobject.js.map +1 -1
  97. package/dist/esm/models/components/evalsuitetokenmeasurement.d.ts +34 -0
  98. package/dist/esm/models/components/evalsuitetokenmeasurement.d.ts.map +1 -0
  99. package/dist/esm/models/components/evalsuitetokenmeasurement.js +43 -0
  100. package/dist/esm/models/components/evalsuitetokenmeasurement.js.map +1 -0
  101. package/dist/esm/models/components/generation.d.ts +3 -4
  102. package/dist/esm/models/components/generation.d.ts.map +1 -1
  103. package/dist/esm/models/components/generation.js.map +1 -1
  104. package/dist/esm/models/components/generationcreated.d.ts +3 -4
  105. package/dist/esm/models/components/generationcreated.d.ts.map +1 -1
  106. package/dist/esm/models/components/generationcreated.js.map +1 -1
  107. package/dist/esm/models/components/generatordetail.d.ts +3 -4
  108. package/dist/esm/models/components/generatordetail.d.ts.map +1 -1
  109. package/dist/esm/models/components/generatordetail.js.map +1 -1
  110. package/dist/esm/models/components/index.d.ts +2 -0
  111. package/dist/esm/models/components/index.d.ts.map +1 -1
  112. package/dist/esm/models/components/index.js +2 -0
  113. package/dist/esm/models/components/index.js.map +1 -1
  114. package/dist/esm/models/components/limits.d.ts +10 -6
  115. package/dist/esm/models/components/limits.d.ts.map +1 -1
  116. package/dist/esm/models/components/limits.js +2 -2
  117. package/dist/esm/models/components/limits.js.map +1 -1
  118. package/dist/esm/models/components/limitsrequest.d.ts +5 -0
  119. package/dist/esm/models/components/limitsrequest.d.ts.map +1 -1
  120. package/dist/esm/models/components/limitsrequest.js.map +1 -1
  121. package/dist/esm/models/components/measureevalsuitetokensbody.d.ts +20 -0
  122. package/dist/esm/models/components/measureevalsuitetokensbody.d.ts.map +1 -0
  123. package/dist/esm/models/components/measureevalsuitetokensbody.js +20 -0
  124. package/dist/esm/models/components/measureevalsuitetokensbody.js.map +1 -0
  125. package/dist/esm/models/components/quoteresponse.d.ts +3 -4
  126. package/dist/esm/models/components/quoteresponse.d.ts.map +1 -1
  127. package/dist/esm/models/components/quoteresponse.js.map +1 -1
  128. package/dist/esm/models/operations/index.d.ts +1 -0
  129. package/dist/esm/models/operations/index.d.ts.map +1 -1
  130. package/dist/esm/models/operations/index.js +1 -0
  131. package/dist/esm/models/operations/index.js.map +1 -1
  132. package/dist/esm/models/operations/measureevalsuitetokens.d.ts +25 -0
  133. package/dist/esm/models/operations/measureevalsuitetokens.d.ts.map +1 -0
  134. package/dist/esm/models/operations/measureevalsuitetokens.js +38 -0
  135. package/dist/esm/models/operations/measureevalsuitetokens.js.map +1 -0
  136. package/dist/esm/react-query/index.d.ts +1 -0
  137. package/dist/esm/react-query/index.d.ts.map +1 -1
  138. package/dist/esm/react-query/index.js +1 -0
  139. package/dist/esm/react-query/index.js.map +1 -1
  140. package/dist/esm/react-query/llmEvalsMeasureSuiteTokens.d.ts +29 -0
  141. package/dist/esm/react-query/llmEvalsMeasureSuiteTokens.d.ts.map +1 -0
  142. package/dist/esm/react-query/llmEvalsMeasureSuiteTokens.js +42 -0
  143. package/dist/esm/react-query/llmEvalsMeasureSuiteTokens.js.map +1 -0
  144. package/dist/esm/sdk/evals.d.ts +7 -0
  145. package/dist/esm/sdk/evals.d.ts.map +1 -1
  146. package/dist/esm/sdk/evals.js +10 -0
  147. package/dist/esm/sdk/evals.js.map +1 -1
  148. package/jsr.json +1 -1
  149. package/package.json +1 -1
  150. package/src/funcs/llmEvalsMeasureSuiteTokens.ts +191 -0
  151. package/src/lib/config.ts +2 -2
  152. package/src/mcp-server/mcp-server.ts +1 -1
  153. package/src/mcp-server/server.ts +3 -1
  154. package/src/mcp-server/tools/llmEvalsMeasureSuiteTokens.ts +37 -0
  155. package/src/models/components/declaration.ts +3 -12
  156. package/src/models/components/evalsampleobject.ts +9 -0
  157. package/src/models/components/evalsuitetokenmeasurement.ts +91 -0
  158. package/src/models/components/generation.ts +3 -4
  159. package/src/models/components/generationcreated.ts +3 -4
  160. package/src/models/components/generatordetail.ts +3 -4
  161. package/src/models/components/index.ts +2 -0
  162. package/src/models/components/limits.ts +12 -8
  163. package/src/models/components/limitsrequest.ts +5 -0
  164. package/src/models/components/measureevalsuitetokensbody.ts +54 -0
  165. package/src/models/components/quoteresponse.ts +3 -4
  166. package/src/models/operations/index.ts +1 -0
  167. package/src/models/operations/measureevalsuitetokens.ts +80 -0
  168. package/src/react-query/index.ts +1 -0
  169. package/src/react-query/llmEvalsMeasureSuiteTokens.ts +110 -0
  170. package/src/sdk/evals.ts +18 -0
@@ -0,0 +1,191 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { SDKCore } from "../core.js";
6
+ import { encodeJSON, encodeSimple } from "../lib/encodings.js";
7
+ import { matchStatusCode } from "../lib/http.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
13
+ import { pathToFunc } from "../lib/url.js";
14
+ import * as components from "../models/components/index.js";
15
+ import {
16
+ ConnectionError,
17
+ InvalidRequestError,
18
+ RequestAbortedError,
19
+ RequestTimeoutError,
20
+ UnexpectedClientError,
21
+ } from "../models/errors/httpclienterrors.js";
22
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
23
+ import { SDKError } from "../models/errors/sdkerror.js";
24
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
25
+ import * as operations from "../models/operations/index.js";
26
+ import { APICall, APIPromise } from "../types/async.js";
27
+ import { Result } from "../types/fp.js";
28
+
29
+ /**
30
+ * Count tokens from stored text for a suite's unmeasured samples
31
+ *
32
+ * @remarks
33
+ * Backfill for rows written before the gateway recorded usage. For samples of the suite's completed runs that have answer or reasoning text but no token figure, counts prompt, reasoning and answer tokens from the stored text (tiktoken o200k_base, one ruler for every model), marks them `tokens_estimated`, and refreshes each run's per-task `tokens` and run totals so the leaderboard's efficiency figures appear. Processes `limit` runs per call, oldest run id first; call again until `remaining_runs` is 0. Samples the provider or the import already measured are left alone, and a sample with no text stays unmeasured. New rows get the same figures at generation or import time, so this is a no-op on a suite with nothing to measure.
34
+ *
35
+ * If set, this operation will use {@link Security.bearerAuth} from the global security.
36
+ */
37
+ export function llmEvalsMeasureSuiteTokens(
38
+ client: SDKCore,
39
+ request: operations.MeasureEvalSuiteTokensRequest,
40
+ options?: RequestOptions,
41
+ ): APIPromise<
42
+ Result<
43
+ components.EvalSuiteTokenMeasurement,
44
+ | SDKError
45
+ | ResponseValidationError
46
+ | ConnectionError
47
+ | RequestAbortedError
48
+ | RequestTimeoutError
49
+ | InvalidRequestError
50
+ | UnexpectedClientError
51
+ | SDKValidationError
52
+ >
53
+ > {
54
+ return new APIPromise($do(
55
+ client,
56
+ request,
57
+ options,
58
+ ));
59
+ }
60
+
61
+ async function $do(
62
+ client: SDKCore,
63
+ request: operations.MeasureEvalSuiteTokensRequest,
64
+ options?: RequestOptions,
65
+ ): Promise<
66
+ [
67
+ Result<
68
+ components.EvalSuiteTokenMeasurement,
69
+ | SDKError
70
+ | ResponseValidationError
71
+ | ConnectionError
72
+ | RequestAbortedError
73
+ | RequestTimeoutError
74
+ | InvalidRequestError
75
+ | UnexpectedClientError
76
+ | SDKValidationError
77
+ >,
78
+ APICall,
79
+ ]
80
+ > {
81
+ const parsed = safeParse(
82
+ request,
83
+ (value) =>
84
+ operations.MeasureEvalSuiteTokensRequest$outboundSchema.parse(value),
85
+ "Input validation failed",
86
+ );
87
+ if (!parsed.ok) {
88
+ return [parsed, { status: "invalid" }];
89
+ }
90
+ const payload = parsed.value;
91
+ const body = encodeJSON("body", payload.MeasureEvalSuiteTokensBody, {
92
+ explode: true,
93
+ });
94
+
95
+ const pathParams = {
96
+ suite_id: encodeSimple("suite_id", payload.suite_id, {
97
+ explode: false,
98
+ charEncoding: "percent",
99
+ }),
100
+ };
101
+ const path = pathToFunc("/api/v1/llm/evals/suites/{suite_id}/tokens/measure")(
102
+ pathParams,
103
+ );
104
+
105
+ const headers = new Headers(compactMap({
106
+ "Content-Type": "application/json",
107
+ Accept: "application/json",
108
+ "X-On-Behalf-Of": encodeSimple(
109
+ "X-On-Behalf-Of",
110
+ payload["X-On-Behalf-Of"],
111
+ { explode: false, charEncoding: "none" },
112
+ ),
113
+ }));
114
+
115
+ const secConfig = await extractSecurity(client._options.bearerAuth);
116
+ const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
117
+ const requestSecurity = resolveGlobalSecurity(securityInput, [0]);
118
+
119
+ const context = {
120
+ options: client._options,
121
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
122
+ operationID: "measureEvalSuiteTokens",
123
+ oAuth2Scopes: null,
124
+
125
+ resolvedSecurity: requestSecurity,
126
+
127
+ securitySource: client._options.bearerAuth,
128
+ retryConfig: options?.retries
129
+ || client._options.retryConfig
130
+ || {
131
+ strategy: "backoff",
132
+ backoff: {
133
+ initialInterval: 500,
134
+ maxInterval: 5000,
135
+ exponent: 1.5,
136
+ maxElapsedTime: 15000,
137
+ },
138
+ retryConnectionErrors: true,
139
+ }
140
+ || { strategy: "none" },
141
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
142
+ };
143
+
144
+ const requestRes = client._createRequest(context, {
145
+ security: requestSecurity,
146
+ method: "POST",
147
+ baseURL: options?.serverURL,
148
+ path: path,
149
+ headers: headers,
150
+ body: body,
151
+ userAgent: client._options.userAgent,
152
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
153
+ }, options);
154
+ if (!requestRes.ok) {
155
+ return [requestRes, { status: "invalid" }];
156
+ }
157
+ const req = requestRes.value;
158
+
159
+ const doResult = await client._do(req, {
160
+ context,
161
+ isErrorStatusCode: (statusCode: number) =>
162
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
163
+ retryConfig: context.retryConfig,
164
+ retryCodes: context.retryCodes,
165
+ });
166
+ if (!doResult.ok) {
167
+ return [doResult, { status: "request-error", request: req }];
168
+ }
169
+ const response = doResult.value;
170
+
171
+ const [result] = await M.match<
172
+ components.EvalSuiteTokenMeasurement,
173
+ | SDKError
174
+ | ResponseValidationError
175
+ | ConnectionError
176
+ | RequestAbortedError
177
+ | RequestTimeoutError
178
+ | InvalidRequestError
179
+ | UnexpectedClientError
180
+ | SDKValidationError
181
+ >(
182
+ M.json(200, components.EvalSuiteTokenMeasurement$inboundSchema),
183
+ M.fail("4XX"),
184
+ M.fail("5XX"),
185
+ )(response, req);
186
+ if (!result.ok) {
187
+ return [result, { status: "complete", request: req, response }];
188
+ }
189
+
190
+ return [result, { status: "complete", request: req, response }];
191
+ }
package/src/lib/config.ts CHANGED
@@ -65,7 +65,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
65
65
  export const SDK_METADATA = {
66
66
  language: "typescript",
67
67
  openapiDocVersion: "1.1.0",
68
- sdkVersion: "0.54.72",
68
+ sdkVersion: "0.54.74",
69
69
  genVersion: "2.943.0",
70
- userAgent: "speakeasy-sdk/typescript 0.54.72 2.943.0 1.1.0 @meetkai/mka1",
70
+ userAgent: "speakeasy-sdk/typescript 0.54.74 2.943.0 1.1.0 @meetkai/mka1",
71
71
  } as const;
@@ -19,7 +19,7 @@ const routes = buildRouteMap({
19
19
  export const app = buildApplication(routes, {
20
20
  name: "mcp",
21
21
  versionInfo: {
22
- currentVersion: "0.54.72",
22
+ currentVersion: "0.54.74",
23
23
  },
24
24
  });
25
25
 
@@ -247,6 +247,7 @@ import { tool$llmEvalsListSchedules } from "./tools/llmEvalsListSchedules.js";
247
247
  import { tool$llmEvalsListSuiteLeaderboardRuns } from "./tools/llmEvalsListSuiteLeaderboardRuns.js";
248
248
  import { tool$llmEvalsListSuites } from "./tools/llmEvalsListSuites.js";
249
249
  import { tool$llmEvalsListSuiteVersions } from "./tools/llmEvalsListSuiteVersions.js";
250
+ import { tool$llmEvalsMeasureSuiteTokens } from "./tools/llmEvalsMeasureSuiteTokens.js";
250
251
  import { tool$llmEvalsRerunFailedSamples } from "./tools/llmEvalsRerunFailedSamples.js";
251
252
  import { tool$llmEvalsRetryFailedRun } from "./tools/llmEvalsRetryFailedRun.js";
252
253
  import { tool$llmEvalsTriggerSchedule } from "./tools/llmEvalsTriggerSchedule.js";
@@ -473,7 +474,7 @@ export function createMCPServer(deps: {
473
474
  }) {
474
475
  const server = new McpServer({
475
476
  name: "SDK",
476
- version: "0.54.72",
477
+ version: "0.54.74",
477
478
  });
478
479
 
479
480
  const client = new SDKCore({
@@ -683,6 +684,7 @@ export function createMCPServer(deps: {
683
684
  tool(tool$llmEvalsGetSuiteVersion);
684
685
  tool(tool$llmEvalsListSuiteLeaderboardRuns);
685
686
  tool(tool$llmEvalsGetSuiteLeaderboard);
687
+ tool(tool$llmEvalsMeasureSuiteTokens);
686
688
  tool(tool$llmEvalsCreateRun);
687
689
  tool(tool$llmEvalsListRuns);
688
690
  tool(tool$llmEvalsGetRun);
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { llmEvalsMeasureSuiteTokens } from "../../funcs/llmEvalsMeasureSuiteTokens.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.MeasureEvalSuiteTokensRequest$inboundSchema,
11
+ };
12
+
13
+ export const tool$llmEvalsMeasureSuiteTokens: ToolDefinition<typeof args> = {
14
+ name: "llm-evals-measure-suite-tokens",
15
+ description: `Count tokens from stored text for a suite's unmeasured samples
16
+
17
+ Backfill for rows written before the gateway recorded usage. For samples of the suite's completed runs that have answer or reasoning text but no token figure, counts prompt, reasoning and answer tokens from the stored text (tiktoken o200k_base, one ruler for every model), marks them \`tokens_estimated\`, and refreshes each run's per-task \`tokens\` and run totals so the leaderboard's efficiency figures appear. Processes \`limit\` runs per call, oldest run id first; call again until \`remaining_runs\` is 0. Samples the provider or the import already measured are left alone, and a sample with no text stays unmeasured. New rows get the same figures at generation or import time, so this is a no-op on a suite with nothing to measure.`,
18
+ args,
19
+ tool: async (client, args, ctx) => {
20
+ const [result, apiCall] = await llmEvalsMeasureSuiteTokens(
21
+ client,
22
+ args.request,
23
+ { fetchOptions: { signal: ctx.signal } },
24
+ ).$inspect();
25
+
26
+ if (!result.ok) {
27
+ return {
28
+ content: [{ type: "text", text: result.error.message }],
29
+ isError: true,
30
+ };
31
+ }
32
+
33
+ const value = result.value;
34
+
35
+ return formatResult(value, apiCall);
36
+ },
37
+ };
@@ -26,14 +26,6 @@ import {
26
26
  Resources$outboundSchema,
27
27
  } from "./resources.js";
28
28
 
29
- /**
30
- * The `@generator(...)` arguments, validated — field-for-field the `GET /generators` entry.
31
- *
32
- * @remarks
33
- *
34
- * Frozen: the service holds one of these per generator for the life of the process and serves
35
- * it on every catalog request.
36
- */
37
29
  export type Declaration = {
38
30
  id: string;
39
31
  version: string;
@@ -46,12 +38,11 @@ export type Declaration = {
46
38
  */
47
39
  resources?: Resources | undefined;
48
40
  /**
49
- * A run's budget: the generator's `default_limits`, or the effective ones as `ctx.limits`.
41
+ * api.md §2 `limits` / `default_limits` on the wire: B.1's `contract.Limits`, with
50
42
  *
51
43
  * @remarks
52
- *
53
- * No defaults. Every number here is a bound the platform enforces and a caller can be billed
54
- * against, so a generator that forgets to state one should not silently inherit a guess.
44
+ * `max_cost` optional and deprecated in the schema while every response still carries it as a
45
+ * number (MK1-722, step 1 of MK1-719). The two must otherwise agree field for field.
55
46
  */
56
47
  defaultLimits: Limits;
57
48
  };
@@ -57,6 +57,10 @@ export type EvalSampleObject = {
57
57
  * The share of `output_tokens` the provider attributed to reasoning. Null when it reported no split.
58
58
  */
59
59
  reasoningTokens: number | null;
60
+ /**
61
+ * True when the token figures were counted from the stored text by the gateway (tiktoken o200k_base, one ruler for every model) because neither the provider nor the imported row reported usage. Comparable verbosity, not a billing count.
62
+ */
63
+ tokensEstimated: boolean;
60
64
  /**
61
65
  * Per-phase wall clock for a harness trial: `environment_setup`, `agent_setup`, `agent_execution`, `verifier`, each `{ started_at, finished_at }` as ISO 8601 timestamps exactly as the harness recorded them. A phase the harness did not time is absent rather than null. Drives the trial timing bar. Null outside harness runs.
62
66
  */
@@ -94,6 +98,7 @@ export const EvalSampleObject$inboundSchema: z.ZodType<
94
98
  output_tokens: z.nullable(z.number().int()),
95
99
  cached_tokens: z.nullable(z.number().int()),
96
100
  reasoning_tokens: z.nullable(z.number().int()),
101
+ tokens_estimated: z.boolean(),
97
102
  phase_timings: z.nullable(z.record(z.any())),
98
103
  created_at: z.number().int(),
99
104
  started_at: z.nullable(z.number().int()),
@@ -112,6 +117,7 @@ export const EvalSampleObject$inboundSchema: z.ZodType<
112
117
  "output_tokens": "outputTokens",
113
118
  "cached_tokens": "cachedTokens",
114
119
  "reasoning_tokens": "reasoningTokens",
120
+ "tokens_estimated": "tokensEstimated",
115
121
  "phase_timings": "phaseTimings",
116
122
  "created_at": "createdAt",
117
123
  "started_at": "startedAt",
@@ -142,6 +148,7 @@ export type EvalSampleObject$Outbound = {
142
148
  output_tokens: number | null;
143
149
  cached_tokens: number | null;
144
150
  reasoning_tokens: number | null;
151
+ tokens_estimated: boolean;
145
152
  phase_timings: { [k: string]: any } | null;
146
153
  created_at: number;
147
154
  started_at: number | null;
@@ -176,6 +183,7 @@ export const EvalSampleObject$outboundSchema: z.ZodType<
176
183
  outputTokens: z.nullable(z.number().int()),
177
184
  cachedTokens: z.nullable(z.number().int()),
178
185
  reasoningTokens: z.nullable(z.number().int()),
186
+ tokensEstimated: z.boolean(),
179
187
  phaseTimings: z.nullable(z.record(z.any())),
180
188
  createdAt: z.number().int(),
181
189
  startedAt: z.nullable(z.number().int()),
@@ -194,6 +202,7 @@ export const EvalSampleObject$outboundSchema: z.ZodType<
194
202
  outputTokens: "output_tokens",
195
203
  cachedTokens: "cached_tokens",
196
204
  reasoningTokens: "reasoning_tokens",
205
+ tokensEstimated: "tokens_estimated",
197
206
  phaseTimings: "phase_timings",
198
207
  createdAt: "created_at",
199
208
  startedAt: "started_at",
@@ -0,0 +1,91 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
+
11
+ export type EvalSuiteTokenMeasurement = {
12
+ object: "eval.suite.token_measurement";
13
+ suiteId: string;
14
+ /**
15
+ * Runs whose samples were counted in this call.
16
+ */
17
+ measuredRuns: number;
18
+ /**
19
+ * Samples that gained token figures in this call.
20
+ */
21
+ measuredSamples: number;
22
+ /**
23
+ * Runs of the suite that still have samples with text but no token figure, after this call.
24
+ */
25
+ remainingRuns: number;
26
+ };
27
+
28
+ /** @internal */
29
+ export const EvalSuiteTokenMeasurement$inboundSchema: z.ZodType<
30
+ EvalSuiteTokenMeasurement,
31
+ z.ZodTypeDef,
32
+ unknown
33
+ > = z.object({
34
+ object: z.literal("eval.suite.token_measurement"),
35
+ suite_id: z.string(),
36
+ measured_runs: z.number().int(),
37
+ measured_samples: z.number().int(),
38
+ remaining_runs: z.number().int(),
39
+ }).transform((v) => {
40
+ return remap$(v, {
41
+ "suite_id": "suiteId",
42
+ "measured_runs": "measuredRuns",
43
+ "measured_samples": "measuredSamples",
44
+ "remaining_runs": "remainingRuns",
45
+ });
46
+ });
47
+ /** @internal */
48
+ export type EvalSuiteTokenMeasurement$Outbound = {
49
+ object: "eval.suite.token_measurement";
50
+ suite_id: string;
51
+ measured_runs: number;
52
+ measured_samples: number;
53
+ remaining_runs: number;
54
+ };
55
+
56
+ /** @internal */
57
+ export const EvalSuiteTokenMeasurement$outboundSchema: z.ZodType<
58
+ EvalSuiteTokenMeasurement$Outbound,
59
+ z.ZodTypeDef,
60
+ EvalSuiteTokenMeasurement
61
+ > = z.object({
62
+ object: z.literal("eval.suite.token_measurement"),
63
+ suiteId: z.string(),
64
+ measuredRuns: z.number().int(),
65
+ measuredSamples: z.number().int(),
66
+ remainingRuns: z.number().int(),
67
+ }).transform((v) => {
68
+ return remap$(v, {
69
+ suiteId: "suite_id",
70
+ measuredRuns: "measured_runs",
71
+ measuredSamples: "measured_samples",
72
+ remainingRuns: "remaining_runs",
73
+ });
74
+ });
75
+
76
+ export function evalSuiteTokenMeasurementToJSON(
77
+ evalSuiteTokenMeasurement: EvalSuiteTokenMeasurement,
78
+ ): string {
79
+ return JSON.stringify(
80
+ EvalSuiteTokenMeasurement$outboundSchema.parse(evalSuiteTokenMeasurement),
81
+ );
82
+ }
83
+ export function evalSuiteTokenMeasurementFromJSON(
84
+ jsonString: string,
85
+ ): SafeParseResult<EvalSuiteTokenMeasurement, SDKValidationError> {
86
+ return safeParse(
87
+ jsonString,
88
+ (x) => EvalSuiteTokenMeasurement$inboundSchema.parse(JSON.parse(x)),
89
+ `Failed to parse 'EvalSuiteTokenMeasurement' from JSON`,
90
+ );
91
+ }
@@ -62,12 +62,11 @@ export type Generation = {
62
62
  counts: { [k: string]: number } | null;
63
63
  llm: LlmRef;
64
64
  /**
65
- * A run's budget: the generator's `default_limits`, or the effective ones as `ctx.limits`.
65
+ * api.md §2 `limits` / `default_limits` on the wire: B.1's `contract.Limits`, with
66
66
  *
67
67
  * @remarks
68
- *
69
- * No defaults. Every number here is a bound the platform enforces and a caller can be billed
70
- * against, so a generator that forgets to state one should not silently inherit a guess.
68
+ * `max_cost` optional and deprecated in the schema while every response still carries it as a
69
+ * number (MK1-722, step 1 of MK1-719). The two must otherwise agree field for field.
71
70
  */
72
71
  limits: Limits;
73
72
  usage: { [k: string]: any } | null;
@@ -56,12 +56,11 @@ export type GenerationCreated = {
56
56
  counts: { [k: string]: number } | null;
57
57
  llm: LlmRef;
58
58
  /**
59
- * A run's budget: the generator's `default_limits`, or the effective ones as `ctx.limits`.
59
+ * api.md §2 `limits` / `default_limits` on the wire: B.1's `contract.Limits`, with
60
60
  *
61
61
  * @remarks
62
- *
63
- * No defaults. Every number here is a bound the platform enforces and a caller can be billed
64
- * against, so a generator that forgets to state one should not silently inherit a guess.
62
+ * `max_cost` optional and deprecated in the schema while every response still carries it as a
63
+ * number (MK1-722, step 1 of MK1-719). The two must otherwise agree field for field.
65
64
  */
66
65
  limits: Limits;
67
66
  usage: { [k: string]: any } | null;
@@ -38,12 +38,11 @@ export type GeneratorDetail = {
38
38
  */
39
39
  resources?: Resources | undefined;
40
40
  /**
41
- * A run's budget: the generator's `default_limits`, or the effective ones as `ctx.limits`.
41
+ * api.md §2 `limits` / `default_limits` on the wire: B.1's `contract.Limits`, with
42
42
  *
43
43
  * @remarks
44
- *
45
- * No defaults. Every number here is a bound the platform enforces and a caller can be billed
46
- * against, so a generator that forgets to state one should not silently inherit a guess.
44
+ * `max_cost` optional and deprecated in the schema while every response still carries it as a
45
+ * number (MK1-722, step 1 of MK1-719). The two must otherwise agree field for field.
47
46
  */
48
47
  defaultLimits: Limits;
49
48
  paramsSchema: { [k: string]: any };
@@ -291,6 +291,7 @@ export * from "./evalsuiteleaderboard.js";
291
291
  export * from "./evalsuitelist.js";
292
292
  export * from "./evalsuitemanifest.js";
293
293
  export * from "./evalsuiteobject.js";
294
+ export * from "./evalsuitetokenmeasurement.js";
294
295
  export * from "./evaltask.js";
295
296
  export * from "./evaltasktype.js";
296
297
  export * from "./event.js";
@@ -455,6 +456,7 @@ export * from "./mcptoolcallwithid.js";
455
456
  export * from "./mcptoolchoice.js";
456
457
  export * from "./mcptooldefinition.js";
457
458
  export * from "./mcptoolfilter.js";
459
+ export * from "./measureevalsuitetokensbody.js";
458
460
  export * from "./memoryentry.js";
459
461
  export * from "./memoryentrydeleted.js";
460
462
  export * from "./memoryentrylist.js";
@@ -9,16 +9,20 @@ import { Result as SafeParseResult } from "../../types/fp.js";
9
9
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
10
 
11
11
  /**
12
- * A run's budget: the generator's `default_limits`, or the effective ones as `ctx.limits`.
12
+ * api.md §2 `limits` / `default_limits` on the wire: B.1's `contract.Limits`, with
13
13
  *
14
14
  * @remarks
15
- *
16
- * No defaults. Every number here is a bound the platform enforces and a caller can be billed
17
- * against, so a generator that forgets to state one should not silently inherit a guess.
15
+ * `max_cost` optional and deprecated in the schema while every response still carries it as a
16
+ * number (MK1-722, step 1 of MK1-719). The two must otherwise agree field for field.
18
17
  */
19
18
  export type Limits = {
20
19
  maxRuntimeHours: number;
21
- maxCost: number;
20
+ /**
21
+ * Deprecated: advisory only, ignored by the service, and going away (MK1-719). Nothing enforces a cost bound on a live run.
22
+ *
23
+ * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
24
+ */
25
+ maxCost?: number | undefined;
22
26
  maxLlmCalls: number;
23
27
  };
24
28
 
@@ -26,7 +30,7 @@ export type Limits = {
26
30
  export const Limits$inboundSchema: z.ZodType<Limits, z.ZodTypeDef, unknown> = z
27
31
  .object({
28
32
  max_runtime_hours: z.number(),
29
- max_cost: z.number(),
33
+ max_cost: z.number().optional(),
30
34
  max_llm_calls: z.number().int(),
31
35
  }).transform((v) => {
32
36
  return remap$(v, {
@@ -38,7 +42,7 @@ export const Limits$inboundSchema: z.ZodType<Limits, z.ZodTypeDef, unknown> = z
38
42
  /** @internal */
39
43
  export type Limits$Outbound = {
40
44
  max_runtime_hours: number;
41
- max_cost: number;
45
+ max_cost?: number | undefined;
42
46
  max_llm_calls: number;
43
47
  };
44
48
 
@@ -49,7 +53,7 @@ export const Limits$outboundSchema: z.ZodType<
49
53
  Limits
50
54
  > = z.object({
51
55
  maxRuntimeHours: z.number(),
52
- maxCost: z.number(),
56
+ maxCost: z.number().optional(),
53
57
  maxLlmCalls: z.number().int(),
54
58
  }).transform((v) => {
55
59
  return remap$(v, {
@@ -13,6 +13,11 @@ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
13
13
  */
14
14
  export type LimitsRequest = {
15
15
  maxRuntimeHours?: number | null | undefined;
16
+ /**
17
+ * Deprecated: advisory only, ignored by the service, and going away (MK1-719). Nothing enforces a cost bound on a live run.
18
+ *
19
+ * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
20
+ */
16
21
  maxCost?: number | null | undefined;
17
22
  maxLlmCalls?: number | null | undefined;
18
23
  };
@@ -0,0 +1,54 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../../types/fp.js";
8
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
9
+
10
+ export type MeasureEvalSuiteTokensBody = {
11
+ /**
12
+ * How many runs to measure in this call. Call again until `remaining_runs` is 0.
13
+ */
14
+ limit?: number | undefined;
15
+ };
16
+
17
+ /** @internal */
18
+ export const MeasureEvalSuiteTokensBody$inboundSchema: z.ZodType<
19
+ MeasureEvalSuiteTokensBody,
20
+ z.ZodTypeDef,
21
+ unknown
22
+ > = z.object({
23
+ limit: z.number().int().default(5),
24
+ });
25
+ /** @internal */
26
+ export type MeasureEvalSuiteTokensBody$Outbound = {
27
+ limit: number;
28
+ };
29
+
30
+ /** @internal */
31
+ export const MeasureEvalSuiteTokensBody$outboundSchema: z.ZodType<
32
+ MeasureEvalSuiteTokensBody$Outbound,
33
+ z.ZodTypeDef,
34
+ MeasureEvalSuiteTokensBody
35
+ > = z.object({
36
+ limit: z.number().int().default(5),
37
+ });
38
+
39
+ export function measureEvalSuiteTokensBodyToJSON(
40
+ measureEvalSuiteTokensBody: MeasureEvalSuiteTokensBody,
41
+ ): string {
42
+ return JSON.stringify(
43
+ MeasureEvalSuiteTokensBody$outboundSchema.parse(measureEvalSuiteTokensBody),
44
+ );
45
+ }
46
+ export function measureEvalSuiteTokensBodyFromJSON(
47
+ jsonString: string,
48
+ ): SafeParseResult<MeasureEvalSuiteTokensBody, SDKValidationError> {
49
+ return safeParse(
50
+ jsonString,
51
+ (x) => MeasureEvalSuiteTokensBody$inboundSchema.parse(JSON.parse(x)),
52
+ `Failed to parse 'MeasureEvalSuiteTokensBody' from JSON`,
53
+ );
54
+ }
@@ -29,12 +29,11 @@ export type QuoteResponse = {
29
29
  currency: string | null;
30
30
  unpriced: Array<string>;
31
31
  /**
32
- * A run's budget: the generator's `default_limits`, or the effective ones as `ctx.limits`.
32
+ * api.md §2 `limits` / `default_limits` on the wire: B.1's `contract.Limits`, with
33
33
  *
34
34
  * @remarks
35
- *
36
- * No defaults. Every number here is a bound the platform enforces and a caller can be billed
37
- * against, so a generator that forgets to state one should not silently inherit a guess.
35
+ * `max_cost` optional and deprecated in the schema while every response still carries it as a
36
+ * number (MK1-722, step 1 of MK1-719). The two must otherwise agree field for field.
38
37
  */
39
38
  limits: Limits;
40
39
  };
@@ -338,6 +338,7 @@ export * from "./livekittoken.js";
338
338
  export * from "./llmcheck.js";
339
339
  export * from "./llmgrant.js";
340
340
  export * from "./llmrevoke.js";
341
+ export * from "./measureevalsuitetokens.js";
341
342
  export * from "./modifyvectorstore.js";
342
343
  export * from "./patchrepo.js";
343
344
  export * from "./pauseagentschedule.js";