@dp-bohrium/widget-sdk 0.5.0 → 0.6.0

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 (167) hide show
  1. package/AGENTS.md +10 -4
  2. package/CHANGELOG.md +18 -1
  3. package/README.md +39 -17
  4. package/assets/licenses/ajv@8.20.0/LICENSE +22 -0
  5. package/assets/licenses/fast-deep-equal@3.1.3/LICENSE +21 -0
  6. package/assets/licenses/fast-uri@3.1.6/LICENSE +30 -0
  7. package/assets/licenses/json-schema-traverse@1.0.0/LICENSE +21 -0
  8. package/assets/licenses/require-from-string@2.0.2/license +21 -0
  9. package/assets/licenses/widget-contracts.LICENSE +21 -0
  10. package/assets/licenses/widget-sdk.LICENSE +21 -0
  11. package/assets/schemas/host-runtime-config.schema.json +305 -0
  12. package/assets/schemas/widget-manifest.schema.json +361 -0
  13. package/assets/schemas/widget-plugin-manifest.schema.json +162 -0
  14. package/assets/schemas/widget-runtime-contracts.schema.json +2870 -0
  15. package/assets/toolchain.json +24 -0
  16. package/conformance/bridge/capability-request.json +23 -0
  17. package/conformance/bridge/files-download-request.json +23 -0
  18. package/conformance/bridge/files-read-versioned-request.json +25 -0
  19. package/conformance/bridge/files-write-request.json +25 -0
  20. package/conformance/bridge/files-write-success.json +25 -0
  21. package/conformance/bridge/network-fetch-denied.json +16 -0
  22. package/conformance/bridge/network-fetch-request.json +19 -0
  23. package/conformance/bridge/network-fetch-success.json +22 -0
  24. package/conformance/bridge/presentation-change-surface-request.json +14 -0
  25. package/conformance/bridge/presentation-close-request.json +14 -0
  26. package/conformance/bridge/presentation-close-success.json +11 -0
  27. package/conformance/bridge/presentation-downgrade-success.json +14 -0
  28. package/conformance/bridge/presentation-focus-backward-request.json +14 -0
  29. package/conformance/bridge/presentation-focus-boundary-success.json +14 -0
  30. package/conformance/bridge/presentation-focus-forward-request.json +14 -0
  31. package/conformance/bridge/presentation-init.json +70 -0
  32. package/conformance/bridge/presentation-policy-denied.json +16 -0
  33. package/conformance/bridge/presentation-present-request.json +14 -0
  34. package/conformance/bridge/presentation-user-denied.json +16 -0
  35. package/conformance/bridge/ready.json +11 -0
  36. package/conformance/bridge/region-acquire-request.json +14 -0
  37. package/conformance/bridge/tasks-list-request.json +17 -0
  38. package/conformance/bridge/tasks-watch-request.json +18 -0
  39. package/conformance/bridge/ui-state-write-request.json +18 -0
  40. package/conformance/bundles/minimal-file-preview/entry.js +1 -0
  41. package/conformance/bundles/minimal-file-preview/manifest.json +12 -0
  42. package/conformance/bundles/minimal-file-preview/samples/file-preview.json +1 -0
  43. package/conformance/bundles/minimal-panel/entry.js +1 -0
  44. package/conformance/bundles/minimal-panel/manifest.json +11 -0
  45. package/conformance/bundles/minimal-panel/samples/panel.json +1 -0
  46. package/conformance/bundles/minimal-tool-result/entry.js +1 -0
  47. package/conformance/bundles/minimal-tool-result/manifest.json +11 -0
  48. package/conformance/bundles/minimal-tool-result/samples/tool-result.json +1 -0
  49. package/conformance/file-grants/write.json +8 -0
  50. package/conformance/file-responses/list.json +1 -0
  51. package/conformance/file-responses/metadata.json +11 -0
  52. package/conformance/file-responses/mutation-conflict.json +6 -0
  53. package/conformance/file-responses/permission-denied.json +6 -0
  54. package/conformance/file-responses/read-revision-only.json +8 -0
  55. package/conformance/file-responses/read-unversioned-range.json +12 -0
  56. package/conformance/file-responses/read-versioned.json +12 -0
  57. package/conformance/file-responses/resource-limit.json +1 -0
  58. package/conformance/file-responses/revision-conflict.json +6 -0
  59. package/conformance/file-responses/text-content.json +7 -0
  60. package/conformance/file-responses/write-outcome-unknown.json +6 -0
  61. package/conformance/file-responses/write-success.json +15 -0
  62. package/conformance/host-runtime-config/invalid-host-service-expiry.json +85 -0
  63. package/conformance/host-runtime-config/invalid-host-service-identity.json +85 -0
  64. package/conformance/host-runtime-config/invalid-host-service-permission.json +85 -0
  65. package/conformance/host-runtime-config/invalid-host-service-status.json +65 -0
  66. package/conformance/host-runtime-config/invalid-missing-manifest-fields.json +55 -0
  67. package/conformance/host-runtime-config/invalid-static-origins.json +60 -0
  68. package/conformance/host-runtime-config/valid-host-service-authorization-required.json +65 -0
  69. package/conformance/host-runtime-config/valid-host-service-authorization.json +85 -0
  70. package/conformance/host-runtime-config/valid-no-requested-permissions.json +52 -0
  71. package/conformance/host-runtime-config/valid.json +85 -0
  72. package/conformance/invalid-bridge-messages/network-fetch-mixed-case-forbidden-header.json +21 -0
  73. package/conformance/invalid-file-grants/extra-file-scope.json +9 -0
  74. package/conformance/invalid-file-grants/missing-write-limits.json +4 -0
  75. package/conformance/invalid-file-requests/arbitrary-path.json +16 -0
  76. package/conformance/invalid-file-requests/missing-expected-revision.json +14 -0
  77. package/conformance/invalid-file-requests/missing-mutation-id.json +14 -0
  78. package/conformance/invalid-file-requests/path-in-reference.json +16 -0
  79. package/conformance/invalid-file-results/read-empty-revision.json +5 -0
  80. package/conformance/invalid-file-results/read-null-revision.json +5 -0
  81. package/conformance/invalid-file-results/write-missing-mutation-id.json +11 -0
  82. package/conformance/invalid-manifests/missing-target.json +11 -0
  83. package/conformance/invalid-manifests/presentation-duplicate-surfaces.json +16 -0
  84. package/conformance/invalid-manifests/presentation-empty-surfaces.json +14 -0
  85. package/conformance/invalid-manifests/presentation-unknown-surface.json +16 -0
  86. package/conformance/invalid-manifests/unknown-field.json +12 -0
  87. package/conformance/invalid-network-requests/mixed-case-forbidden-header.json +11 -0
  88. package/conformance/invalid-presentation-grants/duplicate-surfaces.json +5 -0
  89. package/conformance/invalid-presentation-grants/empty-surfaces.json +5 -0
  90. package/conformance/invalid-presentation-grants/false-confirmation.json +5 -0
  91. package/conformance/invalid-presentation-grants/missing-confirmation.json +4 -0
  92. package/conformance/invalid-presentation-grants/unknown-surface.json +5 -0
  93. package/conformance/invalid-presentation-requests/change-surface-missing-surface.json +4 -0
  94. package/conformance/invalid-presentation-requests/close-with-surface.json +4 -0
  95. package/conformance/invalid-presentation-requests/focus-boundary-missing-direction.json +4 -0
  96. package/conformance/invalid-presentation-requests/focus-boundary-unknown-direction.json +4 -0
  97. package/conformance/invalid-presentation-requests/focus-boundary-with-coordinates.json +9 -0
  98. package/conformance/invalid-presentation-requests/focus-boundary-with-event-provenance.json +8 -0
  99. package/conformance/invalid-presentation-requests/focus-boundary-with-generation.json +8 -0
  100. package/conformance/invalid-presentation-requests/focus-boundary-with-identity.json +12 -0
  101. package/conformance/invalid-presentation-requests/focus-boundary-with-key.json +8 -0
  102. package/conformance/invalid-presentation-requests/focus-boundary-with-modifiers.json +11 -0
  103. package/conformance/invalid-presentation-requests/focus-boundary-with-selector.json +8 -0
  104. package/conformance/invalid-presentation-requests/focus-boundary-with-surface.json +8 -0
  105. package/conformance/invalid-presentation-requests/focus-boundary-with-target.json +8 -0
  106. package/conformance/invalid-presentation-requests/focus-boundary-with-timestamp.json +8 -0
  107. package/conformance/invalid-presentation-requests/focus-boundary-with-z-index.json +8 -0
  108. package/conformance/invalid-presentation-requests/present-missing-surface.json +4 -0
  109. package/conformance/invalid-presentation-requests/unknown-surface.json +4 -0
  110. package/conformance/invalid-presentation-requests/widget-controls-coordinates.json +9 -0
  111. package/conformance/invalid-presentation-requests/widget-controls-geometry.json +8 -0
  112. package/conformance/invalid-presentation-requests/widget-controls-instance-id.json +8 -0
  113. package/conformance/invalid-presentation-requests/widget-controls-principal.json +8 -0
  114. package/conformance/invalid-presentation-requests/widget-controls-run-id.json +4 -0
  115. package/conformance/invalid-presentation-requests/widget-controls-widget-id.json +8 -0
  116. package/conformance/invalid-presentation-requests/widget-controls-widget-version-id.json +8 -0
  117. package/conformance/invalid-presentation-requests/widget-controls-z-index.json +4 -0
  118. package/conformance/invalid-render-inputs/malformed.json +17 -0
  119. package/conformance/manifests/valid-file-preview.json +12 -0
  120. package/conformance/manifests/valid-file-write-preview.json +30 -0
  121. package/conformance/manifests/valid-network.json +15 -0
  122. package/conformance/manifests/valid-panel.json +11 -0
  123. package/conformance/manifests/valid-presentation-panel.json +21 -0
  124. package/conformance/manifests/valid-region-panel.json +18 -0
  125. package/conformance/manifests/valid-tool-result.json +14 -0
  126. package/conformance/render-inputs/compatibility/literature-search-paper-results.json +75 -0
  127. package/conformance/render-inputs/compatibility/scientific-bibliography-bibtex.json +10 -0
  128. package/conformance/render-inputs/compatibility/scientific-dataset-csv.json +10 -0
  129. package/conformance/render-inputs/compatibility/scientific-manuscript-latex.json +10 -0
  130. package/conformance/render-inputs/compatibility/scientific-manuscript-markdown.json +10 -0
  131. package/conformance/render-inputs/compatibility/scientific-molecule-mol.json +10 -0
  132. package/conformance/render-inputs/compatibility/scientific-molecule-mol2.json +10 -0
  133. package/conformance/render-inputs/compatibility/scientific-notebook-ipynb.json +10 -0
  134. package/conformance/render-inputs/compatibility/scientific-paper-pdf.json +10 -0
  135. package/conformance/render-inputs/compatibility/scientific-protein-pdb.json +10 -0
  136. package/conformance/render-inputs/compatibility/scientific-source-python.json +10 -0
  137. package/conformance/render-inputs/compatibility/scientific-structure-cif.json +47 -0
  138. package/conformance/render-inputs/compatibility/scientific-structure-poscar.json +10 -0
  139. package/conformance/render-inputs/compatibility/scientific-structure-stru.json +10 -0
  140. package/conformance/render-inputs/compatibility/scientific-trajectory-xyz.json +10 -0
  141. package/conformance/render-inputs/compatibility/thinking-process-paper-search.json +25 -0
  142. package/conformance/render-inputs/compatibility/thinking-process-scholar-search.json +25 -0
  143. package/conformance/render-inputs/compatibility/thinking-process-web-search.json +25 -0
  144. package/conformance/render-inputs/compatibility/workspace-file-search.json +24 -0
  145. package/conformance/render-inputs/compatibility/workspace-file-tree.json +24 -0
  146. package/conformance/render-inputs/empty.json +10 -0
  147. package/conformance/render-inputs/file-preview.json +10 -0
  148. package/conformance/render-inputs/incremental-update.json +10 -0
  149. package/conformance/render-inputs/large.json +10 -0
  150. package/conformance/render-inputs/malformed.json +1 -0
  151. package/conformance/render-inputs/panel.json +10 -0
  152. package/conformance/render-inputs/partial-state-full-snapshot.json +40 -0
  153. package/conformance/render-inputs/tool-result.json +10 -0
  154. package/conformance/resource-budgets/corpus.json +431 -0
  155. package/dist/cli.mjs +15577 -0
  156. package/dist/contracts.d.ts +2 -0
  157. package/dist/contracts.js +1 -0
  158. package/dist/index.d.ts +1 -1
  159. package/dist/index.js +1 -1
  160. package/dist/runtime/index.js +1 -1
  161. package/dist/{runtime-DVFTv55x.js → runtime-D7KxTtdu.js} +1 -1
  162. package/llms.txt +9 -1
  163. package/package.json +17 -3
  164. package/schemas/host-runtime-config.schema.json +305 -0
  165. package/schemas/widget-manifest.schema.json +361 -0
  166. package/schemas/widget-plugin-manifest.schema.json +162 -0
  167. package/schemas/widget-runtime-contracts.schema.json +2870 -0
@@ -0,0 +1,361 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "widget-manifest.schema.json",
4
+ "description": "打包阶段生成的宿主 Widget 清单;name / description 仅用于首次展示默认值,widgetConfig 为冻结运行配置。",
5
+ "title": "Widget Manifest",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["name", "widgetConfig"],
9
+ "properties": {
10
+ "name": { "type": "string", "minLength": 1, "maxLength": 128 },
11
+ "description": { "type": "string", "maxLength": 2000 },
12
+ "widgetConfig": { "$ref": "#/$defs/WidgetConfig" }
13
+ },
14
+ "$defs": {
15
+ "WidgetConfig": {
16
+ "description": "打包阶段生成的冻结 Widget 运行配置;字段由 CLI 从作者清单写入,作者不得再直接覆盖。",
17
+ "title": "WidgetConfig",
18
+ "type": "object",
19
+ "additionalProperties": false,
20
+ "required": [
21
+ "schemaVersion",
22
+ "hostApiVersion",
23
+ "widgetSdkVersion",
24
+ "entry",
25
+ "contribution",
26
+ "samples"
27
+ ],
28
+ "properties": {
29
+ "schemaVersion": { "const": 1 },
30
+ "hostApiVersion": { "const": 1 },
31
+ "widgetSdkVersion": { "$ref": "#/$defs/WidgetSdkVersion" },
32
+ "entry": { "$ref": "#/$defs/EntryPath" },
33
+ "contribution": { "$ref": "#/$defs/WidgetContributionConfig" },
34
+ "activationEvents": {
35
+ "description": "声明 Host 何时允许激活该 Widget;激活条件不授予事件读取能力。",
36
+ "$ref": "#/$defs/ActivationEvents"
37
+ },
38
+ "requestedCapabilities": {
39
+ "$ref": "#/$defs/RequestedCapabilities"
40
+ },
41
+ "requestedPermissions": { "$ref": "#/$defs/HostUserPermissions" },
42
+ "runtime": { "$ref": "#/$defs/RuntimeOptions" },
43
+ "samples": { "$ref": "#/$defs/Samples" }
44
+ }
45
+ },
46
+ "HostUserPermission": {
47
+ "description": "Widget 可申请读取的 Host 用户数据权限名:个人资料或邮箱。",
48
+ "title": "HostUserPermission",
49
+ "enum": ["host.user.profile.read", "host.user.email.read"]
50
+ },
51
+ "HostUserPermissions": {
52
+ "description": "Widget 申请的 Host 用户数据权限列表。",
53
+ "title": "HostUserPermissions",
54
+ "type": "array",
55
+ "minItems": 1,
56
+ "maxItems": 2,
57
+ "uniqueItems": true,
58
+ "items": { "$ref": "#/$defs/HostUserPermission" }
59
+ },
60
+ "RequestedCapabilities": {
61
+ "description": "Widget 申请的能力集合;声明仅表示申请,最终由 Host 按次授权。",
62
+ "title": "RequestedCapabilities",
63
+ "type": "object",
64
+ "additionalProperties": false,
65
+ "properties": {
66
+ "files": { "$ref": "#/$defs/FilesCapabilityRequest" },
67
+ "events": { "$ref": "#/$defs/EventsCapabilityRequest" },
68
+ "tasks": { "$ref": "#/$defs/TasksCapabilityRequest" },
69
+ "state": { "$ref": "#/$defs/StateCapabilityRequest" },
70
+ "actions": { "$ref": "#/$defs/ActionsCapabilityRequest" },
71
+ "network": { "$ref": "#/$defs/NetworkCapabilityRequest" },
72
+ "presentation": {
73
+ "$ref": "#/$defs/RequestedPresentationCapability"
74
+ },
75
+ "region": {
76
+ "$ref": "#/$defs/RequestedRegionCapability"
77
+ }
78
+ }
79
+ },
80
+ "FilesCapabilityRequest": {
81
+ "description": "文件能力的独立申请开关;保存已有文件必须单独申请 files.write 并获得 Host 授权,可写范围由 Host grant 决定。",
82
+ "title": "FilesCapabilityRequest",
83
+ "type": "object",
84
+ "additionalProperties": false,
85
+ "properties": {
86
+ "list": { "type": "boolean" },
87
+ "metadata": { "type": "boolean" },
88
+ "read": { "type": "boolean" },
89
+ "download": { "type": "boolean" },
90
+ "write": { "type": "boolean" }
91
+ }
92
+ },
93
+ "EventsCapabilityRequest": {
94
+ "description": "事件读取能力的申请;topics 声明要读取的事件主题。",
95
+ "title": "EventsCapabilityRequest",
96
+ "type": "object",
97
+ "additionalProperties": false,
98
+ "required": ["topics"],
99
+ "properties": {
100
+ "topics": {
101
+ "type": "array",
102
+ "minItems": 1,
103
+ "maxItems": 32,
104
+ "uniqueItems": true,
105
+ "items": {
106
+ "type": "string",
107
+ "minLength": 1,
108
+ "maxLength": 128,
109
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
110
+ }
111
+ }
112
+ }
113
+ },
114
+ "TasksCapabilityRequest": {
115
+ "description": "任务发现与观察能力的申请;list / watch 至少显式申请一项,已申请项固定为 true。",
116
+ "title": "TasksCapabilityRequest",
117
+ "type": "object",
118
+ "additionalProperties": false,
119
+ "minProperties": 1,
120
+ "properties": {
121
+ "list": { "const": true },
122
+ "watch": { "const": true }
123
+ }
124
+ },
125
+ "StateCapabilityRequest": {
126
+ "description": "受限 UI 状态读写能力的申请;read / write 分别声明。",
127
+ "title": "StateCapabilityRequest",
128
+ "type": "object",
129
+ "additionalProperties": false,
130
+ "required": ["read", "write"],
131
+ "properties": {
132
+ "read": { "type": "boolean" },
133
+ "write": { "type": "boolean" }
134
+ }
135
+ },
136
+ "ActionsCapabilityRequest": {
137
+ "description": "Host 自定义动作调用能力的申请;names 声明可调用的动作名。",
138
+ "title": "ActionsCapabilityRequest",
139
+ "type": "object",
140
+ "additionalProperties": false,
141
+ "required": ["names"],
142
+ "properties": {
143
+ "names": {
144
+ "type": "array",
145
+ "minItems": 1,
146
+ "maxItems": 32,
147
+ "uniqueItems": true,
148
+ "items": {
149
+ "type": "string",
150
+ "minLength": 1,
151
+ "maxLength": 128,
152
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
153
+ }
154
+ }
155
+ }
156
+ },
157
+ "NetworkCapabilityRequest": {
158
+ "description": "Host 托管网络能力的申请;fetch 固定为 true,目标域名由 Host 运行时按请求授权。",
159
+ "title": "NetworkCapabilityRequest",
160
+ "type": "object",
161
+ "additionalProperties": false,
162
+ "required": ["fetch"],
163
+ "properties": {
164
+ "fetch": { "const": true }
165
+ }
166
+ },
167
+ "RequestedPresentationCapability": {
168
+ "description": "呈现能力的申请;surfaces 声明期望的呈现表面。",
169
+ "title": "RequestedPresentationCapability",
170
+ "type": "object",
171
+ "additionalProperties": false,
172
+ "required": ["surfaces"],
173
+ "properties": {
174
+ "surfaces": {
175
+ "type": "array",
176
+ "minItems": 1,
177
+ "maxItems": 2,
178
+ "uniqueItems": true,
179
+ "items": { "enum": ["floating", "overlay"] }
180
+ }
181
+ }
182
+ },
183
+ "RequestedRegionCapability": {
184
+ "description": "会话右侧区域替换能力的申请;当前仅支持 session.rightRail + replace。",
185
+ "title": "RequestedRegionCapability",
186
+ "type": "object",
187
+ "additionalProperties": false,
188
+ "required": ["regions", "mode"],
189
+ "properties": {
190
+ "regions": {
191
+ "type": "array",
192
+ "minItems": 1,
193
+ "maxItems": 1,
194
+ "uniqueItems": true,
195
+ "items": { "const": "session.rightRail" }
196
+ },
197
+ "mode": { "const": "replace" }
198
+ }
199
+ },
200
+ "WidgetSdkVersion": {
201
+ "description": "构建该 Widget 时使用的 SDK 精确 SemVer 版本,不接受范围。",
202
+ "title": "WidgetSdkVersion",
203
+ "type": "string",
204
+ "pattern": "^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$"
205
+ },
206
+ "EntryPath": {
207
+ "description": "包内 ESM 入口路径;仅允许包内相对 POSIX 路径。",
208
+ "title": "EntryPath",
209
+ "type": "string",
210
+ "minLength": 1,
211
+ "maxLength": 256,
212
+ "pattern": "^(?!/)(?!.*\\.\\.)(?!.*\\\\)(?!.*://).+\\.m?js$"
213
+ },
214
+ "RuntimeOptions": {
215
+ "description": "运行时申请;worker 与 webAssembly 均为可选布尔开关。",
216
+ "title": "RuntimeOptions",
217
+ "type": "object",
218
+ "additionalProperties": false,
219
+ "properties": {
220
+ "worker": { "type": "boolean" },
221
+ "webAssembly": { "type": "boolean" }
222
+ }
223
+ },
224
+ "ActivationEvents": {
225
+ "title": "ActivationEvents",
226
+ "description": "Host 可用于启动 Widget 的公开激活信号。多个值表示任一信号命中即可激活;它们不授予 events.read 权限。工具名形式为 tool-call-<阶段>:<工具名>。",
227
+ "type": "array",
228
+ "minItems": 1,
229
+ "maxItems": 16,
230
+ "uniqueItems": true,
231
+ "items": { "$ref": "#/$defs/ActivationEvent" }
232
+ },
233
+ "ActivationEvent": {
234
+ "description": "公开 Widget 激活信号。高层 WidgetContext.events 使用事件 type;低层 events.read 的 topic 不填写在这里。",
235
+ "oneOf": [
236
+ {
237
+ "type": "string",
238
+ "enum": [
239
+ "session.start",
240
+ "turn-start",
241
+ "turn-end",
242
+ "step-start",
243
+ "step-end",
244
+ "tool-call-generating",
245
+ "tool-call-waiting",
246
+ "tool-call-running",
247
+ "tool-call-result",
248
+ "tool-call-error",
249
+ "workspace-file-changed",
250
+ "workspace-tree-refresh",
251
+ "workspace-file-opened",
252
+ "ui-tool-opened",
253
+ "ui-panel-focused",
254
+ "host-surface-changed"
255
+ ]
256
+ },
257
+ {
258
+ "type": "string",
259
+ "minLength": 1,
260
+ "maxLength": 128,
261
+ "pattern": "^tool-call-(?:generating|waiting|running|result|error):[A-Za-z0-9_.:-]+$"
262
+ }
263
+ ]
264
+ },
265
+ "Samples": {
266
+ "description": "同版本 RenderRequest 测试样例;至少一个,request 为相对 .json 路径。",
267
+ "title": "Samples",
268
+ "type": "array",
269
+ "minItems": 1,
270
+ "uniqueItems": true,
271
+ "items": {
272
+ "type": "object",
273
+ "additionalProperties": false,
274
+ "required": ["id", "title", "request"],
275
+ "properties": {
276
+ "id": {
277
+ "type": "string",
278
+ "minLength": 1,
279
+ "maxLength": 64,
280
+ "pattern": "^[A-Za-z0-9_-]+$"
281
+ },
282
+ "title": { "type": "string", "minLength": 1, "maxLength": 128 },
283
+ "request": {
284
+ "type": "string",
285
+ "minLength": 1,
286
+ "maxLength": 256,
287
+ "pattern": "^(?!/)(?!.*\\.\\.)(?!.*\\\\)(?!.*://).+\\.json$"
288
+ }
289
+ }
290
+ }
291
+ },
292
+ "WidgetContributionConfig": {
293
+ "description": "作者声明的扩展点配置:file-preview 声明扩展名集合,panel 绑定既有 Panel。",
294
+ "title": "WidgetContributionConfig",
295
+ "oneOf": [
296
+ {
297
+ "type": "object",
298
+ "additionalProperties": false,
299
+ "required": ["type", "extensions"],
300
+ "properties": {
301
+ "type": { "const": "file-preview" },
302
+ "extensions": {
303
+ "type": "array",
304
+ "minItems": 1,
305
+ "uniqueItems": true,
306
+ "items": {
307
+ "type": "string",
308
+ "minLength": 1,
309
+ "maxLength": 32,
310
+ "pattern": "^[a-z0-9][a-z0-9.-]*$"
311
+ }
312
+ }
313
+ }
314
+ },
315
+ { "$ref": "#/$defs/PanelContributionConfig" }
316
+ ]
317
+ },
318
+ "PanelContributionConfig": {
319
+ "title": "PanelContributionConfig",
320
+ "description": "绑定 Agent Widget 既有 Panel 的配置。",
321
+ "type": "object",
322
+ "additionalProperties": false,
323
+ "required": ["type", "id"],
324
+ "properties": {
325
+ "type": {
326
+ "description": "Panel 贡献类型。",
327
+ "const": "panel"
328
+ },
329
+ "id": {
330
+ "description": "Host 注册和查找 Panel 时使用的稳定类型标识。",
331
+ "type": "string",
332
+ "minLength": 1,
333
+ "maxLength": 128,
334
+ "pattern": "^[A-Za-z0-9_.:-]+$"
335
+ },
336
+ "placement": {
337
+ "oneOf": [
338
+ {
339
+ "type": "object",
340
+ "additionalProperties": false,
341
+ "required": ["kind"],
342
+ "properties": {
343
+ "kind": { "const": "panel" }
344
+ }
345
+ },
346
+ {
347
+ "type": "object",
348
+ "additionalProperties": false,
349
+ "required": ["kind", "region", "mode"],
350
+ "properties": {
351
+ "kind": { "const": "region" },
352
+ "region": { "const": "session.rightRail" },
353
+ "mode": { "const": "replace" }
354
+ }
355
+ }
356
+ ]
357
+ }
358
+ }
359
+ }
360
+ }
361
+ }
@@ -0,0 +1,162 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "widget-plugin-manifest.schema.json",
4
+ "title": "Widget Plugin Manifest",
5
+ "description": "插件作者维护的插件清单;打包阶段会生成宿主清单的运行时字段。",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "name",
10
+ "version",
11
+ "contributes"
12
+ ],
13
+ "properties": {
14
+ "$schema": {
15
+ "type": "string"
16
+ },
17
+ "name": {
18
+ "type": "string",
19
+ "minLength": 1,
20
+ "maxLength": 128
21
+ },
22
+ "version": {
23
+ "type": "string",
24
+ "pattern": "^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$"
25
+ },
26
+ "displayName": {
27
+ "type": "string",
28
+ "maxLength": 128
29
+ },
30
+ "description": {
31
+ "type": "string",
32
+ "maxLength": 2000
33
+ },
34
+ "entry": {
35
+ "type": "string",
36
+ "minLength": 1,
37
+ "maxLength": 256,
38
+ "pattern": "^(?!/)(?!.*\\.\\.)(?!.*\\\\)(?!.*://).+\\.(?:[cm]?js|tsx?|jsx?)$",
39
+ "description": "插件源码入口;CLI 默认使用 src/widget.ts。"
40
+ },
41
+ "activationEvents": {
42
+ "$ref": "widget-manifest.schema.json#/$defs/ActivationEvents"
43
+ },
44
+ "contributes": {
45
+ "$ref": "#/$defs/WidgetPluginContributions"
46
+ },
47
+ "capabilities": {
48
+ "$ref": "widget-manifest.schema.json#/$defs/RequestedCapabilities"
49
+ },
50
+ "runtime": {
51
+ "$ref": "widget-manifest.schema.json#/$defs/RuntimeOptions"
52
+ },
53
+ "samples": {
54
+ "$ref": "widget-manifest.schema.json#/$defs/Samples"
55
+ }
56
+ },
57
+ "$defs": {
58
+ "WidgetPluginContributions": {
59
+ "description": "插件声明的一组扩展点;当前仅支持 widget 贡献点。",
60
+ "type": "object",
61
+ "additionalProperties": false,
62
+ "required": [
63
+ "widget"
64
+ ],
65
+ "properties": {
66
+ "widget": {
67
+ "$ref": "#/$defs/WidgetContribution"
68
+ }
69
+ }
70
+ },
71
+ "WidgetContribution": {
72
+ "description": "作者贡献点联合:以 type 判别 Panel 或文件预览。",
73
+ "oneOf": [
74
+ {
75
+ "$ref": "#/$defs/WidgetPanelContribution"
76
+ },
77
+ {
78
+ "$ref": "#/$defs/WidgetFilePreviewContribution"
79
+ }
80
+ ]
81
+ },
82
+ "WidgetPanelContribution": {
83
+ "description": "面板贡献:声明 panel 类型与 id;surfaces、title、placement 可选。",
84
+ "type": "object",
85
+ "additionalProperties": false,
86
+ "required": [
87
+ "type",
88
+ "id"
89
+ ],
90
+ "properties": {
91
+ "type": {
92
+ "const": "panel"
93
+ },
94
+ "id": {
95
+ "type": "string",
96
+ "minLength": 1,
97
+ "maxLength": 128,
98
+ "pattern": "^[A-Za-z0-9_.:-]+$"
99
+ },
100
+ "title": {
101
+ "type": "string",
102
+ "maxLength": 128
103
+ },
104
+ "surfaces": {
105
+ "type": "array",
106
+ "minItems": 1,
107
+ "maxItems": 3,
108
+ "uniqueItems": true,
109
+ "items": { "enum": ["workspace", "floating", "overlay"] }
110
+ },
111
+ "placement": {
112
+ "oneOf": [
113
+ {
114
+ "type": "object",
115
+ "additionalProperties": false,
116
+ "required": ["kind"],
117
+ "properties": {
118
+ "kind": { "const": "panel" }
119
+ }
120
+ },
121
+ {
122
+ "type": "object",
123
+ "additionalProperties": false,
124
+ "required": ["kind", "region", "mode"],
125
+ "properties": {
126
+ "kind": { "const": "region" },
127
+ "region": { "const": "session.rightRail" },
128
+ "mode": { "const": "replace" }
129
+ }
130
+ }
131
+ ]
132
+ }
133
+ }
134
+ },
135
+ "WidgetFilePreviewContribution": {
136
+ "description": "文件预览贡献:声明一组小写且不含前导点的扩展名。",
137
+ "type": "object",
138
+ "additionalProperties": false,
139
+ "required": [
140
+ "type",
141
+ "extensions"
142
+ ],
143
+ "properties": {
144
+ "type": {
145
+ "const": "file-preview"
146
+ },
147
+ "extensions": {
148
+ "type": "array",
149
+ "minItems": 1,
150
+ "maxItems": 32,
151
+ "uniqueItems": true,
152
+ "items": {
153
+ "type": "string",
154
+ "minLength": 1,
155
+ "maxLength": 32,
156
+ "pattern": "^[a-z0-9][a-z0-9.-]*$"
157
+ }
158
+ }
159
+ }
160
+ }
161
+ }
162
+ }