@nyte-ai/ai 0.0.0-stage → 0.0.18
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/LICENSE +21 -0
- package/README.md +170 -2
- package/THIRD-PARTY-NOTICES.md +800 -0
- package/dist/chunks/account-limits-cache-031vfpt3.js +37 -0
- package/dist/chunks/account-limits-cache-09vs98g6.js +41 -0
- package/dist/chunks/account-limits-cache-0af5gqeg.js +15 -0
- package/dist/chunks/account-limits-cache-0yd6bde8.js +103 -0
- package/dist/chunks/account-limits-cache-1jv43fhh.js +22 -0
- package/dist/chunks/account-limits-cache-3ykqmnj5.js +88 -0
- package/dist/chunks/account-limits-cache-4b8ckwqw.js +293 -0
- package/dist/chunks/account-limits-cache-4fn5w63p.js +295 -0
- package/dist/chunks/account-limits-cache-4hptgd2h.js +49 -0
- package/dist/chunks/account-limits-cache-53e64mhx.js +417 -0
- package/dist/chunks/account-limits-cache-5jdhn0e1.js +562 -0
- package/dist/chunks/account-limits-cache-5rx2pfm5.js +8 -0
- package/dist/chunks/account-limits-cache-5ygxyyss.js +19 -0
- package/dist/chunks/account-limits-cache-6250ykn6.js +21 -0
- package/dist/chunks/account-limits-cache-6x05n06z.js +49 -0
- package/dist/chunks/account-limits-cache-736tdyme.js +6 -0
- package/dist/chunks/account-limits-cache-75smws02.js +213 -0
- package/dist/chunks/account-limits-cache-7z9s8j16.js +139 -0
- package/dist/chunks/account-limits-cache-8137j3zp.js +37 -0
- package/dist/chunks/account-limits-cache-8qzk56vj.js +160 -0
- package/dist/chunks/account-limits-cache-8s8bz4dr.js +36 -0
- package/dist/chunks/account-limits-cache-8vzx8k6r.js +166 -0
- package/dist/chunks/account-limits-cache-8wfqg73s.js +135 -0
- package/dist/chunks/account-limits-cache-90c9c2eb.js +50 -0
- package/dist/chunks/account-limits-cache-9wqk28n5.js +25 -0
- package/dist/chunks/account-limits-cache-a1jyaq00.js +56 -0
- package/dist/chunks/account-limits-cache-a558rjbg.js +138 -0
- package/dist/chunks/account-limits-cache-a55e14fr.js +70 -0
- package/dist/chunks/account-limits-cache-a6cgeagz.js +77 -0
- package/dist/chunks/account-limits-cache-ag5b8dja.js +38 -0
- package/dist/chunks/account-limits-cache-b0x2sfya.js +45 -0
- package/dist/chunks/account-limits-cache-b23sbrke.js +26 -0
- package/dist/chunks/account-limits-cache-b4edaybk.js +8 -0
- package/dist/chunks/account-limits-cache-bsknrh6t.js +74 -0
- package/dist/chunks/account-limits-cache-c7v93krb.js +235 -0
- package/dist/chunks/account-limits-cache-csbxvam7.js +12 -0
- package/dist/chunks/account-limits-cache-cw7q7vfy.js +293 -0
- package/dist/chunks/account-limits-cache-d1ypzqzp.js +27 -0
- package/dist/chunks/account-limits-cache-d2a51dka.js +17 -0
- package/dist/chunks/account-limits-cache-dejeygdt.js +114 -0
- package/dist/chunks/account-limits-cache-eejm0vth.js +11 -0
- package/dist/chunks/account-limits-cache-ehy0ze2b.js +33 -0
- package/dist/chunks/account-limits-cache-emg5b4hj.js +53 -0
- package/dist/chunks/account-limits-cache-eqwweapz.js +6 -0
- package/dist/chunks/account-limits-cache-eyx1jcxc.js +8 -0
- package/dist/chunks/account-limits-cache-f9z00x8c.js +36 -0
- package/dist/chunks/account-limits-cache-fbkaq46e.js +113 -0
- package/dist/chunks/account-limits-cache-fdwad56n.js +399 -0
- package/dist/chunks/account-limits-cache-fht68jp2.js +22 -0
- package/dist/chunks/account-limits-cache-fp03ztsw.js +17 -0
- package/dist/chunks/account-limits-cache-fsktnetm.js +69 -0
- package/dist/chunks/account-limits-cache-fvadc36m.js +110 -0
- package/dist/chunks/account-limits-cache-ghe9ne4j.js +69 -0
- package/dist/chunks/account-limits-cache-gknnm1kv.js +13 -0
- package/dist/chunks/account-limits-cache-gqsrbky9.js +40 -0
- package/dist/chunks/account-limits-cache-gr671dr2.js +0 -0
- package/dist/chunks/account-limits-cache-gs8a3fhw.js +32 -0
- package/dist/chunks/account-limits-cache-gsa5tzck.js +37 -0
- package/dist/chunks/account-limits-cache-h92bzz1j.js +235 -0
- package/dist/chunks/account-limits-cache-hemxtapd.js +142 -0
- package/dist/chunks/account-limits-cache-hj1h48sc.js +92 -0
- package/dist/chunks/account-limits-cache-hj3ek3ty.js +128 -0
- package/dist/chunks/account-limits-cache-hwehc67r.js +509 -0
- package/dist/chunks/account-limits-cache-hyzn1jmk.js +46 -0
- package/dist/chunks/account-limits-cache-j2bt392s.js +63 -0
- package/dist/chunks/account-limits-cache-k0pkzhbx.js +74 -0
- package/dist/chunks/account-limits-cache-kjx405q0.js +277 -0
- package/dist/chunks/account-limits-cache-ks1sjym9.js +37 -0
- package/dist/chunks/account-limits-cache-me1x57bs.js +89 -0
- package/dist/chunks/account-limits-cache-n3yk6g5c.js +314 -0
- package/dist/chunks/account-limits-cache-nbhht7xz.js +72 -0
- package/dist/chunks/account-limits-cache-nbkyhs6v.js +42 -0
- package/dist/chunks/account-limits-cache-nn9jebsj.js +26 -0
- package/dist/chunks/account-limits-cache-nxkprk3g.js +13 -0
- package/dist/chunks/account-limits-cache-nyy770yd.js +38 -0
- package/dist/chunks/account-limits-cache-pfa86y8e.js +45 -0
- package/dist/chunks/account-limits-cache-pfr14mcn.js +59 -0
- package/dist/chunks/account-limits-cache-q1ebtvet.js +8 -0
- package/dist/chunks/account-limits-cache-q63mc41j.js +51 -0
- package/dist/chunks/account-limits-cache-re8hpzwn.js +104 -0
- package/dist/chunks/account-limits-cache-rz8p1g5y.js +9 -0
- package/dist/chunks/account-limits-cache-skbfmzqe.js +7 -0
- package/dist/chunks/account-limits-cache-tc38g0ca.js +20 -0
- package/dist/chunks/account-limits-cache-v4n30az2.js +24 -0
- package/dist/chunks/account-limits-cache-vwgfz727.js +281 -0
- package/dist/chunks/account-limits-cache-x9fvb3s5.js +8 -0
- package/dist/chunks/account-limits-cache-xds88kxd.js +209 -0
- package/dist/chunks/account-limits-cache-xz65wyd1.js +428 -0
- package/dist/chunks/account-limits-cache-ydq8p8qp.js +39 -0
- package/dist/chunks/account-limits-cache-ykbqsvv6.js +134 -0
- package/dist/chunks/account-limits-cache-za42x8a3.js +25 -0
- package/dist/chunks/account-limits-cache-zcbkmrvy.js +79 -0
- package/dist/chunks/account-limits-cache-zgzptd0z.js +62 -0
- package/dist/chunks/account-limits-cache-zn01kscn.js +252 -0
- package/dist/chunks/account-limits-cache-zpjmeyt0.js +113 -0
- package/dist/chunks/account-limits-cache-zqdb4yh4.js +8 -0
- package/dist/src/account-limits-cache.d.ts +16 -0
- package/dist/src/account-limits-cache.js +7 -0
- package/dist/src/api/anthropic-client.d.ts +25 -0
- package/dist/src/api/anthropic-client.js +30 -0
- package/dist/src/api/anthropic-convert.d.ts +17 -0
- package/dist/src/api/anthropic-convert.js +14 -0
- package/dist/src/api/anthropic-events.d.ts +101 -0
- package/dist/src/api/anthropic-events.js +11 -0
- package/dist/src/api/anthropic-messages.d.ts +88 -0
- package/dist/src/api/anthropic-messages.js +578 -0
- package/dist/src/api/anthropic-messages.lazy.d.ts +2 -0
- package/dist/src/api/anthropic-messages.lazy.js +11 -0
- package/dist/src/api/assistant-stream.d.ts +23 -0
- package/dist/src/api/assistant-stream.js +15 -0
- package/dist/src/api/claude-code.d.ts +12 -0
- package/dist/src/api/claude-code.js +12 -0
- package/dist/src/api/cloudflare.d.ts +8 -0
- package/dist/src/api/cloudflare.js +11 -0
- package/dist/src/api/constrained-sampling.d.ts +24 -0
- package/dist/src/api/constrained-sampling.js +16 -0
- package/dist/src/api/deferred.d.ts +7 -0
- package/dist/src/api/deferred.js +10 -0
- package/dist/src/api/github-copilot-headers.d.ts +15 -0
- package/dist/src/api/github-copilot-headers.js +12 -0
- package/dist/src/api/google-generative-ai.d.ts +22 -0
- package/dist/src/api/google-generative-ai.js +583 -0
- package/dist/src/api/google-generative-ai.lazy.d.ts +2 -0
- package/dist/src/api/google-generative-ai.lazy.js +11 -0
- package/dist/src/api/lazy.d.ts +18 -0
- package/dist/src/api/lazy.js +12 -0
- package/dist/src/api/openai-codex-compact.d.ts +14 -0
- package/dist/src/api/openai-codex-compact.js +389 -0
- package/dist/src/api/openai-codex-compaction-error.d.ts +7 -0
- package/dist/src/api/openai-codex-compaction-error.js +6 -0
- package/dist/src/api/openai-codex-protocol.d.ts +125 -0
- package/dist/src/api/openai-codex-protocol.js +48 -0
- package/dist/src/api/openai-codex-responses.d.ts +4 -0
- package/dist/src/api/openai-codex-responses.js +175 -0
- package/dist/src/api/openai-codex-responses.lazy.d.ts +2 -0
- package/dist/src/api/openai-codex-responses.lazy.js +11 -0
- package/dist/src/api/openai-codex-websocket.d.ts +13 -0
- package/dist/src/api/openai-codex-websocket.js +37 -0
- package/dist/src/api/openai-codex-wire.d.ts +44 -0
- package/dist/src/api/openai-codex-wire.js +34 -0
- package/dist/src/api/openai-compact.d.ts +9 -0
- package/dist/src/api/openai-compact.js +12 -0
- package/dist/src/api/openai-completions-convert.d.ts +58 -0
- package/dist/src/api/openai-completions-convert.js +21 -0
- package/dist/src/api/openai-completions-params.d.ts +29 -0
- package/dist/src/api/openai-completions-params.js +20 -0
- package/dist/src/api/openai-completions-reasoning.d.ts +54 -0
- package/dist/src/api/openai-completions-reasoning.js +22 -0
- package/dist/src/api/openai-completions.d.ts +22 -0
- package/dist/src/api/openai-completions.js +484 -0
- package/dist/src/api/openai-completions.lazy.d.ts +5 -0
- package/dist/src/api/openai-completions.lazy.js +11 -0
- package/dist/src/api/openai-prompt-cache.d.ts +1 -0
- package/dist/src/api/openai-prompt-cache.js +6 -0
- package/dist/src/api/openai-responses-convert.d.ts +58 -0
- package/dist/src/api/openai-responses-convert.js +16 -0
- package/dist/src/api/openai-responses-events.d.ts +379 -0
- package/dist/src/api/openai-responses-events.js +12 -0
- package/dist/src/api/openai-responses-stream.d.ts +36 -0
- package/dist/src/api/openai-responses-stream.js +25 -0
- package/dist/src/api/openai-responses.d.ts +18 -0
- package/dist/src/api/openai-responses.js +276 -0
- package/dist/src/api/openai-responses.lazy.d.ts +2 -0
- package/dist/src/api/openai-responses.lazy.js +11 -0
- package/dist/src/api/simple-options.d.ts +17 -0
- package/dist/src/api/simple-options.js +18 -0
- package/dist/src/api/token-count.d.ts +5 -0
- package/dist/src/api/token-count.js +8 -0
- package/dist/src/api/transform-messages.d.ts +9 -0
- package/dist/src/api/transform-messages.js +6 -0
- package/dist/src/api-options.d.ts +27 -0
- package/dist/src/api-options.js +0 -0
- package/dist/src/auth/context.d.ts +11 -0
- package/dist/src/auth/context.js +6 -0
- package/dist/src/auth/credential-store.d.ts +17 -0
- package/dist/src/auth/credential-store.js +7 -0
- package/dist/src/auth/helpers.d.ts +24 -0
- package/dist/src/auth/helpers.js +8 -0
- package/dist/src/auth/oauth/anthropic.d.ts +7 -0
- package/dist/src/auth/oauth/anthropic.js +12 -0
- package/dist/src/auth/oauth/authorization-input.d.ts +14 -0
- package/dist/src/auth/oauth/authorization-input.js +6 -0
- package/dist/src/auth/oauth/device-code.d.ts +29 -0
- package/dist/src/auth/oauth/device-code.js +9 -0
- package/dist/src/auth/oauth/github-copilot.d.ts +23 -0
- package/dist/src/auth/oauth/github-copilot.js +12 -0
- package/dist/src/auth/oauth/load.d.ts +14 -0
- package/dist/src/auth/oauth/load.js +10 -0
- package/dist/src/auth/oauth/oauth-page.d.ts +13 -0
- package/dist/src/auth/oauth/oauth-page.js +8 -0
- package/dist/src/auth/oauth/openai-codex.d.ts +10 -0
- package/dist/src/auth/oauth/openai-codex.js +18 -0
- package/dist/src/auth/oauth/pkce.d.ts +12 -0
- package/dist/src/auth/oauth/pkce.js +6 -0
- package/dist/src/auth/resolve.d.ts +38 -0
- package/dist/src/auth/resolve.js +12 -0
- package/dist/src/auth/store.d.ts +29 -0
- package/dist/src/auth/store.js +10 -0
- package/dist/src/auth/types.d.ts +291 -0
- package/dist/src/auth/types.js +8 -0
- package/dist/src/auth/verify.d.ts +13 -0
- package/dist/src/auth/verify.js +7 -0
- package/dist/src/bun-oauth.d.ts +2 -0
- package/dist/src/bun-oauth.js +25 -0
- package/dist/src/env-api-keys.d.ts +32 -0
- package/dist/src/env-api-keys.js +27 -0
- package/dist/src/file-models-store.d.ts +18 -0
- package/dist/src/file-models-store.js +9 -0
- package/dist/src/index.d.ts +62 -0
- package/dist/src/index.js +372 -0
- package/dist/src/model-capabilities.d.ts +21 -0
- package/dist/src/model-capabilities.js +14 -0
- package/dist/src/model-pricing.d.ts +6 -0
- package/dist/src/model-pricing.js +10 -0
- package/dist/src/model-variants.d.ts +21 -0
- package/dist/src/model-variants.js +19 -0
- package/dist/src/models-refresh.d.ts +27 -0
- package/dist/src/models-refresh.js +9 -0
- package/dist/src/models-store.d.ts +31 -0
- package/dist/src/models-store.js +6 -0
- package/dist/src/models-types.d.ts +206 -0
- package/dist/src/models-types.js +0 -0
- package/dist/src/models.d.ts +7 -0
- package/dist/src/models.js +44 -0
- package/dist/src/prompt-cache.d.ts +5 -0
- package/dist/src/prompt-cache.js +9 -0
- package/dist/src/provider.d.ts +23 -0
- package/dist/src/provider.js +14 -0
- package/dist/src/providers/account-limits.d.ts +13 -0
- package/dist/src/providers/account-limits.js +8 -0
- package/dist/src/providers/anthropic-limits.d.ts +9 -0
- package/dist/src/providers/anthropic-limits.js +10 -0
- package/dist/src/providers/anthropic.d.ts +2 -0
- package/dist/src/providers/anthropic.js +25 -0
- package/dist/src/providers/github-copilot-catalog.d.ts +5 -0
- package/dist/src/providers/github-copilot-catalog.js +7 -0
- package/dist/src/providers/github-copilot.d.ts +2 -0
- package/dist/src/providers/github-copilot.js +23 -0
- package/dist/src/providers/nyte-catalog.d.ts +15 -0
- package/dist/src/providers/nyte-catalog.js +63 -0
- package/dist/src/providers/openai-codex-limits.d.ts +8 -0
- package/dist/src/providers/openai-codex-limits.js +14 -0
- package/dist/src/providers/openai-codex.d.ts +2 -0
- package/dist/src/providers/openai-codex.js +23 -0
- package/dist/src/providers/openai.d.ts +2 -0
- package/dist/src/providers/openai.js +19 -0
- package/dist/src/providers/opencode-go.d.ts +5 -0
- package/dist/src/providers/opencode-go.js +22 -0
- package/dist/src/providers/opencode-headers.d.ts +5 -0
- package/dist/src/providers/opencode-headers.js +6 -0
- package/dist/src/providers/opencode.d.ts +14 -0
- package/dist/src/providers/opencode.js +23 -0
- package/dist/src/providers/openrouter.d.ts +2 -0
- package/dist/src/providers/openrouter.js +19 -0
- package/dist/src/providers/vercel-ai-gateway.d.ts +3 -0
- package/dist/src/providers/vercel-ai-gateway.js +19 -0
- package/dist/src/session-resources.d.ts +9 -0
- package/dist/src/session-resources.js +10 -0
- package/dist/src/types.d.ts +210 -0
- package/dist/src/types.js +1 -0
- package/dist/src/utils/abort.d.ts +12 -0
- package/dist/src/utils/abort.js +10 -0
- package/dist/src/utils/deferred-tools.d.ts +11 -0
- package/dist/src/utils/deferred-tools.js +6 -0
- package/dist/src/utils/diagnostics.d.ts +11 -0
- package/dist/src/utils/diagnostics.js +12 -0
- package/dist/src/utils/error-body.d.ts +26 -0
- package/dist/src/utils/error-body.js +10 -0
- package/dist/src/utils/estimate.d.ts +20 -0
- package/dist/src/utils/estimate.js +14 -0
- package/dist/src/utils/event-stream.d.ts +22 -0
- package/dist/src/utils/event-stream.js +11 -0
- package/dist/src/utils/failure.d.ts +49 -0
- package/dist/src/utils/failure.js +10 -0
- package/dist/src/utils/fifo-queue.d.ts +11 -0
- package/dist/src/utils/fifo-queue.js +6 -0
- package/dist/src/utils/hash.d.ts +5 -0
- package/dist/src/utils/hash.js +6 -0
- package/dist/src/utils/headers.d.ts +12 -0
- package/dist/src/utils/headers.js +14 -0
- package/dist/src/utils/json-parse.d.ts +33 -0
- package/dist/src/utils/json-parse.js +12 -0
- package/dist/src/utils/node-http-proxy.d.ts +6 -0
- package/dist/src/utils/node-http-proxy.js +9 -0
- package/dist/src/utils/nyte-home.d.ts +2 -0
- package/dist/src/utils/nyte-home.js +6 -0
- package/dist/src/utils/nyte-user-agent.d.ts +1 -0
- package/dist/src/utils/nyte-user-agent.js +6 -0
- package/dist/src/utils/overflow.d.ts +18 -0
- package/dist/src/utils/overflow.js +9 -0
- package/dist/src/utils/provider-env.d.ts +9 -0
- package/dist/src/utils/provider-env.js +6 -0
- package/dist/src/utils/provider-retry.d.ts +22 -0
- package/dist/src/utils/provider-retry.js +9 -0
- package/dist/src/utils/retry.d.ts +66 -0
- package/dist/src/utils/retry.js +18 -0
- package/dist/src/utils/sanitize-unicode.d.ts +24 -0
- package/dist/src/utils/sanitize-unicode.js +6 -0
- package/dist/src/utils/sse.d.ts +21 -0
- package/dist/src/utils/sse.js +6 -0
- package/dist/src/utils/text.d.ts +5 -0
- package/dist/src/utils/text.js +10 -0
- package/dist/src/utils/transcript.d.ts +5 -0
- package/dist/src/utils/transcript.js +36 -0
- package/dist/src/utils/typebox-helpers.d.ts +19 -0
- package/dist/src/utils/typebox-helpers.js +6 -0
- package/dist/src/utils/uuid.d.ts +2 -0
- package/dist/src/utils/uuid.js +6 -0
- package/dist/src/utils/validation.d.ts +13 -0
- package/dist/src/utils/validation.js +8 -0
- package/package.json +152 -3
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// src/auth/oauth/oauth-page.ts
|
|
2
|
+
function escapeHtml(value) {
|
|
3
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
4
|
+
}
|
|
5
|
+
function renderPage(options) {
|
|
6
|
+
const heading = escapeHtml(options.heading);
|
|
7
|
+
const status = escapeHtml(options.status);
|
|
8
|
+
const message = escapeHtml(options.message);
|
|
9
|
+
const footer = escapeHtml(options.footer);
|
|
10
|
+
const details = options.details ? escapeHtml(options.details) : undefined;
|
|
11
|
+
const isError = options.kind === "error";
|
|
12
|
+
return `<!doctype html>
|
|
13
|
+
<html lang="en">
|
|
14
|
+
<head>
|
|
15
|
+
<meta charset="utf-8" />
|
|
16
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
17
|
+
<meta name="robots" content="noindex" />
|
|
18
|
+
<title>${heading} · Nyte</title>
|
|
19
|
+
<style>
|
|
20
|
+
:root {
|
|
21
|
+
color-scheme: light dark;
|
|
22
|
+
--bg: #eeeeee;
|
|
23
|
+
--card: #fcfcfc;
|
|
24
|
+
--ink: #141414;
|
|
25
|
+
--dim: #767676;
|
|
26
|
+
--rule: #a5a5a533;
|
|
27
|
+
--tick: #a5a5a5;
|
|
28
|
+
--ok: #378e23;
|
|
29
|
+
--err: #c3691e;
|
|
30
|
+
--wash: #26262608;
|
|
31
|
+
--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
32
|
+
}
|
|
33
|
+
@media (prefers-color-scheme: dark) {
|
|
34
|
+
:root {
|
|
35
|
+
--bg: #141414;
|
|
36
|
+
--card: #1c1c1c;
|
|
37
|
+
--ink: #e1e1e1;
|
|
38
|
+
--dim: #8a8a8a;
|
|
39
|
+
--rule: #58585899;
|
|
40
|
+
--tick: #585858;
|
|
41
|
+
--ok: #9ece6a;
|
|
42
|
+
--err: #ff9e64;
|
|
43
|
+
--wash: #e1e1e10a;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
* { box-sizing: border-box; }
|
|
47
|
+
html, body { height: 100%; }
|
|
48
|
+
body {
|
|
49
|
+
margin: 0;
|
|
50
|
+
display: grid;
|
|
51
|
+
place-items: center;
|
|
52
|
+
padding: 24px;
|
|
53
|
+
background: var(--bg);
|
|
54
|
+
color: var(--ink);
|
|
55
|
+
font-family: var(--font);
|
|
56
|
+
-webkit-font-smoothing: antialiased;
|
|
57
|
+
}
|
|
58
|
+
main {
|
|
59
|
+
width: 100%;
|
|
60
|
+
max-width: 640px;
|
|
61
|
+
background: var(--card);
|
|
62
|
+
border: 1px solid var(--rule);
|
|
63
|
+
position: relative;
|
|
64
|
+
}
|
|
65
|
+
main::before, main::after {
|
|
66
|
+
content: "";
|
|
67
|
+
position: absolute;
|
|
68
|
+
top: -1px;
|
|
69
|
+
width: 1px;
|
|
70
|
+
height: 14px;
|
|
71
|
+
background: var(--tick);
|
|
72
|
+
}
|
|
73
|
+
main::before { left: -1px; }
|
|
74
|
+
main::after { right: -1px; }
|
|
75
|
+
header {
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
justify-content: space-between;
|
|
79
|
+
padding: 14px 24px;
|
|
80
|
+
border-bottom: 1px solid var(--rule);
|
|
81
|
+
font-size: 13px;
|
|
82
|
+
line-height: 1;
|
|
83
|
+
color: var(--dim);
|
|
84
|
+
}
|
|
85
|
+
.brand { color: var(--ink); font-weight: 500; }
|
|
86
|
+
.status { display: flex; align-items: center; gap: 7px; }
|
|
87
|
+
.status::before {
|
|
88
|
+
content: "";
|
|
89
|
+
width: 7px;
|
|
90
|
+
height: 7px;
|
|
91
|
+
background: var(--ok);
|
|
92
|
+
}
|
|
93
|
+
.status.err::before { background: var(--err); }
|
|
94
|
+
section { padding: 36px 24px 32px; }
|
|
95
|
+
h1 {
|
|
96
|
+
margin: 0 0 12px;
|
|
97
|
+
font-size: 26px;
|
|
98
|
+
line-height: 1.15;
|
|
99
|
+
font-weight: 400;
|
|
100
|
+
letter-spacing: -0.02em;
|
|
101
|
+
text-wrap: balance;
|
|
102
|
+
}
|
|
103
|
+
p {
|
|
104
|
+
margin: 0;
|
|
105
|
+
font-size: 16px;
|
|
106
|
+
line-height: 1.5;
|
|
107
|
+
max-width: 48ch;
|
|
108
|
+
color: var(--dim);
|
|
109
|
+
text-wrap: pretty;
|
|
110
|
+
}
|
|
111
|
+
.details {
|
|
112
|
+
margin: 20px -24px -32px;
|
|
113
|
+
padding: 14px 24px;
|
|
114
|
+
border-top: 1px solid var(--rule);
|
|
115
|
+
background: var(--wash);
|
|
116
|
+
font-size: 13px;
|
|
117
|
+
line-height: 1.5;
|
|
118
|
+
color: var(--dim);
|
|
119
|
+
white-space: pre-wrap;
|
|
120
|
+
word-break: break-word;
|
|
121
|
+
}
|
|
122
|
+
footer {
|
|
123
|
+
padding: 12px 24px;
|
|
124
|
+
border-top: 1px solid var(--rule);
|
|
125
|
+
font-size: 13px;
|
|
126
|
+
color: var(--dim);
|
|
127
|
+
}
|
|
128
|
+
</style>
|
|
129
|
+
</head>
|
|
130
|
+
<body>
|
|
131
|
+
<main data-kind="${options.kind}">
|
|
132
|
+
<header>
|
|
133
|
+
<div class="brand">Nyte</div>
|
|
134
|
+
<div class="status${isError ? " err" : ""}">${status}</div>
|
|
135
|
+
</header>
|
|
136
|
+
<section>
|
|
137
|
+
<h1>${heading}</h1>
|
|
138
|
+
<p>${message}</p>
|
|
139
|
+
${details ? `<div class="details">${details}</div>` : ""}
|
|
140
|
+
</section>
|
|
141
|
+
<footer>${footer}</footer>
|
|
142
|
+
</main>
|
|
143
|
+
</body>
|
|
144
|
+
</html>`;
|
|
145
|
+
}
|
|
146
|
+
function oauthSuccessHtml2(options) {
|
|
147
|
+
return renderPage({
|
|
148
|
+
kind: "success",
|
|
149
|
+
status: "Signed in",
|
|
150
|
+
heading: `Signed in to ${options.provider}`,
|
|
151
|
+
message: "Nyte received the callback and is finishing up. You can close this tab.",
|
|
152
|
+
footer: "Return to the terminal."
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function oauthErrorHtml2(message, details) {
|
|
156
|
+
return renderPage({
|
|
157
|
+
kind: "error",
|
|
158
|
+
status: "Not signed in",
|
|
159
|
+
heading: "Sign-in did not complete",
|
|
160
|
+
message,
|
|
161
|
+
footer: "The terminal has the full error.",
|
|
162
|
+
details
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export { oauthSuccessHtml2, oauthErrorHtml2 };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
anthropicMessagesApi2
|
|
3
|
+
} from "./account-limits-cache-zqdb4yh4.js";
|
|
4
|
+
import {
|
|
5
|
+
usesClaudeSubscription2
|
|
6
|
+
} from "./account-limits-cache-ks1sjym9.js";
|
|
7
|
+
import {
|
|
8
|
+
fetchAnthropicAccountLimits2
|
|
9
|
+
} from "./account-limits-cache-re8hpzwn.js";
|
|
10
|
+
import {
|
|
11
|
+
lazyOAuth2
|
|
12
|
+
} from "./account-limits-cache-6x05n06z.js";
|
|
13
|
+
import {
|
|
14
|
+
loadAnthropicOAuth2
|
|
15
|
+
} from "./account-limits-cache-v4n30az2.js";
|
|
16
|
+
import {
|
|
17
|
+
verifyWithRequest2
|
|
18
|
+
} from "./account-limits-cache-ydq8p8qp.js";
|
|
19
|
+
import {
|
|
20
|
+
ANTHROPIC_AUTH_TOKEN_ENV2,
|
|
21
|
+
ANTHROPIC_OAUTH_TOKEN_ENV2,
|
|
22
|
+
ANTHROPIC_API_KEY_ENV2,
|
|
23
|
+
ANTHROPIC_FEDERATION_RULE_ID_ENV2,
|
|
24
|
+
ANTHROPIC_ORGANIZATION_ID_ENV2,
|
|
25
|
+
ANTHROPIC_SERVICE_ACCOUNT_ID_ENV2,
|
|
26
|
+
ANTHROPIC_IDENTITY_TOKEN_FILE_ENV2,
|
|
27
|
+
ANTHROPIC_WORKSPACE_ID_ENV2
|
|
28
|
+
} from "./account-limits-cache-hyzn1jmk.js";
|
|
29
|
+
import {
|
|
30
|
+
createProvider2
|
|
31
|
+
} from "./account-limits-cache-ykbqsvv6.js";
|
|
32
|
+
|
|
33
|
+
// src/providers/anthropic.ts
|
|
34
|
+
function anthropicApiKeyAuth() {
|
|
35
|
+
return {
|
|
36
|
+
name: "Anthropic API key",
|
|
37
|
+
login: async (interaction) => {
|
|
38
|
+
interaction.signal.throwIfAborted();
|
|
39
|
+
const key = await interaction.prompt({ type: "secret", message: "Enter Anthropic API key" });
|
|
40
|
+
interaction.signal.throwIfAborted();
|
|
41
|
+
return { type: "api_key", key };
|
|
42
|
+
},
|
|
43
|
+
resolve: async ({ ctx, credential, signal }) => {
|
|
44
|
+
signal.throwIfAborted();
|
|
45
|
+
if (credential?.key) {
|
|
46
|
+
return {
|
|
47
|
+
auth: { apiKey: credential.key },
|
|
48
|
+
env: credential.env,
|
|
49
|
+
source: "stored credential"
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const authToken = await ctx.env(ANTHROPIC_AUTH_TOKEN_ENV2);
|
|
53
|
+
signal.throwIfAborted();
|
|
54
|
+
if (authToken) {
|
|
55
|
+
return {
|
|
56
|
+
auth: { headers: { Authorization: `Bearer ${authToken}` } },
|
|
57
|
+
source: ANTHROPIC_AUTH_TOKEN_ENV2
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
for (const envVar of [ANTHROPIC_OAUTH_TOKEN_ENV2, ANTHROPIC_API_KEY_ENV2]) {
|
|
61
|
+
const apiKey = await ctx.env(envVar);
|
|
62
|
+
signal.throwIfAborted();
|
|
63
|
+
if (apiKey)
|
|
64
|
+
return { auth: { apiKey }, source: envVar };
|
|
65
|
+
}
|
|
66
|
+
const federation = {};
|
|
67
|
+
for (const envVar of [
|
|
68
|
+
ANTHROPIC_FEDERATION_RULE_ID_ENV2,
|
|
69
|
+
ANTHROPIC_ORGANIZATION_ID_ENV2,
|
|
70
|
+
ANTHROPIC_IDENTITY_TOKEN_FILE_ENV2
|
|
71
|
+
]) {
|
|
72
|
+
const value = await ctx.env(envVar);
|
|
73
|
+
signal.throwIfAborted();
|
|
74
|
+
if (!value)
|
|
75
|
+
return;
|
|
76
|
+
federation[envVar] = value;
|
|
77
|
+
}
|
|
78
|
+
for (const envVar of [ANTHROPIC_SERVICE_ACCOUNT_ID_ENV2, ANTHROPIC_WORKSPACE_ID_ENV2]) {
|
|
79
|
+
const value = await ctx.env(envVar);
|
|
80
|
+
signal.throwIfAborted();
|
|
81
|
+
if (value)
|
|
82
|
+
federation[envVar] = value;
|
|
83
|
+
}
|
|
84
|
+
return { auth: {}, env: federation, source: "workload identity federation" };
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
var ANTHROPIC_BASE_URL = "https://api.anthropic.com";
|
|
89
|
+
var verifyAnthropicAuth = async ({ auth, signal }) => {
|
|
90
|
+
if (auth.apiKey !== undefined && usesClaudeSubscription2(auth.apiKey)) {
|
|
91
|
+
return { ok: true, verified: false, detail: "OAuth credential" };
|
|
92
|
+
}
|
|
93
|
+
return verifyWithRequest2({
|
|
94
|
+
provider: "Anthropic",
|
|
95
|
+
url: `${auth.baseUrl ?? ANTHROPIC_BASE_URL}/v1/models`,
|
|
96
|
+
headers: {
|
|
97
|
+
...auth.headers,
|
|
98
|
+
"anthropic-version": "2023-06-01",
|
|
99
|
+
...auth.apiKey ? { "x-api-key": auth.apiKey } : {}
|
|
100
|
+
},
|
|
101
|
+
signal
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
function anthropicProvider2() {
|
|
105
|
+
return createProvider2({
|
|
106
|
+
id: "anthropic",
|
|
107
|
+
name: "Anthropic",
|
|
108
|
+
baseUrl: ANTHROPIC_BASE_URL,
|
|
109
|
+
promptCache: {
|
|
110
|
+
minimumRetentionMs: { short: 5 * 60000, long: 60 * 60000 }
|
|
111
|
+
},
|
|
112
|
+
auth: {
|
|
113
|
+
apiKey: anthropicApiKeyAuth(),
|
|
114
|
+
oauth: lazyOAuth2({
|
|
115
|
+
name: "Anthropic (Claude Pro/Max)",
|
|
116
|
+
isSubscription: true,
|
|
117
|
+
load: loadAnthropicOAuth2
|
|
118
|
+
}),
|
|
119
|
+
verify: verifyAnthropicAuth
|
|
120
|
+
},
|
|
121
|
+
fetchAccountLimits: async ({ auth, signal }) => {
|
|
122
|
+
const authorization = Object.entries(auth.headers ?? {}).find(([name]) => name.toLowerCase() === "authorization")?.[1];
|
|
123
|
+
const token = auth.apiKey ?? authorization?.replace(/^Bearer\s+/u, "");
|
|
124
|
+
if (!token || !usesClaudeSubscription2(token))
|
|
125
|
+
return;
|
|
126
|
+
return fetchAnthropicAccountLimits2({
|
|
127
|
+
provider: "anthropic",
|
|
128
|
+
baseUrl: auth.baseUrl ?? ANTHROPIC_BASE_URL
|
|
129
|
+
}, { apiKey: token, headers: auth.headers, signal });
|
|
130
|
+
},
|
|
131
|
+
api: { "anthropic-messages": anthropicMessagesApi2() }
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export { anthropicProvider2 };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AssistantMessageEventStream2
|
|
3
|
+
} from "./account-limits-cache-a6cgeagz.js";
|
|
4
|
+
import {
|
|
5
|
+
emptyAssistantOutput2
|
|
6
|
+
} from "./account-limits-cache-fsktnetm.js";
|
|
7
|
+
|
|
8
|
+
// src/api/lazy.ts
|
|
9
|
+
function lazyStream2(model, setup) {
|
|
10
|
+
const outer = new AssistantMessageEventStream2;
|
|
11
|
+
setup().then(async (inner) => {
|
|
12
|
+
for await (const event of inner)
|
|
13
|
+
outer.push(event);
|
|
14
|
+
outer.end(await inner.result());
|
|
15
|
+
}).catch((cause) => {
|
|
16
|
+
const message = {
|
|
17
|
+
...emptyAssistantOutput2(model),
|
|
18
|
+
stopReason: "error",
|
|
19
|
+
errorMessage: cause instanceof Error ? cause.message : String(cause)
|
|
20
|
+
};
|
|
21
|
+
outer.push({ type: "error", reason: "error", error: message });
|
|
22
|
+
outer.end(message);
|
|
23
|
+
});
|
|
24
|
+
return outer;
|
|
25
|
+
}
|
|
26
|
+
function lazyApi2(load, capabilities) {
|
|
27
|
+
const api = {
|
|
28
|
+
stream: (model, context, options) => lazyStream2(model, async () => (await load()).stream(model, context, options)),
|
|
29
|
+
streamSimple: (model, context, options) => lazyStream2(model, async () => (await load()).streamSimple(model, context, options))
|
|
30
|
+
};
|
|
31
|
+
if (capabilities?.fetchDeferred) {
|
|
32
|
+
api.fetchDeferred = (model, handle, options) => lazyStream2(model, async () => {
|
|
33
|
+
const implementation = await load();
|
|
34
|
+
if (!implementation.fetchDeferred)
|
|
35
|
+
throw new Error("API does not support deferred responses");
|
|
36
|
+
return implementation.fetchDeferred(model, handle, options);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (capabilities?.cancelDeferred) {
|
|
40
|
+
api.cancelDeferred = async (model, handle, options) => {
|
|
41
|
+
const implementation = await load();
|
|
42
|
+
if (!implementation.cancelDeferred)
|
|
43
|
+
throw new Error("API cannot cancel deferred responses");
|
|
44
|
+
await implementation.cancelDeferred(model, handle, options);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return api;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { lazyStream2, lazyApi2 };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/utils/diagnostics.ts
|
|
2
|
+
function formatThrownValue2(cause) {
|
|
3
|
+
if (cause instanceof Error)
|
|
4
|
+
return cause.message || cause.name;
|
|
5
|
+
return String(cause);
|
|
6
|
+
}
|
|
7
|
+
function extractDiagnosticError2(cause) {
|
|
8
|
+
if (!(cause instanceof Error))
|
|
9
|
+
return { name: "ThrownValue", message: formatThrownValue2(cause) };
|
|
10
|
+
const code = "code" in cause ? cause.code : undefined;
|
|
11
|
+
return {
|
|
12
|
+
name: cause.name || undefined,
|
|
13
|
+
message: cause.message || cause.name,
|
|
14
|
+
stack: cause.stack,
|
|
15
|
+
code: typeof code === "string" || typeof code === "number" ? code : undefined
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function createAssistantMessageDiagnostic2(type, cause, details) {
|
|
19
|
+
return { type, timestamp: Date.now(), error: extractDiagnosticError2(cause), details };
|
|
20
|
+
}
|
|
21
|
+
function appendAssistantMessageDiagnostic2(message, diagnostic) {
|
|
22
|
+
message.diagnostics = [...message.diagnostics ?? [], diagnostic];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { formatThrownValue2, extractDiagnosticError2, createAssistantMessageDiagnostic2, appendAssistantMessageDiagnostic2 };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
anthropicMessagesApi2
|
|
3
|
+
} from "./account-limits-cache-zqdb4yh4.js";
|
|
4
|
+
import {
|
|
5
|
+
openAICompletionsApi2
|
|
6
|
+
} from "./account-limits-cache-eyx1jcxc.js";
|
|
7
|
+
import {
|
|
8
|
+
openAIResponsesApi2
|
|
9
|
+
} from "./account-limits-cache-q1ebtvet.js";
|
|
10
|
+
import {
|
|
11
|
+
envApiKeyAuth2
|
|
12
|
+
} from "./account-limits-cache-6x05n06z.js";
|
|
13
|
+
import {
|
|
14
|
+
GITHUB_COPILOT_DEFAULT_ORIGIN2,
|
|
15
|
+
GITHUB_COPILOT_HEADERS2
|
|
16
|
+
} from "./account-limits-cache-za42x8a3.js";
|
|
17
|
+
import {
|
|
18
|
+
matchesCopilotCredential2,
|
|
19
|
+
githubCopilotOAuth2
|
|
20
|
+
} from "./account-limits-cache-cw7q7vfy.js";
|
|
21
|
+
import {
|
|
22
|
+
createProvider2
|
|
23
|
+
} from "./account-limits-cache-ykbqsvv6.js";
|
|
24
|
+
|
|
25
|
+
// src/providers/github-copilot.ts
|
|
26
|
+
function githubCopilotProvider2(options = {}) {
|
|
27
|
+
let getKnownModelIds = () => new Set;
|
|
28
|
+
const provider = createProvider2({
|
|
29
|
+
id: "github-copilot",
|
|
30
|
+
name: "GitHub Copilot",
|
|
31
|
+
baseUrl: GITHUB_COPILOT_DEFAULT_ORIGIN2,
|
|
32
|
+
headers: GITHUB_COPILOT_HEADERS2,
|
|
33
|
+
promptCache: { minimumRetentionMs: { short: 5 * 60000, long: 5 * 60000 } },
|
|
34
|
+
auth: {
|
|
35
|
+
apiKey: envApiKeyAuth2("GitHub Copilot token", ["COPILOT_GITHUB_TOKEN"]),
|
|
36
|
+
oauth: githubCopilotOAuth2(options, () => getKnownModelIds())
|
|
37
|
+
},
|
|
38
|
+
filterModels: (models, credential) => {
|
|
39
|
+
if (credential?.type !== "oauth")
|
|
40
|
+
return models;
|
|
41
|
+
if (!matchesCopilotCredential2(credential))
|
|
42
|
+
return [];
|
|
43
|
+
const available = new Set(credential.availableModelIds);
|
|
44
|
+
return models.filter((model) => available.has(model.id));
|
|
45
|
+
},
|
|
46
|
+
api: {
|
|
47
|
+
"anthropic-messages": anthropicMessagesApi2(),
|
|
48
|
+
"openai-completions": openAICompletionsApi2(),
|
|
49
|
+
"openai-responses": openAIResponsesApi2()
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
getKnownModelIds = () => new Set(provider.getModels().map((model) => model.id));
|
|
53
|
+
return provider;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { githubCopilotProvider2 };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// src/api/openai-responses-events.ts
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
import { Compile } from "typebox/compile";
|
|
4
|
+
var OutputIndex = Type.Optional(Type.Number());
|
|
5
|
+
var ItemId = Type.Optional(Type.String());
|
|
6
|
+
var Namespace = Type.Optional(Type.String());
|
|
7
|
+
var ReasoningItemSchema = Type.Object({
|
|
8
|
+
type: Type.Literal("reasoning"),
|
|
9
|
+
id: Type.String(),
|
|
10
|
+
summary: Type.Optional(Type.Array(Type.Object({ text: Type.String() }))),
|
|
11
|
+
content: Type.Optional(Type.Array(Type.Object({ text: Type.String() }))),
|
|
12
|
+
encrypted_content: Type.Optional(Type.Union([Type.String(), Type.Null()]))
|
|
13
|
+
});
|
|
14
|
+
var MessageItemSchema = Type.Object({
|
|
15
|
+
type: Type.Literal("message"),
|
|
16
|
+
id: ItemId,
|
|
17
|
+
phase: Type.Optional(Type.Union([Type.Literal("commentary"), Type.Literal("final_answer"), Type.Null()])),
|
|
18
|
+
content: Type.Optional(Type.Array(Type.Union([
|
|
19
|
+
Type.Object({ type: Type.Literal("output_text"), text: Type.String() }),
|
|
20
|
+
Type.Object({ type: Type.Literal("refusal"), refusal: Type.String() })
|
|
21
|
+
])))
|
|
22
|
+
});
|
|
23
|
+
var FunctionCallItemSchema = Type.Object({
|
|
24
|
+
type: Type.Literal("function_call"),
|
|
25
|
+
id: ItemId,
|
|
26
|
+
call_id: Type.String(),
|
|
27
|
+
name: Type.String(),
|
|
28
|
+
arguments: Type.Optional(Type.String()),
|
|
29
|
+
namespace: Namespace
|
|
30
|
+
});
|
|
31
|
+
var CustomToolCallItemSchema = Type.Object({
|
|
32
|
+
type: Type.Literal("custom_tool_call"),
|
|
33
|
+
id: ItemId,
|
|
34
|
+
call_id: Type.String(),
|
|
35
|
+
name: Type.String(),
|
|
36
|
+
input: Type.Optional(Type.String()),
|
|
37
|
+
namespace: Namespace
|
|
38
|
+
});
|
|
39
|
+
var OutputItemSchema = Type.Union([
|
|
40
|
+
ReasoningItemSchema,
|
|
41
|
+
MessageItemSchema,
|
|
42
|
+
FunctionCallItemSchema,
|
|
43
|
+
CustomToolCallItemSchema
|
|
44
|
+
]);
|
|
45
|
+
var TerminalReasoningItemSchema2 = Type.Object({
|
|
46
|
+
type: Type.Literal("reasoning"),
|
|
47
|
+
id: Type.String(),
|
|
48
|
+
encrypted_content: Type.Optional(Type.Union([Type.String(), Type.Null()]))
|
|
49
|
+
});
|
|
50
|
+
var StoredReasoningItemSchema2 = Type.Object({
|
|
51
|
+
type: Type.Literal("reasoning"),
|
|
52
|
+
encrypted_content: Type.Optional(Type.Union([Type.String(), Type.Null()]))
|
|
53
|
+
});
|
|
54
|
+
var ResponseStatusSchema = Type.Union([
|
|
55
|
+
Type.Literal("completed"),
|
|
56
|
+
Type.Literal("failed"),
|
|
57
|
+
Type.Literal("in_progress"),
|
|
58
|
+
Type.Literal("cancelled"),
|
|
59
|
+
Type.Literal("queued"),
|
|
60
|
+
Type.Literal("incomplete")
|
|
61
|
+
]);
|
|
62
|
+
var ServiceTierSchema2 = Type.Union([
|
|
63
|
+
Type.Literal("auto"),
|
|
64
|
+
Type.Literal("default"),
|
|
65
|
+
Type.Literal("flex"),
|
|
66
|
+
Type.Literal("scale"),
|
|
67
|
+
Type.Literal("priority"),
|
|
68
|
+
Type.Literal("fast"),
|
|
69
|
+
Type.Null()
|
|
70
|
+
]);
|
|
71
|
+
var TerminalResponseSchema = Type.Object({
|
|
72
|
+
id: Type.Optional(Type.String()),
|
|
73
|
+
status: Type.Optional(ResponseStatusSchema),
|
|
74
|
+
incomplete_details: Type.Optional(Type.Union([Type.Object({ reason: Type.Optional(Type.String()) }), Type.Null()])),
|
|
75
|
+
error: Type.Optional(Type.Union([
|
|
76
|
+
Type.Object({
|
|
77
|
+
code: Type.Optional(Type.Union([Type.String(), Type.Null()])),
|
|
78
|
+
message: Type.Optional(Type.String())
|
|
79
|
+
}),
|
|
80
|
+
Type.Null()
|
|
81
|
+
])),
|
|
82
|
+
output: Type.Optional(Type.Array(Type.Unknown())),
|
|
83
|
+
usage: Type.Optional(Type.Unknown()),
|
|
84
|
+
service_tier: Type.Optional(Type.Unknown())
|
|
85
|
+
});
|
|
86
|
+
function deltaEvent(type) {
|
|
87
|
+
return Type.Object({ type: Type.Literal(type), output_index: OutputIndex, delta: Type.String() });
|
|
88
|
+
}
|
|
89
|
+
var ResponsesStreamEventSchema = Type.Union([
|
|
90
|
+
Type.Object({
|
|
91
|
+
type: Type.Literal("response.created"),
|
|
92
|
+
response: Type.Object({ id: Type.Optional(Type.String()) })
|
|
93
|
+
}),
|
|
94
|
+
Type.Object({
|
|
95
|
+
type: Type.Union([
|
|
96
|
+
Type.Literal("response.output_item.added"),
|
|
97
|
+
Type.Literal("response.output_item.done")
|
|
98
|
+
]),
|
|
99
|
+
output_index: OutputIndex,
|
|
100
|
+
item: OutputItemSchema
|
|
101
|
+
}),
|
|
102
|
+
deltaEvent("response.reasoning_summary_text.delta"),
|
|
103
|
+
Type.Object({
|
|
104
|
+
type: Type.Literal("response.reasoning_summary_part.done"),
|
|
105
|
+
output_index: OutputIndex
|
|
106
|
+
}),
|
|
107
|
+
deltaEvent("response.reasoning_text.delta"),
|
|
108
|
+
deltaEvent("response.output_text.delta"),
|
|
109
|
+
deltaEvent("response.refusal.delta"),
|
|
110
|
+
deltaEvent("response.function_call_arguments.delta"),
|
|
111
|
+
Type.Object({
|
|
112
|
+
type: Type.Literal("response.function_call_arguments.done"),
|
|
113
|
+
output_index: OutputIndex,
|
|
114
|
+
arguments: Type.String()
|
|
115
|
+
}),
|
|
116
|
+
deltaEvent("response.custom_tool_call_input.delta"),
|
|
117
|
+
Type.Object({
|
|
118
|
+
type: Type.Literal("response.custom_tool_call_input.done"),
|
|
119
|
+
output_index: OutputIndex,
|
|
120
|
+
input: Type.String()
|
|
121
|
+
}),
|
|
122
|
+
Type.Object({
|
|
123
|
+
type: Type.Union([
|
|
124
|
+
Type.Literal("response.completed"),
|
|
125
|
+
Type.Literal("response.incomplete"),
|
|
126
|
+
Type.Literal("response.failed")
|
|
127
|
+
]),
|
|
128
|
+
response: TerminalResponseSchema
|
|
129
|
+
}),
|
|
130
|
+
Type.Object({
|
|
131
|
+
type: Type.Literal("error"),
|
|
132
|
+
code: Type.Optional(Type.Union([Type.String(), Type.Null()])),
|
|
133
|
+
message: Type.Optional(Type.String())
|
|
134
|
+
})
|
|
135
|
+
]);
|
|
136
|
+
var ResponsesStreamEventCheck2 = Compile(ResponsesStreamEventSchema);
|
|
137
|
+
|
|
138
|
+
export { TerminalReasoningItemSchema2, StoredReasoningItemSchema2, ServiceTierSchema2, ResponsesStreamEventCheck2 };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultNyteHome2
|
|
3
|
+
} from "./account-limits-cache-rz8p1g5y.js";
|
|
4
|
+
|
|
5
|
+
// src/file-models-store.ts
|
|
6
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
import { Type } from "typebox";
|
|
9
|
+
import { Value } from "typebox/value";
|
|
10
|
+
var StoredEntriesSchema = Type.Record(Type.String(), Type.Unknown());
|
|
11
|
+
var RAW_CATALOGS_KEY = "rawCatalogs";
|
|
12
|
+
var StoredEntrySchema = Type.Object({
|
|
13
|
+
models: Type.Array(Type.Unknown()),
|
|
14
|
+
lastModified: Type.Optional(Type.Number()),
|
|
15
|
+
checkedAt: Type.Optional(Type.Number()),
|
|
16
|
+
etag: Type.Optional(Type.String())
|
|
17
|
+
}, { additionalProperties: false });
|
|
18
|
+
function defaultModelsStorePath2() {
|
|
19
|
+
return join(defaultNyteHome2(), "models-store.json");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class FileModelsStore2 {
|
|
23
|
+
path;
|
|
24
|
+
constructor(path = defaultModelsStorePath2()) {
|
|
25
|
+
this.path = path;
|
|
26
|
+
}
|
|
27
|
+
load() {
|
|
28
|
+
try {
|
|
29
|
+
const parsed = JSON.parse(readFileSync(this.path, "utf8"));
|
|
30
|
+
return Value.Check(StoredEntriesSchema, parsed) ? parsed : {};
|
|
31
|
+
} catch {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
rawCatalogs(all) {
|
|
36
|
+
const catalogs = all[RAW_CATALOGS_KEY];
|
|
37
|
+
return Value.Check(StoredEntriesSchema, catalogs) ? catalogs : {};
|
|
38
|
+
}
|
|
39
|
+
save(all) {
|
|
40
|
+
mkdirSync(dirname(this.path), { recursive: true, mode: 448 });
|
|
41
|
+
writeFileSync(this.path, `${JSON.stringify(all, null, 2)}
|
|
42
|
+
`);
|
|
43
|
+
}
|
|
44
|
+
async read(providerId, options) {
|
|
45
|
+
options?.signal?.throwIfAborted();
|
|
46
|
+
const all = this.load();
|
|
47
|
+
const entry = this.rawCatalogs(all)[providerId];
|
|
48
|
+
if (Value.Check(StoredEntrySchema, entry))
|
|
49
|
+
return entry;
|
|
50
|
+
const legacy = all[providerId];
|
|
51
|
+
return Value.Check(StoredEntrySchema, legacy) ? { models: legacy.models } : undefined;
|
|
52
|
+
}
|
|
53
|
+
async write(providerId, entry, options) {
|
|
54
|
+
options?.signal?.throwIfAborted();
|
|
55
|
+
const all = this.load();
|
|
56
|
+
all[RAW_CATALOGS_KEY] = { ...this.rawCatalogs(all), [providerId]: entry };
|
|
57
|
+
this.save(all);
|
|
58
|
+
}
|
|
59
|
+
async delete(providerId, options) {
|
|
60
|
+
options?.signal?.throwIfAborted();
|
|
61
|
+
const all = this.load();
|
|
62
|
+
const catalogs = this.rawCatalogs(all);
|
|
63
|
+
delete catalogs[providerId];
|
|
64
|
+
delete all[providerId];
|
|
65
|
+
all[RAW_CATALOGS_KEY] = catalogs;
|
|
66
|
+
this.save(all);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { defaultModelsStorePath2, FileModelsStore2 };
|