@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,2 @@
|
|
|
1
|
+
import{ge as PZ,he as HZ,je as u,ke as OZ,le as TZ,pe as r,qg as RZ,ug as CZ,wg as FZ}from"./index-x00sxt2w.js";import{Eg as YZ,Jg as zZ,Kg as GZ,Mg as h,Og as f}from"./index-49ncs7dr.js";import{th as _Z}from"./index-td4g5dc9.js";import{Ah as w,Bh as VZ,uh as x,vh as XZ}from"./index-4ktepxn1.js";import{createHash as aZ}from"node:crypto";import{constants as sZ,copyFileSync as nZ,mkdirSync as tZ,statSync as eZ}from"node:fs";import{readFile as Z0}from"node:fs/promises";import{homedir as $0,tmpdir as J0}from"node:os";import{dirname as X0,join as g}from"node:path";import{chmod as rZ,mkdir as cZ}from"node:fs/promises";import{dirname as JZ}from"node:path";function p(Z){let{path:$,defaultValue:X,normalize:J}=Z,V=Promise.resolve(),Y=(B)=>{if(B==="")return X;try{return J(JSON.parse(B))}catch{return X}},z=async()=>{try{if(x)await w(JZ($),Z.secureDir??!0);return await VZ($,x)}catch(B){if(B.code==="ENOENT")return"";throw B}},G=async()=>{try{return Y(await z())}catch(B){if(B instanceof XZ)throw B;return X}},L=(B,D)=>{let N=V.then(B).then((W)=>D?.onResult?.(W));return V=N.catch(()=>{}),N},U={...f.sidebar,name:Z.lockName??f.sidebar.name,timeoutMs:Z.timeoutMs??f.sidebar.timeoutMs},K=async(B,D,N)=>{await YZ($,D,{serialize:JSON.stringify,beforeRename:async()=>{await N?.beforeCommit?.(),await B.assertOwned()}}),await N?.afterRename?.();try{return await B.assertOwned(),!0}catch(W){if(W instanceof GZ)return!1;throw W}},Q=async(B,D,N)=>{Z.logger?.warn("sidebar lock lost after rename; repairing write",{path:$});try{let W=await h($,U,async(H)=>{let O=B(await G(),D);if(O===void 0)return"skipped";return await K(H,O,N)?"written":"lost-again"});if(W==="lost-again")Z.logger?.warn("sidebar repair lost its lock after rename",{path:$});return{status:"lost-after-rename",repair:W}}catch(W){if(!(W instanceof zZ))throw W;return Z.logger?.warn("sidebar repair lock unavailable; repair skipped",{path:$}),{status:"lost-after-rename",repair:"lock-unavailable"}}},j=async(B,D)=>{let N=D,W=JZ($),H=Z.secureDir??!0;if(x)await w(W,H);else if(await cZ(W,{recursive:!0,mode:448}),H)await rZ(W,448).catch((E)=>{Z.logger?.warn("sidebar directory permission remediation failed",{error:E instanceof Error?E.message:String(E)})});let O=await h($,U,async(E)=>{let t=async(F)=>({value:F,held:await K(E,F,N)});for(let F=0;F<3;F+=1){let ZZ=await z(),$Z=B(Y(ZZ));if($Z===void 0)return;if(F===0)await N?.beforeRecheck?.();if(await z()!==ZZ)continue;return await t($Z)}let e=B(await G());return e===void 0?void 0:await t(e)});if(O===void 0)return{status:"skipped"};if(O.held)return{status:"written"};let n=D?.repair??Z.repair;if(!n)return Z.logger?.warn("sidebar lock lost after rename; write not repaired",{path:$}),{status:"lost-after-rename",repair:"none"};return await Q(n,O.value,N)};return{read:G,write:(B,D)=>L(()=>j(()=>B,D),D),update:(B,D)=>L(()=>j(B,D),D)}}function w0(Z){let $=Z?.credits;if($===null||typeof $!=="object")return;let{hasCredits:X,unlimited:J,balance:V}=$;if(typeof X!=="boolean"||typeof J!=="boolean")return;return OZ({hasCredits:X,unlimited:J,...typeof V==="number"?{balance:V}:{}})}function h0(Z,$=Date.now()){if(!AZ(Z,$))return!1;if(SZ(Z,$))return!1;return FZ(Z?.credits,$)}var y=["primary","secondary"],oZ={primary:300,secondary:10080};function iZ(Z,$){return PZ({scope:"all",label:$,windowMinutes:Z})}function p0(Z){if(!Z)return[];let $=[];for(let X of y){let J=Z[X];if(!J)continue;let V=J.windowMinutes,Y=V!==void 0&&Number.isFinite(V)&&V>0?V:oZ[X];$.push({key:X,label:iZ(V,X),window:J,windowMs:Y*60000})}return $}var M=_Z("sidebar"),V0="OPENCODE_OPENAI_AUTH_SIDEBAR_STATE_FILE";function EZ(){let Z=process.env.XDG_STATE_HOME||g($0(),".local","state");return g(Z,"cortexkit","openai-auth","sidebar-state.json")}var MZ=g(J0(),"opencode-openai-auth","sidebar-state.json");function o0(Z){MZ=Z,d.clear()}var Y0=/^[a-f0-9]{64}$/,c=604800000,qZ=256,IZ=3600000;function R(Z){return aZ("sha256").update(Z).digest("hex")}function z0(Z){return typeof Z==="number"&&Number.isFinite(Z)&&Z>=0?Z:void 0}function bZ(Z){let $=z0(Z);return $!==void 0?{resetCredits:$}:{}}function G0(Z){if(Z===null||typeof Z!=="object"||Array.isArray(Z))return;let $={};for(let[X,J]of Object.entries(Z)){if(J===null||typeof J!=="object"||Array.isArray(J))continue;let V=J;if(typeof V.activeId!=="string"||typeof V.route!=="string"||typeof V.updatedAt!=="number"||!Number.isFinite(V.updatedAt))continue;$[X]={activeId:V.activeId,route:V.route,updatedAt:V.updatedAt}}return Object.keys($).length>0?$:void 0}function K0(Z){if(Z===null||typeof Z!=="object"||Array.isArray(Z))return;let $={};for(let[X,J]of Object.entries(Z)){if(!Y0.test(X)||J===null||typeof J!=="object"||Array.isArray(J))continue;let V=J;if(typeof V.accountId!=="string"||V.accountId.length===0||typeof V.assignedAt!=="number"||!Number.isFinite(V.assignedAt)||V.assignedAt<0||typeof V.lastSeenAt!=="number"||!Number.isFinite(V.lastSeenAt)||V.lastSeenAt<0||typeof V.inputBytes!=="number"||!Number.isFinite(V.inputBytes)||V.inputBytes<0)continue;let Y=V.quotaCheckedAt;if(Y!==void 0&&(typeof Y!=="number"||!Number.isFinite(Y)||Y<0))continue;let z=V.wireAccountId;$[X]={accountId:V.accountId,assignedAt:V.assignedAt,lastSeenAt:V.lastSeenAt,inputBytes:V.inputBytes,...Y===void 0?{}:{quotaCheckedAt:Y},...typeof z==="string"?{wireAccountId:z}:{}}}return Object.keys($).length>0?$:void 0}function T(){let Z=process.env[V0];if(Z)return Z;let $=EZ();if(!d.has($))d.add($),j0($,MZ);return $}var d=new Set;function j0(Z,$){try{tZ(X0(Z),{recursive:!0,mode:448}),nZ($,Z,sZ.COPYFILE_EXCL)}catch{}}var I={main:{quota:null,killed:!1},fallbacks:[],activeId:void 0,route:"main",lastUpdated:0};function v(Z){return Z!==null&&typeof Z==="object"&&!Array.isArray(Z)}function P(Z){return typeof Z==="number"&&Number.isFinite(Z)}function L0(Z){if(!v(Z))return;let{checkedAt:$,usedPercent:X,remainingPercent:J,resetsAt:V,windowMinutes:Y}=Z;if(V!==void 0&&typeof V!=="string"||Y!==void 0&&!P(Y))return;let z=P(X)&&(J===void 0||P(J))&&($===void 0||P($));return{...V!==void 0?{resetsAt:V}:{},...Y!==void 0?{windowMinutes:Y}:{},...P($)?{checkedAt:$}:{},...z?{usedPercent:X}:{},...z&&J!==void 0?{remainingPercent:J}:{}}}function B0(Z){return v(Z)&&(Z.limit===void 0||P(Z.limit))&&(Z.used===void 0||P(Z.used))&&(Z.remaining===void 0||P(Z.remaining))&&(Z.usedPercent===void 0||P(Z.usedPercent))&&(Z.remainingPercent===void 0||P(Z.remainingPercent))&&typeof Z.reached==="boolean"&&(Z.resetsAt===void 0||typeof Z.resetsAt==="string")&&(Z.unit===void 0||typeof Z.unit==="string")&&(Z.source===void 0||typeof Z.source==="string")}function U0(Z){return v(Z)&&typeof Z.hasCredits==="boolean"&&typeof Z.unlimited==="boolean"&&(Z.balance===void 0||P(Z.balance))&&(Z.checkedAt===void 0||P(Z.checkedAt))&&(Z.overageLimitReached===void 0||typeof Z.overageLimitReached==="boolean")}function xZ(Z){if(!v(Z))return null;let $={...Z};for(let X of y){let J=L0($[X]);if(J)$[X]=J;else delete $[X]}if(!P($.checkedAt))delete $.checkedAt;if(!B0($.spendControl))delete $.spendControl;if($.spendControlCleared!==!0)delete $.spendControlCleared;if(!P($.resetCreditsAvailable))delete $.resetCreditsAvailable;if(!U0($.credits))delete $.credits;return $}function k(Z){if(Z===null||typeof Z!=="object"||Array.isArray(Z))return I;let $=Z,X=$.main,J;if(X!==null&&typeof X==="object"&&!Array.isArray(X)){let j=X;J={quota:xZ(j.quota),killed:typeof j.killed==="boolean"?j.killed:!1,...typeof j.mainAccountId==="string"?{mainAccountId:j.mainAccountId}:{},...typeof j.quotaBackedOff==="boolean"?{quotaBackedOff:j.quotaBackedOff}:{},...typeof j.quotaBackoffUntil==="number"?{quotaBackoffUntil:j.quotaBackoffUntil}:{},...typeof j.refreshBackedOff==="boolean"?{refreshBackedOff:j.refreshBackedOff}:{},...typeof j.refreshBackoffUntil==="number"?{refreshBackoffUntil:j.refreshBackoffUntil}:{},...bZ(j.resetCredits)}}else J={quota:null,killed:!1};let V=KZ($.fallbacks),Y=Array.isArray($.vaultAccounts)?KZ($.vaultAccounts):void 0,z=typeof $.activeId==="string"?$.activeId:void 0,G=typeof $.route==="string"?$.route:I.route,L=typeof $.lastUpdated==="number"?$.lastUpdated:0,U=typeof $.planType==="string"?$.planType:void 0,K=G0($.activeRouting),Q=K0($.stickyAssignments);return{main:J,fallbacks:V,activeId:z,route:G,lastUpdated:L,...K!==void 0?{activeRouting:K}:{},...Q!==void 0?{stickyAssignments:Q}:{},...U!==void 0?{planType:U}:{},...$.accountPool===!0?{accountPool:!0}:{},...Y!==void 0?{vaultAccounts:Y}:{},...typeof $.vaultDiscovered==="boolean"?{vaultDiscovered:$.vaultDiscovered}:{}}}function KZ(Z){if(!Array.isArray(Z))return[];return Z.filter(($)=>$!==null&&typeof $==="object"&&!Array.isArray($)&&typeof $.id==="string").map(($)=>({id:$.id,...typeof $.credentialId==="string"?{credentialId:$.credentialId}:{},label:typeof $.label==="string"?$.label:void 0,...typeof $.accountId==="string"?{accountId:$.accountId}:{},quota:xZ($.quota),killed:typeof $.killed==="boolean"?$.killed:!1,enabled:typeof $.enabled==="boolean"?$.enabled:!0,...typeof $.routable==="boolean"?{routable:$.routable}:{},...["needs sign-in","turned off in vault","unavailable"].includes($.vaultState)?{vaultState:$.vaultState}:{},...bZ($.resetCredits)}))}function o(Z){return[...Z.fallbacks,...Z.vaultAccounts??[]]}async function Q0(Z=T()){try{let $=await Z0(Z,"utf8");return k(JSON.parse($))}catch{return I}}var D0=3600000,jZ=128;function fZ(Z,$,X=Date.now()){if(!(Z.updatedAt>=X-D0&&Z.updatedAt<=X))return!1;if($===void 0)return!0;return Z.activeId==="main"||$.some((V)=>V.enabled!==!1&&V.routable!==!1&&V.killed!==!0&&V.id===Z.activeId)}function SZ(Z,$=Date.now()){let X=Z?.spendControl;if(X?.reached!==!0||typeof X.resetsAt!=="string")return;let J=Date.parse(X.resetsAt);if(!Number.isFinite(J)||J<=$)return;return{resetsAt:X.resetsAt,resetAtMs:J}}function AZ(Z,$=Date.now()){let X;for(let V of y){let Y=Z?.[V];if(typeof Y?.resetsAt!=="string"||!Number.isFinite(Y.usedPercent)||Y.usedPercent<100)continue;let z=Date.parse(Y.resetsAt);if(!Number.isFinite(z)||z<=$)continue;if(!X||z<X.resetAtMs)X={resetsAt:Y.resetsAt,resetAtMs:z}}let J=SZ(Z,$);if(J&&(!X||J.resetAtMs<X.resetAtMs))X=J;return X}function q(Z,$=Date.now()){return AZ(Z,$)!==void 0}function N0(Z,$,X=Date.now()){if(!$||Z.route!=="sticky-balanced")return;let J=Z.stickyAssignments?.[R($)];if(!J||J.lastSeenAt<X-c)return;if(J.accountId==="main"&&Z.vaultAccounts===void 0)return Z.main?.killed||q(Z.main?.quota,X)?void 0:"main";let V=o(Z).find((Y)=>Y.id===J.accountId);if(!V||V.enabled===!1||V.routable===!1||V.killed===!0||q(V.quota,X))return;return V.id}function i0(Z,$,X=Date.now()){if(!$){if(Z.vaultAccounts===void 0)return{activeId:Z.activeId??"main",route:Z.route};let K=Z.vaultAccounts.find((Q)=>Q.id===Z.activeId&&Q.enabled&&Q.routable!==!1&&!Q.killed);if(K&&!q(K.quota,X))return{activeId:K.id,route:Z.route}}let J=$?Z.activeRouting?.[$]:void 0,V=o(Z),Y=J?.activeId==="main"?Z.main.quota:V.find((K)=>K.id===J?.activeId)?.quota;if(J&&(Z.vaultAccounts===void 0||J.activeId.startsWith("vault:"))&&fZ(J,V,X)&&!q(Y,X))return{activeId:J.activeId,route:J.route};let z=N0(Z,$,X);if(z)return{activeId:z,route:Z.route};let G=Z.vaultAccounts!==void 0,L=(G?i(Z):Z.fallbacks).filter((K)=>K.enabled&&K.routable!==!1&&!K.killed),U=L.find((K)=>!q(K.quota,X))??L[0];return{activeId:G?U?.id??"vault":Z.route==="fallback-first"&&U?U.id:"main",route:Z.route}}function i(Z){let $=Z.vaultAccounts??[],X=new Map($.map((J)=>[J.id,J]));return r($.map((J)=>J.id),uZ(Z),RZ($)??"").flatMap((J)=>{let V=X.get(J);return V?[V]:[]})}function yZ(Z,$,X=Date.now(),J){if(!Z)return;let V=Object.entries(Z).filter(([z,G])=>z!==J&&fZ(G,$,X)),Y=V.length<=jZ?V:V.sort((z,G)=>G[1].updatedAt-z[1].updatedAt).slice(0,jZ);return Y.length>0?Object.fromEntries(Y):void 0}function b(Z,$,X=Date.now(),J){if(!Z)return;let V=0,Y=0,z=0,G=[];for(let[U,K]of Object.entries(Z)){if(U===J){z+=1;continue}if(K.lastSeenAt<X-c){Y+=1;continue}if($!==void 0&&!$.has(K.accountId)){V+=1;continue}G.push([U,K])}let L=V+Y+z;if(L>0)M.debug("pruned sticky assignments",{pid:process.pid,removed:L,reasons:{"account-not-in-roster":V,expired:Y,"explicit-removal":z}});return G.length>0?Object.fromEntries(G):void 0}function vZ(Z,$){let X=Object.keys(Z).length-qZ;if(X<=0)return Z;let J=new Set(Object.entries(Z).filter(([V])=>V!==$).sort(([V,Y],[z,G])=>Y.lastSeenAt-G.lastSeenAt||V.localeCompare(z)).slice(0,X).map(([V])=>V));return Object.fromEntries(Object.entries(Z).filter(([V])=>!J.has(V)))}function kZ(Z,$){if(Z===$)return!0;if(!Z||!$)return!1;let X=Object.entries(Z);if(X.length!==Object.keys($).length)return!1;return X.every(([J,V])=>Object.is($[J],V))}function wZ(Z,$,X,J){return Z!==void 0&&$.has(Z.accountId)&&!X.has(Z.accountId)&&Z.lastSeenAt>=J-c}function hZ(Z,$,X,J){return $>Z.inputBytes||X-Z.lastSeenAt>=IZ||Z.wireAccountId===void 0&&J!==void 0}function pZ(Z,$){return typeof Z.wireAccountId==="string"&&typeof $==="string"&&Z.wireAccountId!==$}function W0(Z){let $=new Map(Z),X={get size(){return $.size},has:(J)=>$.has(J),get:(J)=>$.get(J),entries:()=>$.entries(),keys:()=>$.keys(),values:()=>$.values(),forEach:(J,V)=>{$.forEach((Y,z)=>{J.call(V,Y,z,X)})},[Symbol.iterator]:()=>$[Symbol.iterator]()};return Object.freeze(X)}function P0(Z,$,X){let J=new Map;for(let[V,Y]of Object.entries(Z??{})){if(V===X)continue;if(Y.quotaCheckedAt!==$[Y.accountId])continue;J.set(Y.accountId,(J.get(Y.accountId)??0)+Y.inputBytes)}return W0(J)}function a(Z){if(Z===void 0)return;return new Set(["main",...Z.filter(($)=>$.enabled!==!1&&$.killed!==!0).map(($)=>$.id)])}var l=Promise.resolve();function _(Z){let $=l.then(Z);return l=$.catch(()=>{}),$}var LZ=new Map;function s(Z){let $=LZ.get(Z);if(!$)$=p({path:Z,defaultValue:I,normalize:k,secureDir:Z===EZ(),logger:M}),LZ.set(Z,$);return $}var m=new Set;async function mZ(Z,$){try{await $}catch(X){let J={pid:process.pid,error:X instanceof Error?X.message:String(X)};if(m.has(Z))M.debug("sidebar write failed again",J);else m.add(Z),M.warn("sidebar write failed",J);throw X}if(m.delete(Z))M.info("sidebar write recovered",{pid:process.pid})}function a0(Z,$=T()){return _(()=>mZ($,s($).write(k(Z))))}function H0(Z){return s(Z).read()}function C(Z,$,X){let J=Symbol("sidebar authority changed");return mZ(Z,s(Z).update((V)=>{if(X?.canWrite&&!X.canWrite())return;let Y=$(V);if(Y===void 0)return;if(X?.vaultMode===!1)Y.vaultAccounts=void 0,Y.vaultDiscovered=void 0;if(X?.vaultMode??Y.vaultAccounts!==void 0)Y.activeId=Y.activeId?.startsWith("vault:")?Y.activeId:void 0,Y.activeRouting=Object.fromEntries(Object.entries(Y.activeRouting??{}).filter(([,z])=>z.activeId.startsWith("vault:"))),Y.stickyAssignments=Object.fromEntries(Object.entries(Y.stickyAssignments??{}).filter(([,z])=>z.accountId.startsWith("vault:")&&!Y.vaultAccounts?.some((G)=>G.id===z.accountId&&G.killed)));return k(Y)},{beforeRecheck:async(...V)=>{if(await X?.beforeRecheck?.(...V),X?.canWrite&&!X.canWrite())throw J}}).catch((V)=>{if(V!==J)throw V}))}function S(Z){let $;for(let X of[Z?.primary?.checkedAt,Z?.secondary?.checkedAt,Z?.checkedAt])if(typeof X==="number"&&Number.isFinite(X))$=$===void 0?X:Math.max($,X);return $}function BZ(Z,$){let X=S(Z),J=S($);if(J!==void 0&&(X===void 0||J>X))return $;return Z}function UZ(Z,$){return Z!==void 0&&$!==void 0&&Z===$}function A(Z,$){let X=Z?.checkedAt;if(typeof X==="number"&&Number.isFinite(X))return X;if(typeof $==="number"&&Number.isFinite($))return $;return}function QZ(Z,$,X,J,V){if(Z&&$){let Y=A(Z,J),z=A($,V);if(z!==void 0&&(Y===void 0||z>Y))return $;return Z}return X?$:Z}function DZ(Z,$){if(Z.spendControl!==void 0)return Z.spendControl;if(Z.spendControlCleared===!0)return;return $.spendControl}function O0(Z,$){if(!Z||!$)return Z??$;let X=(J)=>typeof J.checkedAt==="number"&&Number.isFinite(J.checkedAt)?J.checkedAt:Number.NEGATIVE_INFINITY;return X($)>X(Z)?$:Z}function NZ(Z,$){if(!Z)return $;if(!$)return Z;let X=S(Z),J=S($),V=J!==void 0&&(X===void 0||J>X),Y=QZ(Z.primary,$.primary,V,Z.checkedAt,$.checkedAt),z=QZ(Z.secondary,$.secondary,V,Z.checkedAt,$.checkedAt),G=V?DZ($,Z):DZ(Z,$),L=G===void 0&&(Z.spendControlCleared===!0||$.spendControlCleared===!0),U=O0(Z.credits,$.credits),K;for(let N of[A(Y),A(z)])if(N!==void 0)K=K===void 0?N:Math.max(K,N);let{spendControl:Q,spendControlCleared:j,credits:B,...D}=Z;return{...D,primary:Y,secondary:z,...G!==void 0?{spendControl:G}:{},...L?{spendControlCleared:!0}:{},...U!==void 0?{credits:U}:{},checkedAt:K??Z.checkedAt}}function s0(Z,$=T(),X){return _(async()=>{await C($,(J)=>{let V=new Map(J.fallbacks.map((K)=>[K.id,K])),Y=Z.vaultAccounts!==void 0,z=UZ(Z.main.mainAccountId,J.main.mainAccountId),G=z?NZ(Z.main.quota,J.main.quota):BZ(Z.main.quota,J.main.quota),L=Date.now(),U=b(J.stickyAssignments,Y?void 0:a(o(Z)),L);return{...J,...Z,main:Y?Z.main:{...Z.main,quota:G,mainAccountId:z?Z.main.mainAccountId:G===J.main.quota&&G!==Z.main.quota?J.main.mainAccountId:Z.main.mainAccountId},fallbacks:Y?Z.fallbacks:Z.fallbacks.map((K)=>{let Q=V.get(K.id),j=UZ(K.accountId,Q?.accountId),B=j?NZ(K.quota,Q?.quota??null):BZ(K.quota,Q?.quota??null);return{...K,quota:B,accountId:j?K.accountId:B===Q?.quota&&B!==K.quota?Q?.accountId:K.accountId}}),activeId:J.activeId,activeRouting:J.activeRouting,stickyAssignments:U,lastUpdated:Math.max(L,J.lastUpdated+1),accountPool:Z.accountPool===!0?!0:void 0,vaultAccounts:Z.vaultAccounts,vaultDiscovered:Z.vaultDiscovered}},X)})}function n0(Z,$,X=T(),J){return _(async()=>{await C(X,(V)=>{let Y=yZ({...V.activeRouting,[Z.sessionId]:{activeId:Z.activeId,route:Z.route,updatedAt:Z.updatedAt}},$,Date.now()),z=b(V.stickyAssignments,J?.vaultMode??V.vaultAccounts!==void 0?void 0:a($),Date.now());return{...V,activeId:Z.activeId,route:Z.route,activeRouting:Y,stickyAssignments:z,lastUpdated:Math.max(Date.now(),V.lastUpdated+1)}},J)})}function t0(Z,$=T(),X){return _(async()=>{await C($,(J)=>({...J,activeId:Z.activeId,route:Z.route,lastUpdated:Math.max(Date.now(),J.lastUpdated+1)}),X)})}function e0(Z,$,X=T(),J){return _(async()=>{await C(X,(V)=>{let Y=Date.now(),z=yZ(V.activeRouting,$,Y,Z),G=b(V.stickyAssignments,J?.vaultMode??V.vaultAccounts!==void 0?void 0:a($),Y,R(Z));return{...V,activeRouting:z,stickyAssignments:G,lastUpdated:Math.max(Date.now(),V.lastUpdated+1)}},J)})}function gZ(Z,$){return wZ(Z,new Set($.validPinnedAccountIds),new Set($.excludeAccountIds),$.now)&&!pZ(Z,$.wireAccountIdByAccount?.[Z.accountId])&&!hZ(Z,$.requestBytes,$.now,$.wireAccountIdByAccount?.[Z.accountId])}function dZ(Z,$){let X=R($.sessionId),J=new Set($.validPinnedAccountIds),V=new Set($.excludeAccountIds),Y=b(Z.stickyAssignments,J,$.now),z=!kZ(Z.stickyAssignments,Y),G=Y?.[X],L=G!==void 0&&pZ(G,$.wireAccountIdByAccount?.[G.accountId]);if(wZ(G,J,V,$.now)&&!L){let Q=hZ(G,$.requestBytes,$.now,$.wireAccountIdByAccount?.[G.accountId]),j=Q?{...G,inputBytes:Math.max(G.inputBytes,$.requestBytes),...G.wireAccountId===void 0&&$.wireAccountIdByAccount?.[G.accountId]!==void 0?{wireAccountId:$.wireAccountIdByAccount?.[G.accountId]}:{},...$.now-G.lastSeenAt>=IZ?{lastSeenAt:$.now}:{}}:G;if(!z&&!Q)return{assignment:j,next:void 0};return{assignment:j,next:{...Z,stickyAssignments:{...Y,[X]:j},lastUpdated:Math.max($.now,Z.lastUpdated+1)}}}let U=$.choose(P0(Y,$.quotaCheckedAtByAccount,L?X:void 0));if(!U){if(!z)return{assignment:void 0,next:void 0};return{assignment:void 0,next:{...Z,stickyAssignments:Y,lastUpdated:Math.max($.now,Z.lastUpdated+1)}}}let K={accountId:U.accountId,assignedAt:$.now,lastSeenAt:$.now,inputBytes:$.requestBytes,...U.quotaCheckedAt===void 0?{}:{quotaCheckedAt:U.quotaCheckedAt},...$.wireAccountIdByAccount?.[U.accountId]===void 0?{}:{wireAccountId:$.wireAccountIdByAccount?.[U.accountId]}};return{assignment:K,next:{...Z,stickyAssignments:vZ({...Y,[X]:K},X),lastUpdated:Math.max($.now,Z.lastUpdated+1)}}}async function Z1(Z,$=T(),X){let J=R(Z.sessionId),V=(await H0($)).stickyAssignments?.[J];if(gZ(V,Z))return V;let Y;return await _(async()=>{await C($,(z)=>{let G=dZ(z,Z);return Y=G.assignment,G.next},X)}),Y}function $1(Z,$){let X=Z.stickyAssignments?.[R($.sessionId)];if(gZ(X,$))return{assignment:X,next:void 0};return dZ(Z,$)}function J1(Z,$=T(),X){let J=R(Z.sessionId),V=new Set(Z.validPinnedAccountIds);return _(async()=>{await C($,(Y)=>{let z=Date.now(),G=b(Y.stickyAssignments,X?.vaultMode??Y.vaultAccounts!==void 0?void 0:V,z),L=G?.[J];if(L&&L.assignedAt>Z.assignment.assignedAt){if(kZ(Y.stickyAssignments,G))return;return{...Y,stickyAssignments:G,lastUpdated:Math.max(z,Y.lastUpdated+1)}}let K=L!==void 0&&L.accountId===Z.assignment.accountId&&L.assignedAt===Z.assignment.assignedAt?{...Z.assignment,inputBytes:Math.max(L.inputBytes,Z.assignment.inputBytes),lastSeenAt:Math.max(L.lastSeenAt,Z.assignment.lastSeenAt)}:Z.assignment;return{...Y,stickyAssignments:vZ({...G,[J]:K},J),lastUpdated:Math.max(z,Y.lastUpdated+1)}},X)})}async function X1(Z,$=T()){let X=R(Z),J=!1;return await _(async()=>{await C($,(V)=>{let Y=V.stickyAssignments;if(Y?.[X]===void 0){J=!1;return}J=!0;let{[X]:z,...G}=Y;return{...V,...Object.keys(G).length>0?{stickyAssignments:G}:{stickyAssignments:void 0},lastUpdated:Math.max(Date.now(),V.lastUpdated+1)}})}),J}function V1(){return l}var T0=500;function _0(Z,$,X){return new Promise((J,V)=>{let Y=setTimeout(()=>J(X()),$);Y.unref?.(),Z.then((z)=>{clearTimeout(Y),J(z)},(z)=>{clearTimeout(Y),V(z)})})}function Y1(Z,$={}){let X=$.readBudgetMs??T0,J,V,Y=()=>{try{let G=eZ(Z);return`${G.ino}:${G.size}:${G.mtimeMs}`}catch{return}},z=(G)=>{if(V&&V.key===G)return V.promise;let L=Date.now(),U=Q0(Z).then((j)=>{if(!J||J.readAt<=L)J={state:j,readAt:L,key:G};return{state:j,readAt:L}}),K={key:G,promise:U};V=K;let Q=()=>{if(V===K)V=void 0};return U.then(Q,Q),U};return{get(){let G=Y();if(J&&J.key===G)return Promise.resolve({state:J.state,readAt:J.readAt});return _0(z(G),X,()=>J?{state:J.state,readAt:J.readAt}:{state:I,readAt:0})},read(){return z(Y())},refreshInBackground(){let G=Y();if(J?.key===G)return;z(G)}}}function z1(Z,$,X){let J={assignment:X};Z.delete($),Z.set($,J);while(Z.size>qZ){let V=Z.keys().next().value;if(V===void 0)break;Z.delete(V)}return J}function G1(Z,$){if($.size===0)return Z.state;let X={...Z.state.stickyAssignments},J=!1;for(let[V,Y]of $){if(Y.persistedAt!==void 0&&Z.readAt>Y.persistedAt){$.delete(V);continue}X[V]=Y.assignment,J=!0}if(!J)return Z.state;return{...Z.state,stickyAssignments:X}}function K1(Z){let $=Z.retryDelayMs??500,X=Z.maxRetryDelayMs??30000,J=new Map,V=new Map,Y=new Set,z=0,G=$,L,U=!1,K=()=>{if(L||U||V.size===0)return;L=setTimeout(()=>{L=void 0;let j=[...V];V.clear(),G=Math.min(G*2,X);for(let[B,D]of j){let N=J.get(B);if(N!==void 0)Q(B,D.label,D.write,N)}},G),L.unref?.()},Q=(j,B,D,N)=>{let W;try{W=D()}catch(H){W=Promise.reject(H)}W.then(()=>{if(J.get(j)!==N)return;if(J.delete(j),Y.delete(j))Z.logger.info("sidebar bookkeeping write recovered",{pid:process.pid,write:B});if(Y.size===0)G=$;Z.onWritten?.()},(H)=>{if(J.get(j)!==N)return;let O={pid:process.pid,write:B,error:H instanceof Error?H.message:String(H)};if(U){J.delete(j),Z.logger.debug("sidebar bookkeeping write dropped",O);return}if(Y.has(j))Z.logger.debug("sidebar bookkeeping write failed again",O);else Y.add(j),Z.logger.warn("sidebar bookkeeping write failed; retrying in the background",O);V.set(j,{label:B,write:D}),K()})};return{enqueue(j,B,D){z+=1,J.set(j,z),V.delete(j),Q(j,B,D,z)},cancel(j){J.delete(j),V.delete(j),Y.delete(j)},stop(){if(U=!0,L)clearTimeout(L);L=void 0,V.clear()}}}function R0(Z){let $=Z.activeId;if(Z.vaultAccounts!==void 0){let X=i(Z).filter((V)=>V.enabled&&V.routable!==!1),J=X.find((V)=>V.id===$)??X[0];return J?{id:J.id,name:J.label??J.id,quota:J.quota,killed:J.killed}:{id:"vault",name:"vault",quota:null,killed:!1}}if($&&$!=="main"){let X=Z.fallbacks.find((J)=>J.enabled&&J.id===$);if(X)return{id:X.id,name:X.label??X.id,quota:X.quota,killed:X.killed}}return{id:"main",name:"main",quota:Z.main.quota,killed:Z.main.killed}}function lZ(Z,$=Date.now()){if(!Z)return;return TZ({limits:y.flatMap((X)=>{let J=Z[X];return J?[{kind:"reading",scope:"all",label:X,usedPercent:J.usedPercent,checkedAt:J.checkedAt??(P(J.usedPercent)?Z.checkedAt:void 0)??$,windowMinutes:J.windowMinutes,resetsAt:J.resetsAt}]:[]}),...Z.spendControl?{budget:{...Z.spendControl,kind:"reading",checkedAt:Z.checkedAt??$}}:{}})}function j1(Z,$=Date.now()){let X=Z?.primary?.usedPercent??null,J=Z?.secondary?.usedPercent??null,V=lZ(Z,$);return{primaryUsedPercent:X,secondaryUsedPercent:J,text:!V||V.limits.length===0&&!V.budget?null:u(V,{now:$,form:"compact"})}}function uZ(Z){return Z.route==="sticky-balanced"?"roster":CZ(Z.route)}function L1(Z,$={}){let X=$.now??Date.now(),J=R0(Z).id;return(Z.vaultAccounts!==void 0?i(Z).map((Y)=>({id:Y.id,name:Y.label??Y.id,quota:Y.quota,killed:Y.killed})):C0(Z,J,$.showFallbacks??!0)).map((Y)=>{let z=lZ(Y.quota,X),G=z&&(z.limits.length>0||z.budget)?z:void 0;return{id:Y.id,name:Y.name,killed:Y.killed,active:Y.id===J,stale:G?HZ(G,{now:X}):!1,text:G?u(G,{now:X,form:"narrow"}):null}})}function C0(Z,$,X){let J=[{id:"main",name:"main",quota:Z.main.quota,killed:Z.main.killed},...Z.fallbacks.filter((Y)=>Y.enabled&&(X||Y.id===$)).map((Y)=>({id:Y.id,name:Y.label??Y.id,quota:Y.quota,killed:Y.killed}))],V=new Map(J.map((Y)=>[Y.id,Y]));return r(J.map((Y)=>Y.id),uZ(Z),"main").flatMap((Y)=>{let z=V.get(Y);return z?[z]:[]})}function WZ(Z){let $=globalThis.Bun;return $?.stringWidth?$.stringWidth(Z):Array.from(Z).length}function B1(Z,$){if(WZ(Z)<=$)return Z;if($<1)return"";let X="",J=0;for(let V of Z){let Y=WZ(V);if(J+Y>$-1)break;X+=V,J+=Y}return`${X}…`}var F0=300000,E0=0.01,M0=1;function U1(Z,$,X){if(!Z.resetsAt||!P(Z.usedPercent))return null;let J=new Date(Z.resetsAt).getTime();if(!Number.isFinite(J))return null;let V=J-$,Y=X-V;if(Y<F0)return null;if(Y<$*E0)return null;if(Y>=$)return null;let z=Z.usedPercent,G=Math.min(Math.max(Y/$*100,0),100),L=z-G,U=Math.abs(L)<M0?"on-pace":L>0?"deficit":"reserve",K=null;if(z>0){let Q=Y*100/z,j=V+Q;if(j<J)K=new Date(j).toISOString()}return{pacePercent:G,deltaPercent:L,state:U,runsOutAt:K}}
|
|
2
|
+
export{w0 as ld,h0 as md,iZ as nd,p0 as od,o0 as pd,c as qd,qZ as rd,R as sd,T as td,I as ud,k as vd,Q0 as wd,D0 as xd,jZ as yd,fZ as zd,SZ as Ad,AZ as Bd,q as Cd,N0 as Dd,i0 as Ed,yZ as Fd,b as Gd,a0 as Hd,s0 as Id,n0 as Jd,t0 as Kd,e0 as Ld,dZ as Md,Z1 as Nd,$1 as Od,J1 as Pd,X1 as Qd,V1 as Rd,T0 as Sd,_0 as Td,Y1 as Ud,z1 as Vd,G1 as Wd,K1 as Xd,R0 as Yd,lZ as Zd,j1 as _d,L1 as $d,WZ as ae,B1 as be,U1 as ce};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{Xc as X,Zc as V}from"./index-
|
|
1
|
+
import{Xc as X,Zc as V}from"./index-9kges8jy.js";import{randomUUID as Z}from"node:crypto";import{chmod as $,mkdir as G,readFile as H,rename as L,rm as T,stat as f,writeFile as g}from"node:fs/promises";import{dirname as k,resolve as w}from"node:path";var x="(no OpenCode 1 logins on this machine)";function C(b=process.env){return X(b)}async function Q(b){let z;try{z=await H(b,"utf8")}catch(q){if(q.code==="ENOENT")return;throw q}let j=JSON.parse(z);if(!j||typeof j!=="object"||Array.isArray(j))throw Error(`${b} does not hold a JSON object`);return j}function R(b){return b===void 0?void 0:JSON.stringify(b)}async function D(b){try{return(await f(b)).mode&511}catch(z){if(z.code==="ENOENT")return;throw z}}function _(b=C()){let z=new Map;return{path:w(b),async get(j){let q=(await Q(b))?.[j.path.id];return z.set(j.path.id,R(q)),q},async set(j){let q=j.path.id,W=await D(b),J=await Q(b)??{};if(!z.has(q)||z.get(q)!==R(J[q]))throw new V;J[q]=j.body,await G(k(b),{recursive:!0});let B=`${b}.${Z()}.tmp`;try{await g(B,`${JSON.stringify(J,null,2)}
|
|
2
2
|
`,{mode:W??384}),await $(B,W??384),await L(B,b)}catch(Y){throw await T(B,{force:!0}).catch(()=>{}),Y}return z.set(q,R(j.body)),!0},async all(){let j=await Q(b);if(!j||Object.keys(j).length===0)return{[x]:!0};return j}}}
|
|
3
3
|
export{_ as c};
|