@happyvertical/smrt-inference 0.74.7 → 0.75.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.
- package/AGENTS.md +4 -0
- package/agents/settings.md +13 -0
- package/dist/chunks/{InferenceOverrideCollection-Xch71Ltt.js → InferenceOverrideCollection-C9bY01Rv.js} +2 -2
- package/dist/chunks/{InferenceOverrideCollection-Xch71Ltt.js.map → InferenceOverrideCollection-C9bY01Rv.js.map} +1 -1
- package/dist/i18n/catalog.d.ts +3 -0
- package/dist/i18n/catalog.d.ts.map +1 -0
- package/dist/i18n/catalog.generated.d.ts +3 -0
- package/dist/i18n/catalog.generated.d.ts.map +1 -0
- package/dist/i18n/catalog.js +280 -0
- package/dist/i18n/catalog.js.map +1 -0
- package/dist/manifest.json +1 -1
- package/dist/models.js +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +419 -137
- package/dist/server.js.map +1 -1
- package/dist/settings/controller.d.ts +18 -0
- package/dist/settings/controller.d.ts.map +1 -1
- package/dist/settings/history.d.ts +210 -0
- package/dist/settings/history.d.ts.map +1 -0
- package/dist/settings/settings-service.d.ts +5 -1
- package/dist/settings/settings-service.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +11 -8
- package/dist/svelte/components/InferencePromptHistory.svelte +200 -0
- package/dist/svelte/components/InferencePromptHistory.svelte.d.ts +12 -0
- package/dist/svelte/components/InferencePromptHistory.svelte.d.ts.map +1 -0
- package/dist/svelte/components/InferenceSettingsPanel.svelte +19 -1
- package/dist/svelte/components/InferenceSettingsPanel.svelte.d.ts +3 -1
- package/dist/svelte/components/InferenceSettingsPanel.svelte.d.ts.map +1 -1
- package/dist/svelte/history.messages.d.ts +57 -0
- package/dist/svelte/history.messages.d.ts.map +1 -0
- package/dist/svelte/history.messages.js +58 -0
- package/dist/svelte/index.d.ts +1 -0
- package/dist/svelte/index.d.ts.map +1 -1
- package/dist/svelte/types.d.ts +73 -0
- package/dist/svelte/types.d.ts.map +1 -1
- package/package.json +15 -10
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a page that hosts `InferenceSettingsPanel` does on the server, minus
|
|
3
|
+
* the web framework: the data the panel loads and the writes behind its
|
|
4
|
+
* callbacks. A SvelteKit template app and the app shell each wire their
|
|
5
|
+
* `load` and form actions to one controller, so the two cannot drift.
|
|
6
|
+
*
|
|
7
|
+
* The controller decides nothing about identity. The host passes a session
|
|
8
|
+
* (`can(permission)` is its own check: a permission snapshot, or the shell's
|
|
9
|
+
* owner lookup) and the controller gates every write on
|
|
10
|
+
* {@link CUSTOMIZE_INFERENCE_PERMISSION}, again in the settings service's
|
|
11
|
+
* authorizer. No method returns or logs a key; a refusal names none.
|
|
12
|
+
*/
|
|
13
|
+
import type { AiPromptComparison, AiPromptTemplateHistory } from '@happyvertical/smrt-core';
|
|
1
14
|
import type { InferenceSettingsHost } from './host.js';
|
|
2
15
|
import { type InferenceKeyPayload } from './key-store.js';
|
|
3
16
|
import { type InferencePreferenceStoreLike } from './preferences.js';
|
|
@@ -28,6 +41,8 @@ export type InferenceSettingsPageData = Awaited<ReturnType<typeof loadPage>>;
|
|
|
28
41
|
type Tier = 'cheap' | 'good' | 'great' | 'best';
|
|
29
42
|
/** The principal of a settings request. */
|
|
30
43
|
export interface InferenceControllerSession {
|
|
44
|
+
/** Required for audited historical reads. */
|
|
45
|
+
userId?: string;
|
|
31
46
|
tenantId: string;
|
|
32
47
|
/** Whether the session holds `permission` (the host's own check). */
|
|
33
48
|
can(permission: string): boolean;
|
|
@@ -47,6 +62,9 @@ export interface InferenceSettingsControllerOptions {
|
|
|
47
62
|
preferenceStore: () => Promise<InferencePreferenceStoreLike>;
|
|
48
63
|
}
|
|
49
64
|
export interface InferenceSettingsController {
|
|
65
|
+
/** Recorded usage only, scoped to the authenticated session; customize permission required. */
|
|
66
|
+
compare(session: InferenceControllerSession, request: unknown): Promise<AiPromptComparison>;
|
|
67
|
+
history(session: InferenceControllerSession, request: unknown): Promise<AiPromptTemplateHistory>;
|
|
50
68
|
/** Whether the session may write app-wide settings and keys. */
|
|
51
69
|
canCustomize(session: InferenceControllerSession): boolean;
|
|
52
70
|
/** The panel's props. `by` is the usage report grouping (`a,b`). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/settings/controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/settings/controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAEV,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,OAAO,EACL,KAAK,mBAAmB,EAGzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAGL,KAAK,4BAA4B,EAElC,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAUlD,wDAAwD;AACxD,iBAAe,QAAQ,CACrB,OAAO,EAAE,kCAAkC,EAC3C,OAAO,EAAE,0BAA0B,EACnC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;;;;;;;;;;;;;;;;;;;GAqCnB;AAED,iFAAiF;AACjF,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC;AAE7E,KAAK,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAEhD,2CAA2C;AAC3C,MAAM,WAAW,0BAA0B;IACzC,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;CAClC;AAED,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E,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,OAAO,CAAC,wBAAwB,CAAC;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC,CAAC;IAC1D,aAAa,CACX,OAAO,EAAE,0BAA0B,EACnC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,OAAO,CAAC,wBAAwB,CAAC;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC,CAAC;IAC1D,cAAc,CACZ,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACrC;AAED,eAAO,MAAM,mBAAmB;;;;CAItB,CAAC;AAEX,wCAAwC;AACxC,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,kCAAkC,GAC1C,2BAA2B,CA2K7B"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/** Shared read-only HTTP/MCP contract. Authority is always the host session. */
|
|
2
|
+
import type { AiPromptCompareOptions, AiPromptTemplateHistoryOptions } from '@happyvertical/smrt-core';
|
|
3
|
+
import type { InferenceControllerSession, InferenceSettingsController } from './controller.js';
|
|
4
|
+
/** One permission check for HTTP, MCP and page callbacks; no ambient bypass. */
|
|
5
|
+
export declare function assertInferenceHistoryPermission(session: InferenceControllerSession): Promise<void>;
|
|
6
|
+
export type InferenceCompareRequest = Omit<AiPromptCompareOptions, 'tenantId' | 'allowCrossTenant' | 'since' | 'until'> & {
|
|
7
|
+
since?: string;
|
|
8
|
+
until?: string;
|
|
9
|
+
};
|
|
10
|
+
export type InferenceHistoryRequest = Omit<AiPromptTemplateHistoryOptions, 'tenantId' | 'allowCrossTenant' | 'since' | 'until'> & {
|
|
11
|
+
since?: string;
|
|
12
|
+
until?: string;
|
|
13
|
+
};
|
|
14
|
+
/** Validates untrusted JSON and rejects caller-supplied tenant authority. */
|
|
15
|
+
export declare function parseInferenceHistoryRequest(value: unknown, compare: boolean): {
|
|
16
|
+
transcriptLimit?: number | undefined;
|
|
17
|
+
a?: import("@happyvertical/smrt-core").AiPromptCompareSelector | undefined;
|
|
18
|
+
b?: import("@happyvertical/smrt-core").AiPromptCompareSelector | undefined;
|
|
19
|
+
since?: Date;
|
|
20
|
+
until?: Date;
|
|
21
|
+
promptKey: string;
|
|
22
|
+
};
|
|
23
|
+
/** Both host catalogs use these names and closed schemas. */
|
|
24
|
+
export declare const INFERENCE_HISTORY_TOOLS: readonly [{
|
|
25
|
+
readonly name: "inference_prompt_history";
|
|
26
|
+
readonly operation: "history";
|
|
27
|
+
readonly description: "List recorded template hashes for a prompt in your tenant.";
|
|
28
|
+
}, {
|
|
29
|
+
readonly name: "inference_prompt_compare";
|
|
30
|
+
readonly operation: "compare";
|
|
31
|
+
readonly description: "Compare recorded prompt versions, models or tiers in your tenant; never runs prompts.";
|
|
32
|
+
}];
|
|
33
|
+
export declare function inferenceHistoryInputSchema(compare: boolean): {
|
|
34
|
+
type: "object";
|
|
35
|
+
properties: {
|
|
36
|
+
a?: {
|
|
37
|
+
type: string;
|
|
38
|
+
properties: {
|
|
39
|
+
templateHash: {
|
|
40
|
+
type: string;
|
|
41
|
+
};
|
|
42
|
+
model: {
|
|
43
|
+
type: string;
|
|
44
|
+
};
|
|
45
|
+
tier: {
|
|
46
|
+
type: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
minProperties: number;
|
|
50
|
+
maxProperties: number;
|
|
51
|
+
additionalProperties: boolean;
|
|
52
|
+
} | undefined;
|
|
53
|
+
b?: {
|
|
54
|
+
type: string;
|
|
55
|
+
properties: {
|
|
56
|
+
templateHash: {
|
|
57
|
+
type: string;
|
|
58
|
+
};
|
|
59
|
+
model: {
|
|
60
|
+
type: string;
|
|
61
|
+
};
|
|
62
|
+
tier: {
|
|
63
|
+
type: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
minProperties: number;
|
|
67
|
+
maxProperties: number;
|
|
68
|
+
additionalProperties: boolean;
|
|
69
|
+
} | undefined;
|
|
70
|
+
transcriptLimit?: {
|
|
71
|
+
type: string;
|
|
72
|
+
minimum: number;
|
|
73
|
+
maximum: number;
|
|
74
|
+
} | undefined;
|
|
75
|
+
promptKey: {
|
|
76
|
+
type: string;
|
|
77
|
+
};
|
|
78
|
+
since: {
|
|
79
|
+
type: string;
|
|
80
|
+
};
|
|
81
|
+
until: {
|
|
82
|
+
type: string;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
required: string[];
|
|
86
|
+
additionalProperties: boolean;
|
|
87
|
+
};
|
|
88
|
+
/** Route adapter used after the host authenticates a request. No framework dependency. */
|
|
89
|
+
export declare function inferenceHistoryResponse(controller: InferenceSettingsController, session: InferenceControllerSession, request: Request): Promise<Response>;
|
|
90
|
+
/** Audited transcript destination; hosts supply actor and verified session, never query authority. */
|
|
91
|
+
export declare function inferenceTranscriptResponse(db: import('@happyvertical/sql').DatabaseInterface, session: InferenceControllerSession, actor: string, request: Request): Promise<Response>;
|
|
92
|
+
/** Structural MCP workflow definitions; mount with a verified host principal. */
|
|
93
|
+
export declare function createInferenceHistoryMcpTools(controller: InferenceSettingsController): {
|
|
94
|
+
name: "inference_prompt_history" | "inference_prompt_compare";
|
|
95
|
+
description: "List recorded template hashes for a prompt in your tenant." | "Compare recorded prompt versions, models or tiers in your tenant; never runs prompts.";
|
|
96
|
+
inputSchema: {
|
|
97
|
+
type: "object";
|
|
98
|
+
properties: {
|
|
99
|
+
a?: {
|
|
100
|
+
type: string;
|
|
101
|
+
properties: {
|
|
102
|
+
templateHash: {
|
|
103
|
+
type: string;
|
|
104
|
+
};
|
|
105
|
+
model: {
|
|
106
|
+
type: string;
|
|
107
|
+
};
|
|
108
|
+
tier: {
|
|
109
|
+
type: string;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
minProperties: number;
|
|
113
|
+
maxProperties: number;
|
|
114
|
+
additionalProperties: boolean;
|
|
115
|
+
} | undefined;
|
|
116
|
+
b?: {
|
|
117
|
+
type: string;
|
|
118
|
+
properties: {
|
|
119
|
+
templateHash: {
|
|
120
|
+
type: string;
|
|
121
|
+
};
|
|
122
|
+
model: {
|
|
123
|
+
type: string;
|
|
124
|
+
};
|
|
125
|
+
tier: {
|
|
126
|
+
type: string;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
minProperties: number;
|
|
130
|
+
maxProperties: number;
|
|
131
|
+
additionalProperties: boolean;
|
|
132
|
+
} | undefined;
|
|
133
|
+
transcriptLimit?: {
|
|
134
|
+
type: string;
|
|
135
|
+
minimum: number;
|
|
136
|
+
maximum: number;
|
|
137
|
+
} | undefined;
|
|
138
|
+
promptKey: {
|
|
139
|
+
type: string;
|
|
140
|
+
};
|
|
141
|
+
since: {
|
|
142
|
+
type: string;
|
|
143
|
+
};
|
|
144
|
+
until: {
|
|
145
|
+
type: string;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
required: string[];
|
|
149
|
+
additionalProperties: boolean;
|
|
150
|
+
};
|
|
151
|
+
outputSchema: {
|
|
152
|
+
type: "object";
|
|
153
|
+
additionalProperties: boolean;
|
|
154
|
+
};
|
|
155
|
+
effect: "read";
|
|
156
|
+
idempotent: boolean;
|
|
157
|
+
openWorld: boolean;
|
|
158
|
+
execute(context: {
|
|
159
|
+
arguments: Record<string, unknown>;
|
|
160
|
+
principal: {
|
|
161
|
+
id?: string;
|
|
162
|
+
tenantId?: string;
|
|
163
|
+
scopes?: readonly string[];
|
|
164
|
+
} | null;
|
|
165
|
+
}): Promise<{
|
|
166
|
+
content: {
|
|
167
|
+
type: "text";
|
|
168
|
+
text: string;
|
|
169
|
+
}[];
|
|
170
|
+
structuredContent: import("@happyvertical/smrt-core").AiPromptTemplateHistory | import("@happyvertical/smrt-core").AiPromptComparison;
|
|
171
|
+
}>;
|
|
172
|
+
}[];
|
|
173
|
+
/** MCP equivalent of the host transcript destination, with the same audit boundary. */
|
|
174
|
+
export declare function createInferenceTranscriptMcpTool(database: () => Promise<import('@happyvertical/sql').DatabaseInterface>): {
|
|
175
|
+
name: string;
|
|
176
|
+
description: string;
|
|
177
|
+
inputSchema: {
|
|
178
|
+
type: "object";
|
|
179
|
+
properties: {
|
|
180
|
+
[k: string]: {
|
|
181
|
+
type: string;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
additionalProperties: boolean;
|
|
185
|
+
};
|
|
186
|
+
outputSchema: {
|
|
187
|
+
type: "object";
|
|
188
|
+
additionalProperties: boolean;
|
|
189
|
+
};
|
|
190
|
+
effect: "read";
|
|
191
|
+
idempotent: boolean;
|
|
192
|
+
openWorld: boolean;
|
|
193
|
+
execute(context: {
|
|
194
|
+
arguments: Record<string, unknown>;
|
|
195
|
+
principal: {
|
|
196
|
+
id?: string;
|
|
197
|
+
tenantId?: string;
|
|
198
|
+
scopes?: readonly string[];
|
|
199
|
+
} | null;
|
|
200
|
+
}): Promise<{
|
|
201
|
+
content: {
|
|
202
|
+
type: "text";
|
|
203
|
+
text: string;
|
|
204
|
+
}[];
|
|
205
|
+
structuredContent: {
|
|
206
|
+
transcripts: unknown;
|
|
207
|
+
};
|
|
208
|
+
}>;
|
|
209
|
+
};
|
|
210
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/settings/history.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO,KAAK,EACV,sBAAsB,EACtB,8BAA8B,EAC/B,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,iBAAiB,CAAC;AAMzB,gFAAgF;AAChF,wBAAsB,gCAAgC,CACpD,OAAO,EAAE,0BAA0B,iBAqBpC;AAED,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,sBAAsB,EACtB,UAAU,GAAG,kBAAk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AAM,CAAC;YACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;SAC5B,GAAG,IAAI,CAAC;KACV;;;;;;;IAkBJ;AAED,uFAAuF;AACvF,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,MAAM,OAAO,CAAC,OAAO,oBAAoB,EAAE,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;qBAmB9C;QACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,SAAS,EAAE;YACT,EAAE,CAAC,EAAE,MAAM,CAAC;YACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;SAC5B,GAAG,IAAI,CAAC;KACV;;;;;;;;;EAqCJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AiUsageReport, type AiUsageReportDimension, type InferenceAlias, type InferenceCandidate, type InferenceConfig, type InferenceTarget, type InferenceTier, type InferenceTranscriptsConfig, type RetentionPolicy, type SmrtClassOptions } from '@happyvertical/smrt-core';
|
|
1
|
+
import { type AiPromptCompareOptions, type AiPromptTemplateHistoryOptions, type AiUsageReport, type AiUsageReportDimension, type InferenceAlias, type InferenceCandidate, type InferenceConfig, type InferenceTarget, type InferenceTier, type InferenceTranscriptsConfig, type RetentionPolicy, type SmrtClassOptions } from '@happyvertical/smrt-core';
|
|
2
2
|
import { InferenceOverrideCollection, type InferenceOverrideScopeType } from '../models/InferenceOverrideCollection.js';
|
|
3
3
|
import { type InferenceDoctorReport } from '../node.js';
|
|
4
4
|
import type { InferenceConfigIssue } from '../types.js';
|
|
@@ -343,6 +343,10 @@ export declare class InferenceSettingsService {
|
|
|
343
343
|
tenantId?: string | null;
|
|
344
344
|
transcripts?: boolean;
|
|
345
345
|
}): Promise<AiUsageReport>;
|
|
346
|
+
/** Read recorded prompt runs only; scope is required by the core reader. */
|
|
347
|
+
compare(options: AiPromptCompareOptions): Promise<import("@happyvertical/smrt-core").AiPromptComparison>;
|
|
348
|
+
/** Template versions observed in recorded usage, never executing a prompt. */
|
|
349
|
+
history(options: AiPromptTemplateHistoryOptions): Promise<import("@happyvertical/smrt-core").AiPromptTemplateHistory>;
|
|
346
350
|
/** Local discovery for the model field (#4674's loopback probe). */
|
|
347
351
|
discoverModels(): Promise<Array<{
|
|
348
352
|
service: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-service.d.ts","sourceRoot":"","sources":["../../src/settings/settings-service.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,sBAAsB,
|
|
1
|
+
{"version":3,"file":"settings-service.d.ts","sourceRoot":"","sources":["../../src/settings/settings-service.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,8BAA8B,EACnC,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAW3B,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EAEpB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,0BAA0B,EAE/B,KAAK,eAAe,EAGpB,KAAK,gBAAgB,EAEtB,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EACL,2BAA2B,EAC3B,KAAK,0BAA0B,EAChC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAEL,KAAK,qBAAqB,EAG3B,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACL,KAAK,kBAAkB,EAGxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAEL,KAAK,uBAAuB,EAK7B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,2BAA2B,EAEhC,KAAK,2BAA2B,EACjC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,oBAAoB,EAIpB,KAAK,gCAAgC,EAGrC,mBAAm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AAC,CAAC;QACzC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;KACjB,GACL,OAAO,CAAC,qBAAqB,CAAC;IAYjC;;;;OAIG;IACG,qBAAqB,IAAI,OAAO,CAAC,2BAA2B,CAAC;IA8CnE;;;;;OAKG;IACG,qBAAqB,CAAC,OAAO,EAAE;QACnC,QAAQ,EAAE,gCAAgC,GAAG,IAAI,CAAC;KACnD,GAAG,OAAO,CAAC,IAAI,CAAC;IAYjB;;;;;;OAMG;IACH,KAAK,CACH,OAAO,GAAE;QACP,EAAE,CAAC,EAAE,6BAA6B,EAAE,CAAC;QACrC,KAAK,CAAC,EAAE,IAAI,CAAC;QACb,KAAK,CAAC,EAAE,IAAI,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,WAAW,CAAC,EAAE,OAAO,CAAC;KAClB,GACL,OAAO,CAAC,aAAa,CAAC;IAOzB,4EAA4E;IAC5E,OAAO,CAAC,OAAO,EAAE,sBAAsB;IAIvC,8EAA8E;IAC9E,OAAO,CAAC,OAAO,EAAE,8BAA8B;IAI/C,oEAAoE;IAC9D,cAAc,IAAI,OAAO,CAC7B,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAC9D;IAcD,sEAAsE;IACtE,mBAAmB,IAAI,uBAAuB,EAAE;CA0BjD"}
|
package/dist/smrt-knowledge.json
CHANGED
|
@@ -3,22 +3,23 @@
|
|
|
3
3
|
"sensitiveFieldsExcluded": true,
|
|
4
4
|
"generatedAt": "1970-01-01T00:00:00.000Z",
|
|
5
5
|
"packageName": "@happyvertical/smrt-inference",
|
|
6
|
-
"packageVersion": "0.
|
|
6
|
+
"packageVersion": "0.75.0",
|
|
7
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
8
8
|
"agentDocPath": "AGENTS.md",
|
|
9
9
|
"sourceHashes": {
|
|
10
|
-
"manifest": "
|
|
11
|
-
"packageJson": "
|
|
12
|
-
"agents": "
|
|
10
|
+
"manifest": "f8566828ac68acd4a33b7533653b00776da1b7bab9b07d438d07b6efef64697d",
|
|
11
|
+
"packageJson": "4448b624dacbd7338821aaa292cc14d74b98c29a803c266af120ceb0cf50ee42",
|
|
12
|
+
"agents": "c9327a8a68698ff301e3edc0d201977d3cb299a078ef76ba58947a0bb6eeb3e2",
|
|
13
13
|
"moduleDoc:agents/engines.md": "1fee8176dc87fe963da1e7aeee49cfbb27500e20a3115734a3e05cc80133ab6b",
|
|
14
14
|
"moduleDoc:agents/resolver.md": "71de7295b6988b27b3b27e2ae82fd71e525ef53613c7714a1deea6c45ba92ef6",
|
|
15
15
|
"moduleDoc:agents/hosted.md": "ef6ca489e5c2960fb100a635d786ed26558b8612dfac20b65758d57aad7937a0",
|
|
16
16
|
"moduleDoc:agents/fusions.md": "85cd95e209bcc70f8cdcac1bad702228e74ec59be9c7613d50bc4526afa17f5b",
|
|
17
|
-
"moduleDoc:agents/settings.md": "
|
|
17
|
+
"moduleDoc:agents/settings.md": "1ef4bb939ac6b9343d0d41ce3c486323fb3377e6af8546a2b0598503f31feb48"
|
|
18
18
|
},
|
|
19
19
|
"exports": [
|
|
20
20
|
".",
|
|
21
21
|
"./gate",
|
|
22
|
+
"./i18n/catalog",
|
|
22
23
|
"./manifest",
|
|
23
24
|
"./manifest.json",
|
|
24
25
|
"./models",
|
|
@@ -38,12 +39,13 @@
|
|
|
38
39
|
"@happyvertical/smrt-tenancy": "workspace:*",
|
|
39
40
|
"@happyvertical/smrt-users": "workspace:*",
|
|
40
41
|
"@happyvertical/sql": "catalog:",
|
|
42
|
+
"@happyvertical/smrt-ui": "workspace:*",
|
|
41
43
|
"@happyvertical/smrt-vitest": "workspace:*",
|
|
42
44
|
"@sveltejs/package": "^2.5.8",
|
|
43
45
|
"@sveltejs/vite-plugin-svelte": "^7.3.0",
|
|
44
46
|
"@types/node": "24.13.6",
|
|
45
47
|
"jsdom": "^29.1.1",
|
|
46
|
-
"svelte": "^5.57.
|
|
48
|
+
"svelte": "^5.57.1",
|
|
47
49
|
"svelte-check": "^4.7.6",
|
|
48
50
|
"typescript": "6.0.3",
|
|
49
51
|
"vite": "8.1.6",
|
|
@@ -55,6 +57,7 @@
|
|
|
55
57
|
"@happyvertical/smrt-prompts",
|
|
56
58
|
"@happyvertical/smrt-secrets",
|
|
57
59
|
"@happyvertical/smrt-tenancy",
|
|
60
|
+
"@happyvertical/smrt-ui",
|
|
58
61
|
"@happyvertical/smrt-users",
|
|
59
62
|
"@happyvertical/smrt-vitest"
|
|
60
63
|
],
|
|
@@ -309,7 +312,7 @@
|
|
|
309
312
|
"polymorphicAssociations": 0,
|
|
310
313
|
"uuidColumns": 4
|
|
311
314
|
},
|
|
312
|
-
"agentDoc": "# smrt-inference\n\nBinding behavior for core's inference tiers (epic #4749). Core owns the names\nand the seam ([core inference.md](../core/agents/inference.md)); this package\nowns alias chains, classified fallback, ladder degradation and\n`smrt doctor --ai` (#4752), the fusion interpreter (#4753), the settings\npanel with layered binding storage (#4754), per-user and per-tenant\nbindings (#4756), candidate capability checks (#4758), and hosted\nprovisioning and the spend gate (#4759, #4760). App-author guide:\n[docs/content/inference.md](../../docs/content/inference.md).\n\n## Entries\n\n- Root (browser-safe): importing it calls `registerInference()`, which sets\n the executor (`alias`, `candidates`, `fusion`) and a validating resolver\n (`setInferenceResolver()`). The resolver binds nothing: it validates chain\n config, then defers to a resolver registered earlier (#4756 per-user\n bindings, `./resolver`) or to core's built-in config resolution. No aliases and no chain\n targets means no change in behavior. `browser-safe.test.ts` holds the graph\n free of `node:`, the AI SDK and smrt-config by walking its import graph;\n the bundle-gate browser fixture also builds it (the package has a model).\n- `./node`: `checkInferenceBindings()`, `probeInferenceCandidate()`,\n `inferenceProbeUrl()`, `formatInferenceDoctorReport()`; the CLI's\n `doctor --ai` and #4754's test connection call these. Also hosted\n provisioning (`src/hosted.ts`, #4759).\n- `./resolver` (Node-only, #4756): `createUserInferenceResolver()` and\n `registerUserInferenceResolver()` over smrt-secrets / tenancy / users. The\n root re-exports only the browser-safe stored-config shape\n (`src/provider-config.ts`): parse, redact, tier → target map.\n- `./models` (browser-safe, held by `browser-safe.test.ts` and the\n bundle-gate browser fixture): the `_smrt_inference_overrides` model;\n generated consumer registration imports it from here.\n- `./server` (Node-only): settings service, override service, override\n resolver, key rule, preference kind (#4754); local CLI turns, ChatGPT model\n rounds and connection diagnostics ([agents/engines.md](agents/engines.md)).\n `./svelte`: the panel.\n- `./test-support` (Node-only): shared fake CLI installers and isolated lookup\n dependencies for engine/host tests; fixture source is bundled, never run on\n real credentials ([agents/engines.md](agents/engines.md)).\n- `./gate` (Node-only, #4760): the hosted spend gate and kill switch\n (below). `browser-safe.test.ts` keeps it off the root graph.\n\n## Per-user and per-tenant bindings (#4756)\n\n`createUserInferenceResolver()` resolves per tier: the user's stored config,\nthe tenant's, `fallback`, the app `inference` block, then the configured\nclient; every resolution carries `target.source` (`byo | local | hosted |\napp`, the `source` usage tag). Keys live only in the smrt-secrets type\n`inference.provider-config` (`context = tenantId`), every stored binding is\nself-contained (own `baseUrl` + `apiKey`, or a preset), the user layer\napplies only to a principal of that tenant, and agents pass `userId: null`\n(tenant layer only). The stored config also carries `mode` (#4757).\nDetails: [agents/resolver.md](agents/resolver.md).\n\n## Resolver composition\n\nOne resolver is registered, outermost first: the #4752 validating wrapper,\nthe #4756 user resolver, its `fallback`, then core's config resolution.\nHosts using the #4754 override table pass\n`createInferenceOverrideResolver({ db })` as that `fallback`:\n`registerUserInferenceResolver(createUserInferenceResolver({ db, fallback:\ncreateInferenceOverrideResolver({ db }) }))`. Order per tier: user stored\nbinding, tenant stored binding, allowed tenant override row, app override\nrow, `inference` config, configured client. Keys are stored once, in\n`inference.provider-config`: the host turns #4754's origin-bound\n`bindInferenceKey()` record into a self-contained binding with\n`inferenceProviderConfigFromKey(record, { model })` and writes it through\nthe user resolver's `write(level, config)`; never a second secret type.\n\n## Hosted inference (#4759, #4760)\n\n`./node` provisions per-user gateway keys through `ai.admin` of the\n`bifrost` / `litellm` provider (`SMRT_INFERENCE_HOSTED_*`, read once), storing\nthe key only in the user's `inference.provider-config` (`source: 'hosted'`).\nPlan changes update the key budget, revoke ends local use and then deletes the\nkey (failures are owed and retried by reconcile), and the tenant project is\nlooked up before one is created (`@happyvertical/ai` >= 0.111.7). `./gate`'s\n`registerHostedInferenceGate({ killSwitch, spend })` is core's\n`InferenceGate`: kill switch `inference.hosted.enabled` (a global DISABLE\nalways wins), tenant, entitlement, then plan spend caps; a block throws\n`InferenceUnavailableError` (`entitlement`) and writes a `blocked` usage row.\nDetails: [agents/hosted.md](agents/hosted.md).\n\n## Sign in with ChatGPT (`src/chatgpt/`, `./server`)\n\nLocal profile only; a PREVIEW for open source apps\n([limitations](https://developers.openai.com/siwc/token-sharing-open-source/preview-limitations)).\n`createChatGPTPlanConnection({ appName, credentialsPath })` wraps the SDK's\n`LocalChatGPTSessionManager` (`@happyvertical/auth/local`, loaded lazily): the\nSDK's own owner-only file at `credentialsPath` is the only credential store;\nsmrt never reads it, and no result, log or error carries a token (status is\n`signedIn`, `signingIn`, an account label, a fixed-vocabulary error;\n`clientOptions()` hands the provider `{ accessToken }` only). `start()` returns\nthe URL only after checking https on `auth.openai.com`. The resolver\n(`createChatGPTPlanResolver`, composed outside the user resolver by\n`createInferenceSettingsHost({ chatgptPlan })`) answers only calls whose\n`appliesTo` is true: `chatgpt-plan` with `source: 'byo'` when signed in,\n`unavailable: 'unconfigured'` otherwise, never an API-key fallback, never a\ndefault. The provider rejects `maxTokens`, sampling, `user`, response formats,\nreasoning, forced single-function `toolChoice` and `stream()` with tools; the\ncaller sends none of them (`classifyChatGPTPlanFailure` names the failures).\nGuide: [docs/content/inference-settings.md](../../docs/content/inference-settings.md).\n\nWhich model answers an engine that is not an API key (its default tier\nbinding), reasoning effort and the plan-refusal step:\n[agents/engines.md](agents/engines.md) (#5005).\n\n## Config\n\n```ts\nconfig({ inference: {\n aliases: { frontier: { candidates: [\n { provider: 'anthropic', model: 'claude-…' }, // provider key var\n { provider: 'openai', model: 'gpt-…', baseUrl, apiKeyEnv }, // own key + endpoint\n { preset: 'lemonade', model: 'qwen…' }, // #4674 preset\n { alias: 'local' }, // expanded in place\n ] } },\n tiers: { great: { alias: 'frontier' }, cheap: { candidates: [ … ] } },\n degrade: true, // default\n} });\n```\n\nA candidate is exactly one of provider/model, preset/model, or alias.\n`apiKeyEnv` is read at call time and needs a `baseUrl` (core's pair rule: a\nkey only travels with its own endpoint); a named variable that is unset skips\nthe candidate as `credential`. `findInferenceConfigIssues()` /\n`validateInferenceConfig()` name every offender by path: empty alias, unknown\nalias (tier or nested), cycle, key without endpoint, unknown preset. The\nexecutor also validates every resolved target it runs (a resolver's chains\nnever pass through config), and a candidate key is never dropped: without\nits own `baseUrl` core's pair rule refuses it.\n\n## Executor (`src/executor.ts`)\n\n- Free of SDK imports: it drives the clients core builds through\n `context.clientFor(target)`; tests use fake clients.\n- Failure classes (`classify.ts`): `quota | credential | missing-model |\n transient | refusal | missing-capability`, from error class names, `code`, `retryable` and HTTP\n status across `cause` / `error` / `context.originalError`, never message\n text. The SDK maps 5xx and other HTTP failures to `API_ERROR` /\n `UNKNOWN_ERROR` without a status or cause (happyvertical/sdk#1493); those\n count as `transient`. A definitive client error that survives in the chain\n (other 4xx, `invalid_request_error`, context length) is not a routing\n failure. Core's typed bind refusal (`INFERENCE_TARGET_UNBOUND`: pair rule,\n `HAVE_AI_*`) is `credential` and advances. Aborts and unclassified errors stop the walk and are rethrown (an\n unclassified one is still recorded).\n- `transient` retries the same candidate once after 200–500 ms of jitter;\n every class then advances. A `refusal` finish reason with nothing streamed\n also advances; finish callbacks are replayed only for the kept answer.\n- Streamed text is never extended: a candidate that emitted text and then\n failed ends the walk with a `partial` substitution and\n `InferenceExhaustedError` (`reason: 'partial'`, `partialText`), unless\n `allowPartial` returns the text. A hosted-gate block (`AI_UNAVAILABLE`\n from `clientFor()`, #4760) stops the walk and records nothing (core wrote\n the `blocked` row). A step whose target names a `source` (a ladder step's\n resolved binding) records that source over the chain's, so hosted spend\n meters as hosted; `expandTarget()` hands a chain's own `source` to its\n candidate steps, so a hosted chain reached on a ladder step is gated in\n `clientFor()` and meters as hosted too. A `stream()` consumer that stops reading\n aborts the provider stream (internal signal merged with the caller's).\n- Ladder: when a tier's chain is spent and `degrade !== false`, resolve the\n next lower tier through `context.resolveTier()`, stopping below\n `minimumTier`. Never up. Steps already tried (same identity) are skipped,\n so unbound lower tiers try the configured client once.\n- Tags on the answering call: caller tags, `tierRequested`, `tierResolved`\n (the tier that answered), and `substitutions` (JSON array of\n `{ from, to, reason }`, labels `provider/model`, `preset:<id>/model`,\n `default`). A call that never answered records one zero-token row through\n `context.recordUsage()` (core's usage handlers; no second writer) with\n `outcome: failed | partial`, `reason` and the full trail ending `to: null` (reason `unclassified` when a non-routing error ended it),\n then throws `InferenceExhaustedError` (`INFERENCE_EXHAUSTED`).\n- Capabilities (#4758): before calling a candidate, a call that sends\n `responseFormat` (JSON) or `tools` checks `context.capabilitiesFor(target)`\n (core's detection, [inference.md](../core/agents/inference.md)). A\n mismatch the caller's `capabilityFallback` option permits (`json: 'text'`,\n `tools: 'drop'`) runs the candidate without the feature, tagged\n `capabilityFallback`; any other is a `missing-capability` substitution and\n the walk advances with no model call. The option never reaches a provider.\n Core's `InferenceUnavailableError` (`reason: 'capability'`) also classifies\n as `missing-capability`. No detector (older core) or no requirement: no\n check. Context limits are core's (single targets only).\n- Add a class to `INFERENCE_FAILURE_CLASSES` and a kind to `EXECUTOR_KINDS`\n (`createChainExecutor()` in `fusion.ts` dispatches on it); consumers\n ignore kinds they do not run.\n\n## Fusions (#4753)\n\n`{ fusion: '<key>' }` tier targets run consumer-defined fusions (`single` 1\ncall, `pair` 3, `handoff` 2) from, highest first, the resolver's stored app\nrows (core's `lookupFusion()`, #4800), `inference.fusions`, or\n`defineFusion()`; every source is re-validated before it runs. SMRT ships the interpreter, never a fusion. Seats are\nsmrt-prompts keys run through `createChainClient()`; a dead seat never\naborts a `pair`, all seats dead throws `InferenceFusionError`; each run writes\none `_smrt_ai_runs` row. Fusions are defined at app scope only; a tenant\nmay bind a tier to an allow-listed fusion, never define one. Details:\n[agents/fusions.md](agents/fusions.md).\n\n## Doctor (`src/node.ts`)\n\nPer tier, alias and fusion (structure only): provider recognized (AI SDK provider list or preset id),\nkey variable present (a provider's default variable only warns: a\nsame-provider target inherits the configured key), model named (warns),\nalias resolvable, cycle-free. `probe` GETs `/models` (OpenAI-compatible,\nAnthropic, Gemini) or Ollama `/api/tags` with a 3 s timeout, sending the key\nonly to its own endpoint. A binding errors when its config is invalid or no\ncandidate can answer; one bad candidate in a working chain warns. Keys never\nappear in the report. With `probe` each candidate also reports its\ncapabilities and their source (#4758, `formatInferenceCapabilities()`): the\nlisting's context length, `supported_parameters` and input modalities\n(`inferenceCapabilitiesFromModelListing()`) are the `probe` layer; the SDK\n`provider` layer only through the `sdkCapabilities` option (the doctor builds\nno SDK clients).\n\n## Settings UI and binding storage (#4754)\n\n`./svelte` `InferenceSettingsPanel`, `./server` `InferenceSettingsService` /\n`InferenceOverrideService` / `createInferenceOverrideResolver()`, `./models`\nthe `_smrt_inference_overrides` model (ships through `smrt db:migrate`).\nKeys go to smrt-secrets through the host and are bound to their endpoint's\norigin; user choices are the smrt-preferences kind `inference`; app/tenant\nbindings are override rows, tenants limited to the app row's allow-list and\nthe `tenantTargetPolicy` hook. The app's transcript setting (#4781) is the\napp-only `transcripts` row, editable in the panel only with `appEditable`,\napplied as core's transcript app settings layer; the Usage tab shows\ntranscript counts and links to a host route, never content. Details: [agents/settings.md](agents/settings.md),\nconsumer guide [docs/content/inference-settings.md](../../docs/content/inference-settings.md).\n`./server` also ships the framework-free host wiring both the template and\nthe app shell use: `createInferenceSettingsHost` (secret store under the\nruntime's master key, user resolver over the override resolver, settings\nservice with its authorizer), `createInferenceSettingsController` (the\npanel's `load` and writes, gated on `inference.customize`; a refusal and a\nkey-origin error name no key), and `saveInferenceKey` / `inferenceKeyIsSet`.\nA host supplies only its session check, preference store and routes.\n\n## Validation\n\n```bash\npnpm --filter @happyvertical/smrt-inference test\npnpm --filter @happyvertical/smrt-inference test:postgres # hosted provisioning on PostgreSQL (advisory lock, runOnce)\npnpm --filter @happyvertical/smrt-inference typecheck\npnpm --filter @happyvertical/smrt-inference build\n```\n",
|
|
315
|
+
"agentDoc": "# smrt-inference\n\nBinding behavior for core's inference tiers (epic #4749). Core owns the names\nand the seam ([core inference.md](../core/agents/inference.md)); this package\nowns alias chains, classified fallback, ladder degradation and\n`smrt doctor --ai` (#4752), the fusion interpreter (#4753), the settings\npanel with layered binding storage (#4754), per-user and per-tenant\nbindings (#4756), candidate capability checks (#4758), and hosted\nprovisioning and the spend gate (#4759, #4760). App-author guide:\n[docs/content/inference.md](../../docs/content/inference.md).\n\n## Entries\n\n- Root (browser-safe): importing it calls `registerInference()`, which sets\n the executor (`alias`, `candidates`, `fusion`) and a validating resolver\n (`setInferenceResolver()`). The resolver binds nothing: it validates chain\n config, then defers to a resolver registered earlier (#4756 per-user\n bindings, `./resolver`) or to core's built-in config resolution. No aliases and no chain\n targets means no change in behavior. `browser-safe.test.ts` holds the graph\n free of `node:`, the AI SDK and smrt-config by walking its import graph;\n the bundle-gate browser fixture also builds it (the package has a model).\n- `./node`: `checkInferenceBindings()`, `probeInferenceCandidate()`,\n `inferenceProbeUrl()`, `formatInferenceDoctorReport()`; the CLI's\n `doctor --ai` and #4754's test connection call these. Also hosted\n provisioning (`src/hosted.ts`, #4759).\n- `./resolver` (Node-only, #4756): `createUserInferenceResolver()` and\n `registerUserInferenceResolver()` over smrt-secrets / tenancy / users. The\n root re-exports only the browser-safe stored-config shape\n (`src/provider-config.ts`): parse, redact, tier → target map.\n- `./models` (browser-safe, held by `browser-safe.test.ts` and the\n bundle-gate browser fixture): the `_smrt_inference_overrides` model;\n generated consumer registration imports it from here.\n- `./server` (Node-only): settings service, override service, override\n resolver, key rule, preference kind (#4754); local CLI turns, ChatGPT model\n rounds and connection diagnostics ([agents/engines.md](agents/engines.md)).\n `./svelte`: the panel.\n- `./test-support` (Node-only): shared fake CLI installers and isolated lookup\n dependencies for engine/host tests; fixture source is bundled, never run on\n real credentials ([agents/engines.md](agents/engines.md)).\n- `./gate` (Node-only, #4760): the hosted spend gate and kill switch\n (below). `browser-safe.test.ts` keeps it off the root graph.\n\n## Per-user and per-tenant bindings (#4756)\n\n`createUserInferenceResolver()` resolves per tier: the user's stored config,\nthe tenant's, `fallback`, the app `inference` block, then the configured\nclient; every resolution carries `target.source` (`byo | local | hosted |\napp`, the `source` usage tag). Keys live only in the smrt-secrets type\n`inference.provider-config` (`context = tenantId`), every stored binding is\nself-contained (own `baseUrl` + `apiKey`, or a preset), the user layer\napplies only to a principal of that tenant, and agents pass `userId: null`\n(tenant layer only). The stored config also carries `mode` (#4757).\nDetails: [agents/resolver.md](agents/resolver.md).\n\n## Resolver composition\n\nOne resolver is registered, outermost first: the #4752 validating wrapper,\nthe #4756 user resolver, its `fallback`, then core's config resolution.\nHosts using the #4754 override table pass\n`createInferenceOverrideResolver({ db })` as that `fallback`:\n`registerUserInferenceResolver(createUserInferenceResolver({ db, fallback:\ncreateInferenceOverrideResolver({ db }) }))`. Order per tier: user stored\nbinding, tenant stored binding, allowed tenant override row, app override\nrow, `inference` config, configured client. Keys are stored once, in\n`inference.provider-config`: the host turns #4754's origin-bound\n`bindInferenceKey()` record into a self-contained binding with\n`inferenceProviderConfigFromKey(record, { model })` and writes it through\nthe user resolver's `write(level, config)`; never a second secret type.\n\n## Hosted inference (#4759, #4760)\n\n`./node` provisions per-user gateway keys through `ai.admin` of the\n`bifrost` / `litellm` provider (`SMRT_INFERENCE_HOSTED_*`, read once), storing\nthe key only in the user's `inference.provider-config` (`source: 'hosted'`).\nPlan changes update the key budget, revoke ends local use and then deletes the\nkey (failures are owed and retried by reconcile), and the tenant project is\nlooked up before one is created (`@happyvertical/ai` >= 0.111.7). `./gate`'s\n`registerHostedInferenceGate({ killSwitch, spend })` is core's\n`InferenceGate`: kill switch `inference.hosted.enabled` (a global DISABLE\nalways wins), tenant, entitlement, then plan spend caps; a block throws\n`InferenceUnavailableError` (`entitlement`) and writes a `blocked` usage row.\nDetails: [agents/hosted.md](agents/hosted.md).\n\n## Sign in with ChatGPT (`src/chatgpt/`, `./server`)\n\nLocal profile only; a PREVIEW for open source apps\n([limitations](https://developers.openai.com/siwc/token-sharing-open-source/preview-limitations)).\n`createChatGPTPlanConnection({ appName, credentialsPath })` wraps the SDK's\n`LocalChatGPTSessionManager` (`@happyvertical/auth/local`, loaded lazily): the\nSDK's own owner-only file at `credentialsPath` is the only credential store;\nsmrt never reads it, and no result, log or error carries a token (status is\n`signedIn`, `signingIn`, an account label, a fixed-vocabulary error;\n`clientOptions()` hands the provider `{ accessToken }` only). `start()` returns\nthe URL only after checking https on `auth.openai.com`. The resolver\n(`createChatGPTPlanResolver`, composed outside the user resolver by\n`createInferenceSettingsHost({ chatgptPlan })`) answers only calls whose\n`appliesTo` is true: `chatgpt-plan` with `source: 'byo'` when signed in,\n`unavailable: 'unconfigured'` otherwise, never an API-key fallback, never a\ndefault. The provider rejects `maxTokens`, sampling, `user`, response formats,\nreasoning, forced single-function `toolChoice` and `stream()` with tools; the\ncaller sends none of them (`classifyChatGPTPlanFailure` names the failures).\nGuide: [docs/content/inference-settings.md](../../docs/content/inference-settings.md).\n\nWhich model answers an engine that is not an API key (its default tier\nbinding), reasoning effort and the plan-refusal step:\n[agents/engines.md](agents/engines.md) (#5005).\n\n## Config\n\n```ts\nconfig({ inference: {\n aliases: { frontier: { candidates: [\n { provider: 'anthropic', model: 'claude-…' }, // provider key var\n { provider: 'openai', model: 'gpt-…', baseUrl, apiKeyEnv }, // own key + endpoint\n { preset: 'lemonade', model: 'qwen…' }, // #4674 preset\n { alias: 'local' }, // expanded in place\n ] } },\n tiers: { great: { alias: 'frontier' }, cheap: { candidates: [ … ] } },\n degrade: true, // default\n} });\n```\n\nA candidate is exactly one of provider/model, preset/model, or alias.\n`apiKeyEnv` is read at call time and needs a `baseUrl` (core's pair rule: a\nkey only travels with its own endpoint); a named variable that is unset skips\nthe candidate as `credential`. `findInferenceConfigIssues()` /\n`validateInferenceConfig()` name every offender by path: empty alias, unknown\nalias (tier or nested), cycle, key without endpoint, unknown preset. The\nexecutor also validates every resolved target it runs (a resolver's chains\nnever pass through config), and a candidate key is never dropped: without\nits own `baseUrl` core's pair rule refuses it.\n\n## Executor (`src/executor.ts`)\n\n- Free of SDK imports: it drives the clients core builds through\n `context.clientFor(target)`; tests use fake clients.\n- Failure classes (`classify.ts`): `quota | credential | missing-model |\n transient | refusal | missing-capability`, from error class names, `code`, `retryable` and HTTP\n status across `cause` / `error` / `context.originalError`, never message\n text. The SDK maps 5xx and other HTTP failures to `API_ERROR` /\n `UNKNOWN_ERROR` without a status or cause (happyvertical/sdk#1493); those\n count as `transient`. A definitive client error that survives in the chain\n (other 4xx, `invalid_request_error`, context length) is not a routing\n failure. Core's typed bind refusal (`INFERENCE_TARGET_UNBOUND`: pair rule,\n `HAVE_AI_*`) is `credential` and advances. Aborts and unclassified errors stop the walk and are rethrown (an\n unclassified one is still recorded).\n- `transient` retries the same candidate once after 200–500 ms of jitter;\n every class then advances. A `refusal` finish reason with nothing streamed\n also advances; finish callbacks are replayed only for the kept answer.\n- Streamed text is never extended: a candidate that emitted text and then\n failed ends the walk with a `partial` substitution and\n `InferenceExhaustedError` (`reason: 'partial'`, `partialText`), unless\n `allowPartial` returns the text. A hosted-gate block (`AI_UNAVAILABLE`\n from `clientFor()`, #4760) stops the walk and records nothing (core wrote\n the `blocked` row). A step whose target names a `source` (a ladder step's\n resolved binding) records that source over the chain's, so hosted spend\n meters as hosted; `expandTarget()` hands a chain's own `source` to its\n candidate steps, so a hosted chain reached on a ladder step is gated in\n `clientFor()` and meters as hosted too. A `stream()` consumer that stops reading\n aborts the provider stream (internal signal merged with the caller's).\n- Ladder: when a tier's chain is spent and `degrade !== false`, resolve the\n next lower tier through `context.resolveTier()`, stopping below\n `minimumTier`. Never up. Steps already tried (same identity) are skipped,\n so unbound lower tiers try the configured client once.\n- Tags on the answering call: caller tags, `tierRequested`, `tierResolved`\n (the tier that answered), and `substitutions` (JSON array of\n `{ from, to, reason }`, labels `provider/model`, `preset:<id>/model`,\n `default`). A call that never answered records one zero-token row through\n `context.recordUsage()` (core's usage handlers; no second writer) with\n `outcome: failed | partial`, `reason` and the full trail ending `to: null` (reason `unclassified` when a non-routing error ended it),\n then throws `InferenceExhaustedError` (`INFERENCE_EXHAUSTED`).\n- Capabilities (#4758): before calling a candidate, a call that sends\n `responseFormat` (JSON) or `tools` checks `context.capabilitiesFor(target)`\n (core's detection, [inference.md](../core/agents/inference.md)). A\n mismatch the caller's `capabilityFallback` option permits (`json: 'text'`,\n `tools: 'drop'`) runs the candidate without the feature, tagged\n `capabilityFallback`; any other is a `missing-capability` substitution and\n the walk advances with no model call. The option never reaches a provider.\n Core's `InferenceUnavailableError` (`reason: 'capability'`) also classifies\n as `missing-capability`. No detector (older core) or no requirement: no\n check. Context limits are core's (single targets only).\n- Add a class to `INFERENCE_FAILURE_CLASSES` and a kind to `EXECUTOR_KINDS`\n (`createChainExecutor()` in `fusion.ts` dispatches on it); consumers\n ignore kinds they do not run.\n\n## Fusions (#4753)\n\n`{ fusion: '<key>' }` tier targets run consumer-defined fusions (`single` 1\ncall, `pair` 3, `handoff` 2) from, highest first, the resolver's stored app\nrows (core's `lookupFusion()`, #4800), `inference.fusions`, or\n`defineFusion()`; every source is re-validated before it runs. SMRT ships the interpreter, never a fusion. Seats are\nsmrt-prompts keys run through `createChainClient()`; a dead seat never\naborts a `pair`, all seats dead throws `InferenceFusionError`; each run writes\none `_smrt_ai_runs` row. Fusions are defined at app scope only; a tenant\nmay bind a tier to an allow-listed fusion, never define one. Details:\n[agents/fusions.md](agents/fusions.md).\n\n## Doctor (`src/node.ts`)\n\nPer tier, alias and fusion (structure only): provider recognized (AI SDK provider list or preset id),\nkey variable present (a provider's default variable only warns: a\nsame-provider target inherits the configured key), model named (warns),\nalias resolvable, cycle-free. `probe` GETs `/models` (OpenAI-compatible,\nAnthropic, Gemini) or Ollama `/api/tags` with a 3 s timeout, sending the key\nonly to its own endpoint. A binding errors when its config is invalid or no\ncandidate can answer; one bad candidate in a working chain warns. Keys never\nappear in the report. With `probe` each candidate also reports its\ncapabilities and their source (#4758, `formatInferenceCapabilities()`): the\nlisting's context length, `supported_parameters` and input modalities\n(`inferenceCapabilitiesFromModelListing()`) are the `probe` layer; the SDK\n`provider` layer only through the `sdkCapabilities` option (the doctor builds\nno SDK clients).\n\n## Settings UI and binding storage (#4754)\n\n`./svelte` `InferenceSettingsPanel`, `./server` `InferenceSettingsService` /\n`InferenceOverrideService` / `createInferenceOverrideResolver()`, `./models`\nthe `_smrt_inference_overrides` model (ships through `smrt db:migrate`).\nKeys go to smrt-secrets through the host and are bound to their endpoint's\norigin; user choices are the smrt-preferences kind `inference`; app/tenant\nbindings are override rows, tenants limited to the app row's allow-list and\nthe `tenantTargetPolicy` hook. The app's transcript setting (#4781) is the\napp-only `transcripts` row, editable in the panel only with `appEditable`,\napplied as core's transcript app settings layer; the Usage tab shows\ntranscript counts and links to a host route, never content. Details: [agents/settings.md](agents/settings.md),\nconsumer guide [docs/content/inference-settings.md](../../docs/content/inference-settings.md).\n`./server` also ships the framework-free host wiring both the template and\nthe app shell use: `createInferenceSettingsHost` (secret store under the\nruntime's master key, user resolver over the override resolver, settings\nservice with its authorizer), `createInferenceSettingsController` (the\npanel's `load` and writes, gated on `inference.customize`; a refusal and a\nkey-origin error name no key), and `saveInferenceKey` / `inferenceKeyIsSet`.\nA host supplies only its session check, preference store and routes.\n\n## Validation\n\n```bash\npnpm --filter @happyvertical/smrt-inference test\npnpm --filter @happyvertical/smrt-inference test:postgres # hosted provisioning on PostgreSQL (advisory lock, runOnce)\npnpm --filter @happyvertical/smrt-inference typecheck\npnpm --filter @happyvertical/smrt-inference build\n```\n\n`./i18n/catalog` is a pure-data inventory of registered interface strings, generated\nwith `node scripts/generate-message-catalogs.mjs inference`. It may be empty until\nthe package's interface strings are adopted; it never imports components.\n",
|
|
313
316
|
"moduleDocs": [
|
|
314
317
|
{
|
|
315
318
|
"path": "agents/engines.md",
|
|
@@ -334,7 +337,7 @@
|
|
|
334
337
|
{
|
|
335
338
|
"path": "agents/settings.md",
|
|
336
339
|
"module": "settings",
|
|
337
|
-
"content": "# Settings UI and binding storage (#4754)\n\nConsumer guide: [docs/content/inference-settings.md](../../../docs/content/inference-settings.md).\n\n- **Storage split, enforced by API shape.** Keys: the panel emits\n `onSaveKey({ provider, key, preset?, baseUrl? })` (the endpoint shown when\n the key was typed; the key input remounts on a provider or base URL\n change), the host binds it with `bindInferenceKey()` and stores it once,\n as the #4756 `inference.provider-config` secret, through the user\n resolver's `write()` (`inferenceProviderConfigFromKey()` converts the\n record and re-checks the bound origin), and the panel only ever gets\n `keySet` back. User choices (mode `byo | local | hosted |\n off`, provider, base URL, model, default tier): smrt-preferences kind\n `inference` (`inferencePreferenceKind`, permissions `inference.customize`\n / `inference.personalize`; the host registers both, smrt-preferences is\n not a dependency). App/tenant bindings: `_smrt_inference_overrides`.\n- **Key rule** (`src/settings/keys.ts`, ported from the planner's BYO\n screen): a key is bound when saved to the origin of its endpoint\n (explicit base URL, else preset, else `inferenceProbeUrl()`'s provider\n default, a provider id that is a preset id counting as that preset;\n https only, plain http for loopback; gateways such as\n `litellm`/`bifrost` need a base URL) and `inferenceKeyFor()` releases it\n only for a URL on that origin. `testConnection()` reads no environment key\n and never probes another origin with a stored key; details pass\n `redactInferenceSecret()`. Binding rows, preference payloads and tested\n candidates refuse credential-shaped members (`findKeyMember()`; `key` is\n allowed because #4753 fusions carry one).\n- **Override table**: one row per `(binding, context)`, binding\n `tier:<tier> | default-tier | alias:<name> | fusion:<name>`, `context`\n `__app__` or the tenant id (the prompts pattern), `target` JSON,\n `tenant_allow_list` JSON on app rows. Generated surfaces are closed; ships\n through `smrt db:migrate` (`override-migration.test.ts`). A tier target is\n exactly a model `{ provider?, model }`, an alias `{ alias }` or a fusion\n `{ kind: 'fusion', fusion }`: no endpoint, key or inline chain (those go\n in an alias). Layers, low to high: code default (configured client),\n `inference` config, app row, tenant row; each target replaced whole.\n- **Tenant allow-list**: a tenant writes only `tier:*` and `default-tier`,\n only to a reference (`model:<provider>/<model>`, `alias:<n>`,\n `fusion:<n>`, `tier:<t>`; trailing `*` and `*` match) on the app row's\n list (no list allows nothing), and only when the\n `tenantTargetPolicy` hook returns `true`; this hook is where #4667 caps\n the maximum hosted tier. Both are re-checked on every layered read, so a\n narrowed list or policy disables existing tenant rows (`tenantBlocked`).\n Aliases and fusions are app-scope only (a tenant definition could\n redefine an allow-listed name).\n- **`InferenceSettingsService`** mirrors `PromptSettingsService`:\n `listInferenceSettings()` returns one row per tier with the effective\n target, each scope's raw value and both revert previews computed\n separately (`appRevertTarget` = config, never the app row;\n `inheritedTarget` = config + app row), plus `getDefaultTierSetting()`,\n `listInferenceAliases()`, `listInferenceFusions()` (registry: the\n `registryFusions` option, default #4753's `defineFusion()` registry;\n config `inference.fusions`; editable app rows), each entry with\n `shadows` (lower sources it replaces by name) and `issues` (what would make\n the executor refuse it, prompt keys included), the executor's precedence\n (#4800). `setFusion()` refuses credential members, then a definition that\n adds a structural issue. Writes go through `InferenceOverrideService`\n (authorizer first, fails closed; without `authorize` the service is\n read-only) and refuse a value that adds a config issue to the layer it\n lands in; removing an app alias or fusion that any row (every tenant) or\n config still names is refused (`InferenceBindingInUseError`, tenant rows\n only counted, checked after the authorizer allowed the write) unless\n config or the registry keeps defining it. Every config-backed value a row method\n returns passes `stripKeyMembers()` (config may carry literal keys);\n `getEffectiveConfig()` is server-side only. `testConnection()`, `testCandidate()` and `doctor()` reuse\n `./node`; `testCandidate()` reads a key variable only for a candidate\n already in the effective config (an unsaved one is probed keyless);\n `usage()` is `reportAiUsage()` by model (default), tier, prompt, fusion,\n template, with `transcripts: true` for per-bucket counts (#4781).\n- **Transcript setting** (#4781, `src/settings/transcripts.ts`): binding\n `transcripts`, app row only (service and model refuse a tenant row),\n value `{ enabled?, sample?, maxBytes? }` checked by core's\n `assertInferenceTranscriptsConfig()`. `setTranscriptSettings()` writes it\n through the authorizer and installs it as core's\n `setAiTranscriptAppSettings()` layer (config < app row < env); the\n override resolver re-applies the app rows on every resolve (rows cached\n for `ttlMs`), `loadInferenceTranscriptSettings()` is the worker startup\n hook. `getTranscriptSettings()` adds the revert preview, the env override\n (detected by forcing both values through the layer) and the sweep's\n retention days, read-only (the sweep runs with its caller's policy).\n- **`createInferenceOverrideResolver({ db, base })`** applies stored\n bindings at call time and defers unbound tiers to `base` or config; an\n app-only alias is returned as its inline candidate chain because the\n executor reads only the process config. Rows (not layers) are cached per\n tenant for `ttlMs` (30 s) and invalidated by any write in the process; the\n allow-list and policy are re-applied on every call, and only the requested\n tier's chain is validated, so one dangling reference fails one tier.\n Compose it as the per-user resolver's `fallback` (see AGENTS.md,\n \"Resolver composition\"). Its `lookupFusion()` (#4800) answers core's\n executor lookup from app rows only (read with no tenant, so a tenant row\n never defines a fusion), validated against config + app rows with every\n seat prompt key (`InferenceConfigError`, paths `fusion:<name>…`), app-only\n seat aliases inlined like tier aliases; an app row that exists but cannot\n be read fails `fusion-invalid` (never its value) rather than deferring (the\n list shows it as the app winner with that issue); no app row defers to\n `base`, then config. An app row shadows a config fusion of the same name.\n- **Panel** (`src/svelte`): built like `PromptSettingsPanel` (presentational,\n `svelte` optional peer, prune script, two-project Vitest, `svelte-check`,\n named `$props()` interfaces, types free of core). The default view is the\n whole screen for one provider; Advanced (tier ladder, `auto` tier,\n aliases, fusions) is not rendered until opened. The key input is its own\n form, never in state, cleared on submit. Tenant scope disables targets\n off the allow-list (display only) and makes aliases/fusions read-only.\n Rows remount on `contextKey`. The transcript section is read-only unless\n `appEditable` and `onSaveTranscripts` are both passed; the Usage tab\n links counts through the host's `transcriptHref` and renders no\n transcript content (#4781).\n"
|
|
340
|
+
"content": "# Settings UI and binding storage (#4754)\n\nConsumer guide: [docs/content/inference-settings.md](../../../docs/content/inference-settings.md).\n\n- **Storage split, enforced by API shape.** Keys: the panel emits\n `onSaveKey({ provider, key, preset?, baseUrl? })` (the endpoint shown when\n the key was typed; the key input remounts on a provider or base URL\n change), the host binds it with `bindInferenceKey()` and stores it once,\n as the #4756 `inference.provider-config` secret, through the user\n resolver's `write()` (`inferenceProviderConfigFromKey()` converts the\n record and re-checks the bound origin), and the panel only ever gets\n `keySet` back. User choices (mode `byo | local | hosted |\n off`, provider, base URL, model, default tier): smrt-preferences kind\n `inference` (`inferencePreferenceKind`, permissions `inference.customize`\n / `inference.personalize`; the host registers both, smrt-preferences is\n not a dependency). App/tenant bindings: `_smrt_inference_overrides`.\n- **Key rule** (`src/settings/keys.ts`, ported from the planner's BYO\n screen): a key is bound when saved to the origin of its endpoint\n (explicit base URL, else preset, else `inferenceProbeUrl()`'s provider\n default, a provider id that is a preset id counting as that preset;\n https only, plain http for loopback; gateways such as\n `litellm`/`bifrost` need a base URL) and `inferenceKeyFor()` releases it\n only for a URL on that origin. `testConnection()` reads no environment key\n and never probes another origin with a stored key; details pass\n `redactInferenceSecret()`. Binding rows, preference payloads and tested\n candidates refuse credential-shaped members (`findKeyMember()`; `key` is\n allowed because #4753 fusions carry one).\n- **Override table**: one row per `(binding, context)`, binding\n `tier:<tier> | default-tier | alias:<name> | fusion:<name>`, `context`\n `__app__` or the tenant id (the prompts pattern), `target` JSON,\n `tenant_allow_list` JSON on app rows. Generated surfaces are closed; ships\n through `smrt db:migrate` (`override-migration.test.ts`). A tier target is\n exactly a model `{ provider?, model }`, an alias `{ alias }` or a fusion\n `{ kind: 'fusion', fusion }`: no endpoint, key or inline chain (those go\n in an alias). Layers, low to high: code default (configured client),\n `inference` config, app row, tenant row; each target replaced whole.\n- **Tenant allow-list**: a tenant writes only `tier:*` and `default-tier`,\n only to a reference (`model:<provider>/<model>`, `alias:<n>`,\n `fusion:<n>`, `tier:<t>`; trailing `*` and `*` match) on the app row's\n list (no list allows nothing), and only when the\n `tenantTargetPolicy` hook returns `true`; this hook is where #4667 caps\n the maximum hosted tier. Both are re-checked on every layered read, so a\n narrowed list or policy disables existing tenant rows (`tenantBlocked`).\n Aliases and fusions are app-scope only (a tenant definition could\n redefine an allow-listed name).\n- **`InferenceSettingsService`** mirrors `PromptSettingsService`:\n `listInferenceSettings()` returns one row per tier with the effective\n target, each scope's raw value and both revert previews computed\n separately (`appRevertTarget` = config, never the app row;\n `inheritedTarget` = config + app row), plus `getDefaultTierSetting()`,\n `listInferenceAliases()`, `listInferenceFusions()` (registry: the\n `registryFusions` option, default #4753's `defineFusion()` registry;\n config `inference.fusions`; editable app rows), each entry with\n `shadows` (lower sources it replaces by name) and `issues` (what would make\n the executor refuse it, prompt keys included), the executor's precedence\n (#4800). `setFusion()` refuses credential members, then a definition that\n adds a structural issue. Writes go through `InferenceOverrideService`\n (authorizer first, fails closed; without `authorize` the service is\n read-only) and refuse a value that adds a config issue to the layer it\n lands in; removing an app alias or fusion that any row (every tenant) or\n config still names is refused (`InferenceBindingInUseError`, tenant rows\n only counted, checked after the authorizer allowed the write) unless\n config or the registry keeps defining it. Every config-backed value a row method\n returns passes `stripKeyMembers()` (config may carry literal keys);\n `getEffectiveConfig()` is server-side only. `testConnection()`, `testCandidate()` and `doctor()` reuse\n `./node`; `testCandidate()` reads a key variable only for a candidate\n already in the effective config (an unsaved one is probed keyless);\n `usage()` is `reportAiUsage()` by model (default), tier, prompt, fusion,\n template, with `transcripts: true` for per-bucket counts (#4781).\n- **Transcript setting** (#4781, `src/settings/transcripts.ts`): binding\n `transcripts`, app row only (service and model refuse a tenant row),\n value `{ enabled?, sample?, maxBytes? }` checked by core's\n `assertInferenceTranscriptsConfig()`. `setTranscriptSettings()` writes it\n through the authorizer and installs it as core's\n `setAiTranscriptAppSettings()` layer (config < app row < env); the\n override resolver re-applies the app rows on every resolve (rows cached\n for `ttlMs`), `loadInferenceTranscriptSettings()` is the worker startup\n hook. `getTranscriptSettings()` adds the revert preview, the env override\n (detected by forcing both values through the layer) and the sweep's\n retention days, read-only (the sweep runs with its caller's policy).\n- **`createInferenceOverrideResolver({ db, base })`** applies stored\n bindings at call time and defers unbound tiers to `base` or config; an\n app-only alias is returned as its inline candidate chain because the\n executor reads only the process config. Rows (not layers) are cached per\n tenant for `ttlMs` (30 s) and invalidated by any write in the process; the\n allow-list and policy are re-applied on every call, and only the requested\n tier's chain is validated, so one dangling reference fails one tier.\n Compose it as the per-user resolver's `fallback` (see AGENTS.md,\n \"Resolver composition\"). Its `lookupFusion()` (#4800) answers core's\n executor lookup from app rows only (read with no tenant, so a tenant row\n never defines a fusion), validated against config + app rows with every\n seat prompt key (`InferenceConfigError`, paths `fusion:<name>…`), app-only\n seat aliases inlined like tier aliases; an app row that exists but cannot\n be read fails `fusion-invalid` (never its value) rather than deferring (the\n list shows it as the app winner with that issue); no app row defers to\n `base`, then config. An app row shadows a config fusion of the same name.\n- **Panel** (`src/svelte`): built like `PromptSettingsPanel` (presentational,\n `svelte` optional peer, prune script, two-project Vitest, `svelte-check`,\n named `$props()` interfaces, types free of core). The default view is the\n whole screen for one provider; Advanced (tier ladder, `auto` tier,\n aliases, fusions) is not rendered until opened. The key input is its own\n form, never in state, cleared on submit. Tenant scope disables targets\n off the allow-list (display only) and makes aliases/fusions read-only.\n Rows remount on `contextKey`. The transcript section is read-only unless\n `appEditable` and `onSaveTranscripts` are both passed; the Usage tab\n links counts through the host's `transcriptHref` and renders no\n transcript content (#4781).\n- **Recorded history/compare** (#5055): `history()` and `compare()` wrap core's\n scoped historical readers; no prompt execution. Controller reads require\n `inference.customize`, derive tenant scope from the host session and refuse\n scope fields in JSON. The Usage tab's `onHistory`/`onCompare` callbacks load\n the closed HTTP/MCP request contract; history can fill two hash selectors.\n Comparison references pass exact `callId` plus prompt/window through the\n existing `transcriptHref` callback. Built-in hosts expose matching HTTP/MCP\n reads and an audited, same-tenant transcript destination.\n\nThe recorded history component registers its complete interface messages in\n`src/svelte/history.messages.ts` and reads the host i18n snapshot. Its English\ndefaults are included in the pure `./i18n/catalog` inventory; regenerate with\n`node scripts/generate-message-catalogs.mjs inference` after copy changes.\n"
|
|
338
341
|
}
|
|
339
342
|
],
|
|
340
343
|
"browser": {
|