@goodandready/dsh-ollama-cloud-provider 0.1.17 → 0.1.18
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 +12 -0
- package/README.md +20 -4
- package/README.ru.md +4 -4
- package/README.zh.md +4 -4
- package/lib/index.d.ts +18 -1
- package/lib/index.js +157 -24
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.18 — 2026-11-05
|
|
4
|
+
|
|
5
|
+
- Added local/self-hosted Ollama mode: an explicit empty `apiKeyEnv` means no
|
|
6
|
+
authentication. Native and OpenAI requests omit `Authorization`, the key pool
|
|
7
|
+
returns a synthetic empty credential, and usage/balance requests are skipped.
|
|
8
|
+
- `/api/show` probing enriches local model discovery with context window,
|
|
9
|
+
vision, tools and thinking capabilities; successful probes are cached for five
|
|
10
|
+
minutes and cleared with the catalog cache or explicitly.
|
|
11
|
+
- Catalog discovery now falls back to `/api/tags` ids when `/v1/models` is
|
|
12
|
+
empty and adopts `/api/show` metadata for local endpoints.
|
|
13
|
+
- Added local-mode, probe-cache and no-auth tests; 109/109 tests.
|
|
14
|
+
|
|
3
15
|
## 0.1.17 — 2026-11-05
|
|
4
16
|
|
|
5
17
|
- Added Ollama web capabilities behind `ctx.web`: a search provider and a fetch
|
package/README.md
CHANGED
|
@@ -52,6 +52,22 @@ Select it in the profile:
|
|
|
52
52
|
fetchProvider: ollama-cloud
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
## Local Ollama
|
|
56
|
+
|
|
57
|
+
Set `apiKeyEnv` to an empty string and point `apiBase` at the local or
|
|
58
|
+
self-hosted Ollama server. No `Authorization` header is sent, and cloud
|
|
59
|
+
usage/balance reads are skipped.
|
|
60
|
+
|
|
61
|
+
```yaml
|
|
62
|
+
- id: llm-ollama-cloud
|
|
63
|
+
config:
|
|
64
|
+
apiKeyEnv: ''
|
|
65
|
+
apiBase: http://127.0.0.1:11434
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Local model discovery uses `/api/tags` and enriches each model through
|
|
69
|
+
`/api/show`; successful capability probes are cached for five minutes.
|
|
70
|
+
|
|
55
71
|
## Architecture
|
|
56
72
|
|
|
57
73
|
```mermaid
|
|
@@ -121,17 +137,17 @@ npm pack
|
|
|
121
137
|
Install the published package:
|
|
122
138
|
|
|
123
139
|
```bash
|
|
124
|
-
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
140
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.18
|
|
125
141
|
# DSH Desktop:
|
|
126
|
-
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
142
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.18
|
|
127
143
|
```
|
|
128
144
|
|
|
129
145
|
Or install the packed tarball into a profile:
|
|
130
146
|
|
|
131
147
|
```bash
|
|
132
|
-
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
148
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.18.tgz
|
|
133
149
|
# DSH Desktop:
|
|
134
|
-
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
150
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.18.tgz
|
|
135
151
|
```
|
|
136
152
|
|
|
137
153
|
Restart dsh (or DSH Desktop), then pick **Ollama Cloud** in the model picker.
|
package/README.ru.md
CHANGED
|
@@ -103,17 +103,17 @@ npm pack
|
|
|
103
103
|
Установка опубликованного пакета из npm:
|
|
104
104
|
|
|
105
105
|
```bash
|
|
106
|
-
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
106
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.18
|
|
107
107
|
# DSH Desktop:
|
|
108
|
-
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
108
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.18
|
|
109
109
|
```
|
|
110
110
|
|
|
111
111
|
Либо установка из упакованного tarball:
|
|
112
112
|
|
|
113
113
|
```bash
|
|
114
|
-
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
114
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.18.tgz
|
|
115
115
|
# DSH Desktop:
|
|
116
|
-
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
116
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.18.tgz
|
|
117
117
|
```
|
|
118
118
|
|
|
119
119
|
После установки перезапустите dsh (или DSH Desktop) и выберите **Ollama Cloud** в списке моделей.
|
package/README.zh.md
CHANGED
|
@@ -102,17 +102,17 @@ npm pack
|
|
|
102
102
|
从 npm 安装已发布版本:
|
|
103
103
|
|
|
104
104
|
```bash
|
|
105
|
-
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
105
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.18
|
|
106
106
|
# DSH 桌面端:
|
|
107
|
-
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
107
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.18
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
或通过打包文件安装:
|
|
111
111
|
|
|
112
112
|
```bash
|
|
113
|
-
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
113
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.18.tgz
|
|
114
114
|
# DSH 桌面端:
|
|
115
|
-
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
115
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.18.tgz
|
|
116
116
|
```
|
|
117
117
|
|
|
118
118
|
安装完成后重启 dsh 或 DSH 桌面端,在模型列表中选择 **Ollama Cloud** 即可。
|
package/lib/index.d.ts
CHANGED
|
@@ -439,6 +439,23 @@ interface EffectiveModel extends OllamaCloudModelMeta {
|
|
|
439
439
|
}
|
|
440
440
|
declare function effectiveModel(id: string, config: ResolvedConfig): EffectiveModel;
|
|
441
441
|
declare function describeModel(meta: EffectiveModel, config: ResolvedConfig): string;
|
|
442
|
+
interface ModelProbe {
|
|
443
|
+
readonly contextWindow?: number;
|
|
444
|
+
readonly input: readonly ('text' | 'image')[];
|
|
445
|
+
readonly reasoning: readonly string[];
|
|
446
|
+
readonly reasoningToggle: boolean;
|
|
447
|
+
readonly tools: boolean;
|
|
448
|
+
readonly available: boolean;
|
|
449
|
+
}
|
|
450
|
+
/** Probe one local model via `/api/show`, caching successful answers for five minutes. */
|
|
451
|
+
declare function probeModel(config: ResolvedConfig, model: string, fetchImpl?: typeof fetch): Promise<ModelProbe | undefined>;
|
|
452
|
+
/** Clear all probe entries, or only entries for one endpoint. */
|
|
453
|
+
declare function clearModelProbeCache(baseURL?: string): void;
|
|
454
|
+
declare function modelProbeCacheInfo(): Array<{
|
|
455
|
+
baseURL: string;
|
|
456
|
+
model: string;
|
|
457
|
+
at: number;
|
|
458
|
+
}>;
|
|
442
459
|
declare const name = "llm-ollama-cloud";
|
|
443
460
|
declare const inject: string[];
|
|
444
461
|
/**
|
|
@@ -447,5 +464,5 @@ declare const inject: string[];
|
|
|
447
464
|
* without a restart.
|
|
448
465
|
*/
|
|
449
466
|
declare function apply(ctx: Context, config: Config): void;
|
|
450
|
-
export { type CommandDeps, Config, type Config as OllamaCloudConfig, OllamaCloudAdapter, type OllamaCloudAdapterDeps, PROVIDER, type ResolvedConfig, type ResolvedKey, type RouteDeps, type TransportId, type UsageReport, type UsageResult, type UsageWindow, apply, applyCommands, applyRoutes, classifyResponseError, clearCatalogCache, createKeyPool, createKeyResolver, createUsageReader, describeModel, effectiveModel, inject, name, normalizeBalance, normalizeUsage, resolveConfig };
|
|
467
|
+
export { type CommandDeps, Config, type Config as OllamaCloudConfig, OllamaCloudAdapter, type OllamaCloudAdapterDeps, PROVIDER, type ResolvedConfig, type ResolvedKey, type RouteDeps, type TransportId, type UsageReport, type UsageResult, type UsageWindow, apply, applyCommands, applyRoutes, classifyResponseError, clearCatalogCache, clearModelProbeCache, createKeyPool, createKeyResolver, createUsageReader, describeModel, effectiveModel, inject, modelProbeCacheInfo, name, normalizeBalance, normalizeUsage, probeModel, resolveConfig };
|
|
451
468
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -50,7 +50,7 @@ const DEFAULT_API_BASE = "https://ollama.com";
|
|
|
50
50
|
const DEFAULT_OPENAI_BASE = "https://ollama.com/v1";
|
|
51
51
|
const DEFAULT_USAGE_URL = "https://ollama.com/api/usage";
|
|
52
52
|
const DEFAULT_BALANCE_URL = "https://ollama.com/api/balance";
|
|
53
|
-
const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.
|
|
53
|
+
const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.18";
|
|
54
54
|
const DEFAULT_CONTEXT_WINDOW = 131072;
|
|
55
55
|
const DEFAULT_MAX_TOKENS = 32768;
|
|
56
56
|
const DEFAULT_GENERATE_MAX_TOKENS = 131072;
|
|
@@ -159,7 +159,7 @@ function resolveConfig(config) {
|
|
|
159
159
|
const apiKey = typeof config.apiKey === "string" && config.apiKey.trim() !== "" ? config.apiKey.trim() : void 0;
|
|
160
160
|
const visibleModels = Array.isArray(config.visibleModels) ? config.visibleModels.filter((id) => typeof id === "string" && id !== "") : [];
|
|
161
161
|
return {
|
|
162
|
-
apiKeyEnv: typeof config.apiKeyEnv === "string"
|
|
162
|
+
apiKeyEnv: typeof config.apiKeyEnv === "string" ? config.apiKeyEnv.trim() : DEFAULT_API_KEY_ENV,
|
|
163
163
|
...apiKey === void 0 ? {} : { apiKey },
|
|
164
164
|
apiBase: typeof config.apiBase === "string" && config.apiBase !== "" ? config.apiBase : DEFAULT_API_BASE,
|
|
165
165
|
openAiBase: typeof config.openAiBase === "string" && config.openAiBase !== "" ? config.openAiBase : DEFAULT_OPENAI_BASE,
|
|
@@ -682,6 +682,113 @@ const GENERATED_MODELS = {
|
|
|
682
682
|
}
|
|
683
683
|
}
|
|
684
684
|
};
|
|
685
|
+
// src/routing.ts
|
|
686
|
+
function trim(url) {
|
|
687
|
+
return url.replace(/\/+$/, "");
|
|
688
|
+
}
|
|
689
|
+
function rootFor(config) {
|
|
690
|
+
return trim(config.apiBase);
|
|
691
|
+
}
|
|
692
|
+
function modelsUrlFor(config) {
|
|
693
|
+
return `${rootFor(config)}/v1/models`;
|
|
694
|
+
}
|
|
695
|
+
function tagsUrlFor(config) {
|
|
696
|
+
return `${rootFor(config)}/api/tags`;
|
|
697
|
+
}
|
|
698
|
+
/** Endpoint for one model and one wire protocol. */
|
|
699
|
+
function endpointFor(transport, config) {
|
|
700
|
+
return transport === "openai-chat" ? `${trim(config.openAiBase)}/chat/completions` : `${rootFor(config)}/api/chat`;
|
|
701
|
+
}
|
|
702
|
+
// src/model-probe.ts
|
|
703
|
+
const PROBE_TTL_MS = 3e5;
|
|
704
|
+
const cache$2 = /* @__PURE__ */ new Map();
|
|
705
|
+
function keyOf(config, model) {
|
|
706
|
+
return `${rootFor(config)}|${model}`;
|
|
707
|
+
}
|
|
708
|
+
function isLocalEndpoint(config) {
|
|
709
|
+
if (config.apiKeyEnv === "") return true;
|
|
710
|
+
try {
|
|
711
|
+
const host = new URL(config.apiBase).hostname;
|
|
712
|
+
return host === "127.0.0.1" || host === "localhost" || host === "::1" || host === "[::1]";
|
|
713
|
+
} catch {
|
|
714
|
+
return false;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
function contextOf(info) {
|
|
718
|
+
let best;
|
|
719
|
+
for (const [key, value] of Object.entries(info)) {
|
|
720
|
+
if (!key.endsWith(".context_length")) continue;
|
|
721
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) continue;
|
|
722
|
+
best = best === void 0 ? value : Math.max(best, value);
|
|
723
|
+
}
|
|
724
|
+
return best === void 0 ? void 0 : Math.trunc(best);
|
|
725
|
+
}
|
|
726
|
+
function probeOf(body) {
|
|
727
|
+
if (typeof body !== "object" || body === null || Array.isArray(body)) return void 0;
|
|
728
|
+
const record = body;
|
|
729
|
+
const info = typeof record.model_info === "object" && record.model_info !== null ? record.model_info : {};
|
|
730
|
+
const capabilities = Array.isArray(record.capabilities) ? record.capabilities.filter((entry) => typeof entry === "string") : [];
|
|
731
|
+
const thinking = capabilities.includes("thinking");
|
|
732
|
+
const vision = capabilities.includes("vision");
|
|
733
|
+
const contextWindow = contextOf(info);
|
|
734
|
+
const input = vision ? ["text", "image"] : ["text"];
|
|
735
|
+
return {
|
|
736
|
+
...contextWindow === void 0 ? {} : { contextWindow },
|
|
737
|
+
input,
|
|
738
|
+
reasoning: thinking ? ["off", "high"] : [],
|
|
739
|
+
reasoningToggle: thinking,
|
|
740
|
+
tools: capabilities.includes("tools"),
|
|
741
|
+
available: true
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
/** Probe one local model via `/api/show`, caching successful answers for five minutes. */
|
|
745
|
+
async function probeModel(config, model, fetchImpl = fetch) {
|
|
746
|
+
if (!isLocalEndpoint(config)) return void 0;
|
|
747
|
+
const key = keyOf(config, model);
|
|
748
|
+
const hit = cache$2.get(key);
|
|
749
|
+
if (hit !== void 0 && Date.now() - hit.at < PROBE_TTL_MS) return hit.value;
|
|
750
|
+
try {
|
|
751
|
+
const response = await fetchImpl(`${rootFor(config)}/api/show`, {
|
|
752
|
+
method: "POST",
|
|
753
|
+
headers: {
|
|
754
|
+
accept: "application/json",
|
|
755
|
+
"content-type": "application/json",
|
|
756
|
+
"user-agent": config.userAgent
|
|
757
|
+
},
|
|
758
|
+
body: JSON.stringify({ model }),
|
|
759
|
+
signal: AbortSignal.timeout(1e4)
|
|
760
|
+
});
|
|
761
|
+
if (!response.ok) return void 0;
|
|
762
|
+
const value = probeOf(await response.json());
|
|
763
|
+
if (value === void 0) return void 0;
|
|
764
|
+
cache$2.set(key, {
|
|
765
|
+
at: Date.now(),
|
|
766
|
+
value
|
|
767
|
+
});
|
|
768
|
+
return value;
|
|
769
|
+
} catch {
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
/** Clear all probe entries, or only entries for one endpoint. */
|
|
774
|
+
function clearModelProbeCache(baseURL) {
|
|
775
|
+
if (baseURL === void 0) {
|
|
776
|
+
cache$2.clear();
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
const prefix = `${baseURL.replace(/\/+$/, "")}|`;
|
|
780
|
+
for (const key of cache$2.keys()) if (key.startsWith(prefix)) cache$2.delete(key);
|
|
781
|
+
}
|
|
782
|
+
function modelProbeCacheInfo() {
|
|
783
|
+
return [...cache$2.entries()].map(([key, entry]) => {
|
|
784
|
+
const separator = key.indexOf("|");
|
|
785
|
+
return {
|
|
786
|
+
baseURL: key.slice(0, separator),
|
|
787
|
+
model: key.slice(separator + 1),
|
|
788
|
+
at: entry.at
|
|
789
|
+
};
|
|
790
|
+
});
|
|
791
|
+
}
|
|
685
792
|
// src/pricing.ts
|
|
686
793
|
/** `gpt-oss:120b` → `gpt-oss`; used as the second lookup key. */
|
|
687
794
|
function baseIdOf(id) {
|
|
@@ -756,23 +863,6 @@ function formatUsd(value) {
|
|
|
756
863
|
if (Math.abs(value) >= .01) return `$${value.toFixed(3)}`;
|
|
757
864
|
return `$${value.toFixed(4)}`;
|
|
758
865
|
}
|
|
759
|
-
// src/routing.ts
|
|
760
|
-
function trim(url) {
|
|
761
|
-
return url.replace(/\/+$/, "");
|
|
762
|
-
}
|
|
763
|
-
function rootFor(config) {
|
|
764
|
-
return trim(config.apiBase);
|
|
765
|
-
}
|
|
766
|
-
function modelsUrlFor(config) {
|
|
767
|
-
return `${rootFor(config)}/v1/models`;
|
|
768
|
-
}
|
|
769
|
-
function tagsUrlFor(config) {
|
|
770
|
-
return `${rootFor(config)}/api/tags`;
|
|
771
|
-
}
|
|
772
|
-
/** Endpoint for one model and one wire protocol. */
|
|
773
|
-
function endpointFor(transport, config) {
|
|
774
|
-
return transport === "openai-chat" ? `${trim(config.openAiBase)}/chat/completions` : `${rootFor(config)}/api/chat`;
|
|
775
|
-
}
|
|
776
866
|
// src/catalog.ts
|
|
777
867
|
const CATALOG_TTL_MS = 6e5;
|
|
778
868
|
const CATALOG_TIMEOUT_MS = 15e3;
|
|
@@ -856,6 +946,36 @@ function metaFromLive(entry, caps) {
|
|
|
856
946
|
}
|
|
857
947
|
};
|
|
858
948
|
}
|
|
949
|
+
function metaFromProbe(id, probe) {
|
|
950
|
+
if (probe === void 0) return void 0;
|
|
951
|
+
const base = GENERATED_MODELS[id];
|
|
952
|
+
return {
|
|
953
|
+
id,
|
|
954
|
+
name: base?.name ?? id,
|
|
955
|
+
transport: base?.transport ?? "native",
|
|
956
|
+
contextWindow: probe.contextWindow ?? base?.contextWindow ?? 131072,
|
|
957
|
+
maxTokens: base?.maxTokens ?? 32768,
|
|
958
|
+
input: [...probe.input],
|
|
959
|
+
reasoning: probe.reasoning.length > 0 ? [...probe.reasoning] : base?.reasoning ?? [],
|
|
960
|
+
reasoningToggle: probe.reasoningToggle || base?.reasoningToggle === true,
|
|
961
|
+
tools: probe.tools || base?.tools === true,
|
|
962
|
+
free: base?.free === true,
|
|
963
|
+
available: probe.available,
|
|
964
|
+
...base?.defaultReasoning === void 0 ? {} : { defaultReasoning: base.defaultReasoning },
|
|
965
|
+
cost: base?.cost ?? {
|
|
966
|
+
input: 0,
|
|
967
|
+
output: 0,
|
|
968
|
+
cacheRead: 0
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
async function adoptProbes(config, ids, base, fetchImpl) {
|
|
973
|
+
const probes = await Promise.all(ids.slice(0, 64).map(async (id) => ({
|
|
974
|
+
id,
|
|
975
|
+
meta: metaFromProbe(id, await probeModel(config, id, fetchImpl))
|
|
976
|
+
})));
|
|
977
|
+
for (const { id, meta } of probes) if (meta !== void 0) liveMeta.set(liveKey(base, id), meta);
|
|
978
|
+
}
|
|
859
979
|
/** Replace the in-memory live metadata for one API base with one successful response. */
|
|
860
980
|
function adoptLive(models, tags, base) {
|
|
861
981
|
const caps = capabilitiesByModel(tags);
|
|
@@ -923,13 +1043,16 @@ async function refreshNow(config, fetchImpl, key, keepOnFailure, epoch) {
|
|
|
923
1043
|
}
|
|
924
1044
|
}
|
|
925
1045
|
const fromData = Array.isArray(payload.data) ? payload.data.map((entry) => str$1(entry.id)).filter((id) => id !== void 0) : [];
|
|
926
|
-
|
|
1046
|
+
const fromTags = ((tagsResult.status === "fulfilled" ? tagsResult.value : void 0)?.models ?? []).map((entry) => str$1(entry.name) ?? str$1(entry.model)).filter((id) => id !== void 0);
|
|
1047
|
+
const ids = fromData.length > 0 ? fromData : fromTags;
|
|
1048
|
+
if (ids.length > 0) {
|
|
927
1049
|
for (const liveKey of liveMeta.keys()) if (liveKey.startsWith(`${key}|`)) liveMeta.delete(liveKey);
|
|
1050
|
+
if (isLocalEndpoint(config)) await adoptProbes(config, ids, key, fetchImpl);
|
|
928
1051
|
cache$1.set(key, {
|
|
929
1052
|
at: Date.now(),
|
|
930
|
-
ids
|
|
1053
|
+
ids
|
|
931
1054
|
});
|
|
932
|
-
return
|
|
1055
|
+
return ids;
|
|
933
1056
|
}
|
|
934
1057
|
}
|
|
935
1058
|
if (keepOnFailure) {
|
|
@@ -955,6 +1078,7 @@ function clearCatalogCache() {
|
|
|
955
1078
|
cache$1.clear();
|
|
956
1079
|
inflight.clear();
|
|
957
1080
|
liveMeta.clear();
|
|
1081
|
+
clearModelProbeCache();
|
|
958
1082
|
}
|
|
959
1083
|
function baseMeta(id, base) {
|
|
960
1084
|
const meta = liveMeta.get(liveKey(base, id)) ?? GENERATED_MODELS[id];
|
|
@@ -2581,7 +2705,7 @@ var OllamaCloudAdapter = class extends LlmAdapter {
|
|
|
2581
2705
|
async send(url, key, model, body, config, signal) {
|
|
2582
2706
|
const headers = {
|
|
2583
2707
|
...attributionHeaders(),
|
|
2584
|
-
authorization: `Bearer ${key}
|
|
2708
|
+
...key === "" ? {} : { authorization: `Bearer ${key}` },
|
|
2585
2709
|
"content-type": "application/json",
|
|
2586
2710
|
accept: model.transport === "openai-chat" ? "text/event-stream" : "application/x-ndjson",
|
|
2587
2711
|
"user-agent": config.userAgent
|
|
@@ -3047,6 +3171,12 @@ async function resolveSlot(ctx, slot) {
|
|
|
3047
3171
|
function createKeyPool(ctx, config) {
|
|
3048
3172
|
const all = async () => {
|
|
3049
3173
|
const current = config();
|
|
3174
|
+
const hasConfiguredKey = current.apiKey !== void 0 || current.accounts.some((account) => typeof account.apiKey === "string" && account.apiKey.trim() !== "" || typeof account.apiKeyEnv === "string" && account.apiKeyEnv.trim() !== "");
|
|
3175
|
+
if (current.apiKeyEnv === "" && !hasConfiguredKey) return [{
|
|
3176
|
+
key: "",
|
|
3177
|
+
source: "none",
|
|
3178
|
+
label: "default"
|
|
3179
|
+
}];
|
|
3050
3180
|
const pinned = current.activeAccount.trim();
|
|
3051
3181
|
const slots = slotsOf(current);
|
|
3052
3182
|
if (pinned !== "") {
|
|
@@ -3999,6 +4129,7 @@ function configOps(patch) {
|
|
|
3999
4129
|
};
|
|
4000
4130
|
if ("apiKeyEnv" in patch) {
|
|
4001
4131
|
if (patch.apiKeyEnv === null || patch.apiKeyEnv === void 0) set("apiKeyEnv", void 0);
|
|
4132
|
+
else if (typeof patch.apiKeyEnv === "string" && patch.apiKeyEnv.trim() === "") set("apiKeyEnv", "");
|
|
4002
4133
|
else {
|
|
4003
4134
|
const ref = normalizeCredentialRef(patch.apiKeyEnv);
|
|
4004
4135
|
if (ref === void 0) throw new Error("invalid credential reference");
|
|
@@ -4771,6 +4902,7 @@ function createUsageReader(config, resolveKey, fetchImpl = fetch) {
|
|
|
4771
4902
|
});
|
|
4772
4903
|
};
|
|
4773
4904
|
const readBalance = async (key) => {
|
|
4905
|
+
if (key === "") return void 0;
|
|
4774
4906
|
const current = config();
|
|
4775
4907
|
try {
|
|
4776
4908
|
const response = await request(current.balanceUrl, key);
|
|
@@ -4781,6 +4913,7 @@ function createUsageReader(config, resolveKey, fetchImpl = fetch) {
|
|
|
4781
4913
|
}
|
|
4782
4914
|
};
|
|
4783
4915
|
const readUsage = async (key, range, epoch) => {
|
|
4916
|
+
if (key === "") return void 0;
|
|
4784
4917
|
const current = config();
|
|
4785
4918
|
const cacheKey = `${fingerprint(key)}:${range}`;
|
|
4786
4919
|
const hit = cached(cacheKey);
|
|
@@ -5101,6 +5234,6 @@ function apply(ctx, config) {
|
|
|
5101
5234
|
}), "dsh-ollama-cloud-provider: plugin updater");
|
|
5102
5235
|
});
|
|
5103
5236
|
}
|
|
5104
|
-
export { Config, OllamaCloudAdapter, PROVIDER, apply, applyCommands, applyRoutes, classifyResponseError, clearCatalogCache, createKeyPool, createKeyResolver, createUsageReader, describeModel, effectiveModel, inject, name, normalizeBalance, normalizeUsage, resolveConfig };
|
|
5237
|
+
export { Config, OllamaCloudAdapter, PROVIDER, apply, applyCommands, applyRoutes, classifyResponseError, clearCatalogCache, clearModelProbeCache, createKeyPool, createKeyResolver, createUsageReader, describeModel, effectiveModel, inject, modelProbeCacheInfo, name, normalizeBalance, normalizeUsage, probeModel, resolveConfig };
|
|
5105
5238
|
|
|
5106
5239
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodandready/dsh-ollama-cloud-provider",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Ollama Cloud LLM provider plugin for DeepSeek Harness (dsh).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"build": "tsdown",
|
|
74
74
|
"prepare": "tsdown 1>&2",
|
|
75
75
|
"typecheck": "tsc --noEmit",
|
|
76
|
-
"test": "node --import tsx --test tests/core.test.ts tests/usage.test.ts tests/adapter.test.ts tests/routes.test.ts tests/native.test.ts tests/openai-chat.test.ts tests/commands.test.ts tests/tui-settings.test.ts tests/analytics.test.ts tests/apply.test.ts tests/account-rules.test.ts tests/request-log.test.ts tests/image-budget.test.ts tests/tool-schema.test.ts tests/tools.test.ts tests/plugin-updater.test.ts tests/compat.test.ts tests/status.test.ts tests/settings-draft.test.ts tests/update-state.test.ts tests/ui-render.test.tsx tests/update-card-view.test.tsx tests/web.test.ts tests/mock-ollama.test.ts",
|
|
76
|
+
"test": "node --import tsx --test tests/core.test.ts tests/usage.test.ts tests/adapter.test.ts tests/routes.test.ts tests/native.test.ts tests/openai-chat.test.ts tests/commands.test.ts tests/tui-settings.test.ts tests/analytics.test.ts tests/apply.test.ts tests/account-rules.test.ts tests/request-log.test.ts tests/image-budget.test.ts tests/tool-schema.test.ts tests/tools.test.ts tests/plugin-updater.test.ts tests/compat.test.ts tests/status.test.ts tests/settings-draft.test.ts tests/update-state.test.ts tests/ui-render.test.tsx tests/update-card-view.test.tsx tests/web.test.ts tests/mock-ollama.test.ts tests/local.test.ts",
|
|
77
77
|
"check": "npm run typecheck && npm test && npm run build",
|
|
78
78
|
"release": "npm run check && npm pack",
|
|
79
79
|
"sync:models": "node scripts/sync-models.mjs"
|