@caeliq/llms 1.0.56 → 1.0.58
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 +92 -10
- package/dist/api/middleware.d.ts +9 -0
- package/dist/api/routes.d.ts +15 -0
- package/dist/cjs/server.cjs +225 -215
- 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 +2 -0
- package/dist/cursor-sdk/host-env.d.ts +38 -0
- package/dist/cursor-sdk/lifecycle-planner.d.ts +69 -0
- package/dist/cursor-sdk/prompt.d.ts +59 -0
- package/dist/cursor-sdk/runner.d.ts +40 -0
- package/dist/cursor-sdk/send.d.ts +9 -0
- package/dist/cursor-sdk/session.d.ts +199 -0
- package/dist/cursor-sdk/shared.d.ts +28 -0
- package/dist/cursor-sdk/tool-paths.d.ts +26 -0
- package/dist/cursor-sdk/tools.d.ts +15 -0
- package/dist/cursor-sdk/turn-identity.d.ts +46 -0
- package/dist/cursor-sdk/turn-output.d.ts +77 -0
- package/dist/cursor-sdk/usage.d.ts +28 -0
- package/dist/esm/server.mjs +225 -215
- 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/anthropic.tool-call-id-sanitize.d.ts +1 -0
- package/dist/tests/anthropic.turn-intent.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.host-env.d.ts +1 -0
- package/dist/tests/cursor-sdk.interrupt-reentry.d.ts +1 -0
- package/dist/tests/cursor-sdk.lifecycle-planner.d.ts +1 -0
- package/dist/tests/cursor-sdk.on-delta-thinking.d.ts +1 -0
- package/dist/tests/cursor-sdk.pending-next-rejection.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.scratch-paths.d.ts +1 -0
- package/dist/tests/cursor-sdk.scratch-report.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.tool-call-id.d.ts +1 -0
- package/dist/tests/cursor-sdk.trailing-turn-fallback.d.ts +1 -0
- package/dist/tests/cursor-sdk.turn-coordination.d.ts +1 -0
- package/dist/tests/cursor-sdk.turn-identity.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/stream.upstream-terminated.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 +25 -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 +29 -0
- package/dist/types/turn-intent.d.ts +26 -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/toolCallId.d.ts +15 -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,38 @@
|
|
|
1
|
+
import type { UnifiedChatRequest } from "../types/llm";
|
|
2
|
+
/**
|
|
3
|
+
* Facts about the machine where host tools actually execute.
|
|
4
|
+
*
|
|
5
|
+
* CCR (and therefore the Cursor SDK agent) may run in a container with no
|
|
6
|
+
* access to the user's filesystem, while Claude Code executes every tool call
|
|
7
|
+
* on the user's real machine. Cursor builds its harness prompt server-side from
|
|
8
|
+
* the SDK's workspace root, so the model is told — at system level — that it
|
|
9
|
+
* lives in the scratch workspace. These facts are the counter-evidence: they are
|
|
10
|
+
* lifted verbatim from the host's own environment block.
|
|
11
|
+
*/
|
|
12
|
+
export type HostEnvironment = {
|
|
13
|
+
/** Absolute path of the host project root, when the host advertised one. */
|
|
14
|
+
projectRoot?: string;
|
|
15
|
+
/** Extra roots the host declared as in-scope. */
|
|
16
|
+
additionalRoots: string[];
|
|
17
|
+
platform?: string;
|
|
18
|
+
osVersion?: string;
|
|
19
|
+
/** Every `Key: value` pair discovered, in discovery order, verbatim. */
|
|
20
|
+
facts: Array<{
|
|
21
|
+
key: string;
|
|
22
|
+
value: string;
|
|
23
|
+
}>;
|
|
24
|
+
/** True when anything at all was discovered. */
|
|
25
|
+
known: boolean;
|
|
26
|
+
/** Stable id of the resolved environment; changes only when the facts change. */
|
|
27
|
+
fingerprint: string;
|
|
28
|
+
};
|
|
29
|
+
/** Nothing discovered — guidance falls back to conservative path wording. */
|
|
30
|
+
export declare const EMPTY_HOST_ENVIRONMENT: HostEnvironment;
|
|
31
|
+
export declare function extractHostEnvironment(request: UnifiedChatRequest): HostEnvironment;
|
|
32
|
+
/** Bullet lines describing the host machine, for prompt/rules injection. */
|
|
33
|
+
export declare function describeHostEnvironment(env: HostEnvironment): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Path rule for the model. Positive and concrete when the host root is known,
|
|
36
|
+
* conservative when it is not — never guess a root.
|
|
37
|
+
*/
|
|
38
|
+
export declare function hostPathRule(env: HostEnvironment): string;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export type CursorContextAlignment = "strict" | "unknown" | "divergent";
|
|
2
|
+
export type CursorParkedToolRef = {
|
|
3
|
+
id: string;
|
|
4
|
+
};
|
|
5
|
+
export type CursorToolResultRef = {
|
|
6
|
+
toolCallId: string;
|
|
7
|
+
};
|
|
8
|
+
export type ExactParkedResultMatch<TParked extends CursorParkedToolRef = CursorParkedToolRef, TResult extends CursorToolResultRef = CursorToolResultRef> = ReadonlyArray<{
|
|
9
|
+
parked: TParked;
|
|
10
|
+
result: TResult;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Pair every parked tool with exactly one result by id.
|
|
14
|
+
*
|
|
15
|
+
* Empty, missing, extra, blank, or duplicate ids are not exact matches. The
|
|
16
|
+
* returned pairs follow parked-tool order, and neither input array is mutated.
|
|
17
|
+
*/
|
|
18
|
+
export declare function matchParkedToolResultsExactly<TParked extends CursorParkedToolRef, TResult extends CursorToolResultRef>(parkedTools: readonly TParked[], toolResults: readonly TResult[]): ExactParkedResultMatch<TParked, TResult> | undefined;
|
|
19
|
+
export type CursorRunSnapshot<TParked extends CursorParkedToolRef = CursorParkedToolRef> = {
|
|
20
|
+
kind: "idle";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Identical active turns must be coalesced before invoking this planner.
|
|
24
|
+
* This state therefore always represents a different, superseding turn.
|
|
25
|
+
*/
|
|
26
|
+
| {
|
|
27
|
+
kind: "active-different-turn";
|
|
28
|
+
} | {
|
|
29
|
+
kind: "parked";
|
|
30
|
+
/** False when the prior iterator/run can no longer be continued. */
|
|
31
|
+
live: boolean;
|
|
32
|
+
tools: readonly TParked[];
|
|
33
|
+
};
|
|
34
|
+
export type CursorLifecycleInput<TParked extends CursorParkedToolRef = CursorParkedToolRef, TResult extends CursorToolResultRef = CursorToolResultRef> = {
|
|
35
|
+
session: {
|
|
36
|
+
hasSentPrompt: boolean;
|
|
37
|
+
poisoned: boolean;
|
|
38
|
+
alignment: CursorContextAlignment;
|
|
39
|
+
run: CursorRunSnapshot<TParked>;
|
|
40
|
+
};
|
|
41
|
+
turn: {
|
|
42
|
+
hasMeaningfulSteering: boolean;
|
|
43
|
+
toolResults: readonly TResult[];
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export type CursorLifecycleRetirementReason = "poisoned-session" | "inconsistent-unused-session" | "unknown-context-alignment" | "divergent-context-alignment" | "active-different-turn" | "dead-parked-run" | "parked-turn-has-steering" | "parked-tool-results-mismatch" | "orphaned-tool-results";
|
|
47
|
+
export type CursorLifecycleRetirementPlan = {
|
|
48
|
+
action: "retire-and-replay-full";
|
|
49
|
+
reason: CursorLifecycleRetirementReason;
|
|
50
|
+
};
|
|
51
|
+
export type CursorLifecyclePlan<TParked extends CursorParkedToolRef = CursorParkedToolRef, TResult extends CursorToolResultRef = CursorToolResultRef> = {
|
|
52
|
+
action: "resume-parked";
|
|
53
|
+
reason: "exact-parked-tool-results";
|
|
54
|
+
matches: ExactParkedResultMatch<TParked, TResult>;
|
|
55
|
+
} | {
|
|
56
|
+
action: "send-full";
|
|
57
|
+
reason: "unused-session";
|
|
58
|
+
} | {
|
|
59
|
+
action: "send-incremental";
|
|
60
|
+
reason: "strictly-aligned-idle-session";
|
|
61
|
+
} | CursorLifecycleRetirementPlan;
|
|
62
|
+
/**
|
|
63
|
+
* Choose the only safe lifecycle action for a new, non-coalesced host turn.
|
|
64
|
+
*
|
|
65
|
+
* This function is intentionally pure. It neither resolves parked tools nor
|
|
66
|
+
* changes session state; the caller executes the returned plan under its
|
|
67
|
+
* per-session coordinator.
|
|
68
|
+
*/
|
|
69
|
+
export declare function planCursorLifecycle<TParked extends CursorParkedToolRef, TResult extends CursorToolResultRef>(input: CursorLifecycleInput<TParked, TResult>): CursorLifecyclePlan<TParked, TResult>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { UnifiedChatRequest } from "../types/llm";
|
|
2
|
+
import { type UnifiedTurnIntent } from "../types/turn-intent";
|
|
3
|
+
import type { SDKUserMessage } from "@cursor/sdk";
|
|
4
|
+
import { type HostEnvironment } from "./host-env";
|
|
5
|
+
export declare function buildBridgeSystemGuidance(request: UnifiedChatRequest, workspaceDir: string, hostEnv?: HostEnvironment): string;
|
|
6
|
+
/**
|
|
7
|
+
* Short restatement appended after the transcript. The guidance above is far
|
|
8
|
+
* from the generation point once history is flattened in; this is the last
|
|
9
|
+
* thing the model reads before answering.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildBridgeTailReminder(workspaceDir: string, hostEnv: HostEnvironment): string;
|
|
12
|
+
/** Rules document for the sandbox workspace, injected by Cursor as project rules. */
|
|
13
|
+
export declare function buildWorkspaceRulesDocument(workspaceDir: string, hostEnv: HostEnvironment): string;
|
|
14
|
+
/** One-line rationale attached to Cursor built-in denials. */
|
|
15
|
+
export declare function buildDenyGuidance(hostEnv: HostEnvironment): string;
|
|
16
|
+
/**
|
|
17
|
+
* Detect a short terminal message that only announces work which never occurred.
|
|
18
|
+
* Keep this deliberately narrow: it is a recovery signal, not a general quality score.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isProgressOnlyAssistantText(text: string): boolean;
|
|
21
|
+
export declare function shouldContinueProgressOnlyTurn(input: {
|
|
22
|
+
mode: "bridge" | "plan" | "agent";
|
|
23
|
+
assistantText: string;
|
|
24
|
+
emittedHostTools: number;
|
|
25
|
+
continuationAttempts: number;
|
|
26
|
+
}): boolean;
|
|
27
|
+
export declare function progressOnlyContinuationPrompt(hostEnv?: HostEnvironment): SDKUserMessage;
|
|
28
|
+
/**
|
|
29
|
+
* Flatten Unified chat history into a single SDK prompt for a fresh/continued send.
|
|
30
|
+
* Live parked tool results are resolved via customTools.execute — not only this text.
|
|
31
|
+
*/
|
|
32
|
+
export declare function toSdkPrompt(request: UnifiedChatRequest, options: {
|
|
33
|
+
mode: "bridge" | "plan" | "agent";
|
|
34
|
+
workspaceDir: string;
|
|
35
|
+
/** When true, only the latest user turn (+ guidance) is sent — session already has history. */
|
|
36
|
+
followUpOnly?: boolean;
|
|
37
|
+
hostEnv?: HostEnvironment;
|
|
38
|
+
/** Protocol semantics recovered before Anthropic content was flattened. */
|
|
39
|
+
turnIntent?: UnifiedTurnIntent;
|
|
40
|
+
}): SDKUserMessage;
|
|
41
|
+
export type TrailingCursorToolTurn = {
|
|
42
|
+
toolResults: Array<{
|
|
43
|
+
toolCallId: string;
|
|
44
|
+
content: string;
|
|
45
|
+
isError?: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Claude Code can reject a tool and append a replacement instruction in the
|
|
49
|
+
* same Anthropic user block. AnthropicTransformer splits that block into
|
|
50
|
+
* Unified `tool` then `user` messages. Only meaningful replacement content
|
|
51
|
+
* counts here; Claude Code's synthetic interruption marker alone does not.
|
|
52
|
+
*/
|
|
53
|
+
hasTrailingUserInput: boolean;
|
|
54
|
+
};
|
|
55
|
+
export declare function analyzeTrailingCursorToolTurn(request: UnifiedChatRequest, turnIntent?: UnifiedTurnIntent): TrailingCursorToolTurn;
|
|
56
|
+
export declare function extractTrailingToolResults(request: UnifiedChatRequest, turnIntent?: UnifiedTurnIntent): Array<{
|
|
57
|
+
toolCallId: string;
|
|
58
|
+
content: string;
|
|
59
|
+
}>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type SDKMessage } from "@cursor/sdk";
|
|
2
|
+
import type { UnifiedChatRequest } from "../types/llm";
|
|
3
|
+
import type { UnifiedTurnIntent } from "../types/turn-intent";
|
|
4
|
+
import { type CursorSdkSession } from "./session";
|
|
5
|
+
import { type CursorSdkMode } from "./shared";
|
|
6
|
+
export interface CursorSdkRunnerOptions {
|
|
7
|
+
cursorMode?: CursorSdkMode;
|
|
8
|
+
cursorCwd?: string;
|
|
9
|
+
/** Opt-in only; ignored/forced off in Docker. Default false. */
|
|
10
|
+
sandboxEnabled?: boolean;
|
|
11
|
+
abortSignal?: AbortSignal;
|
|
12
|
+
logger?: any;
|
|
13
|
+
/** Request-local protocol semantics; never serialized into the provider body. */
|
|
14
|
+
turnIntent?: UnifiedTurnIntent;
|
|
15
|
+
/** Stable source conversation identity recovered by the protocol adapter. */
|
|
16
|
+
sourceSessionIdentity?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function streamSessionEvents(session: CursorSdkSession, mode: CursorSdkMode, runToken: symbol, abortSignal?: AbortSignal): AsyncGenerator<{
|
|
19
|
+
kind: "sdk";
|
|
20
|
+
message: SDKMessage;
|
|
21
|
+
source: "stream" | "delta";
|
|
22
|
+
} | {
|
|
23
|
+
kind: "host_tool";
|
|
24
|
+
tool: {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
args: Record<string, unknown>;
|
|
28
|
+
};
|
|
29
|
+
} | {
|
|
30
|
+
kind: "end";
|
|
31
|
+
aborted?: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Coordinate identical host retries before entering the session lifecycle.
|
|
35
|
+
*
|
|
36
|
+
* The shared turn owns the one response producer. Every caller receives an
|
|
37
|
+
* independent bounded replay stream, so no two HTTP responses can consume the
|
|
38
|
+
* same Cursor iterator.
|
|
39
|
+
*/
|
|
40
|
+
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,199 @@
|
|
|
1
|
+
import { type ModelSelection, type Run, type SDKAgent, type SDKMessage } from "@cursor/sdk";
|
|
2
|
+
import type { OpenAiUsage } from "./usage";
|
|
3
|
+
import type { CursorTranscriptCommit } from "./turn-identity";
|
|
4
|
+
import { type HostEnvironment } from "./host-env";
|
|
5
|
+
import { type CursorSdkMode } from "./shared";
|
|
6
|
+
export type ParkedTool = {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
args: Record<string, unknown>;
|
|
10
|
+
runToken?: symbol;
|
|
11
|
+
resolve: (result: string) => void;
|
|
12
|
+
reject: (err: Error) => void;
|
|
13
|
+
promise: Promise<string>;
|
|
14
|
+
};
|
|
15
|
+
export type CursorSdkSession = {
|
|
16
|
+
key: string;
|
|
17
|
+
agent: SDKAgent;
|
|
18
|
+
agentId: string;
|
|
19
|
+
mode: CursorSdkMode;
|
|
20
|
+
workspaceDir: string;
|
|
21
|
+
/** Host machine facts for this session, refreshed each turn. */
|
|
22
|
+
hostEnv: HostEnvironment;
|
|
23
|
+
run?: Run;
|
|
24
|
+
streamIterator?: AsyncIterator<any>;
|
|
25
|
+
/**
|
|
26
|
+
* The one outstanding `iterator.next()` owned by this SDK run. It survives
|
|
27
|
+
* the HTTP tool-call boundary so a continuation never starts a second
|
|
28
|
+
* consumer on Cursor's single-consumer iterator.
|
|
29
|
+
*/
|
|
30
|
+
streamNext?: Promise<IteratorResult<any>>;
|
|
31
|
+
streamNextRunToken?: symbol;
|
|
32
|
+
activeRunToken?: symbol;
|
|
33
|
+
lastSdkUsageRaw?: OpenAiUsage;
|
|
34
|
+
parked: ParkedTool[];
|
|
35
|
+
/** Tool calls waiting to be emitted on the current SSE response. */
|
|
36
|
+
pendingEmit: Array<{
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
args: Record<string, unknown>;
|
|
40
|
+
runToken?: symbol;
|
|
41
|
+
}>;
|
|
42
|
+
emitWaiters: Array<() => void>;
|
|
43
|
+
/** SDK raw delta callbacks waiting to be merged into the current SSE response. */
|
|
44
|
+
pendingSdkMessages: Array<{
|
|
45
|
+
message: SDKMessage;
|
|
46
|
+
runToken?: symbol;
|
|
47
|
+
source: "delta";
|
|
48
|
+
}>;
|
|
49
|
+
sdkMessageWaiters: Array<() => void>;
|
|
50
|
+
/**
|
|
51
|
+
* Serializes cancel/send so a follow-up compact/retry cannot call
|
|
52
|
+
* `agent.send` while a prior run is still marked active in the SDK store.
|
|
53
|
+
*/
|
|
54
|
+
sendChain: Promise<void>;
|
|
55
|
+
/** True after at least one successful `agent.send` on this session. */
|
|
56
|
+
hasSentPrompt: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Exact host-visible transcript represented by this agent after the last
|
|
59
|
+
* completed response. Unknown means tail-only reuse is forbidden.
|
|
60
|
+
*/
|
|
61
|
+
transcriptCommit?: CursorTranscriptCommit;
|
|
62
|
+
/** Agent/model/workspace/tool configuration paired with transcriptCommit. */
|
|
63
|
+
compatibilityStamp?: string;
|
|
64
|
+
/** Fingerprint of the host env baked into the workspace rules/deny hooks. */
|
|
65
|
+
guidanceFingerprint?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Set when the local SDK handles are no longer trustworthy. The manager must
|
|
68
|
+
* not hand this agent out for a future request.
|
|
69
|
+
*/
|
|
70
|
+
poisoned?: boolean;
|
|
71
|
+
poisonReason?: string;
|
|
72
|
+
lastActiveAt: number;
|
|
73
|
+
metrics: {
|
|
74
|
+
customToolCalls: number;
|
|
75
|
+
builtinToolCallsSeen: number;
|
|
76
|
+
/** Host tool calls whose arguments pointed at the scratch workspace. */
|
|
77
|
+
scratchPathViolations: number;
|
|
78
|
+
/** Violations answered with a corrective result instead of execution. */
|
|
79
|
+
scratchPathCorrections: number;
|
|
80
|
+
};
|
|
81
|
+
parkHostTool: (tool: {
|
|
82
|
+
id: string;
|
|
83
|
+
name: string;
|
|
84
|
+
args: Record<string, unknown>;
|
|
85
|
+
}) => Promise<string>;
|
|
86
|
+
notifyEmit: () => void;
|
|
87
|
+
waitForEmit: () => Promise<void>;
|
|
88
|
+
enqueueSdkMessage: (message: SDKMessage, runToken?: symbol) => void;
|
|
89
|
+
notifySdkMessage: () => void;
|
|
90
|
+
waitForSdkMessage: () => Promise<void>;
|
|
91
|
+
};
|
|
92
|
+
export type CancelActiveRunResult = {
|
|
93
|
+
skipped: boolean;
|
|
94
|
+
hadRun: boolean;
|
|
95
|
+
hadIterator: boolean;
|
|
96
|
+
runCancelFailed: boolean;
|
|
97
|
+
iteratorReturnFailed: boolean;
|
|
98
|
+
failed: boolean;
|
|
99
|
+
timedOut: boolean;
|
|
100
|
+
};
|
|
101
|
+
export declare function markSessionPoisoned(session: CursorSdkSession, reason: string): void;
|
|
102
|
+
/**
|
|
103
|
+
* Drop local run handles and await SDK `run.cancel()` when needed.
|
|
104
|
+
*
|
|
105
|
+
* Cursor persists `activeRunId` in its local store and throws
|
|
106
|
+
* `Agent … already has active run` on the next `agent.send` until the prior
|
|
107
|
+
* run is terminal. Client disconnect / compact / retry often leave a live run.
|
|
108
|
+
*/
|
|
109
|
+
export declare function cancelActiveRun(session: CursorSdkSession, options?: {
|
|
110
|
+
rejectParked?: boolean;
|
|
111
|
+
reason?: string;
|
|
112
|
+
timeoutMs?: number;
|
|
113
|
+
onlyRunToken?: symbol;
|
|
114
|
+
poisonOnFailure?: boolean;
|
|
115
|
+
}): Promise<CancelActiveRunResult>;
|
|
116
|
+
export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, message: string): Promise<T>;
|
|
117
|
+
/** Run `fn` exclusively against this session's cancel/send critical section. */
|
|
118
|
+
export declare function withSessionSendLock<T>(session: CursorSdkSession, fn: () => Promise<T>): Promise<T>;
|
|
119
|
+
/**
|
|
120
|
+
* Cursor local sandbox requires a supported host (typically desktop with the
|
|
121
|
+
* sandbox helper). Docker/Alpine/CI do not support it and throw:
|
|
122
|
+
* "Local SDK sandboxing was requested, but sandboxing is not supported…".
|
|
123
|
+
*
|
|
124
|
+
* Model D relies on deny-hooks + customTools park, not sandbox. Default OFF;
|
|
125
|
+
* opt in with transformer `sandboxEnabled: true` or `CCR_CURSOR_SANDBOX=1`
|
|
126
|
+
* only on supported hosts.
|
|
127
|
+
*/
|
|
128
|
+
export declare function shouldEnableCursorSandbox(requested?: boolean): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Adopt this turn's host facts and re-stamp workspace rules when they changed.
|
|
131
|
+
* Cheap: files are only rewritten when their content actually differs.
|
|
132
|
+
*
|
|
133
|
+
* Cursor loads workspace rules when the agent's rules service is constructed,
|
|
134
|
+
* i.e. once per session — verified by appending a canary line to a live
|
|
135
|
+
* session's AGENTS.md, which the model did not see. So this rewrite serves the
|
|
136
|
+
* *next* agent created against this directory; the live turn picks up changed
|
|
137
|
+
* host facts through the prompt, and `session.hostEnv` (used by the scratch
|
|
138
|
+
* path correction) is updated here regardless.
|
|
139
|
+
*/
|
|
140
|
+
export declare function refreshWorkspaceGuidance(session: CursorSdkSession, hostEnv: HostEnvironment): boolean;
|
|
141
|
+
export declare function buildSessionKey(input: {
|
|
142
|
+
headerSession?: string;
|
|
143
|
+
metadataUserId?: string;
|
|
144
|
+
model?: string;
|
|
145
|
+
systemAndFirstUser?: string;
|
|
146
|
+
}): string;
|
|
147
|
+
/** True while a session has a live run, open stream, or unresolved host tools. */
|
|
148
|
+
export declare function isSessionInFlight(session: CursorSdkSession): boolean;
|
|
149
|
+
export declare function touchSession(session: CursorSdkSession): void;
|
|
150
|
+
export declare class SessionManager {
|
|
151
|
+
private logger?;
|
|
152
|
+
private sessions;
|
|
153
|
+
/** Per-key teardown barriers so reconnects cannot overtake SDK cancellation. */
|
|
154
|
+
private retirements;
|
|
155
|
+
/** Per-key creation barriers so retirement waiters cannot create sibling agents. */
|
|
156
|
+
private creations;
|
|
157
|
+
private cleanupTimer?;
|
|
158
|
+
/** Epoch 0 so the first eviction tick performs a sweep. */
|
|
159
|
+
private lastSweepAt;
|
|
160
|
+
constructor(logger?: any | undefined);
|
|
161
|
+
setLogger(logger: any): void;
|
|
162
|
+
get(key: string): CursorSdkSession | undefined;
|
|
163
|
+
retireSession(session: CursorSdkSession, reason: string, cleanup: () => Promise<boolean>): Promise<boolean>;
|
|
164
|
+
getOrCreate(options: {
|
|
165
|
+
key: string;
|
|
166
|
+
apiKey: string;
|
|
167
|
+
model: ModelSelection;
|
|
168
|
+
mode: CursorSdkMode;
|
|
169
|
+
cursorCwd?: string;
|
|
170
|
+
sandboxEnabled?: boolean;
|
|
171
|
+
hostEnv?: HostEnvironment;
|
|
172
|
+
}): Promise<CursorSdkSession>;
|
|
173
|
+
resume(options: {
|
|
174
|
+
key: string;
|
|
175
|
+
agentId: string;
|
|
176
|
+
apiKey: string;
|
|
177
|
+
model?: ModelSelection;
|
|
178
|
+
mode: CursorSdkMode;
|
|
179
|
+
workspaceDir: string;
|
|
180
|
+
sandboxEnabled?: boolean;
|
|
181
|
+
hostEnv?: HostEnvironment;
|
|
182
|
+
}): Promise<CursorSdkSession>;
|
|
183
|
+
resolveParkedTools(session: CursorSdkSession, results: Array<{
|
|
184
|
+
toolCallId: string;
|
|
185
|
+
content: string;
|
|
186
|
+
}>): number;
|
|
187
|
+
dispose(key: string): Promise<void>;
|
|
188
|
+
invalidate(sessionOrKey: CursorSdkSession | string, reason: string): void;
|
|
189
|
+
private createSessionRecord;
|
|
190
|
+
private evictIfNeeded;
|
|
191
|
+
private evictIdle;
|
|
192
|
+
/**
|
|
193
|
+
* Remove scratch workspaces left by earlier processes. `dispose` handles the
|
|
194
|
+
* live case; this collects what a crash, kill, or pre-cleanup build left on
|
|
195
|
+
* the volume. Rate limited and restricted to managed directories.
|
|
196
|
+
*/
|
|
197
|
+
sweepOrphanWorkspaces(now?: number, root?: string): number;
|
|
198
|
+
}
|
|
199
|
+
export declare const globalSessionManager: SessionManager;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { UnifiedMessage } from "../types/llm";
|
|
2
|
+
export declare const CURSOR_SDK_TRANSFORMER_NAME = "cursor-sdk";
|
|
3
|
+
export type CursorSdkMode = "bridge" | "plan" | "agent";
|
|
4
|
+
export declare const DEFAULT_CURSOR_MODE: CursorSdkMode;
|
|
5
|
+
export declare const CCR_HOME: string;
|
|
6
|
+
export declare const CURSOR_SDK_WORKSPACES_ROOT: string;
|
|
7
|
+
export declare const SESSION_IDLE_TTL_MS: number;
|
|
8
|
+
export declare const SESSION_LRU_MAX = 32;
|
|
9
|
+
/** Orphan scratch workspaces are swept after this long without modification. */
|
|
10
|
+
export declare const ORPHAN_WORKSPACE_TTL_MS: number;
|
|
11
|
+
/** How often the sweep may run, regardless of eviction tick frequency. */
|
|
12
|
+
export declare const WORKSPACE_SWEEP_INTERVAL_MS: number;
|
|
13
|
+
/**
|
|
14
|
+
* True only for a directory this module created for a session.
|
|
15
|
+
*
|
|
16
|
+
* Guards every removal: `cursorMode: "agent"` can point the session at a user
|
|
17
|
+
* supplied `cursorCwd`, which must never be swept.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isManagedWorkspacePath(dir: string, root?: string): boolean;
|
|
20
|
+
/** Cursor built-ins we try to deny so Claude Code remains the tool host. */
|
|
21
|
+
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"];
|
|
22
|
+
export declare const CUSTOM_USER_TOOLS_SERVER = "custom-user-tools";
|
|
23
|
+
export declare function ensureCcrHomePaths(): string[];
|
|
24
|
+
/** Flatten Unified message content (string or content parts) into plain text. */
|
|
25
|
+
export declare function contentToText(content: UnifiedMessage["content"]): string;
|
|
26
|
+
export declare function hashSessionFingerprint(parts: string[]): string;
|
|
27
|
+
export declare function coerceThinkingText(value: unknown): string;
|
|
28
|
+
export declare function extractEffort(request: any): string | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type HostEnvironment } from "./host-env";
|
|
2
|
+
export type ScratchPathHit = {
|
|
3
|
+
/** Dotted path to the offending argument, e.g. `edits.0.file_path`. */
|
|
4
|
+
argPath: string;
|
|
5
|
+
/** The offending value, truncated. */
|
|
6
|
+
value: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Detect host tool arguments pointing at the sandbox workspace.
|
|
10
|
+
*
|
|
11
|
+
* This is the observable symptom of the model believing it is confined to its
|
|
12
|
+
* own cwd. Claude Code would execute the call on the host, where that path does
|
|
13
|
+
* not exist (or, worse, exists as an unrelated directory).
|
|
14
|
+
*/
|
|
15
|
+
export declare function findScratchPaths(args: unknown, workspaceDir: string): ScratchPathHit[];
|
|
16
|
+
/**
|
|
17
|
+
* Guard against a pathological case: if the user's project genuinely lives
|
|
18
|
+
* under the scratch root, every path would look like a violation.
|
|
19
|
+
*/
|
|
20
|
+
export declare function scratchDetectionApplies(hostEnv: HostEnvironment): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Tool result returned in place of executing the call. Deterministic correction
|
|
23
|
+
* where the prompt guidance is only preventive — the model gets the topology
|
|
24
|
+
* again at the exact moment it acted on the wrong belief.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildScratchPathCorrection(hits: ScratchPathHit[], toolName: string, workspaceDir: string, hostEnv: HostEnvironment): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SDKCustomTool } from "@cursor/sdk";
|
|
2
|
+
import type { UnifiedChatRequest } from "../types/llm";
|
|
3
|
+
import type { CursorSdkSession } from "./session";
|
|
4
|
+
/**
|
|
5
|
+
* Per-request tally. Session metrics are cumulative and the SDK may invoke
|
|
6
|
+
* `execute` as soon as `agent.send` resolves — before the response stream is
|
|
7
|
+
* even constructed — so a start/end delta on the session counter silently
|
|
8
|
+
* misses the very first violation of a turn.
|
|
9
|
+
*/
|
|
10
|
+
export type TurnToolMetrics = {
|
|
11
|
+
scratchViolations: number;
|
|
12
|
+
scratchCorrections: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function createTurnToolMetrics(): TurnToolMetrics;
|
|
15
|
+
export declare function toCustomTools(request: UnifiedChatRequest, session: CursorSdkSession, logger?: any, turn?: TurnToolMetrics): Record<string, SDKCustomTool>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { UnifiedChatRequest, UnifiedMessage, UnifiedTool } from "../types/llm";
|
|
2
|
+
import type { UnifiedTurnIntent } from "../types/turn-intent";
|
|
3
|
+
import type { CursorSdkMode } from "./shared";
|
|
4
|
+
/**
|
|
5
|
+
* Fingerprint a logical model turn independently of streaming, request tracing,
|
|
6
|
+
* cache hints, object insertion order, and JSON argument formatting.
|
|
7
|
+
*/
|
|
8
|
+
export declare function fingerprintCursorTurn(request: UnifiedChatRequest, runtime?: {
|
|
9
|
+
compatibilityStamp?: string;
|
|
10
|
+
turnIntent?: UnifiedTurnIntent;
|
|
11
|
+
}): string;
|
|
12
|
+
export type CursorCompatibilityInput = {
|
|
13
|
+
model: unknown;
|
|
14
|
+
mode: CursorSdkMode;
|
|
15
|
+
workspaceDir: string;
|
|
16
|
+
guidanceFingerprint?: string;
|
|
17
|
+
sandboxEnabled?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* A one-way credential/account fingerprint supplied by the caller. Never pass
|
|
20
|
+
* a raw API key.
|
|
21
|
+
*/
|
|
22
|
+
credentialFingerprint?: string;
|
|
23
|
+
tools?: UnifiedTool[];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Fingerprint the properties that must remain compatible when an SDK agent is
|
|
27
|
+
* reused. The turn fingerprint separately covers prompt/tool semantics.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createCursorCompatibilityStamp(input: CursorCompatibilityInput): string;
|
|
30
|
+
export type CursorTranscriptCommit = Readonly<{
|
|
31
|
+
transcriptHash: string;
|
|
32
|
+
messageCount: number;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Commit the host-visible transcript after a successful assistant turn.
|
|
36
|
+
*
|
|
37
|
+
* The caller supplies the assistant message assembled from what was actually
|
|
38
|
+
* emitted to the host, rather than relying on Cursor's opaque checkpoint.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createCursorTranscriptCommit(request: UnifiedChatRequest, assistantMessage?: UnifiedMessage): CursorTranscriptCommit;
|
|
41
|
+
/**
|
|
42
|
+
* True only when the incoming transcript contains the exact committed prefix
|
|
43
|
+
* and at least one additional semantic message.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getStrictCursorTranscriptSuffix(commit: CursorTranscriptCommit, request: UnifiedChatRequest): readonly UnifiedMessage[] | undefined;
|
|
46
|
+
export declare function isStrictCursorTranscriptExtension(commit: CursorTranscriptCommit, request: UnifiedChatRequest): boolean;
|