dsh-sun-space 0.3.2 → 0.3.4
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/package.json +1 -1
- package/src/client.js +26 -7
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -23,7 +23,7 @@ window.__ModuleLoader__.load({
|
|
|
23
23
|
// vault 解析链(server 端 vault-path.ts 为唯一事实源):config/分桶映射(workspaces[本工作区])→
|
|
24
24
|
// 约定布局发现;当前工作区无骨架时引导以工作区为根初始化(服务端登记仅放行空目录/已含骨架)。
|
|
25
25
|
// 写回:① 创建会话后经 session/prompt 引导自登记(含 vault 字段);② 晨报自检发现缺失/不一致自动修正。
|
|
26
|
-
const WB_REV = '
|
|
26
|
+
const WB_REV = 'v22' // 根节点 data-wb-rev 版本标记:判别浏览器是否吃到旧 client.js(immutable 缓存坑,HANDOFF 踩坑 1)
|
|
27
27
|
|
|
28
28
|
const STATUS_META = {
|
|
29
29
|
proposed: { label: '待确认派发', color: '#9e9e9e' },
|
|
@@ -85,6 +85,7 @@ window.__ModuleLoader__.load({
|
|
|
85
85
|
'session/list': a => ({ _request: a ?? {} }),
|
|
86
86
|
'session/create': a => ({ request: a }),
|
|
87
87
|
'session/prompt': a => ({ request: a }),
|
|
88
|
+
'workspace/create': a => ({ request: a }),
|
|
88
89
|
'schedule/list': a => ({ request: a ?? {} }),
|
|
89
90
|
'schedule/create': a => ({ request: a }),
|
|
90
91
|
'schedule/edit': a => ({ request: a }),
|
|
@@ -171,7 +172,7 @@ window.__ModuleLoader__.load({
|
|
|
171
172
|
|
|
172
173
|
// ===== 初始化检查(在任何会话的 tab 上都能跑;① 用当前会话作 workspaceFiles scope)=====
|
|
173
174
|
async function runInitChecks(currentSessionId) {
|
|
174
|
-
const c = { vault: false, presets: false, routerSession: null, vaultPath: null, currentCwd: null, notes: [] }
|
|
175
|
+
const c = { vault: false, presets: false, routerSession: null, vaultPath: null, currentCwd: null, currentPreset: null, notes: [] }
|
|
175
176
|
// 会话列表只取一次:currentCwd 供 ① 跨工作区提示与一键初始化,router 解析复用
|
|
176
177
|
let items = null
|
|
177
178
|
try {
|
|
@@ -219,8 +220,13 @@ window.__ModuleLoader__.load({
|
|
|
219
220
|
const sl = await gw('session/list', {})
|
|
220
221
|
items = Array.isArray(sl?.items) ? sl.items : Object.values(sl?.items ?? {})
|
|
221
222
|
}
|
|
223
|
+
// 当前会话预设(复用判定:用户建会话时手选了 Sun Router → 初始化直接用本会话,不另建)
|
|
224
|
+
const cur = items.find(s => s.sessionId === currentSessionId) ?? {}
|
|
225
|
+
c.currentPreset = cur.projections?.values?.agentPreset ?? null
|
|
222
226
|
// vault 根登记由宿主插件在 sun-router 会话创建时自动完成(index.ts agent/created 钩子)
|
|
223
227
|
c.routerSession = vault ? await resolveRouterSession(vault, items) : null
|
|
228
|
+
// 当前会话即 Sun Router → 直接认领(vault 尚未定位/登记缺失时也不另建会话——复用优先)
|
|
229
|
+
if (!c.routerSession && c.currentPreset === 'sun-router') c.routerSession = currentSessionId
|
|
224
230
|
if (!c.routerSession) c.notes.push('Router 会话不存在 → 点下方「创建 Router 会话」(sun-router 预设,随当前工作区),创建后自动登记 state.json')
|
|
225
231
|
} catch {
|
|
226
232
|
c.notes.push('会话列表不可达 → 重试或检查实例')
|
|
@@ -229,8 +235,17 @@ window.__ModuleLoader__.load({
|
|
|
229
235
|
}
|
|
230
236
|
|
|
231
237
|
async function createRouterSession(cwd) {
|
|
232
|
-
// cwd 可选:一键初始化时传当前会话的工作区目录——Router
|
|
233
|
-
|
|
238
|
+
// cwd 可选:一键初始化时传当前会话的工作区目录——Router 会话落在用户选的工作区。
|
|
239
|
+
// 落位两步(踩坑 12:session/create 只传 cwd 只设会话目录、不入工作区 sessionIds → 未分组):
|
|
240
|
+
// ① workspace/create 幂等解析目录 → workspaceId(工作区不存在则注册)
|
|
241
|
+
// ② session/create 传 workspaceId(宿主只在 workspaceId 路径上 attachSession 入组)
|
|
242
|
+
if (cwd && cwd.startsWith('/')) {
|
|
243
|
+
try {
|
|
244
|
+
const w = await gw('workspace/create', { path: cwd })
|
|
245
|
+
const wid = w?.workspace?.workspaceId
|
|
246
|
+
if (wid) return gw('session/create', { workspaceId: wid, agentPreset: 'sun-router' })
|
|
247
|
+
} catch (e) { D.errors.push('workspace/create: ' + String(e?.message ?? e)) } // 解析失败 → 落回 cwd 路径
|
|
248
|
+
}
|
|
234
249
|
return gw('session/create', cwd ? { cwd, agentPreset: 'sun-router' } : { agentPreset: 'sun-router' })
|
|
235
250
|
}
|
|
236
251
|
|
|
@@ -450,8 +465,12 @@ window.__ModuleLoader__.load({
|
|
|
450
465
|
function OnboardPanel({ checks, currentSessionId, onRetry }) {
|
|
451
466
|
const steps = [
|
|
452
467
|
{ n: 1, ok: checks.presets, title: '确认依赖插件', desc: checks.presets ? '智能体协作 / 子智能体插件已启用' : '打开插件面板,启用 sun-space / 智能体协作相关插件后重启实例', action: checks.presets ? null : 'plugins' },
|
|
453
|
-
{ n: 2, ok: !!checks.routerSession, title: '一键初始化(Router 会话 + 知识库)', desc: checks.routerSession
|
|
454
|
-
|
|
468
|
+
{ n: 2, ok: !!checks.routerSession, title: '一键初始化(Router 会话 + 知识库)', desc: checks.routerSession
|
|
469
|
+
? `已就绪:${checks.routerSession.slice(0, 28)}…${checks.routerSession === currentSessionId ? '(当前会话)' : ''}`
|
|
470
|
+
: `一键完成:以当前工作区目录${checks.currentCwd ? `(${checks.currentCwd})` : ''}为知识库根 → 创建 Router 会话 → 写入 90-Meta 骨架 → 分桶自登记(全程零审批)${checks.currentPreset && checks.currentPreset !== 'sun-router' ? `。当前会话是 ${checks.currentPreset} 预设,初始化将新建 Router 会话;想直接复用:新建会话时在模式选择器选「Sun Router」` : ''}`, action: checks.presets && !checks.routerSession ? 'create-router' : null },
|
|
471
|
+
{ n: 3, ok: checks.vault, title: '知识库就绪', desc: checks.vault ? `已就绪:${checks.vaultPath}` : (checks.routerSession
|
|
472
|
+
? (checks.routerSession === currentSessionId ? '当前会话即 Sun Router——点下方按钮直接在本会话初始化知识库' : '知识库骨架缺失 → 点下方按钮让 Router 补建')
|
|
473
|
+
: '完成第②步后自动创建'), action: checks.presets && checks.routerSession && !checks.vault ? 'init-skeleton' : null },
|
|
455
474
|
]
|
|
456
475
|
const allOk = steps.every(x => x.ok)
|
|
457
476
|
return h('div', null, [
|
|
@@ -465,7 +484,7 @@ window.__ModuleLoader__.load({
|
|
|
465
484
|
]),
|
|
466
485
|
st.action === 'plugins' ? h('button', { key: 'a', onClick: () => { try { hostCtx.layout.selectPanel('plugins') } catch (e) { D.errors.push(String(e)) } }, style: btnStyle }, '打开插件面板') : null,
|
|
467
486
|
st.action === 'create-router' ? h('button', { key: 'a', onClick: () => createRouterAndInit(checks, onRetry), style: btnStyle }, '一键初始化') : null,
|
|
468
|
-
st.action === 'init-skeleton' ? h('button', { key: 'a', onClick: () => initSkeletonOnRouter(checks.routerSession, onRetry), style: btnStyle }, '补建知识库骨架') : null,
|
|
487
|
+
st.action === 'init-skeleton' ? h('button', { key: 'a', onClick: () => initSkeletonOnRouter(checks.currentPreset === 'sun-router' ? currentSessionId : checks.routerSession, onRetry), style: btnStyle }, checks.currentPreset === 'sun-router' ? '初始化知识库(本会话)' : '补建知识库骨架') : null,
|
|
469
488
|
|
|
470
489
|
])),
|
|
471
490
|
allOk ? h('p', { key: 'done', style: { color: '#57b26a', fontSize: 13 } }, '✓ 全部就绪——到「定时任务」用模板创建晨报等四条生产任务,即可开始使用。') : null,
|