@nyte-ai/ai 0.0.0-stage → 0.0.19
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 +866 -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-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-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-wtg64ez7.js +69 -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-yzyp0c2h.js +251 -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,276 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyServiceTierPricing2
|
|
3
|
+
} from "../../chunks/account-limits-cache-f9z00x8c.js";
|
|
4
|
+
import"../../chunks/account-limits-cache-b23sbrke.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveCacheRetention2
|
|
7
|
+
} from "../../chunks/account-limits-cache-d2a51dka.js";
|
|
8
|
+
import {
|
|
9
|
+
splitDeferredTools2
|
|
10
|
+
} from "../../chunks/account-limits-cache-8s8bz4dr.js";
|
|
11
|
+
import {
|
|
12
|
+
getSystemMessageText2
|
|
13
|
+
} from "../../chunks/account-limits-cache-b4edaybk.js";
|
|
14
|
+
import {
|
|
15
|
+
getDeclaredTools2,
|
|
16
|
+
getInitialSystemMessage2,
|
|
17
|
+
normalizeContext2,
|
|
18
|
+
resolveTranscript2,
|
|
19
|
+
resolveTranscriptTools2
|
|
20
|
+
} from "../../chunks/account-limits-cache-6250ykn6.js";
|
|
21
|
+
import {
|
|
22
|
+
normalizeProviderError2,
|
|
23
|
+
formatProviderError2
|
|
24
|
+
} from "../../chunks/account-limits-cache-zcbkmrvy.js";
|
|
25
|
+
import {
|
|
26
|
+
headersToRecord2,
|
|
27
|
+
mergeProviderHeaders2,
|
|
28
|
+
getClientApiKey2
|
|
29
|
+
} from "../../chunks/account-limits-cache-ag5b8dja.js";
|
|
30
|
+
import {
|
|
31
|
+
getNyteUserAgent2
|
|
32
|
+
} from "../../chunks/account-limits-cache-gknnm1kv.js";
|
|
33
|
+
import"../../chunks/account-limits-cache-j2bt392s.js";
|
|
34
|
+
import {
|
|
35
|
+
retryProviderRequest2
|
|
36
|
+
} from "../../chunks/account-limits-cache-nbhht7xz.js";
|
|
37
|
+
import"../../chunks/account-limits-cache-nn9jebsj.js";
|
|
38
|
+
import"../../chunks/account-limits-cache-a6cgeagz.js";
|
|
39
|
+
import {
|
|
40
|
+
runAssistantStream2
|
|
41
|
+
} from "../../chunks/account-limits-cache-fsktnetm.js";
|
|
42
|
+
import {
|
|
43
|
+
createGrammarToolInputProperties2
|
|
44
|
+
} from "../../chunks/account-limits-cache-h92bzz1j.js";
|
|
45
|
+
import {
|
|
46
|
+
buildCopilotDynamicHeaders2
|
|
47
|
+
} from "../../chunks/account-limits-cache-za42x8a3.js";
|
|
48
|
+
import {
|
|
49
|
+
clampOpenAIPromptCacheKey2
|
|
50
|
+
} from "../../chunks/account-limits-cache-csbxvam7.js";
|
|
51
|
+
import"../../chunks/account-limits-cache-0af5gqeg.js";
|
|
52
|
+
import"../../chunks/account-limits-cache-eqwweapz.js";
|
|
53
|
+
import"../../chunks/account-limits-cache-8qzk56vj.js";
|
|
54
|
+
import {
|
|
55
|
+
convertResponsesMessages2,
|
|
56
|
+
convertResponsesTools2
|
|
57
|
+
} from "../../chunks/account-limits-cache-n3yk6g5c.js";
|
|
58
|
+
import"../../chunks/account-limits-cache-zgzptd0z.js";
|
|
59
|
+
import"../../chunks/account-limits-cache-fbkaq46e.js";
|
|
60
|
+
import"../../chunks/account-limits-cache-736tdyme.js";
|
|
61
|
+
import"../../chunks/account-limits-cache-a558rjbg.js";
|
|
62
|
+
import {
|
|
63
|
+
withPriorityTier2,
|
|
64
|
+
processResponsesStream2
|
|
65
|
+
} from "../../chunks/account-limits-cache-53e64mhx.js";
|
|
66
|
+
import {
|
|
67
|
+
readOpenAICompactResponse2
|
|
68
|
+
} from "../../chunks/account-limits-cache-pfr14mcn.js";
|
|
69
|
+
import"../../chunks/account-limits-cache-dejeygdt.js";
|
|
70
|
+
import {
|
|
71
|
+
buildBaseOptions2,
|
|
72
|
+
simpleReasoningEffort2
|
|
73
|
+
} from "../../chunks/account-limits-cache-k0pkzhbx.js";
|
|
74
|
+
|
|
75
|
+
// src/api/openai-responses.ts
|
|
76
|
+
import OpenAI from "openai";
|
|
77
|
+
var OPENAI_TOOL_CALL_PROVIDERS = new Set(["openai", "openai-codex", "opencode"]);
|
|
78
|
+
var OPENAI_RESPONSES_MIN_OUTPUT_TOKENS = 16;
|
|
79
|
+
function getCompat(model) {
|
|
80
|
+
return {
|
|
81
|
+
supportsDeveloperRole: model.compat?.supportsDeveloperRole ?? true,
|
|
82
|
+
supportsMidConvoSystemMessages: model.compat?.supportsMidConvoSystemMessages ?? false,
|
|
83
|
+
sessionAffinityFormat: model.compat?.sessionAffinityFormat ?? "openai",
|
|
84
|
+
supportsLongCacheRetention: model.compat?.supportsLongCacheRetention ?? true,
|
|
85
|
+
supportsStrictMode: model.compat?.supportsStrictMode ?? false,
|
|
86
|
+
supportsOpenAIGrammarTools: model.compat?.supportsOpenAIGrammarTools ?? false,
|
|
87
|
+
supportsAdditionalTools: model.compat?.supportsAdditionalTools ?? false,
|
|
88
|
+
supportsToolSearch: model.compat?.supportsToolSearch ?? false,
|
|
89
|
+
supportsExplicitPromptCacheMode: model.compat?.supportsExplicitPromptCacheMode ?? false
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function getPromptCacheRetention(compat, cacheRetention) {
|
|
93
|
+
return cacheRetention === "long" && compat.supportsLongCacheRetention && !compat.supportsExplicitPromptCacheMode ? "24h" : undefined;
|
|
94
|
+
}
|
|
95
|
+
function getPromptCacheOptions(compat, cacheRetention) {
|
|
96
|
+
if (!compat.supportsExplicitPromptCacheMode)
|
|
97
|
+
return;
|
|
98
|
+
if (cacheRetention === "none")
|
|
99
|
+
return { mode: "explicit" };
|
|
100
|
+
if (cacheRetention === "long" && compat.supportsLongCacheRetention)
|
|
101
|
+
return { ttl: "30m" };
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
async function compactOpenAIResponsesContext(model, context, requested) {
|
|
105
|
+
const options = withPriorityTier2(requested);
|
|
106
|
+
const apiKey = getClientApiKey2(model.provider, options?.apiKey, options?.headers);
|
|
107
|
+
const compat = getCompat(model);
|
|
108
|
+
const cacheRetention = resolveCacheRetention2(options?.cacheRetention, options?.env);
|
|
109
|
+
const transcript = resolveTranscript2(normalizeContext2(context), compat.supportsMidConvoSystemMessages);
|
|
110
|
+
const client = createClient({
|
|
111
|
+
model,
|
|
112
|
+
context: transcript,
|
|
113
|
+
apiKey,
|
|
114
|
+
options: { headers: options?.headers, fetch: options?.fetch },
|
|
115
|
+
compat,
|
|
116
|
+
cacheRetention
|
|
117
|
+
});
|
|
118
|
+
const initialSystemMessage = getInitialSystemMessage2(transcript.messages);
|
|
119
|
+
const instructions = initialSystemMessage ? getSystemMessageText2(initialSystemMessage) : undefined;
|
|
120
|
+
const input = buildParams(model, transcript, options, compat, cacheRetention, undefined, false).input;
|
|
121
|
+
const requestOptions = { maxRetries: 0 };
|
|
122
|
+
const serviceTier = options?.serviceTier === "priority" ? "priority" : undefined;
|
|
123
|
+
if (options?.signal !== undefined)
|
|
124
|
+
requestOptions.signal = options.signal;
|
|
125
|
+
if (options?.timeoutMs !== undefined)
|
|
126
|
+
requestOptions.timeout = options.timeoutMs;
|
|
127
|
+
const response = await retryProviderRequest2(() => client.post("/responses/compact", {
|
|
128
|
+
body: { model: model.id, input, instructions, service_tier: serviceTier },
|
|
129
|
+
...requestOptions,
|
|
130
|
+
__security: { bearerAuth: true }
|
|
131
|
+
}).asResponse(), {
|
|
132
|
+
maxRetries: options?.maxRetries,
|
|
133
|
+
maxRetryDelayMs: options?.maxRetryDelayMs,
|
|
134
|
+
signal: options?.signal
|
|
135
|
+
});
|
|
136
|
+
await options?.onResponse?.({ status: response.status, headers: headersToRecord2(response.headers) }, model);
|
|
137
|
+
return readOpenAICompactResponse2(response, model, serviceTier);
|
|
138
|
+
}
|
|
139
|
+
var stream = (model, context, requested) => {
|
|
140
|
+
const options = withPriorityTier2(requested);
|
|
141
|
+
const normalizedContext = resolveTranscript2(context, getCompat(model).supportsMidConvoSystemMessages);
|
|
142
|
+
return runAssistantStream2(model, options?.signal, "OpenAI Responses", async (output, stream) => {
|
|
143
|
+
const apiKey = getClientApiKey2(model.provider, options?.apiKey, options?.headers);
|
|
144
|
+
const cacheRetention = resolveCacheRetention2(options?.cacheRetention, options?.env);
|
|
145
|
+
const compat = getCompat(model);
|
|
146
|
+
const grammarToolInputProperties = createGrammarToolInputProperties2(getDeclaredTools2(normalizedContext.messages), compat.supportsOpenAIGrammarTools);
|
|
147
|
+
const client = createClient({
|
|
148
|
+
model,
|
|
149
|
+
context: normalizedContext,
|
|
150
|
+
apiKey,
|
|
151
|
+
options,
|
|
152
|
+
cacheRetention,
|
|
153
|
+
compat
|
|
154
|
+
});
|
|
155
|
+
const params = buildParams(model, normalizedContext, options, compat, cacheRetention, grammarToolInputProperties);
|
|
156
|
+
await options?.onPayload?.(params, model);
|
|
157
|
+
const requestOptions = { maxRetries: 0 };
|
|
158
|
+
if (options?.signal)
|
|
159
|
+
requestOptions.signal = options.signal;
|
|
160
|
+
if (options?.timeoutMs !== undefined)
|
|
161
|
+
requestOptions.timeout = options.timeoutMs;
|
|
162
|
+
const result = await retryProviderRequest2(() => client.post("/responses", {
|
|
163
|
+
body: params,
|
|
164
|
+
...requestOptions,
|
|
165
|
+
stream: true,
|
|
166
|
+
__security: { bearerAuth: true }
|
|
167
|
+
}).withResponse(), {
|
|
168
|
+
maxRetries: options?.maxRetries,
|
|
169
|
+
maxRetryDelayMs: options?.maxRetryDelayMs,
|
|
170
|
+
signal: options?.signal
|
|
171
|
+
});
|
|
172
|
+
await options?.onResponse?.({ status: result.response.status, headers: headersToRecord2(result.response.headers) }, model);
|
|
173
|
+
stream.push({ type: "start", partial: output });
|
|
174
|
+
await processResponsesStream2(result.data, output, stream, model, {
|
|
175
|
+
serviceTier: options?.serviceTier,
|
|
176
|
+
grammarToolInputProperties,
|
|
177
|
+
applyServiceTierPricing: (usage, serviceTier) => applyServiceTierPricing2(usage, serviceTier, model)
|
|
178
|
+
});
|
|
179
|
+
}, (error) => formatProviderError2(normalizeProviderError2(error), `${model.provider === "openai" ? "OpenAI" : model.provider} API error`));
|
|
180
|
+
};
|
|
181
|
+
var streamSimple = (model, context, options) => {
|
|
182
|
+
getClientApiKey2(model.provider, options?.apiKey, options?.headers);
|
|
183
|
+
return stream(model, context, {
|
|
184
|
+
...buildBaseOptions2(model, context, options),
|
|
185
|
+
reasoningEffort: simpleReasoningEffort2(model, options?.reasoning)
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
function createClient(input) {
|
|
189
|
+
const copilotHeaders = input.model.provider === "github-copilot" ? buildCopilotDynamicHeaders2({
|
|
190
|
+
messages: input.context.messages,
|
|
191
|
+
sessionId: input.options?.sessionId
|
|
192
|
+
}) : undefined;
|
|
193
|
+
const cacheSessionId = input.cacheRetention === "none" ? undefined : input.options?.sessionId;
|
|
194
|
+
const affinityHeaders = {};
|
|
195
|
+
if (cacheSessionId) {
|
|
196
|
+
if (input.compat.sessionAffinityFormat === "openrouter") {
|
|
197
|
+
affinityHeaders["x-session-id"] = cacheSessionId;
|
|
198
|
+
} else {
|
|
199
|
+
if (input.compat.sessionAffinityFormat === "openai") {
|
|
200
|
+
affinityHeaders.session_id = cacheSessionId;
|
|
201
|
+
}
|
|
202
|
+
affinityHeaders["x-client-request-id"] = cacheSessionId;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return new OpenAI({
|
|
206
|
+
apiKey: input.apiKey,
|
|
207
|
+
baseURL: input.model.baseUrl,
|
|
208
|
+
dangerouslyAllowBrowser: true,
|
|
209
|
+
fetch: input.options?.fetch,
|
|
210
|
+
defaultHeaders: mergeProviderHeaders2({ "User-Agent": getNyteUserAgent2() }, input.model.headers, copilotHeaders, affinityHeaders, input.options?.headers)
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function buildParams(model, context, options, compat = getCompat(model), cacheRetention = resolveCacheRetention2(options?.cacheRetention, options?.env), grammarToolInputProperties = createGrammarToolInputProperties2(getDeclaredTools2(context.messages), compat.supportsOpenAIGrammarTools), includeSystemPrompt = true) {
|
|
214
|
+
const deferredToolsMode = compat.supportsAdditionalTools ? "additional-tools" : compat.supportsToolSearch ? "tool-search" : undefined;
|
|
215
|
+
const transcriptTools = resolveTranscriptTools2(context.messages, deferredToolsMode !== undefined);
|
|
216
|
+
const toolPlacement = splitDeferredTools2({ messages: context.messages, tools: transcriptTools.requestTools }, deferredToolsMode !== undefined);
|
|
217
|
+
const messages = convertResponsesMessages2(model, context, OPENAI_TOOL_CALL_PROVIDERS, {
|
|
218
|
+
includeSystemPrompt,
|
|
219
|
+
grammarToolInputProperties,
|
|
220
|
+
supportsMidConvoSystemMessages: compat.supportsMidConvoSystemMessages,
|
|
221
|
+
deferredTools: toolPlacement.deferred,
|
|
222
|
+
deferredToolsMode,
|
|
223
|
+
toolOptions: {
|
|
224
|
+
supportsStrictMode: compat.supportsStrictMode,
|
|
225
|
+
supportsOpenAIGrammarTools: compat.supportsOpenAIGrammarTools
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
const params = {
|
|
229
|
+
model: model.id,
|
|
230
|
+
input: messages,
|
|
231
|
+
stream: true,
|
|
232
|
+
prompt_cache_key: cacheRetention === "none" ? undefined : clampOpenAIPromptCacheKey2(options?.sessionId),
|
|
233
|
+
prompt_cache_retention: getPromptCacheRetention(compat, cacheRetention),
|
|
234
|
+
prompt_cache_options: getPromptCacheOptions(compat, cacheRetention),
|
|
235
|
+
store: false
|
|
236
|
+
};
|
|
237
|
+
if (options?.maxTokens) {
|
|
238
|
+
params.max_output_tokens = Math.max(options.maxTokens, OPENAI_RESPONSES_MIN_OUTPUT_TOKENS);
|
|
239
|
+
}
|
|
240
|
+
if (options?.temperature !== undefined) {
|
|
241
|
+
params.temperature = options?.temperature;
|
|
242
|
+
}
|
|
243
|
+
if (options?.serviceTier !== undefined) {
|
|
244
|
+
params.service_tier = options.serviceTier;
|
|
245
|
+
}
|
|
246
|
+
if (toolPlacement.immediate.length > 0) {
|
|
247
|
+
params.tools = convertResponsesTools2(toolPlacement.immediate, {
|
|
248
|
+
supportsStrictMode: compat.supportsStrictMode,
|
|
249
|
+
supportsOpenAIGrammarTools: compat.supportsOpenAIGrammarTools
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
if (options?.toolChoice !== undefined) {
|
|
253
|
+
params.tool_choice = options.toolChoice;
|
|
254
|
+
}
|
|
255
|
+
if (model.reasoning) {
|
|
256
|
+
if (options?.reasoningEffort || options?.reasoningSummary) {
|
|
257
|
+
const effort = options?.reasoningEffort ? model.thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort : "medium";
|
|
258
|
+
params.reasoning = { effort, summary: options?.reasoningSummary || "auto" };
|
|
259
|
+
params.include = ["reasoning.encrypted_content"];
|
|
260
|
+
} else if (model.provider !== "github-copilot" && model.thinkingLevelMap?.off !== null) {
|
|
261
|
+
params.reasoning = { effort: model.thinkingLevelMap?.off ?? "none" };
|
|
262
|
+
}
|
|
263
|
+
if (model.provider === "xai" || model.provider === "github-copilot") {
|
|
264
|
+
params.include = ["reasoning.encrypted_content"];
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (options?.samplingParams) {
|
|
268
|
+
Object.assign(params, options.samplingParams);
|
|
269
|
+
}
|
|
270
|
+
return params;
|
|
271
|
+
}
|
|
272
|
+
export {
|
|
273
|
+
compactOpenAIResponsesContext,
|
|
274
|
+
stream,
|
|
275
|
+
streamSimple
|
|
276
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
openAIResponsesApi2
|
|
3
|
+
} from "../../chunks/account-limits-cache-q1ebtvet.js";
|
|
4
|
+
import"../../chunks/account-limits-cache-90c9c2eb.js";
|
|
5
|
+
import"../../chunks/account-limits-cache-fsktnetm.js";
|
|
6
|
+
import"../../chunks/account-limits-cache-zcbkmrvy.js";
|
|
7
|
+
import"../../chunks/account-limits-cache-a6cgeagz.js";
|
|
8
|
+
import"../../chunks/account-limits-cache-nn9jebsj.js";
|
|
9
|
+
export {
|
|
10
|
+
openAIResponsesApi2 as openAIResponsesApi
|
|
11
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Api, Model, ModelThinkingLevel, SimpleStreamOptions, StreamOptions, ThinkingBudgets, ThinkingLevel, TranscriptContext } from "../types.ts";
|
|
2
|
+
export declare function clampMaxTokensToContext(model: Model<Api>, context: TranscriptContext, maxTokens: number): number;
|
|
3
|
+
/** The request options every API's `streamSimple` forwards unchanged to its `stream`. */
|
|
4
|
+
export declare function buildBaseOptions(model: Model<Api>, context: TranscriptContext, options?: SimpleStreamOptions): StreamOptions & Pick<SimpleStreamOptions, "toolChoice">;
|
|
5
|
+
/** The simple reasoning level clamped to what `model` supports, or undefined for no reasoning. */
|
|
6
|
+
export declare function simpleReasoningEffort(model: Model<Api>, reasoning: ThinkingLevel | undefined): Exclude<ModelThinkingLevel, "off"> | undefined;
|
|
7
|
+
export declare function thinkingBudgetForLevel(reasoningLevel: ThinkingLevel, customBudgets?: ThinkingBudgets): number;
|
|
8
|
+
/** Cap a thinking budget so at least MIN_ANSWER_TOKENS remain under a shared response ceiling. */
|
|
9
|
+
export declare function clampThinkingBudgetToAnswerRoom(thinkingBudget: number, ceiling: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* The output cap and thinking budget for a budget-based thinking request. An undefined
|
|
12
|
+
* `baseMaxTokens` means the caller set no cap: the model cap is used and thinking fits inside it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function adjustMaxTokensForThinking(baseMaxTokens: number | undefined, modelMaxTokens: number, reasoningLevel: ThinkingLevel, customBudgets?: ThinkingBudgets): {
|
|
15
|
+
maxTokens: number;
|
|
16
|
+
thinkingBudget: number;
|
|
17
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clampMaxTokensToContext2,
|
|
3
|
+
buildBaseOptions2,
|
|
4
|
+
simpleReasoningEffort2,
|
|
5
|
+
thinkingBudgetForLevel2,
|
|
6
|
+
clampThinkingBudgetToAnswerRoom2,
|
|
7
|
+
adjustMaxTokensForThinking2
|
|
8
|
+
} from "../../chunks/account-limits-cache-k0pkzhbx.js";
|
|
9
|
+
import"../../chunks/account-limits-cache-dejeygdt.js";
|
|
10
|
+
import"../../chunks/account-limits-cache-zgzptd0z.js";
|
|
11
|
+
export {
|
|
12
|
+
adjustMaxTokensForThinking2 as adjustMaxTokensForThinking,
|
|
13
|
+
buildBaseOptions2 as buildBaseOptions,
|
|
14
|
+
clampMaxTokensToContext2 as clampMaxTokensToContext,
|
|
15
|
+
clampThinkingBudgetToAnswerRoom2 as clampThinkingBudgetToAnswerRoom,
|
|
16
|
+
simpleReasoningEffort2 as simpleReasoningEffort,
|
|
17
|
+
thinkingBudgetForLevel2 as thinkingBudgetForLevel
|
|
18
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
/** A provider token count. */
|
|
3
|
+
export declare const TokenCount: Type.TInteger;
|
|
4
|
+
/** A token count a provider may also send as `null` or leave out. */
|
|
5
|
+
export declare const NullableTokenCount: Type.TOptional<Type.TUnion<[Type.TInteger, Type.TNull]>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Api, AssistantMessage, Message, Model } from "../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Normalize tool call ID for cross-provider compatibility.
|
|
4
|
+
* OpenAI Responses API generates IDs that are 450+ chars with special characters like `|`.
|
|
5
|
+
* Anthropic APIs require IDs matching ^[a-zA-Z0-9_-]+$ (max 64 chars).
|
|
6
|
+
* Null or undefined content from untyped callers (custom tools, hand-built histories, old session
|
|
7
|
+
* files) becomes an empty array first, so downstream code can rely on the type contract.
|
|
8
|
+
*/
|
|
9
|
+
export declare function transformMessages<TApi extends Api>(messages: Message[], model: Model<TApi>, normalizeToolCallId?: (id: string, model: Model<TApi>, source: AssistantMessage) => string): Message[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-API stream option map. It imports each API module's option type, so it
|
|
3
|
+
* lives apart from `types.ts`, which those modules import for the base contract.
|
|
4
|
+
*/
|
|
5
|
+
import type { AnthropicOptions } from "./api/anthropic-messages.ts";
|
|
6
|
+
import type { GoogleOptions } from "./api/google-generative-ai.ts";
|
|
7
|
+
import type { OpenAICodexResponsesOptions } from "./api/openai-codex-protocol.ts";
|
|
8
|
+
import type { OpenAICompletionsOptions } from "./api/openai-completions-params.ts";
|
|
9
|
+
import type { OpenAIResponsesOptions } from "./api/openai-responses.ts";
|
|
10
|
+
import type { Api, StreamOptions } from "./types.ts";
|
|
11
|
+
/**
|
|
12
|
+
* Maps known APIs to their full provider-specific stream option types.
|
|
13
|
+
* Type-only imports from API implementation modules are erased at emit, so
|
|
14
|
+
* this is tree-shake safe.
|
|
15
|
+
*/
|
|
16
|
+
export interface ApiOptionsMap {
|
|
17
|
+
"anthropic-messages": AnthropicOptions;
|
|
18
|
+
"google-generative-ai": GoogleOptions;
|
|
19
|
+
"openai-completions": OpenAICompletionsOptions;
|
|
20
|
+
"openai-responses": OpenAIResponsesOptions;
|
|
21
|
+
"openai-codex-responses": OpenAICodexResponsesOptions;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Full stream options for an API. Known APIs resolve to their concrete option
|
|
25
|
+
* type; custom API strings fall back to the generic shape.
|
|
26
|
+
*/
|
|
27
|
+
export type ApiStreamOptions<TApi extends Api> = StreamOptions & (TApi extends keyof ApiOptionsMap ? ApiOptionsMap[TApi] : Record<string, unknown>);
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default `AuthContext`: env vars from `process.env` and file existence via
|
|
3
|
+
* node:fs, both loaded through `process.getBuiltinModule` so browser bundlers do
|
|
4
|
+
* not try to resolve node builtins (where they simply report nothing).
|
|
5
|
+
*/
|
|
6
|
+
import type { AuthContext } from "./types.ts";
|
|
7
|
+
/**
|
|
8
|
+
* Default auth context: env vars from `process.env` (undefined in browsers),
|
|
9
|
+
* file existence via node:fs (always false in browsers).
|
|
10
|
+
*/
|
|
11
|
+
export declare function defaultProviderAuthContext(): AuthContext;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AuthOperationOptions, CredentialAccounts, CredentialInfo, CredentialStore } from "./types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Default in-memory credential store. Apps inject persistent stores.
|
|
4
|
+
* Keyed by `Provider.id`, with accounts and selection stored together.
|
|
5
|
+
* Writes run one at a time per provider.
|
|
6
|
+
*/
|
|
7
|
+
export declare class InMemoryCredentialStore implements CredentialStore {
|
|
8
|
+
private credentials;
|
|
9
|
+
private readonly writes;
|
|
10
|
+
/** Runs `task` after the provider's earlier writes; a cancelled caller stops waiting, and a task cancelled before it starts never runs. */
|
|
11
|
+
private enqueue;
|
|
12
|
+
read(providerId: string, options?: AuthOperationOptions): Promise<CredentialAccounts | undefined>;
|
|
13
|
+
list(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]>;
|
|
14
|
+
/** Stores what `fn` returns even after abort: a rotated token has no second copy. */
|
|
15
|
+
modify(providerId: string, fn: (current: CredentialAccounts | undefined) => Promise<CredentialAccounts | undefined>, options?: AuthOperationOptions): Promise<CredentialAccounts | undefined>;
|
|
16
|
+
delete(providerId: string, options?: AuthOperationOptions): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Building blocks for provider auth definitions: the standard env-var api-key
|
|
3
|
+
* auth with a paste-your-key login, and a lazy OAuth wrapper that defers
|
|
4
|
+
* loading Node-only flow code until first use.
|
|
5
|
+
*/
|
|
6
|
+
import type { ApiKeyAuth, OAuthAuth } from "./types.ts";
|
|
7
|
+
/**
|
|
8
|
+
* Standard api-key auth: a stored credential key wins, otherwise the first
|
|
9
|
+
* set env var resolves. Includes a `login` that prompts for the key.
|
|
10
|
+
* Providers with non-standard resolution (provider env, ambient files, IAM)
|
|
11
|
+
* write their own `ApiKeyAuth`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function envApiKeyAuth(name: string, envVars: readonly string[]): ApiKeyAuth;
|
|
14
|
+
/**
|
|
15
|
+
* Loads an OAuth flow on first login, refresh, or auth conversion.
|
|
16
|
+
* Only a successful load is kept: a cached rejection would poison every later
|
|
17
|
+
* login, refresh, and toAuth call for the life of the process.
|
|
18
|
+
*/
|
|
19
|
+
export declare function lazyOAuth(input: {
|
|
20
|
+
name: string;
|
|
21
|
+
isSubscription?: boolean;
|
|
22
|
+
loginLabel?: string;
|
|
23
|
+
load: () => Promise<OAuthAuth>;
|
|
24
|
+
}): OAuthAuth;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anthropic OAuth flow (Claude Pro/Max): PKCE against claude.ai with browser
|
|
3
|
+
* callback or copy-code login, and token refresh against platform.claude.com.
|
|
4
|
+
* Node-only (node:http); the callback server is for CLI use, not browsers.
|
|
5
|
+
*/
|
|
6
|
+
import { type OAuthAuth } from "../types.ts";
|
|
7
|
+
export declare const anthropicOAuth: OAuthAuth;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
anthropicOAuth2
|
|
3
|
+
} from "../../../chunks/account-limits-cache-4fn5w63p.js";
|
|
4
|
+
import"../../../chunks/account-limits-cache-d1ypzqzp.js";
|
|
5
|
+
import"../../../chunks/account-limits-cache-8vzx8k6r.js";
|
|
6
|
+
import"../../../chunks/account-limits-cache-tc38g0ca.js";
|
|
7
|
+
import"../../../chunks/account-limits-cache-b0x2sfya.js";
|
|
8
|
+
import"../../../chunks/account-limits-cache-v4n30az2.js";
|
|
9
|
+
import"../../../chunks/account-limits-cache-b23sbrke.js";
|
|
10
|
+
export {
|
|
11
|
+
anthropicOAuth2 as anthropicOAuth
|
|
12
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a pasted authorization code: a redirect URL, `code#state`, a
|
|
3
|
+
* `code=...&state=...` query string, or a bare code. Browser-safe.
|
|
4
|
+
*/
|
|
5
|
+
export declare function parseAuthorizationInput(input: string): {
|
|
6
|
+
code?: undefined;
|
|
7
|
+
state?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
code: string | undefined;
|
|
10
|
+
state: string | undefined;
|
|
11
|
+
} | {
|
|
12
|
+
code: string;
|
|
13
|
+
state?: undefined;
|
|
14
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type OAuthDeviceCodeIncompletePollResult = {
|
|
2
|
+
status: "pending";
|
|
3
|
+
} | {
|
|
4
|
+
status: "slow_down";
|
|
5
|
+
intervalSeconds?: number;
|
|
6
|
+
} | {
|
|
7
|
+
status: "failed";
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
export type OAuthDeviceCodePollResult<T> = OAuthDeviceCodeIncompletePollResult | {
|
|
11
|
+
status: "complete";
|
|
12
|
+
value: T;
|
|
13
|
+
};
|
|
14
|
+
export type OAuthDeviceCodePollOptions<T> = {
|
|
15
|
+
intervalSeconds?: number;
|
|
16
|
+
expiresInSeconds?: number;
|
|
17
|
+
waitBeforeFirstPoll?: boolean;
|
|
18
|
+
poll: () => Promise<OAuthDeviceCodePollResult<T>>;
|
|
19
|
+
signal: AbortSignal;
|
|
20
|
+
};
|
|
21
|
+
export declare function abortableSleep(ms: number, signal: AbortSignal, cancelMessage: string): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Polls a device-code grant until it completes, fails, or expires. On `slow_down` it uses the
|
|
24
|
+
* server-provided interval when given (GitHub reports the new required minimum in `interval`);
|
|
25
|
+
* trusting only a client-tracked value risks polling early forever under WSL/VM clock drift.
|
|
26
|
+
* Otherwise it applies RFC 8628 section 3.5 and adds 5 seconds.
|
|
27
|
+
*/
|
|
28
|
+
export declare function pollOAuthDeviceCodeFlow<T>(options: OAuthDeviceCodePollOptions<T>): Promise<T>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
abortableSleep3,
|
|
3
|
+
pollOAuthDeviceCodeFlow2
|
|
4
|
+
} from "../../../chunks/account-limits-cache-4hptgd2h.js";
|
|
5
|
+
import"../../../chunks/account-limits-cache-j2bt392s.js";
|
|
6
|
+
export {
|
|
7
|
+
abortableSleep3 as abortableSleep,
|
|
8
|
+
pollOAuthDeviceCodeFlow2 as pollOAuthDeviceCodeFlow
|
|
9
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch-only Copilot OAuth.
|
|
3
|
+
* Hosts own interaction and storage; login and refresh publish only complete credentials.
|
|
4
|
+
*/
|
|
5
|
+
import { Type, type Static } from "typebox";
|
|
6
|
+
import type { FetchFunction } from "../../types.ts";
|
|
7
|
+
import type { OAuthAuth } from "../types.ts";
|
|
8
|
+
declare const CopilotCredential: Type.TObject<{
|
|
9
|
+
type: Type.TLiteral<"oauth">;
|
|
10
|
+
refresh: Type.TString;
|
|
11
|
+
access: Type.TString;
|
|
12
|
+
expires: Type.TInteger;
|
|
13
|
+
availableModelIds: Type.TArray<Type.TString>;
|
|
14
|
+
}>;
|
|
15
|
+
export interface GitHubCopilotOAuthOptions {
|
|
16
|
+
fetch?: FetchFunction;
|
|
17
|
+
/** The client must be permitted to use Copilot's session-token exchange. */
|
|
18
|
+
clientId?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Credential storage is an external boundary, including provider-specific metadata. */
|
|
21
|
+
export declare function matchesCopilotCredential(value: unknown): value is Static<typeof CopilotCredential>;
|
|
22
|
+
export declare function githubCopilotOAuth(options?: GitHubCopilotOAuthOptions, knownModelIds?: () => ReadonlySet<string>): OAuthAuth;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
matchesCopilotCredential2,
|
|
3
|
+
githubCopilotOAuth2
|
|
4
|
+
} from "../../../chunks/account-limits-cache-cw7q7vfy.js";
|
|
5
|
+
import"../../../chunks/account-limits-cache-gs8a3fhw.js";
|
|
6
|
+
import"../../../chunks/account-limits-cache-za42x8a3.js";
|
|
7
|
+
import"../../../chunks/account-limits-cache-4hptgd2h.js";
|
|
8
|
+
import"../../../chunks/account-limits-cache-j2bt392s.js";
|
|
9
|
+
export {
|
|
10
|
+
githubCopilotOAuth2 as githubCopilotOAuth,
|
|
11
|
+
matchesCopilotCredential2 as matchesCopilotCredential
|
|
12
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy loaders for the built-in OAuth flows. Provider definitions advertise
|
|
3
|
+
* OAuth through `lazyOAuth` + one of these, so the Node-only flow modules
|
|
4
|
+
* (callback servers, PKCE) are imported only when a login or refresh runs.
|
|
5
|
+
* Each flow module registers its flow when it loads, so a loader reads a typed
|
|
6
|
+
* registry instead of an untyped module namespace.
|
|
7
|
+
*/
|
|
8
|
+
import type { OAuthAuth } from "../types.ts";
|
|
9
|
+
type OAuthFlowId = "anthropic" | "openaiCodex";
|
|
10
|
+
/** Records a built-in flow; its module calls this on load, and bundled hosts call it up front. */
|
|
11
|
+
export declare function registerOAuthFlow(id: OAuthFlowId, flow: OAuthAuth): void;
|
|
12
|
+
export declare const loadAnthropicOAuth: () => Promise<OAuthAuth>;
|
|
13
|
+
export declare const loadOpenAICodexOAuth: () => Promise<OAuthAuth>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
registerOAuthFlow2,
|
|
3
|
+
loadAnthropicOAuth2,
|
|
4
|
+
loadOpenAICodexOAuth2
|
|
5
|
+
} from "../../../chunks/account-limits-cache-v4n30az2.js";
|
|
6
|
+
export {
|
|
7
|
+
loadAnthropicOAuth2 as loadAnthropicOAuth,
|
|
8
|
+
loadOpenAICodexOAuth2 as loadOpenAICodexOAuth,
|
|
9
|
+
registerOAuthFlow2 as registerOAuthFlow
|
|
10
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-contained HTML pages served by the localhost OAuth callback servers
|
|
3
|
+
* (success and failure), rendered as plain strings with escaped content.
|
|
4
|
+
*
|
|
5
|
+
* The page follows the Nyte landing language (paper/ink, hairline rules with corner
|
|
6
|
+
* ticks, square corners), picks light or dark from the OS, and carries the
|
|
7
|
+
* provider name in the heading. No mark yet, one system font, no JS, no
|
|
8
|
+
* network: the page has to work offline and load from nothing but this string.
|
|
9
|
+
*/
|
|
10
|
+
export declare function oauthSuccessHtml(options: {
|
|
11
|
+
provider: string;
|
|
12
|
+
}): string;
|
|
13
|
+
export declare function oauthErrorHtml(message: string, details?: string): string;
|