dsh-plugin-tool-management 0.22.3 → 0.22.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/CHANGELOG.md +1415 -1363
- package/README.md +177 -176
- package/README_EN.md +177 -176
- package/docs/ARCHITECTURE.md +134 -0
- package/docs/COMPATIBILITY.md +107 -0
- package/docs/TROUBLESHOOTING.md +285 -0
- package/docs/UPDATE.md +50 -48
- package/lib/client.js +4693 -4626
- package/lib/compat/host-contracts.js +4 -2
- package/lib/confirm-gate.js +49 -18
- package/lib/context-inject-surface.js +45 -13
- package/lib/context-inject.js +1 -1
- package/lib/imports/unzip.js +144 -26
- package/lib/index.js +245 -93
- package/lib/legacy-tool-names.js +46 -0
- package/lib/mcp/manager.js +12 -1
- package/lib/mcp/secret-guard.js +27 -0
- package/lib/mcp/state-section.js +17 -8
- package/lib/mcp/tool-visibility.js +86 -10
- package/lib/memories/archive.js +44 -0
- package/lib/memories/index-io.js +4 -1
- package/lib/memories/service.js +94 -3
- package/lib/op-registry.js +5 -1
- package/lib/ops/scene-capture.js +72 -0
- package/lib/prompts/service.js +27 -0
- package/lib/scope/scope-overrides.js +9 -2
- package/lib/skills/catalog.js +18 -9
- package/lib/skills/dir-watch.js +49 -22
- package/lib/skills/service.js +2 -2
- package/lib/subagents/catalog.js +13 -7
- package/lib/subagents/run-provider.js +41 -10
- package/lib/subagents/tools.js +63 -7
- package/lib/tool-table-switch.js +41 -4
- package/lib/tools/control.js +158 -0
- package/lib/tools/deps.js +88 -0
- package/lib/tools/mcp.js +35 -10
- package/lib/tools/memory.js +9 -5
- package/lib/tools/prompt.js +7 -8
- package/lib/tools/remove.js +84 -65
- package/lib/tools/scene.js +179 -76
- package/lib/tools/skills.js +13 -8
- package/lib/tools/subagent.js +19 -10
- package/lib/tools/table.js +92 -57
- package/lib/trash-id.js +3 -2
- package/package.json +156 -152
package/lib/tools/remove.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
// 删除 / 回收站族的 model
|
|
1
|
+
// 删除 / 回收站族的 model 工具:**一条** `plugin_manager_remove`(五个域共用)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 为什么要有这一族:此前模型**只能停用、不能删除** —— "把这条过时的记忆删掉"这类要求手里
|
|
4
4
|
// 没有出口,模型会去调 `*_switch(enabled:false)` 然后回一句"已停用",用户以为删了。面板上
|
|
5
5
|
// 每个域都有删除,模型侧一条都没有。
|
|
6
6
|
//
|
|
7
|
+
// 为什么是**一条**而不是五个域各一条:五个域的动词、参数、回执骨架完全相同,只有名词与
|
|
8
|
+
// id 形状不同 —— 分成五条就是同一段文字抄五遍(≈1.1k token/轮)。合成一条后省下 ≈800 token,
|
|
9
|
+
// 代价是模型要多填一个 `domain`。
|
|
10
|
+
// ⚠️ 代价只在**全开模式**兑现:出厂默认关着的工具,schema 一分不付。
|
|
11
|
+
//
|
|
7
12
|
// 三条纪律:
|
|
8
13
|
// · **删除一律进回收站**(可恢复),与面板同一条路 —— 回执如实说"可恢复"。
|
|
9
14
|
// · **不做 purge**(永久删除):低频且不可恢复,用户要求"使用频率低的可以不要,
|
|
@@ -14,22 +19,29 @@
|
|
|
14
19
|
// 参数名统一 `id`:`trash` 时是资源标识(记忆 `<场景>/<名>`、技能名、人设名、预设 id、
|
|
15
20
|
// 场景名),`restore` 时是 `action=list` 给出的**回收站条目 id** —— 两种含义在描述里写清。
|
|
16
21
|
import { candidateNote, globalActionNote, locateSkillRoot, requireGlobalScope, scopeGlobalOnlyDesc, sessionLayerOn, text, toolOrNeutral, } from './deps.js';
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
/**
|
|
23
|
+
* 三个动词共用的描述骨架(跨域版)。
|
|
24
|
+
*
|
|
25
|
+
* 五个域共用这一段,所以这里**不点名任何一个域、也不点名任何一条工具** —— 域由
|
|
26
|
+
* `domain` 参数说,别的工具该不该点名按可见性在运行时分叉(见 `toolOrNeutral`)。
|
|
27
|
+
* 静态文案点名一条模型手里没有的工具就是把它往墙上推(插件的既定纪律)。
|
|
28
|
+
*/
|
|
29
|
+
function removeDescription() {
|
|
30
|
+
return 'Delete one item (to the trash), restore one, or list the trash. '
|
|
20
31
|
+ 'Deletes are recoverable; this tool never empties the trash. '
|
|
21
|
-
+ '
|
|
32
|
+
+ 'Deleting asks the user to confirm; listing the trash and restoring do not. '
|
|
33
|
+
+ 'Blocked while the active scene is locked. '
|
|
34
|
+
+ 'Only on the user\'s instruction.';
|
|
22
35
|
}
|
|
23
36
|
/** `action` 参数:三个动词 + 每个动词要哪个 `id`。 */
|
|
24
37
|
const ACTION_DESC = 'trash = delete the item named by `id`; restore = put back a trash entry id (from list); list = list the trash (no `id`).';
|
|
25
|
-
/** 删除只有全局一份(会话层没有可删的东西),四个域同一句话。 */
|
|
26
|
-
const REMOVE_SCOPE_DESC = scopeGlobalOnlyDesc('one machine-wide copy', 'switch it off here instead');
|
|
27
38
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
39
|
+
* 删除只有全局一份(会话层没有可删的东西),五个域同一句话。
|
|
40
|
+
*
|
|
41
|
+
* 「改用开关停掉」那句只写通配形式:五个域里只有记忆 / 技能 / 人设有对应的开关,
|
|
42
|
+
* 场景没有「关掉」这个动作(退出是另一件事,见 `sceneExitNote`),预设根本没有开关。
|
|
31
43
|
*/
|
|
32
|
-
const
|
|
44
|
+
const REMOVE_SCOPE_DESC = scopeGlobalOnlyDesc('these items have one machine-wide copy', 'to stop one being used instead, switch it off with the matching *_manager_switch');
|
|
33
45
|
/**
|
|
34
46
|
* 恢复 op 回传的**最终落盘名**。五个域把名字放在不同字段上:
|
|
35
47
|
* · 记忆 / 技能 / 人设 / 场景 → `name`(退号恢复时它是新名字,不是回收站里的原名)
|
|
@@ -54,6 +66,14 @@ function restoredName(r) {
|
|
|
54
66
|
};
|
|
55
67
|
return pick(r) || pick(r && r.data);
|
|
56
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* 一条删除工具的 execute:三个动词的分派与回执。
|
|
71
|
+
*
|
|
72
|
+
* 会话层:删除是**全局**动作 —— 技能正文、人设 `.md`、场景档案、MCP 补丁
|
|
73
|
+
* 提示词预设都只有一份,没有「本会话的副本」,所以这一格的口径就是「全局动作」。
|
|
74
|
+
* 所以这里不写会话层,只在**这个对话真有该域覆盖**时补一句尾注:
|
|
75
|
+
* 删完之后那条会话覆盖还在(读时忽略,对账才清),不说明的话用户会以为它跟着没了。
|
|
76
|
+
*/
|
|
57
77
|
async function runRemove(deps, cfg, args, agent, isMemoryId) {
|
|
58
78
|
const action = String((args && args.action) || '');
|
|
59
79
|
if (action !== 'trash' && action !== 'restore' && action !== 'list') {
|
|
@@ -95,15 +115,19 @@ async function runRemove(deps, cfg, args, agent, isMemoryId) {
|
|
|
95
115
|
// 只按形状(`a/b`)判会误伤 —— 场景名与技能名都没有禁止斜杠的校验,用户起的名字里
|
|
96
116
|
// 完全可能出现。所以这里读一次记忆库确认存在;读不到就当不是,宁可少说一句。
|
|
97
117
|
if (action === 'trash' && cfg.domain !== 'memory' && id.indexOf('/') > 0 && await isMemoryId(id)) {
|
|
98
|
-
|
|
99
|
-
|
|
118
|
+
// 五个域合进一条之后,这条错误只差一个 domain —— 说的是同一个工具,不必绕。
|
|
119
|
+
throw new Error('"' + id + '" is a memory id (memory ids are <scene>/<name>), but domain=' + cfg.domain
|
|
120
|
+
+ ' handles ' + cfg.noun + 's. Call this tool again with domain=memory (action=trash) for it.');
|
|
100
121
|
}
|
|
101
122
|
const r = action === 'trash' ? await cfg.trash(args) : await cfg.restore(args);
|
|
102
123
|
if (!r || r.ok === false)
|
|
103
124
|
throw new Error((r && r.error) || (action === 'trash' ? 'failed to move it to the trash' : 'restore failed'));
|
|
104
125
|
if (action === 'trash') {
|
|
105
|
-
|
|
106
|
-
|
|
126
|
+
// 永久删除是**刻意不给模型**的(不可恢复,且低频)—— 但这句话是给模型看的,
|
|
127
|
+
// 说清「这里只到回收站」就够,不必把人推去面板。
|
|
128
|
+
return 'OK: ' + cfg.label + ' "' + id + '" moved to the trash (recoverable; permanent deletion is not offered here)' +
|
|
129
|
+
(cfg.domain === undefined ? '' : globalActionNote(deps, agent, cfg.domain, cfg.label)) +
|
|
130
|
+
sceneExitNote(deps, agent, cfg.domain);
|
|
107
131
|
}
|
|
108
132
|
// 恢复的回执要说**恢复成了什么**,而不是回收站条目 id:
|
|
109
133
|
// `id` 是 `action=list` 给的那一串(记忆 `mv…`、技能 `<时间戳>-<uuid>`),模型看到它
|
|
@@ -112,7 +136,21 @@ async function runRemove(deps, cfg, args, agent, isMemoryId) {
|
|
|
112
136
|
return 'OK: restored ' + cfg.label + ' "' + name + '" from the trash' +
|
|
113
137
|
(name === id ? '' : ' (trash entry ' + id + ')');
|
|
114
138
|
}
|
|
115
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* 删掉场景之后的补充:场景删了**不等于离开了当前场景**。
|
|
141
|
+
*
|
|
142
|
+
* 退出是另一件事(`scene_manager_switch` action=exit),而那条工具出厂关着 ——
|
|
143
|
+
* 静态描述里点名它就是在指一条模型手里没有的工具,所以这句话按可见性分叉:
|
|
144
|
+
* 看得见就点名,看不见就退回中性说法(工具面的一致纪律,见 `toolOrNeutral`)。
|
|
145
|
+
*
|
|
146
|
+
* 只有场景域需要这一句:其余四个域删掉的就是「不再被使用」,没有「留在里面」这回事。
|
|
147
|
+
*/
|
|
148
|
+
function sceneExitNote(deps, agent, domain) {
|
|
149
|
+
if (domain !== 'scene')
|
|
150
|
+
return '';
|
|
151
|
+
return ' ' + toolOrNeutral(deps, agent, 'scene_manager_switch', 'You are still in it — leave it with scene_manager_switch (action=exit).', 'You are still in it — leaving it is a separate action, and the scene tools are off here.');
|
|
152
|
+
}
|
|
153
|
+
/** 注册删除类工具:五个域共用一条 `plugin_manager_remove`(按 `domain` 分派)。 */
|
|
116
154
|
export function buildRemoveTools(deps) {
|
|
117
155
|
const { defineTool, register } = deps;
|
|
118
156
|
const mem = deps.memoryOps;
|
|
@@ -257,60 +295,41 @@ export function buildRemoveTools(deps) {
|
|
|
257
295
|
},
|
|
258
296
|
},
|
|
259
297
|
};
|
|
298
|
+
// 五个域的配置表:一条工具按 `domain` 取用哪一份。
|
|
299
|
+
const cfgs = {
|
|
300
|
+
memory: memoryCfg,
|
|
301
|
+
skill: skillCfg,
|
|
302
|
+
persona: subagentCfg,
|
|
303
|
+
preset: promptCfg,
|
|
304
|
+
scene: sceneCfg,
|
|
305
|
+
};
|
|
260
306
|
register(defineTool({
|
|
261
|
-
name: '
|
|
262
|
-
description: removeDescription(
|
|
263
|
-
parameters: {
|
|
264
|
-
action: { type: 'string', required: true, enum: ['trash', 'restore', 'list'], description: ACTION_DESC },
|
|
265
|
-
id: { type: 'string', description: 'For trash: the memory id `<scene>/<name>`; for restore: a trash entry id; omit for list.' },
|
|
266
|
-
scope: { type: 'string', enum: ['session', 'global'], description: REMOVE_SCOPE_DESC },
|
|
267
|
-
},
|
|
268
|
-
output: { schema: { type: 'string' }, render: (_a, v) => text(String(v)) },
|
|
269
|
-
async execute(args, exec) { return runRemove(deps, memoryCfg, args, exec && exec.agent, isMemoryId); },
|
|
270
|
-
}));
|
|
271
|
-
register(defineTool({
|
|
272
|
-
name: 'skill_manager_remove',
|
|
273
|
-
description: removeDescription('skill'),
|
|
274
|
-
parameters: {
|
|
275
|
-
action: { type: 'string', required: true, enum: ['trash', 'restore', 'list'], description: ACTION_DESC },
|
|
276
|
-
id: { type: 'string', description: 'For trash: the skill name; for restore: a trash entry id; omit for list.' },
|
|
277
|
-
scope: { type: 'string', enum: ['session', 'global'], description: REMOVE_SCOPE_DESC },
|
|
278
|
-
root: { type: 'string', description: 'Source root the skill lives in. Default: whichever source holds that skill; only used by action=trash.' },
|
|
279
|
-
},
|
|
280
|
-
output: { schema: { type: 'string' }, render: (_a, v) => text(String(v)) },
|
|
281
|
-
async execute(args, exec) { return runRemove(deps, skillCfg, args, exec && exec.agent, isMemoryId); },
|
|
282
|
-
}));
|
|
283
|
-
register(defineTool({
|
|
284
|
-
name: 'subagent_manager_remove',
|
|
285
|
-
description: removeDescription('persona'),
|
|
307
|
+
name: 'plugin_manager_remove',
|
|
308
|
+
description: removeDescription(),
|
|
286
309
|
parameters: {
|
|
287
310
|
action: { type: 'string', required: true, enum: ['trash', 'restore', 'list'], description: ACTION_DESC },
|
|
288
|
-
|
|
311
|
+
domain: {
|
|
312
|
+
type: 'string', required: true, enum: ['memory', 'skill', 'persona', 'preset', 'scene'],
|
|
313
|
+
description: 'Which kind of item: memory | skill | persona | preset | scene. Their ids differ — '
|
|
314
|
+
+ 'memory is `<scene>/<name>`, the others are a plain name (a preset uses its id).',
|
|
315
|
+
},
|
|
316
|
+
id: {
|
|
317
|
+
type: 'string',
|
|
318
|
+
description: 'For trash: that item\'s id (`<scene>/<name>` for memory, a name for skill/persona/scene, '
|
|
319
|
+
+ 'the preset id for preset); for restore: a trash entry id from action=list for that domain; omit for list.',
|
|
320
|
+
},
|
|
289
321
|
scope: { type: 'string', enum: ['session', 'global'], description: REMOVE_SCOPE_DESC },
|
|
322
|
+
root: { type: 'string', description: 'Source root the skill lives in — skills only. Default: whichever source holds that skill; only used by action=trash.' },
|
|
290
323
|
},
|
|
291
324
|
output: { schema: { type: 'string' }, render: (_a, v) => text(String(v)) },
|
|
292
|
-
async execute(args, exec) {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
scope: { type: 'string', enum: ['session', 'global'], description: scopeGlobalOnlyDesc('a preset writes the one global baseline', 'there is nothing per-conversation to delete') },
|
|
301
|
-
},
|
|
302
|
-
output: { schema: { type: 'string' }, render: (_a, v) => text(String(v)) },
|
|
303
|
-
async execute(args, exec) { return runRemove(deps, promptCfg, args, exec && exec.agent, isMemoryId); },
|
|
304
|
-
}));
|
|
305
|
-
register(defineTool({
|
|
306
|
-
name: 'scene_manager_remove',
|
|
307
|
-
description: removeDescription('scene'),
|
|
308
|
-
parameters: {
|
|
309
|
-
action: { type: 'string', required: true, enum: ['trash', 'restore', 'list'], description: ACTION_DESC },
|
|
310
|
-
id: { type: 'string', description: 'For trash: the scene name; for restore: a trash entry id; omit for list.' },
|
|
311
|
-
scope: { type: 'string', enum: ['session', 'global'], description: REMOVE_SCOPE_DESC_SCENE },
|
|
325
|
+
async execute(args, exec) {
|
|
326
|
+
const domain = String((args && args.domain) || '').trim();
|
|
327
|
+
const cfg = cfgs[domain];
|
|
328
|
+
if (cfg === undefined) {
|
|
329
|
+
throw new Error('missing argument: domain — one of ' + Object.keys(cfgs).join(', ')
|
|
330
|
+
+ ' (which kind of item to trash, restore or list)');
|
|
331
|
+
}
|
|
332
|
+
return runRemove(deps, cfg, args, exec && exec.agent, isMemoryId);
|
|
312
333
|
},
|
|
313
|
-
output: { schema: { type: 'string' }, render: (_a, v) => text(String(v)) },
|
|
314
|
-
async execute(args, exec) { return runRemove(deps, sceneCfg, args, exec && exec.agent, isMemoryId); },
|
|
315
334
|
}));
|
|
316
335
|
}
|
package/lib/tools/scene.js
CHANGED
|
@@ -24,11 +24,20 @@
|
|
|
24
24
|
// 理由是"那是改运行时环境的动作";补上 `_switch` 的取舍记在 CHANGELOG 里 —— 要点是
|
|
25
25
|
// **场景段的动作句仍然不加回来**:「上下文注入只给现在是什么」是同一天定下的原则,
|
|
26
26
|
// 不因为多了一条工具就破例(工具描述本来就是写"什么时候该用它"的地方)。
|
|
27
|
-
import { candidateNote, effectiveScope, globalUnchangedNote, isolationOffNote, requireGlobalScope, scopeGlobalOnlyDesc, scopeOnlyNote, scopeSessionDesc, sessionLayerOn, sessionScopeOf, text, toolNameList } from './deps.js';
|
|
27
|
+
import { candidateNote, effectiveScope, globalUnchangedNote, isolationOffNote, requireGlobalScope, scopeGlobalOnlyDesc, scopeOnlyNote, scopeSessionDesc, sessionLayerOn, sessionScopeOf, text, toolAccessSentence, toolNameList } from './deps.js';
|
|
28
28
|
import { FACTORY_TOOL_TABLE_PRESET } from './table.js';
|
|
29
29
|
/** 档案里由模型设置的段(`memories` 段在 P5 已废弃,不再是档案的一部分)。
|
|
30
30
|
* `mcpNotes`与其余三段同族:整段替换、段缺席 = 不碰这一域。 */
|
|
31
31
|
const ARCHIVE_SECTIONS = ['mcp', 'mcpNotes', 'skills', 'subagents'];
|
|
32
|
+
/**
|
|
33
|
+
* 档案侧的**全部**入参(`scene_manager_archive` 那条工具的参数表)。
|
|
34
|
+
*
|
|
35
|
+
* 为什么要单独列一张:`scene_manager_save` 只管场景记录(名字 / 标签 / 说明 / 绑的预设),
|
|
36
|
+
* 档案段搬到了另一条工具。而宿主对**多出来的**参数不报错(schema 默认放行额外属性)——
|
|
37
|
+
* 模型照旧给 `_save` 传一个 `mcp` 时,不挡就是一次**静默失效**:回执说「已保存」,
|
|
38
|
+
* 而档案根本没写。所以 `_save` 见到这里任何一条都要当场说清它搬到了哪里。
|
|
39
|
+
*/
|
|
40
|
+
const ARCHIVE_PARAMS = ['mcp', 'mcpNotes', 'skills', 'subagents', 'quickPrompts', 'toolTablePreset'];
|
|
32
41
|
/** 段里的名单:数组段是名字列表,`mcp` 段是 serverName → `'*'` | 工具名数组。段缺席 = 空。 */
|
|
33
42
|
function segmentNames(value) {
|
|
34
43
|
if (Array.isArray(value))
|
|
@@ -260,7 +269,7 @@ export function buildSceneTools(deps) {
|
|
|
260
269
|
// 为什么 `action` 是必填枚举而不是一个布尔:与 `mcp_manager_switch` 同一条理由 ——
|
|
261
270
|
// 让模型在 enter / exit 两个动词里选一个,比让它猜"scene 传 null 是什么意思"省一次往返。
|
|
262
271
|
// 参数里刻意不出现 `null`:那是 op(`scene-mode-set`)的形态,模型照着填只会填错。
|
|
263
|
-
description: 'Enter a scene, or leave the one currently entered. Entering switches on its archive and everything else off, narrows injection to its memories, and applies its bound prompt preset to AGENTS.md. Leaving restores the runtime snapshot taken on entry. Only when the user asks or approves.',
|
|
272
|
+
description: 'Enter a scene, or leave the one currently entered. Entering switches on its archive and everything else off, narrows injection to its memories, and applies its bound prompt preset to AGENTS.md. Leaving restores the runtime snapshot taken on entry. Asks the user to confirm before it runs. Only when the user asks or approves.',
|
|
264
273
|
parameters: {
|
|
265
274
|
action: { type: 'string', required: true, enum: ['enter', 'exit'], description: 'enter = switch to the scene named in `scene`; exit = leave the current one (no scene needed).' },
|
|
266
275
|
scene: { type: 'string', description: 'Scene name (one path segment), required for enter — the exact name, not the display label.' },
|
|
@@ -395,9 +404,11 @@ export function buildSceneTools(deps) {
|
|
|
395
404
|
// 「写入指引」保留("写成指令而不是备注"—— 这是场景说明质量的杠杆),但不再声称
|
|
396
405
|
// "注入后模型会被要求照办":定稿把场景段的授权语删了(注入只陈述现状),
|
|
397
406
|
// 参数说明与注入侧各说各话时,模型信的那份是错的。改为如实说明去向。
|
|
398
|
-
//
|
|
399
|
-
// 这里只留参数表**答不了**的三件事 ——
|
|
400
|
-
|
|
407
|
+
// 描述不再逐项列举档案里有哪些段(档案段已经搬去 `scene_manager_archive`):
|
|
408
|
+
// 这里只留参数表**答不了**的三件事 —— 场景是什么、保存不等于进入、档案另有一条工具。
|
|
409
|
+
// 那条工具的名字**不点**(它在出厂默认名单里是关着的):静态文案点名一条模型手里
|
|
410
|
+
// 没有的工具只会让它白跑一趟(插件的既定纪律,见 `toolAccessSentence`)。
|
|
411
|
+
description: 'Save a scene — a named bundle the user enters: entering switches on exactly what its archive lists and everything else off. Creates it if absent. Sets the name, the display name, the description and the bound prompt preset; omitted fields keep their values. The archive (which MCP servers, skills and personas entering it switches on) is set by a separate tool — capture: true fills it from what is currently switched on. Saving does not enter it. Asks the user to confirm before it runs. Only on the user\'s instruction.',
|
|
401
412
|
parameters: {
|
|
402
413
|
scene: { type: 'string', required: true, description: 'Scene name (one path segment, ≤64 chars, no / \\ or < > : " | ? *, not `_shared`). Created if absent.' },
|
|
403
414
|
label: { type: 'string', description: 'Display name for this scene.' },
|
|
@@ -406,39 +417,13 @@ export function buildSceneTools(deps) {
|
|
|
406
417
|
// 界面 补了「无」这个选项,工具侧的空串语义要跟着说清,否则模型只知道
|
|
407
418
|
// 「省略 = 保持」,不知道还有一条「解绑」的路。
|
|
408
419
|
prompt: { type: 'string', description: 'Prompt preset id to bind; while this scene is on it is the global baseline. \'\' = bind none (this scene leaves AGENTS.md alone).' },
|
|
409
|
-
// 模型工具表方案绑定:界面早就能绑、档案里一直有这一栏,`_list` / `_switch` 也读它,
|
|
410
|
-
// 唯独 `_save` 写不了。'' = 解绑只能走
|
|
411
|
-
// `rules-update-scene` —— `scene-archive-save` 对载荷里**不带的栏**一律保留现值
|
|
412
|
-
// (archive-engine 的「不带 ≠ 解绑」),所以解绑与设置分成两条路,见 execute 的 ②。
|
|
413
|
-
// 哨兵 `factory-default` 与界面下拉同值(tools/table.ts 的 FACTORY_TOOL_TABLE_PRESET);
|
|
414
|
-
// 不存在的方案名由引擎按 stale 丢弃并在进入时报告,op 不硬拒(与悬空绑定同口径)。
|
|
415
|
-
toolTablePreset: { type: 'string', description: "Model tool-table scheme to bind while this scene is on. '' = unbind; 'factory-default' = the factory default; otherwise a saved scheme name. An unknown name is dropped and reported." },
|
|
416
|
-
// 快捷提示词绑定。段语义与上面三个档案段相反:**空数组是合法值**
|
|
417
|
-
// (进入后全部停用),不是"清除这一段"。本工具不提供解绑(界面可解)—— 与
|
|
418
|
-
// mcp / skills / subagents 三段没有解绑参数同一条口径。id 从场景清单里别的场景的
|
|
419
|
-
// 绑定、或用户口述里来;不存在的 id 被引擎丢弃并在回执报出来。
|
|
420
|
-
quickPrompts: { type: 'array', items: { type: 'string' }, description: 'Quick-prompt ids to switch on when this scene is entered; every other one goes off, and the pre-entry state is restored on exit. [] = all off on entry. Unknown ids are dropped and reported — copy them from the listing.' },
|
|
421
|
-
mcp: {
|
|
422
|
-
type: 'object',
|
|
423
|
-
// 官方要求对象类型**显式声明开放性**(`additionalProperties` 是必需字段,且只能是
|
|
424
|
-
// boolean)—— 嵌套对象不允许带 schema,所以值的形状(`'*'` 还是工具名数组)只能在
|
|
425
|
-
// 描述里说清。这不是偷懒:键是服务器名,本身是动态的。
|
|
426
|
-
additionalProperties: true,
|
|
427
|
-
description: "Archive: serverName -> '*' (whole server) or a list of tool names to leave on. {} = switch none on.",
|
|
428
|
-
},
|
|
429
|
-
// 场景级 MCP 备注覆盖:进入这个场景时用这份盖掉全局备注,退出时还原。
|
|
430
|
-
// 与 mcp 段同一句式(省略 = 保持;{} = 一个都不覆盖)—— 界面存档编辑器早就能改,
|
|
431
|
-
// `_list` 也显示它,`_save` 此前不接这一段。
|
|
432
|
-
mcpNotes: {
|
|
433
|
-
type: 'object',
|
|
434
|
-
additionalProperties: true,
|
|
435
|
-
description: "Archive: serverName -> note overriding that server's global note while this scene is on (back on exit). {} = drop all scene-level overrides.",
|
|
436
|
-
},
|
|
437
|
-
skills: { type: 'array', items: { type: 'string' }, description: 'Archive: skill keys `<root>/<name>` to switch on. [] = switch none on.' },
|
|
438
|
-
subagents: { type: 'array', items: { type: 'string' }, description: 'Archive: persona names to switch on. [] = switch none on.' },
|
|
439
420
|
// 场景记录与档案是**机器级**的,没有「本会话的一份」。这个参数只为一件事:
|
|
440
421
|
// 模型以为自己在改会话时,当场纠回来(见 deps.ts 的 requireGlobalScope)。
|
|
441
422
|
scope: { type: 'string', enum: ['session', 'global'], description: scopeGlobalOnlyDesc('the scene record and archive are machine-wide', 'entering a scene for one conversation is a switch action') },
|
|
423
|
+
// 「照现在的样子存」:档案的勾选集由当前生效状态算出来,不由模型逐项填。
|
|
424
|
+
// 模型填错一个键的后果是「进场景时把某个服务器 / 某条技能关掉了」—— 而那一段
|
|
425
|
+
// 本来就是机器能自己读出来的,用户说「存一下刚才那套」时也不该由模型转述现状。
|
|
426
|
+
capture: { type: 'boolean', description: 'Fill the archive from what is currently switched on (MCP servers and their tools, skills, personas, quick prompts) — the archive is otherwise set by a separate tool. Use it when the user says "save the current setup as a scene".' },
|
|
442
427
|
},
|
|
443
428
|
output: { schema: { type: 'string' }, render: (_a, v) => text(v) },
|
|
444
429
|
async execute(args, exec) {
|
|
@@ -455,10 +440,41 @@ export function buildSceneTools(deps) {
|
|
|
455
440
|
if (scene.indexOf('/') >= 0 || scene.indexOf('\\') >= 0) {
|
|
456
441
|
throw new Error('a scene name is a single path segment (no / or \\): ' + scene);
|
|
457
442
|
}
|
|
443
|
+
// 档案段搬走了,而宿主**不拦多出来的参数**(schema 默认放行额外属性):不挡就是
|
|
444
|
+
// 一次静默失效 —— 回执说「已保存」,档案根本没写。
|
|
445
|
+
const moved = ARCHIVE_PARAMS.filter((k) => args && args[k] !== undefined);
|
|
446
|
+
if (moved.length > 0) {
|
|
447
|
+
// 那条工具在出厂默认里是关着的,所以不点名、只给「怎么弄到它」—— 模型手里有
|
|
448
|
+
// 控制面工具时自己就能开(`toolAccessSentence` 的第二档),没有才让用户去面板。
|
|
449
|
+
throw new Error('this tool no longer takes ' + moved.join(' / ')
|
|
450
|
+
+ ' — the archive of a scene is set by a separate tool: '
|
|
451
|
+
+ toolAccessSentence(deps, 'scene_manager_archive', exec && exec.agent, 'the user has to open it in the panel') + '.');
|
|
452
|
+
}
|
|
453
|
+
// 「照现在的样子存」:档案的勾选集由**当前生效状态**算出来,不由模型逐项填。
|
|
454
|
+
// 这一支走 `scene-capture`(建场景 + 存档案同一件事),不走下面的 ① ——
|
|
455
|
+
// 档案由这条工具写,模型手填的那几段这里一概不接。
|
|
456
|
+
if (args && args.capture === true) {
|
|
457
|
+
if (deps.sceneCapture === undefined)
|
|
458
|
+
throw new Error('capturing the current setup is unavailable in this host');
|
|
459
|
+
const captured = await deps.sceneCapture({
|
|
460
|
+
name: scene,
|
|
461
|
+
...(args.label !== undefined ? { label: String(args.label) } : {}),
|
|
462
|
+
...(args.description !== undefined ? { description: String(args.description) } : {}),
|
|
463
|
+
});
|
|
464
|
+
if (!captured || captured.ok === false)
|
|
465
|
+
throw new Error((captured && captured.error) || 'failed to capture the current setup');
|
|
466
|
+
const summary = captured.summary || {};
|
|
467
|
+
const stale = Array.isArray(captured.stale) ? captured.stale : [];
|
|
468
|
+
return 'OK: scene "' + scene + '" saved from the current setup ('
|
|
469
|
+
+ (summary.mcp || 0) + ' MCP server(s), ' + (summary.skills || 0) + ' skill(s), '
|
|
470
|
+
+ (summary.subagents || 0) + ' persona(s), ' + (summary.quickPrompts || 0) + ' quick prompt(s)). '
|
|
471
|
+
+ 'Entering it will switch exactly those on and everything else off.'
|
|
472
|
+
+ (stale.length ? '\nWARN: dropped entries that no longer exist: ' + stale.join(', ') : '')
|
|
473
|
+
+ ' Saving does not enter it.';
|
|
474
|
+
}
|
|
458
475
|
// ① 场景记录:`rules-create-scene` 本身是**幂等 upsert**(已存在则更新描述/标签/绑定的
|
|
459
476
|
// 预设,不报错),所以不必先查再分建/改 —— 与记忆 save 的"有则改、无则建"同一口径。
|
|
460
|
-
// 总是调它:模型给 scene
|
|
461
|
-
// `scene-archive-save` 会以"场景不存在"拒绝。
|
|
477
|
+
// 总是调它:模型给 scene 而场景还不存在时,这一步把场景建出来。
|
|
462
478
|
const payload = { name: scene };
|
|
463
479
|
const touchedRecord = [];
|
|
464
480
|
if (args.label !== undefined) {
|
|
@@ -476,22 +492,119 @@ export function buildSceneTools(deps) {
|
|
|
476
492
|
const created = await deps.rulesOps['rules-create-scene'](payload);
|
|
477
493
|
if (!created || created.ok === false)
|
|
478
494
|
throw new Error((created && created.error) || 'failed to save the scene');
|
|
479
|
-
// ②
|
|
480
|
-
//
|
|
481
|
-
// 刚解掉的绑定又写回去 —— 所以解绑与设置分成两条路,合并前还要先摘掉刚解掉的键。
|
|
482
|
-
// · `prompt` 的 '' 此前也走不到实处 —— `rules-create-scene` 的 upsert 分支把空串
|
|
483
|
-
// 当"没给"(ops/scene-records.ts),旧绑定原样保留而回执报"已更新"。
|
|
484
|
-
// · `toolTablePreset` 的 '' 同解(那个 op 的更新分支认空串 = 解绑)。
|
|
495
|
+
// ② `prompt` 的解绑只能走 `rules-update-scene`:`rules-create-scene` 的 upsert 分支把
|
|
496
|
+
// 空串当"没给"(ops/scene-records.ts),旧绑定原样保留而回执报"已更新"。
|
|
485
497
|
const clearPrompt = args.prompt !== undefined && String(args.prompt).trim() === '';
|
|
498
|
+
let clearWarn = '';
|
|
499
|
+
if (clearPrompt) {
|
|
500
|
+
const u = await deps.rulesOps['rules-update-scene']({ name: scene, prompt: '' });
|
|
501
|
+
if (!u || u.ok === false) {
|
|
502
|
+
// 主路径已成功、解绑没写上:如实报,别让回执假装绑定已经没了。
|
|
503
|
+
clearWarn = '\nWARN: the unbind was not written (' + ((u && u.error) || 'unknown error') + '); the old binding still applies';
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
// 收敛提示:`rules-create-scene` 在"历史默认(全部启用)"状态下会把启用集合收窄成
|
|
507
|
+
// 单选(`collapseActiveForNewScene`)—— 那是一次**会改变运行时**的动作,必须说出来。
|
|
508
|
+
// 界面上同样如实报(`scenes.result.created.collapsed`)。
|
|
509
|
+
const collapsed = created.collapsedActive === true;
|
|
510
|
+
const parts = [touchedRecord.length ? 'scene record updated (' + touchedRecord.join(', ') + ')' : 'scene existence ensured'];
|
|
511
|
+
// 点名 scene_manager_switch 的那句按 toolAccessSentence 三档分叉(它在出厂默认
|
|
512
|
+
// 名单里就是关着的):部分启用(开 save 不开 switch)时落在中间档 ——
|
|
513
|
+
// 先用控制面工具把 switch 打开,两头都关才轮到"用户手动进"。与 mcp/skill 同一条纪律。
|
|
514
|
+
const enterHint = 'To take effect: '
|
|
515
|
+
+ toolAccessSentence(deps, 'scene_manager_switch', exec && exec.agent, 'the user has to enter this scene manually (scene_manager_switch is not available in this session)') + '.';
|
|
516
|
+
// 会话层:场景记录与档案是**机器级**的(一份索引 + 一份档案),本会话能改的
|
|
517
|
+
// 只有「这个对话用哪个场景」。不说清的话,模型会把「存好了」读成「只在这个对话里生效」。
|
|
518
|
+
const pinned = sessionScopeOf(deps, exec && exec.agent)?.scope?.scene;
|
|
519
|
+
const globalNote = pinned === undefined
|
|
520
|
+
? ''
|
|
521
|
+
: '\nnote: scenes are global (one record and one archive for the whole machine). The pin here only decides which scene this scope uses' +
|
|
522
|
+
' (currently "' + pinned + '"); ' + globalUnchangedNote(deps);
|
|
523
|
+
// 档案没动这句话**必须说**:模型是照着「建一个进场景时开 A 服务器的场景」来的,
|
|
524
|
+
// 而档案已经搬去另一条工具 —— 不说,它会以为整件事做完了。
|
|
525
|
+
// 给「怎么弄到那条工具」而不是只报错名:它在出厂默认里是关着的,但模型手里有控制面
|
|
526
|
+
// 工具(自己就能开),别把它推回面板。
|
|
527
|
+
const archiveNote = '\nThe archive (what entering this scene switches on) was not touched by this call — to set it: '
|
|
528
|
+
+ toolAccessSentence(deps, 'scene_manager_archive', exec && exec.agent, 'the user has to open it in the panel') + '.';
|
|
529
|
+
return 'OK: scene "' + scene + '" — ' + parts.join('; ') + clearWarn + globalNote + archiveNote +
|
|
530
|
+
(collapsed
|
|
531
|
+
? '\nnote: every scene was enabled until now (the historical all-enabled default); this call narrowed the enabled set to one scene, and the new one is not it — the user should confirm the enabled state.'
|
|
532
|
+
: '') +
|
|
533
|
+
'\nSaving does not change the runtime: ' + enterHint;
|
|
534
|
+
},
|
|
535
|
+
}));
|
|
536
|
+
register(defineTool({
|
|
537
|
+
name: 'scene_manager_archive',
|
|
538
|
+
// 档案 = 「进入这个场景时开什么」。它与场景记录(名字 / 标签 / 说明 / 绑的预设)是**两个
|
|
539
|
+
// 对象**,所以分成两条工具:只想改一句场景说明的模型不必面对五段档案参数,而要改档案的
|
|
540
|
+
// 那条路径参数表本身很宽 —— 拆开之后,**只想写场景**的那条工具窄了一半。
|
|
541
|
+
//
|
|
542
|
+
// 整段替换的语义写在这里(`_save` 那条已经不接档案段了):给的段整段替换,没给的段保持。
|
|
543
|
+
description: 'Set the archive of a scene — what entering it switches on: MCP servers (and which of their tools), skills, personas, quick prompts and the model tool-table scheme. A section you give replaces that section whole (include what should stay — the receipt reports what got displaced); sections you omit keep their values. Creates the scene if it does not exist yet. Saving the archive does not enter the scene. Asks the user to confirm before it runs. Only on the user\'s instruction.',
|
|
544
|
+
parameters: {
|
|
545
|
+
scene: { type: 'string', required: true, description: 'Scene name (one path segment, ≤64 chars, no / \\ or < > : " | ? *, not `_shared`).' },
|
|
546
|
+
mcp: {
|
|
547
|
+
type: 'object',
|
|
548
|
+
// 官方要求对象类型**显式声明开放性**(`additionalProperties` 是必需字段,且只能是
|
|
549
|
+
// boolean)—— 嵌套对象不允许带 schema,所以值的形状(`'*'` 还是工具名数组)只能在
|
|
550
|
+
// 描述里说清。这不是偷懒:键是服务器名,本身是动态的。
|
|
551
|
+
additionalProperties: true,
|
|
552
|
+
description: "Archive: serverName -> '*' (whole server) or a list of tool names to leave on. {} = switch none on.",
|
|
553
|
+
},
|
|
554
|
+
// 场景级 MCP 备注覆盖:进入这个场景时用这份盖掉全局备注,退出时还原。
|
|
555
|
+
// 与 mcp 段同一句式(省略 = 保持;{} = 一个都不覆盖)。
|
|
556
|
+
mcpNotes: {
|
|
557
|
+
type: 'object',
|
|
558
|
+
additionalProperties: true,
|
|
559
|
+
description: "Archive: serverName -> note overriding that server's global note while this scene is on (back on exit). {} = drop all scene-level overrides.",
|
|
560
|
+
},
|
|
561
|
+
skills: { type: 'array', items: { type: 'string' }, description: 'Archive: skill keys `<root>/<name>` to switch on. [] = switch none on.' },
|
|
562
|
+
subagents: { type: 'array', items: { type: 'string' }, description: 'Archive: persona names to switch on. [] = switch none on.' },
|
|
563
|
+
// 快捷提示词绑定。段语义与上面三个档案段相反:**空数组是合法值**
|
|
564
|
+
// (进入后全部停用),不是"清除这一段"。本工具不提供解绑(界面可解)—— 与
|
|
565
|
+
// mcp / skills / subagents 三段没有解绑参数同一条口径。id 从场景清单里别的场景的
|
|
566
|
+
// 绑定、或用户口述里来;不存在的 id 被引擎丢弃并在回执报出来。
|
|
567
|
+
quickPrompts: { type: 'array', items: { type: 'string' }, description: 'Quick-prompt ids to switch on when this scene is entered; every other one goes off, and the pre-entry state is restored on exit. [] = all off on entry. Unknown ids are dropped and reported — copy them from the listing.' },
|
|
568
|
+
// 模型工具表方案绑定:界面早就能绑、档案里一直有这一栏,`_list` / `_switch` 也读它。
|
|
569
|
+
// 哨兵 `factory-default` 与界面下拉同值(tools/table.ts 的 FACTORY_TOOL_TABLE_PRESET);
|
|
570
|
+
// 不存在的方案名由引擎按 stale 丢弃并在进入时报告,op 不硬拒(与悬空绑定同口径)。
|
|
571
|
+
toolTablePreset: { type: 'string', description: "Model tool-table scheme to bind while this scene is on. '' = unbind; 'factory-default' = the factory default; otherwise a saved scheme name. An unknown name is dropped and reported." },
|
|
572
|
+
// 档案与场景记录一样是**机器级**的(一份索引 + 一份档案),没有「本会话的一份」。
|
|
573
|
+
scope: { type: 'string', enum: ['session', 'global'], description: scopeGlobalOnlyDesc('the scene record and archive are machine-wide', 'entering a scene for one conversation is a switch action') },
|
|
574
|
+
},
|
|
575
|
+
output: { schema: { type: 'string' }, render: (_a, v) => text(v) },
|
|
576
|
+
async execute(args, exec) {
|
|
577
|
+
const blocked = await deps.lockedSceneGuard();
|
|
578
|
+
if (blocked)
|
|
579
|
+
throw new Error(blocked);
|
|
580
|
+
requireGlobalScope(args, 'scenes', !sessionLayerOn(deps));
|
|
581
|
+
const scene = String((args && args.scene) || '').trim();
|
|
582
|
+
if (scene === '')
|
|
583
|
+
throw new Error('missing argument: scene (the scene name)');
|
|
584
|
+
if (scene.indexOf('/') >= 0 || scene.indexOf('\\') >= 0) {
|
|
585
|
+
throw new Error('a scene name is a single path segment (no / or \\): ' + scene);
|
|
586
|
+
}
|
|
587
|
+
// 场景得先在(档案挂在场景上)。用 upsert 建出来:模型为了写档案先建一次场景是
|
|
588
|
+
// 一次白跑,而档案那条路自己建不出场景记录。
|
|
589
|
+
const ensured = await deps.rulesOps['rules-create-scene']({ name: scene });
|
|
590
|
+
if (!ensured || ensured.ok === false)
|
|
591
|
+
throw new Error((ensured && ensured.error) || 'failed to save the scene');
|
|
592
|
+
// 三种「设置」方向 + 一种「解绑」:
|
|
486
593
|
const unbindToolTable = args.toolTablePreset !== undefined && String(args.toolTablePreset).trim() === '';
|
|
487
594
|
const setToolTable = args.toolTablePreset !== undefined && String(args.toolTablePreset).trim() !== '';
|
|
488
595
|
const setQuickPrompts = args.quickPrompts !== undefined;
|
|
489
596
|
if (setQuickPrompts && !Array.isArray(args.quickPrompts)) {
|
|
490
|
-
|
|
597
|
+
// 档案里 quickPrompts 是一份**完整清单**(在里面的开着,不在里面的关着),
|
|
598
|
+
// 所以「改绑」是改这一份清单 —— 模型自己就能做,原先那句「解绑是面板里的人工步骤」
|
|
599
|
+
// 是错的(模型能存一份新清单)。
|
|
600
|
+
throw new Error('quickPrompts must be an array of ids ([] = turn them all off on entry; the binding is one full list, so to change which prompts are on, save this scene again with the new list)');
|
|
491
601
|
}
|
|
492
602
|
const touched = ARCHIVE_SECTIONS.filter((k) => args[k] !== undefined);
|
|
493
603
|
const mustWriteArchive = touched.length > 0 || setToolTable || setQuickPrompts;
|
|
494
|
-
|
|
604
|
+
if (!mustWriteArchive && !unbindToolTable) {
|
|
605
|
+
throw new Error('nothing to change: give at least one archive section (mcp / mcpNotes / skills / subagents / quickPrompts / toolTablePreset)');
|
|
606
|
+
}
|
|
607
|
+
// 档案现状在读的时候就取一次,且必须在解绑**之前** —— 解绑落盘后这一栏已经没了,
|
|
495
608
|
// 回执的「X → 解绑」要的是解绑前的那个 X。只为看回执的 diff 而读时(解绑且不写档案)
|
|
496
609
|
// 容忍读失败:那一步已经写成功了,别为一句对比话把整次调用判失败。
|
|
497
610
|
let before = {};
|
|
@@ -508,26 +621,20 @@ export function buildSceneTools(deps) {
|
|
|
508
621
|
}
|
|
509
622
|
}
|
|
510
623
|
let clearWarn = '';
|
|
511
|
-
if (
|
|
512
|
-
const
|
|
513
|
-
if (clearPrompt)
|
|
514
|
-
upd.prompt = '';
|
|
515
|
-
if (unbindToolTable)
|
|
516
|
-
upd.toolTablePreset = '';
|
|
517
|
-
const u = await deps.rulesOps['rules-update-scene'](upd);
|
|
624
|
+
if (unbindToolTable) {
|
|
625
|
+
const u = await deps.rulesOps['rules-update-scene']({ name: scene, toolTablePreset: '' });
|
|
518
626
|
if (!u || u.ok === false) {
|
|
519
|
-
// 主路径已成功、解绑没写上:如实报,别让回执假装绑定已经没了。
|
|
520
627
|
clearWarn = '\nWARN: the unbind was not written (' + ((u && u.error) || 'unknown error') + '); the old binding still applies';
|
|
521
628
|
}
|
|
522
629
|
}
|
|
523
|
-
//
|
|
524
|
-
//
|
|
525
|
-
//
|
|
526
|
-
//
|
|
527
|
-
//
|
|
528
|
-
//
|
|
529
|
-
//
|
|
530
|
-
//
|
|
630
|
+
// 档案 read-modify-write:段(mcp / mcpNotes / skills / subagents)与两个绑定栏的
|
|
631
|
+
// 「设置」方向合并成一份,只经 `scene-archive-save` 一条路落盘。
|
|
632
|
+
// **必须 read-modify-write**:`scene-archive-save` 是**整份替换**,只把模型给的段
|
|
633
|
+
// 传过去,没给的段会被静默清掉 —— 与 `subagent_manager_save` 省略字段被
|
|
634
|
+
// 清空同一形状,只是这次清掉的是"这个场景进入时要开哪些东西"。
|
|
635
|
+
// 注意段语义:**段不存在 = 不限制(全部照常)**,段存在但为空 = 全部停用。所以模型给
|
|
636
|
+
// `mcp: {}` 得到的是"全不勾",不是"清除该段" —— 后者只能靠不给。
|
|
637
|
+
// `quickPrompts` 与三段都不同:段缺席 = 这一域不碰,空数组 = 进入后全部停用。
|
|
531
638
|
let archiveNote = '';
|
|
532
639
|
let toolTableNote = '';
|
|
533
640
|
let quickNote = '';
|
|
@@ -564,7 +671,7 @@ export function buildSceneTools(deps) {
|
|
|
564
671
|
if (r.applyError)
|
|
565
672
|
warnTail += '\n(saved, but applying it to the runtime failed: ' + r.applyError + ')';
|
|
566
673
|
}
|
|
567
|
-
// 解绑写失败了就别输出「X → 解绑」—— 上面那句 WARN
|
|
674
|
+
// 解绑写失败了就别输出「X → 解绑」—— 上面那句 WARN 才是事实;设置方向不受影响。
|
|
568
675
|
if (args.toolTablePreset !== undefined && !(unbindToolTable && clearWarn !== '')) {
|
|
569
676
|
toolTableNote = beforeKnown
|
|
570
677
|
? 'tool-table preset: ' + (toolTableLabel(before.toolTablePreset) || 'unbound') + ' -> ' +
|
|
@@ -585,31 +692,27 @@ export function buildSceneTools(deps) {
|
|
|
585
692
|
(afterIds.length === 0 ? ' (all off after entering)' : '') +
|
|
586
693
|
(marks.length ? ' (' + marks.join(' ') + ')' : '');
|
|
587
694
|
}
|
|
588
|
-
|
|
589
|
-
// 单选(`collapseActiveForNewScene`)—— 那是一次**会改变运行时**的动作,必须说出来。
|
|
590
|
-
// 界面上同样如实报(`scenes.result.created.collapsed`)。
|
|
591
|
-
const collapsed = created.collapsedActive === true;
|
|
592
|
-
const parts = [touchedRecord.length ? 'scene record updated (' + touchedRecord.join(', ') + ')' : 'scene existence ensured'];
|
|
695
|
+
const parts = [];
|
|
593
696
|
if (archiveNote)
|
|
594
697
|
parts.push(archiveNote);
|
|
595
698
|
if (toolTableNote)
|
|
596
699
|
parts.push(toolTableNote);
|
|
597
700
|
if (quickNote)
|
|
598
701
|
parts.push(quickNote);
|
|
599
|
-
// 点名 scene_manager_switch
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
? 'To take effect, enter it with scene_manager_switch.'
|
|
604
|
-
: 'To take effect, the user has to enter this scene manually (scene_manager_switch is not available in this session).';
|
|
605
|
-
// 会话层:场景记录与档案是**机器级**的(一份索引 + 一份档案),本会话能改的
|
|
606
|
-
// 只有「这个对话用哪个场景」。不说清的话,模型会把「存好了」读成「只在这个对话里生效」。
|
|
702
|
+
// 点名 scene_manager_switch 的那句按 toolAccessSentence 三档分叉(与 _save 回执同款)。
|
|
703
|
+
const enterHint = 'To take effect: '
|
|
704
|
+
+ toolAccessSentence(deps, 'scene_manager_switch', exec && exec.agent, 'the user has to enter this scene manually (scene_manager_switch is not available in this session)') + '.';
|
|
705
|
+
// 会话层:档案是**机器级**的,本会话能改的只有「这个对话用哪个场景」。
|
|
607
706
|
const pinned = sessionScopeOf(deps, exec && exec.agent)?.scope?.scene;
|
|
608
707
|
const globalNote = pinned === undefined
|
|
609
708
|
? ''
|
|
610
709
|
: '\nnote: scenes are global (one record and one archive for the whole machine). The pin here only decides which scene this scope uses' +
|
|
611
710
|
' (currently "' + pinned + '"); ' + globalUnchangedNote(deps);
|
|
612
|
-
|
|
711
|
+
// 建场景时把启用集合收窄成单选(`collapseActiveForNewScene`)是一次**会改变运行时**
|
|
712
|
+
// 的动作,必须说出来 —— 那是 `rules-create-scene` 干的,与档案无关。
|
|
713
|
+
const collapsed = ensured.collapsedActive === true;
|
|
714
|
+
return 'OK: archive of scene "' + scene + '"' + (parts.length ? ' — ' + parts.join('; ') : '') +
|
|
715
|
+
warnTail + clearWarn + globalNote +
|
|
613
716
|
(collapsed
|
|
614
717
|
? '\nnote: every scene was enabled until now (the historical all-enabled default); this call narrowed the enabled set to one scene, and the new one is not it — the user should confirm the enabled state.'
|
|
615
718
|
: '') +
|