@goodandready/dsh-ollama-cloud-provider 0.1.21 → 0.1.23

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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.23 — 2026-11-05
4
+
5
+ - Richer model catalog rows grouped by effective context, collapsible groups,
6
+ drag reorder persisted as `modelOrder`, and context labels/badges.
7
+ - Added manual catalog entries/overrides with id, display name, context,
8
+ max output, vision, thinking, reasoning efforts/default and tools. Entries
9
+ merge over live discovery; disabled entries are hidden from the picker and
10
+ invalid ids are rejected.
11
+ - Added model grouping/reorder/render tests and manual merge tests; 128/128.
12
+
13
+ ## 0.1.22 — 2026-11-05
14
+
15
+ - Added `/ollama-context` with 4k/8k/16k/32k/64k/128k presets, custom token
16
+ values, follow, status and reset. The override is session-scoped and wins
17
+ over configured `num_ctx`; sessions remain isolated.
18
+ - Added an independent whole-attempt budget (`attemptTimeoutMs`, default off)
19
+ for chat, catalog and web requests. Each retry gets a fresh budget; caller
20
+ cancellation is distinguished from timeout.
21
+ - Added settings for the attempt budget and tests for budget/timeout/session
22
+ isolation; 124/124 tests.
23
+
3
24
  ## 0.1.21 — 2026-11-05
4
25
 
5
26
  - Added local Ollama model management: `/api/tags` disk inventory, `/api/ps`
package/README.md CHANGED
@@ -137,17 +137,17 @@ npm pack
137
137
  Install the published package:
138
138
 
139
139
  ```bash
140
- dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.21
140
+ dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.23
141
141
  # DSH Desktop:
142
- dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.21
142
+ dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.23
143
143
  ```
144
144
 
145
145
  Or install the packed tarball into a profile:
146
146
 
147
147
  ```bash
148
- dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.21.tgz
148
+ dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.23.tgz
149
149
  # DSH Desktop:
150
- dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.21.tgz
150
+ dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.23.tgz
151
151
  ```
152
152
 
153
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.21
106
+ dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.23
107
107
  # DSH Desktop:
108
- dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.21
108
+ dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.23
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.21.tgz
114
+ dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.23.tgz
115
115
  # DSH Desktop:
116
- dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.21.tgz
116
+ dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.23.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.21
105
+ dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.23
106
106
  # DSH 桌面端:
107
- dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.21
107
+ dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.23
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.21.tgz
113
+ dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.23.tgz
114
114
  # DSH 桌面端:
115
- dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.21.tgz
115
+ dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.23.tgz
116
116
  ```
117
117
 
118
118
  安装完成后重启 dsh 或 DSH 桌面端,在模型列表中选择 **Ollama Cloud** 即可。
package/lib/client.js CHANGED
@@ -120,8 +120,23 @@ window.__ModuleLoader__.load({
120
120
  balanceUrl: "Balance endpoint",
121
121
  requestTimeoutMs: "Header timeout (ms)",
122
122
  streamIdleTimeoutMs: "Stream idle timeout (ms)",
123
+ attemptTimeoutMs: "Attempt budget (ms, 0 = off)",
124
+ attemptTimeoutHint: "Whole-attempt timeout; a fresh budget is created for every retry.",
123
125
  maxOutputTokens: "Output limit (0 = provider default)",
124
126
  contextWindow: "Context window override",
127
+ contextGroup: "context",
128
+ dragOrder: "Drag to reorder",
129
+ manualModels: "Manual catalog entries",
130
+ manualModelsHint: "Add or override models beyond live discovery. Disabled entries stay visible here but are hidden from the picker.",
131
+ addManualModel: "Add model",
132
+ removeManualModel: "Remove entry",
133
+ modelId: "Model id",
134
+ modelName: "Display name",
135
+ maxTokens: "Max output tokens",
136
+ reasoningEfforts: "Reasoning efforts",
137
+ manualEffortsHint: "Comma-separated levels, e.g. off, low, medium, high.",
138
+ defaultReasoning: "Default effort",
139
+ enabled: "Enabled",
125
140
  generation: "Generation defaults",
126
141
  generationHint: "Native Ollama defaults. Empty fields are not sent; request options still win.",
127
142
  temperature: "Temperature",
@@ -330,8 +345,23 @@ window.__ModuleLoader__.load({
330
345
  balanceUrl: "余额端点",
331
346
  requestTimeoutMs: "响应头超时(毫秒)",
332
347
  streamIdleTimeoutMs: "流空闲超时(毫秒)",
348
+ attemptTimeoutMs: "单次尝试预算(毫秒,0 = 关闭)",
349
+ attemptTimeoutHint: "整次尝试超时;每次重试都会创建新的预算。",
333
350
  maxOutputTokens: "输出上限(0 = 提供方默认)",
334
351
  contextWindow: "上下文窗口覆盖",
352
+ contextGroup: "上下文",
353
+ dragOrder: "拖动排序",
354
+ manualModels: "手动目录条目",
355
+ manualModelsHint: "在实时发现之外添加或覆盖模型。禁用条目仍在此显示,但会从选择器隐藏。",
356
+ addManualModel: "添加模型",
357
+ removeManualModel: "删除条目",
358
+ modelId: "模型 ID",
359
+ modelName: "显示名称",
360
+ maxTokens: "最大输出 token",
361
+ reasoningEfforts: "推理档位",
362
+ manualEffortsHint: "逗号分隔,例如 off, low, medium, high。",
363
+ defaultReasoning: "默认档位",
364
+ enabled: "启用",
335
365
  generation: "生成默认值",
336
366
  generationHint: "Ollama 原生默认值;空字段不发送,请求参数优先。",
337
367
  temperature: "Temperature",
@@ -1648,6 +1678,7 @@ window.__ModuleLoader__.load({
1648
1678
  transport: state.config.transport,
1649
1679
  requestTimeoutMs: String(state.config.requestTimeoutMs),
1650
1680
  streamIdleTimeoutMs: String(state.config.streamIdleTimeoutMs),
1681
+ attemptTimeoutMs: String(state.config.attemptTimeoutMs ?? 0),
1651
1682
  maxOutputTokens: textOf(state.config.maxOutputTokens),
1652
1683
  contextWindow: textOf(state.config.contextWindow),
1653
1684
  temperature: textOf(state.config.temperature),
@@ -1670,6 +1701,20 @@ window.__ModuleLoader__.load({
1670
1701
  stickySession: state.config.stickySession,
1671
1702
  visibleModels: state.config.showAllModels ? allIds : [...state.config.visibleModels],
1672
1703
  filterModelsByPlan: state.config.filterModelsByPlan,
1704
+ modelVisibility: { ...state.config.modelVisibility },
1705
+ manualModels: (state.config.manualModels ?? []).map((model) => ({
1706
+ id: model.id,
1707
+ enabled: model.enabled !== false,
1708
+ name: model.name ?? "",
1709
+ contextWindow: model.contextWindow === void 0 ? "" : String(model.contextWindow),
1710
+ maxTokens: model.maxTokens === void 0 ? "" : String(model.maxTokens),
1711
+ image: model.image === true,
1712
+ thinking: model.thinking === true,
1713
+ reasoningEfforts: (model.reasoningEfforts ?? []).join(", "),
1714
+ defaultReasoning: model.defaultReasoning ?? "",
1715
+ tools: model.tools === true
1716
+ })),
1717
+ modelOrder: [...state.config.modelOrder ?? []],
1673
1718
  showAll: state.config.showAllModels,
1674
1719
  modelTransports: { ...state.config.modelTransports }
1675
1720
  };
@@ -1701,6 +1746,7 @@ window.__ModuleLoader__.load({
1701
1746
  transport: draft.transport,
1702
1747
  requestTimeoutMs: numberOrNull(draft.requestTimeoutMs) ?? 3e5,
1703
1748
  streamIdleTimeoutMs: numberOrNull(draft.streamIdleTimeoutMs) ?? 3e5,
1749
+ attemptTimeoutMs: boundedNumber(draft.attemptTimeoutMs, 0, 36e5, true) ?? 0,
1704
1750
  maxOutputTokens: numberOrNull(draft.maxOutputTokens),
1705
1751
  contextWindow: numberOrNull(draft.contextWindow),
1706
1752
  temperature: boundedNumber(draft.temperature, 0, 2, false),
@@ -1730,6 +1776,20 @@ window.__ModuleLoader__.load({
1730
1776
  visibleModels: draft.showAll ? [] : draft.visibleModels,
1731
1777
  showAllModels: draft.showAll,
1732
1778
  filterModelsByPlan: draft.filterModelsByPlan,
1779
+ modelVisibility: draft.modelVisibility,
1780
+ manualModels: draft.manualModels.filter((model) => model.id.trim() !== "").map((model) => ({
1781
+ id: model.id.trim(),
1782
+ enabled: model.enabled,
1783
+ ...model.name.trim() === "" ? {} : { name: model.name.trim() },
1784
+ ...numberOrNull(model.contextWindow) === null ? {} : { contextWindow: numberOrNull(model.contextWindow) },
1785
+ ...numberOrNull(model.maxTokens) === null ? {} : { maxTokens: numberOrNull(model.maxTokens) },
1786
+ image: model.image,
1787
+ thinking: model.thinking,
1788
+ ...stopList(model.reasoningEfforts).length === 0 ? {} : { reasoningEfforts: stopList(model.reasoningEfforts) },
1789
+ ...model.defaultReasoning.trim() === "" ? {} : { defaultReasoning: model.defaultReasoning.trim() },
1790
+ tools: model.tools
1791
+ })),
1792
+ modelOrder: draft.modelOrder.filter((id) => id !== ""),
1733
1793
  modelTransports: Object.fromEntries(Object.entries(draft.modelTransports).filter(([, value]) => value !== ""))
1734
1794
  };
1735
1795
  }
@@ -1987,6 +2047,40 @@ window.__ModuleLoader__.load({
1987
2047
  ]
1988
2048
  });
1989
2049
  }
2050
+ // src/client/model-groups.ts
2051
+ function formatContext(value) {
2052
+ if (value >= 1e6) return `${(value / 1e6).toFixed(value % 1e6 === 0 ? 0 : 1)}M`;
2053
+ return `${Math.round(value / 1024)}K`;
2054
+ }
2055
+ /** Stable groups by effective context, richest first. */
2056
+ function groupModels(models, contextLabel) {
2057
+ const groups = /* @__PURE__ */ new Map();
2058
+ for (const model of models) {
2059
+ const existing = groups.get(model.contextWindow);
2060
+ if (existing !== void 0) {
2061
+ existing.models.push(model);
2062
+ continue;
2063
+ }
2064
+ groups.set(model.contextWindow, {
2065
+ key: String(model.contextWindow),
2066
+ label: `${formatContext(model.contextWindow)} ${contextLabel}`,
2067
+ contextWindow: model.contextWindow,
2068
+ models: [model]
2069
+ });
2070
+ }
2071
+ return [...groups.values()].sort((left, right) => right.contextWindow - left.contextWindow);
2072
+ }
2073
+ function reorderIds(order, ids, from, to) {
2074
+ const base = [.../* @__PURE__ */ new Set([...order, ...ids])];
2075
+ const source = base.indexOf(from);
2076
+ const target = base.indexOf(to);
2077
+ if (source < 0 || target < 0 || source === target) return base;
2078
+ const [moved] = base.splice(source, 1);
2079
+ if (moved === void 0) return base;
2080
+ const insertAt = source < target ? target - 1 : target;
2081
+ base.splice(insertAt, 0, moved);
2082
+ return base;
2083
+ }
1990
2084
  // src/client/update-state.ts
1991
2085
  function updateBadge(status) {
1992
2086
  if (status.latestCheckFailed) return "failed";
@@ -2107,10 +2201,22 @@ window.__ModuleLoader__.load({
2107
2201
  }
2108
2202
  // src/client/settings-page.tsx
2109
2203
  function ModelEntry(props) {
2110
- const { model, visible, transport, onVisible, onTransport, t } = props;
2204
+ const { model, visible, transport, onVisible, onTransport, onDragStart, onDrop, dragging, t } = props;
2111
2205
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2112
- className: "ocl-model",
2206
+ className: `ocl-model${dragging === true ? " ocl-dragging" : ""}`,
2207
+ draggable: onDragStart !== void 0,
2208
+ onDragStart,
2209
+ onDragOver: (event) => {
2210
+ if (onDrop !== void 0) event.preventDefault();
2211
+ },
2212
+ onDrop,
2113
2213
  children: [
2214
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2215
+ className: "ocl-drag-handle",
2216
+ title: t("dragOrder"),
2217
+ "aria-hidden": "true",
2218
+ children: "⋮⋮"
2219
+ }),
2114
2220
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2115
2221
  type: "checkbox",
2116
2222
  checked: visible,
@@ -2196,6 +2302,8 @@ window.__ModuleLoader__.load({
2196
2302
  const [loading, setLoading] = (0, react.useState)(true);
2197
2303
  const [saving, setSaving] = (0, react.useState)(false);
2198
2304
  const [search, setSearch] = (0, react.useState)("");
2305
+ const [dragId, setDragId] = (0, react.useState)(null);
2306
+ const [collapsedGroups, setCollapsedGroups] = (0, react.useState)({});
2199
2307
  const [keyDraft, setKeyDraft] = (0, react.useState)("");
2200
2308
  const [accountKeys, setAccountKeys] = (0, react.useState)({});
2201
2309
  const [testModel, setTestModel] = (0, react.useState)("gpt-oss:120b");
@@ -2303,6 +2411,41 @@ window.__ModuleLoader__.load({
2303
2411
  const worst = worstUsedPercent(report);
2304
2412
  const activeAccount = state.accounts.find((account) => account.active);
2305
2413
  const filtered = state.models.filter((model) => search.trim() === "" || model.id.toLowerCase().includes(search.trim().toLowerCase()));
2414
+ const groups = groupModels(filtered, t("contextGroup"));
2415
+ const modelIds = state.models.map((model) => model.id);
2416
+ const moveModel = (from, to) => {
2417
+ if (from === to) return;
2418
+ update({ modelOrder: reorderIds(draft.modelOrder, modelIds, from, to) });
2419
+ };
2420
+ const toggleGroup = (key) => {
2421
+ setCollapsedGroups((current) => ({
2422
+ ...current,
2423
+ [key]: current[key] !== true
2424
+ }));
2425
+ };
2426
+ const addManualModel = () => {
2427
+ update({ manualModels: [...draft.manualModels, {
2428
+ id: "",
2429
+ enabled: true,
2430
+ name: "",
2431
+ contextWindow: "",
2432
+ maxTokens: "",
2433
+ image: false,
2434
+ thinking: false,
2435
+ reasoningEfforts: "",
2436
+ defaultReasoning: "",
2437
+ tools: true
2438
+ }] });
2439
+ };
2440
+ const updateManual = (index, patch) => {
2441
+ update({ manualModels: draft.manualModels.map((model, position) => position === index ? {
2442
+ ...model,
2443
+ ...patch
2444
+ } : model) });
2445
+ };
2446
+ const removeManual = (index) => {
2447
+ update({ manualModels: draft.manualModels.filter((_model, position) => position !== index) });
2448
+ };
2306
2449
  const toggleModel = (id, visible) => {
2307
2450
  const current = new Set(draft.visibleModels);
2308
2451
  if (visible) current.add(id);
@@ -2917,22 +3060,142 @@ window.__ModuleLoader__.load({
2917
3060
  children: filtered.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2918
3061
  className: "ocl-hint",
2919
3062
  children: t("modelsEmpty")
2920
- }) : filtered.map((model) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelEntry, {
2921
- model,
2922
- visible: draft.showAll || draft.visibleModels.includes(model.id),
2923
- transport: draft.modelTransports[model.id] ?? "",
2924
- onVisible: (visible) => toggleModel(model.id, visible),
2925
- onTransport: (transport) => {
2926
- const next = { ...draft.modelTransports };
2927
- if (transport === "") delete next[model.id];
2928
- else next[model.id] = transport;
2929
- update({ modelTransports: next });
2930
- },
2931
- t
2932
- }, model.id))
3063
+ }) : groups.map((group) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3064
+ className: "ocl-model-group",
3065
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
3066
+ type: "button",
3067
+ className: "ocl-model-group-head",
3068
+ onClick: () => toggleGroup(group.key),
3069
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
3070
+ collapsedGroups[group.key] === true ? "▸" : "▾",
3071
+ " ",
3072
+ group.label
3073
+ ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3074
+ className: "ocl-badge",
3075
+ children: group.models.length
3076
+ })]
3077
+ }), collapsedGroups[group.key] === true ? null : group.models.map((model) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelEntry, {
3078
+ model,
3079
+ visible: draft.showAll || draft.visibleModels.includes(model.id),
3080
+ transport: draft.modelTransports[model.id] ?? "",
3081
+ dragging: dragId === model.id,
3082
+ onDragStart: () => setDragId(model.id),
3083
+ onDrop: () => {
3084
+ if (dragId !== null) moveModel(dragId, model.id);
3085
+ setDragId(null);
3086
+ },
3087
+ onVisible: (visible) => toggleModel(model.id, visible),
3088
+ onTransport: (transport) => {
3089
+ const next = { ...draft.modelTransports };
3090
+ if (transport === "") delete next[model.id];
3091
+ else next[model.id] = transport;
3092
+ update({ modelTransports: next });
3093
+ },
3094
+ t
3095
+ }, model.id))]
3096
+ }, group.key))
2933
3097
  })
2934
3098
  ]
2935
3099
  }),
3100
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3101
+ className: "ocl-card",
3102
+ children: [
3103
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", {
3104
+ className: "ocl-card-title",
3105
+ children: [t("manualModels"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3106
+ type: "button",
3107
+ className: "ocl-button",
3108
+ onClick: addManualModel,
3109
+ children: t("addManualModel")
3110
+ })]
3111
+ }),
3112
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3113
+ className: "ocl-hint",
3114
+ children: t("manualModelsHint")
3115
+ }),
3116
+ draft.manualModels.map((model, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3117
+ className: "ocl-model-section",
3118
+ children: [
3119
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3120
+ className: "ocl-grid",
3121
+ children: [
3122
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
3123
+ label: t("modelId"),
3124
+ value: model.id,
3125
+ onChange: (value) => updateManual(index, { id: value })
3126
+ }),
3127
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
3128
+ label: t("modelName"),
3129
+ value: model.name,
3130
+ onChange: (value) => updateManual(index, { name: value })
3131
+ }),
3132
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
3133
+ label: t("contextWindow"),
3134
+ type: "number",
3135
+ value: model.contextWindow,
3136
+ onChange: (value) => updateManual(index, { contextWindow: value })
3137
+ }),
3138
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
3139
+ label: t("maxTokens"),
3140
+ type: "number",
3141
+ value: model.maxTokens,
3142
+ onChange: (value) => updateManual(index, { maxTokens: value })
3143
+ }),
3144
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
3145
+ label: t("reasoningEfforts"),
3146
+ hint: t("manualEffortsHint"),
3147
+ value: model.reasoningEfforts,
3148
+ onChange: (value) => updateManual(index, { reasoningEfforts: value })
3149
+ }),
3150
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
3151
+ label: t("defaultReasoning"),
3152
+ value: model.defaultReasoning,
3153
+ onChange: (value) => updateManual(index, { defaultReasoning: value })
3154
+ })
3155
+ ]
3156
+ }),
3157
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3158
+ className: "ocl-row",
3159
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3160
+ type: "checkbox",
3161
+ checked: model.enabled,
3162
+ onChange: (event) => updateManual(index, { enabled: event.target.checked })
3163
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("enabled") })]
3164
+ }),
3165
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3166
+ className: "ocl-row",
3167
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3168
+ type: "checkbox",
3169
+ checked: model.image,
3170
+ onChange: (event) => updateManual(index, { image: event.target.checked })
3171
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("vision") })]
3172
+ }),
3173
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3174
+ className: "ocl-row",
3175
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3176
+ type: "checkbox",
3177
+ checked: model.thinking,
3178
+ onChange: (event) => updateManual(index, { thinking: event.target.checked })
3179
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("reasoning") })]
3180
+ }),
3181
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3182
+ className: "ocl-row",
3183
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3184
+ type: "checkbox",
3185
+ checked: model.tools,
3186
+ onChange: (event) => updateManual(index, { tools: event.target.checked })
3187
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("tools") })]
3188
+ }),
3189
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3190
+ type: "button",
3191
+ className: "ocl-button ocl-button-danger",
3192
+ onClick: () => removeManual(index),
3193
+ children: t("removeManualModel")
3194
+ })
3195
+ ]
3196
+ }, `${model.id}-${index}`))
3197
+ ]
3198
+ }),
2936
3199
  state !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LocalModelsCard, {
2937
3200
  t,
2938
3201
  config: state.config,
@@ -3107,6 +3370,13 @@ window.__ModuleLoader__.load({
3107
3370
  value: draft.streamIdleTimeoutMs,
3108
3371
  onChange: (value) => update({ streamIdleTimeoutMs: value })
3109
3372
  }),
3373
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
3374
+ label: t("attemptTimeoutMs"),
3375
+ hint: t("attemptTimeoutHint"),
3376
+ type: "number",
3377
+ value: draft.attemptTimeoutMs,
3378
+ onChange: (value) => update({ attemptTimeoutMs: value })
3379
+ }),
3110
3380
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
3111
3381
  label: t("maxOutputTokens"),
3112
3382
  type: "number",
@@ -3264,7 +3534,11 @@ window.__ModuleLoader__.load({
3264
3534
  .ocl-bar-fill-warn { background: var(--ocl-warning); opacity: 1; }
3265
3535
  .ocl-bar-fill-bad { background: var(--ocl-danger); opacity: 1; }
3266
3536
  .ocl-models { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow: auto; padding-right: 4px; }
3267
- .ocl-model { display: grid; grid-template-columns: 22px minmax(0,1fr) 120px; gap: 8px; align-items: center; font-size: 12px; padding: 3px 0; }
3537
+ .ocl-model { display: grid; grid-template-columns: 16px 22px minmax(0,1fr) 120px; gap: 8px; align-items: center; font-size: 12px; padding: 3px 0; }
3538
+ .ocl-drag-handle { cursor: grab; color: var(--ocl-text-secondary); user-select: none; }
3539
+ .ocl-dragging { opacity: 0.5; }
3540
+ .ocl-model-group { display: flex; flex-direction: column; gap: 2px; }
3541
+ .ocl-model-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 4px 0; border: 0; background: none; color: var(--ocl-text-secondary); font-size: 11px; font-weight: 650; cursor: pointer; text-align: left; }
3268
3542
  .ocl-model-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
3269
3543
  .ocl-model-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; color: var(--ocl-text-secondary); font-size: 11px; }
3270
3544
  .ocl-model-legend > span { display: inline-flex; align-items: center; gap: 5px; }
package/lib/index.d.ts CHANGED
@@ -23,6 +23,18 @@ interface ModelPriceOverride {
23
23
  * Plugin configuration. Every field except the literal `apiKey` is volatile:
24
24
  * the harness projects settings forms from schema fields carrying that marker.
25
25
  */
26
+ interface ManualModel {
27
+ id: string;
28
+ enabled?: boolean;
29
+ name?: string;
30
+ contextWindow?: number;
31
+ maxTokens?: number;
32
+ image?: boolean;
33
+ thinking?: boolean;
34
+ reasoningEfforts?: string[];
35
+ defaultReasoning?: string;
36
+ tools?: boolean;
37
+ }
26
38
  interface Config {
27
39
  /** Credential reference resolved per request; defaults to `OLLAMA_API_KEY`. */
28
40
  apiKeyEnv?: string;
@@ -44,12 +56,18 @@ interface Config {
44
56
  requestTimeoutMs?: number;
45
57
  /** Milliseconds a stream may stall; defaults to 300s. */
46
58
  streamIdleTimeoutMs?: number;
59
+ /** Whole-attempt budget; 0 disables the independent budget. */
60
+ attemptTimeoutMs?: number;
47
61
  /** Visible-model allowlist; empty with `showAllModels:false` means none. */
48
62
  visibleModels?: string[];
49
63
  /** Explicit all-models switch; absent means derive from `visibleModels`. */
50
64
  showAllModels?: boolean;
51
65
  /** Per-model visibility overrides; wins over `visibleModels`. */
52
66
  modelVisibility?: Record<string, boolean>;
67
+ /** Manual catalog entries and overrides; merged over live discovery. */
68
+ manualModels?: ManualModel[];
69
+ /** Stable picker order; ids not listed follow by name. */
70
+ modelOrder?: string[];
53
71
  /** Hide models the cloud marks unsupported in the API; defaults to true. */
54
72
  filterModelsByPlan?: boolean;
55
73
  /** Global context-window override. */
@@ -102,9 +120,12 @@ interface ResolvedConfig {
102
120
  modelTransports: Readonly<Record<string, TransportId>>;
103
121
  requestTimeoutMs: number;
104
122
  streamIdleTimeoutMs: number;
123
+ attemptTimeoutMs: number;
105
124
  visibleModels: readonly string[];
106
125
  showAllModels: boolean;
107
126
  modelVisibility: Readonly<Record<string, boolean>>;
127
+ manualModels: readonly ManualModel[];
128
+ modelOrder: readonly string[];
108
129
  filterModelsByPlan: boolean;
109
130
  contextWindow?: number;
110
131
  contextWindowOverrides: Readonly<Record<string, number>>;
package/lib/index.js CHANGED
@@ -43,6 +43,33 @@ function bestEffortFailed(label, error) {
43
43
  sink?.debug?.(`${label}: ${error instanceof Error ? error.message : String(error)}`);
44
44
  } catch {}
45
45
  }
46
+ // src/attempt.ts
47
+ /** One abort/timeout budget for one attempt; callers create a fresh one per retry. */
48
+ function createAttemptBudget(timeoutMs, caller) {
49
+ const controller = new AbortController();
50
+ const budget = {
51
+ signal: controller.signal,
52
+ timedOut: false,
53
+ callerAborted: caller?.aborted === true,
54
+ dispose: () => {}
55
+ };
56
+ const onAbort = () => {
57
+ budget.callerAborted = true;
58
+ controller.abort(caller?.reason);
59
+ };
60
+ caller?.addEventListener("abort", onAbort, { once: true });
61
+ if (caller?.aborted === true) controller.abort(caller.reason);
62
+ const timer = timeoutMs !== void 0 && timeoutMs > 0 ? setTimeout(() => {
63
+ budget.timedOut = true;
64
+ controller.abort();
65
+ }, timeoutMs) : void 0;
66
+ timer?.unref?.();
67
+ budget.dispose = () => {
68
+ if (timer !== void 0) clearTimeout(timer);
69
+ caller?.removeEventListener("abort", onAbort);
70
+ };
71
+ return budget;
72
+ }
46
73
  // src/config.ts
47
74
  const NS = "llm-ollama-cloud";
48
75
  const DEFAULT_API_KEY_ENV = "OLLAMA_API_KEY";
@@ -50,7 +77,7 @@ const DEFAULT_API_BASE = "https://ollama.com";
50
77
  const DEFAULT_OPENAI_BASE = "https://ollama.com/v1";
51
78
  const DEFAULT_USAGE_URL = "https://ollama.com/api/usage";
52
79
  const DEFAULT_BALANCE_URL = "https://ollama.com/api/balance";
53
- const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.21";
80
+ const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.23";
54
81
  const DEFAULT_CONTEXT_WINDOW = 131072;
55
82
  const DEFAULT_MAX_TOKENS = 32768;
56
83
  const DEFAULT_GENERATE_MAX_TOKENS = 131072;
@@ -69,9 +96,23 @@ const Config = z.object({
69
96
  modelTransports: markVolatile(z.dict(z.union(["native", "openai-chat"])).default({})),
70
97
  requestTimeoutMs: markVolatile(z.number().min(1).max(2147483647).default(3e5)),
71
98
  streamIdleTimeoutMs: markVolatile(z.number().min(1).max(2147483647).default(3e5)),
99
+ attemptTimeoutMs: markVolatile(z.number().min(0).max(36e5).step(1).default(0)),
72
100
  visibleModels: markVolatile(z.array(z.string()).default([])),
73
101
  showAllModels: markVolatile(z.boolean()),
74
102
  modelVisibility: markVolatile(z.dict(z.boolean()).default({})),
103
+ manualModels: markVolatile(z.array(z.object({
104
+ id: z.string(),
105
+ enabled: z.boolean().default(true),
106
+ name: z.string(),
107
+ contextWindow: z.number().min(1).max(1e7).step(1),
108
+ maxTokens: z.number().min(1).max(1e7).step(1),
109
+ image: z.boolean(),
110
+ thinking: z.boolean(),
111
+ reasoningEfforts: z.array(z.string()),
112
+ defaultReasoning: z.string(),
113
+ tools: z.boolean()
114
+ })).default([])),
115
+ modelOrder: markVolatile(z.array(z.string()).default([])),
75
116
  filterModelsByPlan: markVolatile(z.boolean().default(true)),
76
117
  contextWindow: markVolatile(z.number().min(1).max(1e7).step(1)),
77
118
  contextWindowOverrides: markVolatile(z.dict(z.number().min(1).max(1e7).step(1)).default({})),
@@ -133,6 +174,36 @@ function nonEmptyStrings(value) {
133
174
  const out = value.filter((entry) => typeof entry === "string" && entry.trim() !== "");
134
175
  return out.length === 0 ? void 0 : out;
135
176
  }
177
+ function manualModelList(value) {
178
+ if (!Array.isArray(value)) return [];
179
+ const out = [];
180
+ for (const entry of value) {
181
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry)) continue;
182
+ const record = entry;
183
+ const id = typeof record.id === "string" ? record.id.trim() : "";
184
+ if (id === "" || id.includes("..") || !/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/.test(id)) continue;
185
+ const name = typeof record.name === "string" ? record.name.trim() : "";
186
+ const contextWindow = integerInRange(record.contextWindow, 1, 1e7);
187
+ const maxTokens = integerInRange(record.maxTokens, 1, 1e7);
188
+ const efforts = Array.isArray(record.reasoningEfforts) ? record.reasoningEfforts.filter((item) => typeof item === "string" && item.trim() !== "") : void 0;
189
+ const thinking = typeof record.thinking === "boolean" ? record.thinking : void 0;
190
+ const normalizedEfforts = thinking === true && (efforts === void 0 || efforts.length === 0) ? ["off", "high"] : thinking === false ? [] : efforts;
191
+ const defaultReasoning = typeof record.defaultReasoning === "string" && record.defaultReasoning.trim() !== "" ? record.defaultReasoning.trim() : void 0;
192
+ out.push({
193
+ id,
194
+ enabled: record.enabled !== false,
195
+ ...name === "" ? {} : { name },
196
+ ...contextWindow === void 0 ? {} : { contextWindow },
197
+ ...maxTokens === void 0 ? {} : { maxTokens },
198
+ ...typeof record.image === "boolean" ? { image: record.image } : {},
199
+ ...thinking === void 0 ? {} : { thinking },
200
+ ...normalizedEfforts === void 0 ? {} : { reasoningEfforts: normalizedEfforts },
201
+ ...defaultReasoning === void 0 ? {} : { defaultReasoning },
202
+ ...typeof record.tools === "boolean" ? { tools: record.tools } : {}
203
+ });
204
+ }
205
+ return out;
206
+ }
136
207
  function recordOf$1(value) {
137
208
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
138
209
  }
@@ -202,9 +273,12 @@ function resolveConfig(config) {
202
273
  modelTransports: transportRecord(config.modelTransports),
203
274
  requestTimeoutMs: positiveInt(config.requestTimeoutMs, 3e5),
204
275
  streamIdleTimeoutMs: positiveInt(config.streamIdleTimeoutMs, 3e5),
276
+ attemptTimeoutMs: typeof config.attemptTimeoutMs === "number" && Number.isInteger(config.attemptTimeoutMs) && config.attemptTimeoutMs >= 0 && config.attemptTimeoutMs <= 36e5 ? config.attemptTimeoutMs : 0,
205
277
  visibleModels,
206
278
  showAllModels: config.showAllModels === true ? true : config.showAllModels === false ? false : visibleModels.length === 0,
207
279
  modelVisibility: booleanRecord(config.modelVisibility),
280
+ manualModels: manualModelList(config.manualModels),
281
+ modelOrder: Array.isArray(config.modelOrder) ? config.modelOrder.filter((id) => typeof id === "string" && id !== "") : [],
208
282
  filterModelsByPlan: config.filterModelsByPlan !== false,
209
283
  ...typeof config.contextWindow === "number" && Number.isInteger(config.contextWindow) && config.contextWindow > 0 ? { contextWindow: config.contextWindow } : {},
210
284
  contextWindowOverrides: numberRecord(config.contextWindowOverrides),
@@ -1246,8 +1320,14 @@ async function refreshCatalog(config, fetchImpl = fetch, force = false) {
1246
1320
  return refreshNow(config, fetchImpl, key, cached !== void 0, generation);
1247
1321
  }
1248
1322
  async function refreshNow(config, fetchImpl, key, keepOnFailure, epoch) {
1249
- const signal = AbortSignal.timeout(CATALOG_TIMEOUT_MS);
1250
- const [modelsResult, tagsResult] = await Promise.allSettled([fetchJson(modelsUrlFor(config), config, fetchImpl, signal), fetchJson(tagsUrlFor(config), config, fetchImpl, signal)]);
1323
+ const budget = createAttemptBudget(CATALOG_TIMEOUT_MS);
1324
+ let modelsResult;
1325
+ let tagsResult;
1326
+ try {
1327
+ [modelsResult, tagsResult] = await Promise.allSettled([fetchJson(modelsUrlFor(config), config, fetchImpl, budget.signal), fetchJson(tagsUrlFor(config), config, fetchImpl, budget.signal)]);
1328
+ } finally {
1329
+ budget.dispose();
1330
+ }
1251
1331
  if (epoch !== generation) return Object.keys(GENERATED_MODELS);
1252
1332
  if (modelsResult.status === "fulfilled") {
1253
1333
  const payload = modelsResult.value;
@@ -1313,12 +1393,24 @@ function baseMeta(id, base) {
1313
1393
  name: id
1314
1394
  } : meta;
1315
1395
  }
1396
+ function manualModelFor(id, config) {
1397
+ return config.manualModels.find((entry) => entry.id === id);
1398
+ }
1316
1399
  function effectiveModel(id, config) {
1317
1400
  const meta = baseMeta(id, config.apiBase);
1401
+ const manual = manualModelFor(id, config);
1318
1402
  return {
1319
1403
  ...meta,
1404
+ name: manual?.name ?? meta.name,
1320
1405
  transport: config.modelTransports[id] ?? config.transport,
1321
- contextWindow: config.contextWindowOverrides[id] ?? config.contextWindow ?? meta.contextWindow
1406
+ contextWindow: config.contextWindowOverrides[id] ?? manual?.contextWindow ?? config.contextWindow ?? meta.contextWindow,
1407
+ maxTokens: manual?.maxTokens ?? meta.maxTokens,
1408
+ input: manual?.image === true ? ["text", "image"] : manual?.image === false ? ["text"] : meta.input,
1409
+ reasoning: manual?.reasoningEfforts ?? meta.reasoning,
1410
+ reasoningToggle: manual?.thinking ?? meta.reasoningToggle,
1411
+ ...(manual?.defaultReasoning ?? meta.defaultReasoning) === void 0 ? {} : { defaultReasoning: manual?.defaultReasoning ?? meta.defaultReasoning },
1412
+ tools: manual?.tools ?? meta.tools,
1413
+ available: manual?.enabled === false ? false : meta.available
1322
1414
  };
1323
1415
  }
1324
1416
  /** Effective per-request output default; `0` means "omit the field". */
@@ -1335,11 +1427,20 @@ function modelVisible(id, config) {
1335
1427
  return config.visibleModels.includes(id);
1336
1428
  }
1337
1429
  function modelAvailable(id, config) {
1430
+ if (manualModelFor(id, config)?.enabled === false) return false;
1338
1431
  if (!config.filterModelsByPlan) return true;
1339
- return baseMeta(id, config.apiBase).available !== false;
1432
+ return effectiveModel(id, config).available !== false;
1340
1433
  }
1341
1434
  function sortForPicker(ids, config, unfiltered = false) {
1435
+ const order = new Map([...config.modelOrder.map((id, index) => [id, index]), ...config.visibleModels.map((id, index) => [id, config.modelOrder.length + index])]);
1342
1436
  return ids.filter((id) => unfiltered || modelVisible(id, config) && modelAvailable(id, config)).sort((left, right) => {
1437
+ const leftOrder = order.get(left);
1438
+ const rightOrder = order.get(right);
1439
+ if (leftOrder !== void 0 || rightOrder !== void 0) {
1440
+ if (leftOrder === void 0) return 1;
1441
+ if (rightOrder === void 0) return -1;
1442
+ if (leftOrder !== rightOrder) return leftOrder - rightOrder;
1443
+ }
1343
1444
  const a = effectiveModel(left, config);
1344
1445
  const b = effectiveModel(right, config);
1345
1446
  if (a.free !== b.free) return a.free ? -1 : 1;
@@ -1426,6 +1527,41 @@ function classifyStreamError(value, status = 200) {
1426
1527
  if (value.error === void 0) return void 0;
1427
1528
  return classifyResponseError(status, JSON.stringify(value), new Headers());
1428
1529
  }
1530
+ // src/context-override.ts
1531
+ const overrides = /* @__PURE__ */ new Map();
1532
+ function sessionKey(sessionId) {
1533
+ return sessionId === void 0 || sessionId === null ? "" : String(sessionId);
1534
+ }
1535
+ function setContextOverride(sessionId, value) {
1536
+ overrides.set(sessionKey(sessionId), value);
1537
+ }
1538
+ function clearContextOverride(sessionId) {
1539
+ overrides.delete(sessionKey(sessionId));
1540
+ }
1541
+ function contextOverrideFor(sessionId) {
1542
+ return overrides.get(sessionKey(sessionId));
1543
+ }
1544
+ /** Session value wins; `follow` and an unset value use the configured num_ctx. */
1545
+ function effectiveNumCtx(config, sessionId) {
1546
+ const override = contextOverrideFor(sessionId);
1547
+ return typeof override === "number" ? override : config.numCtx;
1548
+ }
1549
+ function parseContextValue(raw) {
1550
+ const value = raw.trim().toLowerCase();
1551
+ if (value === "" || value === "status") return void 0;
1552
+ if (value === "follow") return "follow";
1553
+ if (value === "reset") return "reset";
1554
+ const match = /^(\d+)(k|m)?$/.exec(value);
1555
+ if (match === null) return void 0;
1556
+ const number = Number(match[1]) * (match[2] === "k" ? 1024 : match[2] === "m" ? 1048576 : 1);
1557
+ if (!Number.isInteger(number) || number < 1024 || number > 1e7) return void 0;
1558
+ return number;
1559
+ }
1560
+ function describeContext(config, sessionId) {
1561
+ const override = contextOverrideFor(sessionId);
1562
+ const effective = effectiveNumCtx(config, sessionId);
1563
+ return `Context: session=${override === void 0 ? "unset" : override === "follow" ? "follow" : `${override} tokens`}, effective=${effective === void 0 ? "model default" : `${effective} tokens`}`;
1564
+ }
1429
1565
  // src/images.ts
1430
1566
  const MAX_LONG_EDGE = 1568;
1431
1567
  const MAX_BYTES = 1048576;
@@ -1737,12 +1873,13 @@ function nativeThink(effort, model) {
1737
1873
  ].includes(effort) ? effort : void 0;
1738
1874
  }
1739
1875
  /** Build the native `/api/chat` request body for one model. */
1740
- function buildNativeBody(options, model, config, images) {
1876
+ function buildNativeBody(options, model, config, images, numCtxOverride) {
1741
1877
  const tools = buildTools(options.tools);
1742
1878
  const maxTokens = options.maxTokens ?? effectiveMaxTokens(model, config);
1743
1879
  const think = nativeThink(options.reasoningEffort === void 0 ? void 0 : String(options.reasoningEffort), model);
1744
1880
  const temperature = options.temperature ?? config.temperature;
1745
1881
  const stop = options.stop ?? config.stop;
1882
+ const numCtx = numCtxOverride ?? config.numCtx;
1746
1883
  const nativeOptions = {
1747
1884
  ...temperature === void 0 ? {} : { temperature },
1748
1885
  ...config.topK === void 0 ? {} : { top_k: config.topK },
@@ -1751,7 +1888,7 @@ function buildNativeBody(options, model, config, images) {
1751
1888
  ...config.seed === void 0 ? {} : { seed: config.seed },
1752
1889
  ...config.repeatPenalty === void 0 ? {} : { repeat_penalty: config.repeatPenalty },
1753
1890
  ...config.repeatLastN === void 0 ? {} : { repeat_last_n: config.repeatLastN },
1754
- ...config.numCtx === void 0 ? {} : { num_ctx: config.numCtx },
1891
+ ...numCtx === void 0 ? {} : { num_ctx: numCtx },
1755
1892
  ...maxTokens === void 0 || maxTokens <= 0 ? {} : { num_predict: maxTokens },
1756
1893
  ...stop === void 0 || stop.length === 0 ? {} : { stop }
1757
1894
  };
@@ -2684,7 +2821,8 @@ var OllamaCloudAdapter = class extends LlmAdapter {
2684
2821
  }
2685
2822
  async listModels(provider, opts) {
2686
2823
  const config = this.deps.config();
2687
- return sortForPicker(await refreshCatalog(config, this.fetchImpl), config, opts?.unfiltered === true).map((id) => {
2824
+ const discovered = await refreshCatalog(config, this.fetchImpl);
2825
+ return sortForPicker([.../* @__PURE__ */ new Set([...discovered, ...config.manualModels.map((model) => model.id)])], config, opts?.unfiltered === true).map((id) => {
2688
2826
  const model = effectiveModel(id, config);
2689
2827
  return {
2690
2828
  provider,
@@ -2768,7 +2906,7 @@ var OllamaCloudAdapter = class extends LlmAdapter {
2768
2906
  tools: limited
2769
2907
  };
2770
2908
  }
2771
- const body = model.transport === "openai-chat" ? buildChatBody(bodyOptions, model, config, images) : buildNativeBody(bodyOptions, model, config, images);
2909
+ const body = model.transport === "openai-chat" ? buildChatBody(bodyOptions, model, config, images) : buildNativeBody(bodyOptions, model, config, images, effectiveNumCtx(config, options.sessionId));
2772
2910
  let lastError;
2773
2911
  let lastAccount = "default";
2774
2912
  let loggedAny = false;
@@ -2793,8 +2931,9 @@ var OllamaCloudAdapter = class extends LlmAdapter {
2793
2931
  ...errorCode === void 0 ? {} : { error: errorCode }
2794
2932
  });
2795
2933
  };
2934
+ const budget = createAttemptBudget(config.attemptTimeoutMs, options.signal);
2796
2935
  try {
2797
- const response = await this.send(url, entry.key, model, body, config, options.signal);
2936
+ const response = await this.send(url, entry.key, model, body, config, budget.signal);
2798
2937
  if (!response.ok) {
2799
2938
  const text = await response.text().catch(() => "");
2800
2939
  const error = classifyResponseError(response.status, text, response.headers);
@@ -2826,7 +2965,7 @@ var OllamaCloudAdapter = class extends LlmAdapter {
2826
2965
  fallback: false,
2827
2966
  ok: true
2828
2967
  });
2829
- const chunks = model.transport === "openai-chat" ? parseChatStream(response, config.streamIdleTimeoutMs, options.signal) : parseNativeStream(response, config.streamIdleTimeoutMs, options.signal);
2968
+ const chunks = model.transport === "openai-chat" ? parseChatStream(response, config.streamIdleTimeoutMs, budget.signal) : parseNativeStream(response, config.streamIdleTimeoutMs, budget.signal);
2830
2969
  for await (const chunk of chunks) {
2831
2970
  if (firstChunkAt === void 0) firstChunkAt = Date.now();
2832
2971
  started = true;
@@ -2835,9 +2974,9 @@ var OllamaCloudAdapter = class extends LlmAdapter {
2835
2974
  logAttempt(true);
2836
2975
  return;
2837
2976
  } catch (error) {
2838
- const classified = error instanceof LlmError ? error : new LlmError(error instanceof Error ? error.message : "Ollama Cloud request failed", "TRANSPORT", { cause: error });
2977
+ const classified = budget.timedOut ? new LlmError(`Ollama Cloud attempt exceeded ${config.attemptTimeoutMs}ms`, "TIMEOUT", { cause: error }) : error instanceof LlmError ? error : new LlmError(error instanceof Error ? error.message : "Ollama Cloud request failed", "TRANSPORT", { cause: error });
2839
2978
  logAttempt(false, classified.code);
2840
- if (started || options.signal?.aborted === true) throw error;
2979
+ if (started || options.signal?.aborted === true) throw budget.timedOut ? classified : error;
2841
2980
  lastError = classified;
2842
2981
  const transient = this.isTransient(classified);
2843
2982
  const canRotate = index < keys.length - 1 && (transient || this.modelScoped(classified));
@@ -2849,6 +2988,8 @@ var OllamaCloudAdapter = class extends LlmAdapter {
2849
2988
  }
2850
2989
  if (!responseFailure && (canRotate || credentialOrQuota)) this.markCooldown(entry.key, 0);
2851
2990
  if (!canRotate) throw classified;
2991
+ } finally {
2992
+ budget.dispose();
2852
2993
  }
2853
2994
  }
2854
2995
  const finalError = lastError ?? new LlmError("llm-ollama-cloud: every configured account is cooling down after provider rejections", "RATE_LIMIT");
@@ -3641,6 +3782,39 @@ function applyCommands(ctx, deps) {
3641
3782
  }
3642
3783
  }
3643
3784
  });
3785
+ ctx.commands.register({
3786
+ name: "ollama-context",
3787
+ description: "Set the native Ollama context size for this session",
3788
+ input: { hint: "status | 4k | 8k | 16k | 32k | 64k | 128k | <tokens> | follow | reset" },
3789
+ handler: async (invocation) => {
3790
+ const config = deps.config();
3791
+ const sessionId = invocation.agent.id;
3792
+ const raw = invocation.rawInput.trim();
3793
+ const value = parseContextValue(raw);
3794
+ if (raw !== "" && raw.toLowerCase() !== "status" && value === void 0) return {
3795
+ kind: "error",
3796
+ text: "Usage: /ollama-context status | 4k | 8k | 16k | 32k | 64k | 128k | <tokens> | follow | reset"
3797
+ };
3798
+ if (value === "reset") {
3799
+ clearContextOverride(sessionId);
3800
+ return {
3801
+ kind: "success",
3802
+ text: `${describeContext(config, sessionId)}\nSession override cleared.`
3803
+ };
3804
+ }
3805
+ if (value !== void 0) {
3806
+ setContextOverride(sessionId, value);
3807
+ return {
3808
+ kind: "success",
3809
+ text: describeContext(config, sessionId)
3810
+ };
3811
+ }
3812
+ return {
3813
+ kind: "success",
3814
+ text: describeContext(config, sessionId)
3815
+ };
3816
+ }
3817
+ });
3644
3818
  }
3645
3819
  // src/credentials.ts
3646
3820
  async function resolveRef(ctx, refName) {
@@ -4346,9 +4520,12 @@ function publicConfig(config) {
4346
4520
  modelTransports: config.modelTransports,
4347
4521
  requestTimeoutMs: config.requestTimeoutMs,
4348
4522
  streamIdleTimeoutMs: config.streamIdleTimeoutMs,
4523
+ attemptTimeoutMs: config.attemptTimeoutMs,
4349
4524
  visibleModels: config.visibleModels,
4350
4525
  showAllModels: config.showAllModels,
4351
4526
  modelVisibility: config.modelVisibility,
4527
+ manualModels: config.manualModels,
4528
+ modelOrder: config.modelOrder,
4352
4529
  filterModelsByPlan: config.filterModelsByPlan,
4353
4530
  contextWindow: config.contextWindow ?? null,
4354
4531
  contextWindowOverrides: config.contextWindowOverrides,
@@ -4465,6 +4642,32 @@ function cleanModelAccountRules(value) {
4465
4642
  }
4466
4643
  return out;
4467
4644
  }
4645
+ function cleanManualModels(value) {
4646
+ if (!Array.isArray(value)) return [];
4647
+ const out = [];
4648
+ for (const entry of value) {
4649
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry)) continue;
4650
+ const record = entry;
4651
+ const id = typeof record.id === "string" ? record.id.trim() : "";
4652
+ if (id === "" || id.includes("..") || !/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/.test(id)) continue;
4653
+ const efforts = Array.isArray(record.reasoningEfforts) ? record.reasoningEfforts.filter((item) => typeof item === "string" && item.trim() !== "") : void 0;
4654
+ const thinking = typeof record.thinking === "boolean" ? record.thinking : void 0;
4655
+ const normalizedEfforts = thinking === true && (efforts === void 0 || efforts.length === 0) ? ["off", "high"] : thinking === false ? [] : efforts;
4656
+ out.push({
4657
+ id,
4658
+ enabled: record.enabled !== false,
4659
+ ...typeof record.name === "string" && record.name.trim() !== "" ? { name: record.name.trim() } : {},
4660
+ ...typeof record.contextWindow === "number" && Number.isInteger(record.contextWindow) && record.contextWindow > 0 ? { contextWindow: record.contextWindow } : {},
4661
+ ...typeof record.maxTokens === "number" && Number.isInteger(record.maxTokens) && record.maxTokens > 0 ? { maxTokens: record.maxTokens } : {},
4662
+ ...typeof record.image === "boolean" ? { image: record.image } : {},
4663
+ ...thinking === void 0 ? {} : { thinking },
4664
+ ...normalizedEfforts === void 0 ? {} : { reasoningEfforts: normalizedEfforts },
4665
+ ...typeof record.defaultReasoning === "string" && record.defaultReasoning.trim() !== "" ? { defaultReasoning: record.defaultReasoning.trim() } : {},
4666
+ ...typeof record.tools === "boolean" ? { tools: record.tools } : {}
4667
+ });
4668
+ }
4669
+ return out;
4670
+ }
4468
4671
  function cleanBooleanRecord(value) {
4469
4672
  if (typeof value !== "object" || value === null || Array.isArray(value)) return {};
4470
4673
  const out = {};
@@ -4686,9 +4889,12 @@ function configOps(patch) {
4686
4889
  if ("modelTransports" in patch) set("modelTransports", cleanTransports(patch.modelTransports));
4687
4890
  if ("requestTimeoutMs" in patch) set("requestTimeoutMs", patch.requestTimeoutMs);
4688
4891
  if ("streamIdleTimeoutMs" in patch) set("streamIdleTimeoutMs", patch.streamIdleTimeoutMs);
4892
+ if ("attemptTimeoutMs" in patch) set("attemptTimeoutMs", patch.attemptTimeoutMs);
4689
4893
  if ("visibleModels" in patch) set("visibleModels", cleanStringArray(patch.visibleModels));
4690
4894
  if ("showAllModels" in patch) set("showAllModels", patch.showAllModels === true);
4691
4895
  if ("modelVisibility" in patch) set("modelVisibility", cleanBooleanRecord(patch.modelVisibility));
4896
+ if ("manualModels" in patch) set("manualModels", cleanManualModels(patch.manualModels));
4897
+ if ("modelOrder" in patch) set("modelOrder", cleanStringArray(patch.modelOrder));
4692
4898
  if ("filterModelsByPlan" in patch) set("filterModelsByPlan", patch.filterModelsByPlan === true);
4693
4899
  if ("contextWindow" in patch) set("contextWindow", patch.contextWindow);
4694
4900
  if ("contextWindowOverrides" in patch) set("contextWindowOverrides", cleanNumberRecord(patch.contextWindowOverrides));
@@ -5690,17 +5896,12 @@ function isRedirectFailure(error) {
5690
5896
  }
5691
5897
  return false;
5692
5898
  }
5693
- function abortReason(caller, own) {
5694
- if (caller?.aborted === true) return "caller";
5695
- return own.aborted ? "timeout" : void 0;
5696
- }
5697
5899
  async function postOnce(options, url, payload, caller) {
5698
5900
  const apiKey = await options.resolveApiKey();
5699
5901
  if (apiKey === void 0) throw new WebError("ollama-cloud web capabilities need an API key; configure the credential reference through plugin settings", "OLLAMA_WEB_MISSING_CREDENTIAL");
5700
5902
  const fetchImpl = options.fetch ?? fetch;
5701
5903
  const timeoutMs = options.timeoutMs ?? 15e3;
5702
- const own = AbortSignal.timeout(timeoutMs);
5703
- const signal = caller === void 0 ? own : AbortSignal.any([caller, own]);
5904
+ const budget = createAttemptBudget(timeoutMs, caller);
5704
5905
  let response;
5705
5906
  try {
5706
5907
  response = await fetchImpl(url, {
@@ -5712,17 +5913,18 @@ async function postOnce(options, url, payload, caller) {
5712
5913
  },
5713
5914
  body: JSON.stringify(payload),
5714
5915
  redirect: "error",
5715
- signal
5916
+ signal: budget.signal
5716
5917
  });
5717
5918
  } catch (error) {
5718
- const reason = abortReason(caller, own);
5719
- if (reason === "caller") throw new WebError("ollama-cloud web request aborted by caller", "ABORTED", { cause: error });
5720
- if (reason === "timeout") throw new WebError(`ollama-cloud web request timed out after ${timeoutMs}ms`, "OLLAMA_WEB_TIMEOUT", { cause: error });
5919
+ budget.dispose();
5920
+ if (budget.callerAborted) throw new WebError("ollama-cloud web request aborted by caller", "ABORTED", { cause: error });
5921
+ if (budget.timedOut) throw new WebError(`ollama-cloud web request timed out after ${timeoutMs}ms`, "OLLAMA_WEB_TIMEOUT", { cause: error });
5721
5922
  if (isRedirectFailure(error)) throw new WebError(`${url} attempted a redirect`, "WEB_PROVIDER_ERROR", { cause: error });
5722
5923
  const detail = error instanceof Error && error.message !== "" ? `: ${error.message}` : "";
5723
5924
  throw new WebError(`could not reach ${url}${detail}`, "OLLAMA_WEB_TRANSPORT", { cause: error });
5724
5925
  }
5725
5926
  if (!response.ok) {
5927
+ budget.dispose();
5726
5928
  await response.body?.cancel();
5727
5929
  const hint = response.status === 401 || response.status === 403 ? "; check the API key" : "";
5728
5930
  throw new WebError(`${url} answered ${response.status}${hint}`, "WEB_PROVIDER_ERROR");
@@ -5733,7 +5935,11 @@ async function postOnce(options, url, payload, caller) {
5733
5935
  body: await response.json()
5734
5936
  };
5735
5937
  } catch (error) {
5938
+ if (budget.callerAborted) throw new WebError("ollama-cloud web request aborted by caller", "ABORTED", { cause: error });
5939
+ if (budget.timedOut) throw new WebError(`ollama-cloud web request timed out after ${timeoutMs}ms`, "OLLAMA_WEB_TIMEOUT", { cause: error });
5736
5940
  throw new WebError(`${url} did not answer with JSON`, "OLLAMA_WEB_BAD_REPLY", { cause: error });
5941
+ } finally {
5942
+ budget.dispose();
5737
5943
  }
5738
5944
  }
5739
5945
  async function postJson(options, suffix, payload, caller) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-ollama-cloud-provider",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
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 tests/local.test.ts tests/reasoning.test.ts tests/catalog-cache.test.ts tests/local-models.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 tests/reasoning.test.ts tests/catalog-cache.test.ts tests/local-models.test.ts tests/attempt.test.ts tests/model-groups.test.tsx",
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"