bpmax-cli 0.2.1-beta.57 → 0.2.1-beta.59

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.
@@ -0,0 +1,3 @@
1
+ # Source contract
2
+
3
+ 维护者从前端 `riIconList` 导出生成 `assets/ri-icons.json`。分发后的 CLI 只读取该 JSON,不要求用户拥有前端 checkout。
@@ -51,6 +51,7 @@ description: "用于通过 bpmax-cli typed config 创建或编辑 BPMAX 项目
51
51
  10. 高风险改动必须以真实用户身份打开运行态列表页,只读验证目标列、操作按钮、图标/头像/badge/图片预览、筛选和 console/network 错误;不得把接口提交伪装成页面回归。
52
52
 
53
53
  ## 核心配置门禁
54
+ - 任何 icon 选择或修改前,必须先读取 `../bpmax-icon-catalog/SKILL.md` 并运行 `bpmax-cli icon search/get/validate`;只使用 catalog 返回的完整 class。
54
55
  - 列表模板是 `flow_page_template.type = 1`,主体是 `content: JSON.stringify({ level, config })`;不是表单模板,不使用 `rule/value/field_type/publish`。
55
56
  - 当项目列表为空时,先查流程 `meta.table_list_template` 和 `GET /api/flow_page_template?flow_type=<flow_type>&type=1`,不要直接归因到 ES 数据为空。
56
57
  - 列表模板 `data_set_id` 必须指向当前流程实际发布并可刷新的数据集;切换数据集后必须重新检查所有字段 key。
@@ -98,7 +99,7 @@ description: "用于通过 bpmax-cli typed config 创建或编辑 BPMAX 项目
98
99
  - 若使用 `disabled`,必须反向写成 `return !ctx.$CAN_DELETE`;不得把 `confirm`、`onClick` 或事件脚本当成权限 guard。
99
100
  - 项目状态可以作为额外业务限制,但不能替代权限 guard;禁止要求 `current_flow_step_id/name` 为空,创建即进入首节点的流程会使该条件恒为 false。
100
101
  - 操作列列根不得配置 `icon` / `iconColor`;每个操作按钮必须带按钮级 icon。
101
- - icon 必须写完整 class:`ri ri_*`;普通数据列至少 1 列、最多 3 列带 icon。
102
+ - icon 必须写完整且存在于 catalog 的 class:`ri ri_<name-with-hyphens>`,例如 `ri ri_bank-line`;普通数据列至少 1 列、最多 3 列带 icon。
102
103
  - 人员列必须渲染头像,优先 `el-avatar + span`;只显示姓名文本不合格。
103
104
  - 至少一个非操作数据列必须自适应:不写 `props.width`,可用 `props.minWidth` 保证最低可读宽度;操作/选择/序号列不计入自适应列。
104
105
  - 固定数据列可只写 `width`;需要同时约束下限时再写 `minWidth`,并保证 `minWidth <= width`。标题必须能在列宽内完整展示,禁止 `auto`、百分比、非正数等不可验证宽度。
@@ -184,6 +184,7 @@ description: "用于通过 bpmax-cli typed config 创建或编辑 BPMAX PC导航
184
184
  - 如果用户提供的是跨工作区路径,默认不擅自改写 workspace 前缀。
185
185
 
186
186
  ### 7. Icon 规则
187
+ - 开始选 icon 前必须读取 `../bpmax-icon-catalog/SKILL.md`,先用 `bpmax-cli icon search` 获取候选并用 `icon validate` 校验;只提交 catalog 返回的完整 class。
187
188
  - 不要凭源码文件名或历史配置猜 icon 格式。
188
189
  - 必须优先以当前页面弹窗里的图标选择器为准,直接读取界面上实际可选的 icon。
189
190
  - 当前页面实际可选图标来自 `IconPicker` 弹窗,而不是旧版 `iconList` 下拉。
@@ -1,12 +1,39 @@
1
1
  ---
2
2
  name: bpmax-plugin-config
3
3
  version: 1.0.0
4
- description: Discover BPMAX plugin-scoped Agent skills and install them explicitly with bpmax-cli.
4
+ description: Manage BPMAX plugin activation, plugin-scoped Agent skills, and plugin-owned configuration through typed bpmax-cli workflows.
5
5
  ---
6
6
 
7
7
  # BPMAX Plugin Config
8
8
 
9
- Use this skill when a BPMAX task involves a plugin-provided capability and the exact plugin-specific skill may need to be discovered, installed, or updated locally first.
9
+ Use this skill when a BPMAX task involves installing or activating a plugin, discovering its Agent Skill, or changing plugin-owned configuration.
10
+
11
+ ## Distinguish the four plugin states
12
+
13
+ - **Installed** means the organization has the plugin package. It does not mean the plugin is active in any workspace.
14
+ - **Activated** means the installed plugin is effective in selected workspaces. Organization defaults are mandatory in every existing and future workspace and cannot be disabled from one workspace.
15
+ - **Skill installed** means the current Agent has the plugin's local instructions, lint, and config adapters. It does not activate the runtime plugin.
16
+ - **Configured** means plugin-owned business settings have been written after activation and Skill discovery. Activation does not create those settings.
17
+
18
+ ## Activation flow
19
+
20
+ 1. Read the centralized activation overview before changing anything:
21
+
22
+ ```bash
23
+ bpmax-cli plugin activation overview --profile <profile> --format json
24
+ ```
25
+
26
+ 2. Choose one typed mutation scope and review its dry-run:
27
+
28
+ ```bash
29
+ bpmax-cli plugin activation workspace set --workspace <workspace> --plugin <plugin_name> --profile <profile> --format json
30
+ bpmax-cli plugin activation plugin set-workspaces --plugin <plugin_name> --workspace <workspace> --profile <profile> --format json
31
+ bpmax-cli plugin activation defaults set --plugin <plugin_name> --profile <profile> --format json
32
+ ```
33
+
34
+ 3. After the user accepts the displayed scope, repeat the same command with `--confirm`. The CLI must submit through `config.plugin.activation.submit`, read back `config.plugin.activation.export`, and return `readback_confirmed: true`.
35
+
36
+ 4. Only after effective activation is proven should the Agent install/update the plugin Skill and edit plugin-owned configuration.
10
37
 
11
38
  ## Automatic discovery
12
39
 
@@ -36,6 +63,12 @@ bpmax-cli plugin skills ensure <plugin_name> --profile <profile> --agent codex -
36
63
 
37
64
  ## Safety Rules
38
65
 
66
+ - Do not confuse plugin installation, workspace activation, local Skill installation, and plugin configuration.
67
+ - Never infer activation from an installed plugin row or a local Skill directory. Use `plugin activation overview`.
68
+ - A workspace mutation cannot remove an organization default plugin. Do not generate a single-workspace disable attempt for `default_active: true`.
69
+ - Setting organization defaults affects all existing and future workspaces. Always show the dry-run scope before using `--confirm`.
70
+ - A successful PUT is not completion. Require typed overview readback and report `submitted_readback_mismatch` as an unresolved remote mutation, not as success.
71
+ - Removing a plugin from organization defaults does not prove it is disabled in every workspace; inspect the returned effective workspace activation.
39
72
  - Do not assume plugin installation also installed local Agent skills.
40
73
  - Do not manually copy plugin skill folders unless `bpmax-cli plugin skills ensure` fails and the user explicitly approves a fallback.
41
74
  - Treat `config.plugin.*` capabilities like other BPMAX configuration capabilities: they require an authorized profile and organization-admin configuration access.
@@ -55,4 +88,5 @@ bpmax-cli plugin skills check --profile <profile> --agent codex --format json
55
88
  bpmax-cli plugin skills ensure <plugin_name> --profile <profile> --agent codex --format json
56
89
  bpmax-cli plugin skills update <plugin_name> --profile <profile> --agent codex --format json
57
90
  bpmax-cli plugin skills state --profile <profile> --agent codex --format json
91
+ bpmax-cli plugin activation overview --profile <profile> --format json
58
92
  ```
@@ -74,7 +74,7 @@ helper 返回后必须立即执行 `bpmax-cli e2e identity browser complete --re
74
74
 
75
75
  身份桥包含页面路由、精确用户筛选和写后身份回读,浏览器控制调用必须提供至少 180 秒执行预算。调用超时或控制通道中断时不得重跑 mock;先检查 recording session 根目录的 `identity-lease.json`,按 readback-first 方式 resolve。
76
76
 
77
- helper 只能执行固定 UI 动作:读取当前身份、按 typed readback 姓名筛选、核对唯一行内用户 ID、点击该行“模拟”、点击导航菜单“退出模拟”。它不会读取浏览器 Cookie、localStorage 或密码,也不会开放任意接口请求。
77
+ helper 只能执行固定 UI 动作:读取当前身份、按 typed readback 姓名筛选、核对唯一行内用户 ID、点击该行“模拟”、点击导航菜单“退出模拟”。动作文字会在页面 DOM 中自动识别中文、英文和日文版本,不要求 request 语言与当前 UI 语言一致。身份 ID 优先来自 Vuex;只有 `/userProfileEditor?id=<user_id>` 或带当前工作区前缀的 `/w:<workspace>/userProfileEditor?id=<user_id>` 这类已确认用户资料路由可以作为兜底,项目办理页等业务路由中的 `id` 永远不能作为用户 ID。只有姓名而没有可信 ID 时必须阻断,不能形成 status/mock 成功证据。helper 不会读取浏览器 Cookie、localStorage 或密码,也不会开放任意接口请求。
78
78
 
79
79
  ## 身份工作流
80
80
  1. 记录原始管理账号、workspace、当前页面和目标测试角色;使用 `bpmax-cli user resolve` 或 typed user readback 精确解析目标用户,不得凭姓名猜 ID。browser mock 会再次按 `user_id` 回读有效状态和姓名。
@@ -133,14 +133,50 @@ function assertReleaseClaimAvailable(existing, request) {
133
133
  throw new Error('identity_lease_recovery_in_progress');
134
134
  }
135
135
 
136
- function labelsFor(language) {
137
- if (String(language).toLowerCase().startsWith('en')) {
138
- return { simulation: 'Simulation', exitSimulation: 'Exit Simulation' };
139
- }
140
- if (/^(?:jap|ja)/i.test(String(language))) {
141
- return { simulation: 'シミュレーション', exitSimulation: 'シミュレーションを終了' };
136
+ export function identityUiLabelCandidates() {
137
+ return {
138
+ simulation: ['模拟', 'Simulation', 'シミュレーション'],
139
+ exitSimulation: ['退出模拟', 'Exit Simulation', 'シミュレーションを終了'],
140
+ logout: ['退出登录', 'Log out', 'ログアウト'],
141
+ };
142
+ }
143
+
144
+ export function labelsFor(language) {
145
+ const preferred = String(language).toLowerCase().startsWith('en')
146
+ ? 1
147
+ : /^(?:jap|ja)/i.test(String(language))
148
+ ? 2
149
+ : 0;
150
+ const order = (values) => [values[preferred], ...values.filter((_, index) => index !== preferred)];
151
+ const candidates = identityUiLabelCandidates();
152
+ return {
153
+ simulation: order(candidates.simulation),
154
+ exitSimulation: order(candidates.exitSimulation),
155
+ logout: order(candidates.logout),
156
+ };
157
+ }
158
+
159
+ export function mockStateFromGuideAction(count, label, labels) {
160
+ if (count > 1) throw new Error(`identity_exit_simulation_count_${count}`);
161
+ if (count === 0) return false;
162
+ if (labels.exitSimulation.includes(label)) return true;
163
+ if (labels.logout.includes(label)) return false;
164
+ throw new Error('identity_action_label_not_found');
165
+ }
166
+
167
+ export function profileRouteUserId(value, returnUrl) {
168
+ const url = new URL(value);
169
+ const trusted = new URL(returnUrl);
170
+ if (url.origin !== trusted.origin) return null;
171
+ const workspaceMatch = trusted.pathname.match(/^\/w:([^/]+)(?:\/|$)/);
172
+ const allowedPaths = new Set(['/userProfileEditor', '/userProfileEditor/']);
173
+ if (workspaceMatch) {
174
+ allowedPaths.add(`/w:${workspaceMatch[1]}/userProfileEditor`);
175
+ allowedPaths.add(`/w:${workspaceMatch[1]}/userProfileEditor/`);
142
176
  }
143
- return { simulation: '模拟', exitSimulation: '退出模拟' };
177
+ if (!allowedPaths.has(url.pathname)) return null;
178
+ const id = Number(url.searchParams.get('id'));
179
+ return Number.isSafeInteger(id) && id > 0 ? id : null;
144
180
  }
145
181
 
146
182
  function validateRequest(value) {
@@ -328,14 +364,26 @@ async function dismissGuideBeforeMutation(tab, actions) {
328
364
  if (guideCount > 1) throw new Error(`identity_guide_count_${guideCount}`);
329
365
  if (guideCount === 0 || (typeof guide.isVisible === 'function' && !await guide.isVisible())) return;
330
366
 
331
- const close = guide.locator('.guide-header .el-icon-close', {});
367
+ const close = tab.playwright.locator('.guid-menu-container .guide-header .el-icon-close');
332
368
  const closeCount = await close.count();
333
369
  if (closeCount !== 1) throw new Error(`identity_guide_close_count_${closeCount}`);
334
370
  if (typeof close.isVisible === 'function' && !await close.isVisible()) {
335
371
  throw new Error('identity_guide_close_not_visible');
336
372
  }
337
- await close.click({ trial: true });
338
- await close.click({});
373
+ try {
374
+ await close.click({ trial: true });
375
+ await close.click({});
376
+ } catch (error) {
377
+ if (!isTransientLocatorError(error)) throw error;
378
+ const trigger = await waitForUniqueVisible(
379
+ tab.playwright.locator('.page-header .keep-right > .user-info'),
380
+ 'identity_header_trigger_close',
381
+ 5_000,
382
+ );
383
+ await trigger.click({ trial: true });
384
+ await trigger.click({});
385
+ actions.push('dismiss identity guide through stable header trigger');
386
+ }
339
387
  await tab.playwright.waitForTimeout(400);
340
388
  actions.push('dismiss identity guide before target mutation');
341
389
  }
@@ -371,12 +419,13 @@ async function readProfileRouteIdentity(tab, returnUrl) {
371
419
  await userContainer.click({});
372
420
  const profileDeadline = Date.now() + 10_000;
373
421
  let profileUrl = await tab.url();
374
- while (!new URL(profileUrl).searchParams.get('id') && Date.now() <= profileDeadline) {
422
+ let id = profileRouteUserId(profileUrl, returnUrl);
423
+ while (id === null && Date.now() <= profileDeadline) {
375
424
  await tab.playwright.waitForTimeout(250);
376
425
  profileUrl = await tab.url();
426
+ id = profileRouteUserId(profileUrl, returnUrl);
377
427
  }
378
- const id = Number(new URL(profileUrl).searchParams.get('id'));
379
- if (!Number.isSafeInteger(id) || id <= 0) throw new Error('identity_profile_id_missing');
428
+ if (id === null) throw new Error('identity_profile_route_untrusted');
380
429
  if (typeof tab.back === 'function') {
381
430
  await tab.back();
382
431
  }
@@ -395,13 +444,19 @@ async function readCurrentIdentity(tab, request, labels) {
395
444
  const guide = await openGuide(tab);
396
445
  const nameLocator = await unique(guide.locator('.guide-footer .user-name', {}), 'identity_footer_name');
397
446
  const visibleName = (await nameLocator.innerText({})).trim() || null;
398
- const exitCount = await guide.getByText(labels.exitSimulation, { exact: true }).count();
399
- if (!identity?.id) identity = await readProfileRouteIdentity(tab, request.return_url);
447
+ let mocked = identity?.source === 'vuex' ? identity.mock : false;
448
+ if (!identity?.id) {
449
+ const exitAction = guide.locator('.guide-footer .action-item.log-out', {});
450
+ const exitCount = await exitAction.count();
451
+ const exitLabel = exitCount === 1 ? (await exitAction.innerText({})).trim() : null;
452
+ mocked = mockStateFromGuideAction(exitCount, exitLabel, labels);
453
+ identity = await readProfileRouteIdentity(tab, request.return_url);
454
+ }
400
455
  await openGuide(tab);
401
456
  return {
402
457
  ...(identity || normalizeIdentity({}, 'dom')),
403
458
  name: visibleName || identity?.name || null,
404
- mock: exitCount === 1,
459
+ mock: mocked,
405
460
  };
406
461
  }
407
462
 
@@ -464,28 +519,57 @@ function isTransientLocatorError(error) {
464
519
  return /timed out|selector deadline exceeded/i.test(message);
465
520
  }
466
521
 
522
+ function isMockActionRevealRequired(error) {
523
+ const message = error instanceof Error ? error.message : String(error);
524
+ return /identity_action_(?:label_not_found|not_visible)/.test(message);
525
+ }
526
+
527
+ function cssAttributeValue(value) {
528
+ return String(value).replace(/\\/g, '\\\\').replace(/"/g, '\\"');
529
+ }
530
+
467
531
  async function inspectExactTargetAction(tab, request, labels, timeoutMs) {
468
532
  const targetUserId = String(request.target_user_id);
469
533
  const targetUserName = String(request.target_user_name).trim();
470
- return tab.playwright.evaluate(async ({ id, name, buttonLabel, waitMs, stableMs }) => {
534
+ return tab.playwright.evaluate(async ({ id, name, buttonLabels, waitMs, stableMs, managementUrl }) => {
535
+ const trusted = new URL(managementUrl);
536
+ const workspaceMatch = trusted.pathname.match(/^\/w:([^/]+)(?:\/|$)/);
537
+ const allowedProfilePaths = new Set(['/userProfileEditor', '/userProfileEditor/']);
538
+ if (workspaceMatch) {
539
+ allowedProfilePaths.add(`/w:${workspaceMatch[1]}/userProfileEditor`);
540
+ allowedProfilePaths.add(`/w:${workspaceMatch[1]}/userProfileEditor/`);
541
+ }
542
+ const trustedProfileId = (href) => {
543
+ try {
544
+ const url = new URL(href, trusted.origin);
545
+ if (url.origin !== trusted.origin || !allowedProfilePaths.has(url.pathname)) return null;
546
+ const value = Number(url.searchParams.get('id'));
547
+ return Number.isSafeInteger(value) && value > 0 ? String(value) : null;
548
+ } catch {
549
+ return null;
550
+ }
551
+ };
471
552
  const inspect = () => {
472
553
  const input = document.querySelector('.button-line > .el-input input');
473
- const rows = Array.from(document.querySelectorAll('tbody tr')).filter((row) => (
474
- Array.from(row.querySelectorAll('td')).some((cell) => String(cell.textContent || '').trim() === id)
554
+ const allRows = Array.from(document.querySelectorAll('tbody tr'));
555
+ const rows = allRows.filter((row) => Array.from(row.querySelectorAll('a[href]')).some(
556
+ (anchor) => trustedProfileId(anchor.getAttribute('href')) === id,
475
557
  ));
476
558
  if (rows.length !== 1) {
477
559
  return { status: rows.length > 1 ? 'ambiguous' : 'missing', row_count: rows.length };
478
560
  }
479
561
  const row = rows[0];
480
- const idCount = Array.from(row.querySelectorAll('td')).filter(
481
- (cell) => String(cell.textContent || '').trim() === id,
482
- ).length;
562
+ const profileLinks = Array.from(row.querySelectorAll('a[href]')).filter(
563
+ (anchor) => trustedProfileId(anchor.getAttribute('href')) === id,
564
+ );
565
+ const idCount = profileLinks.length;
483
566
  const nameNodes = Array.from(row.querySelectorAll('.user-name-text'));
484
567
  const actualName = nameNodes.length === 1 ? String(nameNodes[0].textContent || '').trim() : null;
485
568
  const buttons = Array.from(row.querySelectorAll('button')).filter(
486
- (button) => String(button.textContent || '').trim() === buttonLabel,
569
+ (button) => buttonLabels.includes(String(button.textContent || '').trim()),
487
570
  );
488
571
  const button = buttons.length === 1 ? buttons[0] : null;
572
+ const actionLabel = button ? String(button.textContent || '').trim() : null;
489
573
  const buttonVisible = Boolean(button && button.getClientRects().length > 0);
490
574
  const buttonEnabled = Boolean(button && !button.disabled && button.getAttribute('aria-disabled') !== 'true');
491
575
  const ready = String(input?.value || '') === name
@@ -500,13 +584,24 @@ async function inspectExactTargetAction(tab, request, labels, timeoutMs) {
500
584
  ? 'ready'
501
585
  : actualName && actualName !== name
502
586
  ? 'name_mismatch'
587
+ : buttons.length === 0
588
+ ? 'action_label_missing'
589
+ : buttons.length > 1
590
+ ? 'action_label_ambiguous'
591
+ : !buttonVisible
592
+ ? 'action_not_visible'
593
+ : !buttonEnabled
594
+ ? 'action_disabled'
503
595
  : 'candidate',
504
596
  row_count: rows.length,
505
597
  id_count: idCount,
506
598
  name_count: nameNodes.length,
507
599
  actual_name: actualName,
600
+ action_label: actionLabel,
508
601
  button_count: buttons.length,
509
602
  input_value: String(input?.value || ''),
603
+ row_index: allRows.indexOf(row),
604
+ profile_href: profileLinks.length === 1 ? profileLinks[0].getAttribute('href') : null,
510
605
  };
511
606
  };
512
607
 
@@ -526,11 +621,15 @@ async function inspectExactTargetAction(tab, request, labels, timeoutMs) {
526
621
  else if (sawCandidate) return { ...state, status: 'overwritten' };
527
622
  await new Promise((resolve) => setTimeout(resolve, 250));
528
623
  }
529
- return { ...inspect(), status: 'timeout' };
624
+ const finalState = inspect();
625
+ return ['action_label_missing', 'action_label_ambiguous', 'action_not_visible', 'action_disabled'].includes(finalState.status)
626
+ ? finalState
627
+ : { ...finalState, status: 'timeout' };
530
628
  }, {
531
629
  id: targetUserId,
532
630
  name: targetUserName,
533
- buttonLabel: labels.simulation,
631
+ buttonLabels: labels.simulation,
632
+ managementUrl: request.user_management_url,
534
633
  waitMs: timeoutMs,
535
634
  stableMs: 750,
536
635
  }, { timeoutMs: timeoutMs + 5_000 });
@@ -540,22 +639,25 @@ async function resolveExactTargetAction(tab, request, labels, timeoutMs) {
540
639
  const state = await inspectExactTargetAction(tab, request, labels, timeoutMs);
541
640
  if (state.status === 'ambiguous') throw new Error(`identity_exact_user_row_count_${state.row_count}`);
542
641
  if (state.status === 'name_mismatch') throw new Error('identity_target_name_changed');
642
+ if (state.status === 'action_label_missing') throw new Error('identity_action_label_not_found');
643
+ if (state.status === 'action_label_ambiguous') throw new Error(`identity_action_label_ambiguous_${state.button_count}`);
644
+ if (state.status === 'action_not_visible') throw new Error('identity_action_not_visible');
645
+ if (state.status === 'action_disabled') throw new Error('identity_action_disabled');
543
646
  if (state.status !== 'ready') return { state, resolved: null };
544
647
 
545
- const targetUserId = String(request.target_user_id);
546
648
  const targetUserName = String(request.target_user_name).trim();
547
- const row = tab.playwright
548
- .locator('tbody tr')
549
- .filter({
550
- has: tab.playwright.getByText(targetUserId, { exact: true }),
551
- hasText: targetUserName,
552
- });
553
- if (await row.count() !== 1
554
- || await row.getByText(targetUserId, { exact: true }).count() !== 1
649
+ const profileHref = String(state.profile_href || '');
650
+ const profileId = profileHref ? profileRouteUserId(new URL(profileHref, request.origin).toString(), request.user_management_url) : null;
651
+ const row = profileHref
652
+ ? tab.playwright.locator(`tbody tr:has(a[href="${cssAttributeValue(profileHref)}"])`)
653
+ : null;
654
+ if (!row
655
+ || profileId !== request.target_user_id
656
+ || await row.count() !== 1
555
657
  || await row.locator('.user-name-text', {}).count() !== 1) {
556
658
  return { state: { ...state, status: 'overwritten' }, resolved: null };
557
659
  }
558
- const simulation = row.getByRole('button', { name: labels.simulation, exact: true });
660
+ const simulation = row.getByRole('button', { name: state.action_label, exact: true });
559
661
  const simulationCount = await simulation.count();
560
662
  if (simulationCount !== 1) throw new Error(`identity_exact_simulation_button_count_${simulationCount}`);
561
663
 
@@ -564,6 +666,7 @@ async function resolveExactTargetAction(tab, request, labels, timeoutMs) {
564
666
  resolved: {
565
667
  simulation,
566
668
  targetName: String(state.actual_name || '').trim(),
669
+ actionLabel: state.action_label,
567
670
  },
568
671
  };
569
672
  }
@@ -577,12 +680,14 @@ async function waitForExactTargetAction(tab, search, request, labels, actions) {
577
680
  return existing.resolved;
578
681
  }
579
682
  } catch (error) {
580
- if (!isTransientLocatorError(error)) throw error;
683
+ if (!isTransientLocatorError(error) && !isMockActionRevealRequired(error)) throw error;
684
+ if (isMockActionRevealRequired(error)) actions.push('reveal hidden simulation action');
581
685
  }
582
686
  for (let attempt = 1; attempt <= TARGET_SEARCH_ATTEMPTS; attempt += 1) {
583
687
  if (attempt === 1) {
584
688
  await search.fill(REVEAL_MOCK_ACTION, {});
585
- await tab.playwright.waitForTimeout(100);
689
+ // userManagement reveals the mock column from a 500 ms debounced watcher.
690
+ await tab.playwright.waitForTimeout(750);
586
691
  } else {
587
692
  await search.fill('', {});
588
693
  await tab.playwright.waitForTimeout(100);
@@ -609,6 +714,22 @@ async function waitForExactTargetAction(tab, search, request, labels, actions) {
609
714
  throw new Error('identity_exact_user_row_count_0');
610
715
  }
611
716
 
717
+ async function clickUniqueVisibleAction(tab, actionLabels, fallbackLocator) {
718
+ if (!tab.dom_cua?.get_visible_dom || !tab.dom_cua?.click) {
719
+ await fallbackLocator.click({});
720
+ return;
721
+ }
722
+ const visibleDom = String(await tab.dom_cua.get_visible_dom());
723
+ const labelPattern = actionLabels
724
+ .map((label) => label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
725
+ .join('|');
726
+ const matches = Array.from(visibleDom.matchAll(
727
+ new RegExp(`<button\\s+[^>]*node_id=["']?([^\\s"'>]+)["']?[^>]*>(?:(?!</button>)[\\s\\S])*(?:${labelPattern})(?:(?!</button>)[\\s\\S])*</button>`, 'g'),
728
+ ));
729
+ if (matches.length !== 1) throw new Error(`identity_visible_action_count_${matches.length}`);
730
+ await tab.dom_cua.click({ node_id: matches[0][1] });
731
+ }
732
+
612
733
  async function clickMock(tab, request, labels, actions, onMutationAttempt = async () => undefined) {
613
734
  await navigateAndWait(
614
735
  tab,
@@ -622,7 +743,7 @@ async function clickMock(tab, request, labels, actions, onMutationAttempt = asyn
622
743
  'identity_user_search',
623
744
  );
624
745
  actions.push(`search target user name and verify exact id ${request.target_user_id}`);
625
- const { simulation, targetName } = await waitForExactTargetAction(tab, search, request, labels, actions);
746
+ let { simulation, targetName } = await waitForExactTargetAction(tab, search, request, labels, actions);
626
747
  const simulationCount = await simulation.count();
627
748
  if (simulationCount !== 1) throw new Error(`identity_exact_simulation_button_count_${simulationCount}`);
628
749
  if (typeof simulation.isVisible === 'function' && !await simulation.isVisible()) {
@@ -632,14 +753,18 @@ async function clickMock(tab, request, labels, actions, onMutationAttempt = asyn
632
753
  throw new Error('identity_exact_simulation_button_disabled');
633
754
  }
634
755
  await dismissGuideBeforeMutation(tab, actions);
756
+ const beforeTrial = await resolveExactTargetAction(tab, request, labels, 1_000);
757
+ if (!beforeTrial.resolved) throw new Error('identity_exact_user_row_changed_before_click');
758
+ simulation = beforeTrial.resolved.simulation;
759
+ targetName = beforeTrial.resolved.targetName;
635
760
  await simulation.click({ trial: true });
636
761
  actions.push(`verify simulation action is clickable for exact user id ${request.target_user_id}`);
762
+ const beforeMutation = await resolveExactTargetAction(tab, request, labels, 1_000);
763
+ if (!beforeMutation.resolved) throw new Error('identity_exact_user_row_changed_before_click');
764
+ simulation = beforeMutation.resolved.simulation;
765
+ targetName = beforeMutation.resolved.targetName;
637
766
  await onMutationAttempt();
638
- const managementUrl = await tab.url();
639
- await tab.playwright.expectNavigation(
640
- () => simulation.click({}),
641
- { url: managementUrl, waitUntil: 'domcontentloaded', timeoutMs: ROUTE_READY_TIMEOUT_MS },
642
- );
767
+ await clickUniqueVisibleAction(tab, labels.simulation, simulation);
643
768
  actions.push(`click simulation for exact user id ${request.target_user_id}`);
644
769
  await navigateAndWait(
645
770
  tab,
@@ -658,8 +783,8 @@ async function clickUnmock(tab, request, labels, actions, onMutationAttempt = as
658
783
  guide.locator('.guide-footer .action-item.log-out', {}),
659
784
  'identity_exit_simulation',
660
785
  );
661
- if ((await exit.innerText({})).trim() !== labels.exitSimulation) {
662
- throw new Error('identity_exit_simulation_label_mismatch');
786
+ if (!labels.exitSimulation.includes((await exit.innerText({})).trim())) {
787
+ throw new Error('identity_action_label_not_found');
663
788
  }
664
789
  await onMutationAttempt();
665
790
  await tab.playwright.expectNavigation(
@@ -4,6 +4,7 @@ description: "用于在 BPMAX 中创建、编辑、导出、验证或删除平
4
4
  ---
5
5
 
6
6
  # BPMAX Workspace Editor
7
+ - 若配置包含 icon,开始前先读取 `../bpmax-icon-catalog/SKILL.md`,通过 `bpmax-cli icon search/get/validate` 选择并校验,禁止猜名。
7
8
 
8
9
  ## 写入路径硬约束
9
10
  - 执行前必须先运行 `bpmax-cli config adapters --format json` 核对 `workspace`;只有 `export_status`、`build_status`、`submit_status`、`create_status`、`delete_status` 都是 `supported` 时,才允许进入真实写入。