@capyclaw/ppt-suite 2.5.67 → 2.5.68

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.
Files changed (141) hide show
  1. package/composition.lock.json +3 -3
  2. package/contract/ppt-contract.json +1 -1
  3. package/dsh-suite.json +4 -4
  4. package/node_modules/@capyclaw/asset-service/src/index.mjs +86 -5
  5. package/node_modules/@capyclaw/document-workbench/src/session/context.mjs +17 -5
  6. package/node_modules/@capyclaw/editor-host/src/index.mjs +7 -2
  7. package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +11 -10
  8. package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +8 -1
  9. package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +31 -3
  10. package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +0 -81
  11. package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +13 -6
  12. package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +31 -15
  13. package/node_modules/@capyclaw/ppt-editor/contract/ppt-contract.json +1 -1
  14. package/node_modules/@capyclaw/ppt-skill-api/contract/ppt-contract.json +1 -1
  15. package/node_modules/@capyclaw/ppt-skill-api/skills/pptist-api/references/tool-contract.md +1 -1
  16. package/node_modules/@capyclaw/ppt-skill-proposal/contract/ppt-contract.json +1 -1
  17. package/node_modules/@capyclaw/ppt-workbench/contract/ppt-contract.json +1 -1
  18. package/node_modules/@capyclaw/ppt-workbench/package.json +1 -1
  19. package/node_modules/@capyclaw/ppt-workbench/server/contract.mjs +1 -1
  20. package/node_modules/@capyclaw/ppt-workbench/server/relay.mjs +18 -18
  21. package/node_modules/@capyclaw/ppt-workbench/server/routes/session.mjs +8 -1
  22. package/node_modules/@capyclaw/ppt-workbench/server/store/sessions.mjs +15 -4
  23. package/node_modules/@capyclaw/service-broker/lib/recovery.mjs +0 -50
  24. package/node_modules/@capyclaw/tool-host/src/descriptors.mjs +28 -4
  25. package/node_modules/@capyclaw/tool-host/src/index.mjs +32 -6
  26. package/package.json +4 -4
  27. package/node_modules/playwright-core/LICENSE +0 -202
  28. package/node_modules/playwright-core/NOTICE +0 -5
  29. package/node_modules/playwright-core/README.md +0 -3
  30. package/node_modules/playwright-core/ThirdPartyNotices.txt +0 -13
  31. package/node_modules/playwright-core/bin/install_media_pack.ps1 +0 -5
  32. package/node_modules/playwright-core/bin/install_webkit_wsl.ps1 +0 -33
  33. package/node_modules/playwright-core/bin/reinstall_chrome_beta_linux.sh +0 -42
  34. package/node_modules/playwright-core/bin/reinstall_chrome_beta_mac.sh +0 -13
  35. package/node_modules/playwright-core/bin/reinstall_chrome_beta_win.ps1 +0 -24
  36. package/node_modules/playwright-core/bin/reinstall_chrome_stable_linux.sh +0 -42
  37. package/node_modules/playwright-core/bin/reinstall_chrome_stable_mac.sh +0 -12
  38. package/node_modules/playwright-core/bin/reinstall_chrome_stable_win.ps1 +0 -24
  39. package/node_modules/playwright-core/bin/reinstall_msedge_beta_linux.sh +0 -48
  40. package/node_modules/playwright-core/bin/reinstall_msedge_beta_mac.sh +0 -11
  41. package/node_modules/playwright-core/bin/reinstall_msedge_beta_win.ps1 +0 -23
  42. package/node_modules/playwright-core/bin/reinstall_msedge_dev_linux.sh +0 -48
  43. package/node_modules/playwright-core/bin/reinstall_msedge_dev_mac.sh +0 -11
  44. package/node_modules/playwright-core/bin/reinstall_msedge_dev_win.ps1 +0 -23
  45. package/node_modules/playwright-core/bin/reinstall_msedge_stable_linux.sh +0 -48
  46. package/node_modules/playwright-core/bin/reinstall_msedge_stable_mac.sh +0 -11
  47. package/node_modules/playwright-core/bin/reinstall_msedge_stable_win.ps1 +0 -24
  48. package/node_modules/playwright-core/browsers.json +0 -52
  49. package/node_modules/playwright-core/cli.js +0 -22
  50. package/node_modules/playwright-core/index.d.ts +0 -17
  51. package/node_modules/playwright-core/index.js +0 -17
  52. package/node_modules/playwright-core/index.mjs +0 -28
  53. package/node_modules/playwright-core/lib/bootstrap.js +0 -149
  54. package/node_modules/playwright-core/lib/coreBundle.js +0 -78041
  55. package/node_modules/playwright-core/lib/entry/cliDaemon.js +0 -5
  56. package/node_modules/playwright-core/lib/entry/dashboardApp.js +0 -3
  57. package/node_modules/playwright-core/lib/entry/mcp.js +0 -10
  58. package/node_modules/playwright-core/lib/entry/oopBrowserDownload.js +0 -3
  59. package/node_modules/playwright-core/lib/package.js +0 -50
  60. package/node_modules/playwright-core/lib/server/chromium/appIcon.png +0 -0
  61. package/node_modules/playwright-core/lib/server/electron/loader.js +0 -123
  62. package/node_modules/playwright-core/lib/serverRegistry.js +0 -1939
  63. package/node_modules/playwright-core/lib/serverRegistry.js.LICENSE +0 -65
  64. package/node_modules/playwright-core/lib/tools/cli-client/channelSessions.js +0 -141
  65. package/node_modules/playwright-core/lib/tools/cli-client/cli.js +0 -7
  66. package/node_modules/playwright-core/lib/tools/cli-client/help.json +0 -808
  67. package/node_modules/playwright-core/lib/tools/cli-client/minimist.js +0 -128
  68. package/node_modules/playwright-core/lib/tools/cli-client/output.js +0 -352
  69. package/node_modules/playwright-core/lib/tools/cli-client/program.js +0 -422
  70. package/node_modules/playwright-core/lib/tools/cli-client/registry.js +0 -180
  71. package/node_modules/playwright-core/lib/tools/cli-client/session.js +0 -261
  72. package/node_modules/playwright-core/lib/tools/dashboard/appIcon.png +0 -0
  73. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/SKILL.md +0 -493
  74. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/element-attributes.md +0 -23
  75. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/playwright-tests.md +0 -39
  76. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/pr-attachments.md +0 -60
  77. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/request-mocking.md +0 -87
  78. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/running-code.md +0 -245
  79. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/session-management.md +0 -227
  80. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/storage-state.md +0 -275
  81. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/test-generation.md +0 -433
  82. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/tracing.md +0 -139
  83. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/video-recording.md +0 -216
  84. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/SKILL.md +0 -136
  85. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +0 -144
  86. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/migration.md +0 -89
  87. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/react.md +0 -69
  88. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/typing.md +0 -173
  89. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/vue.md +0 -77
  90. package/node_modules/playwright-core/lib/tools/skills/playwright-trace/SKILL.md +0 -174
  91. package/node_modules/playwright-core/lib/tools/utils/extension.js +0 -112
  92. package/node_modules/playwright-core/lib/tools/utils/socketConnection.js +0 -108
  93. package/node_modules/playwright-core/lib/utilsBundle.js +0 -86078
  94. package/node_modules/playwright-core/lib/utilsBundle.js.LICENSE +0 -1890
  95. package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +0 -1
  96. package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +0 -32
  97. package/node_modules/playwright-core/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
  98. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +0 -1
  99. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +0 -1
  100. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +0 -1
  101. package/node_modules/playwright-core/lib/vite/dashboard/assets/index-AwgwcYie.css +0 -1
  102. package/node_modules/playwright-core/lib/vite/dashboard/assets/index-hRvO4yU2.js +0 -12
  103. package/node_modules/playwright-core/lib/vite/dashboard/assets/safari-na3_-uQk.svg +0 -1
  104. package/node_modules/playwright-core/lib/vite/dashboard/index.html +0 -29
  105. package/node_modules/playwright-core/lib/vite/dashboard/playwright-logo.svg +0 -24
  106. package/node_modules/playwright-core/lib/vite/htmlReport/index.html +0 -16
  107. package/node_modules/playwright-core/lib/vite/htmlReport/report.css +0 -2
  108. package/node_modules/playwright-core/lib/vite/htmlReport/report.js +0 -32
  109. package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +0 -1
  110. package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule-DK72OMRi.js +0 -32
  111. package/node_modules/playwright-core/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
  112. package/node_modules/playwright-core/lib/vite/recorder/assets/index-BZpYJZ-P.css +0 -1
  113. package/node_modules/playwright-core/lib/vite/recorder/assets/index-Cn0mmDuv.js +0 -129
  114. package/node_modules/playwright-core/lib/vite/recorder/index.html +0 -29
  115. package/node_modules/playwright-core/lib/vite/recorder/playwright-logo.svg +0 -9
  116. package/node_modules/playwright-core/lib/vite/traceViewer/assets/codeMirrorModule-BEB2e8M3.js +0 -32
  117. package/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-D-g2vrvf.js +0 -184
  118. package/node_modules/playwright-core/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +0 -1
  119. package/node_modules/playwright-core/lib/vite/traceViewer/assets/xtermModule-B794rD2Z.js +0 -7
  120. package/node_modules/playwright-core/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +0 -1
  121. package/node_modules/playwright-core/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
  122. package/node_modules/playwright-core/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +0 -1
  123. package/node_modules/playwright-core/lib/vite/traceViewer/index.B_TqY17P.css +0 -1
  124. package/node_modules/playwright-core/lib/vite/traceViewer/index.html +0 -44
  125. package/node_modules/playwright-core/lib/vite/traceViewer/index.oNry3Hjv.js +0 -1
  126. package/node_modules/playwright-core/lib/vite/traceViewer/manifest.webmanifest +0 -16
  127. package/node_modules/playwright-core/lib/vite/traceViewer/playwright-logo.svg +0 -9
  128. package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +0 -1
  129. package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.html +0 -10
  130. package/node_modules/playwright-core/lib/vite/traceViewer/sw.bundle.js +0 -4
  131. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CYwC_gH1.js +0 -5
  132. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +0 -1
  133. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +0 -18
  134. package/node_modules/playwright-core/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +0 -1
  135. package/node_modules/playwright-core/lib/webp_codec.LICENSE +0 -173
  136. package/node_modules/playwright-core/lib/webp_codec.wasm +0 -0
  137. package/node_modules/playwright-core/lib/xdg-open +0 -1267
  138. package/node_modules/playwright-core/package.json +0 -34
  139. package/node_modules/playwright-core/types/protocol.d.ts +0 -24776
  140. package/node_modules/playwright-core/types/structs.d.ts +0 -52
  141. package/node_modules/playwright-core/types/types.d.ts +0 -27167
@@ -46,17 +46,15 @@ export { BASE_PATH }
46
46
  /* 租约存活判定统一走共享 session/lease(OWNER_TTL 单一真源),不再本地硬编码秒数。 */
47
47
  const liveOwner = (doc) => isOwnerLive(doc)
48
48
 
49
- /* 由 createStore 赋值:路由要拿它做「当前会话」的解析与 activate 记录。 */
50
- let sessionStores = null
51
-
52
- /* 影子显示器:平台级「保证有显示器」的兜底责任方。有稿件但无真实窗口时自动补一个
53
- * 无头显示器渲染真像素;真实窗口到来即让位。fail-safe:解析不到 Chromium 自动禁用,
54
- * 工具退回离线渲染(与改造前一致),绝不影响桥启动。语义在 plugin-kit/editor/shadow。 */
55
- let shadowManager = null
56
- let shadowTimer = null
49
+ /* 每实例状态一律挂 ctx,不用模块级变量——同进程多个 relay 实例(embedded+standalone、
50
+ * HMR 重载)共享模块级变量会互相覆盖 store/影子管理器。SessionStores 经门面 __stores
51
+ * 取回(ctx.store.__stores),影子管理器/定时器挂 ctx.shadowManager/ctx.shadowTimer。 */
52
+ const storesOf = (ctx) => ctx.store.__stores
57
53
 
58
54
  function reconcileShadow(ctx) {
59
55
  try {
56
+ const sessionStores = storesOf(ctx)
57
+ const shadowManager = ctx.shadowManager
60
58
  if (!shadowManager || !sessionStores || !ctx.editorAssets) return
61
59
  const keys = new Set([DEFAULT_SESSION, sessionStores.activeSession(), ...sessionStores.sessions()])
62
60
  for (const sid of keys) {
@@ -95,8 +93,8 @@ export const startRelay = createWorkbench({
95
93
  /* 每会话一份 deck:这里返回的是「门面」,真正的 store 在请求发生时才按会话
96
94
  * 解析(见 store/sessions.mjs)。workspace 后端把文档键在 work 上,仍是单文档。 */
97
95
  createStore: ({ hostDir, backend }) => {
98
- sessionStores = new SessionStores({ hostDir, backend })
99
- return createSessionStoreFacade(sessionStores)
96
+ const stores = new SessionStores({ hostDir, backend })
97
+ return createSessionStoreFacade(stores)
100
98
  },
101
99
 
102
100
  createAssetStore: ({ hostDir }) => createFileAssetStore({ dir: path.join(hostDir, 'assets') }),
@@ -105,6 +103,7 @@ export const startRelay = createWorkbench({
105
103
  * 塞进 SessionStores,deck 即落 SQLite 作品库;没有则保持文件后端(行为不变)。
106
104
  * prepare 在 createStore 之后、首个请求之前运行,此时底座服务通常已就绪。 */
107
105
  prepare: (ctx) => {
106
+ const sessionStores = storesOf(ctx)
108
107
  if (sessionStores && typeof ctx.getWorkStore === 'function') sessionStores.setWorkStore(ctx.getWorkStore)
109
108
  /* base64 闸:deck 落盘前把内联 data:image 抽进资产仓,只留 /assets/<sha> 引用。
110
109
  * urlBase 与稿件 publicBase 同形(带挂载前缀),保证编辑器 <img> 能直接加载。 */
@@ -118,6 +117,7 @@ export const startRelay = createWorkbench({
118
117
  },
119
118
 
120
119
  routes: (ctx) => {
120
+ const sessionStores = storesOf(ctx)
121
121
  const jsonP = createJsonPptApp(ctx.store)
122
122
  ctx.jsonP = jsonP
123
123
  /* F:会话模式锁的底座解析器(works.db 单一真源)。底座缺席 → 守卫跳过。 */
@@ -232,21 +232,21 @@ export const startRelay = createWorkbench({
232
232
  * 解析不到 playwright-core / Chromium 时自动禁用,工具退回离线渲染。 */
233
233
  const tuning = getTuning()
234
234
  if (ctx.editorAssets && tuning.shadowDisplay !== false) {
235
- shadowManager = createShadowManager({
235
+ ctx.shadowManager = createShadowManager({
236
236
  log: (message) => console.log(message),
237
237
  maxConcurrent: Number(tuning.shadowMaxConcurrent) || 4,
238
238
  })
239
- shadowTimer = setInterval(() => reconcileShadow(ctx), Number(tuning.shadowReconcileMs) || 5000)
240
- shadowTimer.unref?.()
239
+ ctx.shadowTimer = setInterval(() => reconcileShadow(ctx), Number(tuning.shadowReconcileMs) || 5000)
240
+ ctx.shadowTimer.unref?.()
241
241
  }
242
242
  },
243
243
 
244
244
  /* 停机回收:清对账定时器、关停所有影子 browser(不留孤儿进程)。 */
245
- beforeStop: async () => {
246
- if (shadowTimer) { clearInterval(shadowTimer); shadowTimer = null }
247
- if (shadowManager) {
248
- try { await shadowManager.dispose() } catch { /* ignore */ }
249
- shadowManager = null
245
+ beforeStop: async (ctx) => {
246
+ if (ctx.shadowTimer) { clearInterval(ctx.shadowTimer); ctx.shadowTimer = null }
247
+ if (ctx.shadowManager) {
248
+ try { await ctx.shadowManager.dispose() } catch { /* ignore */ }
249
+ ctx.shadowManager = null
250
250
  }
251
251
  },
252
252
 
@@ -6,6 +6,7 @@
6
6
  * 「用户正在看的那个会话」。
7
7
  */
8
8
  import { send, readBody } from '../http-utils.mjs'
9
+ import { normalizeSessionId } from '../store/sessions.mjs'
9
10
 
10
11
  export function createSessionRoutes({ stores, basePath }) {
11
12
  return [
@@ -21,7 +22,13 @@ export function createSessionRoutes({ stores, basePath }) {
21
22
  } catch {
22
23
  body = {}
23
24
  }
24
- const sid = stores.setActive(body.sessionId || body.session || req.sessionId || '')
25
+ /* 校验会话 id:空/非法直接 400,不再静默回落旧 active 假装激活成功。 */
26
+ const candidate = body.sessionId || body.session || req.sessionId || ''
27
+ if (!normalizeSessionId(candidate)) {
28
+ send(req, res, 400, { ok: false, error: 'sessionId 必填且需为合法会话 id' })
29
+ return true
30
+ }
31
+ const sid = stores.setActive(candidate)
25
32
  send(req, res, 200, { ok: true, sessionId: sid, sessions: stores.sessions() })
26
33
  return true
27
34
  },
@@ -32,7 +32,7 @@ import fs from 'node:fs'
32
32
  import os from 'node:os'
33
33
  import path from 'node:path'
34
34
  import { BridgeStore } from './index.mjs'
35
- import { currentSession } from '../session-context.mjs'
35
+ import { currentSession, sessionContext } from '../session-context.mjs'
36
36
 
37
37
  export const DEFAULT_SESSION = 'default'
38
38
  export const DECK_FILE = 'deck.json'
@@ -280,6 +280,17 @@ function writeMarker(file, key) {
280
280
  */
281
281
  export function createSessionStoreFacade(stores) {
282
282
  const target = { __stores: stores }
283
+ /* 请求内钉住:首次访问解析一次当前会话的 store 并挂到会话上下文,整个请求复用。
284
+ * 否则每次属性访问都重解析 current(),一旦请求中途 active 被别的窗口 /activate
285
+ * 翻转(且 ALS 会话为空,如 MCP 工具),同一请求的后续写入会改向到另一个会话。 */
286
+ const resolveStore = () => {
287
+ const ctx = sessionContext()
288
+ if (ctx) {
289
+ if (!ctx.pinned) ctx.pinned = stores.current()
290
+ return ctx.pinned
291
+ }
292
+ return stores.current()
293
+ }
283
294
  return new Proxy(target, {
284
295
  get(t, prop, receiver) {
285
296
  if (prop === '__stores') return stores
@@ -287,17 +298,17 @@ export function createSessionStoreFacade(stores) {
287
298
  if (typeof prop === 'symbol' || prop === 'then' || prop === 'toJSON') {
288
299
  return Reflect.get(t, prop, receiver)
289
300
  }
290
- const store = stores.current()
301
+ const store = resolveStore()
291
302
  const value = store[prop]
292
303
  return typeof value === 'function' ? value.bind(store) : value
293
304
  },
294
305
  set(t, prop, value) {
295
306
  if (prop === '__stores') return true
296
- stores.current()[prop] = value
307
+ resolveStore()[prop] = value
297
308
  return true
298
309
  },
299
310
  has(t, prop) {
300
- return prop === '__stores' || prop in stores.current()
311
+ return prop === '__stores' || prop in resolveStore()
301
312
  },
302
313
  })
303
314
  }
@@ -273,53 +273,3 @@ export async function waitReceiptResolvable(receipt, ports, timeoutMs = 3000) {
273
273
  await new Promise((resolve) => setTimeout(resolve, 200))
274
274
  }
275
275
  }
276
-
277
- // Caller must serialize against starting a replacement broker and supply the
278
- // identity captured when it spawned this broker. An absent PID alone is not a receipt.
279
- export async function recoverServices(discovery, broker) {
280
- const unresolved = [], stopped = []
281
- if (!broker?.pid || !broker?.marker || !broker?.recoveryMarker || !absent(broker.pid)) return { stopped, unresolved: ['broker:not-confirmed-absent'] }
282
- let discovered = {}
283
- try { discovered = JSON.parse(fs.readFileSync(discovery, 'utf8'))?.services || {} } catch { /* discovery 缺失时只能依赖收据自身 */ }
284
- let entries
285
- try { entries = fs.readdirSync(receiptDir(discovery)) } catch (e) {
286
- return { stopped, unresolved: [e.code === 'ENOENT' ? 'ownership:missing' : 'ownership:unreadable'] }
287
- }
288
- for (const name of entries) {
289
- if (!name.endsWith('.json')) { unresolved.push(`ownership:${name}:unrecognized`); continue }
290
- let r
291
- try { r = JSON.parse(fs.readFileSync(path.join(receiptDir(discovery), name), 'utf8')) } catch { unresolved.push(`ownership:${name}:unreadable`); continue }
292
- if (!r || `${r.id}.json` !== name || !/^[a-z0-9][a-z0-9._-]*$/i.test(r.id) || r.brokerPid !== broker.pid || r.brokerMarker !== broker.recoveryMarker || r.state !== 'spawned' || !Number.isSafeInteger(r.pid) || r.pid <= 0 || !r.identity) {
293
- unresolved.push(`ownership:${name}:unverified`); continue
294
- }
295
- if (!absent(broker.pid)) { unresolved.push('broker:not-confirmed-absent'); break }
296
- if (absent(r.pid)) {
297
- // Dead root: only a receipt whose declared ports are all free can be
298
- // resolved; any listener may be an unverified descendant.
299
- if (await waitReceiptResolvable(r, discovered[r.id]?.ports)) {
300
- removeReceipt(discovery, r.id)
301
- stopped.push(r.id)
302
- } else unresolved.push(`service:${r.id}:already-exited-descendants-unverified`)
303
- continue
304
- }
305
- if (!absent(r.pid)) {
306
- if (marker(r.pid) !== r.identity) { unresolved.push(`service:${r.id}:identity-unverified`); continue }
307
- if (process.platform === 'win32') {
308
- const result = spawnSync('taskkill', ['/PID', String(r.pid), '/F'], { stdio: 'ignore', timeout: 10000, windowsHide: true })
309
- if (result.status !== 0 && !absent(r.pid)) { unresolved.push(`service:${r.id}:stop-failed`); continue }
310
- } else {
311
- try { process.kill(r.pid, 'SIGTERM') } catch (e) { if (e.code !== 'ESRCH') { unresolved.push(`service:${r.id}:stop-failed`); continue } }
312
- }
313
- for (let i = 0; i < 50 && !absent(r.pid); i++) await new Promise(resolve => setTimeout(resolve, 100))
314
- if (!absent(r.pid)) { unresolved.push(`service:${r.id}:still-running`); continue }
315
- }
316
- // Root exit alone does not prove its descendants exited. It is safe to
317
- // resolve once none of the declared ports is still listening; otherwise
318
- // keep the receipt as evidence (fail closed).
319
- if (await waitReceiptResolvable(r, discovered[r.id]?.ports)) {
320
- removeReceipt(discovery, r.id)
321
- stopped.push(r.id)
322
- } else unresolved.push(`service:${r.id}:descendants-unverified`)
323
- }
324
- return { stopped, unresolved }
325
- }
@@ -28,6 +28,22 @@ function anyTypeMatches(patterns, type) {
28
28
  return (patterns || []).some((p) => typeMatches(p, type))
29
29
  }
30
30
 
31
+ /** 双向通配匹配:声明侧或查询侧任一带 `/*` 通配都要能命中。
32
+ * 旧实现只把声明当 pattern、查询当 type,查询侧通配(conductor 问「谁产出
33
+ * artifact:image/*」)永远不命中具体类型。 */
34
+ function typesOverlap(declPatterns, queryType) {
35
+ return (declPatterns || []).some((p) => typeMatches(p, queryType) || typeMatches(queryType, p))
36
+ }
37
+
38
+ /** 深冻结:描述符的 produces/consumes/surface/provides 等嵌套结构也要不可变,
39
+ * 否则注册后仍能被外部改写,注册表的「单一真源」失真。 */
40
+ function deepFreeze(value) {
41
+ if (!value || typeof value !== 'object' || Object.isFrozen(value)) return value
42
+ Object.freeze(value)
43
+ for (const key of Object.keys(value)) deepFreeze(value[key])
44
+ return value
45
+ }
46
+
31
47
  /** 最小结构兜底:name/suite/controlMode/kind 必须在场且合法。深度校验走注入的 validate。 */
32
48
  function structuralCheck(descriptor) {
33
49
  const errors = []
@@ -48,7 +64,7 @@ export function createDescriptorRegistry({ validate } = {}) {
48
64
  /** @type {Map<string, {descriptor:object, suite:string, baseUrl:string, registeredAt:number}>} */
49
65
  const entries = new Map()
50
66
 
51
- function register(descriptor, { suite, baseUrl = '' } = {}) {
67
+ function register(descriptor, { suite, baseUrl = '', force = false } = {}) {
52
68
  const merged = { ...descriptor, suite: descriptor?.suite || suite }
53
69
  const errors = structuralCheck(merged)
54
70
  if (errors.length) {
@@ -64,8 +80,16 @@ export function createDescriptorRegistry({ validate } = {}) {
64
80
  throw err
65
81
  }
66
82
  }
83
+ /* owner 校验:同名描述符已属另一套件时拒绝静默覆盖(防跨套件抢占);
84
+ * 同套件热重载刷新放行,确需跨套件替换须显式 force。 */
85
+ const existing = entries.get(merged.name)
86
+ if (existing && existing.suite !== merged.suite && !force) {
87
+ const err = new Error(`能力描述符 ${merged.name} 已属套件 ${existing.suite},套件 ${merged.suite} 不能覆盖(如确需替换请传 force)`)
88
+ err.code = 'DESCRIPTOR_OWNER_CONFLICT'
89
+ throw err
90
+ }
67
91
  const entry = Object.freeze({
68
- descriptor: Object.freeze({ ...merged }),
92
+ descriptor: deepFreeze({ ...merged }),
69
93
  suite: merged.suite,
70
94
  baseUrl: String(baseUrl || ''),
71
95
  registeredAt: Date.now(),
@@ -92,8 +116,8 @@ export function createDescriptorRegistry({ validate } = {}) {
92
116
  if (query.suite && entry.suite !== query.suite) continue
93
117
  if (query.controlMode && d.controlMode !== query.controlMode) continue
94
118
  if (query.kind && d.kind !== query.kind) continue
95
- if (query.produces && !anyTypeMatches(d.produces, query.produces)) continue
96
- if (query.consumes && !anyTypeMatches(d.consumes, query.consumes)) continue
119
+ if (query.produces && !typesOverlap(d.produces, query.produces)) continue
120
+ if (query.consumes && !typesOverlap(d.consumes, query.consumes)) continue
97
121
  out.push(entry)
98
122
  }
99
123
  return out
@@ -166,7 +166,28 @@ export function createRegistry(capabilities, { enabled = null, ports = null, rep
166
166
  }),
167
167
  }
168
168
 
169
- return { TOOLS, TOOL_IMPL, TOOL_META, FEATURES, CAPABILITIES, ctx }
169
+ /* 动态增删工具:配合 MCP 活引用(tools/list 读 registry.TOOLS),注册/注销后
170
+ * 客户端重新 list 即见最新工具集,无需重建 handler。旧 registry 是纯静态,
171
+ * 套件热重载/能力开关无法反映到工具面。 */
172
+ function registerTool(tool, capabilityId = '') {
173
+ if (!tool || typeof tool.name !== 'string' || !tool.name) throw new Error('registerTool 需要 tool.name')
174
+ if (typeof tool.handler !== 'function') throw new Error(`工具 ${tool.name} 需要 handler`)
175
+ if (TOOL_IMPL[tool.name]) throw new Error(`工具已存在: ${tool.name}`)
176
+ TOOLS.push({ name: tool.name, description: tool.description || '', inputSchema: tool.inputSchema || { type: 'object', properties: {} } })
177
+ TOOL_META[tool.name] = { kind: tool.kind || 'write', since: tool.since || '1.0.0', capability: capabilityId }
178
+ TOOL_IMPL[tool.name] = (args) => tool.handler(args || {}, ctx)
179
+ return true
180
+ }
181
+ function unregisterTool(name) {
182
+ const index = TOOLS.findIndex((tool) => tool.name === name)
183
+ if (index < 0) return false
184
+ TOOLS.splice(index, 1)
185
+ delete TOOL_IMPL[name]
186
+ delete TOOL_META[name]
187
+ return true
188
+ }
189
+
190
+ return { TOOLS, TOOL_IMPL, TOOL_META, FEATURES, CAPABILITIES, ctx, registerTool, unregisterTool }
170
191
  }
171
192
 
172
193
  /** 与 MCP 工具面解耦:调用前统一校验。 */
@@ -199,21 +220,26 @@ export function createToolDispatcher({ tools, callTool }) {
199
220
  * { tools, callTool }(旧 relay 形态)
200
221
  * @param {{ registry?: object, tools?: Array, toolImpl?: object, callTool?: Function, serverInfo?: object, instructions?: string }} options
201
222
  */
202
- export function createMcpHandler({ registry, tools, toolImpl, callTool, serverInfo, instructions } = {}) {
203
- const list = tools || registry?.TOOLS || []
223
+ export function createMcpHandler({ registry, tools, toolImpl, callTool, serverInfo, instructions, listChanged } = {}) {
224
+ /* registry 形态走活引用:tools/list 每次读 registry.TOOLS,callTool 读 registry.TOOL_IMPL,
225
+ * 于是 registerTool/unregisterTool 的动态增删立刻可见,无需重建 handler。 */
226
+ const useRegistry = !tools && !!registry
204
227
  const impl = toolImpl || registry?.TOOL_IMPL || null
205
- if (!Array.isArray(list) || !list.length) throw new Error('createMcpHandler: 没有工具可暴露')
228
+ const staticList = tools || null
229
+ if (!useRegistry && (!Array.isArray(staticList) || !staticList.length)) throw new Error('createMcpHandler: 没有工具可暴露')
206
230
  if (!impl && typeof callTool !== 'function') throw new Error('createMcpHandler: 需要 toolImpl 或 callTool')
207
231
  return createKitMcpHandler({
208
- tools: list,
232
+ tools: useRegistry ? () => registry.TOOLS : staticList,
209
233
  callTool: (name, args, context) => {
210
234
  if (typeof callTool === 'function' && !impl) return callTool(name, args, context)
211
- const fn = impl[name]
235
+ const source = useRegistry ? registry.TOOL_IMPL : impl
236
+ const fn = source[name]
212
237
  if (!fn) throw new Error(`未知工具: ${name}`)
213
238
  return fn(args, context)
214
239
  },
215
240
  serverInfo: serverInfo || { name: 'dsh-tool-host', version: '0.1.0' },
216
241
  instructions,
242
+ listChanged,
217
243
  })
218
244
  }
219
245
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capyclaw/ppt-suite",
3
- "version": "2.5.67",
3
+ "version": "2.5.68",
4
4
  "description": "PPT 工作台套件:workbench + 2 个独立 skill 包 + 文档工作台框架 + 底层 kit + 服务中间件(broker)与技能服务;公共基建(os / toolHost / serviceHost / assets / serviceBroker / editorHost)由 @capyclaw/core 统一提供,需同一 profile 启用它。",
5
5
  "type": "module",
6
6
  "main": "./lib/index.mjs",
@@ -24,11 +24,12 @@
24
24
  "@capyclaw/ppt-editor": "^1.1.0",
25
25
  "@capyclaw/ppt-skill-api": "^2.3.4",
26
26
  "@capyclaw/ppt-skill-proposal": "^2.4.0",
27
- "@capyclaw/ppt-workbench": "^2.5.67",
27
+ "@capyclaw/ppt-workbench": "^2.5.68",
28
28
  "@capyclaw/service-broker": "^0.2.25",
29
29
  "@capyclaw/service-host": "^0.1.5",
30
30
  "@capyclaw/skills-service": "^0.2.2",
31
- "@capyclaw/tool-host": "^0.2.0"
31
+ "@capyclaw/tool-host": "^0.2.0",
32
+ "playwright": "^1.64.1"
32
33
  },
33
34
  "dsh": {
34
35
  "bundle": {
@@ -92,7 +93,6 @@
92
93
  "jszip",
93
94
  "lie",
94
95
  "pako",
95
- "playwright-core",
96
96
  "pptxgenjs",
97
97
  "process-nextick-args",
98
98
  "queue",
@@ -1,202 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Portions Copyright (c) Microsoft Corporation.
190
- Portions Copyright 2017 Google Inc.
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
@@ -1,5 +0,0 @@
1
- Playwright
2
- Copyright (c) Microsoft Corporation
3
-
4
- This software contains code derived from the Puppeteer project (https://github.com/puppeteer/puppeteer),
5
- available under the Apache 2.0 license (https://github.com/puppeteer/puppeteer/blob/master/LICENSE).
@@ -1,3 +0,0 @@
1
- # playwright-core
2
-
3
- This package contains the no-browser flavor of [Playwright](http://github.com/microsoft/playwright).
@@ -1,13 +0,0 @@
1
- microsoft/playwright-core
2
-
3
- THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
4
-
5
- This package bundles third-party software inside individual files under
6
- `lib/`. Each bundled output has a sidecar `<bundle>.js.LICENSE` file next
7
- to it listing every npm package whose source was inlined into that
8
- bundle, together with the full license text for each.
9
-
10
- For example:
11
- - lib/utilsBundle.js.LICENSE
12
-
13
- This project incorporates components from the projects listed below. The original copyright notices and the licenses under which Microsoft received such components are set forth below. Microsoft reserves all rights not expressly granted herein, whether by implication, estoppel or otherwise.
@@ -1,5 +0,0 @@
1
- $osInfo = Get-WmiObject -Class Win32_OperatingSystem
2
- # check if running on Windows Server
3
- if ($osInfo.ProductType -eq 3) {
4
- Install-WindowsFeature Server-Media-Foundation
5
- }
@@ -1,33 +0,0 @@
1
- $ErrorActionPreference = 'Stop'
2
-
3
- # This script sets up a WSL distribution that will be used to run WebKit.
4
-
5
- $Distribution = "playwright"
6
- $Username = "pwuser"
7
-
8
- $distributions = (wsl --list --quiet) -split "\r?\n"
9
- if ($distributions -contains $Distribution) {
10
- Write-Host "WSL distribution '$Distribution' already exists. Skipping installation."
11
- } else {
12
- Write-Host "Installing new WSL distribution '$Distribution'..."
13
- $VhdSize = "10GB"
14
- wsl --install -d Ubuntu-24.04 --name $Distribution --no-launch --vhd-size $VhdSize
15
- wsl -d $Distribution -u root adduser --gecos GECOS --disabled-password $Username
16
- }
17
-
18
- $pwshDirname = (Resolve-Path -Path $PSScriptRoot).Path;
19
- $playwrightCoreRoot = Resolve-Path (Join-Path $pwshDirname "..")
20
-
21
- $initScript = @"
22
- if [ ! -f "/home/$Username/node/bin/node" ]; then
23
- mkdir -p /home/$Username/node
24
- curl -fsSL https://nodejs.org/dist/v22.17.0/node-v22.17.0-linux-x64.tar.xz -o /home/$Username/node/node-v22.17.0-linux-x64.tar.xz
25
- tar -xJf /home/$Username/node/node-v22.17.0-linux-x64.tar.xz -C /home/$Username/node --strip-components=1
26
- sudo -u $Username echo 'export PATH=/home/$Username/node/bin:\`$PATH' >> /home/$Username/.profile
27
- fi
28
- /home/$Username/node/bin/node cli.js install-deps webkit
29
- sudo -u $Username PLAYWRIGHT_SKIP_BROWSER_GC=1 /home/$Username/node/bin/node cli.js install webkit
30
- "@ -replace "\r\n", "`n"
31
-
32
- wsl -d $Distribution --cd $playwrightCoreRoot -u root -- bash -c "$initScript"
33
- Write-Host "Done!"