@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mlightcad
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @mlightcad/cad-llm-plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared AI model (LLM) settings for [cad-viewer](https://github.com/mlightcad/cad-viewer).
|
|
4
|
+
|
|
5
|
+
Several features rely on an LLM: the CAD Agent chat
|
|
6
|
+
([`@mlightcad/cad-agent-plugin`](../cad-agent-plugin/README.md)) and text
|
|
7
|
+
recognition (OCR) in `pdftext`
|
|
8
|
+
([`@mlightcad/cad-pdf-plugin`](../cad-pdf-plugin/README.md)). This package owns
|
|
9
|
+
the one configuration they share and the UI to edit it. The UI is plain DOM
|
|
10
|
+
(no Vue / React), so it works in `@mlightcad/cad-editor` and in
|
|
11
|
+
framework-free hosts such as `cad-simple-viewer-demo` alike.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- `llmsettings` command: opens `AcUiLlmSettingsDialog`, built on
|
|
16
|
+
`AcUiDialog` from `@mlightcad/cad-simple-viewer`
|
|
17
|
+
- picks the model in use (chat, and OCR when it accepts images)
|
|
18
|
+
- built-in providers (DeepSeek, DeepSeek VL, OpenAI, Anthropic) that only
|
|
19
|
+
need an API key, plus custom OpenAI / Anthropic compatible endpoints
|
|
20
|
+
- model catalogs, filled by hand or from the provider's model listing
|
|
21
|
+
- Config store in `localStorage` with encrypted API keys
|
|
22
|
+
(`acapLlmLoadConfig` / `acapLlmSaveConfig`), and `acapLlmOnConfigChange` so
|
|
23
|
+
every view of the config stays in sync
|
|
24
|
+
- `acapLlmCreateModel`: AI SDK model for the resolved settings
|
|
25
|
+
- Text recognizer for `pdftext`, registered as `cad-llm` in
|
|
26
|
+
`AcApTextRecognitionService`. It uses the model in use when it accepts
|
|
27
|
+
images, otherwise the first image-capable configured model, and returns
|
|
28
|
+
nothing when there is none, so `pdftext` falls back to manual input
|
|
29
|
+
- `AcApLlmSettingsService` provider (from `@mlightcad/cad-simple-viewer`), so
|
|
30
|
+
any feature can open the dialog or check whether a vision model is
|
|
31
|
+
configured without depending on this package
|
|
32
|
+
|
|
33
|
+
The settings are stored under the `localStorage` key
|
|
34
|
+
`cad-agent-plugin.llm-config`, the key the agent plugin used before this
|
|
35
|
+
package existed, so saved settings carry over.
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { AcApDocManager } from '@mlightcad/cad-simple-viewer'
|
|
41
|
+
import { registerLazyLlmPlugin } from '@mlightcad/cad-llm-plugin/register'
|
|
42
|
+
|
|
43
|
+
registerLazyLlmPlugin(AcApDocManager.instance.pluginManager)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The `/register` entry is small: the main bundle, which includes the AI SDK,
|
|
47
|
+
loads on the first `llmsettings`, OCR request or status check.
|
|
48
|
+
|
|
49
|
+
In a Vue host, also merge the strings into vue-i18n so the command line
|
|
50
|
+
shows the `llmsettings` description:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { mergeLlmI18nIntoVueI18n } from '@mlightcad/cad-llm-plugin/register'
|
|
54
|
+
|
|
55
|
+
mergeLlmI18nIntoVueI18n((locale, messages) =>
|
|
56
|
+
i18n.global.mergeLocaleMessage(locale, messages)
|
|
57
|
+
)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`@mlightcad/cad-editor` does both automatically when this package is
|
|
61
|
+
installed and adds an **AI → Model Settings** ribbon button.
|
|
62
|
+
|
|
63
|
+
From another feature, open the settings or check them through the viewer
|
|
64
|
+
service instead of importing this package:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { AcApLlmSettingsService } from '@mlightcad/cad-simple-viewer'
|
|
68
|
+
|
|
69
|
+
const status = await AcApLlmSettingsService.getStatus()
|
|
70
|
+
if (status && !status.vision) await AcApLlmSettingsService.open()
|
|
71
|
+
```
|