@askalf/dario 4.8.139 → 4.8.140

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.
@@ -432,6 +432,25 @@ export declare function resolveEffort(flag: EffortValue | undefined, clientBody:
432
432
  * — never a broken request.
433
433
  */
434
434
  export declare function supportsAdaptiveThinking(modelId: string): boolean;
435
+ /**
436
+ * Anthropic prompt-cache control. `ttl` is the cache lifetime: `5m` (the
437
+ * upstream default when omitted) or `1h`. Real CC sends `1h` on its system
438
+ * blocks (see live-fingerprint.ts extractTemplate), so dario mirrors it.
439
+ */
440
+ export type CacheControl = {
441
+ type: 'ephemeral';
442
+ ttl?: '5m' | '1h';
443
+ };
444
+ /**
445
+ * The cache-control dario stamps on every breakpoint (2 system + tools +
446
+ * conversation). `ttl: '1h'` mirrors real CC — dario shipped the 5-min
447
+ * ephemeral default, so its prefix expired 12x sooner than CC's and any
448
+ * interactive turn past the 5-min window re-created the whole prefix
449
+ * (system + all tools) at cache-creation cost, draining the Max window far
450
+ * faster than direct CC (root cause of dario#678). Single source of truth so
451
+ * the emitted TTL can't silently drift back to 5m.
452
+ */
453
+ export declare const CC_CACHE_CONTROL: CacheControl;
435
454
  /**
436
455
  * Place CC-style prompt-cache breakpoints on the tools array and the
437
456
  * conversation. The system prompt is already cached at build time (2 system
@@ -446,12 +465,8 @@ export declare function supportsAdaptiveThinking(modelId: string): boolean;
446
465
  * sails through. CC genuinely caches tools + conversation, so NOT caching them
447
466
  * was itself a wire divergence from CC. Exported for unit testing.
448
467
  */
449
- export declare function applyCcPromptCaching(ccRequest: Record<string, unknown>, cacheControl: {
450
- type: 'ephemeral';
451
- }): void;
452
- export declare function buildCCRequest(clientBody: Record<string, unknown>, billingTag: string, cacheControl: {
453
- type: 'ephemeral';
454
- }, identity: {
468
+ export declare function applyCcPromptCaching(ccRequest: Record<string, unknown>, cacheControl: CacheControl): void;
469
+ export declare function buildCCRequest(clientBody: Record<string, unknown>, billingTag: string, cacheControl: CacheControl, identity: {
455
470
  deviceId: string;
456
471
  accountUuid: string;
457
472
  sessionId: string;
@@ -1235,6 +1235,16 @@ export function supportsAdaptiveThinking(modelId) {
1235
1235
  return true;
1236
1236
  return false;
1237
1237
  }
1238
+ /**
1239
+ * The cache-control dario stamps on every breakpoint (2 system + tools +
1240
+ * conversation). `ttl: '1h'` mirrors real CC — dario shipped the 5-min
1241
+ * ephemeral default, so its prefix expired 12x sooner than CC's and any
1242
+ * interactive turn past the 5-min window re-created the whole prefix
1243
+ * (system + all tools) at cache-creation cost, draining the Max window far
1244
+ * faster than direct CC (root cause of dario#678). Single source of truth so
1245
+ * the emitted TTL can't silently drift back to 5m.
1246
+ */
1247
+ export const CC_CACHE_CONTROL = { type: 'ephemeral', ttl: '1h' };
1238
1248
  /**
1239
1249
  * Place CC-style prompt-cache breakpoints on the tools array and the
1240
1250
  * conversation. The system prompt is already cached at build time (2 system
package/dist/doctor.js CHANGED
@@ -334,7 +334,7 @@ export async function runChecks(opts = {}) {
334
334
  // non-passthrough request and dominate the input-token cost on small
335
335
  // turns. Anthropic caches them after the first hit (cache_creation
336
336
  // tokens on call 1, then cache_read on subsequent calls within the
337
- // 5-min/1-hr TTL), but non-CC users routing heavy tooling get
337
+ // 1-hour TTL), but non-CC users routing heavy tooling get
338
338
  // surprised by the first-request charge. Surface the size up front
339
339
  // so they can plan.
340
340
  //
@@ -355,7 +355,7 @@ export async function runChecks(opts = {}) {
355
355
  detail: `${promptChars.toLocaleString()} chars system prompt + ${toolCount} tool defs ` +
356
356
  `(${toolChars.toLocaleString()} chars JSON-serialized) injected per non-passthrough ` +
357
357
  `request. Cached after first hit; read-cost only on subsequent calls within ` +
358
- `the 5-min/1-hr TTL. Exact token count surfaces as cache_creation_input_tokens ` +
358
+ `the 1-hour TTL. Exact token count surfaces as cache_creation_input_tokens ` +
359
359
  `on the first response (or run \`dario doctor --usage\`).`,
360
360
  });
361
361
  }
package/dist/proxy.js CHANGED
@@ -9,7 +9,7 @@ import { arch, platform } from 'node:process';
9
9
  import { getAccessToken, getStatus } from './oauth.js';
10
10
  import { buildHealthResponse, derivePoolStatus, shouldDiscloseHealthInternals } from './health-response.js';
11
11
  import { darioVersion } from './version.js';
12
- import { buildCCRequest, applyCcPromptCaching, parseEffortSuffix, reverseMapResponse, createStreamingReverseMapper, orderHeadersForOutbound, isMcpToolName, CC_TEMPLATE } from './cc-template.js';
12
+ import { buildCCRequest, applyCcPromptCaching, parseEffortSuffix, reverseMapResponse, createStreamingReverseMapper, orderHeadersForOutbound, isMcpToolName, CC_TEMPLATE, CC_CACHE_CONTROL } from './cc-template.js';
13
13
  import { stampCch, hasCchSeed } from './cch.js';
14
14
  import { describeTemplate, detectDrift, checkCCCompat } from './live-fingerprint.js';
15
15
  import { AccountPool, computeStickyKey, parseRateLimits, modelFamily, isInAuthCooldown, authCooldownMs, reconcilePoolAccounts } from './pool.js';
@@ -2049,7 +2049,8 @@ export async function startProxy(opts = {}) {
2049
2049
  // current Claude Code, which sends none. dario#528.
2050
2050
  const cch = hasCchSeed(cliVersion) ? computeCch() : null;
2051
2051
  const billingTag = buildBillingTag(cliVersion, cch);
2052
- const CACHE_EPHEMERAL = { type: 'ephemeral' };
2052
+ // 1h cache TTL, matching real CC (see CC_CACHE_CONTROL / dario#678).
2053
+ const CACHE_EPHEMERAL = CC_CACHE_CONTROL;
2053
2054
  // Session stickiness: rebind the pre-selected pool account to
2054
2055
  // whatever the sticky-key resolver picks. If this is a new
2055
2056
  // conversation the key binds to the current best account
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askalf/dario",
3
- "version": "4.8.139",
3
+ "version": "4.8.140",
4
4
  "description": "Use your Claude Pro/Max subscription in any tool — Cursor, Cline, Aider, the Agent SDK, your scripts — at subscription pricing, not per-token API bills. One local Anthropic + OpenAI-compatible endpoint.",
5
5
  "type": "module",
6
6
  "bin": {