@kindgi/adapter-model-azure-openai 0.0.0-stage → 0.1.7
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 +201 -0
- package/README.md +90 -2
- package/dist/config.d.ts +61 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +260 -0
- package/dist/config.js.map +1 -0
- package/dist/entry.d.ts +11 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +195 -0
- package/dist/entry.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -3
- package/src/config.ts +319 -0
- package/src/entry.ts +258 -0
- package/src/index.ts +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Kindgi Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,91 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@kindgi/adapter-model-azure-openai`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Azure OpenAI `ModelProvider` for [`@kindgi/capabilities`](../../capabilities/): a registration's models served by your Azure OpenAI deployments, on the v1 API, signed in with the resource's key or with the runtime's own Entra identity.
|
|
4
|
+
|
|
5
|
+
It covers **Azure OpenAI deployments**. Other models served by Azure AI Foundry (Llama, Mistral, DeepSeek…) aren't in it.
|
|
6
|
+
|
|
7
|
+
It's built on [`@kindgi/adapter-model-shared`](../model-shared/): the retries, typed errors (`ModelProviderError`), the reasoning state carried across a pause, usage and cost are the same as every adapter built on it. The requests are sent by the AI SDK's `@ai-sdk/azure` provider at the provider-spec level, pinned exactly.
|
|
8
|
+
|
|
9
|
+
## A registration
|
|
10
|
+
|
|
11
|
+
`adapter_id: @kindgi/adapter-model-azure-openai`, with these `adapter_config` keys:
|
|
12
|
+
|
|
13
|
+
| Key | What |
|
|
14
|
+
|---|---|
|
|
15
|
+
| `resourceName` | The Azure OpenAI resource, as in `<name>.openai.azure.com`. |
|
|
16
|
+
| `baseURL` | Instead of `resourceName`: a custom endpoint, https, with no credentials, query or fragment. On an Azure OpenAI host (another cloud's, say) it ends in `/openai/v1`; a gateway's is any path, with `auth: api-key`. |
|
|
17
|
+
| `deployments` | Required. The deployment serving each registered model: `"model=deployment,…"`, e.g. `"gpt-6.1-sol=gpt-6-1-sol,gpt-6-luna=luna-prod"`. Azure deployment names are yours to choose (often the model's own name, as `gpt-6.1-sol`), so every model in `metadata.models` needs one. |
|
|
18
|
+
| `api` | `responses` (default) or `chat-completions`. Tools with GPT-6 need `responses`: Azure refuses them on Chat Completions while the model reasons. |
|
|
19
|
+
| `auth` | `api-key` (default): the resource's key, through `secret_ref`. `entra`: the runtime's Azure identity; no `secret_ref`; an Azure OpenAI host only (below). |
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"adapter_id": "@kindgi/adapter-model-azure-openai",
|
|
24
|
+
"adapter_config": {
|
|
25
|
+
"resourceName": "acme-openai",
|
|
26
|
+
"deployments": "gpt-6.1-sol=gpt-6-1-sol",
|
|
27
|
+
"auth": "entra"
|
|
28
|
+
},
|
|
29
|
+
"metadata": {
|
|
30
|
+
"id": "azure-openai",
|
|
31
|
+
"region": "canadacentral",
|
|
32
|
+
"models": [
|
|
33
|
+
{
|
|
34
|
+
"name": "gpt-6.1-sol",
|
|
35
|
+
"contextWindow": 1050000,
|
|
36
|
+
"sampling": false,
|
|
37
|
+
"features": ["tool-use", "structured-output"],
|
|
38
|
+
"cost": { "promptUsdPer1kTokens": 0.002, "completionUsdPer1kTokens": 0.01, "cachedPromptMultiplier": 0.05 }
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`checkConfig` reports each problem with a registration at the setting at fault, without the network or the secret:
|
|
46
|
+
- `resourceName` and `baseURL` together, or neither;
|
|
47
|
+
- a `resourceName` that isn't one DNS label, or a `baseURL` that isn't https;
|
|
48
|
+
- an unknown `api`, `auth` or `adapter_config` key;
|
|
49
|
+
- `api-key` without `secret_ref`, or `entra` with one;
|
|
50
|
+
- `entra` on a host that isn't Azure OpenAI's, naming the host;
|
|
51
|
+
- a `baseURL` with credentials, a query or a fragment, ending in more than one `/`, or an Azure OpenAI host's `baseURL` without `/openai/v1`;
|
|
52
|
+
- a malformed `deployments` entry, a model named twice or not listed, a deployment name Azure wouldn't take, or a model with no deployment.
|
|
53
|
+
|
|
54
|
+
## How it signs in
|
|
55
|
+
|
|
56
|
+
Each of these has a test. It signs in before each attempt, with the call's abort signal, and the attempt's request carries what that sign-in got, so calls running at once never share a credential.
|
|
57
|
+
- **`auth: entra`:** a bearer token from the runtime's Azure identity (`AdapterFactoryInput.identities.azure`), asked for every attempt (the identity caches and renews it), within 10 seconds; a call stopped meanwhile ends at once, with its own reason. No `api-key` header is sent. A runtime with no Azure identity refuses the registration, naming `KINDGI_AZURE_CLIENT_ID`. The identity needs the **Cognitive Services OpenAI User** role on the resource.
|
|
58
|
+
- **Only an Azure OpenAI host gets the token**, because whoever receives it could use it against every Azure OpenAI resource the runtime's identity has a role on. Another host is refused at registration (and by the factory), naming it:
|
|
59
|
+
|
|
60
|
+
| Cloud | Hosts | Scope |
|
|
61
|
+
|---|---|---|
|
|
62
|
+
| Azure | `*.openai.azure.com`, `*.cognitiveservices.azure.com`, `*.services.ai.azure.com` | `https://cognitiveservices.azure.com/.default` |
|
|
63
|
+
| Azure Government | `*.openai.azure.us`, `*.cognitiveservices.azure.us` | `https://cognitiveservices.azure.us/.default` |
|
|
64
|
+
|
|
65
|
+
Microsoft lists each cloud's endpoints on [Compare Azure Government and global Azure](https://learn.microsoft.com/en-us/azure/azure-government/compare-azure-government-global-azure). Azure Government needs the runtime's identity to be in Azure Government too.
|
|
66
|
+
- **`auth: api-key`:** the key `secret_ref` names, read for every attempt and sent as `api-key` (whitespace around it dropped), so a rotated key takes effect on the next call.
|
|
67
|
+
- **A failed sign-in** (the identity gives no token, the key can't be read, even with the secret store down, or is empty or blank) ends the call as an `auth` error at once, never retried.
|
|
68
|
+
- **No request follows a redirect** (`redirect: 'error'`): the credential reaches the endpoint and nothing else.
|
|
69
|
+
- **Never the environment:** `AZURE_API_KEY` and `AZURE_RESOURCE_NAME` are never read. The provider is always given its endpoint and its credential.
|
|
70
|
+
|
|
71
|
+
## What it sends
|
|
72
|
+
|
|
73
|
+
- **Responses** (the default): `POST …/openai/v1/responses?api-version=v1`, with the deployment as `model` and `store: false`, so Azure keeps no conversation state for it: Kindgi's journal is the record.
|
|
74
|
+
- **Chat Completions:** `POST …/openai/v1/chat/completions`, with the deployment as `model`.
|
|
75
|
+
- **Whether a model reasons** is the registration's to say: one registered with `thinking` or `sampling: false` reasons, one with `sampling: true` doesn't, whatever its deployment is called. A reasoning model keeps its encrypted reasoning between tool turns on Responses, and gets `max_completion_tokens` on Chat Completions. When the registration says neither, the AI SDK decides from the deployment's name, so register one or the other when the name doesn't say.
|
|
76
|
+
- Every attempt goes through the runtime's `fetch` (`AdapterFactoryInput.fetch`), which refuses the hosts its deployment forbids.
|
|
77
|
+
|
|
78
|
+
## Cost
|
|
79
|
+
|
|
80
|
+
`costUsd` is `tokenCostUsd` over the model's registered rates: prompt and completion, cached prompt tokens at `cachedPromptMultiplier`, and the long-context tier when registered. Azure's prices depend on the deployment type (Global, Data Zone, Regional), so register the rates of yours. Costs are estimates from published prices; Azure's invoice is authoritative.
|
|
81
|
+
|
|
82
|
+
## Exports
|
|
83
|
+
|
|
84
|
+
- **`azureOpenAIAdapterEntry`**: the `AdapterFactoryEntry` a runtime registers, with `azureOpenAIAdapterFactory` and `azureOpenAICheckConfig`.
|
|
85
|
+
- `readAzureOpenAIConfig(input)`: a registration read and checked, or every problem with it.
|
|
86
|
+
- `AZURE_OPENAI_CLOUDS` and `azureCloudOf(hostname)`: the hosts Entra may go to, by cloud, with each scope.
|
|
87
|
+
- `AZURE_OPENAI_ADAPTER_ID`, `AZURE_OPENAI_APIS`, `AZURE_OPENAI_AUTHS`, `AZURE_OPENAI_SCOPE` (the public cloud's), `IDENTITY_TIMEOUT_MS`, and the `AzureOpenAIConfig`, `AzureOpenAIApi` and `AzureOpenAIAuth` types.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
Apache-2.0
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An Azure OpenAI registration's `adapter_config`, read and checked: where the resource is,
|
|
3
|
+
* which API, how to sign in, and which deployment serves each model. Static: no network, no
|
|
4
|
+
* secret read (`checkConfig` runs it at registration, the factory again when it builds).
|
|
5
|
+
*/
|
|
6
|
+
import type { AdapterConfigCheckInput, AdapterConfigProblem } from '@kindgi/capabilities';
|
|
7
|
+
export declare const AZURE_OPENAI_ADAPTER_ID = "@kindgi/adapter-model-azure-openai";
|
|
8
|
+
/** The v1 API's Responses (the default), or Chat Completions. */
|
|
9
|
+
export declare const AZURE_OPENAI_APIS: readonly ["responses", "chat-completions"];
|
|
10
|
+
export type AzureOpenAIApi = (typeof AZURE_OPENAI_APIS)[number];
|
|
11
|
+
/** A key (`secret_ref`, sent as `api-key`), or the runtime's Entra identity (a bearer token). */
|
|
12
|
+
export declare const AZURE_OPENAI_AUTHS: readonly ["api-key", "entra"];
|
|
13
|
+
export type AzureOpenAIAuth = (typeof AZURE_OPENAI_AUTHS)[number];
|
|
14
|
+
export interface AzureOpenAIConfig {
|
|
15
|
+
readonly endpoint: {
|
|
16
|
+
readonly resourceName: string;
|
|
17
|
+
} | {
|
|
18
|
+
readonly baseURL: string;
|
|
19
|
+
};
|
|
20
|
+
readonly api: AzureOpenAIApi;
|
|
21
|
+
readonly auth: AzureOpenAIAuth;
|
|
22
|
+
/** With `auth: entra`: the scope the runtime's token is for, the endpoint's cloud's. */
|
|
23
|
+
readonly scope?: string;
|
|
24
|
+
/** The deployment for each registered model. */
|
|
25
|
+
readonly deployments: ReadonlyMap<string, string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The hosts the runtime's Entra token may go to, by cloud, each with the scope its tokens are
|
|
29
|
+
* for. Nothing else gets the token: a registration naming another host could replay it against
|
|
30
|
+
* every Azure OpenAI resource the runtime's identity holds a role on. A custom endpoint (a
|
|
31
|
+
* gateway) takes `auth: api-key`.
|
|
32
|
+
*
|
|
33
|
+
* Sources (read 2026-10-09): the endpoints by cloud,
|
|
34
|
+
* https://learn.microsoft.com/en-us/azure/azure-government/compare-azure-government-global-azure;
|
|
35
|
+
* Azure Government's scope, https://learn.microsoft.com/en-us/dotnet/api/overview/azure/ai.openai-readme
|
|
36
|
+
* (its Azure Government example). Microsoft's newer pages name the public
|
|
37
|
+
* scope `https://ai.azure.com/.default`; `cognitiveservices.azure.com` is the one proven live
|
|
38
|
+
* (2026-10-09), so it stays until a live run proves the other.
|
|
39
|
+
*/
|
|
40
|
+
export declare const AZURE_OPENAI_CLOUDS: readonly [{
|
|
41
|
+
readonly cloud: "Azure";
|
|
42
|
+
readonly hostSuffixes: readonly [".openai.azure.com", ".cognitiveservices.azure.com", ".services.ai.azure.com"];
|
|
43
|
+
readonly scope: "https://cognitiveservices.azure.com/.default";
|
|
44
|
+
}, {
|
|
45
|
+
readonly cloud: "Azure Government";
|
|
46
|
+
readonly hostSuffixes: readonly [".openai.azure.us", ".cognitiveservices.azure.us"];
|
|
47
|
+
readonly scope: "https://cognitiveservices.azure.us/.default";
|
|
48
|
+
}];
|
|
49
|
+
type AzureCloud = (typeof AZURE_OPENAI_CLOUDS)[number];
|
|
50
|
+
/** The cloud an Azure OpenAI host belongs to; undefined for any other host. */
|
|
51
|
+
export declare function azureCloudOf(hostname: string): AzureCloud | undefined;
|
|
52
|
+
/** The registration read, or every problem with it. */
|
|
53
|
+
export declare function readAzureOpenAIConfig(input: AdapterConfigCheckInput): {
|
|
54
|
+
readonly kind: 'ok';
|
|
55
|
+
readonly config: AzureOpenAIConfig;
|
|
56
|
+
} | {
|
|
57
|
+
readonly kind: 'err';
|
|
58
|
+
readonly problems: readonly AdapterConfigProblem[];
|
|
59
|
+
};
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EAErB,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,uBAAuB,uCAAuC,CAAC;AAE5E,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,4CAA6C,CAAC;AAC5E,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,iGAAiG;AACjG,eAAO,MAAM,kBAAkB,+BAAgC,CAAC;AAChE,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACpF,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,wFAAwF;IACxF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnD;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;EAWtB,CAAC;AAEX,KAAK,UAAU,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAKrE;AAqBD,uDAAuD;AACvD,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,uBAAuB,GAE5B;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAA;CAAE,GAC3D;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,oBAAoB,EAAE,CAAA;CAAE,CAkG/E"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
export const AZURE_OPENAI_ADAPTER_ID = '@kindgi/adapter-model-azure-openai';
|
|
4
|
+
/** The v1 API's Responses (the default), or Chat Completions. */
|
|
5
|
+
export const AZURE_OPENAI_APIS = ['responses', 'chat-completions'];
|
|
6
|
+
/** A key (`secret_ref`, sent as `api-key`), or the runtime's Entra identity (a bearer token). */
|
|
7
|
+
export const AZURE_OPENAI_AUTHS = ['api-key', 'entra'];
|
|
8
|
+
/**
|
|
9
|
+
* The hosts the runtime's Entra token may go to, by cloud, each with the scope its tokens are
|
|
10
|
+
* for. Nothing else gets the token: a registration naming another host could replay it against
|
|
11
|
+
* every Azure OpenAI resource the runtime's identity holds a role on. A custom endpoint (a
|
|
12
|
+
* gateway) takes `auth: api-key`.
|
|
13
|
+
*
|
|
14
|
+
* Sources (read 2026-10-09): the endpoints by cloud,
|
|
15
|
+
* https://learn.microsoft.com/en-us/azure/azure-government/compare-azure-government-global-azure;
|
|
16
|
+
* Azure Government's scope, https://learn.microsoft.com/en-us/dotnet/api/overview/azure/ai.openai-readme
|
|
17
|
+
* (its Azure Government example). Microsoft's newer pages name the public
|
|
18
|
+
* scope `https://ai.azure.com/.default`; `cognitiveservices.azure.com` is the one proven live
|
|
19
|
+
* (2026-10-09), so it stays until a live run proves the other.
|
|
20
|
+
*/
|
|
21
|
+
export const AZURE_OPENAI_CLOUDS = [
|
|
22
|
+
{
|
|
23
|
+
cloud: 'Azure',
|
|
24
|
+
hostSuffixes: ['.openai.azure.com', '.cognitiveservices.azure.com', '.services.ai.azure.com'],
|
|
25
|
+
scope: 'https://cognitiveservices.azure.com/.default',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
cloud: 'Azure Government',
|
|
29
|
+
hostSuffixes: ['.openai.azure.us', '.cognitiveservices.azure.us'],
|
|
30
|
+
scope: 'https://cognitiveservices.azure.us/.default',
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
/** The cloud an Azure OpenAI host belongs to; undefined for any other host. */
|
|
34
|
+
export function azureCloudOf(hostname) {
|
|
35
|
+
const host = hostname.toLowerCase();
|
|
36
|
+
return AZURE_OPENAI_CLOUDS.find((c) => c.hostSuffixes.some((suffix) => host.endsWith(suffix) && host.length > suffix.length));
|
|
37
|
+
}
|
|
38
|
+
/** The v1 API's path on an Azure OpenAI host. */
|
|
39
|
+
const V1_PATH = '/openai/v1';
|
|
40
|
+
const AZURE_HOSTS = AZURE_OPENAI_CLOUDS.flatMap((c) => c.hostSuffixes.map((s) => `*${s}`)).join(', ');
|
|
41
|
+
const KEYS = ['resourceName', 'baseURL', 'deployments', 'api', 'auth'];
|
|
42
|
+
/** A single DNS label, as Azure's resource names are. */
|
|
43
|
+
const RESOURCE_NAME = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;
|
|
44
|
+
/**
|
|
45
|
+
* A deployment name as it can sit in this setting and in the request path: Azure sets no
|
|
46
|
+
* character rule of its own (its ARM reference says only "string"; `gpt-6.1-sol` is a real
|
|
47
|
+
* one), so only what would break the setting (`,`, `=`) or the path (`/`, whitespace) is refused,
|
|
48
|
+
* and Azure answers for the rest.
|
|
49
|
+
*/
|
|
50
|
+
const DEPLOYMENT_NAME = /^[^\s,=/]+$/;
|
|
51
|
+
const at = (key) => `/adapter_config/${key}`;
|
|
52
|
+
/** The registration read, or every problem with it. */
|
|
53
|
+
export function readAzureOpenAIConfig(input) {
|
|
54
|
+
const config = input.config ?? {};
|
|
55
|
+
const problems = [];
|
|
56
|
+
for (const key of Object.keys(config)) {
|
|
57
|
+
if (!KEYS.includes(key)) {
|
|
58
|
+
problems.push({
|
|
59
|
+
path: at(key),
|
|
60
|
+
message: `adapter_config.${key} isn't an Azure OpenAI setting: it takes resourceName or baseURL, deployments, api and auth.`,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const auth = config.auth ?? 'api-key';
|
|
65
|
+
const resourceName = config.resourceName;
|
|
66
|
+
const baseURL = config.baseURL;
|
|
67
|
+
let endpoint;
|
|
68
|
+
let cloud;
|
|
69
|
+
if (resourceName !== undefined && baseURL !== undefined) {
|
|
70
|
+
problems.push({
|
|
71
|
+
path: at('baseURL'),
|
|
72
|
+
message: 'adapter_config.resourceName and adapter_config.baseURL exclude each other: the resource, or a custom endpoint.',
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else if (resourceName !== undefined) {
|
|
76
|
+
if (typeof resourceName !== 'string' || !RESOURCE_NAME.test(resourceName)) {
|
|
77
|
+
problems.push({
|
|
78
|
+
path: at('resourceName'),
|
|
79
|
+
message: 'adapter_config.resourceName must be the Azure OpenAI resource name, as in <name>.openai.azure.com (letters, digits, hyphens).',
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
endpoint = { resourceName };
|
|
84
|
+
cloud = AZURE_OPENAI_CLOUDS[0];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else if (baseURL !== undefined) {
|
|
88
|
+
const read = readBaseURL(baseURL, auth, problems);
|
|
89
|
+
if (read !== undefined) {
|
|
90
|
+
endpoint = { baseURL: read.baseURL };
|
|
91
|
+
cloud = read.cloud;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
problems.push({
|
|
96
|
+
path: at('resourceName'),
|
|
97
|
+
message: 'needs adapter_config.resourceName, the Azure OpenAI resource (as in <name>.openai.azure.com), or adapter_config.baseURL for a custom endpoint.',
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const api = config.api ?? 'responses';
|
|
101
|
+
if (!AZURE_OPENAI_APIS.includes(api)) {
|
|
102
|
+
problems.push({
|
|
103
|
+
path: at('api'),
|
|
104
|
+
message: `adapter_config.api must be one of ${AZURE_OPENAI_APIS.join(', ')}.`,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (!AZURE_OPENAI_AUTHS.includes(auth)) {
|
|
108
|
+
problems.push({
|
|
109
|
+
path: at('auth'),
|
|
110
|
+
message: `adapter_config.auth must be one of ${AZURE_OPENAI_AUTHS.join(', ')}.`,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
else if (auth === 'api-key' && !input.hasSecretRef) {
|
|
114
|
+
problems.push({
|
|
115
|
+
path: '/secret_ref',
|
|
116
|
+
message: "needs secret_ref: the resource's API key (or adapter_config.auth = entra, to sign in as the runtime's Azure identity).",
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
else if (auth === 'entra' && input.hasSecretRef) {
|
|
120
|
+
problems.push({
|
|
121
|
+
path: '/secret_ref',
|
|
122
|
+
message: "adapter_config.auth = entra signs in as the runtime's Azure identity: remove secret_ref.",
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (auth === 'entra' && input.identities?.azure === false) {
|
|
126
|
+
problems.push({
|
|
127
|
+
path: at('auth'),
|
|
128
|
+
message: "adapter_config.auth = entra needs the runtime's Azure identity (its managed identity; KINDGI_AZURE_CLIENT_ID names a user-assigned one), and this runtime has none.",
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const deployments = readDeployments(config.deployments, input.metadata, problems);
|
|
132
|
+
if (problems.length > 0 || endpoint === undefined || deployments === undefined) {
|
|
133
|
+
return { kind: 'err', problems };
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
kind: 'ok',
|
|
137
|
+
config: {
|
|
138
|
+
endpoint,
|
|
139
|
+
api: api,
|
|
140
|
+
auth: auth,
|
|
141
|
+
...(auth === 'entra' && cloud !== undefined && { scope: cloud.scope }),
|
|
142
|
+
deployments,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* A custom endpoint: https, with no credentials, query or fragment (they'd sit in the stored
|
|
148
|
+
* settings); on an Azure OpenAI host, the v1 path (the portal's endpoint lacks it, and would
|
|
149
|
+
* 404); and with `auth: entra`, an Azure OpenAI host only.
|
|
150
|
+
*/
|
|
151
|
+
function readBaseURL(value, auth, problems) {
|
|
152
|
+
const path = at('baseURL');
|
|
153
|
+
const url = typeof value === 'string' ? parseUrl(value) : undefined;
|
|
154
|
+
if (url === undefined || url.protocol !== 'https:') {
|
|
155
|
+
problems.push({
|
|
156
|
+
path,
|
|
157
|
+
message: `adapter_config.baseURL must be an https URL (e.g. https://<name>.openai.azure.com${V1_PATH}).`,
|
|
158
|
+
});
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
const before = problems.length;
|
|
162
|
+
const raw = value;
|
|
163
|
+
if (url.username !== '' || url.password !== '') {
|
|
164
|
+
problems.push({
|
|
165
|
+
path,
|
|
166
|
+
message: "adapter_config.baseURL can't hold credentials: a key goes in secret_ref, never in the URL.",
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
if (url.search !== '' || raw.includes('?') || url.hash !== '' || raw.includes('#')) {
|
|
170
|
+
problems.push({
|
|
171
|
+
path,
|
|
172
|
+
message: "adapter_config.baseURL can't hold a query or a fragment: a key goes in secret_ref, and the API version is the adapter's.",
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
if (/\/\/+$/.test(url.pathname)) {
|
|
176
|
+
problems.push({
|
|
177
|
+
path,
|
|
178
|
+
message: "adapter_config.baseURL can't end in more than one /: the adapter adds the API's path.",
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
const cloud = azureCloudOf(url.hostname);
|
|
182
|
+
if (cloud !== undefined && url.pathname.replace(/\/+$/, '') !== V1_PATH) {
|
|
183
|
+
problems.push({
|
|
184
|
+
path,
|
|
185
|
+
message: `adapter_config.baseURL on an Azure OpenAI host must end in ${V1_PATH} (https://${url.hostname}${V1_PATH}), the v1 API.`,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (auth === 'entra' && cloud === undefined) {
|
|
189
|
+
problems.push({
|
|
190
|
+
path,
|
|
191
|
+
message: `adapter_config.auth = entra sends the runtime's Azure token, which goes only to an Azure OpenAI host (${AZURE_HOSTS}); ${url.hostname} isn't one. A custom endpoint takes auth = api-key.`,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return problems.length === before ? { baseURL: raw, cloud } : undefined;
|
|
195
|
+
}
|
|
196
|
+
/** `"model=deployment,model=deployment"`: every registered model, each a deployment Azure takes. */
|
|
197
|
+
function readDeployments(value, metadata, problems) {
|
|
198
|
+
const path = at('deployments');
|
|
199
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
200
|
+
problems.push({
|
|
201
|
+
path,
|
|
202
|
+
message: 'needs adapter_config.deployments, the deployment for each model: "model=deployment,…" (e.g. "gpt-6.1-sol=gpt-6-1-sol").',
|
|
203
|
+
});
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
const models = new Set(metadata.models.map((m) => m.name));
|
|
207
|
+
const map = new Map();
|
|
208
|
+
const before = problems.length;
|
|
209
|
+
for (const pair of value.split(',')) {
|
|
210
|
+
const [model, deployment, extra] = pair.split('=').map((part) => part.trim());
|
|
211
|
+
if (model === undefined ||
|
|
212
|
+
model === '' ||
|
|
213
|
+
deployment === undefined ||
|
|
214
|
+
deployment === '' ||
|
|
215
|
+
extra !== undefined) {
|
|
216
|
+
problems.push({
|
|
217
|
+
path,
|
|
218
|
+
message: `adapter_config.deployments has "${pair.trim()}": each entry is model=deployment.`,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
else if (map.has(model)) {
|
|
222
|
+
problems.push({
|
|
223
|
+
path,
|
|
224
|
+
message: `adapter_config.deployments names ${model} twice: one deployment each.`,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
else if (!models.has(model)) {
|
|
228
|
+
problems.push({
|
|
229
|
+
path,
|
|
230
|
+
message: `adapter_config.deployments names ${model}, which this registration doesn't list in metadata.models.`,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
else if (!DEPLOYMENT_NAME.test(deployment)) {
|
|
234
|
+
problems.push({
|
|
235
|
+
path,
|
|
236
|
+
message: `adapter_config.deployments gives ${model} the deployment "${deployment}": a deployment name can't hold spaces, ",", "=" or "/".`,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
else
|
|
240
|
+
map.set(model, deployment);
|
|
241
|
+
}
|
|
242
|
+
for (const model of models) {
|
|
243
|
+
if (!map.has(model) && problems.length === before) {
|
|
244
|
+
problems.push({
|
|
245
|
+
path,
|
|
246
|
+
message: `adapter_config.deployments has no deployment for ${model}.`,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return problems.length === before ? map : undefined;
|
|
251
|
+
}
|
|
252
|
+
function parseUrl(value) {
|
|
253
|
+
try {
|
|
254
|
+
return new URL(value);
|
|
255
|
+
}
|
|
256
|
+
catch {
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=config.js.map
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;QAC3B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YAClD,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI;gBACJ,OAAO,EAAE,oDAAoD,KAAK,GAAG;aACtE,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC7B,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/entry.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AdapterConfigCheckInput, type AdapterConfigProblem, type AdapterFactory, type AdapterFactoryEntry } from '@kindgi/capabilities';
|
|
2
|
+
/** The Entra scope Azure OpenAI takes in Azure's public cloud. */
|
|
3
|
+
export declare const AZURE_OPENAI_SCOPE: "https://cognitiveservices.azure.com/.default";
|
|
4
|
+
/** How long a token from the runtime's identity may take before the call fails as `auth`. */
|
|
5
|
+
export declare const IDENTITY_TIMEOUT_MS = 10000;
|
|
6
|
+
/** What's wrong with a registration, for `POST /v1/providers` and `GET …/check`. */
|
|
7
|
+
export declare function azureOpenAICheckConfig(input: AdapterConfigCheckInput): readonly AdapterConfigProblem[];
|
|
8
|
+
export declare const azureOpenAIAdapterFactory: AdapterFactory;
|
|
9
|
+
/** The entry a runtime registers: the factory, and its static check. */
|
|
10
|
+
export declare const azureOpenAIAdapterEntry: AdapterFactoryEntry;
|
|
11
|
+
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AA4BA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EAKzB,MAAM,sBAAsB,CAAC;AAK9B,kEAAkE;AAClE,eAAO,MAAM,kBAAkB,gDAA+B,CAAC;AAE/D,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAE1C,oFAAoF;AACpF,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,uBAAuB,GAC7B,SAAS,oBAAoB,EAAE,CAGjC;AAED,eAAO,MAAM,yBAAyB,EAAE,cAwDvC,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,EAAE,mBAKrC,CAAC"}
|