@caeliq/llms 1.0.67 → 1.0.68

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.
@@ -95,12 +95,12 @@ export declare function createSseHelpers(model: string, encoder: TextEncoder): {
95
95
  finish_reason: "stop" | "tool_calls";
96
96
  }[];
97
97
  usage: {
98
+ prompt_tokens_details?: {
99
+ cached_tokens: number;
100
+ } | undefined;
98
101
  prompt_tokens: number;
99
102
  completion_tokens: number;
100
103
  total_tokens: number;
101
- prompt_tokens_details: {
102
- cached_tokens: number;
103
- };
104
104
  };
105
105
  id: string;
106
106
  object: string;
@@ -36,6 +36,11 @@ export type CursorLifecycleInput<TParked extends CursorParkedToolRef = CursorPar
36
36
  hasSentPrompt: boolean;
37
37
  poisoned: boolean;
38
38
  alignment: CursorContextAlignment;
39
+ /**
40
+ * False when agent/model/workspace/tool configuration changed since the
41
+ * transcript commit. Undefined preserves the legacy behavior (match).
42
+ */
43
+ compatibilityMatch?: boolean;
39
44
  run: CursorRunSnapshot<TParked>;
40
45
  };
41
46
  turn: {
@@ -4,6 +4,7 @@ import type { CursorTranscriptCommit } from "./turn-identity";
4
4
  import { type HostEnvironment } from "./host-env";
5
5
  import { type CursorSdkMode } from "./shared";
6
6
  export type ParkedTool = {
7
+ /** Original Cursor SDK tool-call id (never emitted to the client). */
7
8
  id: string;
8
9
  name: string;
9
10
  args: Record<string, unknown>;
@@ -30,8 +31,20 @@ export type CursorSdkSession = {
30
31
  streamNext?: Promise<IteratorResult<any>>;
31
32
  streamNextRunToken?: symbol;
32
33
  activeRunToken?: symbol;
34
+ /** Raw usage from the last completed SDK turn; never a parked CCR boundary. */
33
35
  lastSdkUsageRaw?: OpenAiUsage;
34
36
  parked: ParkedTool[];
37
+ /**
38
+ * Per-session bidirectional map between raw Cursor SDK tool-call ids
39
+ * (possibly newline-joined / overlong) and the host-safe aliases emitted
40
+ * to the client. Parked records keep originals; the wire carries aliases;
41
+ * incoming echoes are translated back before matching. Dies with the
42
+ * session; bounded below so long-lived agents cannot grow it forever.
43
+ */
44
+ toolIdAliases: {
45
+ byOriginal: Map<string, string>;
46
+ byAlias: Map<string, string>;
47
+ };
35
48
  /** Tool calls waiting to be emitted on the current SSE response. */
36
49
  pendingEmit: Array<{
37
50
  id: string;
@@ -103,6 +116,13 @@ export type CancelActiveRunResult = {
103
116
  failed: boolean;
104
117
  timedOut: boolean;
105
118
  };
119
+ export declare function aliasHostToolId(session: CursorSdkSession, original: unknown): string | undefined;
120
+ /**
121
+ * Translate a client-echoed tool-call id back to the parked SDK original.
122
+ * Unknown ids pass through unchanged so legacy / unmapped turns mismatch
123
+ * exactly as before instead of collapsing onto something unrelated.
124
+ */
125
+ export declare function resolveHostToolId(session: CursorSdkSession, echoed: unknown): string;
106
126
  export declare function markSessionPoisoned(session: CursorSdkSession, reason: string): void;
107
127
  /**
108
128
  * Drop local run handles and await SDK `run.cancel()` when needed.
@@ -210,6 +230,7 @@ export declare class SessionManager {
210
230
  dispose(key: string): Promise<void>;
211
231
  invalidate(sessionOrKey: CursorSdkSession | string, reason: string): Promise<void>;
212
232
  private disposeAgent;
233
+ private rehydratePersistedAgent;
213
234
  private createSessionRecord;
214
235
  private evictIfNeeded;
215
236
  private evictIdle;
@@ -26,3 +26,10 @@ export declare function contentToText(content: UnifiedMessage["content"]): strin
26
26
  export declare function hashSessionFingerprint(parts: string[]): string;
27
27
  export declare function coerceThinkingText(value: unknown): string;
28
28
  export declare function extractEffort(request: any): string | undefined;
29
+ /**
30
+ * Transient Cursor provider failures (throttling / overload) must not destroy
31
+ * the warm sticky agent: the retry reuses it instead of paying a cold start.
32
+ * Auth errors and client aborts are NOT transient — they keep the old
33
+ * retire-the-session behavior at the call site.
34
+ */
35
+ export declare function isCursorTransientProviderError(err: unknown): boolean;
@@ -27,18 +27,25 @@ export declare function estimateRequestPromptTokens(request: UnifiedChatRequest)
27
27
  export declare function requestUsageFromEstimate(promptTokens: number, outputChars: number, cacheReadTokens?: number): OpenAiUsage;
28
28
  export declare function cursorUsageCountersFromSdk(raw: OpenAiUsage | undefined): CursorUsageCounters | undefined;
29
29
  /**
30
- * Cursor SDK usage is session-cumulative, while Claude Code needs per-request
31
- * usage. Use SDK usage only as a cache-read ratio and apply it to CCR's
32
- * current-request prompt estimate.
30
+ * Cursor SDK usage is per SDK turn, while Claude Code needs per-CCR-request
31
+ * usage. In bridge mode one SDK turn can span several parked host-tool request
32
+ * cycles. Use a terminal SDK witness only as a cache-read ratio for the CCR
33
+ * request that observes it; never attribute it to an earlier parked response.
33
34
  *
34
35
  * Kept for tests; prefer buildAccurateUsageFromSdk for turn-end reporting.
35
36
  */
36
37
  export declare function cacheReadFromSdkDelta(current: OpenAiUsage | undefined, previous: OpenAiUsage | undefined, promptTokens: number): number;
37
38
  /**
38
- * Build per-request OpenAI usage from SDK TurnEnded counters, normalized to
39
- * the per-request prompt estimate but preserving Cursor's cache proportions
40
- * (same math as cursor-opencode-provider buildLanguageModelV3UsageFromCounters).
41
- * Falls back to chars/4-based completion tokens when SDK output is absent.
39
+ * Build per-request OpenAI usage from the SDK turn-end usage message,
40
+ * normalized to the per-request prompt estimate but preserving Cursor's cache
41
+ * proportions (same math as cursor-opencode-provider
42
+ * buildLanguageModelV3UsageFromCounters). Falls back to chars/4-based
43
+ * completion tokens when SDK output is absent.
44
+ *
45
+ * When the runtime reports no usage for the turn (the SDK emits the usage
46
+ * message only "when the runtime reported usage"), prompt_tokens_details is
47
+ * omitted entirely so the cache-outcome tap reports "unknown" instead of a
48
+ * bogus "unexpected-miss" from a zero that was never measured.
42
49
  */
43
50
  export declare function buildAccurateUsageFromSdk(sdkRaw: OpenAiUsage | undefined, promptTokens: number, outputChars: number, priorRaw?: OpenAiUsage | undefined): OpenAiUsage;
44
51
  /** Map SDK TokenUsage / usage message into OpenAI shape (diagnostics only). */