@coolclaw/coolclaw 1.0.19 → 1.0.20
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.
|
@@ -2035,12 +2035,50 @@ function logAckFailure(params) {
|
|
|
2035
2035
|
const target = params.target ? ` target=${params.target}` : "";
|
|
2036
2036
|
params.log(`${params.channel} ack cleanup failed${target}: ${String(params.error)}`);
|
|
2037
2037
|
}
|
|
2038
|
-
function buildStructuredActionRetryPrompt(renderedPrompt, reason) {
|
|
2038
|
+
function buildStructuredActionRetryPrompt(renderedPrompt, reason, agentTask) {
|
|
2039
2039
|
const reasonText = reason && reason.trim().length > 0 ? reason.trim() : "invalid_output";
|
|
2040
|
+
const translatedReason = translateStructuredRetryReason(reasonText);
|
|
2041
|
+
const allowedActionTypes2 = agentTask?.actionContract?.options?.map((option) => option.actionType).filter((actionType) => typeof actionType === "string" && actionType.length > 0) ?? [];
|
|
2042
|
+
const allowedLine = allowedActionTypes2.length > 0 ? `
|
|
2043
|
+
\u5F53\u524D\u53EA\u5141\u8BB8 actionType\uFF1A${allowedActionTypes2.join("\u3001")}\u3002` : "";
|
|
2044
|
+
const forbiddenNames = [...forbiddenLegacyActionNames(allowedActionTypes2), "SUBMIT_ACTION", "reason", "content"];
|
|
2045
|
+
const forbiddenLine = allowedActionTypes2.length > 0 ? `
|
|
2046
|
+
\u4E0D\u8981\u4F7F\u7528 ${joinChineseOr(forbiddenNames)}\u3002` : "";
|
|
2040
2047
|
return `${renderedPrompt}
|
|
2041
2048
|
|
|
2042
|
-
|
|
2043
|
-
\u8BF7\u91CD\u65B0\
|
|
2049
|
+
${translatedReason}${allowedLine}${forbiddenLine}
|
|
2050
|
+
\u8BF7\u6309\u4E0A\u65B9\u3010\u8F93\u51FA\u683C\u5F0F\u3011\u91CD\u65B0\u8F93\u51FA\u5B8C\u6574 JSON\uFF1B\u53EA\u8F93\u51FA\u4E00\u4E2A\u5B8C\u6574 JSON \u5BF9\u8C61\uFF0C\u4E0D\u8981\u8F93\u51FA Markdown\u3001\u89E3\u91CA\u6587\u5B57\u6216\u4EE3\u7801\u5757\u3002`;
|
|
2051
|
+
}
|
|
2052
|
+
function translateStructuredRetryReason(reasonText) {
|
|
2053
|
+
if (reasonText === "disallowed_action_type") {
|
|
2054
|
+
return "\u4E0A\u4E00\u6B21\u8F93\u51FA\u672A\u88AB\u63A5\u53D7\uFF1AactionType \u4E0D\u5728\u5F53\u524D\u5141\u8BB8\u5217\u8868\u3002";
|
|
2055
|
+
}
|
|
2056
|
+
if (reasonText === "invalid_action_shape") {
|
|
2057
|
+
return "\u4E0A\u4E00\u6B21\u8F93\u51FA\u672A\u88AB\u63A5\u53D7\uFF1AJSON \u5B57\u6BB5\u7ED3\u6784\u4E0D\u7B26\u5408\u5F53\u524D\u3010\u8F93\u51FA\u683C\u5F0F\u3011\u3002";
|
|
2058
|
+
}
|
|
2059
|
+
if (reasonText === "missing_contract") {
|
|
2060
|
+
return "\u4E0A\u4E00\u6B21\u8F93\u51FA\u672A\u88AB\u63A5\u53D7\uFF1A\u5F53\u524D\u4EFB\u52A1\u7F3A\u5C11\u53EF\u63D0\u4EA4\u7684\u52A8\u4F5C\u5951\u7EA6\u3002";
|
|
2061
|
+
}
|
|
2062
|
+
return `\u4E0A\u4E00\u6B21\u8F93\u51FA\u672A\u88AB\u63A5\u53D7\uFF0C\u5931\u8D25\u539F\u56E0\uFF1A${reasonText}\u3002`;
|
|
2063
|
+
}
|
|
2064
|
+
function forbiddenLegacyActionNames(allowedActionTypes2) {
|
|
2065
|
+
const legacyNames = allowedActionTypes2.map((actionType) => {
|
|
2066
|
+
if (actionType === "WOLF_KILL") return "WOLF_TURN";
|
|
2067
|
+
if (actionType === "WITCH_SAVE" || actionType === "WITCH_POISON" || actionType === "WITCH_PASS") return "WITCH_TURN";
|
|
2068
|
+
if (actionType === "SEER_CHECK") return "SEER_TURN";
|
|
2069
|
+
if (actionType === "DAY_SPEAK") return "DAY_SPEAK_TURN";
|
|
2070
|
+
if (actionType === "DAY_VOTE") return "DAY_VOTE_TURN";
|
|
2071
|
+
if (actionType === "LAST_WORD") return "LAST_WORD_TURN";
|
|
2072
|
+
if (actionType === "HUNTER_SHOOT" || actionType === "HUNTER_PASS") return "HUNTER_SKILL_TURN";
|
|
2073
|
+
return void 0;
|
|
2074
|
+
}).filter((name) => Boolean(name));
|
|
2075
|
+
return [...new Set(legacyNames)];
|
|
2076
|
+
}
|
|
2077
|
+
function joinChineseOr(values) {
|
|
2078
|
+
if (values.length <= 1) {
|
|
2079
|
+
return values.join("");
|
|
2080
|
+
}
|
|
2081
|
+
return `${values.slice(0, -1).join("\u3001")} \u6216 ${values[values.length - 1]}`;
|
|
2044
2082
|
}
|
|
2045
2083
|
function hasStructuredRetryBudget(deadlineEpochMs, nowEpochMs = Date.now(), safetyMarginMs = 1e3) {
|
|
2046
2084
|
if (!deadlineEpochMs || deadlineEpochMs <= 0) {
|
|
@@ -2885,7 +2923,7 @@ var coolclawChannelPlugin = createChatChannelPlugin({
|
|
|
2885
2923
|
gameModelActionRejected = void 0;
|
|
2886
2924
|
gameModelActionType = void 0;
|
|
2887
2925
|
gameValidationReason = void 0;
|
|
2888
|
-
const retryPrompt = buildStructuredActionRetryPrompt(envelope.text, retryReason);
|
|
2926
|
+
const retryPrompt = buildStructuredActionRetryPrompt(envelope.text, retryReason, gameMeta.agentTask);
|
|
2889
2927
|
await dispatchGameReply({
|
|
2890
2928
|
...gameBaseReplyContext,
|
|
2891
2929
|
Body: retryPrompt,
|
package/dist/cli-metadata.js
CHANGED
package/dist/index.js
CHANGED
package/dist/setup-entry.js
CHANGED