@@ -24,6 +24,7 @@ const RESULT_ENVELOPE_KEYS = [
|
24 | 24 | "sendResult", |
25 | 25 | "toolResult", |
26 | 26 | ]; |
| 27 | +const BROADCAST_SEND_ENVELOPE_KEYS = ["payload", "result", "sendResult", "toolResult"]; |
27 | 28 | const PARTIAL_DELIVERY_ENVELOPE_KEYS = [...RESULT_ENVELOPE_KEYS, "error", "cause"]; |
28 | 29 | const SESSIONS_SEND_DELIVERY_STATUSES = new Set(["accepted", "ok"]); |
29 | 30 | const CONVERSATION_CREATE_ACTIONS = new Set([ |
@@ -233,6 +234,20 @@ function deliveryEnvelopeIndicatesNoOp(value: unknown, depth = 0): boolean {
|
233 | 234 | return RESULT_ENVELOPE_KEYS.some((key) => deliveryEnvelopeIndicatesNoOp(record[key], depth + 1)); |
234 | 235 | } |
235 | 236 | |
| 237 | +function broadcastEntryHasSuccessfulBareOkSend( |
| 238 | +record: Record<string, unknown>, |
| 239 | +depth: number, |
| 240 | +): boolean { |
| 241 | +return BROADCAST_SEND_ENVELOPE_KEYS.some((key) => { |
| 242 | +const value = record[key]; |
| 243 | +return ( |
| 244 | +deliveryEnvelopeIndicatesOk(value, depth + 1) && |
| 245 | +!deliveryEnvelopeIndicatesNonDelivery(value, depth + 1) && |
| 246 | +!deliveryEnvelopeIndicatesNoOp(value, depth + 1) |
| 247 | +); |
| 248 | +}); |
| 249 | +} |
| 250 | + |
236 | 251 | function deliveryEnvelopeIndicatesSuccessfulBroadcast(value: unknown, depth = 0): boolean { |
237 | 252 | if (!value || typeof value !== "object" || depth > 4) { |
238 | 253 | return false; |
@@ -246,7 +261,8 @@ function deliveryEnvelopeIndicatesSuccessfulBroadcast(value: unknown, depth = 0)
|
246 | 261 | (item as Record<string, unknown>).ok === true && |
247 | 262 | !deliveryEnvelopeIndicatesNonDelivery(item) && |
248 | 263 | !deliveryEnvelopeIndicatesNoOp(item) && |
249 | | -deliveryEnvelopeIndicatesDelivered(item, depth + 1), |
| 264 | +(deliveryEnvelopeIndicatesDelivered(item, depth + 1) || |
| 265 | +broadcastEntryHasSuccessfulBareOkSend(item as Record<string, unknown>, depth + 1)), |
250 | 266 | ); |
251 | 267 | } |
252 | 268 | const record = value as Record<string, unknown>; |
|