@swirls/looms 0.0.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.
Files changed (270) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +9 -0
  3. package/dist/actor/cell.d.ts +27 -0
  4. package/dist/actor/cell.js +41 -0
  5. package/dist/actor/host.d.ts +27 -0
  6. package/dist/actor/host.js +82 -0
  7. package/dist/actor/index.d.ts +3 -0
  8. package/dist/actor/index.js +3 -0
  9. package/dist/actor/routing.d.ts +15 -0
  10. package/dist/actor/routing.js +80 -0
  11. package/dist/agent/definitions-store.d.ts +11 -0
  12. package/dist/agent/definitions-store.js +10 -0
  13. package/dist/agent/definitions.d.ts +152 -0
  14. package/dist/agent/definitions.js +74 -0
  15. package/dist/agent/effects.d.ts +425 -0
  16. package/dist/agent/effects.js +318 -0
  17. package/dist/agent/events.d.ts +170 -0
  18. package/dist/agent/events.js +61 -0
  19. package/dist/agent/index.d.ts +13 -0
  20. package/dist/agent/index.js +13 -0
  21. package/dist/agent/llm.d.ts +35 -0
  22. package/dist/agent/llm.js +48 -0
  23. package/dist/agent/module.d.ts +1037 -0
  24. package/dist/agent/module.js +27 -0
  25. package/dist/agent/projections.d.ts +17 -0
  26. package/dist/agent/projections.js +81 -0
  27. package/dist/agent/scope.d.ts +171 -0
  28. package/dist/agent/scope.js +7 -0
  29. package/dist/agent/signals.d.ts +17 -0
  30. package/dist/agent/signals.js +19 -0
  31. package/dist/agent/stop-when.d.ts +12 -0
  32. package/dist/agent/stop-when.js +6 -0
  33. package/dist/agent/threads.d.ts +34 -0
  34. package/dist/agent/threads.js +407 -0
  35. package/dist/agent/tool-schema.d.ts +21 -0
  36. package/dist/agent/tool-schema.js +67 -0
  37. package/dist/agent/types.d.ts +87 -0
  38. package/dist/agent/types.js +32 -0
  39. package/dist/ai-vercel/index.d.ts +2 -0
  40. package/dist/ai-vercel/index.js +2 -0
  41. package/dist/ai-vercel/messages.d.ts +9 -0
  42. package/dist/ai-vercel/messages.js +68 -0
  43. package/dist/ai-vercel/vercel-llm.d.ts +8 -0
  44. package/dist/ai-vercel/vercel-llm.js +98 -0
  45. package/dist/approval/effects.d.ts +133 -0
  46. package/dist/approval/effects.js +13 -0
  47. package/dist/approval/events.d.ts +52 -0
  48. package/dist/approval/events.js +28 -0
  49. package/dist/approval/index.d.ts +6 -0
  50. package/dist/approval/index.js +6 -0
  51. package/dist/approval/module.d.ts +342 -0
  52. package/dist/approval/module.js +10 -0
  53. package/dist/approval/projections.d.ts +42 -0
  54. package/dist/approval/projections.js +57 -0
  55. package/dist/approval/scope.d.ts +45 -0
  56. package/dist/approval/scope.js +7 -0
  57. package/dist/approval/signals.d.ts +19 -0
  58. package/dist/approval/signals.js +34 -0
  59. package/dist/cli/cli.d.ts +2 -0
  60. package/dist/cli/cli.js +6 -0
  61. package/dist/cli/commands.d.ts +13 -0
  62. package/dist/cli/commands.js +133 -0
  63. package/dist/cli/index.d.ts +1 -0
  64. package/dist/cli/index.js +1 -0
  65. package/dist/client/client.d.ts +69 -0
  66. package/dist/client/client.js +179 -0
  67. package/dist/client/index.d.ts +2 -0
  68. package/dist/client/index.js +2 -0
  69. package/dist/client/sse.d.ts +10 -0
  70. package/dist/client/sse.js +103 -0
  71. package/dist/cloudflare/alarm-scheduler.d.ts +9 -0
  72. package/dist/cloudflare/alarm-scheduler.js +13 -0
  73. package/dist/cloudflare/durable-object.d.ts +24 -0
  74. package/dist/cloudflare/durable-object.js +43 -0
  75. package/dist/cloudflare/event-store.d.ts +10 -0
  76. package/dist/cloudflare/event-store.js +18 -0
  77. package/dist/cloudflare/index.d.ts +4 -0
  78. package/dist/cloudflare/index.js +4 -0
  79. package/dist/cloudflare/router.d.ts +12 -0
  80. package/dist/cloudflare/router.js +26 -0
  81. package/dist/core/bun-sqlite.d.ts +13 -0
  82. package/dist/core/bun-sqlite.js +19 -0
  83. package/dist/core/catalog.d.ts +49 -0
  84. package/dist/core/catalog.js +39 -0
  85. package/dist/core/coalesce.d.ts +21 -0
  86. package/dist/core/coalesce.js +178 -0
  87. package/dist/core/compose.d.ts +59 -0
  88. package/dist/core/compose.js +97 -0
  89. package/dist/core/cursor.d.ts +16 -0
  90. package/dist/core/cursor.js +46 -0
  91. package/dist/core/effects.d.ts +110 -0
  92. package/dist/core/effects.js +99 -0
  93. package/dist/core/envelope.d.ts +79 -0
  94. package/dist/core/envelope.js +68 -0
  95. package/dist/core/event-codec.d.ts +8 -0
  96. package/dist/core/event-codec.js +82 -0
  97. package/dist/core/event-index.d.ts +28 -0
  98. package/dist/core/event-index.js +86 -0
  99. package/dist/core/fold.d.ts +19 -0
  100. package/dist/core/fold.js +362 -0
  101. package/dist/core/ids.d.ts +11 -0
  102. package/dist/core/ids.js +47 -0
  103. package/dist/core/index.d.ts +26 -0
  104. package/dist/core/index.js +25 -0
  105. package/dist/core/match.d.ts +8 -0
  106. package/dist/core/match.js +58 -0
  107. package/dist/core/module-scope.d.ts +99 -0
  108. package/dist/core/module-scope.js +72 -0
  109. package/dist/core/module.d.ts +74 -0
  110. package/dist/core/module.js +3 -0
  111. package/dist/core/projection.d.ts +83 -0
  112. package/dist/core/projection.js +241 -0
  113. package/dist/core/protocol.d.ts +99 -0
  114. package/dist/core/protocol.js +101 -0
  115. package/dist/core/replay.d.ts +13 -0
  116. package/dist/core/replay.js +34 -0
  117. package/dist/core/schema.d.ts +35 -0
  118. package/dist/core/schema.js +130 -0
  119. package/dist/core/serialize.d.ts +14 -0
  120. package/dist/core/serialize.js +42 -0
  121. package/dist/core/snapshot-store.d.ts +39 -0
  122. package/dist/core/snapshot-store.js +53 -0
  123. package/dist/core/snapshots.d.ts +26 -0
  124. package/dist/core/snapshots.js +100 -0
  125. package/dist/core/sqlite-store.d.ts +31 -0
  126. package/dist/core/sqlite-store.js +328 -0
  127. package/dist/core/state.d.ts +43 -0
  128. package/dist/core/state.js +31 -0
  129. package/dist/core/store.d.ts +146 -0
  130. package/dist/core/store.js +229 -0
  131. package/dist/core/thread.d.ts +41 -0
  132. package/dist/core/thread.js +13 -0
  133. package/dist/core/types.d.ts +27 -0
  134. package/dist/core/types.js +42 -0
  135. package/dist/core/validate-event.d.ts +19 -0
  136. package/dist/core/validate-event.js +42 -0
  137. package/dist/debugger/components/debugger-split.d.ts +23 -0
  138. package/dist/debugger/components/debugger-split.js +25 -0
  139. package/dist/debugger/components/event-inspector.d.ts +5 -0
  140. package/dist/debugger/components/event-inspector.js +38 -0
  141. package/dist/debugger/components/event-stream.d.ts +13 -0
  142. package/dist/debugger/components/event-stream.js +119 -0
  143. package/dist/debugger/components/json-view.d.ts +5 -0
  144. package/dist/debugger/components/json-view.js +5 -0
  145. package/dist/debugger/components/run-tree.d.ts +14 -0
  146. package/dist/debugger/components/run-tree.js +38 -0
  147. package/dist/debugger/components/status-dot.d.ts +3 -0
  148. package/dist/debugger/components/status-dot.js +5 -0
  149. package/dist/debugger/contracts.d.ts +22 -0
  150. package/dist/debugger/contracts.js +1 -0
  151. package/dist/debugger/events/catalog.d.ts +6 -0
  152. package/dist/debugger/events/catalog.js +27 -0
  153. package/dist/debugger/events/domain-summarize.d.ts +3 -0
  154. package/dist/debugger/events/domain-summarize.js +107 -0
  155. package/dist/debugger/events/family.d.ts +8 -0
  156. package/dist/debugger/events/family.js +44 -0
  157. package/dist/debugger/events/protocol-summarize.d.ts +3 -0
  158. package/dist/debugger/events/protocol-summarize.js +70 -0
  159. package/dist/debugger/index.d.ts +17 -0
  160. package/dist/debugger/index.js +16 -0
  161. package/dist/debugger/lib/cn.d.ts +5 -0
  162. package/dist/debugger/lib/cn.js +17 -0
  163. package/dist/debugger/lib/event-counts.d.ts +5 -0
  164. package/dist/debugger/lib/event-counts.js +23 -0
  165. package/dist/debugger/lib/event-meta.d.ts +8 -0
  166. package/dist/debugger/lib/event-meta.js +20 -0
  167. package/dist/debugger/lib/project-run.d.ts +9 -0
  168. package/dist/debugger/lib/project-run.js +14 -0
  169. package/dist/debugger/lib/status.d.ts +3 -0
  170. package/dist/debugger/lib/status.js +31 -0
  171. package/dist/debugger/lib/visible-events.d.ts +8 -0
  172. package/dist/debugger/lib/visible-events.js +21 -0
  173. package/dist/debugger/styles.css +71 -0
  174. package/dist/debugger/ui/checkbox.d.ts +4 -0
  175. package/dist/debugger/ui/checkbox.js +9 -0
  176. package/dist/debugger/ui/input.d.ts +3 -0
  177. package/dist/debugger/ui/input.js +7 -0
  178. package/dist/debugger/ui/scroll-area.d.ts +9 -0
  179. package/dist/debugger/ui/scroll-area.js +10 -0
  180. package/dist/debugger/ui/tabs.d.ts +7 -0
  181. package/dist/debugger/ui/tabs.js +17 -0
  182. package/dist/index.d.ts +2 -0
  183. package/dist/index.js +2 -0
  184. package/dist/projectors/index-model.d.ts +56 -0
  185. package/dist/projectors/index-model.js +117 -0
  186. package/dist/projectors/index.d.ts +4 -0
  187. package/dist/projectors/index.js +3 -0
  188. package/dist/projectors/memory.d.ts +5 -0
  189. package/dist/projectors/memory.js +77 -0
  190. package/dist/projectors/postgres.d.ts +9 -0
  191. package/dist/projectors/postgres.js +108 -0
  192. package/dist/projectors/projector.d.ts +11 -0
  193. package/dist/projectors/projector.js +1 -0
  194. package/dist/projectors/schema.d.ts +5 -0
  195. package/dist/projectors/schema.js +43 -0
  196. package/dist/projectors/sqlite.d.ts +9 -0
  197. package/dist/projectors/sqlite.js +103 -0
  198. package/dist/projectors/with-projectors.d.ts +17 -0
  199. package/dist/projectors/with-projectors.js +55 -0
  200. package/dist/react/derived.d.ts +19 -0
  201. package/dist/react/derived.js +50 -0
  202. package/dist/react/index.d.ts +6 -0
  203. package/dist/react/index.js +5 -0
  204. package/dist/react/materialize.d.ts +3 -0
  205. package/dist/react/materialize.js +86 -0
  206. package/dist/react/notify.d.ts +18 -0
  207. package/dist/react/notify.js +80 -0
  208. package/dist/react/react.d.ts +61 -0
  209. package/dist/react/react.js +187 -0
  210. package/dist/react/register.d.ts +31 -0
  211. package/dist/react/register.js +1 -0
  212. package/dist/react/sse.d.ts +1 -0
  213. package/dist/react/sse.js +1 -0
  214. package/dist/react/store.d.ts +56 -0
  215. package/dist/react/store.js +340 -0
  216. package/dist/react/tables.d.ts +21 -0
  217. package/dist/react/tables.js +6 -0
  218. package/dist/runtime/dispatch-effect.d.ts +3 -0
  219. package/dist/runtime/dispatch-effect.js +113 -0
  220. package/dist/runtime/events-api.d.ts +4 -0
  221. package/dist/runtime/events-api.js +84 -0
  222. package/dist/runtime/index.d.ts +5 -0
  223. package/dist/runtime/index.js +5 -0
  224. package/dist/runtime/looms.d.ts +74 -0
  225. package/dist/runtime/looms.js +109 -0
  226. package/dist/runtime/runtime-helpers.d.ts +51 -0
  227. package/dist/runtime/runtime-helpers.js +230 -0
  228. package/dist/runtime/runtime.d.ts +91 -0
  229. package/dist/runtime/runtime.js +531 -0
  230. package/dist/runtime/server.d.ts +17 -0
  231. package/dist/runtime/server.js +226 -0
  232. package/dist/runtime/sse.d.ts +15 -0
  233. package/dist/runtime/sse.js +96 -0
  234. package/dist/runtime/wake-scheduler.d.ts +8 -0
  235. package/dist/runtime/wake-scheduler.js +38 -0
  236. package/dist/s2/config.d.ts +27 -0
  237. package/dist/s2/config.js +54 -0
  238. package/dist/s2/index.d.ts +6 -0
  239. package/dist/s2/index.js +6 -0
  240. package/dist/s2/lite.d.ts +26 -0
  241. package/dist/s2/lite.js +150 -0
  242. package/dist/s2/projector.d.ts +8 -0
  243. package/dist/s2/projector.js +28 -0
  244. package/dist/s2/serialize.d.ts +1 -0
  245. package/dist/s2/serialize.js +1 -0
  246. package/dist/s2/snapshot-store.d.ts +17 -0
  247. package/dist/s2/snapshot-store.js +320 -0
  248. package/dist/s2/store.d.ts +35 -0
  249. package/dist/s2/store.js +337 -0
  250. package/dist/testing/index.d.ts +11 -0
  251. package/dist/testing/index.js +63 -0
  252. package/dist/workflow/definitions-store.d.ts +11 -0
  253. package/dist/workflow/definitions-store.js +8 -0
  254. package/dist/workflow/definitions.d.ts +82 -0
  255. package/dist/workflow/definitions.js +32 -0
  256. package/dist/workflow/effects.d.ts +305 -0
  257. package/dist/workflow/effects.js +208 -0
  258. package/dist/workflow/events.d.ts +60 -0
  259. package/dist/workflow/events.js +39 -0
  260. package/dist/workflow/index.d.ts +8 -0
  261. package/dist/workflow/index.js +8 -0
  262. package/dist/workflow/module.d.ts +926 -0
  263. package/dist/workflow/module.js +19 -0
  264. package/dist/workflow/projections.d.ts +30 -0
  265. package/dist/workflow/projections.js +43 -0
  266. package/dist/workflow/scope.d.ts +61 -0
  267. package/dist/workflow/scope.js +7 -0
  268. package/dist/workflow/threads.d.ts +171 -0
  269. package/dist/workflow/threads.js +287 -0
  270. package/package.json +183 -0
@@ -0,0 +1,342 @@
1
+ export declare function approval(): import("@swirls/looms/core").RuntimeModule<"approval", import("@swirls/looms/core").EventCatalog<"approval", {
2
+ requested: import("effect/Schema").Struct<{
3
+ readonly approvalId: import("effect/Schema").String;
4
+ readonly title: import("effect/Schema").String;
5
+ readonly description: import("effect/Schema").optional<import("effect/Schema").String>;
6
+ readonly actions: import("effect/Schema").$Array<import("effect/Schema").Struct<{
7
+ readonly id: import("effect/Schema").String;
8
+ readonly label: import("effect/Schema").String;
9
+ readonly outcome: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"approve">, import("effect/Schema").Literal<"reject">]>;
10
+ }>>;
11
+ readonly schema: import("effect/Schema").optional<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>;
12
+ }>;
13
+ decided: import("effect/Schema").Struct<{
14
+ readonly approvalId: import("effect/Schema").String;
15
+ readonly actionId: import("effect/Schema").String;
16
+ readonly outcome: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"approve">, import("effect/Schema").Literal<"reject">]>;
17
+ readonly payload: import("effect/Schema").optional<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>;
18
+ }>;
19
+ timed_out: import("effect/Schema").Struct<{
20
+ readonly approvalId: import("effect/Schema").String;
21
+ }>;
22
+ }>, {
23
+ request: import("@swirls/looms/core").EffectDefinition<{
24
+ readonly approvalId: string;
25
+ readonly title: string;
26
+ readonly description?: string | undefined;
27
+ readonly actions: readonly {
28
+ readonly id: string;
29
+ readonly label: string;
30
+ readonly outcome: "approve" | "reject";
31
+ }[];
32
+ readonly schema?: import("effect/Schema").Json | undefined;
33
+ }, never, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
34
+ readonly type: "approval.decided";
35
+ readonly payload: {
36
+ readonly approvalId: string;
37
+ readonly actionId: string;
38
+ readonly outcome: "approve" | "reject";
39
+ readonly payload?: import("effect/Schema").Json | undefined;
40
+ };
41
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
42
+ readonly type: "approval.requested";
43
+ readonly payload: {
44
+ readonly approvalId: string;
45
+ readonly title: string;
46
+ readonly description?: string | undefined;
47
+ readonly actions: readonly {
48
+ readonly id: string;
49
+ readonly label: string;
50
+ readonly outcome: "approve" | "reject";
51
+ }[];
52
+ readonly schema?: import("effect/Schema").Json | undefined;
53
+ };
54
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
55
+ readonly type: "approval.timed_out";
56
+ readonly payload: {
57
+ readonly approvalId: string;
58
+ };
59
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
60
+ readonly type: "runtime.effect.failed";
61
+ readonly payload: {
62
+ readonly effectId: string;
63
+ readonly error: string;
64
+ };
65
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
66
+ readonly type: "runtime.run.completed";
67
+ readonly payload: {
68
+ readonly output: import("effect/Schema").Json;
69
+ readonly error: string | null;
70
+ };
71
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
72
+ readonly type: "runtime.run.started";
73
+ readonly payload: {
74
+ readonly rootThreadId?: string | undefined;
75
+ readonly kind: string;
76
+ readonly definitionName: string;
77
+ readonly input: import("effect/Schema").Json;
78
+ };
79
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
80
+ readonly type: "runtime.signal.received";
81
+ readonly payload: {
82
+ readonly signalType: string;
83
+ };
84
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
85
+ readonly type: "runtime.snapshot.taken";
86
+ readonly payload: {
87
+ readonly seq: number;
88
+ readonly stateHash: string;
89
+ readonly state?: import("effect/Schema").Json | undefined;
90
+ };
91
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
92
+ readonly type: "runtime.thread.cancelled";
93
+ readonly payload: {
94
+ readonly threadId: string;
95
+ readonly reason?: string | undefined;
96
+ };
97
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
98
+ readonly type: "runtime.thread.completed";
99
+ readonly payload: {
100
+ readonly threadId: string;
101
+ readonly output: import("effect/Schema").Json;
102
+ };
103
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
104
+ readonly type: "runtime.thread.failed";
105
+ readonly payload: {
106
+ readonly threadId: string;
107
+ readonly error: string;
108
+ };
109
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
110
+ readonly type: "runtime.thread.started";
111
+ readonly payload: {
112
+ readonly threadId: string;
113
+ readonly kind: string;
114
+ readonly definitionName: string;
115
+ readonly input: import("effect/Schema").Json;
116
+ readonly parentThreadId: string | null;
117
+ };
118
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
119
+ readonly type: "runtime.timer.fired";
120
+ readonly payload: {
121
+ readonly timerId: string;
122
+ readonly waitId: string;
123
+ };
124
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
125
+ readonly type: "runtime.timer.set";
126
+ readonly payload: {
127
+ readonly timerId: string;
128
+ readonly waitId: string;
129
+ readonly wakeAt: number;
130
+ };
131
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
132
+ readonly type: "runtime.wait.registered";
133
+ readonly payload: {
134
+ readonly waitId: string;
135
+ readonly threadId?: string | undefined;
136
+ readonly on: {
137
+ readonly type: string | readonly string[];
138
+ readonly match?: import("effect/Schema").Json | undefined;
139
+ } | {
140
+ readonly timerAt: number;
141
+ };
142
+ readonly tag?: import("effect/Schema").Json | undefined;
143
+ };
144
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
145
+ readonly type: "runtime.wait.satisfied";
146
+ readonly payload: {
147
+ readonly waitId: string;
148
+ readonly tag?: import("effect/Schema").Json | undefined;
149
+ readonly event: {
150
+ readonly id: string;
151
+ readonly type: string;
152
+ readonly payload: import("effect/Schema").Json;
153
+ };
154
+ };
155
+ })>;
156
+ }, {}, {
157
+ pendingApprovals: import("@swirls/looms/core").ProjectionDefinition<{
158
+ readonly items: {
159
+ readonly approvalId: string;
160
+ readonly title: string;
161
+ readonly description?: string | undefined;
162
+ readonly status: "approved" | "pending" | "rejected" | "timed_out";
163
+ readonly threadId: string | null;
164
+ }[];
165
+ } | {
166
+ items: ({
167
+ readonly approvalId: string;
168
+ readonly title: string;
169
+ readonly description?: string | undefined;
170
+ readonly status: "approved" | "pending" | "rejected" | "timed_out";
171
+ readonly threadId: string | null;
172
+ } | {
173
+ approvalId: string;
174
+ title: string;
175
+ description?: string | undefined;
176
+ threadId: string | null;
177
+ status: string;
178
+ })[];
179
+ }>;
180
+ }, any> & {
181
+ readonly effects: {
182
+ request: import("@swirls/looms/core").EffectDefinition<{
183
+ readonly approvalId: string;
184
+ readonly title: string;
185
+ readonly description?: string | undefined;
186
+ readonly actions: readonly {
187
+ readonly id: string;
188
+ readonly label: string;
189
+ readonly outcome: "approve" | "reject";
190
+ }[];
191
+ readonly schema?: import("effect/Schema").Json | undefined;
192
+ }, never, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
193
+ readonly type: "approval.decided";
194
+ readonly payload: {
195
+ readonly approvalId: string;
196
+ readonly actionId: string;
197
+ readonly outcome: "approve" | "reject";
198
+ readonly payload?: import("effect/Schema").Json | undefined;
199
+ };
200
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
201
+ readonly type: "approval.requested";
202
+ readonly payload: {
203
+ readonly approvalId: string;
204
+ readonly title: string;
205
+ readonly description?: string | undefined;
206
+ readonly actions: readonly {
207
+ readonly id: string;
208
+ readonly label: string;
209
+ readonly outcome: "approve" | "reject";
210
+ }[];
211
+ readonly schema?: import("effect/Schema").Json | undefined;
212
+ };
213
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
214
+ readonly type: "approval.timed_out";
215
+ readonly payload: {
216
+ readonly approvalId: string;
217
+ };
218
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
219
+ readonly type: "runtime.effect.failed";
220
+ readonly payload: {
221
+ readonly effectId: string;
222
+ readonly error: string;
223
+ };
224
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
225
+ readonly type: "runtime.run.completed";
226
+ readonly payload: {
227
+ readonly output: import("effect/Schema").Json;
228
+ readonly error: string | null;
229
+ };
230
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
231
+ readonly type: "runtime.run.started";
232
+ readonly payload: {
233
+ readonly rootThreadId?: string | undefined;
234
+ readonly kind: string;
235
+ readonly definitionName: string;
236
+ readonly input: import("effect/Schema").Json;
237
+ };
238
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
239
+ readonly type: "runtime.signal.received";
240
+ readonly payload: {
241
+ readonly signalType: string;
242
+ };
243
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
244
+ readonly type: "runtime.snapshot.taken";
245
+ readonly payload: {
246
+ readonly seq: number;
247
+ readonly stateHash: string;
248
+ readonly state?: import("effect/Schema").Json | undefined;
249
+ };
250
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
251
+ readonly type: "runtime.thread.cancelled";
252
+ readonly payload: {
253
+ readonly threadId: string;
254
+ readonly reason?: string | undefined;
255
+ };
256
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
257
+ readonly type: "runtime.thread.completed";
258
+ readonly payload: {
259
+ readonly threadId: string;
260
+ readonly output: import("effect/Schema").Json;
261
+ };
262
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
263
+ readonly type: "runtime.thread.failed";
264
+ readonly payload: {
265
+ readonly threadId: string;
266
+ readonly error: string;
267
+ };
268
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
269
+ readonly type: "runtime.thread.started";
270
+ readonly payload: {
271
+ readonly threadId: string;
272
+ readonly kind: string;
273
+ readonly definitionName: string;
274
+ readonly input: import("effect/Schema").Json;
275
+ readonly parentThreadId: string | null;
276
+ };
277
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
278
+ readonly type: "runtime.timer.fired";
279
+ readonly payload: {
280
+ readonly timerId: string;
281
+ readonly waitId: string;
282
+ };
283
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
284
+ readonly type: "runtime.timer.set";
285
+ readonly payload: {
286
+ readonly timerId: string;
287
+ readonly waitId: string;
288
+ readonly wakeAt: number;
289
+ };
290
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
291
+ readonly type: "runtime.wait.registered";
292
+ readonly payload: {
293
+ readonly waitId: string;
294
+ readonly threadId?: string | undefined;
295
+ readonly on: {
296
+ readonly type: string | readonly string[];
297
+ readonly match?: import("effect/Schema").Json | undefined;
298
+ } | {
299
+ readonly timerAt: number;
300
+ };
301
+ readonly tag?: import("effect/Schema").Json | undefined;
302
+ };
303
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
304
+ readonly type: "runtime.wait.satisfied";
305
+ readonly payload: {
306
+ readonly waitId: string;
307
+ readonly tag?: import("effect/Schema").Json | undefined;
308
+ readonly event: {
309
+ readonly id: string;
310
+ readonly type: string;
311
+ readonly payload: import("effect/Schema").Json;
312
+ };
313
+ };
314
+ })>;
315
+ };
316
+ readonly threads: {};
317
+ readonly projections: {
318
+ pendingApprovals: import("@swirls/looms/core").ProjectionDefinition<{
319
+ readonly items: {
320
+ readonly approvalId: string;
321
+ readonly title: string;
322
+ readonly description?: string | undefined;
323
+ readonly status: "approved" | "pending" | "rejected" | "timed_out";
324
+ readonly threadId: string | null;
325
+ }[];
326
+ } | {
327
+ items: ({
328
+ readonly approvalId: string;
329
+ readonly title: string;
330
+ readonly description?: string | undefined;
331
+ readonly status: "approved" | "pending" | "rejected" | "timed_out";
332
+ readonly threadId: string | null;
333
+ } | {
334
+ approvalId: string;
335
+ title: string;
336
+ description?: string | undefined;
337
+ threadId: string | null;
338
+ status: string;
339
+ })[];
340
+ }>;
341
+ };
342
+ };
@@ -0,0 +1,10 @@
1
+ import { defineModule } from '@swirls/looms/core';
2
+ import { requestApprovalEffect } from './effects.js';
3
+ import { pendingApprovals } from './projections.js';
4
+ import { approvalModule } from './scope.js';
5
+ export function approval() {
6
+ return defineModule(approvalModule, () => ({
7
+ effects: { request: requestApprovalEffect },
8
+ projections: { pendingApprovals },
9
+ }));
10
+ }
@@ -0,0 +1,42 @@
1
+ import { Schema } from 'effect';
2
+ export declare const PendingApprovalSchema: Schema.Struct<{
3
+ readonly approvalId: Schema.String;
4
+ readonly title: Schema.String;
5
+ readonly description: Schema.optional<Schema.String>;
6
+ readonly status: Schema.Union<readonly [Schema.Literal<"pending">, Schema.Literal<"approved">, Schema.Literal<"rejected">, Schema.Literal<"timed_out">]>;
7
+ readonly threadId: Schema.NullOr<Schema.String>;
8
+ }>;
9
+ export type PendingApproval = Schema.Schema.Type<typeof PendingApprovalSchema>;
10
+ export declare const PendingApprovalsSchema: Schema.Struct<{
11
+ readonly items: Schema.mutable<Schema.$Array<Schema.Struct<{
12
+ readonly approvalId: Schema.String;
13
+ readonly title: Schema.String;
14
+ readonly description: Schema.optional<Schema.String>;
15
+ readonly status: Schema.Union<readonly [Schema.Literal<"pending">, Schema.Literal<"approved">, Schema.Literal<"rejected">, Schema.Literal<"timed_out">]>;
16
+ readonly threadId: Schema.NullOr<Schema.String>;
17
+ }>>>;
18
+ }>;
19
+ export type PendingApprovalsState = Schema.Schema.Type<typeof PendingApprovalsSchema>;
20
+ export declare const pendingApprovals: import("@swirls/looms/core").ProjectionDefinition<{
21
+ readonly items: {
22
+ readonly approvalId: string;
23
+ readonly title: string;
24
+ readonly description?: string | undefined;
25
+ readonly status: "approved" | "pending" | "rejected" | "timed_out";
26
+ readonly threadId: string | null;
27
+ }[];
28
+ } | {
29
+ items: ({
30
+ readonly approvalId: string;
31
+ readonly title: string;
32
+ readonly description?: string | undefined;
33
+ readonly status: "approved" | "pending" | "rejected" | "timed_out";
34
+ readonly threadId: string | null;
35
+ } | {
36
+ approvalId: string;
37
+ title: string;
38
+ description?: string | undefined;
39
+ threadId: string | null;
40
+ status: string;
41
+ })[];
42
+ }>;
@@ -0,0 +1,57 @@
1
+ import { Schema } from 'effect';
2
+ import { approvalModule } from './scope.js';
3
+ export const PendingApprovalSchema = Schema.Struct({
4
+ approvalId: Schema.String,
5
+ title: Schema.String,
6
+ description: Schema.optional(Schema.String),
7
+ status: Schema.Union([
8
+ Schema.Literal('pending'),
9
+ Schema.Literal('approved'),
10
+ Schema.Literal('rejected'),
11
+ Schema.Literal('timed_out'),
12
+ ]),
13
+ threadId: Schema.NullOr(Schema.String),
14
+ });
15
+ export const PendingApprovalsSchema = Schema.Struct({
16
+ items: Schema.mutable(Schema.Array(PendingApprovalSchema)),
17
+ });
18
+ export const pendingApprovals = approvalModule.projection({
19
+ name: 'pendingApprovals',
20
+ shape: PendingApprovalsSchema,
21
+ initialState: { items: [] },
22
+ reduce(state, event) {
23
+ switch (event.type) {
24
+ case 'approval.requested': {
25
+ const { approvalId, title, description } = event.payload;
26
+ const threadId = event.threadId ?? null;
27
+ return {
28
+ items: [
29
+ ...state.items.filter((item) => item.approvalId !== approvalId),
30
+ {
31
+ approvalId,
32
+ title: title || 'Approval',
33
+ description: description || undefined,
34
+ status: 'pending',
35
+ threadId,
36
+ },
37
+ ],
38
+ };
39
+ }
40
+ case 'approval.decided': {
41
+ const { approvalId, outcome } = event.payload;
42
+ const status = outcome === 'reject' ? 'rejected' : 'approved';
43
+ return {
44
+ items: state.items.map((item) => item.approvalId === approvalId ? { ...item, status } : item),
45
+ };
46
+ }
47
+ case 'approval.timed_out': {
48
+ const { approvalId } = event.payload;
49
+ return {
50
+ items: state.items.map((item) => item.approvalId === approvalId ? { ...item, status: 'timed_out' } : item),
51
+ };
52
+ }
53
+ default:
54
+ return state;
55
+ }
56
+ },
57
+ });
@@ -0,0 +1,45 @@
1
+ import { type EventOf } from '@swirls/looms/core';
2
+ export declare const approvalModule: import("@swirls/looms/core").ModuleScope<"approval", import("@swirls/looms/core").ScopeUniverse<import("@swirls/looms/core").EventCatalog<"approval", {
3
+ requested: import("effect/Schema").Struct<{
4
+ readonly approvalId: import("effect/Schema").String;
5
+ readonly title: import("effect/Schema").String;
6
+ readonly description: import("effect/Schema").optional<import("effect/Schema").String>;
7
+ readonly actions: import("effect/Schema").$Array<import("effect/Schema").Struct<{
8
+ readonly id: import("effect/Schema").String;
9
+ readonly label: import("effect/Schema").String;
10
+ readonly outcome: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"approve">, import("effect/Schema").Literal<"reject">]>;
11
+ }>>;
12
+ readonly schema: import("effect/Schema").optional<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>;
13
+ }>;
14
+ decided: import("effect/Schema").Struct<{
15
+ readonly approvalId: import("effect/Schema").String;
16
+ readonly actionId: import("effect/Schema").String;
17
+ readonly outcome: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"approve">, import("effect/Schema").Literal<"reject">]>;
18
+ readonly payload: import("effect/Schema").optional<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>;
19
+ }>;
20
+ timed_out: import("effect/Schema").Struct<{
21
+ readonly approvalId: import("effect/Schema").String;
22
+ }>;
23
+ }>, undefined>, import("@swirls/looms/core").EventCatalog<"approval", {
24
+ requested: import("effect/Schema").Struct<{
25
+ readonly approvalId: import("effect/Schema").String;
26
+ readonly title: import("effect/Schema").String;
27
+ readonly description: import("effect/Schema").optional<import("effect/Schema").String>;
28
+ readonly actions: import("effect/Schema").$Array<import("effect/Schema").Struct<{
29
+ readonly id: import("effect/Schema").String;
30
+ readonly label: import("effect/Schema").String;
31
+ readonly outcome: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"approve">, import("effect/Schema").Literal<"reject">]>;
32
+ }>>;
33
+ readonly schema: import("effect/Schema").optional<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>;
34
+ }>;
35
+ decided: import("effect/Schema").Struct<{
36
+ readonly approvalId: import("effect/Schema").String;
37
+ readonly actionId: import("effect/Schema").String;
38
+ readonly outcome: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"approve">, import("effect/Schema").Literal<"reject">]>;
39
+ readonly payload: import("effect/Schema").optional<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>;
40
+ }>;
41
+ timed_out: import("effect/Schema").Struct<{
42
+ readonly approvalId: import("effect/Schema").String;
43
+ }>;
44
+ }>, undefined>;
45
+ export type ApprovalEvent = EventOf<typeof approvalModule>;
@@ -0,0 +1,7 @@
1
+ import { createModuleScope } from '@swirls/looms/core';
2
+ import { approvalCatalog } from './events.js';
3
+ export const approvalModule = createModuleScope({
4
+ namespace: 'approval',
5
+ protocolVersion: '1.0.0',
6
+ events: approvalCatalog,
7
+ });
@@ -0,0 +1,19 @@
1
+ import { type EventInput, type JsonValue, type RuntimeEffect } from '@swirls/looms/core';
2
+ import type { ApprovalAction } from './events';
3
+ export declare function gate(args: {
4
+ title: string;
5
+ description?: string;
6
+ approvalId?: string;
7
+ actions?: ApprovalAction[];
8
+ schema?: JsonValue;
9
+ }): RuntimeEffect[];
10
+ export type ApprovalChoice = 'approve' | 'reject' | {
11
+ actionId: string;
12
+ outcome: 'approve' | 'reject';
13
+ payload?: JsonValue;
14
+ };
15
+ /**
16
+ * Build the `approval.decided` event that resolves a pending gate.
17
+ * Send it with `looms.signal(runId, [decision(approvalId, 'approve')])`.
18
+ */
19
+ export declare function decision(approvalId: string, choice: ApprovalChoice): EventInput;
@@ -0,0 +1,34 @@
1
+ import { createWaitId, invoke, isJsonString, wait, } from '@swirls/looms/core';
2
+ import { requestApprovalEffect } from './effects.js';
3
+ import { approvalModule } from './scope.js';
4
+ export function gate(args) {
5
+ const approvalId = args.approvalId ?? createWaitId('approval');
6
+ const actions = args.actions ?? [
7
+ { id: 'approve', label: 'Approve', outcome: 'approve' },
8
+ { id: 'reject', label: 'Reject', outcome: 'reject' },
9
+ ];
10
+ return [
11
+ invoke(requestApprovalEffect, {
12
+ approvalId,
13
+ title: args.title,
14
+ description: args.description,
15
+ actions,
16
+ schema: args.schema,
17
+ }, `request_${approvalId}`),
18
+ wait({
19
+ waitId: createWaitId(approvalId, 'decision'),
20
+ on: { type: 'approval.decided', match: { approvalId } },
21
+ tag: { approvalId },
22
+ }),
23
+ ];
24
+ }
25
+ /**
26
+ * Build the `approval.decided` event that resolves a pending gate.
27
+ * Send it with `looms.signal(runId, [decision(approvalId, 'approve')])`.
28
+ */
29
+ export function decision(approvalId, choice) {
30
+ const decided = isJsonString(choice)
31
+ ? { approvalId, actionId: choice, outcome: choice }
32
+ : { approvalId, actionId: choice.actionId, outcome: choice.outcome, payload: choice.payload };
33
+ return approvalModule.input('decided', decided);
34
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bun
2
+ export {};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bun
2
+ import { BunRuntime, BunServices } from '@effect/platform-bun';
3
+ import { Effect } from 'effect';
4
+ import { Command } from 'effect/unstable/cli';
5
+ import { looms, VERSION } from './commands.js';
6
+ looms.pipe(Command.run({ version: VERSION }), Effect.provide(BunServices.layer), BunRuntime.runMain);
@@ -0,0 +1,13 @@
1
+ import { Effect, FileSystem, Layer, Path, Stdio, Terminal } from 'effect';
2
+ import { CliError, Command } from 'effect/unstable/cli';
3
+ import { ChildProcessSpawner } from 'effect/unstable/process';
4
+ declare const VERSION = "0.0.1";
5
+ export declare const looms: Command.Command<"looms", {
6
+ readonly url: string;
7
+ }, {
8
+ readonly url: string;
9
+ }, CliError.UserError, never>;
10
+ export declare const cliTestLayer: Layer.Layer<ChildProcessSpawner.ChildProcessSpawner | FileSystem.FileSystem | Path.Path | Stdio.Stdio | Terminal.Terminal, never, never>;
11
+ /** Run the CLI with an explicit argv (for tests and programmatic use). */
12
+ export declare const runCli: (argv: ReadonlyArray<string>) => Effect.Effect<void, CliError.CliError, Command.Environment>;
13
+ export { VERSION };