@magpie-community/opencode-cursor-auth 0.2.18 → 0.2.19

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/index.mjs CHANGED
@@ -2656,12 +2656,12 @@ async function answerOf(auth, chat, signal, session = "") {
2656
2656
  let response = native ? await runNative({ ...args, native }) : await runOnce(args)
2657
2657
  const rebuild = async () => {
2658
2658
  const fallback = await runOnce(args)
2659
- fallback.diagnostic = "stateless; bootstrap=imported-history; reason=missing-batch-count"
2659
+ fallback.diagnostic = "stateless; bootstrap=imported-history; reason=" + (response.error?.continuityReason || "missing-batch-count")
2660
2660
  return fallback
2661
2661
  }
2662
- // A missing native batch count may be retried once, only before Chat
2663
- // output is exposed or any native result was submitted. Never repeat an
2664
- // uncertain tool result write or duplicate a progressive stream's output.
2662
+ // A missing or conflicting native batch count may be retried once,
2663
+ // only before Chat output is exposed or any native result was submitted.
2664
+ // Never repeat an uncertain tool write or progressive stream output.
2665
2665
  if (response.error?.retentionIneligible && !signal?.aborted) response = await rebuild()
2666
2666
  else if (native) response.rebuild = rebuild
2667
2667
  response.diagnostic ??= "stateless; bootstrap=imported-history; reason=" + (prepared.fallback || "retention capacity or reservation unavailable")
@@ -2719,8 +2719,10 @@ async function answerOf(auth, chat, signal, session = "") {
2719
2719
  for await (const e of events) {
2720
2720
  if (e.error) {
2721
2721
  if (!e.error.retentionIneligible || !r.rebuild || signal?.aborted) return errorResponse(e.error)
2722
+ const reason = e.error.continuityReason
2722
2723
  r = await r.rebuild()
2723
2724
  if (r.error) return errorResponse(r.error)
2725
+ if (reason) r.diagnostic = "stateless; bootstrap=imported-history; reason=" + reason
2724
2726
  events = r.events
2725
2727
  responseHeaders["X-Magpie-Cursor-Continuity"] = r.diagnostic
2726
2728
  retry = true
@@ -675,7 +675,13 @@ class NativeSession {
675
675
  }
676
676
  listed(count) {
677
677
  if (!Number.isSafeInteger(count) || count < 1) invalid("invalid native tool count", 502)
678
- if (this.segment.expected != null && this.segment.expected !== count) invalid("inconsistent native tool count", 502)
678
+ if (this.segment.expected != null && this.segment.expected !== count) {
679
+ // Conflicting counts leave the native step boundary ambiguous. Retire
680
+ // this owner; Chat may rebuild from history only if no native result
681
+ // was submitted to this Run.
682
+ this.fail({ status: 502, message: "inconsistent native tool count", retentionIneligible: !this.resultSubmitted, continuityReason: "inconsistent-batch-count" })
683
+ return
684
+ }
679
685
  this.segment.expected = count
680
686
  if (this.state === "awaiting-results") return // an identical retransmission
681
687
  this.waitForBatch()
@@ -876,7 +882,10 @@ class NativeSession {
876
882
  } else if (u.num === 14) {
877
883
  if (!this.segment.content && !this.segment.calls.length) invalid("an empty reply (Cursor ended the turn without text or a tool call)", 502)
878
884
  this.terminalSeen(uf)
879
- } else if (u.num === 27) this.listed(num(uf, 1))
885
+ } else if (u.num === 27) {
886
+ this.listed(num(uf, 1))
887
+ if (this.error) return
888
+ }
880
889
  }
881
890
  break
882
891
  case 2: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-cursor-auth",
3
- "version": "0.2.18",
3
+ "version": "0.2.19",
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",