switchboard-router 0.9.2 → 0.9.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/app/.next/static/chunks/{1321-4de88db4bd94a23c.js → 1321-6bd6f91d24e9863e.js} +1 -1
- package/app/.next/static/chunks/1330-56405eca78b12fee.js +7 -0
- package/app/{.next-cli-build/static/chunks/3531-936a1e7912d9876c.js → .next/static/chunks/3531-eb5d385c954b3765.js} +7 -7
- package/app/.next/static/chunks/app/(dashboard)/dashboard/agent-library/page-cf3bc192f7a27304.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/basic-chat/page-0e1d54e59ac767a1.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/[toolId]/{page-d7205b7328b3fed1.js → page-af0d85c06970853b.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/{page-d0b6efe01e687aec.js → page-2cfc2352bc42d9b8.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-62cd36ee99eaa630.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/routing/page-0b02e9a2f1cc6e43.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/console-log/page-ded6ec41e583b3b3.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-ca47b09e6ed6ae7b.js +16 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/{page-772f246688672d59.js → page-78d098f14f8cff05.js} +8 -8
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-d1654fba27199492.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/combo/[id]/{page-8554ba79c854167f.js → page-ff13a39fb7744f5e.js} +3 -3
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/page-919f3eec8dfc9b6e.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-db19da41661d630b.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/mitm/{page-8779ff2bc755ba78.js → page-309b09a142a2995d.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/page-86cd6523dcd61f1b.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/profile/{page-d32871b974f7e72f.js → page-ae6cf9ce7ac84eb7.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-d8610d9b77a2cae4.js → page-97e0f7067cab0724.js} +3 -3
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/new/page-413b59dd764a1563.js +1 -0
- package/app/{.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-555f079cdf31bbf6.js → .next/static/chunks/app/(dashboard)/dashboard/providers/page-31212a5a4a9825b0.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/pxpipe/page-1805f993834a1adb.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/quota/page-798a65a8c4d2708a.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/skills/[id]/page-aba614778bfe50ad.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/skills/page-b1e9603ce7be0155.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/token-saver/page-1711a424a8dcad0e.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/translator/page-0c7b901caf8614b9.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-b085086e6c5b9387.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/{layout-62b4e2cdf745f8d0.js → layout-59baac68c7aedd25.js} +1 -1
- package/app/.next/static/css/c5928b380ef8a163.css +1 -0
- package/app/.next-cli-build/BUILD_ID +1 -1
- package/app/.next-cli-build/app-path-routes-manifest.json +6 -6
- package/app/.next-cli-build/build-manifest.json +2 -2
- package/app/.next-cli-build/prerender-manifest.json +3 -3
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/agent-library/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/agent-library/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js +15 -2
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error.html +1 -1
- package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_not-found.html +1 -1
- package/app/.next-cli-build/server/app/_not-found.rsc +4 -4
- package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/aider-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +5 -5
- package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js +3 -3
- package/app/.next-cli-build/server/app/api/cli-tools/grok-settings/route.js +3 -3
- package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +3 -3
- package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/messages/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/info/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1beta/models/route.js +1 -1
- package/app/.next-cli-build/server/app/api/version/route.js +1 -1
- package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/callback.html +1 -1
- package/app/.next-cli-build/server/app/callback.rsc +4 -4
- package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +4 -4
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/index.html +1 -1
- package/app/.next-cli-build/server/app/index.rsc +4 -4
- package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/landing.html +1 -1
- package/app/.next-cli-build/server/app/landing.rsc +4 -4
- package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/login.html +1 -1
- package/app/.next-cli-build/server/app/login.rsc +4 -4
- package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app-paths-manifest.json +6 -6
- package/app/.next-cli-build/server/chunks/1350.js +1 -1
- package/app/.next-cli-build/server/chunks/194.js +1 -1
- package/app/.next-cli-build/server/chunks/6395.js +1 -1
- package/app/.next-cli-build/server/chunks/6406.js +1 -1
- package/app/.next-cli-build/server/chunks/646.js +1 -1
- package/app/.next-cli-build/server/chunks/6985.js +1 -1
- package/app/.next-cli-build/server/chunks/7454.js +1 -1
- package/app/.next-cli-build/server/chunks/869.js +1 -1
- package/app/.next-cli-build/server/chunks/8834.js +1 -1
- package/app/.next-cli-build/server/chunks/8976.js +1 -1
- package/app/.next-cli-build/server/chunks/8998.js +9 -9
- package/app/.next-cli-build/server/chunks/9261.js +6 -6
- package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
- package/app/.next-cli-build/server/pages/404.html +1 -1
- package/app/.next-cli-build/server/pages/500.html +1 -1
- package/app/.next-cli-build/server/server-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/server-reference-manifest.json +1 -1
- package/app/.next-cli-build/static/chunks/{1321-4de88db4bd94a23c.js → 1321-6bd6f91d24e9863e.js} +1 -1
- package/app/.next-cli-build/static/chunks/1330-56405eca78b12fee.js +7 -0
- package/app/{.next/static/chunks/3531-936a1e7912d9876c.js → .next-cli-build/static/chunks/3531-eb5d385c954b3765.js} +7 -7
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/agent-library/page-cf3bc192f7a27304.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/basic-chat/page-0e1d54e59ac767a1.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/[toolId]/{page-d7205b7328b3fed1.js → page-af0d85c06970853b.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/{page-d0b6efe01e687aec.js → page-2cfc2352bc42d9b8.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/page-62cd36ee99eaa630.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/routing/page-0b02e9a2f1cc6e43.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/console-log/page-ded6ec41e583b3b3.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/endpoint/page-ca47b09e6ed6ae7b.js +16 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/{page-772f246688672d59.js → page-78d098f14f8cff05.js} +8 -8
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-d1654fba27199492.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/combo/[id]/{page-8554ba79c854167f.js → page-ff13a39fb7744f5e.js} +3 -3
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/page-919f3eec8dfc9b6e.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-db19da41661d630b.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/mitm/{page-8779ff2bc755ba78.js → page-309b09a142a2995d.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/page-86cd6523dcd61f1b.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/profile/{page-d32871b974f7e72f.js → page-ae6cf9ce7ac84eb7.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-d8610d9b77a2cae4.js → page-97e0f7067cab0724.js} +3 -3
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/new/page-413b59dd764a1563.js +1 -0
- package/app/{.next/static/chunks/app/(dashboard)/dashboard/providers/page-555f079cdf31bbf6.js → .next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-31212a5a4a9825b0.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/pxpipe/page-1805f993834a1adb.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/page-798a65a8c4d2708a.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/[id]/page-aba614778bfe50ad.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/page-b1e9603ce7be0155.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/token-saver/page-1711a424a8dcad0e.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/translator/page-0c7b901caf8614b9.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/usage/page-b085086e6c5b9387.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/{layout-62b4e2cdf745f8d0.js → layout-59baac68c7aedd25.js} +1 -1
- package/app/.next-cli-build/static/css/c5928b380ef8a163.css +1 -0
- package/app/open-sse/identity/tls/bin/darwin/arm64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/darwin/x64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/linux/arm64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/linux/x64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/win32/arm64/switchboard-claude-tls.exe +0 -0
- package/app/open-sse/identity/tls/bin/win32/x64/switchboard-claude-tls.exe +0 -0
- package/app/package.json +1 -1
- package/package.json +1 -1
- package/src/cli/api/client.js +1 -1
- package/app/.next/static/chunks/5497-78bd7208dc4a083d.js +0 -7
- package/app/.next/static/chunks/app/(dashboard)/dashboard/agent-library/page-24b5a8515eee26d6.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/basic-chat/page-4ec8bfa73afe20a6.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-5cfdfdf507c8222f.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/routing/page-25629f96675ad55d.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/console-log/page-b54cd17200807e49.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-cd44cb44125275b6.js +0 -3
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-52c12af07f9a6de0.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/page-0f54c9a5e7391a77.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-cfbd3661ac75b8c5.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/page-c33d24bdadcf0c6e.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/new/page-74d56b3b7ac42546.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/pxpipe/page-bd18ad88b98cd373.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/quota/page-b3ffcc7df06a37d8.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/skills/[id]/page-56bf48ee2068208e.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/skills/page-46986a955b8c89b2.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/token-saver/page-20972a96e348f397.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/translator/page-0cc2ccbe11cc0013.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-5af5fff7d28ed91d.js +0 -1
- package/app/.next/static/css/d89fdbc0e71b454e.css +0 -1
- package/app/.next-cli-build/static/chunks/5497-78bd7208dc4a083d.js +0 -7
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/agent-library/page-24b5a8515eee26d6.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/basic-chat/page-4ec8bfa73afe20a6.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/page-5cfdfdf507c8222f.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/routing/page-25629f96675ad55d.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/console-log/page-b54cd17200807e49.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/endpoint/page-cd44cb44125275b6.js +0 -3
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-52c12af07f9a6de0.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/page-0f54c9a5e7391a77.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-cfbd3661ac75b8c5.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/page-c33d24bdadcf0c6e.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/new/page-74d56b3b7ac42546.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/pxpipe/page-bd18ad88b98cd373.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/page-b3ffcc7df06a37d8.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/[id]/page-56bf48ee2068208e.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/page-46986a955b8c89b2.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/token-saver/page-20972a96e348f397.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/translator/page-0cc2ccbe11cc0013.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/usage/page-5af5fff7d28ed91d.js +0 -1
- package/app/.next-cli-build/static/css/d89fdbc0e71b454e.css +0 -1
- /package/app/.next/static/{Fq0KReA64JGBdC8atypku → kGdbG3TEpkBeoqsRS2Mre}/_buildManifest.js +0 -0
- /package/app/.next/static/{Fq0KReA64JGBdC8atypku → kGdbG3TEpkBeoqsRS2Mre}/_ssgManifest.js +0 -0
- /package/app/.next-cli-build/static/{Fq0KReA64JGBdC8atypku → kGdbG3TEpkBeoqsRS2Mre}/_buildManifest.js +0 -0
- /package/app/.next-cli-build/static/{Fq0KReA64JGBdC8atypku → kGdbG3TEpkBeoqsRS2Mre}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{18964:(e,t,s)=>{"use strict";s.d(t,{default:()=>N});var r=s(95155),a=s(12115),l=s(14051),i=s.n(l),n=s(35497),o=s(57250),d=s(65921),c=s(90620),m=s(88105),p=s(98500),x=s.n(p),u=s(38003);let h={available:{icon:"check_circle",color:"#22c55e",label:"Available"},cooldown:{icon:"schedule",color:"#f59e0b",label:"Cooldown"},unavailable:{icon:"error",color:"#ef4444",label:"Unavailable"},unknown:{icon:"help",color:"#6b7280",label:"Unknown"}};function f(){let[e,t]=(0,a.useState)(null),[s,l]=(0,a.useState)(!0),[i,o]=(0,a.useState)(!1),[c,m]=(0,a.useState)(null),p=(0,a.useRef)(null),x=(0,d.i)(),u=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/availability");if(e.ok){let s=await e.json();t(s)}}catch{}finally{l(!1)}},[]);(0,a.useEffect)(()=>{u();let e=setInterval(u,3e4);return()=>clearInterval(e)},[u]),(0,a.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&o(!1)};return i&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let f=async(e,t)=>{m(`${e}:${t}`);try{(await fetch("/api/models/availability",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clearCooldown",provider:e,model:t})})).ok?(x.success(`Cooldown cleared for ${t}`),await u()):x.error("Failed to clear cooldown")}catch{x.error("Failed to clear cooldown")}finally{m(null)}};if(s)return null;let g=e?.models||[],b=0===(e?.unavailableCount||g.filter(e=>"available"!==e.status).length),y={};return g.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";y[t]||(y[t]=[]),y[t].push(e)}),(0,r.jsx)("div",{className:"relative",ref:p,children:i&&(0,r.jsxs)("div",{className:"absolute top-full right-0 mt-2 w-80 bg-surface border border-border rounded-xl shadow-2xl z-50 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:b?"#22c55e":"#f59e0b"},children:b?"verified":"warning"}),(0,r.jsx)("span",{className:"text-sm font-semibold text-text-main",children:"Model Status"})]}),(0,r.jsx)("button",{onClick:u,className:"p-1 rounded-lg hover:bg-surface text-text-muted hover:text-text-main transition-colors",title:"Refresh",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]}),(0,r.jsx)("div",{className:"px-4 py-3 max-h-60 overflow-y-auto",children:b?(0,r.jsx)("p",{className:"text-sm text-text-muted text-center py-2",children:"All models are responding normally."}):(0,r.jsx)("div",{className:"flex flex-col gap-2.5",children:Object.entries(y).map(([e,t])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-text-main mb-1.5 capitalize",children:e}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:t.map(e=>{let t=h[e.status]||h.unknown,s=c===`${e.provider}:${e.model}`;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-surface/30",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",style:{color:t.color},children:t.icon}),(0,r.jsx)("span",{className:"font-mono text-xs text-text-main truncate",children:e.model})]}),"cooldown"===e.status&&(0,r.jsx)(n.$n,{size:"sm",variant:"ghost",onClick:()=>f(e.provider,e.model),disabled:s,className:"text-[10px] px-1.5! py-0.5! ml-2",children:s?"...":"Clear"})]},`${e.provider}-${e.model}`)})})]},e))})})]})})}var g=s(78559);let b={openai:{title:"Add OpenAI Compatible",type:"openai-compatible",defaultBaseUrl:"https://api.openai.com/v1",namePlaceholder:"My LiteLLM / OpenRouter / vLLM",baseUrlHint:"Base URL ending in /v1 for your OpenAI-compatible API.",modelIdPlaceholder:"e.g. gpt-4, claude-3-opus",errorLabel:"OpenAI Compatible",hasApiType:!0},anthropic:{title:"Add Anthropic Compatible",type:"anthropic-compatible",defaultBaseUrl:"https://api.anthropic.com/v1",namePlaceholder:"My Claude proxy",baseUrlHint:"Base URL ending in /v1. /messages is appended automatically.",modelIdPlaceholder:"e.g. claude-3-opus",errorLabel:"Anthropic Compatible",hasApiType:!1}},y=[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}];function v({variant:e,isOpen:t,onClose:s,onCreated:l}){let i=b[e],o=()=>({name:"",...i.hasApiType?{apiType:"chat"}:{},baseUrl:i.defaultBaseUrl}),[d,c]=(0,a.useState)(o),[m,p]=(0,a.useState)(!1),[x,u]=(0,a.useState)(""),[h,f]=(0,a.useState)(""),[j,N]=(0,a.useState)(""),[w,k]=(0,a.useState)(!1),[C,T]=(0,a.useState)(null),A=function(e){try{return["http:","https:"].includes(new URL(e).protocol)}catch{return!1}}(d.baseUrl.trim());(0,a.useEffect)(()=>{t&&(c(o()),u(""),f(""),N(""),T(null))},[t,e]),(0,a.useEffect)(()=>{i.hasApiType&&t&&c(e=>({...e,baseUrl:i.defaultBaseUrl}))},[d.apiType]);let I=async()=>{if(!d.name.trim()||!A)return void u("Enter a valid http:// or https:// base URL");p(!0),u("");try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d.name.trim(),...i.hasApiType?{apiType:d.apiType}:{},baseUrl:d.baseUrl.trim(),type:i.type})}),t=await e.json();e.ok?(l(t.node),c(o()),f(""),T(null)):u(t.error||"Failed to create provider")}catch(e){(0,g.s)(`Error creating ${i.errorLabel} node:`,e),u("Network error")}finally{p(!1)}},E=async()=>{k(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:d.baseUrl,apiKey:h,type:i.type,modelId:j.trim()||void 0})}),t=await e.json();T(t)}catch{T({valid:!1,error:"Network error"})}finally{k(!1)}};return(0,r.jsx)(n.aF,{isOpen:t,title:i.title,onClose:s,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(n.pd,{label:"Name",value:d.name,onChange:e=>c({...d,name:e.target.value}),placeholder:i.namePlaceholder,hint:"Friendly label (e.g. Work LiteLLM)."}),i.hasApiType&&(0,r.jsx)(n.l6,{label:"API Type",options:y,value:d.apiType,onChange:e=>c({...d,apiType:e.target.value})}),(0,r.jsx)(n.pd,{label:"Base URL",value:d.baseUrl,onChange:e=>c({...d,baseUrl:e.target.value}),placeholder:i.defaultBaseUrl,hint:i.baseUrlHint}),(0,r.jsx)(n.pd,{label:"API Key (for Check)",type:"password",autoComplete:"off",value:h,onChange:e=>f(e.target.value)}),(0,r.jsx)(n.pd,{label:"Model ID (optional)",value:j,onChange:e=>N(e.target.value),placeholder:i.modelIdPlaceholder,hint:"If the provider has no /models endpoint, enter a model ID to test chat/completions."}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)(n.$n,{onClick:E,disabled:!h||w||!A,variant:"secondary",className:"w-full sm:w-auto",children:w?"Checking...":"Check"}),(()=>{if(!C)return null;let{valid:e,error:t,method:s}=C;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===s&&(0,r.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),x?(0,r.jsx)("p",{className:"text-sm text-red-500",children:x}):null,(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,r.jsx)(n.$n,{onClick:I,fullWidth:!0,disabled:!d.name.trim()||!A||m,children:m?"Creating...":"Create"}),(0,r.jsx)(n.$n,{onClick:s,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function j(e,t,s){let a=[];if(e>0&&a.push((0,r.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[e," Connected"]},"connected")),t>0){let e=s?`${t} Error (${s})`:`${t} Error`;a.push((0,r.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:e},"error"))}return 0===a.length?(0,r.jsx)("span",{className:"text-text-muted",children:"No connections"}):a}function N({initialData:e}){let[t,s]=(0,a.useState)(e?.connections||[]),[l,i]=(0,a.useState)(e?.nodes||[]),[o,p]=(0,a.useState)(!e),[x,h]=(0,a.useState)(!1),[g,b]=(0,a.useState)(!1),[y,j]=(0,a.useState)(!1),[T,A]=(0,a.useState)(!1),[I,E]=(0,a.useState)(null),[$,R]=(0,a.useState)(null),O=(0,d.i)(),S=(0,u.C)(e=>e.query),P=(0,u.C)(e=>e.register),U=(0,u.C)(e=>e.unregister);(0,a.useEffect)(()=>(P("Search providers..."),()=>U()),[P,U]);let _=e=>!S.trim()||e.toLowerCase().includes(S.trim().toLowerCase()),z=(e,t)=>[...e].sort(([e,s],[r,a])=>{let l=s.priority??999,i=a.priority??999;if(l!==i)return l-i;let n=M(e,t),o=M(r,t),d=+(n.connected>0),c=+(o.connected>0);return d!==c?c-d:(s.name||"").localeCompare(a.name||"")}),L=(0,a.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch("/api/providers"),fetch("/api/provider-nodes")]);if(!e.ok||!t.ok)throw Error("Failed to fetch provider data");let r=await e.json(),a=await t.json();e.ok&&s(r.connections||[]),t.ok&&i(a.nodes||[])}catch(e){O.error("Failed to fetch provider data")}finally{p(!1)}},[O]);(0,a.useEffect)(()=>{e?.connections?p(!1):L()},[e,L]);let M=(e,s)=>{let r=Array.isArray(s)?s:[s],a=t.filter(t=>t.provider===e&&r.includes(t.authType)),l=e=>{let t=Object.entries(e).some(([e,t])=>e.startsWith("modelLock_")&&t&&new Date(t).getTime()>Date.now());return"unavailable"!==e.testStatus||t?e.testStatus:"active"},i=a.filter(e=>{let t=l(e);return"active"===t||"success"===t}).length,n=a.filter(e=>{let t=l(e);return"error"===t||"expired"===t||"unavailable"===t}),o=n.length,d=a.length,c=d>0&&a.every(e=>!1===e.isActive),m=n.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:i,error:o,total:d,errorCode:m?function(e){if(!e)return null;let t=e.lastErrorType;if("runtime_error"===t)return"RUNTIME";if("upstream_auth_error"===t||"auth_missing"===t||"token_refresh_failed"===t||"token_expired"===t)return"AUTH";if("upstream_rate_limited"===t)return"429";if("upstream_unavailable"===t)return"5XX";if("network_error"===t)return"NET";let s=Number(e.errorCode);if(Number.isFinite(s)&&s>=400)return String(s);let r=function(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}(e.lastError);if("401"===r||"403"===r)return"AUTH";if(r&&"ERR"!==r)return r;let a=(e.lastError||"").toLowerCase();return a.includes("runtime")||a.includes("not runnable")||a.includes("not installed")?"RUNTIME":a.includes("invalid api key")||a.includes("token invalid")||a.includes("revoked")||a.includes("unauthorized")?"AUTH":"ERR"}(m):null,errorTime:m?.lastErrorAt?function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let s=Math.floor(t/60);if(s<24)return`${s}h ago`;let r=Math.floor(s/24);return`${r}d ago`}(m.lastErrorAt):null,allDisabled:c}},q=async(e,r,a)=>{let l=Array.isArray(r)?r:[r],i=t=>t.provider===e&&l.includes(t.authType),n=t.filter(i);s(e=>e.map(e=>i(e)?{...e,isActive:a}:e)),await Promise.allSettled(n.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:a})})))},F=async(e,t=null)=>{if(!I){E("provider"===e?t:e),R(null);try{let s=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),r=await s.json();if(R(r),r.summary){let{passed:e,failed:t,total:s}=r.summary;0===t?O.success(`All ${s} tests passed`):O.warning(`${e}/${s} passed, ${t} failed`)}}catch(e){R({error:"Test request failed"}),O.error("Provider test failed")}finally{E(null)}}},D=l.filter(e=>"openai-compatible"===e.type).map(e=>({id:e.id,name:e.name||"OpenAI Compatible",color:"#10A37F",textIcon:"OC",apiType:e.apiType})).filter(e=>_(e.name)),B=l.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"})).filter(e=>_(e.name)),K=z(Object.entries(c.zN).filter(([,e])=>!e.hidden&&_(e.name)),"oauth"),H=Object.entries(m.IS).filter(([,e])=>!e.hidden&&_(e.name)).sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),J=z(Object.entries(m.nJ).filter(([,e])=>!e.hidden&&_(e.name)&&(e.serviceKinds??["llm"]).includes("llm")),"freeTier").sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),W=Object.entries(c.fg).filter(([,e])=>!e.hidden&&(e.serviceKinds??["llm"]).includes("llm")&&_(e.name)).sort(([e,t],[s,r])=>{let a=M(e,"apikey").total>0?0:1,l=M(s,"apikey").total>0?0:1;return a!==l?a-l:(t.name||"").localeCompare(r.name||"")}),Q=!!S.trim(),X=Q||x?W:W.slice(0,20),Z=W.length-20;if(o)return(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsx)(n.Qv,{}),(0,r.jsx)(n.Qv,{})]});let V=!S.trim()||K.length>0||H.length>0||J.length>0||W.length>0||D.length>0||B.length>0;return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[!V&&(0,r.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"search_off"}),(0,r.jsx)("p",{className:"text-text-muted text-sm",children:"No providers match your search"})]}),K.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"OAuth Providers"}),(0,r.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,r.jsx)(f,{}),(0,r.jsxs)("button",{onClick:()=>F("oauth"),disabled:!!I,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"oauth"===I?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all OAuth connections","aria-label":"Test all OAuth connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"oauth"===I?" animate-spin":""}`,children:"play_arrow"}),"oauth"===I?"Testing...":"Test All"]})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:K.map(([e,t])=>(0,r.jsx)(w,{providerId:e,provider:t,stats:M(e,"oauth"),authType:"oauth",onToggle:t=>q(e,"oauth",t)},e))})]}),(H.length>0||J.length>0)&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"Free Tier Providers"}),(0,r.jsxs)("button",{onClick:()=>F("free"),disabled:!!I,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"free"===I?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all Free connections","aria-label":"Test all Free provider connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"free"===I?" animate-spin":""}`,children:"play_arrow"}),"free"===I?"Testing...":"Test All"]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[H.map(([e,t])=>{let s="kiro"===e?["oauth","apikey","api_key"]:"oauth";return(0,r.jsx)(w,{providerId:e,provider:t,stats:M(e,s),authType:"free",onToggle:t=>q(e,s,t)},e)}),J.map(([e,t])=>(0,r.jsx)(k,{providerId:e,provider:t,stats:M(e,"apikey"),authType:"apikey",onToggle:t=>q(e,"apikey",t)},e))]})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"API Key Providers"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Built-in providers plus your own OpenAI- or Anthropic-compatible endpoints."})]}),(0,r.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>A(e=>!e),className:"w-full sm:w-auto",children:"Add custom provider"}),T&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",className:"fixed inset-0 z-40 cursor-default","aria-label":"Close menu",onClick:()=>A(!1)}),(0,r.jsxs)("div",{className:"absolute right-0 top-full z-50 mt-1 w-64 rounded-xl border border-border bg-surface p-1 shadow-xl",children:[(0,r.jsxs)("button",{type:"button",className:"flex w-full items-start gap-2 rounded-lg px-3 py-2.5 text-left text-sm transition-colors hover:bg-bg",onClick:()=>{A(!1),b(!0)},children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary mt-0.5",children:"api"}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block font-medium",children:"OpenAI compatible"}),(0,r.jsx)("span",{className:"block text-xs text-text-muted",children:"Any OpenAI-style base URL + API key"})]})]}),(0,r.jsxs)("button",{type:"button",className:"flex w-full items-start gap-2 rounded-lg px-3 py-2.5 text-left text-sm transition-colors hover:bg-bg",onClick:()=>{A(!1),j(!0)},children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary mt-0.5",children:"psychology"}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block font-medium",children:"Anthropic compatible"}),(0,r.jsx)("span",{className:"block text-xs text-text-muted",children:"Messages API base URL + API key"})]})]})]})]})]}),W.length>0&&(0,r.jsxs)("button",{onClick:()=>F("apikey"),disabled:!!I,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"apikey"===I?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all API Key connections","aria-label":"Test all API Key connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"apikey"===I?" animate-spin":""}`,children:"play_arrow"}),"apikey"===I?"Testing...":"Test All"]})]})]}),(D.length>0||B.length>0)&&(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted",children:"Your custom providers"}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[...D,...B].map(e=>(0,r.jsx)(k,{providerId:e.id,provider:e,stats:M(e.id,"apikey"),authType:"compatible",onToggle:t=>q(e.id,"apikey",t)},e.id))})]}),0===D.length&&0===B.length&&0===W.length&&(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3 py-8 border border-dashed border-border rounded-xl text-text-muted text-sm",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[28px]",children:"extension"}),(0,r.jsx)("p",{children:"No API key providers yet."}),(0,r.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>b(!0),children:"Add custom provider"})]}),X.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(D.length>0||B.length>0)&&(0,r.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted",children:"Built-in providers"}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:X.map(([e,t])=>(0,r.jsx)(k,{providerId:e,provider:t,stats:M(e,"apikey"),authType:"apikey",onToggle:t=>q(e,"apikey",t)},e))})]}),!Q&&!x&&Z>0&&(0,r.jsxs)("button",{onClick:()=>h(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2.5 text-sm font-medium text-primary transition-colors hover:border-primary hover:bg-primary/5",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"expand_more"}),"Show all ",W.length," providers"]})]}),(0,r.jsx)(v,{variant:"openai",isOpen:g,onClose:()=>b(!1),onCreated:e=>{i(t=>[...t,e]),b(!1)}}),(0,r.jsx)(v,{variant:"anthropic",isOpen:y,onClose:()=>j(!1),onCreated:e=>{i(t=>[...t,e]),j(!1)}}),$&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-3 pt-[6vh] sm:pt-[10vh]",onClick:()=>R(null),children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative bg-surface border border-border rounded-xl w-full max-w-[600px] max-h-[86vh] sm:max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-surface/95 backdrop-blur-sm rounded-t-xl",children:[(0,r.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,r.jsx)("button",{onClick:()=>R(null),className:"p-1 rounded-lg hover:bg-bg text-text-muted hover:text-text-main transition-colors","aria-label":"Close test results",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,r.jsx)("div",{className:"p-5",children:(0,r.jsx)(C,{results:$})})]})]})]})}function w({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:c,errorTime:m,allDisabled:p}=s,u=!!t.noAuth;return(0,r.jsx)(x(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${p?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:p?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):u?(0,r.jsx)(n.Ex,{variant:"success",size:"sm",dot:!0,children:"Ready"}):(0,r.jsxs)(r.Fragment,{children:[j(i,d,c),m&&(0,r.jsx)("span",{className:"text-text-muted",children:m})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!p)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!p,onChange:()=>{},title:p?"Enable provider":"Disable provider"})})})]})})})}function k({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:c,errorTime:p,allDisabled:u}=s,h=e.startsWith(m.JH),f=e.startsWith(m.DI);return(0,r.jsx)(x(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${u?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:h?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":f?"/providers/anthropic-m.png":`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:u?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):(0,r.jsxs)(r.Fragment,{children:[j(i,d,c),h&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),f&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"Messages"}),p&&(0,r.jsx)("span",{className:"text-text-muted",children:p})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!u)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!u,onChange:()=>{},title:u?"Enable provider":"Disable provider"})})})]})})})}function C({results:e}){if(e.error&&!e.results)return(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,r.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:s}=e,a=e.results||[];return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[t&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs mb-1 sm:gap-3",children:[(0,r.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[s]||s," Test"]}),(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,r.jsxs)("span",{className:"text-text-muted sm:ml-auto",children:[t.total," tested"]})]}),a.map((e,t)=>(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-lg bg-black/[0.03] px-3 py-2 text-xs dark:bg-white/[0.03] sm:flex-nowrap",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,r.jsxs)("div",{className:"min-w-0 flex-[1_1_160px]",children:[(0,r.jsx)("span",{className:"block truncate font-medium sm:inline",children:e.connectionName}),(0,r.jsxs)("span",{className:"block truncate text-text-muted sm:ml-1.5 sm:inline",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,r.jsxs)("span",{className:"shrink-0 text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,r.jsx)("span",{className:`shrink-0 text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?"OK":e.diagnosis?.type||"ERROR"})]},e.connectionId||t)),0===a.length&&(0,r.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}v.propTypes={variant:i().oneOf(["openai","anthropic"]).isRequired,isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},w.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},k.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string,apiType:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},C.propTypes={results:i().shape({mode:i().string,results:i().array,summary:i().shape({total:i().number,passed:i().number,failed:i().number}),error:i().string}).isRequired}},93979:(e,t,s)=>{Promise.resolve().then(s.bind(s,18964))}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,5497,8441,3794,7358],()=>e(e.s=93979)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{18964:(e,t,s)=>{"use strict";s.d(t,{default:()=>N});var r=s(95155),a=s(12115),l=s(14051),i=s.n(l),n=s(35497),o=s(57250),d=s(65921),c=s(90620),m=s(88105),p=s(98500),x=s.n(p),u=s(38003);let h={available:{icon:"check_circle",color:"#22c55e",label:"Available"},cooldown:{icon:"schedule",color:"#f59e0b",label:"Cooldown"},unavailable:{icon:"error",color:"#ef4444",label:"Unavailable"},unknown:{icon:"help",color:"#6b7280",label:"Unknown"}};function f(){let[e,t]=(0,a.useState)(null),[s,l]=(0,a.useState)(!0),[i,o]=(0,a.useState)(!1),[c,m]=(0,a.useState)(null),p=(0,a.useRef)(null),x=(0,d.i)(),u=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/availability");if(e.ok){let s=await e.json();t(s)}}catch{}finally{l(!1)}},[]);(0,a.useEffect)(()=>{u();let e=setInterval(u,3e4);return()=>clearInterval(e)},[u]),(0,a.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&o(!1)};return i&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let f=async(e,t)=>{m(`${e}:${t}`);try{(await fetch("/api/models/availability",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clearCooldown",provider:e,model:t})})).ok?(x.success(`Cooldown cleared for ${t}`),await u()):x.error("Failed to clear cooldown")}catch{x.error("Failed to clear cooldown")}finally{m(null)}};if(s)return null;let g=e?.models||[],b=0===(e?.unavailableCount||g.filter(e=>"available"!==e.status).length),v={};return g.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";v[t]||(v[t]=[]),v[t].push(e)}),(0,r.jsx)("div",{className:"relative",ref:p,children:i&&(0,r.jsxs)("div",{className:"absolute top-full right-0 mt-2 w-80 bg-surface border border-border rounded-xl shadow-2xl z-50 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:b?"#22c55e":"#f59e0b"},children:b?"verified":"warning"}),(0,r.jsx)("span",{className:"text-sm font-semibold text-text-main",children:"Model Status"})]}),(0,r.jsx)("button",{onClick:u,className:"p-1 rounded-lg hover:bg-surface text-text-muted hover:text-text-main transition-colors",title:"Refresh",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]}),(0,r.jsx)("div",{className:"px-4 py-3 max-h-60 overflow-y-auto",children:b?(0,r.jsx)("p",{className:"text-sm text-text-muted text-center py-2",children:"All models are responding normally."}):(0,r.jsx)("div",{className:"flex flex-col gap-2.5",children:Object.entries(v).map(([e,t])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-text-main mb-1.5 capitalize",children:e}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:t.map(e=>{let t=h[e.status]||h.unknown,s=c===`${e.provider}:${e.model}`;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-surface/30",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",style:{color:t.color},children:t.icon}),(0,r.jsx)("span",{className:"font-mono text-xs text-text-main truncate",children:e.model})]}),"cooldown"===e.status&&(0,r.jsx)(n.$n,{size:"sm",variant:"ghost",onClick:()=>f(e.provider,e.model),disabled:s,className:"text-[10px] px-1.5! py-0.5! ml-2",children:s?"...":"Clear"})]},`${e.provider}-${e.model}`)})})]},e))})})]})})}var g=s(78559);let b={openai:{title:"Add OpenAI Compatible",type:"openai-compatible",defaultBaseUrl:"https://api.openai.com/v1",namePlaceholder:"My LiteLLM / OpenRouter / vLLM",baseUrlHint:"Base URL ending in /v1 for your OpenAI-compatible API.",modelIdPlaceholder:"e.g. gpt-4, claude-3-opus",errorLabel:"OpenAI Compatible",hasApiType:!0},anthropic:{title:"Add Anthropic Compatible",type:"anthropic-compatible",defaultBaseUrl:"https://api.anthropic.com/v1",namePlaceholder:"My Claude proxy",baseUrlHint:"Base URL ending in /v1. /messages is appended automatically.",modelIdPlaceholder:"e.g. claude-3-opus",errorLabel:"Anthropic Compatible",hasApiType:!1}},v=[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}];function y({variant:e,isOpen:t,onClose:s,onCreated:l}){let i=b[e],o=()=>({name:"",...i.hasApiType?{apiType:"chat"}:{},baseUrl:i.defaultBaseUrl}),[d,c]=(0,a.useState)(o),[m,p]=(0,a.useState)(!1),[x,u]=(0,a.useState)(""),[h,f]=(0,a.useState)(""),[j,N]=(0,a.useState)(""),[w,k]=(0,a.useState)(!1),[C,T]=(0,a.useState)(null),A=function(e){try{return["http:","https:"].includes(new URL(e).protocol)}catch{return!1}}(d.baseUrl.trim());(0,a.useEffect)(()=>{t&&(c(o()),u(""),f(""),N(""),T(null))},[t,e]),(0,a.useEffect)(()=>{i.hasApiType&&t&&c(e=>({...e,baseUrl:i.defaultBaseUrl}))},[d.apiType]);let I=async()=>{if(!d.name.trim()||!A)return void u("Enter a valid http:// or https:// base URL");p(!0),u("");try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d.name.trim(),...i.hasApiType?{apiType:d.apiType}:{},baseUrl:d.baseUrl.trim(),type:i.type})}),t=await e.json();e.ok?(l(t.node),c(o()),f(""),T(null)):u(t.error||"Failed to create provider")}catch(e){(0,g.s)(`Error creating ${i.errorLabel} node:`,e),u("Network error")}finally{p(!1)}},E=async()=>{k(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:d.baseUrl,apiKey:h,type:i.type,modelId:j.trim()||void 0})}),t=await e.json();T(t)}catch{T({valid:!1,error:"Network error"})}finally{k(!1)}};return(0,r.jsx)(n.aF,{isOpen:t,title:i.title,onClose:s,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(n.pd,{label:"Name",value:d.name,onChange:e=>c({...d,name:e.target.value}),placeholder:i.namePlaceholder,hint:"Friendly label (e.g. Work LiteLLM)."}),i.hasApiType&&(0,r.jsx)(n.l6,{label:"API Type",options:v,value:d.apiType,onChange:e=>c({...d,apiType:e.target.value})}),(0,r.jsx)(n.pd,{label:"Base URL",value:d.baseUrl,onChange:e=>c({...d,baseUrl:e.target.value}),placeholder:i.defaultBaseUrl,hint:i.baseUrlHint}),(0,r.jsx)(n.pd,{label:"API Key (for Check)",type:"password",autoComplete:"off",value:h,onChange:e=>f(e.target.value)}),(0,r.jsx)(n.pd,{label:"Model ID (optional)",value:j,onChange:e=>N(e.target.value),placeholder:i.modelIdPlaceholder,hint:"If the provider has no /models endpoint, enter a model ID to test chat/completions."}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)(n.$n,{onClick:E,disabled:!h||w||!A,variant:"secondary",className:"w-full sm:w-auto",children:w?"Checking...":"Check"}),(()=>{if(!C)return null;let{valid:e,error:t,method:s}=C;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===s&&(0,r.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),x?(0,r.jsx)("p",{className:"text-sm text-red-500",children:x}):null,(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,r.jsx)(n.$n,{onClick:I,fullWidth:!0,disabled:!d.name.trim()||!A||m,children:m?"Creating...":"Create"}),(0,r.jsx)(n.$n,{onClick:s,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function j(e,t,s){let a=[];if(e>0&&a.push((0,r.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[e," Connected"]},"connected")),t>0){let e=s?`${t} Error (${s})`:`${t} Error`;a.push((0,r.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:e},"error"))}return 0===a.length?(0,r.jsx)("span",{className:"text-text-muted",children:"No connections"}):a}function N({initialData:e}){let[t,s]=(0,a.useState)(e?.connections||[]),[l,i]=(0,a.useState)(e?.nodes||[]),[o,p]=(0,a.useState)(!e),[x,h]=(0,a.useState)(!1),[g,b]=(0,a.useState)(!1),[v,j]=(0,a.useState)(!1),[T,A]=(0,a.useState)(!1),[I,E]=(0,a.useState)(null),[$,R]=(0,a.useState)(null),S=(0,d.i)(),O=(0,u.C)(e=>e.query),P=(0,u.C)(e=>e.register),U=(0,u.C)(e=>e.unregister);(0,a.useEffect)(()=>(P("Search providers..."),()=>U()),[P,U]);let _=e=>!O.trim()||e.toLowerCase().includes(O.trim().toLowerCase()),z=(e,t)=>[...e].sort(([e,s],[r,a])=>{let l=s.priority??999,i=a.priority??999;if(l!==i)return l-i;let n=M(e,t),o=M(r,t),d=+(n.connected>0),c=+(o.connected>0);return d!==c?c-d:(s.name||"").localeCompare(a.name||"")}),L=(0,a.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch("/api/providers"),fetch("/api/provider-nodes")]);if(!e.ok||!t.ok)throw Error("Failed to fetch provider data");let r=await e.json(),a=await t.json();e.ok&&s(r.connections||[]),t.ok&&i(a.nodes||[])}catch(e){S.error("Failed to fetch provider data")}finally{p(!1)}},[S]);(0,a.useEffect)(()=>{e?.connections?p(!1):L()},[e,L]);let M=(e,s)=>{let r=Array.isArray(s)?s:[s],a=t.filter(t=>t.provider===e&&r.includes(t.authType)),l=e=>{let t=Object.entries(e).some(([e,t])=>e.startsWith("modelLock_")&&t&&new Date(t).getTime()>Date.now());return"unavailable"!==e.testStatus||t?e.testStatus:"active"},i=a.filter(e=>{let t=l(e);return"active"===t||"success"===t}).length,n=a.filter(e=>{let t=l(e);return"error"===t||"expired"===t||"unavailable"===t}),o=n.length,d=a.length,c=d>0&&a.every(e=>!1===e.isActive),m=n.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:i,error:o,total:d,errorCode:m?function(e){if(!e)return null;let t=e.lastErrorType;if("runtime_error"===t)return"RUNTIME";if("upstream_auth_error"===t||"auth_missing"===t||"token_refresh_failed"===t||"token_expired"===t)return"AUTH";if("upstream_rate_limited"===t)return"429";if("upstream_unavailable"===t)return"5XX";if("network_error"===t)return"NET";let s=Number(e.errorCode);if(Number.isFinite(s)&&s>=400)return String(s);let r=function(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}(e.lastError);if("401"===r||"403"===r)return"AUTH";if(r&&"ERR"!==r)return r;let a=(e.lastError||"").toLowerCase();return a.includes("runtime")||a.includes("not runnable")||a.includes("not installed")?"RUNTIME":a.includes("invalid api key")||a.includes("token invalid")||a.includes("revoked")||a.includes("unauthorized")?"AUTH":"ERR"}(m):null,errorTime:m?.lastErrorAt?function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let s=Math.floor(t/60);if(s<24)return`${s}h ago`;let r=Math.floor(s/24);return`${r}d ago`}(m.lastErrorAt):null,allDisabled:c}},F=async(e,r,a)=>{let l=Array.isArray(r)?r:[r],i=t=>t.provider===e&&l.includes(t.authType),n=t.filter(i);s(e=>e.map(e=>i(e)?{...e,isActive:a}:e)),await Promise.allSettled(n.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:a})})))},q=async(e,t=null)=>{if(!I){E("provider"===e?t:e),R(null);try{let s=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),r=await s.json();if(R(r),r.summary){let{passed:e,failed:t,total:s}=r.summary;0===t?S.success(`All ${s} tests passed`):S.warning(`${e}/${s} passed, ${t} failed`)}}catch(e){R({error:"Test request failed"}),S.error("Provider test failed")}finally{E(null)}}},D=l.filter(e=>"openai-compatible"===e.type).map(e=>({id:e.id,name:e.name||"OpenAI Compatible",color:"#10A37F",textIcon:"OC",apiType:e.apiType})).filter(e=>_(e.name)),K=l.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"})).filter(e=>_(e.name)),B=z(Object.entries(c.zN).filter(([,e])=>!e.hidden&&_(e.name)),"oauth"),H=Object.entries(m.IS).filter(([,e])=>!e.hidden&&_(e.name)).sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),J=z(Object.entries(m.nJ).filter(([,e])=>!e.hidden&&_(e.name)&&(e.serviceKinds??["llm"]).includes("llm")),"freeTier").sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),W=Object.entries(c.fg).filter(([,e])=>!e.hidden&&(e.serviceKinds??["llm"]).includes("llm")&&_(e.name)).sort(([e,t],[s,r])=>{let a=M(e,"apikey").total>0?0:1,l=M(s,"apikey").total>0?0:1;return a!==l?a-l:(t.name||"").localeCompare(r.name||"")}),Q=!!O.trim(),Z=Q||x?W:W.slice(0,20),X=W.length-20;if(o)return(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsx)(n.Qv,{}),(0,r.jsx)(n.Qv,{})]});let G=!O.trim()||B.length>0||H.length>0||J.length>0||W.length>0||D.length>0||K.length>0;return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[!G&&(0,r.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"search_off"}),(0,r.jsx)("p",{className:"text-text-muted text-sm",children:"No providers match your search"})]}),B.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"OAuth Providers"}),(0,r.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,r.jsx)(f,{}),(0,r.jsxs)("button",{onClick:()=>q("oauth"),disabled:!!I,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"oauth"===I?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all OAuth connections","aria-label":"Test all OAuth connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"oauth"===I?" animate-spin":""}`,children:"play_arrow"}),"oauth"===I?"Testing...":"Test All"]})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:B.map(([e,t])=>(0,r.jsx)(w,{providerId:e,provider:t,stats:M(e,"oauth"),authType:"oauth",onToggle:t=>F(e,"oauth",t)},e))})]}),(H.length>0||J.length>0)&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"Free Tier Providers"}),(0,r.jsxs)("button",{onClick:()=>q("free"),disabled:!!I,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"free"===I?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all Free connections","aria-label":"Test all Free provider connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"free"===I?" animate-spin":""}`,children:"play_arrow"}),"free"===I?"Testing...":"Test All"]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[H.map(([e,t])=>{let s="kiro"===e?["oauth","apikey","api_key"]:"oauth";return(0,r.jsx)(w,{providerId:e,provider:t,stats:M(e,s),authType:"free",onToggle:t=>F(e,s,t)},e)}),J.map(([e,t])=>(0,r.jsx)(k,{providerId:e,provider:t,stats:M(e,"apikey"),authType:"apikey",onToggle:t=>F(e,"apikey",t)},e))]})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"API Key Providers"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Built-in providers plus your own OpenAI- or Anthropic-compatible endpoints."})]}),(0,r.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>A(e=>!e),className:"w-full sm:w-auto",children:"Add custom provider"}),T&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",className:"fixed inset-0 z-40 cursor-default","aria-label":"Close menu",onClick:()=>A(!1)}),(0,r.jsxs)("div",{className:"absolute right-0 top-full z-50 mt-1 w-64 rounded-xl border border-border bg-surface p-1 shadow-xl",children:[(0,r.jsxs)("button",{type:"button",className:"flex w-full items-start gap-2 rounded-lg px-3 py-2.5 text-left text-sm transition-colors hover:bg-bg",onClick:()=>{A(!1),b(!0)},children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary mt-0.5",children:"api"}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block font-medium",children:"OpenAI compatible"}),(0,r.jsx)("span",{className:"block text-xs text-text-muted",children:"Any OpenAI-style base URL + API key"})]})]}),(0,r.jsxs)("button",{type:"button",className:"flex w-full items-start gap-2 rounded-lg px-3 py-2.5 text-left text-sm transition-colors hover:bg-bg",onClick:()=>{A(!1),j(!0)},children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary mt-0.5",children:"psychology"}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block font-medium",children:"Anthropic compatible"}),(0,r.jsx)("span",{className:"block text-xs text-text-muted",children:"Messages API base URL + API key"})]})]})]})]})]}),W.length>0&&(0,r.jsxs)("button",{onClick:()=>q("apikey"),disabled:!!I,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"apikey"===I?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all API Key connections","aria-label":"Test all API Key connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"apikey"===I?" animate-spin":""}`,children:"play_arrow"}),"apikey"===I?"Testing...":"Test All"]})]})]}),(D.length>0||K.length>0)&&(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted",children:"Your custom providers"}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[...D,...K].map(e=>(0,r.jsx)(k,{providerId:e.id,provider:e,stats:M(e.id,"apikey"),authType:"compatible",onToggle:t=>F(e.id,"apikey",t)},e.id))})]}),0===D.length&&0===K.length&&0===W.length&&(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3 py-8 border border-dashed border-border rounded-xl text-text-muted text-sm",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[28px]",children:"extension"}),(0,r.jsx)("p",{children:"No API key providers yet."}),(0,r.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>b(!0),children:"Add custom provider"})]}),Z.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(D.length>0||K.length>0)&&(0,r.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted",children:"Built-in providers"}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:Z.map(([e,t])=>(0,r.jsx)(k,{providerId:e,provider:t,stats:M(e,"apikey"),authType:"apikey",onToggle:t=>F(e,"apikey",t)},e))})]}),!Q&&!x&&X>0&&(0,r.jsxs)("button",{onClick:()=>h(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2.5 text-sm font-medium text-primary transition-colors hover:border-primary hover:bg-primary/5",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"expand_more"}),"Show all ",W.length," providers"]})]}),(0,r.jsx)(y,{variant:"openai",isOpen:g,onClose:()=>b(!1),onCreated:e=>{i(t=>[...t,e]),b(!1)}}),(0,r.jsx)(y,{variant:"anthropic",isOpen:v,onClose:()=>j(!1),onCreated:e=>{i(t=>[...t,e]),j(!1)}}),$&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-3 pt-[6vh] sm:pt-[10vh]",onClick:()=>R(null),children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative bg-surface border border-border rounded-xl w-full max-w-[600px] max-h-[86vh] sm:max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-surface/95 backdrop-blur-sm rounded-t-xl",children:[(0,r.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,r.jsx)("button",{onClick:()=>R(null),className:"p-1 rounded-lg hover:bg-bg text-text-muted hover:text-text-main transition-colors","aria-label":"Close test results",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,r.jsx)("div",{className:"p-5",children:(0,r.jsx)(C,{results:$})})]})]})]})}function w({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:c,errorTime:m,allDisabled:p}=s,u=!!t.noAuth;return(0,r.jsx)(x(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${p?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:p?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):u?(0,r.jsx)(n.Ex,{variant:"success",size:"sm",dot:!0,children:"Ready"}):(0,r.jsxs)(r.Fragment,{children:[j(i,d,c),m&&(0,r.jsx)("span",{className:"text-text-muted",children:m})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!p)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!p,onChange:()=>{},title:p?"Enable provider":"Disable provider"})})})]})})})}function k({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:c,errorTime:p,allDisabled:u}=s,h=e.startsWith(m.JH),f=e.startsWith(m.DI);return(0,r.jsx)(x(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${u?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:h?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":f?"/providers/anthropic-m.png":`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:u?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):(0,r.jsxs)(r.Fragment,{children:[j(i,d,c),h&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),f&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"Messages"}),p&&(0,r.jsx)("span",{className:"text-text-muted",children:p})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!u)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!u,onChange:()=>{},title:u?"Enable provider":"Disable provider"})})})]})})})}function C({results:e}){if(e.error&&!e.results)return(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,r.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:s}=e,a=e.results||[];return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[t&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs mb-1 sm:gap-3",children:[(0,r.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[s]||s," Test"]}),(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,r.jsxs)("span",{className:"text-text-muted sm:ml-auto",children:[t.total," tested"]})]}),a.map((e,t)=>(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-lg bg-black/[0.03] px-3 py-2 text-xs dark:bg-white/[0.03] sm:flex-nowrap",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,r.jsxs)("div",{className:"min-w-0 flex-[1_1_160px]",children:[(0,r.jsx)("span",{className:"block truncate font-medium sm:inline",children:e.connectionName}),(0,r.jsxs)("span",{className:"block truncate text-text-muted sm:ml-1.5 sm:inline",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,r.jsxs)("span",{className:"shrink-0 text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,r.jsx)("span",{className:`shrink-0 text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?"OK":e.diagnosis?.type||"ERROR"})]},e.connectionId||t)),0===a.length&&(0,r.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}y.propTypes={variant:i().oneOf(["openai","anthropic"]).isRequired,isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},w.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},k.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string,apiType:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},C.propTypes={results:i().shape({mode:i().string,results:i().array,summary:i().shape({total:i().number,passed:i().number,failed:i().number}),error:i().string}).isRequired}},35497:(e,t,s)=>{"use strict";s.d(t,{x0:()=>w.default,Ex:()=>d.default,$n:()=>r.default,nh:()=>I.default,Zp:()=>i.default,Qv:()=>o.CardSkeleton,CK:()=>u.default,uo:()=>n.ConfirmModal,G9:()=>v.default,wI:()=>N.default,vj:()=>j.default,vE:()=>y.default,pd:()=>a.default,Mh:()=>b.default,uR:()=>x.default,Nf:()=>h.default,aF:()=>n.default,rq:()=>p.default,gw:()=>k.default,LF:()=>m.default,Wx:()=>A.default,gM:()=>g.default,Iz:()=>C.default,l6:()=>l.default,lM:()=>c.default,m_:()=>T.default,jK:()=>f.default});var r=s(92542),a=s(11910),l=s(98),i=s(84588),n=s(81127),o=s(25086);s(56319);var d=s(56061),c=s(98542);s(38587),s(21110),s(92622),s(8823),s(92173);var m=s(90882),p=s(72908),x=s(28815),u=s(45455),h=s(28058),f=s(4809);s(21931),s(80752),s(40197);var g=s(23615);s(44736);var b=s(62899);s(94230);var v=s(30815),y=s(23936),j=s(95088),N=s(73579),w=s(96748),k=s(4823),C=s(28067),T=s(97677),A=s(51825),I=s(29366);s(76361),s(91450)},93979:(e,t,s)=>{Promise.resolve().then(s.bind(s,18964))}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,1330,8441,3794,7358],()=>e(e.s=93979)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7414],{35497:(e,t,s)=>{"use strict";s.d(t,{x0:()=>w.default,Ex:()=>o.default,$n:()=>a.default,nh:()=>C.default,Zp:()=>d.default,Qv:()=>n.CardSkeleton,CK:()=>h.default,uo:()=>i.ConfirmModal,G9:()=>b.default,wI:()=>v.default,vj:()=>y.default,vE:()=>N.default,pd:()=>l.default,Mh:()=>j.default,uR:()=>p.default,Nf:()=>u.default,aF:()=>i.default,rq:()=>m.default,gw:()=>k.default,LF:()=>c.default,Wx:()=>E.default,gM:()=>g.default,Iz:()=>S.default,l6:()=>r.default,lM:()=>x.default,m_:()=>P.default,jK:()=>f.default});var a=s(92542),l=s(11910),r=s(98),d=s(84588),i=s(81127),n=s(25086);s(56319);var o=s(56061),x=s(98542);s(38587),s(21110),s(92622),s(8823),s(92173);var c=s(90882),m=s(72908),p=s(28815),h=s(45455),u=s(28058),f=s(4809);s(21931),s(80752),s(40197);var g=s(23615);s(44736);var j=s(62899);s(94230);var b=s(30815),N=s(23936),y=s(95088),v=s(73579),w=s(96748),k=s(4823),S=s(28067),P=s(97677),E=s(51825),C=s(29366);s(76361),s(91450)},71470:(e,t,s)=>{"use strict";s.d(t,{default:()=>g});var a=s(95155),l=s(12115),r=s(21742),d=s(90639),i=s(28408),n=s(32539),o=s(59656),x=s(84420),c=s(19538),m=s(35497);let p=e=>e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e||0),h=[{id:"today",label:"Today"},{id:"yesterday",label:"Yesterday"},{id:"last7d",label:"7 days"},{id:"last30d",label:"30 days"},{id:"all",label:"All time"}],u={applied:"Prompt exceeded threshold",below_threshold:"Below size threshold",not_profitable:"Compression not profitable",below_min_chars:"Below minimum chars",below_min_tokens:"Below minimum tokens",unsupported_model:"Model not in allowlist",unsupported_format:"Non-Claude request format",timeout:"Compression timed out",transform_error:"Transform error",passthrough:"Passthrough",disabled:"Disabled",not_installed:"Not installed"};function f({label:e,value:t,sub:s,tone:l}){return(0,a.jsxs)(m.Zp,{className:"p-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted uppercase tracking-wide",children:e}),(0,a.jsx)("p",{className:`text-xl font-semibold mt-1 ${l||""}`,children:t}),s&&(0,a.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:s})]})}function g(){let[e,t]=(0,l.useState)(null),[s,g]=(0,l.useState)(null),[j,b]=(0,l.useState)(null),[N,y]=(0,l.useState)(null),[v,w]=(0,l.useState)("last7d"),[k,S]=(0,l.useState)(!0),P=(0,l.useCallback)(async()=>{S(!0);try{let[e,s,a]=await Promise.all([fetch("/api/pxpipe/status",{headers:{"Cache-Control":"no-store"}}),fetch("/api/pxpipe/stats"),fetch("/api/pxpipe/logs?limit=50")]);t(await e.json()),b(await s.json()),y(await a.json());let l=await fetch("/api/pxpipe/health",{method:"POST"});g(await l.json())}catch{}finally{S(!1)}},[]);(0,l.useEffect)(()=>{P()},[P]);let E=j?.windows?.[v],C=e?e.installed?s?.healthy?"Healthy":e.running?"Running":"Stopped":"Not installed":"—";return(0,a.jsxs)("div",{className:"space-y-6 p-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[(0,a.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"image"}),"PXPIPE Dashboard"]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("a",{href:"/dashboard/token-saver",className:"text-xs text-primary underline hover:opacity-80",children:"Token Saver settings"}),(0,a.jsx)(m.$n,{size:"sm",variant:"ghost",onClick:P,disabled:k,children:k?"Refreshing…":"Refresh"})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:[(0,a.jsx)(f,{label:"Status",value:C,tone:s?.healthy?"text-success":e?.installed?"text-warning":"text-text-muted",sub:e?.enabled?"Enabled in pipeline":"Disabled in pipeline"}),(0,a.jsx)(f,{label:"Version",value:e?.version?`v${e.version}`:"—",sub:"pxpipe-proxy"}),(0,a.jsx)(f,{label:"Uptime",value:(e=>{if(!e||e<=0)return"—";let t=Math.floor(e/6e4),s=Math.floor(t/60);return s>0?`${s}h${String(t%60).padStart(2,"0")}m`:`${t}m`})(e?.uptimeMs),sub:"module loaded"}),(0,a.jsx)(f,{label:"Requests",value:E?E.requests.toLocaleString():"—"}),(0,a.jsx)(f,{label:"Compressed",value:E?E.compressed.toLocaleString():"—",tone:"text-success"}),(0,a.jsx)(f,{label:"Bypassed",value:E?E.bypassed.toLocaleString():"—"})]}),(0,a.jsxs)(m.Zp,{className:"p-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3 mb-4",children:[(0,a.jsx)("h3",{className:"font-medium",children:"Token savings (estimated)"}),(0,a.jsx)("div",{className:"flex items-center gap-1 rounded-lg border border-border bg-bg-subtle p-1",children:h.map(e=>(0,a.jsx)("button",{onClick:()=>w(e.id),className:`px-3 py-1 rounded-md text-xs font-medium transition-colors ${v===e.id?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:e.label},e.id))})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-center",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Original tokens"}),(0,a.jsx)("p",{className:"text-lg font-semibold",children:E?p(E.tokensBeforeEst):"—"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"After PXPIPE"}),(0,a.jsx)("p",{className:"text-lg font-semibold",children:E?p(E.tokensAfterEst):"—"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Saved"}),(0,a.jsx)("p",{className:"text-lg font-semibold text-success",children:E?p(E.tokensSavedEst):"—"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Reduction"}),(0,a.jsx)("p",{className:"text-lg font-semibold text-success",children:E?`${E.savedPct}%`:"—"})]})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-3",children:["Estimates from body size before/after imaging; billed usage per request (recorded on the Usage page) remains the ground truth. Images generated:"," ",E?E.imagesGenerated.toLocaleString():"—"," \xb7 avg compression time:"," ",E?`${E.avgCompressionMs}ms`:"—"," \xb7 errors: ",E?E.errors:"—"]})]}),(0,a.jsxs)(m.Zp,{className:"p-4",children:[(0,a.jsx)("h3",{className:"font-medium mb-3",children:"Tokens saved — last 30 days"}),j?.timeline?.some(e=>e.tokensSavedEst>0)?(0,a.jsx)(r.u,{width:"100%",height:220,children:(0,a.jsxs)(d.Q,{data:j.timeline,margin:{top:4,right:8,left:0,bottom:0},children:[(0,a.jsx)("defs",{children:(0,a.jsxs)("linearGradient",{id:"gradPxpipe",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,a.jsx)("stop",{offset:"5%",stopColor:"#10b981",stopOpacity:.25}),(0,a.jsx)("stop",{offset:"95%",stopColor:"#10b981",stopOpacity:0})]})}),(0,a.jsx)(i.d,{strokeDasharray:"3 3",strokeOpacity:.2}),(0,a.jsx)(n.W,{dataKey:"date",tick:{fontSize:11},tickFormatter:e=>e.slice(5)}),(0,a.jsx)(o.h,{tick:{fontSize:11},tickFormatter:p,width:48}),(0,a.jsx)(x.m,{formatter:e=>[p(e),"Tokens saved"],labelFormatter:e=>e}),(0,a.jsx)(c.Gk,{type:"monotone",dataKey:"tokensSavedEst",stroke:"#10b981",fill:"url(#gradPxpipe)",strokeWidth:2})]})}):(0,a.jsx)("div",{className:"h-32 flex items-center justify-center text-text-muted text-sm",children:"No savings recorded yet — enable PXPIPE in the Token Saver and route a large Claude-format request."})]}),(0,a.jsxs)(m.Zp,{className:"p-4",children:[(0,a.jsx)("h3",{className:"font-medium mb-3",children:"History"}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full text-sm",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"text-left text-xs text-text-muted border-b border-border",children:[(0,a.jsx)("th",{className:"py-2 pr-3",children:"Time"}),(0,a.jsx)("th",{className:"py-2 pr-3",children:"Model"}),(0,a.jsx)("th",{className:"py-2 pr-3 text-right",children:"Original"}),(0,a.jsx)("th",{className:"py-2 pr-3 text-right",children:"Compressed"}),(0,a.jsx)("th",{className:"py-2 pr-3 text-right",children:"Saved"}),(0,a.jsx)("th",{className:"py-2 pr-3 text-right",children:"%"}),(0,a.jsx)("th",{className:"py-2 pr-3 text-right",children:"Duration"}),(0,a.jsx)("th",{className:"py-2",children:"Status"})]})}),(0,a.jsxs)("tbody",{children:[(j?.recent||[]).slice(0,50).map((e,t)=>(0,a.jsxs)("tr",{className:"border-b border-border/50",children:[(0,a.jsx)("td",{className:"py-1.5 pr-3 whitespace-nowrap text-text-muted",children:new Date(e.ts).toLocaleString()}),(0,a.jsx)("td",{className:"py-1.5 pr-3 font-mono text-xs",children:e.provider?`${e.provider}/${e.model}`:e.model||"—"}),(0,a.jsx)("td",{className:"py-1.5 pr-3 text-right font-mono text-xs",children:e.applied?p(e.tokensBeforeEst||0):"—"}),(0,a.jsx)("td",{className:"py-1.5 pr-3 text-right font-mono text-xs",children:e.applied?p(e.tokensAfterEst||0):"—"}),(0,a.jsx)("td",{className:"py-1.5 pr-3 text-right font-mono text-xs text-success",children:e.applied?p(e.tokensSavedEst||0):"—"}),(0,a.jsx)("td",{className:"py-1.5 pr-3 text-right font-mono text-xs",children:e.applied?`${e.savedPct}%`:"—"}),(0,a.jsx)("td",{className:"py-1.5 pr-3 text-right font-mono text-xs",children:null!=e.durationMs?`${e.durationMs}ms`:"—"}),(0,a.jsx)("td",{className:"py-1.5",children:(0,a.jsx)("span",{className:`text-xs px-2 py-0.5 rounded ${e.applied?"bg-success/15 text-success":"transform_error"===e.reason||"timeout"===e.reason?"bg-danger/15 text-danger":"bg-warning/15 text-warning"}`,title:e.detail||"",children:e.applied?"Compressed":u[e.reason]||e.reason})})]},`${e.ts}-${t}`)),(!j?.recent||0===j.recent.length)&&(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:8,className:"py-6 text-center text-text-muted text-sm",children:"No PXPIPE activity yet"})})]})]})})]}),(0,a.jsxs)(m.Zp,{className:"p-4",id:"logs",children:[(0,a.jsx)("h3",{className:"font-medium mb-3",children:"PXPIPE Logs"}),N?.installLog?(0,a.jsx)("pre",{className:"rounded bg-black/5 dark:bg-white/5 p-3 text-xs font-mono overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap",children:N.installLog}):(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No install log yet."})]})]})}},91710:(e,t,s)=>{Promise.resolve().then(s.bind(s,71470))}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,1330,8441,3794,7358],()=>e(e.s=91710)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3826],{17002:(e,t,r)=>{Promise.resolve().then(r.bind(r,75095)),Promise.resolve().then(r.bind(r,25086))},35497:(e,t,r)=>{"use strict";r.d(t,{x0:()=>w.default,Ex:()=>d.default,$n:()=>a.default,nh:()=>$.default,Zp:()=>l.default,Qv:()=>o.CardSkeleton,CK:()=>h.default,uo:()=>n.ConfirmModal,G9:()=>y.default,wI:()=>k.default,vj:()=>j.default,vE:()=>v.default,pd:()=>s.default,Mh:()=>f.default,uR:()=>m.default,Nf:()=>p.default,aF:()=>n.default,rq:()=>x.default,gw:()=>N.default,LF:()=>u.default,Wx:()=>A.default,gM:()=>g.default,Iz:()=>C.default,l6:()=>i.default,lM:()=>c.default,m_:()=>S.default,jK:()=>b.default});var a=r(92542),s=r(11910),i=r(98),l=r(84588),n=r(81127),o=r(25086);r(56319);var d=r(56061),c=r(98542);r(38587),r(21110),r(92622),r(8823),r(92173);var u=r(90882),x=r(72908),m=r(28815),h=r(45455),p=r(28058),b=r(4809);r(21931),r(80752),r(40197);var g=r(23615);r(44736);var f=r(62899);r(94230);var y=r(30815),v=r(23936),j=r(95088),k=r(73579),w=r(96748),N=r(4823),C=r(28067),S=r(97677),A=r(51825),$=r(29366);r(76361),r(91450)},75095:(e,t,r)=>{"use strict";r.d(t,{default:()=>I});var a=r(95155),s=r(12115),i=r(57250),l=r(97650);let n="quotaCacheData",o="quotaAutoRefresh",d=[10,20,50,100],c=[{value:"all",label:"All accounts"},{value:"active",label:"Active"},{value:"inactive",label:"Turned off"}],u=[{value:"default",label:"Default quota order"},{value:"remaining-asc",label:"% quota: low to high"},{value:"remaining-desc",label:"% quota: high to low"}];function x(e){return e.name?.trim()||e.email?.trim()||e.displayName?.trim()||null}function m(e,t){let r=t[e.id]?.quotas?.[0];return r&&"number"==typeof r.remaining?r.remaining:1/0}function h(e){let t={};return e.forEach(e=>{t[e.id]=!0}),t}function p(e,t){let r=new Set(t.map(e=>e.id));return Object.fromEntries(Object.entries(e).filter(([e])=>r.has(e)))}async function b(e,t){return await e(t)}function g(){try{let e=window.localStorage.getItem(n);return e?JSON.parse(e):{}}catch(e){return console.error("Error reading quota cache:",e),{}}}function f(e,t){try{let r=g();r[e]={...t,cachedAt:new Date().toISOString()},window.localStorage.setItem(n,JSON.stringify(r))}catch(e){console.error("Error writing quota cache:",e)}}function y(e,t){return t&&0!==t?!e||e<0?100:e>=t?0:Math.round((t-e)/t*100):0}function v({quotas:e=[],compact:t=!1,sortMode:r="default",showSortLabel:i=!1}){let[l,n]=(0,s.useState)(1),o=(0,s.useMemo)(()=>e.map((e,t)=>({...e,index:t,remaining:e?.remaining!==void 0?Math.max(0,Math.round(e.remaining)):e?.remainingPercentage!==void 0?Math.round(e.remainingPercentage):y(e?.used,e?.total)})),[e]),d=(0,s.useMemo)(()=>"remaining-asc"===r?[...o].sort((e,t)=>e.remaining-t.remaining||e.name.localeCompare(t.name)):"remaining-desc"===r?[...o].sort((e,t)=>t.remaining-e.remaining||e.name.localeCompare(t.name)):o,[o,r]),c=Math.max(1,Math.ceil(d.length/10));if((0,s.useEffect)(()=>{n(1)},[r,e]),(0,s.useEffect)(()=>{n(e=>Math.min(e,c))},[c]),!e||0===e.length)return null;let u=d.slice((l-1)*10,10*l),x=0===d.length?0:(l-1)*10+1,m=Math.min(10*l,d.length),h=t?"py-1 px-1.5":"py-2 px-3",p=t?"text-[11px]":"text-sm",b=t?"text-[11px]":"text-sm",g=t?"text-[10px] leading-tight":"text-xs";return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"text-[10px] text-text-muted",children:[d.length," quota",d.length>1?"s":""]}),i&&(0,a.jsx)("div",{className:"rounded-md border border-black/10 bg-black/[0.02] px-2 py-1 text-[10px] text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:"Sorted by account remaining"})]}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsx)("table",{className:"w-full table-fixed text-left",children:(0,a.jsx)("tbody",{children:u.map(e=>{var r;let s=(r=e.remaining)>70?{text:"text-green-600 dark:text-green-400",bg:"bg-green-500",bgLight:"bg-green-500/10",emoji:"\uD83D\uDFE2"}:r>=30?{text:"text-yellow-600 dark:text-yellow-400",bg:"bg-yellow-500",bgLight:"bg-yellow-500/10",emoji:"\uD83D\uDFE1"}:{text:"text-red-600 dark:text-red-400",bg:"bg-red-500",bgLight:"bg-red-500/10",emoji:"\uD83D\uDD34"},i=function(e){if(!e)return"-";try{let t="string"==typeof e?new Date(e):e,r=new Date,a=t-r;if(a<=0)return"-";let s=Math.ceil(a/6e4);if(s<60)return`${s}m`;let i=Math.floor(s/60),l=s%60;if(i<24)return`${i}h ${l}m`;let n=Math.floor(i/24);return`${n}d ${i%24}h ${l}m`}catch(e){return"-"}}(e.resetAt),l=function(e){if(!e)return null;try{let t=new Date(e),r=new Date,a=new Date(r.getFullYear(),r.getMonth(),r.getDate()),s=new Date(a);s.setDate(s.getDate()+1);let i="";i=t>=a&&t<s?"Today":t>=s&&t<new Date(s.getTime()+864e5)?"Tomorrow":t.toLocaleDateString("en-US",{month:"short",day:"numeric"});let l=t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return`${i}, ${l}`}catch{return null}}(e.resetAt),n=!1!==e.recurring?`in ${i}`:`expires in ${i}`;return(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,a.jsx)("td",{className:`${h} w-[30%]`,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,a.jsx)("span",{className:"text-[10px] shrink-0",children:s.emoji}),(0,a.jsx)("span",{className:`${p} font-medium text-text-primary truncate`,children:e.name})]})}),(0,a.jsx)("td",{className:`${h} w-[45%]`,children:(0,a.jsxs)("div",{className:t?"space-y-1":"space-y-1.5",children:[(0,a.jsx)("div",{className:`${t?"h-1":"h-1.5"} rounded-full overflow-hidden border ${s.bgLight} ${0===e.remaining?"border-black/10 dark:border-white/10":"border-transparent"}`,children:(0,a.jsx)("div",{className:`h-full transition-all duration-300 ${s.bg}`,style:{width:`${Math.min(e.remaining,100)}%`}})}),(0,a.jsxs)("div",{className:`flex items-center justify-between ${t?"text-[10px]":"text-xs"}`,children:[(0,a.jsxs)("span",{className:"text-text-muted",children:[e.used.toLocaleString()," / ",e.total>0?e.total.toLocaleString():"∞"]}),(0,a.jsxs)("span",{className:`font-medium ${s.text}`,children:[e.remaining,"%"]})]})]})}),(0,a.jsx)("td",{className:`${h} w-[25%]`,children:"-"!==i||l?t?(0,a.jsx)("div",{className:`${b} text-text-primary font-medium truncate`,title:l||"",children:"-"!==i?n:l}):(0,a.jsxs)("div",{className:"space-y-0.5",children:["-"!==i&&(0,a.jsx)("div",{className:`${b} text-text-primary font-medium`,children:n}),l&&(0,a.jsx)("div",{className:`${g} text-text-muted`,children:l})]}):(0,a.jsx)("div",{className:`${b} text-text-muted italic`,children:"N/A"})})]},`${e.name}-${e.index}`)})})})}),c>1&&(0,a.jsxs)("div",{className:"rounded-md border border-black/10 bg-black/[0.02] px-2 py-1.5 dark:border-white/10 dark:bg-white/[0.03]",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 text-[10px] text-text-muted",children:[(0,a.jsxs)("span",{children:["Showing ",x,"-",m," of ",d.length]}),(0,a.jsxs)("span",{children:["Page ",l," / ",c]})]}),(0,a.jsxs)("div",{className:"mt-1.5 flex items-center justify-end gap-1",children:[(0,a.jsx)("button",{type:"button",onClick:()=>n(e=>Math.max(1,e-1)),disabled:1===l,className:"flex h-6 items-center rounded-md border border-black/10 px-2 text-[10px] text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Prev"}),(0,a.jsx)("button",{type:"button",onClick:()=>n(e=>Math.min(c,e+1)),disabled:l===c,className:"flex h-6 items-center rounded-md border border-black/10 px-2 text-[10px] text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Next"})]})]})]})}var j=r(98542),k=r(97677),w=r(84588),N=r(35497),C=r(88105),S=r(11059),A=r(78559),$=r(77251);let E={"builder-id":"AWS Builder ID",idc:"IAM Identity Center",google:"Google",github:"GitHub",imported:"Imported Token",api_key:"API Key"},q={claude:"claudeAutoPing",codex:"codexAutoPing"},P={claude:"When your 5h quota runs out, auto-sends a request the moment it resets so a new window starts right away.",codex:"Auto-starts the next 5h Codex window after reset by sending a tiny gpt-5.5 request. Consumes a small amount of quota."};function M(e){return e.name?.trim()&&e.email?.trim()&&e.name.trim()!==e.email.trim()?e.email.trim():e.name?.trim()&&e.displayName?.trim()&&e.name.trim()!==e.displayName.trim()?e.displayName.trim():null}function D(e){let t=e.providerSpecificData?.region;if(t)return t;let r=e.providerSpecificData?.profileArn;return("string"==typeof r?r.split(":")[3]:"")||""}function T(e){if(!e)return"N/A";let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}):"N/A"}function I(){let{copied:e,copy:t}=(0,S.C)(),[r,I]=(0,s.useState)([]),[O,_]=(0,s.useState)({}),[F,z]=(0,s.useState)({}),[L,R]=(0,s.useState)({}),[U,K]=(0,s.useState)(!0),[J,G]=(0,s.useState)({claude:{},codex:{}}),[H,W]=(0,s.useState)(null),[B,V]=(0,s.useState)(!1),[Q,Y]=(0,s.useState)(!1),[Z,X]=(0,s.useState)(60),[ee,et]=(0,s.useState)(!0),[er,ea]=(0,s.useState)(null),[es,ei]=(0,s.useState)(null),[el,en]=(0,s.useState)(null),[eo,ed]=(0,s.useState)(null),[ec,eu]=(0,s.useState)(null),[ex,em]=(0,s.useState)(!1),[eh,ep]=(0,s.useState)(null),[eb,eg]=(0,s.useState)("all"),[ef,ey]=(0,s.useState)([]),[ev,ej]=(0,s.useState)("all"),[ek,ew]=(0,s.useState)("default"),[eN,eC]=(0,s.useState)(!1),[eS,eA]=(0,s.useState)(!1),[e$,eE]=(0,s.useState)(!1),[eq,eP]=(0,s.useState)(1),[eM,eD]=(0,s.useState)(20),[eT,eI]=(0,s.useState)(String(20)),[eO,e_]=(0,s.useState)({page:1,pageSize:20,total:0,totalPages:1}),[eF,ez]=(0,s.useState)({eligibleConnections:0,providerFilteredConnections:0}),eL=(0,s.useRef)(null),eR=(0,s.useRef)(null),eU=(0,s.useRef)(0),eK=(0,s.useCallback)(async(e=eq)=>{try{var t,r;let a=new URLSearchParams({page:String(e),pageSize:String(eM),accountStatus:ev,sort:"priority"});"all"!==eb&&a.set("provider",eb);let s=await fetch(`/api/providers/client?${a.toString()}`);if(!s.ok)throw Error("Failed to fetch connections");let i=await s.json(),l=i.connections||[],n=(t=i.pagination,t||{page:1,pageSize:eM,total:0,totalPages:1}),o=function(e,t=0){return e||{eligibleConnections:t,providerFilteredConnections:t}}(i.totals,l.length);return I(l),ey(i.providerOptions||[]),e_(n),ez(o),eP((r=i.pagination,r?.page||e)),l}catch(e){return(0,A.s)("Error fetching connections:",e),I([]),ey([]),e_({page:1,pageSize:eM,total:0,totalPages:1}),ez({eligibleConnections:0,providerFilteredConnections:0}),[]}},[ev,eq,eM,eb]),eJ=(0,s.useCallback)(async(e,t,{force:r=!1}={})=>{z(t=>({...t,[e]:!0})),R(t=>({...t,[e]:null}));try{let a=`/api/usage/${e}${r?"?force=1":""}`,s=await fetch(a);if(!s.ok){let r=(await s.json().catch(()=>({}))).error||s.statusText;if(404===s.status)return void(0,A.s)(`[ProviderLimits] Connection not found for ${t}, skipping`);if(401===s.status){(0,A.s)(`[ProviderLimits] Auth error for ${t}:`,r);let a={quotas:[],message:r};_(t=>({...t,[e]:a})),f(e,a);return}throw Error(`HTTP ${s.status}: ${r}`)}let i=await s.json(),n={quotas:function(e,t){if(!t||"object"!=typeof t)return[];let r=[];try{switch(e.toLowerCase()){case"github":default:t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"antigravity":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:t.displayName||e,modelKey:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"codex":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,remaining:t.remaining,resetAt:t.resetAt||null})});break;case"kiro":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"qoder":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{("organization"!==e||t&&0!==(Number(t.total)||0))&&r.push({name:"user"===e?"Personal":"organization"===e?"Organization":e,used:t.used||0,total:t.total||0,unit:t.unit,resetAt:t.resetAt||null})});break;case"claude":t.message?r.push({name:"error",used:0,total:0,resetAt:null,message:t.message}):t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"vercel-ai-gateway":case"ollama":case"deepseek":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"codebuddy-cn":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,recurring:!1!==t.recurring})});break;case"kimi":case"kimi-coding":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})})}}catch(t){return console.error(`Error parsing quota data for ${e}:`,t),[]}let a=(0,l.KC)(e);if(a.length>0){let e=new Map(a.map((e,t)=>[e.id,t]));r.sort((t,r)=>{let a=t.modelKey||t.name,s=r.modelKey||r.name;return(e.get(a)??999)-(e.get(s)??999)})}return r}(t,i),plan:i.plan||null,message:i.message||null,raw:i};_(t=>({...t,[e]:n})),f(e,n)}catch(r){(0,A.s)(`[ProviderLimits] Error fetching quota for ${t} (${e}):`,r),R(t=>({...t,[e]:r.message||"Failed to fetch quota"}))}finally{z(t=>({...t,[e]:!1}))}},[]),eG=(0,s.useCallback)(async(e,t)=>{await eJ(e,t,{force:!0}),W(new Date)},[eJ]),eH=(0,s.useCallback)(async(e,t)=>{if("codex"===t&&!el){en(e),R(t=>({...t,[e]:null}));try{let r=await fetch(`/api/usage/${e}/codex-reset-credits`,{method:"POST"}),a=await r.json().catch(()=>({}));if(!r.ok)throw Error(a.message||a.error||a.code||"Failed to reset Codex limit");await eJ(e,t),W(new Date)}catch(t){R(r=>({...r,[e]:t.message||"Failed to reset Codex limit"}))}finally{en(null)}}},[eJ,el]),eW=(0,s.useCallback)(async e=>{eu({connection:e,loading:!0,error:null,data:null});try{let t=await fetch(`/api/usage/${e.id}/codex-reset-credits`,{cache:"no-store"}),r=await t.json().catch(()=>({}));if(!t.ok)throw Error(r.error||r.message||"Failed to load Codex reset credits");let a=Array.isArray(r.credits)?[...r.credits]:[];a.sort((e,t)=>{let r=e.expiresAt?new Date(e.expiresAt).getTime():1/0,a=t.expiresAt?new Date(t.expiresAt).getTime():1/0;return r-a}),eu({connection:e,loading:!1,error:null,data:{...r,credits:a}})}catch(t){eu({connection:e,loading:!1,error:t.message||"Failed to load Codex reset credits",data:null})}},[]),eB=(0,s.useCallback)(async e=>{let t=x(r.find(t=>t.id===e)||{})||e;if(await (0,$.l)({message:`Delete connection “${t}”?`,confirmText:"Continue"})){ea(e);try{if((await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok){_(t=>{let r={...t};return delete r[e],r}),z(t=>{let r={...t};return delete r[e],r}),R(t=>{let r={...t};return delete r[e],r});try{let t=g();t[e]&&(delete t[e],window.localStorage.setItem(n,JSON.stringify(t)))}catch(e){(0,A.s)("Error deleting cache entry:",e)}await b(eK,eq)}}catch(e){(0,A.s)("Error deleting connection:",e)}finally{ea(null)}}},[r,eK,eq]),eV=(0,s.useCallback)(async(e,t)=>{ei(e);try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&(_(e=>({...e})),await b(eK,eq))}catch(e){(0,A.s)("Error updating connection status:",e)}finally{ei(null)}},[eK,eq]),eQ=(0,s.useCallback)(async e=>{if(!eh?.id)return;let t=eh.id,r=eh.provider;try{(await fetch(`/api/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await eK(),em(!1),ep(null),C.wb.includes(r)&&await eJ(t,r))}catch(e){(0,A.s)("Error saving connection:",e)}},[eh,eK,eJ]),eY=(0,s.useCallback)(async(e=!1)=>{if(Q)return;Y(!0),X(60);let t=eU.current+=1,r=Math.round(10);try{let a=await eK(eq);z(h(a)),R(e=>p(e,a)),_(e=>p(e,a)),await Promise.all(a.filter(a=>e||"claude"!==a.provider||t%r==0).map(e=>eJ(e.id,e.provider))),W(new Date)}catch(e){(0,A.s)("Error refreshing all providers:",e)}finally{Y(!1)}},[Q,eK,eJ,eq]);(0,s.useEffect)(()=>{(async()=>{et(!0);let e=await eK(eq);et(!1),z(h(e)),R(t=>p(t,e)),_(t=>p(t,e)),await Promise.all(e.map(e=>eJ(e.id,e.provider))),W(new Date)})()},[eK,eJ,eq]),(0,s.useEffect)(()=>{let e=window.localStorage.getItem(o);K(null===e||"true"===e),V(!0)},[]),(0,s.useEffect)(()=>{B&&window.localStorage.setItem(o,String(U))},[U,B]),(0,s.useEffect)(()=>{fetch("/api/settings",{cache:"no-store"}).then(e=>e.ok?e.json():{}).then(e=>G({claude:e?.claudeAutoPing?.connections||{},codex:e?.codexAutoPing?.connections||{}})).catch(()=>{})},[]);let eZ=(0,s.useCallback)(async(e,t,r)=>{let a=q[t];if(!a)return;let s={...J[t]||{},[e]:r};G({...J,[t]:s});try{let e=await fetch("/api/settings",{cache:"no-store"}),t={...(e.ok?await e.json():{})[a]||{},connections:s};await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[a]:t})})}catch{G(J)}},[J]);(0,s.useEffect)(()=>{if(!B||!U){eL.current&&(clearInterval(eL.current),eL.current=null),eR.current&&(clearInterval(eR.current),eR.current=null);return}return eL.current=setInterval(()=>{eY()},6e4),eR.current=setInterval(()=>{X(e=>e<=1?60:e-1)},1e3),()=>{eL.current&&clearInterval(eL.current),eR.current&&clearInterval(eR.current)}},[U,eY,B]),(0,s.useEffect)(()=>{let e=()=>{document.hidden?(eL.current&&(clearInterval(eL.current),eL.current=null),eR.current&&(clearInterval(eR.current),eR.current=null)):U&&B&&(eL.current=setInterval(()=>eY(),6e4),eR.current=setInterval(()=>{X(e=>e<=1?60:e-1)},1e3))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[U,eY,B]);let eX=(0,s.useMemo)(()=>(function(e,t,r,a,s){if("codex"===a&&"default"!==s)return[...e].sort((e,r)=>{let a=m(e,t),i=m(r,t),l="remaining-asc"===s?a-i:i-a;return 0!==l?l:(x(e)||"").localeCompare(x(r)||"")});if(!r){let t=new Map;for(let r of e){let e=r.provider||"";t.has(e)||t.set(e,[]),t.get(e).push(r)}return Array.from(t.values()).flat()}let i=e=>{let r=(t[e.id]?.quotas||[]).map(e=>e.resetAt?new Date(e.resetAt).getTime():1/0).filter(e=>Number.isFinite(e));return r.length>0?Math.min(...r):1/0};return[...e].sort((e,t)=>{let r=i(e)-i(t);return 0!==r?r:(e.provider||"").localeCompare(t.provider||"")||(x(e)||"").localeCompare(x(t)||"")})})(r,O,eN,eb,ek),[r,O,eN,eb,ek]),e0=e=>{let t=O[e.id]?.quotas;return!!t?.length&&t.some(e=>!!e.total&&!(e.total<=0)&&5>=y(e.used,e.total))},e1=(0,s.useCallback)(async(e,t)=>{if(e.length&&!e$){eE(!0);try{await Promise.all(e.map(e=>fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})}))),await b(eK,eq)}catch(e){(0,A.s)("Error bulk toggling connections:",e)}finally{eE(!1)}}},[e$,eK,eq]),e5="all"===eb?"All providers":eb,e2=eF.eligibleConnections>0,e8=eX.length>0,e3=eF.eligibleConnections?eF.providerFilteredConnections?{icon:"filter_alt_off",title:"No Accounts On This Page",description:"Try moving to another page or refreshing the current filters."}:{icon:"filter_alt_off",title:"No Accounts Match Current Filters",description:"all"===eb?"Try changing the account status filter to see more quota trackers.":`No ${"inactive"===ev?"turned off":"active"===ev?"active":"matching"} accounts found for ${eb}.`}:{icon:"cloud_off",title:"No Providers Connected",description:"Connect to providers with OAuth to track your API quota limits and usage."},e4=function(e){var t;let{start:r,end:a}=(t=e).total?{start:(t.page-1)*t.pageSize+1,end:Math.min(t.page*t.pageSize,t.total)}:{start:0,end:0};return`Showing ${r}-${a} of ${e.total}`}(eO),e6=!d.includes(eM);return ee||e2?ee||e8?(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsx)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-end",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>eA(e=>!e),className:"flex h-8 items-center justify-between gap-1 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-haspopup":"menu","aria-expanded":eS,title:"Filter quota providers",children:[(0,a.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:["all"===eb?(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"apps"}):(0,a.jsx)(i.A,{src:`/providers/${eb}.png`,alt:eb,size:18,className:"size-[18px] rounded object-contain",fallbackText:eb.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"truncate capitalize hidden lg:inline",children:e5})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"expand_more"})]}),eS&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"fixed inset-0 z-30 bg-transparent","aria-label":"Close provider filter",onClick:()=>eA(!1)}),(0,a.jsxs)("div",{className:"absolute left-0 z-40 mt-2 w-64 overflow-hidden rounded-2xl border border-black/10 bg-surface/95 p-1.5 shadow-xl shadow-black/10 backdrop-blur dark:border-white/10 dark:bg-surface/95 sm:w-72",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{"all"!==eb&&eP(1),eg("all"),eA(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${"all"===eb?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[22px]",children:"apps"}),(0,a.jsx)("span",{className:"font-medium",children:"All providers"}),"all"===eb&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]}),(0,a.jsx)("div",{className:"my-1 h-px bg-black/10 dark:bg-white/10"}),(0,a.jsx)("div",{className:"max-h-72 overflow-y-auto pr-1",children:ef.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{eb!==e&&eP(1),eg(e),eA(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${eb===e?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)(i.A,{src:`/providers/${e}.png`,alt:e,size:24,className:"size-6 rounded-md object-contain",fallbackText:e.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"font-medium capitalize",children:e}),eb===e&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]},e))})]})]})]}),(0,a.jsx)("select",{value:ev,onChange:e=>{let t=e.target.value;ev!==t&&eP(1),ej(t)},className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Filter accounts by status",children:c.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),"codex"===eb&&(0,a.jsx)("select",{value:ek,onChange:e=>ew(e.target.value),className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Sort Codex quotas by remaining",children:u.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,a.jsxs)("button",{type:"button",onClick:()=>eC(e=>!e),"aria-pressed":eN,className:`flex h-8 shrink-0 items-center gap-1 rounded-lg border px-2 text-xs transition-colors ${eN?"border-amber-500/40 bg-amber-500/10 text-amber-500":"border-black/10 text-text-primary hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5"}`,title:"Sort accounts by earliest quota reset time",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"hourglass_top"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Expiring first"})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{e1(eX.filter(e=>(e.isActive??!0)&&e0(e)).map(e=>e.id),!1)},disabled:e$,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-red-500/30 px-2 text-xs text-red-500 transition-colors hover:bg-red-500/10 disabled:opacity-50",title:"Disable connections with depleted quota on the current page",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"block"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Turn off Empty"})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{e1(eX.filter(e=>!(e.isActive??!0)&&!e0(e)).map(e=>e.id),!0)},disabled:e$,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-emerald-500/30 px-2 text-xs text-emerald-500 transition-colors hover:bg-emerald-500/10 disabled:opacity-50",title:"Enable connections that still have quota on the current page",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Turn on Available"})]}),(0,a.jsxs)("button",{onClick:()=>K(e=>!e),className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5",title:U?"Disable auto-refresh":"Enable auto-refresh",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${U?"text-primary":"text-text-muted"}`,children:U?"toggle_on":"toggle_off"}),(0,a.jsx)("span",{className:"hidden text-text-primary sm:inline",children:"Auto-refresh"}),U&&(0,a.jsxs)("span",{className:"text-[10px] text-text-muted tabular-nums",children:["(",Z,"s)"]})]}),(0,a.jsx)("button",{type:"button",onClick:()=>eY(!0),disabled:Q,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5 disabled:opacity-50",title:"Refresh all",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${Q?"animate-spin":""}`,children:"refresh"})})]})}),eN&&(0,a.jsx)("div",{className:"rounded-xl border border-amber-500/20 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-300",children:"Expiring-first currently reorders accounts inside the current page. Cross-page ordering still follows backend pagination."}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:eX.map(r=>{let s,l,n,o=O[r.id],d=F[r.id],c=L[r.id],u=!1===r.isActive,m="codex"===r.provider,h=Number.isFinite(l="number"==typeof(s=o?.raw?.resetCredits?.availableCount)?s:Number(s))?Math.max(0,l):0,p=el===r.id,b=er===r.id||es===r.id||p;return(0,a.jsxs)(w.default,{padding:"none",className:`min-w-0 ${u?"opacity-60":""}`,children:[(0,a.jsx)("div",{className:"px-3 py-2 border-b border-black/10 dark:border-white/10",children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("div",{className:"w-8 h-8 shrink-0 rounded-md flex items-center justify-center overflow-hidden",children:(0,a.jsx)(i.A,{src:`/providers/${r.provider}.png`,alt:r.provider,size:32,className:"object-contain",fallbackText:r.provider?.slice(0,2).toUpperCase()||"PR"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-primary capitalize truncate",children:r.provider}),x(r)?(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:x(r)}):null,M(r)?(0,a.jsx)("p",{className:"text-[11px] text-text-muted/80 truncate",children:M(r)}):null,"kiro"===r.provider&&(0,a.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:[(0,a.jsx)("span",{className:"rounded-full bg-brand-500/10 px-2 py-0.5 text-[10px] font-semibold text-brand-600 dark:text-brand-300",children:(n=r.providerSpecificData?.authMethod)&&E[n]?E[n]:"api_key"===r.authType?"API Key":"OAuth"}),D(r)&&(0,a.jsx)("span",{className:"rounded-full bg-blue-500/10 px-2 py-0.5 text-[10px] font-semibold text-blue-600 dark:text-blue-400",children:D(r)}),(0,a.jsx)("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-semibold ${u?"bg-surface-2 text-text-muted":"active"===r.testStatus||"success"===r.testStatus?"bg-green-500/10 text-green-600 dark:text-green-400":"error"===r.testStatus||"expired"===r.testStatus||"unavailable"===r.testStatus?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-surface-2 text-text-muted"}`,children:u?"disabled":r.testStatus||"unknown"}),r.providerSpecificData?.profileArn&&(0,a.jsxs)("button",{type:"button",onClick:()=>t(r.providerSpecificData.profileArn,r.id),title:r.providerSpecificData.profileArn,className:"inline-flex max-w-full items-center gap-1 rounded-full border border-border-subtle px-2 py-0.5 text-[10px] text-text-muted transition-colors hover:text-primary",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:e===r.id?"check":"content_copy"}),(0,a.jsx)("code",{className:"truncate font-mono",children:r.providerSpecificData.profileArn})]})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[m&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(k.default,{text:h>0?`Use one Codex reset credit. Available: ${h}`:"No Codex reset credits available",children:(0,a.jsxs)("button",{type:"button",onClick:()=>ed({connection:r,resetCreditCount:h}),disabled:h<=0||d||b,"aria-label":h>0?`Use one Codex reset credit. ${h} available.`:"No Codex reset credits available",className:`flex h-8 min-w-10 items-center justify-center gap-1 rounded-lg border px-2 text-[11px] font-medium tabular-nums transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary/60 disabled:cursor-not-allowed disabled:opacity-60 ${h>0?"border-primary/30 bg-primary/5 text-primary hover:bg-primary/10":"border-black/10 bg-black/[0.02] text-text-muted dark:border-white/10 dark:bg-white/[0.03]"}`,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[15px] ${p?"animate-spin":""}`,children:p?"progress_activity":"restart_alt"}),(0,a.jsx)("span",{children:h})]})}),(0,a.jsx)(k.default,{text:"View Codex reset credit expiry",children:(0,a.jsx)("button",{type:"button",onClick:()=>eW(r),disabled:d||b,"aria-label":"View Codex reset credit expiry",className:"flex h-8 w-8 items-center justify-center rounded-lg border border-black/10 text-text-muted transition-colors hover:bg-black/5 hover:text-primary disabled:cursor-not-allowed disabled:opacity-50 dark:border-white/10 dark:hover:bg-white/5",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[17px]",children:"schedule"})})})]}),q[r.provider]&&"oauth"===r.authType&&(0,a.jsx)(k.default,{text:P[r.provider],children:(0,a.jsx)("button",{type:"button",onClick:()=>eZ(r.id,r.provider,J[r.provider]?.[r.id]!==!0),"aria-label":"Toggle auto-ping",className:`flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${J[r.provider]?.[r.id]===!0?"text-primary":"text-text-muted"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"bolt"})})}),(0,a.jsx)(k.default,{text:"Refresh quota",children:(0,a.jsx)("button",{type:"button",onClick:()=>eG(r.id,r.provider),disabled:d||b,"aria-label":"Refresh quota",className:"flex h-8 w-8 items-center justify-center rounded-lg hover:bg-black/5 dark:hover:bg-white/5 transition-colors disabled:opacity-50",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted ${d?"animate-spin":""}`,children:"refresh"})})}),(0,a.jsx)(k.default,{text:"Edit connection",children:(0,a.jsx)("button",{type:"button",onClick:()=>{ep(r),em(!0)},disabled:b,"aria-label":"Edit connection",className:"flex h-8 w-8 items-center justify-center rounded-lg hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary transition-colors disabled:opacity-50",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})})}),(0,a.jsx)(k.default,{text:"Delete connection",children:(0,a.jsx)("button",{type:"button",onClick:()=>eB(r.id),disabled:b,"aria-label":"Delete connection",className:"flex h-8 w-8 items-center justify-center rounded-lg hover:bg-red-500/10 text-red-500 transition-colors disabled:opacity-50",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] ${er===r.id?"animate-pulse":""}`,children:"delete"})})}),(0,a.jsx)("div",{className:"inline-flex items-center pl-0.5",title:r.isActive??!0?"Disable connection":"Enable connection",children:(0,a.jsx)(j.default,{size:"sm",checked:r.isActive??!0,disabled:b,onChange:e=>eV(r.id,e)})})]})]})}),(0,a.jsx)("div",{className:"px-2 py-1.5",children:d?(0,a.jsx)("div",{className:"text-center py-5 text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] animate-spin",children:"progress_activity"})}):c?(0,a.jsxs)("div",{className:"text-center py-5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] text-red-500",children:"error"}),(0,a.jsx)("p",{className:"mt-1.5 text-xs text-text-muted",children:c})]}):o?.message?(0,a.jsx)("div",{className:"text-center py-5",children:(0,a.jsx)("p",{className:"text-xs text-text-muted",children:o.message})}):(0,a.jsx)(v,{quotas:o?.quotas,compact:!0,sortMode:"default",showSortLabel:"codex"===r.provider&&"default"!==ek})})]},r.id)})}),(0,a.jsx)("div",{className:"rounded-xl border border-black/10 bg-black/[0.02] px-3 py-2 dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:e4}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)("select",{value:e6?"custom":String(eM),onChange:e=>{let t=e.target.value;if("custom"===t)return;let r=Number.parseInt(t,10);Number.isFinite(r)&&(eP(1),eD(r),eI(String(r)))},className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Accounts per page",children:[d.map(e=>(0,a.jsxs)("option",{value:String(e),children:[e," / page"]},e)),(0,a.jsx)("option",{value:"custom",children:"Custom"})]}),(0,a.jsx)("input",{type:"number",min:"1",max:String(500),inputMode:"numeric",value:eT,onChange:e=>eI(e.target.value),onBlur:()=>{let e=Number.parseInt(eT,10);if(!Number.isFinite(e))return void eI(String(eM));let t=Math.min(500,Math.max(1,e));eP(1),eD(t),eI(String(t))},onKeyDown:e=>{if("Enter"!==e.key)return;let t=Number.parseInt(eT,10);if(!Number.isFinite(t))return void eI(String(eM));let r=Math.min(500,Math.max(1,t));eP(1),eD(r),eI(String(r))},className:"h-8 w-20 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Custom accounts per page",placeholder:"Custom"}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Page ",eO.page," / ",eO.totalPages]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("button",{type:"button",onClick:()=>eP(1),disabled:eO.page<=1||ee||Q,className:"flex h-8 items-center rounded-lg border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"First Page"}),(0,a.jsx)("button",{type:"button",onClick:()=>eP(e=>Math.max(1,e-1)),disabled:eO.page<=1||ee||Q,className:"flex h-8 w-8 items-center justify-center rounded-lg border border-black/10 text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5","aria-label":"Previous accounts page",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"chevron_left"})}),(0,a.jsx)("button",{type:"button",onClick:()=>eP(e=>Math.min(eO.totalPages,e+1)),disabled:eO.page>=eO.totalPages||ee||Q,className:"flex h-8 w-8 items-center justify-center rounded-lg border border-black/10 text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5","aria-label":"Next accounts page",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"chevron_right"})}),(0,a.jsx)("button",{type:"button",onClick:()=>eP(eO.totalPages),disabled:eO.page>=eO.totalPages||ee||Q,className:"flex h-8 items-center rounded-lg border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Last Page"})]})]})}),(0,a.jsx)(N.uo,{isOpen:!!eo,onClose:()=>{el||ed(null)},onConfirm:async()=>{let e=eo?.connection;e&&(await eH(e.id,e.provider),ed(null))},title:"Reset Codex limit?",message:`Use 1 Codex reset credit for ${x(eo?.connection||{})||"this account"}. This cannot be undone. Remaining credits: ${eo?.resetCreditCount??0}.`,confirmText:"Reset limit",cancelText:"Cancel",variant:"danger",loading:!!el}),ec&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 px-4 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"w-full max-w-2xl overflow-hidden rounded-2xl border border-black/15 bg-white shadow-2xl ring-1 ring-black/10 dark:border-white/15 dark:bg-neutral-950 dark:ring-white/10",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 border-b border-black/10 bg-black/[0.03] px-4 py-3 dark:border-white/10 dark:bg-white/[0.04]",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-base font-semibold text-text-primary",children:"Codex Reset Credit Expiry"}),(0,a.jsx)("p",{className:"mt-0.5 truncate text-xs text-text-muted",children:x(ec.connection)||"Codex account"})]}),(0,a.jsx)("button",{type:"button",onClick:()=>eu(null),className:"flex h-8 w-8 items-center justify-center rounded-lg text-text-muted transition-colors hover:bg-black/5 hover:text-text-primary dark:hover:bg-white/5","aria-label":"Close reset credit expiry modal",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),(0,a.jsx)("div",{className:"max-h-[70vh] overflow-auto bg-white p-4 dark:bg-neutral-950",children:ec.loading?(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-[20px]",children:"progress_activity"}),"Loading reset credits..."]}):ec.error?(0,a.jsx)("div",{className:"rounded-xl border border-red-500/20 bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-300",children:ec.error}):ec.data?.credits?.length?(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between rounded-xl border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:[(0,a.jsxs)("span",{children:[ec.data.credits.length," reset credit",1===ec.data.credits.length?"":"s"]}),(0,a.jsxs)("span",{children:[ec.data.availableCount??0," available"]})]}),(0,a.jsx)("div",{className:"overflow-x-auto rounded-xl border border-black/10 dark:border-white/10",children:(0,a.jsxs)("table",{className:"w-full min-w-[560px] text-left text-sm",children:[(0,a.jsx)("thead",{className:"bg-black/[0.03] text-xs uppercase tracking-wide text-text-muted dark:bg-white/[0.04]",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-3 py-2 font-medium",children:"Status"}),(0,a.jsx)("th",{className:"px-3 py-2 font-medium",children:"Granted At"}),(0,a.jsx)("th",{className:"px-3 py-2 font-medium",children:"Expires At"}),(0,a.jsx)("th",{className:"px-3 py-2 font-medium",children:"Remaining"})]})}),(0,a.jsx)("tbody",{children:ec.data.credits.map((e,t)=>(0,a.jsxs)("tr",{className:"border-t border-black/5 dark:border-white/5",children:[(0,a.jsx)("td",{className:"px-3 py-2",children:(0,a.jsx)("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary",children:e.status||"unknown"})}),(0,a.jsx)("td",{className:"px-3 py-2 text-text-muted",children:T(e.grantedAt)}),(0,a.jsx)("td",{className:"px-3 py-2 text-text-primary",children:T(e.expiresAt)}),(0,a.jsx)("td",{className:"px-3 py-2 font-medium text-text-primary",children:function(e){if(!e)return"N/A";let t=new Date(e).getTime()-Date.now();if(!Number.isFinite(t))return"N/A";if(t<=0)return"Expired";let r=Math.ceil(t/36e5),a=Math.floor(r/24),s=r%24;return a>0?`${a}d ${s}h`:`${s}h`}(e.expiresAt)})]},`${e.status}-${e.expiresAt||t}`))})]})})]}):(0,a.jsx)("div",{className:"rounded-xl border border-black/10 bg-black/[0.02] px-3 py-8 text-center text-sm text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:"No reset credit details returned for this account."})})]})}),(0,a.jsx)(N.wI,{isOpen:ex,connection:eh,onSave:eQ,onClose:()=>{em(!1),ep(null)}})]}):(0,a.jsx)(w.default,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:e3.icon}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:e3.title}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:e3.description})]})}):(0,a.jsx)(w.default,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:"cloud_off"}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:"No Providers Connected"}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:"Connect to providers with OAuth to track your API quota limits and usage."})]})})}}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,1330,8441,3794,7358],()=>e(e.s=17002)),_N_E=e.O()}]);
|
package/app/.next/static/chunks/app/(dashboard)/dashboard/skills/[id]/page-aba614778bfe50ad.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2838],{23262:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>x});var a=s(95155),l=s(12115),r=s(98500),i=s.n(r),n=s(73321),d=s(35497),o=s(11059),c=s(46453),m=s(23241);function x(){let e=(0,n.useParams)(),t="string"==typeof e?.id?e.id:"",s=c.J3.find(e=>e.id===t),[r,x]=(0,l.useState)(""),[u,f]=(0,l.useState)({}),[p,h]=(0,l.useState)(""),[b,j]=(0,l.useState)(!0),[v,g]=(0,l.useState)(""),{copied:N,copy:y}=(0,o.C)(2e3),k=(0,c.Rz)(t);(0,l.useEffect)(()=>{g(`${window.location.origin}${k}`)},[k]),(0,l.useEffect)(()=>{if(!t)return;let e=!1;return j(!0),h(""),x(""),fetch(k).then(async e=>{if(!e.ok)throw Error((await e.json().catch(()=>({}))).error||`HTTP ${e.status}`);return e.text()}).then(t=>{if(e)return;let{html:s,meta:a}=(0,m.L6)(t);f(a),x(s)}).catch(t=>{e||h(t.message||"Failed to load skill")}).finally(()=>{e||j(!1)}),()=>{e=!0}},[t,k]);let w=s?.name||u.name||t,_=s?.description||u.description||"";return(0,a.jsxs)("div",{className:"max-w-3xl mx-auto space-y-4 pb-10",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)(i(),{href:"/dashboard/skills",className:"text-xs text-text-muted hover:text-primary inline-flex items-center gap-1 mb-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"arrow_back"}),"All skills"]}),(0,a.jsx)("h1",{className:"text-[20px] font-semibold text-text-main tracking-tight",children:w}),_?(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1 leading-relaxed",children:_}):null]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 shrink-0",children:[(0,a.jsxs)(d.$n,{size:"sm",variant:"secondary",onClick:()=>y(v||k),title:v||k,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:N?"check":"content_copy"}),N?"Copied!":"Copy raw URL"]}),(0,a.jsxs)("a",{href:k,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 px-2.5 py-1.5 rounded-md border border-border text-xs text-text-main hover:border-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"open_in_new"}),"Raw markdown"]})]})]}),(v||k)&&!b&&!p?(0,a.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-surface-2 px-3 py-2",children:[(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-text-subtle font-semibold mb-0.5",children:"Agent fetch URL"}),(0,a.jsx)("code",{className:"text-[12px] font-mono text-text-main break-all",children:v||k})]}):null,(0,a.jsxs)(d.Zp,{padding:"lg",className:"overflow-hidden",children:[b&&(0,a.jsxs)("p",{className:"text-sm text-text-muted flex items-center gap-2 py-8 justify-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}),"Loading skill…"]}),p&&(0,a.jsxs)("div",{className:"text-sm text-red-400 py-4",children:[(0,a.jsx)("p",{className:"font-medium",children:"Could not load skill"}),(0,a.jsx)("p",{className:"text-xs mt-1 opacity-80",children:p}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Expected file: ",(0,a.jsxs)("code",{className:"font-mono",children:["skills/",t,"/SKILL.md"]})]})]}),b||p||!r?null:(0,a.jsx)("article",{className:"skill-md",dangerouslySetInnerHTML:{__html:r}})]})]})}},35497:(e,t,s)=>{"use strict";s.d(t,{x0:()=>k.default,Ex:()=>o.default,$n:()=>a.default,nh:()=>S.default,Zp:()=>i.default,Qv:()=>d.CardSkeleton,CK:()=>f.default,uo:()=>n.ConfirmModal,G9:()=>v.default,wI:()=>y.default,vj:()=>N.default,vE:()=>g.default,pd:()=>l.default,Mh:()=>j.default,uR:()=>u.default,Nf:()=>p.default,aF:()=>n.default,rq:()=>x.default,gw:()=>w.default,LF:()=>m.default,Wx:()=>E.default,gM:()=>b.default,Iz:()=>_.default,l6:()=>r.default,lM:()=>c.default,m_:()=>C.default,jK:()=>h.default});var a=s(92542),l=s(11910),r=s(98),i=s(84588),n=s(81127),d=s(25086);s(56319);var o=s(56061),c=s(98542);s(38587),s(21110),s(92622),s(8823),s(92173);var m=s(90882),x=s(72908),u=s(28815),f=s(45455),p=s(28058),h=s(4809);s(21931),s(80752),s(40197);var b=s(23615);s(44736);var j=s(62899);s(94230);var v=s(30815),g=s(23936),N=s(95088),y=s(73579),k=s(96748),w=s(4823),_=s(28067),C=s(97677),E=s(51825),S=s(29366);s(76361),s(91450)},46453:(e,t,s)=>{"use strict";s.d(t,{EV:()=>r,J3:()=>a,Rz:()=>l});let a=[{id:"switchboard",name:"Switchboard (Entry)",description:"Setup, model discovery, combos & Auto routing. Start here — one /v1 endpoint, multi-provider gateway.",endpoint:"/v1",icon:"hub",isEntry:!0},{id:"switchboard-chat",name:"Chat",description:"Chat / code-gen via OpenAI, Anthropic, or Responses formats — streaming, tools, combo as model.",endpoint:"/v1/chat/completions",icon:"chat"}];function l(e){return`/api/skills/${e}`}function r(e){return`/dashboard/skills/${e}`}},98745:(e,t,s)=>{Promise.resolve().then(s.bind(s,23262))}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,1330,8441,3794,7358],()=>e(e.s=98745)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9516],{35497:(e,t,s)=>{"use strict";s.d(t,{x0:()=>k.default,Ex:()=>o.default,$n:()=>a.default,nh:()=>_.default,Zp:()=>i.default,Qv:()=>d.CardSkeleton,CK:()=>u.default,uo:()=>l.ConfirmModal,G9:()=>g.default,wI:()=>N.default,vj:()=>y.default,vE:()=>v.default,pd:()=>r.default,Mh:()=>j.default,uR:()=>p.default,Nf:()=>h.default,aF:()=>l.default,rq:()=>m.default,gw:()=>w.default,LF:()=>x.default,Wx:()=>R.default,gM:()=>b.default,Iz:()=>E.default,l6:()=>n.default,lM:()=>c.default,m_:()=>C.default,jK:()=>f.default});var a=s(92542),r=s(11910),n=s(98),i=s(84588),l=s(81127),d=s(25086);s(56319);var o=s(56061),c=s(98542);s(38587),s(21110),s(92622),s(8823),s(92173);var x=s(90882),m=s(72908),p=s(28815),u=s(45455),h=s(28058),f=s(4809);s(21931),s(80752),s(40197);var b=s(23615);s(44736);var j=s(62899);s(94230);var g=s(30815),v=s(23936),y=s(95088),N=s(73579),k=s(96748),w=s(4823),E=s(28067),C=s(97677),R=s(51825),_=s(29366);s(76361),s(91450)},36072:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>x});var a=s(95155),r=s(12115),n=s(35497),i=s(11059),l=s(46453);function d(e,t){return t?/^https?:\/\//i.test(t)?t:`${e||""}${t.startsWith("/")?t:`/${t}`}`:""}function o({value:e,label:t="Copy link"}){let{copied:s,copy:r}=(0,i.C)(2e3);return(0,a.jsxs)("button",{type:"button",onClick:()=>r(e),className:"px-2 py-1 rounded-md bg-primary text-on-primary text-[11px] font-medium hover:bg-primary/90 transition-colors cursor-pointer shrink-0 inline-flex items-center gap-1",title:e,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:s?"check":"content_copy"}),s?"Copied!":t]})}function c({skill:e,origin:t}){let s=(0,l.Rz)(e.id),r=(0,l.EV)(e.id),i=d(t,s),x=d(t,r);return(0,a.jsxs)("div",{className:`flex items-start gap-3 p-4 rounded-[14px] border shadow-[var(--shadow-soft)] transition-colors ${e.isEntry?"border-brand-500/40 bg-brand-500/5":"border-border-subtle bg-surface hover:bg-surface-2"}`,children:[(0,a.jsx)("div",{className:`size-9 rounded-lg flex items-center justify-center shrink-0 ${e.isEntry?"bg-primary text-on-primary":"bg-primary/10 text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:e.icon})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("h3",{className:"font-semibold text-sm text-text-main",children:e.name}),e.isEntry&&(0,a.jsx)(n.Ex,{variant:"primary",size:"sm",children:"START HERE"}),e.endpoint&&(0,a.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,a.jsx)("code",{className:"text-[10px]",children:e.endpoint})})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:e.description}),(0,a.jsxs)("div",{className:"mt-2 flex flex-col gap-1",children:[(0,a.jsxs)("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"text-[12px] text-primary hover:underline inline-flex items-center gap-1 w-fit",children:["Open skill docs",(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"open_in_new"})]}),(0,a.jsx)("code",{className:"text-[11px] font-mono text-text-subtle break-all",title:"Paste this URL to an AI agent",children:i||s})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5 shrink-0 items-end",children:[(0,a.jsx)(o,{value:i||s,label:"Copy agent URL"}),(0,a.jsxs)("a",{href:x||r,target:"_blank",rel:"noopener noreferrer",className:"px-2 py-1 rounded-md border border-border text-[11px] text-text-main hover:border-primary inline-flex items-center gap-1 transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"open_in_new"}),"Open"]})]})]})}function x(){let e=function(){let[e,t]=(0,r.useState)("");return(0,r.useEffect)(()=>{t(window.location.origin)},[]),e}(),t=d(e,(0,l.Rz)("switchboard"));return(0,a.jsxs)("div",{className:"max-w-4xl mx-auto space-y-6",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("h1",{className:"text-[17px] font-semibold text-text-main",children:"Skills"}),(0,a.jsx)("p",{className:"text-xs font-mono text-text-subtle",children:"agent skill links \xb7 not Media providers"})]}),(0,a.jsxs)(n.Zp,{padding:"md",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-2",children:[(0,a.jsx)("div",{className:"text-xs text-text-muted",children:"Paste this to your AI:"}),(0,a.jsx)(o,{value:`Read this skill and use it: ${t||(0,l.Rz)("switchboard")}`,label:"Copy prompt"})]}),(0,a.jsxs)("div",{className:"px-3 py-2 rounded bg-surface-2 font-mono text-[12px] text-text-main break-all border border-border/50",children:["Read this skill and use it: ",t||(0,l.Rz)("switchboard")]})]}),(0,a.jsx)("div",{className:"space-y-2",children:l.J3.map(t=>(0,a.jsx)(c,{skill:t,origin:e},t.id))}),(0,a.jsx)(n.Zp,{padding:"md",children:(0,a.jsxs)("p",{className:"text-xs text-text-muted leading-relaxed",children:[(0,a.jsx)("strong",{className:"text-text-main",children:"Open"})," opens a readable docs page in a new tab. ",(0,a.jsx)("strong",{className:"text-text-main",children:"Copy agent URL"})," copies"," ",(0,a.jsx)("code",{className:"text-[11px]",children:"/api/skills/<id>"})," for AI agents to fetch the raw markdown."]})})]})}},46453:(e,t,s)=>{"use strict";s.d(t,{EV:()=>n,J3:()=>a,Rz:()=>r});let a=[{id:"switchboard",name:"Switchboard (Entry)",description:"Setup, model discovery, combos & Auto routing. Start here — one /v1 endpoint, multi-provider gateway.",endpoint:"/v1",icon:"hub",isEntry:!0},{id:"switchboard-chat",name:"Chat",description:"Chat / code-gen via OpenAI, Anthropic, or Responses formats — streaming, tools, combo as model.",endpoint:"/v1/chat/completions",icon:"chat"}];function r(e){return`/api/skills/${e}`}function n(e){return`/dashboard/skills/${e}`}},49137:(e,t,s)=>{Promise.resolve().then(s.bind(s,36072))}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,1330,8441,3794,7358],()=>e(e.s=49137)),_N_E=e.O()}]);
|
package/app/.next/static/chunks/app/(dashboard)/dashboard/token-saver/page-1711a424a8dcad0e.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9839],{35497:(e,t,a)=>{"use strict";a.d(t,{x0:()=>k.default,Ex:()=>d.default,$n:()=>s.default,nh:()=>P.default,Zp:()=>n.default,Qv:()=>o.CardSkeleton,CK:()=>p.default,uo:()=>i.ConfirmModal,G9:()=>j.default,wI:()=>N.default,vj:()=>y.default,vE:()=>v.default,pd:()=>l.default,Mh:()=>b.default,uR:()=>h.default,Nf:()=>u.default,aF:()=>i.default,rq:()=>x.default,gw:()=>w.default,LF:()=>m.default,Wx:()=>E.default,gM:()=>g.default,Iz:()=>C.default,l6:()=>r.default,lM:()=>c.default,m_:()=>S.default,jK:()=>f.default});var s=a(92542),l=a(11910),r=a(98),n=a(84588),i=a(81127),o=a(25086);a(56319);var d=a(56061),c=a(98542);a(38587),a(21110),a(92622),a(8823),a(92173);var m=a(90882),x=a(72908),h=a(28815),p=a(45455),u=a(28058),f=a(4809);a(21931),a(80752),a(40197);var g=a(23615);a(44736);var b=a(62899);a(94230);var j=a(30815),v=a(23936),y=a(95088),N=a(73579),k=a(96748),w=a(4823),C=a(28067),S=a(97677),E=a(51825),P=a(29366);a(76361),a(91450)},46357:(e,t,a)=>{Promise.resolve().then(a.bind(a,70323))},70323:(e,t,a)=>{"use strict";a.d(t,{default:()=>x});var s=a(95155),l=a(12115),r=a(35497),n=a(11059),i=a(73006);let o=["zh-CN"],d=[{id:"lite",label:"Lite",desc:"Drop filler, keep grammar"},{id:"full",label:"Full",desc:"Drop articles, fragments OK"},{id:"ultra",label:"Ultra",desc:"Telegraphic, max compression"},{id:"wenyan-lite",label:"文 Lite",desc:"Classical Chinese, light compression",wenyan:!0},{id:"wenyan",label:"文 Full",desc:"Maximum 文言文, 80-90% reduction",wenyan:!0},{id:"wenyan-ultra",label:"文 Ultra",desc:"Extreme classical compression",wenyan:!0}],c=[{id:"lite",label:"Lite",desc:"Build asked, name lazier option"},{id:"full",label:"Full",desc:"Ladder enforced: stdlib/native first"},{id:"ultra",label:"Ultra",desc:"YAGNI extremist, deletion first"}];var m=a(78559);function x(){let e,[t,a]=(0,l.useState)(!0),[x,h]=(0,l.useState)(!1),[p,u]=(0,l.useState)(8),[f,g]=(0,l.useState)({entries:0,hits:0,bytesSaved:0}),b=(0,l.useRef)({}),[j,v]=(0,l.useState)(!1),[y,N]=(0,l.useState)("http://localhost:8787"),[k,w]=(0,l.useState)({installed:!1,running:!1,python:null,loading:!0}),[C,S]=(0,l.useState)(!1),[E,P]=(0,l.useState)(!1),[$,T]=(0,l.useState)(""),[I,R]=(0,l.useState)({version:null,extras:{code:!1,ml:!1},available:["code","ml"],loading:!1}),[M,L]=(0,l.useState)([]),[O,B]=(0,l.useState)(!1),[U,H]=(0,l.useState)(""),[F,K]=(0,l.useState)(null),[_,z]=(0,l.useState)(""),[A,D]=(0,l.useState)(null),[G,J]=(0,l.useState)(!1),[W,X]=(0,l.useState)(!0),[q,Y]=(0,l.useState)(!1),Z=(0,l.useRef)(null),[Q,V]=(0,l.useState)(!1),[ee,et]=(0,l.useState)("full"),[ea,es]=(0,l.useState)(!1),[el,er]=(0,l.useState)("full"),[en,ei]=(0,l.useState)(!1),[eo,ed]=(0,l.useState)(25e3),[ec,em]=(0,l.useState)({installed:!1,installing:!1,running:!1,version:null,loading:!0}),[ex,eh]=(0,l.useState)(null),[ep,eu]=(0,l.useState)(!1),[ef,eg]=(0,l.useState)(!1),[eb,ej]=(0,l.useState)(""),[ev,ey]=(0,l.useState)("en"),{copied:eN,copy:ek}=(0,n.C)();(0,l.useEffect)(()=>(ey((0,i.kk)()),(0,i.oQ)(()=>ey((0,i.kk)()))),[]);let ew=o.includes(ev),eC=ew?d:d.filter(e=>!e.wenyan);(0,l.useEffect)(()=>{let e=d.find(e=>e.id===ee);e?.wenyan&&!ew&&(et("ultra"),eS({cavemanLevel:"ultra"}))},[ew,ee]);let eS=async e=>{try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(e){(0,m.s)("Error updating setting:",e)}},eE=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({rtkEnabled:e})})).ok&&a(e)}catch(e){(0,m.s)("Error updating rtkEnabled:",e)}},eP=async()=>{let e=y.trim()||"http://localhost:8787";N(e),await eS({headroomUrl:e}),eT()},e$=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/token-saver/vault-stats",{headers:{"Cache-Control":"no-store"}});e.ok&&g(await e.json())}catch{}},[]),eT=(0,l.useCallback)(async()=>{w(e=>({...e,loading:!0}));try{let e=await fetch("/api/headroom/status",{headers:{"Cache-Control":"no-store"}}),t=await e.json();if(w({...t,loading:!1}),t?.installed)try{let e=await fetch("/api/headroom/extras",{cache:"no-store"}),t=await e.json();e.ok?R({version:t.version??null,extras:t.extras||{code:!1,ml:!1},available:t.available||["code","ml"],loading:!1}):R(e=>({...e,loading:!1})),L([])}catch{R(e=>({...e,loading:!1})),L([])}else R(e=>({...e,version:null,extras:{code:!1,ml:!1},loading:!1})),L([])}catch{w({installed:!1,running:!1,python:null,loading:!1}),R({version:null,extras:{code:!1,ml:!1},available:["code","ml"],loading:!1}),L([])}},[]),eI=(0,l.useCallback)(async()=>{T(""),P(!0);try{let e=await fetch("/api/headroom/start",{method:"POST"}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||"Failed to start proxy");await eT()}catch(e){T(e.message)}finally{P(!1)}},[eT]),eR=(0,l.useCallback)(async()=>{P(!0);try{await fetch("/api/headroom/stop",{method:"POST"}),await eT()}finally{P(!1)}},[eT]),eM=(0,l.useCallback)(()=>{z(""),Z.current&&clearInterval(Z.current);let e=async()=>{try{let e=await fetch("/api/headroom/extras?log=1",{headers:{"Cache-Control":"no-store"}}),t=await e.json().catch(()=>({}));"string"==typeof t.log&&z(t.log)}catch{}};e(),Z.current=setInterval(e,1500)},[]),eL=(0,l.useCallback)(()=>{Z.current&&(clearInterval(Z.current),Z.current=null)},[]);(0,l.useEffect)(()=>()=>eL(),[eL]);let eO=(0,l.useCallback)(async()=>{if(0!==M.length){B(!0),H(""),eM();try{let e=await fetch("/api/headroom/extras",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({extras:M})}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||"Install failed");R(e=>({...e,version:t.version??e.version,extras:t.extras||e.extras})),L([])}catch(e){H(e.message)}finally{eL(),B(!1)}}},[M,eM,eL]),eB=(0,l.useCallback)(async e=>{K(e),H(""),eM();try{let t=await fetch("/api/headroom/extras",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({extras:[e]})}),a=await t.json().catch(()=>({}));if(!t.ok)throw Error(a.error||"Remove failed");R(e=>({...e,version:a.version??e.version,extras:a.extras||e.extras}))}catch(e){H(e.message)}finally{eL(),K(null)}},[eM,eL]),eU=(0,l.useCallback)(()=>{if(0!==M.length){if(M.includes("ml"))return void D({title:"Install [ml]",message:"[ml] downloads ~1 GB (torch + huggingface-hub). Continue?",confirmText:"Install",variant:"primary",onConfirm:eO});eO()}},[M,eO]),eH=(0,l.useCallback)(e=>{D({title:`Remove [${e}]`,message:`Remove [${e}] and its packages?`,confirmText:"Remove",variant:"danger",onConfirm:()=>eB(e)})},[eB]),eF=(0,l.useCallback)(async(e,t)=>{if(H(""),"code"===e&&J(t),"ml"===e&&X(t),await eS({["code"===e?"headroomCodeAware":"headroomKompress"]:t}),k.running){Y(!0);try{let e=await fetch("/api/headroom/restart",{method:"POST"}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||"Restart failed");await eT()}catch(e){H(e.message)}finally{Y(!1)}}},[k.running,eT]),eK=(0,l.useCallback)(async()=>{em(e=>({...e,loading:!0}));try{let e=await fetch("/api/pxpipe/status",{headers:{"Cache-Control":"no-store"}}),t=await e.json();em({...t,loading:!1}),"number"==typeof t.minChars&&ed(t.minChars)}catch{em({installed:!1,installing:!1,running:!1,version:null,loading:!1})}},[]),e_=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/pxpipe/health",{method:"POST"});eh(await e.json())}catch(e){eh({healthy:!1,checks:[],error:e.message})}},[]),ez=(0,l.useCallback)(async e=>{ej(""),eg(!0);try{let t=await fetch(`/api/pxpipe/${e}`,{method:"POST"}),a=await t.json().catch(()=>({}));if(!t.ok)throw Error(a.error||`PXPIPE ${e} failed`);await eK(),await e_()}catch(e){ej(e.message)}finally{eg(!1)}},[eK,e_]);(0,l.useEffect)(()=>{(async()=>{try{let e=await fetch("/api/settings");if(e.ok){let t=await e.json();a(!1!==t.rtkEnabled),b.current=t.tokenSaver&&"object"==typeof t.tokenSaver?t.tokenSaver:{},h(!!t.tokenSaver?.vault),u(t.tokenSaver?.vaultThresholdKB??8),v(!!t.headroomEnabled),N(t.headroomUrl||"http://localhost:8787"),J(!0===t.headroomCodeAware),X(!1!==t.headroomKompress),V(!!t.cavemanEnabled),et(t.cavemanLevel||"full"),es(!!t.ponytailEnabled),er(t.ponytailLevel||"full"),ei(!!t.pxpipeEnabled),"number"==typeof t.pxpipeMinChars&&ed(t.pxpipeMinChars),eT(),eK().then(e_)}}catch{}})()},[eT,eK,e_]),(0,l.useEffect)(()=>{e$()},[e$]);let eA=!!k.running,eD=k.loading?"Checking…":eA?"Running":!1===k.localUrl||k.installed?!1!==k.localUrl?"Stopped":"External":"Not installed",eG=!1!==k.localUrl,eJ=!!k.canStart,eW=eG&&!!k.managedPid,eX=ex?.healthy===!0,eq=ec.loading?"Checking…":ec.installing?"Installing…":ec.installed?eX?"Healthy":ec.running?"Running":"Stopped":"Not installed";return eX||ec.running,(0,s.jsxs)("div",{className:"space-y-6 p-6",children:[(0,s.jsxs)(r.Zp,{id:"rtk",children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,s.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-primary",children:"bolt"}),"Token Saver"]})}),(0,s.jsxs)("div",{className:"flex items-center justify-between pt-2 pb-4 border-b border-border gap-4",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("p",{className:"font-medium",children:["Compress tool output"," ",(0,s.jsx)("a",{href:"https://github.com/rtk-ai/rtk",target:"_blank",className:"text-xs font-normal text-primary underline hover:opacity-80",children:"(RTK)"})]}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"git/grep/ls/tree/logs → 60-90% fewer input tokens"})]}),(0,s.jsx)(r.lM,{checked:t,onChange:()=>eE(!t),"aria-label":"Compress tool output (RTK)"})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between py-4 gap-4 flex-wrap",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,s.jsxs)("p",{className:"font-medium",children:["Compress context"," ",(0,s.jsx)("a",{href:"https://github.com/chopratejas/headroom",target:"_blank",rel:"noreferrer",className:"text-xs font-normal text-primary underline hover:opacity-80",children:"(Headroom)"})]}),(0,s.jsx)("span",{className:`text-xs px-2 py-0.5 rounded ${eA?"bg-success/15 text-success":"bg-warning/15 text-warning"}`,children:eD}),(0,s.jsx)("button",{type:"button",onClick:()=>S(!0),className:"text-xs text-primary underline hover:opacity-80",children:eA?"Manage":"Setup"})]}),(0,s.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Compress prompts via /v1/compress before routing to the model"})]}),(0,s.jsx)(r.lM,{checked:j,onChange:()=>{var e;let t;return e=!j,void(N(t=y.trim()||"http://localhost:8787"),v(e),eS({headroomEnabled:e,headroomUrl:t}))},"aria-label":"Compress context (Headroom)"})]}),k.installed&&(0,s.jsxs)("div",{className:"mb-3 ml-1 pl-3 pb-4 border-l-2 border-border",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["Compression extras",I.version?` \xb7 v${I.version}`:"",":"]}),I.available.map(e=>{let t=!!I.extras[e],a=M.includes(e),l="code"===e?"tree-sitter AST compression for code responses":"Kompress-v2 HF model for prose/agentic traces (~+1GB)";if(t){let t="code"===e?G:W;return(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs px-2 py-1 rounded border border-success/40 bg-success/5 text-text",title:l,children:[(0,s.jsx)(r.lM,{size:"sm",checked:t,disabled:q,onChange:()=>eF(e,!t)}),(0,s.jsxs)("span",{className:"font-medium",children:["[",e,"]"]}),(0,s.jsx)("button",{type:"button",onClick:()=>eH(e),disabled:F===e,className:"ml-1 text-error underline hover:opacity-80 disabled:opacity-50",title:`Uninstall [${e}]`,children:F===e?"Uninstalling…":"Uninstall"})]},e)}return(0,s.jsxs)("label",{className:`flex items-center gap-1.5 text-xs px-2 py-1 rounded border cursor-pointer transition-colors ${a?"border-primary bg-primary/10 text-primary":"border-border text-text-muted hover:bg-surface-2"}`,title:l,children:[(0,s.jsx)("input",{type:"checkbox",className:"w-3 h-3",checked:a,onChange:()=>{L(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}}),(0,s.jsxs)("span",{className:"font-medium",children:["[",e,"]"]}),(0,s.jsx)("span",{className:"opacity-70",children:"not installed"})]},e)}),M.length>0&&(0,s.jsx)("button",{onClick:eU,disabled:O,className:"text-xs px-2.5 py-1 rounded bg-primary text-white hover:opacity-90 disabled:opacity-50",children:O?"Installing…":`Install [proxy,${M.join(",")}]`})]}),U&&(0,s.jsx)("p",{className:"text-xs text-error mt-1",children:U}),q&&(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Restarting proxy…"}),(O||F)&&_&&(0,s.jsx)("pre",{className:"mt-2 max-h-32 overflow-auto rounded bg-surface-2 p-2 text-[10px] leading-tight text-text-muted whitespace-pre-wrap",children:_}),(0,s.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Installing adds the package; use ",(0,s.jsx)("code",{children:"on"}),"/",(0,s.jsx)("code",{children:"off"})," ","to activate it (restarts the proxy). Default install is"," ",(0,s.jsx)("code",{children:"[proxy]"})," only (SmartCrusher for JSON). Adding"," ",(0,s.jsx)("code",{children:"[code]"})," enables AST compression (Python/JS/TS/Go/Rust/Java/C/C++/Perl). Adding ",(0,s.jsx)("code",{children:"[ml]"})," ","enables the Kompress-v2 HF model for prose/agentic traces but adds ~1 GB (torch + huggingface-hub)."]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between pt-4 border-t border-border gap-4 flex-wrap",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("p",{className:"font-medium",children:["Compress LLM output"," ",(0,s.jsx)("a",{href:"https://github.com/JuliusBrussee/caveman",target:"_blank",rel:"noreferrer",className:"text-xs font-normal text-primary underline hover:opacity-80",children:"(Caveman)"})]}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Terse-style system prompt → ~65% fewer output tokens (up to 87%)"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:[Q&&(0,s.jsxs)("div",{className:"flex flex-col items-end gap-1",children:[(0,s.jsx)("div",{className:"flex items-center gap-1.5",children:eC.map(e=>(0,s.jsx)("button",{onClick:()=>{var t;et(t=e.id),eS({cavemanLevel:t})},className:`px-3 py-1.5 rounded text-xs font-medium border transition-colors ${ee===e.id?"bg-primary text-on-primary border-primary":"bg-transparent border-border text-text-muted hover:bg-surface-2"}`,title:e.desc,children:e.label},e.id))}),(0,s.jsx)("p",{className:"text-xs text-primary",children:d.find(e=>e.id===ee)?.desc})]}),(0,s.jsx)(r.lM,{checked:Q,onChange:()=>{var e;V(e=!Q),eS({cavemanEnabled:e})},"aria-label":"Compress LLM output (Caveman)"})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between pt-4 mt-4 border-t border-border gap-4 flex-wrap",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("p",{className:"font-medium",children:["Lazy senior dev"," ",(0,s.jsx)("a",{href:"https://github.com/DietrichGebert/ponytail",target:"_blank",rel:"noreferrer",className:"text-xs font-normal text-primary underline hover:opacity-80",children:"(Ponytail)"})]}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Bias the model toward minimal code: YAGNI, reuse stdlib, deletion over addition"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:[ea&&(0,s.jsxs)("div",{className:"flex flex-col items-end gap-1",children:[(0,s.jsx)("div",{className:"flex items-center gap-1.5",children:c.map(e=>(0,s.jsx)("button",{onClick:()=>{var t;er(t=e.id),eS({ponytailLevel:t})},className:`px-3 py-1.5 rounded text-xs font-medium border transition-colors ${el===e.id?"bg-primary text-on-primary border-primary":"bg-transparent border-border text-text-muted hover:bg-surface-2"}`,title:e.desc,children:e.label},e.id))}),(0,s.jsx)("p",{className:"text-xs text-primary",children:c.find(e=>e.id===el)?.desc})]}),(0,s.jsx)(r.lM,{checked:ea,onChange:()=>{var e;es(e=!ea),eS({ponytailEnabled:e})},"aria-label":"Lazy senior dev (Ponytail)"})]})]}),!1]}),(0,s.jsxs)(r.Zp,{id:"vault",children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,s.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-primary",children:"inventory_2"}),"Conversation Vault"]})}),(0,s.jsxs)("div",{className:"flex items-center justify-between pt-2 pb-4 border-b border-border gap-4",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"font-medium",children:"Externalize large tool results"}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Store full results outside the conversation and search them when needed"})]}),(0,s.jsx)(r.lM,{checked:x,onChange:()=>{var e;let t;return e=!x,t={...b.current,vault:e},void(b.current=t,h(e),eS({tokenSaver:t}))},"aria-label":"Externalize large tool results"})]}),(0,s.jsx)("div",{className:"py-4 border-b border-border",children:(0,s.jsx)(r.pd,{label:"Externalize tool results larger than (KB)","aria-label":"Externalize tool results larger than (KB)",type:"number",min:7,step:1,value:p,onChange:e=>u(e.target.value),onBlur:()=>{let e=Math.max(7,Number.parseInt(p,10)||8),t={...b.current,vaultThresholdKB:e};b.current=t,u(e),eS({tokenSaver:t})},className:"max-w-xs"})}),(0,s.jsxs)("div",{className:"flex items-center justify-between pt-4 gap-4 flex-wrap",children:[(0,s.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-text-muted",children:"Entries stored"}),(0,s.jsx)("p",{className:"font-mono font-medium",children:f.entries})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-text-muted",children:"Search hits"}),(0,s.jsx)("p",{className:"font-mono font-medium",children:f.hits})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-text-muted",children:"Bytes saved"}),(0,s.jsx)("p",{className:"font-mono font-medium",children:!Number.isFinite(e=Number(f.bytesSaved))||e<=0?"0 B":e<1024?`${Math.round(e)} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`})]})]}),(0,s.jsx)("button",{type:"button",onClick:e$,className:"text-xs text-primary underline hover:opacity-80",children:"Refresh"})]})]}),(0,s.jsx)(r.aF,{isOpen:C,title:eA?"Headroom":"Setup Headroom",onClose:()=>S(!1),children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,s.jsx)("span",{children:"Status"}),(0,s.jsx)("span",{className:eA?"text-success":"text-warning",children:eD})]}),eA&&(0,s.jsx)("a",{href:"/api/headroom/proxy/dashboard",target:"_blank",rel:"noreferrer",className:"w-full rounded border border-border px-4 py-2 text-center text-sm hover:bg-surface-2",children:"Open Headroom Dashboard"}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Proxy URL"}),(0,s.jsx)(r.pd,{value:y,onChange:e=>N(e.target.value),onBlur:eP,placeholder:"http://localhost:8787",className:"font-mono text-sm"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Use a local proxy for Start/Stop, or an external Docker sidecar like http://headroom:8787."})]}),eW?(0,s.jsx)(r.$n,{onClick:eR,variant:"ghost",fullWidth:!0,disabled:E,children:E?"Stopping…":"Stop Headroom"}):eA?(0,s.jsx)("p",{className:"text-sm text-success",children:"Headroom proxy is reachable. You can enable the token saver."}):eJ?(0,s.jsx)(r.$n,{onClick:eI,fullWidth:!0,disabled:E,children:E?"Starting…":"Start Headroom"}):eG?k.python?(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Install then click Start:"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("pre",{className:"flex-1 rounded bg-black/5 dark:bg-white/5 p-2 text-xs font-mono overflow-x-auto",children:'pip install "headroom-ai[proxy]"'}),(0,s.jsx)(r.$n,{size:"sm",variant:"ghost",onClick:()=>ek('pip install "headroom-ai[proxy]"'),children:eN?"Copied":"Copy"})]})]}):(0,s.jsx)("p",{className:"text-sm text-warning",children:"Python ≥ 3.10 required for local managed mode. Install Python first, or use an external proxy URL."}):(0,s.jsx)("p",{className:"text-sm text-warning",children:"Start Headroom separately at the configured URL, then recheck."}),$&&(0,s.jsx)("p",{className:"text-sm text-warning",children:$}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(r.$n,{onClick:()=>eT(),variant:"ghost",fullWidth:!0,children:"Recheck"}),(0,s.jsx)(r.$n,{onClick:()=>S(!1),fullWidth:!0,children:"Done"})]})]})}),(0,s.jsx)(r.uo,{isOpen:!!A,onClose:()=>D(null),onConfirm:()=>{let e=A?.onConfirm;D(null),e?.()},title:A?.title,message:A?.message,confirmText:A?.confirmText,variant:A?.variant}),(0,s.jsx)(r.aF,{isOpen:ep,title:ec.installed?"PXPIPE":"Setup PXPIPE",onClose:()=>eu(!1),children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Compress prompts using multimodal encoding. Runs in-process — no extra server or environment variables required."}),(0,s.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,s.jsx)("span",{children:"Status"}),(0,s.jsxs)("span",{className:eX||ec.running?"text-success":"text-warning",children:[eq,ec.version?` \xb7 v${ec.version}`:""]})]}),ex?.checks?.length>0&&(0,s.jsxs)("div",{className:"flex flex-col gap-1 rounded border border-border p-3",children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-1",children:"Health check"}),ex.checks.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,s.jsxs)("span",{className:e.ok?"text-success":"text-warning",children:[e.ok?"●":"○"," ",e.label]}),e.detail&&(0,s.jsx)("span",{className:"text-text-muted font-mono truncate max-w-[50%]",children:e.detail})]},e.id)),ex.error&&(0,s.jsx)("p",{className:"text-xs text-warning mt-1",children:ex.error})]}),ec.installed?(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[ec.running?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.$n,{onClick:()=>ez("restart"),variant:"ghost",disabled:ef,children:"Restart"}),(0,s.jsx)(r.$n,{onClick:()=>ez("stop"),variant:"ghost",disabled:ef,children:"Stop"})]}):(0,s.jsx)(r.$n,{onClick:()=>ez("start"),disabled:ef,children:ef?"Starting…":"Start"}),(0,s.jsx)(r.$n,{onClick:()=>ez("install"),variant:"ghost",disabled:ef,children:"Repair"}),(0,s.jsx)("a",{href:"/dashboard/pxpipe#logs",className:"col-span-2 rounded border border-border px-4 py-2 text-center text-sm hover:bg-surface-2",children:"Open Logs"})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)("p",{className:"text-sm text-warning",children:"PXPIPE is not installed."}),(0,s.jsx)(r.$n,{onClick:()=>ez("install"),fullWidth:!0,disabled:ef||ec.installing,children:ef||ec.installing?"Installing…":"Install"}),(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Installs the npm package ",(0,s.jsx)("code",{className:"font-mono",children:"pxpipe-proxy"})," into the Switchboard data directory. May take a few minutes."]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Minimum prompt size (chars)"}),(0,s.jsx)(r.pd,{value:String(eo),onChange:e=>ed(e.target.value),onBlur:()=>{let e=Math.max(0,Number(eo)||25e3);ed(e),eS({pxpipeMinChars:e})},placeholder:"25000",className:"font-mono text-sm"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Requests smaller than this bypass PXPIPE and are sent as-is."})]}),eb&&(0,s.jsx)("p",{className:"text-sm text-warning",children:eb}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(r.$n,{onClick:()=>eK().then(e_),variant:"ghost",fullWidth:!0,children:"Recheck"}),(0,s.jsx)(r.$n,{onClick:()=>eu(!1),fullWidth:!0,children:"Done"})]})]})})]})}}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,1330,8441,3794,7358],()=>e(e.s=46357)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3528],{5214:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"workAsyncStorage",{enumerable:!0,get:function(){return r.workAsyncStorageInstance}});let r=n(17828)},17828:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"workAsyncStorageInstance",{enumerable:!0,get:function(){return r}});let r=(0,n(64054).createAsyncLocalStorage)()},21957:(e,t,n)=>{"use strict";function r({moduleIds:e}){return null}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PreloadChunks",{enumerable:!0,get:function(){return r}}),n(95155),n(47650),n(5214),n(2451),n(53887)},35497:(e,t,n)=>{"use strict";n.d(t,{x0:()=>O.default,Ex:()=>d.default,$n:()=>r.default,nh:()=>P.default,Zp:()=>l.default,Qv:()=>i.CardSkeleton,CK:()=>m.default,uo:()=>o.ConfirmModal,G9:()=>y.default,wI:()=>_.default,vj:()=>v.default,vE:()=>j.default,pd:()=>a.default,Mh:()=>b.default,uR:()=>p.default,Nf:()=>x.default,aF:()=>o.default,rq:()=>f.default,gw:()=>S.default,LF:()=>u.default,Wx:()=>C.default,gM:()=>h.default,Iz:()=>w.default,l6:()=>s.default,lM:()=>c.default,m_:()=>N.default,jK:()=>g.default});var r=n(92542),a=n(11910),s=n(98),l=n(84588),o=n(81127),i=n(25086);n(56319);var d=n(56061),c=n(98542);n(38587),n(21110),n(92622),n(8823),n(92173);var u=n(90882),f=n(72908),p=n(28815),m=n(45455),x=n(28058),g=n(4809);n(21931),n(80752),n(40197);var h=n(23615);n(44736);var b=n(62899);n(94230);var y=n(30815),j=n(23936),v=n(95088),_=n(73579),O=n(96748),S=n(4823),w=n(28067),N=n(97677),C=n(51825),P=n(29366);n(76361),n(91450)},41112:(e,t,n)=>{"use strict";function r({reason:e,children:t}){return t}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BailoutToCSR",{enumerable:!0,get:function(){return r}}),n(1980)},51473:(e,t,n)=>{Promise.resolve().then(n.bind(n,69472))},64054:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={bindSnapshot:function(){return i},createAsyncLocalStorage:function(){return o},createSnapshot:function(){return d}};for(var r in n)Object.defineProperty(t,r,{enumerable:!0,get:n[r]});let a=Object.defineProperty(Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available"),"__NEXT_ERROR_CODE",{value:"E504",enumerable:!1,configurable:!0});class s{disable(){throw a}getStore(){}run(){throw a}exit(){throw a}enterWith(){throw a}static bind(e){return e}}let l="u">typeof globalThis&&globalThis.AsyncLocalStorage;function o(){return l?new l:new s}function i(e){return l?l.bind(e):s.bind(e)}function d(){return l?l.snapshot():function(e,...t){return e(...t)}}},68635:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i}});let r=n(95155),a=n(12115),s=n(41112);function l(e){return{default:e&&"default"in e?e.default:e}}n(21957);let o={loader:()=>Promise.resolve(l(()=>null)),loading:null,ssr:!0},i=function(e){let t={...o,...e},n=(0,a.lazy)(()=>t.loader().then(l)),i=t.loading;function d(e){let l=i?(0,r.jsx)(i,{isLoading:!0,pastDelay:!0,error:null}):null,o=!t.ssr||!!t.loading,d=o?a.Suspense:a.Fragment,c=t.ssr?(0,r.jsxs)(r.Fragment,{children:[null,(0,r.jsx)(n,{...e})]}):(0,r.jsx)(s.BailoutToCSR,{reason:"next/dynamic",children:(0,r.jsx)(n,{...e})});return(0,r.jsx)(d,{...o?{fallback:l}:{},children:c})}return d.displayName="LoadableComponent",d}},69472:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>p});var r=n(95155),a=n(12115),s=n(35497),l=n(11059),o=n(75707),i=n.n(o),d=n(78559);let c=i()(()=>n.e(8202).then(n.bind(n,28202)),{loadableGenerated:{webpack:()=>[28202]},ssr:!1}),u=[{id:1,label:"Client Request",file:"1_req_client.json",lang:"json",desc:"Raw request from client"},{id:2,label:"Source Body",file:"2_req_source.json",lang:"json",desc:"After initial conversion"},{id:3,label:"OpenAI Intermediate",file:"3_req_openai.json",lang:"json",desc:"source → openai"},{id:4,label:"Target Request",file:"4_req_target.json",lang:"json",desc:"openai → target + URL + headers"},{id:5,label:"Provider Response",file:"5_res_provider.txt",lang:"text",desc:"Raw SSE from provider"},{id:6,label:"OpenAI Response",file:"6_res_openai.txt",lang:"text",desc:"target → openai (response)"},{id:7,label:"Client Response",file:"7_res_client.txt",lang:"text",desc:"Final response to client"}],f={minimap:{enabled:!1},fontSize:12,lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0};function p(){let{copy:e}=(0,l.C)(),[t,n]=(0,a.useState)({}),[o,i]=(0,a.useState)({1:!0}),[p,x]=(0,a.useState)({}),[g,h]=(0,a.useState)({}),[b,y]=(0,a.useState)(null),j=(e,t)=>x(n=>({...n,[e]:t})),v=(e,t)=>h(n=>({...n,[e]:t})),_=e=>h(t=>{if(!t[e])return t;let n={...t};return delete n[e],n}),O=(e,t)=>n(n=>({...n,[e]:t})),S=e=>i(t=>{let n={};return u.forEach(e=>{n[e.id]=!1}),n[e]=!0,n}),w=async e=>{let t=u.find(t=>t.id===e);j(`load-${e}`,!0);try{let n=await fetch(`/api/translator/load?file=${t.file}`),r=await n.json();r.success?(O(e,r.content),1===e&&await N(r.content)):(0,d.s)(r.error||"File not found")}catch(e){(0,d.s)(e.message)}j(`load-${e}`,!1)},N=async e=>{try{let t="string"==typeof e?JSON.parse(e):e,n=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:1,body:t})}),r=await n.json();r.success&&y(r.result)}catch{}},C=(e,t)=>fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,content:t})}).catch(()=>{}),P=async()=>{j("toOpenAI",!0);try{let e=t[1],n=JSON.parse(e);C("1_req_client.json",e),C("2_req_source.json",JSON.stringify({timestamp:new Date().toISOString(),headers:{},body:n.body||n},null,2));let r=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:2,body:n})}),a=await r.json();if(!a.success){(0,d.s)(a.error),v(1,a.error);return}let s=JSON.stringify(a.result.body,null,2);O(3,s),_(1),S(3)}catch(e){(0,d.s)(e.message),v(1,`Invalid JSON in Client Request: ${e.message}`)}finally{j("toOpenAI",!1)}},T=async()=>{j("toTarget",!0);try{let e=t[3],n=JSON.parse(e);C("3_req_openai.json",e);let r=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:3,body:{...n,provider:b?.provider,model:b?.model}})}),a=await r.json();if(!a.success){(0,d.s)(a.error),v(3,a.error);return}let s={...a.result,provider:b?.provider,model:b?.model};O(4,JSON.stringify(s,null,2)),_(3),S(4)}catch(e){(0,d.s)(e.message),v(3,`Invalid JSON in OpenAI Intermediate: ${e.message}`)}finally{j("toTarget",!1)}},k=async()=>{j("send",!0);try{let e=t[4];if(!e||!e.trim())return void v(4,"Target request is empty — build or load a request in step 4 before sending.");let n=JSON.parse(e);C("4_req_target.json",e);let r=n.provider||b?.provider,a=n.model||b?.model;if(!r||!a){(0,d.s)("Missing provider or model. Please run step 1 first to detect them."),v(4,"Missing provider or model. Please run step 1 first to detect them.");return}let s=await fetch("/api/translator/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,model:a,body:n.body||n})});if(!s.ok){let e=await s.json().catch(()=>({error:s.statusText}));(0,d.s)(e.error||"Send failed");return}let l=s.body.getReader(),o=new TextDecoder,i="";for(;;){let{done:e,value:t}=await l.read();if(e)break;i+=o.decode(t,{stream:!0})}O(5,i),S(5),await fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:"5_res_provider.txt",content:i})})}catch(e){(0,d.s)(e.message),v(4,e.message)}finally{j("send",!1)}},I=async n=>{t[n]&&e(t[n],`translator-step-${n}`)};return(0,r.jsxs)("div",{className:"p-8 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-2xl font-bold text-text-main",children:"Translator Debug"}),(0,r.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Replay request flow — matches log files"})]}),b&&(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[(0,r.jsx)(m,{label:"src",value:b.sourceFormat,color:"blue"}),(0,r.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,r.jsx)(m,{label:"dst",value:b.targetFormat,color:"orange"}),(0,r.jsx)(m,{label:"provider",value:b.provider,color:"green"}),(0,r.jsx)(m,{label:"model",value:b.model,color:"purple"})]})]}),u.map(e=>{var n;let a=1===(n=e.id)?(0,r.jsx)(s.$n,{size:"sm",icon:"arrow_forward",loading:p.toOpenAI,onClick:P,children:"→ OpenAI"}):3===n?(0,r.jsx)(s.$n,{size:"sm",icon:"arrow_forward",loading:p.toTarget,onClick:T,children:"→ Target"}):4===n?(0,r.jsx)(s.$n,{size:"sm",icon:"send",loading:p.send,disabled:!t[4]?.trim(),onClick:k,children:"Send"}):null,l=!!o[e.id],d=t[e.id]||"";return(0,r.jsx)(s.Zp,{children:(0,r.jsxs)("div",{className:"p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("button",{onClick:()=>{let t;return t=e.id,i(e=>({...e,[t]:!e[t]}))},className:"flex items-center gap-2 flex-1 text-left group",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px] text-text-muted group-hover:text-primary transition-colors",children:l?"expand_more":"chevron_right"}),(0,r.jsx)("span",{className:"text-xs font-mono text-text-muted/60 w-4",children:e.id}),(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:e.label}),(0,r.jsx)("span",{className:"text-xs text-text-muted/60 font-mono",children:e.file}),d&&(0,r.jsxs)("span",{className:"text-xs text-green-500",children:["(",d.length," chars)"]})]}),!l&&(0,r.jsxs)("div",{className:"flex gap-1 shrink-0",children:[(0,r.jsx)(s.$n,{size:"sm",variant:"ghost",icon:"folder_open",loading:p[`load-${e.id}`],onClick:()=>w(e.id)}),a]})]}),l&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,r.jsx)(c,{height:"400px",defaultLanguage:"text"===e.lang?"plaintext":"json",value:d,onChange:t=>{O(e.id,t||""),_(e.id),1===e.id&&N(t||"")},theme:"vs-dark",options:f})}),g[e.id]&&(0,r.jsxs)("p",{role:"alert",className:"flex items-center gap-1.5 text-xs text-red-500",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px] leading-none",children:"error"}),g[e.id]]}),(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,r.jsx)(s.$n,{size:"sm",variant:"outline",icon:"folder_open",loading:p[`load-${e.id}`],onClick:()=>w(e.id),children:"Load"}),(0,r.jsx)(s.$n,{size:"sm",variant:"outline",icon:"data_object",onClick:()=>(e=>{try{let n=JSON.parse(t[e]);O(e,JSON.stringify(n,null,2)),_(e)}catch(t){v(e,`Invalid JSON: ${t.message}`)}})(e.id),children:"Format"}),(0,r.jsx)(s.$n,{size:"sm",variant:"outline",icon:"content_copy",onClick:()=>I(e.id),children:"Copy"}),a]})]})]})},e.id)})]})}function m({label:e,value:t,color:n}){return(0,r.jsxs)("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono ${{blue:"bg-blue-500/10 text-blue-500",orange:"bg-orange-500/10 text-orange-500",green:"bg-green-500/10 text-green-500",purple:"bg-purple-500/10 text-purple-500"}[n]}`,children:[(0,r.jsxs)("span",{className:"text-text-muted/70 font-sans text-[10px]",children:[e,":"]}),t]})}},75707:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return a}});let r=n(73623)._(n(68635));function a(e,t){let n={};"function"==typeof e&&(n.loader=e);let a={...n,...t};return(0,r.default)({...a,modules:a.loadableGenerated?.modules})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,1330,8441,3794,7358],()=>e(e.s=51473)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2825],{35497:(e,t,s)=>{"use strict";s.d(t,{x0:()=>k.default,Ex:()=>o.default,$n:()=>a.default,nh:()=>P.default,Zp:()=>r.default,Qv:()=>d.CardSkeleton,CK:()=>u.default,uo:()=>i.ConfirmModal,G9:()=>j.default,wI:()=>w.default,vj:()=>N.default,vE:()=>v.default,pd:()=>l.default,Mh:()=>g.default,uR:()=>p.default,Nf:()=>h.default,aF:()=>i.default,rq:()=>m.default,gw:()=>y.default,LF:()=>x.default,Wx:()=>D.default,gM:()=>b.default,Iz:()=>S.default,l6:()=>n.default,lM:()=>c.default,m_:()=>C.default,jK:()=>f.default});var a=s(92542),l=s(11910),n=s(98),r=s(84588),i=s(81127),d=s(25086);s(56319);var o=s(56061),c=s(98542);s(38587),s(21110),s(92622),s(8823),s(92173);var x=s(90882),m=s(72908),p=s(28815),u=s(45455),h=s(28058),f=s(4809);s(21931),s(80752),s(40197);var b=s(23615);s(44736);var g=s(62899);s(94230);var j=s(30815),v=s(23936),N=s(95088),w=s(73579),k=s(96748),y=s(4823),S=s(28067),C=s(97677),D=s(51825),P=s(29366);s(76361),s(91450)},81772:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>C});var a=s(95155),l=s(12115),n=s(73321),r=s(35497),i=s(84588),d=s(92542),o=s(31474),c=s(34131);function x({isOpen:e,onClose:t,title:s,children:n,width:r="md",className:i,"aria-label":d}){let m={sm:"w-[400px]",md:"w-[500px]",lg:"w-[600px]",xl:"w-[800px]",full:"w-full"},p=(0,c.sp)({isOpen:e,onClose:t}),u=(0,l.useId)();return e?(0,a.jsxs)("div",{className:"fixed inset-0 z-50",children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-[2px] fade-in cursor-pointer",onClick:t,"aria-hidden":"true"}),(0,a.jsxs)("div",{ref:p,role:"dialog","aria-modal":"true","aria-label":d,"aria-labelledby":d?void 0:s?u:void 0,tabIndex:-1,className:(0,o.cn)("absolute right-0 top-0 h-full bg-surface flex flex-col","shadow-[var(--shadow-elev)]","slide-in-right","border-l border-border-subtle","outline-none",m[r]||m.md,i),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-border-subtle flex-shrink-0",children:[(0,a.jsx)("div",{className:"flex items-center gap-3",children:s&&(0,a.jsx)("h2",{id:u,className:"text-lg font-semibold text-text-main",children:s})}),(0,a.jsx)("button",{type:"button",onClick:t,"aria-label":"Close",className:"p-1.5 rounded-[10px] text-text-muted hover:bg-surface-2 hover:text-text-main transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-6 custom-scrollbar",children:n})]})]}):null}function m({currentPage:e,pageSize:t,totalItems:s,onPageChange:l,onPageSizeChange:n,className:r}){let i=Math.ceil(s/t),c=s>0?(e-1)*t+1:0,x=Math.min(e*t,s),p=(()=>{let t=[],s=Math.max(1,e-2),a=Math.min(i,s+5-1);a-s+1<5&&(s=Math.max(1,a-5+1));for(let e=s;e<=a;e++)t.push(e);return t})();return(0,a.jsxs)("div",{className:(0,o.cn)("flex flex-col sm:flex-row items-center justify-between gap-4 py-4 px-2",r),children:[s>0&&(0,a.jsxs)("div",{className:"text-sm text-text-muted",children:["Showing ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:c})," to"," ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:x})," of"," ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:s})," results"]}),(0,a.jsxs)("nav",{"aria-label":"Pagination",className:"flex flex-wrap items-center justify-center gap-2 sm:gap-4",children:[n&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm text-text-muted",children:"Rows:"}),(0,a.jsx)("select",{"aria-label":"Rows per page",value:t,onChange:e=>n(Number(e.target.value)),className:(0,o.cn)("h-9 rounded-lg border border-black/10 dark:border-white/10 bg-surface","text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20","cursor-pointer"),style:{colorScheme:"auto"},children:[10,20,50].map(e=>(0,a.jsx)("option",{value:e,children:e},e))})]}),i>1&&(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(d.default,{variant:"outline","aria-label":"Previous page",onClick:()=>l(e-1),disabled:1===e,className:"w-9 px-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"chevron_left"})}),p[0]>1&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.default,{variant:"ghost",size:"sm",onClick:()=>l(1),className:"w-9 px-0 hidden sm:inline-flex",children:"1"}),p[0]>2&&(0,a.jsx)("span",{className:"text-text-muted px-1 hidden sm:inline",children:"..."})]}),p.map(t=>(0,a.jsx)(d.default,{variant:e===t?"primary":"ghost",size:"sm","aria-current":e===t?"page":void 0,onClick:()=>l(t),className:(0,o.cn)("w-9 px-0",e===t?"inline-flex":"hidden sm:inline-flex"),children:t},t)),p[p.length-1]<i&&(0,a.jsxs)(a.Fragment,{children:[p[p.length-1]<i-1&&(0,a.jsx)("span",{className:"text-text-muted px-1 hidden sm:inline",children:"..."}),(0,a.jsx)(d.default,{variant:"ghost",size:"sm",onClick:()=>l(i),className:"w-9 px-0 hidden sm:inline-flex",children:i})]}),(0,a.jsx)(d.default,{variant:"outline","aria-label":"Next page",onClick:()=>l(e+1),disabled:e===i,className:"w-9 px-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"chevron_right"})})]})]})]})}var p=s(88105),u=s(78559);let h=null,f=null;async function b(){if(h&&f)return{providerNameCache:h,providerNodesCache:f};let e=await fetch("/api/provider-nodes"),t=(await e.json()).nodes||[];for(let e of(f={},t))f[e.id]=e.name;return{providerNameCache:h={...p.Q2,...f},providerNodesCache:f}}function g(e,t){if(!e||!t)return e;let s=t[e];if("string"==typeof s)return s;if(s?.name)return s.name;let a=(0,p.zt)(e)||p.Q2[e];return a?.name||e}function j({title:e,children:t,defaultOpen:s=!1,icon:n=null}){let[r,i]=(0,l.useState)(s),d=(0,l.useId)();return(0,a.jsxs)("div",{className:"border border-black/5 dark:border-white/5 rounded-lg overflow-hidden",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,"aria-controls":d,className:"w-full flex items-center justify-between p-3 bg-black/[0.02] dark:bg-white/[0.02] hover:bg-black/[0.04] dark:hover:bg-white/[0.04] transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-inset",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[n&&(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-text-muted","aria-hidden":"true",children:n}),(0,a.jsx)("span",{className:"font-semibold text-sm text-text-main",children:e})]}),(0,a.jsx)("span",{"aria-hidden":"true",className:(0,o.cn)("material-symbols-outlined text-[20px] text-text-muted transition-transform duration-200",r?"rotate-90":""),children:"chevron_right"})]}),r&&(0,a.jsx)("div",{id:d,className:"p-4 border-t border-black/5 dark:border-white/5",children:t})]})}function v({startDate:e,endDate:t}){if(!e||!t)return!1;let s=new Date(e).getTime(),a=new Date(t).getTime();return!(Number.isNaN(s)||Number.isNaN(a))&&s>a}function N(e){return e?.cached_tokens||e?.cache_read_input_tokens||0}function w(e){return e?.cache_creation_input_tokens||0}function k(e){let t=e?.prompt_tokens||e?.input_tokens||0,s=N(e);return t<s?s:t}function y(){let[e,t]=(0,l.useState)([]),[s,n]=(0,l.useState)({page:1,pageSize:20,totalItems:0,totalPages:0}),[r,c]=(0,l.useState)(!1),[p,h]=(0,l.useState)(null),[f,y]=(0,l.useState)(null),[S,C]=(0,l.useState)(!1),[D,P]=(0,l.useState)([]),[_,R]=(0,l.useState)(null),[T,z]=(0,l.useState)({provider:"",startDate:"",endDate:""}),L=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/usage/providers"),t=await e.json();P(t.providers||[]);let s=await b();R(s.providerNameCache)}catch(e){(0,u.s)("Failed to fetch providers:",e)}},[]),I=(0,l.useCallback)(async()=>{if(!v(T)){c(!0),h(null);try{let e=new URLSearchParams({page:s.page.toString(),pageSize:s.pageSize.toString()});T.provider&&e.append("provider",T.provider),T.startDate&&e.append("startDate",T.startDate),T.endDate&&e.append("endDate",T.endDate);let a=await fetch(`/api/usage/request-details?${e}`);if(!a.ok)throw Error(`Request failed with status ${a.status}`);let l=await a.json();t(l.details||[]),n(e=>({...e,...l.pagination}))}catch(e){(0,u.s)("Failed to fetch request details:",e),h(e?.message||"Network request failed")}finally{c(!1)}}},[s.page,s.pageSize,T]);(0,l.useEffect)(()=>{L()},[L]),(0,l.useEffect)(()=>{I()},[I]);let F=v(T);return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6",children:[(0,a.jsxs)(i.default,{padding:"md",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"provider-filter",className:"text-sm font-medium text-text-main",children:"Provider"}),(0,a.jsxs)("select",{id:"provider-filter",value:T.provider,onChange:e=>z({...T,provider:e.target.value}),className:(0,o.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20","w-full min-w-0 cursor-pointer"),style:{colorScheme:"auto"},children:[(0,a.jsx)("option",{value:"",children:"All Providers"}),D.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"start-date-filter",className:"text-sm font-medium text-text-main",children:"Start Date"}),(0,a.jsx)("input",{id:"start-date-filter",type:"datetime-local",value:T.startDate,"aria-invalid":F||void 0,"aria-describedby":F?"usage-date-range-error":void 0,onChange:e=>z({...T,startDate:e.target.value}),className:(0,o.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","w-full min-w-0 text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20")})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"end-date-filter",className:"text-sm font-medium text-text-main",children:"End Date"}),(0,a.jsx)("input",{id:"end-date-filter",type:"datetime-local",value:T.endDate,"aria-invalid":F||void 0,"aria-describedby":F?"usage-date-range-error":void 0,onChange:e=>z({...T,endDate:e.target.value}),className:(0,o.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","w-full min-w-0 text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20")})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2 sm:col-span-2 lg:col-span-1",children:[(0,a.jsx)("span",{className:"hidden text-sm font-medium text-text-main opacity-0 lg:block","aria-hidden":"true",children:"Clear"}),(0,a.jsx)(d.default,{variant:"ghost",onClick:()=>{z({provider:"",startDate:"",endDate:""})},disabled:!T.provider&&!T.startDate&&!T.endDate,className:"w-full",children:"Clear Filters"})]})]}),F&&(0,a.jsx)("div",{id:"usage-date-range-error",role:"alert",className:"mt-3 text-sm text-danger",children:"Start Date must be on or before End Date."})]}),(0,a.jsxs)(i.default,{padding:"none",children:[(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full min-w-[880px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5",children:[(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Timestamp"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Model"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Provider"}),(0,a.jsx)("th",{className:"text-right p-4 text-sm font-semibold text-text-main",children:"Input Tokens"}),(0,a.jsx)("th",{className:"text-right p-4 text-sm font-semibold text-text-main",children:"Cached"}),(0,a.jsx)("th",{className:"text-right p-4 text-sm font-semibold text-text-main",children:"Cache Creation"}),(0,a.jsx)("th",{className:"text-right p-4 text-sm font-semibold text-text-main",children:"Output Tokens"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Latency"}),(0,a.jsx)("th",{className:"text-center p-4 text-sm font-semibold text-text-main",children:"Action"})]})}),(0,a.jsx)("tbody",{children:r?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:"9",className:"p-8 text-center text-text-muted",children:(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-[20px]","aria-hidden":"true",children:"progress_activity"}),"Loading..."]})})}):p?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:"9",className:"p-8 text-center",children:(0,a.jsxs)("div",{role:"alert",className:"flex flex-col items-center justify-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[24px] text-danger","aria-hidden":"true",children:"error"}),(0,a.jsx)("p",{className:"text-sm font-medium text-text-main",children:"Failed to load request details"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:p}),(0,a.jsx)(d.default,{variant:"outline",size:"sm",onClick:()=>I(),className:"mt-1",children:"Retry"})]})})}):0===e.length?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:"9",className:"p-8 text-center text-text-muted",children:"No request details found"})}):e.map((e,t)=>(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5 last:border-b-0 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,a.jsx)("td",{className:"whitespace-nowrap p-4 text-sm text-text-main",children:new Date(e.timestamp).toLocaleString()}),(0,a.jsx)("td",{className:"max-w-[260px] truncate p-4 font-mono text-sm text-text-main",children:e.model}),(0,a.jsx)("td",{className:"max-w-[180px] truncate p-4 text-sm text-text-main",children:(0,a.jsx)("span",{className:"font-medium",children:g(e.provider,_)})}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main text-right font-mono",children:k(e.tokens).toLocaleString()}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main text-right font-mono",children:N(e.tokens)>0?N(e.tokens).toLocaleString():"—"}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main text-right font-mono",children:w(e.tokens)>0?w(e.tokens).toLocaleString():"—"}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main text-right font-mono",children:e.tokens?.completion_tokens?.toLocaleString()||0}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-muted",children:(0,a.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,a.jsxs)("div",{children:["TTFT: ",(0,a.jsxs)("span",{className:"font-mono",children:[e.latency?.ttft||0,"ms"]})]}),(0,a.jsxs)("div",{children:["Total: ",(0,a.jsxs)("span",{className:"font-mono",children:[e.latency?.total||0,"ms"]})]})]})}),(0,a.jsx)("td",{className:"p-4 text-center",children:(0,a.jsx)(d.default,{variant:"outline",size:"sm",onClick:()=>{y(e),C(!0)},children:"Detail"})})]},`${e.id}-${t}`))})]})}),!r&&!p&&e.length>0&&(0,a.jsx)("div",{className:"border-t border-black/5 dark:border-white/5",children:(0,a.jsx)(m,{currentPage:s.page,pageSize:s.pageSize,totalItems:s.totalItems,onPageChange:e=>{n(t=>({...t,page:e}))},onPageSizeChange:e=>{n(t=>({...t,pageSize:e,page:1}))}})})]}),(0,a.jsx)(x,{isOpen:S,onClose:()=>C(!1),title:"Request Details",width:"lg",children:f&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"grid min-w-0 grid-cols-1 gap-4 text-sm sm:grid-cols-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"ID:"})," ",(0,a.jsx)("span",{className:"break-all font-mono text-text-main",children:f.id})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Timestamp:"})," ",(0,a.jsx)("span",{className:"text-text-main",children:new Date(f.timestamp).toLocaleString()})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Provider:"})," ",(0,a.jsx)("span",{className:"text-text-main font-medium",children:g(f.provider,_)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Model:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:f.model})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Status:"})," ",(0,a.jsx)("span",{className:(0,o.cn)("font-medium","success"===f.status?"text-green-600":"text-red-600"),children:f.status})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Latency:"})," ",(0,a.jsxs)("span",{className:"text-text-main font-mono",children:["TTFT ",f.latency?.ttft||0,"ms / Total ",f.latency?.total||0,"ms"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Input Tokens:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:k(f.tokens).toLocaleString()})]}),N(f.tokens)>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Cached Tokens:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:N(f.tokens).toLocaleString()})]}),w(f.tokens)>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Cache Creation:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:w(f.tokens).toLocaleString()})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Output Tokens:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:f.tokens?.completion_tokens?.toLocaleString()||0})]})]}),f.pxpipe&&(0,a.jsxs)("div",{className:"rounded-lg border border-black/5 dark:border-white/5 p-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-text-muted",children:"image"}),(0,a.jsx)("span",{className:"font-semibold text-sm text-text-main",children:"PXPIPE"}),(0,a.jsx)("span",{className:(0,o.cn)("text-xs px-2 py-0.5 rounded",f.pxpipe.applied?"bg-green-500/15 text-green-600":"bg-amber-500/15 text-amber-600"),children:f.pxpipe.applied?"Activated":"Skipped"})]}),f.pxpipe.applied?(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-sm sm:grid-cols-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted block text-xs",children:"Original (est.)"}),(0,a.jsxs)("span",{className:"font-mono",children:[(f.pxpipe.tokensBeforeEst||0).toLocaleString()," tokens"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted block text-xs",children:"Compressed (est.)"}),(0,a.jsxs)("span",{className:"font-mono",children:[(f.pxpipe.tokensAfterEst||0).toLocaleString()," tokens"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted block text-xs",children:"Saved"}),(0,a.jsxs)("span",{className:"font-mono text-green-600",children:[f.pxpipe.savedPct||0,"%"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted block text-xs",children:"Images"}),(0,a.jsxs)("span",{className:"font-mono",children:[f.pxpipe.imageCount||0," (",f.pxpipe.durationMs||0,"ms)"]})]})]}):(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Reason: ",(0,a.jsx)("span",{className:"font-mono",children:f.pxpipe.reason}),f.pxpipe.detail?` — ${f.pxpipe.detail}`:""]})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(j,{title:"1. Client Request (Input)",defaultOpen:!0,icon:"input",children:(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:JSON.stringify(f.request,null,2)})}),f.providerRequest&&(0,a.jsx)(j,{title:"2. Provider Request (Translated)",icon:"translate",children:(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:JSON.stringify(f.providerRequest,null,2)})}),f.providerResponse&&(0,a.jsx)(j,{title:"3. Provider Response (Raw)",icon:"data_object",children:(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:"object"==typeof f.providerResponse?JSON.stringify(f.providerResponse,null,2):f.providerResponse})}),(0,a.jsxs)(j,{title:"4. Client Response (Final)",defaultOpen:!0,icon:"output",children:[f.response?.thinking&&(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsxs)("h4",{className:"font-semibold text-text-main mb-2 flex items-center gap-2 text-xs uppercase tracking-wide opacity-70",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"psychology"}),"Thinking Process"]}),(0,a.jsx)("pre",{className:"max-h-[200px] max-w-full overflow-auto rounded-lg border border-amber-200 bg-amber-50 p-3 font-mono text-xs text-amber-900 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-100 sm:p-4",children:f.response.thinking})]}),(0,a.jsx)("h4",{className:"font-semibold text-text-main mb-2 text-xs uppercase tracking-wide opacity-70",children:"Content"}),(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:f.response?.content||"[No content]"})]})]})]})})]})}let S=[{value:"today",label:"Today"},{value:"24h",label:"24h"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"60d",label:"60D"}];function C(){return(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(r.Qv,{}),children:(0,a.jsx)(D,{})})}function D(){let e=(0,n.useSearchParams)(),t=(0,n.useRouter)(),[s,i]=(0,l.useState)("today"),d=e.get("tab"),o=d&&["overview","logs","details"].includes(d)?d:"overview";return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)(r.Iz,{options:[{value:"overview",label:"Overview"},{value:"details",label:"Details"}],value:o,onChange:s=>{if(s===o)return;let a=new URLSearchParams(e);a.set("tab",s),t.push(`/dashboard/usage?${a.toString()}`,{scroll:!1})},className:"w-full sm:w-auto"}),"overview"===o&&(0,a.jsx)(r.Iz,{options:S,value:s,onChange:i,size:"sm",className:"w-full sm:w-auto"})]}),"overview"===o&&(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(r.Qv,{}),children:(0,a.jsx)(r.jK,{period:s,setPeriod:i,hidePeriodSelector:!0})}),"logs"===o&&(0,a.jsx)(r.gM,{}),"details"===o&&(0,a.jsx)(y,{})]})}},87618:(e,t,s)=>{Promise.resolve().then(s.bind(s,81772))}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,1330,8441,3794,7358],()=>e(e.s=87618)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9305],{19216:(e,s,n)=>{Promise.resolve().then(n.bind(n,96748)),Promise.resolve().then(n.bind(n,56319)),Promise.resolve().then(n.bind(n,56061)),Promise.resolve().then(n.bind(n,92542)),Promise.resolve().then(n.bind(n,29366)),Promise.resolve().then(n.bind(n,84588)),Promise.resolve().then(n.bind(n,40197)),Promise.resolve().then(n.bind(n,45455)),Promise.resolve().then(n.bind(n,30815)),Promise.resolve().then(n.bind(n,73579)),Promise.resolve().then(n.bind(n,92173)),Promise.resolve().then(n.bind(n,95088)),Promise.resolve().then(n.bind(n,8823)),Promise.resolve().then(n.bind(n,80752)),Promise.resolve().then(n.bind(n,23936)),Promise.resolve().then(n.bind(n,11910)),Promise.resolve().then(n.bind(n,44736)),Promise.resolve().then(n.bind(n,62899)),Promise.resolve().then(n.bind(n,94230)),Promise.resolve().then(n.bind(n,21931)),Promise.resolve().then(n.bind(n,91450)),Promise.resolve().then(n.bind(n,76361)),Promise.resolve().then(n.bind(n,25086)),Promise.resolve().then(n.bind(n,28815)),Promise.resolve().then(n.bind(n,28058)),Promise.resolve().then(n.bind(n,81127)),Promise.resolve().then(n.bind(n,72908)),Promise.resolve().then(n.bind(n,4823)),Promise.resolve().then(n.bind(n,90882)),Promise.resolve().then(n.bind(n,51825)),Promise.resolve().then(n.bind(n,23615)),Promise.resolve().then(n.bind(n,28067)),Promise.resolve().then(n.bind(n,98)),Promise.resolve().then(n.bind(n,92622)),Promise.resolve().then(n.bind(n,21110)),Promise.resolve().then(n.bind(n,38587)),Promise.resolve().then(n.bind(n,98542)),Promise.resolve().then(n.bind(n,97677)),Promise.resolve().then(n.bind(n,4809)),Promise.resolve().then(n.bind(n,28469))},28469:(e,s,n)=>{"use strict";n.d(s,{default:()=>l});var r=n(95155),i=n(12115),o=n(26430),t=n(35625);function l({children:e}){let[s]=(0,i.useState)(()=>new o.E({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}}));return(0,r.jsx)(t.Ht,{client:s,children:e})}}},e=>{e.O(0,[2574,3862,782,8500,594,6430,1321,4707,
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9305],{19216:(e,s,n)=>{Promise.resolve().then(n.bind(n,96748)),Promise.resolve().then(n.bind(n,56319)),Promise.resolve().then(n.bind(n,56061)),Promise.resolve().then(n.bind(n,92542)),Promise.resolve().then(n.bind(n,29366)),Promise.resolve().then(n.bind(n,84588)),Promise.resolve().then(n.bind(n,40197)),Promise.resolve().then(n.bind(n,45455)),Promise.resolve().then(n.bind(n,30815)),Promise.resolve().then(n.bind(n,73579)),Promise.resolve().then(n.bind(n,92173)),Promise.resolve().then(n.bind(n,95088)),Promise.resolve().then(n.bind(n,8823)),Promise.resolve().then(n.bind(n,80752)),Promise.resolve().then(n.bind(n,23936)),Promise.resolve().then(n.bind(n,11910)),Promise.resolve().then(n.bind(n,44736)),Promise.resolve().then(n.bind(n,62899)),Promise.resolve().then(n.bind(n,94230)),Promise.resolve().then(n.bind(n,21931)),Promise.resolve().then(n.bind(n,91450)),Promise.resolve().then(n.bind(n,76361)),Promise.resolve().then(n.bind(n,25086)),Promise.resolve().then(n.bind(n,28815)),Promise.resolve().then(n.bind(n,28058)),Promise.resolve().then(n.bind(n,81127)),Promise.resolve().then(n.bind(n,72908)),Promise.resolve().then(n.bind(n,4823)),Promise.resolve().then(n.bind(n,90882)),Promise.resolve().then(n.bind(n,51825)),Promise.resolve().then(n.bind(n,23615)),Promise.resolve().then(n.bind(n,28067)),Promise.resolve().then(n.bind(n,98)),Promise.resolve().then(n.bind(n,92622)),Promise.resolve().then(n.bind(n,21110)),Promise.resolve().then(n.bind(n,38587)),Promise.resolve().then(n.bind(n,98542)),Promise.resolve().then(n.bind(n,97677)),Promise.resolve().then(n.bind(n,4809)),Promise.resolve().then(n.bind(n,28469))},28469:(e,s,n)=>{"use strict";n.d(s,{default:()=>l});var r=n(95155),i=n(12115),o=n(26430),t=n(35625);function l({children:e}){let[s]=(0,i.useState)(()=>new o.E({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}}));return(0,r.jsx)(t.Ht,{client:s,children:e})}}},e=>{e.O(0,[2574,3862,782,8500,594,6430,1321,4707,1330,8441,3794,7358],()=>e(e.s=19216)),_N_E=e.O()}]);
|