@niracler/encore 0.2.0 → 0.3.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.
package/src/codex.mjs CHANGED
@@ -171,6 +171,7 @@ const normAgentName = value => String(value || '').split('/').filter(Boolean).po
171
171
 
172
172
  export function readCodex(records, { includeMemory = false } = {}) {
173
173
  const transcript = createTranscript()
174
+ let cwd
174
175
  const working = new Map()
175
176
  let model
176
177
  let title
@@ -246,6 +247,7 @@ export function readCodex(records, { includeMemory = false } = {}) {
246
247
  const payload = record.payload || {}
247
248
  const time = isoTime(record.timestamp)
248
249
  if (record.type === 'session_meta') {
250
+ cwd = payload.cwd || cwd
249
251
  model = model || payload.model
250
252
  if (payload.title && !title) title = payload.title
251
253
  const baseText = typeof payload.base_instructions === 'string' ? payload.base_instructions : payload.base_instructions?.text
@@ -254,7 +256,10 @@ export function readCodex(records, { includeMemory = false } = {}) {
254
256
  initSys.unshift(...splitMarkdownSections(baseText, 'init-sys-base', 'Core'))
255
257
  }
256
258
  }
257
- if (record.type === 'turn_context') model = model || payload.model
259
+ if (record.type === 'turn_context') {
260
+ model = model || payload.model
261
+ cwd = payload.cwd || cwd
262
+ }
258
263
  if (record.type === 'world_state' && payload.state?.agents_md?.text) {
259
264
  addMem('agents-md', 'AGENTS.md', 'AGENTS.md(工作区与全局协作指令)', payload.state.agents_md.text)
260
265
  }
@@ -352,10 +357,12 @@ export function readCodex(records, { includeMemory = false } = {}) {
352
357
  } else if (!injected.test(text)) {
353
358
  sawFirstUserTurn = true
354
359
  pendingCompact = null
355
- transcript.user(cleanPrompt(text), time, { images: imagesOf(payload.content) })
360
+ const header = text.match(/^# Files mentioned by the user:\s*\n([\s\S]*?)\n## My request:/)?.[1] || ''
361
+ const references = [...header.matchAll(/^## .+?: (.+)$/gm)].map(match => match[1].trim())
362
+ transcript.user(cleanPrompt(text), time, { images: imagesOf(payload.content), references, cwd })
356
363
  }
357
364
  } else if (payload.type === 'message' && payload.role === 'assistant') {
358
- transcript.assistant(textOf(payload.content), time)
365
+ transcript.assistant(textOf(payload.content), time, { cwd })
359
366
  } else if (payload.type === 'reasoning') {
360
367
  transcript.reasoning((payload.summary || []).map(part => part.text).join('\n\n'), time)
361
368
  } else if (payload.type === 'custom_tool_call') {
package/src/common.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createReadStream } from 'node:fs'
2
2
  import { spawn } from 'node:child_process'
3
3
  import { StringDecoder } from 'node:string_decoder'
4
+ import { fileReferences, messageReferences } from './external-files.mjs'
4
5
 
5
6
  export const tools = {
6
7
  codex: 'Codex',
@@ -116,11 +117,12 @@ export function isoTime(value) {
116
117
  return Number.isNaN(date.getTime()) ? undefined : date.toISOString()
117
118
  }
118
119
 
119
- export function mentions(text) {
120
+ export function mentions(text, references = []) {
120
121
  const files = []
121
122
  const request = String(text)
122
123
  .replace(/(^|\s)@(?:"([^"]+)"|(~?[/\\][^\s"]+))/g, (whole, space, quoted, bare) => {
123
124
  const name = (quoted || bare).split(/[/\\]/).pop()
125
+ references.push(quoted || bare)
124
126
  files.push(attachmentLabel(name))
125
127
  return space === '\n' ? space : ''
126
128
  })
@@ -288,15 +290,22 @@ export function createTranscript() {
288
290
  }
289
291
  return {
290
292
  items,
291
- user(text, time, { images = [], ...extra } = {}) {
293
+ user(text, time, { images = [], references = [], cwd, ...extra } = {}) {
292
294
  text = String(text ?? '').trim() || (images.length ? '[图片]' : '')
295
+ const files = fileReferences([...references, ...messageReferences(text)], cwd)
296
+ if (files.length) extra.deliverables = [...(extra.deliverables || []), ...files]
293
297
  if (text) add({ type: 'user', text, time, ...extra, images: images.length ? images : undefined })
294
298
  },
295
- assistant(text, time, { key, ...extra } = {}) {
299
+ assistant(text, time, { key, cwd, ...extra } = {}) {
296
300
  text = String(text ?? '').trim()
297
301
  if (!text) return
298
302
  const last = items.at(-1)
299
- if (key && last?.type === 'assistant' && last.key === key) last.text += `\n\n${text}`
303
+ const files = fileReferences(messageReferences(text), cwd)
304
+ if (files.length) extra.deliverables = files
305
+ if (key && last?.type === 'assistant' && last.key === key) {
306
+ last.text += `\n\n${text}`
307
+ if (files.length) last.deliverables = [...(last.deliverables || []), ...files]
308
+ }
300
309
  else add({ type: 'assistant', text, time, key, ...extra })
301
310
  },
302
311
  reasoning(text, time) {
@@ -311,13 +320,24 @@ export function createTranscript() {
311
320
  compact(info, time) {
312
321
  return add({ type: 'compact', ...info, time })
313
322
  },
314
- result(id, output, time, images = []) {
323
+ result(id, output, time, images = [], cwd) {
315
324
  const item = id ? calls.get(id) : items.findLast(entry => entry.type === 'tool' && !entry.output)
316
325
  if (!item) return
317
326
  if (time) item.done = time
318
327
  output = String(output ?? '').trim()
319
328
  if (output) item.output = item.output ? `${item.output}\n${output}` : output
320
329
  if (images.length) item.images = [...(item.images || []), ...images]
330
+ const name = item.name?.split('__').at(-1)
331
+ if (name === 'present_files' || name === 'SendUserFile') {
332
+ const result = parseArguments(output)
333
+ const args = parseArguments(item.input)
334
+ const entries = result?.type === 'present_files_result' ? result.files
335
+ : name === 'SendUserFile' && /\b\d+ files? delivered to user\b/i.test(output) ? args?.files : undefined
336
+ if (Array.isArray(entries)) {
337
+ const files = fileReferences(entries, args?.cwd || cwd)
338
+ if (files.length) item.deliverables = files
339
+ }
340
+ }
321
341
  },
322
342
  finish({ tool, model, title, description = '', deliverables = [], tokens, contextWindow, initialContext }) {
323
343
  for (const item of items) delete item.key
@@ -0,0 +1,176 @@
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 { Transform } from 'node:stream'
7
+ import { pipeline } from 'node:stream/promises'
8
+ import { fileURLToPath } from 'node:url'
9
+
10
+ function isLocal(path) {
11
+ return typeof path === 'string' && path && !path.startsWith('#') && !path.startsWith('//')
12
+ && (!/^[a-z][\w+.-]*:/i.test(path) || isAbsolute(path) || path.startsWith('file:'))
13
+ }
14
+
15
+ function decodeLocalName(path) {
16
+ try { return decodeURIComponent(path) } catch { return path } // Local filenames may contain a literal %.
17
+ }
18
+
19
+ export function fileReferences(entries, cwd) {
20
+ const files = new Map()
21
+ for (const entry of entries) {
22
+ let path = typeof entry === 'string' ? entry : entry?.path
23
+ if (typeof path === 'string' && path.startsWith('sandbox:/')) {
24
+ files.set(path, { title: basename(path), availability: 'missing' })
25
+ continue
26
+ }
27
+ if (!isLocal(path)) continue
28
+ if (path.startsWith('file:')) {
29
+ try { path = fileURLToPath(path) } catch { continue }
30
+ }
31
+ if (path.startsWith('~/')) path = join(homedir(), path.slice(2))
32
+ if (cwd && !isAbsolute(path)) path = resolve(cwd, path)
33
+ const sha256 = typeof entry === 'object' ? entry.sha256 : undefined
34
+ files.set(path, { title: basename(path), source: { path, ...(sha256 && { sha256 }) } })
35
+ }
36
+ return [...files.values()]
37
+ }
38
+
39
+ export function messageReferences(text) {
40
+ const prose = text.replace(/^\s*(\x60{3,}|~{3,})[^\n]*\n[\s\S]*?^\s*\1\s*$/gm, '').replace(/\x60[^\x60\n]*\x60/g, '')
41
+ const paths = []
42
+ for (const match of prose.matchAll(/\[([^\]\n]*)\]\((<[^>\n]+>|(?:[^()\n]|\([^()\n]*\))+)\)/g)) {
43
+ if (match[1].startsWith('$')) continue
44
+ let path = match[2].replace(/^<|>$/g, '').split('#')[0]
45
+ if ((!isLocal(path) && !path.startsWith('sandbox:/')) || !extname(path)) continue
46
+ paths.push(decodeLocalName(path))
47
+ }
48
+ return paths
49
+ }
50
+
51
+ const supportedInline = new Set(['.pdf', '.xlsx', '.png', '.jpg', '.jpeg', '.webp', '.gif', '.mp4', '.mov', '.webm', '.mp3', '.wav', '.ogg'])
52
+ const notFound = err => ['ENOENT', 'ENOTDIR'].includes(err.code)
53
+ const within = (path, root) => {
54
+ const rel = relative(root, path)
55
+ return rel !== '..' && !rel.startsWith('..' + sep) && !isAbsolute(rel)
56
+ }
57
+
58
+ export async function nativeSessionRoot(log, tool, records) {
59
+ const stores = {
60
+ codex: ['.codex/sessions', '.codex/archived_sessions'],
61
+ workbuddy: ['.workbuddy/projects'], 'claude-code': ['.claude/projects'],
62
+ }
63
+ const path = await realpath(log)
64
+ if (!stores[tool]?.some(dir => within(path, join(homedir(), dir)))) return undefined
65
+ const cwd = tool === 'codex' ? records.find(row => row.type === 'session_meta')?.payload?.cwd
66
+ : records.find(row => row.cwd)?.cwd
67
+ return cwd && isAbsolute(cwd) ? cwd : undefined
68
+ }
69
+
70
+ async function snapshot(path, target, roots, userSelected) {
71
+ let actual
72
+ let handle
73
+ try {
74
+ actual = await realpath(path)
75
+ if (!roots.some(root => within(actual, root)) && !userSelected) return { unavailableReason: 'outside-root' }
76
+ if (!(await stat(actual)).isFile()) return { availability: 'missing', unavailableReason: 'unreadable' }
77
+ handle = await open(actual, 'r')
78
+ } catch (err) {
79
+ if (notFound(err)) return { availability: 'missing' }
80
+ if (['EPERM', 'EACCES', 'ELOOP'].includes(err.code)) return { availability: 'missing', unavailableReason: 'unreadable' }
81
+ throw err
82
+ }
83
+ let stage
84
+ try {
85
+ const dir = join(target, 'attachments')
86
+ await mkdir(dir, { recursive: true })
87
+ if ((await lstat(dir)).isSymbolicLink()) throw new Error('Attachment directory must be inside the replay')
88
+ stage = await mkdtemp(join(dir, 'copy-'))
89
+ const temp = join(stage, 'file')
90
+ const hash = createHash('sha256')
91
+ const meter = new Transform({ transform(chunk, encoding, callback) { hash.update(chunk); callback(null, chunk) } })
92
+ await pipeline(handle.createReadStream(), meter, createWriteStream(temp, { flags: 'wx' }))
93
+ const digest = hash.digest('hex')
94
+ const ext = extname(path).toLowerCase()
95
+ const name = digest + (supportedInline.has(ext) ? ext : '.bin')
96
+ await rename(temp, join(dir, name))
97
+ return { href: 'attachments/' + name, digest }
98
+ } finally {
99
+ await handle.close()
100
+ if (stage) await rm(stage, { recursive: true, force: true })
101
+ }
102
+ }
103
+
104
+ // Consume explicit external sources once. Reopening a replay uses its own packaged files.
105
+ export async function collectExternalFiles(session, directory, assetRoots, nativeRoot) {
106
+ const userFiles = new Set((session.items || []).filter(item => item.type === 'user').flatMap(item => item.deliverables || []))
107
+ const files = [...(session.deliverables || session.files || []), ...(session.items || []).flatMap(item => item.deliverables || [])]
108
+ if (!files.length) return false
109
+ const originalWorkspace = nativeRoot && !assetRoots
110
+ if (!assetRoots?.length) assetRoots = [process.cwd()]
111
+ const roots = await Promise.all(assetRoots.map(root => realpath(resolve(root))))
112
+ if (originalWorkspace) {
113
+ try { roots.push(await realpath(nativeRoot)) } catch (err) { if (!notFound(err)) throw err }
114
+ }
115
+ const copies = new Map()
116
+ let changed = false
117
+ for (const file of files) {
118
+ if (!file.source && file.href && isLocal(file.href)) {
119
+ // Root-relative web URLs belong to the host site. Explicit file: URLs are local.
120
+ if (isAbsolute(file.href) && !within(file.href, homedir()) && !roots.some(root => within(file.href, root))) continue
121
+ const external = isAbsolute(file.href) || /^(?:~\/|file:)/.test(file.href)
122
+ if (external) {
123
+ file.source = fileReferences([file.href])[0]?.source
124
+ } else {
125
+ const target = decodeLocalName(file.href.split(/[?#]/)[0])
126
+ const path = resolve(directory, target)
127
+ let availability
128
+ let reason
129
+ try {
130
+ const actual = await realpath(path)
131
+ if (!within(actual, await realpath(directory))) {
132
+ file.source = { path }
133
+ } else if (!(await stat(actual)).isFile()) {
134
+ availability = 'missing'
135
+ reason = 'unreadable'
136
+ } else if (file.sessionSha256) {
137
+ const hash = createHash('sha256')
138
+ for await (const chunk of createReadStream(actual)) hash.update(chunk)
139
+ availability = hash.digest('hex') === file.sessionSha256 ? 'verified' : 'export-copy'
140
+ } else {
141
+ availability = 'export-copy'
142
+ }
143
+ } catch (err) {
144
+ availability = 'missing'
145
+ if (!notFound(err)) reason = 'unreadable'
146
+ }
147
+ if (availability && (file.availability !== availability || file.unavailableReason !== reason)) {
148
+ file.availability = availability
149
+ if (reason) file.unavailableReason = reason
150
+ else delete file.unavailableReason
151
+ if (availability === 'missing') delete file.preview
152
+ changed = true
153
+ }
154
+ }
155
+ }
156
+ if (!file.source) continue
157
+ const source = file.source
158
+ const sourcePath = source.path.startsWith('~/') ? join(homedir(), source.path.slice(2)) : source.path
159
+ const path = resolve(nativeRoot || roots[0], sourcePath)
160
+ const userSelected = Boolean(originalWorkspace && userFiles.has(file))
161
+ const key = JSON.stringify([path, userSelected])
162
+ if (!copies.has(key)) copies.set(key, await snapshot(path, directory, roots, userSelected))
163
+ const { href, digest, unavailableReason } = copies.get(key)
164
+ delete file.source
165
+ delete file.href
166
+ delete file.preview
167
+ delete file.unavailableReason
168
+ if (href) file.href = href
169
+ if (/^[a-f0-9]{64}$/i.test(source.sha256 || '')) file.sessionSha256 = source.sha256.toLowerCase()
170
+ else delete file.sessionSha256
171
+ if (unavailableReason) file.unavailableReason = unavailableReason
172
+ file.availability = !href ? 'missing' : digest === file.sessionSha256 ? 'verified' : 'export-copy'
173
+ changed = true
174
+ }
175
+ return changed
176
+ }
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,12 +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: '快照:启动初始态',
50
+ activeContext: '上下文快照',
51
+ snapInitial: '初始上下文',
25
52
  snapInspect: '回看:第 {step} / {total} 步',
26
53
  snapCurrent: '第 {step} / {total} 步',
27
54
  usedSuffix: '已用',
@@ -32,20 +59,20 @@ export const DICTS = {
32
59
  legendSys: '系统提示词',
33
60
  legendSchema: '工具定义',
34
61
  legendUser: '用户消息',
35
- legendMem: '注入内容',
62
+ legendMem: '记忆规则',
36
63
  legendSkill: '技能注入',
37
64
  legendMsg: '助手回复',
38
65
  legendTool: '工具输出',
39
66
  catSys: '系统提示词(System Prompt)',
40
67
  catSchema: '工具定义(Tool Schemas & MCP)',
41
68
  catUser: '用户消息(User Messages)',
42
- catMem: '注入内容(Memory & Rules)',
69
+ catMem: '记忆规则(Memory & Rules)',
43
70
  catSkill: '技能注入(Skills)',
44
- catMsg: '助手回复(Assistant Messages)',
71
+ catMsg: '助手回复(Assistant Replies)',
45
72
  catTool: '工具输出(Tool Outputs)',
46
73
  contextInspector: '上下文明细',
47
74
  contextInspectorHint: '点击色块或消息定格展开',
48
- emptyCategory: '当前步骤暂无条目',
75
+ emptyCategory: '当前步骤暂无记录',
49
76
  viewFullPayload: '查看完整内容 ↗',
50
77
  omittedImages: '({prefix}{count} 张附图未收录)',
51
78
  omittedImagesAlso: '另有 ',
@@ -59,15 +86,29 @@ export const DICTS = {
59
86
  compactModalTitle: '上下文压缩摘要',
60
87
  asksYou: '{tool} 问你',
61
88
  deliverablesTitle: '交回的成果',
62
- subagentReportTitle: '子任务报告 · {label}',
89
+ inputFiles: '随消息附上的文件',
90
+ fileVerified: '已核对为会话当时的版本',
91
+ fileExportCopy: '已收录导出时的版本,无法确认是否与会话当时一致',
92
+ fileHashMismatch: '已收录导出时的版本,与会话记录的校验值不符',
93
+ fileMissing: '未找到原文件,无法回看',
94
+ fileOutsideRoot: '文件位于资产根目录之外,未收录',
95
+ fileUnreadable: '未能读取原文件,无法回看',
96
+ viewChanges: '查看改动', beforeRevision: '原稿', afterRevision: '校订稿', openSourcePage: '打开这一页',
97
+ readPdf: '阅读报告', readWorkbook: '查看完整表格', downloadFile: '下载 {type}',
98
+ pdfPages: '{n} 页', sheetCount: '{n} 张工作表', sheetName: '工作表', emptySheet: '空白工作表',
99
+ pageNumber: '页码', pdfPage: '第 {n} 页', prevPage: '上一页', nextPage: '下一页',
100
+ zoom: '缩放', fitWidth: '适合宽度', loadingSheet: '正在读取表格…', sheetLoadError: '读取失败,可重新打开预览或下载原文件。',
101
+ landscape: '横版',
102
+ portrait: '竖版',
103
+ subagentReportTitle: '子 Agent 报告 · {label}',
63
104
  viewReport: '查看报告',
64
105
  refFrameEyebrow: '📎 参考画面',
65
- aiFrameEyebrow: '🖼 中间过程效果图',
106
+ aiFrameEyebrow: '🖼 过程画面',
66
107
  frameSub: '{time} 产出 · 点击放大查看',
67
108
  docEyebrow: '📄 中间文稿产出 · {file}',
68
109
  docSub: '{time} 写入 · 约 {kb}k 字 · 点击阅读草稿',
69
110
  audioEyebrow: '🔊 过程配音试听({count} 段)',
70
- lightboxDefaultTitle: '效果图预览',
111
+ lightboxDefaultTitle: '画面预览',
71
112
  docModalDefaultTitle: '中间文稿预览',
72
113
  closePreview: '关闭预览',
73
114
  tlAria: '回放时间轴与控制',
@@ -76,10 +117,10 @@ export const DICTS = {
76
117
  tlStepMeta: '第 {step} 步 · {time}',
77
118
  tlCompressPin: '压缩 #{seq}',
78
119
  tlCompressTitle: '🗜 上下文压缩 #{seq}(-{dropped}k)',
79
- tlPromptTitle: '💬 提问 #{turn}:{summary}',
120
+ tlPromptTitle: '💬 第 {turn} 轮:{summary}',
80
121
  tlStepFallback: '步骤详情',
81
122
  defaultRefFrame: '参考画面 #{n}',
82
- defaultAiFrame: '过程产出 #{n}',
123
+ defaultAiFrame: '过程画面 #{n}',
83
124
  defaultAudioClip: '试听片段',
84
125
  statSearch: '搜索 {n} 次',
85
126
  statOpen: '打开 {n} 个网页',
@@ -90,13 +131,40 @@ export const DICTS = {
90
131
  statCode: '运行 {n} 段代码',
91
132
  statEdit: '写 {n} 个文件',
92
133
  statSkill: '加载 {n} 个技能',
93
- statAgent: '派出 {n} 个子任务',
94
- statReply: '收到 {n} 份子任务结果',
134
+ statAgent: '派出 {n} 个子 Agent',
135
+ statReply: '收到 {n} 份子 Agent 报告',
95
136
  statOther: '其他操作 {n} 次',
96
137
  statSep: ',',
97
138
  execToolsFallback: '执行工具',
98
139
  },
99
140
  en: {
141
+ workspaceWrite: 'Workspace Write',
142
+ contextLabel: 'Context',
143
+ itemCount: '{n} records',
144
+ agentSent: 'Dispatched',
145
+ agentStopped: 'Stopped',
146
+ agentRateLimited: 'Rate limited',
147
+ agentFailed: 'Failed',
148
+ agentDone: 'Returned',
149
+ turnTag: 'Turn #{n}',
150
+ replyTag: 'Reply #{n}',
151
+ stepTag: 'Step {n}',
152
+ thinking: 'Thinking',
153
+ reasoning: 'Reasoning',
154
+ preview: 'Preview',
155
+ draft: 'Draft',
156
+ rule: 'Rule',
157
+ promptTitle: 'Prompt #{n}',
158
+ sessionStart: 'Session start',
159
+ userMessage: 'User message',
160
+ assistantReply: 'Assistant reply',
161
+ appendedPrompt: 'User message appended to context',
162
+ waitingForTools: 'Waiting for agent reasoning and tool calls',
163
+ synthesizing: 'Synthesizing ({tools})',
164
+ directResponse: 'Direct response',
165
+ completedResponse: 'Completed response',
166
+ toolCalls: 'Tool calls × {n}',
167
+ archivedTools: 'Archived {n} tool outputs (-{tokens}k tokens)',
100
168
  langCode: 'en',
101
169
  toggleLangLabel: '中文',
102
170
  toggleLangTitle: '切换到中文',
@@ -117,8 +185,8 @@ export const DICTS = {
117
185
  emptyHintStart: 'Click <b>▶ Play</b> at the bottom-left',
118
186
  emptyHintOrSend: ' or the blue <b>↑</b> send button',
119
187
  emptyHintEnd: ' to replay the conversation and live context growth',
120
- activeContext: 'Active Context',
121
- snapInitial: 'Snapshot: Initial Mount',
188
+ activeContext: 'Context Snapshot',
189
+ snapInitial: 'Initial Context',
122
190
  snapInspect: 'Inspecting: Step {step} / {total}',
123
191
  snapCurrent: 'Step {step} / {total}',
124
192
  usedSuffix: 'used',
@@ -128,7 +196,7 @@ export const DICTS = {
128
196
  outputReserveTitle: 'Max Output Reserve (8%)',
129
197
  legendSys: 'System Prompt',
130
198
  legendSchema: 'Tool Schemas',
131
- legendUser: 'User Prompts',
199
+ legendUser: 'User Messages',
132
200
  legendMem: 'Memory & Rules',
133
201
  legendSkill: 'Skills',
134
202
  legendMsg: 'Assistant',
@@ -136,13 +204,13 @@ export const DICTS = {
136
204
  catSys: 'System Prompt',
137
205
  catSchema: 'Tool Schemas & MCP',
138
206
  catUser: 'User Messages',
139
- catMem: 'Memory & Injected Rules',
207
+ catMem: 'Memory & Rules',
140
208
  catSkill: 'Skills',
141
- catMsg: 'Assistant Messages',
209
+ catMsg: 'Assistant Replies',
142
210
  catTool: 'Tool Outputs',
143
211
  contextInspector: 'Context Inspector',
144
212
  contextInspectorHint: 'Click a bar segment or message to inspect',
145
- emptyCategory: 'No items at this step',
213
+ emptyCategory: 'No records at this step',
146
214
  viewFullPayload: 'View full payload ↗',
147
215
  omittedImages: '({prefix}{count} attached image(s) omitted)',
148
216
  omittedImagesAlso: 'plus ',
@@ -156,10 +224,24 @@ export const DICTS = {
156
224
  compactModalTitle: 'Compaction Summary',
157
225
  asksYou: '{tool} asks',
158
226
  deliverablesTitle: 'Deliverables',
227
+ inputFiles: 'Attachments',
228
+ fileVerified: 'Verified against the version in the session',
229
+ fileExportCopy: 'Captured at export. Its version at the time of the session could not be confirmed.',
230
+ fileHashMismatch: 'Captured at export. Its checksum differs from the one recorded in the session.',
231
+ fileMissing: 'Original file not found. No copy is available.',
232
+ fileOutsideRoot: 'Outside the asset roots. No copy was included.',
233
+ fileUnreadable: 'The original file could not be read. No copy is available.',
234
+ viewChanges: 'View changes', beforeRevision: 'Original', afterRevision: 'Revised', openSourcePage: 'Open this page',
235
+ readPdf: 'Read PDF', readWorkbook: 'View workbook', downloadFile: 'Download {type}',
236
+ pdfPages: '{n} pages', sheetCount: '{n} sheets', sheetName: 'Sheet', emptySheet: 'Empty worksheet',
237
+ pageNumber: 'Page', pdfPage: 'Page {n}', prevPage: 'Previous page', nextPage: 'Next page',
238
+ zoom: 'Zoom', fitWidth: 'Fit width', loadingSheet: 'Loading workbook…', sheetLoadError: 'Could not read workbook. Reopen the preview to retry or download the file.',
239
+ landscape: 'Landscape',
240
+ portrait: 'Portrait',
159
241
  subagentReportTitle: 'Sub-agent Report · {label}',
160
242
  viewReport: 'View Report',
161
- refFrameEyebrow: '📎 Reference Image',
162
- aiFrameEyebrow: '🖼 Stage Output',
243
+ refFrameEyebrow: '📎 Reference Frame',
244
+ aiFrameEyebrow: '🖼 Agent Frame',
163
245
  frameSub: 'Produced at {time} · Click to enlarge',
164
246
  docEyebrow: '📄 Draft Document · {file}',
165
247
  docSub: 'Written at {time} · ~{kb}k chars · Click to read',
@@ -173,10 +255,10 @@ export const DICTS = {
173
255
  tlStepMeta: 'Step {step} · {time}',
174
256
  tlCompressPin: 'Compact #{seq}',
175
257
  tlCompressTitle: '🗜 Compaction #{seq} (-{dropped}k)',
176
- tlPromptTitle: '💬 Prompt #{turn}: {summary}',
258
+ tlPromptTitle: '💬 Turn #{turn}: {summary}',
177
259
  tlStepFallback: 'Step details',
178
- defaultRefFrame: 'Reference #{n}',
179
- defaultAiFrame: 'Stage Output #{n}',
260
+ defaultRefFrame: 'Reference Frame #{n}',
261
+ defaultAiFrame: 'Agent Frame #{n}',
180
262
  defaultAudioClip: 'Audio clip',
181
263
  statSearch: 'searched {n}x',
182
264
  statOpen: 'opened {n} page(s)',
package/src/index.d.ts CHANGED
@@ -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'
@@ -153,7 +169,7 @@ export function importRawSession(
153
169
 
154
170
  export function rebuildReplayDir(
155
171
  dirOrSessionFile: string,
156
- options?: Pick<BuildReplayOptions, 'lang' | 'title' | 'description'>
172
+ options?: Pick<BuildReplayOptions, 'lang' | 'title' | 'description' | 'assetRoots'>
157
173
  ): Promise<BuildReplayResult>
158
174
 
159
175
  export function buildReplay(
@@ -206,7 +222,7 @@ export function attachPlayerController(
206
222
  export function createEncorePlayer(
207
223
  target: string | HTMLElement,
208
224
  sourceOrSession?: string | EncoreSession,
209
- options?: { baseUrl?: string; lang?: PlayerLang | 'auto'; initialStep?: number }
225
+ options?: { baseUrl?: string; lang?: PlayerLang | 'auto'; initialStep?: number; showLangToggle?: boolean }
210
226
  ): Promise<{ setLang: (nextLang: PlayerLang) => void; getController: () => Record<string, any> | null }>
211
227
 
212
228
  export function buildStandalonePlayerJs(options?: { write?: boolean }): string