@skaile/forge-settings 1.3.2 → 1.4.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 (46) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +20 -0
  3. package/dist/module.json +1 -1
  4. package/dist/runtime/components/ForgeProvidersPanel.d.vue.ts +13 -0
  5. package/dist/runtime/components/ForgeProvidersPanel.vue +461 -78
  6. package/dist/runtime/components/ForgeProvidersPanel.vue.d.ts +13 -0
  7. package/dist/runtime/server/harness-settings.d.ts +50 -12
  8. package/dist/runtime/server/harness-settings.js +93 -9
  9. package/dist/runtime/server/index.d.ts +2 -0
  10. package/dist/runtime/server/index.js +2 -0
  11. package/dist/runtime/server/provider-service.d.ts +26 -2
  12. package/dist/runtime/server/provider-service.js +16 -1
  13. package/dist/runtime/server/provider-write.d.ts +25 -9
  14. package/dist/runtime/server/provider-write.js +72 -4
  15. package/dist/runtime/shared/data-zone.d.ts +66 -0
  16. package/dist/runtime/shared/data-zone.js +79 -0
  17. package/dist/runtime/shared/harness-providers.d.ts +41 -2
  18. package/dist/runtime/shared/harness-providers.js +31 -8
  19. package/dist/runtime/shared/harnesses.d.ts +7 -0
  20. package/dist/runtime/shared/harnesses.js +18 -0
  21. package/dist/runtime/shared/provider-accounts.d.ts +215 -0
  22. package/dist/runtime/shared/provider-accounts.js +255 -0
  23. package/dist/runtime/shared/provider-registry.d.ts +38 -0
  24. package/dist/runtime/shared/provider-registry.js +16 -0
  25. package/dist/runtime/shared/settings-types.d.ts +7 -0
  26. package/dist/runtime/vue/index.d.ts +2 -0
  27. package/dist/runtime/vue/index.js +2 -0
  28. package/dist/runtime/vue/providers-panel-model.d.ts +98 -5
  29. package/dist/runtime/vue/providers-panel-model.js +13 -1
  30. package/dist/runtime/vue/useProvidersPanel.d.ts +66 -5
  31. package/dist/runtime/vue/useProvidersPanel.js +417 -29
  32. package/package.json +2 -2
  33. package/src/runtime/components/ForgeProvidersPanel.vue +477 -78
  34. package/src/runtime/server/harness-settings.ts +165 -21
  35. package/src/runtime/server/index.ts +2 -0
  36. package/src/runtime/server/provider-service.ts +53 -1
  37. package/src/runtime/server/provider-write.ts +129 -15
  38. package/src/runtime/shared/data-zone.ts +172 -0
  39. package/src/runtime/shared/harness-providers.ts +77 -6
  40. package/src/runtime/shared/harnesses.ts +25 -0
  41. package/src/runtime/shared/provider-accounts.ts +526 -0
  42. package/src/runtime/shared/provider-registry.ts +58 -0
  43. package/src/runtime/shared/settings-types.ts +7 -0
  44. package/src/runtime/vue/index.ts +2 -0
  45. package/src/runtime/vue/providers-panel-model.ts +123 -5
  46. package/src/runtime/vue/useProvidersPanel.ts +586 -37
@@ -6,10 +6,18 @@
6
6
  */
7
7
 
8
8
  import type { EnvLayerId } from "../shared/env-vars";
9
+ import type {
10
+ CredentialExpiry,
11
+ ProviderDeploymentRow,
12
+ ProviderSignInId,
13
+ } from "../shared/provider-accounts";
9
14
  import type {
10
15
  AIProviderCredentialKind,
11
16
  AIProviderKind,
12
17
  AIProviderSurface,
18
+ AIProviderTransport,
19
+ DataZone,
20
+ DataZoneRule,
13
21
  } from "../shared/provider-registry";
14
22
  import type { ProvidersPanelClient } from "./providers-client";
15
23
 
@@ -50,6 +58,17 @@ export interface ProvidersPanelProps {
50
58
  * `layer`; a string replaces it; `false` hides it (Add provider stays).
51
59
  */
52
60
  note?: string | false;
61
+ /**
62
+ * Expert mode: the sign-in step also offers the raw reference form
63
+ * (`env:` / `keyring:` / `cmd:` / `platform:`) and expert-only parameters
64
+ * (`api_version`) become editable. Default `false`.
65
+ */
66
+ expert?: boolean;
67
+ /**
68
+ * The host's data-zone rule ("Where may AI process data?"). Rows outside it
69
+ * show a muted note naming the rule. Absent or `any`: no row is marked.
70
+ */
71
+ dataZoneRule?: DataZoneRule;
53
72
  }
54
73
 
55
74
  /** Emits both variants declare. */
@@ -72,12 +91,29 @@ export interface ProvidersPanelEntry {
72
91
  baseUrl?: string;
73
92
  preset?: string;
74
93
  surface?: AIProviderSurface;
94
+ /** How requests reach the surface, when not `direct`. */
95
+ transport?: AIProviderTransport;
96
+ /** Routing parameters (`resource`, `deployment`, `api_version`, …) of an `llm`/`embed` entry. */
97
+ transportParams?: Record<string, string>;
98
+ /**
99
+ * When the credential expires (ISO timestamp), for a credential that
100
+ * reports one. The row then shows "Expires in N days · Renew".
101
+ */
102
+ credentialExpiresAt?: string | null;
75
103
  enabled: boolean;
76
104
  locked: boolean;
77
105
  /** Registry documents holding the id, lowest first: `["instance"]`, `["workspace"]` or both. */
78
106
  layers: ProvidersPanelLayer[];
79
107
  /** The scope's own document's values for the editable fields the dialog does not show. */
80
108
  layerFields?: Record<string, unknown>;
109
+ /** Where the entry processes data. Absent (an older host): the preset's zone, else `transfer`. */
110
+ dataZone?: DataZone;
111
+ /** The entry's `eu_processing` switch. */
112
+ euProcessing?: boolean;
113
+ /** The entry's `allowed_models`; absent = every model, `[]` = none. */
114
+ allowedModels?: string[];
115
+ /** Logical model ids the entry declares (`model_map`); absent: its models come from discovery. */
116
+ modelIds?: string[];
81
117
  }
82
118
 
83
119
  /** One catalog preset, as `GET /api/providers/presets` and `.../detected` list it. */
@@ -86,9 +122,15 @@ export interface ProvidersPanelPreset {
86
122
  label: string;
87
123
  kind: AIProviderKind;
88
124
  surface?: AIProviderSurface;
125
+ /** How requests reach the surface; Azure transports offer Entra ID sign-in. */
126
+ transport?: AIProviderTransport;
89
127
  base_url?: string;
90
128
  base_url_env?: string;
91
129
  credential: { kind: AIProviderCredentialKind; env?: string };
130
+ /** Default parameters. */
131
+ params?: Record<string, string>;
132
+ /** `params` keys an entry naming this preset must supply. */
133
+ required_params?: string[];
92
134
  }
93
135
 
94
136
  /** Where a row's entry lives relative to the scope's own document. */
@@ -131,8 +173,25 @@ export interface ProvidersPanelRow extends ProvidersPanelEntry {
131
173
  origin: string;
132
174
  /** `configured · <source>`, `missing <VAR>`, the resolver's reason, or `No credential needed.`. */
133
175
  status: string;
134
- /** Which other layer defines or overrides the credential; see the panel contract. */
135
176
  overrideNotices: string[];
177
+ /** "Microsoft Azure · Entra ID · contoso-ai": family · sign-in kind · resource. */
178
+ accountLine: string;
179
+ /** The credential's expiry, when it reports one. */
180
+ expiry: CredentialExpiry | null;
181
+ /** "Renew" is offered next to the expiry: the credential can be changed here. */
182
+ canRenew: boolean;
183
+ /** The entry's effective data zone. */
184
+ zone: DataZone;
185
+ /** The zone chip: EU / EU option / Transfer / Local. */
186
+ zoneLabel: string;
187
+ /** "EU processing is on for this account" is offered: an `eu_option` entry the panel may write. */
188
+ canSetEuProcessing: boolean;
189
+ /** Why the host's data-zone rule keeps the entry out, naming the rule; `null` when it does not. */
190
+ blockedNote: string | null;
191
+ /** The model chip: "All models" | "N models". `null` for a voice entry. */
192
+ modelsChip: string | null;
193
+ /** "Models allowed here" can be changed: an `llm`/`embed` entry the panel may write. */
194
+ canFilterModels: boolean;
136
195
  }
137
196
 
138
197
  /** The add/edit dialog's fields. */
@@ -144,13 +203,46 @@ export interface ProvidersPanelForm {
144
203
  surface: string;
145
204
  /** Empty: the preset's endpoint. */
146
205
  baseUrl: string;
147
- /** Adding only: the `env:` variable the credential references. */
206
+ /** Key sign-in: the `env:` variable the credential references. */
148
207
  envName: string;
149
- /** Adding only, "Set value now": written to the scope's `.env`, never to the provider route. */
208
+ /** Key sign-in, "Set value now": written to the scope's `.env`, never to the provider route. */
150
209
  secret: string;
210
+ /** The chosen "How do you sign in?" option. */
211
+ signIn: ProviderSignInId | "";
212
+ /** `reference` sign-in: the typed reference. */
213
+ credentialRef: string;
214
+ /** Routing parameters by key (`resource`, `deployment`, `api_version`, …). */
215
+ params: Record<string, string>;
151
216
  }
152
217
 
153
- // ── Constants ─────────────────────────────────────────────────────────────────
218
+ /** The Microsoft Azure card's fields. */
219
+ export interface ProvidersPanelAzureForm {
220
+ /** Azure resource name, shared by both entries. */
221
+ resource: string;
222
+ /** Write an Azure OpenAI entry. */
223
+ useOpenAI: boolean;
224
+ /** Write a Claude on Foundry entry. */
225
+ useFoundry: boolean;
226
+ /** Azure OpenAI deployments: deployment name → logical model id (`model_map`). */
227
+ deployments: ProviderDeploymentRow[];
228
+ /** Azure OpenAI `api_version`; prefilled, editable in expert mode. */
229
+ apiVersion: string;
230
+ }
231
+
232
+ /** The add dialog's step: preset library, then the account fields, then the test of what was created. */
233
+ export type ProvidersPanelDialogStep = "library" | "account" | "done";
234
+
235
+ /** "Models allowed here": every model, or only the listed ones. */
236
+ export type ProvidersPanelModelsMode = "all" | "only";
237
+
238
+ /** The "Models allowed here" editor's fields. */
239
+ export interface ProvidersPanelModelsForm {
240
+ mode: ProvidersPanelModelsMode;
241
+ /** The ticked model ids. */
242
+ selected: string[];
243
+ /** The checklist's search text. */
244
+ query: string;
245
+ }
154
246
 
155
247
  /** The preset select's value for an entry that names no preset. */
156
248
  export const CUSTOM_PRESET = "__custom__";
@@ -158,6 +250,9 @@ export const CUSTOM_PRESET = "__custom__";
158
250
  /** Credential select value: open the inline key editor. */
159
251
  export const CREDENTIAL_ENTER_KEY = "__enter_key__";
160
252
 
253
+ /** The preset select's value for the Microsoft Azure account (Azure OpenAI and/or Claude on Foundry). */
254
+ export const AZURE_ACCOUNT = "__azure__";
255
+
161
256
  /** Credential select value: open the inline reference editor. */
162
257
  export const CREDENTIAL_OTHER_REF = "__other_ref__";
163
258
 
@@ -198,6 +293,27 @@ export const ENV_REF_PATTERN = /^env:(.+)$/;
198
293
  /** The credential kind a written reference gets when the row states none. */
199
294
  export const FALLBACK_CREDENTIAL_KIND: AIProviderCredentialKind = "api_key_header";
200
295
 
296
+ /** A row's model chip: "All models" without an allow-list, else its size. */
297
+ export function providerModelsChip(allowedModels: readonly string[] | undefined): string {
298
+ if (allowedModels === undefined) return "All models";
299
+ return allowedModels.length === 1 ? "1 model" : `${allowedModels.length} models`;
300
+ }
301
+
302
+ /**
303
+ * The checklist's ids: the known models (declared or discovered) in their
304
+ * order, then any allowed id neither lists (so it can still be unticked),
305
+ * narrowed by a case-insensitive `query`.
306
+ */
307
+ export function providerModelChoices(
308
+ known: readonly string[],
309
+ allowed: readonly string[],
310
+ query = "",
311
+ ): string[] {
312
+ const ids = [...new Set([...known, ...allowed])];
313
+ const needle = query.trim().toLowerCase();
314
+ return needle ? ids.filter((id) => id.toLowerCase().includes(needle)) : ids;
315
+ }
316
+
201
317
  export const ENV_SOURCE_LABEL: Record<EnvLayerId, string> = {
202
318
  instance: "instance .env",
203
319
  workspace: "workspace .env",
@@ -237,11 +353,13 @@ export function nonEnvSourceLabel(ref: string): string | undefined {
237
353
  return undefined;
238
354
  }
239
355
 
240
- export const EMPTY_FORM: Readonly<ProvidersPanelForm> = {
356
+ export const EMPTY_FORM: Readonly<Omit<ProvidersPanelForm, "params">> = {
241
357
  preset: "",
242
358
  id: "",
243
359
  surface: "",
244
360
  baseUrl: "",
245
361
  envName: "",
246
362
  secret: "",
363
+ signIn: "",
364
+ credentialRef: "",
247
365
  };