@swirls/looms 0.18.0 → 0.18.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @swirls/looms
2
2
 
3
+ ## 0.18.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 14bfc23: A wake that reaches `maxWakeIterations` no longer fails and leaves its run with nothing driving
8
+ it. It starts nothing new, waits for the effects it already started, parks, and asks its
9
+ scheduler to wake the run again at once, as the hosting guide describes. A long agent session
10
+ whose workers kept calling tools could reach the limit inside one wake and then sit idle until
11
+ an unrelated request woke it. `MaxWakeIterationsError` is no longer raised and is deprecated.
12
+
3
13
  ## 0.18.0
4
14
 
5
15
  ### Minor Changes
@@ -31,252 +31,6 @@ export declare const callLlmEffect: NoInfer<import("@swirls/looms/core").LocalEf
31
31
  readonly alreadyCompacted?: boolean | undefined;
32
32
  readonly consumedSteerMessageIds?: readonly string[] | undefined;
33
33
  }, AgentDefinitionsTag | LlmTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
34
- readonly type: "runtime.child.close.requested";
35
- readonly payload: {
36
- readonly policy: "terminate" | "wait";
37
- };
38
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
39
- readonly type: "runtime.child.settled";
40
- readonly payload: {
41
- readonly runId: string;
42
- readonly status: "cancelled" | "completed" | "failed";
43
- readonly output: Schema.Json;
44
- readonly error: string | null;
45
- };
46
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
47
- readonly type: "runtime.effect.ambiguous";
48
- readonly payload: {
49
- readonly effectId: string;
50
- readonly attempt: number;
51
- readonly error: string;
52
- };
53
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
54
- readonly type: "runtime.effect.attempt.started";
55
- readonly payload: {
56
- readonly effectId: string;
57
- readonly attempt: number;
58
- };
59
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
60
- readonly type: "runtime.effect.cancel.requested";
61
- readonly payload: {
62
- readonly effectId: string;
63
- readonly attempt: number;
64
- readonly deadlineAt: number | null;
65
- };
66
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
67
- readonly type: "runtime.effect.cancelled";
68
- readonly payload: {
69
- readonly effectId: string;
70
- readonly attempt: number;
71
- };
72
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
73
- readonly type: "runtime.effect.completed";
74
- readonly payload: {
75
- readonly effectId: string;
76
- readonly attempt: number;
77
- };
78
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
79
- readonly type: "runtime.effect.dispatch.deferred";
80
- readonly payload: {
81
- readonly effectId: string;
82
- readonly attempt: number;
83
- readonly retryAt: number;
84
- readonly error: string;
85
- readonly try: number;
86
- };
87
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
88
- readonly type: "runtime.effect.dispatched";
89
- readonly payload: {
90
- readonly effectId: string;
91
- readonly attempt: number;
92
- readonly deadlineAt: number | null;
93
- };
94
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
95
- readonly type: "runtime.effect.failed";
96
- readonly payload: {
97
- readonly effectId: string;
98
- readonly error: string;
99
- readonly nonRetryable?: boolean | undefined;
100
- readonly retryAfterMs?: number | undefined;
101
- };
102
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
103
- readonly type: "runtime.effect.heartbeat";
104
- readonly payload: {
105
- readonly effectId: string;
106
- readonly attempt: number;
107
- readonly heartbeatAt: number;
108
- readonly deadlineAt: number | null;
109
- readonly details?: Schema.Json | undefined;
110
- };
111
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
112
- readonly type: "runtime.effect.queued";
113
- readonly payload: {
114
- readonly effectId: string;
115
- readonly attempt: number;
116
- readonly deadlineAt: number | null;
117
- };
118
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
119
- readonly type: "runtime.effect.retry.scheduled";
120
- readonly payload: {
121
- readonly effectId: string;
122
- readonly attempt: number;
123
- readonly nextAttemptAt: number;
124
- readonly error: string;
125
- };
126
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
127
- readonly type: "runtime.effect.timed_out";
128
- readonly payload: {
129
- readonly effectId: string;
130
- readonly attempt: number;
131
- readonly timeout: string;
132
- };
133
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
134
- readonly type: "runtime.effect.worker.started";
135
- readonly payload: {
136
- readonly effectId: string;
137
- readonly attempt: number;
138
- readonly deadlineAt: number | null;
139
- };
140
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
141
- readonly type: "runtime.fork.elided";
142
- readonly payload: {
143
- readonly type: string;
144
- };
145
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
146
- readonly type: "runtime.run.cancelled";
147
- readonly payload: {
148
- readonly reason?: string | undefined;
149
- };
150
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
151
- readonly type: "runtime.run.completed";
152
- readonly payload: {
153
- readonly output: Schema.Json;
154
- readonly error: string | null;
155
- };
156
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
157
- readonly type: "runtime.run.forked";
158
- readonly payload: {
159
- readonly sourceRunId: string;
160
- readonly sourceSeq: number;
161
- };
162
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
163
- readonly type: "runtime.run.launched";
164
- readonly payload: {
165
- readonly runId: string;
166
- readonly kind: string;
167
- readonly definitionName: string;
168
- readonly definitionVersion: string;
169
- readonly effectId: string;
170
- readonly close: "terminate" | "wait";
171
- };
172
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
173
- readonly type: "runtime.run.started";
174
- readonly payload: {
175
- readonly rootThreadId?: string | undefined;
176
- readonly kind: string;
177
- readonly definitionName: string;
178
- readonly definitionVersion: string;
179
- readonly input: Schema.Json;
180
- readonly requestedThreadId?: string | null | undefined;
181
- readonly launchedBy?: {
182
- readonly runId: string;
183
- readonly threadId: string;
184
- readonly effectId: string;
185
- readonly causationId: string;
186
- readonly causationSeq: number;
187
- } | undefined;
188
- readonly attributes?: {
189
- readonly [x: string]: string;
190
- } | undefined;
191
- readonly trace?: {
192
- readonly traceparent: string;
193
- readonly tracestate?: string | undefined;
194
- } | undefined;
195
- };
196
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
197
- readonly type: "runtime.signal.received";
198
- readonly payload: {
199
- readonly signalType: string;
200
- };
201
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
202
- readonly type: "runtime.snapshot.taken";
203
- readonly payload: {
204
- readonly seq: number;
205
- readonly stateHash: string;
206
- readonly state?: Schema.Json | undefined;
207
- };
208
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
209
- readonly type: "runtime.thread.cancel.requested";
210
- readonly payload: {
211
- readonly threadId: string;
212
- };
213
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
214
- readonly type: "runtime.thread.cancelled";
215
- readonly payload: {
216
- readonly threadId: string;
217
- readonly reason?: string | undefined;
218
- readonly resumeSeq?: number | undefined;
219
- };
220
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
221
- readonly type: "runtime.thread.completed";
222
- readonly payload: {
223
- readonly threadId: string;
224
- readonly output: Schema.Json;
225
- };
226
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
227
- readonly type: "runtime.thread.failed";
228
- readonly payload: {
229
- readonly threadId: string;
230
- readonly error: string;
231
- };
232
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
233
- readonly type: "runtime.thread.started";
234
- readonly payload: {
235
- readonly threadId: string;
236
- readonly kind: string;
237
- readonly definitionName: string;
238
- readonly definitionVersion: string;
239
- readonly input: Schema.Json;
240
- readonly parentThreadId: string | null;
241
- };
242
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
243
- readonly type: "runtime.timer.fired";
244
- readonly payload: {
245
- readonly timerId: string;
246
- readonly waitId: string;
247
- };
248
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
249
- readonly type: "runtime.timer.set";
250
- readonly payload: {
251
- readonly timerId: string;
252
- readonly waitId: string;
253
- readonly wakeAt: number;
254
- };
255
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
256
- readonly type: "runtime.wait.registered";
257
- readonly payload: {
258
- readonly waitId: string;
259
- readonly threadId?: string | undefined;
260
- readonly on: {
261
- readonly type: string | readonly string[];
262
- readonly match?: Schema.Json | undefined;
263
- } | {
264
- readonly timerAt: number;
265
- };
266
- readonly tag?: Schema.Json | undefined;
267
- };
268
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
269
- readonly type: "runtime.wait.satisfied";
270
- readonly payload: {
271
- readonly waitId: string;
272
- readonly tag?: Schema.Json | undefined;
273
- readonly event: {
274
- readonly id: string;
275
- readonly type: string;
276
- readonly payload: Schema.Json;
277
- };
278
- };
279
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
280
34
  readonly type: "agent.context.compacted";
281
35
  readonly payload: {
282
36
  readonly turn: number;
@@ -559,19 +313,7 @@ export declare const callLlmEffect: NoInfer<import("@swirls/looms/core").LocalEf
559
313
  readonly input: number;
560
314
  readonly output: number;
561
315
  };
562
- })>>;
563
- export declare const executeToolEffect: NoInfer<import("@swirls/looms/core").LocalEffectDefinition<{
564
- readonly turn: number;
565
- readonly definitionName?: string | undefined;
566
- readonly definitionVersion: string;
567
- readonly toolCall: {
568
- readonly id: string;
569
- readonly name: string;
570
- readonly arguments: Schema.Json;
571
- };
572
- readonly input?: Schema.Json | undefined;
573
- readonly depth?: number | undefined;
574
- }, AgentDefinitionsTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
316
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
575
317
  readonly type: "runtime.child.close.requested";
576
318
  readonly payload: {
577
319
  readonly policy: "terminate" | "wait";
@@ -817,7 +559,19 @@ export declare const executeToolEffect: NoInfer<import("@swirls/looms/core").Loc
817
559
  readonly payload: Schema.Json;
818
560
  };
819
561
  };
820
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
562
+ })>>;
563
+ export declare const executeToolEffect: NoInfer<import("@swirls/looms/core").LocalEffectDefinition<{
564
+ readonly turn: number;
565
+ readonly definitionName?: string | undefined;
566
+ readonly definitionVersion: string;
567
+ readonly toolCall: {
568
+ readonly id: string;
569
+ readonly name: string;
570
+ readonly arguments: Schema.Json;
571
+ };
572
+ readonly input?: Schema.Json | undefined;
573
+ readonly depth?: number | undefined;
574
+ }, AgentDefinitionsTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
821
575
  readonly type: "agent.context.compacted";
822
576
  readonly payload: {
823
577
  readonly turn: number;
@@ -1100,5 +854,251 @@ export declare const executeToolEffect: NoInfer<import("@swirls/looms/core").Loc
1100
854
  readonly input: number;
1101
855
  readonly output: number;
1102
856
  };
857
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
858
+ readonly type: "runtime.child.close.requested";
859
+ readonly payload: {
860
+ readonly policy: "terminate" | "wait";
861
+ };
862
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
863
+ readonly type: "runtime.child.settled";
864
+ readonly payload: {
865
+ readonly runId: string;
866
+ readonly status: "cancelled" | "completed" | "failed";
867
+ readonly output: Schema.Json;
868
+ readonly error: string | null;
869
+ };
870
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
871
+ readonly type: "runtime.effect.ambiguous";
872
+ readonly payload: {
873
+ readonly effectId: string;
874
+ readonly attempt: number;
875
+ readonly error: string;
876
+ };
877
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
878
+ readonly type: "runtime.effect.attempt.started";
879
+ readonly payload: {
880
+ readonly effectId: string;
881
+ readonly attempt: number;
882
+ };
883
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
884
+ readonly type: "runtime.effect.cancel.requested";
885
+ readonly payload: {
886
+ readonly effectId: string;
887
+ readonly attempt: number;
888
+ readonly deadlineAt: number | null;
889
+ };
890
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
891
+ readonly type: "runtime.effect.cancelled";
892
+ readonly payload: {
893
+ readonly effectId: string;
894
+ readonly attempt: number;
895
+ };
896
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
897
+ readonly type: "runtime.effect.completed";
898
+ readonly payload: {
899
+ readonly effectId: string;
900
+ readonly attempt: number;
901
+ };
902
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
903
+ readonly type: "runtime.effect.dispatch.deferred";
904
+ readonly payload: {
905
+ readonly effectId: string;
906
+ readonly attempt: number;
907
+ readonly retryAt: number;
908
+ readonly error: string;
909
+ readonly try: number;
910
+ };
911
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
912
+ readonly type: "runtime.effect.dispatched";
913
+ readonly payload: {
914
+ readonly effectId: string;
915
+ readonly attempt: number;
916
+ readonly deadlineAt: number | null;
917
+ };
918
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
919
+ readonly type: "runtime.effect.failed";
920
+ readonly payload: {
921
+ readonly effectId: string;
922
+ readonly error: string;
923
+ readonly nonRetryable?: boolean | undefined;
924
+ readonly retryAfterMs?: number | undefined;
925
+ };
926
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
927
+ readonly type: "runtime.effect.heartbeat";
928
+ readonly payload: {
929
+ readonly effectId: string;
930
+ readonly attempt: number;
931
+ readonly heartbeatAt: number;
932
+ readonly deadlineAt: number | null;
933
+ readonly details?: Schema.Json | undefined;
934
+ };
935
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
936
+ readonly type: "runtime.effect.queued";
937
+ readonly payload: {
938
+ readonly effectId: string;
939
+ readonly attempt: number;
940
+ readonly deadlineAt: number | null;
941
+ };
942
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
943
+ readonly type: "runtime.effect.retry.scheduled";
944
+ readonly payload: {
945
+ readonly effectId: string;
946
+ readonly attempt: number;
947
+ readonly nextAttemptAt: number;
948
+ readonly error: string;
949
+ };
950
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
951
+ readonly type: "runtime.effect.timed_out";
952
+ readonly payload: {
953
+ readonly effectId: string;
954
+ readonly attempt: number;
955
+ readonly timeout: string;
956
+ };
957
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
958
+ readonly type: "runtime.effect.worker.started";
959
+ readonly payload: {
960
+ readonly effectId: string;
961
+ readonly attempt: number;
962
+ readonly deadlineAt: number | null;
963
+ };
964
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
965
+ readonly type: "runtime.fork.elided";
966
+ readonly payload: {
967
+ readonly type: string;
968
+ };
969
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
970
+ readonly type: "runtime.run.cancelled";
971
+ readonly payload: {
972
+ readonly reason?: string | undefined;
973
+ };
974
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
975
+ readonly type: "runtime.run.completed";
976
+ readonly payload: {
977
+ readonly output: Schema.Json;
978
+ readonly error: string | null;
979
+ };
980
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
981
+ readonly type: "runtime.run.forked";
982
+ readonly payload: {
983
+ readonly sourceRunId: string;
984
+ readonly sourceSeq: number;
985
+ };
986
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
987
+ readonly type: "runtime.run.launched";
988
+ readonly payload: {
989
+ readonly runId: string;
990
+ readonly kind: string;
991
+ readonly definitionName: string;
992
+ readonly definitionVersion: string;
993
+ readonly effectId: string;
994
+ readonly close: "terminate" | "wait";
995
+ };
996
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
997
+ readonly type: "runtime.run.started";
998
+ readonly payload: {
999
+ readonly rootThreadId?: string | undefined;
1000
+ readonly kind: string;
1001
+ readonly definitionName: string;
1002
+ readonly definitionVersion: string;
1003
+ readonly input: Schema.Json;
1004
+ readonly requestedThreadId?: string | null | undefined;
1005
+ readonly launchedBy?: {
1006
+ readonly runId: string;
1007
+ readonly threadId: string;
1008
+ readonly effectId: string;
1009
+ readonly causationId: string;
1010
+ readonly causationSeq: number;
1011
+ } | undefined;
1012
+ readonly attributes?: {
1013
+ readonly [x: string]: string;
1014
+ } | undefined;
1015
+ readonly trace?: {
1016
+ readonly traceparent: string;
1017
+ readonly tracestate?: string | undefined;
1018
+ } | undefined;
1019
+ };
1020
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1021
+ readonly type: "runtime.signal.received";
1022
+ readonly payload: {
1023
+ readonly signalType: string;
1024
+ };
1025
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1026
+ readonly type: "runtime.snapshot.taken";
1027
+ readonly payload: {
1028
+ readonly seq: number;
1029
+ readonly stateHash: string;
1030
+ readonly state?: Schema.Json | undefined;
1031
+ };
1032
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1033
+ readonly type: "runtime.thread.cancel.requested";
1034
+ readonly payload: {
1035
+ readonly threadId: string;
1036
+ };
1037
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1038
+ readonly type: "runtime.thread.cancelled";
1039
+ readonly payload: {
1040
+ readonly threadId: string;
1041
+ readonly reason?: string | undefined;
1042
+ readonly resumeSeq?: number | undefined;
1043
+ };
1044
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1045
+ readonly type: "runtime.thread.completed";
1046
+ readonly payload: {
1047
+ readonly threadId: string;
1048
+ readonly output: Schema.Json;
1049
+ };
1050
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1051
+ readonly type: "runtime.thread.failed";
1052
+ readonly payload: {
1053
+ readonly threadId: string;
1054
+ readonly error: string;
1055
+ };
1056
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1057
+ readonly type: "runtime.thread.started";
1058
+ readonly payload: {
1059
+ readonly threadId: string;
1060
+ readonly kind: string;
1061
+ readonly definitionName: string;
1062
+ readonly definitionVersion: string;
1063
+ readonly input: Schema.Json;
1064
+ readonly parentThreadId: string | null;
1065
+ };
1066
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1067
+ readonly type: "runtime.timer.fired";
1068
+ readonly payload: {
1069
+ readonly timerId: string;
1070
+ readonly waitId: string;
1071
+ };
1072
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1073
+ readonly type: "runtime.timer.set";
1074
+ readonly payload: {
1075
+ readonly timerId: string;
1076
+ readonly waitId: string;
1077
+ readonly wakeAt: number;
1078
+ };
1079
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1080
+ readonly type: "runtime.wait.registered";
1081
+ readonly payload: {
1082
+ readonly waitId: string;
1083
+ readonly threadId?: string | undefined;
1084
+ readonly on: {
1085
+ readonly type: string | readonly string[];
1086
+ readonly match?: Schema.Json | undefined;
1087
+ } | {
1088
+ readonly timerAt: number;
1089
+ };
1090
+ readonly tag?: Schema.Json | undefined;
1091
+ };
1092
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1093
+ readonly type: "runtime.wait.satisfied";
1094
+ readonly payload: {
1095
+ readonly waitId: string;
1096
+ readonly tag?: Schema.Json | undefined;
1097
+ readonly event: {
1098
+ readonly id: string;
1099
+ readonly type: string;
1100
+ readonly payload: Schema.Json;
1101
+ };
1102
+ };
1103
1103
  })>>;
1104
1104
  export declare function readToolCall(value: JsonValue): ToolCall | null;
@@ -85,6 +85,10 @@ export declare class DuplicateEffectDispatchError extends DuplicateEffectDispatc
85
85
  declare const MaxWakeIterationsError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
86
86
  readonly _tag: "MaxWakeIterationsError";
87
87
  } & Readonly<A>;
88
+ /**
89
+ * @deprecated The runtime no longer raises this. A wake that reaches `maxWakeIterations` parks
90
+ * and hands the rest of its work to a new wake.
91
+ */
88
92
  export declare class MaxWakeIterationsError extends MaxWakeIterationsError_base<{
89
93
  readonly runId: string;
90
94
  readonly maxIterations: number;
@@ -64,6 +64,10 @@ export class DuplicateEffectDispatchError extends Data.TaggedError('DuplicateEff
64
64
  this.name = 'DuplicateEffectDispatchError';
65
65
  }
66
66
  }
67
+ /**
68
+ * @deprecated The runtime no longer raises this. A wake that reaches `maxWakeIterations` parks
69
+ * and hands the rest of its work to a new wake.
70
+ */
67
71
  export class MaxWakeIterationsError extends Data.TaggedError('MaxWakeIterationsError') {
68
72
  constructor(runId, maxIterations) {
69
73
  super({
@@ -21,6 +21,12 @@ export interface CreateRuntimeOptions<TModules extends readonly AnyRuntimeModule
21
21
  * after a crash inside one long wake.
22
22
  */
23
23
  readonly snapshotEvery?: number;
24
+ /**
25
+ * How many times one wake may plan before it hands the run to a new wake. Default 100. A wake
26
+ * that reaches it starts nothing new, waits for the effects it already started, parks, and
27
+ * asks its scheduler to wake the run again at once. It bounds the work one wake does in a
28
+ * single host invocation; it does not stop a run.
29
+ */
24
30
  readonly maxWakeIterations?: number;
25
31
  /**
26
32
  * How far ahead a wake with in-process effects in flight keeps its `WakeScheduler.keepAlive`
@@ -3,7 +3,7 @@ import { createEvent, deferredUntil, EventStoreTag, foldRun, isPrimitiveEffect,
3
3
  import { childCloseCancellations, notifyLaunchingParent } from './child-run.js';
4
4
  import { nextRuntimeDeadline, planDeadlineTransitions, planTerminalCancellationTransitions, } from './deadline-transition-planner.js';
5
5
  import { admitOrFailAttempt } from './effect-admission.js';
6
- import { DuplicateEffectDispatchError, MaxWakeIterationsError, RuntimeExecutionError, } from './errors.js';
6
+ import { DuplicateEffectDispatchError, RuntimeExecutionError } from './errors.js';
7
7
  import { cascadedCancellations, createEffectFailedEvent, groupOutstanding, stripSeq, synthesizedThreadFailed, waitSatisfiedEvents, } from './helpers.js';
8
8
  import { executeLocalEffects } from './local-effect-executor.js';
9
9
  import { notifyObserver } from './observer.js';
@@ -175,6 +175,8 @@ export function createWakeEngine(options) {
175
175
  const inFlight = new Map();
176
176
  const settled = yield* Queue.unbounded();
177
177
  let guard = 0;
178
+ // Set once this pass has used its iterations: the rest of the work goes to a new wake.
179
+ let yieldToNextWake = false;
178
180
  // Deadlines at or before this instant were handled by the last loop iteration.
179
181
  let plannedAt = Number.NEGATIVE_INFINITY;
180
182
  const foldProduced = (produced) => Effect.gen(function* () {
@@ -211,10 +213,19 @@ export function createWakeEngine(options) {
211
213
  };
212
214
  const dispatchKeyFor = (item) => `${item.effectId}:${attemptFor(item)}`;
213
215
  while (!isRunTerminal(cursor.state)) {
214
- if (guard >= maxWakeIterations) {
215
- return yield* new MaxWakeIterationsError(runId, maxWakeIterations);
216
+ // A pass that has used its iterations starts nothing new. It waits for the effects
217
+ // it already started, then parks and hands the rest to a new wake (see below). A
218
+ // long-lived run (an agent that keeps calling tools while siblings wait) does far
219
+ // more than one pass's worth of work, and failing here would leave it with nothing
220
+ // driving it until some request happened to wake it again.
221
+ const draining = guard >= maxWakeIterations;
222
+ if (draining && inFlight.size === 0) {
223
+ yieldToNextWake = true;
224
+ break;
225
+ }
226
+ if (!draining) {
227
+ guard += 1;
216
228
  }
217
- guard += 1;
218
229
  // A signal (or coalesced join) may have appended events while local effects ran.
219
230
  if (executionContext.wakeAgain) {
220
231
  executionContext.wakeAgain = false;
@@ -224,7 +235,7 @@ export function createWakeEngine(options) {
224
235
  const now = yield* Clock.currentTimeMillis;
225
236
  plannedAt = now;
226
237
  const deadlinePlan = planDeadlineTransitions({ runId, state, registry, now });
227
- if (deadlinePlan.events.length > 0) {
238
+ if (!draining && deadlinePlan.events.length > 0) {
228
239
  for (const notice of deadlinePlan.timerNotices) {
229
240
  observe({
230
241
  type: 'timer.late',
@@ -265,7 +276,7 @@ export function createWakeEngine(options) {
265
276
  now,
266
277
  maxInFlightWorkerEffects: options.maxInFlightWorkerEffects,
267
278
  });
268
- if (workerPlans.length > 0) {
279
+ if (!draining && workerPlans.length > 0) {
269
280
  for (const workerPlan of workerPlans) {
270
281
  const admission = yield* admitOrFailAttempt({
271
282
  registry,
@@ -351,12 +362,12 @@ export function createWakeEngine(options) {
351
362
  ]
352
363
  : [];
353
364
  });
354
- if (exhausted.length > 0) {
365
+ if (!draining && exhausted.length > 0) {
355
366
  yield* foldProduced(exhausted);
356
367
  continue;
357
368
  }
358
369
  const due = outstanding.filter((item) => !dispatchedEffectIds.has(dispatchKeyFor(item)));
359
- if (due.length > 0) {
370
+ if (!draining && due.length > 0) {
360
371
  const attempts = new Map(due.map((item) => [item.effectId, attemptFor(item)]));
361
372
  for (const item of due) {
362
373
  const key = `${item.effectId}:${attempts.get(item.effectId) ?? 1}`;
@@ -501,7 +512,11 @@ export function createWakeEngine(options) {
501
512
  }
502
513
  // Snapshot on park: the next wake (on any instance) starts from here.
503
514
  cursor = yield* persistSnapshot(store, runId, cursor);
504
- const nextDeadline = nextRuntimeDeadline(cursor.state, plannedAt);
515
+ const runtimeDeadline = nextRuntimeDeadline(cursor.state, plannedAt);
516
+ // Work this pass left for the next wake is due now.
517
+ const nextDeadline = yieldToNextWake
518
+ ? Math.min(runtimeDeadline ?? Number.POSITIVE_INFINITY, yield* Clock.currentTimeMillis)
519
+ : runtimeDeadline;
505
520
  if (nextDeadline !== undefined) {
506
521
  yield* options.scheduler().schedule(runId, nextDeadline);
507
522
  }
@@ -342,15 +342,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
342
342
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
343
343
  readonly type: "schedule.paused";
344
344
  readonly payload: {};
345
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
346
- readonly type: "schedule.resumed";
347
- readonly payload: {};
348
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
349
- readonly type: "schedule.retired";
350
- readonly payload: {};
351
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
352
- readonly type: "schedule.triggered";
353
- readonly payload: {};
354
345
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
355
346
  readonly type: "schedule.planned";
356
347
  readonly payload: {
@@ -374,6 +365,12 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
374
365
  readonly payload: {
375
366
  readonly reason: string;
376
367
  };
368
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
369
+ readonly type: "schedule.resumed";
370
+ readonly payload: {};
371
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
372
+ readonly type: "schedule.retired";
373
+ readonly payload: {};
377
374
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
378
375
  readonly type: "schedule.skipped";
379
376
  readonly payload: {
@@ -384,6 +381,9 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
384
381
  readonly manual: boolean;
385
382
  readonly triggerId?: string | undefined;
386
383
  };
384
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
385
+ readonly type: "schedule.triggered";
386
+ readonly payload: {};
387
387
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
388
388
  readonly type: "schedule.updated";
389
389
  readonly payload: {
@@ -693,15 +693,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
693
693
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
694
694
  readonly type: "schedule.paused";
695
695
  readonly payload: {};
696
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
697
- readonly type: "schedule.resumed";
698
- readonly payload: {};
699
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
700
- readonly type: "schedule.retired";
701
- readonly payload: {};
702
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
703
- readonly type: "schedule.triggered";
704
- readonly payload: {};
705
696
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
706
697
  readonly type: "schedule.planned";
707
698
  readonly payload: {
@@ -725,6 +716,12 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
725
716
  readonly payload: {
726
717
  readonly reason: string;
727
718
  };
719
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
720
+ readonly type: "schedule.resumed";
721
+ readonly payload: {};
722
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
723
+ readonly type: "schedule.retired";
724
+ readonly payload: {};
728
725
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
729
726
  readonly type: "schedule.skipped";
730
727
  readonly payload: {
@@ -735,6 +732,9 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
735
732
  readonly manual: boolean;
736
733
  readonly triggerId?: string | undefined;
737
734
  };
735
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
736
+ readonly type: "schedule.triggered";
737
+ readonly payload: {};
738
738
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
739
739
  readonly type: "schedule.updated";
740
740
  readonly payload: {
@@ -1120,15 +1120,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
1120
1120
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1121
1121
  readonly type: "schedule.paused";
1122
1122
  readonly payload: {};
1123
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1124
- readonly type: "schedule.resumed";
1125
- readonly payload: {};
1126
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1127
- readonly type: "schedule.retired";
1128
- readonly payload: {};
1129
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1130
- readonly type: "schedule.triggered";
1131
- readonly payload: {};
1132
1123
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1133
1124
  readonly type: "schedule.planned";
1134
1125
  readonly payload: {
@@ -1152,6 +1143,12 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
1152
1143
  readonly payload: {
1153
1144
  readonly reason: string;
1154
1145
  };
1146
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1147
+ readonly type: "schedule.resumed";
1148
+ readonly payload: {};
1149
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1150
+ readonly type: "schedule.retired";
1151
+ readonly payload: {};
1155
1152
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1156
1153
  readonly type: "schedule.skipped";
1157
1154
  readonly payload: {
@@ -1162,6 +1159,9 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
1162
1159
  readonly manual: boolean;
1163
1160
  readonly triggerId?: string | undefined;
1164
1161
  };
1162
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1163
+ readonly type: "schedule.triggered";
1164
+ readonly payload: {};
1165
1165
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1166
1166
  readonly type: "schedule.updated";
1167
1167
  readonly payload: {
@@ -1471,15 +1471,6 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
1471
1471
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1472
1472
  readonly type: "schedule.paused";
1473
1473
  readonly payload: {};
1474
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1475
- readonly type: "schedule.resumed";
1476
- readonly payload: {};
1477
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1478
- readonly type: "schedule.retired";
1479
- readonly payload: {};
1480
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1481
- readonly type: "schedule.triggered";
1482
- readonly payload: {};
1483
1474
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1484
1475
  readonly type: "schedule.planned";
1485
1476
  readonly payload: {
@@ -1503,6 +1494,12 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
1503
1494
  readonly payload: {
1504
1495
  readonly reason: string;
1505
1496
  };
1497
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1498
+ readonly type: "schedule.resumed";
1499
+ readonly payload: {};
1500
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1501
+ readonly type: "schedule.retired";
1502
+ readonly payload: {};
1506
1503
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1507
1504
  readonly type: "schedule.skipped";
1508
1505
  readonly payload: {
@@ -1513,6 +1510,9 @@ export declare function schedule(options?: ScheduleModuleOptions): import("@swir
1513
1510
  readonly manual: boolean;
1514
1511
  readonly triggerId?: string | undefined;
1515
1512
  };
1513
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1514
+ readonly type: "schedule.triggered";
1515
+ readonly payload: {};
1516
1516
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1517
1517
  readonly type: "schedule.updated";
1518
1518
  readonly payload: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swirls/looms",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "description": "Pluggable event-sourced runtime for durable agents and workflows",
5
5
  "homepage": "https://github.com/ByteSliceHQ/looms#readme",
6
6
  "bugs": {