glove-foundry 0.10.1 → 0.11.0

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.
@@ -576,6 +576,7 @@ function openRunMailbox(options) {
576
576
  const meshWaiters = /* @__PURE__ */ new Map();
577
577
  const handlers = /* @__PURE__ */ new Set();
578
578
  const meshHandlers = /* @__PURE__ */ new Set();
579
+ const eventRoutes = /* @__PURE__ */ new Set();
579
580
  let closed = false;
580
581
  const toHandlers = async (updates) => {
581
582
  for (const handler of [...handlers]) await handler(updates);
@@ -590,6 +591,7 @@ function openRunMailbox(options) {
590
591
  const meshAnswers = /* @__PURE__ */ new Map();
591
592
  const heardMesh = [];
592
593
  const updates = [];
594
+ const routed = [];
593
595
  const rest = [];
594
596
  for (const delivery of deliveries) {
595
597
  if (delivery.durable?.event.expiresAt && Date.parse(delivery.durable.event.expiresAt) <= Date.now()) {
@@ -609,7 +611,9 @@ function openRunMailbox(options) {
609
611
  } else if (isDelegationUpdate(delivery) && handlers.size > 0) {
610
612
  updates.push(delivery);
611
613
  } else {
612
- rest.push(delivery);
614
+ const route = [...eventRoutes].find((candidate) => candidate.match(delivery));
615
+ if (route) routed.push({ route, delivery });
616
+ else rest.push(delivery);
613
617
  }
614
618
  }
615
619
  for (const [delegationId, batch] of replies) {
@@ -622,6 +626,7 @@ function openRunMailbox(options) {
622
626
  if (updates.length > 0) await toHandlers(updates);
623
627
  if (heardMesh.length > 0) for (const handler of [...meshHandlers]) await handler(heardMesh.map((item) => item.message));
624
628
  options.consumed?.([...[...replies.values()].flat(), ...[...meshAnswers.values()].flat(), ...updates, ...heardMesh]);
629
+ for (const { route, delivery } of routed) await route.take(delivery);
625
630
  if (rest.length > 0) await options.sink.forward(rest);
626
631
  }
627
632
  });
@@ -687,13 +692,25 @@ function openRunMailbox(options) {
687
692
  await waiting;
688
693
  };
689
694
  },
695
+ onEvents(match, take) {
696
+ const route = { match, take };
697
+ eventRoutes.add(route);
698
+ const waiting = options.sink.reclaim(match).then(async (taken) => {
699
+ for (const delivery of taken) await take(delivery);
700
+ });
701
+ return async () => {
702
+ eventRoutes.delete(route);
703
+ await waiting;
704
+ };
705
+ },
690
706
  async close() {
691
707
  if (closed) return;
692
708
  closed = true;
693
709
  for (const finish of [...waiters.values()]) finish(null);
694
710
  for (const finish of [...meshWaiters.values()]) finish(null);
695
711
  await listener.stop(async () => {
696
- for (const delivery of await options.sink.reclaim(() => true)) {
712
+ const unused = options.sink.release ? await options.sink.release() : await options.sink.reclaim(() => true);
713
+ for (const delivery of unused) {
697
714
  await writeMailboxDelivery(options.directory, options.conversationId, delivery);
698
715
  }
699
716
  });
@@ -736,6 +753,9 @@ function deliveryOf(event) {
736
753
  }
737
754
  var formatRunEvents = defaultEventFormatter;
738
755
  var RunEventQueue = class {
756
+ constructor(preparation) {
757
+ this.preparation = preparation;
758
+ }
739
759
  events = [];
740
760
  async push(event) {
741
761
  if (this.events.some((queued) => queued.id === event.id)) return false;
@@ -748,7 +768,26 @@ var RunEventQueue = class {
748
768
  async take() {
749
769
  const taken = this.events;
750
770
  this.events = [];
751
- return taken;
771
+ if (!this.preparation) return taken;
772
+ const ready = [];
773
+ const kept = [];
774
+ for (const event of taken) {
775
+ const delivery = deliveryOf(event);
776
+ if (!delivery || !this.preparation.applies(delivery)) {
777
+ ready.push(event);
778
+ continue;
779
+ }
780
+ try {
781
+ const prepared = await this.preparation.prepare(event, delivery);
782
+ if ("suppress" in prepared) this.preparation.suppressed(delivery, prepared.suppress);
783
+ else ready.push({ ...event, content: prepared.say });
784
+ } catch (cause) {
785
+ kept.push(event);
786
+ this.preparation.failed(event, cause);
787
+ }
788
+ }
789
+ this.events = [...kept, ...this.events];
790
+ return ready;
752
791
  }
753
792
  async remove(ids) {
754
793
  const drop = new Set(ids);
@@ -787,6 +826,60 @@ async function waitForConversationLease(directory, runId, signal, pollMs = 25) {
787
826
  }
788
827
  }
789
828
 
829
+ // src/event-receipts.ts
830
+ import { createHash as createHash2 } from "node:crypto";
831
+ import { Effect } from "effect";
832
+ function matchesReceiptFilter(receipt, filter = {}) {
833
+ if (filter.agentId && receipt.agentId !== filter.agentId) return false;
834
+ if (filter.conversationId && receipt.conversationId !== filter.conversationId) return false;
835
+ if (filter.status) {
836
+ const statuses = typeof filter.status === "string" ? [filter.status] : filter.status;
837
+ if (!statuses.includes(receipt.status)) return false;
838
+ }
839
+ return true;
840
+ }
841
+ function assertEventReceipt(receipt) {
842
+ if (!receipt.id || !receipt.eventId) throw new Error("Event receipt must name its event.");
843
+ if (!receipt.agentId || !receipt.conversationId) throw new Error("Event receipt must name its conversation.");
844
+ }
845
+ function lateChatEffectId(receiptId) {
846
+ return `effect_${createHash2("sha256").update(`late-chat\0${receiptId}`).digest("hex")}`;
847
+ }
848
+ function eventTranscriptMessageId(receiptId) {
849
+ return `foundry-event:${receiptId}`;
850
+ }
851
+ var processReceipts = /* @__PURE__ */ new WeakMap();
852
+ function eventReceiptStore(data) {
853
+ if (data.claimEventReceipt && data.putEventReceipt && data.getEventReceipt) {
854
+ return {
855
+ durable: true,
856
+ get: (id) => Effect.runPromise(data.getEventReceipt(id)),
857
+ claim: (receipt) => Effect.runPromise(data.claimEventReceipt(receipt)),
858
+ put: (receipt) => Effect.runPromise(data.putEventReceipt(receipt))
859
+ };
860
+ }
861
+ let local = processReceipts.get(data);
862
+ if (!local) processReceipts.set(data, local = /* @__PURE__ */ new Map());
863
+ const memory = local;
864
+ return {
865
+ durable: false,
866
+ async get(id) {
867
+ const receipt = memory.get(id);
868
+ return receipt ? structuredClone(receipt) : null;
869
+ },
870
+ async claim(receipt) {
871
+ assertEventReceipt(receipt);
872
+ if (memory.has(receipt.id)) return false;
873
+ memory.set(receipt.id, structuredClone(receipt));
874
+ return true;
875
+ },
876
+ async put(receipt) {
877
+ assertEventReceipt(receipt);
878
+ memory.set(receipt.id, structuredClone(receipt));
879
+ }
880
+ };
881
+ }
882
+
790
883
  export {
791
884
  meshIdentity,
792
885
  isThreadId,
@@ -819,8 +912,14 @@ export {
819
912
  drainMailbox,
820
913
  openRunMailbox,
821
914
  deliveryEvent,
915
+ deliveryOf,
822
916
  formatRunEvents,
823
917
  RunEventQueue,
824
918
  writeConversationLease,
825
- waitForConversationLease
919
+ waitForConversationLease,
920
+ matchesReceiptFilter,
921
+ assertEventReceipt,
922
+ lateChatEffectId,
923
+ eventTranscriptMessageId,
924
+ eventReceiptStore
826
925
  };
@@ -1,3 +1,7 @@
1
+ import {
2
+ assertEventReceipt,
3
+ matchesReceiptFilter
4
+ } from "./chunk-2JCISE2U.js";
1
5
  import {
2
6
  DURABLE_SEGMENT,
3
7
  EMPTY_CAPABILITY_REGISTRY,
@@ -21,7 +25,7 @@ import {
21
25
  installationKey,
22
26
  internalAgentName,
23
27
  waitForFoundryCoreCommandResult
24
- } from "./chunk-CYOIHSUX.js";
28
+ } from "./chunk-NWFOY3L7.js";
25
29
 
26
30
  // src/application.ts
27
31
  var FOUNDRY_APPLICATION_BRAND = /* @__PURE__ */ Symbol.for(
@@ -943,6 +947,7 @@ var MemoryFoundryDataAdapter = class {
943
947
  approvals = /* @__PURE__ */ new Map();
944
948
  activations = /* @__PURE__ */ new Map();
945
949
  occurrences = /* @__PURE__ */ new Map();
950
+ receipts = /* @__PURE__ */ new Map();
946
951
  conversations = /* @__PURE__ */ new Map();
947
952
  workspace = /* @__PURE__ */ new Map();
948
953
  workingEnvironments = /* @__PURE__ */ new Map();
@@ -1028,6 +1033,7 @@ var MemoryFoundryDataAdapter = class {
1028
1033
  for (const [id2, item] of this.approvals) if (item.agentId === agentId) this.approvals.delete(id2);
1029
1034
  for (const [id2, item] of this.activations) if (item.agentId === agentId) this.activations.delete(id2);
1030
1035
  for (const [id2, item] of this.occurrences) if (item.agentId === agentId) this.occurrences.delete(id2);
1036
+ for (const [id2, item] of this.receipts) if (item.agentId === agentId) this.receipts.delete(id2);
1031
1037
  for (const id2 of conversationIds) this.conversations.delete(id2);
1032
1038
  for (const [id2, item] of this.inbox) if (item.agentId === agentId || conversationIds.has(item.conversationId ?? "")) this.inbox.delete(id2);
1033
1039
  for (const [id2, item] of this.tasks) if (item.agentId === agentId || conversationIds.has(item.conversationId ?? "")) this.tasks.delete(id2);
@@ -1113,6 +1119,29 @@ var MemoryFoundryDataAdapter = class {
1113
1119
  listEvents() {
1114
1120
  return Effect2.sync(() => [...this.events.values()].map((record) => structuredClone(record)));
1115
1121
  }
1122
+ claimEventReceipt(receipt) {
1123
+ return Effect2.sync(() => {
1124
+ assertEventReceipt(receipt);
1125
+ if (this.receipts.has(receipt.id)) return false;
1126
+ this.receipts.set(receipt.id, structuredClone(receipt));
1127
+ return true;
1128
+ });
1129
+ }
1130
+ putEventReceipt(receipt) {
1131
+ return Effect2.sync(() => {
1132
+ assertEventReceipt(receipt);
1133
+ this.receipts.set(receipt.id, structuredClone(receipt));
1134
+ });
1135
+ }
1136
+ getEventReceipt(id2) {
1137
+ return Effect2.sync(() => {
1138
+ const receipt = this.receipts.get(id2);
1139
+ return receipt ? structuredClone(receipt) : null;
1140
+ });
1141
+ }
1142
+ listEventReceipts(filter) {
1143
+ return Effect2.sync(() => [...this.receipts.values()].filter((item) => matchesReceiptFilter(item, filter)).map((item) => structuredClone(item)));
1144
+ }
1116
1145
  claimScheduleOccurrence(occurrence) {
1117
1146
  return Effect2.sync(() => {
1118
1147
  assertScheduleOccurrence(occurrence);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveResolvable
3
- } from "./chunk-CYOIHSUX.js";
3
+ } from "./chunk-NWFOY3L7.js";
4
4
 
5
5
  // src/guidance.ts
6
6
  import { createHash } from "node:crypto";
@@ -226,6 +226,9 @@ function eventRecordId(target, eventId) {
226
226
  function eventDue(record, now = Date.now()) {
227
227
  return record.policy.whenIdle !== "defer" || record.policy.deferTimeoutMs !== void 0 && now >= Date.parse(record.createdAt) + record.policy.deferTimeoutMs;
228
228
  }
229
+ function isGenericDelivery(delivery) {
230
+ return delivery.kind === "agent-message" || delivery.kind === "transmission";
231
+ }
229
232
 
230
233
  // src/core-command-result.ts
231
234
  import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
@@ -1151,6 +1154,7 @@ var CONVENTION_EXPORTS = [
1151
1154
  "delegates",
1152
1155
  "durableSubagents",
1153
1156
  "eventDelivery",
1157
+ "prepareEvent",
1154
1158
  "answerWaitMs",
1155
1159
  "memory",
1156
1160
  "goals",
@@ -1295,6 +1299,7 @@ export {
1295
1299
  foundryEventSchema,
1296
1300
  eventRecordId,
1297
1301
  eventDue,
1302
+ isGenericDelivery,
1298
1303
  FOUNDRY_CORE_COMMAND_DIRECTORY_ENV,
1299
1304
  createFoundryCoreCommandRequest,
1300
1305
  getFoundryCoreCommandRequest,
@@ -40,7 +40,7 @@ import {
40
40
  scheduleOccurrenceId,
41
41
  scheduleRevisionMatches,
42
42
  transmissionPredicate
43
- } from "./chunk-VLD3DKPI.js";
43
+ } from "./chunk-4WBQ7XVF.js";
44
44
  import {
45
45
  FOUNDRY_CONVERSATION_LEASE_EVENT,
46
46
  FOUNDRY_CONVERSATION_LISTEN_EVENT,
@@ -64,7 +64,7 @@ import {
64
64
  workerAgentId,
65
65
  writeConversationLease,
66
66
  writeMailboxDelivery
67
- } from "./chunk-J6NHL4SM.js";
67
+ } from "./chunk-2JCISE2U.js";
68
68
  import {
69
69
  EMPTY_CAPABILITY_REGISTRY,
70
70
  EMPTY_NATIVE_REGISTRY,
@@ -97,7 +97,7 @@ import {
97
97
  messageOptionsSchema,
98
98
  monitorFoundryCoreCommandRequest,
99
99
  settleFoundryCoreCommandRequest
100
- } from "./chunk-CYOIHSUX.js";
100
+ } from "./chunk-NWFOY3L7.js";
101
101
 
102
102
  // src/codegen.ts
103
103
  import { mkdir, writeFile } from "node:fs/promises";
@@ -1789,6 +1789,8 @@ var FoundryRuntime = class _FoundryRuntime {
1789
1789
  });
1790
1790
  /** Pending inbound records each run is handling, so they are cleared when it settles. */
1791
1791
  eventTimers = /* @__PURE__ */ new Map();
1792
+ /** Events a run withheld because preparing them failed: attempts so far and the pending retry. */
1793
+ eventRetries = /* @__PURE__ */ new Map();
1792
1794
  completedEventRuns = /* @__PURE__ */ new Map();
1793
1795
  pendingInboundByRun = /* @__PURE__ */ new Map();
1794
1796
  /** Recently settled runs, for a record assigned to a run that already finished. */
@@ -2077,6 +2079,8 @@ var FoundryRuntime = class _FoundryRuntime {
2077
2079
  this.stopping = true;
2078
2080
  for (const timer of this.eventTimers.values()) clearTimeout(timer);
2079
2081
  this.eventTimers.clear();
2082
+ for (const retry of this.eventRetries.values()) if (retry.timer) clearTimeout(retry.timer);
2083
+ this.eventRetries.clear();
2080
2084
  for (const timer of this.activationTimers.values()) clearTimeout(timer);
2081
2085
  this.activationTimers.clear();
2082
2086
  this.activationDispatches.clear();
@@ -4128,6 +4132,49 @@ var FoundryRuntime = class _FoundryRuntime {
4128
4132
  await Effect5.runPromise(this.data.putEvent({ ...record, runId, ...acknowledged ? { status: "acknowledged" } : {} }));
4129
4133
  }
4130
4134
  }
4135
+ /**
4136
+ * Deliver events again after a delay that doubles each time (1s up to 5
4137
+ * minutes), when a run withheld them because preparing them failed. They
4138
+ * stay pending meanwhile; a restart delivers them as usual.
4139
+ */
4140
+ scheduleEventRetries(ids) {
4141
+ if (this.stopping) return;
4142
+ for (const id2 of ids) {
4143
+ const retry = this.eventRetries.get(id2) ?? { attempts: 0 };
4144
+ if (retry.timer) continue;
4145
+ retry.attempts++;
4146
+ const delay = Math.min(1e3 * 2 ** (retry.attempts - 1), 3e5);
4147
+ retry.timer = setTimeout(() => {
4148
+ retry.timer = void 0;
4149
+ void this.retryEvent(id2).catch((cause) => this.reportDeliveryFailure("event-retry", cause));
4150
+ }, delay);
4151
+ retry.timer.unref?.();
4152
+ this.eventRetries.set(id2, retry);
4153
+ }
4154
+ }
4155
+ async retryEvent(id2) {
4156
+ if (this.stopping || !this.data.listEvents) return;
4157
+ const record = (await Effect5.runPromise(this.data.listEvents())).find((item) => item.id === id2);
4158
+ if (!record || record.status !== "pending") {
4159
+ this.eventRetries.delete(id2);
4160
+ return;
4161
+ }
4162
+ const owner = await Effect5.runPromise(this.data.getAgent(record.target.agentId));
4163
+ if (!owner) {
4164
+ this.eventRetries.delete(id2);
4165
+ return;
4166
+ }
4167
+ try {
4168
+ await this.assertDurableActive(owner);
4169
+ } catch {
4170
+ return;
4171
+ }
4172
+ await this.deliver(
4173
+ { ...record.target, definitionId: record.definitionId, workspaceId: record.workspaceId },
4174
+ [{ ...record.delivery, durable: { id: record.id, event: record.event, policy: record.policy } }],
4175
+ true
4176
+ );
4177
+ }
4131
4178
  async finishEvents(runId, consumed) {
4132
4179
  if (!this.data.listEvents || !this.data.putEvent || this.stopping) return;
4133
4180
  const run = await this.getRun(runId);
@@ -4144,6 +4191,9 @@ var FoundryRuntime = class _FoundryRuntime {
4144
4191
  continue;
4145
4192
  }
4146
4193
  await Effect5.runPromise(this.data.putEvent({ ...record, status: record.event.expiresAt && Date.parse(record.event.expiresAt) <= Date.now() ? "expired" : "acknowledged", runId }));
4194
+ const retry = this.eventRetries.get(record.id);
4195
+ if (retry?.timer) clearTimeout(retry.timer);
4196
+ this.eventRetries.delete(record.id);
4147
4197
  if ((record.delivery.kind === "transmission" || record.delivery.kind === "agent-message") && this.data.deletePendingInbound) {
4148
4198
  await Effect5.runPromise(this.data.deletePendingInbound(record.delivery.pendingId));
4149
4199
  }
@@ -4858,6 +4908,7 @@ var FoundryRuntime = class _FoundryRuntime {
4858
4908
  if (event.status === "completed") {
4859
4909
  const result = parseJson(event.output);
4860
4910
  await this.finishEvents(event.run.id, result?.consumedEventIds ?? []);
4911
+ if (result?.retryEventIds?.length) this.scheduleEventRetries(result.retryEventIds);
4861
4912
  }
4862
4913
  await this.finishPendingInbound(event.run.id).catch((cause) => this.reportDeliveryFailure(this.toFoundryRun(event.run).conversationId ?? "settle", cause));
4863
4914
  };
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  FoundryRuntime,
4
4
  FoundryServer,
5
5
  writeGeneratedTypes
6
- } from "./chunk-L72FKI7P.js";
6
+ } from "./chunk-YCW66WKQ.js";
7
7
  import {
8
8
  DEFAULT_FOUNDRY_CONFIG
9
9
  } from "./chunk-ZFNMFE3T.js";
@@ -11,9 +11,9 @@ import "./chunk-J7ZBJM54.js";
11
11
  import {
12
12
  EMPTY_FOUNDRY_APPLICATION,
13
13
  isFoundryApplication
14
- } from "./chunk-VLD3DKPI.js";
15
- import "./chunk-J6NHL4SM.js";
16
- import "./chunk-CYOIHSUX.js";
14
+ } from "./chunk-4WBQ7XVF.js";
15
+ import "./chunk-2JCISE2U.js";
16
+ import "./chunk-NWFOY3L7.js";
17
17
 
18
18
  // src/cli.ts
19
19
  import { watch } from "node:fs";
@@ -1,5 +1,5 @@
1
1
  import { StoreAdapter, AgentEvent, Message, TokenConsumptionCounter } from 'glove-core';
2
- import { x as AccountId, o as AccountReference, y as AccountNotFound, d1 as TransmissionId, cV as RouteId, cU as Route, cW as RouteNotFound, c_ as TopologyConflict, a3 as BindingId, q as AgentBinding, a4 as BindingNotFound, Q as AgentId, ax as EventReference, av as EventId, aw as EventNotFound, cY as RunId, z as AccountSessionUnavailable, b as FoundryDataAdapter, bB as FoundryInstanceProvisioner, j as FoundryApproval, a$ as FoundryAgentDefinition, cX as RunGrant, cx as GrantResolutionError, n as AnyFoundryTransmission, bg as FoundryCapabilityRegistry, bZ as FoundryNativeRegistry, c5 as FoundryRequest, a9 as CreateAgentInstanceOptions, c as AgentInstance, bV as FoundryMessageOptions, V as AgentMessageReceipt, br as FoundryEventTarget, bq as FoundryEventPolicy, C as Conversation, f as FoundryEventRecord, d as FoundryActivationRecord, i as FoundryPendingInbound, l as FoundryTask, S as SharedInboxItem, aa as CreateConversationOptions, m as AgentPlaybook, P as PlaybookSubscription, al as DefinePlaybookSubscriptionOptions, a1 as ApplicationConnectionState, d5 as UpdateAgentInstanceOptions, d6 as UpdateConversationOptions, W as WorkspaceEntry, E as EnvironmentValue, bU as FoundryMessageInput, c8 as FoundryResult, b9 as FoundryApprovalStatus, b6 as FoundryApprovalDecision, be as FoundryCapabilityManifest, bX as FoundryNativeManifest, T as AgentInstallation, bo as FoundryDelegationStatus, bm as FoundryDelegation, bT as FoundryMeshThreadStatus, bS as FoundryMeshThread, h as FoundryScheduleOccurrenceFilter, g as FoundryScheduleOccurrence, c9 as FoundryRouteMap, B as AccountSummary, _ as AnyFoundryAgent } from './event-delivery-C7rYiNPs.js';
2
+ import { B as AccountId, r as AccountReference, D as AccountNotFound, d8 as TransmissionId, d0 as RouteId, c$ as Route, d1 as RouteNotFound, d5 as TopologyConflict, a6 as BindingId, t as AgentBinding, a7 as BindingNotFound, U as AgentId, aB as EventReference, ay as EventId, az as EventNotFound, d3 as RunId, G as AccountSessionUnavailable, d as FoundryDataAdapter, bI as FoundryInstanceProvisioner, m as FoundryApproval, b3 as FoundryAgentDefinition, d2 as RunGrant, cE as GrantResolutionError, q as AnyFoundryTransmission, bk as FoundryCapabilityRegistry, c4 as FoundryNativeRegistry, cc as FoundryRequest, ac as CreateAgentInstanceOptions, e as AgentInstance, c0 as FoundryMessageOptions, Z as AgentMessageReceipt, bx as FoundryEventTarget, bu as FoundryEventPolicy, C as Conversation, h as FoundryEventRecord, f as FoundryActivationRecord, l as FoundryPendingInbound, o as FoundryTask, S as SharedInboxItem, ad as CreateConversationOptions, p as AgentPlaybook, P as PlaybookSubscription, ao as DefinePlaybookSubscriptionOptions, a4 as ApplicationConnectionState, dc as UpdateAgentInstanceOptions, dd as UpdateConversationOptions, W as WorkspaceEntry, E as EnvironmentValue, b$ as FoundryMessageInput, cf as FoundryResult, bd as FoundryApprovalStatus, ba as FoundryApprovalDecision, bi as FoundryCapabilityManifest, c2 as FoundryNativeManifest, X as AgentInstallation, bs as FoundryDelegationStatus, bq as FoundryDelegation, b_ as FoundryMeshThreadStatus, bZ as FoundryMeshThread, k as FoundryScheduleOccurrenceFilter, j as FoundryScheduleOccurrence, cg as FoundryRouteMap, H as AccountSummary, a1 as AnyFoundryAgent } from './event-delivery-BfSL9sGo.js';
3
3
  import * as effect_Brand from 'effect/Brand';
4
4
  import { Context, Effect, Layer, Schema } from 'effect';
5
5
  import { FoundryStationDaemonAdapter } from './station.js';
@@ -456,6 +456,8 @@ declare class FoundryRuntime {
456
456
  private readonly gate;
457
457
  /** Pending inbound records each run is handling, so they are cleared when it settles. */
458
458
  private readonly eventTimers;
459
+ /** Events a run withheld because preparing them failed: attempts so far and the pending retry. */
460
+ private readonly eventRetries;
459
461
  private readonly completedEventRuns;
460
462
  private readonly pendingInboundByRun;
461
463
  /** Recently settled runs, for a record assigned to a run that already finished. */
@@ -621,10 +623,10 @@ declare class FoundryRuntime {
621
623
  installCapability(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
622
624
  uninstallCapability(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
623
625
  listAccounts(): Promise<{
624
- label?: string | undefined;
625
626
  id: string & effect_Brand.Brand<"FoundryAccountId">;
626
627
  transmissionId: string & effect_Brand.Brand<"FoundryTransmissionId">;
627
628
  externalAccountId: string;
629
+ label?: string | undefined;
628
630
  metadata: {
629
631
  readonly [x: string]: unknown;
630
632
  };
@@ -727,6 +729,13 @@ declare class FoundryRuntime {
727
729
  /** Start one run with everything held for a conversation, once nothing else holds it. */
728
730
  private flushHeldDeliveries;
729
731
  private markHandedOver;
732
+ /**
733
+ * Deliver events again after a delay that doubles each time (1s up to 5
734
+ * minutes), when a run withheld them because preparing them failed. They
735
+ * stay pending meanwhile; a restart delivers them as usual.
736
+ */
737
+ private scheduleEventRetries;
738
+ private retryEvent;
730
739
  private finishEvents;
731
740
  private redeliverEvents;
732
741
  /** Clear the bookkeeping that lets a restart hand these deliveries over again. */
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'glove-core';
2
- import './event-delivery-C7rYiNPs.js';
3
- export { k as FoundryClient, l as FoundryClientAuthorizationAdapter, m as FoundryClientOptions, q as FoundryHealth, y as FoundryRunHandle, G as FoundrySteerHandleResult, W as WaitOptions, N as createFoundryClient } from './client-HM2x2-Ut.js';
2
+ import './event-delivery-BfSL9sGo.js';
3
+ export { k as FoundryClient, l as FoundryClientAuthorizationAdapter, m as FoundryClientOptions, q as FoundryHealth, y as FoundryRunHandle, G as FoundrySteerHandleResult, W as WaitOptions, N as createFoundryClient } from './client-B4Emyeek.js';
4
4
  import 'effect';
5
5
  import 'zod';
6
6
  import 'glove-mesh';