@goodandready/dsh-ollama-cloud-provider 0.1.37 → 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 +9 -0
- package/README.md +4 -4
- package/README.ru.md +4 -4
- package/README.zh.md +4 -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 -5921
- 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 +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
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
|
+
|
|
3
12
|
## 0.1.37 — 2026-11-11
|
|
4
13
|
|
|
5
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).
|
package/README.md
CHANGED
|
@@ -128,17 +128,17 @@ npm pack
|
|
|
128
128
|
Install the published package:
|
|
129
129
|
|
|
130
130
|
```bash
|
|
131
|
-
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
|
|
132
132
|
# DSH Desktop:
|
|
133
|
-
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
|
|
134
134
|
```
|
|
135
135
|
|
|
136
136
|
Or install the packed tarball into a profile:
|
|
137
137
|
|
|
138
138
|
```bash
|
|
139
|
-
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
|
|
140
140
|
# DSH Desktop:
|
|
141
|
-
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
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
Restart dsh (or DSH Desktop), then pick **Ollama Cloud** in the model picker.
|
package/README.ru.md
CHANGED
|
@@ -110,17 +110,17 @@ npm pack
|
|
|
110
110
|
Установка опубликованного пакета из npm:
|
|
111
111
|
|
|
112
112
|
```bash
|
|
113
|
-
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
|
|
114
114
|
# DSH Desktop:
|
|
115
|
-
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
|
|
116
116
|
```
|
|
117
117
|
|
|
118
118
|
Либо установка из упакованного tarball:
|
|
119
119
|
|
|
120
120
|
```bash
|
|
121
|
-
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
|
|
122
122
|
# DSH Desktop:
|
|
123
|
-
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
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
После установки перезапустите dsh (или DSH Desktop) и выберите **Ollama Cloud** в списке моделей.
|
package/README.zh.md
CHANGED
|
@@ -109,17 +109,17 @@ npm pack
|
|
|
109
109
|
从 npm 安装已发布版本:
|
|
110
110
|
|
|
111
111
|
```bash
|
|
112
|
-
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
|
|
113
113
|
# DSH 桌面端:
|
|
114
|
-
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
|
|
115
115
|
```
|
|
116
116
|
|
|
117
117
|
或通过打包文件安装:
|
|
118
118
|
|
|
119
119
|
```bash
|
|
120
|
-
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
|
|
121
121
|
# DSH 桌面端:
|
|
122
|
-
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
|
|
123
123
|
```
|
|
124
124
|
|
|
125
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
|