@cortexkit/opencode-openai-auth 1.23.1 → 1.23.2
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-by5wfvqm.js} +2 -2
- package/dist/index-nd2ks7er.js +2 -0
- package/dist/index-t876xhkr.js +60 -0
- package/dist/{index-p81hxfe6.js → index-v8w8j1wx.js} +1 -1
- package/dist/{index-3ya2s179.js → index-v8wrmhyp.js} +1 -1
- package/dist/{index-bd18sfjj.js → index-x00sxt2w.js} +10 -10
- 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,108 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import {
|
|
3
|
+
isCacheWarmStopReason,
|
|
4
|
+
reportRouting
|
|
5
|
+
} from "./bd5977eca210d2b8-index.js";
|
|
6
|
+
import { isRecord } from "./775431e21f469203-record.js";
|
|
7
|
+
export function codexBillingUsage(value) {
|
|
8
|
+
if (!isRecord(value))
|
|
9
|
+
return;
|
|
10
|
+
const details = isRecord(value.input_tokens_details) ? value.input_tokens_details : void 0, cached = details?.cached_tokens, written = details?.cache_write_tokens, reasoning = isRecord(value.output_tokens_details) ? value.output_tokens_details.reasoning_tokens : void 0;
|
|
11
|
+
return {
|
|
12
|
+
...typeof value.input_tokens === "number" ? {
|
|
13
|
+
input: Math.max(0, value.input_tokens - (typeof cached === "number" ? cached : 0) - (typeof written === "number" && written > 0 ? written : 0))
|
|
14
|
+
} : {},
|
|
15
|
+
...typeof cached === "number" ? { cacheRead: cached } : {},
|
|
16
|
+
...typeof written === "number" && written > 0 ? { cacheWrite: written } : {},
|
|
17
|
+
...typeof value.output_tokens === "number" ? { output: value.output_tokens } : {},
|
|
18
|
+
...typeof reasoning === "number" ? { reasoning } : {},
|
|
19
|
+
reasoningIncludedInOutput: !0
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class VaultBillingAttempt {
|
|
24
|
+
sessionId;
|
|
25
|
+
receipt;
|
|
26
|
+
requestKind;
|
|
27
|
+
model;
|
|
28
|
+
attempt;
|
|
29
|
+
warming;
|
|
30
|
+
freeQuota;
|
|
31
|
+
attemptId = randomUUID();
|
|
32
|
+
reported = !1;
|
|
33
|
+
completed = !1;
|
|
34
|
+
failed = !1;
|
|
35
|
+
responseId;
|
|
36
|
+
usage;
|
|
37
|
+
constructor(sessionId, receipt, requestKind, model, attempt, warming, freeQuota = !1) {
|
|
38
|
+
this.sessionId = sessionId;
|
|
39
|
+
this.receipt = receipt;
|
|
40
|
+
this.requestKind = requestKind;
|
|
41
|
+
this.model = model;
|
|
42
|
+
this.attempt = attempt;
|
|
43
|
+
this.warming = warming;
|
|
44
|
+
this.freeQuota = freeQuota;
|
|
45
|
+
}
|
|
46
|
+
event(event) {
|
|
47
|
+
if (!isRecord(event))
|
|
48
|
+
return;
|
|
49
|
+
if (event.type === "error" || event.type === "response.failed")
|
|
50
|
+
this.failed = !0;
|
|
51
|
+
if (event.type !== "response.completed" && event.type !== "response.incomplete" && event.type !== "response.failed")
|
|
52
|
+
return;
|
|
53
|
+
this.completed = event.type !== "response.failed";
|
|
54
|
+
if (isRecord(event.response)) {
|
|
55
|
+
if (typeof event.response.id === "string")
|
|
56
|
+
this.responseId = event.response.id;
|
|
57
|
+
this.usage = codexBillingUsage(event.response.usage);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
piCompleted(responseId, value) {
|
|
61
|
+
this.completed = !0;
|
|
62
|
+
this.piResponseId(responseId);
|
|
63
|
+
if (!isRecord(value))
|
|
64
|
+
return;
|
|
65
|
+
const usage = { reasoningIncludedInOutput: !0 };
|
|
66
|
+
for (const key of ["input", "output", "cacheRead", "reasoning"])
|
|
67
|
+
if (typeof value[key] === "number")
|
|
68
|
+
usage[key] = value[key];
|
|
69
|
+
if (typeof value.cacheWrite === "number" && value.cacheWrite > 0)
|
|
70
|
+
usage.cacheWrite = value.cacheWrite;
|
|
71
|
+
this.usage = usage;
|
|
72
|
+
}
|
|
73
|
+
piResponseId(responseId) {
|
|
74
|
+
this.responseId = responseId;
|
|
75
|
+
}
|
|
76
|
+
end(outputStarted, ended, status, cancelled = !1) {
|
|
77
|
+
if (this.reported)
|
|
78
|
+
return;
|
|
79
|
+
this.reported = !0;
|
|
80
|
+
let warming;
|
|
81
|
+
try {
|
|
82
|
+
warming = this.warming?.(this.sessionId);
|
|
83
|
+
} catch {}
|
|
84
|
+
reportRouting({
|
|
85
|
+
sessionId: this.sessionId,
|
|
86
|
+
kind: "billing",
|
|
87
|
+
attemptId: this.attemptId,
|
|
88
|
+
requestKind: this.requestKind,
|
|
89
|
+
credentialId: this.receipt.credentialId,
|
|
90
|
+
...this.receipt.accountIdentity ? { accountId: this.receipt.accountIdentity } : {},
|
|
91
|
+
provider: "openai",
|
|
92
|
+
model: this.model,
|
|
93
|
+
...this.freeQuota ? { chargeBasis: "subscription_included" } : {},
|
|
94
|
+
attempt: this.attempt,
|
|
95
|
+
cache: {
|
|
96
|
+
implicit: !0,
|
|
97
|
+
warming: warming?.on ? { on: !0 } : {
|
|
98
|
+
on: !1,
|
|
99
|
+
...isCacheWarmStopReason(warming?.stopReason) ? { stopReason: warming.stopReason } : {}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
outcome: this.failed || status !== void 0 && (status < 200 || status >= 300) ? "failed" : this.completed && (ended || cancelled) ? "completed" : outputStarted ? "cut" : "failed",
|
|
103
|
+
...status !== void 0 ? { status } : {},
|
|
104
|
+
...this.responseId ? { providerResponseId: this.responseId } : {},
|
|
105
|
+
...this.usage ? { usage: this.usage } : {}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createLogger } from "./d669d72c40e9e116-logger.js";
|
|
2
|
+
import { isRecord } from "./775431e21f469203-record.js";
|
|
3
|
+
const log = createLogger("transport");
|
|
4
|
+
function category(value) {
|
|
5
|
+
return typeof value === "string" && value.length >= 1 && value.length <= 40 && !/[^a-z0-9_]/.test(value) ? value : "other";
|
|
6
|
+
}
|
|
7
|
+
export function inputTransformationsOf(response) {
|
|
8
|
+
if (!isRecord(response))
|
|
9
|
+
return;
|
|
10
|
+
const items = response.input_transformations;
|
|
11
|
+
return Array.isArray(items) && items.length > 0 ? items : void 0;
|
|
12
|
+
}
|
|
13
|
+
export function logInputTransformations(response, transport, host, context) {
|
|
14
|
+
const transformations = inputTransformationsOf(response);
|
|
15
|
+
if (!transformations)
|
|
16
|
+
return !1;
|
|
17
|
+
const items = Object.create(null), reasons = Object.create(null);
|
|
18
|
+
for (const item of transformations) {
|
|
19
|
+
const entry = isRecord(item) ? item : void 0, key = `${category(entry?.action)}:${category(entry?.type)}`, reason = category(entry?.reason);
|
|
20
|
+
items[key] = (items[key] ?? 0) + 1;
|
|
21
|
+
reasons[reason] = (reasons[reason] ?? 0) + 1;
|
|
22
|
+
}
|
|
23
|
+
log.info("Codex transformed input items", {
|
|
24
|
+
model: isRecord(response) && typeof response.model === "string" ? response.model : "unknown",
|
|
25
|
+
count: transformations.length,
|
|
26
|
+
items,
|
|
27
|
+
reasons,
|
|
28
|
+
transport,
|
|
29
|
+
host,
|
|
30
|
+
warm: context?.warm,
|
|
31
|
+
chained: context?.chained
|
|
32
|
+
});
|
|
33
|
+
return !0;
|
|
34
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { formatDuration } from "./bd4aef685681048c-duration.js";
|
|
2
|
+
/**
|
|
3
|
+
* Wait in the caller's Pi stream without sending or selecting an account.
|
|
4
|
+
* After 'elapsed', the caller must re-check that the account remains eligible,
|
|
5
|
+
* its identity has not been replaced, and its credentials are still available
|
|
6
|
+
* for use. When waiting to reuse the same account's prompt cache, also check
|
|
7
|
+
* that the session's activity record still belongs to that account incarnation
|
|
8
|
+
* and that the wait target does not exceed its cache expiry. Only then send.
|
|
9
|
+
* After 'aborted', end the stream without a refusal; abort never rejects.
|
|
10
|
+
*/
|
|
11
|
+
export function waitForPi(delayMs, options) {
|
|
12
|
+
if (!Number.isFinite(delayMs) || delayMs < 0) {
|
|
13
|
+
throw new RangeError('Pi wait requires a finite non-negative delay');
|
|
14
|
+
}
|
|
15
|
+
return new Promise((resolve) => {
|
|
16
|
+
const target = Date.now() + delayMs;
|
|
17
|
+
let timer;
|
|
18
|
+
let settled = false;
|
|
19
|
+
const workingMessage = (text) => {
|
|
20
|
+
// A presentation failure must not strand the stream or mask cancellation.
|
|
21
|
+
try {
|
|
22
|
+
options.setWorkingMessage(text);
|
|
23
|
+
}
|
|
24
|
+
catch { }
|
|
25
|
+
};
|
|
26
|
+
const finish = (result) => {
|
|
27
|
+
if (settled)
|
|
28
|
+
return;
|
|
29
|
+
settled = true;
|
|
30
|
+
clearTimeout(timer);
|
|
31
|
+
options.signal?.removeEventListener('abort', abort);
|
|
32
|
+
workingMessage();
|
|
33
|
+
resolve(result);
|
|
34
|
+
};
|
|
35
|
+
const abort = () => finish('aborted');
|
|
36
|
+
const tick = () => {
|
|
37
|
+
const remaining = target - Date.now();
|
|
38
|
+
if (remaining <= 0)
|
|
39
|
+
return finish('elapsed');
|
|
40
|
+
workingMessage(`Waiting for the account limit to reset · ${formatDuration(remaining)} · Esc to cancel`);
|
|
41
|
+
// The callback may itself cancel the stream. Do not arm a timer afterward.
|
|
42
|
+
if (!settled)
|
|
43
|
+
timer = setTimeout(tick, Math.min(1000, remaining));
|
|
44
|
+
};
|
|
45
|
+
options.signal?.addEventListener('abort', abort, { once: true });
|
|
46
|
+
if (options.signal?.aborted)
|
|
47
|
+
abort();
|
|
48
|
+
else
|
|
49
|
+
tick();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { confirm } from "./4ba847b77580b1eb-confirm.js";
|
|
2
|
+
import { select } from "./7b5d6afff4ff32b9-select.js";
|
|
3
|
+
import { isInteractive, printLine, processTerminal, } from "./ea56007991dbf068-terminal.js";
|
|
4
|
+
export function menuContext(terminal) {
|
|
5
|
+
const interactive = isInteractive(terminal);
|
|
6
|
+
return {
|
|
7
|
+
terminal,
|
|
8
|
+
interactive,
|
|
9
|
+
print: (line) => printLine(terminal, line),
|
|
10
|
+
confirm: (message, defaultYes) => confirm(terminal, message, defaultYes),
|
|
11
|
+
select: async (items, options) => interactive && items.length > 0 ? select(terminal, items, options) : null,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function printPlainMenu(context, options) {
|
|
15
|
+
context.print(options.title);
|
|
16
|
+
if (options.subtitle)
|
|
17
|
+
context.print(options.subtitle);
|
|
18
|
+
for (const line of options.status ?? [])
|
|
19
|
+
context.print(` ${line}`);
|
|
20
|
+
context.print('');
|
|
21
|
+
context.print('Actions:');
|
|
22
|
+
for (const action of options.actions) {
|
|
23
|
+
context.print(action.hint
|
|
24
|
+
? ` - ${action.label} (${action.hint})`
|
|
25
|
+
: ` - ${action.label}`);
|
|
26
|
+
}
|
|
27
|
+
context.print('');
|
|
28
|
+
context.print('This menu needs an interactive terminal to choose an action; nothing was changed.');
|
|
29
|
+
return { status: 'not-interactive' };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Show the full-screen menu once and run the chosen action. Without an
|
|
33
|
+
* interactive terminal it prints the same content as a plain list and runs
|
|
34
|
+
* nothing, so a piped or scripted login exits cleanly instead of hanging on
|
|
35
|
+
* a key that never comes. An action's failure is printed and reported rather
|
|
36
|
+
* than thrown, because the caller still owes the host its result.
|
|
37
|
+
*/
|
|
38
|
+
export async function runMenu(options) {
|
|
39
|
+
const terminal = options.terminal ?? processTerminal();
|
|
40
|
+
const context = menuContext(terminal);
|
|
41
|
+
if (!context.interactive)
|
|
42
|
+
return printPlainMenu(context, options);
|
|
43
|
+
if (options.actions.length === 0) {
|
|
44
|
+
context.print('No actions are available.');
|
|
45
|
+
return { status: 'cancelled' };
|
|
46
|
+
}
|
|
47
|
+
const chosen = await select(terminal, options.actions.map((action) => ({
|
|
48
|
+
label: action.label,
|
|
49
|
+
value: action,
|
|
50
|
+
color: action.destructive ? 'red' : 'cyan',
|
|
51
|
+
...(action.hint ? { hint: action.hint } : {}),
|
|
52
|
+
})), {
|
|
53
|
+
message: options.title,
|
|
54
|
+
subtitle: options.subtitle ?? 'Select an account action',
|
|
55
|
+
...(options.status ? { lines: options.status } : {}),
|
|
56
|
+
clearScreen: true,
|
|
57
|
+
});
|
|
58
|
+
if (!chosen)
|
|
59
|
+
return { status: 'cancelled' };
|
|
60
|
+
if (chosen.destructive &&
|
|
61
|
+
!(await context.confirm(chosen.confirm ?? `${chosen.label}?`))) {
|
|
62
|
+
context.print('Cancelled; nothing was changed.');
|
|
63
|
+
return { status: 'declined', action: chosen.id };
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
await chosen.run(context);
|
|
67
|
+
return { status: 'ran', action: chosen.id };
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
context.print(`${chosen.label} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
71
|
+
return { status: 'failed', action: chosen.id, error };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sameAccount
|
|
3
|
+
} from "./1547bd74f4214d2d-index.js";
|
|
4
|
+
import { limitAccountId } from "./595bdf3fff13ba79-limit-identity.js";
|
|
5
|
+
const strength = { unproven: 0, reading: 1, provider: 2 };
|
|
6
|
+
|
|
7
|
+
export class LimitProvenanceStore {
|
|
8
|
+
namespace;
|
|
9
|
+
entries = new Map;
|
|
10
|
+
constructor(namespace) {
|
|
11
|
+
this.namespace = namespace;
|
|
12
|
+
}
|
|
13
|
+
record(entry, now) {
|
|
14
|
+
if (entry.accountKey.namespace !== this.namespace)
|
|
15
|
+
return;
|
|
16
|
+
if (![entry.expiry, entry.observedAt, entry.evidenceAt, now].every(Number.isFinite))
|
|
17
|
+
return;
|
|
18
|
+
this.prune(now);
|
|
19
|
+
if (entry.expiry <= now)
|
|
20
|
+
return;
|
|
21
|
+
const id = limitAccountId(entry.accountKey), previous = this.entries.get(id);
|
|
22
|
+
if (previous?.expiry === entry.expiry) {
|
|
23
|
+
if (strength[previous.branch] <= strength[entry.branch])
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.entries.set(id, entry);
|
|
27
|
+
if (this.entries.size <= 256)
|
|
28
|
+
return;
|
|
29
|
+
let oldest, observedAt = 1 / 0;
|
|
30
|
+
for (const [key, value] of this.entries)
|
|
31
|
+
if (value.observedAt < observedAt) {
|
|
32
|
+
oldest = key;
|
|
33
|
+
observedAt = value.observedAt;
|
|
34
|
+
}
|
|
35
|
+
if (oldest !== void 0)
|
|
36
|
+
this.entries.delete(oldest);
|
|
37
|
+
}
|
|
38
|
+
read(account, expiry, evidenceAt, now) {
|
|
39
|
+
this.prune(now);
|
|
40
|
+
const entry = this.entries.get(limitAccountId(account));
|
|
41
|
+
return entry?.expiry === expiry && entry.evidenceAt === evidenceAt ? entry : void 0;
|
|
42
|
+
}
|
|
43
|
+
retire(account) {
|
|
44
|
+
this.entries.delete(limitAccountId(account));
|
|
45
|
+
}
|
|
46
|
+
clear() {
|
|
47
|
+
this.entries.clear();
|
|
48
|
+
}
|
|
49
|
+
reconcile(snapshot, now) {
|
|
50
|
+
this.prune(now);
|
|
51
|
+
for (const [id, entry] of this.entries)
|
|
52
|
+
if (!snapshot.marks.some((mark) => sameAccount(mark.key.account, entry.accountKey) && mark.key.window === "account" && mark.key.scope.kind === "pool" && mark.entries.some((value) => value.cause === "rate-limit" && value.until === entry.expiry && value.evidenceAt === entry.evidenceAt)))
|
|
53
|
+
this.entries.delete(id);
|
|
54
|
+
}
|
|
55
|
+
prune(now) {
|
|
56
|
+
for (const [id, entry] of this.entries)
|
|
57
|
+
if (entry.expiry <= now)
|
|
58
|
+
this.entries.delete(id);
|
|
59
|
+
}
|
|
60
|
+
}
|