@skaile/forge-settings 0.0.0-stage → 1.0.1
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/CHANGELOG.md +28 -0
- package/LICENSE +21 -0
- package/README.md +94 -2
- package/dist/module.d.mts +17 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +23 -0
- package/dist/runtime/ai-sdk/index.d.ts +46 -0
- package/dist/runtime/ai-sdk/index.js +31 -0
- package/dist/runtime/components/ForgeProvidersPanel.d.vue.ts +21 -0
- package/dist/runtime/components/ForgeProvidersPanel.vue +435 -0
- package/dist/runtime/components/ForgeProvidersPanel.vue.d.ts +21 -0
- package/dist/runtime/editor/index.d.ts +58 -0
- package/dist/runtime/editor/index.js +72 -0
- package/dist/runtime/model/errors.d.ts +32 -0
- package/dist/runtime/model/errors.js +19 -0
- package/dist/runtime/server/credential-policy.d.ts +61 -0
- package/dist/runtime/server/credential-policy.js +65 -0
- package/dist/runtime/server/credential-store.d.ts +184 -0
- package/dist/runtime/server/credential-store.js +234 -0
- package/dist/runtime/server/env-layers.d.ts +62 -0
- package/dist/runtime/server/env-layers.js +183 -0
- package/dist/runtime/server/env.d.ts +30 -0
- package/dist/runtime/server/env.js +15 -0
- package/dist/runtime/server/harness-settings.d.ts +150 -0
- package/dist/runtime/server/harness-settings.js +166 -0
- package/dist/runtime/server/index.d.ts +23 -0
- package/dist/runtime/server/index.js +14 -0
- package/dist/runtime/server/provider-discovery.d.ts +73 -0
- package/dist/runtime/server/provider-discovery.js +77 -0
- package/dist/runtime/server/provider-layers.d.ts +27 -0
- package/dist/runtime/server/provider-layers.js +35 -0
- package/dist/runtime/server/provider-service.d.ts +126 -0
- package/dist/runtime/server/provider-service.js +87 -0
- package/dist/runtime/server/provider-settings.d.ts +78 -0
- package/dist/runtime/server/provider-settings.js +81 -0
- package/dist/runtime/server/provider-write.d.ts +154 -0
- package/dist/runtime/server/provider-write.js +221 -0
- package/dist/runtime/server/settings-defaults.d.ts +26 -0
- package/dist/runtime/server/settings-defaults.js +46 -0
- package/dist/runtime/shared/env-vars.d.ts +55 -0
- package/dist/runtime/shared/env-vars.js +22 -0
- package/dist/runtime/shared/guards.d.ts +2 -0
- package/dist/runtime/shared/guards.js +3 -0
- package/dist/runtime/shared/harness-providers.d.ts +62 -0
- package/dist/runtime/shared/harness-providers.js +38 -0
- package/dist/runtime/shared/harnesses.d.ts +19 -0
- package/dist/runtime/shared/harnesses.js +15 -0
- package/dist/runtime/shared/provider-registry.d.ts +255 -0
- package/dist/runtime/shared/provider-registry.js +112 -0
- package/dist/runtime/shared/settings-types.d.ts +84 -0
- package/dist/runtime/shared/settings-types.js +0 -0
- package/dist/runtime/shims-vue.d.ts +8 -0
- package/dist/runtime/vue/index.d.ts +14 -0
- package/dist/runtime/vue/index.js +6 -0
- package/dist/runtime/vue/providers-panel-model.d.ts +147 -0
- package/dist/runtime/vue/providers-panel-model.js +37 -0
- package/dist/runtime/vue/settings-modal-scope.d.ts +62 -0
- package/dist/runtime/vue/settings-modal-scope.js +2 -0
- package/dist/runtime/vue/useProvidersPanel.d.ts +115 -0
- package/dist/runtime/vue/useProvidersPanel.js +633 -0
- package/dist/types.d.mts +9 -0
- package/package.json +117 -4
- package/src/runtime/ai-sdk/index.ts +88 -0
- package/src/runtime/components/ForgeProvidersPanel.vue +449 -0
- package/src/runtime/editor/index.ts +146 -0
- package/src/runtime/model/errors.ts +52 -0
- package/src/runtime/server/credential-policy.ts +139 -0
- package/src/runtime/server/credential-store.ts +473 -0
- package/src/runtime/server/env-layers.ts +287 -0
- package/src/runtime/server/env.ts +46 -0
- package/src/runtime/server/harness-settings.ts +373 -0
- package/src/runtime/server/index.ts +24 -0
- package/src/runtime/server/provider-discovery.ts +164 -0
- package/src/runtime/server/provider-layers.ts +67 -0
- package/src/runtime/server/provider-service.ts +244 -0
- package/src/runtime/server/provider-settings.ts +192 -0
- package/src/runtime/server/provider-write.ts +433 -0
- package/src/runtime/server/settings-defaults.ts +87 -0
- package/src/runtime/shared/env-vars.ts +82 -0
- package/src/runtime/shared/guards.ts +4 -0
- package/src/runtime/shared/harness-providers.ts +118 -0
- package/src/runtime/shared/harnesses.ts +34 -0
- package/src/runtime/shared/provider-registry.ts +391 -0
- package/src/runtime/shared/settings-types.ts +87 -0
- package/src/runtime/shims-vue.d.ts +8 -0
- package/src/runtime/vue/index.ts +15 -0
- package/src/runtime/vue/providers-panel-model.ts +203 -0
- package/src/runtime/vue/settings-modal-scope.ts +66 -0
- package/src/runtime/vue/useProvidersPanel.ts +930 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tier a settings modal edits, and the URLs of its routes.
|
|
3
|
+
*
|
|
4
|
+
* The URL protocol is the host's: every field names a route the host serves,
|
|
5
|
+
* and no component builds a URL from an id or a slug. `ForgeProvidersPanel`
|
|
6
|
+
* takes the `providers*` / `environmentUrl` / `providersLayer` fields of this
|
|
7
|
+
* record as its props; the rest belong to the host's own modal tabs (harness,
|
|
8
|
+
* voice, workspace), which stay in the host.
|
|
9
|
+
*/
|
|
10
|
+
/** Which settings tier a modal edits. */
|
|
11
|
+
export type SettingsModalSettingsScope = "instance" | "workspace";
|
|
12
|
+
/**
|
|
13
|
+
* The tier the modal edits: the instance (app-wide defaults) or one
|
|
14
|
+
* workspace. The caller owns every route: the modal never builds a URL from an
|
|
15
|
+
* id or slug.
|
|
16
|
+
*/
|
|
17
|
+
export interface SettingsModalScope {
|
|
18
|
+
/** Dialog header text, e.g. the workspace name. */
|
|
19
|
+
label: string;
|
|
20
|
+
/**
|
|
21
|
+
* `"instance"`: the Harness tab edits the instance defaults
|
|
22
|
+
* (`PUT /api/settings?scope=instance`); `"workspace"`: it edits this
|
|
23
|
+
* workspace's overrides through {@link settingsUrl}.
|
|
24
|
+
*/
|
|
25
|
+
settingsScope: SettingsModalSettingsScope;
|
|
26
|
+
/**
|
|
27
|
+
* `GET`/`PUT` endpoint of this scope's settings: `/api/settings` for the
|
|
28
|
+
* instance, the workspace's override row (`{ harness, model }`) otherwise.
|
|
29
|
+
*/
|
|
30
|
+
settingsUrl: string;
|
|
31
|
+
/** Base URL for the Workspace + Connectors tabs' config API calls. */
|
|
32
|
+
workspaceApiBaseUrl: string;
|
|
33
|
+
/** `GET` model catalog of this scope's registry, queried with `?harness=<id>`. */
|
|
34
|
+
modelsUrl: string;
|
|
35
|
+
/** Provider registry write base: `PUT|DELETE <url>/:id`, `GET <url>/detected`. */
|
|
36
|
+
providersWriteUrl: string;
|
|
37
|
+
/**
|
|
38
|
+
* `GET` endpoint of this scope's `.env` layer, which the Providers tab reads and
|
|
39
|
+
* writes. Defaults to the instance layer, `/api/settings/env`.
|
|
40
|
+
*/
|
|
41
|
+
environmentUrl?: string;
|
|
42
|
+
/**
|
|
43
|
+
* `GET` endpoint listing registry entries with their credential status
|
|
44
|
+
* resolved against this scope's environment. Defaults to `/api/providers`.
|
|
45
|
+
*/
|
|
46
|
+
providersUrl?: string;
|
|
47
|
+
/**
|
|
48
|
+
* The registry document the Providers tab edits, when it differs from
|
|
49
|
+
* {@link settingsScope}. A single-workspace app keeps instance settings but
|
|
50
|
+
* writes the workspace registry over a user-level one: `"workspace"` there
|
|
51
|
+
* makes the lower document's entries inherited and patchable.
|
|
52
|
+
*/
|
|
53
|
+
providersLayer?: SettingsModalSettingsScope;
|
|
54
|
+
/** Workspace name for workspace-scope copy (the harness-change confirm); defaults to {@link label}. */
|
|
55
|
+
workspaceName?: string;
|
|
56
|
+
/** The caller may read but not write this scope (e.g. a `readonly` user, another owner's workspace). */
|
|
57
|
+
readOnly?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/** Default `GET` route of the merged provider list. */
|
|
60
|
+
export declare const DEFAULT_PROVIDERS_URL = "/api/providers";
|
|
61
|
+
/** Default `GET`/`PUT` route of the instance `.env` layer. */
|
|
62
|
+
export declare const DEFAULT_ENVIRONMENT_URL = "/api/settings/env";
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared brain for `components-nuxt-ui/ForgeProvidersPanel.vue` — the settings
|
|
3
|
+
* modal's Providers tab.
|
|
4
|
+
*
|
|
5
|
+
* It drives the registry editor: loading, the add/edit form, the delete confirmation,
|
|
6
|
+
* the "detected in environment" one-click adds, the per-row credential picker,
|
|
7
|
+
* the enabled toggle and every request live here.
|
|
8
|
+
*
|
|
9
|
+
* The panel writes one registry document — the scope's own `layer` — through
|
|
10
|
+
* `PUT|DELETE ${providersWriteUrl}/:id`. An entry a lower layer defines can be
|
|
11
|
+
* patched at workspace scope (`credential` / `enabled` only) and reset by
|
|
12
|
+
* deleting the patch. A key typed into the panel goes to the scope's `.env`
|
|
13
|
+
* route only; the provider route receives an `env:NAME` reference, never a
|
|
14
|
+
* value.
|
|
15
|
+
*/
|
|
16
|
+
import { type ComputedRef, type Ref, type WritableComputedRef } from "vue";
|
|
17
|
+
import { type EnvSettingsDocument } from "../shared/env-vars.js";
|
|
18
|
+
import { type AIProviderSurface } from "../shared/provider-registry.js";
|
|
19
|
+
import { type ProvidersPanelEntry, type ProvidersPanelEmit, type ProvidersPanelForm, type ProvidersPanelPreset, type ProvidersPanelProps, type ProvidersPanelRow } from "./providers-panel-model.js";
|
|
20
|
+
export { CREDENTIAL_ENTER_KEY, CREDENTIAL_OTHER_REF, CUSTOM_PRESET } from "./providers-panel-model.js";
|
|
21
|
+
export type { ProvidersPanelCredentialOption, ProvidersPanelEmit, ProvidersPanelEntry, ProvidersPanelForm, ProvidersPanelLayer, ProvidersPanelPreset, ProvidersPanelProps, ProvidersPanelRow, ProvidersPanelRowState, } from "./providers-panel-model.js";
|
|
22
|
+
/** What both `ForgeProvidersPanel` variants bind to. */
|
|
23
|
+
export interface ProvidersPanelState {
|
|
24
|
+
/** The scope's entries, disabled ones included, in registry order. */
|
|
25
|
+
rows: ComputedRef<ProvidersPanelRow[]>;
|
|
26
|
+
loading: Ref<boolean>;
|
|
27
|
+
loadError: Ref<string | null>;
|
|
28
|
+
/** Re-read the entries, the detected presets and the environment document. */
|
|
29
|
+
refresh: () => Promise<void>;
|
|
30
|
+
dialogVisible: Ref<boolean>;
|
|
31
|
+
dialogTitle: ComputedRef<string>;
|
|
32
|
+
/** The row being edited; `null` while adding. */
|
|
33
|
+
editing: Ref<ProvidersPanelEntry | null>;
|
|
34
|
+
form: ProvidersPanelForm;
|
|
35
|
+
/** A refusal from the form check or either request, shown in the dialog. */
|
|
36
|
+
dialogError: Ref<string | null>;
|
|
37
|
+
saving: Ref<boolean>;
|
|
38
|
+
/** Catalog presets plus "Custom" ({@link CUSTOM_PRESET}). */
|
|
39
|
+
presetOptions: ComputedRef<Array<{
|
|
40
|
+
label: string;
|
|
41
|
+
value: string;
|
|
42
|
+
}>>;
|
|
43
|
+
surfaceOptions: Array<{
|
|
44
|
+
label: string;
|
|
45
|
+
value: AIProviderSurface;
|
|
46
|
+
}>;
|
|
47
|
+
isCustom: ComputedRef<boolean>;
|
|
48
|
+
/** The surface select is shown: a custom `llm`/`embed` entry. */
|
|
49
|
+
showSurface: ComputedRef<boolean>;
|
|
50
|
+
baseUrlPlaceholder: ComputedRef<string>;
|
|
51
|
+
/** "Set value now" is offered: the scope has an `.env` route. */
|
|
52
|
+
canSetValue: ComputedRef<boolean>;
|
|
53
|
+
/** The dialog shows the env name and secret fields: adding, not editing. */
|
|
54
|
+
showCredentialFields: ComputedRef<boolean>;
|
|
55
|
+
idError: ComputedRef<string | null>;
|
|
56
|
+
openAdd: (presetId?: string) => void;
|
|
57
|
+
openEdit: (row: ProvidersPanelEntry) => void;
|
|
58
|
+
selectPreset: (value: string) => void;
|
|
59
|
+
saveProvider: () => Promise<void>;
|
|
60
|
+
deleteTarget: Ref<ProvidersPanelEntry | null>;
|
|
61
|
+
/** The confirmation dialog's `v-model`; closing it cancels. */
|
|
62
|
+
deleteOpen: WritableComputedRef<boolean>;
|
|
63
|
+
deleteError: Ref<string | null>;
|
|
64
|
+
deleting: Ref<boolean>;
|
|
65
|
+
requestDelete: (row: ProvidersPanelEntry) => void;
|
|
66
|
+
confirmDelete: () => Promise<void>;
|
|
67
|
+
/** Presets whose key is set in the scope's env and that no entry names. */
|
|
68
|
+
detected: Ref<ProvidersPanelPreset[]>;
|
|
69
|
+
/** Preset id whose one-click add is in flight. */
|
|
70
|
+
detectedBusy: Ref<string | null>;
|
|
71
|
+
detectedError: Ref<string | null>;
|
|
72
|
+
addDetected: (preset: ProvidersPanelPreset) => Promise<void>;
|
|
73
|
+
/** The credential select's `@update`: a NAME writes, the two actions open an editor. */
|
|
74
|
+
onCredentialSelect: (row: ProvidersPanelRow, value: string) => void;
|
|
75
|
+
setCredentialEnv: (row: ProvidersPanelRow, name: string) => Promise<void>;
|
|
76
|
+
setEnabled: (row: ProvidersPanelRow, enabled: boolean) => Promise<void>;
|
|
77
|
+
/** Delete the workspace patch of an inherited entry. */
|
|
78
|
+
resetPatch: (row: ProvidersPanelRow) => Promise<void>;
|
|
79
|
+
/** Row id with a write in flight. */
|
|
80
|
+
rowBusy: Ref<string | null>;
|
|
81
|
+
rowError: Ref<{
|
|
82
|
+
id: string;
|
|
83
|
+
message: string;
|
|
84
|
+
} | null>;
|
|
85
|
+
/** "Enter a key…" is offered: the scope has an editable `.env` route. */
|
|
86
|
+
canEnterKey: ComputedRef<boolean>;
|
|
87
|
+
/** Row id whose key editor is open. */
|
|
88
|
+
keyEditing: Ref<string | null>;
|
|
89
|
+
keyForm: {
|
|
90
|
+
name: string;
|
|
91
|
+
value: string;
|
|
92
|
+
};
|
|
93
|
+
keyError: Ref<string | null>;
|
|
94
|
+
openKeyEditor: (row: ProvidersPanelRow) => void;
|
|
95
|
+
cancelKeyEditor: () => void;
|
|
96
|
+
saveKeyEditor: () => Promise<void>;
|
|
97
|
+
/** Row id whose reference editor is open. */
|
|
98
|
+
refEditing: Ref<string | null>;
|
|
99
|
+
refForm: {
|
|
100
|
+
ref: string;
|
|
101
|
+
};
|
|
102
|
+
refError: Ref<string | null>;
|
|
103
|
+
openRefEditor: (row: ProvidersPanelRow) => void;
|
|
104
|
+
cancelRefEditor: () => void;
|
|
105
|
+
saveRefEditor: () => Promise<void>;
|
|
106
|
+
envDocument: Ref<EnvSettingsDocument | null>;
|
|
107
|
+
/** The environment document says the caller may write its layer. */
|
|
108
|
+
envEditable: ComputedRef<boolean>;
|
|
109
|
+
/** Draft new values per variable name. */
|
|
110
|
+
envValues: Record<string, string>;
|
|
111
|
+
envError: Ref<string | null>;
|
|
112
|
+
envBusy: Ref<boolean>;
|
|
113
|
+
setEnvValue: (name: string) => Promise<void>;
|
|
114
|
+
}
|
|
115
|
+
export declare function useProvidersPanel(props: ProvidersPanelProps, emit: ProvidersPanelEmit): ProvidersPanelState;
|