dsh-seal-scripts 0.5.1 → 0.5.2

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.
@@ -47,9 +47,9 @@ async function cachedDigest(dir) {
47
47
  export async function buildState(deps, dshHome, snapshot = null) {
48
48
  const options = readOptionsSync(dshHome)
49
49
  const persistence = deps.persistence
50
- if (persistence === undefined) throw new Error('会话持久化不可用')
50
+ if (persistence === undefined) throw new Error('session persistence is unavailable')
51
51
  const root = persistence.config?.root
52
- if (typeof root !== 'string' || root === '') throw new Error('会话持久化没有存储根目录')
52
+ if (typeof root !== 'string' || root === '') throw new Error('session persistence has no storage root')
53
53
  // 子代理会话不列:它们的 cwd 与主会话相同,混进来只会是一堆同名行。
54
54
  const headers = (await persistence.list())
55
55
  .map((row) => row.header ?? row)
@@ -58,7 +58,7 @@ export async function buildState(deps, dshHome, snapshot = null) {
58
58
 
59
59
  const byCwd = new Map()
60
60
  for (const header of headers) {
61
- const cwd = typeof header.cwd === 'string' ? header.cwd : '(无工作区)'
61
+ const cwd = typeof header.cwd === 'string' ? header.cwd : '(no workspace)'
62
62
  if (!byCwd.has(cwd)) byCwd.set(cwd, [])
63
63
  byCwd.get(cwd).push(header)
64
64
  }
@@ -75,7 +75,7 @@ export async function buildState(deps, dshHome, snapshot = null) {
75
75
  const digestCode = digest === null ? 'no-log' : (digest.ok === false ? digest.code : '')
76
76
  sessions.push({
77
77
  id: header.id,
78
- title: title || (digestCode === 'no-zstd' || digestCode === 'unreadable' ? shortId(header.id) : '空会话'),
78
+ title: title || (digestCode === 'no-zstd' || digestCode === 'unreadable' ? shortId(header.id) : 'empty session'),
79
79
  hasTitle: title !== '',
80
80
  digestCode,
81
81
  userMessages: digest?.userMessages ?? 0,
@@ -88,7 +88,7 @@ export async function buildState(deps, dshHome, snapshot = null) {
88
88
 
89
89
  // 只从载入文件算:以前这里为每份回顾整份 readFile,只为算几个界面从不显示的字段。
90
90
  let memories = []
91
- if (typeof cwd === 'string' && cwd !== '(无工作区)') {
91
+ if (typeof cwd === 'string' && cwd !== '(no workspace)') {
92
92
  const dir = memoryDir(dshHome, cwd)
93
93
  const data = await readAssembly(dir, cwd)
94
94
  const now = new Date()
@@ -112,7 +112,7 @@ export async function buildState(deps, dshHome, snapshot = null) {
112
112
  .sort((a, b) => String(b.compactedAt).localeCompare(String(a.compactedAt)))
113
113
  }
114
114
  // health:拆回顾最近一次成功/失败(F6)。没有记录就是 null,界面不显示那一行。
115
- const health = typeof cwd === 'string' && cwd !== '(无工作区)' ? healthOf(dshHome, cwd) : null
115
+ const health = typeof cwd === 'string' && cwd !== '(no workspace)' ? healthOf(dshHome, cwd) : null
116
116
  workspaces.push({ cwd, sessions, memories, health })
117
117
  }
118
118
  workspaces.sort((a, b) => a.cwd.localeCompare(b.cwd))
@@ -155,7 +155,7 @@ export function routesSessions(route, { dshHome, getDeps, waitForSplit, canLifec
155
155
  if (req.method !== 'POST') { respond(res, 405, { error: { code: 'method-not-allowed', message: 'POST' } }); return }
156
156
  const body = JSON.parse(await readBody(req) || '{}')
157
157
  if (typeof body.cwd !== 'string' || body.cwd === '') {
158
- respond(res, 400, { error: { code: 'invalid-body', message: '需要 cwd' } }); return
158
+ respond(res, 400, { error: { code: 'invalid-body', message: 'cwd is required' } }); return
159
159
  }
160
160
  // 选项每一次现读:设置页改完立刻重新取,框里的内容与下一轮注入是同一套装配。
161
161
  const options = readOptionsSync(dshHome)
@@ -181,7 +181,7 @@ export function routesSessions(route, { dshHome, getDeps, waitForSplit, canLifec
181
181
  if (req.method !== 'POST') { respond(res, 405, { error: { code: 'method-not-allowed', message: 'POST' } }); return }
182
182
  const body = JSON.parse(await readBody(req) || '{}')
183
183
  if (canLifecycle === false) {
184
- respond(res, 503, { error: { code: 'host-capability', message: '本宿主缺 agents.create/resume,「删除并回顾」已关闭' } })
184
+ respond(res, 503, { error: { code: 'host-capability', message: 'this host lacks agents.create/resume; "Delete + review" is off' } })
185
185
  return
186
186
  }
187
187
  try {
@@ -48,7 +48,7 @@ export function routesTools(route, { dshHome, onOptionsChanged }) {
48
48
  if (req.method !== 'POST') { respond(res, 405, { error: { code: 'method-not-allowed', message: 'POST' } }); return }
49
49
  const raw = await readBody(req)
50
50
  let body
51
- try { body = JSON.parse(raw || '{}') } catch { respond(res, 400, { error: { code: 'bad-json', message: '请求体不是 JSON' } }); return }
51
+ try { body = JSON.parse(raw || '{}') } catch { respond(res, 400, { error: { code: 'bad-json', message: 'request body is not JSON' } }); return }
52
52
  let packed
53
53
  try {
54
54
  packed = await exportToolSequence({ dshHome, dir: body && body.cwd })
@@ -97,13 +97,13 @@ export function routesTools(route, { dshHome, onOptionsChanged }) {
97
97
  const raw = await readBody(req)
98
98
  let body
99
99
  try { body = JSON.parse(raw || '{}') } catch {
100
- respond(res, 400, { error: { code: 'bad-json', message: '请求体不是 JSON' } })
100
+ respond(res, 400, { error: { code: 'bad-json', message: 'request body is not JSON' } })
101
101
  return
102
102
  }
103
103
  const data = typeof body.data === 'string' ? body.data : ''
104
- if (data === '') { respond(res, 400, { error: { code: 'missing-file', message: '没有收到包内容' } }); return }
105
- try { buffer = Buffer.from(data, 'base64') } catch { respond(res, 400, { error: { code: 'bad-base64', message: '包内容不是合法的 base64' } }); return }
106
- if (buffer.length === 0) { respond(res, 400, { error: { code: 'empty-file', message: '包是空的' } }); return }
104
+ if (data === '') { respond(res, 400, { error: { code: 'missing-file', message: 'no package content received' } }); return }
105
+ try { buffer = Buffer.from(data, 'base64') } catch { respond(res, 400, { error: { code: 'bad-base64', message: 'package content is not valid base64' } }); return }
106
+ if (buffer.length === 0) { respond(res, 400, { error: { code: 'empty-file', message: 'the package is empty' } }); return }
107
107
  bytes = buffer.length
108
108
  if (body.dryRun === true) dryRun = true
109
109
  if (typeof body.name === 'string' && body.name !== '') name = body.name
@@ -115,7 +115,7 @@ export function routesTools(route, { dshHome, onOptionsChanged }) {
115
115
  const written = await readBodyToFile(req, tmpFile)
116
116
  bytes = written.bytes
117
117
  if (bytes === 0) {
118
- respond(res, 400, { error: { code: 'empty-file', message: '包是空的' } })
118
+ respond(res, 400, { error: { code: 'empty-file', message: 'the package is empty' } })
119
119
  return
120
120
  }
121
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-seal-scripts",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "index.js",