@dp-bohrium/widget-cli 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/assets/schemas/widget-runtime-contracts.schema.json +906 -0
- package/assets/toolchain.json +8 -8
- package/dist/cli.mjs +184 -14
- package/dist/core.d.mts +1 -348
- package/dist/core.mjs +1 -1
- package/dist/development-host.d.mts +40 -4
- package/dist/{dsh-BlpXm2Bv.mjs → dsh-BL6cMLrg.mjs} +1151 -3
- package/dist/generated-runtime-contracts-CbZY-iss.d.mts +500 -0
- package/package.json +2 -2
|
@@ -5,7 +5,7 @@ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
//#region ../../.build/widget-stage-tools/tooling/compiler.mjs
|
|
7
7
|
/** 从当前安装的 SDK package.json 读取版本,插件作者不需要重复填写。 */
|
|
8
|
-
const WIDGET_SDK_VERSION = "0.
|
|
8
|
+
const WIDGET_SDK_VERSION = "0.9.0";
|
|
9
9
|
function compiledContribution(contribution) {
|
|
10
10
|
switch (contribution.type) {
|
|
11
11
|
case "panel": return {
|
|
@@ -165,6 +165,490 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
165
165
|
enumerable: true
|
|
166
166
|
}) : target, mod));
|
|
167
167
|
/** GENERATED FILE. Do not edit directly. */
|
|
168
|
+
const widgetDevelopmentPolicy = {
|
|
169
|
+
"required": [
|
|
170
|
+
"schemaVersion",
|
|
171
|
+
"source",
|
|
172
|
+
"code",
|
|
173
|
+
"phase",
|
|
174
|
+
"operation",
|
|
175
|
+
"severity",
|
|
176
|
+
"message"
|
|
177
|
+
],
|
|
178
|
+
"keys": [
|
|
179
|
+
"schemaVersion",
|
|
180
|
+
"source",
|
|
181
|
+
"code",
|
|
182
|
+
"sourceCode",
|
|
183
|
+
"phase",
|
|
184
|
+
"sourcePhase",
|
|
185
|
+
"operation",
|
|
186
|
+
"severity",
|
|
187
|
+
"message",
|
|
188
|
+
"retryable",
|
|
189
|
+
"correlationId",
|
|
190
|
+
"diagnostics",
|
|
191
|
+
"io"
|
|
192
|
+
],
|
|
193
|
+
"textMax": {
|
|
194
|
+
"code": 96,
|
|
195
|
+
"sourceCode": 96,
|
|
196
|
+
"sourcePhase": 96,
|
|
197
|
+
"operation": 96,
|
|
198
|
+
"message": 1024,
|
|
199
|
+
"field": 128,
|
|
200
|
+
"expected": 256,
|
|
201
|
+
"observed": 256,
|
|
202
|
+
"file": 256,
|
|
203
|
+
"excerpt": 1024
|
|
204
|
+
},
|
|
205
|
+
"maxDetails": 8,
|
|
206
|
+
"phases": [
|
|
207
|
+
"discovery",
|
|
208
|
+
"build",
|
|
209
|
+
"config",
|
|
210
|
+
"load",
|
|
211
|
+
"handshake",
|
|
212
|
+
"render",
|
|
213
|
+
"update",
|
|
214
|
+
"capability",
|
|
215
|
+
"dispose"
|
|
216
|
+
],
|
|
217
|
+
"severities": [
|
|
218
|
+
"warning",
|
|
219
|
+
"request-error",
|
|
220
|
+
"instance-failure"
|
|
221
|
+
],
|
|
222
|
+
"identifierPattern": "^[A-Za-z][A-Za-z0-9_.-]*$",
|
|
223
|
+
"filePattern": "^(?!/)(?!.*\\\\)(?!.*:)(?!.*(?:^|/)\\.{1,2}(?:/|$))[^\\u0000-\\u001f]+$"
|
|
224
|
+
};
|
|
225
|
+
function record(value) {
|
|
226
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
227
|
+
}
|
|
228
|
+
function keys(value, required, allowed = required) {
|
|
229
|
+
return required.every((key) => Object.hasOwn(value, key)) && Object.keys(value).every((key) => allowed.includes(key));
|
|
230
|
+
}
|
|
231
|
+
const identifier = new RegExp(widgetDevelopmentPolicy.identifierPattern, "u");
|
|
232
|
+
const sourceFile = new RegExp(widgetDevelopmentPolicy.filePattern, "u");
|
|
233
|
+
function text(value, max, empty = false) {
|
|
234
|
+
return typeof value === "string" && (empty || value.length > 0) && [...value].length <= max;
|
|
235
|
+
}
|
|
236
|
+
function correlation(value) {
|
|
237
|
+
return typeof value === "string" && value.length > 0;
|
|
238
|
+
}
|
|
239
|
+
function id(value) {
|
|
240
|
+
return text(value, widgetDevelopmentPolicy.textMax.code) && identifier.test(value);
|
|
241
|
+
}
|
|
242
|
+
function detail(value) {
|
|
243
|
+
if (!record(value)) return false;
|
|
244
|
+
if ("file" in value) return keys(value, [
|
|
245
|
+
"file",
|
|
246
|
+
"line",
|
|
247
|
+
"column"
|
|
248
|
+
], [
|
|
249
|
+
"file",
|
|
250
|
+
"line",
|
|
251
|
+
"column",
|
|
252
|
+
"excerpt"
|
|
253
|
+
]) && text(value["file"], widgetDevelopmentPolicy.textMax.file) && sourceFile.test(value["file"]) && Number.isSafeInteger(value["line"]) && Number(value["line"]) > 0 && Number.isSafeInteger(value["column"]) && Number(value["column"]) > 0 && (value["excerpt"] === void 0 || text(value["excerpt"], widgetDevelopmentPolicy.textMax.excerpt));
|
|
254
|
+
return keys(value, ["field"], [
|
|
255
|
+
"field",
|
|
256
|
+
"expected",
|
|
257
|
+
"observed"
|
|
258
|
+
]) && text(value["field"], widgetDevelopmentPolicy.textMax.field) && (value["expected"] === void 0 || text(value["expected"], widgetDevelopmentPolicy.textMax.expected, true)) && (value["observed"] === void 0 || text(value["observed"], widgetDevelopmentPolicy.textMax.observed, true));
|
|
259
|
+
}
|
|
260
|
+
function io(value) {
|
|
261
|
+
if (!record(value) || !keys(value, ["kind"], [
|
|
262
|
+
"kind",
|
|
263
|
+
"status",
|
|
264
|
+
"sourceCode"
|
|
265
|
+
]) || value["sourceCode"] !== void 0 && !id(value["sourceCode"])) return false;
|
|
266
|
+
if (value["kind"] === "http") return Number.isInteger(value["status"]) && Number(value["status"]) >= 100 && Number(value["status"]) <= 599 && !(Number(value["status"]) >= 200 && Number(value["status"]) < 300);
|
|
267
|
+
return (value["kind"] === "transport" || value["kind"] === "invalid-response") && value["status"] === void 0;
|
|
268
|
+
}
|
|
269
|
+
/** 与源头 Schema 同源限额的轻量边界判定,不加载 AJV 或 Runtime。 */
|
|
270
|
+
function isWidgetGuestDiagnostic(value) {
|
|
271
|
+
if (!record(value) || !keys(value, widgetDevelopmentPolicy.required, widgetDevelopmentPolicy.keys) || value["schemaVersion"] !== 1 || value["source"] !== "sdk" || !id(value["code"]) || !id(value["operation"]) || !widgetDevelopmentPolicy.phases.some((phase) => phase === value["phase"]) || !widgetDevelopmentPolicy.severities.some((severity) => severity === value["severity"]) || !text(value["message"], widgetDevelopmentPolicy.textMax.message)) return false;
|
|
272
|
+
if (value["retryable"] !== void 0 && typeof value["retryable"] !== "boolean" || value["correlationId"] !== void 0 && !correlation(value["correlationId"]) || value["sourceCode"] !== void 0 && !id(value["sourceCode"]) || value["sourcePhase"] !== void 0 && !id(value["sourcePhase"])) return false;
|
|
273
|
+
return (value["diagnostics"] === void 0 || Array.isArray(value["diagnostics"]) && value["diagnostics"].length <= widgetDevelopmentPolicy.maxDetails && value["diagnostics"].every(detail)) && (value["io"] === void 0 || io(value["io"]));
|
|
274
|
+
}
|
|
275
|
+
/** 失败回执仍需 Host 再匹配实际已发送的 request/revision。 */
|
|
276
|
+
function isWidgetRenderResult(value) {
|
|
277
|
+
if (!record(value) || !correlation(value["requestId"]) || !Number.isSafeInteger(value["revision"]) || Number(value["revision"]) < 1) return false;
|
|
278
|
+
if (value["outcome"] === "handled" || value["outcome"] === "superseded") return keys(value, [
|
|
279
|
+
"requestId",
|
|
280
|
+
"revision",
|
|
281
|
+
"outcome"
|
|
282
|
+
]);
|
|
283
|
+
return value["outcome"] === "failed" && keys(value, [
|
|
284
|
+
"requestId",
|
|
285
|
+
"revision",
|
|
286
|
+
"outcome",
|
|
287
|
+
"diagnostic"
|
|
288
|
+
]) && isWidgetGuestDiagnostic(value["diagnostic"]) && value["diagnostic"].correlationId === value["requestId"] && (value["diagnostic"].phase === "render" || value["diagnostic"].phase === "update");
|
|
289
|
+
}
|
|
290
|
+
function rule(input) {
|
|
291
|
+
const followUpActions = input.disposition === "repair" ? [
|
|
292
|
+
{
|
|
293
|
+
id: "build-project",
|
|
294
|
+
params: { target: "current-project" }
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
id: "refresh-preview",
|
|
298
|
+
params: { target: "current-project" }
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
id: "verify-scenario",
|
|
302
|
+
params: { target: "next-built-generation" }
|
|
303
|
+
}
|
|
304
|
+
] : [];
|
|
305
|
+
const value = {
|
|
306
|
+
id: input.id,
|
|
307
|
+
version: 1,
|
|
308
|
+
sources: [input.source],
|
|
309
|
+
codes: input.codes,
|
|
310
|
+
disposition: input.disposition ?? "inspect",
|
|
311
|
+
nextAction: input.nextAction ?? {
|
|
312
|
+
id: "inspect",
|
|
313
|
+
params: { area: input.area }
|
|
314
|
+
},
|
|
315
|
+
verification: input.verification ?? {
|
|
316
|
+
target: "current-attempt",
|
|
317
|
+
milestone: "diagnostics-updated"
|
|
318
|
+
},
|
|
319
|
+
guidance: input.guidance,
|
|
320
|
+
followUpActions
|
|
321
|
+
};
|
|
322
|
+
Object.freeze(value.sources);
|
|
323
|
+
Object.freeze(value.codes);
|
|
324
|
+
Object.freeze(value.nextAction.params);
|
|
325
|
+
Object.freeze(value.nextAction);
|
|
326
|
+
Object.freeze(value.verification);
|
|
327
|
+
for (const action of followUpActions) {
|
|
328
|
+
Object.freeze(action.params);
|
|
329
|
+
Object.freeze(action);
|
|
330
|
+
}
|
|
331
|
+
Object.freeze(followUpActions);
|
|
332
|
+
return Object.freeze(value);
|
|
333
|
+
}
|
|
334
|
+
/** 通用恢复目录;宿主绑定已有工具及权限,Guest 不指定这些规则。 */
|
|
335
|
+
const STANDARD_RULES = Object.freeze([
|
|
336
|
+
rule({
|
|
337
|
+
id: "runtime-render",
|
|
338
|
+
source: "sdk",
|
|
339
|
+
codes: ["RENDER_FAILED", "UPDATE_FAILED"],
|
|
340
|
+
area: "render",
|
|
341
|
+
disposition: "repair",
|
|
342
|
+
nextAction: {
|
|
343
|
+
id: "edit-project",
|
|
344
|
+
params: { evidence: "diagnostics" }
|
|
345
|
+
},
|
|
346
|
+
verification: {
|
|
347
|
+
target: "next-built-generation",
|
|
348
|
+
milestone: "scenario-passed"
|
|
349
|
+
},
|
|
350
|
+
guidance: "读取当前请求的源码诊断,修复处理器后构建并刷新预览,再重跑原失败场景;ready 不代表恢复。"
|
|
351
|
+
}),
|
|
352
|
+
rule({
|
|
353
|
+
id: "bundle-load",
|
|
354
|
+
source: "sdk",
|
|
355
|
+
codes: ["BUNDLE_LOAD_FAILED", "DIGEST_MISMATCH"],
|
|
356
|
+
area: "bundle",
|
|
357
|
+
guidance: "检查入口资源、响应类型、实际摘要、模块依赖及 CSP 证据,再选择修复;不能从超时猜测根因。"
|
|
358
|
+
}),
|
|
359
|
+
rule({
|
|
360
|
+
id: "runtime-lease",
|
|
361
|
+
source: "sdk",
|
|
362
|
+
codes: ["RUNTIME_CONFIG_EXPIRED", "FILE_REFERENCE_INVALID"],
|
|
363
|
+
area: "lease",
|
|
364
|
+
guidance: "核对当前 scope、配置和引用;通过已授权的 acquire/续期取得新凭据,不重用一次性票据。"
|
|
365
|
+
}),
|
|
366
|
+
rule({
|
|
367
|
+
id: "runtime-authorization",
|
|
368
|
+
source: "sdk",
|
|
369
|
+
codes: ["WIDGET_VERSION_REVOKED", "FILE_PERMISSION_DENIED"],
|
|
370
|
+
area: "capability",
|
|
371
|
+
disposition: "external-action",
|
|
372
|
+
nextAction: {
|
|
373
|
+
id: "request-external-action",
|
|
374
|
+
params: { reason: "authorization" }
|
|
375
|
+
},
|
|
376
|
+
guidance: "保留现场并请求目标授权恢复;不要重试被撤销资源或绕过权限。继续不受影响的工作。"
|
|
377
|
+
}),
|
|
378
|
+
rule({
|
|
379
|
+
id: "runtime-profile",
|
|
380
|
+
source: "sdk",
|
|
381
|
+
codes: ["HOST_API_UNSUPPORTED"],
|
|
382
|
+
area: "configuration",
|
|
383
|
+
guidance: "核对实际 Host 兼容声明与工具链;按声明选择迁移或宿主升级,不修改版本字段伪装支持。"
|
|
384
|
+
}),
|
|
385
|
+
rule({
|
|
386
|
+
id: "runtime-handshake",
|
|
387
|
+
source: "sdk",
|
|
388
|
+
codes: ["HANDSHAKE_TIMEOUT"],
|
|
389
|
+
area: "handshake",
|
|
390
|
+
guidance: "先确认资源加载,再检查 profile、frame 来源与连接阶段;补充证据后再建立新 attempt。"
|
|
391
|
+
}),
|
|
392
|
+
rule({
|
|
393
|
+
id: "runtime-protocol",
|
|
394
|
+
source: "sdk",
|
|
395
|
+
codes: [
|
|
396
|
+
"MESSAGE_INVALID",
|
|
397
|
+
"CHANNEL_MISMATCH",
|
|
398
|
+
"MESSAGE_TOO_LARGE",
|
|
399
|
+
"MESSAGE_RATE_LIMITED",
|
|
400
|
+
"TOO_MANY_PENDING_REQUESTS"
|
|
401
|
+
],
|
|
402
|
+
area: "runtime",
|
|
403
|
+
guidance: "检查协议、消息大小、频率及 pending 诊断;保留既有保护,修复生产方后再连接,不能提高预算掩盖错误。"
|
|
404
|
+
}),
|
|
405
|
+
rule({
|
|
406
|
+
id: "runtime-capability",
|
|
407
|
+
source: "sdk",
|
|
408
|
+
codes: [
|
|
409
|
+
"CAPABILITY_UNDECLARED",
|
|
410
|
+
"CAPABILITY_DENIED",
|
|
411
|
+
"CAPABILITY_UNSUPPORTED",
|
|
412
|
+
"CAPABILITY_TIMEOUT",
|
|
413
|
+
"RESOURCE_LIMIT"
|
|
414
|
+
],
|
|
415
|
+
area: "capability",
|
|
416
|
+
guidance: "区分未声明、未授权、未接线、预算与超时;检查操作是否可能已执行,再选择声明修复、可用替代或授权流程。"
|
|
417
|
+
}),
|
|
418
|
+
rule({
|
|
419
|
+
id: "runtime-lifetime",
|
|
420
|
+
source: "sdk",
|
|
421
|
+
codes: ["WIDGET_CRASHED", "INSTANCE_DISPOSED"],
|
|
422
|
+
area: "runtime",
|
|
423
|
+
guidance: "查询当前挂载尝试和末次诊断;区分正常释放与崩溃,修复后创建新 attempt,不复活旧实例。"
|
|
424
|
+
}),
|
|
425
|
+
rule({
|
|
426
|
+
id: "capability-authorization",
|
|
427
|
+
source: "host",
|
|
428
|
+
codes: [
|
|
429
|
+
"permission-denied",
|
|
430
|
+
"network-consent-denied",
|
|
431
|
+
"network-credential-unavailable"
|
|
432
|
+
],
|
|
433
|
+
area: "capability",
|
|
434
|
+
disposition: "external-action",
|
|
435
|
+
nextAction: {
|
|
436
|
+
id: "request-external-action",
|
|
437
|
+
params: { reason: "authorization" }
|
|
438
|
+
},
|
|
439
|
+
guidance: "按具体 operation 核对授权或凭据可用性;使用既有授权入口,不从聊天索取凭据或绕过拒绝。"
|
|
440
|
+
}),
|
|
441
|
+
rule({
|
|
442
|
+
id: "capability-policy",
|
|
443
|
+
source: "host",
|
|
444
|
+
codes: [
|
|
445
|
+
"unsupported",
|
|
446
|
+
"network-policy-denied",
|
|
447
|
+
"network-redirect-denied",
|
|
448
|
+
"network-scope-invalid",
|
|
449
|
+
"network-dns-denied"
|
|
450
|
+
],
|
|
451
|
+
area: "capability",
|
|
452
|
+
guidance: "核对宿主接线、当前作用域和网络策略;选择允许的操作或替代路径,不反复原样调用。"
|
|
453
|
+
}),
|
|
454
|
+
rule({
|
|
455
|
+
id: "capability-budget",
|
|
456
|
+
source: "host",
|
|
457
|
+
codes: [
|
|
458
|
+
"resource-limit",
|
|
459
|
+
"network-request-too-large",
|
|
460
|
+
"network-response-too-large"
|
|
461
|
+
],
|
|
462
|
+
area: "capability",
|
|
463
|
+
guidance: "读取已知预算维度,缩小请求或分块;未知维度继续排查,不销毁健康 Bridge 或自动提高额度。"
|
|
464
|
+
}),
|
|
465
|
+
rule({
|
|
466
|
+
id: "capability-rate",
|
|
467
|
+
source: "host",
|
|
468
|
+
codes: ["network-rate-limited"],
|
|
469
|
+
area: "capability",
|
|
470
|
+
disposition: "retry",
|
|
471
|
+
nextAction: {
|
|
472
|
+
id: "wait",
|
|
473
|
+
params: { milestone: "budget-reset" }
|
|
474
|
+
},
|
|
475
|
+
guidance: "仅在确认原操作未执行且允许重试时,按宿主预算等待;预算未知时先 inspect,不能忙轮询。"
|
|
476
|
+
}),
|
|
477
|
+
rule({
|
|
478
|
+
id: "capability-reference",
|
|
479
|
+
source: "host",
|
|
480
|
+
codes: ["invalid-reference"],
|
|
481
|
+
area: "lease",
|
|
482
|
+
guidance: "重新校验当前作用域与文件引用,通过已有授权入口取得有效引用。"
|
|
483
|
+
}),
|
|
484
|
+
rule({
|
|
485
|
+
id: "capability-conflict",
|
|
486
|
+
source: "host",
|
|
487
|
+
codes: [
|
|
488
|
+
"revision-conflict",
|
|
489
|
+
"mutation-conflict",
|
|
490
|
+
"write-outcome-unknown"
|
|
491
|
+
],
|
|
492
|
+
area: "operation-outcome",
|
|
493
|
+
verification: {
|
|
494
|
+
target: "original-operation",
|
|
495
|
+
milestone: "operation-confirmed"
|
|
496
|
+
},
|
|
497
|
+
guidance: "按原 revision 和 mutation 身份核对资源及操作结果,再决定是否提交新修改;不自动重放写入。"
|
|
498
|
+
}),
|
|
499
|
+
rule({
|
|
500
|
+
id: "capability-transport",
|
|
501
|
+
source: "host",
|
|
502
|
+
codes: [
|
|
503
|
+
"timeout",
|
|
504
|
+
"internal-error",
|
|
505
|
+
"network-transport-unavailable",
|
|
506
|
+
"network-error"
|
|
507
|
+
],
|
|
508
|
+
area: "operation-outcome",
|
|
509
|
+
guidance: "保留 transport/HTTP/格式分类,先确认原操作是否执行;无响应不等于未产生副作用。"
|
|
510
|
+
}),
|
|
511
|
+
rule({
|
|
512
|
+
id: "toolchain-build",
|
|
513
|
+
source: "toolchain",
|
|
514
|
+
codes: [
|
|
515
|
+
"WIDGET_CLI_BUILD_FAILED",
|
|
516
|
+
"WIDGET_CLI_BUILD_UNRESOLVED_IMPORT",
|
|
517
|
+
"WIDGET_DEV_BUILD_FAILED"
|
|
518
|
+
],
|
|
519
|
+
area: "toolchain",
|
|
520
|
+
disposition: "repair",
|
|
521
|
+
nextAction: {
|
|
522
|
+
id: "edit-project",
|
|
523
|
+
params: { evidence: "diagnostics" }
|
|
524
|
+
},
|
|
525
|
+
verification: {
|
|
526
|
+
target: "next-built-generation",
|
|
527
|
+
milestone: "scenario-passed"
|
|
528
|
+
},
|
|
529
|
+
guidance: "读取编译器与相对源码诊断,修复后用原执行工具构建,核对回执与新产物,再刷新并复验。"
|
|
530
|
+
}),
|
|
531
|
+
rule({
|
|
532
|
+
id: "toolchain-validation",
|
|
533
|
+
source: "toolchain",
|
|
534
|
+
codes: [
|
|
535
|
+
"WIDGET_CLI_MANIFEST_INVALID",
|
|
536
|
+
"WIDGET_CLI_VALIDATION_FAILED",
|
|
537
|
+
"WIDGET_CLI_PACK_VALIDATION_FAILED",
|
|
538
|
+
"WIDGET_DEV_PROJECT_INVALID"
|
|
539
|
+
],
|
|
540
|
+
area: "configuration",
|
|
541
|
+
disposition: "repair",
|
|
542
|
+
nextAction: {
|
|
543
|
+
id: "edit-project",
|
|
544
|
+
params: { evidence: "diagnostics" }
|
|
545
|
+
},
|
|
546
|
+
verification: {
|
|
547
|
+
target: "next-built-generation",
|
|
548
|
+
milestone: "scenario-passed"
|
|
549
|
+
},
|
|
550
|
+
guidance: "依据字段与预期值修复工程清单、入口或样例,再检查并构建;不要打包不完整产物。"
|
|
551
|
+
}),
|
|
552
|
+
rule({
|
|
553
|
+
id: "toolchain-profile",
|
|
554
|
+
source: "toolchain",
|
|
555
|
+
codes: [
|
|
556
|
+
"WIDGET_CLI_PROJECT_TOOLCHAIN_REQUIRED",
|
|
557
|
+
"WIDGET_CLI_PROJECT_PROFILE_MISMATCH",
|
|
558
|
+
"WIDGET_CLI_PROJECT_SDK_MISMATCH",
|
|
559
|
+
"WIDGET_CLI_BUILD_RECEIPT_MISMATCH",
|
|
560
|
+
"WIDGET_CLI_HOST_PROFILE_UNSUPPORTED",
|
|
561
|
+
"WIDGET_CLI_HOST_COMPAT_INVALID",
|
|
562
|
+
"WIDGET_CLI_NO_WIDGET_PROJECT"
|
|
563
|
+
],
|
|
564
|
+
area: "toolchain",
|
|
565
|
+
guidance: "运行 doctor/integration 并核对当前工程与目标宿主;显式采用或迁移工具链,再构建,不伪造 receipt。"
|
|
566
|
+
}),
|
|
567
|
+
rule({
|
|
568
|
+
id: "development-host",
|
|
569
|
+
source: "toolchain",
|
|
570
|
+
codes: [
|
|
571
|
+
"WIDGET_DEV_FAILED",
|
|
572
|
+
"WIDGET_DEV_UNAUTHORIZED",
|
|
573
|
+
"WIDGET_DEV_CLAIM_REJECTED",
|
|
574
|
+
"WIDGET_DEV_PROFILE_NOT_FOUND"
|
|
575
|
+
],
|
|
576
|
+
area: "host-bridge",
|
|
577
|
+
guidance: "读取失败阶段、端点状态和具体响应;区分未监听、403、超时与不兼容,再检查目标宿主。"
|
|
578
|
+
})
|
|
579
|
+
]);
|
|
580
|
+
const UNKNOWN_RULE = rule({
|
|
581
|
+
id: "unknown",
|
|
582
|
+
source: "host",
|
|
583
|
+
codes: [],
|
|
584
|
+
area: "runtime",
|
|
585
|
+
guidance: "查询当前状态、实际产物和最后失败阶段,补充证据后选择恢复路径;不要猜测命令或反复执行。"
|
|
586
|
+
});
|
|
587
|
+
const OUTCOME_RULE = rule({
|
|
588
|
+
id: "operation-outcome",
|
|
589
|
+
source: "host",
|
|
590
|
+
codes: [],
|
|
591
|
+
area: "operation-outcome",
|
|
592
|
+
verification: {
|
|
593
|
+
target: "original-operation",
|
|
594
|
+
milestone: "operation-confirmed"
|
|
595
|
+
},
|
|
596
|
+
guidance: "原操作可能已执行或部分完成。先按原操作身份核对资源,再决定后续动作,不自动重放。"
|
|
597
|
+
});
|
|
598
|
+
const REPEATED_RULE = rule({
|
|
599
|
+
id: "repeated-without-progress",
|
|
600
|
+
source: "host",
|
|
601
|
+
codes: [],
|
|
602
|
+
area: "runtime",
|
|
603
|
+
guidance: "相同故障没有新证据或产物,先补充诊断或改变排查策略,不重复同一编辑、构建或重试。"
|
|
604
|
+
});
|
|
605
|
+
/** 包含 unknown 与操作核对规则,Agent 可按 plan.ruleId 定位每个实际计划。 */
|
|
606
|
+
const WIDGET_RECOVERY_RULES = Object.freeze([
|
|
607
|
+
...STANDARD_RULES,
|
|
608
|
+
UNKNOWN_RULE,
|
|
609
|
+
OUTCOME_RULE,
|
|
610
|
+
REPEATED_RULE
|
|
611
|
+
]);
|
|
612
|
+
/** 根据稳定码选择通用规则;未知码明确走排查,不匹配自由文本。 */
|
|
613
|
+
function findWidgetRecoveryRule(diagnostic) {
|
|
614
|
+
return WIDGET_RECOVERY_RULES.find((value) => value.sources.includes(diagnostic.source) && value.codes.includes(diagnostic.code)) ?? UNKNOWN_RULE;
|
|
615
|
+
}
|
|
616
|
+
/** 纯规则选择,不运行工具;宿主仍须校验实际能力、权限、scope 与恢复预算。 */
|
|
617
|
+
function createWidgetRecoveryPlan(diagnostic, context = {}) {
|
|
618
|
+
let selected = findWidgetRecoveryRule(diagnostic);
|
|
619
|
+
if (context.executionState === "unknown" || context.executionState === "partial" || context.mayHaveExecuted === true && context.executionState !== "finished") selected = OUTCOME_RULE;
|
|
620
|
+
else if (context.progress?.repeated && !context.progress.hasNewEvidence) selected = REPEATED_RULE;
|
|
621
|
+
else if (selected.disposition === "retry" && (diagnostic.retryable !== true || context.executionState !== "not_started" || context.mayHaveExecuted !== false)) selected = OUTCOME_RULE;
|
|
622
|
+
if (selected.disposition === "repair" && !diagnostic.diagnostics?.length) return {
|
|
623
|
+
schemaVersion: 1,
|
|
624
|
+
ruleId: selected.id,
|
|
625
|
+
ruleVersion: selected.version,
|
|
626
|
+
...context.progress ? { progress: { ...context.progress } } : {},
|
|
627
|
+
disposition: "inspect",
|
|
628
|
+
nextAction: {
|
|
629
|
+
id: "inspect",
|
|
630
|
+
params: { area: diagnostic.source === "toolchain" ? "toolchain" : "render" }
|
|
631
|
+
},
|
|
632
|
+
followUpActions: [],
|
|
633
|
+
verification: {
|
|
634
|
+
target: "current-attempt",
|
|
635
|
+
milestone: "diagnostics-updated"
|
|
636
|
+
},
|
|
637
|
+
guidance: "缺少可定位的诊断,先查询编译或源码证据,再修复;不能仅凭错误码猜测补丁。"
|
|
638
|
+
};
|
|
639
|
+
return {
|
|
640
|
+
schemaVersion: 1,
|
|
641
|
+
ruleId: selected.id,
|
|
642
|
+
ruleVersion: selected.version,
|
|
643
|
+
disposition: selected.disposition,
|
|
644
|
+
...context.progress ? { progress: { ...context.progress } } : {},
|
|
645
|
+
nextAction: structuredClone(selected.nextAction),
|
|
646
|
+
followUpActions: structuredClone(selected.followUpActions),
|
|
647
|
+
verification: { ...selected.verification },
|
|
648
|
+
guidance: selected.guidance
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
/** GENERATED FILE. Do not edit directly. */
|
|
168
652
|
const widgetRuntimeContractsSchema = {
|
|
169
653
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
170
654
|
"$id": "widget-runtime-contracts.schema.json",
|
|
@@ -218,7 +702,15 @@ const widgetRuntimeContractsSchema = {
|
|
|
218
702
|
"hostUserProfileReadOutput": { "$ref": "#/$defs/HostUserProfileReadOutput" },
|
|
219
703
|
"hostUserEmailReadInput": { "$ref": "#/$defs/HostUserEmailReadInput" },
|
|
220
704
|
"hostUserEmailReadOutput": { "$ref": "#/$defs/HostUserEmailReadOutput" },
|
|
221
|
-
"hostUserServiceRequest": { "$ref": "#/$defs/HostUserServiceRequest" }
|
|
705
|
+
"hostUserServiceRequest": { "$ref": "#/$defs/HostUserServiceRequest" },
|
|
706
|
+
"widgetDevelopmentDiagnostic": { "$ref": "#/$defs/WidgetDevelopmentDiagnostic" },
|
|
707
|
+
"widgetRecoveryContext": { "$ref": "#/$defs/WidgetRecoveryContext" },
|
|
708
|
+
"widgetRecoveryPlan": { "$ref": "#/$defs/WidgetRecoveryPlan" },
|
|
709
|
+
"widgetRecoveryRule": { "$ref": "#/$defs/WidgetRecoveryRule" },
|
|
710
|
+
"widgetDevelopmentOffer": { "$ref": "#/$defs/WidgetDevelopmentOffer" },
|
|
711
|
+
"widgetDevelopmentConnect": { "$ref": "#/$defs/WidgetDevelopmentConnect" },
|
|
712
|
+
"widgetRenderResult": { "$ref": "#/$defs/WidgetRenderResult" },
|
|
713
|
+
"widgetDevelopmentMessage": { "$ref": "#/$defs/WidgetDevelopmentMessage" }
|
|
222
714
|
},
|
|
223
715
|
"$defs": {
|
|
224
716
|
"JsonValue": {
|
|
@@ -3398,6 +3890,650 @@ const widgetRuntimeContractsSchema = {
|
|
|
3398
3890
|
"cancelled"
|
|
3399
3891
|
] }
|
|
3400
3892
|
}
|
|
3893
|
+
},
|
|
3894
|
+
"WidgetDiagnosticDetail": {
|
|
3895
|
+
"title": "WidgetDiagnosticDetail",
|
|
3896
|
+
"description": "受控字段诊断或工程相对源码位置;不携带原始对象。",
|
|
3897
|
+
"oneOf": [{
|
|
3898
|
+
"type": "object",
|
|
3899
|
+
"additionalProperties": false,
|
|
3900
|
+
"required": ["field"],
|
|
3901
|
+
"properties": {
|
|
3902
|
+
"field": {
|
|
3903
|
+
"type": "string",
|
|
3904
|
+
"minLength": 1,
|
|
3905
|
+
"maxLength": 128
|
|
3906
|
+
},
|
|
3907
|
+
"expected": {
|
|
3908
|
+
"type": "string",
|
|
3909
|
+
"maxLength": 256
|
|
3910
|
+
},
|
|
3911
|
+
"observed": {
|
|
3912
|
+
"type": "string",
|
|
3913
|
+
"maxLength": 256
|
|
3914
|
+
}
|
|
3915
|
+
}
|
|
3916
|
+
}, {
|
|
3917
|
+
"type": "object",
|
|
3918
|
+
"additionalProperties": false,
|
|
3919
|
+
"required": [
|
|
3920
|
+
"file",
|
|
3921
|
+
"line",
|
|
3922
|
+
"column"
|
|
3923
|
+
],
|
|
3924
|
+
"properties": {
|
|
3925
|
+
"file": {
|
|
3926
|
+
"type": "string",
|
|
3927
|
+
"minLength": 1,
|
|
3928
|
+
"maxLength": 256,
|
|
3929
|
+
"pattern": "^(?!/)(?!.*\\\\)(?!.*:)(?!.*(?:^|/)\\.{1,2}(?:/|$))[^\\u0000-\\u001f]+$"
|
|
3930
|
+
},
|
|
3931
|
+
"line": {
|
|
3932
|
+
"type": "integer",
|
|
3933
|
+
"minimum": 1
|
|
3934
|
+
},
|
|
3935
|
+
"column": {
|
|
3936
|
+
"type": "integer",
|
|
3937
|
+
"minimum": 1
|
|
3938
|
+
},
|
|
3939
|
+
"excerpt": {
|
|
3940
|
+
"type": "string",
|
|
3941
|
+
"minLength": 1,
|
|
3942
|
+
"maxLength": 1024
|
|
3943
|
+
}
|
|
3944
|
+
}
|
|
3945
|
+
}]
|
|
3946
|
+
},
|
|
3947
|
+
"WidgetDiagnosticIO": {
|
|
3948
|
+
"title": "WidgetDiagnosticIO",
|
|
3949
|
+
"description": "保留 transport、HTTP 与非法响应事实;不包含 URL 或原始响应。",
|
|
3950
|
+
"oneOf": [{
|
|
3951
|
+
"type": "object",
|
|
3952
|
+
"additionalProperties": false,
|
|
3953
|
+
"required": ["kind"],
|
|
3954
|
+
"properties": {
|
|
3955
|
+
"kind": { "enum": ["transport", "invalid-response"] },
|
|
3956
|
+
"sourceCode": {
|
|
3957
|
+
"type": "string",
|
|
3958
|
+
"minLength": 1,
|
|
3959
|
+
"maxLength": 96,
|
|
3960
|
+
"pattern": "^[A-Za-z][A-Za-z0-9_.-]*$"
|
|
3961
|
+
}
|
|
3962
|
+
}
|
|
3963
|
+
}, {
|
|
3964
|
+
"type": "object",
|
|
3965
|
+
"additionalProperties": false,
|
|
3966
|
+
"required": ["kind", "status"],
|
|
3967
|
+
"properties": {
|
|
3968
|
+
"kind": { "enum": ["http"] },
|
|
3969
|
+
"status": {
|
|
3970
|
+
"type": "integer",
|
|
3971
|
+
"minimum": 100,
|
|
3972
|
+
"maximum": 599,
|
|
3973
|
+
"not": {
|
|
3974
|
+
"minimum": 200,
|
|
3975
|
+
"maximum": 299
|
|
3976
|
+
}
|
|
3977
|
+
},
|
|
3978
|
+
"sourceCode": {
|
|
3979
|
+
"type": "string",
|
|
3980
|
+
"minLength": 1,
|
|
3981
|
+
"maxLength": 96,
|
|
3982
|
+
"pattern": "^[A-Za-z][A-Za-z0-9_.-]*$"
|
|
3983
|
+
}
|
|
3984
|
+
}
|
|
3985
|
+
}]
|
|
3986
|
+
},
|
|
3987
|
+
"WidgetDevelopmentDiagnostic": {
|
|
3988
|
+
"title": "WidgetDevelopmentDiagnostic",
|
|
3989
|
+
"description": "可信出口的标准诊断;恢复指令和 scope 由宿主另行生成。",
|
|
3990
|
+
"type": "object",
|
|
3991
|
+
"additionalProperties": false,
|
|
3992
|
+
"required": [
|
|
3993
|
+
"schemaVersion",
|
|
3994
|
+
"source",
|
|
3995
|
+
"code",
|
|
3996
|
+
"phase",
|
|
3997
|
+
"operation",
|
|
3998
|
+
"severity",
|
|
3999
|
+
"message"
|
|
4000
|
+
],
|
|
4001
|
+
"properties": {
|
|
4002
|
+
"schemaVersion": { "const": 1 },
|
|
4003
|
+
"source": { "enum": [
|
|
4004
|
+
"sdk",
|
|
4005
|
+
"host",
|
|
4006
|
+
"toolchain"
|
|
4007
|
+
] },
|
|
4008
|
+
"code": {
|
|
4009
|
+
"type": "string",
|
|
4010
|
+
"minLength": 1,
|
|
4011
|
+
"maxLength": 96,
|
|
4012
|
+
"pattern": "^[A-Za-z][A-Za-z0-9_.-]*$"
|
|
4013
|
+
},
|
|
4014
|
+
"sourceCode": {
|
|
4015
|
+
"type": "string",
|
|
4016
|
+
"minLength": 1,
|
|
4017
|
+
"maxLength": 96,
|
|
4018
|
+
"pattern": "^[A-Za-z][A-Za-z0-9_.-]*$"
|
|
4019
|
+
},
|
|
4020
|
+
"phase": { "enum": [
|
|
4021
|
+
"discovery",
|
|
4022
|
+
"build",
|
|
4023
|
+
"config",
|
|
4024
|
+
"load",
|
|
4025
|
+
"handshake",
|
|
4026
|
+
"render",
|
|
4027
|
+
"update",
|
|
4028
|
+
"capability",
|
|
4029
|
+
"dispose"
|
|
4030
|
+
] },
|
|
4031
|
+
"sourcePhase": {
|
|
4032
|
+
"type": "string",
|
|
4033
|
+
"minLength": 1,
|
|
4034
|
+
"maxLength": 96,
|
|
4035
|
+
"pattern": "^[A-Za-z][A-Za-z0-9_.-]*$"
|
|
4036
|
+
},
|
|
4037
|
+
"operation": {
|
|
4038
|
+
"type": "string",
|
|
4039
|
+
"minLength": 1,
|
|
4040
|
+
"maxLength": 96,
|
|
4041
|
+
"pattern": "^[A-Za-z][A-Za-z0-9_.-]*$"
|
|
4042
|
+
},
|
|
4043
|
+
"severity": { "enum": [
|
|
4044
|
+
"warning",
|
|
4045
|
+
"request-error",
|
|
4046
|
+
"instance-failure"
|
|
4047
|
+
] },
|
|
4048
|
+
"message": {
|
|
4049
|
+
"type": "string",
|
|
4050
|
+
"minLength": 1,
|
|
4051
|
+
"maxLength": 1024
|
|
4052
|
+
},
|
|
4053
|
+
"retryable": { "type": "boolean" },
|
|
4054
|
+
"correlationId": { "$ref": "#/$defs/WidgetError/properties/correlationId" },
|
|
4055
|
+
"diagnostics": {
|
|
4056
|
+
"type": "array",
|
|
4057
|
+
"maxItems": 8,
|
|
4058
|
+
"items": { "$ref": "#/$defs/WidgetDiagnosticDetail" }
|
|
4059
|
+
},
|
|
4060
|
+
"io": { "$ref": "#/$defs/WidgetDiagnosticIO" }
|
|
4061
|
+
}
|
|
4062
|
+
},
|
|
4063
|
+
"WidgetRecoveryAction": {
|
|
4064
|
+
"title": "WidgetRecoveryAction",
|
|
4065
|
+
"description": "恢复动作的语义及类型化参数;可信宿主绑定已有工具,不包含任意命令。",
|
|
4066
|
+
"oneOf": [
|
|
4067
|
+
{
|
|
4068
|
+
"type": "object",
|
|
4069
|
+
"additionalProperties": false,
|
|
4070
|
+
"required": ["id", "params"],
|
|
4071
|
+
"properties": {
|
|
4072
|
+
"id": { "const": "inspect" },
|
|
4073
|
+
"params": {
|
|
4074
|
+
"type": "object",
|
|
4075
|
+
"additionalProperties": false,
|
|
4076
|
+
"required": ["area"],
|
|
4077
|
+
"properties": { "area": { "enum": [
|
|
4078
|
+
"toolchain",
|
|
4079
|
+
"host-bridge",
|
|
4080
|
+
"configuration",
|
|
4081
|
+
"bundle",
|
|
4082
|
+
"handshake",
|
|
4083
|
+
"render",
|
|
4084
|
+
"capability",
|
|
4085
|
+
"lease",
|
|
4086
|
+
"operation-outcome",
|
|
4087
|
+
"runtime"
|
|
4088
|
+
] } }
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
},
|
|
4092
|
+
{
|
|
4093
|
+
"type": "object",
|
|
4094
|
+
"additionalProperties": false,
|
|
4095
|
+
"required": ["id", "params"],
|
|
4096
|
+
"properties": {
|
|
4097
|
+
"id": { "const": "wait" },
|
|
4098
|
+
"params": {
|
|
4099
|
+
"type": "object",
|
|
4100
|
+
"additionalProperties": false,
|
|
4101
|
+
"required": ["milestone"],
|
|
4102
|
+
"properties": {
|
|
4103
|
+
"milestone": { "enum": ["budget-reset", "connection-restored"] },
|
|
4104
|
+
"retryAfterMs": {
|
|
4105
|
+
"type": "integer",
|
|
4106
|
+
"minimum": 1
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
}
|
|
4110
|
+
}
|
|
4111
|
+
},
|
|
4112
|
+
{
|
|
4113
|
+
"type": "object",
|
|
4114
|
+
"additionalProperties": false,
|
|
4115
|
+
"required": ["id", "params"],
|
|
4116
|
+
"properties": {
|
|
4117
|
+
"id": { "const": "edit-project" },
|
|
4118
|
+
"params": {
|
|
4119
|
+
"type": "object",
|
|
4120
|
+
"additionalProperties": false,
|
|
4121
|
+
"required": ["evidence"],
|
|
4122
|
+
"properties": { "evidence": { "const": "diagnostics" } }
|
|
4123
|
+
}
|
|
4124
|
+
}
|
|
4125
|
+
},
|
|
4126
|
+
{
|
|
4127
|
+
"type": "object",
|
|
4128
|
+
"additionalProperties": false,
|
|
4129
|
+
"required": ["id", "params"],
|
|
4130
|
+
"properties": {
|
|
4131
|
+
"id": { "const": "build-project" },
|
|
4132
|
+
"params": {
|
|
4133
|
+
"type": "object",
|
|
4134
|
+
"additionalProperties": false,
|
|
4135
|
+
"required": ["target"],
|
|
4136
|
+
"properties": { "target": { "const": "current-project" } }
|
|
4137
|
+
}
|
|
4138
|
+
}
|
|
4139
|
+
},
|
|
4140
|
+
{
|
|
4141
|
+
"type": "object",
|
|
4142
|
+
"additionalProperties": false,
|
|
4143
|
+
"required": ["id", "params"],
|
|
4144
|
+
"properties": {
|
|
4145
|
+
"id": { "const": "refresh-preview" },
|
|
4146
|
+
"params": {
|
|
4147
|
+
"type": "object",
|
|
4148
|
+
"additionalProperties": false,
|
|
4149
|
+
"required": ["target"],
|
|
4150
|
+
"properties": { "target": { "const": "current-project" } }
|
|
4151
|
+
}
|
|
4152
|
+
}
|
|
4153
|
+
},
|
|
4154
|
+
{
|
|
4155
|
+
"type": "object",
|
|
4156
|
+
"additionalProperties": false,
|
|
4157
|
+
"required": ["id", "params"],
|
|
4158
|
+
"properties": {
|
|
4159
|
+
"id": { "const": "verify-scenario" },
|
|
4160
|
+
"params": {
|
|
4161
|
+
"type": "object",
|
|
4162
|
+
"additionalProperties": false,
|
|
4163
|
+
"required": ["target"],
|
|
4164
|
+
"properties": {
|
|
4165
|
+
"target": { "enum": ["current-attempt", "next-built-generation"] },
|
|
4166
|
+
"scenarioId": {
|
|
4167
|
+
"type": "string",
|
|
4168
|
+
"minLength": 1,
|
|
4169
|
+
"maxLength": 96,
|
|
4170
|
+
"pattern": "^[A-Za-z][A-Za-z0-9_.-]*$"
|
|
4171
|
+
}
|
|
4172
|
+
}
|
|
4173
|
+
}
|
|
4174
|
+
}
|
|
4175
|
+
},
|
|
4176
|
+
{
|
|
4177
|
+
"type": "object",
|
|
4178
|
+
"additionalProperties": false,
|
|
4179
|
+
"required": ["id", "params"],
|
|
4180
|
+
"properties": {
|
|
4181
|
+
"id": { "const": "request-external-action" },
|
|
4182
|
+
"params": {
|
|
4183
|
+
"type": "object",
|
|
4184
|
+
"additionalProperties": false,
|
|
4185
|
+
"required": ["reason"],
|
|
4186
|
+
"properties": { "reason": { "enum": [
|
|
4187
|
+
"authorization",
|
|
4188
|
+
"host-support",
|
|
4189
|
+
"host-start",
|
|
4190
|
+
"credentials"
|
|
4191
|
+
] } }
|
|
4192
|
+
}
|
|
4193
|
+
}
|
|
4194
|
+
},
|
|
4195
|
+
{
|
|
4196
|
+
"type": "object",
|
|
4197
|
+
"additionalProperties": false,
|
|
4198
|
+
"required": ["id", "params"],
|
|
4199
|
+
"properties": {
|
|
4200
|
+
"id": { "const": "stop-preview" },
|
|
4201
|
+
"params": {
|
|
4202
|
+
"type": "object",
|
|
4203
|
+
"additionalProperties": false,
|
|
4204
|
+
"required": ["target"],
|
|
4205
|
+
"properties": { "target": { "const": "current-preview" } }
|
|
4206
|
+
}
|
|
4207
|
+
}
|
|
4208
|
+
}
|
|
4209
|
+
]
|
|
4210
|
+
},
|
|
4211
|
+
"WidgetRecoveryVerification": {
|
|
4212
|
+
"title": "WidgetRecoveryVerification",
|
|
4213
|
+
"description": "恢复复验目标;下一成功构建须在取得回执后绑定实际产物。",
|
|
4214
|
+
"type": "object",
|
|
4215
|
+
"additionalProperties": false,
|
|
4216
|
+
"required": ["target", "milestone"],
|
|
4217
|
+
"properties": {
|
|
4218
|
+
"target": { "enum": [
|
|
4219
|
+
"current-attempt",
|
|
4220
|
+
"next-built-generation",
|
|
4221
|
+
"original-operation"
|
|
4222
|
+
] },
|
|
4223
|
+
"milestone": { "enum": [
|
|
4224
|
+
"diagnostics-updated",
|
|
4225
|
+
"render-handled",
|
|
4226
|
+
"scenario-passed",
|
|
4227
|
+
"operation-confirmed"
|
|
4228
|
+
] },
|
|
4229
|
+
"scenarioId": {
|
|
4230
|
+
"type": "string",
|
|
4231
|
+
"minLength": 1,
|
|
4232
|
+
"maxLength": 96,
|
|
4233
|
+
"pattern": "^[A-Za-z][A-Za-z0-9_.-]*$"
|
|
4234
|
+
}
|
|
4235
|
+
}
|
|
4236
|
+
},
|
|
4237
|
+
"WidgetRecoveryPlan": {
|
|
4238
|
+
"title": "WidgetRecoveryPlan",
|
|
4239
|
+
"description": "可信宿主选择的恢复计划;不能由 Guest 的诊断 payload 指定。",
|
|
4240
|
+
"type": "object",
|
|
4241
|
+
"additionalProperties": false,
|
|
4242
|
+
"required": [
|
|
4243
|
+
"schemaVersion",
|
|
4244
|
+
"ruleId",
|
|
4245
|
+
"ruleVersion",
|
|
4246
|
+
"disposition",
|
|
4247
|
+
"nextAction",
|
|
4248
|
+
"verification",
|
|
4249
|
+
"guidance",
|
|
4250
|
+
"followUpActions"
|
|
4251
|
+
],
|
|
4252
|
+
"properties": {
|
|
4253
|
+
"progress": { "$ref": "#/$defs/WidgetRecoveryProgress" },
|
|
4254
|
+
"schemaVersion": { "const": 1 },
|
|
4255
|
+
"ruleId": {
|
|
4256
|
+
"type": "string",
|
|
4257
|
+
"minLength": 1,
|
|
4258
|
+
"maxLength": 96,
|
|
4259
|
+
"pattern": "^[A-Za-z][A-Za-z0-9_.-]*$"
|
|
4260
|
+
},
|
|
4261
|
+
"ruleVersion": {
|
|
4262
|
+
"type": "integer",
|
|
4263
|
+
"minimum": 1
|
|
4264
|
+
},
|
|
4265
|
+
"disposition": { "enum": [
|
|
4266
|
+
"retry",
|
|
4267
|
+
"repair",
|
|
4268
|
+
"inspect",
|
|
4269
|
+
"external-action",
|
|
4270
|
+
"stop"
|
|
4271
|
+
] },
|
|
4272
|
+
"nextAction": { "$ref": "#/$defs/WidgetRecoveryAction" },
|
|
4273
|
+
"verification": { "$ref": "#/$defs/WidgetRecoveryVerification" },
|
|
4274
|
+
"guidance": {
|
|
4275
|
+
"type": "string",
|
|
4276
|
+
"minLength": 1,
|
|
4277
|
+
"maxLength": 4096
|
|
4278
|
+
},
|
|
4279
|
+
"followUpActions": {
|
|
4280
|
+
"description": "首项动作完成后的有限恢复步骤;宿主逐步验证前置条件,不原样盲目重放。",
|
|
4281
|
+
"type": "array",
|
|
4282
|
+
"maxItems": 8,
|
|
4283
|
+
"items": { "$ref": "#/$defs/WidgetRecoveryAction" }
|
|
4284
|
+
}
|
|
4285
|
+
}
|
|
4286
|
+
},
|
|
4287
|
+
"WidgetRecoveryRule": {
|
|
4288
|
+
"title": "WidgetRecoveryRule",
|
|
4289
|
+
"description": "公共恢复规则目录条目;空 codes 仅用于显式 unknown 回退。",
|
|
4290
|
+
"type": "object",
|
|
4291
|
+
"additionalProperties": false,
|
|
4292
|
+
"required": [
|
|
4293
|
+
"id",
|
|
4294
|
+
"version",
|
|
4295
|
+
"sources",
|
|
4296
|
+
"codes",
|
|
4297
|
+
"disposition",
|
|
4298
|
+
"nextAction",
|
|
4299
|
+
"verification",
|
|
4300
|
+
"guidance",
|
|
4301
|
+
"followUpActions"
|
|
4302
|
+
],
|
|
4303
|
+
"properties": {
|
|
4304
|
+
"id": {
|
|
4305
|
+
"type": "string",
|
|
4306
|
+
"minLength": 1,
|
|
4307
|
+
"maxLength": 96,
|
|
4308
|
+
"pattern": "^[A-Za-z][A-Za-z0-9_.-]*$"
|
|
4309
|
+
},
|
|
4310
|
+
"version": {
|
|
4311
|
+
"type": "integer",
|
|
4312
|
+
"minimum": 1
|
|
4313
|
+
},
|
|
4314
|
+
"sources": {
|
|
4315
|
+
"type": "array",
|
|
4316
|
+
"minItems": 1,
|
|
4317
|
+
"maxItems": 3,
|
|
4318
|
+
"uniqueItems": true,
|
|
4319
|
+
"items": { "enum": [
|
|
4320
|
+
"sdk",
|
|
4321
|
+
"host",
|
|
4322
|
+
"toolchain"
|
|
4323
|
+
] }
|
|
4324
|
+
},
|
|
4325
|
+
"codes": {
|
|
4326
|
+
"type": "array",
|
|
4327
|
+
"maxItems": 64,
|
|
4328
|
+
"uniqueItems": true,
|
|
4329
|
+
"items": {
|
|
4330
|
+
"type": "string",
|
|
4331
|
+
"minLength": 1,
|
|
4332
|
+
"maxLength": 96,
|
|
4333
|
+
"pattern": "^[A-Za-z][A-Za-z0-9_.-]*$"
|
|
4334
|
+
}
|
|
4335
|
+
},
|
|
4336
|
+
"disposition": { "enum": [
|
|
4337
|
+
"retry",
|
|
4338
|
+
"repair",
|
|
4339
|
+
"inspect",
|
|
4340
|
+
"external-action",
|
|
4341
|
+
"stop"
|
|
4342
|
+
] },
|
|
4343
|
+
"nextAction": { "$ref": "#/$defs/WidgetRecoveryAction" },
|
|
4344
|
+
"verification": { "$ref": "#/$defs/WidgetRecoveryVerification" },
|
|
4345
|
+
"guidance": {
|
|
4346
|
+
"type": "string",
|
|
4347
|
+
"minLength": 1,
|
|
4348
|
+
"maxLength": 4096
|
|
4349
|
+
},
|
|
4350
|
+
"followUpActions": {
|
|
4351
|
+
"description": "首项动作完成后的有限恢复步骤;宿主逐步验证前置条件,不原样盲目重放。",
|
|
4352
|
+
"type": "array",
|
|
4353
|
+
"maxItems": 8,
|
|
4354
|
+
"items": { "$ref": "#/$defs/WidgetRecoveryAction" }
|
|
4355
|
+
}
|
|
4356
|
+
}
|
|
4357
|
+
},
|
|
4358
|
+
"WidgetDevelopmentExtension": {
|
|
4359
|
+
"title": "WidgetDevelopmentExtension",
|
|
4360
|
+
"description": "经 offer/connect 显式选择的开发扩展;不授予 capability。",
|
|
4361
|
+
"const": "development-diagnostics-v1"
|
|
4362
|
+
},
|
|
4363
|
+
"WidgetDevelopmentOffer": {
|
|
4364
|
+
"title": "WidgetDevelopmentOffer",
|
|
4365
|
+
"description": "独立于旧 bootstrap-ready 的支持声明,接收方仍须校验 frame 来源和挂载尝试。",
|
|
4366
|
+
"type": "object",
|
|
4367
|
+
"additionalProperties": false,
|
|
4368
|
+
"required": [
|
|
4369
|
+
"type",
|
|
4370
|
+
"protocolVersion",
|
|
4371
|
+
"extensions"
|
|
4372
|
+
],
|
|
4373
|
+
"properties": {
|
|
4374
|
+
"type": { "const": "widget-bootstrap-offer" },
|
|
4375
|
+
"protocolVersion": { "const": 1 },
|
|
4376
|
+
"extensions": {
|
|
4377
|
+
"type": "array",
|
|
4378
|
+
"minItems": 1,
|
|
4379
|
+
"maxItems": 1,
|
|
4380
|
+
"uniqueItems": true,
|
|
4381
|
+
"items": { "$ref": "#/$defs/WidgetDevelopmentExtension" }
|
|
4382
|
+
}
|
|
4383
|
+
}
|
|
4384
|
+
},
|
|
4385
|
+
"WidgetDevelopmentConnect": {
|
|
4386
|
+
"title": "WidgetDevelopmentConnect",
|
|
4387
|
+
"description": "仅在收到当前 iframe 合法 offer 后使用的扩展 connect;旧形状保持不变。",
|
|
4388
|
+
"type": "object",
|
|
4389
|
+
"additionalProperties": false,
|
|
4390
|
+
"required": [
|
|
4391
|
+
"type",
|
|
4392
|
+
"protocolVersion",
|
|
4393
|
+
"channelId",
|
|
4394
|
+
"initPayload",
|
|
4395
|
+
"extensions"
|
|
4396
|
+
],
|
|
4397
|
+
"properties": {
|
|
4398
|
+
"type": { "const": "widget-host-connect" },
|
|
4399
|
+
"protocolVersion": { "const": 1 },
|
|
4400
|
+
"channelId": {
|
|
4401
|
+
"type": "string",
|
|
4402
|
+
"minLength": 16
|
|
4403
|
+
},
|
|
4404
|
+
"initPayload": { "$ref": "#/$defs/InitPayload" },
|
|
4405
|
+
"extensions": {
|
|
4406
|
+
"type": "array",
|
|
4407
|
+
"minItems": 1,
|
|
4408
|
+
"maxItems": 1,
|
|
4409
|
+
"uniqueItems": true,
|
|
4410
|
+
"items": { "$ref": "#/$defs/WidgetDevelopmentExtension" }
|
|
4411
|
+
}
|
|
4412
|
+
}
|
|
4413
|
+
},
|
|
4414
|
+
"WidgetRenderResult": {
|
|
4415
|
+
"title": "WidgetRenderResult",
|
|
4416
|
+
"description": "仅表示受管渲染处理器的处理结果,不代表视觉或业务验收。",
|
|
4417
|
+
"oneOf": [{
|
|
4418
|
+
"type": "object",
|
|
4419
|
+
"additionalProperties": false,
|
|
4420
|
+
"required": [
|
|
4421
|
+
"requestId",
|
|
4422
|
+
"revision",
|
|
4423
|
+
"outcome"
|
|
4424
|
+
],
|
|
4425
|
+
"properties": {
|
|
4426
|
+
"requestId": { "$ref": "#/$defs/RenderRequestBase/properties/requestId" },
|
|
4427
|
+
"revision": {
|
|
4428
|
+
"type": "integer",
|
|
4429
|
+
"minimum": 1
|
|
4430
|
+
},
|
|
4431
|
+
"outcome": { "enum": ["handled", "superseded"] }
|
|
4432
|
+
}
|
|
4433
|
+
}, {
|
|
4434
|
+
"type": "object",
|
|
4435
|
+
"additionalProperties": false,
|
|
4436
|
+
"required": [
|
|
4437
|
+
"requestId",
|
|
4438
|
+
"revision",
|
|
4439
|
+
"outcome",
|
|
4440
|
+
"diagnostic"
|
|
4441
|
+
],
|
|
4442
|
+
"properties": {
|
|
4443
|
+
"requestId": { "$ref": "#/$defs/RenderRequestBase/properties/requestId" },
|
|
4444
|
+
"revision": {
|
|
4445
|
+
"type": "integer",
|
|
4446
|
+
"minimum": 1
|
|
4447
|
+
},
|
|
4448
|
+
"outcome": { "const": "failed" },
|
|
4449
|
+
"diagnostic": { "$ref": "#/$defs/WidgetRenderFailureDiagnostic" }
|
|
4450
|
+
}
|
|
4451
|
+
}]
|
|
4452
|
+
},
|
|
4453
|
+
"WidgetDiagnosticMessage": {
|
|
4454
|
+
"title": "WidgetDiagnosticMessage",
|
|
4455
|
+
"description": "经协商的开发扩展 Bridge 消息;仍受现有通道与消息预算约束。",
|
|
4456
|
+
"type": "object",
|
|
4457
|
+
"allOf": [{ "$ref": "#/$defs/BridgeEnvelopeBase" }, {
|
|
4458
|
+
"type": "object",
|
|
4459
|
+
"required": ["type", "payload"],
|
|
4460
|
+
"properties": {
|
|
4461
|
+
"type": { "const": "diagnostic" },
|
|
4462
|
+
"payload": { "$ref": "#/$defs/WidgetGuestDiagnostic" }
|
|
4463
|
+
}
|
|
4464
|
+
}],
|
|
4465
|
+
"unevaluatedProperties": false
|
|
4466
|
+
},
|
|
4467
|
+
"WidgetRenderResultMessage": {
|
|
4468
|
+
"title": "WidgetRenderResultMessage",
|
|
4469
|
+
"description": "经协商的开发扩展 Bridge 消息;仍受现有通道与消息预算约束。",
|
|
4470
|
+
"type": "object",
|
|
4471
|
+
"allOf": [{ "$ref": "#/$defs/BridgeEnvelopeBase" }, {
|
|
4472
|
+
"type": "object",
|
|
4473
|
+
"required": ["type", "payload"],
|
|
4474
|
+
"properties": {
|
|
4475
|
+
"type": { "const": "render-result" },
|
|
4476
|
+
"payload": { "$ref": "#/$defs/WidgetRenderResult" }
|
|
4477
|
+
}
|
|
4478
|
+
}],
|
|
4479
|
+
"unevaluatedProperties": false
|
|
4480
|
+
},
|
|
4481
|
+
"WidgetDevelopmentMessage": {
|
|
4482
|
+
"title": "WidgetDevelopmentMessage",
|
|
4483
|
+
"description": "扩展 profile 下的 Widget → Host 消息;原 WidgetToHostMessage 不扩展。",
|
|
4484
|
+
"oneOf": [
|
|
4485
|
+
{ "$ref": "#/$defs/WidgetToHostMessage" },
|
|
4486
|
+
{ "$ref": "#/$defs/WidgetDiagnosticMessage" },
|
|
4487
|
+
{ "$ref": "#/$defs/WidgetRenderResultMessage" }
|
|
4488
|
+
]
|
|
4489
|
+
},
|
|
4490
|
+
"WidgetRecoveryContext": {
|
|
4491
|
+
"title": "WidgetRecoveryContext",
|
|
4492
|
+
"description": "复用工具执行结果语义的可信恢复上下文;缺失字段表示未知,不能授权重放。",
|
|
4493
|
+
"type": "object",
|
|
4494
|
+
"additionalProperties": false,
|
|
4495
|
+
"properties": {
|
|
4496
|
+
"progress": { "$ref": "#/$defs/WidgetRecoveryProgress" },
|
|
4497
|
+
"executionState": { "enum": [
|
|
4498
|
+
"not_started",
|
|
4499
|
+
"finished",
|
|
4500
|
+
"partial",
|
|
4501
|
+
"unknown"
|
|
4502
|
+
] },
|
|
4503
|
+
"mayHaveExecuted": { "type": "boolean" }
|
|
4504
|
+
}
|
|
4505
|
+
},
|
|
4506
|
+
"WidgetGuestDiagnostic": {
|
|
4507
|
+
"title": "WidgetGuestDiagnostic",
|
|
4508
|
+
"description": "Guest 仅声明 SDK 诊断事实,不得冒充 Host 或工具链。",
|
|
4509
|
+
"allOf": [{ "$ref": "#/$defs/WidgetDevelopmentDiagnostic" }, {
|
|
4510
|
+
"type": "object",
|
|
4511
|
+
"required": ["source"],
|
|
4512
|
+
"properties": { "source": { "const": "sdk" } }
|
|
4513
|
+
}]
|
|
4514
|
+
},
|
|
4515
|
+
"WidgetRenderFailureDiagnostic": {
|
|
4516
|
+
"title": "WidgetRenderFailureDiagnostic",
|
|
4517
|
+
"description": "失败处理回执的 SDK 请求诊断;接收方还须匹配当前 requestId。",
|
|
4518
|
+
"allOf": [{ "$ref": "#/$defs/WidgetGuestDiagnostic" }, {
|
|
4519
|
+
"type": "object",
|
|
4520
|
+
"required": ["correlationId"],
|
|
4521
|
+
"properties": {
|
|
4522
|
+
"correlationId": { "$ref": "#/$defs/WidgetDevelopmentDiagnostic/properties/correlationId" },
|
|
4523
|
+
"phase": { "enum": ["render", "update"] }
|
|
4524
|
+
}
|
|
4525
|
+
}]
|
|
4526
|
+
},
|
|
4527
|
+
"WidgetRecoveryProgress": {
|
|
4528
|
+
"title": "WidgetRecoveryProgress",
|
|
4529
|
+
"description": "可信宿主观察到的恢复进展;重复故障无新证据时不能重复同一修复。",
|
|
4530
|
+
"type": "object",
|
|
4531
|
+
"additionalProperties": false,
|
|
4532
|
+
"required": ["repeated", "hasNewEvidence"],
|
|
4533
|
+
"properties": {
|
|
4534
|
+
"repeated": { "type": "boolean" },
|
|
4535
|
+
"hasNewEvidence": { "type": "boolean" }
|
|
4536
|
+
}
|
|
3401
4537
|
}
|
|
3402
4538
|
}
|
|
3403
4539
|
};
|
|
@@ -10800,6 +11936,11 @@ compileDefinition("WidgetToHostMessage");
|
|
|
10800
11936
|
compileDefinition("CapabilityRequest");
|
|
10801
11937
|
const capabilityResultValidator = compileDefinition("CapabilityResult");
|
|
10802
11938
|
compileDefinition("WidgetError");
|
|
11939
|
+
const developmentDiagnosticValidator = compileDefinition("WidgetDevelopmentDiagnostic");
|
|
11940
|
+
compileDefinition("WidgetDevelopmentOffer");
|
|
11941
|
+
compileDefinition("WidgetDevelopmentConnect");
|
|
11942
|
+
compileDefinition("WidgetDevelopmentMessage");
|
|
11943
|
+
compileDefinition("WidgetRecoveryPlan");
|
|
10803
11944
|
compileDefinition("ResourceBudget");
|
|
10804
11945
|
compileDefinition("GrantedCapability");
|
|
10805
11946
|
compileDefinition("PublicWidgetEvent");
|
|
@@ -10827,10 +11968,17 @@ function validateRenderRequest(value) {
|
|
|
10827
11968
|
function validateCapabilityResult(value) {
|
|
10828
11969
|
return validateContract(capabilityResultValidator, value);
|
|
10829
11970
|
}
|
|
11971
|
+
/** 内部/Host 工具按源头 Schema 校验开发合同,不增加浏览器校验器入口。 */
|
|
11972
|
+
function validateWidgetDevelopmentDiagnostic(value) {
|
|
11973
|
+
return validateContract(developmentDiagnosticValidator, value);
|
|
11974
|
+
}
|
|
10830
11975
|
//#endregion
|
|
10831
11976
|
//#region src/project/validate.mjs
|
|
10832
11977
|
function loadContractValidators() {
|
|
10833
11978
|
return Promise.resolve({
|
|
11979
|
+
validateWidgetDevelopmentDiagnostic,
|
|
11980
|
+
createWidgetRecoveryPlan,
|
|
11981
|
+
isWidgetRenderResult,
|
|
10834
11982
|
validateWidgetManifest(value) {
|
|
10835
11983
|
return validateWidgetManifest(value);
|
|
10836
11984
|
},
|
|
@@ -11690,4 +12838,4 @@ async function scaffoldDshWidget(input, output, options) {
|
|
|
11690
12838
|
};
|
|
11691
12839
|
}
|
|
11692
12840
|
//#endregion
|
|
11693
|
-
export { normalizeArchivePath as a,
|
|
12841
|
+
export { normalizeArchivePath as a, loadContractValidators as c, prepareWidgetPackage as i, compileAuthorManifest as l, scaffoldDshWidget as n, checkWidgetProject as o, buildWidgetPackage as r, resolveWidgetProjects as s, auditDshPlugin as t };
|