@morlay/session-mode 0.0.0-stage → 0.2.0-alpha.0
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/LICENSE +21 -0
- package/README.md +85 -2
- package/dist/endpoint.d.mts +2 -0
- package/dist/endpoint.mjs +3 -0
- package/dist/index.d.mts +691 -0
- package/dist/index.mjs +2350 -0
- package/dist/mode-config-BIYT66jI.mjs +22 -0
- package/dist/mode-config-rules-z4gdHLR1.mjs +52 -0
- package/dist/rolldown-runtime-3qf6kE1h.d.mts +1 -0
- package/dist/server.d.mts +2 -0
- package/dist/server.mjs +1 -0
- package/dist/session-mode-endpoint-CLpvSnzM.d.mts +120 -0
- package/dist/session-mode-endpoint-Dq-E_kHt.mjs +53 -0
- package/dist/session-mode-endpoint.service-Bn4EH6aB.d.mts +21 -0
- package/dist/session-mode-endpoint.service-MrqQipN6.mjs +79 -0
- package/dist/testing.d.mts +12 -0
- package/dist/testing.mjs +23 -0
- package/dist/ui.d.mts +125 -0
- package/dist/ui.mjs +1165 -0
- package/package.json +63 -3
- package/src/context-assembler.provide.ts +139 -0
- package/src/context-assembler.service.ts +67 -0
- package/src/contract/context-assembler.contract.ts +30 -0
- package/src/contract/index.ts +3 -0
- package/src/contract/session-mode.contract.ts +104 -0
- package/src/contract/session-scope.contract.ts +53 -0
- package/src/defaults.ts +39 -0
- package/src/endpoint/index.ts +6 -0
- package/src/endpoint/mode-config-rules.ts +59 -0
- package/src/endpoint/mode-config.ts +58 -0
- package/src/endpoint/session-mode-endpoint.ts +121 -0
- package/src/endpoint/session-mode-shapes.ts +71 -0
- package/src/endpoint/tool-group-ref.ts +11 -0
- package/src/events.ts +102 -0
- package/src/guidance/groups.ts +101 -0
- package/src/guidance/index.ts +4 -0
- package/src/guidance/packs/ask.ts +17 -0
- package/src/guidance/packs/code.ts +25 -0
- package/src/guidance/packs/fs.ts +60 -0
- package/src/guidance/packs/index.ts +52 -0
- package/src/guidance/packs/mcp.ts +25 -0
- package/src/guidance/packs/plan.ts +42 -0
- package/src/guidance/packs/shell.ts +45 -0
- package/src/guidance/packs/skill.ts +12 -0
- package/src/guidance/packs/swarm.ts +60 -0
- package/src/guidance/packs/web-access.ts +24 -0
- package/src/guidance/tool-groups.ts +72 -0
- package/src/guidance/types.ts +29 -0
- package/src/index.ts +63 -0
- package/src/mode-sources.ts +83 -0
- package/src/mode-store.ts +45 -0
- package/src/modes.ts +126 -0
- package/src/per-agent-rows.ts +62 -0
- package/src/per-agent.ts +36 -0
- package/src/persona.ts +30 -0
- package/src/ptc-describe.ts +136 -0
- package/src/ptc-sdk.ts +101 -0
- package/src/reminder.ts +89 -0
- package/src/rules.ts +8 -0
- package/src/server/index.ts +7 -0
- package/src/server/session-mode-endpoint.service.ts +117 -0
- package/src/session-mode-store.ts +218 -0
- package/src/session-mode.projection.ts +78 -0
- package/src/session-mode.provide.ts +38 -0
- package/src/session-mode.service.ts +670 -0
- package/src/session-scope.service.ts +515 -0
- package/src/subagent/delegation-context.ts +30 -0
- package/src/subagent/return-guidance.ts +56 -0
- package/src/subagent/subagent-guidance.service.ts +76 -0
- package/src/subagent.provide.ts +5 -0
- package/src/system-remainder.ts +43 -0
- package/src/testing/index.ts +34 -0
- package/src/tool-guidance.service.ts +265 -0
- package/src/ui/index.ts +12 -0
- package/src/ui/locales.ts +134 -0
- package/src/ui/session-mode-endpoint.client.ts +19 -0
- package/src/ui/session-mode-locales.contribution.ts +51 -0
- package/src/ui/session-mode-panel-tab.ts +39 -0
- package/src/ui/session-mode-panel.view.tsx +931 -0
- package/src/ui/session-mode-seat.view.tsx +174 -0
- package/src/ui/session-mode-slots.ts +13 -0
- package/src/ui/session-mode.provide.ts +24 -0
- package/src/ui/session-mode.store.ts +90 -0
- package/src/ui/use-roster.ts +24 -0
- package/src/ui/view-props.ts +19 -0
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
// 按**会话**收口:一份模式定义落成这个会话的工具面与几个抑制面。
|
|
2
|
+
//
|
|
3
|
+
// `apply` 落到这个 agent 身上四件事:工具面(`agent.ctx.tools.restrict`)、`tool:<工具名>` 说明 section、
|
|
4
|
+
// 执行层 guard(技能面),以及官方几条注入面(行级的 `agent/pre-step` 上按 agent 查表丢)。
|
|
5
|
+
// PTC 出现时(装配里有 PTC 执行器的专属 section)再把 `tools:sdk` 换成稳定骨架——判据是运行时事实。
|
|
6
|
+
import type { Agent } from "@morlay/dsh-agent/contract";
|
|
7
|
+
import { ToolRegistrations, ToolRegistry } from "@morlay/dsh-agent";
|
|
8
|
+
import type { MessageSource, UserMessage } from "@morlay/dsh-agent/contract";
|
|
9
|
+
import { Skill } from "@morlay/dsh-skill";
|
|
10
|
+
import { inject, Injectable, type Context, type OnInit } from "@morlay/zephyr";
|
|
11
|
+
import { ContextAssembler } from "./contract/context-assembler.contract.ts";
|
|
12
|
+
import {
|
|
13
|
+
SessionScope,
|
|
14
|
+
type ScopedToolEntry,
|
|
15
|
+
type SessionScopeAccount,
|
|
16
|
+
type SessionScopeDefinition,
|
|
17
|
+
} from "./contract/session-scope.contract.ts";
|
|
18
|
+
import {
|
|
19
|
+
AgentPreStep,
|
|
20
|
+
SystemPromptAssemble,
|
|
21
|
+
type PreStepDecision,
|
|
22
|
+
sourceKindOf,
|
|
23
|
+
} from "./events.ts";
|
|
24
|
+
import { groupDescriptorOf } from "./guidance/groups.ts";
|
|
25
|
+
import {
|
|
26
|
+
PTC_ONLY_SECTION,
|
|
27
|
+
groupRef,
|
|
28
|
+
groupTools,
|
|
29
|
+
isProtectedTool,
|
|
30
|
+
refGroup,
|
|
31
|
+
toolGroupOf,
|
|
32
|
+
} from "./guidance/tool-groups.ts";
|
|
33
|
+
import { perAgentAccount } from "./per-agent.ts";
|
|
34
|
+
import { projectToolSchema } from "@morlay/dsh-agent/contract";
|
|
35
|
+
import { describeToolDefinition, type DescribeEntry } from "./ptc-describe.ts";
|
|
36
|
+
import { ptcSections } from "./ptc-sdk.ts";
|
|
37
|
+
|
|
38
|
+
// 单个工具的说明 section 名前缀:`tool:<工具名>`(`tools:` 那类是聚合块,不归收口管)。
|
|
39
|
+
const TOOL_SECTION_PREFIX = "tool:";
|
|
40
|
+
|
|
41
|
+
// 归"动态快照"的两条平台说明 section(实现检出路径、Web GUI 朝向)。
|
|
42
|
+
const RUNTIME_SECTIONS: ReadonlySet<string> = new Set(["harness:source", "app:web-surface"]);
|
|
43
|
+
|
|
44
|
+
// 加载技能的那个官方工具名。
|
|
45
|
+
const SKILL_TOOL_NAME = "skill";
|
|
46
|
+
|
|
47
|
+
type Denial = "not-allowlisted" | "denylisted";
|
|
48
|
+
|
|
49
|
+
const SKILL_REFUSAL = (skill: string, mode: string, denial: Denial): string =>
|
|
50
|
+
denial === "denylisted"
|
|
51
|
+
? `${skill} 被「${mode}」的技能黑名单排除,加载它不会有结果;按当前模式可用的技能完成任务,或让用户切到别的模式。`
|
|
52
|
+
: `${skill} 不在「${mode}」的技能白名单里,加载它不会有结果;按当前模式可用的技能完成任务,或让用户切到别的模式。`;
|
|
53
|
+
|
|
54
|
+
// 一份**合成**出来的名单面:最终可用 = (白名单留空 ? 全部 : 白名单) − 黑名单。
|
|
55
|
+
interface NameGate {
|
|
56
|
+
readonly allow: ReadonlySet<string> | undefined;
|
|
57
|
+
readonly deny: ReadonlySet<string>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function gateOfNames(allow: readonly string[], deny: readonly string[]): NameGate | undefined {
|
|
61
|
+
const denied = new Set(deny);
|
|
62
|
+
const allowed = allow.length === 0 ? undefined : new Set(allow);
|
|
63
|
+
if (allowed === undefined && denied.size === 0) return undefined;
|
|
64
|
+
return { allow: allowed, deny: denied };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 判定一个名字:`undefined` = 放行,否则是被拒的原因(黑名单先判,于是 deny 优先)。
|
|
68
|
+
function denialOf(gate: NameGate, name: string): Denial | undefined {
|
|
69
|
+
if (gate.deny.has(name)) return "denylisted";
|
|
70
|
+
if (gate.allow !== undefined && !gate.allow.has(name)) return "not-allowlisted";
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 技能目录正文里的条目行:`- \`<技能名>\`: <说明>`(官方 `tool-skill` 的渲染形状)。
|
|
75
|
+
const CATALOG_LINE = /^- `([^`]+)`: /u;
|
|
76
|
+
|
|
77
|
+
// 按技能名单收窄一条 `skill-catalog` 正文:删掉被拒技能那几行,`source.entries` 不动
|
|
78
|
+
// (官方按那份结构化名单的 digest 判目录要不要重发,改了它会每一步都重发一条目录)。
|
|
79
|
+
function narrowCatalog(
|
|
80
|
+
message: UserMessage,
|
|
81
|
+
gate: NameGate,
|
|
82
|
+
warn: (line: string) => void,
|
|
83
|
+
): UserMessage | undefined {
|
|
84
|
+
const source = message.source as {
|
|
85
|
+
readonly entries?: readonly { readonly name: string }[];
|
|
86
|
+
};
|
|
87
|
+
const denied = new Set(
|
|
88
|
+
(source.entries ?? [])
|
|
89
|
+
.map((entry) => entry.name)
|
|
90
|
+
.filter((name) => denialOf(gate, name) !== undefined),
|
|
91
|
+
);
|
|
92
|
+
if (denied.size === 0) return undefined;
|
|
93
|
+
const [block, ...rest] = message.content;
|
|
94
|
+
if (block?.type !== "text" || rest.length > 0) {
|
|
95
|
+
warn(
|
|
96
|
+
`skill catalog message is not one text block; denied skills stay listed: ${[...denied].join(", ")}`,
|
|
97
|
+
);
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
const removed = new Set<string>();
|
|
101
|
+
const lines = block.text.split("\n").filter((line) => {
|
|
102
|
+
const match = CATALOG_LINE.exec(line);
|
|
103
|
+
if (match === null) return true;
|
|
104
|
+
const name = match[1] ?? "";
|
|
105
|
+
if (!denied.has(name)) return true;
|
|
106
|
+
removed.add(name);
|
|
107
|
+
return false;
|
|
108
|
+
});
|
|
109
|
+
const missing = [...denied].filter((name) => !removed.has(name));
|
|
110
|
+
if (missing.length > 0) {
|
|
111
|
+
warn(`skill catalog lines not recognized; denied skills stay listed: ${missing.join(", ")}`);
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
return { ...message, content: [{ ...block, text: lines.join("\n") }] };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// `skill` 工具调用的技能名:参数形状是官方那一行的 `{ name: string }`。
|
|
118
|
+
function skillNameOf(arguments_: unknown): string | undefined {
|
|
119
|
+
if (typeof arguments_ !== "object" || arguments_ === null) return undefined;
|
|
120
|
+
const name = (arguments_ as { readonly name?: unknown }).name;
|
|
121
|
+
return typeof name === "string" && name.length > 0 ? name : undefined;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 一个 agent 当前装着的那一份(行级订阅按它查表)。
|
|
125
|
+
interface Applied {
|
|
126
|
+
// 装配期过滤用的名单:按需组放行之后要跟着重算,所以不是只读。
|
|
127
|
+
gate: NameGate | undefined;
|
|
128
|
+
// 模式给的那份名单(不含按需组叠加):放行一组时用它重算 `gate`。
|
|
129
|
+
readonly baseGate: NameGate | undefined;
|
|
130
|
+
readonly skillGate: NameGate | undefined;
|
|
131
|
+
readonly definition: SessionScopeDefinition;
|
|
132
|
+
// 这个会话的 agent 作用域:放行一组时要在同一层重算收窄(不再二次做边界 cast)。
|
|
133
|
+
readonly scope: Context;
|
|
134
|
+
readonly known: readonly string[];
|
|
135
|
+
readonly dispose: () => void;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
interface ToolFace {
|
|
139
|
+
readonly known: readonly string[];
|
|
140
|
+
readonly baseDeny: ReadonlySet<string>;
|
|
141
|
+
readonly groups: ReadonlyMap<string, readonly string[]>;
|
|
142
|
+
disposeRestriction?: (() => void) | undefined;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@Injectable()
|
|
146
|
+
export class SessionScopeDefault extends SessionScope implements OnInit {
|
|
147
|
+
readonly assemble$ = new SystemPromptAssemble();
|
|
148
|
+
|
|
149
|
+
readonly preStep$ = new AgentPreStep();
|
|
150
|
+
|
|
151
|
+
private readonly tools = inject(ToolRegistry);
|
|
152
|
+
|
|
153
|
+
// 注册项的表(不是根注册表的条目):PTC 根下 `getAll()` 只有 `run_code`,枚举注册项只能读这一行。
|
|
154
|
+
private readonly registrations = inject(ToolRegistrations);
|
|
155
|
+
|
|
156
|
+
private readonly channel = inject(ContextAssembler);
|
|
157
|
+
|
|
158
|
+
private readonly skill = inject.optional(Skill);
|
|
159
|
+
|
|
160
|
+
private readonly applied = new WeakMap<Agent, Applied>();
|
|
161
|
+
|
|
162
|
+
private readonly activatedGroups = new WeakMap<Agent, Set<string>>();
|
|
163
|
+
|
|
164
|
+
private readonly faces = new WeakMap<Agent, ToolFace>();
|
|
165
|
+
|
|
166
|
+
private readonly catalogs = new WeakMap<Agent, readonly ScopedToolEntry[]>();
|
|
167
|
+
|
|
168
|
+
private row: Context | undefined;
|
|
169
|
+
|
|
170
|
+
onInit(ctx: Context): void {
|
|
171
|
+
this.row = ctx;
|
|
172
|
+
// 装配期过滤:只认已经 `apply` 过的会话(没装模式那层的部署一律放行)。
|
|
173
|
+
this.assemble$.onWaterfall(async (assembly, context, next) => {
|
|
174
|
+
const agent = context.agent as Agent | undefined;
|
|
175
|
+
const applied = agent === undefined ? undefined : this.applied.get(agent);
|
|
176
|
+
if (agent === undefined || applied === undefined) return next();
|
|
177
|
+
// PTC 的判据是**运行时事实**:这一刻选中的执行器是 PTC 执行器。
|
|
178
|
+
// 它的信号是它注册的专属 section(`tools:ptc-only`,只有它写这一条),模式配置说了不算。
|
|
179
|
+
//
|
|
180
|
+
// 为什么不用「可见工具里有 `run_code`」判:上游把 `run_code` 列为保留名(`tools` 的 `register` 与
|
|
181
|
+
// `restrict` 都对它抛错),本包再把 `run_code` / `describe_tool` 列进 PROTECTED_TOOLS 从 deny 集里摘掉
|
|
182
|
+
// ——它永远收不掉,两种判据不会分叉;而 section 是「执行器在场」的**唯一**可靠信号
|
|
183
|
+
// (PTC 的 transport 是执行器私有实例,不进注册表)。
|
|
184
|
+
// 骨架正文仍按可见工具现算(下一行的 `visibleTools`),所以正文跟着真实目录走。
|
|
185
|
+
const ptc = assembly.sections.some((section) => section.name === PTC_ONLY_SECTION);
|
|
186
|
+
const result = await next();
|
|
187
|
+
const sections = result.sections.filter((section) => this.keepSection(section.name, applied));
|
|
188
|
+
if (!ptc) return { ...result, sections };
|
|
189
|
+
return { ...result, sections: [...ptcSections(sections, this.visibleTools(agent))] };
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
account(agent: Agent): SessionScopeAccount {
|
|
194
|
+
const row = this.row;
|
|
195
|
+
if (row === undefined) throw new Error("session-mode: 收口在装配完成前被使用");
|
|
196
|
+
return perAgentAccount(row, agent);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
apply(agent: Agent, definition: SessionScopeDefinition): void {
|
|
200
|
+
const previous = this.applied.get(agent);
|
|
201
|
+
if (previous !== undefined) previous.dispose();
|
|
202
|
+
const gate = gateOfNames(definition.allowTools, definition.denyTools);
|
|
203
|
+
const skillGate = gateOfNames(definition.allowSkills, definition.denySkills);
|
|
204
|
+
const scope = agent.ctx as unknown as Context;
|
|
205
|
+
const account = this.account(agent);
|
|
206
|
+
if (!definition.runtimeContext) {
|
|
207
|
+
account.add(scope.systemPrompt.suppressRuntimeContext());
|
|
208
|
+
}
|
|
209
|
+
const definitions = this.registrations.getAll(agent);
|
|
210
|
+
const known = definitions.map((tool) => tool.name);
|
|
211
|
+
this.catalogs.set(
|
|
212
|
+
agent,
|
|
213
|
+
definitions.map((tool) => ({ name: tool.name, description: tool.description ?? "" })),
|
|
214
|
+
);
|
|
215
|
+
// 按需组默认不可见:设了白名单的模式不做按需(那些模式的意图本来就是"只留这几件")。
|
|
216
|
+
const groups =
|
|
217
|
+
gate === undefined || gate.allow === undefined
|
|
218
|
+
? groupTools(known)
|
|
219
|
+
: new Map<string, string[]>();
|
|
220
|
+
const activated = this.activatedGroups.get(agent) ?? new Set<string>();
|
|
221
|
+
this.activatedGroups.set(agent, activated);
|
|
222
|
+
const face: ToolFace = { known, baseDeny: new Set(definition.denyTools), groups };
|
|
223
|
+
this.faces.set(agent, face);
|
|
224
|
+
// 收窄句柄也记在这条账上:换模式 / 行重挂时旧的那份必须被抬起来,否则第二次 `apply` 读到的是
|
|
225
|
+
// **已被上一次收窄过的** `definitions(agent)`,白名单里的名字会凭空消失(上一份 deny 永远留着)。
|
|
226
|
+
account.add(() => {
|
|
227
|
+
face.disposeRestriction?.();
|
|
228
|
+
face.disposeRestriction = undefined;
|
|
229
|
+
});
|
|
230
|
+
// `describe_tool` 常驻:PTC 程序里随时取某一组的 d.ts。
|
|
231
|
+
//
|
|
232
|
+
// 注册无条件(不判 PTC 是否生效):非 PTC 装配下模型看不到它(模型面由执行器的 `describe()` 决定),
|
|
233
|
+
// 而白名单模式要能点名「允许」它——判据与源包一致。
|
|
234
|
+
account.add(
|
|
235
|
+
scope.tools.register(
|
|
236
|
+
describeToolDefinition({
|
|
237
|
+
entries: () => this.describeEntriesOf(agent),
|
|
238
|
+
sectionOf: (name) => this.sectionTextOf(agent, name),
|
|
239
|
+
// 组正文按**这个会话此刻可见的工具**过滤:组里写了没装的行(上游已改名/已移除的工具)不注入。
|
|
240
|
+
groupOf: (key) =>
|
|
241
|
+
groupDescriptorOf(key, (tool) => this.tools.get(tool, agent as never) !== undefined),
|
|
242
|
+
onDescribe: (group) => {
|
|
243
|
+
this.activateGroup(agent, group);
|
|
244
|
+
},
|
|
245
|
+
}) as never,
|
|
246
|
+
) as unknown as () => void,
|
|
247
|
+
);
|
|
248
|
+
this.restrict(scope, gate, face, activated);
|
|
249
|
+
if (skillGate !== undefined) {
|
|
250
|
+
account.add(
|
|
251
|
+
scope.tools.guard((exec) => {
|
|
252
|
+
if (exec.name !== SKILL_TOOL_NAME) return undefined;
|
|
253
|
+
const skillName = skillNameOf(exec.arguments);
|
|
254
|
+
if (skillName === undefined) return undefined;
|
|
255
|
+
const skillDenial = denialOf(skillGate, skillName);
|
|
256
|
+
return skillDenial === undefined
|
|
257
|
+
? undefined
|
|
258
|
+
: SKILL_REFUSAL(skillName, definition.name, skillDenial);
|
|
259
|
+
}) as unknown as () => void,
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
this.channel.setInstructions(agent, definition.instructions);
|
|
263
|
+
// 官方几条注入面(`agent-instructions` / `skill-catalog` / `time-context`)由各自的官方行在**装配投影之外**
|
|
264
|
+
// 往瀑布里 append,只能在瀑布上丢。顺序是判据:那些行随 preset 挂在 `agent.ctx` 上、早于本注册,所以
|
|
265
|
+
// 我们的过滤必须是**最外层**(`prepend`)才看得到它们 append 的那些消息。
|
|
266
|
+
account.add(
|
|
267
|
+
scope.on(
|
|
268
|
+
"agent/pre-step",
|
|
269
|
+
async (_payload: unknown, next: () => Promise<PreStepDecision>) => {
|
|
270
|
+
const decision = await next();
|
|
271
|
+
if (decision.kind !== "enter") return decision;
|
|
272
|
+
const current = this.applied.get(agent);
|
|
273
|
+
if (current === undefined) return decision;
|
|
274
|
+
const kept = this.suppress(decision.messages, current);
|
|
275
|
+
return kept === undefined ? decision : { ...decision, messages: kept };
|
|
276
|
+
},
|
|
277
|
+
{ prepend: true },
|
|
278
|
+
) as unknown as () => void,
|
|
279
|
+
);
|
|
280
|
+
// 装配期过滤用的 gate 要**含按需组**:那些组的工具不进目录,它们的说明 section 也不该留在提示词里。
|
|
281
|
+
// `restrict` 那一侧按同一份 `face.groups` 判,两处同源。
|
|
282
|
+
this.applied.set(agent, {
|
|
283
|
+
gate: this.gateWithOnDemand(gate, face, activated),
|
|
284
|
+
baseGate: gate,
|
|
285
|
+
skillGate,
|
|
286
|
+
definition,
|
|
287
|
+
scope,
|
|
288
|
+
known,
|
|
289
|
+
dispose: () => account.release(),
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// 在名单之上再叠一层「按需组还没放行」:没放行的组里每一件工具都等价于进黑名单。
|
|
294
|
+
private gateWithOnDemand(
|
|
295
|
+
gate: NameGate | undefined,
|
|
296
|
+
face: ToolFace,
|
|
297
|
+
activated: ReadonlySet<string>,
|
|
298
|
+
): NameGate | undefined {
|
|
299
|
+
const denied = new Set(gate?.deny ?? []);
|
|
300
|
+
for (const [group, tools] of face.groups) {
|
|
301
|
+
if (activated.has(group)) continue;
|
|
302
|
+
for (const tool of tools) denied.add(tool);
|
|
303
|
+
}
|
|
304
|
+
if (gate?.allow === undefined && denied.size === 0) return undefined;
|
|
305
|
+
return { allow: gate?.allow, deny: denied };
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// `describe_tool` 要的那个快照:每条工具的 name / description / 参数与输出 schema。
|
|
309
|
+
//
|
|
310
|
+
// 读**收窄前**的全集(`definitions()`,不是 `definitions(agent)`):按需组的工具默认不在目录里、
|
|
311
|
+
// 被收口挡住,而 describe 正是模型发现它们的手段——判据与源包一致(收口是执行面,describe 是发现面)。
|
|
312
|
+
// 每次调用现算(不缓存):工具集随按需组与晚注册变化,缓存会把新组的签名漏掉。
|
|
313
|
+
private describeEntriesOf(_agent: Agent): readonly DescribeEntry[] {
|
|
314
|
+
return this.registrations.getAll().map((tool) => ({
|
|
315
|
+
name: tool.name,
|
|
316
|
+
description: tool.description ?? "",
|
|
317
|
+
// `definition.parameters` 是 schemastery 形状;`projectToolSchema` 给出 JSON Schema,
|
|
318
|
+
// 才能转成真实的 TS 参数类型(而不是 `JsonValue`)。
|
|
319
|
+
parametersSchema: projectToolSchema(tool, false).parameters,
|
|
320
|
+
outputSchema: tool.output?.schema,
|
|
321
|
+
}));
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// 某个工具的说明 section 正文(`tool:<name>`):随 describe 一起返回,不占 system。
|
|
325
|
+
private sectionTextOf(agent: Agent, name: string): string | undefined {
|
|
326
|
+
const prompt = (
|
|
327
|
+
agent.ctx as unknown as {
|
|
328
|
+
systemPrompt?: { sections?: { get(key: string): { text?: unknown } | undefined } };
|
|
329
|
+
}
|
|
330
|
+
).systemPrompt;
|
|
331
|
+
const section = prompt?.sections?.get(`tool:${name}`);
|
|
332
|
+
return typeof section?.text === "string" ? section.text : undefined;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
knownTools(agent: Agent): readonly string[] {
|
|
336
|
+
const applied = this.applied.get(agent);
|
|
337
|
+
if (applied === undefined) return [];
|
|
338
|
+
const names = this.registrations.getAll(agent).map((tool) => tool.name);
|
|
339
|
+
return applied.gate === undefined
|
|
340
|
+
? names
|
|
341
|
+
: names.filter((tool) => denialOf(applied.gate as NameGate, tool) === undefined);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
catalogOf(agent: Agent): readonly ScopedToolEntry[] {
|
|
345
|
+
return this.catalogs.get(agent) ?? [];
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
async skillCatalog(agent: Agent): Promise<readonly ScopedToolEntry[]> {
|
|
349
|
+
const skill = this.skill;
|
|
350
|
+
if (skill === undefined) return [];
|
|
351
|
+
const cwd = (agent.session.header as { cwd?: unknown } | undefined)?.cwd;
|
|
352
|
+
const rows = await skill
|
|
353
|
+
.list({ scope: agent, ...(typeof cwd === "string" ? { cwd } : {}) })
|
|
354
|
+
.catch(() => [] as readonly { name: string; description: string }[]);
|
|
355
|
+
return rows.map((row) => ({ name: row.name, description: row.description }));
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// 这个会话的程序能绑到的工具名:注册项在这一层的可见集(收窄之后),不含根注册表的选择。
|
|
359
|
+
// 上游 0.2.3-alpha.3 起装配上下文不再带 `toolSet`,而 PTC 根 `getAll()` 只有 `run_code` 一条,
|
|
360
|
+
// 所以这里读注册项表——它正是 PTC 程序绑定的来源。
|
|
361
|
+
private visibleTools(agent: Agent): string[] {
|
|
362
|
+
return this.registrations.getAll(agent).map((tool) => tool.name);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// 一条 section 要不要留在提示词里。
|
|
366
|
+
private keepSection(name: string, applied: Applied): boolean {
|
|
367
|
+
if (!applied.definition.runtimeContext && RUNTIME_SECTIONS.has(name)) return false;
|
|
368
|
+
if (
|
|
369
|
+
applied.definition.dropSections.some((pattern) =>
|
|
370
|
+
pattern.endsWith("*") ? name.startsWith(pattern.slice(0, -1)) : name === pattern,
|
|
371
|
+
)
|
|
372
|
+
) {
|
|
373
|
+
return false;
|
|
374
|
+
}
|
|
375
|
+
const gate = applied.gate;
|
|
376
|
+
if (gate === undefined) return true;
|
|
377
|
+
// 工具自己的说明 section 与工具目录同源。
|
|
378
|
+
if (name.startsWith(TOOL_SECTION_PREFIX)) {
|
|
379
|
+
return denialOf(gate, name.slice(TOOL_SECTION_PREFIX.length)) === undefined;
|
|
380
|
+
}
|
|
381
|
+
// MCP server 的指令是一条 `mcp:<server>` section:整组工具都不可见时它也不该留着。
|
|
382
|
+
if (name.startsWith("mcp:")) {
|
|
383
|
+
const server = name.slice("mcp:".length);
|
|
384
|
+
return applied.known.some(
|
|
385
|
+
(tool) => tool.startsWith(`mcp__${server}__`) && denialOf(gate, tool) === undefined,
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// `describe_tool` 取到某一组就把它放行:按需组默认被 `gateWithOnDemand` 挡在目录外,
|
|
392
|
+
// 「发现面」放行了而「执行面」没跟上,模型就拿到签名也调不到(`tools.subagent is not a function`)。
|
|
393
|
+
// 本次程序里的绑定表在开跑前已经构造好,放行从下一次 `run_code` 起生效。
|
|
394
|
+
private activateGroup(agent: Agent, group: string): void {
|
|
395
|
+
const applied = this.applied.get(agent);
|
|
396
|
+
const face = this.faces.get(agent);
|
|
397
|
+
const activated = this.activatedGroups.get(agent);
|
|
398
|
+
if (applied === undefined || face === undefined || activated === undefined) return;
|
|
399
|
+
const ref = groupRef(group);
|
|
400
|
+
if (!face.groups.has(ref) || activated.has(ref)) return;
|
|
401
|
+
activated.add(ref);
|
|
402
|
+
applied.gate = this.gateWithOnDemand(applied.baseGate, face, activated);
|
|
403
|
+
this.restrict(applied.scope, applied.baseGate, face, activated);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// 按当前已放行的组重算工具面:模式白名单与基础黑名单原样,未放行那一组的工具进 deny。
|
|
407
|
+
//
|
|
408
|
+
// **必须经 agent 作用域的 tools 调**:上游 `restrict()` 读的是服务实例自己的 ctx(`scopeOf(this.ctx)`),
|
|
409
|
+
// 行级的 tools 是全局作用域,调用会抛 `requires a scoped context` ——被下面的降级 catch 吞掉之后表现为
|
|
410
|
+
// 「名单写了但工具面没变」。
|
|
411
|
+
private restrict(
|
|
412
|
+
scope: Context,
|
|
413
|
+
gate: NameGate | undefined,
|
|
414
|
+
face: ToolFace,
|
|
415
|
+
activated: ReadonlySet<string>,
|
|
416
|
+
): void {
|
|
417
|
+
face.disposeRestriction?.();
|
|
418
|
+
face.disposeRestriction = undefined;
|
|
419
|
+
const denied = new Set<string>();
|
|
420
|
+
for (const ref of face.baseDeny) {
|
|
421
|
+
if (ref.startsWith("group:") || ref.startsWith("mcp:")) {
|
|
422
|
+
const group = refGroup(ref);
|
|
423
|
+
for (const tool of face.known) if (toolGroupOf(tool) === group) denied.add(tool);
|
|
424
|
+
} else {
|
|
425
|
+
denied.add(ref);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
for (const [group, tools] of face.groups) {
|
|
429
|
+
if (activated.has(group)) continue;
|
|
430
|
+
for (const tool of tools) denied.add(tool);
|
|
431
|
+
}
|
|
432
|
+
for (const tool of denied) {
|
|
433
|
+
if (isProtectedTool(tool)) denied.delete(tool);
|
|
434
|
+
}
|
|
435
|
+
if (gate?.allow === undefined && denied.size === 0) return;
|
|
436
|
+
const known = new Set(face.known);
|
|
437
|
+
const allow =
|
|
438
|
+
gate?.allow === undefined
|
|
439
|
+
? undefined
|
|
440
|
+
: [...gate.allow, ...[...known].filter((tool) => isProtectedTool(tool))].filter((tool) =>
|
|
441
|
+
known.has(tool),
|
|
442
|
+
);
|
|
443
|
+
const denyList = [...denied].filter((tool) => known.has(tool));
|
|
444
|
+
face.disposeRestriction = this.installRestriction(scope, allow, denyList);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// `tools.restrict` 只认**全局**工具名;名单里出现 agent 自己注册的名字时降级成"只按全局视图里有的名字"再试。
|
|
448
|
+
private installRestriction(
|
|
449
|
+
scope: Context,
|
|
450
|
+
allow: readonly string[] | undefined,
|
|
451
|
+
deny: readonly string[],
|
|
452
|
+
): (() => void) | undefined {
|
|
453
|
+
const attempt = (
|
|
454
|
+
nextAllow: readonly string[] | undefined,
|
|
455
|
+
nextDeny: readonly string[],
|
|
456
|
+
): (() => void) | undefined => {
|
|
457
|
+
if (nextAllow === undefined && nextDeny.length === 0) return undefined;
|
|
458
|
+
try {
|
|
459
|
+
return scope.tools.restrict({
|
|
460
|
+
...(nextAllow === undefined ? {} : { allow: [...nextAllow] }),
|
|
461
|
+
...(nextDeny.length === 0 ? {} : { deny: [...nextDeny] }),
|
|
462
|
+
});
|
|
463
|
+
} catch {
|
|
464
|
+
// 收窄是增强,不该让整行装配失败;降级到下一档再试。
|
|
465
|
+
return undefined;
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
const first = attempt(allow, deny);
|
|
469
|
+
if (first !== undefined || (allow === undefined && deny.length === 0)) return first;
|
|
470
|
+
const global = new Set(this.registrations.getAll().map((tool) => tool.name));
|
|
471
|
+
return attempt(
|
|
472
|
+
allow === undefined ? undefined : allow.filter((name) => global.has(name)),
|
|
473
|
+
deny.filter((name) => global.has(name)),
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// 官方几条注入面按这份定义过一遍本步的消息表:`undefined` = 一条都不动。
|
|
478
|
+
private suppress(messages: readonly UserMessage[], applied: Applied): UserMessage[] | undefined {
|
|
479
|
+
let changed = false;
|
|
480
|
+
const kept: UserMessage[] = [];
|
|
481
|
+
for (const message of messages) {
|
|
482
|
+
const kind = sourceKindOf(message.source as MessageSource);
|
|
483
|
+
if (kind === "agent-instructions") {
|
|
484
|
+
if (applied.definition.instructions) kept.push(message);
|
|
485
|
+
else changed = true;
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
if (kind === "skill-catalog") {
|
|
489
|
+
if (!applied.definition.skills) {
|
|
490
|
+
changed = true;
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
const narrow =
|
|
494
|
+
applied.skillGate === undefined
|
|
495
|
+
? undefined
|
|
496
|
+
: narrowCatalog(message, applied.skillGate, (line) =>
|
|
497
|
+
this.row?.logger.warn(`session-mode: ${line}`),
|
|
498
|
+
);
|
|
499
|
+
if (narrow === undefined) kept.push(message);
|
|
500
|
+
else {
|
|
501
|
+
changed = true;
|
|
502
|
+
kept.push(narrow);
|
|
503
|
+
}
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
if (kind === "time-context") {
|
|
507
|
+
if (applied.definition.runtimeContext) kept.push(message);
|
|
508
|
+
else changed = true;
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
kept.push(message);
|
|
512
|
+
}
|
|
513
|
+
return changed ? kept : undefined;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// 委派范围说明(运行时上下文 `subagent:delegation`)的中文那条。
|
|
2
|
+
//
|
|
3
|
+
// 上游把它注册在**子代理自己的 agent 作用域**上,同层重复注册同名 context 会抛错
|
|
4
|
+
// (`NamedEntries.insert`),所以改的是装配结果:`system-prompt/assemble` 瀑布里换文本,
|
|
5
|
+
// 只对子代理的装配动手,且在该次装配内生效。
|
|
6
|
+
import type { Agent } from "@morlay/dsh-agent/contract";
|
|
7
|
+
import type { AssembledContext } from "@morlay/dsh-agent/contract";
|
|
8
|
+
|
|
9
|
+
// 上游注册的上下文名:同名才叫接管。
|
|
10
|
+
export const DELEGATION_CONTEXT_NAME = "subagent:delegation";
|
|
11
|
+
|
|
12
|
+
// 中文那条:权限在创建时固定、需要审批的操作一律被拒,超出范围时说明限制而不是重试。
|
|
13
|
+
export const DELEGATION_CONTEXT_TEXT =
|
|
14
|
+
"你是被派发的子代理:权限范围在创建时就固定,本会话内不能放宽——需要审批的操作一律被自动拒绝。\n" +
|
|
15
|
+
"任务需要超出这个范围时不要重试被拒的操作,在回复里说明这个限制,让派发你的智能体处理。";
|
|
16
|
+
|
|
17
|
+
// 这次装配是不是子代理的:判据是 `origin`。
|
|
18
|
+
//
|
|
19
|
+
// 不用 `parentSession`:它记的是「谁创建了这个会话」,普通 fork 也可能带着它(历史 fork 就带着),
|
|
20
|
+
// 拿它分类会把 fork 出来的会话当成派发的子代理。上游的判据是 `origin === 'subagent'`。
|
|
21
|
+
export function isDelegatedAgent(agent: Agent | undefined): boolean {
|
|
22
|
+
return agent?.session.header.origin === "subagent";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 一条上下文条目要不要换成中文:名字对上才换,其余原样。
|
|
26
|
+
export function rewordedContext(entry: AssembledContext): AssembledContext {
|
|
27
|
+
return entry.name === DELEGATION_CONTEXT_NAME
|
|
28
|
+
? { ...entry, text: DELEGATION_CONTEXT_TEXT }
|
|
29
|
+
: entry;
|
|
30
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// 回报指引:中文那份是本部署的默认,名单配了才收窄到指定 preset。
|
|
2
|
+
//
|
|
3
|
+
// 上游把这段英文文案写在它自己的 `manager.ts` 里、没有替换面;本包不 fork 那 2000 多行,
|
|
4
|
+
// 改的是**装配结果**——`agent/pre-step` 上把已认领的那条消息里的英文块换成中文
|
|
5
|
+
// (判据见 `packages/agent-ex/session-mode/.agents/designs/20261106-subagent接管面只搬两处文案.md`)。
|
|
6
|
+
import type { ContentBlock } from "@morlay/dsh-agent/contract";
|
|
7
|
+
|
|
8
|
+
// 上游英文指引的起始句:认不出就不动(宁可留英文,也不要注错父 id)。
|
|
9
|
+
const UPSTREAM_OPENING = "Your parent agent id is ";
|
|
10
|
+
|
|
11
|
+
// 起始句之后是父 id 的 JSON 字面量(品牌类型就是字符串,转义形态只有这一种)。
|
|
12
|
+
const UPSTREAM_PARENT = /^"((?:[^"\\]|\\.)*)"/u;
|
|
13
|
+
|
|
14
|
+
// 这个会话要不要用中文那份:名单留空 = 任意会话都用,配了才反过来收窄。
|
|
15
|
+
// 入参是本部署那个 preset id(`Config.preset`,默认 `"ptc"`)——本部署没有 roster,没有"组合出来的 preset"。
|
|
16
|
+
export function localizedGuidanceApplies(
|
|
17
|
+
preset: string | undefined,
|
|
18
|
+
configured: readonly string[],
|
|
19
|
+
): boolean {
|
|
20
|
+
if (configured.length === 0) return true;
|
|
21
|
+
return preset !== undefined && configured.includes(preset);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 中文回报指引:父 id、用什么回报、父看不到什么、回报不结束回合。
|
|
25
|
+
export function localizedReturnGuidanceText(parentId: string): string {
|
|
26
|
+
const encodedParentId = JSON.stringify(parentId);
|
|
27
|
+
return (
|
|
28
|
+
`你的父智能体 id 是 ${encodedParentId}。完成前用 send_message({ agent_id: ${encodedParentId}, ` +
|
|
29
|
+
'message: "<自包含的结论>" }) 把结果发给它。父智能体与你共享工作区,但不会自动收到你的对话、' +
|
|
30
|
+
"工具输出与推理过程。发现会改变父智能体下一步行动的事情时也尽早再发一条;发消息不会结束你的回合。"
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 把一块上游英文指引换成中文;不是那条就给 `undefined`(调用方据此判定"这条别动")。
|
|
35
|
+
export function rewordReturnGuidance(text: string): string | undefined {
|
|
36
|
+
if (!text.startsWith(UPSTREAM_OPENING)) return undefined;
|
|
37
|
+
const encoded = UPSTREAM_PARENT.exec(text.slice(UPSTREAM_OPENING.length))?.[1];
|
|
38
|
+
if (encoded === undefined) return undefined;
|
|
39
|
+
const parentId = JSON.parse(`"${encoded}"`) as unknown;
|
|
40
|
+
return typeof parentId === "string" ? localizedReturnGuidanceText(parentId) : undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// 一条消息的正文里那块英文指引换掉;没命中就给 `undefined`(消息原样保留)。
|
|
44
|
+
export function rewordGuidanceContent(
|
|
45
|
+
content: readonly ContentBlock[],
|
|
46
|
+
): ContentBlock[] | undefined {
|
|
47
|
+
let changed = false;
|
|
48
|
+
const blocks = content.map((block) => {
|
|
49
|
+
if (block.type !== "text") return block;
|
|
50
|
+
const text = rewordReturnGuidance(block.text);
|
|
51
|
+
if (text === undefined) return block;
|
|
52
|
+
changed = true;
|
|
53
|
+
return { ...block, text };
|
|
54
|
+
});
|
|
55
|
+
return changed ? blocks : undefined;
|
|
56
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// 子代理两处文案的接管行:都改**装配结果**,不 fork 上游实现。
|
|
2
|
+
//
|
|
3
|
+
// - 回报指引:`agent/pre-step` 上把已认领消息里那块上游英文换成中文;
|
|
4
|
+
// - 委派范围说明:`system-prompt/assemble` 上把 `subagent:delegation` 那条上下文换成中文。
|
|
5
|
+
//
|
|
6
|
+
// 判据与理由见 `packages/agent-ex/session-mode/.agents/designs/20261106-subagent接管面只搬两处文案.md`。
|
|
7
|
+
import { Injectable, type OnInit } from "@morlay/zephyr";
|
|
8
|
+
import { AgentPreStep, SystemPromptAssemble } from "../events.ts";
|
|
9
|
+
import { DEFAULT_PRESET } from "../session-mode.service.ts";
|
|
10
|
+
import { isDelegatedAgent, rewordedContext } from "./delegation-context.ts";
|
|
11
|
+
import { localizedGuidanceApplies, rewordGuidanceContent } from "./return-guidance.ts";
|
|
12
|
+
|
|
13
|
+
// 装配面配置:中文回报指引限定在哪些 preset 里(留空 = 不限),以及本部署那一个 preset id。
|
|
14
|
+
//
|
|
15
|
+
// `preset` 与 `SessionModeDefault` 的同一个字段默认值一致:本部署只装它那一份行清单,不向官方 roster 询问。
|
|
16
|
+
export interface SubagentGuidanceConfig {
|
|
17
|
+
readonly localizedReturnGuidancePresets?: readonly string[];
|
|
18
|
+
readonly preset?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function normalizeConfig(input: SubagentGuidanceConfig = {}): Required<SubagentGuidanceConfig> {
|
|
22
|
+
return {
|
|
23
|
+
localizedReturnGuidancePresets: [...(input.localizedReturnGuidancePresets ?? [])],
|
|
24
|
+
preset: input.preset ?? DEFAULT_PRESET,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Injectable()
|
|
29
|
+
export class SubagentGuidance implements OnInit {
|
|
30
|
+
static Config = normalizeConfig;
|
|
31
|
+
|
|
32
|
+
readonly assemble$ = new SystemPromptAssemble();
|
|
33
|
+
|
|
34
|
+
readonly preStep$ = new AgentPreStep();
|
|
35
|
+
|
|
36
|
+
private readonly config: Required<SubagentGuidanceConfig>;
|
|
37
|
+
|
|
38
|
+
constructor(input: SubagentGuidanceConfig = {}) {
|
|
39
|
+
this.config = normalizeConfig(input);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
onInit(): void {
|
|
43
|
+
this.assemble$.onWaterfall(async (assembly, context, next) => {
|
|
44
|
+
const result = await next();
|
|
45
|
+
if (!isDelegatedAgent(context.agent)) return result;
|
|
46
|
+
const contexts = result.contexts.map((entry) => rewordedContext(entry));
|
|
47
|
+
const changed = contexts.some((entry, index) => entry !== result.contexts[index]);
|
|
48
|
+
return changed ? { ...result, contexts } : result;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
this.preStep$.onWaterfall(async ({ agent }, next) => {
|
|
52
|
+
const decision = await next();
|
|
53
|
+
// 指引只出现在子代理的首条任务上:父会话的装配与消息表都不动。
|
|
54
|
+
if (decision.kind === "reject" || !isDelegatedAgent(agent)) return decision;
|
|
55
|
+
if (!this.wantsChinese()) return decision;
|
|
56
|
+
let changed = false;
|
|
57
|
+
const messages = decision.messages.map((message) => {
|
|
58
|
+
const content = rewordGuidanceContent(message.content);
|
|
59
|
+
if (content === undefined) return message;
|
|
60
|
+
changed = true;
|
|
61
|
+
return { ...message, content };
|
|
62
|
+
});
|
|
63
|
+
return changed ? { ...decision, messages } : decision;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 这个会话要不要中文回报指引:名单留空就是不限。
|
|
68
|
+
private wantsChinese(): boolean {
|
|
69
|
+
return localizedGuidanceApplies(this.presetOf(), this.config.localizedReturnGuidancePresets);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 部署那一个 preset id:本部署只装它那一份行清单,不再向官方 roster 询问,也不按 agent 的 ctx 分叉。
|
|
73
|
+
private presetOf(): string {
|
|
74
|
+
return this.config.preset;
|
|
75
|
+
}
|
|
76
|
+
}
|