dsh-seal-scripts 0.5.1 → 0.6.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.en.md +185 -165
- package/README.md +179 -184
- package/lib/client.js +818 -7
- package/lib/core/assembly.js +8 -8
- package/lib/core/host-limits.js +5 -5
- package/lib/core/index.js +38 -31
- 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 +191 -27
- package/lib/host/delete.js +48 -20
- 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 +4 -3
package/lib/host/delete.js
CHANGED
|
@@ -58,29 +58,52 @@ async function plainDirectory(dir) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* 关掉活会话。只用宿主公开的能力:agents.create/resume 返回的句柄 + cancel/whenIdle/flush。
|
|
62
|
+
* 拿不到句柄就拒绝,不猜——这是插件原本的语义,也是上游 DSH 唯一能保证的路径。
|
|
62
63
|
* @returns {Promise<{ok:true} | {ok:false, code:string, message:string}>}
|
|
63
64
|
*/
|
|
64
65
|
async function closeLive(deps, sessionId) {
|
|
65
66
|
const live = deps.sessions?.get(sessionId)
|
|
66
67
|
const agent = deps.agents?.get(sessionId)
|
|
67
68
|
if (live === undefined && agent === undefined) return { ok: true }
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
if (agent === undefined) {
|
|
70
|
+
return { ok: false, code: 'session-busy', message: 'this session is live in the engine but has no agent attached; close it in the app first, then delete' }
|
|
71
|
+
}
|
|
72
|
+
// 1) 宿主自带 teardown:够用时一步到底(cancel → whenIdle → 关作用域 → 落盘句柄 → detach)。
|
|
73
|
+
// 1) 插件在 agents.create/resume 上抓到的句柄。
|
|
74
|
+
const handle = ownedHandlesOf(agent);
|
|
75
|
+
if (handle === undefined) {
|
|
76
|
+
// 2) 没句柄就自己造一把:cancel → whenIdle → 关掉 agent 自己的作用域,全用 agent 上公开的成员。
|
|
77
|
+
// 摘注册表是宿主闭包里的动作,外面拿不到,所以删完可能留一条残留,用 leftover 标记回给调用方。
|
|
78
|
+
if (typeof agent.cancel !== 'function' || typeof agent.whenIdle !== 'function'
|
|
79
|
+
|| typeof agent.scope?.dispose !== 'function') {
|
|
80
|
+
return { ok: false, code: 'session-busy', message: 'the live session has no public handle available; let its owner stop it first, then delete' }
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
agent.cancel({ kind: 'disposed' }, { keepInbox: true })
|
|
84
|
+
await withTimeout(agent.whenIdle(), 'the agent did not become idle')
|
|
85
|
+
await withTimeout(agent.scope.dispose(), 'the agent scope did not close')
|
|
86
|
+
} catch (error) {
|
|
87
|
+
return { ok: false, code: 'session-busy', message: 'cannot shut this session down: ' + message(error) + '; the original logs are kept' }
|
|
88
|
+
}
|
|
89
|
+
const leftover = deps.agents.get(sessionId) !== undefined || deps.sessions.get(sessionId) !== undefined
|
|
90
|
+
return { ok: true, leftover }
|
|
91
|
+
}
|
|
92
|
+
if (agent.session !== live || typeof agent.cancel !== 'function'
|
|
70
93
|
|| typeof agent.whenIdle !== 'function' || typeof deps.sessions?.flush !== 'function') {
|
|
71
|
-
return { ok: false, code: 'session-busy', message: '
|
|
94
|
+
return { ok: false, code: 'session-busy', message: 'the live session has no public handle available; let its owner stop it first, then delete' }
|
|
72
95
|
}
|
|
73
96
|
try {
|
|
74
97
|
agent.cancel({ kind: 'disposed' })
|
|
75
|
-
await withTimeout(agent.whenIdle(), 'agent
|
|
76
|
-
if (await deps.sessions.flush(live) !== true) throw new Error('
|
|
77
|
-
await withTimeout(handle.dispose(), 'agent
|
|
98
|
+
await withTimeout(agent.whenIdle(), 'the agent did not become idle')
|
|
99
|
+
if (await deps.sessions.flush(live) !== true) throw new Error('no persistence listener confirmed the flush')
|
|
100
|
+
await withTimeout(handle.dispose(), 'the agent release did not finish')
|
|
78
101
|
if (deps.agents.get(sessionId) !== undefined || deps.sessions.get(sessionId) !== undefined) {
|
|
79
|
-
throw new Error('
|
|
102
|
+
throw new Error('live references remain after release')
|
|
80
103
|
}
|
|
81
104
|
return { ok: true }
|
|
82
105
|
} catch (error) {
|
|
83
|
-
return { ok: false, code: 'session-busy', message: '
|
|
106
|
+
return { ok: false, code: 'session-busy', message: 'cannot shut this session down: ' + message(error) + '; the original logs are kept' }
|
|
84
107
|
}
|
|
85
108
|
}
|
|
86
109
|
|
|
@@ -91,10 +114,10 @@ async function closeLive(deps, sessionId) {
|
|
|
91
114
|
* @returns {Promise<{status:number, ok:boolean, deleted?:string, warnings?:string[], error?:object}>}
|
|
92
115
|
*/
|
|
93
116
|
export async function deleteSessionPermanently(deps, sessionId) {
|
|
94
|
-
if (typeof sessionId !== 'string' || sessionId === '') return failure(400, 'invalid-session-id', 'sessionId
|
|
117
|
+
if (typeof sessionId !== 'string' || sessionId === '') return failure(400, 'invalid-session-id', 'sessionId must be a non-empty string')
|
|
95
118
|
const root = deps.persistence?.config?.root
|
|
96
|
-
if (typeof root !== 'string' || root === '') return failure(503, 'persistence-unavailable', '
|
|
97
|
-
if (deleting.has(sessionId)) return failure(409, 'session-busy', '
|
|
119
|
+
if (typeof root !== 'string' || root === '') return failure(503, 'persistence-unavailable', 'session persistence has no storage root configured')
|
|
120
|
+
if (deleting.has(sessionId)) return failure(409, 'session-busy', 'this session is already being deleted')
|
|
98
121
|
deleting.add(sessionId)
|
|
99
122
|
try {
|
|
100
123
|
let header, workspaces
|
|
@@ -103,31 +126,36 @@ export async function deleteSessionPermanently(deps, sessionId) {
|
|
|
103
126
|
header = all.map((row) => row.header ?? row).find((h) => h.id === sessionId)
|
|
104
127
|
workspaces = deps.workspaceRegistry === undefined ? [] : deps.workspaceRegistry.list()
|
|
105
128
|
if (!Array.isArray(workspaces) || workspaces.some((row) => typeof row.detachSession !== 'function')) {
|
|
106
|
-
throw new Error('workspace
|
|
129
|
+
throw new Error('workspace\'s public detachSession is unavailable')
|
|
107
130
|
}
|
|
108
131
|
} catch (error) {
|
|
109
|
-
return failure(500, 'delete-lookup-failed', '
|
|
132
|
+
return failure(500, 'delete-lookup-failed', 'cannot find the session to delete: ' + message(error))
|
|
110
133
|
}
|
|
111
|
-
if (header === undefined) return failure(404, 'session-not-found', '
|
|
134
|
+
if (header === undefined) return failure(404, 'session-not-found', 'no such session: ' + sessionId)
|
|
112
135
|
|
|
113
136
|
const closed = await closeLive(deps, sessionId)
|
|
114
137
|
if (!closed.ok) return failure(409, closed.code, closed.message)
|
|
138
|
+
// 自己造的那把钥匙只能停住 agent;注册表摘除是宿主闭包里的动作,外面做不到。
|
|
139
|
+
const stopNote = closed.leftover === true
|
|
140
|
+
? 'the engine still holds a live reference to this session until it restarts'
|
|
141
|
+
: ''
|
|
115
142
|
|
|
116
143
|
const dir = sessionDirOf(root, header.cwd, sessionId)
|
|
117
|
-
if (!inside(resolve(root), dir)) return failure(500, 'delete-failed', '
|
|
144
|
+
if (!inside(resolve(root), dir)) return failure(500, 'delete-failed', 'the session directory escaped the storage root')
|
|
118
145
|
try {
|
|
119
146
|
await plainDirectory(dir)
|
|
120
147
|
const names = await readdir(dir)
|
|
121
|
-
if (!names.some((n) => PAYLOAD_NAME.test(n))) throw new Error('
|
|
148
|
+
if (!names.some((n) => PAYLOAD_NAME.test(n))) throw new Error('no session log in the directory')
|
|
122
149
|
await rm(dir, { recursive: true, force: true })
|
|
123
150
|
} catch (error) {
|
|
124
|
-
return failure(500, 'delete-failed', '
|
|
151
|
+
return failure(500, 'delete-failed', 'cannot delete the session log: ' + message(error))
|
|
125
152
|
}
|
|
126
153
|
|
|
127
|
-
const warnings = []
|
|
154
|
+
const warnings = stopNote === '' ? [] : [stopNote]
|
|
155
|
+
// 目录已删,让工作区把它从列表里摘掉(公开接口只有这一条)。
|
|
128
156
|
for (const workspace of workspaces) {
|
|
129
157
|
try { await workspace.detachSession(sessionId) }
|
|
130
|
-
catch (error) { warnings.push('
|
|
158
|
+
catch (error) { warnings.push('workspace ' + workspace.id + ' still holds this session: ' + message(error)) }
|
|
131
159
|
}
|
|
132
160
|
return { status: 200, ok: true, deleted: sessionId, ...(warnings.length ? { warnings } : {}) }
|
|
133
161
|
} finally {
|
|
@@ -45,7 +45,7 @@ export function probeHostFormat(sessionDir) {
|
|
|
45
45
|
return {
|
|
46
46
|
ok: false,
|
|
47
47
|
code: 'host-format-changed',
|
|
48
|
-
detail: '
|
|
48
|
+
detail: 'unknown log names appeared: ' + unknown.join(', ')
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -60,7 +60,7 @@ export function probeHostFormat(sessionDir) {
|
|
|
60
60
|
return {
|
|
61
61
|
ok: false,
|
|
62
62
|
code: 'host-format-changed',
|
|
63
|
-
detail: LOG_NAME + '
|
|
63
|
+
detail: LOG_NAME + ' does not start with the zstd magic number'
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
} finally {
|
package/lib/host/http-util.js
CHANGED
|
@@ -74,7 +74,7 @@ export function readBodyBuffer(req, limit = NO_LIMIT) {
|
|
|
74
74
|
chunks.length = 0
|
|
75
75
|
// 已经太大:暂停上游,不再收;交给调用方回 413。
|
|
76
76
|
try { req.pause() } catch { /* 有些 req 没有 pause */ }
|
|
77
|
-
const err = new Error('
|
|
77
|
+
const err = new Error('request body exceeds the limit (' + max + ' bytes)')
|
|
78
78
|
err.code = 'body-too-large'
|
|
79
79
|
no(err)
|
|
80
80
|
return
|
package/lib/host/lifecycle.js
CHANGED
|
@@ -30,13 +30,13 @@ export function installLifecycle(agents, logger) {
|
|
|
30
30
|
if (agents[MARK] === true) return () => {}
|
|
31
31
|
const proto = Object.getPrototypeOf(agents)
|
|
32
32
|
if (proto === null || typeof proto !== 'object') {
|
|
33
|
-
logger?.warn?.('
|
|
33
|
+
logger?.warn?.('host agents have no usable prototype; deleting live sessions is off')
|
|
34
34
|
return () => {}
|
|
35
35
|
}
|
|
36
36
|
// 先把两条都验完再动手:验一条补一条的话,第二条缺了会留下半套补丁。
|
|
37
37
|
for (const method of METHODS) {
|
|
38
38
|
if (typeof proto[method] !== 'function') {
|
|
39
|
-
logger?.warn?.('
|
|
39
|
+
logger?.warn?.('host lacks agents.' + method + '(); deleting live sessions is off')
|
|
40
40
|
return () => {}
|
|
41
41
|
}
|
|
42
42
|
}
|
package/lib/host/register.js
CHANGED
|
@@ -24,11 +24,11 @@ export function makeRoute(webCtx) {
|
|
|
24
24
|
try {
|
|
25
25
|
const rejection = webCtx.connection?.requestRejection?.(req)
|
|
26
26
|
if (rejection !== undefined) {
|
|
27
|
-
respond(res, rejection, { error: { code: 'access-denied', message: '
|
|
27
|
+
respond(res, rejection, { error: { code: 'access-denied', message: 'sign in first' } })
|
|
28
28
|
return
|
|
29
29
|
}
|
|
30
30
|
if (!sameOrigin(req)) {
|
|
31
|
-
respond(res, 403, { error: { code: 'cross-origin', message: '
|
|
31
|
+
respond(res, 403, { error: { code: 'cross-origin', message: 'cross-origin request rejected' } })
|
|
32
32
|
return
|
|
33
33
|
}
|
|
34
34
|
await handler(req, res)
|
|
@@ -39,7 +39,7 @@ export function makeRoute(webCtx) {
|
|
|
39
39
|
}
|
|
40
40
|
// 路径越界是调用方给错了参数,不是服务端坏了:回 400 + 可识别的错误码。
|
|
41
41
|
// 判据在 path-guard.js 里,靠它那句固定开头认人。
|
|
42
|
-
if (
|
|
42
|
+
if (/^only files inside /.test(error?.message ?? '')) {
|
|
43
43
|
respond(res, 400, { error: { code: 'path-outside', message: error.message } })
|
|
44
44
|
return
|
|
45
45
|
}
|
|
@@ -22,9 +22,9 @@ const PREFIX = '/api/session-seal-scripts.'
|
|
|
22
22
|
async function deleteMemory(dshHome, cwd, file) {
|
|
23
23
|
const dir = memoryDir(dshHome, cwd)
|
|
24
24
|
// 判据只留 path-guard 一份(以前这里自带一份,用 startsWith('..') 会把 ..foo.md 误拦)。
|
|
25
|
-
const abs = assertMarkdown(assertInside(dir, file, { label: '
|
|
25
|
+
const abs = assertMarkdown(assertInside(dir, file, { label: 'this workspace\'s review directory' }), file)
|
|
26
26
|
const exists = await stat(abs).then(() => true, () => false)
|
|
27
|
-
if (!exists) throw new Error('
|
|
27
|
+
if (!exists) throw new Error('this review does not exist: ' + file)
|
|
28
28
|
// 顺序不能反:先删正文、再删边车。中间崩溃 → 边车成了孤儿,readAssembly 会自己清掉。
|
|
29
29
|
// 反过来(先删边车)而正文还在,下一次读会按 mtime 把边车补回来——等于没删掉索引。
|
|
30
30
|
await rm(abs, { force: true })
|
|
@@ -51,7 +51,7 @@ export function routesMemories(route, { dshHome }) {
|
|
|
51
51
|
if (req.method !== 'POST') { respond(res, 405, { error: { code: 'method-not-allowed', message: 'POST' } }); return }
|
|
52
52
|
const body = JSON.parse(await readBody(req) || '{}')
|
|
53
53
|
if (typeof body.cwd !== 'string' || typeof body.file !== 'string') {
|
|
54
|
-
respond(res, 400, { error: { code: 'invalid-body', message: '
|
|
54
|
+
respond(res, 400, { error: { code: 'invalid-body', message: 'cwd and file are required' } }); return
|
|
55
55
|
}
|
|
56
56
|
respond(res, 200, await deleteMemory(dshHome, body.cwd, body.file))
|
|
57
57
|
})
|
|
@@ -60,7 +60,7 @@ export function routesMemories(route, { dshHome }) {
|
|
|
60
60
|
if (req.method !== 'POST') { respond(res, 405, { error: { code: 'method-not-allowed', message: 'POST' } }); return }
|
|
61
61
|
const body = JSON.parse(await readBody(req) || '{}')
|
|
62
62
|
if (typeof body.cwd !== 'string' || typeof body.file !== 'string') {
|
|
63
|
-
respond(res, 400, { error: { code: 'invalid-body', message: '
|
|
63
|
+
respond(res, 400, { error: { code: 'invalid-body', message: 'cwd and file are required' } }); return
|
|
64
64
|
}
|
|
65
65
|
respond(res, 200, await readMemory(dshHome, body.cwd, body.file))
|
|
66
66
|
})
|
|
@@ -69,18 +69,18 @@ export function routesMemories(route, { dshHome }) {
|
|
|
69
69
|
if (req.method !== 'POST') { respond(res, 405, { error: { code: 'method-not-allowed', message: 'POST' } }); return }
|
|
70
70
|
const body = JSON.parse(await readBody(req) || '{}')
|
|
71
71
|
if (typeof body.cwd !== 'string' || typeof body.file !== 'string') {
|
|
72
|
-
respond(res, 400, { error: { code: 'invalid-body', message: '
|
|
72
|
+
respond(res, 400, { error: { code: 'invalid-body', message: 'cwd and file are required' } }); return
|
|
73
73
|
}
|
|
74
74
|
const hasKeywords = Array.isArray(body.keywords)
|
|
75
75
|
const hasDiary = typeof body.diary === 'string'
|
|
76
76
|
if (!hasKeywords && !hasDiary) {
|
|
77
|
-
respond(res, 400, { error: { code: 'invalid-body', message: 'keywords
|
|
77
|
+
respond(res, 400, { error: { code: 'invalid-body', message: 'pass at least one of keywords or diary' } }); return
|
|
78
78
|
}
|
|
79
79
|
// 写侧必须过闸门:以前这里直接 join + 手写 tmp/rename,能改别的工作区的回顾,
|
|
80
80
|
// 也不受「日记 ≤ 摘要、关键词 < 日记」约束,写不进去时还回 ok:true。
|
|
81
81
|
const dir = memoryDir(dshHome, body.cwd)
|
|
82
82
|
await mkdir(dir, { recursive: true })
|
|
83
|
-
const abs = assertMarkdown(assertInside(dir, body.file, { label: '
|
|
83
|
+
const abs = assertMarkdown(assertInside(dir, body.file, { label: 'this workspace\'s review directory' }), body.file)
|
|
84
84
|
const before = await readFile(abs, 'utf8')
|
|
85
85
|
// 和 session_mem_write 走同一个 applyWrite:两道闸门、只动目标区、改完校验。
|
|
86
86
|
// 它抛什么就回什么——设置页和模型看到的是同一句话。
|
|
@@ -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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-seal-scripts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
"cordis.patch.yml",
|
|
17
17
|
"lib",
|
|
18
18
|
"README.md",
|
|
19
|
-
"LICENSE"
|
|
19
|
+
"LICENSE",
|
|
20
|
+
"README.en.md"
|
|
20
21
|
],
|
|
21
22
|
"peerDependencies": {
|
|
22
|
-
"@deepseek-ai/dsh": ">=0.2.
|
|
23
|
+
"@deepseek-ai/dsh": ">=0.2.2-rc.1 <1.0.0"
|
|
23
24
|
},
|
|
24
25
|
"peerDependenciesMeta": {
|
|
25
26
|
"@deepseek-ai/dsh": {
|