pi-spark 0.19.1 → 0.19.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-spark",
3
- "version": "0.19.1",
3
+ "version": "0.19.2",
4
4
  "description": "Pi package that polishes your daily experience.",
5
5
  "keywords": [
6
6
  "pi-coding-agent",
@@ -38,17 +38,17 @@
38
38
  "zod": "^4.4.3"
39
39
  },
40
40
  "peerDependencies": {
41
- "@earendil-works/pi-agent-core": ">=0.80.6",
42
- "@earendil-works/pi-ai": ">=0.80.6",
43
- "@earendil-works/pi-coding-agent": ">=0.80.6",
44
- "@earendil-works/pi-tui": ">=0.80.6",
41
+ "@earendil-works/pi-agent-core": ">=0.80.8",
42
+ "@earendil-works/pi-ai": ">=0.80.8",
43
+ "@earendil-works/pi-coding-agent": ">=0.80.8",
44
+ "@earendil-works/pi-tui": ">=0.80.8",
45
45
  "typebox": "*"
46
46
  },
47
47
  "devDependencies": {
48
- "@earendil-works/pi-agent-core": ">=0.80.6",
49
- "@earendil-works/pi-ai": ">=0.80.6",
50
- "@earendil-works/pi-coding-agent": ">=0.80.6",
51
- "@earendil-works/pi-tui": ">=0.80.6",
48
+ "@earendil-works/pi-agent-core": ">=0.80.8",
49
+ "@earendil-works/pi-ai": ">=0.80.8",
50
+ "@earendil-works/pi-coding-agent": ">=0.80.8",
51
+ "@earendil-works/pi-tui": ">=0.80.8",
52
52
  "@types/node": "*",
53
53
  "typebox": "*",
54
54
  "typescript": "^7.0.2"
@@ -51,7 +51,7 @@ export class CreditsManager {
51
51
  }
52
52
 
53
53
  const signals = AbortSignal.any([AbortSignal.timeout(REQUEST_TIMEOUT_MS), signal]);
54
- const credits = await provider.fetch(ctx, apiKey, signals);
54
+ const credits = await provider.fetch(apiKey, signals);
55
55
 
56
56
  // The active model may have changed while the request was in flight.
57
57
  if (ctx.model?.provider !== provider.id) return;
@@ -18,7 +18,7 @@ export const deepseekProvider: CreditsProvider = {
18
18
  id: PROVIDER,
19
19
  label: "DeepSeek",
20
20
 
21
- async fetch(_ctx, apiKey, signal): Promise<Credits> {
21
+ async fetch(apiKey, signal): Promise<Credits> {
22
22
  const headers: Record<string, string> = {
23
23
  Accept: "application/json",
24
24
  Authorization: `Bearer ${apiKey}`,
@@ -108,7 +108,7 @@ export const fireworksProvider: CreditsProvider = {
108
108
  id: PROVIDER,
109
109
  label: "Fireworks",
110
110
 
111
- async fetch(_ctx, apiKey, signal): Promise<Credits> {
111
+ async fetch(apiKey, signal): Promise<Credits> {
112
112
  const name = await resolveAccount(apiKey, signal);
113
113
  const balance = await unary<Balance>("GetBalance", { name }, apiKey, signal);
114
114
 
@@ -42,7 +42,7 @@ export const kimiCodeProvider: CreditsProvider = {
42
42
  id: PROVIDER,
43
43
  label: "Kimi Code",
44
44
 
45
- async fetch(_ctx, apiKey, signal): Promise<Credits> {
45
+ async fetch(apiKey, signal): Promise<Credits> {
46
46
  const headers: Record<string, string> = {
47
47
  Accept: "application/json",
48
48
  Authorization: `Bearer ${apiKey}`,
@@ -18,7 +18,7 @@ function createMoonshotProvider(id: string, host: string, currency: string): Cre
18
18
  id,
19
19
  label: "Moonshot",
20
20
 
21
- async fetch(_ctx, apiKey, signal): Promise<Credits> {
21
+ async fetch(apiKey, signal): Promise<Credits> {
22
22
  const headers: Record<string, string> = {
23
23
  Accept: "application/json",
24
24
  Authorization: `Bearer ${apiKey}`,
@@ -1,4 +1,5 @@
1
1
  import { uuidv7 } from "@earendil-works/pi-agent-core";
2
+ import { readStoredCredential } from "@earendil-works/pi-coding-agent";
2
3
  import prettyMilliseconds from "pretty-ms";
3
4
 
4
5
  import { confirmCodexReset, formatAvailableResets, showCodexResetLoader, showCodexResetSelector } from "./openai-codex-panel";
@@ -52,7 +53,7 @@ async function runCodexReset(ctx: ExtensionContext, refresh: RefreshCredits): Pr
52
53
  const apiKey = await ctx.modelRegistry.getApiKeyForProvider(PROVIDER);
53
54
  if (!apiKey) return;
54
55
 
55
- const headers = buildHeaders(ctx, apiKey);
56
+ const headers = buildHeaders(apiKey);
56
57
 
57
58
  const credit = await showCodexResetSelector(ctx, async (signal) => {
58
59
  const requestSignal = AbortSignal.any([signal, AbortSignal.timeout(REQUEST_TIMEOUT_MS)]);
@@ -76,15 +77,15 @@ async function redeemReset(ctx: ExtensionContext, headers: Record<string, string
76
77
  }).finally(() => refresh(ctx));
77
78
  }
78
79
 
79
- function buildHeaders(ctx: ExtensionContext, apiKey: string): Record<string, string> {
80
+ function buildHeaders(apiKey: string): Record<string, string> {
80
81
  const headers: Record<string, string> = {
81
82
  Accept: "application/json",
82
83
  Authorization: `Bearer ${apiKey}`,
83
84
  };
84
85
 
85
- const credential = ctx.modelRegistry.authStorage.get(PROVIDER);
86
- const accountId = credential?.type === "oauth" ? (credential.accountId as string | undefined) : undefined;
87
- if (accountId) headers["ChatGPT-Account-ID"] = accountId;
86
+ const credential = readStoredCredential(PROVIDER);
87
+ const accountId = credential?.type === "oauth" ? credential.accountId : undefined;
88
+ if (typeof accountId === "string" && accountId.length > 0) headers["ChatGPT-Account-ID"] = accountId;
88
89
 
89
90
  return headers;
90
91
  }
@@ -151,8 +152,8 @@ export const openaiCodexProvider: CreditsProvider = {
151
152
  id: PROVIDER,
152
153
  label: "Codex",
153
154
 
154
- async fetch(ctx, apiKey, signal): Promise<Credits> {
155
- const headers = buildHeaders(ctx, apiKey);
155
+ async fetch(apiKey, signal): Promise<Credits> {
156
+ const headers = buildHeaders(apiKey);
156
157
  const usage = await fetchUsage(headers, signal);
157
158
  const availableCount = usage.rate_limit_reset_credits?.available_count ?? 0;
158
159
  const suffix = availableCount > 0 ? `(${formatAvailableResets(availableCount)})` : undefined;
@@ -160,9 +161,8 @@ export const openaiCodexProvider: CreditsProvider = {
160
161
  return toCredits(usage, suffix);
161
162
  },
162
163
 
163
- register(pi, ctx, refresh): void {
164
- const credential = ctx.modelRegistry.authStorage.get(PROVIDER);
165
- if (credential?.type !== "oauth") return;
164
+ register(pi, _ctx, refresh): void {
165
+ if (readStoredCredential(PROVIDER)?.type !== "oauth") return;
166
166
 
167
167
  pi.registerCommand("codex-reset", {
168
168
  description: "Select and redeem a banked OpenAI Codex rate-limit reset",
@@ -16,7 +16,7 @@ export const openrouterProvider: CreditsProvider = {
16
16
  id: PROVIDER,
17
17
  label: "OpenRouter",
18
18
 
19
- async fetch(_ctx, apiKey, signal): Promise<Credits> {
19
+ async fetch(apiKey, signal): Promise<Credits> {
20
20
  const headers: Record<string, string> = {
21
21
  Accept: "application/json",
22
22
  Authorization: `Bearer ${apiKey}`,
@@ -13,7 +13,7 @@ export const vercelAiGatewayProvider: CreditsProvider = {
13
13
  id: PROVIDER,
14
14
  label: "Vercel",
15
15
 
16
- async fetch(_ctx, apiKey, signal): Promise<Credits> {
16
+ async fetch(apiKey, signal): Promise<Credits> {
17
17
  const headers: Record<string, string> = {
18
18
  Accept: "application/json",
19
19
  Authorization: `Bearer ${apiKey}`,
@@ -23,6 +23,6 @@ export type RefreshCredits = (ctx: ExtensionContext) => Promise<void>;
23
23
  export interface CreditsProvider {
24
24
  readonly id: ProviderId;
25
25
  readonly label: string;
26
- fetch(ctx: ExtensionContext, apiKey: string, signal: AbortSignal): Promise<Credits>;
26
+ fetch(apiKey: string, signal: AbortSignal): Promise<Credits>;
27
27
  register?(pi: ExtensionAPI, ctx: ExtensionContext, refresh: RefreshCredits): void;
28
28
  }