@omnicross/core 0.1.9 → 0.2.0
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 -21
- package/NOTICE +57 -57
- package/README.md +22 -15
- package/dist/{CompletionService-kNA17cfI.d.cts → CompletionService-BiJqftc-.d.cts} +1 -1
- package/dist/{CompletionService-C3BX0Ovy.d.ts → CompletionService-NXN_Av5W.d.ts} +1 -1
- package/dist/{ProviderProxy-QdwNV6l1.d.cts → ProviderProxy-CgIcCVwk.d.cts} +1 -1
- package/dist/{ProviderProxy--ROec6VI.d.ts → ProviderProxy-DYoY5XoT.d.ts} +1 -1
- package/dist/auth/GeminiCodeAssistProjectResolver.cjs +6 -6
- package/dist/auth/GeminiCodeAssistProjectResolver.js +4 -4
- package/dist/chunk-32SRZFFP.cjs +153 -0
- package/dist/chunk-4JOU54M5.js +200 -0
- package/dist/{chunk-2UTGX6FM.js → chunk-4VVCXVB7.js} +1 -1
- package/dist/{chunk-EPN67EGP.cjs → chunk-5UK3KLE2.cjs} +9 -1
- package/dist/chunk-6DDYNS2B.cjs +384 -0
- package/dist/{chunk-HKB656B4.js → chunk-6OC3ORW6.js} +55 -287
- package/dist/chunk-6OKXH2TW.js +320 -0
- package/dist/{chunk-XELFM7KL.cjs → chunk-7B56AJBB.cjs} +6275 -2421
- package/dist/{chunk-YWL7YZWS.cjs → chunk-7LRTPNFL.cjs} +5 -0
- package/dist/{chunk-CCVRRJOX.js → chunk-7PIUVCKK.js} +9 -2
- package/dist/{chunk-IIRPUVPH.cjs → chunk-7ZHBN75N.cjs} +3 -1
- package/dist/{chunk-UAPBLNN2.js → chunk-AQDON6MB.js} +8 -0
- package/dist/{chunk-RJ5ZGNI3.js → chunk-CFSGYFOZ.js} +1 -1
- package/dist/chunk-CTKM773J.cjs +3919 -0
- package/dist/chunk-DEIUR2TH.js +3919 -0
- package/dist/{chunk-WNKWAEUR.js → chunk-EYGBM2VC.js} +3 -1
- package/dist/{chunk-NGYOO5TO.js → chunk-FJNKXOWE.js} +9 -9
- package/dist/chunk-FX325I5Q.cjs +320 -0
- package/dist/chunk-G4CZIUIB.cjs +200 -0
- package/dist/chunk-HCOQQAZE.cjs +123 -0
- package/dist/{chunk-55FMGZ3L.js → chunk-HN74IGEO.js} +1 -1
- package/dist/{chunk-ZY6KU6P3.js → chunk-HOMUGKHR.js} +8 -5
- package/dist/{chunk-AOFWNWLT.cjs → chunk-IUL4VWNU.cjs} +22 -1
- package/dist/{chunk-5LNYGCIW.cjs → chunk-KIQ2HA2A.cjs} +5 -5
- package/dist/{chunk-MUHWHQVM.cjs → chunk-KQBLZMP6.cjs} +4 -3
- package/dist/chunk-LFEH7CEO.js +384 -0
- package/dist/chunk-N76KU6F5.js +123 -0
- package/dist/{chunk-CMVXX7ON.cjs → chunk-NOITAVHA.cjs} +114 -58
- package/dist/{chunk-Q27JY5RG.cjs → chunk-OIKREZVQ.cjs} +7 -4
- package/dist/{chunk-RJUONLUQ.cjs → chunk-OST5RJOJ.cjs} +1 -1
- package/dist/chunk-QIIAMBTM.js +153 -0
- package/dist/{chunk-56QD3YW6.cjs → chunk-QWNUOR7F.cjs} +11 -4
- package/dist/{chunk-S3DYFEBE.js → chunk-R4VCO2CB.js} +10 -1
- package/dist/{chunk-ZQQUD66M.cjs → chunk-SQMAEDNE.cjs} +63 -295
- package/dist/{chunk-4VZX5F4T.cjs → chunk-T6NWPIYZ.cjs} +5 -2
- package/dist/{chunk-P7EM6BND.cjs → chunk-TVYA5JSQ.cjs} +10 -10
- package/dist/{chunk-EBLFCNPY.js → chunk-U47LQXPB.js} +5 -2
- package/dist/{chunk-N7OOJI5V.js → chunk-V2UKUTJ3.js} +5 -0
- package/dist/{chunk-45FHEOKW.js → chunk-V53ZEFXC.js} +92 -36
- package/dist/{chunk-OC6DOOFX.cjs → chunk-VXRTQZF2.cjs} +5 -5
- package/dist/{chunk-CQIJCPMF.js → chunk-WSJE42SG.js} +5149 -1295
- package/dist/{chunk-RICPANBY.cjs → chunk-WX2E2G7H.cjs} +13 -4
- package/dist/{chunk-DE2SRBFZ.js → chunk-X335TJNS.js} +4 -3
- package/dist/{chunk-N2EIM2XJ.js → chunk-ZLNHPUFA.js} +22 -1
- package/dist/completion/CompletionService.cjs +30 -27
- package/dist/completion/CompletionService.d.cts +3 -2
- package/dist/completion/CompletionService.d.ts +3 -2
- package/dist/completion/CompletionService.js +29 -26
- package/dist/completion.cjs +38 -35
- package/dist/completion.d.cts +3 -2
- package/dist/completion.d.ts +3 -2
- package/dist/completion.js +37 -34
- package/dist/image-generation.cjs +52 -0
- package/dist/image-generation.d.cts +93 -0
- package/dist/image-generation.d.ts +93 -0
- package/dist/image-generation.js +52 -0
- package/dist/index.cjs +126 -31
- package/dist/index.d.cts +11 -7
- package/dist/index.d.ts +11 -7
- package/dist/index.js +143 -48
- package/dist/openai-operation.cjs +18 -0
- package/dist/openai-operation.d.cts +19 -0
- package/dist/openai-operation.d.ts +19 -0
- package/dist/openai-operation.js +18 -0
- package/dist/outbound-api/auditCapture.cjs +3 -3
- package/dist/outbound-api/auditCapture.d.cts +19 -2
- package/dist/outbound-api/auditCapture.d.ts +19 -2
- package/dist/outbound-api/auditCapture.js +2 -2
- package/dist/outbound-api/auditRedact.cjs +2 -2
- package/dist/outbound-api/auditRedact.js +1 -1
- package/dist/outbound-api/routeResolver.cjs +2 -2
- package/dist/outbound-api/routeResolver.d.cts +7 -4
- package/dist/outbound-api/routeResolver.d.ts +7 -4
- package/dist/outbound-api/routeResolver.js +1 -1
- package/dist/outbound-api/subscriptionRegistryPort.d.cts +2 -1
- package/dist/outbound-api/subscriptionRegistryPort.d.ts +2 -1
- package/dist/outbound-api/types.d.cts +6 -3
- package/dist/outbound-api/types.d.ts +6 -3
- package/dist/outbound-api.cjs +49 -32
- package/dist/outbound-api.d.cts +97 -10
- package/dist/outbound-api.d.ts +97 -10
- package/dist/outbound-api.js +48 -31
- package/dist/pipeline/AccountAllowanceScheduling.d.cts +18 -15
- package/dist/pipeline/AccountAllowanceScheduling.d.ts +18 -15
- package/dist/pipeline/LlmConfigProviderAuth.cjs +3 -3
- package/dist/pipeline/LlmConfigProviderAuth.js +2 -2
- package/dist/pipeline/SubscriptionAccountHealth.cjs +2 -2
- package/dist/pipeline/SubscriptionAccountHealth.d.cts +7 -0
- package/dist/pipeline/SubscriptionAccountHealth.d.ts +7 -0
- package/dist/pipeline/SubscriptionAccountHealth.js +1 -1
- package/dist/pipeline/executeProviderCall.cjs +2 -2
- package/dist/pipeline/executeProviderCall.d.cts +11 -6
- package/dist/pipeline/executeProviderCall.d.ts +11 -6
- package/dist/pipeline/executeProviderCall.js +1 -1
- package/dist/pipeline/upstreamFetch.cjs +2 -2
- package/dist/pipeline/upstreamFetch.d.cts +5 -0
- package/dist/pipeline/upstreamFetch.d.ts +5 -0
- package/dist/pipeline/upstreamFetch.js +1 -1
- package/dist/ports.d.cts +6 -3
- package/dist/ports.d.ts +6 -3
- package/dist/provider-proxy/ProviderProxy.cjs +30 -27
- package/dist/provider-proxy/ProviderProxy.d.cts +3 -2
- package/dist/provider-proxy/ProviderProxy.d.ts +3 -2
- package/dist/provider-proxy/ProviderProxy.js +29 -26
- package/dist/provider-proxy/identity/codexCliHeaders.cjs +4 -2
- package/dist/provider-proxy/identity/codexCliHeaders.d.cts +26 -6
- package/dist/provider-proxy/identity/codexCliHeaders.d.ts +26 -6
- package/dist/provider-proxy/identity/codexCliHeaders.js +5 -3
- package/dist/provider-proxy/ingress/providerProxyShared.cjs +32 -27
- package/dist/provider-proxy/ingress/providerProxyShared.d.cts +21 -8
- package/dist/provider-proxy/ingress/providerProxyShared.d.ts +21 -8
- package/dist/provider-proxy/ingress/providerProxyShared.js +31 -26
- package/dist/provider-proxy/types.d.cts +14 -483
- package/dist/provider-proxy/types.d.ts +14 -483
- package/dist/provider-proxy.cjs +44 -27
- package/dist/provider-proxy.d.cts +30 -8
- package/dist/provider-proxy.d.ts +30 -8
- package/dist/provider-proxy.js +43 -26
- package/dist/{routeResolver-C0mkkZaM.d.ts → routeResolver-CTCcSHWu.d.ts} +4 -2
- package/dist/{routeResolver-CVFE8KKe.d.cts → routeResolver-rpKQLyDO.d.cts} +4 -2
- package/dist/transformer/TransformerChainExecutor.cjs +2 -2
- package/dist/transformer/TransformerChainExecutor.d.cts +2 -2
- package/dist/transformer/TransformerChainExecutor.d.ts +2 -2
- package/dist/transformer/TransformerChainExecutor.js +1 -1
- package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.cjs +16 -0
- package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.d.cts +53 -0
- package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.d.ts +53 -0
- package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.js +16 -0
- package/dist/transformer/transformers/AnthropicTransformer.cjs +4 -3
- package/dist/transformer/transformers/AnthropicTransformer.js +3 -2
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +4 -4
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +3 -3
- package/dist/transformer/transformers/GeminiTransformer.cjs +4 -4
- package/dist/transformer/transformers/GeminiTransformer.js +3 -3
- package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +3 -3
- package/dist/transformer/transformers/OpenAIResponseTransformer.js +2 -2
- package/dist/transformer/transformers/OpenAITransformer.cjs +3 -3
- package/dist/transformer/transformers/OpenAITransformer.js +2 -2
- package/dist/transformer/transformers.cjs +10 -9
- package/dist/transformer/transformers.js +13 -12
- package/dist/transformer/types.d.cts +39 -4
- package/dist/transformer/types.d.ts +39 -4
- package/dist/transformer.cjs +14 -13
- package/dist/transformer.js +14 -13
- package/dist/{types-BB8pxk_3.d.ts → types-5T223WYQ.d.ts} +183 -23
- package/dist/types-Bd72H4SB.d.ts +196 -0
- package/dist/types-CVRge76p.d.ts +1115 -0
- package/dist/types-CbglB73l.d.cts +196 -0
- package/dist/types-DsHBBk3h.d.cts +1115 -0
- package/dist/{types-C2MwkLah.d.cts → types-jjU24eYG.d.cts} +183 -23
- package/dist/usage/usage-recorder.cjs +2 -2
- package/dist/usage/usage-recorder.d.cts +12 -2
- package/dist/usage/usage-recorder.d.ts +12 -2
- package/dist/usage/usage-recorder.js +1 -1
- package/dist/usage.cjs +20 -3
- package/dist/usage.d.cts +154 -0
- package/dist/usage.d.ts +154 -0
- package/dist/usage.js +20 -3
- package/package.json +69 -64
- package/dist/chunk-7C7DET6S.js +0 -154
- package/dist/chunk-7VU7V2E4.js +0 -0
- package/dist/chunk-EYZYXJTJ.cjs +0 -1
- package/dist/chunk-FCR77GYM.cjs +0 -33
- package/dist/chunk-K5NM7VAH.js +0 -33
- package/dist/chunk-XPIOJQS2.cjs +0 -154
- /package/dist/{chunk-XXFYLL7R.js → chunk-ECZ3ZE2C.js} +0 -0
- /package/dist/{chunk-3SCOLIPT.cjs → chunk-MXI2PWIC.cjs} +0 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Sayo
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sayo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
@omnicross/core — THIRD-PARTY NOTICES
|
|
2
|
-
======================================
|
|
3
|
-
|
|
4
|
-
This package contains code adapted from, and depends on, the following
|
|
5
|
-
third-party works. Their respective licenses apply to those portions.
|
|
6
|
-
|
|
7
|
-
--------------------------------------------------------------------------------
|
|
8
|
-
1. musistudio/llms (MIT License)
|
|
9
|
-
--------------------------------------------------------------------------------
|
|
10
|
-
|
|
11
|
-
The transformer subsystem (`src/transformer/`) — the unified-IR request/response
|
|
12
|
-
transformer chain (`TransformerService`, `TransformerChainExecutor`, and the
|
|
13
|
-
built-in transformers) — is adapted from the `musistudio/llms` project, the
|
|
14
|
-
upstream of the transformer intermediate representation.
|
|
15
|
-
|
|
16
|
-
Copyright (c) 2025 musistudio
|
|
17
|
-
https://github.com/musistudio/llms
|
|
18
|
-
|
|
19
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
20
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
21
|
-
in the Software without restriction, including without limitation the rights
|
|
22
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
23
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
24
|
-
furnished to do so, subject to the following conditions:
|
|
25
|
-
|
|
26
|
-
The above copyright notice and this permission notice shall be included in
|
|
27
|
-
all copies or substantial portions of the Software.
|
|
28
|
-
|
|
29
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
30
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
31
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
32
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
33
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
34
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
|
-
SOFTWARE.
|
|
36
|
-
|
|
37
|
-
--------------------------------------------------------------------------------
|
|
38
|
-
2. @mozilla/readability (Apache License 2.0)
|
|
39
|
-
--------------------------------------------------------------------------------
|
|
40
|
-
|
|
41
|
-
The built-in web-fetch tool (`src/completion/builtin-web-fetch.ts`) uses
|
|
42
|
-
`@mozilla/readability` to extract readable article content from fetched HTML.
|
|
43
|
-
|
|
44
|
-
Copyright Mozilla Foundation and contributors
|
|
45
|
-
https://github.com/mozilla/readability
|
|
46
|
-
|
|
47
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
48
|
-
use this file except in compliance with the License. You may obtain a copy of
|
|
49
|
-
the License at
|
|
50
|
-
|
|
51
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
52
|
-
|
|
53
|
-
Unless required by applicable law or agreed to in writing, software
|
|
54
|
-
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
55
|
-
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
56
|
-
License for the specific language governing permissions and limitations under
|
|
57
|
-
the License.
|
|
1
|
+
@omnicross/core — THIRD-PARTY NOTICES
|
|
2
|
+
======================================
|
|
3
|
+
|
|
4
|
+
This package contains code adapted from, and depends on, the following
|
|
5
|
+
third-party works. Their respective licenses apply to those portions.
|
|
6
|
+
|
|
7
|
+
--------------------------------------------------------------------------------
|
|
8
|
+
1. musistudio/llms (MIT License)
|
|
9
|
+
--------------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
The transformer subsystem (`src/transformer/`) — the unified-IR request/response
|
|
12
|
+
transformer chain (`TransformerService`, `TransformerChainExecutor`, and the
|
|
13
|
+
built-in transformers) — is adapted from the `musistudio/llms` project, the
|
|
14
|
+
upstream of the transformer intermediate representation.
|
|
15
|
+
|
|
16
|
+
Copyright (c) 2025 musistudio
|
|
17
|
+
https://github.com/musistudio/llms
|
|
18
|
+
|
|
19
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
20
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
21
|
+
in the Software without restriction, including without limitation the rights
|
|
22
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
23
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
24
|
+
furnished to do so, subject to the following conditions:
|
|
25
|
+
|
|
26
|
+
The above copyright notice and this permission notice shall be included in
|
|
27
|
+
all copies or substantial portions of the Software.
|
|
28
|
+
|
|
29
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
30
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
31
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
32
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
33
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
34
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
|
+
SOFTWARE.
|
|
36
|
+
|
|
37
|
+
--------------------------------------------------------------------------------
|
|
38
|
+
2. @mozilla/readability (Apache License 2.0)
|
|
39
|
+
--------------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
The built-in web-fetch tool (`src/completion/builtin-web-fetch.ts`) uses
|
|
42
|
+
`@mozilla/readability` to extract readable article content from fetched HTML.
|
|
43
|
+
|
|
44
|
+
Copyright Mozilla Foundation and contributors
|
|
45
|
+
https://github.com/mozilla/readability
|
|
46
|
+
|
|
47
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
48
|
+
use this file except in compliance with the License. You may obtain a copy of
|
|
49
|
+
the License at
|
|
50
|
+
|
|
51
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
52
|
+
|
|
53
|
+
Unless required by applicable law or agreed to in writing, software
|
|
54
|
+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
55
|
+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
56
|
+
License for the specific language governing permissions and limitations under
|
|
57
|
+
the License.
|
package/README.md
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
# @omnicross/core
|
|
2
|
-
|
|
3
|
-
The omnicross LLM serving core — provider dispatch, the completion pipeline, the transformer chain, the outbound API server, and the resident provider proxy. Embed it in any Node project, or run it via [`@omnicross/daemon`](https://www.npmjs.com/package/@omnicross/daemon).
|
|
4
|
-
|
|
5
|
-
Part of the [omnicross](https://github.com/Dumoedss/omnicross) monorepo — see the root README for the full overview.
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @omnicross/core @omnicross/contracts
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
# @omnicross/core
|
|
2
|
+
|
|
3
|
+
The omnicross LLM serving core — provider dispatch, the completion pipeline, the transformer chain, the outbound API server, and the resident provider proxy. Embed it in any Node project, or run it via [`@omnicross/daemon`](https://www.npmjs.com/package/@omnicross/daemon).
|
|
4
|
+
|
|
5
|
+
Part of the [omnicross](https://github.com/Dumoedss/omnicross) monorepo — see the root README for the full overview.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @omnicross/core @omnicross/contracts
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The published core runtime remains supported on Node.js `>=20.9`. The monorepo's
|
|
12
|
+
official OpenAI JavaScript SDK contract suite is contributor tooling, uses
|
|
13
|
+
`openai@7.8.x`, and requires Node.js 22 or newer. Run it from the repository root
|
|
14
|
+
with `npm run test:images-sdk-contract`; the command checks the Node major before
|
|
15
|
+
loading the SDK. The SDK is intentionally not a runtime or package-local
|
|
16
|
+
development dependency of `@omnicross/core`.
|
|
17
|
+
|
|
18
|
+
## License
|
|
19
|
+
|
|
20
|
+
[MIT](LICENSE)
|
|
21
|
+
|
|
22
|
+
This package adapts third-party work under its own license — see the `NOTICE` file.
|
|
@@ -3,7 +3,7 @@ import { LLMProvider } from '@omnicross/contracts/llm-config';
|
|
|
3
3
|
import { C as CorePaths, U as UsageEventSink } from './usage-event-sink-BX7FE1NL.cjs';
|
|
4
4
|
import { L as Logger } from './logger-4GvQNzhE.cjs';
|
|
5
5
|
import { ProviderConfigSource } from './ports/provider-config-source.cjs';
|
|
6
|
-
import { UsageRecorderImport } from './
|
|
6
|
+
import { U as UsageRecorderImport } from './types-DsHBBk3h.cjs';
|
|
7
7
|
import { O as OpenAITool, A as AnthropicTool, G as GeminiTools, M as McpToolProvider, B as BuiltinToolExecutor } from './BuiltinToolExecutor-CS2WpXhM.cjs';
|
|
8
8
|
import { C as CompletionOptions, S as StreamCallbacks, a as CompletionResult } from './types-BScIHmPr.cjs';
|
|
9
9
|
import { ApiKeyPoolService } from './completion/ApiKeyPoolService.cjs';
|
|
@@ -3,7 +3,7 @@ import { LLMProvider } from '@omnicross/contracts/llm-config';
|
|
|
3
3
|
import { C as CorePaths, U as UsageEventSink } from './usage-event-sink-BX7FE1NL.js';
|
|
4
4
|
import { L as Logger } from './logger-4GvQNzhE.js';
|
|
5
5
|
import { ProviderConfigSource } from './ports/provider-config-source.js';
|
|
6
|
-
import { UsageRecorderImport } from './
|
|
6
|
+
import { U as UsageRecorderImport } from './types-CVRge76p.js';
|
|
7
7
|
import { O as OpenAITool, A as AnthropicTool, G as GeminiTools, M as McpToolProvider, B as BuiltinToolExecutor } from './BuiltinToolExecutor-BluWyeob.js';
|
|
8
8
|
import { C as CompletionOptions, S as StreamCallbacks, a as CompletionResult } from './types-BScIHmPr.js';
|
|
9
9
|
import { ApiKeyPoolService } from './completion/ApiKeyPoolService.js';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
require('../chunk-
|
|
4
|
+
var _chunkVXRTQZF2cjs = require('../chunk-VXRTQZF2.cjs');
|
|
5
|
+
require('../chunk-WX2E2G7H.cjs');
|
|
6
6
|
require('../chunk-77USGNRW.cjs');
|
|
7
|
-
require('../chunk-
|
|
7
|
+
require('../chunk-IUL4VWNU.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkOST5RJOJcjs = require('../chunk-OST5RJOJ.cjs');
|
|
11
11
|
require('../chunk-235MXAGX.cjs');
|
|
12
12
|
require('../chunk-HVBBDBS3.cjs');
|
|
13
13
|
require('../chunk-NKVZ6Z3Y.cjs');
|
|
@@ -30,7 +30,7 @@ var GeminiCodeAssistHandshakeError = class extends Error {
|
|
|
30
30
|
var GeminiCodeAssistProjectResolver = (_class = class {
|
|
31
31
|
// upstream-proxy: the Code Assist handshake is upstream egress → honor the
|
|
32
32
|
// gemini proxy by default (still injectable for tests).
|
|
33
|
-
constructor(fetchImpl = (url, init) =>
|
|
33
|
+
constructor(fetchImpl = (url, init) => _chunkOST5RJOJcjs.fetchUpstream.call(void 0, url, init, { providerId: "gemini" })) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
34
34
|
this.fetchImpl = fetchImpl;
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -64,7 +64,7 @@ var GeminiCodeAssistProjectResolver = (_class = class {
|
|
|
64
64
|
return run;
|
|
65
65
|
}
|
|
66
66
|
codeAssistUrl(method) {
|
|
67
|
-
return `${
|
|
67
|
+
return `${_chunkVXRTQZF2cjs.resolveCodeAssistEndpoint.call(void 0, )}/${_chunkVXRTQZF2cjs.resolveCodeAssistApiVersion.call(void 0, )}:${method}`;
|
|
68
68
|
}
|
|
69
69
|
/** Seed project id from env; reject a purely-numeric value (project NUMBER). */
|
|
70
70
|
seedProjectId() {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveCodeAssistApiVersion,
|
|
3
3
|
resolveCodeAssistEndpoint
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-4VVCXVB7.js";
|
|
5
|
+
import "../chunk-R4VCO2CB.js";
|
|
6
6
|
import "../chunk-WYVGULTQ.js";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-ZLNHPUFA.js";
|
|
8
8
|
import {
|
|
9
9
|
fetchUpstream
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-CFSGYFOZ.js";
|
|
11
11
|
import "../chunk-3WD4HTR2.js";
|
|
12
12
|
import "../chunk-MKF46GNZ.js";
|
|
13
13
|
import "../chunk-GL6XM527.js";
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;// src/usage/throughputTracker.ts
|
|
2
|
+
var THROUGHPUT_RETENTION_MS = 15 * 6e4;
|
|
3
|
+
var THROUGHPUT_SAMPLE_LIMIT = 2e4;
|
|
4
|
+
var THROUGHPUT_WINDOWS_MS = [6e4, 3e5, 9e5];
|
|
5
|
+
var THROUGHPUT_BUCKET_COUNT = 30;
|
|
6
|
+
var COMPACT_THRESHOLD = 1024;
|
|
7
|
+
var UsageThroughputTracker = (_class = class {
|
|
8
|
+
__init() {this.samples = []}
|
|
9
|
+
/** Index of the oldest live sample; slots before it are consumed. */
|
|
10
|
+
__init2() {this.head = 0}
|
|
11
|
+
|
|
12
|
+
/** Newest ts dropped by the sample CAP (not by retention). Null when none. */
|
|
13
|
+
__init3() {this.evictedThroughTs = null}
|
|
14
|
+
constructor(now = Date.now()) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);
|
|
15
|
+
this.startedAt = now;
|
|
16
|
+
}
|
|
17
|
+
/** Record one served request. O(1) amortised; never touches disk. */
|
|
18
|
+
record(input, now = Date.now()) {
|
|
19
|
+
this.samples.push({
|
|
20
|
+
ts: _nullishCoalesce(input.ts, () => ( now)),
|
|
21
|
+
inputTokens: input.inputTokens,
|
|
22
|
+
outputTokens: input.outputTokens,
|
|
23
|
+
cacheReadTokens: input.cacheReadTokens,
|
|
24
|
+
cacheCreationTokens: input.cacheCreationTokens,
|
|
25
|
+
reasoningTokens: input.reasoningTokens,
|
|
26
|
+
costUsd: input.costUsd
|
|
27
|
+
});
|
|
28
|
+
this.prune(now);
|
|
29
|
+
}
|
|
30
|
+
/** Aggregate every reported window plus the shared trend series. */
|
|
31
|
+
snapshot(now = Date.now()) {
|
|
32
|
+
this.prune(now);
|
|
33
|
+
return {
|
|
34
|
+
available: true,
|
|
35
|
+
collectedAt: now,
|
|
36
|
+
startedAt: this.startedAt,
|
|
37
|
+
retentionMs: THROUGHPUT_RETENTION_MS,
|
|
38
|
+
bucketMs: THROUGHPUT_RETENTION_MS / THROUGHPUT_BUCKET_COUNT,
|
|
39
|
+
windows: THROUGHPUT_WINDOWS_MS.map((windowMs) => this.window(windowMs, now)),
|
|
40
|
+
buckets: this.buckets(now)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Drop all samples (tests / teardown). `startedAt` is unchanged. */
|
|
44
|
+
clear() {
|
|
45
|
+
this.samples = [];
|
|
46
|
+
this.head = 0;
|
|
47
|
+
this.evictedThroughTs = null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Drop samples past the retention horizon, then enforce the sample cap.
|
|
51
|
+
*
|
|
52
|
+
* Retention pruning uses the CALLER's `now`, which is never later than a
|
|
53
|
+
* subsequent snapshot's `now`, so it can only ever keep MORE than the widest
|
|
54
|
+
* window needs — it can never shave data off the 15-minute window.
|
|
55
|
+
*/
|
|
56
|
+
prune(now) {
|
|
57
|
+
const cutoff = now - THROUGHPUT_RETENTION_MS;
|
|
58
|
+
while (this.head < this.samples.length && this.samples[this.head].ts < cutoff) {
|
|
59
|
+
this.head += 1;
|
|
60
|
+
}
|
|
61
|
+
while (this.samples.length - this.head > THROUGHPUT_SAMPLE_LIMIT) {
|
|
62
|
+
const dropped = this.samples[this.head];
|
|
63
|
+
this.evictedThroughTs = this.evictedThroughTs === null ? dropped.ts : Math.max(this.evictedThroughTs, dropped.ts);
|
|
64
|
+
this.head += 1;
|
|
65
|
+
}
|
|
66
|
+
if (this.head >= COMPACT_THRESHOLD) {
|
|
67
|
+
this.samples = this.samples.slice(this.head);
|
|
68
|
+
this.head = 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
window(windowMs, now) {
|
|
72
|
+
const startTs = now - windowMs;
|
|
73
|
+
const row = {
|
|
74
|
+
windowMs,
|
|
75
|
+
requests: 0,
|
|
76
|
+
inputTokens: 0,
|
|
77
|
+
outputTokens: 0,
|
|
78
|
+
cacheReadTokens: 0,
|
|
79
|
+
cacheCreationTokens: 0,
|
|
80
|
+
reasoningTokens: 0,
|
|
81
|
+
totalTokens: 0,
|
|
82
|
+
costUsd: 0,
|
|
83
|
+
requestsPerMinute: 0,
|
|
84
|
+
tokensPerMinute: 0,
|
|
85
|
+
inputTokensPerMinute: 0,
|
|
86
|
+
outputTokensPerMinute: 0,
|
|
87
|
+
cacheTokensPerMinute: 0,
|
|
88
|
+
costUsdPerMinute: 0,
|
|
89
|
+
complete: this.evictedThroughTs === null || this.evictedThroughTs < startTs
|
|
90
|
+
};
|
|
91
|
+
for (let i = this.head; i < this.samples.length; i += 1) {
|
|
92
|
+
const sample = this.samples[i];
|
|
93
|
+
if (sample.ts < startTs) continue;
|
|
94
|
+
row.requests += 1;
|
|
95
|
+
row.inputTokens += sample.inputTokens;
|
|
96
|
+
row.outputTokens += sample.outputTokens;
|
|
97
|
+
row.cacheReadTokens += sample.cacheReadTokens;
|
|
98
|
+
row.cacheCreationTokens += sample.cacheCreationTokens;
|
|
99
|
+
row.reasoningTokens += sample.reasoningTokens;
|
|
100
|
+
row.costUsd += sample.costUsd;
|
|
101
|
+
}
|
|
102
|
+
row.totalTokens = row.inputTokens + row.outputTokens + row.cacheReadTokens + row.cacheCreationTokens;
|
|
103
|
+
const minutes = windowMs / 6e4;
|
|
104
|
+
row.requestsPerMinute = row.requests / minutes;
|
|
105
|
+
row.tokensPerMinute = row.totalTokens / minutes;
|
|
106
|
+
row.inputTokensPerMinute = row.inputTokens / minutes;
|
|
107
|
+
row.outputTokensPerMinute = row.outputTokens / minutes;
|
|
108
|
+
row.cacheTokensPerMinute = (row.cacheReadTokens + row.cacheCreationTokens) / minutes;
|
|
109
|
+
row.costUsdPerMinute = row.costUsd / minutes;
|
|
110
|
+
return row;
|
|
111
|
+
}
|
|
112
|
+
buckets(now) {
|
|
113
|
+
const bucketMs = THROUGHPUT_RETENTION_MS / THROUGHPUT_BUCKET_COUNT;
|
|
114
|
+
const endTs = Math.floor(now / bucketMs) * bucketMs + bucketMs;
|
|
115
|
+
const startTs = endTs - THROUGHPUT_RETENTION_MS;
|
|
116
|
+
const out = [];
|
|
117
|
+
for (let i = 0; i < THROUGHPUT_BUCKET_COUNT; i += 1) {
|
|
118
|
+
out.push({ startTs: startTs + i * bucketMs, requests: 0, tokens: 0, outputTokens: 0 });
|
|
119
|
+
}
|
|
120
|
+
for (let i = this.head; i < this.samples.length; i += 1) {
|
|
121
|
+
const sample = this.samples[i];
|
|
122
|
+
if (sample.ts < startTs || sample.ts >= endTs) continue;
|
|
123
|
+
const bucket = out[Math.floor((sample.ts - startTs) / bucketMs)];
|
|
124
|
+
if (!bucket) continue;
|
|
125
|
+
bucket.requests += 1;
|
|
126
|
+
bucket.outputTokens += sample.outputTokens;
|
|
127
|
+
bucket.tokens += sample.inputTokens + sample.outputTokens + sample.cacheReadTokens + sample.cacheCreationTokens;
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
}, _class);
|
|
132
|
+
var sharedTracker = null;
|
|
133
|
+
function getSharedUsageThroughputTracker() {
|
|
134
|
+
if (!sharedTracker) sharedTracker = new UsageThroughputTracker();
|
|
135
|
+
return sharedTracker;
|
|
136
|
+
}
|
|
137
|
+
function setSharedUsageThroughputTracker(instance) {
|
|
138
|
+
sharedTracker = instance;
|
|
139
|
+
}
|
|
140
|
+
function __resetSharedUsageThroughputTrackerForTests() {
|
|
141
|
+
sharedTracker = null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
exports.THROUGHPUT_RETENTION_MS = THROUGHPUT_RETENTION_MS; exports.THROUGHPUT_SAMPLE_LIMIT = THROUGHPUT_SAMPLE_LIMIT; exports.THROUGHPUT_WINDOWS_MS = THROUGHPUT_WINDOWS_MS; exports.THROUGHPUT_BUCKET_COUNT = THROUGHPUT_BUCKET_COUNT; exports.UsageThroughputTracker = UsageThroughputTracker; exports.getSharedUsageThroughputTracker = getSharedUsageThroughputTracker; exports.setSharedUsageThroughputTracker = setSharedUsageThroughputTracker; exports.__resetSharedUsageThroughputTrackerForTests = __resetSharedUsageThroughputTrackerForTests;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// src/openai-operation/openAIOperation.ts
|
|
2
|
+
var OPERATIONS = {
|
|
3
|
+
"chat.completions.create": {
|
|
4
|
+
id: "chat.completions.create",
|
|
5
|
+
policyFamily: "chat",
|
|
6
|
+
routeFamily: "chat",
|
|
7
|
+
owner: "builtin",
|
|
8
|
+
bodyKind: "json",
|
|
9
|
+
requestedModelSource: "request"
|
|
10
|
+
},
|
|
11
|
+
"responses.create": {
|
|
12
|
+
id: "responses.create",
|
|
13
|
+
policyFamily: "responses",
|
|
14
|
+
routeFamily: "responses",
|
|
15
|
+
owner: "builtin",
|
|
16
|
+
bodyKind: "json",
|
|
17
|
+
requestedModelSource: "request"
|
|
18
|
+
},
|
|
19
|
+
"responses.compact": {
|
|
20
|
+
id: "responses.compact",
|
|
21
|
+
policyFamily: "responses",
|
|
22
|
+
routeFamily: "responses",
|
|
23
|
+
owner: "extension",
|
|
24
|
+
bodyKind: "json",
|
|
25
|
+
requestedModelSource: "request"
|
|
26
|
+
},
|
|
27
|
+
"images.generate": {
|
|
28
|
+
id: "images.generate",
|
|
29
|
+
policyFamily: "images",
|
|
30
|
+
routeFamily: "images",
|
|
31
|
+
owner: "extension",
|
|
32
|
+
bodyKind: "json",
|
|
33
|
+
requestedModelSource: "configured"
|
|
34
|
+
},
|
|
35
|
+
"images.edit": {
|
|
36
|
+
id: "images.edit",
|
|
37
|
+
policyFamily: "images",
|
|
38
|
+
routeFamily: "images",
|
|
39
|
+
owner: "extension",
|
|
40
|
+
bodyKind: "multipart",
|
|
41
|
+
requestedModelSource: "configured"
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var MATCH_ORDER = [
|
|
45
|
+
{ id: "responses.compact", suffix: ["responses", "compact"] },
|
|
46
|
+
{ id: "images.generate", suffix: ["images", "generations"] },
|
|
47
|
+
{ id: "images.edit", suffix: ["images", "edits"] },
|
|
48
|
+
{ id: "chat.completions.create", suffix: ["chat", "completions"] },
|
|
49
|
+
{ id: "responses.create", suffix: ["responses"] }
|
|
50
|
+
];
|
|
51
|
+
function getOpenAIOperation(id) {
|
|
52
|
+
return OPERATIONS[id];
|
|
53
|
+
}
|
|
54
|
+
function pathSegments(url) {
|
|
55
|
+
const queryIndex = url.indexOf("?");
|
|
56
|
+
const path = queryIndex >= 0 ? url.slice(0, queryIndex) : url;
|
|
57
|
+
return path.split("/").filter(Boolean);
|
|
58
|
+
}
|
|
59
|
+
function hasExactSuffix(segments, suffix) {
|
|
60
|
+
if (segments.length < suffix.length) return false;
|
|
61
|
+
const offset = segments.length - suffix.length;
|
|
62
|
+
return suffix.every((segment, index) => segments[offset + index] === segment);
|
|
63
|
+
}
|
|
64
|
+
function classifyOpenAIOperation(method, url) {
|
|
65
|
+
if (method !== "POST" || !url) return null;
|
|
66
|
+
const segments = pathSegments(url);
|
|
67
|
+
for (const candidate of MATCH_ORDER) {
|
|
68
|
+
if (hasExactSuffix(segments, candidate.suffix)) return OPERATIONS[candidate.id];
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/openai-operation/openAIOperationRegistry.ts
|
|
74
|
+
var OpenAIOperationRegistrationError = class extends Error {
|
|
75
|
+
constructor(code, message) {
|
|
76
|
+
super(message);
|
|
77
|
+
this.code = code;
|
|
78
|
+
}
|
|
79
|
+
code;
|
|
80
|
+
name = "OpenAIOperationRegistrationError";
|
|
81
|
+
};
|
|
82
|
+
var OpenAIOperationError = class extends Error {
|
|
83
|
+
name = "OpenAIOperationError";
|
|
84
|
+
status;
|
|
85
|
+
code;
|
|
86
|
+
retryable;
|
|
87
|
+
headers;
|
|
88
|
+
constructor(init) {
|
|
89
|
+
super(init.message);
|
|
90
|
+
this.status = init.status;
|
|
91
|
+
this.code = init.code;
|
|
92
|
+
this.retryable = init.retryable ?? false;
|
|
93
|
+
this.headers = init.headers ?? {};
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var SAFE_LOCAL_ERROR_HEADERS = /* @__PURE__ */ new Set(["retry-after", "x-request-id"]);
|
|
97
|
+
function safeErrorHeaders(headers) {
|
|
98
|
+
const safe = {};
|
|
99
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
100
|
+
if (SAFE_LOCAL_ERROR_HEADERS.has(name.toLowerCase())) safe[name] = value;
|
|
101
|
+
}
|
|
102
|
+
return safe;
|
|
103
|
+
}
|
|
104
|
+
function writeOpenAIOperationError(res, error) {
|
|
105
|
+
if (res.headersSent || res.writableEnded) return false;
|
|
106
|
+
res.writeHead(error.status, {
|
|
107
|
+
"Content-Type": "application/json",
|
|
108
|
+
...safeErrorHeaders(error.headers)
|
|
109
|
+
});
|
|
110
|
+
res.end(JSON.stringify({
|
|
111
|
+
error: {
|
|
112
|
+
type: "openai_operation_error",
|
|
113
|
+
code: error.code,
|
|
114
|
+
message: error.message,
|
|
115
|
+
retryable: error.retryable
|
|
116
|
+
}
|
|
117
|
+
}));
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
function unsupportedOpenAIOperation(operation) {
|
|
121
|
+
return new OpenAIOperationError({
|
|
122
|
+
status: 501,
|
|
123
|
+
code: "unsupported_capability",
|
|
124
|
+
message: `Operation '${operation.id}' is not available`
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
var OpenAIOperationRegistry = class {
|
|
128
|
+
handlers = /* @__PURE__ */ new Map();
|
|
129
|
+
register(operationId, handler) {
|
|
130
|
+
const operation = getOpenAIOperation(operationId);
|
|
131
|
+
if (operation.owner !== "extension") {
|
|
132
|
+
throw new OpenAIOperationRegistrationError(
|
|
133
|
+
"builtin_operation",
|
|
134
|
+
`Operation '${operationId}' is owned by a built-in ingress`
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
if (this.handlers.has(operationId)) {
|
|
138
|
+
throw new OpenAIOperationRegistrationError(
|
|
139
|
+
"duplicate_operation_handler",
|
|
140
|
+
`Operation '${operationId}' already has a handler`
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
this.handlers.set(operationId, handler);
|
|
144
|
+
let disposed = false;
|
|
145
|
+
return () => {
|
|
146
|
+
if (disposed) return;
|
|
147
|
+
disposed = true;
|
|
148
|
+
if (this.handlers.get(operationId) === handler) this.handlers.delete(operationId);
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
has(operationId) {
|
|
152
|
+
return this.handlers.has(operationId);
|
|
153
|
+
}
|
|
154
|
+
async dispatch(context) {
|
|
155
|
+
const handler = this.handlers.get(context.operation.id);
|
|
156
|
+
if (!handler) return false;
|
|
157
|
+
const controller = new AbortController();
|
|
158
|
+
const abort = () => {
|
|
159
|
+
if (!controller.signal.aborted) controller.abort();
|
|
160
|
+
};
|
|
161
|
+
const onRequestClose = () => {
|
|
162
|
+
if (context.request.aborted || !context.request.complete) abort();
|
|
163
|
+
};
|
|
164
|
+
const onResponseClose = () => {
|
|
165
|
+
if (!context.response.writableEnded) abort();
|
|
166
|
+
};
|
|
167
|
+
context.request.once("aborted", abort);
|
|
168
|
+
context.request.once("close", onRequestClose);
|
|
169
|
+
context.response.once("close", onResponseClose);
|
|
170
|
+
if (context.request.aborted || context.response.destroyed) abort();
|
|
171
|
+
try {
|
|
172
|
+
await handler({ ...context, signal: controller.signal });
|
|
173
|
+
return true;
|
|
174
|
+
} catch (error) {
|
|
175
|
+
const publicError = error instanceof OpenAIOperationError ? error : new OpenAIOperationError({
|
|
176
|
+
status: 500,
|
|
177
|
+
code: "operation_handler_failed",
|
|
178
|
+
message: `Operation '${context.operation.id}' handler failed`
|
|
179
|
+
});
|
|
180
|
+
if (!writeOpenAIOperationError(context.response, publicError)) {
|
|
181
|
+
throw new Error(publicError.message);
|
|
182
|
+
}
|
|
183
|
+
return true;
|
|
184
|
+
} finally {
|
|
185
|
+
context.request.removeListener("aborted", abort);
|
|
186
|
+
context.request.removeListener("close", onRequestClose);
|
|
187
|
+
context.response.removeListener("close", onResponseClose);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export {
|
|
193
|
+
getOpenAIOperation,
|
|
194
|
+
classifyOpenAIOperation,
|
|
195
|
+
OpenAIOperationRegistrationError,
|
|
196
|
+
OpenAIOperationError,
|
|
197
|
+
writeOpenAIOperationError,
|
|
198
|
+
unsupportedOpenAIOperation,
|
|
199
|
+
OpenAIOperationRegistry
|
|
200
|
+
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
transformRequestOut,
|
|
4
4
|
transformResponseIn,
|
|
5
5
|
transformResponseOut
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-R4VCO2CB.js";
|
|
7
7
|
|
|
8
8
|
// src/transformer/transformers/GeminiCodeAssistTransformer.ts
|
|
9
9
|
var DEFAULT_CODE_ASSIST_ENDPOINT = "https://cloudcode-pa.googleapis.com";
|