@twinsearth/dsh-fang 3.1.31 → 3.1.33
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/client.js +67 -3
- package/package.json +1 -1
- package/src/kernel/types.mjs +1 -1
- package/src/plugins/orchestrator.mjs +52 -15
package/client.js
CHANGED
|
@@ -2129,6 +2129,69 @@ window.__ModuleLoader__.load({
|
|
|
2129
2129
|
doc.body.appendChild(backdrop)
|
|
2130
2130
|
}
|
|
2131
2131
|
|
|
2132
|
+
/**
|
|
2133
|
+
* v3.1.32:绿色「派生新分身」。
|
|
2134
|
+
* 1) 自动关联默认元主(开发者推荐的模板);没有默认则取第一个活跃元主;
|
|
2135
|
+
* 2) 弹窗选择一个进行中会话(一次只能导入一个,与服务端 derive 的硬校验一致)。
|
|
2136
|
+
*/
|
|
2137
|
+
async function deriveQuick() {
|
|
2138
|
+
if (isBusy()) return
|
|
2139
|
+
S.busy = 'derive:quick'
|
|
2140
|
+
let essence = null
|
|
2141
|
+
try {
|
|
2142
|
+
const listed = await api('/fang/api/essence/list')
|
|
2143
|
+
const data = listed.body ?? {}
|
|
2144
|
+
const essences = Array.isArray(data.essences) ? data.essences.filter((item) => item && item.archived !== true) : []
|
|
2145
|
+
const defaultId = String(data.defaultId ?? '')
|
|
2146
|
+
essence = essences.find((item) => String(item.id) === defaultId) ?? essences[0] ?? null
|
|
2147
|
+
} catch { essence = null }
|
|
2148
|
+
S.busy = ''
|
|
2149
|
+
if (!essence) {
|
|
2150
|
+
setNotice({
|
|
2151
|
+
tone: 'warn',
|
|
2152
|
+
title: '还没有可用的元主模板',
|
|
2153
|
+
message: '先「克隆母体」生成一个元主,或在元主列表里设置默认元主,再派生分身。',
|
|
2154
|
+
})
|
|
2155
|
+
return
|
|
2156
|
+
}
|
|
2157
|
+
S.busy = 'derive:quick:sessions'
|
|
2158
|
+
const res = await api('/fang/api/sessions?limit=200')
|
|
2159
|
+
S.busy = ''
|
|
2160
|
+
const sessions = Array.isArray(res.body?.sessions)
|
|
2161
|
+
? res.body.sessions.filter((session) => session.archived !== true)
|
|
2162
|
+
: []
|
|
2163
|
+
if (sessions.length === 0) {
|
|
2164
|
+
setNotice({ tone: 'warn', title: '没有可导入的会话', message: '先在 DSH 里开一个对话,再派生分身。' })
|
|
2165
|
+
return
|
|
2166
|
+
}
|
|
2167
|
+
showDerivePicker(sessions, essence.name || essence.id, async (sessionId) => {
|
|
2168
|
+
const session = sessions.find((item) => String(item.sessionId) === String(sessionId))
|
|
2169
|
+
const title = String(session?.title || essence.name || '派生分身').slice(0, 60)
|
|
2170
|
+
S.busy = 'derive:quick:run'
|
|
2171
|
+
const out = await api('/fang/api/tasks/create', {
|
|
2172
|
+
method: 'POST',
|
|
2173
|
+
body: JSON.stringify({ title, essenceId: essence.id, importSession: { sessionId } }),
|
|
2174
|
+
})
|
|
2175
|
+
S.busy = ''
|
|
2176
|
+
if (out.status === 200 && out.body?.ok) {
|
|
2177
|
+
setNotice({
|
|
2178
|
+
tone: 'ok',
|
|
2179
|
+
title: '已派生分身',
|
|
2180
|
+
message: `模板「${essence.name || essence.id}」· 会话 ${short(String(sessionId), 8)}${out.body?.port ? ' · 端口 ' + out.body.port : ''}`,
|
|
2181
|
+
actions: out.body?.taskId ? [{ label: '打开分身', onClick: () => void openTask({ taskId: out.body.taskId }) }] : [],
|
|
2182
|
+
})
|
|
2183
|
+
} else {
|
|
2184
|
+
setNotice({
|
|
2185
|
+
tone: 'bad',
|
|
2186
|
+
title: '派生失败',
|
|
2187
|
+
message: failureHint(out.body?.error || 'http-' + out.status),
|
|
2188
|
+
detail: out.body?.detail || '',
|
|
2189
|
+
actions: [{ label: '重试', onClick: () => void deriveQuick() }],
|
|
2190
|
+
})
|
|
2191
|
+
}
|
|
2192
|
+
await refresh()
|
|
2193
|
+
})
|
|
2194
|
+
}
|
|
2132
2195
|
async function deriveFromEssence(essence) {
|
|
2133
2196
|
if (isBusy()) return
|
|
2134
2197
|
S.busy = 'essence:derive:' + essence.id
|
|
@@ -2783,7 +2846,7 @@ window.__ModuleLoader__.load({
|
|
|
2783
2846
|
adviseDecision,
|
|
2784
2847
|
openEssence, copyEssence, archiveEssence, deleteEssence, downloadEssence, essenceImport,
|
|
2785
2848
|
essenceBackup, essenceRestore, openEssenceDetail, unfreezeEssence, stopEssenceRuntime,
|
|
2786
|
-
openBranches, forkBranch, activateBranch, deriveFromEssence,
|
|
2849
|
+
openBranches, forkBranch, activateBranch, deriveFromEssence, deriveQuick,
|
|
2787
2850
|
beginRename, commitRename, cancelRename, selectSession, toggleSet, toggleForkGroup,
|
|
2788
2851
|
toggleTemporary, setView: (next) => { S.view = next; schedule(true) },
|
|
2789
2852
|
loadForkSessions, loadMirror, mirrorAction, loadLink, probeMother, notify, announce,
|
|
@@ -3119,7 +3182,8 @@ window.__ModuleLoader__.load({
|
|
|
3119
3182
|
if (node) node.focus?.()
|
|
3120
3183
|
return
|
|
3121
3184
|
}
|
|
3122
|
-
|
|
3185
|
+
// v3.1.32:绿色按钮 = 默认元主 + 选一个进行中会话(不再直接发无会话请求)
|
|
3186
|
+
void app.deriveQuick()
|
|
3123
3187
|
},
|
|
3124
3188
|
fk: 'derive',
|
|
3125
3189
|
})),
|
|
@@ -3803,7 +3867,7 @@ window.__ModuleLoader__.load({
|
|
|
3803
3867
|
? ['没有临时内容', '临时 = 快速派生的空白分身(标题为“快速派生”)与空会话。']
|
|
3804
3868
|
: ['还没有存档', '归档后的分身会出现在这里,可还原或永久删除。']
|
|
3805
3869
|
body.append(emptyBlock(copy[0], copy[1], key === 'active'
|
|
3806
|
-
? [button('派生新分身', { size: 'sm', variant: 'primary', onClick: () => void app.
|
|
3870
|
+
? [button('派生新分身', { size: 'sm', variant: 'primary', onClick: () => void app.deriveQuick() })]
|
|
3807
3871
|
: []))
|
|
3808
3872
|
} else {
|
|
3809
3873
|
for (const task of tasks) body.append(renderForkCard(S, app, task, { archived: key === 'archived' }))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twinsearth/dsh-fang",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.33",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "dsh-Fang (瓮城) — mother/fork plugin development environment for DeepSeek Harness: one readonly mother, a disposable child dsh-Web per task.",
|
package/src/kernel/types.mjs
CHANGED
|
@@ -181,31 +181,57 @@ export function stripUrlToken(url) {
|
|
|
181
181
|
|
|
182
182
|
/** Find a runnable dsh launcher. `.cmd` wrappers are spawned through a shell by the forker. */
|
|
183
183
|
export function resolveCliPath(explicit = '', env = process.env, execPath = process.execPath) {
|
|
184
|
+
// v3.1.33:平台感知。v3.1.32 及以前只探测 Windows 的 dsh.cmd + 硬编码盘符,
|
|
185
|
+
// 在 macOS 上必然找不到 launcher → 回落裸 'dsh' → spawn ENOENT → spawn-error。
|
|
186
|
+
// (MacMini 实测:runtime-spawn-failed: spawn-error, profile=essence-runtime)
|
|
187
|
+
const isWindows = process.platform === 'win32'
|
|
188
|
+
// win 用 resources,mac 的 .app 是 Contents/Resources(大写)——按平台给真实大小写优先。
|
|
189
|
+
const binDirNames = isWindows ? ['resources', 'Resources'] : ['Resources', 'resources']
|
|
190
|
+
const binNames = isWindows ? ['dsh.cmd', 'dsh.exe', 'dsh'] : ['dsh', 'dsh.sh']
|
|
184
191
|
const candidates = []
|
|
185
|
-
if (
|
|
186
|
-
|
|
187
|
-
if (
|
|
192
|
+
const push = (value) => { if (value) candidates.push(value) }
|
|
193
|
+
|
|
194
|
+
if (explicit) push(explicit)
|
|
195
|
+
if (env.DSH_CLI) push(env.DSH_CLI)
|
|
196
|
+
if (env.DSH_INSTALL_DIR) {
|
|
197
|
+
for (const dir of binDirNames) {
|
|
198
|
+
for (const name of binNames) push(path.join(env.DSH_INSTALL_DIR, dir, 'runtime', 'cli', 'bin', name))
|
|
199
|
+
}
|
|
200
|
+
}
|
|
188
201
|
for (const dir of String(env.PATH ?? env.Path ?? '').split(path.delimiter)) {
|
|
189
202
|
if (!dir) continue
|
|
190
|
-
|
|
203
|
+
for (const name of binNames) push(path.join(dir, name))
|
|
191
204
|
}
|
|
192
|
-
//
|
|
193
|
-
// <install>\DeepSeek Harness.exe
|
|
194
|
-
//
|
|
205
|
+
// 从当前宿主可执行文件反推安装根:
|
|
206
|
+
// win : <install>\DeepSeek Harness.exe → <install>\resources\runtime\cli\bin\dsh.cmd
|
|
207
|
+
// mac : <app>/Contents/MacOS/DeepSeek Harness → <app>/Contents/Resources/runtime/cli/bin/dsh
|
|
195
208
|
try {
|
|
196
209
|
let dir = path.dirname(String(execPath ?? ''))
|
|
197
|
-
for (let i = 0; i <
|
|
198
|
-
|
|
199
|
-
|
|
210
|
+
for (let i = 0; i < 6 && dir; i += 1) {
|
|
211
|
+
for (const sub of binDirNames) {
|
|
212
|
+
for (const name of binNames) {
|
|
213
|
+
push(path.join(dir, sub, 'runtime', 'cli', 'bin', name))
|
|
214
|
+
push(path.join(dir, 'runtime', 'cli', 'bin', name))
|
|
215
|
+
}
|
|
216
|
+
}
|
|
200
217
|
const parent = path.dirname(dir)
|
|
201
218
|
if (parent === dir) break
|
|
202
219
|
dir = parent
|
|
203
220
|
}
|
|
204
221
|
} catch { /* keep legacy candidates */ }
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
'
|
|
208
|
-
|
|
222
|
+
|
|
223
|
+
if (isWindows) {
|
|
224
|
+
push('E:\\DS\\resources\\runtime\\cli\\bin\\dsh.cmd')
|
|
225
|
+
push('C:\\Program Files\\DeepSeek Harness\\resources\\runtime\\cli\\bin\\dsh.cmd')
|
|
226
|
+
} else {
|
|
227
|
+
// macOS / Linux 常见安装位置(含 .app 包内 CLI)
|
|
228
|
+
push('/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh')
|
|
229
|
+
push(path.join(String(env.HOME ?? ''), 'Applications', 'DeepSeek Harness.app', 'Contents', 'Resources', 'runtime', 'cli', 'bin', 'dsh'))
|
|
230
|
+
push('/opt/homebrew/bin/dsh')
|
|
231
|
+
push('/usr/local/bin/dsh')
|
|
232
|
+
push('/usr/bin/dsh')
|
|
233
|
+
}
|
|
234
|
+
|
|
209
235
|
for (const c of candidates) {
|
|
210
236
|
try { if (c && fs.existsSync(c)) return c } catch { /* next */ }
|
|
211
237
|
}
|
|
@@ -2336,7 +2362,18 @@ export function apply(ctx, config) {
|
|
|
2336
2362
|
// 契约 file 桥(contract-outbox);普通分身在 846/1461/1534 行已有同名注入。
|
|
2337
2363
|
env: { DSH_FANG_ROLE: 'fork', DSH_FANG_TASK_ID: forkId, DSH_FANG_ESSENCE: '1', DSH_FANG_MOTHER: layout.dataDir },
|
|
2338
2364
|
})
|
|
2339
|
-
if (!started.ok)
|
|
2365
|
+
if (!started.ok) {
|
|
2366
|
+
// v3.1.33:把真实 errno 与启动规格带进错误信息,避免只剩一个笼统的 spawn-error。
|
|
2367
|
+
const detail = started.message ? ` message=${started.message}` : ''
|
|
2368
|
+
const spec = started.spec ? ` spec=${started.spec.command} ${(started.spec.args ?? []).join(' ')}` : ''
|
|
2369
|
+
const logTail = Array.isArray(started.log) && started.log.length > 0
|
|
2370
|
+
? ` log=${String(started.log.slice(-3).join(' | ')).slice(0, 400)}`
|
|
2371
|
+
: ''
|
|
2372
|
+
throw new Error(
|
|
2373
|
+
`runtime-spawn-failed: ${started.error ?? 'unknown'} (forkId=${forkId}, homeDir=${homeDir}, profile=essence-runtime)`
|
|
2374
|
+
+ detail + spec + logTail,
|
|
2375
|
+
)
|
|
2376
|
+
}
|
|
2340
2377
|
return {
|
|
2341
2378
|
ok: true, essenceId: id, forkId,
|
|
2342
2379
|
url: started.url, port: started.port, pid: started.pid,
|