@mlightcad/cad-llm-plugin 0.0.0-stage → 1.8.0-preview.4

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 +71 -3
  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
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
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # @mlightcad/cad-llm-plugin
2
+
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
+ ```