dsh-plugin-t-expert 0.3.88 → 0.3.89

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.
@@ -1,463 +0,0 @@
1
- /**
2
- * T Team for DeepSeek Harness.
3
- *
4
- * A host-plane plugin that registers the `t_team_*` tools and one usage
5
- * agent-scoped usage section. Each session keeps a stable tool set and core
6
- * instructions. Existing business tools cover the complete team lifecycle.
7
- * After installation any session can
8
- * run multi-agent teamwork through natural language (e.g. "use T Team to research X"):
9
- * the model creates a team (it becomes the captain), spawns members as
10
- * durable continuable subagents, breaks the goal into tasks with
11
- * dependencies, wakes members with messages, relays reports, and collects
12
- * results.
13
- *
14
- * Installation (bundle): `dsh plugin --profile <name> add dsh-plugin-t-expert`
15
- * (or a local path). The bundle patch mounts this plugin row into the host
16
- * composition; the tools register into the shared `tools` registry and the
17
- * usage section into the global system prompt, so the plugin needs no realm.
18
- *
19
- * @module t-team
20
- */
21
- import z from '@deepseek-ai/schemastery';
22
- import { createUserMessage } from '@deepseek-ai/dsh-llm';
23
- import { haltTeamWork, stagedPlanApprovedContext, registerTTeamTools, } from "./tools.js";
24
- import { installTTeamGestureBoundary, registerTTeamCommand } from "./command.js";
25
- import { readFile } from 'node:fs/promises';
26
- import { join } from 'node:path';
27
- import { fileURLToPath } from 'node:url';
28
- import { collectArchivedTeamsActivity, collectTeamsActivity } from "./snapshot.js";
29
- import { findTeamByCaptain } from "./state.js";
30
- import { formatProfilesForPrompt } from "./profiles.js";
31
- import { installTeamCapabilities } from "./capabilities.js";
32
- import { TEAM_TOOL_NAMES } from "./tool-names.js";
33
- import { authenticatedWebRoutes, readJsonRequest, RequestBodyError } from "./web-routes.js";
34
- /** Web-server service key candidates, newest first. */
35
- const WEB_SERVER_KEYS = ['webServer', 'httpServer'];
36
- /** Workspace registry service key candidates, newest first. */
37
- const WORKSPACE_KEYS = ['workspaceRegistry', 'workspace'];
38
- export const name = 't-team';
39
- export const inject = ['tools', 'llm', 'subagents', 'systemPrompt', 'agents'];
40
- // `z.object()` has an implicit `{}` default in Schemastery. Fallback routes
41
- // are optional, so model absence explicitly; otherwise a missing route is
42
- // validated as an empty object and fails on the required provider/model keys.
43
- const fallbackRouteConfig = z.union([
44
- z.object({ provider: z.string().required(), model: z.string().required() }),
45
- z.const(undefined),
46
- ]);
47
- export const Config = z.object({
48
- stateDir: z.string().default('.t-team'),
49
- memberProvider: z.string().default('spawn'),
50
- memberModel: z.string(),
51
- executionPrompt: z.string(),
52
- fallback: fallbackRouteConfig,
53
- profiles: z.dict(z.object({
54
- description: z.string(),
55
- protocol: z.string(),
56
- executionPrompt: z.string(),
57
- fallback: fallbackRouteConfig,
58
- members: z.array(z.object({
59
- name: z.string().required(),
60
- role: z.string(),
61
- provider: z.string(),
62
- model: z.string(),
63
- reasoning_effort: z.string(),
64
- executionPrompt: z.string(),
65
- fallback: fallbackRouteConfig,
66
- })).min(1).required(),
67
- taskPlanning: z.union([z.const('captain'), z.const('seed')]),
68
- reviewPolicy: z.object({
69
- requirementsMinRounds: z.natural().min(1),
70
- requirementsMaxRounds: z.natural().min(1),
71
- codeMaxRounds: z.natural().min(1),
72
- maxRepairAttempts: z.natural().min(1),
73
- requiredReviewers: z.array(z.string()),
74
- }),
75
- tasks: z.array(z.object({
76
- id: z.string().required(),
77
- subject: z.string().required(),
78
- description: z.string(),
79
- assignee: z.string(),
80
- dependencies: z.array(z.string()),
81
- })),
82
- })).default({}),
83
- memberMaxDepth: z.natural().default(1),
84
- maxMembers: z.natural().min(1).default(8),
85
- promptSectionOrder: z.natural().default(117),
86
- slashCommand: z.boolean().default(true),
87
- });
88
- /** The model-facing usage policy: when and how to drive T Team. */
89
- export function usageSectionText(toolNames, profilesText = '') {
90
- return `T Team captain protocol:
91
- 1. Inspect current team state when needed, using t_team_status. Continue existing work without duplicating its roster/tasks. Create only when no current team exists, with the user's goal as description and approval="required"; automatic approval requires an explicit request to run immediately. Staged plans never spawn or schedule work.
92
- 2. Add each needed role once; members inherit your model route unless another is requested/needed. A requested profile goes to create({profile}); it supplies its roster. Seed profiles also supply tasks; captain-planning profiles require your DAG. Do not duplicate either.
93
- 3. Build the complete smallest useful DAG while staged. Every task needs a subject; dependencies represent prerequisites. Give every required contributor a task or explicit message. Present the plan and end your turn for review; never approve in that planning turn. Approve only after a later explicit user approval or the Web action.
94
- 4. Respect Web approve/return/discard control messages. On return, ask what to change before editing; after the answer, use one atomic t_team_edit_plan batch (edit downstream references before removals), summarize and await review again. Never inspect or edit the T Team state directory in the workspace or the plugin source code to revise plans. Discard does not authorize a replacement.
95
- 5. The scheduler dispatches ready tasks after approval. Delegate; do not duplicate slow work or send messages merely to start a stage. Handle reports/user work, then yield when waiting is all that remains: reports wake you automatically. Use status after a delivery or user request, never busy-poll or wait for unassigned members. A member report already states what changed, so do not call status again merely to confirm it; call it when you need the parts the report does not cover (the current graph, other members' state).
96
- 6. Tasks carry attempt_id capabilities. Use the current attempt_id; stale means ownership changed. Pause members only on explicit request; later guidance via send_message continues that same attempt. Retry, transfer or take over through reassign_task first; it revokes the old attempt and waits for quiescence. Prefer a member. Captain implementation/review takeover requires a user request. Every takeover is one ready task at a time, finished in this turn; never yield with captain-owned work open.
97
- 7. Quality kinds (requirements, implementation, verification, review, repair, integration) require objective + acceptance; implementation/repair also require inScope + verify. Derive paths/commands from the workspace/profile, never assume src/ or pnpm test. Review/requirements complete only with verdict=pass; needs_revision/reject fail with findings. Never approve your own implementation or ask for a deliberate failure.
98
- 8. When full quality mode is requested: requirements → implementation → verification → review → integration. Plan the entire DAG while staged, including implementation before requirements finishes and integration depending on review round 1. Failed review automatically adds repair + next review and rewires pending downstream gates. Do not recreate this loop, omit integration or depend on a failed task. The automatic repair task already carries the review findings and is already assigned to the implementer, so do NOT relay those findings through send_message: the implementer has them, and the relay only makes it stop and explain that the repair is already done. Review acceptance judges the latest implementation. Do not put smoke-test scripts into task instructions.
99
- 9. Halted means the user stopped work (including the captain turn). Resume only on a later explicit user request with a reason, via t_team_resume or create_task({resume:true,resumeReason}); creating tasks alone never resumes. Escalated means the review loop hit its limit, not a halt. Deployment requires explicit user confirmation.
100
- 10. Wait for all required tasks to be terminal and members idle/ready, present results, then delete/archive unless the user wants to continue. Never discard unfinished work without authorization.
101
- Tools: ${toolNames}${profilesText === '' ? '' : `\n\n${profilesText}`}`;
102
- }
103
- export function apply(ctx, config) {
104
- const resolved = {
105
- stateDir: config.stateDir ?? '.t-team',
106
- memberProvider: config.memberProvider ?? 'spawn',
107
- memberModel: config.memberModel,
108
- executionPrompt: config.executionPrompt,
109
- fallback: config.fallback,
110
- memberMaxDepth: config.memberMaxDepth ?? 1,
111
- maxMembers: config.maxMembers ?? 8,
112
- profiles: config.profiles ?? {},
113
- };
114
- // Hot reload: a squad saved in the settings tab re-applies this plugin with a new
115
- // `profiles` object (the host updates the fiber's config instead of restarting the
116
- // harness). Every read below must therefore go through `resolved.profiles` — the
117
- // per-apply snapshot — and never through a module-level constant captured once at
118
- // startup: that was the "edit a squad, restart DSH" behaviour this exists to remove.
119
- const profiles = () => resolved.profiles;
120
- // Provider registration is a sibling plugin's effect (`subagent-spawn` /
121
- // `subagent-fork` rows), which can land after this mount under the Loader's
122
- // concurrent activation — so capability validation happens at the first
123
- // member spawn (`spawnMember`), the earliest point the provider list is
124
- // settled, rather than here.
125
- const tTeamRuntime = registerTTeamTools(ctx, resolved);
126
- installTeamCapabilities(ctx, {
127
- stateDir: resolved.stateDir,
128
- isPendingMember: tTeamRuntime.isPendingMember,
129
- order: config.promptSectionOrder,
130
- // Keep the bounded profile directory available without extra tool calls.
131
- // installTeamCapabilities snapshots this once; no business state rewrites it.
132
- // resolved.profiles is this apply's snapshot, so a hot reload rebuilds the
133
- // captain prompt with the new squad directory instead of a stale closure.
134
- captainPrompt: () => usageSectionText(TEAM_TOOL_NAMES.join(', '), formatProfilesForPrompt(profiles())),
135
- });
136
- // Deterministic activation surfaces: the closed-namespace `/t-team`
137
- // host command (surfaces in the Web GUI slash menu via the Harness
138
- // ui-commands client) and the plain-text gesture boundary for surfaces
139
- // without command adjudication (headless CLI). Both default on; a profile
140
- // can disable them to keep the natural-language trigger exclusive.
141
- //
142
- // `commands` is registered lazily (not a required inject): it ships in the
143
- // base bundle of every standard profile, but a minimal composition that
144
- // omits the command registry keeps the plugin fully functional — the fiber
145
- // never pends on it and simply never gains the slash command.
146
- if (config.slashCommand ?? true) {
147
- ctx.inject(['commands'], (commandCtx) => {
148
- registerTTeamCommand(commandCtx, profiles);
149
- });
150
- installTTeamGestureBoundary(ctx, profiles);
151
- }
152
- // The activity panel data/artwork routes need the Web server and the
153
- // workspace registry, which headless profiles do not mount; under
154
- // concurrent activation they may also bind after this plugin. Register the
155
- // routes lazily: try now, then on each service binding event. In a webless
156
- // profile the plugin stays tool-only and never blocks boot.
157
- let webRegistered = false;
158
- const registerWebSurface = () => {
159
- if (webRegistered)
160
- return;
161
- const rawWebServer = (ctx.get(WEB_SERVER_KEYS[0]) ?? ctx.get(WEB_SERVER_KEYS[1]));
162
- const workspaceRegistry = (ctx.get(WORKSPACE_KEYS[0]) ?? ctx.get(WORKSPACE_KEYS[1]));
163
- if (rawWebServer === undefined || workspaceRegistry === undefined)
164
- return;
165
- const webServer = authenticatedWebRoutes(rawWebServer, () => ctx.get('connection'));
166
- // 审计修复(#10):`webRegistered = true` 过去写在任何注册之前,一旦某条路由
167
- // register 抛错(例如 webServer 服务重载后重复路径),布尔已置位,后续
168
- // internal/service 事件永不重试,路由永久缺失。改为「收集 disposer + 全部成功
169
- // 才置位」,任一失败回滚已注册的路由并重抛,让下次服务绑定事件可以再试一次。
170
- const disposers = [];
171
- try {
172
- // Activity panel data route: the browser floater polls this for team
173
- // snapshots (disk truth + live subagent activity). Mirrors the Claude
174
- // Code desktop watcher's server-side snapshot pattern.
175
- disposers.push(ctx.effect(() => webServer.register({
176
- kind: 'exact',
177
- path: '/plugins/t-team/state',
178
- handler: async (req, res) => {
179
- const url = new URL(req.url ?? '/', 'http://x');
180
- const roots = workspaceRegistry.list().map((workspace) => ({
181
- workspace: workspace.title,
182
- stateRoot: join(workspace.path, resolved.stateDir),
183
- }));
184
- // ?archived=1 serves teams moved to archive/ (post-delete review).
185
- const snapshots = url.searchParams.get('archived') === '1'
186
- ? await collectArchivedTeamsActivity(ctx, roots)
187
- : await collectTeamsActivity(ctx, roots);
188
- const body = JSON.stringify({ teams: snapshots });
189
- res.writeHead(200, {
190
- 'content-type': 'application/json; charset=utf-8',
191
- 'cache-control': 'no-store',
192
- });
193
- res.end(body);
194
- },
195
- }), 't-team: activity route'));
196
- disposers.push(ctx.effect(() => webServer.register({
197
- kind: 'exact',
198
- path: '/plugins/t-team/halt',
199
- handler: async (req, res) => {
200
- if (req.method !== 'POST') {
201
- res.writeHead(405, { allow: 'POST', 'cache-control': 'no-store' });
202
- res.end();
203
- return;
204
- }
205
- let payload;
206
- try {
207
- payload = await readJsonRequest(req);
208
- }
209
- catch (error) {
210
- res.writeHead(error instanceof RequestBodyError ? error.status : 400, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
211
- res.end(JSON.stringify({ error: error instanceof Error ? error.message : 'invalid request body' }));
212
- return;
213
- }
214
- const sessionId = typeof payload.sessionId === 'string' ? payload.sessionId.trim() : '';
215
- const teamId = typeof payload.teamId === 'string' ? payload.teamId.trim() : '';
216
- if (sessionId === '' || teamId === '') {
217
- res.writeHead(400, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
218
- res.end(JSON.stringify({ error: 'sessionId and teamId are required' }));
219
- return;
220
- }
221
- const captain = ctx.agents.get(sessionId);
222
- if (captain === undefined) {
223
- res.writeHead(409, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
224
- res.end(JSON.stringify({ error: 'captain session is not attached' }));
225
- return;
226
- }
227
- const workspace = captain.session.header.cwd ?? process.cwd();
228
- const stateRoot = join(workspace, resolved.stateDir);
229
- const team = await findTeamByCaptain(stateRoot, captain.id);
230
- if (team === undefined || team.id !== teamId) {
231
- res.writeHead(404, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
232
- res.end(JSON.stringify({ error: 'team not found for this captain' }));
233
- return;
234
- }
235
- try {
236
- const result = await haltTeamWork({
237
- ctx,
238
- stateRoot,
239
- teamId,
240
- captain,
241
- });
242
- res.writeHead(200, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
243
- res.end(JSON.stringify(result));
244
- }
245
- catch (error) {
246
- ctx.logger.warn(`t-team: halt failed for ${teamId}: ${String(error)}`);
247
- res.writeHead(500, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
248
- res.end(JSON.stringify({ error: 'failed to stop the team' }));
249
- }
250
- },
251
- }), 't-team: halt route'));
252
- disposers.push(ctx.effect(() => webServer.register({
253
- kind: 'exact',
254
- path: '/plugins/t-team/plan',
255
- handler: async (req, res) => {
256
- if (req.method !== 'POST') {
257
- res.writeHead(405, { allow: 'POST', 'cache-control': 'no-store' });
258
- res.end();
259
- return;
260
- }
261
- let payload;
262
- try {
263
- payload = await readJsonRequest(req);
264
- }
265
- catch (error) {
266
- res.writeHead(error instanceof RequestBodyError ? error.status : 400, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
267
- res.end(JSON.stringify({ error: error instanceof Error ? error.message : 'invalid request body' }));
268
- return;
269
- }
270
- const sessionId = typeof payload['sessionId'] === 'string' ? payload['sessionId'].trim() : '';
271
- const teamId = typeof payload['teamId'] === 'string' ? payload['teamId'].trim() : '';
272
- const action = typeof payload['action'] === 'string' ? payload['action'] : '';
273
- if (sessionId === '' || teamId === '' || action === '') {
274
- res.writeHead(400, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
275
- res.end(JSON.stringify({ error: 'sessionId, teamId, and action are required' }));
276
- return;
277
- }
278
- const captain = ctx.agents.get(sessionId);
279
- if (captain === undefined) {
280
- res.writeHead(409, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
281
- res.end(JSON.stringify({ error: 'captain session is not attached' }));
282
- return;
283
- }
284
- const workspace = captain.session.header.cwd ?? process.cwd();
285
- const stateRoot = join(workspace, resolved.stateDir);
286
- const team = await findTeamByCaptain(stateRoot, captain.id);
287
- if (team === undefined || team.id !== teamId) {
288
- res.writeHead(404, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
289
- res.end(JSON.stringify({ error: 'team not found for this captain' }));
290
- return;
291
- }
292
- try {
293
- if (action === 'approve') {
294
- const approved = await tTeamRuntime.approveStagedTeam(captain, teamId);
295
- // The browser receives the HTTP result, so the model needs its own
296
- // control message. steer wakes an idle captain or joins its next
297
- // step; the tool approve path already returns to the model itself.
298
- try {
299
- captain.steer(createUserMessage({
300
- content: [{ type: 'text', text: stagedPlanApprovedContext(team.name) }],
301
- source: { kind: 'plugin', plugin: 't-team' },
302
- }));
303
- }
304
- catch (error) {
305
- // Approval is already committed. Do not report a failed approval
306
- // and invite a retry that could duplicate the user's action.
307
- ctx.logger.warn(`t-team: approval notification failed for ${teamId}: ${String(error)}`);
308
- }
309
- res.writeHead(200, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
310
- res.end(JSON.stringify({ ok: true, phase: 'running', ...approved }));
311
- return;
312
- }
313
- if (action === 'continue') {
314
- const continued = await tTeamRuntime.continueStagedPlanning(captain, teamId);
315
- res.writeHead(200, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
316
- res.end(JSON.stringify({ ok: true, phase: 'staged', review: 'awaiting_feedback', ...continued }));
317
- return;
318
- }
319
- if (action === 'discard') {
320
- const discarded = await tTeamRuntime.discardStagedTeam(captain, teamId);
321
- res.writeHead(200, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
322
- res.end(JSON.stringify({ ok: true, phase: 'archived', ...discarded }));
323
- return;
324
- }
325
- const dependencies = Array.isArray(payload['dependencies'])
326
- ? payload['dependencies'].filter((item) => typeof item === 'string')
327
- : [];
328
- let mutation;
329
- if (action === 'update_member') {
330
- if (typeof payload['memberName'] !== 'string'
331
- || typeof payload['provider'] !== 'string'
332
- || typeof payload['model'] !== 'string')
333
- throw new Error('memberName, provider, and model are required');
334
- mutation = {
335
- action,
336
- memberName: payload['memberName'],
337
- provider: payload['provider'],
338
- model: payload['model'],
339
- ...typeof payload['role'] === 'string' || payload['role'] === null ? { role: payload['role'] } : {},
340
- ...typeof payload['reasoningEffort'] === 'string' || payload['reasoningEffort'] === null
341
- ? { reasoningEffort: payload['reasoningEffort'] }
342
- : {},
343
- ...typeof payload['executionPrompt'] === 'string' || payload['executionPrompt'] === null
344
- ? { executionPrompt: payload['executionPrompt'] }
345
- : {},
346
- };
347
- }
348
- else if (action === 'update_task') {
349
- if (typeof payload['taskId'] !== 'string' || typeof payload['subject'] !== 'string') {
350
- throw new Error('taskId and subject are required');
351
- }
352
- mutation = {
353
- action,
354
- taskId: payload['taskId'],
355
- subject: payload['subject'],
356
- dependencies,
357
- ...typeof payload['description'] === 'string' || payload['description'] === null
358
- ? { description: payload['description'] }
359
- : {},
360
- ...typeof payload['assignee'] === 'string' || payload['assignee'] === null
361
- ? { assignee: payload['assignee'] }
362
- : {},
363
- };
364
- }
365
- else if (action === 'add_task') {
366
- if (typeof payload['subject'] !== 'string')
367
- throw new Error('subject is required');
368
- mutation = {
369
- action,
370
- subject: payload['subject'],
371
- dependencies,
372
- ...typeof payload['description'] === 'string' || payload['description'] === null
373
- ? { description: payload['description'] }
374
- : {},
375
- ...typeof payload['assignee'] === 'string' || payload['assignee'] === null
376
- ? { assignee: payload['assignee'] }
377
- : {},
378
- };
379
- }
380
- else if (action === 'remove_task') {
381
- if (typeof payload['taskId'] !== 'string')
382
- throw new Error('taskId is required');
383
- mutation = { action, taskId: payload['taskId'] };
384
- }
385
- else {
386
- throw new Error(`unknown plan action "${action}"`);
387
- }
388
- const updated = await tTeamRuntime.updateStagedPlan(captain, teamId, mutation);
389
- res.writeHead(200, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
390
- res.end(JSON.stringify({ ok: true, phase: updated.phase, members: updated.members.length, tasks: updated.tasks.length }));
391
- }
392
- catch (error) {
393
- res.writeHead(409, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
394
- res.end(JSON.stringify({ error: error instanceof Error ? error.message : 'plan operation failed' }));
395
- }
396
- },
397
- }), 't-team: plan route'));
398
- // Whale mascot artwork: serve the packaged V2 role/action images to the
399
- // activity panel. An explicit allowlist guards the route (no path
400
- // traversal); the images ship with the bundle (files: assets/).
401
- const artDir = fileURLToPath(new URL('../assets/t-team/', import.meta.url));
402
- const ART_ALLOWLIST = new Set([
403
- 'team-lead-v2.png',
404
- 'member-researcher-v2.png', 'member-engineer-v2.png',
405
- 'member-qa-v2.png', 'member-designer-v2.png',
406
- 'member-security-v2.png', 'member-docs-v2.png',
407
- 'member-data-v2.png', 'member-operator-v2.png',
408
- 'action-working-v2.png', 'action-thinking-v2.png',
409
- 'action-reporting-v2.png', 'action-celebrating-v2.png',
410
- 'action-sleeping-v2.png', 'action-sending-v2.png',
411
- ]);
412
- disposers.push(ctx.effect(() => webServer.register({
413
- kind: 'prefix',
414
- path: '/plugins/t-team/assets',
415
- handler: async (req, res) => {
416
- let name;
417
- try {
418
- name = decodeURIComponent(new URL(req.url ?? '/', 'http://x').pathname.split('/').pop() ?? '');
419
- }
420
- catch {
421
- // Malformed percent-encoding: treat as an unknown asset, not a 400.
422
- res.writeHead(404);
423
- res.end();
424
- return;
425
- }
426
- if (!ART_ALLOWLIST.has(name)) {
427
- res.writeHead(404);
428
- res.end();
429
- return;
430
- }
431
- try {
432
- const data = await readFile(join(artDir, name));
433
- res.writeHead(200, {
434
- 'content-type': 'image/png',
435
- 'cache-control': 'public, max-age=86400',
436
- });
437
- res.end(data);
438
- }
439
- catch (error) {
440
- ctx.logger.warn(`t-team: artwork read failed for ${name}: ${String(error)}`);
441
- res.writeHead(404);
442
- res.end();
443
- }
444
- },
445
- }), 't-team: artwork route'));
446
- } catch (error) {
447
- // 任一路由注册失败:回滚已经注册成功的,保持 webRegistered=false,让下次
448
- // internal/service 绑定事件重试,而不是留下半套路由 + 永久不再重试。
449
- for (const dispose of disposers.reverse()) {
450
- try { dispose(); } catch { /* 回滚尽力而为,失败只影响清理 */ }
451
- }
452
- throw error;
453
- }
454
- webRegistered = true;
455
- };
456
- registerWebSurface();
457
- ctx.on('internal/service', (name) => {
458
- if (WEB_SERVER_KEYS.includes(name)
459
- || WORKSPACE_KEYS.includes(name)) {
460
- registerWebSurface();
461
- }
462
- });
463
- }