@songtonyli/dsh-cli 0.1.28 → 0.1.29
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.md +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-slots/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-tui-app/README.md +3 -3
- package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +3 -3
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +171 -41
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ workspace and no build step. Native packages that ship one build per platform
|
|
|
26
26
|
ripgrep, the PTY backend's addons, sharp, koffi, and the Landlock launcher — are
|
|
27
27
|
ordinary optional dependencies, so npm resolves the right one for your machine.
|
|
28
28
|
|
|
29
|
-
Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.
|
|
29
|
+
Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.29; `dsh --version`
|
|
30
30
|
also reports the harness build the package was assembled from.
|
|
31
31
|
|
|
32
32
|
## License
|
package/bin/dsh.mjs
CHANGED
|
@@ -18,7 +18,7 @@ const argv = process.argv.slice(2)
|
|
|
18
18
|
// version this package publishes. Reporting only one of the two would make an
|
|
19
19
|
// ordinary `npm install @songtonyli/dsh-cli@x` look like it installed something else.
|
|
20
20
|
if (argv.length === 1 && (argv[0] === '--version' || argv[0] === '-V')) {
|
|
21
|
-
console.log('@songtonyli/dsh-cli 0.1.
|
|
21
|
+
console.log('@songtonyli/dsh-cli 0.1.29 (deepseek-harness 0.1.6-alpha.2)')
|
|
22
22
|
process.exit(0)
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -160,7 +160,7 @@ window.__ModuleLoader__.load({
|
|
|
160
160
|
const SCROLLBAR_LINGER_MS = 2e3;
|
|
161
161
|
/** Format complete-build metadata for the local brand badge. */
|
|
162
162
|
function localBuildVersion() {
|
|
163
|
-
return `0.1.6-alpha.2-
|
|
163
|
+
return `0.1.6-alpha.2-0c7bf05` + ({}.DSH_CLIENT_GIT_DIRTY === "true" ? "-dirty" : "");
|
|
164
164
|
}
|
|
165
165
|
/** Each panel row subscribes only to its own selection state. */
|
|
166
166
|
function PanelRow({ id, label, wide, usePanelInfo, selectPanel, renderSlot }) {
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/react": "~18.3.1",
|
|
27
|
-
"@deepseek-ai/
|
|
28
|
-
"@deepseek-ai/
|
|
27
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
28
|
+
"@deepseek-ai/dsh-client-store": "^0.1.6-alpha.2"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"lib/index.js",
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/bundle/tui-app/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 0ad4a73e8b9ef6b75a40caeae5b9737a6d7fe52b
|
|
6
|
+
README.zh.md: 86d015df48377e05e45686203012b4b8d46b4325
|
|
@@ -238,7 +238,7 @@ The runner is a direct driver over the core API carrier, like `dsh-headless`, th
|
|
|
238
238
|
|
|
239
239
|
### Run flow
|
|
240
240
|
|
|
241
|
-
The runner awaits the complete application (`ctx.get('loader')?.await()`) and builds a session host over the core registry with three operations: `create` makes one fresh persisted Agent with the shared [`agentDefaultModel`](../../core/agent-default-model/README.md) selection, `resume`
|
|
241
|
+
The runner awaits the complete application (`ctx.get('loader')?.await()`) and builds a session host over the core registry with three operations: `create` makes one fresh persisted Agent with the shared [`agentDefaultModel`](../../core/agent-default-model/README.md) selection, `resume` takes the Agent write handle first and then observes the live Session through `ctx.sessionQuery` so bind draws every persisted event including resume closers, and `fork` observes the source through `ctx.sessionQuery`, cuts after the chosen (by default the last) `turn/end` up to the next `turn/start`, and creates a seeded Agent with `parentSession` and `isSeeded` metadata. Every operation installs a `ModelSelectionRef` in the Agent's scoped setup so `/model` changes the next request. The terminal application starts on the session `--resume` or a fresh `create` yields, subscribes to `session/event`, `agent/assistant-stream`, and `agent/status`, answers the `approval/request` and `user-questions/request` waterfalls for the bound Agent only, and switches sessions by binding the next one and disposing the previous handle; while the host opens the next session the editor refuses input, and a quit during that wait releases the session that arrives afterwards. Quitting cancels any running turn, waits for quiescence, flushes the bound Session, disposes its handle, and requests exit 0; a driver failure writes `dsh: <message>` to stderr and requests exit 1. `/resume` and `/sessions` share the persisted-session chooser. Editor `Shift+Tab` dispatches empty `/effort` to open its current-model picker, and editor `Shift+Left` / `Shift+Right` use pi-tui's word navigation. `/login` starts `authorization.begin` with only subscription methods (every method except a key-collecting `api-key` login). A notice the flow marks with `openInBrowser` is handed to the default browser through `dsh-native-command`'s credential-scrubbed helper while the URL stays printed; the handoff is suppressed when `openBrowser` is false, the launch came through SSH, or the host has no desktop, and an opener failure becomes a notice beside the URL rather than a sign-in failure. A nonempty `!` or `!!` line submitted in the editor runs through `ctx.shell` in this process; `!` injects a next-step notice and `!!` stays local.
|
|
242
242
|
|
|
243
243
|
### Rendering model
|
|
244
244
|
|
|
@@ -252,7 +252,7 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
|
|
|
252
252
|
|
|
253
253
|
| File | Role |
|
|
254
254
|
|---|---|
|
|
255
|
-
| [`src/index.ts`](src/index.ts) | The `tui-app` plugin: the session host (create, resume, fork),
|
|
255
|
+
| [`src/index.ts`](src/index.ts) | The `tui-app` plugin: the session host (create, resume, fork), resume observation, quit flow, exit mapping |
|
|
256
256
|
| [`src/startup.ts`](src/startup.ts) | The `tui-app-startup` provider: prompt positional, `--resume`, `--no-open`, and `--help` |
|
|
257
257
|
| [`src/app.ts`](src/app.ts) | The terminal application: layout, the key router, commands, session binding, seams, log and stream folding, the stop arm, the transient line it mounts, the terminal handover the reader runs on, and prefix-on-submit `!` / `!!` |
|
|
258
258
|
| [`src/keys.ts`](src/keys.ts) | The key model: the focus regions, what one press means in each, the legends they degrade through, the entry keys, the `/help` lines, and the handoff window |
|
|
@@ -261,7 +261,7 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
|
|
|
261
261
|
| [`src/permission.ts`](src/permission.ts) | Permission-preset names and picker rows for `/permission` |
|
|
262
262
|
| [`src/attach.ts`](src/attach.ts) | `/attach`: local files into image or file blocks through the attachment store |
|
|
263
263
|
| [`src/export.ts`](src/export.ts) | `/export`: the session-log ZIP written through the export package's archive helpers |
|
|
264
|
-
| [`src/blocks.ts`](src/blocks.ts) | Transcript components: user prompt, assistant reply, tool card, system prompt and injected context, notice; the navigable blocks expose their sections and draw the focus gutter, and the foldable ones carry the marker both fold keys name. Each block keeps the lines it last drew and a reply keeps the coloured fences of its last Markdown parse, so a frame of a settled transcript costs one key comparison per block and a stream delta colours only the fence that changed |
|
|
264
|
+
| [`src/blocks.ts`](src/blocks.ts) | Transcript components: user prompt, assistant reply, tool card, system prompt and injected context, notice; the navigable blocks expose their sections and draw the focus gutter, and the foldable ones carry the marker both fold keys name. Each block keeps the lines it last drew and a reply keeps the coloured fences of its last Markdown parse and re-lexes only the open tail after the last closed fence, so a frame of a settled transcript costs one key comparison per block and a stream delta colours only the fence that changed |
|
|
265
265
|
| [`src/context.ts`](src/context.ts) | Project logged system prompts and injected user messages into transcript sections |
|
|
266
266
|
| [`src/navigation.ts`](src/navigation.ts) | The transcript as sections, the cursor that walks them along four axes, the turns those sections group into, and the inspector heading |
|
|
267
267
|
| [`src/inspector.ts`](src/inspector.ts) | The docked inspector: the framed pane with its mode chip, the section heading, the numbered wrapping parts strip, the folded rows, and its mounted component |
|
|
@@ -238,7 +238,7 @@ runner 与 `dsh-headless` 一样是核心 API 载体之上的直接驱动器,
|
|
|
238
238
|
|
|
239
239
|
### 运行流程
|
|
240
240
|
|
|
241
|
-
runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心注册表之上构建含三个操作的会话宿主:`create` 用共享的 [`agentDefaultModel`](../../core/agent-default-model/README.zh.md) 选择创建一个全新的持久化 Agent,`resume`
|
|
241
|
+
runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心注册表之上构建含三个操作的会话宿主:`create` 用共享的 [`agentDefaultModel`](../../core/agent-default-model/README.zh.md) 选择创建一个全新的持久化 Agent,`resume` 先拿到 Agent 写句柄,再经 `ctx.sessionQuery` 观察实时 Session,使 bind 画出每条持久化事件(包括恢复时的闭合事件),`fork` 通过 `ctx.sessionQuery` 观察源会话、在所选(默认最后一个)`turn/end` 之后直到下一个 `turn/start` 处切割,并创建带 `parentSession` 与 `isSeeded` 元数据的种子 Agent。每个操作都在 Agent 的作用域 setup 中安装 `ModelSelectionRef`,因此 `/model` 会改变下一次请求。终端应用从 `--resume` 或一次新的 `create` 产生的会话开始,订阅 `session/event`、`agent/assistant-stream` 与 `agent/status`,只为绑定的 Agent 应答 `approval/request` 与 `user-questions/request` waterfall,并通过绑定下一个会话、dispose 先前句柄来切换会话;宿主打开下一个会话期间编辑器拒绝输入,等待期间退出会释放随后到达的会话。退出时取消任何进行中的轮次、等待完全停稳、flush 绑定的会话、dispose 其句柄并请求以 0 退出;驱动器失败会向 stderr 写入 `dsh: <message>` 并请求以 1 退出。`/resume` 与 `/sessions` 共用持久化会话选择器。编辑器中的 `Shift+Tab` 会派发空参数 `/effort` 以打开当前模型的推理强度选择器,而编辑器中的 `Shift+Left` / `Shift+Right` 使用 pi-tui 的词导航。`/login` 只带着订阅方法(除收集密钥的 `api-key` 登录外的每一种方法)启动 `authorization.begin`。flow 用 `openInBrowser` 标记的 notice 会经 `dsh-native-command` 的凭据擦除辅助进程交给默认浏览器,URL 同时保持打印;当 `openBrowser` 为 false、启动经过 SSH 或宿主没有桌面时抑制该交接,打开器失败则成为 URL 旁的一条通知,而非登录失败。编辑器里提交的非空 `!` 或 `!!` 行经本进程的 `ctx.shell` 运行;`!` 注入一条下一步通知,`!!` 只留在本地。
|
|
242
242
|
|
|
243
243
|
### 渲染模型
|
|
244
244
|
|
|
@@ -252,7 +252,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
|
|
|
252
252
|
|
|
253
253
|
| 文件 | 职责 |
|
|
254
254
|
|---|---|
|
|
255
|
-
| [`src/index.ts`](src/index.ts) | `tui-app` 插件:会话宿主(创建、恢复、fork
|
|
255
|
+
| [`src/index.ts`](src/index.ts) | `tui-app` 插件:会话宿主(创建、恢复、fork)、恢复观察、退出流程、退出码映射 |
|
|
256
256
|
| [`src/startup.ts`](src/startup.ts) | `tui-app-startup` 提供方:提示位置参数、`--resume`、`--no-open` 与 `--help` |
|
|
257
257
|
| [`src/app.ts`](src/app.ts) | 终端应用:布局、按键路由、命令、会话绑定、接缝、日志与流的折叠、停止装填、它挂载的临时提示行、阅读器所依托的终端交接,以及提交时解析的 `!` / `!!` |
|
|
258
258
|
| [`src/keys.ts`](src/keys.ts) | 按键模型:各焦点区域、一次按键在每个区域中的含义、它们逐级收缩的按键提示、进入用的按键、`/help` 的各行,以及交接窗口 |
|
|
@@ -261,7 +261,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
|
|
|
261
261
|
| [`src/permission.ts`](src/permission.ts) | `/permission` 的权限预设名称及选择器行 |
|
|
262
262
|
| [`src/attach.ts`](src/attach.ts) | `/attach`:本地文件经附件存储成为图片或文件块 |
|
|
263
263
|
| [`src/export.ts`](src/export.ts) | `/export`:通过导出包的归档辅助函数写出会话日志 ZIP |
|
|
264
|
-
| [`src/blocks.ts`](src/blocks.ts) | 对话记录组件:用户提示、assistant 回复、工具卡片、系统提示词与注入上下文、通知;可导航的块暴露其各小节并绘制焦点标记条,可折叠的块则承载两个折叠键共用的那条标记。每个块保留上次画出的行,回复还保留上次 Markdown
|
|
264
|
+
| [`src/blocks.ts`](src/blocks.ts) | 对话记录组件:用户提示、assistant 回复、工具卡片、系统提示词与注入上下文、通知;可导航的块暴露其各小节并绘制焦点标记条,可折叠的块则承载两个折叠键共用的那条标记。每个块保留上次画出的行,回复还保留上次 Markdown 解析所着色的代码围栏,并只对最后一个已关闭围栏之后仍打开的尾部重新词法分析,因此已稳定的对话记录每帧只花每块一次键比较,一次流式增量也只为发生变化的那个围栏着色 |
|
|
265
265
|
| [`src/context.ts`](src/context.ts) | 把已记录的系统提示词与注入的用户消息投影为对话记录小节 |
|
|
266
266
|
| [`src/navigation.ts`](src/navigation.ts) | 把对话记录看作各个小节、沿四条轴走遍它们的光标、这些小节归入的各轮次,以及检视面板的标题 |
|
|
267
267
|
| [`src/inspector.ts`](src/inspector.ts) | 停靠的检视面板:带模式徽标的边框面板、小节标题、带编号且会折行的各部分选择行、折叠后的各行,及其挂载的组件 |
|
|
@@ -2377,10 +2377,11 @@ function editorTheme(palette) {
|
|
|
2377
2377
|
* changes per frame - a fade's level, the focus mark's lift - is drawn over
|
|
2378
2378
|
* those kept lines. Fenced code is the expensive part of a reply, so a reply
|
|
2379
2379
|
* also keeps the coloured fences of its last Markdown parse
|
|
2380
|
-
* ({@link FenceMemo}): a stream delta re-
|
|
2381
|
-
* only the fence that changed. `invalidate()`
|
|
2382
|
-
* application calls on every block when a grammar
|
|
2383
|
-
* needs no call, because it misses every key on
|
|
2380
|
+
* ({@link FenceMemo}): a stream delta re-lexes only the open tail after the
|
|
2381
|
+
* last closed fence and colours only the fence that changed. `invalidate()`
|
|
2382
|
+
* drops all of it, which the application calls on every block when a grammar
|
|
2383
|
+
* lands; a new terminal width needs no call, because it misses every key on
|
|
2384
|
+
* its own.
|
|
2384
2385
|
* @module @deepseek-ai/dsh-tui-app/blocks
|
|
2385
2386
|
*/
|
|
2386
2387
|
/** Columns the focus gutter takes from the width a block's content wraps at. */
|
|
@@ -2470,9 +2471,9 @@ var LastDrawn = class {
|
|
|
2470
2471
|
/**
|
|
2471
2472
|
* The coloured fences of one reply, kept from one Markdown parse to the next.
|
|
2472
2473
|
*
|
|
2473
|
-
* pi-tui's `Markdown` re-parses
|
|
2474
|
-
*
|
|
2475
|
-
*
|
|
2474
|
+
* pi-tui's `Markdown` re-parses whenever its text changes and asks the theme
|
|
2475
|
+
* to colour every fence it finds, so a streaming reply that already carries
|
|
2476
|
+
* three fences would colour all three on every delta of the open tail.
|
|
2476
2477
|
* This keeps what the last parse asked for: a fence that is asked for again
|
|
2477
2478
|
* is answered from memory, and a fence the last parse did not ask for is
|
|
2478
2479
|
* dropped at the next {@link FenceMemo.settle}, so the memo never holds more
|
|
@@ -2709,6 +2710,59 @@ var ContextBlock = class {
|
|
|
2709
2710
|
}
|
|
2710
2711
|
};
|
|
2711
2712
|
/**
|
|
2713
|
+
* Source through the last closed fenced block, including the newline that
|
|
2714
|
+
* follows the closer when the message still has one. An unclosed fence, or a
|
|
2715
|
+
* reply with no fence, yields an empty prefix so the whole message is lexed.
|
|
2716
|
+
* @param text - the live Markdown source.
|
|
2717
|
+
* @returns the closed prefix, or the empty string.
|
|
2718
|
+
*/
|
|
2719
|
+
function closedFencePrefix(text) {
|
|
2720
|
+
let last = 0;
|
|
2721
|
+
let index = 0;
|
|
2722
|
+
let open;
|
|
2723
|
+
while (index <= text.length) {
|
|
2724
|
+
const newline = text.indexOf("\n", index);
|
|
2725
|
+
const end = newline === -1 ? text.length : newline;
|
|
2726
|
+
const line = text.slice(index, end);
|
|
2727
|
+
let indent = 0;
|
|
2728
|
+
while (indent < 3 && line[indent] === " ") indent += 1;
|
|
2729
|
+
const rest = line.slice(indent);
|
|
2730
|
+
const marker = /^(`{3,}|~{3,})/.exec(rest)?.[1];
|
|
2731
|
+
if (marker !== void 0) {
|
|
2732
|
+
const info = rest.slice(marker.length);
|
|
2733
|
+
if (open === void 0) {
|
|
2734
|
+
if (!(marker.startsWith("`") && info.includes("`"))) open = {
|
|
2735
|
+
char: marker[0],
|
|
2736
|
+
length: marker.length
|
|
2737
|
+
};
|
|
2738
|
+
} else if (marker[0] === open.char && marker.length >= open.length && info.trim() === "") {
|
|
2739
|
+
last = newline === -1 ? text.length : newline + 1;
|
|
2740
|
+
open = void 0;
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
if (newline === -1) break;
|
|
2744
|
+
index = newline + 1;
|
|
2745
|
+
}
|
|
2746
|
+
return text.slice(0, last);
|
|
2747
|
+
}
|
|
2748
|
+
/**
|
|
2749
|
+
* Stack a closed-fence drawing and the open tail the way one Markdown parse
|
|
2750
|
+
* would: a fence adds a blank line before the next block unless that block
|
|
2751
|
+
* is a blank-line token (the tail then starts with a newline).
|
|
2752
|
+
* @param prefixLines - the cached prefix drawing.
|
|
2753
|
+
* @param tail - the unparsed tail source.
|
|
2754
|
+
* @param tailLines - the tail drawing.
|
|
2755
|
+
* @returns the combined Markdown lines.
|
|
2756
|
+
*/
|
|
2757
|
+
function joinFencePrefix(prefixLines, tail, tailLines) {
|
|
2758
|
+
if (tail.startsWith("\n")) return [...prefixLines, ...tailLines];
|
|
2759
|
+
return [
|
|
2760
|
+
...prefixLines,
|
|
2761
|
+
"",
|
|
2762
|
+
...tailLines
|
|
2763
|
+
];
|
|
2764
|
+
}
|
|
2765
|
+
/**
|
|
2712
2766
|
* An assistant reply: streamed reasoning above streamed Markdown text. The
|
|
2713
2767
|
* durable `assistant/message` replaces both with the committed content.
|
|
2714
2768
|
*
|
|
@@ -2728,6 +2782,14 @@ var AssistantBlock = class {
|
|
|
2728
2782
|
text = "";
|
|
2729
2783
|
interrupted = false;
|
|
2730
2784
|
markdown;
|
|
2785
|
+
/** Closed-fence prefix, parsed only when that prefix or the width changes. */
|
|
2786
|
+
prefixMarkdown;
|
|
2787
|
+
/** Last prefix drawing, reused while the closed fences and width hold. */
|
|
2788
|
+
prefixCache;
|
|
2789
|
+
/** Last text handed to {@link AssistantBlock.markdown}, so fade ticks do not re-lex. */
|
|
2790
|
+
appliedTail;
|
|
2791
|
+
/** Last text handed to {@link AssistantBlock.prefixMarkdown}. */
|
|
2792
|
+
appliedPrefix;
|
|
2731
2793
|
reasoningText;
|
|
2732
2794
|
fade;
|
|
2733
2795
|
/** Width of the last render that drew a text tail; absent before the first one. */
|
|
@@ -2752,7 +2814,9 @@ var AssistantBlock = class {
|
|
|
2752
2814
|
this.turn = turn;
|
|
2753
2815
|
const palette = theme.palette;
|
|
2754
2816
|
this.fences = theme.codeHighlight === void 0 ? void 0 : new FenceMemo(theme.codeHighlight);
|
|
2755
|
-
|
|
2817
|
+
const themeForMarkdown = markdownTheme(palette, this.fences);
|
|
2818
|
+
this.markdown = new Markdown("", 0, 0, themeForMarkdown);
|
|
2819
|
+
this.prefixMarkdown = new Markdown("", 0, 0, themeForMarkdown);
|
|
2756
2820
|
this.reasoningText = new Text("", 0, 0);
|
|
2757
2821
|
}
|
|
2758
2822
|
/**
|
|
@@ -2817,7 +2881,6 @@ var AssistantBlock = class {
|
|
|
2817
2881
|
appendText(delta) {
|
|
2818
2882
|
this.text += delta;
|
|
2819
2883
|
this.revision += 1;
|
|
2820
|
-
this.markdown.setText(this.text);
|
|
2821
2884
|
}
|
|
2822
2885
|
/**
|
|
2823
2886
|
* Append streamed reasoning text.
|
|
@@ -2841,11 +2904,17 @@ var AssistantBlock = class {
|
|
|
2841
2904
|
this.revision += 1;
|
|
2842
2905
|
this.fade = void 0;
|
|
2843
2906
|
this.reasoningFade = void 0;
|
|
2844
|
-
this.
|
|
2907
|
+
this.prefixCache = void 0;
|
|
2908
|
+
this.appliedPrefix = void 0;
|
|
2909
|
+
this.appliedTail = void 0;
|
|
2845
2910
|
this.reasoningText.setText(this.theme.palette.dim(this.theme.palette.italic(reasoning.trimEnd())));
|
|
2846
2911
|
}
|
|
2847
2912
|
invalidate() {
|
|
2848
2913
|
this.markdown.invalidate();
|
|
2914
|
+
this.prefixMarkdown.invalidate();
|
|
2915
|
+
this.prefixCache = void 0;
|
|
2916
|
+
this.appliedPrefix = void 0;
|
|
2917
|
+
this.appliedTail = void 0;
|
|
2849
2918
|
this.reasoningText.invalidate();
|
|
2850
2919
|
this.fences?.clear();
|
|
2851
2920
|
this.drawn.clear();
|
|
@@ -2921,13 +2990,58 @@ var AssistantBlock = class {
|
|
|
2921
2990
|
*/
|
|
2922
2991
|
renderText(width, at) {
|
|
2923
2992
|
const fade = this.fade;
|
|
2924
|
-
const lines = this.
|
|
2993
|
+
const lines = this.renderMarkdown(width);
|
|
2925
2994
|
this.fences?.settle();
|
|
2926
2995
|
if (fade === void 0) return lines;
|
|
2927
2996
|
if (this.fadeWidth !== void 0 && this.fadeWidth !== width) fade.flush();
|
|
2928
2997
|
this.fadeWidth = width;
|
|
2929
2998
|
return recolorTail(lines, fadingInSpans(fade), fade.style(), this.repaintFloor - at);
|
|
2930
2999
|
}
|
|
3000
|
+
/**
|
|
3001
|
+
* Lex the open tail and reuse the closed-fence prefix at this width.
|
|
3002
|
+
* @param width - the width the Markdown lays out in.
|
|
3003
|
+
* @returns the Markdown lines, fade not yet applied.
|
|
3004
|
+
*/
|
|
3005
|
+
renderMarkdown(width) {
|
|
3006
|
+
const prefix = closedFencePrefix(this.text);
|
|
3007
|
+
if (prefix.length === 0) {
|
|
3008
|
+
this.prefixCache = void 0;
|
|
3009
|
+
this.appliedPrefix = void 0;
|
|
3010
|
+
this.applyMarkdown(this.markdown, this.text, "tail");
|
|
3011
|
+
return this.markdown.render(width);
|
|
3012
|
+
}
|
|
3013
|
+
const tail = this.text.slice(prefix.length);
|
|
3014
|
+
let prefixLines = this.prefixCache;
|
|
3015
|
+
if (prefixLines === void 0 || prefixLines.text !== prefix || prefixLines.width !== width) {
|
|
3016
|
+
this.applyMarkdown(this.prefixMarkdown, prefix, "prefix");
|
|
3017
|
+
prefixLines = {
|
|
3018
|
+
text: prefix,
|
|
3019
|
+
width,
|
|
3020
|
+
lines: this.prefixMarkdown.render(width)
|
|
3021
|
+
};
|
|
3022
|
+
this.prefixCache = prefixLines;
|
|
3023
|
+
}
|
|
3024
|
+
if (tail.trim() === "") return prefixLines.lines;
|
|
3025
|
+
this.applyMarkdown(this.markdown, tail, "tail");
|
|
3026
|
+
return joinFencePrefix(prefixLines.lines, tail, this.markdown.render(width));
|
|
3027
|
+
}
|
|
3028
|
+
/**
|
|
3029
|
+
* Hand `text` to `markdown` only when it differs, so a fade tick does not re-lex.
|
|
3030
|
+
* @param markdown - the prefix or tail instance.
|
|
3031
|
+
* @param text - the source that instance should hold.
|
|
3032
|
+
* @param which - which applied-text slot to update.
|
|
3033
|
+
*/
|
|
3034
|
+
applyMarkdown(markdown, text, which) {
|
|
3035
|
+
if (which === "prefix") {
|
|
3036
|
+
if (this.appliedPrefix === text) return;
|
|
3037
|
+
markdown.setText(text);
|
|
3038
|
+
this.appliedPrefix = text;
|
|
3039
|
+
return;
|
|
3040
|
+
}
|
|
3041
|
+
if (this.appliedTail === text) return;
|
|
3042
|
+
markdown.setText(text);
|
|
3043
|
+
this.appliedTail = text;
|
|
3044
|
+
}
|
|
2931
3045
|
};
|
|
2932
3046
|
/**
|
|
2933
3047
|
* A tool call card: status glyph, tool name, headline, then a foldable body.
|
|
@@ -11523,28 +11637,29 @@ const internals = {
|
|
|
11523
11637
|
canOpenUrl: () => canOpenNativePath(),
|
|
11524
11638
|
openUrl: openNativeUrl
|
|
11525
11639
|
};
|
|
11526
|
-
/**
|
|
11527
|
-
|
|
11528
|
-
|
|
11529
|
-
*
|
|
11530
|
-
*
|
|
11531
|
-
* @
|
|
11532
|
-
* @
|
|
11533
|
-
|
|
11534
|
-
|
|
11535
|
-
|
|
11536
|
-
|
|
11537
|
-
|
|
11538
|
-
|
|
11640
|
+
/**
|
|
11641
|
+
* Events the terminal binds after the Agent has taken the write handle.
|
|
11642
|
+
* The live Session already includes interrupted-turn closers resume appended.
|
|
11643
|
+
* @param ctx - plugin context carrying the session query engine.
|
|
11644
|
+
* @param id - the session the Agent just resumed.
|
|
11645
|
+
* @returns the persisted events in log order, closers included.
|
|
11646
|
+
* @throws when no query engine is composed.
|
|
11647
|
+
*/
|
|
11648
|
+
async function observeBoundHistory(ctx, id) {
|
|
11649
|
+
const env_1 = {
|
|
11650
|
+
stack: [],
|
|
11651
|
+
error: void 0,
|
|
11652
|
+
hasError: false
|
|
11653
|
+
};
|
|
11539
11654
|
try {
|
|
11540
|
-
const
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
|
|
11655
|
+
const query = ctx.get("sessionQuery");
|
|
11656
|
+
if (query === void 0) throw new Error("tui-app: resuming a session needs a composed session query engine");
|
|
11657
|
+
return __addDisposableResource(env_1, await query.observeSession(id, { projectionMode: "none" }), false).events;
|
|
11658
|
+
} catch (e_1) {
|
|
11659
|
+
env_1.error = e_1;
|
|
11660
|
+
env_1.hasError = true;
|
|
11546
11661
|
} finally {
|
|
11547
|
-
|
|
11662
|
+
__disposeResources(env_1);
|
|
11548
11663
|
}
|
|
11549
11664
|
}
|
|
11550
11665
|
/**
|
|
@@ -11573,7 +11688,7 @@ function coreServices(ctx) {
|
|
|
11573
11688
|
* @throws when no query engine is composed or the session has no such completed turn.
|
|
11574
11689
|
*/
|
|
11575
11690
|
async function forkSeed(ctx, id, turn) {
|
|
11576
|
-
const
|
|
11691
|
+
const env_2 = {
|
|
11577
11692
|
stack: [],
|
|
11578
11693
|
error: void 0,
|
|
11579
11694
|
hasError: false
|
|
@@ -11581,17 +11696,17 @@ async function forkSeed(ctx, id, turn) {
|
|
|
11581
11696
|
try {
|
|
11582
11697
|
const query = ctx.get("sessionQuery");
|
|
11583
11698
|
if (query === void 0) throw new Error("forking a session needs a composed session query engine");
|
|
11584
|
-
const source = __addDisposableResource(
|
|
11699
|
+
const source = __addDisposableResource(env_2, await query.observeSession(id), false);
|
|
11585
11700
|
const boundary = source.events.findLast((event) => event.type === "turn/end" && (turn === void 0 || event.data.turn === turn));
|
|
11586
11701
|
if (boundary === void 0) throw new Error(turn === void 0 ? `session ${id} has no completed turn to fork from` : `session ${id} has no completed turn ${String(turn)} to fork from`);
|
|
11587
11702
|
let cut = boundary.seq + 1;
|
|
11588
11703
|
while (cut < source.events.length && source.events[cut]?.type !== "turn/start") cut += 1;
|
|
11589
11704
|
return source.events.slice(0, cut);
|
|
11590
|
-
} catch (
|
|
11591
|
-
|
|
11592
|
-
|
|
11705
|
+
} catch (e_2) {
|
|
11706
|
+
env_2.error = e_2;
|
|
11707
|
+
env_2.hasError = true;
|
|
11593
11708
|
} finally {
|
|
11594
|
-
__disposeResources(
|
|
11709
|
+
__disposeResources(env_2);
|
|
11595
11710
|
}
|
|
11596
11711
|
}
|
|
11597
11712
|
/**
|
|
@@ -11645,10 +11760,25 @@ function sessionHost(ctx, core, cwd) {
|
|
|
11645
11760
|
}, seed ?? []);
|
|
11646
11761
|
return {
|
|
11647
11762
|
create: () => create(void 0, void 0),
|
|
11648
|
-
resume: async (id) =>
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11763
|
+
resume: async (id) => {
|
|
11764
|
+
const selection = {
|
|
11765
|
+
current: void 0,
|
|
11766
|
+
assembled: void 0
|
|
11767
|
+
};
|
|
11768
|
+
const handle = await agents.resume({
|
|
11769
|
+
resumeSessionId: id,
|
|
11770
|
+
setup: (agentCtx) => {
|
|
11771
|
+
installModelSelection(agentCtx, selection);
|
|
11772
|
+
}
|
|
11773
|
+
});
|
|
11774
|
+
await handle.agent.whenIdle();
|
|
11775
|
+
return {
|
|
11776
|
+
agent: handle.agent,
|
|
11777
|
+
selection,
|
|
11778
|
+
history: await observeBoundHistory(ctx, id),
|
|
11779
|
+
dispose: () => handle.dispose()
|
|
11780
|
+
};
|
|
11781
|
+
},
|
|
11652
11782
|
fork: async (id, turn) => create(await forkSeed(ctx, id, turn), id)
|
|
11653
11783
|
};
|
|
11654
11784
|
}
|
package/package.json
CHANGED