@cortexkit/opencode-openai-auth 1.6.1 → 1.7.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.
Files changed (42) hide show
  1. package/dist/bin.js +8 -8
  2. package/dist/{codex-request-D_In8uaR.d.ts → codex-request-CN4rD2kf.d.ts} +2 -832
  3. package/dist/{index-z8bptbrk.js → index-0p3cbtwq.js} +2 -2
  4. package/dist/{index-1qxz4s8a.js → index-2e2kqmsy.js} +2 -2
  5. package/dist/{index-b0ty9qam.js → index-7zy4vdd3.js} +2 -2
  6. package/dist/{index-ge60xry3.js → index-apkavdvq.js} +2 -2
  7. package/dist/{index-rf0ht3gc.js → index-b5459de4.js} +2 -2
  8. package/dist/{index-8xq099qf.js → index-dr93b3g6.js} +2 -2
  9. package/dist/{index-jkpg9d1p.js → index-g08eptzm.js} +1 -1
  10. package/dist/{index-ya9c5e4m.js → index-jaqm1xda.js} +1 -1
  11. package/dist/{index-79y7w9bz.js → index-p9vnmnzr.js} +1 -1
  12. package/dist/index-qg2syg0r.js +65 -0
  13. package/dist/{index-x9nffaye.js → index-r4avvxf0.js} +1 -1
  14. package/dist/{index-k5anexvs.js → index-se9ykks8.js} +2 -2
  15. package/dist/{index-7nmdsmpp.js → index-yayz83vv.js} +2 -2
  16. package/dist/index.d.ts +4 -79
  17. package/dist/index.js +1 -1
  18. package/dist/{model-D22uj0OB.d.ts → protocol-BeeDdtpa.d.ts} +24 -66
  19. package/dist/rpc/port-file.js +1 -1
  20. package/dist/rpc/protocol.d.ts +1 -1
  21. package/dist/rpc/protocol.js +1 -1
  22. package/dist/rpc/rpc-client.d.ts +2 -12
  23. package/dist/rpc/rpc-client.js +1 -1
  24. package/dist/rpc/rpc-dir.js +1 -1
  25. package/dist/rpc-client-DlR9a0_7.d.ts +13 -0
  26. package/dist/{sidebar-state-Bb9L9oPq.d.ts → sidebar-state-DHsZ9axt.d.ts} +1 -3
  27. package/dist/sidebar-state.d.ts +2 -2
  28. package/dist/sidebar-state.js +1 -1
  29. package/dist/{token-xtq3457d.js → token-511npvw8.js} +1 -1
  30. package/dist/token-util-jsw1zdc6.js +1 -0
  31. package/dist/tui-preferences.js +1 -1
  32. package/dist/tui.d.ts +11 -2
  33. package/dist/v2/server.d.ts +2 -2
  34. package/dist/v2/server.js +2 -2
  35. package/package.json +1 -1
  36. package/src/tui-compiled/raw/tui/v2.tsx +88 -6
  37. package/src/tui-compiled/raw/tui.tsx +45 -3
  38. package/src/tui-compiled/runtime/tui/v2.js +66 -5
  39. package/src/tui-compiled/runtime/tui.js +32 -3
  40. package/dist/index-cv6aqcvk.js +0 -65
  41. package/dist/protocol-CK9guiFy.d.ts +0 -29
  42. package/dist/token-util-nyvn9866.js +0 -1
@@ -1,2 +1,2 @@
1
- import{lf as F}from"./index-ya9c5e4m.js";import{randomUUID as k}from"node:crypto";import{lstat as N,readFile as f,rename as y,unlink as I}from"node:fs/promises";import{tmpdir as P}from"node:os";import{dirname as W,join as E,resolve as K}from"node:path";var O=process.platform==="win32",L=new Set;function V(j){if(j?.reason==="io-error"){if(j.win32Code===2||j.win32Code===3)return"ENOENT";if(j.win32Code===80||j.win32Code===183)return"EEXIST"}return j?.code??"ERR_PRIVATE_FILE"}var _;var v="native-addon-unavailable";function b(j){return Object.assign(Error("Windows private-files native addon is unavailable",{cause:j}),{code:"ERR_PRIVATE_FILES_UNAVAILABLE",reason:v})}function g(j,x){return x instanceof j.PrivateFilesUnavailableError||x?.code==="ERR_PRIVATE_FILES_UNAVAILABLE"}async function m(j){try{await j.verifyPrivatePath(E(P(),`.common-auth-private-files-probe-${k()}`),"file")}catch(x){if(g(j,x))throw b(x)}}function $(){return _??=import("@cortexkit/private-files").then(async(j)=>{if(O)await m(j);return j},(j)=>{throw O?b(j):j}),_}class Q extends Error{path;stage;code;win32Code;reason;published=!1;durabilityConfirmed=!1;fileDurable=!1;attempts=0;elapsedMs=0;orphanPath;constructor(j,x,z){let q=z;super(q?.code==="ERR_PRIVATE_FILES_UNAVAILABLE"?`Private file refused at ${x}: ${j} (${v}). The Windows native addon of @cortexkit/private-files could not be loaded, so owner-only access cannot be enforced and nothing was read or written. Reinstall the plugin so the private-files Windows prebuild for this architecture is present; Windows has no safe fallback to permission bits.`:`Private file refused at ${x}: ${j} (${q?.reason??q?.code??"io-error"}). Keep this file in a folder that only you, the system or administrators can change, such as a folder in your home directory. If other users could read the file before, sign in again to replace the credentials it held. On Windows the file must also be on a local drive that keeps Windows file permissions, such as NTFS.`,{cause:z});this.path=j,this.stage=x,this.name="PrivateFileError",this.code=V(q),this.win32Code=q?.win32Code,this.reason=q?.reason}}async function T(j,x,z){try{return await z()}catch(q){if(q instanceof Q)throw q;throw new Q(j,x,q)}}var c;async function Y(j,x){j=K(j),x??=c,await T(j,"safe-parent",async()=>{let z=await(await $()).verifySafeParent(j,x);if(z.ok===!1){if(z.reason==="io-error"||z.reason==="wrong-kind")await N(j);throw new Q(z.level??z.path,"safe-parent",{...z,code:"ERR_PRIVATE_FILES_SECURITY"})}})}async function S(j,x,z=!1){if(j=K(j),x==="directory")return Y(j);await T(j,"verify",async()=>{let q=await $(),H=await q.verifyOwnerOnly(j),C=!1;if(!H.ok){let{reason:J}=H.refusal;if(J==="io-error")await q.verifyPrivatePath(j,x);if(z&&[q.EXTRA_ACE,q.NOT_PROTECTED,q.NULL_DACL,q.EMPTY_DACL].includes(J))await Y(W(j)),await q.securePrivatePath(j,x),C=!0;else throw Object.assign(Error("Owner-only verification refused"),{reason:J,code:"ERR_PRIVATE_FILES_SECURITY"})}if(await q.verifyPrivatePath(j,x),C&&!L.has(j))L.add(j),process.emitWarning(`Private permissions tightened: ${j}. This object may have been readable before; rotate credentials if needed.`,"PrivateFileMigration")})}async function w(j,x=!1,z){j=K(j),await T(j,"directory",async()=>{let q=await $();try{return await N(j),await Y(j,z)}catch(C){if(V(C)!=="ENOENT")throw C}let H=W(j);if(H===j)throw Object.assign(Error("Missing root"),{code:"ENOENT"});await w(H,!1,z);try{await q.createOwnerOnly(j,{kind:"dir"})}catch(C){if(V(C)!=="EEXIST")throw C}await Y(j,z)})}async function p(j,x=!1){if(!O)return f(j,"utf8");return(await u(j,x)).toString("utf8")}async function u(j,x=!1){if(!O)return f(j);if(j=K(j),x)await Y(W(j)),await S(j,"file",!0);return T(j,"read",async()=>(await $()).readOwnerOnly(j))}async function d(j,x){await Y(W(K(j))),await T(j,"create",async()=>{await(await $()).createPrivateFile(K(j),x)})}async function r(j){await Y(W(K(j))),await T(j,"directory-create",async()=>{await(await $()).createOwnerOnly(K(j),{kind:"dir"})})}async function l(j,x,z={}){j=K(j),x=K(x);let q=z.now??(()=>performance.now()),H=q(),C=z.deadline??1/0,J,Z=[0,10,20,40,80,100],U,G=0;for(let D of Z){let R=Math.min(J??1/0,C);if(q()>=R)break;if(D)await(z.sleep??((B)=>new Promise((X)=>setTimeout(X,B))))(Math.min(D,Math.max(0,R-q())));if(q()>=R)break;let A=q();if(await z.beforeRename?.(),J!==void 0)J+=q()-A;if(q()>=C)break;G++;try{return await(z.rename??y)(j,x),{attempts:G,elapsedMs:q()-H}}catch(B){U??=B;let X=B;if(!(X.win32Code!==void 0?X.win32Code===32||X.win32Code===33:["EBUSY","EPERM","EACCES"].includes(X.code??"")&&!X.reason))break;J??=q()+500}}let M=new Q(x,"rename",U??Object.assign(Error("Publication deadline expired"),{code:"ETIMEDOUT"}));throw M.attempts=G,M.elapsedMs=q()-H,M}async function e(j,x,z={}){j=K(j),await w(W(j));try{await S(j,"file",!0)}catch(G){if(G.code!=="ENOENT")throw G}let q=K(z.stagePath??`${j}.${k()}.tmp`);if(W(q)!==W(j))throw new Q(j,"stage-directory",{code:"EXDEV"});let H=!1,C=!1,J={attempts:0,elapsedMs:0},Z="stage-create",U=(G)=>{try{z.onOutcome?.({path:j,stage:G?.stage??"published",published:C,fileDurable:C,durabilityConfirmed:!1,attempts:G?.attempts??J.attempts,elapsedMs:G?.elapsedMs??J.elapsedMs,...G&&{code:G.code,win32Code:G.win32Code}})}catch{}};try{if(await d(q,x),H=!0,Z="before-rename",J=await l(q,j,z),H=!1,C=!0,Z="published-callback",z.onRenamed?.(),Z="published-verify",await S(j,"file"),z.durable&&z.durability!=="file-only-on-windows")throw new Q(j,"directory-sync-unsupported",{code:"ENOTSUP"});U()}catch(G){let M=G instanceof Q?G:new Q(j,Z,G);if(M.published=C,M.fileDurable=C,C)Object.assign(M,J);if(H){try{await I(q)}catch{M.orphanPath=q}H=!1}throw U(M),M}finally{if(H)await I(q).catch(()=>{})}}
2
- export{O as We,Q as Xe,T as Ye,Y as Ze,S as _e,w as $e,p as af,d as bf,r as cf,l as df,e as ef};
1
+ import{mf as F}from"./index-jaqm1xda.js";import{randomUUID as k}from"node:crypto";import{lstat as N,readFile as f,rename as y,unlink as I}from"node:fs/promises";import{tmpdir as P}from"node:os";import{dirname as W,join as E,resolve as K}from"node:path";var O=process.platform==="win32",L=new Set;function V(j){if(j?.reason==="io-error"){if(j.win32Code===2||j.win32Code===3)return"ENOENT";if(j.win32Code===80||j.win32Code===183)return"EEXIST"}return j?.code??"ERR_PRIVATE_FILE"}var _;var v="native-addon-unavailable";function b(j){return Object.assign(Error("Windows private-files native addon is unavailable",{cause:j}),{code:"ERR_PRIVATE_FILES_UNAVAILABLE",reason:v})}function g(j,x){return x instanceof j.PrivateFilesUnavailableError||x?.code==="ERR_PRIVATE_FILES_UNAVAILABLE"}async function m(j){try{await j.verifyPrivatePath(E(P(),`.common-auth-private-files-probe-${k()}`),"file")}catch(x){if(g(j,x))throw b(x)}}function $(){return _??=import("@cortexkit/private-files").then(async(j)=>{if(O)await m(j);return j},(j)=>{throw O?b(j):j}),_}class Q extends Error{path;stage;code;win32Code;reason;published=!1;durabilityConfirmed=!1;fileDurable=!1;attempts=0;elapsedMs=0;orphanPath;constructor(j,x,z){let q=z;super(q?.code==="ERR_PRIVATE_FILES_UNAVAILABLE"?`Private file refused at ${x}: ${j} (${v}). The Windows native addon of @cortexkit/private-files could not be loaded, so owner-only access cannot be enforced and nothing was read or written. Reinstall the plugin so the private-files Windows prebuild for this architecture is present; Windows has no safe fallback to permission bits.`:`Private file refused at ${x}: ${j} (${q?.reason??q?.code??"io-error"}). Keep this file in a folder that only you, the system or administrators can change, such as a folder in your home directory. If other users could read the file before, sign in again to replace the credentials it held. On Windows the file must also be on a local drive that keeps Windows file permissions, such as NTFS.`,{cause:z});this.path=j,this.stage=x,this.name="PrivateFileError",this.code=V(q),this.win32Code=q?.win32Code,this.reason=q?.reason}}async function T(j,x,z){try{return await z()}catch(q){if(q instanceof Q)throw q;throw new Q(j,x,q)}}var c;async function Y(j,x){j=K(j),x??=c,await T(j,"safe-parent",async()=>{let z=await(await $()).verifySafeParent(j,x);if(z.ok===!1){if(z.reason==="io-error"||z.reason==="wrong-kind")await N(j);throw new Q(z.level??z.path,"safe-parent",{...z,code:"ERR_PRIVATE_FILES_SECURITY"})}})}async function S(j,x,z=!1){if(j=K(j),x==="directory")return Y(j);await T(j,"verify",async()=>{let q=await $(),H=await q.verifyOwnerOnly(j),C=!1;if(!H.ok){let{reason:J}=H.refusal;if(J==="io-error")await q.verifyPrivatePath(j,x);if(z&&[q.EXTRA_ACE,q.NOT_PROTECTED,q.NULL_DACL,q.EMPTY_DACL].includes(J))await Y(W(j)),await q.securePrivatePath(j,x),C=!0;else throw Object.assign(Error("Owner-only verification refused"),{reason:J,code:"ERR_PRIVATE_FILES_SECURITY"})}if(await q.verifyPrivatePath(j,x),C&&!L.has(j))L.add(j),process.emitWarning(`Private permissions tightened: ${j}. This object may have been readable before; rotate credentials if needed.`,"PrivateFileMigration")})}async function w(j,x=!1,z){j=K(j),await T(j,"directory",async()=>{let q=await $();try{return await N(j),await Y(j,z)}catch(C){if(V(C)!=="ENOENT")throw C}let H=W(j);if(H===j)throw Object.assign(Error("Missing root"),{code:"ENOENT"});await w(H,!1,z);try{await q.createOwnerOnly(j,{kind:"dir"})}catch(C){if(V(C)!=="EEXIST")throw C}await Y(j,z)})}async function p(j,x=!1){if(!O)return f(j,"utf8");return(await u(j,x)).toString("utf8")}async function u(j,x=!1){if(!O)return f(j);if(j=K(j),x)await Y(W(j)),await S(j,"file",!0);return T(j,"read",async()=>(await $()).readOwnerOnly(j))}async function d(j,x){await Y(W(K(j))),await T(j,"create",async()=>{await(await $()).createPrivateFile(K(j),x)})}async function r(j){await Y(W(K(j))),await T(j,"directory-create",async()=>{await(await $()).createOwnerOnly(K(j),{kind:"dir"})})}async function l(j,x,z={}){j=K(j),x=K(x);let q=z.now??(()=>performance.now()),H=q(),C=z.deadline??1/0,J,Z=[0,10,20,40,80,100],U,G=0;for(let D of Z){let R=Math.min(J??1/0,C);if(q()>=R)break;if(D)await(z.sleep??((B)=>new Promise((X)=>setTimeout(X,B))))(Math.min(D,Math.max(0,R-q())));if(q()>=R)break;let A=q();if(await z.beforeRename?.(),J!==void 0)J+=q()-A;if(q()>=C)break;G++;try{return await(z.rename??y)(j,x),{attempts:G,elapsedMs:q()-H}}catch(B){U??=B;let X=B;if(!(X.win32Code!==void 0?X.win32Code===32||X.win32Code===33:["EBUSY","EPERM","EACCES"].includes(X.code??"")&&!X.reason))break;J??=q()+500}}let M=new Q(x,"rename",U??Object.assign(Error("Publication deadline expired"),{code:"ETIMEDOUT"}));throw M.attempts=G,M.elapsedMs=q()-H,M}async function e(j,x,z={}){j=K(j),await w(W(j));try{await S(j,"file",!0)}catch(G){if(G.code!=="ENOENT")throw G}let q=K(z.stagePath??`${j}.${k()}.tmp`);if(W(q)!==W(j))throw new Q(j,"stage-directory",{code:"EXDEV"});let H=!1,C=!1,J={attempts:0,elapsedMs:0},Z="stage-create",U=(G)=>{try{z.onOutcome?.({path:j,stage:G?.stage??"published",published:C,fileDurable:C,durabilityConfirmed:!1,attempts:G?.attempts??J.attempts,elapsedMs:G?.elapsedMs??J.elapsedMs,...G&&{code:G.code,win32Code:G.win32Code}})}catch{}};try{if(await d(q,x),H=!0,Z="before-rename",J=await l(q,j,z),H=!1,C=!0,Z="published-callback",z.onRenamed?.(),Z="published-verify",await S(j,"file"),z.durable&&z.durability!=="file-only-on-windows")throw new Q(j,"directory-sync-unsupported",{code:"ENOTSUP"});U()}catch(G){let M=G instanceof Q?G:new Q(j,Z,G);if(M.published=C,M.fileDurable=C,C)Object.assign(M,J);if(H){try{await I(q)}catch{M.orphanPath=q}H=!1}throw U(M),M}finally{if(H)await I(q).catch(()=>{})}}
2
+ export{O as Xe,Q as Ye,T as Ze,Y as _e,S as $e,w as af,p as bf,d as cf,r as df,l as ef,e as ff};
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as PoolStore, _ as TokenResponse, a as RESPONSES_LITE_MODELS, b as parseJwtClaims, c as CacheKeepManager, d as ResetTargetIdentity, f as OpenAiVault, g as IdTokenClaims, l as MenuMigrationState, n as CODEX_VERSION, o as PoolLifecycleDeps, t as CODEX_USER_AGENT, u as OpenAiMenuOptions, v as beginAccountLogin, x as AccountPaths, y as extractAccountIdFromClaims } from "./codex-request-D_In8uaR.js";
2
- import { S as SidebarState, y as SidebarMachineState } from "./sidebar-state-Bb9L9oPq.js";
1
+ import { _ as AccountPaths, a as RESPONSES_LITE_MODELS, c as ResetTargetIdentity, g as parseJwtClaims, h as extractAccountIdFromClaims, l as OpenAiVault, m as TokenResponse, n as CODEX_VERSION, o as PoolLifecycleDeps, p as IdTokenClaims, t as CODEX_USER_AGENT } from "./codex-request-CN4rD2kf.js";
2
+ import { S as SidebarState, y as SidebarMachineState } from "./sidebar-state-DHsZ9axt.js";
3
3
  import { Hooks, Plugin, PluginInput } from "@opencode-ai/plugin";
4
4
  //#region ../core/dist/provider.d.ts
5
5
  type QuotaWindowName = string;
@@ -377,75 +377,6 @@ type AccountStorage = {
377
377
  };
378
378
  declare function loadAccounts(paths: AccountPaths): Promise<AccountStorage | null>;
379
379
  //#endregion
380
- //#region ../core/dist/refresh-all-quota.d.ts
381
- interface RefreshAllQuotaResult {
382
- account: string;
383
- ok: boolean;
384
- error?: string;
385
- /**
386
- * The account cannot recover on its own: the provider has rejected its
387
- * credentials, so no amount of retrying will help until the operator re-adds
388
- * it.
389
- *
390
- * Carried as a flag rather than left for the caller to infer from `error`,
391
- * because sniffing an error string for a user-facing decision breaks the
392
- * moment the wording changes.
393
- */
394
- permanent?: boolean;
395
- }
396
- //#endregion
397
- //#region src/commands.d.ts
398
- /** What the `/openai` menu reads and changes in this process. */
399
- interface OpenCodeMenuContext {
400
- readOnly?: boolean;
401
- allowAction?: OpenAiMenuOptions['allowAction'];
402
- unavailableSections?: OpenAiMenuOptions['unavailableSections'];
403
- accountStoragePath: string;
404
- /** Runtime-state file that goes with `accountStoragePath`. */
405
- accountStatePath: string;
406
- /** Host package version, sent as the version half of the OAuth `User-Agent`. */
407
- packageVersion: string;
408
- /**
409
- * Each account's saved quota windows and applicable reset-credit count, and
410
- * whether it is rate limited now: what the Reset credits section judges
411
- * eligibility and reports a redemption with. OpenCode 2 backs it with its
412
- * account pool instead of a `QuotaManager`.
413
- */
414
- quotaManager?: Pick<QuotaManager, 'isRateLimited' | 'getMain' | 'getFallback'>;
415
- loadAccounts: typeof loadAccounts;
416
- /** The pool store the accounts live in. */
417
- store: () => PoolStore;
418
- /** Whether the install is migrated, and what holds it back when not. */
419
- migration: () => Promise<MenuMigrationState>;
420
- /** Starts an OAuth account-add flow; injected by the runtime boundary. */
421
- beginAccountLogin?: typeof beginAccountLogin;
422
- /** Actively poll quota for every account. */
423
- refreshAllQuota?: () => Promise<RefreshAllQuotaResult[]>;
424
- /** Refresh the sidebar-state file after a change. */
425
- refreshSidebar?: () => Promise<void>;
426
- /** Re-read the pool so requests route across the changed rows at once. */
427
- afterWrite?: () => unknown;
428
- cacheKeepManager?: Pick<CacheKeepManager, 'status' | 'start' | 'stop' | 'remove'> | null;
429
- /** Host-specific limits to show alongside the keep-warm status. */
430
- cacheKeepNotice?: string;
431
- setCacheKeepEnabled?: (enabled: boolean) => void;
432
- setCacheKeepSubagents?: (enabled: boolean) => void;
433
- setCacheKeepSustain?: (enabled: boolean) => void;
434
- setCacheKeepWindow?: (window: {
435
- startHour: number;
436
- endHour: number;
437
- } | undefined) => void;
438
- clearStickyRouting?: (sessionId: string) => Promise<boolean>;
439
- getStickyRouting?: (sessionId: string) => Promise<string | undefined>;
440
- resolveResetTarget?: (accountKey: string) => Promise<ResetTargetIdentity>;
441
- refreshResetTargetQuota?: (accountKey: string) => Promise<RefreshAllQuotaResult>;
442
- fetchImpl?: typeof fetch;
443
- now?: () => number;
444
- randomUUID?: () => string;
445
- /** This host's connection to the Claustrum vault (the Vault section). */
446
- vault?: OpenAiVault;
447
- }
448
- //#endregion
449
380
  //#region src/core/background-quota-refresh.d.ts
450
381
  type TimerHandle = ReturnType<typeof setInterval>;
451
382
  interface BackgroundQuotaRefreshOptions {
@@ -489,6 +420,8 @@ export declare function codexOAuthModelLimit(modelId: string): {
489
420
  input: number;
490
421
  output: number;
491
422
  } | undefined;
423
+ /** Terra supports Sol's reasoning variants before every host catalog knows it. */
424
+ export declare function codexOAuthModelVariantSource(modelId: string): string | undefined;
492
425
  /**
493
426
  * Surfaced when a request would go to the wire with no credential.
494
427
  *
@@ -502,8 +435,6 @@ export declare const EMPTY_BEARER_MESSAGE = "Refusing to send a request with no
502
435
  export declare const getMainRefreshLockName: () => string;
503
436
  export declare const MAIN_REFRESH_LOCK_TTL_MS: number;
504
437
  export declare const MAIN_REFRESH_LEASE_TTL_MS = 90000;
505
- export declare function __bootQuotaSeedPromiseForTest(): Promise<unknown> | undefined;
506
- export declare function __resetBootQuotaSeedForTest(): void;
507
438
  export declare class AuthPersistError extends Error {
508
439
  readonly code = "OPENAI_AUTH_PERSIST_FAILED";
509
440
  constructor(cause: unknown);
@@ -561,12 +492,6 @@ export declare function buildResetRedemptionDeps(): {
561
492
  now: () => number;
562
493
  randomUUID: () => `${string}-${string}-${string}-${string}-${string}`;
563
494
  };
564
- /**
565
- * Test seam: the context the latest loader run gave the `/openai` menu, so a
566
- * test of the loader's live gates (keep-warm, sticky pins) can drive them on
567
- * an install the menu itself would not open on.
568
- */
569
- export declare function __menuContextForTest(): OpenCodeMenuContext | null;
570
495
  export declare const POOL_MIGRATION_ENABLED = true;
571
496
  interface CodexAuthPluginOptions {
572
497
  /**
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{$ as p,R as f,S as g,T as h,U as i,V as j,W as k,X as l,Y as m,Z as n,_ as o,aa as q,ba as r,ca as s,da as t,ea as u,fa as v,ga as w,ha as x,ia as y,ja as z,ka as A,la as B,ma as C,n as c,na as D,o as d,oa as E,p as e,pa as F}from"./index-cv6aqcvk.js";import"./index-k5anexvs.js";import"./index-1qxz4s8a.js";import{Wc as a,Xc as b}from"./index-ge60xry3.js";import"./index-8xq099qf.js";import"./index-z8bptbrk.js";import"./index-rf0ht3gc.js";import"./index-b0ty9qam.js";import"./index-7nmdsmpp.js";import"./index-x9nffaye.js";import"./index-ya9c5e4m.js";export{C as rewriteResponsesLiteBody,A as resolveSidebarSessionId,r as poolResetTarget,a as parseJwtClaims,x as mergePushedQuotaMetadata,k as getMainRefreshLockName,w as findCachekeepFallbackAccount,b as extractAccountIdFromClaims,F as default,s as createResetTargetResolver,h as codexOAuthModelListed,i as codexOAuthModelLimit,z as buildSidebarState,y as buildSidebarMachineState,t as buildResetRedemptionDeps,o as __resetBootQuotaSeedForTest,u as __menuContextForTest,n as __bootQuotaSeedPromiseForTest,q as ResetTargetResolutionError,c as RESPONSES_LITE_MODELS,v as POOL_MIGRATION_ENABLED,E as OpenAIAuthPlugin,B as MID_CONVERSATION_EFFORT_MODELS,l as MAIN_REFRESH_LOCK_TTL_MS,m as MAIN_REFRESH_LEASE_TTL_MS,j as EMPTY_BEARER_MESSAGE,g as DISALLOWED_MODELS,D as CodexAuthPlugin,d as CODEX_VERSION,e as CODEX_USER_AGENT,p as AuthPersistError,f as ALLOWED_MODELS};
1
+ import{$ as p,R as f,S as g,T as h,U as i,V as j,W as k,X as l,Y as m,Z as n,_ as o,aa as q,ba as r,ca as s,da as t,ea as u,fa as v,ga as w,ha as x,ia as y,ja as z,ka as A,la as B,ma as C,n as c,na as D,o as d,oa as E,p as e,pa as F,qa as G}from"./index-qg2syg0r.js";import"./index-se9ykks8.js";import"./index-2e2kqmsy.js";import{Xc as a,Yc as b}from"./index-apkavdvq.js";import"./index-dr93b3g6.js";import"./index-0p3cbtwq.js";import"./index-b5459de4.js";import"./index-7zy4vdd3.js";import"./index-yayz83vv.js";import"./index-r4avvxf0.js";import"./index-jaqm1xda.js";export{D as rewriteResponsesLiteBody,B as resolveSidebarSessionId,s as poolResetTarget,a as parseJwtClaims,y as mergePushedQuotaMetadata,l as getMainRefreshLockName,x as findCachekeepFallbackAccount,b as extractAccountIdFromClaims,G as default,t as createResetTargetResolver,j as codexOAuthModelVariantSource,h as codexOAuthModelListed,i as codexOAuthModelLimit,A as buildSidebarState,z as buildSidebarMachineState,u as buildResetRedemptionDeps,p as __resetBootQuotaSeedForTest,v as __menuContextForTest,o as __bootQuotaSeedPromiseForTest,r as ResetTargetResolutionError,c as RESPONSES_LITE_MODELS,w as POOL_MIGRATION_ENABLED,F as OpenAIAuthPlugin,C as MID_CONVERSATION_EFFORT_MODELS,m as MAIN_REFRESH_LOCK_TTL_MS,n as MAIN_REFRESH_LEASE_TTL_MS,k as EMPTY_BEARER_MESSAGE,g as DISALLOWED_MODELS,E as CodexAuthPlugin,d as CODEX_VERSION,e as CODEX_USER_AGENT,q as AuthPersistError,f as ALLOWED_MODELS};
@@ -167,74 +167,32 @@ interface CommandApplyResult {
167
167
  menu: CommandMenuModel;
168
168
  }
169
169
  type NotifyKind = 'info' | 'warning' | 'error';
170
+ //#endregion
171
+ //#region ../core/dist/protocol.d.ts
172
+ /** The menu, as the slash command opens it in the TUI. */
173
+ type OpenDialogPayload = CommandDialogPayload;
170
174
  /**
171
- * The per-invocation context of one slash-command call. The library reads
172
- * both fields once, when the call starts, and keeps that copy for any work
173
- * the call leaves running (a login completing later, for example), so a host
174
- * that reuses one context object across sessions cannot reroute feedback.
175
+ * A message for the user from work a menu action left running (a login that
176
+ * finishes after the action returned).
175
177
  */
176
- interface CommandInvocation {
178
+ interface NotifyPayload {
179
+ command: string;
180
+ notify: {
181
+ message: string;
182
+ kind: NotifyKind;
183
+ };
184
+ }
185
+ interface RpcNotification {
186
+ id: number;
187
+ type: 'open-dialog';
188
+ payload: OpenDialogPayload | NotifyPayload;
177
189
  sessionId?: string;
178
- notify(message: string, kind?: NotifyKind): void;
179
- }
180
- interface ActionOutcome {
181
- ok: boolean;
182
- text: string;
183
- /** The failure's stable code; a failure without one is `refused`. */
184
- code?: string;
185
- }
186
- interface ActionInput {
187
- values: KnobValues;
188
- /** The item the action sits on; absent for a section-level action. */
189
- itemId?: string;
190
- invocation: CommandInvocation;
191
- }
192
- type ActionBase = {
193
- id: string;
194
- label: string;
195
- description?: string;
196
- /** The header a section-level action is listed under; see `MenuSection`. */
197
- group?: string;
198
- knobs?: MenuKnob[];
199
- run(input: ActionInput): Promise<string | ActionOutcome>;
200
- };
201
- /**
202
- * An action and its body. An irreversible action must name its
203
- * confirmation; a reversible one may.
204
- */
205
- type ActionDefinition = ActionBase & ({
206
- irreversible: true;
207
- confirm: string;
208
- } | {
209
- irreversible?: false;
210
- confirm?: string;
211
- });
212
- interface ItemDefinition {
213
- id: string;
214
- label: string;
215
- detail?: string;
216
- /** The header the item is listed under; see `MenuSection`. */
217
- group?: string;
218
- /** A short value shown right-aligned beside the label. */
219
- status?: string;
220
- facts?: Record<string, unknown>;
221
- actions?: ActionDefinition[];
222
- }
223
- interface SectionContent {
224
- /** Read-only text; renderers never make a line selectable. */
225
- lines?: string[];
226
- items?: ItemDefinition[];
227
- actions?: ActionDefinition[];
228
- facts?: Record<string, unknown>;
229
- }
230
- /** A section a plugin supplies for one of its slots. */
231
- interface PluginSection {
232
- title: string;
233
- build(invocation: CommandInvocation): SectionContent | Promise<SectionContent>;
234
- }
235
- /** A provider extra: a plugin section shown after the fixed slots. */
236
- interface PluginExtraSection extends PluginSection {
237
- id: string;
238
190
  }
191
+ /** One action applied from the drawer. */
192
+ type ApplyRequest = CommandApplyRequest;
193
+ /** Its message and the refreshed menu. */
194
+ type ApplyResult = CommandApplyResult;
195
+ /** Whether a pushed notification is the menu itself or a message. */
196
+ declare function isNotifyPayload(payload: OpenDialogPayload | NotifyPayload): payload is NotifyPayload;
239
197
  //#endregion
240
- export { KnobValues as a, PluginExtraSection as c, CommandInvocation as i, PluginSection as l, CommandApplyResult as n, MenuKnob as o, CommandDialogPayload as r, NotifyKind as s, CommandApplyRequest as t };
198
+ export { RpcNotification as a, OpenDialogPayload as i, ApplyResult as n, isNotifyPayload as o, NotifyPayload as r, ApplyRequest as t };
@@ -1 +1 @@
1
- import{De as c}from"../index-z8bptbrk.js";import{Fe as a,He as b}from"../index-rf0ht3gc.js";import"../index-7nmdsmpp.js";import"../index-x9nffaye.js";import"../index-ya9c5e4m.js";export{a as writePortFile,c as isOpenaiRpcStateDir,b as discoverPortFile};
1
+ import{Ee as c}from"../index-0p3cbtwq.js";import{Ge as a,Ie as b}from"../index-b5459de4.js";import"../index-yayz83vv.js";import"../index-r4avvxf0.js";import"../index-jaqm1xda.js";export{a as writePortFile,c as isOpenaiRpcStateDir,b as discoverPortFile};
@@ -1,2 +1,2 @@
1
- import { a as RpcNotification, i as OpenDialogPayload, n as ApplyResult, o as isNotifyPayload, r as NotifyPayload, t as ApplyRequest } from "../protocol-CK9guiFy.js";
1
+ import { a as RpcNotification, i as OpenDialogPayload, n as ApplyResult, o as isNotifyPayload, r as NotifyPayload, t as ApplyRequest } from "../protocol-BeeDdtpa.js";
2
2
  export { type ApplyRequest, type ApplyResult, type NotifyPayload, type OpenDialogPayload, type RpcNotification, isNotifyPayload };
@@ -1 +1 @@
1
- import{Ue as b}from"../index-b0ty9qam.js";import"../index-7nmdsmpp.js";import"../index-ya9c5e4m.js";export{b as isNotifyPayload};
1
+ import{Ve as b}from"../index-7zy4vdd3.js";import"../index-yayz83vv.js";import"../index-jaqm1xda.js";export{b as isNotifyPayload};
@@ -1,12 +1,2 @@
1
- import { a as RpcNotification, n as ApplyResult, t as ApplyRequest } from "../protocol-CK9guiFy.js";
2
- import { t as PortFileEntry } from "../port-file-8ElfwDcq.js";
3
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/rpc/rpc-client.d.ts
4
- export declare const DEFAULT_RPC_TIMEOUT_MS = 2000;
5
- //#endregion
6
- //#region src/rpc/rpc-client.d.ts
7
- export interface RpcClient {
8
- pending: (lastReceivedId: number, sessionId?: string) => Promise<RpcNotification[]>;
9
- apply: (request: ApplyRequest, timeoutMs?: number) => Promise<ApplyResult>;
10
- }
11
- export declare function createRpcClient(dir: string, expectedPid?: number, onSelected?: (entry: PortFileEntry | null) => void): RpcClient;
12
- //#endregion
1
+ import { n as createRpcClient, r as DEFAULT_RPC_TIMEOUT_MS, t as RpcClient } from "../rpc-client-DlR9a0_7.js";
2
+ export { DEFAULT_RPC_TIMEOUT_MS, RpcClient, createRpcClient };
@@ -1 +1 @@
1
- import{Ie as F,Je as f}from"../index-rf0ht3gc.js";import"../index-7nmdsmpp.js";import"../index-ya9c5e4m.js";function y(r,s,v){return f(r,s,v)}export{y as createRpcClient,F as DEFAULT_RPC_TIMEOUT_MS};
1
+ import{Je as F,Ke as f}from"../index-b5459de4.js";import"../index-yayz83vv.js";import"../index-jaqm1xda.js";function y(r,s,v){return f(r,s,v)}export{y as createRpcClient,F as DEFAULT_RPC_TIMEOUT_MS};
@@ -1 +1 @@
1
- import{ff as a,gf as b,hf as c,if as d}from"../index-x9nffaye.js";import"../index-ya9c5e4m.js";export{a as tmpdir,d as resolveRpcDir,c as getRpcDir,b as RPC_DIRECTORY_PREFIX};
1
+ import{gf as a,hf as b,if as c,jf as d}from"../index-r4avvxf0.js";import"../index-jaqm1xda.js";export{a as tmpdir,d as resolveRpcDir,c as getRpcDir,b as RPC_DIRECTORY_PREFIX};
@@ -0,0 +1,13 @@
1
+ import { a as RpcNotification, n as ApplyResult, t as ApplyRequest } from "./protocol-BeeDdtpa.js";
2
+ import { t as PortFileEntry } from "./port-file-8ElfwDcq.js";
3
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/rpc/rpc-client.d.ts
4
+ declare const DEFAULT_RPC_TIMEOUT_MS = 2000;
5
+ //#endregion
6
+ //#region src/rpc/rpc-client.d.ts
7
+ interface RpcClient {
8
+ pending: (lastReceivedId: number, sessionId?: string, timeoutMs?: number) => Promise<RpcNotification[]>;
9
+ apply: (request: ApplyRequest, timeoutMs?: number) => Promise<ApplyResult>;
10
+ }
11
+ declare function createRpcClient(dir: string, expectedPid?: number, onSelected?: (entry: PortFileEntry | null) => void): RpcClient;
12
+ //#endregion
13
+ export { createRpcClient as n, DEFAULT_RPC_TIMEOUT_MS as r, RpcClient as t };
@@ -291,8 +291,6 @@ interface SidebarState {
291
291
  */
292
292
  vaultAccounts?: SidebarAccountState[];
293
293
  }
294
- /** Test seam: point the one-time import at a fixture instead of the temp folder. */
295
- declare function setLegacySidebarStateFileForTest(file: string): void;
296
294
  declare const STICKY_ASSIGNMENT_MAX_AGE_MS: number;
297
295
  declare const STICKY_ASSIGNMENT_MAX_ENTRIES = 256;
298
296
  declare function hashSidebarSessionId(sessionId: string): string;
@@ -547,4 +545,4 @@ interface QuotaPacing {
547
545
  }
548
546
  declare function computeQuotaPacing(window: QuotaWindow, windowMs: number, now: number): QuotaPacing | null;
549
547
  //#endregion
550
- export { planSidebarStickyAssignment as $, StickyPinOverlayEntry as A, exhaustedQuotaResetAt as B, SidebarStateCache as C, StickyAssignmentMap as D, StickyAssignmentChoice as E, computeQuotaPacing as F, getPresentQuotaWindows as G, formatWindowLabel as H, createSidebarBookkeepingQueue as I, hashSidebarSessionId as J, getSidebarState as K, createSidebarStateCache as L, accountServesOnCredits as M, applyStickyPinOverlay as N, StickyAssignmentPlan as O, clearSidebarStickyAssignment as P, persistSidebarStickyAssignment as Q, displayWidth as R, SidebarState as S, StickyAssignment as T, getCollapsedAccountLines as U, fitCollapsedLabel as V, getCollapsedQuotaSummary as W, isUsableRoutingEntry as X, isQuotaExhausted as Y, normalizeSidebarState as Z, SidebarAccountState as _, QuotaMap as _t, ActiveRoutingEntry as a, resolveActiveAccount as at, SidebarRoutingAccount as b, DEFAULT_SIDEBAR_STATE as c, resolveSidebarStickyAssignment as ct, QuotaPacing as d, setSidebarMachineState as dt, planSidebarStickyAssignmentFromSnapshot as et, QuotaWindow as f, setSidebarState as ft, STICKY_ASSIGNMENT_MAX_ENTRIES as g, upsertSidebarActiveRouting as gt, STICKY_ASSIGNMENT_MAX_AGE_MS as h, spendControlExhaustedResetAt as ht, AccountQuota as i, removeSidebarActiveRouting as it, accountCreditsText as j, StickyPinOverlay as k, HOT_PATH_READ_BUDGET_MS as l, setLegacySidebarStateFileForTest as lt, ResolveStickyAssignmentInput as m, sidebarQuotaProjection as mt, ACTIVE_ROUTING_MAX_ENTRIES as n, pruneStickyAssignments as nt, ActiveRoutingMap as o, resolveSessionSidebarRouting as ot, QuotaWindowKey as p, settleWithinBudget as pt, getSidebarStateFile as q, AccountCredits as r, rememberStickyPin as rt, CollapsedAccountLine as s, resolveSessionStickyAccount as st, ACTIVE_ROUTING_MAX_AGE_MS as t, pruneActiveRouting as tt, PresentQuotaWindow as u, setSidebarLegacyRouting as ut, SidebarBookkeepingQueue as v, SpendControlReading as w, SidebarSnapshot as x, SidebarMachineState as y, drainSidebarWrites as z };
548
+ export { planSidebarStickyAssignment as $, StickyPinOverlayEntry as A, exhaustedQuotaResetAt as B, SidebarStateCache as C, StickyAssignmentMap as D, StickyAssignmentChoice as E, computeQuotaPacing as F, getPresentQuotaWindows as G, formatWindowLabel as H, createSidebarBookkeepingQueue as I, hashSidebarSessionId as J, getSidebarState as K, createSidebarStateCache as L, accountServesOnCredits as M, applyStickyPinOverlay as N, StickyAssignmentPlan as O, clearSidebarStickyAssignment as P, persistSidebarStickyAssignment as Q, displayWidth as R, SidebarState as S, StickyAssignment as T, getCollapsedAccountLines as U, fitCollapsedLabel as V, getCollapsedQuotaSummary as W, isUsableRoutingEntry as X, isQuotaExhausted as Y, normalizeSidebarState as Z, SidebarAccountState as _, ActiveRoutingEntry as a, resolveActiveAccount as at, SidebarRoutingAccount as b, DEFAULT_SIDEBAR_STATE as c, resolveSidebarStickyAssignment as ct, QuotaPacing as d, setSidebarState as dt, planSidebarStickyAssignmentFromSnapshot as et, QuotaWindow as f, settleWithinBudget as ft, STICKY_ASSIGNMENT_MAX_ENTRIES as g, QuotaMap as gt, STICKY_ASSIGNMENT_MAX_AGE_MS as h, upsertSidebarActiveRouting as ht, AccountQuota as i, removeSidebarActiveRouting as it, accountCreditsText as j, StickyPinOverlay as k, HOT_PATH_READ_BUDGET_MS as l, setSidebarLegacyRouting as lt, ResolveStickyAssignmentInput as m, spendControlExhaustedResetAt as mt, ACTIVE_ROUTING_MAX_ENTRIES as n, pruneStickyAssignments as nt, ActiveRoutingMap as o, resolveSessionSidebarRouting as ot, QuotaWindowKey as p, sidebarQuotaProjection as pt, getSidebarStateFile as q, AccountCredits as r, rememberStickyPin as rt, CollapsedAccountLine as s, resolveSessionStickyAccount as st, ACTIVE_ROUTING_MAX_AGE_MS as t, pruneActiveRouting as tt, PresentQuotaWindow as u, setSidebarMachineState as ut, SidebarBookkeepingQueue as v, SpendControlReading as w, SidebarSnapshot as x, SidebarMachineState as y, drainSidebarWrites as z };
@@ -1,2 +1,2 @@
1
- import { $ as planSidebarStickyAssignment, A as StickyPinOverlayEntry, B as exhaustedQuotaResetAt, C as SidebarStateCache, D as StickyAssignmentMap, E as StickyAssignmentChoice, F as computeQuotaPacing, G as getPresentQuotaWindows, H as formatWindowLabel, I as createSidebarBookkeepingQueue, J as hashSidebarSessionId, K as getSidebarState, L as createSidebarStateCache, M as accountServesOnCredits, N as applyStickyPinOverlay, O as StickyAssignmentPlan, P as clearSidebarStickyAssignment, Q as persistSidebarStickyAssignment, R as displayWidth, S as SidebarState, T as StickyAssignment, U as getCollapsedAccountLines, V as fitCollapsedLabel, W as getCollapsedQuotaSummary, X as isUsableRoutingEntry, Y as isQuotaExhausted, Z as normalizeSidebarState, _ as SidebarAccountState, a as ActiveRoutingEntry, at as resolveActiveAccount, b as SidebarRoutingAccount, c as DEFAULT_SIDEBAR_STATE, ct as resolveSidebarStickyAssignment, d as QuotaPacing, dt as setSidebarMachineState, et as planSidebarStickyAssignmentFromSnapshot, f as QuotaWindow, ft as setSidebarState, g as STICKY_ASSIGNMENT_MAX_ENTRIES, gt as upsertSidebarActiveRouting, h as STICKY_ASSIGNMENT_MAX_AGE_MS, ht as spendControlExhaustedResetAt, i as AccountQuota, it as removeSidebarActiveRouting, j as accountCreditsText, k as StickyPinOverlay, l as HOT_PATH_READ_BUDGET_MS, lt as setLegacySidebarStateFileForTest, m as ResolveStickyAssignmentInput, mt as sidebarQuotaProjection, n as ACTIVE_ROUTING_MAX_ENTRIES, nt as pruneStickyAssignments, o as ActiveRoutingMap, ot as resolveSessionSidebarRouting, p as QuotaWindowKey, pt as settleWithinBudget, q as getSidebarStateFile, r as AccountCredits, rt as rememberStickyPin, s as CollapsedAccountLine, st as resolveSessionStickyAccount, t as ACTIVE_ROUTING_MAX_AGE_MS, tt as pruneActiveRouting, u as PresentQuotaWindow, ut as setSidebarLegacyRouting, v as SidebarBookkeepingQueue, w as SpendControlReading, x as SidebarSnapshot, y as SidebarMachineState, z as drainSidebarWrites } from "./sidebar-state-Bb9L9oPq.js";
2
- export { ACTIVE_ROUTING_MAX_AGE_MS, ACTIVE_ROUTING_MAX_ENTRIES, AccountCredits, AccountQuota, ActiveRoutingEntry, ActiveRoutingMap, CollapsedAccountLine, DEFAULT_SIDEBAR_STATE, HOT_PATH_READ_BUDGET_MS, PresentQuotaWindow, QuotaPacing, QuotaWindow, QuotaWindowKey, ResolveStickyAssignmentInput, STICKY_ASSIGNMENT_MAX_AGE_MS, STICKY_ASSIGNMENT_MAX_ENTRIES, SidebarAccountState, SidebarBookkeepingQueue, SidebarMachineState, SidebarRoutingAccount, SidebarSnapshot, SidebarState, SidebarStateCache, SpendControlReading, StickyAssignment, StickyAssignmentChoice, StickyAssignmentMap, StickyAssignmentPlan, StickyPinOverlay, StickyPinOverlayEntry, accountCreditsText, accountServesOnCredits, applyStickyPinOverlay, clearSidebarStickyAssignment, computeQuotaPacing, createSidebarBookkeepingQueue, createSidebarStateCache, displayWidth, drainSidebarWrites, exhaustedQuotaResetAt, fitCollapsedLabel, formatWindowLabel, getCollapsedAccountLines, getCollapsedQuotaSummary, getPresentQuotaWindows, getSidebarState, getSidebarStateFile, hashSidebarSessionId, isQuotaExhausted, isUsableRoutingEntry, normalizeSidebarState, persistSidebarStickyAssignment, planSidebarStickyAssignment, planSidebarStickyAssignmentFromSnapshot, pruneActiveRouting, pruneStickyAssignments, rememberStickyPin, removeSidebarActiveRouting, resolveActiveAccount, resolveSessionSidebarRouting, resolveSessionStickyAccount, resolveSidebarStickyAssignment, setLegacySidebarStateFileForTest, setSidebarLegacyRouting, setSidebarMachineState, setSidebarState, settleWithinBudget, sidebarQuotaProjection, spendControlExhaustedResetAt, upsertSidebarActiveRouting };
1
+ import { $ as planSidebarStickyAssignment, A as StickyPinOverlayEntry, B as exhaustedQuotaResetAt, C as SidebarStateCache, D as StickyAssignmentMap, E as StickyAssignmentChoice, F as computeQuotaPacing, G as getPresentQuotaWindows, H as formatWindowLabel, I as createSidebarBookkeepingQueue, J as hashSidebarSessionId, K as getSidebarState, L as createSidebarStateCache, M as accountServesOnCredits, N as applyStickyPinOverlay, O as StickyAssignmentPlan, P as clearSidebarStickyAssignment, Q as persistSidebarStickyAssignment, R as displayWidth, S as SidebarState, T as StickyAssignment, U as getCollapsedAccountLines, V as fitCollapsedLabel, W as getCollapsedQuotaSummary, X as isUsableRoutingEntry, Y as isQuotaExhausted, Z as normalizeSidebarState, _ as SidebarAccountState, a as ActiveRoutingEntry, at as resolveActiveAccount, b as SidebarRoutingAccount, c as DEFAULT_SIDEBAR_STATE, ct as resolveSidebarStickyAssignment, d as QuotaPacing, dt as setSidebarState, et as planSidebarStickyAssignmentFromSnapshot, f as QuotaWindow, ft as settleWithinBudget, g as STICKY_ASSIGNMENT_MAX_ENTRIES, h as STICKY_ASSIGNMENT_MAX_AGE_MS, ht as upsertSidebarActiveRouting, i as AccountQuota, it as removeSidebarActiveRouting, j as accountCreditsText, k as StickyPinOverlay, l as HOT_PATH_READ_BUDGET_MS, lt as setSidebarLegacyRouting, m as ResolveStickyAssignmentInput, mt as spendControlExhaustedResetAt, n as ACTIVE_ROUTING_MAX_ENTRIES, nt as pruneStickyAssignments, o as ActiveRoutingMap, ot as resolveSessionSidebarRouting, p as QuotaWindowKey, pt as sidebarQuotaProjection, q as getSidebarStateFile, r as AccountCredits, rt as rememberStickyPin, s as CollapsedAccountLine, st as resolveSessionStickyAccount, t as ACTIVE_ROUTING_MAX_AGE_MS, tt as pruneActiveRouting, u as PresentQuotaWindow, ut as setSidebarMachineState, v as SidebarBookkeepingQueue, w as SpendControlReading, x as SidebarSnapshot, y as SidebarMachineState, z as drainSidebarWrites } from "./sidebar-state-DHsZ9axt.js";
2
+ export { ACTIVE_ROUTING_MAX_AGE_MS, ACTIVE_ROUTING_MAX_ENTRIES, AccountCredits, AccountQuota, ActiveRoutingEntry, ActiveRoutingMap, CollapsedAccountLine, DEFAULT_SIDEBAR_STATE, HOT_PATH_READ_BUDGET_MS, PresentQuotaWindow, QuotaPacing, QuotaWindow, QuotaWindowKey, ResolveStickyAssignmentInput, STICKY_ASSIGNMENT_MAX_AGE_MS, STICKY_ASSIGNMENT_MAX_ENTRIES, SidebarAccountState, SidebarBookkeepingQueue, SidebarMachineState, SidebarRoutingAccount, SidebarSnapshot, SidebarState, SidebarStateCache, SpendControlReading, StickyAssignment, StickyAssignmentChoice, StickyAssignmentMap, StickyAssignmentPlan, StickyPinOverlay, StickyPinOverlayEntry, accountCreditsText, accountServesOnCredits, applyStickyPinOverlay, clearSidebarStickyAssignment, computeQuotaPacing, createSidebarBookkeepingQueue, createSidebarStateCache, displayWidth, drainSidebarWrites, exhaustedQuotaResetAt, fitCollapsedLabel, formatWindowLabel, getCollapsedAccountLines, getCollapsedQuotaSummary, getPresentQuotaWindows, getSidebarState, getSidebarStateFile, hashSidebarSessionId, isQuotaExhausted, isUsableRoutingEntry, normalizeSidebarState, persistSidebarStickyAssignment, planSidebarStickyAssignment, planSidebarStickyAssignmentFromSnapshot, pruneActiveRouting, pruneStickyAssignments, rememberStickyPin, removeSidebarActiveRouting, resolveActiveAccount, resolveSessionSidebarRouting, resolveSessionStickyAccount, resolveSidebarStickyAssignment, setSidebarLegacyRouting, setSidebarMachineState, setSidebarState, settleWithinBudget, sidebarQuotaProjection, spendControlExhaustedResetAt, upsertSidebarActiveRouting };
@@ -1 +1 @@
1
- import{$b as v,Gb as a,Hb as b,Ib as c,Jb as d,Kb as e,Lb as f,Mb as g,Nb as h,Ob as i,Pb as j,Qb as k,Rb as l,Sb as m,Tb as n,Ub as o,Vb as p,Wb as q,Xb as r,Yb as s,Zb as t,_b as u,ac as w,bc as x,cc as y,dc as z,ec as A,fc as B,gc as C,hc as D,ic as E,jc as F,kc as G,lc as H,mc as I,nc as J,oc as K,pc as L,qc as M,rc as N,sc as O,tc as P,uc as Q,vc as R,wc as S,xc as T}from"./index-1qxz4s8a.js";import"./index-ge60xry3.js";import"./index-8xq099qf.js";import"./index-b0ty9qam.js";import"./index-7nmdsmpp.js";import"./index-ya9c5e4m.js";export{y as upsertSidebarActiveRouting,p as spendControlExhaustedResetAt,O as sidebarQuotaProjection,I as settleWithinBudget,w as setSidebarState,x as setSidebarMachineState,z as setSidebarLegacyRouting,e as setLegacySidebarStateFileForTest,C as resolveSidebarStickyAssignment,s as resolveSessionStickyAccount,t as resolveSessionSidebarRouting,N as resolveActiveAccount,A as removeSidebarActiveRouting,K as rememberStickyPin,v as pruneStickyAssignments,u as pruneActiveRouting,D as planSidebarStickyAssignmentFromSnapshot,B as planSidebarStickyAssignment,E as persistSidebarStickyAssignment,k as normalizeSidebarState,o as isUsableRoutingEntry,r as isQuotaExhausted,h as hashSidebarSessionId,i as getSidebarStateFile,l as getSidebarState,d as getPresentQuotaWindows,P as getCollapsedQuotaSummary,Q as getCollapsedAccountLines,c as formatWindowLabel,S as fitCollapsedLabel,q as exhaustedQuotaResetAt,G as drainSidebarWrites,R as displayWidth,J as createSidebarStateCache,M as createSidebarBookkeepingQueue,T as computeQuotaPacing,F as clearSidebarStickyAssignment,L as applyStickyPinOverlay,b as accountServesOnCredits,a as accountCreditsText,g as STICKY_ASSIGNMENT_MAX_ENTRIES,f as STICKY_ASSIGNMENT_MAX_AGE_MS,H as HOT_PATH_READ_BUDGET_MS,j as DEFAULT_SIDEBAR_STATE,n as ACTIVE_ROUTING_MAX_ENTRIES,m as ACTIVE_ROUTING_MAX_AGE_MS};
1
+ import{$b as u,Hb as a,Ib as b,Jb as c,Kb as d,Lb as e,Mb as f,Nb as g,Ob as h,Pb as i,Qb as j,Rb as k,Sb as l,Tb as m,Ub as n,Vb as o,Wb as p,Xb as q,Yb as r,Zb as s,_b as t,ac as v,bc as w,cc as x,dc as y,ec as z,fc as A,gc as B,hc as C,ic as D,jc as E,kc as F,lc as G,mc as H,nc as I,oc as J,pc as K,qc as L,rc as M,sc as N,tc as O,uc as P,vc as Q,wc as R,xc as S,yc as T}from"./index-2e2kqmsy.js";import"./index-apkavdvq.js";import"./index-dr93b3g6.js";import"./index-7zy4vdd3.js";import"./index-yayz83vv.js";import"./index-jaqm1xda.js";export{y as upsertSidebarActiveRouting,p as spendControlExhaustedResetAt,O as sidebarQuotaProjection,I as settleWithinBudget,w as setSidebarState,x as setSidebarMachineState,z as setSidebarLegacyRouting,e as setLegacySidebarStateFileForTest,C as resolveSidebarStickyAssignment,s as resolveSessionStickyAccount,t as resolveSessionSidebarRouting,N as resolveActiveAccount,A as removeSidebarActiveRouting,K as rememberStickyPin,v as pruneStickyAssignments,u as pruneActiveRouting,D as planSidebarStickyAssignmentFromSnapshot,B as planSidebarStickyAssignment,E as persistSidebarStickyAssignment,k as normalizeSidebarState,o as isUsableRoutingEntry,r as isQuotaExhausted,h as hashSidebarSessionId,i as getSidebarStateFile,l as getSidebarState,d as getPresentQuotaWindows,P as getCollapsedQuotaSummary,Q as getCollapsedAccountLines,c as formatWindowLabel,S as fitCollapsedLabel,q as exhaustedQuotaResetAt,G as drainSidebarWrites,R as displayWidth,J as createSidebarStateCache,M as createSidebarBookkeepingQueue,T as computeQuotaPacing,F as clearSidebarStickyAssignment,L as applyStickyPinOverlay,b as accountServesOnCredits,a as accountCreditsText,g as STICKY_ASSIGNMENT_MAX_ENTRIES,f as STICKY_ASSIGNMENT_MAX_AGE_MS,H as HOT_PATH_READ_BUDGET_MS,j as DEFAULT_SIDEBAR_STATE,n as ACTIVE_ROUTING_MAX_ENTRIES,m as ACTIVE_ROUTING_MAX_AGE_MS};
@@ -1 +1 @@
1
- import{a as U,b as V}from"./index-jkpg9d1p.js";import{jf as R}from"./index-ya9c5e4m.js";var E=R((M,Q)=>{var{defineProperty:H,getOwnPropertyDescriptor:W,getOwnPropertyNames:X}=Object,Y=Object.prototype.hasOwnProperty,Z=(z,q)=>{for(var B in q)H(z,B,{get:q[B],enumerable:!0})},$=(z,q,B,F)=>{if(q&&typeof q==="object"||typeof q==="function"){for(let v of X(q))if(!Y.call(z,v)&&v!==B)H(z,v,{get:()=>q[v],enumerable:!(F=W(q,v))||F.enumerable})}return z},A=(z)=>$(H({},"__esModule",{value:!0}),z),L={};Z(L,{refreshToken:()=>D});Q.exports=A(L);var K=U(),G=V();async function D(z){let q=z?.project,B=z?.team;if(!q&&!B){let v=(0,G.findProjectInfo)();q=v.projectId,B=v.teamId}else if(!q||!B){let v=(0,G.findProjectInfo)();q=q??v.projectId,B=B??v.teamId}if(!q)throw new K.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let F=(0,G.loadToken)(q);if(!F||(0,G.isExpired)((0,G.getTokenPayload)(F.token),z?.expirationBufferMs)){let v=await(0,G.getVercelToken)({expirationBufferMs:z?.expirationBufferMs});if(F=await(0,G.getVercelOidcToken)(v,q,B),!F)throw new K.VercelOidcTokenError("Failed to refresh OIDC token");(0,G.saveToken)(F,q)}process.env.VERCEL_OIDC_TOKEN=F.token;return}});export default E();
1
+ import{a as U,b as V}from"./index-g08eptzm.js";import{kf as R}from"./index-jaqm1xda.js";var E=R((M,Q)=>{var{defineProperty:H,getOwnPropertyDescriptor:W,getOwnPropertyNames:X}=Object,Y=Object.prototype.hasOwnProperty,Z=(z,q)=>{for(var B in q)H(z,B,{get:q[B],enumerable:!0})},$=(z,q,B,F)=>{if(q&&typeof q==="object"||typeof q==="function"){for(let v of X(q))if(!Y.call(z,v)&&v!==B)H(z,v,{get:()=>q[v],enumerable:!(F=W(q,v))||F.enumerable})}return z},A=(z)=>$(H({},"__esModule",{value:!0}),z),L={};Z(L,{refreshToken:()=>D});Q.exports=A(L);var K=U(),G=V();async function D(z){let q=z?.project,B=z?.team;if(!q&&!B){let v=(0,G.findProjectInfo)();q=v.projectId,B=v.teamId}else if(!q||!B){let v=(0,G.findProjectInfo)();q=q??v.projectId,B=B??v.teamId}if(!q)throw new K.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let F=(0,G.loadToken)(q);if(!F||(0,G.isExpired)((0,G.getTokenPayload)(F.token),z?.expirationBufferMs)){let v=await(0,G.getVercelToken)({expirationBufferMs:z?.expirationBufferMs});if(F=await(0,G.getVercelOidcToken)(v,q,B),!F)throw new K.VercelOidcTokenError("Failed to refresh OIDC token");(0,G.saveToken)(F,q)}process.env.VERCEL_OIDC_TOKEN=F.token;return}});export default E();
@@ -0,0 +1 @@
1
+ import{b as a}from"./index-g08eptzm.js";import"./index-jaqm1xda.js";export default a();
@@ -1,4 +1,4 @@
1
- import{qe as h,we as u,xe as P}from"./index-8xq099qf.js";import{We as M,Xe as R,af as S}from"./index-7nmdsmpp.js";import"./index-ya9c5e4m.js";import{mkdir as Yq,writeFile as Vq}from"node:fs/promises";import{homedir as Wq}from"node:os";import{dirname as Dq,join as b}from"node:path";import{applyEdits as t,modify as r,parse as e}from"jsonc-parser";function qq(z){return z!==null&&typeof z==="object"&&!Array.isArray(z)}async function k(z){try{let q=[],H=e(await S(z,M),q,{allowTrailingComma:!0});return q.length===0&&qq(H)?H:{}}catch(q){if(q instanceof R&&q.code!=="ENOENT")throw q;return{}}}var zq=`// Shared preferences for TUI plugins.
1
+ import{re as h,xe as u,ye as P}from"./index-dr93b3g6.js";import{Xe as M,Ye as R,bf as S}from"./index-yayz83vv.js";import"./index-jaqm1xda.js";import{mkdir as Yq,writeFile as Vq}from"node:fs/promises";import{homedir as Wq}from"node:os";import{dirname as Dq,join as b}from"node:path";import{applyEdits as t,modify as r,parse as e}from"jsonc-parser";function qq(z){return z!==null&&typeof z==="object"&&!Array.isArray(z)}async function k(z){try{let q=[],H=e(await S(z,M),q,{allowTrailingComma:!0});return q.length===0&&qq(H)?H:{}}catch(q){if(q instanceof R&&q.code!=="ENOENT")throw q;return{}}}var zq=`// Shared preferences for TUI plugins.
2
2
  // Plugins update individual keys in place and preserve comments.
3
3
  {}
4
4
  `;function g(z){let{file:q,pluginKey:H,beforeCommit:Q}=z,$={...P.preferences,timeoutMs:z.timeoutMs??P.preferences.timeoutMs},Z=Promise.resolve();async function X(U,j){await u(q,$,async(K)=>{let J;try{J=await S(q,M)}catch(G){if(G.code!=="ENOENT")throw G;J=""}if(J.trim()==="")J=zq;let B=t(J,r(J,[H,...U],j,{formattingOptions:{insertSpaces:!0,tabSize:2}}));await h(q,B,{serialize:(G)=>String(G),beforeRename:async()=>{await Q?.(),await K.assertOwned()}})})}return{queueTuiPreferenceUpdate(U,j){let K=[...U],J=structuredClone(j),B=Z.then(()=>X(K,J));return Z=B.catch(()=>{}),B}}}import{readFileSync as Hq,realpathSync as Qq,statSync as Xq,watch as Zq}from"node:fs";import{readFile as $q,stat as Bq}from"node:fs/promises";import{basename as p,dirname as s,join as Gq,resolve as Jq}from"node:path";import{clearTimeout as w,setTimeout as c}from"node:timers";function n(z){let q=Jq(z);if(M)return q;try{return Qq(q)}catch{let H=s(q);return H===q?q:Gq(n(H),p(q))}}function d(z){return z&&`${z.dev}:${z.ino}:${z.mtimeMs}:${z.size}`}function T(z,q,H={}){let Q=globalThis,$=Symbol.for("cortexkit.common-auth.tui-prefs.watchers.v1"),Z=Q[$]??new Map;Q[$]=Z;let X=n(z),U=Z.get(X);if(U)return U.subscribe(q);let j=p(X),K=M?(Y)=>S(Y):H.fs?.readFile??((Y)=>$q(Y,"utf8")),J=H.fs?.stat??Bq,B=null,G=null,x=null,C=null;if(!M)try{let Y=d((H.fs?.statSync??Xq)(X));C=(H.fs?.readFileSync??((V)=>Hq(V,"utf8")))(X),x=Y}catch{}let N=!1,L=new Set,E=Promise.resolve(),v=(Y)=>{return E=E.then(async()=>{if(N)return;let V=d(await J(X).catch(()=>null));if(!Y&&V===x)return;if(V===null){x=null;return}let I=await K(X).catch((W)=>{if(W instanceof R&&W.code!=="ENOENT")if(H.onError)H.onError(W);else process.emitWarning(W.message,W.name);return null});if(N)return;if(I===null)return;if(x=V,I===C)return;C=I;for(let W of[...L]){if(!L.has(W))continue;try{W.notify()}catch{}}}),E},i=()=>{if(N)return;if(B)w(B);B=c(()=>{B=null,v(!0)},150)},O=null;try{O=(H.watchDirectory??Zq)(s(X),(Y,V)=>{let I=V?.toString(),W=I===j||I?.startsWith(`${j}.`)&&I.endsWith(".tmp");if(I!=null&&!W)return;i()}),O.on("error",()=>{O?.close(),O=null})}catch{}let f=()=>{if(N||G)return;G=c(()=>{if(G=null,N)return;v(!1).finally(f)},1000),G.unref()},F={subscribe:(Y)=>{let V={notify:Y};return L.add(V),()=>{if(!L.delete(V)||L.size>0)return;if(N=!0,B)w(B);if(G)w(G);if(O?.close(),Z.get(X)===F)Z.delete(X)}}};return Z.set(X,F),f(),F.subscribe(q)}var Uq="OPENCODE_TUI_PREFERENCES_FILE",Iq="tui-preferences.jsonc";function m(){let z=process.env[Uq];if(z)return z;let q=process.env.OPENCODE_CONFIG_DIR||b(process.env.XDG_CONFIG_HOME||b(Wq(),".config"),"opencode");return b(q,Iq)}function _(z){return typeof z==="object"&&z!==null&&!Array.isArray(z)}function dq(){return k(m())}var Mq="openai-auth",Aq=160,l={forceToTop:!1,order:Aq,startCollapsed:!1,rememberCollapsed:!0,collapsed:null,pollMs:1500,refreshDebounceMs:200,header:{label:"OPENAI",showVersion:!0},sections:{quota:!0,fallbackAccounts:!0,routing:!0,health:!0,pacing:!0},appearance:{barWidth:10,barFilledChar:"█",barEmptyChar:"░",warnThreshold:50,errorThreshold:80}};function D(z,q){return typeof z==="boolean"?z:q}function A(z,q,H,Q){if(typeof z!=="number"||!Number.isFinite(z))return q;return Math.min(Math.max(Math.round(z),H),Q)}function jq(z,q,H){if(typeof z!=="string"||z.length===0)return q;return z.slice(0,H)}function o(z,q){if(typeof z!=="string")return q;return[...z][0]??q}function pq(z){let q=z[Mq];if(!_(q))return structuredClone(l);let H=l,Q=_(q.header)?q.header:{},$=_(q.sections)?q.sections:{},Z=_(q.appearance)?q.appearance:{},X=A(Z.warnThreshold,H.appearance.warnThreshold,0,99),U=Math.max(A(Z.errorThreshold,H.appearance.errorThreshold,0,100),Math.min(X+1,100));return{forceToTop:D(q.forceToTop,H.forceToTop),order:A(q.order,H.order,-1e4,1e4),startCollapsed:D(q.startCollapsed,H.startCollapsed),rememberCollapsed:D(q.rememberCollapsed,H.rememberCollapsed),collapsed:typeof q.collapsed==="boolean"?q.collapsed:null,pollMs:A(q.pollMs,H.pollMs,500,30000),refreshDebounceMs:A(q.refreshDebounceMs,H.refreshDebounceMs,50,5000),header:{label:jq(Q.label,H.header.label,20),showVersion:D(Q.showVersion,H.header.showVersion)},sections:{quota:D($.quota,H.sections.quota),fallbackAccounts:D($.fallbackAccounts,H.sections.fallbackAccounts),routing:D($.routing,H.sections.routing),health:D($.health,H.sections.health),pacing:D($.pacing,H.sections.pacing)},appearance:{barWidth:A(Z.barWidth,H.appearance.barWidth,4,40),barFilledChar:o(Z.barFilledChar,H.appearance.barFilledChar),barEmptyChar:o(Z.barEmptyChar,H.appearance.barEmptyChar),warnThreshold:X,errorThreshold:U}}}var Nq=-1e5;function sq(z,q,H){let Q=z[q];if(!_(Q))return H;if(Q.forceToTop===!0)return Nq+Object.keys(z).indexOf(q);return A(Q.order,H,-1e4,1e4)}var Kq=`// Shared preferences for opencode TUI plugins.
package/dist/tui.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { S as SidebarState, d as QuotaPacing, f as QuotaWindow, i as AccountQuota, w as SpendControlReading } from "./sidebar-state-Bb9L9oPq.js";
2
- import { i as OpenDialogPayload, n as ApplyResult, t as ApplyRequest } from "./protocol-CK9guiFy.js";
1
+ import { i as OpenDialogPayload, n as ApplyResult, t as ApplyRequest } from "./protocol-BeeDdtpa.js";
2
+ import { S as SidebarState, d as QuotaPacing, f as QuotaWindow, i as AccountQuota, w as SpendControlReading } from "./sidebar-state-DHsZ9axt.js";
3
+ import { t as RpcClient } from "./rpc-client-DlR9a0_7.js";
3
4
  import { Plugin } from "@opencode/plugin/tui";
4
5
  import { TuiPluginApi, TuiPluginModule } from "@opencode-ai/plugin/tui";
5
6
  import { JSX } from "solid-js";
@@ -14,6 +15,14 @@ interface TuiTransportOptions {
14
15
  dispose(): void;
15
16
  };
16
17
  openDialog?: (payload: OpenDialogPayload, apply: (request: Omit<ApplyRequest, 'sessionId'>) => Promise<ApplyResult>) => Promise<void>;
18
+ /**
19
+ * Builds the RPC client the poll drains. Tests inject failures here; a
20
+ * host setup that runs again needs its own RPC client.
21
+ */
22
+ createRpcClient?: (dir: string, expectedPid?: number) => RpcClient;
23
+ /** Timer seam so tests can drive poll cycles without wall-clock waits. */
24
+ setIntervalImpl?: typeof globalThis.setInterval;
25
+ clearIntervalImpl?: typeof globalThis.clearInterval;
17
26
  }
18
27
  //#endregion
19
28
  //#region src/tui.d.ts
@@ -1,5 +1,5 @@
1
- import { h as BeginAccountLoginResult, i as CodexSessionMetadata, m as BeginAccountLoginOptions, o as PoolLifecycleDeps, p as OpenAiVaultOptions, r as CodexRequestRuntime, s as HostSlotAdapter, x as AccountPaths } from "../codex-request-D_In8uaR.js";
2
- import { i as OpenDialogPayload, n as ApplyResult } from "../protocol-CK9guiFy.js";
1
+ import { _ as AccountPaths, d as BeginAccountLoginOptions, f as BeginAccountLoginResult, i as CodexSessionMetadata, o as PoolLifecycleDeps, r as CodexRequestRuntime, s as HostSlotAdapter, u as OpenAiVaultOptions } from "../codex-request-CN4rD2kf.js";
2
+ import { i as OpenDialogPayload, n as ApplyResult } from "../protocol-BeeDdtpa.js";
3
3
  import { Plugin } from "@opencode/plugin";
4
4
  import "@opencode/plugin/promise/session";
5
5
  import "@opencode/plugin/promise/integration";