@niracler/encore 0.1.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/README.md +105 -97
- package/README.zh-CN.md +123 -72
- package/bin/encore.mjs +134 -82
- package/package.json +28 -13
- package/player/encore-player.css +83 -1
- package/player/encore-player.js +595 -157
- package/schema/session.schema.json +255 -0
- package/skills/encore/SKILL.md +39 -35
- package/src/attachment-previews.mjs +169 -0
- package/src/attachment-reader.mjs +169 -0
- package/src/claude-ai.mjs +3 -1
- package/src/claude-code.mjs +13 -9
- package/src/codex.mjs +34 -10
- package/src/common.mjs +45 -15
- package/src/detect.mjs +37 -9
- package/src/external-files.mjs +176 -0
- package/src/i18n.mjs +107 -25
- package/src/index.d.ts +260 -0
- package/src/index.mjs +61 -40
- package/src/markdown.mjs +14 -11
- package/src/player-assets.mjs +4 -1
- package/src/player-runtime.mjs +74 -11
- package/src/render.mjs +66 -18
- package/src/server.mjs +2 -0
- package/src/timeline.mjs +165 -91
- package/src/workbuddy.mjs +48 -0
|
@@ -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: '
|
|
69
|
+
catMem: '记忆规则(Memory & Rules)',
|
|
43
70
|
catSkill: '技能注入(Skills)',
|
|
44
|
-
catMsg: '助手回复(Assistant
|
|
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
|
-
|
|
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: '💬
|
|
120
|
+
tlPromptTitle: '💬 第 {turn} 轮:{summary}',
|
|
80
121
|
tlStepFallback: '步骤详情',
|
|
81
122
|
defaultRefFrame: '参考画面 #{n}',
|
|
82
|
-
defaultAiFrame: '
|
|
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: '
|
|
121
|
-
snapInitial: '
|
|
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
|
|
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 &
|
|
207
|
+
catMem: 'Memory & Rules',
|
|
140
208
|
catSkill: 'Skills',
|
|
141
|
-
catMsg: 'Assistant
|
|
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
|
|
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
|
|
162
|
-
aiFrameEyebrow: '🖼
|
|
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: '💬
|
|
258
|
+
tlPromptTitle: '💬 Turn #{turn}: {summary}',
|
|
177
259
|
tlStepFallback: 'Step details',
|
|
178
|
-
defaultRefFrame: 'Reference #{n}',
|
|
179
|
-
defaultAiFrame: '
|
|
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
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
export type AgentToolId = 'codex' | 'claude-code' | 'claude-ai' | 'workbuddy' | (string & {})
|
|
2
|
+
export type PlayerLang = 'zh' | 'en'
|
|
3
|
+
|
|
4
|
+
export interface ContextRecord {
|
|
5
|
+
id: string
|
|
6
|
+
tag?: string
|
|
7
|
+
title: string
|
|
8
|
+
meta?: string
|
|
9
|
+
tokEst?: number
|
|
10
|
+
stepIndex?: number
|
|
11
|
+
payload: string
|
|
12
|
+
images?: string[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface InitialContext {
|
|
16
|
+
sys?: ContextRecord[]
|
|
17
|
+
schema?: ContextRecord[]
|
|
18
|
+
mem?: ContextRecord[]
|
|
19
|
+
skill?: ContextRecord[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface SessionFrame {
|
|
23
|
+
time?: string
|
|
24
|
+
img: string
|
|
25
|
+
who?: 'you' | 'ai'
|
|
26
|
+
label?: string
|
|
27
|
+
w?: number
|
|
28
|
+
h?: number
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface SessionDeliverable {
|
|
32
|
+
title: string
|
|
33
|
+
source?: { path: string; sha256?: string }
|
|
34
|
+
sessionSha256?: string
|
|
35
|
+
availability?: 'verified' | 'export-copy' | 'missing'
|
|
36
|
+
unavailableReason?: 'outside-root' | 'unreadable'
|
|
37
|
+
href?: string
|
|
38
|
+
meta?: string
|
|
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
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface SessionItem {
|
|
53
|
+
type: 'user' | 'assistant' | 'reasoning' | 'tool' | 'compact'
|
|
54
|
+
deliverables?: SessionDeliverable[]
|
|
55
|
+
text?: string
|
|
56
|
+
time?: string
|
|
57
|
+
done?: string
|
|
58
|
+
name?: string
|
|
59
|
+
kind?: string
|
|
60
|
+
summary?: string
|
|
61
|
+
input?: string
|
|
62
|
+
output?: string
|
|
63
|
+
file?: string
|
|
64
|
+
files?: string[]
|
|
65
|
+
skill?: string
|
|
66
|
+
agent?: string
|
|
67
|
+
question?: boolean
|
|
68
|
+
answer?: boolean
|
|
69
|
+
contextTokens?: number
|
|
70
|
+
images?: string[]
|
|
71
|
+
omittedImages?: number
|
|
72
|
+
stats?: Record<string, number>
|
|
73
|
+
seq?: number
|
|
74
|
+
trigger?: string
|
|
75
|
+
preTokens?: number
|
|
76
|
+
postTokens?: number
|
|
77
|
+
droppedTokens?: number
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface EncoreSession {
|
|
81
|
+
tool: AgentToolId
|
|
82
|
+
model?: string
|
|
83
|
+
lang?: PlayerLang
|
|
84
|
+
title: string
|
|
85
|
+
description?: string
|
|
86
|
+
started?: string
|
|
87
|
+
ended?: string
|
|
88
|
+
tokens?: number
|
|
89
|
+
contextWindow?: number
|
|
90
|
+
initialContext?: InitialContext
|
|
91
|
+
frames?: SessionFrame[]
|
|
92
|
+
deliverables?: SessionDeliverable[]
|
|
93
|
+
items: SessionItem[]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface PrivacyLeak {
|
|
97
|
+
path: string
|
|
98
|
+
rule: string
|
|
99
|
+
match: string
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface BuildReplayOptions {
|
|
103
|
+
assetRoots?: string[]
|
|
104
|
+
tool?: AgentToolId
|
|
105
|
+
outDir?: string
|
|
106
|
+
lang?: PlayerLang | 'auto'
|
|
107
|
+
title?: string
|
|
108
|
+
description?: string
|
|
109
|
+
from?: string
|
|
110
|
+
to?: string
|
|
111
|
+
images?: boolean
|
|
112
|
+
imageWidth?: number
|
|
113
|
+
clip?: number
|
|
114
|
+
conversation?: string
|
|
115
|
+
includeMemory?: boolean
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface BuildReplayResult {
|
|
119
|
+
mode: 'import' | 'rebuild'
|
|
120
|
+
tool: AgentToolId
|
|
121
|
+
toolLabel: string
|
|
122
|
+
dir: string
|
|
123
|
+
sessionFile: string
|
|
124
|
+
session: EncoreSession
|
|
125
|
+
leaks: PrivacyLeak[]
|
|
126
|
+
assets: {
|
|
127
|
+
indexHtml: string
|
|
128
|
+
playerJs: string
|
|
129
|
+
playerCss: string
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface DetectedInput {
|
|
134
|
+
kind: 'replay-dir' | 'session-json' | 'raw-log'
|
|
135
|
+
dir?: string
|
|
136
|
+
sessionFile?: string
|
|
137
|
+
tool?: AgentToolId
|
|
138
|
+
files?: string[]
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface RecentSessionSummary {
|
|
142
|
+
tool: AgentToolId
|
|
143
|
+
toolLabel: string
|
|
144
|
+
file: string
|
|
145
|
+
mtimeMs: number
|
|
146
|
+
timeLabel: string
|
|
147
|
+
sizeKB: number
|
|
148
|
+
preview: string
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export const tools: Record<string, string>
|
|
152
|
+
export const DICTS: Record<PlayerLang, Record<string, string>>
|
|
153
|
+
export const waitThreshold: number
|
|
154
|
+
export const binSeconds: number
|
|
155
|
+
|
|
156
|
+
export function detectInput(targetPath: string): Promise<DetectedInput>
|
|
157
|
+
export function detectJsonlTool(filePath: string): Promise<AgentToolId>
|
|
158
|
+
export function scanRecentSessions(options?: {
|
|
159
|
+
limit?: number
|
|
160
|
+
codexDir?: string
|
|
161
|
+
claudeDir?: string
|
|
162
|
+
workbuddyDir?: string
|
|
163
|
+
}): Promise<RecentSessionSummary[]>
|
|
164
|
+
|
|
165
|
+
export function importRawSession(
|
|
166
|
+
files: string | string[],
|
|
167
|
+
options?: BuildReplayOptions
|
|
168
|
+
): Promise<BuildReplayResult>
|
|
169
|
+
|
|
170
|
+
export function rebuildReplayDir(
|
|
171
|
+
dirOrSessionFile: string,
|
|
172
|
+
options?: Pick<BuildReplayOptions, 'lang' | 'title' | 'description' | 'assetRoots'>
|
|
173
|
+
): Promise<BuildReplayResult>
|
|
174
|
+
|
|
175
|
+
export function buildReplay(
|
|
176
|
+
inputs: string | string[],
|
|
177
|
+
options?: BuildReplayOptions
|
|
178
|
+
): Promise<BuildReplayResult>
|
|
179
|
+
|
|
180
|
+
export function readJsonl(
|
|
181
|
+
files: string | string[],
|
|
182
|
+
options?: { from?: string; to?: string }
|
|
183
|
+
): Promise<Record<string, unknown>[]>
|
|
184
|
+
|
|
185
|
+
export function readCodex(records: Record<string, unknown>[], options?: { includeMemory?: boolean }): EncoreSession
|
|
186
|
+
export function readClaudeCode(records: Record<string, unknown>[], options?: { includeMemory?: boolean }): EncoreSession
|
|
187
|
+
export function readClaudeAi(data: unknown, options?: { conversation?: string }): EncoreSession
|
|
188
|
+
export function readWorkBuddy(records: Record<string, unknown>[]): EncoreSession
|
|
189
|
+
|
|
190
|
+
export function redactText(text: string): string
|
|
191
|
+
export function redactSession(session: EncoreSession): EncoreSession
|
|
192
|
+
export function clipSession(session: EncoreSession, limits?: { input?: number; output?: number }): EncoreSession
|
|
193
|
+
export function findLeaks(session: EncoreSession): PrivacyLeak[]
|
|
194
|
+
|
|
195
|
+
export function timeline(session: EncoreSession, options?: { lang?: PlayerLang | 'auto' }): Record<string, any>
|
|
196
|
+
export function buildPlayerData(
|
|
197
|
+
session: EncoreSession,
|
|
198
|
+
line?: Record<string, any>,
|
|
199
|
+
options?: { baseUrl?: string; lang?: PlayerLang | 'auto' }
|
|
200
|
+
): Record<string, any>
|
|
201
|
+
export function renderPlayerWidget(
|
|
202
|
+
session: EncoreSession,
|
|
203
|
+
line?: Record<string, any>,
|
|
204
|
+
options?: {
|
|
205
|
+
baseUrl?: string
|
|
206
|
+
lang?: PlayerLang | 'auto'
|
|
207
|
+
backHref?: string
|
|
208
|
+
backLabel?: string
|
|
209
|
+
showLangToggle?: boolean
|
|
210
|
+
}
|
|
211
|
+
): string
|
|
212
|
+
export function createSessionPlaybackModel(data: Record<string, any>): Record<string, any>
|
|
213
|
+
export function attachPlayerController(
|
|
214
|
+
root: HTMLElement,
|
|
215
|
+
rawData?: Record<string, any>,
|
|
216
|
+
options?: {
|
|
217
|
+
lang?: PlayerLang
|
|
218
|
+
initialStep?: number
|
|
219
|
+
onToggleLang?: (nextLang: PlayerLang, curStep: number) => void
|
|
220
|
+
}
|
|
221
|
+
): Record<string, any> | null
|
|
222
|
+
export function createEncorePlayer(
|
|
223
|
+
target: string | HTMLElement,
|
|
224
|
+
sourceOrSession?: string | EncoreSession,
|
|
225
|
+
options?: { baseUrl?: string; lang?: PlayerLang | 'auto'; initialStep?: number; showLangToggle?: boolean }
|
|
226
|
+
): Promise<{ setLang: (nextLang: PlayerLang) => void; getController: () => Record<string, any> | null }>
|
|
227
|
+
|
|
228
|
+
export function buildStandalonePlayerJs(options?: { write?: boolean }): string
|
|
229
|
+
export function renderIndexHtml(options?: { title?: string; lang?: string; sessionSrc?: string }): string
|
|
230
|
+
export function writePlayerAssets(
|
|
231
|
+
targetDir: string,
|
|
232
|
+
options?: { title?: string; lang?: string; sessionSrc?: string }
|
|
233
|
+
): { indexHtml: string; playerJs: string; playerCss: string }
|
|
234
|
+
|
|
235
|
+
export function serveReplayDir(
|
|
236
|
+
dir: string,
|
|
237
|
+
options?: { port?: number; open?: boolean }
|
|
238
|
+
): Promise<{ server: import('node:http').Server; port: number; url: string }>
|
|
239
|
+
export function openBrowser(url: string): void
|
|
240
|
+
|
|
241
|
+
export function resolveLang(lang?: string): PlayerLang
|
|
242
|
+
export function createTranslator(lang?: string): ((key: string, vars?: Record<string, unknown>) => string) & {
|
|
243
|
+
lang: PlayerLang
|
|
244
|
+
dict: Record<string, string>
|
|
245
|
+
}
|
|
246
|
+
export function escapeHtml(str: unknown): string
|
|
247
|
+
export function renderMarkdown(text: unknown): string
|
|
248
|
+
export function cutSession(session: EncoreSession, window?: { from?: string; to?: string }): EncoreSession
|
|
249
|
+
export function deriveDefaultTitle(session: Partial<EncoreSession>): string
|
|
250
|
+
export function extractImages(
|
|
251
|
+
session: EncoreSession,
|
|
252
|
+
outDir: string,
|
|
253
|
+
options?: { keep?: boolean; width?: number; lang?: PlayerLang }
|
|
254
|
+
): Promise<EncoreSession>
|
|
255
|
+
export function sumStats(items: SessionItem[]): Record<string, number>
|
|
256
|
+
export function describeStats(stats: Record<string, number>, lang?: PlayerLang | ((k: string, v?: any) => string)): string
|
|
257
|
+
export function kindOf(stats?: Record<string, number>): 'send' | 'back' | 'look' | 'make'
|
|
258
|
+
export function minutes(seconds?: number): number
|
|
259
|
+
export function wallClock(start: string, seconds?: number, withSeconds?: boolean): string
|
|
260
|
+
export function elapsedClock(seconds?: number): string
|