@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.
- package/composition.lock.json +3 -3
- package/contract/ppt-contract.json +1 -1
- package/dsh-suite.json +4 -4
- package/node_modules/@capyclaw/asset-service/src/index.mjs +86 -5
- package/node_modules/@capyclaw/document-workbench/src/session/context.mjs +17 -5
- package/node_modules/@capyclaw/editor-host/src/index.mjs +7 -2
- package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +11 -10
- package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +8 -1
- package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +31 -3
- package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +0 -81
- package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +13 -6
- package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +31 -15
- package/node_modules/@capyclaw/ppt-editor/contract/ppt-contract.json +1 -1
- package/node_modules/@capyclaw/ppt-skill-api/contract/ppt-contract.json +1 -1
- package/node_modules/@capyclaw/ppt-skill-api/skills/pptist-api/references/tool-contract.md +1 -1
- package/node_modules/@capyclaw/ppt-skill-proposal/contract/ppt-contract.json +1 -1
- package/node_modules/@capyclaw/ppt-workbench/contract/ppt-contract.json +1 -1
- package/node_modules/@capyclaw/ppt-workbench/package.json +1 -1
- package/node_modules/@capyclaw/ppt-workbench/server/contract.mjs +1 -1
- package/node_modules/@capyclaw/ppt-workbench/server/relay.mjs +18 -18
- package/node_modules/@capyclaw/ppt-workbench/server/routes/session.mjs +8 -1
- package/node_modules/@capyclaw/ppt-workbench/server/store/sessions.mjs +15 -4
- package/node_modules/@capyclaw/service-broker/lib/recovery.mjs +0 -50
- package/node_modules/@capyclaw/tool-host/src/descriptors.mjs +28 -4
- package/node_modules/@capyclaw/tool-host/src/index.mjs +32 -6
- package/package.json +4 -4
- package/node_modules/playwright-core/LICENSE +0 -202
- package/node_modules/playwright-core/NOTICE +0 -5
- package/node_modules/playwright-core/README.md +0 -3
- package/node_modules/playwright-core/ThirdPartyNotices.txt +0 -13
- package/node_modules/playwright-core/bin/install_media_pack.ps1 +0 -5
- package/node_modules/playwright-core/bin/install_webkit_wsl.ps1 +0 -33
- package/node_modules/playwright-core/bin/reinstall_chrome_beta_linux.sh +0 -42
- package/node_modules/playwright-core/bin/reinstall_chrome_beta_mac.sh +0 -13
- package/node_modules/playwright-core/bin/reinstall_chrome_beta_win.ps1 +0 -24
- package/node_modules/playwright-core/bin/reinstall_chrome_stable_linux.sh +0 -42
- package/node_modules/playwright-core/bin/reinstall_chrome_stable_mac.sh +0 -12
- package/node_modules/playwright-core/bin/reinstall_chrome_stable_win.ps1 +0 -24
- package/node_modules/playwright-core/bin/reinstall_msedge_beta_linux.sh +0 -48
- package/node_modules/playwright-core/bin/reinstall_msedge_beta_mac.sh +0 -11
- package/node_modules/playwright-core/bin/reinstall_msedge_beta_win.ps1 +0 -23
- package/node_modules/playwright-core/bin/reinstall_msedge_dev_linux.sh +0 -48
- package/node_modules/playwright-core/bin/reinstall_msedge_dev_mac.sh +0 -11
- package/node_modules/playwright-core/bin/reinstall_msedge_dev_win.ps1 +0 -23
- package/node_modules/playwright-core/bin/reinstall_msedge_stable_linux.sh +0 -48
- package/node_modules/playwright-core/bin/reinstall_msedge_stable_mac.sh +0 -11
- package/node_modules/playwright-core/bin/reinstall_msedge_stable_win.ps1 +0 -24
- package/node_modules/playwright-core/browsers.json +0 -52
- package/node_modules/playwright-core/cli.js +0 -22
- package/node_modules/playwright-core/index.d.ts +0 -17
- package/node_modules/playwright-core/index.js +0 -17
- package/node_modules/playwright-core/index.mjs +0 -28
- package/node_modules/playwright-core/lib/bootstrap.js +0 -149
- package/node_modules/playwright-core/lib/coreBundle.js +0 -78041
- package/node_modules/playwright-core/lib/entry/cliDaemon.js +0 -5
- package/node_modules/playwright-core/lib/entry/dashboardApp.js +0 -3
- package/node_modules/playwright-core/lib/entry/mcp.js +0 -10
- package/node_modules/playwright-core/lib/entry/oopBrowserDownload.js +0 -3
- package/node_modules/playwright-core/lib/package.js +0 -50
- package/node_modules/playwright-core/lib/server/chromium/appIcon.png +0 -0
- package/node_modules/playwright-core/lib/server/electron/loader.js +0 -123
- package/node_modules/playwright-core/lib/serverRegistry.js +0 -1939
- package/node_modules/playwright-core/lib/serverRegistry.js.LICENSE +0 -65
- package/node_modules/playwright-core/lib/tools/cli-client/channelSessions.js +0 -141
- package/node_modules/playwright-core/lib/tools/cli-client/cli.js +0 -7
- package/node_modules/playwright-core/lib/tools/cli-client/help.json +0 -808
- package/node_modules/playwright-core/lib/tools/cli-client/minimist.js +0 -128
- package/node_modules/playwright-core/lib/tools/cli-client/output.js +0 -352
- package/node_modules/playwright-core/lib/tools/cli-client/program.js +0 -422
- package/node_modules/playwright-core/lib/tools/cli-client/registry.js +0 -180
- package/node_modules/playwright-core/lib/tools/cli-client/session.js +0 -261
- package/node_modules/playwright-core/lib/tools/dashboard/appIcon.png +0 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/SKILL.md +0 -493
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/element-attributes.md +0 -23
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/playwright-tests.md +0 -39
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/pr-attachments.md +0 -60
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/request-mocking.md +0 -87
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/running-code.md +0 -245
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/session-management.md +0 -227
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/storage-state.md +0 -275
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/test-generation.md +0 -433
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/tracing.md +0 -139
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/video-recording.md +0 -216
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/SKILL.md +0 -136
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +0 -144
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/migration.md +0 -89
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/react.md +0 -69
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/typing.md +0 -173
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/vue.md +0 -77
- package/node_modules/playwright-core/lib/tools/skills/playwright-trace/SKILL.md +0 -174
- package/node_modules/playwright-core/lib/tools/utils/extension.js +0 -112
- package/node_modules/playwright-core/lib/tools/utils/socketConnection.js +0 -108
- package/node_modules/playwright-core/lib/utilsBundle.js +0 -86078
- package/node_modules/playwright-core/lib/utilsBundle.js.LICENSE +0 -1890
- package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +0 -1
- package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +0 -32
- package/node_modules/playwright-core/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +0 -1
- package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +0 -1
- package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +0 -1
- package/node_modules/playwright-core/lib/vite/dashboard/assets/index-AwgwcYie.css +0 -1
- package/node_modules/playwright-core/lib/vite/dashboard/assets/index-hRvO4yU2.js +0 -12
- package/node_modules/playwright-core/lib/vite/dashboard/assets/safari-na3_-uQk.svg +0 -1
- package/node_modules/playwright-core/lib/vite/dashboard/index.html +0 -29
- package/node_modules/playwright-core/lib/vite/dashboard/playwright-logo.svg +0 -24
- package/node_modules/playwright-core/lib/vite/htmlReport/index.html +0 -16
- package/node_modules/playwright-core/lib/vite/htmlReport/report.css +0 -2
- package/node_modules/playwright-core/lib/vite/htmlReport/report.js +0 -32
- package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +0 -1
- package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule-DK72OMRi.js +0 -32
- package/node_modules/playwright-core/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/index-BZpYJZ-P.css +0 -1
- package/node_modules/playwright-core/lib/vite/recorder/assets/index-Cn0mmDuv.js +0 -129
- package/node_modules/playwright-core/lib/vite/recorder/index.html +0 -29
- package/node_modules/playwright-core/lib/vite/recorder/playwright-logo.svg +0 -9
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/codeMirrorModule-BEB2e8M3.js +0 -32
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-D-g2vrvf.js +0 -184
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +0 -1
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/xtermModule-B794rD2Z.js +0 -7
- package/node_modules/playwright-core/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +0 -1
- package/node_modules/playwright-core/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +0 -1
- package/node_modules/playwright-core/lib/vite/traceViewer/index.B_TqY17P.css +0 -1
- package/node_modules/playwright-core/lib/vite/traceViewer/index.html +0 -44
- package/node_modules/playwright-core/lib/vite/traceViewer/index.oNry3Hjv.js +0 -1
- package/node_modules/playwright-core/lib/vite/traceViewer/manifest.webmanifest +0 -16
- package/node_modules/playwright-core/lib/vite/traceViewer/playwright-logo.svg +0 -9
- package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +0 -1
- package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.html +0 -10
- package/node_modules/playwright-core/lib/vite/traceViewer/sw.bundle.js +0 -4
- package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CYwC_gH1.js +0 -5
- package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +0 -1
- package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +0 -18
- package/node_modules/playwright-core/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +0 -1
- package/node_modules/playwright-core/lib/webp_codec.LICENSE +0 -173
- package/node_modules/playwright-core/lib/webp_codec.wasm +0 -0
- package/node_modules/playwright-core/lib/xdg-open +0 -1267
- package/node_modules/playwright-core/package.json +0 -34
- package/node_modules/playwright-core/types/protocol.d.ts +0 -24776
- package/node_modules/playwright-core/types/structs.d.ts +0 -52
- package/node_modules/playwright-core/types/types.d.ts +0 -27167
package/composition.lock.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"suite": "capyclaw-ppt-suite",
|
|
3
|
-
"suiteVersion": "2.5.
|
|
3
|
+
"suiteVersion": "2.5.68",
|
|
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.
|
|
54
|
+
"version": "2.5.68",
|
|
55
55
|
"apiVersion": null,
|
|
56
56
|
"path": "../capyclaw-ppt-workbench",
|
|
57
|
-
"sha256": "
|
|
57
|
+
"sha256": "63ae23e18aeb8ae0fe5066251eb87c1724d64bbf25c003e2f4dd4ca0be62e34b"
|
|
58
58
|
},
|
|
59
59
|
"@capyclaw/service-broker": {
|
|
60
60
|
"version": "0.2.25",
|
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.
|
|
4
|
+
"version": "2.5.68",
|
|
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.
|
|
43
|
+
"@capyclaw/ppt-workbench": "^2.5.68",
|
|
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.
|
|
62
|
+
"@capyclaw/ppt-workbench": "^2.5.68",
|
|
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.
|
|
78
|
+
"version": "^2.5.68",
|
|
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
|
|
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
|
|
185
|
+
return raw || 'application/octet-stream'
|
|
120
186
|
}
|
|
121
187
|
|
|
122
188
|
/**
|
|
@@ -170,7 +236,8 @@ export function createAssetRoutes({ assetStore, basePath = '', maxUploadBytes =
|
|
|
170
236
|
}
|
|
171
237
|
if (!buffer.length) { send(req, res, 400, { error: '图片数据为空' }); return true }
|
|
172
238
|
const asset = await assetStore.put(buffer, body.contentType || 'application/octet-stream')
|
|
173
|
-
|
|
239
|
+
/* 回给与 GET 一致的 sanitized content-type(保留 charset、script 类转 text/plain)。 */
|
|
240
|
+
send(req, res, 200, { ok: true, ...asset, contentType: safeContentType(asset.contentType) })
|
|
174
241
|
return true
|
|
175
242
|
}
|
|
176
243
|
return false
|
|
@@ -184,8 +251,14 @@ export function createAssetHost(config = {}) {
|
|
|
184
251
|
? createFileAssetStore({ dir: config.dir })
|
|
185
252
|
: null
|
|
186
253
|
|
|
254
|
+
/* 能力标签如实申报:gc/delete 仅当底层 store 支持时才 advertise(file store 有,
|
|
255
|
+
* workspace store 无),避免「声明满足、活实例缺方法」。 */
|
|
256
|
+
const tags = ['workspace-store', 'file-store', 'routes', 'sha256', 'mount']
|
|
257
|
+
if (typeof defaultStore?.gc === 'function') tags.push('gc')
|
|
258
|
+
if (typeof defaultStore?.delete === 'function') tags.push('delete')
|
|
259
|
+
|
|
187
260
|
return {
|
|
188
|
-
api: createServiceApi('assets', '1.0.0',
|
|
261
|
+
api: createServiceApi('assets', '1.0.0', tags),
|
|
189
262
|
version: '0.1.0',
|
|
190
263
|
createStore: createWorkspaceAssetStore,
|
|
191
264
|
createFileStore: createFileAssetStore,
|
|
@@ -219,5 +292,13 @@ export function createAssetHost(config = {}) {
|
|
|
219
292
|
if (!defaultStore) throw new Error('asset-service: 未配置 storeClient/dir')
|
|
220
293
|
return defaultStore.get(id)
|
|
221
294
|
},
|
|
295
|
+
async delete(id) {
|
|
296
|
+
if (typeof defaultStore?.delete !== 'function') throw new Error('asset-service: 当前 store 不支持 delete')
|
|
297
|
+
return defaultStore.delete(id)
|
|
298
|
+
},
|
|
299
|
+
async gc(options) {
|
|
300
|
+
if (typeof defaultStore?.gc !== 'function') throw new Error('asset-service: 当前 store 不支持 gc')
|
|
301
|
+
return defaultStore.gc(options)
|
|
302
|
+
},
|
|
222
303
|
}
|
|
223
304
|
}
|
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
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,
|
|
@@ -44,18 +44,19 @@ export function createRawAdapter({ log }) {
|
|
|
44
44
|
|
|
45
45
|
if (thenable(result)) {
|
|
46
46
|
let instance = {}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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: () =>
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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`)
|
|
@@ -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
|
-
}
|
|
@@ -22,12 +22,19 @@ function reply(id, result) {
|
|
|
22
22
|
|
|
23
23
|
export function createMcpHandler({
|
|
24
24
|
tools = [], callTool, serverInfo, instructions,
|
|
25
|
-
maxBodyBytes = 10 * 1024 * 1024, maxBatch = 100,
|
|
25
|
+
maxBodyBytes = 10 * 1024 * 1024, maxBatch = 100, listChanged = false,
|
|
26
26
|
} = {}) {
|
|
27
|
-
|
|
27
|
+
/* tools 可以是静态数组,或一个返回当前数组的函数(活引用)。活引用让
|
|
28
|
+
* tools/list 每次读到最新工具集——registry 动态增删工具后无需重建 handler。 */
|
|
29
|
+
const liveProvider = typeof tools === 'function' ? tools : null
|
|
30
|
+
if (!liveProvider && !Array.isArray(tools)) throw new Error('createMcpHandler: tools 必须是数组或返回数组的函数')
|
|
28
31
|
if (typeof callTool !== 'function') throw new Error('createMcpHandler: callTool 必须是函数')
|
|
29
32
|
|
|
30
|
-
const
|
|
33
|
+
const currentTools = () => {
|
|
34
|
+
const list = liveProvider ? liveProvider() : tools
|
|
35
|
+
return Array.isArray(list) ? list : []
|
|
36
|
+
}
|
|
37
|
+
const toolMapNow = () => new Map(currentTools().map((tool) => [tool.name, tool]))
|
|
31
38
|
|
|
32
39
|
return async function handle(req, res) {
|
|
33
40
|
/* 长工具调用(如截图)期间客户端可能超时断连;socket 的 'error' 事件
|
|
@@ -89,7 +96,7 @@ export function createMcpHandler({
|
|
|
89
96
|
if (method === 'initialize') {
|
|
90
97
|
const result = {
|
|
91
98
|
protocolVersion: String(params?.protocolVersion || DEFAULT_PROTOCOL),
|
|
92
|
-
capabilities: { tools: { listChanged:
|
|
99
|
+
capabilities: { tools: { listChanged: !!listChanged } },
|
|
93
100
|
serverInfo: serverInfo || { name: 'dsh-plugin', version: '0.0.0' },
|
|
94
101
|
}
|
|
95
102
|
if (typeof instructions === 'string' && instructions) result.instructions = instructions
|
|
@@ -101,13 +108,13 @@ export function createMcpHandler({
|
|
|
101
108
|
if (method === 'ping') return isNotification ? null : reply(id, {})
|
|
102
109
|
|
|
103
110
|
if (method === 'tools/list') {
|
|
104
|
-
return isNotification ? null : reply(id, { tools })
|
|
111
|
+
return isNotification ? null : reply(id, { tools: currentTools() })
|
|
105
112
|
}
|
|
106
113
|
|
|
107
114
|
if (method === 'tools/call') {
|
|
108
115
|
const name = params?.name
|
|
109
116
|
const args = params?.arguments && typeof params.arguments === 'object' ? params.arguments : {}
|
|
110
|
-
const tool =
|
|
117
|
+
const tool = toolMapNow().get(name)
|
|
111
118
|
if (!tool) {
|
|
112
119
|
if (isNotification) return null
|
|
113
120
|
return reply(id, {
|
|
@@ -14,24 +14,40 @@
|
|
|
14
14
|
* 返回恒为 {content:[...]}(object),因此 DSH 原生面 output.schema 用 object 恒满足。
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
export
|
|
17
|
+
/** 单个 text 块的默认上限:防 base64/大输出撑爆 LLM 上下文。image 块不受影响。 */
|
|
18
|
+
export const DEFAULT_MAX_TEXT_BYTES = 256 * 1024
|
|
19
|
+
|
|
20
|
+
function capText(text, max) {
|
|
21
|
+
if (!max || max <= 0 || typeof text !== 'string' || text.length <= max) return text
|
|
22
|
+
return `${text.slice(0, max)}\n…[truncated: original ${text.length} chars, limit ${max}]`
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function capContent(content, max) {
|
|
26
|
+
return content.map((block) => (
|
|
27
|
+
block && block.type === 'text' && typeof block.text === 'string'
|
|
28
|
+
? { ...block, text: capText(block.text, max) }
|
|
29
|
+
: block
|
|
30
|
+
))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** 把任意工具返回值归一为 MCP content 形态(并对超限 text 块截断+提示)。 */
|
|
34
|
+
export function normalizeToolResult(out, { maxTextBytes = DEFAULT_MAX_TEXT_BYTES } = {}) {
|
|
19
35
|
const isError = out && typeof out.isError === 'boolean' ? { isError: out.isError } : {}
|
|
36
|
+
let content
|
|
20
37
|
if (out && Array.isArray(out.content)) {
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
content = out.content
|
|
39
|
+
} else if (out && typeof out.text === 'string') {
|
|
40
|
+
content = [{ type: 'text', text: out.text }]
|
|
41
|
+
} else if (typeof out === 'string') {
|
|
42
|
+
content = [{ type: 'text', text: out }]
|
|
43
|
+
} else if (out === undefined || out === null) {
|
|
44
|
+
content = [{ type: 'text', text: '' }]
|
|
45
|
+
} else {
|
|
46
|
+
let text
|
|
47
|
+
try { text = JSON.stringify(out) } catch { text = String(out) }
|
|
48
|
+
content = [{ type: 'text', text: text ?? String(out) }]
|
|
31
49
|
}
|
|
32
|
-
|
|
33
|
-
try { text = JSON.stringify(out) } catch { text = String(out) }
|
|
34
|
-
return { content: [{ type: 'text', text: text ?? String(out) }] }
|
|
50
|
+
return { content: capContent(content, maxTextBytes), ...isError }
|
|
35
51
|
}
|
|
36
52
|
|
|
37
53
|
/** 从归一化结果提取纯文本(用于把失败内容拼成 Error.message)。 */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# PPTist Workbench 工具契约
|
|
2
2
|
|
|
3
3
|
- contractVersion: `2.5.0`
|
|
4
|
-
- packageVersion: `2.5.
|
|
4
|
+
- packageVersion: `2.5.68`
|
|
5
5
|
- toolCount: 32
|
|
6
6
|
- features: `deck.manuscript`, `deck.contract`, `deck.read`, `deck.audit`, `deck.inspect`, `deck.task`, `deck.write`, `deck.compose`, `deck.recolor`, `deck.image`, `media.search`, `deck.screenshot`, `deck.present`, `deck.undo`, `deck.chart`, `deck.table`, `deck.notes`, `deck.shape`, `deck.line`, `deck.formula`, `deck.import`, `deck.export`
|
|
7
7
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capyclaw/ppt-workbench",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.68",
|
|
4
4
|
"description": "PPT 工作台运行时(headless 可用):32 个 ppt_* MCP 工具(导入/导出 PPTX + 图表/表格/公式/形状/线条/备注 + 契约探测);浏览器实时编辑器由可选成员包 @capyclaw/ppt-editor 提供。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./plugin.mjs",
|
|
@@ -10,7 +10,7 @@ import { createCapabilityReport } from './shared/tool-host.mjs'
|
|
|
10
10
|
export const CONTRACT_VERSION = '2.5.0'
|
|
11
11
|
|
|
12
12
|
/** 工作台包版本。 */
|
|
13
|
-
export const PACKAGE_VERSION = '2.5.
|
|
13
|
+
export const PACKAGE_VERSION = '2.5.68'
|
|
14
14
|
|
|
15
15
|
/** 生成模型可读的能力报告(`editorPath` 由 tool-host 从 editorUrl 推出:同源相对路径,不带端口)。 */
|
|
16
16
|
export function capabilityReport(args, editorUrl = '', runtime = {}) {
|