pi-cursor-sdk 0.5.4 → 0.5.5

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 (61) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/README.md +4 -4
  3. package/dist/cursor-fallback-models.generated.js +161 -1
  4. package/dist/cursor-local-run-terminal-error.js +57 -0
  5. package/dist/cursor-provider-turn-finalize.js +2 -0
  6. package/dist/cursor-provider-turn-send.js +3 -0
  7. package/dist/cursor-session-store.js +2 -1
  8. package/docs/cursor-live-smoke-checklist.md +2 -2
  9. package/docs/cursor-model-ux-spec.md +4 -2
  10. package/docs/cursor-native-tool-visual-audit.md +1 -1
  11. package/docs/cursor-testing-lessons.md +7 -1
  12. package/docs/cursor-tool-surfaces.md +3 -3
  13. package/docs/development.md +15 -7
  14. package/docs/reference.md +9 -5
  15. package/node_modules/@modelcontextprotocol/core/node_modules/zod/package.json +1 -1
  16. package/node_modules/@modelcontextprotocol/core/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
  17. package/node_modules/@modelcontextprotocol/core/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
  18. package/node_modules/@modelcontextprotocol/core/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
  19. package/node_modules/@modelcontextprotocol/core/node_modules/zod/src/v4/core/compile.ts +9 -0
  20. package/node_modules/@modelcontextprotocol/core/node_modules/zod/src/v4/core/schemas.ts +35 -1
  21. package/node_modules/@modelcontextprotocol/core/node_modules/zod/src/v4/core/util.ts +13 -0
  22. package/node_modules/@modelcontextprotocol/core/node_modules/zod/src/v4/core/versions.ts +1 -1
  23. package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/compile.cjs +8 -0
  24. package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/compile.js +8 -0
  25. package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/schemas.cjs +30 -0
  26. package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/schemas.d.cts +3 -1
  27. package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/schemas.d.ts +3 -1
  28. package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/schemas.js +30 -0
  29. package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/util.cjs +15 -0
  30. package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/util.d.cts +2 -0
  31. package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/util.d.ts +2 -0
  32. package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/util.js +14 -0
  33. package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/versions.cjs +1 -1
  34. package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/versions.js +1 -1
  35. package/node_modules/@modelcontextprotocol/server/node_modules/zod/package.json +1 -1
  36. package/node_modules/@modelcontextprotocol/server/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
  37. package/node_modules/@modelcontextprotocol/server/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
  38. package/node_modules/@modelcontextprotocol/server/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
  39. package/node_modules/@modelcontextprotocol/server/node_modules/zod/src/v4/core/compile.ts +9 -0
  40. package/node_modules/@modelcontextprotocol/server/node_modules/zod/src/v4/core/schemas.ts +35 -1
  41. package/node_modules/@modelcontextprotocol/server/node_modules/zod/src/v4/core/util.ts +13 -0
  42. package/node_modules/@modelcontextprotocol/server/node_modules/zod/src/v4/core/versions.ts +1 -1
  43. package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/compile.cjs +8 -0
  44. package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/compile.js +8 -0
  45. package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/schemas.cjs +30 -0
  46. package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/schemas.d.cts +3 -1
  47. package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/schemas.d.ts +3 -1
  48. package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/schemas.js +30 -0
  49. package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/util.cjs +15 -0
  50. package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/util.d.cts +2 -0
  51. package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/util.d.ts +2 -0
  52. package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/util.js +14 -0
  53. package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/versions.cjs +1 -1
  54. package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/versions.js +1 -1
  55. package/package.json +9 -3
  56. package/scripts/steering-rpc-smoke.mjs +1 -1
  57. package/src/cursor-fallback-models.generated.ts +161 -1
  58. package/src/cursor-local-run-terminal-error.ts +58 -0
  59. package/src/cursor-provider-turn-finalize.ts +2 -0
  60. package/src/cursor-provider-turn-send.ts +2 -0
  61. package/src/cursor-session-store.ts +2 -1
@@ -1,6 +1,6 @@
1
1
  import type { ModelListItem } from "@cursor/sdk";
2
2
 
3
- // Generated with @cursor/sdk@1.0.37 from 48 Cursor models.
3
+ // Generated with @cursor/sdk@1.0.40 from 49 Cursor models.
4
4
  // Refresh with: npm run refresh:cursor-snapshots -- --write
5
5
  // Do not add secrets; this file stores public model metadata only.
6
6
  export const FALLBACK_MODEL_ITEMS = [
@@ -4796,6 +4796,10 @@ export const FALLBACK_MODEL_ITEMS = [
4796
4796
  variants: [
4797
4797
  {
4798
4798
  params: [
4799
+ {
4800
+ id: "cyber",
4801
+ value: "false"
4802
+ },
4799
4803
  {
4800
4804
  id: "context",
4801
4805
  value: "300k"
@@ -4813,6 +4817,10 @@ export const FALLBACK_MODEL_ITEMS = [
4813
4817
  },
4814
4818
  {
4815
4819
  params: [
4820
+ {
4821
+ id: "cyber",
4822
+ value: "false"
4823
+ },
4816
4824
  {
4817
4825
  id: "context",
4818
4826
  value: "300k"
@@ -4830,6 +4838,10 @@ export const FALLBACK_MODEL_ITEMS = [
4830
4838
  },
4831
4839
  {
4832
4840
  params: [
4841
+ {
4842
+ id: "cyber",
4843
+ value: "false"
4844
+ },
4833
4845
  {
4834
4846
  id: "context",
4835
4847
  value: "300k"
@@ -4847,6 +4859,10 @@ export const FALLBACK_MODEL_ITEMS = [
4847
4859
  },
4848
4860
  {
4849
4861
  params: [
4862
+ {
4863
+ id: "cyber",
4864
+ value: "false"
4865
+ },
4850
4866
  {
4851
4867
  id: "context",
4852
4868
  value: "300k"
@@ -4864,6 +4880,10 @@ export const FALLBACK_MODEL_ITEMS = [
4864
4880
  },
4865
4881
  {
4866
4882
  params: [
4883
+ {
4884
+ id: "cyber",
4885
+ value: "false"
4886
+ },
4867
4887
  {
4868
4888
  id: "context",
4869
4889
  value: "300k"
@@ -4881,6 +4901,10 @@ export const FALLBACK_MODEL_ITEMS = [
4881
4901
  },
4882
4902
  {
4883
4903
  params: [
4904
+ {
4905
+ id: "cyber",
4906
+ value: "false"
4907
+ },
4884
4908
  {
4885
4909
  id: "context",
4886
4910
  value: "300k"
@@ -4898,6 +4922,10 @@ export const FALLBACK_MODEL_ITEMS = [
4898
4922
  },
4899
4923
  {
4900
4924
  params: [
4925
+ {
4926
+ id: "cyber",
4927
+ value: "false"
4928
+ },
4901
4929
  {
4902
4930
  id: "context",
4903
4931
  value: "300k"
@@ -4915,6 +4943,10 @@ export const FALLBACK_MODEL_ITEMS = [
4915
4943
  },
4916
4944
  {
4917
4945
  params: [
4946
+ {
4947
+ id: "cyber",
4948
+ value: "false"
4949
+ },
4918
4950
  {
4919
4951
  id: "context",
4920
4952
  value: "300k"
@@ -4932,6 +4964,10 @@ export const FALLBACK_MODEL_ITEMS = [
4932
4964
  },
4933
4965
  {
4934
4966
  params: [
4967
+ {
4968
+ id: "cyber",
4969
+ value: "false"
4970
+ },
4935
4971
  {
4936
4972
  id: "context",
4937
4973
  value: "300k"
@@ -4949,6 +4985,10 @@ export const FALLBACK_MODEL_ITEMS = [
4949
4985
  },
4950
4986
  {
4951
4987
  params: [
4988
+ {
4989
+ id: "cyber",
4990
+ value: "false"
4991
+ },
4952
4992
  {
4953
4993
  id: "context",
4954
4994
  value: "300k"
@@ -4966,6 +5006,10 @@ export const FALLBACK_MODEL_ITEMS = [
4966
5006
  },
4967
5007
  {
4968
5008
  params: [
5009
+ {
5010
+ id: "cyber",
5011
+ value: "false"
5012
+ },
4969
5013
  {
4970
5014
  id: "context",
4971
5015
  value: "1m"
@@ -4983,6 +5027,10 @@ export const FALLBACK_MODEL_ITEMS = [
4983
5027
  },
4984
5028
  {
4985
5029
  params: [
5030
+ {
5031
+ id: "cyber",
5032
+ value: "false"
5033
+ },
4986
5034
  {
4987
5035
  id: "context",
4988
5036
  value: "1m"
@@ -5000,6 +5048,10 @@ export const FALLBACK_MODEL_ITEMS = [
5000
5048
  },
5001
5049
  {
5002
5050
  params: [
5051
+ {
5052
+ id: "cyber",
5053
+ value: "false"
5054
+ },
5003
5055
  {
5004
5056
  id: "context",
5005
5057
  value: "1m"
@@ -5018,6 +5070,10 @@ export const FALLBACK_MODEL_ITEMS = [
5018
5070
  },
5019
5071
  {
5020
5072
  params: [
5073
+ {
5074
+ id: "cyber",
5075
+ value: "false"
5076
+ },
5021
5077
  {
5022
5078
  id: "context",
5023
5079
  value: "1m"
@@ -5035,6 +5091,10 @@ export const FALLBACK_MODEL_ITEMS = [
5035
5091
  },
5036
5092
  {
5037
5093
  params: [
5094
+ {
5095
+ id: "cyber",
5096
+ value: "false"
5097
+ },
5038
5098
  {
5039
5099
  id: "context",
5040
5100
  value: "1m"
@@ -5052,6 +5112,10 @@ export const FALLBACK_MODEL_ITEMS = [
5052
5112
  },
5053
5113
  {
5054
5114
  params: [
5115
+ {
5116
+ id: "cyber",
5117
+ value: "false"
5118
+ },
5055
5119
  {
5056
5120
  id: "context",
5057
5121
  value: "1m"
@@ -5069,6 +5133,10 @@ export const FALLBACK_MODEL_ITEMS = [
5069
5133
  },
5070
5134
  {
5071
5135
  params: [
5136
+ {
5137
+ id: "cyber",
5138
+ value: "false"
5139
+ },
5072
5140
  {
5073
5141
  id: "context",
5074
5142
  value: "1m"
@@ -5086,6 +5154,10 @@ export const FALLBACK_MODEL_ITEMS = [
5086
5154
  },
5087
5155
  {
5088
5156
  params: [
5157
+ {
5158
+ id: "cyber",
5159
+ value: "false"
5160
+ },
5089
5161
  {
5090
5162
  id: "context",
5091
5163
  value: "1m"
@@ -5103,6 +5175,10 @@ export const FALLBACK_MODEL_ITEMS = [
5103
5175
  },
5104
5176
  {
5105
5177
  params: [
5178
+ {
5179
+ id: "cyber",
5180
+ value: "false"
5181
+ },
5106
5182
  {
5107
5183
  id: "context",
5108
5184
  value: "1m"
@@ -5120,6 +5196,10 @@ export const FALLBACK_MODEL_ITEMS = [
5120
5196
  },
5121
5197
  {
5122
5198
  params: [
5199
+ {
5200
+ id: "cyber",
5201
+ value: "false"
5202
+ },
5123
5203
  {
5124
5204
  id: "context",
5125
5205
  value: "1m"
@@ -6264,6 +6344,86 @@ export const FALLBACK_MODEL_ITEMS = [
6264
6344
  }
6265
6345
  ]
6266
6346
  },
6347
+ {
6348
+ id: "deepseek-v41-flash-1017",
6349
+ displayName: "DeepSeek V4.1 Flash 1017",
6350
+ parameters: [
6351
+ {
6352
+ id: "reasoning_effort",
6353
+ displayName: "Reasoning",
6354
+ values: [
6355
+ {
6356
+ value: "none",
6357
+ displayName: "None"
6358
+ },
6359
+ {
6360
+ value: "low",
6361
+ displayName: "Low"
6362
+ },
6363
+ {
6364
+ value: "medium",
6365
+ displayName: "Medium"
6366
+ },
6367
+ {
6368
+ value: "high",
6369
+ displayName: "High"
6370
+ },
6371
+ {
6372
+ value: "max",
6373
+ displayName: "Max"
6374
+ }
6375
+ ]
6376
+ }
6377
+ ],
6378
+ variants: [
6379
+ {
6380
+ params: [
6381
+ {
6382
+ id: "reasoning_effort",
6383
+ value: "none"
6384
+ }
6385
+ ],
6386
+ displayName: "DeepSeek V4.1 Flash 1017 None"
6387
+ },
6388
+ {
6389
+ params: [
6390
+ {
6391
+ id: "reasoning_effort",
6392
+ value: "low"
6393
+ }
6394
+ ],
6395
+ displayName: "DeepSeek V4.1 Flash 1017 Low"
6396
+ },
6397
+ {
6398
+ params: [
6399
+ {
6400
+ id: "reasoning_effort",
6401
+ value: "medium"
6402
+ }
6403
+ ],
6404
+ displayName: "DeepSeek V4.1 Flash 1017 Medium"
6405
+ },
6406
+ {
6407
+ params: [
6408
+ {
6409
+ id: "reasoning_effort",
6410
+ value: "high"
6411
+ }
6412
+ ],
6413
+ displayName: "DeepSeek V4.1 Flash 1017 High"
6414
+ },
6415
+ {
6416
+ params: [
6417
+ {
6418
+ id: "reasoning_effort",
6419
+ value: "max"
6420
+ }
6421
+ ],
6422
+ displayName: "DeepSeek V4.1 Flash 1017 Max",
6423
+ isDefault: true
6424
+ }
6425
+ ]
6426
+ },
6267
6427
  {
6268
6428
  id: "default",
6269
6429
  displayName: "Auto",
@@ -0,0 +1,58 @@
1
+ import type { LocalAgentRunDocument, LocalAgentStore, Run, RunError, RunResult } from "@cursor/sdk";
2
+
3
+ const watchedRunsByStore = new WeakMap<LocalAgentStore, Map<string, Run>>();
4
+ const terminalErrors = new WeakMap<Run, RunError>();
5
+ const TERMINAL_RUN_STATUSES = new Set<LocalAgentRunDocument["status"]>(["finished", "error", "cancelled", "expired"]);
6
+
7
+ // A failed local SDK run leaves its native tool processes running, and Run.cancel() stops them only
8
+ // while run.status is "running". The SDK awaits the terminal run-row write before it changes
9
+ // run.status, so cancelling from that write is ordered before the change, not racing it.
10
+ function onRunRowWrite(watched: Map<string, Run>, row: LocalAgentRunDocument): void {
11
+ const run = watched.get(row.runId);
12
+ if (!run || !TERMINAL_RUN_STATUSES.has(row.status)) return;
13
+ watched.delete(row.runId);
14
+ if (row.status !== "error" || run.status !== "running") return;
15
+ terminalErrors.set(run, { message: row.error?.trim() || "Cursor SDK run failed." });
16
+ run.cancel().catch(() => {});
17
+ }
18
+
19
+ /** Wraps a local store so watched runs are cancelled while still running when the SDK records a terminal error. */
20
+ export function observeCursorLocalRunTerminalErrors(store: LocalAgentStore): LocalAgentStore {
21
+ const watched = new Map<string, Run>();
22
+ const { runs } = store;
23
+ const observed: LocalAgentStore = {
24
+ agents: store.agents,
25
+ checkpoints: store.checkpoints,
26
+ runEvents: store.runEvents,
27
+ runs: {
28
+ get: (input) => runs.get(input),
29
+ create: (input) => runs.create(input),
30
+ delete: (input) => runs.delete(input),
31
+ list: (input) => runs.list(input),
32
+ update: async (input) => {
33
+ try {
34
+ return await runs.update(input);
35
+ } finally {
36
+ onRunRowWrite(watched, input.run);
37
+ }
38
+ },
39
+ },
40
+ };
41
+ watchedRunsByStore.set(observed, watched);
42
+ return observed;
43
+ }
44
+
45
+ /**
46
+ * Call as soon as send() resolves. A run can only fail with native tools running after network
47
+ * input, which cannot be processed before this continuation.
48
+ */
49
+ export function watchCursorLocalRunTerminalError(store: LocalAgentStore, run: Run): void {
50
+ if (run.status === "running") watchedRunsByStore.get(store)?.set(run.id, run);
51
+ }
52
+
53
+ /** Restores the SDK failure that terminal-error cancellation turned into a "cancelled" wait result. */
54
+ export function resolveCursorLocalRunTerminalError(run: Run, waitResult: RunResult, callerAborted: boolean): RunResult {
55
+ const terminalError = terminalErrors.get(run);
56
+ if (!terminalError || callerAborted || waitResult.status !== "cancelled") return waitResult;
57
+ return { ...waitResult, status: "error", error: terminalError };
58
+ }
@@ -16,6 +16,7 @@ import {
16
16
  } from "./cursor-provider-run-outcome.js";
17
17
  import type { StartedCursorProviderTurn } from "./cursor-provider-turn-types.js";
18
18
  import { loadCursorSdk } from "./cursor-sdk-runtime.js";
19
+ import { resolveCursorLocalRunTerminalError } from "./cursor-local-run-terminal-error.js";
19
20
 
20
21
  export async function cacheSdkContextWindow(
21
22
  agentId: string,
@@ -157,6 +158,7 @@ export async function awaitFinalizeCursorRunOutcome(params: AwaitFinalizeCursorR
157
158
  let waitResult: Awaited<ReturnType<typeof params.run.wait>>;
158
159
  try {
159
160
  waitResult = params.waitResult ?? (await params.run.wait());
161
+ waitResult = resolveCursorLocalRunTerminalError(params.run, waitResult, params.signal?.aborted === true);
160
162
  } catch (error) {
161
163
  await recordCursorProviderTerminalUsage(params.prepared, params.signal?.aborted ? "abort" : "error");
162
164
  throw error;
@@ -4,6 +4,7 @@ import { createCursorCloudLifecyclePersistenceError } from "./cursor-cloud-lifec
4
4
  import { cursorLiveRuns } from "./cursor-provider-live-run-drain.js";
5
5
  import { consumeCursorLocalForceOverride } from "./cursor-runtime-state.js";
6
6
  import { recordCursorSessionAgentLineage } from "./cursor-session-agent-lineage.js";
7
+ import { watchCursorLocalRunTerminalError } from "./cursor-local-run-terminal-error.js";
7
8
  import type { installCursorSdkProcessErrorGuard } from "./cursor-sdk-process-error-guard.js";
8
9
  import type {
9
10
  CursorProviderTurnRunnerParams,
@@ -123,6 +124,7 @@ export async function sendCursorProviderTurn(sendParams: SendCursorProviderTurnP
123
124
  recordCursorSessionAgentLineage(agent.agentId, params.scope.scopeKey);
124
125
  }
125
126
  const run = await runPromise;
127
+ if (prepared.runtimeTarget === "local") watchCursorLocalRunTerminalError(prepared.store, run);
126
128
  sdkRun = run;
127
129
  runtime.sdkRun = run;
128
130
  try {
@@ -6,6 +6,7 @@ import { dirname, isAbsolute, join, relative, resolve, sep, toNamespacedPath } f
6
6
  import type { LocalAgentStore } from "@cursor/sdk";
7
7
  import { loadCursorSdk } from "./cursor-sdk-runtime.js";
8
8
  import { guardCursorCustomStorePath, normalizeCursorCustomStoreRoot, prepareCursorCustomStoreRoot } from "./cursor-custom-store-path.js";
9
+ import { observeCursorLocalRunTerminalErrors } from "./cursor-local-run-terminal-error.js";
9
10
 
10
11
  export interface CursorSessionStoreIdentity {
11
12
  readonly version: 1;
@@ -299,7 +300,7 @@ async function openOwnedCursorSessionStore(
299
300
  const openedStore = store;
300
301
  return {
301
302
  identity: openedIdentity,
302
- store: openedStore,
303
+ store: observeCursorLocalRunTerminalErrors(openedStore),
303
304
  dispose: async () => {
304
305
  try {
305
306
  await openedStore.dispose();