@caph42/pi-cursor-provider 0.0.0-stage → 0.4.0
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/LICENSE +23 -0
- package/README.md +147 -2
- package/package.json +43 -4
- package/src/auth.ts +272 -0
- package/src/client.ts +90 -0
- package/src/codec.ts +235 -0
- package/src/config.ts +76 -0
- package/src/index.ts +105 -0
- package/src/ledger.ts +292 -0
- package/src/models.ts +336 -0
- package/src/native-session.ts +958 -0
- package/src/pi-stream.ts +330 -0
- package/src/run.ts +1268 -0
- package/src/usage.ts +257 -0
package/src/codec.ts
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-written protobuf and Connect framing for Cursor AgentService/Run.
|
|
3
|
+
*
|
|
4
|
+
* Ported from magpie's Cursor provider (MIT):
|
|
5
|
+
* https://github.com/magpie-community/plugins/tree/main/packages/cursor
|
|
6
|
+
* which itself was ported from magpie's Go client (internal/provider/cursor*.go).
|
|
7
|
+
*/
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
import { STATUS_CODES } from "node:http"
|
|
10
|
+
import { gunzipSync } from "node:zlib"
|
|
11
|
+
|
|
12
|
+
export const EMPTY = Buffer.alloc(0)
|
|
13
|
+
|
|
14
|
+
const statusText = (s) =>
|
|
15
|
+
({ 413: "Request Entity Too Large", 414: "Request URI Too Long", 416: "Requested Range Not Satisfiable", 418: "I'm a teapot", 509: "" })[s] ?? STATUS_CODES[s] ?? ""
|
|
16
|
+
|
|
17
|
+
export class PB {
|
|
18
|
+
parts = []
|
|
19
|
+
push(b) {
|
|
20
|
+
this.parts.push(b)
|
|
21
|
+
return this
|
|
22
|
+
}
|
|
23
|
+
uv(v) {
|
|
24
|
+
const out = []
|
|
25
|
+
while (v >= 0x80) {
|
|
26
|
+
out.push((v % 128) | 0x80)
|
|
27
|
+
v = Math.floor(v / 128)
|
|
28
|
+
}
|
|
29
|
+
out.push(v)
|
|
30
|
+
return this.push(Uint8Array.from(out))
|
|
31
|
+
}
|
|
32
|
+
tag(num, wire) {
|
|
33
|
+
return this.uv(num * 8 + wire)
|
|
34
|
+
}
|
|
35
|
+
varint(num, v) {
|
|
36
|
+
return this.tag(num, 0).uv(v)
|
|
37
|
+
}
|
|
38
|
+
bytes(num, v) {
|
|
39
|
+
const b = v instanceof PB ? v.done() : v ?? EMPTY
|
|
40
|
+
return this.tag(num, 2).uv(b.length).push(b)
|
|
41
|
+
}
|
|
42
|
+
str(num, s) {
|
|
43
|
+
return this.bytes(num, Buffer.from(s, "utf8"))
|
|
44
|
+
}
|
|
45
|
+
double(num, v) {
|
|
46
|
+
const b = Buffer.alloc(8)
|
|
47
|
+
b.writeDoubleLE(v)
|
|
48
|
+
return this.tag(num, 1).push(b)
|
|
49
|
+
}
|
|
50
|
+
done() {
|
|
51
|
+
return Buffer.concat(this.parts)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export const pb = () => new PB()
|
|
55
|
+
|
|
56
|
+
// fields reads a message's fields; a malformed tail is dropped.
|
|
57
|
+
export function fields(b) {
|
|
58
|
+
b = Buffer.isBuffer(b) ? b : Buffer.from(b ?? EMPTY)
|
|
59
|
+
const out = []
|
|
60
|
+
let i = 0
|
|
61
|
+
const uv = () => {
|
|
62
|
+
let v = 0
|
|
63
|
+
let m = 1
|
|
64
|
+
while (i < b.length) {
|
|
65
|
+
const c = b[i++]
|
|
66
|
+
v += (c & 0x7f) * m
|
|
67
|
+
if (c < 0x80) return v
|
|
68
|
+
m *= 128
|
|
69
|
+
}
|
|
70
|
+
return -1
|
|
71
|
+
}
|
|
72
|
+
while (i < b.length) {
|
|
73
|
+
const key = uv()
|
|
74
|
+
if (key < 0) break
|
|
75
|
+
const f = { num: Math.floor(key / 8), wire: key % 8, n: 0, data: EMPTY }
|
|
76
|
+
switch (f.wire) {
|
|
77
|
+
case 0: {
|
|
78
|
+
const v = uv()
|
|
79
|
+
if (v < 0) return out
|
|
80
|
+
f.n = v
|
|
81
|
+
break
|
|
82
|
+
}
|
|
83
|
+
case 1:
|
|
84
|
+
if (i + 8 > b.length) return out
|
|
85
|
+
f.data = b.subarray(i, i + 8)
|
|
86
|
+
f.n = Number(b.readBigUInt64LE(i))
|
|
87
|
+
i += 8
|
|
88
|
+
break
|
|
89
|
+
case 2: {
|
|
90
|
+
const l = uv()
|
|
91
|
+
if (l < 0 || i + l > b.length) return out
|
|
92
|
+
f.data = b.subarray(i, i + l)
|
|
93
|
+
i += l
|
|
94
|
+
break
|
|
95
|
+
}
|
|
96
|
+
case 5:
|
|
97
|
+
if (i + 4 > b.length) return out
|
|
98
|
+
f.n = b.readUInt32LE(i)
|
|
99
|
+
i += 4
|
|
100
|
+
break
|
|
101
|
+
default:
|
|
102
|
+
return out
|
|
103
|
+
}
|
|
104
|
+
out.push(f)
|
|
105
|
+
}
|
|
106
|
+
return out
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export const field = (fs, num) => fs.find((f) => f.num === num)
|
|
110
|
+
export const pbStr = (fs, num) => field(fs, num)?.data.toString("utf8") ?? ""
|
|
111
|
+
export const pbNum = (fs, num) => field(fs, num)?.n ?? 0
|
|
112
|
+
|
|
113
|
+
// pbValue is a google.protobuf.Value.
|
|
114
|
+
export function pbValue(v) {
|
|
115
|
+
if (v === null || v === undefined) return pb().varint(1, 0)
|
|
116
|
+
if (typeof v === "number") return pb().double(2, v)
|
|
117
|
+
if (typeof v === "string") return pb().str(3, v)
|
|
118
|
+
if (typeof v === "boolean") return pb().varint(4, v ? 1 : 0)
|
|
119
|
+
if (Array.isArray(v)) {
|
|
120
|
+
const l = pb()
|
|
121
|
+
for (const e of v) l.bytes(1, pbValue(e))
|
|
122
|
+
return pb().bytes(6, l)
|
|
123
|
+
}
|
|
124
|
+
if (typeof v === "object") {
|
|
125
|
+
const st = pb()
|
|
126
|
+
for (const k of Object.keys(v).sort()) st.bytes(1, pb().str(1, k).bytes(2, pbValue(v[k])))
|
|
127
|
+
return pb().bytes(5, st)
|
|
128
|
+
}
|
|
129
|
+
return pb().varint(1, 0)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// pbAny reads a google.protobuf.Value.
|
|
133
|
+
export function pbAny(b) {
|
|
134
|
+
for (const f of fields(b)) {
|
|
135
|
+
switch (f.num) {
|
|
136
|
+
case 1:
|
|
137
|
+
return null
|
|
138
|
+
case 2:
|
|
139
|
+
return f.data.length === 8 ? f.data.readDoubleLE(0) : 0
|
|
140
|
+
case 3:
|
|
141
|
+
return f.data.toString("utf8")
|
|
142
|
+
case 4:
|
|
143
|
+
return f.n !== 0
|
|
144
|
+
case 5: {
|
|
145
|
+
const m = {}
|
|
146
|
+
for (const e of fields(f.data)) {
|
|
147
|
+
if (e.num !== 1) continue
|
|
148
|
+
const kv = fields(e.data)
|
|
149
|
+
const v = field(kv, 2)
|
|
150
|
+
m[pbStr(kv, 1)] = v ? pbAny(v.data) : null
|
|
151
|
+
}
|
|
152
|
+
return m
|
|
153
|
+
}
|
|
154
|
+
case 6:
|
|
155
|
+
return fields(f.data).filter((e) => e.num === 1).map((e) => pbAny(e.data))
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return null
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// frame wraps a message as one frame of a Connect stream.
|
|
162
|
+
export function frame(msg) {
|
|
163
|
+
const head = Buffer.alloc(5)
|
|
164
|
+
head.writeUInt32BE(msg.length, 1)
|
|
165
|
+
return Buffer.concat([head, msg])
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// frames reads a Connect stream's frames: a message, or the stream's end
|
|
169
|
+
// with its JSON.
|
|
170
|
+
export async function* frames(body) {
|
|
171
|
+
let buf = EMPTY
|
|
172
|
+
for await (const chunk of body) {
|
|
173
|
+
buf = buf.length ? Buffer.concat([buf, chunk]) : Buffer.from(chunk)
|
|
174
|
+
while (buf.length >= 5) {
|
|
175
|
+
const n = buf.readUInt32BE(1)
|
|
176
|
+
if (n > 64 << 20) throw new Error("a malformed stream")
|
|
177
|
+
if (buf.length < 5 + n) break
|
|
178
|
+
const flags = buf[0]
|
|
179
|
+
let data = buf.subarray(5, 5 + n)
|
|
180
|
+
buf = buf.subarray(5 + n)
|
|
181
|
+
if (flags & 1) data = gunzipSync(data)
|
|
182
|
+
yield { end: (flags & 2) !== 0, data }
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (buf.length) throw new Error("unexpected EOF")
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// ---- failures -----------------------------------------------------------------------
|
|
189
|
+
|
|
190
|
+
export const regional = (msg) => msg.toLowerCase().includes("region")
|
|
191
|
+
|
|
192
|
+
// failure is the status and message for Cursor's Connect error, whose
|
|
193
|
+
// details say it best: {"code", "message", "details": [{"debug": {"error",
|
|
194
|
+
// "details": {"title", "detail"}}}]}, or the same under "error" at a
|
|
195
|
+
// stream's end.
|
|
196
|
+
export function failure(status, text) {
|
|
197
|
+
let e
|
|
198
|
+
try {
|
|
199
|
+
e = JSON.parse(typeof text === "string" ? text : Buffer.from(text).toString("utf8"))
|
|
200
|
+
} catch {
|
|
201
|
+
return statusOf(status, "", String(text ?? "").trim())
|
|
202
|
+
}
|
|
203
|
+
const f = e?.error && typeof e.error === "object" ? e.error : e ?? {}
|
|
204
|
+
let msg = f.message ?? ""
|
|
205
|
+
for (const d of f.details ?? []) {
|
|
206
|
+
const t = `${d?.debug?.details?.title ?? ""}: ${d?.debug?.details?.detail ?? ""}`.trim()
|
|
207
|
+
if (t !== ":") msg = t.replace(/^[:\s]+|[:\s]+$/g, "")
|
|
208
|
+
}
|
|
209
|
+
if (!msg || msg === "Error") msg = f.code ?? ""
|
|
210
|
+
if (!f.code && status >= 200 && status < 300) return { status, message: msg } // a stream that ended well
|
|
211
|
+
return statusOf(status, f.code ?? "", msg)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// statusOf is the status and words for Cursor's error of this code and
|
|
215
|
+
// message. A region the team isn't served in says so, not to sign in.
|
|
216
|
+
export function statusOf(status, code, msg) {
|
|
217
|
+
msg ||= statusText(status)
|
|
218
|
+
const low = msg.toLowerCase()
|
|
219
|
+
// magpie names the provider before the message itself
|
|
220
|
+
const out = (status, message) => ({ status, message })
|
|
221
|
+
if (regional(msg)) return out(403, msg + " — Cursor serves your team only in some regions and turned this request away; signing in again won't change that")
|
|
222
|
+
if (code === "permission_denied") return out(403, msg)
|
|
223
|
+
if (code === "unauthenticated" || status === 401 || low.includes("expired"))
|
|
224
|
+
return out(401, msg + " — sign in to Cursor again with /login cursor")
|
|
225
|
+
if (code === "resource_exhausted" || low.includes("quota") || low.includes("rate limit") || low.includes("usage limit"))
|
|
226
|
+
return out(429, "usage limit reached: " + msg)
|
|
227
|
+
if (low.includes("too long") || low.includes("context length") || low.includes("too many tokens"))
|
|
228
|
+
return out(400, "input is too long for the model's context: " + msg)
|
|
229
|
+
if (code === "invalid_argument") return out(400, msg)
|
|
230
|
+
if (code === "unavailable") return out(503, msg)
|
|
231
|
+
if (code) return out(502, msg)
|
|
232
|
+
return out(status, msg)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// ---- the conversation -------------------------------------------------------------
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which Cursor models Pi's picker offers.
|
|
3
|
+
*
|
|
4
|
+
* Cursor lists every model (and every context size and effort of it) a
|
|
5
|
+
* subscription may use; that is long enough that the useful ones get lost in
|
|
6
|
+
* `/model`. `cursor.json` in Pi's config directory (`PI_CODING_AGENT_DIR`,
|
|
7
|
+
* else `~/.pi/agent`) names what to hide:
|
|
8
|
+
*
|
|
9
|
+
* { "hiddenModels": ["claude-*", "gpt-5", "cursor/gpt-5-mini"] }
|
|
10
|
+
*
|
|
11
|
+
* A pattern globs the id `/model` shows (the part after `cursor/`): `*` is any
|
|
12
|
+
* run of characters, everything else is literal, and the match ignores case.
|
|
13
|
+
* Hiding is a picker filter only: a session already on that model keeps it. A
|
|
14
|
+
* missing, unreadable or malformed file hides nothing.
|
|
15
|
+
*/
|
|
16
|
+
import { readFileSync } from "node:fs"
|
|
17
|
+
import { homedir } from "node:os"
|
|
18
|
+
import { join } from "node:path"
|
|
19
|
+
|
|
20
|
+
export const CONFIG_FILE = "cursor.json"
|
|
21
|
+
|
|
22
|
+
/** `cursor.json` beside the rest of Pi's config. */
|
|
23
|
+
export function configPath(env: NodeJS.ProcessEnv = process.env): string {
|
|
24
|
+
const dir = (env.PI_CODING_AGENT_DIR ?? "").trim()
|
|
25
|
+
return join(dir || join(homedir(), ".pi", "agent"), CONFIG_FILE)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** `hiddenModels` as patterns: strings only, trimmed, empty ones dropped. */
|
|
29
|
+
function patternsOf(value: unknown): string[] {
|
|
30
|
+
if (!Array.isArray(value)) return []
|
|
31
|
+
return value.flatMap((v) => (typeof v === "string" && v.trim() ? [v.trim()] : []))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The patterns in `cursor.json`. A file that is absent or not JSON hides nothing. */
|
|
35
|
+
export function hiddenPatterns(path: string = configPath()): string[] {
|
|
36
|
+
let text: string
|
|
37
|
+
try {
|
|
38
|
+
text = readFileSync(path, "utf8")
|
|
39
|
+
} catch {
|
|
40
|
+
return []
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const json: unknown = JSON.parse(text)
|
|
44
|
+
return patternsOf((json as { hiddenModels?: unknown } | null)?.hiddenModels)
|
|
45
|
+
} catch {
|
|
46
|
+
return []
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A pattern as a regex: `*` any run, the rest literal (a `?` is a question mark, not a wildcard),
|
|
51
|
+
* the whole id, ignoring case. */
|
|
52
|
+
function globRe(pattern: string): RegExp {
|
|
53
|
+
const body = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")
|
|
54
|
+
return new RegExp(`^${body}$`, "i")
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A model id as /model spells it: no `cursor/` prefix. */
|
|
58
|
+
const bare = (id: string) => (id.startsWith("cursor/") ? id.slice("cursor/".length) : id)
|
|
59
|
+
|
|
60
|
+
/** Whether any pattern hides this model id. Both the id and the pattern may carry `cursor/`, and a
|
|
61
|
+
* pattern without the `@size` suffix hides every context size of that model. */
|
|
62
|
+
export function hidden(patterns: string[], id: string): boolean {
|
|
63
|
+
const name = bare(id)
|
|
64
|
+
const at = name.indexOf("@")
|
|
65
|
+
const family = at < 0 ? name : name.slice(0, at)
|
|
66
|
+
return patterns.some((p) => {
|
|
67
|
+
const re = globRe(bare(p))
|
|
68
|
+
return re.test(name) || re.test(family)
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** The models a pattern list keeps, in order. No patterns keeps all of them. */
|
|
73
|
+
export function visible<T extends { id: string }>(models: T[], patterns: string[]): T[] {
|
|
74
|
+
if (!patterns.length) return models
|
|
75
|
+
return models.filter((m) => !hidden(patterns, m.id))
|
|
76
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pi extension: provider id `cursor`.
|
|
3
|
+
*
|
|
4
|
+
* Login follows pi-cursor (MIT): https://github.com/Rahularya01/pi-cursor
|
|
5
|
+
* A stateless turn opens an HTTP/2 Run and tears it down after tools.
|
|
6
|
+
* A native Run in this process stays open and takes call_cursor_ results.
|
|
7
|
+
* This does not register a parked bridge, a checkpoint, or a run journal.
|
|
8
|
+
*/
|
|
9
|
+
import type { RefreshModelsContext } from "@earendil-works/pi-ai"
|
|
10
|
+
import type { ExtensionAPI, ProviderModelConfig } from "@earendil-works/pi-coding-agent"
|
|
11
|
+
import { login, refresh, resolveAccessToken } from "./auth.ts"
|
|
12
|
+
import { AGENT, clientVersion } from "./client.ts"
|
|
13
|
+
import { configPath, hiddenPatterns, visible } from "./config.ts"
|
|
14
|
+
import { piModelConfigs, usable } from "./models.ts"
|
|
15
|
+
import { streamCursor } from "./pi-stream.ts"
|
|
16
|
+
import { fetchUsage, formatUsage } from "./usage.ts"
|
|
17
|
+
|
|
18
|
+
export { fetchUsage, formatUsage, onDemandOf } from "./usage.ts"
|
|
19
|
+
|
|
20
|
+
// offered is every model Cursor offers the account; models is what cursor.json keeps
|
|
21
|
+
let offered: ProviderModelConfig[] = []
|
|
22
|
+
let models: ProviderModelConfig[] = []
|
|
23
|
+
|
|
24
|
+
async function refreshModels(ctx: RefreshModelsContext): Promise<ProviderModelConfig[]> {
|
|
25
|
+
if (ctx.signal.aborted) return models
|
|
26
|
+
if (ctx.allowNetwork) {
|
|
27
|
+
const fromCred =
|
|
28
|
+
ctx.credential?.type === "oauth" ? ctx.credential.access : ctx.credential?.type === "api_key" ? ctx.credential.key : undefined
|
|
29
|
+
const auth = await resolveAccessToken({ apiKey: fromCred })
|
|
30
|
+
if (auth) {
|
|
31
|
+
try {
|
|
32
|
+
offered = piModelConfigs(await usable(auth.token, ctx.force === true)) as ProviderModelConfig[]
|
|
33
|
+
} catch {
|
|
34
|
+
// keep the list Cursor gave last; only the hide list below changes
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// cursor.json is read on every refresh, network or not, so a hidden model leaves
|
|
39
|
+
// the picker on the next list refresh
|
|
40
|
+
models = visible(offered, hiddenPatterns())
|
|
41
|
+
return models
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default function (pi: ExtensionAPI) {
|
|
45
|
+
pi.registerProvider("cursor", {
|
|
46
|
+
name: "Cursor",
|
|
47
|
+
baseUrl: AGENT,
|
|
48
|
+
apiKey: "$CURSOR_ACCESS_TOKEN",
|
|
49
|
+
api: "cursor-run",
|
|
50
|
+
models,
|
|
51
|
+
oauth: {
|
|
52
|
+
name: "Cursor",
|
|
53
|
+
isSubscription: true,
|
|
54
|
+
login,
|
|
55
|
+
refreshToken: (credentials, signal) => refresh(credentials, signal),
|
|
56
|
+
getApiKey: (credentials) => credentials.access,
|
|
57
|
+
},
|
|
58
|
+
refreshModels,
|
|
59
|
+
streamSimple: streamCursor,
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
pi.registerCommand("cursor.doctor", {
|
|
63
|
+
description: "Show which Cursor credential would be used, without printing the token",
|
|
64
|
+
handler: async (args, ctx) => {
|
|
65
|
+
const extra = args.trim() ? " This command does not take arguments." : ""
|
|
66
|
+
const auth = await resolveAccessToken()
|
|
67
|
+
const version = await clientVersion()
|
|
68
|
+
const patterns = hiddenPatterns()
|
|
69
|
+
const hiddenText = patterns.length ? `Hidden from /model: ${patterns.join(", ")} (${configPath()}).` : `No models hidden (${configPath()}).`
|
|
70
|
+
if (!auth) {
|
|
71
|
+
ctx.ui.notify(`Cursor is not signed in (${version}). Run /login cursor or set CURSOR_ACCESS_TOKEN. ${hiddenText}${extra}`, "warning")
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
ctx.ui.notify(`Cursor auth source: ${auth.source}. Client ${version}. ${hiddenText} Token not shown.${extra}`, "info")
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
pi.registerCommand("cursor.usage", {
|
|
79
|
+
description: "Show Cursor plan usage for this billing period",
|
|
80
|
+
handler: async (args, ctx) => {
|
|
81
|
+
const extra = args.trim() ? " This command does not take arguments." : ""
|
|
82
|
+
const auth = await resolveAccessToken()
|
|
83
|
+
if (!auth) {
|
|
84
|
+
const version = await clientVersion()
|
|
85
|
+
ctx.ui.notify(`Cursor is not signed in (${version}). Run /login cursor or set CURSOR_ACCESS_TOKEN.${extra}`, "warning")
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
// every model the account has: usage windows classify events by these, hidden or not
|
|
89
|
+
let ids = offered.map((m) => m.id)
|
|
90
|
+
if (!ids.length) {
|
|
91
|
+
try {
|
|
92
|
+
ids = (await usable(auth.token)).map((m: { id: string }) => m.id)
|
|
93
|
+
} catch {
|
|
94
|
+
ids = []
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const report = await fetchUsage(auth.token, ids)
|
|
99
|
+
ctx.ui.notify(formatUsage(report) + extra, report.error ? "warning" : "info")
|
|
100
|
+
} catch (e) {
|
|
101
|
+
ctx.ui.notify(`Cursor usage could not be read. ${e instanceof Error ? e.message : String(e)}${extra}`, "warning")
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
})
|
|
105
|
+
}
|