@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,60 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { gptModelVersion } from "./e5229952fc12f647-codex-models.js";
|
|
3
|
+
import { isRecord } from "./775431e21f469203-record.js";
|
|
4
|
+
import { stableStringify } from "./66937534c260d20b-stable-json.js";
|
|
5
|
+
export function supportsMidConversationEffort(model) {
|
|
6
|
+
const version = gptModelVersion(model);
|
|
7
|
+
return version !== void 0 && Number(version.split(".")[0]) >= 6;
|
|
8
|
+
}
|
|
9
|
+
export function isMessageWithRole(item, role) {
|
|
10
|
+
return isRecord(item) && (item.type === "message" || ("role" in item)) && item.role === role;
|
|
11
|
+
}
|
|
12
|
+
export function applyMidConversationEffort(body, state) {
|
|
13
|
+
const model = typeof body.model === "string" ? body.model : "";
|
|
14
|
+
if (!supportsMidConversationEffort(model))
|
|
15
|
+
return;
|
|
16
|
+
const reasoning = isRecord(body.reasoning) ? body.reasoning : void 0, effort = typeof reasoning?.effort === "string" ? reasoning.effort : void 0;
|
|
17
|
+
if (!effort)
|
|
18
|
+
return;
|
|
19
|
+
const input = Array.isArray(body.input) ? body.input : void 0;
|
|
20
|
+
state.effortUpdates ??= [];
|
|
21
|
+
const updates = state.effortUpdates, fingerprint = (item) => createHash("sha256").update(stableStringify(item)).digest("hex").slice(0, 16);
|
|
22
|
+
if (state.pinnedEffort === void 0 || updates.some((update) => !input || !isMessageWithRole(input[update.anchor], "user") || fingerprint(input[update.anchor]) !== update.fingerprint)) {
|
|
23
|
+
state.pinnedEffort = effort;
|
|
24
|
+
state.effortUpdates = [];
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!input || input.length === 0)
|
|
28
|
+
return;
|
|
29
|
+
const anchor = input.findLastIndex((item) => isMessageWithRole(item, "user")), latest = updates.at(-1), effective = latest?.effort ?? state.pinnedEffort;
|
|
30
|
+
if (anchor >= 0 && effort !== effective)
|
|
31
|
+
if (latest?.anchor === anchor) {
|
|
32
|
+
const before = updates.at(-2)?.effort ?? state.pinnedEffort;
|
|
33
|
+
if (effort === before)
|
|
34
|
+
updates.pop();
|
|
35
|
+
else
|
|
36
|
+
latest.effort = effort;
|
|
37
|
+
} else
|
|
38
|
+
updates.push({ anchor, fingerprint: fingerprint(input[anchor]), effort });
|
|
39
|
+
else if (anchor < 0 && effort !== effective)
|
|
40
|
+
return;
|
|
41
|
+
if (updates.some((update, i) => i > 0 && update.anchor <= (updates[i - 1]?.anchor ?? -1))) {
|
|
42
|
+
state.pinnedEffort = effort;
|
|
43
|
+
state.effortUpdates = [];
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
body.reasoning = { ...reasoning, effort: state.pinnedEffort };
|
|
47
|
+
if (updates.length === 0)
|
|
48
|
+
return;
|
|
49
|
+
const replay = input.slice();
|
|
50
|
+
for (let i = updates.length - 1;i >= 0; i--) {
|
|
51
|
+
const update = updates[i];
|
|
52
|
+
if (!update)
|
|
53
|
+
continue;
|
|
54
|
+
replay.splice(update.anchor, 0, {
|
|
55
|
+
type: "configuration_update",
|
|
56
|
+
reasoning: { effort: update.effort }
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
body.input = replay;
|
|
60
|
+
}
|
|
@@ -156,6 +156,56 @@ export const DEFAULT_SIDEBAR_STATE = {
|
|
|
156
156
|
route: "main",
|
|
157
157
|
lastUpdated: 0
|
|
158
158
|
};
|
|
159
|
+
function quotaRecord(value) {
|
|
160
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
161
|
+
}
|
|
162
|
+
function quotaNumber(value) {
|
|
163
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
164
|
+
}
|
|
165
|
+
function readQuotaWindow(value) {
|
|
166
|
+
if (!quotaRecord(value))
|
|
167
|
+
return;
|
|
168
|
+
const { checkedAt, usedPercent, remainingPercent, resetsAt, windowMinutes } = value;
|
|
169
|
+
if (resetsAt !== void 0 && typeof resetsAt !== "string" || windowMinutes !== void 0 && !quotaNumber(windowMinutes))
|
|
170
|
+
return;
|
|
171
|
+
const hasReading = quotaNumber(usedPercent) && (remainingPercent === void 0 || quotaNumber(remainingPercent)) && (checkedAt === void 0 || quotaNumber(checkedAt));
|
|
172
|
+
return {
|
|
173
|
+
...resetsAt !== void 0 ? { resetsAt } : {},
|
|
174
|
+
...windowMinutes !== void 0 ? { windowMinutes } : {},
|
|
175
|
+
...quotaNumber(checkedAt) ? { checkedAt } : {},
|
|
176
|
+
...hasReading ? { usedPercent } : {},
|
|
177
|
+
...hasReading && remainingPercent !== void 0 ? { remainingPercent } : {}
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function quotaSpendControl(value) {
|
|
181
|
+
return quotaRecord(value) && (value.limit === void 0 || quotaNumber(value.limit)) && (value.used === void 0 || quotaNumber(value.used)) && (value.remaining === void 0 || quotaNumber(value.remaining)) && (value.usedPercent === void 0 || quotaNumber(value.usedPercent)) && (value.remainingPercent === void 0 || quotaNumber(value.remainingPercent)) && typeof value.reached === "boolean" && (value.resetsAt === void 0 || typeof value.resetsAt === "string") && (value.unit === void 0 || typeof value.unit === "string") && (value.source === void 0 || typeof value.source === "string");
|
|
182
|
+
}
|
|
183
|
+
function quotaCredits(value) {
|
|
184
|
+
return quotaRecord(value) && typeof value.hasCredits === "boolean" && typeof value.unlimited === "boolean" && (value.balance === void 0 || quotaNumber(value.balance)) && (value.checkedAt === void 0 || quotaNumber(value.checkedAt)) && (value.overageLimitReached === void 0 || typeof value.overageLimitReached === "boolean");
|
|
185
|
+
}
|
|
186
|
+
function readAccountQuota(value) {
|
|
187
|
+
if (!quotaRecord(value))
|
|
188
|
+
return null;
|
|
189
|
+
const quota = { ...value };
|
|
190
|
+
for (const key of QUOTA_WINDOW_KEYS) {
|
|
191
|
+
const window = readQuotaWindow(quota[key]);
|
|
192
|
+
if (window)
|
|
193
|
+
quota[key] = window;
|
|
194
|
+
else
|
|
195
|
+
delete quota[key];
|
|
196
|
+
}
|
|
197
|
+
if (!quotaNumber(quota.checkedAt))
|
|
198
|
+
delete quota.checkedAt;
|
|
199
|
+
if (!quotaSpendControl(quota.spendControl))
|
|
200
|
+
delete quota.spendControl;
|
|
201
|
+
if (quota.spendControlCleared !== !0)
|
|
202
|
+
delete quota.spendControlCleared;
|
|
203
|
+
if (!quotaNumber(quota.resetCreditsAvailable))
|
|
204
|
+
delete quota.resetCreditsAvailable;
|
|
205
|
+
if (!quotaCredits(quota.credits))
|
|
206
|
+
delete quota.credits;
|
|
207
|
+
return quota;
|
|
208
|
+
}
|
|
159
209
|
export function normalizeSidebarState(raw) {
|
|
160
210
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
161
211
|
return DEFAULT_SIDEBAR_STATE;
|
|
@@ -164,7 +214,7 @@ export function normalizeSidebarState(raw) {
|
|
|
164
214
|
if (rawMain !== null && typeof rawMain === "object" && !Array.isArray(rawMain)) {
|
|
165
215
|
const m = rawMain;
|
|
166
216
|
main = {
|
|
167
|
-
quota:
|
|
217
|
+
quota: readAccountQuota(m.quota),
|
|
168
218
|
killed: typeof m.killed === "boolean" ? m.killed : !1,
|
|
169
219
|
...typeof m.mainAccountId === "string" ? { mainAccountId: m.mainAccountId } : {},
|
|
170
220
|
...typeof m.quotaBackedOff === "boolean" ? { quotaBackedOff: m.quotaBackedOff } : {},
|
|
@@ -198,7 +248,7 @@ function normalizeAccountList(raw) {
|
|
|
198
248
|
...typeof e.credentialId === "string" ? { credentialId: e.credentialId } : {},
|
|
199
249
|
label: typeof e.label === "string" ? e.label : void 0,
|
|
200
250
|
...typeof e.accountId === "string" ? { accountId: e.accountId } : {},
|
|
201
|
-
quota:
|
|
251
|
+
quota: readAccountQuota(e.quota),
|
|
202
252
|
killed: typeof e.killed === "boolean" ? e.killed : !1,
|
|
203
253
|
enabled: typeof e.enabled === "boolean" ? e.enabled : !0,
|
|
204
254
|
...typeof e.routable === "boolean" ? { routable: e.routable } : {},
|
|
@@ -975,7 +1025,7 @@ export function sidebarQuotaProjection(quota, now = Date.now()) {
|
|
|
975
1025
|
scope: "all",
|
|
976
1026
|
label,
|
|
977
1027
|
usedPercent: window.usedPercent,
|
|
978
|
-
checkedAt: window.checkedAt ?? quota.checkedAt ?? now,
|
|
1028
|
+
checkedAt: window.checkedAt ?? (quotaNumber(window.usedPercent) ? quota.checkedAt : void 0) ?? now,
|
|
979
1029
|
windowMinutes: window.windowMinutes,
|
|
980
1030
|
resetsAt: window.resetsAt
|
|
981
1031
|
}
|
|
@@ -1061,7 +1111,7 @@ export function fitCollapsedLabel(label, columns) {
|
|
|
1061
1111
|
}
|
|
1062
1112
|
const PACING_MIN_ELAPSED_MS = 300000, PACING_MIN_ELAPSED_FRACTION = 0.01, ON_PACE_DELTA = 1;
|
|
1063
1113
|
export function computeQuotaPacing(window, windowMs, now) {
|
|
1064
|
-
if (!window.resetsAt)
|
|
1114
|
+
if (!window.resetsAt || !quotaNumber(window.usedPercent))
|
|
1065
1115
|
return null;
|
|
1066
1116
|
const resetsAt = new Date(window.resetsAt).getTime();
|
|
1067
1117
|
if (!Number.isFinite(resetsAt))
|
|
@@ -124,7 +124,7 @@ export async function openControlDialog(dialog, initial, apply, active = () => !
|
|
|
124
124
|
});
|
|
125
125
|
if (!active())
|
|
126
126
|
return;
|
|
127
|
-
payload = { command: result.command, menu: result.menu };
|
|
127
|
+
payload = { command: result.command, menu: result.menu ?? payload.menu };
|
|
128
128
|
await dialog.alert({ title: payload.menu.title, message: result.text });
|
|
129
129
|
} catch (error) {
|
|
130
130
|
if (!active())
|
|
@@ -296,7 +296,8 @@ const SPEND_CONTROL_LABEL = 'credits'
|
|
|
296
296
|
// the wall clock — the label column is sized from these alone.
|
|
297
297
|
function quotaRowLabels(quota: AccountQuota | null): string[] {
|
|
298
298
|
const labels = getPresentQuotaWindows(quota).map((row) => row.label)
|
|
299
|
-
if (quota?.spendControl)
|
|
299
|
+
if (hasSpendControlPercentages(quota?.spendControl))
|
|
300
|
+
labels.push(SPEND_CONTROL_LABEL)
|
|
300
301
|
return labels
|
|
301
302
|
}
|
|
302
303
|
|
|
@@ -385,7 +386,7 @@ export function buildQuotaRowsForDisplay(
|
|
|
385
386
|
}
|
|
386
387
|
})
|
|
387
388
|
const spendControl = quota?.spendControl
|
|
388
|
-
if (spendControl) {
|
|
389
|
+
if (hasSpendControlPercentages(spendControl)) {
|
|
389
390
|
const rowProjection = projection && { ...projection, limits: [] }
|
|
390
391
|
const reset = quotaWindowParts(rowProjection, {
|
|
391
392
|
now,
|
|
@@ -445,8 +446,20 @@ function pluralizeUnit(unit: string, count: number): string {
|
|
|
445
446
|
return unit.endsWith('s') ? unit : `${unit}s`
|
|
446
447
|
}
|
|
447
448
|
|
|
449
|
+
function hasSpendControlPercentages(
|
|
450
|
+
reading: SpendControlReading | undefined,
|
|
451
|
+
): reading is SpendControlReading & {
|
|
452
|
+
usedPercent: number
|
|
453
|
+
remainingPercent: number
|
|
454
|
+
} {
|
|
455
|
+
return (
|
|
456
|
+
Number.isFinite(reading?.usedPercent) &&
|
|
457
|
+
Number.isFinite(reading?.remainingPercent)
|
|
458
|
+
)
|
|
459
|
+
}
|
|
460
|
+
|
|
448
461
|
export function formatSpendControlAmounts(
|
|
449
|
-
spendControl: SpendControlReading,
|
|
462
|
+
spendControl: SpendControlReading & { limit: number; used: number },
|
|
450
463
|
): string {
|
|
451
464
|
const unit = pluralizeUnit(spendControl.unit ?? 'unit', spendControl.limit)
|
|
452
465
|
return `${formatGroupedAmount(spendControl.used)} / ${formatGroupedAmount(spendControl.limit)} ${unit}`
|
|
@@ -466,10 +479,19 @@ export function getAccountMetadataRows(
|
|
|
466
479
|
servingOnCredits = false,
|
|
467
480
|
): Array<{ label: string; value: string }> {
|
|
468
481
|
const rows: Array<{ label: string; value: string }> = []
|
|
469
|
-
if (
|
|
482
|
+
if (
|
|
483
|
+
typeof spendControl?.limit === 'number' &&
|
|
484
|
+
Number.isFinite(spendControl.limit) &&
|
|
485
|
+
typeof spendControl.used === 'number' &&
|
|
486
|
+
Number.isFinite(spendControl.used)
|
|
487
|
+
) {
|
|
470
488
|
rows.push({
|
|
471
489
|
label: 'credits',
|
|
472
|
-
value: formatSpendControlAmounts(
|
|
490
|
+
value: formatSpendControlAmounts({
|
|
491
|
+
...spendControl,
|
|
492
|
+
limit: spendControl.limit,
|
|
493
|
+
used: spendControl.used,
|
|
494
|
+
}),
|
|
473
495
|
})
|
|
474
496
|
}
|
|
475
497
|
if (prepaidCredits !== undefined) {
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/** ANSI controls used by the first-party auth menu. */
|
|
2
|
+
export const ANSI = {
|
|
3
|
+
hide: '\x1b[?25l',
|
|
4
|
+
show: '\x1b[?25h',
|
|
5
|
+
up: (n = 1) => `\x1b[${n}A`,
|
|
6
|
+
clearLine: '\x1b[2K',
|
|
7
|
+
clearScreen: '\x1b[2J',
|
|
8
|
+
moveTo: (row, col) => `\x1b[${row};${col}H`,
|
|
9
|
+
cyan: '\x1b[36m',
|
|
10
|
+
green: '\x1b[32m',
|
|
11
|
+
red: '\x1b[31m',
|
|
12
|
+
dim: '\x1b[2m',
|
|
13
|
+
reset: '\x1b[0m',
|
|
14
|
+
};
|
|
15
|
+
/** Tokenize complete keys in one read; incomplete escape sequences are ignored. */
|
|
16
|
+
export function parseKeys(data) {
|
|
17
|
+
const value = data.toString();
|
|
18
|
+
const keys = [];
|
|
19
|
+
for (let index = 0; index < value.length;) {
|
|
20
|
+
const char = value[index];
|
|
21
|
+
if (char === '\x1b') {
|
|
22
|
+
const sequence = value.slice(index, index + 3);
|
|
23
|
+
const arrow = sequence[1] === '[' || sequence[1] === 'O' ? sequence[2] : undefined;
|
|
24
|
+
if (arrow && 'ABCD'.includes(arrow)) {
|
|
25
|
+
const action = { A: 'up', B: 'down', C: 'right', D: 'left' };
|
|
26
|
+
const parsed = action[arrow];
|
|
27
|
+
if (parsed)
|
|
28
|
+
keys.push(parsed);
|
|
29
|
+
index += 3;
|
|
30
|
+
}
|
|
31
|
+
else if (index + 1 === value.length) {
|
|
32
|
+
// Only a chunk consisting solely of ESC gets the legacy Escape timeout.
|
|
33
|
+
if (index === 0)
|
|
34
|
+
keys.push('escape-start');
|
|
35
|
+
index += 1;
|
|
36
|
+
}
|
|
37
|
+
else if ((value[index + 1] === '[' || value[index + 1] === 'O') &&
|
|
38
|
+
index + 2 >= value.length) {
|
|
39
|
+
// An incomplete escape prefix at the chunk boundary is not a key.
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
index += 1;
|
|
44
|
+
}
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (char === '\r' || char === '\n')
|
|
48
|
+
keys.push('enter');
|
|
49
|
+
else if (char === '\x03')
|
|
50
|
+
keys.push('escape');
|
|
51
|
+
else if (char && char >= ' ')
|
|
52
|
+
keys.push('char');
|
|
53
|
+
index += 1;
|
|
54
|
+
}
|
|
55
|
+
return keys;
|
|
56
|
+
}
|
|
57
|
+
/** Preserve the single-key parser for callers that only need the first token. */
|
|
58
|
+
export function parseKey(data) {
|
|
59
|
+
return parseKeys(data)[0] ?? null;
|
|
60
|
+
}
|
|
61
|
+
const ANSI_PATTERN = `${String.fromCharCode(27)}\\[[0-9;]*m`;
|
|
62
|
+
const ANSI_REGEX = new RegExp(ANSI_PATTERN, 'g');
|
|
63
|
+
const ANSI_LEADING_REGEX = new RegExp(`^${ANSI_PATTERN}`);
|
|
64
|
+
/** Remove colour codes, leaving the text an operator sees. */
|
|
65
|
+
export function stripAnsi(input) {
|
|
66
|
+
return input.replace(ANSI_REGEX, '');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Shorten coloured text to a visible width without cutting an escape code in
|
|
70
|
+
* half, resetting the colour before the ellipsis so it cannot bleed.
|
|
71
|
+
*/
|
|
72
|
+
export function truncateAnsi(input, maxVisibleChars) {
|
|
73
|
+
if (maxVisibleChars <= 0)
|
|
74
|
+
return '';
|
|
75
|
+
if (stripAnsi(input).length <= maxVisibleChars)
|
|
76
|
+
return input;
|
|
77
|
+
const suffix = maxVisibleChars >= 3 ? '...' : '.'.repeat(maxVisibleChars);
|
|
78
|
+
const keep = Math.max(0, maxVisibleChars - suffix.length);
|
|
79
|
+
let output = '';
|
|
80
|
+
let offset = 0;
|
|
81
|
+
let visible = 0;
|
|
82
|
+
while (offset < input.length && visible < keep) {
|
|
83
|
+
if (input[offset] === '\x1b') {
|
|
84
|
+
const match = input.slice(offset).match(ANSI_LEADING_REGEX);
|
|
85
|
+
if (match) {
|
|
86
|
+
output += match[0];
|
|
87
|
+
offset += match[0].length;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
output += input[offset];
|
|
92
|
+
offset += 1;
|
|
93
|
+
visible += 1;
|
|
94
|
+
}
|
|
95
|
+
return output.includes('\x1b[')
|
|
96
|
+
? `${output}${ANSI.reset}${suffix}`
|
|
97
|
+
: output + suffix;
|
|
98
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a persisted `{ startHour, endHour }` pair. Anything other than two
|
|
3
|
+
* distinct whole hours in 0-23 is no window at all, which callers treat as
|
|
4
|
+
* "always warm".
|
|
5
|
+
*/
|
|
6
|
+
export function normalizeCacheKeepWindow(value) {
|
|
7
|
+
if (!value || typeof value !== 'object')
|
|
8
|
+
return undefined;
|
|
9
|
+
const record = value;
|
|
10
|
+
const startHour = Number(record.startHour);
|
|
11
|
+
const endHour = Number(record.endHour);
|
|
12
|
+
if (!Number.isInteger(startHour) ||
|
|
13
|
+
!Number.isInteger(endHour) ||
|
|
14
|
+
startHour < 0 ||
|
|
15
|
+
startHour > 23 ||
|
|
16
|
+
endHour < 0 ||
|
|
17
|
+
endHour > 23 ||
|
|
18
|
+
startHour === endHour) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return { startHour, endHour };
|
|
22
|
+
}
|
|
23
|
+
/** Whether the local hour of `now` falls inside the window; no window is never inside. */
|
|
24
|
+
export function isWithinCacheKeepWindow(window, now = new Date()) {
|
|
25
|
+
if (!window)
|
|
26
|
+
return false;
|
|
27
|
+
const hour = now.getHours();
|
|
28
|
+
if (window.startHour < window.endHour) {
|
|
29
|
+
return hour >= window.startHour && hour < window.endHour;
|
|
30
|
+
}
|
|
31
|
+
// Overnight wrap (e.g. 22-6): in window at or after the start, or before the end.
|
|
32
|
+
return hour >= window.startHour || hour < window.endHour;
|
|
33
|
+
}
|