Commit Graph
80 Commits
Author SHA1 Message Date
wuuliandXulin Wu 6b5c19d50e cursor: a content refusal is a request error, not a sign-in (#1179)
Cursor labels a refusal of the request's content as unauthenticated ("The provider refused to serve this request based on the content"). The plugin turned that into a 401 and asked the user to sign in again, though the account serves other requests. statusOf now matches that exact wording before the sign-in rule and answers 400 with Cursor's own message; the sign-in is kept. Every other unauthenticated error still asks for a sign-in. cursor 0.2.48.

Run at the reviewed head e43311357 merged onto origin/main 2ede7d53, on a Mac:
- HOME=$(mktemp -d) bun test packages/cursor: 431 pass, 0 fail.
- bun scripts/check.mjs cursor: ok.

Broken by hand: with the new line taken out, 5 tests go red (the content-refusal cases at 200/unauthenticated, 401 and 403/permission_denied, and RunSSE with stream off and on).

Not tried: a real Cursor refusal; the cases are fixtures of the reported wording.

Co-authored-by: Xulin Wu <wuxulin@bytedance.com>
2026-11-15 18:12:40 +08:00
wuuliandwuuli 62c3241954 cursor 0.2.47: wait for announced MCP execs before sealing a batch (#1133)
A Cursor step can send its tool count, then a checkpoint naming only the
first MCP call, then the second call's exec. The count made the #550
fallback seal the batch at that checkpoint, so the second tool was lost
(native: "native call arrived after its batch was sealed"; stateless: one
tool). StepCalls now tracks MCP calls announced by a partial or started
update until their exec or Cursor's own completion arrives, and neither
path seals on a checkpoint while one is pending. Cleared at nextStep.

Reviewed at d3a50d48. Run (macOS, mica): bun test packages/cursor 425
pass 0 fail; bun scripts/check.mjs cursor ok. Broken by hand: without
both pendingMcp checks the four new tests fail; with them they pass.
PR checks bumped, test, on-npm green. Not tried: a real Cursor account
(the author ran a live Pi -> magpie -> Cursor probe, 6 tool calls ok).

Co-authored-by: wuuli <wuuli@users.noreply.github.com>
2026-11-14 16:04:32 +08:00
wuuliandwuuli 463bbfe2b6 cursor 0.2.46: a quiet Run's error says the stream timed out, so Pi retries it (#1075)
Cursor's quiet watchdog (idle and heartbeat-only) now ends its error with "; stream timed out (try again)", so Pi, which classifies a streamed error by its words once the 502 is lost behind a 200, retries the turn within its own budget. The status, limits and failure stay as they were. 0.2.46.

Reviewed at 507b2fd0. Checked Pi's own retry list (earendil-works/pi packages/ai/src/utils/retry.ts on main has "timed? out"; "(try again)" alone matches nothing there). magpie's gateway decides on the 502 status (busyStatus), so its own handling is unchanged. Run (WSL, Bun 1.4.2): packages/cursor bun test 421 pass, 0 fail; bun scripts/check.mjs cursor ok. Not run: scripts/cursor-pi-retry.integration.mjs (needs an installed Pi SDK, loopback only); a real Cursor stall (#550).

Co-authored-by: wuuli <wuuli@users.noreply.github.com>
2026-11-13 15:09:02 +08:00
yetone 0135b7b0ea agy-cli 0.1.32: the first model list after warming has agy's Claude and GPT models (#1064)
On a signed-in agy, `agy models` takes about 4.4s and `agy acp`'s
session/new about 3s. provider.models() needed three calls before
claude-opus-5-5, claude-sonnet-5-5 and gpt-oss-120b showed up, and
OpenCode 2.x calls it once.

What changed:
- packages/agy-cli/index.mjs:
  - The offered-model probe now starts in listAgyModels' .then, as soon as
    a non-empty list arrives and a caller asked for probeOffered. It no
    longer waits for the next models() call. A hung or failed `agy models`
    still never spawns the probe.
  - probeSignedIn reuses the `agy models` stdout it already has. The same
    parser (parseAgyModels, split out of listAgyModels) fills
    cachedModelCatalog, and the probe starts. Sign-in waits for the probe
    for at most 3s.
  - The offer (acpOfferedModels, acpOfferedKey, offeredProbeAt and any
    in-flight probe) is forgotten when agyPath changes and after a new
    sign-in finishes. A generation counter drops the answer of a probe
    that started before the reset.
  - provider.warming() returns a promise while a list or probe is still
    running, and null when nothing is.
- scripts/opencode2.mjs, copied byte for byte to every
  packages/*/opencode2.mjs: after the first background refresh, the
  adapter awaits hooks.provider.warming() once, for at most 60s, and then
  refreshes once more. It does not loop. Plugins without warming() behave
  as before.
- Not done: the issue's on-disk catalog cache (point 3), skipped as asked.

Known gap: agy-cli has no `config` hook, so under OpenCode 2.x the adapter
lists no provider for it. refresh() returns before it calls
provider.models(), so the follow-up refresh can't add agy's models on 2.x
until agy-cli gets a config hook.

Tests: test/testkit.mjs's fake agy takes a sessionNewDelayMs. The new
tests in test/catalog.mjs set 1.5s on both `agy models` and session/new
and wait for state through warming(), with no fixed sleeps:
- On a slow cold start, the first models() after warming lists Claude and
  GPT, from one probe spawn.
- authorize() on a signed-in agy fills the catalog, and the next models()
  runs no second `agy models`.
- The sign-in wait is bounded: with a 6s session/new, sign-in returns in
  about 4.5s.
- Changing agyPath probes again.
The hang test now awaits warming() before it counts acp spawns.
scripts/opencode2.test.mjs: the warming list is read a second time when
warming ends, and only once when nothing is warming.

Run on Linux (a separate test Mac was over its load limit):
- packages/agy-cli bun test: 17 pass, 0 fail.
- bun scripts/check.mjs agy-cli: ok.
- bun scripts/check.mjs (all packages): ok.
- Root bun test in a temp HOME: 8530 pass, 19 skip, 0 fail.

Broken by hand on Linux, each red, then restored green:
- No probe in the .then: the slow cold-start test.
- probeSignedIn drops the list: the authorize and bounded-wait tests.
- agyPath change keeps the old offer: the agyPath test.
- Unbounded sign-in wait: the bounded-wait test (7514ms).
- Probe also on a failed listing: the hang test.
- origin/main's index.mjs with the new tests: all four #1064 tests.
- Adapter reads the list once: the warming adapter test, and the
  copy-identity check.

Not tried: a real agy (no Google sign-in, no network). The reset after
login.finish has no unit test of its own.

Reported-by: hiee3
2026-11-13 10:59:13 +08:00
yetone 2479b36f23 cursor 0.2.45: a test switch lets Cursor search the web and saves that trace (#635)
A new plugin option, "Cursor web search (test)" (web_search_test, off by
default), sits next to Wire trace. On, a Run adds web_search_tool_call
(ToolCall field 18) to x-cursor-agent-allowed-tools and answers Cursor's
search query with an approval, as cursor-agent does when it auto-approves.
Every other tool of Cursor's own is refused as before. A Run in which
Cursor asked to search saves its WireTrace to cursor-traces whether it
succeeded or failed; a Run that never searched saves nothing unless Wire
trace is on and it failed. The trace is WireTrace as it is (kinds, field
numbers, sizes, times) plus one "web search" event; no search term or
result is written.

Protocol, from cursor-agent 2026.11.05-86047df's agent.v1 descriptors (the
plugin ships no .proto):
- AgentServerMessage 7 interaction_query: InteractionQuery {1 id uint32,
  oneof query: 2 web_search_request_query (WebSearchRequestQuery {1 args:
  WebSearchArgs {1 search_term, 2 tool_call_id}}), 9 web_fetch, ...}
- AgentClientMessage 6 interaction_response: InteractionResponse {1 id,
  oneof result: 2 web_search_request_response (WebSearchRequestResponse
  {1 approved {} | 2 rejected {1 reason}})}
- cursor-agent's x1.webSearchApproved builds exactly that approval; with
  no args it rejects "Missing web search arguments", and so does this.
Before: native failed the Run on any interaction query ("unsupported native
interaction query", 502); stateless left it unanswered. Both stay so with
the switch off, and for every query but a web search with it on.

Run on mote, HOME a fresh mktemp -d:
- bun test packages/cursor: 421 pass, 0 fail
- bun scripts/check.mjs: ok
- the new off tests against origin/main 907847b's index.mjs and
  native-session.mjs: pass (the off behaviour is the old one); the on
  tests there: red, as they should be
The full root suite was not run (other reviews were using mote and mica).

Broken by hand, each red (11 tests named plugins#635):
- approval sent as a rejection: 5 red
- native answer not gated on the switch: off test red
- header always adds web_search_tool_call: both off tests red
- header adds shell_tool_call too: 6 red
- stateless never sends the answer: 2 red
- a successful Run without a search saved: 2 red
- a successful Run that searched not saved (ended() a no-op): 2 red
- frame bytes written into the trace: 4 red (secret found)
- any interaction query taken as a search: 3 red

Not tried: Cursor's real servers (fakes only, no real account). Whether
Cursor sends tool_call_started (update 2) for its own search, which would
keep StepCalls from counting it as completed by Cursor, is unknown; the
real trace this switch records is for that. With the switch on, every Run
holds a trace in memory until it ends, as with Wire trace on.
2026-11-11 23:41:17 -08:00
yetone 740e1af252 tests: grok's nocli puts PATH back when its file ends, so gumloop's Node children find node on CI
publish.yml has been red on main since 7ebab07c (run 43011771755, and
43012668584, 43012789287 after it): 4 of gumloop's regression tests
failed with `Executable not found in $PATH: "node"`, so dist and npm
were skipped and gumloop 0.1.0 and agy-cli 0.1.19 reached neither.

Cause: bun test runs every file of the root run in one process.
packages/grok/nocli.mjs sets PATH=/usr/bin:/bin (and HOME, USERPROFILE,
GROK_HOME, GROK_BIN_DIR) for grok's files and never put them back, so
every file after grok's ran with that PATH. On ubuntu CI node is
actions/setup-node's, under /opt/hostedtoolcache, so gumloop's
spawn("node") found none whenever bun ran grok's files before
gumloop's (CI's order). Locally bun ran gumloop first, so it passed.

Change:
- grok/nocli.mjs: the first noRealGrok of a file snapshots process.env
  and registers an afterAll that puts it back, removing what was added.
- gumloop/regression.test.mjs: node's absolute path is found once with
  Bun.which at load and spawned by path; not found, the Node tests fail
  as before (no skip).
- Siblings the same way (a file-level env change never put back), found
  by a full-run env audit: chat/chat.test.mjs (XDG_CONFIG_HOME pointing
  at its deleted temp dir, MAGPIE_API_KEY/GATEWAY_KEY/ADDR deleted) and
  cursor/calls.test.mjs (XDG_DATA_HOME) now restore them in afterAll.
  window-warmup's fake-gateway.ts/scheduler.test.ts XDG pins are left,
  filed as #996 (fake-gateway is also the --serve demo's).
  Other PATH writers (devin, gcp-ai, grok's own tests, sap-aicore,
  agy-cli, layerfs) already restore theirs; the audit saw PATH change
  only at grok's files.

Ran (magpie-desktop WSL, node only in ~/sdk/node/bin, bun 1.4.2):
- Red first, origin/main: `bun test --randomize --seed=3` (and 5) on
  grok/loop-check + gumloop/regression: the 4 CI failures, same error;
  also with --preload ./packages/grok/nocli.mjs.
- Same seeds with this change: 95 pass 0 fail (new gumloop test plus
  origin/main's copy of it).
- Broken by hand: afterAll(putBack) commented out -> both seeds red
  again, 4 fail.
- Root `HOME=$(mktemp -d) bun test` (with an env-audit preload): 8298
  pass, 19 skip, 0 fail, 8317 tests, 584 files; PATH back to the start
  value at the first file after grok's.
- Touched packages (chat, cursor, grok, gumloop, qoder) after the
  chat/cursor change: 1117 pass 0 fail, each XDG value back to start.

Not tried: ubuntu CI itself before pushing (publish.yml runs it next);
Windows (nocli sets PATH empty there, restored the same way).
2026-11-11 19:53:46 +08:00
yetone f73ba656b2 cursor: auth.calls lists the account's calls made outside magpie (0.2.44, WaiooT on X)
magpie's Usage page counts only what went through magpie, so Cursor's
editor and cursor-agent use was missing ("求支持统计cursor的使用情况").
auth.calls reads GetFilteredUsageEvents page by page from the time magpie
asks for and gives each of the account's own events: id, time, model,
tokens (input uncached; cache read/write apart), cost (totalCents / 100)
and conversation. A team's other members (owningUser vs GetMe's userId)
and the conversations this plugin ran itself (kept 40 days in
$XDG_DATA_HOME/opencode-cursor-auth/conversations.json, written
temp-and-rename) are left out. A refused page fails the reading.

Run: bun test in packages/cursor on mote (410 pass), scripts/check.mjs.
calls.test.mjs's fixtures carry the field names of a real Pro account's
reply. Real account: the hook read 43 events (30 days) from the owner's
Cursor sign-in, tokens and costs as the dashboard has them.
Broken by hand: without the own-conversation and owningUser filters the
first calls test goes red.
Not tried: a team account with other members; Cursor's editor (none
installed here), so an editor event's shape is taken as the same.
2026-11-10 11:57:54 +08:00
我是一条没有名字的区 087c36123d inkstone 0.1.3: image-caps preflight, a zero-prompt browser sign-in, key calls on the session cookie (#832)
inkstone 0.1.3 (#832, yunwang2442-creator):

- Image requests are prechecked before they leave: 8 images, 10MB each, 40MB in all.
  - A request over a cap gets a local 400 shape refusal, so magpie asks the next account and rests none.
  - The plan's invalid_media / media_fetch_failed / unsupported_media_type errors become the same kind of refusal.
- The body rewrite strips the reasoning fields and sets image detail to auto.
- A zero-prompt browser sign-in comes first, and a second browser method reuses a pasted key.
  - Neither browser method is offered when no Chromium-family browser is found (#825).
- The /keys calls ride the session cookie, without the pagination query. Key creation retries the console's -15100 "refresh page and retry".
- The #826 metadata token read is kept, and its test is back.
- The fake browser is built once per user and source hash (#824), and the title wait reads only on Windows.
- maxConcurrency is 4.
- The doubled comment line is dropped from every opencode2.mjs copy, agy-cli's included.

Reviewed at 88e66bde, on mote (macOS, Bun 1.4.2) with a temp HOME:
- full bun test: 6853 pass / 0 fail; both checks exit 0
- bun scripts/check.mjs and bun scripts/check.mjs inkstone: exit 0
- 21 hand breaks: 20 red, 1 not caught (the /keys pagination test calls protocol.listKeys directly; follow-up filed)

Not tried: a real InkStone account or sign-in, Windows and Linux runs.
2026-11-07 22:24:56 +08:00
我是一条没有名字的区 e7004d9354 inkstone 0.1.0: Intern InkStone (书生·端砚) Token Plan, browser sign-in, credit card and ink-* key chat (#775)
New package @magpie-community/opencode-inkstone-auth 0.1.0 for Intern
InkStone (书生·端砚, Shanghai AI Lab) Token Plan, provider id
`intern-inkstone`. Community package by yunwang2442-creator.

What it does:
- Browser sign-in (Edge/Chrome, its own profile under
  $XDG_CONFIG_HOME or ~/.config/magpie/inkstone-browser, or
  %LOCALAPPDATA%\magpie\inkstone-browser). The login window has no
  debugging port. A headless CDP read takes the uaa-token cookie, and the
  same read renews it silently later.
- Usage card: ink-credit balance, 5-hour and 7-day windows, credit packs.
- Chat: a pasted ink-* API key, or one the sign-in creates, named
  ink-<host4>-<acct4>-<rand4> (18 of the console's 20 characters). An
  idempotency clash (-15109) retries with a fresh name, up to three times.
  Pruning is on by default. It only touches this machine's and account's
  prefix, keeps the newest two and the key this sign-in created, and never
  deletes manual keys or keys of unknown age.
- Closing on Unix: SIGTERM, then SIGKILL only after a 15s grace. Leftover
  browsers are matched by --user-data-dir=<escaped profile>, and Windows
  uses .Contains().
- The login wait comes from an injected waitForLogin in tests. No env
  hook is left in production code.
- Hosts: discovery.intern-ai.org.cn, discovery-api.intern-ai.org.cn,
  127.0.0.1 (CDP).

Outside the package: scripts/opencode2.mjs lets a prompt with
`required: false` stay optional (`p.required !== false`). Every package's
copy is synced byte for byte, so all 39 copies in the merged tree are blob
afe074cb. No other package sets `required: false` on a prompt, so this
changes nothing for them. Also a root README row and a registry entry.

Review at 36412a15, on mote, HOME=$(mktemp -d), Bun 1.4.2:
- bun test packages/inkstone: 68 pass, 0 fail in Asia/Shanghai, UTC,
  America/Los_Angeles and Pacific/Kiritimati.
- bun scripts/check.mjs inkstone and bun scripts/check.mjs: ok.
- bun test (repo), on 36412a15 merged with origin/main e7cb9dc5:
  6743 pass, 20 skip, 0 fail. main has since moved by cline 0.1.14 and
  zcode 0.1.55 only, and none of the adapter copies changed.
- Broken by hand, each red: no protectName protection; prune_keys default
  off; no post-sign-in prune; no SIGTERM on close; the -15109 retry keeping
  its name.

Not tried: a real InkStone account sign-in on macOS, Linux or Windows (no
account here); a live chat request; magpie end to end with the plugin.
2026-11-07 15:07:06 +08:00
nicegui 1eb9473f5b cursor 0.2.43: read per-step ModelCallCompletedUpdate usage (#796)
Asks AgentService/Run for emit_model_call_usage (AgentRunRequest field 37) and reads InteractionUpdate 31 (ModelCallCompletedUpdate: model_call_id, then input, output, cache read, cache write and reasoning tokens). These field numbers are checked against cursor-agent 2026.11.05-86047df's bundle. A multi-step native turn's final step reports that call's exact counts. The rest of TurnEnded's totals goes to usage.magpie_deferred, or the earlier calls' #31 sum when TurnEnded has no counts. A stateless step with a #31 before it seals takes that count and doesn't poll the dashboard. Without #31, both paths are as before.

Reviewed at d2c49f3b on mote (mote-run, HOME=$(mktemp -d)):
- bun scripts/check.mjs cursor: ok.
- bun test packages/cursor: 406 pass, 0 fail. native-e2e alone 3 times: 145 pass each.
- Probes: TurnEnded with no counts and a #31 per step, and only the final step's #31. Both give own 61000/700 and deferred 105000/1400, which add up to the turn.
- Broken by hand, red each time: no field 37; native ignoring #31; #31 read unshifted; stateless ignoring #31; stateless still polling after #31.
- Not red: dropping the lastStepUsage reset in nextStep. That test gap is filed as a follow-up.

Not tried: a real Cursor account (whether api2 sends #31, and in what order).
2026-11-06 20:54:23 +08:00
nicegui 484b870266 cursor 0.2.42: a mid-batch checkpoint after a count sent first no longer seals a parallel tool batch (#788)
cursor 0.2.42: a checkpoint whose pending calls equal the calls handed out ends a step short of its count only when tool_requests_listed came after the step's last call update or exec (StepCalls.listedAfter). A count sent first can no longer let a checkpoint between parallel calls seal the batch after one call (502 "native call arrived after its batch was sealed"). An exec also removes its id from the calls Cursor completed by itself.

Reviewed at e0794fef on mote (HOME=$(mktemp -d), Bun 1.4.2): bun test packages/cursor 405 pass, 0 fail; bun scripts/check.mjs cursor ok. Broken by hand: without listedAfter in native, 2 fail; without it in stateless, 2 fail; without byCursor.delete, 1 fails. Trade-off: a count sent before the calls, with Cursor-completed calls that send no update 3, now waits for the quiet timeout instead of ending on the checkpoint. A probe shows it; it hasn't been seen on the wire; filed as #790. 0.2.42 is the next version after npm's 0.2.41. Not tried: a real Cursor account. PR CI green.
2026-11-06 18:53:48 +08:00
Gavin Wang f2dc68c17e cursor 0.2.41: new input past a parent awaiting results gets a retained Run that takes no reservation (#706)
cursor 0.2.41 (ooboqoo): new input past a parent that is awaiting results gets a retained Run that takes no reservation, so those turns stop falling back to "owner busy" and then "historical native calls" rebuilds. When a later Run of the conversation starts, a parent waiting on results owes its step at once, bounded before that start, and the later Run collects it. The collection waits until owedAt, because Cursor adds a step to a Run's one event as the step ends. If the parent's own results resume it, an uncollected count is withdrawn, and a collected one comes off its final, so the event is billed once.

Reviewed at 74a1d8b23 merged onto main 20b89389, on Linux (WSL2 Ubuntu 24.04, Bun 1.4.2):
- `bun scripts/check.mjs` OK.
- `bun test packages/cursor` three times: 400/1 once, under load, from native-http1's 100 ms writeWait test. That test isn't touched here and is filed as #754. The other two runs were 401/0. Main ran 394/0 twice.
- `native-e2e` + `native-session` + `native-http1` three times: 182/0 each. native-http1 alone five times: green.
- Broken by hand:
  - The selector filter in `create` dropped: the admission test red.
  - No handover: 5 red.
  - No hold: 1 red.
  - No withdraw: 1 red.
  - No final subtraction: 1 red.
  - Restored: 177/0.
- Real account: the author's runs are in the PR. 398 requests at a0f9363, with no owner busy. 144 requests at 74a1d8b, where all 15 handed-over parents were collected once.
2026-11-05 14:02:34 +08:00
Gavin Wang 4f3eddc256 cursor 0.2.40: a new user turn whose old native calls are all answered gets a retained Run (#672)
A new user turn whose earlier native calls (call_cursor_…) all have tool
results now gets a retained Run of its own, with those calls imported as
history the way the stateless path imports them. Any call still pending, a
request ending in tool results with no live owner, or a tool attachment last
still falls back as before; the owner-busy check is unchanged. Nothing is
submitted to an old exec: a user message last has no trailing handles.

By ooboqoo (#672).

Run at the reviewed head 5b4dcf1 on mote:
- packages/cursor `bun test`: 394 pass, 0 fail
- `bun scripts/check.mjs`: ok
Broken by hand: with origin/main's native-session.mjs and the PR's tests,
"terminal old handles do not wedge a new user turn" and the new admission
test both fail (2 fail, 168 pass in those two files).
Not tried: a real Cursor account (the author reports ~270 requests over a
day, all 200 or client-cancelled 499); Cursor dashboard usage or caching.
2026-11-03 19:45:28 +08:00
yetone 023631774e cursor 0.2.39: release the catalog's Claude listing (jiaohanying, #634)
b8ec827 (#634, jiaohanying) lists the Claude Cursor hides from an
account once per context size. Its branch said 0.2.38, which main's
17e5ef7 had already published, so the package goes out as 0.2.39.

Run at b8ec827's tree with this version (mote, Bun, temp HOME): bun test
packages/cursor 393 pass; whole bun test 5199 tests, 0 fail; bun
scripts/check.mjs ok.
2026-11-03 17:55:16 +08:00
焦寒营 b8ec827579 cursor: the Claude Cursor hides from an account is listed once per context size (jiaohanying, #634)
By jiaohanying (#634).

An account Cursor blocks Claude for has no Claude in the picker
(AvailableModels), only in the usable list, so those models were listed
as usableOnly fallback entries: a 200K window assumed, no sizes.

AvailableModels with scope 3 (the full catalog) is now asked alongside
the other two (8s; a failure leaves the list as before). The live
Anthropic models the picker lacks (not isHidden, not Auto, not chat-only
or Tab-only, with a variant the account has an id for) are listed as the
picker's models are: once per context size (claude-opus-5-5@300k, @1m),
thinking a parameter, the efforts the account is served, 1m in Max Mode.
A catalog variant without a legacySlug gets the one of the model's ids
that says its effort, thinking and fast; none or several, it is not
offered. Only the parameters the model defines are sent: the catalog's
Opus 4.7 to 5.5 variants carry cyber=false, which the picker's don't and
cursor-agent never sends. A saved sized id (claude-opus-4-8-thinking@1m)
now runs at its size. With no effort asked a catalog model goes at
Cursor's default variant (Opus 5 and 4.8: high), as the picker's do.

The version is bumped in the next commit: main's 17e5ef7 already took
0.2.38.

Run at the reviewed head f4cb8ed449ee63dfb92fa37509a171ee43de3280 (mote,
Bun, temp HOME):
- bun test packages/cursor: 393 pass, 0 fail. bun scripts/check.mjs: ok.
- Squashed onto origin/main a064cf1 with the version at 0.2.39: bun test
  packages/cursor 393 pass; whole bun test 5199 tests, 0 fail (15 skip);
  check.mjs ok.

Broken by hand:
- c588c65's withSlugs (no parameter filter): the cyber test fails
  (Expected false, Received true); the other 8 pass.
- main's index.mjs under the new catalog.test.mjs: 7 of 9 fail.

The author ran a real Run on a blocked account at low effort:
claude-opus-5-5@300k went as claude-opus-5-5-low [context=300k,
effort=low, fast=false], @1m as the same id in Max Mode [context=1m].
Not tried by the reviewer: a real Cursor account (none available for
this review), and a long conversation at 300K or 1m. Every account now
makes the scope 3 request too, so a slow catalog can hold the list up to
8s, as GetUsableModels can.
2026-11-03 17:55:05 +08:00
yetone 17e5ef7457 all: load on OpenCode 2.x through a default {id, setup} (#657)
nbczw8750 (#657): trae 0.2.26 on OpenCode 2.2.5 fails with "Plugin
must export a default definition with an id and an effect or setup
function. (cause: SchemaError(Missing key at ["default"]))". 2.x
imports a package's exports["."] (a plugin dir and an npm install
alike) and has no V1 path at all, so every package here that serves
models failed the same way, not only trae.

Every one of the 32 model packages now has:
- opencode2.mjs, exports["."]: a copy of scripts/opencode2.mjs, an
  adapter that runs the package's V1 plugins inside 2.x's promise
  API. Config providers become 2.x providers (package pinned so the
  aisdk sdk hook runs), V1 auth methods become integration methods
  (oauth auto/code with forms; api without authorize as a key method),
  V1 credentials are kept in metadata.v1, the loader's baseURL,
  apiKey, headers and fetch are applied through the sdk hook, an
  auth.set renewal is stored per credential, and credential.switched
  /updated reload the account's own model list.
- opencode.mjs, main: re-exports the V1 plugin functions only.
  OpenCode 1.x and magpie's host.js take main. On 1.x, trae 0.2.26's
  main exported a non-plugin (_internal) and 1.19.5 refused it ("Plugin
  export is not a function"); the new main fixes that too.
- both files in "files"; patch version bumped. devin already had 2.x
  and is unchanged.

scripts/check.mjs fails a model package whose 2.x entry has no default
{id, setup}, whose opencode2.mjs differs from the canonical one, whose
entry is missing from files, or whose main exports a non-plugin.

Run at this head (mote):
- HOME=$(mktemp -d) bun test, as CI runs it: 4900 pass, 0 fail
  (4914 tests, 374 files). A first run set globalThis.fetch for the
  whole process from opencode2.test and failed 528 tests in other
  packages; the block is now set and put back around that file's tests.
- bun scripts/check.mjs: every package passes. With the network
  blocked cloudflare-workers-ai fails on its fetched catalog, the same
  on origin/main.
- Real OpenCode 2.2.5 (npm opencode-ai), sandbox HOME, packed trae
  0.2.27: loads with no error; /api/integration lists trae-cn "Trae CN"
  and trae-global "Trae Global" with their browser sign-ins; `auth
  login` starts the trae.cn authorization and waits (cancelled there);
  with a fake credential POSTed to /api/credential, `opencode models`
  lists trae-cn's six models.
- Real 2.2.5 with a fake V1 key plugin through the same adapter
  against a local fake server: `auth login` with a key, `models`,
  `opencode run` reached /real/v1/chat/completions with the loader's
  "Bearer loader-sk-fake" and header, and printed the fake's reply;
  with @ai-sdk/anthropic it reached /real/v1/messages with x-api-key
  from the loader. This run found the key method missing after 2.x's
  second integration transform (a once-only flag outside the
  transform); fixed, and opencode2.test checks a rebuild.
- Real OpenCode 1.19.5, sandbox HOME, trae 0.2.27: `opencode models`
  lists trae-cn and trae-global models; 0.2.26 failed there.

Broken by hand (scratch copy, bun test scripts/ and check.mjs):
- trae's exports back to "./index.mjs": the trae 2.x test fails
  (default.id undefined), check fails trae with "OpenCode 2.x:
  ./index.mjs has no default {id, setup} (plugins#657)".
- zed's opencode2.mjs changed: the copies test fails, check fails zed
  "differs from scripts/opencode2.mjs".
- the key flag back outside the transform: the 1.x plugin test fails
  on the rebuilt sign-ins (key missing).

Not tried: a real sign-in with a real account on 2.x; Windows (the
reporter's OS); chat.headers, chat.params, usage and tool hooks, which
the adapter doesn't carry to 2.x; the tools/pages packages (calc,
goanyapi, layerfs, search1api, aelios, agent-console, chat,
fingerprint, nowledge-mem, kimi-desktop), which still load only on 1.x.
2026-11-03 13:54:26 +08:00
yetone 3f615ea9ef cursor 0.2.37: a step with under 10 minutes of a retained Run's lifetime left starts fresh, and a deadline cut says to retry (#616)
yetone/magpie#4419 (Okxdd123; ggbdpq traced the cause and wrote the
repro): a Pi turn on cursor/grok-4.7@500k kept one native Run across 12
tool steps. The 13th went on in that Run with 494 s of its 15-minute
lifetime left, the answer was still streaming at the deadline, and the
Run failed mid-answer with "native Run lifetime expired". The 200 was
long sent, so the agent read only those words, and Pi doesn't retry on
any of them, so the turn ended although asking again goes on.

- native-session.mjs: a retained Run takes a tool batch's results only
  with more than continueReserve (10 minutes, new in NATIVE_LIMITS; at
  most two thirds of the lifetime) left. With less, the owner is retired
  and the step goes on a fresh Run from the supplied history, as #157
  did for the last minute. 60 s didn't cover a long answer.
- The deadline's error now says "native Run lifetime expired: the Run
  timed out; retry your request" (LIFETIME_EXPIRED). "timed out" is in
  Pi's _isRetryableError list and in magpie's passingSaid; "retry your
  request" is in passingSaid, so magpie's gateway adds nothing more. For
  Claude Code and Codex, magpie translates the error as api_error /
  server_error, as before.
- README: the 10-minute reserve and the wording.

Tests (native-e2e.test.mjs), no network and no real waiting: Date.now
moved so a continuation has 494 s (the reporter's case) or 599 s left ->
rebuilt on a fresh Run, no result written to the old one; 660 s left ->
same Run. A retained continuation streams half an answer, the deadline
is brought in with expireIn(0), and the SSE's one error starts "native
Run lifetime expired" and matches Pi's retry regex and magpie's
passingSaid (both copied into the test).

Broken by hand: the old reserve (min(60 s, lifetime/10)) turns the 494 s
and 599 s cases red; the old wording turns the mid-answer case red
(3 fail, 135 pass in native-e2e).

Run (mote, HOME=$(mktemp -d), as CI): bun test at the repo root, 4716
pass, 0 fail; bun scripts/check.mjs, exit 0. packages/cursor alone: 384
pass, 0 fail.

Not tried: a real Cursor account reaching the 15-minute deadline; a real
Pi, Claude Code or Codex reading the new wording (Pi's regex is the one
in pi-coding-agent's agent-session.js as installed locally, not
necessarily Pi 1.4.0's).
2026-11-02 08:00:09 +08:00
yetone 24cd0b9123 cursor 0.2.36: a stateless step whose calls came hands them over when no count follows (#550)
Windsland52's fifth wire trace (2026-10-31 19:44, cursor-grok-4.6-xhigh,
stateless, why "historical native calls"): thinking, text, then two MCP
calls 43 ms apart (partial, started, exec each), no tool count (update
27), no checkpoint, and 24 heartbeats until quiet ended the Run at 240 s.
The stateless decode only ends a step on the count, a checkpoint or EOF,
so it waited out quiet; the retry of the same turn stays stateless, so a
native stall cost two 4-minute waits. Cursor's own client never waits on
toolRequestsListed (b70725c).

Now decode reads with a deadline while the step has calls, no count and
no call still being written (a #7 neither started, exec'd nor completed:
Cursor's own call still running). Once countWait (60 s, NATIVE_LIMITS)
passes since Cursor's last frame that isn't a heartbeat, the calls that
came go to the caller as tool_calls, noted "no count" in the trace.
Heartbeats never move the deadline. The native path is unchanged: there
the step can't end without the count, and its batchWait stays as it was.
60 s and not batchWait's 30 s: a long call is written with heartbeats
only (#377), and a cut there costs a re-written call, not a failed turn.

Run (mote, bun test in packages/cursor at this head): 380 pass, 0 fail.
New tests in stall-550.test.mjs build the fifth trace's frame kinds in
order (bytes made up where the trace has sizes only): the two calls go to
the caller; heartbeats every 20 ms don't move a 300 ms deadline; a call
still being written holds the step; a count inside the wait ends on the
count as before.
Broken by hand: with the deadline never armed, the first two go red
(open after 2 s); without the still-writing guard, the third goes red.
Not tried: a real Cursor account, or a step whose count comes later than
60 s after its last call (none in the reporter's traces).
2026-11-02 05:06:49 +08:00
yetone b70725c1a6 cursor 0.2.35: a step ends on calls Cursor completed itself, or on a checkpoint waiting on every call (#550)
Windsland52's wire trace (stateless path): partial c1 -> completed c1,
partial c2 -> completed c2, partial c3 -> started c3 -> one exec, then
the tool count (update 27), 7 set_blob, a checkpoint whose
pending_tool_calls (ConversationStateStructure 4) holds one id, and
240s of heartbeats. Cursor's count includes calls it completed itself
(#7 then #3, with no #2 and no exec), which never reach this side, so
the step waited for calls that were never coming while Cursor waited on
the one exec's result. The native path had the same gap and failed after
batchWait. Cursor's own client (cursor-agent 2026.10.01) takes a
toolCallCompleted for a call it never started, and never waits on
toolRequestsListed.

Now, on both paths, a #3 for a call seen as #7 in the same step, never
started (#2) or exec'd here, counts toward the step's tool count, and a
checkpoint after the count whose pending calls equal the calls this side
holds ends the step too. The strict "more calls than the count" check
still counts only calls that came and were answered here. The quiet
error and batchWait name the count, the calls, the answered and those
completed by Cursor; the Wire trace keeps each update's count, tool
kind, pending and why the Run was cut. Update 8 is named (token count).

Run at this head: stall-550.test.mjs (10 tests, built from the trace's
195 inbound frames in order) and the cursor suite 376/0 on mote; the
root suite with a temp HOME 4196 pass, 0 fail, and check.mjs cursor ok
on mote; native-session, native-e2e, stall-550, conversation and
stepusage 191/0 on Windows (win-run).
Broken by hand, each red only in its own test: the stateless
completed-by-Cursor rule, the stateless checkpoint rule, the native
completed rule, the native checkpoint (waitedOn), and the #7-in-this-step
requirement.
Not tried: a real Cursor account; the real count value (the trace gives
only 2..127); that a #3's call_id equals McpArgs.tool_call_id; what the
two completed calls were; whether Cursor can checkpoint mid-step with
pending equal to the calls before more execs.
2026-10-31 16:36:38 +08:00
yetone 1a5b184991 cursor 0.2.34: the quiet error names its checkpoint; an opt-in Wire trace saves a failed Run's frames (#550)
Windsland52 (#550, 0.2.33, cursor/grok-4.6 at xhigh): four Runs ended
"Cursor went quiet: 24 heartbeats and nothing else for 240 s, its last
message checkpoint". They asked for the checkpoint to be named, and for a
way to see what Cursor sends after it. No change to quiet's budget or to
retry, as asked.

The quiet error now says, for a checkpoint: its number in the Run, which
of its step's checkpoints it was (native path; the stateless path doesn't
count steps), how many came in a row, and the kinds before it, e.g.
"its last message checkpoint #1 of the Run, the first of step 1, after
blob request x2, thinking". Other kinds read as before.

Wire trace is a new plugin option (wire_trace), off by default. With it
on, a Run that fails (not one the caller cancels), native or stateless,
writes <magpie's folder>/cursor-traces/<start>-<rand>.json (temp and
rename, mode 600, newest 20 kept). It holds both directions' frames as
time, size, kind, top-level field numbers with wire type and size, and
the field numbers and sizes one level inside: the shape, never the bytes.
No text, thinking, tool name or argument, blob or blob id, checkpoint
content, token, header, account or conversation id is read into it. The
error message is scrubbed of email-, uuid-, auth-id- and token-shaped
strings. It also has quiet's counters, the model id and plugin version.
The first 2000 and last 3000 frames are kept, the rest counted. The
folder comes from input.directory, which magpie sets to its config
folder. The option exists only in magpie, so OpenCode's project folder is
never written to.

Run on mote at this tree (33027a8 + this change):
- HOME=$(mktemp -d) bun test at the root: 4186 pass, 9 skip, 0 fail.
- bun scripts/check.mjs cursor ok.
- native-session + native-e2e on xiaomi-gpu (Windows, win-run): 165
  pass, 0 fail.
Broken by hand, on mote:
- The new tests against origin/main's code: 5 fail.
- Raw frame bytes added to each entry: both e2e trace tests red (secret,
  token found).
- Tracing cancelled Runs too: the cancelled test red.
- Ignoring the option: "off unless the option is on" red.
Not tried: a real Cursor account. The stall hasn't been reproduced here,
so the fixtures follow what #550 reports (heartbeats after a checkpoint),
not a captured Run. Not tried in the magpie GUI either: that the option
shows as a toggle under Plugin options is from how Included usage only
shows, not looked at.
2026-10-31 15:10:54 +08:00
yetone 00de68a0f8 cursor 0.2.33: free credit (the plan's bonus and credit grants) on the card, with its limits
CryptoSarom on X (2116260605053321489): "magpie 似乎没法支持 cursor 的赠金读取,
以及赠金使用限制". The card read only the included pools and on-demand.

What Cursor exposes, as Cursor 3.x's IDE (workbench.desktop.main.js) and
cursor-agent 2026.10.01's schemas have it:
- GetCurrentPeriodUsage planUsage.bonusSpend (cents), remainingBonus (bool,
  no amount) and bonusTooltip: the IDE's "+$X free usage on us" line.
- DashboardService/GetUsageLimitStatusAndActiveGrants activeGrants
  (aiserver.v1.ActiveCreditGrant): totalCents, remainingCents, expiresAtMs,
  allowedModelIds / allowedModelTags / allowedModelSelections (models it
  may be spent on), allowedClientTypes ("glass" without "ide" is the IDE's
  Cloud Agent credits), campaignName. The IDE's "Use your $X free credits"
  banner reads it; it matches tags lower case with "-" as ".".

The card now shows Free usage (bonus spent, "more left" when
remainingBonus) and a window per grant (spent / total USD, runsOutAt and
runsOut at its expiry, models when limited, "(Cloud Agents only)" when
cursor-agent can't spend it). All are aside. Routing: a bonus with some
left, or a grant magpie can spend on every model, sets the spent pools
aside as on-demand does; a model-limited grant leaves its models out of
a spent pool (Cursor Models keeps a non-empty list, or goes aside). With
Included usage only on, none of this keeps an account served. A grants
read that fails leaves the card as before.

Run on mote at this tree: HOME=$(mktemp -d) bun test: 3960 pass, 9 skip,
1 fail (a test of my own, since fixed); then credit/usage/included-only
79 pass 0 fail; bun scripts/check.mjs cursor ok. Broken by hand: the new
credit.test.mjs against the old index.mjs, 9 of 9 red.
Real account (Premium, merged weekly, cursor-agent's sign-in, read only):
GetCurrentPeriodUsage, GetUsageLimitStatusAndActiveGrants,
GetCreditGrantsBalance, GetClientVisibleCreditGrants read; it has no bonus
and no grant, and the new plugin's card for it is unchanged (Weekly, Grok
Bot, On-demand). Those replies are credit.test.mjs's REAL_ fixtures; the
#1868 team account's real bonusSpend 14151 now shows "+$141.51 on us".
Not tried: a real account with a grant or remainingBonus true (none at
hand), so the grant fixtures follow the schema, and whether Cursor
really serves a spent pool on bonus is Cursor's word ("free usage beyond
what you've purchased"), not a request made past a spent pool.
2026-10-31 04:46:49 +08:00
yetone 060722efcf cursor 0.2.32: a merged (newer) plan's included usage is one Weekly window for every model, no Other Models
majiang_ai on X: Cursor's newer plans have no third-party-model pool,
while magpie's card still showed Cursor Models, Other Models and Total.

What Cursor says: GetPlanInfo answers isMerged true and
planInfo.includedUsagePeriod INCLUDED_USAGE_PERIOD_WEEKLY for such a plan
(enum 1 MONTHLY, 2 WEEKLY, from cursor-agent 2026.10.22's proto), and
GetCurrentPeriodUsage's billing cycle is then the week, with
autoPercentUsed == totalPercentUsed and apiPercentUsed 0. The dashboard's
usage page (cursor.com/v2/usage, chunk read on 10-29) draws one meter,
"Weekly usage limit", from the period's totalPercentUsed.

Now planOf reads isMerged and the period with the plan name (same hourly
cache, last good answer kept). A merged plan's usage is one window,
Weekly (span 7d; Monthly on a monthly merged plan, Included when not
said), with no models list, so it counts every model; On-demand and
Grok Bot as before; no Other Models or Total. A plan GetPlanInfo can't
read, or isMerged false, keeps the two pools.

Run:
- HOME=$(mktemp -d) bun test (whole repo, on mote): 3229 pass, 8 skip, 0 fail
- bun scripts/check.mjs: ok
- Broken by hand: the merged branch turned off, 5 of the 6 new tests red
  (the 6th checks the unmerged case still has the pools).
- Real account (owner's Cursor, a merged Premium plan, keychain token,
  read-only calls): the published 0.2.31 shows Cursor Models 7%, Other
  Models 0%, Total 7%; this change shows Weekly 7% (resets 11-03), Grok
  Bot, On-demand.

Not tried: an old (unmerged) plan's real account; none is at hand, the
unmerged path is unchanged and covered by the existing tests. A merged
monthly plan was not seen for real.
2026-10-29 17:55:11 +08:00
yetone 6a86762e26 cursor 0.2.31: Included usage only, a plugin option that stops an account once its included pools are used up (#485)
A new magpie plugin option, included_only ("Included usage only", off by
default), read through input.magpie.option at each usage reading, so a
change needs no restart. Modelled on Factory's standard_only (#349).

On: Cursor Models and Other Models drive routing (they lose `aside`), and
On-demand (fixed or unlimited) and Total are shown with `aside`, so a team
member whose on-demand could still pay is no longer kept in routing once
an included pool is used up. The Enterprise path does the same: the
Enterprise allowance stops the account and On-demand is shown only.
Off, or outside magpie, or an option that throws or isn't `true`: the
windows are exactly as 0.2.30 gives them.

Tests (included-only.test.mjs, new): Team accounts with a member's own
fixed limit, an org-wide fixed pool and unlimited on-demand, each with the
pools spent, left, and only Cursor Models spent, read with the switch off
and on; a fixed budget spent stops either way; no on-demand allowed is
unchanged; the switch flipped on one plugin instance between readings;
input missing/throwing/non-true; Enterprise unlimited and fixed-with-room;
the option's declaration fits host.js's limits (label 60, description 300).

Run on mote (mote-run):
- HOME=$(mktemp -d) bun test packages/cursor: 344 pass, 0 fail, 20 files
- bun scripts/check.mjs: ok
Broken by hand (each in mote's copy, included-only + usage tests):
- pools keep `aside` with the switch on: 8 fail
- fixed On-demand not set aside: 2 fail
- Enterprise allowance ignores the switch: 2 fail
- Enterprise fixed On-demand not set aside: 1 fail
- switch always on: 23 fail
- switch read once at plugin start: 1 fail
- a truthy non-true value taken as on: 1 fail
- option declared under another key: 1 fail

Not tried: a real Cursor Team account with the switch on in magpie (none
with on-demand here); the dashboard replies are fixtures shaped as
usage.test.mjs's. The option label is English only, as every plugin's
options are (magpie shows auth.options' label as given).
2026-10-29 16:29:48 +08:00
lexleizou 719de026e7 cursor 0.2.30: an Enterprise account's overall allowance from usage-summary (#391)
Fixes yetone/magpie#3288. An Enterprise account's GetCurrentPeriodUsage has no planUsage, so its card was empty. usage() now reads the website's /api/usage-summary with the same dashboard session the Grok Bot read builds, and shows an Enterprise window (amount/limit in USD, reset at the cycle's end) when the summary is Enterprise with overall enabled and used/limit real numbers. It is aside while team on-demand is unlimited or a measured budget has room, and a measured on-demand budget gets its own window. Anything else leaves the card empty, as before. Version 0.2.30.

The reviewer pushed 9435f59 on top of e2f03a0: main merged in (the only conflict was the version line; main took 0.2.27 to 0.2.29 meanwhile), version 0.2.30.

Run at 9435f59f0f0e4902e37f8634eebe8e41127cc9b1, on mote (mote-run, HOME=$(mktemp -d)):
- bun test packages/cursor: 328 pass, 0 fail (19 files). bun scripts/check.mjs cursor: ok.
- Full bun test: 3063 pass, 8 skip, 0 fail (257 files).
- Broken by hand on usage.test.mjs, each red then restored: the old Number() reads of overall.used/limit (the can't-be-read test; null/""/false/[] read as 0 again), no room check on the on-demand budget (the 50000 and 60000 of 50000 cases), the summary read off (10 tests).
- npm pack 0.2.30 and imported the packed index.mjs (CursorAuthPlugin, _internal). npm has 0.2.29.

Not tried: a real Enterprise account (none here); the summary's shape rests on the author's account. Still unanswered from the review: whether an Enterprise seat's summary carries a personal on-demand cap (individualUsage.onDemand); a ms-string billingCycleEnd gives no resetsAt. #372 touches the same `if (!u)` branch and now has to rebase onto this.
2026-10-28 23:49:08 +08:00
yetone 8f81a8aeb8 cursor 0.2.29: a native Run over HTTP/1.1 sends its history's blobs 16 at a time
ysm119 on Discord: Cursor models 30 s+ to first token, 1-4 min a turn.
0.2.28 (d9c858c) let BidiAppends go 16 at once, but only on runOnce, the
stateless fallback. Every real request goes through runNative, which
still opened HTTP/1.1 with atOnce=1, and nativeTransport.flush waits for
each write's callback, i.e. each append's answer. Cursor asks for every
history message as a KV getBlob, so a Run that fell back to HTTP/1.1
(a proxy or network that blocks h2) paid one ~265 ms round trip per
message before the model started.

Now runNative opens with H1.atOnce and kvReply: KV replies (field 3,
kv_client_message) overlap up to 16 at a time; any other message (a tool
result, the close) waits for every append before it, goes alone, and is
written once Cursor answered it, so it is never uncertain.

Measured with the real Cursor account in a sandbox HOME (bun 1.4.2,
this Mac; FORCE_H1 points h2 at a dead port so the Run falls back):
- HTTP/2, old and new alike: short prompt 5.0 s cold / 1.8 s warm;
  30-step agent request (121 messages, 40 tools, 233 KB) 6.5 / 2.9 s;
  100 steps (590 KB) 6.2-7.3 / 4.0-4.2 s.
- HTTP/1.1, 0.2.28: 30 steps 37-39 s to first token (~135 appends
  one after another); 100 steps 117-130 s.
- HTTP/1.1, 0.2.29: 30 steps 4.4-9.1 s; 100 steps 9.0-13.2 s (8 runs on
  grok-4.7@256k, 3 on composer-2.5), each answer correct about step 17
  and the first message, so the blobs arrive whole. A 6-turn tool loop
  over HTTP/1.1: turn 0 6.3 s, later turns 2.6-3.0 s.
- One early 0.2.29 run (100 steps) ended in a 187-byte error whose
  status wasn't captured; 11 runs after it, with the body printed,
  all passed. Its cause is unknown.

Run: bun test packages/cursor on mote, 316 pass 0 fail;
bun scripts/check.mjs cursor ok.
Broken by hand: runNative passing 1 again turns the two stall tests red;
the alone barrier disabled turns 4 red (the new openH1 test,
result-before-close, both uncertain-append tests).

Not tried: Opus (the account has no weekly quota for it, 429); the
reporter's own network or proxy, so whether he is on HTTP/1.1 is not
known; Cursor's own client as a baseline; a full sandbox magpie with
0.2.29 installed.
2026-10-28 15:59:22 +08:00
yetone 944610f8c8 cursor: each test file mints sign-in tokens of its own
The publish run for d9c858c (cursor 0.2.28) went red in
conversation.test.mjs: its first Run went to 127.0.0.1:42583, a closed
agent server of listwait.test.mjs, got ECONNRESET and fell back to
HTTP/1.1, which its fake API doesn't answer. listwait's tokens were
{exp: now+7200+n} with a counter from 0, byte for byte the tokens
conversation.test.mjs mints, so within one second the plugin's agent
endpoint and model list kept for listwait's token were found by
conversation's. conversation, maxmode and usage had the same latent
collision with each other. Each of those files, and context's tokens,
now carry a sub of their own (as http1, latency and the native tests
already did).

Run: on Linux (wsl-run), listwait then conversation was red 6 of 6
before and 0 of 6 after; listwait, conversation, maxmode and usage in
one run 0 of 4 red; bun test packages/cursor 314 pass. On mote, the
whole repo's bun test (2997 pass, 0 fail) and bun scripts/check.mjs (ok).
Broken by hand: the failing order was found by replaying CI's file order
and logging open()'s HTTP/2 failure (ECONNRESET to listwait's port).
Not tried: CI's exact random order beyond the replay.
2026-10-28 14:49:59 +08:00
yetone d9c858c3c0 cursor 0.2.28: a Run over HTTP/1.1 sends its BidiAppends 16 at a time, as cursor-agent does
Over HTTP/1.1 (where HTTP/2 can't open a Run) each client message goes up
as a BidiAppend. openH1 sent them strictly one at a time, so a new Run's
history (one blob a message, which Cursor asks for all at once) cost a
round trip to api2.cursor.sh per message before the model could start:
hundreds of round trips for a long conversation. cursor-agent 2026.10.01
(startAppendingInputs) keeps up to 16 appends in flight, numbered by
seqno (`m.length>=16&&await Promise.race(m)`).

openH1 now keeps up to atOnce (H1.atOnce, 16) appends on their way, in
seqno order; past that a write waits for one to finish. A native
session's Run passes 1: it counts a write as done only when Cursor
answered that append, so a tool result is never uncertain (the native
HTTP/1 tests hold that, maxInFlight 1). Seen from ysm119's report
(33-36 s to first token on claude-opus-5-5); whether he is on HTTP/1.1 is
not known.

Run: bun test packages/cursor (314 pass, 0 fail) and
bun scripts/check.mjs cursor (ok), on mote.
Broken by hand: with openH1 back to one at a time, the new http1 test is
red (most in flight 1, expected > 1). With runNative not passing 1, five
native-http1 tests are red (maxInFlight 3, uncertain-append and writeWait
cases), so the serial contract is held there; open.test.mjs's serial
openH1 tests now ask for atOnce 1 by name.
Not tried: a real Cursor account over HTTP/1.1; the serial cost was not
measured against Cursor itself, only counted against a fake.
2026-10-28 14:38:50 +08:00
yetone fc1457162c cursor 0.2.27: a chat request no longer waits for a model list Cursor can't give
ysm119 on Discord: claude-opus-5-5 through the plugin takes 33-36 s to its
first token on every request. A chat request picks its variant from the
account's model list (AvailableModels, up to 30 s) before it opens its
Run. A list Cursor couldn't give was never kept, so every request asked
for it again and waited for the ask to fail before its Run; a list past
its 10 minutes was waited for again too, and requests at once each asked.

listFor now gives the chat path the list without waiting when it needn't:
a list past its keep is used while a new one is asked for in the
background, requests at once share one ask (listing), and after a failed
ask requests go without the list for 5 minutes (LIST_RETRY), as the first
one did. Only a token with no list and no recent failure waits.
provider.models still fails when Cursor can't list, so magpie keeps its
list.

Measured against a fake Cursor (bun 1.4.2, on mote): with AvailableModels
failing after 3 s, every request's setup was 3003 ms before, re-asked each
time; the plugin's own setup is ~20 ms cold, ~4 ms warm, and stream
chunks reach the client 0-7 ms after the server writes them.

Run: bun test packages/cursor (314 pass, 0 fail) and
bun scripts/check.mjs cursor (ok), on mote.
Broken by hand: on the old index.mjs all three listwait.test.mjs tests
are red; with only answerOf back on usable(), the failed-list and stale-
list tests are red.
Not tried: a real Cursor account (its token is in the Keychain); whether
ysm119's AvailableModels fails or is slow is not confirmed.
2026-10-28 14:38:01 +08:00
yetone df4dfcd8f7 cursor 0.2.26: a picker model whose usable id is its other family goes as that id
ysm119 on Discord, after 0.2.25: claude-haiku-5-5-thinking still failed
its Test with no answer. A Team account's picker can have Claude Haiku 5.5
with thinking as its default, while cursor-agent models lists Haiku only
as claude-haiku-5-5 (no thinking). modelsOf looked up the usable ids of
the default's family alone, found none, and every Haiku id went out as a
picker variant (claude-haiku-5-5-thinking-high, -low, ...) the account
doesn't have. modelsOf now falls back to the same model's family with
thinking or without it, so each variant id goes as the id the account
lists.

Run: bun test packages/cursor (311 pass, 0 fail) and
bun scripts/check.mjs cursor (ok), in a sandbox HOME.
Broken by hand: with the fam lookup back to the default's family only,
the new context.test.mjs test is red (17 pass, 1 fail).
Not tried: a real Team account whose list has Haiku without thinking;
the owner's Cursor account doesn't show this shape. The fixture is
built from the report's ids, not captured bytes.
2026-10-27 17:06:02 +08:00
yetone cb776e2ebb cursor 0.2.25: a tiered family is named without its tier; a thinking id runs on the model without it
Reported by ysm119 (magpie Discord, 10-27, after 0.2.24): on the Team
account the Cursor list showed "Claude Opus 5 1M Medium Thinking",
"Claude Opus 4.7 1M Medium Thinking", "Claude Sonnet 4.6 1M Thinking",
"Claude Haiku 5.5" and so on, read as one fixed tier each ("没法设置模型
档位"), and the picked claude-haiku-5-5-thinking failed its test.

Cause:
- usableTitle (0.2.24) dropped effort words only at the end of Cursor's
  name, so a name with "Thinking" or "(NO ZDR)" after the tier kept
  "1M Medium". The entry already had the family's efforts as variants
  (magpie's reasoning levels); only its name said Medium.
- claude-haiku-5-5-thinking is an id 0.1.x listed and is still in the
  reporter's picks. When the account's list has no Haiku 5.5 with
  thinking, named() found no family and the id went to Cursor as it was:
  "AI Model Not Found".

Now:
- A usable-only family's name drops its default id's effort phrase, Fast
  and 1M wherever Cursor puts them, and keeps words of the model's name
  (GPT-5.1 Codex Max stays Max).
- An id with no family of its own runs on the same model with thinking
  toggled (usable-only family or picker variants), at the id's effort,
  before it would be sent as named.

Run:
- bun test packages/cursor: 310 pass, 0 fail; bun scripts/check.mjs
  cursor ok.
- Three new tests in context.test.mjs, built on the reporter's literal
  names; all three fail on 0.2.24's index.mjs (names kept "1M Medium",
  claude-haiku-5-5-thinking sent as is, a picker thinking-only Haiku
  asked as claude-haiku-5-5-low).

Not tried: the reporter's real Team list (their ids weren't sent; the
tests use Cursor's id pattern, claude-opus-5-thinking-high, for their
names), any real Cursor request, magpie end to end. A family whose ids
carry a suffix after the effort (the "(NO ZDR)" Fable, id unknown) may
still list one entry per tier.
2026-10-27 16:29:39 +08:00
yetone fc2866fc9e cursor 0.2.24: a family only cursor-agent lists runs as its usable ids
Reported by ysm119 (magpie Discord): on a Cursor Team account,
`magpie claude cursor/claude-opus-5-5@1m` waited and then failed with
"AI Model Not Found", and `cursor/claude-opus-5-5` the same, while
`cursor-agent models` lists claude-opus-5-5-low, -medium, -high, -xhigh,
-max (and -fast of each), and `cursor/claude-opus-5-5-low` works.

Cause: when the account's AvailableModels picker lacks a model (or a
picker model has no variant the account can use), the plugin sent the
family id or the literal `@<size>` id upstream, which Cursor doesn't know.

Now:
- A family GetUsableModels lists and the picker doesn't is listed once
  under its family id with its efforts, and a request goes as the usable
  id the effort and fast pick (claude-opus-5-5 + low -> claude-opus-5-5-low).
- A picker model whose chosen variant isn't usable goes as its family's
  nearest usable id.
- An `@<size>` id the list no longer has runs at the model's nearest
  size, in Max Mode past the model's window.
An account whose picker covers every usable id lists and sends as before.

Run:
- bun test packages/cursor: 307 pass, 0 fail; bun scripts/check.mjs cursor ok.
- Four new tests in context.test.mjs built on the reporter's literal ids
  (claude-opus-5-5-low ... -max-fast, "Claude Opus 5.5 1M Low").
- Broken by hand: the three tests for the new behaviour fail on 0.2.23's
  index.mjs; the "covered picker lists as before" test passes on both.
- Real account (owner's, read-only token): with claude-opus-5-5 dropped
  from the real AvailableModels reply, 0.2.23 sends "claude-opus-5-5@1m"
  and "claude-opus-5-5" and gets Cursor's 502 "AI Model Not Found: Model
  name is not valid", the reporter's error. 0.2.24 sends a usable id and
  Cursor takes the model (429 weekly limit on this account for Opus 5.5).
  Dropping grok-4.7 the same way: grok-4.7@500k, grok-4.7 and grok-4.7-low
  answer 200 on 0.2.24; grok-4.7@500k is 502 Not Found on 0.2.23. With
  the real, unmodified picker: grok-4.7@256k and composer-2.5 answer 200.

Not tried: a Team account (the reporter's), an Opus 5.5 reply that
succeeds (this account's weekly quota is spent), magpie end to end.
2026-10-27 14:37:11 +08:00
Kun Songandbborn2 36d8902601 cursor 0.2.23: send cursor-agent's team in x-cursor-team-id (#231)
cursor-agent sends the team a request is billed to in `x-cursor-team-id`, from
cli-config.json's `authInfo.activeTeamId`. Without it, Cursor takes the
token's default team. In an organization that team may have on-demand spend
turned off, and the request then fails with "Team budget limit reached".

The plugin now sends the same header on Run (both the native and the stateless
path) and on the dashboard calls. It takes the team only when the token's
`sub` is the config's `authInfo.authId`, so an account signed in from magpie
never gets another account's team. GetHardLimit and GetCurrentPeriodUsage still
go out with `{}`, as cursor-agent sends them. GetFilteredUsageEvents names the
team only when there is one. The config's location (CURSOR_CONFIG_DIR, then
$XDG_CONFIG_HOME/cursor, then ~/.cursor) and the team check (a positive
integer) match cursor-agent 2026.10.01's paths.js and request.js.

Run at d4476ff merged onto main 1fbe22b, in a sandbox HOME, with the network
pointed at a dead proxy:
- `bun test` (whole repo): 2640 pass, 0 fail. `bun test packages/cursor`:
  303 pass. `bun scripts/check.mjs cursor`: ok.
- Broke each change by hand, and team-id.test.mjs went red each time (11 pass,
  1 fail): the header removed from runNative, the header removed from runOnce,
  and the team put back into GetCurrentPeriodUsage's body.
- Real Cursor account (no team) through the plugin's loader: one chat turn with
  a config that has no team, and one whose activeTeamId is a team the account
  isn't in. Both returned 200 "ok", so a single-team account is unchanged. The
  author ran a real account in two teams: the budget-spent team returned 429,
  the other returned 200.

Not tried: a multi-team account here. Accounts signed in from magpie get no
team (#233 covers those).

Co-authored-by: bborn2 <bborn2@users.noreply.github.com>
2026-10-25 17:37:12 +08:00
yetone f0bd94c4e2 cursor 0.2.22: a heartbeat keeps a counted tool batch open, and its failure says how much came (#377)
Okxdd123's grok-4.7 step counted its batch, thought, then wrote one long
call for over 30 s with only heartbeats, and failed as "Cursor did not
complete its declared native tool batch". batchWait was reset by a
call, answered call, count or text, never a heartbeat, so a single long
call's arguments could not outlast it. A heartbeat (InteractionUpdate
13) now resets it while the batch is open; silence stays bounded by
idle (60 s) and a heartbeat-only stretch by quiet (240 s), as #2672 set.
The failure now reads "N of M calls came, K answered here, none since
X ms", the counts the report asked for.

Not changed: the issue's third ask, a stateless rebuild for this
failure. A streamed reply has already shown its reasoning by then, and
the rebuild only runs before output is exposed.

Run: the two new native-session tests and the updated #155 test are red
on the old code (3 fail) and green after; bun test packages/cursor 291
pass in a sandbox HOME; bun scripts/check.mjs ok. Not tried live: it
needs a real Cursor step writing one call for over 30 s.
2026-10-25 14:44:44 +08:00
yetone c9a0215f31 cursor: a continued Run that goes quiet after the caller's results ends (#364)
Test only. #364's tests covered the pause at a sealed batch but not the
resume after the submit: with resume() leaving the Run paused, every
test passed and a retained Run that went quiet on its second model call
would wait for lifetime again. This one is red with that break (times
out at 5 s) and green at cf1873e.

Run: packages/cursor native-e2e.test.mjs, Bun 1.4.2, sandbox HOME:
131 pass, 0 fail.
2026-10-24 20:35:20 +08:00
LooSheng cf1873e292 cursor 0.2.21: a Run Cursor stops answering ends, retained or stateless (yetone/magpie#2672) (#364)
A Run Cursor stops answering mid-turn now ends with a 502 that says so,
on both the stateless path (runOnce/decode) and the retained path
(NativeSession.pump), instead of holding the reply open until the agent
gives up (yetone/magpie#2672: two composer-2.5 turns waited 305 s).

Quiet wraps a Run's frames: 60 s with no message at all, or 240 s with
only Cursor's heartbeats (InteractionUpdate.heartbeat), ends it. Only
time spent waiting on Cursor's next frame counts; a retained Run parked
for the caller's tool results is paused (resultWait bounds it) and
resumes from nothing after the submit. Each frame gets a fresh wake
promise, so frames already passed on are not held for the stream's life
(review of cbd5d3b). cursor 0.2.20 -> 0.2.21.

Run at the reviewed head 6a17d61 (base 79e383c; main 8d687ad since
touched only kimi-work), Bun 1.4.2, sandbox HOME:
- packages/cursor `bun test`: 288 pass, 0 fail (17 files).
- `bun scripts/check.mjs`: every package ok.
- 20,000 frames of 50 KB through Quiet.frames with the stream left
  open: 95 MB RSS (1376 MB at cbd5d3b).

Broken by hand, each red:
- the long-lived `gone` promise put back: the WeakRef frames test fails;
- heartbeats counted as frames: both heartbeats-only tests fail;
- stateless path unwrapped: 3 stateless tests fail;
- resume() leaving the Run paused: no test went red. A test for it
  (a continued Run going quiet after the caller's results) follows in
  its own commit; red with that break, green at this head.
- decode's `e.quiet` branch removed: no test red (the message then
  reads "the reply broke off: Cursor went quiet: ..."; tests use
  toContain). Cosmetic, left as is.

Not tried by the reviewer: a real Cursor account, Windows, Cursor
actually going quiet (the author's live runs are on the PR).
2026-10-24 20:34:47 +08:00
yetone a41a8d3a57 cursor 0.2.20: the MCP server the caller's tools go to Cursor under is "tools", not "magpie"
What goes to Cursor named magpie in four places: the dynamic tool catalog
in the system prompt ('The MCP namespace "magpie" has the tools below' and
each <call> entry's "namespace":"magpie"), every CallDynamicTool call in
the history (args.namespace), each McpToolDefinition's provider_identifier
(field 4), and the server answered for mcp_state_exec_args (name and
identifier). magpie's LESSONS.md rule: text added to a vendor's prompt
names neither magpie nor the vendor's limits, with the care a header
change gets (5d33f060b / 3c4f8f9ae).

cursor-agent names a user's MCP server by its mcp.json label
(providerIdentifier = serverName) and a call by "<label>-<tool>"; read in
cursor-agent 2026.10.01-e373342. The plugin now does the same with the
generic label "tools" (NS), in all four places. Calls are read back under
NAMESPACES = ["tools", "magpie"]: a "<ns>-<tool>" name without field 5 is
stripped of either prefix, and a native exec's provider/server is accepted
as either, so a native session begun on 0.2.19 still has its calls served.
The non-native history is rebuilt from the caller's messages each request,
so it carries the new name at once.

Siblings in other packages that still name magpie upstream, filed, not
changed here: commandcode User-Agent and x-project-slug (#352), kimi-work
User-Agent (#353), qoder business.name (#354), autoclaw device_id (#355),
kimi-desktop's instructions tag (#356), opendesign's host fallback (#357),
layerfs tool descriptions (#358). Left alone as not upstream: X-Magpie-*
response headers, the x-magpie-cursor-session hook header (never sent to
Cursor), magpie_native/magpie_deferred usage fields, sign-in messages.

Test: upstream-words.test.mjs builds a Run (buildRun) from a conversation
with tools and a tool call, and checks that the catalog, every transcript
blob, the request bytes and the mcp_state answer contain no /magpie/i, and
that a call is read back as both "tools-read" and "magpie-read". Red on
the old index.mjs (2 of 3 fail: catalog, mcp_state); green now.
conversation, reasoning and native-test-wire expectations moved to
"tools"; native-e2e still sends provider "magpie", so the old name is
covered on the native path.

Run at this tree:
- bun test in packages/cursor: 279 pass, 0 fail (17 files).
- bun scripts/check.mjs: every package ok.
- Live, owner's Cursor account, sandbox HOME (scratchpad), the plugin's
  loader.fetch with one read_file tool, http2 writes scanned for "magpie":
  auto: turn 1 called read_file {"path":"notes.txt"}, turn 2 with the
  result answered "Pelican"; 0 chunks named magpie (the old index.mjs
  under the same scan: 2). grok-4.7-fast: the same two turns, 0 chunks.
  claude-4.6-sonnet: 429, not in this plan's weekly usage.
Not tried: a native session resumed across the upgrade against real Cursor
(covered by native-e2e's "magpie" provider against the fake server only).
2026-10-24 16:54:42 +08:00
yetone c845b17e9c cursor: http1.test counts a Run when its first message comes, not when its stream is read (#272)
Cause: the fake agent counted runs++ when the server's "stream" event
fired. In the region test the first Run stalls (mode "stall"), the plugin
gives up at H2.wait and goes on over HTTP/1.1, and the test then sets
mode "answer". On a loaded machine the server can read the stalled Run's
HEADERS only after that switch, so the stale stream was taken as a second
Run: ag.runs 2, expected 1. "Runs kept on HTTP/1.1 try HTTP/2 again once
H2.retryAfter has passed" has the same stall-then-answer shape. The plugin
is right; the fake miscounted. A Run now counts once its first message
arrives (the plugin writes it only after the head, so a stream whose
client gave up never brings one), and a stream already destroyed when it
is read isn't answered.

Run on macOS arm64, bun 1.4.2:
- Injected: the fake held the first stream and emitted it the moment the
  test set mode "answer". origin/main's test: red, Expected 1 Received 2,
  the issue's output. With this change: green. The retryAfter test under
  the same injection: red on origin/main, green now.
- Loaded: 8 parallel `bun test --rerun-each 15 packages/cursor/http1.test.mjs`
  at load average ~50: 8 x 240 pass, 0 fail.
- `HOME=$(mktemp -d) bun test` from the root: 1920 pass, 0 fail.
  `bun scripts/check.mjs`: ok.
Test-only, no version bump.
2026-10-21 07:39:22 +08:00
nicegui 0a2496bb3a cursor 0.2.19: conflicting native batch counts rebuild once from history before any output (#207, nicegui)
A Cursor native Run whose step lists two different tool counts (a Codex-to-Cursor failover hit "inconsistent native tool count") now retires the owner instead of throwing. When no native result was submitted to that Run and no Chat output was exposed, the request is rebuilt once from Chat history (the same stateless rebuild the missing-count case uses), with reason=inconsistent-batch-count in X-Magpie-Cursor-Continuity. A Run that had a result submitted, or a stream that already sent output, still returns the error. The decoder stops reading the failed Run at once. Cursor 0.2.19.

Reviewed at c43b93c (on main 0b58032, clean). Run there, HOME and XDG in a sandbox dir:
- packages/cursor `bun test`: 275 pass, 1 fail. The fail is latency.test "events never show in time", red 6 of 6 on untouched main 0b58032 under load average ~270; filed as #210.
- `bun scripts/check.mjs cursor`: ok.
- native-e2e -t "conflicting count": 4 pass. With index.mjs and native-session.mjs from main: 3 of 4 red (JSON and stream rebuild, submitted-result guard). With retentionIneligible forced true: the submitted-result test goes red.
- The fake Cursor is the test's HTTP/2 server on 127.0.0.1; no real account used. The conflict is injected; why Cursor sent two counts is still unknown.
2026-10-17 21:17:45 +08:00
yetone 2ea25b925b cursor: the latency test's far events show once their step has answered, and a step's wait is counted in asks, not ms (#159, #162, #165)
#159 and #162: the "far from Cursor" fake showed a Run's usage event
SHOWS (225 ms scaled) after the Run's stream closed. The step's wait
takes its last look about 180 ms after that close, so only ~45 ms stood
between "the event is not there yet" (what the test means) and "the
event is already there" (the step owns it and the sum moves). A loaded
machine eats 45 ms. #162's title guessed an earlier test's cached
usage; it was the step's own event showing inside its wait.

The fake now holds a far Run's event until the step whose Run it is has
answered, and shows it at once if that step already has: the state the
test is about, not a duration.

#165: test 1 bounded each step's wait in milliseconds, which load
stretches. Each wait asks once and the round trip is most of it, so the
bound is now at most 2 asks per step (its own event, plus what earlier
steps owe).

Run (bun 1.4.2, load average 280-295 throughout):
- Old test, cause injected by showing the event earlier (SHOWS - 50 ms):
  #159's failure; SHOWS - 80 ms: #162's. New test with the same
  injections: green.
- packages/cursor/latency.test.mjs: 9 of 9 green.
- packages/cursor whole package (HOME=$(mktemp -d) bun test): 3 of 3,
  272 pass, 0 fail.
- Broken by hand in index.mjs, each turned the new test red: the step
  waiting for its own event removed; owed() not gathering at the end;
  the ask bound raised (a step asking 3+ times).
Not run: the whole-repo suite (test-only change in one file).
2026-10-16 19:11:56 +08:00
yetone 0c35adbf03 cursor 0.2.18: a failed tool result tells Cursor isError, and a refused keychain read is not asked again for ten minutes
Two things magpie's built-in Cursor did that the plugin didn't, ahead of
the built-in's retirement:

- The stateless path (conversation) sent every tool result with
  isError false. A chat tool message with is_error: true (what magpie now
  sends for a failed tool, as the built-in's cursorResult told Cursor
  isError) is marked isError, as the native path already did.
- cliToken ran `security` on every call. It now reads the Keychain as the
  built-in's cursorKeychainToken (internal/provider/cursor.go; magpie
  #746, #2408): a read is kept 10s; a read that failed with anything but
  exit 44 (no such item) may have been a dialog the user said no to, and
  is not asked again for 10 minutes; reads go one at a time, so callers
  at once share one run. A sign-in and the read after `cursor-agent
  status` read afresh, as forgetCursorStatus / cursorTokenOf(true) did.
  README's "read on every request" says so now.

What was run (bun 1.4.2, macOS, load average ~280-300):
- parity.test.mjs (new, 5 tests): green. Broken by hand, each watched
  red, then restored: is_error ignored (1 red), cache check removed
  (3 red), denied backoff at 10s (1 red), exit 44 treated as refusal
  (1 red), no read serialisation (1 red).
- `security find-generic-password` for a missing item gives execFile
  err.code 44 (number) on this Mac, as the mapping assumes.
- Full `bun test` in packages/cursor, 7 runs: 272/272 green in 4; the
  other 3 red only in latency.test.mjs ("events never show in time",
  #159; "nothing naming the session", #162), which the change doesn't
  touch. On clean origin/main aec06bd, latency.test.mjs alone is red
  too, including "far from Cursor ... cache and all" (filed as #165).
- Not tried: a real Keychain dialog denial; the backoff is checked with
  a fake `security`.
2026-10-16 17:36:57 +08:00
yetone 3dbaa0b16f cursor 0.2.17: a tool-result continuation in a Run's last minute rebuilds before writing results, not 502 at the lifetime (#157, nicegui)
Run at this commit: packages/cursor `bun test` (isolated HOME) 267 pass, 0 fail; `bun scripts/check.mjs` ok. Version bump only.
2026-10-16 15:40:48 +08:00
nicegui 0b821908bc cursor: a tool-result continuation in a Run's last minute rebuilds before writing results, not 502 at the lifetime (#157, nicegui)
The 15-minute absolute lifetime spans all of a retained Run's tool
roundtrips. A tool-result continuation that arrives with no more than
min(60s, lifetime/10) left now retires the owner (410 "retired before
lifetime deadline") and rebuilds from the supplied history before writing
any result, instead of resuming and failing mid-segment with "native Run
lifetime expired". Replays of an already submitted batch keep their path.
Merging main resolved a conflict with a7614aa (#143): expireIn sets
expiresAt as well as the timer.

Reviewed at 75e481a (nicegui's 6f03753 plus the merge of main):
- packages/cursor `bun test` (isolated HOME) 267 pass, 0 fail, three
  times; `bun scripts/check.mjs` ok; PR CI run 38868447170 green, attempt 1.
- The near-expiry test fails on the source without the reserve check.
- Near-deadline injected by shifting Date.now() from the owner's
  expiresAt, not by waiting: 62s left resumes on the same Run (1 Run, 1
  result written); 59s and 0.5s left rebuild (2 Runs, no result written).
  With the check removed by hand, 59s and 0.5s go red.
2026-10-16 15:39:10 +08:00
yetone a7614aa2ff cursor: the lifetime-expiry test brings a Run's lifetime in after its first answer, not before it starts (#143)
The native retention test set NATIVE_LIMITS.lifetime = 65 before the
first ask. The lifetime counts from the Run's start, so on a loaded
machine the first Run expired before it answered: 410 where the test
wants 200. NativeSession now sets its deadline through expireIn(ms), the
constructor giving it the whole lifetime as before, and the lifetime case
calls owner.expireIn(65) after the first answer. The resultWait case
still sets its limit up front, since that wait counts from the answer.
The plugin's behaviour is unchanged, so there is no version bump.

Run:
- Injected: on the old test, a lifetime of 0–10 ms is red ("Expected: 200
  Received: 410"); 15 ms and up is green. The new test is green.
- HOME=$(mktemp -d) bun test, whole repo: 10 runs in a row, 0 fail
  each. On current main 2dd4328 plus this change: 1609 pass, 0 fail.
- bun test packages/cursor/latency.test.mjs 8 runs: green with this
  change. On main without it, 1 red in 8 runs. That red is
  "events never show in time" at load ~120, filed as #159. It is not
  this test. grok's login flake from an earlier run is #160.
2026-10-16 15:30:52 +08:00
yetone 2dd4328d5a cursor 0.2.16: a multi-step turn's last step reports its own share of usage, and a step's calls get batchWait from the latest one (#156, #155)
Run at this commit: packages/cursor `bun test` (isolated HOME) 266 pass, 0 fail; `bun scripts/check.mjs` ok. Version bump only.
2026-10-16 15:09:25 +08:00
yetone c7c6498d85 cursor: a multi-step turn's last step reports its own share of usage, and a step's calls get batchWait from the latest one (#156 erzay, #155 midmirror)
#156: a native Run of N tool steps ended with TurnEndedUpdate's totals as
the final step's prompt_tokens (1,105,934 on erzay's ~21-step turn, where
the real context was ~61K), and Codex compacted at once. The final step
now keeps its last model call's share, max(that call's chars/4 prompt
estimate, turn total / model calls), split proportionally across input,
cache read and cache write; the rest goes into usage.magpie_deferred
(merged with any settled stateless debt), so magpie still bills the whole
turn. On erzay's numbers that is ~52.7K reported, ~1.05M deferred.

#155: waitForBatch armed once, at a step's first call, so a step whose
calls arrive one by one as the model writes them (13 calls, 9 long-arg)
failed 502 "did not complete its declared native tool batch" ~30s after
the first call even though it never paused that long. The deadline now
restarts on every call, answered call, count and text/reasoning frame.

Run at this commit: packages/cursor `bun test` (isolated HOME) 266 pass,
0 fail, three times; `bun scripts/check.mjs` ok. The three new tests fail
on 4e64f26's source (prompt 1105934; sealed step failed at 300ms; stall
failed 303ms after the first call instead of after the latest).
2026-10-16 15:09:25 +08:00
yetone 2b67811af8 cursor 0.2.15: calls the bridge answers itself count toward Cursor's tool count, and KV replies wait for a slow link instead of failing the Run (#142, Evopower)
Run at this commit: packages/cursor `bun test` (isolated HOME) 263 pass, 0 fail; `bun scripts/check.mjs` ok. Version bump only.
2026-10-15 17:51:41 +08:00
yetone 1bf9113390 cursor: calls the bridge answers itself count toward Cursor's tool count, and KV replies wait for a slow link instead of failing the Run (#142, Evopower)
Cursor's tool_requests_listed (InteractionUpdate 27) counts every call of
the model's step, and is sent after them. That count includes calls the
plugin answers itself: a tool the request doesn't have (0.2.14's native
path refuses those) and Cursor's get_mcp_tools (exec 36). 0.2.14 counted
only the calls it accepted. A step with a refused call then either waited
30s for a call that never came (502 "did not complete its declared native
tool batch") or met the next step's count with the stale one (502
"inconsistent native tool count", the reporter's error). The stateless
decoder had the same miscount and hung. Both paths now count answered
calls toward the step and end a step whose calls were all answered without
one.

503 "native outbound messages limit reached": a long history goes out as
one blob per message, and Cursor asks for every blob at once. The native
transport caps its pending writes at 256 messages / 16 MiB and failed the
Run when a slow link backed them up past that. KV replies now wait for
room (NATIVE_LIMITS.writeWait, 30s) and fail only if the link doesn't
drain for that long. The stateless path writes directly and has no cap.

The fixtures are real Cursor frames captured on 2026-10-15 (model auto,
cursor-agent's agent.v1): get_mcp_tools plus a refused WebSearch in one
step followed by read_file, which gave 0.2.14 the reporter's exact
"inconsistent native tool count"; and read_file, refused WebSearch,
read_file under a count of 3, which gave 0.2.14 the batch timeout.

Run at this commit (on origin/main 43d93b0):
- packages/cursor `bun test` (isolated HOME): 263 pass, 0 fail.
- `bun scripts/check.mjs`: every package ok.
- Broken by hand: with native-session.mjs and index.mjs reverted to
  0.2.14, the new tests fail with "inconsistent native tool count",
  "native outbound messages limit reached", the batch wait, and the
  stateless decoder's hang; 4 of 5 red (the stateless mixed case passes
  on 0.2.14, which hands WebSearch to the caller there).
- Real Cursor, before the fix: the captures above reproduced both 502s
  through the plugin's native path. The 503 was not reproduced on a real
  link (my queue peaked at 160 of 256); it is reproduced in the test with
  a 16-message bound and a slow fake write.
- Real Cursor, after the fix (owner's account, model auto, the mixed
  prompt): native path 3 of 3 runs 200 with read_file a.txt and b.txt
  (WebSearch refused to the model), stateless 3 of 3 runs 200; a native
  Run with 1200 history messages 200.
- Not proven: the reporter's empty replies. They are likely the turns
  after these failures and are not addressed separately.
2026-10-15 17:51:41 +08:00
yetone e543ab1ae8 cursor 0.2.14: Run tool calls stay on one native Cursor session, and a tool past Cursor's limit resumes stateless, not as a failed turn (#135, nicegui)
Run at this commit: packages/cursor `bun test` (isolated HOME) 258 pass, 0 fail; `bun scripts/check.mjs` ok. Version bump only.
2026-10-15 13:40:06 +08:00
nicegui 33cdf7c1a8 cursor: Run tool calls stay on one native Cursor session and resume stateless after a long tool, not a failed turn (#135, nicegui)
Cursor's Run (native) calls stay on one Cursor session across a tool result. With them, a tool that runs longer than Cursor's limit resumes stateless, not as a failed turn. The session pool lives in native-session.mjs. It applies to a conversation's first user turn, and a new user turn goes stateless (see the README). X-Magpie-Cursor-Continuity says which path a request took.

The dashboard-usage ledger counts two distinct events in one response that share a millisecond, as main did. Only timestamps claimed by earlier fetches are left out. A new deferred-usage test covers it.

Run at the reviewed head 398aeddc0186cfc38189b1f05577b181aa2d587d (merge base 5d5d86e; main has no packages/cursor change since):
- packages/cursor `bun test` 3 times: 258 pass, 0 fail each time.
- `bun test latency` 12 times with fresh HOMEs: 12/12 pass.
- Broken by hand: putting back `if (claimed.has(key + "\0" + ev.timestamp) || at >= before()) continue` makes the new test "distinct same-millisecond events in one response are billed together, not again on later fetches" fail (2 pass, 1 fail). The head's line passes.
- `bun scripts/check.mjs`: all packages pass.
- `npm pack`, extracted into a fresh dir: index.mjs, native-session.mjs, package.json, README.md. `import("./index.mjs")` exports CursorAuthPlugin and _internal, and native-session.mjs imports.
- CI: test and on-npm green.

Not tried: a real Cursor account. The owner's stored plugin sign-in has no access token. The author reports a real Claude Code run through an isolated gateway: a child resumed stateless after a 125s tool, and all 6 requests returned 200.
2026-10-15 13:39:14 +08:00
yetone 3351e47715 cursor 0.2.13: a Run cancelled while it opens is closed upstream (#130), and dashboard usage is counted per account (#131)
#130: a cancel that landed between the HTTP/2 head and runOnce's abort
listener left the Run streaming upstream with its heartbeat, for nobody.
#131: claimed/owed/flights are keyed by account and conversation, so one
account's Run no longer collects another's debt from its own dashboard.

Run at this commit: full `bun test` (isolated HOME) 1292 pass, 0 fail;
`bun scripts/check.mjs` ok. Version bump only.
2026-10-15 04:15:31 +08:00