@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.
Files changed (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -2
  3. package/dist/cad-llm-plugin-register.js +613 -0
  4. package/dist/cad-llm-plugin-register.umd.cjs +1 -0
  5. package/dist/cad-llm-plugin.js +21481 -0
  6. package/dist/cad-llm-plugin.umd.cjs +514 -0
  7. package/lib/AcApLlmPlugin.d.ts +39 -0
  8. package/lib/AcApLlmPlugin.d.ts.map +1 -0
  9. package/lib/AcApLlmPlugin.js +119 -0
  10. package/lib/AcApLlmPlugin.js.map +1 -0
  11. package/lib/AcApLlmTextRecognizer.d.ts +43 -0
  12. package/lib/AcApLlmTextRecognizer.d.ts.map +1 -0
  13. package/lib/AcApLlmTextRecognizer.js +303 -0
  14. package/lib/AcApLlmTextRecognizer.js.map +1 -0
  15. package/lib/command/AcApLlmSettingsCmd.d.ts +16 -0
  16. package/lib/command/AcApLlmSettingsCmd.d.ts.map +1 -0
  17. package/lib/command/AcApLlmSettingsCmd.js +114 -0
  18. package/lib/command/AcApLlmSettingsCmd.js.map +1 -0
  19. package/lib/constants.d.ts +7 -0
  20. package/lib/constants.d.ts.map +1 -0
  21. package/lib/constants.js +7 -0
  22. package/lib/constants.js.map +1 -0
  23. package/lib/i18n/ar.d.ts +77 -0
  24. package/lib/i18n/ar.d.ts.map +1 -0
  25. package/lib/i18n/ar.js +77 -0
  26. package/lib/i18n/ar.js.map +1 -0
  27. package/lib/i18n/command.d.ts +30 -0
  28. package/lib/i18n/command.d.ts.map +1 -0
  29. package/lib/i18n/command.js +30 -0
  30. package/lib/i18n/command.js.map +1 -0
  31. package/lib/i18n/cs.d.ts +77 -0
  32. package/lib/i18n/cs.d.ts.map +1 -0
  33. package/lib/i18n/cs.js +77 -0
  34. package/lib/i18n/cs.js.map +1 -0
  35. package/lib/i18n/en.d.ts +82 -0
  36. package/lib/i18n/en.d.ts.map +1 -0
  37. package/lib/i18n/en.js +82 -0
  38. package/lib/i18n/en.js.map +1 -0
  39. package/lib/i18n/index.d.ts +29 -0
  40. package/lib/i18n/index.d.ts.map +1 -0
  41. package/lib/i18n/index.js +142 -0
  42. package/lib/i18n/index.js.map +1 -0
  43. package/lib/i18n/ja.d.ts +77 -0
  44. package/lib/i18n/ja.d.ts.map +1 -0
  45. package/lib/i18n/ja.js +77 -0
  46. package/lib/i18n/ja.js.map +1 -0
  47. package/lib/i18n/ko.d.ts +77 -0
  48. package/lib/i18n/ko.d.ts.map +1 -0
  49. package/lib/i18n/ko.js +77 -0
  50. package/lib/i18n/ko.js.map +1 -0
  51. package/lib/i18n/tr.d.ts +77 -0
  52. package/lib/i18n/tr.d.ts.map +1 -0
  53. package/lib/i18n/tr.js +77 -0
  54. package/lib/i18n/tr.js.map +1 -0
  55. package/lib/i18n/zh.d.ts +77 -0
  56. package/lib/i18n/zh.d.ts.map +1 -0
  57. package/lib/i18n/zh.js +77 -0
  58. package/lib/i18n/zh.js.map +1 -0
  59. package/lib/index.d.ts +25 -0
  60. package/lib/index.d.ts.map +1 -0
  61. package/lib/index.js +25 -0
  62. package/lib/index.js.map +1 -0
  63. package/lib/model/AcApLlmModelFactory.d.ts +14 -0
  64. package/lib/model/AcApLlmModelFactory.d.ts.map +1 -0
  65. package/lib/model/AcApLlmModelFactory.js +46 -0
  66. package/lib/model/AcApLlmModelFactory.js.map +1 -0
  67. package/lib/model/AcApLlmModelListing.d.ts +67 -0
  68. package/lib/model/AcApLlmModelListing.d.ts.map +1 -0
  69. package/lib/model/AcApLlmModelListing.js +275 -0
  70. package/lib/model/AcApLlmModelListing.js.map +1 -0
  71. package/lib/model/anthropicBrowserAccess.d.ts +8 -0
  72. package/lib/model/anthropicBrowserAccess.d.ts.map +1 -0
  73. package/lib/model/anthropicBrowserAccess.js +8 -0
  74. package/lib/model/anthropicBrowserAccess.js.map +1 -0
  75. package/lib/model/normalizeLlmBaseUrl.d.ts +17 -0
  76. package/lib/model/normalizeLlmBaseUrl.d.ts.map +1 -0
  77. package/lib/model/normalizeLlmBaseUrl.js +31 -0
  78. package/lib/model/normalizeLlmBaseUrl.js.map +1 -0
  79. package/lib/model/openAiCompatibleFetch.d.ts +11 -0
  80. package/lib/model/openAiCompatibleFetch.d.ts.map +1 -0
  81. package/lib/model/openAiCompatibleFetch.js +122 -0
  82. package/lib/model/openAiCompatibleFetch.js.map +1 -0
  83. package/lib/model/skipDataUrlDownload.d.ts +12 -0
  84. package/lib/model/skipDataUrlDownload.d.ts.map +1 -0
  85. package/lib/model/skipDataUrlDownload.js +58 -0
  86. package/lib/model/skipDataUrlDownload.js.map +1 -0
  87. package/lib/register.d.ts +20 -0
  88. package/lib/register.d.ts.map +1 -0
  89. package/lib/register.js +139 -0
  90. package/lib/register.js.map +1 -0
  91. package/lib/storage/AcApLlmConfigStore.d.ts +218 -0
  92. package/lib/storage/AcApLlmConfigStore.d.ts.map +1 -0
  93. package/lib/storage/AcApLlmConfigStore.js +637 -0
  94. package/lib/storage/AcApLlmConfigStore.js.map +1 -0
  95. package/lib/storage/AcApLlmModelCatalog.d.ts +68 -0
  96. package/lib/storage/AcApLlmModelCatalog.d.ts.map +1 -0
  97. package/lib/storage/AcApLlmModelCatalog.js +141 -0
  98. package/lib/storage/AcApLlmModelCatalog.js.map +1 -0
  99. package/lib/storage/apiKeyCrypto.d.ts +28 -0
  100. package/lib/storage/apiKeyCrypto.d.ts.map +1 -0
  101. package/lib/storage/apiKeyCrypto.js +214 -0
  102. package/lib/storage/apiKeyCrypto.js.map +1 -0
  103. package/lib/storage/settingsEquality.d.ts +10 -0
  104. package/lib/storage/settingsEquality.d.ts.map +1 -0
  105. package/lib/storage/settingsEquality.js +36 -0
  106. package/lib/storage/settingsEquality.js.map +1 -0
  107. package/lib/ui/AcApLlmModelChoices.d.ts +31 -0
  108. package/lib/ui/AcApLlmModelChoices.d.ts.map +1 -0
  109. package/lib/ui/AcApLlmModelChoices.js +68 -0
  110. package/lib/ui/AcApLlmModelChoices.js.map +1 -0
  111. package/lib/ui/AcApLlmProviderLabels.d.ts +19 -0
  112. package/lib/ui/AcApLlmProviderLabels.d.ts.map +1 -0
  113. package/lib/ui/AcApLlmProviderLabels.js +34 -0
  114. package/lib/ui/AcApLlmProviderLabels.js.map +1 -0
  115. package/lib/ui/AcUiLlmSettingsDialog.d.ts +125 -0
  116. package/lib/ui/AcUiLlmSettingsDialog.d.ts.map +1 -0
  117. package/lib/ui/AcUiLlmSettingsDialog.js +1218 -0
  118. package/lib/ui/AcUiLlmSettingsDialog.js.map +1 -0
  119. package/lib/ui/llmSettingsStyles.d.ts +6 -0
  120. package/lib/ui/llmSettingsStyles.d.ts.map +1 -0
  121. package/lib/ui/llmSettingsStyles.js +6 -0
  122. package/lib/ui/llmSettingsStyles.js.map +1 -0
  123. package/package.json +54 -3
@@ -0,0 +1,139 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ 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);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ 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;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ var __read = (this && this.__read) || function (o, n) {
38
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
39
+ if (!m) return o;
40
+ var i = m.call(o), r, ar = [], e;
41
+ try {
42
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
43
+ }
44
+ catch (error) { e = { error: error }; }
45
+ finally {
46
+ try {
47
+ if (r && !r.done && (m = i["return"])) m.call(i);
48
+ }
49
+ finally { if (e) throw e.error; }
50
+ }
51
+ return ar;
52
+ };
53
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
54
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
55
+ if (ar || !(i in from)) {
56
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
57
+ ar[i] = from[i];
58
+ }
59
+ }
60
+ return to.concat(ar || Array.prototype.slice.call(from));
61
+ };
62
+ import { AcApDocManager, AcApLlmSettingsService, AcApTextRecognitionService } from '@mlightcad/cad-simple-viewer';
63
+ import { LLM_PLUGIN_NAME, LLM_PLUGIN_TRIGGERS, LLM_SERVICE_ID } from './constants.js';
64
+ import { registerLlmI18n } from './i18n/index.js';
65
+ /** Loads the main bundle on first use. */
66
+ var loadMain = function () { return import('@mlightcad/cad-llm-plugin'); };
67
+ /**
68
+ * Registers the shared AI model settings for lazy loading:
69
+ *
70
+ * - the `llmsettings` command,
71
+ * - the settings dialog in `AcApLlmSettingsService`, so any feature (CAD
72
+ * agent, PDF text recognition, ...) can open it or check what is
73
+ * configured,
74
+ * - the LLM text recognizer in `AcApTextRecognitionService`, used by `pdftext`
75
+ * when a vision-capable model is configured.
76
+ *
77
+ * Import from `@mlightcad/cad-llm-plugin/register` so the main bundle (which
78
+ * includes the AI SDK) stays out of the application entry chunk.
79
+ *
80
+ * @param pluginManager - Plugin manager that receives the lazy registration.
81
+ */
82
+ export function registerLazyLlmPlugin(pluginManager) {
83
+ var _this = this;
84
+ registerLlmI18n();
85
+ AcApTextRecognitionService.register({
86
+ id: LLM_SERVICE_ID,
87
+ recognize: function (request) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
88
+ switch (_a.label) {
89
+ case 0: return [4 /*yield*/, loadMain()];
90
+ case 1: return [2 /*return*/, (_a.sent()).acapLlmRecognizeText(request)];
91
+ }
92
+ }); }); },
93
+ recognizeBatch: function (request) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
94
+ switch (_a.label) {
95
+ case 0: return [4 /*yield*/, loadMain()];
96
+ case 1: return [2 /*return*/, (_a.sent()).acapLlmRecognizeTextBatch(request)];
97
+ }
98
+ }); }); }
99
+ });
100
+ AcApLlmSettingsService.register({
101
+ id: LLM_SERVICE_ID,
102
+ open: function (options) { return __awaiter(_this, void 0, void 0, function () {
103
+ var AcUiLlmSettingsDialog;
104
+ var _a, _b, _c;
105
+ return __generator(this, function (_d) {
106
+ switch (_d.label) {
107
+ case 0: return [4 /*yield*/, loadMain()];
108
+ case 1:
109
+ AcUiLlmSettingsDialog = (_d.sent()).AcUiLlmSettingsDialog;
110
+ return [4 /*yield*/, AcUiLlmSettingsDialog.open({
111
+ host: (_c = (_a = options === null || options === void 0 ? void 0 : options.host) !== null && _a !== void 0 ? _a : (_b = AcApDocManager.instance.curView) === null || _b === void 0 ? void 0 : _b.container) !== null && _c !== void 0 ? _c : document.body
112
+ })];
113
+ case 2:
114
+ _d.sent();
115
+ return [2 /*return*/];
116
+ }
117
+ });
118
+ }); },
119
+ getStatus: function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
120
+ switch (_a.label) {
121
+ case 0: return [4 /*yield*/, loadMain()];
122
+ case 1: return [2 /*return*/, (_a.sent()).acapLlmGetStatus()];
123
+ }
124
+ }); }); }
125
+ });
126
+ pluginManager.registerLazyPlugin({
127
+ name: LLM_PLUGIN_NAME,
128
+ triggers: __spreadArray([], __read(LLM_PLUGIN_TRIGGERS), false),
129
+ loader: function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
130
+ switch (_a.label) {
131
+ case 0: return [4 /*yield*/, loadMain()];
132
+ case 1: return [2 /*return*/, (_a.sent()).createLlmPlugin()];
133
+ }
134
+ }); }); }
135
+ });
136
+ }
137
+ export { LLM_PLUGIN_NAME, LLM_PLUGIN_TRIGGERS, LLM_SERVICE_ID } from './constants.js';
138
+ export { llmT, mergeLlmI18nIntoVueI18n, registerLlmI18n } from './i18n/index.js';
139
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACL,cAA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AE,EAAA;wBAAjB,sBAAA,CAAC,SAAgB,CAAC,CAAC,gBAAgB,EAAE,EAAA;;iBAAA;KAC7D,CAAC,CAAA;IAEF,aAAa,CAAC,kBAAkB,CAAC;QAC/B,IAAI,EAAE,eAAe;QACrB,QAAQ,2BAAM,mBAAmB,SAAC;QAClC,MAAM,EAAE;;wBAAa,qBAAM,QAAQ,EAAE,EAAA;wBAAjB,sBAAA,CAAC,SAAgB,CAAC,CAAC,eAAe,EAAE,EAAA;;iBAAA;KACzD,CAAC,CAAA;AACJ,CAAC;AAED,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,cAAc,EACf,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAEL,IAAI,EACJ,uBAAuB,EACvB,eAAe,EAChB,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,218 @@
1
+ import type { AcApLlmStatus } from '@mlightcad/cad-simple-viewer';
2
+ import { type AcApLlmApiProtocol, type AcApLlmBuiltinProviderId, type AcApLlmModelEntry } from './AcApLlmModelCatalog.js';
3
+ /** Whether a provider ships with the plugin or was declared by the user. */
4
+ export type AcApLlmProviderKind = 'builtin' | 'custom';
5
+ /**
6
+ * Persisted configuration of one LLM provider.
7
+ *
8
+ * A built-in provider takes its protocol, default base URL and default model
9
+ * catalog from {@link ACAP_LLM_BUILTIN_PROVIDERS}; the user only supplies a key and,
10
+ * optionally, a base URL or model override. A custom provider declares all of
11
+ * them.
12
+ */
13
+ export interface AcApLlmProviderConfig {
14
+ /** Built-in id, or the user-chosen lowercase slug of a custom provider. */
15
+ id: string;
16
+ /** Built-in or user-declared. */
17
+ kind: AcApLlmProviderKind;
18
+ /** Optional label for custom providers; the id is shown when absent. */
19
+ displayName?: string;
20
+ /** Wire protocol (fixed for built-in providers). */
21
+ protocol: AcApLlmApiProtocol;
22
+ /** Base URL; empty means the built-in default. */
23
+ baseUrl: string;
24
+ /** Secret API key. */
25
+ apiKey: string;
26
+ /**
27
+ * Model catalog. `null` means "use the built-in defaults" and is only
28
+ * meaningful for built-in providers.
29
+ */
30
+ models: AcApLlmModelEntry[] | null;
31
+ }
32
+ /** Every configured provider plus the model currently used for chat. */
33
+ export interface AcApLlmConfig {
34
+ /** Configured providers in the order they were added. */
35
+ providers: AcApLlmProviderConfig[];
36
+ /** Provider whose model is used for chat. */
37
+ activeProviderId: string;
38
+ /** Model id used for chat. */
39
+ activeModel: string;
40
+ }
41
+ /**
42
+ * Fully resolved settings for one chat request, derived from {@link AcApLlmConfig}.
43
+ */
44
+ export interface AcApLlmSettings {
45
+ /** Provider id. */
46
+ provider: string;
47
+ /** Built-in or custom provider. */
48
+ kind: AcApLlmProviderKind;
49
+ /** Wire protocol. */
50
+ protocol: AcApLlmApiProtocol;
51
+ /** Secret API key for the provider. */
52
+ apiKey: string;
53
+ /** Effective REST API base URL. */
54
+ baseUrl: string;
55
+ /** Model identifier passed to the provider SDK. */
56
+ model: string;
57
+ }
58
+ /** Settings shape stored by plugin versions before multi-provider support. */
59
+ export interface AcApLlmLegacySettings {
60
+ provider?: string;
61
+ baseUrl?: string;
62
+ model?: string;
63
+ apiKey?: string;
64
+ }
65
+ /**
66
+ * Lowercase slug a custom provider id must match. It starts with a letter so
67
+ * it can never collide with numeric keys and reads well in the model picker.
68
+ */
69
+ export declare const ACAP_LLM_CUSTOM_PROVIDER_ID_PATTERN: RegExp;
70
+ /**
71
+ * Returns a config with no providers configured.
72
+ *
73
+ * @returns Fresh default config.
74
+ */
75
+ export declare function acapLlmCreateDefaultConfig(): AcApLlmConfig;
76
+ /**
77
+ * Creates an unconfigured built-in provider entry.
78
+ *
79
+ * @param id - Built-in provider id.
80
+ * @returns A provider with an empty key, default URL and default catalog.
81
+ */
82
+ export declare function acapLlmCreateBuiltinProvider(id: AcApLlmBuiltinProviderId): AcApLlmProviderConfig;
83
+ /**
84
+ * Creates an empty custom provider draft.
85
+ *
86
+ * @returns A custom provider with no id, URL, key or models.
87
+ */
88
+ export declare function acapLlmCreateCustomProvider(): AcApLlmProviderConfig;
89
+ /**
90
+ * Looks up a provider in a config, falling back to an unconfigured built-in.
91
+ *
92
+ * @param config - Current config.
93
+ * @param id - Provider id.
94
+ * @returns The stored provider, a blank built-in entry, or `undefined` for an
95
+ * unknown custom id.
96
+ */
97
+ export declare function acapLlmFindProvider(config: AcApLlmConfig, id: string): AcApLlmProviderConfig | undefined;
98
+ /**
99
+ * Returns the models a provider offers in the model selector.
100
+ *
101
+ * @param provider - Provider config.
102
+ * @returns The custom catalog, or the built-in defaults when not customized.
103
+ */
104
+ export declare function acapLlmEffectiveModels(provider: AcApLlmProviderConfig): readonly AcApLlmModelEntry[];
105
+ /**
106
+ * Returns the base URL requests are sent to.
107
+ *
108
+ * @param provider - Provider config.
109
+ * @returns The configured URL, or the built-in default when blank.
110
+ */
111
+ export declare function acapLlmEffectiveBaseUrl(provider: AcApLlmProviderConfig): string;
112
+ /**
113
+ * Resolves the active provider and model into per-request settings.
114
+ *
115
+ * @param config - Current config.
116
+ * @returns Settings for the active model (empty key when unconfigured).
117
+ */
118
+ export declare function acapLlmResolveActiveSettings(config: AcApLlmConfig): AcApLlmSettings;
119
+ /**
120
+ * Determines whether the active model accepts image attachments.
121
+ *
122
+ * Uses the catalog entry when the model is listed, otherwise guesses from the
123
+ * model id.
124
+ *
125
+ * @param config - Current config.
126
+ * @returns `true` when image attachments are allowed.
127
+ */
128
+ export declare function acapLlmActiveModelSupportsVision(config: AcApLlmConfig): boolean;
129
+ /**
130
+ * Resolves the settings used for image input such as OCR.
131
+ *
132
+ * Prefers the active model when it has a key and accepts images, so a user who
133
+ * picked a vision model gets exactly that one. Otherwise falls back to the
134
+ * first vision-capable model of any provider with a key, so text recognition
135
+ * still works while chat runs on a text-only model.
136
+ *
137
+ * @param config - Current config.
138
+ * @returns Settings for a vision-capable model, or `undefined` when no
139
+ * configured provider offers one.
140
+ */
141
+ export declare function acapLlmResolveVisionSettings(config: AcApLlmConfig): AcApLlmSettings | undefined;
142
+ /**
143
+ * Inserts or replaces a provider and makes it the active one.
144
+ *
145
+ * The active model is kept when the provider still offers it; otherwise the
146
+ * provider's first model is selected.
147
+ *
148
+ * @param config - Current config.
149
+ * @param provider - Provider to save.
150
+ * @returns A new config.
151
+ */
152
+ export declare function acapLlmUpsertProvider(config: AcApLlmConfig, provider: AcApLlmProviderConfig): AcApLlmConfig;
153
+ /**
154
+ * Removes a provider. When it was active, chat switches to the first
155
+ * remaining provider that has a key, or to the default provider.
156
+ *
157
+ * @param config - Current config.
158
+ * @param id - Provider id to remove.
159
+ * @returns A new config.
160
+ */
161
+ export declare function acapLlmRemoveProvider(config: AcApLlmConfig, id: string): AcApLlmConfig;
162
+ /**
163
+ * Converts pre-multi-provider settings into a {@link AcApLlmConfig}.
164
+ *
165
+ * `openai-compatible` becomes a custom provider of the same id that lists the
166
+ * saved model; the other providers become built-in entries that keep a base
167
+ * URL only when it differs from the default.
168
+ *
169
+ * @param legacy - Settings in the old single-provider shape.
170
+ * @returns The equivalent config.
171
+ */
172
+ export declare function acapLlmMigrateLegacySettings(legacy: AcApLlmLegacySettings): AcApLlmConfig;
173
+ /**
174
+ * Validates a stored model catalog, dropping entries without a usable id.
175
+ *
176
+ * @param value - Catalog as read from storage.
177
+ * @returns The valid entries, or `null` when no catalog was stored.
178
+ */
179
+ export declare function acapLlmRestoreModelEntries(value: unknown): AcApLlmModelEntry[] | null;
180
+ /**
181
+ * Points chat at an existing provider when the stored active one is gone,
182
+ * e.g. a custom provider dropped because its stored entry was invalid.
183
+ *
184
+ * @param config - Config to check.
185
+ * @returns The same config when its active provider exists, otherwise a copy
186
+ * that activates the first provider with a key (or the default provider).
187
+ */
188
+ export declare function acapLlmEnsureActiveProvider(config: AcApLlmConfig): AcApLlmConfig;
189
+ /**
190
+ * Loads the LLM config from `localStorage`, migrating legacy settings once.
191
+ *
192
+ * @returns Parsed config with decrypted keys, or defaults when missing or
193
+ * invalid.
194
+ */
195
+ export declare function acapLlmLoadConfig(): Promise<AcApLlmConfig>;
196
+ /**
197
+ * Persists the LLM config to `localStorage` with encrypted API keys.
198
+ *
199
+ * @param config - Full config to serialize.
200
+ */
201
+ export declare function acapLlmSaveConfig(config: AcApLlmConfig): Promise<void>;
202
+ /**
203
+ * Subscribes to configs saved by {@link acapLlmSaveConfig}, so every UI that
204
+ * shows the active model (settings dialog, agent panel) stays in sync.
205
+ *
206
+ * @param listener - Receives the saved config.
207
+ * @returns A function that unsubscribes.
208
+ */
209
+ export declare function acapLlmOnConfigChange(listener: (config: AcApLlmConfig) => void): () => void;
210
+ /**
211
+ * Loads the config and reports what it can do, for
212
+ * `AcApLlmSettingsService.getStatus`.
213
+ *
214
+ * @returns Whether a provider has a key and whether a configured model
215
+ * accepts images.
216
+ */
217
+ export declare function acapLlmGetStatus(): Promise<AcApLlmStatus>;
218
+ //# sourceMappingURL=AcApLlmConfigStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcApLlmConfigStore.d.ts","sourceRoot":"","sources":["../../src/storage/AcApLlmConfigStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAEjE,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAG7B,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAA;AAGjC,4EAA4E;AAC5E,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,CAAA;AAEtD;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACpC,2EAA2E;IAC3E,EAAE,EAAE,MAAM,CAAA;IACV,iCAAiC;IACjC,IAAI,EAAE,mBAAmB,CAAA;IACzB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,oDAAoD;IACpD,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAA;IACf,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,MAAM,EAAE,iBAAiB,EAAE,GAA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