@niracler/encore 0.2.0 → 0.4.0

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.
@@ -0,0 +1,193 @@
1
+ import { createHash } from 'node:crypto'
2
+ import { createReadStream, createWriteStream } from 'node:fs'
3
+ import { lstat, mkdir, mkdtemp, open, realpath, rename, rm, stat } from 'node:fs/promises'
4
+ import { homedir } from 'node:os'
5
+ import { basename, extname, isAbsolute, join, relative, resolve, sep } from 'node:path'
6
+ import { Readable, Transform } from 'node:stream'
7
+ import { pipeline } from 'node:stream/promises'
8
+ import { fileURLToPath } from 'node:url'
9
+
10
+ export const recordedText = Symbol('recordedText')
11
+
12
+ function isLocal(path) {
13
+ return typeof path === 'string' && path && !path.startsWith('#') && !path.startsWith('//')
14
+ && (!/^[a-z][\w+.-]*:/i.test(path) || isAbsolute(path) || path.startsWith('file:'))
15
+ }
16
+
17
+ function decodeLocalName(path) {
18
+ try { return decodeURIComponent(path) } catch { return path } // Local filenames may contain a literal %.
19
+ }
20
+
21
+ export function fileReferences(entries, cwd) {
22
+ const files = new Map()
23
+ for (const entry of entries) {
24
+ let path = typeof entry === 'string' ? entry : entry?.path
25
+ if (typeof path === 'string' && path.startsWith('sandbox:/')) {
26
+ files.set(path, { title: basename(path), availability: 'missing' })
27
+ continue
28
+ }
29
+ if (!isLocal(path)) continue
30
+ if (path.startsWith('file:')) {
31
+ try { path = fileURLToPath(path) } catch { continue }
32
+ }
33
+ if (path.startsWith('~/')) path = join(homedir(), path.slice(2))
34
+ if (cwd && !isAbsolute(path)) path = resolve(cwd, path)
35
+ const sha256 = typeof entry === 'object' ? entry.sha256 : undefined
36
+ files.set(path, { title: basename(path), source: { path, ...(sha256 && { sha256 }) } })
37
+ }
38
+ return [...files.values()]
39
+ }
40
+
41
+ export function messageReferences(text) {
42
+ const prose = text.replace(/^\s*(\x60{3,}|~{3,})[^\n]*\n[\s\S]*?^\s*\1\s*$/gm, '').replace(/\x60[^\x60\n]*\x60/g, '')
43
+ const paths = []
44
+ for (const match of prose.matchAll(/\[([^\]\n]*)\]\((<[^>\n]+>|(?:[^()\n]|\([^()\n]*\))+)\)/g)) {
45
+ if (match[1].startsWith('$')) continue
46
+ let path = match[2].replace(/^<|>$/g, '').split('#')[0]
47
+ if ((!isLocal(path) && !path.startsWith('sandbox:/')) || !extname(path)) continue
48
+ paths.push(decodeLocalName(path))
49
+ }
50
+ return paths
51
+ }
52
+
53
+ const supportedInline = new Set(['.pdf', '.xlsx', '.png', '.jpg', '.jpeg', '.webp', '.gif', '.mp4', '.mov', '.webm', '.mp3', '.wav', '.ogg'])
54
+ const notFound = err => ['ENOENT', 'ENOTDIR'].includes(err.code)
55
+ export const within = (path, root) => {
56
+ const rel = relative(root, path)
57
+ return rel !== '..' && !rel.startsWith('..' + sep) && !isAbsolute(rel)
58
+ }
59
+
60
+ export async function nativeSessionRoot(log, tool, records) {
61
+ const stores = {
62
+ codex: ['.codex/sessions', '.codex/archived_sessions'],
63
+ workbuddy: ['.workbuddy/projects'], 'claude-code': ['.claude/projects'],
64
+ }
65
+ const path = await realpath(log)
66
+ if (!stores[tool]?.some(dir => within(path, join(homedir(), dir)))) return undefined
67
+ const cwd = tool === 'codex' ? records.find(row => row.type === 'session_meta')?.payload?.cwd
68
+ : records.find(row => row.cwd)?.cwd
69
+ return cwd && isAbsolute(cwd) ? cwd : undefined
70
+ }
71
+
72
+ async function snapshot(path, target, roots, userSelected) {
73
+ let actual
74
+ let handle
75
+ try {
76
+ actual = await realpath(path)
77
+ if (!roots.some(root => within(actual, root)) && !userSelected) return { unavailableReason: 'outside-root' }
78
+ if (!(await stat(actual)).isFile()) return { availability: 'missing', unavailableReason: 'unreadable' }
79
+ handle = await open(actual, 'r')
80
+ } catch (err) {
81
+ if (notFound(err)) return { availability: 'missing' }
82
+ if (['EPERM', 'EACCES', 'ELOOP'].includes(err.code)) return { availability: 'missing', unavailableReason: 'unreadable' }
83
+ throw err
84
+ }
85
+ try {
86
+ return await writeAttachment(handle.createReadStream(), path, target)
87
+ } finally {
88
+ await handle.close()
89
+ }
90
+ }
91
+
92
+ async function writeAttachment(stream, path, target) {
93
+ let stage
94
+ try {
95
+ const dir = join(target, 'attachments')
96
+ await mkdir(dir, { recursive: true })
97
+ if ((await lstat(dir)).isSymbolicLink()) throw new Error('Attachment directory must be inside the replay')
98
+ stage = await mkdtemp(join(dir, 'copy-'))
99
+ const temp = join(stage, 'file')
100
+ const hash = createHash('sha256')
101
+ const meter = new Transform({ transform(chunk, encoding, callback) { hash.update(chunk); callback(null, chunk) } })
102
+ await pipeline(stream, meter, createWriteStream(temp, { flags: 'wx' }))
103
+ const digest = hash.digest('hex')
104
+ const ext = extname(path).toLowerCase()
105
+ const name = digest + (supportedInline.has(ext) ? ext : '.bin')
106
+ await rename(temp, join(dir, name))
107
+ return { href: 'attachments/' + name, digest }
108
+ } finally {
109
+ if (stage) await rm(stage, { recursive: true, force: true })
110
+ }
111
+ }
112
+
113
+ // Consume explicit external sources once. Reopening a replay uses its own packaged files.
114
+ export async function collectExternalFiles(session, directory, assetRoots, nativeRoot, sessionRoots = []) {
115
+ const userFiles = new Set((session.items || []).filter(item => item.type === 'user').flatMap(item => item.deliverables || []))
116
+ const files = [...(session.deliverables || session.files || []), ...(session.items || []).flatMap(item => item.deliverables || [])]
117
+ if (!files.length) return false
118
+ const originalWorkspace = nativeRoot && !assetRoots
119
+ if (!assetRoots?.length) assetRoots = [process.cwd()]
120
+ const roots = await Promise.all(assetRoots.map(root => realpath(resolve(root))))
121
+ if (originalWorkspace) {
122
+ try { roots.push(await realpath(nativeRoot)) } catch (err) { if (!notFound(err)) throw err }
123
+ }
124
+ for (const root of sessionRoots) roots.push(await realpath(root))
125
+ const copies = new Map()
126
+ let changed = false
127
+ for (const file of files) {
128
+ if (file[recordedText] !== undefined) {
129
+ const copy = await writeAttachment(Readable.from([Buffer.from(file[recordedText])]), file.title, directory)
130
+ Object.assign(file, { href: copy.href, availability: 'export-copy' })
131
+ delete file[recordedText]
132
+ changed = true
133
+ continue
134
+ }
135
+ if (!file.source && file.href && isLocal(file.href)) {
136
+ // Root-relative web URLs belong to the host site. Explicit file: URLs are local.
137
+ if (isAbsolute(file.href) && !within(file.href, homedir()) && !roots.some(root => within(file.href, root))) continue
138
+ const external = isAbsolute(file.href) || /^(?:~\/|file:)/.test(file.href)
139
+ if (external) {
140
+ file.source = fileReferences([file.href])[0]?.source
141
+ } else {
142
+ const target = decodeLocalName(file.href.split(/[?#]/)[0])
143
+ const path = resolve(directory, target)
144
+ let availability
145
+ let reason
146
+ try {
147
+ const actual = await realpath(path)
148
+ if (!within(actual, await realpath(directory))) {
149
+ file.source = { path }
150
+ } else if (!(await stat(actual)).isFile()) {
151
+ availability = 'missing'
152
+ reason = 'unreadable'
153
+ } else if (file.sessionSha256) {
154
+ const hash = createHash('sha256')
155
+ for await (const chunk of createReadStream(actual)) hash.update(chunk)
156
+ availability = hash.digest('hex') === file.sessionSha256 ? 'verified' : 'export-copy'
157
+ } else {
158
+ availability = 'export-copy'
159
+ }
160
+ } catch (err) {
161
+ availability = 'missing'
162
+ if (!notFound(err)) reason = 'unreadable'
163
+ }
164
+ if (availability && (file.availability !== availability || file.unavailableReason !== reason)) {
165
+ file.availability = availability
166
+ if (reason) file.unavailableReason = reason
167
+ else delete file.unavailableReason
168
+ if (availability === 'missing') delete file.preview
169
+ changed = true
170
+ }
171
+ }
172
+ }
173
+ if (!file.source) continue
174
+ const source = file.source
175
+ const sourcePath = source.path.startsWith('~/') ? join(homedir(), source.path.slice(2)) : source.path
176
+ const path = resolve(nativeRoot || roots[0], sourcePath)
177
+ const userSelected = Boolean(originalWorkspace && userFiles.has(file))
178
+ const key = JSON.stringify([path, userSelected])
179
+ if (!copies.has(key)) copies.set(key, await snapshot(path, directory, roots, userSelected))
180
+ const { href, digest, unavailableReason } = copies.get(key)
181
+ delete file.source
182
+ delete file.href
183
+ delete file.preview
184
+ delete file.unavailableReason
185
+ if (href) file.href = href
186
+ if (/^[a-f0-9]{64}$/i.test(source.sha256 || '')) file.sessionSha256 = source.sha256.toLowerCase()
187
+ else delete file.sessionSha256
188
+ if (unavailableReason) file.unavailableReason = unavailableReason
189
+ file.availability = !href ? 'missing' : digest === file.sessionSha256 ? 'verified' : 'export-copy'
190
+ changed = true
191
+ }
192
+ return changed
193
+ }
package/src/i18n.mjs CHANGED
@@ -1,5 +1,32 @@
1
1
  export const DICTS = {
2
2
  zh: {
3
+ workspaceWrite: '工作区可写',
4
+ contextLabel: '上下文',
5
+ itemCount: '{n} 条',
6
+ agentSent: '已派出',
7
+ agentStopped: '已叫停',
8
+ agentRateLimited: '额度中断',
9
+ agentFailed: '失败',
10
+ agentDone: '已交回',
11
+ turnTag: '第 {n} 轮',
12
+ replyTag: '第 {n} 次回复',
13
+ stepTag: '第 {n} 步',
14
+ thinking: '思考',
15
+ reasoning: '推理过程',
16
+ preview: '预览',
17
+ draft: '草稿',
18
+ rule: '规则',
19
+ promptTitle: '提问 #{n}',
20
+ sessionStart: '会话开始',
21
+ userMessage: '用户消息',
22
+ assistantReply: '助手回复',
23
+ appendedPrompt: '已将用户消息加入上下文',
24
+ waitingForTools: '等待助手推理与调用工具',
25
+ synthesizing: '汇总结果({tools})',
26
+ directResponse: '直接回复',
27
+ completedResponse: '回复完成',
28
+ toolCalls: '工具调用 × {n}',
29
+ archivedTools: '已归档 {n} 条工具输出(-{tokens}k tokens)',
3
30
  langCode: 'zh-CN',
4
31
  toggleLangLabel: 'EN',
5
32
  toggleLangTitle: 'Switch to English',
@@ -16,13 +43,12 @@ export const DICTS = {
16
43
  sendThisPrompt: '发送本轮提问',
17
44
  waitNextStep: '等待下一步',
18
45
  composerPlaceholder: '向 Agent 发送消息…',
19
- composerFinished: '会话已结束 · 点击上方任意消息可回看当时上下文',
46
+ composerFinished: '会话已结束 · 点击上方任意消息可查看当时的上下文快照',
20
47
  emptyHintStart: '点击左下角 <b>▶ 播放</b>',
21
48
  emptyHintOrSend: ' 或输入框蓝色发送键 <b>↑</b>',
22
49
  emptyHintEnd: ',体验完整对话与上下文生长',
23
- activeContext: '当前上下文',
24
- snapInitial: '快照:启动初始态',
25
- snapInspect: '回看:第 {step} / {total} 步',
50
+ activeContext: '上下文快照',
51
+ snapInitial: '初始上下文',
26
52
  snapCurrent: '第 {step} / {total} 步',
27
53
  usedSuffix: '已用',
28
54
  freeSpaceTitle: '剩余窗口 (Free Space)',
@@ -32,20 +58,20 @@ export const DICTS = {
32
58
  legendSys: '系统提示词',
33
59
  legendSchema: '工具定义',
34
60
  legendUser: '用户消息',
35
- legendMem: '注入内容',
61
+ legendMem: '记忆规则',
36
62
  legendSkill: '技能注入',
37
63
  legendMsg: '助手回复',
38
64
  legendTool: '工具输出',
39
65
  catSys: '系统提示词(System Prompt)',
40
66
  catSchema: '工具定义(Tool Schemas & MCP)',
41
67
  catUser: '用户消息(User Messages)',
42
- catMem: '注入内容(Memory & Rules)',
68
+ catMem: '记忆规则(Memory & Rules)',
43
69
  catSkill: '技能注入(Skills)',
44
- catMsg: '助手回复(Assistant Messages)',
70
+ catMsg: '助手回复(Assistant Replies)',
45
71
  catTool: '工具输出(Tool Outputs)',
46
72
  contextInspector: '上下文明细',
47
73
  contextInspectorHint: '点击色块或消息定格展开',
48
- emptyCategory: '当前步骤暂无条目',
74
+ emptyCategory: '当前步骤暂无记录',
49
75
  viewFullPayload: '查看完整内容 ↗',
50
76
  omittedImages: '({prefix}{count} 张附图未收录)',
51
77
  omittedImagesAlso: '另有 ',
@@ -59,15 +85,29 @@ export const DICTS = {
59
85
  compactModalTitle: '上下文压缩摘要',
60
86
  asksYou: '{tool} 问你',
61
87
  deliverablesTitle: '交回的成果',
62
- subagentReportTitle: '子任务报告 · {label}',
88
+ inputFiles: '随消息附上的文件',
89
+ fileVerified: '已核对为会话当时的版本',
90
+ fileExportCopy: '已收录导出时的版本,无法确认是否与会话当时一致',
91
+ fileHashMismatch: '已收录导出时的版本,与会话记录的校验值不符',
92
+ fileMissing: '未找到原文件,无法回看',
93
+ fileOutsideRoot: '文件位于资产根目录之外,未收录',
94
+ fileUnreadable: '未能读取原文件,无法回看',
95
+ viewChanges: '查看改动', beforeRevision: '原稿', afterRevision: '校订稿', openSourcePage: '打开这一页',
96
+ readPdf: '阅读报告', readWorkbook: '查看完整表格', downloadFile: '下载 {type}',
97
+ pdfPages: '{n} 页', sheetCount: '{n} 张工作表', sheetName: '工作表', emptySheet: '空白工作表',
98
+ pageNumber: '页码', pdfPage: '第 {n} 页', prevPage: '上一页', nextPage: '下一页',
99
+ zoom: '缩放', fitWidth: '适合宽度', loadingSheet: '正在读取表格…', sheetLoadError: '读取失败,可重新打开预览或下载原文件。',
100
+ landscape: '横版',
101
+ portrait: '竖版',
102
+ subagentReportTitle: '子 Agent 报告 · {label}',
63
103
  viewReport: '查看报告',
64
104
  refFrameEyebrow: '📎 参考画面',
65
- aiFrameEyebrow: '🖼 中间过程效果图',
105
+ aiFrameEyebrow: '🖼 过程画面',
66
106
  frameSub: '{time} 产出 · 点击放大查看',
67
107
  docEyebrow: '📄 中间文稿产出 · {file}',
68
108
  docSub: '{time} 写入 · 约 {kb}k 字 · 点击阅读草稿',
69
109
  audioEyebrow: '🔊 过程配音试听({count} 段)',
70
- lightboxDefaultTitle: '效果图预览',
110
+ lightboxDefaultTitle: '画面预览',
71
111
  docModalDefaultTitle: '中间文稿预览',
72
112
  closePreview: '关闭预览',
73
113
  tlAria: '回放时间轴与控制',
@@ -76,10 +116,10 @@ export const DICTS = {
76
116
  tlStepMeta: '第 {step} 步 · {time}',
77
117
  tlCompressPin: '压缩 #{seq}',
78
118
  tlCompressTitle: '🗜 上下文压缩 #{seq}(-{dropped}k)',
79
- tlPromptTitle: '💬 提问 #{turn}:{summary}',
119
+ tlPromptTitle: '💬 第 {turn} 轮:{summary}',
80
120
  tlStepFallback: '步骤详情',
81
121
  defaultRefFrame: '参考画面 #{n}',
82
- defaultAiFrame: '过程产出 #{n}',
122
+ defaultAiFrame: '过程画面 #{n}',
83
123
  defaultAudioClip: '试听片段',
84
124
  statSearch: '搜索 {n} 次',
85
125
  statOpen: '打开 {n} 个网页',
@@ -90,13 +130,40 @@ export const DICTS = {
90
130
  statCode: '运行 {n} 段代码',
91
131
  statEdit: '写 {n} 个文件',
92
132
  statSkill: '加载 {n} 个技能',
93
- statAgent: '派出 {n} 个子任务',
94
- statReply: '收到 {n} 份子任务结果',
133
+ statAgent: '派出 {n} 个子 Agent',
134
+ statReply: '收到 {n} 份子 Agent 报告',
95
135
  statOther: '其他操作 {n} 次',
96
136
  statSep: ',',
97
137
  execToolsFallback: '执行工具',
98
138
  },
99
139
  en: {
140
+ workspaceWrite: 'Workspace Write',
141
+ contextLabel: 'Context',
142
+ itemCount: '{n} records',
143
+ agentSent: 'Dispatched',
144
+ agentStopped: 'Stopped',
145
+ agentRateLimited: 'Rate limited',
146
+ agentFailed: 'Failed',
147
+ agentDone: 'Returned',
148
+ turnTag: 'Turn #{n}',
149
+ replyTag: 'Reply #{n}',
150
+ stepTag: 'Step {n}',
151
+ thinking: 'Thinking',
152
+ reasoning: 'Reasoning',
153
+ preview: 'Preview',
154
+ draft: 'Draft',
155
+ rule: 'Rule',
156
+ promptTitle: 'Prompt #{n}',
157
+ sessionStart: 'Session start',
158
+ userMessage: 'User message',
159
+ assistantReply: 'Assistant reply',
160
+ appendedPrompt: 'User message appended to context',
161
+ waitingForTools: 'Waiting for agent reasoning and tool calls',
162
+ synthesizing: 'Synthesizing ({tools})',
163
+ directResponse: 'Direct response',
164
+ completedResponse: 'Completed response',
165
+ toolCalls: 'Tool calls × {n}',
166
+ archivedTools: 'Archived {n} tool outputs (-{tokens}k tokens)',
100
167
  langCode: 'en',
101
168
  toggleLangLabel: '中文',
102
169
  toggleLangTitle: '切换到中文',
@@ -117,9 +184,8 @@ export const DICTS = {
117
184
  emptyHintStart: 'Click <b>▶ Play</b> at the bottom-left',
118
185
  emptyHintOrSend: ' or the blue <b>↑</b> send button',
119
186
  emptyHintEnd: ' to replay the conversation and live context growth',
120
- activeContext: 'Active Context',
121
- snapInitial: 'Snapshot: Initial Mount',
122
- snapInspect: 'Inspecting: Step {step} / {total}',
187
+ activeContext: 'Context Snapshot',
188
+ snapInitial: 'Initial Context',
123
189
  snapCurrent: 'Step {step} / {total}',
124
190
  usedSuffix: 'used',
125
191
  freeSpaceTitle: 'Free Context Space',
@@ -128,7 +194,7 @@ export const DICTS = {
128
194
  outputReserveTitle: 'Max Output Reserve (8%)',
129
195
  legendSys: 'System Prompt',
130
196
  legendSchema: 'Tool Schemas',
131
- legendUser: 'User Prompts',
197
+ legendUser: 'User Messages',
132
198
  legendMem: 'Memory & Rules',
133
199
  legendSkill: 'Skills',
134
200
  legendMsg: 'Assistant',
@@ -136,13 +202,13 @@ export const DICTS = {
136
202
  catSys: 'System Prompt',
137
203
  catSchema: 'Tool Schemas & MCP',
138
204
  catUser: 'User Messages',
139
- catMem: 'Memory & Injected Rules',
205
+ catMem: 'Memory & Rules',
140
206
  catSkill: 'Skills',
141
- catMsg: 'Assistant Messages',
207
+ catMsg: 'Assistant Replies',
142
208
  catTool: 'Tool Outputs',
143
209
  contextInspector: 'Context Inspector',
144
210
  contextInspectorHint: 'Click a bar segment or message to inspect',
145
- emptyCategory: 'No items at this step',
211
+ emptyCategory: 'No records at this step',
146
212
  viewFullPayload: 'View full payload ↗',
147
213
  omittedImages: '({prefix}{count} attached image(s) omitted)',
148
214
  omittedImagesAlso: 'plus ',
@@ -156,10 +222,24 @@ export const DICTS = {
156
222
  compactModalTitle: 'Compaction Summary',
157
223
  asksYou: '{tool} asks',
158
224
  deliverablesTitle: 'Deliverables',
225
+ inputFiles: 'Attachments',
226
+ fileVerified: 'Verified against the version in the session',
227
+ fileExportCopy: 'Captured at export. Its version at the time of the session could not be confirmed.',
228
+ fileHashMismatch: 'Captured at export. Its checksum differs from the one recorded in the session.',
229
+ fileMissing: 'Original file not found. No copy is available.',
230
+ fileOutsideRoot: 'Outside the asset roots. No copy was included.',
231
+ fileUnreadable: 'The original file could not be read. No copy is available.',
232
+ viewChanges: 'View changes', beforeRevision: 'Original', afterRevision: 'Revised', openSourcePage: 'Open this page',
233
+ readPdf: 'Read PDF', readWorkbook: 'View workbook', downloadFile: 'Download {type}',
234
+ pdfPages: '{n} pages', sheetCount: '{n} sheets', sheetName: 'Sheet', emptySheet: 'Empty worksheet',
235
+ pageNumber: 'Page', pdfPage: 'Page {n}', prevPage: 'Previous page', nextPage: 'Next page',
236
+ zoom: 'Zoom', fitWidth: 'Fit width', loadingSheet: 'Loading workbook…', sheetLoadError: 'Could not read workbook. Reopen the preview to retry or download the file.',
237
+ landscape: 'Landscape',
238
+ portrait: 'Portrait',
159
239
  subagentReportTitle: 'Sub-agent Report · {label}',
160
240
  viewReport: 'View Report',
161
- refFrameEyebrow: '📎 Reference Image',
162
- aiFrameEyebrow: '🖼 Stage Output',
241
+ refFrameEyebrow: '📎 Reference Frame',
242
+ aiFrameEyebrow: '🖼 Agent Frame',
163
243
  frameSub: 'Produced at {time} · Click to enlarge',
164
244
  docEyebrow: '📄 Draft Document · {file}',
165
245
  docSub: 'Written at {time} · ~{kb}k chars · Click to read',
@@ -171,12 +251,12 @@ export const DICTS = {
171
251
  tlControlsAria: 'Playback controls',
172
252
  tlJumpAria: 'Jump to step {step}: {label}',
173
253
  tlStepMeta: 'Step {step} · {time}',
174
- tlCompressPin: 'Compact #{seq}',
254
+ tlCompressPin: 'Compaction #{seq}',
175
255
  tlCompressTitle: '🗜 Compaction #{seq} (-{dropped}k)',
176
- tlPromptTitle: '💬 Prompt #{turn}: {summary}',
256
+ tlPromptTitle: '💬 Turn #{turn}: {summary}',
177
257
  tlStepFallback: 'Step details',
178
- defaultRefFrame: 'Reference #{n}',
179
- defaultAiFrame: 'Stage Output #{n}',
258
+ defaultRefFrame: 'Reference Frame #{n}',
259
+ defaultAiFrame: 'Agent Frame #{n}',
180
260
  defaultAudioClip: 'Audio clip',
181
261
  statSearch: 'searched {n}x',
182
262
  statOpen: 'opened {n} page(s)',
package/src/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type AgentToolId = 'codex' | 'claude-code' | 'claude-ai' | 'workbuddy' | (string & {})
1
+ export type AgentToolId = 'codex' | 'claude-code' | 'claude-ai' | 'workbuddy' | 'antigravity' | 'antigravity-app' | 'antigravity-cli' | (string & {})
2
2
  export type PlayerLang = 'zh' | 'en'
3
3
 
4
4
  export interface ContextRecord {
@@ -30,13 +30,28 @@ export interface SessionFrame {
30
30
 
31
31
  export interface SessionDeliverable {
32
32
  title: string
33
+ source?: { path: string; sha256?: string }
34
+ sessionSha256?: string
35
+ availability?: 'verified' | 'export-copy' | 'missing'
36
+ unavailableReason?: 'outside-root' | 'unreadable'
33
37
  href?: string
34
38
  meta?: string
35
39
  cover?: string
40
+ portrait?: { href: string; cover?: string }
41
+ previewSheet?: string
42
+ previewColumns?: string[]
43
+ revision?: { href: string; label: string } & (
44
+ { page: number; linePrefix: string } | { sheet: string; cell: string }
45
+ )
46
+ preview?: { change?: { before: string; after: string } } & (
47
+ { type: 'pdf'; pages: { src: string; width: number; height: number }[] }
48
+ | { type: 'xlsx'; src: string; sheet: string; count: number; rows: string[][] }
49
+ )
36
50
  }
37
51
 
38
52
  export interface SessionItem {
39
53
  type: 'user' | 'assistant' | 'reasoning' | 'tool' | 'compact'
54
+ deliverables?: SessionDeliverable[]
40
55
  text?: string
41
56
  time?: string
42
57
  done?: string
@@ -85,6 +100,7 @@ export interface PrivacyLeak {
85
100
  }
86
101
 
87
102
  export interface BuildReplayOptions {
103
+ assetRoots?: string[]
88
104
  tool?: AgentToolId
89
105
  outDir?: string
90
106
  lang?: PlayerLang | 'auto'
@@ -126,6 +142,7 @@ export interface RecentSessionSummary {
126
142
  tool: AgentToolId
127
143
  toolLabel: string
128
144
  file: string
145
+ archived?: boolean
129
146
  mtimeMs: number
130
147
  timeLabel: string
131
148
  sizeKB: number
@@ -143,6 +160,8 @@ export function scanRecentSessions(options?: {
143
160
  limit?: number
144
161
  codexDir?: string
145
162
  claudeDir?: string
163
+ antigravityAppDir?: string
164
+ antigravityCliDir?: string
146
165
  workbuddyDir?: string
147
166
  }): Promise<RecentSessionSummary[]>
148
167
 
@@ -153,7 +172,7 @@ export function importRawSession(
153
172
 
154
173
  export function rebuildReplayDir(
155
174
  dirOrSessionFile: string,
156
- options?: Pick<BuildReplayOptions, 'lang' | 'title' | 'description'>
175
+ options?: Pick<BuildReplayOptions, 'lang' | 'title' | 'description' | 'assetRoots'>
157
176
  ): Promise<BuildReplayResult>
158
177
 
159
178
  export function buildReplay(
@@ -206,7 +225,7 @@ export function attachPlayerController(
206
225
  export function createEncorePlayer(
207
226
  target: string | HTMLElement,
208
227
  sourceOrSession?: string | EncoreSession,
209
- options?: { baseUrl?: string; lang?: PlayerLang | 'auto'; initialStep?: number }
228
+ options?: { baseUrl?: string; lang?: PlayerLang | 'auto'; initialStep?: number; backHref?: string; backLabel?: string; showLangToggle?: boolean }
210
229
  ): Promise<{ setLang: (nextLang: PlayerLang) => void; getController: () => Record<string, any> | null }>
211
230
 
212
231
  export function buildStandalonePlayerJs(options?: { write?: boolean }): string