pi-cursor-sdk 0.5.3 → 0.5.4
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/CHANGELOG.md +40 -1
- package/README.md +62 -816
- package/dist/context.js +11 -5
- package/dist/cursor-agents-context.js +6 -6
- package/dist/cursor-api-key.js +1 -1
- package/dist/cursor-bridge-contract.js +1 -13
- package/dist/cursor-cloud-local-state.js +0 -1
- package/dist/cursor-config.js +1 -17
- package/dist/cursor-fallback-models.generated.js +264 -1
- package/dist/cursor-live-run-coordinator.js +1 -0
- package/dist/cursor-mcp-timeout-override.js +6 -17
- package/dist/cursor-native-tool-display-replay.js +5 -5
- package/dist/cursor-native-tools.js +11 -0
- package/dist/cursor-pi-tool-bridge-env.js +25 -2
- package/dist/cursor-pi-tool-bridge-server.js +98 -48
- package/dist/cursor-pi-tool-bridge-snapshot.js +1 -1
- package/dist/cursor-pi-tool-bridge.js +4 -12
- package/dist/cursor-provider-errors.js +0 -6
- package/dist/cursor-provider-live-run-drain.js +8 -3
- package/dist/cursor-provider-overflow.js +7 -21
- package/dist/cursor-provider-turn-prepare.js +8 -1
- package/dist/cursor-provider-turn-runner.js +17 -6
- package/dist/cursor-provider.js +1 -4
- package/dist/cursor-runtime-state.js +3 -3
- package/dist/cursor-sdk-event-debug.js +2 -2
- package/dist/cursor-sdk-output-filter.js +1 -1
- package/dist/cursor-sdk-process-error-guard.js +1 -2
- package/dist/cursor-session-agent.js +6 -8
- package/dist/cursor-session-scope.js +1 -7
- package/dist/cursor-session-store.js +1 -1
- package/dist/cursor-state.js +9 -23
- package/dist/cursor-tool-lifecycle.js +0 -3
- package/dist/cursor-tool-manifest.js +3 -1
- package/dist/cursor-tool-presentation-registry.js +2 -4
- package/dist/cursor-tool-visibility.js +0 -3
- package/dist/cursor-transcript-tool-specs.js +1 -2
- package/dist/index.js +21 -0
- package/dist/model-discovery.js +0 -1
- package/dist/model-list-cache.js +4 -9
- package/docs/cursor-live-smoke-checklist.md +3 -3
- package/docs/cursor-model-ux-spec.md +16 -8
- package/docs/cursor-native-tool-replay.md +2 -2
- package/docs/cursor-native-tool-visual-audit.md +1 -1
- package/docs/cursor-testing-lessons.md +15 -3
- package/docs/cursor-tool-surfaces.md +32 -3
- package/docs/development.md +93 -0
- package/docs/platform-smoke-implementation.md +3 -2
- package/docs/reference.md +806 -0
- package/package.json +6 -4
- package/scripts/platform-smoke/artifact-secrets.mjs +13 -4
- package/scripts/platform-smoke/local-resume-runner.mjs +0 -1
- package/scripts/platform-smoke/target-runtime.mjs +4 -2
- package/scripts/platform-smoke/targets.mjs +0 -1
- package/shared/cursor-sdk-output-filter.d.mts +2 -0
- package/shared/cursor-sdk-output-filter.mjs +92 -28
- package/shared/cursor-sensitive-text.d.mts +1 -0
- package/shared/cursor-sensitive-text.mjs +7 -0
- package/src/context.ts +16 -9
- package/src/cursor-agents-context.ts +6 -6
- package/src/cursor-api-key.ts +1 -1
- package/src/cursor-bridge-contract.ts +1 -15
- package/src/cursor-cloud-local-state.ts +0 -2
- package/src/cursor-config.ts +1 -24
- package/src/cursor-fallback-models.generated.ts +264 -1
- package/src/cursor-live-run-coordinator.ts +5 -0
- package/src/cursor-mcp-timeout-override.ts +6 -30
- package/src/cursor-native-tool-display-replay.ts +4 -6
- package/src/cursor-native-tools.ts +14 -0
- package/src/cursor-pi-tool-bridge-env.ts +31 -2
- package/src/cursor-pi-tool-bridge-server.ts +89 -45
- package/src/cursor-pi-tool-bridge-snapshot.ts +0 -1
- package/src/cursor-pi-tool-bridge.ts +2 -18
- package/src/cursor-provider-errors.ts +0 -8
- package/src/cursor-provider-live-run-drain.ts +8 -2
- package/src/cursor-provider-overflow.ts +6 -24
- package/src/cursor-provider-turn-prepare.ts +10 -1
- package/src/cursor-provider-turn-runner.ts +17 -6
- package/src/cursor-provider.ts +0 -5
- package/src/cursor-runtime-state.ts +3 -3
- package/src/cursor-sdk-event-debug.ts +2 -2
- package/src/cursor-sdk-output-filter.ts +2 -1
- package/src/cursor-sdk-process-error-guard.ts +1 -3
- package/src/cursor-session-agent.ts +8 -8
- package/src/cursor-session-scope.ts +1 -9
- package/src/cursor-session-store.ts +1 -1
- package/src/cursor-state.ts +9 -36
- package/src/cursor-tool-lifecycle.ts +0 -4
- package/src/cursor-tool-manifest.ts +4 -1
- package/src/cursor-tool-presentation-registry.ts +3 -5
- package/src/cursor-tool-visibility.ts +0 -4
- package/src/cursor-transcript-tool-specs.ts +0 -3
- package/src/index.ts +18 -0
- package/src/model-discovery.ts +0 -1
- package/src/model-list-cache.ts +4 -10
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
buildWebSearchReplaySummaryArgs,
|
|
41
41
|
type CursorReplayActivityBuildContext,
|
|
42
42
|
} from "./cursor-replay-activity-builders.js";
|
|
43
|
-
import {
|
|
43
|
+
import type { CursorReplaySourceToolName } from "./cursor-replay-source-names.js";
|
|
44
44
|
import type {
|
|
45
45
|
CursorReplayActivityDetailFields,
|
|
46
46
|
CursorReplayGenerateImageDetailFields,
|
|
@@ -112,7 +112,7 @@ const WEB_SEARCH_NAME_PATTERN =
|
|
|
112
112
|
const WEB_FETCH_NAME_PATTERN =
|
|
113
113
|
/^(?:web[-_ ]?fetch|fetch[-_ ]?web|webfetch|browser[-_ ]?fetch|fetch[-_ ]?url)$/i;
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
const CURSOR_TOOL_PRESENTATION_SPECS = [
|
|
116
116
|
{
|
|
117
117
|
normalizedName: "read",
|
|
118
118
|
nameAliases: ["read_file"],
|
|
@@ -345,9 +345,7 @@ const WEB_KIND_BY_PATTERN = CURSOR_TOOL_PRESENTATION_SPECS.flatMap((spec) => {
|
|
|
345
345
|
return webNamePatterns.map((pattern) => ({ pattern, webKind }));
|
|
346
346
|
});
|
|
347
347
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
export function getCursorToolPresentationSpec(
|
|
348
|
+
function getCursorToolPresentationSpec(
|
|
351
349
|
name: string,
|
|
352
350
|
): CursorToolPresentationSpec | undefined {
|
|
353
351
|
const trimmed = name.trim();
|
|
@@ -41,7 +41,3 @@ export function classifyCursorToolVisibility(toolCall: unknown): CursorToolVisib
|
|
|
41
41
|
fastLocalDiscovery: config?.fastLocalDiscovery ?? false,
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
export function isFastLocalDiscoveryTool(toolCall: unknown): boolean {
|
|
46
|
-
return classifyCursorToolVisibility(toolCall).fastLocalDiscovery;
|
|
47
|
-
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
CURSOR_KNOWN_NORMALIZED_TOOL_NAMES,
|
|
3
2
|
CURSOR_REPLAY_ACTIVITY_TOOL_NAME,
|
|
4
3
|
getCursorReplayCallSummary,
|
|
5
4
|
getCursorToolActivityTitle,
|
|
@@ -417,8 +416,6 @@ const TOOL_DISPLAY_IMPLEMENTATIONS: Record<CursorNormalizedToolName, ToolDisplay
|
|
|
417
416
|
},
|
|
418
417
|
};
|
|
419
418
|
|
|
420
|
-
export const CURSOR_TOOL_DISPLAY_SPEC_KEYS = CURSOR_KNOWN_NORMALIZED_TOOL_NAMES;
|
|
421
|
-
|
|
422
419
|
function getToolDisplaySpec(name: string): ToolDisplaySpec | undefined {
|
|
423
420
|
if (Object.hasOwn(TOOL_DISPLAY_IMPLEMENTATIONS, name)) return TOOL_DISPLAY_IMPLEMENTATIONS[name as CursorNormalizedToolName];
|
|
424
421
|
return undefined;
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,8 @@ import { registerCursorFallbackIssueWarning } from "./cursor-fallback-warning.js
|
|
|
15
15
|
import { registerCursorAgentsContextDedup } from "./cursor-agents-context-registration.js";
|
|
16
16
|
import { registerCursorOverflowNormalization } from "./cursor-provider-overflow.js";
|
|
17
17
|
import { registerCursorSdkSessionProcessErrorGuard } from "./cursor-sdk-process-error-guard.js";
|
|
18
|
+
import { installCursorSdkProcessOutputFilter } from "./cursor-sdk-output-filter.js";
|
|
19
|
+
import { cursorLiveRuns } from "./cursor-provider-live-run-drain.js";
|
|
18
20
|
import { prepareCursorSessionForCompaction } from "./cursor-session-compaction-prep.js";
|
|
19
21
|
import { registerCursorUsageLedger } from "./cursor-usage-ledger.js";
|
|
20
22
|
import { registerCursorUsageCommand } from "./cursor-usage-command.js";
|
|
@@ -37,10 +39,26 @@ type CursorExtensionApi =
|
|
|
37
39
|
& Parameters<typeof registerCursorUsageLedger>[0];
|
|
38
40
|
|
|
39
41
|
export default async function (pi: CursorExtensionApi) {
|
|
42
|
+
installCursorSdkProcessOutputFilter();
|
|
40
43
|
// Session cwd must register before other session_start listeners that depend on it.
|
|
41
44
|
registerCursorSessionScope(pi);
|
|
42
45
|
registerCursorUsageLedger(pi);
|
|
43
46
|
registerCursorUsageCommand(pi);
|
|
47
|
+
pi.registerCommand("cursor-abort", {
|
|
48
|
+
description: "Abort this session's pending local Cursor run without undoing completed work",
|
|
49
|
+
handler: async (_args, ctx) => {
|
|
50
|
+
const run = cursorLiveRuns.getActiveForScope(getCursorSessionScopeSnapshot(pi).scopeKey);
|
|
51
|
+
if (run && !run.disposed) {
|
|
52
|
+
if (!ctx.isIdle() && ctx.model?.provider === "cursor") ctx.abort();
|
|
53
|
+
await cursorLiveRuns.release(run);
|
|
54
|
+
}
|
|
55
|
+
const message = run
|
|
56
|
+
? "Pending local Cursor run released. Retry under the current policy; already-executed work was not undone."
|
|
57
|
+
: "No pending local Cursor run in this session.";
|
|
58
|
+
if (ctx.hasUI) ctx.ui.notify(message, "info");
|
|
59
|
+
else process.stderr.write(`${message}\n`);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
44
62
|
let fallbackIssue: CursorModelFallbackIssue | undefined;
|
|
45
63
|
const registerCursorProvider = registerCursorProviderBinding(pi);
|
|
46
64
|
const setFallbackWarning = registerCursorFallbackIssueWarning(pi);
|
package/src/model-discovery.ts
CHANGED
package/src/model-list-cache.ts
CHANGED
|
@@ -29,11 +29,11 @@ function getCachePath(): string {
|
|
|
29
29
|
return join(getAgentDir(), MODEL_LIST_CACHE_FILE);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
function isModelCacheDisabled(): boolean {
|
|
33
33
|
return parseEnvBoolean(process.env[DISABLE_ENV_VAR], false);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
function getModelCacheTtlMs(): number {
|
|
37
37
|
const raw = process.env[TTL_ENV_VAR];
|
|
38
38
|
if (raw === undefined) return DEFAULT_TTL_MS;
|
|
39
39
|
const parsed = Number.parseInt(raw, 10);
|
|
@@ -133,7 +133,8 @@ function readCacheFile(): ModelListCacheFile | undefined {
|
|
|
133
133
|
|
|
134
134
|
// Return cached models only when caching is enabled, the key matches, and the
|
|
135
135
|
// entry is within the TTL. Used on the hot startup path to skip the network.
|
|
136
|
-
export function loadFreshCachedModels(keyFingerprint: string
|
|
136
|
+
export function loadFreshCachedModels(keyFingerprint: string): ModelListItem[] | undefined {
|
|
137
|
+
const now = Date.now();
|
|
137
138
|
if (isModelCacheDisabled()) return undefined;
|
|
138
139
|
const ttlMs = getModelCacheTtlMs();
|
|
139
140
|
if (ttlMs <= 0) return undefined;
|
|
@@ -180,10 +181,3 @@ export function clearModelListCache(): void {
|
|
|
180
181
|
// Cache cleanup is best-effort; it must not break native logout.
|
|
181
182
|
}
|
|
182
183
|
}
|
|
183
|
-
|
|
184
|
-
export const __testUtils = {
|
|
185
|
-
getCachePath,
|
|
186
|
-
DEFAULT_TTL_MS,
|
|
187
|
-
DISABLE_ENV_VAR,
|
|
188
|
-
TTL_ENV_VAR,
|
|
189
|
-
};
|