effect-cursor-sdk 0.1.1
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.
- package/LICENSE +21 -0
- package/README.md +275 -0
- package/dist/index.d.ts +840 -0
- package/dist/index.js +1186 -0
- package/dist/index.js.map +1 -0
- package/package.json +85 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,840 @@
|
|
|
1
|
+
import { Config, Context, Effect, Layer, ManagedRuntime, Metric, Option, Redacted, Schema, Scope, Stream } from "effect";
|
|
2
|
+
import { AgentDefinition, AgentMessage, AgentOperationOptions, AgentOptions, AuthenticationError, ConfigurationError, CursorAgentError, CursorAgentPlatform, CursorRequestOptions, GetAgentMessagesOptions, GetAgentOptions, GetRunOptions, IntegrationNotConnectedError, ListAgentsOptions, ListResult, ListRunsOptions, McpServerConfig, ModelListItem, ModelParameterDefinition, ModelParameterValue, ModelSelection, ModelVariant, NetworkError, RateLimitError, Run, RunOperation, RunResult, RunResultStatus, RunStatus, SDKAgent, SDKAgentInfo, SDKArtifact, SDKAssistantMessage, SDKImage, SDKImageDimension, SDKMessage, SDKModel, SDKRepository, SDKStatusMessage, SDKSystemMessage, SDKTaskMessage, SDKThinkingMessage, SDKToolUseMessage, SDKUser, SDKUserMessage, SDKUserMessageEvent, SendOptions, SettingSource, TextBlock, ToolUseBlock, UnknownAgentError, UnsupportedRunOperationError, createAgentPlatform, createInMemoryRunEventNotifier, createLocalRunEventNotifier, createSdkMessageRunStreamEvent, decodeLocalRunStreamEvent, decodeSdkMessageRunStreamEvent, getTurnType, isTerminalLocalRunStreamEvent, localRunStreamEventToSdkMessage, startLocalRunEventNotifierServer } from "@cursor/sdk";
|
|
3
|
+
import * as _$effect_Types0 from "effect/Types";
|
|
4
|
+
import * as _$effect_Cause0 from "effect/Cause";
|
|
5
|
+
|
|
6
|
+
//#region src/cursor-error.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* The operation being executed when an SDK error crossed into Effect.
|
|
9
|
+
*
|
|
10
|
+
* @category errors
|
|
11
|
+
*/
|
|
12
|
+
type CursorOperation = "agent.create" | "agent.resume" | "agent.prompt" | "agent.send" | "agent.close" | "agent.reload" | "agent.dispose" | "agent.list" | "agent.get" | "agent.archive" | "agent.unarchive" | "agent.delete" | "messages.list" | "run.list" | "run.get" | "run.wait" | "run.stream" | "run.conversation" | "run.cancel" | "artifacts.list" | "artifacts.download" | "cursor.me" | "cursor.models.list" | "cursor.repositories.list";
|
|
13
|
+
/**
|
|
14
|
+
* Safe metadata attached to wrapper errors.
|
|
15
|
+
*
|
|
16
|
+
* @category errors
|
|
17
|
+
*/
|
|
18
|
+
interface CursorErrorContext {
|
|
19
|
+
readonly operation: CursorOperation;
|
|
20
|
+
readonly agentId?: string;
|
|
21
|
+
readonly runId?: string;
|
|
22
|
+
readonly runtime?: "local" | "cloud";
|
|
23
|
+
readonly status?: string;
|
|
24
|
+
}
|
|
25
|
+
interface CursorErrorFields extends CursorErrorContext {
|
|
26
|
+
readonly message: string;
|
|
27
|
+
readonly cause: unknown;
|
|
28
|
+
readonly isRetryable: boolean;
|
|
29
|
+
}
|
|
30
|
+
declare const CursorAuthenticationError_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
|
|
31
|
+
readonly _tag: "CursorAuthenticationError";
|
|
32
|
+
} & Readonly<A>;
|
|
33
|
+
/**
|
|
34
|
+
* Authentication or permission failure reported by the Cursor SDK.
|
|
35
|
+
*
|
|
36
|
+
* @see {@link mapCursorError}
|
|
37
|
+
* @category errors
|
|
38
|
+
*/
|
|
39
|
+
declare class CursorAuthenticationError extends CursorAuthenticationError_base<CursorErrorFields> {}
|
|
40
|
+
declare const CursorRateLimitError_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
|
|
41
|
+
readonly _tag: "CursorRateLimitError";
|
|
42
|
+
} & Readonly<A>;
|
|
43
|
+
/**
|
|
44
|
+
* Cursor rate limit or usage-limit failure.
|
|
45
|
+
*
|
|
46
|
+
* @see {@link mapCursorError}
|
|
47
|
+
* @category errors
|
|
48
|
+
*/
|
|
49
|
+
declare class CursorRateLimitError extends CursorRateLimitError_base<CursorErrorFields> {}
|
|
50
|
+
declare const CursorConfigurationError_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
|
|
51
|
+
readonly _tag: "CursorConfigurationError";
|
|
52
|
+
} & Readonly<A>;
|
|
53
|
+
/**
|
|
54
|
+
* Invalid configuration, model, prompt, repository, or request options.
|
|
55
|
+
*
|
|
56
|
+
* @see {@link AgentOptions}
|
|
57
|
+
* @see {@link mapCursorError}
|
|
58
|
+
* @category errors
|
|
59
|
+
*/
|
|
60
|
+
declare class CursorConfigurationError extends CursorConfigurationError_base<CursorErrorFields> {}
|
|
61
|
+
declare const CursorIntegrationNotConnectedError_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
|
|
62
|
+
readonly _tag: "CursorIntegrationNotConnectedError";
|
|
63
|
+
} & Readonly<A>;
|
|
64
|
+
/**
|
|
65
|
+
* SCM integration is not connected for a requested cloud repository.
|
|
66
|
+
*
|
|
67
|
+
* @see {@link mapCursorError}
|
|
68
|
+
* @category errors
|
|
69
|
+
*/
|
|
70
|
+
declare class CursorIntegrationNotConnectedError extends CursorIntegrationNotConnectedError_base<CursorErrorFields & {
|
|
71
|
+
readonly provider?: string;
|
|
72
|
+
readonly helpUrl?: string;
|
|
73
|
+
}> {}
|
|
74
|
+
declare const CursorNetworkError_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
|
|
75
|
+
readonly _tag: "CursorNetworkError";
|
|
76
|
+
} & Readonly<A>;
|
|
77
|
+
/**
|
|
78
|
+
* Network, service availability, timeout, or backend failure.
|
|
79
|
+
*
|
|
80
|
+
* @see {@link mapCursorError}
|
|
81
|
+
* @category errors
|
|
82
|
+
*/
|
|
83
|
+
declare class CursorNetworkError extends CursorNetworkError_base<CursorErrorFields> {}
|
|
84
|
+
declare const CursorUnsupportedOperationError_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
|
|
85
|
+
readonly _tag: "CursorUnsupportedOperationError";
|
|
86
|
+
} & Readonly<A>;
|
|
87
|
+
/**
|
|
88
|
+
* A run operation is unavailable for the current runtime or run state.
|
|
89
|
+
*
|
|
90
|
+
* @see {@link RunOperation}
|
|
91
|
+
* @see {@link mapCursorError}
|
|
92
|
+
* @category errors
|
|
93
|
+
*/
|
|
94
|
+
declare class CursorUnsupportedOperationError extends CursorUnsupportedOperationError_base<CursorErrorFields & {
|
|
95
|
+
readonly sdkOperation?: RunOperation;
|
|
96
|
+
}> {}
|
|
97
|
+
declare const CursorRunFailedError_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
|
|
98
|
+
readonly _tag: "CursorRunFailedError";
|
|
99
|
+
} & Readonly<A>;
|
|
100
|
+
/**
|
|
101
|
+
* A run reached an error terminal state or failed to produce a usable result.
|
|
102
|
+
*
|
|
103
|
+
* @see {@link RunResult}
|
|
104
|
+
* @category errors
|
|
105
|
+
*/
|
|
106
|
+
declare class CursorRunFailedError extends CursorRunFailedError_base<CursorErrorFields> {}
|
|
107
|
+
declare const CursorStreamError_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
|
|
108
|
+
readonly _tag: "CursorStreamError";
|
|
109
|
+
} & Readonly<A>;
|
|
110
|
+
/**
|
|
111
|
+
* Stream creation or iteration failed.
|
|
112
|
+
*
|
|
113
|
+
* @see {@link CursorRunService}
|
|
114
|
+
* @see {@link SDKMessage}
|
|
115
|
+
* @category errors
|
|
116
|
+
*/
|
|
117
|
+
declare class CursorStreamError extends CursorStreamError_base<CursorErrorFields> {}
|
|
118
|
+
declare const CursorUnknownError_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
|
|
119
|
+
readonly _tag: "CursorUnknownError";
|
|
120
|
+
} & Readonly<A>;
|
|
121
|
+
/**
|
|
122
|
+
* Fallback for unknown SDK or JavaScript failures.
|
|
123
|
+
*
|
|
124
|
+
* @see {@link mapCursorError}
|
|
125
|
+
* @category errors
|
|
126
|
+
*/
|
|
127
|
+
declare class CursorUnknownError extends CursorUnknownError_base<CursorErrorFields> {}
|
|
128
|
+
/**
|
|
129
|
+
* Convert any SDK failure into a tagged Effect error.
|
|
130
|
+
*
|
|
131
|
+
* @param cause - Unknown value thrown by `@cursor/sdk` or JavaScript runtime code.
|
|
132
|
+
* @param context - Safe operation metadata to attach to the tagged error.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* import { Effect } from "effect"
|
|
137
|
+
* import { mapCursorError } from "effect-cursor-sdk"
|
|
138
|
+
*
|
|
139
|
+
* const effect = Effect.tryPromise({
|
|
140
|
+
* try: () => run.wait(),
|
|
141
|
+
* catch: (cause) => mapCursorError(cause, { operation: "run.wait", runId: run.id })
|
|
142
|
+
* })
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @see {@link CursorAuthenticationError}
|
|
146
|
+
* @see {@link CursorUnsupportedOperationError}
|
|
147
|
+
* @see {@link CursorStreamError}
|
|
148
|
+
*
|
|
149
|
+
* @category errors
|
|
150
|
+
*/
|
|
151
|
+
declare function mapCursorError(cause: unknown, context: CursorErrorContext & {
|
|
152
|
+
readonly operation: "run.stream";
|
|
153
|
+
}): CursorStreamError;
|
|
154
|
+
declare function mapCursorError(cause: unknown, context: CursorErrorContext & {
|
|
155
|
+
readonly operation: "run.cancel" | "run.conversation";
|
|
156
|
+
}): CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnsupportedOperationError | CursorUnknownError;
|
|
157
|
+
declare function mapCursorError(cause: unknown, context: CursorErrorContext): CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError;
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/cursor-sdk-factory.d.ts
|
|
160
|
+
/**
|
|
161
|
+
* Thin boundary around the static `@cursor/sdk` APIs.
|
|
162
|
+
*
|
|
163
|
+
* Most application code should use {@link CursorAgentService},
|
|
164
|
+
* {@link CursorRunService}, {@link CursorArtifactService}, and
|
|
165
|
+
* {@link CursorInspectionService}. This factory exists so live code, tests, and
|
|
166
|
+
* user applications can replace SDK construction and static calls without
|
|
167
|
+
* monkey-patching imports.
|
|
168
|
+
*
|
|
169
|
+
* So in one line: you probably won't need this.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* import { CursorSdkFactory, CursorAgentService } from "effect-cursor-sdk"
|
|
174
|
+
* import { Layer } from "effect"
|
|
175
|
+
*
|
|
176
|
+
* const TestSdk = Layer.succeed(CursorSdkFactory)(
|
|
177
|
+
* CursorSdkFactory.of({
|
|
178
|
+
* create: () => mockAgent,
|
|
179
|
+
* // implement the remaining factory methods for your test
|
|
180
|
+
* })
|
|
181
|
+
* )
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* @see {@link CursorAgentService} for creating, resuming, sending, and disposing agents.
|
|
185
|
+
* @see {@link CursorRunService} for wrapping `Run` handles.
|
|
186
|
+
* @see {@link CursorInspectionService} for static agent and account APIs.
|
|
187
|
+
* @see {@link CursorArtifactService} for artifact APIs on an SDK agent.
|
|
188
|
+
*
|
|
189
|
+
* @remarks
|
|
190
|
+
* **API boundary notice:** `create`, `resume`, and `prompt` take raw
|
|
191
|
+
* {@link AgentOptions} today; the same possible future change described on
|
|
192
|
+
* {@link CursorAgentServiceShape} may apply here. Prefer
|
|
193
|
+
* {@link loadCursorConfig} with {@link agentOptionsFromConfig} before calling
|
|
194
|
+
* these methods when wiring production code.
|
|
195
|
+
*
|
|
196
|
+
* @category services
|
|
197
|
+
*/
|
|
198
|
+
interface CursorSdkFactoryShape {
|
|
199
|
+
readonly create: (options: AgentOptions) => Promise<SDKAgent>;
|
|
200
|
+
readonly resume: (agentId: string, options?: Partial<AgentOptions>) => Promise<SDKAgent>;
|
|
201
|
+
readonly prompt: (message: string, options?: AgentOptions) => Promise<RunResult>;
|
|
202
|
+
readonly listAgents: (options?: ListAgentsOptions) => Promise<ListResult<SDKAgentInfo>>;
|
|
203
|
+
readonly listRuns: (agentId: string, options?: ListRunsOptions) => Promise<ListResult<Run>>;
|
|
204
|
+
readonly getRun: (runId: string, options?: GetRunOptions) => Promise<Run>;
|
|
205
|
+
readonly getAgent: (agentId: string, options?: GetAgentOptions) => Promise<SDKAgentInfo>;
|
|
206
|
+
readonly archiveAgent: (agentId: string, options?: AgentOperationOptions) => Promise<void>;
|
|
207
|
+
readonly unarchiveAgent: (agentId: string, options?: AgentOperationOptions) => Promise<void>;
|
|
208
|
+
readonly deleteAgent: (agentId: string, options?: AgentOperationOptions) => Promise<void>;
|
|
209
|
+
readonly listMessages: (agentId: string, options?: GetAgentMessagesOptions) => Promise<AgentMessage[]>;
|
|
210
|
+
readonly me: (options?: CursorRequestOptions) => Promise<SDKUser>;
|
|
211
|
+
readonly listModels: (options?: CursorRequestOptions) => Promise<SDKModel[]>;
|
|
212
|
+
readonly listRepositories: (options?: CursorRequestOptions) => Promise<SDKRepository[]>;
|
|
213
|
+
}
|
|
214
|
+
declare const CursorSdkFactory_base: Context.ServiceClass<CursorSdkFactory, "effect-cursor-sdk/cursor-sdk-factory/CursorSdkFactory", CursorSdkFactoryShape>;
|
|
215
|
+
/**
|
|
216
|
+
* Context service that provides the live `@cursor/sdk` static API boundary.
|
|
217
|
+
*
|
|
218
|
+
* Use {@link CursorSdkFactory.Live} in production layers and override the
|
|
219
|
+
* service in tests with {@link makeMockSdkFactoryLayer} or a custom layer.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* const program = Effect.gen(function*() {
|
|
224
|
+
* const sdk = yield* CursorSdkFactory
|
|
225
|
+
* return sdk.create({ model: { id: "composer-2" }, local: { cwd: process.cwd() } })
|
|
226
|
+
* })
|
|
227
|
+
* ```
|
|
228
|
+
*
|
|
229
|
+
* @see {@link CursorSdkFactoryShape}
|
|
230
|
+
* @see {@link liveLayer}
|
|
231
|
+
* @category services
|
|
232
|
+
*/
|
|
233
|
+
declare class CursorSdkFactory extends CursorSdkFactory_base {
|
|
234
|
+
static readonly Live: Layer.Layer<CursorSdkFactory, never, never>;
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/cursor-agent.d.ts
|
|
238
|
+
/**
|
|
239
|
+
* Agent lifecycle surface backed by the Cursor SDK.
|
|
240
|
+
*
|
|
241
|
+
* @remarks
|
|
242
|
+
* **API boundary notice:** `create`, `resume`, `prompt`, and `scoped` currently
|
|
243
|
+
* accept raw {@link AgentOptions} (including a plain `apiKey` string). A future
|
|
244
|
+
* major version may require options to flow through Effectful {@link CursorConfig}
|
|
245
|
+
* with {@link loadCursorConfig} and {@link agentOptionsFromConfig} instead of
|
|
246
|
+
* passing `AgentOptions` at this boundary. Prefer the config path for new code;
|
|
247
|
+
* see the package README.
|
|
248
|
+
*/
|
|
249
|
+
interface CursorAgentServiceShape {
|
|
250
|
+
readonly create: (options: AgentOptions) => Effect.Effect<SDKAgent, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
251
|
+
readonly resume: (agentId: string, options?: Partial<AgentOptions>) => Effect.Effect<SDKAgent, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
252
|
+
readonly prompt: (message: string, options?: AgentOptions) => Effect.Effect<RunResult, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
253
|
+
readonly send: (agent: SDKAgent, message: string | SDKUserMessage, options?: SendOptions) => Effect.Effect<Run, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
254
|
+
readonly reload: (agent: SDKAgent) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
255
|
+
readonly close: (agent: SDKAgent) => Effect.Effect<void>;
|
|
256
|
+
readonly dispose: (agent: SDKAgent) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
257
|
+
readonly scoped: (options: AgentOptions) => Effect.Effect<SDKAgent, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError, Scope.Scope>;
|
|
258
|
+
}
|
|
259
|
+
declare const CursorAgentService_base: Context.ServiceClass<CursorAgentService, "effect-cursor-sdk/cursor-agent/CursorAgentService", CursorAgentServiceShape>;
|
|
260
|
+
/**
|
|
261
|
+
* Effect-native agent lifecycle and prompt service.
|
|
262
|
+
*
|
|
263
|
+
* The service wraps `Agent.create`, `Agent.resume`, `Agent.prompt`, and
|
|
264
|
+
* instance lifecycle methods while preserving SDK-owned option and result
|
|
265
|
+
* types.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```ts
|
|
269
|
+
* import { CursorAgentService, liveLayer } from "effect-cursor-sdk"
|
|
270
|
+
* import { Effect } from "effect"
|
|
271
|
+
*
|
|
272
|
+
* const program = Effect.gen(function*() {
|
|
273
|
+
* const agents = yield* CursorAgentService
|
|
274
|
+
* const agent = yield* agents.create({ model: { id: "composer-2" }, local: { cwd: process.cwd() } })
|
|
275
|
+
* return yield* agents.send(agent, "Summarize this repository")
|
|
276
|
+
* }).pipe(Effect.provide(liveLayer))
|
|
277
|
+
* ```
|
|
278
|
+
*
|
|
279
|
+
* @see {@link CursorRunService} for operations on returned `Run` handles.
|
|
280
|
+
* @see {@link CursorSdkFactory} for replacing SDK construction in tests.
|
|
281
|
+
*
|
|
282
|
+
* @remarks
|
|
283
|
+
* Inherits the **API boundary notice** on {@link CursorAgentServiceShape} about
|
|
284
|
+
* a possible future switch from raw {@link AgentOptions} to
|
|
285
|
+
* {@link loadCursorConfig} / {@link agentOptionsFromConfig}.
|
|
286
|
+
*
|
|
287
|
+
* @category services
|
|
288
|
+
*/
|
|
289
|
+
declare class CursorAgentService extends CursorAgentService_base {
|
|
290
|
+
static readonly Live: Layer.Layer<CursorAgentService, never, CursorSdkFactory>;
|
|
291
|
+
}
|
|
292
|
+
//#endregion
|
|
293
|
+
//#region src/cursor-artifacts.d.ts
|
|
294
|
+
interface CursorArtifactServiceShape {
|
|
295
|
+
readonly listArtifacts: (agent: SDKAgent) => Effect.Effect<SDKArtifact[], CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
296
|
+
readonly downloadArtifact: (agent: SDKAgent, path: string) => Effect.Effect<Buffer, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
297
|
+
}
|
|
298
|
+
declare const CursorArtifactService_base: Context.ServiceClass<CursorArtifactService, "effect-cursor-sdk/cursor-artifacts/CursorArtifactService", CursorArtifactServiceShape>;
|
|
299
|
+
/**
|
|
300
|
+
* Effect-native wrappers for agent artifacts.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```ts
|
|
304
|
+
* const artifacts = yield* CursorArtifactService
|
|
305
|
+
* const items = yield* artifacts.listArtifacts(agent)
|
|
306
|
+
* const bytes = yield* artifacts.downloadArtifact(agent, items[0]!.path)
|
|
307
|
+
* ```
|
|
308
|
+
*
|
|
309
|
+
* @see {@link SDKArtifact}
|
|
310
|
+
*
|
|
311
|
+
* @category services
|
|
312
|
+
*/
|
|
313
|
+
declare class CursorArtifactService extends CursorArtifactService_base {
|
|
314
|
+
static readonly Live: Layer.Layer<CursorArtifactService, never, never>;
|
|
315
|
+
}
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region src/cursor-config.d.ts
|
|
318
|
+
/**
|
|
319
|
+
* Branded secret material for the Cursor API key.
|
|
320
|
+
*
|
|
321
|
+
* Values are held inside {@link Redacted} on {@link CursorConfig}; this schema
|
|
322
|
+
* only brands the decoded plaintext type so it cannot be confused with other
|
|
323
|
+
* strings at the type level.
|
|
324
|
+
*/
|
|
325
|
+
declare const CursorApiKey: Schema.brand<Schema.Redacted<Schema.String>, "CursorApiKey">;
|
|
326
|
+
type CursorApiKey = typeof CursorApiKey.Type;
|
|
327
|
+
/**
|
|
328
|
+
* Branded model identifier from wrapper config.
|
|
329
|
+
*
|
|
330
|
+
* Populated from the `CURSOR_MODEL` environment variable when using
|
|
331
|
+
* {@link loadCursorConfig}.
|
|
332
|
+
*/
|
|
333
|
+
declare const CursorModelId: Schema.brand<Schema.String, "CursorModelId">;
|
|
334
|
+
type CursorModelId = typeof CursorModelId.Type;
|
|
335
|
+
/**
|
|
336
|
+
* Branded local working directory for agent runs.
|
|
337
|
+
*
|
|
338
|
+
* Populated from `CURSOR_LOCAL_CWD` when using {@link loadCursorConfig}.
|
|
339
|
+
*/
|
|
340
|
+
declare const CursorLocalCwd: Schema.brand<Schema.String, "CursorLocalCwd">;
|
|
341
|
+
type CursorLocalCwd = typeof CursorLocalCwd.Type;
|
|
342
|
+
declare const CursorConfig_base: Schema.Class<CursorConfig, Schema.Struct<{
|
|
343
|
+
readonly apiKey: Schema.optional<Schema.brand<Schema.Redacted<Schema.String>, "CursorApiKey">>;
|
|
344
|
+
readonly modelId: Schema.optional<Schema.brand<Schema.String, "CursorModelId">>;
|
|
345
|
+
readonly cwd: Schema.optional<Schema.brand<Schema.String, "CursorLocalCwd">>;
|
|
346
|
+
}>, {}>;
|
|
347
|
+
/**
|
|
348
|
+
* Minimal configuration owned by this wrapper.
|
|
349
|
+
*
|
|
350
|
+
* The SDK's `AgentOptions` type remains the source of truth for complete
|
|
351
|
+
* runtime options. This schema only models environment-derived defaults.
|
|
352
|
+
* Use {@link agentOptionsFromConfig} to merge those defaults into SDK-owned
|
|
353
|
+
* {@link AgentOptions}.
|
|
354
|
+
*
|
|
355
|
+
* @remarks
|
|
356
|
+
* **Forward path:** A future major version of this package may require all
|
|
357
|
+
* agent-related options to be supplied through this module (for example
|
|
358
|
+
* {@link loadCursorConfig} plus {@link agentOptionsFromConfig}) instead of raw
|
|
359
|
+
* {@link AgentOptions} on {@link CursorAgentService}.
|
|
360
|
+
* Prefer this path for new code.
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
* ```ts
|
|
364
|
+
* const config = new CursorConfig({
|
|
365
|
+
* apiKey: Redacted.make(CursorApiKey.make(process.env.CURSOR_API_KEY!)),
|
|
366
|
+
* modelId: CursorModelId.make("composer-2"),
|
|
367
|
+
* cwd: CursorLocalCwd.make(process.cwd())
|
|
368
|
+
* })
|
|
369
|
+
* ```
|
|
370
|
+
*
|
|
371
|
+
* @see {@link cursorConfig}
|
|
372
|
+
* @see {@link loadCursorConfig}
|
|
373
|
+
*
|
|
374
|
+
* @category config
|
|
375
|
+
*/
|
|
376
|
+
declare class CursorConfig extends CursorConfig_base {}
|
|
377
|
+
/**
|
|
378
|
+
* Effect Config descriptors for common Cursor environment variables.
|
|
379
|
+
*
|
|
380
|
+
* Reads `CURSOR_API_KEY`, `CURSOR_MODEL`, and `CURSOR_LOCAL_CWD` from the active
|
|
381
|
+
* Effect {@link ConfigProvider.ConfigProvider}. All fields are optional so
|
|
382
|
+
* callers can still pass complete SDK options explicitly.
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```ts
|
|
386
|
+
* const config = yield* loadCursorConfig
|
|
387
|
+
* const options = agentOptionsFromConfig(config)
|
|
388
|
+
* ```
|
|
389
|
+
*
|
|
390
|
+
* @see {@link Config}
|
|
391
|
+
* @see {@link loadCursorConfig}
|
|
392
|
+
*
|
|
393
|
+
* @category config
|
|
394
|
+
*/
|
|
395
|
+
declare const cursorConfig: Config.Config<{
|
|
396
|
+
apiKey: Option.Option<Redacted.Redacted<string>>;
|
|
397
|
+
modelId: Option.Option<string>;
|
|
398
|
+
cwd: Option.Option<string>;
|
|
399
|
+
}>;
|
|
400
|
+
/**
|
|
401
|
+
* Build SDK `AgentOptions` from wrapper config and optional overrides.
|
|
402
|
+
*
|
|
403
|
+
* Explicit override values always win over environment-derived defaults.
|
|
404
|
+
*
|
|
405
|
+
* @param config - Wrapper-owned environment defaults.
|
|
406
|
+
* @param overrides - Complete or partial SDK-owned options to merge over the defaults.
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* ```ts
|
|
410
|
+
* const options = agentOptionsFromConfig(config, {
|
|
411
|
+
* cloud: {
|
|
412
|
+
* repos: [{ url: "https://github.com/acme/app" }],
|
|
413
|
+
* autoCreatePR: true
|
|
414
|
+
* }
|
|
415
|
+
* })
|
|
416
|
+
* ```
|
|
417
|
+
*
|
|
418
|
+
* @see {@link CursorConfig}
|
|
419
|
+
* @see {@link AgentOptions}
|
|
420
|
+
*
|
|
421
|
+
* @remarks
|
|
422
|
+
* Same **forward path** notice as {@link CursorConfig}: this merge is the
|
|
423
|
+
* intended boundary for redacted keys and env defaults ahead of a possible
|
|
424
|
+
* requirement to use it for all agent entry points.
|
|
425
|
+
*
|
|
426
|
+
* @category config
|
|
427
|
+
*/
|
|
428
|
+
declare const agentOptionsFromConfig: (config: CursorConfig, overrides?: AgentOptions) => AgentOptions;
|
|
429
|
+
/**
|
|
430
|
+
* Load environment-derived defaults as a schema-backed value.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```ts
|
|
434
|
+
* const config = yield* loadCursorConfig
|
|
435
|
+
* const options = agentOptionsFromConfig(config, { local: { cwd: process.cwd() } })
|
|
436
|
+
* ```
|
|
437
|
+
*
|
|
438
|
+
* @see {@link cursorConfig}
|
|
439
|
+
* @see {@link agentOptionsFromConfig}
|
|
440
|
+
*
|
|
441
|
+
* @remarks
|
|
442
|
+
* Same **forward path** notice as {@link CursorConfig}: this effect is the
|
|
443
|
+
* intended entry for redacted env defaults ahead of a possible requirement to
|
|
444
|
+
* use it (with {@link agentOptionsFromConfig}) for all agent entry points.
|
|
445
|
+
*
|
|
446
|
+
* @category config
|
|
447
|
+
*/
|
|
448
|
+
declare const loadCursorConfig: Effect.Effect<CursorConfig, Config.ConfigError, never>;
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region src/cursor-inspection.d.ts
|
|
451
|
+
interface CursorInspectionServiceShape {
|
|
452
|
+
readonly listAgents: (options?: ListAgentsOptions) => Effect.Effect<ListResult<SDKAgentInfo>, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
453
|
+
readonly getAgent: (agentId: string, options?: GetAgentOptions) => Effect.Effect<SDKAgentInfo, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
454
|
+
readonly archiveAgent: (agentId: string, options?: AgentOperationOptions) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
455
|
+
readonly unarchiveAgent: (agentId: string, options?: AgentOperationOptions) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
456
|
+
readonly deleteAgent: (agentId: string, options?: AgentOperationOptions) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
457
|
+
readonly listRuns: (agentId: string, options?: ListRunsOptions) => Effect.Effect<ListResult<Run>, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
458
|
+
readonly getRun: (runId: string, options?: GetRunOptions) => Effect.Effect<Run, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
459
|
+
readonly listMessages: (agentId: string, options?: GetAgentMessagesOptions) => Effect.Effect<AgentMessage[], CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
460
|
+
readonly me: (options?: CursorRequestOptions) => Effect.Effect<SDKUser, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
461
|
+
readonly listModels: (options?: CursorRequestOptions) => Effect.Effect<SDKModel[], CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
462
|
+
readonly listRepositories: (options?: CursorRequestOptions) => Effect.Effect<SDKRepository[], CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
463
|
+
}
|
|
464
|
+
declare const CursorInspectionService_base: Context.ServiceClass<CursorInspectionService, "effect-cursor-sdk/cursor-inspection/CursorInspectionService", CursorInspectionServiceShape>;
|
|
465
|
+
/**
|
|
466
|
+
* Effect-native wrappers for SDK inspection, lifecycle, and account catalog APIs.
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```ts
|
|
470
|
+
* const inspection = yield* CursorInspectionService
|
|
471
|
+
* const agents = yield* inspection.listAgents({ runtime: "cloud", includeArchived: true })
|
|
472
|
+
* const models = yield* inspection.listModels()
|
|
473
|
+
* ```
|
|
474
|
+
*
|
|
475
|
+
* @see {@link CursorSdkFactory}
|
|
476
|
+
* @see {@link SDKAgentInfo}
|
|
477
|
+
*
|
|
478
|
+
* @category services
|
|
479
|
+
*/
|
|
480
|
+
declare class CursorInspectionService extends CursorInspectionService_base {
|
|
481
|
+
static readonly Live: Layer.Layer<CursorInspectionService, never, CursorSdkFactory>;
|
|
482
|
+
}
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region src/cursor-mock.d.ts
|
|
485
|
+
/**
|
|
486
|
+
* Fixture data used by the deterministic mock SDK layer.
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* ```ts
|
|
490
|
+
* const fixtures: CursorMockFixtures = {
|
|
491
|
+
* stream: [assistantEvent],
|
|
492
|
+
* result: { id: "run-1", status: "finished", result: "Done" }
|
|
493
|
+
* }
|
|
494
|
+
* ```
|
|
495
|
+
*
|
|
496
|
+
* @see {@link mockLayer}
|
|
497
|
+
* @see {@link makeMockSdkFactoryLayer}
|
|
498
|
+
* @category testing
|
|
499
|
+
*/
|
|
500
|
+
interface CursorMockFixtures {
|
|
501
|
+
readonly agentId?: string;
|
|
502
|
+
readonly runId?: string;
|
|
503
|
+
readonly stream?: ReadonlyArray<SDKMessage>;
|
|
504
|
+
readonly result?: RunResult;
|
|
505
|
+
readonly artifacts?: ReadonlyArray<SDKArtifact>;
|
|
506
|
+
readonly artifactData?: Buffer;
|
|
507
|
+
readonly agents?: ReadonlyArray<SDKAgentInfo>;
|
|
508
|
+
readonly messages?: ReadonlyArray<AgentMessage>;
|
|
509
|
+
readonly models?: ReadonlyArray<SDKModel>;
|
|
510
|
+
readonly repositories?: ReadonlyArray<SDKRepository>;
|
|
511
|
+
readonly user?: SDKUser;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Deterministic SDK `Run` implementation for tests.
|
|
515
|
+
*
|
|
516
|
+
* @param streamEvents - Events yielded by {@link MockCursorRun.stream}.
|
|
517
|
+
* @param waitResult - Result returned by {@link MockCursorRun.wait}.
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* ```ts
|
|
521
|
+
* const run = new MockCursorRun([assistantEvent], {
|
|
522
|
+
* id: "run-1",
|
|
523
|
+
* status: "finished",
|
|
524
|
+
* result: "Done"
|
|
525
|
+
* })
|
|
526
|
+
* ```
|
|
527
|
+
*
|
|
528
|
+
* @see {@link makeMockRun}
|
|
529
|
+
* @category testing
|
|
530
|
+
*/
|
|
531
|
+
declare class MockCursorRun implements Run {
|
|
532
|
+
#private;
|
|
533
|
+
readonly streamEvents: ReadonlyArray<SDKMessage>;
|
|
534
|
+
readonly waitResult: RunResult;
|
|
535
|
+
readonly id: string;
|
|
536
|
+
readonly agentId: string;
|
|
537
|
+
readonly createdAt: number;
|
|
538
|
+
constructor(streamEvents: ReadonlyArray<SDKMessage>, waitResult: RunResult);
|
|
539
|
+
get status(): RunStatus;
|
|
540
|
+
get result(): string | undefined;
|
|
541
|
+
get model(): RunResult["model"];
|
|
542
|
+
get durationMs(): number | undefined;
|
|
543
|
+
get git(): RunResult["git"];
|
|
544
|
+
supports(_operation: RunOperation): boolean;
|
|
545
|
+
unsupportedReason(_operation: RunOperation): string | undefined;
|
|
546
|
+
stream(): AsyncGenerator<SDKMessage, void>;
|
|
547
|
+
conversation(): Promise<[]>;
|
|
548
|
+
wait(): Promise<RunResult>;
|
|
549
|
+
cancel(): Promise<void>;
|
|
550
|
+
onDidChangeStatus(listener: (status: RunStatus) => void): () => void;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Deterministic SDK `Agent` implementation for tests.
|
|
554
|
+
*
|
|
555
|
+
* @param fixtures - Static data used by `send`, artifact methods, and metadata methods.
|
|
556
|
+
*
|
|
557
|
+
* @example
|
|
558
|
+
* ```ts
|
|
559
|
+
* const agent = new MockCursorAgent({ result: { id: "run-1", status: "finished" } })
|
|
560
|
+
* const run = await agent.send("hello")
|
|
561
|
+
* ```
|
|
562
|
+
*
|
|
563
|
+
* @see {@link makeMockAgent}
|
|
564
|
+
* @see {@link CursorMockFixtures}
|
|
565
|
+
* @category testing
|
|
566
|
+
*/
|
|
567
|
+
declare class MockCursorAgent implements SDKAgent {
|
|
568
|
+
readonly fixtures: CursorMockFixtures;
|
|
569
|
+
readonly agentId: string;
|
|
570
|
+
readonly runs: Run[];
|
|
571
|
+
closed: boolean;
|
|
572
|
+
constructor(fixtures?: CursorMockFixtures);
|
|
573
|
+
get model(): AgentOptions["model"] | undefined;
|
|
574
|
+
send(_message: string | SDKUserMessage, _options?: SendOptions): Promise<Run>;
|
|
575
|
+
close(): void;
|
|
576
|
+
reload(): Promise<void>;
|
|
577
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
578
|
+
listArtifacts(): Promise<SDKArtifact[]>;
|
|
579
|
+
downloadArtifact(_path: string): Promise<Buffer>;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Create a mock run from fixtures.
|
|
583
|
+
*
|
|
584
|
+
* @param fixtures - Optional mock run and stream data.
|
|
585
|
+
*
|
|
586
|
+
* @see {@link MockCursorRun}
|
|
587
|
+
* @category testing
|
|
588
|
+
*/
|
|
589
|
+
declare const makeMockRun: (fixtures?: CursorMockFixtures) => MockCursorRun;
|
|
590
|
+
/**
|
|
591
|
+
* Create a mock agent from fixtures.
|
|
592
|
+
*
|
|
593
|
+
* @param fixtures - Optional mock agent, run, artifact, and metadata data.
|
|
594
|
+
*
|
|
595
|
+
* @see {@link MockCursorAgent}
|
|
596
|
+
* @category testing
|
|
597
|
+
*/
|
|
598
|
+
declare const makeMockAgent: (fixtures?: CursorMockFixtures) => MockCursorAgent;
|
|
599
|
+
/**
|
|
600
|
+
* Layer replacing the SDK factory with deterministic mock behavior.
|
|
601
|
+
*
|
|
602
|
+
* This is the lowest-level mock entry point. Prefer {@link mockLayer} when you
|
|
603
|
+
* want all higher-level services wired together for tests.
|
|
604
|
+
*
|
|
605
|
+
* @param fixtures - Static SDK responses returned by the factory methods.
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
* ```ts
|
|
609
|
+
* const layer = makeMockSdkFactoryLayer({
|
|
610
|
+
* agents: [{ agentId: "mock-agent", name: "Mock", summary: "Test", lastModified: 0 }]
|
|
611
|
+
* })
|
|
612
|
+
* ```
|
|
613
|
+
*
|
|
614
|
+
* @see {@link CursorSdkFactory}
|
|
615
|
+
* @see {@link mockLayer}
|
|
616
|
+
* @category testing
|
|
617
|
+
*/
|
|
618
|
+
declare const makeMockSdkFactoryLayer: (fixtures?: CursorMockFixtures) => Layer.Layer<CursorSdkFactory, never, never>;
|
|
619
|
+
//#endregion
|
|
620
|
+
//#region src/cursor-run.d.ts
|
|
621
|
+
interface CursorRunServiceShape {
|
|
622
|
+
readonly supports: (run: Run, operation: RunOperation) => boolean;
|
|
623
|
+
readonly unsupportedReason: (run: Run, operation: RunOperation) => string | undefined;
|
|
624
|
+
readonly wait: (run: Run) => Effect.Effect<RunResult, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
625
|
+
readonly cancel: (run: Run) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnsupportedOperationError | CursorUnknownError>;
|
|
626
|
+
readonly conversation: (run: Run) => ReturnType<Run["conversation"]> extends Promise<infer A> ? Effect.Effect<A, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnsupportedOperationError | CursorUnknownError> : never;
|
|
627
|
+
readonly streamEvents: (run: Run) => Stream.Stream<SDKMessage, CursorStreamError>;
|
|
628
|
+
readonly collectText: (run: Run) => Effect.Effect<string, CursorStreamError>;
|
|
629
|
+
readonly onDidChangeStatus: (run: Run, listener: (status: RunStatus) => void) => Effect.Effect<() => void>;
|
|
630
|
+
}
|
|
631
|
+
declare const CursorRunService_base: Context.ServiceClass<CursorRunService, "effect-cursor-sdk/cursor-run/CursorRunService", CursorRunServiceShape>;
|
|
632
|
+
/**
|
|
633
|
+
* Effect-native helpers for SDK run handles.
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* ```ts
|
|
637
|
+
* const run = yield* agents.send(agent, "Refactor auth")
|
|
638
|
+
* const text = yield* runs.collectText(run)
|
|
639
|
+
* ```
|
|
640
|
+
*
|
|
641
|
+
* @see {@link CursorAgentService} for creating and sending runs.
|
|
642
|
+
* @see {@link SDKMessage} for the SDK-owned stream event shape.
|
|
643
|
+
*
|
|
644
|
+
* @category services
|
|
645
|
+
*/
|
|
646
|
+
declare class CursorRunService extends CursorRunService_base {
|
|
647
|
+
static readonly Live: Layer.Layer<CursorRunService, never, never>;
|
|
648
|
+
}
|
|
649
|
+
//#endregion
|
|
650
|
+
//#region src/cursor-runtime.d.ts
|
|
651
|
+
/**
|
|
652
|
+
* Live service layer for the SDK-backed Effect wrapper.
|
|
653
|
+
*
|
|
654
|
+
* Provides {@link CursorAgentService}, {@link CursorRunService},
|
|
655
|
+
* {@link CursorArtifactService}, and {@link CursorInspectionService} using
|
|
656
|
+
* {@link CursorSdkFactory.Live}.
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* ```ts
|
|
660
|
+
* const result = yield* program.pipe(Effect.provide(liveLayer))
|
|
661
|
+
* ```
|
|
662
|
+
*
|
|
663
|
+
* @see {@link CursorSdkFactory}
|
|
664
|
+
* @see {@link liveRuntime}
|
|
665
|
+
*
|
|
666
|
+
* @category layers
|
|
667
|
+
*/
|
|
668
|
+
declare const liveLayer: Layer.Layer<CursorAgentService | CursorSdkFactory | CursorArtifactService | CursorRunService | CursorInspectionService, never, never>;
|
|
669
|
+
/**
|
|
670
|
+
* Deterministic mock layer for tests and examples.
|
|
671
|
+
*
|
|
672
|
+
* @param fixtures - Static SDK responses returned by the mock factory.
|
|
673
|
+
*
|
|
674
|
+
* @example
|
|
675
|
+
* ```ts
|
|
676
|
+
* const layer = mockLayer({
|
|
677
|
+
* result: { id: "run-1", status: "finished", result: "ok" }
|
|
678
|
+
* })
|
|
679
|
+
* ```
|
|
680
|
+
*
|
|
681
|
+
* @see {@link CursorMockFixtures}
|
|
682
|
+
* @see {@link makeMockSdkFactoryLayer}
|
|
683
|
+
*
|
|
684
|
+
* @category layers
|
|
685
|
+
*/
|
|
686
|
+
declare const mockLayer: (fixtures?: CursorMockFixtures) => Layer.Layer<CursorAgentService | CursorSdkFactory | CursorArtifactService | CursorRunService | CursorInspectionService, never, never>;
|
|
687
|
+
/**
|
|
688
|
+
* Ready-made live runtime.
|
|
689
|
+
*
|
|
690
|
+
* Use this for small scripts that prefer `ManagedRuntime.runPromise` over
|
|
691
|
+
* manually providing {@link liveLayer}.
|
|
692
|
+
*
|
|
693
|
+
* @example
|
|
694
|
+
* ```ts
|
|
695
|
+
* const value = await liveRuntime.runPromise(program)
|
|
696
|
+
* ```
|
|
697
|
+
*
|
|
698
|
+
* @see {@link liveLayer}
|
|
699
|
+
*
|
|
700
|
+
* @category runtimes
|
|
701
|
+
*/
|
|
702
|
+
declare const liveRuntime: ManagedRuntime.ManagedRuntime<CursorAgentService | CursorSdkFactory | CursorArtifactService | CursorRunService | CursorInspectionService, never>;
|
|
703
|
+
/**
|
|
704
|
+
* Ready-made mock runtime.
|
|
705
|
+
*
|
|
706
|
+
* @param fixtures - Static SDK responses returned by the mock services.
|
|
707
|
+
*
|
|
708
|
+
* @example
|
|
709
|
+
* ```ts
|
|
710
|
+
* const runtime = makeMockRuntime({ result: { id: "run-1", status: "finished" } })
|
|
711
|
+
* const value = await runtime.runPromise(program)
|
|
712
|
+
* ```
|
|
713
|
+
*
|
|
714
|
+
* @see {@link mockLayer}
|
|
715
|
+
* @see {@link CursorMockFixtures}
|
|
716
|
+
*
|
|
717
|
+
* @category runtimes
|
|
718
|
+
*/
|
|
719
|
+
declare const makeMockRuntime: (fixtures?: CursorMockFixtures) => ManagedRuntime.ManagedRuntime<CursorAgentService | CursorSdkFactory | CursorArtifactService | CursorRunService | CursorInspectionService, never>;
|
|
720
|
+
//#endregion
|
|
721
|
+
//#region src/cursor-telemetry.d.ts
|
|
722
|
+
/**
|
|
723
|
+
* Increments once when an instrumented SDK effect **starts** execution.
|
|
724
|
+
*
|
|
725
|
+
* Bound to the metric key `cursor_operations_started`. Used by
|
|
726
|
+
* {@link instrument} on every wrapped call; pair with
|
|
727
|
+
* {@link cursorOperationsFailed} to compute failure rates per operation when
|
|
728
|
+
* both counters are exported to your metrics stack.
|
|
729
|
+
*
|
|
730
|
+
* @see {@link instrument}
|
|
731
|
+
* @see {@link cursorOperationsFailed}
|
|
732
|
+
*
|
|
733
|
+
* @category telemetry
|
|
734
|
+
*/
|
|
735
|
+
declare const cursorOperationsStarted: Metric.Counter<number>;
|
|
736
|
+
/**
|
|
737
|
+
* Increments once when an instrumented SDK effect **fails** (any error channel
|
|
738
|
+
* value), after {@link cursorOperationsStarted} has already been recorded for
|
|
739
|
+
* that run.
|
|
740
|
+
*
|
|
741
|
+
* Bound to the metric key `cursor_operations_failed`. Failures are tracked in
|
|
742
|
+
* `Effect.tapError` so the effect still fails with the original error; this
|
|
743
|
+
* counter is observability-only.
|
|
744
|
+
*
|
|
745
|
+
* @see {@link instrument}
|
|
746
|
+
* @see {@link cursorOperationsStarted}
|
|
747
|
+
*
|
|
748
|
+
* @category telemetry
|
|
749
|
+
*/
|
|
750
|
+
declare const cursorOperationsFailed: Metric.Counter<number>;
|
|
751
|
+
/**
|
|
752
|
+
* Counter reserved for **per-message** or **per-chunk** stream throughput.
|
|
753
|
+
*
|
|
754
|
+
* Bound to the metric key `cursor_stream_events`. The service wrappers do not
|
|
755
|
+
* attach this metric automatically to {@link CursorRunService.streamEvents};
|
|
756
|
+
* export it from your app if you want to `Metric.track` inside a
|
|
757
|
+
* `Stream.tapEffect` (or similar) when consuming SDK stream payloads.
|
|
758
|
+
*
|
|
759
|
+
* @see {@link CursorRunService}
|
|
760
|
+
*
|
|
761
|
+
* @category telemetry
|
|
762
|
+
*/
|
|
763
|
+
declare const cursorStreamEvents: Metric.Counter<number>;
|
|
764
|
+
/**
|
|
765
|
+
* Deep-clones **plain** objects and arrays while replacing values under keys that
|
|
766
|
+
* often carry secrets, bearer material, or large opaque blobs (for example API
|
|
767
|
+
* keys, tokens, passwords, cookies, `Authorization`, or a generic `data` field).
|
|
768
|
+
*
|
|
769
|
+
* Matching is **substring-based on the lower-cased key name** (for example
|
|
770
|
+
* `apiKey`, `CURSOR_API_TOKEN`, `client_secret`, `setCookie` all match). Primitives
|
|
771
|
+
* and `null` pass through unchanged. Non-plain objects (for example `Date`, `Map`,
|
|
772
|
+
* class instances) are replaced by `"[opaque]"` so they are not serialized as empty
|
|
773
|
+
* objects. True circular references in the input are replaced by `"[circular]"`.
|
|
774
|
+
* Recursion deeper than 64 levels falls back to `"[opaque]"` for the overflow branch.
|
|
775
|
+
*
|
|
776
|
+
* This is a best-effort redactor for logs and attributes—not a cryptographic
|
|
777
|
+
* guarantee; do not rely on it for compliance redaction without review.
|
|
778
|
+
*
|
|
779
|
+
* @param value - Arbitrary JSON-like value to sanitize.
|
|
780
|
+
* @returns A structure of the same shape with sensitive-looking entries replaced
|
|
781
|
+
* by the string `"[redacted]"`.
|
|
782
|
+
*
|
|
783
|
+
* @example
|
|
784
|
+
* ```ts
|
|
785
|
+
* redact({ apiKey: "secret", nested: { token: "x" }, safe: 1 })
|
|
786
|
+
* // => { apiKey: "[redacted]", nested: { token: "[redacted]" }, safe: 1 }
|
|
787
|
+
* ```
|
|
788
|
+
*
|
|
789
|
+
* @category telemetry
|
|
790
|
+
*/
|
|
791
|
+
declare const redact: (value: unknown) => unknown;
|
|
792
|
+
/**
|
|
793
|
+
* Wraps an SDK-backed {@link Effect.Effect | Effect} with consistent
|
|
794
|
+
* observability: increments {@link cursorOperationsStarted} at execution start,
|
|
795
|
+
* increments {@link cursorOperationsFailed} on the error channel, and attaches
|
|
796
|
+
* a span named `cursor.<operation>` (for example `cursor.agent.list`).
|
|
797
|
+
*
|
|
798
|
+
* The span name is stable and includes the {@link CursorOperation} tag space
|
|
799
|
+
* so traces can be filtered consistently across agent, run, artifact, and
|
|
800
|
+
* inspection APIs.
|
|
801
|
+
*
|
|
802
|
+
* @param operation - Logical SDK operation; must match {@link CursorOperation}
|
|
803
|
+
* for typed error mapping and trace taxonomy.
|
|
804
|
+
* @param effect - The effect produced by `Effect.tryPromise` (or similar)
|
|
805
|
+
* around a single SDK call.
|
|
806
|
+
* @returns The same effect type `Effect<A, E, R>` with metrics and span
|
|
807
|
+
* attached; success and failure values are unchanged.
|
|
808
|
+
*
|
|
809
|
+
* @example
|
|
810
|
+
* ```ts
|
|
811
|
+
* import { Effect } from "effect"
|
|
812
|
+
* import { instrument } from "./cursor-telemetry"
|
|
813
|
+
*
|
|
814
|
+
* const eff = instrument(
|
|
815
|
+
* "agent.get",
|
|
816
|
+
* Effect.tryPromise({
|
|
817
|
+
* try: () => sdk.getAgent(id),
|
|
818
|
+
* catch: (e) => e,
|
|
819
|
+
* }),
|
|
820
|
+
* )
|
|
821
|
+
* ```
|
|
822
|
+
*
|
|
823
|
+
* @see {@link cursorOperationsStarted}
|
|
824
|
+
* @see {@link cursorOperationsFailed}
|
|
825
|
+
* @see {@link CursorOperation}
|
|
826
|
+
*
|
|
827
|
+
* @category telemetry
|
|
828
|
+
*/
|
|
829
|
+
declare const instrument: <A, E, R>(operation: CursorOperation, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
830
|
+
//#endregion
|
|
831
|
+
//#region src/index.d.ts
|
|
832
|
+
/**
|
|
833
|
+
* Public package name.
|
|
834
|
+
*
|
|
835
|
+
* @category metadata
|
|
836
|
+
*/
|
|
837
|
+
declare const packageName = "effect-cursor-sdk";
|
|
838
|
+
//#endregion
|
|
839
|
+
export { type AgentDefinition, type AgentMessage, type AgentOperationOptions, type AgentOptions, AuthenticationError, ConfigurationError, CursorAgentError, CursorAgentPlatform, CursorAgentService, CursorAgentServiceShape, CursorApiKey, CursorArtifactService, CursorArtifactServiceShape, CursorAuthenticationError, CursorConfig, CursorConfigurationError, CursorErrorContext, CursorInspectionService, CursorInspectionServiceShape, CursorIntegrationNotConnectedError, CursorLocalCwd, CursorMockFixtures, CursorModelId, CursorNetworkError, CursorOperation, CursorRateLimitError, type CursorRequestOptions, CursorRunFailedError, CursorRunService, CursorRunServiceShape, CursorSdkFactory, CursorSdkFactoryShape, CursorStreamError, CursorUnknownError, CursorUnsupportedOperationError, type GetAgentMessagesOptions, type GetAgentOptions, type GetRunOptions, IntegrationNotConnectedError, type ListAgentsOptions, type ListResult, type ListRunsOptions, type McpServerConfig, MockCursorAgent, MockCursorRun, type ModelListItem, type ModelParameterDefinition, type ModelParameterValue, type ModelSelection, type ModelVariant, NetworkError, RateLimitError, type Run, type RunOperation, type RunResult, type RunResultStatus, type RunStatus, type SDKAgent, type SDKAgentInfo, type SDKArtifact, type SDKAssistantMessage, type SDKImage, type SDKImageDimension, type SDKMessage, type SDKModel, type SDKRepository, type SDKStatusMessage, type SDKSystemMessage, type SDKTaskMessage, type SDKThinkingMessage, type SDKToolUseMessage, type SDKUser, type SDKUserMessage, type SDKUserMessageEvent, type SendOptions, type SettingSource, type TextBlock, type ToolUseBlock, UnknownAgentError, UnsupportedRunOperationError, agentOptionsFromConfig, createAgentPlatform, createInMemoryRunEventNotifier, createLocalRunEventNotifier, createSdkMessageRunStreamEvent, cursorConfig, cursorOperationsFailed, cursorOperationsStarted, cursorStreamEvents, decodeLocalRunStreamEvent, decodeSdkMessageRunStreamEvent, getTurnType, instrument, isTerminalLocalRunStreamEvent, liveLayer, liveRuntime, loadCursorConfig, localRunStreamEventToSdkMessage, makeMockAgent, makeMockRun, makeMockRuntime, makeMockSdkFactoryLayer, mapCursorError, mockLayer, packageName, redact, startLocalRunEventNotifierServer };
|
|
840
|
+
//# sourceMappingURL=index.d.ts.map
|