@alipay/alipay-aipay 1.6.2-beta2 → 1.6.2-beta3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/alipay-aipay",
3
- "version": "1.6.2-beta2",
3
+ "version": "1.6.2-beta3",
4
4
  "description": "支付宝 AI 付 Skill 安装包 - 优先安装 Agent Skill,并在 macOS/Linux 后台准备用户级 CLI 工具",
5
5
  "type": "module",
6
6
  "bin": {
package/skill/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.2-beta2
1
+ 1.6.2-beta3
@@ -203,7 +203,7 @@ runner 失败时不得展示手写方案或进入步骤 3。成功时必须取
203
203
 
204
204
  - `full_process`:`../normal/full-process-routing.md` 已使用同一个 `integration.start.confirm`,在同一方案中绑定检查器产生的项目来源、代码状态和其他产品,以及产品、项目路径、语言/框架和服务声明;消息送达后已经直接进入本步骤,禁止再次渲染或要求确认。该消息不展示步骤清单,也不缩减执行范围;后续仍必须按当前产品完成本 flow 的全部适用接口、完成条件和 checklist。用户中断后若项目、产品、语言或框架发生变化,返回完整接入 router 重新澄清和扫描,再输出一条当前方案并继续。该方案仍禁止提前展示 MCC、授权范围、产品开通材料或 onboarding 待办。
205
205
 
206
- 方案送达后只通过上述 development loader 进入步骤 3;loader 仍在原位置记录兼容 stage `integration.user_confirmed` 和 `integration.pre_dev_reading.start`。前者表示已基于完整确定事实自动进入执行,不表示收到额外确认回复;不得另行执行 telemetry 命令或伪造用户回复。after-flow 从此后下一条用户消息开始;前置澄清、候选和方案只计 total。
206
+ 方案送达后只通过上述 development loader 进入步骤 3;loader 仍在原位置记录兼容 stage `integration.user_confirmed` 和 `integration.pre_dev_reading.start`。前者表示已基于完整确定事实自动进入执行并自动标记计数 flow start,不表示收到额外确认回复;不得另行执行 telemetry 命令或伪造用户回复。after-flow 从此后下一条用户消息开始;前置澄清、候选和方案只计 total。
207
207
 
208
208
  **方案后的上下文锁定**:已有项目保持步骤 1 前已经唯一解析的实际根目录和原有工程结构;新项目必须已经在步骤 1 前按用户明确选择的方式完成初始化并通过构建标识检查。此处不重复准备、初始化或探测项目。路径内容与步骤 1 成功时不一致则停止并重新澄清;只有目标项目或服务端语言变化时返回步骤 1,其他情况直接进入步骤 3。
209
209
 
@@ -554,20 +554,22 @@ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" integration-message saf
554
554
 
555
555
  <!-- ALIPAY_AIPAY_PRODUCT:aipay:START -->
556
556
  ```bash
557
- node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" integration-message checklist-result --variant AIPAY --project-path "$PROJECT_PATH" --scope-receipt "$CHECKLIST_SCOPE_RECEIPT" --overall-result "$OVERALL_RESULT" --failed-items "$FAILED_ITEMS" --manual-items "$MANUAL_ITEMS" --sandbox-result "$SANDBOX_RESULT" --sandbox-config-state "$SANDBOX_CONFIG_STATE" --blocking-defect-state "$BLOCKING_DEFECT_STATE" --execution-mode "$EXECUTION_MODE" --next-flow-reminder "$NEXT_FLOW_REMINDER" --user-input-count-total <total> --user-input-count-after-flow-start <afterFlowStart> --flow-start-observed <true|false>
557
+ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" integration-message checklist-result --variant AIPAY --project-path "$PROJECT_PATH" --scope-receipt "$CHECKLIST_SCOPE_RECEIPT" --overall-result "$OVERALL_RESULT" --failed-items "$FAILED_ITEMS" --manual-items "$MANUAL_ITEMS" --sandbox-result "$SANDBOX_RESULT" --sandbox-config-state "$SANDBOX_CONFIG_STATE" --blocking-defect-state "$BLOCKING_DEFECT_STATE" --execution-mode "$EXECUTION_MODE" --next-flow-reminder "$NEXT_FLOW_REMINDER"
558
558
  ```
559
559
  <!-- ALIPAY_AIPAY_PRODUCT:END -->
560
560
  <!-- ALIPAY_AIPAY_PRODUCT:webpay:START -->
561
561
  ```bash
562
- node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" integration-message checklist-result --variant WEBPAY --project-path "$PROJECT_PATH" --scope-receipt "$CHECKLIST_SCOPE_RECEIPT" --overall-result "$OVERALL_RESULT" --failed-items "$FAILED_ITEMS" --manual-items "$MANUAL_ITEMS" --webpay-experience-result "$WEBPAY_EXPERIENCE_RESULT" --sandbox-config-state "$SANDBOX_CONFIG_STATE" --blocking-defect-state "$BLOCKING_DEFECT_STATE" --execution-mode "$EXECUTION_MODE" --next-flow-reminder "$NEXT_FLOW_REMINDER" --user-input-count-total <total> --user-input-count-after-flow-start <afterFlowStart> --flow-start-observed <true|false>
562
+ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" integration-message checklist-result --variant WEBPAY --project-path "$PROJECT_PATH" --scope-receipt "$CHECKLIST_SCOPE_RECEIPT" --overall-result "$OVERALL_RESULT" --failed-items "$FAILED_ITEMS" --manual-items "$MANUAL_ITEMS" --webpay-experience-result "$WEBPAY_EXPERIENCE_RESULT" --sandbox-config-state "$SANDBOX_CONFIG_STATE" --blocking-defect-state "$BLOCKING_DEFECT_STATE" --execution-mode "$EXECUTION_MODE" --next-flow-reminder "$NEXT_FLOW_REMINDER"
563
563
  ```
564
564
  <!-- ALIPAY_AIPAY_PRODUCT:END -->
565
565
  <!-- ALIPAY_AIPAY_PRODUCT:apppay:START -->
566
566
  ```bash
567
- node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" integration-message checklist-result --variant APPPAY --project-path "$PROJECT_PATH" --scope-receipt "$CHECKLIST_SCOPE_RECEIPT" --overall-result "$OVERALL_RESULT" --failed-items "$FAILED_ITEMS" --manual-items "$MANUAL_ITEMS" --sandbox-config-state "$SANDBOX_CONFIG_STATE" --blocking-defect-state "$BLOCKING_DEFECT_STATE" --execution-mode "$EXECUTION_MODE" --next-flow-reminder "$NEXT_FLOW_REMINDER" --user-input-count-total <total> --user-input-count-after-flow-start <afterFlowStart> --flow-start-observed <true|false>
567
+ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" integration-message checklist-result --variant APPPAY --project-path "$PROJECT_PATH" --scope-receipt "$CHECKLIST_SCOPE_RECEIPT" --overall-result "$OVERALL_RESULT" --failed-items "$FAILED_ITEMS" --manual-items "$MANUAL_ITEMS" --sandbox-config-state "$SANDBOX_CONFIG_STATE" --blocking-defect-state "$BLOCKING_DEFECT_STATE" --execution-mode "$EXECUTION_MODE" --next-flow-reminder "$NEXT_FLOW_REMINDER"
568
568
  ```
569
569
  <!-- ALIPAY_AIPAY_PRODUCT:END -->
570
570
 
571
+ 用户输入计数默认由 telemetry run state 派生。只有本地计数状态不可用且已重新核对时,才在 checklist 命令末尾同时追加 `--user-input-count-total <total> --user-input-count-after-flow-start <afterFlowStart> --flow-start-observed <true|false>`;runner 会拒绝明显不合理计数。
572
+
571
573
  同一次代码开发流程只渲染一次最终 checklist 结果;renderer stdout 是本次默认收口的唯一对客正文,禁止在前后追加风险说明、通过项摘要、执行说明、衔接提醒或第二份待办。
572
574
 
573
575
  这些产品专属字段只用于 renderer 校验最终结论,不在 checklist 对客结果中重复展示。APP 支付未来沙箱测试对客引导的维护 TODO 只保留在消息目录对应变体,不得渲染给用户;补充时必须同步本 flow、`modules/checklist.md` 和测试。
@@ -7,7 +7,7 @@ import { fileURLToPath } from 'node:url';
7
7
 
8
8
  import { checklistForProduct } from './checklist_sections.mjs';
9
9
  import { createChecklistScopeReceipt } from './integration_message_runner.mjs';
10
- import { emitStageMetricAsync } from './telemetry.mjs';
10
+ import { emitStageMetricAsync, markTelemetryFlowStart } from './telemetry.mjs';
11
11
 
12
12
  const scriptDir = path.dirname(fileURLToPath(import.meta.url));
13
13
  const referencesDir = path.resolve(scriptDir, '../..');
@@ -239,6 +239,9 @@ export function runFlowCli(argv = process.argv) {
239
239
  const phaseBlock = extractFlowBlock(source, phaseBlockName(flow, phase));
240
240
  for (const stage of stageDeclarations(phaseBlock, productType)) {
241
241
  emitStageMetricAsync(stage, { productType });
242
+ if (stage === 'integration.user_confirmed' || stage === 'onboarding.user_confirmed') {
243
+ markTelemetryFlowStart();
244
+ }
242
245
  }
243
246
  process.stdout.write(`${loadFlowBundle(flow, phase, { productType })}\n`);
244
247
  }
@@ -1357,7 +1357,11 @@ async function runChecklistResult(args) {
1357
1357
  }
1358
1358
  const rendered = renderMessage('integration.checklist.result', variant, input);
1359
1359
  if (input.executionMode === '仅代码开发') {
1360
- emitTerminalMetric({ rootIntent: 'integration_only', productType: variant, ...terminalMetricContextFromArgs(args) });
1360
+ emitTerminalMetric({
1361
+ rootIntent: 'integration_only',
1362
+ productType: variant,
1363
+ ...terminalMetricContextFromArgs(args, { rootIntent: 'integration_only' })
1364
+ });
1361
1365
  }
1362
1366
  return rendered;
1363
1367
  }
@@ -751,7 +751,11 @@ function closeoutInputFromArgs(args) {
751
751
  async function runCloseout(args) {
752
752
  const variables = closeoutInputFromArgs(args);
753
753
  const rendered = renderMessage('process.partial_result', 'DEFAULT', variables);
754
- emitTerminalMetric({ productName: variables.productName, ...terminalMetricContextFromArgs(args) });
754
+ emitTerminalMetric({
755
+ productName: variables.productName,
756
+ rootIntent: args['root-intent'],
757
+ ...terminalMetricContextFromArgs(args, { rootIntent: args['root-intent'] })
758
+ });
755
759
  return rendered;
756
760
  }
757
761
 
@@ -19,12 +19,34 @@ const syncLogMsg = 'alipay_aipay_skill_event';
19
19
  const syncLogYuyanID = '180020010001290755';
20
20
  const uploadTimeoutMs = 2500;
21
21
  const terminalForegroundUploadTimeoutMs = 1200;
22
+ const terminalForegroundUploadMaxAttempts = 2;
23
+ const terminalForegroundUploadRetryDelayMs = 300;
24
+ const terminalBackgroundRetryDelayMs = 1000;
25
+ const terminalCountArgNames = Object.freeze([
26
+ 'user-input-count-total',
27
+ 'user-input-count-after-flow-start',
28
+ 'flow-start-observed'
29
+ ]);
22
30
  const outboxFlushLimit = 50;
23
31
  const outboxClaimTtlMs = 5 * 60 * 1000;
24
32
  const outboxMaxRecords = 1000;
25
33
  const outboxMaxAgeMs = 7 * 24 * 60 * 60 * 1000;
26
34
  const permissionedFlushTtlMs = 12 * 60 * 60 * 1000;
27
35
  const platformProjectIdEnvKeys = Object.freeze(['COZE_PROJECT_ID', 'MEOO_PROJECT_ID']);
36
+ const sessionStateEnvKeys = Object.freeze([
37
+ 'CODEX_THREAD_ID',
38
+ 'CODEX_SESSION_ID',
39
+ 'CLAUDE_CODE_SESSION_ID',
40
+ 'OPENCLAW_SESSION_ID',
41
+ 'CURSOR_SESSION_ID',
42
+ 'CURSOR_TRACE_ID',
43
+ 'COZE_SESSION_ID',
44
+ 'COZE_CONVERSATION_ID',
45
+ 'HERMES_SESSION_ID',
46
+ 'OPENAI_CONVERSATION_ID',
47
+ 'SESSION_ID',
48
+ 'CI_JOB_ID'
49
+ ]);
28
50
  const permissionedFlushNetworkErrors = new Set([
29
51
  'ENOTFOUND',
30
52
  'EAI_AGAIN',
@@ -170,28 +192,20 @@ function isMaintenanceProcess(env = process.env, argv = process.argv) {
170
192
  return argv.some((arg) => /(^|[/\\])test[/\\].+\.test\.mjs$/u.test(String(arg || '')));
171
193
  }
172
194
 
173
- function stableStateKey(env = process.env) {
174
- const source =
175
- env.ALIPAY_AIPAY_SESSION_ID ||
176
- platformProjectRunId(env) ||
177
- env.CODEX_THREAD_ID ||
178
- env.CODEX_SESSION_ID ||
179
- env.CLAUDE_CODE_SESSION_ID ||
180
- env.OPENCLAW_SESSION_ID ||
181
- env.CURSOR_SESSION_ID ||
182
- env.CURSOR_TRACE_ID ||
183
- env.COZE_SESSION_ID ||
184
- env.COZE_CONVERSATION_ID ||
185
- env.HERMES_SESSION_ID ||
186
- env.OPENAI_CONVERSATION_ID ||
187
- env.SESSION_ID ||
188
- env.CI_JOB_ID ||
189
- '';
195
+ function stableStateSource(env = process.env) {
196
+ return env.ALIPAY_AIPAY_SESSION_ID || platformProjectRunId(env) || sessionStateEnvKeys.map((key) => env[key]).find(Boolean) || '';
197
+ }
198
+
199
+ function stateKeyFromSource(source) {
190
200
  if (!source) return 'default';
191
201
  if (safeText(source) && source.length <= 128) return source;
192
202
  return `key-${crypto.createHash('sha256').update(source).digest('hex')}`;
193
203
  }
194
204
 
205
+ function stableStateKey(env = process.env) {
206
+ return stateKeyFromSource(stableStateSource(env));
207
+ }
208
+
195
209
  function stateDir(env = process.env) {
196
210
  if (env.ALIPAY_AIPAY_TELEMETRY_DIR) return env.ALIPAY_AIPAY_TELEMETRY_DIR;
197
211
  return telemetryRoot();
@@ -216,7 +230,8 @@ function permissionedFlushStatePath(env = process.env) {
216
230
  if (env.ALIPAY_AIPAY_TELEMETRY_PERMISSIONED_FLUSH_STATE_FILE) {
217
231
  return env.ALIPAY_AIPAY_TELEMETRY_PERMISSIONED_FLUSH_STATE_FILE;
218
232
  }
219
- return path.join(stateDir(env), `${stableStateKey(env)}.permissioned-flush.json`);
233
+ const source = stableStateSource(env) || (Object.keys(env).length > 0 ? readRunState(env)?.run_id : '') || '';
234
+ return path.join(stateDir(env), `${stateKeyFromSource(source)}.permissioned-flush.json`);
220
235
  }
221
236
 
222
237
  export function telemetryStoragePaths(env = process.env) {
@@ -385,6 +400,13 @@ function parseNonNegativeInteger(value) {
385
400
  return Number.isSafeInteger(parsed) ? parsed : null;
386
401
  }
387
402
 
403
+ function sleepSync(ms) {
404
+ if (!Number.isFinite(ms) || ms <= 0) return;
405
+ try {
406
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, Math.min(ms, 30000));
407
+ } catch {}
408
+ }
409
+
388
410
  function parseBooleanFlag(value) {
389
411
  if (typeof value === 'boolean') return value;
390
412
  if (typeof value !== 'string') return null;
@@ -394,23 +416,60 @@ function parseBooleanFlag(value) {
394
416
  return null;
395
417
  }
396
418
 
397
- function terminalExtInfoFromPayload(payload = {}, env = process.env) {
398
- if (!payload || typeof payload !== 'object' || Array.isArray(payload)) return '';
419
+ function normalizeUserInputCounts(value) {
420
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
421
+ return { total: 0, after_flow_start: 0, flow_start_observed: false };
422
+ }
423
+ const total = parseNonNegativeInteger(value.total ?? value.user_input_count_total);
424
+ const afterFlowStart = parseNonNegativeInteger(value.after_flow_start ?? value.user_input_count_after_flow_start);
425
+ const flowStartObserved = parseBooleanFlag(value.flow_start_observed);
426
+ if (total === null || afterFlowStart === null || flowStartObserved === null) {
427
+ return { total: 0, after_flow_start: 0, flow_start_observed: false };
428
+ }
429
+ return {
430
+ total,
431
+ after_flow_start: Math.min(afterFlowStart, total),
432
+ flow_start_observed: flowStartObserved,
433
+ flow_start_observed_at: parseNonNegativeInteger(value.flow_start_observed_at) || undefined,
434
+ updated_at: parseNonNegativeInteger(value.updated_at) || undefined
435
+ };
436
+ }
437
+
438
+ function validateTerminalCountPayload(payload = {}, env = process.env, { strict = false } = {}) {
439
+ const fail = (message) => {
440
+ if (strict) throw new Error(message);
441
+ return null;
442
+ };
399
443
  const total = parseNonNegativeInteger(payload.userInputCountTotal ?? payload.user_input_count_total);
400
444
  const afterFlowStart = parseNonNegativeInteger(
401
445
  payload.userInputCountAfterFlowStart ?? payload.user_input_count_after_flow_start
402
446
  );
403
447
  const flowStartObserved = parseBooleanFlag(payload.flowStartObserved ?? payload.flow_start_observed);
404
448
  const rootIntent = rootIntentFrom(payload, env);
405
- if (total === null || afterFlowStart === null || flowStartObserved === null) return '';
406
- if (!rootIntent) return '';
407
- if (afterFlowStart > total) return '';
408
- if (!flowStartObserved && afterFlowStart !== 0) return '';
449
+ if (total === null || afterFlowStart === null || flowStartObserved === null) {
450
+ return fail('终态用户输入计数必须是合法非负整数,flow-start-observed 必须是 true/false');
451
+ }
452
+ if (total < 1) return fail('终态 user_input_count_total 必须至少包含触发当前 run 的用户输入');
453
+ if (!rootIntent) return fail('终态用户输入计数缺少合法 root_intent');
454
+ if (afterFlowStart > total) return fail('终态 user_input_count_after_flow_start 不能大于 user_input_count_total');
455
+ if (flowStartObserved && afterFlowStart >= total) {
456
+ return fail('终态 flow start 已观测时,after-flow 用户输入数必须小于 total;请重新核对 before-flow/after-flow 分界');
457
+ }
458
+ if (!flowStartObserved && afterFlowStart !== 0) {
459
+ return fail('终态 flow start 未观测时,after-flow 用户输入数必须为 0');
460
+ }
461
+ return { total, afterFlowStart, flowStartObserved, rootIntent };
462
+ }
463
+
464
+ function terminalExtInfoFromPayload(payload = {}, env = process.env) {
465
+ if (!payload || typeof payload !== 'object' || Array.isArray(payload)) return '';
466
+ const counts = validateTerminalCountPayload(payload, env);
467
+ if (!counts) return '';
409
468
  return JSON.stringify({
410
- user_input_count_total: total,
411
- user_input_count_after_flow_start: afterFlowStart,
412
- flow_start_observed: flowStartObserved,
413
- root_intent: rootIntent
469
+ user_input_count_total: counts.total,
470
+ user_input_count_after_flow_start: counts.afterFlowStart,
471
+ flow_start_observed: counts.flowStartObserved,
472
+ root_intent: counts.rootIntent
414
473
  });
415
474
  }
416
475
 
@@ -568,15 +627,41 @@ function parseCliArgs(argv) {
568
627
  return { command, args };
569
628
  }
570
629
 
571
- export function terminalMetricContextFromArgs(args) {
630
+ export function terminalMetricContextFromArgs(args, context = {}) {
572
631
  const optional = (name) => {
573
632
  const value = args[name];
574
633
  return typeof value === 'string' && value.length > 0 ? value : undefined;
575
634
  };
635
+ const hasCountArg = terminalCountArgNames.some((name) => Object.prototype.hasOwnProperty.call(args, name));
636
+ if (hasCountArg) {
637
+ const missing = terminalCountArgNames.filter((name) => optional(name) === undefined);
638
+ if (missing.length > 0) throw new Error(`终态用户输入计数参数必须同时提供,缺少 --${missing[0]}`);
639
+ const counts = validateTerminalCountPayload({
640
+ userInputCountTotal: optional('user-input-count-total'),
641
+ userInputCountAfterFlowStart: optional('user-input-count-after-flow-start'),
642
+ flowStartObserved: optional('flow-start-observed'),
643
+ rootIntent: args['root-intent'] || args.rootIntent || args.root_intent || context.rootIntent || context.root_intent
644
+ }, process.env, { strict: true });
645
+ return {
646
+ userInputCountTotal: counts.total,
647
+ userInputCountAfterFlowStart: counts.afterFlowStart,
648
+ flowStartObserved: counts.flowStartObserved
649
+ };
650
+ }
651
+ const state = readRunState(process.env);
652
+ const stored = normalizeUserInputCounts(state?.user_input_counts);
653
+ if (stored.total < 1) return {};
654
+ const counts = validateTerminalCountPayload({
655
+ userInputCountTotal: stored.total,
656
+ userInputCountAfterFlowStart: stored.after_flow_start,
657
+ flowStartObserved: stored.flow_start_observed,
658
+ rootIntent: state?.root_intent
659
+ }, process.env);
660
+ if (!counts) return {};
576
661
  return {
577
- userInputCountTotal: optional('user-input-count-total'),
578
- userInputCountAfterFlowStart: optional('user-input-count-after-flow-start'),
579
- flowStartObserved: optional('flow-start-observed')
662
+ userInputCountTotal: counts.total,
663
+ userInputCountAfterFlowStart: counts.afterFlowStart,
664
+ flowStartObserved: counts.flowStartObserved
580
665
  };
581
666
  }
582
667
 
@@ -665,9 +750,26 @@ function createOrReuseRunState(args, env = process.env, nowMs = Date.now()) {
665
750
  return createRunState(args, env, nowMs);
666
751
  }
667
752
 
753
+ function flowStartStage(stage) {
754
+ return stage === 'integration.user_confirmed' || stage === 'onboarding.user_confirmed';
755
+ }
756
+
757
+ function withFlowStartObserved(state, nowMs = Date.now()) {
758
+ const counts = normalizeUserInputCounts(state.user_input_counts);
759
+ return {
760
+ ...state,
761
+ user_input_counts: {
762
+ ...counts,
763
+ flow_start_observed: true,
764
+ flow_start_observed_at: counts.flow_start_observed_at || nowMs,
765
+ updated_at: nowMs
766
+ }
767
+ };
768
+ }
769
+
668
770
  function updateRunStateFromEvent(event, env = process.env) {
669
771
  const existing = readRunState(env) || {};
670
- const next = {
772
+ let next = {
671
773
  ...existing,
672
774
  schema_ver: 1,
673
775
  run_id: event.run_id,
@@ -676,6 +778,9 @@ function updateRunStateFromEvent(event, env = process.env) {
676
778
  created_at: existing.created_at || Date.now(),
677
779
  updated_at: Date.now()
678
780
  };
781
+ if (flowStartStage(event.stage)) {
782
+ next = withFlowStartObserved(next, Number.isFinite(Number(event.timestamp)) ? Number(event.timestamp) : Date.now());
783
+ }
679
784
  if (event.stage === 'run.terminal') {
680
785
  next.terminal = true;
681
786
  next.terminal_at = Number.isFinite(Number(event.timestamp)) ? Number(event.timestamp) : Date.now();
@@ -686,6 +791,46 @@ function updateRunStateFromEvent(event, env = process.env) {
686
791
  writeRunState(next, env);
687
792
  }
688
793
 
794
+ export function markTelemetryFlowStart(env = process.env, nowMs = Date.now()) {
795
+ if (!telemetryEnabled(env)) return null;
796
+ const existing = readRunState(env);
797
+ if (!existing?.run_id || existing.terminal) return null;
798
+ const next = withFlowStartObserved({
799
+ ...existing,
800
+ updated_at: nowMs
801
+ }, nowMs);
802
+ writeRunState(next, env);
803
+ return next.user_input_counts;
804
+ }
805
+
806
+ export function recordTelemetryUserInput(phase, env = process.env, nowMs = Date.now()) {
807
+ if (!telemetryEnabled(env)) return null;
808
+ if (!['before-flow', 'after-flow'].includes(phase)) {
809
+ throw new Error('--phase 仅支持 before-flow、after-flow');
810
+ }
811
+ const existing = readRunState(env);
812
+ if (!existing?.run_id || existing.terminal) return null;
813
+ const counts = normalizeUserInputCounts(existing.user_input_counts);
814
+ if (phase === 'before-flow' && counts.flow_start_observed) {
815
+ throw new Error('当前 run 已观测 flow start,后续用户输入必须记录为 after-flow');
816
+ }
817
+ const nextCounts = {
818
+ ...counts,
819
+ total: counts.total + 1,
820
+ after_flow_start: counts.after_flow_start + (phase === 'after-flow' ? 1 : 0),
821
+ flow_start_observed: counts.flow_start_observed || phase === 'after-flow',
822
+ updated_at: nowMs
823
+ };
824
+ if (phase === 'after-flow' && !counts.flow_start_observed) nextCounts.flow_start_observed_at = nowMs;
825
+ const next = {
826
+ ...existing,
827
+ user_input_counts: nextCounts,
828
+ updated_at: nowMs
829
+ };
830
+ writeRunState(next, env);
831
+ return nextCounts;
832
+ }
833
+
689
834
  function updateExistingRunStateFromEvent(event, env = process.env) {
690
835
  const existing = readRunState(env);
691
836
  if (!existing) return false;
@@ -1098,6 +1243,17 @@ function releaseOutboxClaim(claimedPath) {
1098
1243
  }
1099
1244
  }
1100
1245
 
1246
+ function outboxTargetFilePending(file) {
1247
+ try {
1248
+ if (fs.existsSync(file)) return true;
1249
+ const dir = path.dirname(file);
1250
+ const prefix = `${path.basename(file)}.sending.`;
1251
+ return fs.readdirSync(dir).some((name) => name.startsWith(prefix));
1252
+ } catch {
1253
+ return false;
1254
+ }
1255
+ }
1256
+
1101
1257
  function readOutboxRecord(file) {
1102
1258
  try {
1103
1259
  const record = JSON.parse(fs.readFileSync(file, 'utf8'));
@@ -1257,16 +1413,18 @@ export async function flushOutbox(env = process.env, {
1257
1413
  return result;
1258
1414
  }
1259
1415
 
1260
- function spawnOutboxFlush(env = process.env) {
1416
+ function spawnOutboxFlush(env = process.env, { delayMs = 0 } = {}) {
1261
1417
  if (!telemetryUploadEnabled(env)) return false;
1262
1418
  try {
1419
+ const childEnv = {
1420
+ ...env,
1421
+ ALIPAY_AIPAY_TELEMETRY_UPLOAD_TIMEOUT_MS: env.ALIPAY_AIPAY_TELEMETRY_UPLOAD_TIMEOUT_MS || String(uploadTimeoutMs)
1422
+ };
1423
+ if (delayMs > 0) childEnv.ALIPAY_AIPAY_TELEMETRY_FLUSH_DELAY_MS = String(Math.min(delayMs, 30000));
1263
1424
  const child = spawn(process.execPath, [scriptPath(), 'flush-outbox-worker'], {
1264
1425
  detached: true,
1265
1426
  stdio: 'ignore',
1266
- env: {
1267
- ...env,
1268
- ALIPAY_AIPAY_TELEMETRY_UPLOAD_TIMEOUT_MS: env.ALIPAY_AIPAY_TELEMETRY_UPLOAD_TIMEOUT_MS || String(uploadTimeoutMs)
1269
- }
1427
+ env: childEnv
1270
1428
  });
1271
1429
  child.on('error', (error) => {
1272
1430
  writeUploadStatus({
@@ -1291,25 +1449,34 @@ function foregroundFlushTerminalOutboxFile(file, env = process.env) {
1291
1449
  if (!telemetryUploadEnabled(env) || !file) return false;
1292
1450
  const parsed = parseNonNegativeInteger(env.ALIPAY_AIPAY_TELEMETRY_TERMINAL_FLUSH_TIMEOUT_MS);
1293
1451
  const timeoutMs = parsed && parsed > 0 ? Math.min(parsed, 30000) : terminalForegroundUploadTimeoutMs;
1294
- try {
1295
- execFileSync(process.execPath, [scriptPath(), 'flush-outbox-worker'], {
1296
- stdio: 'ignore',
1297
- timeout: timeoutMs + 800,
1298
- env: {
1299
- ...env,
1300
- ALIPAY_AIPAY_TELEMETRY_UPLOAD_TIMEOUT_MS: String(timeoutMs),
1301
- ALIPAY_AIPAY_TELEMETRY_FLUSH_TARGET_FILE: file
1302
- }
1303
- });
1304
- return true;
1305
- } catch (error) {
1306
- writeUploadStatus({
1307
- status: 'failed',
1308
- error_code: safeDimension(error?.code || error?.signal || error?.name || 'TERMINAL_FLUSH_FAILED', 'TERMINAL_FLUSH_FAILED', 80),
1309
- error_message: 'terminal flush failed'
1310
- }, env);
1311
- return false;
1452
+ const parsedAttempts = parseNonNegativeInteger(env.ALIPAY_AIPAY_TELEMETRY_TERMINAL_FLUSH_ATTEMPTS);
1453
+ const attempts = parsedAttempts && parsedAttempts > 0
1454
+ ? Math.min(parsedAttempts, 3)
1455
+ : terminalForegroundUploadMaxAttempts;
1456
+ for (let attempt = 1; attempt <= attempts; attempt += 1) {
1457
+ try {
1458
+ execFileSync(process.execPath, [scriptPath(), 'flush-outbox-worker'], {
1459
+ stdio: 'ignore',
1460
+ timeout: timeoutMs + 800,
1461
+ env: {
1462
+ ...env,
1463
+ ALIPAY_AIPAY_TELEMETRY_UPLOAD_TIMEOUT_MS: String(timeoutMs),
1464
+ ALIPAY_AIPAY_TELEMETRY_FLUSH_TARGET_FILE: file
1465
+ }
1466
+ });
1467
+ } catch (error) {
1468
+ writeUploadStatus({
1469
+ status: 'failed',
1470
+ error_code: safeDimension(error?.code || error?.signal || error?.name || 'TERMINAL_FLUSH_FAILED', 'TERMINAL_FLUSH_FAILED', 80),
1471
+ error_message: 'terminal flush failed'
1472
+ }, env);
1473
+ }
1474
+ if (!outboxTargetFilePending(file)) return true;
1475
+ const retryable = Boolean(networkUploadFailure(readUploadStatus(env)));
1476
+ if (!retryable || attempt >= attempts) return false;
1477
+ sleepSync(terminalForegroundUploadRetryDelayMs);
1312
1478
  }
1479
+ return !outboxTargetFilePending(file);
1313
1480
  }
1314
1481
 
1315
1482
  function scheduleSyncLogUpload(event, env = process.env) {
@@ -1320,7 +1487,9 @@ function scheduleSyncLogUpload(event, env = process.env) {
1320
1487
  return false;
1321
1488
  }
1322
1489
  if (event?.stage === 'run.terminal') {
1323
- foregroundFlushTerminalOutboxFile(queuedFile, env);
1490
+ if (!foregroundFlushTerminalOutboxFile(queuedFile, env)) {
1491
+ spawnOutboxFlush(env, { delayMs: terminalBackgroundRetryDelayMs });
1492
+ }
1324
1493
  return true;
1325
1494
  }
1326
1495
  return spawnOutboxFlush(env);
@@ -1363,6 +1532,26 @@ export async function runTelemetryCli(argv = process.argv) {
1363
1532
  }
1364
1533
  return 0;
1365
1534
  }
1535
+ if (command === 'count-user-input' && args._.length === 0) {
1536
+ assertCliArgs(args, new Set(['phase']), 0);
1537
+ const counts = recordTelemetryUserInput(args.phase, process.env, Date.now());
1538
+ if (counts) {
1539
+ process.stderr.write(`${internalPrefix}USER_INPUT_COUNT_STATE=${JSON.stringify(counts)}\n`);
1540
+ } else {
1541
+ process.stderr.write(`${internalPrefix}USER_INPUT_COUNT_STATE_MISSING=true\n`);
1542
+ }
1543
+ return 0;
1544
+ }
1545
+ if (command === 'mark-flow-start' && args._.length === 0) {
1546
+ assertCliArgs(args, new Set(), 0);
1547
+ const counts = markTelemetryFlowStart(process.env, Date.now());
1548
+ if (counts) {
1549
+ process.stderr.write(`${internalPrefix}USER_INPUT_FLOW_START_STATE=${JSON.stringify(counts)}\n`);
1550
+ } else {
1551
+ process.stderr.write(`${internalPrefix}USER_INPUT_FLOW_START_STATE_MISSING=true\n`);
1552
+ }
1553
+ return 0;
1554
+ }
1366
1555
  if (command === 'upload-status' && args._.length === 0) {
1367
1556
  assertCliArgs(args, new Set(), 0);
1368
1557
  const status = readUploadStatus(process.env) || { schema_ver: 1, status: 'unknown' };
@@ -1397,6 +1586,8 @@ export async function runTelemetryCli(argv = process.argv) {
1397
1586
  assertCliArgs(args, new Set(), 0);
1398
1587
  if (!telemetryEnabled(process.env)) return 0;
1399
1588
  const timeout = Number(process.env.ALIPAY_AIPAY_TELEMETRY_UPLOAD_TIMEOUT_MS || uploadTimeoutMs);
1589
+ const delay = parseNonNegativeInteger(process.env.ALIPAY_AIPAY_TELEMETRY_FLUSH_DELAY_MS);
1590
+ if (delay && delay > 0) sleepSync(Math.min(delay, 30000));
1400
1591
  await flushOutbox(process.env, {
1401
1592
  targetFile: process.env.ALIPAY_AIPAY_TELEMETRY_FLUSH_TARGET_FILE || '',
1402
1593
  timeoutMs: Number.isFinite(timeout) ? timeout : uploadTimeoutMs
@@ -1,4 +1,4 @@
1
- - 字段/测试白名单:stage/flow、产品、根意图、时间戳、Skill 版本、宿主/模型、匿名机器哈希、`run_id`、终态计数;禁密钥、账号密码、订单/交易号、截图/凭证、用户输入、路径/URL、响应、命令输出、堆栈原文。失败不影响业务;内部行 `ALIPAY_AIPAY_INTERNAL:`。
2
- - run:`start-run` 创建/复用 `run_id`,脚本继承 `PLATFORM_ID=<run_id>`;`root_intent + product_type` 判定复用/新建,`UNKNOWN` 补全产品仍复用同一 `run_id`;换产品/根意图/已终态/重新开始/重新走流程/作废本轮流程才新建。第三方 ID(`COZE_PROJECT_ID`、`MEOO_PROJECT_ID`、`VITE_APP_ID`/`PLATFORM_ID`)优先;`current-run-id` 只查看,不新建 run。outbox 落盘,collector 2xx 才删;维护/测试/Benchmark 禁上传。
3
- - 计数:`user_input_count_total` 自触发当前 run 的用户消息起;`user_input_count_after_flow_start` 自方案送达并进入正式执行后的下一条用户消息起。产品/MCC 澄清或选择、项目/语言/框架补齐、项目候选和方案本身只计 total;`full_process` 不因 Onboarding 重置。`flow_start_observed` 表示正式 flow start;用户 kill 未终态不补报。终态只追加计数,不新增确认点、stage 或独立上报。`run.terminal` 入队后以短超时前台 drain,仅当前 terminal 文件,避免流程最后的 detached worker 被宿主回收,不申请额外权限;失败仍保留 outbox。`c4=ext_info`,计数合法且有 `root_intent` 才写 JSON。
4
- - 补传:不为权限探测新增网络事件;实际低敏上传就是自然探测,宿主已允许访问 collector 时不额外申请权限。`upload-status`/`permissioned-flush-status` 只读;后者输出 `PERMISSIONED_FLUSH_CANDIDATE=true`(最近 `ENOTFOUND|EAI_AGAIN|ETIMEDOUT`、outbox 积压、12h 未请求)后执行 `permissioned-flush-needed` 预占窗口。唯一 `PERMISSIONED_FLUSH_NEEDED=true` 时才申请 `telemetry flush-outbox`;`flush-outbox` 后台补传:POST `https://collect.alipay.com/yuyan/`(`collect.alipay.com:443`,路径 `/yuyan/`)。说明:`是否允许 Agent 上报 Skill 使用过程的统计信息?只含产品类别、时间、Skill 版本、匿名设备标识、人机交互次数等用于帮助改善用户体验的非敏感信息,不会采集包含源代码、用户输入内容等任何敏感信息。` 同一 Agent 会话只请求一次;拒绝/失败/非 2xx 保留 outbox;collector 结果非业务条件;无 `inspect-outbox`、`--confirm-reviewed`、`alipay-cli whoami` 兜底。
1
+ - 测试白名单:stage/flow、产品、根意图、时间戳、Skill 版本、宿主/模型、匿名机器哈希、`run_id`、终态计数;禁密钥/账号密码/订单/交易号/截图/凭证/用户输入/路径/URL/响应/命令输出/堆栈原文;失败不影响业务,内部行 `ALIPAY_AIPAY_INTERNAL:`。
2
+ - run:`start-run` 创建/复用 `run_id`,脚本继承 `PLATFORM_ID=<run_id>`;`root_intent + product_type` 判定复用/新建,`UNKNOWN` 补全产品仍复用同一 `run_id`;换产品/根意图/已终态/重新开始/重新走流程/作废本轮流程才新建。`COZE_PROJECT_ID`、`MEOO_PROJECT_ID`、`VITE_APP_ID`/`PLATFORM_ID` 优先;`current-run-id` 只查看,不新建 run。outbox 2xx 才删;维护/测试/Benchmark 禁上传。
3
+ - 计数:每条用户输入到达当前 run 后立刻执行 `telemetry count-user-input --phase before-flow|after-flow` 写本地 run state,不联网;触发 run 的首条消息计 before-flow。`user_input_count_total` 自触发 run 用户消息起;`user_input_count_after_flow_start` 自方案送达并进入正式执行后的下一条用户消息起。产品/MCC 澄清或选择、项目/语言/框架补齐、项目候选和方案本身只计 total;`full_process` 不因 Onboarding 重置。`flow_start_observed`=正式 flow start,由 `integration.user_confirmed|onboarding.user_confirmed` 自动标记;用户 kill 未终态不补报。closeout 默认派生本地计数,状态不可用且已核对时才显式传三项;runner 拒绝缺项、负数、`after > total`、已观测 flow start 但 `after >= total`。终态只追加计数,不新增确认点、stage 或独立上报。`run.terminal` 入队后以短超时前台 drain,仅当前 terminal 文件,避免流程最后的 detached worker 被宿主回收;若文件仍在且是网络类错误,短重试一次并挂延迟后台补传,不申请额外权限;失败保留 outbox。`c4=ext_info`,计数合法且有 `root_intent` 才写 JSON。
4
+ - 补传:不为权限探测新增网络事件;实际低敏上传就是自然探测,宿主已允许访问 collector 时不额外申请权限。`upload-status`/`permissioned-flush-status` 不联网、不消耗请求窗口;后者在最近 `ENOTFOUND|EAI_AGAIN|ETIMEDOUT`、outbox 积压、12h 未请求时出 `PERMISSIONED_FLUSH_CANDIDATE=true`,再执行 `permissioned-flush-needed` 预占;唯一 `PERMISSIONED_FLUSH_NEEDED=true` 时才申请。`flush-outbox` 后台补传:POST 到 `collect.alipay.com:443`,路径 `/yuyan/`。说明:`是否允许 Agent 上报 Skill 使用过程的统计信息?只含产品类别、时间、Skill 版本、匿名设备标识、人机交互次数等用于帮助改善用户体验的非敏感信息,不会采集包含源代码、用户输入内容等任何敏感信息。` 同一 Agent 会话只请求一次;无宿主标识时按当前 `run_id` 隔离 12h;拒绝/失败/非2xx留 outbox;collector 结果非业务条件;无 `inspect-outbox`、`--confirm-reviewed`、`alipay-cli whoami` 兜底。
@@ -59,7 +59,7 @@ Step 1: 方案规划 → Step 2: 环境检查 → Step 3: 登录授权
59
59
  环境检查、产品/MCC 澄清或方案展示前先执行平台入口。`onboarding_only` 正常由 `onboarding-bootstrap --root-intent onboarding_only` 包含本动作和 entry 加载;仅原子 fallback 或 `full_process` 衔接时执行:
60
60
 
61
61
  ```bash
62
- node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-message platform-entry --user-input-count-total <total> --user-input-count-after-flow-start <afterFlowStart> --flow-start-observed <true|false>
62
+ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-message platform-entry
63
63
  ```
64
64
 
65
65
  - Windows:runner 从私有 run context 取 `run_id` 生成 `platform_id`,禁止 Agent 传入或拼接;消息渲染即终结 run,送达唯一 stdout 后停止 Onboarding;`full_process` 保留 Integration 结果。
@@ -68,7 +68,7 @@ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-message plat
68
68
  用户明确要用企业账号通过 Skill 开通时执行下列消息并停止 Onboarding;不得主动询问账号类型,也不得从 MCC、营业执照或“公司”等描述推断。
69
69
 
70
70
  ```bash
71
- node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-message enterprise-unsupported --variant <ONBOARDING_ONLY|FULL_PROCESS> --user-input-count-total <total> --user-input-count-after-flow-start <afterFlowStart> --flow-start-observed <true|false>
71
+ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-message enterprise-unsupported --variant <ONBOARDING_ONLY|FULL_PROCESS>
72
72
  ```
73
73
 
74
74
  `onboarding_only` 固定 `ONBOARDING_ONLY`,`full_process` 固定 `FULL_PROCESS`。原文送达最终 stdout 后停止,不执行 Step 6 或追加收口。
@@ -121,7 +121,7 @@ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-message mcc-
121
121
 
122
122
  `salesCode`、`scope` 和材料要求只取“产品映射”。方案只由 `mcc-resolve-plan` 或已有唯一 MCC 时的 `onboarding-message plan-confirm` 生成,须展示产品/scope、MCC、条件材料、企业账号边界及商家平台链接;名称、编码和资质由同一表事实交叉校验,`-` 固定显示“当前类目参考表未列出”。禁止补充模板外资格或审核规则。
123
123
 
124
- 不得保留“先运行旧字符串搜索,无匹配后再临时让 Agent 猜”的两阶段流程,或重复询问已知信息。只有唯一事实通过机器校验、方案 marker 唯一且 stdout 已送达,才执行 `onboarding-execute-ready --product-type "$PRODUCT_TYPE"`;缺值、冲突或非唯一继续澄清。产品/MCC 变化时重新校验并渲染。execute loader 记录兼容 stage `onboarding.user_confirmed`,不代表新增用户回复,禁止手工上报。after-flow 从此后下一条用户消息开始;前置澄清、候选和方案只计 total。`full_process` 不在本阶段重置。
124
+ 不得保留“先运行旧字符串搜索,无匹配后再临时让 Agent 猜”的两阶段流程,或重复询问已知信息。只有唯一事实通过机器校验、方案 marker 唯一且 stdout 已送达,才执行 `onboarding-execute-ready --product-type "$PRODUCT_TYPE"`;缺值、冲突或非唯一继续澄清。产品/MCC 变化时重新校验并渲染。execute loader 记录兼容 stage `onboarding.user_confirmed` 并自动标记计数 flow start,不代表新增用户回复,禁止手工上报。after-flow 从此后下一条用户消息开始;前置澄清、候选和方案只计 total。`full_process` 不在本阶段重置。
125
125
 
126
126
  <!-- ALIPAY_AIPAY_FLOW:ONBOARDING_ENTRY:END -->
127
127
 
@@ -501,9 +501,11 @@ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-message appl
501
501
  `SIGNING_RESULT`、`SERVICE_RESULT`、`APPLICATION_RESULT` 和 `INTEGRATION_RESULT` 必须使用消息目录允许的状态枚举原文,禁止拼接 `appId`、公钥文件路径、错误码、截图证据或其他自由文本;支付宝公钥保存路径只允许在已取得唯一 `ALIPAY_PUBLIC_KEY_EXPORT_STATUS=EXPORTED` 和 `ALIPAY_PUBLIC_KEY_FILE` 时,通过 `APP_KEY_SAVE_PATH` 或 `APPLICATION_OPERATION_APP_KEY_SAVE_PATH` 独立传入结果 runner。这些证据不能污染分支结果枚举。
502
502
 
503
503
  ```bash
504
- node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-message closeout --product-type "$PRODUCT_TYPE" --root-intent "$ROOT_INTENT" --signing-result "$SIGNING_RESULT" --application-result "$APPLICATION_RESULT" --remaining-actions "$REMAINING_ACTIONS" [--integration-result "$INTEGRATION_RESULT"] [--service-result "$SERVICE_RESULT"] [--sandbox-config-state "$SANDBOX_CONFIG_STATE"] [--manual-verification-items "$MANUAL_VERIFICATION_ITEMS"] [--application-operation-app-id "$APPLICATION_OPERATION_APP_ID" [--application-operation-next-action "$APPLICATION_OPERATION_NEXT_ACTION"] [--application-operation-app-key-save-path "$APPLICATION_OPERATION_APP_KEY_SAVE_PATH"]] --user-input-count-total <total> --user-input-count-after-flow-start <afterFlowStart> --flow-start-observed <true|false>
504
+ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-message closeout --product-type "$PRODUCT_TYPE" --root-intent "$ROOT_INTENT" --signing-result "$SIGNING_RESULT" --application-result "$APPLICATION_RESULT" --remaining-actions "$REMAINING_ACTIONS" [--integration-result "$INTEGRATION_RESULT"] [--service-result "$SERVICE_RESULT"] [--sandbox-config-state "$SANDBOX_CONFIG_STATE"] [--manual-verification-items "$MANUAL_VERIFICATION_ITEMS"] [--application-operation-app-id "$APPLICATION_OPERATION_APP_ID" [--application-operation-next-action "$APPLICATION_OPERATION_NEXT_ACTION"] [--application-operation-app-key-save-path "$APPLICATION_OPERATION_APP_KEY_SAVE_PATH"]]
505
505
  ```
506
506
 
507
+ 用户输入计数默认由 telemetry run state 派生,不在 closeout 事后回溯。只有本地计数状态不可用且已重新核对时,才在 closeout 命令末尾同时追加 `--user-input-count-total <total> --user-input-count-after-flow-start <afterFlowStart> --flow-start-observed <true|false>`;runner 会拒绝明显不合理计数。
508
+
507
509
  runner 从 `PRODUCT_TYPE` 派生产品名,网站支付/APP 支付派生服务结果“无需处理”,从 `ROOT_INTENT` 派生代码开发栏和后续衔接;标题只按完成条件派生。`onboarding_only` 省略 `--integration-result`、`--sandbox-config-state` 和 `--manual-verification-items`。`full_process`:代码开发通过填“已完成”并传 `READY`;仅沙箱待配置且其余代码与安全检查通过填“部分完成,沙箱配置待完成”并传 `CREATE_PENDING|VERIFY_PENDING`;沙箱 `READY` 且只剩非阻塞人工待验证项时填“部分完成,人工待验证”,传 `READY`,把 checklist `manualItems` 原样作为 `MANUAL_VERIFICATION_ITEMS`,并在 `REMAINING_ACTIONS` 写明实际待办,禁止传“无”。runner 拒绝旧完整参数、stdin JSON、`--input-json`、可派生字段和空字符串伪值。renderer 校验结果与沙箱状态/人工待验证项一致,并派生恢复口令或人工待验证展示;不增加确认点。不得在 stdout 前后追加衔接提醒,不伪造本轮代码修改、沙箱创建或测试结果,也不重复进入 integration。
508
510
 
509
511
  若 `full_process` 最后一跳紧接应用创建、审核提交或复用,不再先输出 `application.operation.result` 再立刻 closeout;只记录同一 `APPLICATION_OPERATION_APP_ID`,runner 复用 `APPLICATION_RESULT`,非“需人工配置”还记录 `APPLICATION_OPERATION_NEXT_ACTION`;“需人工配置”的下一步由 runner 派生。若同一动作已成功导出支付宝公钥,同时传 `APPLICATION_OPERATION_APP_KEY_SAVE_PATH`,收口必须展示“当前 appId: xxx 对应的支付宝公钥保存在:xxx”;“需人工配置”禁止传该路径。已上线且无保存路径时不展开“应用分支结果”;已上线且有保存路径时只展开 appId、状态和路径;其他应用结果合并展示并保留完成态红线。`onboarding_only`、应用分支仍需用户补材料/确认,或应用操作结果不是紧邻 Step 6 收口时,仍按应用模块输出 `application.operation.result`。合并展示不得改写完成条件,待审核、待设置公钥或待人工配置仍不得表述为应用发布完成。
@@ -41,14 +41,14 @@ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" render <messageId> --va
41
41
  | 意图 | 判定 | 入口 | 后续按需加载 |
42
42
  |---|---|---|---|
43
43
  | `integration_only` | 只要求代码开发、支付集成或集成排障,未同时要求产品开通 | 执行 `node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" integration-bootstrap --root-intent integration_only` | 当前阶段、产品和语言的契约、示例与脚本 |
44
- | `onboarding_only` | 只要求签约、入驻或产品开通,未同时要求代码开发 | 执行 `node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-bootstrap --root-intent onboarding_only --user-input-count-total <total> --user-input-count-after-flow-start <afterFlowStart> --flow-start-observed <true|false>` | 当前阶段的授权、查询或写分支模块 |
44
+ | `onboarding_only` | 只要求签约、入驻或产品开通,未同时要求代码开发 | 执行 `node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-bootstrap --root-intent onboarding_only` | 当前阶段的授权、查询或写分支模块 |
45
45
  | `full_process` | 明确要求完整接入、一站式,或同一请求同时要求代码开发和产品开通 | `normal/full-process-routing.md` | 先 Integration,满足衔接条件后 Onboarding |
46
46
 
47
47
  `integration_only` 的 `integration-bootstrap` 只在同一 Node 进程串行执行 `telemetry start-run` 与 `flow integration entry`。`onboarding_only` 的 `onboarding-bootstrap` 只串行执行 `telemetry start-run`、`onboarding-message platform-entry` 与 `flow onboarding entry`。两者均为既有无业务写入动作,执行后不得重复原子命令。Windows 引导渲染即终结 run 并停止,`platform_id` 取本次 `run_id` 且禁止 Agent 传入;非 Windows 返回 entry 契约。`full_process` 不使用 `integration-bootstrap`;衔接 Onboarding 也不使用带 `start-run` 的 bootstrap,仍执行 `node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-message platform-entry` 后按需加载 entry,避免重复 `run.intent_detected`。
48
48
 
49
49
  `full_process` 识别根意图后立即执行 `node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" telemetry start-run --root-intent full_process`;产品已唯一确定时追加 `--product-type <aipay|webpay|apppay>`。`integration_only` 和 `onboarding_only` 已由上表各自 bootstrap 包含同一次 `start-run`,不得重复执行本条 telemetry。命令创建/复用当前流程 `run_id`,并在遥测开启时记录 `run.intent_detected`:同一意图和产品继续复用,`UNKNOWN` 补全产品仍复用同一 `run_id`;明确换产品、换根意图或既有 run 已终态才重建。第三方平台项目 ID 仍优先固定为 `run_id`,不得被显式 run ID 或本地生成值覆盖。业务 stage 只由登记 runner/script 异步记录。
50
50
 
51
- 遥测默认开启,`ALIPAY_AIPAY_TELEMETRY=0|false|off|no` 可关闭 `METRIC_EVENT`、outbox、上传和 flush;私有 run context 仍供 `PLATFORM_ID` 与终态生命周期使用。落盘/网络/上传/flush 失败静默,不改变业务、消息或确认,stdout 为空且 stderr 内部行不对客。`integration_only` 由 checklist 终结;Onboarding 由 closeout 或登记的提前终止消息终结。上报权限不新增专门网络探针,首次 `start-run` 及后续 stage 的实际低敏上传就是自然探测;宿主已允许访问 collector 时不额外申请权限,仅 `normal/telemetry.md` 的只读状态命令确认网络失败和 outbox 积压后,才允许一次补传权限申请。Agent 按 `normal/telemetry.md` 维护本轮用户输入计数,只在终态命令追加参数,不新增业务确认点或独立上报;入队后当前 `run.terminal` 文件做短超时前台 drain,失败仍保留 outbox 且不影响业务收口。after-flow 以方案后 `*.user_confirmed` 为起点;前置澄清和候选选择不计入。脚本始终以当前 `run_id` 为 `PLATFORM_ID`,Agent 不手写环境前缀或改 MCP payload;维护诊断、outbox、上传和 flush 细节只在 `normal/telemetry.md` 按需读取。
51
+ 遥测默认开启,`ALIPAY_AIPAY_TELEMETRY=0|false|off|no` 关闭事件/outbox/上传/flush;私有 run context 仍供 `PLATFORM_ID` 与终态生命周期。失败静默,不改变业务/消息/确认,stdout 空且 stderr 内部行不对客。`integration_only` 由 checklist 终结;Onboarding 由 closeout 或登记提前终止消息终结。上报权限不新增专门网络探针,首次 `start-run` 及后续 stage 的实际低敏上传就是自然探测;宿主已允许访问 collector 时不额外申请权限,仅 `normal/telemetry.md` 的不联网状态命令确认网络失败和 outbox 积压后,才允许一次补传权限申请。Agent 按 `normal/telemetry.md` 在每条用户输入到达时即时记录本轮计数:flow start 前执行 `telemetry count-user-input --phase before-flow`,`*.user_confirmed` 由 flow loader 自动标记起点,之后执行 `--phase after-flow`;closeout 默认从本地 run state 派生计数,状态不可用且已核对时才显式传三项计数参数,runner 拒绝缺项、负数、`after > total`、已观测 flow start 但 `after >= total` 等明显错误。不新增业务确认点或独立上报;入队后当前 `run.terminal` 文件做短超时前台 drain,失败仍保留 outbox 且不影响业务收口,网络类失败按维护文档短重试/后台兜底。after-flow 以方案后 `*.user_confirmed` 为起点;前置澄清和候选不计。脚本以当前 `run_id` 为 `PLATFORM_ID`,Agent 不手写环境前缀或改 MCP payload;维护诊断、outbox、上传和 flush 细节只在 `normal/telemetry.md` 按需读取。
52
52
 
53
53
  三种入口均只在无法从已有产品名称或业务描述可靠确定唯一产品时执行 flow 登记的 `product-clarify` runner;不得推定或手写澄清。产品明确但 MCC 尚无检索输入时使用 `mcc-clarify`;已有经营描述后先按 Onboarding flow 读取一次当前 `<SKILL_DIR>/references/onboarding/modules/mcc-reference.md` 做 Agent 语义候选,再统一调用 `mcc-resolve-plan` 由 runner 复核、合并和渲染;用户直接提供当前表内完整 MCC 编码时可跳过 Agent 泛化并由 runner 精确校验。不得拆回 `mcc-search + mcc-candidates`、先旧检索失败后临时猜测,或为方案展示再拼 renderer 输入。
54
54