@happyvertical/smrt-inference 0.0.0-stage → 0.60.15

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 (107) hide show
  1. package/AGENTS.md +201 -0
  2. package/CLAUDE.md +1 -0
  3. package/LICENSE +7 -0
  4. package/README.md +73 -2
  5. package/agents/fusions.md +92 -0
  6. package/agents/hosted.md +145 -0
  7. package/agents/resolver.md +65 -0
  8. package/agents/settings.md +84 -0
  9. package/dist/__smrt-register__.d.ts +2 -0
  10. package/dist/__smrt-register__.d.ts.map +1 -0
  11. package/dist/chunks/InferenceOverrideCollection-wl7sI-3C.js +398 -0
  12. package/dist/chunks/InferenceOverrideCollection-wl7sI-3C.js.map +1 -0
  13. package/dist/chunks/provider-config-4Bx8N52X.js +1847 -0
  14. package/dist/chunks/provider-config-4Bx8N52X.js.map +1 -0
  15. package/dist/classify.d.ts +32 -0
  16. package/dist/classify.d.ts.map +1 -0
  17. package/dist/config.d.ts +89 -0
  18. package/dist/config.d.ts.map +1 -0
  19. package/dist/errors.d.ts +51 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/executor.d.ts +45 -0
  22. package/dist/executor.d.ts.map +1 -0
  23. package/dist/fusion-store.d.ts +16 -0
  24. package/dist/fusion-store.d.ts.map +1 -0
  25. package/dist/fusion.d.ts +155 -0
  26. package/dist/fusion.d.ts.map +1 -0
  27. package/dist/gate.d.ts +143 -0
  28. package/dist/gate.d.ts.map +1 -0
  29. package/dist/gate.js +94 -0
  30. package/dist/gate.js.map +1 -0
  31. package/dist/hosted.d.ts +454 -0
  32. package/dist/hosted.d.ts.map +1 -0
  33. package/dist/index.d.ts +9 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +8 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/manifest.json +453 -0
  38. package/dist/models/InferenceOverride.d.ts +38 -0
  39. package/dist/models/InferenceOverride.d.ts.map +1 -0
  40. package/dist/models/InferenceOverrideCollection.d.ts +35 -0
  41. package/dist/models/InferenceOverrideCollection.d.ts.map +1 -0
  42. package/dist/models.d.ts +11 -0
  43. package/dist/models.d.ts.map +1 -0
  44. package/dist/models.js +2 -0
  45. package/dist/node.d.ts +110 -0
  46. package/dist/node.d.ts.map +1 -0
  47. package/dist/node.js +1361 -0
  48. package/dist/node.js.map +1 -0
  49. package/dist/provider-config.d.ts +113 -0
  50. package/dist/provider-config.d.ts.map +1 -0
  51. package/dist/register.d.ts +30 -0
  52. package/dist/register.d.ts.map +1 -0
  53. package/dist/resolver.d.ts +166 -0
  54. package/dist/resolver.d.ts.map +1 -0
  55. package/dist/resolver.js +288 -0
  56. package/dist/resolver.js.map +1 -0
  57. package/dist/server.d.ts +24 -0
  58. package/dist/server.d.ts.map +1 -0
  59. package/dist/server.js +985 -0
  60. package/dist/server.js.map +1 -0
  61. package/dist/settings/cache.d.ts +5 -0
  62. package/dist/settings/cache.d.ts.map +1 -0
  63. package/dist/settings/keys.d.ts +70 -0
  64. package/dist/settings/keys.d.ts.map +1 -0
  65. package/dist/settings/layers.d.ts +54 -0
  66. package/dist/settings/layers.d.ts.map +1 -0
  67. package/dist/settings/override-service.d.ts +119 -0
  68. package/dist/settings/override-service.d.ts.map +1 -0
  69. package/dist/settings/preferences.d.ts +137 -0
  70. package/dist/settings/preferences.d.ts.map +1 -0
  71. package/dist/settings/resolver.d.ts +34 -0
  72. package/dist/settings/resolver.d.ts.map +1 -0
  73. package/dist/settings/settings-service.d.ts +282 -0
  74. package/dist/settings/settings-service.d.ts.map +1 -0
  75. package/dist/settings/targets.d.ts +93 -0
  76. package/dist/settings/targets.d.ts.map +1 -0
  77. package/dist/smrt-knowledge.json +335 -0
  78. package/dist/smrt-knowledge.okf.md +80 -0
  79. package/dist/svelte/components/InferenceAliasEditor.svelte +210 -0
  80. package/dist/svelte/components/InferenceAliasEditor.svelte.d.ts +13 -0
  81. package/dist/svelte/components/InferenceAliasEditor.svelte.d.ts.map +1 -0
  82. package/dist/svelte/components/InferenceDefaultView.svelte +330 -0
  83. package/dist/svelte/components/InferenceDefaultView.svelte.d.ts +15 -0
  84. package/dist/svelte/components/InferenceDefaultView.svelte.d.ts.map +1 -0
  85. package/dist/svelte/components/InferenceFusionList.svelte +135 -0
  86. package/dist/svelte/components/InferenceFusionList.svelte.d.ts +16 -0
  87. package/dist/svelte/components/InferenceFusionList.svelte.d.ts.map +1 -0
  88. package/dist/svelte/components/InferenceSettingsPanel.svelte +345 -0
  89. package/dist/svelte/components/InferenceSettingsPanel.svelte.d.ts +65 -0
  90. package/dist/svelte/components/InferenceSettingsPanel.svelte.d.ts.map +1 -0
  91. package/dist/svelte/components/InferenceTierRow.svelte +199 -0
  92. package/dist/svelte/components/InferenceTierRow.svelte.d.ts +14 -0
  93. package/dist/svelte/components/InferenceTierRow.svelte.d.ts.map +1 -0
  94. package/dist/svelte/components/InferenceUsageTable.svelte +127 -0
  95. package/dist/svelte/components/InferenceUsageTable.svelte.d.ts +15 -0
  96. package/dist/svelte/components/InferenceUsageTable.svelte.d.ts.map +1 -0
  97. package/dist/svelte/index.d.ts +17 -0
  98. package/dist/svelte/index.d.ts.map +1 -0
  99. package/dist/svelte/index.js +14 -0
  100. package/dist/svelte/types.d.ts +197 -0
  101. package/dist/svelte/types.d.ts.map +1 -0
  102. package/dist/svelte/types.js +96 -0
  103. package/dist/types.d.ts +47 -0
  104. package/dist/types.d.ts.map +1 -0
  105. package/dist/types.js +13 -0
  106. package/dist/types.js.map +1 -0
  107. package/package.json +105 -3
@@ -0,0 +1,199 @@
1
+ <script lang="ts">
2
+ /**
3
+ * One rung of the tier ladder: "same as default", a model, an alias or a
4
+ * fusion. In the tenant scope, targets the allow-list does not open are
5
+ * disabled (display only; the server enforces the list on every write).
6
+ */
7
+ import { untrack } from 'svelte';
8
+ import type {
9
+ InferenceAliasView,
10
+ InferenceFusionView,
11
+ InferenceProviderView,
12
+ InferenceSettingsScope,
13
+ InferenceTargetView,
14
+ InferenceTierChange,
15
+ InferenceTierView,
16
+ } from '../types.js';
17
+ import {
18
+ inferenceLevelLabel,
19
+ isRefAllowed,
20
+ targetViewRef,
21
+ tierRevertPreview,
22
+ } from '../types.js';
23
+
24
+ interface InferenceTierRowProps {
25
+ row: InferenceTierView;
26
+ scope: InferenceSettingsScope;
27
+ providers: InferenceProviderView[];
28
+ aliases: InferenceAliasView[];
29
+ fusions: InferenceFusionView[];
30
+ busy: boolean;
31
+ onSaveTier?: (change: InferenceTierChange) => void;
32
+ }
33
+
34
+ const {
35
+ row,
36
+ scope,
37
+ providers,
38
+ aliases,
39
+ fusions,
40
+ busy,
41
+ onSaveTier,
42
+ }: InferenceTierRowProps = $props();
43
+
44
+ type Kind = 'default' | 'model' | 'alias' | 'fusion';
45
+
46
+ function kindOf(target: InferenceTargetView | null | undefined): Kind {
47
+ if (!target || Object.keys(target).length === 0) return 'default';
48
+ if (target.kind === 'fusion' || target.fusion) return 'fusion';
49
+ if (target.alias) return 'alias';
50
+ return 'model';
51
+ }
52
+
53
+ const own = untrack(
54
+ () => (scope === 'app' ? row.appTarget : row.tenantTarget) ?? null,
55
+ );
56
+ let kind = $state<Kind>(kindOf(own));
57
+ let provider = $state(own?.provider ?? '');
58
+ let model = $state(own?.model ?? '');
59
+ let alias = $state(own?.alias ?? '');
60
+ let fusion = $state(own?.fusion ?? '');
61
+
62
+ const restricted = $derived(scope === 'tenant');
63
+ const allowed = (target: InferenceTargetView) =>
64
+ !restricted || isRefAllowed(targetViewRef(target), row.tenantAllowList);
65
+ const modelAllowed = $derived(
66
+ !restricted ||
67
+ (row.tenantAllowList ?? []).some(
68
+ (pattern) => pattern === '*' || pattern.startsWith('model:'),
69
+ ),
70
+ );
71
+ const aliasAllowed = $derived(
72
+ aliases.some((entry) => allowed({ alias: entry.name })),
73
+ );
74
+ const fusionAllowed = $derived(
75
+ fusions.some((entry) => allowed({ kind: 'fusion', fusion: entry.name })),
76
+ );
77
+
78
+ function target(): InferenceTargetView | null {
79
+ if (kind === 'model') {
80
+ return provider
81
+ ? { provider, model: model.trim() }
82
+ : { model: model.trim() };
83
+ }
84
+ if (kind === 'alias') return { alias };
85
+ if (kind === 'fusion') return { kind: 'fusion', fusion };
86
+ return null;
87
+ }
88
+
89
+ function submit(event: SubmitEvent): void {
90
+ event.preventDefault();
91
+ onSaveTier?.({ tier: row.tier, scope, target: target() });
92
+ }
93
+ </script>
94
+
95
+ <form class="itr" onsubmit={submit} data-testid={`inference-tier-${row.tier}`}>
96
+ <div class="itr-head">
97
+ <strong class="itr-tier">{row.tier}</strong>
98
+ <span class="itr-effective">{row.effectiveLabel}</span>
99
+ <span class="itr-level">{inferenceLevelLabel(row.supplyingLevel)}</span>
100
+ </div>
101
+ {#if restricted && row.tenantBlocked}
102
+ <p class="itr-note" role="note">
103
+ This tenant binding is no longer on the allow-list and is not in effect.
104
+ </p>
105
+ {/if}
106
+ <div class="itr-controls">
107
+ <label>
108
+ <span class="itr-label">Target for {row.tier}</span>
109
+ <select name="kind" bind:value={kind} disabled={busy}>
110
+ <option value="default">Same as default</option>
111
+ <option value="model" disabled={!modelAllowed}>Model</option>
112
+ <option value="alias" disabled={!aliasAllowed}>Alias</option>
113
+ <option value="fusion" disabled={!fusionAllowed}>Fusion</option>
114
+ </select>
115
+ </label>
116
+ {#if kind === 'model'}
117
+ <label>
118
+ <span class="itr-label">Provider</span>
119
+ <select name="provider" bind:value={provider} disabled={busy}>
120
+ <option value="">Configured provider</option>
121
+ {#each providers.filter((option) => option.kind === 'provider') as option (option.id)}
122
+ <option value={option.id}>{option.label}</option>
123
+ {/each}
124
+ </select>
125
+ </label>
126
+ <label>
127
+ <span class="itr-label">Model</span>
128
+ <input name="model" bind:value={model} required disabled={busy} />
129
+ </label>
130
+ {:else if kind === 'alias'}
131
+ <label>
132
+ <span class="itr-label">Alias</span>
133
+ <select name="alias" bind:value={alias} required disabled={busy}>
134
+ <option value="" disabled>Choose an alias</option>
135
+ {#each aliases as entry (entry.name)}
136
+ <option value={entry.name} disabled={!allowed({ alias: entry.name })}>{entry.name}</option>
137
+ {/each}
138
+ </select>
139
+ </label>
140
+ {:else if kind === 'fusion'}
141
+ <label>
142
+ <span class="itr-label">Fusion</span>
143
+ <select name="fusion" bind:value={fusion} required disabled={busy}>
144
+ <option value="" disabled>Choose a fusion</option>
145
+ {#each fusions as entry (entry.name)}
146
+ <option value={entry.name} disabled={!allowed({ kind: 'fusion', fusion: entry.name })}>
147
+ {entry.name}
148
+ </option>
149
+ {/each}
150
+ </select>
151
+ </label>
152
+ {/if}
153
+ <button type="submit" disabled={busy || !onSaveTier}>Save</button>
154
+ </div>
155
+ <p class="itr-hint">"Same as default" reverts to: {tierRevertPreview(row, scope)}</p>
156
+ </form>
157
+
158
+ <style>
159
+ @layer smrt.reset, smrt.structure, smrt.theme;
160
+ @layer smrt.theme {
161
+ .itr {
162
+ display: flex;
163
+ flex-direction: column;
164
+ gap: 0.375rem;
165
+ padding: 0.5rem 0;
166
+ border-bottom: var(--smrt-hairline);
167
+ }
168
+ .itr-head {
169
+ display: flex;
170
+ gap: 0.75rem;
171
+ align-items: baseline;
172
+ flex-wrap: wrap;
173
+ }
174
+ .itr-tier {
175
+ text-transform: capitalize;
176
+ min-width: 4rem;
177
+ }
178
+ .itr-level,
179
+ .itr-hint,
180
+ .itr-note,
181
+ .itr-label {
182
+ font-size: 0.8125rem;
183
+ color: var(--smrt-color-on-surface-variant);
184
+ }
185
+ .itr-hint,
186
+ .itr-note {
187
+ margin: 0;
188
+ }
189
+ .itr-label {
190
+ display: block;
191
+ }
192
+ .itr-controls {
193
+ display: flex;
194
+ gap: 0.5rem;
195
+ align-items: flex-end;
196
+ flex-wrap: wrap;
197
+ }
198
+ }
199
+ </style>
@@ -0,0 +1,14 @@
1
+ import type { InferenceAliasView, InferenceFusionView, InferenceProviderView, InferenceSettingsScope, InferenceTierChange, InferenceTierView } from '../types.js';
2
+ interface InferenceTierRowProps {
3
+ row: InferenceTierView;
4
+ scope: InferenceSettingsScope;
5
+ providers: InferenceProviderView[];
6
+ aliases: InferenceAliasView[];
7
+ fusions: InferenceFusionView[];
8
+ busy: boolean;
9
+ onSaveTier?: (change: InferenceTierChange) => void;
10
+ }
11
+ declare const InferenceTierRow: import("svelte").Component<InferenceTierRowProps, {}, "">;
12
+ type InferenceTierRow = ReturnType<typeof InferenceTierRow>;
13
+ export default InferenceTierRow;
14
+ //# sourceMappingURL=InferenceTierRow.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InferenceTierRow.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/components/InferenceTierRow.svelte.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EAEtB,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,aAAa,CAAC;AASrB,UAAU,qBAAqB;IAC7B,GAAG,EAAE,iBAAiB,CAAC;IACvB,KAAK,EAAE,sBAAsB,CAAC;IAC9B,SAAS,EAAE,qBAAqB,EAAE,CAAC;IACnC,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACpD;AAyID,QAAA,MAAM,gBAAgB,2DAAwC,CAAC;AAC/D,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC5D,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,127 @@
1
+ <script lang="ts">
2
+ /**
3
+ * The Usage tab: `reportAiUsage()` buckets (#4751) by model, tier and/or
4
+ * prompt key. Renders only the dimensions the report was grouped by, so it
5
+ * works with the model dimension alone.
6
+ */
7
+ import type { InferenceUsageDimension, InferenceUsageView } from '../types.js';
8
+ import { usageColumns } from '../types.js';
9
+
10
+ interface InferenceUsageTableProps {
11
+ usage: InferenceUsageView | null;
12
+ busy: boolean;
13
+ onUsageGroupBy?: (by: InferenceUsageDimension[]) => void;
14
+ }
15
+
16
+ const { usage, busy, onUsageGroupBy }: InferenceUsageTableProps = $props();
17
+
18
+ const DIMENSIONS: Array<{ id: InferenceUsageDimension; label: string }> = [
19
+ { id: 'model', label: 'Model' },
20
+ { id: 'tier', label: 'Tier' },
21
+ { id: 'prompt', label: 'Prompt key' },
22
+ ];
23
+
24
+ const columns = $derived(usage ? usageColumns(usage) : []);
25
+
26
+ function regroup(event: Event): void {
27
+ const form = (event.currentTarget as HTMLInputElement).form;
28
+ if (!form || !onUsageGroupBy) return;
29
+ const by = new FormData(form)
30
+ .getAll('by')
31
+ .map(String) as InferenceUsageDimension[];
32
+ onUsageGroupBy(by.length > 0 ? by : ['model']);
33
+ }
34
+
35
+ function outcomes(value: Record<string, number> | undefined): string {
36
+ const entries = Object.entries(value ?? {});
37
+ return entries.length > 0
38
+ ? entries.map(([label, count]) => `${label} ${count}`).join(', ')
39
+ : '–';
40
+ }
41
+ </script>
42
+
43
+ <div class="iut" data-testid="inference-usage">
44
+ {#if onUsageGroupBy}
45
+ <form class="iut-group">
46
+ <span class="iut-label">Group by</span>
47
+ {#each DIMENSIONS as dimension (dimension.id)}
48
+ <label>
49
+ <input
50
+ type="checkbox"
51
+ name="by"
52
+ value={dimension.id}
53
+ checked={columns.includes(dimension.id)}
54
+ disabled={busy}
55
+ onchange={regroup}
56
+ />
57
+ {dimension.label}
58
+ </label>
59
+ {/each}
60
+ </form>
61
+ {/if}
62
+ {#if !usage || usage.buckets.length === 0}
63
+ <p class="iut-label">No usage recorded yet.</p>
64
+ {:else}
65
+ <table class="iut-table">
66
+ <thead>
67
+ <tr>
68
+ {#each columns as column (column)}
69
+ <th scope="col">{DIMENSIONS.find((entry) => entry.id === column)?.label ?? column}</th>
70
+ {/each}
71
+ <th scope="col">Calls</th>
72
+ <th scope="col">Tokens</th>
73
+ <th scope="col">Est. cost</th>
74
+ <th scope="col">Outcomes</th>
75
+ </tr>
76
+ </thead>
77
+ <tbody>
78
+ {#each usage.buckets as bucket, index (index)}
79
+ <tr>
80
+ {#each columns as column (column)}
81
+ <td>{bucket.key[column] ?? '(unattributed)'}</td>
82
+ {/each}
83
+ <td>{bucket.calls}</td>
84
+ <td>{bucket.totalTokens}</td>
85
+ <td>
86
+ ${bucket.estimatedCost.toFixed(4)}
87
+ {#if bucket.uncostedCalls}<span class="iut-label">({bucket.uncostedCalls} uncosted)</span>{/if}
88
+ </td>
89
+ <td>{outcomes(bucket.outcomes)}</td>
90
+ </tr>
91
+ {/each}
92
+ </tbody>
93
+ </table>
94
+ {#if usage.costBasis}<p class="iut-label">{usage.costBasis}</p>{/if}
95
+ {/if}
96
+ </div>
97
+
98
+ <style>
99
+ @layer smrt.reset, smrt.structure, smrt.theme;
100
+ @layer smrt.theme {
101
+ .iut {
102
+ display: flex;
103
+ flex-direction: column;
104
+ gap: 0.75rem;
105
+ }
106
+ .iut-group {
107
+ display: flex;
108
+ gap: 0.75rem;
109
+ align-items: center;
110
+ }
111
+ .iut-table {
112
+ border-collapse: collapse;
113
+ font-size: 0.875rem;
114
+ }
115
+ .iut-table th,
116
+ .iut-table td {
117
+ text-align: left;
118
+ padding: 0.25rem 0.75rem 0.25rem 0;
119
+ border-bottom: var(--smrt-hairline);
120
+ }
121
+ .iut-label {
122
+ margin: 0;
123
+ font-size: 0.8125rem;
124
+ color: var(--smrt-color-on-surface-variant);
125
+ }
126
+ }
127
+ </style>
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The Usage tab: `reportAiUsage()` buckets (#4751) by model, tier and/or
3
+ * prompt key. Renders only the dimensions the report was grouped by, so it
4
+ * works with the model dimension alone.
5
+ */
6
+ import type { InferenceUsageDimension, InferenceUsageView } from '../types.js';
7
+ interface InferenceUsageTableProps {
8
+ usage: InferenceUsageView | null;
9
+ busy: boolean;
10
+ onUsageGroupBy?: (by: InferenceUsageDimension[]) => void;
11
+ }
12
+ declare const InferenceUsageTable: import("svelte").Component<InferenceUsageTableProps, {}, "">;
13
+ type InferenceUsageTable = ReturnType<typeof InferenceUsageTable>;
14
+ export default InferenceUsageTable;
15
+ //# sourceMappingURL=InferenceUsageTable.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InferenceUsageTable.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/components/InferenceUsageTable.svelte.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAI/E,UAAU,wBAAwB;IAChC,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,cAAc,CAAC,EAAE,CAAC,EAAE,EAAE,uBAAuB,EAAE,KAAK,IAAI,CAAC;CAC1D;AAsFD,QAAA,MAAM,mBAAmB,8DAAwC,CAAC;AAClE,KAAK,mBAAmB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAClE,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @happyvertical/smrt-inference/svelte
3
+ *
4
+ * Optional Svelte 5 UI for inference settings (#4754). Presentational only:
5
+ * the panel takes rows and callbacks, does no fetching, and makes no
6
+ * authorization decision. Hosts render it from a server load that used
7
+ * `InferenceSettingsService` (`./server`) and wire saves to their own
8
+ * permission-checked actions. The root entry stays Svelte-free.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ import type { ComponentProps } from 'svelte';
13
+ import InferenceSettingsPanel from './components/InferenceSettingsPanel.svelte';
14
+ export { InferenceSettingsPanel };
15
+ export type InferenceSettingsPanelProps = ComponentProps<typeof InferenceSettingsPanel>;
16
+ export { candidateViewLabel, defaultTierRevertPreview, describeTargetView, INFERENCE_SETTINGS_MODES, INFERENCE_SETTINGS_TIERS, type InferenceAliasChange, type InferenceAliasView, type InferenceCandidateView, type InferenceConnectionRequest, type InferenceDefaultsChange, type InferenceDefaultsView, type InferenceDefaultTierChange, type InferenceDefaultTierView, type InferenceDiscoveryView, type InferenceFusionChange, type InferenceFusionView, type InferenceKeyChange, type InferenceProviderView, type InferenceSettingsLevelView, type InferenceSettingsMode, type InferenceSettingsScope, type InferenceSettingsTier, type InferenceTargetView, type InferenceTestResultView, type InferenceTierChange, type InferenceTierView, type InferenceUsageDimension, type InferenceUsageView, inferenceLevelLabel, isRefAllowed, targetViewRef, tierRevertPreview, usageColumns, } from './types.js';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/svelte/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,sBAAsB,MAAM,4CAA4C,CAAC;AAEhF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,MAAM,MAAM,2BAA2B,GAAG,cAAc,CACtD,OAAO,sBAAsB,CAC9B,CAAC;AAEF,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,YAAY,GACb,MAAM,YAAY,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @happyvertical/smrt-inference/svelte
3
+ *
4
+ * Optional Svelte 5 UI for inference settings (#4754). Presentational only:
5
+ * the panel takes rows and callbacks, does no fetching, and makes no
6
+ * authorization decision. Hosts render it from a server load that used
7
+ * `InferenceSettingsService` (`./server`) and wire saves to their own
8
+ * permission-checked actions. The root entry stays Svelte-free.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ import InferenceSettingsPanel from './components/InferenceSettingsPanel.svelte';
13
+ export { InferenceSettingsPanel };
14
+ export { candidateViewLabel, defaultTierRevertPreview, describeTargetView, INFERENCE_SETTINGS_MODES, INFERENCE_SETTINGS_TIERS, inferenceLevelLabel, isRefAllowed, targetViewRef, tierRevertPreview, usageColumns, } from './types.js';
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Presentational types for the inference settings UI (#4754).
3
+ *
4
+ * Deliberately free of `@happyvertical/smrt-core`, the AI SDK and the
5
+ * `@smrt()` model, so the browser bundle stays a thin presentation layer.
6
+ * Field names match the rows `InferenceSettingsService` returns
7
+ * (`./server`), so a row is structurally assignable to its view with no
8
+ * mapping step.
9
+ *
10
+ * @module
11
+ */
12
+ export declare const INFERENCE_SETTINGS_TIERS: readonly ["cheap", "good", "great", "best"];
13
+ export type InferenceSettingsTier = (typeof INFERENCE_SETTINGS_TIERS)[number];
14
+ export declare const INFERENCE_SETTINGS_MODES: readonly ["byo", "local", "hosted", "off"];
15
+ export type InferenceSettingsMode = (typeof INFERENCE_SETTINGS_MODES)[number];
16
+ export type InferenceSettingsLevelView = 'default' | 'config' | 'app' | 'tenant';
17
+ export type InferenceSettingsScope = 'app' | 'tenant';
18
+ /**
19
+ * A tier target as the panel reads and emits it: a model, an alias or a
20
+ * fusion. Never a key, never an endpoint (an endpoint belongs in an alias).
21
+ * `null` means "same as default".
22
+ */
23
+ export interface InferenceTargetView {
24
+ kind?: string;
25
+ provider?: string;
26
+ model?: string;
27
+ alias?: string;
28
+ fusion?: string;
29
+ candidates?: unknown[];
30
+ }
31
+ /** The user's choices for the default view, plus whether a key is stored. */
32
+ export interface InferenceDefaultsView {
33
+ mode?: InferenceSettingsMode;
34
+ provider?: string;
35
+ baseUrl?: string;
36
+ model?: string;
37
+ defaultTier?: InferenceSettingsTier;
38
+ /** Whether the host holds a key for {@link provider}. The key itself never comes back. */
39
+ keySet?: boolean;
40
+ }
41
+ /** What Save emits from the default view. Never contains a key. */
42
+ export interface InferenceDefaultsChange {
43
+ mode: InferenceSettingsMode;
44
+ provider?: string;
45
+ baseUrl?: string;
46
+ model?: string;
47
+ defaultTier?: InferenceSettingsTier;
48
+ }
49
+ /** What the replace-key action emits. The host stores it through smrt-secrets. */
50
+ export interface InferenceKeyChange {
51
+ provider: string;
52
+ key: string;
53
+ /** Set when the provider choice is a #4674 preset. */
54
+ preset?: string;
55
+ /**
56
+ * The base URL shown when the key was entered. The host binds the key to
57
+ * this endpoint's origin (`bindInferenceKey()`), not to saved choices.
58
+ */
59
+ baseUrl?: string;
60
+ }
61
+ /** One provider choice (`InferenceProviderOption` from `./server`). */
62
+ export interface InferenceProviderView {
63
+ id: string;
64
+ label: string;
65
+ kind: 'preset' | 'provider';
66
+ baseUrl?: string;
67
+ requiresApiKey: boolean;
68
+ needsBaseUrl?: boolean;
69
+ local?: boolean;
70
+ }
71
+ /** Local discovery results (#4674). */
72
+ export interface InferenceDiscoveryView {
73
+ service: string;
74
+ baseUrl: string;
75
+ models: string[];
76
+ }
77
+ /** What Test connection asks the host to probe. Never carries a key. */
78
+ export interface InferenceConnectionRequest {
79
+ provider?: string;
80
+ preset?: string;
81
+ baseUrl?: string;
82
+ model?: string;
83
+ }
84
+ /** Key-free probe result (`InferenceConnectionResult`). */
85
+ export interface InferenceTestResultView {
86
+ reachable: boolean;
87
+ skipped?: boolean;
88
+ status?: number;
89
+ durationMs?: number;
90
+ detail: string;
91
+ }
92
+ /** One tier row (`InferenceTierSettingsRow`). */
93
+ export interface InferenceTierView {
94
+ tier: InferenceSettingsTier;
95
+ effectiveTarget?: InferenceTargetView | null;
96
+ effectiveLabel: string;
97
+ supplyingLevel?: InferenceSettingsLevelView;
98
+ appTarget?: InferenceTargetView | null;
99
+ tenantTarget?: InferenceTargetView | null;
100
+ /** What reverting the app scope produces. */
101
+ appRevertLabel?: string;
102
+ /** What reverting the tenant scope produces (`null`: not computed). */
103
+ inheritedLabel?: string | null;
104
+ tenantAllowList?: string[] | null;
105
+ tenantBlocked?: boolean;
106
+ }
107
+ /** `auto`'s default tier (`InferenceDefaultTierSetting`). */
108
+ export interface InferenceDefaultTierView {
109
+ effectiveTier: InferenceSettingsTier;
110
+ supplyingLevel?: InferenceSettingsLevelView;
111
+ appTier?: InferenceSettingsTier | null;
112
+ tenantTier?: InferenceSettingsTier | null;
113
+ appRevertTier?: InferenceSettingsTier;
114
+ inheritedTier?: InferenceSettingsTier | null;
115
+ tenantAllowList?: string[] | null;
116
+ tenantBlocked?: boolean;
117
+ }
118
+ /** One candidate of an alias chain. `apiKeyEnv` names a variable; there is never a key. */
119
+ export interface InferenceCandidateView {
120
+ provider?: string;
121
+ model?: string;
122
+ baseUrl?: string;
123
+ apiKeyEnv?: string;
124
+ preset?: string;
125
+ alias?: string;
126
+ params?: Record<string, unknown>;
127
+ }
128
+ /** One alias (`InferenceAliasSetting`). */
129
+ export interface InferenceAliasView {
130
+ name: string;
131
+ source?: 'config' | 'app';
132
+ candidates: InferenceCandidateView[];
133
+ description?: string;
134
+ inConfig?: boolean;
135
+ }
136
+ /** One fusion (`InferenceFusionSetting`). */
137
+ export interface InferenceFusionView {
138
+ name: string;
139
+ source: 'registry' | 'config' | 'app';
140
+ definition: Record<string, unknown>;
141
+ description?: string;
142
+ editable?: boolean;
143
+ }
144
+ /** Usage report (`reportAiUsage()`, #4751), structurally. */
145
+ export interface InferenceUsageView {
146
+ by: string[];
147
+ costBasis?: string;
148
+ buckets: Array<{
149
+ key: Record<string, string | null | undefined>;
150
+ calls: number;
151
+ totalTokens: number;
152
+ estimatedCost: number;
153
+ uncostedCalls?: number;
154
+ outcomes?: Record<string, number>;
155
+ }>;
156
+ }
157
+ export type InferenceUsageDimension = 'model' | 'tier' | 'prompt';
158
+ export interface InferenceTierChange {
159
+ tier: InferenceSettingsTier;
160
+ scope: InferenceSettingsScope;
161
+ target: InferenceTargetView | null;
162
+ }
163
+ export interface InferenceDefaultTierChange {
164
+ scope: InferenceSettingsScope;
165
+ tier: InferenceSettingsTier | null;
166
+ }
167
+ export interface InferenceAliasChange {
168
+ name: string;
169
+ /** `null` removes the app definition. */
170
+ candidates: InferenceCandidateView[] | null;
171
+ description?: string;
172
+ }
173
+ export interface InferenceFusionChange {
174
+ name: string;
175
+ /** `null` removes the config entry. */
176
+ definition: Record<string, unknown> | null;
177
+ }
178
+ /** Human label for a supplying level. */
179
+ export declare function inferenceLevelLabel(level: InferenceSettingsLevelView | undefined): string;
180
+ /** Key-free label of a target. Mirrors `describeInferenceTarget()` in `./server`. */
181
+ export declare function describeTargetView(target: InferenceTargetView | null | undefined): string;
182
+ /** Key-free label of a candidate (`provider/model`, `preset:<id>/model`, `alias <name>`). */
183
+ export declare function candidateViewLabel(candidate: InferenceCandidateView): string;
184
+ /** Allow-list reference of a target. Mirrors `inferenceTargetRef()` in `./server`. */
185
+ export declare function targetViewRef(target: InferenceTargetView): string;
186
+ /**
187
+ * Whether a reference is on an allow-list (exact, trailing `*`, or `*`).
188
+ * Display only: the server enforces the list on every tenant write.
189
+ */
190
+ export declare function isRefAllowed(ref: string, allowList: readonly string[] | null | undefined): boolean;
191
+ /** What reverting a tier at `scope` produces (the prompts revert invariant). */
192
+ export declare function tierRevertPreview(row: InferenceTierView, scope: InferenceSettingsScope): string;
193
+ /** The tier `auto` returns to when the scope reverts. */
194
+ export declare function defaultTierRevertPreview(view: InferenceDefaultTierView, scope: InferenceSettingsScope): InferenceSettingsTier;
195
+ /** Usage columns to render: only the dimensions the report was grouped by. */
196
+ export declare function usageColumns(view: InferenceUsageView): string[];
197
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/svelte/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,wBAAwB,6CAK3B,CAAC;AACX,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E,eAAO,MAAM,wBAAwB,4CAK3B,CAAC;AACX,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E,MAAM,MAAM,0BAA0B,GAClC,SAAS,GACT,QAAQ,GACR,KAAK,GACL,QAAQ,CAAC;AACb,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEtD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;CACxB;AAED,6EAA6E;AAC7E,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,0FAA0F;IAC1F,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,mEAAmE;AACnE,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC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