@adaptic/lumic-utils 1.0.27 → 1.0.29

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 (33) hide show
  1. package/dist/{apollo-client.client-eo-xgmdi.js → apollo-client.client-BQLzKbg9.js} +4 -4
  2. package/dist/{apollo-client.client-eo-xgmdi.js.map → apollo-client.client-BQLzKbg9.js.map} +1 -1
  3. package/dist/{apollo-client.client-DD13VF_T.js → apollo-client.client-C1dwHT2X.js} +3 -3
  4. package/dist/{apollo-client.client-DD13VF_T.js.map → apollo-client.client-C1dwHT2X.js.map} +1 -1
  5. package/dist/{apollo-client.server-BxpJcsVI.js → apollo-client.server-Crk0lXFR.js} +3 -3
  6. package/dist/{apollo-client.server-BxpJcsVI.js.map → apollo-client.server-Crk0lXFR.js.map} +1 -1
  7. package/dist/{apollo-client.server-2zi9dbLa.js → apollo-client.server-DoI6FK_-.js} +3 -3
  8. package/dist/{apollo-client.server-2zi9dbLa.js.map → apollo-client.server-DoI6FK_-.js.map} +1 -1
  9. package/dist/{index-BbwdRyPk.js → index-CV8HlDp8.js} +719 -42
  10. package/dist/{index-zDK1X6HR.js.map → index-CV8HlDp8.js.map} +1 -1
  11. package/dist/{index-zDK1X6HR.js → index-CtY-7qjs.js} +720 -41
  12. package/dist/{index-BbwdRyPk.js.map → index-CtY-7qjs.js.map} +1 -1
  13. package/dist/{index-BQ1buNZm.js → index-DA066GXe.js} +2 -2
  14. package/dist/{index-BQ1buNZm.js.map → index-DA066GXe.js.map} +1 -1
  15. package/dist/{index-CV0UmY0w.js → index-IAFN9E4Q.js} +2 -2
  16. package/dist/{index-CV0UmY0w.js.map → index-IAFN9E4Q.js.map} +1 -1
  17. package/dist/index.cjs +3 -1
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.mjs +1 -1
  20. package/dist/test.cjs +1 -1
  21. package/dist/test.mjs +1 -1
  22. package/dist/types/config/secrets.d.ts +10 -0
  23. package/dist/types/functions/__tests__/gpt56-model-release-layer.test.d.ts +1 -0
  24. package/dist/types/functions/__tests__/llm-openai-responses-routing.test.d.ts +1 -0
  25. package/dist/types/functions/llm-config.d.ts +8 -6
  26. package/dist/types/functions/llm-openai.d.ts +125 -2
  27. package/dist/types/index.d.ts +1 -1
  28. package/dist/types/schemas/openai-schemas.d.ts +30 -30
  29. package/dist/types/schemas/perplexity-schemas.d.ts +40 -40
  30. package/dist/types/types/openai-types.d.ts +42 -5
  31. package/dist/types/utils/config.d.ts +12 -1
  32. package/dist/types/utils/llm-cost-tracker.d.ts +2 -2
  33. package/package.json +1 -1
@@ -16,43 +16,43 @@ export declare const perplexityResponseSchema: z.ZodObject<{
16
16
  role: z.ZodEnum<["assistant"]>;
17
17
  content: z.ZodString;
18
18
  }, "strip", z.ZodTypeAny, {
19
- content: string;
20
19
  role: "assistant";
21
- }, {
22
20
  content: string;
21
+ }, {
23
22
  role: "assistant";
23
+ content: string;
24
24
  }>;
25
25
  delta: z.ZodOptional<z.ZodObject<{
26
26
  role: z.ZodOptional<z.ZodString>;
27
27
  content: z.ZodOptional<z.ZodString>;
28
28
  }, "strip", z.ZodTypeAny, {
29
- content?: string | undefined;
30
29
  role?: string | undefined;
31
- }, {
32
30
  content?: string | undefined;
31
+ }, {
33
32
  role?: string | undefined;
33
+ content?: string | undefined;
34
34
  }>>;
35
35
  }, "strip", z.ZodTypeAny, {
36
36
  message: {
37
- content: string;
38
37
  role: "assistant";
38
+ content: string;
39
39
  };
40
40
  index: number;
41
41
  finish_reason: "length" | "stop" | "model_length" | null;
42
42
  delta?: {
43
- content?: string | undefined;
44
43
  role?: string | undefined;
44
+ content?: string | undefined;
45
45
  } | undefined;
46
46
  }, {
47
47
  message: {
48
- content: string;
49
48
  role: "assistant";
49
+ content: string;
50
50
  };
51
51
  index: number;
52
52
  finish_reason: "length" | "stop" | "model_length" | null;
53
53
  delta?: {
54
- content?: string | undefined;
55
54
  role?: string | undefined;
55
+ content?: string | undefined;
56
56
  } | undefined;
57
57
  }>, "many">;
58
58
  usage: z.ZodOptional<z.ZodObject<{
@@ -81,43 +81,43 @@ export declare const perplexityResponseSchema: z.ZodObject<{
81
81
  role: z.ZodEnum<["assistant"]>;
82
82
  content: z.ZodString;
83
83
  }, "strip", z.ZodTypeAny, {
84
- content: string;
85
84
  role: "assistant";
86
- }, {
87
85
  content: string;
86
+ }, {
88
87
  role: "assistant";
88
+ content: string;
89
89
  }>;
90
90
  delta: z.ZodOptional<z.ZodObject<{
91
91
  role: z.ZodOptional<z.ZodString>;
92
92
  content: z.ZodOptional<z.ZodString>;
93
93
  }, "strip", z.ZodTypeAny, {
94
- content?: string | undefined;
95
94
  role?: string | undefined;
96
- }, {
97
95
  content?: string | undefined;
96
+ }, {
98
97
  role?: string | undefined;
98
+ content?: string | undefined;
99
99
  }>>;
100
100
  }, "strip", z.ZodTypeAny, {
101
101
  message: {
102
- content: string;
103
102
  role: "assistant";
103
+ content: string;
104
104
  };
105
105
  index: number;
106
106
  finish_reason: "length" | "stop" | "model_length" | null;
107
107
  delta?: {
108
- content?: string | undefined;
109
108
  role?: string | undefined;
109
+ content?: string | undefined;
110
110
  } | undefined;
111
111
  }, {
112
112
  message: {
113
- content: string;
114
113
  role: "assistant";
114
+ content: string;
115
115
  };
116
116
  index: number;
117
117
  finish_reason: "length" | "stop" | "model_length" | null;
118
118
  delta?: {
119
- content?: string | undefined;
120
119
  role?: string | undefined;
120
+ content?: string | undefined;
121
121
  } | undefined;
122
122
  }>, "many">;
123
123
  usage: z.ZodOptional<z.ZodObject<{
@@ -146,43 +146,43 @@ export declare const perplexityResponseSchema: z.ZodObject<{
146
146
  role: z.ZodEnum<["assistant"]>;
147
147
  content: z.ZodString;
148
148
  }, "strip", z.ZodTypeAny, {
149
- content: string;
150
149
  role: "assistant";
151
- }, {
152
150
  content: string;
151
+ }, {
153
152
  role: "assistant";
153
+ content: string;
154
154
  }>;
155
155
  delta: z.ZodOptional<z.ZodObject<{
156
156
  role: z.ZodOptional<z.ZodString>;
157
157
  content: z.ZodOptional<z.ZodString>;
158
158
  }, "strip", z.ZodTypeAny, {
159
- content?: string | undefined;
160
159
  role?: string | undefined;
161
- }, {
162
160
  content?: string | undefined;
161
+ }, {
163
162
  role?: string | undefined;
163
+ content?: string | undefined;
164
164
  }>>;
165
165
  }, "strip", z.ZodTypeAny, {
166
166
  message: {
167
- content: string;
168
167
  role: "assistant";
168
+ content: string;
169
169
  };
170
170
  index: number;
171
171
  finish_reason: "length" | "stop" | "model_length" | null;
172
172
  delta?: {
173
- content?: string | undefined;
174
173
  role?: string | undefined;
174
+ content?: string | undefined;
175
175
  } | undefined;
176
176
  }, {
177
177
  message: {
178
- content: string;
179
178
  role: "assistant";
179
+ content: string;
180
180
  };
181
181
  index: number;
182
182
  finish_reason: "length" | "stop" | "model_length" | null;
183
183
  delta?: {
184
- content?: string | undefined;
185
184
  role?: string | undefined;
185
+ content?: string | undefined;
186
186
  } | undefined;
187
187
  }>, "many">;
188
188
  usage: z.ZodOptional<z.ZodObject<{
@@ -215,43 +215,43 @@ export declare const validatePerplexityResponse: (data: unknown) => z.objectInpu
215
215
  role: z.ZodEnum<["assistant"]>;
216
216
  content: z.ZodString;
217
217
  }, "strip", z.ZodTypeAny, {
218
- content: string;
219
218
  role: "assistant";
220
- }, {
221
219
  content: string;
220
+ }, {
222
221
  role: "assistant";
222
+ content: string;
223
223
  }>;
224
224
  delta: z.ZodOptional<z.ZodObject<{
225
225
  role: z.ZodOptional<z.ZodString>;
226
226
  content: z.ZodOptional<z.ZodString>;
227
227
  }, "strip", z.ZodTypeAny, {
228
- content?: string | undefined;
229
228
  role?: string | undefined;
230
- }, {
231
229
  content?: string | undefined;
230
+ }, {
232
231
  role?: string | undefined;
232
+ content?: string | undefined;
233
233
  }>>;
234
234
  }, "strip", z.ZodTypeAny, {
235
235
  message: {
236
- content: string;
237
236
  role: "assistant";
237
+ content: string;
238
238
  };
239
239
  index: number;
240
240
  finish_reason: "length" | "stop" | "model_length" | null;
241
241
  delta?: {
242
- content?: string | undefined;
243
242
  role?: string | undefined;
243
+ content?: string | undefined;
244
244
  } | undefined;
245
245
  }, {
246
246
  message: {
247
- content: string;
248
247
  role: "assistant";
248
+ content: string;
249
249
  };
250
250
  index: number;
251
251
  finish_reason: "length" | "stop" | "model_length" | null;
252
252
  delta?: {
253
- content?: string | undefined;
254
253
  role?: string | undefined;
254
+ content?: string | undefined;
255
255
  } | undefined;
256
256
  }>, "many">;
257
257
  usage: z.ZodOptional<z.ZodObject<{
@@ -282,43 +282,43 @@ export declare const safeValidatePerplexityResponse: (data: unknown) => import("
282
282
  role: z.ZodEnum<["assistant"]>;
283
283
  content: z.ZodString;
284
284
  }, "strip", z.ZodTypeAny, {
285
- content: string;
286
285
  role: "assistant";
287
- }, {
288
286
  content: string;
287
+ }, {
289
288
  role: "assistant";
289
+ content: string;
290
290
  }>;
291
291
  delta: z.ZodOptional<z.ZodObject<{
292
292
  role: z.ZodOptional<z.ZodString>;
293
293
  content: z.ZodOptional<z.ZodString>;
294
294
  }, "strip", z.ZodTypeAny, {
295
- content?: string | undefined;
296
295
  role?: string | undefined;
297
- }, {
298
296
  content?: string | undefined;
297
+ }, {
299
298
  role?: string | undefined;
299
+ content?: string | undefined;
300
300
  }>>;
301
301
  }, "strip", z.ZodTypeAny, {
302
302
  message: {
303
- content: string;
304
303
  role: "assistant";
304
+ content: string;
305
305
  };
306
306
  index: number;
307
307
  finish_reason: "length" | "stop" | "model_length" | null;
308
308
  delta?: {
309
- content?: string | undefined;
310
309
  role?: string | undefined;
310
+ content?: string | undefined;
311
311
  } | undefined;
312
312
  }, {
313
313
  message: {
314
- content: string;
315
314
  role: "assistant";
315
+ content: string;
316
316
  };
317
317
  index: number;
318
318
  finish_reason: "length" | "stop" | "model_length" | null;
319
319
  delta?: {
320
- content?: string | undefined;
321
320
  role?: string | undefined;
321
+ content?: string | undefined;
322
322
  } | undefined;
323
323
  }>, "many">;
324
324
  usage: z.ZodOptional<z.ZodObject<{
@@ -15,6 +15,26 @@ export interface ModelCapabilities {
15
15
  supportsDeveloperPrompt: boolean;
16
16
  supportsTemperature: boolean;
17
17
  isReasoningModel: boolean;
18
+ /**
19
+ * When `true`, function tools MUST be sent via the OpenAI Responses API
20
+ * (`/v1/responses`) rather than Chat Completions (`/v1/chat/completions`).
21
+ *
22
+ * OpenAI's GPT-5.6 reasoning trio (sol/terra/luna) returns HTTP 400
23
+ * ("Function tools with reasoning_effort are not supported for gpt-5.6-sol
24
+ * in /v1/chat/completions") whenever `tools` is present on a Chat
25
+ * Completions request. The lumic OpenAI provider reads this flag to
26
+ * transparently route tool-bearing calls for such models to the Responses
27
+ * API while keeping the returned {@link LLMResponse} envelope byte-identical.
28
+ *
29
+ * Omitted (⇒ `false`) for every model that accepts function tools on Chat
30
+ * Completions — INCLUDING the o-series reasoning models (o1/o3/o4-mini),
31
+ * which accept `tools` on `/v1/chat/completions` today and therefore stay on
32
+ * the Chat path. Only set this when a model 400s on Chat Completions + tools.
33
+ *
34
+ * Deliberately data-driven: the call path branches on this flag, never on
35
+ * hardcoded model-name string checks.
36
+ */
37
+ requiresResponsesApiForTools?: boolean;
18
38
  }
19
39
  /**
20
40
  * Configuration for OpenAI-compatible providers (Deepseek, Kimi, Qwen, xAI, Gemini, etc.)
@@ -41,7 +61,8 @@ export declare const SUPPORTED_MODELS: {
41
61
  readonly supportsStructuredOutput: true;
42
62
  readonly supportsDeveloperPrompt: true;
43
63
  readonly supportsTemperature: false;
44
- readonly isReasoningModel: false;
64
+ readonly isReasoningModel: true;
65
+ readonly requiresResponsesApiForTools: true;
45
66
  };
46
67
  readonly 'gpt-5.6-terra': {
47
68
  readonly provider: "openai";
@@ -50,7 +71,8 @@ export declare const SUPPORTED_MODELS: {
50
71
  readonly supportsStructuredOutput: true;
51
72
  readonly supportsDeveloperPrompt: true;
52
73
  readonly supportsTemperature: false;
53
- readonly isReasoningModel: false;
74
+ readonly isReasoningModel: true;
75
+ readonly requiresResponsesApiForTools: true;
54
76
  };
55
77
  readonly 'gpt-5.6-luna': {
56
78
  readonly provider: "openai";
@@ -59,7 +81,8 @@ export declare const SUPPORTED_MODELS: {
59
81
  readonly supportsStructuredOutput: true;
60
82
  readonly supportsDeveloperPrompt: true;
61
83
  readonly supportsTemperature: false;
62
- readonly isReasoningModel: false;
84
+ readonly isReasoningModel: true;
85
+ readonly requiresResponsesApiForTools: true;
63
86
  };
64
87
  readonly 'gpt-5.5': {
65
88
  readonly provider: "openai";
@@ -549,7 +572,15 @@ export interface LLMOptions {
549
572
  developerPrompt?: string;
550
573
  context?: ChatCompletionMessageParam[];
551
574
  store?: boolean;
552
- reasoning_effort?: 'low' | 'medium' | 'high';
575
+ /**
576
+ * Reasoning effort for reasoning models, on OpenAI's 2026 ladder ordered from
577
+ * least to most effort: `none` < `minimal` < `low` < `medium` < `high` <
578
+ * `xhigh`. (There is no `max` level.) Callers may request any level; the
579
+ * OpenAI provider clamps it per-model to a level the target model — and the
580
+ * installed OpenAI SDK — actually accepts, so an over- or under-shoot degrades
581
+ * gracefully instead of returning HTTP 400. Ignored for non-reasoning models.
582
+ */
583
+ reasoning_effort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
553
584
  metadata?: Record<string, string>;
554
585
  parallel_tool_calls?: boolean;
555
586
  service_tier?: 'auto' | 'default';
@@ -604,12 +635,18 @@ export type OpenAIResponseFormat = 'text' | 'json' | {
604
635
  };
605
636
  };
606
637
  /**
607
- * Default model tiers per provider for use with LLM_MODEL_MINI/NORMAL/ADVANCED env vars
638
+ * Default model tiers per provider for use with the
639
+ * LLM_MODEL_MINI/NORMAL/ADVANCED/CRITICAL env vars.
640
+ *
641
+ * Four tiers, increasing in capability/cost: `mini` (high-volume, cheap) →
642
+ * `normal` (default) → `advanced` → `critical` (most-capable). The tier a caller
643
+ * lands on is resolved in `../utils/config` (see `LLM_MODEL_*`).
608
644
  */
609
645
  export declare const PROVIDER_DEFAULT_MODELS: Record<LLMProvider, {
610
646
  mini: SupportedModel;
611
647
  normal: SupportedModel;
612
648
  advanced: SupportedModel;
649
+ critical: SupportedModel;
613
650
  }>;
614
651
  /**
615
652
  * Represents the options for the OpenAI Images API.
@@ -10,6 +10,7 @@ export declare const LLM_DEFAULT_PROVIDER: LLMProvider;
10
10
  export declare const LLM_MINI_PROVIDER: LLMProvider;
11
11
  export declare const LLM_NORMAL_PROVIDER: LLMProvider;
12
12
  export declare const LLM_ADVANCED_PROVIDER: LLMProvider;
13
+ export declare const LLM_CRITICAL_PROVIDER: LLMProvider;
13
14
  export declare const LLM_PROVIDER: LLMProvider;
14
15
  /**
15
16
  * The default model to use when no model is specified.
@@ -20,17 +21,25 @@ export declare const DEFAULT_MODEL: LLMModel;
20
21
  * Model tier values resolved from env vars.
21
22
  *
22
23
  * Resolution order per tier:
23
- * 1. LLM_MODEL_MINI / LLM_MODEL_NORMAL / LLM_MODEL_ADVANCED (explicit model override)
24
+ * 1. LLM_MODEL_MINI / LLM_MODEL_NORMAL / LLM_MODEL_ADVANCED / LLM_MODEL_CRITICAL (explicit model override)
24
25
  * 2. PROVIDER_DEFAULT_MODELS[tier-specific provider][tier] (provider default for tier)
25
26
  *
26
27
  * The tier-specific provider is:
27
28
  * LLM_MINI_PROVIDER → falls back to LLM_DEFAULT_PROVIDER
28
29
  * LLM_NORMAL_PROVIDER → falls back to LLM_DEFAULT_PROVIDER
29
30
  * LLM_ADVANCED_PROVIDER → falls back to LLM_DEFAULT_PROVIDER
31
+ * LLM_CRITICAL_PROVIDER → falls back to LLM_DEFAULT_PROVIDER
30
32
  */
31
33
  export declare const LLM_MODEL_MINI: LLMModel;
32
34
  export declare const LLM_MODEL_NORMAL: LLMModel;
33
35
  export declare const LLM_MODEL_ADVANCED: LLMModel;
36
+ /**
37
+ * The most-capable ("critical") model tier — reserved for the highest-stakes
38
+ * calls. Resolves from LLM_MODEL_CRITICAL, else the critical-tier default of the
39
+ * resolved LLM_CRITICAL_PROVIDER (see PROVIDER_DEFAULT_MODELS). For OpenAI this
40
+ * is gpt-5.6-sol; for other providers it mirrors their advanced tier.
41
+ */
42
+ export declare const LLM_MODEL_CRITICAL: LLMModel;
34
43
  export declare const PERPLEXITY_MODEL: string;
35
44
  export declare const PERPLEXITY_API_URL = "https://api.perplexity.ai/chat/completions";
36
45
  export interface Config {
@@ -39,9 +48,11 @@ export interface Config {
39
48
  LLM_MINI_PROVIDER: LLMProvider;
40
49
  LLM_NORMAL_PROVIDER: LLMProvider;
41
50
  LLM_ADVANCED_PROVIDER: LLMProvider;
51
+ LLM_CRITICAL_PROVIDER: LLMProvider;
42
52
  LLM_MODEL_MINI: string;
43
53
  LLM_MODEL_NORMAL: string;
44
54
  LLM_MODEL_ADVANCED: string;
55
+ LLM_MODEL_CRITICAL: string;
45
56
  PERPLEXITY_MODEL: string;
46
57
  PERPLEXITY_API_URL: string;
47
58
  }
@@ -107,8 +107,8 @@ export declare class LLMCostTracker {
107
107
  * @param provider - The LLM provider ('openai' or 'deepseek')
108
108
  * @param model - The model name (e.g., 'gpt-5', 'deepseek-chat')
109
109
  * @param inputTokens - Number of input/prompt tokens
110
- * @param outputTokens - Number of output/completion tokens
111
- * @param reasoningTokens - Number of reasoning tokens (default: 0)
110
+ * @param outputTokens - Total output/completion tokens, INCLUDING reasoning tokens
111
+ * @param reasoningTokens - Reasoning tokens, a subset of outputTokens (default: 0). Billed at the output rate, not on top of it.
112
112
  * @param cacheHitTokens - Number of cache hit tokens (default: 0)
113
113
  */
114
114
  trackUsage(provider: string, model: string, inputTokens: number, outputTokens: number, reasoningTokens?: number, cacheHitTokens?: number): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptic/lumic-utils",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "NPM repo set of utility functions usable across the entire organisation.",
5
5
  "always-build-npm": false,
6
6
  "type": "module",