effect-cursor-sdk 0.3.1 → 0.4.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.
- package/DEPRECATIONS.md +2 -85
- package/README.md +69 -47
- package/dist/index.d.ts +62 -99
- package/dist/index.js +38 -39
- package/dist/index.js.map +1 -1
- package/docs/RECIPES.md +7 -15
- package/docs/SDK_COVERAGE.md +4 -4
- package/docs/changeset-agent.md +124 -0
- package/package.json +5 -2
- package/docs/MIGRATION_NEXT_MAJOR.md +0 -22
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Config, Context, Effect, Layer, ManagedRuntime, Metric, Option, Redacted, Schedule, 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";
|
|
2
|
+
import { AgentBusyError, 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
3
|
import * as _$effect_Types0 from "effect/Types";
|
|
4
4
|
import * as _$effect_Cause0 from "effect/Cause";
|
|
5
5
|
import * as _$effect_Duration0 from "effect/Duration";
|
|
@@ -59,6 +59,16 @@ declare const CursorConfigurationError_base: new <A extends Record<string, any>
|
|
|
59
59
|
* @category errors
|
|
60
60
|
*/
|
|
61
61
|
declare class CursorConfigurationError extends CursorConfigurationError_base<CursorErrorFields> {}
|
|
62
|
+
declare const CursorAgentBusyError_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 & {
|
|
63
|
+
readonly _tag: "CursorAgentBusyError";
|
|
64
|
+
} & Readonly<A>;
|
|
65
|
+
/**
|
|
66
|
+
* The agent already has an active run; starting another run was rejected (409).
|
|
67
|
+
*
|
|
68
|
+
* @see {@link mapCursorError}
|
|
69
|
+
* @category errors
|
|
70
|
+
*/
|
|
71
|
+
declare class CursorAgentBusyError extends CursorAgentBusyError_base<CursorErrorFields> {}
|
|
62
72
|
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 & {
|
|
63
73
|
readonly _tag: "CursorIntegrationNotConnectedError";
|
|
64
74
|
} & Readonly<A>;
|
|
@@ -154,8 +164,8 @@ declare function mapCursorError(cause: unknown, context: CursorErrorContext & {
|
|
|
154
164
|
}): CursorStreamError;
|
|
155
165
|
declare function mapCursorError(cause: unknown, context: CursorErrorContext & {
|
|
156
166
|
readonly operation: "run.cancel" | "run.conversation";
|
|
157
|
-
}): CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnsupportedOperationError | CursorUnknownError;
|
|
158
|
-
declare function mapCursorError(cause: unknown, context: CursorErrorContext): CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError;
|
|
167
|
+
}): CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnsupportedOperationError | CursorUnknownError;
|
|
168
|
+
declare function mapCursorError(cause: unknown, context: CursorErrorContext): CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError;
|
|
159
169
|
//#endregion
|
|
160
170
|
//#region src/cursor-config.d.ts
|
|
161
171
|
/**
|
|
@@ -196,11 +206,10 @@ declare const CursorConfig_base: Schema.Class<CursorConfig, Schema.Struct<{
|
|
|
196
206
|
* {@link AgentOptions} at the SDK boundary.
|
|
197
207
|
*
|
|
198
208
|
* @remarks
|
|
199
|
-
*
|
|
200
|
-
* `CursorAgentService` methods such as `
|
|
201
|
-
* or merge manually with {@link agentOptionsFromConfig}
|
|
202
|
-
*
|
|
203
|
-
* `scoped` overloads may be removed in a future major version.
|
|
209
|
+
* Load defaults with {@link loadCursorConfig}, then call
|
|
210
|
+
* `CursorAgentService` methods such as `create`, `resume`, `prompt`, and
|
|
211
|
+
* `scoped`, or merge manually with {@link agentOptionsFromConfig} for advanced
|
|
212
|
+
* SDK-factory wiring.
|
|
204
213
|
*
|
|
205
214
|
* @example
|
|
206
215
|
* ```ts
|
|
@@ -244,7 +253,7 @@ declare const cursorConfig: Config.Config<{
|
|
|
244
253
|
* Build SDK `AgentOptions` from wrapper config and optional overrides.
|
|
245
254
|
*
|
|
246
255
|
* This is the adapter from typed, redacted {@link CursorConfig} to the SDK's
|
|
247
|
-
* plain-string `apiKey` boundary. Prefer `CursorAgentService.
|
|
256
|
+
* plain-string `apiKey` boundary. Prefer `CursorAgentService.create`
|
|
248
257
|
* (and related methods) over building {@link AgentOptions} by hand.
|
|
249
258
|
*
|
|
250
259
|
* @param config - Wrapper-owned environment defaults.
|
|
@@ -266,7 +275,7 @@ declare const cursorConfig: Config.Config<{
|
|
|
266
275
|
* @remarks
|
|
267
276
|
* Explicit override values always win over environment-derived defaults.
|
|
268
277
|
* For application code, prefer service methods that take {@link CursorConfig}
|
|
269
|
-
* instead of calling this helper
|
|
278
|
+
* instead of calling this helper directly.
|
|
270
279
|
*
|
|
271
280
|
* @category config
|
|
272
281
|
*/
|
|
@@ -278,7 +287,7 @@ declare const agentOptionsFromConfig: (config: CursorConfig, overrides?: AgentOp
|
|
|
278
287
|
* from {@link cursorConfig}.
|
|
279
288
|
* Omitting `CURSOR_API_KEY` only means no default API-key-based auth will be
|
|
280
289
|
* set; callers can still provide credentials via {@link agentOptionsFromConfig}
|
|
281
|
-
* overrides or the
|
|
290
|
+
* overrides or the config-first service helpers on {@link CursorAgentService}.
|
|
282
291
|
*
|
|
283
292
|
* If the API key is not set, it will log a warning message.
|
|
284
293
|
*
|
|
@@ -289,7 +298,7 @@ declare const agentOptionsFromConfig: (config: CursorConfig, overrides?: AgentOp
|
|
|
289
298
|
* ```ts
|
|
290
299
|
* const config = yield* loadCursorConfig
|
|
291
300
|
* const options = agentOptionsFromConfig(config, { local: { cwd: process.cwd() } })
|
|
292
|
-
* // Or use CursorAgentService.
|
|
301
|
+
* // Or use CursorAgentService.create(config, { local: { cwd: process.cwd() } })
|
|
293
302
|
* ```
|
|
294
303
|
*
|
|
295
304
|
* To change the way that the environment variables are loaded,
|
|
@@ -317,7 +326,7 @@ declare const agentOptionsFromConfig: (config: CursorConfig, overrides?: AgentOp
|
|
|
317
326
|
* @remarks
|
|
318
327
|
* This effect is the preferred entry for redacted environment defaults.
|
|
319
328
|
* Pair it with {@link agentOptionsFromConfig} or `CursorAgentService` helpers
|
|
320
|
-
* such as `
|
|
329
|
+
* such as `create`, `resume`, `prompt`, and `scoped`.
|
|
321
330
|
*
|
|
322
331
|
* @category config
|
|
323
332
|
*/
|
|
@@ -354,29 +363,19 @@ declare const loadCursorConfig: Effect.Effect<CursorConfig, Config.ConfigError,
|
|
|
354
363
|
* @see {@link CursorArtifactService} for artifact APIs on an SDK agent.
|
|
355
364
|
*
|
|
356
365
|
* @remarks
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
* This factory remains the low-level adapter for tests and advanced overrides.
|
|
366
|
+
* Application code should use {@link CursorAgentService} with
|
|
367
|
+
* {@link loadCursorConfig} and config-first `create` / `resume` / `prompt` /
|
|
368
|
+
* `scoped` helpers. This factory remains the low-level adapter for tests and
|
|
369
|
+
* advanced overrides.
|
|
362
370
|
*
|
|
363
371
|
* @category services
|
|
364
372
|
*/
|
|
365
373
|
interface CursorSdkFactoryShape {
|
|
366
|
-
/**
|
|
367
|
-
* @deprecated Prefer {@link CursorAgentService} with config-based helpers.
|
|
368
|
-
* Low-level adapter to `Agent.create`.
|
|
369
|
-
*/
|
|
374
|
+
/** Low-level adapter to `Agent.create`. */
|
|
370
375
|
readonly create: (options: AgentOptions) => Promise<SDKAgent>;
|
|
371
|
-
/**
|
|
372
|
-
* @deprecated Prefer {@link CursorAgentService} with config-based helpers.
|
|
373
|
-
* Low-level adapter to `Agent.resume`.
|
|
374
|
-
*/
|
|
376
|
+
/** Low-level adapter to `Agent.resume`. */
|
|
375
377
|
readonly resume: (agentId: string, options?: Partial<AgentOptions>) => Promise<SDKAgent>;
|
|
376
|
-
/**
|
|
377
|
-
* @deprecated Prefer {@link CursorAgentService} with config-based helpers.
|
|
378
|
-
* Low-level adapter to `Agent.prompt`.
|
|
379
|
-
*/
|
|
378
|
+
/** Low-level adapter to `Agent.prompt`. */
|
|
380
379
|
readonly prompt: (message: string, options?: AgentOptions) => Promise<RunResult>;
|
|
381
380
|
readonly listAgents: (options?: ListAgentsOptions) => Promise<ListResult<SDKAgentInfo>>;
|
|
382
381
|
readonly listRuns: (agentId: string, options?: ListRunsOptions) => Promise<ListResult<Run>>;
|
|
@@ -422,80 +421,46 @@ declare class CursorSdkFactory extends CursorSdkFactory_base {
|
|
|
422
421
|
* Agent lifecycle surface backed by the Cursor SDK.
|
|
423
422
|
*
|
|
424
423
|
* @remarks
|
|
425
|
-
*
|
|
426
|
-
* {@link CursorAgentServiceShape.
|
|
427
|
-
* {@link CursorAgentServiceShape.
|
|
428
|
-
* {@link CursorAgentServiceShape.
|
|
424
|
+
* Use {@link loadCursorConfig} with {@link CursorAgentServiceShape.create},
|
|
425
|
+
* {@link CursorAgentServiceShape.resume},
|
|
426
|
+
* {@link CursorAgentServiceShape.prompt}, and
|
|
427
|
+
* {@link CursorAgentServiceShape.scoped}
|
|
429
428
|
* so secrets stay in `Redacted` form until {@link agentOptionsFromConfig}
|
|
430
|
-
* merges into SDK {@link AgentOptions}
|
|
431
|
-
* are deprecated; see `DEPRECATIONS.md` and the README at the package root.
|
|
429
|
+
* merges into SDK {@link AgentOptions} at the SDK boundary.
|
|
432
430
|
*/
|
|
433
431
|
interface CursorAgentServiceShape {
|
|
434
|
-
/**
|
|
435
|
-
* @deprecated Prefer {@link CursorAgentServiceShape.createFromConfig} with {@link loadCursorConfig}
|
|
436
|
-
* instead of raw {@link AgentOptions} (including a plain `apiKey` string). Next major: `createFromConfig`
|
|
437
|
-
* is planned to become `create` with the same parameters.
|
|
438
|
-
*/
|
|
439
|
-
readonly create: (options: AgentOptions) => Effect.Effect<SDKAgent, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
440
432
|
/**
|
|
441
433
|
* Create an agent from {@link CursorConfig} and optional SDK overrides.
|
|
442
434
|
*
|
|
443
|
-
* @remarks
|
|
444
|
-
* Next major: planned rename to `create` with the same signature once plain-`AgentOptions` entry points are removed.
|
|
445
|
-
*
|
|
446
435
|
* @see {@link loadCursorConfig}
|
|
447
436
|
* @see {@link agentOptionsFromConfig}
|
|
448
437
|
*/
|
|
449
|
-
readonly
|
|
450
|
-
/**
|
|
451
|
-
* @deprecated Prefer {@link CursorAgentServiceShape.resumeFromConfig} with {@link loadCursorConfig}
|
|
452
|
-
* instead of raw {@link AgentOptions}. Next major: `resumeFromConfig` is planned to become `resume` with the same parameters.
|
|
453
|
-
*/
|
|
454
|
-
readonly resume: (agentId: string, options?: Partial<AgentOptions>) => Effect.Effect<SDKAgent, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
438
|
+
readonly create: (config: CursorConfig, overrides?: AgentOptions) => Effect.Effect<SDKAgent, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
455
439
|
/**
|
|
456
440
|
* Resume an agent from {@link CursorConfig} and optional SDK overrides.
|
|
457
441
|
*
|
|
458
|
-
* @remarks
|
|
459
|
-
* Next major: planned rename to `resume` with the same signature once plain-`AgentOptions` entry points are removed.
|
|
460
|
-
*
|
|
461
442
|
* @see {@link loadCursorConfig}
|
|
462
443
|
* @see {@link agentOptionsFromConfig}
|
|
463
444
|
*/
|
|
464
|
-
readonly
|
|
465
|
-
/**
|
|
466
|
-
* @deprecated Prefer {@link CursorAgentServiceShape.promptFromConfig} with {@link loadCursorConfig}
|
|
467
|
-
* instead of raw {@link AgentOptions}. Next major: `promptFromConfig` is planned to become `prompt` with the same parameters.
|
|
468
|
-
*/
|
|
469
|
-
readonly prompt: (message: string, options?: AgentOptions) => Effect.Effect<RunResult, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
445
|
+
readonly resume: (agentId: string, config: CursorConfig, overrides?: AgentOptions) => Effect.Effect<SDKAgent, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
470
446
|
/**
|
|
471
447
|
* One-shot prompt from {@link CursorConfig} and optional SDK overrides.
|
|
472
448
|
*
|
|
473
|
-
* @remarks
|
|
474
|
-
* Next major: planned rename to `prompt` with the same signature once plain-`AgentOptions` entry points are removed.
|
|
475
|
-
*
|
|
476
449
|
* @see {@link loadCursorConfig}
|
|
477
450
|
* @see {@link agentOptionsFromConfig}
|
|
478
451
|
*/
|
|
479
|
-
readonly
|
|
480
|
-
readonly send: (agent: SDKAgent, message: string | SDKUserMessage, options?: SendOptions) => Effect.Effect<Run, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
481
|
-
readonly reload: (agent: SDKAgent) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
452
|
+
readonly prompt: (message: string, config: CursorConfig, overrides?: AgentOptions) => Effect.Effect<RunResult, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
453
|
+
readonly send: (agent: SDKAgent, message: string | SDKUserMessage, options?: SendOptions) => Effect.Effect<Run, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
454
|
+
readonly reload: (agent: SDKAgent) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
482
455
|
readonly close: (agent: SDKAgent) => Effect.Effect<void>;
|
|
483
|
-
readonly dispose: (agent: SDKAgent) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
484
|
-
/**
|
|
485
|
-
* @deprecated Prefer {@link CursorAgentServiceShape.scopedFromConfig} with {@link loadCursorConfig}
|
|
486
|
-
* instead of raw {@link AgentOptions}. Next major: `scopedFromConfig` is planned to become `scoped` with the same parameters.
|
|
487
|
-
*/
|
|
488
|
-
readonly scoped: (options: AgentOptions) => Effect.Effect<SDKAgent, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError, Scope.Scope>;
|
|
456
|
+
readonly dispose: (agent: SDKAgent) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
489
457
|
/**
|
|
490
458
|
* Acquire an agent in a scope from {@link CursorConfig} and optional SDK overrides.
|
|
491
459
|
*
|
|
492
|
-
* @remarks
|
|
493
|
-
* Next major: planned rename to `scoped` with the same signature once plain-`AgentOptions` entry points are removed.
|
|
494
|
-
*
|
|
495
460
|
* @see {@link loadCursorConfig}
|
|
496
461
|
* @see {@link agentOptionsFromConfig}
|
|
497
462
|
*/
|
|
498
|
-
readonly
|
|
463
|
+
readonly scoped: (config: CursorConfig, overrides?: AgentOptions) => Effect.Effect<SDKAgent, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError, Scope.Scope>;
|
|
499
464
|
}
|
|
500
465
|
declare const CursorAgentService_base: Context.ServiceClass<CursorAgentService, "effect-cursor-sdk/cursor-agent/CursorAgentService", CursorAgentServiceShape>;
|
|
501
466
|
/**
|
|
@@ -513,7 +478,7 @@ declare const CursorAgentService_base: Context.ServiceClass<CursorAgentService,
|
|
|
513
478
|
* const program = Effect.gen(function*() {
|
|
514
479
|
* const agents = yield* CursorAgentService
|
|
515
480
|
* const config = yield* loadCursorConfig
|
|
516
|
-
* const agent = yield* agents.
|
|
481
|
+
* const agent = yield* agents.create(config, {
|
|
517
482
|
* model: { id: "composer-2" },
|
|
518
483
|
* local: { cwd: process.cwd() },
|
|
519
484
|
* })
|
|
@@ -525,11 +490,9 @@ declare const CursorAgentService_base: Context.ServiceClass<CursorAgentService,
|
|
|
525
490
|
* @see {@link CursorSdkFactory} for replacing SDK construction in tests.
|
|
526
491
|
*
|
|
527
492
|
* @remarks
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
* {@link CursorAgentServiceShape.
|
|
531
|
-
* See `DEPRECATIONS.md` at the package root for migration and planned next-major renames
|
|
532
|
-
* (`createFromConfig` → `create`, etc.).
|
|
493
|
+
* Load defaults with {@link loadCursorConfig}, then call {@link CursorAgentServiceShape.create},
|
|
494
|
+
* {@link CursorAgentServiceShape.resume}, {@link CursorAgentServiceShape.prompt}, or
|
|
495
|
+
* {@link CursorAgentServiceShape.scoped} with optional SDK overrides.
|
|
533
496
|
*
|
|
534
497
|
* @category services
|
|
535
498
|
*/
|
|
@@ -539,8 +502,8 @@ declare class CursorAgentService extends CursorAgentService_base {
|
|
|
539
502
|
//#endregion
|
|
540
503
|
//#region src/cursor-artifacts.d.ts
|
|
541
504
|
interface CursorArtifactServiceShape {
|
|
542
|
-
readonly listArtifacts: (agent: SDKAgent) => Effect.Effect<SDKArtifact[], CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
543
|
-
readonly downloadArtifact: (agent: SDKAgent, path: string) => Effect.Effect<Buffer, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
505
|
+
readonly listArtifacts: (agent: SDKAgent) => Effect.Effect<SDKArtifact[], CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
506
|
+
readonly downloadArtifact: (agent: SDKAgent, path: string) => Effect.Effect<Buffer, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
544
507
|
}
|
|
545
508
|
declare const CursorArtifactService_base: Context.ServiceClass<CursorArtifactService, "effect-cursor-sdk/cursor-artifacts/CursorArtifactService", CursorArtifactServiceShape>;
|
|
546
509
|
/**
|
|
@@ -563,17 +526,17 @@ declare class CursorArtifactService extends CursorArtifactService_base {
|
|
|
563
526
|
//#endregion
|
|
564
527
|
//#region src/cursor-inspection.d.ts
|
|
565
528
|
interface CursorInspectionServiceShape {
|
|
566
|
-
readonly listAgents: (options?: ListAgentsOptions) => Effect.Effect<ListResult<SDKAgentInfo>, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
567
|
-
readonly getAgent: (agentId: string, options?: GetAgentOptions) => Effect.Effect<SDKAgentInfo, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
568
|
-
readonly archiveAgent: (agentId: string, options?: AgentOperationOptions) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
569
|
-
readonly unarchiveAgent: (agentId: string, options?: AgentOperationOptions) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
570
|
-
readonly deleteAgent: (agentId: string, options?: AgentOperationOptions) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
571
|
-
readonly listRuns: (agentId: string, options?: ListRunsOptions) => Effect.Effect<ListResult<Run>, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
572
|
-
readonly getRun: (runId: string, options?: GetRunOptions) => Effect.Effect<Run, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
573
|
-
readonly listMessages: (agentId: string, options?: GetAgentMessagesOptions) => Effect.Effect<AgentMessage[], CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
574
|
-
readonly me: (options?: CursorRequestOptions) => Effect.Effect<SDKUser, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
575
|
-
readonly listModels: (options?: CursorRequestOptions) => Effect.Effect<SDKModel[], CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
576
|
-
readonly listRepositories: (options?: CursorRequestOptions) => Effect.Effect<SDKRepository[], CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
529
|
+
readonly listAgents: (options?: ListAgentsOptions) => Effect.Effect<ListResult<SDKAgentInfo>, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
530
|
+
readonly getAgent: (agentId: string, options?: GetAgentOptions) => Effect.Effect<SDKAgentInfo, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
531
|
+
readonly archiveAgent: (agentId: string, options?: AgentOperationOptions) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
532
|
+
readonly unarchiveAgent: (agentId: string, options?: AgentOperationOptions) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
533
|
+
readonly deleteAgent: (agentId: string, options?: AgentOperationOptions) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
534
|
+
readonly listRuns: (agentId: string, options?: ListRunsOptions) => Effect.Effect<ListResult<Run>, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
535
|
+
readonly getRun: (runId: string, options?: GetRunOptions) => Effect.Effect<Run, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
536
|
+
readonly listMessages: (agentId: string, options?: GetAgentMessagesOptions) => Effect.Effect<AgentMessage[], CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
537
|
+
readonly me: (options?: CursorRequestOptions) => Effect.Effect<SDKUser, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
538
|
+
readonly listModels: (options?: CursorRequestOptions) => Effect.Effect<SDKModel[], CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
539
|
+
readonly listRepositories: (options?: CursorRequestOptions) => Effect.Effect<SDKRepository[], CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
577
540
|
}
|
|
578
541
|
declare const CursorInspectionService_base: Context.ServiceClass<CursorInspectionService, "effect-cursor-sdk/cursor-inspection/CursorInspectionService", CursorInspectionServiceShape>;
|
|
579
542
|
/**
|
|
@@ -906,9 +869,9 @@ declare const summarizeRunForLog: (run: {
|
|
|
906
869
|
interface CursorRunServiceShape {
|
|
907
870
|
readonly supports: (run: Run, operation: RunOperation) => boolean;
|
|
908
871
|
readonly unsupportedReason: (run: Run, operation: RunOperation) => string | undefined;
|
|
909
|
-
readonly wait: (run: Run) => Effect.Effect<RunResult, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnknownError>;
|
|
910
|
-
readonly cancel: (run: Run) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnsupportedOperationError | CursorUnknownError>;
|
|
911
|
-
readonly conversation: (run: Run) => ReturnType<Run["conversation"]> extends Promise<infer A> ? Effect.Effect<A, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorNetworkError | CursorUnsupportedOperationError | CursorUnknownError> : never;
|
|
872
|
+
readonly wait: (run: Run) => Effect.Effect<RunResult, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnknownError>;
|
|
873
|
+
readonly cancel: (run: Run) => Effect.Effect<void, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnsupportedOperationError | CursorUnknownError>;
|
|
874
|
+
readonly conversation: (run: Run) => ReturnType<Run["conversation"]> extends Promise<infer A> ? Effect.Effect<A, CursorAuthenticationError | CursorRateLimitError | CursorIntegrationNotConnectedError | CursorConfigurationError | CursorAgentBusyError | CursorNetworkError | CursorUnsupportedOperationError | CursorUnknownError> : never;
|
|
912
875
|
readonly streamEvents: (run: Run) => Stream.Stream<SDKMessage, CursorStreamError>;
|
|
913
876
|
readonly collectText: (run: Run) => Effect.Effect<string, CursorStreamError>;
|
|
914
877
|
readonly onDidChangeStatus: (run: Run, listener: (status: RunStatus) => void) => Effect.Effect<() => void>;
|
|
@@ -1135,5 +1098,5 @@ declare const instrument: <A, E, R>(operation: CursorOperation, effect: Effect.E
|
|
|
1135
1098
|
*/
|
|
1136
1099
|
declare const packageName = "effect-cursor-sdk";
|
|
1137
1100
|
//#endregion
|
|
1138
|
-
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, CursorMockFactoryMethod, 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, appendAssistantSdkMessageText, collectTextTracked, createAgentPlatform, createInMemoryRunEventNotifier, createLocalRunEventNotifier, createSdkMessageRunStreamEvent, cursorCatalogLoadTimeout, cursorCatalogRetrySchedule, cursorConfig, cursorOperationsFailed, cursorOperationsStarted, cursorStreamEvents, decodeLocalRunStreamEvent, decodeSdkMessageRunStreamEvent, getTurnType, instrument, isTerminalLocalRunStreamEvent, liveLayer, liveRuntime, loadCursorConfig, localRunStreamEventToSdkMessage, makeMockAgent, makeMockAssistantSdkMessage, makeMockRun, makeMockRuntime, makeMockSdkFactoryLayer, mapCursorError, mockLayer, packageName, redact, startLocalRunEventNotifierServer, streamEventsTracked, summarizeAgentOptionsForLog, summarizeRunForLog };
|
|
1101
|
+
export { AgentBusyError, type AgentDefinition, type AgentMessage, type AgentOperationOptions, type AgentOptions, AuthenticationError, ConfigurationError, CursorAgentBusyError, CursorAgentError, CursorAgentPlatform, CursorAgentService, CursorAgentServiceShape, CursorApiKey, CursorArtifactService, CursorArtifactServiceShape, CursorAuthenticationError, CursorConfig, CursorConfigurationError, CursorErrorContext, CursorInspectionService, CursorInspectionServiceShape, CursorIntegrationNotConnectedError, CursorLocalCwd, CursorMockFactoryMethod, 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, appendAssistantSdkMessageText, collectTextTracked, createAgentPlatform, createInMemoryRunEventNotifier, createLocalRunEventNotifier, createSdkMessageRunStreamEvent, cursorCatalogLoadTimeout, cursorCatalogRetrySchedule, cursorConfig, cursorOperationsFailed, cursorOperationsStarted, cursorStreamEvents, decodeLocalRunStreamEvent, decodeSdkMessageRunStreamEvent, getTurnType, instrument, isTerminalLocalRunStreamEvent, liveLayer, liveRuntime, loadCursorConfig, localRunStreamEventToSdkMessage, makeMockAgent, makeMockAssistantSdkMessage, makeMockRun, makeMockRuntime, makeMockSdkFactoryLayer, mapCursorError, mockLayer, packageName, redact, startLocalRunEventNotifierServer, streamEventsTracked, summarizeAgentOptionsForLog, summarizeRunForLog };
|
|
1139
1102
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Config, ConfigProvider, Context, Data, Effect, Layer, ManagedRuntime, Match, Metric, Option, Redacted, Schedule, Schema, Stream } from "effect";
|
|
2
|
-
import { Agent, AuthenticationError, AuthenticationError as AuthenticationError$1, ConfigurationError, ConfigurationError as ConfigurationError$1, Cursor, CursorAgentError, CursorAgentError as CursorAgentError$1, CursorAgentPlatform, IntegrationNotConnectedError, IntegrationNotConnectedError as IntegrationNotConnectedError$1, NetworkError, NetworkError as NetworkError$1, RateLimitError, RateLimitError as RateLimitError$1, UnknownAgentError, UnknownAgentError as UnknownAgentError$1, UnsupportedRunOperationError, UnsupportedRunOperationError as UnsupportedRunOperationError$1, createAgentPlatform, createInMemoryRunEventNotifier, createLocalRunEventNotifier, createSdkMessageRunStreamEvent, decodeLocalRunStreamEvent, decodeSdkMessageRunStreamEvent, getTurnType, isTerminalLocalRunStreamEvent, localRunStreamEventToSdkMessage, startLocalRunEventNotifierServer } from "@cursor/sdk";
|
|
2
|
+
import { Agent, AgentBusyError, AgentBusyError as AgentBusyError$1, AuthenticationError, AuthenticationError as AuthenticationError$1, ConfigurationError, ConfigurationError as ConfigurationError$1, Cursor, CursorAgentError, CursorAgentError as CursorAgentError$1, CursorAgentPlatform, IntegrationNotConnectedError, IntegrationNotConnectedError as IntegrationNotConnectedError$1, NetworkError, NetworkError as NetworkError$1, RateLimitError, RateLimitError as RateLimitError$1, UnknownAgentError, UnknownAgentError as UnknownAgentError$1, UnsupportedRunOperationError, UnsupportedRunOperationError as UnsupportedRunOperationError$1, createAgentPlatform, createInMemoryRunEventNotifier, createLocalRunEventNotifier, createSdkMessageRunStreamEvent, decodeLocalRunStreamEvent, decodeSdkMessageRunStreamEvent, getTurnType, isTerminalLocalRunStreamEvent, localRunStreamEventToSdkMessage, startLocalRunEventNotifierServer } from "@cursor/sdk";
|
|
3
3
|
//#region src/cursor-error.ts
|
|
4
4
|
/**
|
|
5
5
|
* Authentication or permission failure reported by the Cursor SDK.
|
|
@@ -24,6 +24,13 @@ var CursorRateLimitError = class extends Data.TaggedError("CursorRateLimitError"
|
|
|
24
24
|
*/
|
|
25
25
|
var CursorConfigurationError = class extends Data.TaggedError("CursorConfigurationError") {};
|
|
26
26
|
/**
|
|
27
|
+
* The agent already has an active run; starting another run was rejected (409).
|
|
28
|
+
*
|
|
29
|
+
* @see {@link mapCursorError}
|
|
30
|
+
* @category errors
|
|
31
|
+
*/
|
|
32
|
+
var CursorAgentBusyError = class extends Data.TaggedError("CursorAgentBusyError") {};
|
|
33
|
+
/**
|
|
27
34
|
* SCM integration is not connected for a requested cloud repository.
|
|
28
35
|
*
|
|
29
36
|
* @see {@link mapCursorError}
|
|
@@ -98,6 +105,8 @@ function mapCursorError(cause, context) {
|
|
|
98
105
|
});
|
|
99
106
|
}), Match.when(Match.instanceOf(ConfigurationError$1), () => {
|
|
100
107
|
return new CursorConfigurationError(fields);
|
|
108
|
+
}), Match.when(Match.instanceOf(AgentBusyError$1), () => {
|
|
109
|
+
return new CursorAgentBusyError(fields);
|
|
101
110
|
}), Match.when(Match.instanceOf(NetworkError$1), () => {
|
|
102
111
|
return new CursorNetworkError(fields);
|
|
103
112
|
}), Match.when(Match.instanceOf(UnknownAgentError$1), () => {
|
|
@@ -140,11 +149,10 @@ const CursorLocalCwd = Schema.String.pipe(Schema.brand("CursorLocalCwd"));
|
|
|
140
149
|
* {@link AgentOptions} at the SDK boundary.
|
|
141
150
|
*
|
|
142
151
|
* @remarks
|
|
143
|
-
*
|
|
144
|
-
* `CursorAgentService` methods such as `
|
|
145
|
-
* or merge manually with {@link agentOptionsFromConfig}
|
|
146
|
-
*
|
|
147
|
-
* `scoped` overloads may be removed in a future major version.
|
|
152
|
+
* Load defaults with {@link loadCursorConfig}, then call
|
|
153
|
+
* `CursorAgentService` methods such as `create`, `resume`, `prompt`, and
|
|
154
|
+
* `scoped`, or merge manually with {@link agentOptionsFromConfig} for advanced
|
|
155
|
+
* SDK-factory wiring.
|
|
148
156
|
*
|
|
149
157
|
* @example
|
|
150
158
|
* ```ts
|
|
@@ -192,7 +200,7 @@ const cursorConfig = Config.all({
|
|
|
192
200
|
* Build SDK `AgentOptions` from wrapper config and optional overrides.
|
|
193
201
|
*
|
|
194
202
|
* This is the adapter from typed, redacted {@link CursorConfig} to the SDK's
|
|
195
|
-
* plain-string `apiKey` boundary. Prefer `CursorAgentService.
|
|
203
|
+
* plain-string `apiKey` boundary. Prefer `CursorAgentService.create`
|
|
196
204
|
* (and related methods) over building {@link AgentOptions} by hand.
|
|
197
205
|
*
|
|
198
206
|
* @param config - Wrapper-owned environment defaults.
|
|
@@ -214,7 +222,7 @@ const cursorConfig = Config.all({
|
|
|
214
222
|
* @remarks
|
|
215
223
|
* Explicit override values always win over environment-derived defaults.
|
|
216
224
|
* For application code, prefer service methods that take {@link CursorConfig}
|
|
217
|
-
* instead of calling this helper
|
|
225
|
+
* instead of calling this helper directly.
|
|
218
226
|
*
|
|
219
227
|
* @category config
|
|
220
228
|
*/
|
|
@@ -239,7 +247,7 @@ const agentOptionsFromConfig = (config, overrides = {}) => {
|
|
|
239
247
|
* from {@link cursorConfig}.
|
|
240
248
|
* Omitting `CURSOR_API_KEY` only means no default API-key-based auth will be
|
|
241
249
|
* set; callers can still provide credentials via {@link agentOptionsFromConfig}
|
|
242
|
-
* overrides or the
|
|
250
|
+
* overrides or the config-first service helpers on {@link CursorAgentService}.
|
|
243
251
|
*
|
|
244
252
|
* If the API key is not set, it will log a warning message.
|
|
245
253
|
*
|
|
@@ -250,7 +258,7 @@ const agentOptionsFromConfig = (config, overrides = {}) => {
|
|
|
250
258
|
* ```ts
|
|
251
259
|
* const config = yield* loadCursorConfig
|
|
252
260
|
* const options = agentOptionsFromConfig(config, { local: { cwd: process.cwd() } })
|
|
253
|
-
* // Or use CursorAgentService.
|
|
261
|
+
* // Or use CursorAgentService.create(config, { local: { cwd: process.cwd() } })
|
|
254
262
|
* ```
|
|
255
263
|
*
|
|
256
264
|
* To change the way that the environment variables are loaded,
|
|
@@ -278,7 +286,7 @@ const agentOptionsFromConfig = (config, overrides = {}) => {
|
|
|
278
286
|
* @remarks
|
|
279
287
|
* This effect is the preferred entry for redacted environment defaults.
|
|
280
288
|
* Pair it with {@link agentOptionsFromConfig} or `CursorAgentService` helpers
|
|
281
|
-
* such as `
|
|
289
|
+
* such as `create`, `resume`, `prompt`, and `scoped`.
|
|
282
290
|
*
|
|
283
291
|
* @category config
|
|
284
292
|
*/
|
|
@@ -560,7 +568,7 @@ const instrument = (operation, effect) => {
|
|
|
560
568
|
* const program = Effect.gen(function*() {
|
|
561
569
|
* const agents = yield* CursorAgentService
|
|
562
570
|
* const config = yield* loadCursorConfig
|
|
563
|
-
* const agent = yield* agents.
|
|
571
|
+
* const agent = yield* agents.create(config, {
|
|
564
572
|
* model: { id: "composer-2" },
|
|
565
573
|
* local: { cwd: process.cwd() },
|
|
566
574
|
* })
|
|
@@ -572,18 +580,16 @@ const instrument = (operation, effect) => {
|
|
|
572
580
|
* @see {@link CursorSdkFactory} for replacing SDK construction in tests.
|
|
573
581
|
*
|
|
574
582
|
* @remarks
|
|
575
|
-
*
|
|
576
|
-
*
|
|
577
|
-
* {@link CursorAgentServiceShape.
|
|
578
|
-
* See `DEPRECATIONS.md` at the package root for migration and planned next-major renames
|
|
579
|
-
* (`createFromConfig` → `create`, etc.).
|
|
583
|
+
* Load defaults with {@link loadCursorConfig}, then call {@link CursorAgentServiceShape.create},
|
|
584
|
+
* {@link CursorAgentServiceShape.resume}, {@link CursorAgentServiceShape.prompt}, or
|
|
585
|
+
* {@link CursorAgentServiceShape.scoped} with optional SDK overrides.
|
|
580
586
|
*
|
|
581
587
|
* @category services
|
|
582
588
|
*/
|
|
583
589
|
var CursorAgentService = class CursorAgentService extends Context.Service()("effect-cursor-sdk/cursor-agent/CursorAgentService") {
|
|
584
590
|
static Live = Layer.effect(CursorAgentService)(Effect.gen(function* () {
|
|
585
591
|
const sdk = yield* CursorSdkFactory;
|
|
586
|
-
const
|
|
592
|
+
const createWithOptions = (options) => {
|
|
587
593
|
return instrument("agent.create", Effect.tryPromise({
|
|
588
594
|
try: () => sdk.create(options),
|
|
589
595
|
catch: (cause) => {
|
|
@@ -591,7 +597,7 @@ var CursorAgentService = class CursorAgentService extends Context.Service()("eff
|
|
|
591
597
|
}
|
|
592
598
|
}));
|
|
593
599
|
};
|
|
594
|
-
const
|
|
600
|
+
const resumeWithOptions = (agentId, options) => {
|
|
595
601
|
return instrument("agent.resume", Effect.tryPromise({
|
|
596
602
|
try: () => sdk.resume(agentId, options),
|
|
597
603
|
catch: (cause) => {
|
|
@@ -602,7 +608,7 @@ var CursorAgentService = class CursorAgentService extends Context.Service()("eff
|
|
|
602
608
|
}
|
|
603
609
|
}));
|
|
604
610
|
};
|
|
605
|
-
const
|
|
611
|
+
const promptWithOptions = (message, options) => {
|
|
606
612
|
return instrument("agent.prompt", Effect.tryPromise({
|
|
607
613
|
try: () => sdk.prompt(message, options),
|
|
608
614
|
catch: (cause) => {
|
|
@@ -646,36 +652,29 @@ var CursorAgentService = class CursorAgentService extends Context.Service()("eff
|
|
|
646
652
|
}
|
|
647
653
|
}));
|
|
648
654
|
};
|
|
649
|
-
const
|
|
650
|
-
return
|
|
651
|
-
return Effect.ignore(dispose(agent));
|
|
652
|
-
});
|
|
653
|
-
};
|
|
654
|
-
const createFromConfig = (config, overrides = {}) => {
|
|
655
|
-
return create(agentOptionsFromConfig(config, overrides));
|
|
655
|
+
const create = (config, overrides = {}) => {
|
|
656
|
+
return createWithOptions(agentOptionsFromConfig(config, overrides));
|
|
656
657
|
};
|
|
657
|
-
const
|
|
658
|
-
return
|
|
658
|
+
const resume = (agentId, config, overrides = {}) => {
|
|
659
|
+
return resumeWithOptions(agentId, agentOptionsFromConfig(config, overrides));
|
|
659
660
|
};
|
|
660
|
-
const
|
|
661
|
-
return
|
|
661
|
+
const prompt = (message, config, overrides = {}) => {
|
|
662
|
+
return promptWithOptions(message, agentOptionsFromConfig(config, overrides));
|
|
662
663
|
};
|
|
663
|
-
const
|
|
664
|
-
return
|
|
664
|
+
const scoped = (config, overrides = {}) => {
|
|
665
|
+
return Effect.acquireRelease(createWithOptions(agentOptionsFromConfig(config, overrides)), (agent) => {
|
|
666
|
+
return Effect.ignore(dispose(agent));
|
|
667
|
+
});
|
|
665
668
|
};
|
|
666
669
|
return {
|
|
667
670
|
create,
|
|
668
|
-
createFromConfig,
|
|
669
671
|
resume,
|
|
670
|
-
resumeFromConfig,
|
|
671
672
|
prompt,
|
|
672
|
-
promptFromConfig,
|
|
673
673
|
send,
|
|
674
674
|
reload,
|
|
675
675
|
close,
|
|
676
676
|
dispose,
|
|
677
|
-
scoped
|
|
678
|
-
scopedFromConfig
|
|
677
|
+
scoped
|
|
679
678
|
};
|
|
680
679
|
}));
|
|
681
680
|
};
|
|
@@ -1532,6 +1531,6 @@ const makeMockRuntime = (fixtures = {}) => {
|
|
|
1532
1531
|
*/
|
|
1533
1532
|
const packageName = "effect-cursor-sdk";
|
|
1534
1533
|
//#endregion
|
|
1535
|
-
export { AuthenticationError, ConfigurationError, CursorAgentError, CursorAgentPlatform, CursorAgentService, CursorApiKey, CursorArtifactService, CursorAuthenticationError, CursorConfig, CursorConfigurationError, CursorInspectionService, CursorIntegrationNotConnectedError, CursorLocalCwd, CursorModelId, CursorNetworkError, CursorRateLimitError, CursorRunFailedError, CursorRunService, CursorSdkFactory, CursorStreamError, CursorUnknownError, CursorUnsupportedOperationError, IntegrationNotConnectedError, MockCursorAgent, MockCursorRun, NetworkError, RateLimitError, UnknownAgentError, UnsupportedRunOperationError, agentOptionsFromConfig, appendAssistantSdkMessageText, collectTextTracked, createAgentPlatform, createInMemoryRunEventNotifier, createLocalRunEventNotifier, createSdkMessageRunStreamEvent, cursorCatalogLoadTimeout, cursorCatalogRetrySchedule, cursorConfig, cursorOperationsFailed, cursorOperationsStarted, cursorStreamEvents, decodeLocalRunStreamEvent, decodeSdkMessageRunStreamEvent, getTurnType, instrument, isTerminalLocalRunStreamEvent, liveLayer, liveRuntime, loadCursorConfig, localRunStreamEventToSdkMessage, makeMockAgent, makeMockAssistantSdkMessage, makeMockRun, makeMockRuntime, makeMockSdkFactoryLayer, mapCursorError, mockLayer, packageName, redact, startLocalRunEventNotifierServer, streamEventsTracked, summarizeAgentOptionsForLog, summarizeRunForLog };
|
|
1534
|
+
export { AgentBusyError, AuthenticationError, ConfigurationError, CursorAgentBusyError, CursorAgentError, CursorAgentPlatform, CursorAgentService, CursorApiKey, CursorArtifactService, CursorAuthenticationError, CursorConfig, CursorConfigurationError, CursorInspectionService, CursorIntegrationNotConnectedError, CursorLocalCwd, CursorModelId, CursorNetworkError, CursorRateLimitError, CursorRunFailedError, CursorRunService, CursorSdkFactory, CursorStreamError, CursorUnknownError, CursorUnsupportedOperationError, IntegrationNotConnectedError, MockCursorAgent, MockCursorRun, NetworkError, RateLimitError, UnknownAgentError, UnsupportedRunOperationError, agentOptionsFromConfig, appendAssistantSdkMessageText, collectTextTracked, createAgentPlatform, createInMemoryRunEventNotifier, createLocalRunEventNotifier, createSdkMessageRunStreamEvent, cursorCatalogLoadTimeout, cursorCatalogRetrySchedule, cursorConfig, cursorOperationsFailed, cursorOperationsStarted, cursorStreamEvents, decodeLocalRunStreamEvent, decodeSdkMessageRunStreamEvent, getTurnType, instrument, isTerminalLocalRunStreamEvent, liveLayer, liveRuntime, loadCursorConfig, localRunStreamEventToSdkMessage, makeMockAgent, makeMockAssistantSdkMessage, makeMockRun, makeMockRuntime, makeMockSdkFactoryLayer, mapCursorError, mockLayer, packageName, redact, startLocalRunEventNotifierServer, streamEventsTracked, summarizeAgentOptionsForLog, summarizeRunForLog };
|
|
1536
1535
|
|
|
1537
1536
|
//# sourceMappingURL=index.js.map
|