openyida 2026.11.2 → 2026.11.3

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 (94) hide show
  1. package/README.md +11 -9
  2. package/bin/yida.js +2 -1
  3. package/lib/app/application-entry-urls.js +35 -1
  4. package/lib/app/check-prd-completeness.js +27 -6
  5. package/lib/app/create-app.js +17 -9
  6. package/lib/app/fast-build.js +151 -0
  7. package/lib/app/fast-theme.js +83 -0
  8. package/lib/app/form-data-contract.js +162 -0
  9. package/lib/app/services/canvas-page-schema-builder.js +10 -0
  10. package/lib/asset/ai-image.js +8 -5
  11. package/lib/asset/asset-cmd.js +24 -4
  12. package/lib/asset/asset-execution.js +25 -4
  13. package/lib/asset/asset-plan.js +4 -2
  14. package/lib/asset/asset-resolve.js +21 -7
  15. package/lib/auth/oauth-loopback.js +1 -1
  16. package/lib/auth/org.js +2 -0
  17. package/lib/auth/token-auth.js +1 -0
  18. package/lib/core/agent-capabilities.js +30 -9
  19. package/lib/core/batch.js +71 -122
  20. package/lib/core/command-manifest.js +71 -38
  21. package/lib/core/locales/en.js +20 -4
  22. package/lib/core/locales/zh.js +19 -3
  23. package/lib/core/permission-guidance.js +10 -10
  24. package/lib/core/query-data.js +67 -10
  25. package/lib/core/sample.js +73 -0
  26. package/lib/core/task-concurrency.js +96 -0
  27. package/lib/corp-efficiency/corp-efficiency.js +15 -8
  28. package/lib/design/fast-document.js +118 -0
  29. package/lib/design-plan/design-plan.js +3 -3
  30. package/lib/design-plan/init.js +90 -5
  31. package/lib/design-plan/materialize.js +2 -2
  32. package/lib/design-plan/validate.js +64 -9
  33. package/lib/flash-note/build-flash-note-prompt.js +1 -1
  34. package/lib/samples/openyida-scaffold/canvas-data-source.jsx +135 -0
  35. package/lib/samples/openyida-scaffold/canvas-file-upload.jsx +106 -0
  36. package/lib/samples/openyida-scaffold/file-upload-client.jsx +160 -0
  37. package/lib/samples/yida-app/fast-app.json +64 -0
  38. package/lib/samples/yida-design/fast-design.json +38 -0
  39. package/package.json +3 -3
  40. package/scripts/postinstall.js +6 -6
  41. package/yida-skills/SKILL.md +10 -9
  42. package/yida-skills/references/official-example-schema-patterns.md +3 -3
  43. package/yida-skills/references/qwenwork-link-presentation.md +11 -16
  44. package/yida-skills/references/user-facing-summary.md +1 -1
  45. package/yida-skills/skills/yida-app/SKILL.md +23 -12
  46. package/yida-skills/skills/yida-app/references/fast-context.md +7 -0
  47. package/yida-skills/skills/yida-app/workflow/fast-build.md +65 -0
  48. package/yida-skills/skills/yida-app/workflow/parallel-work.md +15 -5
  49. package/yida-skills/skills/yida-app/workflow/plan/workflow.md +5 -1
  50. package/yida-skills/skills/yida-app/workflow/step-2-design.md +13 -6
  51. package/yida-skills/skills/yida-app/workflow/step-3-create-or-reuse-app.md +7 -2
  52. package/yida-skills/skills/yida-app/workflow/step-4-forms-processes.md +4 -1
  53. package/yida-skills/skills/yida-app/workflow/step-5-seed-records.md +4 -1
  54. package/yida-skills/skills/yida-app/workflow/step-6-main-page.md +3 -0
  55. package/yida-skills/skills/yida-app/workflow/step-7-page-code.md +5 -2
  56. package/yida-skills/skills/yida-app/workflow/step-8-publish-navigation.md +3 -0
  57. package/yida-skills/skills/yida-app/workflow/step-9-output-finish.md +7 -2
  58. package/yida-skills/skills/yida-canvas-custom-page/SKILL.md +14 -4
  59. package/yida-skills/skills/yida-canvas-custom-page/references/data-bridge-guide.md +2 -0
  60. package/yida-skills/skills/yida-canvas-custom-page/references/file-upload.md +75 -0
  61. package/yida-skills/skills/yida-canvas-custom-page/references/native-components-bridge.md +4 -3
  62. package/yida-skills/skills/yida-canvas-custom-page/references/page-generation-guide.md +1 -1
  63. package/yida-skills/skills/yida-canvas-data-binding/SKILL.md +23 -82
  64. package/yida-skills/skills/yida-corp-efficiency/SKILL.md +3 -3
  65. package/yida-skills/skills/yida-create-app/SKILL.md +9 -5
  66. package/yida-skills/skills/yida-create-form-page/SKILL.md +1 -1
  67. package/yida-skills/skills/yida-create-form-page/references/field-definition-guide.md +1 -1
  68. package/yida-skills/skills/yida-create-form-page/references/form-field-properties.md +13 -17
  69. package/yida-skills/skills/yida-custom-page/SKILL.md +2 -0
  70. package/yida-skills/skills/yida-custom-page/references/attachment-upload-guide.md +4 -0
  71. package/yida-skills/skills/yida-data-management/SKILL.md +2 -0
  72. package/yida-skills/skills/yida-data-management/references/data-format-guide.md +9 -0
  73. package/yida-skills/skills/yida-design/SKILL.md +7 -2
  74. package/yida-skills/skills/yida-design/references/application-theme-consistency.md +4 -4
  75. package/yida-skills/skills/yida-design/references/ask-human-interaction-contract.md +2 -2
  76. package/yida-skills/skills/yida-design/references/design-mode.md +4 -2
  77. package/yida-skills/skills/yida-design/references/fast-design-spec.md +32 -0
  78. package/yida-skills/skills/yida-design/references/native-form-styles.md +2 -2
  79. package/yida-skills/skills/yida-design/templates/design-themes/app-teal/design.md +4 -4
  80. package/yida-skills/skills/yida-design/templates/design-themes/app-terminal/design.md +4 -4
  81. package/yida-skills/skills/yida-design/workflow/output-design.md +1 -1
  82. package/yida-skills/skills/yida-design/workflow/step-4-wireframe-interaction.md +1 -1
  83. package/yida-skills/skills/yida-design/workflow/step-6-handoff.md +1 -1
  84. package/yida-skills/skills/yida-dingtalk-openapi/references/api-contract.md +1 -1
  85. package/yida-skills/skills/yida-flash-note-to-prd/references/flash-note-prompt.md +1 -1
  86. package/yida-skills/skills/yida-image-assets/SKILL.md +11 -5
  87. package/yida-skills/skills/yida-login/SKILL.md +6 -0
  88. package/yida-skills/skills/yida-ppt-slider/references/examples.md +3 -3
  89. package/yida-skills/skills/yida-prd/SKILL.md +5 -1
  90. package/yida-skills/skills/yida-publish-page/SKILL.md +3 -0
  91. package/yida-skills/skills/yida-requirement-analysis/SKILL.md +4 -1
  92. package/yida-skills/skills/yida-requirement-analysis/references/handoff.md +4 -1
  93. package/yida-skills/skills/yida-requirement-analysis/workflow/prepare-brief.md +3 -0
  94. package/yida-skills/skills-index.json +2 -2
@@ -0,0 +1,162 @@
1
+ 'use strict';
2
+
3
+ const { normalizeSchemaFields, createSchemaHash } = require('./schema-field-resolution');
4
+ const { CliError } = require('../core/cli-error');
5
+ const { t } = require('../core/i18n');
6
+
7
+ const own = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
8
+ const object = value => value !== null && typeof value === 'object' && !Array.isArray(value);
9
+ const strings = new Set(['TextField', 'TextareaField', 'RadioField', 'SelectField']);
10
+ const numbers = new Set(['NumberField', 'RateField', 'DateField']);
11
+ const sets = new Set(['CheckboxField', 'MultiSelectField', 'EmployeeField', 'DepartmentSelectField']);
12
+ const files = new Set(['ImageField', 'AttachmentField']);
13
+ const numericText = value => typeof value === 'string' && /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(value.trim());
14
+
15
+ function buildWriteContract(schema) {
16
+ const fields = normalizeSchemaFields(schema);
17
+ const props = Object.create(null);
18
+ const visit = node => {
19
+ if (!object(node)) {return;}
20
+ if (node.props?.fieldId) {props[node.props.fieldId] = node.props;}
21
+ if (Array.isArray(node.children)) {node.children.forEach(visit);}
22
+ };
23
+ for (const page of Array.isArray(schema?.content?.pages) ? schema.content.pages : []) {
24
+ if (Array.isArray(page.componentsTree)) {page.componentsTree.forEach(visit);}
25
+ }
26
+ return { fields, props, schemaHash: createSchemaHash(schema) };
27
+ }
28
+
29
+ function arrayValue(value, reading) {
30
+ if (reading) {
31
+ // Association projections can contain two JSON string envelopes.
32
+ for (let i = 0; i < 2 && typeof value === 'string'; i++) {
33
+ try {value = JSON.parse(value);} catch {return null;}
34
+ }
35
+ }
36
+ if (reading && (value === null || value === '')) {return [];}
37
+ return Array.isArray(value) ? value : null;
38
+ }
39
+
40
+ function canonical(field, value, reading = false) {
41
+ const type = field.componentType;
42
+ const supported = strings.has(type) || numbers.has(type) || sets.has(type) || files.has(type)
43
+ || ['CitySelectField', 'CascadeDateField', 'AssociationFormField'].includes(type);
44
+ if (!supported) {return { ok: false, reason: 'UNSUPPORTED_COMPONENT' };}
45
+ if (value === null || reading && value === '') {
46
+ return { ok: true, value: strings.has(type) || numbers.has(type) ? null : [] };
47
+ }
48
+ if (strings.has(type)) {
49
+ return typeof value === 'string' ? { ok: true, value: value || null } : { ok: false };
50
+ }
51
+ if (numbers.has(type)) {
52
+ const number = reading && numericText(value) ? Number(value) : value;
53
+ return typeof number === 'number' && Number.isFinite(number) ? { ok: true, value: number } : { ok: false };
54
+ }
55
+ const list = arrayValue(value, reading);
56
+ if (!list) {return { ok: false };}
57
+ if (sets.has(type) || type === 'CitySelectField') {
58
+ if (!list.every(item => typeof item === 'string' && item.length > 0
59
+ || ['DepartmentSelectField', 'CitySelectField'].includes(type) && typeof item === 'number' && Number.isFinite(item))) {
60
+ return { ok: false };
61
+ }
62
+ const ids = list.map(String);
63
+ if (sets.has(type) && new Set(ids).size !== ids.length) {return { ok: false, reason: 'DUPLICATE_SELECTION' };}
64
+ return { ok: true, value: sets.has(type) ? ids.sort() : ids };
65
+ }
66
+ if (type === 'CascadeDateField') {
67
+ const endpoints = reading ? list.map(item => item === null ? '' : numericText(item) ? Number(item) : item) : list;
68
+ return endpoints.length === 2 && endpoints.every(item => item === '' || typeof item === 'number' && Number.isFinite(item))
69
+ ? { ok: true, value: endpoints } : { ok: false };
70
+ }
71
+ if (type === 'AssociationFormField') {
72
+ const keys = reading ? ['instanceId'] : ['appType', 'formUuid', 'formType', 'instanceId', 'title'];
73
+ return list.every(item => object(item) && keys.every(key => typeof item[key] === 'string' && item[key].trim()))
74
+ ? { ok: true, value: list.map(item => item.instanceId).sort() } : { ok: false };
75
+ }
76
+ const identities = list.map(item => object(item)
77
+ ? item.fileId || item.id || item.downloadUrl || item.url : null);
78
+ return identities.every(id => typeof id === 'string' && id.length > 0)
79
+ ? { ok: true, value: identities.slice().sort() } : { ok: false };
80
+ }
81
+
82
+ function prepareWriteData(data, contract, resolveAliases = false) {
83
+ const issues = [];
84
+ if (!contract.fields.length) {issues.push({ path: '$', code: 'SCHEMA_FIELDS_UNAVAILABLE' });}
85
+ const compile = (input, parent = null, prefix = '$') => {
86
+ if (!object(input)) {issues.push({ path: prefix, code: 'EXPECTED_OBJECT' }); return {};}
87
+ const available = contract.fields.filter(field => field.parentFieldId === parent);
88
+ const output = Object.create(null);
89
+ for (const [key, value] of Object.entries(input)) {
90
+ const location = `${prefix}[${JSON.stringify(key)}]`;
91
+ const exact = available.filter(field => field.fieldId === key);
92
+ const matches = exact.length ? exact : resolveAliases ? available.filter(field => field.alias && field.alias === key) : [];
93
+ if (matches.length !== 1) {
94
+ const candidates = available.filter(field => field.label === key || field.localizedLabels.some(label => label.label === key));
95
+ issues.push({ path: location, code: matches.length > 1 ? 'AMBIGUOUS_FIELD_REFERENCE' : 'UNKNOWN_FIELD',
96
+ fieldRef: key, candidates: (matches.length ? matches : candidates).map(field => ({ fieldId: field.fieldId, label: field.label })) });
97
+ continue;
98
+ }
99
+ const field = matches[0];
100
+ if (own(output, field.fieldId)) {issues.push({ path: location, code: 'DUPLICATE_FIELD_REFERENCE', fieldId: field.fieldId }); continue;}
101
+ if (field.componentType === 'TableField') {
102
+ if (!Array.isArray(value)) {issues.push({ path: location, fieldId: field.fieldId, code: 'EXPECTED_ARRAY' }); continue;}
103
+ output[field.fieldId] = value.map((row, index) => compile(row, field.fieldId, `${location}[${index}]`));
104
+ continue;
105
+ }
106
+ const normalized = canonical(field, value);
107
+ if (!normalized.ok) {
108
+ issues.push({ path: location, fieldId: field.fieldId, componentType: field.componentType,
109
+ code: normalized.reason || 'INVALID_VALUE_TYPE' });
110
+ } else {
111
+ const options = contract.props[field.fieldId]?.dataSource;
112
+ if (['RadioField', 'SelectField', 'CheckboxField', 'MultiSelectField'].includes(field.componentType)
113
+ && Array.isArray(options) && options.length && value !== null && value !== '') {
114
+ const values = options.map(option => object(option) ? option.value : option);
115
+ if (values.every(option => typeof option === 'string')
116
+ && (Array.isArray(value) ? value : [value]).some(option => !values.includes(option))) {
117
+ issues.push({ path: location, fieldId: field.fieldId, code: 'UNKNOWN_OPTION' });
118
+ }
119
+ }
120
+ }
121
+ output[field.fieldId] = value;
122
+ }
123
+ return output;
124
+ };
125
+ const compiled = compile(data);
126
+ if (!Object.keys(compiled).length && !issues.length) {issues.push({ path: '$', code: 'EMPTY_WRITE_PAYLOAD' });}
127
+ if (issues.length) {
128
+ throw new CliError(t('data_verify.preflight_failed', String(issues.length)), {
129
+ code: 'DATA_WRITE_PREFLIGHT_FAILED', details: { issues, schemaHash: contract.schemaHash,
130
+ retryable: false, retrySafe: true, sideEffectState: 'none', nextStep: 'resolve_fields_and_repair_payload' },
131
+ });
132
+ }
133
+ return compiled;
134
+ }
135
+
136
+ function compareWriteData(expected, actual, contract) {
137
+ const issues = [];
138
+ const compare = (wanted, observed, parent = null, prefix = '$') => {
139
+ if (!object(observed)) {issues.push({ path: prefix, code: 'READBACK_DATA_UNAVAILABLE' }); return;}
140
+ for (const [id, value] of Object.entries(wanted)) {
141
+ const location = `${prefix}[${JSON.stringify(id)}]`;
142
+ const field = contract.fields.find(item => item.fieldId === id && item.parentFieldId === parent);
143
+ if (!field) {issues.push({ path: location, code: 'SCHEMA_FIELD_UNAVAILABLE' }); continue;}
144
+ const key = !own(observed, id) && field.componentType === 'AssociationFormField' ? `${id}_id` : id;
145
+ if (!own(observed, key)) {issues.push({ path: location, fieldId: id, code: 'READBACK_FIELD_MISSING' }); continue;}
146
+ if (field.componentType === 'TableField') {
147
+ const rows = arrayValue(observed[key], true);
148
+ if (!rows || rows.length !== value.length) {issues.push({ path: location, fieldId: id, code: 'READBACK_ROW_COUNT_MISMATCH' }); continue;}
149
+ value.forEach((row, index) => compare(row, rows[index], id, `${location}[${index}]`));
150
+ continue;
151
+ }
152
+ const before = canonical(field, value), after = canonical(field, observed[key], true);
153
+ if (!before.ok || !after.ok || JSON.stringify(before.value) !== JSON.stringify(after.value)) {
154
+ issues.push({ path: location, fieldId: id, code: 'READBACK_VALUE_MISMATCH' });
155
+ }
156
+ }
157
+ };
158
+ compare(expected, actual);
159
+ return issues;
160
+ }
161
+
162
+ module.exports = { buildWriteContract, prepareWriteData, compareWriteData };
@@ -1,5 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const FILE_UPLOAD_CLIENT_SOURCE = fs.readFileSync(
6
+ path.join(__dirname, '../../samples/openyida-scaffold/file-upload-client.jsx'), 'utf8'
7
+ );
8
+
3
9
  const {
4
10
  createNodeIdGenerator,
5
11
  generateSuffix,
@@ -19,6 +25,7 @@ const CANVAS_YIDA_API_BRIDGE_SOURCE = `${createPageNavigation.toString()}
19
25
  ${createTaskCenterNavigation.toString()}
20
26
  ${createTaskCenterContract.toString()}
21
27
  ${createTaskCenterLoader.toString()}
28
+ ${FILE_UPLOAD_CLIENT_SOURCE}
22
29
  var OPENYIDA_YIDA_FORM_API_METHODS = [
23
30
  'saveFormData',
24
31
  'updateFormData',
@@ -494,6 +501,7 @@ function openyidaInstallYidaApiBridge() {
494
501
  var bridge = openyidaCreateYidaApiBridge(this);
495
502
  var utilsBridge = openyidaCreateUtilsBridge(this, bridge);
496
503
  var connectorBridge = openyidaCreateConnectorApiBridge();
504
+ var fileBridge = createYidaFileClient(window);
497
505
  try {
498
506
  window.__OPENYIDA_YIDA_API__ = bridge;
499
507
  window.openyidaYidaApi = bridge;
@@ -501,6 +509,7 @@ function openyidaInstallYidaApiBridge() {
501
509
  window.openyidaUtils = utilsBridge;
502
510
  window.__OPENYIDA_CONNECTOR_API__ = connectorBridge;
503
511
  window.openyidaConnectorApi = connectorBridge;
512
+ window.__OPENYIDA_FILE_API__ = fileBridge;
504
513
  } catch (err) {}
505
514
  openyidaYidaApiBridgeTargets().forEach(function(target) {
506
515
  try {
@@ -510,6 +519,7 @@ function openyidaInstallYidaApiBridge() {
510
519
  target.openyidaUtils = utilsBridge;
511
520
  target.__OPENYIDA_CONNECTOR_API__ = connectorBridge;
512
521
  target.openyidaConnectorApi = connectorBridge;
522
+ target.__OPENYIDA_FILE_API__ = fileBridge;
513
523
  } catch (err) {}
514
524
  });
515
525
  return bridge;
@@ -79,7 +79,7 @@ function getMaterialSourcingGuidance() {
79
79
  '1. Plan 确认后、Fast 设计就绪后先核实后台 Agent/Bash 能力,按 executionContract 派发并立即继续业务;仅同步时先做已授权资源和独立页面工作,再分批素材。',
80
80
  '2. 同一页面的图片位置也并发搜索,最多同时四个;每个位置选一张来源完整的图片并查看。',
81
81
  '3. 第二轮只补第一轮失败的必需位置,换一张图片或使用设计允许的生成图。',
82
- '4. 两轮结束后,可选位置采用设计允许的无图布局,必需位置保留缺口;已就绪页面直接继续。',
82
+ '4. 页面布局与交互就绪即发布可用预览,不等图片;按设计显示缺图状态,素材到位只更新图片绑定。必需图片缺口不冒充最终验收通过。',
83
83
  '5. 每页使用 asset resolve --page-id 并发检查直链,需托管时上传,写入独立清单并交接该页。',
84
84
  ],
85
85
  schedulingPolicy: {
@@ -93,14 +93,15 @@ function getMaterialSourcingGuidance() {
93
93
  executionContract: getAssetExecutionContract(),
94
94
  afterDispatch: 'continue_resource_and_page_work',
95
95
  resumeRunning: 'attach_existing_host_task',
96
- waitPolicy: 'own_page_only_after_independent_work',
96
+ waitPolicy: 'after_first_preview_within_shared_deadline',
97
97
  unsupportedHost: 'business_first_then_bounded_asset_batches',
98
98
  searchOrder: ['required_slots', 'hero_slots', 'design_order'],
99
- waitAt: 'own_page_image_binding_and_acceptance',
99
+ waitAt: 'final_asset_acceptance_only',
100
100
  resultWriter: 'one_per_page',
101
101
  timeBudget: {
102
- owner: 'host_agent', requestTimeoutMs: 30000, pageDeadlineMs: 180000,
102
+ owner: 'host_agent', requestTimeoutMs: 15000, pageDeadlineMs: 60000, collectionDeadlineMs: 60000,
103
103
  startsAt: 'first_search_dispatch', resume: 'keep_original_deadline',
104
+ collectionStartsAt: 'first_collection_search_dispatch', resolveDeadlineOption: '--deadline-at',
104
105
  exhausted: 'finish_verified_assets_and_report_remaining_gaps',
105
106
  },
106
107
  },
@@ -121,10 +122,12 @@ function getMaterialSourcingGuidance() {
121
122
  },
122
123
  failurePolicy: {
123
124
  attemptsPerCandidate: 1,
125
+ retryDelayMs: 0,
126
+ deniedSource: 'skip_source_for_remaining_collection_without_sleep',
124
127
  sourceUnavailable: 'switch_source_for_remaining_slots',
125
128
  candidateFailed: 'replace_input',
126
129
  exhausted: 'planned_optional_layout_or_required_gap',
127
- retryCondition: 'within_two_rounds_or_explicit_request',
130
+ retryCondition: 'within_original_deadline_and_two_rounds_or_explicit_new_request',
128
131
  },
129
132
  libraries: getFreeStockLibraries(),
130
133
  rules: [
@@ -8,14 +8,15 @@ const { resolveAssets, ASSET_SOURCES } = require('./asset-resolve');
8
8
  const { detectImageGenerator, getMaterialSourcingGuidance } = require('./ai-image');
9
9
  const { throwCommandError, throwStatus, throwUsage } = require('../core/command-errors');
10
10
  const { t } = require('../core/i18n');
11
+ const { assetDeadline } = require('./asset-execution');
11
12
 
12
- const RESOLVE_USAGE = '用法: openyida asset resolve (--input <manifest-draft.json> | --slot <slotId>=<路径或URL> ...) [--manifest <asset-manifest.json>] [--design <design.md>] [--page-id <pageId>] [--source search|user|generated] [--app-type <appType>] [--upload-assets] [--offline] [--json]';
13
+ const RESOLVE_USAGE = '用法: openyida asset resolve (--input <manifest-draft.json> | --slot <slotId>=<路径或URL> ...) [--manifest <asset-manifest.json>] [--design <design.md> | --build-spec <build-context.json>] [--page-id <pageId>] [--source search|user|generated] [--app-type <appType>] [--deadline-at <ISO8601>] [--upload-assets] [--offline] [--json]';
13
14
 
14
15
  function printHelp() {
15
16
  console.log(`
16
17
  用法:
17
18
  openyida asset status [--offline] [--json]
18
- openyida asset resolve (--input <manifest-draft.json> | --slot <slotId>=<路径或URL> ...) [--manifest <asset-manifest.json>] [--design <design.md>] [--page-id <pageId>] [--source search|user|generated] [--app-type <appType>] [--upload-assets] [--offline] [--json]
19
+ ${RESOLVE_USAGE.slice(4)}
19
20
  openyida asset sources [--json]
20
21
 
21
22
  子命令:
@@ -57,6 +58,7 @@ function parseArgs(args) {
57
58
  appType: '',
58
59
  source: 'search',
59
60
  timeout: 0,
61
+ deadlineAt: '',
60
62
  json: false,
61
63
  help: args[0] === '--help' || args[0] === '-h',
62
64
  errors: [],
@@ -90,9 +92,13 @@ function parseArgs(args) {
90
92
  parsed.design = args[++i] || '';
91
93
  if (!parsed.design || parsed.design.startsWith('--')) {parsed.errors.push('ASSET_DESIGN_REQUIRED');}
92
94
  } else if (arg === '--page-id') {
93
- parsed.usedOptions.push('--page-id');
94
95
  parsed.pageId = args[++i] || '';
96
+ parsed.usedOptions.push('--page-id');
95
97
  if (!parsed.pageId.trim() || parsed.pageId.startsWith('--')) {parsed.errors.push('ASSET_PAGE_ID_REQUIRED');}
98
+ } else if (arg === '--build-spec') {
99
+ parsed.usedOptions.push('--build-spec');
100
+ parsed.buildSpec = args[++i] || '';
101
+ if (!parsed.buildSpec || parsed.buildSpec.startsWith('--')) {parsed.errors.push('ASSET_DESIGN_REQUIRED');}
96
102
  } else if (arg === '--manifest') {
97
103
  parsed.usedOptions.push('--manifest');
98
104
  parsed.manifest = args[++i] || '';
@@ -103,6 +109,10 @@ function parseArgs(args) {
103
109
  } else if (arg === '--timeout') {
104
110
  parsed.usedOptions.push('--timeout');
105
111
  parsed.timeout = parseInt(args[++i], 10) || 0;
112
+ } else if (arg === '--deadline-at') {
113
+ parsed.usedOptions.push('--deadline-at');
114
+ parsed.deadlineAt = args[++i] || '';
115
+ if (!parsed.deadlineAt || parsed.deadlineAt.startsWith('--')) {parsed.errors.push('ASSET_INPUT_INVALID');}
106
116
  } else {
107
117
  parsed.errors.push(`未知参数:${arg}`);
108
118
  }
@@ -155,8 +165,17 @@ async function runResolve(options) {
155
165
  if (!ASSET_SOURCES.includes(options.source)) {
156
166
  throwUsage('--source 仅支持 search、user 或 generated', RESOLVE_USAGE, { code: 'ASSET_INVALID_SOURCE' });
157
167
  }
168
+ // Reuse the collection's absolute deadline; an expired retry must not overwrite its manifest.
169
+ const deadline = assetDeadline(options.deadlineAt);
170
+ if (Date.now() >= deadline) {
171
+ throwStatus('素材未达到 final 状态', 2, { code: 'ASSET_MATERIAL_NOT_FINAL',
172
+ details: { reason: 'ASSET_DEADLINE_EXCEEDED', deadlineAt: options.deadlineAt,
173
+ manifestPath: options.manifest ? path.resolve(options.manifest) : '' } });
174
+ }
158
175
  const draft = options.input ? readDraft(options.input) : {};
159
- const assetStrategy = options.design ? readDesignAssetStrategy(path.resolve(options.design)) : draft.assetStrategy;
176
+ if (options.design && options.buildSpec) {throwUsage('ASSET_INPUT_INVALID', RESOLVE_USAGE, { code: 'ASSET_INPUT_INVALID' });}
177
+ const assetStrategy = options.buildSpec ? require('../app/fast-build').readFastBuild(path.resolve(options.buildSpec)).assetStrategy
178
+ : options.design ? readDesignAssetStrategy(path.resolve(options.design)) : draft.assetStrategy;
160
179
  const assets = [
161
180
  ...(draft.assets || []),
162
181
  ...options.slots.map(slot => ({ ...slot, source: options.source })),
@@ -173,6 +192,7 @@ async function runResolve(options) {
173
192
  assetSource: options.source,
174
193
  uploadAssets: options.uploadAssets,
175
194
  timeout: options.timeout || undefined,
195
+ deadlineAt: options.deadlineAt,
176
196
  });
177
197
  const manifestPath = options.manifest ? writeManifest(options.manifest, result) : '';
178
198
  if (result.materialStatus === 'draft') {
@@ -1,20 +1,41 @@
1
1
  'use strict';
2
2
 
3
+ const { CliError } = require('../core/cli-error');
4
+
5
+ function assetDeadline(value) {
6
+ if (value === undefined || value === '') { return Infinity; }
7
+ const deadline = typeof value === 'string' && /^\d{4}-\d\d-\d\dT.+(?:Z|[+-]\d\d:\d\d)$/.test(value) ? Date.parse(value) : NaN;
8
+ if (!Number.isFinite(deadline)) {
9
+ throw new CliError('ASSET_INPUT_INVALID', { code: 'ASSET_INPUT_INVALID',
10
+ details: { field: 'deadlineAt', expected: 'ISO timestamp with timezone' } });
11
+ }
12
+ return deadline;
13
+ }
14
+
15
+ function assetTimeout(deadline, timeout) {
16
+ if (!Number.isFinite(deadline)) { return timeout; }
17
+ const remaining = deadline - Date.now();
18
+ if (remaining <= 0) { throw new Error('ASSET_DEADLINE_EXCEEDED'); }
19
+ return Math.min(timeout || 15000, remaining);
20
+ }
21
+
3
22
  function getAssetExecutionContract() {
4
23
  return {
5
24
  capabilitySource: 'agent-capabilities.asset_capabilities + actual_host_tool_inventory',
6
25
  modes: ['background_agent', 'background_shell', 'synchronous'],
7
26
  selection: 'Use a verified nonblocking agent when available; otherwise a verified background shell for scriptable steps; otherwise business-first synchronous batches.',
8
27
  nonblockingProof: ['actual_tool_and_background_option', 'hostTaskId', 'dispatchReturnedAt_before_endedAt', 'result_and_exit_status_retrieval'],
28
+ pageDependencies: { implementation: [], preview: [], finalAssetAcceptance: ['required_assets'] },
29
+ preview: 'Publish the authorized usable page with designed missing-image states before waiting for assets. Bind verified images incrementally without regenerating the page; disclose required gaps until final acceptance.',
9
30
  shell: {
10
31
  qwenworkHint: 'Inspect Bash.run_in_background in the current tool schema; do not infer Agent background support from Bash support or a host name.',
11
32
  allowedWork: ['scriptable_search_with_verified_cli', 'allowed_download_or_upload', 'asset_resolve'],
12
33
  foregroundWork: ['host_only_search_or_generation', 'visual_image_review'],
13
- handoff: 'Pass task.resolve.argv with actual paths and appType when uploading; use the supported background option, save the returned job ID and log/output paths, then resume business work. Poll only at the owning page image-binding join; read exit code and manifest, and stop timed-out jobs before handing over file ownership.',
34
+ handoff: 'Pass task.resolve.argv with actual paths and appType when uploading; append the shared --deadline-at value. Save the background job ID and output paths, then resume business work. Join images after the first preview; read exit code and manifest, and stop timed-out jobs before handing over file ownership.',
14
35
  unsupported: 'A shell cannot call agent-only image tools. A command ending in & or a returned PID alone is not proof of durable background support.',
15
36
  },
16
- synchronousOrder: ['authorized_resource_creation_or_reuse', 'seed_if_in_scope', 'independent_page_layout_and_data_work', 'bounded_asset_batch', 'next_independent_work', 'own_page_image_binding'],
17
- forbid: ['blocking_whole_collection_subagent_before_business', 'immediate_wait_after_background_dispatch', 'all_page_asset_barrier', 'claim_parallel_without_overlapping_intervals'],
37
+ synchronousOrder: ['authorized_resource_creation_or_reuse', 'seed_if_in_scope', 'independent_page_layout_and_data_work', 'authorized_first_preview', 'bounded_asset_batch', 'next_independent_work', 'own_page_image_binding'],
38
+ forbid: ['blocking_whole_collection_subagent_before_business', 'immediate_wait_after_background_dispatch', 'all_page_asset_barrier', 'claim_parallel_without_overlapping_intervals', 'wait_for_assets_before_first_preview', 'sleep_before_retrying_denied_source'],
18
39
  audit: 'Copy actual taskState records and businessWork intervals into build-manifest.assetExecution for check-prd-completeness; missing evidence is not verified concurrency.',
19
40
  };
20
41
  }
@@ -76,4 +97,4 @@ function auditAssetExecution(record, expectedTasks = []) {
76
97
  return { status: record.tasks.length ? 'verified' : 'not_applicable', issues, evidence: 'recorded_intervals_only' };
77
98
  }
78
99
 
79
- module.exports = { getAssetExecutionContract, selectAssetExecutionMode, auditAssetExecution };
100
+ module.exports = { assetDeadline, assetTimeout, getAssetExecutionContract, selectAssetExecutionMode, auditAssetExecution };
@@ -176,8 +176,9 @@ function buildAssetTasks(assetStrategy, outputDir, options = {}) {
176
176
  const searches = [...slots].sort((a, b) => Number(b.required) - Number(a.required)
177
177
  || Number(b.usage === 'hero') - Number(a.usage === 'hero'));
178
178
  return {
179
- pageId: page.pageId, skillId: 'yida-image-assets', startWhen: 'plan_confirmed',
179
+ pageId: page.pageId, skillId: 'yida-image-assets', startWhen: options.buildSpec ? 'fast_context_ready' : 'plan_confirmed',
180
180
  taskKey: path.resolve(manifest), taskState: `${basename}.task.json`,
181
+ collectionKey: path.resolve(outputDir, 'asset-manifests'),
181
182
  ...guidance.schedulingPolicy,
182
183
  collectionPolicy: guidance.collectionPolicy,
183
184
  failurePolicy: guidance.failurePolicy,
@@ -188,9 +189,10 @@ function buildAssetTasks(assetStrategy, outputDir, options = {}) {
188
189
  })),
189
190
  resolve: {
190
191
  startWhen: 'page_draft_ready', appTypeRequired: Boolean(managed), uploadRequiresAppType: true,
192
+ deadlineOption: '--deadline-at', deadlineSource: 'shared_collection_deadline_at',
191
193
  uploadArgs: managed ? [] : ['--app-type', '<appType>'],
192
194
  argv: ['asset', 'resolve', '--input', draft, '--manifest', manifest,
193
- '--design', path.join(outputDir, 'design.md'), '--page-id', page.pageId,
195
+ ...(options.buildSpec ? ['--build-spec', options.buildSpec] : ['--design', path.join(outputDir, 'design.md')]), '--page-id', page.pageId,
194
196
  ...(managed ? ['--app-type', managed.appType] : []), '--json'],
195
197
  },
196
198
  };
@@ -12,6 +12,7 @@ const { MAX_IMAGE_BYTES, uploadAttachment } = require('./attachment-upload');
12
12
  const { getAssetStatus } = require('./asset-status');
13
13
  const { t } = require('../core/i18n');
14
14
  const { verifyImageUrl } = require('./url-verify');
15
+ const { assetDeadline, assetTimeout } = require('./asset-execution');
15
16
 
16
17
  const ALLOWED_STOCK_IMAGE_PROVIDERS = Object.freeze({
17
18
  unsplash: Object.freeze(['images.unsplash.com']),
@@ -70,6 +71,8 @@ function extensionFromUrl(rawUrl) {
70
71
  }
71
72
 
72
73
  async function downloadUrlToTemp(rawUrl, options = {}, depth = 0) {
74
+ options = { ...options, deadline: Number.isFinite(options.deadline) ? options.deadline : Date.now() + (options.timeout || 15000) };
75
+ const timeout = assetTimeout(options.deadline, options.timeout);
73
76
  if (depth > 4) {throw new Error('TOO_MANY_REDIRECTS');}
74
77
  if (options.stockOnly && !getCollectedImageProvider(rawUrl)) {throw new Error('STOCK_PROVIDER_REDIRECT_NOT_ALLOWED');}
75
78
  const parsed = new URL(rawUrl);
@@ -83,12 +86,12 @@ async function downloadUrlToTemp(rawUrl, options = {}, depth = 0) {
83
86
  const client = parsed.protocol === 'https:' ? https : http;
84
87
  const req = client.get(parsed, { headers: { 'User-Agent': 'OpenYidaAsset/1.0', Accept: 'image/*' } }, res => {
85
88
  if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
86
- res.resume();
89
+ res.destroy();
87
90
  try { resolve(new URL(res.headers.location, rawUrl).toString()); } catch (error) { reject(error); }
88
91
  return;
89
92
  }
90
93
  if (res.statusCode < 200 || res.statusCode >= 300) {
91
- res.resume(); reject(new Error(`HTTP_${res.statusCode}`)); return;
94
+ res.destroy(); reject(new Error(`HTTP_${res.statusCode}`)); return;
92
95
  }
93
96
  const declaredTooLarge = Number(res.headers['content-length']) > MAX_IMAGE_BYTES;
94
97
  let bytes = 0;
@@ -120,7 +123,9 @@ async function downloadUrlToTemp(rawUrl, options = {}, depth = 0) {
120
123
  out.on('finish', () => out.close(() => resolve('')));
121
124
  res.pipe(out);
122
125
  });
123
- req.setTimeout(options.timeout || 15000, () => req.destroy(new Error('TIMEOUT')));
126
+ const timer = setTimeout(() => req.destroy(new Error('TIMEOUT')), timeout);
127
+ req.on('close', () => clearTimeout(timer));
128
+ req.setTimeout(timeout, () => req.destroy(new Error('TIMEOUT')));
124
129
  req.on('error', reject);
125
130
  });
126
131
  if (redirect) {
@@ -209,7 +214,7 @@ async function resolveOne(candidate, ctx = {}) {
209
214
  }
210
215
  if (deliveryPolicy === 'original-url') {
211
216
  const verified = await (ctx.verifyFn || verifyImageUrl)(raw, {
212
- timeout: ctx.timeout, minWidth: ctx.minWidth, minHeight: ctx.minHeight,
217
+ timeout: assetTimeout(ctx.deadline, ctx.timeout), minWidth: ctx.minWidth, minHeight: ctx.minHeight,
213
218
  allowUrl: assetSource === 'search' ? url => getCollectedImageProvider(url) === inputProvider : undefined,
214
219
  });
215
220
  if (!verified.ok) {return { ...common, resolved: false, reason: verified.reason };}
@@ -218,7 +223,9 @@ async function resolveOne(candidate, ctx = {}) {
218
223
  let tempPath = '';
219
224
  let verifiedMetadata;
220
225
  try {
221
- tempPath = await (ctx.downloadFn || downloadUrlToTemp)(raw, { timeout: ctx.timeout, stockOnly: assetSource === 'search' });
226
+ tempPath = await (ctx.downloadFn || downloadUrlToTemp)(raw, {
227
+ timeout: assetTimeout(ctx.deadline, ctx.timeout), deadline: ctx.deadline, stockOnly: assetSource === 'search',
228
+ });
222
229
  if (fs.statSync(tempPath).size > MAX_IMAGE_BYTES) {return original(readImageMetadata(tempPath));}
223
230
  const downloaded = readImageMetadata(tempPath);
224
231
  const failure = sizeFailure(downloaded, ctx);
@@ -228,6 +235,7 @@ async function resolveOne(candidate, ctx = {}) {
228
235
  const reused = await reuseDelivery(raw, common, ctx);
229
236
  if (reused) {return reused;}
230
237
  if (!ctx.canUpload) {return original(verifiedMetadata, 'YIDA_ATTACHMENT_UNAVAILABLE');}
238
+ assetTimeout(ctx.deadline, ctx.timeout);
231
239
  const results = await ctx.uploadFn([tempPath]);
232
240
  const hit = (results || []).find(result => result.success && result.originalPath === tempPath)
233
241
  || (results || []).find(result => result.success);
@@ -277,6 +285,7 @@ async function resolveOne(candidate, ctx = {}) {
277
285
  return { ...metadata, resolved: false, url: raw, source: 'local', reason: 'YIDA_ATTACHMENT_UNAVAILABLE' };
278
286
  }
279
287
  try {
288
+ assetTimeout(ctx.deadline, ctx.timeout);
280
289
  const results = await ctx.uploadFn([raw]);
281
290
  const hit = (results || []).find(result => result.success && result.originalPath === raw)
282
291
  || (results || []).find(result => result.success);
@@ -317,6 +326,7 @@ function metadataGaps(asset) {
317
326
  }
318
327
 
319
328
  async function resolveAssets(assets = [], options = {}) {
329
+ const deadline = assetDeadline(options.deadlineAt);
320
330
  const plan = prepareAssetPlan(assets, options.assetStrategy, options.pageId);
321
331
  const entries = plan.entries;
322
332
  const online = options.online !== false;
@@ -341,6 +351,7 @@ async function resolveAssets(assets = [], options = {}) {
341
351
  }
342
352
  let result;
343
353
  try {
354
+ assetTimeout(deadline, options.timeout);
344
355
  result = await resolveOne(input, {
345
356
  previous: asset,
346
357
  assetSource: source,
@@ -351,13 +362,14 @@ async function resolveAssets(assets = [], options = {}) {
351
362
  online,
352
363
  canUpload,
353
364
  timeout: options.timeout,
365
+ deadline,
354
366
  downloadFn: options.downloadFn,
355
367
  verifyFn: options.verifyFn,
356
368
  uploadFn,
357
369
  ...size,
358
370
  });
359
371
  } catch (error) {
360
- result = { resolved: false, url: input, reason: error.code || 'ASSET_READ_FAILED' };
372
+ result = { resolved: false, url: input, reason: error.code || (error.message === 'ASSET_DEADLINE_EXCEEDED' ? error.message : 'ASSET_READ_FAILED') };
361
373
  }
362
374
  return { index, asset, input, source, result };
363
375
  }));
@@ -434,12 +446,14 @@ async function resolveAssets(assets = [], options = {}) {
434
446
  gaps.push({ ...gap });
435
447
  }
436
448
  const blocked = pageGaps.some(gap => !gap.slotId || pageAssets.some(asset => asset.slotId === gap.slotId && asset.required));
437
- return { ...page, materialStatus: blocked ? 'draft' : pageAssets.length ? 'final' : 'none', gaps: pageGaps };
449
+ return { ...page, materialStatus: blocked ? 'draft' : pageAssets.length ? 'final' : 'none', gaps: pageGaps,
450
+ assetGate: { implementation: 'unblocked', preview: 'unblocked', finalAssetAcceptance: blocked ? 'blocked' : 'unblocked' } };
438
451
  });
439
452
  const materialStatus = gaps.length ? 'draft' : entries.length ? 'final' : 'none';
440
453
  return {
441
454
  schemaVersion: 2,
442
455
  materialStatus,
456
+ ...(Number.isFinite(deadline) ? { executionBudget: { deadlineAt: new Date(deadline).toISOString(), exhausted: Date.now() >= deadline } } : {}),
443
457
  ...(plan.assetStrategy !== undefined ? { assetStrategy: plan.assetStrategy } : {}),
444
458
  pages,
445
459
  capabilityEvidence: {
@@ -698,7 +698,7 @@ function runDingtalkLoopback(options = {}) {
698
698
  prompt: options.prompt,
699
699
  });
700
700
  const callerOwnsBrowser = callerOwnsLoginBrowser(options);
701
- if (!options.quiet || callerOwnsBrowser) {
701
+ if (!options.quiet || callerOwnsBrowser || options.showAuthUrl) {
702
702
  process.stderr.write(`Open this URL to login:\n${authUrl}\n`);
703
703
  }
704
704
  if (!options.quiet) {
package/lib/auth/org.js CHANGED
@@ -235,6 +235,7 @@ async function switchOrganization(targetCorpId, options = {}) {
235
235
  endpoint: options.endpoint || (currentSession && currentSession.base_url),
236
236
  clientId: options.clientId || (currentSession && currentSession.client_id),
237
237
  corpId: targetCorpId,
238
+ showAuthUrl: true,
238
239
  };
239
240
 
240
241
  const cloud = isQwenWorkWebRuntime(options.runtime || detectRuntimeCapabilities({ env: options.env || process.env }));
@@ -322,6 +323,7 @@ async function run(args = []) {
322
323
  const json = hasFlag(args, '--json');
323
324
  const options = {
324
325
  quiet: hasFlag(args, '--quiet') || json,
326
+ noBrowser: hasFlag(args, '--no-browser'),
325
327
  clientId: getArgValue(args, '--client-id'),
326
328
  authProfile: getArgValue(args, '--profile'),
327
329
  userId: getArgValue(args, '--user-id'),
@@ -336,6 +336,7 @@ async function tokenLogin(options = {}) {
336
336
  port: options.port,
337
337
  quiet: options.quiet,
338
338
  noBrowser: options.noBrowser,
339
+ showAuthUrl: options.showAuthUrl,
339
340
  timeoutMs: options.timeoutMs,
340
341
  });
341
342