pi-ui-extend 0.1.59 → 0.1.60

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.
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
2
2
  import { readFile } from "node:fs/promises";
3
3
  import { homedir } from "node:os";
4
4
  import { join } from "node:path";
5
+ import { AuthStorage } from "@earendil-works/pi-coding-agent";
5
6
  import { formatCompactProgressBar } from "../../context-progress-bar.js";
6
7
  import { APP_ICONS } from "../icons.js";
7
8
  const OPENAI_USAGE_URL = "https://chatgpt.com/backend-api/wham/usage";
@@ -168,26 +169,25 @@ export function openAIUsageStatusFromResponse(data, modelKey, now = Date.now())
168
169
  };
169
170
  }
170
171
  async function queryOpenAIModelUsage(modelKey) {
171
- const authData = await readOpenAIAuth();
172
+ let authData = await readOpenAIAuth();
172
173
  if (!authData || authData.type !== "oauth" || !authData.access)
173
174
  return undefined;
174
175
  if (isExpired(authData))
175
- return undefined;
176
+ authData = await refreshOpenAICodexAuth();
177
+ if (!authData.access)
178
+ throw new Error("OpenAI Codex OAuth refresh returned no access token");
176
179
  const usage = await fetchOpenAIUsage(authData.access);
177
180
  return openAIUsageStatusFromResponse(usage, modelKey);
178
181
  }
179
182
  async function queryOpenAIAccountUsage(now) {
180
- const authData = await readOpenAIAuth();
183
+ let authData = await readOpenAIAuth();
181
184
  if (!authData || authData.type !== "oauth" || !authData.access)
182
185
  return undefined;
183
- if (isExpired(authData))
184
- return {
185
- account: accountLabelFromOpenAIAuth(authData),
186
- windows: [],
187
- limitReached: false,
188
- error: "OAuth token is expired",
189
- };
190
186
  try {
187
+ if (isExpired(authData))
188
+ authData = await refreshOpenAICodexAuth();
189
+ if (!authData.access)
190
+ throw new Error("OpenAI Codex OAuth refresh returned no access token");
191
191
  const usage = await fetchOpenAIUsage(authData.access);
192
192
  const windows = [usage.rate_limit?.primary_window, usage.rate_limit?.secondary_window]
193
193
  .filter(isRateLimitWindow)
@@ -219,6 +219,22 @@ async function queryOpenAIAccountUsage(now) {
219
219
  };
220
220
  }
221
221
  }
222
+ async function refreshOpenAICodexAuth() {
223
+ // Delegate to pi core so refresh-token rotation is persisted under the same
224
+ // cross-process auth.json lock used by model requests.
225
+ const authStorage = AuthStorage.create(getPiAuthPath());
226
+ const access = await authStorage.getApiKey("openai-codex", { includeFallback: false });
227
+ const credential = authStorage.get("openai-codex");
228
+ if (!access || credential?.type !== "oauth" || !credential.access || isExpired(credential)) {
229
+ throw new Error("OpenAI Codex OAuth token refresh failed");
230
+ }
231
+ return {
232
+ type: "oauth",
233
+ access: credential.access,
234
+ refresh: credential.refresh,
235
+ expires: credential.expires,
236
+ };
237
+ }
222
238
  async function readOpenAIAuth() {
223
239
  const authData = await readOpenCodeAuth();
224
240
  const piAuth = await readPiAuth();
@@ -38,9 +38,9 @@
38
38
  "vscode-languageserver-protocol": "^3.17.5"
39
39
  },
40
40
  "peerDependencies": {
41
- "@earendil-works/pi-ai": "0.80.6",
42
- "@earendil-works/pi-coding-agent": "0.80.6",
43
- "@earendil-works/pi-tui": "0.80.6",
41
+ "@earendil-works/pi-ai": "0.80.7",
42
+ "@earendil-works/pi-coding-agent": "0.80.7",
43
+ "@earendil-works/pi-tui": "0.80.7",
44
44
  "typebox": "*"
45
45
  },
46
46
  "devDependencies": {
@@ -124,14 +124,14 @@
124
124
  },
125
125
 
126
126
  "gpt": {
127
- "description": "Prefer enabled GPT-family models: spark/mini for cheap roles, gpt-5.6-sol for heavy roles; fallback cross-provider on quota.",
127
+ "description": "Use the GPT-5.6 family by role: luna for fast tasks, terra for balanced work, and sol for heavy reasoning; fallback cross-provider on quota.",
128
128
  "types": {
129
- "quick": { "model": "openai-codex/gpt-5.3-codex-spark", "fallbackModels": ["zai/glm-4.5-air"], "thinking": "off" },
130
- "scan": { "model": "openai-codex/gpt-5.3-codex-spark", "fallbackModels": ["zai/glm-4.5-air"], "thinking": "off" },
131
- "research": { "model": "openai-codex/gpt-5.4-mini", "fallbackModels": ["zai/glm-5-turbo"], "thinking": "low" },
132
- "docs": { "model": "openai-codex/gpt-5.3-codex-spark", "fallbackModels": ["zai/glm-4.5-air"], "thinking": "low" },
133
- "frontend": { "model": "openai-codex/gpt-5.4-mini", "fallbackModels": ["antigravity/gemini-3-flash-preview", "zai/glm-5.2"], "thinking": "medium" },
134
- "tests": { "model": "openai-codex/gpt-5.4-mini", "fallbackModels": ["zai/glm-5-turbo"], "thinking": "medium" },
129
+ "quick": { "model": "openai-codex/gpt-5.6-luna", "fallbackModels": ["zai/glm-4.5-air"], "thinking": "off" },
130
+ "scan": { "model": "openai-codex/gpt-5.6-luna", "fallbackModels": ["zai/glm-4.5-air"], "thinking": "off" },
131
+ "research": { "model": "openai-codex/gpt-5.6-terra", "fallbackModels": ["zai/glm-5-turbo"], "thinking": "low" },
132
+ "docs": { "model": "openai-codex/gpt-5.6-luna", "fallbackModels": ["zai/glm-4.5-air"], "thinking": "low" },
133
+ "frontend": { "model": "openai-codex/gpt-5.6-terra", "fallbackModels": ["antigravity/gemini-3-flash-preview", "zai/glm-5.2"], "thinking": "medium" },
134
+ "tests": { "model": "openai-codex/gpt-5.6-terra", "fallbackModels": ["zai/glm-5-turbo"], "thinking": "medium" },
135
135
  "review": { "model": "openai-codex/gpt-5.6-sol", "fallbackModels": ["zai/glm-5.2"], "thinking": "high" },
136
136
  "implement": { "model": "openai-codex/gpt-5.6-sol", "fallbackModels": ["zai/glm-5.2"], "thinking": "high" },
137
137
  "deep": { "model": "openai-codex/gpt-5.6-sol", "fallbackModels": ["zai/glm-5.2"], "thinking": "high" }
@@ -155,35 +155,35 @@ export const DEFAULT_PI_TOOLS_SUITE_CONFIG_JSONC = String.raw`{
155
155
  }
156
156
  },
157
157
  "gpt": {
158
- "description": "Prefer enabled GPT-family models: spark/mini for cheap roles, gpt-5.6-sol for heavy roles; fallback cross-provider on quota.",
158
+ "description": "Use the GPT-5.6 family by role: luna for fast tasks, terra for balanced work, and sol for heavy reasoning; fallback cross-provider on quota.",
159
159
  "types": {
160
160
  "quick": {
161
- "model": "openai-codex/gpt-5.3-codex-spark",
161
+ "model": "openai-codex/gpt-5.6-luna",
162
162
  "fallbackModels": ["zai/glm-4.5-air"],
163
163
  "thinking": "off"
164
164
  },
165
165
  "scan": {
166
- "model": "openai-codex/gpt-5.3-codex-spark",
166
+ "model": "openai-codex/gpt-5.6-luna",
167
167
  "fallbackModels": ["zai/glm-4.5-air"],
168
168
  "thinking": "off"
169
169
  },
170
170
  "research": {
171
- "model": "openai-codex/gpt-5.4-mini",
171
+ "model": "openai-codex/gpt-5.6-terra",
172
172
  "fallbackModels": ["zai/glm-5-turbo"],
173
173
  "thinking": "low"
174
174
  },
175
175
  "docs": {
176
- "model": "openai-codex/gpt-5.3-codex-spark",
176
+ "model": "openai-codex/gpt-5.6-luna",
177
177
  "fallbackModels": ["zai/glm-4.5-air"],
178
178
  "thinking": "low"
179
179
  },
180
180
  "frontend": {
181
- "model": "antigravity/gemini-3-flash-preview",
182
- "fallbackModels": ["zai/glm-5.2"],
181
+ "model": "openai-codex/gpt-5.6-terra",
182
+ "fallbackModels": ["antigravity/gemini-3-flash-preview", "zai/glm-5.2"],
183
183
  "thinking": "medium"
184
184
  },
185
185
  "tests": {
186
- "model": "openai-codex/gpt-5.4-mini",
186
+ "model": "openai-codex/gpt-5.6-terra",
187
187
  "fallbackModels": ["zai/glm-5-turbo"],
188
188
  "thinking": "medium"
189
189
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-ui-extend",
3
- "version": "0.1.59",
3
+ "version": "0.1.60",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
@@ -65,9 +65,9 @@
65
65
  "prepublishOnly": "npm run check && npm run build:pix && npm run generate-schemas"
66
66
  },
67
67
  "dependencies": {
68
- "@earendil-works/pi-ai": "0.80.6",
69
- "@earendil-works/pi-coding-agent": "0.80.6",
70
- "@earendil-works/pi-tui": "0.80.6",
68
+ "@earendil-works/pi-ai": "0.80.7",
69
+ "@earendil-works/pi-coding-agent": "0.80.7",
70
+ "@earendil-works/pi-tui": "0.80.7",
71
71
  "@mariozechner/clipboard": "^0.3.9",
72
72
  "jsonc-parser": "3.3.1",
73
73
  "typebox": "1.1.38",