@alipay/alipay-aipay 1.6.2-beta3 → 1.6.2

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-beta3",
3
+ "version": "1.6.2",
4
4
  "description": "支付宝 AI 付 Skill 安装包 - 优先安装 Agent Skill,并在 macOS/Linux 后台准备用户级 CLI 工具",
5
5
  "type": "module",
6
6
  "bin": {
package/skill/SKILL.md CHANGED
@@ -5,23 +5,27 @@ description: >-
5
5
  触发关键词:"AI支付"、"接支付宝"、"一站式接支付宝"、"接个支付"、"开发支付"、"402收款"、"AI按量付费"、"AI网页应用收款"、"AI移动应用收款"、"按量付费"、"快捷收款"、"快捷收单"、"网站支付"、"APP 支付"、"产品开通"、"商家开通"、"签约入驻"等。
6
6
  ---
7
7
 
8
- 本文件只负责在加载业务规则前确定本轮实际使用的 Skill 版本。禁止在完成下列启动协议前读取 `references/runtime-entry.md`、flow、模块、消息目录或业务脚本。
8
+ # 支付宝 AI 付 Skill 启动器
9
9
 
10
- 首次使用 `alipay-aipay`:解析本文件目录为规范化绝对 `<SKILL_DIR>`,记录 `ALIPAY_AIPAY_SELF_UPDATE_CHECKED=true`,执行单命令;`<SKILL_DIR>` 是占位符,禁止用 shell 变量赋值、命令替换或依赖特定 shell:
10
+ 本文件只负责在加载业务规则前确定本轮实际使用的 Skill 版本。禁止在完成下列启动协议前读取 `references/runtime-entry.md`、任一 flow、模块、消息目录或业务脚本。
11
+
12
+ ## 前置版本检查
13
+
14
+ 本次 Agent 对话首次使用 `alipay-aipay` 时,先把本文件所在目录解析为规范化绝对路径 `<SKILL_DIR>`,记录一次性事实 `ALIPAY_AIPAY_SELF_UPDATE_CHECKED=true`,再执行以下单条命令。`<SKILL_DIR>` 是执行时替换的路径占位符;禁止用 shell 变量赋值、命令替换或依赖特定 shell:
11
15
 
12
16
  ```text
13
17
  node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" self-update check --skill-dir "<SKILL_DIR>"
14
18
  ```
15
19
 
16
- `SKILL_DIR` 只绑定当前 Skill,禁止换成 Agent 启动目录、用户项目、Home、npm 源码根或其他副本。`VERSION` 缺失/非法或入口缺失由命令修复;失败或 marker 不唯一按 `SELF_UPDATE:CHECK_FAILED`。
20
+ `SKILL_DIR` 必须绑定刚触发且正在执行本命令的 Skill 规范化绝对路径,不得换成 Agent 启动目录、用户项目目录、用户 Home、npm 包源码根或另一份 Skill 副本。`VERSION` 缺失/非法或 `references/runtime-entry.md` 缺失时由本命令尝试精确修复;命令失败或 marker 无法唯一解析时按 `SELF_UPDATE:CHECK_FAILED`。
17
21
 
18
- stderr 只允许一个内部终态,禁止展示 marker 或 npm/npx 原始输出:
22
+ stderr 只允许出现以下一个内部终态;不得向用户展示 marker 或 npm/npx 原始输出:
19
23
 
20
- - `SELF_UPDATE:UPDATED=<合法 SemVer>`:已切换新版。
24
+ - `SELF_UPDATE:UPDATED=<合法 SemVer>`:当前 Skill 目录已原子切换到新版。
21
25
  - `SELF_UPDATE:CURRENT=<合法 SemVer>`:继续当前版本。
22
- - `SELF_UPDATE:RETRY_WITH_NETWORK`:可取权后原样重试一次。
23
- - `SELF_UPDATE:SKIPPED_NETWORK_RESTRICTED|CHECK_FAILED|INSTALL_FAILED|VERIFY_FAILED`:继续当前可用版本。
26
+ - `SELF_UPDATE:RETRY_WITH_NETWORK`:registry 或安装阶段网络不可达;可申请联网后原样重试本命令一次。
27
+ - `SELF_UPDATE:SKIPPED_NETWORK_RESTRICTED|CHECK_FAILED|INSTALL_FAILED|VERIFY_FAILED`:静默继续当前可用版本,不重试、不申请权限。
24
28
 
25
- 除 `RETRY_WITH_NETWORK` 外,只完整读取同一 `SKILL_DIR` 的 `references/runtime-entry.md`,记录 `ALIPAY_AIPAY_RUNTIME_ENTRY_LOADED=true` 和路径,再路由。`UPDATED` 后废弃旧 loaded 事实,禁止继续读取更新前版本的任何业务文档;其他终态同样不再读取本启动器或 `self-update.md` 补充规则。
29
+ 除 `RETRY_WITH_NETWORK` 的一次原样重试外,只完整读取同一 `SKILL_DIR` 的 `references/runtime-entry.md`,在当前上下文记录 `ALIPAY_AIPAY_RUNTIME_ENTRY_LOADED=true` 和规范化路径,再按原请求路由。`UPDATED` 后先废弃旧 loaded 事实,禁止继续读取更新前版本的任何业务文档;其他终态同样不再读取本启动器或 `self-update.md` 补充规则。
26
30
 
27
- 同一对话后续确认、补材料、候选、恢复、中断继续、重复触发和 Full Process 衔接,两项事实存在且路径未变时跳过版本检查和入口重读;仅 `UPDATED`、路径变化或上下文压缩导致规则不可用时重读并刷新;事实不落盘。
31
+ 同一对话后续确认、补材料、候选选择、恢复、中断继续、重复触发和 Full Process 衔接,两项事实存在、路径未变且入口规则仍在时,跳过版本检查和入口重读。仅 `UPDATED`、路径变化或上下文压缩导致规则不可用时重读并刷新;事实不落盘。
package/skill/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.2-beta3
1
+ 1.6.2
@@ -4,6 +4,7 @@ import fs from 'node:fs';
4
4
  import path from 'node:path';
5
5
  import process from 'node:process';
6
6
  import { fileURLToPath } from 'node:url';
7
+ import { recordTelemetryUserInputForCurrentPhase } from './telemetry.mjs';
7
8
 
8
9
  const internalPrefix = 'ALIPAY_AIPAY_INTERNAL:';
9
10
  const scriptDir = path.dirname(fileURLToPath(import.meta.url));
@@ -113,11 +114,18 @@ function parseArgs(argv) {
113
114
  return { command, args };
114
115
  }
115
116
 
117
+ function required(args, name) {
118
+ const value = args[name];
119
+ if (typeof value !== 'string' || !value) throw new Error(`缺少参数 --${name}`);
120
+ return value;
121
+ }
122
+
116
123
  export function runInteractionReplyCli(argv = process.argv) {
117
124
  const { command, args } = parseArgs(argv);
118
125
  if (command !== 'confirm' || typeof args.reply !== 'string' || !args.reply) {
119
- throw new Error('用法: interaction_reply.mjs confirm --reply <用户原始回复>');
126
+ throw new Error('用法: interaction_reply.mjs confirm --reply <用户原始回复> --input-id <本地用户输入幂等键>');
120
127
  }
128
+ recordTelemetryUserInputForCurrentPhase(required(args, 'input-id'));
121
129
  const decision = isAffirmativeReply(args.reply) ? 'CONFIRMED' : 'REJECTED';
122
130
  process.stderr.write(`${internalPrefix}REPLY_DECISION=${decision}\n`);
123
131
  if (decision === 'REJECTED') process.exitCode = 2;
@@ -5,6 +5,7 @@ import path from 'node:path';
5
5
  import process from 'node:process';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import { isAffirmativeReply } from './interaction_reply.mjs';
8
+ import { recordTelemetryUserInputForCurrentPhase } from './telemetry.mjs';
8
9
 
9
10
  const internalPrefix = 'ALIPAY_AIPAY_INTERNAL:';
10
11
  const scriptDir = path.dirname(fileURLToPath(import.meta.url));
@@ -33,6 +34,7 @@ function required(args, name) {
33
34
  }
34
35
 
35
36
  function assertRegisteredReply(args, kind) {
37
+ recordTelemetryUserInputForCurrentPhase(required(args, 'input-id'));
36
38
  if (!isAffirmativeReply(required(args, 'reply'))) {
37
39
  process.stderr.write(`${internalPrefix}RECOVERY_INPUT_REJECTED=${kind}\n`);
38
40
  process.exitCode = 2;
@@ -85,7 +87,7 @@ export function runOnboardingRecoveryCli(argv = process.argv) {
85
87
  const { command, args } = parseArgs(argv);
86
88
  if (command === 'auth-confirm') return runAuthConfirm(args);
87
89
  if (command === 'application-key') return runApplicationKeyRecovery(args);
88
- throw new Error('用法: onboarding_recovery_runner.mjs <auth-confirm|application-key> --reply <明确完成表达> ...');
90
+ throw new Error('用法: onboarding_recovery_runner.mjs <auth-confirm|application-key> --reply <明确完成表达> --input-id <本地用户输入幂等键> ...');
89
91
  }
90
92
 
91
93
  if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
@@ -132,19 +132,20 @@ function appendOptionalTerminalCountOptions(targetArgs, options) {
132
132
  }
133
133
  }
134
134
 
135
- async function startTelemetryRun(rootIntent, productType) {
135
+ async function startTelemetryRun(rootIntent, productType, inputId = '') {
136
136
  const telemetryArgs = ['start-run', '--root-intent', rootIntent];
137
137
  if (productType) telemetryArgs.push('--product-type', productType);
138
+ if (inputId) telemetryArgs.push('--input-id', inputId);
138
139
  const { runTelemetryCli } = await import('./telemetry.mjs');
139
140
  await runTelemetryCli(cliArgv(telemetryArgs));
140
141
  }
141
142
 
142
143
  async function runIntegrationBootstrap(args) {
143
144
  const options = parseRuntimeArgs(args);
144
- assertOnlyOptions(options, ['root-intent', 'product-type']);
145
+ assertOnlyOptions(options, ['root-intent', 'product-type', 'input-id']);
145
146
  const rootIntent = assertEnumOption(options, 'root-intent', ['integration_only']);
146
147
  const productType = assertEnumOption(options, 'product-type', ['aipay', 'webpay', 'apppay'], { required: false });
147
- await startTelemetryRun(rootIntent, productType);
148
+ await startTelemetryRun(rootIntent, productType, options['input-id']);
148
149
  const { runFlowCli } = await import('./flow_loader.mjs');
149
150
  runFlowCli(cliArgv(['integration', 'entry']));
150
151
  }
@@ -154,13 +155,14 @@ async function runOnboardingBootstrap(args) {
154
155
  assertOnlyOptions(options, [
155
156
  'root-intent',
156
157
  'product-type',
158
+ 'input-id',
157
159
  'user-input-count-total',
158
160
  'user-input-count-after-flow-start',
159
161
  'flow-start-observed'
160
162
  ]);
161
163
  const rootIntent = assertEnumOption(options, 'root-intent', ['onboarding_only']);
162
164
  const productType = assertEnumOption(options, 'product-type', ['aipay', 'webpay', 'apppay'], { required: false });
163
- await startTelemetryRun(rootIntent, productType);
165
+ await startTelemetryRun(rootIntent, productType, options['input-id']);
164
166
  const { runOnboardingMessageCli } = await import('./onboarding_message_runner.mjs');
165
167
  const platformEntryArgs = ['platform-entry'];
166
168
  appendOptionalTerminalCountOptions(platformEntryArgs, options);
@@ -27,6 +27,7 @@ const terminalCountArgNames = Object.freeze([
27
27
  'user-input-count-after-flow-start',
28
28
  'flow-start-observed'
29
29
  ]);
30
+ const initialUserInputId = 'run.start';
30
31
  const outboxFlushLimit = 50;
31
32
  const outboxClaimTtlMs = 5 * 60 * 1000;
32
33
  const outboxMaxRecords = 1000;
@@ -416,20 +417,39 @@ function parseBooleanFlag(value) {
416
417
  return null;
417
418
  }
418
419
 
420
+ function normalizeUserInputId(value) {
421
+ if (typeof value !== 'string') return '';
422
+ const text = value.trim();
423
+ if (!text || text.length > 256 || /[\u0000-\u001f\u007f]/u.test(text)) return '';
424
+ return text;
425
+ }
426
+
427
+ function userInputHash(inputId, runId) {
428
+ const normalized = normalizeUserInputId(inputId);
429
+ if (!normalized || !safeRunId(runId)) return '';
430
+ return crypto.createHash('sha256').update(`${runId}\u0000${normalized}`).digest('hex').slice(0, 32);
431
+ }
432
+
433
+ function normalizeUserInputHashes(value) {
434
+ if (!Array.isArray(value)) return [];
435
+ return [...new Set(value.filter((entry) => typeof entry === 'string' && /^[a-f0-9]{32}$/u.test(entry)))];
436
+ }
437
+
419
438
  function normalizeUserInputCounts(value) {
420
439
  if (!value || typeof value !== 'object' || Array.isArray(value)) {
421
- return { total: 0, after_flow_start: 0, flow_start_observed: false };
440
+ return { total: 0, after_flow_start: 0, flow_start_observed: false, input_hashes: [] };
422
441
  }
423
442
  const total = parseNonNegativeInteger(value.total ?? value.user_input_count_total);
424
443
  const afterFlowStart = parseNonNegativeInteger(value.after_flow_start ?? value.user_input_count_after_flow_start);
425
444
  const flowStartObserved = parseBooleanFlag(value.flow_start_observed);
426
445
  if (total === null || afterFlowStart === null || flowStartObserved === null) {
427
- return { total: 0, after_flow_start: 0, flow_start_observed: false };
446
+ return { total: 0, after_flow_start: 0, flow_start_observed: false, input_hashes: [] };
428
447
  }
429
448
  return {
430
449
  total,
431
450
  after_flow_start: Math.min(afterFlowStart, total),
432
451
  flow_start_observed: flowStartObserved,
452
+ input_hashes: normalizeUserInputHashes(value.input_hashes),
433
453
  flow_start_observed_at: parseNonNegativeInteger(value.flow_start_observed_at) || undefined,
434
454
  updated_at: parseNonNegativeInteger(value.updated_at) || undefined
435
455
  };
@@ -461,6 +481,39 @@ function validateTerminalCountPayload(payload = {}, env = process.env, { strict
461
481
  return { total, afterFlowStart, flowStartObserved, rootIntent };
462
482
  }
463
483
 
484
+ function initialUserInputCounts(nowMs = Date.now(), inputId = initialUserInputId, runId = '') {
485
+ return {
486
+ total: 1,
487
+ after_flow_start: 0,
488
+ flow_start_observed: false,
489
+ input_hashes: [userInputHash(inputId, runId) || userInputHash(initialUserInputId, runId)].filter(Boolean),
490
+ updated_at: nowMs
491
+ };
492
+ }
493
+
494
+ function addUserInputCount(counts, phase, inputId, runId, nowMs = Date.now()) {
495
+ const inputHash = userInputHash(inputId, runId);
496
+ if (!inputHash || counts.input_hashes.includes(inputHash)) return counts;
497
+ return {
498
+ ...counts,
499
+ total: counts.total + 1,
500
+ after_flow_start: counts.after_flow_start + (phase === 'after-flow' ? 1 : 0),
501
+ input_hashes: [...counts.input_hashes, inputHash],
502
+ updated_at: nowMs
503
+ };
504
+ }
505
+
506
+ function publicUserInputCountState(counts) {
507
+ if (!counts) return null;
508
+ const normalized = normalizeUserInputCounts(counts);
509
+ return {
510
+ total: normalized.total,
511
+ after_flow_start: normalized.after_flow_start,
512
+ flow_start_observed: normalized.flow_start_observed,
513
+ tracked_inputs: normalized.input_hashes.length
514
+ };
515
+ }
516
+
464
517
  function terminalExtInfoFromPayload(payload = {}, env = process.env) {
465
518
  if (!payload || typeof payload !== 'object' || Array.isArray(payload)) return '';
466
519
  const counts = validateTerminalCountPayload(payload, env);
@@ -650,7 +703,20 @@ export function terminalMetricContextFromArgs(args, context = {}) {
650
703
  }
651
704
  const state = readRunState(process.env);
652
705
  const stored = normalizeUserInputCounts(state?.user_input_counts);
653
- if (stored.total < 1) return {};
706
+ if (stored.total < 1) {
707
+ const fallbackCounts = validateTerminalCountPayload({
708
+ userInputCountTotal: 1,
709
+ userInputCountAfterFlowStart: 0,
710
+ flowStartObserved: Boolean(stored.flow_start_observed),
711
+ rootIntent: state?.root_intent
712
+ }, process.env);
713
+ if (!fallbackCounts) return {};
714
+ return {
715
+ userInputCountTotal: fallbackCounts.total,
716
+ userInputCountAfterFlowStart: fallbackCounts.afterFlowStart,
717
+ flowStartObserved: fallbackCounts.flowStartObserved
718
+ };
719
+ }
654
720
  const counts = validateTerminalCountPayload({
655
721
  userInputCountTotal: stored.total,
656
722
  userInputCountAfterFlowStart: stored.after_flow_start,
@@ -699,11 +765,42 @@ function createRunState(args, env = process.env, nowMs = Date.now()) {
699
765
  run_id: runId,
700
766
  root_intent: rootIntent,
701
767
  product_type: productType,
768
+ user_input_counts: initialUserInputCounts(nowMs, args['input-id'] || initialUserInputId, runId),
702
769
  created_at: nowMs,
703
770
  updated_at: nowMs
704
771
  };
705
772
  }
706
773
 
774
+ function withInitialUserInputCount(state, nowMs = Date.now(), inputId = initialUserInputId) {
775
+ const counts = normalizeUserInputCounts(state?.user_input_counts);
776
+ if (counts.total >= 1) return state;
777
+ return {
778
+ ...state,
779
+ user_input_counts: initialUserInputCounts(nowMs, inputId, state.run_id),
780
+ updated_at: nowMs
781
+ };
782
+ }
783
+
784
+ function withCurrentUserInputCount(state, nowMs = Date.now(), inputId = '') {
785
+ const normalizedInputId = normalizeUserInputId(inputId);
786
+ const counts = normalizeUserInputCounts(state?.user_input_counts);
787
+ if (counts.total < 1) return withInitialUserInputCount(state, nowMs, normalizedInputId || initialUserInputId);
788
+ if (!normalizedInputId) return state;
789
+ const nextCounts = addUserInputCount(
790
+ counts,
791
+ counts.flow_start_observed ? 'after-flow' : 'before-flow',
792
+ normalizedInputId,
793
+ state.run_id,
794
+ nowMs
795
+ );
796
+ if (nextCounts === counts) return state;
797
+ return {
798
+ ...state,
799
+ user_input_counts: nextCounts,
800
+ updated_at: nowMs
801
+ };
802
+ }
803
+
707
804
  function compatibleProductType(existingProductType, requestedProductType) {
708
805
  const existing = canonicalProductType(existingProductType) || 'UNKNOWN';
709
806
  const requested = canonicalProductType(requestedProductType) || 'UNKNOWN';
@@ -740,12 +837,12 @@ function createOrReuseRunState(args, env = process.env, nowMs = Date.now()) {
740
837
  const requestedRunId = platformProjectRunId(env) || safeRunId(args['run-id']);
741
838
  const existing = readRunState(env);
742
839
  if (reusableRunState(existing, rootIntent, requestedProductType) && (!requestedRunId || existing.run_id === requestedRunId)) {
743
- return {
840
+ return withCurrentUserInputCount({
744
841
  ...existing,
745
842
  root_intent: rootIntent,
746
843
  product_type: mergeProductType(existing.product_type, requestedProductType),
747
844
  updated_at: nowMs
748
- };
845
+ }, nowMs, args['input-id']);
749
846
  }
750
847
  return createRunState(args, env, nowMs);
751
848
  }
@@ -803,25 +900,26 @@ export function markTelemetryFlowStart(env = process.env, nowMs = Date.now()) {
803
900
  return next.user_input_counts;
804
901
  }
805
902
 
806
- export function recordTelemetryUserInput(phase, env = process.env, nowMs = Date.now()) {
903
+ export function recordTelemetryUserInput(phase, env = process.env, nowMs = Date.now(), inputId = '') {
807
904
  if (!telemetryEnabled(env)) return null;
808
905
  if (!['before-flow', 'after-flow'].includes(phase)) {
809
906
  throw new Error('--phase 仅支持 before-flow、after-flow');
810
907
  }
908
+ const normalizedInputId = normalizeUserInputId(inputId);
909
+ if (!normalizedInputId) throw new Error('用户输入计数必须提供本地幂等 --input-id,且不得包含用户输入原文或敏感信息');
811
910
  const existing = readRunState(env);
812
911
  if (!existing?.run_id || existing.terminal) return null;
813
912
  const counts = normalizeUserInputCounts(existing.user_input_counts);
814
913
  if (phase === 'before-flow' && counts.flow_start_observed) {
815
914
  throw new Error('当前 run 已观测 flow start,后续用户输入必须记录为 after-flow');
816
915
  }
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;
916
+ if (phase === 'after-flow' && !counts.flow_start_observed) {
917
+ throw new Error('当前 run 尚未观测 flow start,不能记录 after-flow 用户输入');
918
+ }
919
+ const inputHash = userInputHash(normalizedInputId, existing.run_id);
920
+ if (!inputHash) throw new Error('用户输入计数 input-id 无法生成本地幂等键');
921
+ if (counts.input_hashes.includes(inputHash)) return counts;
922
+ const nextCounts = addUserInputCount(counts, phase, normalizedInputId, existing.run_id, nowMs);
825
923
  const next = {
826
924
  ...existing,
827
925
  user_input_counts: nextCounts,
@@ -831,6 +929,14 @@ export function recordTelemetryUserInput(phase, env = process.env, nowMs = Date.
831
929
  return nextCounts;
832
930
  }
833
931
 
932
+ export function recordTelemetryUserInputForCurrentPhase(inputId, env = process.env, nowMs = Date.now()) {
933
+ if (!telemetryEnabled(env)) return null;
934
+ const existing = readRunState(env);
935
+ if (!existing?.run_id || existing.terminal) return null;
936
+ const counts = normalizeUserInputCounts(existing.user_input_counts);
937
+ return recordTelemetryUserInput(counts.flow_start_observed ? 'after-flow' : 'before-flow', env, nowMs, inputId);
938
+ }
939
+
834
940
  function updateExistingRunStateFromEvent(event, env = process.env) {
835
941
  const existing = readRunState(env);
836
942
  if (!existing) return false;
@@ -1309,7 +1415,7 @@ function networkUploadFailure(status) {
1309
1415
  return '';
1310
1416
  }
1311
1417
 
1312
- export function permissionedFlushDecision(env = process.env, nowMs = Date.now(), { markRequested = false } = {}) {
1418
+ export function permissionedFlushDecision(env = process.env, nowMs = Date.now()) {
1313
1419
  const outboxCount = outboxFiles(env).length;
1314
1420
  const status = readUploadStatus(env);
1315
1421
  const errorCode = networkUploadFailure(status);
@@ -1332,17 +1438,30 @@ export function permissionedFlushDecision(env = process.env, nowMs = Date.now(),
1332
1438
  };
1333
1439
  }
1334
1440
  result.needed = true;
1335
- if (markRequested) {
1336
- writePermissionedFlushState({
1337
- requested_at: nowMs,
1338
- error_code: errorCode,
1339
- outbox_count: outboxCount
1340
- }, env);
1341
- result.requested_at = nowMs;
1342
- }
1343
1441
  return result;
1344
1442
  }
1345
1443
 
1444
+ export function recordPermissionedFlushRequested(env = process.env, nowMs = Date.now(), decision = permissionedFlushDecision(env, nowMs)) {
1445
+ if (!decision.needed) return decision;
1446
+ writePermissionedFlushState({
1447
+ requested_at: nowMs,
1448
+ error_code: decision.error_code,
1449
+ outbox_count: decision.outbox_count
1450
+ }, env);
1451
+ return {
1452
+ ...decision,
1453
+ requested_at: nowMs
1454
+ };
1455
+ }
1456
+
1457
+ function emitPermissionedFlushNeededMarkers(env = process.env, nowMs = Date.now(), stream = process.stderr) {
1458
+ const decision = permissionedFlushDecision(env, nowMs);
1459
+ if (!decision.needed || !stream || typeof stream.write !== 'function') return false;
1460
+ stream.write(`${internalPrefix}PERMISSIONED_FLUSH_DECISION=${JSON.stringify(decision)}\n`);
1461
+ stream.write(`${internalPrefix}PERMISSIONED_FLUSH_NEEDED=true\n`);
1462
+ return true;
1463
+ }
1464
+
1346
1465
  export async function flushOutbox(env = process.env, {
1347
1466
  limit = outboxFlushLimit,
1348
1467
  targetFile = '',
@@ -1489,6 +1608,7 @@ function scheduleSyncLogUpload(event, env = process.env) {
1489
1608
  if (event?.stage === 'run.terminal') {
1490
1609
  if (!foregroundFlushTerminalOutboxFile(queuedFile, env)) {
1491
1610
  spawnOutboxFlush(env, { delayMs: terminalBackgroundRetryDelayMs });
1611
+ emitPermissionedFlushNeededMarkers(env);
1492
1612
  }
1493
1613
  return true;
1494
1614
  }
@@ -1507,7 +1627,7 @@ export async function runTelemetryCli(argv = process.argv) {
1507
1627
  try {
1508
1628
  const { command, args } = parseCliArgs(argv);
1509
1629
  if (command === 'start-run') {
1510
- assertCliArgs(args, new Set(['root-intent', 'product-type', 'run-id']), 0);
1630
+ assertCliArgs(args, new Set(['root-intent', 'product-type', 'run-id', 'input-id']), 0);
1511
1631
  const state = createOrReuseRunState(args);
1512
1632
  if (!writeRunState(state) && telemetryEnabled(process.env)) {
1513
1633
  recordLocalTelemetryFailure('LOCAL_RUN_STATE_WRITE_FAILED', 'failed to write local telemetry run state');
@@ -1533,10 +1653,10 @@ export async function runTelemetryCli(argv = process.argv) {
1533
1653
  return 0;
1534
1654
  }
1535
1655
  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());
1656
+ assertCliArgs(args, new Set(['phase', 'input-id']), 0);
1657
+ const counts = recordTelemetryUserInput(args.phase, process.env, Date.now(), args['input-id']);
1538
1658
  if (counts) {
1539
- process.stderr.write(`${internalPrefix}USER_INPUT_COUNT_STATE=${JSON.stringify(counts)}\n`);
1659
+ process.stderr.write(`${internalPrefix}USER_INPUT_COUNT_STATE=${JSON.stringify(publicUserInputCountState(counts))}\n`);
1540
1660
  } else {
1541
1661
  process.stderr.write(`${internalPrefix}USER_INPUT_COUNT_STATE_MISSING=true\n`);
1542
1662
  }
@@ -1546,7 +1666,7 @@ export async function runTelemetryCli(argv = process.argv) {
1546
1666
  assertCliArgs(args, new Set(), 0);
1547
1667
  const counts = markTelemetryFlowStart(process.env, Date.now());
1548
1668
  if (counts) {
1549
- process.stderr.write(`${internalPrefix}USER_INPUT_FLOW_START_STATE=${JSON.stringify(counts)}\n`);
1669
+ process.stderr.write(`${internalPrefix}USER_INPUT_FLOW_START_STATE=${JSON.stringify(publicUserInputCountState(counts))}\n`);
1550
1670
  } else {
1551
1671
  process.stderr.write(`${internalPrefix}USER_INPUT_FLOW_START_STATE_MISSING=true\n`);
1552
1672
  }
@@ -1560,7 +1680,7 @@ export async function runTelemetryCli(argv = process.argv) {
1560
1680
  }
1561
1681
  if (command === 'permissioned-flush-status' && args._.length === 0) {
1562
1682
  assertCliArgs(args, new Set(), 0);
1563
- const decision = permissionedFlushDecision(process.env, Date.now(), { markRequested: false });
1683
+ const decision = permissionedFlushDecision(process.env, Date.now());
1564
1684
  process.stderr.write(`${internalPrefix}PERMISSIONED_FLUSH_STATUS=${JSON.stringify(decision)}\n`);
1565
1685
  if (decision.needed) {
1566
1686
  process.stderr.write(`${internalPrefix}PERMISSIONED_FLUSH_CANDIDATE=true\n`);
@@ -1569,17 +1689,18 @@ export async function runTelemetryCli(argv = process.argv) {
1569
1689
  }
1570
1690
  if (command === 'permissioned-flush-needed' && args._.length === 0) {
1571
1691
  assertCliArgs(args, new Set(), 0);
1572
- const decision = permissionedFlushDecision(process.env, Date.now(), { markRequested: true });
1692
+ const decision = permissionedFlushDecision(process.env, Date.now());
1573
1693
  process.stderr.write(`${internalPrefix}PERMISSIONED_FLUSH_DECISION=${JSON.stringify(decision)}\n`);
1574
- if (decision.needed) {
1575
- process.stderr.write(`${internalPrefix}PERMISSIONED_FLUSH_NEEDED=true\n`);
1576
- }
1694
+ if (decision.needed) process.stderr.write(`${internalPrefix}PERMISSIONED_FLUSH_NEEDED=true\n`);
1577
1695
  return 0;
1578
1696
  }
1579
1697
  if (command === 'flush-outbox') {
1580
1698
  assertCliArgs(args, new Set(), 0);
1581
1699
  if (!telemetryEnabled(process.env)) return 0;
1582
- spawnOutboxFlush(process.env);
1700
+ const decision = permissionedFlushDecision(process.env, Date.now());
1701
+ if (spawnOutboxFlush(process.env)) {
1702
+ recordPermissionedFlushRequested(process.env, Date.now(), decision);
1703
+ }
1583
1704
  return 0;
1584
1705
  }
1585
1706
  if (command === 'flush-outbox-worker') {
@@ -1,4 +1,4 @@
1
- - 测试白名单:stage/flow、产品、根意图、时间戳、Skill 版本、宿主/模型、匿名机器哈希、`run_id`、终态计数;禁密钥/账号密码/订单/交易号/截图/凭证/用户输入/路径/URL/响应/命令输出/堆栈原文;失败不影响业务,内部行 `ALIPAY_AIPAY_INTERNAL:`。
1
+ - 字段白名单:stage/flow、产品、根意图、时间戳、Skill 版本、宿主/模型、匿名机器哈希、`run_id`、终态计数;禁密钥/账号密码/订单/交易号/截图/凭证/用户输入/路径/URL/响应/命令输出/堆栈原文;失败不影响业务,内部行 `ALIPAY_AIPAY_INTERNAL:`。
2
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` 兜底。
3
+ - 计数:统计窗口从首次触发本 Skill 的用户消息开始,到当前 `run_id` 的 `run.terminal` 事件生成为止。只计用户在 Agent 对话框发送的消息,不计宿主权限弹窗、系统授权、网页授权、扫码、Skill stage、runner、工具调用或自动轮询;文字、图片/文件上传、空白或短确认消息、材料补充、确认回复和中途插话都按一条用户消息计,同一条消息同时包含文字和图片/文件时仍只计一条。`USER_INPUT_ID` 由 Agent 从首次触发本 Skill 的用户消息开始,在当前对话内给每条新用户消息分配单调序号,同一消息重试复用同一值;禁止包含或派生自用户输入内容、文件名、路径、截图/OCR、业务材料、stage 名或工具调用序号,运行时只保存本地 hash 且不上报。`start-run --input-id "$USER_INPUT_ID"` 自动把触发当前 run 的首条用户输入计为 `before-flow`;若中断/压缩后用新的 `USER_INPUT_ID` 重复进入同一未终态 run,`start-run` 会按当前 phase 幂等补计该用户消息。`reply confirm --reply "$USER_REPLY" --input-id "$USER_INPUT_ID"` 和 onboarding recovery 自动按当前 phase 幂等计数,禁止再为同一条回复手动执行 `count-user-input`。其他用户输入到达当前 run 后,包括用户中途打断、补充材料、只上传图片/文件或只问问题,在继续任何 Skill 动作或对该输入作业务答复前立刻执行 `telemetry count-user-input --phase before-flow|after-flow --input-id "$USER_INPUT_ID"` 写本地 run state,不联网;重复同一 `USER_INPUT_ID` 不加计。`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` 自动标记但不计数;flow start 前拒绝 `after-flow`,用户 kill 未终态不补报。closeout 默认派生本地计数;状态为空时终态使用首条输入的最小合法计数,状态不可用且已核对时才显式传三项;runner 拒绝缺项、负数、`after > total`、已观测 flow start 但 `after >= total`。终态只追加计数,不新增确认点、stage 或独立上报。`run.terminal` 入队后以短超时前台 drain,仅当前 terminal 文件,避免流程最后的 detached worker 被宿主回收;若文件仍在且是网络类错误,短重试一次并挂延迟后台补传,同时输出内部 `PERMISSIONED_FLUSH_NEEDED=true` 供 Agent 当场申请补传权限;失败保留 outbox。`c4=ext_info`,计数合法且有 `root_intent` 才写 JSON。
4
+ - 补传:不为权限探测新增网络事件;实际低敏上传就是自然探测,宿主已允许访问 collector 时不额外申请权限。任一终态后若 `run.terminal`/outbox 因 DNS、连接或超时失败积压,执行以下本地判断。`upload-status`/`permissioned-flush-status`/`permissioned-flush-needed` 都不联网;前两者不消耗请求窗口,`permissioned-flush-needed` 也不写 `requested_at`,避免 Agent 中断或宿主拒绝权限时误抑制后续补传。最近 `ENOTFOUND|EAI_AGAIN|ETIMEDOUT` 等 DNS/连接/超时类错误、outbox 积压、12h 未实际触发补传时,`permissioned-flush-status` 出 `PERMISSIONED_FLUSH_CANDIDATE=true`,`permissioned-flush-needed` 出唯一 `PERMISSIONED_FLUSH_NEEDED=true` 后才申请。`flush-outbox` 后台 worker 成功触发后才记录本次已发起补传,随后 POST 到 `collect.alipay.com:443`,路径 `/yuyan/`。说明:`是否允许 Agent 上报 Skill 使用过程的统计信息?只含产品类别、时间、Skill 版本、匿名设备标识、人机交互次数等用于帮助改善用户体验的非敏感信息,不会采集包含源代码、用户输入内容等任何敏感信息。` 同一 Agent 会话只对已实际触发的补传抑制重复请求;无宿主标识时按当前 `run_id` 隔离 12h;拒绝/中断且 `flush-outbox` 未执行时不写抑制状态,本地 worker 触发失败也不写抑制状态;执行后失败/非2xx留 outbox;collector 结果非业务条件;无 `inspect-outbox`、`--confirm-reviewed`、`alipay-cli whoami` 兜底。
@@ -56,7 +56,7 @@ Step 1: 方案规划 → Step 2: 环境检查 → Step 3: 登录授权
56
56
  <!-- GENERATED:ONBOARDING-GUARDS-SHARED:START -->
57
57
  共享护栏:`P-MCP-CONTRACT-FROZEN` 仅用已验证脚本;禁推断或尝试近似方法;`P-AUTH-BEFORE-ONBOARDING` 登录/scope/MCC 未通过前禁查询和写入;`P-SENSITIVE-STATE` 公钥限当前 app 调用且禁复述/保存;敏感值禁入回复/摘要/日志/状态/宽权限文件;临时 URL 仅由登记动作展示;`P-CUSTOMER-OUTPUT-EXCLUSIVE` 登记 stdout 原文是唯一正文;阻塞送达后立即等待;`P-ONBOARDING-CONTROL-CHANNEL` 内部行禁对客;正文为空按唯一终态转移;`P-DETERMINISTIC-HANDOFF` 仅执行登记命令并按唯一终态转移;禁追加解析;失败只走登记恢复。
58
58
  <!-- GENERATED:ONBOARDING-GUARDS-SHARED:END -->
59
- 环境检查、产品/MCC 澄清或方案展示前先执行平台入口。`onboarding_only` 正常由 `onboarding-bootstrap --root-intent onboarding_only` 包含本动作和 entry 加载;仅原子 fallback 或 `full_process` 衔接时执行:
59
+ 环境检查、产品/MCC 澄清或方案展示前先执行平台入口。`onboarding_only` 正常由 `onboarding-bootstrap --root-intent onboarding_only --input-id "$USER_INPUT_ID"` 包含本动作和 entry 加载;仅原子 fallback 或 `full_process` 衔接时执行:
60
60
 
61
61
  ```bash
62
62
  node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-message platform-entry
@@ -191,7 +191,7 @@ Step 1 的产品/MCC 唯一事实校验和方案送达、Step 2 的环境 READY
191
191
  ├─ AUTH_FLOW:RETRY_WITH_LOCAL_FS_PERMISSION → 保留当前授权页短时状态,取得 CLI 私有状态目录权限后原样重试当前 wait 命令一次
192
192
  ├─ AUTH_FLOW:FAILED → 停止并按错误输出恢复,禁止进入 Step 3.1
193
193
  └─ AUTH_FLOW:SCOPE_MISMATCH / MCC_MISMATCH → 执行第 4 项
194
- 3. 仅 PENDING 后把用户原始回复传给 `node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-recovery auth-confirm --reply "$USER_REPLY" --scope "$SCOPE" --sales-code "$SALES_CODE" --mcc-code "$MCC_CODE" --product-name "$PRODUCT_NAME" --mcc-name "$MCC_NAME"`;runner 复用统一肯定语义判定(包括 `1`、“继续”“好了”“已完成”“OK”等),接受后只执行一次原 `auth.sh confirm`。否定、疑问、取消、修改意见或含糊输入返回内部拒绝且不得查询;成功后的转移同第 2 项,PENDING 继续等待且不重启轮询
194
+ 3. 仅 PENDING 后把用户原始回复传给 `node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-recovery auth-confirm --reply "$USER_REPLY" --input-id "$USER_INPUT_ID" --scope "$SCOPE" --sales-code "$SALES_CODE" --mcc-code "$MCC_CODE" --product-name "$PRODUCT_NAME" --mcc-name "$MCC_NAME"`;runner 复用统一肯定语义判定(包括 `1`、“继续”“好了”“已完成”“OK”等)并按当前用户消息幂等计数,接受后只执行一次原 `auth.sh confirm`。否定、疑问、取消、修改意见或含糊输入返回内部拒绝且不得查询;成功后的转移同第 2 项,PENDING 继续等待且不重启轮询
195
195
  4. node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" auth mismatch --defer-open --scope "$SCOPE" --sales-code "$SALES_CODE" --mcc-code "$MCC_CODE" --product-name "$PRODUCT_NAME" --mcc-name "$MCC_NAME"
196
196
  ├─ AUTH_FLOW:READY_TO_OPEN → 输出非阻塞授权页并按第 2 项执行 open + wait
197
197
  ├─ AUTH_FLOW:CONTEXT_MISMATCH → 未执行 logout;使用当前已确认的完整参数重新执行第 1 项
@@ -446,8 +446,8 @@ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" app open-key-page "<app
446
446
  node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" app verify-key-and-audit --product-type "$PRODUCT_TYPE" "<本轮create输出的appId>" "<同一publicKey>"
447
447
  node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" app verify-key --product-type "$PRODUCT_TYPE" "<appId>" "<同一publicKey>"
448
448
  # 仅轮询耗尽且用户明确已完成;单查一次
449
- node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-recovery application-key --reply "$USER_REPLY" --product-type "$PRODUCT_TYPE" --mode verify-key-and-audit --app-id "<本轮create输出的appId>" --public-key "<同一publicKey>"
450
- node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-recovery application-key --reply "$USER_REPLY" --product-type "$PRODUCT_TYPE" --mode verify-key --app-id "<appId>" --public-key "<同一publicKey>"
449
+ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-recovery application-key --reply "$USER_REPLY" --input-id "$USER_INPUT_ID" --product-type "$PRODUCT_TYPE" --mode verify-key-and-audit --app-id "<本轮create输出的appId>" --public-key "<同一publicKey>"
450
+ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-recovery application-key --reply "$USER_REPLY" --input-id "$USER_INPUT_ID" --product-type "$PRODUCT_TYPE" --mode verify-key --app-id "<appId>" --public-key "<同一publicKey>"
451
451
  node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" app audit --product-type "$PRODUCT_TYPE" "<appId>"
452
452
  ```
453
453
 
@@ -32,7 +32,7 @@ CLI `login --complete` 成功只表示页面侧确认完成,不代表本机已
32
32
 
33
33
  授权页只允许 `https://aipay.alipay.com/cli-auth`,必含唯一 `deviceCode/productCode/mccCode`,只允许可选 `platform`;禁止 CLI `verification_url`、额外参数、重复参数和 fragment。页面 stdout 必须先作为独立对客消息送达,再执行 `auth.sh open` 和 `auth.sh wait`,后续 pending 或收口不得合并进同一回复。
34
34
 
35
- `wait` 生产最多查询 12 次,未成功的相邻查询间隔 5 秒,成功或过期立即停止。耗尽后把用户原始回复交给统一 runtime 的 `onboarding-recovery auth-confirm`;runner 复用统一肯定语义判定器,接受 `继续`、`好了`、`已完成`、`确认`、`OK` 和兼容输入 `1`,每次接受只执行一次 `auth.sh confirm`,不重启自动轮询。否定、疑问、取消、修改意见或含糊输入不查询。
35
+ `wait` 生产最多查询 12 次,未成功的相邻查询间隔 5 秒,成功或过期立即停止。耗尽后按 flow 登记命令把用户原始回复和当前 `USER_INPUT_ID` 交给统一 runtime 的 `onboarding-recovery auth-confirm`;runner 复用统一肯定语义判定器并对该用户消息幂等计数,接受 `继续`、`好了`、`已完成`、`确认`、`OK` 和兼容输入 `1`,每次接受只执行一次 `auth.sh confirm`,不重启自动轮询。否定、疑问、取消、修改意见或含糊输入不查询。
36
36
 
37
37
  授权对客正文只由 `auth.sh` 调用消息目录生成。初始页面不得提前要求回复完成;pending 的自然语言提示、允许回复和授权页返回提示都不在本模块维护副本。
38
38
 
@@ -30,7 +30,7 @@ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" render <messageId> --va
30
30
 
31
31
  动态 JSON 只取本轮事实;无变量传 `{}`,禁止字符串替换或 `eval`。正常路径禁止预跑 `render --schema` 或用 `jq`/消息目录探测字段。renderer 返回 `MESSAGE_RENDER_ERROR` 时必须先复查同一 `messageId` + `variant` schema,禁止猜枚举;非 0 即停止,不手写兜底。
32
32
 
33
- 阻塞点展示登记摘要后,把用户原始回复交给 `node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" reply confirm --reply "$USER_REPLY"`;仅唯一 `ALIPAY_AIPAY_INTERNAL:REPLY_DECISION=CONFIRMED` 可推进。`1`、`继续/继续推进`、`好了/已完成`、`确认/确定/同意`、`OK` 等明确肯定表达等价;否定、疑问、取消、修改或含糊回复不确认。确认只绑定当前产品、项目、主体、候选和摘要,任一变化即失效;此校验不新增操作点。
33
+ 阻塞点展示登记摘要后,把用户原始回复交给 `node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" reply confirm --reply "$USER_REPLY" --input-id "$USER_INPUT_ID"`;仅唯一 `ALIPAY_AIPAY_INTERNAL:REPLY_DECISION=CONFIRMED` 可推进。`1`、`继续/继续推进`、`好了/已完成`、`确认/确定/同意`、`OK` 等明确肯定表达等价;否定、疑问、取消、修改或含糊回复不确认。确认只绑定当前产品、项目、主体、候选和摘要,任一变化即失效;此校验不新增操作点。
34
34
 
35
35
  `<SKILL_DIR>` 是启动器确定的当前 Skill 规范化绝对路径占位符,不是 shell 变量。Skill 自有受控 Node、Shell 和 Python 入口必须使用文档登记的 `<SKILL_DIR>/references/...` 绝对路径单命令执行,禁止前置 `cd`、拼 `&&`、管道或退回相对路径;这些入口不新增权限确认或业务操作点。未登记命令和用户项目命令仍使用所在 Markdown 目录或已确认项目根,不得借用 Skill 权限。
36
36
 
@@ -40,15 +40,19 @@ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" render <messageId> --va
40
40
 
41
41
  | 意图 | 判定 | 入口 | 后续按需加载 |
42
42
  |---|---|---|---|
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` | 当前阶段的授权、查询或写分支模块 |
43
+ | `integration_only` | 只要求代码开发、支付集成或集成排障,未同时要求产品开通 | 执行 `node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" integration-bootstrap --root-intent integration_only --input-id "$USER_INPUT_ID"` | 当前阶段、产品和语言的契约、示例与脚本 |
44
+ | `onboarding_only` | 只要求签约、入驻或产品开通,未同时要求代码开发 | 执行 `node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" onboarding-bootstrap --root-intent onboarding_only --input-id "$USER_INPUT_ID"` | 当前阶段的授权、查询或写分支模块 |
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
- `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 异步记录。
49
+ `full_process` 识别根意图后立即执行 `node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" telemetry start-run --root-intent full_process --input-id "$USER_INPUT_ID"`;产品已唯一确定时追加 `--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` 关闭事件/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` 按需读取。
51
+ 遥测默认开启,`ALIPAY_AIPAY_TELEMETRY=0|false|off|no` 关闭事件/outbox/上传/flush;私有 run context 仍供 `PLATFORM_ID` 与终态生命周期。失败静默,不改变业务/消息/确认,stdout 空且 stderr 内部行不对客。`integration_only` 由 checklist 终结;Onboarding 由 closeout 或登记提前终止消息终结。上报权限不新增网络探针;实际低敏上传就是自然探测,collector 可达时不申请。任一终态后若 `run.terminal`/outbox 因 DNS、连接或超时失败积压,按 `normal/telemetry.md` 先本地状态判断,唯一需要时才申请一次补传权限。
52
+
53
+ 用户输入计数是入口前置职责,统计窗口从首次触发本 Skill 的用户消息开始,到当前 `run_id` 的 `run.terminal` 事件生成为止。只计用户在 Agent 对话框发送的消息,不计宿主/系统/网页授权、扫码、Skill stage、runner、工具调用或自动轮询。文字、图片/文件上传、空白或短确认消息、材料补充、确认回复和中途插话都按一条用户消息计数;同一条消息同时包含文字和图片/文件时仍只计一条。`USER_INPUT_ID` 是当前用户消息的本地幂等键:Agent 从首次触发本 Skill 的用户消息开始,在当前对话内给每条新用户消息分配单调序号,并在同一消息的重试中复用同一值。`USER_INPUT_ID` 不得包含或派生自用户输入内容、文件名、路径、截图/OCR、业务材料、stage 名或工具调用序号;运行时只保存其本地 hash,不上报。
54
+
55
+ `start-run` 自动把触发当前 run 的首条用户输入计为 `before-flow`;若中断/压缩后用新的 `USER_INPUT_ID` 重复进入同一未终态 run,`start-run` 会按当前 phase 幂等补计该用户消息。阻塞确认统一通过 `reply confirm --reply "$USER_REPLY" --input-id "$USER_INPUT_ID"`,该 runner 自动按当前 phase 幂等计数,禁止再为同一条确认回复额外执行 `telemetry count-user-input`。其他不会经过 `reply confirm` 或 onboarding recovery 的用户输入,包括用户中途打断、补充材料、只上传图片/文件或只问问题,在继续任何 Skill 动作或对该输入作业务答复前按当前 phase 执行一次 `node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" telemetry count-user-input --phase before-flow|after-flow --input-id "$USER_INPUT_ID"`;重复同一 `USER_INPUT_ID` 不加计。`*.user_confirmed` 由 flow loader 自动标记起点但不计数,after-flow 从其后的下一条用户消息开始,前置澄清和候选不计 after-flow,`full_process` 不因 Onboarding 重置。closeout 默认从本地 run state 派生计数;状态为空时终态使用首条输入的最小合法计数,状态不可用且已核对时才显式传三项计数参数,runner 拒绝缺项、负数、`after > total`、已观测 flow start 但 `after >= total` 等明显错误。不新增业务确认点或独立上报;入队后当前 `run.terminal` 文件做短超时前台 drain,失败仍保留 outbox 且不影响业务收口,网络类失败按维护文档短重试/后台兜底。脚本以当前 `run_id` 为 `PLATFORM_ID`,Agent 不手写环境前缀或改 MCP payload;维护诊断、outbox、上传和 flush 细节只在 `normal/telemetry.md` 按需读取。
52
56
 
53
57
  三种入口均只在无法从已有产品名称或业务描述可靠确定唯一产品时执行 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
58