@swirls/looms 0.23.0 → 0.25.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.
- package/CHANGELOG.md +22 -0
- package/dist/agent/threads.js +4 -1
- package/dist/approval/effects.d.ts +26 -26
- package/dist/approval/module.d.ts +52 -52
- package/dist/debugger/app/assets/index-GLtrulmj.js +23 -0
- package/dist/debugger/app/assets/{routes-Ch30UGik.js → routes-CECZJJob.js} +1 -1
- package/dist/debugger/app/index.html +1 -1
- package/dist/evaluator/effects.d.ts +33 -33
- package/dist/evaluator/module.d.ts +66 -66
- package/dist/nats/index.d.ts +1 -1
- package/dist/nats/index.js +1 -1
- package/dist/nats/projector.d.ts +17 -0
- package/dist/nats/projector.js +29 -8
- package/dist/nats/subjects.d.ts +8 -0
- package/dist/nats/subjects.js +10 -0
- package/dist/nats/transport.d.ts +10 -0
- package/dist/nats/transport.js +13 -4
- package/dist/swarm/board.d.ts +292 -0
- package/dist/swarm/board.js +123 -0
- package/dist/swarm/conformance.d.ts +15 -0
- package/dist/swarm/conformance.js +225 -0
- package/dist/swarm/definitions.d.ts +94 -0
- package/dist/swarm/definitions.js +51 -0
- package/dist/swarm/effects.d.ts +4720 -0
- package/dist/swarm/effects.js +296 -0
- package/dist/swarm/ensure.d.ts +16 -0
- package/dist/swarm/ensure.js +24 -0
- package/dist/swarm/events.d.ts +240 -0
- package/dist/swarm/events.js +49 -0
- package/dist/swarm/index.d.ts +15 -0
- package/dist/swarm/index.js +15 -0
- package/dist/swarm/memory-board.d.ts +10 -0
- package/dist/swarm/memory-board.js +344 -0
- package/dist/swarm/module.d.ts +9593 -0
- package/dist/swarm/module.js +94 -0
- package/dist/swarm/projections.d.ts +60 -0
- package/dist/swarm/projections.js +102 -0
- package/dist/swarm/prompt.d.ts +4 -0
- package/dist/swarm/prompt.js +35 -0
- package/dist/swarm/scope.d.ts +357 -0
- package/dist/swarm/scope.js +8 -0
- package/dist/swarm/services.d.ts +29 -0
- package/dist/swarm/services.js +40 -0
- package/dist/swarm/signals.d.ts +14 -0
- package/dist/swarm/signals.js +15 -0
- package/dist/swarm/steps.d.ts +15 -0
- package/dist/swarm/steps.js +27 -0
- package/dist/swarm/threads.d.ts +41 -0
- package/dist/swarm/threads.js +244 -0
- package/dist/swarm/tools.d.ts +19 -0
- package/dist/swarm/tools.js +100 -0
- package/package.json +7 -2
- package/dist/debugger/app/assets/index-CxbIGkpY.js +0 -22
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { type EventOf } from '@swirls/looms/core';
|
|
2
|
+
export declare const swarmModule: import("@swirls/looms/core").ModuleScope<"swarm", import("@swirls/looms/core").ScopeUniverse<import("@swirls/looms/core").EventCatalog<"swarm", {
|
|
3
|
+
'board.pulled': import("effect/Schema").Struct<{
|
|
4
|
+
readonly board: import("effect/Schema").String;
|
|
5
|
+
readonly pull: import("effect/Schema").Finite;
|
|
6
|
+
readonly cursor: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
7
|
+
readonly events: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
8
|
+
readonly cursor: import("effect/Schema").String;
|
|
9
|
+
readonly type: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"message.posted">, import("effect/Schema").Literal<"message.labeled">, import("effect/Schema").Literal<"task.created">, import("effect/Schema").Literal<"task.ready">, import("effect/Schema").Literal<"task.claimed">, import("effect/Schema").Literal<"task.blocked">, import("effect/Schema").Literal<"task.completed">, import("effect/Schema").Literal<"task.failed">, import("effect/Schema").Literal<"task.canceled">, import("effect/Schema").Literal<"task.reopened">]>;
|
|
10
|
+
readonly at: import("effect/Schema").Finite;
|
|
11
|
+
readonly by: import("effect/Schema").String;
|
|
12
|
+
readonly message: import("effect/Schema").optional<import("effect/Schema").Struct<{
|
|
13
|
+
readonly id: import("effect/Schema").String;
|
|
14
|
+
readonly channel: import("effect/Schema").String;
|
|
15
|
+
readonly text: import("effect/Schema").String;
|
|
16
|
+
readonly by: import("effect/Schema").String;
|
|
17
|
+
readonly re: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
18
|
+
readonly mentions: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
19
|
+
readonly labels: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").String>;
|
|
20
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
21
|
+
}>>;
|
|
22
|
+
readonly task: import("effect/Schema").optional<import("effect/Schema").Struct<{
|
|
23
|
+
readonly id: import("effect/Schema").String;
|
|
24
|
+
readonly channel: import("effect/Schema").String;
|
|
25
|
+
readonly text: import("effect/Schema").String;
|
|
26
|
+
readonly by: import("effect/Schema").String;
|
|
27
|
+
readonly for: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
28
|
+
readonly needs: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
29
|
+
readonly state: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"waiting">, import("effect/Schema").Literal<"ready">, import("effect/Schema").Literal<"claimed">, import("effect/Schema").Literal<"blocked">, import("effect/Schema").Literal<"completed">, import("effect/Schema").Literal<"failed">, import("effect/Schema").Literal<"canceled">]>;
|
|
30
|
+
readonly holder: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
31
|
+
readonly epoch: import("effect/Schema").Finite;
|
|
32
|
+
readonly leaseUntil: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
33
|
+
readonly note: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
34
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
35
|
+
readonly updatedAt: import("effect/Schema").Finite;
|
|
36
|
+
}>>;
|
|
37
|
+
}>>;
|
|
38
|
+
readonly more: import("effect/Schema").Boolean;
|
|
39
|
+
readonly nextPullAt: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
40
|
+
}>;
|
|
41
|
+
'member.activated': import("effect/Schema").Struct<{
|
|
42
|
+
readonly board: import("effect/Schema").String;
|
|
43
|
+
readonly member: import("effect/Schema").String;
|
|
44
|
+
readonly activation: import("effect/Schema").Finite;
|
|
45
|
+
readonly runId: import("effect/Schema").String;
|
|
46
|
+
readonly events: import("effect/Schema").Finite;
|
|
47
|
+
readonly at: import("effect/Schema").Finite;
|
|
48
|
+
}>;
|
|
49
|
+
nudged: import("effect/Schema").Struct<{}>;
|
|
50
|
+
stopped: import("effect/Schema").Struct<{}>;
|
|
51
|
+
'message.posted': import("effect/Schema").Struct<{
|
|
52
|
+
readonly callId: import("effect/Schema").String;
|
|
53
|
+
readonly board: import("effect/Schema").String;
|
|
54
|
+
readonly message: import("effect/Schema").Struct<{
|
|
55
|
+
readonly id: import("effect/Schema").String;
|
|
56
|
+
readonly channel: import("effect/Schema").String;
|
|
57
|
+
readonly text: import("effect/Schema").String;
|
|
58
|
+
readonly by: import("effect/Schema").String;
|
|
59
|
+
readonly re: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
60
|
+
readonly mentions: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
61
|
+
readonly labels: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").String>;
|
|
62
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
63
|
+
}>;
|
|
64
|
+
}>;
|
|
65
|
+
'message.labeled': import("effect/Schema").Struct<{
|
|
66
|
+
readonly callId: import("effect/Schema").String;
|
|
67
|
+
readonly board: import("effect/Schema").String;
|
|
68
|
+
readonly message: import("effect/Schema").Struct<{
|
|
69
|
+
readonly id: import("effect/Schema").String;
|
|
70
|
+
readonly channel: import("effect/Schema").String;
|
|
71
|
+
readonly text: import("effect/Schema").String;
|
|
72
|
+
readonly by: import("effect/Schema").String;
|
|
73
|
+
readonly re: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
74
|
+
readonly mentions: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
75
|
+
readonly labels: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").String>;
|
|
76
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
77
|
+
}>;
|
|
78
|
+
}>;
|
|
79
|
+
'messages.read': import("effect/Schema").Struct<{
|
|
80
|
+
readonly callId: import("effect/Schema").String;
|
|
81
|
+
readonly board: import("effect/Schema").String;
|
|
82
|
+
readonly messages: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
83
|
+
readonly id: import("effect/Schema").String;
|
|
84
|
+
readonly channel: import("effect/Schema").String;
|
|
85
|
+
readonly text: import("effect/Schema").String;
|
|
86
|
+
readonly by: import("effect/Schema").String;
|
|
87
|
+
readonly re: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
88
|
+
readonly mentions: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
89
|
+
readonly labels: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").String>;
|
|
90
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
91
|
+
}>>;
|
|
92
|
+
}>;
|
|
93
|
+
'task.created': import("effect/Schema").Struct<{
|
|
94
|
+
readonly callId: import("effect/Schema").String;
|
|
95
|
+
readonly board: import("effect/Schema").String;
|
|
96
|
+
readonly task: import("effect/Schema").Struct<{
|
|
97
|
+
readonly id: import("effect/Schema").String;
|
|
98
|
+
readonly channel: import("effect/Schema").String;
|
|
99
|
+
readonly text: import("effect/Schema").String;
|
|
100
|
+
readonly by: import("effect/Schema").String;
|
|
101
|
+
readonly for: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
102
|
+
readonly needs: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
103
|
+
readonly state: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"waiting">, import("effect/Schema").Literal<"ready">, import("effect/Schema").Literal<"claimed">, import("effect/Schema").Literal<"blocked">, import("effect/Schema").Literal<"completed">, import("effect/Schema").Literal<"failed">, import("effect/Schema").Literal<"canceled">]>;
|
|
104
|
+
readonly holder: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
105
|
+
readonly epoch: import("effect/Schema").Finite;
|
|
106
|
+
readonly leaseUntil: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
107
|
+
readonly note: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
108
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
109
|
+
readonly updatedAt: import("effect/Schema").Finite;
|
|
110
|
+
}>;
|
|
111
|
+
}>;
|
|
112
|
+
'tasks.listed': import("effect/Schema").Struct<{
|
|
113
|
+
readonly callId: import("effect/Schema").String;
|
|
114
|
+
readonly board: import("effect/Schema").String;
|
|
115
|
+
readonly tasks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
116
|
+
readonly id: import("effect/Schema").String;
|
|
117
|
+
readonly channel: import("effect/Schema").String;
|
|
118
|
+
readonly text: import("effect/Schema").String;
|
|
119
|
+
readonly by: import("effect/Schema").String;
|
|
120
|
+
readonly for: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
121
|
+
readonly needs: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
122
|
+
readonly state: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"waiting">, import("effect/Schema").Literal<"ready">, import("effect/Schema").Literal<"claimed">, import("effect/Schema").Literal<"blocked">, import("effect/Schema").Literal<"completed">, import("effect/Schema").Literal<"failed">, import("effect/Schema").Literal<"canceled">]>;
|
|
123
|
+
readonly holder: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
124
|
+
readonly epoch: import("effect/Schema").Finite;
|
|
125
|
+
readonly leaseUntil: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
126
|
+
readonly note: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
127
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
128
|
+
readonly updatedAt: import("effect/Schema").Finite;
|
|
129
|
+
}>>;
|
|
130
|
+
}>;
|
|
131
|
+
'task.claimed': import("effect/Schema").Struct<{
|
|
132
|
+
readonly callId: import("effect/Schema").String;
|
|
133
|
+
readonly board: import("effect/Schema").String;
|
|
134
|
+
readonly claim: import("effect/Schema").NullOr<import("effect/Schema").Struct<{
|
|
135
|
+
readonly task: import("effect/Schema").Struct<{
|
|
136
|
+
readonly id: import("effect/Schema").String;
|
|
137
|
+
readonly channel: import("effect/Schema").String;
|
|
138
|
+
readonly text: import("effect/Schema").String;
|
|
139
|
+
readonly by: import("effect/Schema").String;
|
|
140
|
+
readonly for: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
141
|
+
readonly needs: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
142
|
+
readonly state: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"waiting">, import("effect/Schema").Literal<"ready">, import("effect/Schema").Literal<"claimed">, import("effect/Schema").Literal<"blocked">, import("effect/Schema").Literal<"completed">, import("effect/Schema").Literal<"failed">, import("effect/Schema").Literal<"canceled">]>;
|
|
143
|
+
readonly holder: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
144
|
+
readonly epoch: import("effect/Schema").Finite;
|
|
145
|
+
readonly leaseUntil: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
146
|
+
readonly note: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
147
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
148
|
+
readonly updatedAt: import("effect/Schema").Finite;
|
|
149
|
+
}>;
|
|
150
|
+
readonly token: import("effect/Schema").String;
|
|
151
|
+
readonly until: import("effect/Schema").Finite;
|
|
152
|
+
}>>;
|
|
153
|
+
}>;
|
|
154
|
+
'task.settled': import("effect/Schema").Struct<{
|
|
155
|
+
readonly callId: import("effect/Schema").String;
|
|
156
|
+
readonly board: import("effect/Schema").String;
|
|
157
|
+
readonly task: import("effect/Schema").Struct<{
|
|
158
|
+
readonly id: import("effect/Schema").String;
|
|
159
|
+
readonly channel: import("effect/Schema").String;
|
|
160
|
+
readonly text: import("effect/Schema").String;
|
|
161
|
+
readonly by: import("effect/Schema").String;
|
|
162
|
+
readonly for: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
163
|
+
readonly needs: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
164
|
+
readonly state: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"waiting">, import("effect/Schema").Literal<"ready">, import("effect/Schema").Literal<"claimed">, import("effect/Schema").Literal<"blocked">, import("effect/Schema").Literal<"completed">, import("effect/Schema").Literal<"failed">, import("effect/Schema").Literal<"canceled">]>;
|
|
165
|
+
readonly holder: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
166
|
+
readonly epoch: import("effect/Schema").Finite;
|
|
167
|
+
readonly leaseUntil: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
168
|
+
readonly note: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
169
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
170
|
+
readonly updatedAt: import("effect/Schema").Finite;
|
|
171
|
+
}>;
|
|
172
|
+
}>;
|
|
173
|
+
'call.rejected': import("effect/Schema").Struct<{
|
|
174
|
+
readonly callId: import("effect/Schema").String;
|
|
175
|
+
readonly board: import("effect/Schema").String;
|
|
176
|
+
readonly code: import("effect/Schema").String;
|
|
177
|
+
readonly error: import("effect/Schema").String;
|
|
178
|
+
}>;
|
|
179
|
+
}>, undefined>, import("@swirls/looms/core").EventCatalog<"swarm", {
|
|
180
|
+
'board.pulled': import("effect/Schema").Struct<{
|
|
181
|
+
readonly board: import("effect/Schema").String;
|
|
182
|
+
readonly pull: import("effect/Schema").Finite;
|
|
183
|
+
readonly cursor: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
184
|
+
readonly events: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
185
|
+
readonly cursor: import("effect/Schema").String;
|
|
186
|
+
readonly type: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"message.posted">, import("effect/Schema").Literal<"message.labeled">, import("effect/Schema").Literal<"task.created">, import("effect/Schema").Literal<"task.ready">, import("effect/Schema").Literal<"task.claimed">, import("effect/Schema").Literal<"task.blocked">, import("effect/Schema").Literal<"task.completed">, import("effect/Schema").Literal<"task.failed">, import("effect/Schema").Literal<"task.canceled">, import("effect/Schema").Literal<"task.reopened">]>;
|
|
187
|
+
readonly at: import("effect/Schema").Finite;
|
|
188
|
+
readonly by: import("effect/Schema").String;
|
|
189
|
+
readonly message: import("effect/Schema").optional<import("effect/Schema").Struct<{
|
|
190
|
+
readonly id: import("effect/Schema").String;
|
|
191
|
+
readonly channel: import("effect/Schema").String;
|
|
192
|
+
readonly text: import("effect/Schema").String;
|
|
193
|
+
readonly by: import("effect/Schema").String;
|
|
194
|
+
readonly re: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
195
|
+
readonly mentions: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
196
|
+
readonly labels: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").String>;
|
|
197
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
198
|
+
}>>;
|
|
199
|
+
readonly task: import("effect/Schema").optional<import("effect/Schema").Struct<{
|
|
200
|
+
readonly id: import("effect/Schema").String;
|
|
201
|
+
readonly channel: import("effect/Schema").String;
|
|
202
|
+
readonly text: import("effect/Schema").String;
|
|
203
|
+
readonly by: import("effect/Schema").String;
|
|
204
|
+
readonly for: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
205
|
+
readonly needs: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
206
|
+
readonly state: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"waiting">, import("effect/Schema").Literal<"ready">, import("effect/Schema").Literal<"claimed">, import("effect/Schema").Literal<"blocked">, import("effect/Schema").Literal<"completed">, import("effect/Schema").Literal<"failed">, import("effect/Schema").Literal<"canceled">]>;
|
|
207
|
+
readonly holder: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
208
|
+
readonly epoch: import("effect/Schema").Finite;
|
|
209
|
+
readonly leaseUntil: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
210
|
+
readonly note: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
211
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
212
|
+
readonly updatedAt: import("effect/Schema").Finite;
|
|
213
|
+
}>>;
|
|
214
|
+
}>>;
|
|
215
|
+
readonly more: import("effect/Schema").Boolean;
|
|
216
|
+
readonly nextPullAt: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
217
|
+
}>;
|
|
218
|
+
'member.activated': import("effect/Schema").Struct<{
|
|
219
|
+
readonly board: import("effect/Schema").String;
|
|
220
|
+
readonly member: import("effect/Schema").String;
|
|
221
|
+
readonly activation: import("effect/Schema").Finite;
|
|
222
|
+
readonly runId: import("effect/Schema").String;
|
|
223
|
+
readonly events: import("effect/Schema").Finite;
|
|
224
|
+
readonly at: import("effect/Schema").Finite;
|
|
225
|
+
}>;
|
|
226
|
+
nudged: import("effect/Schema").Struct<{}>;
|
|
227
|
+
stopped: import("effect/Schema").Struct<{}>;
|
|
228
|
+
'message.posted': import("effect/Schema").Struct<{
|
|
229
|
+
readonly callId: import("effect/Schema").String;
|
|
230
|
+
readonly board: import("effect/Schema").String;
|
|
231
|
+
readonly message: import("effect/Schema").Struct<{
|
|
232
|
+
readonly id: import("effect/Schema").String;
|
|
233
|
+
readonly channel: import("effect/Schema").String;
|
|
234
|
+
readonly text: import("effect/Schema").String;
|
|
235
|
+
readonly by: import("effect/Schema").String;
|
|
236
|
+
readonly re: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
237
|
+
readonly mentions: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
238
|
+
readonly labels: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").String>;
|
|
239
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
240
|
+
}>;
|
|
241
|
+
}>;
|
|
242
|
+
'message.labeled': import("effect/Schema").Struct<{
|
|
243
|
+
readonly callId: import("effect/Schema").String;
|
|
244
|
+
readonly board: import("effect/Schema").String;
|
|
245
|
+
readonly message: import("effect/Schema").Struct<{
|
|
246
|
+
readonly id: import("effect/Schema").String;
|
|
247
|
+
readonly channel: import("effect/Schema").String;
|
|
248
|
+
readonly text: import("effect/Schema").String;
|
|
249
|
+
readonly by: import("effect/Schema").String;
|
|
250
|
+
readonly re: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
251
|
+
readonly mentions: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
252
|
+
readonly labels: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").String>;
|
|
253
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
254
|
+
}>;
|
|
255
|
+
}>;
|
|
256
|
+
'messages.read': import("effect/Schema").Struct<{
|
|
257
|
+
readonly callId: import("effect/Schema").String;
|
|
258
|
+
readonly board: import("effect/Schema").String;
|
|
259
|
+
readonly messages: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
260
|
+
readonly id: import("effect/Schema").String;
|
|
261
|
+
readonly channel: import("effect/Schema").String;
|
|
262
|
+
readonly text: import("effect/Schema").String;
|
|
263
|
+
readonly by: import("effect/Schema").String;
|
|
264
|
+
readonly re: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
265
|
+
readonly mentions: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
266
|
+
readonly labels: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").String>;
|
|
267
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
268
|
+
}>>;
|
|
269
|
+
}>;
|
|
270
|
+
'task.created': import("effect/Schema").Struct<{
|
|
271
|
+
readonly callId: import("effect/Schema").String;
|
|
272
|
+
readonly board: import("effect/Schema").String;
|
|
273
|
+
readonly task: import("effect/Schema").Struct<{
|
|
274
|
+
readonly id: import("effect/Schema").String;
|
|
275
|
+
readonly channel: import("effect/Schema").String;
|
|
276
|
+
readonly text: import("effect/Schema").String;
|
|
277
|
+
readonly by: import("effect/Schema").String;
|
|
278
|
+
readonly for: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
279
|
+
readonly needs: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
280
|
+
readonly state: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"waiting">, import("effect/Schema").Literal<"ready">, import("effect/Schema").Literal<"claimed">, import("effect/Schema").Literal<"blocked">, import("effect/Schema").Literal<"completed">, import("effect/Schema").Literal<"failed">, import("effect/Schema").Literal<"canceled">]>;
|
|
281
|
+
readonly holder: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
282
|
+
readonly epoch: import("effect/Schema").Finite;
|
|
283
|
+
readonly leaseUntil: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
284
|
+
readonly note: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
285
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
286
|
+
readonly updatedAt: import("effect/Schema").Finite;
|
|
287
|
+
}>;
|
|
288
|
+
}>;
|
|
289
|
+
'tasks.listed': import("effect/Schema").Struct<{
|
|
290
|
+
readonly callId: import("effect/Schema").String;
|
|
291
|
+
readonly board: import("effect/Schema").String;
|
|
292
|
+
readonly tasks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
293
|
+
readonly id: import("effect/Schema").String;
|
|
294
|
+
readonly channel: import("effect/Schema").String;
|
|
295
|
+
readonly text: import("effect/Schema").String;
|
|
296
|
+
readonly by: import("effect/Schema").String;
|
|
297
|
+
readonly for: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
298
|
+
readonly needs: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
299
|
+
readonly state: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"waiting">, import("effect/Schema").Literal<"ready">, import("effect/Schema").Literal<"claimed">, import("effect/Schema").Literal<"blocked">, import("effect/Schema").Literal<"completed">, import("effect/Schema").Literal<"failed">, import("effect/Schema").Literal<"canceled">]>;
|
|
300
|
+
readonly holder: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
301
|
+
readonly epoch: import("effect/Schema").Finite;
|
|
302
|
+
readonly leaseUntil: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
303
|
+
readonly note: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
304
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
305
|
+
readonly updatedAt: import("effect/Schema").Finite;
|
|
306
|
+
}>>;
|
|
307
|
+
}>;
|
|
308
|
+
'task.claimed': import("effect/Schema").Struct<{
|
|
309
|
+
readonly callId: import("effect/Schema").String;
|
|
310
|
+
readonly board: import("effect/Schema").String;
|
|
311
|
+
readonly claim: import("effect/Schema").NullOr<import("effect/Schema").Struct<{
|
|
312
|
+
readonly task: import("effect/Schema").Struct<{
|
|
313
|
+
readonly id: import("effect/Schema").String;
|
|
314
|
+
readonly channel: import("effect/Schema").String;
|
|
315
|
+
readonly text: import("effect/Schema").String;
|
|
316
|
+
readonly by: import("effect/Schema").String;
|
|
317
|
+
readonly for: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
318
|
+
readonly needs: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
319
|
+
readonly state: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"waiting">, import("effect/Schema").Literal<"ready">, import("effect/Schema").Literal<"claimed">, import("effect/Schema").Literal<"blocked">, import("effect/Schema").Literal<"completed">, import("effect/Schema").Literal<"failed">, import("effect/Schema").Literal<"canceled">]>;
|
|
320
|
+
readonly holder: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
321
|
+
readonly epoch: import("effect/Schema").Finite;
|
|
322
|
+
readonly leaseUntil: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
323
|
+
readonly note: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
324
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
325
|
+
readonly updatedAt: import("effect/Schema").Finite;
|
|
326
|
+
}>;
|
|
327
|
+
readonly token: import("effect/Schema").String;
|
|
328
|
+
readonly until: import("effect/Schema").Finite;
|
|
329
|
+
}>>;
|
|
330
|
+
}>;
|
|
331
|
+
'task.settled': import("effect/Schema").Struct<{
|
|
332
|
+
readonly callId: import("effect/Schema").String;
|
|
333
|
+
readonly board: import("effect/Schema").String;
|
|
334
|
+
readonly task: import("effect/Schema").Struct<{
|
|
335
|
+
readonly id: import("effect/Schema").String;
|
|
336
|
+
readonly channel: import("effect/Schema").String;
|
|
337
|
+
readonly text: import("effect/Schema").String;
|
|
338
|
+
readonly by: import("effect/Schema").String;
|
|
339
|
+
readonly for: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
340
|
+
readonly needs: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
341
|
+
readonly state: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"waiting">, import("effect/Schema").Literal<"ready">, import("effect/Schema").Literal<"claimed">, import("effect/Schema").Literal<"blocked">, import("effect/Schema").Literal<"completed">, import("effect/Schema").Literal<"failed">, import("effect/Schema").Literal<"canceled">]>;
|
|
342
|
+
readonly holder: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
343
|
+
readonly epoch: import("effect/Schema").Finite;
|
|
344
|
+
readonly leaseUntil: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
345
|
+
readonly note: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
346
|
+
readonly createdAt: import("effect/Schema").Finite;
|
|
347
|
+
readonly updatedAt: import("effect/Schema").Finite;
|
|
348
|
+
}>;
|
|
349
|
+
}>;
|
|
350
|
+
'call.rejected': import("effect/Schema").Struct<{
|
|
351
|
+
readonly callId: import("effect/Schema").String;
|
|
352
|
+
readonly board: import("effect/Schema").String;
|
|
353
|
+
readonly code: import("effect/Schema").String;
|
|
354
|
+
readonly error: import("effect/Schema").String;
|
|
355
|
+
}>;
|
|
356
|
+
}>, undefined>;
|
|
357
|
+
export type SwarmEvent = EventOf<typeof swarmModule>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createModuleScope } from '@swirls/looms/core';
|
|
2
|
+
import { swarmCatalog } from './events.js';
|
|
3
|
+
export const swarmModule = createModuleScope({
|
|
4
|
+
namespace: 'swarm',
|
|
5
|
+
protocolVersion: '1.0.0',
|
|
6
|
+
description: 'Agent swarms that coordinate through a shared message board.',
|
|
7
|
+
events: swarmCatalog,
|
|
8
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from 'effect';
|
|
2
|
+
import type { DefinitionStore } from '@swirls/looms/core';
|
|
3
|
+
import { BoardError, type BoardResolver, type MessageBoard } from './board';
|
|
4
|
+
import type { SwarmDefinition } from './definitions';
|
|
5
|
+
export type SwarmDefinitionStore = DefinitionStore<SwarmDefinition>;
|
|
6
|
+
declare const SwarmDefinitionsTag_base: Context.ServiceClass<SwarmDefinitionsTag, "looms/SwarmDefinitions", SwarmDefinitionStore>;
|
|
7
|
+
export declare class SwarmDefinitionsTag extends SwarmDefinitionsTag_base {
|
|
8
|
+
}
|
|
9
|
+
declare const BoardFaultError_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 & {
|
|
10
|
+
readonly _tag: "BoardFaultError";
|
|
11
|
+
} & Readonly<A>;
|
|
12
|
+
/** The board could not be reached or threw something other than a refusal. Retried. */
|
|
13
|
+
export declare class BoardFaultError extends BoardFaultError_base<{
|
|
14
|
+
readonly message: string;
|
|
15
|
+
readonly cause: unknown;
|
|
16
|
+
}> {
|
|
17
|
+
}
|
|
18
|
+
export interface Boards {
|
|
19
|
+
/** Run one call against a board. Refusals fail with `BoardError`, faults with `BoardFaultError`. */
|
|
20
|
+
readonly call: <A>(boardId: string, run: (board: MessageBoard) => Promise<A>) => Effect.Effect<A, BoardError | BoardFaultError>;
|
|
21
|
+
}
|
|
22
|
+
declare const BoardsTag_base: Context.ServiceClass<BoardsTag, "looms/SwarmBoards", Boards>;
|
|
23
|
+
export declare class BoardsTag extends BoardsTag_base {
|
|
24
|
+
}
|
|
25
|
+
export declare function makeBoards(resolve: BoardResolver): Boards;
|
|
26
|
+
/** One in-memory board per id, created on first use. */
|
|
27
|
+
export declare function memoryBoards(): BoardResolver;
|
|
28
|
+
export declare const SwarmServicesLive: (definitions: SwarmDefinitionStore, boards: BoardResolver) => Layer.Layer<BoardsTag | SwarmDefinitionsTag, never, never>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Context, Data, Effect, Layer } from 'effect';
|
|
2
|
+
import { BoardError } from './board.js';
|
|
3
|
+
import { createMemoryBoard } from './memory-board.js';
|
|
4
|
+
export class SwarmDefinitionsTag extends Context.Service()('looms/SwarmDefinitions') {
|
|
5
|
+
}
|
|
6
|
+
/** The board could not be reached or threw something other than a refusal. Retried. */
|
|
7
|
+
export class BoardFaultError extends Data.TaggedError('BoardFaultError') {
|
|
8
|
+
}
|
|
9
|
+
export class BoardsTag extends Context.Service()('looms/SwarmBoards') {
|
|
10
|
+
}
|
|
11
|
+
function fault(cause) {
|
|
12
|
+
return cause instanceof BoardError
|
|
13
|
+
? cause
|
|
14
|
+
: new BoardFaultError({
|
|
15
|
+
message: cause instanceof Error ? cause.message : String(cause),
|
|
16
|
+
cause,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export function makeBoards(resolve) {
|
|
20
|
+
return {
|
|
21
|
+
call: (boardId, run) => Effect.tryPromise({
|
|
22
|
+
try: () => Promise.resolve(resolve(boardId)).then(run),
|
|
23
|
+
catch: fault,
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** One in-memory board per id, created on first use. */
|
|
28
|
+
export function memoryBoards() {
|
|
29
|
+
const boards = new Map();
|
|
30
|
+
return (boardId) => {
|
|
31
|
+
const existing = boards.get(boardId);
|
|
32
|
+
if (existing) {
|
|
33
|
+
return existing;
|
|
34
|
+
}
|
|
35
|
+
const created = createMemoryBoard();
|
|
36
|
+
boards.set(boardId, created);
|
|
37
|
+
return created;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export const SwarmServicesLive = (definitions, boards) => Layer.merge(Layer.succeed(SwarmDefinitionsTag, definitions), Layer.succeed(BoardsTag, makeBoards(boards)));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tell a swarm the board changed, so it reads it now instead of at its next poll.
|
|
3
|
+
* Send it after a write the swarm did not make itself, such as a person posting from a UI:
|
|
4
|
+
* `looms.signal(swarmRunId, [nudge()])`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const nudge: import("@swirls/looms/core").SignalDefinition<undefined, Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
7
|
+
readonly type: "swarm.nudged";
|
|
8
|
+
readonly payload: {};
|
|
9
|
+
}>;
|
|
10
|
+
/** Stop waking members. The swarm completes once the members that are mid-run have finished. */
|
|
11
|
+
export declare const stop: import("@swirls/looms/core").SignalDefinition<undefined, Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
12
|
+
readonly type: "swarm.stopped";
|
|
13
|
+
readonly payload: {};
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { swarmModule } from './scope.js';
|
|
2
|
+
/**
|
|
3
|
+
* Tell a swarm the board changed, so it reads it now instead of at its next poll.
|
|
4
|
+
* Send it after a write the swarm did not make itself, such as a person posting from a UI:
|
|
5
|
+
* `looms.signal(swarmRunId, [nudge()])`.
|
|
6
|
+
*/
|
|
7
|
+
export const nudge = swarmModule.signal({
|
|
8
|
+
description: 'Read the board now instead of at the next poll.',
|
|
9
|
+
build: () => swarmModule.input('nudged', {}),
|
|
10
|
+
});
|
|
11
|
+
/** Stop waking members. The swarm completes once the members that are mid-run have finished. */
|
|
12
|
+
export const stop = swarmModule.signal({
|
|
13
|
+
description: 'Stop waking members and complete once running members finish.',
|
|
14
|
+
build: () => swarmModule.input('stopped', {}),
|
|
15
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Schema } from 'effect';
|
|
2
|
+
import { type RuntimeEffect } from '@swirls/looms/core';
|
|
3
|
+
import { type CreateTaskArgsSchema, type PostArgsSchema } from './effects';
|
|
4
|
+
/** Which board a step writes to and the name it writes under. */
|
|
5
|
+
export interface BoardBinding {
|
|
6
|
+
readonly board: string;
|
|
7
|
+
readonly as: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Post to a board from a thread or workflow node, and park until the board has answered.
|
|
11
|
+
* The node resumes with the posted message, or fails if the board refused the post.
|
|
12
|
+
*/
|
|
13
|
+
export declare function post(binding: BoardBinding, args: Schema.Schema.Type<typeof PostArgsSchema>): RuntimeEffect[];
|
|
14
|
+
/** Create a board task from a thread or workflow node, and park until the board has answered. */
|
|
15
|
+
export declare function createTask(binding: BoardBinding, args: Schema.Schema.Type<typeof CreateTaskArgsSchema>): RuntimeEffect[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createWaitId, invoke, wait } from '@swirls/looms/core';
|
|
2
|
+
import { createTaskEffect, postEffect, } from './effects.js';
|
|
3
|
+
/**
|
|
4
|
+
* Post to a board from a thread or workflow node, and park until the board has answered.
|
|
5
|
+
* The node resumes with the posted message, or fails if the board refused the post.
|
|
6
|
+
*/
|
|
7
|
+
export function post(binding, args) {
|
|
8
|
+
const callId = createWaitId('swarm');
|
|
9
|
+
return [
|
|
10
|
+
invoke(postEffect, { callId, ...binding, ...args }, `post_${callId}`),
|
|
11
|
+
wait({
|
|
12
|
+
waitId: callId,
|
|
13
|
+
on: { type: ['swarm.message.posted', 'swarm.call.rejected'], match: { callId } },
|
|
14
|
+
}),
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
/** Create a board task from a thread or workflow node, and park until the board has answered. */
|
|
18
|
+
export function createTask(binding, args) {
|
|
19
|
+
const callId = createWaitId('swarm');
|
|
20
|
+
return [
|
|
21
|
+
invoke(createTaskEffect, { callId, ...binding, ...args }, `task_${callId}`),
|
|
22
|
+
wait({
|
|
23
|
+
waitId: callId,
|
|
24
|
+
on: { type: ['swarm.task.created', 'swarm.call.rejected'], match: { callId } },
|
|
25
|
+
}),
|
|
26
|
+
];
|
|
27
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type DefinitionStore, type ThreadDefinition } from '@swirls/looms/core';
|
|
2
|
+
import { type BoardEvent } from './board';
|
|
3
|
+
import { type SwarmDefinition, type SwarmMember } from './definitions';
|
|
4
|
+
/** Board events a member can have queued. Older ones are dropped and counted. */
|
|
5
|
+
export declare const INBOX_LIMIT = 50;
|
|
6
|
+
export interface SwarmMemberState {
|
|
7
|
+
/** How many times this member has been woken. */
|
|
8
|
+
readonly activations: number;
|
|
9
|
+
/** Board events waiting for the member's next activation. */
|
|
10
|
+
readonly inbox: readonly BoardEvent[];
|
|
11
|
+
/** The events of an activation that has been decided but has no run yet. */
|
|
12
|
+
readonly batch: readonly BoardEvent[] | null;
|
|
13
|
+
/** The member's run in progress. */
|
|
14
|
+
readonly runId: string | null;
|
|
15
|
+
/** Events that overflowed the inbox. */
|
|
16
|
+
readonly dropped: number;
|
|
17
|
+
readonly lastError: string | null;
|
|
18
|
+
}
|
|
19
|
+
export interface SwarmState {
|
|
20
|
+
readonly definitionName: string;
|
|
21
|
+
readonly definitionVersion: string;
|
|
22
|
+
readonly board: string;
|
|
23
|
+
/** How far into the board's event log the swarm has read. */
|
|
24
|
+
readonly cursor: string | null;
|
|
25
|
+
/** Completed pulls. Names the next pull, so each pull effect has its own tag. */
|
|
26
|
+
readonly pulls: number;
|
|
27
|
+
/** Read the board as soon as possible. */
|
|
28
|
+
readonly pullNow: boolean;
|
|
29
|
+
/** Otherwise read it at this time, or not until nudged when null. */
|
|
30
|
+
readonly nextPullAt: number | null;
|
|
31
|
+
/** Something may have been written while a pull was in flight, so pull once more after it. */
|
|
32
|
+
readonly dirty: boolean;
|
|
33
|
+
readonly members: {
|
|
34
|
+
readonly [name: string]: SwarmMemberState;
|
|
35
|
+
};
|
|
36
|
+
readonly stopped: boolean;
|
|
37
|
+
readonly invalid: string | null;
|
|
38
|
+
}
|
|
39
|
+
/** Whether a board event should wake `member`. A member is never woken by its own writes. */
|
|
40
|
+
export declare function concerns(member: SwarmMember, event: BoardEvent): boolean;
|
|
41
|
+
export declare function createSwarmThread(definitions: DefinitionStore<SwarmDefinition>): ThreadDefinition<SwarmState>;
|