@magpie-community/opencode-cursor-auth 0.2.16 → 0.2.17

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/README.md CHANGED
@@ -94,7 +94,10 @@ Tool results can continue a retained Run in the same plugin process. The owner
94
94
  uses the same session/cache key and first user message as `conversation_id`, so
95
95
  Task subagents sharing their parent's session can run independently. Retention
96
96
  waits at most 120 seconds for a result batch and 15 minutes for a Run's total
97
- lifetime. The pool holds at most 8 owners per account and 32 per process, with
97
+ lifetime. A continuation arriving in the last minute of that lifetime rebuilds
98
+ from supplied history before submitting results to the old Run. The absolute
99
+ deadline still applies to an active segment; it is never extended by activity.
100
+ The pool holds at most 8 owners per account and 32 per process, with
98
101
  bounded history, blobs, arguments, and pending writes. When pending writes
99
102
  reach their bound (a long history asks for its blobs at once, and a slow link
100
103
  drains them slowly), the Run waits for the link to drain, and fails only if it
@@ -381,6 +381,14 @@ export class NativeSessionPool {
381
381
  return { owner, batch, replay: true, segment: batch.next }
382
382
  }
383
383
  if (owner.state !== "awaiting-results" || owner.segment !== batch || !batch.clean) return fallback("owner busy")
384
+ // A retained Run's absolute timer spans all tool roundtrips. Rebuild
385
+ // near its deadline before writing this batch: otherwise a new Chat
386
+ // segment can lose its transport after already exposing output.
387
+ const reserve = Math.min(60_000, owner.limits.lifetime / 10)
388
+ if (owner.expiresAt - Date.now() <= reserve) {
389
+ owner.fail({ status: 410, message: "native Run retired before lifetime deadline" }, "expired")
390
+ return fallback("owner near lifetime deadline")
391
+ }
384
392
  return { owner, batch, results, encoded, digest, chat }
385
393
  } catch (e) {
386
394
  if (!(e instanceof NativeSessionError)) throw e
@@ -463,7 +471,14 @@ class NativeSession {
463
471
  this.terminal = false
464
472
  this.segment = new Segment(this, prepared.chat)
465
473
  this.retain(bytes(prepared.chat))
466
- this.lifetimeTimer = later(() => this.fail({ status: 410, message: "native Run lifetime expired" }, "expired"), this.limits.lifetime)
474
+ this.expireIn(this.limits.lifetime)
475
+ }
476
+ // expireIn sets the Run's absolute deadline ms from now: from its start,
477
+ // the whole lifetime; a test brings it in after the first answer
478
+ expireIn(ms) {
479
+ clearTimeout(this.lifetimeTimer)
480
+ this.expiresAt = Date.now() + ms
481
+ this.lifetimeTimer = later(() => this.fail({ status: 410, message: "native Run lifetime expired" }, "expired"), ms)
467
482
  }
468
483
  retain(n) {
469
484
  if (this.retainedBytes + n > this.limits.outputBytes) invalid("native output/history retention limit reached", 503)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-cursor-auth",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
4
4
  "description": "Cursor subscriptions (Pro, Pro+, Ultra, Teams) in OpenCode and magpie, through the API cursor-agent talks to",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",