@capyclaw/capyclaw-workbench 0.1.4 → 0.1.5
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/node_modules/@capyclaw/foundation/package.json +1 -1
- package/node_modules/@capyclaw/plugin-kit/package.json +1 -1
- package/node_modules/@capyclaw/service-host/dsh-suite.json +1 -1
- package/node_modules/@capyclaw/service-host/package.json +1 -1
- package/node_modules/@capyclaw/suite-kit/package.json +1 -1
- package/node_modules/@capyclaw/tool-host/dsh-suite.json +1 -1
- package/node_modules/@capyclaw/tool-host/package.json +1 -1
- package/node_modules/@capyclaw/tool-host/src/mode-gate.mjs +21 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capyclaw/suite-kit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "DSH suite/domain 标准件(双重身份:构建期库 + 运行时库,暂不拆包,见 README「双重身份」)。构建期:manifest 校验、compose、profile 生成、domain 解析、artifact 打包;运行时:统一能力描述符、编排闸/授权、嵌入握手与 surface 挂载。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.mjs",
|
|
@@ -28,6 +28,10 @@ export function createModeGate({ getWorkStore } = {}) {
|
|
|
28
28
|
const domainByTool = new Map() // 原生工具名 → domain
|
|
29
29
|
const domainBySuite = new Map() // 套件名 → domain(描述符发现面按 suite 兜底)
|
|
30
30
|
const lockCache = new Map() // sid → kind(锁终生固化,一旦落定永不变更,可缓存)
|
|
31
|
+
// 规范工作模式种类:套件尚未 declare 时的兜底白名单(保证加载顺序鲁棒);
|
|
32
|
+
// 运行时与已注册 domain 取并集,容纳新增套件。防止拼错的 kind 把会话终生锁进
|
|
33
|
+
// 一个没有任何工具的域(会话砖化)。
|
|
34
|
+
const CANONICAL_KINDS = ['rsp', 'browser', 'ppt', 'canvas', 'capyclaw', 'works']
|
|
31
35
|
let guardInstalled = false
|
|
32
36
|
const guardDisposers = []
|
|
33
37
|
let coreToolsRegistered = false
|
|
@@ -77,6 +81,19 @@ export function createModeGate({ getWorkStore } = {}) {
|
|
|
77
81
|
return domainByTool.get(String(name)) || ''
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
/** 当前可用的工作模式种类(规范白名单 ∪ 已注册 domain),排序去重。 */
|
|
85
|
+
function knownKinds() {
|
|
86
|
+
const set = new Set(CANONICAL_KINDS)
|
|
87
|
+
for (const d of domainBySuite.values()) set.add(d)
|
|
88
|
+
for (const d of domainByTool.values()) set.add(d)
|
|
89
|
+
return [...set].sort()
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** kind 是否为已知工作模式(语义校验,防砖化)。 */
|
|
93
|
+
function isKnownKind(kind) {
|
|
94
|
+
return knownKinds().includes(String(kind || ''))
|
|
95
|
+
}
|
|
96
|
+
|
|
80
97
|
/**
|
|
81
98
|
* DSH register 的 when 条件。未声明领域的工具返回 undefined(不挂 when,恒可见,
|
|
82
99
|
* 也避免给内置/核心工具增加每步求值开销)。
|
|
@@ -125,6 +142,9 @@ export function createModeGate({ getWorkStore } = {}) {
|
|
|
125
142
|
execute: async (args, exec) => {
|
|
126
143
|
const kind = String(args?.kind || '').trim()
|
|
127
144
|
if (!kind) return { ok: false, error: '需要 kind(要锁定的工作模式/领域)' }
|
|
145
|
+
if (!isKnownKind(kind)) {
|
|
146
|
+
return { ok: false, error: `未知的工作模式「${kind}」,未锁定。`, validKinds: knownKinds() }
|
|
147
|
+
}
|
|
128
148
|
const sid = exec?.agent?.session?.id
|
|
129
149
|
if (!sid) return { ok: false, error: '无法识别当前会话,不能锁定' }
|
|
130
150
|
const ws = store()
|
|
@@ -268,5 +288,5 @@ export function createModeGate({ getWorkStore } = {}) {
|
|
|
268
288
|
})
|
|
269
289
|
}
|
|
270
290
|
|
|
271
|
-
return { declareTools, domainOf, modeOf, isVisible, whenFor, guard, install, installPrompt, filterEntries }
|
|
291
|
+
return { declareTools, domainOf, modeOf, isVisible, whenFor, guard, install, installPrompt, filterEntries, knownKinds, isKnownKind }
|
|
272
292
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capyclaw/capyclaw-workbench",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "CapyClaw 子会话工作台运行时:7 个 capyclaw_* 工具(创建/驱动/查询/关闭 DSH 子会话 + 读写设置)+ 俄罗斯套娃控制台(同源嵌入 DSH GUI)。挂在 dsh 的 /capyclaw/capyclaw。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./plugin.mjs",
|