@alipay/alipay-aipay 1.6.8-beta3 → 1.6.8-beta4
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
package/skill/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.6.8-
|
|
1
|
+
1.6.8-beta4
|
|
@@ -362,7 +362,7 @@ function mccCatalogForAgent(records) {
|
|
|
362
362
|
|
|
363
363
|
function parseAgentCandidateRefs(args, records) {
|
|
364
364
|
const raw = optional(args, 'agent-candidate-refs-json');
|
|
365
|
-
if (raw === undefined) return {
|
|
365
|
+
if (raw === undefined) return { codes: [] };
|
|
366
366
|
let parsed;
|
|
367
367
|
try {
|
|
368
368
|
parsed = JSON.parse(raw);
|
|
@@ -380,7 +380,7 @@ function parseAgentCandidateRefs(args, records) {
|
|
|
380
380
|
}
|
|
381
381
|
codes.push(refs.get(ref));
|
|
382
382
|
}
|
|
383
|
-
return {
|
|
383
|
+
return { codes };
|
|
384
384
|
}
|
|
385
385
|
|
|
386
386
|
function mccTableSummary(records) {
|
|
@@ -323,6 +323,92 @@ mcc_semantic_retry_file() {
|
|
|
323
323
|
"$(mcc_cache_component "$sales_code")"
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
mcc_agent_review_file() {
|
|
327
|
+
local product_type="$1" sales_code="$2" root scope
|
|
328
|
+
root="$(mcc_cache_root)" || return 1
|
|
329
|
+
scope="$(mcc_cache_scope_id)" || return 1
|
|
330
|
+
if [ -e "$root" ] && { [ ! -d "$root" ] || [ -L "$root" ]; }; then
|
|
331
|
+
return 1
|
|
332
|
+
fi
|
|
333
|
+
mkdir -p "$root" 2>/dev/null || return 1
|
|
334
|
+
chmod 700 "$root" 2>/dev/null || true
|
|
335
|
+
printf '%s/%s.%s.%s.agent-reviews.json' \
|
|
336
|
+
"$root" \
|
|
337
|
+
"$(mcc_cache_component "$scope")" \
|
|
338
|
+
"$(mcc_cache_component "$product_type")" \
|
|
339
|
+
"$(mcc_cache_component "$sales_code")"
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
mcc_agent_review_issued() {
|
|
343
|
+
local product_type="$1" sales_code="$2" input_id="$3" file
|
|
344
|
+
file="$(mcc_agent_review_file "$product_type" "$sales_code")" || return 1
|
|
345
|
+
[ -f "$file" ] && [ ! -L "$file" ] || return 1
|
|
346
|
+
jq -e \
|
|
347
|
+
--arg inputId "$input_id" \
|
|
348
|
+
'.schemaVersion == 1
|
|
349
|
+
and ((.entries // null) | type == "array")
|
|
350
|
+
and all(.entries[];
|
|
351
|
+
type == "object"
|
|
352
|
+
and ((.query // null) | type == "string")
|
|
353
|
+
and ((.inputId // null) | type == "string")
|
|
354
|
+
)
|
|
355
|
+
and any(.entries[]; .inputId == $inputId)' \
|
|
356
|
+
"$file" >/dev/null 2>&1
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
mark_mcc_agent_review_issued() {
|
|
360
|
+
local product_type="$1" sales_code="$2" query="$3" input_id="$4"
|
|
361
|
+
local file dir lock tmp
|
|
362
|
+
file="$(mcc_agent_review_file "$product_type" "$sales_code")" || return 1
|
|
363
|
+
dir="${file%/*}"
|
|
364
|
+
lock="${file}.lock"
|
|
365
|
+
if ! mkdir "$lock" 2>/dev/null; then
|
|
366
|
+
return 1
|
|
367
|
+
fi
|
|
368
|
+
if [ -e "$file" ] && { [ ! -f "$file" ] || [ -L "$file" ]; }; then
|
|
369
|
+
rmdir "$lock" 2>/dev/null || true
|
|
370
|
+
return 1
|
|
371
|
+
fi
|
|
372
|
+
tmp="$(mktemp "$dir/.mcc-agent-reviews.XXXXXX" 2>/dev/null)" || {
|
|
373
|
+
rmdir "$lock" 2>/dev/null || true
|
|
374
|
+
return 1
|
|
375
|
+
}
|
|
376
|
+
chmod 600 "$tmp" 2>/dev/null || true
|
|
377
|
+
if [ -f "$file" ]; then
|
|
378
|
+
if ! jq -ce \
|
|
379
|
+
--arg query "$query" \
|
|
380
|
+
--arg inputId "$input_id" '
|
|
381
|
+
if .schemaVersion != 1 or ((.entries // null) | type != "array") then
|
|
382
|
+
error("invalid MCC agent review state")
|
|
383
|
+
elif any(.entries[]; .query == $query and .inputId == $inputId) then
|
|
384
|
+
.
|
|
385
|
+
else
|
|
386
|
+
.entries += [{query: $query, inputId: $inputId}]
|
|
387
|
+
end
|
|
388
|
+
' "$file" >"$tmp" 2>/dev/null; then
|
|
389
|
+
rm -f "$tmp" 2>/dev/null || true
|
|
390
|
+
rmdir "$lock" 2>/dev/null || true
|
|
391
|
+
return 1
|
|
392
|
+
fi
|
|
393
|
+
else
|
|
394
|
+
if ! jq -cn \
|
|
395
|
+
--arg query "$query" \
|
|
396
|
+
--arg inputId "$input_id" \
|
|
397
|
+
'{schemaVersion: 1, entries: [{query: $query, inputId: $inputId}]}' \
|
|
398
|
+
>"$tmp" 2>/dev/null; then
|
|
399
|
+
rm -f "$tmp" 2>/dev/null || true
|
|
400
|
+
rmdir "$lock" 2>/dev/null || true
|
|
401
|
+
return 1
|
|
402
|
+
fi
|
|
403
|
+
fi
|
|
404
|
+
if ! mv "$tmp" "$file" 2>/dev/null; then
|
|
405
|
+
rm -f "$tmp" 2>/dev/null || true
|
|
406
|
+
rmdir "$lock" 2>/dev/null || true
|
|
407
|
+
return 1
|
|
408
|
+
fi
|
|
409
|
+
rmdir "$lock" 2>/dev/null || true
|
|
410
|
+
}
|
|
411
|
+
|
|
326
412
|
claim_mcc_semantic_retry() {
|
|
327
413
|
local product_type="$1" sales_code="$2" query="$3" input_id="$4" semantic_terms_json="$5"
|
|
328
414
|
local file dir lock entry original_query retry_count next_retry_count now tmp lock_acquired=false
|
|
@@ -654,6 +740,15 @@ query_mcc_detail_chunk() {
|
|
|
654
740
|
printf '%s' "$business"
|
|
655
741
|
}
|
|
656
742
|
|
|
743
|
+
mcc_match_error_kind() {
|
|
744
|
+
case "$1" in
|
|
745
|
+
*agent-candidate-refs-json*) printf 'INVALID_AGENT_CANDIDATE_REFS' ;;
|
|
746
|
+
*semantic-terms-json*) printf 'INVALID_SEMANTIC_TERMS' ;;
|
|
747
|
+
*mcc-catalog-json*) printf 'INVALID_DYNAMIC_CATALOG' ;;
|
|
748
|
+
*) printf 'MATCHER_RUNTIME_ERROR' ;;
|
|
749
|
+
esac
|
|
750
|
+
}
|
|
751
|
+
|
|
657
752
|
normalize_mcc_catalog() {
|
|
658
753
|
local rows_json="$1" details_json="$2"
|
|
659
754
|
jq -cn --argjson rows "$rows_json" --argjson details "$details_json" '
|
|
@@ -713,6 +808,7 @@ normalize_mcc_catalog() {
|
|
|
713
808
|
|
|
714
809
|
run_mcc_match_codes() {
|
|
715
810
|
local query="$1" product_type="$2" root_intent="$3" catalog="$4" semantic_terms_json="$5" agent_candidate_refs_json="${6:-}" runner_out runner_err runner_rc line resolution=""
|
|
811
|
+
local runner_error error_kind
|
|
716
812
|
runner_out=$(mktemp "${TMPDIR:-/tmp}/mcc_match_out.XXXXXX") || { echo "❌ 创建临时文件失败"; exit 1; }
|
|
717
813
|
runner_err=$(mktemp "${TMPDIR:-/tmp}/mcc_match_err.XXXXXX") || { rm -f "$runner_out"; echo "❌ 创建临时文件失败"; exit 1; }
|
|
718
814
|
local node_args=(
|
|
@@ -729,7 +825,16 @@ run_mcc_match_codes() {
|
|
|
729
825
|
"${NODE_BINARY:-node}" "${node_args[@]}" >"$runner_out" 2>"$runner_err"
|
|
730
826
|
runner_rc=$?
|
|
731
827
|
if [ "$runner_rc" -ne 0 ] || [ -s "$runner_out" ]; then
|
|
828
|
+
runner_error="$(sed -n 's/^ONBOARDING_MESSAGE_ERROR://p' "$runner_err" | sed -n '1p')"
|
|
829
|
+
error_kind="$(mcc_match_error_kind "$runner_error")"
|
|
830
|
+
if [ "$error_kind" = "INVALID_AGENT_CANDIDATE_REFS" ] && [ -n "$agent_candidate_refs_json" ]; then
|
|
831
|
+
rm -f "$runner_out" "$runner_err"
|
|
832
|
+
emit_control "MCC_AGENT_CANDIDATE_REFS_IGNORED=INVALID"
|
|
833
|
+
run_mcc_match_codes "$query" "$product_type" "$root_intent" "$catalog" "$semantic_terms_json"
|
|
834
|
+
return $?
|
|
835
|
+
fi
|
|
732
836
|
rm -f "$runner_out" "$runner_err"
|
|
837
|
+
emit_control "MCC_MATCH_ERROR=$error_kind"
|
|
733
838
|
mcc_query_failed
|
|
734
839
|
fi
|
|
735
840
|
while IFS= read -r line; do
|
|
@@ -754,7 +859,7 @@ validate_mcc_selection_cache() {
|
|
|
754
859
|
}
|
|
755
860
|
|
|
756
861
|
run_resolve_plan() {
|
|
757
|
-
local query="" product_type="" root_intent="" semantic_terms_json='[]' agent_candidate_refs_json="" select_value="" selection_receipt="" input_id="" sales_code tree rows tree_catalog resolution match_type semantic_status full_codes candidate_rows qualification_rows details catalog selection_cache="" used_selection_cache=false stale_selection=false resolved_semantic_terms='[]'
|
|
862
|
+
local query="" product_type="" root_intent="" semantic_terms_json='[]' agent_candidate_refs_json="" select_value="" selection_receipt="" input_id="" sales_code tree rows tree_catalog resolution match_type semantic_status full_codes candidate_rows qualification_rows details catalog selection_cache="" used_selection_cache=false stale_selection=false resolved_semantic_terms='[]' retry_rc=0 next_retry_count=0 retry_reason="" retry_payload="" agent_review_required="false" agent_review_payload=""
|
|
758
863
|
shift
|
|
759
864
|
while [[ $# -gt 0 ]]; do
|
|
760
865
|
case "$1" in
|
|
@@ -840,20 +945,25 @@ run_resolve_plan() {
|
|
|
840
945
|
semantic_status=$(printf '%s' "$resolution" | jq -r '.semanticStatus // ""' 2>/dev/null) || mcc_query_failed
|
|
841
946
|
resolved_semantic_terms=$(printf '%s' "$resolution" | jq -c '.semanticTerms // []' 2>/dev/null) || mcc_query_failed
|
|
842
947
|
agent_review_required=$(printf '%s' "$resolution" | jq -r '.agentReview.required // false' 2>/dev/null) || mcc_query_failed
|
|
948
|
+
if [ -n "$input_id" ] && [ -n "$agent_candidate_refs_json" ]; then
|
|
949
|
+
mark_mcc_agent_review_issued "$product_type" "$sales_code" "$query" "$input_id" || true
|
|
950
|
+
fi
|
|
843
951
|
if [ "$agent_review_required" = "true" ] && [ -z "$agent_candidate_refs_json" ] && [ -n "$input_id" ]; then
|
|
844
952
|
agent_review_payload=$(printf '%s' "$resolution" | jq -c '.agentReview' 2>/dev/null) || mcc_query_failed
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
953
|
+
if ! mcc_agent_review_issued "$product_type" "$sales_code" "$input_id"; then
|
|
954
|
+
mark_mcc_agent_review_issued "$product_type" "$sales_code" "$query" "$input_id" || true
|
|
955
|
+
emit_control "MCC_QUERY_RESULT=SUCCESS"
|
|
956
|
+
emit_control "MCC_RESOLUTION=$(printf '%s' "$resolution" | jq -c 'del(.agentReview)' 2>/dev/null)"
|
|
957
|
+
emit_control "MCC_AGENT_REVIEW_REQUIRED=$agent_review_payload"
|
|
958
|
+
return 0
|
|
959
|
+
fi
|
|
849
960
|
fi
|
|
850
961
|
if [ "$match_type" = "NONE" ] \
|
|
851
962
|
&& [ "$semantic_status" != "DYNAMIC_CATALOG_CODE_NOT_FOUND" ] \
|
|
852
963
|
&& [ "$semantic_status" != "DYNAMIC_CATALOG_CODE_AMBIGUOUS" ]; then
|
|
853
964
|
if [ -n "$input_id" ]; then
|
|
854
|
-
retry_input_id="$input_id"
|
|
855
965
|
next_retry_count="$(claim_mcc_semantic_retry \
|
|
856
|
-
"$product_type" "$sales_code" "$query" "$
|
|
966
|
+
"$product_type" "$sales_code" "$query" "$input_id" "$resolved_semantic_terms" 2>/dev/null)"
|
|
857
967
|
retry_rc=$?
|
|
858
968
|
else
|
|
859
969
|
# A retry without a message identity cannot be bound to one user input.
|