@coolclaw/coolclaw 1.0.21 → 1.0.22
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.
|
@@ -651,6 +651,10 @@ async function handleInboundFrame(input) {
|
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
|
+
const gameEventEnvelope = isGameEventEnvelope(envelope);
|
|
655
|
+
if (gameEventEnvelope) {
|
|
656
|
+
await ackProcessedSeq(input, envelope);
|
|
657
|
+
}
|
|
654
658
|
let inFlightDeferred = null;
|
|
655
659
|
if (dedupeState) {
|
|
656
660
|
inFlightDeferred = createDeferred();
|
|
@@ -671,7 +675,9 @@ async function handleInboundFrame(input) {
|
|
|
671
675
|
dedupeState.inFlight.delete(dedupeState.eventId);
|
|
672
676
|
}
|
|
673
677
|
}
|
|
674
|
-
|
|
678
|
+
if (!gameEventEnvelope) {
|
|
679
|
+
await ackProcessedSeq(input, envelope);
|
|
680
|
+
}
|
|
675
681
|
}
|
|
676
682
|
function createDeferred() {
|
|
677
683
|
let resolve;
|
|
@@ -694,6 +700,9 @@ function isArenaVoiceSelectEnvelope(envelope) {
|
|
|
694
700
|
function isArenaPluginUpgradeEnvelope(envelope) {
|
|
695
701
|
return envelope.metadata?.arenaPluginUpgradeRequest === true && typeof envelope.metadata.eventId === "string" && envelope.metadata.eventId.length > 0;
|
|
696
702
|
}
|
|
703
|
+
function isGameEventEnvelope(envelope) {
|
|
704
|
+
return envelope.metadata?.gameEvent === true;
|
|
705
|
+
}
|
|
697
706
|
function mapNotificationFrame(frame) {
|
|
698
707
|
const payload = isRecord3(frame.payload) ? frame.payload : {};
|
|
699
708
|
const seq = typeof payload.seq === "number" ? payload.seq : void 0;
|
|
@@ -2136,6 +2145,12 @@ function hasStructuredRetryBudget(deadlineEpochMs, nowEpochMs = Date.now(), safe
|
|
|
2136
2145
|
}
|
|
2137
2146
|
return nowEpochMs < deadlineEpochMs - Math.max(0, safetyMarginMs);
|
|
2138
2147
|
}
|
|
2148
|
+
function isGameDeadlineExpired(deadlineEpochMs, nowEpochMs = Date.now()) {
|
|
2149
|
+
return typeof deadlineEpochMs === "number" && deadlineEpochMs > 0 && nowEpochMs >= deadlineEpochMs;
|
|
2150
|
+
}
|
|
2151
|
+
function isTerminalGameActionSubmitStatus(status) {
|
|
2152
|
+
return status === "submitted" || status === "uncertain" || status === "expired";
|
|
2153
|
+
}
|
|
2139
2154
|
function shouldSubmitStructuredRejectedOutput(params) {
|
|
2140
2155
|
if (!params.structuredTask || params.gameSubmitted) {
|
|
2141
2156
|
return false;
|
|
@@ -2169,6 +2184,12 @@ function assertInboundRuntimeAvailable(runtime, context) {
|
|
|
2169
2184
|
throw new Error(`CoolClaw runtime.channel unavailable while dispatching ${context.messageType}`);
|
|
2170
2185
|
}
|
|
2171
2186
|
async function submitGameActionWithLog(action, meta, wsClient, log, source, rawResponse, auditMeta) {
|
|
2187
|
+
if (isGameDeadlineExpired(meta.deadlineEpochMs)) {
|
|
2188
|
+
log?.warn?.(
|
|
2189
|
+
`[GAME-ACTION] submit skipped: deadline expired source=${source} eventId=${meta.eventId} deadlineEpochMs=${meta.deadlineEpochMs}`
|
|
2190
|
+
);
|
|
2191
|
+
return "expired";
|
|
2192
|
+
}
|
|
2172
2193
|
if (!wsClient.isConnected()) {
|
|
2173
2194
|
log?.error?.(`[GAME-ACTION] submit skipped: ws not connected eventId=${meta.eventId}`);
|
|
2174
2195
|
return "failed";
|
|
@@ -2349,7 +2370,7 @@ async function submitStructuredFinalActionWithLog(params) {
|
|
|
2349
2370
|
}
|
|
2350
2371
|
);
|
|
2351
2372
|
return {
|
|
2352
|
-
submitted: status
|
|
2373
|
+
submitted: isTerminalGameActionSubmitStatus(status),
|
|
2353
2374
|
status,
|
|
2354
2375
|
reason: status === "failed" ? `llm_action_submit_failed:${validation.action.actionType}` : void 0,
|
|
2355
2376
|
rawHash,
|
|
@@ -2836,7 +2857,7 @@ var coolclawChannelPlugin = createChatChannelPlugin({
|
|
|
2836
2857
|
retryValidationReason: structuredTask && gameReplyAttempt > 0 ? validation.repairReason : void 0
|
|
2837
2858
|
}
|
|
2838
2859
|
);
|
|
2839
|
-
if (submitted
|
|
2860
|
+
if (isTerminalGameActionSubmitStatus(submitted)) {
|
|
2840
2861
|
gameSubmitted = true;
|
|
2841
2862
|
} else {
|
|
2842
2863
|
gameFallbackReason = `llm_action_submit_failed:${validation.action.actionType}`;
|
package/dist/cli-metadata.js
CHANGED
package/dist/index.js
CHANGED
package/dist/setup-entry.js
CHANGED