@skaile/forge-settings 1.3.3 → 2.0.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +52 -9
  3. package/dist/module.json +1 -1
  4. package/dist/runtime/ai-sdk/index.d.ts +33 -26
  5. package/dist/runtime/ai-sdk/index.js +34 -16
  6. package/dist/runtime/components/ForgeProvidersPanel.d.vue.ts +13 -0
  7. package/dist/runtime/components/ForgeProvidersPanel.vue +461 -78
  8. package/dist/runtime/components/ForgeProvidersPanel.vue.d.ts +13 -0
  9. package/dist/runtime/editor/index.d.ts +55 -16
  10. package/dist/runtime/editor/index.js +82 -40
  11. package/dist/runtime/model/selector.d.ts +16 -0
  12. package/dist/runtime/model/selector.js +12 -0
  13. package/dist/runtime/server/credential-store.d.ts +16 -4
  14. package/dist/runtime/server/credential-store.js +3 -4
  15. package/dist/runtime/server/env-layers.d.ts +1 -1
  16. package/dist/runtime/server/env-layers.js +3 -3
  17. package/dist/runtime/server/index.d.ts +9 -8
  18. package/dist/runtime/server/index.js +3 -3
  19. package/dist/runtime/server/provider-discovery.d.ts +28 -8
  20. package/dist/runtime/server/provider-discovery.js +57 -33
  21. package/dist/runtime/server/provider-layers.d.ts +1 -1
  22. package/dist/runtime/server/provider-layers.js +3 -5
  23. package/dist/runtime/server/provider-service.d.ts +26 -2
  24. package/dist/runtime/server/provider-service.js +16 -1
  25. package/dist/runtime/server/provider-write.d.ts +26 -10
  26. package/dist/runtime/server/provider-write.js +75 -7
  27. package/dist/runtime/server/voice-provider.d.ts +61 -0
  28. package/dist/runtime/server/voice-provider.js +31 -0
  29. package/dist/runtime/shared/data-zone.d.ts +68 -0
  30. package/dist/runtime/shared/data-zone.js +79 -0
  31. package/dist/runtime/shared/harness-providers.d.ts +42 -3
  32. package/dist/runtime/shared/harness-providers.js +31 -8
  33. package/dist/runtime/shared/harnesses.d.ts +7 -0
  34. package/dist/runtime/shared/harnesses.js +18 -0
  35. package/dist/runtime/shared/provider-accounts.d.ts +215 -0
  36. package/dist/runtime/shared/provider-accounts.js +255 -0
  37. package/dist/runtime/shared/provider-registry.d.ts +19 -182
  38. package/dist/runtime/shared/provider-registry.js +25 -65
  39. package/dist/runtime/vue/index.d.ts +2 -0
  40. package/dist/runtime/vue/index.js +2 -0
  41. package/dist/runtime/vue/providers-panel-model.d.ts +98 -5
  42. package/dist/runtime/vue/providers-panel-model.js +13 -1
  43. package/dist/runtime/vue/useProvidersPanel.d.ts +66 -5
  44. package/dist/runtime/vue/useProvidersPanel.js +417 -29
  45. package/dist/runtime/{server → workspaces}/harness-settings.d.ts +51 -13
  46. package/dist/runtime/{server → workspaces}/harness-settings.js +93 -9
  47. package/dist/runtime/workspaces/index.d.ts +16 -0
  48. package/dist/runtime/workspaces/index.js +5 -0
  49. package/dist/runtime/workspaces/language-model.d.ts +45 -0
  50. package/dist/runtime/workspaces/language-model.js +26 -0
  51. package/dist/runtime/workspaces/model-endpoint.d.ts +38 -0
  52. package/dist/runtime/workspaces/model-endpoint.js +54 -0
  53. package/dist/runtime/workspaces/provider-settings.d.ts +35 -0
  54. package/dist/runtime/{server → workspaces}/provider-settings.js +0 -31
  55. package/dist/runtime/{server → workspaces}/settings-defaults.d.ts +1 -1
  56. package/dist/runtime/{shared → workspaces}/settings-types.d.ts +11 -4
  57. package/package.json +11 -2
  58. package/src/runtime/ai-sdk/index.ts +88 -47
  59. package/src/runtime/components/ForgeProvidersPanel.vue +477 -78
  60. package/src/runtime/editor/index.ts +158 -63
  61. package/src/runtime/model/selector.ts +31 -0
  62. package/src/runtime/server/credential-store.ts +20 -10
  63. package/src/runtime/server/env-layers.ts +4 -4
  64. package/src/runtime/server/index.ts +9 -8
  65. package/src/runtime/server/provider-discovery.ts +114 -48
  66. package/src/runtime/server/provider-layers.ts +6 -6
  67. package/src/runtime/server/provider-service.ts +53 -1
  68. package/src/runtime/server/provider-write.ts +132 -18
  69. package/src/runtime/server/voice-provider.ts +110 -0
  70. package/src/runtime/shared/data-zone.ts +179 -0
  71. package/src/runtime/shared/harness-providers.ts +78 -7
  72. package/src/runtime/shared/harnesses.ts +25 -0
  73. package/src/runtime/shared/provider-accounts.ts +526 -0
  74. package/src/runtime/shared/provider-registry.ts +82 -256
  75. package/src/runtime/vue/index.ts +2 -0
  76. package/src/runtime/vue/providers-panel-model.ts +123 -5
  77. package/src/runtime/vue/useProvidersPanel.ts +589 -37
  78. package/src/runtime/{server → workspaces}/harness-settings.ts +166 -22
  79. package/src/runtime/workspaces/index.ts +17 -0
  80. package/src/runtime/workspaces/language-model.ts +82 -0
  81. package/src/runtime/workspaces/model-endpoint.ts +100 -0
  82. package/src/runtime/workspaces/provider-settings.ts +96 -0
  83. package/src/runtime/{server → workspaces}/settings-defaults.ts +1 -1
  84. package/src/runtime/{shared → workspaces}/settings-types.ts +11 -4
  85. package/dist/runtime/server/provider-settings.d.ts +0 -78
  86. package/src/runtime/server/provider-settings.ts +0 -192
  87. /package/dist/runtime/{server → workspaces}/settings-defaults.js +0 -0
  88. /package/dist/runtime/{shared → workspaces}/settings-types.js +0 -0
@@ -1,166 +1,23 @@
1
1
  /**
2
2
  * The AI provider registry vocabulary, as forge-settings speaks it.
3
3
  *
4
- * `@skaile/workspaces` owns this schema (`core/src/provider-registry.ts`): the
5
- * validator, the layer merge, the catalog presets and the model-reference
6
- * resolver live there and are deliberately NOT reimplemented here. What follows
7
- * is a *structural* mirror of the record so browser bundles do not import the
8
- * workspaces core. Field names, union members and optionality match the
9
- * upstream record exactly, so an entry produced by the runtime is assignable to
10
- * these types and vice versa.
4
+ * The schema is `@skaile/provider-registry`'s: every record type, the
5
+ * enumerations and the credential-reference grammar below are re-exported from
6
+ * there, so an entry this package reads is the same type the runtime resolves
7
+ * and there is one validator, not a mirror. What this module adds are Forge's
8
+ * view helpers: reading either registry shape in registry order, filtering by
9
+ * kind, voice selection and the credential editor's wording.
11
10
  *
12
- * Browser-safe on purpose — no `node:` imports — so the settings modal renders
13
- * registry entries with the same types the server resolves them with.
11
+ * Browser-safe on purpose — no `node:` imports, and only the browser-safe root
12
+ * of `@skaile/provider-registry` — so the settings modal renders registry
13
+ * entries with the same types the server resolves them with.
14
14
  *
15
15
  * Vocabulary: these are **AI provider** records. They are unrelated to the
16
16
  * platform's connector `ProviderType`/`ProviderLink` (git, SharePoint, Drive).
17
17
  */
18
- /** What an entry produces. `stt`/`tts` use the reduced voice record. */
19
- export declare const AI_PROVIDER_KINDS: readonly ["llm", "stt", "tts", "embed"];
20
- /** Union of {@link AI_PROVIDER_KINDS}. */
21
- export type AIProviderKind = (typeof AI_PROVIDER_KINDS)[number];
22
- /** Kinds that use the voice subset of the record. */
23
- export declare const AI_PROVIDER_VOICE_KINDS: readonly ["stt", "tts"];
24
- /** Union of {@link AI_PROVIDER_VOICE_KINDS}. */
25
- export type AIProviderVoiceKind = (typeof AI_PROVIDER_VOICE_KINDS)[number];
26
- /** Wire protocol of an `llm`/`embed` entry — omp's `api` values verbatim. */
27
- export declare const AI_PROVIDER_SURFACES: readonly ["anthropic-messages", "openai-completions", "openai-responses", "openai-codex-responses", "azure-openai-responses", "bedrock-converse-stream", "google-generative-ai", "google-vertex"];
28
- /** Union of {@link AI_PROVIDER_SURFACES}. */
29
- export type AIProviderSurface = (typeof AI_PROVIDER_SURFACES)[number];
30
- /** How the request reaches the surface — selects the `params` shape. */
31
- export declare const AI_PROVIDER_TRANSPORTS: readonly ["direct", "bedrock", "vertex", "foundry", "azure-openai"];
32
- /** Union of {@link AI_PROVIDER_TRANSPORTS}. */
33
- export type AIProviderTransport = (typeof AI_PROVIDER_TRANSPORTS)[number];
34
- /** How the credential is presented. */
35
- export declare const AI_PROVIDER_CREDENTIAL_KINDS: readonly ["api_key_header", "bearer", "sigv4", "google_adc", "azure_entra", "oauth", "command", "none"];
36
- /** Union of {@link AI_PROVIDER_CREDENTIAL_KINDS}. */
37
- export type AIProviderCredentialKind = (typeof AI_PROVIDER_CREDENTIAL_KINDS)[number];
38
- /** `transport: bedrock` routing parameters. */
39
- export interface AIProviderBedrockParams {
40
- /** AWS region, e.g. `us-east-1`. */
41
- region: string;
42
- }
43
- /** `transport: vertex` routing parameters. */
44
- export interface AIProviderVertexParams {
45
- /** GCP project id. */
46
- project: string;
47
- /** Vertex location, e.g. `europe-west4`. */
48
- location: string;
49
- /** Model publisher; defaults to `google`. */
50
- publisher?: string;
51
- }
52
- /** `transport: foundry` routing parameters. */
53
- export interface AIProviderFoundryParams {
54
- /** Azure AI Foundry resource name. */
55
- resource: string;
56
- }
57
- /** `transport: azure-openai` routing parameters. */
58
- export interface AIProviderAzureOpenAIParams {
59
- /** Azure OpenAI resource name. */
60
- resource: string;
61
- /** Deployment the request is routed to. */
62
- deployment: string;
63
- /** `api-version` query value. */
64
- api_version: string;
65
- }
66
- /** Voice parameters, typed per preset: Deepgram `{model, language}`, ElevenLabs `{voice_id, output_format}`. */
67
- export type AIProviderVoiceParams = Record<string, string | number | boolean>;
68
- /** The `transport` → `params` discriminated union. */
69
- export type AIProviderTransportSlice = {
70
- transport?: "direct";
71
- params?: Record<string, never>;
72
- } | {
73
- transport: "bedrock";
74
- params: AIProviderBedrockParams;
75
- } | {
76
- transport: "vertex";
77
- params: AIProviderVertexParams;
78
- } | {
79
- transport: "foundry";
80
- params: AIProviderFoundryParams;
81
- } | {
82
- transport: "azure-openai";
83
- params: AIProviderAzureOpenAIParams;
84
- };
85
- /** Reference to a secret — never the secret itself. See {@link parseCredentialRef}. */
86
- export interface AIProviderCredential {
87
- kind: AIProviderCredentialKind;
88
- /**
89
- * `env:NAME` · `cmd:<shell>` · `platform:<configId>` · `keyring:<service>/<account>`.
90
- * A literal secret here is a validation error, not a warning.
91
- */
92
- ref?: string;
93
- }
94
- /** Per-model capability facts, keyed by the logical (`model_map`) id. */
95
- export interface AIProviderCapabilities {
96
- context_window?: number;
97
- tools?: boolean;
98
- images?: boolean;
99
- thinking_max?: number;
100
- }
101
- /** omp-compatible discovery descriptor. */
102
- export interface AIProviderDiscovery {
103
- type: string;
104
- /** Path appended to `base_url` when the surface default does not apply. */
105
- path?: string;
106
- }
107
- /** Fields every entry carries, whatever its `kind`. */
108
- export interface AIProviderEntryCommon {
109
- /** Display name. Never load-bearing. */
110
- label?: string;
111
- /** Catalog preset this entry inherits from. */
112
- preset?: string;
113
- /** Literal endpoint; wins over the preset value and the transport derivation. */
114
- base_url?: string;
115
- /** Static, non-secret request headers. */
116
- headers?: Record<string, string>;
117
- credential?: AIProviderCredential;
118
- /** Default `true`; read it through {@link isEntryEnabled}. */
119
- enabled?: boolean;
120
- /** Set by the control plane: lower layers cannot override this entry. */
121
- locked?: boolean;
122
- }
123
- /** An `llm`/`embed` entry — the full record. */
124
- export type AIProviderLlmEntry = AIProviderEntryCommon & AIProviderTransportSlice & {
125
- kind: "llm" | "embed";
126
- /** Required unless a `preset` supplies it. */
127
- surface?: AIProviderSurface;
128
- /** Azure's `api-version` lives here. */
129
- query_params?: Record<string, string>;
130
- /** Logical id → provider-side id. */
131
- model_map?: Record<string, string>;
132
- /** Keyed by the logical id, i.e. the `model_map` key. */
133
- capabilities?: Record<string, AIProviderCapabilities>;
134
- discovery?: AIProviderDiscovery;
135
- };
136
- /**
137
- * An `stt`/`tts` entry — the reduced record. `surface`, `transport`,
138
- * `model_map`, `capabilities` and `discovery` are `llm`-only: a TTS voice is
139
- * not a wire protocol. The voice defaults forge apps used to hardcode at their
140
- * call sites (Deepgram model/language, ElevenLabs voice id/output format) live
141
- * in `params`.
142
- */
143
- export type AIProviderVoiceEntry = AIProviderEntryCommon & {
144
- kind: AIProviderVoiceKind;
145
- params?: AIProviderVoiceParams;
146
- };
147
- /** One registry entry. */
148
- export type AIProviderEntry = AIProviderLlmEntry | AIProviderVoiceEntry;
149
- /** Entry id → entry. Iteration order is registry order. */
150
- export type AIProviderRegistry = Record<string, AIProviderEntry>;
151
- /** Configuration layers, lowest precedence first. */
152
- export type AIProviderLayerId = "catalog" | "user" | "workspace" | "runtime" | "session";
153
- /** The merged, layered view the runtime hands to a session. */
154
- export interface MergedAIProviderRegistry {
155
- version: 1;
156
- providers: AIProviderRegistry;
157
- /** Registry order: highest-precedence layer first, document order within a layer. */
158
- order: string[];
159
- /** Highest-precedence layer that contributed to each entry. */
160
- origin: Record<string, AIProviderLayerId>;
161
- /** Entries frozen by `locked: true`. */
162
- locked: string[];
163
- }
18
+ import type { AIProviderEntry, AIProviderKind, AIProviderLayerId, AIProviderLlmEntry, AIProviderRegistry, AIProviderVoiceEntry, AIProviderVoiceKind, MergedAIProviderRegistry } from "@skaile/provider-registry";
19
+ export type { AIProviderAzureOpenAIParams, AIProviderBedrockParams, AIProviderCapabilities, AIProviderCredential, AIProviderCredentialKind, AIProviderCredentialRef, AIProviderDataZone, AIProviderDataZoneRule, AIProviderDiscovery, AIProviderEntry, AIProviderEntryCommon, AIProviderFoundryParams, AIProviderKind, AIProviderLayerId, AIProviderLlmEntry, AIProviderModelAllowListFields, AIProviderRegistry, AIProviderSurface, AIProviderTransport, AIProviderTransportSlice, AIProviderVertexParams, AIProviderVoiceEntry, AIProviderVoiceKind, AIProviderVoiceParams, MergedAIProviderRegistry, } from "@skaile/provider-registry";
20
+ export { AI_PROVIDER_CREDENTIAL_KINDS, AI_PROVIDER_DATA_ZONE_RULES, AI_PROVIDER_DATA_ZONES, AI_PROVIDER_KINDS, AI_PROVIDER_SURFACES, AI_PROVIDER_TRANSPORTS, AI_PROVIDER_VOICE_KINDS, allowedModelIds, formatCredentialRef, isEntryEnabled, isModelAllowed, parseCredentialRef, } from "@skaile/provider-registry";
164
21
  /** Either shape a consumer may be handed. */
165
22
  export type AIProviderRegistryView = AIProviderRegistry | MergedAIProviderRegistry;
166
23
  /**
@@ -170,8 +27,13 @@ export type AIProviderRegistryView = AIProviderRegistry | MergedAIProviderRegist
170
27
  * reading it) has to put the entries back in the shape it was handed.
171
28
  */
172
29
  export declare function isMergedRegistry(registry: AIProviderRegistryView): registry is MergedAIProviderRegistry;
173
- /** `enabled` defaults to `true`. */
174
- export declare function isEntryEnabled(entry: AIProviderEntry): boolean;
30
+ /**
31
+ * The layered shape of a view. A merged registry is returned as is; a bare
32
+ * entry map becomes one layer in its own iteration order, reported as the
33
+ * `runtime` layer (the host handed it over in memory) with nothing locked.
34
+ * The model constructor resolves against this shape only.
35
+ */
36
+ export declare function asMergedRegistry(registry: AIProviderRegistryView, layer?: AIProviderLayerId): MergedAIProviderRegistry;
175
37
  /** Entries in registry order, as `[id, entry]` pairs. Both registry shapes accepted. */
176
38
  export declare function registryEntries(registry: AIProviderRegistryView): Array<[string, AIProviderEntry]>;
177
39
  /**
@@ -211,31 +73,6 @@ export declare const VOICE_OVERRIDE_SETTING: {
211
73
  * @returns The chosen id, or `undefined` when no entry of that kind exists.
212
74
  */
213
75
  export declare function selectVoiceEntryId(ids: readonly string[], wanted?: string): string | undefined;
214
- /** A parsed `credential.ref`. */
215
- export type AIProviderCredentialRef = {
216
- form: "env";
217
- name: string;
218
- } | {
219
- form: "cmd";
220
- command: string;
221
- } | {
222
- form: "platform";
223
- configId: string;
224
- } | {
225
- form: "keyring";
226
- service: string;
227
- account: string;
228
- };
229
- /**
230
- * Parse a `credential.ref`.
231
- *
232
- * Returns `undefined` for anything that is not one of the four reference forms
233
- * — which, in a registry entry or a credential editor, means someone typed a
234
- * literal secret.
235
- */
236
- export declare function parseCredentialRef(ref: string): AIProviderCredentialRef | undefined;
237
- /** Render a parsed reference back to its `<form>:<body>` string. */
238
- export declare function formatCredentialRef(ref: AIProviderCredentialRef): string;
239
76
  /** The reference forms, spelled the way a credential editor offers them. */
240
77
  export declare const CREDENTIAL_REF_FORMS: readonly ["env:NAME", "keyring:service/account", "cmd:<shell command>", "platform:<configId>"];
241
78
  /** What a credential editor tells a user who typed something that is not a reference. */
@@ -1,37 +1,31 @@
1
- export const AI_PROVIDER_KINDS = ["llm", "stt", "tts", "embed"];
2
- export const AI_PROVIDER_VOICE_KINDS = ["stt", "tts"];
3
- export const AI_PROVIDER_SURFACES = [
4
- "anthropic-messages",
5
- "openai-completions",
6
- "openai-responses",
7
- "openai-codex-responses",
8
- "azure-openai-responses",
9
- "bedrock-converse-stream",
10
- "google-generative-ai",
11
- "google-vertex"
12
- ];
13
- export const AI_PROVIDER_TRANSPORTS = [
14
- "direct",
15
- "bedrock",
16
- "vertex",
17
- "foundry",
18
- "azure-openai"
19
- ];
20
- export const AI_PROVIDER_CREDENTIAL_KINDS = [
21
- "api_key_header",
22
- "bearer",
23
- "sigv4",
24
- "google_adc",
25
- "azure_entra",
26
- "oauth",
27
- "command",
28
- "none"
29
- ];
1
+ import { isEntryEnabled, parseCredentialRef } from "@skaile/provider-registry";
2
+ export {
3
+ AI_PROVIDER_CREDENTIAL_KINDS,
4
+ AI_PROVIDER_DATA_ZONE_RULES,
5
+ AI_PROVIDER_DATA_ZONES,
6
+ AI_PROVIDER_KINDS,
7
+ AI_PROVIDER_SURFACES,
8
+ AI_PROVIDER_TRANSPORTS,
9
+ AI_PROVIDER_VOICE_KINDS,
10
+ allowedModelIds,
11
+ formatCredentialRef,
12
+ isEntryEnabled,
13
+ isModelAllowed,
14
+ parseCredentialRef
15
+ } from "@skaile/provider-registry";
30
16
  export function isMergedRegistry(registry) {
31
17
  return Array.isArray(registry.order);
32
18
  }
33
- export function isEntryEnabled(entry) {
34
- return entry.enabled !== false;
19
+ export function asMergedRegistry(registry, layer = "runtime") {
20
+ if (isMergedRegistry(registry)) return registry;
21
+ const order = Object.keys(registry);
22
+ return {
23
+ version: 1,
24
+ providers: registry,
25
+ order,
26
+ origin: Object.fromEntries(order.map((id) => [id, layer])),
27
+ locked: []
28
+ };
35
29
  }
36
30
  export function registryEntries(registry) {
37
31
  if (isMergedRegistry(registry)) {
@@ -54,41 +48,7 @@ export function selectVoiceEntryId(ids, wanted) {
54
48
  if (trimmed && ids.includes(trimmed)) return trimmed;
55
49
  return ids[0];
56
50
  }
57
- const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
58
51
  const CREDENTIAL_REF = /^(env|cmd|platform|keyring):([\s\S]+)$/;
59
- export function parseCredentialRef(ref) {
60
- const match = CREDENTIAL_REF.exec(ref.trim());
61
- if (!match) return void 0;
62
- const body = match[2].trim();
63
- if (body === "") return void 0;
64
- switch (match[1]) {
65
- case "env":
66
- return ENV_NAME.test(body) ? { form: "env", name: body } : void 0;
67
- case "cmd":
68
- return { form: "cmd", command: body };
69
- case "platform":
70
- return { form: "platform", configId: body };
71
- case "keyring": {
72
- const slash = body.indexOf("/");
73
- if (slash <= 0 || slash === body.length - 1) return void 0;
74
- return { form: "keyring", service: body.slice(0, slash), account: body.slice(slash + 1) };
75
- }
76
- default:
77
- return void 0;
78
- }
79
- }
80
- export function formatCredentialRef(ref) {
81
- switch (ref.form) {
82
- case "env":
83
- return `env:${ref.name}`;
84
- case "cmd":
85
- return `cmd:${ref.command}`;
86
- case "platform":
87
- return `platform:${ref.configId}`;
88
- case "keyring":
89
- return `keyring:${ref.service}/${ref.account}`;
90
- }
91
- }
92
52
  export const CREDENTIAL_REF_FORMS = [
93
53
  "env:NAME",
94
54
  "keyring:service/account",
@@ -6,10 +6,12 @@
6
6
  * `ForgeProvidersPanel` itself is registered as a component by
7
7
  * `@skaile/forge-settings/nuxt`.
8
8
  */
9
+ export * from "../shared/data-zone.js";
9
10
  export * from "../shared/env-vars.js";
10
11
  export * from "../shared/harness-providers.js";
11
12
  export * from "../shared/harnesses.js";
12
13
  export * from "../shared/model-roles.js";
14
+ export * from "../shared/provider-accounts.js";
13
15
  export * from "../shared/provider-registry.js";
14
16
  export * from "./model-roles-panel.js";
15
17
  export * from "./providers-client.js";
@@ -1,7 +1,9 @@
1
+ export * from "../shared/data-zone.js";
1
2
  export * from "../shared/env-vars.js";
2
3
  export * from "../shared/harness-providers.js";
3
4
  export * from "../shared/harnesses.js";
4
5
  export * from "../shared/model-roles.js";
6
+ export * from "../shared/provider-accounts.js";
5
7
  export * from "../shared/provider-registry.js";
6
8
  export * from "./model-roles-panel.js";
7
9
  export * from "./providers-client.js";
@@ -5,7 +5,8 @@
5
5
  * are re-exported by `useProvidersPanel`; the rest is internal to the package.
6
6
  */
7
7
  import type { EnvLayerId } from "../shared/env-vars.js";
8
- import type { AIProviderCredentialKind, AIProviderKind, AIProviderSurface } from "../shared/provider-registry.js";
8
+ import type { CredentialExpiry, ProviderDeploymentRow, ProviderSignInId } from "../shared/provider-accounts.js";
9
+ import type { AIProviderCredentialKind, AIProviderDataZone, AIProviderDataZoneRule, AIProviderKind, AIProviderSurface, AIProviderTransport } from "../shared/provider-registry.js";
9
10
  import type { ProvidersPanelClient } from "./providers-client.js";
10
11
  /** Registry document a provider entry is defined in. */
11
12
  export type ProvidersPanelLayer = "instance" | "workspace";
@@ -43,6 +44,17 @@ export interface ProvidersPanelProps {
43
44
  * `layer`; a string replaces it; `false` hides it (Add provider stays).
44
45
  */
45
46
  note?: string | false;
47
+ /**
48
+ * Expert mode: the sign-in step also offers the raw reference form
49
+ * (`env:` / `keyring:` / `cmd:` / `platform:`) and expert-only parameters
50
+ * (`api_version`) become editable. Default `false`.
51
+ */
52
+ expert?: boolean;
53
+ /**
54
+ * The host's data-zone rule ("Where may AI process data?"). Rows outside it
55
+ * show a muted note naming the rule. Absent or `any`: no row is marked.
56
+ */
57
+ dataZoneRule?: AIProviderDataZoneRule;
46
58
  }
47
59
  /** Emits both variants declare. */
48
60
  export type ProvidersPanelEmit = (event: "changed") => void;
@@ -63,12 +75,29 @@ export interface ProvidersPanelEntry {
63
75
  baseUrl?: string;
64
76
  preset?: string;
65
77
  surface?: AIProviderSurface;
78
+ /** How requests reach the surface, when not `direct`. */
79
+ transport?: AIProviderTransport;
80
+ /** Routing parameters (`resource`, `deployment`, `api_version`, …) of an `llm`/`embed` entry. */
81
+ transportParams?: Record<string, string>;
82
+ /**
83
+ * When the credential expires (ISO timestamp), for a credential that
84
+ * reports one. The row then shows "Expires in N days · Renew".
85
+ */
86
+ credentialExpiresAt?: string | null;
66
87
  enabled: boolean;
67
88
  locked: boolean;
68
89
  /** Registry documents holding the id, lowest first: `["instance"]`, `["workspace"]` or both. */
69
90
  layers: ProvidersPanelLayer[];
70
91
  /** The scope's own document's values for the editable fields the dialog does not show. */
71
92
  layerFields?: Record<string, unknown>;
93
+ /** Where the entry processes data. Absent (an older host): the preset's zone, else `transfer`. */
94
+ dataZone?: AIProviderDataZone;
95
+ /** The entry's `eu_processing` switch. */
96
+ euProcessing?: boolean;
97
+ /** The entry's `allowed_models`; absent = every model, `[]` = none. */
98
+ allowedModels?: string[];
99
+ /** Logical model ids the entry declares (`model_map`); absent: its models come from discovery. */
100
+ modelIds?: string[];
72
101
  }
73
102
  /** One catalog preset, as `GET /api/providers/presets` and `.../detected` list it. */
74
103
  export interface ProvidersPanelPreset {
@@ -76,12 +105,18 @@ export interface ProvidersPanelPreset {
76
105
  label: string;
77
106
  kind: AIProviderKind;
78
107
  surface?: AIProviderSurface;
108
+ /** How requests reach the surface; Azure transports offer Entra ID sign-in. */
109
+ transport?: AIProviderTransport;
79
110
  base_url?: string;
80
111
  base_url_env?: string;
81
112
  credential: {
82
113
  kind: AIProviderCredentialKind;
83
114
  env?: string;
84
115
  };
116
+ /** Default parameters. */
117
+ params?: Record<string, string>;
118
+ /** `params` keys an entry naming this preset must supply. */
119
+ required_params?: string[];
85
120
  }
86
121
  /** Where a row's entry lives relative to the scope's own document. */
87
122
  export type ProvidersPanelRowState = "own" | "inherited" | "patched";
@@ -121,8 +156,25 @@ export interface ProvidersPanelRow extends ProvidersPanelEntry {
121
156
  origin: string;
122
157
  /** `configured · <source>`, `missing <VAR>`, the resolver's reason, or `No credential needed.`. */
123
158
  status: string;
124
- /** Which other layer defines or overrides the credential; see the panel contract. */
125
159
  overrideNotices: string[];
160
+ /** "Microsoft Azure · Entra ID · contoso-ai": family · sign-in kind · resource. */
161
+ accountLine: string;
162
+ /** The credential's expiry, when it reports one. */
163
+ expiry: CredentialExpiry | null;
164
+ /** "Renew" is offered next to the expiry: the credential can be changed here. */
165
+ canRenew: boolean;
166
+ /** The entry's effective data zone. */
167
+ zone: AIProviderDataZone;
168
+ /** The zone chip: EU / EU option / Transfer / Local. */
169
+ zoneLabel: string;
170
+ /** "EU processing is on for this account" is offered: an `eu_option` entry the panel may write. */
171
+ canSetEuProcessing: boolean;
172
+ /** Why the host's data-zone rule keeps the entry out, naming the rule; `null` when it does not. */
173
+ blockedNote: string | null;
174
+ /** The model chip: "All models" | "N models". `null` for a voice entry. */
175
+ modelsChip: string | null;
176
+ /** "Models allowed here" can be changed: an `llm`/`embed` entry the panel may write. */
177
+ canFilterModels: boolean;
126
178
  }
127
179
  /** The add/edit dialog's fields. */
128
180
  export interface ProvidersPanelForm {
@@ -133,15 +185,48 @@ export interface ProvidersPanelForm {
133
185
  surface: string;
134
186
  /** Empty: the preset's endpoint. */
135
187
  baseUrl: string;
136
- /** Adding only: the `env:` variable the credential references. */
188
+ /** Key sign-in: the `env:` variable the credential references. */
137
189
  envName: string;
138
- /** Adding only, "Set value now": written to the scope's `.env`, never to the provider route. */
190
+ /** Key sign-in, "Set value now": written to the scope's `.env`, never to the provider route. */
139
191
  secret: string;
192
+ /** The chosen "How do you sign in?" option. */
193
+ signIn: ProviderSignInId | "";
194
+ /** `reference` sign-in: the typed reference. */
195
+ credentialRef: string;
196
+ /** Routing parameters by key (`resource`, `deployment`, `api_version`, …). */
197
+ params: Record<string, string>;
198
+ }
199
+ /** The Microsoft Azure card's fields. */
200
+ export interface ProvidersPanelAzureForm {
201
+ /** Azure resource name, shared by both entries. */
202
+ resource: string;
203
+ /** Write an Azure OpenAI entry. */
204
+ useOpenAI: boolean;
205
+ /** Write a Claude on Foundry entry. */
206
+ useFoundry: boolean;
207
+ /** Azure OpenAI deployments: deployment name → logical model id (`model_map`). */
208
+ deployments: ProviderDeploymentRow[];
209
+ /** Azure OpenAI `api_version`; prefilled, editable in expert mode. */
210
+ apiVersion: string;
211
+ }
212
+ /** The add dialog's step: preset library, then the account fields, then the test of what was created. */
213
+ export type ProvidersPanelDialogStep = "library" | "account" | "done";
214
+ /** "Models allowed here": every model, or only the listed ones. */
215
+ export type ProvidersPanelModelsMode = "all" | "only";
216
+ /** The "Models allowed here" editor's fields. */
217
+ export interface ProvidersPanelModelsForm {
218
+ mode: ProvidersPanelModelsMode;
219
+ /** The ticked model ids. */
220
+ selected: string[];
221
+ /** The checklist's search text. */
222
+ query: string;
140
223
  }
141
224
  /** The preset select's value for an entry that names no preset. */
142
225
  export declare const CUSTOM_PRESET = "__custom__";
143
226
  /** Credential select value: open the inline key editor. */
144
227
  export declare const CREDENTIAL_ENTER_KEY = "__enter_key__";
228
+ /** The preset select's value for the Microsoft Azure account (Azure OpenAI and/or Claude on Foundry). */
229
+ export declare const AZURE_ACCOUNT = "__azure__";
145
230
  /** Credential select value: open the inline reference editor. */
146
231
  export declare const CREDENTIAL_OTHER_REF = "__other_ref__";
147
232
  /** Registry ids the write routes accept (`isSafeProviderId` upstream). */
@@ -163,6 +248,14 @@ export declare function providersPanelRowMeta(row: {
163
248
  export declare const ENV_REF_PATTERN: RegExp;
164
249
  /** The credential kind a written reference gets when the row states none. */
165
250
  export declare const FALLBACK_CREDENTIAL_KIND: AIProviderCredentialKind;
251
+ /** A row's model chip: "All models" without an allow-list, else its size. */
252
+ export declare function providerModelsChip(allowedModels: readonly string[] | undefined): string;
253
+ /**
254
+ * The checklist's ids: the known models (declared or discovered) in their
255
+ * order, then any allowed id neither lists (so it can still be unticked),
256
+ * narrowed by a case-insensitive `query`.
257
+ */
258
+ export declare function providerModelChoices(known: readonly string[], allowed: readonly string[], query?: string): string[];
166
259
  export declare const ENV_SOURCE_LABEL: Record<EnvLayerId, string>;
167
260
  export declare const OVERRIDES_INSTANCE_NOTICE = "Entering a key here stores it in this workspace's .env and overrides that value for this workspace.";
168
261
  /**
@@ -174,4 +267,4 @@ export declare function requestErrorMessage(err: unknown, fallback: string): str
174
267
  export declare function envNameOfRef(ref: string | undefined): string | undefined;
175
268
  /** `configured · …` for a reference that is not an env var. */
176
269
  export declare function nonEnvSourceLabel(ref: string): string | undefined;
177
- export declare const EMPTY_FORM: Readonly<ProvidersPanelForm>;
270
+ export declare const EMPTY_FORM: Readonly<Omit<ProvidersPanelForm, "params">>;
@@ -1,5 +1,6 @@
1
1
  export const CUSTOM_PRESET = "__custom__";
2
2
  export const CREDENTIAL_ENTER_KEY = "__enter_key__";
3
+ export const AZURE_ACCOUNT = "__azure__";
3
4
  export const CREDENTIAL_OTHER_REF = "__other_ref__";
4
5
  export const PROVIDER_ID_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
5
6
  export const DEFAULT_PRESETS_URL = "/api/providers/presets";
@@ -14,6 +15,15 @@ export function providersPanelRowMeta(row) {
14
15
  }
15
16
  export const ENV_REF_PATTERN = /^env:(.+)$/;
16
17
  export const FALLBACK_CREDENTIAL_KIND = "api_key_header";
18
+ export function providerModelsChip(allowedModels) {
19
+ if (allowedModels === void 0) return "All models";
20
+ return allowedModels.length === 1 ? "1 model" : `${allowedModels.length} models`;
21
+ }
22
+ export function providerModelChoices(known, allowed, query = "") {
23
+ const ids = [.../* @__PURE__ */ new Set([...known, ...allowed])];
24
+ const needle = query.trim().toLowerCase();
25
+ return needle ? ids.filter((id) => id.toLowerCase().includes(needle)) : ids;
26
+ }
17
27
  export const ENV_SOURCE_LABEL = {
18
28
  instance: "instance .env",
19
29
  workspace: "workspace .env",
@@ -42,5 +52,7 @@ export const EMPTY_FORM = {
42
52
  surface: "",
43
53
  baseUrl: "",
44
54
  envName: "",
45
- secret: ""
55
+ secret: "",
56
+ signIn: "",
57
+ credentialRef: ""
46
58
  };