@effect-agent/platform-cloudflare 0.1.0-beta.34 → 0.1.0-beta.36

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/dist/index.mjs CHANGED
@@ -342,10 +342,12 @@ const ensureTransactionAlarmBy = async (transaction, deadline) => {
342
342
  if (scheduled === null || scheduled > deadline) await transaction.setAlarm(deadline);
343
343
  };
344
344
  const stableExternalWait = (snapshot, reports) => {
345
+ const decision = reports.get(snapshot.submissionId)?.decision._tag;
346
+ if (decision === "SettleAborted") return false;
345
347
  switch (snapshot.state) {
346
348
  case "suspended":
347
- case "unknown":
348
349
  case "joined": return true;
350
+ case "unknown": return decision === "AwaitUnknownResolution" || decision === "MarkUnknown";
349
351
  case "admitted": return reports.get(snapshot.submissionId)?.decision._tag === "AwaitParentEstablishment";
350
352
  case "input-applied":
351
353
  case "joining":
@@ -481,7 +483,12 @@ var ConversationMaintenance = class ConversationMaintenance extends Context.Serv
481
483
  const settlements = yield* runtime.processConversationResolved(identity.conversationId).pipe(Effect.provideService(AgentBindingResolver, resolver));
482
484
  const remaining = yield* Stream.runCollect(ledger.scanNonterminal);
483
485
  const reports = new Map(recovered.map((report) => [report.submissionId, report]));
484
- const autonomous = remaining.some((snapshot) => !stableExternalWait(snapshot, reports));
486
+ const head = remaining[0];
487
+ const headWaiting = head !== void 0 && stableExternalWait(head, reports);
488
+ const autonomous = remaining.some((snapshot, index) => {
489
+ if (index > 0 && headWaiting && snapshot.state === "ready" && reports.get(snapshot.submissionId)?.decision._tag === "ApplyInput") return false;
490
+ return !stableExternalWait(snapshot, reports);
491
+ });
485
492
  const progressed = settlements.length > 0 || recovered.some((report) => report.disposition === "repaired");
486
493
  const delay = autonomous ? yield* rearmDelay(progressed) : 0;
487
494
  const now = yield* Clock.currentTimeMillis;