Part of the provider-package audit. Every module in provider-cursor should now follow docs/internals/effect-services.md.
Module state becomes service-owned
- The shell-spawn
unhandledRejection guard used to be installed globally behind a module-level flag the first time sdk.ts was imported.
- It now belongs to a
CursorSdk service. Its layer adds the listener with Effect.acquireRelease and removes it on release.
- The "another handler owns the decision" logic and the stderr output are unchanged.
- The runner and text generation reach
Agent and createAgentPlatform through this service, so the guard is armed whenever they are in use.
- The server provides
CursorSdk.layer once, next to the runner layer in ProviderOrchestrationAdapterInfrastructure. The guard is now armed when that layer builds instead of on first import, and there is still exactly one guard while the server runs.
- The sandbox-support warm-up used to be a module-level memoized promise. It's now a
Ref and Deferred owned by the runner. It still warms at most once, later callers wait for that attempt, and failures are ignored.
Conventions
CursorSdkCatalogShape and CursorAgentSdkRunnerShape are inlined into their services.
effect/http modules are imported as subpath namespaces.
makeCursorAgentSdkRunner is an Effect.fn that yields CursorSdk.
- The snapshot error's
detail no longer copies cause.message.
- An unused default adapter
layer is removed.
Left for a follow-up: keychainToken.ts still memoizes the macOS keychain read in module state, and its timeout error extends Error. Its main consumer, the Promise-based Cursor usage reader in apps/server, moves into the package with the usage-reader work, so it'll be converted there.
Tests: provider-cursor 102 passed. Server ProviderInstanceRegistry 8 passed. Typecheck is clean for provider-cursor and apps/server.
Model: Claude Opus 5.5 via Claude Code in T3 Code.
🤖 Generated with Claude Code
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This refactor moves Cursor process state and its unhandled-rejection guard into a scoped Effect service, changing production layer wiring and listener lifetime. It also adds a file-level
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).globalConsole:offstatic-analysis suppression, which requires human review under the configured criteria.