@cortexkit/opencode-openai-auth 0.7.2 → 0.9.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/README.md +9 -5
- package/dist/index-301y4qa1.js +2 -0
- package/dist/index-338z7171.js +211 -0
- package/dist/index-5y4vzdf8.js +2 -0
- package/dist/{index-zxqb5ydj.js → index-9ehhb051.js} +1 -1
- package/dist/{index-zg1x8sty.js → index-jwn4r3sw.js} +1 -1
- package/dist/{index-9jpc8yct.js → index-sdt2d2ra.js} +1 -1
- package/dist/index-w42s0g6m.js +2 -0
- package/dist/index.d.ts +213 -36
- package/dist/index.js +59 -154
- package/dist/internal-Y7QNVDJT.d.ts +908 -0
- package/dist/quota-normalize-3qffywcm.js +1 -0
- package/dist/rpc/port-file.d.ts +11 -9
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/protocol.d.ts +2 -21
- package/dist/rpc/rpc-client.d.ts +7 -4
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.d.ts +7 -5
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/sidebar-state-B98sERYt.d.ts +219 -0
- package/dist/sidebar-state.d.ts +2 -171
- package/dist/sidebar-state.js +1 -1
- package/dist/{token-bvp0y166.js → token-9823y0pc.js} +1 -1
- package/dist/token-util-ypgz7rge.js +1 -0
- package/dist/tui-preferences.d.ts +27 -26
- package/dist/tui-preferences.js +1 -1
- package/dist/tui.d.ts +42 -19
- package/package.json +8 -14
- package/src/tui/entry.mjs +2 -2
- package/src/tui-compiled/{core/account-paths.ts → raw/core-account-paths.ts} +29 -18
- package/src/tui-compiled/raw/core-custody-state.ts +243 -0
- package/src/tui-compiled/raw/logger.ts +53 -0
- package/src/tui-compiled/{rpc/port-file.ts → raw/rpc-port-file.ts} +1 -1
- package/src/tui-compiled/raw/rpc-protocol.ts +12 -0
- package/src/{rpc/rpc-client.ts → tui-compiled/raw/rpc-rpc-client.ts} +2 -2
- package/src/{sidebar-state.ts → tui-compiled/raw/sidebar-state.ts} +142 -13
- package/src/{tui/command-dialogs.tsx → tui-compiled/raw/tui-command-dialogs.tsx} +94 -44
- package/src/{tui.tsx → tui-compiled/raw/tui.tsx} +149 -28
- package/src/{core/account-paths.ts → tui-compiled/runtime/core-account-paths.ts} +29 -18
- package/src/tui-compiled/runtime/core-custody-state.ts +243 -0
- package/src/tui-compiled/runtime/logger.ts +53 -0
- package/src/{rpc/port-file.ts → tui-compiled/runtime/rpc-port-file.ts} +1 -1
- package/src/tui-compiled/runtime/rpc-protocol.ts +12 -0
- package/src/tui-compiled/{rpc/rpc-client.ts → runtime/rpc-rpc-client.ts} +2 -2
- package/src/tui-compiled/{sidebar-state.ts → runtime/sidebar-state.ts} +142 -13
- package/src/tui-compiled/{tui/command-dialogs.tsx → runtime/tui-command-dialogs.tsx} +73 -37
- package/src/tui-compiled/{tui.tsx → runtime/tui.tsx} +251 -153
- package/src/tui-compiled/shared/internal.ts +6 -0
- package/src/{logger.ts → tui-compiled/shared/logger.ts} +91 -23
- package/src/tui-compiled/shared/paths.ts +33 -0
- package/src/{core → tui-compiled/shared}/refresh-file-lock.ts +7 -4
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -15
- package/dist/codex-http.d.ts +0 -3
- package/dist/commands.d.ts +0 -88
- package/dist/config.d.ts +0 -47
- package/dist/core/account-paths.d.ts +0 -25
- package/dist/core/accounts.d.ts +0 -330
- package/dist/core/atomic-write.d.ts +0 -1
- package/dist/core/background-quota-refresh.d.ts +0 -46
- package/dist/core/backoff.d.ts +0 -53
- package/dist/core/cachekeep.d.ts +0 -118
- package/dist/core/oauth.d.ts +0 -138
- package/dist/core/provider.d.ts +0 -70
- package/dist/core/quota-manager.d.ts +0 -192
- package/dist/core/refresh-all-quota.d.ts +0 -86
- package/dist/core/refresh-file-lock.d.ts +0 -12
- package/dist/core/reset-credits.d.ts +0 -116
- package/dist/core/sticky-routing.d.ts +0 -43
- package/dist/dump.d.ts +0 -20
- package/dist/hosted-web-search.d.ts +0 -5
- package/dist/index-87145jkw.js +0 -2
- package/dist/index-8f1200qx.js +0 -6
- package/dist/index-cfjed1st.js +0 -89
- package/dist/index-nrvjr97q.js +0 -3
- package/dist/index-qaggaze1.js +0 -2
- package/dist/index-sdcpzbnk.js +0 -2
- package/dist/logger.d.ts +0 -22
- package/dist/model-costs.d.ts +0 -29
- package/dist/prompt-context.d.ts +0 -19
- package/dist/quota-normalize-dvwtmy7f.js +0 -1
- package/dist/quota-normalize.d.ts +0 -43
- package/dist/raw-ws-bun.d.ts +0 -40
- package/dist/raw-ws-node.d.ts +0 -37
- package/dist/raw-ws-upgrade.d.ts +0 -2
- package/dist/raw-ws.d.ts +0 -3
- package/dist/response-stream-error.d.ts +0 -12
- package/dist/rpc/notifications.d.ts +0 -5
- package/dist/rpc/rpc-server.d.ts +0 -17
- package/dist/token-util-jcj7k7pa.js +0 -1
- package/dist/tui/command-dialogs.d.ts +0 -21
- package/dist/util/error.d.ts +0 -1
- package/dist/util/open-url.d.ts +0 -6
- package/dist/util/proxy-env.d.ts +0 -4
- package/dist/util/record.d.ts +0 -1
- package/dist/util/stable-json.d.ts +0 -1
- package/dist/util/uuid-v7.d.ts +0 -1
- package/dist/version.d.ts +0 -1
- package/dist/ws-pool.d.ts +0 -57
- package/dist/ws.d.ts +0 -71
- package/src/rpc/notifications.ts +0 -54
- package/src/rpc/protocol.ts +0 -33
- package/src/rpc/rpc-server.ts +0 -172
- package/src/tui-compiled/core/refresh-file-lock.ts +0 -381
- package/src/tui-compiled/logger.ts +0 -196
- package/src/tui-compiled/rpc/protocol.ts +0 -33
- package/src/util/error.ts +0 -9
- package/src/util/open-url.ts +0 -30
- package/src/util/proxy-env.ts +0 -42
- package/src/util/record.ts +0 -3
- package/src/util/stable-json.ts +0 -15
- package/src/util/uuid-v7.ts +0 -18
- /package/src/{rpc/rpc-dir.ts → tui-compiled/raw/rpc-rpc-dir.ts} +0 -0
- /package/src/tui-compiled/{tui-preferences.ts → raw/tui-preferences.ts} +0 -0
- /package/src/tui-compiled/{rpc/rpc-dir.ts → runtime/rpc-rpc-dir.ts} +0 -0
- /package/src/{tui-preferences.ts → tui-compiled/runtime/tui-preferences.ts} +0 -0
- /package/src/tui-compiled/{util → shared/util}/error.ts +0 -0
- /package/src/tui-compiled/{util → shared/util}/open-url.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{lb as a,mb as b,nb as c,ob as d,pb as e}from"./index-301y4qa1.js";import"./index-9ehhb051.js";export{a as toResetIso,d as normalizeWsFrame,e as normalizeWham,b as normalizeQuotaHeaders,c as isCompleteQuotaHeaderFrame};
|
package/dist/rpc/port-file.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
//#region src/rpc/port-file.d.ts
|
|
1
2
|
export interface PortFileEntry {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
port: number;
|
|
4
|
+
token: string;
|
|
5
|
+
pid: number;
|
|
6
|
+
startedAt: number;
|
|
6
7
|
}
|
|
7
8
|
export declare function writePortFile(dir: string, entry: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
port: number;
|
|
10
|
+
token: string;
|
|
11
|
+
pid: number;
|
|
11
12
|
}, options?: {
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
secureDir?: boolean;
|
|
14
|
+
beforeWrite?: () => void | Promise<void>;
|
|
14
15
|
}): Promise<string>;
|
|
15
16
|
export declare function sweepRpcState(root: string, activeDir: string): Promise<void>;
|
|
16
17
|
export declare function discoverPortFile(dir: string, expectedPid?: number): Promise<PortFileEntry | null>;
|
|
18
|
+
//#endregion
|
package/dist/rpc/port-file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{I as a,J as b,K as c}from"../index-w42s0g6m.js";import"../index-338z7171.js";import"../index-301y4qa1.js";import"../index-9ehhb051.js";export{a as writePortFile,b as sweepRpcState,c as discoverPortFile};
|
package/dist/rpc/protocol.d.ts
CHANGED
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
command: CommandModalName;
|
|
4
|
-
text: string;
|
|
5
|
-
knobs: Record<string, unknown>;
|
|
6
|
-
}
|
|
7
|
-
export interface RpcNotification {
|
|
8
|
-
id: number;
|
|
9
|
-
type: 'open-dialog';
|
|
10
|
-
payload: OpenDialogPayload;
|
|
11
|
-
sessionId?: string;
|
|
12
|
-
}
|
|
13
|
-
export interface ApplyRequest {
|
|
14
|
-
command: CommandModalName;
|
|
15
|
-
arguments: string;
|
|
16
|
-
sessionId?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface ApplyResult {
|
|
19
|
-
text: string;
|
|
20
|
-
knobs: Record<string, unknown>;
|
|
21
|
-
}
|
|
1
|
+
import { a as CommandModalName, i as ApplyResult, o as OpenDialogPayload, r as ApplyRequest, s as RpcNotification } from "../internal-Y7QNVDJT.js";
|
|
2
|
+
export type { ApplyRequest, ApplyResult, CommandModalName, OpenDialogPayload, RpcNotification };
|
package/dist/rpc/rpc-client.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { i as ApplyResult, r as ApplyRequest, s as RpcNotification } from "../internal-Y7QNVDJT.js";
|
|
2
|
+
import { PortFileEntry } from "./port-file.js";
|
|
3
|
+
import "./protocol.js";
|
|
4
|
+
//#region src/rpc/rpc-client.d.ts
|
|
3
5
|
export interface RpcClient {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
pending: (lastReceivedId: number, sessionId?: string) => Promise<RpcNotification[]>;
|
|
7
|
+
apply: (request: ApplyRequest, timeoutMs?: number) => Promise<ApplyResult>;
|
|
6
8
|
}
|
|
7
9
|
export declare const DEFAULT_RPC_TIMEOUT_MS = 2000;
|
|
8
10
|
export declare function createRpcClient(dir: string, expectedPid?: number, onSelected?: (entry: PortFileEntry | null) => void): RpcClient;
|
|
11
|
+
//#endregion
|
package/dist/rpc/rpc-client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{K as c}from"../index-w42s0g6m.js";import"../index-338z7171.js";import"../index-301y4qa1.js";import"../index-9ehhb051.js";var y=2000;async function p(n,r,s,o,i,e=y){let t=await c(n,r);if(s?.(t),!t)return null;let l=new AbortController,u=setTimeout(()=>l.abort(),e);try{let a=await fetch(`http://127.0.0.1:${t.port}/rpc/${o}`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${t.token}`},body:JSON.stringify(i),signal:l.signal});if(!a.ok)return null;return await a.json()}catch{return null}finally{clearTimeout(u)}}function m(n,r,s){let o=!1,i=(e)=>{if(o)return;o=!0,s?.(e)};return{async pending(e,t){return(await p(n,r,i,"pending-notifications",{lastReceivedId:e,sessionId:t}))?.messages??[]},async apply(e,t){return await p(n,r,i,"apply",{...e},t)??{text:"apply failed",knobs:{}}}}}export{m as createRpcClient,y as DEFAULT_RPC_TIMEOUT_MS};
|
package/dist/rpc/rpc-dir.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { tmpdir } from
|
|
1
|
+
import { tmpdir } from "node:os";
|
|
2
|
+
//#region src/rpc/rpc-dir.d.ts
|
|
2
3
|
export interface RpcDirResolution {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
dir: string;
|
|
5
|
+
secureDir: boolean;
|
|
6
|
+
sweepRoot?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare function getRpcDir(projectDirectory: string): string;
|
|
8
9
|
export declare function resolveRpcDir(projectDirectory: string): Promise<RpcDirResolution>;
|
|
9
|
-
|
|
10
|
+
//#endregion
|
|
11
|
+
export { tmpdir };
|
package/dist/rpc/rpc-dir.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ib as a,jb as b,kb as c}from"../index-jwn4r3sw.js";import"../index-9ehhb051.js";export{a as tmpdir,c as resolveRpcDir,b as getRpcDir};
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
//#region src/core/custody-state.d.ts
|
|
2
|
+
type VaultCustodyState = 'serves' | 'cold' | 'needs_reauth' | 'identity_mismatch' | 'no_handle';
|
|
3
|
+
declare const CUSTODY_INERT_REASONS: readonly ['needs-login', 'mode-mismatch', 'corrupt-under-binding', 'manifest-unreadable', 'unbound-under-claustrum', 'orphan-tombstone', 'vault-cold', 'vault-reauth', 'identity-mismatch', 'no-handle', 'takeover-incomplete', 'new-local-family-under-claustrum', 'takeover-incomplete/vault-unavailable', 'takeover-incomplete/slot-absent'];
|
|
4
|
+
type CustodyInertReason = (typeof CUSTODY_INERT_REASONS)[number];
|
|
5
|
+
type CustodyVerdict = {
|
|
6
|
+
kind: 'LOCAL';
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'VAULT';
|
|
9
|
+
canonicalize?: boolean;
|
|
10
|
+
installTombstone?: boolean;
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'INERT';
|
|
13
|
+
reason: CustodyInertReason;
|
|
14
|
+
installTombstone?: boolean;
|
|
15
|
+
canonicalize?: boolean;
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'NEEDS_LOGIN';
|
|
18
|
+
reason?: 'corrupt';
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/sidebar-state.d.ts
|
|
22
|
+
interface QuotaWindow {
|
|
23
|
+
usedPercent: number;
|
|
24
|
+
remainingPercent: number;
|
|
25
|
+
checkedAt?: number;
|
|
26
|
+
resetsAt?: string;
|
|
27
|
+
windowMinutes?: number;
|
|
28
|
+
}
|
|
29
|
+
interface SpendControlReading {
|
|
30
|
+
limit: number;
|
|
31
|
+
used: number;
|
|
32
|
+
remaining: number;
|
|
33
|
+
usedPercent: number;
|
|
34
|
+
remainingPercent: number;
|
|
35
|
+
resetsAt?: string;
|
|
36
|
+
unit?: string;
|
|
37
|
+
source?: string;
|
|
38
|
+
reached: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface AccountQuota {
|
|
41
|
+
checkedAt?: number;
|
|
42
|
+
primary?: QuotaWindow;
|
|
43
|
+
secondary?: QuotaWindow;
|
|
44
|
+
spendControl?: SpendControlReading;
|
|
45
|
+
resetCreditsAvailable?: number;
|
|
46
|
+
}
|
|
47
|
+
type QuotaWindowKey = 'primary' | 'secondary';
|
|
48
|
+
declare function formatWindowLabel(windowMinutes: number | undefined, fallbackKey: QuotaWindowKey): string;
|
|
49
|
+
interface PresentQuotaWindow {
|
|
50
|
+
key: QuotaWindowKey;
|
|
51
|
+
label: string;
|
|
52
|
+
window: QuotaWindow;
|
|
53
|
+
windowMs: number | null;
|
|
54
|
+
}
|
|
55
|
+
declare function getPresentQuotaWindows(quota: AccountQuota | null): PresentQuotaWindow[];
|
|
56
|
+
interface SidebarAccountState {
|
|
57
|
+
id: string;
|
|
58
|
+
label: string | undefined;
|
|
59
|
+
/** ChatGPT identity of the account this quota belongs to. */
|
|
60
|
+
accountId?: string;
|
|
61
|
+
quota: AccountQuota | null;
|
|
62
|
+
killed: boolean;
|
|
63
|
+
enabled: boolean;
|
|
64
|
+
resetCredits?: number;
|
|
65
|
+
custody?: SidebarAccountCustody;
|
|
66
|
+
}
|
|
67
|
+
type SidebarCustodyState = 'vault' | 'needsLogin' | 'local' | 'inert';
|
|
68
|
+
type SidebarCustodyReason = CustodyInertReason | 'corrupt';
|
|
69
|
+
interface SidebarAccountCustody {
|
|
70
|
+
state: SidebarCustodyState;
|
|
71
|
+
reason?: SidebarCustodyReason;
|
|
72
|
+
recordVersion?: number;
|
|
73
|
+
}
|
|
74
|
+
interface ActiveRoutingEntry {
|
|
75
|
+
activeId: string;
|
|
76
|
+
route: string;
|
|
77
|
+
updatedAt: number;
|
|
78
|
+
}
|
|
79
|
+
type ActiveRoutingMap = Record<string, ActiveRoutingEntry>;
|
|
80
|
+
interface StickyAssignment {
|
|
81
|
+
accountId: string;
|
|
82
|
+
wireAccountId?: string;
|
|
83
|
+
assignedAt: number;
|
|
84
|
+
lastSeenAt: number;
|
|
85
|
+
inputBytes: number;
|
|
86
|
+
quotaCheckedAt?: number;
|
|
87
|
+
}
|
|
88
|
+
type StickyAssignmentMap = Record<string, StickyAssignment>;
|
|
89
|
+
interface StickyAssignmentChoice {
|
|
90
|
+
accountId: string;
|
|
91
|
+
quotaCheckedAt?: number;
|
|
92
|
+
}
|
|
93
|
+
interface ResolveStickyAssignmentInput {
|
|
94
|
+
sessionId: string;
|
|
95
|
+
requestBytes: number;
|
|
96
|
+
now: number;
|
|
97
|
+
validPinnedAccountIds: readonly string[];
|
|
98
|
+
excludeAccountIds?: readonly string[];
|
|
99
|
+
quotaCheckedAtByAccount: Readonly<Record<string, number | undefined>>;
|
|
100
|
+
wireAccountIdByAccount?: Readonly<Record<string, string | undefined>>;
|
|
101
|
+
choose: (pendingBytes: ReadonlyMap<string, number>) => StickyAssignmentChoice | undefined;
|
|
102
|
+
}
|
|
103
|
+
interface SidebarState {
|
|
104
|
+
main: {
|
|
105
|
+
quota: AccountQuota | null;
|
|
106
|
+
/** ChatGPT identity of the main account this quota belongs to. */
|
|
107
|
+
mainAccountId?: string;
|
|
108
|
+
custody?: SidebarAccountCustody;
|
|
109
|
+
killed: boolean;
|
|
110
|
+
quotaBackedOff?: boolean;
|
|
111
|
+
quotaBackoffUntil?: number;
|
|
112
|
+
refreshBackedOff?: boolean;
|
|
113
|
+
refreshBackoffUntil?: number;
|
|
114
|
+
resetCredits?: number;
|
|
115
|
+
};
|
|
116
|
+
fallbacks: SidebarAccountState[];
|
|
117
|
+
/** @deprecated Compatibility field for readers that do not consume activeRouting. */
|
|
118
|
+
activeId: string | undefined;
|
|
119
|
+
/** Machine-global routing mode and compatibility value for older readers. */
|
|
120
|
+
route: string;
|
|
121
|
+
activeRouting?: ActiveRoutingMap;
|
|
122
|
+
stickyAssignments?: StickyAssignmentMap;
|
|
123
|
+
planType?: string;
|
|
124
|
+
credits?: number;
|
|
125
|
+
lastUpdated: number;
|
|
126
|
+
}
|
|
127
|
+
declare const STICKY_ASSIGNMENT_MAX_AGE_MS: number;
|
|
128
|
+
declare const STICKY_ASSIGNMENT_MAX_ENTRIES = 256;
|
|
129
|
+
declare function hashSidebarSessionId(sessionId: string): string;
|
|
130
|
+
declare function getSidebarStateFile(): string;
|
|
131
|
+
declare function projectCustodyForSidebar(verdict: CustodyVerdict): SidebarAccountCustody;
|
|
132
|
+
declare const DEFAULT_SIDEBAR_STATE: SidebarState;
|
|
133
|
+
/**
|
|
134
|
+
* Normalize an arbitrary parsed value into a well-formed SidebarState.
|
|
135
|
+
*
|
|
136
|
+
* JSON.parse + `as SidebarState` is an unchecked cast — a partial, old, or
|
|
137
|
+
* malformed state file passes through and the TUI's `state().main.quota` /
|
|
138
|
+
* `state().fallbacks.filter(...)` throw at runtime. This helper guarantees
|
|
139
|
+
* every required field is present and correctly typed before the value leaves
|
|
140
|
+
* the I/O boundary, so a bad file can never crash the host TUI.
|
|
141
|
+
*/
|
|
142
|
+
declare function normalizeSidebarState(raw: unknown): SidebarState;
|
|
143
|
+
declare function getSidebarState(stateFile?: string): Promise<SidebarState>;
|
|
144
|
+
declare const ACTIVE_ROUTING_MAX_AGE_MS: number;
|
|
145
|
+
declare const ACTIVE_ROUTING_MAX_ENTRIES = 128;
|
|
146
|
+
type SidebarRoutingAccount = {
|
|
147
|
+
id: string;
|
|
148
|
+
enabled?: boolean;
|
|
149
|
+
killed?: boolean;
|
|
150
|
+
};
|
|
151
|
+
declare function isUsableRoutingEntry(entry: ActiveRoutingEntry, accounts: readonly SidebarRoutingAccount[] | undefined, now?: number): boolean;
|
|
152
|
+
declare function spendControlExhaustedResetAt(quota: AccountQuota | null | undefined, now?: number): {
|
|
153
|
+
resetsAt: string;
|
|
154
|
+
resetAtMs: number;
|
|
155
|
+
} | undefined;
|
|
156
|
+
declare function exhaustedQuotaResetAt(quota: AccountQuota | null | undefined, now?: number): {
|
|
157
|
+
resetsAt: string;
|
|
158
|
+
resetAtMs: number;
|
|
159
|
+
} | undefined;
|
|
160
|
+
declare function isQuotaExhausted(quota: AccountQuota | null | undefined, now?: number): boolean;
|
|
161
|
+
declare function resolveSessionStickyAccount(state: SidebarState, sessionId: string | undefined, now?: number): string | undefined;
|
|
162
|
+
declare function resolveSessionSidebarRouting(state: SidebarState, sessionId?: string, now?: number): {
|
|
163
|
+
activeId: string;
|
|
164
|
+
route: string;
|
|
165
|
+
};
|
|
166
|
+
declare function pruneActiveRouting(activeRouting: ActiveRoutingMap | undefined, accounts: readonly SidebarRoutingAccount[] | undefined, now?: number, removedSessionId?: string): ActiveRoutingMap | undefined;
|
|
167
|
+
declare function pruneStickyAssignments(assignments: StickyAssignmentMap | undefined, validAccountIds: ReadonlySet<string> | undefined, now?: number, removedSessionHash?: string): StickyAssignmentMap | undefined;
|
|
168
|
+
interface SidebarMergeHooks {
|
|
169
|
+
beforeRecheck?: () => void | Promise<void>;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Write sidebar state to disk, serialized through a promise chain so
|
|
173
|
+
* concurrent callers never interleave or let a stale write land last.
|
|
174
|
+
*
|
|
175
|
+
* @param state The state to persist.
|
|
176
|
+
* @param file Explicit path override — callers that bind the path at init
|
|
177
|
+
* time (e.g. the index.ts loader) pass this so late callbacks
|
|
178
|
+
* always write to the path that was current when the loader ran,
|
|
179
|
+
* even if the env changes underneath them during tests.
|
|
180
|
+
* Defaults to getSidebarStateFile() (per-call resolution).
|
|
181
|
+
*/
|
|
182
|
+
declare function setSidebarState(state: SidebarState, file?: string): Promise<void>;
|
|
183
|
+
type SidebarMachineState = Pick<SidebarState, 'main' | 'fallbacks' | 'planType' | 'credits' | 'lastUpdated'> & {
|
|
184
|
+
route: string;
|
|
185
|
+
};
|
|
186
|
+
declare function setSidebarMachineState(machineState: SidebarMachineState, file?: string, hooks?: SidebarMergeHooks): Promise<void>;
|
|
187
|
+
declare function upsertSidebarActiveRouting(input: {
|
|
188
|
+
sessionId: string;
|
|
189
|
+
} & ActiveRoutingEntry, accounts: readonly SidebarRoutingAccount[] | undefined, file?: string, hooks?: SidebarMergeHooks): Promise<void>;
|
|
190
|
+
declare function setSidebarLegacyRouting(input: ActiveRoutingEntry, file?: string): Promise<void>;
|
|
191
|
+
declare function removeSidebarActiveRouting(sessionId: string, accounts: readonly SidebarRoutingAccount[] | undefined, file?: string, hooks?: SidebarMergeHooks): Promise<void>;
|
|
192
|
+
declare function resolveSidebarStickyAssignment(input: ResolveStickyAssignmentInput, file?: string, hooks?: SidebarMergeHooks): Promise<StickyAssignment | undefined>;
|
|
193
|
+
declare function clearSidebarStickyAssignment(sessionId: string, file?: string): Promise<boolean>;
|
|
194
|
+
/**
|
|
195
|
+
* Await all pending sidebar writes. Tests call this before restoring env
|
|
196
|
+
* vars in teardown so no in-flight write can re-resolve getSidebarStateFile()
|
|
197
|
+
* after the env is changed.
|
|
198
|
+
*/
|
|
199
|
+
declare function drainSidebarWrites(): Promise<void>;
|
|
200
|
+
declare function resolveActiveAccount(state: SidebarState): {
|
|
201
|
+
id: string;
|
|
202
|
+
name: string;
|
|
203
|
+
quota: AccountQuota | null;
|
|
204
|
+
killed: boolean;
|
|
205
|
+
};
|
|
206
|
+
declare function getCollapsedQuotaSummary(quota: AccountQuota | null): {
|
|
207
|
+
primaryUsedPercent: number | null;
|
|
208
|
+
secondaryUsedPercent: number | null;
|
|
209
|
+
text: string | null;
|
|
210
|
+
};
|
|
211
|
+
interface QuotaPacing {
|
|
212
|
+
pacePercent: number;
|
|
213
|
+
deltaPercent: number;
|
|
214
|
+
state: 'deficit' | 'reserve' | 'on-pace';
|
|
215
|
+
runsOutAt: string | null;
|
|
216
|
+
}
|
|
217
|
+
declare function computeQuotaPacing(window: QuotaWindow, windowMs: number, now: number): QuotaPacing | null;
|
|
218
|
+
//#endregion
|
|
219
|
+
export { getCollapsedQuotaSummary as A, pruneStickyAssignments as B, StickyAssignmentChoice as C, drainSidebarWrites as D, computeQuotaPacing as E, isQuotaExhausted as F, resolveSidebarStickyAssignment as G, resolveActiveAccount as H, isUsableRoutingEntry as I, setSidebarState as J, setSidebarLegacyRouting as K, normalizeSidebarState as L, getSidebarState as M, getSidebarStateFile as N, exhaustedQuotaResetAt as O, hashSidebarSessionId as P, VaultCustodyState as Q, projectCustodyForSidebar as R, StickyAssignment as S, clearSidebarStickyAssignment as T, resolveSessionSidebarRouting as U, removeSidebarActiveRouting as V, resolveSessionStickyAccount as W, upsertSidebarActiveRouting as X, spendControlExhaustedResetAt as Y, CustodyInertReason as Z, SidebarCustodyState as _, ActiveRoutingMap as a, SidebarState as b, QuotaPacing as c, ResolveStickyAssignmentInput as d, STICKY_ASSIGNMENT_MAX_AGE_MS as f, SidebarCustodyReason as g, SidebarAccountState as h, ActiveRoutingEntry as i, getPresentQuotaWindows as j, formatWindowLabel as k, QuotaWindow as l, SidebarAccountCustody as m, ACTIVE_ROUTING_MAX_ENTRIES as n, DEFAULT_SIDEBAR_STATE as o, STICKY_ASSIGNMENT_MAX_ENTRIES as p, setSidebarMachineState as q, AccountQuota as r, PresentQuotaWindow as s, ACTIVE_ROUTING_MAX_AGE_MS as t, QuotaWindowKey as u, SidebarMachineState as v, StickyAssignmentMap as w, SpendControlReading as x, SidebarRoutingAccount as y, pruneActiveRouting as z };
|
package/dist/sidebar-state.d.ts
CHANGED
|
@@ -1,171 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
remainingPercent: number;
|
|
4
|
-
checkedAt?: number;
|
|
5
|
-
resetsAt?: string;
|
|
6
|
-
windowMinutes?: number;
|
|
7
|
-
}
|
|
8
|
-
export interface AccountQuota {
|
|
9
|
-
checkedAt?: number;
|
|
10
|
-
primary?: QuotaWindow;
|
|
11
|
-
secondary?: QuotaWindow;
|
|
12
|
-
resetCreditsAvailable?: number;
|
|
13
|
-
}
|
|
14
|
-
export type QuotaWindowKey = 'primary' | 'secondary';
|
|
15
|
-
export declare function formatWindowLabel(windowMinutes: number | undefined, fallbackKey: QuotaWindowKey): string;
|
|
16
|
-
export interface PresentQuotaWindow {
|
|
17
|
-
key: QuotaWindowKey;
|
|
18
|
-
label: string;
|
|
19
|
-
window: QuotaWindow;
|
|
20
|
-
windowMs: number | null;
|
|
21
|
-
}
|
|
22
|
-
export declare function getPresentQuotaWindows(quota: AccountQuota | null): PresentQuotaWindow[];
|
|
23
|
-
export interface SidebarAccountState {
|
|
24
|
-
id: string;
|
|
25
|
-
label: string | undefined;
|
|
26
|
-
/** ChatGPT identity of the account this quota belongs to. */
|
|
27
|
-
accountId?: string;
|
|
28
|
-
quota: AccountQuota | null;
|
|
29
|
-
killed: boolean;
|
|
30
|
-
enabled: boolean;
|
|
31
|
-
resetCredits?: number;
|
|
32
|
-
}
|
|
33
|
-
export interface ActiveRoutingEntry {
|
|
34
|
-
activeId: string;
|
|
35
|
-
route: string;
|
|
36
|
-
updatedAt: number;
|
|
37
|
-
}
|
|
38
|
-
export type ActiveRoutingMap = Record<string, ActiveRoutingEntry>;
|
|
39
|
-
export interface StickyAssignment {
|
|
40
|
-
accountId: string;
|
|
41
|
-
wireAccountId?: string;
|
|
42
|
-
assignedAt: number;
|
|
43
|
-
lastSeenAt: number;
|
|
44
|
-
inputBytes: number;
|
|
45
|
-
quotaCheckedAt?: number;
|
|
46
|
-
}
|
|
47
|
-
export type StickyAssignmentMap = Record<string, StickyAssignment>;
|
|
48
|
-
export interface StickyAssignmentChoice {
|
|
49
|
-
accountId: string;
|
|
50
|
-
quotaCheckedAt?: number;
|
|
51
|
-
}
|
|
52
|
-
export interface ResolveStickyAssignmentInput {
|
|
53
|
-
sessionId: string;
|
|
54
|
-
requestBytes: number;
|
|
55
|
-
now: number;
|
|
56
|
-
validPinnedAccountIds: readonly string[];
|
|
57
|
-
excludeAccountIds?: readonly string[];
|
|
58
|
-
quotaCheckedAtByAccount: Readonly<Record<string, number | undefined>>;
|
|
59
|
-
wireAccountIdByAccount?: Readonly<Record<string, string | undefined>>;
|
|
60
|
-
choose: (pendingBytes: ReadonlyMap<string, number>) => StickyAssignmentChoice | undefined;
|
|
61
|
-
}
|
|
62
|
-
export interface SidebarState {
|
|
63
|
-
main: {
|
|
64
|
-
quota: AccountQuota | null;
|
|
65
|
-
/** ChatGPT identity of the main account this quota belongs to. */
|
|
66
|
-
mainAccountId?: string;
|
|
67
|
-
killed: boolean;
|
|
68
|
-
quotaBackedOff?: boolean;
|
|
69
|
-
quotaBackoffUntil?: number;
|
|
70
|
-
refreshBackedOff?: boolean;
|
|
71
|
-
refreshBackoffUntil?: number;
|
|
72
|
-
resetCredits?: number;
|
|
73
|
-
};
|
|
74
|
-
fallbacks: SidebarAccountState[];
|
|
75
|
-
/** @deprecated Compatibility field for readers that do not consume activeRouting. */
|
|
76
|
-
activeId: string | undefined;
|
|
77
|
-
/** Machine-global routing mode and compatibility value for older readers. */
|
|
78
|
-
route: string;
|
|
79
|
-
activeRouting?: ActiveRoutingMap;
|
|
80
|
-
stickyAssignments?: StickyAssignmentMap;
|
|
81
|
-
planType?: string;
|
|
82
|
-
credits?: number;
|
|
83
|
-
lastUpdated: number;
|
|
84
|
-
}
|
|
85
|
-
export declare const STICKY_ASSIGNMENT_MAX_AGE_MS: number;
|
|
86
|
-
export declare const STICKY_ASSIGNMENT_MAX_ENTRIES = 256;
|
|
87
|
-
export declare function hashSidebarSessionId(sessionId: string): string;
|
|
88
|
-
export declare function getSidebarStateFile(): string;
|
|
89
|
-
export declare const DEFAULT_SIDEBAR_STATE: SidebarState;
|
|
90
|
-
/**
|
|
91
|
-
* Normalize an arbitrary parsed value into a well-formed SidebarState.
|
|
92
|
-
*
|
|
93
|
-
* JSON.parse + `as SidebarState` is an unchecked cast — a partial, old, or
|
|
94
|
-
* malformed state file passes through and the TUI's `state().main.quota` /
|
|
95
|
-
* `state().fallbacks.filter(...)` throw at runtime. This helper guarantees
|
|
96
|
-
* every required field is present and correctly typed before the value leaves
|
|
97
|
-
* the I/O boundary, so a bad file can never crash the host TUI.
|
|
98
|
-
*/
|
|
99
|
-
export declare function normalizeSidebarState(raw: unknown): SidebarState;
|
|
100
|
-
export declare function getSidebarState(stateFile?: string): Promise<SidebarState>;
|
|
101
|
-
export declare const ACTIVE_ROUTING_MAX_AGE_MS: number;
|
|
102
|
-
export declare const ACTIVE_ROUTING_MAX_ENTRIES = 128;
|
|
103
|
-
export type SidebarRoutingAccount = {
|
|
104
|
-
id: string;
|
|
105
|
-
enabled?: boolean;
|
|
106
|
-
killed?: boolean;
|
|
107
|
-
};
|
|
108
|
-
export declare function isUsableRoutingEntry(entry: ActiveRoutingEntry, accounts: readonly SidebarRoutingAccount[] | undefined, now?: number): boolean;
|
|
109
|
-
export declare function exhaustedQuotaResetAt(quota: AccountQuota | null | undefined, now?: number): {
|
|
110
|
-
resetsAt: string;
|
|
111
|
-
resetAtMs: number;
|
|
112
|
-
} | undefined;
|
|
113
|
-
export declare function isQuotaExhausted(quota: AccountQuota | null | undefined, now?: number): boolean;
|
|
114
|
-
export declare function resolveSessionStickyAccount(state: SidebarState, sessionId: string | undefined, now?: number): string | undefined;
|
|
115
|
-
export declare function resolveSessionSidebarRouting(state: SidebarState, sessionId?: string, now?: number): {
|
|
116
|
-
activeId: string;
|
|
117
|
-
route: string;
|
|
118
|
-
};
|
|
119
|
-
export declare function pruneActiveRouting(activeRouting: ActiveRoutingMap | undefined, accounts: readonly SidebarRoutingAccount[] | undefined, now?: number, removedSessionId?: string): ActiveRoutingMap | undefined;
|
|
120
|
-
export declare function pruneStickyAssignments(assignments: StickyAssignmentMap | undefined, validAccountIds: ReadonlySet<string> | undefined, now?: number, removedSessionHash?: string): StickyAssignmentMap | undefined;
|
|
121
|
-
interface SidebarMergeHooks {
|
|
122
|
-
beforeRecheck?: () => void | Promise<void>;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Write sidebar state to disk, serialized through a promise chain so
|
|
126
|
-
* concurrent callers never interleave or let a stale write land last.
|
|
127
|
-
*
|
|
128
|
-
* @param state The state to persist.
|
|
129
|
-
* @param file Explicit path override — callers that bind the path at init
|
|
130
|
-
* time (e.g. the index.ts loader) pass this so late callbacks
|
|
131
|
-
* always write to the path that was current when the loader ran,
|
|
132
|
-
* even if the env changes underneath them during tests.
|
|
133
|
-
* Defaults to getSidebarStateFile() (per-call resolution).
|
|
134
|
-
*/
|
|
135
|
-
export declare function setSidebarState(state: SidebarState, file?: string): Promise<void>;
|
|
136
|
-
export type SidebarMachineState = Pick<SidebarState, 'main' | 'fallbacks' | 'planType' | 'credits' | 'lastUpdated'> & {
|
|
137
|
-
route: string;
|
|
138
|
-
};
|
|
139
|
-
export declare function setSidebarMachineState(machineState: SidebarMachineState, file?: string, hooks?: SidebarMergeHooks): Promise<void>;
|
|
140
|
-
export declare function upsertSidebarActiveRouting(input: {
|
|
141
|
-
sessionId: string;
|
|
142
|
-
} & ActiveRoutingEntry, accounts: readonly SidebarRoutingAccount[] | undefined, file?: string, hooks?: SidebarMergeHooks): Promise<void>;
|
|
143
|
-
export declare function setSidebarLegacyRouting(input: ActiveRoutingEntry, file?: string): Promise<void>;
|
|
144
|
-
export declare function removeSidebarActiveRouting(sessionId: string, accounts: readonly SidebarRoutingAccount[] | undefined, file?: string, hooks?: SidebarMergeHooks): Promise<void>;
|
|
145
|
-
export declare function resolveSidebarStickyAssignment(input: ResolveStickyAssignmentInput, file?: string, hooks?: SidebarMergeHooks): Promise<StickyAssignment | undefined>;
|
|
146
|
-
export declare function clearSidebarStickyAssignment(sessionId: string, file?: string): Promise<boolean>;
|
|
147
|
-
/**
|
|
148
|
-
* Await all pending sidebar writes. Tests call this before restoring env
|
|
149
|
-
* vars in teardown so no in-flight write can re-resolve getSidebarStateFile()
|
|
150
|
-
* after the env is changed.
|
|
151
|
-
*/
|
|
152
|
-
export declare function drainSidebarWrites(): Promise<void>;
|
|
153
|
-
export declare function resolveActiveAccount(state: SidebarState): {
|
|
154
|
-
id: string;
|
|
155
|
-
name: string;
|
|
156
|
-
quota: AccountQuota | null;
|
|
157
|
-
killed: boolean;
|
|
158
|
-
};
|
|
159
|
-
export declare function getCollapsedQuotaSummary(quota: AccountQuota | null): {
|
|
160
|
-
primaryUsedPercent: number | null;
|
|
161
|
-
secondaryUsedPercent: number | null;
|
|
162
|
-
text: string | null;
|
|
163
|
-
};
|
|
164
|
-
export interface QuotaPacing {
|
|
165
|
-
pacePercent: number;
|
|
166
|
-
deltaPercent: number;
|
|
167
|
-
state: 'deficit' | 'reserve' | 'on-pace';
|
|
168
|
-
runsOutAt: string | null;
|
|
169
|
-
}
|
|
170
|
-
export declare function computeQuotaPacing(window: QuotaWindow, windowMs: number, now: number): QuotaPacing | null;
|
|
171
|
-
export {};
|
|
1
|
+
import { A as getCollapsedQuotaSummary, B as pruneStickyAssignments, C as StickyAssignmentChoice, D as drainSidebarWrites, E as computeQuotaPacing, F as isQuotaExhausted, G as resolveSidebarStickyAssignment, H as resolveActiveAccount, I as isUsableRoutingEntry, J as setSidebarState, K as setSidebarLegacyRouting, L as normalizeSidebarState, M as getSidebarState, N as getSidebarStateFile, O as exhaustedQuotaResetAt, P as hashSidebarSessionId, R as projectCustodyForSidebar, S as StickyAssignment, T as clearSidebarStickyAssignment, U as resolveSessionSidebarRouting, V as removeSidebarActiveRouting, W as resolveSessionStickyAccount, X as upsertSidebarActiveRouting, Y as spendControlExhaustedResetAt, _ as SidebarCustodyState, a as ActiveRoutingMap, b as SidebarState, c as QuotaPacing, d as ResolveStickyAssignmentInput, f as STICKY_ASSIGNMENT_MAX_AGE_MS, g as SidebarCustodyReason, h as SidebarAccountState, i as ActiveRoutingEntry, j as getPresentQuotaWindows, k as formatWindowLabel, l as QuotaWindow, m as SidebarAccountCustody, n as ACTIVE_ROUTING_MAX_ENTRIES, o as DEFAULT_SIDEBAR_STATE, p as STICKY_ASSIGNMENT_MAX_ENTRIES, q as setSidebarMachineState, r as AccountQuota, s as PresentQuotaWindow, t as ACTIVE_ROUTING_MAX_AGE_MS, u as QuotaWindowKey, v as SidebarMachineState, w as StickyAssignmentMap, x as SpendControlReading, y as SidebarRoutingAccount, z as pruneActiveRouting } from "./sidebar-state-B98sERYt.js";
|
|
2
|
+
export { ACTIVE_ROUTING_MAX_AGE_MS, ACTIVE_ROUTING_MAX_ENTRIES, AccountQuota, ActiveRoutingEntry, ActiveRoutingMap, DEFAULT_SIDEBAR_STATE, PresentQuotaWindow, QuotaPacing, QuotaWindow, QuotaWindowKey, ResolveStickyAssignmentInput, STICKY_ASSIGNMENT_MAX_AGE_MS, STICKY_ASSIGNMENT_MAX_ENTRIES, SidebarAccountCustody, SidebarAccountState, SidebarCustodyReason, SidebarCustodyState, SidebarMachineState, SidebarRoutingAccount, SidebarState, SpendControlReading, StickyAssignment, StickyAssignmentChoice, StickyAssignmentMap, clearSidebarStickyAssignment, computeQuotaPacing, drainSidebarWrites, exhaustedQuotaResetAt, formatWindowLabel, getCollapsedQuotaSummary, getPresentQuotaWindows, getSidebarState, getSidebarStateFile, hashSidebarSessionId, isQuotaExhausted, isUsableRoutingEntry, normalizeSidebarState, projectCustodyForSidebar, pruneActiveRouting, pruneStickyAssignments, removeSidebarActiveRouting, resolveActiveAccount, resolveSessionSidebarRouting, resolveSessionStickyAccount, resolveSidebarStickyAssignment, setSidebarLegacyRouting, setSidebarMachineState, setSidebarState, spendControlExhaustedResetAt, upsertSidebarActiveRouting };
|
package/dist/sidebar-state.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as x,B as y,C as z,D as A,E as B,F as C,G as D,H as E,d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i,m as j,n as k,o as l,p as m,q as n,r as o,s as p,t as q,u as r,v as s,w as t,x as u,y as v,z as w}from"./index-5y4vzdf8.js";import"./index-338z7171.js";import"./index-301y4qa1.js";import"./index-9ehhb051.js";export{w as upsertSidebarActiveRouting,n as spendControlExhaustedResetAt,u as setSidebarState,v as setSidebarMachineState,x as setSidebarLegacyRouting,z as resolveSidebarStickyAssignment,q as resolveSessionStickyAccount,r as resolveSessionSidebarRouting,C as resolveActiveAccount,y as removeSidebarActiveRouting,t as pruneStickyAssignments,s as pruneActiveRouting,g as projectCustodyForSidebar,i as normalizeSidebarState,m as isUsableRoutingEntry,p as isQuotaExhausted,e as hashSidebarSessionId,f as getSidebarStateFile,j as getSidebarState,b as getPresentQuotaWindows,D as getCollapsedQuotaSummary,a as formatWindowLabel,o as exhaustedQuotaResetAt,B as drainSidebarWrites,E as computeQuotaPacing,A as clearSidebarStickyAssignment,d as STICKY_ASSIGNMENT_MAX_ENTRIES,c as STICKY_ASSIGNMENT_MAX_AGE_MS,h as DEFAULT_SIDEBAR_STATE,l as ACTIVE_ROUTING_MAX_ENTRIES,k as ACTIVE_ROUTING_MAX_AGE_MS};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as U,b as V}from"./index-
|
|
1
|
+
import{a as U,b as V}from"./index-sdt2d2ra.js";import{rb as R}from"./index-9ehhb051.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-sdt2d2ra.js";import"./index-9ehhb051.js";export default a();
|
|
@@ -1,34 +1,35 @@
|
|
|
1
|
+
//#region src/tui-preferences.d.ts
|
|
1
2
|
export declare const TUI_PREFS_FILE_ENV = "OPENCODE_TUI_PREFERENCES_FILE";
|
|
2
3
|
export declare function getTuiPreferencesFile(): string;
|
|
3
4
|
export declare function readTuiPreferencesFile(): Promise<Record<string, unknown>>;
|
|
4
5
|
export declare const PLUGIN_KEY = "openai-auth";
|
|
5
6
|
export declare const DEFAULT_SLOT_ORDER = 160;
|
|
6
7
|
export interface OpenaiAuthTuiPrefs {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
8
|
+
forceToTop: boolean;
|
|
9
|
+
order: number;
|
|
10
|
+
startCollapsed: boolean;
|
|
11
|
+
rememberCollapsed: boolean;
|
|
12
|
+
collapsed: boolean | null;
|
|
13
|
+
pollMs: number;
|
|
14
|
+
refreshDebounceMs: number;
|
|
15
|
+
header: {
|
|
16
|
+
label: string;
|
|
17
|
+
showVersion: boolean;
|
|
18
|
+
};
|
|
19
|
+
sections: {
|
|
20
|
+
quota: boolean;
|
|
21
|
+
fallbackAccounts: boolean;
|
|
22
|
+
routing: boolean;
|
|
23
|
+
health: boolean;
|
|
24
|
+
pacing: boolean;
|
|
25
|
+
};
|
|
26
|
+
appearance: {
|
|
27
|
+
barWidth: number;
|
|
28
|
+
barFilledChar: string;
|
|
29
|
+
barEmptyChar: string;
|
|
30
|
+
warnThreshold: number;
|
|
31
|
+
errorThreshold: number;
|
|
32
|
+
};
|
|
32
33
|
}
|
|
33
34
|
export type AppearancePrefs = OpenaiAuthTuiPrefs['appearance'];
|
|
34
35
|
export declare const DEFAULT_PREFS: OpenaiAuthTuiPrefs;
|
|
@@ -37,4 +38,4 @@ export declare function computeEffectiveOrder(root: Record<string, unknown>, plu
|
|
|
37
38
|
type JsonValue = string | number | boolean | null;
|
|
38
39
|
export declare function queueTuiPreferenceUpdate(pluginKey: string, path: string[], value: JsonValue): Promise<void>;
|
|
39
40
|
export declare function watchTuiPreferences(onChange: () => void): () => void;
|
|
40
|
-
|
|
41
|
+
//#endregion
|
package/dist/tui-preferences.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{qb as P,rb as C,tb as _}from"./index-9ehhb051.js";var g=C((T,L)=>{(function(Q){if(typeof L==="object"&&typeof L.exports==="object"){var J=Q(_,T);if(J!==void 0)L.exports=J}else if(typeof define==="function"&&define.amd)define(["require","exports","./impl/format","./impl/edit","./impl/scanner","./impl/parser"],Q)})(function(Q,J){Object.defineProperty(J,"__esModule",{value:!0}),J.applyEdits=J.modify=J.format=J.printParseErrorCode=J.ParseErrorCode=J.stripComments=J.visit=J.getNodeValue=J.getNodePath=J.findNodeAtOffset=J.findNodeAtLocation=J.parseTree=J.parse=J.getLocation=J.SyntaxKind=J.ScanError=J.createScanner=void 0;let X=Q("./impl/format"),Z=Q("./impl/edit"),G=Q("./impl/scanner"),$=Q("./impl/parser");J.createScanner=G.createScanner;var W;(function(z){z[z.None=0]="None",z[z.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",z[z.UnexpectedEndOfString=2]="UnexpectedEndOfString",z[z.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",z[z.InvalidUnicode=4]="InvalidUnicode",z[z.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",z[z.InvalidCharacter=6]="InvalidCharacter"})(W||(J.ScanError=W={}));var H;(function(z){z[z.OpenBraceToken=1]="OpenBraceToken",z[z.CloseBraceToken=2]="CloseBraceToken",z[z.OpenBracketToken=3]="OpenBracketToken",z[z.CloseBracketToken=4]="CloseBracketToken",z[z.CommaToken=5]="CommaToken",z[z.ColonToken=6]="ColonToken",z[z.NullKeyword=7]="NullKeyword",z[z.TrueKeyword=8]="TrueKeyword",z[z.FalseKeyword=9]="FalseKeyword",z[z.StringLiteral=10]="StringLiteral",z[z.NumericLiteral=11]="NumericLiteral",z[z.LineCommentTrivia=12]="LineCommentTrivia",z[z.BlockCommentTrivia=13]="BlockCommentTrivia",z[z.LineBreakTrivia=14]="LineBreakTrivia",z[z.Trivia=15]="Trivia",z[z.Unknown=16]="Unknown",z[z.EOF=17]="EOF"})(H||(J.SyntaxKind=H={})),J.getLocation=$.getLocation,J.parse=$.parse,J.parseTree=$.parseTree,J.findNodeAtLocation=$.findNodeAtLocation,J.findNodeAtOffset=$.findNodeAtOffset,J.getNodePath=$.getNodePath,J.getNodeValue=$.getNodeValue,J.visit=$.visit,J.stripComments=$.stripComments;var q;(function(z){z[z.InvalidSymbol=1]="InvalidSymbol",z[z.InvalidNumberFormat=2]="InvalidNumberFormat",z[z.PropertyNameExpected=3]="PropertyNameExpected",z[z.ValueExpected=4]="ValueExpected",z[z.ColonExpected=5]="ColonExpected",z[z.CommaExpected=6]="CommaExpected",z[z.CloseBraceExpected=7]="CloseBraceExpected",z[z.CloseBracketExpected=8]="CloseBracketExpected",z[z.EndOfFileExpected=9]="EndOfFileExpected",z[z.InvalidCommentToken=10]="InvalidCommentToken",z[z.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",z[z.UnexpectedEndOfString=12]="UnexpectedEndOfString",z[z.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",z[z.InvalidUnicode=14]="InvalidUnicode",z[z.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",z[z.InvalidCharacter=16]="InvalidCharacter"})(q||(J.ParseErrorCode=q={}));function D(z){switch(z){case 1:return"InvalidSymbol";case 2:return"InvalidNumberFormat";case 3:return"PropertyNameExpected";case 4:return"ValueExpected";case 5:return"ColonExpected";case 6:return"CommaExpected";case 7:return"CloseBraceExpected";case 8:return"CloseBracketExpected";case 9:return"EndOfFileExpected";case 10:return"InvalidCommentToken";case 11:return"UnexpectedEndOfComment";case 12:return"UnexpectedEndOfString";case 13:return"UnexpectedEndOfNumber";case 14:return"InvalidUnicode";case 15:return"InvalidEscapeCharacter";case 16:return"InvalidCharacter"}return"<unknown ParseErrorCode>"}J.printParseErrorCode=D;function m(z,U,j){return X.format(z,U,j)}J.format=m;function f(z,U,j,A){return Z.setProperty(z,U,j,A)}J.modify=f;function u(z,U){let j=U.slice(0).sort((I,Y)=>{let F=I.offset-Y.offset;if(F===0)return I.length-Y.length;return F}),A=z.length;for(let I=j.length-1;I>=0;I--){let Y=j[I];if(Y.offset+Y.length<=A)z=Z.applyEdit(z,Y);else throw Error("Overlapping edit");A=Y.offset}return z}J.applyEdits=u})});var M=P(g(),1);import{watch as K}from"node:fs";import{mkdir as c,readFile as O,rename as y,writeFile as S}from"node:fs/promises";import{homedir as E}from"node:os";import{basename as l,dirname as v,join as k}from"node:path";var p="OPENCODE_TUI_PREFERENCES_FILE",x="tui-preferences.jsonc";function w(){let Q=process.env[p];if(Q)return Q;let J=process.env.OPENCODE_CONFIG_DIR||k(process.env.XDG_CONFIG_HOME||k(E(),".config"),"opencode");return k(J,x)}function N(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}async function Xz(){try{let Q=await O(w(),"utf8"),J=[],X=M.parse(Q,J,{allowTrailingComma:!0});if(J.length>0)return{};return N(X)?X:{}}catch{return{}}}var i="openai-auth",s=160,b={forceToTop:!1,order:s,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 V(Q,J){return typeof Q==="boolean"?Q:J}function B(Q,J,X,Z){if(typeof Q!=="number"||!Number.isFinite(Q))return J;return Math.min(Math.max(Math.round(Q),X),Z)}function d(Q,J,X){if(typeof Q!=="string"||Q.length===0)return J;return Q.slice(0,X)}function h(Q,J){if(typeof Q!=="string")return J;return[...Q][0]??J}function Zz(Q){let J=Q[i];if(!N(J))return structuredClone(b);let X=b,Z=N(J.header)?J.header:{},G=N(J.sections)?J.sections:{},$=N(J.appearance)?J.appearance:{},W=B($.warnThreshold,X.appearance.warnThreshold,0,99),H=Math.max(B($.errorThreshold,X.appearance.errorThreshold,0,100),Math.min(W+1,100));return{forceToTop:V(J.forceToTop,X.forceToTop),order:B(J.order,X.order,-1e4,1e4),startCollapsed:V(J.startCollapsed,X.startCollapsed),rememberCollapsed:V(J.rememberCollapsed,X.rememberCollapsed),collapsed:typeof J.collapsed==="boolean"?J.collapsed:null,pollMs:B(J.pollMs,X.pollMs,500,30000),refreshDebounceMs:B(J.refreshDebounceMs,X.refreshDebounceMs,50,5000),header:{label:d(Z.label,X.header.label,20),showVersion:V(Z.showVersion,X.header.showVersion)},sections:{quota:V(G.quota,X.sections.quota),fallbackAccounts:V(G.fallbackAccounts,X.sections.fallbackAccounts),routing:V(G.routing,X.sections.routing),health:V(G.health,X.sections.health),pacing:V(G.pacing,X.sections.pacing)},appearance:{barWidth:B($.barWidth,X.appearance.barWidth,4,40),barFilledChar:h($.barFilledChar,X.appearance.barFilledChar),barEmptyChar:h($.barEmptyChar,X.appearance.barEmptyChar),warnThreshold:W,errorThreshold:H}}}var n=-1e5;function $z(Q,J,X){let Z=Q[J];if(!N(Z))return X;if(Z.forceToTop===!0)return n+Object.keys(Q).indexOf(J);return B(Z.order,X,-1e4,1e4)}var t=`// Shared preferences for opencode TUI plugins.
|
|
2
2
|
// One top-level key per plugin (short name). See each plugin's README for
|
|
3
3
|
// its supported settings. This file is safe to hand-edit; plugins update
|
|
4
4
|
// individual keys in place and preserve comments.
|