dsh-genapi-models 0.0.0-stage → 1.1.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/LICENSE +21 -0
- package/README.md +86 -2
- package/cordis.patch.yml +168 -0
- package/icon.svg +4 -0
- package/lib/client.js +386 -0
- package/lib/index.js +21 -0
- package/locale/en.json +6 -0
- package/locale/ru.json +6 -0
- package/package.json +59 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 maburykh-gif
|
|
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,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# GenAPI model routes
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Bundle for DeepSeek Harness that adds **GenAPI** (https://proxy.gen-api.ru/v1/, OpenAI-compatible) to the model picker
|
|
4
|
+
as 5 sections, with editable shortcodes and a builder for your own sections:
|
|
5
|
+
|
|
6
|
+
| Section | Purpose |
|
|
7
|
+
|---|---|
|
|
8
|
+
| GenAPI · тексты | статьи, копирайт, SEO, анализ |
|
|
9
|
+
| GenAPI · архитектор | проектирование, сложный код, разбор багов |
|
|
10
|
+
| GenAPI · дизайн | структура страниц, UI/UX, вёрстка, ревью макетов |
|
|
11
|
+
| GenAPI · изображения | генерация картинок (каталог; запускается скриптом) |
|
|
12
|
+
| GenAPI · видео | генерация видео (каталог; запускается скриптом) |
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
1. Get an API key in the GenAPI dashboard: https://gen-api.ru/account/api-tokens
|
|
17
|
+
2. Install the bundle and open **Settings → Models**.
|
|
18
|
+
3. Paste the key into the GenAPI provider card. It is stored in the profile's credential
|
|
19
|
+
store as `GENAPI_API_KEY`, never in this package or in the configuration file.
|
|
20
|
+
4. Restart the application — the sections appear in the picker.
|
|
21
|
+
|
|
22
|
+
Image and video sections are catalogs only: the chat engine serves text dialogs, so selecting one of those models in chat produces no answer. Generate media with your own script or the provider's media API.
|
|
23
|
+
|
|
24
|
+
## Settings → GenAPI
|
|
25
|
+
|
|
26
|
+
The settings card does three things:
|
|
27
|
+
|
|
28
|
+
- **Key and referral.** Links to the key page and to the author's referral link, with a plain
|
|
29
|
+
disclosure; a neutral documentation link is offered next to it.
|
|
30
|
+
- **Section shortcodes.** Every built-in section gets a short label shown in the model picker, e.g.
|
|
31
|
+
`GenAPI · тексты [text]`. Edit a code and press
|
|
32
|
+
**Сохранить шорткоды** — the label is written to the profile's `llm-pi-ai` settings layer.
|
|
33
|
+
- **Your own sections.** Pick any model of GenAPI, give the section a name and a shortcode,
|
|
34
|
+
optionally set the context window and output cap and mark it as accepting images. The section is
|
|
35
|
+
created as a normal OpenAI-compatible provider route `genapi-custom-<code>`, so it appears in
|
|
36
|
+
the model picker next to the built-in ones. **Удалить** removes it again.
|
|
37
|
+
|
|
38
|
+
Custom sections are stored in the profile settings document of `llm-pi-ai`, not in this package: they
|
|
39
|
+
survive plugin upgrades and are visible in the Models page.
|
|
40
|
+
|
|
41
|
+
## Ключ и реферальная ссылка
|
|
42
|
+
|
|
43
|
+
Ключ создаётся в панели GenAPI: **https://gen-api.ru/?ref_id=176692**
|
|
44
|
+
|
|
45
|
+
Это **реферальная ссылка автора плагина**: вам цена та же, автор получает бонус от сервиса. Если
|
|
46
|
+
реферальная ссылка не нужна — нейтральная документация:
|
|
47
|
+
https://gen-api.ru/docs
|
|
48
|
+
|
|
49
|
+
Ключ вводится на странице «Модели» в карточке провайдера и хранится в профиле как `GENAPI_API_KEY`;
|
|
50
|
+
в этом пакете и в файлах конфигурации ключа нет.
|
|
51
|
+
|
|
52
|
+
## Configuration
|
|
53
|
+
|
|
54
|
+
The bundle declares its routes on the shared `llm-pi-ai` plugin, the same way the AITunnel bundle
|
|
55
|
+
does. A bundle layer applies **before** the profile's own `cordis.patch.yml`, so a user who already
|
|
56
|
+
lists providers there keeps theirs — this bundle never overwrites a user configuration.
|
|
57
|
+
|
|
58
|
+
> Several hub bundles installed at once all target the same `llm-pi-ai` row, and the last bundle
|
|
59
|
+
> layer wins. To run more than one hub at the same time, list the desired providers in the profile's
|
|
60
|
+
> own `cordis.patch.yml` — the profile patch is applied after every bundle layer and therefore takes
|
|
61
|
+
> precedence. The user-defined sections from this card are written on top of that and work in either
|
|
62
|
+
> case.
|
|
63
|
+
|
|
64
|
+
## Requirements
|
|
65
|
+
|
|
66
|
+
- DeepSeek Harness with the `llm-pi-ai` plugin available (shipped by default).
|
|
67
|
+
- Network access to `proxy.gen-api.ru`.
|
|
68
|
+
|
|
69
|
+
## Notes
|
|
70
|
+
|
|
71
|
+
- Model ids come from the provider's `GET https://proxy.gen-api.ru/v1/models` catalog checked on 26 ноября 2026.
|
|
72
|
+
Capacities are taken from the provider catalog where published; otherwise a conservative family
|
|
73
|
+
value is used.
|
|
74
|
+
- Section shortcodes are searchable labels in the picker, not an automatic request router.
|
|
75
|
+
- Model availability and pricing are the provider's; nothing here is free.
|
|
76
|
+
|
|
77
|
+
## Notes
|
|
78
|
+
|
|
79
|
+
Медиа-разделы — каталог: у GenAPI изображения и видео работают через нативный асинхронный task-API (/api/v1/networks), а не через OpenAI-чат; в чате DSH выбрать их можно, но генерация запускается скриптом.
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
|
|
83
|
+
MIT.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
Сделано в [SEO Fortuna](https://seofortuna.ru) — агентство SEO и AI-автоматизации; здесь же лежат остальные плагины DSH.
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# GenAPI: маршруты GenAPI на общем llm-pi-ai, как у AITunnel-бандла.
|
|
2
|
+
#
|
|
3
|
+
# Ключ не хранится здесь: apiKeyEnv ссылается на GENAPI_API_KEY в хранилище
|
|
4
|
+
# учётных данных профиля ($DSH_HOME/.credentials.yaml).
|
|
5
|
+
#
|
|
6
|
+
# Важно: слой бандла применяется раньше пользовательского патча профиля.
|
|
7
|
+
# Если в cordis.patch.yml профиля уже объявлен llm-pi-ai со своими providers,
|
|
8
|
+
# побеждает пользовательский конфиг — этот бандл ничего не перезапишет.
|
|
9
|
+
#
|
|
10
|
+
# Несколько хаб-бандлов одновременно переопределяют одну и ту же строку
|
|
11
|
+
# llm-pi-ai: применяется последний. Чтобы держать несколько хабов сразу,
|
|
12
|
+
# перечислите их провайдеров в cordis.patch.yml профиля (он главнее бандлов).
|
|
13
|
+
- id: llm-pi-ai
|
|
14
|
+
name: "@deepseek-ai/dsh-llm-pi-ai"
|
|
15
|
+
config:
|
|
16
|
+
providers:
|
|
17
|
+
genapi-text:
|
|
18
|
+
displayName: "GenAPI · тексты [text]"
|
|
19
|
+
api: openai-completions
|
|
20
|
+
baseURL: "https://proxy.gen-api.ru/v1/"
|
|
21
|
+
apiKeyEnv: GENAPI_API_KEY
|
|
22
|
+
models:
|
|
23
|
+
- id: "claude-sonnet-5-5"
|
|
24
|
+
name: "Claude Sonnet 5.5"
|
|
25
|
+
contextWindow: 1000000
|
|
26
|
+
maxTokens: 128000
|
|
27
|
+
input: [text, image]
|
|
28
|
+
- id: "gpt-5-6-luna"
|
|
29
|
+
name: "GPT-5.6 Luna"
|
|
30
|
+
contextWindow: 1000000
|
|
31
|
+
maxTokens: 128000
|
|
32
|
+
input: [text, image]
|
|
33
|
+
- id: "gemini-3-8-flash"
|
|
34
|
+
name: "Gemini 3.8 Flash"
|
|
35
|
+
contextWindow: 1000000
|
|
36
|
+
maxTokens: 65000
|
|
37
|
+
input: [text, image]
|
|
38
|
+
- id: "deepseek-v4-flash"
|
|
39
|
+
name: "DeepSeek V4 Flash"
|
|
40
|
+
contextWindow: 1000000
|
|
41
|
+
maxTokens: 131072
|
|
42
|
+
input: [text]
|
|
43
|
+
- id: "qwen-3-8-max"
|
|
44
|
+
name: "Qwen 3.8 Max"
|
|
45
|
+
contextWindow: 1000000
|
|
46
|
+
maxTokens: 65536
|
|
47
|
+
input: [text, image]
|
|
48
|
+
- id: "grok-4-7"
|
|
49
|
+
name: "Grok 4.7"
|
|
50
|
+
contextWindow: 500000
|
|
51
|
+
maxTokens: 131072
|
|
52
|
+
input: [text, image]
|
|
53
|
+
- id: "kimi-k3"
|
|
54
|
+
name: "Kimi K3"
|
|
55
|
+
contextWindow: 1000000
|
|
56
|
+
maxTokens: 131072
|
|
57
|
+
input: [text, image]
|
|
58
|
+
genapi-architect:
|
|
59
|
+
displayName: "GenAPI · архитектор [arh]"
|
|
60
|
+
api: openai-completions
|
|
61
|
+
baseURL: "https://proxy.gen-api.ru/v1/"
|
|
62
|
+
apiKeyEnv: GENAPI_API_KEY
|
|
63
|
+
models:
|
|
64
|
+
- id: "gpt-5-6-sol-pro"
|
|
65
|
+
name: "GPT-5.6 Sol Pro"
|
|
66
|
+
contextWindow: 1000000
|
|
67
|
+
maxTokens: 128000
|
|
68
|
+
input: [text, image]
|
|
69
|
+
- id: "claude-opus-5-5"
|
|
70
|
+
name: "Claude Opus 5.5"
|
|
71
|
+
contextWindow: 1000000
|
|
72
|
+
maxTokens: 128000
|
|
73
|
+
input: [text, image]
|
|
74
|
+
- id: "deepseek-v4-pro"
|
|
75
|
+
name: "DeepSeek V4 Pro"
|
|
76
|
+
contextWindow: 1000000
|
|
77
|
+
maxTokens: 131072
|
|
78
|
+
input: [text]
|
|
79
|
+
- id: "gpt-5.4"
|
|
80
|
+
name: "GPT-5.4"
|
|
81
|
+
contextWindow: 1000000
|
|
82
|
+
maxTokens: 128000
|
|
83
|
+
input: [text, image]
|
|
84
|
+
- id: "gemini-3-1-pro"
|
|
85
|
+
name: "Gemini 3.1 Pro"
|
|
86
|
+
contextWindow: 1000000
|
|
87
|
+
maxTokens: 65536
|
|
88
|
+
input: [text, image]
|
|
89
|
+
genapi-design:
|
|
90
|
+
displayName: "GenAPI · дизайн [design]"
|
|
91
|
+
api: openai-completions
|
|
92
|
+
baseURL: "https://proxy.gen-api.ru/v1/"
|
|
93
|
+
apiKeyEnv: GENAPI_API_KEY
|
|
94
|
+
models:
|
|
95
|
+
- id: "claude-opus-5-5"
|
|
96
|
+
name: "Claude Opus 5.5"
|
|
97
|
+
contextWindow: 1000000
|
|
98
|
+
maxTokens: 128000
|
|
99
|
+
input: [text, image]
|
|
100
|
+
- id: "gemini-3-8-flash"
|
|
101
|
+
name: "Gemini 3.8 Flash"
|
|
102
|
+
contextWindow: 1000000
|
|
103
|
+
maxTokens: 65000
|
|
104
|
+
input: [text, image]
|
|
105
|
+
- id: "qwen-3-8-max"
|
|
106
|
+
name: "Qwen 3.8 Max"
|
|
107
|
+
contextWindow: 1000000
|
|
108
|
+
maxTokens: 65536
|
|
109
|
+
input: [text, image]
|
|
110
|
+
- id: "gpt-5.4"
|
|
111
|
+
name: "GPT-5.4"
|
|
112
|
+
contextWindow: 1000000
|
|
113
|
+
maxTokens: 128000
|
|
114
|
+
input: [text, image]
|
|
115
|
+
- id: "grok-4-7"
|
|
116
|
+
name: "Grok 4.7"
|
|
117
|
+
contextWindow: 500000
|
|
118
|
+
maxTokens: 131072
|
|
119
|
+
input: [text, image]
|
|
120
|
+
genapi-image:
|
|
121
|
+
displayName: "GenAPI · изображения [img]"
|
|
122
|
+
api: openai-completions
|
|
123
|
+
baseURL: "https://proxy.gen-api.ru/v1/"
|
|
124
|
+
apiKeyEnv: GENAPI_API_KEY
|
|
125
|
+
models:
|
|
126
|
+
- id: "flux-2"
|
|
127
|
+
name: "Flux 2"
|
|
128
|
+
input: [text]
|
|
129
|
+
- id: "nano-banana-2"
|
|
130
|
+
name: "Nano Banana 2"
|
|
131
|
+
input: [text]
|
|
132
|
+
- id: "qwen-image-3"
|
|
133
|
+
name: "Qwen Image 3"
|
|
134
|
+
input: [text]
|
|
135
|
+
- id: "seedream-v4-5"
|
|
136
|
+
name: "Seedream 4.5"
|
|
137
|
+
input: [text]
|
|
138
|
+
- id: "imagen-4"
|
|
139
|
+
name: "Imagen 4"
|
|
140
|
+
input: [text]
|
|
141
|
+
genapi-video:
|
|
142
|
+
displayName: "GenAPI · видео [video]"
|
|
143
|
+
api: openai-completions
|
|
144
|
+
baseURL: "https://proxy.gen-api.ru/v1/"
|
|
145
|
+
apiKeyEnv: GENAPI_API_KEY
|
|
146
|
+
models:
|
|
147
|
+
- id: "kling-video-v3"
|
|
148
|
+
name: "Kling Video V3"
|
|
149
|
+
input: [text]
|
|
150
|
+
- id: "seedance-2-5"
|
|
151
|
+
name: "Seedance 2.5"
|
|
152
|
+
input: [text]
|
|
153
|
+
- id: "runway-gen4"
|
|
154
|
+
name: "Runway Gen-4"
|
|
155
|
+
input: [text]
|
|
156
|
+
- id: "minimax-h3-max"
|
|
157
|
+
name: "MiniMax H3 Max"
|
|
158
|
+
input: [text]
|
|
159
|
+
- id: "luma-dream-machine-ray-2"
|
|
160
|
+
name: "Luma Dream Machine Ray 2"
|
|
161
|
+
input: [text]
|
|
162
|
+
|
|
163
|
+
# Клиентская половина: раздел в настройках, ссылка на ключ и реферальная ссылка,
|
|
164
|
+
# шорткоды и конструктор своих разделов. Без этой строки пакет остаётся
|
|
165
|
+
# чисто декларативным бандлом.
|
|
166
|
+
- insert:
|
|
167
|
+
- id: genapi-models
|
|
168
|
+
name: 'dsh-genapi-models'
|
package/icon.svg
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="GenAPI">
|
|
2
|
+
<rect width="64" height="64" rx="14" fill="#00B894"/>
|
|
3
|
+
<text x="32" y="42" font-family="Segoe UI, Arial, sans-serif" font-size="30" font-weight="700" fill="#ffffff" text-anchor="middle">G</text>
|
|
4
|
+
</svg>
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-genapi-models — browser half.
|
|
3
|
+
*
|
|
4
|
+
* A Settings → GenAPI card with three jobs:
|
|
5
|
+
* 1. the GenAPI key page link, the author's referral link (disclosed) and docs;
|
|
6
|
+
* 2. editable shortcodes for the built-in model sections;
|
|
7
|
+
* 3. user-defined sections: pick any model of the hub, name it, give it a
|
|
8
|
+
* shortcode — the section is written into the llm-pi-ai settings layer as a
|
|
9
|
+
* normal OpenAI-compatible provider route, so it appears in the model picker.
|
|
10
|
+
*
|
|
11
|
+
* Nothing opens by itself, no popups, no timers, no background requests. The
|
|
12
|
+
* only writes happen after an explicit button click.
|
|
13
|
+
*/
|
|
14
|
+
window.__ModuleLoader__.load({
|
|
15
|
+
id: "dsh-genapi-models",
|
|
16
|
+
factory: (require) => {
|
|
17
|
+
var module = { exports: {} };
|
|
18
|
+
var exports = module.exports;
|
|
19
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
20
|
+
let react = require("react");
|
|
21
|
+
|
|
22
|
+
const HUB = "GenAPI";
|
|
23
|
+
const SLUG = "genapi";
|
|
24
|
+
const ENV = "GENAPI_API_KEY";
|
|
25
|
+
const BASE_URL = "https://proxy.gen-api.ru/v1/";
|
|
26
|
+
const REFERRAL_URL = "https://gen-api.ru/?ref_id=176692";
|
|
27
|
+
const DOCS_URL = "https://gen-api.ru/docs";
|
|
28
|
+
const KEY_URL = "https://gen-api.ru/account/api-tokens";
|
|
29
|
+
const SETTINGS_NS = "llm-pi-ai";
|
|
30
|
+
const BUILTIN = [{"route": "genapi-text", "label": "GenAPI · тексты", "code": "text"}, {"route": "genapi-architect", "label": "GenAPI · архитектор", "code": "arh"}, {"route": "genapi-design", "label": "GenAPI · дизайн", "code": "design"}, {"route": "genapi-image", "label": "GenAPI · изображения", "code": "img"}, {"route": "genapi-video", "label": "GenAPI · видео", "code": "video"}];
|
|
31
|
+
const MODELS = [{"id": "claude-sonnet-5-5", "name": "Claude Sonnet 5.5"}, {"id": "gpt-5-6-luna", "name": "GPT-5.6 Luna"}, {"id": "gemini-3-8-flash", "name": "Gemini 3.8 Flash"}, {"id": "deepseek-v4-flash", "name": "DeepSeek V4 Flash"}, {"id": "qwen-3-8-max", "name": "Qwen 3.8 Max"}, {"id": "grok-4-7", "name": "Grok 4.7"}, {"id": "kimi-k3", "name": "Kimi K3"}, {"id": "gpt-5-6-sol-pro", "name": "GPT-5.6 Sol Pro"}, {"id": "claude-opus-5-5", "name": "Claude Opus 5.5"}, {"id": "deepseek-v4-pro", "name": "DeepSeek V4 Pro"}, {"id": "gpt-5.4", "name": "GPT-5.4"}, {"id": "gemini-3-1-pro", "name": "Gemini 3.1 Pro"}];
|
|
32
|
+
|
|
33
|
+
const wrap = {
|
|
34
|
+
display: "flex",
|
|
35
|
+
flexDirection: "column",
|
|
36
|
+
gap: "12px",
|
|
37
|
+
padding: "16px",
|
|
38
|
+
maxWidth: "760px",
|
|
39
|
+
lineHeight: "1.5"
|
|
40
|
+
};
|
|
41
|
+
const heading = { fontSize: "15px", fontWeight: 600, margin: 0 };
|
|
42
|
+
const subheading = { fontSize: "13px", fontWeight: 600, margin: 0 };
|
|
43
|
+
const paragraph = { margin: 0, fontSize: "13px", opacity: 0.85 };
|
|
44
|
+
const note = { margin: 0, fontSize: "12px", opacity: 0.65 };
|
|
45
|
+
const linkRow = { display: "flex", alignItems: "center", gap: "6px", flexWrap: "wrap" };
|
|
46
|
+
const link = { color: "inherit", textDecoration: "underline", textUnderlineOffset: "2px" };
|
|
47
|
+
const question = {
|
|
48
|
+
display: "inline-flex",
|
|
49
|
+
alignItems: "center",
|
|
50
|
+
justifyContent: "center",
|
|
51
|
+
width: "16px",
|
|
52
|
+
height: "16px",
|
|
53
|
+
borderRadius: "50%",
|
|
54
|
+
border: "1px solid currentColor",
|
|
55
|
+
fontSize: "11px",
|
|
56
|
+
cursor: "help",
|
|
57
|
+
opacity: 0.75,
|
|
58
|
+
userSelect: "none"
|
|
59
|
+
};
|
|
60
|
+
const divider = { height: "1px", background: "currentColor", opacity: 0.15 };
|
|
61
|
+
const row = { display: "flex", alignItems: "center", gap: "8px", flexWrap: "wrap" };
|
|
62
|
+
const label = { fontSize: "12px", opacity: 0.75, minWidth: "150px" };
|
|
63
|
+
const input = { fontSize: "12px", padding: "4px 8px", borderRadius: "6px", border: "1px solid currentColor", background: "transparent", color: "inherit" };
|
|
64
|
+
const inputCode = { ...input, width: "90px" };
|
|
65
|
+
const inputModel = { ...input, minWidth: "280px" };
|
|
66
|
+
const button = { fontSize: "12px", padding: "5px 12px", borderRadius: "6px", border: "1px solid currentColor", background: "transparent", color: "inherit", cursor: "pointer" };
|
|
67
|
+
const buttonDanger = { ...button, opacity: 0.8 };
|
|
68
|
+
const error = { margin: 0, fontSize: "12px", color: "#e5484d" };
|
|
69
|
+
const ok = { margin: 0, fontSize: "12px", color: "#30a46c" };
|
|
70
|
+
const chip = { fontSize: "11px", opacity: 0.7, border: "1px solid currentColor", borderRadius: "999px", padding: "1px 8px" };
|
|
71
|
+
|
|
72
|
+
/** Shortcode from a display name: the trailing [code], if any. */
|
|
73
|
+
function shortcodeOf(displayName) {
|
|
74
|
+
const match = /\[([^\]]{1,16})\]\s*$/.exec(typeof displayName === "string" ? displayName : "");
|
|
75
|
+
return match === null ? "" : match[1];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** A display name without its shortcode suffix. */
|
|
79
|
+
function baseLabelOf(displayName, fallback) {
|
|
80
|
+
const text = typeof displayName === "string" ? displayName : "";
|
|
81
|
+
return text.replace(/\s*\[[^\]]{1,16}\]\s*$/, "") || fallback;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Compose the display name shown in the model picker. */
|
|
85
|
+
function displayNameFor(baseLabel, code) {
|
|
86
|
+
const trimmed = typeof code === "string" ? code.trim() : "";
|
|
87
|
+
return trimmed.length === 0 ? baseLabel : baseLabel + " [" + trimmed + "]";
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** HTML-safe unique route id for a user section. */
|
|
91
|
+
function routeIdFor(code, name, taken) {
|
|
92
|
+
let stem = (code.length > 0 ? code : name)
|
|
93
|
+
.toLowerCase()
|
|
94
|
+
.replace(/[^a-z0-9_-]+/g, "-")
|
|
95
|
+
.replace(/^-+|-+$/g, "");
|
|
96
|
+
if (stem.length === 0) stem = "section";
|
|
97
|
+
let route = SLUG + "-custom-" + stem;
|
|
98
|
+
let suffix = 2;
|
|
99
|
+
while (taken.indexOf(route) >= 0) {
|
|
100
|
+
route = SLUG + "-custom-" + stem + "-" + suffix;
|
|
101
|
+
suffix += 1;
|
|
102
|
+
}
|
|
103
|
+
return route;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The Settings section for GenAPI.
|
|
108
|
+
* @param {object} props carries the client context with the settings remote
|
|
109
|
+
* @returns {import('react').ReactElement} the section body
|
|
110
|
+
*/
|
|
111
|
+
function GenapiSettings(props) {
|
|
112
|
+
const ctx = props.ctx;
|
|
113
|
+
const [view, setView] = react.useState(null);
|
|
114
|
+
const [status, setStatus] = react.useState("loading");
|
|
115
|
+
const [message, setMessage] = react.useState("");
|
|
116
|
+
const [failure, setFailure] = react.useState("");
|
|
117
|
+
const [busy, setBusy] = react.useState(false);
|
|
118
|
+
const [codes, setCodes] = react.useState({});
|
|
119
|
+
const [customs, setCustoms] = react.useState([]);
|
|
120
|
+
const [draft, setDraft] = react.useState({ name: "", code: "", model: "", context: "", max: "", image: false });
|
|
121
|
+
|
|
122
|
+
const reload = react.useCallback(async () => {
|
|
123
|
+
try {
|
|
124
|
+
const described = await ctx.remote.settings.describe();
|
|
125
|
+
if (!described || described.ok !== true) {
|
|
126
|
+
setFailure(described && described.error ? described.error.message : "Настройки недоступны");
|
|
127
|
+
setStatus("error");
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const namespaces = described.value && Array.isArray(described.value.namespaces) ? described.value.namespaces : [];
|
|
131
|
+
const namespace = namespaces.find((entry) => entry.ns === SETTINGS_NS);
|
|
132
|
+
if (namespace === undefined) {
|
|
133
|
+
setFailure("Настройки llm-pi-ai не найдены");
|
|
134
|
+
setStatus("error");
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const providers = namespace.value && namespace.value.providers ? namespace.value.providers : {};
|
|
138
|
+
const nextCodes = {};
|
|
139
|
+
for (const section of BUILTIN) {
|
|
140
|
+
const live = providers[section.route] || {};
|
|
141
|
+
const code = shortcodeOf(live.displayName) || section.code;
|
|
142
|
+
nextCodes[section.route] = code;
|
|
143
|
+
}
|
|
144
|
+
const nextCustoms = [];
|
|
145
|
+
for (const route of Object.keys(providers)) {
|
|
146
|
+
if (route.indexOf(SLUG + "-custom-") !== 0) continue;
|
|
147
|
+
const profile = providers[route] || {};
|
|
148
|
+
const model = Array.isArray(profile.models) && profile.models.length > 0 ? profile.models[0] : {};
|
|
149
|
+
nextCustoms.push({
|
|
150
|
+
route: route,
|
|
151
|
+
name: baseLabelOf(profile.displayName, route),
|
|
152
|
+
code: shortcodeOf(profile.displayName),
|
|
153
|
+
model: typeof model.id === "string" ? model.id : "",
|
|
154
|
+
context: model.contextWindow,
|
|
155
|
+
max: model.maxTokens
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
setView(namespace);
|
|
159
|
+
setCodes(nextCodes);
|
|
160
|
+
setCustoms(nextCustoms);
|
|
161
|
+
setStatus("ready");
|
|
162
|
+
setFailure("");
|
|
163
|
+
} catch (cause) {
|
|
164
|
+
setFailure(String(cause));
|
|
165
|
+
setStatus("error");
|
|
166
|
+
}
|
|
167
|
+
}, [ctx]);
|
|
168
|
+
|
|
169
|
+
react.useEffect(() => { reload(); }, [reload]);
|
|
170
|
+
|
|
171
|
+
const applyOps = async (ops, successMessage) => {
|
|
172
|
+
if (view === null) return;
|
|
173
|
+
setBusy(true);
|
|
174
|
+
setFailure("");
|
|
175
|
+
setMessage("");
|
|
176
|
+
try {
|
|
177
|
+
const response = await ctx.remote.settings.mutate(SETTINGS_NS, ops, view.revision);
|
|
178
|
+
if (!response || response.ok !== true) {
|
|
179
|
+
setFailure(response && response.error ? response.error.message : "Не удалось сохранить");
|
|
180
|
+
} else {
|
|
181
|
+
setMessage(successMessage);
|
|
182
|
+
await reload();
|
|
183
|
+
}
|
|
184
|
+
} catch (cause) {
|
|
185
|
+
setFailure(String(cause));
|
|
186
|
+
} finally {
|
|
187
|
+
setBusy(false);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const saveShortcodes = async () => {
|
|
192
|
+
if (view === null) return;
|
|
193
|
+
const providers = view.value && view.value.providers ? view.value.providers : {};
|
|
194
|
+
const ops = [];
|
|
195
|
+
for (const section of BUILTIN) {
|
|
196
|
+
const live = providers[section.route] || {};
|
|
197
|
+
const baseLabel = baseLabelOf(live.displayName, section.label);
|
|
198
|
+
const code = typeof codes[section.route] === "string" ? codes[section.route] : "";
|
|
199
|
+
ops.push({ op: "set", path: ["providers", section.route, "displayName"], value: displayNameFor(baseLabel, code) });
|
|
200
|
+
}
|
|
201
|
+
await applyOps(ops, "Шорткоды сохранены");
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const addCustom = async () => {
|
|
205
|
+
if (view === null) return;
|
|
206
|
+
const name = draft.name.trim();
|
|
207
|
+
const code = draft.code.trim();
|
|
208
|
+
const model = draft.model.trim();
|
|
209
|
+
if (name.length === 0 || model.length === 0) {
|
|
210
|
+
setFailure("Укажите название раздела и модель");
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const providers = view.value && view.value.providers ? view.value.providers : {};
|
|
214
|
+
const route = routeIdFor(code, name, Object.keys(providers));
|
|
215
|
+
const entry = { id: model, name: model, input: draft.image ? ["text", "image"] : ["text"] };
|
|
216
|
+
const context = parseInt(draft.context, 10);
|
|
217
|
+
const maxTokens = parseInt(draft.max, 10);
|
|
218
|
+
if (Number.isFinite(context) && context > 0) entry.contextWindow = context;
|
|
219
|
+
if (Number.isFinite(maxTokens) && maxTokens > 0) entry.maxTokens = maxTokens;
|
|
220
|
+
const profile = {
|
|
221
|
+
displayName: displayNameFor(name, code),
|
|
222
|
+
api: "openai-completions",
|
|
223
|
+
baseURL: BASE_URL,
|
|
224
|
+
apiKeyEnv: ENV,
|
|
225
|
+
models: [entry]
|
|
226
|
+
};
|
|
227
|
+
await applyOps([{ op: "set", path: ["providers", route], value: profile }], "Раздел добавлен: " + displayNameFor(name, code));
|
|
228
|
+
setDraft({ name: "", code: "", model: "", context: "", max: "", image: false });
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const removeCustom = async (route) => {
|
|
232
|
+
await applyOps([{ op: "unset", path: ["providers", route] }], "Раздел удалён");
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const children = [
|
|
236
|
+
react.createElement("h2", { style: heading }, HUB),
|
|
237
|
+
react.createElement("p", { style: paragraph },
|
|
238
|
+
"Ключ создаётся в панели " + HUB + " и хранится в хранилище учётных данных профиля как " + ENV + " — в файлах плагина ключа нет."
|
|
239
|
+
),
|
|
240
|
+
react.createElement("div", { style: linkRow },
|
|
241
|
+
react.createElement("a", { style: link, href: REFERRAL_URL, target: "_blank", rel: "noopener noreferrer" }, "Открыть панель " + HUB),
|
|
242
|
+
react.createElement("span", {
|
|
243
|
+
style: question,
|
|
244
|
+
title: "Если хотите помочь разработчику плагина — зарегистрируйтесь по этой ссылке. Для вас цена не меняется.",
|
|
245
|
+
"aria-label": "Если хотите помочь разработчику плагина"
|
|
246
|
+
}, "?"),
|
|
247
|
+
react.createElement("span", { style: chip }, "ключ: " + ENV)
|
|
248
|
+
),
|
|
249
|
+
react.createElement("p", { style: note },
|
|
250
|
+
"Это реферальная ссылка автора плагина: вам цена та же, автор получает бонус от сервиса. Если ссылка не нужна — ",
|
|
251
|
+
react.createElement("a", { style: link, href: DOCS_URL, target: "_blank", rel: "noopener noreferrer" }, "документация " + HUB),
|
|
252
|
+
". Страница ключа: ",
|
|
253
|
+
react.createElement("a", { style: link, href: KEY_URL, target: "_blank", rel: "noopener noreferrer" }, KEY_URL),
|
|
254
|
+
"."
|
|
255
|
+
),
|
|
256
|
+
react.createElement("div", { style: divider }),
|
|
257
|
+
react.createElement("h3", { style: subheading }, "Шорткоды разделов"),
|
|
258
|
+
react.createElement("p", { style: note },
|
|
259
|
+
"Короткая метка видна в селекторе моделей рядом с названием раздела (" + HUB + " · тексты [text]) и помогает быстро найти раздел поиском. Метки хранятся в настройках llm-pi-ai профиля."
|
|
260
|
+
)
|
|
261
|
+
];
|
|
262
|
+
|
|
263
|
+
if (status === "loading") {
|
|
264
|
+
children.push(react.createElement("p", { style: note }, "Загружаю разделы…"));
|
|
265
|
+
} else if (status === "error") {
|
|
266
|
+
children.push(react.createElement("p", { style: error }, failure));
|
|
267
|
+
children.push(react.createElement("button", { style: button, onClick: reload, disabled: busy }, "Повторить"));
|
|
268
|
+
} else {
|
|
269
|
+
const rows = BUILTIN.map((section) => react.createElement("div", { style: row, key: section.route },
|
|
270
|
+
react.createElement("span", { style: label }, section.label),
|
|
271
|
+
react.createElement("input", {
|
|
272
|
+
style: inputCode,
|
|
273
|
+
value: typeof codes[section.route] === "string" ? codes[section.route] : "",
|
|
274
|
+
placeholder: "шорткод",
|
|
275
|
+
maxLength: 16,
|
|
276
|
+
onChange: (event) => {
|
|
277
|
+
const value = event.target.value;
|
|
278
|
+
setCodes((current) => ({ ...current, [section.route]: value }));
|
|
279
|
+
}
|
|
280
|
+
}),
|
|
281
|
+
react.createElement("span", { style: chip }, section.route)
|
|
282
|
+
));
|
|
283
|
+
children.push(...rows);
|
|
284
|
+
children.push(react.createElement("button", { style: button, onClick: saveShortcodes, disabled: busy }, "Сохранить шорткоды"));
|
|
285
|
+
children.push(react.createElement("div", { style: divider }));
|
|
286
|
+
children.push(react.createElement("h3", { style: subheading }, "Свои разделы"));
|
|
287
|
+
children.push(react.createElement("p", { style: note },
|
|
288
|
+
"Создайте раздел под конкретную модель " + HUB + ": он появится отдельной группой в селекторе моделей и будет вызывать выбранную модель через " + BASE_URL + "."
|
|
289
|
+
));
|
|
290
|
+
if (customs.length === 0) {
|
|
291
|
+
children.push(react.createElement("p", { style: note }, "Пока нет своих разделов."));
|
|
292
|
+
}
|
|
293
|
+
for (const item of customs) {
|
|
294
|
+
children.push(react.createElement("div", { style: row, key: item.route },
|
|
295
|
+
react.createElement("span", { style: label }, item.name + (item.code ? " [" + item.code + "]" : "")),
|
|
296
|
+
react.createElement("span", { style: chip }, item.model),
|
|
297
|
+
react.createElement("span", { style: chip }, item.route),
|
|
298
|
+
react.createElement("button", { style: buttonDanger, onClick: () => removeCustom(item.route), disabled: busy }, "Удалить")
|
|
299
|
+
));
|
|
300
|
+
}
|
|
301
|
+
const listId = SLUG + "-known-models";
|
|
302
|
+
children.push(react.createElement("div", { style: row },
|
|
303
|
+
react.createElement("input", {
|
|
304
|
+
style: input,
|
|
305
|
+
placeholder: "Название раздела",
|
|
306
|
+
value: draft.name,
|
|
307
|
+
onChange: (event) => setDraft((current) => ({ ...current, name: event.target.value }))
|
|
308
|
+
}),
|
|
309
|
+
react.createElement("input", {
|
|
310
|
+
style: inputCode,
|
|
311
|
+
placeholder: "шорткод",
|
|
312
|
+
maxLength: 16,
|
|
313
|
+
value: draft.code,
|
|
314
|
+
onChange: (event) => setDraft((current) => ({ ...current, code: event.target.value }))
|
|
315
|
+
}),
|
|
316
|
+
react.createElement("input", {
|
|
317
|
+
style: inputModel,
|
|
318
|
+
placeholder: "модель (например, " + (MODELS[0] ? MODELS[0].id : "model-id") + ")",
|
|
319
|
+
value: draft.model,
|
|
320
|
+
list: listId,
|
|
321
|
+
onChange: (event) => setDraft((current) => ({ ...current, model: event.target.value }))
|
|
322
|
+
}),
|
|
323
|
+
react.createElement("datalist", { id: listId },
|
|
324
|
+
MODELS.map((model) => react.createElement("option", { key: model.id, value: model.id }, model.name))
|
|
325
|
+
),
|
|
326
|
+
react.createElement("input", {
|
|
327
|
+
style: inputCode,
|
|
328
|
+
placeholder: "контекст",
|
|
329
|
+
value: draft.context,
|
|
330
|
+
onChange: (event) => setDraft((current) => ({ ...current, context: event.target.value }))
|
|
331
|
+
}),
|
|
332
|
+
react.createElement("input", {
|
|
333
|
+
style: inputCode,
|
|
334
|
+
placeholder: "макс. ответ",
|
|
335
|
+
value: draft.max,
|
|
336
|
+
onChange: (event) => setDraft((current) => ({ ...current, max: event.target.value }))
|
|
337
|
+
}),
|
|
338
|
+
react.createElement("label", { style: note },
|
|
339
|
+
react.createElement("input", {
|
|
340
|
+
type: "checkbox",
|
|
341
|
+
checked: draft.image,
|
|
342
|
+
onChange: (event) => setDraft((current) => ({ ...current, image: event.target.checked }))
|
|
343
|
+
}),
|
|
344
|
+
" принимает картинки"
|
|
345
|
+
),
|
|
346
|
+
react.createElement("button", { style: button, onClick: addCustom, disabled: busy }, "Добавить раздел")
|
|
347
|
+
));
|
|
348
|
+
if (busy) children.push(react.createElement("p", { style: note }, "Сохраняю…"));
|
|
349
|
+
if (failure) children.push(react.createElement("p", { style: error }, failure));
|
|
350
|
+
if (message) children.push(react.createElement("p", { style: ok }, message));
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return react.createElement("div", { style: wrap }, children);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** Plugin name shown in diagnostics. */
|
|
357
|
+
const name = "genapi-models";
|
|
358
|
+
/** Settings slot plus the Host remote that reads and writes the provider list. */
|
|
359
|
+
const inject = ["slots", "remote", "remote.settings"];
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Register the GenAPI settings section.
|
|
363
|
+
*
|
|
364
|
+
* @param {object} ctx client plugin context
|
|
365
|
+
*/
|
|
366
|
+
function apply(ctx) {
|
|
367
|
+
try {
|
|
368
|
+
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
369
|
+
name: "settings.section",
|
|
370
|
+
id: "genapi",
|
|
371
|
+
order: 47,
|
|
372
|
+
label: () => HUB
|
|
373
|
+
}, () => react.createElement(GenapiSettings, { ctx: ctx })));
|
|
374
|
+
} catch (cause) {
|
|
375
|
+
// A settings card must never take the client down with it.
|
|
376
|
+
console.error("[genapi-models] settings card failed to mount:", cause);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
exports.GenapiSettings = GenapiSettings;
|
|
381
|
+
exports.apply = apply;
|
|
382
|
+
exports.inject = inject;
|
|
383
|
+
exports.name = name;
|
|
384
|
+
return module.exports;
|
|
385
|
+
}
|
|
386
|
+
});
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-genapi-models — host half.
|
|
3
|
+
*
|
|
4
|
+
* The bundle patch in `cordis.patch.yml` declares the GenAPI routes on the
|
|
5
|
+
* shared `llm-pi-ai` plugin; this module exists so the bundle has a plugin row
|
|
6
|
+
* that can carry the client half — a settings card with the key page, the
|
|
7
|
+
* author's referral link, editable section shortcodes and a builder for
|
|
8
|
+
* user-defined sections. It registers no services and changes no requests.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Entry id of this plugin in the profile. */
|
|
12
|
+
export const name = 'genapi-models'
|
|
13
|
+
|
|
14
|
+
/** No host services are needed: the client card is static. */
|
|
15
|
+
export const inject = []
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Mount the host half.
|
|
19
|
+
* @param {import('@deepseek-ai/cordis').Context} _ctx profile context
|
|
20
|
+
*/
|
|
21
|
+
export function apply(_ctx) {}
|
package/locale/en.json
ADDED
package/locale/ru.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-genapi-models",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "GenAPI model routes for DeepSeek Harness: an OpenAI-compatible gateway in 5 sections, editable shortcodes, user-defined custom sections, plus a settings card with the GenAPI key page (author referral link, disclosed)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"dsh-plugin",
|
|
10
|
+
"genapi",
|
|
11
|
+
"gen-api",
|
|
12
|
+
"llm",
|
|
13
|
+
"models",
|
|
14
|
+
"openai-compatible",
|
|
15
|
+
"providers",
|
|
16
|
+
"custom-sections",
|
|
17
|
+
"shortcodes"
|
|
18
|
+
],
|
|
19
|
+
"exports": {
|
|
20
|
+
".": "./lib/index.js",
|
|
21
|
+
"./client": "./lib/client.js",
|
|
22
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
23
|
+
"./locale/*.json": "./locale/*.json",
|
|
24
|
+
"./icon": "./icon.svg",
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"lib/index.js",
|
|
29
|
+
"lib/client.js",
|
|
30
|
+
"cordis.patch.yml",
|
|
31
|
+
"locale/*.json",
|
|
32
|
+
"icon.svg",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"dsh": {
|
|
37
|
+
"bundle": {
|
|
38
|
+
"patch": "./cordis.patch.yml"
|
|
39
|
+
},
|
|
40
|
+
"client": {
|
|
41
|
+
"platform": "web",
|
|
42
|
+
"inject": [
|
|
43
|
+
"@deepseek-ai/dsh-client-ui-settings",
|
|
44
|
+
"@deepseek-ai/dsh-api-remotes"
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/maburykh-gif/dsh-plugins.git",
|
|
51
|
+
"directory": "packages/genapi-models"
|
|
52
|
+
},
|
|
53
|
+
"author": "maburykh-gif",
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@deepseek-ai/dsh": "^0.2.2-rc.1",
|
|
56
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.2.2-rc.1",
|
|
57
|
+
"@deepseek-ai/dsh-api-remotes": "^0.2.2-rc.1",
|
|
58
|
+
"react": "^18.2.0"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://seofortuna.ru"
|
|
61
|
+
}
|