@morlay/better-session 0.0.10 → 0.0.12
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 +64 -0
- package/dist/invariant.d.mts +8 -0
- package/dist/invariant.d.mts.map +1 -0
- package/dist/invariant.mjs +10 -0
- package/dist/invariant.mjs.map +1 -0
- package/package.json +15 -14
- package/src/invariant.ts +13 -0
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# @morlay/better-session
|
|
2
|
+
|
|
3
|
+
profile 聚合 bundle:一次性装配 `@morlay/session-branch`、
|
|
4
|
+
`@morlay/session-rdb`、`@morlay/ui-conversation-message-actions` 到
|
|
5
|
+
DeepSeek Harness web profile,提供 **就地编辑 / 重试 / 分支**
|
|
6
|
+
(rewind / retry / fork)闭环。
|
|
7
|
+
|
|
8
|
+
## 安装
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
dsh plugin --profile web add "@morlay/better-session"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
安装自动带上子包(`@morlay/session-branch`、`@morlay/session-rdb`、
|
|
15
|
+
`@morlay/ui-conversation-message-actions`),并由 bundle 的 patch
|
|
16
|
+
(`cordis.patch.yml`)自动装配:
|
|
17
|
+
|
|
18
|
+
- `ctx.sessionPersistence` ← RDB(SQLite / PostgreSQL)持久化后端
|
|
19
|
+
- `ctx.sessionBranch` ← rewind / fork 数据层
|
|
20
|
+
- `ctx.sessionEditor` ← edit / retry / fork 编排(HTTP:`/session-editor`)
|
|
21
|
+
- `conversation.chat.node` ← 渲染替换(user 消息行内编辑 / 重试按钮)
|
|
22
|
+
|
|
23
|
+
## 使用
|
|
24
|
+
|
|
25
|
+
装配后即可在 GUI 会话中:
|
|
26
|
+
|
|
27
|
+
- **编辑** user 消息 → 就地重写并重放(重新生成回复)
|
|
28
|
+
- **重试** 任意闭合回合 → 就地重放该回合输入(带确认弹窗)
|
|
29
|
+
- **分支**(fork)→ 从任意闭合边界派生**新会话**
|
|
30
|
+
|
|
31
|
+
也可以直接调用服务:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
// 编排层(host)
|
|
35
|
+
await ctx.sessionEditor.retry({ action: "retry", sessionId, turn: 2, cascade: "truncate" });
|
|
36
|
+
// 数据层
|
|
37
|
+
await ctx.sessionBranch.rewind(sessionId, 5);
|
|
38
|
+
await ctx.sessionBranch.forkFrom(sourceId, { atSeq: 6, childSessionId });
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 配置(rdb)
|
|
42
|
+
|
|
43
|
+
默认配置为 SQLite(`$DSH_HOME/sessions/sessions.sqlite`)。在
|
|
44
|
+
`$DSH_HOME/settings.yaml` 覆盖 `session-rdb` namespace:
|
|
45
|
+
|
|
46
|
+
```yaml
|
|
47
|
+
session-rdb:
|
|
48
|
+
type: sqlite # 或 postgres + connectionString
|
|
49
|
+
path: /abs/path/to/sessions.sqlite
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 本地开发
|
|
53
|
+
|
|
54
|
+
本包是 monorepo(pnpm workspaces)的一员,命令入口见根 [justfile](../../justfile):
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
just dep # 安装依赖
|
|
58
|
+
just build # 构建全部包(tsdown)
|
|
59
|
+
just test # vitest(含 PostgreSQL 契约测试,需 TEST_PG_URL)
|
|
60
|
+
just lint # oxlint
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
架构与约定见 [docs/ARCHITECTURE.md](../../docs/ARCHITECTURE.md) 与
|
|
64
|
+
[docs/CODING_GUIDELINE.md](../../docs/CODING_GUIDELINE.md)。
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
//#region src/invariant.d.ts
|
|
3
|
+
declare const name = "web-app-invariant";
|
|
4
|
+
declare const inject: string[];
|
|
5
|
+
declare const apply: (ctx: Context) => Promise<() => void>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { apply, inject, name };
|
|
8
|
+
//# sourceMappingURL=invariant.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invariant.d.mts","names":[],"sources":["../src/invariant.ts"],"mappings":";;cAKa;cAEA;cAIA,QAAK,KAAS,YAAU"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/invariant.ts
|
|
2
|
+
const PACKAGE_NAME = "@morlay/better-session";
|
|
3
|
+
const name = "web-app-invariant";
|
|
4
|
+
const inject = ["invariants"];
|
|
5
|
+
const install = () => {};
|
|
6
|
+
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
7
|
+
//#endregion
|
|
8
|
+
export { apply, inject, name };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=invariant.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invariant.mjs","names":[],"sources":["../src/invariant.ts"],"sourcesContent":["import type { Context } from \"@deepseek-ai/cordis\";\nimport type { InvariantInstaller } from \"@deepseek-ai/dsh-invariants\";\n\nconst PACKAGE_NAME = \"@morlay/better-session\";\n\nexport const name = \"web-app-invariant\";\n\nexport const inject = [\"invariants\"];\n\nconst install: InvariantInstaller = () => {};\n\nexport const apply = (ctx: Context): Promise<() => void> =>\n Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));\n"],"mappings":";AAGA,MAAM,eAAe;AAErB,MAAa,OAAO;AAEpB,MAAa,SAAS,CAAC,YAAY;AAEnC,MAAM,gBAAoC,CAAC;AAE3C,MAAa,SAAS,QACpB,QAAQ,QAAQ,IAAI,WAAW,SAAS,cAAc,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morlay/better-session",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "Example dsh profile bundle: assembles @morlay/session-rdb and @morlay/ui-conversation-message-actions into a web profile — rewind / retry / fork closed loop on RDB persistence.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -17,31 +17,32 @@
|
|
|
17
17
|
"url": "https://github.com/morlay/better-session.git"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"src",
|
|
20
22
|
"cordis.patch.yml",
|
|
21
|
-
"
|
|
23
|
+
"!**/__tests__"
|
|
22
24
|
],
|
|
23
25
|
"type": "module",
|
|
24
26
|
"exports": {
|
|
25
|
-
"./invariant"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
30
|
-
"./package.json": "./package.json"
|
|
27
|
+
".": "./dist/invariant.mjs",
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
"./cordis.patch.yml": "./cordis.patch.yml"
|
|
31
30
|
},
|
|
32
31
|
"dependencies": {
|
|
33
|
-
"@morlay/session-branch": "^0.0.
|
|
34
|
-
"@morlay/session-rdb": "^0.0.
|
|
35
|
-
"@morlay/ui-conversation-message-actions": "^0.0.
|
|
32
|
+
"@morlay/session-branch": "^0.0.2",
|
|
33
|
+
"@morlay/session-rdb": "^0.0.12",
|
|
34
|
+
"@morlay/ui-conversation-message-actions": "^0.0.12"
|
|
36
35
|
},
|
|
37
36
|
"peerDependencies": {
|
|
38
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
39
|
-
"@deepseek-ai/dsh-invariants": "^0.1.
|
|
37
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
38
|
+
"@deepseek-ai/dsh-invariants": "^0.1.2-rc.1"
|
|
40
39
|
},
|
|
41
40
|
"dsh": {
|
|
42
41
|
"bundle": {
|
|
43
42
|
"patch": "./cordis.patch.yml"
|
|
44
43
|
}
|
|
45
44
|
},
|
|
46
|
-
"scripts": {
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "pnpm exec tsdown"
|
|
47
|
+
}
|
|
47
48
|
}
|
package/src/invariant.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import type { InvariantInstaller } from "@deepseek-ai/dsh-invariants";
|
|
3
|
+
|
|
4
|
+
const PACKAGE_NAME = "@morlay/better-session";
|
|
5
|
+
|
|
6
|
+
export const name = "web-app-invariant";
|
|
7
|
+
|
|
8
|
+
export const inject = ["invariants"];
|
|
9
|
+
|
|
10
|
+
const install: InvariantInstaller = () => {};
|
|
11
|
+
|
|
12
|
+
export const apply = (ctx: Context): Promise<() => void> =>
|
|
13
|
+
Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|