@tomflow/chatloop-context 0.6.32 → 0.6.33
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/lib/approval-policy.mjs +27 -6
- package/package.json +2 -2
package/lib/approval-policy.mjs
CHANGED
|
@@ -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]!==
|
|
40
|
-
|
|
41
|
-
|
|
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
|
|
44
|
-
|
|
45
|
-
|
|
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.
|
|
3
|
+
"version": "0.6.33",
|
|
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.
|
|
35
|
+
"@tomflow/chatloop-extension": "0.4.35",
|
|
36
36
|
"@tomflow/chatloop-trace": "0.4.6"
|
|
37
37
|
}
|
|
38
38
|
}
|