@kenkaiiii/gg-core 5.39.3 → 5.40.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/dist/index.d.cts CHANGED
@@ -185,7 +185,16 @@ interface OAuthCredentials {
185
185
  }
186
186
  interface OAuthLoginCallbacks {
187
187
  onOpenUrl: (url: string) => void;
188
- onPromptCode: (message: string) => Promise<string>;
188
+ /**
189
+ * Collect a pasted authorization code or callback URL.
190
+ *
191
+ * `signal` aborts when the code already arrived another way (the local
192
+ * callback listener won the race) and the prompt should be torn down.
193
+ * Implementations may ignore it — an abandoned promise is simply never
194
+ * awaited — but a terminal prompt should honour it so the line does not
195
+ * linger after login already succeeded.
196
+ */
197
+ onPromptCode: (message: string, signal?: AbortSignal) => Promise<string>;
189
198
  onStatus: (message: string) => void;
190
199
  }
191
200
 
@@ -365,13 +374,27 @@ declare class AuthStorage {
365
374
  clearAll(): Promise<void>;
366
375
  /**
367
376
  * Returns valid credentials, auto-refreshing if expired.
377
+ *
368
378
  * If `forceRefresh` is true, refreshes even if the token hasn't expired
369
- * (useful when the provider rejects a token with 401 before its stored expiry).
379
+ * (useful when the provider rejects a token with 401 before its stored
380
+ * expiry). Callers recovering from a rejection should also pass
381
+ * `rejectedToken` — see the stampede guard below.
382
+ *
370
383
  * Throws if not logged in.
371
384
  */
372
385
  resolveCredentials(provider: string, opts?: {
373
386
  forceRefresh?: boolean;
374
387
  storageKeys?: string[];
388
+ /**
389
+ * The access token the provider just rejected. Refreshing an OAuth grant
390
+ * invalidates the previous access token, so N processes sharing auth.json
391
+ * (app windows, CLI sessions, the usage poller) can otherwise revoke each
392
+ * other in a loop: each one force-refreshes on 401, and every refresh kills
393
+ * the token the others still hold. Naming the rejected token lets the
394
+ * refresh path tell "this credential is genuinely dead" from "someone else
395
+ * already rotated it" and simply adopt the newer on-disk credential.
396
+ */
397
+ rejectedToken?: string;
375
398
  }): Promise<OAuthCredentials>;
376
399
  /**
377
400
  * Returns a valid access token, auto-refreshing if expired.
package/dist/index.d.ts CHANGED
@@ -185,7 +185,16 @@ interface OAuthCredentials {
185
185
  }
186
186
  interface OAuthLoginCallbacks {
187
187
  onOpenUrl: (url: string) => void;
188
- onPromptCode: (message: string) => Promise<string>;
188
+ /**
189
+ * Collect a pasted authorization code or callback URL.
190
+ *
191
+ * `signal` aborts when the code already arrived another way (the local
192
+ * callback listener won the race) and the prompt should be torn down.
193
+ * Implementations may ignore it — an abandoned promise is simply never
194
+ * awaited — but a terminal prompt should honour it so the line does not
195
+ * linger after login already succeeded.
196
+ */
197
+ onPromptCode: (message: string, signal?: AbortSignal) => Promise<string>;
189
198
  onStatus: (message: string) => void;
190
199
  }
191
200
 
@@ -365,13 +374,27 @@ declare class AuthStorage {
365
374
  clearAll(): Promise<void>;
366
375
  /**
367
376
  * Returns valid credentials, auto-refreshing if expired.
377
+ *
368
378
  * If `forceRefresh` is true, refreshes even if the token hasn't expired
369
- * (useful when the provider rejects a token with 401 before its stored expiry).
379
+ * (useful when the provider rejects a token with 401 before its stored
380
+ * expiry). Callers recovering from a rejection should also pass
381
+ * `rejectedToken` — see the stampede guard below.
382
+ *
370
383
  * Throws if not logged in.
371
384
  */
372
385
  resolveCredentials(provider: string, opts?: {
373
386
  forceRefresh?: boolean;
374
387
  storageKeys?: string[];
388
+ /**
389
+ * The access token the provider just rejected. Refreshing an OAuth grant
390
+ * invalidates the previous access token, so N processes sharing auth.json
391
+ * (app windows, CLI sessions, the usage poller) can otherwise revoke each
392
+ * other in a loop: each one force-refreshes on 401, and every refresh kills
393
+ * the token the others still hold. Naming the rejected token lets the
394
+ * refresh path tell "this credential is genuinely dead" from "someone else
395
+ * already rotated it" and simply adopt the newer on-disk credential.
396
+ */
397
+ rejectedToken?: string;
375
398
  }): Promise<OAuthCredentials>;
376
399
  /**
377
400
  * Returns a valid access token, auto-refreshing if expired.
package/dist/index.js CHANGED
@@ -54,7 +54,7 @@ import {
54
54
  registerRuntimeModels,
55
55
  usesOpenAICodexTransport,
56
56
  withFileLock
57
- } from "./chunk-XDE6VUI4.js";
57
+ } from "./chunk-JH7OVHH5.js";
58
58
  import {
59
59
  getAppPaths
60
60
  } from "./chunk-EAIPT76S.js";
@@ -92,6 +92,7 @@ var import_node_path3 = __toESM(require("path"), 1);
92
92
  var import_node_crypto2 = require("crypto");
93
93
  var import_gg_ai = require("@kenkaiiii/gg-ai");
94
94
  var MAX_BYTES = 10 * 1024 * 1024;
95
+ var MIN_HEADROOM_BYTES = 64 * 1024;
95
96
 
96
97
  // src/claude-code-version.ts
97
98
  var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;