* Point every Cursor SDK state surface at writable tmpfs and return the * `stateRoot` to pass to `Agent.prompt`: * * - `platform.stateRoot` covers the SDK's in-process run/checkpoint stores * (the `sdk-agent-store` path that failed in production). * - `HOME` / `CURSOR_CONFIG_DIR` / `CURSOR_DA
()
| 321 | * invocations in a shared instance can't observe a mix. |
| 322 | */ |
| 323 | async function redirectSdkStateToTmp(): Promise<string> { |
| 324 | const cursorDir = path.join(SDK_STATE_HOME, ".cursor"); |
| 325 | const stateRoot = path.join(SDK_STATE_HOME, "sdk-agent-store"); |
| 326 | process.env.HOME = SDK_STATE_HOME; |
| 327 | process.env.CURSOR_CONFIG_DIR = cursorDir; |
| 328 | process.env.CURSOR_DATA_DIR = cursorDir; |
| 329 | await mkdir(cursorDir, { recursive: true }); |
| 330 | await mkdir(stateRoot, { recursive: true }); |
| 331 | return stateRoot; |
| 332 | } |
| 333 | |
| 334 | function archiveSizeGuard(tag: string) { |
| 335 | let downloaded = 0; |