@tomflow/chatloop-context 0.6.32 → 0.6.34

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.
@@ -36,13 +36,23 @@ const formReceipt=(text,kind,stored)=>{
36
36
  [,formId,traceRef,version,label]=m;
37
37
  }else{
38
38
  const lines=text.split(/\r?\n/).map(x=>x.trim()).filter(Boolean);
39
- if(lines.length!==6||lines[0]!=='Chat Loop Form 提交结果(由用户点击表单提交)'
40
- ||lines[3]!=='选项值: A'||lines[5]!==FORM_NOTE)return null;
41
- const id=lines[1].match(new RegExp('^formId:\\s*('+FORM_UUID+')$','i'));
39
+ if(lines.length!==6||lines[0]!==FORM_HEADER
40
+ ||!['选项值: A','选项值: approve'].includes(lines[3])
41
+ ||lines[5]!==FORM_NOTE)return null;
42
+ const id=lines[1].match(/^formId:\s*([a-z0-9][a-z0-9_-]{7,127})$/i);
42
43
  const trace=lines[2].match(new RegExp('^traceRef:\\s*('+FORM_UUID+')$','i'));
43
- const choice=lines[4].match(/^选项标签:\s*A[||]\s*确认当前\s*([RP][1-9][0-9]*)\s*(需求|技术与验证方案|技术方案|方案)$/i);
44
- if(!id||!trace||!choice)return null;
45
- formId=id[1];traceRef=trace[1];version=choice[1];label=choice[2];
44
+ const oldChoice=lines[4].match(/^选项标签:\s*A[||]\s*确认当前\s*([RP][1-9][0-9]*)\s*(需求|技术与验证方案|技术方案|方案)$/i);
45
+ const modernChoice=lines[3]==='选项值: approve'
46
+ &&lines[4].match(/^选项标签:\s*A[||]\s*确认(需求|技术与验证方案|技术方案|方案)$/);
47
+ if(!id||!trace||!oldChoice&&!modernChoice)return null;
48
+ formId=id[1];traceRef=trace[1];
49
+ const versions=[...formId.matchAll(/(?:^|[-_])([rp][1-9][0-9]*)(?=[-_]|$)/gi)]
50
+ .map(m=>m[1].toUpperCase());
51
+ version=oldChoice?.[1]
52
+ ||(modernChoice&&versions.length===1?versions[0]:null);
53
+ label=oldChoice?.[2]||modernChoice?.[1];
54
+ if(!version||oldChoice&&versions.some(v=>v!==version.toUpperCase()))
55
+ return null;
46
56
  }
47
57
  version=version.toUpperCase();
48
58
  if(!versionedLabel(version,label,kind)
@@ -73,5 +83,16 @@ export function approvedTurnSourceMatches(record,observed,kind){
73
83
  &&stored.version===actual.version&&stored.label===actual.label
74
84
  &&stored.version===observed.version);
75
85
  }
86
+ // Current workflow records only a bounded soft receipt in approval.observe.
87
+ // A matching original six-line user Turn and both independent identifiers
88
+ // are mandatory; this summary is never itself browser approval evidence.
89
+ const summary=typeof record.userTurn==='string'&&record.userTurn.match(
90
+ /^user-turn:UNAVAILABLE; form:([a-z0-9][a-z0-9_-]{7,127}); trace:([0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}); approve$/i);
91
+ if(summary){
92
+ const actual=formReceipt(observed.userText,kind,false);
93
+ return Boolean(actual&&actual.formId===summary[1].toLowerCase()
94
+ &&actual.traceRef===summary[2].toLowerCase()
95
+ &&actual.version===observed.version);
96
+ }
76
97
  return record.userTurn===observed.userText||record.userTurn===observed.userKey;
77
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomflow/chatloop-context",
3
- "version": "0.6.32",
3
+ "version": "0.6.34",
4
4
  "type": "module",
5
5
  "description": "Independent local Context SDK and short-lived CLI for Chat Loop projects",
6
6
  "publishConfig": {
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "ps-list": "9.0.0",
35
- "@tomflow/chatloop-extension": "0.4.34",
35
+ "@tomflow/chatloop-extension": "0.4.36",
36
36
  "@tomflow/chatloop-trace": "0.4.6"
37
37
  }
38
38
  }