@caeliq/llms 1.0.55 → 1.0.57
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/README.md +102 -12
- package/dist/api/middleware.d.ts +9 -0
- package/dist/api/routes.d.ts +15 -0
- package/dist/cjs/server.cjs +238 -230
- package/dist/cjs/server.cjs.map +4 -4
- package/dist/cursor-sdk/events-to-sse.d.ts +113 -0
- package/dist/cursor-sdk/hooks-template.d.ts +1 -0
- package/dist/cursor-sdk/prompt.d.ts +29 -0
- package/dist/cursor-sdk/runner.d.ts +11 -0
- package/dist/cursor-sdk/send.d.ts +9 -0
- package/dist/cursor-sdk/session.d.ts +146 -0
- package/dist/cursor-sdk/shared.d.ts +14 -0
- package/dist/cursor-sdk/tools.d.ts +4 -0
- package/dist/cursor-sdk/usage.d.ts +28 -0
- package/dist/esm/server.mjs +233 -225
- package/dist/esm/server.mjs.map +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/output/console-handler.d.ts +23 -0
- package/dist/plugins/output/index.d.ts +29 -0
- package/dist/plugins/output/output-manager.d.ts +110 -0
- package/dist/plugins/output/temp-file-handler.d.ts +53 -0
- package/dist/plugins/output/types.d.ts +157 -0
- package/dist/plugins/output/webhook-handler.d.ts +37 -0
- package/dist/plugins/plugin-manager.d.ts +62 -0
- package/dist/plugins/token-speed.d.ts +22 -0
- package/dist/plugins/types.d.ts +25 -0
- package/dist/server.d.ts +60 -0
- package/dist/services/config.d.ts +32 -0
- package/dist/services/provider.d.ts +34 -0
- package/dist/services/tokenizer.d.ts +44 -0
- package/dist/services/transformer.d.ts +28 -0
- package/dist/tests/anthropic.stream-boundaries.d.ts +1 -0
- package/dist/tests/anthropic.stream-cancel.d.ts +1 -0
- package/dist/tests/antigravity.claude-tool-schema.d.ts +1 -0
- package/dist/tests/antigravity.endpoint-fallback.d.ts +1 -0
- package/dist/tests/cache-control.strip.d.ts +1 -0
- package/dist/tests/cache-paths.integration.d.ts +1 -0
- package/dist/tests/claude-auth.beta-headers.d.ts +1 -0
- package/dist/tests/codex-auth.reliability.d.ts +1 -0
- package/dist/tests/cursor-sdk.cancel.d.ts +1 -0
- package/dist/tests/cursor-sdk.on-delta-thinking.d.ts +1 -0
- package/dist/tests/cursor-sdk.progress-only.d.ts +1 -0
- package/dist/tests/cursor-sdk.runner-recovery.d.ts +1 -0
- package/dist/tests/cursor-sdk.send.d.ts +1 -0
- package/dist/tests/cursor-sdk.stream-error.d.ts +1 -0
- package/dist/tests/cursor-sdk.thinking-signature.d.ts +1 -0
- package/dist/tests/cursor-sdk.usage.d.ts +1 -0
- package/dist/tests/deepseek.reasoning.d.ts +1 -0
- package/dist/tests/gemini.abnormal-finish.d.ts +1 -0
- package/dist/tests/gemini.dual-dialect-request.d.ts +1 -0
- package/dist/tests/gemini.function-call-signatures.d.ts +1 -0
- package/dist/tests/gemini.parity.d.ts +1 -0
- package/dist/tests/gemini.thinking-effort.d.ts +1 -0
- package/dist/tests/gemini.thought-signature-roundtrip.d.ts +1 -0
- package/dist/tests/opencode-headers.no-provider-retry.d.ts +1 -0
- package/dist/tests/thinking-sequencer.dual-dialect.d.ts +1 -0
- package/dist/tests/transformer-service.endpoints.d.ts +1 -0
- package/dist/tests/upstream-ports.smoke.d.ts +1 -0
- package/dist/tokenizer/api-tokenizer.d.ts +45 -0
- package/dist/tokenizer/huggingface-tokenizer.d.ts +52 -0
- package/dist/tokenizer/tiktoken-tokenizer.d.ts +20 -0
- package/dist/transformer/anthropic.transformer.d.ts +22 -0
- package/dist/transformer/antigravity-auth.transformer.d.ts +15 -0
- package/dist/transformer/cerebras.transformer.d.ts +16 -0
- package/dist/transformer/chrome-on-device.transformer.d.ts +7 -0
- package/dist/transformer/claude-auth.transformer.d.ts +25 -0
- package/dist/transformer/cleancache.transformer.d.ts +6 -0
- package/dist/transformer/codex.transformer.d.ts +61 -0
- package/dist/transformer/cursor-sdk.transformer.d.ts +23 -0
- package/dist/transformer/customparams.transformer.d.ts +30 -0
- package/dist/transformer/deepseek.transformer.d.ts +7 -0
- package/dist/transformer/enhancetool.transformer.d.ts +6 -0
- package/dist/transformer/extrathinktag.transformer.d.ts +10 -0
- package/dist/transformer/forcereasoning.transformer.d.ts +8 -0
- package/dist/transformer/gemini.transformer.d.ts +15 -0
- package/dist/transformer/groq.transformer.d.ts +7 -0
- package/dist/transformer/index.d.ts +65 -0
- package/dist/transformer/maxcompletiontokens.transformer.d.ts +6 -0
- package/dist/transformer/maxtoken.transformer.d.ts +9 -0
- package/dist/transformer/mistral.transformer.d.ts +25 -0
- package/dist/transformer/openai.responses.transformer.d.ts +13 -0
- package/dist/transformer/openai.transformer.d.ts +52 -0
- package/dist/transformer/opencode-headers.transformer.d.ts +30 -0
- package/dist/transformer/openrouter.transformer.d.ts +10 -0
- package/dist/transformer/qwen-auth.transformer.d.ts +9 -0
- package/dist/transformer/reasoning.transformer.d.ts +10 -0
- package/dist/transformer/sampling.transformer.d.ts +13 -0
- package/dist/transformer/streamoptions.transformer.d.ts +6 -0
- package/dist/transformer/tooluse.transformer.d.ts +7 -0
- package/dist/transformer/vercel.transformer.d.ts +11 -0
- package/dist/transformer/vertex-claude.transformer.d.ts +9 -0
- package/dist/transformer/vertex-gemini.transformer.d.ts +12 -0
- package/dist/transformer/vertex-openai.transformer.d.ts +19 -0
- package/dist/types/llm.d.ts +255 -0
- package/dist/types/transformer.d.ts +23 -0
- package/dist/utils/antigravity-auth.d.ts +75 -0
- package/dist/utils/auth-recovery.d.ts +2 -0
- package/dist/utils/cache.d.ts +14 -0
- package/dist/utils/cacheControl.d.ts +44 -0
- package/dist/utils/claude-auth.d.ts +22 -0
- package/dist/utils/codex-auth.d.ts +33 -0
- package/dist/utils/converter.d.ts +11 -0
- package/dist/utils/cursor-auth.d.ts +3 -0
- package/dist/utils/deepseek.util.d.ts +28 -0
- package/dist/utils/gemini-cache.d.ts +8 -0
- package/dist/utils/gemini-thinking.d.ts +66 -0
- package/dist/utils/gemini.util.d.ts +43 -0
- package/dist/utils/google.util.d.ts +160 -0
- package/dist/utils/image.d.ts +1 -0
- package/dist/utils/mistral.util.d.ts +14 -0
- package/dist/utils/openai.util.d.ts +17 -0
- package/dist/utils/qwen-auth.d.ts +13 -0
- package/dist/utils/redact.d.ts +30 -0
- package/dist/utils/request.d.ts +4 -0
- package/dist/utils/retry.d.ts +27 -0
- package/dist/utils/router.d.ts +42 -0
- package/dist/utils/schema.d.ts +46 -0
- package/dist/utils/sse/SSEParser.transform.d.ts +6 -0
- package/dist/utils/sse/SSESerializer.transform.d.ts +3 -0
- package/dist/utils/sse/index.d.ts +3 -0
- package/dist/utils/sse/rewriteStream.d.ts +9 -0
- package/dist/utils/stream.d.ts +11 -0
- package/dist/utils/thinking.d.ts +33 -0
- package/dist/utils/thought-signature-cache.d.ts +34 -0
- package/dist/utils/toolArgumentsParser.d.ts +8 -0
- package/dist/utils/vertex-claude.util.d.ts +47 -0
- package/package.json +3 -3
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export type SseEmitter = {
|
|
2
|
+
enqueueChunk: (chunk: Record<string, unknown>) => void;
|
|
3
|
+
enqueueDone: () => void;
|
|
4
|
+
};
|
|
5
|
+
export declare function createSseHelpers(model: string, encoder: TextEncoder): {
|
|
6
|
+
setId(next: string): void;
|
|
7
|
+
content(text: string): {
|
|
8
|
+
choices: {
|
|
9
|
+
index: number;
|
|
10
|
+
delta: {
|
|
11
|
+
role: string;
|
|
12
|
+
content: string;
|
|
13
|
+
};
|
|
14
|
+
finish_reason: null;
|
|
15
|
+
}[];
|
|
16
|
+
id: string;
|
|
17
|
+
object: string;
|
|
18
|
+
created: number;
|
|
19
|
+
model: string;
|
|
20
|
+
};
|
|
21
|
+
thinking(text: string): {
|
|
22
|
+
choices: {
|
|
23
|
+
index: number;
|
|
24
|
+
delta: {
|
|
25
|
+
thinking: {
|
|
26
|
+
content: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
finish_reason: null;
|
|
30
|
+
}[];
|
|
31
|
+
id: string;
|
|
32
|
+
object: string;
|
|
33
|
+
created: number;
|
|
34
|
+
model: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Claude Code / Anthropic expecting extended-thinking streams require a
|
|
38
|
+
* signature_delta before the thinking block is closed. Cursor SDK has no
|
|
39
|
+
* provider signature, so emit a synthetic one (same pattern as reasoning /
|
|
40
|
+
* forcereasoning transformers). Without this, thinking_deltas are on the
|
|
41
|
+
* wire but the UI often never surfaces them.
|
|
42
|
+
*/
|
|
43
|
+
thinkingSignature(signature?: string): {
|
|
44
|
+
choices: {
|
|
45
|
+
index: number;
|
|
46
|
+
delta: {
|
|
47
|
+
thinking: {
|
|
48
|
+
signature: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
finish_reason: null;
|
|
52
|
+
}[];
|
|
53
|
+
id: string;
|
|
54
|
+
object: string;
|
|
55
|
+
created: number;
|
|
56
|
+
model: string;
|
|
57
|
+
};
|
|
58
|
+
toolCall(tool: {
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
args: Record<string, unknown>;
|
|
62
|
+
}, index?: number): {
|
|
63
|
+
choices: {
|
|
64
|
+
index: number;
|
|
65
|
+
delta: {
|
|
66
|
+
role: string;
|
|
67
|
+
tool_calls: {
|
|
68
|
+
index: number;
|
|
69
|
+
id: string;
|
|
70
|
+
type: string;
|
|
71
|
+
function: {
|
|
72
|
+
name: string;
|
|
73
|
+
arguments: string;
|
|
74
|
+
};
|
|
75
|
+
}[];
|
|
76
|
+
};
|
|
77
|
+
finish_reason: null;
|
|
78
|
+
}[];
|
|
79
|
+
id: string;
|
|
80
|
+
object: string;
|
|
81
|
+
created: number;
|
|
82
|
+
model: string;
|
|
83
|
+
};
|
|
84
|
+
finish(reason: "stop" | "tool_calls", usage?: {
|
|
85
|
+
prompt_tokens?: number;
|
|
86
|
+
completion_tokens?: number;
|
|
87
|
+
total_tokens?: number;
|
|
88
|
+
prompt_tokens_details?: {
|
|
89
|
+
cached_tokens?: number;
|
|
90
|
+
};
|
|
91
|
+
}): {
|
|
92
|
+
choices: {
|
|
93
|
+
index: number;
|
|
94
|
+
delta: {};
|
|
95
|
+
finish_reason: "stop" | "tool_calls";
|
|
96
|
+
}[];
|
|
97
|
+
usage: {
|
|
98
|
+
prompt_tokens: number;
|
|
99
|
+
completion_tokens: number;
|
|
100
|
+
total_tokens: number;
|
|
101
|
+
prompt_tokens_details: {
|
|
102
|
+
cached_tokens: number;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
id: string;
|
|
106
|
+
object: string;
|
|
107
|
+
created: number;
|
|
108
|
+
model: string;
|
|
109
|
+
};
|
|
110
|
+
encode(chunk: Record<string, unknown>): Uint8Array<ArrayBufferLike>;
|
|
111
|
+
encodeDone(): Uint8Array<ArrayBufferLike>;
|
|
112
|
+
};
|
|
113
|
+
export declare function accumulateChatCompletion(model: string, chunks: Array<Record<string, unknown>>): Record<string, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ensureDenyHooksWorkspace(workspaceDir: string): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { UnifiedChatRequest } from "../types/llm";
|
|
2
|
+
import type { SDKUserMessage } from "@cursor/sdk";
|
|
3
|
+
export declare function buildBridgeSystemGuidance(request: UnifiedChatRequest, workspaceDir: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Detect a short terminal message that only announces work which never occurred.
|
|
6
|
+
* Keep this deliberately narrow: it is a recovery signal, not a general quality score.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isProgressOnlyAssistantText(text: string): boolean;
|
|
9
|
+
export declare function shouldContinueProgressOnlyTurn(input: {
|
|
10
|
+
mode: "bridge" | "plan" | "agent";
|
|
11
|
+
assistantText: string;
|
|
12
|
+
emittedHostTools: number;
|
|
13
|
+
continuationAttempts: number;
|
|
14
|
+
}): boolean;
|
|
15
|
+
export declare function progressOnlyContinuationPrompt(): SDKUserMessage;
|
|
16
|
+
/**
|
|
17
|
+
* Flatten Unified chat history into a single SDK prompt for a fresh/continued send.
|
|
18
|
+
* Live parked tool results are resolved via customTools.execute — not only this text.
|
|
19
|
+
*/
|
|
20
|
+
export declare function toSdkPrompt(request: UnifiedChatRequest, options: {
|
|
21
|
+
mode: "bridge" | "plan" | "agent";
|
|
22
|
+
workspaceDir: string;
|
|
23
|
+
/** When true, only the latest user turn (+ guidance) is sent — session already has history. */
|
|
24
|
+
followUpOnly?: boolean;
|
|
25
|
+
}): SDKUserMessage;
|
|
26
|
+
export declare function extractTrailingToolResults(request: UnifiedChatRequest): Array<{
|
|
27
|
+
toolCallId: string;
|
|
28
|
+
content: string;
|
|
29
|
+
}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UnifiedChatRequest } from "../types/llm";
|
|
2
|
+
import { type CursorSdkMode } from "./shared";
|
|
3
|
+
export interface CursorSdkRunnerOptions {
|
|
4
|
+
cursorMode?: CursorSdkMode;
|
|
5
|
+
cursorCwd?: string;
|
|
6
|
+
/** Opt-in only; ignored/forced off in Docker. Default false. */
|
|
7
|
+
sandboxEnabled?: boolean;
|
|
8
|
+
abortSignal?: AbortSignal;
|
|
9
|
+
logger?: any;
|
|
10
|
+
}
|
|
11
|
+
export declare function runCursor(request: UnifiedChatRequest, provider: any, context: any, options?: CursorSdkRunnerOptions): Promise<Response>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SDKUserMessage } from "@cursor/sdk";
|
|
2
|
+
import { type CursorSdkSession } from "./session";
|
|
3
|
+
export declare const CURSOR_SEND_TIMEOUT_MESSAGE = "Cursor SDK agent.send timed out";
|
|
4
|
+
export declare function isCursorAgentBusyError(err: unknown): boolean;
|
|
5
|
+
export declare function isCursorSendPoisonError(err: unknown): boolean;
|
|
6
|
+
export declare function sendCursorPrompt(session: CursorSdkSession, prompt: SDKUserMessage, sendOptions: Record<string, any>, options?: {
|
|
7
|
+
abortSignal?: AbortSignal;
|
|
8
|
+
logger?: any;
|
|
9
|
+
}): Promise<import("@cursor/sdk").Run>;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { type ModelSelection, type Run, type SDKAgent, type SDKMessage } from "@cursor/sdk";
|
|
2
|
+
import type { OpenAiUsage } from "./usage";
|
|
3
|
+
import { type CursorSdkMode } from "./shared";
|
|
4
|
+
export type ParkedTool = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
args: Record<string, unknown>;
|
|
8
|
+
runToken?: symbol;
|
|
9
|
+
resolve: (result: string) => void;
|
|
10
|
+
reject: (err: Error) => void;
|
|
11
|
+
promise: Promise<string>;
|
|
12
|
+
};
|
|
13
|
+
export type CursorSdkSession = {
|
|
14
|
+
key: string;
|
|
15
|
+
agent: SDKAgent;
|
|
16
|
+
agentId: string;
|
|
17
|
+
mode: CursorSdkMode;
|
|
18
|
+
workspaceDir: string;
|
|
19
|
+
run?: Run;
|
|
20
|
+
streamIterator?: AsyncIterator<any>;
|
|
21
|
+
activeRunToken?: symbol;
|
|
22
|
+
lastSdkUsageRaw?: OpenAiUsage;
|
|
23
|
+
parked: ParkedTool[];
|
|
24
|
+
/** Tool calls waiting to be emitted on the current SSE response. */
|
|
25
|
+
pendingEmit: Array<{
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
args: Record<string, unknown>;
|
|
29
|
+
runToken?: symbol;
|
|
30
|
+
}>;
|
|
31
|
+
emitWaiters: Array<() => void>;
|
|
32
|
+
/** SDK raw delta callbacks waiting to be merged into the current SSE response. */
|
|
33
|
+
pendingSdkMessages: Array<{
|
|
34
|
+
message: SDKMessage;
|
|
35
|
+
runToken?: symbol;
|
|
36
|
+
source: "delta";
|
|
37
|
+
}>;
|
|
38
|
+
sdkMessageWaiters: Array<() => void>;
|
|
39
|
+
/**
|
|
40
|
+
* Serializes cancel/send so a follow-up compact/retry cannot call
|
|
41
|
+
* `agent.send` while a prior run is still marked active in the SDK store.
|
|
42
|
+
*/
|
|
43
|
+
sendChain: Promise<void>;
|
|
44
|
+
/** True after at least one successful `agent.send` on this session. */
|
|
45
|
+
hasSentPrompt: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Set when the local SDK handles are no longer trustworthy. The manager must
|
|
48
|
+
* not hand this agent out for a future request.
|
|
49
|
+
*/
|
|
50
|
+
poisoned?: boolean;
|
|
51
|
+
poisonReason?: string;
|
|
52
|
+
lastActiveAt: number;
|
|
53
|
+
metrics: {
|
|
54
|
+
customToolCalls: number;
|
|
55
|
+
builtinToolCallsSeen: number;
|
|
56
|
+
};
|
|
57
|
+
parkHostTool: (tool: {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
args: Record<string, unknown>;
|
|
61
|
+
}) => Promise<string>;
|
|
62
|
+
notifyEmit: () => void;
|
|
63
|
+
waitForEmit: () => Promise<void>;
|
|
64
|
+
enqueueSdkMessage: (message: SDKMessage, runToken?: symbol) => void;
|
|
65
|
+
notifySdkMessage: () => void;
|
|
66
|
+
waitForSdkMessage: () => Promise<void>;
|
|
67
|
+
};
|
|
68
|
+
export type CancelActiveRunResult = {
|
|
69
|
+
skipped: boolean;
|
|
70
|
+
hadRun: boolean;
|
|
71
|
+
hadIterator: boolean;
|
|
72
|
+
failed: boolean;
|
|
73
|
+
timedOut: boolean;
|
|
74
|
+
};
|
|
75
|
+
export declare function markSessionPoisoned(session: CursorSdkSession, reason: string): void;
|
|
76
|
+
/**
|
|
77
|
+
* Drop local run handles and await SDK `run.cancel()` when needed.
|
|
78
|
+
*
|
|
79
|
+
* Cursor persists `activeRunId` in its local store and throws
|
|
80
|
+
* `Agent … already has active run` on the next `agent.send` until the prior
|
|
81
|
+
* run is terminal. Client disconnect / compact / retry often leave a live run.
|
|
82
|
+
*/
|
|
83
|
+
export declare function cancelActiveRun(session: CursorSdkSession, options?: {
|
|
84
|
+
rejectParked?: boolean;
|
|
85
|
+
reason?: string;
|
|
86
|
+
timeoutMs?: number;
|
|
87
|
+
onlyRunToken?: symbol;
|
|
88
|
+
poisonOnFailure?: boolean;
|
|
89
|
+
}): Promise<CancelActiveRunResult>;
|
|
90
|
+
export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, message: string): Promise<T>;
|
|
91
|
+
/** Run `fn` exclusively against this session's cancel/send critical section. */
|
|
92
|
+
export declare function withSessionSendLock<T>(session: CursorSdkSession, fn: () => Promise<T>): Promise<T>;
|
|
93
|
+
/**
|
|
94
|
+
* Cursor local sandbox requires a supported host (typically desktop with the
|
|
95
|
+
* sandbox helper). Docker/Alpine/CI do not support it and throw:
|
|
96
|
+
* "Local SDK sandboxing was requested, but sandboxing is not supported…".
|
|
97
|
+
*
|
|
98
|
+
* Model D relies on deny-hooks + customTools park, not sandbox. Default OFF;
|
|
99
|
+
* opt in with transformer `sandboxEnabled: true` or `CCR_CURSOR_SANDBOX=1`
|
|
100
|
+
* only on supported hosts.
|
|
101
|
+
*/
|
|
102
|
+
export declare function shouldEnableCursorSandbox(requested?: boolean): boolean;
|
|
103
|
+
export declare function buildSessionKey(input: {
|
|
104
|
+
headerSession?: string;
|
|
105
|
+
metadataUserId?: string;
|
|
106
|
+
model?: string;
|
|
107
|
+
systemAndFirstUser?: string;
|
|
108
|
+
}): string;
|
|
109
|
+
/** True while a session has a live run, open stream, or unresolved host tools. */
|
|
110
|
+
export declare function isSessionInFlight(session: CursorSdkSession): boolean;
|
|
111
|
+
export declare function touchSession(session: CursorSdkSession): void;
|
|
112
|
+
export declare class SessionManager {
|
|
113
|
+
private logger?;
|
|
114
|
+
private sessions;
|
|
115
|
+
private cleanupTimer?;
|
|
116
|
+
constructor(logger?: any | undefined);
|
|
117
|
+
setLogger(logger: any): void;
|
|
118
|
+
get(key: string): CursorSdkSession | undefined;
|
|
119
|
+
getOrCreate(options: {
|
|
120
|
+
key: string;
|
|
121
|
+
apiKey: string;
|
|
122
|
+
model: ModelSelection;
|
|
123
|
+
mode: CursorSdkMode;
|
|
124
|
+
cursorCwd?: string;
|
|
125
|
+
sandboxEnabled?: boolean;
|
|
126
|
+
}): Promise<CursorSdkSession>;
|
|
127
|
+
resume(options: {
|
|
128
|
+
key: string;
|
|
129
|
+
agentId: string;
|
|
130
|
+
apiKey: string;
|
|
131
|
+
model?: ModelSelection;
|
|
132
|
+
mode: CursorSdkMode;
|
|
133
|
+
workspaceDir: string;
|
|
134
|
+
sandboxEnabled?: boolean;
|
|
135
|
+
}): Promise<CursorSdkSession>;
|
|
136
|
+
resolveParkedTools(session: CursorSdkSession, results: Array<{
|
|
137
|
+
toolCallId: string;
|
|
138
|
+
content: string;
|
|
139
|
+
}>): number;
|
|
140
|
+
dispose(key: string): Promise<void>;
|
|
141
|
+
invalidate(sessionOrKey: CursorSdkSession | string, reason: string): void;
|
|
142
|
+
private createSessionRecord;
|
|
143
|
+
private evictIfNeeded;
|
|
144
|
+
private evictIdle;
|
|
145
|
+
}
|
|
146
|
+
export declare const globalSessionManager: SessionManager;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const CURSOR_SDK_TRANSFORMER_NAME = "cursor-sdk";
|
|
2
|
+
export type CursorSdkMode = "bridge" | "plan" | "agent";
|
|
3
|
+
export declare const DEFAULT_CURSOR_MODE: CursorSdkMode;
|
|
4
|
+
export declare const CCR_HOME: string;
|
|
5
|
+
export declare const CURSOR_SDK_WORKSPACES_ROOT: string;
|
|
6
|
+
export declare const SESSION_IDLE_TTL_MS: number;
|
|
7
|
+
export declare const SESSION_LRU_MAX = 32;
|
|
8
|
+
/** Cursor built-ins we try to deny so Claude Code remains the tool host. */
|
|
9
|
+
export declare const CURSOR_BUILTIN_DENY_LIST: readonly ["Shell", "Read", "Write", "Delete", "Grep", "Glob", "Edit", "ApplyPatch", "Task", "SemanticSearch", "SemSearch", "ReadLints", "LS", "CreatePlan", "UpdateTodos", "Await", "WebFetch", "WebSearch", "GenerateImage"];
|
|
10
|
+
export declare const CUSTOM_USER_TOOLS_SERVER = "custom-user-tools";
|
|
11
|
+
export declare function ensureCcrHomePaths(): string[];
|
|
12
|
+
export declare function hashSessionFingerprint(parts: string[]): string;
|
|
13
|
+
export declare function coerceThinkingText(value: unknown): string;
|
|
14
|
+
export declare function extractEffort(request: any): string | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SDKCustomTool } from "@cursor/sdk";
|
|
2
|
+
import type { UnifiedChatRequest } from "../types/llm";
|
|
3
|
+
import type { CursorSdkSession } from "./session";
|
|
4
|
+
export declare function toCustomTools(request: UnifiedChatRequest, session: CursorSdkSession): Record<string, SDKCustomTool>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { UnifiedChatRequest } from "../types/llm";
|
|
2
|
+
export type OpenAiUsage = {
|
|
3
|
+
prompt_tokens: number;
|
|
4
|
+
completion_tokens: number;
|
|
5
|
+
total_tokens: number;
|
|
6
|
+
prompt_tokens_details?: {
|
|
7
|
+
cached_tokens?: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Rough char→token estimate for mid-turn usage before Cursor emits a usage
|
|
12
|
+
* event (and as the host-facing request usage even when it does).
|
|
13
|
+
* Mirrors cursor-opencode-provider: never report Cursor cumulative counters as
|
|
14
|
+
* the current Claude Code / OpenCode request usage.
|
|
15
|
+
*/
|
|
16
|
+
export declare function estimateTokens(chars: number): number;
|
|
17
|
+
/** Estimate current-request prompt tokens from the Claude Code → CCR payload. */
|
|
18
|
+
export declare function estimateRequestPromptTokens(request: UnifiedChatRequest): number;
|
|
19
|
+
/** Build OpenAI-style usage for a single CCR request (not Cursor session totals). */
|
|
20
|
+
export declare function requestUsageFromEstimate(promptTokens: number, outputChars: number, cacheReadTokens?: number): OpenAiUsage;
|
|
21
|
+
/**
|
|
22
|
+
* Cursor SDK usage is session-cumulative, while Claude Code needs per-request
|
|
23
|
+
* usage. Use SDK usage only as a cache-read ratio and apply it to CCR's
|
|
24
|
+
* current-request prompt estimate.
|
|
25
|
+
*/
|
|
26
|
+
export declare function cacheReadFromSdkDelta(current: OpenAiUsage | undefined, previous: OpenAiUsage | undefined, promptTokens: number): number;
|
|
27
|
+
/** Map SDK TokenUsage / usage message into OpenAI shape (diagnostics only). */
|
|
28
|
+
export declare function usageFromSdk(message: any): OpenAiUsage | undefined;
|