@cursor/sdk 1.0.19 → 1.0.21

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.
@@ -1,4 +1,5 @@
1
1
  import { type TokenProvider } from "@anysphere/analytics-client";
2
+ import type { SdkAnalyticsBaseProps, SdkAnalyticsEventSchema, SdkExecutorStartupProps, SdkRunCompletedProps, SdkRunCreatedProps, SdkRunSendLatencyProps, SdkRuntime } from "@anysphere/analytics-types/sdk";
2
3
  /**
3
4
  * Drains buffered SDK analytics events for every apiKey that has emitted
4
5
  * anything in this process. Called from `agent[Symbol.asyncDispose]()`.
@@ -8,97 +9,8 @@ import { type TokenProvider } from "@anysphere/analytics-client";
8
9
  */
9
10
  export declare function flushSdkAnalytics(timeoutMs?: number): Promise<void>;
10
11
  export declare function __resetAnalyticsForTests(): void;
11
- /**
12
- * Four dispatch targets, flattened into one field so a single
13
- * `WHERE runtime = 'X'` or `WHERE runtime != 'local'` query covers both
14
- * "which execution environment?" and "is this local?" questions without
15
- * awkwardly repeating "cloud" at two nesting levels.
16
- */
17
- export type SdkRuntime = "local" | "cloud" | "pool" | "machine";
18
- /**
19
- * Base props auto-merged into every SDK event by the analytics wrapper.
20
- * Callers never pass these. Kept as an interface (not derived) so the DBT
21
- * generator at `scripts/generate-dbt-from-analytics-types.ts` can resolve
22
- * them — its AST walker only looks at interface declarations in the same
23
- * source file.
24
- */
25
- export interface SdkAnalyticsBaseProps {
26
- /** Runtime surface emitting telemetry. Always "sdk" for this package. */
27
- surface: "sdk";
28
- /** Version of @cursor/sdk that emitted the event. */
29
- sdk_version: string;
30
- /** Node process.platform (e.g., "darwin", "linux", "win32"). */
31
- os_platform: string;
32
- /** Node process.arch (e.g., "x64", "arm64"). */
33
- os_arch: string;
34
- }
35
- export interface SdkRunCreatedProps {
36
- agent_id: string;
37
- run_id: string;
38
- /** Backend request id used for the SDK turn, when the runtime exposes it. */
39
- request_id?: string;
40
- runtime: SdkRuntime;
41
- model: string;
42
- /**
43
- * JSON-encoded `ModelSelection.params` (`[{ id, value }, ...]`) when the
44
- * caller supplied any. Omitted when no params were set.
45
- */
46
- model_params?: string;
47
- prompt_length: number;
48
- has_images: boolean;
49
- is_resume: boolean;
50
- mcp_server_count: number;
51
- cloud_repo_count?: number;
52
- cloud_auto_create_pr?: boolean;
53
- }
54
- export interface SdkRunCompletedProps {
55
- agent_id: string;
56
- run_id: string;
57
- /** Backend request id used for the SDK turn, when the runtime exposes it. */
58
- request_id?: string;
59
- runtime: SdkRuntime;
60
- end_reason: "success" | "error" | "abort";
61
- }
62
- export interface SdkRunSendLatencyProps {
63
- agent_id: string;
64
- run_id: string;
65
- /** Backend request id used for the SDK turn, when the runtime exposes it. */
66
- request_id?: string;
67
- runtime: SdkRuntime;
68
- is_resume: boolean;
69
- is_first_send_after_resume: boolean;
70
- cold_executor: boolean;
71
- executor_acquire_ms: number;
72
- load_latest_ms: number;
73
- get_blob_store_ms: number;
74
- pre_send_ms: number;
75
- time_to_first_message_ms?: number;
76
- terminated_reason: "success" | "error" | "abort" | "hang_timeout";
77
- turn_count: number;
78
- }
79
- export interface SdkExecutorStartupProps {
80
- runtime: SdkRuntime;
81
- ensure_ghost_mode_ms: number;
82
- bootstrap_statsig_ms: number;
83
- create_workspace_runtime_ms: number;
84
- load_sandbox_policy_ms: number;
85
- total_ms: number;
86
- }
87
- /**
88
- * Schema consumed by the DBT generator. The runtime emit path in this file
89
- * auto-merges SdkAnalyticsBaseProps into every event, so this intersection
90
- * mirrors the actual wire shape and generates the right SQL columns.
91
- *
92
- * Do not reference this from runtime code — it exists purely for dbt.
93
- */
94
- export type SdkAnalyticsEventSchema = {
95
- "sdk.run.created": SdkAnalyticsBaseProps & SdkRunCreatedProps;
96
- "sdk.run.completed": SdkAnalyticsBaseProps & SdkRunCompletedProps;
97
- "sdk.run.send_latency": SdkAnalyticsBaseProps & SdkRunSendLatencyProps;
98
- "sdk.executor.startup": SdkAnalyticsBaseProps & SdkExecutorStartupProps;
99
- };
100
12
  export declare function trackSdkRunCreated(apiKey: string | undefined, props: SdkRunCreatedProps): void;
101
13
  export declare function trackSdkRunCompleted(apiKey: string | undefined, props: SdkRunCompletedProps): void;
102
14
  export declare function trackSdkRunSendLatency(apiKey: string | undefined, props: SdkRunSendLatencyProps): void;
103
- export type { TokenProvider };
15
+ export type { SdkAnalyticsBaseProps, SdkAnalyticsEventSchema, SdkExecutorStartupProps, SdkRunCompletedProps, SdkRunCreatedProps, SdkRunSendLatencyProps, SdkRuntime, TokenProvider, };
104
16
  //# sourceMappingURL=analytics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/agent/analytics.ts"],"names":[],"mappings":"AAKA,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAC;AAgGrC;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,GAAE,MAAa,GACvB,OAAO,CAAC,IAAI,CAAC,CAGf;AAGD,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C;AAED;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,yEAAyE;IACzE,OAAO,EAAE,KAAK,CAAC;IACf,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,UAAU,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,EA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