@morlay/ui-conversation-message-actions 0.0.9

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 morlay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # @morlay/ui-conversation-message-actions
2
+
3
+ `rewind / retry / fork` 的**编排层**:在 `@morlay/session-branch` 的 provider
4
+ 抽象之上组装完整功能(产品语义对齐 [dsh-message-edit](https://github.com/Moeblack/dsh-message-edit)),
5
+ 并提供**浏览器半**(client bundle):替换 `conversation.chat.node` 渲染,
6
+ 在 user 消息行内直接挂编辑 / 重试入口。
7
+
8
+ ## 服务面(`ctx.sessionEditor`)
9
+
10
+ | 操作 | 语义 |
11
+ | ---------- | --------------------------------------------------------------------------------- |
12
+ | `edit` | 编辑已落定文本块(用户消息 / 助手块),**就地**(rewind + 重写,session id 不变) |
13
+ | `reroll` | 重生成最后一条已落定助手回复(使用原用户输入) |
14
+ | `retry` | 重试任意历史回合(`truncate` 只重放目标输入 / `preserve` 重放后续全部) |
15
+ | `rewind` | 截断式回退:原会话回退到闭合 `turn/end` 边界 |
16
+ | `fork` | 从任意闭合边界派生**新会话**(唯一产生新 id 的操作) |
17
+ | `timeline` | 版本树投影(HTTP:`GET /session-editor?sessionId=…`) |
18
+
19
+ ## 就地编辑语义
20
+
21
+ - **edit / retry / reroll 是就地操作**:`rewind` 截断到目标轮之前的闭合
22
+ `turn/end` 边界,再 `append` 版本效果 + 手工回合 / 重放输入回**同一会话**
23
+ ——session id 不变,版本树保持单根;
24
+ - **只有 `fork` 创建新 id**(`ForkOperation` / `forkFrom`,纯 append 派生);
25
+ - 版本效果事件(`session-branch/version`)携带 `ignorable: true`:live log 可见、
26
+ **不落 canonical log**(rdb 持久化时过滤并稠密化剩余事件);
27
+ - 重放输入经 agent 驱动(见下)排队到原会话,agent 基于截断后历史回复。
28
+
29
+ ## agent 驱动(重放排队输入)
30
+
31
+ `agents` 服务以 duck-typed 接口使用(不硬依赖 `@deepseek-ai/dsh-agent`),
32
+ 缺失时退化为「已 durable 的就地版本」(可随时 resume 续跑):
33
+
34
+ - **live agent**(会话驻留 / 已恢复):直接 `followup` 排队,不重建、不换 id;
35
+ - **cold 会话**:`resume` 已持久化会话(`create` 对已持久化日志必失败),
36
+ resume 后 agent 驻留(不 dispose,避免 session 被移出 store 破坏客户端窗口);
37
+ - 模型 provider/model 在 **rewind 之前**从 `request/header` 解析(就地编辑
38
+ 可能截断掉 header,编辑第一轮 boundary = -1 时尤甚)。
39
+
40
+ ## 浏览器半(client bundle)
41
+
42
+ `lib/client.js` 经 `__ModuleLoader__.load` 手递,替换整个 `conversation.chat.node`:
43
+
44
+ - **shadow 注册**:12 个 key(user / steering / context / assistant-step /
45
+ command / manual-compaction / compaction / model-retry / turn-error /
46
+ turn-max-tokens / turn-tail / unknown)全部以 `priority: -1` 重新注册,
47
+ 最低优先级渲染,shadow 上游渲染器;
48
+ - **编辑 / 重试按钮只挂在 user 消息**(`UserMessageNodeView`):编辑弹窗复用
49
+ dsh settings 同款 `Modal` + `Button`,输入框复用 composer-card 视觉与自动
50
+ 增长;重试先弹确认;未闭合轮次不显示重试;
51
+ - **操作后刷新**:就地编辑后优先调用客户端会话级 `resync()`(重置窗口并重新
52
+ 拉取历史,不整页重载——rewind 的删除无法经 append-only 事件流表达,seq
53
+ 回退只做增量会残留旧节点),不可用时回退 `location.reload()`;
54
+ - **构建约束**:client bundle 必须是**单文件**(client-modules 只服务/加载
55
+ `client.js`)——`noExternal` 全内联第三方 + `inlineDynamicImports` 合并
56
+ 动态 import,`@deepseek-ai/*` 一律 external(平台 seed 词或独立插件,
57
+ 内联会把别的插件的 `__ModuleLoader__.load` 嵌进来导致 duplicate factory);
58
+ CSS Modules 经 lightningcss 内联 + `<style data-plugin>` 注入。
59
+
60
+ ## 分层边界
61
+
62
+ - 数据层(`forkFrom` / `rewind` / `readBranchPrefix` / `syncLiveCursor`)来自
63
+ `ctx.sessionBranch`(provider 实现,如 `@morlay/session-rdb`);
64
+ - 本服务只做**编排**:闭合轮次扫描、版本效果事件构造、派生 seed 组装、
65
+ rewind 命令透传、agent 驱动、HTTP 面(`POST /session-editor` 执行
66
+ edit / reroll / retry / rewind / fork)。
67
+
68
+ ## 装配
69
+
70
+ ```yaml
71
+ # cordis.patch.yml
72
+ - insert:
73
+ - id: session-editor
74
+ name: "@morlay/ui-conversation-message-actions"
75
+ ```
76
+
77
+ 依赖 `ctx.sessionBranch`(需先装配 `@morlay/session-rdb` 等
78
+ provider 实现)与 `ctx.sessions`(dsh-session);`agents` 可选。
79
+
80
+ ## 测试
81
+
82
+ ```sh
83
+ just test packages/ui-conversation-message-actions
84
+ ```
85
+
86
+ 端到端装配真实 rdb 后端,验证 retry / rewind / fork / timeline 闭环,
87
+ 以及 live 会话的 rewind(内存 log / coordinator cursor 同步)与 agent 重放。
@@ -0,0 +1,9 @@
1
+ # @morlay/ui-conversation-message-actions bundle patch.
2
+ #
3
+ # 在 profile 的 dsh.profile.bundles 中列出本包后,本 patch 插入编排层插件行,
4
+ # 注册 ctx.sessionEditor。依赖 ctx.sessionBranch(由 provider 实现插件如
5
+ # @morlay/session-rdb 提供),请确保其在 bundles 中排在前面。
6
+
7
+ - insert:
8
+ - id: ui-conversation-message-actions
9
+ name: "@morlay/ui-conversation-message-actions"