@morlay/ui-conversation-message-actions 0.0.19-alpha.3 → 0.0.19-alpha.5

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/dist/plan.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { SessionSeq } from "@deepseek-ai/dsh-session";
2
- import { SESSION_BRANCH_VERSION_SCHEMA, SessionBranchError } from "@morlay/session-branch";
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
- const before = event.data.content[operation.blockIndex];
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
  };
@@ -0,0 +1,4 @@
1
+ //#region src/shared.ts
2
+ const SESSION_EDITOR_PATH = "/session-editor";
3
+ //#endregion
4
+ export { SESSION_EDITOR_PATH as t };
@@ -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, BranchTimeline, BranchTimeline as BranchTimeline$1, CascadePolicy } from "@morlay/session-branch";
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 { type BranchTimeline, EmptySettings, Harness, SESSION_EDITOR_PATH, Session, type SessionEvent, type SessionHeader, SessionIdBrand, SessionSeq, SessionStore, TokenMeter, assistantMessage, createPersisted, harness, meta, oneTurnLog, parseJsonlArtifact, turnLog, twoTurnLog, userMessage };
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 };
@@ -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, BranchTimeline, BranchTimeline as BranchTimeline$1, CascadePolicy, SessionBranch } from "@morlay/session-branch";
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 { type BranchTimeline, EmptySettings, Harness, SESSION_EDITOR_PATH, Session, type SessionEvent, type SessionHeader, SessionIdBrand, SessionSeq, SessionStore, TokenMeter, assistantMessage, createPersisted, harness, meta, oneTurnLog, parseJsonlArtifact, turnLog, twoTurnLog, userMessage };
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 };