@goodandready/dsh-ollama-cloud-provider 0.1.36 → 0.1.38
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 +13 -0
- package/README.md +5 -4
- package/README.ru.md +5 -4
- package/README.zh.md +5 -4
- package/lib/account-rules.js +26 -0
- package/lib/adapter.d.ts +92 -0
- package/lib/adapter.js +566 -0
- package/lib/analytics.d.ts +81 -0
- package/lib/analytics.js +314 -0
- package/lib/attempt.js +29 -0
- package/lib/best-effort.js +20 -0
- package/lib/catalog-cache.js +81 -0
- package/lib/catalog.d.ts +10 -0
- package/lib/catalog.js +309 -0
- package/lib/commands.d.ts +14 -0
- package/lib/commands.js +228 -0
- package/lib/config.d.ts +173 -0
- package/lib/config.js +279 -0
- package/lib/context-override.js +38 -0
- package/lib/credentials.d.ts +23 -0
- package/lib/credentials.js +105 -0
- package/lib/discovery.js +108 -0
- package/lib/errors.d.ts +9 -0
- package/lib/errors.js +72 -0
- package/lib/files.js +13 -0
- package/lib/images.js +78 -0
- package/lib/index.d.ts +10 -521
- package/lib/index.js +20 -5909
- package/lib/local-host.js +38 -0
- package/lib/messages.js +263 -0
- package/lib/models.generated.d.ts +26 -0
- package/lib/models.generated.js +499 -0
- package/lib/plugin-updater.js +293 -0
- package/lib/pricing.js +78 -0
- package/lib/provider-ids.d.ts +4 -0
- package/lib/provider-ids.js +9 -0
- package/lib/quota-model.js +66 -0
- package/lib/reasoning.js +71 -0
- package/lib/request-log.d.ts +38 -0
- package/lib/request-log.js +194 -0
- package/lib/retry.js +24 -0
- package/lib/routes-public.js +59 -0
- package/lib/routes-values.js +129 -0
- package/lib/routes.d.ts +28 -0
- package/lib/routes.js +677 -0
- package/lib/routing.js +20 -0
- package/lib/sanitize.js +43 -0
- package/lib/status.js +42 -0
- package/lib/tool-schema.js +109 -0
- package/lib/tools.js +38 -0
- package/lib/transports/native.js +156 -0
- package/lib/transports/ndjson.js +73 -0
- package/lib/transports/openai-chat.js +278 -0
- package/lib/transports/sse.js +57 -0
- package/lib/transports/tool-call-id.js +17 -0
- package/lib/tui-settings.js +246 -0
- package/lib/usage.d.ts +69 -0
- package/lib/usage.js +277 -0
- package/lib/web.js +143 -0
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.38 — 2026-11-12
|
|
4
|
+
|
|
5
|
+
- Architecture & Contracts: established canonical `docs/design/DESIGN.md` (following `project-design-contract`), `AGENTS.md`, `index.md`, `deploy.sh`, and `docs/deployment/DEPLOYMENT.md` (#127).
|
|
6
|
+
- Artifact Guard & Packaging: implemented automated pack guard `scripts/pack-check.mjs` preventing root release tarballs and enforcing DSH Store file size limit (<256 KiB) as part of `npm run check` and `npm run release` (#128, #131).
|
|
7
|
+
- Publication Boundary: established `.gitattributes` publication layer with `export-ignore` excluding internal documents, deployment scripts, plans, and `scripts/` from public exports while maintaining git tracking (#130).
|
|
8
|
+
- Error Diagnostics & Health: replaced 10 unmonitored silent catches across adapter, catalog, index, routes, and transports with `bestEffortFailed` logging via `ctx.logger`; augmented `GET /dsh-ollama/health` with provider error surfacing (`ok: false` and `error` field) on discovery failures (#131).
|
|
9
|
+
- Modularity: decomposed monolithic 6033-line `lib/index.js` into clean domain-separated modules (`routes.js`, `adapter.js`, `config.js`, etc.) with `tsdown` unbundling, reducing primary entry point to ~150 lines (#131).
|
|
10
|
+
- Repository Hygiene: audited and pruned 12 stale and detached worktrees, documenting SHAs and ancestor relationships (#129).
|
|
11
|
+
|
|
12
|
+
## 0.1.37 — 2026-11-11
|
|
13
|
+
|
|
14
|
+
- Session Integrity & Tool Calls: eliminated tool-call ID collisions across multiple steps and turns by minting globally unique UUID-based identifiers (`call_${randomUUID()}`) whenever Ollama Cloud omits `id` or returns an empty string, across both native and OpenAI-compatible transports (`src/transports/tool-call-id.ts`, `native.ts`, `openai-chat.ts`). Preserves upstream `call.id` when supplied by Ollama. Prevents session log corruption (`SessionFormatError: PTC dispatch repeats subCallId`) that previously caused multi-step conversations to silently disappear on DSH startup (GitHub #2, Gitea #125).
|
|
15
|
+
|
|
3
16
|
## 0.1.36 — 2026-11-09
|
|
4
17
|
|
|
5
18
|
- Resilience: shortened 401/403 credential rejection cooldown from 24 hours to 5 minutes, added explicit reset endpoint (`POST /dsh-ollama/cooldowns/reset`) and "Reset cooldowns" UI action in settings page, and surfaced exact remaining wait time and root cause (`INVALID_CREDENTIAL`, `QUOTA`, `RATE_LIMIT`) when all keys are cooling (#117).
|
package/README.md
CHANGED
|
@@ -93,6 +93,7 @@ graph LR
|
|
|
93
93
|
|
|
94
94
|
- **Two wire transports** chosen per model: the native Ollama API (NDJSON) and the OpenAI-compatible gateway (SSE).
|
|
95
95
|
- **Text, thinking, tool calls, images, usage and finish reasons** on both transports.
|
|
96
|
+
- **Unique tool-call IDs** minted across steps and turns, preventing session log collisions when upstream omits an id.
|
|
96
97
|
- **Live catalog** from `GET /v1/models`, enriched with capability flags from `GET /api/tags`.
|
|
97
98
|
- **Accurate limits** for the dsh picker: context window, input modalities, reasoning levels and their default, tool support, and API visibility.
|
|
98
99
|
- **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.
|
|
@@ -127,17 +128,17 @@ npm pack
|
|
|
127
128
|
Install the published package:
|
|
128
129
|
|
|
129
130
|
```bash
|
|
130
|
-
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
131
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.38
|
|
131
132
|
# DSH Desktop:
|
|
132
|
-
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
133
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.38
|
|
133
134
|
```
|
|
134
135
|
|
|
135
136
|
Or install the packed tarball into a profile:
|
|
136
137
|
|
|
137
138
|
```bash
|
|
138
|
-
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
139
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.38.tgz
|
|
139
140
|
# DSH Desktop:
|
|
140
|
-
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
141
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.38.tgz
|
|
141
142
|
```
|
|
142
143
|
|
|
143
144
|
Restart dsh (or DSH Desktop), then pick **Ollama Cloud** in the model picker.
|
package/README.ru.md
CHANGED
|
@@ -76,6 +76,7 @@ graph LR
|
|
|
76
76
|
|
|
77
77
|
- **Два транспорта**, выбираемые индивидуально для каждой модели: нативный протокол Ollama API (NDJSON) и совместимый шлюз OpenAI (SSE).
|
|
78
78
|
- **Поддержка всех режимов**: текст, reasoning/thinking, вызовы функций/инструментов, изображения (vision), подсчёт токенов и finish reasons на обоих транспортах.
|
|
79
|
+
- **Уникальные идентификаторы вызовов инструментов**: генерация глобально уникальных ID для каждого шага исключает коллизии в мультишаговых сессиях агентов и защищает журнал сессий DSH от повреждения.
|
|
79
80
|
- **Живой каталог моделей**: автоматическое чтение `GET /v1/models`, дополненное флагами возможностей `capabilities` (`tools`, `thinking`, `vision`) из `GET /api/tags`.
|
|
80
81
|
- **Точные лимиты и метаданные**: контекстное окно, входные модальности, уровни reasoning и значение по умолчанию, статус поддержки инструментов и видимость в API.
|
|
81
82
|
- **Баланс и аналитика расхода**: интеграция с официальными облачными эндпоинтами `/api/balance` и `/api/usage` — включённые и купленные кредиты, расход за 24 часа / 7 дней / 30 дней, а также группировка по моделям.
|
|
@@ -109,17 +110,17 @@ npm pack
|
|
|
109
110
|
Установка опубликованного пакета из npm:
|
|
110
111
|
|
|
111
112
|
```bash
|
|
112
|
-
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
113
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.38
|
|
113
114
|
# DSH Desktop:
|
|
114
|
-
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
115
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.38
|
|
115
116
|
```
|
|
116
117
|
|
|
117
118
|
Либо установка из упакованного tarball:
|
|
118
119
|
|
|
119
120
|
```bash
|
|
120
|
-
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
121
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.38.tgz
|
|
121
122
|
# DSH Desktop:
|
|
122
|
-
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
123
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.38.tgz
|
|
123
124
|
```
|
|
124
125
|
|
|
125
126
|
После установки перезапустите dsh (или DSH Desktop) и выберите **Ollama Cloud** в списке моделей.
|
package/README.zh.md
CHANGED
|
@@ -76,6 +76,7 @@ graph LR
|
|
|
76
76
|
|
|
77
77
|
- **两种底层传输协议**:按模型选择 Ollama 原生协议(NDJSON)或 OpenAI 兼容协议(SSE)。
|
|
78
78
|
- **全要素流式交互**:文本、深度思考(thinking)、工具调用、多模态图像、Token 统计与 finish reasons。
|
|
79
|
+
- **全局唯一工具调用 ID**:自动生成跨步不重复的工具调用标识符,彻底防止多步对话(如 PTC 预设)因 ID 冲突导致 DSH 会话日志校验失败。
|
|
79
80
|
- **实时模型目录**:自动从 `GET /v1/models` 获取模型列表,并结合 `GET /api/tags` 补全能力标记(`tools`、`thinking`、`vision`)。
|
|
80
81
|
- **精准模型元数据**:上下文长度、输入模态、推理等级与默认配置、工具支持状态及 API 开放性。
|
|
81
82
|
- **官方余额与用量分析**:集成官方 `/api/balance` 与 `/api/usage`,呈现可用额度、已购额度、24小时/7天/30天支出及按模型细分报表。
|
|
@@ -108,17 +109,17 @@ npm pack
|
|
|
108
109
|
从 npm 安装已发布版本:
|
|
109
110
|
|
|
110
111
|
```bash
|
|
111
|
-
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
112
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.38
|
|
112
113
|
# DSH 桌面端:
|
|
113
|
-
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
114
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.38
|
|
114
115
|
```
|
|
115
116
|
|
|
116
117
|
或通过打包文件安装:
|
|
117
118
|
|
|
118
119
|
```bash
|
|
119
|
-
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
120
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.38.tgz
|
|
120
121
|
# DSH 桌面端:
|
|
121
|
-
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
122
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.38.tgz
|
|
122
123
|
```
|
|
123
124
|
|
|
124
125
|
安装完成后重启 dsh 或 DSH 桌面端,在模型列表中选择 **Ollama Cloud** 即可。
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/account-rules.ts
|
|
2
|
+
function glob(pattern) {
|
|
3
|
+
const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
|
|
4
|
+
return new RegExp(`^${escaped}$`, "i");
|
|
5
|
+
}
|
|
6
|
+
/** First matching rule wins; an empty pattern or account is ignored. */
|
|
7
|
+
function matchModelAccount(model, rules) {
|
|
8
|
+
for (const rule of rules) {
|
|
9
|
+
if (rule.pattern === "" || rule.account === "") continue;
|
|
10
|
+
if (glob(rule.pattern).test(model)) return rule.account;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Pin the matching account first, keeping the rest as fallbacks. A rule that
|
|
15
|
+
* names an account not present in the pool is a no-op.
|
|
16
|
+
*/
|
|
17
|
+
function orderKeysForModel(keys, model, rules) {
|
|
18
|
+
const account = matchModelAccount(model, rules);
|
|
19
|
+
if (account === void 0) return keys;
|
|
20
|
+
const preferred = keys.find((entry) => (entry.label ?? "default") === account);
|
|
21
|
+
if (preferred === void 0) return keys;
|
|
22
|
+
return [preferred, ...keys.filter((entry) => entry !== preferred)];
|
|
23
|
+
}
|
|
24
|
+
export { matchModelAccount, orderKeysForModel };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=account-rules.js.map
|
package/lib/adapter.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ResolvedConfig } from "./config.js";
|
|
2
|
+
import { KeyResolver, ResolvedKey } from "./credentials.js";
|
|
3
|
+
import { RequestOutcome } from "./request-log.js";
|
|
4
|
+
import { GenerateOptions, LlmAdapter, LlmModelInfo, LlmProviderInfo, LlmResolvedModelInfo, ResolvedRetryPolicy, StreamChunk } from "@deepseek-ai/dsh-llm";
|
|
5
|
+
import { AttachmentStore } from "@deepseek-ai/dsh-attachment";
|
|
6
|
+
type RoutingReason = 'rule' | 'sticky' | 'pinned' | 'default' | 'rotation';
|
|
7
|
+
interface RoutingTraceEntry {
|
|
8
|
+
readonly at: number;
|
|
9
|
+
readonly provider: string;
|
|
10
|
+
readonly model: string;
|
|
11
|
+
readonly account: string;
|
|
12
|
+
readonly reason: RoutingReason;
|
|
13
|
+
readonly fallback: boolean;
|
|
14
|
+
readonly ok: boolean;
|
|
15
|
+
readonly error?: string;
|
|
16
|
+
}
|
|
17
|
+
interface OllamaCloudAdapterDeps {
|
|
18
|
+
readonly config: () => ResolvedConfig;
|
|
19
|
+
readonly resolveKey: KeyResolver;
|
|
20
|
+
readonly resolveKeys?: (provider: string) => Promise<readonly ResolvedKey[]>;
|
|
21
|
+
readonly resolveAttachments?: () => AttachmentStore | undefined;
|
|
22
|
+
readonly fetchImpl?: typeof fetch;
|
|
23
|
+
/** Test seam; defaults to the local append-only request log. */
|
|
24
|
+
readonly recordRequest?: (provider: string, model: string, purpose?: string, account?: string, reason?: string, outcome?: RequestOutcome) => void;
|
|
25
|
+
/** Test seam; defaults to ~/.dsh/storages/dsh-ollama/cooldowns.json. */
|
|
26
|
+
readonly cooldownPath?: string;
|
|
27
|
+
/** Test seam; defaults to ~/.dsh/storages/dsh-ollama/sticky.json. */
|
|
28
|
+
readonly stickyPath?: string;
|
|
29
|
+
/** Receives a one-time warning when the provider tool limit drops tools. */
|
|
30
|
+
readonly warn?: (message: string) => void;
|
|
31
|
+
}
|
|
32
|
+
declare class OllamaCloudAdapter extends LlmAdapter {
|
|
33
|
+
private readonly deps;
|
|
34
|
+
private readonly fetchImpl;
|
|
35
|
+
private readonly cooldownPath;
|
|
36
|
+
private readonly stickyPath;
|
|
37
|
+
private cooldownWrites;
|
|
38
|
+
private stickyWrites;
|
|
39
|
+
/** key fingerprint → cooldown deadline and the rejection that caused it. */
|
|
40
|
+
private readonly cooldowns;
|
|
41
|
+
/** key fingerprint + model → short preference mark for model-scoped rejections. */
|
|
42
|
+
private readonly modelCooldowns;
|
|
43
|
+
private readonly sticky;
|
|
44
|
+
private readonly routing;
|
|
45
|
+
private warnedTools;
|
|
46
|
+
constructor(deps: OllamaCloudAdapterDeps);
|
|
47
|
+
providerInfo(provider: string): LlmProviderInfo;
|
|
48
|
+
providerRetryPolicy(_provider: string): ResolvedRetryPolicy;
|
|
49
|
+
listModels(provider: string, opts?: {
|
|
50
|
+
unfiltered?: boolean;
|
|
51
|
+
}): Promise<readonly LlmModelInfo[]>;
|
|
52
|
+
/** Recent routing decisions, newest first; no keys or prompt content. */
|
|
53
|
+
routingTrace(): readonly RoutingTraceEntry[];
|
|
54
|
+
resolveModel(provider: string, model: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
|
|
55
|
+
stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
|
|
56
|
+
private run;
|
|
57
|
+
private rememberSticky;
|
|
58
|
+
/** Await pending sticky persistence writes (tests and shutdown). */
|
|
59
|
+
flushSticky(): Promise<void>;
|
|
60
|
+
private loadSticky;
|
|
61
|
+
private pruneSticky;
|
|
62
|
+
private persistSticky;
|
|
63
|
+
private pushTrace;
|
|
64
|
+
private send;
|
|
65
|
+
private keyId;
|
|
66
|
+
private coolingDown;
|
|
67
|
+
private modelKey;
|
|
68
|
+
private modelCoolingDown;
|
|
69
|
+
private markModelCooldown;
|
|
70
|
+
/**
|
|
71
|
+
* A model-scoped rejection says nothing about the key's other models:
|
|
72
|
+
* `:free` models and other paid models may still work on the same account.
|
|
73
|
+
* Only account-wide quota, credential and rate-limit responses cool the key.
|
|
74
|
+
*/
|
|
75
|
+
private modelScoped;
|
|
76
|
+
/** Current cooldown for one resolved key, if any. */
|
|
77
|
+
accountHealth(key: string): {
|
|
78
|
+
coolingUntil: number;
|
|
79
|
+
reason: string;
|
|
80
|
+
} | undefined;
|
|
81
|
+
/** Await pending cooldown persistence writes (tests and shutdown). */
|
|
82
|
+
flushCooldowns(): Promise<void>;
|
|
83
|
+
/** Manually clear all active account and model cooldowns. */
|
|
84
|
+
clearCooldowns(): void;
|
|
85
|
+
private loadCooldowns;
|
|
86
|
+
private pruneCooldowns;
|
|
87
|
+
private persistCooldowns;
|
|
88
|
+
private markCooldown;
|
|
89
|
+
private isTransient;
|
|
90
|
+
}
|
|
91
|
+
export { OllamaCloudAdapter, OllamaCloudAdapterDeps, RoutingReason, RoutingTraceEntry };
|
|
92
|
+
//# sourceMappingURL=adapter.d.ts.map
|