@caeliq/llms 1.0.72 → 1.0.73

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 (37) hide show
  1. package/dist/cjs/server.cjs +233 -230
  2. package/dist/cjs/server.cjs.map +4 -4
  3. package/dist/cursor-sdk/inbound-session.d.ts +21 -0
  4. package/dist/cursor-sdk/model-selection.d.ts +23 -0
  5. package/dist/cursor-sdk/session.d.ts +16 -5
  6. package/dist/cursor-sdk/shared.d.ts +10 -1
  7. package/dist/cursor-sdk/turn-output.d.ts +2 -0
  8. package/dist/esm/server.mjs +233 -230
  9. package/dist/esm/server.mjs.map +4 -4
  10. package/dist/services/provider.d.ts +8 -2
  11. package/dist/session-registry.d.ts +30 -3
  12. package/dist/tests/codex.bootstrap-buffer.d.ts +1 -0
  13. package/dist/tests/codex.model-catalog.d.ts +1 -0
  14. package/dist/tests/cursor-sdk.inbound-session.d.ts +1 -0
  15. package/dist/tests/cursor-sdk.interrupt-reentry.d.ts +1 -1
  16. package/dist/tests/cursor-sdk.model-remint.d.ts +1 -0
  17. package/dist/tests/cursor-sdk.model-selection.d.ts +1 -0
  18. package/dist/tests/cursor-sdk.on-delta-thinking.d.ts +1 -1
  19. package/dist/tests/cursor-sdk.runner-recovery.d.ts +1 -1
  20. package/dist/tests/cursor-sdk.scratch-report.d.ts +1 -1
  21. package/dist/tests/cursor-sdk.turn-coordination.d.ts +1 -1
  22. package/dist/tests/fallback.request-context.routes.d.ts +1 -0
  23. package/dist/tests/path-alias.build.d.ts +1 -0
  24. package/dist/tests/request-scoped-errors.d.ts +1 -0
  25. package/dist/tests/request-scoped-errors.routes.d.ts +1 -0
  26. package/dist/tests/responses.multi-agent.routes.d.ts +1 -0
  27. package/dist/tests/responses.orphan-delegation.d.ts +1 -0
  28. package/dist/tests/support/isolate-session-registry.d.ts +1 -0
  29. package/dist/transformer/codex.transformer.d.ts +18 -0
  30. package/dist/types/llm.d.ts +21 -2
  31. package/dist/utils/codex-bootstrap.d.ts +68 -0
  32. package/dist/utils/codex-model-catalog.d.ts +63 -0
  33. package/dist/utils/nested-agent.d.ts +4 -0
  34. package/dist/utils/openai.responses.util.d.ts +37 -1
  35. package/dist/utils/reasoning-effort.d.ts +3 -20
  36. package/dist/utils/request-scoped-errors.d.ts +92 -0
  37. package/package.json +3 -3
@@ -0,0 +1,21 @@
1
+ export type InternalCursorSession = {
2
+ /** Opaque id passed to the Cursor SDK session key. Never a client header. */
3
+ internalId: string;
4
+ /** Registry key: protocol identity, or the anonymous opening. */
5
+ inboundKey: string;
6
+ };
7
+ /**
8
+ * Protocol conversation → opaque Cursor session id.
9
+ *
10
+ * `isActive` reports whether the agent behind an internal id is running a
11
+ * turn or finished one within the replay window; it extends an opening's
12
+ * retry window past the time of its first request.
13
+ */
14
+ export declare function resolveInternalCursorSession(input: {
15
+ protocol?: string;
16
+ request: unknown;
17
+ context: any;
18
+ model: string;
19
+ sourceSessionIdentity?: string;
20
+ isActive?: (internalId: string) => boolean;
21
+ }): InternalCursorSession;
@@ -0,0 +1,23 @@
1
+ import type { ModelListItem, ModelSelection } from "@cursor/sdk";
2
+ /**
3
+ * Reasoning the client asked for. `undefined`: none (absent, `none`, or
4
+ * disabled). `{}`: on at the model's default effort. `{ effort }`: on at
5
+ * that level.
6
+ */
7
+ export type CursorReasoning = {
8
+ effort?: string;
9
+ } | undefined;
10
+ /**
11
+ * Map a CCR model id and the client's reasoning request onto an SDK
12
+ * ModelSelection from a Cursor.models.list catalog. Parameterized models
13
+ * (Grok 4.7 context/effort/fast) always get explicit params, as the Cursor
14
+ * SDK docs recommend; see `wantedParams` for the values.
15
+ *
16
+ * Grok 4.7 has no off switch, so no reasoning selects 256k+low+non-fast;
17
+ * Claude models select `thinking=false`, GPT 5.4+ `reasoning=none`.
18
+ */
19
+ export declare function selectCursorModelSelection(models: ModelListItem[], modelId: string, reasoning?: CursorReasoning): ModelSelection;
20
+ /** Stable id+params key for persist/compare. Order of params does not matter. */
21
+ export declare function cursorModelFingerprint(selection: ModelSelection): string;
22
+ export declare function cursorModelSelectionsEqual(left: ModelSelection | undefined, right: ModelSelection): boolean;
23
+ export declare function isCursorInvalidRegistryModelError(err: unknown): boolean;
@@ -67,6 +67,11 @@ export type CursorSdkSession = {
67
67
  sendChain: Promise<void>;
68
68
  /** True after at least one successful `agent.send` on this session. */
69
69
  hasSentPrompt: boolean;
70
+ /**
71
+ * The agent was resumed (`Agent.resume`) rather than created for this
72
+ * session, so it carries server-side state from an earlier binding.
73
+ */
74
+ resumedAgent: boolean;
70
75
  /**
71
76
  * Exact host-visible transcript represented by this agent after the last
72
77
  * completed response. Unknown means tail-only reuse is forbidden.
@@ -164,14 +169,18 @@ export declare function shouldEnableCursorSandbox(requested?: boolean): boolean;
164
169
  */
165
170
  export declare function refreshWorkspaceGuidance(session: CursorSdkSession, hostEnv: HostEnvironment): boolean;
166
171
  /**
167
- * Cursor SDK session directory key. Prefer explicit client conversation ids
168
- * over hashing prompt text — never include system / harness version.
172
+ * Cursor SDK session directory key. Prefer an explicit conversation id over
173
+ * hashing prompt text — never include system / harness version.
174
+ *
175
+ * The runner passes the opaque id from `inbound-session.ts` as
176
+ * `headerSession`. That id is already unique per protocol conversation,
177
+ * including parallel Tasks. Clients do not send it.
169
178
  *
170
- * Claude Code subagents share the parent session id. Mix first-user text so
171
- * parallel Task agents each get their own Cursor Agent instead of collapsing
172
- * onto one turn registry slot.
179
+ * Direct callers that still pass a shared parent id plus first-user text get
180
+ * the mix below, so parallel workers do not collapse onto one Agent.
173
181
  */
174
182
  export declare function buildSessionKey(input: {
183
+ /** Opaque Cursor session id, or a caller-supplied conversation id. */
175
184
  headerSession?: string;
176
185
  /** Inbound-captured Claude/OpenCode session id (protocolContext / req). */
177
186
  clientSessionId?: string;
@@ -203,6 +212,8 @@ export declare class SessionManager {
203
212
  constructor(logger?: any | undefined);
204
213
  setLogger(logger: any): void;
205
214
  get(key: string): CursorSdkSession | undefined;
215
+ /** Live session for `key`, without touching, retiring, or creating one. */
216
+ peek(key: string): CursorSdkSession | undefined;
206
217
  retireSession(session: CursorSdkSession, reason: string, cleanup: () => Promise<boolean>): Promise<boolean>;
207
218
  getOrCreate(options: {
208
219
  key: string;
@@ -1,3 +1,4 @@
1
+ import { type CursorReasoning } from "./model-selection";
1
2
  import type { UnifiedMessage } from "../types/llm";
2
3
  export declare const CURSOR_SDK_TRANSFORMER_NAME = "cursor-sdk";
3
4
  export type CursorSdkMode = "bridge" | "plan" | "agent";
@@ -25,7 +26,15 @@ export declare function ensureCcrHomePaths(): string[];
25
26
  export declare function contentToText(content: UnifiedMessage["content"]): string;
26
27
  export declare function hashSessionFingerprint(parts: string[]): string;
27
28
  export declare function coerceThinkingText(value: unknown): string;
28
- export declare function extractEffort(request: any): string | undefined;
29
+ /**
30
+ * The reasoning a Unified request asks Cursor for. Every inbound protocol
31
+ * maps its own field (`thinking` / `output_config.effort`,
32
+ * `reasoning_effort`, `reasoning`) onto Unified `reasoning` and `thinking`.
33
+ * No signal, effort `none`, or disabled thinking means no reasoning.
34
+ */
35
+ export declare function extractCursorReasoning(request: any): CursorReasoning;
36
+ /** Stable label for a reasoning request, for compatibility stamps. */
37
+ export declare function cursorReasoningKey(reasoning: CursorReasoning): string;
29
38
  /**
30
39
  * Transient Cursor provider failures (throttling / overload) must not destroy
31
40
  * the warm sticky agent: the retry reuses it instead of paying a cold start.
@@ -1,3 +1,5 @@
1
+ /** How long an identical completed turn replays instead of re-running. */
2
+ export declare const COMPLETED_TURN_TTL_MS = 60000;
1
3
  declare class SharedCursorTurn {
2
4
  readonly sessionKey: string;
3
5
  readonly fingerprint: string;