@capyclaw/ppt-suite 2.5.67 → 2.5.69

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 (147) 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 +92 -6
  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/abi/loader.mjs +8 -1
  8. package/node_modules/@capyclaw/foundation/abi/spec.mjs +5 -2
  9. package/node_modules/@capyclaw/foundation/abi/version.mjs +63 -5
  10. package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +11 -10
  11. package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +8 -1
  12. package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +31 -3
  13. package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +12 -2
  14. package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +0 -81
  15. package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +13 -6
  16. package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +31 -15
  17. package/node_modules/@capyclaw/ppt-editor/contract/ppt-contract.json +1 -1
  18. package/node_modules/@capyclaw/ppt-skill-api/contract/ppt-contract.json +1 -1
  19. package/node_modules/@capyclaw/ppt-skill-api/skills/pptist-api/references/tool-contract.md +1 -1
  20. package/node_modules/@capyclaw/ppt-skill-proposal/contract/ppt-contract.json +1 -1
  21. package/node_modules/@capyclaw/ppt-workbench/contract/ppt-contract.json +1 -1
  22. package/node_modules/@capyclaw/ppt-workbench/package.json +1 -1
  23. package/node_modules/@capyclaw/ppt-workbench/server/contract.mjs +1 -1
  24. package/node_modules/@capyclaw/ppt-workbench/server/relay.mjs +18 -18
  25. package/node_modules/@capyclaw/ppt-workbench/server/routes/session.mjs +8 -1
  26. package/node_modules/@capyclaw/ppt-workbench/server/store/sessions.mjs +15 -4
  27. package/node_modules/@capyclaw/service-broker/lib/manifest.mjs +15 -2
  28. package/node_modules/@capyclaw/service-broker/lib/recovery.mjs +0 -50
  29. package/node_modules/@capyclaw/service-host/src/index.mjs +9 -1
  30. package/node_modules/@capyclaw/tool-host/src/descriptors.mjs +28 -4
  31. package/node_modules/@capyclaw/tool-host/src/index.mjs +32 -6
  32. package/package.json +4 -4
  33. package/node_modules/playwright-core/LICENSE +0 -202
  34. package/node_modules/playwright-core/NOTICE +0 -5
  35. package/node_modules/playwright-core/README.md +0 -3
  36. package/node_modules/playwright-core/ThirdPartyNotices.txt +0 -13
  37. package/node_modules/playwright-core/bin/install_media_pack.ps1 +0 -5
  38. package/node_modules/playwright-core/bin/install_webkit_wsl.ps1 +0 -33
  39. package/node_modules/playwright-core/bin/reinstall_chrome_beta_linux.sh +0 -42
  40. package/node_modules/playwright-core/bin/reinstall_chrome_beta_mac.sh +0 -13
  41. package/node_modules/playwright-core/bin/reinstall_chrome_beta_win.ps1 +0 -24
  42. package/node_modules/playwright-core/bin/reinstall_chrome_stable_linux.sh +0 -42
  43. package/node_modules/playwright-core/bin/reinstall_chrome_stable_mac.sh +0 -12
  44. package/node_modules/playwright-core/bin/reinstall_chrome_stable_win.ps1 +0 -24
  45. package/node_modules/playwright-core/bin/reinstall_msedge_beta_linux.sh +0 -48
  46. package/node_modules/playwright-core/bin/reinstall_msedge_beta_mac.sh +0 -11
  47. package/node_modules/playwright-core/bin/reinstall_msedge_beta_win.ps1 +0 -23
  48. package/node_modules/playwright-core/bin/reinstall_msedge_dev_linux.sh +0 -48
  49. package/node_modules/playwright-core/bin/reinstall_msedge_dev_mac.sh +0 -11
  50. package/node_modules/playwright-core/bin/reinstall_msedge_dev_win.ps1 +0 -23
  51. package/node_modules/playwright-core/bin/reinstall_msedge_stable_linux.sh +0 -48
  52. package/node_modules/playwright-core/bin/reinstall_msedge_stable_mac.sh +0 -11
  53. package/node_modules/playwright-core/bin/reinstall_msedge_stable_win.ps1 +0 -24
  54. package/node_modules/playwright-core/browsers.json +0 -52
  55. package/node_modules/playwright-core/cli.js +0 -22
  56. package/node_modules/playwright-core/index.d.ts +0 -17
  57. package/node_modules/playwright-core/index.js +0 -17
  58. package/node_modules/playwright-core/index.mjs +0 -28
  59. package/node_modules/playwright-core/lib/bootstrap.js +0 -149
  60. package/node_modules/playwright-core/lib/coreBundle.js +0 -78041
  61. package/node_modules/playwright-core/lib/entry/cliDaemon.js +0 -5
  62. package/node_modules/playwright-core/lib/entry/dashboardApp.js +0 -3
  63. package/node_modules/playwright-core/lib/entry/mcp.js +0 -10
  64. package/node_modules/playwright-core/lib/entry/oopBrowserDownload.js +0 -3
  65. package/node_modules/playwright-core/lib/package.js +0 -50
  66. package/node_modules/playwright-core/lib/server/chromium/appIcon.png +0 -0
  67. package/node_modules/playwright-core/lib/server/electron/loader.js +0 -123
  68. package/node_modules/playwright-core/lib/serverRegistry.js +0 -1939
  69. package/node_modules/playwright-core/lib/serverRegistry.js.LICENSE +0 -65
  70. package/node_modules/playwright-core/lib/tools/cli-client/channelSessions.js +0 -141
  71. package/node_modules/playwright-core/lib/tools/cli-client/cli.js +0 -7
  72. package/node_modules/playwright-core/lib/tools/cli-client/help.json +0 -808
  73. package/node_modules/playwright-core/lib/tools/cli-client/minimist.js +0 -128
  74. package/node_modules/playwright-core/lib/tools/cli-client/output.js +0 -352
  75. package/node_modules/playwright-core/lib/tools/cli-client/program.js +0 -422
  76. package/node_modules/playwright-core/lib/tools/cli-client/registry.js +0 -180
  77. package/node_modules/playwright-core/lib/tools/cli-client/session.js +0 -261
  78. package/node_modules/playwright-core/lib/tools/dashboard/appIcon.png +0 -0
  79. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/SKILL.md +0 -493
  80. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/element-attributes.md +0 -23
  81. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/playwright-tests.md +0 -39
  82. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/pr-attachments.md +0 -60
  83. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/request-mocking.md +0 -87
  84. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/running-code.md +0 -245
  85. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/session-management.md +0 -227
  86. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/storage-state.md +0 -275
  87. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/test-generation.md +0 -433
  88. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/tracing.md +0 -139
  89. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/video-recording.md +0 -216
  90. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/SKILL.md +0 -136
  91. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +0 -144
  92. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/migration.md +0 -89
  93. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/react.md +0 -69
  94. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/typing.md +0 -173
  95. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/vue.md +0 -77
  96. package/node_modules/playwright-core/lib/tools/skills/playwright-trace/SKILL.md +0 -174
  97. package/node_modules/playwright-core/lib/tools/utils/extension.js +0 -112
  98. package/node_modules/playwright-core/lib/tools/utils/socketConnection.js +0 -108
  99. package/node_modules/playwright-core/lib/utilsBundle.js +0 -86078
  100. package/node_modules/playwright-core/lib/utilsBundle.js.LICENSE +0 -1890
  101. package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +0 -1
  102. package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +0 -32
  103. package/node_modules/playwright-core/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
  104. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +0 -1
  105. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +0 -1
  106. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +0 -1
  107. package/node_modules/playwright-core/lib/vite/dashboard/assets/index-AwgwcYie.css +0 -1
  108. package/node_modules/playwright-core/lib/vite/dashboard/assets/index-hRvO4yU2.js +0 -12
  109. package/node_modules/playwright-core/lib/vite/dashboard/assets/safari-na3_-uQk.svg +0 -1
  110. package/node_modules/playwright-core/lib/vite/dashboard/index.html +0 -29
  111. package/node_modules/playwright-core/lib/vite/dashboard/playwright-logo.svg +0 -24
  112. package/node_modules/playwright-core/lib/vite/htmlReport/index.html +0 -16
  113. package/node_modules/playwright-core/lib/vite/htmlReport/report.css +0 -2
  114. package/node_modules/playwright-core/lib/vite/htmlReport/report.js +0 -32
  115. package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +0 -1
  116. package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule-DK72OMRi.js +0 -32
  117. package/node_modules/playwright-core/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
  118. package/node_modules/playwright-core/lib/vite/recorder/assets/index-BZpYJZ-P.css +0 -1
  119. package/node_modules/playwright-core/lib/vite/recorder/assets/index-Cn0mmDuv.js +0 -129
  120. package/node_modules/playwright-core/lib/vite/recorder/index.html +0 -29
  121. package/node_modules/playwright-core/lib/vite/recorder/playwright-logo.svg +0 -9
  122. package/node_modules/playwright-core/lib/vite/traceViewer/assets/codeMirrorModule-BEB2e8M3.js +0 -32
  123. package/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-D-g2vrvf.js +0 -184
  124. package/node_modules/playwright-core/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +0 -1
  125. package/node_modules/playwright-core/lib/vite/traceViewer/assets/xtermModule-B794rD2Z.js +0 -7
  126. package/node_modules/playwright-core/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +0 -1
  127. package/node_modules/playwright-core/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
  128. package/node_modules/playwright-core/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +0 -1
  129. package/node_modules/playwright-core/lib/vite/traceViewer/index.B_TqY17P.css +0 -1
  130. package/node_modules/playwright-core/lib/vite/traceViewer/index.html +0 -44
  131. package/node_modules/playwright-core/lib/vite/traceViewer/index.oNry3Hjv.js +0 -1
  132. package/node_modules/playwright-core/lib/vite/traceViewer/manifest.webmanifest +0 -16
  133. package/node_modules/playwright-core/lib/vite/traceViewer/playwright-logo.svg +0 -9
  134. package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +0 -1
  135. package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.html +0 -10
  136. package/node_modules/playwright-core/lib/vite/traceViewer/sw.bundle.js +0 -4
  137. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CYwC_gH1.js +0 -5
  138. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +0 -1
  139. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +0 -18
  140. package/node_modules/playwright-core/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +0 -1
  141. package/node_modules/playwright-core/lib/webp_codec.LICENSE +0 -173
  142. package/node_modules/playwright-core/lib/webp_codec.wasm +0 -0
  143. package/node_modules/playwright-core/lib/xdg-open +0 -1267
  144. package/node_modules/playwright-core/package.json +0 -34
  145. package/node_modules/playwright-core/types/protocol.d.ts +0 -24776
  146. package/node_modules/playwright-core/types/structs.d.ts +0 -52
  147. package/node_modules/playwright-core/types/types.d.ts +0 -27167
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "suite": "capyclaw-ppt-suite",
3
- "suiteVersion": "2.5.67",
3
+ "suiteVersion": "2.5.69",
4
4
  "packages": {
5
5
  "@capyclaw/asset-service": {
6
6
  "version": "0.1.4",
@@ -51,10 +51,10 @@
51
51
  "sha256": "bde060cee7613c789625ed18b59b7e2bb2ff981aa05363a5d851635000baa6c0"
52
52
  },
53
53
  "@capyclaw/ppt-workbench": {
54
- "version": "2.5.67",
54
+ "version": "2.5.69",
55
55
  "apiVersion": null,
56
56
  "path": "../capyclaw-ppt-workbench",
57
- "sha256": "74f906ae88eade25820c3b0ed467672ac0a8852694a5a6f455f52299590016a0"
57
+ "sha256": "f05aea309ec244ad9b70d13a251e4b9da69c34f4aafd2a09cf79298860274f08"
58
58
  },
59
59
  "@capyclaw/service-broker": {
60
60
  "version": "0.2.25",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "contractVersion": "2.5.0",
3
- "packageVersion": "2.5.67",
3
+ "packageVersion": "2.5.69",
4
4
  "toolCount": 32,
5
5
  "tools": [
6
6
  {
package/dsh-suite.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "../../../../../../C/packages/capyclaw-suite-kit/suite.schema.json",
3
3
  "name": "capyclaw-ppt-suite",
4
- "version": "2.5.67",
4
+ "version": "2.5.69",
5
5
  "title": "PPT 工作台套件",
6
6
  "description": "PPT 工作台套件:workbench + 2 个独立 skill 包 + 文档工作台框架 + 底层 kit + 服务中间件(broker)与技能服务;公共基建(os / toolHost / serviceHost / assets / serviceBroker / editorHost)由 @capyclaw/core 统一提供,需同一 profile 启用它。",
7
7
  "packages": {
@@ -40,7 +40,7 @@
40
40
  "version": "^2.3.4",
41
41
  "path": "./node_modules/@capyclaw/ppt-skill-api",
42
42
  "requires": {
43
- "@capyclaw/ppt-workbench": "^2.5.67",
43
+ "@capyclaw/ppt-workbench": "^2.5.69",
44
44
  "capabilities": {
45
45
  "ppt.runtime": "^2.5.0"
46
46
  }
@@ -59,7 +59,7 @@
59
59
  "version": "^2.4.0",
60
60
  "path": "./node_modules/@capyclaw/ppt-skill-proposal",
61
61
  "requires": {
62
- "@capyclaw/ppt-workbench": "^2.5.67",
62
+ "@capyclaw/ppt-workbench": "^2.5.69",
63
63
  "capabilities": {
64
64
  "ppt.runtime": "^2.5.0"
65
65
  }
@@ -75,7 +75,7 @@
75
75
  },
76
76
  "@capyclaw/ppt-workbench": {
77
77
  "role": "runtime",
78
- "version": "^2.5.67",
78
+ "version": "^2.5.69",
79
79
  "path": "./node_modules/@capyclaw/ppt-workbench",
80
80
  "requires": {
81
81
  "capabilities": {
@@ -107,16 +107,82 @@ export function createFileAssetStore({ dir } = {}) {
107
107
  if (!validId(id)) return false
108
108
  try { return fs.existsSync(path.join(dir, path.basename(String(id)))) } catch { return false }
109
109
  },
110
+ /** 删除单个对象(data + meta)。内容寻址仓库此前只增不删,磁盘无界增长。 */
111
+ async delete(id) {
112
+ if (!validId(id)) return false
113
+ const file = path.join(dir, path.basename(String(id)))
114
+ let existed = false
115
+ try {
116
+ existed = fs.existsSync(file)
117
+ fs.rmSync(file, { force: true })
118
+ fs.rmSync(file + '.meta.json', { force: true })
119
+ } catch { /* 尽力删除 */ }
120
+ return existed
121
+ },
122
+ /**
123
+ * 垃圾回收:清崩溃残留的孤儿 .tmp、按 mtime 龄淘汰、按总量 LRU 淘汰。
124
+ * keepIds 里的对象(仍被引用)永不删。返回 {removed, freedBytes, orphanTmpRemoved}。
125
+ */
126
+ async gc({ maxAgeMs = 0, maxBytes = 0, keepIds = [] } = {}) {
127
+ const keep = new Set(keepIds)
128
+ const now = Date.now()
129
+ let removed = 0
130
+ let freedBytes = 0
131
+ let orphanTmpRemoved = 0
132
+ let names
133
+ try { names = fs.readdirSync(dir) } catch { return { removed, freedBytes, orphanTmpRemoved } }
134
+ /* 孤儿 tmp:put 中途崩溃留下的半成品,超过 1h 宽限才清(避免误删在途写入)。 */
135
+ for (const name of names) {
136
+ if (!name.includes('.tmp-')) continue
137
+ const full = path.join(dir, name)
138
+ try {
139
+ const st = fs.statSync(full)
140
+ if (now - st.mtimeMs > 3600000) { fs.rmSync(full, { force: true }); orphanTmpRemoved += 1 }
141
+ } catch { /* 忽略 */ }
142
+ }
143
+ const objects = []
144
+ for (const name of fs.readdirSync(dir)) {
145
+ if (!validId(name)) continue
146
+ const full = path.join(dir, name)
147
+ try { const st = fs.statSync(full); objects.push({ id: name, full, size: st.size, mtime: st.mtimeMs }) } catch { /* 忽略 */ }
148
+ }
149
+ const removeObject = (o) => {
150
+ try {
151
+ fs.rmSync(o.full, { force: true })
152
+ fs.rmSync(o.full + '.meta.json', { force: true })
153
+ removed += 1
154
+ freedBytes += o.size
155
+ } catch { /* 忽略 */ }
156
+ }
157
+ if (maxAgeMs > 0) {
158
+ for (const o of objects) {
159
+ if (!keep.has(o.id) && now - o.mtime > maxAgeMs) removeObject(o)
160
+ }
161
+ }
162
+ if (maxBytes > 0) {
163
+ const alive = objects.filter((o) => fs.existsSync(o.full)).sort((a, b) => a.mtime - b.mtime)
164
+ let total = alive.reduce((sum, o) => sum + o.size, 0)
165
+ for (const o of alive) {
166
+ if (total <= maxBytes) break
167
+ if (keep.has(o.id)) continue
168
+ removeObject(o)
169
+ total -= o.size
170
+ }
171
+ }
172
+ return { removed, freedBytes, orphanTmpRemoved }
173
+ },
110
174
  }
111
175
  }
112
176
 
113
- /** 防止 text/html / svg 在 loopback 同源执行脚本;图片仍按原 MIME 内联。 */
177
+ /** 防止 text/html / svg 在 loopback 同源执行脚本;图片仍按原 MIME 内联。
178
+ * 安全类型保留原始参数(charset 等),不再一刀切剥掉——否则文本资产 charset 丢失。 */
114
179
  function safeContentType(type) {
115
- const base = String(type || '').split(';')[0].trim().toLowerCase() || 'application/octet-stream'
180
+ const raw = String(type || '').replace(/[\r\n]/g, '').trim()
181
+ const base = raw.split(';')[0].trim().toLowerCase() || 'application/octet-stream'
116
182
  if (base === 'text/html' || base === 'application/xhtml+xml' || base === 'image/svg+xml') {
117
183
  return 'text/plain; charset=utf-8'
118
184
  }
119
- return base
185
+ return raw || 'application/octet-stream'
120
186
  }
121
187
 
122
188
  /**
@@ -134,7 +200,12 @@ export function createAssetRoutes({ assetStore, basePath = '', maxUploadBytes =
134
200
  const getPrefix = getPrefixes.find((candidate) => p.startsWith(candidate))
135
201
  if (getPrefix) {
136
202
  if (!assetStore) { send(req, res, 404, { error: 'asset store unavailable' }); return true }
137
- const id = decodeURIComponent(p.slice(getPrefix.length))
203
+ let id
204
+ try { id = decodeURIComponent(p.slice(getPrefix.length)) } catch {
205
+ /* 畸形百分号编码(如 /assets/%zz):decodeURIComponent 抛 URIError,
206
+ * 不包会一路冒成 500。这是客户端错误,回 400。 */
207
+ send(req, res, 400, { error: 'malformed asset id encoding' }); return true
208
+ }
138
209
  if (!validId(id)) { send(req, res, 404, { error: 'asset not found' }); return true }
139
210
  const asset = assetStore.get(id)
140
211
  if (!asset) { send(req, res, 404, { error: 'asset not found' }); return true }
@@ -170,7 +241,8 @@ export function createAssetRoutes({ assetStore, basePath = '', maxUploadBytes =
170
241
  }
171
242
  if (!buffer.length) { send(req, res, 400, { error: '图片数据为空' }); return true }
172
243
  const asset = await assetStore.put(buffer, body.contentType || 'application/octet-stream')
173
- send(req, res, 200, { ok: true, ...asset })
244
+ /* 回给与 GET 一致的 sanitized content-type(保留 charset、script 类转 text/plain)。 */
245
+ send(req, res, 200, { ok: true, ...asset, contentType: safeContentType(asset.contentType) })
174
246
  return true
175
247
  }
176
248
  return false
@@ -184,8 +256,14 @@ export function createAssetHost(config = {}) {
184
256
  ? createFileAssetStore({ dir: config.dir })
185
257
  : null
186
258
 
259
+ /* 能力标签如实申报:gc/delete 仅当底层 store 支持时才 advertise(file store 有,
260
+ * workspace store 无),避免「声明满足、活实例缺方法」。 */
261
+ const tags = ['workspace-store', 'file-store', 'routes', 'sha256', 'mount']
262
+ if (typeof defaultStore?.gc === 'function') tags.push('gc')
263
+ if (typeof defaultStore?.delete === 'function') tags.push('delete')
264
+
187
265
  return {
188
- api: createServiceApi('assets', '1.0.0', ['workspace-store', 'file-store', 'routes', 'sha256', 'mount']),
266
+ api: createServiceApi('assets', '1.0.0', tags),
189
267
  version: '0.1.0',
190
268
  createStore: createWorkspaceAssetStore,
191
269
  createFileStore: createFileAssetStore,
@@ -219,5 +297,13 @@ export function createAssetHost(config = {}) {
219
297
  if (!defaultStore) throw new Error('asset-service: 未配置 storeClient/dir')
220
298
  return defaultStore.get(id)
221
299
  },
300
+ async delete(id) {
301
+ if (typeof defaultStore?.delete !== 'function') throw new Error('asset-service: 当前 store 不支持 delete')
302
+ return defaultStore.delete(id)
303
+ },
304
+ async gc(options) {
305
+ if (typeof defaultStore?.gc !== 'function') throw new Error('asset-service: 当前 store 不支持 gc')
306
+ return defaultStore.gc(options)
307
+ },
222
308
  }
223
309
  }
@@ -18,15 +18,25 @@ import { AsyncLocalStorage } from 'node:async_hooks'
18
18
 
19
19
  const storage = new AsyncLocalStorage()
20
20
 
21
- /** 在指定会话的上下文里跑一段逻辑(await 链与定时器都会继承)。 */
21
+ /** 在指定会话的上下文里跑一段逻辑(await 链与定时器都会继承)。
22
+ * payload 是对象而非裸字符串:除会话 id 外还携带一个「本请求已钉住的 store」槽位,
23
+ * 让 store 门面在请求内首次访问时解析一次并复用,避免请求中途 active 被别的窗口
24
+ * /activate 翻转后,同一请求的后续写入改向到另一个会话(跨会话写)。 */
22
25
  export function runWithSession(sessionId, fn) {
23
- return storage.run(String(sessionId || ''), fn)
26
+ return storage.run({ sid: String(sessionId || ''), pinned: null }, fn)
24
27
  }
25
28
 
26
29
  /** 当前请求所属的会话 id;不在请求里时返回空串。 */
27
30
  export function currentSession() {
28
31
  const value = storage.getStore()
29
- return typeof value === 'string' ? value : ''
32
+ return value && typeof value.sid === 'string' ? value.sid : ''
33
+ }
34
+
35
+ /** 当前请求的会话上下文对象({sid, pinned});不在请求里时返回 null。
36
+ * store 门面用它把「本请求用哪一份 store」钉住一次,整个请求复用。 */
37
+ export function sessionContext() {
38
+ const value = storage.getStore()
39
+ return value && typeof value === 'object' ? value : null
30
40
  }
31
41
 
32
42
  /**
@@ -58,8 +68,10 @@ export function bindToolsToCallerSession(registry) {
58
68
  const bound = (args, exec) => {
59
69
  const sid = sessionFromExec(exec)
60
70
  /* exec 原样透传:今天的实现体只用 args,但未来若有工具要执行上下文
61
- * (进度/中止等),不能在这层被静默丢掉。 */
62
- return sid ? runWithSession(sid, () => impl(args, exec)) : impl(args, exec)
71
+ * (进度/中止等),不能在这层被静默丢掉。
72
+ * 即使拿不到调用者会话(MCP 传输形态)也建立上下文:store 门面会在本次调用
73
+ * 首次访问时把「最近聚焦窗口」钉住,整个工具执行期间不再随 active 翻转改向。 */
74
+ return runWithSession(sid, () => impl(args, exec))
63
75
  }
64
76
  bound.__sessionBound = true
65
77
  impls[name] = bound
@@ -118,7 +118,10 @@ export function createEditorHost({ id, dir, basePath = '', index = 'index.html',
118
118
  const statusPath = `${prefix}/status`
119
119
  if (u.pathname === claimPath && req.method === 'POST') {
120
120
  const body = await readBody(req)
121
- const result = lease.claim(String(body.id || ''), !!body.force)
121
+ const clientId = String(body.id || '')
122
+ /* 空 id 不得认领:否则多个匿名窗口互相覆盖租约,仲裁失去意义。 */
123
+ if (!clientId) { send(req, res, 400, { ok: false, error: 'claim 需要非空 id' }); return true }
124
+ const result = lease.claim(clientId, !!body.force)
122
125
  send(req, res, result.ok ? 200 : 409, result)
123
126
  return true
124
127
  }
@@ -150,7 +153,9 @@ export function createEditorHost({ id, dir, basePath = '', index = 'index.html',
150
153
 
151
154
  export function createEditorHostService(config = {}) {
152
155
  return {
153
- api: createServiceApi('editorHost', '1.0.0', ['static', 'lease', 'heartbeat', 'status']),
156
+ /* 能力如实申报:只声明真正实现的端点。旧实现含 'heartbeat' 但根本没有
157
+ * /heartbeat 端点(心跳走 document-workbench 桥),属虚标,移除。 */
158
+ api: createServiceApi('editorHost', '1.0.0', ['static', 'lease', 'status']),
154
159
  version: '0.1.0',
155
160
  createEditorHost,
156
161
  createLease: createEditorLease,
@@ -2,7 +2,7 @@
2
2
  import { ABI_MAJOR, getInterfaceKind } from './kinds.mjs'
3
3
  import { validateInterface } from './validate.mjs'
4
4
  import { AbiError, ERROR_CODES, toAbiError } from './errors.mjs'
5
- import { satisfies } from './version.mjs'
5
+ import { satisfies, isValidRange } from './version.mjs'
6
6
 
7
7
  const thenable = (value) => value && typeof value.then === 'function'
8
8
 
@@ -164,6 +164,13 @@ export function createLoader({ adapters = {}, capabilities = {}, log = null, abi
164
164
  plugins.delete(spec.name)
165
165
  void previous.handle?.dispose?.()
166
166
  }
167
+ /* 非法范围单独报 E_SCHEMA:旧实现把「range 写错」和「能力真缺」都归成
168
+ * E_CAP_MISSING「能力不可用」,误导排障。先区分两者。 */
169
+ const badRanges = spec.requires.filter((need) => need.name.startsWith('os.') && !isValidRange(need.range))
170
+ if (badRanges.length) {
171
+ throw error(ERROR_CODES.E_SCHEMA, `插件 ${spec.name} 能力范围非法:${badRanges.map((r) => r.raw).join(', ')}`,
172
+ { plugin: spec.name, invalid: badRanges })
173
+ }
167
174
  const missing = spec.requires.filter((need) => need.name.startsWith('os.')
168
175
  && !satisfies(capabilityMap()[need.name] || '', need.range))
169
176
  if (missing.length) {
@@ -191,9 +191,12 @@ export function definePlugin(options = {}) {
191
191
  const requiresEntries = requires.map((entry) => parseCapability(entry, 'requires'))
192
192
  const providesEntries = provides.map((entry) => parseCapability(entry, 'provides'))
193
193
  for (const entry of providesEntries) {
194
- if (/^[\^~<>=]/.test(entry.range)) {
194
+ /* 白名单而非黑名单:provides 必须是完整 x.y.z(可带 prerelease)。旧实现只拒
195
+ * ^~<>= 前缀,'1.x' / '1.*' / 裸 '1' 漏网被当成版本发布,消费方 parseVersion
196
+ * 解析不了 → satisfies 恒 false,能力永远「不可用」。 */
197
+ if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(entry.range)) {
195
198
  throw new AbiError(ERROR_CODES.E_PLUGIN_SHAPE,
196
- `provides 必须写精确版本,不能写范围:${entry.raw}`, { entry: entry.raw })
199
+ `provides 必须写精确版本(x.y.z),不能写范围:${entry.raw}`, { entry: entry.raw })
197
200
  }
198
201
  }
199
202
 
@@ -2,25 +2,57 @@
2
2
  * 版本与范围:能力声明用 `^1` / `^1.2.0` / `>=1.2` / `1.x` / 精确版本。
3
3
  *
4
4
  * 只实现这份 ABI 需要的语义,不引入 semver 依赖:
5
- * - `^1.2.3` → >=1.2.3 且同主版本;`^0.2.3` → >=0.2.3 且同次版本(0.x 约定)
5
+ * - `^1.2.3` → >=1.2.3 且同主版本;`^0.2.3` → >=0.2.3 且同次版本;
6
+ * `^0.0.3` → >=0.0.3 且同补丁(0.0.x 约定,semver 标准)
6
7
  * - `~1.2.3` → >=1.2.3 且同次版本
7
8
  * - `1.x` / `1.*` → 同主版本
8
9
  * - `>=` `>` `<=` `<` `=` 前缀
9
10
  * - 裸版本 → 精确匹配(比较时忽略末位 0)
11
+ * - prerelease 保留并参与比较:1.0.0-beta < 1.0.0;带 prerelease 的版本只满足
12
+ * 同 [major,minor,patch] 且同样带 prerelease 的范围(semver 标准,避免预发布
13
+ * 版本被当成正式版本放行)。
10
14
  */
11
15
 
12
16
  export function parseVersion(text) {
13
17
  if (typeof text !== 'string') return null
14
- const match = /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-[0-9A-Za-z.-]+)?$/.exec(text.trim())
18
+ const match = /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-([0-9A-Za-z.-]+))?$/.exec(text.trim())
15
19
  if (!match) return null
16
- return [Number(match[1]), Number(match[2] || 0), Number(match[3] || 0)]
20
+ const parts = [Number(match[1]), Number(match[2] || 0), Number(match[3] || 0)]
21
+ parts.prerelease = match[4] || null
22
+ return parts
23
+ }
24
+
25
+ function comparePrerelease(a, b) {
26
+ /* 无 prerelease > 有 prerelease(1.0.0 > 1.0.0-beta)。 */
27
+ if (!a && !b) return 0
28
+ if (!a) return 1
29
+ if (!b) return -1
30
+ const left = a.split('.')
31
+ const right = b.split('.')
32
+ for (let i = 0; i < Math.max(left.length, right.length); i++) {
33
+ const x = left[i]
34
+ const y = right[i]
35
+ if (x === undefined) return -1
36
+ if (y === undefined) return 1
37
+ const xn = /^\d+$/.test(x)
38
+ const yn = /^\d+$/.test(y)
39
+ if (xn && yn) {
40
+ const d = Number(x) - Number(y)
41
+ if (d !== 0) return d < 0 ? -1 : 1
42
+ } else if (xn !== yn) {
43
+ return xn ? -1 : 1 // 数字标识符 < 字母数字标识符
44
+ } else if (x !== y) {
45
+ return x < y ? -1 : 1
46
+ }
47
+ }
48
+ return 0
17
49
  }
18
50
 
19
51
  function compareParts(a, b) {
20
52
  for (let i = 0; i < 3; i++) {
21
53
  if (a[i] !== b[i]) return a[i] < b[i] ? -1 : 1
22
54
  }
23
- return 0
55
+ return comparePrerelease(a.prerelease || null, b.prerelease || null)
24
56
  }
25
57
 
26
58
  export function compareVersions(a, b) {
@@ -44,12 +76,23 @@ export function satisfies(version, range) {
44
76
  if (raw.startsWith('^')) {
45
77
  const base = parseVersion(raw.slice(1))
46
78
  if (!base) return false
79
+ /* prerelease 只满足同 [major,minor,patch] 且带 prerelease 的范围(semver 标准),
80
+ * 避免 1.1.0-beta 被 ^1.0.0 当正式版本放行。 */
81
+ if (current.prerelease && (!base.prerelease
82
+ || current[0] !== base[0] || current[1] !== base[1] || current[2] !== base[2])) return false
47
83
  if (compareParts(current, base) < 0) return false
48
- return base[0] === 0 ? current[0] === 0 && current[1] === base[1] : current[0] === base[0]
84
+ if (base[0] === 0) {
85
+ /* 0.0.x caret 收紧到补丁位:^0.0.3 只容 0.0.3,不容 0.0.9。 */
86
+ if (base[1] === 0) return current[0] === 0 && current[1] === 0 && current[2] === base[2]
87
+ return current[0] === 0 && current[1] === base[1]
88
+ }
89
+ return current[0] === base[0]
49
90
  }
50
91
  if (raw.startsWith('~')) {
51
92
  const base = parseVersion(raw.slice(1))
52
93
  if (!base) return false
94
+ if (current.prerelease && (!base.prerelease
95
+ || current[0] !== base[0] || current[1] !== base[1] || current[2] !== base[2])) return false
53
96
  return compareParts(current, base) >= 0 && current[0] === base[0] && current[1] === base[1]
54
97
  }
55
98
  if (raw.startsWith('>=')) {
@@ -80,3 +123,18 @@ export function satisfies(version, range) {
80
123
  const exact = parseVersion(raw)
81
124
  return Boolean(exact) && compareParts(current, exact) === 0
82
125
  }
126
+
127
+ /**
128
+ * 范围是否「语义合法」(区别于「合法但不满足」)。供加载器把非法范围单独报
129
+ * E_SCHEMA,而不是误归因成「能力不可用」误导排障。空范围视为「任意」,合法。
130
+ */
131
+ export function isValidRange(range) {
132
+ const raw = String(range ?? '').trim()
133
+ if (!raw || raw === '*' || raw === 'x') return true
134
+ if (/^[\^~]/.test(raw)) return Boolean(parseVersion(raw.slice(1)))
135
+ if (/^(>=|<=)/.test(raw)) return Boolean(parseVersion(raw.slice(2)))
136
+ if (/^[><]/.test(raw)) return Boolean(parseVersion(raw.slice(1)))
137
+ if (raw.startsWith('=')) return isValidRange(raw.slice(1))
138
+ if (/^(\d+)(?:\.(\d+))?\.[x*]$/.test(raw)) return true
139
+ return Boolean(parseVersion(raw))
140
+ }
@@ -44,18 +44,19 @@ export function createRawAdapter({ log }) {
44
44
 
45
45
  if (thenable(result)) {
46
46
  let instance = {}
47
- let settled = false
48
- const started = Promise.resolve(result).then((value) => {
49
- instance = normalize(value)
50
- settled = true
51
- return instance.start ? instance.start() : undefined
52
- })
47
+ /* apply 结算只做归一化,绝不在此 eagerly 跑 instance.start()——旧实现
48
+ * 在 compile 返回的 promise resolve 时就启动,绕过 loader 的 start 阶段与
49
+ * stopRequested:loader 正在回滚/已请求卸载时 raw 仍会起进程/监听。
50
+ * start 交给 loader 在 start 阶段显式触发(此时才尊重 stopRequested)。 */
51
+ const ready = Promise.resolve(result).then((value) => { instance = normalize(value) })
53
52
  return {
54
- start: () => started,
53
+ start: async ({ signal } = {}) => {
54
+ await ready
55
+ /* 转发 loader 的卸载 signal,让 raw 实例的 start 也能感知取消。 */
56
+ return instance.start ? instance.start({ signal }) : undefined
57
+ },
55
58
  dispose: async () => {
56
- if (!settled) {
57
- try { await started } catch { /* start 失败由 loader 记录 */ }
58
- }
59
+ try { await ready } catch { /* apply 失败由 loader 记录 */ }
59
60
  if (typeof instance.dispose === 'function') return instance.dispose()
60
61
  },
61
62
  }
@@ -62,14 +62,21 @@ export function createRuntimeDriverAdapter({ host, config, log }) {
62
62
  ...(impl.args || []),
63
63
  ]
64
64
 
65
+ /* keepAlive 由声明推导:restart.max===0 表示「不要自动重启」,对应 keepAlive:false。
66
+ * 旧实现恒 true,应用声明 restart:{max:0} 仍被 broker 拉起,切换/回收行为与声明不符。 */
67
+ const keepAlive = !(impl.restart && impl.restart.max === 0)
65
68
  const serviceSpec = {
66
69
  id: impl.id,
67
70
  cmd,
68
71
  ports: { main: port },
69
72
  url: 'http://127.0.0.1:${PORT}/',
70
- keepAlive: true,
73
+ keepAlive,
71
74
  }
72
75
  if (impl.health?.path) serviceSpec.healthPath = impl.health.path
76
+ /* 声明的健康期望/超时与重启策略必须透传给 broker,不能被静默丢弃。 */
77
+ if (impl.health?.expect && typeof impl.health.expect === 'object') serviceSpec.expect = impl.health.expect
78
+ if (impl.health?.timeoutMs) serviceSpec.waitMs = impl.health.timeoutMs
79
+ if (impl.restart) serviceSpec.restart = impl.restart
73
80
  if (impl.dir) {
74
81
  serviceSpec.cwd = fileURLToPath(new URL(impl.dir, mountContext.context.baseUrl))
75
82
  }
@@ -13,12 +13,40 @@ const NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/
13
13
  const DEFAULT_RANK = 600
14
14
 
15
15
  export function parseSkill(raw, path) {
16
+ /* BOM 会让 /^---/ 匹配不到 frontmatter,误报「缺少 YAML frontmatter」。先剥掉。 */
17
+ raw = raw.replace(/^\uFEFF/, '')
16
18
  const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/u.exec(raw)
17
19
  if (!frontmatter?.[1]) throw new Error(`skill ${path} 缺少 YAML frontmatter`)
18
20
  const meta = {}
19
- for (const line of frontmatter[1].split(/\r?\n/)) {
20
- const match = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(line)
21
- if (match) meta[match[1]] = match[2].replace(/^['"]|['"]$/g, '').trim()
21
+ const lines = frontmatter[1].split(/\r?\n/)
22
+ for (let i = 0; i < lines.length; i++) {
23
+ const match = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(lines[i])
24
+ if (!match) continue
25
+ const key = match[1]
26
+ let value = match[2].trim()
27
+ /* 块标量 description: | / > :旧实现把 '|' 本身当成描述直达 LLM,多行正文全丢。
28
+ * 这里聚合后续缩进行,| 保留换行、> 折叠为空格,按 chomping 处理尾部空白。 */
29
+ const block = /^([|>])([+-]?)$/.exec(value)
30
+ if (block) {
31
+ const body = []
32
+ let j = i + 1
33
+ for (; j < lines.length; j++) {
34
+ const ln = lines[j]
35
+ if (ln.trim() === '') { body.push(''); continue }
36
+ if (/^\s/.test(ln)) body.push(ln)
37
+ else break
38
+ }
39
+ i = j - 1
40
+ const nonEmpty = body.filter((l) => l.trim() !== '')
41
+ const minIndent = nonEmpty.length ? Math.min(...nonEmpty.map((l) => /^\s*/.exec(l)[0].length)) : 0
42
+ const stripped = body.map((l) => l.slice(minIndent))
43
+ let text = stripped.join(block[1] === '>' ? ' ' : '\n')
44
+ if (block[2] !== '+') text = text.replace(/\s+$/, '')
45
+ value = text
46
+ } else {
47
+ value = value.replace(/^['"]|['"]$/g, '').trim()
48
+ }
49
+ meta[key] = value
22
50
  }
23
51
  if (!meta.name || !meta.description) throw new Error(`skill ${path} 缺少 name/description`)
24
52
  if (!NAME_RE.test(meta.name)) throw new Error(`skill ${path} name 必须是 kebab-case`)
@@ -91,7 +91,11 @@ export function createNet(host, config = {}) {
91
91
  }
92
92
  return
93
93
  }
94
- await new Promise((resolve) => setTimeout(resolve, WEB_LATE_POLL_MS))
94
+ await new Promise((resolve) => {
95
+ /* unref:迟到补挂的轮询定时器不得拖住进程退出(最长 60s 的尾延迟)。 */
96
+ const timer = setTimeout(resolve, WEB_LATE_POLL_MS)
97
+ timer.unref?.()
98
+ })
95
99
  }
96
100
  })().catch(() => {})
97
101
  }
@@ -116,7 +120,10 @@ export function createNet(host, config = {}) {
116
120
  if (!web && shouldWaitForWeb()) {
117
121
  const deadline = Date.now() + WEB_WAIT_MS
118
122
  while (!web && Date.now() < deadline && !closed) {
119
- await new Promise((resolve) => setTimeout(resolve, WEB_POLL_MS))
123
+ await new Promise((resolve) => {
124
+ const timer = setTimeout(resolve, WEB_POLL_MS)
125
+ timer.unref?.()
126
+ })
120
127
  web = webServer()
121
128
  }
122
129
  }
@@ -140,6 +147,9 @@ export function createNet(host, config = {}) {
140
147
  disposal = (async () => {
141
148
  if (!sharedHost) return
142
149
  // listen 失败由 ready/start 报告;清理仍需执行,且 close 失败不能被吞掉。
150
+ // 注意:dispose 在 listen 失败时仍 RESOLVE(错误经 ready/start 上报)——这是
151
+ // 被 network-lifecycle 测试固化的契约,close 不再二次上抛 listen 错,避免
152
+ // 破坏「清理成功即 dispose 成功」的语义。
143
153
  await listening.catch(() => {})
144
154
  // 迟到补挂的路由要一起撤掉,否则共享宿主关了、宿主网页端口上还留着分发器。
145
155
  try {
@@ -7,7 +7,6 @@
7
7
  import { tuning } from '../tuning.mjs'
8
8
 
9
9
  const DEFAULT_TTL = 15 // 秒
10
- const DEFAULT_HEARTBEAT = 3 // 秒(心跳间隔应小于 TTL)
11
10
 
12
11
  /**
13
12
  * 创建编辑器租约仲裁器。
@@ -57,83 +56,3 @@ export function createEditorLease(opts = {}) {
57
56
  },
58
57
  }
59
58
  }
60
-
61
- /**
62
- * 编辑器端自动挂接循环。
63
- * 首次 claim 强制抢占(后打开者赢),之后静默心跳。
64
- * @param {{
65
- * clientId: string,
66
- * claim: (force: boolean) => Promise<boolean>,
67
- * release?: () => void,
68
- * onActive?: () => void,
69
- * onStandby?: () => void,
70
- * retryMs?: number,
71
- * heartbeatMs?: number,
72
- * setInterval?: (cb: () => void) => any,
73
- * clearInterval?: (handle: any) => void
74
- * }} o
75
- */
76
- export function startAutoAttach(o) {
77
- if (!o || !o.clientId) throw new Error('startAutoAttach: clientId 必填')
78
- if (typeof o.claim !== 'function') throw new Error('startAutoAttach: claim 必须是函数')
79
-
80
- const retryMs = o.retryMs || 1000
81
- const heartbeatMs = o.heartbeatMs || DEFAULT_HEARTBEAT * 1000
82
- const setI = o.setInterval || ((cb) => setInterval(cb, heartbeatMs))
83
- const clearI = o.clearInterval || ((handle) => clearInterval(handle))
84
-
85
- let active = false
86
- let heartbeat = null
87
- let disposed = false
88
-
89
- async function tryClaim(force) {
90
- try {
91
- return await o.claim(force)
92
- } catch {
93
- return false
94
- }
95
- }
96
-
97
- function goActive() {
98
- if (active) return
99
- active = true
100
- try { o.onActive && o.onActive() } catch { /* 用户回调失败不阻塞挂接 */ }
101
- heartbeat = setI(async () => {
102
- if (disposed) return
103
- const ok = await tryClaim(false)
104
- if (!ok) goStandby()
105
- })
106
- }
107
-
108
- function goStandby() {
109
- if (!active) return
110
- active = false
111
- if (heartbeat != null) {
112
- clearI(heartbeat)
113
- heartbeat = null
114
- }
115
- try { o.onStandby && o.onStandby() } catch { /* 静默 */ }
116
- }
117
-
118
- ;(async () => {
119
- let first = true
120
- while (!disposed) {
121
- const ok = await tryClaim(first)
122
- first = false
123
- if (ok) {
124
- goActive()
125
- return
126
- }
127
- await new Promise((resolve) => setTimeout(resolve, retryMs))
128
- }
129
- })()
130
-
131
- return {
132
- get active() { return active },
133
- dispose() {
134
- disposed = true
135
- goStandby()
136
- try { o.release && o.release() } catch { /* 释放失败不阻塞退出 */ }
137
- },
138
- }
139
- }