@cortexkit/opencode-openai-auth 0.11.0 → 1.0.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 (204) hide show
  1. package/README.md +15 -26
  2. package/dist/index-766sfrh5.js +1 -0
  3. package/dist/index-8kj7sa1p.js +12 -0
  4. package/dist/index-8rqfbhfw.js +221 -0
  5. package/dist/index-b3q3j39x.js +2 -0
  6. package/dist/index-bmd7x5aq.js +2 -0
  7. package/dist/index-eqh53k8v.js +2 -0
  8. package/dist/{index-sdt2d2ra.js → index-hy9030jh.js} +1 -1
  9. package/dist/index-jyr8y8k4.js +7 -0
  10. package/dist/index-rv08jmd4.js +2 -0
  11. package/dist/index.d.ts +578 -145
  12. package/dist/index.js +1 -110
  13. package/dist/pool-lifecycle-DbDmgabd.d.ts +2430 -0
  14. package/dist/port-file-Do3lQIEk.d.ts +29 -0
  15. package/dist/protocol-BOBdkqqm.d.ts +198 -0
  16. package/dist/rpc/port-file.d.ts +4 -17
  17. package/dist/rpc/port-file.js +1 -1
  18. package/dist/rpc/protocol.d.ts +2 -2
  19. package/dist/rpc/protocol.js +1 -0
  20. package/dist/rpc/rpc-client.d.ts +5 -4
  21. package/dist/rpc/rpc-client.js +1 -1
  22. package/dist/rpc/rpc-dir.d.ts +2 -0
  23. package/dist/rpc/rpc-dir.js +1 -1
  24. package/dist/sidebar-state-D6cUKgkm.d.ts +385 -0
  25. package/dist/sidebar-state.d.ts +2 -2
  26. package/dist/sidebar-state.js +1 -1
  27. package/dist/token-util-wdza526f.js +1 -0
  28. package/dist/{token-9823y0pc.js → token-ypk61xj0.js} +1 -1
  29. package/dist/tui-preferences.js +5 -2
  30. package/dist/tui.d.ts +9 -4
  31. package/dist/v2/server.d.ts +54 -0
  32. package/dist/v2/server.js +4 -0
  33. package/package.json +21 -9
  34. package/src/tui/entry.mjs +26 -25
  35. package/src/tui-compiled/raw/logger.js +24 -0
  36. package/src/tui-compiled/raw/rpc/protocol.js +3 -0
  37. package/src/tui-compiled/raw/rpc/rpc-client.js +7 -0
  38. package/src/tui-compiled/raw/rpc/rpc-dir.js +27 -0
  39. package/src/tui-compiled/raw/selector.js +21 -0
  40. package/src/tui-compiled/raw/shared/0332701351b3eeec-format.js +138 -0
  41. package/src/tui-compiled/raw/shared/04a6357627de5ed0-errors.js +38 -0
  42. package/src/tui-compiled/raw/shared/053cc17b5419261e-codec.js +12 -0
  43. package/src/tui-compiled/raw/shared/0766d78c6f481f18-watcher.js +157 -0
  44. package/src/tui-compiled/raw/shared/08eef45626a94992-reserved.js +13 -0
  45. package/src/tui-compiled/raw/shared/39c3cb05738fcf6d-projection.js +134 -0
  46. package/src/tui-compiled/raw/shared/3c2d4169d00f907e-tui-support.js +5 -0
  47. package/src/tui-compiled/raw/shared/3e7d45a77c6ad4d5-index.js +4 -0
  48. package/src/tui-compiled/raw/shared/415792e85d80819e-capture-sink.js +13 -0
  49. package/src/tui-compiled/raw/shared/42ae93ab554fcec2-open-url.js +28 -0
  50. package/src/tui-compiled/raw/shared/43fc9e6b994519c7-refresh-lock.js +136 -0
  51. package/src/tui-compiled/raw/shared/458b934e92490331-mutate.js +500 -0
  52. package/src/tui-compiled/raw/shared/45bf5343bbbf9add-admission.js +142 -0
  53. package/src/tui-compiled/raw/shared/46f3dff1266160e8-client.js +2 -0
  54. package/src/tui-compiled/raw/shared/4825e03209d6ae3e-with-lock.js +48 -0
  55. package/src/tui-compiled/raw/shared/4f36d333d081d040-merge.js +162 -0
  56. package/src/tui-compiled/raw/shared/54eba94fd64c8c3c-index.js +7 -0
  57. package/src/tui-compiled/raw/shared/7211cfec06a298bc-atomic-write.js +80 -0
  58. package/src/tui-compiled/raw/shared/754d6017f8e419cf-builtins.js +534 -0
  59. package/src/tui-compiled/raw/shared/75bd8c3bd63b315f-identity.js +79 -0
  60. package/src/tui-compiled/raw/shared/7a91bb630e6f4804-index.js +1 -0
  61. package/src/tui-compiled/raw/shared/826342a4b6a8b89b-model.js +16 -0
  62. package/src/tui-compiled/raw/shared/83068c0dbe8a6f13-publication.js +304 -0
  63. package/src/tui-compiled/raw/shared/836fc615de6afbd9-settings.js +120 -0
  64. package/src/tui-compiled/raw/shared/83bc3ba9d0fe2761-runtime.js +68 -0
  65. package/src/tui-compiled/raw/shared/8a18abe4fa2977c8-menu.js +300 -0
  66. package/src/tui-compiled/raw/shared/901e149c5a0dbbff-sticky.js +339 -0
  67. package/src/tui-compiled/raw/shared/9020c407ce64f672-ordered.js +58 -0
  68. package/src/tui-compiled/raw/shared/905bffc0220f43d0-map.js +105 -0
  69. package/src/tui-compiled/raw/shared/94820e324f2b4c09-seam.js +301 -0
  70. package/src/tui-compiled/raw/shared/97484d9bb98c705b-provider-state.js +226 -0
  71. package/src/tui-compiled/raw/shared/9968e3cade6969a1-index.js +2 -0
  72. package/src/tui-compiled/raw/shared/9b4da614c45f9cd0-lock-constants.js +14 -0
  73. package/src/tui-compiled/raw/shared/9d3fc9e37456504e-refresh.js +225 -0
  74. package/src/tui-compiled/raw/shared/9deae3c4da4fd63b-hooks.js +34 -0
  75. package/src/tui-compiled/raw/shared/a09b6a533c11858f-tui-preferences.js +77 -0
  76. package/src/tui-compiled/raw/shared/a62a27a204266acd-attribution.js +60 -0
  77. package/src/tui-compiled/raw/shared/a910277ac43a8626-pull.js +143 -0
  78. package/src/tui-compiled/raw/shared/b85c5301fddcb98a-paths.js +5 -0
  79. package/src/tui-compiled/raw/shared/c14988621dc60a75-port-file.js +217 -0
  80. package/src/tui-compiled/raw/shared/c64d7afbc14ca125-sidebar-file.js +157 -0
  81. package/src/tui-compiled/raw/shared/c6b176708c446d6d-pins.js +34 -0
  82. package/src/tui-compiled/raw/shared/c7d252bedee01600-pi.js +206 -0
  83. package/src/tui-compiled/raw/shared/c852a15cfe489d12-pool.js +120 -0
  84. package/src/tui-compiled/raw/shared/cc9e0702a752cea7-index.js +3 -0
  85. package/src/tui-compiled/raw/shared/cd94316a888b0a8e-schema.js +754 -0
  86. package/src/tui-compiled/raw/shared/d319517e3ea6ad70-redact.js +83 -0
  87. package/src/tui-compiled/raw/shared/d5a8f1061ee2f114-index.js +5 -0
  88. package/src/tui-compiled/raw/shared/d669d72c40e9e116-logger.js +19 -0
  89. package/src/tui-compiled/raw/shared/d7dcba96fea1685c-engine.js +246 -0
  90. package/src/tui-compiled/raw/shared/dbef697d1df1cd84-index.js +5 -0
  91. package/src/tui-compiled/raw/shared/e4acc4cb713f300c-protocol.js +3 -0
  92. package/src/tui-compiled/raw/shared/e8cd4929507508d8-refresh-file-lock.js +501 -0
  93. package/src/tui-compiled/raw/shared/ec971142548df90e-index.js +6 -0
  94. package/src/tui-compiled/raw/shared/f37fcefc7aedbf25-error.js +11 -0
  95. package/src/tui-compiled/raw/shared/fbcdcd0f925e74c0-rpc-client.js +253 -0
  96. package/src/tui-compiled/raw/shared/fd45e82f2f9c0a0d-torn.js +294 -0
  97. package/src/tui-compiled/raw/shared/fe02abeadc535f77-rows.js +1258 -0
  98. package/src/tui-compiled/raw/sidebar-state.js +960 -0
  99. package/src/tui-compiled/raw/tui/command-dialogs.tsx +424 -0
  100. package/src/tui-compiled/raw/tui-preferences.js +135 -0
  101. package/src/tui-compiled/raw/tui.tsx +135 -143
  102. package/src/tui-compiled/runtime/logger.js +24 -0
  103. package/src/tui-compiled/runtime/rpc/protocol.js +3 -0
  104. package/src/tui-compiled/runtime/rpc/rpc-client.js +7 -0
  105. package/src/tui-compiled/runtime/rpc/rpc-dir.js +27 -0
  106. package/src/tui-compiled/runtime/selector.js +21 -0
  107. package/src/tui-compiled/runtime/shared/0332701351b3eeec-format.js +138 -0
  108. package/src/tui-compiled/runtime/shared/04a6357627de5ed0-errors.js +38 -0
  109. package/src/tui-compiled/runtime/shared/053cc17b5419261e-codec.js +12 -0
  110. package/src/tui-compiled/runtime/shared/0766d78c6f481f18-watcher.js +157 -0
  111. package/src/tui-compiled/runtime/shared/08eef45626a94992-reserved.js +13 -0
  112. package/src/tui-compiled/runtime/shared/39c3cb05738fcf6d-projection.js +134 -0
  113. package/src/tui-compiled/runtime/shared/3c2d4169d00f907e-tui-support.js +5 -0
  114. package/src/tui-compiled/runtime/shared/3e7d45a77c6ad4d5-index.js +4 -0
  115. package/src/tui-compiled/runtime/shared/415792e85d80819e-capture-sink.js +13 -0
  116. package/src/tui-compiled/runtime/shared/42ae93ab554fcec2-open-url.js +28 -0
  117. package/src/tui-compiled/runtime/shared/43fc9e6b994519c7-refresh-lock.js +136 -0
  118. package/src/tui-compiled/runtime/shared/458b934e92490331-mutate.js +500 -0
  119. package/src/tui-compiled/runtime/shared/45bf5343bbbf9add-admission.js +142 -0
  120. package/src/tui-compiled/runtime/shared/46f3dff1266160e8-client.js +2 -0
  121. package/src/tui-compiled/runtime/shared/4825e03209d6ae3e-with-lock.js +48 -0
  122. package/src/tui-compiled/runtime/shared/4f36d333d081d040-merge.js +162 -0
  123. package/src/tui-compiled/runtime/shared/54eba94fd64c8c3c-index.js +7 -0
  124. package/src/tui-compiled/runtime/shared/7211cfec06a298bc-atomic-write.js +80 -0
  125. package/src/tui-compiled/runtime/shared/754d6017f8e419cf-builtins.js +534 -0
  126. package/src/tui-compiled/runtime/shared/75bd8c3bd63b315f-identity.js +79 -0
  127. package/src/tui-compiled/runtime/shared/7a91bb630e6f4804-index.js +1 -0
  128. package/src/tui-compiled/runtime/shared/826342a4b6a8b89b-model.js +16 -0
  129. package/src/tui-compiled/runtime/shared/83068c0dbe8a6f13-publication.js +304 -0
  130. package/src/tui-compiled/runtime/shared/836fc615de6afbd9-settings.js +120 -0
  131. package/src/tui-compiled/runtime/shared/83bc3ba9d0fe2761-runtime.js +68 -0
  132. package/src/tui-compiled/runtime/shared/8a18abe4fa2977c8-menu.js +300 -0
  133. package/src/tui-compiled/runtime/shared/901e149c5a0dbbff-sticky.js +339 -0
  134. package/src/tui-compiled/runtime/shared/9020c407ce64f672-ordered.js +58 -0
  135. package/src/tui-compiled/runtime/shared/905bffc0220f43d0-map.js +105 -0
  136. package/src/tui-compiled/runtime/shared/94820e324f2b4c09-seam.js +301 -0
  137. package/src/tui-compiled/runtime/shared/97484d9bb98c705b-provider-state.js +226 -0
  138. package/src/tui-compiled/runtime/shared/9968e3cade6969a1-index.js +2 -0
  139. package/src/tui-compiled/runtime/shared/9b4da614c45f9cd0-lock-constants.js +14 -0
  140. package/src/tui-compiled/runtime/shared/9d3fc9e37456504e-refresh.js +225 -0
  141. package/src/tui-compiled/runtime/shared/9deae3c4da4fd63b-hooks.js +34 -0
  142. package/src/tui-compiled/runtime/shared/a09b6a533c11858f-tui-preferences.js +77 -0
  143. package/src/tui-compiled/runtime/shared/a62a27a204266acd-attribution.js +60 -0
  144. package/src/tui-compiled/runtime/shared/a910277ac43a8626-pull.js +143 -0
  145. package/src/tui-compiled/runtime/shared/b85c5301fddcb98a-paths.js +5 -0
  146. package/src/tui-compiled/runtime/shared/c14988621dc60a75-port-file.js +217 -0
  147. package/src/tui-compiled/runtime/shared/c64d7afbc14ca125-sidebar-file.js +157 -0
  148. package/src/tui-compiled/runtime/shared/c6b176708c446d6d-pins.js +34 -0
  149. package/src/tui-compiled/runtime/shared/c7d252bedee01600-pi.js +206 -0
  150. package/src/tui-compiled/runtime/shared/c852a15cfe489d12-pool.js +120 -0
  151. package/src/tui-compiled/runtime/shared/cc9e0702a752cea7-index.js +3 -0
  152. package/src/tui-compiled/runtime/shared/cd94316a888b0a8e-schema.js +754 -0
  153. package/src/tui-compiled/runtime/shared/d319517e3ea6ad70-redact.js +83 -0
  154. package/src/tui-compiled/runtime/shared/d5a8f1061ee2f114-index.js +5 -0
  155. package/src/tui-compiled/runtime/shared/d669d72c40e9e116-logger.js +19 -0
  156. package/src/tui-compiled/runtime/shared/d7dcba96fea1685c-engine.js +246 -0
  157. package/src/tui-compiled/runtime/shared/dbef697d1df1cd84-index.js +5 -0
  158. package/src/tui-compiled/runtime/shared/e4acc4cb713f300c-protocol.js +3 -0
  159. package/src/tui-compiled/runtime/shared/e8cd4929507508d8-refresh-file-lock.js +501 -0
  160. package/src/tui-compiled/runtime/shared/ec971142548df90e-index.js +6 -0
  161. package/src/tui-compiled/runtime/shared/f37fcefc7aedbf25-error.js +11 -0
  162. package/src/tui-compiled/runtime/shared/fbcdcd0f925e74c0-rpc-client.js +253 -0
  163. package/src/tui-compiled/runtime/shared/fd45e82f2f9c0a0d-torn.js +294 -0
  164. package/src/tui-compiled/runtime/shared/fe02abeadc535f77-rows.js +1258 -0
  165. package/src/tui-compiled/runtime/sidebar-state.js +960 -0
  166. package/src/tui-compiled/runtime/tui/command-dialogs.js +378 -0
  167. package/src/tui-compiled/runtime/tui-preferences.js +135 -0
  168. package/src/tui-compiled/runtime/{tui.tsx → tui.js} +288 -316
  169. package/dist/index-4effjmr6.js +0 -2
  170. package/dist/index-9ehhb051.js +0 -2
  171. package/dist/index-g3hsdjh4.js +0 -2
  172. package/dist/index-hh52v8sb.js +0 -2
  173. package/dist/index-jwn4r3sw.js +0 -1
  174. package/dist/index-sq36b120.js +0 -211
  175. package/dist/internal-BTndPmW2.d.ts +0 -914
  176. package/dist/quota-normalize-08hpp51v.js +0 -1
  177. package/dist/sidebar-state-CoKYKcLn.d.ts +0 -220
  178. package/dist/token-util-ypgz7rge.js +0 -1
  179. package/src/tui-compiled/raw/core-account-paths.ts +0 -114
  180. package/src/tui-compiled/raw/core-custody-state.ts +0 -243
  181. package/src/tui-compiled/raw/logger.ts +0 -53
  182. package/src/tui-compiled/raw/rpc-port-file.ts +0 -177
  183. package/src/tui-compiled/raw/rpc-protocol.ts +0 -12
  184. package/src/tui-compiled/raw/rpc-rpc-client.ts +0 -82
  185. package/src/tui-compiled/raw/rpc-rpc-dir.ts +0 -46
  186. package/src/tui-compiled/raw/sidebar-state.ts +0 -1659
  187. package/src/tui-compiled/raw/tui-command-dialogs.tsx +0 -1096
  188. package/src/tui-compiled/raw/tui-preferences.ts +0 -328
  189. package/src/tui-compiled/runtime/core-account-paths.ts +0 -114
  190. package/src/tui-compiled/runtime/core-custody-state.ts +0 -243
  191. package/src/tui-compiled/runtime/logger.ts +0 -53
  192. package/src/tui-compiled/runtime/rpc-port-file.ts +0 -177
  193. package/src/tui-compiled/runtime/rpc-protocol.ts +0 -12
  194. package/src/tui-compiled/runtime/rpc-rpc-client.ts +0 -82
  195. package/src/tui-compiled/runtime/rpc-rpc-dir.ts +0 -46
  196. package/src/tui-compiled/runtime/sidebar-state.ts +0 -1659
  197. package/src/tui-compiled/runtime/tui-command-dialogs.tsx +0 -855
  198. package/src/tui-compiled/runtime/tui-preferences.ts +0 -328
  199. package/src/tui-compiled/shared/internal.ts +0 -6
  200. package/src/tui-compiled/shared/logger.ts +0 -264
  201. package/src/tui-compiled/shared/paths.ts +0 -33
  202. package/src/tui-compiled/shared/refresh-file-lock.ts +0 -384
  203. package/src/tui-compiled/shared/util/error.ts +0 -9
  204. package/src/tui-compiled/shared/util/open-url.ts +0 -30
@@ -0,0 +1,385 @@
1
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.14.2+49be191d46b46482/node_modules/@cortexkit/common-auth/dist/logger/engine.d.ts
2
+ interface ChannelLogger {
3
+ error(message: string, data?: unknown): void;
4
+ warn(message: string, data?: unknown): void;
5
+ info(message: string, data?: unknown): void;
6
+ debug(message: string, data?: unknown): void;
7
+ trace(message: string, data?: unknown): void;
8
+ }
9
+ declare function createLogger(channel: string): ChannelLogger;
10
+ //#endregion
11
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.14.2+49be191d46b46482/node_modules/@cortexkit/common-auth/dist/quota/projection.d.ts
12
+ interface ProjectedLimit {
13
+ scope: string;
14
+ label: string;
15
+ kind: 'reading' | 'retired' | 'absent';
16
+ /** The reading, retirement or absence time. */
17
+ checkedAt: number;
18
+ /** The stored window length; undefined when the provider reported none. */
19
+ windowMinutes?: number;
20
+ /** Present on readings only. */
21
+ usedPercent?: number;
22
+ /** Present on readings only: `100 - usedPercent`. */
23
+ remainingPercent?: number;
24
+ resetsAt?: string;
25
+ }
26
+ interface ProjectedBudget {
27
+ checkedAt: number;
28
+ reached: boolean;
29
+ remainingPercent?: number;
30
+ resetsAt?: string;
31
+ }
32
+ interface ProjectedQuota {
33
+ scope: string;
34
+ /** One entry per label: longest known window first, unknown lengths last. */
35
+ limits: readonly ProjectedLimit[];
36
+ /**
37
+ * The oldest reading time among the limits (or, with no reading, the oldest
38
+ * evidence time), so a projection is only as fresh as its stalest limit.
39
+ */
40
+ checkedAt?: number;
41
+ /** Present only when the stored budget is a reading, not cleared. */
42
+ budget?: ProjectedBudget;
43
+ }
44
+ //#endregion
45
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.14.2+49be191d46b46482/node_modules/@cortexkit/common-auth/dist/sidebar-file/sidebar-file.d.ts
46
+ interface SidebarFileHooks {
47
+ /** Runs on the first merge attempt, before checking for older, unlocked writers. */
48
+ beforeRecheck?: () => void | Promise<void>;
49
+ /** @internal Test seam after staging, before the ownership fence. */
50
+ beforeCommit?: () => Promise<void>;
51
+ /** @internal Test seam after the rename, before ownership is checked again. */
52
+ afterRename?: () => Promise<void>;
53
+ }
54
+ //#endregion
55
+ //#region src/sidebar-state.d.ts
56
+ interface QuotaWindow {
57
+ usedPercent: number;
58
+ remainingPercent: number;
59
+ checkedAt?: number;
60
+ resetsAt?: string;
61
+ windowMinutes?: number;
62
+ }
63
+ interface SpendControlReading {
64
+ limit: number;
65
+ used: number;
66
+ remaining: number;
67
+ usedPercent: number;
68
+ remainingPercent: number;
69
+ resetsAt?: string;
70
+ unit?: string;
71
+ source?: string;
72
+ reached: boolean;
73
+ }
74
+ interface AccountQuota {
75
+ checkedAt?: number;
76
+ primary?: QuotaWindow;
77
+ secondary?: QuotaWindow;
78
+ spendControl?: SpendControlReading;
79
+ spendControlCleared?: true;
80
+ resetCreditsAvailable?: number;
81
+ }
82
+ type QuotaWindowKey = 'primary' | 'secondary';
83
+ declare function formatWindowLabel(windowMinutes: number | undefined, fallbackKey: QuotaWindowKey): string;
84
+ interface PresentQuotaWindow {
85
+ key: QuotaWindowKey;
86
+ label: string;
87
+ window: QuotaWindow;
88
+ windowMs: number | null;
89
+ }
90
+ declare function getPresentQuotaWindows(quota: AccountQuota | null): PresentQuotaWindow[];
91
+ interface SidebarAccountState {
92
+ id: string;
93
+ label: string | undefined;
94
+ /** ChatGPT identity of the account this quota belongs to. */
95
+ accountId?: string;
96
+ quota: AccountQuota | null;
97
+ killed: boolean;
98
+ enabled: boolean;
99
+ resetCredits?: number;
100
+ }
101
+ interface ActiveRoutingEntry {
102
+ activeId: string;
103
+ route: string;
104
+ updatedAt: number;
105
+ }
106
+ type ActiveRoutingMap = Record<string, ActiveRoutingEntry>;
107
+ interface StickyAssignment {
108
+ accountId: string;
109
+ wireAccountId?: string;
110
+ assignedAt: number;
111
+ lastSeenAt: number;
112
+ inputBytes: number;
113
+ quotaCheckedAt?: number;
114
+ }
115
+ type StickyAssignmentMap = Record<string, StickyAssignment>;
116
+ interface StickyAssignmentChoice {
117
+ accountId: string;
118
+ quotaCheckedAt?: number;
119
+ }
120
+ interface ResolveStickyAssignmentInput {
121
+ sessionId: string;
122
+ requestBytes: number;
123
+ now: number;
124
+ validPinnedAccountIds: readonly string[];
125
+ excludeAccountIds?: readonly string[];
126
+ quotaCheckedAtByAccount: Readonly<Record<string, number | undefined>>;
127
+ wireAccountIdByAccount?: Readonly<Record<string, string | undefined>>;
128
+ choose: (pendingBytes: ReadonlyMap<string, number>) => StickyAssignmentChoice | undefined;
129
+ }
130
+ interface SidebarState {
131
+ main: {
132
+ quota: AccountQuota | null;
133
+ /** ChatGPT identity of the main account this quota belongs to. */
134
+ mainAccountId?: string;
135
+ killed: boolean;
136
+ quotaBackedOff?: boolean;
137
+ quotaBackoffUntil?: number;
138
+ refreshBackedOff?: boolean;
139
+ refreshBackoffUntil?: number;
140
+ resetCredits?: number;
141
+ };
142
+ fallbacks: SidebarAccountState[];
143
+ /** @deprecated Compatibility field for readers that do not consume activeRouting. */
144
+ activeId: string | undefined;
145
+ /** Machine-global routing mode and compatibility value for older readers. */
146
+ route: string;
147
+ activeRouting?: ActiveRoutingMap;
148
+ stickyAssignments?: StickyAssignmentMap;
149
+ planType?: string;
150
+ credits?: number;
151
+ lastUpdated: number;
152
+ /**
153
+ * True when the accounts come from the shared account pool (a migrated
154
+ * install): `main` is then the pool row `main` and `fallbacks` are the
155
+ * other rows in roster order. Absent on any other install.
156
+ */
157
+ accountPool?: boolean;
158
+ /**
159
+ * Present while the host is in vault mode (enrolled with the Claustrum
160
+ * vault): the vault accounts that serve instead of the local accounts, in
161
+ * the vault's order. `main` then carries no account and `fallbacks` is
162
+ * empty, so a reader that does not know this field shows no local account.
163
+ * Each entry's `label` is the account's email when the vault knows it,
164
+ * else the vault's label; `enabled` is false for an account the vault will
165
+ * not serve now (declined, or waiting for a new login there).
166
+ */
167
+ vaultAccounts?: SidebarAccountState[];
168
+ }
169
+ /** Test seam: point the one-time import at a fixture instead of the temp folder. */
170
+ declare function setLegacySidebarStateFileForTest(file: string): void;
171
+ declare const STICKY_ASSIGNMENT_MAX_AGE_MS: number;
172
+ declare const STICKY_ASSIGNMENT_MAX_ENTRIES = 256;
173
+ declare function hashSidebarSessionId(sessionId: string): string;
174
+ declare function getSidebarStateFile(): string;
175
+ declare const DEFAULT_SIDEBAR_STATE: SidebarState;
176
+ /**
177
+ * Normalize an arbitrary parsed value into a well-formed SidebarState.
178
+ *
179
+ * JSON.parse + `as SidebarState` is an unchecked cast — a partial, old, or
180
+ * malformed state file passes through and the TUI's `state().main.quota` /
181
+ * `state().fallbacks.filter(...)` throw at runtime. This helper guarantees
182
+ * every required field is present and correctly typed before the value leaves
183
+ * the I/O boundary, so a bad file can never crash the host TUI.
184
+ */
185
+ declare function normalizeSidebarState(raw: unknown): SidebarState;
186
+ declare function getSidebarState(stateFile?: string): Promise<SidebarState>;
187
+ declare const ACTIVE_ROUTING_MAX_AGE_MS: number;
188
+ declare const ACTIVE_ROUTING_MAX_ENTRIES = 128;
189
+ type SidebarRoutingAccount = {
190
+ id: string;
191
+ enabled?: boolean;
192
+ killed?: boolean;
193
+ };
194
+ declare function isUsableRoutingEntry(entry: ActiveRoutingEntry, accounts: readonly SidebarRoutingAccount[] | undefined, now?: number): boolean;
195
+ declare function spendControlExhaustedResetAt(quota: AccountQuota | null | undefined, now?: number): {
196
+ resetsAt: string;
197
+ resetAtMs: number;
198
+ } | undefined;
199
+ declare function exhaustedQuotaResetAt(quota: AccountQuota | null | undefined, now?: number): {
200
+ resetsAt: string;
201
+ resetAtMs: number;
202
+ } | undefined;
203
+ declare function isQuotaExhausted(quota: AccountQuota | null | undefined, now?: number): boolean;
204
+ declare function resolveSessionStickyAccount(state: SidebarState, sessionId: string | undefined, now?: number): string | undefined;
205
+ declare function resolveSessionSidebarRouting(state: SidebarState, sessionId?: string, now?: number): {
206
+ activeId: string;
207
+ route: string;
208
+ };
209
+ declare function pruneActiveRouting(activeRouting: ActiveRoutingMap | undefined, accounts: readonly SidebarRoutingAccount[] | undefined, now?: number, removedSessionId?: string): ActiveRoutingMap | undefined;
210
+ declare function pruneStickyAssignments(assignments: StickyAssignmentMap | undefined, validAccountIds: ReadonlySet<string> | undefined, now?: number, removedSessionHash?: string): StickyAssignmentMap | undefined;
211
+ type SidebarMergeHooks = Pick<SidebarFileHooks, 'beforeRecheck'> & {
212
+ /** Whether this snapshot may still be written; checked again after lock waits. */
213
+ canWrite?: () => boolean;
214
+ };
215
+ /**
216
+ * Write sidebar state to disk, serialized through a promise chain so
217
+ * concurrent callers never interleave or let a stale write land last.
218
+ *
219
+ * @param state The state to persist.
220
+ * @param file Explicit path override — callers that bind the path at init
221
+ * time (e.g. the index.ts loader) pass this so late callbacks
222
+ * always write to the path that was current when the loader ran,
223
+ * even if the env changes underneath them during tests.
224
+ * Defaults to getSidebarStateFile() (per-call resolution).
225
+ */
226
+ declare function setSidebarState(state: SidebarState, file?: string): Promise<void>;
227
+ type SidebarMachineState = Pick<SidebarState, 'main' | 'fallbacks' | 'planType' | 'credits' | 'lastUpdated' | 'accountPool' | 'vaultAccounts'> & {
228
+ route: string;
229
+ };
230
+ declare function setSidebarMachineState(machineState: SidebarMachineState, file?: string, hooks?: SidebarMergeHooks): Promise<void>;
231
+ declare function upsertSidebarActiveRouting(input: {
232
+ sessionId: string;
233
+ } & ActiveRoutingEntry, accounts: readonly SidebarRoutingAccount[] | undefined, file?: string, hooks?: SidebarMergeHooks): Promise<void>;
234
+ declare function setSidebarLegacyRouting(input: ActiveRoutingEntry, file?: string, hooks?: SidebarMergeHooks): Promise<void>;
235
+ declare function removeSidebarActiveRouting(sessionId: string, accounts: readonly SidebarRoutingAccount[] | undefined, file?: string, hooks?: SidebarMergeHooks): Promise<void>;
236
+ interface StickyAssignmentPlan {
237
+ /** The pin the session should use, or undefined when nothing is eligible. */
238
+ assignment: StickyAssignment | undefined;
239
+ /** The state to persist, or undefined when `latest` already records it. */
240
+ next: SidebarState | undefined;
241
+ }
242
+ /**
243
+ * Decide a session's pin from one state snapshot, without touching the file.
244
+ *
245
+ * This is the whole placement decision: prune dead pins, keep a still-valid
246
+ * pin (refreshing its metadata), or place the session afresh through
247
+ * `input.choose` weighted by the bytes other sessions already committed to
248
+ * each account. The locked file merge and the request path both use it, so
249
+ * the two cannot drift apart.
250
+ */
251
+ declare function planSidebarStickyAssignment(latest: SidebarState, input: ResolveStickyAssignmentInput): StickyAssignmentPlan;
252
+ /**
253
+ * Resolve a session's pin against the file itself: an unlocked read serves a
254
+ * current pin, anything else is decided and written under the sidebar lock.
255
+ * The request path does not use this (it cannot wait on the lock); see
256
+ * `planSidebarStickyAssignment` and `persistSidebarStickyAssignment`.
257
+ */
258
+ declare function resolveSidebarStickyAssignment(input: ResolveStickyAssignmentInput, file?: string, hooks?: SidebarMergeHooks): Promise<StickyAssignment | undefined>;
259
+ /**
260
+ * Decide a session's pin in memory from a snapshot, for the request path.
261
+ * Returns the plan without reading or writing the file; the caller persists
262
+ * `plan.next` in the background when it is defined.
263
+ */
264
+ declare function planSidebarStickyAssignmentFromSnapshot(state: SidebarState, input: ResolveStickyAssignmentInput): StickyAssignmentPlan;
265
+ /**
266
+ * Record a pin the request path already decided and used.
267
+ *
268
+ * The merge prunes pins the same way placement does, then writes the given
269
+ * pin, unless another process has since placed the same session later than
270
+ * this one did: that newer pin is kept and this process picks it up on its
271
+ * next refresh. When both describe the same placement, the high-water request
272
+ * size and last-seen time are kept.
273
+ */
274
+ declare function persistSidebarStickyAssignment(input: {
275
+ sessionId: string;
276
+ assignment: StickyAssignment;
277
+ validPinnedAccountIds: readonly string[];
278
+ }, file?: string): Promise<void>;
279
+ declare function clearSidebarStickyAssignment(sessionId: string, file?: string): Promise<boolean>;
280
+ /**
281
+ * Await all pending sidebar writes. Tests call this before restoring env
282
+ * vars in teardown so no in-flight write can re-resolve getSidebarStateFile()
283
+ * after the env is changed.
284
+ */
285
+ declare function drainSidebarWrites(): Promise<void>;
286
+ /**
287
+ * Longest a request waits for a lock-free read of a local bookkeeping file
288
+ * before it goes ahead with the previous snapshot. A read of these few-kilobyte
289
+ * files normally takes well under a millisecond; the budget only bounds a
290
+ * pathological disk. The read keeps running and refreshes the cache for the
291
+ * next request.
292
+ */
293
+ declare const HOT_PATH_READ_BUDGET_MS = 500;
294
+ /**
295
+ * Settle with `read` if it settles within `budgetMs`, otherwise with the value
296
+ * `stale` returns at that moment. A rejection within the budget is passed on;
297
+ * one after it is dropped, because the caller has already moved on.
298
+ */
299
+ declare function settleWithinBudget<T>(read: Promise<T>, budgetMs: number, stale: () => T): Promise<T>;
300
+ interface SidebarSnapshot {
301
+ state: SidebarState;
302
+ /**
303
+ * `Date.now()` when the read that produced `state` started (0 when no read
304
+ * has completed yet). Anything written to the file before this time is in
305
+ * `state`.
306
+ */
307
+ readAt: number;
308
+ }
309
+ interface SidebarStateCache {
310
+ /**
311
+ * The snapshot for one request. Costs one `stat` when the file is
312
+ * unchanged. A changed file (or the first call) is read without any lock,
313
+ * waiting at most `HOT_PATH_READ_BUDGET_MS`; past that the previous
314
+ * snapshot is served, or the default state when there is none, which is
315
+ * what an unreadable file has always meant.
316
+ */
317
+ get(): Promise<SidebarSnapshot>;
318
+ /** Read the file now and keep the result; for background callers. */
319
+ read(): Promise<SidebarSnapshot>;
320
+ /** Re-read in the background if the file changed since the last read. */
321
+ refreshInBackground(): void;
322
+ }
323
+ declare function createSidebarStateCache(file: string, options?: {
324
+ readBudgetMs?: number;
325
+ }): SidebarStateCache;
326
+ /**
327
+ * A pin this process decided and is using, possibly not yet on disk. It keeps
328
+ * the session on the same account in this process even when persisting it
329
+ * failed, and it is dropped once a snapshot read after the pin landed is in
330
+ * hand: from then on the file is authoritative, including a newer placement
331
+ * another process made.
332
+ */
333
+ interface StickyPinOverlayEntry {
334
+ assignment: StickyAssignment;
335
+ /** `Date.now()` after the pin was written to the file. */
336
+ persistedAt?: number;
337
+ }
338
+ type StickyPinOverlay = Map<string, StickyPinOverlayEntry>;
339
+ /** Record a pin, keeping the map within the file's own pin limit. */
340
+ declare function rememberStickyPin(overlay: StickyPinOverlay, sessionHash: string, assignment: StickyAssignment): StickyPinOverlayEntry;
341
+ /** The snapshot's state with this process's not-yet-visible pins applied. */
342
+ declare function applyStickyPinOverlay(snapshot: SidebarSnapshot, overlay: StickyPinOverlay): SidebarState;
343
+ interface SidebarBookkeepingQueue {
344
+ /**
345
+ * Start a write now and return without waiting for it. Starting it
346
+ * synchronously puts it on the shared write chain in call order, so
347
+ * `drainSidebarWrites` covers it. A failure is logged once and retried from
348
+ * a timer; a newer write under the same key replaces a pending retry.
349
+ * `label` names the kind of write in logs and must not identify a session.
350
+ */
351
+ enqueue(key: string, label: string, write: () => Promise<void>): void;
352
+ /** Forget a pending retry and ignore the outcome of a write in flight. */
353
+ cancel(key: string): void;
354
+ /** Stop retrying; writes already started still run. */
355
+ stop(): void;
356
+ }
357
+ declare function createSidebarBookkeepingQueue(options: {
358
+ logger: ReturnType<typeof createLogger>;
359
+ retryDelayMs?: number;
360
+ maxRetryDelayMs?: number;
361
+ /** Called after each write that lands. */
362
+ onWritten?: () => void;
363
+ }): SidebarBookkeepingQueue;
364
+ declare function resolveActiveAccount(state: SidebarState): {
365
+ id: string;
366
+ name: string;
367
+ quota: AccountQuota | null;
368
+ killed: boolean;
369
+ };
370
+ /** Keep provider window lengths and per-window reading times when projecting old sidebar snapshots. */
371
+ declare function sidebarQuotaProjection(quota: AccountQuota | null, now?: number): ProjectedQuota | undefined;
372
+ declare function getCollapsedQuotaSummary(quota: AccountQuota | null, now?: number): {
373
+ primaryUsedPercent: number | null;
374
+ secondaryUsedPercent: number | null;
375
+ text: string | null;
376
+ };
377
+ interface QuotaPacing {
378
+ pacePercent: number;
379
+ deltaPercent: number;
380
+ state: 'deficit' | 'reserve' | 'on-pace';
381
+ runsOutAt: string | null;
382
+ }
383
+ declare function computeQuotaPacing(window: QuotaWindow, windowMs: number, now: number): QuotaPacing | null;
384
+ //#endregion
385
+ export { resolveSessionSidebarRouting as $, clearSidebarStickyAssignment as A, getSidebarStateFile as B, StickyAssignment as C, StickyPinOverlay as D, StickyAssignmentPlan as E, exhaustedQuotaResetAt as F, persistSidebarStickyAssignment as G, isQuotaExhausted as H, formatWindowLabel as I, pruneActiveRouting as J, planSidebarStickyAssignment as K, getCollapsedQuotaSummary as L, createSidebarBookkeepingQueue as M, createSidebarStateCache as N, StickyPinOverlayEntry as O, drainSidebarWrites as P, resolveActiveAccount as Q, getPresentQuotaWindows as R, SpendControlReading as S, StickyAssignmentMap as T, isUsableRoutingEntry as U, hashSidebarSessionId as V, normalizeSidebarState as W, rememberStickyPin as X, pruneStickyAssignments as Y, removeSidebarActiveRouting as Z, SidebarMachineState as _, ActiveRoutingMap as a, setSidebarState as at, SidebarState as b, PresentQuotaWindow as c, spendControlExhaustedResetAt as ct, QuotaWindowKey as d, resolveSessionStickyAccount as et, ResolveStickyAssignmentInput as f, SidebarBookkeepingQueue as g, SidebarAccountState as h, ActiveRoutingEntry as i, setSidebarMachineState as it, computeQuotaPacing as j, applyStickyPinOverlay as k, QuotaPacing as l, upsertSidebarActiveRouting as lt, STICKY_ASSIGNMENT_MAX_ENTRIES as m, ACTIVE_ROUTING_MAX_ENTRIES as n, setLegacySidebarStateFileForTest as nt, DEFAULT_SIDEBAR_STATE as o, settleWithinBudget as ot, STICKY_ASSIGNMENT_MAX_AGE_MS as p, planSidebarStickyAssignmentFromSnapshot as q, AccountQuota as r, setSidebarLegacyRouting as rt, HOT_PATH_READ_BUDGET_MS as s, sidebarQuotaProjection as st, ACTIVE_ROUTING_MAX_AGE_MS as t, resolveSidebarStickyAssignment as tt, QuotaWindow as u, SidebarRoutingAccount as v, StickyAssignmentChoice as w, SidebarStateCache as x, SidebarSnapshot as y, getSidebarState as z };
@@ -1,2 +1,2 @@
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-CoKYKcLn.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 };
1
+ import { $ as resolveSessionSidebarRouting, A as clearSidebarStickyAssignment, B as getSidebarStateFile, C as StickyAssignment, D as StickyPinOverlay, E as StickyAssignmentPlan, F as exhaustedQuotaResetAt, G as persistSidebarStickyAssignment, H as isQuotaExhausted, I as formatWindowLabel, J as pruneActiveRouting, K as planSidebarStickyAssignment, L as getCollapsedQuotaSummary, M as createSidebarBookkeepingQueue, N as createSidebarStateCache, O as StickyPinOverlayEntry, P as drainSidebarWrites, Q as resolveActiveAccount, R as getPresentQuotaWindows, S as SpendControlReading, T as StickyAssignmentMap, U as isUsableRoutingEntry, V as hashSidebarSessionId, W as normalizeSidebarState, X as rememberStickyPin, Y as pruneStickyAssignments, Z as removeSidebarActiveRouting, _ as SidebarMachineState, a as ActiveRoutingMap, at as setSidebarState, b as SidebarState, c as PresentQuotaWindow, ct as spendControlExhaustedResetAt, d as QuotaWindowKey, et as resolveSessionStickyAccount, f as ResolveStickyAssignmentInput, g as SidebarBookkeepingQueue, h as SidebarAccountState, i as ActiveRoutingEntry, it as setSidebarMachineState, j as computeQuotaPacing, k as applyStickyPinOverlay, l as QuotaPacing, lt as upsertSidebarActiveRouting, m as STICKY_ASSIGNMENT_MAX_ENTRIES, n as ACTIVE_ROUTING_MAX_ENTRIES, nt as setLegacySidebarStateFileForTest, o as DEFAULT_SIDEBAR_STATE, ot as settleWithinBudget, p as STICKY_ASSIGNMENT_MAX_AGE_MS, q as planSidebarStickyAssignmentFromSnapshot, r as AccountQuota, rt as setSidebarLegacyRouting, s as HOT_PATH_READ_BUDGET_MS, st as sidebarQuotaProjection, t as ACTIVE_ROUTING_MAX_AGE_MS, tt as resolveSidebarStickyAssignment, u as QuotaWindow, v as SidebarRoutingAccount, w as StickyAssignmentChoice, x as SidebarStateCache, y as SidebarSnapshot, z as getSidebarState } from "./sidebar-state-D6cUKgkm.js";
2
+ export { ACTIVE_ROUTING_MAX_AGE_MS, ACTIVE_ROUTING_MAX_ENTRIES, AccountQuota, ActiveRoutingEntry, ActiveRoutingMap, 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, applyStickyPinOverlay, clearSidebarStickyAssignment, computeQuotaPacing, createSidebarBookkeepingQueue, createSidebarStateCache, drainSidebarWrites, exhaustedQuotaResetAt, formatWindowLabel, 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 +1 @@
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-g3hsdjh4.js";import"./index-sq36b120.js";import"./index-hh52v8sb.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
+ import{$a as e,Ab as F,Bb as G,Cb as H,Db as I,Eb as J,Fb as K,Gb as L,Hb as M,Ib as N,Jb as O,Xa as a,Ya as b,Za as c,_a as d,ab as f,bb as g,cb as h,db as i,eb as j,fb as k,gb as l,hb as m,ib as n,jb as o,kb as p,lb as q,mb as r,nb as s,ob as t,pb as u,qb as v,rb as w,sb as x,tb as y,ub as z,vb as A,wb as B,xb as C,yb as D,zb as E}from"./index-eqh53k8v.js";import"./index-jyr8y8k4.js";import"./index-bmd7x5aq.js";import"./index-b3q3j39x.js";export{w as upsertSidebarActiveRouting,n as spendControlExhaustedResetAt,M as sidebarQuotaProjection,G as settleWithinBudget,u as setSidebarState,v as setSidebarMachineState,x as setSidebarLegacyRouting,c as setLegacySidebarStateFileForTest,A as resolveSidebarStickyAssignment,q as resolveSessionStickyAccount,r as resolveSessionSidebarRouting,L as resolveActiveAccount,y as removeSidebarActiveRouting,I as rememberStickyPin,t as pruneStickyAssignments,s as pruneActiveRouting,B as planSidebarStickyAssignmentFromSnapshot,z as planSidebarStickyAssignment,C as persistSidebarStickyAssignment,i as normalizeSidebarState,m as isUsableRoutingEntry,p as isQuotaExhausted,f as hashSidebarSessionId,g as getSidebarStateFile,j as getSidebarState,b as getPresentQuotaWindows,N as getCollapsedQuotaSummary,a as formatWindowLabel,o as exhaustedQuotaResetAt,E as drainSidebarWrites,H as createSidebarStateCache,K as createSidebarBookkeepingQueue,O as computeQuotaPacing,D as clearSidebarStickyAssignment,J as applyStickyPinOverlay,e as STICKY_ASSIGNMENT_MAX_ENTRIES,d as STICKY_ASSIGNMENT_MAX_AGE_MS,F as HOT_PATH_READ_BUDGET_MS,h as DEFAULT_SIDEBAR_STATE,l as ACTIVE_ROUTING_MAX_ENTRIES,k as ACTIVE_ROUTING_MAX_AGE_MS};
@@ -0,0 +1 @@
1
+ import{b as a}from"./index-hy9030jh.js";import"./index-b3q3j39x.js";export default a();
@@ -1 +1 @@
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();
1
+ import{a as U,b as V}from"./index-hy9030jh.js";import{tc as R}from"./index-b3q3j39x.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,6 +1,9 @@
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.
1
+ import{Lb as p,Rb as l,Sb as m}from"./index-jyr8y8k4.js";import{sc as Hz,tc as zz,vc as y}from"./index-b3q3j39x.js";var x=zz((c,b)=>{(function(Q){if(typeof b==="object"&&typeof b.exports==="object"){var H=Q(y,c);if(H!==void 0)b.exports=H}else if(typeof define==="function"&&define.amd)define(["require","exports","./impl/format","./impl/edit","./impl/scanner","./impl/parser"],Q)})(function(Q,H){Object.defineProperty(H,"__esModule",{value:!0}),H.applyEdits=H.modify=H.format=H.printParseErrorCode=H.ParseErrorCode=H.stripComments=H.visit=H.getNodeValue=H.getNodePath=H.findNodeAtOffset=H.findNodeAtLocation=H.parseTree=H.parse=H.getLocation=H.SyntaxKind=H.ScanError=H.createScanner=void 0;let X=Q("./impl/format"),Z=Q("./impl/edit"),G=Q("./impl/scanner"),$=Q("./impl/parser");H.createScanner=G.createScanner;var B;(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"})(B||(H.ScanError=B={}));var D;(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"})(D||(H.SyntaxKind=D={})),H.getLocation=$.getLocation,H.parse=$.parse,H.parseTree=$.parseTree,H.findNodeAtLocation=$.findNodeAtLocation,H.findNodeAtOffset=$.findNodeAtOffset,H.getNodePath=$.getNodePath,H.getNodeValue=$.getNodeValue,H.visit=$.visit,H.stripComments=$.stripComments;var M;(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"})(M||(H.ParseErrorCode=M={}));function R(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>"}H.printParseErrorCode=R;function W(z,N,V){return X.format(z,N,V)}H.format=W;function J(z,N,V,U){return Z.setProperty(z,N,V,U)}H.modify=J;function Y(z,N){let V=N.slice(0).sort((I,j)=>{let T=I.offset-j.offset;if(T===0)return I.length-j.length;return T}),U=z.length;for(let I=V.length-1;I>=0;I--){let j=V[I];if(j.offset+j.length<=U)z=Z.applyEdit(z,j);else throw Error("Overlapping edit");U=j.offset}return z}H.applyEdits=Y})});import{mkdir as Dz,writeFile as Uz}from"node:fs/promises";import{homedir as Iz}from"node:os";import{dirname as jz,join as h}from"node:path";var F=Hz(x(),1);import{readFile as d}from"node:fs/promises";function Qz(Q){return Q!==null&&typeof Q==="object"&&!Array.isArray(Q)}async function K(Q){try{let H=[],X=F.parse(await d(Q,"utf8"),H,{allowTrailingComma:!0});return H.length===0&&Qz(X)?X:{}}catch{return{}}}var Xz=`// Shared preferences for TUI plugins.
2
+ // Plugins update individual keys in place and preserve comments.
3
+ {}
4
+ `;function P(Q){let{file:H,pluginKey:X,beforeCommit:Z}=Q,G={...m.preferences,timeoutMs:Q.timeoutMs??m.preferences.timeoutMs},$=Promise.resolve();async function B(D,M){await l(H,G,async(R)=>{let W;try{W=await d(H,"utf8")}catch(Y){if(Y.code!=="ENOENT")throw Y;W=""}if(W.trim()==="")W=Xz;let J=F.applyEdits(W,F.modify(W,[X,...D],M,{formattingOptions:{insertSpaces:!0,tabSize:2}}));await p(H,J,{serialize:(Y)=>String(Y),beforeRename:async()=>{await Z?.(),await R.assertOwned()}})})}return{queueTuiPreferenceUpdate(D,M){let R=[...D],W=structuredClone(M),J=$.then(()=>B(R,W));return $=J.catch(()=>{}),J}}}import{readFileSync as Zz,realpathSync as $z,statSync as Bz,watch as Gz}from"node:fs";import{readFile as Jz,stat as Yz}from"node:fs/promises";import{basename as n,dirname as a,join as Vz,resolve as Wz}from"node:path";import{clearTimeout as f,setTimeout as s}from"node:timers";function t(Q){let H=Wz(Q);try{return $z(H)}catch{let X=a(H);return X===H?H:Vz(t(X),n(H))}}function i(Q){return Q&&`${Q.dev}:${Q.ino}:${Q.mtimeMs}:${Q.size}`}function C(Q,H,X={}){let Z=globalThis,G=Symbol.for("cortexkit.common-auth.tui-prefs.watchers.v1"),$=Z[G]??new Map;Z[G]=$;let B=t(Q),D=$.get(B);if(D)return D.subscribe(H);let M=n(B),R=X.fs?.readFile??((L)=>Jz(L,"utf8")),W=X.fs?.stat??Yz,J=null,Y=null,z=null,N=null;try{let L=i((X.fs?.statSync??Bz)(B));N=(X.fs?.readFileSync??((q)=>Zz(q,"utf8")))(B),z=L}catch{}let V=!1,U=new Set,I=Promise.resolve(),j=(L)=>{return I=I.then(async()=>{if(V)return;let q=i(await W(B).catch(()=>null));if(!L&&q===z)return;if(q===null){z=null;return}let O=await R(B).catch(()=>null);if(V)return;if(O===null)return;if(z=q,O===N)return;N=O;for(let g of[...U]){if(!U.has(g))continue;try{g.notify()}catch{}}}),I},T=()=>{if(V)return;if(J)f(J);J=s(()=>{J=null,j(!0)},150)},k=null;try{k=(X.watchDirectory??Gz)(a(B),(L,q)=>{let O=q?.toString(),g=O===M||O?.startsWith(`${M}.`)&&O.endsWith(".tmp");if(O!=null&&!g)return;T()}),k.on("error",()=>{k?.close(),k=null})}catch{}let E=()=>{if(V||Y)return;Y=s(()=>{if(Y=null,V)return;j(!1).finally(E)},1000),Y.unref()},v={subscribe:(L)=>{let q={notify:L};return U.add(q),()=>{if(!U.delete(q)||U.size>0)return;if(V=!0,J)f(J);if(Y)f(Y);if(k?.close(),$.get(B)===v)$.delete(B)}}};return $.set(B,v),E(),v.subscribe(H)}var qz="OPENCODE_TUI_PREFERENCES_FILE",Mz="tui-preferences.jsonc";function S(){let Q=process.env[qz];if(Q)return Q;let H=process.env.OPENCODE_CONFIG_DIR||h(process.env.XDG_CONFIG_HOME||h(Iz(),".config"),"opencode");return h(H,Mz)}function w(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function lz(){return K(S())}var Nz="openai-auth",Az=160,o={forceToTop:!1,order:Az,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 A(Q,H){return typeof Q==="boolean"?Q:H}function _(Q,H,X,Z){if(typeof Q!=="number"||!Number.isFinite(Q))return H;return Math.min(Math.max(Math.round(Q),X),Z)}function Lz(Q,H,X){if(typeof Q!=="string"||Q.length===0)return H;return Q.slice(0,X)}function e(Q,H){if(typeof Q!=="string")return H;return[...Q][0]??H}function dz(Q){let H=Q[Nz];if(!w(H))return structuredClone(o);let X=o,Z=w(H.header)?H.header:{},G=w(H.sections)?H.sections:{},$=w(H.appearance)?H.appearance:{},B=_($.warnThreshold,X.appearance.warnThreshold,0,99),D=Math.max(_($.errorThreshold,X.appearance.errorThreshold,0,100),Math.min(B+1,100));return{forceToTop:A(H.forceToTop,X.forceToTop),order:_(H.order,X.order,-1e4,1e4),startCollapsed:A(H.startCollapsed,X.startCollapsed),rememberCollapsed:A(H.rememberCollapsed,X.rememberCollapsed),collapsed:typeof H.collapsed==="boolean"?H.collapsed:null,pollMs:_(H.pollMs,X.pollMs,500,30000),refreshDebounceMs:_(H.refreshDebounceMs,X.refreshDebounceMs,50,5000),header:{label:Lz(Z.label,X.header.label,20),showVersion:A(Z.showVersion,X.header.showVersion)},sections:{quota:A(G.quota,X.sections.quota),fallbackAccounts:A(G.fallbackAccounts,X.sections.fallbackAccounts),routing:A(G.routing,X.sections.routing),health:A(G.health,X.sections.health),pacing:A(G.pacing,X.sections.pacing)},appearance:{barWidth:_($.barWidth,X.appearance.barWidth,4,40),barFilledChar:e($.barFilledChar,X.appearance.barFilledChar),barEmptyChar:e($.barEmptyChar,X.appearance.barEmptyChar),warnThreshold:B,errorThreshold:D}}}var Oz=-1e5;function sz(Q,H,X){let Z=Q[H];if(!w(Z))return X;if(Z.forceToTop===!0)return Oz+Object.keys(Q).indexOf(H);return _(Z.order,X,-1e4,1e4)}var Rz=`// Shared preferences for opencode TUI plugins.
2
5
  // One top-level key per plugin (short name). See each plugin's README for
3
6
  // its supported settings. This file is safe to hand-edit; plugins update
4
7
  // individual keys in place and preserve comments.
5
8
  {}
6
- `;async function a(Q,J,X){let Z=w();await c(v(Z),{recursive:!0});let G;try{G=await O(Z,"utf8")}catch{G=""}if(G.trim()==="")G=t;let $=M.modify(G,[Q,...J],X,{formattingOptions:{insertSpaces:!0,tabSize:2}}),W=M.applyEdits(G,$),H=`${Z}.${process.pid}.tmp`;await S(H,W,"utf8"),await y(H,Z)}var R=Promise.resolve();function Gz(Q,J,X){return R=R.then(()=>a(Q,J,X)).catch(()=>{}),R}var o=150;function Hz(Q){let J=w(),X=l(J),Z=null,G=null;O(J,"utf8").then(($)=>{if(G===null)G=$}).catch(()=>{});try{let $=K(v(J),(W,H)=>{let q=H===X||H?.startsWith(`${X}.`)&&H.endsWith(".tmp");if(H!=null&&!q)return;if(Z)clearTimeout(Z);Z=setTimeout(()=>{Z=null,O(J,"utf8").catch(()=>null).then((D)=>{if(D===null)return;if(D===G)return;G=D,Q()})},o)});return()=>{if(Z)clearTimeout(Z);$.close()}}catch{return()=>{}}}export{Hz as watchTuiPreferences,Zz as resolveOpenaiAuthPrefs,Xz as readTuiPreferencesFile,Gz as queueTuiPreferenceUpdate,w as getTuiPreferencesFile,$z as computeEffectiveOrder,p as TUI_PREFS_FILE_ENV,i as PLUGIN_KEY,s as DEFAULT_SLOT_ORDER,b as DEFAULT_PREFS};
9
+ `,r=new Map;function _z(Q,H){let X=JSON.stringify([Q,H]),Z=r.get(X);if(!Z)Z=P({file:Q,pluginKey:H}),r.set(X,Z);return Z}async function Fz(Q){await Dz(jz(Q),{recursive:!0}),await Uz(Q,Rz,{encoding:"utf8",flag:"wx"}).catch(()=>{})}var u=Promise.resolve();function iz(Q,H,X){let Z=S(),G=_z(Z,Q);return u=u.then(()=>Fz(Z)).then(()=>G.queueTuiPreferenceUpdate(H,X)).catch(()=>{}),u}function nz(Q){return C(S(),Q)}export{nz as watchTuiPreferences,dz as resolveOpenaiAuthPrefs,lz as readTuiPreferencesFile,iz as queueTuiPreferenceUpdate,S as getTuiPreferencesFile,sz as computeEffectiveOrder,qz as TUI_PREFS_FILE_ENV,Nz as PLUGIN_KEY,Az as DEFAULT_SLOT_ORDER,o as DEFAULT_PREFS};
package/dist/tui.d.ts CHANGED
@@ -1,15 +1,16 @@
1
- import { a as CommandModalName, r as ApplyRequest } from "./internal-BTndPmW2.js";
2
- import { b as SidebarState, c as QuotaPacing, l as QuotaWindow, r as AccountQuota, x as SpendControlReading } from "./sidebar-state-CoKYKcLn.js";
3
- import "./rpc/protocol.js";
1
+ import { t as ApplyRequest } from "./protocol-BOBdkqqm.js";
2
+ import { S as SpendControlReading, b as SidebarState, l as QuotaPacing, r as AccountQuota, u as QuotaWindow } from "./sidebar-state-D6cUKgkm.js";
4
3
  import { TuiPluginModule } from "@opencode-ai/plugin/tui";
5
4
  //#region src/tui.d.ts
6
- export declare function buildApplyRequest(command: CommandModalName, arguments_: string, sessionId?: string): ApplyRequest;
5
+ /** One drawer action as the RPC apply request carries it, with its session. */
6
+ export declare function buildApplyRequest(request: Omit<ApplyRequest, 'sessionId'>, sessionId?: string): ApplyRequest;
7
7
  type Tone = 'ok' | 'warn' | 'err' | 'muted' | 'accent' | 'text';
8
8
  export declare function formatResetIn(resetsAt: string | undefined): string;
9
9
  export interface QuotaDisplayRow {
10
10
  key: 'primary' | 'secondary' | 'spendControl';
11
11
  label: string;
12
12
  labelWidth: number;
13
+ text: string;
13
14
  window: QuotaWindow;
14
15
  pacing: QuotaPacing | null;
15
16
  }
@@ -30,6 +31,10 @@ export declare function renderedQuotas(state: {
30
31
  enabled?: boolean;
31
32
  quota?: AccountQuota | null;
32
33
  }>;
34
+ vaultAccounts?: ReadonlyArray<{
35
+ enabled?: boolean;
36
+ quota?: AccountQuota | null;
37
+ }>;
33
38
  }): ReadonlyArray<AccountQuota | null | undefined>;
34
39
  export declare function computeQuotaLabelWidth(quotas: ReadonlyArray<AccountQuota | null | undefined>): number;
35
40
  export declare function buildQuotaRowsForDisplay(quota: AccountQuota | null, now: number, pacingEnabled: boolean, labelWidth?: number): QuotaDisplayRow[];
@@ -0,0 +1,54 @@
1
+ import { a as BeginAccountLoginOptions, f as AccountPaths, i as OpenAiVaultOptions, n as HostSlotAdapter, o as BeginAccountLoginResult, t as PoolLifecycleDeps } from "../pool-lifecycle-DbDmgabd.js";
2
+ import { Plugin } from "@opencode/plugin";
3
+ import "@opencode/plugin/promise/session";
4
+ import "@opencode/plugin/promise/integration";
5
+ import "@opencode/plugin/promise/registration";
6
+ //#region src/v2/login.d.ts
7
+ type BeginLogin = (options: BeginAccountLoginOptions) => Promise<BeginAccountLoginResult>;
8
+ //#endregion
9
+ //#region src/v2/setup.d.ts
10
+ /**
11
+ * The plugin id both hosts list this plugin under: the OpenCode 1 plugin's
12
+ * own id, since OpenCode 1 reads the `./server` entry as well.
13
+ */
14
+ export declare const OPENAI_AUTH_PLUGIN_ID = "cortexkit-openai-auth";
15
+ /** Test and embedding seams; every field has a production default. */
16
+ interface OpenAIAuthV2Options {
17
+ /** The account config and state files; read on every use. */
18
+ paths?: () => AccountPaths;
19
+ /** OpenCode 1's login slot the migration reads; its `auth.json` by default. */
20
+ slot?: HostSlotAdapter;
21
+ /** This build's version, for the heartbeat and the version fence. */
22
+ version?: string;
23
+ /** Used for token refreshes and quota polls. */
24
+ fetch?: typeof fetch;
25
+ /** Starts one ChatGPT login (`beginAccountLogin`). */
26
+ beginLogin?: BeginLogin;
27
+ /** The migration's version fence; `migrationFenceOpen` for `version` by default. */
28
+ fence?: PoolLifecycleDeps['fence'];
29
+ /** Overrides `POOL_MIGRATION_ENABLED`, so tests can run the migration. */
30
+ poolMigration?: boolean;
31
+ /** Whether to write this process's heartbeat (other processes' fence reads it). */
32
+ heartbeat?: boolean;
33
+ /** The vault's directory and connections; the production ones by default. */
34
+ vault?: Partial<Pick<OpenAiVaultOptions, 'stateDir' | 'connectionFile' | 'connectScoped' | 'connectEnrollment' | 'pollIntervalMs'>> & {
35
+ /**
36
+ * Longest an adoption or the pool source's first quota polls wait for
37
+ * the vault's first roster; `VAULT_FIRST_ROSTER_BACKGROUND_WAIT_MS` by
38
+ * default.
39
+ */
40
+ firstRosterWaitMs?: number;
41
+ };
42
+ }
43
+ export declare function createOpenAIAuthPlugin(options?: OpenAIAuthV2Options): Plugin.Plugin;
44
+ //#endregion
45
+ //#region src/v2/server.d.ts
46
+ declare const _default: {
47
+ id: string;
48
+ /** OpenCode 2. */
49
+ setup: (context: import("@opencode/plugin/promise/plugin").Context) => Promise<import("@opencode/plugin/promise/plugin").Cleanup | void> | import("@opencode/plugin/promise/plugin").Cleanup | void;
50
+ /** OpenCode 1. */
51
+ server: import("@opencode-ai/plugin").Plugin;
52
+ };
53
+ //#endregion
54
+ export { type OpenAIAuthV2Options, _default as default };