copilot-api-plus 1.4.1 → 1.4.2

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/dist/main.js CHANGED
@@ -3206,6 +3206,10 @@ function sanitizeForCopilotBackend(payload) {
3206
3206
  delete extended.context_management;
3207
3207
  }
3208
3208
  sanitizeOutputConfigFormat(extended.output_config?.format);
3209
+ if (payload.effort !== void 0) {
3210
+ consola.debug("Stripping effort field (unsupported by Copilot backend)");
3211
+ delete payload.effort;
3212
+ }
3209
3213
  }
3210
3214
  function sanitizeOutputConfigFormat(format) {
3211
3215
  if (!isRecord(format) || format.type !== "json_schema") return;
@@ -3244,11 +3248,13 @@ function normalizeAdaptiveThinkingForCopilot(payload) {
3244
3248
  * capabilities. Mutates in place.
3245
3249
  *
3246
3250
  * - Models with `adaptive_thinking: true` (Claude Opus 4.7,
3247
- * Sonnet 4.6, etc.) get `{ type: "adaptive" }` plus a top-level
3248
- * `effort: "max"` (or `"xhigh"` for Opus 4.7 long-horizon work).
3249
- * This matches Anthropic's 2026 API: manual `budget_tokens` on
3250
- * Opus 4.7 returns 400, and `effort` is the documented control
3251
- * for thinking depth on adaptive models.
3251
+ * Sonnet 4.6, etc.) get `{ type: "adaptive", budget_tokens: max }`.
3252
+ * Per Anthropic 2026 docs, `effort` is the recommended control
3253
+ * for thinking depth on adaptive models — but Copilot's `/v1/messages`
3254
+ * mirror rejects the top-level `effort` field with a 400. The
3255
+ * `budget_tokens` hint on adaptive thinking is documented as still
3256
+ * accepted, and serves as a softer nudge that keeps the model from
3257
+ * skipping thinking entirely on simple prompts.
3252
3258
  * - Other thinking-capable models get
3253
3259
  * `{ type: "enabled", budget_tokens: max_thinking_budget }`.
3254
3260
  * - Models without thinking capability are left untouched.
@@ -3262,14 +3268,16 @@ function injectMaxThinkingBudget(payload) {
3262
3268
  if (payload.thinking !== void 0) return;
3263
3269
  const supports = findModel(payload.model)?.capabilities.supports;
3264
3270
  if (!supports) return;
3271
+ const maxBudget = supports.max_thinking_budget;
3272
+ if (!maxBudget || maxBudget <= 0) return;
3265
3273
  if (supports.adaptive_thinking === true) {
3266
- payload.thinking = { type: "adaptive" };
3267
- if (payload.effort === void 0) payload.effort = "max";
3268
- consola.debug(`Injected adaptive thinking + effort=${payload.effort} for ${payload.model} (no client preference)`);
3274
+ payload.thinking = {
3275
+ type: "adaptive",
3276
+ budget_tokens: maxBudget
3277
+ };
3278
+ consola.debug(`Injected adaptive thinking budget=${maxBudget} for ${payload.model} (no client preference)`);
3269
3279
  return;
3270
3280
  }
3271
- const maxBudget = supports.max_thinking_budget;
3272
- if (!maxBudget || maxBudget <= 0) return;
3273
3281
  payload.thinking = {
3274
3282
  type: "enabled",
3275
3283
  budget_tokens: maxBudget