pi-cursor-inference 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/LICENSE +1 -1
- package/README.md +59 -9
- package/dist/index.mjs +5 -5
- package/docs/brand.md +153 -1
- package/docs/gallery.png +0 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# pi-cursor-inference
|
|
2
2
|
|
|
3
|
+
## 0.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Advertise image, thinking, context-window, and Max Mode support from each model's matched Cursor catalog metadata, retain the real Cursor wire selection behind synthetic family and Max IDs, and omit unmatched selections instead of assigning permissive fallback capabilities ([#7](https://github.com/victor-software-house/pi-cursor/pull/7)).
|
|
8
|
+
- Attribute the package's MIT license to Victor Araújo personally ([#5](https://github.com/victor-software-house/pi-cursor/pull/5)).
|
|
9
|
+
- Document reported per-response token accounting, including absent and basic-usage limitations, and the exhaustive formatted-source boundary between RunInference usage, DashboardService event, conversation/time-bounded and aggregate costs, quoted usage-based prices, and external billing surfaces; use direct equality language in reconciliation messages ([#7](https://github.com/victor-software-house/pi-cursor/pull/7)).
|
|
10
|
+
|
|
11
|
+
## 0.0.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Correct the pi.dev gallery preview with a native 4K 16:9 composition and make the README's implementation links resolve from npm and pi.dev ([`3f525e6`](https://github.com/victor-software-house/pi-cursor/commit/3f525e6393f3eff23f16cd4aa0f21004db2dfbe4)).
|
|
16
|
+
|
|
3
17
|
## 0.0.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -38,8 +38,11 @@ records the complete history review performed before the repository became publi
|
|
|
38
38
|
- Native Pi OAuth through `/login cursor`, plus `PI_CURSOR_TOKEN` for headless use.
|
|
39
39
|
- Dynamic model discovery from `AvailableModels`, `GetUsableModels`, and
|
|
40
40
|
`GetDefaultModelForCli`.
|
|
41
|
-
-
|
|
42
|
-
|
|
41
|
+
- Per-model image and thinking support is advertised only when `AvailableModels` explicitly enables
|
|
42
|
+
it. Selectable families without complete catalog metadata are omitted rather than receiving
|
|
43
|
+
invented capabilities.
|
|
44
|
+
- Normal and Max rows respect Cursor's separate mode flags. Their context windows follow the
|
|
45
|
+
selected default variant's `context` parameter when present, then the catalog token limit.
|
|
43
46
|
- Streaming thinking text when the provider supplies it, opaque reasoning signatures, text,
|
|
44
47
|
usage, generic tool-call argument deltas, and tool continuations.
|
|
45
48
|
- Final response assembly always preserves routed thinking text when Cursor's final message carries
|
|
@@ -70,16 +73,61 @@ Enterprise plans. When the backend returns a per-model breakdown, **Tab** switch
|
|
|
70
73
|
**Summary** and **Models**; `r` refreshes and `q`/Esc closes the pane.
|
|
71
74
|
|
|
72
75
|
The pane uses captured DashboardService calls and renderer-defined units. It does not infer prices
|
|
73
|
-
from model tokens or
|
|
76
|
+
from model tokens or substitute values for missing samples. Optional failed calls remain visible as
|
|
74
77
|
named misses while available usage still renders. Outside TUI mode, print writes plain text, JSON
|
|
75
78
|
emits a custom message event, and RPC uses a notification.
|
|
76
79
|
|
|
80
|
+
## Turn usage and billed cost
|
|
81
|
+
|
|
82
|
+
When RunInference supplies a usage arm, the completed Cursor assistant response stores those token
|
|
83
|
+
counts in Pi's standard message usage fields. `extendedUsage` supplies input, output, cache-read,
|
|
84
|
+
and cache-write counts and takes precedence. Basic `usage` supplies only prompt and completion
|
|
85
|
+
counts, so the cache fields remain zero. A successful response with no usage arm retains the
|
|
86
|
+
initialized zero values; those zeros are not provider-reported token measurements.
|
|
87
|
+
|
|
88
|
+
The typed RunInference response contract has no money field. Its `providerMetadata` arm is an untyped
|
|
89
|
+
object, but the formatted client does not read a billed-cost key from it. Cursor models therefore use
|
|
90
|
+
zero price rates in Pi, and Pi's per-turn `cost` remains zero rather than applying a rate table that
|
|
91
|
+
can differ from the account's billed result.
|
|
92
|
+
|
|
93
|
+
Fine-grained billed-cost records exist, but not in the RunInference response:
|
|
94
|
+
|
|
95
|
+
- The pinned Cursor client schema includes DashboardService `GetFilteredUsageEvents`. Its event rows
|
|
96
|
+
carry model, Max Mode, token counts, model cost (`tokenUsage.totalCents`), Cursor Token fee,
|
|
97
|
+
`chargedCents`, timestamp, client type, and optional `conversationId`. The current `/cursor usage`
|
|
98
|
+
pane calls only aggregate DashboardService methods; account/role access to the filtered endpoint
|
|
99
|
+
has not been live-verified for this package.
|
|
100
|
+
- The same DashboardService schema includes `GetClientUsageData`, whose request takes
|
|
101
|
+
`conversationId` and an int32 `timestampBeforeRequest`, and whose response contains named
|
|
102
|
+
`costInCents` items. Exact-symbol searches find no caller or field consumer in the full packaged
|
|
103
|
+
Cursor 3.18.9 workbench or agent-host JavaScript, so the source does not establish the timestamp
|
|
104
|
+
unit, item meanings, settlement timing, or concurrent-request behavior.
|
|
105
|
+
- `AiService.CheckUsageBasedPrice` returns cents and a price ID for proposed feature details. The
|
|
106
|
+
formatted workbench uses it only to render a usage-based-pricing preflight before enablement; it
|
|
107
|
+
has no conversation or invocation identifier and is not measured post-response usage.
|
|
108
|
+
- The official [Admin API usage-events endpoint](https://cursor.com/docs/account/teams/admin-api#get-usage-events-data)
|
|
109
|
+
exposes a closely matching event shape through separate Team Admin API-key authentication. Its
|
|
110
|
+
documented data is aggregated hourly.
|
|
111
|
+
- Cursor's [Agent SDK](https://cursor.com/docs/sdk/python) exposes eventual billed cost by local turn
|
|
112
|
+
or cloud run through `agent.get_usage()`. That interface belongs to Cursor's agent runtime, which
|
|
113
|
+
this package does not use because Pi owns the agent loop, tools, execution, and transcript.
|
|
114
|
+
|
|
115
|
+
Neither DashboardService monetary shape nor the Admin API usage-event shape exposes RunInference's
|
|
116
|
+
per-call `invocationId`. `pi-cursor` sends the stable Pi session ID as Cursor's `conversationId`, so
|
|
117
|
+
several inference calls share that identifier. A model/timestamp/token match may identify an event in
|
|
118
|
+
ordinary data, and `GetClientUsageData` offers a conversation/time boundary, but neither contract
|
|
119
|
+
provides an identifier-level join to one RunInference call. Their attribution and settlement
|
|
120
|
+
semantics are not established under concurrent requests. `pi-cursor` therefore does not assign
|
|
121
|
+
those cents to individual Pi messages. See the
|
|
122
|
+
[formatted-source audit](https://github.com/victor-software-house/pi-cursor/blob/main/docs/protocol/turn-accounting-source-audit-2026-09-04.md)
|
|
123
|
+
for the exact pinned modules, full-bundle searches, and fields.
|
|
124
|
+
|
|
77
125
|
## Configuration
|
|
78
126
|
|
|
79
127
|
`/cursor settings` persists two toggles in Pi's agent directory:
|
|
80
128
|
|
|
81
129
|
- **Strict reconciliation** defaults to **on**. When enabled, streamed and final response copies
|
|
82
|
-
must
|
|
130
|
+
must be structurally equal; tool IDs, names, and arguments are checked before local execution. When
|
|
83
131
|
disabled, Cursor's final content is accepted without that cross-copy equality check. Local stream
|
|
84
132
|
validity, advertised-tool validation, and final-content parsing remain mandatory.
|
|
85
133
|
- **Persist diagnostics** defaults to **off**. When enabled, each assistant message carries a
|
|
@@ -94,8 +142,9 @@ never erase non-empty streamed thinking, even when strict reconciliation is off.
|
|
|
94
142
|
|
|
95
143
|
Cursor Max Mode defaults to **off**, matching the IDE's ordinary composer model configuration.
|
|
96
144
|
Catalog entries with a distinct Max Mode appear as separate `-max` models and carry Cursor's
|
|
97
|
-
captured context parameter automatically.
|
|
98
|
-
`
|
|
145
|
+
captured context parameter automatically. A model that supports only Max Mode produces only its
|
|
146
|
+
`-max` row, while the request still uses the underlying selectable Cursor model ID. Advanced callers
|
|
147
|
+
may override the Cursor-specific `cursorMaxMode` and `cursorContext` sampling parameters per request.
|
|
99
148
|
|
|
100
149
|
## Verification
|
|
101
150
|
|
|
@@ -126,8 +175,9 @@ not claimed.
|
|
|
126
175
|
|
|
127
176
|
- No `AgentService/Run`, Cursor-native tools, MCP projection, or agent bridge.
|
|
128
177
|
- No multi-account database, keychain/1Password reader, or installed-IDE dependency.
|
|
129
|
-
- No
|
|
178
|
+
- No synthesized Grok thinking summary: current RunInference measurements provide an opaque
|
|
130
179
|
continuation signature but no reasoning text for Grok 4.6.
|
|
131
180
|
|
|
132
|
-
See
|
|
133
|
-
[
|
|
181
|
+
See the
|
|
182
|
+
[implementation and verification record](https://github.com/victor-software-house/pi-cursor/blob/main/docs/plan.md)
|
|
183
|
+
and [protocol and scope decisions](https://github.com/victor-software-house/pi-cursor/blob/main/docs/decisions.md).
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{arch as e,env as t,platform as n,stderr as r}from"node:process";import{DynamicBorder as i,getAgentDir as a,getSettingsListTheme as o}from"@earendil-works/pi-coding-agent";import{Container as s,Input as c,Loader as l,SettingsList as u,Spacer as d,Text as f,fuzzyFilter as p,matchesKey as m,truncateToWidth as h,visibleWidth as g}from"@earendil-works/pi-tui";import{P as _,match as v}from"ts-pattern";import{chmodSync as y,mkdirSync as ee,readFileSync as te,writeFileSync as ne}from"node:fs";import{dirname as re,join as ie}from"node:path";import{create as b,fromBinary as ae,fromJson as oe,toBinary as se}from"@bufbuild/protobuf";import{request as ce}from"node:https";import{brotliDecompressSync as le,gunzipSync as ue,gzipSync as de}from"node:zlib";import{fileDesc as x,messageDesc as S}from"@bufbuild/protobuf/codegenv2";import{execSync as fe}from"node:child_process";import{createHash as C,randomBytes as pe,randomUUID as me}from"node:crypto";import{mkdir as he,readFile as ge,writeFile as _e}from"node:fs/promises";import{networkInterfaces as ve}from"node:os";import{setTimeout as ye}from"node:timers/promises";import{ValueSchema as be,file_google_protobuf_struct as xe}from"@bufbuild/protobuf/wkt";import{isDeepStrictEqual as Se}from"node:util";import{calculateCost as Ce,createAssistantMessageEventStream as we,createProvider as Te,parseStreamingJson as Ee}from"@earendil-works/pi-ai";import{connect as De}from"node:http2";import{Buffer as Oe}from"node:buffer";var ke=class extends s{searchInput=new c;viewText;detailText;footerText;keybinds=new Map;selectedIndex=0;activeViewId;onSelect;onCancel;items;theme;keybindings;options;constructor(e,t,n,r){super(),this.items=e,this.theme=t,this.keybindings=n,this.options=r,this.activeViewId=r.defaultViewId??r.views?.[0]?.id,this.searchInput.focused=!0,this.viewText=new f(``,1,0),this.detailText=new f(``,1,0),this.footerText=new f(``,1,0),this.addChild(new i(e=>t.fg(`border`,e))),this.addChild(new d(1));let a=r.subtitle!==void 0&&r.subtitle!==``?`${t.fg(`accent`,` ${r.title}`)} ${t.fg(`dim`,r.subtitle)}`:t.fg(`accent`,` ${r.title}`);this.addChild(new f(a,1,0)),this.addChild(this.viewText),this.addChild(new d(1)),this.addChild(new f(this.theme.fg(`dim`,` ${r.searchLabel??`search`}:`),1,0)),this.addChild(this.searchInput),this.addChild(new d(1)),this.addChild({render:e=>this.renderRows(e),invalidate:()=>{}}),this.addChild(new d(1)),this.addChild(this.detailText),this.addChild(new d(1)),this.addChild(this.footerText),this.addChild(new d(1)),this.addChild(new i(e=>t.fg(`border`,e))),this.refresh()}addKeybind(e,t){this.keybinds.set(e,t)}handleInput(e){let t=this.keybinds.get(e);if(t){t();return}let n=this.options.views?.find(t=>t.key===e);if(n){this.activeViewId=n.id,this.selectedIndex=0,this.refresh();return}let r=this.filteredItems();if(this.keybindings.matches(e,`tui.select.up`))this.selectedIndex=r.length===0?0:this.selectedIndex===0?r.length-1:this.selectedIndex-1;else if(this.keybindings.matches(e,`tui.select.down`))this.selectedIndex=r.length===0||this.selectedIndex===r.length-1?0:this.selectedIndex+1;else if(this.keybindings.matches(e,`tui.select.confirm`)){let e=r[this.selectedIndex];e&&this.onSelect?.(e.value);return}else if(this.keybindings.matches(e,`tui.select.cancel`)){this.onCancel?.();return}else{let t=this.searchInput.getValue();this.searchInput.handleInput(e),this.searchInput.getValue()!==t&&(this.selectedIndex=0)}this.refresh()}activeView(){return this.options.views?.find(e=>e.id===this.activeViewId)}filteredItems(){let e=this.activeView(),t=e?this.items.filter(t=>e.predicate(t)):this.items,n=this.searchInput.getValue().trim();return n?p(t,n,e=>`${e.value} ${e.label} ${e.description} ${e.searchText??``}`):t}refresh(){let e=this.filteredItems();this.selectedIndex=Math.max(0,Math.min(this.selectedIndex,Math.max(0,e.length-1))),this.viewText.setText(this.renderViewLine(e.length));let t=e[this.selectedIndex];this.detailText.setText(t&&this.options.detail?this.options.detail(t,this.theme):``),this.footerText.setText(this.renderFooter())}renderViewLine(e){let t=this.options.views??[],n=this.activeView(),r=this.theme.fg(`dim`,`${e}/${this.items.length}`);return t.length===0?` ${r}`:` ${t.map(e=>{let t=e.key!==void 0&&e.key!==``?`${e.key} ${e.label}`:e.label;return e.id===n?.id?this.theme.fg(`accent`,t):this.theme.fg(`muted`,t)}).join(this.theme.fg(`dim`,` · `))} ${r}`}renderRows(e){let t=this.filteredItems();if(this.selectedIndex=Math.max(0,Math.min(this.selectedIndex,Math.max(0,t.length-1))),t.length===0)return[this.theme.fg(`muted`,` No matching commands`)];let n=this.options.maxVisible??12,r=Math.max(0,Math.min(this.selectedIndex-Math.floor(n/2),t.length-n)),i=Math.min(r+n,t.length),a=Math.min(this.options.maxLabelWidth??20,Math.max(this.options.minLabelWidth??10,...t.map(e=>g(e.label)+2))),o=[];for(let n=r;n<i;n++){let r=t[n];if(!r)continue;let i=n===this.selectedIndex,s=i?this.theme.fg(`accent`,`→ `):` `,c=h(r.label,a-2,``),l=c+` `.repeat(Math.max(1,a-g(c))),u=Math.max(0,e-g(s)-a-2),d=h(r.description,u,``),f=i?this.theme.fg(`accent`,l):r.tone?this.theme.fg(r.tone,l):l,p=i?this.theme.fg(`accent`,d):this.theme.fg(r.tone===`dim`?`dim`:`muted`,d);o.push(h(`${s}${f}${p}`,e))}return(r>0||i<t.length)&&o.push(this.theme.fg(`dim`,h(` (${this.selectedIndex+1}/${t.length})`,e))),o}renderFooter(){return` ${[`${this.theme.fg(`dim`,`type`)} ${this.theme.fg(`muted`,`search`)}`,`${this.theme.fg(`dim`,this.keyLabel(`tui.select.up`,`tui.select.down`))} ${this.theme.fg(`muted`,`navigate`)}`,`${this.theme.fg(`dim`,this.keyLabel(`tui.select.confirm`))} ${this.theme.fg(`muted`,`select`)}`,...(this.options.extraHints??[]).map(e=>`${this.theme.fg(`dim`,e.key)} ${this.theme.fg(`muted`,e.label)}`),`${this.theme.fg(`dim`,this.keyLabel(`tui.select.cancel`))} ${this.theme.fg(`muted`,`cancel`)}`].join(` `)}`}keyLabel(...e){return e.flatMap(e=>this.keybindings.getKeys(e)).filter((e,t,n)=>n.indexOf(e)===t).join(`/`)}};function Ae(e,t,n,r){let i=new s;i.addChild(new f(t.fg(`accent`,t.bold(r.title)),1,0)),r.configPath!==void 0&&i.addChild(new f(t.fg(`dim`,r.configPath),1,0));let a=new u(r.items,r.maxVisible??12,r.settingsListTheme,(t,n)=>{r.onChange(t,n),r.items.find(e=>e.id===t)!==void 0&&a.updateValue(t,n),e.requestRender()},()=>n(void 0),{enableSearch:!0});return i.addChild(a),i.addChild(new f(t.fg(`dim`,r.footerHint??`Esc: close | Arrow keys: navigate | Enter/Space: change`),1,0)),{render:e=>i.render(e),invalidate:()=>i.invalidate(),handleInput:t=>{a.handleInput?.(t),e.requestRender()}}}function je(e,t){let n=t[e.currentValue];n!==void 0&&(e.description=n)}const Me=[{value:`usage`,label:`Usage`,description:`Account limits, spend, and per-model usage`},{value:`settings`,label:`Settings`,description:`Reconciliation safety and persisted diagnostics`}];async function Ne(e){return e.custom((e,t,n,r)=>{let i=new ke([...Me],t,n,{title:`Cursor`,subtitle:`managed inference`,maxVisible:Me.length,minLabelWidth:12,maxLabelWidth:16,searchLabel:`action`});return i.onSelect=e=>{(e===`usage`||e===`settings`)&&r(e)},i.onCancel=()=>r(void 0),i})}function Pe(e){return Object.is(e,void 0)}function w(e){return typeof e!=`object`||!e?!1:Object.getPrototypeOf(e)===null||Object.getPrototypeOf(e)===Object.prototype}function Fe(e,t){return t===void 0?!0:t.only===void 0?!(t.except?.includes(e)??!1):t.only.includes(e)}function Ie(e,t){let n={...e};for(let[r,i]of Object.entries(n))t(i,r,e)&&delete n[r];return n}function Le(e,t,n){return Ie(e,(r,i)=>Fe(i,n)&&t(r,i,e))}function T(e,t){return Le(e,Pe,t)}function Re(e){return{ok:!0,value:e}}function E(e){return{ok:!1,error:e}}function D(e){return e instanceof Error?e.message:String(e)}const O={strictReconciliation:!0,diagnostics:!1};let ze={...O};function k(e=a()){return ie(e,`pi-cursor.json`)}function A(){return ze}function Be(e){return ze={...e},ze}function Ve(e){if(!w(e))throw Error(`settings must be a JSON object`);let t=e.strictReconciliation,n=e.diagnostics;if(t!==void 0&&typeof t!=`boolean`)throw Error(`strictReconciliation must be a boolean`);if(n!==void 0&&typeof n!=`boolean`)throw Error(`diagnostics must be a boolean`);return{strictReconciliation:t??O.strictReconciliation,diagnostics:n??O.diagnostics}}function He(e=k()){try{return{settings:Be(Ve(JSON.parse(te(e,`utf8`))))}}catch(t){let n=Be({...O});return t instanceof Error&&Reflect.get(t,`code`)===`ENOENT`?{settings:n}:{settings:n,warning:`Cursor ignored invalid settings at ${e}: ${t instanceof Error?t.message:String(t)}`}}}function Ue(e,t=k()){let n=Be(Ve(e));return ee(re(t),{recursive:!0}),ne(t,`${JSON.stringify(n,null,2)}\n`,{encoding:`utf8`,mode:384}),y(t,384),n}function We(e=A()){return[`strict reconciliation: ${e.strictReconciliation?`on`:`off`} — ${e.strictReconciliation?`fail when streamed and final response copies
|
|
2
|
-
`)}const Ge={strictReconciliation:{on:`Fail before tool execution when streamed and final response copies
|
|
1
|
+
import{arch as e,env as t,platform as n,stderr as r}from"node:process";import{DynamicBorder as i,getAgentDir as a,getSettingsListTheme as o}from"@earendil-works/pi-coding-agent";import{Container as s,Input as c,Loader as l,SettingsList as u,Spacer as d,Text as f,fuzzyFilter as p,matchesKey as m,truncateToWidth as h,visibleWidth as g}from"@earendil-works/pi-tui";import{P as _,match as v}from"ts-pattern";import{chmodSync as y,mkdirSync as ee,readFileSync as te,writeFileSync as ne}from"node:fs";import{dirname as re,join as ie}from"node:path";import{create as b,fromBinary as ae,fromJson as oe,toBinary as se}from"@bufbuild/protobuf";import{request as ce}from"node:https";import{brotliDecompressSync as le,gunzipSync as ue,gzipSync as de}from"node:zlib";import{fileDesc as x,messageDesc as S}from"@bufbuild/protobuf/codegenv2";import{execSync as fe}from"node:child_process";import{createHash as C,randomBytes as pe,randomUUID as me}from"node:crypto";import{mkdir as he,readFile as ge,writeFile as _e}from"node:fs/promises";import{networkInterfaces as ve}from"node:os";import{setTimeout as ye}from"node:timers/promises";import{ValueSchema as be,file_google_protobuf_struct as xe}from"@bufbuild/protobuf/wkt";import{isDeepStrictEqual as Se}from"node:util";import{calculateCost as Ce,createAssistantMessageEventStream as we,createProvider as Te,parseStreamingJson as Ee}from"@earendil-works/pi-ai";import{connect as De}from"node:http2";import{Buffer as Oe}from"node:buffer";var ke=class extends s{searchInput=new c;viewText;detailText;footerText;keybinds=new Map;selectedIndex=0;activeViewId;onSelect;onCancel;items;theme;keybindings;options;constructor(e,t,n,r){super(),this.items=e,this.theme=t,this.keybindings=n,this.options=r,this.activeViewId=r.defaultViewId??r.views?.[0]?.id,this.searchInput.focused=!0,this.viewText=new f(``,1,0),this.detailText=new f(``,1,0),this.footerText=new f(``,1,0),this.addChild(new i(e=>t.fg(`border`,e))),this.addChild(new d(1));let a=r.subtitle!==void 0&&r.subtitle!==``?`${t.fg(`accent`,` ${r.title}`)} ${t.fg(`dim`,r.subtitle)}`:t.fg(`accent`,` ${r.title}`);this.addChild(new f(a,1,0)),this.addChild(this.viewText),this.addChild(new d(1)),this.addChild(new f(this.theme.fg(`dim`,` ${r.searchLabel??`search`}:`),1,0)),this.addChild(this.searchInput),this.addChild(new d(1)),this.addChild({render:e=>this.renderRows(e),invalidate:()=>{}}),this.addChild(new d(1)),this.addChild(this.detailText),this.addChild(new d(1)),this.addChild(this.footerText),this.addChild(new d(1)),this.addChild(new i(e=>t.fg(`border`,e))),this.refresh()}addKeybind(e,t){this.keybinds.set(e,t)}handleInput(e){let t=this.keybinds.get(e);if(t){t();return}let n=this.options.views?.find(t=>t.key===e);if(n){this.activeViewId=n.id,this.selectedIndex=0,this.refresh();return}let r=this.filteredItems();if(this.keybindings.matches(e,`tui.select.up`))this.selectedIndex=r.length===0?0:this.selectedIndex===0?r.length-1:this.selectedIndex-1;else if(this.keybindings.matches(e,`tui.select.down`))this.selectedIndex=r.length===0||this.selectedIndex===r.length-1?0:this.selectedIndex+1;else if(this.keybindings.matches(e,`tui.select.confirm`)){let e=r[this.selectedIndex];e&&this.onSelect?.(e.value);return}else if(this.keybindings.matches(e,`tui.select.cancel`)){this.onCancel?.();return}else{let t=this.searchInput.getValue();this.searchInput.handleInput(e),this.searchInput.getValue()!==t&&(this.selectedIndex=0)}this.refresh()}activeView(){return this.options.views?.find(e=>e.id===this.activeViewId)}filteredItems(){let e=this.activeView(),t=e?this.items.filter(t=>e.predicate(t)):this.items,n=this.searchInput.getValue().trim();return n?p(t,n,e=>`${e.value} ${e.label} ${e.description} ${e.searchText??``}`):t}refresh(){let e=this.filteredItems();this.selectedIndex=Math.max(0,Math.min(this.selectedIndex,Math.max(0,e.length-1))),this.viewText.setText(this.renderViewLine(e.length));let t=e[this.selectedIndex];this.detailText.setText(t&&this.options.detail?this.options.detail(t,this.theme):``),this.footerText.setText(this.renderFooter())}renderViewLine(e){let t=this.options.views??[],n=this.activeView(),r=this.theme.fg(`dim`,`${e}/${this.items.length}`);return t.length===0?` ${r}`:` ${t.map(e=>{let t=e.key!==void 0&&e.key!==``?`${e.key} ${e.label}`:e.label;return e.id===n?.id?this.theme.fg(`accent`,t):this.theme.fg(`muted`,t)}).join(this.theme.fg(`dim`,` · `))} ${r}`}renderRows(e){let t=this.filteredItems();if(this.selectedIndex=Math.max(0,Math.min(this.selectedIndex,Math.max(0,t.length-1))),t.length===0)return[this.theme.fg(`muted`,` No matching commands`)];let n=this.options.maxVisible??12,r=Math.max(0,Math.min(this.selectedIndex-Math.floor(n/2),t.length-n)),i=Math.min(r+n,t.length),a=Math.min(this.options.maxLabelWidth??20,Math.max(this.options.minLabelWidth??10,...t.map(e=>g(e.label)+2))),o=[];for(let n=r;n<i;n++){let r=t[n];if(!r)continue;let i=n===this.selectedIndex,s=i?this.theme.fg(`accent`,`→ `):` `,c=h(r.label,a-2,``),l=c+` `.repeat(Math.max(1,a-g(c))),u=Math.max(0,e-g(s)-a-2),d=h(r.description,u,``),f=i?this.theme.fg(`accent`,l):r.tone?this.theme.fg(r.tone,l):l,p=i?this.theme.fg(`accent`,d):this.theme.fg(r.tone===`dim`?`dim`:`muted`,d);o.push(h(`${s}${f}${p}`,e))}return(r>0||i<t.length)&&o.push(this.theme.fg(`dim`,h(` (${this.selectedIndex+1}/${t.length})`,e))),o}renderFooter(){return` ${[`${this.theme.fg(`dim`,`type`)} ${this.theme.fg(`muted`,`search`)}`,`${this.theme.fg(`dim`,this.keyLabel(`tui.select.up`,`tui.select.down`))} ${this.theme.fg(`muted`,`navigate`)}`,`${this.theme.fg(`dim`,this.keyLabel(`tui.select.confirm`))} ${this.theme.fg(`muted`,`select`)}`,...(this.options.extraHints??[]).map(e=>`${this.theme.fg(`dim`,e.key)} ${this.theme.fg(`muted`,e.label)}`),`${this.theme.fg(`dim`,this.keyLabel(`tui.select.cancel`))} ${this.theme.fg(`muted`,`cancel`)}`].join(` `)}`}keyLabel(...e){return e.flatMap(e=>this.keybindings.getKeys(e)).filter((e,t,n)=>n.indexOf(e)===t).join(`/`)}};function Ae(e,t,n,r){let i=new s;i.addChild(new f(t.fg(`accent`,t.bold(r.title)),1,0)),r.configPath!==void 0&&i.addChild(new f(t.fg(`dim`,r.configPath),1,0));let a=new u(r.items,r.maxVisible??12,r.settingsListTheme,(t,n)=>{r.onChange(t,n),r.items.find(e=>e.id===t)!==void 0&&a.updateValue(t,n),e.requestRender()},()=>n(void 0),{enableSearch:!0});return i.addChild(a),i.addChild(new f(t.fg(`dim`,r.footerHint??`Esc: close | Arrow keys: navigate | Enter/Space: change`),1,0)),{render:e=>i.render(e),invalidate:()=>i.invalidate(),handleInput:t=>{a.handleInput?.(t),e.requestRender()}}}function je(e,t){let n=t[e.currentValue];n!==void 0&&(e.description=n)}const Me=[{value:`usage`,label:`Usage`,description:`Account limits, spend, and per-model usage`},{value:`settings`,label:`Settings`,description:`Reconciliation safety and persisted diagnostics`}];async function Ne(e){return e.custom((e,t,n,r)=>{let i=new ke([...Me],t,n,{title:`Cursor`,subtitle:`managed inference`,maxVisible:Me.length,minLabelWidth:12,maxLabelWidth:16,searchLabel:`action`});return i.onSelect=e=>{(e===`usage`||e===`settings`)&&r(e)},i.onCancel=()=>r(void 0),i})}function Pe(e){return Object.is(e,void 0)}function w(e){return typeof e!=`object`||!e?!1:Object.getPrototypeOf(e)===null||Object.getPrototypeOf(e)===Object.prototype}function Fe(e,t){return t===void 0?!0:t.only===void 0?!(t.except?.includes(e)??!1):t.only.includes(e)}function Ie(e,t){let n={...e};for(let[r,i]of Object.entries(n))t(i,r,e)&&delete n[r];return n}function Le(e,t,n){return Ie(e,(r,i)=>Fe(i,n)&&t(r,i,e))}function T(e,t){return Le(e,Pe,t)}function Re(e){return{ok:!0,value:e}}function E(e){return{ok:!1,error:e}}function D(e){return e instanceof Error?e.message:String(e)}const O={strictReconciliation:!0,diagnostics:!1};let ze={...O};function k(e=a()){return ie(e,`pi-cursor.json`)}function A(){return ze}function Be(e){return ze={...e},ze}function Ve(e){if(!w(e))throw Error(`settings must be a JSON object`);let t=e.strictReconciliation,n=e.diagnostics;if(t!==void 0&&typeof t!=`boolean`)throw Error(`strictReconciliation must be a boolean`);if(n!==void 0&&typeof n!=`boolean`)throw Error(`diagnostics must be a boolean`);return{strictReconciliation:t??O.strictReconciliation,diagnostics:n??O.diagnostics}}function He(e=k()){try{return{settings:Be(Ve(JSON.parse(te(e,`utf8`))))}}catch(t){let n=Be({...O});return t instanceof Error&&Reflect.get(t,`code`)===`ENOENT`?{settings:n}:{settings:n,warning:`Cursor ignored invalid settings at ${e}: ${t instanceof Error?t.message:String(t)}`}}}function Ue(e,t=k()){let n=Be(Ve(e));return ee(re(t),{recursive:!0}),ne(t,`${JSON.stringify(n,null,2)}\n`,{encoding:`utf8`,mode:384}),y(t,384),n}function We(e=A()){return[`strict reconciliation: ${e.strictReconciliation?`on`:`off`} — ${e.strictReconciliation?`fail when streamed and final response copies do not match`:`accept the final response without cross-copy equality checks`}`,`persist diagnostics: ${e.diagnostics?`on`:`off`} — ${e.diagnostics?`store response metadata and reconciliation census data in assistant session messages`:`add no Cursor diagnostics to assistant session messages`}`,`thinking preservation: always on — empty or redacted final reasoning cannot erase streamed thinking`].join(`
|
|
2
|
+
`)}const Ge={strictReconciliation:{on:`Fail before tool execution when streamed and final response copies do not match.`,off:`Accept final content without streamed/final equality checks; stream validity still applies.`},diagnostics:{on:`Persist response metadata and census data; about 0.6 kB baseline per turn, more with side channels.`,off:`Add no Cursor diagnostic data to assistant session messages.`}};function Ke(){let e=A();return[{id:`strictReconciliation`,label:`Strict reconciliation`,description:Ge.strictReconciliation[e.strictReconciliation?`on`:`off`],currentValue:e.strictReconciliation?`on`:`off`,values:[`on`,`off`]},{id:`diagnostics`,label:`Persist diagnostics`,description:Ge.diagnostics[e.diagnostics?`on`:`off`],currentValue:e.diagnostics?`on`:`off`,values:[`on`,`off`]}]}async function qe(e,t){if(e.mode!==`tui`){t(`${We()}\nconfig: ${k()}`,`info`);return}let n=Ke();await e.ui.custom((t,r,i,a)=>Ae(t,r,a,{title:`Cursor Settings`,configPath:k(),items:n,settingsListTheme:o(),onChange:(t,r)=>{let i=n.find(e=>e.id===t);if(!(i===void 0||t!==`strictReconciliation`&&t!==`diagnostics`)){i.currentValue=r,je(i,Ge[t]);try{Ue({...A(),[t]:r===`on`})}catch(t){e.ui.notify(`Failed to save Cursor settings: ${t instanceof Error?t.message:String(t)}`,`error`)}}}}))}function Je(e,t){let n={"accept-encoding":`gzip,br`,authorization:`Bearer ${e.token}`,"connect-protocol-version":`1`,"connect-timeout-ms":`10000`,"content-type":`application/proto`,"user-agent":`connect-es/1.6.1`,"x-cursor-client-type":`cli`,"x-cursor-client-version":`extension-unknown`,"x-ghost-mode":`false`,"x-request-id":crypto.randomUUID()};return t.length===0&&(n[`content-length`]=`0`),n}function Ye(e,t){return t===`gzip`?new Uint8Array(ue(e)):t===`br`?new Uint8Array(le(e)):e}function Xe(e,t,n){return new Promise((r,i)=>{if(t.signal?.aborted===!0){i(new DOMException(`Aborted`,`AbortError`));return}let a=(t.request??ce)({protocol:`https:`,host:e.hostname,port:e.port===``?443:e.port,path:e.pathname,method:`POST`,headers:Je(t,n)},e=>{let t=[],n=0;e.on(`data`,e=>{if(n+=e.length,n>4194304){a.destroy(),i(Error(`response exceeded 4194304 bytes`));return}t.push(e)}),e.on(`end`,()=>{try{r({status:e.statusCode??0,body:Ye(Buffer.concat(t),e.headers[`content-encoding`])})}catch(e){i(Error(D(e)))}}),e.on(`error`,i)});a.on(`error`,i),a.setTimeout(1e4,()=>{a.destroy(Error(`no response within 10000ms`))});let o=t.signal;if(o!==void 0){let e=()=>{a.destroy(),i(new DOMException(`Aborted`,`AbortError`))};o.addEventListener(`abort`,e,{once:!0}),a.on(`close`,()=>o.removeEventListener(`abort`,e))}n.length===0||a.write(n),a.end()})}function Ze(e){try{let t=JSON.parse(new TextDecoder().decode(e));if(typeof t==`object`&&t&&`message`in t){let{message:e}=t;if(typeof e==`string`&&e!==``)return e}}catch{return}}function Qe(e){return e===401||e===403?`auth`:e>=500?`transient`:`permanent`}async function j(e,t,n,r){if(r.token.includes(`\r`)||r.token.includes(`
|
|
3
3
|
`))return E({kind:`invalid`,method:e,message:`Cursor credential contains a line break`});let i=new URL(`https://api2.cursor.sh/aiserver.v1.DashboardService/${e}`),a=se(t.schema,t.message),o;try{o=await Xe(i,r,a)}catch(t){return t instanceof DOMException&&t.name===`AbortError`?E({kind:`transient`,method:e,message:`cancelled`}):E({kind:`transient`,method:e,message:D(t)})}if(o.status!==200){let t=Ze(o.body);return E({kind:Qe(o.status),method:e,message:`${String(o.status)}${t===void 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5mbxgBIAEoCzIpLmFpc2VydmVyLnYxLkdldFBsYW5JbmZvUmVzcG9uc2UuUGxhbkluZm9IAIgBARJHCgxuZXh0X3VwZ3JhZGUYAiABKAsyLC5haXNlcnZlci52MS5HZXRQbGFuSW5mb1Jlc3BvbnNlLk5leHRVcGdyYWRlSAGIAQEabAoLTmV4dFVwZ3JhZGUSDAoEdGllchgBIAEoCRIMCgRuYW1lGAIgASgJEh0KFWluY2x1ZGVkX2Ftb3VudF9jZW50cxgDIAEoBRINCgVwcmljZRgEIAEoCRITCgtkZXNjcmlwdGlvbhgFIAEoCRqvAgoIUGxhbkluZm8SEQoJcGxhbl9uYW1lGAEgASgJEh0KFWluY2x1ZGVkX2Ftb3VudF9jZW50cxgCIAEoBRISCgVwcmljZRgDIAEoCUgAiAEBEh4KEWJpbGxpbmdfY3ljbGVfZW5kGAQgASgDSAGIAQESRwoKcGxhbl9vd25lchgFIAEoDjIzLmFpc2VydmVyLnYxLkdldFBsYW5JbmZvUmVzcG9uc2UuUGxhbkluZm8uUGxhbk93bmVyIlQKCVBsYW5Pd25lchIaChZQTEFOX09XTkVSX1VOU1BFQ0lGSUVEEAASFQoRUExBTl9PV05FUl9TVFJJUEUQARIUChBQTEFOX09XTkVSX0FQUExFEAJCCAoGX3ByaWNlQhQKEl9iaWxsaW5nX2N5Y2xlX2VuZEIMCgpfcGxhbl9pbmZvQg8KDV9uZXh0X3VwZ3JhZGViBnByb3RvMw`),$e=S(M,0),et=S(M,1),tt=S(M,2),nt=S(M,3),rt=S(M,4),it=S(M,5),at=S(M,6),ot=S(M,7),st=S(M,8),ct=S(M,9),lt=S(M,10),ut=S(M,11);function dt(e){return E({kind:`permanent`,method:`GetCurrentPeriodUsage`,message:e})}function ft(e){let t=Number(e??0n);return t<=0?`Current period`:`Resets ${new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,timeZone:`UTC`}).format(new Date(t))}`}function pt(e){let t=Math.max(0,Math.min(100,e));return`${t>0&&t<1?1:Math.round(t)}%`}function mt(e){let t=Math.abs(e)/100,n=e<0?`-`:``;return t>0&&t<.01?`${n}<$0.01`:`${n}$${t.toFixed(2)}`}function N(e){return mt(e*100)}function ht(e,t,n){return e===void 0?n!==void 0&&n>0?(t??0)/n*100:0:e}function gt(e,t){let n=(e?.individualUsed??0)/100,r=e?.individualLimit,i=r===void 0?void 0:r>0?{kind:`fixed`,usedDollars:n,limitDollars:r/100}:{kind:`disabled`,usedDollars:n};return e?.limitType===`team`?i===void 0?t===void 0?(e.pooledLimit??0)>0?{kind:`unlimited`,usedDollars:n,scope:`team-member`}:{kind:`unavailable`,usedDollars:n}:t.noUsageBasedAllowed||t.hardLimit<=0?{kind:`disabled`,usedDollars:n}:{kind:`unlimited`,usedDollars:n,scope:`team-member`}:i:t===void 0?i??{kind:`unavailable`,usedDollars:n}:t.noUsageBasedAllowed?{kind:`disabled`,usedDollars:n}:t.hardLimit>=2147483647?{kind:`unlimited`,usedDollars:n,scope:`personal`}:t.hardLimit>0?{kind:`fixed`,usedDollars:n,limitDollars:t.hardLimit}:{kind:`disabled`,usedDollars:n}}function _t(e,t,n){let r=BigInt(Math.floor(n)),i=BigInt(Math.min(Number(t),Math.max(Number(e),Number(r))))-e;if(i<=0n)return[];let a=e-(t-e),o=[];for(let t=1;t<=5;t++){let n=i*BigInt(t)/BigInt(5);o.push({cycle:`current`,point:t,startDate:e,endDate:e+n},{cycle:`previous`,point:t,startDate:a,endDate:a+n})}return o}async function vt(e,t,n){let r=[],i=0,a=Array.from({length:Math.min(t,e.length)},async()=>{for(;;){let t=i;i+=1;let a=e[t];if(a===void 0)return;r[t]=await n(a)}});return await Promise.all(a),r}async function yt(e){let t={token:e.token,...e.signal===void 0?{}:{signal:e.signal},...e.request===void 0?{}:{request:e.request}},n=[],r=e=>{if(e.ok)return e.value;n.push(e.error)},[i,a,o]=await Promise.all([j(`GetCurrentPeriodUsage`,{schema:tt,message:b(tt)},nt,t),j(`GetHardLimit`,{schema:rt,message:b(rt)},it,t),j(`GetPlanInfo`,{schema:lt,message:b(lt)},ut,t)]);if(!i.ok)return E(i.error);let s=r(a),c=r(o)?.planInfo,l=e=>Re({model:e,misses:n}),u=i.value.planUsage;if(u!==void 0){let e=i.value.billingCycleEnd>0n?i.value.billingCycleEnd:c?.billingCycleEnd;return l({kind:`standard`,planName:c?.planName??`Current plan`,resetLabel:ft(e),includedTotalPercent:ht(u.totalPercentUsed,u.includedSpend,u.limit),includedAutoPercent:u.autoPercentUsed??0,includedApiPercent:u.apiPercentUsed??0,onDemand:gt(i.value.spendLimitUsage,s)})}let d=await j(`GetMe`,{schema:at,message:b(at)},ot,t);if(!d.ok)return E(d.error);if(d.value.isEnterpriseUser!==!0)return dt(`Usage details are not available for this plan.`);let{teamId:f,userId:p}=d.value;if(f===void 0||f===0||p===0)return dt(`Enterprise spend details are not available for this account.`);let m=await j(`GetMonthlyBillingCycle`,{schema:st,message:b(st)},ct,t);if(!m.ok)return E(m.error);let h=_t(m.value.startDateEpochMillis,m.value.endDateEpochMillis,e.nowMillis??Date.now()),g=Array.from({length:6}),_=Array.from({length:6});g[0]=0,_[0]=0;let y=[],ee=await vt(h,4,e=>j(`GetAggregatedUsageEvents`,{schema:$e,message:b($e,{teamId:f,userId:p,startDate:e.startDate,endDate:e.endDate})},et,t));for(let[e,t]of ee.entries()){let n=h[e];if(n===void 0)continue;let i=r(t);if(i===void 0)continue;let a=Math.max(0,i.totalCostCents)/100;v(n.cycle).with(`current`,()=>{g[n.point]=a,y=i.aggregations}).with(`previous`,()=>{_[n.point]=a}).exhaustive()}return l({kind:`spend`,planName:c?.planName??`Enterprise`,resetLabel:ft(m.value.endDateEpochMillis),currentCycle:g,previousPeriod:_,models:y})}const P=[`▁`,`▂`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`];function F(e,t=28){let n=Math.min(100,Math.max(0,e)),r=Math.round(n/100*t),i=Math.min(t,n>0?Math.max(1,r):0);return`${`█`.repeat(i)}${`░`.repeat(t-i)}`}function bt(e){let t=[],n=0;for(let r of e)n=r??n,t.push(n);return t}function xt(e){return e.findLast(e=>e!==void 0)}function St(e,t,n=28){if(e.length===0)return P[0].repeat(n);let r=bt(e),i=P.length-1;return Array.from({length:n},(e,a)=>{let o=a/Math.max(n-1,1)*(r.length-1),s=Math.floor(o),c=Math.min(s+1,r.length-1),l=(r[s]??0)+((r[c]??0)-(r[s]??0))*(o-s),u=t>0?Math.max(0,Math.min(1,l/t)):0;return P[Math.round(u*i)]??P[0]}).join(``)}function Ct(e){return v(e).with({kind:`fixed`},e=>({title:`On-Demand`,bar:F(e.limitDollars>0?e.usedDollars/e.limitDollars*100:0),details:[`${N(e.usedDollars)} / ${N(e.limitDollars)}`,`${N(Math.max(e.limitDollars-e.usedDollars,0))} remaining`]})).with({kind:`unlimited`},e=>({title:`On-Demand`,bar:`·`.repeat(28),details:[N(e.usedDollars),e.scope===`team-member`?`no personal limit`:`no monthly limit`]})).with({kind:`disabled`},e=>({title:`On-Demand`,bar:`·`.repeat(28),details:[e.usedDollars>0?N(e.usedDollars):`disabled`,`on-demand usage is off`]})).with({kind:`unavailable`},e=>({title:`On-Demand`,bar:`·`.repeat(28),details:[e.usedDollars>0?N(e.usedDollars):`unavailable`,`on-demand limit unavailable`]})).exhaustive()}function wt(e){return[{title:`Included`,bar:F(e.includedTotalPercent),details:[`${pt(e.includedTotalPercent)} used`]},{title:` Auto`,bar:F(e.includedAutoPercent),details:[`${pt(e.includedAutoPercent)} used`]},{title:` API`,bar:F(e.includedApiPercent),details:[`${pt(e.includedApiPercent)} used`]},Ct(e.onDemand)]}function Tt(e){return Math.max(0,xt(e.currentCycle)??0,xt(e.previousPeriod)??0)}function Et(e){let t=e.slice(1),n=xt(t);if(n===void 0)return[`no sample answered`];let r=t.filter(e=>e===void 0).length;if(r===0)return[N(n)];let i=`${r} of ${t.length} samples missing`,a=t.at(-1)!==void 0;return[N(n),a?i:`at least — ${i}`]}function Dt(e){let t=Tt(e);return[{title:`Current cycle`,bar:St(e.currentCycle,t),details:Et(e.currentCycle)},{title:`Previous period`,bar:St(e.previousPeriod,t),details:Et(e.previousPeriod)}]}function Ot(e){let t=e.models.toSorted((e,t)=>t.totalCents-e.totalCents),n=Math.max(0,...t.map(e=>e.totalCents));return t.map(e=>({title:e.modelIntent,bar:F(n>0?e.totalCents/n*100:0),details:[mt(e.totalCents),`in ${I(e.inputTokens)}`,`out ${I(e.outputTokens)}`,`cache ${I(e.cacheReadTokens)}r/${I(e.cacheWriteTokens)}w`]}))}function I(e){let t=Number(e);return t>=1e9?`${(t/1e9).toFixed(2)}B`:t>=1e6?`${(t/1e6).toFixed(2)}M`:t>=1e3?`${(t/1e3).toFixed(2)}K`:String(e)}function L(e){return v(e.model).with({kind:`standard`},e=>[{id:`summary`,title:`Summary`,meters:wt(e)}]).with({kind:`spend`},e=>[{id:`summary`,title:`Summary`,meters:Dt(e)},...e.models.length>0?[{id:`models`,title:`Models`,meters:Ot(e)}]:[]]).exhaustive()}function kt(e){return`${e.model.planName} · ${e.model.resetLabel}`}function At(e,t=`summary`){let n=L(e),r=n.find(e=>e.id===t)??n[0],i=[kt(e)],a=r.meters.reduce((e,t)=>Math.max(e,t.title.length),0);for(let e of r.meters){let t=e.details.length===0?`no data`:e.details.join(` · `);i.push(` ● ${e.title.padEnd(a)} ${e.bar} ${t}`)}r.meters.length===0&&i.push(` no usage recorded in this period`);for(let t of e.misses)i.push(` ${t.method} failed: ${t.message}`);return i}function jt(e,t){if(t?.matches(e,`tui.select.cancel`)===!0||m(e,`escape`))return`close`;if(t?.matches(e,`tui.input.tab`)===!0||m(e,`tab`))return`next-tab`;if(e===`q`)return`close`;if(e===`r`)return`refetch`}function Mt(e){let t=e>1?[`tab switch view`]:[];return t.push(`r refresh`,`q/Esc close`),t.join(` `)}function Nt(e,t){return e.map(e=>({title:e.title,active:e.id===t}))}function Pt(e,t,n,r){let i=new Set(t.misses.map(e=>` ${e.method} failed: ${e.message}`)),a=kt(t),o=[``];for(let s of At(t,n)){let t=i.has(s)?e.fg(`error`,s):s===a?e.fg(`accent`,e.bold(s)):e.fg(`text`,s);o.push(h(` ${t}`,r))}return o}function Ft(e,t){let n=new AbortController,r;return{refresh:async()=>{if(n.signal.aborted)return;r?.abort(),r=new AbortController;let i=AbortSignal.any([n.signal,r.signal]);t({type:`loading`});let a=await e(i);i.aborted||t(v(a).with({ok:!0},e=>({type:`loaded`,usage:e.value})).with({ok:!1},e=>({type:`error`,message:`${e.error.method} failed: ${e.error.message}`})).exhaustive())},close:()=>{n.abort(),r?.abort()}}}var It=class{state={type:`loading`};loader=null;activeTabId=`summary`;theme;tui;keybindings;onClose;onRefetch;constructor(e,t,n,r,i){this.theme=e,this.tui=t,this.keybindings=n,this.onClose=r,this.onRefetch=i,this.startLoader()}setState(e){this.stopLoader(),this.state=e,v(e).with({type:`loading`},()=>{this.startLoader()}).with({type:`error`},()=>{}).with({type:`loaded`},e=>{let t=L(e.usage);t.some(e=>e.id===this.activeTabId)||(this.activeTabId=t[0].id)}).exhaustive()}handleInput(e){v(jt(e,this.keybindings)).with(`close`,()=>{this.onClose()}).with(`refetch`,()=>{this.onRefetch()}).with(`next-tab`,()=>{this.cycleTab()}).with(void 0,()=>{}).exhaustive()}render(e){let t=Math.max(20,e),n=new i(e=>this.theme.fg(`border`,e)),r=[...n.render(t)];r.push(h(` ${this.theme.fg(`accent`,this.theme.bold(`Cursor usage`))}`,t));let a=v(this.state).with({type:`loading`},()=>({tabCount:1,lines:this.loader?.render(t)??[this.theme.fg(`muted`,` Fetching usage…`)]})).with({type:`error`},e=>({tabCount:1,lines:[``,h(` ${this.theme.fg(`error`,e.message)}`,t)]})).with({type:`loaded`},e=>{let n=L(e.usage);return{tabCount:n.length,lines:[...n.length>1?[``,this.renderTabStrip(n,t)]:[],...Pt(this.theme,e.usage,this.activeTabId,t)]}}).exhaustive();return r.push(...a.lines,``),r.push(h(` ${this.theme.fg(`dim`,Mt(a.tabCount))}`,t)),r.push(...n.render(t)),r}invalidate(){}destroy(){this.stopLoader()}cycleTab(){if(this.state.type!==`loaded`)return;let e=L(this.state.usage);if(e.length<2)return;let t=e.findIndex(e=>e.id===this.activeTabId);this.activeTabId=e[(t+1)%e.length]?.id??e[0].id,this.tui.requestRender()}renderTabStrip(e,t){let n=Nt(e,this.activeTabId).map(e=>e.active?this.theme.fg(`accent`,this.theme.bold(e.title)):this.theme.fg(`dim`,e.title)).join(this.theme.fg(`dim`,` · `));return h(` ${n}`,t)}startLoader(){this.loader=new l(this.tui,e=>this.theme.fg(`accent`,e),e=>this.theme.fg(`muted`,e),`Fetching usage…`)}stopLoader(){this.loader?.stop(),this.loader=null}};const Lt=`Usage: /cursor [usage|settings|help]. No args opens the action menu.`,Rt=[{value:`usage`,label:`usage`,description:`open the Cursor usage pane`},{value:`settings`,label:`settings`,description:`configure reconciliation and diagnostics`},{value:`help`,label:`help`,description:`show command usage`}];function zt(e){let t=e.trimStart();if(/\s/u.test(t))return null;let n=Rt.filter(e=>e.value.startsWith(t));return n.length===0?null:n}function R(e,t,n){if(e.mode===`print`){e.writeOutput(`${t}\n`);return}if(e.mode===`json`){e.sendMessage({customType:`cursor-command-output`,content:t,display:!0,details:{level:n}});return}e.ui.notify(t,n)}async function Bt(e){try{let t=(await e.modelRegistry.getProviderAuth(`cursor`))?.auth.apiKey;if(t!==void 0&&t!==``)return t}catch(t){R(e,`Cursor authentication failed: ${t instanceof Error?t.message:String(t)}`,`error`);return}R(e,`Cursor is not signed in. Run /login cursor first.`,`warning`)}async function Vt(e,t){let n=await Bt(e);if(n===void 0)return;let r=t.loadUsage??yt;if(e.mode!==`tui`){let t=await r({token:n});if(!t.ok){R(e,`${t.error.method} failed: ${t.error.message}`,`error`);return}R(e,At(t.value).join(`
|
|
4
4
|
`),`info`);return}await e.ui.custom((e,t,i,a)=>{let o,s=new It(t,e,i,()=>{o.close(),a(null)},()=>{o.refresh()});return o=Ft(e=>r({token:n,signal:e}),t=>{s.setState(t),e.requestRender()}),o.refresh(),{render:e=>s.render(e),invalidate:()=>s.invalidate(),handleInput:e=>s.handleInput(e),dispose:()=>{o.close(),s.destroy()}}})}async function Ht(e,t,n={}){let r=t.trim().toLowerCase();if(r===``){if(e.mode!==`tui`){R(e,Lt,`info`);return}let t=await(n.openMenu??Ne)(e.ui);t!==void 0&&await Ht(e,t,n);return}if(r===`usage`){await Vt(e,n);return}if(r===`settings`){await(n.openSettings??qe)(e,(t,n)=>R(e,t,n));return}if(r===`help`){R(e,Lt,`info`);return}R(e,`Unknown /cursor subcommand: ${r}.\n${Lt}`,`error`)}function Ut(e){e.registerCommand(`cursor`,{description:`Open Cursor usage or configure reconciliation and diagnostics`,getArgumentCompletions:zt,handler:async(t,n)=>{await Ht({...n,sendMessage:e.sendMessage,writeOutput:e=>r.write(e)},t)}})}const Wt=new Set([`00:00:00:00:00:00`,`ff:ff:ff:ff:ff:ff`,`ac:de:48:00:11:22`]),Gt=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,Kt={platform:n,arch:e,env:t,execute:e=>fe(e,{timeout:5e3}).toString(),interfaces:ve,createUuid:me};function qt(e,t,n){switch(e){case`darwin`:return`ioreg -rd1 -c IOPlatformExpertDevice`;case`win32`:return`${t===`ia32`&&Object.hasOwn(n,`PROCESSOR_ARCHITEW6432`)?`%windir%\\sysnative\\cmd.exe /c %windir%\\System32`:`%windir%\\System32`}\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid`;case`linux`:return`( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :`;case`freebsd`:return`kenv -q smbios.system.uuid || sysctl -n kern.hostuuid`;default:throw Error(`Unsupported platform: ${e}`)}}function Jt(e,t){switch(e){case`darwin`:{let e=t.split(`IOPlatformUUID`)[1]?.split(`
|
|
5
5
|
`)[0];if(e===void 0)throw Error(`IOPlatformUUID is missing`);return e.replace(/=|\s+|"/giu,``).toLowerCase()}case`win32`:{let e=t.split(`REG_SZ`)[1];if(e===void 0)throw Error(`MachineGuid is missing`);return e.replace(/\r+|\n+|\s+/giu,``).toLowerCase()}case`linux`:case`freebsd`:return t.replace(/\r+|\n+|\s+/giu,``).toLowerCase();default:throw Error(`Unsupported platform: ${e}`)}}function Yt(e=Kt){let t=qt(e.platform,e.arch,e.env),n=Jt(e.platform,e.execute(t));return C(`sha256`).update(n,`utf8`).digest(`hex`)}function Xt(e){for(let t in e){let n=e[t];if(n!==void 0)for(let e of n){let t=e.mac.replace(/-/gu,`:`).toLowerCase();if(!Wt.has(t))return e.mac}}throw Error(`Unable to retrieve mac address (unexpected format)`)}function Zt(e=Kt){try{return C(`sha256`).update(Xt(e.interfaces()),`utf8`).digest(`hex`)}catch{return}}function Qt(e){return ie(e,`pi-cursor`,`identity.json`)}function $t(e){let t=JSON.parse(e);if(!w(t)||typeof t.machineId!=`string`||!Gt.test(t.machineId))throw Error(`Persisted Cursor fallback identity is invalid`);return t.machineId}function en(e,t){return typeof e==`object`&&!!e&&`code`in e&&e.code===t}async function tn(e,t){let n=Qt(e);try{return $t(await ge(n,`utf8`))}catch(e){if(!en(e,`ENOENT`))throw e}let r=t();if(!Gt.test(r))throw Error(`Generated Cursor fallback identity is invalid`);await he(ie(e,`pi-cursor`),{recursive:!0});try{return await _e(n,`${JSON.stringify({machineId:r})}\n`,{encoding:`utf8`,flag:`wx`,mode:384}),r}catch(e){if(!en(e,`EEXIST`))throw e;return $t(await ge(n,`utf8`))}}async function nn(e,t=Kt){let n,r;try{n=Yt(t),r=`host`}catch{n=await tn(e,t.createUuid),r=`fallback`}let i=Zt(t);return i===void 0?{machineId:n,machineIdSource:r}:{machineId:n,macMachineId:i,machineIdSource:r}}const rn=`x-cursor-client-type`,an={fetch,sleep:async(e,t)=>{await ye(e,void 0,{signal:t})},randomBytes:pe,randomUuid:me};function on(e){return Buffer.from(e).toString(`base64url`)}function sn(e=an){let t=e.randomBytes(32);if(t.byteLength!==32)throw Error(`Cursor login verifier must be 32 bytes`);let n=on(t),r=on(C(`sha256`).update(n,`utf8`).digest()),i=e.randomUuid();return{verifier:n,challenge:r,uuid:i,url:`https://cursor.com/loginDeepControl?${new URLSearchParams({challenge:r,uuid:i,mode:`login`,supportsSelectedTeamLogin:`true`,redirectTarget:`cli`}).toString()}`}}function cn(e){if(!w(e)||typeof e.accessToken!=`string`||e.accessToken===``||typeof e.refreshToken!=`string`||e.refreshToken===``)throw Error(`Cursor authentication response is missing tokens`);return{accessToken:e.accessToken,refreshToken:e.refreshToken}}function ln(e){if(!w(e)||typeof e.access_token!=`string`||e.access_token===``)throw Error(`Cursor refresh response is missing an access token`);return e.access_token}function un(e){let t=e.split(`.`)[1];if(t===void 0||t===``)throw Error(`Cursor access token is not a JWT`);let n;try{n=JSON.parse(Buffer.from(t,`base64url`).toString(`utf8`))}catch(e){throw Error(`Cursor access token has an invalid JWT payload`,{cause:e})}if(!w(n)||typeof n.exp!=`number`||!Number.isSafeInteger(n.exp))throw Error(`Cursor access token has no valid expiry`);return n.exp*1e3-3e5}function dn(){return{traceparent:`00-${pe(16).toString(`hex`)}-${pe(8).toString(`hex`)}-00`,"x-ghost-mode":`implicit-false`,"x-new-onboarding-completed":`false`,[rn]:`ide`}}var fn=class extends Error{constructor(e){super(`Cursor login denied by sign-in policy: ${e}`),this.name=`CursorSignInPolicyError`}};async function pn(e,t,n=an){let r=Date.now()+18e4;for(;!t.aborted&&Date.now()<r&&(await n.sleep(500,t),!t.aborted);)try{let r=new URL(`https://api2.cursor.sh/auth/poll`);r.search=new URLSearchParams(e).toString();let i=await n.fetch(r,{headers:dn(),signal:t});if(i.status===404)continue;if(i.status===403){let e=await i.json().catch(()=>void 0);if(w(e)&&typeof e.error==`string`)throw new fn(e.error)}if(!i.ok)throw Error(`Cursor login poll returned HTTP ${String(i.status)}`);let a=cn(await i.json());return{type:`oauth`,access:a.accessToken,refresh:a.refreshToken,expires:un(a.accessToken)}}catch(e){if(t.aborted||e instanceof fn)throw e}throw Error(`Cursor login polling timed out`)}async function mn(e,t,n=fetch){let r=new AbortController,i=setTimeout(()=>r.abort(),2e4),a=()=>r.abort();t.addEventListener(`abort`,a,{once:!0});try{let t=await n(`https://api2.cursor.sh/oauth/token`,{method:`POST`,headers:{"content-type":`application/json`,[rn]:`ide`},body:JSON.stringify({grant_type:`refresh_token`,client_id:`KbZUR41cY7W6zRSdpSUJ7I7mLYBKOCmB`,refresh_token:e.refresh}),signal:r.signal});if(!t.ok)throw Error(`Cursor token refresh returned HTTP ${String(t.status)}`);let i=await t.json();if(w(i)&&i.shouldLogout===!0)throw Error(`Cursor revoked this session; sign in again with /login cursor`);let a=ln(i);return{type:`oauth`,access:a,refresh:e.refresh,expires:un(a)}}finally{clearTimeout(i),t.removeEventListener(`abort`,a)}}function hn(e=an){return{name:`Cursor`,isSubscription:!0,loginLabel:`Sign in with Cursor`,login:async t=>{let n=sn(e);return t.notify({type:`auth_url`,url:n.url,instructions:`Complete Cursor sign-in in your browser.`}),t.notify({type:`progress`,message:`Waiting for Cursor sign-in…`}),await pn(n,t.signal,e)},refresh:async(t,n)=>await mn(t,n,e.fetch),toAuth:async e=>({apiKey:e.access})}}const z=x(`ChZhZ2VudC92MS9jYXRhbG9nLnByb3RvEghhZ2VudC52MSIRCg9UaGlua2luZ0RldGFpbHMiQgoOUmVxdWVzdGVkTW9kZWwaMAoTTW9kZWxQYXJhbWV0ZXJWYWx1ZRIKCgJpZBgBIAEoCRINCgV2YWx1ZRgCIAEoCSLwAQoMTW9kZWxEZXRhaWxzEhAKCG1vZGVsX2lkGAEgASgJEjgKEHRoaW5raW5nX2RldGFpbHMYAiABKAsyGS5hZ2VudC52MS5UaGlua2luZ0RldGFpbHNIAIgBARIYChBkaXNwbGF5X21vZGVsX2lkGAMgASgJEhQKDGRpc3BsYXlfbmFtZRgEIAEoCRIaChJkaXNwbGF5X25hbWVfc2hvcnQYBSABKAkSDwoHYWxpYXNlcxgGIAMoCRIVCghtYXhfbW9kZRg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z]),xn=S(bn,0),Sn=S(bn,1),Cn=/^(.*)-(none|minimal|low|medium|high|xhigh|extra-high|max)(-fast)?$/u,wn={none:`off`,minimal:`minimal`,low:`low`,medium:`medium`,high:`high`,xhigh:`xhigh`,"extra-high":`xhigh`,max:`max`},Tn=[`medium`,`high`,`low`,`minimal`,`xhigh`,`max`,`off`];let B;function En(e){let t;try{t=new URL(e)}catch(e){throw Error(`Cursor backend authority is invalid`,{cause:e})}if(t.protocol!==`https:`||t.username!==``||t.password!==``||t.pathname!==``&&t.pathname!==`/`||t.search!==``||t.hash!==``)throw Error(`Cursor backend authority must be an HTTPS origin`);return new URL(t.origin)}function Dn(e,t){return t===`gzip`?new Uint8Array(ue(e)):t===`br`?new Uint8Array(le(e)):e}function On(e,t,n,r){let i=En(r.backendUrl),a=se(t.schema,t.message);return new Promise((t,o)=>{if(r.signal?.aborted===!0){o(new DOMException(`Aborted`,`AbortError`));return}let s=(r.request??ce)({protocol:`https:`,host:i.hostname,port:i.port===``?443:i.port,path:`/aiserver.v1.AiService/${e}`,method:`POST`,headers:{"accept-encoding":`gzip,br`,authorization:`Bearer ${r.token}`,"connect-protocol-version":`1`,"content-type":`application/proto`,"user-agent":`connect-es/1.6.1`,"x-cursor-client-type":`cli`,"x-cursor-client-version":`cli-2026.09.02-fa0c06e-lab`,"x-ghost-mode":`false`,"x-request-id":crypto.randomUUID(),...a.length===0?{"content-length":`0`}:{}}},r=>{let i=[],a=0;r.on(`data`,e=>{if(a+=e.length,a>4194304){s.destroy(Error(`Cursor catalog response exceeded its size limit`));return}i.push(e)}),r.on(`end`,()=>{if(r.statusCode!==200){o(Error(`Cursor ${e} returned HTTP ${String(r.statusCode??0)}`));return}try{let e=Dn(Buffer.concat(i),r.headers[`content-encoding`]);t(ae(n,e))}catch(t){o(Error(`Cursor ${e} returned invalid protobuf: ${D(t)}`))}}),r.on(`error`,o)});s.on(`error`,o),s.setTimeout(1e4,()=>s.destroy(Error(`Cursor ${e} timed out`)));let c=r.signal;if(c!==void 0){let e=()=>{s.destroy(new DOMException(`Aborted`,`AbortError`))};c.addEventListener(`abort`,e,{once:!0}),s.on(`close`,()=>c.removeEventListener(`abort`,e))}a.length===0||s.write(a),s.end()})}function kn(e){let t=Cn.exec(e.modelId),n=t?.[1],r=t?.[2],i=t?.[3]===`-fast`,a=r===void 0?void 0:wn[r];return n===void 0||a===void 0?{id:e.modelId,level:`off`}:{id:`${n}${i?`-fast`:``}`,level:a}}function An(e){let t=new Map;for(let n of e){if(n.modelId===``)continue;let e=kn(n),r=t.get(e.id)??[];r.push({model:n,level:e.level}),t.set(e.id,r)}return[...t].map(([e,t])=>({id:e,members:t}))}function jn(e){return e.displayName||e.displayNameShort||e.displayModelId||e.modelId}function Mn(e,t){let n=new Set(e.members.map(({model:e})=>e.modelId));return t.find(t=>t.name===e.id||t.idAliases.includes(e.id)||t.legacySlugs.some(e=>n.has(e))||t.variants.some(e=>e.legacySlug!==void 0&&n.has(e.legacySlug)))}function Nn(e){return e===void 0?``:[e.primaryText,e.secondaryText,e.tertiaryText,e.markdownContent??``].join(`
|
|
6
|
-
`)}function Pn(e){if(e.supportsMaxMode!==!0)return!1;if(e.contextTokenLimitForMaxMode!==void 0&&e.contextTokenLimitForMaxMode!==e.contextTokenLimit||Nn(e.tooltipDataForMaxMode)!==Nn(e.tooltipData)||e.variants.some(e=>e.isMaxMode))return!0;let t=e.variants.find(e=>e.isDefaultNonMaxConfig===!0),n=e.variants.find(e=>e.isDefaultMaxConfig===!0);return t!==void 0&&n!==void 0&&t!==n}function Fn(e,t){return e.variants.find(e=>t?e.isDefaultMaxConfig===!0:e.isDefaultNonMaxConfig===!0)?.parameterValues.find(e=>e.id===`context`)?.value}function In(e,t){let n=t?e
|
|
7
|
-
`))throw Error(`Cursor credential contains a line break`);let t=(e.now??Date.now)(),n=En(e.backendUrl).origin,r=`${n}:${await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e.token)).then(e=>Buffer.from(e).toString(`hex`))}`;if(e.force!==!0&&B?.key===r&&B.expiresAt>t)return B.models;let[i,a,o]=await Promise.all([On(`AvailableModels`,{schema:xn,message:b(xn,{useModelParameters:!0,doNotUseMarkdown:!0})},Sn,e),On(`GetUsableModels`,{schema:vn,message:b(vn)},yn,e),On(`GetDefaultModelForCli`,{schema:gn,message:b(gn)},_n,e)]),s=Rn(i,a,o,n);return B={key:r,expiresAt:t+6e5,models:s},s}const V=x(`ChthaXNlcnZlci92MS9pbmZlcmVuY2UucHJvdG8SC2Fpc2VydmVyLnYxIsQBChJJbmZlcmVuY2VBZ2VudFRvb2wSDAoEbmFtZRgBIAEoCRITCgtkZXNjcmlwdGlvbhgCIAEoCRIrCgpwYXJhbWV0ZXJzGAMgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdBJHChJjdXN0b21fdG9vbF9mb3JtYXQYBCABKAsyJi5haXNlcnZlci52MS5JbmZlcmVuY2VDdXN0b21Ub29sRm9ybWF0SACIAQFCFQoTX2N1c3RvbV90b29sX2Zvcm1hdCJtChlJbmZlcmVuY2VBbnRocm9waWNPcHRpb25zEj4KDWNhY2hlX2NvbnRyb2wYASABKAsyIi5haXNlcnZlci52MS5JbmZlcmVuY2VDYWNoZUNvbnRyb2xIAIgBAUIQCg5fY2FjaGVfY29udHJvbCIlChVJbmZlcmVuY2VDYWNoZUNvbnRyb2wSDAoEdHlwZRgBIAEoCSKwAQoUSW5mZXJlbmNlQ29udGVudFBhcnQSLgoEdGV4dBgBIAEoCzIeLmFpc2VydmVyLnYxLkluZmVyZW5jZVRleHRQYXJ0SAASMAoFaW1hZ2UYAiABKAsyHy5haXNlcnZlci52MS5JbmZlcmVuY2VJbWFnZVBhcnRIABIuCgRmaWxlGAMgASgLMh4uYWlzZXJ2ZXIudjEuSW5mZXJlbmNlRmlsZVBhcnRIAEIGCgRwYXJ0IkkKFUluZmVyZW5jZUNvbnRlbnRQYXJ0cxIwCgVwYXJ0cxgBIAMoCzIhLmFpc2VydmVyLnYxLkluZmVyZW5j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2};function G(e,t){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<=0||t<=0)throw Error(`Cursor image has invalid dimensions`);return{width:e,height:t}}function sr(e){if(e===``||e.length%4!=0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u.test(e))throw Error(`Cursor image data is not valid base64`);let t=Buffer.from(e,`base64`);if(t.toString(`base64`)!==e)throw Error(`Cursor image data is not canonical base64`);return t}function cr(e){if(e.byteLength<24||!e.subarray(0,8).every((e,t)=>e===[137,80,78,71,13,10,26,10][t]))throw Error(`Cursor image MIME type does not match PNG bytes`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return G(t.getUint32(16),t.getUint32(20))}function lr(e){let t=new TextDecoder().decode(e.subarray(0,6));if(e.byteLength<10||t!==`GIF87a`&&t!==`GIF89a`)throw Error(`Cursor image MIME type does not match GIF bytes`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength);return G(n.getUint16(6,!0),n.getUint16(8,!0))}function ur(e){if(e.byteLength<26||e[0]!==66||e[1]!==77)throw Error(`Cursor image MIME type does not match BMP bytes`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return G(t.getInt32(18,!0),Math.abs(t.getInt32(22,!0)))}function dr(e){if(e.byteLength<4||e[0]!==255||e[1]!==216)throw Error(`Cursor image MIME type does not match JPEG bytes`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=2;for(;n+3<e.byteLength;){if(e[n]!==255){n+=1;continue}for(;e[n]===255;)n+=1;let r=e[n];if(n+=1,r===void 0||r===217||r===218)break;if(r===1||r>=208&&r<=215)continue;if(n+2>e.byteLength)break;let i=t.getUint16(n);if(i<2||n+i>e.byteLength)break;if(r>=192&&r<=195||r>=197&&r<=199||r>=201&&r<=203||r>=205&&r<=207){if(i<7)break;return G(t.getUint16(n+5),t.getUint16(n+3))}n+=i}throw Error(`Cursor JPEG image has no decodable dimensions`)}function fr(e,t,n){return new TextDecoder().decode(e.subarray(t,t+n))}function K(e,t){let n=e[t];if(n===void 0)throw Error(`Cursor image data is truncated`);return n}function pr(e){if(e.byteLength<30||fr(e,0,4)!==`RIFF`||fr(e,8,4)!==`WEBP`)throw Error(`Cursor image MIME type does not match WebP bytes`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=fr(e,12,4);if(n===`VP8X`)return G(1+K(e,24)+(K(e,25)<<8)+(K(e,26)<<16),1+K(e,27)+(K(e,28)<<8)+(K(e,29)<<16));if(n===`VP8 `){if(e[23]!==157||e[24]!==1||e[25]!==42)throw Error(`Cursor WebP VP8 frame header is malformed`);return G(t.getUint16(26,!0)&16383,t.getUint16(28,!0)&16383)}if(n===`VP8L`){if(e[20]!==47)throw Error(`Cursor WebP lossless header is malformed`);let n=t.getUint32(21,!0);return G((n&16383)+1,(n>>>14&16383)+1)}throw Error(`Cursor WebP chunk '${n}' is unsupported`)}function mr(e,t){switch(e){case`image/png`:return cr(t);case`image/jpeg`:return dr(t);case`image/gif`:return lr(t);case`image/webp`:return pr(t);case`image/bmp`:return ur(t);default:throw Error(`Cursor image MIME type '${e}' is unsupported`)}}function hr(e){if(e.mimeType!==e.mimeType.trim()||e.mimeType!==e.mimeType.toLowerCase())throw Error(`Cursor image MIME type '${e.mimeType}' is malformed`);let t=sr(e.data);return mr(e.mimeType,t),e}function q(e){if(e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`){if(typeof e==`number`&&!Number.isFinite(e))throw Error(`Cursor inference JSON contains a non-finite number`);return e}if(Array.isArray(e))return e.map(e=>q(e));if(w(e))return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>[e,q(t)]));throw Error(`Cursor inference value is not JSON-serializable`)}function gr(e){if(!w(e))return;let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=q(r));return t}function _r(e,t){let n=gr(e);if(n===void 0)throw Error(`${t} must be a JSON object`);return n}const vr=/^(.*)-(none|minimal|low|medium|high|xhigh|extra-high|max)(-fast)?$/u,yr=[`medium`,`high`,`low`,`minimal`,`xhigh`,`max`,`off`],br={"auto-smart":{modelId:`auto-smart`,parameters:[{id:`optimize_for`,value:`balanced`}]},"composer-2.5":{modelId:`composer-2.5`,parameters:[{id:`fast`,value:`false`}]},"cursor-grok-4.6-high":{modelId:`grok-4.6`,parameters:[{id:`effort`,value:`high`},{id:`fast`,value:`false`}]},"claude-opus-5-thinking-high":{modelId:`claude-opus-5`,parameters:[{id:`thinking`,value:`true`},{id:`context`,value:`300k`},{id:`effort`,value:`high`},{id:`fast`,value:`false`}]},"gemini-3.7-flash-high":{modelId:`gemini-3.7-flash`,parameters:[{id:`effort`,value:`high`}]}};function xr(e,t){let n=e.thinkingLevelMap;if(n===void 0)return e.id;if(t!==void 0&&t!==``){let e=Object.entries(n).find(([e])=>e===t)?.[1];if(typeof e==`string`&&e!==``)return e}for(let e of yr){let t=n[e];if(typeof t==`string`&&t!==``)return t}return e.id}function Sr(e){return/^(gpt-|o[1-9](?:-|$)|codex-)/u.test(e)}function Cr(e,t){if(t===void 0)return e;let n=e.filter(({id:e})=>e!==`context`);return[{id:`context`,value:t},...n]}function wr(e,t){let n=xr(e,t.reasoning),r=br[n];if(r!==void 0)return{...r,maxMode:t.maxMode,parameters:Cr(r.parameters,t.context)};let i=vr.exec(n),a=i?.[1],o=i?.[2],s=i?.[3]===`-fast`;return a===void 0||o===void 0||!Sr(a)?{modelId:n,maxMode:t.maxMode,parameters:[]}:{modelId:`${a}${s?`-fast`:``}`,maxMode:t.maxMode,parameters:[{id:`context`,value:t.context??`272k`},{id:`reasoning`,value:o},{id:`fast`,value:String(s)}]}}function Tr(e){return hr(e),b(Vn,{part:{case:`image`,value:b(Un,{data:e.data,mimeType:e.mimeType})}})}function Er(e){return b(Vn,{part:{case:`text`,value:b(Yn,{text:e})}})}function Dr(e){return typeof e==`string`?{case:`text`,value:e}:e.every(e=>e.type===`text`)?{case:`text`,value:e.map(e=>e.text).join(``)}:{case:`parts`,value:b(Hn,{parts:e.map(e=>e.type===`text`?Er(e.text):Tr(e))})}}function Or(e){let t=e.content.flatMap(e=>e.type===`text`?[e.text]:[]);return t.length===1?t[0]??``:t.map(e=>q({type:`text`,text:e}))}function kr(e){return e.content.some(e=>e.type===`image`)?e.content.map(e=>e.type===`text`?Er(e.text):Tr(e)):[]}function Ar(e){if(e.role===`user`)return b(H,{role:W.USER,content:Dr(e.content)});if(e.role===`assistant`){let t=[],n=[],r=[];for(let i of e.content)if(i.type===`text`)t.push(i.text);else if(i.type===`thinking`)n.push(b(Kn,T({isRedacted:i.redacted===!0,text:i.thinking,signature:i.redacted===!0?void 0:i.thinkingSignature,redactedData:i.redacted===!0?i.thinkingSignature:void 0,modelName:e.provider===`cursor`?e.responseModel:void 0})));else{let e=_r(i.arguments,`Cursor inference tool '${i.name}' arguments`);r.push(b(Xn,{toolCallId:i.id,toolName:i.name,args:e,rawToolCallArgs:JSON.stringify(e)}))}return b(H,T({role:W.ASSISTANT,content:t.length===0?void 0:{case:`text`,value:t.join(``)},reasoningParts:n,toolCalls:r,modelProviderMessageId:e.responseId}))}return b(H,{role:W.TOOL,content:{case:`toolContent`,value:b(Zn,{parts:[b(Qn,{toolCallId:e.toolCallId,toolName:e.toolName,result:oe(be,Or(e)),isError:e.isError,experimentalContent:kr(e)})]})}})}function jr(e){let t=_r(e.parameters,`Cursor inference tool '${e.name}' schema`);return b(Bn,{name:e.name,description:e.description,parameters:{jsonSchema:t}})}function Mr(e,t={}){let n=e.messages.map(Ar);e.systemPrompt!==void 0&&e.systemPrompt!==``&&n.unshift(b(H,{role:W.SYSTEM,content:{case:`text`,value:e.systemPrompt}}));let r=t.maxTokens===void 0&&t.temperature===void 0&&t.topP===void 0&&t.stopSequences===void 0?void 0:b(Wn,T({maxTokens:t.maxTokens,temperature:t.temperature,topP:t.topP,stopSequences:t.stopSequences===void 0?void 0:[...t.stopSequences]}));return b(Jn,T({messages:n,tools:e.tools?.map(jr)??[],modelConfig:r}))}function Nr(e){return e.role===`user`?typeof e.content==`string`?e.content:e.content.flatMap(e=>e.type===`text`?[e.text]:[]).join(``):e.role===`assistant`?e.content.flatMap(e=>e.type===`text`?[e.text]:[]).join(``):``}function Pr(e){return e.messages.flatMap(e=>{if(e.role===`toolResult`)return[];let t=Nr(e);return t===``?[]:[b(nr,{role:e.role===`user`?or.USER:or.ASSISTANT,text:t})]})}function Fr(e,t,n=!1,r){let i=wr(e,T({maxMode:n,reasoning:t,context:r}));return b(qn,{modelId:i.modelId,maxMode:i.maxMode,parameters:i.parameters.map(e=>b(Gn,e))})}function Ir(e,t,n=!1,r){let i=Fr(e,t,n,r);return JSON.stringify({modelId:i.modelId,maxMode:i.maxMode,parameters:i.parameters.map(({id:e,value:t})=>({id:e,value:t}))})}function Lr(e,t,n,r,i=!1,a){if(n===``)throw Error(`Cursor managed inference requires a stable Pi session id`);return b(rr,{conversationId:n,requestedModel:Fr(e,r,i,a),routingConversation:Pr(t),agentMode:`agent`})}function Rr(e){return e.filter(e=>e.type===`text`)}function zr(e){return e.filter(e=>e.type===`thinking`)}function Br(e){return e.filter(e=>e.type===`toolCall`)}function Vr(e){return e.map(({text:e})=>e).join(``)}function Hr(e){return e.map(({thinking:e})=>e).join(``)}function J(e){return e.thinkingSignature===void 0||e.thinkingSignature===``?void 0:e.thinkingSignature}function Y(e){return J(e)!==void 0||e.redacted===!0}function Ur(e,t){return{...e,...T({thinkingSignature:J(t)??J(e),redacted:t.redacted===!0||e.redacted===!0||void 0})}}function Wr(e){return{type:`thinking`,thinking:``,...T({thinkingSignature:J(e),redacted:e.redacted===!0||void 0})}}function Gr(e,t){return J(e)===J(t)&&e.redacted===t.redacted}function Kr(e,t){if(!Y(t))return!1;let n=Wr(t);return!e.some(e=>Gr(e,n))&&(e.push(n),!0)}function qr(e,t){if(t.some(({thinking:e})=>e.trim()!==``)){let n=t.map(e=>({...e})),r=0,i=0;for(let t of e.filter(Y)){let e=J(t),a=e===void 0?-1:n.findIndex(t=>J(t)===e);if(a<0&&t.thinking.trim()!==``&&(a=n.findIndex(e=>e.thinking===t.thinking)),a>=0){let e=n[a];e!==void 0&&(n[a]=Ur(e,t)),r+=1}else Kr(n,t)&&(i+=1)}return{blocks:n,source:`final`,mergedMetadata:r,unmatchedMetadata:i}}let n=e.map(e=>({...e})),r=[],i=0;for(let e of t.filter(Y)){let t=J(e),a=t===void 0?-1:n.findIndex(e=>J(e)===t);if(a>=0){let t=n[a];t!==void 0&&(n[a]=Ur(t,e)),i+=1}else r.push(e)}let a=n.map((e,t)=>({block:e,index:t})).filter(({block:e})=>e.thinking.trim()!==``&&!Y(e));if(r.length===1&&a.length===1){let e=a[0],t=r[0];e!==void 0&&t!==void 0&&(n[e.index]=Ur(e.block,t),i+=1,r.length=0)}let o=0;for(let e of r)Kr(n,e)&&(o+=1);return{blocks:n,source:n.some(({thinking:e})=>e.trim()!==``)?`stream`:n.length>0?`opaque-final`:`none`,mergedMetadata:i,unmatchedMetadata:o}}function X(e,t){let n=new Map;for(let r of e){if(n.has(r.id))throw Error(`Cursor ${t} response duplicated tool '${r.id}'`);n.set(r.id,r)}return n}function Jr(e,t){let n=X(e,`streamed`),r=X(t,`final`);if(n.size!==r.size)throw Error(`Cursor final response tool set disagrees with completed streamed tools`);for(let[e,t]of n){let n=r.get(e);if(n===void 0)throw Error(`Cursor final response tool set disagrees with completed streamed tools`);if(t.name!==n.name)throw Error(`Cursor final response changed the name of tool '${e}'`);if(!Se(t.arguments,n.arguments))throw Error(`Cursor final response changed the arguments of tool '${e}'`)}}function Yr(e,t,n={}){let r=n.strict??!0,i=Rr(e),a=t===void 0?[]:Rr(t),o=zr(e),s=t===void 0?[]:zr(t),c=Br(e),l=t===void 0?[]:Br(t);r&&t!==void 0&&c.length>0?Jr(c,l):(X(c,`streamed`),X(l,`final`));let u=a.length>0?`final`:i.length>0?`stream`:`none`,d=a.length>0?a:i,f=l.length>0?l:c,p=qr(o,s),m=a.length>0||l.length>0?t?.filter(e=>e.type!==`thinking`)??[]:e.filter(e=>e.type!==`thinking`),h=t===void 0?e:a.length===0&&l.length>0&&i.length>0?[...p.blocks,...d,...f]:[...p.blocks,...m],g=Vr(i),_=Vr(a),v=Hr(o),y=Hr(s),ee=c.length>0&&l.length>0?r?`exact`:`unchecked`:c.length>0?`stream-only`:l.length>0?`final-only`:`none`;return{content:h,summary:{responseInfo:t!==void 0,strict:r,text:{streamedBlocks:i.length,finalBlocks:a.length,streamedCharacters:g.length,finalCharacters:_.length,exact:i.length>0&&a.length>0?g===_:null,source:u},reasoning:{streamedBlocks:o.length,finalBlocks:s.length,streamedCharacters:v.length,finalCharacters:y.length,exact:o.some(({thinking:e})=>e.trim()!==``)&&s.some(({thinking:e})=>e.trim()!==``)?v===y:null,source:p.source,mergedMetadata:p.mergedMetadata,unmatchedMetadata:p.unmatchedMetadata},tools:{streamed:c.length,final:l.length,status:ee}}}}function Z(e,t){if(e===``)return t?{}:void 0;let n;try{n=t?JSON.parse(e):Ee(e)}catch{return}if(typeof n==`object`&&n&&!Array.isArray(n))return Object.fromEntries(Object.entries(n))}function Xr(e){if(e.args!==void 0)return Object.fromEntries(Object.entries(e.args));if(e.rawToolCallArgs===void 0||e.rawToolCallArgs===``)return{};let t;try{t=JSON.parse(e.rawToolCallArgs)}catch(t){throw Error(`Cursor final tool call '${e.toolCallId}' has invalid raw arguments`,{cause:t})}if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`Cursor final tool call '${e.toolCallId}' arguments are not an object`);return Object.fromEntries(Object.entries(t))}function Zr(e){return{tokenLogprobs:e.tokenLogprobs.map(({values:e})=>e),tokenIds:e.tokenIds.map(({values:e})=>e.map(Number)),promptTokenIds:e.promptTokenIds.map(({values:e})=>e.map(Number)),extraTokens:e.extraTokens.map(({values:e})=>e.map(Number)),extraLogprobs:e.extraLogprobs.map(({values:e})=>e),routingMatrix:e.routingMatrix.map(({values:e})=>e.map(e=>e===``?null:e))}}function Qr(e){return T({messageIndex:e.messageIndex,partIndex:e.partIndex,expContentIndex:e.expContentIndex,description:e.description})}function $r(e){return v(e).with(W.USER,()=>`user`).with(W.ASSISTANT,()=>`assistant`).with(W.TOOL,()=>`tool`).with(W.SYSTEM,()=>`system`).with(W.UNSPECIFIED,()=>`unspecified`).otherwise(e=>`unknown-${String(e)}`)}function ei(e){let t=e.message===``?e.code||`Cursor inference failed`:e.message;return e.isInputTokenLimitError||e.errorType===ar.INPUT_TOKEN_LIMIT?`context_length_exceeded: ${t}`:t}var ti=class{#e;#t;#n;#r;#i;#a;#o;#s=new Map;#c=new Set;#l=new Map;#u;#d;#f;#p=[];#m;constructor(e,t,n,r,i){this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#i=i}handle(e){if(e.message.case!==`invocationResponse`)throw Error(`Cursor mapper received outer arm '${e.message.case??`<unset>`}'`);let t=e.message.value.response;if(t===void 0)throw Error(`Cursor invocation response has no payload`);this.#h(t)}#h(e){let t=e.response.case;this.#l.set(t,(this.#l.get(t)??0)+1),v(e.response).with({case:`thinkingPart`},({value:e})=>{e.text!==``&&this.#_(e.text,e.signature),e.isFinal&&this.#S()}).with({case:`textPart`},({value:e})=>{e.text!==``&&this.#v(e.text),e.isFinal&&this.#x()}).with({case:`toolCallPart`},({value:e})=>this.#y(e)).with({case:`extendedUsage`},({value:e})=>{this.#t.usage.input=e.inputTokens,this.#t.usage.output=e.outputTokens,this.#t.usage.cacheRead=e.cacheReadTokens,this.#t.usage.cacheWrite=e.cacheWriteTokens,this.#b()}).with({case:`usage`},({value:e})=>{this.#l.has(`extendedUsage`)||(this.#t.usage.input=e.promptTokens,this.#t.usage.output=e.completionTokens,this.#t.usage.cacheRead=0,this.#t.usage.cacheWrite=0,this.#b())}).with({case:`responseInfo`},({value:e})=>{e.errorMessage!==void 0&&e.errorMessage!==``&&(this.#u={message:e.errorMessage,outputLimit:!1}),e.id!==``&&(this.#t.responseId=e.id),e.model!==``&&(this.#t.responseModel=e.model);let t=Number(e.createdAt);Number.isSafeInteger(t)&&t>0&&(this.#t.timestamp=t),this.#g(e)}).with({case:`error`},({value:e})=>{this.#u={message:ei(e),outputLimit:e.isOutputTokenLimitError||e.errorType===ar.OUTPUT_TOKEN_LIMIT}}).with({case:`invocationId`},({value:e})=>{if(e.invocationId!==this.#r)throw Error(`Cursor nested invocation identity disagrees with its outer envelope`)}).with({case:`providerMetadata`},({value:e})=>{this.#f=e.metadata}).with({case:`imageDescriptions`},({value:e})=>{this.#p.push(...e.descriptions.map(Qr))}).with({case:void 0},()=>{throw Error(`Cursor inference response has no arm`)}).exhaustive()}#g(e){let t=[],n={};for(let r of e.messages){let e=$r(r.role);if(n[e]=(n[e]??0)+1,r.role!==W.TOOL){for(let e of r.reasoningParts){let n=e.isRedacted?e.redactedData:e.signature;t.push(T({type:`thinking`,thinking:e.text,thinkingSignature:n,redacted:e.isRedacted?!0:void 0}))}r.content!==void 0&&r.content.trim()!==``&&t.push({type:`text`,text:r.content});for(let e of r.toolCalls){if(e.toolCallId===``||e.toolName===``)throw Error(`Cursor final response contains an unnamed tool call`);if(!this.#n.has(e.toolName))throw Error(`Cursor final response called unadvertised tool '${e.toolName}'`);t.push({type:`toolCall`,id:e.toolCallId,name:e.toolName,arguments:Xr(e)})}}}this.#d=t,this.#m=T({createdAt:e.createdAt.toString(),supportsSelfSummary:e.supportsSelfSummary,roleCounts:n,inferenceExtraData:e.inferenceExtraData===void 0?void 0:Zr(e.inferenceExtraData)})}#_(e,t){if(this.#x(),this.#o===void 0){let e={type:`thinking`,thinking:``,...T({thinkingSignature:t})};this.#t.content.push(e),this.#o={index:this.#t.content.length-1,block:e},this.#e.push({type:`thinking_start`,contentIndex:this.#o.index,partial:this.#t})}else if(t!==void 0&&this.#o.block.thinkingSignature!==void 0&&this.#o.block.thinkingSignature!==t)throw Error(`Cursor thinking signature changed within one block`);else t!==void 0&&(this.#o.block.thinkingSignature=t);this.#o.block.thinking+=e,this.#e.push({type:`thinking_delta`,contentIndex:this.#o.index,delta:e,partial:this.#t})}#v(e){if(this.#S(),this.#a===void 0){let e={type:`text`,text:``};this.#t.content.push(e),this.#a={index:this.#t.content.length-1,block:e},this.#e.push({type:`text_start`,contentIndex:this.#a.index,partial:this.#t})}this.#a.block.text+=e,this.#e.push({type:`text_delta`,contentIndex:this.#a.index,delta:e,partial:this.#t})}#y(e){if(e.toolCallId===``)throw Error(`Cursor tool call has no id`);if(this.#c.has(e.toolCallId))throw Error(`Cursor tool call '${e.toolCallId}' continued after completion`);let t=this.#s.get(e.toolCallId);if(t===void 0){if(e.toolName===``)throw Error(`Cursor tool call starts without a name`);if(!this.#n.has(e.toolName))throw Error(`Cursor called unadvertised tool '${e.toolName}'`);this.#x(),this.#S();let n={type:`toolCall`,id:e.toolCallId,name:e.toolName,arguments:{}};this.#t.content.push(n),t={index:this.#t.content.length-1,block:n,name:e.toolName,json:``,complete:!1,toolIndex:e.toolIndex},this.#s.set(e.toolCallId,t),this.#e.push({type:`toolcall_start`,contentIndex:t.index,partial:this.#t})}if(e.toolName!==``&&e.toolName!==t.name)throw Error(`Cursor tool call '${e.toolCallId}' changed name`);if(!e.isComplete){if(e.args===``)return;t.json+=e.args;let n=Z(t.json,!1);n!==void 0&&(t.block.arguments=n),this.#e.push({type:`toolcall_delta`,contentIndex:t.index,delta:e.args,partial:this.#t});return}let n=Z(e.args,!0);if(n===void 0)throw Error(`Cursor tool call '${e.toolCallId}' completed with invalid JSON arguments`);let r=Z(t.json,!0);if(t.json!==``&&(r===void 0||!Se(r,n)))throw Error(`Cursor tool call '${e.toolCallId}' argument stream disagrees with completion`);t.block.arguments=n,t.complete=!0,this.#e.push({type:`toolcall_end`,contentIndex:t.index,toolCall:t.block,partial:this.#t}),this.#s.delete(e.toolCallId),this.#c.add(e.toolCallId)}#b(){this.#t.usage.totalTokens=this.#t.usage.input+this.#t.usage.output+this.#t.usage.cacheRead+this.#t.usage.cacheWrite}#x(){this.#a!==void 0&&(this.#e.push({type:`text_end`,contentIndex:this.#a.index,content:this.#a.block.text,partial:this.#t}),this.#a=void 0)}#S(){this.#o!==void 0&&(this.#e.push({type:`thinking_end`,contentIndex:this.#o.index,content:this.#o.block.thinking,partial:this.#t}),this.#o=void 0)}finish(){if(this.#x(),this.#S(),this.#s.size>0)throw Error(`Cursor invocation ended with incomplete tool calls`);let e=Yr(this.#t.content,this.#d,{strict:this.#i.strictReconciliation});this.#t.content.splice(0,this.#t.content.length,...e.content);let t=this.#t.content.filter(({type:e})=>e===`toolCall`);if(this.#i.strictReconciliation&&this.#c.size>0&&t.length===0)throw Error(`Cursor toolUse completed without a finalized tool call`);if(this.#i.diagnostics){let t={arms:Object.fromEntries(this.#l),reconciliation:e.summary};this.#f!==void 0&&(t.providerMetadata=this.#f),this.#p.length>0&&(t.imageDescriptions=this.#p),this.#m!==void 0&&(t.responseInfo=this.#m),this.#t.diagnostics=[...this.#t.diagnostics??[],{type:`cursor-inference-response`,timestamp:Date.now(),details:t}]}return this.#u===void 0?{stopReason:t.length>0?`toolUse`:`stop`}:this.#u.outputLimit&&this.#t.content.length>0?{stopReason:`length`}:{stopReason:`error`,errorMessage:this.#u.message}}};function ni(e){return{role:`assistant`,content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`pending`,timestamp:Date.now()}}function ri(e){return e instanceof Error?e.message:String(e)}function ii(e,t){let n=t?.samplingParams?.cursorMaxMode??e.samplingParams?.cursorMaxMode;return v(n).with(void 0,()=>!1).with(_.boolean,e=>e).otherwise(()=>{throw Error(`Cursor sampling parameter cursorMaxMode must be a boolean`)})}function ai(e,t){let n=t?.samplingParams?.cursorContext??e.samplingParams?.cursorContext;return v(n).with(void 0,()=>void 0).with(_.string,e=>e).otherwise(()=>{throw Error(`Cursor sampling parameter cursorContext must be a string`)})}function oi(e,t){return v(e).with(void 0,()=>void 0).with(_.when(e=>typeof e==`number`&&Number.isFinite(e)),e=>e).otherwise(()=>{throw Error(`Cursor sampling parameter ${t} must be a finite number`)})}function si(e,t){return v(e).with(void 0,()=>void 0).with(_.array(_.string),e=>e).otherwise(()=>{throw Error(`Cursor sampling parameter ${t} must be an array of strings`)})}function ci(e,t,n,r){let i=we(),a=ni(e),o=n.settings??A();return(async()=>{try{if(i.push({type:`start`,partial:a}),r?.apiKey===void 0||r.apiKey===``)throw Error(`Cursor credential is unavailable`);let s=r.sessionId;if(s===void 0||s===``)throw Error(`Cursor managed inference requires SimpleStreamOptions.sessionId`);let c=(n.createInvocationId??(()=>crypto.randomUUID()))(),l=typeof r.reasoning==`string`?r.reasoning:void 0,u=ii(e,r),d=ai(e,r),f=Mr(t,T({maxTokens:r.maxTokens,temperature:r.temperature,topP:oi(r.samplingParams?.topP,`topP`),stopSequences:si(r.samplingParams?.stopSequences,`stopSequences`)})),p=b(U,{message:{case:`runRequest`,value:Lr(e,t,s,l,u,d)}}),m=new ti(i,a,new Set(t.tools?.map(({name:e})=>e)??[]),c,o);await(typeof n.runtime==`function`?await n.runtime(r.apiKey):n.runtime).invoke(s,Ir(e,l,u,d),p,c,f,T({signal:r.signal,onResponse:e=>m.handle(e)}));let h=m.finish();if(a.stopReason=h.stopReason,h.errorMessage!==void 0&&(a.errorMessage=h.errorMessage),Ce(e,a.usage),a.stopReason===`error`)i.push({type:`error`,reason:`error`,error:a});else if(a.stopReason===`stop`||a.stopReason===`toolUse`||a.stopReason===`length`||a.stopReason===`deferred`)i.push({type:`done`,reason:a.stopReason,message:a});else throw Error(`Cursor mapper returned invalid terminal '${a.stopReason}'`);i.end()}catch(e){a.stopReason=r?.signal?.aborted===!0?`aborted`:`error`,a.errorMessage=ri(e),i.push({type:`error`,reason:a.stopReason,error:a}),i.end()}})(),i}function li(e,t=0){let n=new Uint8Array(5+e.length),r=new DataView(n.buffer);return r.setUint8(0,t),r.setUint32(1,e.length,!1),n.set(e,5),n}var ui=class{#e=new Uint8Array;#t=0;#n=0;get#r(){return this.#n-this.#t}#i(e){if(this.#n+e<=this.#e.length)return;let t=this.#r+e;if(t<=this.#e.length)this.#e.copyWithin(0,this.#t,this.#n);else{let e=Math.max(this.#e.length*2,65536);for(;e<t;)e*=2;let n=new Uint8Array(e);n.set(this.#e.subarray(this.#t,this.#n)),this.#e=n}this.#n=this.#r,this.#t=0}push(e){e.length>0&&(this.#i(e.length),this.#e.set(e,this.#n),this.#n+=e.length);let t=[];for(;!(this.#r<5);){let e=new DataView(this.#e.buffer,this.#e.byteOffset+this.#t,5),n=e.getUint8(0),r=e.getUint32(1,!1);if(r>16777216)throw Error(`Connect frame length ${String(r)} exceeds the 16777216 byte cap`);if(this.#r<5+r)break;let i=this.#t+5,a=this.#e.slice(i,i+r);this.#t=i+r;let o=!!(n&1);t.push({body:o?ue(a,{maxOutputLength:16777216}):a,compressed:o,endOfStream:!!(n&2)})}return this.#t===this.#n&&(this.#t=0,this.#n=0),t}end(){if(this.#r>0)throw Error(`Connect stream ended mid-frame with ${String(this.#r)} trailing bytes`)}get pending(){return this.#r}};const di=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;function Q(e,t){if(t.includes(`\r`)||t.includes(`
|
|
8
|
-
`))throw Error(`${e} contains a line break`)}function fi(e,t=Date.now()){let n=Math.floor(t/1e6),r=new Uint8Array([n>>40&255,n>>32&255,n>>24&255,n>>16&255,n>>8&255,n&255]),i=165;for(let e=0;e<r.length;e+=1){let t=r[e];if(t===void 0)throw Error(`Cursor checksum input is incomplete`);r[e]=(t^i)+e%256&255,i=r[e]??i}let a=Oe.from(r).toString(`base64`);return e.macMachineId===void 0?`${a}${e.machineId}`:`${a}${e.machineId}/${e.macMachineId}`}function pi(t){Q(`Cursor credential`,t.token),Q(`Cursor request id`,t.requestId),Q(`Cursor client key`,t.clientKey);let r=t.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone;if(Q(`Cursor timezone`,r),!/^[0-9a-f]{64}$/u.test(t.clientKey))throw Error(`Cursor client key must be 32-byte lowercase hex`);if(!di.test(t.requestId))throw Error(`Cursor request id must be a UUID`);return{":method":`POST`,":path":`/aiserver.v1.InferenceService/RunInference`,authorization:`Bearer ${t.token}`,cookie:`CursorCookie=Cookie-${t.token.slice(0,15)}`,"connect-accept-encoding":`gzip`,"connect-content-encoding":`gzip`,"connect-protocol-version":`1`,"content-type":`application/connect+proto`,"user-agent":`connect-es/1.6.1`,"x-amzn-trace-id":`Root=${t.requestId}`,"x-client-key":t.clientKey,"x-cursor-checksum":fi(t.identity,t.nowMs),"x-cursor-client-arch":t.arch??e,"x-cursor-client-commit":`2ba48ff3f7514cc4643c52ca9f7b3173d9b66130`,"x-cursor-client-device-type":`desktop`,"x-cursor-client-os":t.platform??n,"x-cursor-client-type":`ide`,"x-cursor-client-version":`3.18.9`,"x-cursor-streaming":`true`,"x-cursor-timezone":r,"x-ghost-mode":String(t.ghostMode),"x-new-onboarding-completed":`false`,"x-request-id":t.requestId}}const mi=2e3;function hi(e){return Buffer.from(crypto.getRandomValues(new Uint8Array(e))).toString(`hex`)}function gi(e){let t;try{t=new URL(e)}catch(e){throw Error(`Cursor backend authority is invalid`,{cause:e})}if(t.protocol!==`https:`||t.username!==``||t.password!==``||t.pathname!==``&&t.pathname!==`/`||t.search!==``||t.hash!==``)throw Error(`Cursor backend authority must be an HTTPS origin`);return new URL(t.origin)}function _i(e){let t=se(U,e);if(t.byteLength>16777216)throw Error(`Cursor RunInference client message exceeds the Connect frame limit`);return t.byteLength<1024?li(t):li(de(t),1)}function vi(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch(e){throw Error(`Cursor returned an invalid Connect end-of-stream trailer`,{cause:e})}if(!w(t))throw Error(`Cursor returned an invalid Connect end-of-stream trailer`);if(t.error===void 0)return{};if(!w(t.error)||typeof t.error.code!=`string`)throw Error(`Cursor returned an invalid Connect error trailer`);let n=t.error.code.trim(),r=t.error.message;if(n===``||r!==void 0&&typeof r!=`string`)throw Error(`Cursor returned an invalid Connect error trailer`);return{error:T({code:n,message:r})}}function yi(e){return e.message.trim()===``?`Cursor invocation error ${String(e.code)}`:e.message}function bi(e,t,n){return new Promise((r,i)=>{let a=setTimeout(()=>i(Error(`${n} timed out`)),t);e.then(e=>(clearTimeout(a),r(e)),e=>(clearTimeout(a),i(e)))})}var xi=class{routeKey;ready;completion;#e;#t=new Map;#n=new Set;#r;#i;#a;#o;#s;#c=Promise.resolve();#l=Promise.resolve();#u=0;#d=0;#f;#p;#m;#h=new Set;constructor(e,t,n,r){this.routeKey=t,this.#r=r.responseTimeoutMs??65e3;let i,a;this.ready=new Promise((e,t)=>{i=e,a=t}),this.ready.catch(()=>void 0),this.#i=i,this.#a=a;let o,s;this.completion=new Promise((e,t)=>{o=e,s=t}),this.completion.catch(()=>void 0),this.#o=o,this.#s=s,this.#e=e.request(n),this.#g()}#g(){let e=new ui,t=0;this.#e.on(`response`,e=>{if(t=Number(e[`:status`]??0),t!==200){this.#v(Error(`Cursor RunInference returned HTTP ${String(t)}`));return}(e[`content-type`]??``).startsWith(`application/connect+proto`)||this.#v(Error(`Cursor RunInference returned an invalid content type`))}),this.#e.on(`data`,t=>{try{for(let n of e.push(t)){if(this.#p!==void 0)throw Error(`Cursor sent data after the Connect trailer`);if(n.endOfStream){if(this.#p=vi(n.body),this.#p.error!==void 0)throw Error(`Cursor RunInference failed: ${this.#p.error.code}${this.#p.error.message===void 0?``:` — ${this.#p.error.message}`}`);continue}let e=ae(ir,n.body);if(this.#u+=1,this.#d+=n.body.byteLength,this.#u>512||this.#d>8388608)throw Error(`Cursor RunInference response delivery exceeded its bound`);this.#l=this.#l.then(async()=>{try{await this.#_(e);return}finally{--this.#u,this.#d-=n.body.byteLength}}),this.#l.catch(e=>{this.#v(e)})}}catch(e){this.#v(e)}}),this.#e.on(`error`,e=>this.#v(e)),this.#e.on(`aborted`,()=>this.#v(Error(`Cursor RunInference stream aborted`))),this.#e.on(`end`,()=>{try{e.end()}catch(e){this.#v(e);return}this.#l.then(()=>{if(this.#m===void 0&&t===200){if(this.#p===void 0){this.#v(Error(`Cursor RunInference ended without a Connect trailer`));return}if(this.#t.size>0){this.#v(Error(`Cursor RunInference ended with pending invocations`));return}this.#o({trailer:this.#p})}})})}async#_(e){switch(e.message.case){case`heartbeat`:return;case`runReady`:if(this.#f!==void 0)throw Error(`Cursor sent duplicate runReady`);if(e.message.value.resolvedModel===void 0||e.message.value.resolvedModel.modelId===``)throw Error(`Cursor runReady has no resolved model`);this.#f=e.message.value,this.#i(e.message.value);return;case`invocationResponse`:{let{invocationId:t}=e.message.value;if(this.#n.has(t))return;let n=this.#t.get(t);if(n===void 0)throw Error(`Cursor response has unknown invocation '${t}'`);n.delivery=n.delivery.then(async()=>await n.onResponse(e)),await n.delivery;return}case`invocationEnd`:{let t=e.message.value;if(this.#n.delete(t.invocationId))return;let n=this.#t.get(t.invocationId);if(n===void 0)throw Error(`Cursor ended unknown invocation '${t.invocationId}'`);this.#t.delete(t.invocationId),n.signal?.removeEventListener(`abort`,n.abort),await n.delivery,t.error===void 0?n.resolve({invocationId:t.invocationId,end:t}):n.reject(Error(`Cursor invocation failed: ${yi(t.error)}`));return}case void 0:throw Error(`Cursor RunInference server message has no arm`)}}#v(e){if(this.#m===void 0){this.#m=e,this.#a(e);for(let t of this.#t.values())t.signal?.removeEventListener(`abort`,t.abort),t.reject(e);this.#t.clear(),this.#s(e),this.#e.destroy(e instanceof Error?e:Error(String(e)))}}async send(e){if(this.#m!==void 0)throw this.#m;let t=_i(e);this.#c=this.#c.then(async()=>await new Promise((e,n)=>{this.#e.write(t,t=>{t==null?e():n(t)})})),await this.#c}async waitUntilReady(){return await bi(this.ready,this.#r,`Cursor runReady`)}abort(e){this.#v(e)}async invoke(e,t,n){if(this.#h.has(`finishing`))throw Error(`Cursor RunInference run is finishing`);if(await this.waitUntilReady(),this.#t.size>=64)throw Error(`Cursor RunInference has too many pending invocations`);if(this.#t.has(e)||this.#n.has(e))throw Error(`Cursor invocation '${e}' already exists`);let r,i,a=new Promise((e,t)=>{r=e,i=t}),o=()=>{this.#t.get(e)!==void 0&&(this.#t.delete(e),this.#n.add(e),this.send(b(U,{message:{case:`cancelInvocation`,value:b($n,{invocationId:e})}})).then(()=>i(new DOMException(`Aborted`,`AbortError`)),e=>{i(e),this.#v(e)}))};if(this.#t.set(e,{onResponse:n.onResponse,resolve:r,reject:i,signal:n.signal,abort:o,delivery:Promise.resolve()}),n.signal?.aborted===!0?o():n.signal?.addEventListener(`abort`,o,{once:!0}),this.#n.has(e))return await a;try{await this.send(b(U,{message:{case:`invokeModel`,value:b(tr,{invocationId:e,request:t})}}))}catch(t){this.#t.delete(e),n.signal?.removeEventListener(`abort`,o),i(t)}return await a}async finish(e){if(this.#h.has(`finishing`)){await bi(this.completion,e,`Cursor RunInference shutdown`);return}this.#h.add(`finishing`);for(let[e,t]of this.#t)this.#t.delete(e),this.#n.add(e),t.signal?.removeEventListener(`abort`,t.abort),t.reject(Error(`Cursor RunInference closed before invocation completed`)),await this.send(b(U,{message:{case:`cancelInvocation`,value:b($n,{invocationId:e})}}));await this.send(b(U,{message:{case:`finishRun`,value:b(er)}})),this.#e.end(),await bi(this.completion,e,`Cursor RunInference shutdown`)}},Si=class{#e;#t;#n;#r=new Map;#i=new Map;#a;#o;#s=new Set;constructor(e){if(this.#t=gi(e.backendUrl),this.#e=e,this.#n=(e.createClientKey??(()=>hi(32)))(),!/^[0-9a-f]{64}$/u.test(this.#n))throw Error(`Cursor client key must be 32-byte lowercase hex`)}async#c(){if(this.#s.has(`closed`))throw Error(`Cursor managed-inference runtime is shut down`);return this.#a!==void 0&&!this.#a.destroyed&&!this.#a.closed?this.#a:(this.#o??=Promise.resolve((this.#e.connect??(e=>De(e)))(this.#t.origin)).catch(e=>{throw this.#o=void 0,e}).then(e=>(this.#a=e,this.#o=void 0,e.once(`goaway`,()=>{this.#a===e&&(this.#a=void 0)}),e.on(`error`,()=>{this.#a===e&&(this.#a=void 0)}),e.once(`close`,()=>{this.#a===e&&(this.#a=void 0)}),e)),await this.#o)}async#l(e,t){let n=(this.#e.createRequestId??(()=>crypto.randomUUID()))(),r=pi({token:this.#e.token,ghostMode:this.#e.ghostMode,identity:this.#e.identity,requestId:n,clientKey:this.#n,nowMs:(this.#e.now??Date.now)(),timezone:(this.#e.timezone??(()=>Intl.DateTimeFormat().resolvedOptions().timeZone))()}),i=new xi(await this.#c(),e,r,this.#e);try{return await i.send(t),await i.waitUntilReady(),i}catch(e){throw i.abort(e),e}}async runFor(e,t,n){if(e===``)throw Error(`Cursor managed inference requires a stable Pi session id`);let r=this.#i.get(e)??Promise.resolve(),i,a=new Promise(e=>{i=e}),o=r.then(async()=>await a);this.#i.set(e,o),await r;try{let r=this.#r.get(e);if(r?.routeKey===t)return r.run;r!==void 0&&(this.#r.delete(e),await r.run.finish(this.#e.shutdownTimeoutMs??mi));let i=await this.#l(t,n);this.#r.set(e,{routeKey:t,run:i});let a=()=>{this.#r.get(e)?.run===i&&this.#r.delete(e)};return i.completion.then(a,a),i}finally{i(),this.#i.get(e)===o&&this.#i.delete(e)}}async invoke(e,t,n,r,i,a){return await(await this.runFor(e,t,n)).invoke(r,i,a)}async finishSession(e){let t=this.#r.get(e);t!==void 0&&(this.#r.delete(e),await t.run.finish(this.#e.shutdownTimeoutMs??mi))}async shutdown(){if(this.#s.has(`closed`))return;this.#s.add(`closed`);let e=[...this.#r.values()];this.#r.clear(),await Promise.allSettled(e.map(async({run:e})=>await e.finish(this.#e.shutdownTimeoutMs??mi))),this.#a?.destroy(),this.#a=void 0}};const Ci=`https://api2.cursor.sh`,$=`PI_CURSOR_TOKEN`;function wi(e){return e?.type===`oauth`?e.access:e?.type===`api_key`?e.key:process.env[$]}function Ti(e){return C(`sha256`).update(e,`utf8`).digest(`hex`)}const Ei={discoverModels:zn};function Di(e,t=Ei){let n,r=[],i=async t=>{let r=Ti(t);if(n?.digest===r)return n.runtime;await n?.runtime.shutdown();let i=new Si({backendUrl:Ci,token:t,ghostMode:!1,identity:e});return n={digest:r,runtime:i},i},a=(e,t,n)=>ci(e,t,{runtime:i},n),o=async e=>{if(!e.allowNetwork||e.signal.aborted)return;let n=wi(e.credential);if(n===void 0||n===``)throw Error(`Cursor credential is unavailable`);try{let i=await t.discoverModels({backendUrl:Ci,token:n,signal:e.signal,...e.force===void 0?{}:{force:e.force}});if(e.signal.aborted)return;await e.publish({persist:{models:i,checkedAt:Date.now()},update:()=>{r=i}})}catch(t){throw e.signal.aborted||await e.publish({persist:null,update:()=>{r=[]}}),t}};return{provider:{...Te({id:`cursor`,name:`Cursor`,baseUrl:Ci,auth:{apiKey:{name:$,check:async({ctx:e,signal:t})=>(t.throwIfAborted(),await e.env($)===void 0?void 0:{type:`api_key`,source:$}),resolve:async({ctx:e,credential:t,signal:n})=>{n.throwIfAborted();let r=t?.key??await e.env($);return r===void 0||r===``?void 0:{auth:{apiKey:r},source:$}}},oauth:hn()},models:[],api:{stream:a,streamSimple:a}}),getModels:()=>r,refreshModels:o},shutdown:async()=>{await n?.runtime.shutdown(),n=void 0}}}async function Oi(e){let t=He(),n=await nn(a()),r=Di(n);e.registerProvider(r.provider),Ut(e),(n.machineIdSource===`fallback`||t.warning!==void 0)&&e.on(`session_start`,(e,r)=>{n.machineIdSource===`fallback`&&r.ui.notify(`Cursor could not derive the host machine id; using a persisted fallback identity.`,`warning`),t.warning!==void 0&&r.ui.notify(t.warning,`warning`)}),e.on(`session_shutdown`,async()=>{await r.shutdown()})}export{Oi as default};
|
|
6
|
+
`)}function Pn(e){if(e.supportsMaxMode!==!0)return!1;if(e.supportsNonMaxMode===!1||e.contextTokenLimitForMaxMode!==void 0&&e.contextTokenLimitForMaxMode!==e.contextTokenLimit||Nn(e.tooltipDataForMaxMode)!==Nn(e.tooltipData)||e.variants.some(e=>e.isMaxMode))return!0;let t=e.variants.find(e=>e.isDefaultNonMaxConfig===!0),n=e.variants.find(e=>e.isDefaultMaxConfig===!0);return t!==void 0&&n!==void 0&&t!==n}function Fn(e,t){return e.variants.find(e=>t?e.isDefaultMaxConfig===!0:e.isDefaultNonMaxConfig===!0)?.parameterValues.find(e=>e.id===`context`)?.value}function In(e){let t=/^(\d+(?:\.\d+)?)([km])$/u.exec(e??``);if(t===null)return;let n=Number(t[1])*(t[2]===`m`?1e6:1e3);return Number.isSafeInteger(n)&&n>0?n:void 0}function Ln(e,t){let n=In(Fn(e,t));if(n!==void 0)return n;let r=t?e.contextTokenLimitForMaxMode??e.contextTokenLimit:e.contextTokenLimit;return r!==void 0&&r>0?r:2e5}function Rn(e,t,n,r){let i=Tn.flatMap(t=>e.members.filter(e=>e.level===t))[0]??e.members[0];if(i===void 0)throw Error(`Cursor model family '${e.id}' is empty`);let a={};for(let t of e.members)a[t.level]=t.model.modelId;let o=n.supportsThinking===!0,s=n.clientDisplayName===void 0||n.clientDisplayName===``?jn(i.model).replace(/ (?:None|Minimal|Low|Medium|High|Extra High|Max)(?= Fast$|$)/u,``):n.clientDisplayName,c=Fn(n,r),l=`${e.id}${r?`-max`:``}`,u=e.members.some(({model:e})=>e.modelId!==l),d={...r?{cursorMaxMode:!0}:{},...c===void 0?{}:{cursorContext:c}};return{id:l,name:`${s}${r?` Max`:``}`,provider:`cursor`,api:`cursor-inference`,baseUrl:t,reasoning:o,input:n.supportsImages===!0?[`text`,`image`]:[`text`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:Ln(n,r),maxTokens:64e3,...Object.keys(d).length===0?{}:{samplingParams:d},...Object.keys(a).length>0&&(o||u)?{thinkingLevelMap:a}:{}}}function zn(e,t,n,r){if(e.models.length===0)throw Error(`Cursor AvailableModels returned no models`);let i=An(t.models).flatMap(t=>{let n=Mn(t,e.models);return n===void 0?[]:[...n.supportsNonMaxMode===!1?[]:[Rn(t,r,n,!1)],...Pn(n)?[Rn(t,r,n,!0)]:[]]});if(i.length===0)throw Error(`Cursor catalog returned no fully described usable models`);let a=n.model;if(a!==void 0&&a.modelId!==``){let e=a.modelId;if(!new Set(t.models.map(({modelId:e})=>e)).has(e))throw Error(`Cursor default model '${e}' is not usable`);let n=kn(a).id;if(!i.some(({id:e})=>e===n||e===`${n}-max`))throw Error(`Cursor default model '${e}' has no complete catalog metadata`)}return i}async function Bn(e){if(e.token.includes(`\r`)||e.token.includes(`
|
|
7
|
+
`))throw Error(`Cursor credential contains a line break`);let t=(e.now??Date.now)(),n=En(e.backendUrl).origin,r=`${n}:${await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e.token)).then(e=>Buffer.from(e).toString(`hex`))}`;if(e.force!==!0&&B?.key===r&&B.expiresAt>t)return B.models;let[i,a,o]=await Promise.all([On(`AvailableModels`,{schema:xn,message:b(xn,{useModelParameters:!0,doNotUseMarkdown:!0})},Sn,e),On(`GetUsableModels`,{schema:vn,message:b(vn)},yn,e),On(`GetDefaultModelForCli`,{schema:gn,message:b(gn)},_n,e)]),s=zn(i,a,o,n);return B={key:r,expiresAt:t+6e5,models:s},s}const V=x(`ChthaXNlcnZlci92MS9pbmZlcmVuY2UucHJvdG8SC2Fpc2VydmVyLnYxIsQBChJJbmZlcmVuY2VBZ2VudFRvb2wSDAoEbmFtZRgBIAEoCRITCgtkZXNjcmlwdGlvbhgCIAEoCRIrCgpwYXJhbWV0ZXJzGAMgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdBJHChJjdXN0b21fdG9vbF9mb3JtYXQYBCABKAsyJi5haXNlcnZlci52MS5JbmZlcmVuY2VDdXN0b21Ub29sRm9ybWF0SACIAQFCFQoTX2N1c3RvbV90b29sX2Zvcm1hdCJtChlJbmZlcmVuY2VBbnRocm9waWNPcHRpb25zEj4KDWNhY2hlX2NvbnRyb2wYASABKAsyIi5haXNlcnZlci52MS5JbmZlcmVuY2VDYWNoZUNvbnRyb2xIAIgBAUIQCg5fY2FjaGVfY29udHJvbCIlChVJbmZlcmVuY2VDYWNoZUNvbnRyb2wSDAoEdHlwZRgBIAEoCSKwAQoUSW5mZXJlbmNlQ29udGVudFBhcnQSLgoEdGV4dBgBIAEoCzIeLmFpc2VydmVyLnYxLkluZmVyZW5j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(V,41),nr=S(V,46),rr=S(V,48),ir=S(V,50),ar=S(V,51),W={UNSPECIFIED:0,USER:1,ASSISTANT:2,TOOL:3,SYSTEM:4},or={UNSPECIFIED:0,UNKNOWN:1,INPUT_TOKEN_LIMIT:2,OUTPUT_TOKEN_LIMIT:3,RATE_LIMIT:4,AUTHENTICATION:5,PERMISSION:6,OVERLOADED:7,CONTENT_FILTER:8},sr={UNSPECIFIED:0,USER:1,ASSISTANT:2};function G(e,t){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<=0||t<=0)throw Error(`Cursor image has invalid dimensions`);return{width:e,height:t}}function cr(e){if(e===``||e.length%4!=0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u.test(e))throw Error(`Cursor image data is not valid base64`);let t=Buffer.from(e,`base64`);if(t.toString(`base64`)!==e)throw Error(`Cursor image data is not canonical base64`);return t}function lr(e){if(e.byteLength<24||!e.subarray(0,8).every((e,t)=>e===[137,80,78,71,13,10,26,10][t]))throw Error(`Cursor image MIME type does not match PNG bytes`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return G(t.getUint32(16),t.getUint32(20))}function ur(e){let t=new TextDecoder().decode(e.subarray(0,6));if(e.byteLength<10||t!==`GIF87a`&&t!==`GIF89a`)throw Error(`Cursor image MIME type does not match GIF bytes`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength);return G(n.getUint16(6,!0),n.getUint16(8,!0))}function dr(e){if(e.byteLength<26||e[0]!==66||e[1]!==77)throw Error(`Cursor image MIME type does not match BMP bytes`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return G(t.getInt32(18,!0),Math.abs(t.getInt32(22,!0)))}function fr(e){if(e.byteLength<4||e[0]!==255||e[1]!==216)throw Error(`Cursor image MIME type does not match JPEG bytes`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=2;for(;n+3<e.byteLength;){if(e[n]!==255){n+=1;continue}for(;e[n]===255;)n+=1;let r=e[n];if(n+=1,r===void 0||r===217||r===218)break;if(r===1||r>=208&&r<=215)continue;if(n+2>e.byteLength)break;let i=t.getUint16(n);if(i<2||n+i>e.byteLength)break;if(r>=192&&r<=195||r>=197&&r<=199||r>=201&&r<=203||r>=205&&r<=207){if(i<7)break;return G(t.getUint16(n+5),t.getUint16(n+3))}n+=i}throw Error(`Cursor JPEG image has no decodable dimensions`)}function pr(e,t,n){return new TextDecoder().decode(e.subarray(t,t+n))}function K(e,t){let n=e[t];if(n===void 0)throw Error(`Cursor image data is truncated`);return n}function mr(e){if(e.byteLength<30||pr(e,0,4)!==`RIFF`||pr(e,8,4)!==`WEBP`)throw Error(`Cursor image MIME type does not match WebP bytes`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=pr(e,12,4);if(n===`VP8X`)return G(1+K(e,24)+(K(e,25)<<8)+(K(e,26)<<16),1+K(e,27)+(K(e,28)<<8)+(K(e,29)<<16));if(n===`VP8 `){if(e[23]!==157||e[24]!==1||e[25]!==42)throw Error(`Cursor WebP VP8 frame header is malformed`);return G(t.getUint16(26,!0)&16383,t.getUint16(28,!0)&16383)}if(n===`VP8L`){if(e[20]!==47)throw Error(`Cursor WebP lossless header is malformed`);let n=t.getUint32(21,!0);return G((n&16383)+1,(n>>>14&16383)+1)}throw Error(`Cursor WebP chunk '${n}' is unsupported`)}function hr(e,t){switch(e){case`image/png`:return lr(t);case`image/jpeg`:return fr(t);case`image/gif`:return ur(t);case`image/webp`:return mr(t);case`image/bmp`:return dr(t);default:throw Error(`Cursor image MIME type '${e}' is unsupported`)}}function gr(e){if(e.mimeType!==e.mimeType.trim()||e.mimeType!==e.mimeType.toLowerCase())throw Error(`Cursor image MIME type '${e.mimeType}' is malformed`);let t=cr(e.data);return hr(e.mimeType,t),e}function q(e){if(e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`){if(typeof e==`number`&&!Number.isFinite(e))throw Error(`Cursor inference JSON contains a non-finite number`);return e}if(Array.isArray(e))return e.map(e=>q(e));if(w(e))return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>[e,q(t)]));throw Error(`Cursor inference value is not JSON-serializable`)}function _r(e){if(!w(e))return;let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=q(r));return t}function vr(e,t){let n=_r(e);if(n===void 0)throw Error(`${t} must be a JSON object`);return n}const yr=/^(.*)-(none|minimal|low|medium|high|xhigh|extra-high|max)(-fast)?$/u,br=[`medium`,`high`,`low`,`minimal`,`xhigh`,`max`,`off`],xr={"auto-smart":{modelId:`auto-smart`,parameters:[{id:`optimize_for`,value:`balanced`}]},"composer-2.5":{modelId:`composer-2.5`,parameters:[{id:`fast`,value:`false`}]},"cursor-grok-4.6-high":{modelId:`grok-4.6`,parameters:[{id:`effort`,value:`high`},{id:`fast`,value:`false`}]},"claude-opus-5-thinking-high":{modelId:`claude-opus-5`,parameters:[{id:`thinking`,value:`true`},{id:`context`,value:`300k`},{id:`effort`,value:`high`},{id:`fast`,value:`false`}]},"gemini-3.7-flash-high":{modelId:`gemini-3.7-flash`,parameters:[{id:`effort`,value:`high`}]}};function Sr(e,t){let n=e.thinkingLevelMap;if(n===void 0)return e.id;if(t!==void 0&&t!==``){let e=Object.entries(n).find(([e])=>e===t)?.[1];if(typeof e==`string`&&e!==``)return e}for(let e of br){let t=n[e];if(typeof t==`string`&&t!==``)return t}return e.id}function Cr(e){return/^(gpt-|o[1-9](?:-|$)|codex-)/u.test(e)}function wr(e,t){if(t===void 0)return e;let n=e.filter(({id:e})=>e!==`context`);return[{id:`context`,value:t},...n]}function Tr(e,t){let n=Sr(e,t.reasoning),r=xr[n];if(r!==void 0)return{...r,maxMode:t.maxMode,parameters:wr(r.parameters,t.context)};let i=yr.exec(n),a=i?.[1],o=i?.[2],s=i?.[3]===`-fast`;return a===void 0||o===void 0||!Cr(a)?{modelId:n,maxMode:t.maxMode,parameters:[]}:{modelId:`${a}${s?`-fast`:``}`,maxMode:t.maxMode,parameters:[{id:`context`,value:t.context??`272k`},{id:`reasoning`,value:o},{id:`fast`,value:String(s)}]}}function Er(e){return gr(e),b(Hn,{part:{case:`image`,value:b(Wn,{data:e.data,mimeType:e.mimeType})}})}function Dr(e){return b(Hn,{part:{case:`text`,value:b(Xn,{text:e})}})}function Or(e){return typeof e==`string`?{case:`text`,value:e}:e.every(e=>e.type===`text`)?{case:`text`,value:e.map(e=>e.text).join(``)}:{case:`parts`,value:b(Un,{parts:e.map(e=>e.type===`text`?Dr(e.text):Er(e))})}}function kr(e){let t=e.content.flatMap(e=>e.type===`text`?[e.text]:[]);return t.length===1?t[0]??``:t.map(e=>q({type:`text`,text:e}))}function Ar(e){return e.content.some(e=>e.type===`image`)?e.content.map(e=>e.type===`text`?Dr(e.text):Er(e)):[]}function jr(e){if(e.role===`user`)return b(H,{role:W.USER,content:Or(e.content)});if(e.role===`assistant`){let t=[],n=[],r=[];for(let i of e.content)if(i.type===`text`)t.push(i.text);else if(i.type===`thinking`)n.push(b(qn,T({isRedacted:i.redacted===!0,text:i.thinking,signature:i.redacted===!0?void 0:i.thinkingSignature,redactedData:i.redacted===!0?i.thinkingSignature:void 0,modelName:e.provider===`cursor`?e.responseModel:void 0})));else{let e=vr(i.arguments,`Cursor inference tool '${i.name}' arguments`);r.push(b(Zn,{toolCallId:i.id,toolName:i.name,args:e,rawToolCallArgs:JSON.stringify(e)}))}return b(H,T({role:W.ASSISTANT,content:t.length===0?void 0:{case:`text`,value:t.join(``)},reasoningParts:n,toolCalls:r,modelProviderMessageId:e.responseId}))}return b(H,{role:W.TOOL,content:{case:`toolContent`,value:b(Qn,{parts:[b($n,{toolCallId:e.toolCallId,toolName:e.toolName,result:oe(be,kr(e)),isError:e.isError,experimentalContent:Ar(e)})]})}})}function Mr(e){let t=vr(e.parameters,`Cursor inference tool '${e.name}' schema`);return b(Vn,{name:e.name,description:e.description,parameters:{jsonSchema:t}})}function Nr(e,t={}){let n=e.messages.map(jr);e.systemPrompt!==void 0&&e.systemPrompt!==``&&n.unshift(b(H,{role:W.SYSTEM,content:{case:`text`,value:e.systemPrompt}}));let r=t.maxTokens===void 0&&t.temperature===void 0&&t.topP===void 0&&t.stopSequences===void 0?void 0:b(Gn,T({maxTokens:t.maxTokens,temperature:t.temperature,topP:t.topP,stopSequences:t.stopSequences===void 0?void 0:[...t.stopSequences]}));return b(Yn,T({messages:n,tools:e.tools?.map(Mr)??[],modelConfig:r}))}function Pr(e){return e.role===`user`?typeof e.content==`string`?e.content:e.content.flatMap(e=>e.type===`text`?[e.text]:[]).join(``):e.role===`assistant`?e.content.flatMap(e=>e.type===`text`?[e.text]:[]).join(``):``}function Fr(e){return e.messages.flatMap(e=>{if(e.role===`toolResult`)return[];let t=Pr(e);return t===``?[]:[b(rr,{role:e.role===`user`?sr.USER:sr.ASSISTANT,text:t})]})}function Ir(e,t,n=!1,r){let i=Tr(e,T({maxMode:n,reasoning:t,context:r}));return b(Jn,{modelId:i.modelId,maxMode:i.maxMode,parameters:i.parameters.map(e=>b(Kn,e))})}function Lr(e,t,n=!1,r){let i=Ir(e,t,n,r);return JSON.stringify({modelId:i.modelId,maxMode:i.maxMode,parameters:i.parameters.map(({id:e,value:t})=>({id:e,value:t}))})}function Rr(e,t,n,r,i=!1,a){if(n===``)throw Error(`Cursor managed inference requires a stable Pi session id`);return b(ir,{conversationId:n,requestedModel:Ir(e,r,i,a),routingConversation:Fr(t),agentMode:`agent`})}function zr(e){return e.filter(e=>e.type===`text`)}function Br(e){return e.filter(e=>e.type===`thinking`)}function Vr(e){return e.filter(e=>e.type===`toolCall`)}function Hr(e){return e.map(({text:e})=>e).join(``)}function Ur(e){return e.map(({thinking:e})=>e).join(``)}function J(e){return e.thinkingSignature===void 0||e.thinkingSignature===``?void 0:e.thinkingSignature}function Y(e){return J(e)!==void 0||e.redacted===!0}function Wr(e,t){return{...e,...T({thinkingSignature:J(t)??J(e),redacted:t.redacted===!0||e.redacted===!0||void 0})}}function Gr(e){return{type:`thinking`,thinking:``,...T({thinkingSignature:J(e),redacted:e.redacted===!0||void 0})}}function Kr(e,t){return J(e)===J(t)&&e.redacted===t.redacted}function qr(e,t){if(!Y(t))return!1;let n=Gr(t);return!e.some(e=>Kr(e,n))&&(e.push(n),!0)}function Jr(e,t){if(t.some(({thinking:e})=>e.trim()!==``)){let n=t.map(e=>({...e})),r=0,i=0;for(let t of e.filter(Y)){let e=J(t),a=e===void 0?-1:n.findIndex(t=>J(t)===e);if(a<0&&t.thinking.trim()!==``&&(a=n.findIndex(e=>e.thinking===t.thinking)),a>=0){let e=n[a];e!==void 0&&(n[a]=Wr(e,t)),r+=1}else qr(n,t)&&(i+=1)}return{blocks:n,source:`final`,mergedMetadata:r,unmatchedMetadata:i}}let n=e.map(e=>({...e})),r=[],i=0;for(let e of t.filter(Y)){let t=J(e),a=t===void 0?-1:n.findIndex(e=>J(e)===t);if(a>=0){let t=n[a];t!==void 0&&(n[a]=Wr(t,e)),i+=1}else r.push(e)}let a=n.map((e,t)=>({block:e,index:t})).filter(({block:e})=>e.thinking.trim()!==``&&!Y(e));if(r.length===1&&a.length===1){let e=a[0],t=r[0];e!==void 0&&t!==void 0&&(n[e.index]=Wr(e.block,t),i+=1,r.length=0)}let o=0;for(let e of r)qr(n,e)&&(o+=1);return{blocks:n,source:n.some(({thinking:e})=>e.trim()!==``)?`stream`:n.length>0?`opaque-final`:`none`,mergedMetadata:i,unmatchedMetadata:o}}function X(e,t){let n=new Map;for(let r of e){if(n.has(r.id))throw Error(`Cursor ${t} response duplicated tool '${r.id}'`);n.set(r.id,r)}return n}function Yr(e,t){let n=X(e,`streamed`),r=X(t,`final`);if(n.size!==r.size)throw Error(`Cursor final response tool set does not match completed streamed tools`);for(let[e,t]of n){let n=r.get(e);if(n===void 0)throw Error(`Cursor final response tool set does not match completed streamed tools`);if(t.name!==n.name)throw Error(`Cursor final response changed the name of tool '${e}'`);if(!Se(t.arguments,n.arguments))throw Error(`Cursor final response changed the arguments of tool '${e}'`)}}function Xr(e,t,n={}){let r=n.strict??!0,i=zr(e),a=t===void 0?[]:zr(t),o=Br(e),s=t===void 0?[]:Br(t),c=Vr(e),l=t===void 0?[]:Vr(t);r&&t!==void 0&&c.length>0?Yr(c,l):(X(c,`streamed`),X(l,`final`));let u=a.length>0?`final`:i.length>0?`stream`:`none`,d=a.length>0?a:i,f=l.length>0?l:c,p=Jr(o,s),m=a.length>0||l.length>0?t?.filter(e=>e.type!==`thinking`)??[]:e.filter(e=>e.type!==`thinking`),h=t===void 0?e:a.length===0&&l.length>0&&i.length>0?[...p.blocks,...d,...f]:[...p.blocks,...m],g=Hr(i),_=Hr(a),v=Ur(o),y=Ur(s),ee=c.length>0&&l.length>0?r?`exact`:`unchecked`:c.length>0?`stream-only`:l.length>0?`final-only`:`none`;return{content:h,summary:{responseInfo:t!==void 0,strict:r,text:{streamedBlocks:i.length,finalBlocks:a.length,streamedCharacters:g.length,finalCharacters:_.length,exact:i.length>0&&a.length>0?g===_:null,source:u},reasoning:{streamedBlocks:o.length,finalBlocks:s.length,streamedCharacters:v.length,finalCharacters:y.length,exact:o.some(({thinking:e})=>e.trim()!==``)&&s.some(({thinking:e})=>e.trim()!==``)?v===y:null,source:p.source,mergedMetadata:p.mergedMetadata,unmatchedMetadata:p.unmatchedMetadata},tools:{streamed:c.length,final:l.length,status:ee}}}}function Zr(e,t){if(e===``)return t?{}:void 0;let n;try{n=t?JSON.parse(e):Ee(e)}catch{return}if(typeof n==`object`&&n&&!Array.isArray(n))return Object.fromEntries(Object.entries(n))}function Qr(e){if(e.args!==void 0)return Object.fromEntries(Object.entries(e.args));if(e.rawToolCallArgs===void 0||e.rawToolCallArgs===``)return{};let t;try{t=JSON.parse(e.rawToolCallArgs)}catch(t){throw Error(`Cursor final tool call '${e.toolCallId}' has invalid raw arguments`,{cause:t})}if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`Cursor final tool call '${e.toolCallId}' arguments are not an object`);return Object.fromEntries(Object.entries(t))}function $r(e){return{tokenLogprobs:e.tokenLogprobs.map(({values:e})=>e),tokenIds:e.tokenIds.map(({values:e})=>e.map(Number)),promptTokenIds:e.promptTokenIds.map(({values:e})=>e.map(Number)),extraTokens:e.extraTokens.map(({values:e})=>e.map(Number)),extraLogprobs:e.extraLogprobs.map(({values:e})=>e),routingMatrix:e.routingMatrix.map(({values:e})=>e.map(e=>e===``?null:e))}}function ei(e){return T({messageIndex:e.messageIndex,partIndex:e.partIndex,expContentIndex:e.expContentIndex,description:e.description})}function ti(e){return v(e).with(W.USER,()=>`user`).with(W.ASSISTANT,()=>`assistant`).with(W.TOOL,()=>`tool`).with(W.SYSTEM,()=>`system`).with(W.UNSPECIFIED,()=>`unspecified`).otherwise(e=>`unknown-${String(e)}`)}function ni(e){let t=e.message===``?e.code||`Cursor inference failed`:e.message;return e.isInputTokenLimitError||e.errorType===or.INPUT_TOKEN_LIMIT?`context_length_exceeded: ${t}`:t}var ri=class{#e;#t;#n;#r;#i;#a;#o;#s=new Map;#c=new Set;#l=new Map;#u;#d;#f;#p=[];#m;constructor(e,t,n,r,i){this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#i=i}handle(e){if(e.message.case!==`invocationResponse`)throw Error(`Cursor mapper received outer arm '${e.message.case??`<unset>`}'`);let t=e.message.value.response;if(t===void 0)throw Error(`Cursor invocation response has no payload`);this.#h(t)}#h(e){let t=e.response.case;this.#l.set(t,(this.#l.get(t)??0)+1),v(e.response).with({case:`thinkingPart`},({value:e})=>{e.text!==``&&this.#_(e.text,e.signature),e.isFinal&&this.#S()}).with({case:`textPart`},({value:e})=>{e.text!==``&&this.#v(e.text),e.isFinal&&this.#x()}).with({case:`toolCallPart`},({value:e})=>this.#y(e)).with({case:`extendedUsage`},({value:e})=>{this.#t.usage.input=e.inputTokens,this.#t.usage.output=e.outputTokens,this.#t.usage.cacheRead=e.cacheReadTokens,this.#t.usage.cacheWrite=e.cacheWriteTokens,this.#b()}).with({case:`usage`},({value:e})=>{this.#l.has(`extendedUsage`)||(this.#t.usage.input=e.promptTokens,this.#t.usage.output=e.completionTokens,this.#t.usage.cacheRead=0,this.#t.usage.cacheWrite=0,this.#b())}).with({case:`responseInfo`},({value:e})=>{e.errorMessage!==void 0&&e.errorMessage!==``&&(this.#u={message:e.errorMessage,outputLimit:!1}),e.id!==``&&(this.#t.responseId=e.id),e.model!==``&&(this.#t.responseModel=e.model);let t=Number(e.createdAt);Number.isSafeInteger(t)&&t>0&&(this.#t.timestamp=t),this.#g(e)}).with({case:`error`},({value:e})=>{this.#u={message:ni(e),outputLimit:e.isOutputTokenLimitError||e.errorType===or.OUTPUT_TOKEN_LIMIT}}).with({case:`invocationId`},({value:e})=>{if(e.invocationId!==this.#r)throw Error(`Cursor nested invocation identity does not match its outer envelope`)}).with({case:`providerMetadata`},({value:e})=>{this.#f=e.metadata}).with({case:`imageDescriptions`},({value:e})=>{this.#p.push(...e.descriptions.map(ei))}).with({case:void 0},()=>{throw Error(`Cursor inference response has no arm`)}).exhaustive()}#g(e){let t=[],n={};for(let r of e.messages){let e=ti(r.role);if(n[e]=(n[e]??0)+1,r.role!==W.TOOL){for(let e of r.reasoningParts){let n=e.isRedacted?e.redactedData:e.signature;t.push(T({type:`thinking`,thinking:e.text,thinkingSignature:n,redacted:e.isRedacted?!0:void 0}))}r.content!==void 0&&r.content.trim()!==``&&t.push({type:`text`,text:r.content});for(let e of r.toolCalls){if(e.toolCallId===``||e.toolName===``)throw Error(`Cursor final response contains an unnamed tool call`);if(!this.#n.has(e.toolName))throw Error(`Cursor final response called unadvertised tool '${e.toolName}'`);t.push({type:`toolCall`,id:e.toolCallId,name:e.toolName,arguments:Qr(e)})}}}this.#d=t,this.#m=T({createdAt:e.createdAt.toString(),supportsSelfSummary:e.supportsSelfSummary,roleCounts:n,inferenceExtraData:e.inferenceExtraData===void 0?void 0:$r(e.inferenceExtraData)})}#_(e,t){if(this.#x(),this.#o===void 0){let e={type:`thinking`,thinking:``,...T({thinkingSignature:t})};this.#t.content.push(e),this.#o={index:this.#t.content.length-1,block:e},this.#e.push({type:`thinking_start`,contentIndex:this.#o.index,partial:this.#t})}else if(t!==void 0&&this.#o.block.thinkingSignature!==void 0&&this.#o.block.thinkingSignature!==t)throw Error(`Cursor thinking signature changed within one block`);else t!==void 0&&(this.#o.block.thinkingSignature=t);this.#o.block.thinking+=e,this.#e.push({type:`thinking_delta`,contentIndex:this.#o.index,delta:e,partial:this.#t})}#v(e){if(this.#S(),this.#a===void 0){let e={type:`text`,text:``};this.#t.content.push(e),this.#a={index:this.#t.content.length-1,block:e},this.#e.push({type:`text_start`,contentIndex:this.#a.index,partial:this.#t})}this.#a.block.text+=e,this.#e.push({type:`text_delta`,contentIndex:this.#a.index,delta:e,partial:this.#t})}#y(e){if(e.toolCallId===``)throw Error(`Cursor tool call has no id`);if(this.#c.has(e.toolCallId))throw Error(`Cursor tool call '${e.toolCallId}' continued after completion`);let t=this.#s.get(e.toolCallId);if(t===void 0){if(e.toolName===``)throw Error(`Cursor tool call starts without a name`);if(!this.#n.has(e.toolName))throw Error(`Cursor called unadvertised tool '${e.toolName}'`);this.#x(),this.#S();let n={type:`toolCall`,id:e.toolCallId,name:e.toolName,arguments:{}};this.#t.content.push(n),t={index:this.#t.content.length-1,block:n,name:e.toolName,json:``,complete:!1,toolIndex:e.toolIndex},this.#s.set(e.toolCallId,t),this.#e.push({type:`toolcall_start`,contentIndex:t.index,partial:this.#t})}if(e.toolName!==``&&e.toolName!==t.name)throw Error(`Cursor tool call '${e.toolCallId}' changed name`);if(!e.isComplete){if(e.args===``)return;t.json+=e.args;let n=Zr(t.json,!1);n!==void 0&&(t.block.arguments=n),this.#e.push({type:`toolcall_delta`,contentIndex:t.index,delta:e.args,partial:this.#t});return}let n=Zr(e.args,!0);if(n===void 0)throw Error(`Cursor tool call '${e.toolCallId}' completed with invalid JSON arguments`);let r=Zr(t.json,!0);if(t.json!==``&&(r===void 0||!Se(r,n)))throw Error(`Cursor tool call '${e.toolCallId}' argument stream does not match completion`);t.block.arguments=n,t.complete=!0,this.#e.push({type:`toolcall_end`,contentIndex:t.index,toolCall:t.block,partial:this.#t}),this.#s.delete(e.toolCallId),this.#c.add(e.toolCallId)}#b(){this.#t.usage.totalTokens=this.#t.usage.input+this.#t.usage.output+this.#t.usage.cacheRead+this.#t.usage.cacheWrite}#x(){this.#a!==void 0&&(this.#e.push({type:`text_end`,contentIndex:this.#a.index,content:this.#a.block.text,partial:this.#t}),this.#a=void 0)}#S(){this.#o!==void 0&&(this.#e.push({type:`thinking_end`,contentIndex:this.#o.index,content:this.#o.block.thinking,partial:this.#t}),this.#o=void 0)}finish(){if(this.#x(),this.#S(),this.#s.size>0)throw Error(`Cursor invocation ended with incomplete tool calls`);let e=Xr(this.#t.content,this.#d,{strict:this.#i.strictReconciliation});this.#t.content.splice(0,this.#t.content.length,...e.content);let t=this.#t.content.filter(({type:e})=>e===`toolCall`);if(this.#i.strictReconciliation&&this.#c.size>0&&t.length===0)throw Error(`Cursor toolUse completed without a finalized tool call`);if(this.#i.diagnostics){let t={arms:Object.fromEntries(this.#l),reconciliation:e.summary};this.#f!==void 0&&(t.providerMetadata=this.#f),this.#p.length>0&&(t.imageDescriptions=this.#p),this.#m!==void 0&&(t.responseInfo=this.#m),this.#t.diagnostics=[...this.#t.diagnostics??[],{type:`cursor-inference-response`,timestamp:Date.now(),details:t}]}return this.#u===void 0?{stopReason:t.length>0?`toolUse`:`stop`}:this.#u.outputLimit&&this.#t.content.length>0?{stopReason:`length`}:{stopReason:`error`,errorMessage:this.#u.message}}};function ii(e){return{role:`assistant`,content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`pending`,timestamp:Date.now()}}function ai(e){return e instanceof Error?e.message:String(e)}function oi(e,t){let n=t?.samplingParams?.cursorMaxMode??e.samplingParams?.cursorMaxMode;return v(n).with(void 0,()=>!1).with(_.boolean,e=>e).otherwise(()=>{throw Error(`Cursor sampling parameter cursorMaxMode must be a boolean`)})}function si(e,t){let n=t?.samplingParams?.cursorContext??e.samplingParams?.cursorContext;return v(n).with(void 0,()=>void 0).with(_.string,e=>e).otherwise(()=>{throw Error(`Cursor sampling parameter cursorContext must be a string`)})}function ci(e,t){return v(e).with(void 0,()=>void 0).with(_.when(e=>typeof e==`number`&&Number.isFinite(e)),e=>e).otherwise(()=>{throw Error(`Cursor sampling parameter ${t} must be a finite number`)})}function li(e,t){return v(e).with(void 0,()=>void 0).with(_.array(_.string),e=>e).otherwise(()=>{throw Error(`Cursor sampling parameter ${t} must be an array of strings`)})}function ui(e,t,n,r){let i=we(),a=ii(e),o=n.settings??A();return(async()=>{try{if(i.push({type:`start`,partial:a}),r?.apiKey===void 0||r.apiKey===``)throw Error(`Cursor credential is unavailable`);let s=r.sessionId;if(s===void 0||s===``)throw Error(`Cursor managed inference requires SimpleStreamOptions.sessionId`);let c=(n.createInvocationId??(()=>crypto.randomUUID()))(),l=typeof r.reasoning==`string`?r.reasoning:void 0,u=oi(e,r),d=si(e,r),f=Nr(t,T({maxTokens:r.maxTokens,temperature:r.temperature,topP:ci(r.samplingParams?.topP,`topP`),stopSequences:li(r.samplingParams?.stopSequences,`stopSequences`)})),p=b(U,{message:{case:`runRequest`,value:Rr(e,t,s,l,u,d)}}),m=new ri(i,a,new Set(t.tools?.map(({name:e})=>e)??[]),c,o);await(typeof n.runtime==`function`?await n.runtime(r.apiKey):n.runtime).invoke(s,Lr(e,l,u,d),p,c,f,T({signal:r.signal,onResponse:e=>m.handle(e)}));let h=m.finish();if(a.stopReason=h.stopReason,h.errorMessage!==void 0&&(a.errorMessage=h.errorMessage),Ce(e,a.usage),a.stopReason===`error`)i.push({type:`error`,reason:`error`,error:a});else if(a.stopReason===`stop`||a.stopReason===`toolUse`||a.stopReason===`length`||a.stopReason===`deferred`)i.push({type:`done`,reason:a.stopReason,message:a});else throw Error(`Cursor mapper returned invalid terminal '${a.stopReason}'`);i.end()}catch(e){a.stopReason=r?.signal?.aborted===!0?`aborted`:`error`,a.errorMessage=ai(e),i.push({type:`error`,reason:a.stopReason,error:a}),i.end()}})(),i}function di(e,t=0){let n=new Uint8Array(5+e.length),r=new DataView(n.buffer);return r.setUint8(0,t),r.setUint32(1,e.length,!1),n.set(e,5),n}var fi=class{#e=new Uint8Array;#t=0;#n=0;get#r(){return this.#n-this.#t}#i(e){if(this.#n+e<=this.#e.length)return;let t=this.#r+e;if(t<=this.#e.length)this.#e.copyWithin(0,this.#t,this.#n);else{let e=Math.max(this.#e.length*2,65536);for(;e<t;)e*=2;let n=new Uint8Array(e);n.set(this.#e.subarray(this.#t,this.#n)),this.#e=n}this.#n=this.#r,this.#t=0}push(e){e.length>0&&(this.#i(e.length),this.#e.set(e,this.#n),this.#n+=e.length);let t=[];for(;!(this.#r<5);){let e=new DataView(this.#e.buffer,this.#e.byteOffset+this.#t,5),n=e.getUint8(0),r=e.getUint32(1,!1);if(r>16777216)throw Error(`Connect frame length ${String(r)} exceeds the 16777216 byte cap`);if(this.#r<5+r)break;let i=this.#t+5,a=this.#e.slice(i,i+r);this.#t=i+r;let o=!!(n&1);t.push({body:o?ue(a,{maxOutputLength:16777216}):a,compressed:o,endOfStream:!!(n&2)})}return this.#t===this.#n&&(this.#t=0,this.#n=0),t}end(){if(this.#r>0)throw Error(`Connect stream ended mid-frame with ${String(this.#r)} trailing bytes`)}get pending(){return this.#r}};const pi=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;function Z(e,t){if(t.includes(`\r`)||t.includes(`
|
|
8
|
+
`))throw Error(`${e} contains a line break`)}function mi(e,t=Date.now()){let n=Math.floor(t/1e6),r=new Uint8Array([n>>40&255,n>>32&255,n>>24&255,n>>16&255,n>>8&255,n&255]),i=165;for(let e=0;e<r.length;e+=1){let t=r[e];if(t===void 0)throw Error(`Cursor checksum input is incomplete`);r[e]=(t^i)+e%256&255,i=r[e]??i}let a=Oe.from(r).toString(`base64`);return e.macMachineId===void 0?`${a}${e.machineId}`:`${a}${e.machineId}/${e.macMachineId}`}function hi(t){Z(`Cursor credential`,t.token),Z(`Cursor request id`,t.requestId),Z(`Cursor client key`,t.clientKey);let r=t.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone;if(Z(`Cursor timezone`,r),!/^[0-9a-f]{64}$/u.test(t.clientKey))throw Error(`Cursor client key must be 32-byte lowercase hex`);if(!pi.test(t.requestId))throw Error(`Cursor request id must be a UUID`);return{":method":`POST`,":path":`/aiserver.v1.InferenceService/RunInference`,authorization:`Bearer ${t.token}`,cookie:`CursorCookie=Cookie-${t.token.slice(0,15)}`,"connect-accept-encoding":`gzip`,"connect-content-encoding":`gzip`,"connect-protocol-version":`1`,"content-type":`application/connect+proto`,"user-agent":`connect-es/1.6.1`,"x-amzn-trace-id":`Root=${t.requestId}`,"x-client-key":t.clientKey,"x-cursor-checksum":mi(t.identity,t.nowMs),"x-cursor-client-arch":t.arch??e,"x-cursor-client-commit":`2ba48ff3f7514cc4643c52ca9f7b3173d9b66130`,"x-cursor-client-device-type":`desktop`,"x-cursor-client-os":t.platform??n,"x-cursor-client-type":`ide`,"x-cursor-client-version":`3.18.9`,"x-cursor-streaming":`true`,"x-cursor-timezone":r,"x-ghost-mode":String(t.ghostMode),"x-new-onboarding-completed":`false`,"x-request-id":t.requestId}}const Q=2e3;function gi(e){return Buffer.from(crypto.getRandomValues(new Uint8Array(e))).toString(`hex`)}function _i(e){let t;try{t=new URL(e)}catch(e){throw Error(`Cursor backend authority is invalid`,{cause:e})}if(t.protocol!==`https:`||t.username!==``||t.password!==``||t.pathname!==``&&t.pathname!==`/`||t.search!==``||t.hash!==``)throw Error(`Cursor backend authority must be an HTTPS origin`);return new URL(t.origin)}function vi(e){let t=se(U,e);if(t.byteLength>16777216)throw Error(`Cursor RunInference client message exceeds the Connect frame limit`);return t.byteLength<1024?di(t):di(de(t),1)}function yi(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch(e){throw Error(`Cursor returned an invalid Connect end-of-stream trailer`,{cause:e})}if(!w(t))throw Error(`Cursor returned an invalid Connect end-of-stream trailer`);if(t.error===void 0)return{};if(!w(t.error)||typeof t.error.code!=`string`)throw Error(`Cursor returned an invalid Connect error trailer`);let n=t.error.code.trim(),r=t.error.message;if(n===``||r!==void 0&&typeof r!=`string`)throw Error(`Cursor returned an invalid Connect error trailer`);return{error:T({code:n,message:r})}}function bi(e){return e.message.trim()===``?`Cursor invocation error ${String(e.code)}`:e.message}function xi(e,t,n){return new Promise((r,i)=>{let a=setTimeout(()=>i(Error(`${n} timed out`)),t);e.then(e=>(clearTimeout(a),r(e)),e=>(clearTimeout(a),i(e)))})}var Si=class{routeKey;ready;completion;#e;#t=new Map;#n=new Set;#r;#i;#a;#o;#s;#c=Promise.resolve();#l=Promise.resolve();#u=0;#d=0;#f;#p;#m;#h=new Set;constructor(e,t,n,r){this.routeKey=t,this.#r=r.responseTimeoutMs??65e3;let i,a;this.ready=new Promise((e,t)=>{i=e,a=t}),this.ready.catch(()=>void 0),this.#i=i,this.#a=a;let o,s;this.completion=new Promise((e,t)=>{o=e,s=t}),this.completion.catch(()=>void 0),this.#o=o,this.#s=s,this.#e=e.request(n),this.#g()}#g(){let e=new fi,t=0;this.#e.on(`response`,e=>{if(t=Number(e[`:status`]??0),t!==200){this.#v(Error(`Cursor RunInference returned HTTP ${String(t)}`));return}(e[`content-type`]??``).startsWith(`application/connect+proto`)||this.#v(Error(`Cursor RunInference returned an invalid content type`))}),this.#e.on(`data`,t=>{try{for(let n of e.push(t)){if(this.#p!==void 0)throw Error(`Cursor sent data after the Connect trailer`);if(n.endOfStream){if(this.#p=yi(n.body),this.#p.error!==void 0)throw Error(`Cursor RunInference failed: ${this.#p.error.code}${this.#p.error.message===void 0?``:` — ${this.#p.error.message}`}`);continue}let e=ae(ar,n.body);if(this.#u+=1,this.#d+=n.body.byteLength,this.#u>512||this.#d>8388608)throw Error(`Cursor RunInference response delivery exceeded its bound`);this.#l=this.#l.then(async()=>{try{await this.#_(e);return}finally{--this.#u,this.#d-=n.body.byteLength}}),this.#l.catch(e=>{this.#v(e)})}}catch(e){this.#v(e)}}),this.#e.on(`error`,e=>this.#v(e)),this.#e.on(`aborted`,()=>this.#v(Error(`Cursor RunInference stream aborted`))),this.#e.on(`end`,()=>{try{e.end()}catch(e){this.#v(e);return}this.#l.then(()=>{if(this.#m===void 0&&t===200){if(this.#p===void 0){this.#v(Error(`Cursor RunInference ended without a Connect trailer`));return}if(this.#t.size>0){this.#v(Error(`Cursor RunInference ended with pending invocations`));return}this.#o({trailer:this.#p})}})})}async#_(e){switch(e.message.case){case`heartbeat`:return;case`runReady`:if(this.#f!==void 0)throw Error(`Cursor sent duplicate runReady`);if(e.message.value.resolvedModel===void 0||e.message.value.resolvedModel.modelId===``)throw Error(`Cursor runReady has no resolved model`);this.#f=e.message.value,this.#i(e.message.value);return;case`invocationResponse`:{let{invocationId:t}=e.message.value;if(this.#n.has(t))return;let n=this.#t.get(t);if(n===void 0)throw Error(`Cursor response has unknown invocation '${t}'`);n.delivery=n.delivery.then(async()=>await n.onResponse(e)),await n.delivery;return}case`invocationEnd`:{let t=e.message.value;if(this.#n.delete(t.invocationId))return;let n=this.#t.get(t.invocationId);if(n===void 0)throw Error(`Cursor ended unknown invocation '${t.invocationId}'`);this.#t.delete(t.invocationId),n.signal?.removeEventListener(`abort`,n.abort),await n.delivery,t.error===void 0?n.resolve({invocationId:t.invocationId,end:t}):n.reject(Error(`Cursor invocation failed: ${bi(t.error)}`));return}case void 0:throw Error(`Cursor RunInference server message has no arm`)}}#v(e){if(this.#m===void 0){this.#m=e,this.#a(e);for(let t of this.#t.values())t.signal?.removeEventListener(`abort`,t.abort),t.reject(e);this.#t.clear(),this.#s(e),this.#e.destroy(e instanceof Error?e:Error(String(e)))}}async send(e){if(this.#m!==void 0)throw this.#m;let t=vi(e);this.#c=this.#c.then(async()=>await new Promise((e,n)=>{this.#e.write(t,t=>{t==null?e():n(t)})})),await this.#c}async waitUntilReady(){return await xi(this.ready,this.#r,`Cursor runReady`)}abort(e){this.#v(e)}async invoke(e,t,n){if(this.#h.has(`finishing`))throw Error(`Cursor RunInference run is finishing`);if(await this.waitUntilReady(),this.#t.size>=64)throw Error(`Cursor RunInference has too many pending invocations`);if(this.#t.has(e)||this.#n.has(e))throw Error(`Cursor invocation '${e}' already exists`);let r,i,a=new Promise((e,t)=>{r=e,i=t}),o=()=>{this.#t.get(e)!==void 0&&(this.#t.delete(e),this.#n.add(e),this.send(b(U,{message:{case:`cancelInvocation`,value:b(er,{invocationId:e})}})).then(()=>i(new DOMException(`Aborted`,`AbortError`)),e=>{i(e),this.#v(e)}))};if(this.#t.set(e,{onResponse:n.onResponse,resolve:r,reject:i,signal:n.signal,abort:o,delivery:Promise.resolve()}),n.signal?.aborted===!0?o():n.signal?.addEventListener(`abort`,o,{once:!0}),this.#n.has(e))return await a;try{await this.send(b(U,{message:{case:`invokeModel`,value:b(nr,{invocationId:e,request:t})}}))}catch(t){this.#t.delete(e),n.signal?.removeEventListener(`abort`,o),i(t)}return await a}async finish(e){if(this.#h.has(`finishing`)){await xi(this.completion,e,`Cursor RunInference shutdown`);return}this.#h.add(`finishing`);for(let[e,t]of this.#t)this.#t.delete(e),this.#n.add(e),t.signal?.removeEventListener(`abort`,t.abort),t.reject(Error(`Cursor RunInference closed before invocation completed`)),await this.send(b(U,{message:{case:`cancelInvocation`,value:b(er,{invocationId:e})}}));await this.send(b(U,{message:{case:`finishRun`,value:b(tr)}})),this.#e.end(),await xi(this.completion,e,`Cursor RunInference shutdown`)}},Ci=class{#e;#t;#n;#r=new Map;#i=new Map;#a;#o;#s=new Set;constructor(e){if(this.#t=_i(e.backendUrl),this.#e=e,this.#n=(e.createClientKey??(()=>gi(32)))(),!/^[0-9a-f]{64}$/u.test(this.#n))throw Error(`Cursor client key must be 32-byte lowercase hex`)}async#c(){if(this.#s.has(`closed`))throw Error(`Cursor managed-inference runtime is shut down`);return this.#a!==void 0&&!this.#a.destroyed&&!this.#a.closed?this.#a:(this.#o??=Promise.resolve((this.#e.connect??(e=>De(e)))(this.#t.origin)).catch(e=>{throw this.#o=void 0,e}).then(e=>(this.#a=e,this.#o=void 0,e.once(`goaway`,()=>{this.#a===e&&(this.#a=void 0)}),e.on(`error`,()=>{this.#a===e&&(this.#a=void 0)}),e.once(`close`,()=>{this.#a===e&&(this.#a=void 0)}),e)),await this.#o)}async#l(e,t){let n=(this.#e.createRequestId??(()=>crypto.randomUUID()))(),r=hi({token:this.#e.token,ghostMode:this.#e.ghostMode,identity:this.#e.identity,requestId:n,clientKey:this.#n,nowMs:(this.#e.now??Date.now)(),timezone:(this.#e.timezone??(()=>Intl.DateTimeFormat().resolvedOptions().timeZone))()}),i=new Si(await this.#c(),e,r,this.#e);try{return await i.send(t),await i.waitUntilReady(),i}catch(e){throw i.abort(e),e}}async runFor(e,t,n){if(e===``)throw Error(`Cursor managed inference requires a stable Pi session id`);let r=this.#i.get(e)??Promise.resolve(),i,a=new Promise(e=>{i=e}),o=r.then(async()=>await a);this.#i.set(e,o),await r;try{let r=this.#r.get(e);if(r?.routeKey===t)return r.run;r!==void 0&&(this.#r.delete(e),await r.run.finish(this.#e.shutdownTimeoutMs??Q));let i=await this.#l(t,n);this.#r.set(e,{routeKey:t,run:i});let a=()=>{this.#r.get(e)?.run===i&&this.#r.delete(e)};return i.completion.then(a,a),i}finally{i(),this.#i.get(e)===o&&this.#i.delete(e)}}async invoke(e,t,n,r,i,a){return await(await this.runFor(e,t,n)).invoke(r,i,a)}async finishSession(e){let t=this.#r.get(e);t!==void 0&&(this.#r.delete(e),await t.run.finish(this.#e.shutdownTimeoutMs??Q))}async shutdown(){if(this.#s.has(`closed`))return;this.#s.add(`closed`);let e=[...this.#r.values()];this.#r.clear(),await Promise.allSettled(e.map(async({run:e})=>await e.finish(this.#e.shutdownTimeoutMs??Q))),this.#a?.destroy(),this.#a=void 0}};const wi=`https://api2.cursor.sh`,$=`PI_CURSOR_TOKEN`;function Ti(e){return e?.type===`oauth`?e.access:e?.type===`api_key`?e.key:process.env[$]}function Ei(e){return C(`sha256`).update(e,`utf8`).digest(`hex`)}const Di={discoverModels:Bn};function Oi(e,t=Di){let n,r=[],i=async t=>{let r=Ei(t);if(n?.digest===r)return n.runtime;await n?.runtime.shutdown();let i=new Ci({backendUrl:wi,token:t,ghostMode:!1,identity:e});return n={digest:r,runtime:i},i},a=(e,t,n)=>ui(e,t,{runtime:i},n),o=async e=>{if(!e.allowNetwork||e.signal.aborted)return;let n=Ti(e.credential);if(n===void 0||n===``)throw Error(`Cursor credential is unavailable`);try{let i=await t.discoverModels({backendUrl:wi,token:n,signal:e.signal,...e.force===void 0?{}:{force:e.force}});if(e.signal.aborted)return;await e.publish({persist:{models:i,checkedAt:Date.now()},update:()=>{r=i}})}catch(t){throw e.signal.aborted||await e.publish({persist:null,update:()=>{r=[]}}),t}};return{provider:{...Te({id:`cursor`,name:`Cursor`,baseUrl:wi,auth:{apiKey:{name:$,check:async({ctx:e,signal:t})=>(t.throwIfAborted(),await e.env($)===void 0?void 0:{type:`api_key`,source:$}),resolve:async({ctx:e,credential:t,signal:n})=>{n.throwIfAborted();let r=t?.key??await e.env($);return r===void 0||r===``?void 0:{auth:{apiKey:r},source:$}}},oauth:hn()},models:[],api:{stream:a,streamSimple:a}}),getModels:()=>r,refreshModels:o},shutdown:async()=>{await n?.runtime.shutdown(),n=void 0}}}async function ki(e){let t=He(),n=await nn(a()),r=Oi(n);e.registerProvider(r.provider),Ut(e),(n.machineIdSource===`fallback`||t.warning!==void 0)&&e.on(`session_start`,(e,r)=>{n.machineIdSource===`fallback`&&r.ui.notify(`Cursor could not derive the host machine id; using a persisted fallback identity.`,`warning`),t.warning!==void 0&&r.ui.notify(t.warning,`warning`)}),e.on(`session_shutdown`,async()=>{await r.shutdown()})}export{ki as default};
|
package/docs/brand.md
CHANGED
|
@@ -15,7 +15,10 @@ isometric geometry, and it must stay that way.
|
|
|
15
15
|
| [`mark-dark.svg`](mark-dark.svg) | Same geometry, graphite field. |
|
|
16
16
|
| [`banner.svg`](banner.svg) | README header, 1200×240. |
|
|
17
17
|
| [`banner-dark.svg`](banner-dark.svg) | Same, graphite field. |
|
|
18
|
-
|
|
|
18
|
+
| `gallery.svg` | pi.dev package card, 3840×2160 on a 1200×675 design grid. Repository-only: it is **not** in the package `files` whitelist, so do not link to it from a packaged file — see [Gallery](#gallery). |
|
|
19
|
+
| [`gallery.png`](gallery.png) | The shipped card image, rendered 1:1 from `gallery.svg`. |
|
|
20
|
+
| `social-preview.svg` | GitHub repository social preview, 3840×1920 on a 1280×640 design grid. Repository-only: it is not in the package `files` whitelist. |
|
|
21
|
+
| `social-preview.png` | The uploaded 2:1 image, rendered from `social-preview.svg`. Repository-only. |
|
|
19
22
|
|
|
20
23
|
Pair the two fields with `<picture>` and `prefers-color-scheme`. **Never recolour a single file at
|
|
21
24
|
the call site**, and never scale the mark to supply padding — see [Construction](#construction).
|
|
@@ -191,6 +194,155 @@ Tracking is applied as extra advance **after** each glyph, so the pen origin is
|
|
|
191
194
|
first glyph's advance, not of its ink. The ink starts one left-side-bearing further right, which is
|
|
192
195
|
why the wordmark's first path coordinate is not 210.
|
|
193
196
|
|
|
197
|
+
## Gallery
|
|
198
|
+
|
|
199
|
+
pi.dev renders package media in a **232×129.625** box with `object-fit: cover`, so the source must be
|
|
200
|
+
exactly 16:9 or the card crops it. `gallery.svg` and `gallery.png` are **3840×2160 (4K)**, with the
|
|
201
|
+
SVG retaining a `0 0 1200 675` design grid so the construction coordinates below stay readable.
|
|
202
|
+
Resolution is not the layout contract: 16:9 is. Never reduce the raster below 4K. The bordered card's
|
|
203
|
+
inner image box still trims about **2.26 design-grid units off the top and bottom**, so nothing may
|
|
204
|
+
sit at the vertical edges.
|
|
205
|
+
|
|
206
|
+
The card is **full bleed and opaque**: no outer corner radius, no inset hairline, no transparent
|
|
207
|
+
pixel. A radius here doubles against the card's own corners, a hairline loses its horizontal runs to
|
|
208
|
+
the trim and reads as a frame missing two sides, and transparent corners composite unpredictably
|
|
209
|
+
against a page field we do not control. There is one field only: pi.dev serves a single image URL, so
|
|
210
|
+
the gallery has no dark variant to pair.
|
|
211
|
+
|
|
212
|
+
This is not the banner cropped or rescaled. It is a centred vertical stack — mark tile, wordmark,
|
|
213
|
+
tagline, chip — sized for a thumbnail. The wordmark-to-tagline size ratio widens from the banner's
|
|
214
|
+
3.53 to **4.33** so the wordmark still reads at 232px wide while the tagline stays one exact line.
|
|
215
|
+
|
|
216
|
+
### Gallery geometry
|
|
217
|
+
|
|
218
|
+
| Element | Geometry |
|
|
219
|
+
|:--|:--|
|
|
220
|
+
| Field | `0,0 1200×675`, no radius, opaque `#ecedef` |
|
|
221
|
+
| Stack | centred on `x 600`; top `y 92`, bottom `y 582.24`; margins 92 top, 92.76 bottom |
|
|
222
|
+
| Mark tile | `496,92 208×208`, rx 39, **inverted field** |
|
|
223
|
+
| Mark placement | `X = 496 + 6.5u`, `Y = 92 + 6.5u` — the 32-unit mark at 6.5× |
|
|
224
|
+
| Wordmark | pen origin `x 339.48`, baseline 427.5; ink 343.64–856.36, pen end 854.28 |
|
|
225
|
+
| Tagline | pen origin `x 239.48`, baseline 483.1; ink 241.9–958.09, pen end 959.48 |
|
|
226
|
+
| Chip | `486.88,529.74 226.25×52.5`, rx 12.5; outline inset 0.94, stroke 1.88; right edge **713.13** |
|
|
227
|
+
| Chip glyph | `511.88,547.24 5×17.5`, magenta — one slab of the mark |
|
|
228
|
+
| Chip label | pen origin `x 531.88`, baseline 563.49; ends at 687.88, right pad 25.25 |
|
|
229
|
+
|
|
230
|
+
Three vertical gaps carry the grouping, measured **ink box to ink box**, not baseline to baseline:
|
|
231
|
+
tile bottom → wordmark ink top **52**, wordmark ink bottom → tagline ink top **22**, tagline ink
|
|
232
|
+
bottom → chip top **44**. Ink heights are 91.1 for the wordmark and 20.64 for the tagline.
|
|
233
|
+
|
|
234
|
+
**The tagline gap is exactly half the chip gap, and that ratio is load bearing.** At the card's
|
|
235
|
+
0.19333× those three gaps become 10.1, 4.3 and 8.5 px. Equalise them and the card shows three
|
|
236
|
+
equidistant grey lines instead of a wordmark with its subtitle and a separate chip.
|
|
237
|
+
|
|
238
|
+
The mark tile is 208, not 200, because `u = 6.5` puts every half-unit coordinate of
|
|
239
|
+
[Construction](#construction) on an exact two-decimal value. At `u = 6.25` the slabs land on
|
|
240
|
+
`x.xx5` and the rotation check below fails on rounding alone.
|
|
241
|
+
|
|
242
|
+
The chip is the banner chip scaled by **1.25** (label 16 → 20px): box `181×42 rx 10` →
|
|
243
|
+
`226.25×52.5 rx 12.5`, glyph `+20,+14 4×14` → `+25,+17.5 5×17.5`, label pen `+36` → `+45`, label
|
|
244
|
+
baseline `+27` → `+33.75`. The 45 / 25.25 padding asymmetry is intentional — the magenta bar occupies
|
|
245
|
+
the left — so centre the **box** on `x 600`, never the label inside the box.
|
|
246
|
+
|
|
247
|
+
### Regenerating the gallery outlines
|
|
248
|
+
|
|
249
|
+
Run the script in [Regenerating the outlines](#regenerating-the-outlines) with this `RUNS` instead.
|
|
250
|
+
Wordmark **Black 104px with −5.2 tracking** (the banner's −0.05 em), tagline **Medium 24px**, chip
|
|
251
|
+
label **Regular 20px**; the three strings are the banner's, unchanged.
|
|
252
|
+
|
|
253
|
+
```python
|
|
254
|
+
RUNS = [
|
|
255
|
+
("wordmark", "pi-cursor", "Black", 104, 339.48, 427.5, -5.2),
|
|
256
|
+
("tagline", "/cursor in Pi · unofficial routed Cursor inference", "Medium", 24, 239.48, 483.1, 0),
|
|
257
|
+
("chip", "/cursor usage", "Regular", 20, 531.88, 563.49, 0),
|
|
258
|
+
]
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
The mark slabs are baked at `496 + 6.5x, 92 + 6.5y`, exactly as the banner bakes them at 3.5×. The
|
|
262
|
+
file carries **no `transform` attribute anywhere**; a `translate … scale` wrapper makes every number
|
|
263
|
+
in the table above unverifiable.
|
|
264
|
+
|
|
265
|
+
### Gallery verification
|
|
266
|
+
|
|
267
|
+
Anything that regenerates the two gallery files must still pass all of it:
|
|
268
|
+
|
|
269
|
+
1. `xmllint --noout docs/gallery.svg`, intrinsic `width="3840" height="2160"`, a proportional
|
|
270
|
+
`viewBox="0 0 1200 675"`, and a non-empty `aria-label`.
|
|
271
|
+
2. No `<text>`, `font-family`, `@font-face`, `base64`, `<image>`, `<script>`, `<metadata>`, comment,
|
|
272
|
+
editor namespace, or filesystem path. The file is one `<svg>`, four `<rect>` and five `<path>`,
|
|
273
|
+
and its only URL is the SVG namespace. Also no `transform` — that one is **gallery-only**, not an
|
|
274
|
+
omission from the shared list, because [Gallery geometry](#gallery-geometry) is stated in absolute
|
|
275
|
+
coordinates and a wrapper transform would make every number in it unverifiable.
|
|
276
|
+
3. `magick identify -format '%w x %h %[opaque]' docs/gallery.png` → `3840 x 2160 True`. The raster
|
|
277
|
+
must remain 16:9 and at least 4K; higher resolutions are allowed. The PNG must equal the SVG
|
|
278
|
+
render: `magick compare -metric AE <render> docs/gallery.png null:` → `0`.
|
|
279
|
+
4. Rotate each unit slab by `(x,y) → (32−y, x)` and confirm the set is closed, as in
|
|
280
|
+
[Construction](#construction). Never check the mark by eye.
|
|
281
|
+
5. Simulate the card **from the PNG**, never by rendering the SVG small — pi.dev resamples a bitmap,
|
|
282
|
+
and a small SVG render is crisper than anything a visitor sees:
|
|
283
|
+
`magick docs/gallery.png -filter Lanczos -resize 232x131! -gravity center -crop 232x130+0+0 card.png`.
|
|
284
|
+
Look at it, and at 2× (`464x261` cropped to `464x260`). Every 3-unit gap in the mark must still be
|
|
285
|
+
open and the magenta slab must still be visible.
|
|
286
|
+
6. Render with `FONTCONFIG_FILE` pointing at a config whose only `<dir>` is empty, and confirm the
|
|
287
|
+
output is pixel-identical to a normal render.
|
|
288
|
+
|
|
289
|
+
## Social preview
|
|
290
|
+
|
|
291
|
+
GitHub's social-preview surface is 2:1. None of the existing assets fit it: the banner is 5:1,
|
|
292
|
+
the gallery is 16:9, and the marks are square. `social-preview.svg` is therefore a dedicated
|
|
293
|
+
composition, not a stretched or cropped asset.
|
|
294
|
+
|
|
295
|
+
The approved layout keeps the banner's reading order: an inverted mark tile on the left, then the
|
|
296
|
+
wordmark, subtitle, and usage chip in one text column. It uses the existing palette, Quarter Turn
|
|
297
|
+
geometry, outlined Geist Mono lettering, and exact strings. The field is opaque and full bleed so
|
|
298
|
+
hosting platforms can apply their own corner treatment.
|
|
299
|
+
|
|
300
|
+
The source uses a 1280×640 design grid and renders at 3840×1920. The 2:1 proportion is the layout
|
|
301
|
+
contract; the 3× raster avoids using GitHub's 1280×640 recommendation as a resolution ceiling.
|
|
302
|
+
GitHub documents no maximum pixel dimensions, only a file-size limit below 1 MB.
|
|
303
|
+
|
|
304
|
+
### Geometry
|
|
305
|
+
|
|
306
|
+
| Element | Design-grid geometry |
|
|
307
|
+
|:--|:--|
|
|
308
|
+
| Field | `0,0 1280×640`, opaque `#ecedef` |
|
|
309
|
+
| Mark tile | `80,192 256×256`, radius 48 |
|
|
310
|
+
| Mark | Quarter Turn at `u = 8`, offset `80,192` |
|
|
311
|
+
| Text origin | `x 420`; 84-unit gap after the tile |
|
|
312
|
+
| Wordmark | baseline `273.58`, Black 112px, −5.6 tracking |
|
|
313
|
+
| Subtitle | baseline `333.88`, Medium 26px |
|
|
314
|
+
| Chip | `420,384.74 271.5×63`, Regular 24px label |
|
|
315
|
+
| Margins | 80 left/right; 192 top/bottom |
|
|
316
|
+
|
|
317
|
+
The tile and text band are both centered on `y 320`. The gaps from wordmark to subtitle and subtitle
|
|
318
|
+
to chip are 24 and 48 design units, preserving the gallery's 1:2 relationship.
|
|
319
|
+
|
|
320
|
+
### Regeneration
|
|
321
|
+
|
|
322
|
+
Use the outline script in [Regenerating the outlines](#regenerating-the-outlines) with:
|
|
323
|
+
|
|
324
|
+
```python
|
|
325
|
+
RUNS = [
|
|
326
|
+
("wordmark", "pi-cursor", "Black", 112, 420, 273.58, -5.6),
|
|
327
|
+
("tagline", "/cursor in Pi · unofficial routed Cursor inference", "Medium", 26, 420, 333.88, 0),
|
|
328
|
+
("chip", "/cursor usage", "Regular", 24, 474, 425.24, 0),
|
|
329
|
+
]
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Bake the mark at `80 + 8x, 192 + 8y`. Keep coordinates absolute; do not add a wrapper transform.
|
|
333
|
+
Render the PNG at 3840×1920.
|
|
334
|
+
|
|
335
|
+
### Verification
|
|
336
|
+
|
|
337
|
+
1. Validate the SVG and require intrinsic `3840×1920`, `viewBox="0 0 1280 640"`, and an
|
|
338
|
+
`aria-label`.
|
|
339
|
+
2. Reject embedded text, fonts, images, scripts, metadata, transforms, comments, file paths, or
|
|
340
|
+
external URLs. The expected structure is one SVG, four rectangles, and five paths.
|
|
341
|
+
3. Require an opaque 3840×1920 PNG below 1 MB and pixel equality with an `rsvg-convert` render.
|
|
342
|
+
4. Inspect 1280×640 and smaller 2:1 downscales from the PNG, plus a centered 1.91:1 crop. The mark's
|
|
343
|
+
gaps and magenta slab must remain visible.
|
|
344
|
+
5. Confirm an empty-fontconfig render is pixel-identical.
|
|
345
|
+
|
|
194
346
|
## Verification
|
|
195
347
|
|
|
196
348
|
Anything that regenerates these files must still pass all of it:
|
package/docs/gallery.png
CHANGED
|
Binary file
|
package/package.json
CHANGED