@skydiveai/pi-server 0.1.252-beta.2 → 0.1.252-beta.21

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 (2) hide show
  1. package/dist/index.mjs +22 -1
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -859,6 +859,27 @@ function buildModelFromSpec(spec) {
859
859
  }
860
860
  }
861
861
  /**
862
+ * Per-model minimum output budgets for the models we dictate. A registry
863
+ * entry can carry a fabricated or missing maxTokens (models.dev source
864
+ * gaps): pi-ai then either sends the fabricated value (e.g. 4096 for
865
+ * z-ai/glm-5.3-flash, capping reasoning mid-thought with
866
+ * stop_reason=length) or omits the param entirely and the provider's
867
+ * built-in default applies. Listed models always send at least this
868
+ * budget; a higher registry value passes through untouched. Models not in
869
+ * the map are returned untouched - this is not a global floor.
870
+ */
871
+ const DICTATED_MODEL_MIN_MAX_TOKENS = { "glm-5.3-flash": 16384 };
872
+ function dictateModelMaxTokens(model) {
873
+ for (const [key, minimum] of Object.entries(DICTATED_MODEL_MIN_MAX_TOKENS)) if (model.id === key || model.id.endsWith(`/${key}`)) {
874
+ if ((model.maxTokens ?? 0) < minimum) return {
875
+ ...model,
876
+ maxTokens: minimum
877
+ };
878
+ break;
879
+ }
880
+ return model;
881
+ }
882
+ /**
862
883
  * Resolve the model a request should run on: a valid `x_model` wins,
863
884
  * anything else falls back to registry resolution of the body model. Shared
864
885
  * by every transport so they honor the spec identically.
@@ -867,7 +888,7 @@ function resolveRequestModel({ modelInput, modelSpecInput, defaultModel, log })
867
888
  const modelSpec = parseModelSpec(modelSpecInput, log);
868
889
  return {
869
890
  modelSpec,
870
- model: modelSpec ? buildModelFromSpec(modelSpec) : resolveModel(modelInput ?? defaultModel, log)
891
+ model: modelSpec ? buildModelFromSpec(modelSpec) : dictateModelMaxTokens(resolveModel(modelInput ?? defaultModel, log))
871
892
  };
872
893
  }
873
894
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skydiveai/pi-server",
3
- "version": "0.1.252-beta.2",
3
+ "version": "0.1.252-beta.21",
4
4
  "homepage": "https://skydive.com",
5
5
  "license": "MIT",
6
6
  "author": "Create, Inc.",
@@ -36,12 +36,12 @@
36
36
  "@earendil-works/pi-coding-agent": "0.80.10",
37
37
  "@types/node": "^24.0.0",
38
38
  "@typescript/native-preview": "^7.0.0-dev.20260113.1",
39
- "@vitest/coverage-v8": "^2.1.8",
39
+ "@vitest/coverage-v8": "^3.2.4",
40
40
  "openai": "^5.8.2",
41
41
  "pino-pretty": "^13.0.0",
42
42
  "tsdown": "^0.21.10",
43
- "typescript": "^5.9.3",
44
- "vitest": "^2.1.8"
43
+ "typescript": "^6.0.3",
44
+ "vitest": "^3.2.7"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@earendil-works/pi-coding-agent": ">=0.74.0 <0.81.0"