pi-cliproxyapi-provider 0.2.0 → 0.3.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.
package/README.md CHANGED
@@ -146,7 +146,7 @@ Startup registers the provider immediately from the last-known-good local snapsh
146
146
 
147
147
  Manual refreshes update the running provider immediately; `/reload` is not required. Failed refreshes retain the last-known-good data independently for each source.
148
148
 
149
- A scheduled GitHub Actions workflow checks the bundled fallback catalog daily. When it changes, the workflow validates the package, bumps the patch version, commits the update, and publishes the new version to npm. Maintainers can also update the catalog locally with:
149
+ A scheduled GitHub Actions workflow checks the bundled fallback catalog daily. When it changes, the workflow validates the package, bumps the patch version, commits the update, and starts the normal release workflow. Maintainers can also update the catalog locally with:
150
150
 
151
151
  ```bash
152
152
  npm run update:models-dev
@@ -160,4 +160,4 @@ npm test
160
160
 
161
161
  ## Release
162
162
 
163
- Releases are published to npm when a matching `v*` tag is pushed. Changed daily models.dev catalogs also produce automatic patch releases. See [RELEASING.md](RELEASING.md) for authentication, versioning, verification, and troubleshooting.
163
+ Changing the `package.json` version on `master` automatically creates a matching Git tag and GitHub Release, generates release notes, and publishes the package to npm. Changed daily models.dev catalogs also produce automatic patch releases through the same workflow. See [RELEASING.md](RELEASING.md) for authentication, versioning, verification, and troubleshooting.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-cliproxyapi-provider",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Pi provider package for CLIProxyAPI with automatic model discovery and models.dev enrichment.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -0,0 +1,54 @@
1
+ import type { ThinkingLevelMap } from "@earendil-works/pi-ai";
2
+
3
+ export interface ModelCapabilityContext {
4
+ availableModelId: string;
5
+ metadataModelId?: string;
6
+ }
7
+
8
+ export interface ModelCapabilityOverrides {
9
+ reasoning?: boolean;
10
+ thinkingLevelMap?: ThinkingLevelMap;
11
+ }
12
+
13
+ interface ModelCapabilityRule {
14
+ matches: (context: ModelCapabilityContext) => boolean;
15
+ overrides: ModelCapabilityOverrides;
16
+ }
17
+
18
+ const GPT_5_6_THINKING_LEVEL_MAP: ThinkingLevelMap = {
19
+ off: "none",
20
+ minimal: "minimal",
21
+ low: "low",
22
+ medium: "medium",
23
+ high: "high",
24
+ xhigh: "xhigh",
25
+ max: "max",
26
+ };
27
+
28
+ function includesModelFamily(context: ModelCapabilityContext, family: string): boolean {
29
+ return [context.availableModelId, context.metadataModelId]
30
+ .filter((id): id is string => id !== undefined)
31
+ .some((id) => id.includes(family));
32
+ }
33
+
34
+ const MODEL_CAPABILITY_RULES: readonly ModelCapabilityRule[] = [
35
+ {
36
+ matches: (context) => includesModelFamily(context, "gpt-5.6"),
37
+ overrides: {
38
+ reasoning: true,
39
+ thinkingLevelMap: GPT_5_6_THINKING_LEVEL_MAP,
40
+ },
41
+ },
42
+ ];
43
+
44
+ export function getModelCapabilityOverrides(context: ModelCapabilityContext): ModelCapabilityOverrides {
45
+ const resolved: ModelCapabilityOverrides = {};
46
+
47
+ for (const rule of MODEL_CAPABILITY_RULES) {
48
+ if (!rule.matches(context)) continue;
49
+ if (rule.overrides.reasoning !== undefined) resolved.reasoning = rule.overrides.reasoning;
50
+ if (rule.overrides.thinkingLevelMap) resolved.thinkingLevelMap = { ...rule.overrides.thinkingLevelMap };
51
+ }
52
+
53
+ return resolved;
54
+ }
package/src/provider.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { CpaModel } from "./cpa.ts";
2
2
  import { findMetadataMatch, type MetadataMatchMethod } from "./matching.ts";
3
+ import { getModelCapabilityOverrides } from "./model-capabilities.ts";
3
4
  import type { InputModality, ModelsDevCatalog, ModelsDevMetadata, ProviderModelConfigLike } from "./types.ts";
4
5
 
5
6
  export const PI_MODEL_DEFAULTS = {
@@ -38,10 +39,18 @@ function costFromMetadata(metadata: ModelsDevMetadata): ProviderModelConfigLike[
38
39
  }
39
40
 
40
41
  function modelFromMetadata(cpaModel: CpaModel, metadata: ModelsDevMetadata): ProviderModelConfigLike {
42
+ const capabilityOverrides = getModelCapabilityOverrides({
43
+ availableModelId: cpaModel.id,
44
+ metadataModelId: metadata.id,
45
+ });
46
+
41
47
  return {
42
48
  id: cpaModel.id,
43
49
  name: metadata.name ?? cpaModel.id,
44
- reasoning: metadata.reasoning ?? PI_MODEL_DEFAULTS.reasoning,
50
+ reasoning: capabilityOverrides.reasoning ?? metadata.reasoning ?? PI_MODEL_DEFAULTS.reasoning,
51
+ ...(capabilityOverrides.thinkingLevelMap
52
+ ? { thinkingLevelMap: capabilityOverrides.thinkingLevelMap }
53
+ : {}),
45
54
  input: inputFromMetadata(metadata),
46
55
  cost: costFromMetadata(metadata),
47
56
  contextWindow: metadata.limit?.context ?? PI_MODEL_DEFAULTS.contextWindow,
@@ -58,10 +67,13 @@ function cloneModelDefaults(): typeof PI_MODEL_DEFAULTS {
58
67
  }
59
68
 
60
69
  function defaultModel(cpaModel: CpaModel): ProviderModelConfigLike {
70
+ const capabilityOverrides = getModelCapabilityOverrides({ availableModelId: cpaModel.id });
71
+
61
72
  return {
62
73
  id: cpaModel.id,
63
74
  name: cpaModel.id,
64
75
  ...cloneModelDefaults(),
76
+ ...capabilityOverrides,
65
77
  };
66
78
  }
67
79
 
package/src/types.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { ThinkingLevelMap } from "@earendil-works/pi-ai";
2
+
1
3
  export type InputModality = "text" | "image";
2
4
 
3
5
  export interface CpaProviderConfig {
@@ -36,6 +38,7 @@ export interface ProviderModelConfigLike {
36
38
  id: string;
37
39
  name: string;
38
40
  reasoning: boolean;
41
+ thinkingLevelMap?: ThinkingLevelMap;
39
42
  input: InputModality[];
40
43
  cost: {
41
44
  input: number;