@dp-bohrium/widget-sdk 0.5.0 → 0.7.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 (188) hide show
  1. package/AGENTS.md +13 -4
  2. package/CHANGELOG.md +39 -1
  3. package/README.md +33 -20
  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 +2874 -0
  15. package/assets/toolchain.json +28 -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 +15618 -0
  156. package/dist/contracts.d.ts +2 -0
  157. package/dist/contracts.js +2 -0
  158. package/dist/index.d.ts +2 -2
  159. package/dist/index.js +17 -11
  160. package/dist/manifest.d.ts +1 -1
  161. package/dist/protocol/generated-host-runtime-config.d.ts +551 -0
  162. package/dist/protocol/generated-manifest.d.ts +192 -0
  163. package/dist/protocol/generated-plugin-manifest.d.ts +176 -0
  164. package/dist/protocol/generated-runtime-contracts.d.ts +1224 -0
  165. package/dist/protocol/index.d.ts +43 -0
  166. package/dist/protocol/plugin-manifest.d.ts +30 -0
  167. package/dist/protocol/widget-events.d.ts +13 -0
  168. package/dist/runtime/bootstrap.d.ts +1 -1
  169. package/dist/runtime/client.d.ts +1 -1
  170. package/dist/runtime/event-validation.d.ts +1 -1
  171. package/dist/runtime/events.d.ts +1 -1
  172. package/dist/runtime/files.d.ts +1 -1
  173. package/dist/runtime/index.d.ts +1 -1
  174. package/dist/runtime/index.js +1 -1
  175. package/dist/runtime/mock-host.d.ts +1 -1
  176. package/dist/runtime/network.d.ts +1 -1
  177. package/dist/runtime/protocol-endpoint.d.ts +1 -1
  178. package/dist/runtime/service.d.ts +2 -2
  179. package/dist/runtime/transport.d.ts +1 -1
  180. package/dist/{runtime-DVFTv55x.js → runtime-DZA7Gqzl.js} +1 -1
  181. package/dist/widget-events-BT0QxR-H.js +65 -0
  182. package/dist/widget.d.ts +2 -2
  183. package/llms.txt +8 -1
  184. package/package.json +18 -6
  185. package/schemas/host-runtime-config.schema.json +305 -0
  186. package/schemas/widget-manifest.schema.json +361 -0
  187. package/schemas/widget-plugin-manifest.schema.json +162 -0
  188. package/schemas/widget-runtime-contracts.schema.json +2874 -0
@@ -0,0 +1,2874 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "widget-runtime-contracts.schema.json",
4
+ "description": "Runtime 契约的汇总根容器;仅用于代码生成与符合性校验,不直接对外签发。",
5
+ "title": "Widget Runtime Contracts",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "widgetContributionKind",
10
+ "renderRequest",
11
+ "hostToWidgetMessage",
12
+ "widgetToHostMessage",
13
+ "capabilityRequest",
14
+ "capabilityResult",
15
+ "widgetError",
16
+ "resourceBudget"
17
+ ],
18
+ "properties": {
19
+ "widgetContributionKind": {
20
+ "$ref": "#/$defs/WidgetContributionKind"
21
+ },
22
+ "renderRequest": {
23
+ "$ref": "#/$defs/RenderRequest"
24
+ },
25
+ "hostToWidgetMessage": {
26
+ "$ref": "#/$defs/HostToWidgetMessage"
27
+ },
28
+ "widgetToHostMessage": {
29
+ "$ref": "#/$defs/WidgetToHostMessage"
30
+ },
31
+ "capabilityRequest": {
32
+ "$ref": "#/$defs/CapabilityRequest"
33
+ },
34
+ "capabilityResult": {
35
+ "$ref": "#/$defs/CapabilityResult"
36
+ },
37
+ "widgetError": {
38
+ "$ref": "#/$defs/WidgetError"
39
+ },
40
+ "resourceBudget": {
41
+ "$ref": "#/$defs/ResourceBudget"
42
+ },
43
+ "widgetEventBatch": {
44
+ "$ref": "#/$defs/WidgetEventBatch"
45
+ },
46
+ "toolLifecycleEvent": {
47
+ "$ref": "#/$defs/ToolLifecycleEvent"
48
+ },
49
+ "publicWidgetEvent": {
50
+ "$ref": "#/$defs/PublicWidgetEvent"
51
+ },
52
+ "widgetLiveEvent": {
53
+ "$ref": "#/$defs/WidgetLiveEvent"
54
+ },
55
+ "publicWidgetEventTopic": {
56
+ "$ref": "#/$defs/PublicWidgetEventTopic"
57
+ },
58
+ "widgetNetworkFetchOutput": {
59
+ "$ref": "#/$defs/WidgetNetworkFetchOutput"
60
+ },
61
+ "presentationCapabilityOutput": {
62
+ "$ref": "#/$defs/PresentationCapabilityOutput"
63
+ },
64
+ "presentationCapabilityResult": {
65
+ "$ref": "#/$defs/PresentationCapabilityResult"
66
+ },
67
+ "regionCapabilityResult": {
68
+ "$ref": "#/$defs/RegionCapabilityResult"
69
+ },
70
+ "fileDownloadResult": {
71
+ "$ref": "#/$defs/FileDownloadResult"
72
+ },
73
+ "fileReadResult": { "$ref": "#/$defs/FileReadResult" },
74
+ "fileWriteResult": { "$ref": "#/$defs/FileWriteResult" },
75
+ "taskObservationSnapshot": {
76
+ "$ref": "#/$defs/TaskObservationSnapshot"
77
+ },
78
+ "taskObservationEvent": {
79
+ "$ref": "#/$defs/TaskObservationEvent"
80
+ },
81
+ "taskObservationBatch": {
82
+ "$ref": "#/$defs/TaskObservationBatch"
83
+ },
84
+ "taskListField": {
85
+ "$ref": "#/$defs/TaskListField"
86
+ },
87
+ "taskListItem": {
88
+ "$ref": "#/$defs/TaskListItem"
89
+ },
90
+ "taskListPage": {
91
+ "$ref": "#/$defs/TaskListPage"
92
+ },
93
+ "toolResultEnvelope": {
94
+ "$ref": "#/$defs/ToolResultEnvelope"
95
+ },
96
+ "uiStateResult": {
97
+ "$ref": "#/$defs/UiStateResult"
98
+ },
99
+ "uiStateWriteResult": {
100
+ "$ref": "#/$defs/UiStateWriteResult"
101
+ },
102
+ "hostUserService": {
103
+ "$ref": "#/$defs/HostUserService"
104
+ },
105
+ "hostUserAction": {
106
+ "$ref": "#/$defs/HostUserAction"
107
+ },
108
+ "hostUserProfileReadInput": {
109
+ "$ref": "#/$defs/HostUserProfileReadInput"
110
+ },
111
+ "hostUserProfileReadOutput": {
112
+ "$ref": "#/$defs/HostUserProfileReadOutput"
113
+ },
114
+ "hostUserEmailReadInput": {
115
+ "$ref": "#/$defs/HostUserEmailReadInput"
116
+ },
117
+ "hostUserEmailReadOutput": {
118
+ "$ref": "#/$defs/HostUserEmailReadOutput"
119
+ },
120
+ "hostUserServiceRequest": {
121
+ "$ref": "#/$defs/HostUserServiceRequest"
122
+ }
123
+ },
124
+ "$defs": {
125
+ "JsonValue": {
126
+ "description": "可序列化为 JSON 的任意值;null / boolean / number / string / 数组 / 对象的递归联合。",
127
+ "title": "JsonValue",
128
+ "oneOf": [
129
+ { "type": "null" },
130
+ { "type": "boolean" },
131
+ { "type": "number" },
132
+ { "type": "string" },
133
+ { "type": "array", "items": { "$ref": "#/$defs/JsonValue" } },
134
+ {
135
+ "type": "object",
136
+ "additionalProperties": { "$ref": "#/$defs/JsonValue" }
137
+ }
138
+ ]
139
+ },
140
+ "HostUserPermission": {
141
+ "description": "Host 用户数据权限名:个人资料或邮箱读取。",
142
+ "title": "HostUserPermission",
143
+ "enum": ["host.user.profile.read", "host.user.email.read"]
144
+ },
145
+ "HostUserService": {
146
+ "description": "Host 用户服务标识;固定为 host.user。",
147
+ "title": "HostUserService",
148
+ "const": "host.user"
149
+ },
150
+ "HostUserAction": {
151
+ "description": "Host 用户服务下的具体动作:个人资料或邮箱读取。",
152
+ "title": "HostUserAction",
153
+ "enum": ["profile.read", "email.read"]
154
+ },
155
+ "HostUserProfileReadInput": {
156
+ "description": "读取用户资料的请求输入;当前无需额外参数(null)。",
157
+ "title": "HostUserProfileReadInput",
158
+ "type": "null"
159
+ },
160
+ "HostUserProfileReadOutput": {
161
+ "description": "读取用户资料的结果;含稳定 userId 与展示名。",
162
+ "title": "HostUserProfileReadOutput",
163
+ "type": "object",
164
+ "additionalProperties": false,
165
+ "required": ["userId", "displayName"],
166
+ "properties": {
167
+ "userId": { "type": "string", "minLength": 1 },
168
+ "displayName": { "type": "string", "minLength": 1 }
169
+ }
170
+ },
171
+ "HostUserEmailReadInput": {
172
+ "description": "读取用户邮箱的请求输入;当前无需额外参数(null)。",
173
+ "title": "HostUserEmailReadInput",
174
+ "type": "null"
175
+ },
176
+ "HostUserEmailReadOutput": {
177
+ "description": "读取用户邮箱的结果;email 为地址或 null。",
178
+ "title": "HostUserEmailReadOutput",
179
+ "type": "object",
180
+ "additionalProperties": false,
181
+ "required": ["email"],
182
+ "properties": {
183
+ "email": {
184
+ "oneOf": [
185
+ { "type": "string", "minLength": 3, "maxLength": 320 },
186
+ { "type": "null" }
187
+ ]
188
+ }
189
+ }
190
+ },
191
+ "HostUserServiceRequest": {
192
+ "description": "Host 用户服务请求;以 action 判别资料或邮箱读取。",
193
+ "title": "HostUserServiceRequest",
194
+ "oneOf": [
195
+ {
196
+ "type": "object",
197
+ "additionalProperties": false,
198
+ "required": ["service", "action", "payload"],
199
+ "properties": {
200
+ "service": { "$ref": "#/$defs/HostUserService" },
201
+ "action": { "const": "profile.read" },
202
+ "payload": { "$ref": "#/$defs/HostUserProfileReadInput" }
203
+ }
204
+ },
205
+ {
206
+ "type": "object",
207
+ "additionalProperties": false,
208
+ "required": ["service", "action", "payload"],
209
+ "properties": {
210
+ "service": { "$ref": "#/$defs/HostUserService" },
211
+ "action": { "const": "email.read" },
212
+ "payload": { "$ref": "#/$defs/HostUserEmailReadInput" }
213
+ }
214
+ }
215
+ ]
216
+ },
217
+ "WidgetServicePermission": {
218
+ "description": "单条服务权限:服务名 + 允许的动作列表。",
219
+ "title": "WidgetServicePermission",
220
+ "type": "object",
221
+ "additionalProperties": false,
222
+ "required": ["service", "actions"],
223
+ "properties": {
224
+ "service": {
225
+ "type": "string",
226
+ "minLength": 1,
227
+ "maxLength": 128,
228
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
229
+ },
230
+ "actions": {
231
+ "type": "array",
232
+ "minItems": 1,
233
+ "maxItems": 32,
234
+ "uniqueItems": true,
235
+ "items": {
236
+ "type": "string",
237
+ "minLength": 1,
238
+ "maxLength": 128,
239
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
240
+ }
241
+ }
242
+ }
243
+ },
244
+ "WidgetServicePermissions": {
245
+ "description": "服务权限列表。",
246
+ "title": "WidgetServicePermissions",
247
+ "type": "array",
248
+ "minItems": 1,
249
+ "maxItems": 32,
250
+ "uniqueItems": true,
251
+ "items": { "$ref": "#/$defs/WidgetServicePermission" }
252
+ },
253
+ "WidgetContributionKind": {
254
+ "description": "Runtime 内部枚举;Forge 外部 Manifest 可声明的 Surface 仅为 file-preview 与 panel。tool-result 仅供受信任的内部 Host、Agent 事件与协议验证,不得作为外部作者 Contribution。",
255
+ "title": "WidgetContributionKind",
256
+ "enum": ["tool-result", "file-preview", "panel"]
257
+ },
258
+ "RenderState": {
259
+ "description": "渲染状态:loading / partial / complete / error。",
260
+ "title": "RenderState",
261
+ "enum": ["loading", "partial", "complete", "error"]
262
+ },
263
+ "ThemeMode": {
264
+ "description": "主题模式:light 或 dark。",
265
+ "title": "ThemeMode",
266
+ "enum": ["light", "dark"]
267
+ },
268
+ "Theme": {
269
+ "description": "渲染上下文中的主题:mode 与设计令牌表。",
270
+ "title": "Theme",
271
+ "type": "object",
272
+ "additionalProperties": false,
273
+ "required": ["mode", "tokens"],
274
+ "properties": {
275
+ "mode": { "$ref": "#/$defs/ThemeMode" },
276
+ "tokens": {
277
+ "type": "object",
278
+ "additionalProperties": false,
279
+ "required": [
280
+ "background",
281
+ "foreground",
282
+ "muted",
283
+ "mutedForeground",
284
+ "border",
285
+ "primary",
286
+ "danger"
287
+ ],
288
+ "properties": {
289
+ "background": { "type": "string", "minLength": 1 },
290
+ "foreground": { "type": "string", "minLength": 1 },
291
+ "muted": { "type": "string", "minLength": 1 },
292
+ "mutedForeground": { "type": "string", "minLength": 1 },
293
+ "border": { "type": "string", "minLength": 1 },
294
+ "primary": { "type": "string", "minLength": 1 },
295
+ "danger": { "type": "string", "minLength": 1 }
296
+ }
297
+ }
298
+ }
299
+ },
300
+ "FileReference": {
301
+ "description": "Host 签发的文件引用;仅含不透明 id、可选内容版本和展示元数据。引用本身不授予写权限,不含路径或 URL。",
302
+ "title": "FileReference",
303
+ "type": "object",
304
+ "additionalProperties": false,
305
+ "required": ["id", "kind", "name"],
306
+ "properties": {
307
+ "id": { "type": "string", "minLength": 1 },
308
+ "kind": { "enum": ["file", "directory"] },
309
+ "name": { "type": "string", "minLength": 1 },
310
+ "extension": {
311
+ "type": "string",
312
+ "pattern": "^[a-z0-9][a-z0-9.-]*$",
313
+ "maxLength": 32
314
+ },
315
+ "mimeType": { "type": "string", "minLength": 1, "maxLength": 255 },
316
+ "size": { "type": "integer", "minimum": 0 },
317
+ "revision": { "$ref": "#/$defs/FileRevision" }
318
+ }
319
+ },
320
+ "FileRevision": {
321
+ "description": "由存储执行端签发的文件内容版本,用于条件读取和保存;不是 RenderRequest.revision。",
322
+ "title": "FileRevision",
323
+ "type": "string",
324
+ "minLength": 1,
325
+ "maxLength": 256
326
+ },
327
+ "FileMutationId": {
328
+ "description": "一次逻辑保存的稳定标识;重试或确认结果时必须复用,相同标识不得提交不同内容。",
329
+ "title": "FileMutationId",
330
+ "type": "string",
331
+ "minLength": 1,
332
+ "maxLength": 128,
333
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
334
+ },
335
+ "FileReadInput": {
336
+ "description": "分块读取已授权文件;后续分块应携带首块返回的 expectedRevision,防止拼接不同版本。",
337
+ "title": "FileReadInput",
338
+ "type": "object",
339
+ "additionalProperties": false,
340
+ "required": ["file", "offset", "length", "encoding"],
341
+ "properties": {
342
+ "file": { "$ref": "#/$defs/FileReference" },
343
+ "offset": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
344
+ "length": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 },
345
+ "encoding": { "enum": ["utf8", "base64"] },
346
+ "expectedRevision": { "$ref": "#/$defs/FileRevision" }
347
+ }
348
+ },
349
+ "FileReadResult": {
350
+ "description": "文件读取结果;普通读取只要求内容与编码,原有游标和截断信息按 Host 能力返回。revision 可选且必须与本次读取的内容属于同一快照;请求 expectedRevision 时必须返回匹配版本。缺少 revision 的结果仅用于只读展示,不能据此条件保存。提供字节游标时 nextOffset 等于请求 offset + bytesRead,不按字符串长度计数。",
351
+ "title": "FileReadResult",
352
+ "type": "object",
353
+ "additionalProperties": false,
354
+ "required": ["content", "encoding"],
355
+ "properties": {
356
+ "content": { "type": "string" },
357
+ "encoding": { "enum": ["utf8", "base64"] },
358
+ "offset": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
359
+ "bytesRead": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
360
+ "nextOffset": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
361
+ "eof": { "type": "boolean" },
362
+ "truncated": { "type": "boolean" },
363
+ "revision": { "$ref": "#/$defs/FileRevision" }
364
+ }
365
+ },
366
+ "FileWriteInput": {
367
+ "description": "按 Host 授权范围对已有文件作整文件条件替换;Host 校验引用、作用域、权限和实际字节预算。超时不表示未写入,使用同一 mutationId 核对结果。",
368
+ "title": "FileWriteInput",
369
+ "type": "object",
370
+ "additionalProperties": false,
371
+ "required": ["file", "content", "encoding", "expectedRevision", "mutationId"],
372
+ "properties": {
373
+ "file": { "$ref": "#/$defs/FileReference" },
374
+ "content": { "type": "string" },
375
+ "encoding": { "enum": ["utf8", "base64"] },
376
+ "expectedRevision": { "$ref": "#/$defs/FileRevision" },
377
+ "mutationId": { "$ref": "#/$defs/FileMutationId" }
378
+ }
379
+ },
380
+ "FileWriteResult": {
381
+ "description": "执行端已确认持久化的保存回执;file.id 保持原文件引用身份,revision 是新内容版本。",
382
+ "title": "FileWriteResult",
383
+ "type": "object",
384
+ "additionalProperties": false,
385
+ "required": ["file", "revision", "bytesWritten", "mutationId"],
386
+ "properties": {
387
+ "file": { "$ref": "#/$defs/FileReference" },
388
+ "revision": { "$ref": "#/$defs/FileRevision" },
389
+ "bytesWritten": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
390
+ "mutationId": { "$ref": "#/$defs/FileMutationId" }
391
+ }
392
+ },
393
+ "FileDownloadResult": {
394
+ "description": "文件下载保存意图的结果:saved / started / cancelled。",
395
+ "title": "FileDownloadResult",
396
+ "type": "object",
397
+ "additionalProperties": false,
398
+ "required": ["status"],
399
+ "properties": {
400
+ "status": {
401
+ "enum": ["saved", "started", "cancelled"]
402
+ }
403
+ }
404
+ },
405
+ "TaskStatus": {
406
+ "description": "Host 投影给 Widget 的统一任务状态。",
407
+ "title": "TaskStatus",
408
+ "enum": ["queued", "running", "succeeded", "failed", "cancelled", "expired"]
409
+ },
410
+ "TaskObservationSnapshot": {
411
+ "description": "任务观察的当前快照:taskId、status 与 updatedAt;progress、message 可选。",
412
+ "title": "TaskObservationSnapshot",
413
+ "type": "object",
414
+ "additionalProperties": false,
415
+ "required": ["taskId", "status", "updatedAt"],
416
+ "properties": {
417
+ "taskId": {
418
+ "type": "string",
419
+ "minLength": 1,
420
+ "maxLength": 256
421
+ },
422
+ "status": { "$ref": "#/$defs/TaskStatus" },
423
+ "progress": {
424
+ "type": "number",
425
+ "minimum": 0,
426
+ "maximum": 1
427
+ },
428
+ "message": {
429
+ "type": "string",
430
+ "maxLength": 1024
431
+ },
432
+ "updatedAt": {
433
+ "type": "string",
434
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T[^ ]+Z$"
435
+ }
436
+ }
437
+ },
438
+ "TaskObservationEvent": {
439
+ "description": "任务观察流中的单条事件;payload 由服务端裁剪。",
440
+ "title": "TaskObservationEvent",
441
+ "type": "object",
442
+ "additionalProperties": false,
443
+ "required": ["id", "type", "occurredAt", "payload"],
444
+ "properties": {
445
+ "id": {
446
+ "type": "string",
447
+ "minLength": 1,
448
+ "maxLength": 256
449
+ },
450
+ "type": {
451
+ "enum": ["started", "progress", "succeeded", "failed", "cancelled", "expired"]
452
+ },
453
+ "occurredAt": {
454
+ "type": "string",
455
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T[^ ]+Z$"
456
+ },
457
+ "payload": {
458
+ "$ref": "#/$defs/JsonValue"
459
+ }
460
+ }
461
+ },
462
+ "TaskObservationBatch": {
463
+ "description": "任务观察的一页结果:快照 + 有限事件页 + 游标。",
464
+ "title": "TaskObservationBatch",
465
+ "type": "object",
466
+ "additionalProperties": false,
467
+ "required": ["schemaVersion", "taskId", "cursor", "reset", "hasMore", "snapshot", "events"],
468
+ "properties": {
469
+ "schemaVersion": { "const": 1 },
470
+ "taskId": {
471
+ "type": "string",
472
+ "minLength": 1,
473
+ "maxLength": 256
474
+ },
475
+ "cursor": {
476
+ "type": "string",
477
+ "minLength": 1,
478
+ "maxLength": 256
479
+ },
480
+ "reset": { "type": "boolean" },
481
+ "hasMore": { "type": "boolean" },
482
+ "snapshot": { "$ref": "#/$defs/TaskObservationSnapshot" },
483
+ "events": {
484
+ "type": "array",
485
+ "maxItems": 100,
486
+ "items": { "$ref": "#/$defs/TaskObservationEvent" }
487
+ }
488
+ }
489
+ },
490
+ "TaskListField": {
491
+ "description": "任务列表中的受限展示字段;key 是稳定机器键,value 是 Host 裁剪后的展示文本。",
492
+ "title": "TaskListField",
493
+ "type": "object",
494
+ "additionalProperties": false,
495
+ "required": ["key", "value"],
496
+ "properties": {
497
+ "key": {
498
+ "description": "展示字段的稳定机器键,例如 machine 或 command。",
499
+ "type": "string",
500
+ "minLength": 1,
501
+ "maxLength": 64,
502
+ "pattern": "^[A-Za-z][A-Za-z0-9_.:-]*$"
503
+ },
504
+ "value": {
505
+ "description": "Host 完成授权与裁剪后的展示文本。",
506
+ "type": "string",
507
+ "maxLength": 16384
508
+ }
509
+ }
510
+ },
511
+ "TaskListItem": {
512
+ "description": "Host 已授权发现的任务摘要;taskId 是可继续传给 tasks.watch 的不透明引用。",
513
+ "title": "TaskListItem",
514
+ "type": "object",
515
+ "additionalProperties": false,
516
+ "required": ["taskId", "kind", "name", "status", "updatedAt", "fields"],
517
+ "properties": {
518
+ "taskId": {
519
+ "description": "可继续传给 tasks.watch 的 Host 不透明任务引用。",
520
+ "type": "string",
521
+ "minLength": 1,
522
+ "maxLength": 256
523
+ },
524
+ "kind": {
525
+ "description": "任务来源类型的稳定机器键。",
526
+ "type": "string",
527
+ "minLength": 1,
528
+ "maxLength": 64,
529
+ "pattern": "^[A-Za-z][A-Za-z0-9_.:-]*$"
530
+ },
531
+ "name": {
532
+ "description": "任务的安全展示名称。",
533
+ "type": "string",
534
+ "minLength": 1,
535
+ "maxLength": 256
536
+ },
537
+ "status": {
538
+ "$ref": "#/$defs/TaskStatus"
539
+ },
540
+ "progress": {
541
+ "description": "可选执行进度,取值范围为 0 到 1。",
542
+ "type": "number",
543
+ "minimum": 0,
544
+ "maximum": 1
545
+ },
546
+ "message": {
547
+ "description": "Host 裁剪后的可选状态说明。",
548
+ "type": "string",
549
+ "maxLength": 1024
550
+ },
551
+ "updatedAt": {
552
+ "description": "任务摘要最后更新时间,使用 UTC ISO 8601 字符串。",
553
+ "type": "string",
554
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T[^ ]+Z$"
555
+ },
556
+ "fields": {
557
+ "description": "任务面板可展示的受限附加字段。",
558
+ "type": "array",
559
+ "maxItems": 32,
560
+ "items": { "$ref": "#/$defs/TaskListField" }
561
+ }
562
+ }
563
+ },
564
+ "TaskListPage": {
565
+ "description": "Host 已授权任务摘要的一页结果;nextCursor 缺失表示当前页已到末尾。",
566
+ "title": "TaskListPage",
567
+ "type": "object",
568
+ "additionalProperties": false,
569
+ "required": ["schemaVersion", "tasks"],
570
+ "properties": {
571
+ "schemaVersion": {
572
+ "description": "任务列表页结构版本,当前固定为 1。",
573
+ "const": 1
574
+ },
575
+ "tasks": {
576
+ "description": "当前页中 Host 已授权的任务摘要。",
577
+ "type": "array",
578
+ "maxItems": 100,
579
+ "items": { "$ref": "#/$defs/TaskListItem" }
580
+ },
581
+ "nextCursor": {
582
+ "description": "下一页的不透明游标;缺失表示当前列表已到末尾。",
583
+ "type": "string",
584
+ "minLength": 1,
585
+ "maxLength": 512
586
+ }
587
+ }
588
+ },
589
+ "ToolResultMetric": {
590
+ "description": "工具结果中的单个指标。",
591
+ "title": "ToolResultMetric",
592
+ "type": "object",
593
+ "additionalProperties": false,
594
+ "required": ["name", "value"],
595
+ "properties": {
596
+ "name": { "type": "string", "minLength": 1, "maxLength": 128 },
597
+ "value": { "type": "number" },
598
+ "unit": { "type": "string", "maxLength": 64 },
599
+ "label": { "type": "string", "maxLength": 128 }
600
+ }
601
+ },
602
+ "ToolResultArtifact": {
603
+ "description": "工具结果中的产物元数据,不含内容本身。",
604
+ "title": "ToolResultArtifact",
605
+ "type": "object",
606
+ "additionalProperties": false,
607
+ "required": ["id", "name"],
608
+ "properties": {
609
+ "id": { "type": "string", "minLength": 1, "maxLength": 256 },
610
+ "name": { "type": "string", "minLength": 1, "maxLength": 255 },
611
+ "kind": { "enum": ["file", "directory"] },
612
+ "mimeType": { "type": "string", "minLength": 1, "maxLength": 255 },
613
+ "size": { "type": "integer", "minimum": 0 },
614
+ "downloadable": { "type": "boolean" }
615
+ }
616
+ },
617
+ "ToolResultProvenance": {
618
+ "description": "工具结果的来源信息。",
619
+ "title": "ToolResultProvenance",
620
+ "type": "object",
621
+ "additionalProperties": false,
622
+ "required": ["source"],
623
+ "properties": {
624
+ "source": { "type": "string", "minLength": 1, "maxLength": 256 },
625
+ "kind": { "type": "string", "minLength": 1, "maxLength": 64 },
626
+ "label": { "type": "string", "maxLength": 256 }
627
+ }
628
+ },
629
+ "ToolResultNotice": {
630
+ "description": "工具结果中的提示或警告。",
631
+ "title": "ToolResultNotice",
632
+ "type": "object",
633
+ "additionalProperties": false,
634
+ "required": ["code", "message"],
635
+ "properties": {
636
+ "code": { "type": "string", "minLength": 1, "maxLength": 128 },
637
+ "message": { "type": "string", "minLength": 1, "maxLength": 1024 }
638
+ }
639
+ },
640
+ "ToolResultEnvelope": {
641
+ "description": "工具执行结果信封;仅供受信任的内部 Host 与 Agent 事件,不进入作者 Contribution。",
642
+ "title": "ToolResultEnvelope",
643
+ "type": "object",
644
+ "additionalProperties": false,
645
+ "required": ["schemaVersion", "status"],
646
+ "properties": {
647
+ "schemaVersion": { "const": 1 },
648
+ "status": { "enum": ["running", "succeeded", "failed", "cancelled"] },
649
+ "summary": { "type": "string", "maxLength": 2048 },
650
+ "data": { "$ref": "#/$defs/JsonValue" },
651
+ "metrics": {
652
+ "type": "array",
653
+ "maxItems": 64,
654
+ "items": { "$ref": "#/$defs/ToolResultMetric" }
655
+ },
656
+ "artifacts": {
657
+ "type": "array",
658
+ "maxItems": 64,
659
+ "items": { "$ref": "#/$defs/ToolResultArtifact" }
660
+ },
661
+ "provenance": {
662
+ "type": "array",
663
+ "maxItems": 32,
664
+ "items": { "$ref": "#/$defs/ToolResultProvenance" }
665
+ },
666
+ "warnings": {
667
+ "type": "array",
668
+ "maxItems": 32,
669
+ "items": { "$ref": "#/$defs/ToolResultNotice" }
670
+ },
671
+ "missing": {
672
+ "type": "array",
673
+ "maxItems": 32,
674
+ "items": { "$ref": "#/$defs/ToolResultNotice" }
675
+ }
676
+ }
677
+ },
678
+ "UiStateResult": {
679
+ "description": "受限 UI 状态读取结果。",
680
+ "title": "UiStateResult",
681
+ "type": "object",
682
+ "additionalProperties": false,
683
+ "required": ["found"],
684
+ "properties": {
685
+ "found": { "type": "boolean" },
686
+ "value": { "$ref": "#/$defs/JsonValue" }
687
+ }
688
+ },
689
+ "UiStateWriteResult": {
690
+ "description": "受限 UI 状态写入结果。",
691
+ "title": "UiStateWriteResult",
692
+ "type": "object",
693
+ "additionalProperties": false,
694
+ "required": ["status"],
695
+ "properties": { "status": { "const": "saved" } }
696
+ },
697
+ "GrantedCapability": {
698
+ "description": "Host 已授予的能力;多数分支附带调用与预算限制(ui.presentation / ui.region 除外)。",
699
+ "title": "GrantedCapability",
700
+ "oneOf": [
701
+ {
702
+ "type": "object",
703
+ "additionalProperties": false,
704
+ "required": ["name", "services", "limits"],
705
+ "properties": {
706
+ "name": { "const": "service.invoke" },
707
+ "services": { "$ref": "#/$defs/WidgetServicePermissions" },
708
+ "limits": {
709
+ "type": "object",
710
+ "additionalProperties": false,
711
+ "required": ["callsPerMinute", "requestBytes", "responseBytes"],
712
+ "properties": {
713
+ "callsPerMinute": { "type": "integer", "minimum": 1 },
714
+ "requestBytes": { "type": "integer", "minimum": 1 },
715
+ "responseBytes": { "type": "integer", "minimum": 1 }
716
+ }
717
+ }
718
+ }
719
+ },
720
+ {
721
+ "type": "object",
722
+ "additionalProperties": false,
723
+ "required": [
724
+ "name",
725
+ "limits"
726
+ ],
727
+ "properties": {
728
+ "name": {
729
+ "const": "files.list"
730
+ },
731
+ "limits": {
732
+ "type": "object",
733
+ "additionalProperties": false,
734
+ "required": [
735
+ "pageSize",
736
+ "callsPerMinute"
737
+ ],
738
+ "properties": {
739
+ "pageSize": {
740
+ "type": "integer",
741
+ "minimum": 1
742
+ },
743
+ "callsPerMinute": {
744
+ "type": "integer",
745
+ "minimum": 1
746
+ }
747
+ }
748
+ }
749
+ }
750
+ },
751
+ {
752
+ "type": "object",
753
+ "additionalProperties": false,
754
+ "required": [
755
+ "name",
756
+ "limits"
757
+ ],
758
+ "properties": {
759
+ "name": {
760
+ "const": "files.download"
761
+ },
762
+ "limits": {
763
+ "type": "object",
764
+ "additionalProperties": false,
765
+ "required": [
766
+ "bytesPerRun",
767
+ "callsPerMinute"
768
+ ],
769
+ "properties": {
770
+ "bytesPerRun": {
771
+ "type": "integer",
772
+ "minimum": 1
773
+ },
774
+ "callsPerMinute": {
775
+ "type": "integer",
776
+ "minimum": 1
777
+ }
778
+ }
779
+ }
780
+ }
781
+ },
782
+ {
783
+ "type": "object",
784
+ "additionalProperties": false,
785
+ "required": [
786
+ "name",
787
+ "limits"
788
+ ],
789
+ "properties": {
790
+ "name": {
791
+ "const": "files.metadata"
792
+ },
793
+ "limits": {
794
+ "type": "object",
795
+ "additionalProperties": false,
796
+ "required": [
797
+ "callsPerMinute"
798
+ ],
799
+ "properties": {
800
+ "callsPerMinute": {
801
+ "type": "integer",
802
+ "minimum": 1
803
+ }
804
+ }
805
+ }
806
+ }
807
+ },
808
+ {
809
+ "type": "object",
810
+ "additionalProperties": false,
811
+ "required": [
812
+ "name",
813
+ "limits"
814
+ ],
815
+ "properties": {
816
+ "name": {
817
+ "const": "files.read"
818
+ },
819
+ "limits": {
820
+ "type": "object",
821
+ "additionalProperties": false,
822
+ "required": [
823
+ "bytesPerRequest",
824
+ "callsPerMinute"
825
+ ],
826
+ "properties": {
827
+ "bytesPerRequest": {
828
+ "type": "integer",
829
+ "minimum": 1
830
+ },
831
+ "bytesPerRun": {
832
+ "description": "历史读取累计额度字段,仅为兼容旧配置保留;当前 files.read 不累计或执行此额度,新宿主不再下发。",
833
+ "deprecated": true,
834
+ "type": "integer",
835
+ "minimum": 1
836
+ },
837
+ "callsPerMinute": {
838
+ "type": "integer",
839
+ "minimum": 1
840
+ }
841
+ }
842
+ }
843
+ }
844
+ },
845
+ {
846
+ "type": "object",
847
+ "additionalProperties": false,
848
+ "required": ["name", "limits"],
849
+ "properties": {
850
+ "name": { "const": "files.write" },
851
+ "limits": {
852
+ "type": "object",
853
+ "additionalProperties": false,
854
+ "required": ["bytesPerRequest", "bytesPerRun", "callsPerMinute"],
855
+ "properties": {
856
+ "bytesPerRequest": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 },
857
+ "bytesPerRun": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 },
858
+ "callsPerMinute": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 }
859
+ }
860
+ }
861
+ }
862
+ },
863
+ {
864
+ "type": "object",
865
+ "additionalProperties": false,
866
+ "required": ["name", "topics", "limits"],
867
+ "properties": {
868
+ "name": {
869
+ "const": "events.read"
870
+ },
871
+ "topics": {
872
+ "type": "array",
873
+ "minItems": 1,
874
+ "maxItems": 32,
875
+ "uniqueItems": true,
876
+ "items": {
877
+ "type": "string",
878
+ "minLength": 1,
879
+ "maxLength": 128,
880
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
881
+ }
882
+ },
883
+ "limits": {
884
+ "type": "object",
885
+ "additionalProperties": false,
886
+ "required": [
887
+ "callsPerMinute",
888
+ "pageSize",
889
+ "minPollMs"
890
+ ],
891
+ "properties": {
892
+ "callsPerMinute": {
893
+ "type": "integer",
894
+ "minimum": 1,
895
+ "maximum": 9007199254740991
896
+ },
897
+ "pageSize": {
898
+ "type": "integer",
899
+ "minimum": 1,
900
+ "maximum": 100
901
+ },
902
+ "minPollMs": {
903
+ "type": "integer",
904
+ "minimum": 1000,
905
+ "maximum": 60000
906
+ }
907
+ }
908
+ }
909
+ }
910
+ },
911
+ {
912
+ "type": "object",
913
+ "additionalProperties": false,
914
+ "required": ["name", "limits"],
915
+ "properties": {
916
+ "name": { "const": "tasks.list" },
917
+ "limits": {
918
+ "type": "object",
919
+ "additionalProperties": false,
920
+ "required": ["callsPerMinute", "pageSize", "minPollMs"],
921
+ "properties": {
922
+ "callsPerMinute": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 },
923
+ "pageSize": { "type": "integer", "minimum": 1, "maximum": 100 },
924
+ "minPollMs": { "type": "integer", "minimum": 1000, "maximum": 60000 }
925
+ }
926
+ }
927
+ }
928
+ },
929
+ {
930
+ "type": "object",
931
+ "additionalProperties": false,
932
+ "required": ["name", "limits"],
933
+ "properties": {
934
+ "name": { "const": "tasks.watch" },
935
+ "limits": {
936
+ "type": "object",
937
+ "additionalProperties": false,
938
+ "required": ["callsPerMinute", "pageSize", "minPollMs"],
939
+ "properties": {
940
+ "callsPerMinute": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 },
941
+ "pageSize": { "type": "integer", "minimum": 1, "maximum": 100 },
942
+ "minPollMs": { "type": "integer", "minimum": 1000, "maximum": 60000 }
943
+ }
944
+ }
945
+ }
946
+ },
947
+ {
948
+ "type": "object",
949
+ "additionalProperties": false,
950
+ "required": ["name", "limits"],
951
+ "properties": {
952
+ "name": { "const": "ui.state" },
953
+ "limits": {
954
+ "type": "object",
955
+ "additionalProperties": false,
956
+ "required": ["callsPerMinute", "bytesPerRun", "maxValueBytes"],
957
+ "properties": {
958
+ "callsPerMinute": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 },
959
+ "bytesPerRun": { "type": "integer", "minimum": 1, "maximum": 1048576 },
960
+ "maxValueBytes": { "type": "integer", "minimum": 1, "maximum": 262144 }
961
+ }
962
+ }
963
+ }
964
+ },
965
+ {
966
+ "type": "object",
967
+ "additionalProperties": false,
968
+ "required": [
969
+ "name",
970
+ "actions",
971
+ "limits"
972
+ ],
973
+ "properties": {
974
+ "name": {
975
+ "const": "actions.invoke"
976
+ },
977
+ "actions": {
978
+ "type": "array",
979
+ "minItems": 1,
980
+ "maxItems": 32,
981
+ "uniqueItems": true,
982
+ "items": {
983
+ "type": "string",
984
+ "minLength": 1,
985
+ "maxLength": 128,
986
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
987
+ }
988
+ },
989
+ "limits": {
990
+ "type": "object",
991
+ "additionalProperties": false,
992
+ "required": [
993
+ "callsPerMinute"
994
+ ],
995
+ "properties": {
996
+ "callsPerMinute": {
997
+ "type": "integer",
998
+ "minimum": 1,
999
+ "maximum": 9007199254740991
1000
+ }
1001
+ }
1002
+ }
1003
+ }
1004
+ },
1005
+ {
1006
+ "type": "object",
1007
+ "additionalProperties": false,
1008
+ "required": ["name", "limits"],
1009
+ "properties": {
1010
+ "name": { "const": "network.fetch" },
1011
+ "limits": { "$ref": "#/$defs/WidgetNetworkLimits" }
1012
+ }
1013
+ },
1014
+ { "$ref": "#/$defs/GrantedPresentationCapability" },
1015
+ { "$ref": "#/$defs/GrantedRegionCapability" }
1016
+ ]
1017
+ },
1018
+ "GrantedRegionCapability": {
1019
+ "description": "已授予的会话右侧区域替换能力。",
1020
+ "title": "GrantedRegionCapability",
1021
+ "type": "object",
1022
+ "additionalProperties": false,
1023
+ "required": ["name", "regions", "mode", "requiresHostConfirmation"],
1024
+ "properties": {
1025
+ "name": { "const": "ui.region" },
1026
+ "regions": {
1027
+ "type": "array",
1028
+ "minItems": 1,
1029
+ "maxItems": 1,
1030
+ "uniqueItems": true,
1031
+ "items": { "const": "session.rightRail" }
1032
+ },
1033
+ "mode": { "const": "replace" },
1034
+ "requiresHostConfirmation": { "const": true }
1035
+ }
1036
+ },
1037
+ "GrantedPresentationCapability": {
1038
+ "description": "已授予的呈现能力;含 surfaces,requiresHostConfirmation 恒为 true。",
1039
+ "title": "GrantedPresentationCapability",
1040
+ "type": "object",
1041
+ "additionalProperties": false,
1042
+ "required": ["name", "surfaces", "requiresHostConfirmation"],
1043
+ "properties": {
1044
+ "name": { "const": "ui.presentation" },
1045
+ "surfaces": {
1046
+ "type": "array",
1047
+ "minItems": 1,
1048
+ "maxItems": 2,
1049
+ "uniqueItems": true,
1050
+ "items": { "enum": ["floating", "overlay"] }
1051
+ },
1052
+ "requiresHostConfirmation": { "const": true }
1053
+ }
1054
+ },
1055
+ "WidgetRenderContext": {
1056
+ "description": "渲染上下文:locale、theme、viewport、能力与关联 id。",
1057
+ "title": "WidgetRenderContext",
1058
+ "type": "object",
1059
+ "additionalProperties": false,
1060
+ "required": [
1061
+ "locale",
1062
+ "theme",
1063
+ "viewport",
1064
+ "capabilities",
1065
+ "correlationId"
1066
+ ],
1067
+ "properties": {
1068
+ "locale": { "type": "string", "minLength": 1 },
1069
+ "theme": { "$ref": "#/$defs/Theme" },
1070
+ "viewport": {
1071
+ "type": "object",
1072
+ "additionalProperties": false,
1073
+ "required": ["width", "height"],
1074
+ "properties": {
1075
+ "width": { "type": "number", "minimum": 0 },
1076
+ "height": { "type": "number", "minimum": 0 }
1077
+ }
1078
+ },
1079
+ "capabilities": {
1080
+ "type": "array",
1081
+ "items": { "$ref": "#/$defs/GrantedCapability" }
1082
+ },
1083
+ "correlationId": { "type": "string", "minLength": 1 }
1084
+ }
1085
+ },
1086
+ "ToolResultContent": {
1087
+ "description": "tool-result 渲染内容;仅内部通道使用,外部作者不挂载。",
1088
+ "title": "ToolResultContent",
1089
+ "type": "object",
1090
+ "additionalProperties": false,
1091
+ "required": ["contribution", "tool", "input"],
1092
+ "properties": {
1093
+ "contribution": { "const": "tool-result" },
1094
+ "tool": {
1095
+ "type": "object",
1096
+ "additionalProperties": false,
1097
+ "required": ["name", "callId", "status"],
1098
+ "properties": {
1099
+ "name": { "type": "string", "minLength": 1 },
1100
+ "callId": { "type": "string", "minLength": 1 },
1101
+ "status": {
1102
+ "enum": ["running", "succeeded", "failed", "cancelled"]
1103
+ }
1104
+ }
1105
+ },
1106
+ "input": { "$ref": "#/$defs/JsonValue" },
1107
+ "result": { "$ref": "#/$defs/JsonValue" },
1108
+ "envelope": { "$ref": "#/$defs/ToolResultEnvelope" },
1109
+ "error": {
1110
+ "type": "object",
1111
+ "additionalProperties": false,
1112
+ "required": ["code", "message"],
1113
+ "properties": {
1114
+ "code": { "type": "string", "minLength": 1 },
1115
+ "message": { "type": "string", "minLength": 1 }
1116
+ }
1117
+ }
1118
+ }
1119
+ },
1120
+ "FilePreviewContent": {
1121
+ "description": "文件预览内容;contribution 必须为 file-preview。",
1122
+ "title": "FilePreviewContent",
1123
+ "type": "object",
1124
+ "additionalProperties": false,
1125
+ "required": ["contribution", "file"],
1126
+ "properties": {
1127
+ "contribution": { "const": "file-preview" },
1128
+ "file": { "$ref": "#/$defs/FileReference" },
1129
+ "preview": { "$ref": "#/$defs/JsonValue" }
1130
+ }
1131
+ },
1132
+ "PanelContent": {
1133
+ "description": "面板内容;contribution 必须为 panel。",
1134
+ "title": "PanelContent",
1135
+ "type": "object",
1136
+ "additionalProperties": false,
1137
+ "required": ["contribution", "id", "data"],
1138
+ "properties": {
1139
+ "contribution": { "const": "panel" },
1140
+ "id": { "type": "string", "minLength": 1 },
1141
+ "title": { "type": "string" },
1142
+ "data": { "$ref": "#/$defs/JsonValue" }
1143
+ }
1144
+ },
1145
+ "RenderRequestBase": {
1146
+ "description": "渲染请求公共字段:schemaVersion、requestId、instanceId、revision、state、context。",
1147
+ "title": "RenderRequestBase",
1148
+ "type": "object",
1149
+ "required": [
1150
+ "schemaVersion",
1151
+ "requestId",
1152
+ "instanceId",
1153
+ "revision",
1154
+ "state",
1155
+ "context"
1156
+ ],
1157
+ "properties": {
1158
+ "schemaVersion": { "const": 1 },
1159
+ "requestId": { "type": "string", "minLength": 1 },
1160
+ "instanceId": { "type": "string", "minLength": 1 },
1161
+ "revision": { "type": "integer", "minimum": 1 },
1162
+ "state": { "$ref": "#/$defs/RenderState" },
1163
+ "context": { "$ref": "#/$defs/WidgetRenderContext" }
1164
+ }
1165
+ },
1166
+ "ToolResultRenderRequest": {
1167
+ "description": "历史 Host 投影类型;仅供受信任的内部 Host 与协议验证。Forge 新插件不得声明或挂载 tool-result,工具结果应由 Runtime 逻辑映射到自定义 Panel。",
1168
+ "title": "ToolResultRenderRequest",
1169
+ "type": "object",
1170
+ "allOf": [
1171
+ { "$ref": "#/$defs/RenderRequestBase" },
1172
+ {
1173
+ "type": "object",
1174
+ "required": ["contribution", "content"],
1175
+ "properties": {
1176
+ "contribution": { "const": "tool-result" },
1177
+ "content": { "$ref": "#/$defs/ToolResultContent" }
1178
+ }
1179
+ }
1180
+ ],
1181
+ "unevaluatedProperties": false
1182
+ },
1183
+ "FilePreviewRenderRequest": {
1184
+ "description": "文件预览渲染请求:公共字段 + contribution=file-preview + content。",
1185
+ "title": "FilePreviewRenderRequest",
1186
+ "type": "object",
1187
+ "allOf": [
1188
+ { "$ref": "#/$defs/RenderRequestBase" },
1189
+ {
1190
+ "type": "object",
1191
+ "required": ["contribution", "content"],
1192
+ "properties": {
1193
+ "contribution": { "const": "file-preview" },
1194
+ "content": { "$ref": "#/$defs/FilePreviewContent" }
1195
+ }
1196
+ }
1197
+ ],
1198
+ "unevaluatedProperties": false
1199
+ },
1200
+ "PanelRenderRequest": {
1201
+ "description": "面板渲染请求:公共字段 + contribution=panel + content。",
1202
+ "title": "PanelRenderRequest",
1203
+ "type": "object",
1204
+ "allOf": [
1205
+ { "$ref": "#/$defs/RenderRequestBase" },
1206
+ {
1207
+ "type": "object",
1208
+ "required": ["contribution", "content"],
1209
+ "properties": {
1210
+ "contribution": { "const": "panel" },
1211
+ "content": { "$ref": "#/$defs/PanelContent" }
1212
+ }
1213
+ }
1214
+ ],
1215
+ "unevaluatedProperties": false
1216
+ },
1217
+ "RenderRequest": {
1218
+ "description": "完整渲染请求联合:tool-result(内部)/ file-preview / panel。",
1219
+ "title": "RenderRequest",
1220
+ "oneOf": [
1221
+ { "$ref": "#/$defs/ToolResultRenderRequest" },
1222
+ { "$ref": "#/$defs/FilePreviewRenderRequest" },
1223
+ { "$ref": "#/$defs/PanelRenderRequest" }
1224
+ ]
1225
+ },
1226
+ "CapabilityRequest": {
1227
+ "description": "Widget 发起的能力请求;以 operation 判别语义与 input。",
1228
+ "title": "CapabilityRequest",
1229
+ "oneOf": [
1230
+ {
1231
+ "type": "object",
1232
+ "additionalProperties": false,
1233
+ "required": ["operation", "input"],
1234
+ "properties": {
1235
+ "operation": { "const": "service.invoke" },
1236
+ "input": {
1237
+ "type": "object",
1238
+ "additionalProperties": false,
1239
+ "required": ["service", "action", "payload"],
1240
+ "properties": {
1241
+ "service": {
1242
+ "type": "string",
1243
+ "minLength": 1,
1244
+ "maxLength": 128,
1245
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
1246
+ },
1247
+ "action": {
1248
+ "type": "string",
1249
+ "minLength": 1,
1250
+ "maxLength": 128,
1251
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
1252
+ },
1253
+ "payload": { "$ref": "#/$defs/JsonValue" }
1254
+ }
1255
+ }
1256
+ }
1257
+ },
1258
+ {
1259
+ "type": "object",
1260
+ "additionalProperties": false,
1261
+ "required": [
1262
+ "operation",
1263
+ "input"
1264
+ ],
1265
+ "properties": {
1266
+ "operation": {
1267
+ "const": "files.list"
1268
+ },
1269
+ "input": {
1270
+ "type": "object",
1271
+ "additionalProperties": false,
1272
+ "required": [
1273
+ "directory"
1274
+ ],
1275
+ "properties": {
1276
+ "directory": {
1277
+ "$ref": "#/$defs/FileReference"
1278
+ },
1279
+ "cursor": {
1280
+ "type": "string"
1281
+ },
1282
+ "limit": {
1283
+ "type": "integer",
1284
+ "minimum": 1
1285
+ }
1286
+ }
1287
+ }
1288
+ }
1289
+ },
1290
+ {
1291
+ "type": "object",
1292
+ "additionalProperties": false,
1293
+ "required": [
1294
+ "operation",
1295
+ "input"
1296
+ ],
1297
+ "properties": {
1298
+ "operation": {
1299
+ "const": "files.metadata"
1300
+ },
1301
+ "input": {
1302
+ "type": "object",
1303
+ "additionalProperties": false,
1304
+ "required": [
1305
+ "reference"
1306
+ ],
1307
+ "properties": {
1308
+ "reference": {
1309
+ "$ref": "#/$defs/FileReference"
1310
+ }
1311
+ }
1312
+ }
1313
+ }
1314
+ },
1315
+ {
1316
+ "type": "object",
1317
+ "additionalProperties": false,
1318
+ "required": [
1319
+ "operation",
1320
+ "input"
1321
+ ],
1322
+ "properties": {
1323
+ "operation": {
1324
+ "const": "files.read"
1325
+ },
1326
+ "input": { "$ref": "#/$defs/FileReadInput" }
1327
+ }
1328
+ },
1329
+ {
1330
+ "type": "object",
1331
+ "additionalProperties": false,
1332
+ "required": ["operation", "input"],
1333
+ "properties": {
1334
+ "operation": { "const": "files.write" },
1335
+ "input": { "$ref": "#/$defs/FileWriteInput" }
1336
+ }
1337
+ },
1338
+ {
1339
+ "type": "object",
1340
+ "additionalProperties": false,
1341
+ "required": [
1342
+ "operation",
1343
+ "input"
1344
+ ],
1345
+ "properties": {
1346
+ "operation": {
1347
+ "const": "files.download"
1348
+ },
1349
+ "input": {
1350
+ "type": "object",
1351
+ "additionalProperties": false,
1352
+ "required": ["file", "suggestedName"],
1353
+ "properties": {
1354
+ "file": { "$ref": "#/$defs/FileReference" },
1355
+ "suggestedName": {
1356
+ "type": "string",
1357
+ "minLength": 1,
1358
+ "maxLength": 255,
1359
+ "pattern": "^[^\\\\/\\u0000-\\u001f]+$"
1360
+ }
1361
+ }
1362
+ }
1363
+ }
1364
+ },
1365
+ {
1366
+ "type": "object",
1367
+ "additionalProperties": false,
1368
+ "required": ["operation", "input"],
1369
+ "properties": {
1370
+ "operation": { "const": "tasks.list" },
1371
+ "input": {
1372
+ "type": "object",
1373
+ "additionalProperties": false,
1374
+ "properties": {
1375
+ "cursor": { "type": "string", "minLength": 1, "maxLength": 512 },
1376
+ "limit": { "type": "integer", "minimum": 1, "maximum": 100 }
1377
+ }
1378
+ }
1379
+ }
1380
+ },
1381
+ {
1382
+ "type": "object",
1383
+ "additionalProperties": false,
1384
+ "required": ["operation", "input"],
1385
+ "properties": {
1386
+ "operation": { "const": "tasks.watch" },
1387
+ "input": {
1388
+ "type": "object",
1389
+ "additionalProperties": false,
1390
+ "required": ["taskId"],
1391
+ "properties": {
1392
+ "taskId": { "type": "string", "minLength": 1, "maxLength": 256 },
1393
+ "cursor": { "type": "string", "minLength": 1, "maxLength": 256 },
1394
+ "limit": { "type": "integer", "minimum": 1, "maximum": 100 }
1395
+ }
1396
+ }
1397
+ }
1398
+ },
1399
+ {
1400
+ "type": "object",
1401
+ "additionalProperties": false,
1402
+ "required": ["operation", "input"],
1403
+ "properties": {
1404
+ "operation": { "const": "ui.state" },
1405
+ "input": {
1406
+ "oneOf": [
1407
+ {
1408
+ "type": "object",
1409
+ "additionalProperties": false,
1410
+ "required": ["action", "key"],
1411
+ "properties": {
1412
+ "action": { "const": "read" },
1413
+ "key": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9_.:-]+$" }
1414
+ }
1415
+ },
1416
+ {
1417
+ "type": "object",
1418
+ "additionalProperties": false,
1419
+ "required": ["action", "key", "value"],
1420
+ "properties": {
1421
+ "action": { "const": "write" },
1422
+ "key": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9_.:-]+$" },
1423
+ "value": { "$ref": "#/$defs/JsonValue" }
1424
+ }
1425
+ }
1426
+ ]
1427
+ }
1428
+ }
1429
+ },
1430
+ {
1431
+ "type": "object",
1432
+ "additionalProperties": false,
1433
+ "required": [
1434
+ "operation",
1435
+ "input"
1436
+ ],
1437
+ "properties": {
1438
+ "operation": {
1439
+ "const": "events.read"
1440
+ },
1441
+ "input": {
1442
+ "type": "object",
1443
+ "additionalProperties": false,
1444
+ "required": [
1445
+ "topic",
1446
+ "limit"
1447
+ ],
1448
+ "properties": {
1449
+ "topic": {
1450
+ "type": "string",
1451
+ "minLength": 1,
1452
+ "maxLength": 128,
1453
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
1454
+ },
1455
+ "cursor": {
1456
+ "type": "string",
1457
+ "minLength": 1,
1458
+ "maxLength": 256
1459
+ },
1460
+ "limit": {
1461
+ "type": "integer",
1462
+ "minimum": 1,
1463
+ "maximum": 100
1464
+ }
1465
+ }
1466
+ }
1467
+ }
1468
+ },
1469
+ {
1470
+ "type": "object",
1471
+ "additionalProperties": false,
1472
+ "required": [
1473
+ "operation",
1474
+ "input"
1475
+ ],
1476
+ "properties": {
1477
+ "operation": {
1478
+ "const": "actions.invoke"
1479
+ },
1480
+ "input": {
1481
+ "type": "object",
1482
+ "additionalProperties": false,
1483
+ "required": [
1484
+ "action",
1485
+ "idempotencyKey",
1486
+ "arguments"
1487
+ ],
1488
+ "properties": {
1489
+ "action": {
1490
+ "type": "string",
1491
+ "minLength": 1,
1492
+ "maxLength": 128,
1493
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
1494
+ },
1495
+ "idempotencyKey": {
1496
+ "type": "string",
1497
+ "minLength": 1,
1498
+ "maxLength": 256
1499
+ },
1500
+ "arguments": {
1501
+ "$ref": "#/$defs/JsonValue"
1502
+ }
1503
+ }
1504
+ }
1505
+ }
1506
+ },
1507
+ {
1508
+ "type": "object",
1509
+ "additionalProperties": false,
1510
+ "required": ["operation", "input"],
1511
+ "properties": {
1512
+ "operation": { "const": "network.fetch" },
1513
+ "input": { "$ref": "#/$defs/WidgetNetworkFetchInput" }
1514
+ }
1515
+ },
1516
+ { "$ref": "#/$defs/PresentationCapabilityRequest" },
1517
+ { "$ref": "#/$defs/RegionCapabilityRequest" }
1518
+ ]
1519
+ },
1520
+ "RegionCapabilityRequest": {
1521
+ "description": "区域能力请求:acquire 或 release。",
1522
+ "title": "RegionCapabilityRequest",
1523
+ "type": "object",
1524
+ "oneOf": [
1525
+ {
1526
+ "type": "object",
1527
+ "additionalProperties": false,
1528
+ "required": ["operation", "input"],
1529
+ "properties": {
1530
+ "operation": { "const": "ui.region" },
1531
+ "input": {
1532
+ "type": "object",
1533
+ "additionalProperties": false,
1534
+ "required": ["action", "region"],
1535
+ "properties": {
1536
+ "action": { "const": "acquire" },
1537
+ "region": { "const": "session.rightRail" }
1538
+ }
1539
+ }
1540
+ }
1541
+ },
1542
+ {
1543
+ "type": "object",
1544
+ "additionalProperties": false,
1545
+ "required": ["operation", "input"],
1546
+ "properties": {
1547
+ "operation": { "const": "ui.region" },
1548
+ "input": {
1549
+ "type": "object",
1550
+ "additionalProperties": false,
1551
+ "required": ["action"],
1552
+ "properties": { "action": { "const": "release" } }
1553
+ }
1554
+ }
1555
+ }
1556
+ ]
1557
+ },
1558
+ "PresentationCapabilityRequest": {
1559
+ "description": "呈现能力请求:present / change-surface、close,或 focus-boundary。",
1560
+ "title": "PresentationCapabilityRequest",
1561
+ "oneOf": [
1562
+ {
1563
+ "type": "object",
1564
+ "additionalProperties": false,
1565
+ "required": ["operation", "input"],
1566
+ "properties": {
1567
+ "operation": { "const": "ui.presentation" },
1568
+ "input": {
1569
+ "oneOf": [
1570
+ {
1571
+ "type": "object",
1572
+ "additionalProperties": false,
1573
+ "required": ["action", "surface"],
1574
+ "properties": {
1575
+ "action": { "enum": ["present", "change-surface"] },
1576
+ "surface": {
1577
+ "enum": ["workspace", "floating", "overlay"]
1578
+ }
1579
+ }
1580
+ },
1581
+ {
1582
+ "type": "object",
1583
+ "additionalProperties": false,
1584
+ "required": ["action"],
1585
+ "properties": {
1586
+ "action": { "const": "close" }
1587
+ }
1588
+ }
1589
+ ]
1590
+ }
1591
+ }
1592
+ },
1593
+ { "$ref": "#/$defs/FocusBoundaryPresentationCapabilityRequest" }
1594
+ ]
1595
+ },
1596
+ "FocusBoundaryPresentationCapabilityRequest": {
1597
+ "description": "呈现焦点边界请求:forward 或 backward。",
1598
+ "title": "FocusBoundaryPresentationCapabilityRequest",
1599
+ "oneOf": [
1600
+ {
1601
+ "type": "object",
1602
+ "additionalProperties": false,
1603
+ "required": ["operation", "input"],
1604
+ "properties": {
1605
+ "operation": { "const": "ui.presentation" },
1606
+ "input": {
1607
+ "type": "object",
1608
+ "additionalProperties": false,
1609
+ "required": ["action", "direction"],
1610
+ "properties": {
1611
+ "action": { "const": "focus-boundary" },
1612
+ "direction": { "enum": ["forward", "backward"] }
1613
+ }
1614
+ }
1615
+ }
1616
+ }
1617
+ ]
1618
+ },
1619
+ "WidgetNetworkLimits": {
1620
+ "description": "Host 托管网络的限制项:超时、并发、频率与字节数。",
1621
+ "title": "WidgetNetworkLimits",
1622
+ "type": "object",
1623
+ "additionalProperties": false,
1624
+ "required": [
1625
+ "timeoutMs",
1626
+ "maxRedirects",
1627
+ "maxConcurrentRequests",
1628
+ "callsPerMinute",
1629
+ "requestHeaderBytes",
1630
+ "responseHeaderBytes",
1631
+ "requestBodyBytes",
1632
+ "responseBodyBytes"
1633
+ ],
1634
+ "properties": {
1635
+ "timeoutMs": { "$ref": "#/$defs/PositiveInteger" },
1636
+ "maxRedirects": { "$ref": "#/$defs/PositiveInteger" },
1637
+ "maxConcurrentRequests": { "$ref": "#/$defs/PositiveInteger" },
1638
+ "callsPerMinute": { "$ref": "#/$defs/PositiveInteger" },
1639
+ "requestHeaderBytes": { "$ref": "#/$defs/PositiveInteger" },
1640
+ "responseHeaderBytes": { "$ref": "#/$defs/PositiveInteger" },
1641
+ "requestBodyBytes": { "$ref": "#/$defs/PositiveInteger" },
1642
+ "responseBodyBytes": { "$ref": "#/$defs/PositiveInteger" }
1643
+ }
1644
+ },
1645
+ "PositiveInteger": {
1646
+ "description": "正整数。",
1647
+ "title": "PositiveInteger",
1648
+ "type": "integer",
1649
+ "minimum": 1,
1650
+ "maximum": 9007199254740991
1651
+ },
1652
+ "NetworkHeaders": {
1653
+ "description": "HTTP 响应头集合。",
1654
+ "title": "NetworkHeaders",
1655
+ "type": "object",
1656
+ "maxProperties": 64,
1657
+ "propertyNames": {
1658
+ "pattern": "^[!#$%&'*+.^_`|~0-9A-Za-z-]+$"
1659
+ },
1660
+ "additionalProperties": {
1661
+ "type": "string",
1662
+ "maxLength": 16384
1663
+ }
1664
+ },
1665
+ "WidgetNetworkRequestHeaders": {
1666
+ "description": "Widget 发起网络请求时附加的请求头集合。",
1667
+ "title": "WidgetNetworkRequestHeaders",
1668
+ "type": "object",
1669
+ "maxProperties": 64,
1670
+ "propertyNames": {
1671
+ "allOf": [
1672
+ { "pattern": "^[!#$%&'*+.^_`|~0-9A-Za-z-]+$" },
1673
+ {
1674
+ "not": {
1675
+ "pattern": "^(?:[Aa][Uu][Tt][Hh][Oo][Rr][Ii][Zz][Aa][Tt][Ii][Oo][Nn]|[Cc][Oo][Oo][Kk][Ii][Ee]|[Pp][Rr][Oo][Xx][Yy]-[Aa][Uu][Tt][Hh][Oo][Rr][Ii][Zz][Aa][Tt][Ii][Oo][Nn]|[Xx]-[Aa][Pp][Ii]-[Kk][Ee][Yy]|[Aa][Pp][Ii]-[Kk][Ee][Yy]|[Xx]-[Aa][Uu][Tt][Hh]-[Tt][Oo][Kk][Ee][Nn]|[Xx]-[Aa][Cc][Cc][Ee][Ss][Ss]-[Tt][Oo][Kk][Ee][Nn]|[Cc][Rr][Ee][Dd][Ee][Nn][Tt][Ii][Aa][Ll]-[Bb][Ii][Nn][Dd][Ii][Nn][Gg]-[Ii][Dd]|[Xx]-[Cc][Rr][Ee][Dd][Ee][Nn][Tt][Ii][Aa][Ll]-[Bb][Ii][Nn][Dd][Ii][Nn][Gg]-[Ii][Dd])$"
1676
+ }
1677
+ }
1678
+ ]
1679
+ },
1680
+ "additionalProperties": {
1681
+ "type": "string",
1682
+ "maxLength": 16384
1683
+ }
1684
+ },
1685
+ "WidgetNetworkFetchInput": {
1686
+ "description": "Host 托管网络请求输入;url 由 Host 校验,auth 声明凭据需求。",
1687
+ "title": "WidgetNetworkFetchInput",
1688
+ "type": "object",
1689
+ "additionalProperties": false,
1690
+ "required": ["url", "auth"],
1691
+ "properties": {
1692
+ "url": { "type": "string", "minLength": 1, "maxLength": 8192 },
1693
+ "auth": { "enum": ["none", "optional", "required"] },
1694
+ "method": {
1695
+ "enum": ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"]
1696
+ },
1697
+ "headers": { "$ref": "#/$defs/WidgetNetworkRequestHeaders" },
1698
+ "body": { "type": "string" },
1699
+ "bodyEncoding": { "enum": ["utf8", "base64"] },
1700
+ "redirect": { "enum": ["follow", "manual", "error"] }
1701
+ },
1702
+ "dependentRequired": {
1703
+ "bodyEncoding": ["body"]
1704
+ }
1705
+ },
1706
+ "WidgetNetworkFetchOutput": {
1707
+ "description": "Host 托管网络请求结果;body 按 bodyEncoding 解释。",
1708
+ "title": "WidgetNetworkFetchOutput",
1709
+ "type": "object",
1710
+ "additionalProperties": false,
1711
+ "required": [
1712
+ "status",
1713
+ "statusText",
1714
+ "headers",
1715
+ "body",
1716
+ "bodyEncoding",
1717
+ "finalUrl",
1718
+ "redirected"
1719
+ ],
1720
+ "properties": {
1721
+ "status": { "type": "integer", "minimum": 100, "maximum": 599 },
1722
+ "statusText": { "type": "string", "maxLength": 256 },
1723
+ "headers": { "$ref": "#/$defs/NetworkHeaders" },
1724
+ "body": { "type": "string" },
1725
+ "bodyEncoding": { "enum": ["utf8", "base64"] },
1726
+ "finalUrl": { "type": "string", "minLength": 1, "maxLength": 8192 },
1727
+ "redirected": { "type": "boolean" }
1728
+ }
1729
+ },
1730
+ "PresentationCapabilityOutput": {
1731
+ "description": "呈现能力输出:present / change-surface / focus-boundary / close。",
1732
+ "title": "PresentationCapabilityOutput",
1733
+ "oneOf": [
1734
+ {
1735
+ "type": "object",
1736
+ "additionalProperties": false,
1737
+ "required": ["action", "surface"],
1738
+ "properties": {
1739
+ "action": { "enum": ["present", "change-surface"] },
1740
+ "surface": { "enum": ["workspace", "floating", "overlay"] }
1741
+ }
1742
+ },
1743
+ {
1744
+ "type": "object",
1745
+ "additionalProperties": false,
1746
+ "required": ["action"],
1747
+ "properties": {
1748
+ "action": { "const": "close" }
1749
+ }
1750
+ },
1751
+ {
1752
+ "type": "object",
1753
+ "additionalProperties": false,
1754
+ "required": ["action", "direction"],
1755
+ "properties": {
1756
+ "action": { "const": "focus-boundary" },
1757
+ "direction": { "enum": ["forward", "backward"] }
1758
+ }
1759
+ }
1760
+ ]
1761
+ },
1762
+ "PresentationCapabilityResult": {
1763
+ "description": "呈现能力请求的结果。",
1764
+ "title": "PresentationCapabilityResult",
1765
+ "oneOf": [
1766
+ {
1767
+ "type": "object",
1768
+ "additionalProperties": false,
1769
+ "required": ["ok", "data"],
1770
+ "properties": {
1771
+ "ok": { "const": true },
1772
+ "data": { "$ref": "#/$defs/PresentationCapabilityOutput" }
1773
+ }
1774
+ },
1775
+ {
1776
+ "type": "object",
1777
+ "additionalProperties": false,
1778
+ "required": ["ok", "reason", "message", "retryable"],
1779
+ "properties": {
1780
+ "ok": { "const": false },
1781
+ "reason": {
1782
+ "enum": [
1783
+ "unsupported",
1784
+ "permission-denied",
1785
+ "resource-limit",
1786
+ "invalid-reference",
1787
+ "timeout",
1788
+ "internal-error",
1789
+ "network-consent-denied",
1790
+ "network-policy-denied",
1791
+ "network-transport-unavailable",
1792
+ "network-request-too-large",
1793
+ "network-response-too-large",
1794
+ "network-rate-limited",
1795
+ "network-redirect-denied",
1796
+ "network-credential-unavailable",
1797
+ "network-scope-invalid",
1798
+ "network-dns-denied",
1799
+ "network-error"
1800
+ ]
1801
+ },
1802
+ "message": { "type": "string", "minLength": 1 },
1803
+ "retryable": { "type": "boolean" }
1804
+ }
1805
+ }
1806
+ ]
1807
+ },
1808
+ "RegionCapabilityResult": {
1809
+ "description": "区域能力请求的结果;成功时含不透明 leaseId。",
1810
+ "title": "RegionCapabilityResult",
1811
+ "oneOf": [
1812
+ {
1813
+ "type": "object",
1814
+ "additionalProperties": false,
1815
+ "required": ["ok", "data"],
1816
+ "properties": {
1817
+ "ok": { "const": true },
1818
+ "data": {
1819
+ "type": "object",
1820
+ "additionalProperties": false,
1821
+ "required": ["action", "region", "mode"],
1822
+ "properties": {
1823
+ "action": { "enum": ["acquire", "release"] },
1824
+ "region": { "const": "session.rightRail" },
1825
+ "mode": { "const": "replace" },
1826
+ "leaseId": { "type": "string", "minLength": 1, "maxLength": 256 }
1827
+ }
1828
+ }
1829
+ }
1830
+ },
1831
+ {
1832
+ "type": "object",
1833
+ "additionalProperties": false,
1834
+ "required": ["ok", "reason", "message", "retryable"],
1835
+ "properties": {
1836
+ "ok": { "const": false },
1837
+ "reason": {
1838
+ "enum": [
1839
+ "unsupported",
1840
+ "permission-denied",
1841
+ "resource-limit",
1842
+ "invalid-reference",
1843
+ "timeout",
1844
+ "internal-error"
1845
+ ]
1846
+ },
1847
+ "message": { "type": "string", "minLength": 1 },
1848
+ "retryable": { "type": "boolean" }
1849
+ }
1850
+ }
1851
+ ]
1852
+ },
1853
+ "CapabilityResult": {
1854
+ "description": "能力请求结果:成功时带 data,失败时带 reason / message / retryable。",
1855
+ "title": "CapabilityResult",
1856
+ "oneOf": [
1857
+ {
1858
+ "type": "object",
1859
+ "additionalProperties": false,
1860
+ "required": ["ok", "data"],
1861
+ "properties": {
1862
+ "ok": { "const": true },
1863
+ "data": { "$ref": "#/$defs/JsonValue" }
1864
+ }
1865
+ },
1866
+ {
1867
+ "type": "object",
1868
+ "additionalProperties": false,
1869
+ "required": ["ok", "reason", "message", "retryable"],
1870
+ "properties": {
1871
+ "ok": { "const": false },
1872
+ "reason": {
1873
+ "enum": [
1874
+ "unsupported",
1875
+ "permission-denied",
1876
+ "resource-limit",
1877
+ "invalid-reference",
1878
+ "timeout",
1879
+ "internal-error",
1880
+ "network-consent-denied",
1881
+ "network-policy-denied",
1882
+ "network-transport-unavailable",
1883
+ "network-request-too-large",
1884
+ "network-response-too-large",
1885
+ "network-rate-limited",
1886
+ "network-redirect-denied",
1887
+ "network-credential-unavailable",
1888
+ "network-scope-invalid",
1889
+ "network-dns-denied",
1890
+ "network-error",
1891
+ "revision-conflict",
1892
+ "mutation-conflict",
1893
+ "write-outcome-unknown"
1894
+ ]
1895
+ },
1896
+ "message": { "type": "string", "minLength": 1 },
1897
+ "retryable": { "type": "boolean" }
1898
+ }
1899
+ }
1900
+ ]
1901
+ },
1902
+ "WidgetError": {
1903
+ "description": "结构化稳定错误:code + phase + message + retryable + correlationId。",
1904
+ "title": "WidgetError",
1905
+ "type": "object",
1906
+ "additionalProperties": false,
1907
+ "required": ["code", "phase", "message", "retryable", "correlationId"],
1908
+ "properties": {
1909
+ "code": {
1910
+ "enum": [
1911
+ "BUNDLE_LOAD_FAILED",
1912
+ "DIGEST_MISMATCH",
1913
+ "RUNTIME_CONFIG_EXPIRED",
1914
+ "WIDGET_VERSION_REVOKED",
1915
+ "HOST_API_UNSUPPORTED",
1916
+ "HANDSHAKE_TIMEOUT",
1917
+ "MESSAGE_INVALID",
1918
+ "CHANNEL_MISMATCH",
1919
+ "MESSAGE_TOO_LARGE",
1920
+ "MESSAGE_RATE_LIMITED",
1921
+ "TOO_MANY_PENDING_REQUESTS",
1922
+ "CAPABILITY_UNDECLARED",
1923
+ "CAPABILITY_DENIED",
1924
+ "CAPABILITY_UNSUPPORTED",
1925
+ "CAPABILITY_TIMEOUT",
1926
+ "FILE_REFERENCE_INVALID",
1927
+ "FILE_PERMISSION_DENIED",
1928
+ "RESOURCE_LIMIT",
1929
+ "RENDER_FAILED",
1930
+ "UPDATE_FAILED",
1931
+ "WIDGET_CRASHED",
1932
+ "INSTANCE_DISPOSED"
1933
+ ]
1934
+ },
1935
+ "phase": {
1936
+ "enum": [
1937
+ "load",
1938
+ "handshake",
1939
+ "render",
1940
+ "update",
1941
+ "capability",
1942
+ "dispose"
1943
+ ]
1944
+ },
1945
+ "message": { "type": "string", "minLength": 1 },
1946
+ "retryable": { "type": "boolean" },
1947
+ "correlationId": { "type": "string", "minLength": 1 }
1948
+ }
1949
+ },
1950
+ "ResourceBudget": {
1951
+ "description": "Host 为当前运行签发的资源预算:包、Bridge、文件、超时、并发、重试与失败。",
1952
+ "title": "ResourceBudget",
1953
+ "type": "object",
1954
+ "additionalProperties": false,
1955
+ "required": [
1956
+ "version",
1957
+ "bundle",
1958
+ "bridge",
1959
+ "files",
1960
+ "timeouts",
1961
+ "concurrency",
1962
+ "retry",
1963
+ "failure"
1964
+ ],
1965
+ "properties": {
1966
+ "version": { "const": 1 },
1967
+ "bundle": {
1968
+ "type": "object",
1969
+ "additionalProperties": false,
1970
+ "required": [
1971
+ "compressedBytes",
1972
+ "expandedBytes",
1973
+ "fileCount",
1974
+ "singleFileBytes"
1975
+ ],
1976
+ "properties": {
1977
+ "compressedBytes": { "type": "integer", "minimum": 1 },
1978
+ "expandedBytes": { "type": "integer", "minimum": 1 },
1979
+ "fileCount": { "type": "integer", "minimum": 1 },
1980
+ "singleFileBytes": { "type": "integer", "minimum": 1 }
1981
+ }
1982
+ },
1983
+ "bridge": {
1984
+ "type": "object",
1985
+ "additionalProperties": false,
1986
+ "required": [
1987
+ "messageBytes",
1988
+ "messagesPerSecond",
1989
+ "pendingRequests"
1990
+ ],
1991
+ "properties": {
1992
+ "messageBytes": { "type": "integer", "minimum": 1 },
1993
+ "messagesPerSecond": { "type": "integer", "minimum": 1 },
1994
+ "pendingRequests": { "type": "integer", "minimum": 1 }
1995
+ }
1996
+ },
1997
+ "files": {
1998
+ "type": "object",
1999
+ "additionalProperties": false,
2000
+ "required": [
2001
+ "readBytesPerRequest",
2002
+ "callsPerMinute",
2003
+ "listPageSize"
2004
+ ],
2005
+ "properties": {
2006
+ "readBytesPerRequest": { "type": "integer", "minimum": 1 },
2007
+ "readBytesPerRun": {
2008
+ "description": "历史读取累计额度字段,仅为兼容旧配置保留;当前 files.read 不累计或执行此额度,新宿主不再下发。",
2009
+ "deprecated": true,
2010
+ "type": "integer", "minimum": 1
2011
+ },
2012
+ "callsPerMinute": { "type": "integer", "minimum": 1 },
2013
+ "listPageSize": { "type": "integer", "minimum": 1 },
2014
+ "writeBytesPerRequest": {
2015
+ "description": "写入单次原始字节上限;未签发时不得授权 files.write。",
2016
+ "type": "integer", "minimum": 1, "maximum": 9007199254740991
2017
+ },
2018
+ "writeBytesPerRun": {
2019
+ "description": "当前运行的累计写入原始字节上限;未签发时不得授权 files.write。",
2020
+ "type": "integer", "minimum": 1, "maximum": 9007199254740991
2021
+ }
2022
+ }
2023
+ },
2024
+ "timeouts": {
2025
+ "type": "object",
2026
+ "additionalProperties": false,
2027
+ "required": [
2028
+ "bundleLoadMs",
2029
+ "handshakeMs",
2030
+ "firstRenderMs",
2031
+ "updateMs",
2032
+ "capabilityMs",
2033
+ "disposeGraceMs"
2034
+ ],
2035
+ "properties": {
2036
+ "bundleLoadMs": { "type": "integer", "minimum": 1 },
2037
+ "handshakeMs": { "type": "integer", "minimum": 1 },
2038
+ "firstRenderMs": { "type": "integer", "minimum": 1 },
2039
+ "updateMs": { "type": "integer", "minimum": 1 },
2040
+ "capabilityMs": { "type": "integer", "minimum": 1 },
2041
+ "disposeGraceMs": { "type": "integer", "minimum": 1 }
2042
+ }
2043
+ },
2044
+ "concurrency": {
2045
+ "type": "object",
2046
+ "additionalProperties": false,
2047
+ "required": [
2048
+ "activeIframesPerPage",
2049
+ "activeIframesPerRun",
2050
+ "hiddenRecycleMs"
2051
+ ],
2052
+ "properties": {
2053
+ "activeIframesPerPage": { "type": "integer", "minimum": 1 },
2054
+ "activeIframesPerRun": { "type": "integer", "minimum": 1 },
2055
+ "hiddenRecycleMs": { "type": "integer", "minimum": 1 }
2056
+ }
2057
+ },
2058
+ "retry": {
2059
+ "type": "object",
2060
+ "additionalProperties": false,
2061
+ "required": [
2062
+ "maxAttempts",
2063
+ "initialDelayMs",
2064
+ "maxDelayMs",
2065
+ "totalMs"
2066
+ ],
2067
+ "properties": {
2068
+ "maxAttempts": { "type": "integer", "minimum": 1 },
2069
+ "initialDelayMs": { "type": "integer", "minimum": 1 },
2070
+ "maxDelayMs": { "type": "integer", "minimum": 1 },
2071
+ "totalMs": { "type": "integer", "minimum": 1 }
2072
+ }
2073
+ },
2074
+ "failure": {
2075
+ "type": "object",
2076
+ "additionalProperties": false,
2077
+ "required": ["consecutiveFailures", "windowMs"],
2078
+ "properties": {
2079
+ "consecutiveFailures": { "type": "integer", "minimum": 1 },
2080
+ "windowMs": { "type": "integer", "minimum": 1 }
2081
+ }
2082
+ }
2083
+ }
2084
+ },
2085
+ "InitPayload": {
2086
+ "description": "init 消息负载:实例、locale、theme、能力与资源预算。",
2087
+ "title": "InitPayload",
2088
+ "type": "object",
2089
+ "additionalProperties": false,
2090
+ "required": [
2091
+ "instanceId",
2092
+ "locale",
2093
+ "theme",
2094
+ "capabilities",
2095
+ "resourceBudget"
2096
+ ],
2097
+ "properties": {
2098
+ "instanceId": { "type": "string", "minLength": 1 },
2099
+ "locale": { "type": "string", "minLength": 1 },
2100
+ "theme": { "$ref": "#/$defs/Theme" },
2101
+ "capabilities": {
2102
+ "type": "array",
2103
+ "items": { "$ref": "#/$defs/GrantedCapability" }
2104
+ },
2105
+ "resourceBudget": { "$ref": "#/$defs/ResourceBudget" }
2106
+ }
2107
+ },
2108
+ "BridgeEnvelopeBase": {
2109
+ "description": "Bridge 信封公共字段:protocolVersion、channelId、messageId、sequence。",
2110
+ "title": "BridgeEnvelopeBase",
2111
+ "type": "object",
2112
+ "required": ["protocolVersion", "channelId", "messageId", "sequence"],
2113
+ "properties": {
2114
+ "protocolVersion": { "const": 1 },
2115
+ "channelId": { "type": "string", "minLength": 16 },
2116
+ "messageId": { "type": "string", "minLength": 1 },
2117
+ "sequence": { "type": "integer", "minimum": 1 }
2118
+ }
2119
+ },
2120
+ "InitMessage": {
2121
+ "description": "Host 下发初始上下文的 Bridge 消息。",
2122
+ "title": "InitMessage",
2123
+ "type": "object",
2124
+ "allOf": [
2125
+ { "$ref": "#/$defs/BridgeEnvelopeBase" },
2126
+ {
2127
+ "type": "object",
2128
+ "required": ["type", "payload"],
2129
+ "properties": {
2130
+ "type": { "const": "init" },
2131
+ "payload": { "$ref": "#/$defs/InitPayload" }
2132
+ }
2133
+ }
2134
+ ],
2135
+ "unevaluatedProperties": false
2136
+ },
2137
+ "RenderMessage": {
2138
+ "description": "Host 下发完整渲染快照的 Bridge 消息;type 为 render 或 update。",
2139
+ "title": "RenderMessage",
2140
+ "type": "object",
2141
+ "allOf": [
2142
+ { "$ref": "#/$defs/BridgeEnvelopeBase" },
2143
+ {
2144
+ "type": "object",
2145
+ "required": ["type", "payload"],
2146
+ "properties": {
2147
+ "type": { "enum": ["render", "update"] },
2148
+ "payload": { "$ref": "#/$defs/RenderRequest" }
2149
+ }
2150
+ }
2151
+ ],
2152
+ "unevaluatedProperties": false
2153
+ },
2154
+ "CapabilityResultMessage": {
2155
+ "description": "Host 返回能力请求结果的 Bridge 消息。",
2156
+ "title": "CapabilityResultMessage",
2157
+ "type": "object",
2158
+ "allOf": [
2159
+ { "$ref": "#/$defs/BridgeEnvelopeBase" },
2160
+ {
2161
+ "type": "object",
2162
+ "required": ["type", "payload"],
2163
+ "properties": {
2164
+ "type": { "const": "capability-result" },
2165
+ "payload": {
2166
+ "type": "object",
2167
+ "additionalProperties": false,
2168
+ "required": ["requestId", "result"],
2169
+ "properties": {
2170
+ "requestId": { "type": "string", "minLength": 1 },
2171
+ "result": { "$ref": "#/$defs/CapabilityResult" }
2172
+ }
2173
+ }
2174
+ }
2175
+ }
2176
+ ],
2177
+ "unevaluatedProperties": false
2178
+ },
2179
+ "ErrorMessage": {
2180
+ "description": "任一方向的结构化错误 Bridge 消息。",
2181
+ "title": "ErrorMessage",
2182
+ "type": "object",
2183
+ "allOf": [
2184
+ { "$ref": "#/$defs/BridgeEnvelopeBase" },
2185
+ {
2186
+ "type": "object",
2187
+ "required": ["type", "payload"],
2188
+ "properties": {
2189
+ "type": { "const": "error" },
2190
+ "payload": { "$ref": "#/$defs/WidgetError" }
2191
+ }
2192
+ }
2193
+ ],
2194
+ "unevaluatedProperties": false
2195
+ },
2196
+ "DisposeMessage": {
2197
+ "description": "Host 通知销毁实例的终态 Bridge 消息。",
2198
+ "title": "DisposeMessage",
2199
+ "type": "object",
2200
+ "allOf": [
2201
+ { "$ref": "#/$defs/BridgeEnvelopeBase" },
2202
+ {
2203
+ "type": "object",
2204
+ "required": ["type", "payload"],
2205
+ "properties": {
2206
+ "type": { "const": "dispose" },
2207
+ "payload": {
2208
+ "type": "object",
2209
+ "additionalProperties": false,
2210
+ "required": ["reason", "deadlineMs"],
2211
+ "properties": {
2212
+ "reason": { "type": "string", "minLength": 1 },
2213
+ "deadlineMs": { "type": "integer", "minimum": 1 }
2214
+ }
2215
+ }
2216
+ }
2217
+ }
2218
+ ],
2219
+ "unevaluatedProperties": false
2220
+ },
2221
+ "ReadyMessage": {
2222
+ "description": "Widget 向 Host 上报就绪的 Bridge 消息;含 SDK 与 Host API 版本。",
2223
+ "title": "ReadyMessage",
2224
+ "type": "object",
2225
+ "allOf": [
2226
+ { "$ref": "#/$defs/BridgeEnvelopeBase" },
2227
+ {
2228
+ "type": "object",
2229
+ "required": ["type", "payload"],
2230
+ "properties": {
2231
+ "type": { "const": "ready" },
2232
+ "payload": {
2233
+ "type": "object",
2234
+ "additionalProperties": false,
2235
+ "required": ["widgetSdkVersion", "hostApiVersion"],
2236
+ "properties": {
2237
+ "widgetSdkVersion": { "type": "string", "minLength": 1 },
2238
+ "hostApiVersion": { "const": 1 }
2239
+ }
2240
+ }
2241
+ }
2242
+ }
2243
+ ],
2244
+ "unevaluatedProperties": false
2245
+ },
2246
+ "ResizeMessage": {
2247
+ "description": "Widget 请求调整视口尺寸的 Bridge 消息。",
2248
+ "title": "ResizeMessage",
2249
+ "type": "object",
2250
+ "allOf": [
2251
+ { "$ref": "#/$defs/BridgeEnvelopeBase" },
2252
+ {
2253
+ "type": "object",
2254
+ "required": ["type", "payload"],
2255
+ "properties": {
2256
+ "type": { "const": "resize" },
2257
+ "payload": {
2258
+ "type": "object",
2259
+ "additionalProperties": false,
2260
+ "required": ["width", "height"],
2261
+ "properties": {
2262
+ "width": { "type": "number", "minimum": 0 },
2263
+ "height": { "type": "number", "minimum": 0 }
2264
+ }
2265
+ }
2266
+ }
2267
+ }
2268
+ ],
2269
+ "unevaluatedProperties": false
2270
+ },
2271
+ "CapabilityRequestMessage": {
2272
+ "description": "Widget 发起能力请求的 Bridge 消息。",
2273
+ "title": "CapabilityRequestMessage",
2274
+ "type": "object",
2275
+ "allOf": [
2276
+ { "$ref": "#/$defs/BridgeEnvelopeBase" },
2277
+ {
2278
+ "type": "object",
2279
+ "required": ["type", "payload"],
2280
+ "properties": {
2281
+ "type": { "const": "capability-request" },
2282
+ "payload": {
2283
+ "type": "object",
2284
+ "additionalProperties": false,
2285
+ "required": ["requestId", "request"],
2286
+ "properties": {
2287
+ "requestId": { "type": "string", "minLength": 1 },
2288
+ "request": { "$ref": "#/$defs/CapabilityRequest" }
2289
+ }
2290
+ }
2291
+ }
2292
+ }
2293
+ ],
2294
+ "unevaluatedProperties": false
2295
+ },
2296
+ "HostToWidgetMessage": {
2297
+ "description": "Host → Widget 的 Bridge 消息联合。",
2298
+ "title": "HostToWidgetMessage",
2299
+ "oneOf": [
2300
+ { "$ref": "#/$defs/InitMessage" },
2301
+ { "$ref": "#/$defs/RenderMessage" },
2302
+ { "$ref": "#/$defs/WidgetEventMessage" },
2303
+ { "$ref": "#/$defs/CapabilityResultMessage" },
2304
+ { "$ref": "#/$defs/ErrorMessage" },
2305
+ { "$ref": "#/$defs/DisposeMessage" }
2306
+ ]
2307
+ },
2308
+ "WidgetToHostMessage": {
2309
+ "description": "Widget → Host 的 Bridge 消息联合。",
2310
+ "title": "WidgetToHostMessage",
2311
+ "oneOf": [
2312
+ { "$ref": "#/$defs/ReadyMessage" },
2313
+ { "$ref": "#/$defs/ResizeMessage" },
2314
+ { "$ref": "#/$defs/CapabilityRequestMessage" },
2315
+ { "$ref": "#/$defs/ErrorMessage" }
2316
+ ]
2317
+ },
2318
+ "PublicWidgetEventTopic": {
2319
+ "title": "PublicWidgetEventTopic",
2320
+ "description": "Agent Widget 从当前 Workflow 流公开的事件主题。",
2321
+ "enum": [
2322
+ "workflow.lifecycle",
2323
+ "tools.lifecycle",
2324
+ "approval.lifecycle",
2325
+ "interaction.lifecycle"
2326
+ ]
2327
+ },
2328
+ "PublicWidgetEvent": {
2329
+ "title": "PublicWidgetEvent",
2330
+ "description": "Agent Widget 从已解析 Workflow 事件构造并向 Widget Runtime 推送的事件联合。",
2331
+ "oneOf": [
2332
+ { "$ref": "#/$defs/WorkflowStartedPublicWidgetEvent" },
2333
+ { "$ref": "#/$defs/WorkflowDonePublicWidgetEvent" },
2334
+ { "$ref": "#/$defs/WorkflowErrorPublicWidgetEvent" },
2335
+ { "$ref": "#/$defs/ToolCallPublicWidgetEvent" },
2336
+ { "$ref": "#/$defs/ToolResultPublicWidgetEvent" },
2337
+ { "$ref": "#/$defs/SandboxApprovalRequestedPublicWidgetEvent" },
2338
+ { "$ref": "#/$defs/SandboxApprovedPublicWidgetEvent" },
2339
+ { "$ref": "#/$defs/SandboxDeniedPublicWidgetEvent" },
2340
+ { "$ref": "#/$defs/UserInputRequestedPublicWidgetEvent" },
2341
+ { "$ref": "#/$defs/ComputeReviewRequestedPublicWidgetEvent" }
2342
+ ]
2343
+ },
2344
+ "WidgetLiveEvent": {
2345
+ "title": "WidgetLiveEvent",
2346
+ "description": "Host 从当前 Runtime 向 iframe 主动推送的聚合事件;事件由 type 唯一标识。",
2347
+ "type": "object",
2348
+ "additionalProperties": false,
2349
+ "required": ["type", "payload"],
2350
+ "properties": {
2351
+ "type": {
2352
+ "$ref": "#/$defs/WidgetEventName"
2353
+ },
2354
+ "payload": {
2355
+ "type": "object",
2356
+ "additionalProperties": { "$ref": "#/$defs/JsonValue" }
2357
+ }
2358
+ }
2359
+ },
2360
+ "WidgetEventName": {
2361
+ "title": "WidgetEventName",
2362
+ "description": "已激活 Widget 可监听的实时事件;session.start 只用于激活,不在此列。",
2363
+ "type": "string",
2364
+ "enum": [
2365
+ "turn-start",
2366
+ "turn-end",
2367
+ "step-start",
2368
+ "step-end",
2369
+ "tool-call-generating",
2370
+ "tool-call-waiting",
2371
+ "tool-call-running",
2372
+ "tool-call-result",
2373
+ "tool-call-error",
2374
+ "workspace-file-changed",
2375
+ "workspace-tree-refresh",
2376
+ "workspace-file-opened",
2377
+ "ui-tool-opened",
2378
+ "ui-panel-focused",
2379
+ "host-surface-changed"
2380
+ ]
2381
+ },
2382
+ "PublicWidgetEventId": {
2383
+ "title": "PublicWidgetEventId",
2384
+ "description": "用于同一 Agent Widget Runtime 内去重的稳定事件标识。",
2385
+ "type": "string",
2386
+ "minLength": 1,
2387
+ "maxLength": 256
2388
+ },
2389
+ "PublicWidgetSessionId": {
2390
+ "title": "PublicWidgetSessionId",
2391
+ "description": "事件所属的 Session 标识。",
2392
+ "type": "string",
2393
+ "minLength": 1,
2394
+ "maxLength": 256
2395
+ },
2396
+ "PublicWidgetWorkflowId": {
2397
+ "title": "PublicWidgetWorkflowId",
2398
+ "description": "事件所属的 Workflow 标识。",
2399
+ "type": "string",
2400
+ "minLength": 1,
2401
+ "maxLength": 256
2402
+ },
2403
+ "PublicWidgetEventOccurredAt": {
2404
+ "title": "PublicWidgetEventOccurredAt",
2405
+ "description": "事件产生时间:YYYY-MM-DD + T + 非空格字符,以 Z 结尾。",
2406
+ "type": "string",
2407
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T[^ ]+Z$"
2408
+ },
2409
+ "WorkflowStartedPublicWidgetEventPayload": {
2410
+ "title": "WorkflowStartedPublicWidgetEventPayload",
2411
+ "description": "Workflow 流已建立时公开的数据。",
2412
+ "type": "object",
2413
+ "additionalProperties": false,
2414
+ "required": ["protocolVersion"],
2415
+ "properties": {
2416
+ "protocolVersion": { "type": "integer", "minimum": 1 }
2417
+ }
2418
+ },
2419
+ "EmptyPublicWidgetEventPayload": {
2420
+ "title": "EmptyPublicWidgetEventPayload",
2421
+ "description": "没有额外业务字段的事件负载。",
2422
+ "type": "object",
2423
+ "additionalProperties": false
2424
+ },
2425
+ "WorkflowDonePublicWidgetEventPayload": {
2426
+ "title": "WorkflowDonePublicWidgetEventPayload",
2427
+ "description": "Workflow 正常结束时公开的数据。",
2428
+ "type": "object",
2429
+ "additionalProperties": false,
2430
+ "required": ["status"],
2431
+ "properties": {
2432
+ "status": { "enum": ["completed", "failed", "cancelled", "expired"] },
2433
+ "durationMs": { "type": "number", "minimum": 0 },
2434
+ "error": { "type": "string" }
2435
+ }
2436
+ },
2437
+ "WorkflowErrorPublicWidgetEventPayload": {
2438
+ "title": "WorkflowErrorPublicWidgetEventPayload",
2439
+ "description": "Workflow 错误事件公开的数据。",
2440
+ "type": "object",
2441
+ "additionalProperties": false,
2442
+ "required": ["terminal"],
2443
+ "properties": {
2444
+ "terminal": { "type": "boolean" },
2445
+ "error": { "type": "string" }
2446
+ }
2447
+ },
2448
+ "ToolCallPublicWidgetEventPayload": {
2449
+ "title": "ToolCallPublicWidgetEventPayload",
2450
+ "description": "tool-call 原始语义对应的公开数据。",
2451
+ "type": "object",
2452
+ "additionalProperties": false,
2453
+ "required": ["toolCallId", "toolName"],
2454
+ "properties": {
2455
+ "toolCallId": {
2456
+ "type": "string",
2457
+ "minLength": 1,
2458
+ "maxLength": 256
2459
+ },
2460
+ "toolName": {
2461
+ "type": "string",
2462
+ "minLength": 1,
2463
+ "maxLength": 128,
2464
+ "pattern": "^[A-Za-z0-9_.:-]+$"
2465
+ },
2466
+ "args": { "$ref": "#/$defs/JsonValue" },
2467
+ "executionState": { "enum": ["waiting", "running"] }
2468
+ }
2469
+ },
2470
+ "ToolResultPublicWidgetEventPayload": {
2471
+ "title": "ToolResultPublicWidgetEventPayload",
2472
+ "description": "tool-result 原始语义对应的公开数据。",
2473
+ "type": "object",
2474
+ "additionalProperties": false,
2475
+ "required": ["toolCallId", "output"],
2476
+ "properties": {
2477
+ "toolCallId": { "type": "string", "minLength": 1, "maxLength": 256 },
2478
+ "toolName": {
2479
+ "type": "string",
2480
+ "minLength": 1,
2481
+ "maxLength": 128,
2482
+ "pattern": "^[A-Za-z0-9_.:-]+$"
2483
+ },
2484
+ "output": { "$ref": "#/$defs/JsonValue" },
2485
+ "durationMs": { "type": "number", "minimum": 0 }
2486
+ }
2487
+ },
2488
+ "SandboxApprovalRequestedPublicWidgetEventPayload": {
2489
+ "title": "SandboxApprovalRequestedPublicWidgetEventPayload",
2490
+ "description": "沙盒审批请求公开的数据。",
2491
+ "type": "object",
2492
+ "additionalProperties": false,
2493
+ "required": ["approvalId", "mode"],
2494
+ "properties": {
2495
+ "approvalId": { "type": "string", "minLength": 1, "maxLength": 256 },
2496
+ "mode": { "enum": ["create", "reuse"] },
2497
+ "sandboxName": { "type": "string" },
2498
+ "resource": { "$ref": "#/$defs/JsonValue" },
2499
+ "existingSandboxes": {
2500
+ "type": "array",
2501
+ "items": {
2502
+ "type": "object",
2503
+ "additionalProperties": false,
2504
+ "required": ["id", "name"],
2505
+ "properties": {
2506
+ "id": { "type": "string", "minLength": 1 },
2507
+ "name": { "type": "string", "minLength": 1 }
2508
+ }
2509
+ }
2510
+ },
2511
+ "proxyAgentName": { "type": "string" }
2512
+ }
2513
+ },
2514
+ "SandboxApprovedPublicWidgetEventPayload": {
2515
+ "title": "SandboxApprovedPublicWidgetEventPayload",
2516
+ "description": "沙盒审批通过时公开的数据。",
2517
+ "type": "object",
2518
+ "additionalProperties": false,
2519
+ "required": ["sandboxId"],
2520
+ "properties": {
2521
+ "sandboxId": { "type": "string", "minLength": 1, "maxLength": 256 }
2522
+ }
2523
+ },
2524
+ "UserInputRequestedPublicWidgetEventPayload": {
2525
+ "title": "UserInputRequestedPublicWidgetEventPayload",
2526
+ "description": "用户输入请求公开的数据。",
2527
+ "type": "object",
2528
+ "additionalProperties": false,
2529
+ "properties": {
2530
+ "toolCallId": { "type": "string", "minLength": 1, "maxLength": 256 },
2531
+ "requestId": { "type": "string", "minLength": 1, "maxLength": 256 },
2532
+ "request": { "$ref": "#/$defs/JsonValue" },
2533
+ "schema": { "$ref": "#/$defs/JsonValue" },
2534
+ "title": { "type": "string" },
2535
+ "description": { "type": "string" },
2536
+ "retryAttempt": { "type": "integer", "minimum": 0 },
2537
+ "retryMessage": { "type": "string" },
2538
+ "cancellable": { "type": "boolean" },
2539
+ "timeoutSeconds": { "type": "number", "minimum": 0 },
2540
+ "proxyWorkflowId": { "type": "string" },
2541
+ "proxyAgentName": { "type": "string" }
2542
+ }
2543
+ },
2544
+ "ComputeReviewRequestedPublicWidgetEventPayload": {
2545
+ "title": "ComputeReviewRequestedPublicWidgetEventPayload",
2546
+ "description": "计算任务审批请求公开的数据。",
2547
+ "type": "object",
2548
+ "additionalProperties": false,
2549
+ "required": ["draftId", "toolCallId"],
2550
+ "properties": {
2551
+ "draftId": { "type": "string", "minLength": 1, "maxLength": 256 },
2552
+ "toolCallId": { "type": "string", "minLength": 1, "maxLength": 256 }
2553
+ }
2554
+ },
2555
+ "PublicWidgetEventBase": {
2556
+ "description": "公开事件公共字段:schemaVersion、id、occurredAt、sessionId、workflowId。",
2557
+ "title": "PublicWidgetEventBase",
2558
+ "type": "object",
2559
+ "required": [
2560
+ "schemaVersion",
2561
+ "id",
2562
+ "occurredAt",
2563
+ "sessionId",
2564
+ "workflowId"
2565
+ ],
2566
+ "properties": {
2567
+ "schemaVersion": { "const": 1 },
2568
+ "id": { "$ref": "#/$defs/PublicWidgetEventId" },
2569
+ "occurredAt": { "$ref": "#/$defs/PublicWidgetEventOccurredAt" },
2570
+ "sessionId": { "$ref": "#/$defs/PublicWidgetSessionId" },
2571
+ "workflowId": { "$ref": "#/$defs/PublicWidgetWorkflowId" }
2572
+ }
2573
+ },
2574
+ "WorkflowStartedPublicWidgetEvent": {
2575
+ "title": "WorkflowStartedPublicWidgetEvent",
2576
+ "description": "Workflow 流建立事件。",
2577
+ "type": "object",
2578
+ "allOf": [
2579
+ { "$ref": "#/$defs/PublicWidgetEventBase" },
2580
+ {
2581
+ "type": "object",
2582
+ "required": ["topic", "type", "payload"],
2583
+ "properties": {
2584
+ "topic": { "const": "workflow.lifecycle" },
2585
+ "type": { "const": "connected" },
2586
+ "payload": { "$ref": "#/$defs/WorkflowStartedPublicWidgetEventPayload" }
2587
+ }
2588
+ }
2589
+ ],
2590
+ "unevaluatedProperties": false
2591
+ },
2592
+ "WorkflowDonePublicWidgetEvent": {
2593
+ "title": "WorkflowDonePublicWidgetEvent",
2594
+ "description": "Workflow 正常终态事件。",
2595
+ "type": "object",
2596
+ "allOf": [
2597
+ { "$ref": "#/$defs/PublicWidgetEventBase" },
2598
+ {
2599
+ "type": "object",
2600
+ "required": ["topic", "type", "payload"],
2601
+ "properties": {
2602
+ "topic": { "const": "workflow.lifecycle" },
2603
+ "type": { "const": "done" },
2604
+ "payload": { "$ref": "#/$defs/WorkflowDonePublicWidgetEventPayload" }
2605
+ }
2606
+ }
2607
+ ],
2608
+ "unevaluatedProperties": false
2609
+ },
2610
+ "WorkflowErrorPublicWidgetEvent": {
2611
+ "title": "WorkflowErrorPublicWidgetEvent",
2612
+ "description": "Workflow 错误事件。",
2613
+ "type": "object",
2614
+ "allOf": [
2615
+ { "$ref": "#/$defs/PublicWidgetEventBase" },
2616
+ {
2617
+ "type": "object",
2618
+ "required": ["topic", "type", "payload"],
2619
+ "properties": {
2620
+ "topic": { "const": "workflow.lifecycle" },
2621
+ "type": { "const": "error" },
2622
+ "payload": { "$ref": "#/$defs/WorkflowErrorPublicWidgetEventPayload" }
2623
+ }
2624
+ }
2625
+ ],
2626
+ "unevaluatedProperties": false
2627
+ },
2628
+ "ToolCallPublicWidgetEvent": {
2629
+ "title": "ToolCallPublicWidgetEvent",
2630
+ "description": "tool-call 事件。",
2631
+ "type": "object",
2632
+ "allOf": [
2633
+ { "$ref": "#/$defs/PublicWidgetEventBase" },
2634
+ {
2635
+ "type": "object",
2636
+ "required": ["topic", "type", "payload"],
2637
+ "properties": {
2638
+ "topic": { "const": "tools.lifecycle" },
2639
+ "type": { "const": "tool-call" },
2640
+ "payload": { "$ref": "#/$defs/ToolCallPublicWidgetEventPayload" }
2641
+ }
2642
+ }
2643
+ ],
2644
+ "unevaluatedProperties": false
2645
+ },
2646
+ "ToolResultPublicWidgetEvent": {
2647
+ "title": "ToolResultPublicWidgetEvent",
2648
+ "description": "tool-result 事件。",
2649
+ "type": "object",
2650
+ "allOf": [
2651
+ { "$ref": "#/$defs/PublicWidgetEventBase" },
2652
+ {
2653
+ "type": "object",
2654
+ "required": ["topic", "type", "payload"],
2655
+ "properties": {
2656
+ "topic": { "const": "tools.lifecycle" },
2657
+ "type": { "const": "tool-result" },
2658
+ "payload": { "$ref": "#/$defs/ToolResultPublicWidgetEventPayload" }
2659
+ }
2660
+ }
2661
+ ],
2662
+ "unevaluatedProperties": false
2663
+ },
2664
+ "SandboxApprovalRequestedPublicWidgetEvent": {
2665
+ "title": "SandboxApprovalRequestedPublicWidgetEvent",
2666
+ "description": "sandbox-approval-requested 事件。",
2667
+ "type": "object",
2668
+ "allOf": [
2669
+ { "$ref": "#/$defs/PublicWidgetEventBase" },
2670
+ {
2671
+ "type": "object",
2672
+ "required": ["topic", "type", "payload"],
2673
+ "properties": {
2674
+ "topic": { "const": "approval.lifecycle" },
2675
+ "type": { "const": "sandbox-approval-requested" },
2676
+ "payload": { "$ref": "#/$defs/SandboxApprovalRequestedPublicWidgetEventPayload" }
2677
+ }
2678
+ }
2679
+ ],
2680
+ "unevaluatedProperties": false
2681
+ },
2682
+ "SandboxApprovedPublicWidgetEvent": {
2683
+ "title": "SandboxApprovedPublicWidgetEvent",
2684
+ "description": "sandbox-approved 事件。",
2685
+ "type": "object",
2686
+ "allOf": [
2687
+ { "$ref": "#/$defs/PublicWidgetEventBase" },
2688
+ {
2689
+ "type": "object",
2690
+ "required": ["topic", "type", "payload"],
2691
+ "properties": {
2692
+ "topic": { "const": "approval.lifecycle" },
2693
+ "type": { "const": "sandbox-approved" },
2694
+ "payload": { "$ref": "#/$defs/SandboxApprovedPublicWidgetEventPayload" }
2695
+ }
2696
+ }
2697
+ ],
2698
+ "unevaluatedProperties": false
2699
+ },
2700
+ "SandboxDeniedPublicWidgetEvent": {
2701
+ "title": "SandboxDeniedPublicWidgetEvent",
2702
+ "description": "sandbox-denied 事件。",
2703
+ "type": "object",
2704
+ "allOf": [
2705
+ { "$ref": "#/$defs/PublicWidgetEventBase" },
2706
+ {
2707
+ "type": "object",
2708
+ "required": ["topic", "type", "payload"],
2709
+ "properties": {
2710
+ "topic": { "const": "approval.lifecycle" },
2711
+ "type": { "const": "sandbox-denied" },
2712
+ "payload": { "$ref": "#/$defs/EmptyPublicWidgetEventPayload" }
2713
+ }
2714
+ }
2715
+ ],
2716
+ "unevaluatedProperties": false
2717
+ },
2718
+ "UserInputRequestedPublicWidgetEvent": {
2719
+ "title": "UserInputRequestedPublicWidgetEvent",
2720
+ "description": "user-input-requested 事件。",
2721
+ "type": "object",
2722
+ "allOf": [
2723
+ { "$ref": "#/$defs/PublicWidgetEventBase" },
2724
+ {
2725
+ "type": "object",
2726
+ "required": ["topic", "type", "payload"],
2727
+ "properties": {
2728
+ "topic": { "const": "interaction.lifecycle" },
2729
+ "type": { "const": "user-input-requested" },
2730
+ "payload": { "$ref": "#/$defs/UserInputRequestedPublicWidgetEventPayload" }
2731
+ }
2732
+ }
2733
+ ],
2734
+ "unevaluatedProperties": false
2735
+ },
2736
+ "ComputeReviewRequestedPublicWidgetEvent": {
2737
+ "title": "ComputeReviewRequestedPublicWidgetEvent",
2738
+ "description": "compute-review-requested 事件。",
2739
+ "type": "object",
2740
+ "allOf": [
2741
+ { "$ref": "#/$defs/PublicWidgetEventBase" },
2742
+ {
2743
+ "type": "object",
2744
+ "required": ["topic", "type", "payload"],
2745
+ "properties": {
2746
+ "topic": { "const": "interaction.lifecycle" },
2747
+ "type": { "const": "compute-review-requested" },
2748
+ "payload": { "$ref": "#/$defs/ComputeReviewRequestedPublicWidgetEventPayload" }
2749
+ }
2750
+ }
2751
+ ],
2752
+ "unevaluatedProperties": false
2753
+ },
2754
+ "WidgetEventMessage": {
2755
+ "title": "WidgetEventMessage",
2756
+ "description": "Host 通过当前 Widget MessageChannel 主动推送的 Workflow 事件。",
2757
+ "type": "object",
2758
+ "allOf": [
2759
+ { "$ref": "#/$defs/BridgeEnvelopeBase" },
2760
+ {
2761
+ "type": "object",
2762
+ "required": ["type", "payload"],
2763
+ "properties": {
2764
+ "type": { "const": "event" },
2765
+ "payload": { "$ref": "#/$defs/WidgetLiveEvent" }
2766
+ }
2767
+ }
2768
+ ],
2769
+ "unevaluatedProperties": false
2770
+ },
2771
+ "WidgetEvent": {
2772
+ "description": "低层 events.read 事件页中的单条原始事件;type 为受限标识、payload 为 JSON。",
2773
+ "type": "object",
2774
+ "additionalProperties": false,
2775
+ "required": [
2776
+ "id",
2777
+ "type",
2778
+ "payload"
2779
+ ],
2780
+ "properties": {
2781
+ "id": {
2782
+ "type": "string",
2783
+ "minLength": 1,
2784
+ "maxLength": 256
2785
+ },
2786
+ "type": {
2787
+ "type": "string",
2788
+ "minLength": 1,
2789
+ "maxLength": 128,
2790
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
2791
+ },
2792
+ "payload": {
2793
+ "$ref": "#/$defs/JsonValue"
2794
+ }
2795
+ }
2796
+ },
2797
+ "WidgetEventBatch": {
2798
+ "description": "低层 events.read 的一页事件:topic、cursor、reset、hasMore 与事件列表。",
2799
+ "type": "object",
2800
+ "additionalProperties": false,
2801
+ "required": [
2802
+ "schemaVersion",
2803
+ "topic",
2804
+ "cursor",
2805
+ "reset",
2806
+ "hasMore",
2807
+ "events"
2808
+ ],
2809
+ "properties": {
2810
+ "schemaVersion": {
2811
+ "const": 1
2812
+ },
2813
+ "topic": {
2814
+ "type": "string",
2815
+ "minLength": 1,
2816
+ "maxLength": 128,
2817
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
2818
+ },
2819
+ "cursor": {
2820
+ "type": "string",
2821
+ "minLength": 1,
2822
+ "maxLength": 256
2823
+ },
2824
+ "reset": {
2825
+ "type": "boolean"
2826
+ },
2827
+ "hasMore": {
2828
+ "type": "boolean"
2829
+ },
2830
+ "events": {
2831
+ "type": "array",
2832
+ "maxItems": 100,
2833
+ "items": {
2834
+ "$ref": "#/$defs/WidgetEvent"
2835
+ }
2836
+ },
2837
+ "snapshot": {
2838
+ "$ref": "#/$defs/JsonValue"
2839
+ }
2840
+ }
2841
+ },
2842
+ "ToolLifecycleEvent": {
2843
+ "description": "工具生命周期事件:started / completed / failed / cancelled。",
2844
+ "type": "object",
2845
+ "additionalProperties": false,
2846
+ "required": [
2847
+ "toolCallId",
2848
+ "toolName",
2849
+ "phase"
2850
+ ],
2851
+ "properties": {
2852
+ "toolCallId": {
2853
+ "type": "string",
2854
+ "minLength": 1,
2855
+ "maxLength": 256
2856
+ },
2857
+ "toolName": {
2858
+ "type": "string",
2859
+ "minLength": 1,
2860
+ "maxLength": 128,
2861
+ "pattern": "^[A-Za-z0-9_.:-]+$"
2862
+ },
2863
+ "phase": {
2864
+ "enum": [
2865
+ "started",
2866
+ "completed",
2867
+ "failed",
2868
+ "cancelled"
2869
+ ]
2870
+ }
2871
+ }
2872
+ }
2873
+ }
2874
+ }