@cortexkit/opencode-openai-auth 1.23.1 → 1.23.3
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 +7 -7
- package/dist/{index-7hy72nfy.js → index-9kges8jy.js} +2 -2
- package/dist/index-ekt6aq17.js +60 -0
- package/dist/index-nd2ks7er.js +2 -0
- package/dist/{index-p81hxfe6.js → index-vf4nn20q.js} +1 -1
- package/dist/{index-bd18sfjj.js → index-x00sxt2w.js} +10 -10
- package/dist/{index-3ya2s179.js → index-xkngfyvc.js} +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/{runtime-layout-B07ApQZL.d.ts → internal-DacVgEWs.d.ts} +86 -663
- package/dist/rpc/port-file.js +1 -1
- package/dist/runtime-layout-Dcbj_Rq3.d.ts +650 -0
- package/dist/{sidebar-state--OTpRzFd.d.ts → sidebar-state-L--CdbLi.d.ts} +4 -15
- package/dist/sidebar-state.d.ts +1 -1
- package/dist/sidebar-state.js +1 -1
- package/dist/tui.d.ts +5 -2
- package/dist/v2/server.d.ts +2 -1
- package/dist/v2/server.js +4 -4
- package/package.json +1 -1
- package/src/tui-compiled/raw/shared/054118b2705fdc20-ansi.js +98 -0
- package/src/tui-compiled/raw/shared/0895e780489c494d-window.js +33 -0
- package/src/tui-compiled/raw/shared/0b7d24474e2f33e9-credential-redaction.js +424 -0
- package/src/tui-compiled/raw/shared/0c9533222cb4380c-namespace.js +224 -0
- package/src/tui-compiled/raw/shared/112607e46a5b5f58-accounts.js +393 -0
- package/src/tui-compiled/raw/shared/136fa4abe48ad69d-cachekeep.js +411 -0
- package/src/tui-compiled/raw/shared/1547bd74f4214d2d-index.js +28 -0
- package/src/tui-compiled/raw/shared/1567207f323dc733-codex-http.js +44 -0
- package/src/tui-compiled/raw/shared/15f402885cbb2fb3-envelope-loss.js +151 -0
- package/src/tui-compiled/raw/shared/18df43cab4563acf-families.js +149 -0
- package/src/tui-compiled/raw/shared/1a4c289eec261e04-codex-instructions.js +59 -0
- package/src/tui-compiled/raw/shared/1afd446e190ef85c-vault-messages.js +12 -0
- package/src/tui-compiled/raw/shared/1b06ec96856ff8b9-codex-endpoint.js +17 -0
- package/src/tui-compiled/raw/shared/1e2f1a89bb34a773-vault-adapter.js +110 -0
- package/src/tui-compiled/raw/shared/2194fb8e8b42d7d5-insula-quota.js +73 -0
- package/src/tui-compiled/raw/shared/22b2bce42f2d6806-handle.js +10 -0
- package/src/tui-compiled/raw/shared/2577ec69f9973ae9-quota-normalize.js +13 -14
- package/src/tui-compiled/raw/shared/26055d4e5ad5e71f-codex-request.js +198 -0
- package/src/tui-compiled/raw/shared/26b57ac4c3b0c3f6-unconfirmed-retain-counter.js +41 -0
- package/src/tui-compiled/raw/shared/2bb681e99c2721d7-registry.js +538 -0
- package/src/tui-compiled/raw/shared/2dce6e9613993329-quota-manager.js +13 -20
- package/src/tui-compiled/raw/shared/2ec33b3e2b8ac38a-terminal.js +168 -0
- package/src/tui-compiled/raw/shared/30bcca1d1b4240a0-pool-session-pins.js +32 -0
- package/src/tui-compiled/raw/shared/3af9a210aa2ccdf2-codex-call-status.js +21 -0
- package/src/tui-compiled/raw/shared/3b31b36bf0877602-wording.js +120 -0
- package/src/tui-compiled/raw/shared/3c4c1a2d3fc92726-failure.js +59 -0
- package/src/tui-compiled/raw/shared/3dfe71eec6e0487d-presets.js +240 -0
- package/src/tui-compiled/raw/shared/43de3a5c4845cfc1-pool-adapter.js +149 -0
- package/src/tui-compiled/raw/shared/49353b63a833c8fb-session-cache-policy.js +60 -0
- package/src/tui-compiled/raw/shared/4adf46e07e025363-axes.js +7 -0
- package/src/tui-compiled/raw/shared/4ba847b77580b1eb-confirm.js +21 -0
- package/src/tui-compiled/raw/shared/4d05c2d7a531aece-oauth.js +48 -36
- package/src/tui-compiled/raw/shared/5018d4665e969588-limit-policy.js +159 -0
- package/src/tui-compiled/raw/shared/595bdf3fff13ba79-limit-identity.js +49 -0
- package/src/tui-compiled/raw/shared/59def9e82b61204a-session-cache-activity.js +35 -0
- package/src/tui-compiled/raw/shared/5d806e1a305d14f5-commands.js +879 -0
- package/src/tui-compiled/raw/shared/5fc39320fa8bd3a0-limit-registry.js +473 -0
- package/src/tui-compiled/raw/shared/63c1ee7e70e85e8d-vault.js +1 -0
- package/src/tui-compiled/raw/shared/6545ab7f757314b7-refresh-all-quota.js +237 -0
- package/src/tui-compiled/raw/shared/66937534c260d20b-stable-json.js +11 -0
- package/src/tui-compiled/raw/shared/7056acef1b021f19-bridge.js +10 -0
- package/src/tui-compiled/raw/shared/72d2ca42883809b4-marker.js +107 -0
- package/src/tui-compiled/raw/shared/775431e21f469203-record.js +3 -0
- package/src/tui-compiled/raw/shared/799f3ade4efbd1ea-opencode-v1.js +47 -0
- package/src/tui-compiled/raw/shared/7b2a0471b29e4f5e-wake.js +47 -0
- package/src/tui-compiled/raw/shared/7b5d6afff4ff32b9-select.js +159 -0
- package/src/tui-compiled/raw/shared/7bf96bf4d9249b3d-vault-billing.js +108 -0
- package/src/tui-compiled/raw/shared/7c98bde36aad4819-input-transformations.js +34 -0
- package/src/tui-compiled/raw/shared/7fb0418303f20a10-index.js +3 -0
- package/src/tui-compiled/raw/shared/806e12ccbad34388-pi-wait.js +51 -0
- package/src/tui-compiled/raw/shared/81ae201b724cac14-menu.js +73 -0
- package/src/tui-compiled/raw/shared/8349ed25dc629e97-scope.js +10 -0
- package/src/tui-compiled/raw/shared/86da3379973780b9-limit-provenance.js +60 -0
- package/src/tui-compiled/raw/shared/8aba66ed486d30a7-decide.js +425 -0
- package/src/tui-compiled/raw/shared/8c0c8df25a5dca1f-manager.js +735 -0
- package/src/tui-compiled/raw/shared/8c42bbec02f59636-vault-routing.js +212 -0
- package/src/tui-compiled/raw/shared/8ca6175bfae53e13-envelope.js +123 -0
- package/src/tui-compiled/raw/shared/8d0245e41049d83f-header-classifier.js +121 -0
- package/src/tui-compiled/raw/shared/9c162809179c7560-login.js +89 -0
- package/src/tui-compiled/raw/shared/a1f495296a4b756f-frame-turn.js +72 -0
- package/src/tui-compiled/raw/shared/a37138dcbd893f55-hold-bounds.js +5 -0
- package/src/tui-compiled/raw/shared/aa7fb10d77a2cccd-vault-account-menu.js +133 -0
- package/src/tui-compiled/raw/shared/adc5eeb5a8d28280-persistence.js +9 -0
- package/src/tui-compiled/raw/shared/b301c79e6378d1fb-vault.js +678 -0
- package/src/tui-compiled/raw/shared/b3c11de5f36e617a-reset.js +44 -0
- package/src/tui-compiled/raw/shared/ba6535c610d1edb3-pool-source-state.js +100 -0
- package/src/tui-compiled/raw/shared/bd4aef685681048c-duration.js +20 -0
- package/src/tui-compiled/raw/shared/bd5977eca210d2b8-index.js +662 -0
- package/src/tui-compiled/raw/shared/bfc46d34f4c9db33-limit-recovery.js +127 -0
- package/src/tui-compiled/raw/shared/c66495424ad84aee-hold.js +25 -0
- package/src/tui-compiled/raw/shared/c6a67b836bd5afcd-vault-command-menu.js +300 -0
- package/src/tui-compiled/raw/shared/c9340fb545c4e5de-internal.js +73 -0
- package/src/tui-compiled/raw/shared/c954c6447b7b9b64-activity.js +52 -0
- package/src/tui-compiled/raw/shared/cba8b0aee46b8526-codex-lite.js +85 -0
- package/src/tui-compiled/raw/shared/cec39ccddab4fe9c-labels.js +11 -0
- package/src/tui-compiled/raw/shared/cef0f2346957e83c-index.js +552 -0
- package/src/tui-compiled/raw/shared/cf7dedf24f902d68-dump-size.js +41 -0
- package/src/tui-compiled/raw/shared/d422d6dbc4e35199-background-quota-refresh.js +107 -0
- package/src/tui-compiled/raw/shared/d5b268767d330507-doctor.js +81 -0
- package/src/tui-compiled/raw/shared/d7ac5ca41f49121b-index.js +12 -0
- package/src/tui-compiled/raw/shared/d7fa77560855dee2-jitter.js +9 -0
- package/src/tui-compiled/raw/shared/de7f7d8803624369-path.js +31 -0
- package/src/tui-compiled/raw/shared/df0bdc74fb0c0db0-limit-mark.js +27 -0
- package/src/tui-compiled/raw/shared/e26c2bb5722ab047-routing-hold.js +23 -0
- package/src/tui-compiled/raw/shared/e2ae081583adfce3-dump.js +80 -0
- package/src/tui-compiled/raw/shared/e44ba1b3a9903f5d-reset-credits.js +483 -0
- package/src/tui-compiled/raw/shared/e5229952fc12f647-codex-models.js +34 -0
- package/src/tui-compiled/raw/shared/e8fda84e90176436-uuid-v7.js +13 -0
- package/src/tui-compiled/raw/shared/ea56007991dbf068-terminal.js +19 -0
- package/src/tui-compiled/raw/shared/ec6f1d96e7d70174-quota-refusal.js +145 -0
- package/src/tui-compiled/raw/shared/f03d7b43a214a4a1-canonical-input.js +42 -0
- package/src/tui-compiled/raw/shared/f1012265b3a768c7-merge-laws.js +31 -0
- package/src/tui-compiled/raw/shared/f2ca864fe967415a-cache-policy.js +198 -0
- package/src/tui-compiled/raw/shared/f317a4740f9d76f8-identity.js +21 -0
- package/src/tui-compiled/raw/shared/f607353c4126272a-routing-wait.js +19 -0
- package/src/tui-compiled/raw/shared/f6189f5c9aee31eb-decision.js +55 -0
- package/src/tui-compiled/raw/shared/f6d728f5e601f98b-request-history.js +120 -0
- package/src/tui-compiled/raw/shared/f981e6b15fb76cdb-codex-body.js +28 -0
- package/src/tui-compiled/raw/shared/fda579e5a0a54165-codex-effort.js +60 -0
- package/src/tui-compiled/raw/sidebar-state.js +54 -4
- package/src/tui-compiled/raw/tui/v2-dialog.js +1 -1
- package/src/tui-compiled/raw/tui.tsx +27 -5
- package/src/tui-compiled/runtime/shared/054118b2705fdc20-ansi.js +98 -0
- package/src/tui-compiled/runtime/shared/0895e780489c494d-window.js +33 -0
- package/src/tui-compiled/runtime/shared/0b7d24474e2f33e9-credential-redaction.js +424 -0
- package/src/tui-compiled/runtime/shared/0c9533222cb4380c-namespace.js +224 -0
- package/src/tui-compiled/runtime/shared/112607e46a5b5f58-accounts.js +393 -0
- package/src/tui-compiled/runtime/shared/136fa4abe48ad69d-cachekeep.js +411 -0
- package/src/tui-compiled/runtime/shared/1547bd74f4214d2d-index.js +28 -0
- package/src/tui-compiled/runtime/shared/1567207f323dc733-codex-http.js +44 -0
- package/src/tui-compiled/runtime/shared/15f402885cbb2fb3-envelope-loss.js +151 -0
- package/src/tui-compiled/runtime/shared/18df43cab4563acf-families.js +149 -0
- package/src/tui-compiled/runtime/shared/1a4c289eec261e04-codex-instructions.js +59 -0
- package/src/tui-compiled/runtime/shared/1afd446e190ef85c-vault-messages.js +12 -0
- package/src/tui-compiled/runtime/shared/1b06ec96856ff8b9-codex-endpoint.js +17 -0
- package/src/tui-compiled/runtime/shared/1e2f1a89bb34a773-vault-adapter.js +110 -0
- package/src/tui-compiled/runtime/shared/2194fb8e8b42d7d5-insula-quota.js +73 -0
- package/src/tui-compiled/runtime/shared/22b2bce42f2d6806-handle.js +10 -0
- package/src/tui-compiled/runtime/shared/2577ec69f9973ae9-quota-normalize.js +13 -14
- package/src/tui-compiled/runtime/shared/26055d4e5ad5e71f-codex-request.js +198 -0
- package/src/tui-compiled/runtime/shared/26b57ac4c3b0c3f6-unconfirmed-retain-counter.js +41 -0
- package/src/tui-compiled/runtime/shared/2bb681e99c2721d7-registry.js +538 -0
- package/src/tui-compiled/runtime/shared/2dce6e9613993329-quota-manager.js +13 -20
- package/src/tui-compiled/runtime/shared/2ec33b3e2b8ac38a-terminal.js +168 -0
- package/src/tui-compiled/runtime/shared/30bcca1d1b4240a0-pool-session-pins.js +32 -0
- package/src/tui-compiled/runtime/shared/3af9a210aa2ccdf2-codex-call-status.js +21 -0
- package/src/tui-compiled/runtime/shared/3b31b36bf0877602-wording.js +120 -0
- package/src/tui-compiled/runtime/shared/3c4c1a2d3fc92726-failure.js +59 -0
- package/src/tui-compiled/runtime/shared/3dfe71eec6e0487d-presets.js +240 -0
- package/src/tui-compiled/runtime/shared/43de3a5c4845cfc1-pool-adapter.js +149 -0
- package/src/tui-compiled/runtime/shared/49353b63a833c8fb-session-cache-policy.js +60 -0
- package/src/tui-compiled/runtime/shared/4adf46e07e025363-axes.js +7 -0
- package/src/tui-compiled/runtime/shared/4ba847b77580b1eb-confirm.js +21 -0
- package/src/tui-compiled/runtime/shared/4d05c2d7a531aece-oauth.js +48 -36
- package/src/tui-compiled/runtime/shared/5018d4665e969588-limit-policy.js +159 -0
- package/src/tui-compiled/runtime/shared/595bdf3fff13ba79-limit-identity.js +49 -0
- package/src/tui-compiled/runtime/shared/59def9e82b61204a-session-cache-activity.js +35 -0
- package/src/tui-compiled/runtime/shared/5d806e1a305d14f5-commands.js +879 -0
- package/src/tui-compiled/runtime/shared/5fc39320fa8bd3a0-limit-registry.js +473 -0
- package/src/tui-compiled/runtime/shared/63c1ee7e70e85e8d-vault.js +1 -0
- package/src/tui-compiled/runtime/shared/6545ab7f757314b7-refresh-all-quota.js +237 -0
- package/src/tui-compiled/runtime/shared/66937534c260d20b-stable-json.js +11 -0
- package/src/tui-compiled/runtime/shared/7056acef1b021f19-bridge.js +10 -0
- package/src/tui-compiled/runtime/shared/72d2ca42883809b4-marker.js +107 -0
- package/src/tui-compiled/runtime/shared/775431e21f469203-record.js +3 -0
- package/src/tui-compiled/runtime/shared/799f3ade4efbd1ea-opencode-v1.js +47 -0
- package/src/tui-compiled/runtime/shared/7b2a0471b29e4f5e-wake.js +47 -0
- package/src/tui-compiled/runtime/shared/7b5d6afff4ff32b9-select.js +159 -0
- package/src/tui-compiled/runtime/shared/7bf96bf4d9249b3d-vault-billing.js +108 -0
- package/src/tui-compiled/runtime/shared/7c98bde36aad4819-input-transformations.js +34 -0
- package/src/tui-compiled/runtime/shared/7fb0418303f20a10-index.js +3 -0
- package/src/tui-compiled/runtime/shared/806e12ccbad34388-pi-wait.js +51 -0
- package/src/tui-compiled/runtime/shared/81ae201b724cac14-menu.js +73 -0
- package/src/tui-compiled/runtime/shared/8349ed25dc629e97-scope.js +10 -0
- package/src/tui-compiled/runtime/shared/86da3379973780b9-limit-provenance.js +60 -0
- package/src/tui-compiled/runtime/shared/8aba66ed486d30a7-decide.js +425 -0
- package/src/tui-compiled/runtime/shared/8c0c8df25a5dca1f-manager.js +735 -0
- package/src/tui-compiled/runtime/shared/8c42bbec02f59636-vault-routing.js +212 -0
- package/src/tui-compiled/runtime/shared/8ca6175bfae53e13-envelope.js +123 -0
- package/src/tui-compiled/runtime/shared/8d0245e41049d83f-header-classifier.js +121 -0
- package/src/tui-compiled/runtime/shared/9c162809179c7560-login.js +89 -0
- package/src/tui-compiled/runtime/shared/a1f495296a4b756f-frame-turn.js +72 -0
- package/src/tui-compiled/runtime/shared/a37138dcbd893f55-hold-bounds.js +5 -0
- package/src/tui-compiled/runtime/shared/aa7fb10d77a2cccd-vault-account-menu.js +133 -0
- package/src/tui-compiled/runtime/shared/adc5eeb5a8d28280-persistence.js +9 -0
- package/src/tui-compiled/runtime/shared/b301c79e6378d1fb-vault.js +678 -0
- package/src/tui-compiled/runtime/shared/b3c11de5f36e617a-reset.js +44 -0
- package/src/tui-compiled/runtime/shared/ba6535c610d1edb3-pool-source-state.js +100 -0
- package/src/tui-compiled/runtime/shared/bd4aef685681048c-duration.js +20 -0
- package/src/tui-compiled/runtime/shared/bd5977eca210d2b8-index.js +662 -0
- package/src/tui-compiled/runtime/shared/bfc46d34f4c9db33-limit-recovery.js +127 -0
- package/src/tui-compiled/runtime/shared/c66495424ad84aee-hold.js +25 -0
- package/src/tui-compiled/runtime/shared/c6a67b836bd5afcd-vault-command-menu.js +300 -0
- package/src/tui-compiled/runtime/shared/c9340fb545c4e5de-internal.js +73 -0
- package/src/tui-compiled/runtime/shared/c954c6447b7b9b64-activity.js +52 -0
- package/src/tui-compiled/runtime/shared/cba8b0aee46b8526-codex-lite.js +85 -0
- package/src/tui-compiled/runtime/shared/cec39ccddab4fe9c-labels.js +11 -0
- package/src/tui-compiled/runtime/shared/cef0f2346957e83c-index.js +552 -0
- package/src/tui-compiled/runtime/shared/cf7dedf24f902d68-dump-size.js +41 -0
- package/src/tui-compiled/runtime/shared/d422d6dbc4e35199-background-quota-refresh.js +107 -0
- package/src/tui-compiled/runtime/shared/d5b268767d330507-doctor.js +81 -0
- package/src/tui-compiled/runtime/shared/d7ac5ca41f49121b-index.js +12 -0
- package/src/tui-compiled/runtime/shared/d7fa77560855dee2-jitter.js +9 -0
- package/src/tui-compiled/runtime/shared/de7f7d8803624369-path.js +31 -0
- package/src/tui-compiled/runtime/shared/df0bdc74fb0c0db0-limit-mark.js +27 -0
- package/src/tui-compiled/runtime/shared/e26c2bb5722ab047-routing-hold.js +23 -0
- package/src/tui-compiled/runtime/shared/e2ae081583adfce3-dump.js +80 -0
- package/src/tui-compiled/runtime/shared/e44ba1b3a9903f5d-reset-credits.js +483 -0
- package/src/tui-compiled/runtime/shared/e5229952fc12f647-codex-models.js +34 -0
- package/src/tui-compiled/runtime/shared/e8fda84e90176436-uuid-v7.js +13 -0
- package/src/tui-compiled/runtime/shared/ea56007991dbf068-terminal.js +19 -0
- package/src/tui-compiled/runtime/shared/ec6f1d96e7d70174-quota-refusal.js +145 -0
- package/src/tui-compiled/runtime/shared/f03d7b43a214a4a1-canonical-input.js +42 -0
- package/src/tui-compiled/runtime/shared/f1012265b3a768c7-merge-laws.js +31 -0
- package/src/tui-compiled/runtime/shared/f2ca864fe967415a-cache-policy.js +198 -0
- package/src/tui-compiled/runtime/shared/f317a4740f9d76f8-identity.js +21 -0
- package/src/tui-compiled/runtime/shared/f607353c4126272a-routing-wait.js +19 -0
- package/src/tui-compiled/runtime/shared/f6189f5c9aee31eb-decision.js +55 -0
- package/src/tui-compiled/runtime/shared/f6d728f5e601f98b-request-history.js +120 -0
- package/src/tui-compiled/runtime/shared/f981e6b15fb76cdb-codex-body.js +28 -0
- package/src/tui-compiled/runtime/shared/fda579e5a0a54165-codex-effort.js +60 -0
- package/src/tui-compiled/runtime/sidebar-state.js +54 -4
- package/src/tui-compiled/runtime/tui/v2-dialog.js +1 -1
- package/src/tui-compiled/runtime/tui.js +11 -4
- package/dist/index-0p8r7cpy.js +0 -60
- package/dist/index-px1t650b.js +0 -2
- package/dist/map-D5PHhv4z.d.ts +0 -72
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { limitAccountId } from "./595bdf3fff13ba79-limit-identity.js";
|
|
2
|
+
export const RECOVERY_REMEMBERED_BOUND = 256, RECOVERY_STAGED_BOUND = 256, RECOVERY_CONSUMED_BOUND = 1024;
|
|
3
|
+
function evidenceId(evidence) {
|
|
4
|
+
return JSON.stringify([
|
|
5
|
+
limitAccountId(evidence.account),
|
|
6
|
+
evidence.until,
|
|
7
|
+
evidence.evidenceAt
|
|
8
|
+
]);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class LimitRecoveryLatch {
|
|
12
|
+
log;
|
|
13
|
+
generation;
|
|
14
|
+
issued = 0;
|
|
15
|
+
adopted = 0;
|
|
16
|
+
remembered = new Map;
|
|
17
|
+
staged = new Map;
|
|
18
|
+
consumed = new Map;
|
|
19
|
+
exhausted = !1;
|
|
20
|
+
constructor(log = () => {}) {
|
|
21
|
+
this.log = log;
|
|
22
|
+
}
|
|
23
|
+
capture(view, at) {
|
|
24
|
+
return { token: ++this.issued, view, at };
|
|
25
|
+
}
|
|
26
|
+
adopt(read, current) {
|
|
27
|
+
const { view, token, at } = read, raw = view.snapshot;
|
|
28
|
+
if (token <= this.adopted || !view.authoritative || view.degradedAgreement || raw.namespace !== current.namespace || raw.generation !== current.generation || raw.revision !== current.revision)
|
|
29
|
+
return !1;
|
|
30
|
+
this.adopted = token;
|
|
31
|
+
if (this.generation !== raw.generation) {
|
|
32
|
+
this.generation = raw.generation;
|
|
33
|
+
this.remembered.clear();
|
|
34
|
+
this.staged.clear();
|
|
35
|
+
this.consumed.clear();
|
|
36
|
+
}
|
|
37
|
+
const bindings = new Set(view.bindings.map((b) => limitAccountId(b.account))), observed = new Map;
|
|
38
|
+
for (const mark of raw.marks) {
|
|
39
|
+
if (mark.key.window !== "account" || mark.key.scope.kind !== "pool")
|
|
40
|
+
continue;
|
|
41
|
+
if (!bindings.has(limitAccountId(mark.key.account)))
|
|
42
|
+
continue;
|
|
43
|
+
for (const entry of mark.entries) {
|
|
44
|
+
if (entry.cause !== "rate-limit")
|
|
45
|
+
continue;
|
|
46
|
+
const evidence = {
|
|
47
|
+
account: mark.key.account,
|
|
48
|
+
until: entry.until,
|
|
49
|
+
evidenceAt: entry.evidenceAt,
|
|
50
|
+
committedRevision: entry.committedRevision
|
|
51
|
+
};
|
|
52
|
+
observed.set(evidenceId(evidence), evidence);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
for (const entries of [this.remembered, this.staged])
|
|
56
|
+
for (const [id, evidence] of entries) {
|
|
57
|
+
if (!bindings.has(limitAccountId(evidence.account))) {
|
|
58
|
+
entries.delete(id);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (observed.has(id))
|
|
62
|
+
continue;
|
|
63
|
+
const cleared = raw.tombstones.some((clear) => limitAccountId(clear.key.account) === limitAccountId(evidence.account) && clear.key.window === "account" && clear.key.scope.kind === "pool" && clear.revision >= evidence.committedRevision && (clear.cause === void 0 || clear.cause === "rate-limit"));
|
|
64
|
+
if (entries === this.staged && !cleared)
|
|
65
|
+
continue;
|
|
66
|
+
entries.delete(id);
|
|
67
|
+
if (!cleared && entries === this.remembered && evidence.until <= at)
|
|
68
|
+
this.stage(evidence);
|
|
69
|
+
}
|
|
70
|
+
for (const [id, evidence] of observed) {
|
|
71
|
+
if (this.consumed.has(id))
|
|
72
|
+
continue;
|
|
73
|
+
if (evidence.until <= at) {
|
|
74
|
+
this.remembered.delete(id);
|
|
75
|
+
this.stage(evidence);
|
|
76
|
+
} else if (this.remembered.has(id) || this.remembered.size < RECOVERY_REMEMBERED_BOUND)
|
|
77
|
+
this.remembered.set(id, evidence);
|
|
78
|
+
}
|
|
79
|
+
return !0;
|
|
80
|
+
}
|
|
81
|
+
stage(evidence) {
|
|
82
|
+
const id = evidenceId(evidence);
|
|
83
|
+
if (this.consumed.has(id) || this.exhausted)
|
|
84
|
+
return;
|
|
85
|
+
let { NEGATIVE_INFINITY: until, NEGATIVE_INFINITY: evidenceAt } = Number;
|
|
86
|
+
for (const previous of this.consumed.values()) {
|
|
87
|
+
if (limitAccountId(previous.account) !== limitAccountId(evidence.account))
|
|
88
|
+
continue;
|
|
89
|
+
until = Math.max(until, previous.until);
|
|
90
|
+
evidenceAt = Math.max(evidenceAt, previous.evidenceAt);
|
|
91
|
+
}
|
|
92
|
+
if (evidence.until <= until && evidence.evidenceAt <= evidenceAt)
|
|
93
|
+
return;
|
|
94
|
+
if (this.staged.has(id) || this.staged.size < RECOVERY_STAGED_BOUND)
|
|
95
|
+
this.staged.set(id, evidence);
|
|
96
|
+
}
|
|
97
|
+
candidate(binding, now) {
|
|
98
|
+
if (this.exhausted || this.generation === void 0)
|
|
99
|
+
return;
|
|
100
|
+
const account = limitAccountId(binding.account);
|
|
101
|
+
let result;
|
|
102
|
+
for (const evidence of this.staged.values()) {
|
|
103
|
+
if (limitAccountId(evidence.account) !== account || evidence.until > now)
|
|
104
|
+
continue;
|
|
105
|
+
if (!result || evidence.until > result.until || evidence.until === result.until && evidence.evidenceAt > result.evidenceAt)
|
|
106
|
+
result = evidence;
|
|
107
|
+
}
|
|
108
|
+
return result && { ...result, generation: this.generation };
|
|
109
|
+
}
|
|
110
|
+
consume(evidence) {
|
|
111
|
+
const id = evidenceId(evidence);
|
|
112
|
+
if (this.exhausted || evidence.generation !== this.generation || !this.staged.has(id) || this.consumed.has(id))
|
|
113
|
+
return !1;
|
|
114
|
+
const sameAccount = [...this.staged].filter(([, entry]) => limitAccountId(entry.account) === limitAccountId(evidence.account));
|
|
115
|
+
if (this.consumed.size + sameAccount.length > RECOVERY_CONSUMED_BOUND) {
|
|
116
|
+
this.exhausted = !0;
|
|
117
|
+
this.staged.clear();
|
|
118
|
+
this.log("OpenAI limits recovery evidence is full; skipping further recovery clears.");
|
|
119
|
+
return !1;
|
|
120
|
+
}
|
|
121
|
+
for (const [key, entry] of sameAccount) {
|
|
122
|
+
this.consumed.set(key, entry);
|
|
123
|
+
this.staged.delete(key);
|
|
124
|
+
}
|
|
125
|
+
return !0;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { effectiveCacheTtlMs } from "./c954c6447b7b9b64-activity.js";
|
|
2
|
+
import { sameAccount } from "./f6d728f5e601f98b-request-history.js";
|
|
3
|
+
export const MAX_SAME_ACCOUNT_HOLD_MS = 3_621_000;
|
|
4
|
+
/** Pass routing.maxSameAccountWait without coercing persisted values. */
|
|
5
|
+
export function readMaxSameAccountWait(value) {
|
|
6
|
+
return value === 0 || value === 15 || value === 'max' ? value : 15;
|
|
7
|
+
}
|
|
8
|
+
/** Resolve a session snapshot into the pure reducer's same-account bounds. */
|
|
9
|
+
export function sameAccountHoldFacts(input) {
|
|
10
|
+
const setting = readMaxSameAccountWait(input.maxSameAccountWait);
|
|
11
|
+
const record = input.activity;
|
|
12
|
+
if (setting === 0 ||
|
|
13
|
+
!record ||
|
|
14
|
+
!sameAccount(record.accountKey, input.accountKey) ||
|
|
15
|
+
!Number.isFinite(record.lastAcceptedAt))
|
|
16
|
+
return undefined;
|
|
17
|
+
const ttlMs = effectiveCacheTtlMs(record.ttlMs);
|
|
18
|
+
const cacheExpiresAt = record.lastAcceptedAt + ttlMs;
|
|
19
|
+
if (ttlMs === 0 || !Number.isFinite(cacheExpiresAt))
|
|
20
|
+
return undefined;
|
|
21
|
+
return {
|
|
22
|
+
cacheExpiresAt,
|
|
23
|
+
maxWaitMs: setting === 'max' ? Number.POSITIVE_INFINITY : 900000,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CommandError,
|
|
3
|
+
createCommandMenu
|
|
4
|
+
} from "./dbef697d1df1cd84-index.js";
|
|
5
|
+
import {
|
|
6
|
+
formatQuota,
|
|
7
|
+
isQuotaMap,
|
|
8
|
+
projectQuota,
|
|
9
|
+
quotaCreditsText
|
|
10
|
+
} from "./d5a8f1061ee2f114-index.js";
|
|
11
|
+
import {
|
|
12
|
+
getKillswitchThresholdsForAccount
|
|
13
|
+
} from "./dbc61cd405941828-accounts.js";
|
|
14
|
+
import { vaultMainRouteId } from "./abd062d633e29fd2-pool-routing.js";
|
|
15
|
+
import { isRecord } from "./775431e21f469203-record.js";
|
|
16
|
+
import {
|
|
17
|
+
isVaultMenuConnected,
|
|
18
|
+
readVaultMenu,
|
|
19
|
+
refreshVaultMenu,
|
|
20
|
+
VAULT_LOCAL_ACTION_REFUSAL,
|
|
21
|
+
VAULT_MODE_LOCAL_NOTE,
|
|
22
|
+
vaultAccountName
|
|
23
|
+
} from "./aa7fb10d77a2cccd-vault-account-menu.js";
|
|
24
|
+
function record(value) {
|
|
25
|
+
return isRecord(value) ? { ...value } : {};
|
|
26
|
+
}
|
|
27
|
+
export function withPrepaidCredits(text, quota) {
|
|
28
|
+
const credits = isQuotaMap(quota) ? quotaCreditsText(quota.credits) : void 0;
|
|
29
|
+
return credits ? `${text} \xB7 prepaid ${credits}` : text;
|
|
30
|
+
}
|
|
31
|
+
export function withQuotaSectionCredits(menu, quotaById) {
|
|
32
|
+
return {
|
|
33
|
+
...menu,
|
|
34
|
+
sections: menu.sections.map((section) => section.id !== "quota" ? section : {
|
|
35
|
+
...section,
|
|
36
|
+
items: section.items.map((item) => item.detail === void 0 ? item : {
|
|
37
|
+
...item,
|
|
38
|
+
detail: withPrepaidCredits(item.detail, quotaById.get(item.id))
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function forwardAction(menu, sectionId, action, itemId) {
|
|
44
|
+
const confirmation = action.confirm?.irreversible ? { irreversible: !0, confirm: action.confirm.message } : { ...action.confirm ? { confirm: action.confirm.message } : {} };
|
|
45
|
+
return {
|
|
46
|
+
id: action.id,
|
|
47
|
+
label: action.label,
|
|
48
|
+
...action.description ? { description: action.description } : {},
|
|
49
|
+
...action.group ? { group: action.group } : {},
|
|
50
|
+
knobs: action.knobs,
|
|
51
|
+
...confirmation,
|
|
52
|
+
run: async ({ values, invocation }) => {
|
|
53
|
+
const result = await menu.apply({
|
|
54
|
+
command: menu.command,
|
|
55
|
+
sectionId,
|
|
56
|
+
...itemId ? { itemId } : {},
|
|
57
|
+
actionId: action.id,
|
|
58
|
+
values,
|
|
59
|
+
confirmed: !0
|
|
60
|
+
}, invocation);
|
|
61
|
+
return {
|
|
62
|
+
ok: result.ok,
|
|
63
|
+
text: result.text,
|
|
64
|
+
...result.code ? { code: result.code } : {}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export function menuStore(store, vault) {
|
|
70
|
+
return new Proxy(store, {
|
|
71
|
+
get(target, key) {
|
|
72
|
+
if (key === "read")
|
|
73
|
+
return async () => {
|
|
74
|
+
const load = await target.read();
|
|
75
|
+
if (load.status !== "ready")
|
|
76
|
+
return load;
|
|
77
|
+
const named = {
|
|
78
|
+
...load,
|
|
79
|
+
rows: load.rows.map((row) => ({
|
|
80
|
+
...row,
|
|
81
|
+
label: row.label ?? row.id
|
|
82
|
+
}))
|
|
83
|
+
};
|
|
84
|
+
if (!vault)
|
|
85
|
+
return named;
|
|
86
|
+
const view = await readVaultMenu(vault);
|
|
87
|
+
if (!isVaultMenuConnected(view))
|
|
88
|
+
return named;
|
|
89
|
+
const rows = [
|
|
90
|
+
...view.status.accounts.map((row) => ({
|
|
91
|
+
id: row.routeId,
|
|
92
|
+
label: vaultAccountName(row),
|
|
93
|
+
type: "oauth",
|
|
94
|
+
enabled: row.enabled,
|
|
95
|
+
identity: row.accountIdentity,
|
|
96
|
+
quota: row.quota,
|
|
97
|
+
hasEntry: !1,
|
|
98
|
+
needsFirstReading: !1,
|
|
99
|
+
candidate: !1
|
|
100
|
+
}))
|
|
101
|
+
];
|
|
102
|
+
return { ...load, rows };
|
|
103
|
+
};
|
|
104
|
+
if (key === "readSettings")
|
|
105
|
+
return async () => {
|
|
106
|
+
const read = await target.readSettings();
|
|
107
|
+
if (read.status === "error" || !vault)
|
|
108
|
+
return read;
|
|
109
|
+
const view = await readVaultMenu(vault), killswitch = record(read.settings.killswitch);
|
|
110
|
+
if (!isVaultMenuConnected(view) || !read.settings.killswitch)
|
|
111
|
+
return read;
|
|
112
|
+
const accounts = record(killswitch.accounts);
|
|
113
|
+
for (const row of view.status.accounts)
|
|
114
|
+
accounts[row.routeId] = getKillswitchThresholdsForAccount({ version: 1, accounts: [], ...read.settings }, row.routeId);
|
|
115
|
+
return {
|
|
116
|
+
...read,
|
|
117
|
+
settings: {
|
|
118
|
+
...read.settings,
|
|
119
|
+
killswitch: { ...killswitch, accounts }
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
const value = Reflect.get(target, key);
|
|
124
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
export function createVaultCommandMenu(options, vault, reads = {}) {
|
|
129
|
+
const localMenu = createCommandMenu(options), projection = (mainId) => createCommandMenu({
|
|
130
|
+
command: options.command,
|
|
131
|
+
title: options.title,
|
|
132
|
+
store: menuStore(options.store, vault),
|
|
133
|
+
accounts: options.accounts,
|
|
134
|
+
quota: options.quota,
|
|
135
|
+
limits: options.limits,
|
|
136
|
+
...options.settings ? { settings: options.settings } : {},
|
|
137
|
+
routing: {
|
|
138
|
+
...options.routing,
|
|
139
|
+
formerMainId: mainId ?? "",
|
|
140
|
+
vaultOrder: async () => {
|
|
141
|
+
const view = await readVaultMenu(vault);
|
|
142
|
+
if (!isVaultMenuConnected(view))
|
|
143
|
+
return;
|
|
144
|
+
return {
|
|
145
|
+
rows: view.status.accounts.map((row) => ({
|
|
146
|
+
id: row.routeId,
|
|
147
|
+
label: vaultAccountName(row)
|
|
148
|
+
})),
|
|
149
|
+
reorder: async (ids) => {
|
|
150
|
+
if (!isVaultMenuConnected(await readVaultMenu(vault)))
|
|
151
|
+
throw new CommandError("vault-local-action", VAULT_LOCAL_ACTION_REFUSAL);
|
|
152
|
+
return vault.reorder(ids);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
...options.extraLocks ? { extraLocks: options.extraLocks } : {},
|
|
158
|
+
...options.now ? { now: options.now } : {}
|
|
159
|
+
}), build = async (slot, invocation) => {
|
|
160
|
+
const view = await readVaultMenu(vault), connected = isVaultMenuConnected(view), mainId = vaultMainRouteId(view.status.accounts.map((row) => ({
|
|
161
|
+
id: row.routeId,
|
|
162
|
+
credentialId: row.credentialId
|
|
163
|
+
}))), source = connected ? projection(mainId) : localMenu, section = (await source.open(invocation)).menu.sections.find((section) => section.id === slot);
|
|
164
|
+
if (!section)
|
|
165
|
+
throw new CommandError("unavailable", "The account menu is unavailable.");
|
|
166
|
+
if (!connected)
|
|
167
|
+
return {
|
|
168
|
+
lines: section.lines,
|
|
169
|
+
items: section.items.map((item) => ({
|
|
170
|
+
...item,
|
|
171
|
+
actions: item.actions.map((action) => forwardAction(source, slot, action, item.id))
|
|
172
|
+
})),
|
|
173
|
+
actions: section.actions.map((action) => forwardAction(source, slot, action))
|
|
174
|
+
};
|
|
175
|
+
const vaultById = new Map(view.status.accounts.map((row) => [row.routeId, row])), now = (options.now ?? Date.now)(), checkQuota = (id) => ({
|
|
176
|
+
id: "check",
|
|
177
|
+
label: id ? "Check this account" : "Check now",
|
|
178
|
+
group: "Actions",
|
|
179
|
+
run: async () => {
|
|
180
|
+
const ids = [...(await readVaultMenu(vault)).routes].filter((routeId) => !id || routeId === id);
|
|
181
|
+
if (id && ids.length === 0)
|
|
182
|
+
throw new CommandError("unavailable", "This vault account cannot be checked right now.");
|
|
183
|
+
for (const routeId of ids) {
|
|
184
|
+
const result = await vault.pollQuota(routeId);
|
|
185
|
+
if (!result.ok)
|
|
186
|
+
throw new CommandError("quota-check-failed", `${routeId}: ${result.error ?? "vault unavailable"}`);
|
|
187
|
+
}
|
|
188
|
+
return `Checked quota for ${ids.length} account${ids.length === 1 ? "" : "s"}.`;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
if (slot === "quota") {
|
|
192
|
+
const quotaText = (row, form) => formatQuota(projectQuota(row.quota, options.quota?.scope), {
|
|
193
|
+
now,
|
|
194
|
+
form
|
|
195
|
+
});
|
|
196
|
+
return {
|
|
197
|
+
lines: view.status.accounts.filter((row) => !view.routes.has(row.routeId)).map((row) => `${vaultAccountName(row)} (${row.enabled ? row.state : "disabled"}): ${withPrepaidCredits(quotaText(row, "compact"), row.quota)}`),
|
|
198
|
+
items: view.status.accounts.filter((row) => view.routes.has(row.routeId)).map((row) => ({
|
|
199
|
+
id: row.routeId,
|
|
200
|
+
label: vaultAccountName(row),
|
|
201
|
+
group: "Accounts",
|
|
202
|
+
status: quotaText(row, "compact"),
|
|
203
|
+
detail: withPrepaidCredits(quotaText(row, "full"), row.quota),
|
|
204
|
+
actions: [checkQuota(row.routeId)]
|
|
205
|
+
})),
|
|
206
|
+
actions: view.routes.size > 0 ? [checkQuota()] : []
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const items = section.items.map((item) => {
|
|
210
|
+
const remote = vaultById.get(item.id), detail = remote && slot === "accounts" ? `Vault \xB7 ${remote.credentialType === "oauth" ? "login" : "API key"} \xB7 ${remote.state} \xB7 ${remote.enabled ? "enabled" : "declined"}` : item.detail;
|
|
211
|
+
return {
|
|
212
|
+
id: item.id,
|
|
213
|
+
label: item.label,
|
|
214
|
+
detail,
|
|
215
|
+
group: item.group,
|
|
216
|
+
status: remote && slot === "accounts" ? remote.enabled ? remote.state : "disabled" : item.status,
|
|
217
|
+
...item.facts ? { facts: item.facts } : {},
|
|
218
|
+
actions: remote && slot !== "limits" ? [] : item.actions.map((action) => forwardAction(source, slot, action, item.id))
|
|
219
|
+
};
|
|
220
|
+
}), actions = section.actions.filter((action) => view.status.accounts.length > 0 && (slot === "limits" || slot === "routing" && (action.id === "mode" || action.id === "order" || action.id === "maxSameAccountWait"))).map((action) => forwardAction(source, slot, action)), mode = section.actions.find((action) => action.id === "mode")?.knobs.find((knob) => knob.id === "mode"), noDefault = slot === "routing" && mainId === null && mode?.kind === "choice" && (mode.value === "main-first" || mode.value === "fallback-first");
|
|
221
|
+
return {
|
|
222
|
+
lines: slot === "accounts" ? [
|
|
223
|
+
...view.status.discovered ? [
|
|
224
|
+
`${view.status.accounts.length} vault account${view.status.accounts.length === 1 ? "" : "s"}`,
|
|
225
|
+
`${view.routes.size} can route`
|
|
226
|
+
] : ["Connected \xB7 waiting for the vault's first answer"],
|
|
227
|
+
VAULT_MODE_LOCAL_NOTE
|
|
228
|
+
] : [
|
|
229
|
+
...section.lines,
|
|
230
|
+
...noDefault ? ["No default vault account, so this mode orders like Ordered"] : []
|
|
231
|
+
],
|
|
232
|
+
items,
|
|
233
|
+
actions
|
|
234
|
+
};
|
|
235
|
+
}, connectedMenu = createCommandMenu({
|
|
236
|
+
...options,
|
|
237
|
+
accounts: void 0,
|
|
238
|
+
quota: void 0,
|
|
239
|
+
routing: void 0,
|
|
240
|
+
limits: void 0,
|
|
241
|
+
replace: {
|
|
242
|
+
accounts: {
|
|
243
|
+
title: "Accounts",
|
|
244
|
+
build: (invocation) => build("accounts", invocation)
|
|
245
|
+
},
|
|
246
|
+
quota: {
|
|
247
|
+
title: "Quota",
|
|
248
|
+
build: (invocation) => build("quota", invocation)
|
|
249
|
+
},
|
|
250
|
+
routing: {
|
|
251
|
+
title: "Routing",
|
|
252
|
+
build: (invocation) => build("routing", invocation)
|
|
253
|
+
},
|
|
254
|
+
limits: {
|
|
255
|
+
title: "Limits",
|
|
256
|
+
build: (invocation) => build("limits", invocation)
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
extras: options.extras?.map((section) => section.id !== "reset" ? section : {
|
|
260
|
+
...section,
|
|
261
|
+
build: async (invocation) => {
|
|
262
|
+
const view = await readVaultMenu(vault);
|
|
263
|
+
if (isVaultMenuConnected(view))
|
|
264
|
+
return { lines: [VAULT_MODE_LOCAL_NOTE] };
|
|
265
|
+
return section.build(invocation);
|
|
266
|
+
}
|
|
267
|
+
})
|
|
268
|
+
}), current = async () => {
|
|
269
|
+
if (!isVaultMenuConnected(await readVaultMenu(vault)))
|
|
270
|
+
return { menu: localMenu, error: void 0 };
|
|
271
|
+
const error = reads.refresh === !1 ? void 0 : await refreshVaultMenu(vault);
|
|
272
|
+
return { menu: connectedMenu, error };
|
|
273
|
+
}, open = async (state, invocation) => {
|
|
274
|
+
const payload = await state.menu.open(invocation);
|
|
275
|
+
if (state.error)
|
|
276
|
+
payload.menu.sections.find((section) => section.id === "vault")?.lines.push(`Last error: ${state.error}`);
|
|
277
|
+
return payload;
|
|
278
|
+
};
|
|
279
|
+
return {
|
|
280
|
+
command: options.command,
|
|
281
|
+
open: async (invocation) => open(await current(), invocation),
|
|
282
|
+
apply: async (request, invocation) => {
|
|
283
|
+
const state = await current(), { menu } = state;
|
|
284
|
+
if (menu === connectedMenu && (request.sectionId === "accounts" || request.sectionId === "reset" || request.sectionId === "quota" && (await readVaultMenu(vault)).routes.size === 0 || request.sectionId === "limits" && request.itemId !== void 0 && !(await readVaultMenu(vault)).status.accounts.some((row) => row.routeId === request.itemId)))
|
|
285
|
+
return {
|
|
286
|
+
...await open(state, invocation),
|
|
287
|
+
ok: !1,
|
|
288
|
+
code: "vault-local-action",
|
|
289
|
+
text: VAULT_LOCAL_ACTION_REFUSAL
|
|
290
|
+
};
|
|
291
|
+
if (reads.refuseApply)
|
|
292
|
+
return {
|
|
293
|
+
...await open(state, invocation),
|
|
294
|
+
ok: !1,
|
|
295
|
+
...reads.refuseApply
|
|
296
|
+
};
|
|
297
|
+
return menu.apply(request, invocation);
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export {
|
|
2
|
+
acquireRefreshFileLock,
|
|
3
|
+
isLostMarkerRaceError,
|
|
4
|
+
writeJsonAtomic
|
|
5
|
+
} from "./ec971142548df90e-index.js";
|
|
6
|
+
export * from "./dbc61cd405941828-accounts.js";
|
|
7
|
+
export * from "./d422d6dbc4e35199-background-quota-refresh.js";
|
|
8
|
+
export * from "./134b008900698fe0-backoff.js";
|
|
9
|
+
export {
|
|
10
|
+
buildKeepwarmBody,
|
|
11
|
+
buildKeepwarmRequest,
|
|
12
|
+
CACHE_KEEP_CAPS,
|
|
13
|
+
createCacheKeepManager,
|
|
14
|
+
createOpenAICacheKeepAdapter,
|
|
15
|
+
getCacheKeepWindow,
|
|
16
|
+
keepwarmReplayHeaders,
|
|
17
|
+
openaiCacheKeepProfile,
|
|
18
|
+
resolveCacheKeepAccountIdentity
|
|
19
|
+
} from "./136fa4abe48ad69d-cachekeep.js";
|
|
20
|
+
export * from "./f981e6b15fb76cdb-codex-body.js";
|
|
21
|
+
export * from "./3af9a210aa2ccdf2-codex-call-status.js";
|
|
22
|
+
export * from "./fda579e5a0a54165-codex-effort.js";
|
|
23
|
+
export * from "./1b06ec96856ff8b9-codex-endpoint.js";
|
|
24
|
+
export * from "./1567207f323dc733-codex-http.js";
|
|
25
|
+
export * from "./1a4c289eec261e04-codex-instructions.js";
|
|
26
|
+
export * from "./cba8b0aee46b8526-codex-lite.js";
|
|
27
|
+
export * from "./e5229952fc12f647-codex-models.js";
|
|
28
|
+
export * from "./26055d4e5ad5e71f-codex-request.js";
|
|
29
|
+
export {
|
|
30
|
+
renderResetCoordinatorResult
|
|
31
|
+
} from "./5d806e1a305d14f5-commands.js";
|
|
32
|
+
export * from "./e2ae081583adfce3-dump.js";
|
|
33
|
+
export * from "./cf7dedf24f902d68-dump-size.js";
|
|
34
|
+
export * from "./a1f495296a4b756f-frame-turn.js";
|
|
35
|
+
export * from "./7c98bde36aad4819-input-transformations.js";
|
|
36
|
+
export * from "./595bdf3fff13ba79-limit-identity.js";
|
|
37
|
+
export * from "./df0bdc74fb0c0db0-limit-mark.js";
|
|
38
|
+
export * from "./5018d4665e969588-limit-policy.js";
|
|
39
|
+
export * from "./86da3379973780b9-limit-provenance.js";
|
|
40
|
+
export {
|
|
41
|
+
acquireOpenAiLimits
|
|
42
|
+
} from "./5fc39320fa8bd3a0-limit-registry.js";
|
|
43
|
+
export * from "./d669d72c40e9e116-logger.js";
|
|
44
|
+
export * from "./4d05c2d7a531aece-oauth.js";
|
|
45
|
+
export * from "./b85c5301fddcb98a-paths.js";
|
|
46
|
+
export * from "./30bcca1d1b4240a0-pool-session-pins.js";
|
|
47
|
+
export * from "./ba6535c610d1edb3-pool-source-state.js";
|
|
48
|
+
export * from "./e4acc4cb713f300c-protocol.js";
|
|
49
|
+
export * from "./85512cc5263ba259-provider.js";
|
|
50
|
+
export * from "./2dce6e9613993329-quota-manager.js";
|
|
51
|
+
export * from "./2577ec69f9973ae9-quota-normalize.js";
|
|
52
|
+
export * from "./ec6f1d96e7d70174-quota-refusal.js";
|
|
53
|
+
export * from "./6545ab7f757314b7-refresh-all-quota.js";
|
|
54
|
+
export * from "./e44ba1b3a9903f5d-reset-credits.js";
|
|
55
|
+
export * from "./f607353c4126272a-routing-wait.js";
|
|
56
|
+
export * from "./59def9e82b61204a-session-cache-activity.js";
|
|
57
|
+
export * from "./49353b63a833c8fb-session-cache-policy.js";
|
|
58
|
+
export * from "./4593a4d71edf69fd-tombstone.js";
|
|
59
|
+
export * from "./f03d7b43a214a4a1-canonical-input.js";
|
|
60
|
+
export * from "./0b7d24474e2f33e9-credential-redaction.js";
|
|
61
|
+
export * from "./f37fcefc7aedbf25-error.js";
|
|
62
|
+
export * from "./42ae93ab554fcec2-open-url.js";
|
|
63
|
+
export * from "./775431e21f469203-record.js";
|
|
64
|
+
export * from "./66937534c260d20b-stable-json.js";
|
|
65
|
+
export * from "./e8fda84e90176436-uuid-v7.js";
|
|
66
|
+
export * from "./b301c79e6378d1fb-vault.js";
|
|
67
|
+
export {
|
|
68
|
+
runVaultAccountMenu,
|
|
69
|
+
VAULT_LOCAL_ACTION_REFUSAL,
|
|
70
|
+
vaultAccountName
|
|
71
|
+
} from "./aa7fb10d77a2cccd-vault-account-menu.js";
|
|
72
|
+
export * from "./7bf96bf4d9249b3d-vault-billing.js";
|
|
73
|
+
export * from "./8c42bbec02f59636-vault-routing.js";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { sameAccount } from "./f6d728f5e601f98b-request-history.js";
|
|
2
|
+
export function effectiveCacheTtlMs(ttlMs) {
|
|
3
|
+
return ttlMs !== undefined && Number.isFinite(ttlMs) && ttlMs >= 0
|
|
4
|
+
? ttlMs
|
|
5
|
+
: 300000;
|
|
6
|
+
}
|
|
7
|
+
/** One process-local cache record per session; no credential or store I/O. */
|
|
8
|
+
export function createSessionActivityStore() {
|
|
9
|
+
const records = new Map();
|
|
10
|
+
return {
|
|
11
|
+
get size() {
|
|
12
|
+
return records.size;
|
|
13
|
+
},
|
|
14
|
+
recordAccepted(input) {
|
|
15
|
+
if (!sameAccount(input.accountKey, input.currentAccountKey) ||
|
|
16
|
+
!Number.isFinite(input.lastAcceptedAt))
|
|
17
|
+
return false;
|
|
18
|
+
const previous = records.get(input.sessionId);
|
|
19
|
+
// Late completions must not replace more recent accepted cache activity.
|
|
20
|
+
if (previous && previous.lastAcceptedAt > input.lastAcceptedAt)
|
|
21
|
+
return false;
|
|
22
|
+
const ttls = typeof input.ttlMs === 'number' ? [input.ttlMs] : input.ttlMs;
|
|
23
|
+
const ttlMs = ttls?.length
|
|
24
|
+
? Math.max(...ttls.map(effectiveCacheTtlMs))
|
|
25
|
+
: effectiveCacheTtlMs(undefined);
|
|
26
|
+
records.set(input.sessionId, Object.freeze({
|
|
27
|
+
accountKey: Object.freeze({ ...input.accountKey }),
|
|
28
|
+
lastAcceptedAt: input.lastAcceptedAt,
|
|
29
|
+
ttlMs,
|
|
30
|
+
}));
|
|
31
|
+
if (records.size > 256) {
|
|
32
|
+
let oldest;
|
|
33
|
+
let acceptedAt = Number.POSITIVE_INFINITY;
|
|
34
|
+
for (const [sessionId, record] of records) {
|
|
35
|
+
if (record.lastAcceptedAt < acceptedAt) {
|
|
36
|
+
oldest = sessionId;
|
|
37
|
+
acceptedAt = record.lastAcceptedAt;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (oldest !== undefined)
|
|
41
|
+
records.delete(oldest);
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
},
|
|
45
|
+
get(sessionId) {
|
|
46
|
+
return records.get(sessionId);
|
|
47
|
+
},
|
|
48
|
+
forgetSession(sessionId) {
|
|
49
|
+
records.delete(sessionId);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { moveInstructionsToDeveloperMessage } from "./1a4c289eec261e04-codex-instructions.js";
|
|
2
|
+
import { isRecord } from "./775431e21f469203-record.js";
|
|
3
|
+
export const RESPONSES_LITE_HEADER = "x-openai-internal-codex-responses-lite", RESPONSES_LITE_MODELS = new Set([
|
|
4
|
+
"gpt-5.6-sol",
|
|
5
|
+
"gpt-5.6-terra",
|
|
6
|
+
"gpt-5.6-luna",
|
|
7
|
+
"gpt-6-astra",
|
|
8
|
+
"gpt-6-sol",
|
|
9
|
+
"gpt-6-luna",
|
|
10
|
+
"gpt-6.1-sol",
|
|
11
|
+
"gpt-6.1-terra",
|
|
12
|
+
"gpt-6.2-sol",
|
|
13
|
+
"gpt-6.2-astra"
|
|
14
|
+
]);
|
|
15
|
+
function stripResponsesLiteImageDetails(value) {
|
|
16
|
+
if (Array.isArray(value)) {
|
|
17
|
+
let next = value;
|
|
18
|
+
for (let index = 0;index < value.length; index++) {
|
|
19
|
+
const nested = stripResponsesLiteImageDetails(value[index]);
|
|
20
|
+
if (nested === value[index])
|
|
21
|
+
continue;
|
|
22
|
+
if (next === value)
|
|
23
|
+
next = value.slice();
|
|
24
|
+
next[index] = nested;
|
|
25
|
+
}
|
|
26
|
+
return next;
|
|
27
|
+
}
|
|
28
|
+
if (!isRecord(value))
|
|
29
|
+
return value;
|
|
30
|
+
let next = value;
|
|
31
|
+
for (const key of Object.keys(value)) {
|
|
32
|
+
if (value.type === "input_image" && key === "detail") {
|
|
33
|
+
if (next === value)
|
|
34
|
+
next = { ...value };
|
|
35
|
+
delete next[key];
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const nested = stripResponsesLiteImageDetails(value[key]);
|
|
39
|
+
if (nested === value[key])
|
|
40
|
+
continue;
|
|
41
|
+
if (next === value)
|
|
42
|
+
next = { ...value };
|
|
43
|
+
next[key] = nested;
|
|
44
|
+
}
|
|
45
|
+
return next;
|
|
46
|
+
}
|
|
47
|
+
export function rewriteResponsesLiteBody(parsed, leadingBareInstructions) {
|
|
48
|
+
const reasoning = isRecord(parsed.reasoning) ? { ...parsed.reasoning } : {};
|
|
49
|
+
reasoning.context = "all_turns";
|
|
50
|
+
parsed.reasoning = reasoning;
|
|
51
|
+
parsed.parallel_tool_calls = !1;
|
|
52
|
+
const input = stripResponsesLiteImageDetails(Array.isArray(parsed.input) ? parsed.input : []), tools = Array.isArray(parsed.tools) ? parsed.tools.filter((tool) => !(isRecord(tool) && tool.type === "web_search")) : [];
|
|
53
|
+
parsed.input = [
|
|
54
|
+
{ type: "additional_tools", role: "developer", tools },
|
|
55
|
+
...input
|
|
56
|
+
];
|
|
57
|
+
moveInstructionsToDeveloperMessage(parsed, {
|
|
58
|
+
responsesLite: !0,
|
|
59
|
+
leadingBareInstructions
|
|
60
|
+
});
|
|
61
|
+
delete parsed.tools;
|
|
62
|
+
delete parsed.instructions;
|
|
63
|
+
}
|
|
64
|
+
export function responsesLiteHttpBody(body) {
|
|
65
|
+
if (!supportsResponsesLite(body.model))
|
|
66
|
+
return !1;
|
|
67
|
+
rewriteResponsesLiteBody(body);
|
|
68
|
+
return !0;
|
|
69
|
+
}
|
|
70
|
+
export function supportsResponsesLite(model) {
|
|
71
|
+
return typeof model === "string" && RESPONSES_LITE_MODELS.has(model);
|
|
72
|
+
}
|
|
73
|
+
export function resolveResponsesLite(configured, override = process.env.CORTEXKIT_OPENAI_AUTH_RESPONSES_LITE) {
|
|
74
|
+
return parseBooleanOverride(override) ?? configured === !0;
|
|
75
|
+
}
|
|
76
|
+
export function parseBooleanOverride(raw) {
|
|
77
|
+
const value = raw?.trim().toLowerCase();
|
|
78
|
+
if (value === void 0)
|
|
79
|
+
return;
|
|
80
|
+
if (["1", "true", "yes", "on"].includes(value))
|
|
81
|
+
return !0;
|
|
82
|
+
if (["", "0", "false", "no", "off"].includes(value))
|
|
83
|
+
return !1;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { hasUnsafeWording } from "./3b31b36bf0877602-wording.js";
|
|
2
|
+
const emailPattern = /[^\s@]+@[^\s@]+\.[^\s@]+/;
|
|
3
|
+
export function containsEmail(text) {
|
|
4
|
+
return emailPattern.test(text);
|
|
5
|
+
}
|
|
6
|
+
/** Re-login guidance may use user labels, but must not expose emails or cause replay. */
|
|
7
|
+
export function sanitizeRefusalLabel(label) {
|
|
8
|
+
return containsEmail(label) || hasUnsafeWording(label)
|
|
9
|
+
? 'this account'
|
|
10
|
+
: label;
|
|
11
|
+
}
|