@goodandready/dsh-ollama-cloud-provider 0.0.0-stage → 0.1.3
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/CHANGELOG.md +57 -0
- package/LICENSE +21 -0
- package/NOTICE +15 -0
- package/README.md +251 -2
- package/README.ru.md +220 -0
- package/README.zh.md +187 -0
- package/cordis.patch.yml +11 -0
- package/lib/client.js +2656 -0
- package/lib/index.d.ts +452 -0
- package/lib/index.js +4651 -0
- package/media/visual-verification.png +0 -0
- package/package.json +121 -6
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.3 — 2026-10-21
|
|
4
|
+
|
|
5
|
+
- Aligned README documentation trio with dsh-documentation-standard: added standardized Hero headers, goodandready.app hub badges, support tables, and Mermaid architecture diagrams across English, Russian, and Chinese documentations.
|
|
6
|
+
- Updated installation instructions and package version parity.
|
|
7
|
+
|
|
8
|
+
## 0.1.2 — 2026-10-21
|
|
9
|
+
|
|
10
|
+
- Test connection falls back to the reasoning text when a thinking model returns
|
|
11
|
+
no content, and uses a 64-token budget (#17).
|
|
12
|
+
- Production acceptance of 0.1.1 confirmed chat, catalog and balance; the probe
|
|
13
|
+
is the only follow-up defect.
|
|
14
|
+
|
|
15
|
+
## 0.1.1 — 2026-10-21
|
|
16
|
+
|
|
17
|
+
Audit fixes (Gitea #1–#15):
|
|
18
|
+
|
|
19
|
+
- A transient transport/timeout/server failure no longer cools down the only
|
|
20
|
+
configured account; the harness retry policy can recover. Credential and quota
|
|
21
|
+
rejections still cool the key (#1).
|
|
22
|
+
- Removed the unimplemented `toolUpdate: 'addition-only'` declaration so the
|
|
23
|
+
model always receives the full tool list (#2).
|
|
24
|
+
- `/dsh-ollama/key` and `/key/clear` only accept this plugin's credential
|
|
25
|
+
references (`apiKeyEnv`, configured account refs and `OLLAMA_*`) (#3).
|
|
26
|
+
- The sidebar quota card honors `showSidebarQuota`, stays unmounted while the
|
|
27
|
+
setting is off and stops polling `/state` (#4).
|
|
28
|
+
- The injected stylesheet carries `data-dsh-plugin` so neighbouring plugin
|
|
29
|
+
cleanup cannot strip it (#5).
|
|
30
|
+
- Analytics uses the shared `estimateCost` implementation and applies
|
|
31
|
+
`priceOverrides` (#7).
|
|
32
|
+
- Empty catch blocks report through `bestEffortFailed` at debug level (#8).
|
|
33
|
+
- Removed unused modules and exports (`quota-runway`, `requireImages`,
|
|
34
|
+
`clearAnalyticsCache`, `PLUGIN_PROVIDERS`, `showUrlFor`) (#9).
|
|
35
|
+
- Heatmap and theme values no longer hardcode colors (#10).
|
|
36
|
+
- Test-connection requests disable thinking and use a 32-token budget (#11).
|
|
37
|
+
- The request log is flushed on shutdown (#12).
|
|
38
|
+
- Architecture documentation moved to `docs/design/ARCHITECTURE.md`; the
|
|
39
|
+
design contract lives in `docs/design/DESIGN.md` (#13).
|
|
40
|
+
- Added wiring, analytics, route-guard and adapter regression tests (#14).
|
|
41
|
+
- Account rows show the 7-day spend without a meaningless percentage (#15).
|
|
42
|
+
|
|
43
|
+
## 0.1.0
|
|
44
|
+
|
|
45
|
+
Initial release.
|
|
46
|
+
|
|
47
|
+
- Registers the `ollama-cloud` provider route for DeepSeek Harness.
|
|
48
|
+
- Native `/api/chat` transport (NDJSON) with thinking, tool calls, images and usage counters.
|
|
49
|
+
- OpenAI-compatible `/v1/chat/completions` transport selectable per model.
|
|
50
|
+
- Live model catalog from `/v1/models` enriched with `/api/tags` capabilities, plus an offline snapshot.
|
|
51
|
+
- Balance from `/api/balance` (credits and legacy percentage windows) and spend from `/api/usage`
|
|
52
|
+
with 24-hour, 7-day and 30-day windows and per-model groups.
|
|
53
|
+
- Multi-account rotation before the first streamed token, persistent cooldowns, sticky sessions and
|
|
54
|
+
model → account glob rules.
|
|
55
|
+
- Price estimates including off-peak rates and per-model overrides.
|
|
56
|
+
- Settings page, sidebar quota card, quota/analytics panel with a request heatmap, `/ollama` command,
|
|
57
|
+
TUI settings section and one-click plugin update.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-opencode-provider contributors
|
|
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/NOTICE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
dsh-ollama-cloud-provider
|
|
2
|
+
Copyright (c) 2026 GooDAnDReaDY
|
|
3
|
+
|
|
4
|
+
This product is MIT-licensed (see LICENSE).
|
|
5
|
+
|
|
6
|
+
Third-party references and attribution:
|
|
7
|
+
|
|
8
|
+
- The plugin structure, cordis lifecycle wiring, HTTP route guards, request log, analytics reader,
|
|
9
|
+
quota runway and generic client widgets were adapted from the author's own
|
|
10
|
+
`@goodandready/dsh-opencode-provider` (MIT).
|
|
11
|
+
- The feature set was informed by `@goodandready/dsh-clinebot` (MIT) and
|
|
12
|
+
`@mars-sea/dsh-commandcode-provider` (MIT). No vendor code from those packages is bundled.
|
|
13
|
+
- DeepSeek Harness packages (`@deepseek-ai/*`) are host-owned peer dependencies and are not bundled.
|
|
14
|
+
- Ollama Cloud API facts were verified against the public documentation and live endpoints on
|
|
15
|
+
2026-10-21. Ollama is a trademark of its respective owner; this plugin is unofficial.
|
package/README.md
CHANGED
|
@@ -1,3 +1,252 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 📦 @goodandready/dsh-ollama-cloud-provider
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
<h3>Ollama Cloud LLM Provider for DeepSeek Harness</h3>
|
|
6
|
+
|
|
7
|
+
<p>
|
|
8
|
+
<a href="https://goodandready.app/"><img src="https://img.shields.io/badge/🌐_DSH_Hub-goodandready.app-ff4500.svg?style=for-the-badge&labelColor=1a1a2e" alt="GoodAndReady Showcase"></a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/@goodandready/dsh-ollama-cloud-provider"><img src="https://img.shields.io/npm/v/@goodandready/dsh-ollama-cloud-provider?style=for-the-badge&color=crimson&logo=npm" alt="npm version"></a>
|
|
10
|
+
<a href="https://github.com/GooDAnDReaDY/dsh-ollama-cloud-provider/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge" alt="License"></a>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<table align="center">
|
|
16
|
+
<tr>
|
|
17
|
+
<td align="center">
|
|
18
|
+
⭐ <strong>If you like this plugin, please star it on GitHub</strong> — it shows me that the plugin is useful to you and motivates me to keep developing it.
|
|
19
|
+
<br><br>
|
|
20
|
+
🐛 <strong>If you find a bug or would like to request a feature</strong>, open a GitHub issue in any language — I will review your proposal and implement useful suggestions in a future plugin version.
|
|
21
|
+
</td>
|
|
22
|
+
</tr>
|
|
23
|
+
</table>
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
Ollama Cloud provider plugin for [DeepSeek Harness](https://deepseek-harness.github.io/deepseek-harness/) (dsh).
|
|
28
|
+
|
|
29
|
+
It registers one native LLM route, `ollama-cloud`, served by `https://ollama.com`, with two wire protocols:
|
|
30
|
+
|
|
31
|
+
| Transport | Endpoint | When |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| `native` (default) | `POST /api/chat` | thinking, tool calls, usage counters |
|
|
34
|
+
| `openai-chat` | `POST /v1/chat/completions` | OpenAI-compatible deployments and fallback |
|
|
35
|
+
|
|
36
|
+
Requests resolve the key per call, so a changed credential reaches the next request without a restart.
|
|
37
|
+
|
|
38
|
+
## Architecture
|
|
39
|
+
|
|
40
|
+
```mermaid
|
|
41
|
+
graph LR
|
|
42
|
+
subgraph DSH["DeepSeek Harness Core"]
|
|
43
|
+
Agent["DSH Agent / Chat"]
|
|
44
|
+
Creds["Credentials / launch env"]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
subgraph Plugin["dsh-ollama-cloud-provider"]
|
|
48
|
+
Router{"Route: ollama-cloud"}
|
|
49
|
+
Pool["Account pool<br/>rotation, cooldowns, sticky"]
|
|
50
|
+
Catalog["Live catalog<br/>/v1/models + /api/tags"]
|
|
51
|
+
Usage["Balance & usage<br/>/api/balance + /api/usage"]
|
|
52
|
+
|
|
53
|
+
subgraph Transports["Wire protocols"]
|
|
54
|
+
T1["Native /api/chat (NDJSON)"]
|
|
55
|
+
T2["OpenAI /v1/chat/completions (SSE)"]
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
subgraph Ollama["Ollama Cloud"]
|
|
60
|
+
Chat["ollama.com/api/chat"]
|
|
61
|
+
OpenAI["ollama.com/v1/chat/completions"]
|
|
62
|
+
Billing["/api/balance, /api/usage"]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
Agent --> Router
|
|
66
|
+
Creds -.-> Pool
|
|
67
|
+
Router --> Pool
|
|
68
|
+
Pool --> Transports
|
|
69
|
+
T1 --> Chat
|
|
70
|
+
T2 --> OpenAI
|
|
71
|
+
Catalog --> Router
|
|
72
|
+
Usage --> Billing
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Features
|
|
76
|
+
|
|
77
|
+
- **Two wire transports** chosen per model: the native Ollama API (NDJSON) and the OpenAI-compatible gateway (SSE).
|
|
78
|
+
- **Text, thinking, tool calls, images, usage and finish reasons** on both transports.
|
|
79
|
+
- **Live catalog** from `GET /v1/models`, enriched with capability flags from `GET /api/tags`.
|
|
80
|
+
- **Accurate limits** for the dsh picker: context window, input modalities, reasoning levels and their default, tool support, and API visibility.
|
|
81
|
+
- **Balance and usage** from the official `/api/balance` and `/api/usage` endpoints: included credits, purchased credits, 24-hour / 7-day / 30-day spend, and spend by model.
|
|
82
|
+
- **Multi-account rotation** before any content is streamed: 401/403/429 and quota rejections mark a key and retry with the next one. Cooldowns persist across restarts.
|
|
83
|
+
- **Sticky accounts** per conversation, plus model → account glob rules.
|
|
84
|
+
- **Price estimates** from the published Ollama pricing table, including off-peak rates, with per-model overrides.
|
|
85
|
+
- **Browser UI**:
|
|
86
|
+
- **Settings → Ollama Cloud**: key, balance, accounts, rules, model allowlist, per-model transport, connection settings.
|
|
87
|
+
- **Sidebar quota card** (off by default, and it does not poll `/state` while disabled): a ring with the highest used window and rows with remaining credits or legacy windows.
|
|
88
|
+
- **Center quota panel**: spend windows, spend by model, accounts, routing trace, usage analytics and a request heatmap.
|
|
89
|
+
- **`/ollama` command** for status, usage, balance, accounts, models, rules and `test [model]`.
|
|
90
|
+
- **TUI settings section** for terminal profiles.
|
|
91
|
+
- **One-click plugin update** in Settings → Ollama Cloud.
|
|
92
|
+
|
|
93
|
+
## Install
|
|
94
|
+
|
|
95
|
+
Build and pack first:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npm install
|
|
99
|
+
npm run build
|
|
100
|
+
npm pack
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Install the published package:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.3
|
|
107
|
+
# DSH Desktop:
|
|
108
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.3
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Or install the packed tarball into a profile:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.3.tgz
|
|
115
|
+
# DSH Desktop:
|
|
116
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.3.tgz
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Restart dsh (or DSH Desktop), then pick **Ollama Cloud** in the model picker.
|
|
120
|
+
|
|
121
|
+
> **Use the tarball, not the directory.** On dsh 0.2.1-rc.2 the Desktop CLI aliases a local
|
|
122
|
+
> directory passed to `dsh plugin add` and overwrites the target's `package.json`.
|
|
123
|
+
|
|
124
|
+
## Configure
|
|
125
|
+
|
|
126
|
+
```yaml
|
|
127
|
+
- id: llm-ollama-cloud
|
|
128
|
+
name: "@goodandready/dsh-ollama-cloud-provider"
|
|
129
|
+
config:
|
|
130
|
+
apiKeyEnv: OLLAMA_API_KEY # default
|
|
131
|
+
# apiKey: ... # composition only, never commit
|
|
132
|
+
transport: native # native | openai-chat
|
|
133
|
+
requestTimeoutMs: 300000
|
|
134
|
+
streamIdleTimeoutMs: 300000
|
|
135
|
+
visibleModels: []
|
|
136
|
+
modelTransports: {}
|
|
137
|
+
# contextWindowOverrides: { "model-id": 131072 }
|
|
138
|
+
# maxOutputTokens: 32768
|
|
139
|
+
accounts:
|
|
140
|
+
- label: Work
|
|
141
|
+
apiKeyEnv: OLLAMA_API_KEY_2
|
|
142
|
+
activeAccount: '' # label or credential name to pin
|
|
143
|
+
stickySession: true
|
|
144
|
+
showSidebarQuota: false
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Every field except `apiKey` is volatile and appears in dsh settings.
|
|
148
|
+
|
|
149
|
+
### Keys
|
|
150
|
+
|
|
151
|
+
1. `config.apiKey` (composition only, `role('secret')`).
|
|
152
|
+
2. The dsh credential seam under `apiKeyEnv` (default `OLLAMA_API_KEY`).
|
|
153
|
+
3. The launch environment (process, project `.env`, `$DSH_HOME/.env`).
|
|
154
|
+
|
|
155
|
+
Create a key at <https://ollama.com/settings/keys>. Keys do not expire; `x-api-key` is **not** accepted, only `Authorization: Bearer`.
|
|
156
|
+
|
|
157
|
+
### Accounts and rotation
|
|
158
|
+
|
|
159
|
+
Add a second account in **Settings → Ollama Cloud → Accounts**: give it a name and a credential reference (for example `OLLAMA_API_KEY_2`), paste its key, then Save. The default account always serves first unless `activeAccount` pins another one.
|
|
160
|
+
|
|
161
|
+
Rotation happens **before any content is streamed**. When the serving key is rejected with an invalid credential, a rate limit or an exhausted quota, the adapter marks that key and retries the same request with the next usable account. A request that already started streaming is not replayed. Cooldowns are stored in `~/.dsh/storages/dsh-ollama/cooldowns.json` keyed by a SHA-256 fingerprint — raw keys are never written.
|
|
162
|
+
|
|
163
|
+
### Model → account rules
|
|
164
|
+
|
|
165
|
+
Pin a model to a preferred account with a glob. The first matching rule wins; `*` and `?` are supported and matching is case-insensitive. Other accounts remain fallbacks.
|
|
166
|
+
|
|
167
|
+
```yaml
|
|
168
|
+
modelAccountRules:
|
|
169
|
+
- pattern: "*flash*"
|
|
170
|
+
account: "Work"
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Balance and usage
|
|
174
|
+
|
|
175
|
+
The plugin uses the documented cloud endpoints:
|
|
176
|
+
|
|
177
|
+
- `GET /api/balance` → `included.balance_usd` / `included.allowance_usd` / `included.period` and `purchased.balance_usd`. Legacy accounts return `included.session.remaining_percent` and `included.weekly.remaining_percent`; both formats are displayed.
|
|
178
|
+
- `GET /api/usage?range=24h|7d|30d&group_by=model` → totals and per-model groups with request count, USD, input, cached input and output tokens.
|
|
179
|
+
|
|
180
|
+
`/api/usage` is limited to **10 requests per minute per user**, so the reader caches each range (balance 60 s, usage 120 s, failures 30 s) and never polls in the background. Quota failures are fail-open: chat never depends on them.
|
|
181
|
+
|
|
182
|
+
## Settings page
|
|
183
|
+
|
|
184
|
+
Open **Settings → Ollama Cloud**:
|
|
185
|
+
|
|
186
|
+
- **Key** — status, paste a key, clear it, run **Test connection** against a chosen model. The probe disables thinking so the reply is visible.
|
|
187
|
+
- **Balance and usage** — credit bar or legacy windows, spend windows, warning at 80 % and exhausted at 95 %.
|
|
188
|
+
- **Accounts** — extra keys, per-account spend, pin, remove, set a key.
|
|
189
|
+
- **Model → account rules** — glob rules.
|
|
190
|
+
- **Routing** — sticky session per conversation.
|
|
191
|
+
- **Models** — search, refresh the live catalog, hide models, override the wire transport per model, see price, context and capabilities.
|
|
192
|
+
- **Connection** — native and OpenAI bases, usage and balance endpoints, transport, timeouts, output cap and context override.
|
|
193
|
+
- **Sidebar** — show or hide the quota card.
|
|
194
|
+
- **Plugin update** — current/latest version and **Update now**.
|
|
195
|
+
|
|
196
|
+
The Host serves `/dsh-ollama/state`, `/health`, `/analytics`, `/usage`, `/balance`, `/config`, `/key`, `/key/clear`, `/refresh`, `/models/refresh`, `/test` and `/update`. Writes require JSON, are refused for cross-origin requests, and are restricted to loopback (`127.0.0.1` / `::1`).
|
|
197
|
+
|
|
198
|
+
## Command
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
/ollama status # provider, accounts, quota and model count
|
|
202
|
+
/ollama usage # 7-day spend windows and spend by model
|
|
203
|
+
/ollama balance # included and purchased credits
|
|
204
|
+
/ollama accounts # labels, source, active/cooling, 7-day spend
|
|
205
|
+
/ollama models # ids, price, context, capabilities
|
|
206
|
+
/ollama rules # model → account rules
|
|
207
|
+
/ollama test [model] # minimal real request
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Verified API facts
|
|
211
|
+
|
|
212
|
+
Checked live on 2026-10-21:
|
|
213
|
+
|
|
214
|
+
- `GET https://ollama.com/v1/models` is public and returns `data[]` plus a non-standard `models[]` array carrying `context_window`, `max_context_window`, `input_modalities`, `supported_reasoning_levels`, `default_reasoning_level`, `visibility` and `supported_in_api`.
|
|
215
|
+
- `GET https://ollama.com/api/tags` is public and is the only per-model source of `capabilities` (`completion`, `tools`, `thinking`, `vision`).
|
|
216
|
+
- The live catalog returned 23 cloud models.
|
|
217
|
+
- Native `/api/chat` streams NDJSON and reports `prompt_eval_count`, `prompt_eval_cached_count`, `eval_count` and `done_reason` in the final line.
|
|
218
|
+
- OpenAI `/v1/chat/completions` supports streaming, tools, vision, `reasoning_effort` and `stream_options.include_usage`.
|
|
219
|
+
- Anthropic compatibility (`/v1/messages`) exists but is partial; this plugin does not use it.
|
|
220
|
+
|
|
221
|
+
## Development
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
npm run typecheck
|
|
225
|
+
npm test
|
|
226
|
+
npm run build
|
|
227
|
+
npm run check # typecheck + tests + build
|
|
228
|
+
npm run release # check + packed tarball
|
|
229
|
+
node scripts/probe.mjs
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
`scripts/probe.mjs` is read-only against the public catalog; with `OLLAMA_API_KEY` set it also probes chat, balance and usage and prints the raw shapes.
|
|
233
|
+
|
|
234
|
+
## Visual verification
|
|
235
|
+
|
|
236
|
+
The Ollama Cloud settings page in DSH Desktop (dark theme): configured credential, balance and usage, and the connection probe.
|
|
237
|
+
|
|
238
|
+

|
|
239
|
+
|
|
240
|
+
## Limitations
|
|
241
|
+
|
|
242
|
+
- **Cloud only.** Local `http://localhost:11434` is not registered as a route.
|
|
243
|
+
- Embeddings are not exposed: no cloud model in the live catalog advertises the `embedding` capability.
|
|
244
|
+
- File attachments are forwarded as deterministic handle text, not inline bytes.
|
|
245
|
+
- The usage endpoint is limited to 10 requests per minute; caches and the UI account for that.
|
|
246
|
+
- Cost values are estimates from the published table (including off-peak rates); the gateway is the authority.
|
|
247
|
+
- Automatic update requires the DSH CLI entry in the runtime.
|
|
248
|
+
- The UI requires a web profile; the TUI keeps the `/ollama` command and the model route.
|
|
249
|
+
|
|
250
|
+
## License
|
|
251
|
+
|
|
252
|
+
MIT © [GooDAnDReaDY](https://github.com/GooDAnDReaDY). See [LICENSE](./LICENSE) and [NOTICE](./NOTICE).
|
package/README.ru.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# 📦 @goodandready/dsh-ollama-cloud-provider
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
<h3>Плагин-провайдер Ollama Cloud для DeepSeek Harness</h3>
|
|
6
|
+
|
|
7
|
+
<p>
|
|
8
|
+
<a href="https://goodandready.app/"><img src="https://img.shields.io/badge/🌐_DSH_Hub-goodandready.app-ff4500.svg?style=for-the-badge&labelColor=1a1a2e" alt="Витрина GoodAndReady"></a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/@goodandready/dsh-ollama-cloud-provider"><img src="https://img.shields.io/npm/v/@goodandready/dsh-ollama-cloud-provider?style=for-the-badge&color=crimson&logo=npm" alt="npm версия"></a>
|
|
10
|
+
<a href="https://github.com/GooDAnDReaDY/dsh-ollama-cloud-provider/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge" alt="Лицензия"></a>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<table align="center">
|
|
16
|
+
<tr>
|
|
17
|
+
<td align="center">
|
|
18
|
+
⭐ <strong>Если вам нравится этот плагин, поставьте ему Star на GitHub</strong> — это покажет мне, что плагин полезен, и добавит мотивации продолжать его развитие.
|
|
19
|
+
<br><br>
|
|
20
|
+
🐛 <strong>Если вы нашли баг или хотите предложить новую функцию</strong>, создайте Issue на GitHub на любом языке — я рассмотрю предложение и реализую полезные улучшения в одной из следующих версий плагина.
|
|
21
|
+
</td>
|
|
22
|
+
</tr>
|
|
23
|
+
</table>
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
Плагин-провайдер **Ollama Cloud** для [DeepSeek Harness](https://deepseek-harness.github.io/deepseek-harness/) (dsh).
|
|
28
|
+
|
|
29
|
+
Плагин регистрирует один нативный LLM-маршрут `ollama-cloud` (`https://ollama.com`) и поддерживает два протокола передачи данных:
|
|
30
|
+
|
|
31
|
+
| Транспорт | Эндпоинт | Назначение |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| `native` (по умолчанию) | `POST /api/chat` | thinking, вызовы инструментов (tool calls), счётчики usage (NDJSON) |
|
|
34
|
+
| `openai-chat` | `POST /v1/chat/completions` | Совместимость с OpenAI API и резервный транспорт (SSE) |
|
|
35
|
+
|
|
36
|
+
Ключи разрешаются динамически на каждый вызов: смена credential применяется мгновенно без перезапуска сервера.
|
|
37
|
+
|
|
38
|
+
## Архитектура
|
|
39
|
+
|
|
40
|
+
```mermaid
|
|
41
|
+
graph LR
|
|
42
|
+
subgraph DSH["Ядро DeepSeek Harness"]
|
|
43
|
+
Agent["DSH Агент / Чат"]
|
|
44
|
+
Creds["Сервис учетных данных / окружение"]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
subgraph Plugin["dsh-ollama-cloud-provider"]
|
|
48
|
+
Router{"Маршрут: ollama-cloud"}
|
|
49
|
+
Pool["Пул аккаунтов<br/>ротация, cooldown, sticky"]
|
|
50
|
+
Catalog["Живой каталог<br/>/v1/models + /api/tags"]
|
|
51
|
+
Usage["Баланс и расход<br/>/api/balance + /api/usage"]
|
|
52
|
+
|
|
53
|
+
subgraph Transports["Протоколы передачи"]
|
|
54
|
+
T1["Native /api/chat (NDJSON)"]
|
|
55
|
+
T2["OpenAI /v1/chat/completions (SSE)"]
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
subgraph Ollama["Ollama Cloud"]
|
|
60
|
+
Chat["ollama.com/api/chat"]
|
|
61
|
+
OpenAI["ollama.com/v1/chat/completions"]
|
|
62
|
+
Billing["/api/balance, /api/usage"]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
Agent --> Router
|
|
66
|
+
Creds -.-> Pool
|
|
67
|
+
Router --> Pool
|
|
68
|
+
Pool --> Transports
|
|
69
|
+
T1 --> Chat
|
|
70
|
+
T2 --> OpenAI
|
|
71
|
+
Catalog --> Router
|
|
72
|
+
Usage --> Billing
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Полный обзор возможностей
|
|
76
|
+
|
|
77
|
+
- **Два транспорта**, выбираемые индивидуально для каждой модели: нативный протокол Ollama API (NDJSON) и совместимый шлюз OpenAI (SSE).
|
|
78
|
+
- **Поддержка всех режимов**: текст, reasoning/thinking, вызовы функций/инструментов, изображения (vision), подсчёт токенов и finish reasons на обоих транспортах.
|
|
79
|
+
- **Живой каталог моделей**: автоматическое чтение `GET /v1/models`, дополненное флагами возможностей `capabilities` (`tools`, `thinking`, `vision`) из `GET /api/tags`.
|
|
80
|
+
- **Точные лимиты и метаданные**: контекстное окно, входные модальности, уровни reasoning и значение по умолчанию, статус поддержки инструментов и видимость в API.
|
|
81
|
+
- **Баланс и аналитика расхода**: интеграция с официальными облачными эндпоинтами `/api/balance` и `/api/usage` — включённые и купленные кредиты, расход за 24 часа / 7 дней / 30 дней, а также группировка по моделям.
|
|
82
|
+
- **Пул аккаунтов с авто-ротацией до первого токена**: при получении 401, 403, 429 или ответа об исчерпании квоты ключ переводится в cooldown, а запрос автоматически перенаправляется на следующий доступный аккаунт. Состояния cooldown сохраняются между перезапусками по SHA-256 fingerprint.
|
|
83
|
+
- **Sticky sessions**: закрепление одного аккаунта за конкретным диалогом, плюс гибкие правила `модель ➔ аккаунт` по glob-паттернам.
|
|
84
|
+
- **Оценка стоимости**: тарификация по официальному прайс-листу Ollama Cloud, включая ночные скидки (off-peak rates) и возможность ручного переопределения цен на модель.
|
|
85
|
+
- **Интерфейс в браузере (Web UI)**:
|
|
86
|
+
- **Настройки → Ollama Cloud**: управление ключами, отображение баланса, пул аккаунтов, правила маршрутизации, allowlist моделей, выбор транспорта.
|
|
87
|
+
- **Карточка квоты в сайдбаре**: кольцевой индикатор с наиболее загруженным окном и детализацией остатка кредитов (по умолчанию выключена и не нагружает сеть фоновыми опросами).
|
|
88
|
+
- **Центральная панель квот**: окна расходов, разбивка по моделям, трейс маршрутизации, аналитика токенов и интерактивный heatmap запросов.
|
|
89
|
+
- **Команда `/ollama`**: статус провайдера, квоты, баланс, список аккаунтов, моделей, правил и запуск тестового запроса `test [model]`.
|
|
90
|
+
- **Интеграция с терминалом (TUI)**: специальная секция настроек в терминальном режиме.
|
|
91
|
+
- **One-Click обновление плагина**: прямая проверка npm registry и кнопка обновления в Web UI.
|
|
92
|
+
|
|
93
|
+
## Установка
|
|
94
|
+
|
|
95
|
+
Сборка и упаковка из исходного кода:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npm install
|
|
99
|
+
npm run build
|
|
100
|
+
npm pack
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Установка опубликованного пакета из npm:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.3
|
|
107
|
+
# DSH Desktop:
|
|
108
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.3
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Либо установка из упакованного tarball:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.3.tgz
|
|
115
|
+
# DSH Desktop:
|
|
116
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.3.tgz
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
После установки перезапустите dsh (или DSH Desktop) и выберите **Ollama Cloud** в списке моделей.
|
|
120
|
+
|
|
121
|
+
## Конфигурация
|
|
122
|
+
|
|
123
|
+
```yaml
|
|
124
|
+
- id: llm-ollama-cloud
|
|
125
|
+
name: "@goodandready/dsh-ollama-cloud-provider"
|
|
126
|
+
config:
|
|
127
|
+
apiKeyEnv: OLLAMA_API_KEY # имя переменной или credential
|
|
128
|
+
# apiKey: ... # только в composition, не коммитить в git
|
|
129
|
+
transport: native # native | openai-chat
|
|
130
|
+
requestTimeoutMs: 300000
|
|
131
|
+
streamIdleTimeoutMs: 300000
|
|
132
|
+
visibleModels: []
|
|
133
|
+
modelTransports: {}
|
|
134
|
+
accounts:
|
|
135
|
+
- label: Work
|
|
136
|
+
apiKeyEnv: OLLAMA_API_KEY_2
|
|
137
|
+
activeAccount: '' # метка для принудительного закрепления
|
|
138
|
+
stickySession: true
|
|
139
|
+
showSidebarQuota: false
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Все поля, кроме `apiKey`, доступны для изменения в интерфейсе настроек DSH.
|
|
143
|
+
|
|
144
|
+
### Получение и хранение ключей
|
|
145
|
+
|
|
146
|
+
1. `config.apiKey` в файле конфигурации (`role('secret')`).
|
|
147
|
+
2. Системный сервис учетных данных DSH по имени `apiKeyEnv` (по умолчанию `OLLAMA_API_KEY`).
|
|
148
|
+
3. Переменные окружения процесса, `.env` проекта или `$DSH_HOME/.env`.
|
|
149
|
+
|
|
150
|
+
Ключ создается в личном кабинете: <https://ollama.com/settings/keys>. Ключи бессрочные; облачный API принимает только заголовок `Authorization: Bearer`.
|
|
151
|
+
|
|
152
|
+
### Пул аккаунтов и ротация
|
|
153
|
+
|
|
154
|
+
Дополнительный аккаунт добавляется в **Настройки → Ollama Cloud → Аккаунты**: укажите имя метки и credential reference (например, `OLLAMA_API_KEY_2`), вставьте токен и сохраните. Ротация происходит **строго до начала генерации потока**: отклонённый ключ получает cooldown, а запрос повторяется со следующим готовым аккаунтом.
|
|
155
|
+
|
|
156
|
+
Состояния cooldown сохраняются в `~/.dsh/storages/dsh-ollama/cooldowns.json` по SHA-256 хешу ключа.
|
|
157
|
+
|
|
158
|
+
### Правила привязки «модель ➔ аккаунт»
|
|
159
|
+
|
|
160
|
+
```yaml
|
|
161
|
+
modelAccountRules:
|
|
162
|
+
- pattern: "*flash*"
|
|
163
|
+
account: "Work"
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Первый совпавший glob-паттерн направляет модель на указанный аккаунт, остальные аккаунты остаются в резерве.
|
|
167
|
+
|
|
168
|
+
## Баланс и мониторинг расхода
|
|
169
|
+
|
|
170
|
+
- `GET /api/balance` — поддерживает новый формат (`included.balance_usd`, `allowance_usd`, `period`, `purchased.balance_usd`) и legacy-формат (`session` / `weekly` с `remaining_percent`).
|
|
171
|
+
- `GET /api/usage?range=24h|7d|30d&group_by=model` — суммарные показатели и разбивка по моделям.
|
|
172
|
+
|
|
173
|
+
Эндпоинт `/api/usage` ограничен лимитом в **10 запросов в минуту**, поэтому баланс кэшируется на 60 секунд, статистика расхода — на 120 секунд. Фоновых опросов нет; временная недоступность квот не прерывает работу чата.
|
|
174
|
+
|
|
175
|
+
## Страница настроек Web UI
|
|
176
|
+
|
|
177
|
+
В разделе **Настройки → Ollama Cloud**:
|
|
178
|
+
- **Key**: статус ключа, вставка, очистка, кнопка **Test connection**.
|
|
179
|
+
- **Balance & Usage**: шкалы кредитов, окна расходов, предупреждения при 80% и 95%.
|
|
180
|
+
- **Accounts**: управление пулом дополнительных учетных записей.
|
|
181
|
+
- **Model rules**: настройка правил ротации по моделям.
|
|
182
|
+
- **Models**: поиск, принудительное обновление каталога моделей, allowlist, переопределение транспорта.
|
|
183
|
+
- **Connection**: базовые адреса, таймауты, лимиты токенов.
|
|
184
|
+
- **Plugin update**: проверка обновлений и кнопка **Update now**.
|
|
185
|
+
|
|
186
|
+
## Визуальная верификация
|
|
187
|
+
|
|
188
|
+
Настройки и баланс Ollama Cloud в интерфейсе DSH Desktop (темная тема):
|
|
189
|
+
|
|
190
|
+

|
|
191
|
+
|
|
192
|
+
## Команды CLI
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
/ollama status # статус провайдера, квоты, модели
|
|
196
|
+
/ollama usage # окна расходов и статистика по моделям
|
|
197
|
+
/ollama balance # баланс кредитов
|
|
198
|
+
/ollama accounts # список аккаунтов и их расход
|
|
199
|
+
/ollama models # каталог моделей и параметры
|
|
200
|
+
/ollama rules # правила модель ➔ аккаунт
|
|
201
|
+
/ollama test [model] # проверочный запрос к модели
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Проверенные факты API (2026-10-21)
|
|
205
|
+
|
|
206
|
+
- `GET https://ollama.com/v1/models` возвращает стандартный `data[]` и расширенный массив `models[]` с метаданными контекста и модальностей.
|
|
207
|
+
- `GET https://ollama.com/api/tags` служит источником флагов `capabilities` по моделям.
|
|
208
|
+
- Нативный `/api/chat` передает NDJSON с подробной статистикой токенов в финальном объекте.
|
|
209
|
+
- Совместимый эндпоинт OpenAI `/v1/chat/completions` поддерживает стриминг, инструменты, зрение (vision) и `reasoning_effort`.
|
|
210
|
+
|
|
211
|
+
## Ограничения
|
|
212
|
+
|
|
213
|
+
- Только Ollama Cloud; локальный сервис `http://localhost:11434` данным плагином не регистрируется.
|
|
214
|
+
- Эмбеддинги (embeddings) в облачном API не предоставляются.
|
|
215
|
+
- Файловые вложения передаются текстовыми дескрипторами (handle), а не бинарными байтами.
|
|
216
|
+
- Интерфейс требует web-профиль; в терминальном TUI доступны команда `/ollama` и маршрут модели.
|
|
217
|
+
|
|
218
|
+
## Лицензия
|
|
219
|
+
|
|
220
|
+
MIT © [GooDAnDReaDY](https://github.com/GooDAnDReaDY). См. [LICENSE](./LICENSE) и [NOTICE](./NOTICE).
|