dsh-ssh-tui 0.3.5 → 0.3.7
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/README.en.md +24 -15
- package/README.md +23 -13
- package/cordis.patch.yml +17 -3
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/route-memory.js +55 -0
- package/lib/route-memory.js.map +1 -0
- package/lib/tui.js +740 -286
- package/lib/tui.js.map +1 -1
- package/lib/types/route-memory.d.ts +35 -0
- package/lib/types/tui.d.ts +117 -15
- package/package.json +29 -29
package/README.en.md
CHANGED
|
@@ -9,6 +9,10 @@ If you mostly work over SSH — a jump host, a test box, a keyboard-only
|
|
|
9
9
|
session — start here. A local desktop terminal with themes and layout
|
|
10
10
|
you already like can stay as it is.
|
|
11
11
|
|
|
12
|
+
Listed on the [dshfind plugin directory](https://dshfind.com/en/plugins/cyjyyd/dsh-ssh-tui):
|
|
13
|
+
|
|
14
|
+
[](https://dshfind.com/en/plugins/cyjyyd/dsh-ssh-tui?ref=badge)
|
|
15
|
+
|
|
12
16
|
Install with the official CLI (no clone):
|
|
13
17
|
|
|
14
18
|
```sh
|
|
@@ -226,17 +230,18 @@ The plugin runs on Linux, macOS, and Windows (Node ≥ 22.19):
|
|
|
226
230
|
| `1..9` + `Enter` | answer an `ask_user_question` dialog |
|
|
227
231
|
|
|
228
232
|
Type `/` to see slash-command suggestions — the panel merges the TUI's own
|
|
229
|
-
commands (`/find`, `/model`, `/help`, ...) with every command the harness
|
|
233
|
+
commands (`/find`, `/model`, `/provider`, `/help`, ...) with every command the harness
|
|
230
234
|
registers (`/goal`, `/plan`, `/compact`, `/permission`, `/feedback`, ...).
|
|
231
235
|
`/compact` shows a spinning 「压缩上下文」 card and footer until it
|
|
232
236
|
finishes, then the tokens recovered. `Tab` completes, `Enter` runs.
|
|
233
237
|
`/help` lists everything.
|
|
234
238
|
|
|
235
|
-
`/model` lists models for the **current** provider
|
|
236
|
-
is `grok-4.6` / `grok-4.5` plus reasoning effort (`xhigh` on 4.6).
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
239
|
+
`/model` lists models for the **current** provider only. On SuperGrok that
|
|
240
|
+
is `grok-4.6` / `grok-4.5` plus reasoning effort (`xhigh` on 4.6). `/provider`
|
|
241
|
+
switches provider, then model; it takes effect on the **next request** — no
|
|
242
|
+
restart. Each provider’s last model and effort is remembered. `/setup` adds
|
|
243
|
+
or updates one API-key provider without wiping the others. SuperGrok / X
|
|
244
|
+
Premium uses local OAuth and does not need a key.
|
|
240
245
|
|
|
241
246
|
For OpenCode and other third-party providers, `/model` queries the provider's
|
|
242
247
|
endpoint (`GET {baseURL}/models`) for a live model list, falling back to the
|
|
@@ -275,17 +280,20 @@ Interrupted streaming output keeps the already-generated prefix and is marked
|
|
|
275
280
|
system messages. Harness slash commands that accept image attachments are
|
|
276
281
|
labelled `(images ok)` in the command list and completion hints.
|
|
277
282
|
|
|
278
|
-
`/usage` (alias `/quota`) follows the **current** provider:
|
|
283
|
+
`/usage` (alias `/balance`; `/quota` still works) follows the **current** provider:
|
|
279
284
|
|
|
285
|
+
- **DeepSeek official** `GET {baseURL}/user/balance`;
|
|
286
|
+
- **OpenAI Completions gateways** probe `/user/balance` and `credit_grants`;
|
|
280
287
|
- **SuperGrok** reads `GET cli-chat-proxy.grok.com/v1/billing` (weekly remaining %);
|
|
281
288
|
- **OpenCode Go** reads the official `/v1/usage` windows (5-hour / week / month);
|
|
282
289
|
- **OpenCode Zen** is metered — the TUI points at `https://opencode.ai/zen`.
|
|
283
290
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
291
|
+
OpenCode Go / SuperGrok quota is fetched silently at start and on a
|
|
292
|
+
window-based cadence; the footer shows remaining %. A ⚠ transcript line
|
|
293
|
+
appears only when remaining crosses 50% / 25% / 10% / 5%. `/usage` or
|
|
294
|
+
`/balance` still prints the full snapshot. Cadence: every 10 turns for a
|
|
295
|
+
5-hour cap (every 4 when near), every 50 for weekly (every 10 when near),
|
|
296
|
+
every 80 for monthly (every 20 when near).
|
|
289
297
|
|
|
290
298
|
The startup screen shows the official DeepSeek whale logo (rendered from the
|
|
291
299
|
harness favicon) in the DeepSeek brand color, with the wordmark below it. The
|
|
@@ -352,7 +360,7 @@ collapsed card instead of being prefixed onto parent transcript lines;
|
|
|
352
360
|
`/subagents` lists active runs.
|
|
353
361
|
|
|
354
362
|
`/mode` opens the agent-mode picker backed by dsh's official preset roster:
|
|
355
|
-
标准模式 (standard), PTC 模式 (code), 极简模式 (minimal), 创造模式 (cordis),
|
|
363
|
+
标准模式 (standard), PTC 模式 (ptc; `code` on dsh 0.1.1), 极简模式 (minimal), 创造模式 (cordis),
|
|
356
364
|
智能路由模式 (routing-suite, from `dsh-routing-suite`),
|
|
357
365
|
plus any locally authored presets (e.g. `whoami-standard`). On a session that
|
|
358
366
|
has not produced work the switch applies immediately; otherwise it is remembered
|
|
@@ -383,8 +391,9 @@ switching while running.
|
|
|
383
391
|
Each paint is one `stdout.write` of dirty rows only, so a jump host or
|
|
384
392
|
corporate proxy does not see one SSH packet per line. Local ttys use 80 ms.
|
|
385
393
|
Over SSH the TUI probes CSI 6n once and picks 80 / 160 / 250 / 400 ms from
|
|
386
|
-
the round-trip. `DSH_TUI_PAINT_MS` always wins (40–1000).
|
|
387
|
-
|
|
394
|
+
the round-trip. `DSH_TUI_PAINT_MS` always wins (40–1000). The stats line
|
|
395
|
+
starts with `SSH ●●●○ 90ms` (1 pip red, 2 yellow, 3+ green). The probe
|
|
396
|
+
does not write into the transcript.
|
|
388
397
|
|
|
389
398
|
SSH disconnect still kills a TUI that is not inside tmux. Do not start a
|
|
390
399
|
second copy of the same session from another window.
|
package/README.md
CHANGED
|
@@ -10,6 +10,10 @@ English: [README.en.md](README.en.md)
|
|
|
10
10
|
|
|
11
11
|
SuperGrok / X Premium 订阅走配套插件 [dsh-llm-xai-oauth](https://github.com/cyjyyd/dsh-llm-xai-oauth),复用本机 grok-bridge token,不需要 xAI API Key。
|
|
12
12
|
|
|
13
|
+
本插件已被 [dshfind 插件目录](https://dshfind.com/zh/plugins/cyjyyd/dsh-ssh-tui) 收录:
|
|
14
|
+
|
|
15
|
+
[](https://dshfind.com/zh/plugins/cyjyyd/dsh-ssh-tui?ref=badge)
|
|
16
|
+
|
|
13
17
|
安装(官方 CLI,无需 clone):
|
|
14
18
|
|
|
15
19
|
```bash
|
|
@@ -51,8 +55,8 @@ dsh --profile tui
|
|
|
51
55
|
编辑工具 git 风格 diff(`-` 浅红底 / `+` 浅绿底 / 文件统计,编辑卡片默认展开且
|
|
52
56
|
diff 内容不截断)、JSON 参数与结果自动转可读内容;
|
|
53
57
|
- 转录区滚动回看(`PgUp`/`PgDn`、鼠标滚轮),点击思考/工具标题行直接展开收起;
|
|
54
|
-
-
|
|
55
|
-
|
|
58
|
+
- 输入框下方两行底栏:第一行链路芯片 + 按宽度丢组的会话数字(轮次、入/出 token、速度);
|
|
59
|
+
第二行只留一个活动词(运行中 / 工具 N / 子代理 N / 压缩中…),身份收到右侧;
|
|
56
60
|
- 历史会话启动选择器:`dsh --profile tui --resume`(或 `resume`)先选会话再进入;
|
|
57
61
|
- 终端窗口标题栏:运行中旋转图标 + `运行中 · 工具 N`,完成后 `✓ 已完成`,并响
|
|
58
62
|
一声终端铃(`DSH_TUI_NO_BELL=1` 关闭);
|
|
@@ -194,18 +198,20 @@ dsh --profile tui --no-color
|
|
|
194
198
|
| `Ctrl+D` | 退出 |
|
|
195
199
|
| `Ctrl+L` | 重绘整个画面 |
|
|
196
200
|
|
|
197
|
-
|
|
198
|
-
|
|
201
|
+
`/mode` 切换官方 preset:标准 (`standard`)、PTC (`ptc`;dsh 0.1.1 上仍是 `code`)、极简 (`minimal`)、创造 (`cordis`),以及本地安装的其它模式。
|
|
202
|
+
|
|
203
|
+
斜杠命令:`/help`、`/find`、`/model`、`/provider`、`/submodel`、`/subeffort`、`/mode`、`/resume`、
|
|
204
|
+
`/status`、`/subagents`、`/usage`(`/balance` 同义)、`/setup`、`/clear`,
|
|
199
205
|
以及 harness 自带命令(`/goal`、`/plan`、`/compact` 等)。`/compact` 进行中会显示
|
|
200
206
|
「压缩上下文」卡片和底栏转圈,结束时写出回收的 token 数。模型请求失败会显示重试
|
|
201
207
|
进度;会话标题由模型生成后写到窗口标题。harness 命令若声明
|
|
202
208
|
支持图片附件,会在命令列表和补全提示中标注“可附图”。
|
|
203
209
|
|
|
204
|
-
`/model`
|
|
205
|
-
`grok-4.6` / `grok-4.5
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
210
|
+
`/model` 只换**当前提供商**的模型和思考强度。已经在 SuperGrok 时,直接选
|
|
211
|
+
`grok-4.6` / `grok-4.5`(`grok-4.6` 含 `xhigh`)。要换 DeepSeek / OpenCode /
|
|
212
|
+
其它路由用 `/provider`:先选提供商,再选模型,**下一步请求生效,不用重启**。
|
|
213
|
+
每个提供商上次的模型和思考强度会分开记住。`/setup` 只新增或更新当前这条
|
|
214
|
+
API Key 提供商,不会冲掉其它路由。SuperGrok / X Premium 走本机 OAuth,不需要填 Key。
|
|
209
215
|
|
|
210
216
|
子代理默认跟随父会话的提供方,并尽量选同一家的轻量模型:DeepSeek 用
|
|
211
217
|
`deepseek-v4-flash` / `deepseek-v4-flash-vision-exp`,xAI 用 `grok-4.5`。
|
|
@@ -233,13 +239,15 @@ SuperGrok / X Premium 走本机 OAuth,不需要填 Key。`/status` 和底栏
|
|
|
233
239
|
`提问用户` 卡片。`/goal` 是折叠的 `目标` 卡片。`/find 思考 padAnsi` 或 `Alt+1..4`
|
|
234
240
|
可跳到对应类别的最新卡片。
|
|
235
241
|
|
|
236
|
-
`/usage`(`/quota`
|
|
242
|
+
`/usage`(`/balance` 同义,旧名 `/quota` 仍可用)按**当前提供商**查额度或余额:
|
|
237
243
|
|
|
244
|
+
- **DeepSeek 官方**:`GET {baseURL}/user/balance`(文档接口),显示可用/赠送/充值余额;
|
|
245
|
+
- **OpenAI Completions 兼容网关**:按配置的 base URL 探测 `/user/balance`、`/dashboard/billing/credit_grants` 等;
|
|
238
246
|
- **SuperGrok**:`GET cli-chat-proxy.grok.com/v1/billing`,显示本周剩余%;
|
|
239
247
|
- **OpenCode Go**:官方 `/v1/usage`,滚动 5 小时 / 本周 / 本月剩余%;
|
|
240
248
|
- **OpenCode Zen**:按量计费、没有固定额度,提示到 `https://opencode.ai/zen`。
|
|
241
249
|
|
|
242
|
-
|
|
250
|
+
OpenCode Go / SuperGrok 启动和运行中都静默查询,底栏只显示剩余%;跨过 50% / 25% / 10% / 5% 才往工作区打 ⚠。`/usage` 或 `/balance` 仍打印完整结果。查询节奏按最紧窗口:5 小时额度每 10 轮(接近改 4 轮),周额度每 50 轮(接近改 10 轮),月额度每 80 轮(接近改 20 轮)。
|
|
243
251
|
|
|
244
252
|
## 配置
|
|
245
253
|
|
|
@@ -259,7 +267,9 @@ ssh-tui-subagent:
|
|
|
259
267
|
```
|
|
260
268
|
|
|
261
269
|
`/model`、`/mode`、`/submodel` 与 `/subeffort` 的修改会写回这里,
|
|
262
|
-
web 端与 TUI
|
|
270
|
+
web 端与 TUI 共用同一份设置。`/model` 换提供商后**下一步请求生效**,不必重启。
|
|
271
|
+
每个提供商上次的模型和思考强度记在 `ssh-tui-routes` 里,切回 SuperGrok / 官方 / Go 时会预填。
|
|
272
|
+
`/setup` 只更新当前这条提供商(模型列表会合并),不会删掉其它路由的 Key 和模型。
|
|
263
273
|
|
|
264
274
|
对 OpenCode 和其他第三方提供商,`/model` 会先调用提供商的端点
|
|
265
275
|
(`GET {baseURL}/models`)获取实时模型列表;端点不可达时回退到已配置的
|
|
@@ -334,7 +344,7 @@ npm run build
|
|
|
334
344
|
- **标题栏或铃声不生效**:确认终端支持 OSC 0 与 BEL;铃声可用
|
|
335
345
|
`DSH_TUI_NO_BELL=1` 关闭。
|
|
336
346
|
- **滚轮误触取消**:已加入转义序列缓冲,网络拆包也不会把 `ESC` 当取消。
|
|
337
|
-
- **跳板机 / 多层代理 SSH 发画**:每一帧只发脏行,并且拼成一次 `stdout.write`。本机 80 ms;SSH 启动时用 CSI 6n 测往返,按 RTT 选 80/160/250/400 ms。`DSH_TUI_PAINT_MS` 始终优先(40–1000
|
|
347
|
+
- **跳板机 / 多层代理 SSH 发画**:每一帧只发脏行,并且拼成一次 `stdout.write`。本机 80 ms;SSH 启动时用 CSI 6n 测往返,按 RTT 选 80/160/250/400 ms。`DSH_TUI_PAINT_MS` 始终优先(40–1000)。统计行最左是 `SSH ●●●○ 90ms`(一格红、两格黄、三格及以上绿)。探测不写进转录。
|
|
338
348
|
- **SSH 断了任务也没了**:用 tmux 开 TUI(见上文)。不要在另一个 SSH 窗口再开同一会话。
|
|
339
349
|
- **提示会话已在 pid 运行**:那份 TUI 还活着。`tmux attach -t dsh`;确认进程已死再删 `$DSH_HOME/tui-locks/` 对应文件。
|
|
340
350
|
|
package/cordis.patch.yml
CHANGED
|
@@ -13,14 +13,19 @@
|
|
|
13
13
|
directory is {{cwd}}. Verify your work by running the code or tests.
|
|
14
14
|
Keep answers brief and factual.
|
|
15
15
|
|
|
16
|
-
#
|
|
17
|
-
#
|
|
16
|
+
# A patch replaces the targeted row's whole `config`, so restating `root`
|
|
17
|
+
# keeps the official HMR row complete while the TUI keeps module reload off.
|
|
18
|
+
# The launcher's watch-only fallback still keeps user patch layers live.
|
|
18
19
|
- id: hmr
|
|
19
20
|
disabled: true
|
|
21
|
+
config:
|
|
22
|
+
root: ['.']
|
|
20
23
|
|
|
21
24
|
- id: tools
|
|
22
25
|
config:
|
|
23
|
-
mode
|
|
26
|
+
# 0.1.2 renamed the tools-mode value `code` → `ptc` with no alias.
|
|
27
|
+
# Map either env value onto the schema this dsh install actually accepts.
|
|
28
|
+
mode: !!js (function () { var mode = process.env.DSH_TOOLS_MODE; if (mode !== 'code' && mode !== 'ptc') return mode; try { var req = process.getBuiltinModule('module').createRequire(ctx.baseUrl || process.cwd() + '/'); var ver = req('@deepseek-ai/dsh-tools/package.json').version || ''; if (!/^0\.(0|1)\.(0|1)/.test(ver)) return 'ptc'; return 'code' } catch (err) { if (mode === 'code') return 'ptc'; return mode } })()
|
|
24
29
|
|
|
25
30
|
# The `main` agent is created by the TUI plugin itself after the loader
|
|
26
31
|
# settles, so it can read the saved default provider/model from
|
|
@@ -63,6 +68,15 @@
|
|
|
63
68
|
config:
|
|
64
69
|
default: standard
|
|
65
70
|
|
|
71
|
+
# Host-plane PTC runtime used by the shipped `ptc` preset. Absent on
|
|
72
|
+
# dsh-base; web/headless insert it themselves. Keep it optional so an
|
|
73
|
+
# older dsh install without the package still boots standard mode.
|
|
74
|
+
# Disabled when the package is not installed (older dsh 0.1.1 runtimes
|
|
75
|
+
# still boot; 0.1.2's ptc preset can mount once the worker is on disk).
|
|
76
|
+
- id: code-runtime
|
|
77
|
+
name: '@deepseek-ai/dsh-code-runtime-worker-thread'
|
|
78
|
+
disabled: !!js (function () { try { process.getBuiltinModule('module').createRequire(ctx.baseUrl || process.cwd() + '/').resolve('@deepseek-ai/dsh-code-runtime-worker-thread'); return false } catch (err) { return true } })()
|
|
79
|
+
|
|
66
80
|
- id: ssh-tui-startup
|
|
67
81
|
name: 'dsh-ssh-tui/startup'
|
|
68
82
|
|
package/lib/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { mountTui } from './tui.js';
|
|
|
13
13
|
import { defaultReasoningEffort } from './reasoning.js';
|
|
14
14
|
import { createSubagentSelection } from './subagent-model.js';
|
|
15
15
|
import { acquireSessionLock, releaseSessionLock, sessionLockDisabled } from './session-lock.js';
|
|
16
|
+
import { installRouteMemory } from './route-memory.js';
|
|
16
17
|
export const name = 'ssh-tui';
|
|
17
18
|
/** Core services required before the terminal channel can drive an agent. */
|
|
18
19
|
export const inject = ['agents', 'agentDefaultModel'];
|
|
@@ -27,6 +28,7 @@ export function apply(ctx, config) {
|
|
|
27
28
|
throw new Error('dsh-ssh-tui: both stdin and stdout must be TTYs; use a terminal/SSH session');
|
|
28
29
|
}
|
|
29
30
|
const subagentSelection = createSubagentSelection(ctx);
|
|
31
|
+
installRouteMemory(ctx);
|
|
30
32
|
ctx.effect(() => {
|
|
31
33
|
let disposed = false;
|
|
32
34
|
let switching = false;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,qBAAqB,EAAiE,MAAM,wBAAwB,CAAA;AAG7H,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAsB,MAAM,UAAU,CAAA;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,qBAAqB,EAAiE,MAAM,wBAAwB,CAAA;AAG7H,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAsB,MAAM,UAAU,CAAA;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAA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O,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACtB,CAAC,CAAC,CAAA;QAEF,OAAO,KAAK,IAAmB,EAAE;YAC/B,QAAQ,GAAG,IAAI,CAAA;YACf,WAAW,CAAC,KAAK,EAAE,CAAA;YACnB,MAAM,UAAU,EAAE,OAAO,EAAE,CAAA;YAC3B,MAAM,MAAM,EAAE,OAAO,EAAE,CAAA;YACvB,MAAM,eAAe,EAAE,CAAA;QACzB,CAAC,CAAA;IACH,CAAC,EAAE,SAAS,CAAC,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remember the last model/effort per provider so /model and /setup can switch
|
|
3
|
+
* routes without wiping the previous provider's choice.
|
|
4
|
+
*/
|
|
5
|
+
import z from '@deepseek-ai/schemastery';
|
|
6
|
+
import { installSettingsSection, settingsNamespace } from '@deepseek-ai/dsh-settings';
|
|
7
|
+
export const ROUTE_MEMORY_NAMESPACE = settingsNamespace('ssh-tui-routes');
|
|
8
|
+
/** Settings schema for `$DSH_HOME/settings.yaml` under ssh-tui-routes. */
|
|
9
|
+
export const ROUTE_MEMORY_SCHEMA = z.object({
|
|
10
|
+
providers: z.dict(z.object({
|
|
11
|
+
model: z.string(),
|
|
12
|
+
reasoningEffort: z.string().default(''),
|
|
13
|
+
})).default({}),
|
|
14
|
+
});
|
|
15
|
+
export function parseRouteMemory(raw) {
|
|
16
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw))
|
|
17
|
+
return {};
|
|
18
|
+
const out = {};
|
|
19
|
+
for (const [provider, value] of Object.entries(raw)) {
|
|
20
|
+
const id = provider.trim();
|
|
21
|
+
if (id === '' || value === null || typeof value !== 'object' || Array.isArray(value))
|
|
22
|
+
continue;
|
|
23
|
+
const row = value;
|
|
24
|
+
const model = typeof row.model === 'string' ? row.model.trim() : '';
|
|
25
|
+
if (model === '')
|
|
26
|
+
continue;
|
|
27
|
+
const effort = typeof row.reasoningEffort === 'string' ? row.reasoningEffort.trim() : '';
|
|
28
|
+
out[id] = effort === '' ? { model } : { model, reasoningEffort: effort };
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
export function rememberedRouteFor(memory, provider) {
|
|
33
|
+
return memory[provider.trim()];
|
|
34
|
+
}
|
|
35
|
+
/** Register the route-memory settings section so /model and /provider can persist. */
|
|
36
|
+
export function installRouteMemory(ctx) {
|
|
37
|
+
installSettingsSection(ctx, ROUTE_MEMORY_NAMESPACE, ROUTE_MEMORY_SCHEMA, {
|
|
38
|
+
providers: {},
|
|
39
|
+
}, {
|
|
40
|
+
setSource: () => { },
|
|
41
|
+
onChange: () => { },
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export function upsertRememberedRoute(memory, provider, route) {
|
|
45
|
+
const id = provider.trim();
|
|
46
|
+
if (id === '' || route.model.trim() === '')
|
|
47
|
+
return memory;
|
|
48
|
+
return {
|
|
49
|
+
...memory,
|
|
50
|
+
[id]: route.reasoningEffort === undefined || route.reasoningEffort === ''
|
|
51
|
+
? { model: route.model }
|
|
52
|
+
: { model: route.model, reasoningEffort: route.reasoningEffort },
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=route-memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-memory.js","sourceRoot":"","sources":["../src/route-memory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAErF,MAAM,CAAC,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAA;AAEzE,0EAA0E;AAC1E,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;QACzB,KAAK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