@leitwerk-dev/models 0.2.0 → 0.2.1
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/README.md +8 -0
- package/dist/index.d.ts +3 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +60 -25
- package/dist/index.js.map +1 -1
- package/dist/models-provider.d.ts +72 -0
- package/dist/models-provider.d.ts.map +1 -1
- package/dist/provider-auth.d.ts +3 -1
- package/dist/provider-auth.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +9 -5
- package/src/models-provider.ts +99 -17
- package/src/provider-auth.ts +3 -1
package/README.md
CHANGED
|
@@ -56,3 +56,11 @@ Standard providers accept an optional `models` list to add deployments or replac
|
|
|
56
56
|
Both kinds of model definition accept `thinking_level_map`, `input`, `cost`, and `compat`. Thinking-map keys are `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`; `null` marks a level unsupported. `context_window`, `max_tokens`, and `thinking_level_map` are converted to Pi's field names. `cost` and `compat` use Pi's camelCase keys directly. Gateway-level compatibility settings apply to all models; model-level settings override them. Supported compatibility keys are `supportsStore`, `supportsDeveloperRole`, `supportsReasoningEffort`, `supportsUsageInStreaming`, `maxTokensField`, `supportsStrictMode`, `thinkingFormat`, and `requiresReasoningContentOnAssistantMessages`. Model IDs must be unique within each list, and unknown metadata fields are rejected.
|
|
57
57
|
|
|
58
58
|
Custom gateways support `openai-completions`, `openai-responses`, `anthropic-messages`, and `google-generative-ai`. They support worker LLM turns. Because they do not declare a server adapter, they cannot be selected for process-title generation.
|
|
59
|
+
|
|
60
|
+
## API support
|
|
61
|
+
|
|
62
|
+
The following exported declarations are `@public`:
|
|
63
|
+
|
|
64
|
+
- `@leitwerk-dev/models`: `default`.
|
|
65
|
+
|
|
66
|
+
See the [SDK compatibility policy](../../docs/process-sdk.md#api-compatibility) for member classifications and support guarantees.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
declare const modelsExtension: {
|
|
6
|
-
manifest: {
|
|
7
|
-
readonly id: "models";
|
|
8
|
-
readonly version: "0.1.0";
|
|
9
|
-
};
|
|
10
|
-
modelProviders: import("@leitwerk-dev/process-sdk").ModelProviderSet;
|
|
11
|
-
};
|
|
1
|
+
import { type LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
/** @public */
|
|
3
|
+
declare const modelsExtension: LeitwerkExtensionModule;
|
|
12
4
|
export default modelsExtension;
|
|
13
|
-
export * from "./models-provider.js";
|
|
14
|
-
export * from "./provider-auth.js";
|
|
15
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAW/F,cAAc;AACd,QAAA,MAAM,eAAe,EAAE,uBAKtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -112,22 +112,37 @@ var positiveIntegerSchema = v3.pipe(v3.number(), v3.integer(), v3.minValue(1));
|
|
|
112
112
|
var nonNegativeNumberSchema = v3.pipe(v3.number(), v3.finite(), v3.minValue(0));
|
|
113
113
|
var thinkingLevelValueSchema = v3.optional(v3.nullable(nonEmptyStringSchema));
|
|
114
114
|
var thinkingLevelMapSchema = v3.strictObject({
|
|
115
|
+
/** @internal */
|
|
115
116
|
off: thinkingLevelValueSchema,
|
|
117
|
+
/** @internal */
|
|
116
118
|
minimal: thinkingLevelValueSchema,
|
|
119
|
+
/** @internal */
|
|
117
120
|
low: thinkingLevelValueSchema,
|
|
121
|
+
/** @internal */
|
|
118
122
|
medium: thinkingLevelValueSchema,
|
|
123
|
+
/** @internal */
|
|
119
124
|
high: thinkingLevelValueSchema,
|
|
125
|
+
/** @internal */
|
|
120
126
|
xhigh: thinkingLevelValueSchema,
|
|
127
|
+
/** @internal */
|
|
121
128
|
max: thinkingLevelValueSchema
|
|
122
129
|
});
|
|
123
130
|
var compatibilitySchema = v3.strictObject({
|
|
131
|
+
/** @internal */
|
|
124
132
|
supportsStore: v3.optional(v3.boolean()),
|
|
133
|
+
/** @internal */
|
|
125
134
|
supportsDeveloperRole: v3.optional(v3.boolean()),
|
|
135
|
+
/** @internal */
|
|
126
136
|
supportsReasoningEffort: v3.optional(v3.boolean()),
|
|
137
|
+
/** @internal */
|
|
127
138
|
supportsUsageInStreaming: v3.optional(v3.boolean()),
|
|
139
|
+
/** @internal */
|
|
128
140
|
maxTokensField: v3.optional(v3.picklist(["max_tokens", "max_completion_tokens"])),
|
|
141
|
+
/** @internal */
|
|
129
142
|
supportsStrictMode: v3.optional(v3.boolean()),
|
|
143
|
+
/** @internal */
|
|
130
144
|
requiresReasoningContentOnAssistantMessages: v3.optional(v3.boolean()),
|
|
145
|
+
/** @internal */
|
|
131
146
|
thinkingFormat: v3.optional(
|
|
132
147
|
v3.picklist([
|
|
133
148
|
"openai",
|
|
@@ -144,9 +159,13 @@ var compatibilitySchema = v3.strictObject({
|
|
|
144
159
|
)
|
|
145
160
|
});
|
|
146
161
|
var modelCostSchema = v3.strictObject({
|
|
162
|
+
/** @internal */
|
|
147
163
|
input: nonNegativeNumberSchema,
|
|
164
|
+
/** @internal */
|
|
148
165
|
output: nonNegativeNumberSchema,
|
|
166
|
+
/** @internal */
|
|
149
167
|
cacheRead: nonNegativeNumberSchema,
|
|
168
|
+
/** @internal */
|
|
150
169
|
cacheWrite: nonNegativeNumberSchema
|
|
151
170
|
});
|
|
152
171
|
var baseUrlSchema = v3.pipe(
|
|
@@ -161,21 +180,39 @@ var baseUrlSchema = v3.pipe(
|
|
|
161
180
|
);
|
|
162
181
|
var customModelSchema = v3.pipe(
|
|
163
182
|
v3.strictObject({
|
|
183
|
+
/** @internal */
|
|
164
184
|
id: nonEmptyStringSchema,
|
|
185
|
+
/** @internal */
|
|
165
186
|
name: v3.optional(nonEmptyStringSchema),
|
|
187
|
+
/** @internal */
|
|
166
188
|
reasoning: v3.optional(v3.boolean()),
|
|
189
|
+
/** @internal */
|
|
167
190
|
thinking_level_map: v3.optional(thinkingLevelMapSchema),
|
|
191
|
+
/** @internal */
|
|
168
192
|
input: v3.optional(v3.pipe(v3.array(v3.picklist(["text", "image"])), v3.minLength(1))),
|
|
193
|
+
/** @internal */
|
|
169
194
|
cost: v3.optional(modelCostSchema),
|
|
195
|
+
/** @internal */
|
|
170
196
|
compat: v3.optional(compatibilitySchema),
|
|
197
|
+
/** @internal */
|
|
171
198
|
context_window: v3.optional(positiveIntegerSchema),
|
|
199
|
+
/** @internal */
|
|
172
200
|
max_tokens: v3.optional(positiveIntegerSchema)
|
|
173
201
|
}),
|
|
174
202
|
v3.transform(({ context_window, max_tokens, thinking_level_map, ...model }) => ({
|
|
175
203
|
...model,
|
|
176
|
-
...thinking_level_map === void 0 ? {} : {
|
|
177
|
-
|
|
178
|
-
|
|
204
|
+
...thinking_level_map === void 0 ? {} : {
|
|
205
|
+
/** @internal */
|
|
206
|
+
thinkingLevelMap: thinking_level_map
|
|
207
|
+
},
|
|
208
|
+
...context_window === void 0 ? {} : {
|
|
209
|
+
/** @internal */
|
|
210
|
+
contextWindow: context_window
|
|
211
|
+
},
|
|
212
|
+
...max_tokens === void 0 ? {} : {
|
|
213
|
+
/** @internal */
|
|
214
|
+
maxTokens: max_tokens
|
|
215
|
+
}
|
|
179
216
|
}))
|
|
180
217
|
);
|
|
181
218
|
var modelDefinitionsSchema = v3.pipe(
|
|
@@ -208,15 +245,24 @@ function normalizeStandardModels(providerId, models, baseUrl) {
|
|
|
208
245
|
if (!reference) throw new Error(`Provider '${providerId}' has no canonical API definition`);
|
|
209
246
|
return {
|
|
210
247
|
...model,
|
|
248
|
+
/** @internal */
|
|
211
249
|
provider: providerId,
|
|
250
|
+
/** @internal */
|
|
212
251
|
api: reference.api,
|
|
252
|
+
/** @internal */
|
|
213
253
|
baseUrl: baseUrl ?? reference.baseUrl,
|
|
254
|
+
/** @internal */
|
|
214
255
|
name: model.name ?? model.id,
|
|
256
|
+
/** @internal */
|
|
215
257
|
reasoning: model.reasoning ?? false,
|
|
258
|
+
/** @internal */
|
|
216
259
|
input: model.input ?? ["text"],
|
|
260
|
+
/** @internal */
|
|
217
261
|
cost: model.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
218
262
|
// Match Pi's defaults for explicitly configured models.
|
|
263
|
+
/** @internal */
|
|
219
264
|
contextWindow: model.contextWindow ?? 128e3,
|
|
265
|
+
/** @internal */
|
|
220
266
|
maxTokens: model.maxTokens ?? 16384
|
|
221
267
|
};
|
|
222
268
|
});
|
|
@@ -256,17 +302,13 @@ function parseStandardProviderConfig(raw, providerId) {
|
|
|
256
302
|
assertKnownFields(rawConfig, ["api_key", "base_url", "models"]);
|
|
257
303
|
const apiKey = rawConfig.api_key === void 0 || rawConfig.api_key === null ? getStandardEnvApiKey(providerId) : resolveSecret(rawConfig.api_key, "api_key");
|
|
258
304
|
const baseUrl = rawConfig.base_url === void 0 || rawConfig.base_url === null ? void 0 : v3.parse(baseUrlSchema, resolveSecret(rawConfig.base_url, "base_url"));
|
|
305
|
+
const models = rawConfig.models === void 0 ? void 0 : normalizeStandardModels(
|
|
306
|
+
providerId,
|
|
307
|
+
v3.parse(modelDefinitionsSchema, rawConfig.models),
|
|
308
|
+
baseUrl
|
|
309
|
+
);
|
|
259
310
|
return {
|
|
260
|
-
config: {
|
|
261
|
-
...baseUrl ? { baseUrl } : {},
|
|
262
|
-
...rawConfig.models === void 0 ? {} : {
|
|
263
|
-
models: normalizeStandardModels(
|
|
264
|
-
providerId,
|
|
265
|
-
v3.parse(modelDefinitionsSchema, rawConfig.models),
|
|
266
|
-
baseUrl
|
|
267
|
-
)
|
|
268
|
-
}
|
|
269
|
-
},
|
|
311
|
+
config: { ...baseUrl ? { baseUrl } : {}, ...models ? { models } : {} },
|
|
270
312
|
...apiKey ? { credential: { apiKey } } : {}
|
|
271
313
|
};
|
|
272
314
|
}
|
|
@@ -370,26 +412,19 @@ function resolveModelProviders(raw) {
|
|
|
370
412
|
|
|
371
413
|
// src/index.ts
|
|
372
414
|
var manifest = {
|
|
415
|
+
/** @internal */
|
|
373
416
|
id: "models",
|
|
417
|
+
/** @internal */
|
|
374
418
|
version: "0.1.0"
|
|
375
419
|
};
|
|
376
420
|
var modelsExtension = {
|
|
421
|
+
/** @internal */
|
|
377
422
|
manifest,
|
|
423
|
+
/** @internal */
|
|
378
424
|
modelProviders: defineModelProviders(resolveModelProviders)
|
|
379
425
|
};
|
|
380
426
|
var index_default = modelsExtension;
|
|
381
427
|
export {
|
|
382
|
-
|
|
383
|
-
createStandardModelProvider,
|
|
384
|
-
index_default as default,
|
|
385
|
-
evaluateStandardModelStatuses,
|
|
386
|
-
getKnownEnvKeys,
|
|
387
|
-
getStandardEnvApiKey,
|
|
388
|
-
getSupportedStandardProviders,
|
|
389
|
-
manifest,
|
|
390
|
-
parseApiKeyCredential,
|
|
391
|
-
parseCustomGatewayConfig,
|
|
392
|
-
parseStandardProviderConfig,
|
|
393
|
-
resolveModelProviders
|
|
428
|
+
index_default as default
|
|
394
429
|
};
|
|
395
430
|
//# sourceMappingURL=index.js.map
|