openyida 2026.10.30 → 2026.11.1

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 (51) hide show
  1. package/lib/agent/frozen-bundle.js +21 -6
  2. package/lib/app/app-theme-state.js +80 -0
  3. package/lib/app/canvas-compile.js +11 -11
  4. package/lib/app/canvas-icon-guard.js +1 -1
  5. package/lib/app/canvas-navigation-guard.js +1 -1
  6. package/lib/app/canvas-path-guard.js +1 -1
  7. package/lib/app/canvas-theme-guard.js +1 -1
  8. package/lib/app/create-app.js +31 -0
  9. package/lib/app/fix-theme.js +1 -1
  10. package/lib/app/form-data-response-guard.js +1 -1
  11. package/lib/app/form-detail-link-guard.js +1 -1
  12. package/lib/app/form-open-guard.js +1 -1
  13. package/lib/app/inline-css-guard.js +1 -1
  14. package/lib/app/jsx-text-guard.js +1 -1
  15. package/lib/app/page-compat.js +1 -1
  16. package/lib/app/page-linter.js +1 -1
  17. package/lib/app/update-app.js +51 -47
  18. package/lib/app/upgrade-app-theme.js +1 -1
  19. package/lib/auth/qwenwork-desktop.js +2 -1
  20. package/lib/auth/qwenwork-login.js +40 -5
  21. package/lib/core/agent-capabilities.js +48 -10
  22. package/lib/core/babel-transform/index.js +3 -4
  23. package/lib/core/babel.js +24 -0
  24. package/lib/core/command-manifest.js +7 -3
  25. package/lib/core/form-edit-permissions.js +210 -0
  26. package/lib/core/locales/en.js +9 -1
  27. package/lib/core/locales/zh.js +9 -1
  28. package/lib/core/query-data.js +12 -1
  29. package/lib/core/qwenwork-login-guidance.js +4 -1
  30. package/lib/core/utils.js +15 -10
  31. package/lib/permission/permission-scope.js +27 -8
  32. package/lib/permission/save-permission.js +6 -4
  33. package/package.json +10 -2
  34. package/yida-skills/SKILL.md +6 -0
  35. package/yida-skills/references/execution-rules.md +11 -0
  36. package/yida-skills/references/qwenwork-cloud-login.md +2 -0
  37. package/yida-skills/references/qwenwork-desktop-login.md +2 -0
  38. package/yida-skills/references/setup-and-env.md +22 -6
  39. package/yida-skills/references/user-facing-summary.md +23 -3
  40. package/yida-skills/skills/yida-app/SKILL.md +6 -0
  41. package/yida-skills/skills/yida-app/workflow/step-3-create-or-reuse-app.md +3 -3
  42. package/yida-skills/skills/yida-app/workflow/step-9-output-finish.md +1 -1
  43. package/yida-skills/skills/yida-create-app/SKILL.md +7 -1
  44. package/yida-skills/skills/yida-data-management/SKILL.md +4 -1
  45. package/yida-skills/skills/yida-data-management/references/api-matrix.md +4 -0
  46. package/yida-skills/skills/yida-design/references/application-style-library.md +4 -2
  47. package/yida-skills/skills/yida-design/workflow/output-design.md +1 -1
  48. package/yida-skills/skills/yida-design/workflow/step-2-theme-system.md +1 -1
  49. package/yida-skills/skills/yida-form-permission/SKILL.md +3 -22
  50. package/yida-skills/skills/yida-login/SKILL.md +11 -4
  51. package/yida-skills/skills/yida-requirement-analysis/workflow/prepare-brief.md +2 -0
@@ -137,6 +137,7 @@ function materializeBundle(runtime, config, options = {}) {
137
137
  const sources = [];
138
138
  const sourceTrees = [];
139
139
  const destinations = new Set();
140
+ const dependencySources = new Map();
140
141
  let totalBytes = 0;
141
142
  let published = false;
142
143
  let runtimePackage;
@@ -175,12 +176,20 @@ function materializeBundle(runtime, config, options = {}) {
175
176
  copy();
176
177
  sourceTrees.push({ source, skip, files: treeFiles.sort() });
177
178
  }
178
- function copyDependencies(source, target, ancestors = []) {
179
- if (ancestors.length > 50) {throw bundleError();}
179
+ function copiedDependency(target, name) {
180
+ for (let current = target; ; current = path.posix.dirname(current)) {
181
+ const candidate = `${current}/node_modules/${name}`;
182
+ if (dependencySources.has(candidate)) {return dependencySources.get(candidate);}
183
+ if (current === path.posix.dirname(current)) {return null;}
184
+ }
185
+ }
186
+ function copyDependencies(source, target, depth = 0) {
187
+ if (depth > 50) {throw bundleError();}
180
188
  const metadata = packageMetadata(source);
181
189
  const optional = metadata.optionalDependencies || {};
182
190
  const peers = metadata.peerDependencies || {};
183
191
  const dependencies = { ...peers, ...metadata.dependencies, ...optional };
192
+ const pendingDependencies = [];
184
193
  for (const name of Object.keys(dependencies).sort()) {
185
194
  // Runtime is copied from the verified bytes, never from optional node_modules.
186
195
  if (source === sourceRoot && name === runtimePackage) {continue;}
@@ -190,11 +199,17 @@ function materializeBundle(runtime, config, options = {}) {
190
199
  throw bundleError('AGENT_BUNDLE_DEPENDENCY_MISSING');
191
200
  }
192
201
  if (packageMetadata(resolved).name !== name) {throw bundleError();}
193
- // An ancestor copy already satisfies cycles using normal Node resolution.
194
- if (ancestors.includes(resolved)) {continue;}
202
+ // Reuse only the nearest Node-visible copy of this exact source package.
203
+ // A nested version with the same name must still shadow its ancestor.
204
+ if (copiedDependency(target, name) === resolved) {continue;}
195
205
  const destination = `${target}/node_modules/${name}`;
206
+ dependencySources.set(destination, resolved);
196
207
  copyTree(resolved, destination, (relative) => ['node_modules', '.git', '.cache'].includes(relative.split('/')[0]));
197
- copyDependencies(resolved, destination, [...ancestors, resolved]);
208
+ pendingDependencies.push({ resolved, destination });
209
+ }
210
+ // Reserve all siblings before traversing shared dependencies or peer cycles.
211
+ for (const { resolved, destination } of pendingDependencies) {
212
+ copyDependencies(resolved, destination, depth + 1);
198
213
  }
199
214
  }
200
215
  try {
@@ -213,7 +228,7 @@ function materializeBundle(runtime, config, options = {}) {
213
228
  if (fs.existsSync(prd)) {
214
229
  for (const name of fs.readdirSync(prd).sort()) {if (/^demo-.*\.md$/.test(name)) {copyFile(path.join(prd, name), `openyida/project/prd/${name}`);}}
215
230
  }
216
- copyDependencies(sourceRoot, 'openyida', [sourceRoot]);
231
+ copyDependencies(sourceRoot, 'openyida');
217
232
  // An npm replacement during copying must not produce an internally mixed
218
233
  // CLI/skills snapshot. Recheck source content and tree membership before
219
234
  // publishing. Once published, execution never consults these source paths.
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ const { httpGet, requestWithAutoLogin } = require('../core/utils');
4
+ const { throwCommandError } = require('../core/command-errors');
5
+ const { t } = require('../core/i18n');
6
+ const { isAgentAppType } = require('./agent-app-type');
7
+
8
+ function themeContextFailure(reason) {
9
+ throwCommandError(t('upgrade_app_theme.context_failed'), {
10
+ code: 'APP_THEME_CONTEXT_UNVERIFIED', details: { reason },
11
+ });
12
+ }
13
+
14
+ // The application API exposes persisted mode/provenance. These establish the
15
+ // configured theme, not proof that a browser loaded the stylesheet.
16
+ function resolveAppThemeState(app = {}) {
17
+ const config = app.config && typeof app.config === 'object' && !Array.isArray(app.config) ? app.config : {};
18
+ const mode = app.appThemeMode ?? config.APP_THEME_MODE;
19
+ const enabled = app.appThemeEnable;
20
+ const createdModern = config.CREATED_WITH_MODERN_THEME;
21
+ if (enabled === 'n' || mode === 'legacy' || createdModern === 'n') {
22
+ return { mode: 'legacy', source: 'server_settings' };
23
+ }
24
+ if (enabled === 'y' && mode === 'modern') {
25
+ return { mode: 'modern', source: 'server_theme_state' };
26
+ }
27
+ if (enabled !== undefined && enabled !== null && enabled !== 'y') {
28
+ return { mode: 'unknown', source: 'server_settings' };
29
+ }
30
+ if (createdModern === 'y' &&
31
+ (mode === 'modern' || ((mode === undefined || mode === null || mode === '') && isAgentAppType(app.agentAppType)))) {
32
+ return { mode: 'modern', source: 'server_creation_config' };
33
+ }
34
+ return { mode: 'unknown', source: 'server_settings' };
35
+ }
36
+
37
+ async function fetchCurrentApp(appType, authRef, verifyIdentity = false) {
38
+ const target = { baseUrl: authRef.baseUrl, corpId: authRef.corpId, userId: authRef.userId };
39
+ if (verifyIdentity && (typeof appType !== 'string' || !/^[A-Za-z0-9_-]+$/.test(appType) ||
40
+ typeof target.corpId !== 'string' || !target.corpId || !target.baseUrl)) {
41
+ themeContextFailure('invalid_target');
42
+ }
43
+ const assertIdentity = auth => {
44
+ if (verifyIdentity && Object.keys(target).some(key => auth[key] !== target[key])) {
45
+ themeContextFailure('identity_changed');
46
+ }
47
+ };
48
+ const response = await requestWithAutoLogin((auth) => {
49
+ assertIdentity(auth);
50
+ return httpGet(
51
+ auth.baseUrl,
52
+ `/${encodeURIComponent(appType)}/query/app/getAppIncludingAecpInfo.json`,
53
+ {
54
+ _api: 'nattyFetch',
55
+ _mock: 'false',
56
+ appKey: appType,
57
+ _csrf_token: auth.csrfToken,
58
+ _stamp: Date.now(),
59
+ }
60
+ );
61
+ }, authRef);
62
+ assertIdentity(authRef);
63
+
64
+ if (verifyIdentity) {
65
+ const app = response?.content;
66
+ if (response?.success !== true || !app || typeof app !== 'object' || Array.isArray(app)) {
67
+ themeContextFailure('app_query_failed');
68
+ }
69
+ if (app.appType !== appType || app.corpId !== target.corpId) {
70
+ themeContextFailure('app_identity_mismatch');
71
+ }
72
+ }
73
+
74
+ if (!response || !response.success) {
75
+ throw new Error(response ? response.errorMsg || '查询应用详情失败' : '查询应用详情失败');
76
+ }
77
+ return response.content || {};
78
+ }
79
+
80
+ module.exports = { fetchCurrentApp, resolveAppThemeState };
@@ -28,7 +28,7 @@
28
28
  * 把 export default 改写成画布入口 `YidaComp` → UglifyJS 压缩 → 正则抽出依赖包名。
29
29
  */
30
30
 
31
- const Babel = require('@babel/standalone');
31
+ const Babel = require('../core/babel');
32
32
  const globals = require('globals');
33
33
  const UglifyJS = require('uglify-js');
34
34
  const {
@@ -273,8 +273,8 @@ function findSelfReferentialDependencyBindingIssues(source) {
273
273
  Babel.transform(source, {
274
274
  filename: 'canvas.tsx',
275
275
  presets: [
276
- ['typescript', { allExtensions: true, isTSX: true, allowDeclareFields: true }],
277
- ['react', { runtime: 'classic' }],
276
+ [Babel.presets.typescript, { allExtensions: true, isTSX: true, allowDeclareFields: true }],
277
+ [Babel.presets.react, { runtime: 'classic' }],
278
278
  ],
279
279
  plugins: [guardPlugin],
280
280
  sourceType: 'module',
@@ -396,8 +396,8 @@ function findBareDependencyGlobalIssues(source) {
396
396
  Babel.transform(source, {
397
397
  filename: 'canvas.tsx',
398
398
  presets: [
399
- ['typescript', { allExtensions: true, isTSX: true, allowDeclareFields: true }],
400
- ['react', { runtime: 'classic' }],
399
+ [Babel.presets.typescript, { allExtensions: true, isTSX: true, allowDeclareFields: true }],
400
+ [Babel.presets.react, { runtime: 'classic' }],
401
401
  ],
402
402
  plugins: [guardPlugin],
403
403
  sourceType: 'module',
@@ -460,8 +460,8 @@ function findUnboundIdentifierIssues(source, options = {}) {
460
460
  Babel.transform(source, {
461
461
  filename: 'canvas.tsx',
462
462
  presets: [
463
- ['typescript', { allExtensions: true, isTSX: true, allowDeclareFields: true }],
464
- ['react', { runtime: 'classic' }],
463
+ [Babel.presets.typescript, { allExtensions: true, isTSX: true, allowDeclareFields: true }],
464
+ [Babel.presets.react, { runtime: 'classic' }],
465
465
  ],
466
466
  plugins: [guardPlugin],
467
467
  sourceType: 'module',
@@ -559,8 +559,8 @@ function findUnavailableCanvasInstanceApiIssues(source) {
559
559
  Babel.transform(source, {
560
560
  filename: 'canvas.tsx',
561
561
  presets: [
562
- ['typescript', { allExtensions: true, isTSX: true, allowDeclareFields: true }],
563
- ['react', { runtime: 'classic' }],
562
+ [Babel.presets.typescript, { allExtensions: true, isTSX: true, allowDeclareFields: true }],
563
+ [Babel.presets.react, { runtime: 'classic' }],
564
564
  ],
565
565
  plugins: [guardPlugin],
566
566
  sourceType: 'module',
@@ -998,8 +998,8 @@ function compileCanvasLocal(source, options = {}) {
998
998
  const stage1 = Babel.transform(source, {
999
999
  filename: 'canvas.tsx',
1000
1000
  presets: [
1001
- ['typescript', { allExtensions: true, isTSX: true, allowDeclareFields: true }],
1002
- ['react', { runtime: 'classic' }],
1001
+ [Babel.presets.typescript, { allExtensions: true, isTSX: true, allowDeclareFields: true }],
1002
+ [Babel.presets.react, { runtime: 'classic' }],
1003
1003
  ],
1004
1004
  sourceType: 'module',
1005
1005
  compact: false,
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Babel = require('@babel/standalone');
3
+ const Babel = require('../core/babel');
4
4
  const { CliError } = require('../core/cli-error');
5
5
  const { t } = require('../core/i18n');
6
6
  const { packages } = require('./canvas-icon-exports.json');
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Babel = require('@babel/standalone');
3
+ const Babel = require('../core/babel');
4
4
  const { CliError } = require('../core/cli-error');
5
5
  const { t } = require('../core/i18n');
6
6
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Babel = require('@babel/standalone');
3
+ const Babel = require('../core/babel');
4
4
  const { CliError } = require('../core/cli-error');
5
5
  const { t } = require('../core/i18n');
6
6
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Babel = require('@babel/standalone');
3
+ const Babel = require('../core/babel');
4
4
  const { CliError } = require('../core/cli-error');
5
5
  const { warn } = require('../core/chalk');
6
6
  const { t } = require('../core/i18n');
@@ -22,6 +22,7 @@ const { parseOpenOption, withBrowserHandoff } = require('../core/browser-handoff
22
22
  const { throwCommandError } = require('../core/command-errors');
23
23
  const { isPermissionGuidanceError } = require('../core/permission-guidance');
24
24
  const { resolveBuilderAiSource } = require('./builder-ai-source');
25
+ const { fetchCurrentApp, resolveAppThemeState } = require('./app-theme-state');
25
26
 
26
27
  const DEFAULT_APP_OPTIONS = {
27
28
  iconColor: '#0089FF',
@@ -376,6 +377,35 @@ async function run(args) {
376
377
  const appUrl = entryUrls.appUrl;
377
378
  const corpId = authRef.corpId || (authRef.authData && authRef.authData.corp_id) || '';
378
379
 
380
+ let themeVerification;
381
+ try {
382
+ const app = await fetchCurrentApp(appType, authRef, true);
383
+ const theme = resolveAppThemeState(app);
384
+ if (theme.mode !== 'modern') {
385
+ throwCommandError(t('create_app.modern_theme_unverified'), {
386
+ code: 'APP_THEME_NOT_MODERN', details: { themeMode: theme.mode },
387
+ });
388
+ }
389
+ themeVerification = { verified: true, appThemeMode: 'modern', source: theme.source,
390
+ scope: 'configuration_readback', runtimeVerified: false };
391
+ } catch (error) {
392
+ const created = { appCreated: true, appType, corpId, url: appUrl, retryCreate: false,
393
+ partial: true, residual: { appType, corpId }, retrySafe: false, mutationPerformed: true,
394
+ sideEffectState: 'applied', readbackAllowed: true };
395
+ if (isPermissionGuidanceError(error)) {
396
+ error.details = { ...error.details, ...created };
397
+ throw error;
398
+ }
399
+ throwCommandError(t('create_app.modern_theme_unverified'), {
400
+ code: 'APP_CREATED_THEME_UNVERIFIED', details: {
401
+ ...created,
402
+ causeCode: error.code || 'APP_THEME_READ_FAILED',
403
+ ...(error.details?.themeMode ? { themeMode: error.details.themeMode } : {}),
404
+ ...(error.details?.reason ? { reason: error.details.reason } : {}),
405
+ },
406
+ });
407
+ }
408
+
379
409
  chalkResult(true, t('create_app.success'), [
380
410
  ['appType', appType],
381
411
  ['Corp ID', corpId || t('common.unknown_error')],
@@ -391,6 +421,7 @@ async function run(args) {
391
421
  appType,
392
422
  appName,
393
423
  corpId,
424
+ themeVerification,
394
425
  url: appUrl,
395
426
  ...entryUrls,
396
427
  },
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Babel = require('@babel/standalone');
3
+ const Babel = require('../core/babel');
4
4
  const { collectFixedBrandViolations } = require('./canvas-theme-guard');
5
5
 
6
6
  // Use parser tokens to remove separators without treating comments as syntax.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Babel = require('@babel/standalone');
3
+ const Babel = require('../core/babel');
4
4
  const traverse = Babel.packages.traverse.default || Babel.packages.traverse;
5
5
  const { CliError } = require('../core/cli-error');
6
6
  const { t } = require('../core/i18n');
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Babel = require('@babel/standalone');
3
+ const Babel = require('../core/babel');
4
4
 
5
5
  const parser = Babel.packages.parser;
6
6
  const traverse = Babel.packages.traverse.default || Babel.packages.traverse;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Babel = require('@babel/standalone');
3
+ const Babel = require('../core/babel');
4
4
  const { t } = require('../core/i18n');
5
5
 
6
6
  const parser = Babel.packages.parser;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Babel = require('@babel/standalone');
3
+ const Babel = require('../core/babel');
4
4
  const { CliError } = require('../core/cli-error');
5
5
  const { t } = require('../core/i18n');
6
6
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Babel = require('@babel/standalone');
3
+ const Babel = require('../core/babel');
4
4
 
5
5
  const parser = Babel.packages.parser;
6
6
  const traverse = Babel.packages.traverse.default || Babel.packages.traverse;
@@ -2,7 +2,7 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
- const Babel = require('@babel/standalone');
5
+ const Babel = require('../core/babel');
6
6
  const { findProjectRoot } = require('../core/utils');
7
7
  const { lintYidaSource } = require('./page-linter');
8
8
  const { warnLargePageSource } = require('./page-size-guard');
@@ -10,7 +10,7 @@ const { findBareCjkJsxTextIdentifiers } = require('./jsx-text-guard');
10
10
  const { findDirectFormOpenIssues } = require('./form-open-guard');
11
11
  const { findFormDetailLinkIssues } = require('./form-detail-link-guard');
12
12
  const { findResponsiveLayoutIssues } = require('./responsive-layout-guard');
13
- const Babel = require('@babel/standalone');
13
+ const Babel = require('../core/babel');
14
14
 
15
15
  const THEN_CALLBACK_LINE_LIMIT = 50;
16
16
  const CALLBACK_SCAN_LINE_LIMIT = 80;
@@ -7,8 +7,8 @@
7
7
  'use strict';
8
8
 
9
9
  const querystring = require('querystring');
10
+ const { fetchCurrentApp, resolveAppThemeState } = require('./app-theme-state');
10
11
  const {
11
- httpGet,
12
12
  httpPost,
13
13
  requestWithAutoLogin,
14
14
  } = require('../core/utils');
@@ -376,35 +376,24 @@ function preserveBasicSettings(payload, app) {
376
376
  }
377
377
  }
378
378
 
379
- function requireAppStyleConfirmation(params, context) {
380
- const modern = pickAppField(context, 'appThemeEnable', 'APP_THEME_ENABLE') === 'y' &&
381
- pickAppField(context, 'appThemeMode', 'APP_THEME_MODE') === 'modern';
382
- if (!modern && params.confirmLegacyAppStyle !== true) {
379
+ function requireAppStyleConfirmation(params, app) {
380
+ const theme = resolveAppThemeState(app);
381
+ if (theme.mode !== 'modern' && params.confirmLegacyAppStyle !== true) {
382
+ const storedMode = pickAppField(app, 'appThemeMode', 'APP_THEME_MODE');
383
383
  throwCommandError(t('update_app.legacy_style_confirm_required'), {
384
384
  code: 'LEGACY_APP_CUSTOM_THEME_CONFIRMATION_REQUIRED',
385
- details: { appType: params.appType, applicationSettingsWritten: false, nextAction: 'ask_user_for_application_style_injection' },
385
+ details: { appType: params.appType, applicationSettingsWritten: false,
386
+ themeCapability: theme.mode, storedThemeMode: typeof storedMode === 'string' ? storedMode : null,
387
+ nextAction: 'ask_user_for_application_style_injection' },
386
388
  });
387
389
  }
388
390
  }
389
391
 
390
- // Runtime capability is resolved by the server. Stored APP_THEME_MODE alone is insufficient.
391
392
  async function checkAppStyleInjection(params, authRef) {
392
- const html = await requestWithAutoLogin(auth => httpGet(auth.baseUrl,
393
- `/${encodeURIComponent(params.appType)}/admin`, { _stamp: Date.now() }, { responseType: 'text' }), authRef);
394
- const { parseThemeContext } = require('./upgrade-app-theme');
395
- // Even human approval cannot waive target application and organization identity.
396
- const identity = parseThemeContext(html, ['appType', 'corpId']);
397
- if (identity.appType !== params.appType || !authRef.corpId || identity.corpId !== authRef.corpId) {
398
- throwCommandError(t('upgrade_app_theme.context_failed'), { code: 'APP_THEME_CONTEXT_UNVERIFIED' });
399
- }
400
- let context;
401
- try {
402
- context = parseThemeContext(html, ['appType', 'corpId', 'appThemeEnable', 'appThemeMode']);
403
- } catch (error) {
404
- if (error.code !== 'APP_THEME_CONTEXT_UNVERIFIED') {throw error;}
405
- return requireAppStyleConfirmation(params, {});
406
- }
407
- requireAppStyleConfirmation(params, context);
393
+ // AppRpc#getAppIncludingAecpInfo returns the application's own identity.
394
+ // Never open /admin or follow a browser login redirect to validate an API write.
395
+ const app = await fetchCurrentApp(params.appType, authRef, true);
396
+ requireAppStyleConfirmation(params, app);
408
397
  }
409
398
 
410
399
  function buildUpdateAppPostData(params, currentApp = {}, authRef) {
@@ -520,25 +509,6 @@ function buildUpdateAppPostData(params, currentApp = {}, authRef) {
520
509
  return postDataObj;
521
510
  }
522
511
 
523
- async function fetchCurrentApp(appType, authRef) {
524
- const response = await requestWithAutoLogin((auth) => httpGet(
525
- auth.baseUrl,
526
- `/${appType}/query/app/getAppIncludingAecpInfo.json`,
527
- {
528
- _api: 'nattyFetch',
529
- _mock: 'false',
530
- appKey: appType,
531
- _csrf_token: auth.csrfToken,
532
- _stamp: Date.now(),
533
- }
534
- ), authRef);
535
-
536
- if (!response || !response.success) {
537
- throw new Error(response ? response.errorMsg || '查询应用详情失败' : '查询应用详情失败');
538
- }
539
- return response.content || {};
540
- }
541
-
542
512
  function getThemeSettings(app) {
543
513
  const rawStyle = pickAppField(app, 'customThemeStyle', 'CUSTOM_THEME_STYLE');
544
514
  let customThemeStyle = rawStyle || null;
@@ -573,6 +543,32 @@ function themeReadbackEvidence(params, details) {
573
543
  return { ...details, scope: 'configuration_readback', operation, runtimeVerified: false };
574
544
  }
575
545
 
546
+ /** Configuration completion is separate from rendering. */
547
+ function getThemeCompletion(params, currentApp, app, themeVerified, navigationVerified) {
548
+ const before = resolveAppThemeState(currentApp);
549
+ const theme = resolveAppThemeState(app);
550
+ const operation = params.customThemeStyle ? 'application_css'
551
+ : params.disableCustomTheme ? 'disable'
552
+ : params.colour && params.colour !== 'custom' ? 'preset' : 'partial_update';
553
+ const actual = getThemeSettings(app);
554
+ const checks = {
555
+ themeModeVerified: theme.mode !== 'unknown' && theme.mode === before.mode,
556
+ settingsVerified: themeVerified === true,
557
+ navigationVerified: navigationVerified === true,
558
+ };
559
+ if (operation === 'application_css') {
560
+ checks.resourceBound = actual.colour === 'custom' && !!normalizeCssColorToHex(actual.themeColor) &&
561
+ actual.customThemeStyle?.enabled === true &&
562
+ typeof actual.customThemeStyle?.cssUrl === 'string' && !!actual.customThemeStyle.cssUrl.trim();
563
+ // Legacy overlays require scope approval.
564
+ if (theme.mode === 'legacy') {checks.legacyScopeConfirmed = params.confirmLegacyAppStyle === true;}
565
+ }
566
+ const complete = operation !== 'partial_update' && Object.values(checks).every(value => value === true);
567
+ return { scope: 'configuration_readback', operation, mode: theme.mode, modeSource: theme.source,
568
+ complete, status: complete ? 'complete' : operation === 'partial_update' ? 'partial' : 'incomplete',
569
+ checks, missing: Object.keys(checks).filter(key => !checks[key]), runtimeVerified: false };
570
+ }
571
+
576
572
  function noThemeUpload(appType) {
577
573
  return { requested: false, status: 'not_requested', uploadedThisRun: false, appType };
578
574
  }
@@ -633,6 +629,7 @@ async function saveAppSettings(params, authRef) {
633
629
  const navigationFields = Object.keys(expectedNavigation);
634
630
  if (!verifyTheme && !navigationFields.length) {return response;}
635
631
  let actual;
632
+ let actualApp = {};
636
633
  let actualNavigation;
637
634
  let readbackError;
638
635
  let themeVerified = !verifyTheme;
@@ -642,13 +639,15 @@ async function saveAppSettings(params, authRef) {
642
639
  if (attempt) { await new Promise((resolve) => setTimeout(resolve, attempt * 250)); }
643
640
  try {
644
641
  const app = await fetchCurrentApp(params.appType, authRef);
642
+ actualApp = app;
645
643
  actual = getThemeSettings(app);
646
644
  actualNavigation = getNavigationSettings(app, navigationFields, currentApp, params.disableCustomTheme);
647
645
  readbackError = undefined;
648
646
  themeVerified = !verifyTheme || themeSettingsMatch(expected, actual);
649
647
  navigationVerified = navigationFields.every((name) => expectedNavigation[name] === actualNavigation[name]);
650
- if (themeVerified && navigationVerified) {
651
- return { ...response,
648
+ const themeCompletion = getThemeCompletion(params, currentApp, app, themeVerified, navigationVerified);
649
+ if (themeVerified && navigationVerified && (!params.customThemeStyle || themeCompletion.complete)) {
650
+ return { ...response, themeCompletion,
652
651
  ...(submittedFields ? { submittedFields } : {}),
653
652
  ...(verifyTheme ? { themeVerification: themeReadbackEvidence(params, { verified: true, ...actual }) } : {}),
654
653
  ...(navigationFields.length ? { navigationVerification: { verified: true, ...actualNavigation } } : {}),
@@ -662,9 +661,12 @@ async function saveAppSettings(params, authRef) {
662
661
  }
663
662
  return {
664
663
  success: false,
664
+ themeCompletion: getThemeCompletion(params, currentApp, actualApp, themeVerified, navigationVerified),
665
665
  ...(submittedFields ? { submittedFields } : {}),
666
- errorCode: themeVerified ? 'APP_NAVIGATION_NOT_PERSISTED' : 'APP_THEME_NOT_PERSISTED',
667
- errorMsg: t(themeVerified ? 'update_app.navigation_not_persisted' : 'update_app.theme_not_persisted'),
666
+ errorCode: !themeVerified ? 'APP_THEME_NOT_PERSISTED' : !navigationVerified
667
+ ? 'APP_NAVIGATION_NOT_PERSISTED' : 'APP_THEME_CONFIGURATION_INCOMPLETE',
668
+ errorMsg: t(!themeVerified ? 'update_app.theme_not_persisted' : !navigationVerified
669
+ ? 'update_app.navigation_not_persisted' : 'update_app.theme_configuration_incomplete'),
668
670
  ...(verifyTheme ? { themeVerification: themeReadbackEvidence(params, themeVerified
669
671
  ? { verified: true, ...actual } : { verified: false, expected, actual, readbackError }) } : {}),
670
672
  ...(navigationFields.length ? { navigationVerification: navigationVerified
@@ -813,6 +815,7 @@ async function run(args) {
813
815
  success: true,
814
816
  appType: params.appType,
815
817
  themeVerification: response.themeVerification,
818
+ themeCompletion: response.themeCompletion,
816
819
  themeUpload,
817
820
  nameVerification,
818
821
  navigationVerification: response.navigationVerification,
@@ -838,11 +841,12 @@ async function run(args) {
838
841
  themeUpload,
839
842
  runtimeVerification: { verified: false, status: 'not_checked' },
840
843
  submittedFields: response && response.submittedFields,
844
+ themeCompletion: response && response.themeCompletion,
841
845
  errorCode: response && response.errorCode, themeVerification: response && response.themeVerification,
842
846
  navigationVerification: response && response.navigationVerification }));
843
847
  throwCommandError(errorMsg, { code: response && response.errorCode,
844
848
  details: response && { ...(response.errorCode === 'APP_NAVIGATION_NOT_PERSISTED' ? response.navigationVerification : response.themeVerification),
845
- ...themeFailureEvidence(themeUpload) } });
849
+ themeCompletion: response.themeCompletion, ...themeFailureEvidence(themeUpload) } });
846
850
  }
847
851
  }
848
852
 
@@ -32,7 +32,7 @@ function parseThemeContext(html, wanted = ['appType', 'corpId', 'agentAppType'])
32
32
  for (const match of html.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script\s*>/gi)) {
33
33
  if (!match[1].includes('window.pageConfig')) { continue; }
34
34
  let ast;
35
- try { ast = require('@babel/standalone').transform(match[1], { ast: true, code: false }).ast; }
35
+ try { ast = require('../core/babel').transform(match[1], { ast: true, code: false }).ast; }
36
36
  catch (_) { return fail(); }
37
37
  for (const statement of ast.program.body) {
38
38
  const expr = statement.expression;
@@ -17,7 +17,8 @@ const MAX_RESPONSE_BYTES = 65536;
17
17
  function fail(code) {
18
18
  return new CliError(t('qwenwork.desktop_login_failed'), {
19
19
  code: `QWENWORK_DESKTOP_${code}`,
20
- details: { invocation: buildQwenWorkLoginInvocation() },
20
+ details: { stage: 'authentication', owner: 'openyida', retryable: false,
21
+ nextAction: 'retry_after_host_state_changes', output_visibility: 'internal', invocation: buildQwenWorkLoginInvocation() },
21
22
  });
22
23
  }
23
24