pi-cursor-sdk 0.1.40 → 0.1.41

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 (35) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +10 -9
  3. package/docs/cursor-dogfood-checklist.md +6 -0
  4. package/docs/cursor-live-smoke-checklist.md +4 -4
  5. package/docs/cursor-model-ux-spec.md +6 -6
  6. package/docs/cursor-native-tool-replay.md +4 -4
  7. package/docs/cursor-native-tool-visual-audit.md +2 -2
  8. package/docs/cursor-testing-lessons.md +1 -1
  9. package/docs/cursor-tool-surfaces.md +4 -0
  10. package/docs/platform-smoke.md +9 -1
  11. package/package.json +8 -5
  12. package/scripts/lib/cursor-visual-manifest.d.mts +3 -0
  13. package/scripts/lib/cursor-visual-manifest.mjs +82 -0
  14. package/scripts/platform-smoke/artifacts.mjs +147 -2
  15. package/scripts/platform-smoke/card-detect.mjs +1 -1
  16. package/scripts/platform-smoke/doctor.mjs +53 -8
  17. package/scripts/platform-smoke/scenarios.mjs +1 -1
  18. package/scripts/platform-smoke.mjs +69 -7
  19. package/scripts/visual-tui-smoke-self-test.mjs +229 -0
  20. package/scripts/visual-tui-smoke.mjs +45 -179
  21. package/src/context.ts +25 -10
  22. package/src/cursor-active-tools.ts +7 -0
  23. package/src/cursor-native-tool-display-registration.ts +31 -21
  24. package/src/cursor-native-tool-display-state.ts +13 -4
  25. package/src/cursor-pi-tool-bridge-run.ts +6 -3
  26. package/src/cursor-pi-tool-bridge-types.ts +2 -2
  27. package/src/cursor-provider-errors.ts +2 -1
  28. package/src/cursor-provider-live-run-drain.ts +1 -1
  29. package/src/cursor-provider-turn-prepare.ts +1 -1
  30. package/src/cursor-provider-turn-send.ts +2 -0
  31. package/src/cursor-question-tool.ts +2 -1
  32. package/src/cursor-sdk-event-debug.ts +3 -1
  33. package/src/cursor-skill-tool.ts +2 -1
  34. package/src/cursor-tool-manifest.ts +2 -1
  35. package/src/cursor-usage-accounting.ts +5 -4
@@ -78,12 +78,14 @@ export interface CursorSdkEventDebugSendMeta {
78
78
 
79
79
  export interface CursorSdkEventDebugRunMeta {
80
80
  runId: string;
81
+ requestId?: string;
81
82
  agentId: string;
82
83
  status: string;
83
84
  }
84
85
 
85
86
  interface CursorSdkRunLike {
86
87
  id: string;
88
+ requestId?: string;
87
89
  agentId?: string;
88
90
  status?: string;
89
91
  stream?: () => AsyncIterable<unknown>;
@@ -373,7 +375,7 @@ export class CursorSdkEventDebugSink {
373
375
  attachRunStream(run: unknown): void {
374
376
  const sdkRun = run as CursorSdkRunLike;
375
377
  if (typeof sdkRun.stream !== "function") {
376
- this.recordProviderEvent("run_stream_unavailable", { runId: sdkRun.id });
378
+ this.recordProviderEvent("run_stream_unavailable", { runId: sdkRun.id, requestId: sdkRun.requestId });
377
379
  return;
378
380
  }
379
381
  this.streamCapturePromise = (async () => {
@@ -8,6 +8,7 @@ import type {
8
8
  Skill,
9
9
  } from "@earendil-works/pi-coding-agent";
10
10
  import { Type } from "typebox";
11
+ import { arePiToolsDisabled } from "./cursor-active-tools.js";
11
12
  import { isCursorModel } from "./cursor-model.js";
12
13
  import { registerCursorModelLifecycle, type CursorModelLifecycleExtensionApi } from "./cursor-model-lifecycle.js";
13
14
  import { resolveCursorPiToolBridgeEnabled } from "./cursor-pi-tool-bridge-env.js";
@@ -62,7 +63,7 @@ function shouldExposeSkillTool(model: ExtensionContext["model"]): boolean {
62
63
 
63
64
  function syncCursorSkillToolForModel(pi: Pick<ExtensionAPI, "getActiveTools" | "setActiveTools">, model: ExtensionContext["model"]): void {
64
65
  const activeToolNames = new Set(pi.getActiveTools());
65
- const shouldBeActive = shouldExposeSkillTool(model);
66
+ const shouldBeActive = !arePiToolsDisabled(pi) && shouldExposeSkillTool(model);
66
67
  const alreadyActive = activeToolNames.has(CURSOR_ACTIVATE_SKILL_TOOL_NAME);
67
68
  if (shouldBeActive === alreadyActive) return;
68
69
  if (shouldBeActive) {
@@ -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.17 local-agent ToolType values; actual exposure can vary by run.
7
+ * Representative @cursor/sdk@1.0.18 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 =
@@ -26,6 +26,7 @@ export function buildCursorToolManifestText(options: {
26
26
  "Callable tool surfaces this run:",
27
27
  `- Cursor SDK host tools (callable; not listed in MCP listTools): ${CURSOR_HOST_TOOL_MANIFEST_SUMMARY}.`,
28
28
  "- Configured Cursor MCP servers: discovered at runtime via MCP listTools (depends on Cursor settings and PI_CURSOR_SETTING_SOURCES).",
29
+ "- Pi CLI tool toggles such as --no-tools affect pi tools and bridge exposure only; they do not disable Cursor SDK host tools or configured Cursor MCP.",
29
30
  ];
30
31
  const bridgeTools = options.bridgeSnapshot?.tools ?? [];
31
32
  if (!piBridgeEnabled) {
@@ -56,10 +56,11 @@ export function estimateCursorContextTotalTokens(partial: AssistantMessage, mode
56
56
  return estimateCursorContextTokens(withAssistantMessage(context, partial), getCursorPromptOptions(model));
57
57
  }
58
58
 
59
- export function applyCursorApproximateUsage(partial: AssistantMessage, model: Model<Api>, context: Context, sessionInputTokens: number): void {
60
- partial.usage.input = sessionInputTokens;
61
- partial.usage.output = estimateCursorAssistantSessionOutputTokens(partial);
59
+ export function applyCursorApproximateUsage(partial: AssistantMessage, _model: Model<Api>, _context: Context, sessionInputTokens: number): void {
60
+ const outputTokens = estimateCursorAssistantSessionOutputTokens(partial);
61
+ partial.usage.input = Math.max(0, sessionInputTokens);
62
+ partial.usage.output = outputTokens;
62
63
  partial.usage.cacheRead = 0;
63
64
  partial.usage.cacheWrite = 0;
64
- partial.usage.totalTokens = estimateCursorContextTotalTokens(partial, model, context);
65
+ partial.usage.totalTokens = partial.usage.input + partial.usage.output + partial.usage.cacheRead + partial.usage.cacheWrite;
65
66
  }