@hasna/switcher 0.2.23 → 0.2.25

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/Dockerfile CHANGED
@@ -14,7 +14,10 @@ RUN bun run generate \
14
14
  && bun run build
15
15
 
16
16
  FROM --platform=linux/arm64 oven/bun:1.3.14-alpine AS runtime
17
+ # Bun.SQL auto-pipelining off: in Bun 1.3.14 it can match a query to another query's result
18
+ # (the Todos fix, #4043). Bun reads the flag only at process start, so it is set here.
17
19
  ENV NODE_ENV=production \
20
+ BUN_FEATURE_FLAG_DISABLE_SQL_AUTO_PIPELINING=1 \
18
21
  PORT=8080
19
22
  WORKDIR /app
20
23
  RUN apk upgrade --no-cache \
package/README.md CHANGED
@@ -778,6 +778,8 @@ console.log(plan.catalog.models.length);
778
778
 
779
779
  The SDK supports Node and Bun. It has no database or launcher imports. Explicit credentials may be supplied as a string or a fresh resolver function; `clientFromEnv()` uses the shared contracts resolver with environment-only inputs and no disk fallback.
780
780
 
781
+ The SDK client retries a call at most three times, with exponential backoff (200 ms, 400 ms, 800 ms plus up to 50% jitter; no single wait exceeds 2 s, jitter included), and only for two failure shapes: any HTTP 503 (an edge in front of the API being briefly unreachable, or Switcher's own JSON `storage unavailable`, whose failed write rolled back), or a 5xx response with a non-JSON body such as the plain-text `error code: 500`. A GET is retried; a write is retried only when its idempotency key was supplied, and every attempt reuses that key, so the server replays the stored result instead of repeating the write. `createProvider`, `updateProvider`, `deleteProvider`, `refreshModels`, `saveCatalog`, `createProfile`, `updateProfile`, `deleteProfile`, `launchPlan`, `createRun` and `finishRun` mint one key per call when you pass none. A 401, a 403, any other 4xx, a 5xx other than 503 that has a JSON body, a refused connection and a non-JSON success body are never retried. Pass `retry: {retries, baseDelayMs, maxDelayMs}` to tune the policy (at most 5 retries and 10 s for any one wait; larger values are clamped) or `retry: false` to turn it off.
782
+
781
783
  SDK and CLI API-error diagnostics validate code/request-ID fields, bound message length, remove terminal control characters, and redact the operator credential actually sent with that request. Redaction covers raw, JSON-string-escaped, URL-encoded and Base64/Base64url representations. Native harness stdout and terminal output remain under the native client's control.
782
784
 
783
785
  Public lifecycle endpoints: `GET /health`, `/ready`, `/version`, `/openapi.json`, and `/v1/openapi.json`. Provider/profile CRUD, `/v1/provider-presets`, catalog list/refresh, version-checked catalog metadata commits, launch-plan validation and run metadata are under `/v1`. The SDK includes `listProviderPresets()`, `getProviderPreset()`, `health()`, `ready()`, and `version()`. SDK types are generated from that OpenAPI document. API errors include code, message and request ID.
@@ -1,8 +1,19 @@
1
1
  /** Keep enough room for Claude's next turn and compaction request on DeepSeek.
2
2
  * https://api-docs.deepseek.com/quick_start/agent_integrations/claude_code/
3
3
  * Inspect the original provider URL: the native URL is a loopback gateway.
4
+ *
5
+ * For any other provider, the selected model's catalog window sets the same headroom. Without
6
+ * CLAUDE_CODE_AUTO_COMPACT_WINDOW, Claude Code runs no auto-compaction at all for a `[1m]` model id
7
+ * it doesn't recognise, so the context grows until the provider refuses it (a glm session on
8
+ * OpenRouter grew past 1M tokens and every request failed, 04.11, SH-00074). Setting it turns
9
+ * proactive compaction back on: CLAUDE_CODE_AUTO_COMPACT_WINDOW (100k to 1M) compacts at three
10
+ * quarters of the window, DeepSeek's ratio (786432 of 1048576). Below 1M,
11
+ * CLAUDE_CODE_MAX_CONTEXT_TOKENS tells Claude the real window instead of its 200k assumption; at 1M
12
+ * and above the `[1m]` suffix does (claudeNativeModelId). Both are documented Claude Code settings:
13
+ * https://code.claude.com/docs/en/model-config#correct-the-window-for-a-gateway-or-custom-model-id
14
+ * A model without a declared window keeps Claude's own defaults; explicit settings always win.
4
15
  */
5
- export declare function claudeContextEnvironment(providerBaseUrl: string, environment?: NodeJS.ProcessEnv): Record<string, string>;
16
+ export declare function claudeContextEnvironment(providerBaseUrl: string, environment?: NodeJS.ProcessEnv, contextWindow?: number): Record<string, string>;
6
17
  /** Claude Code treats a model it doesn't know as a 200k-token one and compacts near 168k, even when
7
18
  * the provider serves more and CLAUDE_CODE_AUTO_COMPACT_WINDOW is higher (measured on DeepSeek flash,
8
19
  * 30.10). The `[1m]` suffix tells it the window is 1M; Claude strips it before calling the provider.