@crossworks/client-types 0.400.35 → 0.400.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossworks/client-types",
3
- "version": "0.400.35",
3
+ "version": "0.400.41",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -9,7 +9,7 @@
9
9
  "./*": "./src/*.ts"
10
10
  },
11
11
  "devDependencies": {
12
- "@types/node": "^26.6.5"
12
+ "@types/node": "^26.6.6"
13
13
  },
14
14
  "license": "SEE LICENSE IN LICENSE.md",
15
15
  "repository": {
@@ -10,9 +10,10 @@
10
10
  * and `fails_full_size` are a first read, not a verdict. A model that is not
11
11
  * here is untested: it may run, and nothing claims it works.
12
12
  *
13
- * Today this feeds the pool's refusal (`decisionModelRefusal`, read by
14
- * `poolModelIssue`) and the decider pool's re-curation (`poolPosition`). The request planner
15
- * and the worker screen read it later.
13
+ * It feeds the pool's refusal (`decisionModelRefusal`, read by
14
+ * `poolModelIssue`), the decider pool's re-curation (`poolPosition`) and the
15
+ * request planner's limits (`decisionRequestLimits`, read by
16
+ * @mantle/decisions). The worker screen reads it later.
16
17
  */
17
18
 
18
19
  export type DecisionModelStatus =
@@ -41,6 +42,11 @@ export type DecisionModelProfile = {
41
42
  /** Reported exactly this many input tokens for a larger request: a
42
43
  * suspected silent cut. Unsafe until checked. */
43
44
  suspectedCutAt?: number;
45
+ /** Most questions it takes in one request, when measured. */
46
+ maxQuestions?: number;
47
+ /** Most input tokens it takes in one request, when measured and lower
48
+ * than the catalog's context size. */
49
+ maxInputTokens?: number;
44
50
  /** A start value for passage scoring's threshold where Jev's 1.5 drops
45
51
  * right passages. Tune it with eval:route. */
46
52
  thresholdStart?: number;
@@ -153,3 +159,67 @@ export function decisionModelRefusal(model: string | null | undefined): string |
153
159
  'Pick a tested decision model such as ~typesafe/jev-latest or perplexity/pplx-decider-v1.2.'
154
160
  );
155
161
  }
162
+
163
+ /** The size of one decision request a model takes. Null = no limit is known,
164
+ * so the use's own size stands. */
165
+ export type DecisionRequestLimits = {
166
+ maxQuestions: number | null;
167
+ maxInputTokens: number | null;
168
+ /** A reported input-token count exactly at this is a suspected silent cut:
169
+ * the answer is not used. */
170
+ cutAt: number | null;
171
+ /** `profile`: a tested model, sized from its measured profile.
172
+ * `careful`: untested, or failed at full size, so the careful limits. */
173
+ source: 'profile' | 'careful';
174
+ };
175
+
176
+ /** Limits for a model that is untested or failed at full size. The probe's
177
+ * failures were a 16-question limit and a 16,384-token limit (2026-10-30),
178
+ * so a request this size passes both. */
179
+ export const CAREFUL_DECISION_LIMITS = { maxQuestions: 16, maxInputTokens: 16_384 } as const;
180
+
181
+ /**
182
+ * The request limits of a decision model (pure). `catalogContext` is the live
183
+ * catalog's context size for the model, or null when the catalog has not
184
+ * loaded or does not list it.
185
+ *
186
+ * A tested model (it took a full-size request, as Jev takes every use's
187
+ * request in production) is sized from its measured profile only: with no
188
+ * measured limit, each use keeps the request it was measured with. The
189
+ * catalog does not size it, because the request estimate counts high and a
190
+ * catalog value would then split or refuse requests the model answers.
191
+ * Any other model gets the careful limits, lowered to the catalog's context
192
+ * size when that is smaller.
193
+ */
194
+ export function decisionRequestLimits(
195
+ model: string | null | undefined,
196
+ catalogContext: number | null,
197
+ ): DecisionRequestLimits {
198
+ const p = decisionModelProfile(model);
199
+ const ctx =
200
+ typeof catalogContext === 'number' && Number.isFinite(catalogContext) && catalogContext > 0
201
+ ? catalogContext
202
+ : null;
203
+ const low = (...xs: Array<number | null | undefined>): number | null => {
204
+ const known = xs.filter((x): x is number => typeof x === 'number');
205
+ return known.length > 0 ? Math.min(...known) : null;
206
+ };
207
+ const tested =
208
+ p !== null && (p.status === 'works' || p.status === 'no_training_only' || p.status === 'slow');
209
+ if (!tested) {
210
+ const tokens = low(CAREFUL_DECISION_LIMITS.maxInputTokens, ctx, p?.suspectedCutAt);
211
+ return {
212
+ maxQuestions: low(CAREFUL_DECISION_LIMITS.maxQuestions, p?.maxQuestions),
213
+ maxInputTokens: tokens,
214
+ cutAt: p?.suspectedCutAt ?? tokens,
215
+ source: 'careful',
216
+ };
217
+ }
218
+ const tokens = low(p.maxInputTokens, p.suspectedCutAt);
219
+ return {
220
+ maxQuestions: p.maxQuestions ?? null,
221
+ maxInputTokens: tokens,
222
+ cutAt: p.suspectedCutAt ?? tokens,
223
+ source: 'profile',
224
+ };
225
+ }