@twinsearth/dsh-fang 3.1.16 → 3.1.19
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 +22 -9
- package/client.js +263 -19
- package/locale/en.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +1 -1
- package/src/kernel/types.mjs +2 -1
- package/src/plugins/adapter.mjs +26 -0
- package/src/plugins/session-catalog.mjs +12 -1
package/README.md
CHANGED
|
@@ -3,24 +3,37 @@
|
|
|
3
3
|
[](LICENSE-SDK)
|
|
4
4
|
[](https://www.npmjs.com/package/@twinsearth/dsh-fang)
|
|
5
5
|
|
|
6
|
-
# 瓮城
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
加载、运行、更新、回滚、卸载、回收,全生命周期管理。
|
|
7
|
+
# 瓮城:DSH 的第一台虚拟机!
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
> Dsh-瓮城,诞生于一群热爱折腾、也被折腾过无数次的极客之手。
|
|
10
|
+
> 我们深知在「自进化 AI」时代,**「如何安全地尝试新事物」比「新事物本身」更重要**。
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
## 如果你是以下三类人,瓮城就是为你量身定制的
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
### 1. 插件开发狂魔
|
|
15
|
+
每天要写 N 个新插件、改几百次代码。以前改一次重启一次 DSH;现在在瓮城里随便热更新,坏了直接秒回滚。
|
|
16
|
+
|
|
17
|
+
### 2. 多任务并发狂
|
|
18
|
+
一个窗口跑数据分析,一个窗口写爬虫,一个窗口做长周期测试。瓮城让你像开浏览器一样「多开不崩」,并且各跑各的绝对隔离。
|
|
19
|
+
|
|
20
|
+
### 3. 安全焦虑症患者
|
|
21
|
+
不敢把客户端交给第三方插件,怕乱删文件、怕被盗取 API Key。瓮城的审核系统和独立沙箱,把危险代码安排得明明白白。
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 它怎么做到
|
|
16
26
|
|
|
17
27
|
**母体大脑 + 分身器官 + 容器兜底**:
|
|
18
28
|
|
|
19
|
-
一个只读母体,每个任务派生一个用完即弃的子 dsh-Web;
|
|
29
|
+
- 一个只读母体,每个任务派生一个用完即弃的子 dsh-Web;
|
|
30
|
+
- 开发都在分身里,母体只在「提升」时被显式更新;
|
|
31
|
+
- 崩溃不扩散、污染不残留、插件不串味。
|
|
20
32
|
|
|
21
|
-
|
|
33
|
+
> 技术定位:**DeepSeek Harness 的第一台虚拟机**。
|
|
34
|
+
> 用 dsh-Web 当瓮城完成风险阻隔与审批(Beta),把 DeepSeek Harness 当主城保存原样不变(稳定版)。
|
|
22
35
|
|
|
23
|
-
|
|
36
|
+
---
|
|
24
37
|
|
|
25
38
|
> v2.3.1 把「瓮城」做进 Web UI(左侧导航 + 3:7 分屏控制面板 + 双击派生 + 母体/分身会话继续开发);
|
|
26
39
|
> v2.0.0 按三层拓扑重新部署,
|
package/client.js
CHANGED
|
@@ -479,6 +479,19 @@ window.__ModuleLoader__.load({
|
|
|
479
479
|
let timer = 0
|
|
480
480
|
let observer = null
|
|
481
481
|
let observed = null
|
|
482
|
+
let fallbackEl = null
|
|
483
|
+
let reported = false
|
|
484
|
+
|
|
485
|
+
// v3.1.17:客户端自报「已加载」,仅时间戳(供 /fang/adapter/identity 的 clientLoaded)。
|
|
486
|
+
const reportLoaded = () => {
|
|
487
|
+
if (reported) return
|
|
488
|
+
reported = true
|
|
489
|
+
try {
|
|
490
|
+
void fetch('/fang/adapter/client-report', { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' })
|
|
491
|
+
.catch(() => { /* 老宿主没有该路由:忽略 */ })
|
|
492
|
+
} catch { /* ignore */ }
|
|
493
|
+
}
|
|
494
|
+
|
|
482
495
|
const findBrandName = () => {
|
|
483
496
|
const candidates = document.querySelectorAll('[class*="brandName"]')
|
|
484
497
|
for (const node of candidates) {
|
|
@@ -502,50 +515,107 @@ window.__ModuleLoader__.load({
|
|
|
502
515
|
if (el.title !== title) el.title = title
|
|
503
516
|
if (el.getAttribute('aria-label') !== title) el.setAttribute('aria-label', title)
|
|
504
517
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
if (el && el.isConnected && el.parentElement) { paint(el); return true }
|
|
509
|
-
const brandName = findBrandName()
|
|
510
|
-
if (!brandName || !brandName.parentElement) return false
|
|
511
|
-
el = document.createElement('span')
|
|
518
|
+
|
|
519
|
+
const createBadge = () => {
|
|
520
|
+
const el = document.createElement('span')
|
|
512
521
|
el.id = WEB_ROLE_BADGE_ID
|
|
513
522
|
el.className = 'fang-web-role'
|
|
514
523
|
el.setAttribute('role', 'status')
|
|
515
524
|
el.setAttribute('aria-live', 'polite')
|
|
525
|
+
return el
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/** 首选:宿主侧栏品牌词标右侧。 */
|
|
529
|
+
const placeInBrand = () => {
|
|
530
|
+
if (!document || !document.body) return false
|
|
531
|
+
const existing = document.getElementById(WEB_ROLE_BADGE_ID)
|
|
532
|
+
if (existing && existing.isConnected && existing.parentElement && existing !== fallbackEl) { paint(existing); return true }
|
|
533
|
+
const brandName = findBrandName()
|
|
534
|
+
if (!brandName || !brandName.parentElement) return false
|
|
535
|
+
if (fallbackEl) { try { fallbackEl.remove() } catch { /* ignore */ } fallbackEl = null }
|
|
536
|
+
const el = createBadge()
|
|
516
537
|
brandName.parentElement.insertBefore(el, brandName.nextSibling)
|
|
517
538
|
paint(el)
|
|
518
|
-
|
|
519
|
-
if (observer) { try { observer.disconnect() } catch { /* ignore */ } }
|
|
520
|
-
observer = new MutationObserver(() => { try { place() } catch { /* ignore */ } })
|
|
521
|
-
try { observer.observe(brandName.parentElement, { childList: true, subtree: true }) } catch { /* ignore */ }
|
|
522
|
-
observed = brandName.parentElement
|
|
539
|
+
observe(brandName.parentElement)
|
|
523
540
|
return true
|
|
524
541
|
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* 兜底(v3.1.17):品牌槽不存在或被宿主整段移除时,挂到 body 右上角固定角标。
|
|
545
|
+
* 只在 3 次重试仍失败后启用,避免与正常挂载抢位置。
|
|
546
|
+
*/
|
|
547
|
+
const placeFallback = () => {
|
|
548
|
+
if (!document || !document.body) return false
|
|
549
|
+
if (fallbackEl && fallbackEl.isConnected) { paint(fallbackEl); return true }
|
|
550
|
+
const el = createBadge()
|
|
551
|
+
el.classList.add('fang-web-role--fallback')
|
|
552
|
+
el.style.position = 'fixed'
|
|
553
|
+
el.style.top = '8px'
|
|
554
|
+
el.style.right = '12px'
|
|
555
|
+
el.style.zIndex = '2147483000'
|
|
556
|
+
el.style.padding = '2px 8px'
|
|
557
|
+
el.style.borderRadius = '10px'
|
|
558
|
+
el.style.fontSize = '11px'
|
|
559
|
+
el.style.fontWeight = '600'
|
|
560
|
+
el.style.pointerEvents = 'none'
|
|
561
|
+
el.style.background = 'rgba(0,0,0,.55)'
|
|
562
|
+
document.body.append(el)
|
|
563
|
+
fallbackEl = el
|
|
564
|
+
paint(el)
|
|
565
|
+
observe(document.body)
|
|
566
|
+
return true
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
const observe = (node) => {
|
|
570
|
+
if (!node) return
|
|
571
|
+
if (observed === node && observer) return
|
|
572
|
+
if (observer) { try { observer.disconnect() } catch { /* ignore */ } }
|
|
573
|
+
observer = new MutationObserver(() => {
|
|
574
|
+
try { if (!placeInBrand()) placeFallback() } catch { /* ignore */ }
|
|
575
|
+
})
|
|
576
|
+
try { observer.observe(node, { childList: true, subtree: true }) } catch { /* ignore */ }
|
|
577
|
+
observed = node
|
|
578
|
+
}
|
|
579
|
+
|
|
525
580
|
const install = () => {
|
|
526
|
-
|
|
581
|
+
const ok = placeInBrand()
|
|
582
|
+
if (ok) { if (timer) { clearInterval(timer); timer = 0 } return true }
|
|
527
583
|
return false
|
|
528
584
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
585
|
+
|
|
586
|
+
reportLoaded()
|
|
587
|
+
|
|
588
|
+
// 3 次重试(250ms 间隔)后才兜底;宿主侧栏渲染通常在第一帧后就绪。
|
|
589
|
+
if (!install()) {
|
|
532
590
|
let tries = 0
|
|
533
591
|
timer = setInterval(() => {
|
|
534
592
|
tries += 1
|
|
535
|
-
|
|
593
|
+
const done = install()
|
|
594
|
+
if (!done && tries >= 3) {
|
|
595
|
+
clearInterval(timer)
|
|
596
|
+
timer = 0
|
|
597
|
+
placeFallback()
|
|
598
|
+
} else if (done) {
|
|
599
|
+
clearInterval(timer)
|
|
600
|
+
timer = 0
|
|
601
|
+
}
|
|
536
602
|
}, 250)
|
|
537
603
|
}
|
|
604
|
+
|
|
538
605
|
void (async () => {
|
|
539
606
|
const detected = await detectWebRole()
|
|
540
607
|
if (!detected) return
|
|
541
608
|
role = detected
|
|
542
|
-
install()
|
|
609
|
+
if (!install()) placeFallback()
|
|
543
610
|
})()
|
|
611
|
+
|
|
544
612
|
return () => {
|
|
545
613
|
if (timer) { clearInterval(timer); timer = 0 }
|
|
546
614
|
if (observer) { try { observer.disconnect() } catch { /* ignore */ } observer = null }
|
|
547
615
|
void observed
|
|
548
616
|
try { document.getElementById(WEB_ROLE_BADGE_ID)?.remove() } catch { /* ignore */ }
|
|
617
|
+
try { fallbackEl?.remove() } catch { /* ignore */ }
|
|
618
|
+
fallbackEl = null
|
|
549
619
|
}
|
|
550
620
|
}
|
|
551
621
|
|
|
@@ -6329,15 +6399,189 @@ window.__ModuleLoader__.load({
|
|
|
6329
6399
|
})
|
|
6330
6400
|
}
|
|
6331
6401
|
|
|
6402
|
+
|
|
6403
|
+
/**
|
|
6404
|
+
* v3.1.19:分身 Web 的界面收敛。
|
|
6405
|
+
*
|
|
6406
|
+
* 1) 隐藏左侧栏「插件」入口 —— 分身里不允许进入插件设置页(避免用户在一次性沙箱里
|
|
6407
|
+
* 改动宿主插件配置,导致下一次派生继承脏配置)。
|
|
6408
|
+
* 2) 「启动」类按钮在分身里变成真正无操作:capture 阶段拦下点击,
|
|
6409
|
+
* 宿主处理器不执行 → 不切换面板、不弹提醒、不打印错误。
|
|
6410
|
+
* (此前用户点「启动」会收到一条无法处理的报错,属噪音。)
|
|
6411
|
+
*
|
|
6412
|
+
* 只在 role === 'fork' 时生效;母体/元主不受影响。
|
|
6413
|
+
*/
|
|
6414
|
+
function mountForkUiLocks() {
|
|
6415
|
+
if (typeof document === 'undefined' || !document.body) return () => {}
|
|
6416
|
+
const doc = document
|
|
6417
|
+
let disposed = false
|
|
6418
|
+
let active = false
|
|
6419
|
+
let timer = 0
|
|
6420
|
+
let observer = null
|
|
6421
|
+
const NAV_TEXTS = ['插件']
|
|
6422
|
+
const ACTION_TEXTS = ['启动', '启动插件', '开始使用', '启用']
|
|
6423
|
+
|
|
6424
|
+
const isPanelRow = (node) => {
|
|
6425
|
+
try {
|
|
6426
|
+
if (!node || node.tagName !== 'BUTTON') return false
|
|
6427
|
+
const cls = String(node.className || '')
|
|
6428
|
+
return /panelRow/i.test(cls)
|
|
6429
|
+
} catch { return false }
|
|
6430
|
+
}
|
|
6431
|
+
|
|
6432
|
+
const hidePluginNav = () => {
|
|
6433
|
+
if (disposed || !active) return
|
|
6434
|
+
for (const node of doc.querySelectorAll('button')) {
|
|
6435
|
+
if (!isPanelRow(node)) continue
|
|
6436
|
+
const text = String(node.textContent || '').trim()
|
|
6437
|
+
if (!NAV_TEXTS.includes(text)) continue
|
|
6438
|
+
if (node.dataset.fangForkHidden === '1' && node.hidden) continue
|
|
6439
|
+
node.dataset.fangForkHidden = '1'
|
|
6440
|
+
node.hidden = true
|
|
6441
|
+
node.setAttribute('aria-hidden', 'true')
|
|
6442
|
+
node.style.setProperty('display', 'none', 'important')
|
|
6443
|
+
}
|
|
6444
|
+
}
|
|
6445
|
+
|
|
6446
|
+
const onClickCapture = (event) => {
|
|
6447
|
+
if (!active || disposed) return
|
|
6448
|
+
const target = event.target
|
|
6449
|
+
const button = target && typeof target.closest === 'function' ? target.closest('button') : null
|
|
6450
|
+
if (!button) return
|
|
6451
|
+
const text = String(button.textContent || '').trim()
|
|
6452
|
+
// ① 侧栏「插件」入口:双重保险(DOM 已隐藏,这里再拦一次点击/键盘激活)
|
|
6453
|
+
if (isPanelRow(button) && NAV_TEXTS.includes(text)) {
|
|
6454
|
+
event.preventDefault()
|
|
6455
|
+
event.stopPropagation()
|
|
6456
|
+
event.stopImmediatePropagation()
|
|
6457
|
+
return
|
|
6458
|
+
}
|
|
6459
|
+
// ② 插件页「启动」:无操作(不切换、不提醒、不报错)
|
|
6460
|
+
const isAction = ACTION_TEXTS.some((label) => text === label || text.startsWith(label))
|
|
6461
|
+
if (!isAction) return
|
|
6462
|
+
event.preventDefault()
|
|
6463
|
+
event.stopPropagation()
|
|
6464
|
+
event.stopImmediatePropagation()
|
|
6465
|
+
// ③ 万一宿主已被别处触发过提示,把残留的错误气泡收掉(仅限含错误语义的气泡)
|
|
6466
|
+
setTimeout(() => {
|
|
6467
|
+
if (disposed) return
|
|
6468
|
+
for (const node of doc.querySelectorAll('[role="alert"],[class*="toast"],[class*="Toast"]')) {
|
|
6469
|
+
const body = String(node.textContent || '')
|
|
6470
|
+
if (!/失败|错误|异常|无法|不能|不可|不允许|拒绝|failed|error/i.test(body)) continue
|
|
6471
|
+
if (node.dataset.fangForkAlertHidden === '1') continue
|
|
6472
|
+
node.dataset.fangForkAlertPrevDisplay = node.style.display || ''
|
|
6473
|
+
node.dataset.fangForkAlertHidden = '1'
|
|
6474
|
+
node.style.setProperty('display', 'none', 'important')
|
|
6475
|
+
}
|
|
6476
|
+
}, 60)
|
|
6477
|
+
}
|
|
6478
|
+
|
|
6479
|
+
const activate = () => {
|
|
6480
|
+
if (active || disposed) return
|
|
6481
|
+
active = true
|
|
6482
|
+
hidePluginNav()
|
|
6483
|
+
doc.addEventListener('click', onClickCapture, true)
|
|
6484
|
+
try {
|
|
6485
|
+
observer = new MutationObserver(() => { hidePluginNav() })
|
|
6486
|
+
observer.observe(doc.body, { childList: true, subtree: true })
|
|
6487
|
+
} catch { observer = null }
|
|
6488
|
+
timer = setInterval(hidePluginNav, 1500)
|
|
6489
|
+
try { timer && timer.unref && timer.unref() } catch { /* ignore */ }
|
|
6490
|
+
hidePluginNav()
|
|
6491
|
+
}
|
|
6492
|
+
|
|
6493
|
+
void (async () => {
|
|
6494
|
+
try {
|
|
6495
|
+
const role = await detectWebRole()
|
|
6496
|
+
if (disposed || role !== 'fork') return
|
|
6497
|
+
activate()
|
|
6498
|
+
} catch { /* 识别失败:保持原样,不误伤母体 */ }
|
|
6499
|
+
})()
|
|
6500
|
+
|
|
6501
|
+
return () => {
|
|
6502
|
+
disposed = true
|
|
6503
|
+
active = false
|
|
6504
|
+
if (timer) { clearInterval(timer); timer = 0 }
|
|
6505
|
+
try { observer?.disconnect() } catch { /* ignore */ }
|
|
6506
|
+
observer = null
|
|
6507
|
+
try { doc.removeEventListener('click', onClickCapture, true) } catch { /* ignore */ }
|
|
6508
|
+
// 恢复被隐藏的入口与提示,避免热卸载后宿主界面残缺
|
|
6509
|
+
for (const node of doc.querySelectorAll('button[data-fang-fork-hidden="1"]')) {
|
|
6510
|
+
try {
|
|
6511
|
+
node.hidden = false
|
|
6512
|
+
node.removeAttribute('aria-hidden')
|
|
6513
|
+
node.style.removeProperty('display')
|
|
6514
|
+
delete node.dataset.fangForkHidden
|
|
6515
|
+
} catch { /* ignore */ }
|
|
6516
|
+
}
|
|
6517
|
+
for (const node of doc.querySelectorAll('[data-fang-fork-alert-hidden="1"]')) {
|
|
6518
|
+
try {
|
|
6519
|
+
const prev = node.dataset.fangForkAlertPrevDisplay || ''
|
|
6520
|
+
if (prev) node.style.display = prev
|
|
6521
|
+
else node.style.removeProperty('display')
|
|
6522
|
+
delete node.dataset.fangForkAlertPrevDisplay
|
|
6523
|
+
delete node.dataset.fangForkAlertHidden
|
|
6524
|
+
} catch { /* ignore */ }
|
|
6525
|
+
}
|
|
6526
|
+
}
|
|
6527
|
+
}
|
|
6528
|
+
|
|
6529
|
+
|
|
6530
|
+
/**
|
|
6531
|
+
* v3.1.19:元主 / 分身 Web 的「关闭二次确认」。
|
|
6532
|
+
*
|
|
6533
|
+
* 右上角直接关闭很容易误触(尤其是把分身窗口当临时浏览器用时)。
|
|
6534
|
+
* 这里注册 beforeunload:浏览器会弹出原生「离开此网站?」确认框,
|
|
6535
|
+
* 用户确认后才真正关闭;母体(主会话)不注册,避免打断正常主机操作。
|
|
6536
|
+
*/
|
|
6537
|
+
function mountCloseConfirm() {
|
|
6538
|
+
if (typeof window === 'undefined') return () => {}
|
|
6539
|
+
let installed = false
|
|
6540
|
+
let disposed = false
|
|
6541
|
+
const onBeforeUnload = (event) => {
|
|
6542
|
+
try {
|
|
6543
|
+
event.preventDefault()
|
|
6544
|
+
// 现代浏览器忽略自定义文案,但仍要求设置 returnValue 才会弹确认框
|
|
6545
|
+
event.returnValue = '确认关闭瓮城窗口?未保存的分身状态会丢失。'
|
|
6546
|
+
} catch { /* ignore */ }
|
|
6547
|
+
return event.returnValue
|
|
6548
|
+
}
|
|
6549
|
+
const activate = () => {
|
|
6550
|
+
if (installed || disposed) return
|
|
6551
|
+
installed = true
|
|
6552
|
+
window.addEventListener('beforeunload', onBeforeUnload)
|
|
6553
|
+
// 兜底:宿主若用 history/路由隐藏关闭入口,键盘快捷键也走同一确认
|
|
6554
|
+
window.addEventListener('unload', () => {}, { once: true })
|
|
6555
|
+
}
|
|
6556
|
+
void (async () => {
|
|
6557
|
+
try {
|
|
6558
|
+
const role = await detectWebRole()
|
|
6559
|
+
if (disposed) return
|
|
6560
|
+
// 母体是主机式长驻窗口,不打断;元主/分身需要确认
|
|
6561
|
+
if (role === 'essence' || role === 'fork') activate()
|
|
6562
|
+
} catch { /* ignore */ }
|
|
6563
|
+
})()
|
|
6564
|
+
return () => {
|
|
6565
|
+
disposed = true
|
|
6566
|
+
if (!installed) return
|
|
6567
|
+
installed = false
|
|
6568
|
+
try { window.removeEventListener('beforeunload', onBeforeUnload) } catch { /* ignore */ }
|
|
6569
|
+
}
|
|
6570
|
+
}
|
|
6571
|
+
|
|
6332
6572
|
// ── 插件入口 ──────────────────────────────────────────────────────────
|
|
6333
6573
|
return {
|
|
6334
6574
|
mountPanel,
|
|
6335
|
-
...(typeof window !== 'undefined' && window.__FANG_TEST_HOOK__ ? { __renderDecisionMini: renderDecisionMini, __mountWebRoleBadge: mountWebRoleBadge, __detectWebRole: detectWebRole, __mountDecisionRelay: mountDecisionRelay } : {}),
|
|
6575
|
+
...(typeof window !== 'undefined' && window.__FANG_TEST_HOOK__ ? { __renderDecisionMini: renderDecisionMini, __mountWebRoleBadge: mountWebRoleBadge, __detectWebRole: detectWebRole, __mountForkUiLocks: mountForkUiLocks, __mountCloseConfirm: mountCloseConfirm, __mountDecisionRelay: mountDecisionRelay } : {}),
|
|
6336
6576
|
inject: ['slots'],
|
|
6337
6577
|
apply(ctx) {
|
|
6338
6578
|
const disposers = []
|
|
6339
6579
|
// v3.1.12:侧栏 HARNESS 右侧的 Web 端身份徽标(母体 / 元主 / 分身)。
|
|
6340
6580
|
disposers.push(mountWebRoleBadge())
|
|
6581
|
+
// v3.1.19:分身 Web 界面收敛(隐藏「插件」入口 + 「启动」无操作)。
|
|
6582
|
+
disposers.push(mountForkUiLocks())
|
|
6583
|
+
// v3.1.19:元主 / 分身 Web 关闭前二次确认(防误触)。
|
|
6584
|
+
disposers.push(mountCloseConfirm())
|
|
6341
6585
|
// 母体 Web = DSH 主会话视图;Web 端直接切回 conversation 面板。
|
|
6342
6586
|
const goMother = () => {
|
|
6343
6587
|
try {
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
|
-
"title": "
|
|
4
|
-
"description": "
|
|
3
|
+
"title": "Fangcheng: DSH's First Virtual Machine!",
|
|
4
|
+
"description": "Dsh-Fangcheng was born from a group of geeks who love tinkering — and have been burned by it more times than we can count. In the era of self-evolving AI, we believe that \"how to safely try something new\" matters more than \"the new thing itself\".\n\nIf you are one of these three, Fangcheng was built for you:\n1. The plugin-building maniac: writing N new plugins a day and changing code hundreds of times. You used to restart DSH after every edit; now you hot-reload inside Fangcheng, and a broken build rolls back instantly.\n2. The multi-tasker: one window for data analysis, one for a crawler, one for long-running tests. Fangcheng lets you open as many as you like without crashing — each in its own absolute isolation.\n3. The security worrier: unwilling to hand your client to third-party plugins, afraid of deleted files or stolen API keys. Fangcheng's review gates and independent sandboxes keep risky code boxed in."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
|
-
"title": "
|
|
4
|
-
"description": "
|
|
3
|
+
"title": "瓮城:DSH的第一台虚拟机!",
|
|
4
|
+
"description": "Dsh-瓮城,诞生于一群热爱折腾、也被折腾过无数次的极客之手。我们深知在“自进化 AI”时代,“如何安全地尝试新事物”比“新事物本身”更重要!\n\n如果你是以下三类人,瓮城就是为你量身定制的:\n1. 插件开发狂魔:每天要写 N 个新插件、改几百次代码。以前改一次重启一次 DSH;现在在瓮城里随便热更新,坏了直接秒回滚。\n2. 多任务并发狂:一个窗口跑数据分析,一个窗口写爬虫,一个窗口做长周期测试。瓮城让你像开浏览器一样“多开不崩”,并各跑各的绝对隔离。\n3. 安全焦虑症患者:不敢把客户端交给第三方插件,怕乱删文件、怕被盗取 API Key。瓮城的审核系统和独立沙箱,把危险代码安排得明明白白。"
|
|
5
5
|
}
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twinsearth/dsh-fang",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.19",
|
|
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
|
@@ -129,7 +129,7 @@ export const AUDIT = {
|
|
|
129
129
|
RUNTIME_ERROR: 'runtime-error',
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
export const FANG_VERSION = '3.1.
|
|
132
|
+
export const FANG_VERSION = '3.1.19'
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
135
|
* @typedef {object} ForkInfo
|
|
@@ -193,6 +193,7 @@ export const ADAPTER_OP = {
|
|
|
193
193
|
export const ADAPTER_ROUTE = {
|
|
194
194
|
HELLO: '/adapter/hello',
|
|
195
195
|
IDENTITY: '/adapter/identity',
|
|
196
|
+
CLIENT_REPORT: '/adapter/client-report',
|
|
196
197
|
STATUS: '/adapter/status',
|
|
197
198
|
APPROVALS: '/adapter/approvals',
|
|
198
199
|
AUDIT: '/adapter/audit',
|
package/src/plugins/adapter.mjs
CHANGED
|
@@ -695,13 +695,29 @@ export function apply(ctx, config) {
|
|
|
695
695
|
|
|
696
696
|
// v3.1.14:Web 端拿不到 adapter Bearer token,身份探测走公开只读路由;
|
|
697
697
|
// 只暴露 role/kind/version,不含 taskId/sessionId/token。
|
|
698
|
+
let clientReported = false
|
|
699
|
+
let clientReportedAt = 0
|
|
700
|
+
|
|
698
701
|
const identity = () => ({
|
|
699
702
|
ok: true,
|
|
700
703
|
role,
|
|
701
704
|
kind: identityKind({ role, taskId, essence: typeof process !== 'undefined' && process.env?.DSH_FANG_ESSENCE === '1' }),
|
|
702
705
|
version: FANG_VERSION,
|
|
703
706
|
protocol: ADAPTER_PROTOCOL_VERSION,
|
|
707
|
+
// v3.1.17:一眼判断「服务端有身份、客户端没加载」——不含 taskId/token 等敏感字段。
|
|
708
|
+
surface: 'web-adapter',
|
|
709
|
+
clientLoaded: clientReported,
|
|
710
|
+
clientReportedAt: clientReportedAt || null,
|
|
704
711
|
})
|
|
712
|
+
/**
|
|
713
|
+
* 客户端自报:Web 端加载了 fang client 后会 POST 到这里;
|
|
714
|
+
* 只记录时间,不记录任何身份/token(用于运维排查徽标不显示)。
|
|
715
|
+
*/
|
|
716
|
+
const reportClient = () => {
|
|
717
|
+
clientReported = true
|
|
718
|
+
clientReportedAt = Date.now()
|
|
719
|
+
return { ok: true, clientReported: true, at: clientReportedAt }
|
|
720
|
+
}
|
|
705
721
|
|
|
706
722
|
const approvals = () => {
|
|
707
723
|
const items = approvalItemsWithOrphans()
|
|
@@ -1108,6 +1124,8 @@ export function apply(ctx, config) {
|
|
|
1108
1124
|
routes: [],
|
|
1109
1125
|
|
|
1110
1126
|
hello,
|
|
1127
|
+
identity,
|
|
1128
|
+
reportClient,
|
|
1111
1129
|
status,
|
|
1112
1130
|
approvals,
|
|
1113
1131
|
audit,
|
|
@@ -1235,6 +1253,14 @@ export function apply(ctx, config) {
|
|
|
1235
1253
|
handler: (req, res) => json(res, 200, identity()),
|
|
1236
1254
|
})
|
|
1237
1255
|
try { service.routes.push(`${prefix}${ADAPTER_ROUTE.IDENTITY}`) } catch { /* fake ws */ }
|
|
1256
|
+
// v3.1.17:客户端自报加载状态(只记录时间戳,不含身份/token)。
|
|
1257
|
+
webServer.register({
|
|
1258
|
+
kind: 'exact',
|
|
1259
|
+
path: `${prefix}${ADAPTER_ROUTE.CLIENT_REPORT}`,
|
|
1260
|
+
method: 'POST',
|
|
1261
|
+
handler: (req, res) => json(res, 200, reportClient()),
|
|
1262
|
+
})
|
|
1263
|
+
try { service.routes.push(`${prefix}${ADAPTER_ROUTE.CLIENT_REPORT}`) } catch { /* fake ws */ }
|
|
1238
1264
|
const route = (method, routePath, handler) => {
|
|
1239
1265
|
webServer.register({
|
|
1240
1266
|
kind: 'exact',
|
|
@@ -365,6 +365,10 @@ export function apply(ctx, config) {
|
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
const workspaceFilter = typeof opts.workspaceId === 'string' && opts.workspaceId.trim() ? opts.workspaceId.trim() : null
|
|
368
|
+
// v3.1.17:房主 Router 的 Ticket→会话映射键(sessionKey/ticketId)原样带回,
|
|
369
|
+
// 便于 3_Sessions 把「工单」与「母体会话目录」对齐;不参与过滤,只做标注。
|
|
370
|
+
const sessionKey = typeof opts.sessionKey === 'string' && opts.sessionKey.trim() ? opts.sessionKey.trim() : null
|
|
371
|
+
const ticketId = typeof opts.ticketId === 'string' && opts.ticketId.trim() ? opts.ticketId.trim() : null
|
|
368
372
|
|
|
369
373
|
let items = scanned.sessions
|
|
370
374
|
if (!includeArchivedEffective) items = items.filter((session) => !session.archived)
|
|
@@ -385,7 +389,14 @@ export function apply(ctx, config) {
|
|
|
385
389
|
})
|
|
386
390
|
return {
|
|
387
391
|
ok: true,
|
|
388
|
-
sessions: page.map((session) => ({
|
|
392
|
+
sessions: page.map((session) => ({
|
|
393
|
+
...sessionView(session),
|
|
394
|
+
...titleFields(titleOf(session), session.workspaceTitle),
|
|
395
|
+
...(sessionKey ? { sessionKey } : {}),
|
|
396
|
+
...(ticketId ? { ticketId } : {}),
|
|
397
|
+
})),
|
|
398
|
+
...(sessionKey ? { sessionKey } : {}),
|
|
399
|
+
...(ticketId ? { ticketId } : {}),
|
|
389
400
|
total,
|
|
390
401
|
returned: page.length,
|
|
391
402
|
limit: requestedLimit,
|