pi-cursor-sdk 0.1.22 → 0.1.24

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.
@@ -64,6 +64,7 @@ export function snapshotToolToMcpTool(tool: CursorPiBridgeToolDefinition): Tool
64
64
  piToolName: tool.piToolName,
65
65
  mcpToolName: tool.mcpToolName,
66
66
  piToolDescription: tool.description,
67
+ piToolPromptGuidelines: tool.promptGuidelines,
67
68
  }),
68
69
  inputSchema: tool.inputSchema,
69
70
  _meta: { piToolName: tool.piToolName },
@@ -42,6 +42,7 @@ export function buildCursorPiToolBridgeSurfaceSignature(snapshot: CursorPiToolBr
42
42
  piToolName: tool.piToolName,
43
43
  mcpToolName: tool.mcpToolName,
44
44
  description: tool.description,
45
+ promptGuidelines: tool.promptGuidelines,
45
46
  inputSchema: tool.inputSchema,
46
47
  source: tool.sourceInfo?.source,
47
48
  path: tool.sourceInfo?.path,
@@ -79,6 +80,7 @@ export function buildCursorPiToolBridgeSnapshot(
79
80
  piToolName: tool.name,
80
81
  mcpToolName,
81
82
  description,
83
+ promptGuidelines: tool.promptGuidelines,
82
84
  inputSchema: normalizeMcpInputSchema(tool.parameters),
83
85
  sourceInfo: tool.sourceInfo,
84
86
  });
@@ -30,6 +30,7 @@ export interface CursorPiBridgeToolDefinition {
30
30
  piToolName: string;
31
31
  mcpToolName: string;
32
32
  description: string;
33
+ promptGuidelines?: ToolInfo["promptGuidelines"];
33
34
  inputSchema: CursorPiMcpInputSchema;
34
35
  sourceInfo: ToolInfo["sourceInfo"];
35
36
  }
@@ -1,8 +1 @@
1
- const CURSOR_API_KEY_ENV_VAR = "CURSOR_API_KEY";
2
-
3
- export function resolveCursorApiKey(apiKey?: string): string | undefined {
4
- const trimmed = apiKey?.trim();
5
- if (!trimmed) return undefined;
6
- if (trimmed === CURSOR_API_KEY_ENV_VAR) return process.env.CURSOR_API_KEY?.trim();
7
- return trimmed;
8
- }
1
+ export { resolveCursorApiKey } from "./cursor-api-key.js";
@@ -4,7 +4,7 @@ import type { CursorPiToolBridgeSnapshot } from "./cursor-pi-tool-bridge-types.j
4
4
  export const CURSOR_TOOL_MANIFEST_ENV = "PI_CURSOR_TOOL_MANIFEST";
5
5
 
6
6
  /**
7
- * Representative @cursor/sdk@1.0.14 local-agent ToolType values; actual exposure can vary by run.
7
+ * Representative @cursor/sdk@1.0.15 local-agent ToolType values; actual exposure can vary by run.
8
8
  * See docs/cursor-native-tool-replay.md#sdk-tooltype-replay-matrix.
9
9
  */
10
10
  export const CURSOR_HOST_TOOL_MANIFEST_SUMMARY =
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ import { registerCursorAgentsContextDedup } from "./cursor-agents-context.js";
9
9
  import { registerCursorSessionAgent } from "./cursor-session-agent.js";
10
10
  import { prepareCursorSessionForCompaction } from "./cursor-session-compaction-prep.js";
11
11
  import { streamCursor } from "./cursor-provider.js";
12
+ import { CURSOR_API_KEY_CONFIG_VALUE } from "./cursor-api-key.js";
12
13
 
13
14
  type CursorExtensionApi =
14
15
  & Pick<ExtensionAPI, "registerProvider" | "registerCommand" | "on">
@@ -24,7 +25,7 @@ function createCursorProviderConfig(models: ProviderModelConfig[]): ProviderConf
24
25
  return {
25
26
  name: "Cursor",
26
27
  baseUrl: "https://cursor.com",
27
- apiKey: "CURSOR_API_KEY",
28
+ apiKey: CURSOR_API_KEY_CONFIG_VALUE,
28
29
  api: "cursor-sdk",
29
30
  models,
30
31
  streamSimple: streamCursor,
@@ -8,10 +8,10 @@ import type {
8
8
  import { AuthStorage, type ProviderModelConfig } from "@earendil-works/pi-coding-agent";
9
9
  import type { ModelThinkingLevel, ThinkingLevelMap } from "@earendil-works/pi-ai";
10
10
  import { loadContextWindowCache } from "./context-window-cache.js";
11
+ import { CURSOR_API_KEY_ENV_VAR, resolveCursorApiKey } from "./cursor-api-key.js";
11
12
  import { FALLBACK_MODEL_ITEMS } from "./cursor-fallback-models.generated.js";
12
13
 
13
14
  const CURSOR_PROVIDER_ID = "cursor";
14
- const CURSOR_API_KEY_ENV_VAR = "CURSOR_API_KEY";
15
15
  const FALLBACK_CONTEXT_WINDOW = 128000;
16
16
  const FALLBACK_MAX_TOKENS = 16384;
17
17
  const ZERO_COST = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
@@ -50,29 +50,22 @@ function getCliApiKeyFromArgv(argv: string[] = process.argv): string | undefined
50
50
  return undefined;
51
51
  }
52
52
 
53
- function normalizeApiKey(value: string | undefined): string | undefined {
54
- const trimmed = value?.trim();
55
- if (!trimmed) return undefined;
56
- if (trimmed === CURSOR_API_KEY_ENV_VAR) return process.env.CURSOR_API_KEY?.trim() || undefined;
57
- return trimmed;
58
- }
59
-
60
53
  async function getStoredCursorApiKey(): Promise<string | undefined> {
61
54
  try {
62
- return normalizeApiKey(await AuthStorage.create().getApiKey(CURSOR_PROVIDER_ID, { includeFallback: false }));
55
+ return resolveCursorApiKey(await AuthStorage.create().getApiKey(CURSOR_PROVIDER_ID, { includeFallback: false }));
63
56
  } catch {
64
57
  return undefined;
65
58
  }
66
59
  }
67
60
 
68
61
  async function getDiscoveryApiKey(): Promise<string | undefined> {
69
- const cliApiKey = normalizeApiKey(getCliApiKeyFromArgv());
62
+ const cliApiKey = resolveCursorApiKey(getCliApiKeyFromArgv());
70
63
  if (cliApiKey) return cliApiKey;
71
64
 
72
65
  const storedApiKey = await getStoredCursorApiKey();
73
66
  if (storedApiKey) return storedApiKey;
74
67
 
75
- return normalizeApiKey(process.env.CURSOR_API_KEY);
68
+ return resolveCursorApiKey(process.env.CURSOR_API_KEY);
76
69
  }
77
70
 
78
71
  export interface CursorModelMetadata {
@@ -472,5 +465,5 @@ export const __testUtils = {
472
465
  parseContextWindow,
473
466
  registerModelItems,
474
467
  getCliApiKeyFromArgv,
475
- normalizeApiKey,
468
+ normalizeApiKey: resolveCursorApiKey,
476
469
  };