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.
- package/README.en.md +3 -1
- package/README.md +3 -1
- package/lib/client.js +784 -3
- package/lib/core/assembly.js +8 -8
- package/lib/core/host-limits.js +5 -5
- package/lib/core/index.js +30 -30
- package/lib/core/inject.js +1 -1
- package/lib/core/lang.js +418 -75
- package/lib/core/locale.js +1 -1
- package/lib/core/memory-file.js +2 -5
- package/lib/core/migrate.js +1 -1
- package/lib/core/path-guard.js +4 -4
- package/lib/core/schema-runner.js +10 -10
- package/lib/core/schema-tools.js +88 -88
- package/lib/core/schema.js +49 -61
- package/lib/core/search.js +1 -1
- package/lib/core/settings.js +1 -1
- package/lib/core/store.js +1 -1
- package/lib/core/tool-transfer.js +14 -14
- package/lib/core/tool.js +71 -71
- package/lib/core/zip.js +35 -35
- package/lib/core/zstd-js.js +50 -50
- package/lib/core/zstd.js +1 -1
- package/lib/host/capabilities.js +3 -3
- package/lib/host/compact-delete.js +11 -11
- package/lib/host/delete.js +16 -16
- package/lib/host/host-contract.js +2 -2
- package/lib/host/http-util.js +1 -1
- package/lib/host/lifecycle.js +2 -2
- package/lib/host/register.js +3 -3
- package/lib/host/routes/memories.js +7 -7
- package/lib/host/routes/sessions.js +8 -8
- package/lib/host/routes/tools.js +6 -6
- package/package.json +1 -1
|
@@ -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 !== '(
|
|
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: '
|
|
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: '
|
|
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 {
|
package/lib/host/routes/tools.js
CHANGED
|
@@ -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: '
|
|
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: '
|
|
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: '
|
|
105
|
-
try { buffer = Buffer.from(data, 'base64') } catch { respond(res, 400, { error: { code: 'bad-base64', message: '
|
|
106
|
-
if (buffer.length === 0) { respond(res, 400, { error: { code: 'empty-file', message: '
|
|
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
|
}
|