@cortexkit/opencode-openai-auth 1.0.5 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +9 -8
- package/dist/{pool-lifecycle-C_6YRmsh.d.ts → codex-request-CjXETpTA.d.ts} +190 -27
- package/dist/index-03em8hv1.js +69 -0
- package/dist/index-6n4pnfkg.js +2 -0
- package/dist/{index-pg305s90.js → index-bc89akak.js} +1 -1
- package/dist/{index-y4gxyxqd.js → index-ehjj89rx.js} +2 -2
- package/dist/index-f21addzm.js +90 -0
- package/dist/{index-fsky1rsh.js → index-ffg0sgg5.js} +2 -2
- package/dist/{index-nx2qh047.js → index-ftkhhr6d.js} +1 -1
- package/dist/{index-826s1yxa.js → index-htvcmtcx.js} +2 -2
- package/dist/{index-fsxbncpw.js → index-qp5hdpw8.js} +1 -1
- package/dist/index-qxbchh2d.js +8 -0
- package/dist/{index-116q849r.js → index-r2s51ac1.js} +2 -2
- package/dist/index-rwbrhkse.js +65 -0
- package/dist/{index-66asrje2.js → index-xwvze96g.js} +1 -1
- package/dist/index.d.ts +18 -8
- package/dist/index.js +1 -1
- package/dist/{protocol-DctqemRI.d.ts → model-CQcw10oW.d.ts} +67 -25
- package/dist/{port-file-ZPlxXB4G.d.ts → port-file-BDJnzgHH.d.ts} +1 -1
- package/dist/protocol-C-kagE6O.d.ts +29 -0
- package/dist/rpc/port-file.d.ts +1 -1
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/protocol.d.ts +1 -1
- package/dist/rpc/protocol.js +1 -1
- package/dist/rpc/rpc-client.d.ts +3 -3
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/{sidebar-state-z_M7Trnd.d.ts → sidebar-state-BfQ4mpZO.d.ts} +109 -10
- package/dist/sidebar-state.d.ts +2 -2
- package/dist/sidebar-state.js +1 -1
- package/dist/token-util-cf0nyh7n.js +1 -0
- package/dist/{token-bzhkgc29.js → token-z6qq7a1d.js} +1 -1
- package/dist/tui-preferences.js +1 -1
- package/dist/tui.d.ts +20 -2
- package/dist/v2/server.d.ts +180 -1
- package/dist/v2/server.js +3 -3
- package/package.json +3 -3
- package/src/tui-compiled/raw/shared/0332701351b3eeec-format.js +148 -26
- package/src/tui-compiled/raw/shared/0f77ebc3c914c9c6-custody.js +371 -0
- package/src/tui-compiled/raw/shared/134b008900698fe0-backoff.js +92 -0
- package/src/tui-compiled/raw/shared/169b2b4bf30909bc-consumer.js +430 -0
- package/src/tui-compiled/raw/shared/2577ec69f9973ae9-quota-normalize.js +154 -0
- package/src/tui-compiled/raw/shared/2dce6e9613993329-quota-manager.js +473 -0
- package/src/tui-compiled/raw/shared/30f5bc480f31f51c-roster.js +566 -0
- package/src/tui-compiled/raw/shared/43fc9e6b994519c7-refresh-lock.js +0 -1
- package/src/tui-compiled/raw/shared/4593a4d71edf69fd-tombstone.js +25 -0
- package/src/tui-compiled/raw/shared/4d05c2d7a531aece-oauth.js +500 -0
- package/src/tui-compiled/raw/shared/6371b24a0573d79e-any-signal.js +42 -0
- package/src/tui-compiled/raw/shared/7c140680fc81be92-interlock.js +29 -0
- package/src/tui-compiled/raw/shared/85512cc5263ba259-provider.js +87 -0
- package/src/tui-compiled/raw/shared/abd062d633e29fd2-pool-routing.js +192 -0
- package/src/tui-compiled/raw/shared/b9588ad4725c1d10-enrollment.js +806 -0
- package/src/tui-compiled/raw/shared/bfbdd0f9aae56b47-pool-quota.js +85 -0
- package/src/tui-compiled/raw/shared/c852a15cfe489d12-pool.js +0 -1
- package/src/tui-compiled/raw/shared/ca0fccaba1d87af4-errors.js +8 -0
- package/src/tui-compiled/raw/shared/d0f0b6be200311af-insula.js +152 -0
- package/src/tui-compiled/raw/shared/d5a8f1061ee2f114-index.js +1 -1
- package/src/tui-compiled/raw/shared/d9d2892a4c371301-host-slot.js +72 -0
- package/src/tui-compiled/raw/shared/dbc61cd405941828-accounts.js +1470 -0
- package/src/tui-compiled/raw/shared/e8cd4929507508d8-refresh-file-lock.js +26 -12
- package/src/tui-compiled/raw/shared/e8d3c8da776ef9cd-index.js +24 -0
- package/src/tui-compiled/raw/sidebar-state.js +103 -14
- package/src/tui-compiled/raw/tui/command-dialogs.tsx +3 -34
- package/src/tui-compiled/raw/tui/section-text.js +21 -0
- package/src/tui-compiled/raw/tui/v2-dialog.js +137 -0
- package/src/tui-compiled/raw/tui/v2.tsx +133 -0
- package/src/tui-compiled/raw/tui.tsx +228 -70
- package/src/tui-compiled/runtime/shared/0332701351b3eeec-format.js +148 -26
- package/src/tui-compiled/runtime/shared/0f77ebc3c914c9c6-custody.js +371 -0
- package/src/tui-compiled/runtime/shared/134b008900698fe0-backoff.js +92 -0
- package/src/tui-compiled/runtime/shared/169b2b4bf30909bc-consumer.js +430 -0
- package/src/tui-compiled/runtime/shared/2577ec69f9973ae9-quota-normalize.js +154 -0
- package/src/tui-compiled/runtime/shared/2dce6e9613993329-quota-manager.js +473 -0
- package/src/tui-compiled/runtime/shared/30f5bc480f31f51c-roster.js +566 -0
- package/src/tui-compiled/runtime/shared/43fc9e6b994519c7-refresh-lock.js +0 -1
- package/src/tui-compiled/runtime/shared/4593a4d71edf69fd-tombstone.js +25 -0
- package/src/tui-compiled/runtime/shared/4d05c2d7a531aece-oauth.js +500 -0
- package/src/tui-compiled/runtime/shared/6371b24a0573d79e-any-signal.js +42 -0
- package/src/tui-compiled/runtime/shared/7c140680fc81be92-interlock.js +29 -0
- package/src/tui-compiled/runtime/shared/85512cc5263ba259-provider.js +87 -0
- package/src/tui-compiled/runtime/shared/abd062d633e29fd2-pool-routing.js +192 -0
- package/src/tui-compiled/runtime/shared/b9588ad4725c1d10-enrollment.js +806 -0
- package/src/tui-compiled/runtime/shared/bfbdd0f9aae56b47-pool-quota.js +85 -0
- package/src/tui-compiled/runtime/shared/c852a15cfe489d12-pool.js +0 -1
- package/src/tui-compiled/runtime/shared/ca0fccaba1d87af4-errors.js +8 -0
- package/src/tui-compiled/runtime/shared/d0f0b6be200311af-insula.js +152 -0
- package/src/tui-compiled/runtime/shared/d5a8f1061ee2f114-index.js +1 -1
- package/src/tui-compiled/runtime/shared/d9d2892a4c371301-host-slot.js +72 -0
- package/src/tui-compiled/runtime/shared/dbc61cd405941828-accounts.js +1470 -0
- package/src/tui-compiled/runtime/shared/e8cd4929507508d8-refresh-file-lock.js +26 -12
- package/src/tui-compiled/runtime/shared/e8d3c8da776ef9cd-index.js +24 -0
- package/src/tui-compiled/runtime/sidebar-state.js +103 -14
- package/src/tui-compiled/runtime/tui/command-dialogs.js +3 -15
- package/src/tui-compiled/runtime/tui/section-text.js +21 -0
- package/src/tui-compiled/runtime/tui/v2-dialog.js +137 -0
- package/src/tui-compiled/runtime/tui/v2.js +95 -0
- package/src/tui-compiled/runtime/tui.js +351 -222
- package/dist/index-4fnghj9e.js +0 -65
- package/dist/index-a69gr76b.js +0 -2
- package/dist/index-h263aftt.js +0 -157
- package/dist/index-ssj7m2rd.js +0 -8
- package/dist/index-ydz3hbhc.js +0 -2
- package/dist/map-m6f5a_IA.d.ts +0 -56
- package/dist/token-util-4a2xxnpg.js +0 -1
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { projectQuota } from "./d5a8f1061ee2f114-index.js";
|
|
2
|
+
import {
|
|
3
|
+
admit,
|
|
4
|
+
decideStickyBreak,
|
|
5
|
+
orderForPlacement,
|
|
6
|
+
routeOrdered,
|
|
7
|
+
routeSticky
|
|
8
|
+
} from "./3e7d45a77c6ad4d5-index.js";
|
|
9
|
+
import {
|
|
10
|
+
isKillswitchEnabled,
|
|
11
|
+
killswitchPassesPolicy
|
|
12
|
+
} from "./dbc61cd405941828-accounts.js";
|
|
13
|
+
import { windowsFromQuotaMap } from "./bfbdd0f9aae56b47-pool-quota.js";
|
|
14
|
+
export const FORMER_MAIN_ID = "main";
|
|
15
|
+
export function vaultMainRouteId(routes) {
|
|
16
|
+
return routes.find((route) => route.id.startsWith("vault:") && route.credentialId === "chatgpt:openai")?.id ?? null;
|
|
17
|
+
}
|
|
18
|
+
export function poolKillswitchVerdicts(accounts, storage, now) {
|
|
19
|
+
const verdicts = new Map;
|
|
20
|
+
if (isKillswitchEnabled(storage))
|
|
21
|
+
for (const account of accounts)
|
|
22
|
+
verdicts.set(account.id, killswitchPassesPolicy(windowsFromQuotaMap(account.quota), storage, account.id === FORMER_MAIN_ID ? void 0 : account.id, now));
|
|
23
|
+
return verdicts;
|
|
24
|
+
}
|
|
25
|
+
export const POOL_QUOTA_UNKNOWN_RETRY_SECONDS = 5, FIRST_QUOTA_READING_WAIT_MS = 5000;
|
|
26
|
+
export function orderedPlacement(mode) {
|
|
27
|
+
if (mode === "ordered")
|
|
28
|
+
return "roster";
|
|
29
|
+
return mode === "fallback-first" ? "fallback-first" : "main-first";
|
|
30
|
+
}
|
|
31
|
+
export function waitForFirstQuotaReading(input, waitMs = FIRST_QUOTA_READING_WAIT_MS) {
|
|
32
|
+
const rows = input.rows.filter((row) => row.kind === "oauth" && input.killswitch.get(row.id) !== !1 && projectQuota(row.quota).limits.length === 0);
|
|
33
|
+
if (rows.length === 0)
|
|
34
|
+
return;
|
|
35
|
+
if (admit({
|
|
36
|
+
rows: input.rows,
|
|
37
|
+
now: input.now,
|
|
38
|
+
rateLimitMarks: input.rateLimitMarks,
|
|
39
|
+
refreshBackoff: input.refreshBackoff,
|
|
40
|
+
requestPull: () => {}
|
|
41
|
+
}).admitted.some((row) => input.killswitch.get(row.id) !== !1))
|
|
42
|
+
return;
|
|
43
|
+
const pulls = [];
|
|
44
|
+
admit({
|
|
45
|
+
rows,
|
|
46
|
+
now: input.now,
|
|
47
|
+
rateLimitMarks: input.rateLimitMarks,
|
|
48
|
+
refreshBackoff: input.refreshBackoff,
|
|
49
|
+
requestPull: (id) => {
|
|
50
|
+
const pending = input.requestPull(id);
|
|
51
|
+
if (pending)
|
|
52
|
+
pulls.push(pending.catch(() => {}));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
if (pulls.length === 0)
|
|
56
|
+
return;
|
|
57
|
+
let timer;
|
|
58
|
+
return Promise.race([
|
|
59
|
+
Promise.all(pulls),
|
|
60
|
+
new Promise((resolve) => {
|
|
61
|
+
timer = setTimeout(resolve, waitMs);
|
|
62
|
+
})
|
|
63
|
+
]).then(() => {}).finally(() => clearTimeout(timer));
|
|
64
|
+
}
|
|
65
|
+
function isConfirmedExhaustion(refusal) {
|
|
66
|
+
return refusal.reason === "exhausted" || refusal.reason === "budget-spent";
|
|
67
|
+
}
|
|
68
|
+
export function blockFor(id, admission, killswitch) {
|
|
69
|
+
if (id === void 0)
|
|
70
|
+
return { reason: "no-credential" };
|
|
71
|
+
if (killswitch.get(id) === !1)
|
|
72
|
+
return { reason: "killswitch" };
|
|
73
|
+
const exclusion = admission.excluded.find((entry) => entry.id === id);
|
|
74
|
+
if (exclusion?.reason === "rate-limited")
|
|
75
|
+
return { reason: "mid-stream-rate-limit", resetAtMs: exclusion.until };
|
|
76
|
+
if (exclusion)
|
|
77
|
+
return { reason: "no-credential" };
|
|
78
|
+
const refusal = admission.refused.find((entry) => entry.id === id);
|
|
79
|
+
if (refusal && "resetAtMs" in refusal)
|
|
80
|
+
return { reason: "quota-exhausted", resetAtMs: refusal.resetAtMs };
|
|
81
|
+
if (refusal)
|
|
82
|
+
return { reason: "quota-unknown" };
|
|
83
|
+
return { reason: "no-credential" };
|
|
84
|
+
}
|
|
85
|
+
function routeBlock(ids, admission, killswitch) {
|
|
86
|
+
if (admission.refused.find((refusal) => !isConfirmedExhaustion(refusal) && killswitch.get(refusal.id) !== !1))
|
|
87
|
+
return { reason: "quota-unknown" };
|
|
88
|
+
return blockFor(ids[0], admission, killswitch);
|
|
89
|
+
}
|
|
90
|
+
export function planOrdered(input) {
|
|
91
|
+
const replayable = input.replayable !== !1, mainId = input.mainId === void 0 ? FORMER_MAIN_ID : input.mainId ?? "", placement = replayable ? input.placement : "main-first", route = routeOrdered({
|
|
92
|
+
rows: input.rows,
|
|
93
|
+
placement,
|
|
94
|
+
formerMainId: mainId,
|
|
95
|
+
killswitch: input.killswitch,
|
|
96
|
+
rateLimitMarks: input.rateLimitMarks,
|
|
97
|
+
refreshBackoff: input.refreshBackoff,
|
|
98
|
+
now: input.now,
|
|
99
|
+
requestPull: input.requestPull
|
|
100
|
+
}), ids = orderForPlacement(input.rows.map((row) => row.id), placement, mainId), confirmed = new Set(route.admission.refused.filter((refusal) => isConfirmedExhaustion(refusal) && input.killswitch.get(refusal.id) !== !1).map((refusal) => refusal.id)), lastPath = ids.filter((id) => confirmed.has(id));
|
|
101
|
+
if (!replayable) {
|
|
102
|
+
const hasMain = ids.includes(mainId), target = hasMain ? mainId : route.order[0] ?? lastPath[0];
|
|
103
|
+
if (target !== void 0 && route.order.includes(target))
|
|
104
|
+
return { kind: "send", order: [target], lastPath: !1 };
|
|
105
|
+
if (target !== void 0 && confirmed.has(target))
|
|
106
|
+
return { kind: "send", order: [target], lastPath: !0 };
|
|
107
|
+
return {
|
|
108
|
+
kind: "block",
|
|
109
|
+
block: hasMain ? blockFor(mainId, route.admission, input.killswitch) : routeBlock(ids, route.admission, input.killswitch)
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (route.order.length > 0)
|
|
113
|
+
return { kind: "send", order: route.order, lastPath: !1 };
|
|
114
|
+
if (lastPath.length > 0)
|
|
115
|
+
return { kind: "send", order: lastPath, lastPath: !0 };
|
|
116
|
+
return {
|
|
117
|
+
kind: "block",
|
|
118
|
+
block: routeBlock(ids, route.admission, input.killswitch)
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
export function admitSticky(input) {
|
|
122
|
+
const admission = admit({
|
|
123
|
+
rows: input.rows,
|
|
124
|
+
rateLimitMarks: input.rateLimitMarks,
|
|
125
|
+
refreshBackoff: input.refreshBackoff,
|
|
126
|
+
now: input.now,
|
|
127
|
+
requestPull: input.requestPull
|
|
128
|
+
}), projections = new Map;
|
|
129
|
+
for (const row of input.rows)
|
|
130
|
+
projections.set(row.id, projectQuota(row.quota));
|
|
131
|
+
for (const row of admission.admitted)
|
|
132
|
+
if (row.projection)
|
|
133
|
+
projections.set(row.id, row.projection);
|
|
134
|
+
return {
|
|
135
|
+
projections,
|
|
136
|
+
excluded: new Set(admission.excluded.map((entry) => entry.id))
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function routePoolSticky(input, options, extra) {
|
|
140
|
+
const exclude = extra.exclude, rows = exclude ? input.rows.filter((row) => !exclude.has(row.id)) : input.rows, resetCredits = new Map;
|
|
141
|
+
for (const row of rows) {
|
|
142
|
+
const credits = options.resetCredits(row.id);
|
|
143
|
+
if (credits !== void 0)
|
|
144
|
+
resetCredits.set(row.id, credits);
|
|
145
|
+
}
|
|
146
|
+
return routeSticky({
|
|
147
|
+
rows,
|
|
148
|
+
now: input.now,
|
|
149
|
+
rateLimitMarks: input.rateLimitMarks,
|
|
150
|
+
refreshBackoff: input.refreshBackoff,
|
|
151
|
+
requestPull: input.requestPull,
|
|
152
|
+
killswitch: input.killswitch,
|
|
153
|
+
requestBytes: options.requestBytes,
|
|
154
|
+
...extra.pendingBytes ? { pendingBytes: extra.pendingBytes } : {},
|
|
155
|
+
rowReservePercent: (row) => options.reservePercent(row.id),
|
|
156
|
+
refusedPinPolicy: "move-on-confirmed-exhaustion",
|
|
157
|
+
resetCreditsApplicable: resetCredits,
|
|
158
|
+
...extra.pin === void 0 ? {} : { pin: { accountId: extra.pin } },
|
|
159
|
+
...options.onEmptyWeightedSet ? { onEmptyWeightedSet: options.onEmptyWeightedSet } : {}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
export function selectStickyRow(input, options, exclude, pendingBytes) {
|
|
163
|
+
const route = routePoolSticky(input, options, { exclude, pendingBytes });
|
|
164
|
+
if (route.outcome !== "dispatch" || route.source === "pin")
|
|
165
|
+
return;
|
|
166
|
+
return {
|
|
167
|
+
accountId: route.accountId,
|
|
168
|
+
source: route.source,
|
|
169
|
+
...route.quotaCheckedAt === void 0 ? {} : { quotaCheckedAt: route.quotaCheckedAt }
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
export function routePinnedRow(input, options, id) {
|
|
173
|
+
const killed = input.killswitch.get(id) === !1, route = routePoolSticky(input, options, { pin: id });
|
|
174
|
+
if (route.outcome === "dispatch") {
|
|
175
|
+
if (route.pin.action === "assign")
|
|
176
|
+
return { kind: "move", reason: killed ? "killswitch" : "exhausted" };
|
|
177
|
+
return route.accountId === id ? { kind: "serve" } : { kind: "detour" };
|
|
178
|
+
}
|
|
179
|
+
const refusal = route.admission.refused.find((entry) => entry.id === id);
|
|
180
|
+
if (!killed && refusal && isConfirmedExhaustion(refusal))
|
|
181
|
+
return { kind: "last-path" };
|
|
182
|
+
return { kind: "none" };
|
|
183
|
+
}
|
|
184
|
+
export function stickyBreak(input, sticky, id, status) {
|
|
185
|
+
const killswitchPasses = input.killswitch.get(id);
|
|
186
|
+
return decideStickyBreak({
|
|
187
|
+
quota: sticky.projections.get(id),
|
|
188
|
+
now: input.now,
|
|
189
|
+
...status === void 0 ? {} : { status },
|
|
190
|
+
...killswitchPasses === void 0 ? {} : { killswitchPasses }
|
|
191
|
+
});
|
|
192
|
+
}
|