@morlay/ui-conversation-message-actions 0.0.19-alpha.3 → 0.0.19-alpha.4
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 +4 -3
- package/dist/client.cjs +39 -179
- package/dist/index.d.cts +3 -6
- package/dist/index.d.mts +3 -6
- package/dist/index.mjs +8 -86
- package/dist/{plan-CT_6Y1fD.d.cts → plan-BKgGPZdD.d.mts} +2 -3
- package/dist/{plan-Cm9hCord.d.mts → plan-BUTplrpz.d.cts} +2 -3
- package/dist/plan.d.cts +1 -1
- package/dist/plan.d.mts +1 -1
- package/dist/plan.mjs +2 -49
- package/dist/shared-BBbOTwy4.mjs +4 -0
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.mts +2 -2
- package/dist/testing.mjs +582 -199
- package/package.json +6 -6
- package/src/client/chat-node/MessageItem.tsx +6 -3
- package/src/client/controller.ts +58 -221
- package/src/client/index.ts +0 -4
- package/src/index.ts +5 -143
- package/src/plan.ts +2 -54
- package/src/shared.ts +1 -96
- package/src/testing.ts +0 -2
- package/src/types.ts +1 -3
- package/dist/shared-LK3nImWW.mjs +0 -55
package/dist/plan.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SessionSeq } from "@deepseek-ai/dsh-session";
|
|
2
|
-
import {
|
|
2
|
+
import { SessionBranchError } from "@morlay/session-branch";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
//#region src/plan.ts
|
|
5
5
|
function isTextualBlock(block) {
|
|
@@ -139,19 +139,6 @@ function assistantReplacement(event, blockIndex, text) {
|
|
|
139
139
|
})
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
|
-
function pairVersionEffect(sourceSessionId, effect) {
|
|
143
|
-
return {
|
|
144
|
-
schemaVersion: SESSION_BRANCH_VERSION_SCHEMA,
|
|
145
|
-
effect: {
|
|
146
|
-
...effect,
|
|
147
|
-
id: randomUUID()
|
|
148
|
-
},
|
|
149
|
-
inverse: {
|
|
150
|
-
kind: "restore-version",
|
|
151
|
-
sessionId: sourceSessionId
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
142
|
function editPlan(operation, turns) {
|
|
156
143
|
const turnIndex = turns.findIndex((turn) => operation.eventSeq > turn.startSeq && (turn.endSeq === void 0 || operation.eventSeq < turn.endSeq));
|
|
157
144
|
const turn = turns[turnIndex];
|
|
@@ -159,8 +146,7 @@ function editPlan(operation, turns) {
|
|
|
159
146
|
const event = turn.users.find((candidate) => candidate.seq === operation.eventSeq) ?? turn.assistants.find((candidate) => candidate.seq === operation.eventSeq);
|
|
160
147
|
if (event === void 0) throw new SessionBranchError("所选消息不存在或不可编辑。", "INVALID_BOUNDARY");
|
|
161
148
|
if (event.type === "user/message") {
|
|
162
|
-
|
|
163
|
-
if (before?.type !== "text") throw new SessionBranchError("所选用户消息块不是文本。", "INVALID_BOUNDARY");
|
|
149
|
+
if (event.data.content[operation.blockIndex]?.type !== "text") throw new SessionBranchError("所选用户消息块不是文本。", "INVALID_BOUNDARY");
|
|
164
150
|
const edited = cloneUser(event.data, replaceTextBlock(event.data.content, operation.blockIndex, operation.text));
|
|
165
151
|
const userIndex = turn.users.findIndex((candidate) => candidate.seq === event.seq);
|
|
166
152
|
const sameTurnFollowups = turn.users.slice(userIndex + 1).map((user) => cloneUser(user.data));
|
|
@@ -168,16 +154,6 @@ function editPlan(operation, turns) {
|
|
|
168
154
|
return {
|
|
169
155
|
anchorSeq: turn.startSeq,
|
|
170
156
|
...userIndex === 0 ? {} : { rewindBoundary: event.seq },
|
|
171
|
-
version: pairVersionEffect(operation.sessionId, {
|
|
172
|
-
operation: "edit",
|
|
173
|
-
cascade: operation.cascade,
|
|
174
|
-
targetTurn: turn.turn,
|
|
175
|
-
targetEventSeq: event.seq,
|
|
176
|
-
targetBlockIndex: operation.blockIndex,
|
|
177
|
-
blockKind: "user",
|
|
178
|
-
before: before.text,
|
|
179
|
-
after: operation.text
|
|
180
|
-
}),
|
|
181
157
|
queuedUsers: [
|
|
182
158
|
edited,
|
|
183
159
|
...sameTurnFollowups,
|
|
@@ -189,20 +165,9 @@ function editPlan(operation, turns) {
|
|
|
189
165
|
if (!turn.closed) throw new SessionBranchError("未闭合轮次的助手消息不可编辑。", "INVALID_BOUNDARY");
|
|
190
166
|
const before = event.data.message.content[operation.blockIndex];
|
|
191
167
|
if (!isTextualBlock(before)) throw new SessionBranchError("所选助手消息块不是文本或思考。", "INVALID_BOUNDARY");
|
|
192
|
-
const blockKind = before.type === "reasoning" ? "assistant.reasoning" : "assistant.response";
|
|
193
168
|
if (turn.user === void 0) throw new SessionBranchError("所选助手消息没有可重建的用户输入。", "INVALID_BOUNDARY");
|
|
194
169
|
return {
|
|
195
170
|
anchorSeq: turn.startSeq,
|
|
196
|
-
version: pairVersionEffect(operation.sessionId, {
|
|
197
|
-
operation: "edit",
|
|
198
|
-
cascade: operation.cascade,
|
|
199
|
-
targetTurn: turn.turn,
|
|
200
|
-
targetEventSeq: event.seq,
|
|
201
|
-
targetBlockIndex: operation.blockIndex,
|
|
202
|
-
blockKind,
|
|
203
|
-
before: before.text,
|
|
204
|
-
after: operation.text
|
|
205
|
-
}),
|
|
206
171
|
manualTurn: {
|
|
207
172
|
turn: turn.turn,
|
|
208
173
|
user: cloneUser(turn.user.data),
|
|
@@ -218,12 +183,6 @@ function retryPlan(operation, turns) {
|
|
|
218
183
|
if (turn?.user === void 0) throw new SessionBranchError("所选回合没有可重放的用户输入。", "INVALID_BOUNDARY");
|
|
219
184
|
return {
|
|
220
185
|
anchorSeq: turn.startSeq,
|
|
221
|
-
version: pairVersionEffect(operation.sessionId, {
|
|
222
|
-
operation: "retry",
|
|
223
|
-
cascade: operation.cascade,
|
|
224
|
-
targetTurn: turn.turn,
|
|
225
|
-
targetEventSeq: turn.user.seq
|
|
226
|
-
}),
|
|
227
186
|
queuedUsers: operation.cascade === "preserve" ? downstreamUsers(turns, turnIndex) : turn.users.map((user) => cloneUser(user.data)),
|
|
228
187
|
targetSeq: turn.user.seq
|
|
229
188
|
};
|
|
@@ -236,12 +195,6 @@ function rerollPlan(operation, turns) {
|
|
|
236
195
|
if (target === void 0) continue;
|
|
237
196
|
return {
|
|
238
197
|
anchorSeq: turn.startSeq,
|
|
239
|
-
version: pairVersionEffect(operation.sessionId, {
|
|
240
|
-
operation: "reroll",
|
|
241
|
-
cascade: "truncate",
|
|
242
|
-
targetTurn: turn.turn,
|
|
243
|
-
targetEventSeq: target.seq
|
|
244
|
-
}),
|
|
245
198
|
queuedUsers: turn.users.map((user) => cloneUser(user.data)),
|
|
246
199
|
targetSeq: target.seq
|
|
247
200
|
};
|
package/dist/testing.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SessionEditor } from "./index.cjs";
|
|
2
2
|
import { Context, Service } from "@deepseek-ai/cordis";
|
|
3
3
|
import { Session, Session as Session$1, SessionEvent, SessionEvent as SessionEvent$1, SessionHeader, SessionHeader as SessionHeader$1, SessionId, SessionId as SessionIdBrand, SessionLogOffset, SessionSeq, SessionStore } from "@deepseek-ai/dsh-session";
|
|
4
|
-
import { BranchBoundary,
|
|
4
|
+
import { BranchBoundary, CascadePolicy } from "@morlay/session-branch";
|
|
5
5
|
import { TokenMeter } from "@deepseek-ai/dsh-token-meter";
|
|
6
6
|
import { SessionStorageMetadata } from "@deepseek-ai/dsh-session-persistence";
|
|
7
7
|
import { ProjectionSnapshot, SessionProjectionMap } from "@deepseek-ai/dsh-session-projection";
|
|
@@ -3239,4 +3239,4 @@ declare function turnLog(base: number, turn: number, opts?: {
|
|
|
3239
3239
|
time?: number;
|
|
3240
3240
|
}): SessionEvent[];
|
|
3241
3241
|
//#endregion
|
|
3242
|
-
export {
|
|
3242
|
+
export { EmptySettings, Harness, SESSION_EDITOR_PATH, Session, type SessionEvent, type SessionHeader, SessionIdBrand, SessionSeq, SessionStore, TokenMeter, assistantMessage, createPersisted, harness, meta, oneTurnLog, parseJsonlArtifact, turnLog, twoTurnLog, userMessage };
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SessionEditor } from "./index.mjs";
|
|
2
2
|
import { Context, Service } from "@deepseek-ai/cordis";
|
|
3
3
|
import { Session, Session as Session$1, SessionEvent, SessionEvent as SessionEvent$1, SessionHeader, SessionHeader as SessionHeader$1, SessionId, SessionId as SessionIdBrand, SessionLogOffset, SessionSeq, SessionSeq as SessionSeq$1, SessionStore } from "@deepseek-ai/dsh-session";
|
|
4
|
-
import { BranchBoundary,
|
|
4
|
+
import { BranchBoundary, CascadePolicy, SessionBranch } from "@morlay/session-branch";
|
|
5
5
|
import { TokenMeter } from "@deepseek-ai/dsh-token-meter";
|
|
6
6
|
import { ProjectionSnapshot, SessionProjectionMap } from "@deepseek-ai/dsh-session-projection";
|
|
7
7
|
import { SessionPersistence, SessionPersistenceRevision, SessionStorageMetadata } from "@deepseek-ai/dsh-session-persistence";
|
|
@@ -3239,4 +3239,4 @@ declare function turnLog(base: number, turn: number, opts?: {
|
|
|
3239
3239
|
time?: number;
|
|
3240
3240
|
}): SessionEvent[];
|
|
3241
3241
|
//#endregion
|
|
3242
|
-
export {
|
|
3242
|
+
export { EmptySettings, Harness, SESSION_EDITOR_PATH, Session, type SessionEvent, type SessionHeader, SessionIdBrand, SessionSeq, SessionStore, TokenMeter, assistantMessage, createPersisted, harness, meta, oneTurnLog, parseJsonlArtifact, turnLog, twoTurnLog, userMessage };
|