pi-cursor-sdk 0.1.62 → 0.2.0

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 (128) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +5 -5
  3. package/docs/cursor-live-smoke-checklist.md +4 -4
  4. package/docs/cursor-model-ux-spec.md +5 -3
  5. package/docs/cursor-native-tool-visual-audit.md +1 -1
  6. package/docs/cursor-testing-lessons.md +1 -1
  7. package/docs/platform-smoke.md +3 -3
  8. package/node_modules/fast-uri/index.js +37 -1
  9. package/node_modules/fast-uri/package.json +1 -1
  10. package/node_modules/fast-uri/test/security.test.js +136 -0
  11. package/node_modules/hono/dist/cjs/context.js +28 -13
  12. package/node_modules/hono/dist/cjs/helper/proxy/index.js +4 -0
  13. package/node_modules/hono/dist/cjs/helper/streaming/sse.js +1 -1
  14. package/node_modules/hono/dist/cjs/hono-base.js +3 -2
  15. package/node_modules/hono/dist/cjs/jsx/base.js +27 -23
  16. package/node_modules/hono/dist/cjs/jsx/hooks/index.js +16 -13
  17. package/node_modules/hono/dist/cjs/middleware/cache/index.js +103 -8
  18. package/node_modules/hono/dist/cjs/middleware/compress/index.js +5 -0
  19. package/node_modules/hono/dist/cjs/middleware/cors/index.js +2 -2
  20. package/node_modules/hono/dist/cjs/middleware/etag/index.js +1 -1
  21. package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +9 -4
  22. package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +9 -4
  23. package/node_modules/hono/dist/cjs/middleware/language/language.js +10 -6
  24. package/node_modules/hono/dist/cjs/middleware/method-not-allowed/index.js +90 -0
  25. package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +10 -4
  26. package/node_modules/hono/dist/cjs/request.js +7 -9
  27. package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +55 -56
  28. package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +64 -85
  29. package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +13 -5
  30. package/node_modules/hono/dist/cjs/router.js +1 -1
  31. package/node_modules/hono/dist/cjs/utils/accept.js +1 -1
  32. package/node_modules/hono/dist/cjs/utils/cookie.js +3 -2
  33. package/node_modules/hono/dist/cjs/utils/url.js +8 -8
  34. package/node_modules/hono/dist/context.js +28 -13
  35. package/node_modules/hono/dist/helper/proxy/index.js +4 -0
  36. package/node_modules/hono/dist/helper/streaming/sse.js +1 -1
  37. package/node_modules/hono/dist/hono-base.js +3 -2
  38. package/node_modules/hono/dist/jsx/base.js +27 -23
  39. package/node_modules/hono/dist/jsx/hooks/index.js +16 -13
  40. package/node_modules/hono/dist/middleware/cache/index.js +103 -8
  41. package/node_modules/hono/dist/middleware/compress/index.js +5 -0
  42. package/node_modules/hono/dist/middleware/cors/index.js +2 -2
  43. package/node_modules/hono/dist/middleware/etag/index.js +1 -1
  44. package/node_modules/hono/dist/middleware/jwk/jwk.js +9 -4
  45. package/node_modules/hono/dist/middleware/jwt/jwt.js +9 -4
  46. package/node_modules/hono/dist/middleware/language/language.js +10 -6
  47. package/node_modules/hono/dist/middleware/method-not-allowed/index.js +68 -0
  48. package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +10 -4
  49. package/node_modules/hono/dist/request.js +8 -10
  50. package/node_modules/hono/dist/router/reg-exp-router/node.js +55 -56
  51. package/node_modules/hono/dist/router/reg-exp-router/router.js +64 -85
  52. package/node_modules/hono/dist/router/reg-exp-router/trie.js +13 -5
  53. package/node_modules/hono/dist/router.js +1 -1
  54. package/node_modules/hono/dist/types/adapter/aws-lambda/types.d.ts +9 -0
  55. package/node_modules/hono/dist/types/client/types.d.ts +1 -1
  56. package/node_modules/hono/dist/types/hono-base.d.ts +4 -3
  57. package/node_modules/hono/dist/types/jsx/base.d.ts +4 -2
  58. package/node_modules/hono/dist/types/jsx/dom/index.d.ts +5 -5
  59. package/node_modules/hono/dist/types/jsx/dom/intrinsic-element/components.d.ts +2 -2
  60. package/node_modules/hono/dist/types/jsx/dom/server.d.ts +5 -5
  61. package/node_modules/hono/dist/types/jsx/hooks/index.d.ts +8 -6
  62. package/node_modules/hono/dist/types/jsx/index.d.ts +5 -5
  63. package/node_modules/hono/dist/types/middleware/cache/index.d.ts +6 -4
  64. package/node_modules/hono/dist/types/middleware/cors/index.d.ts +1 -1
  65. package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +2 -2
  66. package/node_modules/hono/dist/types/middleware/jwk/jwk.d.ts +2 -0
  67. package/node_modules/hono/dist/types/middleware/jwt/jwt.d.ts +2 -0
  68. package/node_modules/hono/dist/types/middleware/method-not-allowed/index.d.ts +49 -0
  69. package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +1 -1
  70. package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +2 -1
  71. package/node_modules/hono/dist/types/router.d.ts +1 -1
  72. package/node_modules/hono/dist/types/utils/headers.d.ts +2 -2
  73. package/node_modules/hono/dist/types/utils/url.d.ts +1 -0
  74. package/node_modules/hono/dist/utils/accept.js +1 -1
  75. package/node_modules/hono/dist/utils/cookie.js +4 -3
  76. package/node_modules/hono/dist/utils/url.js +6 -7
  77. package/node_modules/hono/package.json +10 -3
  78. package/node_modules/ip-address/README.md +146 -126
  79. package/node_modules/ip-address/dist/common.d.ts +29 -0
  80. package/node_modules/ip-address/dist/common.js +44 -5
  81. package/node_modules/ip-address/dist/common.js.map +1 -1
  82. package/node_modules/ip-address/dist/ipv4.d.ts +8 -1
  83. package/node_modules/ip-address/dist/ipv4.js +24 -20
  84. package/node_modules/ip-address/dist/ipv4.js.map +1 -1
  85. package/node_modules/ip-address/dist/ipv6.d.ts +68 -3
  86. package/node_modules/ip-address/dist/ipv6.js +180 -53
  87. package/node_modules/ip-address/dist/ipv6.js.map +1 -1
  88. package/node_modules/ip-address/dist/v4/constants.js +5 -1
  89. package/node_modules/ip-address/dist/v4/constants.js.map +1 -1
  90. package/node_modules/ip-address/dist/v6/constants.js +3 -2
  91. package/node_modules/ip-address/dist/v6/constants.js.map +1 -1
  92. package/node_modules/ip-address/package.json +6 -4
  93. package/package.json +5 -5
  94. package/scripts/platform-smoke/live-suite-runner.mjs +15 -39
  95. package/scripts/platform-smoke/platform-build-windows.ps1 +1 -1
  96. package/scripts/platform-smoke/scenarios.mjs +1 -1
  97. package/scripts/platform-smoke.mjs +5 -5
  98. package/scripts/refresh-cursor-model-snapshots.mjs +16 -7
  99. package/shared/cursor-model-selection-identities.d.mts +21 -0
  100. package/shared/cursor-model-selection-identities.mjs +95 -0
  101. package/src/bundled-context-windows.ts +18 -12
  102. package/src/context.ts +1 -1
  103. package/src/cursor-context-tools.ts +1 -1
  104. package/src/cursor-display-only-trace.ts +1 -1
  105. package/src/cursor-fallback-models.generated.ts +875 -361
  106. package/src/cursor-live-run-accounting.ts +1 -1
  107. package/src/cursor-live-run-coordinator.ts +1 -1
  108. package/src/cursor-native-replay-routing.ts +1 -1
  109. package/src/cursor-partial-content-emitter.ts +1 -1
  110. package/src/cursor-pi-tool-bridge-mcp.ts +1 -1
  111. package/src/cursor-pi-tool-bridge-run.ts +1 -1
  112. package/src/cursor-pi-tool-bridge-types.ts +1 -1
  113. package/src/cursor-provider-lazy.ts +1 -1
  114. package/src/cursor-provider-live-run-drain.ts +1 -1
  115. package/src/cursor-provider-overflow.ts +1 -1
  116. package/src/cursor-provider-run-finalizer.ts +1 -1
  117. package/src/cursor-provider-turn-coordinator.ts +1 -1
  118. package/src/cursor-provider-turn-lifecycle-emitter.ts +1 -1
  119. package/src/cursor-provider-turn-prepare.ts +1 -1
  120. package/src/cursor-provider-turn-types.ts +1 -1
  121. package/src/cursor-provider.ts +1 -1
  122. package/src/cursor-run-final-text.ts +1 -1
  123. package/src/cursor-sdk-event-debug.ts +1 -1
  124. package/src/cursor-session-agent.ts +1 -1
  125. package/src/cursor-session-send-policy.ts +1 -1
  126. package/src/cursor-usage-accounting.ts +1 -1
  127. package/src/model-discovery.ts +32 -89
  128. package/node_modules/cross-spawn/node_modules/which/CHANGELOG.md +0 -166
@@ -1,4 +1,4 @@
1
- import type { Context, Message, ToolResultMessage } from "@earendil-works/pi-ai/compat";
1
+ import type { Context, Message, ToolResultMessage } from "@earendil-works/pi-ai";
2
2
  import { CURSOR_APPROX_CHARS_PER_TOKEN, estimateCursorPromptMessageTokens } from "./context.js";
3
3
  import type { CursorSdkTurnUsage } from "./cursor-usage-accounting.js";
4
4
 
@@ -1,4 +1,4 @@
1
- import type { Context, ToolResultMessage } from "@earendil-works/pi-ai/compat";
1
+ import type { Context, ToolResultMessage } from "@earendil-works/pi-ai";
2
2
  import type { SDKAgent } from "@cursor/sdk";
3
3
  import {
4
4
  consumeCursorLiveToolResults,
@@ -1,6 +1,6 @@
1
1
  import { canRenderCursorToolNatively } from "./cursor-native-tool-display-state.js";
2
2
  import { getActiveContextToolNames } from "./cursor-context-tools.js";
3
- import type { Context } from "@earendil-works/pi-ai/compat";
3
+ import type { Context } from "@earendil-works/pi-ai";
4
4
 
5
5
  export type NativeReplayDisposition = "queue_replay" | "inactive_trace" | "transcript_trace";
6
6
 
@@ -1,4 +1,4 @@
1
- import type { AssistantMessage, AssistantMessageEventStream } from "@earendil-works/pi-ai/compat";
1
+ import type { AssistantMessage, AssistantMessageEventStream } from "@earendil-works/pi-ai";
2
2
 
3
3
  const DEFAULT_THINKING_TRACE_MAX_CHARS = 50000;
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
- import type { Context, ToolResultMessage } from "@earendil-works/pi-ai/compat";
2
+ import type { Context, ToolResultMessage } from "@earendil-works/pi-ai";
3
3
  import type { CallToolResult, Tool } from "@modelcontextprotocol/sdk/types.js";
4
4
  import { buildCursorPiBridgeMcpToolDescription, CURSOR_PI_BRIDGE_MCP_TOOL_PREFIX } from "./cursor-bridge-contract.js";
5
5
  import type { CursorPiBridgeToolDefinition, CursorPiMcpInputSchema } from "./cursor-pi-tool-bridge-types.js";
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import type { IncomingMessage, ServerResponse } from "node:http";
3
3
  import type { McpServerConfig } from "@cursor/sdk";
4
- import type { Context, ToolResultMessage } from "@earendil-works/pi-ai/compat";
4
+ import type { Context, ToolResultMessage } from "@earendil-works/pi-ai";
5
5
  import { Server as McpProtocolServer } from "@modelcontextprotocol/sdk/server/index.js";
6
6
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
7
7
  import {
@@ -1,5 +1,5 @@
1
1
  import type { McpServerConfig } from "@cursor/sdk";
2
- import type { Context, ToolResultMessage } from "@earendil-works/pi-ai/compat";
2
+ import type { Context, ToolResultMessage } from "@earendil-works/pi-ai";
3
3
  import type { CursorSdkEventDebugRecorder } from "./cursor-sdk-event-debug.js";
4
4
  import type {
5
5
  ExtensionAPI,
@@ -6,7 +6,7 @@ import {
6
6
  type Context,
7
7
  type Model,
8
8
  type SimpleStreamOptions,
9
- } from "@earendil-works/pi-ai/compat";
9
+ } from "@earendil-works/pi-ai";
10
10
 
11
11
  function makeProviderLoadErrorMessage(model: Model<Api>, error: unknown): AssistantMessage {
12
12
  return {
@@ -4,7 +4,7 @@ import {
4
4
  type AssistantMessageEventStream,
5
5
  type Context,
6
6
  type Model,
7
- } from "@earendil-works/pi-ai/compat";
7
+ } from "@earendil-works/pi-ai";
8
8
  import { scheduler } from "node:timers/promises";
9
9
  import {
10
10
  CursorLiveRunAbortError,
@@ -1,5 +1,5 @@
1
1
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
- import type { AssistantMessage } from "@earendil-works/pi-ai/compat";
2
+ import type { AssistantMessage } from "@earendil-works/pi-ai";
3
3
  import { CURSOR_PROVIDER } from "./cursor-model.js";
4
4
 
5
5
  /**
@@ -1,4 +1,4 @@
1
- import type { AssistantMessage } from "@earendil-works/pi-ai/compat";
1
+ import type { AssistantMessage } from "@earendil-works/pi-ai";
2
2
  import { cursorLiveRuns } from "./cursor-provider-live-run-drain.js";
3
3
  import {
4
4
  classifyCursorRunEmission,
@@ -1,4 +1,4 @@
1
- import type { AssistantMessage, AssistantMessageEventStream } from "@earendil-works/pi-ai/compat";
1
+ import type { AssistantMessage, AssistantMessageEventStream } from "@earendil-works/pi-ai";
2
2
  import type { InteractionUpdate } from "@cursor/sdk";
3
3
  import type { CursorLiveRun } from "./cursor-live-run-coordinator.js";
4
4
  import { cursorLiveRuns } from "./cursor-provider-live-run-drain.js";
@@ -1,4 +1,4 @@
1
- import type { AssistantMessage, AssistantMessageEventStream } from "@earendil-works/pi-ai/compat";
1
+ import type { AssistantMessage, AssistantMessageEventStream } from "@earendil-works/pi-ai";
2
2
  import type { CursorLiveRun } from "./cursor-live-run-coordinator.js";
3
3
  import { cursorLiveRuns } from "./cursor-provider-live-run-drain.js";
4
4
  import { CursorPartialContentEmitter } from "./cursor-partial-content-emitter.js";
@@ -1,4 +1,4 @@
1
- import type { Context, SimpleStreamOptions } from "@earendil-works/pi-ai/compat";
1
+ import type { Context, SimpleStreamOptions } from "@earendil-works/pi-ai";
2
2
  import type { AgentModeOption, ModelSelection, SDKAgent } from "@cursor/sdk";
3
3
  import { configureCursorSdkHttp1 } from "./cursor-http1.js";
4
4
  import { installCursorMcpToolTimeoutOverride } from "./cursor-mcp-timeout-override.js";
@@ -5,7 +5,7 @@ import type {
5
5
  Context,
6
6
  Model,
7
7
  SimpleStreamOptions,
8
- } from "@earendil-works/pi-ai/compat";
8
+ } from "@earendil-works/pi-ai";
9
9
  import type { AgentModeOption, ModelSelection, SDKAgent, SDKImage } from "@cursor/sdk";
10
10
  import type { CursorLiveRun } from "./cursor-live-run-coordinator.js";
11
11
  import type { SessionCursorAgentLease } from "./cursor-session-agent.js";
@@ -6,7 +6,7 @@ import {
6
6
  createAssistantMessageEventStream,
7
7
  type Model,
8
8
  type SimpleStreamOptions,
9
- } from "@earendil-works/pi-ai/compat";
9
+ } from "@earendil-works/pi-ai";
10
10
  import {
11
11
  cursorLiveRuns,
12
12
  DEFAULT_CURSOR_NATIVE_REPLAY_IDLE_DISPOSE_MS,
@@ -1,4 +1,4 @@
1
- import type { AssistantMessage } from "@earendil-works/pi-ai/compat";
1
+ import type { AssistantMessage } from "@earendil-works/pi-ai";
2
2
  import { asRecord, hasUsableText } from "./cursor-record-utils.js";
3
3
 
4
4
  function isCursorTextBoundary(text: string, index: number): boolean {
@@ -1,7 +1,7 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { copyFileSync, existsSync, unlinkSync, writeFileSync } from "node:fs";
3
3
  import { join } from "node:path";
4
- import type { AssistantMessageEventStream } from "@earendil-works/pi-ai/compat";
4
+ import type { AssistantMessageEventStream } from "@earendil-works/pi-ai";
5
5
  import type { AgentModeOption, InteractionUpdate } from "@cursor/sdk";
6
6
  import type { CursorPiToolBridgeDiagnosticEvent } from "./cursor-pi-tool-bridge-diagnostics.js";
7
7
  import { serializeCursorPiToolBridgeDiagnostic } from "./cursor-pi-tool-bridge-diagnostics.js";
@@ -1,6 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import type { AgentModeOption, LocalAgentOptions, LocalAgentStore, ModelSelection, SDKAgent, SettingSource } from "@cursor/sdk";
3
- import type { Context } from "@earendil-works/pi-ai/compat";
3
+ import type { Context } from "@earendil-works/pi-ai";
4
4
  import {
5
5
  getRegisteredCursorPiToolBridge,
6
6
  type CursorPiBridgeToolRequest,
@@ -1,4 +1,4 @@
1
- import type { Context } from "@earendil-works/pi-ai/compat";
1
+ import type { Context } from "@earendil-works/pi-ai";
2
2
  import {
3
3
  buildCursorIncrementalPrompt,
4
4
  buildCursorPrompt,
@@ -1,4 +1,4 @@
1
- import type { Api, AssistantMessage, Context, Model } from "@earendil-works/pi-ai/compat";
1
+ import type { Api, AssistantMessage, Context, Model } from "@earendil-works/pi-ai";
2
2
  import {
3
3
  CURSOR_APPROX_CHARS_PER_TOKEN,
4
4
  CURSOR_IMAGE_TOKEN_ESTIMATE,
@@ -5,7 +5,8 @@ import type {
5
5
  ModelSelection,
6
6
  } from "@cursor/sdk";
7
7
  import type { ProviderModelConfig } from "@earendil-works/pi-coding-agent";
8
- import type { ModelThinkingLevel, ThinkingLevelMap } from "@earendil-works/pi-ai/compat";
8
+ import type { ModelThinkingLevel, ThinkingLevelMap } from "@earendil-works/pi-ai";
9
+ import { getCursorModelSelectionIdentities } from "../shared/cursor-model-selection-identities.mjs";
9
10
  import { loadContextWindowCache } from "./context-window-cache.js";
10
11
  import { loadCursorSdk } from "./cursor-sdk-runtime.js";
11
12
  import { resolveCursorApiKey, resolveCursorRuntimeApiKey } from "./cursor-api-key.js";
@@ -176,13 +177,6 @@ function getParamValue(params: ModelParameterValue[], id: string): string | unde
176
177
  return params.find((param) => param.id === id)?.value;
177
178
  }
178
179
 
179
- function encodePiModelId(modelId: string, context?: string, fastOverride?: boolean): string {
180
- const contextQualified = context ? `${modelId}@${context}` : modelId;
181
- if (fastOverride === true) return `${contextQualified}:fast`;
182
- if (fastOverride === false) return `${contextQualified}:slow`;
183
- return contextQualified;
184
- }
185
-
186
180
  function getModelName(item: ModelListItem, context?: string, alias?: string, fastOverride?: boolean): string {
187
181
  const displayName = item.displayName || item.id;
188
182
  const qualifiers: string[] = [];
@@ -193,18 +187,17 @@ function getModelName(item: ModelListItem, context?: string, alias?: string, fas
193
187
  return context ? `${baseName} @ ${context}` : baseName;
194
188
  }
195
189
 
196
- function getFastOverrideBasePiModelId(piModelId: string): string {
197
- return piModelId.replace(/:(?:fast|slow)$/, "");
198
- }
199
-
200
- function getContextWindow(contextWindowCache: Map<string, number>, piModelId: string, context?: string, baseModelId?: string): number {
201
- const fastOverrideBasePiModelId = getFastOverrideBasePiModelId(piModelId);
202
- const contextWindowOverride =
203
- contextWindowCache.get(piModelId) ??
204
- (fastOverrideBasePiModelId !== piModelId ? contextWindowCache.get(fastOverrideBasePiModelId) : undefined);
205
-
190
+ function getContextWindow(
191
+ contextWindowCache: Map<string, number>,
192
+ selectionKeys: readonly string[],
193
+ context?: string,
194
+ baseModelId?: string,
195
+ ): number {
196
+ for (const key of new Set(selectionKeys)) {
197
+ const contextWindow = contextWindowCache.get(key);
198
+ if (contextWindow !== undefined) return contextWindow;
199
+ }
206
200
  return (
207
- contextWindowOverride ??
208
201
  (context ? parseContextWindow(context) : undefined) ??
209
202
  (baseModelId ? contextWindowCache.get(baseModelId) : undefined) ??
210
203
  contextWindowCache.get("default") ??
@@ -219,6 +212,7 @@ function toMetadata(
219
212
  defaultParams: ModelParameterValue[],
220
213
  context: string | undefined,
221
214
  contextWindowCache: Map<string, number>,
215
+ contextWindowKeys: readonly string[],
222
216
  fastOverride?: boolean,
223
217
  ): CursorModelMetadata {
224
218
  const thinkingLevelMap = getThinkingLevelMap(item);
@@ -230,7 +224,7 @@ function toMetadata(
230
224
  displayName: item.displayName || item.id,
231
225
  defaultParams: cloneParams(defaultParams),
232
226
  ...(context ? { context } : {}),
233
- contextWindow: getContextWindow(contextWindowCache, piModelId, context, item.id),
227
+ contextWindow: getContextWindow(contextWindowCache, contextWindowKeys, context, item.id),
234
228
  supportsFast: getParameter(item, "fast") !== undefined,
235
229
  defaultFast: fastValue === "true",
236
230
  ...(fastOverride !== undefined ? { fastOverride } : {}),
@@ -259,78 +253,27 @@ function toModelConfig(metadata: CursorModelMetadata, name: string): ProviderMod
259
253
  };
260
254
  }
261
255
 
262
- function getContextValues(item: ModelListItem): string[] {
263
- return getParameter(item, "context")?.values.map((value) => value.value) ?? [];
264
- }
265
-
266
- function getAmbiguousAliases(items: ModelListItem[]): Set<string> {
267
- const aliasOwners = new Map<string, Set<string>>();
268
- for (const item of items) {
269
- for (const rawAlias of item.aliases ?? []) {
270
- const alias = rawAlias.trim();
271
- if (!alias || alias === item.id) continue;
272
- const owners = aliasOwners.get(alias) ?? new Set<string>();
273
- owners.add(item.id);
274
- aliasOwners.set(alias, owners);
275
- }
276
- }
277
- return new Set([...aliasOwners.entries()].filter(([, owners]) => owners.size > 1).map(([alias]) => alias));
278
- }
279
-
280
- function getModelIds(item: ModelListItem, reservedBaseModelIds: Set<string>, ambiguousAliases: Set<string>): string[] {
281
- const ids = [item.id];
282
- for (const rawAlias of item.aliases ?? []) {
283
- const alias = rawAlias.trim();
284
- if (!alias || alias === item.id || ids.includes(alias) || reservedBaseModelIds.has(alias) || ambiguousAliases.has(alias)) continue;
285
- ids.push(alias);
286
- }
287
- return ids;
288
- }
289
-
290
- function toModelConfigs(
291
- item: ModelListItem,
292
- usedPiModelIds: Set<string>,
293
- reservedBaseModelIds: Set<string>,
294
- ambiguousAliases: Set<string>,
295
- contextWindowCache: Map<string, number>,
296
- ): ProviderModelConfig[] {
297
- const defaultParams = getDefaultParams(item);
298
- const contextValues = getContextValues(item);
299
- const contexts = contextValues.length > 0 ? contextValues : [undefined];
300
- const configs: ProviderModelConfig[] = [];
301
-
302
- const fastOverrides = getParameter(item, "fast") === undefined ? [undefined] : [undefined, true, false];
303
-
304
- for (const selectionModelId of getModelIds(item, reservedBaseModelIds, ambiguousAliases)) {
305
- const alias = selectionModelId === item.id ? undefined : selectionModelId;
306
- for (const context of contexts) {
307
- const contextParams = context ? replaceParam(defaultParams, "context", context) : defaultParams;
308
- for (const fastOverride of fastOverrides) {
309
- const params = fastOverride === undefined ? contextParams : replaceParam(contextParams, "fast", fastOverride ? "true" : "false");
310
- const piModelId = encodePiModelId(selectionModelId, context, fastOverride);
311
- if (usedPiModelIds.has(piModelId)) continue;
312
- usedPiModelIds.add(piModelId);
313
- const metadata = toMetadata(item, piModelId, selectionModelId, params, context, contextWindowCache, fastOverride);
314
- metadataByPiModelId.set(piModelId, metadata);
315
- configs.push(toModelConfig(metadata, getModelName(item, context, alias, fastOverride)));
316
- }
317
- }
318
- }
319
-
320
- return configs;
321
- }
322
-
323
- function sortModelsByBaseId(items: ModelListItem[]): ModelListItem[] {
324
- return [...items].sort((a, b) => a.id.localeCompare(b.id));
325
- }
326
-
327
256
  function registerModelItems(items: ModelListItem[]): ProviderModelConfig[] {
328
257
  metadataByPiModelId.clear();
329
- const usedPiModelIds = new Set<string>();
330
- const reservedBaseModelIds = new Set(items.map((item) => item.id));
331
- const ambiguousAliases = getAmbiguousAliases(items);
332
258
  const contextWindowCache = loadContextWindowCache();
333
- return sortModelsByBaseId(items).flatMap((item) => toModelConfigs(item, usedPiModelIds, reservedBaseModelIds, ambiguousAliases, contextWindowCache));
259
+ return getCursorModelSelectionIdentities(items).map(({ model: item, selectionModelId, context, fastOverride, piModelId, contextWindowKey, baseContextWindowKey }) => {
260
+ const defaultParams = getDefaultParams(item);
261
+ const contextParams = context ? replaceParam(defaultParams, "context", context) : defaultParams;
262
+ const params = fastOverride === undefined ? contextParams : replaceParam(contextParams, "fast", fastOverride ? "true" : "false");
263
+ const metadata = toMetadata(
264
+ item,
265
+ piModelId,
266
+ selectionModelId,
267
+ params,
268
+ context,
269
+ contextWindowCache,
270
+ [piModelId, contextWindowKey, baseContextWindowKey],
271
+ fastOverride,
272
+ );
273
+ metadataByPiModelId.set(piModelId, metadata);
274
+ const alias = selectionModelId === item.id ? undefined : selectionModelId;
275
+ return toModelConfig(metadata, getModelName(item, context, alias, fastOverride));
276
+ });
334
277
  }
335
278
 
336
279
  export function getCursorModelMetadata(modelId: string): CursorModelMetadata | undefined {
@@ -1,166 +0,0 @@
1
- # Changes
2
-
3
-
4
- ## 2.0.2
5
-
6
- * Rename bin to `node-which`
7
-
8
- ## 2.0.1
9
-
10
- * generate changelog and publish on version bump
11
- * enforce 100% test coverage
12
- * Promise interface
13
-
14
- ## 2.0.0
15
-
16
- * Parallel tests, modern JavaScript, and drop support for node < 8
17
-
18
- ## 1.3.1
19
-
20
- * update deps
21
- * update travis
22
-
23
- ## v1.3.0
24
-
25
- * Add nothrow option to which.sync
26
- * update tap
27
-
28
- ## v1.2.14
29
-
30
- * appveyor: drop node 5 and 0.x
31
- * travis-ci: add node 6, drop 0.x
32
-
33
- ## v1.2.13
34
-
35
- * test: Pass missing option to pass on windows
36
- * update tap
37
- * update isexe to 2.0.0
38
- * neveragain.tech pledge request
39
-
40
- ## v1.2.12
41
-
42
- * Removed unused require
43
-
44
- ## v1.2.11
45
-
46
- * Prevent changelog script from being included in package
47
-
48
- ## v1.2.10
49
-
50
- * Use env.PATH only, not env.Path
51
-
52
- ## v1.2.9
53
-
54
- * fix for paths starting with ../
55
- * Remove unused `is-absolute` module
56
-
57
- ## v1.2.8
58
-
59
- * bullet items in changelog that contain (but don't start with) #
60
-
61
- ## v1.2.7
62
-
63
- * strip 'update changelog' changelog entries out of changelog
64
-
65
- ## v1.2.6
66
-
67
- * make the changelog bulleted
68
-
69
- ## v1.2.5
70
-
71
- * make a changelog, and keep it up to date
72
- * don't include tests in package
73
- * Properly handle relative-path executables
74
- * appveyor
75
- * Attach error code to Not Found error
76
- * Make tests pass on Windows
77
-
78
- ## v1.2.4
79
-
80
- * Fix typo
81
-
82
- ## v1.2.3
83
-
84
- * update isexe, fix regression in pathExt handling
85
-
86
- ## v1.2.2
87
-
88
- * update deps, use isexe module, test windows
89
-
90
- ## v1.2.1
91
-
92
- * Sometimes windows PATH entries are quoted
93
- * Fixed a bug in the check for group and user mode bits. This bug was introduced during refactoring for supporting strict mode.
94
- * doc cli
95
-
96
- ## v1.2.0
97
-
98
- * Add support for opt.all and -as cli flags
99
- * test the bin
100
- * update travis
101
- * Allow checking for multiple programs in bin/which
102
- * tap 2
103
-
104
- ## v1.1.2
105
-
106
- * travis
107
- * Refactored and fixed undefined error on Windows
108
- * Support strict mode
109
-
110
- ## v1.1.1
111
-
112
- * test +g exes against secondary groups, if available
113
- * Use windows exe semantics on cygwin & msys
114
- * cwd should be first in path on win32, not last
115
- * Handle lower-case 'env.Path' on Windows
116
- * Update docs
117
- * use single-quotes
118
-
119
- ## v1.1.0
120
-
121
- * Add tests, depend on is-absolute
122
-
123
- ## v1.0.9
124
-
125
- * which.js: root is allowed to execute files owned by anyone
126
-
127
- ## v1.0.8
128
-
129
- * don't use graceful-fs
130
-
131
- ## v1.0.7
132
-
133
- * add license to package.json
134
-
135
- ## v1.0.6
136
-
137
- * isc license
138
-
139
- ## 1.0.5
140
-
141
- * Awful typo
142
-
143
- ## 1.0.4
144
-
145
- * Test for path absoluteness properly
146
- * win: Allow '' as a pathext if cmd has a . in it
147
-
148
- ## 1.0.3
149
-
150
- * Remove references to execPath
151
- * Make `which.sync()` work on Windows by honoring the PATHEXT variable.
152
- * Make `isExe()` always return true on Windows.
153
- * MIT
154
-
155
- ## 1.0.2
156
-
157
- * Only files can be exes
158
-
159
- ## 1.0.1
160
-
161
- * Respect the PATHEXT env for win32 support
162
- * should 0755 the bin
163
- * binary
164
- * guts
165
- * package
166
- * 1st