@xqyz/xq-cli 0.3.14 → 0.3.16
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/CHANGELOG.md +20 -1
- package/README.md +12 -0
- package/package.json +1 -1
- package/src/cli.mjs +1044 -43
package/src/cli.mjs
CHANGED
|
@@ -40,6 +40,7 @@ const DEFAULT_TIMEOUT_MS = 10 * 60 * 1000;
|
|
|
40
40
|
// outline polling timeout.
|
|
41
41
|
const DEFAULT_PARSER_WAKEUP_TIMEOUT_MS = 30_000;
|
|
42
42
|
const PARSER_WAKEUP_INTERVAL_MS = 2_000;
|
|
43
|
+
const KNOWN_PARSE_SUCCESS_CODES = new Set([0, 1, 2, 3, 4]);
|
|
43
44
|
const DEFAULT_SOURCE_FROM = 'xique';
|
|
44
45
|
const DEFAULT_LOGIN_TIMEOUT_MS = 5 * 60 * 1000;
|
|
45
46
|
const API_KEY_MANAGEMENT_URL = 'https://xiquebiaoshu.com/account/api-keys';
|
|
@@ -397,9 +398,32 @@ async function main() {
|
|
|
397
398
|
case 'period-confirm':
|
|
398
399
|
await handlePeriodConfirm(parsed, state);
|
|
399
400
|
return;
|
|
401
|
+
case 'page-scope-status':
|
|
402
|
+
await handlePageScopeStatus(parsed, state);
|
|
403
|
+
return;
|
|
404
|
+
case 'page-scope-accept':
|
|
405
|
+
await handlePageScopeAccept(parsed, state);
|
|
406
|
+
return;
|
|
407
|
+
case 'commercial-status':
|
|
408
|
+
await handleCommercialStatus(parsed, state);
|
|
409
|
+
return;
|
|
410
|
+
case 'commercial-confirm':
|
|
411
|
+
await handleCommercialConfirm(parsed, state);
|
|
412
|
+
return;
|
|
413
|
+
case 'company-list':
|
|
414
|
+
await handleCompanyList(parsed, state);
|
|
415
|
+
return;
|
|
400
416
|
case 'bidder-role':
|
|
401
417
|
await handleBidderRole(parsed, state);
|
|
402
418
|
return;
|
|
419
|
+
case 'basis-select':
|
|
420
|
+
case 'directory-basis':
|
|
421
|
+
await handleBasisSelection(parsed, state);
|
|
422
|
+
return;
|
|
423
|
+
case 'supplement':
|
|
424
|
+
case 'score-supplement':
|
|
425
|
+
await handleSupplement(parsed, state);
|
|
426
|
+
return;
|
|
403
427
|
case 'outline':
|
|
404
428
|
if (isOutlineAction(parsed, ['view', 'show'])) {
|
|
405
429
|
await handleOutlineView(parsed, state);
|
|
@@ -469,7 +493,14 @@ Commands
|
|
|
469
493
|
parse-status Query or wait for parse completion
|
|
470
494
|
period-status Query engineering project period confirmation status
|
|
471
495
|
period-confirm Save confirmed engineering project period
|
|
496
|
+
page-scope-status Check whether the current outline supports the selected page scope
|
|
497
|
+
page-scope-accept Accept the backend's recommended page scope
|
|
498
|
+
commercial-status Query commercial bid framework status
|
|
499
|
+
commercial-confirm Confirm use of the commercial default framework
|
|
500
|
+
company-list Query selectable bidder companies for commercial bids
|
|
472
501
|
bidder-role Save the bidder's goods supply method for the current task
|
|
502
|
+
basis-select Save the parsing-stage outline basis for the current task
|
|
503
|
+
supplement Submit missing requirement / bill / score / directory content and continue the same task
|
|
473
504
|
outline Pre-set task params and trigger outline generation
|
|
474
505
|
outline view View the current outline without triggering generation
|
|
475
506
|
outline update Update the current outline from an edited JSON file
|
|
@@ -501,7 +532,13 @@ Examples
|
|
|
501
532
|
$env:XQ_API_KEY="xq_sk_xxx"
|
|
502
533
|
xq-cli init --file D:\\bids\\tender.docx --wait
|
|
503
534
|
xq-cli parse-status --cid <cid> --uuid <uuid> --wait
|
|
535
|
+
xq-cli commercial-status --cid <cid> --wait
|
|
536
|
+
xq-cli commercial-confirm --cid <cid> --wait
|
|
537
|
+
xq-cli company-list --json
|
|
504
538
|
xq-cli bidder-role --cid <cid> --uuid <uuid> --bidder-role <1|2>
|
|
539
|
+
xq-cli basis-select --cid <cid> --uuid <uuid> --basis <scoreAndDir|scoreOnly|dirOnly> --wait
|
|
540
|
+
xq-cli supplement --cid <cid> --uuid <uuid> --type score --text "评分细则..." --wait
|
|
541
|
+
xq-cli supplement --cid <cid> --uuid <uuid> --type score --file D:\\bids\\score.docx --wait
|
|
505
542
|
xq-cli choices
|
|
506
543
|
xq-cli choices outline --json
|
|
507
544
|
xq-cli gallery-status --json
|
|
@@ -541,13 +578,19 @@ Common options
|
|
|
541
578
|
--timeout-sec <n> Poll timeout in seconds, default 600
|
|
542
579
|
--interval-sec <n> Poll interval in seconds, default 10
|
|
543
580
|
--reference-type <0|1|2> Outline reference choice: 0=merge, 1=format only, 2=score only
|
|
581
|
+
--basis <scoreAndDir|scoreOnly|dirOnly> Parsing-stage outline basis choice
|
|
544
582
|
--bidder-role <1|2> Goods supply method: 1=self production, 2=procured supply
|
|
583
|
+
--supplement-type/--type <type> Missing content type: score, requirement, billOfQuantities, or directory
|
|
584
|
+
--text <content> Text content for a supplement (HTML is accepted)
|
|
585
|
+
--file <path> Supplement file path (.doc/.docx/.pdf/.xls/.xlsx)
|
|
586
|
+
--ignore Explicitly skip a skippable missing-content check
|
|
545
587
|
--api-key <key> Save a user API key locally and verify it with /user/info
|
|
546
588
|
--no-open Do not open the local login page automatically
|
|
547
589
|
--interactive Open prompt menus for the current command
|
|
548
590
|
--dry-run Preview an outline update without saving it
|
|
549
591
|
--yes Confirm an outline update without an interactive prompt
|
|
550
592
|
--allow-delete Allow an outline update that removes existing chapters
|
|
593
|
+
--check-id <id> Page-scope check ID returned by page-scope-status
|
|
551
594
|
--ignore-short-requirement Follow the frontend ignore/continue path for requirement_judgement=0
|
|
552
595
|
--ignore-missing-bill Follow the frontend ignore/continue path for billOfQuantities_judgement=0
|
|
553
596
|
|
|
@@ -771,6 +814,7 @@ async function handleInit(args, state) {
|
|
|
771
814
|
cid,
|
|
772
815
|
uuid: snapshot.uuid,
|
|
773
816
|
title: snapshot.projectName || snapshot.title,
|
|
817
|
+
originType: snapshot.originType,
|
|
774
818
|
files,
|
|
775
819
|
fileTypes: fileMeta.types,
|
|
776
820
|
parseResult: finalParse,
|
|
@@ -880,6 +924,216 @@ async function handlePeriodConfirm(args, state) {
|
|
|
880
924
|
return payload;
|
|
881
925
|
}
|
|
882
926
|
|
|
927
|
+
async function handlePageScopeStatus(args, state) {
|
|
928
|
+
const client = createAuthorizedClient(args, state);
|
|
929
|
+
const cid = resolveCid(args, state);
|
|
930
|
+
const result = await checkPageScopeBeforeWrite(client, state, cid, args);
|
|
931
|
+
const payload = {
|
|
932
|
+
command: 'page-scope-status',
|
|
933
|
+
cid,
|
|
934
|
+
...result,
|
|
935
|
+
};
|
|
936
|
+
outputResult(args, payload, [
|
|
937
|
+
`page-scope check: cid=${cid}`,
|
|
938
|
+
`phase: ${result.phase}`,
|
|
939
|
+
`checkStatus: ${result.pageScopeResult?.checkStatus ?? '-'}`,
|
|
940
|
+
result.phase === 'confirmation_required'
|
|
941
|
+
? `confirmation required: target=${result.pageScopeResult?.targetPageScope ?? '-'}, recommended=${result.pageScopeResult?.recommendedPageScope ?? '-'}`
|
|
942
|
+
: result.phase === 'passed'
|
|
943
|
+
? 'selected page scope is supported by the current outline'
|
|
944
|
+
: 'page-scope response is not recognized; do not start content generation',
|
|
945
|
+
]);
|
|
946
|
+
return payload;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
async function handlePageScopeAccept(args, state) {
|
|
950
|
+
const client = createAuthorizedClient(args, state);
|
|
951
|
+
const cid = resolveCid(args, state);
|
|
952
|
+
const checkId = requiredOption(args, 'checkId');
|
|
953
|
+
const authoritativeState = await fetchAuthoritativeTaskState(client, cid);
|
|
954
|
+
assertContentGenerationAllowed(authoritativeState, '接受建议篇幅');
|
|
955
|
+
const response = await postJson(client, '/task/acceptRecommendedPageScope', {
|
|
956
|
+
cid,
|
|
957
|
+
checkId: String(checkId),
|
|
958
|
+
});
|
|
959
|
+
const payload = {
|
|
960
|
+
command: 'page-scope-accept',
|
|
961
|
+
cid,
|
|
962
|
+
checkId: String(checkId),
|
|
963
|
+
accepted: true,
|
|
964
|
+
response,
|
|
965
|
+
};
|
|
966
|
+
outputResult(args, payload, [
|
|
967
|
+
`recommended page scope accepted: cid=${cid}`,
|
|
968
|
+
`checkId: ${String(checkId)}`,
|
|
969
|
+
'content generation has not been triggered; rerun write for the same cid.',
|
|
970
|
+
]);
|
|
971
|
+
return payload;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
async function handleCommercialStatus(args, state) {
|
|
975
|
+
const client = createAuthorizedClient(args, state);
|
|
976
|
+
const cid = resolveCid(args, state);
|
|
977
|
+
const taskResponse = await getJson(client, `/task/getTaskDetail/${encodeURIComponent(cid)}`, {}, { retries: DEFAULT_RETRY_COUNT });
|
|
978
|
+
const taskDetail = taskResponse?.data || {};
|
|
979
|
+
const originType = Number(taskDetail.originType);
|
|
980
|
+
if (originType !== 3) {
|
|
981
|
+
const payload = {
|
|
982
|
+
command: 'commercial-status',
|
|
983
|
+
cid,
|
|
984
|
+
originType: taskDetail.originType,
|
|
985
|
+
phase: 'not-commercial',
|
|
986
|
+
commercial: false,
|
|
987
|
+
taskDetail,
|
|
988
|
+
};
|
|
989
|
+
outputResult(args, payload, [
|
|
990
|
+
`commercial framework: cid=${cid}`,
|
|
991
|
+
'commercial framework is not required for this task',
|
|
992
|
+
]);
|
|
993
|
+
return payload;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
const result = booleanOption(args, 'wait')
|
|
997
|
+
? await pollCommercialFrameworkUntilReady(client, cid, args)
|
|
998
|
+
: await fetchCommercialFrameworkStatus(client, cid);
|
|
999
|
+
const payload = {
|
|
1000
|
+
command: 'commercial-status',
|
|
1001
|
+
cid,
|
|
1002
|
+
originType,
|
|
1003
|
+
commercial: true,
|
|
1004
|
+
...result,
|
|
1005
|
+
};
|
|
1006
|
+
saveTaskSnapshot(state, cid, {
|
|
1007
|
+
originType,
|
|
1008
|
+
commercialFrameworkPhase: payload.phase,
|
|
1009
|
+
commercialFrameworkStatus: payload.data,
|
|
1010
|
+
commercialFrameworkCheckedAt: new Date().toISOString(),
|
|
1011
|
+
});
|
|
1012
|
+
outputResult(args, payload, [
|
|
1013
|
+
`commercial framework: cid=${cid}`,
|
|
1014
|
+
`phase: ${payload.phase}`,
|
|
1015
|
+
`task_status: ${payload.data?.task_status ?? '-'}`,
|
|
1016
|
+
`directories_ready: ${String(payload.data?.directories_ready ?? false)}`,
|
|
1017
|
+
payload.phase === 'commercial_default_template_required'
|
|
1018
|
+
? 'confirmation required: use the default commercial bid framework'
|
|
1019
|
+
: payload.phase === 'commercial_framework_ready'
|
|
1020
|
+
? 'commercial framework is ready; content generation may continue'
|
|
1021
|
+
: payload.phase === 'commercial_framework_failed'
|
|
1022
|
+
? `commercial framework failed: ${payload.data?.status_msg || payload.data?.status_message || '-'}`
|
|
1023
|
+
: 'commercial framework is still running',
|
|
1024
|
+
]);
|
|
1025
|
+
return payload;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
async function handleCommercialConfirm(args, state) {
|
|
1029
|
+
const client = createAuthorizedClient(args, state);
|
|
1030
|
+
const cid = resolveCid(args, state);
|
|
1031
|
+
const taskResponse = await getJson(client, `/task/getTaskDetail/${encodeURIComponent(cid)}`, {}, { retries: DEFAULT_RETRY_COUNT });
|
|
1032
|
+
if (Number(taskResponse?.data?.originType) !== 3) {
|
|
1033
|
+
throw new Error('当前任务不是商务标,无需确认默认标书框架。');
|
|
1034
|
+
}
|
|
1035
|
+
const response = await postJson(client, '/commercial/default-template/confirm', { cid });
|
|
1036
|
+
const status = booleanOption(args, 'wait')
|
|
1037
|
+
? await pollCommercialFrameworkUntilReady(client, cid, args)
|
|
1038
|
+
: await fetchCommercialFrameworkStatus(client, cid);
|
|
1039
|
+
const payload = {
|
|
1040
|
+
command: 'commercial-confirm',
|
|
1041
|
+
cid,
|
|
1042
|
+
confirmationResponse: response,
|
|
1043
|
+
...status,
|
|
1044
|
+
};
|
|
1045
|
+
saveTaskSnapshot(state, cid, {
|
|
1046
|
+
commercialFrameworkPhase: payload.phase,
|
|
1047
|
+
commercialFrameworkStatus: payload.data,
|
|
1048
|
+
commercialFrameworkConfirmedAt: new Date().toISOString(),
|
|
1049
|
+
});
|
|
1050
|
+
outputResult(args, payload, [
|
|
1051
|
+
`commercial framework confirmed: cid=${cid}`,
|
|
1052
|
+
`phase: ${payload.phase}`,
|
|
1053
|
+
payload.phase === 'commercial_framework_ready'
|
|
1054
|
+
? 'commercial framework is ready; content generation may continue'
|
|
1055
|
+
: 'commercial framework confirmation accepted; continue polling the same cid',
|
|
1056
|
+
]);
|
|
1057
|
+
return payload;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
async function handleCompanyList(args, state) {
|
|
1061
|
+
const client = createAuthorizedClient(args, state);
|
|
1062
|
+
const response = await postJson(client, '/xq/enterprise/company/list', {});
|
|
1063
|
+
const rawList = response?.data?.list ?? response?.data ?? [];
|
|
1064
|
+
const companies = (Array.isArray(rawList) ? rawList : [])
|
|
1065
|
+
.map(item => {
|
|
1066
|
+
if (!item || typeof item !== 'object') return null;
|
|
1067
|
+
const id = String(item.id ?? item.companyId ?? '').trim();
|
|
1068
|
+
const name = String(item.name ?? item.companyName ?? '').trim();
|
|
1069
|
+
if (!id || !name) return null;
|
|
1070
|
+
return {
|
|
1071
|
+
id,
|
|
1072
|
+
name,
|
|
1073
|
+
industry: String(item.industry ?? '').trim(),
|
|
1074
|
+
registeredCapital: String(item.registeredCapital ?? '').trim(),
|
|
1075
|
+
};
|
|
1076
|
+
})
|
|
1077
|
+
.filter(Boolean);
|
|
1078
|
+
const payload = {
|
|
1079
|
+
command: 'company-list',
|
|
1080
|
+
companies,
|
|
1081
|
+
total: companies.length,
|
|
1082
|
+
};
|
|
1083
|
+
outputResult(args, payload, [
|
|
1084
|
+
`bidder companies: ${companies.length}`,
|
|
1085
|
+
...companies.map(company => `${company.id}: ${company.name}`),
|
|
1086
|
+
]);
|
|
1087
|
+
return payload;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
async function fetchCommercialFrameworkStatus(client, cid) {
|
|
1091
|
+
const response = await getJson(client, '/commercial/task/status', { cid }, { retries: DEFAULT_RETRY_COUNT });
|
|
1092
|
+
const data = response?.data || {};
|
|
1093
|
+
return {
|
|
1094
|
+
phase: classifyCommercialFrameworkPhase(data),
|
|
1095
|
+
data,
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
async function pollCommercialFrameworkUntilReady(client, cid, args) {
|
|
1100
|
+
return pollUntil(async () => {
|
|
1101
|
+
const result = await fetchCommercialFrameworkStatus(client, cid);
|
|
1102
|
+
const terminal = [
|
|
1103
|
+
'commercial_framework_ready',
|
|
1104
|
+
'commercial_default_template_required',
|
|
1105
|
+
'commercial_framework_failed',
|
|
1106
|
+
].includes(result.phase);
|
|
1107
|
+
return {
|
|
1108
|
+
done: terminal,
|
|
1109
|
+
data: result,
|
|
1110
|
+
progressLabel: `phase=${result.phase}, task_status=${result.data?.task_status ?? '-'}, directories_ready=${String(result.data?.directories_ready ?? false)}`,
|
|
1111
|
+
};
|
|
1112
|
+
}, {
|
|
1113
|
+
intervalMs: secondsToMs(numberOption(args, 'intervalSec', DEFAULT_TASK_INTERVAL_MS / 1000)),
|
|
1114
|
+
timeoutMs: secondsToMs(numberOption(args, 'timeoutSec', DEFAULT_TIMEOUT_MS / 1000)),
|
|
1115
|
+
quiet: booleanOption(args, 'json'),
|
|
1116
|
+
waitingText: 'waiting commercial framework',
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
function classifyCommercialFrameworkPhase(data = {}) {
|
|
1121
|
+
const taskStatus = Number(data.task_status);
|
|
1122
|
+
const fallback = data.fallback_confirm_required === true
|
|
1123
|
+
|| data.fallback_confirm_required === 1
|
|
1124
|
+
|| ['1', 'true'].includes(String(data.fallback_confirm_required || '').trim().toLowerCase())
|
|
1125
|
+
|| taskStatus === 6;
|
|
1126
|
+
if (fallback) return 'commercial_default_template_required';
|
|
1127
|
+
// task_status=4 is downstream body processing; it does not mean the
|
|
1128
|
+
// commercial framework construction failed when directories are ready.
|
|
1129
|
+
if (taskStatus === 2) return 'commercial_framework_failed';
|
|
1130
|
+
const ready = [true, 1, '1', 'true'].includes(
|
|
1131
|
+
typeof data.directories_ready === 'string' ? data.directories_ready.trim().toLowerCase() : data.directories_ready,
|
|
1132
|
+
);
|
|
1133
|
+
if (ready) return 'commercial_framework_ready';
|
|
1134
|
+
return 'commercial_framework_pending';
|
|
1135
|
+
}
|
|
1136
|
+
|
|
883
1137
|
async function handleBidderRole(args, state) {
|
|
884
1138
|
const client = createAuthorizedClient(args, state);
|
|
885
1139
|
const cid = resolveCid(args, state);
|
|
@@ -915,6 +1169,312 @@ async function handleBidderRole(args, state) {
|
|
|
915
1169
|
return payload;
|
|
916
1170
|
}
|
|
917
1171
|
|
|
1172
|
+
async function handleBasisSelection(args, state) {
|
|
1173
|
+
const client = createAuthorizedClient(args, state);
|
|
1174
|
+
const cid = resolveCid(args, state);
|
|
1175
|
+
const snapshot = await hydrateTaskSnapshot(client, state, cid);
|
|
1176
|
+
const uuid = stringOption(args, 'uuid', snapshot.uuid);
|
|
1177
|
+
if (!uuid) {
|
|
1178
|
+
throw new Error(`No uuid found for task ${cid}. Pass --uuid explicitly or run init first.`);
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
const basis = normalizeDirectoryBasis(stringOptionAny(args, ['basis', 'directoryBasis']));
|
|
1182
|
+
if (!basis) {
|
|
1183
|
+
throw new Error('Option --basis expects scoreAndDir, scoreOnly, or dirOnly.');
|
|
1184
|
+
}
|
|
1185
|
+
if (snapshot.directoryBasisSubmittedAt) {
|
|
1186
|
+
if (snapshot.directoryBasis === basis) {
|
|
1187
|
+
const payload = {
|
|
1188
|
+
command: 'basis-select',
|
|
1189
|
+
cid,
|
|
1190
|
+
uuid,
|
|
1191
|
+
basis,
|
|
1192
|
+
alreadyApplied: true,
|
|
1193
|
+
duplicateRequestPrevented: true,
|
|
1194
|
+
};
|
|
1195
|
+
outputResult(args, payload, [
|
|
1196
|
+
`outline basis already applied: cid=${cid}, basis=${basis}`,
|
|
1197
|
+
'duplicate request prevented; continue querying the same task.',
|
|
1198
|
+
]);
|
|
1199
|
+
return payload;
|
|
1200
|
+
}
|
|
1201
|
+
throw new Error('该任务的解析阶段大纲依据已经提交,不能二次修改;请继续查询同一 cid。');
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
const parseStatus = await fetchParseStatus(client, state, cid, uuid);
|
|
1205
|
+
const issues = collectParseIssues(parseStatus);
|
|
1206
|
+
if (!issues.includes('scoreAndDirectory_judgement')) {
|
|
1207
|
+
throw new Error('当前任务不在解析阶段大纲依据选择状态,请先查询 parse-status。');
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
const response = await getJson(client, '/proxy/saveDirectoryBasis', {
|
|
1211
|
+
uuid,
|
|
1212
|
+
basis,
|
|
1213
|
+
});
|
|
1214
|
+
saveTaskSnapshot(state, cid, {
|
|
1215
|
+
uuid,
|
|
1216
|
+
directoryBasis: basis,
|
|
1217
|
+
directoryBasisSubmittedAt: new Date().toISOString(),
|
|
1218
|
+
directoryBasisIssue: 'scoreAndDirectory_judgement',
|
|
1219
|
+
});
|
|
1220
|
+
|
|
1221
|
+
const waitResult = booleanOption(args, 'wait')
|
|
1222
|
+
? await waitAfterSupplement(client, state, cid, uuid, args, 'scoreAndDirectory_judgement')
|
|
1223
|
+
: null;
|
|
1224
|
+
const payload = {
|
|
1225
|
+
command: 'basis-select',
|
|
1226
|
+
cid,
|
|
1227
|
+
uuid,
|
|
1228
|
+
basis,
|
|
1229
|
+
response,
|
|
1230
|
+
waitResult,
|
|
1231
|
+
};
|
|
1232
|
+
outputResult(args, payload, [
|
|
1233
|
+
`outline basis submitted: cid=${cid}`,
|
|
1234
|
+
`basis: ${basis} (${describeDirectoryBasis(basis)})`,
|
|
1235
|
+
waitResult?.phase === 'ready'
|
|
1236
|
+
? 'same task outline is ready for review.'
|
|
1237
|
+
: waitResult?.phase === 'analysis_ready'
|
|
1238
|
+
? 'same task analysis is ready; confirm outline generation next.'
|
|
1239
|
+
: waitResult?.phase === 'basis_selection_required'
|
|
1240
|
+
? 'same task still requires outline basis selection; do not submit a second choice.'
|
|
1241
|
+
: waitResult?.phase === 'reference_selection_required'
|
|
1242
|
+
? 'same task now requires an explicit outline reference selection.'
|
|
1243
|
+
: waitResult?.phase === 'bidder_role_required'
|
|
1244
|
+
? 'same task now requires a bidder supply-role selection.'
|
|
1245
|
+
: booleanOption(args, 'wait')
|
|
1246
|
+
? 'same task is continuing; query status for the next stage.'
|
|
1247
|
+
: 'submission accepted; use parse-status or outline --wait to continue polling the same task.',
|
|
1248
|
+
]);
|
|
1249
|
+
return payload;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
function normalizeDirectoryBasis(value) {
|
|
1253
|
+
const normalized = String(value || '').trim().toLowerCase();
|
|
1254
|
+
const aliases = {
|
|
1255
|
+
scoreanddir: 'scoreAndDir',
|
|
1256
|
+
scoreanddirectory: 'scoreAndDir',
|
|
1257
|
+
merge: 'scoreAndDir',
|
|
1258
|
+
'融合评分和参考目录': 'scoreAndDir',
|
|
1259
|
+
scoreonly: 'scoreOnly',
|
|
1260
|
+
score: 'scoreOnly',
|
|
1261
|
+
'仅依据评分': 'scoreOnly',
|
|
1262
|
+
dironly: 'dirOnly',
|
|
1263
|
+
directoryonly: 'dirOnly',
|
|
1264
|
+
format: 'dirOnly',
|
|
1265
|
+
'仅依据参考目录': 'dirOnly',
|
|
1266
|
+
};
|
|
1267
|
+
return aliases[normalized] || aliases[String(value || '').trim()] || '';
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
function describeDirectoryBasis(value) {
|
|
1271
|
+
return {
|
|
1272
|
+
scoreAndDir: '融合评分和参考目录',
|
|
1273
|
+
scoreOnly: '仅依据评分',
|
|
1274
|
+
dirOnly: '仅依据参考目录',
|
|
1275
|
+
}[value] || value;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
async function handleSupplement(args, state) {
|
|
1279
|
+
const client = createAuthorizedClient(args, state);
|
|
1280
|
+
const cid = resolveCid(args, state);
|
|
1281
|
+
const snapshot = await hydrateTaskSnapshot(client, state, cid);
|
|
1282
|
+
const uuid = stringOption(args, 'uuid', snapshot.uuid);
|
|
1283
|
+
if (!uuid) {
|
|
1284
|
+
throw new Error(`No uuid found for task ${cid}. Pass --uuid explicitly or run init first.`);
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
const issue = normalizeSupplementIssue(stringOptionAny(args, ['issue', 'supplementIssue']));
|
|
1288
|
+
const type = normalizeSupplementType(stringOptionAny(args, ['supplementType', 'type']), issue);
|
|
1289
|
+
const filePath = stringOption(args, 'file', stringOption(args, 'scoreFile'));
|
|
1290
|
+
const text = stringOptionAny(args, ['text', 'content', 'score', 'requirement', 'directory']);
|
|
1291
|
+
const ignore = booleanOption(args, 'ignore');
|
|
1292
|
+
if (filePath && text) {
|
|
1293
|
+
throw new Error('补充内容只能选择 --text 或 --file 其中一种。');
|
|
1294
|
+
}
|
|
1295
|
+
if (!ignore && !filePath && !text) {
|
|
1296
|
+
throw new Error('补充内容需要 --text <内容> 或 --file <路径>;跳过可补充项时才使用 --ignore。');
|
|
1297
|
+
}
|
|
1298
|
+
if (ignore && (filePath || text)) {
|
|
1299
|
+
throw new Error('--ignore 不能和 --text/--file 同时使用。');
|
|
1300
|
+
}
|
|
1301
|
+
if (!ignore && type === 'billOfQuantities' && text && !filePath) {
|
|
1302
|
+
throw new Error('工程量清单请使用 --file 上传,网页端不支持直接输入文本。');
|
|
1303
|
+
}
|
|
1304
|
+
if (!ignore && type === 'directory' && filePath) {
|
|
1305
|
+
throw new Error('技术方案目录要求请使用 --text 输入,网页端不支持以文件补充。');
|
|
1306
|
+
}
|
|
1307
|
+
if (filePath) {
|
|
1308
|
+
ensureFileExists(filePath);
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
const currentIssues = collectParseIssues(await fetchParseStatus(client, state, cid, uuid));
|
|
1312
|
+
const targetIssue = issue || currentIssues.find(item => issueType(item) === type) || currentIssues[0] || '';
|
|
1313
|
+
if (ignore && (!targetIssue || !AUTO_IGNORE_ISSUE_CONFIG[targetIssue])) {
|
|
1314
|
+
throw new Error('当前任务没有可忽略的对应解析问题;请传 --issue <问题字段>,或使用评分/需求补充内容。');
|
|
1315
|
+
}
|
|
1316
|
+
const payload = ignore
|
|
1317
|
+
? AUTO_IGNORE_ISSUE_CONFIG[targetIssue].buildPayload(uuid)
|
|
1318
|
+
: filePath
|
|
1319
|
+
? null
|
|
1320
|
+
: buildSupplementPayload(uuid, type, text);
|
|
1321
|
+
const response = filePath
|
|
1322
|
+
? await submitSupplementFile(client, uuid, type, filePath)
|
|
1323
|
+
: await submitIntermediateChoice(client, payload);
|
|
1324
|
+
|
|
1325
|
+
saveTaskSnapshot(state, cid, {
|
|
1326
|
+
uuid,
|
|
1327
|
+
supplementIssue: targetIssue,
|
|
1328
|
+
supplementType: type,
|
|
1329
|
+
supplementSubmittedAt: new Date().toISOString(),
|
|
1330
|
+
...(ignore ? { [targetIssue + '_ignored']: true } : {}),
|
|
1331
|
+
});
|
|
1332
|
+
|
|
1333
|
+
const waitResult = booleanOption(args, 'wait')
|
|
1334
|
+
? await waitAfterSupplement(client, state, cid, uuid, args, targetIssue)
|
|
1335
|
+
: null;
|
|
1336
|
+
const resultPayload = {
|
|
1337
|
+
command: 'supplement',
|
|
1338
|
+
cid,
|
|
1339
|
+
uuid,
|
|
1340
|
+
issue: targetIssue || null,
|
|
1341
|
+
type,
|
|
1342
|
+
mode: ignore ? 'ignore' : filePath ? 'file' : 'text',
|
|
1343
|
+
file: filePath || null,
|
|
1344
|
+
response,
|
|
1345
|
+
waitResult,
|
|
1346
|
+
};
|
|
1347
|
+
outputResult(args, resultPayload, [
|
|
1348
|
+
`supplement submitted: cid=${cid}`,
|
|
1349
|
+
`type: ${type}`,
|
|
1350
|
+
`mode: ${resultPayload.mode}`,
|
|
1351
|
+
targetIssue ? `issue: ${targetIssue}` : '',
|
|
1352
|
+
waitResult?.phase === 'ready'
|
|
1353
|
+
? 'same task outline is ready for review.'
|
|
1354
|
+
: waitResult?.phase === 'analysis_ready'
|
|
1355
|
+
? 'same task analysis is ready; confirm outline generation next.'
|
|
1356
|
+
: waitResult?.phase === 'basis_selection_required'
|
|
1357
|
+
? 'same task now requires an explicit parsing-stage outline basis selection.'
|
|
1358
|
+
: waitResult?.phase === 'reference_selection_required'
|
|
1359
|
+
? 'same task now requires an explicit outline reference selection.'
|
|
1360
|
+
: waitResult?.phase === 'bidder_role_required'
|
|
1361
|
+
? 'same task now requires a bidder supply-role selection.'
|
|
1362
|
+
: booleanOption(args, 'wait')
|
|
1363
|
+
? 'same task is continuing; query status for the next stage.'
|
|
1364
|
+
: 'submission accepted; use --wait to continue polling the same task.',
|
|
1365
|
+
].filter(Boolean));
|
|
1366
|
+
return resultPayload;
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
function normalizeSupplementIssue(value) {
|
|
1370
|
+
if (!value) return '';
|
|
1371
|
+
const aliases = {
|
|
1372
|
+
requirement: 'requirement_exist',
|
|
1373
|
+
requirement_short: 'requirement_judgement',
|
|
1374
|
+
bill: 'billOfQuantities_judgement',
|
|
1375
|
+
billOfQuantities: 'billOfQuantities_judgement',
|
|
1376
|
+
score: 'score_judgement',
|
|
1377
|
+
directory: 'directory_judgement',
|
|
1378
|
+
basis: 'scoreAndDirectory_judgement',
|
|
1379
|
+
bidder: 'bidderIdentity_judgement',
|
|
1380
|
+
};
|
|
1381
|
+
const normalized = String(value).trim();
|
|
1382
|
+
return aliases[normalized] || normalized;
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
function normalizeSupplementType(value, issue = '') {
|
|
1386
|
+
const normalized = String(value || '').trim().toLowerCase();
|
|
1387
|
+
const aliases = {
|
|
1388
|
+
score: 'score',
|
|
1389
|
+
rating: 'score',
|
|
1390
|
+
requirement: 'requirement',
|
|
1391
|
+
demand: 'requirement',
|
|
1392
|
+
bill: 'billOfQuantities',
|
|
1393
|
+
billofquantities: 'billOfQuantities',
|
|
1394
|
+
directory: 'directory',
|
|
1395
|
+
};
|
|
1396
|
+
if (normalized && aliases[normalized]) return aliases[normalized];
|
|
1397
|
+
if (issue) return issueType(issue);
|
|
1398
|
+
throw new Error('补充类型必须是 score、requirement、billOfQuantities 或 directory。');
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
function issueType(issue) {
|
|
1402
|
+
if (issue === 'score_judgement') return 'score';
|
|
1403
|
+
if (issue === 'billOfQuantities_judgement') return 'billOfQuantities';
|
|
1404
|
+
if (issue === 'directory_judgement') return 'directory';
|
|
1405
|
+
return 'requirement';
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
function buildSupplementPayload(uuid, type, text) {
|
|
1409
|
+
const payload = {
|
|
1410
|
+
uuid,
|
|
1411
|
+
requirement: '',
|
|
1412
|
+
score: '',
|
|
1413
|
+
type,
|
|
1414
|
+
};
|
|
1415
|
+
if (type === 'score') payload.score = String(text || '').trim();
|
|
1416
|
+
else if (type === 'directory') {
|
|
1417
|
+
payload.directory = String(text || '').trim();
|
|
1418
|
+
payload.modify = 1;
|
|
1419
|
+
} else payload.requirement = String(text || '').trim();
|
|
1420
|
+
if (!payload.score && !payload.requirement && !payload.directory) {
|
|
1421
|
+
throw new Error('补充文本不能为空。');
|
|
1422
|
+
}
|
|
1423
|
+
return payload;
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
async function submitSupplementFile(client, uuid, type, filePath) {
|
|
1427
|
+
const formData = new FormData();
|
|
1428
|
+
formData.append('uuid', uuid);
|
|
1429
|
+
formData.append('type', type);
|
|
1430
|
+
formData.append('files', fs.createReadStream(filePath), path.basename(filePath));
|
|
1431
|
+
return postForm(client, '/proxy/formatFileExtend/upload', formData);
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
async function waitAfterSupplement(client, state, cid, uuid, args, targetIssue = '') {
|
|
1435
|
+
await waitForSupplementParseResolution(client, state, cid, uuid, args, normalizeSupplementIssue(targetIssue));
|
|
1436
|
+
const task = await getJson(client, `/task/getTaskDetail/${encodeURIComponent(cid)}`, {}, { retries: DEFAULT_RETRY_COUNT });
|
|
1437
|
+
// The mode was explicitly confirmed when the task was created. Prefer an
|
|
1438
|
+
// explicit continuation argument, then that durable local snapshot, and
|
|
1439
|
+
// only use the backend mirror as a fallback because older deployments may
|
|
1440
|
+
// briefly omit or return a stale planMode after a supplement request.
|
|
1441
|
+
const planning = Number(
|
|
1442
|
+
args?.planMode
|
|
1443
|
+
?? args?.plan_mode
|
|
1444
|
+
?? state.tasks?.[cid]?.planMode
|
|
1445
|
+
?? task?.data?.planMode
|
|
1446
|
+
?? task?.data?.plan_mode,
|
|
1447
|
+
) === 1;
|
|
1448
|
+
return planning
|
|
1449
|
+
? waitForPlanningAnalysisReady(client, state, cid, uuid, args)
|
|
1450
|
+
: waitForOutlineReady(client, state, cid, uuid, args);
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
async function waitForSupplementParseResolution(client, state, cid, uuid, args, targetIssue = '') {
|
|
1454
|
+
if (!targetIssue) return;
|
|
1455
|
+
await pollUntil(async () => {
|
|
1456
|
+
const result = await fetchParseStatus(client, state, cid, uuid);
|
|
1457
|
+
const issues = collectParseIssues(result);
|
|
1458
|
+
// The parsing-stage basis choice is acknowledged by a dedicated
|
|
1459
|
+
// backend endpoint. Do not treat success=1/2 as resolved while the
|
|
1460
|
+
// same judgement flag is still zero; that would make the continuation
|
|
1461
|
+
// worker report a false next stage and could expose a duplicate card.
|
|
1462
|
+
const resolved = !issues.includes(targetIssue)
|
|
1463
|
+
|| (targetIssue !== 'scoreAndDirectory_judgement'
|
|
1464
|
+
&& (Number(result.success) === 1 || Number(result.success) === 2));
|
|
1465
|
+
return {
|
|
1466
|
+
done: resolved,
|
|
1467
|
+
data: result,
|
|
1468
|
+
progressLabel: `success=${result.success}, pending=${issues.join(',') || 'none'}`,
|
|
1469
|
+
};
|
|
1470
|
+
}, {
|
|
1471
|
+
intervalMs: secondsToMs(numberOption(args, 'intervalSec', DEFAULT_PARSE_INTERVAL_MS / 1000)),
|
|
1472
|
+
timeoutMs: secondsToMs(numberOption(args, 'timeoutSec', DEFAULT_TIMEOUT_MS / 1000)),
|
|
1473
|
+
quiet: booleanOption(args, 'json'),
|
|
1474
|
+
waitingText: 'waiting supplement parse result',
|
|
1475
|
+
});
|
|
1476
|
+
}
|
|
1477
|
+
|
|
918
1478
|
function handleChoices(args) {
|
|
919
1479
|
const scope = normalizeChoicesScope(args._[1] || 'all');
|
|
920
1480
|
const payload = buildChoicesPayload(scope);
|
|
@@ -966,6 +1526,33 @@ async function handleWizard(args, state) {
|
|
|
966
1526
|
interactive: false,
|
|
967
1527
|
}, state);
|
|
968
1528
|
|
|
1529
|
+
// A wizard is still a staged workflow. If outline generation pauses for
|
|
1530
|
+
// any user action, stop here and return the durable task identifiers so
|
|
1531
|
+
// the caller can resume the same cid instead of starting body generation
|
|
1532
|
+
// with an incomplete outline.
|
|
1533
|
+
const outlinePhase = outlineResult?.waitResult?.phase || outlineResult?.phase || '';
|
|
1534
|
+
const outlineReady = outlinePhase === 'ready'
|
|
1535
|
+
|| Boolean(outlineResult?.waitResult?.outlineDetail)
|
|
1536
|
+
|| Boolean(outlineResult?.waitResult?.contentDetail);
|
|
1537
|
+
if (!outlineReady) {
|
|
1538
|
+
const resultPayload = {
|
|
1539
|
+
command: 'wizard',
|
|
1540
|
+
cid,
|
|
1541
|
+
initResult,
|
|
1542
|
+
outlineResult,
|
|
1543
|
+
writeResult: null,
|
|
1544
|
+
exportResult: null,
|
|
1545
|
+
paused: true,
|
|
1546
|
+
phase: outlinePhase || 'outline_pending',
|
|
1547
|
+
};
|
|
1548
|
+
outputResult(args, resultPayload, [
|
|
1549
|
+
`wizard paused: cid=${cid}`,
|
|
1550
|
+
`phase: ${outlinePhase || 'outline_pending'}`,
|
|
1551
|
+
'resume the required confirmation or supplement on the same cid before generating content.',
|
|
1552
|
+
]);
|
|
1553
|
+
return resultPayload;
|
|
1554
|
+
}
|
|
1555
|
+
|
|
969
1556
|
const writeResult = await handleWrite({
|
|
970
1557
|
...wizardArgs,
|
|
971
1558
|
_: ['write'],
|
|
@@ -974,6 +1561,29 @@ async function handleWizard(args, state) {
|
|
|
974
1561
|
interactive: false,
|
|
975
1562
|
}, state);
|
|
976
1563
|
|
|
1564
|
+
const writeReady = Boolean(writeResult?.waitResult?.task_status)
|
|
1565
|
+
|| Boolean(writeResult?.waitResult?.content_portion_status)
|
|
1566
|
+
|| Boolean(writeResult?.writePreparation?.viewStep)
|
|
1567
|
+
|| writeResult?.directoryWaitResult?.phase === 'ready';
|
|
1568
|
+
if (!writeReady) {
|
|
1569
|
+
const resultPayload = {
|
|
1570
|
+
command: 'wizard',
|
|
1571
|
+
cid,
|
|
1572
|
+
initResult,
|
|
1573
|
+
outlineResult,
|
|
1574
|
+
writeResult: writeResult || null,
|
|
1575
|
+
exportResult: null,
|
|
1576
|
+
paused: true,
|
|
1577
|
+
phase: writeResult?.directoryWaitResult?.phase || 'content_pending',
|
|
1578
|
+
};
|
|
1579
|
+
outputResult(args, resultPayload, [
|
|
1580
|
+
`wizard paused before export: cid=${cid}`,
|
|
1581
|
+
`phase: ${resultPayload.phase}`,
|
|
1582
|
+
'resume the same task after its directory or content stage is ready.',
|
|
1583
|
+
]);
|
|
1584
|
+
return resultPayload;
|
|
1585
|
+
}
|
|
1586
|
+
|
|
977
1587
|
const exportResult = await handleExport({
|
|
978
1588
|
...wizardArgs,
|
|
979
1589
|
_: ['export'],
|
|
@@ -1495,9 +2105,21 @@ async function handleOutlineUnlocked(args, state) {
|
|
|
1495
2105
|
for (const hint of collectIssueHints(waitResult.issues, args)) {
|
|
1496
2106
|
summaryLines.push(hint);
|
|
1497
2107
|
}
|
|
2108
|
+
} else if (waitResult?.phase === 'basis_selection_required') {
|
|
2109
|
+
summaryLines.push('outline blocked: parsing-stage outline basis selection required');
|
|
2110
|
+
summaryLines.push('hint: run xq-cli basis-select --cid <cid> --uuid <uuid> --basis <scoreAndDir|scoreOnly|dirOnly> --wait.');
|
|
2111
|
+
} else if (waitResult?.phase === 'special_config_required') {
|
|
2112
|
+
summaryLines.push('outline blocked: EPC project scope selection required');
|
|
2113
|
+
summaryLines.push('hint: choose the EPC writing scope from the parsed backend options, then rerun outline for the same cid.');
|
|
1498
2114
|
} else if (waitResult?.phase === 'reference_selection_required') {
|
|
1499
2115
|
summaryLines.push('outline blocked: reference selection required');
|
|
1500
2116
|
summaryLines.push('hint: rerun with --wait in an interactive terminal, or pass --reference-type <0|1|2>.');
|
|
2117
|
+
} else if (waitResult?.phase === 'bidder_role_required') {
|
|
2118
|
+
summaryLines.push('outline blocked: bidder role selection required');
|
|
2119
|
+
summaryLines.push('hint: run xq-cli bidder-role --cid <cid> --uuid <uuid> --bidder-role <1|2>, then continue polling the same task.');
|
|
2120
|
+
} else if (waitResult?.phase === 'unsupported_intermediate_state') {
|
|
2121
|
+
summaryLines.push(`outline blocked: unsupported backend interaction (${waitResult.issues.join(', ')})`);
|
|
2122
|
+
summaryLines.push('hint: upgrade xq-cli/WorkBuddy to a version that supports this backend interaction; the same cid remains available for recovery.');
|
|
1501
2123
|
} else if (waitResult?.phase === 'failed') {
|
|
1502
2124
|
summaryLines.push(`outline failed: task_status=${waitResult.taskDetail?.task_status ?? '-'}`);
|
|
1503
2125
|
} else {
|
|
@@ -1844,6 +2466,30 @@ async function handleWriteUnlocked(args, state) {
|
|
|
1844
2466
|
assertContentGenerationAllowed(contentDetail.data, '生成正文');
|
|
1845
2467
|
saveTaskSnapshot(state, cid, pickTaskSnapshot(contentDetail.data));
|
|
1846
2468
|
|
|
2469
|
+
const pageScopeResult = await checkPageScopeBeforeWrite(client, state, cid, args);
|
|
2470
|
+
if (pageScopeResult.phase !== 'passed') {
|
|
2471
|
+
const blockedPayload = {
|
|
2472
|
+
command: 'write',
|
|
2473
|
+
cid,
|
|
2474
|
+
type,
|
|
2475
|
+
directoryWaitResult,
|
|
2476
|
+
pageScopeResult,
|
|
2477
|
+
writePreparation: null,
|
|
2478
|
+
triggerResult: null,
|
|
2479
|
+
waitResult: null,
|
|
2480
|
+
};
|
|
2481
|
+
outputResult(args, blockedPayload, [
|
|
2482
|
+
`content generation blocked: cid=${cid}`,
|
|
2483
|
+
pageScopeResult.phase === 'confirmation_required'
|
|
2484
|
+
? 'page-scope confirmation required before charging or starting content'
|
|
2485
|
+
: 'page-scope check returned an unsupported state; content was not started',
|
|
2486
|
+
pageScopeResult.pageScopeResult?.checkId
|
|
2487
|
+
? `checkId: ${pageScopeResult.pageScopeResult.checkId}`
|
|
2488
|
+
: '',
|
|
2489
|
+
].filter(Boolean));
|
|
2490
|
+
return blockedPayload;
|
|
2491
|
+
}
|
|
2492
|
+
|
|
1847
2493
|
const writePreparation = await prepareContentGeneration(client, state, cid, contentDetail, args);
|
|
1848
2494
|
let triggerResult = null;
|
|
1849
2495
|
if (writePreparation.shouldTrigger) {
|
|
@@ -1859,6 +2505,15 @@ async function handleWriteUnlocked(args, state) {
|
|
|
1859
2505
|
if (booleanOption(args, 'wait')) {
|
|
1860
2506
|
status = await pollContentUntilReady(client, state, cid, args);
|
|
1861
2507
|
}
|
|
2508
|
+
if (status?.phase === 'failed') {
|
|
2509
|
+
throw new Error(
|
|
2510
|
+
'[CONTENT_GENERATION_FAILED] 喜鹊后台报告正文生成失败,task_status='
|
|
2511
|
+
+ String(status.task_status ?? '-')
|
|
2512
|
+
+ ',content_portion_status='
|
|
2513
|
+
+ String(status.content_portion_status ?? '-')
|
|
2514
|
+
+ ';已停止等待和导出,请查询同一任务状态。',
|
|
2515
|
+
);
|
|
2516
|
+
}
|
|
1862
2517
|
if (status && status.task_status !== undefined) {
|
|
1863
2518
|
try {
|
|
1864
2519
|
assertContentCompleted(status, '确认正文完成');
|
|
@@ -1876,6 +2531,7 @@ async function handleWriteUnlocked(args, state) {
|
|
|
1876
2531
|
cid,
|
|
1877
2532
|
type,
|
|
1878
2533
|
directoryWaitResult,
|
|
2534
|
+
pageScopeResult,
|
|
1879
2535
|
writePreparation,
|
|
1880
2536
|
triggerResult,
|
|
1881
2537
|
waitResult: status,
|
|
@@ -2014,6 +2670,7 @@ async function handleExport(args, state) {
|
|
|
2014
2670
|
|
|
2015
2671
|
async function hydrateTaskSnapshot(client, state, cid) {
|
|
2016
2672
|
const cached = state.tasks?.[cid] || {};
|
|
2673
|
+
const confirmedPlanMode = cached.planMode;
|
|
2017
2674
|
let detailData = {};
|
|
2018
2675
|
try {
|
|
2019
2676
|
const detail = await getJson(client, `/task/getTaskDetail/${encodeURIComponent(cid)}`, {}, { retries: DEFAULT_RETRY_COUNT });
|
|
@@ -2028,6 +2685,12 @@ async function hydrateTaskSnapshot(client, state, cid) {
|
|
|
2028
2685
|
...detailData,
|
|
2029
2686
|
cid,
|
|
2030
2687
|
});
|
|
2688
|
+
// planMode is immutable for a generation run. Preserve the mode already
|
|
2689
|
+
// recorded with the confirmed CLI configuration when a legacy backend
|
|
2690
|
+
// mirror is missing or temporarily stale during continuation.
|
|
2691
|
+
if (confirmedPlanMode !== undefined && confirmedPlanMode !== null && confirmedPlanMode !== '') {
|
|
2692
|
+
snapshot.planMode = confirmedPlanMode;
|
|
2693
|
+
}
|
|
2031
2694
|
saveTaskSnapshot(state, cid, snapshot);
|
|
2032
2695
|
return snapshot;
|
|
2033
2696
|
}
|
|
@@ -2064,6 +2727,8 @@ function buildOutlineParams(snapshot, args) {
|
|
|
2064
2727
|
const plan = stringOption(args, 'plan', snapshot.plan || '');
|
|
2065
2728
|
const requirement = stringOption(args, 'requirement', snapshot.requirement || '');
|
|
2066
2729
|
const rating = stringOption(args, 'rating', snapshot.rating || '');
|
|
2730
|
+
const bidderCompanyId = stringOption(args, 'bidderCompanyId', snapshot.bidderCompanyId || '');
|
|
2731
|
+
const bidderCompanyName = stringOption(args, 'bidderCompanyName', snapshot.bidderCompanyName || '');
|
|
2067
2732
|
const blindGenerationMode = enumOption(
|
|
2068
2733
|
args,
|
|
2069
2734
|
['blindGenerationMode', 'anonymousBid'],
|
|
@@ -2077,6 +2742,9 @@ function buildOutlineParams(snapshot, args) {
|
|
|
2077
2742
|
if (!title) {
|
|
2078
2743
|
throw new Error('Missing title for outline generation.');
|
|
2079
2744
|
}
|
|
2745
|
+
if (Number(snapshot.originType) === 3 && (!bidderCompanyId || !bidderCompanyName)) {
|
|
2746
|
+
throw new Error('commercial_bidder_company_required: 商务标必须先选择投标公司。');
|
|
2747
|
+
}
|
|
2080
2748
|
|
|
2081
2749
|
return compactObject({
|
|
2082
2750
|
cid: snapshot.cid,
|
|
@@ -2107,6 +2775,10 @@ function buildOutlineParams(snapshot, args) {
|
|
|
2107
2775
|
pageMarginSetting: snapshot.pageMarginSetting,
|
|
2108
2776
|
multiBidId: stringOption(args, 'multiBidId', snapshot.multiBidId),
|
|
2109
2777
|
multiBidType: stringOption(args, 'multiBidType', snapshot.multiBidType),
|
|
2778
|
+
...(bidderCompanyId || bidderCompanyName ? {
|
|
2779
|
+
bidderCompanyId,
|
|
2780
|
+
bidderCompanyName,
|
|
2781
|
+
} : {}),
|
|
2110
2782
|
planMode: enumOption(args, 'planMode', PLAN_MODE_OPTIONS, snapshot.planMode ?? 0),
|
|
2111
2783
|
epcEngineerType: normalizeEpcEngineerType(stringOption(args, 'epcEngineerType', snapshot.epcEngineerType)),
|
|
2112
2784
|
blindBidConfirm: {
|
|
@@ -2523,8 +3195,15 @@ function buildFileMetadata(files, args) {
|
|
|
2523
3195
|
async function pollParseUntilReady(client, state, cid, uuid, args) {
|
|
2524
3196
|
return pollUntil(async () => {
|
|
2525
3197
|
const result = await fetchParseStatus(client, state, cid, uuid);
|
|
3198
|
+
const success = Number(result.success);
|
|
3199
|
+
if (!KNOWN_PARSE_SUCCESS_CODES.has(success)) {
|
|
3200
|
+
throw new Error(
|
|
3201
|
+
`[UNSUPPORTED_PARSE_STATE] 后端返回了未支持的解析状态 success=${String(result.success)},` +
|
|
3202
|
+
'已停止轮询;请升级 xq-cli/WorkBuddy 后使用同一任务恢复。',
|
|
3203
|
+
);
|
|
3204
|
+
}
|
|
2526
3205
|
return {
|
|
2527
|
-
done: isParseReadyForNextStep(
|
|
3206
|
+
done: isParseReadyForNextStep(success),
|
|
2528
3207
|
data: result,
|
|
2529
3208
|
progressLabel: `success=${result.success}`,
|
|
2530
3209
|
};
|
|
@@ -2604,6 +3283,7 @@ async function waitForOutlineReady(client, state, cid, uuid, args, initialSubmit
|
|
|
2604
3283
|
const planModePhase = normalizePlanModePhase(taskDetail.data?.plan_mode_phase);
|
|
2605
3284
|
const referenceData = referenceStatus?.data || {};
|
|
2606
3285
|
const referencePhase = normalizeReferenceStatus(referenceData.status);
|
|
3286
|
+
let parseReadyForOutline = !uuid;
|
|
2607
3287
|
if (referencePhase !== null) {
|
|
2608
3288
|
saveTaskSnapshot(state, cid, {
|
|
2609
3289
|
referenceStatus: referencePhase,
|
|
@@ -2641,60 +3321,95 @@ async function waitForOutlineReady(client, state, cid, uuid, args, initialSubmit
|
|
|
2641
3321
|
};
|
|
2642
3322
|
}
|
|
2643
3323
|
|
|
2644
|
-
if (
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
phase: 'ready',
|
|
2649
|
-
taskDetail: taskDetail.data,
|
|
2650
|
-
outlineDetail: outlineData,
|
|
2651
|
-
},
|
|
2652
|
-
progressLabel: `rootChapters=${countOutlineRoots({ outlineDetail: outlineData, taskDetail: taskDetail.data })}`,
|
|
2653
|
-
};
|
|
2654
|
-
}
|
|
2655
|
-
|
|
2656
|
-
if (referencePhase === 1) {
|
|
2657
|
-
if (submittedReferenceType !== null) {
|
|
3324
|
+
if (uuid) {
|
|
3325
|
+
const parseStatus = await fetchParseStatus(client, state, cid, uuid);
|
|
3326
|
+
const parseSuccess = Number(parseStatus.success);
|
|
3327
|
+
if (!KNOWN_PARSE_SUCCESS_CODES.has(parseSuccess)) {
|
|
2658
3328
|
return {
|
|
2659
|
-
done:
|
|
2660
|
-
data:
|
|
2661
|
-
|
|
3329
|
+
done: true,
|
|
3330
|
+
data: {
|
|
3331
|
+
phase: 'unsupported_parse_state',
|
|
3332
|
+
parseStatus,
|
|
3333
|
+
taskDetail: taskDetail.data,
|
|
3334
|
+
outlineDetail: outlineData,
|
|
3335
|
+
},
|
|
3336
|
+
progressLabel: `unsupported_parse_state=${String(parseStatus.success)}`,
|
|
2662
3337
|
};
|
|
2663
3338
|
}
|
|
3339
|
+
const issues = collectParseIssues(parseStatus);
|
|
3340
|
+
const unsupportedIssues = collectUnsupportedParseIssues(parseStatus);
|
|
2664
3341
|
|
|
2665
|
-
|
|
2666
|
-
if (!selection.ready) {
|
|
3342
|
+
if (parseSuccess === 4 && unsupportedIssues.length > 0) {
|
|
2667
3343
|
return {
|
|
2668
3344
|
done: true,
|
|
2669
3345
|
data: {
|
|
2670
|
-
phase: '
|
|
3346
|
+
phase: 'unsupported_intermediate_state',
|
|
3347
|
+
issues: unsupportedIssues,
|
|
3348
|
+
parseStatus,
|
|
2671
3349
|
taskDetail: taskDetail.data,
|
|
2672
3350
|
outlineDetail: outlineData,
|
|
2673
|
-
referenceDetail: referenceData,
|
|
2674
|
-
options: buildOutlineReferenceChoices(referenceData),
|
|
2675
3351
|
},
|
|
2676
|
-
progressLabel: '
|
|
3352
|
+
progressLabel: `unsupported_intermediate_state=${unsupportedIssues.join(',')}`,
|
|
2677
3353
|
};
|
|
2678
3354
|
}
|
|
2679
3355
|
|
|
2680
|
-
await submitOutlineReferenceType(client, cid, selection.referenceType);
|
|
2681
|
-
submittedReferenceType = selection.referenceType;
|
|
2682
|
-
saveTaskSnapshot(state, cid, {
|
|
2683
|
-
outlineReferenceType: selection.referenceType,
|
|
2684
|
-
});
|
|
2685
|
-
return {
|
|
2686
|
-
done: false,
|
|
2687
|
-
data: null,
|
|
2688
|
-
progressLabel: `referenceType=${selection.referenceType} submitted, waiting outline`,
|
|
2689
|
-
};
|
|
2690
|
-
}
|
|
2691
|
-
|
|
2692
|
-
if (uuid) {
|
|
2693
|
-
const parseStatus = await fetchParseStatus(client, state, cid, uuid);
|
|
2694
|
-
const parseSuccess = Number(parseStatus.success);
|
|
2695
|
-
const issues = collectParseIssues(parseStatus);
|
|
2696
|
-
|
|
2697
3356
|
if (parseSuccess === 4 && issues.length > 0) {
|
|
3357
|
+
const continuation = classifyParseContinuation(issues);
|
|
3358
|
+
if (continuation === 'basis_selection_required') {
|
|
3359
|
+
return {
|
|
3360
|
+
done: true,
|
|
3361
|
+
data: {
|
|
3362
|
+
phase: continuation,
|
|
3363
|
+
issues,
|
|
3364
|
+
parseStatus,
|
|
3365
|
+
taskDetail: taskDetail.data,
|
|
3366
|
+
outlineDetail: outlineData,
|
|
3367
|
+
},
|
|
3368
|
+
progressLabel: 'basis_selection_required from parse status',
|
|
3369
|
+
};
|
|
3370
|
+
}
|
|
3371
|
+
if (continuation === 'special_config_required') {
|
|
3372
|
+
return {
|
|
3373
|
+
done: true,
|
|
3374
|
+
data: {
|
|
3375
|
+
phase: continuation,
|
|
3376
|
+
issues,
|
|
3377
|
+
parseStatus,
|
|
3378
|
+
taskDetail: taskDetail.data,
|
|
3379
|
+
outlineDetail: outlineData,
|
|
3380
|
+
},
|
|
3381
|
+
progressLabel: 'special_config_required from parse status',
|
|
3382
|
+
};
|
|
3383
|
+
}
|
|
3384
|
+
if (continuation === 'reference_selection_required') {
|
|
3385
|
+
return {
|
|
3386
|
+
done: true,
|
|
3387
|
+
data: {
|
|
3388
|
+
phase: continuation,
|
|
3389
|
+
issues,
|
|
3390
|
+
parseStatus,
|
|
3391
|
+
taskDetail: taskDetail.data,
|
|
3392
|
+
outlineDetail: outlineData,
|
|
3393
|
+
referenceDetail: referenceData,
|
|
3394
|
+
options: buildOutlineReferenceChoices(referenceData),
|
|
3395
|
+
},
|
|
3396
|
+
progressLabel: 'reference_selection_required from parse status',
|
|
3397
|
+
};
|
|
3398
|
+
}
|
|
3399
|
+
if (continuation === 'bidder_role_required') {
|
|
3400
|
+
return {
|
|
3401
|
+
done: true,
|
|
3402
|
+
data: {
|
|
3403
|
+
phase: continuation,
|
|
3404
|
+
issues,
|
|
3405
|
+
parseStatus,
|
|
3406
|
+
taskDetail: taskDetail.data,
|
|
3407
|
+
outlineDetail: outlineData,
|
|
3408
|
+
bidderRoleIssue: 'bidderIdentity_judgement',
|
|
3409
|
+
},
|
|
3410
|
+
progressLabel: 'bidder_role_required from parse status',
|
|
3411
|
+
};
|
|
3412
|
+
}
|
|
2698
3413
|
const autoIgnore = resolveAutoIgnoreIssue(issues, args, uuid, handledIssues);
|
|
2699
3414
|
|
|
2700
3415
|
if (autoIgnore) {
|
|
@@ -2720,10 +3435,69 @@ async function waitForOutlineReady(client, state, cid, uuid, args, initialSubmit
|
|
|
2720
3435
|
};
|
|
2721
3436
|
}
|
|
2722
3437
|
|
|
3438
|
+
// A stale outline response can outlive the current parser state.
|
|
3439
|
+
// Only allow it to finish the wait after parsing is in a known
|
|
3440
|
+
// ready state and all human gates have been cleared.
|
|
3441
|
+
parseReadyForOutline = parseSuccess === 1
|
|
3442
|
+
|| parseSuccess === 2
|
|
3443
|
+
|| (parseSuccess === 4 && issues.length === 0);
|
|
3444
|
+
|
|
3445
|
+
if (!parseReadyForOutline) {
|
|
3446
|
+
return {
|
|
3447
|
+
done: false,
|
|
3448
|
+
data: null,
|
|
3449
|
+
progressLabel: `success=${parseSuccess}, task_status=${taskDetail.data?.task_status ?? '-'}, plan_mode_phase=${formatPlanModePhase(planModePhase)}, directory_status=${taskDetail.data?.directory_portion_status ?? '-'}, outline_roots=${countOutlineRoots({ outlineDetail: outlineData })}, outline_status=${outlineData.outline_status ? 1 : 0}, reference_status=${referencePhase ?? '-'}`,
|
|
3450
|
+
};
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3453
|
+
|
|
3454
|
+
if (referencePhase === 1) {
|
|
3455
|
+
if (submittedReferenceType !== null) {
|
|
3456
|
+
return {
|
|
3457
|
+
done: false,
|
|
3458
|
+
data: null,
|
|
3459
|
+
progressLabel: `reference_status=1, referenceType=${submittedReferenceType}, waiting confirmation`,
|
|
3460
|
+
};
|
|
3461
|
+
}
|
|
3462
|
+
|
|
3463
|
+
const selection = await resolveOutlineReferenceSelection(args, referenceData);
|
|
3464
|
+
if (!selection.ready) {
|
|
3465
|
+
return {
|
|
3466
|
+
done: true,
|
|
3467
|
+
data: {
|
|
3468
|
+
phase: 'reference_selection_required',
|
|
3469
|
+
taskDetail: taskDetail.data,
|
|
3470
|
+
outlineDetail: outlineData,
|
|
3471
|
+
referenceDetail: referenceData,
|
|
3472
|
+
options: buildOutlineReferenceChoices(referenceData),
|
|
3473
|
+
},
|
|
3474
|
+
progressLabel: 'reference_selection_required',
|
|
3475
|
+
};
|
|
3476
|
+
}
|
|
3477
|
+
|
|
3478
|
+
await submitOutlineReferenceType(client, cid, selection.referenceType);
|
|
3479
|
+
submittedReferenceType = selection.referenceType;
|
|
3480
|
+
saveTaskSnapshot(state, cid, {
|
|
3481
|
+
outlineReferenceType: submittedReferenceType,
|
|
3482
|
+
});
|
|
2723
3483
|
return {
|
|
2724
3484
|
done: false,
|
|
2725
3485
|
data: null,
|
|
2726
|
-
progressLabel: `
|
|
3486
|
+
progressLabel: `referenceType=${selection.referenceType} submitted, waiting outline`,
|
|
3487
|
+
};
|
|
3488
|
+
}
|
|
3489
|
+
|
|
3490
|
+
// checkReference status=0 means the backend is still preparing the
|
|
3491
|
+
// outline basis. A stale outline response must not bypass that gate.
|
|
3492
|
+
if (hasOutline && parseReadyForOutline && referencePhase !== 0) {
|
|
3493
|
+
return {
|
|
3494
|
+
done: true,
|
|
3495
|
+
data: {
|
|
3496
|
+
phase: 'ready',
|
|
3497
|
+
taskDetail: taskDetail.data,
|
|
3498
|
+
outlineDetail: outlineData,
|
|
3499
|
+
},
|
|
3500
|
+
progressLabel: `rootChapters=${countOutlineRoots({ outlineDetail: outlineData, taskDetail: taskDetail.data })}`,
|
|
2727
3501
|
};
|
|
2728
3502
|
}
|
|
2729
3503
|
|
|
@@ -2760,13 +3534,89 @@ async function waitForPlanningAnalysisReady(client, state, cid, uuid, args) {
|
|
|
2760
3534
|
? await fetchParseStatus(client, state, cid, uuid)
|
|
2761
3535
|
: { success: 1 };
|
|
2762
3536
|
const parseSuccess = Number(parseStatus.success);
|
|
3537
|
+
if (!KNOWN_PARSE_SUCCESS_CODES.has(parseSuccess)) {
|
|
3538
|
+
return {
|
|
3539
|
+
done: true,
|
|
3540
|
+
data: {
|
|
3541
|
+
phase: 'unsupported_parse_state',
|
|
3542
|
+
parseStatus,
|
|
3543
|
+
taskDetail,
|
|
3544
|
+
},
|
|
3545
|
+
progressLabel: `unsupported_parse_state=${String(parseStatus.success)}`,
|
|
3546
|
+
};
|
|
3547
|
+
}
|
|
2763
3548
|
if (parseSuccess === 2) {
|
|
2764
3549
|
throw new Error(
|
|
2765
3550
|
'[TASK_PARSE_NOT_ADVANCED] 规划模式仍处于等待标包/EPC选择(success=2),未进入解析阶段,已停止等待。',
|
|
2766
3551
|
);
|
|
2767
3552
|
}
|
|
2768
3553
|
const issues = collectParseIssues(parseStatus);
|
|
3554
|
+
const unsupportedIssues = collectUnsupportedParseIssues(parseStatus);
|
|
3555
|
+
if (parseSuccess === 4 && unsupportedIssues.length > 0) {
|
|
3556
|
+
return {
|
|
3557
|
+
done: true,
|
|
3558
|
+
data: {
|
|
3559
|
+
phase: 'unsupported_intermediate_state',
|
|
3560
|
+
issues: unsupportedIssues,
|
|
3561
|
+
parseStatus,
|
|
3562
|
+
taskDetail,
|
|
3563
|
+
},
|
|
3564
|
+
progressLabel: `unsupported_intermediate_state=${unsupportedIssues.join(',')}`,
|
|
3565
|
+
};
|
|
3566
|
+
}
|
|
2769
3567
|
if (parseSuccess === 4 && issues.length > 0) {
|
|
3568
|
+
const continuation = classifyParseContinuation(issues);
|
|
3569
|
+
if (continuation === 'basis_selection_required') {
|
|
3570
|
+
return {
|
|
3571
|
+
done: true,
|
|
3572
|
+
data: {
|
|
3573
|
+
phase: continuation,
|
|
3574
|
+
issues,
|
|
3575
|
+
parseStatus,
|
|
3576
|
+
taskDetail,
|
|
3577
|
+
},
|
|
3578
|
+
progressLabel: 'basis_selection_required from parse status',
|
|
3579
|
+
};
|
|
3580
|
+
}
|
|
3581
|
+
if (continuation === 'special_config_required') {
|
|
3582
|
+
return {
|
|
3583
|
+
done: true,
|
|
3584
|
+
data: {
|
|
3585
|
+
phase: continuation,
|
|
3586
|
+
issues,
|
|
3587
|
+
parseStatus,
|
|
3588
|
+
taskDetail,
|
|
3589
|
+
},
|
|
3590
|
+
progressLabel: 'special_config_required from parse status',
|
|
3591
|
+
};
|
|
3592
|
+
}
|
|
3593
|
+
if (continuation === 'reference_selection_required') {
|
|
3594
|
+
return {
|
|
3595
|
+
done: true,
|
|
3596
|
+
data: {
|
|
3597
|
+
phase: continuation,
|
|
3598
|
+
issues,
|
|
3599
|
+
parseStatus,
|
|
3600
|
+
taskDetail,
|
|
3601
|
+
referenceDetail: {},
|
|
3602
|
+
options: [],
|
|
3603
|
+
},
|
|
3604
|
+
progressLabel: 'reference_selection_required from parse status',
|
|
3605
|
+
};
|
|
3606
|
+
}
|
|
3607
|
+
if (continuation === 'bidder_role_required') {
|
|
3608
|
+
return {
|
|
3609
|
+
done: true,
|
|
3610
|
+
data: {
|
|
3611
|
+
phase: continuation,
|
|
3612
|
+
issues,
|
|
3613
|
+
parseStatus,
|
|
3614
|
+
taskDetail,
|
|
3615
|
+
bidderRoleIssue: 'bidderIdentity_judgement',
|
|
3616
|
+
},
|
|
3617
|
+
progressLabel: 'bidder_role_required from parse status',
|
|
3618
|
+
};
|
|
3619
|
+
}
|
|
2770
3620
|
const autoIgnore = resolveAutoIgnoreIssue(issues, args, uuid, handledIssues);
|
|
2771
3621
|
if (autoIgnore) {
|
|
2772
3622
|
await submitIntermediateChoice(client, autoIgnore.payload);
|
|
@@ -2833,6 +3683,18 @@ async function pollContentUntilReady(client, state, cid, args) {
|
|
|
2833
3683
|
const totalChapter = numberOrDefault(contentData.totalChapter, 0);
|
|
2834
3684
|
const percentage = numberOrDefault(contentData.percentage, 0);
|
|
2835
3685
|
|
|
3686
|
+
if (taskStatus === 7 || contentPortionStatus === 7) {
|
|
3687
|
+
return {
|
|
3688
|
+
done: true,
|
|
3689
|
+
data: {
|
|
3690
|
+
...contentData,
|
|
3691
|
+
phase: 'failed',
|
|
3692
|
+
failureCode: 'CONTENT_GENERATION_FAILED',
|
|
3693
|
+
},
|
|
3694
|
+
progressLabel: `task_status=${taskStatus}, content_portion_status=${contentPortionStatus}`,
|
|
3695
|
+
};
|
|
3696
|
+
}
|
|
3697
|
+
|
|
2836
3698
|
if (isContentComplete(contentData)) {
|
|
2837
3699
|
return {
|
|
2838
3700
|
done: true,
|
|
@@ -2885,6 +3747,79 @@ async function fetchOutlineDetail(client, cid) {
|
|
|
2885
3747
|
return getJson(client, '/c/getOutLineDetail', { cid }, { retries: DEFAULT_RETRY_COUNT });
|
|
2886
3748
|
}
|
|
2887
3749
|
|
|
3750
|
+
async function checkPageScopeBeforeWrite(client, state, cid, args = {}) {
|
|
3751
|
+
const outlineResponse = await fetchOutlineDetail(client, cid);
|
|
3752
|
+
const outlineDetail = outlineResponse?.data || {};
|
|
3753
|
+
const outlineRows = getOutlineRows(outlineDetail);
|
|
3754
|
+
if (outlineRows.length === 0) {
|
|
3755
|
+
return {
|
|
3756
|
+
phase: 'unsupported_page_scope_state',
|
|
3757
|
+
pageScopeResult: {
|
|
3758
|
+
checkStatus: null,
|
|
3759
|
+
reason: 'current_outline_empty',
|
|
3760
|
+
},
|
|
3761
|
+
outlineDetail,
|
|
3762
|
+
};
|
|
3763
|
+
}
|
|
3764
|
+
|
|
3765
|
+
// This mirrors the Web outline submit payload. The check is deliberately
|
|
3766
|
+
// made against the authoritative outline, so a CLI/WorkBuddy resume cannot
|
|
3767
|
+
// silently reuse a stale local snapshot.
|
|
3768
|
+
const response = await postJson(client, '/task/checkPageScope', {
|
|
3769
|
+
cid,
|
|
3770
|
+
updateStatus: 1,
|
|
3771
|
+
outLine: buildPageScopeCheckRows(outlineRows),
|
|
3772
|
+
});
|
|
3773
|
+
const pageScopeResult = response?.data || {};
|
|
3774
|
+
const checkStatus = Number(pageScopeResult.checkStatus);
|
|
3775
|
+
const phase = checkStatus === 1
|
|
3776
|
+
? 'passed'
|
|
3777
|
+
: checkStatus === 0
|
|
3778
|
+
? 'confirmation_required'
|
|
3779
|
+
: 'unsupported_page_scope_state';
|
|
3780
|
+
saveTaskSnapshot(state, cid, {
|
|
3781
|
+
pageScopePhase: phase,
|
|
3782
|
+
pageScopeResult,
|
|
3783
|
+
pageScopeCheckedAt: new Date().toISOString(),
|
|
3784
|
+
});
|
|
3785
|
+
return {
|
|
3786
|
+
phase,
|
|
3787
|
+
pageScopeResult,
|
|
3788
|
+
outlineDetail,
|
|
3789
|
+
checkId: pageScopeResult.checkId,
|
|
3790
|
+
response,
|
|
3791
|
+
};
|
|
3792
|
+
}
|
|
3793
|
+
|
|
3794
|
+
function buildPageScopeCheckRows(outlineRows) {
|
|
3795
|
+
return outlineRows.map((item, index) => {
|
|
3796
|
+
const rawText = String(item?.text || '').trim();
|
|
3797
|
+
const text = /^第[一二三四五六七八九十百千万零]+章\s*/.test(rawText)
|
|
3798
|
+
? rawText
|
|
3799
|
+
: `第${numberToChinese(index + 1)}章 ${rawText}`;
|
|
3800
|
+
return compactObject({
|
|
3801
|
+
text,
|
|
3802
|
+
theme: item?.theme,
|
|
3803
|
+
updateFlag: item?.updateFlag || 0,
|
|
3804
|
+
important: item?.important,
|
|
3805
|
+
...(item?.sequelFlag === 1 ? { sequelFlag: 1 } : {}),
|
|
3806
|
+
...(item?.id ? { id: item.id } : {}),
|
|
3807
|
+
});
|
|
3808
|
+
});
|
|
3809
|
+
}
|
|
3810
|
+
|
|
3811
|
+
function numberToChinese(value) {
|
|
3812
|
+
const digits = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十'];
|
|
3813
|
+
if (value <= 10) return digits[value];
|
|
3814
|
+
if (value < 20) return '十' + (value % 10 ? digits[value % 10] : '');
|
|
3815
|
+
if (value < 100) {
|
|
3816
|
+
const tens = Math.floor(value / 10);
|
|
3817
|
+
const ones = value % 10;
|
|
3818
|
+
return digits[tens] + '十' + (ones ? digits[ones] : '');
|
|
3819
|
+
}
|
|
3820
|
+
return String(value);
|
|
3821
|
+
}
|
|
3822
|
+
|
|
2888
3823
|
async function fetchReferenceStatusSafe(client, cid) {
|
|
2889
3824
|
try {
|
|
2890
3825
|
return await getJson(client, `/task/directory/checkReference/${encodeURIComponent(cid)}`, {}, { retries: DEFAULT_RETRY_COUNT });
|
|
@@ -2975,6 +3910,21 @@ async function ensureDirectoryReadyForWrite(client, state, cid, args) {
|
|
|
2975
3910
|
const referenceData = referenceStatus?.data || {};
|
|
2976
3911
|
const referencePhase = normalizeReferenceStatus(referenceData.status);
|
|
2977
3912
|
|
|
3913
|
+
const backendTaskStatus = Number(effectiveContentData.task_status);
|
|
3914
|
+
const backendContentStatus = Number(effectiveContentData.content_portion_status);
|
|
3915
|
+
if (backendTaskStatus === 7 || backendContentStatus === 7) {
|
|
3916
|
+
return {
|
|
3917
|
+
done: true,
|
|
3918
|
+
data: {
|
|
3919
|
+
phase: 'failed',
|
|
3920
|
+
taskDetail: taskData,
|
|
3921
|
+
contentDetail: effectiveContentData,
|
|
3922
|
+
referenceDetail: referenceData,
|
|
3923
|
+
},
|
|
3924
|
+
progressLabel: `task_status=${backendTaskStatus}, content_portion_status=${backendContentStatus}`,
|
|
3925
|
+
};
|
|
3926
|
+
}
|
|
3927
|
+
|
|
2978
3928
|
saveTaskSnapshot(state, cid, pickTaskSnapshot({
|
|
2979
3929
|
...taskData,
|
|
2980
3930
|
...contentData,
|
|
@@ -3266,16 +4216,63 @@ function collectParseIssues(result) {
|
|
|
3266
4216
|
'score_judgement',
|
|
3267
4217
|
'directory_judgement',
|
|
3268
4218
|
'scoreAndDirectory_judgement',
|
|
4219
|
+
'epcEngineer_judgement',
|
|
3269
4220
|
'bidderIdentity_judgement',
|
|
3270
4221
|
];
|
|
3271
4222
|
|
|
3272
4223
|
return issueKeys.filter(key => {
|
|
3273
4224
|
const directValue = result[key];
|
|
3274
4225
|
const nestedValue = result.judgement_status?.[key.replace('_judgement', '')];
|
|
3275
|
-
return
|
|
4226
|
+
return isFalsyStatus(directValue ?? nestedValue ?? '1');
|
|
3276
4227
|
});
|
|
3277
4228
|
}
|
|
3278
4229
|
|
|
4230
|
+
function isFalsyStatus(value) {
|
|
4231
|
+
if (value === false || value === 0) return true;
|
|
4232
|
+
const normalized = String(value ?? '').trim().toLowerCase();
|
|
4233
|
+
return normalized === '0' || normalized === 'false';
|
|
4234
|
+
}
|
|
4235
|
+
|
|
4236
|
+
function collectUnsupportedParseIssues(result = {}) {
|
|
4237
|
+
const knownKeys = new Set([
|
|
4238
|
+
'requirement_exist',
|
|
4239
|
+
'requirement_judgement',
|
|
4240
|
+
'billOfQuantities_judgement',
|
|
4241
|
+
'score_judgement',
|
|
4242
|
+
'directory_judgement',
|
|
4243
|
+
'scoreAndDirectory_judgement',
|
|
4244
|
+
'epcEngineer_judgement',
|
|
4245
|
+
'bidderIdentity_judgement',
|
|
4246
|
+
]);
|
|
4247
|
+
const unsupported = new Set();
|
|
4248
|
+
for (const [key, value] of Object.entries(result || {})) {
|
|
4249
|
+
if (key.endsWith('_judgement') && !knownKeys.has(key) && isFalsyStatus(value)) {
|
|
4250
|
+
unsupported.add(key);
|
|
4251
|
+
}
|
|
4252
|
+
}
|
|
4253
|
+
for (const [key, value] of Object.entries(result?.judgement_status || {})) {
|
|
4254
|
+
const issueKey = key.endsWith('_judgement') ? key : `${key}_judgement`;
|
|
4255
|
+
if (!knownKeys.has(issueKey) && isFalsyStatus(value)) {
|
|
4256
|
+
unsupported.add(issueKey);
|
|
4257
|
+
}
|
|
4258
|
+
}
|
|
4259
|
+
return [...unsupported];
|
|
4260
|
+
}
|
|
4261
|
+
|
|
4262
|
+
function classifyParseContinuation(issues = []) {
|
|
4263
|
+
const normalized = new Set(Array.isArray(issues) ? issues : []);
|
|
4264
|
+
if (normalized.has('scoreAndDirectory_judgement')) {
|
|
4265
|
+
return 'basis_selection_required';
|
|
4266
|
+
}
|
|
4267
|
+
if (normalized.has('epcEngineer_judgement')) {
|
|
4268
|
+
return 'special_config_required';
|
|
4269
|
+
}
|
|
4270
|
+
if (normalized.has('bidderIdentity_judgement')) {
|
|
4271
|
+
return 'bidder_role_required';
|
|
4272
|
+
}
|
|
4273
|
+
return 'supplement_required';
|
|
4274
|
+
}
|
|
4275
|
+
|
|
3279
4276
|
function normalizeReferenceStatus(value) {
|
|
3280
4277
|
if (value === undefined || value === null || value === '') {
|
|
3281
4278
|
return null;
|
|
@@ -4935,6 +5932,8 @@ function pickOutlineConfig(params) {
|
|
|
4935
5932
|
blindBidConfirm: params.blindBidConfirm,
|
|
4936
5933
|
multiBidId: params.multiBidId,
|
|
4937
5934
|
multiBidType: params.multiBidType,
|
|
5935
|
+
bidderCompanyId: params.bidderCompanyId,
|
|
5936
|
+
bidderCompanyName: params.bidderCompanyName,
|
|
4938
5937
|
epcEngineerType: params.epcEngineerType,
|
|
4939
5938
|
});
|
|
4940
5939
|
}
|
|
@@ -5175,6 +6174,8 @@ function pickTaskSnapshot(source) {
|
|
|
5175
6174
|
choiceMultiBiddingId: source.choiceMultiBiddingId,
|
|
5176
6175
|
epcEngineerType: source.epcEngineerType,
|
|
5177
6176
|
bidderRole: source.bidderRole,
|
|
6177
|
+
bidderCompanyId: source.bidderCompanyId,
|
|
6178
|
+
bidderCompanyName: source.bidderCompanyName,
|
|
5178
6179
|
outlineReferenceType: source.outlineReferenceType,
|
|
5179
6180
|
referenceStatus: source.referenceStatus,
|
|
5180
6181
|
themeStyleSetting: source.themeStyleSetting,
|