@capyclaw/ppt-suite 2.5.70 → 2.5.71

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 (108) hide show
  1. package/composition.lock.json +27 -27
  2. package/contract/ppt-contract.json +1 -1
  3. package/dsh-suite.json +27 -17
  4. package/node_modules/@capyclaw/asset-service/dsh-suite.json +1 -1
  5. package/node_modules/@capyclaw/asset-service/package.json +1 -1
  6. package/node_modules/@capyclaw/asset-service/src/index.mjs +4 -3
  7. package/node_modules/@capyclaw/document-workbench/package.json +6 -3
  8. package/node_modules/@capyclaw/document-workbench/src/client/index.mjs +56 -3
  9. package/node_modules/@capyclaw/document-workbench/src/client/visibility.mjs +112 -0
  10. package/node_modules/@capyclaw/document-workbench/src/model/manifest.mjs +6 -4
  11. package/node_modules/@capyclaw/document-workbench/src/model/ops.mjs +7 -2
  12. package/node_modules/@capyclaw/document-workbench/src/session/index.mjs +8 -0
  13. package/node_modules/@capyclaw/document-workbench/src/store/file-backend.mjs +17 -10
  14. package/node_modules/@capyclaw/document-workbench/src/store/projection.mjs +39 -0
  15. package/node_modules/@capyclaw/document-workbench/src/testing/index.mjs +14 -11
  16. package/node_modules/@capyclaw/editor-host/dsh-suite.json +1 -1
  17. package/node_modules/@capyclaw/editor-host/package.json +1 -1
  18. package/node_modules/@capyclaw/editor-host/src/index.mjs +12 -21
  19. package/node_modules/@capyclaw/foundation/abi/assets.mjs +26 -0
  20. package/node_modules/@capyclaw/foundation/abi/bridge.mjs +3 -1
  21. package/node_modules/@capyclaw/foundation/abi/index.mjs +15 -0
  22. package/node_modules/@capyclaw/foundation/abi/visibility.mjs +90 -0
  23. package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +21 -4
  24. package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +5 -1
  25. package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +5 -2
  26. package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +4 -0
  27. package/node_modules/@capyclaw/foundation/lib/kernel.mjs +13 -3
  28. package/node_modules/@capyclaw/foundation/package.json +1 -1
  29. package/node_modules/@capyclaw/plugin-kit/package.json +3 -1
  30. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +5 -2
  31. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat.mjs +26 -0
  32. package/node_modules/@capyclaw/plugin-kit/src/service/static.mjs +79 -0
  33. package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +13 -5
  34. package/node_modules/@capyclaw/portal/package.json +1 -1
  35. package/node_modules/@capyclaw/ppt-editor/app.js +458 -10
  36. package/node_modules/@capyclaw/ppt-editor/contract/ppt-contract.json +1 -1
  37. package/node_modules/@capyclaw/ppt-editor/heartbeat-worker.js +5 -2
  38. package/node_modules/@capyclaw/ppt-editor/index.html +4 -0
  39. package/node_modules/@capyclaw/ppt-editor/package.json +2 -2
  40. package/node_modules/@capyclaw/ppt-skill-api/contract/ppt-contract.json +1 -1
  41. package/node_modules/@capyclaw/ppt-skill-api/package.json +1 -1
  42. package/node_modules/@capyclaw/ppt-skill-api/skills/pptist-api/references/tool-contract.md +1 -1
  43. package/node_modules/@capyclaw/ppt-skill-proposal/contract/ppt-contract.json +1 -1
  44. package/node_modules/@capyclaw/ppt-skill-proposal/package.json +1 -1
  45. package/node_modules/@capyclaw/ppt-workbench/contract/ppt-contract.json +1 -1
  46. package/node_modules/@capyclaw/ppt-workbench/core/deck-layout.js +3 -1
  47. package/node_modules/@capyclaw/ppt-workbench/core/ops/slide.js +9 -3
  48. package/node_modules/@capyclaw/ppt-workbench/core/text.js +14 -2
  49. package/node_modules/@capyclaw/ppt-workbench/package.json +10 -8
  50. package/node_modules/@capyclaw/ppt-workbench/plugin.mjs +13 -1
  51. package/node_modules/@capyclaw/ppt-workbench/server/contract.mjs +1 -1
  52. package/node_modules/@capyclaw/ppt-workbench/server/embedded-host.mjs +200 -29
  53. package/node_modules/@capyclaw/ppt-workbench/server/relay.mjs +10 -7
  54. package/node_modules/@capyclaw/ppt-workbench/server/shared/SHARED_MANIFEST.json +4 -4
  55. package/node_modules/@capyclaw/ppt-workbench/server/store/backends/file-backend.mjs +3 -0
  56. package/node_modules/@capyclaw/ppt-workbench/server/store/checkpoints.mjs +4 -1
  57. package/node_modules/@capyclaw/ppt-workbench/server/store/index.mjs +4 -0
  58. package/node_modules/@capyclaw/ppt-workbench/server/store/sessions.mjs +139 -4
  59. package/node_modules/@capyclaw/ppt-workbench/server/store/shape.mjs +37 -0
  60. package/node_modules/@capyclaw/service-broker/README.md +1 -1
  61. package/node_modules/@capyclaw/service-broker/lib/host.mjs +11 -6
  62. package/node_modules/@capyclaw/service-broker/lib/skills-client.mjs +13 -5
  63. package/node_modules/@capyclaw/service-broker/package.json +1 -1
  64. package/node_modules/@capyclaw/service-host/dsh-suite.json +1 -1
  65. package/node_modules/@capyclaw/service-host/package.json +1 -1
  66. package/node_modules/@capyclaw/service-host/src/index.mjs +13 -22
  67. package/node_modules/@capyclaw/skills-service/README.md +42 -10
  68. package/node_modules/@capyclaw/skills-service/package.json +6 -3
  69. package/node_modules/@capyclaw/skills-service/server.mjs +129 -51
  70. package/node_modules/@capyclaw/suite-kit/README.md +289 -0
  71. package/node_modules/@capyclaw/suite-kit/bin/dsh-domain.mjs +98 -0
  72. package/node_modules/@capyclaw/suite-kit/bin/dsh-suite.mjs +174 -0
  73. package/node_modules/@capyclaw/suite-kit/client/embed.js +35 -0
  74. package/node_modules/@capyclaw/suite-kit/domain.schema.json +129 -0
  75. package/node_modules/@capyclaw/suite-kit/package.json +58 -0
  76. package/node_modules/@capyclaw/suite-kit/src/activation-registry.mjs +184 -0
  77. package/node_modules/@capyclaw/suite-kit/src/artifacts.mjs +131 -0
  78. package/node_modules/@capyclaw/suite-kit/src/capability.mjs +181 -0
  79. package/node_modules/@capyclaw/suite-kit/src/compose.mjs +201 -0
  80. package/node_modules/@capyclaw/suite-kit/src/domain.mjs +138 -0
  81. package/node_modules/@capyclaw/suite-kit/src/embed.mjs +81 -0
  82. package/node_modules/@capyclaw/suite-kit/src/host.mjs +230 -0
  83. package/node_modules/@capyclaw/suite-kit/src/index.mjs +24 -0
  84. package/node_modules/@capyclaw/suite-kit/src/manifest.mjs +263 -0
  85. package/node_modules/@capyclaw/suite-kit/src/orchestration.mjs +100 -0
  86. package/node_modules/@capyclaw/suite-kit/src/profile.mjs +584 -0
  87. package/node_modules/@capyclaw/suite-kit/src/surface.mjs +28 -0
  88. package/node_modules/@capyclaw/suite-kit/suite.schema.json +128 -0
  89. package/node_modules/@capyclaw/tool-host/dsh-suite.json +1 -1
  90. package/node_modules/@capyclaw/tool-host/lib/host.mjs +15 -4
  91. package/node_modules/@capyclaw/tool-host/package.json +1 -1
  92. package/node_modules/@capyclaw/tool-host/src/index.mjs +19 -5
  93. package/node_modules/@capyclaw/tool-host/src/mode-gate.mjs +71 -3
  94. package/node_modules/@capyclaw/work-store/README.md +83 -0
  95. package/node_modules/@capyclaw/work-store/STANDARD.md +263 -0
  96. package/node_modules/@capyclaw/work-store/cordis.patch.yml +3 -0
  97. package/node_modules/@capyclaw/work-store/dsh-suite.json +33 -0
  98. package/node_modules/@capyclaw/work-store/icon.svg +7 -0
  99. package/node_modules/@capyclaw/work-store/lib/host.mjs +21 -0
  100. package/node_modules/@capyclaw/work-store/package.json +68 -0
  101. package/node_modules/@capyclaw/work-store/src/backend.mjs +90 -0
  102. package/node_modules/@capyclaw/work-store/src/db.mjs +199 -0
  103. package/node_modules/@capyclaw/work-store/src/envelope.mjs +132 -0
  104. package/node_modules/@capyclaw/work-store/src/index.mjs +571 -0
  105. package/node_modules/@capyclaw/work-store/src/interop.mjs +70 -0
  106. package/node_modules/@capyclaw/work-store/src/refs.mjs +99 -0
  107. package/node_modules/@capyclaw/work-store/src/routes.mjs +135 -0
  108. package/package.json +16 -14
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capyclaw/ppt-skill-api",
3
- "version": "2.3.4",
3
+ "version": "2.3.5",
4
4
  "description": "PPT skill:PPTist 工具契约、稿件语法、容量、检查审计口径、错误处理。",
5
5
  "type": "module",
6
6
  "main": "./plugin.mjs",
@@ -1,7 +1,7 @@
1
1
  # PPTist Workbench 工具契约
2
2
 
3
3
  - contractVersion: `2.5.0`
4
- - packageVersion: `2.5.70`
4
+ - packageVersion: `2.5.71`
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
  "contractVersion": "2.5.0",
3
- "packageVersion": "2.5.70",
3
+ "packageVersion": "2.5.71",
4
4
  "toolCount": 32,
5
5
  "tools": [
6
6
  {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capyclaw/ppt-skill-proposal",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "PPT skill:叙事(SCQA/金字塔/一页一观点)+ 设计基线(单一强调色/反 AI slop)+ 证据分析卡。",
5
5
  "type": "module",
6
6
  "main": "./plugin.mjs",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "contractVersion": "2.5.0",
3
- "packageVersion": "2.5.70",
3
+ "packageVersion": "2.5.71",
4
4
  "toolCount": 32,
5
5
  "tools": [
6
6
  {
@@ -35,9 +35,11 @@ const shapeEl = (id, x, y, w, h, fill, rotate = 0) => ({
35
35
  path: 'M 0 0 L 200 0 L 200 200 L 0 200 Z', viewBox: [200, 200],
36
36
  fill, fixedRatio: false, rotate,
37
37
  })
38
+ /* fit 保留签名但不再写入 clip:PPTist 的 clip 是裁剪范围 {shape,range},不是 object-fit;
39
+ * 写 {type:'cover'} 会让整张图渲染空白(2026-11 事故)。不裁剪=null,与 ppt_image 一致。 */
38
40
  const imageEl = (id, x, y, w, h, src, fit = 'cover') => ({
39
41
  type: 'image', id, left: x, top: y, width: w, height: h,
40
- src: String(src || ''), clip: { type: fit }, fixedRatio: false, rotate: 0,
42
+ src: String(src || ''), clip: null, fixedRatio: false, rotate: 0,
41
43
  })
42
44
  /** 页级 background / accent 覆盖:一张 deck 里允许单页换底色,但仍出自同一份预设。
43
45
  * 换底色必须连带换字色,否则深底配深字——审计会判对比度不足,模型也看不出来。
@@ -1,8 +1,14 @@
1
1
  /** 页面 op:背景、增删改移复制、选中。 */
2
- import { contrast } from '../text.js'
2
+ import { contrast, normalizeImageClip } from '../text.js'
3
3
 
4
4
  const idx = (c) => (c.id != null ? c.id : c.index)
5
5
  const clone = (P, i) => JSON.parse(JSON.stringify(P.getSlides()[i]))
6
+ /* 整页替换/新增时归一 image clip:编译产物或旧落库可能带 {type:'cover'},
7
+ * 不经 makeElement 直接进 PPTist 会渲染空白。统一转合法 clip 或 null。 */
8
+ const cleanSlide = (s) => {
9
+ if (!s || !Array.isArray(s.elements)) return s
10
+ return { ...s, elements: s.elements.map(e => (e && e.type === 'image' ? { ...e, clip: normalizeImageClip(e.clip) } : e)) }
11
+ }
6
12
 
7
13
  export const slideOps = {
8
14
  'set-background': {
@@ -20,12 +26,12 @@ export const slideOps = {
20
26
  },
21
27
 
22
28
  'add-slide': {
23
- run(P, c) { P.addSlide(c.slide || {}, c.index) },
29
+ run(P, c) { P.addSlide(cleanSlide(c.slide || {}), c.index) },
24
30
  },
25
31
 
26
32
  'update-slide': {
27
33
  run(P, c) {
28
- if (!P.updateSlide(idx(c), c.slide)) throw new Error('update-slide 未命中')
34
+ if (!P.updateSlide(idx(c), cleanSlide(c.slide))) throw new Error('update-slide 未命中')
29
35
  },
30
36
  },
31
37
 
@@ -65,6 +65,18 @@ export function textHtml(current, props, st) {
65
65
  return '<p style="' + style + '">' + body + '</p>'
66
66
  }
67
67
 
68
+ /** PPTist 的 image clip 只认 {shape, range:[[x,y],[x,y]]}(裁剪范围)。
69
+ * 历史上稿件编译曾写 {type:'cover'}(object-fit 语义),PPTist 不认 → 整张图渲染空白,
70
+ * 导出时解构 clip.range 还会 throw。统一在入口归一:非法 / 缺失一律 null(不裁剪)。 */
71
+ export function normalizeImageClip(clip) {
72
+ if (!clip || typeof clip !== 'object') return null
73
+ const range = clip.range
74
+ const okRange = Array.isArray(range) && range.length === 2 &&
75
+ range.every(p => Array.isArray(p) && p.length === 2 && p.every(n => isFinite(Number(n))))
76
+ if (typeof clip.shape !== 'string' || !okRange) return null
77
+ return { shape: clip.shape, range: range.map(p => [Number(p[0]), Number(p[1])]) }
78
+ }
79
+
68
80
  /** 元素属性补丁:几何 / 填充 / 文本样式(content 重写保留正文)。 */
69
81
  export function patchElement(el, props) {
70
82
  ;['left', 'top', 'width', 'height', 'rotate', 'opacity'].forEach(k => {
@@ -73,7 +85,7 @@ export function patchElement(el, props) {
73
85
  if (props.fill != null) el.fill = String(props.fill)
74
86
  if (el.type === 'image') {
75
87
  if (props.src != null) el.src = String(props.src)
76
- if (props.clip != null) el.clip = props.clip
88
+ if (props.clip != null) el.clip = normalizeImageClip(props.clip)
77
89
  return
78
90
  }
79
91
  /* 公式元素:path/latex/viewBox 由渲染器产出,样式走 stroke。 */
@@ -175,7 +187,7 @@ export function makeElement(e) {
175
187
  }
176
188
  return Object.assign(base, {
177
189
  src,
178
- clip: e.clip || null,
190
+ clip: normalizeImageClip(e.clip),
179
191
  ...(e.opacity != null ? { opacity: Number(e.opacity) } : {}),
180
192
  })
181
193
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capyclaw/ppt-workbench",
3
- "version": "2.5.70",
3
+ "version": "2.5.71",
4
4
  "description": "PPT 工作台运行时(headless 可用):32 个 ppt_* MCP 工具(导入/导出 PPTX + 图表/表格/公式/形状/线条/备注 + 契约探测);浏览器实时编辑器由可选成员包 @capyclaw/ppt-editor 提供。",
5
5
  "type": "module",
6
6
  "main": "./plugin.mjs",
@@ -46,13 +46,15 @@
46
46
  "license": "AGPL-3.0-or-later",
47
47
  "scripts": {},
48
48
  "dependencies": {
49
- "@capyclaw/asset-service": "^0.1.4",
50
- "@capyclaw/document-workbench": "^0.2.2",
51
- "@capyclaw/editor-host": "^0.1.5",
52
- "@capyclaw/foundation": "^0.1.9",
53
- "@capyclaw/plugin-kit": "^0.2.6",
54
- "@capyclaw/service-host": "^0.1.5",
55
- "@capyclaw/tool-host": "^0.3.0",
49
+ "@capyclaw/asset-service": "^0.1.6",
50
+ "@capyclaw/document-workbench": "^0.2.4",
51
+ "@capyclaw/editor-host": "^0.1.7",
52
+ "@capyclaw/foundation": "^0.1.11",
53
+ "@capyclaw/plugin-kit": "^0.2.8",
54
+ "@capyclaw/service-host": "^0.1.7",
55
+ "@capyclaw/suite-kit": "^0.2.1",
56
+ "@capyclaw/tool-host": "^0.3.2",
57
+ "@capyclaw/work-store": "^0.3.2",
56
58
  "playwright-core": "^1.60.0",
57
59
  "pptxgenjs": "^3.12.0"
58
60
  },
@@ -1 +1,13 @@
1
- export { name, inject, apply } from './server/embedded-host.mjs'
1
+ /**
2
+ * foundation ABI raw@1 wrapper:准入闸扩面后宿主必须走 ABI(见 bridge-build 注释)。
3
+ * raw@1 逃生舱承载多面共生命周期(webServer 路由 + toolHost 工具 + 描述符/表面/portal,
4
+ * 共享 workId/relay);额外 inject 仅 raw@1 可声明。core/os.skills 是套件运行时前提。
5
+ */
6
+ import { createPlugin, rawPlugin } from '@capyclaw/foundation/abi'
7
+ import { name as hostName, apply as applyHost } from './server/embedded-host.mjs'
8
+
9
+ export const { name, inject, apply } = createPlugin({
10
+ name: hostName,
11
+ inject: ['webServer'],
12
+ implements: [rawPlugin(({ ctx, config }) => applyHost(ctx, config))],
13
+ }, import.meta.url)
@@ -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.70'
13
+ export const PACKAGE_VERSION = '2.5.71'
14
14
 
15
15
  /** 生成模型可读的能力报告(`editorPath` 由 tool-host 从 editorUrl 推出:同源相对路径,不带端口)。 */
16
16
  export function capabilityReport(args, editorUrl = '', runtime = {}) {
@@ -21,6 +21,77 @@ export const name = 'ppt-workbench-host'
21
21
  * 时不加载本插件(standalone 只在脚本里直接调 relay,不经过 cordis)。 */
22
22
  export const inject = ['webServer']
23
23
 
24
+ /* P1-8 描述符语义(互联标准 §B.6 词表,校验器 @capyclaw/suite-kit/capability):
25
+ * 每个工具的真实 produces/consumes。未列出的工具用领域默认(操作本套件作品、返回
26
+ * 状态回执)。envelope 标记导出/截图类工具,P1-6 宿主边界据此把产物登记进信封。
27
+ * 只用词表合法类型(artifact:file/*、artifact:image/*、artifact:deck/canvas、
28
+ * result:status/url、meta:capabilities 等),通配仅结尾 /*。 */
29
+ const DOMAIN_ARTIFACT = 'artifact:deck'
30
+ const TOOL_SEMANTICS = {
31
+ /* 产物导出 / 截图(带信封标记) */
32
+ ppt_export_pptx: { produces: ['artifact:file/pptx'], consumes: ['artifact:deck'], envelope: 'pptx-path' },
33
+ canvas_export: { produces: ['artifact:file/html'], consumes: ['artifact:canvas'], envelope: 'html-path' },
34
+ ppt_screenshot: { produces: ['artifact:image/png', 'artifact:image/jpeg'], consumes: ['artifact:deck'], envelope: 'image' },
35
+ canvas_screenshot: { produces: ['artifact:image/png'], consumes: ['artifact:canvas'], envelope: 'image' },
36
+ /* 素材输入 / 文件导入 / 素材搜索 */
37
+ ppt_image: { produces: ['result:status'], consumes: ['artifact:image/*'] },
38
+ canvas_insert_image: { produces: ['result:status'], consumes: ['artifact:image/*'] },
39
+ ppt_import_pptx: { produces: ['artifact:deck'], consumes: ['artifact:file/pptx'] },
40
+ ppt_images: { produces: ['result:url'], consumes: [] },
41
+ /* 读取 / 检查 / 元信息 */
42
+ ppt_capabilities: { produces: ['meta:capabilities'], consumes: [] },
43
+ canvas_capabilities: { produces: ['meta:capabilities'], consumes: [] },
44
+ ppt_get_deck: { produces: ['artifact:deck'], consumes: ['artifact:deck'] },
45
+ ppt_outline: { produces: ['artifact:deck'], consumes: ['artifact:deck'] },
46
+ canvas_read: { produces: ['artifact:canvas'], consumes: ['artifact:canvas'] },
47
+ ppt_check: { produces: ['result:status'], consumes: ['artifact:deck'] },
48
+ ppt_audit: { produces: ['result:status'], consumes: ['artifact:deck'] },
49
+ ppt_inspect: { produces: ['result:status'], consumes: ['artifact:deck'] },
50
+ canvas_audit: { produces: ['result:status'], consumes: ['artifact:canvas'] },
51
+ canvas_search: { produces: ['result:status'], consumes: ['artifact:canvas'] },
52
+ /* 成稿 / 写入(从文本源生成作品) */
53
+ ppt_write: { produces: ['artifact:deck'], consumes: ['artifact:text/markdown'] },
54
+ ppt_deck: { produces: ['artifact:deck'], consumes: ['artifact:text/markdown'] },
55
+ canvas_write_document: { produces: ['artifact:canvas'], consumes: ['artifact:text/markdown'] },
56
+ canvas_append_blocks: { produces: ['artifact:canvas'], consumes: ['artifact:canvas'] },
57
+ /* 会话级工具(不消费作品) */
58
+ ppt_task: { produces: ['result:status'], consumes: [] },
59
+ canvas_task: { produces: ['result:status'], consumes: [] },
60
+ canvas_checkpoint: { produces: ['result:status'], consumes: [] },
61
+ canvas_commands: { produces: ['meta:capabilities'], consumes: [] },
62
+ ppt_history: { produces: ['result:status'], consumes: ['artifact:deck'] },
63
+ canvas_history: { produces: ['result:status'], consumes: ['artifact:canvas'] },
64
+ }
65
+ const DEFAULT_SEMANTICS = { produces: ['result:status'], consumes: [DOMAIN_ARTIFACT] }
66
+ function semanticsFor(name) { return TOOL_SEMANTICS[name] || DEFAULT_SEMANTICS }
67
+
68
+ /* P1-6 产物提取器:从工具原始返回里取出可登记进信封的产物(文件路径 / 图像字节)。
69
+ * 只读结果、不改返回;登记失败不影响工具本身。type 用信封短词表(pptx/html/image)。 */
70
+ const ENVELOPE_EXTRACTORS = {
71
+ 'pptx-path': (result) => {
72
+ try {
73
+ const parsed = JSON.parse(result && typeof result.text === 'string' ? result.text : '')
74
+ if (parsed && parsed.ok && parsed.path) return [{ filePath: parsed.path, type: 'pptx', title: parsed.title }]
75
+ } catch { /* 非 JSON 返回不登记 */ }
76
+ return []
77
+ },
78
+ 'html-path': (result) => {
79
+ const text = result && typeof result.text === 'string' ? result.text : ''
80
+ const match = text.match(/已导出 HTML:(.+)/)
81
+ return match && match[1] ? [{ filePath: match[1].trim(), type: 'html' }] : []
82
+ },
83
+ 'image': (result) => {
84
+ const items = []
85
+ const content = result && Array.isArray(result.content) ? result.content : []
86
+ for (const part of content) {
87
+ if (part && part.type === 'image' && typeof part.data === 'string') {
88
+ items.push({ bytes: Buffer.from(part.data, 'base64'), mime: part.mimeType || 'image/png', type: 'image' })
89
+ }
90
+ }
91
+ return items
92
+ },
93
+ }
94
+
24
95
  function safeGet(ctx, serviceName) {
25
96
  // 原生插件里 ctx.get(name) 只对已 inject 的服务放行;可选依赖用 reflect.get
26
97
  // 才不会因为「没在 inject 列表里」被拒绝(core 也是这么取依赖的)。
@@ -69,7 +140,23 @@ export async function apply(ctx, config) {
69
140
  ? workspaceService.getWork(workId)
70
141
  : (runtime ? createRuntimeStoreClient(runtime, { workId }) : null)
71
142
  const journalPath = runtime ? path.join(runtime.paths.logs, 'ppt-journal.jsonl') : null
72
- const backend = storeClient ? new WorkspaceBackend({ client: storeClient, workId, journalPath }) : null
143
+ /* M5 checkpoint 列表投影(形状声明):内核 WorkspaceBackend 只产出通用信封
144
+ * (name/seq/appliedSeq/pending/title/createdAt/meta),业务字段(PPT 的 slides、
145
+ * canvas 的页数)由套件适配层的 project(payload, base) 叠加。形状模块在 server/store/
146
+ * (src/server/store/ 逐字拷入),命名导出经 cfg.checkpointProject 注入;dw session
147
+ * 无参调 backend.listCheckpoints(),投影必须来自构造期 project。通用桥(browser/wall)
148
+ * 不声明 → project=null 纯信封,不含任何业务名词。 */
149
+ const checkpointProject = (await import('./store/shape.mjs')).projectPptCheckpoint
150
+ /* 投影适配(宿主边界):套件 projector(store/shape.mjs)按 document-workbench
151
+ * projectCheckpoint 约定只返回「扩展字段」(sessionCheckpointFields + 业务字段 slides),
152
+ * 不含 name/createdAt/meta;而 plugin-kit WorkspaceBackend.listCheckpoints 直接采用
153
+ * project(payload, base) 的返回值(不像 FileStateBackend 那样 {...base, ...extra} 合并)。
154
+ * 这里把通用信封 base 与扩展字段合并后再交给 backend,保证 name/createdAt/meta 不丢、
155
+ * 业务字段叠加;若内核日后改为合并语义,此适配幂等兼容。通用桥无 projector → null 纯信封。 */
156
+ const backend = storeClient ? new WorkspaceBackend({
157
+ client: storeClient, workId, journalPath,
158
+ project: checkpointProject ? (payload, base) => ({ ...base, ...checkpointProject(payload, base) }) : null,
159
+ }) : null
73
160
  const hostDir = (config && config.hostDir)
74
161
  || runtime?.paths?.contentState
75
162
  || process.env.PPT_BRIDGE_HOME
@@ -129,14 +216,41 @@ export async function apply(ctx, config) {
129
216
  const registry = relay.tools
130
217
  const tools = safeGet(ctx, 'tools')
131
218
  const toolState = { registered: [], errors: [], hasTools: !!(tools && typeof tools.register === 'function') }
132
- /* 会话模式锁(框架级强制):把本套件工具声明为 ppt 领域,注册时逐个挂 when
133
- * 可见性条件,并装全局 guard 兜底。锁定其他领域的会话里,本套件工具从工具面消失
134
- * 且被硬拒。toolHost/modeGate 缺席(老宿主)时优雅降级为不屏蔽。domain=cfg.ns
135
- * 一处覆盖所有 bridge 套件,无需各 capability 文件自接。 */
136
- const modeGate = toolHost && toolHost.modeGate
137
- if (modeGate && registry && Array.isArray(registry.TOOLS)) {
138
- modeGate.declareTools('ppt', registry.TOOLS.map((t) => t.name), 'ppt')
139
- if (toolState.hasTools) modeGate.install(tools)
219
+ /* P1-6 产物信封接入(互联标准 §B.4):导出/截图类工具的产物在宿主边界登记进
220
+ * work-store artifacts 信封(producer 记能力名)。ctx.workStore 可用且有 putAsset 时
221
+ * 走 registerFileArtifact/registerBytesArtifact;缺席时优雅回落(工具原样返回、不登记)。
222
+ * src 引擎/store 不改,只在宿主边界 wrap 工具实现——native 与 MCP 两面共享同一 TOOL_IMPL,
223
+ * 故两条调用路径都会登记。登记失败只警告,绝不影响工具结果。 */
224
+ const workStore = safeGet(ctx, 'workStore')
225
+ const putAsset = (assetStore && typeof assetStore.put === 'function')
226
+ ? (bytes, mime) => assetStore.put(bytes, mime)
227
+ : (assetService && typeof assetService.put === 'function')
228
+ ? (bytes, mime) => assetService.put(bytes, mime)
229
+ : null
230
+ if (registry && Array.isArray(registry.TOOLS) && registry.TOOL_IMPL && workStore && typeof workStore.registerArtifact === 'function' && putAsset) {
231
+ const { registerFileArtifact, registerBytesArtifact } = await import('@capyclaw/work-store/interop')
232
+ for (const tool of registry.TOOLS) {
233
+ const sem = semanticsFor(tool.name)
234
+ const extractor = sem.envelope ? ENVELOPE_EXTRACTORS[sem.envelope] : null
235
+ const impl = registry.TOOL_IMPL[tool.name]
236
+ if (!extractor || typeof impl !== 'function') continue
237
+ registry.TOOL_IMPL[tool.name] = async (args, exec) => {
238
+ const result = await impl(args, exec)
239
+ try {
240
+ const sessionId = exec && exec.agent && exec.agent.session ? exec.agent.session.id : null
241
+ for (const item of extractor(result)) {
242
+ const input = { type: item.type, producer: tool.name, producerSuite: 'ppt', workId }
243
+ if (item.title) input.title = item.title
244
+ if (sessionId) input.sessionId = sessionId
245
+ if (item.filePath) await registerFileArtifact(workStore, putAsset, item.filePath, input)
246
+ else if (item.bytes) await registerBytesArtifact(workStore, putAsset, item.bytes, { ...input, mime: item.mime })
247
+ }
248
+ } catch (error) {
249
+ console.warn('[ppt-workbench] 产物信封登记失败 ' + tool.name + ': ' + (error && error.message ? error.message : String(error)))
250
+ }
251
+ return result
252
+ }
253
+ }
140
254
  }
141
255
  const OUTPUT_SCHEMA = { type: 'object', additionalProperties: true }
142
256
 
@@ -154,29 +268,62 @@ export async function apply(ctx, config) {
154
268
  }
155
269
 
156
270
  if (registry && Array.isArray(registry.TOOLS) && toolState.hasTools) {
157
- for (const tool of registry.TOOLS) {
271
+ if (toolHost && typeof toolHost.registerWithDsh === 'function') {
272
+ /* P1-7 规范路径:经 tool-host 的 registerWithDsh 注册(服务级自动注入 modeGate,
273
+ * 套件零接线)。它统一接线 caller-session ALS、图像准入(裸 base64 先持久化成
274
+ * attachment ref)、isError 归一(失败 throw)、会话模式锁 when 可见性 + guard 硬拒
275
+ * 与感知闸,并保留 execute(args,exec)/output{schema,render} 语义;全有或全无,
276
+ * 任一工具失败逆序释放。传平对象 { tools, systemPrompt } 避免 cordis 未 inject
277
+ * 禁访问 ctx.tools/systemPrompt。domain=cfg.ns 一处覆盖所有 bridge 套件。 */
158
278
  try {
159
- const when = modeGate && modeGate.whenFor(tool.name)
160
- const dispose = tools.register({
161
- name: tool.name,
162
- description: tool.description,
163
- parameters: tool.inputSchema,
164
- output: {
165
- schema: OUTPUT_SCHEMA,
166
- render: (_args, value) => [{ type: 'text', text: toolText(value) }],
167
- },
168
- /* 第二个参数是 DSH 的 exec(含 exec.agent.session.id)。工具实现靠它知道
169
- * 「是哪个会话在调用」,多会话工作台才能把读写落到调用者自己那份文档上;
170
- * 早期版本只接 args,工具只能猜用户正在看哪个窗口。 */
171
- execute: async (args, exec) => registry.TOOL_IMPL[tool.name](args || {}, exec),
172
- }, when ? { when } : {})
279
+ const systemPrompt = safeGet(ctx, 'systemPrompt')
280
+ const dispose = toolHost.registerWithDsh({ tools, systemPrompt }, registry, { domain: 'ppt' })
173
281
  if (typeof dispose === 'function') disposers.push(dispose)
174
- toolState.registered.push(tool.name)
282
+ toolState.registered = registry.TOOLS.map((t) => t.name)
175
283
  } catch (error) {
176
- toolState.errors.push(`${tool.name}: ${error && error.message ? error.message : String(error)}`)
284
+ toolState.errors.push(error && error.message ? error.message : String(error))
285
+ console.warn('[ppt-workbench] 工具注册失败(registerWithDsh 全有或全无): ' + toolState.errors.join(' | '))
286
+ }
287
+ } else {
288
+ /* 降级路径(老宿主无 registerWithDsh):会话模式锁 + 逐个 tools.register。
289
+ * DSH 的 ToolDefinition 是 name/description/parameters(JSON Schema)/output{schema,render}/
290
+ * execute;缺 output 时 register 直接抛 TypeError。逐个 try 保证一个工具的 schema
291
+ * 不被支持时,其余工具照常注册。modeGate 缺席(老宿主)时优雅降级为不屏蔽。 */
292
+ const modeGate = toolHost && toolHost.modeGate
293
+ if (modeGate) {
294
+ modeGate.declareTools('ppt', registry.TOOLS.map((t) => t.name), 'ppt')
295
+ modeGate.install(tools)
296
+ if (typeof modeGate.installPrompt === 'function') {
297
+ const systemPrompt = safeGet(ctx, 'systemPrompt')
298
+ if (systemPrompt && typeof systemPrompt.section === 'function') {
299
+ const promptDispose = modeGate.installPrompt(systemPrompt)
300
+ if (typeof promptDispose === 'function') disposers.push(promptDispose)
301
+ }
302
+ }
177
303
  }
304
+ for (const tool of registry.TOOLS) {
305
+ try {
306
+ const when = modeGate && modeGate.whenFor(tool.name)
307
+ const dispose = tools.register({
308
+ name: tool.name,
309
+ description: tool.description,
310
+ parameters: tool.inputSchema,
311
+ output: {
312
+ schema: OUTPUT_SCHEMA,
313
+ render: (_args, value) => [{ type: 'text', text: toolText(value) }],
314
+ },
315
+ /* 第二个参数是 DSH 的 exec(含 exec.agent.session.id)。工具实现靠它知道
316
+ * 「是哪个会话在调用」,多会话工作台才能把读写落到调用者自己那份文档上。 */
317
+ execute: async (args, exec) => registry.TOOL_IMPL[tool.name](args || {}, exec),
318
+ }, when ? { when } : {})
319
+ if (typeof dispose === 'function') disposers.push(dispose)
320
+ toolState.registered.push(tool.name)
321
+ } catch (error) {
322
+ toolState.errors.push(tool.name + ': ' + (error && error.message ? error.message : String(error)))
323
+ }
324
+ }
325
+ if (toolState.errors.length) console.warn('[ppt-workbench] 工具注册失败 ' + toolState.errors.length + ' 个: ' + toolState.errors.join(' | '))
178
326
  }
179
- if (toolState.errors.length) console.warn('[ppt-workbench] 工具注册失败 ' + toolState.errors.length + ' 个: ' + toolState.errors.join(' | '))
180
327
  } else if (registry) {
181
328
  console.log('[ppt-workbench] 提示:宿主没有 tools 服务,工具面未注册(只提供编辑器页面)')
182
329
  }
@@ -197,8 +344,10 @@ export async function apply(ctx, config) {
197
344
  tool: tool.name,
198
345
  controlMode: 'interface',
199
346
  kind: tool.kind || 'write',
200
- produces: [],
201
- consumes: [],
347
+ /* P1-8 描述符语义(互联标准 §B.6 词表):按工具名取真实 produces/consumes
348
+ * (TOOL_SEMANTICS,capability.mjs 校验合法),不再留空数组。 */
349
+ produces: semanticsFor(tool.name).produces,
350
+ consumes: semanticsFor(tool.name).consumes,
202
351
  surface,
203
352
  }, { baseUrl: relay.url })
204
353
  descriptorState.registered += 1
@@ -232,6 +381,28 @@ export async function apply(ctx, config) {
232
381
  if (typeof dispose === 'function') disposers.push(dispose)
233
382
  }
234
383
 
384
+ /* P1-5 表面握手落地:描述符声明了 embeddable:true + embedPath,宿主就必须真实
385
+ * 提供 GET <前缀>/embed.js(嵌入握手客户端)与 GET <前缀>/api/surface(呈现面自描述,
386
+ * EMBED_PROTOCOL_VERSION=1)。复用 suite-kit attachSurface 单一真源,不复制握手代码。
387
+ * 桥宿主不持有 relay 内部 app,用 webServer.register 造 .get shim 交给它——handler
388
+ * 同为 (req,res) 直写响应,完全兼容;embed.js 客户端读 suite-kit 包内真源。
389
+ * 仅 embedded 形态(有 webServer)可挂;standalone 的 app 由框架内部持有未暴露,
390
+ * 宿主边界接不到(剩余项,见交付说明)。exact 子路径与 relay prefix 共存。 */
391
+ if (webServer && typeof webServer.register === 'function') {
392
+ try {
393
+ const { attachSurface } = await import('@capyclaw/suite-kit/surface')
394
+ const surfaceApp = {
395
+ get: (routePath, handler) => {
396
+ const dispose = webServer.register({ kind: 'exact', path: mountPath + routePath, handler })
397
+ if (typeof dispose === 'function') disposers.push(dispose)
398
+ },
399
+ }
400
+ attachSurface(surfaceApp, { suite: 'ppt', embedPath: mountPath })
401
+ } catch (error) {
402
+ console.warn('[ppt-workbench] 表面握手挂载失败: ' + (error && error.message ? error.message : String(error)))
403
+ }
404
+ }
405
+
235
406
  /* 活动台账:embedded 形态没有端口,记 url 即可。台账只供主区舞台
236
407
  * (@capyclaw/portal-hud)补标题/最近使用时间,开不开窗由舞台的内容闸决定。
237
408
  * editorAvailable === false 是拆包工作台的 headless 形态(编辑器在可选成员包里,
@@ -39,6 +39,7 @@ import { inspectContractSnapshots, describeMismatch } from './contract-snapshots
39
39
  import { getTuning } from './tuning.mjs'
40
40
  import { createRuntimeStoreClient, loadRuntimeContext } from './infra/runtime/context.mjs'
41
41
  import { WorkspaceBackend } from './infra/workspace/manager.mjs'
42
+ import { projectPptCheckpoint } from './store/shape.mjs'
42
43
  import { createWorkbench, runIfMain } from './workbench-framework.mjs'
43
44
 
44
45
  export { BASE_PATH }
@@ -59,15 +60,14 @@ function reconcileShadow(ctx) {
59
60
  const keys = new Set([DEFAULT_SESSION, sessionStores.activeSession(), ...sessionStores.sessions()])
60
61
  for (const sid of keys) {
61
62
  if (!sid) continue
62
- const doc = sessionStores.forSession(sid).get()
63
- const slides = doc.deck && Array.isArray(doc.deck.slides) ? doc.deck.slides.length : 0
63
+ /* 只读投影:不复活被空闲驱逐的实例。旧实现 forSession(sid).get() 每 5s 把每个会话
64
+ * 重建一遍并刷新 idle 钟,驱逐永远不生效、内存无界;reconcileInfo 从活实例或元数据
65
+ * 快照取旗标,被驱逐会话仍对账得到(不静默消失)。 */
66
+ const info = sessionStores.reconcileInfo(sid)
67
+ if (!info) continue
64
68
  const url = sid === DEFAULT_SESSION ? ctx.editorUrl : `${ctx.editorUrl}s/${sid}/`
65
69
  /* fire-and-forget:manager 内部守并发与异常,不阻塞对账循环。 */
66
- shadowManager.reconcile(sid, url, {
67
- hasContent: slides > 0,
68
- ownerLive: isOwnerLive(doc),
69
- ownerShadow: isShadowOwner(doc),
70
- })
70
+ shadowManager.reconcile(sid, url, info)
71
71
  }
72
72
  } catch (error) {
73
73
  console.log('[shadow] 对账循环异常:', error.message)
@@ -244,6 +244,8 @@ export const startRelay = createWorkbench({
244
244
  /* 停机回收:清对账定时器、关停所有影子 browser(不留孤儿进程)。 */
245
245
  beforeStop: async (ctx) => {
246
246
  if (ctx.shadowTimer) { clearInterval(ctx.shadowTimer); ctx.shadowTimer = null }
247
+ /* 卸载会话缓存的空闲驱逐定时器(数据已落盘)。 */
248
+ try { storesOf(ctx)?.dispose?.() } catch { /* ignore */ }
247
249
  if (ctx.shadowManager) {
248
250
  try { await ctx.shadowManager.dispose() } catch { /* ignore */ }
249
251
  ctx.shadowManager = null
@@ -266,6 +268,7 @@ runIfMain(import.meta.url, async ({ port, dir }) => {
266
268
  client,
267
269
  workId,
268
270
  journalPath: runtime.paths?.logs ? path.join(runtime.paths.logs, 'ppt-journal.jsonl') : null,
271
+ project: projectPptCheckpoint,
269
272
  })
270
273
  : null
271
274
  const relay = await startRelay({
@@ -4,28 +4,28 @@
4
4
  "packages": {
5
5
  "service-host": {
6
6
  "package": "@capyclaw/service-host",
7
- "version": "0.1.5",
7
+ "version": "0.1.7",
8
8
  "apiVersion": "1.0.0",
9
9
  "spec": "@capyclaw/service-host/src",
10
10
  "sha256": "af0a57d779bfe6a66dc935320178d591ef799a7e037f7a5823cdfa1fe5878eeb"
11
11
  },
12
12
  "tool-host": {
13
13
  "package": "@capyclaw/tool-host",
14
- "version": "0.3.0",
14
+ "version": "0.3.2",
15
15
  "apiVersion": "1.1.0",
16
16
  "spec": "@capyclaw/tool-host/src",
17
17
  "sha256": "23256dbcd5cbee0b96b33c97e4eb4e74d0e169cbdde52f91d4526f2fc0f60d3e"
18
18
  },
19
19
  "asset-service": {
20
20
  "package": "@capyclaw/asset-service",
21
- "version": "0.1.4",
21
+ "version": "0.1.6",
22
22
  "apiVersion": "1.0.0",
23
23
  "spec": "@capyclaw/asset-service/src",
24
24
  "sha256": "311a83e95d56dbb69b739d61aced0889b64e85eddd95b883e322e0fa5be8bd6f"
25
25
  },
26
26
  "editor-host": {
27
27
  "package": "@capyclaw/editor-host",
28
- "version": "0.1.5",
28
+ "version": "0.1.7",
29
29
  "apiVersion": "1.0.0",
30
30
  "spec": "@capyclaw/editor-host/src",
31
31
  "sha256": "c8b80dbd4f1b2bee9ef9001423a013031a21ea9a3b8897b5536fe6e5687f01b3"
@@ -2,12 +2,15 @@
2
2
  import { FileStateBackend } from '@capyclaw/document-workbench/store/file-backend'
3
3
  import { getTuning } from '../../tuning.mjs'
4
4
  import { EMPTY_DOC } from '../doc.mjs'
5
+ import { projectPptCheckpoint } from '../shape.mjs'
5
6
 
6
7
  export class FileBridgeBackend extends FileStateBackend {
7
8
  constructor(file) {
8
9
  super(file, {
9
10
  initialDoc: EMPTY_DOC(),
10
11
  journalMaxBytes: getTuning().journalMaxBytes,
12
+ /* PPT 形状投影显式传入:内核默认只回通用信封,slides/title 由适配层声明。 */
13
+ project: projectPptCheckpoint,
11
14
  })
12
15
  }
13
16
  }
@@ -1,4 +1,6 @@
1
1
  /** 兼容层:checkpoint 名称与载荷沿用 PPT 字段,底层由 DocumentSession 写入。 */
2
+ import { deckPages } from './shape.mjs'
3
+
2
4
  export { checkpointName } from '@capyclaw/document-workbench/session'
3
5
 
4
6
  export function buildCheckpoint(doc, name, meta = {}) {
@@ -10,7 +12,8 @@ export function buildCheckpoint(doc, name, meta = {}) {
10
12
  appliedSeq: doc.applied_seq | 0,
11
13
  pending,
12
14
  title: doc.title || deck.title || '未命名',
13
- slides: Array.isArray(deck.slides) ? deck.slides.length : 0,
15
+ /* 页解释走适配层形状声明(deckPages),不在这里硬编码 deck.slides。 */
16
+ slides: deckPages(doc).length,
14
17
  deck,
15
18
  meta: meta && typeof meta === 'object' ? meta : {},
16
19
  createdAt: new Date().toISOString(),
@@ -5,9 +5,11 @@
5
5
  import { DocumentSession, OWNER_TTL } from '@capyclaw/document-workbench/session'
6
6
  import { FileBridgeBackend } from './backends/file-backend.mjs'
7
7
  import { EMPTY_DOC } from './doc.mjs'
8
+ import { PPT_SHAPE } from './shape.mjs'
8
9
 
9
10
  export * from './sanitize.mjs'
10
11
  export { OWNER_TTL, FileBridgeBackend }
12
+ export { PPT_SHAPE, deckPages, projectPptCheckpoint } from './shape.mjs'
11
13
 
12
14
  export class BridgeStore extends DocumentSession {
13
15
  constructor(fileOrOptions) {
@@ -21,6 +23,8 @@ export class BridgeStore extends DocumentSession {
21
23
  initialDoc: EMPTY_DOC(),
22
24
  documentKey: 'deck',
23
25
  stateCompact: true,
26
+ /* 形状标签随 checkpoint 写入;列表业务字段由 backend 的 project 声明叠加。 */
27
+ shape: PPT_SHAPE,
24
28
  summary: (doc) => ({
25
29
  title: doc.deck && doc.deck.title ? doc.deck.title : '未命名',
26
30
  slides: doc.deck && Array.isArray(doc.deck.slides) ? doc.deck.slides.length : 0,