@mlightcad/cad-llm-plugin 0.0.0-stage → 1.8.0-preview.5
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/LICENSE +21 -0
- package/README.md +70 -2
- package/dist/cad-llm-plugin-register.js +613 -0
- package/dist/cad-llm-plugin-register.umd.cjs +1 -0
- package/dist/cad-llm-plugin.js +21481 -0
- package/dist/cad-llm-plugin.umd.cjs +514 -0
- package/lib/AcApLlmPlugin.d.ts +39 -0
- package/lib/AcApLlmPlugin.d.ts.map +1 -0
- package/lib/AcApLlmPlugin.js +119 -0
- package/lib/AcApLlmPlugin.js.map +1 -0
- package/lib/AcApLlmTextRecognizer.d.ts +43 -0
- package/lib/AcApLlmTextRecognizer.d.ts.map +1 -0
- package/lib/AcApLlmTextRecognizer.js +303 -0
- package/lib/AcApLlmTextRecognizer.js.map +1 -0
- package/lib/command/AcApLlmSettingsCmd.d.ts +16 -0
- package/lib/command/AcApLlmSettingsCmd.d.ts.map +1 -0
- package/lib/command/AcApLlmSettingsCmd.js +114 -0
- package/lib/command/AcApLlmSettingsCmd.js.map +1 -0
- package/lib/constants.d.ts +7 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +7 -0
- package/lib/constants.js.map +1 -0
- package/lib/i18n/ar.d.ts +77 -0
- package/lib/i18n/ar.d.ts.map +1 -0
- package/lib/i18n/ar.js +77 -0
- package/lib/i18n/ar.js.map +1 -0
- package/lib/i18n/command.d.ts +30 -0
- package/lib/i18n/command.d.ts.map +1 -0
- package/lib/i18n/command.js +30 -0
- package/lib/i18n/command.js.map +1 -0
- package/lib/i18n/cs.d.ts +77 -0
- package/lib/i18n/cs.d.ts.map +1 -0
- package/lib/i18n/cs.js +77 -0
- package/lib/i18n/cs.js.map +1 -0
- package/lib/i18n/en.d.ts +82 -0
- package/lib/i18n/en.d.ts.map +1 -0
- package/lib/i18n/en.js +82 -0
- package/lib/i18n/en.js.map +1 -0
- package/lib/i18n/index.d.ts +29 -0
- package/lib/i18n/index.d.ts.map +1 -0
- package/lib/i18n/index.js +142 -0
- package/lib/i18n/index.js.map +1 -0
- package/lib/i18n/ja.d.ts +77 -0
- package/lib/i18n/ja.d.ts.map +1 -0
- package/lib/i18n/ja.js +77 -0
- package/lib/i18n/ja.js.map +1 -0
- package/lib/i18n/ko.d.ts +77 -0
- package/lib/i18n/ko.d.ts.map +1 -0
- package/lib/i18n/ko.js +77 -0
- package/lib/i18n/ko.js.map +1 -0
- package/lib/i18n/tr.d.ts +77 -0
- package/lib/i18n/tr.d.ts.map +1 -0
- package/lib/i18n/tr.js +77 -0
- package/lib/i18n/tr.js.map +1 -0
- package/lib/i18n/zh.d.ts +77 -0
- package/lib/i18n/zh.d.ts.map +1 -0
- package/lib/i18n/zh.js +77 -0
- package/lib/i18n/zh.js.map +1 -0
- package/lib/index.d.ts +25 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +25 -0
- package/lib/index.js.map +1 -0
- package/lib/model/AcApLlmModelFactory.d.ts +14 -0
- package/lib/model/AcApLlmModelFactory.d.ts.map +1 -0
- package/lib/model/AcApLlmModelFactory.js +46 -0
- package/lib/model/AcApLlmModelFactory.js.map +1 -0
- package/lib/model/AcApLlmModelListing.d.ts +67 -0
- package/lib/model/AcApLlmModelListing.d.ts.map +1 -0
- package/lib/model/AcApLlmModelListing.js +275 -0
- package/lib/model/AcApLlmModelListing.js.map +1 -0
- package/lib/model/anthropicBrowserAccess.d.ts +8 -0
- package/lib/model/anthropicBrowserAccess.d.ts.map +1 -0
- package/lib/model/anthropicBrowserAccess.js +8 -0
- package/lib/model/anthropicBrowserAccess.js.map +1 -0
- package/lib/model/normalizeLlmBaseUrl.d.ts +17 -0
- package/lib/model/normalizeLlmBaseUrl.d.ts.map +1 -0
- package/lib/model/normalizeLlmBaseUrl.js +31 -0
- package/lib/model/normalizeLlmBaseUrl.js.map +1 -0
- package/lib/model/openAiCompatibleFetch.d.ts +11 -0
- package/lib/model/openAiCompatibleFetch.d.ts.map +1 -0
- package/lib/model/openAiCompatibleFetch.js +122 -0
- package/lib/model/openAiCompatibleFetch.js.map +1 -0
- package/lib/model/skipDataUrlDownload.d.ts +12 -0
- package/lib/model/skipDataUrlDownload.d.ts.map +1 -0
- package/lib/model/skipDataUrlDownload.js +58 -0
- package/lib/model/skipDataUrlDownload.js.map +1 -0
- package/lib/register.d.ts +20 -0
- package/lib/register.d.ts.map +1 -0
- package/lib/register.js +139 -0
- package/lib/register.js.map +1 -0
- package/lib/storage/AcApLlmConfigStore.d.ts +218 -0
- package/lib/storage/AcApLlmConfigStore.d.ts.map +1 -0
- package/lib/storage/AcApLlmConfigStore.js +637 -0
- package/lib/storage/AcApLlmConfigStore.js.map +1 -0
- package/lib/storage/AcApLlmModelCatalog.d.ts +68 -0
- package/lib/storage/AcApLlmModelCatalog.d.ts.map +1 -0
- package/lib/storage/AcApLlmModelCatalog.js +141 -0
- package/lib/storage/AcApLlmModelCatalog.js.map +1 -0
- package/lib/storage/apiKeyCrypto.d.ts +28 -0
- package/lib/storage/apiKeyCrypto.d.ts.map +1 -0
- package/lib/storage/apiKeyCrypto.js +214 -0
- package/lib/storage/apiKeyCrypto.js.map +1 -0
- package/lib/storage/settingsEquality.d.ts +10 -0
- package/lib/storage/settingsEquality.d.ts.map +1 -0
- package/lib/storage/settingsEquality.js +36 -0
- package/lib/storage/settingsEquality.js.map +1 -0
- package/lib/ui/AcApLlmModelChoices.d.ts +31 -0
- package/lib/ui/AcApLlmModelChoices.d.ts.map +1 -0
- package/lib/ui/AcApLlmModelChoices.js +68 -0
- package/lib/ui/AcApLlmModelChoices.js.map +1 -0
- package/lib/ui/AcApLlmProviderLabels.d.ts +19 -0
- package/lib/ui/AcApLlmProviderLabels.d.ts.map +1 -0
- package/lib/ui/AcApLlmProviderLabels.js +34 -0
- package/lib/ui/AcApLlmProviderLabels.js.map +1 -0
- package/lib/ui/AcUiLlmSettingsDialog.d.ts +125 -0
- package/lib/ui/AcUiLlmSettingsDialog.d.ts.map +1 -0
- package/lib/ui/AcUiLlmSettingsDialog.js +1218 -0
- package/lib/ui/AcUiLlmSettingsDialog.js.map +1 -0
- package/lib/ui/llmSettingsStyles.d.ts +6 -0
- package/lib/ui/llmSettingsStyles.d.ts.map +1 -0
- package/lib/ui/llmSettingsStyles.js +6 -0
- package/lib/ui/llmSettingsStyles.js.map +1 -0
- package/package.json +54 -3
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __values = (this && this.__values) || function(o) {
|
|
49
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
50
|
+
if (m) return m.call(o);
|
|
51
|
+
if (o && typeof o.length === "number") return {
|
|
52
|
+
next: function () {
|
|
53
|
+
if (o && i >= o.length) o = void 0;
|
|
54
|
+
return { value: o && o[i++], done: !o };
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
58
|
+
};
|
|
59
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
60
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
61
|
+
if (!m) return o;
|
|
62
|
+
var i = m.call(o), r, ar = [], e;
|
|
63
|
+
try {
|
|
64
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
65
|
+
}
|
|
66
|
+
catch (error) { e = { error: error }; }
|
|
67
|
+
finally {
|
|
68
|
+
try {
|
|
69
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
70
|
+
}
|
|
71
|
+
finally { if (e) throw e.error; }
|
|
72
|
+
}
|
|
73
|
+
return ar;
|
|
74
|
+
};
|
|
75
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
76
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
77
|
+
if (ar || !(i in from)) {
|
|
78
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
79
|
+
ar[i] = from[i];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
83
|
+
};
|
|
84
|
+
import { ACAP_LLM_BUILTIN_PROVIDERS, acapLlmGuessModelVision, acapLlmIsBuiltinProviderId } from './AcApLlmModelCatalog.js';
|
|
85
|
+
import { decryptApiKey, encryptApiKey } from './apiKeyCrypto.js';
|
|
86
|
+
/** `localStorage` key for the serialized {@link AcApLlmConfig}. */
|
|
87
|
+
var STORAGE_KEY = 'cad-agent-plugin.llm-config';
|
|
88
|
+
/** `localStorage` key of the single-provider settings it replaces. */
|
|
89
|
+
var LEGACY_STORAGE_KEY = 'cad-agent-plugin.llm-settings';
|
|
90
|
+
/** Provider used for chat before the user configures anything. */
|
|
91
|
+
var DEFAULT_PROVIDER = 'deepseek';
|
|
92
|
+
/**
|
|
93
|
+
* Lowercase slug a custom provider id must match. It starts with a letter so
|
|
94
|
+
* it can never collide with numeric keys and reads well in the model picker.
|
|
95
|
+
*/
|
|
96
|
+
export var ACAP_LLM_CUSTOM_PROVIDER_ID_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
97
|
+
/**
|
|
98
|
+
* Returns a config with no providers configured.
|
|
99
|
+
*
|
|
100
|
+
* @returns Fresh default config.
|
|
101
|
+
*/
|
|
102
|
+
export function acapLlmCreateDefaultConfig() {
|
|
103
|
+
return {
|
|
104
|
+
providers: [],
|
|
105
|
+
activeProviderId: DEFAULT_PROVIDER,
|
|
106
|
+
activeModel: ACAP_LLM_BUILTIN_PROVIDERS[DEFAULT_PROVIDER].models[0].id
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Creates an unconfigured built-in provider entry.
|
|
111
|
+
*
|
|
112
|
+
* @param id - Built-in provider id.
|
|
113
|
+
* @returns A provider with an empty key, default URL and default catalog.
|
|
114
|
+
*/
|
|
115
|
+
export function acapLlmCreateBuiltinProvider(id) {
|
|
116
|
+
return {
|
|
117
|
+
id: id,
|
|
118
|
+
kind: 'builtin',
|
|
119
|
+
protocol: ACAP_LLM_BUILTIN_PROVIDERS[id].protocol,
|
|
120
|
+
baseUrl: '',
|
|
121
|
+
apiKey: '',
|
|
122
|
+
models: null
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Creates an empty custom provider draft.
|
|
127
|
+
*
|
|
128
|
+
* @returns A custom provider with no id, URL, key or models.
|
|
129
|
+
*/
|
|
130
|
+
export function acapLlmCreateCustomProvider() {
|
|
131
|
+
return {
|
|
132
|
+
id: '',
|
|
133
|
+
kind: 'custom',
|
|
134
|
+
displayName: '',
|
|
135
|
+
protocol: 'openai-chat',
|
|
136
|
+
baseUrl: '',
|
|
137
|
+
apiKey: '',
|
|
138
|
+
models: []
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Looks up a provider in a config, falling back to an unconfigured built-in.
|
|
143
|
+
*
|
|
144
|
+
* @param config - Current config.
|
|
145
|
+
* @param id - Provider id.
|
|
146
|
+
* @returns The stored provider, a blank built-in entry, or `undefined` for an
|
|
147
|
+
* unknown custom id.
|
|
148
|
+
*/
|
|
149
|
+
export function acapLlmFindProvider(config, id) {
|
|
150
|
+
var stored = config.providers.find(function (provider) { return provider.id === id; });
|
|
151
|
+
if (stored)
|
|
152
|
+
return stored;
|
|
153
|
+
return acapLlmIsBuiltinProviderId(id)
|
|
154
|
+
? acapLlmCreateBuiltinProvider(id)
|
|
155
|
+
: undefined;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Returns the models a provider offers in the model selector.
|
|
159
|
+
*
|
|
160
|
+
* @param provider - Provider config.
|
|
161
|
+
* @returns The custom catalog, or the built-in defaults when not customized.
|
|
162
|
+
*/
|
|
163
|
+
export function acapLlmEffectiveModels(provider) {
|
|
164
|
+
if (provider.models)
|
|
165
|
+
return provider.models;
|
|
166
|
+
return provider.kind === 'builtin' && acapLlmIsBuiltinProviderId(provider.id)
|
|
167
|
+
? ACAP_LLM_BUILTIN_PROVIDERS[provider.id].models
|
|
168
|
+
: [];
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Returns the base URL requests are sent to.
|
|
172
|
+
*
|
|
173
|
+
* @param provider - Provider config.
|
|
174
|
+
* @returns The configured URL, or the built-in default when blank.
|
|
175
|
+
*/
|
|
176
|
+
export function acapLlmEffectiveBaseUrl(provider) {
|
|
177
|
+
var configured = provider.baseUrl.trim();
|
|
178
|
+
if (configured)
|
|
179
|
+
return configured;
|
|
180
|
+
return provider.kind === 'builtin' && acapLlmIsBuiltinProviderId(provider.id)
|
|
181
|
+
? ACAP_LLM_BUILTIN_PROVIDERS[provider.id].baseUrl
|
|
182
|
+
: '';
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Resolves the active provider and model into per-request settings.
|
|
186
|
+
*
|
|
187
|
+
* @param config - Current config.
|
|
188
|
+
* @returns Settings for the active model (empty key when unconfigured).
|
|
189
|
+
*/
|
|
190
|
+
export function acapLlmResolveActiveSettings(config) {
|
|
191
|
+
var _a;
|
|
192
|
+
var provider = (_a = acapLlmFindProvider(config, config.activeProviderId)) !== null && _a !== void 0 ? _a : acapLlmCreateBuiltinProvider(DEFAULT_PROVIDER);
|
|
193
|
+
return {
|
|
194
|
+
provider: provider.id,
|
|
195
|
+
kind: provider.kind,
|
|
196
|
+
protocol: provider.protocol,
|
|
197
|
+
apiKey: provider.apiKey,
|
|
198
|
+
baseUrl: acapLlmEffectiveBaseUrl(provider),
|
|
199
|
+
model: config.activeModel
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Determines whether the active model accepts image attachments.
|
|
204
|
+
*
|
|
205
|
+
* Uses the catalog entry when the model is listed, otherwise guesses from the
|
|
206
|
+
* model id.
|
|
207
|
+
*
|
|
208
|
+
* @param config - Current config.
|
|
209
|
+
* @returns `true` when image attachments are allowed.
|
|
210
|
+
*/
|
|
211
|
+
export function acapLlmActiveModelSupportsVision(config) {
|
|
212
|
+
var provider = acapLlmFindProvider(config, config.activeProviderId);
|
|
213
|
+
var entry = provider
|
|
214
|
+
? acapLlmEffectiveModels(provider).find(function (model) { return model.id === config.activeModel; })
|
|
215
|
+
: undefined;
|
|
216
|
+
return entry ? entry.vision : acapLlmGuessModelVision(config.activeModel);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Resolves the settings used for image input such as OCR.
|
|
220
|
+
*
|
|
221
|
+
* Prefers the active model when it has a key and accepts images, so a user who
|
|
222
|
+
* picked a vision model gets exactly that one. Otherwise falls back to the
|
|
223
|
+
* first vision-capable model of any provider with a key, so text recognition
|
|
224
|
+
* still works while chat runs on a text-only model.
|
|
225
|
+
*
|
|
226
|
+
* @param config - Current config.
|
|
227
|
+
* @returns Settings for a vision-capable model, or `undefined` when no
|
|
228
|
+
* configured provider offers one.
|
|
229
|
+
*/
|
|
230
|
+
export function acapLlmResolveVisionSettings(config) {
|
|
231
|
+
var e_1, _a;
|
|
232
|
+
var active = acapLlmResolveActiveSettings(config);
|
|
233
|
+
if (active.apiKey.trim() && acapLlmActiveModelSupportsVision(config)) {
|
|
234
|
+
return active;
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
for (var _b = __values(config.providers), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
238
|
+
var provider = _c.value;
|
|
239
|
+
if (!provider.apiKey.trim())
|
|
240
|
+
continue;
|
|
241
|
+
var model = acapLlmEffectiveModels(provider).find(function (entry) { return entry.vision; });
|
|
242
|
+
if (!model)
|
|
243
|
+
continue;
|
|
244
|
+
return {
|
|
245
|
+
provider: provider.id,
|
|
246
|
+
kind: provider.kind,
|
|
247
|
+
protocol: provider.protocol,
|
|
248
|
+
apiKey: provider.apiKey,
|
|
249
|
+
baseUrl: acapLlmEffectiveBaseUrl(provider),
|
|
250
|
+
model: model.id
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
255
|
+
finally {
|
|
256
|
+
try {
|
|
257
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
258
|
+
}
|
|
259
|
+
finally { if (e_1) throw e_1.error; }
|
|
260
|
+
}
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Inserts or replaces a provider and makes it the active one.
|
|
265
|
+
*
|
|
266
|
+
* The active model is kept when the provider still offers it; otherwise the
|
|
267
|
+
* provider's first model is selected.
|
|
268
|
+
*
|
|
269
|
+
* @param config - Current config.
|
|
270
|
+
* @param provider - Provider to save.
|
|
271
|
+
* @returns A new config.
|
|
272
|
+
*/
|
|
273
|
+
export function acapLlmUpsertProvider(config, provider) {
|
|
274
|
+
var _a, _b;
|
|
275
|
+
var exists = config.providers.some(function (entry) { return entry.id === provider.id; });
|
|
276
|
+
var providers = exists
|
|
277
|
+
? config.providers.map(function (entry) {
|
|
278
|
+
return entry.id === provider.id ? provider : entry;
|
|
279
|
+
})
|
|
280
|
+
: __spreadArray(__spreadArray([], __read(config.providers), false), [provider], false);
|
|
281
|
+
var models = acapLlmEffectiveModels(provider);
|
|
282
|
+
var keepModel = config.activeProviderId === provider.id &&
|
|
283
|
+
(models.length === 0 ||
|
|
284
|
+
models.some(function (model) { return model.id === config.activeModel; }));
|
|
285
|
+
return {
|
|
286
|
+
providers: providers,
|
|
287
|
+
activeProviderId: provider.id,
|
|
288
|
+
activeModel: keepModel ? config.activeModel : ((_b = (_a = models[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : '')
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Removes a provider. When it was active, chat switches to the first
|
|
293
|
+
* remaining provider that has a key, or to the default provider.
|
|
294
|
+
*
|
|
295
|
+
* @param config - Current config.
|
|
296
|
+
* @param id - Provider id to remove.
|
|
297
|
+
* @returns A new config.
|
|
298
|
+
*/
|
|
299
|
+
export function acapLlmRemoveProvider(config, id) {
|
|
300
|
+
var providers = config.providers.filter(function (provider) { return provider.id !== id; });
|
|
301
|
+
if (config.activeProviderId !== id)
|
|
302
|
+
return __assign(__assign({}, config), { providers: providers });
|
|
303
|
+
return acapLlmEnsureActiveProvider({
|
|
304
|
+
providers: providers,
|
|
305
|
+
activeProviderId: '',
|
|
306
|
+
activeModel: ''
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Converts pre-multi-provider settings into a {@link AcApLlmConfig}.
|
|
311
|
+
*
|
|
312
|
+
* `openai-compatible` becomes a custom provider of the same id that lists the
|
|
313
|
+
* saved model; the other providers become built-in entries that keep a base
|
|
314
|
+
* URL only when it differs from the default.
|
|
315
|
+
*
|
|
316
|
+
* @param legacy - Settings in the old single-provider shape.
|
|
317
|
+
* @returns The equivalent config.
|
|
318
|
+
*/
|
|
319
|
+
export function acapLlmMigrateLegacySettings(legacy) {
|
|
320
|
+
var _a, _b, _c, _d, _e, _f;
|
|
321
|
+
var apiKey = (_a = legacy.apiKey) !== null && _a !== void 0 ? _a : '';
|
|
322
|
+
var baseUrl = (_c = (_b = legacy.baseUrl) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
323
|
+
var id = (_d = legacy.provider) !== null && _d !== void 0 ? _d : '';
|
|
324
|
+
if (acapLlmIsBuiltinProviderId(id)) {
|
|
325
|
+
var info = ACAP_LLM_BUILTIN_PROVIDERS[id];
|
|
326
|
+
var model_1 = ((_e = legacy.model) === null || _e === void 0 ? void 0 : _e.trim()) || info.models[0].id;
|
|
327
|
+
return {
|
|
328
|
+
providers: [
|
|
329
|
+
__assign(__assign({}, acapLlmCreateBuiltinProvider(id)), { apiKey: apiKey, baseUrl: baseUrl === info.baseUrl ? '' : baseUrl })
|
|
330
|
+
],
|
|
331
|
+
activeProviderId: id,
|
|
332
|
+
activeModel: model_1
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
var model = (_f = legacy.model) === null || _f === void 0 ? void 0 : _f.trim();
|
|
336
|
+
if (id !== 'openai-compatible' || !model)
|
|
337
|
+
return acapLlmCreateDefaultConfig();
|
|
338
|
+
return {
|
|
339
|
+
providers: [
|
|
340
|
+
__assign(__assign({}, acapLlmCreateCustomProvider()), { id: id, baseUrl: baseUrl, apiKey: apiKey, models: [{ id: model, vision: acapLlmGuessModelVision(model) }] })
|
|
341
|
+
],
|
|
342
|
+
activeProviderId: id,
|
|
343
|
+
activeModel: model
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Normalizes one persisted provider, dropping entries that cannot be used.
|
|
348
|
+
*
|
|
349
|
+
* @param persisted - Provider as read from storage.
|
|
350
|
+
* @param apiKey - Decrypted API key.
|
|
351
|
+
* @returns The provider, or `undefined` when its id is unusable.
|
|
352
|
+
*/
|
|
353
|
+
function restoreProvider(persisted, apiKey) {
|
|
354
|
+
var _a, _b, _c, _d, _e, _f;
|
|
355
|
+
var id = (_a = persisted.id) !== null && _a !== void 0 ? _a : '';
|
|
356
|
+
if (persisted.kind === 'builtin' || acapLlmIsBuiltinProviderId(id)) {
|
|
357
|
+
if (!acapLlmIsBuiltinProviderId(id))
|
|
358
|
+
return undefined;
|
|
359
|
+
return __assign(__assign({}, acapLlmCreateBuiltinProvider(id)), { baseUrl: (_b = persisted.baseUrl) !== null && _b !== void 0 ? _b : '', apiKey: apiKey, models: acapLlmRestoreModelEntries(persisted.models) });
|
|
360
|
+
}
|
|
361
|
+
if (!ACAP_LLM_CUSTOM_PROVIDER_ID_PATTERN.test(id))
|
|
362
|
+
return undefined;
|
|
363
|
+
return {
|
|
364
|
+
id: id,
|
|
365
|
+
kind: 'custom',
|
|
366
|
+
displayName: (_c = persisted.displayName) !== null && _c !== void 0 ? _c : '',
|
|
367
|
+
protocol: (_d = persisted.protocol) !== null && _d !== void 0 ? _d : 'openai-chat',
|
|
368
|
+
baseUrl: (_e = persisted.baseUrl) !== null && _e !== void 0 ? _e : '',
|
|
369
|
+
apiKey: apiKey,
|
|
370
|
+
models: (_f = acapLlmRestoreModelEntries(persisted.models)) !== null && _f !== void 0 ? _f : []
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Validates a stored model catalog, dropping entries without a usable id.
|
|
375
|
+
*
|
|
376
|
+
* @param value - Catalog as read from storage.
|
|
377
|
+
* @returns The valid entries, or `null` when no catalog was stored.
|
|
378
|
+
*/
|
|
379
|
+
export function acapLlmRestoreModelEntries(value) {
|
|
380
|
+
if (!Array.isArray(value))
|
|
381
|
+
return null;
|
|
382
|
+
return value.flatMap(function (item) {
|
|
383
|
+
var entry = item;
|
|
384
|
+
if (!entry || typeof entry !== 'object')
|
|
385
|
+
return [];
|
|
386
|
+
if (typeof entry.id !== 'string' || !entry.id.trim())
|
|
387
|
+
return [];
|
|
388
|
+
var name = typeof entry.name === 'string' ? entry.name.trim() : '';
|
|
389
|
+
return [__assign(__assign({ id: entry.id }, (name ? { name: name } : {})), { vision: !!entry.vision })];
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Points chat at an existing provider when the stored active one is gone,
|
|
394
|
+
* e.g. a custom provider dropped because its stored entry was invalid.
|
|
395
|
+
*
|
|
396
|
+
* @param config - Config to check.
|
|
397
|
+
* @returns The same config when its active provider exists, otherwise a copy
|
|
398
|
+
* that activates the first provider with a key (or the default provider).
|
|
399
|
+
*/
|
|
400
|
+
export function acapLlmEnsureActiveProvider(config) {
|
|
401
|
+
var _a, _b, _c;
|
|
402
|
+
if (acapLlmFindProvider(config, config.activeProviderId))
|
|
403
|
+
return config;
|
|
404
|
+
var fallback = (_a = config.providers.find(function (provider) { return provider.apiKey.trim(); })) !== null && _a !== void 0 ? _a : acapLlmCreateBuiltinProvider(DEFAULT_PROVIDER);
|
|
405
|
+
return __assign(__assign({}, config), { activeProviderId: fallback.id, activeModel: (_c = (_b = acapLlmEffectiveModels(fallback)[0]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : '' });
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Restores the legacy single-provider settings, decrypting the key.
|
|
409
|
+
*
|
|
410
|
+
* @param raw - JSON stored under {@link LEGACY_STORAGE_KEY}.
|
|
411
|
+
* @returns Legacy settings with a plaintext key.
|
|
412
|
+
*/
|
|
413
|
+
function readLegacySettings(raw) {
|
|
414
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
415
|
+
var persisted, apiKey, _a;
|
|
416
|
+
var _b;
|
|
417
|
+
return __generator(this, function (_c) {
|
|
418
|
+
switch (_c.label) {
|
|
419
|
+
case 0:
|
|
420
|
+
persisted = JSON.parse(raw);
|
|
421
|
+
if (!persisted.apiKeyEnc) return [3 /*break*/, 2];
|
|
422
|
+
return [4 /*yield*/, decryptApiKey(persisted.apiKeyEnc)];
|
|
423
|
+
case 1:
|
|
424
|
+
_a = _c.sent();
|
|
425
|
+
return [3 /*break*/, 3];
|
|
426
|
+
case 2:
|
|
427
|
+
_a = ((_b = persisted.apiKey) !== null && _b !== void 0 ? _b : '');
|
|
428
|
+
_c.label = 3;
|
|
429
|
+
case 3:
|
|
430
|
+
apiKey = _a;
|
|
431
|
+
return [2 /*return*/, __assign(__assign({}, persisted), { apiKey: apiKey })];
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Loads the LLM config from `localStorage`, migrating legacy settings once.
|
|
438
|
+
*
|
|
439
|
+
* @returns Parsed config with decrypted keys, or defaults when missing or
|
|
440
|
+
* invalid.
|
|
441
|
+
*/
|
|
442
|
+
export function acapLlmLoadConfig() {
|
|
443
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
444
|
+
var raw, legacy, _a, _b, persisted, providers, _loop_1, _c, _d, entry, e_2_1, defaults, _e;
|
|
445
|
+
var e_2, _f;
|
|
446
|
+
var _g, _h, _j;
|
|
447
|
+
return __generator(this, function (_k) {
|
|
448
|
+
switch (_k.label) {
|
|
449
|
+
case 0:
|
|
450
|
+
_k.trys.push([0, 13, , 14]);
|
|
451
|
+
raw = localStorage.getItem(STORAGE_KEY);
|
|
452
|
+
if (!!raw) return [3 /*break*/, 4];
|
|
453
|
+
legacy = localStorage.getItem(LEGACY_STORAGE_KEY);
|
|
454
|
+
if (!legacy) return [3 /*break*/, 2];
|
|
455
|
+
_b = acapLlmMigrateLegacySettings;
|
|
456
|
+
return [4 /*yield*/, readLegacySettings(legacy)];
|
|
457
|
+
case 1:
|
|
458
|
+
_a = _b.apply(void 0, [_k.sent()]);
|
|
459
|
+
return [3 /*break*/, 3];
|
|
460
|
+
case 2:
|
|
461
|
+
_a = acapLlmCreateDefaultConfig();
|
|
462
|
+
_k.label = 3;
|
|
463
|
+
case 3: return [2 /*return*/, _a];
|
|
464
|
+
case 4:
|
|
465
|
+
persisted = JSON.parse(raw);
|
|
466
|
+
providers = [];
|
|
467
|
+
_loop_1 = function (entry) {
|
|
468
|
+
var apiKey, _l, provider;
|
|
469
|
+
return __generator(this, function (_m) {
|
|
470
|
+
switch (_m.label) {
|
|
471
|
+
case 0:
|
|
472
|
+
if (!entry.apiKeyEnc) return [3 /*break*/, 2];
|
|
473
|
+
return [4 /*yield*/, decryptApiKey(entry.apiKeyEnc)];
|
|
474
|
+
case 1:
|
|
475
|
+
_l = _m.sent();
|
|
476
|
+
return [3 /*break*/, 3];
|
|
477
|
+
case 2:
|
|
478
|
+
_l = '';
|
|
479
|
+
_m.label = 3;
|
|
480
|
+
case 3:
|
|
481
|
+
apiKey = _l;
|
|
482
|
+
provider = restoreProvider(entry, apiKey);
|
|
483
|
+
if (provider && !providers.some(function (item) { return item.id === provider.id; })) {
|
|
484
|
+
providers.push(provider);
|
|
485
|
+
}
|
|
486
|
+
return [2 /*return*/];
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
};
|
|
490
|
+
_k.label = 5;
|
|
491
|
+
case 5:
|
|
492
|
+
_k.trys.push([5, 10, 11, 12]);
|
|
493
|
+
_c = __values((_g = persisted.providers) !== null && _g !== void 0 ? _g : []), _d = _c.next();
|
|
494
|
+
_k.label = 6;
|
|
495
|
+
case 6:
|
|
496
|
+
if (!!_d.done) return [3 /*break*/, 9];
|
|
497
|
+
entry = _d.value;
|
|
498
|
+
return [5 /*yield**/, _loop_1(entry)];
|
|
499
|
+
case 7:
|
|
500
|
+
_k.sent();
|
|
501
|
+
_k.label = 8;
|
|
502
|
+
case 8:
|
|
503
|
+
_d = _c.next();
|
|
504
|
+
return [3 /*break*/, 6];
|
|
505
|
+
case 9: return [3 /*break*/, 12];
|
|
506
|
+
case 10:
|
|
507
|
+
e_2_1 = _k.sent();
|
|
508
|
+
e_2 = { error: e_2_1 };
|
|
509
|
+
return [3 /*break*/, 12];
|
|
510
|
+
case 11:
|
|
511
|
+
try {
|
|
512
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
513
|
+
}
|
|
514
|
+
finally { if (e_2) throw e_2.error; }
|
|
515
|
+
return [7 /*endfinally*/];
|
|
516
|
+
case 12:
|
|
517
|
+
defaults = acapLlmCreateDefaultConfig();
|
|
518
|
+
return [2 /*return*/, acapLlmEnsureActiveProvider({
|
|
519
|
+
providers: providers,
|
|
520
|
+
activeProviderId: (_h = persisted.activeProviderId) !== null && _h !== void 0 ? _h : defaults.activeProviderId,
|
|
521
|
+
activeModel: (_j = persisted.activeModel) !== null && _j !== void 0 ? _j : defaults.activeModel
|
|
522
|
+
})];
|
|
523
|
+
case 13:
|
|
524
|
+
_e = _k.sent();
|
|
525
|
+
return [2 /*return*/, acapLlmCreateDefaultConfig()];
|
|
526
|
+
case 14: return [2 /*return*/];
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Persists the LLM config to `localStorage` with encrypted API keys.
|
|
533
|
+
*
|
|
534
|
+
* @param config - Full config to serialize.
|
|
535
|
+
*/
|
|
536
|
+
export function acapLlmSaveConfig(config) {
|
|
537
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
538
|
+
var providers, _a, _b, provider, _c, _d, _e, _f, e_3_1, persisted;
|
|
539
|
+
var e_3, _g, _h;
|
|
540
|
+
return __generator(this, function (_j) {
|
|
541
|
+
switch (_j.label) {
|
|
542
|
+
case 0:
|
|
543
|
+
providers = [];
|
|
544
|
+
_j.label = 1;
|
|
545
|
+
case 1:
|
|
546
|
+
_j.trys.push([1, 8, 9, 10]);
|
|
547
|
+
_a = __values(config.providers), _b = _a.next();
|
|
548
|
+
_j.label = 2;
|
|
549
|
+
case 2:
|
|
550
|
+
if (!!_b.done) return [3 /*break*/, 7];
|
|
551
|
+
provider = _b.value;
|
|
552
|
+
_d = (_c = providers).push;
|
|
553
|
+
_e = [__assign({ id: provider.id, kind: provider.kind }, (provider.kind === 'custom'
|
|
554
|
+
? { displayName: provider.displayName, protocol: provider.protocol }
|
|
555
|
+
: {}))];
|
|
556
|
+
_h = { baseUrl: provider.baseUrl, models: provider.models };
|
|
557
|
+
if (!provider.apiKey) return [3 /*break*/, 4];
|
|
558
|
+
return [4 /*yield*/, encryptApiKey(provider.apiKey)];
|
|
559
|
+
case 3:
|
|
560
|
+
_f = _j.sent();
|
|
561
|
+
return [3 /*break*/, 5];
|
|
562
|
+
case 4:
|
|
563
|
+
_f = '';
|
|
564
|
+
_j.label = 5;
|
|
565
|
+
case 5:
|
|
566
|
+
_d.apply(_c, [__assign.apply(void 0, _e.concat([(_h.apiKeyEnc = _f, _h)]))]);
|
|
567
|
+
_j.label = 6;
|
|
568
|
+
case 6:
|
|
569
|
+
_b = _a.next();
|
|
570
|
+
return [3 /*break*/, 2];
|
|
571
|
+
case 7: return [3 /*break*/, 10];
|
|
572
|
+
case 8:
|
|
573
|
+
e_3_1 = _j.sent();
|
|
574
|
+
e_3 = { error: e_3_1 };
|
|
575
|
+
return [3 /*break*/, 10];
|
|
576
|
+
case 9:
|
|
577
|
+
try {
|
|
578
|
+
if (_b && !_b.done && (_g = _a.return)) _g.call(_a);
|
|
579
|
+
}
|
|
580
|
+
finally { if (e_3) throw e_3.error; }
|
|
581
|
+
return [7 /*endfinally*/];
|
|
582
|
+
case 10:
|
|
583
|
+
persisted = {
|
|
584
|
+
version: 2,
|
|
585
|
+
providers: providers,
|
|
586
|
+
activeProviderId: config.activeProviderId,
|
|
587
|
+
activeModel: config.activeModel
|
|
588
|
+
};
|
|
589
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(persisted));
|
|
590
|
+
configEvents.dispatchEvent(new CustomEvent(CONFIG_CHANGE_EVENT, { detail: config }));
|
|
591
|
+
return [2 /*return*/];
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
/** Name of the event {@link acapLlmSaveConfig} fires on {@link configEvents}. */
|
|
597
|
+
var CONFIG_CHANGE_EVENT = 'change';
|
|
598
|
+
/** Notifies in-page listeners, e.g. the agent panel, of saved configs. */
|
|
599
|
+
var configEvents = new EventTarget();
|
|
600
|
+
/**
|
|
601
|
+
* Subscribes to configs saved by {@link acapLlmSaveConfig}, so every UI that
|
|
602
|
+
* shows the active model (settings dialog, agent panel) stays in sync.
|
|
603
|
+
*
|
|
604
|
+
* @param listener - Receives the saved config.
|
|
605
|
+
* @returns A function that unsubscribes.
|
|
606
|
+
*/
|
|
607
|
+
export function acapLlmOnConfigChange(listener) {
|
|
608
|
+
var handler = function (event) {
|
|
609
|
+
return listener(event.detail);
|
|
610
|
+
};
|
|
611
|
+
configEvents.addEventListener(CONFIG_CHANGE_EVENT, handler);
|
|
612
|
+
return function () { return configEvents.removeEventListener(CONFIG_CHANGE_EVENT, handler); };
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Loads the config and reports what it can do, for
|
|
616
|
+
* `AcApLlmSettingsService.getStatus`.
|
|
617
|
+
*
|
|
618
|
+
* @returns Whether a provider has a key and whether a configured model
|
|
619
|
+
* accepts images.
|
|
620
|
+
*/
|
|
621
|
+
export function acapLlmGetStatus() {
|
|
622
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
623
|
+
var config;
|
|
624
|
+
return __generator(this, function (_a) {
|
|
625
|
+
switch (_a.label) {
|
|
626
|
+
case 0: return [4 /*yield*/, acapLlmLoadConfig()];
|
|
627
|
+
case 1:
|
|
628
|
+
config = _a.sent();
|
|
629
|
+
return [2 /*return*/, {
|
|
630
|
+
configured: config.providers.some(function (provider) { return provider.apiKey.trim(); }),
|
|
631
|
+
vision: !!acapLlmResolveVisionSettings(config)
|
|
632
|
+
}];
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
//# sourceMappingURL=AcApLlmConfigStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApLlmConfigStore.js","sourceRoot":"","sources":["../../src/storage/AcApLlmConfigStore.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,EACL,0BAA0B,EAG1B,uBAAuB,EACvB,0BAA0B,EAE3B,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAmGhE,mEAAmE;AACnE,IAAM,WAAW,GAAG,6BAA6B,CAAA;AAEjD,sEAAsE;AACtE,IAAM,kBAAkB,GAAG,+BAA+B,CAAA;AAE1D,kEAAkE;AAClE,IAAM,gBAAgB,GAA6B,UAAU,CAAA;AAE7D;;;GAGG;AACH,MAAM,CAAC,IAAM,mCAAmC,GAC9C,iCAAiC,CAAA;AAEnC;;;;GAIG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO;QACL,SAAS,EAAE,EAAE;QACb,gBAAgB,EAAE,gBAAgB;QAClC,WAAW,EAAE,0BAA0B,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;KACvE,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAC1C,EAA4B;IAE5B,OAAO;QACL,EAAE,IAAA;QACF,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,0BAA0B,CAAC,EAAE,CAAC,CAAC,QAAQ;QACjD,OAAO,EAAE,EAAE;QACX,MAAM,EAAE,EAAE;QACV,MAAM,EAAE,IAAI;KACb,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO;QACL,EAAE,EAAE,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE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