Commit Graph
40 Commits
Author SHA1 Message Date
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 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
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
焦寒营 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 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 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 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
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
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 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
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 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 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
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
geoqiao 4aae1ce7b9 cursor 0.2.11: a step's usage is its own; what it collected of earlier steps is magpie_deferred (#101)
A tool step whose usage event shows after its wait reports 0, and the
conversation's next step collects it. That step used to add it to its own
prompt_tokens, which clients read as context occupancy: pi saw 366940 tokens
(181270 + 185670) on a 300k window and compacted, though 185670 were in use.

Now a step's standard usage fields are its own Run's only. What it collected
of earlier steps goes in usage.magpie_deferred (prompt_tokens,
completion_tokens, cached_tokens, cache_write_tokens), which magpie bills with
the step (yetone/magpie PR) and clients ignore. ledger() also splits collected
events by timestamp: an event stamped from the Run's start on (less 1 s) is
the Run's own; earlier ones and carried counts are deferred. Before, a late
event of an earlier Run could land in a step's own count through gather().

Verified: bun test on packages/cursor, 88 pass (86 before, plus
deferred-usage.test.mjs); bun scripts/check.mjs. With the old index.mjs the
new test fails with Expected 185670, Received 366940. Against real Cursor
(composer-2.5, STEP_WAIT shortened to force late events, 2 rounds) the
deferred totals matched the dashboard's usage events token for token.
The repo-wide bun test has 2 failures in packages/trae that fail the same on
9074723 without this change.
2026-10-13 14:51:26 +08:00
yetone a885a16190 cursor 0.2.10: a Team member with no limit of their own spends the team's on-demand pool, which is shown and counted as the limit, not as unlimited (yetone/magpie#1868)
PaSSw0rds' Team account has on-demand turned on for the whole
organization: spendLimitUsage has no individualLimit, pooledLimit
"45120000" and pooledRemaining "38785730" are int64 strings, pooledUsed
6334270 a number, and GetHardLimit answers {"hardLimit": 451200} with or
without a team id. onDemandOf read that as "unlimited", as cursor-agent's
own usage view does, so the On-demand row showed only the member's own
$198.55 at 0%, and a spent team pool never counted the account used up.

Now a team member with no individualLimit and a pooledLimit > 0 gets a
fixed On-demand window on the pool: used = pooledUsed / pooledLimit,
display "$63,342.70 / $451,200.00 (you: $198.55)", not aside, so magpie
stops routing to it when the pool is spent. A hard limit that forbids
on-demand still reads as disabled; a team with no pool and a hard limit
still reads as unlimited. Dollar figures group thousands.

Run: bun test in packages/cursor (86 pass), bun scripts/check.mjs (exit 0).
The new test, built from the payloads quoted in yetone/magpie#1476, fails
on the old index.mjs (On-demand "$198.55", used 0, aside) and on a fix
that shows the member's spend against the pool instead of the pool's own.
Not tried against a real Team account.
2026-10-13 06:00:37 +08:00
niceguiandluolingpeng 126b105df1 fix(cursor): preserve assistant reasoning across tool continuations (#82)
Co-authored-by: luolingpeng <luolingpeng@lovart.ai>
2026-10-11 19:02:58 +08:00
yetone a298e5430f cursor 0.2.6: an account that may spend on-demand is not used up when its included usage is (fottencity on Discord)
A Cursor team (or personal plan) with on-demand spend allowed keeps being
served once Cursor Models / Other Models reach 100% of the included usage.
The usage read gave only those pools, so magpie counted the account used
up: smart routing put it last, and any failure while a pool read 100%
rested it until the billing period renewed (held to 8 days).

usage now also reads GetHardLimit and the period's spendLimitUsage, and
derives the On-demand state exactly as cursor-agent 2026.10.01's usage
view does (fixed limit, unlimited, disabled, unavailable). When on-demand
is fixed or unlimited, the pools are still shown but marked aside, and an
On-demand window ($used / $limit) is the allowance: used up at its limit,
never when there is none (then aside too). Disabled or not known: the
pools are the allowance, as before. Bot stays before Total.

Verified: bun test (77 pass); the three new on-demand tests fail on the
old index.mjs (pools not aside, no On-demand window); bun
scripts/check.mjs cursor. Fixture shapes come from cursor-agent's own
protobuf schema (GetCurrentPeriodUsageResponse.SpendLimitUsage,
GetHardLimitResponse); not tried against a real enterprise account.
2026-10-10 15:09:34 +08:00
Morgan 6bed2c1c32 cursor 0.2.5: a Cursor account with a Grok Bot allowance shows it on its Usage card (#64)
Grok Bot has an allowance of its own, apart from Cursor's monthly usage,
and it shows on cursor.com's dashboard only. auth.usage now also reads
https://cursor.com/api/dashboard/get-sand-usage-status with the sign-in
as the dashboard session (WorkosCursorSessionToken, as Cursor's dashboard
and CodexBar's CursorSandUsage.swift send it), and adds a "Grok Bot"
window: a paid grant with its weekly reset, a live trial as
"Grok Bot (trial)" without one. The window is aside, so Bot running out
never stops Cursor model requests, and it comes before Total so it is
among the Usage card's three rings. No grant, an expired trial, a
non-2xx, a redirect (not followed), a hang past 5 s or a reply that
isn't JSON each leave Cursor's own windows as they were.

Rebased onto main after cursor 0.2.4 (7516d63); package version is 0.2.5.
Optional pins for the 5 s AbortSignal.timeout and the Origin header are
not in this commit (Codex CLI unavailable for the edits); the runtime
guards stay.

Tests: usagePercent 130 is shown as 100 (and -5 as 0), and a 307 to a
login page is refused rather than followed; each fails with its guard
removed from botUsage.

HOME=$(mktemp -d) bun test packages/cursor: 73 pass, 0 fail.
HOME=$(mktemp -d) bun test (whole repo, on this commit atop main
7516d63): 1033 pass, 0 fail. bun scripts/check.mjs: all 15 ok. Checked
by hand once before an earlier squash: a Free Cursor account linked to
SuperGrok showed the Bot ring in magpie. Not tried with a paid Cursor
grant.
2026-10-10 11:49:29 +08:00
kazecreator 5b67ff41aa cursor 0.2.3: a Run HTTP/2 can't open goes over HTTP/1.1, as RunSSE + BidiAppend on api2 (#59, kazecreator)
Where a proxy or network blocks HTTP/2, a Cursor Run goes over HTTP/1.1 on api2: RunSSE down, a BidiAppend for each client message up. A failure that says HTTP/2 itself can't be had keeps later Runs on HTTP/1.1 for 10 minutes; a refused connection or a reset stream falls back for that Run only. Reviewed at f5c11b7, merged onto 0437abb: cursor 66 pass, whole repo 1026 pass, check.mjs all 15; each guarded piece broken by hand turns http1.test.mjs red.
2026-10-10 09:33:23 +08:00
yetone fb253f91d5 cursor 0.2.2: a model listed at a size Cursor has a fast variant of says fast: true (yetone/magpie#1360, loosheng)
0.2.0 stopped listing a model's -fast one and takes fast as the request's
service_tier, so magpie, which offered its Fast switch (the agent picker's
lightning, a group member's 标准速度/快速) for a model with a -fast one,
offered it for none. The runtime model now says fast: true when a variant
the account is served at that context size has fast=true (Opus 5.5 @ 300k,
Composer 2.5, Grok 4.7), and nothing otherwise (a size with no fast variant,
a model with no fast parameter, an account the usable list doesn't serve the
fast variants). Requests are unchanged.

Tested: new context.test.mjs case, which fails on 0.2.1 (no model says
fast); the whole package (50 tests) and scripts/check.mjs pass. Not tried
with a real Cursor account.
2026-10-09 05:14:56 +08:00
geoqiao 8cd5a0fad8 cursor 0.2.0: the list is Cursor's picker, a model once per context size with that window; effort and fast are the request's (#51)
* cursor 0.2.0: the list is Cursor's picker, a model once for each context size with that window (claude-opus-5-5@300k, @1m), and effort and fast are the request's, sent as the variant's parameters

The usable list (AgentService/GetUsableModels) names a model once for each effort and speed, and the window was read off the name: 1M when it said 1M, else 200K. The names say 1M of models Cursor serves at 300K outside Max Mode ("Claude Opus 5.5 1M"), and nothing of the 300K Sonnet and Haiku or the 256K Grok have, so on this account 110 of 153 names gave a wrong window: Opus too large, Sonnet, Haiku and Grok too small, and the agents compacted at the wrong point. The request carried no context parameter either, so the window Cursor ran at was its own choice, not the one magpie reported. The same id could go to a 300K and a 1M variant.

Now the list is Cursor's model picker alone (AiService/AvailableModels, asked as the CLI asks it: useModelParameters, doNotUseMarkdown), the way pi-cursor-sdk lists Cursor's catalog. A model with a context parameter is offered once for each size, as <model>@<size> named "<name> @ <size>", its window that many tokens; one without is offered once, its window Cursor's contextTokenLimit (Max Mode's for a model served only there), 200K when Cursor gives none. Effort is not a model of its own: the model's efforts (effort / reasoning_effort / reasoning; extra-high is xhigh) are its variants, the request's reasoning_effort is fitted to the nearest and sent as that parameter, and none turns a Claude's thinking off. Fast is not one either: a service_tier of priority or fast sends fast=true, anything else fast=false, so it is paid for only when asked. A request goes as the variant those parameters pick, by the variant's legacySlug (claude-opus-5-5-medium): the agent API refuses the picker's base name with 502 "AI Model Not Found: Model name is not valid". It goes in Max Mode when that variant is Max Mode's (a 1M size; Opus 300K with fast), or, with no variant for the size, when the size is over Cursor's limit outside it; the "Max Mode Required" retry stays. Hidden, Tab-only and chat-only models stay out, as in the CLI.

The ids change (cursor/claude-opus-5-5 is cursor/claude-opus-5-5@300k; the -fast, -low and -thinking models are gone), so 0.2.0: a model picked in magpie or an agent's config has to be picked again. An id the list doesn't have goes to Cursor as it is named, with the default window. poolBase and firstParty take the @size off, so usage pools as before (grok-4.7@256k Cursor Models, claude-opus-5-5@300k Other Models).

context.test.mjs (new) covers the list, the windows, the variants and the request's parameters and mode; maxmode.test.mjs (rewritten) checks what reaches a fake agent API; usage.test.mjs adds the sized ids. HOME=$(mktemp -d) bun test: 45 pass, 0 fail; check.mjs cursor passes. Tried with a real Cursor account: claude-opus-5-5@300k goes as claude-opus-5-5-medium with context=300k and answers, grok-4.6 as cursor-grok-4.6-high, and pi -p --model magpie/cursor/claude-opus-5-5@300k answers; the base name got the 502 above.

* cursor 0.2.0: an id 0.1.x listed still runs as the variant it stood for, and a variant the account hasn't got is neither offered nor asked for (review of #51)

An id the new list doesn't have went to Cursor as it was named. The ids 0.1.11 listed are families of the variants' own ids (claude-opus-5-5, claude-opus-5-5-fast, claude-haiku-5-5-thinking, cursor-grok-4.6), and they are saved in agents' configs, magpie's picks and routing groups: request(raw, "claude-opus-5-5", "high") was {id: "claude-opus-5-5", params: [], maxMode: false}, the bare name the agent API answers 502 "AI Model Not Found" for, with the effort dropped.

Now an id the list doesn't have is read as one of Cursor's own (named): a variant's legacySlug is that variant; a family of them, taken apart as 0.1.x's splitID did, is the family's variant nearest the default, fast for a -fast family, thinking as the family says, at the effort the id names when the request names none; the picker's name for a model, one of its legacySlugs or idAliases, is its default. Each is at the variant's context size, the default's when two sizes share the id. The request's reasoning_effort and service_tier count as for a listed model. The family is tried before the picker's name, so claude-haiku-5-5 stays the Claude without thinking it was in 0.1.11 where Cursor has variants named so; where it has none it is the model's default. Anything else still goes as it is named.

The usable list (AgentService/GetUsableModels) is read again, beside the picker: a variant whose legacySlug isn't in it is dropped, the model's efforts and sizes are the ones its remaining variants have, and a request no remaining variant matches goes as the nearest of them, not as the default's id with parameters the account hasn't got. A model the usable list has nothing of is the picker's alone (GLM-5.3, as 0.1.7 found) and is kept whole; a usable list Cursor can't give leaves the picker as it is.

answerOf's comment says what pick does with no service_tier (fast off). context.test.mjs checks the PICKER_SKIP names stay out (claude-4.5-haiku, claude-haiku-4-5), each id 0.1.11's offered() gives for the fixture's slugs, variant ids and a model's legacy slug, and the usable list's filter; maxmode.test.mjs checks claude-opus-5-5 reaches the fake agent API as claude-opus-5-5-medium. On b33ec2f's index.mjs the three new context tests and that maxmode test fail. HOME=$(mktemp -d) bun test: 48 pass, 0 fail; check.mjs cursor passes. Not tried with a real Cursor account, and not read against cursor-agent's source (neither is on this machine): the old-id rules follow the review's description and 0.1.11's splitID.
2026-10-08 22:03:11 +08:00
yetone 288c6bc9c9 cursor 0.1.10: far from Cursor a conversation's tool steps add up to what Cursor counted, cache included (yetone/magpie#1053, #33). The tool-step usage-event wait of 0.1.9 (first ask at 1.5 s, every 0.5 s, up to 6 s) never met an event on the reporter's network (Windows, mainland China: a GetFilteredUsageEvents round trip of ~4.2 s, the event 4–5 s after the Run closes), so tool steps were counted as their whole prompt estimated with no cache (fable 13/13 steps, 0% cached; opus 27%) where Cursor counted 95–99%, and every tool step waited the full 6 s. A tool step's Run is now owed by its conversation (only when a conversation_id names the session): the step counts every event of the conversation's owed Runs that shows within the same wait, its own or earlier ones, and says 0 used when none has; the conversation's next Runs collect the rest in the background from 5 s after the owed Run closed, and a step that ends the turn waits for whatever is still owed (in-flight collections, then a poll for the rest). Events are claimed once, by count, so the conversation's prompt, cache read, cache write and output add up to Cursor's dashboard, some of it a step late. After 3 steps in a row left something owed an account's tool steps stop waiting (asked again every 10th). A Run that fails after collecting gives it back; an account that can't read its events (4xx) and a Run with no session id are estimated as before. latency.test.mjs runs whole conversations through the plugin against a fake Cursor with the reporter's latency scaled 1/20 and the reporter's literal events (in 2 / cacheRead 63457 / cacheWrite 3081, in 2 / 66538 / 14756, in 4 / 67872 / 2392): on 0.1.9 the 3-step conversation sums to 137936 prompt / 131329 cached instead of 218104 / 197867, and skipped steps still wait the full window (292 ms > 150); both pass now, 20 of 20 runs, and stepusage + latency pass with --rerun-each 20. HOME=$(mktemp -d) bun test: 682 pass, 0 fail; check.mjs cursor passes. Not tried with a real Cursor account on a high-latency network. 2026-10-07 03:17:08 +08:00
yetone 10bf7c4364 cursor 0.1.9: a step that calls tools reports what it used, the cache included (yetone/magpie#676) — Cursor tells a turn's usage (TurnEndedUpdate) only once the client has run the tools and sent their results in the same Run, and the caller runs them after the Run is closed, so a tool step had none: its input was estimated with no cache (2395 / 0 where Cursor counted 4265, 4224 of them cached). After the calls it sends only the checkpoint (no token details) and heartbeats, and a cancelled Run ends with an error and no usage. Every Run is counted in the dashboard's usage events (DashboardService/GetFilteredUsageEvents) by its conversation_id, input apart from the cache read and written, as TurnEndedUpdate does; one shows about 2.5 s after the Run closes. So a tool step with no TurnEnded closes the Run, then looks for its event (after 1.5 s, every 0.5 s, up to 6 s): its conversation's, no older than the Run, not already counted; else the estimate as before. stepusage.test.mjs fails on the old code and passes. Tried with the real Cursor account through a sandbox magpie's plugin host: grok-4.7-fast tool calls report 6186 in, 6144 cached, 121 out (0.1.8: 5057 estimated, 0 cached); streamed too. 2026-10-03 21:10:20 +08:00
yetone 3ae3e4393e cursor 0.1.7: a model Cursor serves only in Max Mode is asked for in Max Mode, and the models Cursor's picker offers beyond the CLI's list (GLM-5.3, GLM-5.3 Flash) are listed (ARNO on Discord: "Cursor: Max Mode Required: The model "gpt-5.6-luna-low" requires Max Mode to be enabled"; "cursor provider 里少了 glm-5.3 和 glm-5.3-flash")
The Run's model went as ModelDetails and RequestedModel with its id alone, never max_mode (ModelDetails field 7, RequestedModel field 2), so a model Cursor serves only in Max Mode was refused. cursor-agent (2026.10.01) turns Max Mode on for such a model itself: requiresMaxMode is supportsNonMaxMode === false or a variant's isMaxMode in AiService/AvailableModels, and a usable model's own maxMode is kept. Now the list notes Max Mode from GetUsableModels' maxMode and from the picker (AvailableModels with useModelParameters, as the CLI asks for it), the Run sends it, and a model neither says it of is asked once more in Max Mode when Cursor answers "Max Mode Required" (the CLI's MAX_MODE_REQUIRED), and in Max Mode from then on. An account Max Mode isn't open to gets Cursor's own answer.

The list was GetUsableModels alone, which is `cursor-agent models`; Cursor's picker offers models it leaves out. The picker's models that no usable id, name or slug names are added: one per variant with a legacy slug, else the model by its name with its default variant's parameters, sent as RequestedModel.parameters; hidden, chat-only, Tab-only and non-agent models, and the four the CLI drops, stay out. A picker Cursor can't give leaves the list as it was.

The tests now import nonet.mjs first: fetch and HTTP/2 reach only this machine, so a test without its fake, or work still running after it, can't send a token to Cursor. maxmode.test.mjs (fake API and agent API: the list with GLM-5.3 and its Flash and Max Mode marked, the picker down, the Run's max_mode and parameters, the retry after Cursor's refusal) fails without the change (5 of 5) and passes with it; bun test packages/cursor (27 pass) and bun scripts/check.mjs pass. No request was made to Cursor.
2026-10-02 22:10:35 +08:00
yetone 15e66f6792 cursor 0.1.6: a conversation's Runs keep one conversation_id, so Grok's and Opus's prompt cache on Cursor sticks, and Cursor's usage no longer counts the cache twice (#6, the port of yetone/magpie#498's 0f415708 the plugin missed)
buildRun gave every Run a new random AgentRunRequest.conversation_id, so Cursor's backend sent each turn to whichever machine and the prompt cache hit only by chance (congee949: cache_read 0, 1152, 0, 0, 0, 0 over six turns of one Grok conversation). The id is now made as the built-in's cursorConversation makes it: a UUID hashed from what names the session — the request's prompt_cache_key (Codex's thread id), else the session magpie (or OpenCode) tells the new chat.headers hook, which the hook hands the loader's fetch in x-magpie-cursor-session and which goes no further — together with the conversation's first user message, so subagents under one session are conversations of their own. With nothing naming the session it stays random per Run: magpie's own "magpie-<24 hex>" session, made of the first message alone when the agent names none, is taken as none, as the built-in's nativeSessionOf does. The hook only marks requests to cursor, as every plugin's chat.headers sees every provider's.

TurnEndedUpdate.input_tokens counts the whole prompt, the cache read and written included; it was taken as the uncached input and the cache added again for prompt_tokens. Now, as cursorUsage: input = max(input_tokens - cache_read - cache_write, 0), reasoning_tokens (field 5) given as completion_tokens_details.reasoning_tokens. The prompt is guessed only when Cursor counted nothing at all, not when it was all read from the cache.

conversation.test.mjs runs the plugin against a fake Cursor (its API a stand-in fetch, the agent API an HTTP/2 server on 127.0.0.1, any other connection refused): a session's turns keep one id, another session or another first message gets its own, prompt_cache_key wins over the host's session, no session gives a new id each Run, the hook leaves other providers alone, and the issue's numbers come out counted once. All five fail against 0.1.5.
2026-10-02 21:50:13 +08:00
yetone d7385c87c4 cursor: Cursor — cursor-agent's browser sign-in (PKCE poll), its existing sign-in or an API key; agent.v1 Run over HTTP/2 as magpie's gateway does it, with tool calls; tried with real requests. README lists every package so far 2026-09-30 17:17:06 +08:00