@atlaswork/atlascode 0.1.126 → 0.1.128

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.
Files changed (36) hide show
  1. package/dist/atlasweb-carrier.json +3 -3
  2. package/dist/cli.js +31 -7
  3. package/dist/web-contract/index.d.ts +8 -0
  4. package/dist/web-contract/index.js +5 -2
  5. package/dist/web-session-runtime/atlascode/web/limits.d.ts +2 -0
  6. package/dist/web-session-runtime/atlascode/web/projection.d.ts +6 -0
  7. package/dist/web-session-runtime/atlascode/web/readonlyRuntime.d.ts +24 -0
  8. package/dist/web-session-runtime/atlascode/web/replayPaging.d.ts +27 -0
  9. package/dist/web-session-runtime/engine/session/load.d.ts +47 -0
  10. package/dist/web-session-runtime/engine/session/predicates.d.ts +1 -1
  11. package/dist/web-session-runtime/engine/session/readonly.d.ts +2 -0
  12. package/dist/web-session-runtime/engine/session/replayScan.d.ts +45 -0
  13. package/dist/web-session-runtime/engine/session/types.d.ts +1 -1
  14. package/dist/web-session-runtime/index.js +373 -4
  15. package/dist/web-session-runtime/kernel/protocol/webSessionV0.d.ts +8 -0
  16. package/dist/web-session-runtime/shared/index.d.ts +1 -1
  17. package/dist/web-session-runtime-execution/atlascode/web/entry.d.ts +2 -0
  18. package/dist/web-session-runtime-execution/atlascode/web/limits.d.ts +2 -0
  19. package/dist/web-session-runtime-execution/atlascode/web/projection.d.ts +6 -0
  20. package/dist/web-session-runtime-execution/atlascode/web/readonlyRuntime.d.ts +24 -0
  21. package/dist/web-session-runtime-execution/atlascode/web/replayPaging.d.ts +27 -0
  22. package/dist/web-session-runtime-execution/engine/session/load.d.ts +47 -0
  23. package/dist/web-session-runtime-execution/engine/session/predicates.d.ts +1 -1
  24. package/dist/web-session-runtime-execution/engine/session/readonly.d.ts +2 -0
  25. package/dist/web-session-runtime-execution/engine/session/replayScan.d.ts +45 -0
  26. package/dist/web-session-runtime-execution/engine/session/types.d.ts +1 -1
  27. package/dist/web-session-runtime-execution/index.js +662 -8
  28. package/dist/web-session-runtime-execution/kernel/execution/executionComposition.d.ts +18 -0
  29. package/dist/web-session-runtime-execution/kernel/execution/executionKernel.d.ts +77 -0
  30. package/dist/web-session-runtime-execution/kernel/protocol/webSessionV0.d.ts +8 -0
  31. package/dist/web-session-runtime-execution/shared/index.d.ts +1 -1
  32. package/package.json +2 -2
  33. package/dist/web-session-runtime/atlascode/web/entry.d.ts +0 -21
  34. package/dist/web-session-runtime/atlascode/web/executionOutlet.d.ts +0 -60
  35. package/dist/web-session-runtime/kernel/execution/executionOutlet.d.ts +0 -60
  36. package/dist/web-session-runtime/kernel/protocol/webExecutionV0.d.ts +0 -542
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "product": "atlascode",
3
- "version": "0.1.126",
4
- "runtimeSha256": "7e7e6f389f7a429be6b06d40237b8e06f311bb8175c30ffd8787a09ac72257d2",
5
- "executionSha256": "79f9c7d42cb7b671a93abd0cf1e639657dcd25ab4dec63ccbb2ac6d634ba891d"
3
+ "version": "0.1.128",
4
+ "runtimeSha256": "85e9b293d8cc5b9467c9af84000315badcab88bbd5c34eb6bcc0534e38446b7a",
5
+ "executionSha256": "5c8c095e3817f6c4c5075472fbe9e71181dde09e36c9b54e08d85184fb4087a8"
6
6
  }
package/dist/cli.js CHANGED
@@ -35446,6 +35446,13 @@ var init_record = __esm(() => {
35446
35446
  init_project();
35447
35447
  });
35448
35448
 
35449
+ // src/engine/session/replayScan.ts
35450
+ var init_replayScan = __esm(() => {
35451
+ init_load();
35452
+ init_scanner();
35453
+ init_predicates();
35454
+ });
35455
+
35449
35456
  // src/engine/session/readonly.ts
35450
35457
  async function loadTranscriptFull(filePath, opts) {
35451
35458
  return loadTranscriptFile(filePath, {
@@ -35457,6 +35464,7 @@ async function loadTranscriptFull(filePath, opts) {
35457
35464
  var init_readonly = __esm(() => {
35458
35465
  init_load();
35459
35466
  init_load();
35467
+ init_replayScan();
35460
35468
  });
35461
35469
 
35462
35470
  // src/engine/session/sessionMemory.ts
@@ -95966,6 +95974,7 @@ function createExecutionKernel(options) {
95966
95974
  const approvalTimeoutMs = options.approvalTimeoutMs ?? EXECUTION_APPROVAL_TIMEOUT_MS;
95967
95975
  const maxTextBytes = options.maxTextBytes ?? EXECUTION_MAX_TEXT_BYTES;
95968
95976
  const followBufferLimit = options.followBufferLimit ?? EXECUTION_FOLLOW_BUFFER_LIMIT;
95977
+ const maxDeltaBytes = EXECUTION_MAX_DELTA_BYTES;
95969
95978
  const streams = new Map;
95970
95979
  const approvals = new Map;
95971
95980
  const subscribers = new Set;
@@ -96062,6 +96071,7 @@ function createExecutionKernel(options) {
96062
96071
  return;
96063
96072
  const turn = st.queue.shift();
96064
96073
  turn.state = "running";
96074
+ turnStates.set(turn.turnId, "running");
96065
96075
  turn.controller = new AbortController;
96066
96076
  st.running = turn;
96067
96077
  emit(st, { workspaceId: ws, sessionId: s, turnId: turn.turnId }, "turn.started", {});
@@ -96072,6 +96082,15 @@ function createExecutionKernel(options) {
96072
96082
  bind: { workspaceId: ws, sessionId: s, turnId: turn.turnId },
96073
96083
  text: turn.text,
96074
96084
  signal: turn.controller.signal,
96085
+ emitDelta: (text) => {
96086
+ if (turn.state !== "running" || turn.controller?.signal.aborted)
96087
+ return;
96088
+ if (Buffer.byteLength(text, "utf8") > maxDeltaBytes) {
96089
+ settleTurn(st, turn, "failed", `turn.delta 超 ${maxDeltaBytes} 字节上限(合同 §8)`);
96090
+ return;
96091
+ }
96092
+ emit(st, { workspaceId: ws, sessionId: s, turnId: turn.turnId }, "turn.delta", { text });
96093
+ },
96075
96094
  requestApproval: () => {
96076
96095
  const approvalId = `appr-${++approvalCounter}`;
96077
96096
  return new Promise((resolve) => {
@@ -96109,6 +96128,9 @@ function createExecutionKernel(options) {
96109
96128
  const handleCommand = async (command) => {
96110
96129
  const ws = command.bind.workspaceId;
96111
96130
  const s = command.bind.sessionId;
96131
+ if (ws.includes("\x00") || s.includes("\x00")) {
96132
+ return err("invalidBind", "workspaceId/sessionId 不得含 NUL 分隔符(流键碰撞面)");
96133
+ }
96112
96134
  if (command.type === "turn.submit") {
96113
96135
  const st = streamOfTracked(ws, s);
96114
96136
  const recorded = st.idempotency.get(command.payload.submitId);
@@ -96168,8 +96190,8 @@ function createExecutionKernel(options) {
96168
96190
  const a = approvals.get(command.payload.approvalId);
96169
96191
  if (!a)
96170
96192
  return err("notFound", `待批操作不存在或已结算:${command.payload.approvalId}`);
96171
- if (command.bind.turnId !== a.turnId) {
96172
- return err("approvalBindMismatch", `decide bind.turnId 与审批归属 turn 不一致(合同 §5)`);
96193
+ if (command.bind.turnId !== a.turnId || command.bind.workspaceId !== a.workspaceId || command.bind.sessionId !== a.sessionId) {
96194
+ return err("approvalBindMismatch", `decide bind 三元组与审批归属不一致(合同 §5)`);
96173
96195
  }
96174
96196
  if (a.settled || now() - a.requestedAt >= approvalTimeoutMs) {
96175
96197
  if (!a.settled)
@@ -96205,18 +96227,20 @@ function createExecutionKernel(options) {
96205
96227
  }
96206
96228
  };
96207
96229
  }
96208
- var EXECUTION_QUEUE_DEPTH = 16, EXECUTION_APPROVAL_TIMEOUT_MS = 300000, EXECUTION_MAX_TEXT_BYTES, EXECUTION_FOLLOW_BUFFER_LIMIT = 1e4, streamKey = (ws, s) => `${ws}\x00${s}`;
96230
+ var EXECUTION_QUEUE_DEPTH = 16, EXECUTION_APPROVAL_TIMEOUT_MS = 300000, EXECUTION_MAX_TEXT_BYTES, EXECUTION_FOLLOW_BUFFER_LIMIT = 1e4, EXECUTION_MAX_DELTA_BYTES, streamKey = (ws, s) => `${ws}\x00${s}`;
96209
96231
  var init_executionKernel = __esm(() => {
96210
96232
  EXECUTION_MAX_TEXT_BYTES = 2 * 1024 * 1024;
96233
+ EXECUTION_MAX_DELTA_BYTES = 256 * 1024;
96211
96234
  });
96212
96235
 
96213
96236
  // src/kernel/execution/executionComposition.ts
96214
- function createExecutionComposition() {
96237
+ function createExecutionComposition(options = {}) {
96215
96238
  const kernel = createExecutionKernel({
96216
- runTurn: async () => {
96239
+ runTurn: options.runTurn ?? (async () => {
96217
96240
  throw new Error("执行能力 runTurn 真体未接线(B0 执行出口波 S4 落地细化附注:引擎深缝候后续切片;能力开关 fail-closed off 时不可达)");
96218
- },
96219
- actorId: () => "atlas-local-ambient"
96241
+ }),
96242
+ actorId: options.actorId ?? (() => "atlas-local-ambient"),
96243
+ ...options.now !== undefined ? { now: options.now } : {}
96220
96244
  });
96221
96245
  const outlet = createExecutionOutlet({
96222
96246
  isExecutionEnabled: () => process.env.ATLAS_WEB_EXECUTION_ENABLED === "1",
@@ -45,6 +45,8 @@ export declare const SearchSessionsRequestSchema: z.ZodObject<{
45
45
  scopeId: z.ZodString;
46
46
  }, z.core.$strict>;
47
47
  export declare const ReplaySessionRequestSchema: z.ZodObject<{
48
+ pageSize: z.ZodOptional<z.ZodNumber>;
49
+ pageToken: z.ZodOptional<z.ZodString>;
48
50
  kind: z.ZodLiteral<"replaySession">;
49
51
  sessionId: z.ZodString;
50
52
  schemaVersion: z.ZodLiteral<0>;
@@ -96,6 +98,8 @@ export declare const WebSessionRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObje
96
98
  productId: z.ZodString;
97
99
  scopeId: z.ZodString;
98
100
  }, z.core.$strict>, z.ZodObject<{
101
+ pageSize: z.ZodOptional<z.ZodNumber>;
102
+ pageToken: z.ZodOptional<z.ZodString>;
99
103
  kind: z.ZodLiteral<"replaySession">;
100
104
  sessionId: z.ZodString;
101
105
  schemaVersion: z.ZodLiteral<0>;
@@ -329,6 +333,8 @@ export declare const ReplaySessionSuccessSchema: z.ZodObject<{
329
333
  }, z.core.$strict>>;
330
334
  truncated: z.ZodLiteral<false>;
331
335
  }, z.core.$strict>;
336
+ hasMore: z.ZodOptional<z.ZodBoolean>;
337
+ nextPageToken: z.ZodOptional<z.ZodString>;
332
338
  schemaVersion: z.ZodLiteral<0>;
333
339
  requestId: z.ZodUUID;
334
340
  productId: z.ZodString;
@@ -401,6 +407,8 @@ export declare const WebSessionSuccessSchema: z.ZodDiscriminatedUnion<[z.ZodObje
401
407
  }, z.core.$strict>>;
402
408
  truncated: z.ZodLiteral<false>;
403
409
  }, z.core.$strict>;
410
+ hasMore: z.ZodOptional<z.ZodBoolean>;
411
+ nextPageToken: z.ZodOptional<z.ZodString>;
404
412
  schemaVersion: z.ZodLiteral<0>;
405
413
  requestId: z.ZodUUID;
406
414
  productId: z.ZodString;
@@ -38,7 +38,8 @@ var SearchSessionsRequestSchema = z.strictObject({
38
38
  var ReplaySessionRequestSchema = z.strictObject({
39
39
  ...EnvelopeFields,
40
40
  kind: z.literal("replaySession"),
41
- sessionId: OpaqueIdSchema
41
+ sessionId: OpaqueIdSchema,
42
+ ...PageFields
42
43
  });
43
44
  var FollowSessionRequestSchema = z.strictObject({
44
45
  ...EnvelopeFields,
@@ -152,7 +153,9 @@ var SearchSessionsSuccessSchema = z.strictObject({
152
153
  var ReplaySessionSuccessSchema = z.strictObject({
153
154
  ...ResponseEnvelopeFields,
154
155
  of: z.literal("replaySession"),
155
- projection: ProjectionSchema
156
+ projection: ProjectionSchema,
157
+ hasMore: z.boolean().optional(),
158
+ nextPageToken: OpaqueTokenSchema.optional()
156
159
  });
157
160
  var FollowSessionSuccessSchema = z.strictObject({
158
161
  ...ResponseEnvelopeFields,
@@ -14,6 +14,8 @@ export declare const DEFAULT_MAX_SCOPES_PER_RUNTIME = 32;
14
14
  export declare const HARD_MAX_SCOPES_PER_RUNTIME = 128;
15
15
  export declare const DEFAULT_PAGE_SIZE = 50;
16
16
  export declare const HARD_MAX_PAGE_SIZE = 200;
17
+ export declare const DEFAULT_MAX_REPLAY_PAGE_BYTES: number;
18
+ export declare const HARD_MAX_REPLAY_PAGE_BYTES: number;
17
19
  export declare const SEARCH_QUERY_MIN_CODE_POINTS = 1;
18
20
  export declare const SEARCH_QUERY_MAX_CODE_POINTS = 256;
19
21
  export declare const DEFAULT_MAX_RECORD_BYTES: number;
@@ -52,6 +52,12 @@ export interface ProjectionLoad {
52
52
  }
53
53
  /** 事件/projection 序列化字节单一口径(replay 与 follow 共享,防兄弟路漂移)。 */
54
54
  export declare function serializedProjectionBytes(p: unknown): number;
55
+ /**
56
+ * F6-PAGE S1 加性导出:分页装窗路径(replayPaging.ts)对 skeleton(内容
57
+ * 剥除面)与 pass2 全量记录(原文面)复用同一块投影判定——可渲染性单源。
58
+ * 全量路径零行为变更(纯 export 添加)。
59
+ */
60
+ export declare function projectBlocks(msg: ProjectionSourceMessage): NeutralBlock[];
55
61
  /**
56
62
  * terminal leaf 集计算(load.ts:1187-1226 同规则镜像:terminal → 最近
57
63
  * user/assistant 祖先;增量尾读路径复用。f4 §5.7 登记:镜像同步义务,
@@ -14,6 +14,7 @@
14
14
  * revision/issued cursors/subscriptions/timers 实例字段,零全局槽)。
15
15
  */
16
16
  import type { WebSessionProjection } from './contract.js';
17
+ import type { ReplayPageReader } from '../../engine/session/readonly.js';
17
18
  import { type FollowHandle } from './follow.js';
18
19
  import { type ProjectionEngineDeps, type ProjectionSourceMessage } from './projection.js';
19
20
  import type { SessionStoreAdapter } from './sessionStoreAdapter.js';
@@ -28,6 +29,8 @@ export interface ReadonlySessionLimits {
28
29
  maxRecordBytes?: number;
29
30
  maxParseRecords?: number;
30
31
  maxProjectionBytes?: number;
32
+ /** F6-PAGE 必改③:replay 分页单页序列化字节界(DEFAULT 4MiB / HARD 16MiB)。 */
33
+ maxReplayPageBytes?: number;
31
34
  maxSubscriptions?: number;
32
35
  maxConcurrentReads?: number;
33
36
  maxPendingEvents?: number;
@@ -56,6 +59,15 @@ export interface ReadonlySessionEngine {
56
59
  }>;
57
60
  /** CLI 同规则链重建(projection 头注镜像义务)。 */
58
61
  buildConversationChain: ProjectionEngineDeps['buildConversationChain'];
62
+ /**
63
+ * F6-PAGE S1 加性缝:replay 分页 skeleton 扫描(真体 =
64
+ * engine/session/replayScan.ts,runtimeDefault 焊接;测试 fake 可缺席
65
+ * ——分页请求遇缺席 → invalidRequest fail-closed)。
66
+ */
67
+ openReplayPageReader?: (filePath: string, opts?: {
68
+ maxBytes?: number;
69
+ expectIno?: number;
70
+ }) => Promise<ReplayPageReader>;
59
71
  }
60
72
  export interface ReadonlySessionRuntimeOptions {
61
73
  /** 静态产品标识(ProductDefinition 单源,'atlascode')。 */
@@ -85,10 +97,21 @@ export interface ListSessionsResult {
85
97
  export interface ReplaySessionRequest {
86
98
  scopeId: string;
87
99
  sessionId: string;
100
+ /**
101
+ * F6-PAGE S1 加性分页参(wire 契约 PageFields 同形;schemaVersion=0
102
+ * optional 不破版)。任一在场 → 分页装窗路径;双缺省 = 旧全量 replay
103
+ * 逐字节不变(A1 对表腿)。
104
+ */
105
+ pageSize?: number;
106
+ pageToken?: string;
88
107
  }
89
108
  export interface ReplaySessionResult {
90
109
  of: 'replaySession';
91
110
  projection: WebSessionProjection;
111
+ /** F6-PAGE S1 加性(分页请求恒发;全量请求零新键)。 */
112
+ hasMore?: boolean;
113
+ /** 仅 hasMore=true 时在场(opaque token,replayPaging.ts 编解码单源)。 */
114
+ nextPageToken?: string;
92
115
  }
93
116
  export interface FollowSessionRequest {
94
117
  scopeId: string;
@@ -129,6 +152,7 @@ export interface ResolvedLimits {
129
152
  maxRecordBytes: number;
130
153
  maxParseRecords: number;
131
154
  maxProjectionBytes: number;
155
+ maxReplayPageBytes: number;
132
156
  maxSubscriptions: number;
133
157
  maxConcurrentReads: number;
134
158
  maxPendingEvents: number;
@@ -0,0 +1,27 @@
1
+ import type { ReplayPageReader } from '../../engine/session/readonly.js';
2
+ import type { WebSessionProjection } from '../../kernel/protocol/webSessionV0.js';
3
+ import type { ResolvedLimits } from './readonlyRuntime.js';
4
+ import { type ProjectionSourceMessage } from './projection.js';
5
+ import type { SessionStoreAdapter } from './sessionStoreAdapter.js';
6
+ export interface ReplayPagedRequest {
7
+ pageSize?: number;
8
+ pageToken?: string;
9
+ }
10
+ export interface ReplayPageDeps {
11
+ adapter: SessionStoreAdapter;
12
+ engine: {
13
+ openReplayPageReader: (filePath: string, opts?: {
14
+ maxBytes?: number;
15
+ expectIno?: number;
16
+ }) => Promise<ReplayPageReader>;
17
+ buildConversationChain: (messages: Map<string, ProjectionSourceMessage>, leaf: ProjectionSourceMessage) => ProjectionSourceMessage[];
18
+ };
19
+ limits: ResolvedLimits;
20
+ productId: string;
21
+ }
22
+ export interface ReplayPageResult {
23
+ projection: WebSessionProjection;
24
+ hasMore: boolean;
25
+ nextPageToken?: string;
26
+ }
27
+ export declare function loadReplayPage(deps: ReplayPageDeps, scopeId: string, sessionId: string, req: ReplayPagedRequest, signal?: AbortSignal): Promise<ReplayPageResult>;
@@ -1,6 +1,53 @@
1
1
  import type { ContentReplacementRecord, LogOption, PersistedWorktreeSession, SerializedMessage, TranscriptMessage } from './types.js';
2
2
  /** 旧 L1825 逐字。 */
3
3
  export declare function removeExtraFields(transcript: TranscriptMessage[]): SerializedMessage[];
4
+ /**
5
+ * Splice the preserved segment back into the chain after compaction.(旧
6
+ * L1850 逐字)
7
+ *
8
+ * Preserved messages exist in the JSONL with their ORIGINAL pre-compact
9
+ * parentUuids (recordTranscript dedup-skipped them — can't rewrite).
10
+ * The internal chain (keep[i+1]→keep[i]) is intact; only endpoints need
11
+ * patching: head→anchor, and anchor's other children→tail. Anchor is the
12
+ * last summary for suffix-preserving, boundary itself for prefix-preserving.
13
+ *
14
+ * Only the LAST seg-boundary is relinked — earlier segs were summarized
15
+ * into it. Everything physically before the absolute-last boundary (except
16
+ * preservedUuids) is deleted, which handles all multi-boundary shapes
17
+ * without special-casing.
18
+ *
19
+ * Mutates the Map in place.
20
+ *
21
+ * F6-PAGE S1 加性导出:replay 分页装窗读路径(engine/session/replayScan.ts)
22
+ * 在 skeleton Map 上复用本变换——零逻辑复刻(链图语义单源),全量路径
23
+ * 零行为变更(纯 export 添加)。
24
+ */
25
+ export declare function applyPreservedSegmentRelinks(messages: Map<string, TranscriptMessage>): void;
26
+ /**
27
+ * Delete messages that Snip executions removed from the in-memory array,
28
+ * and relink parentUuid across the gaps.(旧 L1986 逐字)
29
+ *
30
+ * Unlike compact_boundary which truncates a prefix, snip removes
31
+ * middle ranges. The JSONL is append-only, so removed messages stay on disk
32
+ * and the surviving messages' parentUuid chains walk through them. Without
33
+ * this filter, buildConversationChain reconstructs the full unsnipped history
34
+ * and resume immediately PTLs (adamr-20260320-165831: 397K displayed → 1.65M
35
+ * actual).
36
+ *
37
+ * Deleting alone is not enough: the surviving message AFTER a removed range
38
+ * has parentUuid pointing INTO the gap. buildConversationChain would hit
39
+ * messages.get(undefined) and stop, orphaning everything before the gap. So
40
+ * after delete we relink: for each survivor with a dangling parentUuid, walk
41
+ * backward through the removed region's own parent links to the first
42
+ * non-removed ancestor.
43
+ *
44
+ * The boundary records removedUuids at execution time so we can replay the
45
+ * exact removal on load. Older boundaries without removedUuids are skipped —
46
+ * resume loads their pre-snip history (the pre-fix behavior).
47
+ *
48
+ * Mutates the Map in place.
49
+ */
50
+ export declare function applySnipRemovals(messages: Map<string, TranscriptMessage>): void;
4
51
  /**
5
52
  * Builds a conversation chain from a leaf message to root(旧 L2069 逐字)
6
53
  * @param messages Map of all messages
@@ -11,7 +11,7 @@
11
11
  * 前向补裁。
12
12
  */
13
13
  import type { Message, Entry, TranscriptMessage, SystemCompactBoundaryMessage } from './types.js';
14
- import type { Message as SharedMessage } from '../../shared.js';
14
+ import type { Message as SharedMessage } from '../../shared/index.js';
15
15
  /**
16
16
  * 旧 L134 逐字。Type guard to check if an entry is a transcript message.
17
17
  * Transcript messages include user, assistant, attachment, and system
@@ -14,6 +14,8 @@
14
14
  import { loadTranscriptFile } from './load.js';
15
15
  export { buildConversationChain, TranscriptChangedDuringReadError, TranscriptTooLargeError, } from './load.js';
16
16
  export type { TranscriptMessage } from './types.js';
17
+ export { openReplayPageReader } from './replayScan.js';
18
+ export type { ReplayPageReader, ReplayByteRange } from './replayScan.js';
17
19
  export type ReadonlyTranscriptLoad = Awaited<ReturnType<typeof loadTranscriptFile>>;
18
20
  /** 全量只读加载(force-full,零截断;只读 runtime 专用)。 */
19
21
  export declare function loadTranscriptFull(filePath: string,
@@ -0,0 +1,45 @@
1
+ /** skeleton 记录 = 链/恢复 pass 所需字段的窄结构面(内容已剥除)。 */
2
+ export interface ReplaySkeletonRecord {
3
+ uuid: string;
4
+ parentUuid: string | null;
5
+ type: string;
6
+ timestamp?: string | null;
7
+ isSidechain?: boolean;
8
+ compactMetadata?: unknown;
9
+ subtype?: string;
10
+ snipMetadata?: unknown;
11
+ message?: {
12
+ id?: string;
13
+ content?: unknown;
14
+ };
15
+ }
16
+ /** 行字节范围(文件绝对坐标;length 不含换行)。 */
17
+ export interface ReplayByteRange {
18
+ offset: number;
19
+ length: number;
20
+ }
21
+ export interface ReplayPageReader {
22
+ /** skeleton Map(last-wins;relink/snip 已施加)。 */
23
+ skeletons: Map<string, ReplaySkeletonRecord>;
24
+ /** uuid → 行字节范围(与 skeletons 同键集;被 relink/snip 剪枝的残键无害)。 */
25
+ ranges: Map<string, ReplayByteRange>;
26
+ /** open 后 fstat 身份(web 层 adapter stPost 三元组对表的 ino 侧)。 */
27
+ ino: number;
28
+ size: number;
29
+ /** pass2:按字节范围读页内记录原文(返回序 = 入参序;公共面用
30
+ * Uint8Array——S0-R 打包出口 d.ts 消费 tsconfig 无 node types,
31
+ * Buffer 类型名不入 .d.ts,实现体仍可用 Buffer)。 */
32
+ readRanges(ranges: ReadonlyArray<ReplayByteRange>): Promise<Uint8Array[]>;
33
+ close(): Promise<void>;
34
+ }
35
+ /**
36
+ * 打开 replay 分页读取器:open(O_NOFOLLOW 旗标,POSIX;Windows 守卫跳过
37
+ * ——load.ts S0-R4 F1 同形)→ fstat 身份/尺寸检查点 → 流式逐行 skeleton
38
+ * 扫描 → 装载期图变换(relink/snip)。fd 保持打开供 pass2 readRanges;
39
+ * close 恒由调用方 finally 触达(成功路径 fd 移交 reader,失败路径此处
40
+ * 关闭)。
41
+ */
42
+ export declare function openReplayPageReader(filePath: string, opts?: {
43
+ maxBytes?: number;
44
+ expectIno?: number;
45
+ }): Promise<ReplayPageReader>;
@@ -33,7 +33,7 @@
33
33
  * sourceToolAssistantUUID/attachment):旧仓 `(m as any).message.id` 类
34
34
  * cast 在域扩展型下直接可访,逐字块内按需去 cast(语义逐字不变)。
35
35
  */
36
- import type { ContentBlock, Message as BaseMessage, Usage } from '../../shared.js';
36
+ import type { ContentBlock, Message as BaseMessage, Usage } from '../../shared/types.js';
37
37
  export type UUID = string;
38
38
  /** 旧 types/ids brand → string(残余 ② 口径)。 */
39
39
  export type AgentId = string;