@swirls/looms 0.10.0 → 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.
Files changed (45) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/actor/cell.d.ts +3 -1
  3. package/dist/actor/cell.js +1 -0
  4. package/dist/actor/host.d.ts +3 -1
  5. package/dist/actor/host.js +1 -0
  6. package/dist/agent/module.d.ts +512 -512
  7. package/dist/cli/commands.d.ts +1 -1
  8. package/dist/cli/commands.js +47 -12
  9. package/dist/client/client.d.ts +20 -21
  10. package/dist/client/client.js +2 -1
  11. package/dist/cloudflare/delete-terminal-run-storage.d.ts +39 -0
  12. package/dist/cloudflare/delete-terminal-run-storage.js +98 -0
  13. package/dist/cloudflare/durable-object.d.ts +11 -1
  14. package/dist/cloudflare/durable-object.js +23 -0
  15. package/dist/cloudflare/index.d.ts +1 -0
  16. package/dist/cloudflare/index.js +1 -0
  17. package/dist/core/run-context.d.ts +50 -0
  18. package/dist/core/run-context.js +21 -1
  19. package/dist/debugger/app/assets/{index-D-2Q7ecG.js → index-VTotlHcm.js} +2 -2
  20. package/dist/debugger/app/assets/{routes-lvmllT60.js → routes-CEdsN9DO.js} +2 -2
  21. package/dist/debugger/app/index.html +1 -1
  22. package/dist/projectors/event-log-ops.d.ts +0 -6
  23. package/dist/projectors/event-log-ops.js +2 -12
  24. package/dist/projectors/event-log.d.ts +10 -5
  25. package/dist/projectors/event-log.js +26 -22
  26. package/dist/projectors/replica/columns.d.ts +41 -0
  27. package/dist/projectors/replica/columns.js +77 -0
  28. package/dist/projectors/replica/drizzle.d.ts +328 -57
  29. package/dist/projectors/replica/drizzle.js +18 -14
  30. package/dist/projectors/replica/migrations.d.ts +25 -5
  31. package/dist/projectors/replica/migrations.js +62 -14
  32. package/dist/projectors/replica/postgres.d.ts +12 -11
  33. package/dist/projectors/replica/postgres.js +12 -26
  34. package/dist/projectors/replica/sqlite-bun.d.ts +3 -1
  35. package/dist/projectors/replica/sqlite-bun.js +6 -2
  36. package/dist/projectors/replica/sqlite-migrations.d.ts +5 -5
  37. package/dist/projectors/replica/sqlite-migrations.js +22 -9
  38. package/dist/projectors/replica/sqlite.d.ts +12 -11
  39. package/dist/projectors/replica/sqlite.js +23 -16
  40. package/dist/runtime/looms.d.ts +27 -36
  41. package/dist/runtime/looms.js +1 -0
  42. package/dist/runtime/runtime.js +7 -1
  43. package/dist/runtime/server/http.js +4 -2
  44. package/dist/runtime/types.d.ts +6 -1
  45. package/package.json +1 -1
@@ -235,6 +235,248 @@ export declare function agent(options?: AgentModuleOptions): import("@swirls/loo
235
235
  readonly alreadyCompacted?: boolean | undefined;
236
236
  readonly consumedSteerMessageIds?: readonly string[] | undefined;
237
237
  }, import("./definitions-store").AgentDefinitionsTag | LlmTag, (Omit<EventInput, "payload" | "type"> & {
238
+ readonly type: "agent.context.compacted";
239
+ readonly payload: {
240
+ readonly turn: number;
241
+ readonly originalCount: number;
242
+ readonly compactedCount: number;
243
+ readonly summary?: string | undefined;
244
+ readonly reason?: "manual" | "overflow" | "threshold" | undefined;
245
+ readonly messages?: readonly {
246
+ readonly role: "assistant" | "system" | "tool" | "user";
247
+ readonly content: string;
248
+ readonly toolCallId?: string | undefined;
249
+ readonly name?: string | undefined;
250
+ readonly toolCalls?: {
251
+ readonly id: string;
252
+ readonly name: string;
253
+ readonly arguments: import("effect/Schema").Json;
254
+ }[] | undefined;
255
+ }[] | undefined;
256
+ };
257
+ }) | (Omit<EventInput, "payload" | "type"> & {
258
+ readonly type: "agent.effects.requested";
259
+ readonly payload: {
260
+ readonly toolCallId: string;
261
+ readonly effects: readonly ({
262
+ readonly type: "runtime.spawn";
263
+ readonly childThreadId: string;
264
+ readonly kind: string;
265
+ readonly definitionName: string;
266
+ readonly definitionVersion: string;
267
+ readonly input: import("effect/Schema").Json;
268
+ } | {
269
+ readonly type: "runtime.wait";
270
+ readonly waitId: string;
271
+ readonly on: {
272
+ readonly type: string | readonly string[];
273
+ readonly match?: import("effect/Schema").Json | undefined;
274
+ } | {
275
+ readonly timerAt: number;
276
+ };
277
+ readonly tag?: import("effect/Schema").Json | undefined;
278
+ } | {
279
+ readonly type: "runtime.emit";
280
+ readonly event: {
281
+ readonly type: string;
282
+ readonly payload: import("effect/Schema").Json;
283
+ readonly threadId?: string | null | undefined;
284
+ readonly parentThreadId?: string | null | undefined;
285
+ readonly causationId?: string | null | undefined;
286
+ readonly correlationId?: string | null | undefined;
287
+ readonly effectId?: string | null | undefined;
288
+ readonly origin?: {
289
+ readonly type: "thread";
290
+ readonly threadId: string;
291
+ } | {
292
+ readonly type: "external";
293
+ readonly actorId?: string | undefined;
294
+ } | {
295
+ readonly type: "system";
296
+ } | {
297
+ readonly type: "run";
298
+ readonly runId: string;
299
+ } | undefined;
300
+ readonly ephemeral?: boolean | undefined;
301
+ readonly id?: string | undefined;
302
+ readonly ts?: number | undefined;
303
+ readonly idempotencyKey?: string | null | undefined;
304
+ };
305
+ readonly tag?: string | undefined;
306
+ } | {
307
+ readonly type: "runtime.complete";
308
+ readonly output: import("effect/Schema").Json;
309
+ } | {
310
+ readonly type: "runtime.fail";
311
+ readonly error: string;
312
+ } | {
313
+ readonly type: "runtime.cancel";
314
+ readonly threadId: string;
315
+ readonly tag?: string | undefined;
316
+ } | {
317
+ readonly type: "runtime.launch";
318
+ readonly runId: string;
319
+ readonly kind: string;
320
+ readonly definitionName: string;
321
+ readonly definitionVersion: string;
322
+ readonly input: import("effect/Schema").Json;
323
+ readonly close: "terminate" | "wait";
324
+ readonly tag?: string | undefined;
325
+ } | {
326
+ readonly type: "runtime.cancelRun";
327
+ readonly runId: string;
328
+ readonly tag?: string | undefined;
329
+ } | {
330
+ readonly type: string;
331
+ readonly input: import("effect/Schema").Json;
332
+ readonly tag?: string | undefined;
333
+ readonly at?: number | undefined;
334
+ })[];
335
+ readonly waitOn?: {
336
+ readonly type: string | readonly string[];
337
+ readonly match?: import("effect/Schema").Json | undefined;
338
+ } | undefined;
339
+ };
340
+ }) | (Omit<EventInput, "payload" | "type"> & {
341
+ readonly type: "agent.lineage";
342
+ readonly payload: {
343
+ readonly depth: number;
344
+ };
345
+ }) | (Omit<EventInput, "payload" | "type"> & {
346
+ readonly type: "agent.message";
347
+ readonly payload: {
348
+ readonly turn: number;
349
+ readonly message: {
350
+ readonly role: "assistant" | "system" | "tool" | "user";
351
+ readonly content: string;
352
+ readonly toolCallId?: string | undefined;
353
+ readonly name?: string | undefined;
354
+ readonly toolCalls?: {
355
+ readonly id: string;
356
+ readonly name: string;
357
+ readonly arguments: import("effect/Schema").Json;
358
+ }[] | undefined;
359
+ };
360
+ readonly usage?: {
361
+ readonly input: number;
362
+ readonly output: number;
363
+ } | undefined;
364
+ };
365
+ }) | (Omit<EventInput, "payload" | "type"> & {
366
+ readonly type: "agent.message.received";
367
+ readonly payload: {
368
+ readonly message: {
369
+ readonly role: "assistant" | "system" | "tool" | "user";
370
+ readonly content: string;
371
+ readonly toolCallId?: string | undefined;
372
+ readonly name?: string | undefined;
373
+ readonly toolCalls?: {
374
+ readonly id: string;
375
+ readonly name: string;
376
+ readonly arguments: import("effect/Schema").Json;
377
+ }[] | undefined;
378
+ };
379
+ };
380
+ }) | (Omit<EventInput, "payload" | "type"> & {
381
+ readonly type: "agent.session.cancel.requested";
382
+ readonly payload: {};
383
+ }) | (Omit<EventInput, "payload" | "type"> & {
384
+ readonly type: "agent.session.message.submitted";
385
+ readonly payload: {
386
+ readonly messageId: string;
387
+ readonly text: string;
388
+ readonly delivery?: "followUp" | "nextTurn" | "steer" | undefined;
389
+ readonly activeChildThreadId?: string | undefined;
390
+ };
391
+ }) | (Omit<EventInput, "payload" | "type"> & {
392
+ readonly type: "agent.session.steer.delivered";
393
+ readonly payload: {
394
+ readonly messageId: string;
395
+ readonly activeMessageId: string;
396
+ };
397
+ }) | (Omit<EventInput, "payload" | "type"> & {
398
+ readonly type: "agent.session.turn.closed";
399
+ readonly payload: {
400
+ readonly messageId: string;
401
+ readonly status: "cancelled" | "completed" | "failed";
402
+ readonly error?: string | undefined;
403
+ };
404
+ }) | (Omit<EventInput, "payload" | "type"> & {
405
+ readonly type: "agent.session.turn.started";
406
+ readonly payload: {
407
+ readonly messageId: string;
408
+ readonly childThreadId: string;
409
+ };
410
+ }) | (Omit<EventInput, "payload" | "type"> & {
411
+ readonly type: "agent.spawn.requested";
412
+ readonly payload: {
413
+ readonly childThreadId: string;
414
+ readonly kind: string;
415
+ readonly definitionName: string;
416
+ readonly definitionVersion: string;
417
+ readonly toolCallId: string;
418
+ readonly input: import("effect/Schema").Json;
419
+ readonly depth?: number | undefined;
420
+ };
421
+ }) | (Omit<EventInput, "payload" | "type"> & {
422
+ readonly type: "agent.steered";
423
+ readonly payload: {
424
+ readonly turn: number;
425
+ readonly messageId?: string | undefined;
426
+ readonly message: {
427
+ readonly role: "assistant" | "system" | "tool" | "user";
428
+ readonly content: string;
429
+ readonly toolCallId?: string | undefined;
430
+ readonly name?: string | undefined;
431
+ readonly toolCalls?: {
432
+ readonly id: string;
433
+ readonly name: string;
434
+ readonly arguments: import("effect/Schema").Json;
435
+ }[] | undefined;
436
+ };
437
+ readonly interrupt?: boolean | undefined;
438
+ };
439
+ }) | (Omit<EventInput, "payload" | "type"> & {
440
+ readonly type: "agent.tool.result";
441
+ readonly payload: {
442
+ readonly turn: number;
443
+ readonly toolCallId: string;
444
+ readonly name: string;
445
+ readonly result: import("effect/Schema").Json;
446
+ readonly error: string | null;
447
+ };
448
+ }) | (Omit<EventInput, "payload" | "type"> & {
449
+ readonly type: "agent.tool_call.requested";
450
+ readonly payload: {
451
+ readonly turn: number;
452
+ readonly toolCall: {
453
+ readonly id: string;
454
+ readonly name: string;
455
+ readonly arguments: import("effect/Schema").Json;
456
+ };
457
+ };
458
+ }) | (Omit<EventInput, "payload" | "type"> & {
459
+ readonly type: "agent.turn.started";
460
+ readonly payload: {
461
+ readonly turn: number;
462
+ };
463
+ }) | (Omit<EventInput, "payload" | "type"> & {
464
+ readonly type: "agent.turn.stopped";
465
+ readonly payload: {};
466
+ }) | (Omit<EventInput, "payload" | "type"> & {
467
+ readonly type: "agent.turn.text_delta";
468
+ readonly payload: {
469
+ readonly turn: number;
470
+ readonly delta: string;
471
+ };
472
+ }) | (Omit<EventInput, "payload" | "type"> & {
473
+ readonly type: "agent.turn.usage";
474
+ readonly payload: {
475
+ readonly turn: number;
476
+ readonly input: number;
477
+ readonly output: number;
478
+ };
479
+ }) | (Omit<EventInput, "payload" | "type"> & {
238
480
  readonly type: "runtime.child.close.requested";
239
481
  readonly payload: {
240
482
  readonly policy: "terminate" | "wait";
@@ -480,7 +722,19 @@ export declare function agent(options?: AgentModuleOptions): import("@swirls/loo
480
722
  readonly payload: import("effect/Schema").Json;
481
723
  };
482
724
  };
483
- }) | (Omit<EventInput, "payload" | "type"> & {
725
+ })>;
726
+ executeTool: import("@swirls/looms/core").LocalEffectDefinition<{
727
+ readonly turn: number;
728
+ readonly definitionName?: string | undefined;
729
+ readonly definitionVersion: string;
730
+ readonly toolCall: {
731
+ readonly id: string;
732
+ readonly name: string;
733
+ readonly arguments: import("effect/Schema").Json;
734
+ };
735
+ readonly input?: import("effect/Schema").Json | undefined;
736
+ readonly depth?: number | undefined;
737
+ }, import("./definitions-store").AgentDefinitionsTag, (Omit<EventInput, "payload" | "type"> & {
484
738
  readonly type: "agent.context.compacted";
485
739
  readonly payload: {
486
740
  readonly turn: number;
@@ -722,19 +976,7 @@ export declare function agent(options?: AgentModuleOptions): import("@swirls/loo
722
976
  readonly input: number;
723
977
  readonly output: number;
724
978
  };
725
- })>;
726
- executeTool: import("@swirls/looms/core").LocalEffectDefinition<{
727
- readonly turn: number;
728
- readonly definitionName?: string | undefined;
729
- readonly definitionVersion: string;
730
- readonly toolCall: {
731
- readonly id: string;
732
- readonly name: string;
733
- readonly arguments: import("effect/Schema").Json;
734
- };
735
- readonly input?: import("effect/Schema").Json | undefined;
736
- readonly depth?: number | undefined;
737
- }, import("./definitions-store").AgentDefinitionsTag, (Omit<EventInput, "payload" | "type"> & {
979
+ }) | (Omit<EventInput, "payload" | "type"> & {
738
980
  readonly type: "runtime.child.close.requested";
739
981
  readonly payload: {
740
982
  readonly policy: "terminate" | "wait";
@@ -980,248 +1222,6 @@ export declare function agent(options?: AgentModuleOptions): import("@swirls/loo
980
1222
  readonly payload: import("effect/Schema").Json;
981
1223
  };
982
1224
  };
983
- }) | (Omit<EventInput, "payload" | "type"> & {
984
- readonly type: "agent.context.compacted";
985
- readonly payload: {
986
- readonly turn: number;
987
- readonly originalCount: number;
988
- readonly compactedCount: number;
989
- readonly summary?: string | undefined;
990
- readonly reason?: "manual" | "overflow" | "threshold" | undefined;
991
- readonly messages?: readonly {
992
- readonly role: "assistant" | "system" | "tool" | "user";
993
- readonly content: string;
994
- readonly toolCallId?: string | undefined;
995
- readonly name?: string | undefined;
996
- readonly toolCalls?: {
997
- readonly id: string;
998
- readonly name: string;
999
- readonly arguments: import("effect/Schema").Json;
1000
- }[] | undefined;
1001
- }[] | undefined;
1002
- };
1003
- }) | (Omit<EventInput, "payload" | "type"> & {
1004
- readonly type: "agent.effects.requested";
1005
- readonly payload: {
1006
- readonly toolCallId: string;
1007
- readonly effects: readonly ({
1008
- readonly type: "runtime.spawn";
1009
- readonly childThreadId: string;
1010
- readonly kind: string;
1011
- readonly definitionName: string;
1012
- readonly definitionVersion: string;
1013
- readonly input: import("effect/Schema").Json;
1014
- } | {
1015
- readonly type: "runtime.wait";
1016
- readonly waitId: string;
1017
- readonly on: {
1018
- readonly type: string | readonly string[];
1019
- readonly match?: import("effect/Schema").Json | undefined;
1020
- } | {
1021
- readonly timerAt: number;
1022
- };
1023
- readonly tag?: import("effect/Schema").Json | undefined;
1024
- } | {
1025
- readonly type: "runtime.emit";
1026
- readonly event: {
1027
- readonly type: string;
1028
- readonly payload: import("effect/Schema").Json;
1029
- readonly threadId?: string | null | undefined;
1030
- readonly parentThreadId?: string | null | undefined;
1031
- readonly causationId?: string | null | undefined;
1032
- readonly correlationId?: string | null | undefined;
1033
- readonly effectId?: string | null | undefined;
1034
- readonly origin?: {
1035
- readonly type: "thread";
1036
- readonly threadId: string;
1037
- } | {
1038
- readonly type: "external";
1039
- readonly actorId?: string | undefined;
1040
- } | {
1041
- readonly type: "system";
1042
- } | {
1043
- readonly type: "run";
1044
- readonly runId: string;
1045
- } | undefined;
1046
- readonly ephemeral?: boolean | undefined;
1047
- readonly id?: string | undefined;
1048
- readonly ts?: number | undefined;
1049
- readonly idempotencyKey?: string | null | undefined;
1050
- };
1051
- readonly tag?: string | undefined;
1052
- } | {
1053
- readonly type: "runtime.complete";
1054
- readonly output: import("effect/Schema").Json;
1055
- } | {
1056
- readonly type: "runtime.fail";
1057
- readonly error: string;
1058
- } | {
1059
- readonly type: "runtime.cancel";
1060
- readonly threadId: string;
1061
- readonly tag?: string | undefined;
1062
- } | {
1063
- readonly type: "runtime.launch";
1064
- readonly runId: string;
1065
- readonly kind: string;
1066
- readonly definitionName: string;
1067
- readonly definitionVersion: string;
1068
- readonly input: import("effect/Schema").Json;
1069
- readonly close: "terminate" | "wait";
1070
- readonly tag?: string | undefined;
1071
- } | {
1072
- readonly type: "runtime.cancelRun";
1073
- readonly runId: string;
1074
- readonly tag?: string | undefined;
1075
- } | {
1076
- readonly type: string;
1077
- readonly input: import("effect/Schema").Json;
1078
- readonly tag?: string | undefined;
1079
- readonly at?: number | undefined;
1080
- })[];
1081
- readonly waitOn?: {
1082
- readonly type: string | readonly string[];
1083
- readonly match?: import("effect/Schema").Json | undefined;
1084
- } | undefined;
1085
- };
1086
- }) | (Omit<EventInput, "payload" | "type"> & {
1087
- readonly type: "agent.lineage";
1088
- readonly payload: {
1089
- readonly depth: number;
1090
- };
1091
- }) | (Omit<EventInput, "payload" | "type"> & {
1092
- readonly type: "agent.message";
1093
- readonly payload: {
1094
- readonly turn: number;
1095
- readonly message: {
1096
- readonly role: "assistant" | "system" | "tool" | "user";
1097
- readonly content: string;
1098
- readonly toolCallId?: string | undefined;
1099
- readonly name?: string | undefined;
1100
- readonly toolCalls?: {
1101
- readonly id: string;
1102
- readonly name: string;
1103
- readonly arguments: import("effect/Schema").Json;
1104
- }[] | undefined;
1105
- };
1106
- readonly usage?: {
1107
- readonly input: number;
1108
- readonly output: number;
1109
- } | undefined;
1110
- };
1111
- }) | (Omit<EventInput, "payload" | "type"> & {
1112
- readonly type: "agent.message.received";
1113
- readonly payload: {
1114
- readonly message: {
1115
- readonly role: "assistant" | "system" | "tool" | "user";
1116
- readonly content: string;
1117
- readonly toolCallId?: string | undefined;
1118
- readonly name?: string | undefined;
1119
- readonly toolCalls?: {
1120
- readonly id: string;
1121
- readonly name: string;
1122
- readonly arguments: import("effect/Schema").Json;
1123
- }[] | undefined;
1124
- };
1125
- };
1126
- }) | (Omit<EventInput, "payload" | "type"> & {
1127
- readonly type: "agent.session.cancel.requested";
1128
- readonly payload: {};
1129
- }) | (Omit<EventInput, "payload" | "type"> & {
1130
- readonly type: "agent.session.message.submitted";
1131
- readonly payload: {
1132
- readonly messageId: string;
1133
- readonly text: string;
1134
- readonly delivery?: "followUp" | "nextTurn" | "steer" | undefined;
1135
- readonly activeChildThreadId?: string | undefined;
1136
- };
1137
- }) | (Omit<EventInput, "payload" | "type"> & {
1138
- readonly type: "agent.session.steer.delivered";
1139
- readonly payload: {
1140
- readonly messageId: string;
1141
- readonly activeMessageId: string;
1142
- };
1143
- }) | (Omit<EventInput, "payload" | "type"> & {
1144
- readonly type: "agent.session.turn.closed";
1145
- readonly payload: {
1146
- readonly messageId: string;
1147
- readonly status: "cancelled" | "completed" | "failed";
1148
- readonly error?: string | undefined;
1149
- };
1150
- }) | (Omit<EventInput, "payload" | "type"> & {
1151
- readonly type: "agent.session.turn.started";
1152
- readonly payload: {
1153
- readonly messageId: string;
1154
- readonly childThreadId: string;
1155
- };
1156
- }) | (Omit<EventInput, "payload" | "type"> & {
1157
- readonly type: "agent.spawn.requested";
1158
- readonly payload: {
1159
- readonly childThreadId: string;
1160
- readonly kind: string;
1161
- readonly definitionName: string;
1162
- readonly definitionVersion: string;
1163
- readonly toolCallId: string;
1164
- readonly input: import("effect/Schema").Json;
1165
- readonly depth?: number | undefined;
1166
- };
1167
- }) | (Omit<EventInput, "payload" | "type"> & {
1168
- readonly type: "agent.steered";
1169
- readonly payload: {
1170
- readonly turn: number;
1171
- readonly messageId?: string | undefined;
1172
- readonly message: {
1173
- readonly role: "assistant" | "system" | "tool" | "user";
1174
- readonly content: string;
1175
- readonly toolCallId?: string | undefined;
1176
- readonly name?: string | undefined;
1177
- readonly toolCalls?: {
1178
- readonly id: string;
1179
- readonly name: string;
1180
- readonly arguments: import("effect/Schema").Json;
1181
- }[] | undefined;
1182
- };
1183
- readonly interrupt?: boolean | undefined;
1184
- };
1185
- }) | (Omit<EventInput, "payload" | "type"> & {
1186
- readonly type: "agent.tool.result";
1187
- readonly payload: {
1188
- readonly turn: number;
1189
- readonly toolCallId: string;
1190
- readonly name: string;
1191
- readonly result: import("effect/Schema").Json;
1192
- readonly error: string | null;
1193
- };
1194
- }) | (Omit<EventInput, "payload" | "type"> & {
1195
- readonly type: "agent.tool_call.requested";
1196
- readonly payload: {
1197
- readonly turn: number;
1198
- readonly toolCall: {
1199
- readonly id: string;
1200
- readonly name: string;
1201
- readonly arguments: import("effect/Schema").Json;
1202
- };
1203
- };
1204
- }) | (Omit<EventInput, "payload" | "type"> & {
1205
- readonly type: "agent.turn.started";
1206
- readonly payload: {
1207
- readonly turn: number;
1208
- };
1209
- }) | (Omit<EventInput, "payload" | "type"> & {
1210
- readonly type: "agent.turn.stopped";
1211
- readonly payload: {};
1212
- }) | (Omit<EventInput, "payload" | "type"> & {
1213
- readonly type: "agent.turn.text_delta";
1214
- readonly payload: {
1215
- readonly turn: number;
1216
- readonly delta: string;
1217
- };
1218
- }) | (Omit<EventInput, "payload" | "type"> & {
1219
- readonly type: "agent.turn.usage";
1220
- readonly payload: {
1221
- readonly turn: number;
1222
- readonly input: number;
1223
- readonly output: number;
1224
- };
1225
1225
  })>;
1226
1226
  }, {
1227
1227
  agent: import("@swirls/looms/core").ThreadDefinition<import("./types").AgentState>;
@@ -1372,6 +1372,248 @@ export declare function agent(options?: AgentModuleOptions): import("@swirls/loo
1372
1372
  readonly alreadyCompacted?: boolean | undefined;
1373
1373
  readonly consumedSteerMessageIds?: readonly string[] | undefined;
1374
1374
  }, import("./definitions-store").AgentDefinitionsTag | LlmTag, (Omit<EventInput, "payload" | "type"> & {
1375
+ readonly type: "agent.context.compacted";
1376
+ readonly payload: {
1377
+ readonly turn: number;
1378
+ readonly originalCount: number;
1379
+ readonly compactedCount: number;
1380
+ readonly summary?: string | undefined;
1381
+ readonly reason?: "manual" | "overflow" | "threshold" | undefined;
1382
+ readonly messages?: readonly {
1383
+ readonly role: "assistant" | "system" | "tool" | "user";
1384
+ readonly content: string;
1385
+ readonly toolCallId?: string | undefined;
1386
+ readonly name?: string | undefined;
1387
+ readonly toolCalls?: {
1388
+ readonly id: string;
1389
+ readonly name: string;
1390
+ readonly arguments: import("effect/Schema").Json;
1391
+ }[] | undefined;
1392
+ }[] | undefined;
1393
+ };
1394
+ }) | (Omit<EventInput, "payload" | "type"> & {
1395
+ readonly type: "agent.effects.requested";
1396
+ readonly payload: {
1397
+ readonly toolCallId: string;
1398
+ readonly effects: readonly ({
1399
+ readonly type: "runtime.spawn";
1400
+ readonly childThreadId: string;
1401
+ readonly kind: string;
1402
+ readonly definitionName: string;
1403
+ readonly definitionVersion: string;
1404
+ readonly input: import("effect/Schema").Json;
1405
+ } | {
1406
+ readonly type: "runtime.wait";
1407
+ readonly waitId: string;
1408
+ readonly on: {
1409
+ readonly type: string | readonly string[];
1410
+ readonly match?: import("effect/Schema").Json | undefined;
1411
+ } | {
1412
+ readonly timerAt: number;
1413
+ };
1414
+ readonly tag?: import("effect/Schema").Json | undefined;
1415
+ } | {
1416
+ readonly type: "runtime.emit";
1417
+ readonly event: {
1418
+ readonly type: string;
1419
+ readonly payload: import("effect/Schema").Json;
1420
+ readonly threadId?: string | null | undefined;
1421
+ readonly parentThreadId?: string | null | undefined;
1422
+ readonly causationId?: string | null | undefined;
1423
+ readonly correlationId?: string | null | undefined;
1424
+ readonly effectId?: string | null | undefined;
1425
+ readonly origin?: {
1426
+ readonly type: "thread";
1427
+ readonly threadId: string;
1428
+ } | {
1429
+ readonly type: "external";
1430
+ readonly actorId?: string | undefined;
1431
+ } | {
1432
+ readonly type: "system";
1433
+ } | {
1434
+ readonly type: "run";
1435
+ readonly runId: string;
1436
+ } | undefined;
1437
+ readonly ephemeral?: boolean | undefined;
1438
+ readonly id?: string | undefined;
1439
+ readonly ts?: number | undefined;
1440
+ readonly idempotencyKey?: string | null | undefined;
1441
+ };
1442
+ readonly tag?: string | undefined;
1443
+ } | {
1444
+ readonly type: "runtime.complete";
1445
+ readonly output: import("effect/Schema").Json;
1446
+ } | {
1447
+ readonly type: "runtime.fail";
1448
+ readonly error: string;
1449
+ } | {
1450
+ readonly type: "runtime.cancel";
1451
+ readonly threadId: string;
1452
+ readonly tag?: string | undefined;
1453
+ } | {
1454
+ readonly type: "runtime.launch";
1455
+ readonly runId: string;
1456
+ readonly kind: string;
1457
+ readonly definitionName: string;
1458
+ readonly definitionVersion: string;
1459
+ readonly input: import("effect/Schema").Json;
1460
+ readonly close: "terminate" | "wait";
1461
+ readonly tag?: string | undefined;
1462
+ } | {
1463
+ readonly type: "runtime.cancelRun";
1464
+ readonly runId: string;
1465
+ readonly tag?: string | undefined;
1466
+ } | {
1467
+ readonly type: string;
1468
+ readonly input: import("effect/Schema").Json;
1469
+ readonly tag?: string | undefined;
1470
+ readonly at?: number | undefined;
1471
+ })[];
1472
+ readonly waitOn?: {
1473
+ readonly type: string | readonly string[];
1474
+ readonly match?: import("effect/Schema").Json | undefined;
1475
+ } | undefined;
1476
+ };
1477
+ }) | (Omit<EventInput, "payload" | "type"> & {
1478
+ readonly type: "agent.lineage";
1479
+ readonly payload: {
1480
+ readonly depth: number;
1481
+ };
1482
+ }) | (Omit<EventInput, "payload" | "type"> & {
1483
+ readonly type: "agent.message";
1484
+ readonly payload: {
1485
+ readonly turn: number;
1486
+ readonly message: {
1487
+ readonly role: "assistant" | "system" | "tool" | "user";
1488
+ readonly content: string;
1489
+ readonly toolCallId?: string | undefined;
1490
+ readonly name?: string | undefined;
1491
+ readonly toolCalls?: {
1492
+ readonly id: string;
1493
+ readonly name: string;
1494
+ readonly arguments: import("effect/Schema").Json;
1495
+ }[] | undefined;
1496
+ };
1497
+ readonly usage?: {
1498
+ readonly input: number;
1499
+ readonly output: number;
1500
+ } | undefined;
1501
+ };
1502
+ }) | (Omit<EventInput, "payload" | "type"> & {
1503
+ readonly type: "agent.message.received";
1504
+ readonly payload: {
1505
+ readonly message: {
1506
+ readonly role: "assistant" | "system" | "tool" | "user";
1507
+ readonly content: string;
1508
+ readonly toolCallId?: string | undefined;
1509
+ readonly name?: string | undefined;
1510
+ readonly toolCalls?: {
1511
+ readonly id: string;
1512
+ readonly name: string;
1513
+ readonly arguments: import("effect/Schema").Json;
1514
+ }[] | undefined;
1515
+ };
1516
+ };
1517
+ }) | (Omit<EventInput, "payload" | "type"> & {
1518
+ readonly type: "agent.session.cancel.requested";
1519
+ readonly payload: {};
1520
+ }) | (Omit<EventInput, "payload" | "type"> & {
1521
+ readonly type: "agent.session.message.submitted";
1522
+ readonly payload: {
1523
+ readonly messageId: string;
1524
+ readonly text: string;
1525
+ readonly delivery?: "followUp" | "nextTurn" | "steer" | undefined;
1526
+ readonly activeChildThreadId?: string | undefined;
1527
+ };
1528
+ }) | (Omit<EventInput, "payload" | "type"> & {
1529
+ readonly type: "agent.session.steer.delivered";
1530
+ readonly payload: {
1531
+ readonly messageId: string;
1532
+ readonly activeMessageId: string;
1533
+ };
1534
+ }) | (Omit<EventInput, "payload" | "type"> & {
1535
+ readonly type: "agent.session.turn.closed";
1536
+ readonly payload: {
1537
+ readonly messageId: string;
1538
+ readonly status: "cancelled" | "completed" | "failed";
1539
+ readonly error?: string | undefined;
1540
+ };
1541
+ }) | (Omit<EventInput, "payload" | "type"> & {
1542
+ readonly type: "agent.session.turn.started";
1543
+ readonly payload: {
1544
+ readonly messageId: string;
1545
+ readonly childThreadId: string;
1546
+ };
1547
+ }) | (Omit<EventInput, "payload" | "type"> & {
1548
+ readonly type: "agent.spawn.requested";
1549
+ readonly payload: {
1550
+ readonly childThreadId: string;
1551
+ readonly kind: string;
1552
+ readonly definitionName: string;
1553
+ readonly definitionVersion: string;
1554
+ readonly toolCallId: string;
1555
+ readonly input: import("effect/Schema").Json;
1556
+ readonly depth?: number | undefined;
1557
+ };
1558
+ }) | (Omit<EventInput, "payload" | "type"> & {
1559
+ readonly type: "agent.steered";
1560
+ readonly payload: {
1561
+ readonly turn: number;
1562
+ readonly messageId?: string | undefined;
1563
+ readonly message: {
1564
+ readonly role: "assistant" | "system" | "tool" | "user";
1565
+ readonly content: string;
1566
+ readonly toolCallId?: string | undefined;
1567
+ readonly name?: string | undefined;
1568
+ readonly toolCalls?: {
1569
+ readonly id: string;
1570
+ readonly name: string;
1571
+ readonly arguments: import("effect/Schema").Json;
1572
+ }[] | undefined;
1573
+ };
1574
+ readonly interrupt?: boolean | undefined;
1575
+ };
1576
+ }) | (Omit<EventInput, "payload" | "type"> & {
1577
+ readonly type: "agent.tool.result";
1578
+ readonly payload: {
1579
+ readonly turn: number;
1580
+ readonly toolCallId: string;
1581
+ readonly name: string;
1582
+ readonly result: import("effect/Schema").Json;
1583
+ readonly error: string | null;
1584
+ };
1585
+ }) | (Omit<EventInput, "payload" | "type"> & {
1586
+ readonly type: "agent.tool_call.requested";
1587
+ readonly payload: {
1588
+ readonly turn: number;
1589
+ readonly toolCall: {
1590
+ readonly id: string;
1591
+ readonly name: string;
1592
+ readonly arguments: import("effect/Schema").Json;
1593
+ };
1594
+ };
1595
+ }) | (Omit<EventInput, "payload" | "type"> & {
1596
+ readonly type: "agent.turn.started";
1597
+ readonly payload: {
1598
+ readonly turn: number;
1599
+ };
1600
+ }) | (Omit<EventInput, "payload" | "type"> & {
1601
+ readonly type: "agent.turn.stopped";
1602
+ readonly payload: {};
1603
+ }) | (Omit<EventInput, "payload" | "type"> & {
1604
+ readonly type: "agent.turn.text_delta";
1605
+ readonly payload: {
1606
+ readonly turn: number;
1607
+ readonly delta: string;
1608
+ };
1609
+ }) | (Omit<EventInput, "payload" | "type"> & {
1610
+ readonly type: "agent.turn.usage";
1611
+ readonly payload: {
1612
+ readonly turn: number;
1613
+ readonly input: number;
1614
+ readonly output: number;
1615
+ };
1616
+ }) | (Omit<EventInput, "payload" | "type"> & {
1375
1617
  readonly type: "runtime.child.close.requested";
1376
1618
  readonly payload: {
1377
1619
  readonly policy: "terminate" | "wait";
@@ -1617,7 +1859,19 @@ export declare function agent(options?: AgentModuleOptions): import("@swirls/loo
1617
1859
  readonly payload: import("effect/Schema").Json;
1618
1860
  };
1619
1861
  };
1620
- }) | (Omit<EventInput, "payload" | "type"> & {
1862
+ })>;
1863
+ executeTool: import("@swirls/looms/core").LocalEffectDefinition<{
1864
+ readonly turn: number;
1865
+ readonly definitionName?: string | undefined;
1866
+ readonly definitionVersion: string;
1867
+ readonly toolCall: {
1868
+ readonly id: string;
1869
+ readonly name: string;
1870
+ readonly arguments: import("effect/Schema").Json;
1871
+ };
1872
+ readonly input?: import("effect/Schema").Json | undefined;
1873
+ readonly depth?: number | undefined;
1874
+ }, import("./definitions-store").AgentDefinitionsTag, (Omit<EventInput, "payload" | "type"> & {
1621
1875
  readonly type: "agent.context.compacted";
1622
1876
  readonly payload: {
1623
1877
  readonly turn: number;
@@ -1859,19 +2113,7 @@ export declare function agent(options?: AgentModuleOptions): import("@swirls/loo
1859
2113
  readonly input: number;
1860
2114
  readonly output: number;
1861
2115
  };
1862
- })>;
1863
- executeTool: import("@swirls/looms/core").LocalEffectDefinition<{
1864
- readonly turn: number;
1865
- readonly definitionName?: string | undefined;
1866
- readonly definitionVersion: string;
1867
- readonly toolCall: {
1868
- readonly id: string;
1869
- readonly name: string;
1870
- readonly arguments: import("effect/Schema").Json;
1871
- };
1872
- readonly input?: import("effect/Schema").Json | undefined;
1873
- readonly depth?: number | undefined;
1874
- }, import("./definitions-store").AgentDefinitionsTag, (Omit<EventInput, "payload" | "type"> & {
2116
+ }) | (Omit<EventInput, "payload" | "type"> & {
1875
2117
  readonly type: "runtime.child.close.requested";
1876
2118
  readonly payload: {
1877
2119
  readonly policy: "terminate" | "wait";
@@ -2117,248 +2359,6 @@ export declare function agent(options?: AgentModuleOptions): import("@swirls/loo
2117
2359
  readonly payload: import("effect/Schema").Json;
2118
2360
  };
2119
2361
  };
2120
- }) | (Omit<EventInput, "payload" | "type"> & {
2121
- readonly type: "agent.context.compacted";
2122
- readonly payload: {
2123
- readonly turn: number;
2124
- readonly originalCount: number;
2125
- readonly compactedCount: number;
2126
- readonly summary?: string | undefined;
2127
- readonly reason?: "manual" | "overflow" | "threshold" | undefined;
2128
- readonly messages?: readonly {
2129
- readonly role: "assistant" | "system" | "tool" | "user";
2130
- readonly content: string;
2131
- readonly toolCallId?: string | undefined;
2132
- readonly name?: string | undefined;
2133
- readonly toolCalls?: {
2134
- readonly id: string;
2135
- readonly name: string;
2136
- readonly arguments: import("effect/Schema").Json;
2137
- }[] | undefined;
2138
- }[] | undefined;
2139
- };
2140
- }) | (Omit<EventInput, "payload" | "type"> & {
2141
- readonly type: "agent.effects.requested";
2142
- readonly payload: {
2143
- readonly toolCallId: string;
2144
- readonly effects: readonly ({
2145
- readonly type: "runtime.spawn";
2146
- readonly childThreadId: string;
2147
- readonly kind: string;
2148
- readonly definitionName: string;
2149
- readonly definitionVersion: string;
2150
- readonly input: import("effect/Schema").Json;
2151
- } | {
2152
- readonly type: "runtime.wait";
2153
- readonly waitId: string;
2154
- readonly on: {
2155
- readonly type: string | readonly string[];
2156
- readonly match?: import("effect/Schema").Json | undefined;
2157
- } | {
2158
- readonly timerAt: number;
2159
- };
2160
- readonly tag?: import("effect/Schema").Json | undefined;
2161
- } | {
2162
- readonly type: "runtime.emit";
2163
- readonly event: {
2164
- readonly type: string;
2165
- readonly payload: import("effect/Schema").Json;
2166
- readonly threadId?: string | null | undefined;
2167
- readonly parentThreadId?: string | null | undefined;
2168
- readonly causationId?: string | null | undefined;
2169
- readonly correlationId?: string | null | undefined;
2170
- readonly effectId?: string | null | undefined;
2171
- readonly origin?: {
2172
- readonly type: "thread";
2173
- readonly threadId: string;
2174
- } | {
2175
- readonly type: "external";
2176
- readonly actorId?: string | undefined;
2177
- } | {
2178
- readonly type: "system";
2179
- } | {
2180
- readonly type: "run";
2181
- readonly runId: string;
2182
- } | undefined;
2183
- readonly ephemeral?: boolean | undefined;
2184
- readonly id?: string | undefined;
2185
- readonly ts?: number | undefined;
2186
- readonly idempotencyKey?: string | null | undefined;
2187
- };
2188
- readonly tag?: string | undefined;
2189
- } | {
2190
- readonly type: "runtime.complete";
2191
- readonly output: import("effect/Schema").Json;
2192
- } | {
2193
- readonly type: "runtime.fail";
2194
- readonly error: string;
2195
- } | {
2196
- readonly type: "runtime.cancel";
2197
- readonly threadId: string;
2198
- readonly tag?: string | undefined;
2199
- } | {
2200
- readonly type: "runtime.launch";
2201
- readonly runId: string;
2202
- readonly kind: string;
2203
- readonly definitionName: string;
2204
- readonly definitionVersion: string;
2205
- readonly input: import("effect/Schema").Json;
2206
- readonly close: "terminate" | "wait";
2207
- readonly tag?: string | undefined;
2208
- } | {
2209
- readonly type: "runtime.cancelRun";
2210
- readonly runId: string;
2211
- readonly tag?: string | undefined;
2212
- } | {
2213
- readonly type: string;
2214
- readonly input: import("effect/Schema").Json;
2215
- readonly tag?: string | undefined;
2216
- readonly at?: number | undefined;
2217
- })[];
2218
- readonly waitOn?: {
2219
- readonly type: string | readonly string[];
2220
- readonly match?: import("effect/Schema").Json | undefined;
2221
- } | undefined;
2222
- };
2223
- }) | (Omit<EventInput, "payload" | "type"> & {
2224
- readonly type: "agent.lineage";
2225
- readonly payload: {
2226
- readonly depth: number;
2227
- };
2228
- }) | (Omit<EventInput, "payload" | "type"> & {
2229
- readonly type: "agent.message";
2230
- readonly payload: {
2231
- readonly turn: number;
2232
- readonly message: {
2233
- readonly role: "assistant" | "system" | "tool" | "user";
2234
- readonly content: string;
2235
- readonly toolCallId?: string | undefined;
2236
- readonly name?: string | undefined;
2237
- readonly toolCalls?: {
2238
- readonly id: string;
2239
- readonly name: string;
2240
- readonly arguments: import("effect/Schema").Json;
2241
- }[] | undefined;
2242
- };
2243
- readonly usage?: {
2244
- readonly input: number;
2245
- readonly output: number;
2246
- } | undefined;
2247
- };
2248
- }) | (Omit<EventInput, "payload" | "type"> & {
2249
- readonly type: "agent.message.received";
2250
- readonly payload: {
2251
- readonly message: {
2252
- readonly role: "assistant" | "system" | "tool" | "user";
2253
- readonly content: string;
2254
- readonly toolCallId?: string | undefined;
2255
- readonly name?: string | undefined;
2256
- readonly toolCalls?: {
2257
- readonly id: string;
2258
- readonly name: string;
2259
- readonly arguments: import("effect/Schema").Json;
2260
- }[] | undefined;
2261
- };
2262
- };
2263
- }) | (Omit<EventInput, "payload" | "type"> & {
2264
- readonly type: "agent.session.cancel.requested";
2265
- readonly payload: {};
2266
- }) | (Omit<EventInput, "payload" | "type"> & {
2267
- readonly type: "agent.session.message.submitted";
2268
- readonly payload: {
2269
- readonly messageId: string;
2270
- readonly text: string;
2271
- readonly delivery?: "followUp" | "nextTurn" | "steer" | undefined;
2272
- readonly activeChildThreadId?: string | undefined;
2273
- };
2274
- }) | (Omit<EventInput, "payload" | "type"> & {
2275
- readonly type: "agent.session.steer.delivered";
2276
- readonly payload: {
2277
- readonly messageId: string;
2278
- readonly activeMessageId: string;
2279
- };
2280
- }) | (Omit<EventInput, "payload" | "type"> & {
2281
- readonly type: "agent.session.turn.closed";
2282
- readonly payload: {
2283
- readonly messageId: string;
2284
- readonly status: "cancelled" | "completed" | "failed";
2285
- readonly error?: string | undefined;
2286
- };
2287
- }) | (Omit<EventInput, "payload" | "type"> & {
2288
- readonly type: "agent.session.turn.started";
2289
- readonly payload: {
2290
- readonly messageId: string;
2291
- readonly childThreadId: string;
2292
- };
2293
- }) | (Omit<EventInput, "payload" | "type"> & {
2294
- readonly type: "agent.spawn.requested";
2295
- readonly payload: {
2296
- readonly childThreadId: string;
2297
- readonly kind: string;
2298
- readonly definitionName: string;
2299
- readonly definitionVersion: string;
2300
- readonly toolCallId: string;
2301
- readonly input: import("effect/Schema").Json;
2302
- readonly depth?: number | undefined;
2303
- };
2304
- }) | (Omit<EventInput, "payload" | "type"> & {
2305
- readonly type: "agent.steered";
2306
- readonly payload: {
2307
- readonly turn: number;
2308
- readonly messageId?: string | undefined;
2309
- readonly message: {
2310
- readonly role: "assistant" | "system" | "tool" | "user";
2311
- readonly content: string;
2312
- readonly toolCallId?: string | undefined;
2313
- readonly name?: string | undefined;
2314
- readonly toolCalls?: {
2315
- readonly id: string;
2316
- readonly name: string;
2317
- readonly arguments: import("effect/Schema").Json;
2318
- }[] | undefined;
2319
- };
2320
- readonly interrupt?: boolean | undefined;
2321
- };
2322
- }) | (Omit<EventInput, "payload" | "type"> & {
2323
- readonly type: "agent.tool.result";
2324
- readonly payload: {
2325
- readonly turn: number;
2326
- readonly toolCallId: string;
2327
- readonly name: string;
2328
- readonly result: import("effect/Schema").Json;
2329
- readonly error: string | null;
2330
- };
2331
- }) | (Omit<EventInput, "payload" | "type"> & {
2332
- readonly type: "agent.tool_call.requested";
2333
- readonly payload: {
2334
- readonly turn: number;
2335
- readonly toolCall: {
2336
- readonly id: string;
2337
- readonly name: string;
2338
- readonly arguments: import("effect/Schema").Json;
2339
- };
2340
- };
2341
- }) | (Omit<EventInput, "payload" | "type"> & {
2342
- readonly type: "agent.turn.started";
2343
- readonly payload: {
2344
- readonly turn: number;
2345
- };
2346
- }) | (Omit<EventInput, "payload" | "type"> & {
2347
- readonly type: "agent.turn.stopped";
2348
- readonly payload: {};
2349
- }) | (Omit<EventInput, "payload" | "type"> & {
2350
- readonly type: "agent.turn.text_delta";
2351
- readonly payload: {
2352
- readonly turn: number;
2353
- readonly delta: string;
2354
- };
2355
- }) | (Omit<EventInput, "payload" | "type"> & {
2356
- readonly type: "agent.turn.usage";
2357
- readonly payload: {
2358
- readonly turn: number;
2359
- readonly input: number;
2360
- readonly output: number;
2361
- };
2362
2362
  })>;
2363
2363
  };
2364
2364
  readonly threads: {