@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,74 @@
1
+ export function normalizeTools(tools = []) {
2
+ return tools.map((entry) => {
3
+ if (entry.kind === 'function' || entry.kind === 'thread' || entry.kind === 'effects') {
4
+ // SAFETY: kind discriminant matches ToolLike.
5
+ return entry;
6
+ }
7
+ return asThreadTool({
8
+ child: { kind: entry.kind, name: entry.name },
9
+ description: 'instructions' in entry && entry.instructions
10
+ ? entry.instructions
11
+ : 'description' in entry && entry.description
12
+ ? entry.description
13
+ : entry.name,
14
+ input: 'input' in entry ? entry.input : undefined,
15
+ });
16
+ });
17
+ }
18
+ export function defineTool(def) {
19
+ // SAFETY: factory fields match FunctionTool.
20
+ return { kind: 'function', ...def, input: def.input };
21
+ }
22
+ export function defineAgent(def) {
23
+ // SAFETY: factory fields match AgentDefinition.
24
+ return {
25
+ kind: 'agent',
26
+ ...def,
27
+ input: def.input,
28
+ tools: def.tools ? normalizeTools(def.tools) : undefined,
29
+ };
30
+ }
31
+ export function asThreadTool(def) {
32
+ return {
33
+ kind: 'thread',
34
+ name: def.name ?? def.child.name,
35
+ description: def.description ?? def.child.name,
36
+ input: def.input,
37
+ inputSchema: def.inputSchema,
38
+ childKind: def.child.kind,
39
+ childName: def.child.name,
40
+ child: def.child,
41
+ mapInput: def.mapInput,
42
+ };
43
+ }
44
+ export function asAgentTool(def) {
45
+ return asThreadTool({
46
+ name: def.name,
47
+ description: def.description ?? def.agent.instructions,
48
+ input: def.input ?? def.agent.input,
49
+ inputSchema: def.inputSchema ?? def.agent.inputSchema,
50
+ child: { kind: 'agent', name: def.agent.name },
51
+ mapInput: def.mapInput,
52
+ });
53
+ }
54
+ export function asWorkflowTool(def) {
55
+ return asThreadTool({
56
+ name: def.name,
57
+ description: def.description ?? def.workflow.description,
58
+ input: def.input ?? def.workflow.input,
59
+ inputSchema: def.inputSchema ?? def.workflow.inputSchema,
60
+ child: { kind: 'workflow', name: def.workflow.name },
61
+ mapInput: def.mapInput,
62
+ });
63
+ }
64
+ export function asEffectsTool(def) {
65
+ return {
66
+ kind: 'effects',
67
+ name: def.name,
68
+ description: def.description,
69
+ input: def.input,
70
+ inputSchema: def.inputSchema,
71
+ effects: def.effects,
72
+ waitOn: def.waitOn,
73
+ };
74
+ }
@@ -0,0 +1,425 @@
1
+ import { Schema } from 'effect';
2
+ import { type JsonValue } from '@swirls/looms/core';
3
+ import { AgentDefinitionsTag } from './definitions-store';
4
+ import { LlmTag } from './llm';
5
+ import { type ToolCall } from './types';
6
+ export declare const callLlmEffect: NoInfer<import("@swirls/looms/core").EffectDefinition<{
7
+ readonly turn: number;
8
+ readonly definitionName?: string | undefined;
9
+ readonly messages?: readonly {
10
+ readonly role: "assistant" | "system" | "tool" | "user";
11
+ readonly content: string;
12
+ readonly toolCallId?: string | undefined;
13
+ readonly name?: string | undefined;
14
+ readonly toolCalls?: {
15
+ readonly id: string;
16
+ readonly name: string;
17
+ readonly arguments: Schema.Json;
18
+ }[] | undefined;
19
+ }[] | undefined;
20
+ readonly input?: Schema.Json | undefined;
21
+ }, AgentDefinitionsTag | LlmTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
22
+ readonly type: "agent.effects.requested";
23
+ readonly payload: {
24
+ readonly toolCallId: string;
25
+ readonly effects: readonly import("@swirls/looms/core").RuntimeEffect[];
26
+ readonly waitOn?: {
27
+ readonly type: string | readonly string[];
28
+ readonly match?: Schema.Json | undefined;
29
+ } | undefined;
30
+ };
31
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
32
+ readonly type: "agent.message";
33
+ readonly payload: {
34
+ readonly turn: number;
35
+ readonly message: {
36
+ readonly role: "assistant" | "system" | "tool" | "user";
37
+ readonly content: string;
38
+ readonly toolCallId?: string | undefined;
39
+ readonly name?: string | undefined;
40
+ readonly toolCalls?: {
41
+ readonly id: string;
42
+ readonly name: string;
43
+ readonly arguments: Schema.Json;
44
+ }[] | undefined;
45
+ };
46
+ readonly usage?: {
47
+ readonly input: number;
48
+ readonly output: number;
49
+ } | undefined;
50
+ };
51
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
52
+ readonly type: "agent.message.received";
53
+ readonly payload: {
54
+ readonly message: {
55
+ readonly role: "assistant" | "system" | "tool" | "user";
56
+ readonly content: string;
57
+ readonly toolCallId?: string | undefined;
58
+ readonly name?: string | undefined;
59
+ readonly toolCalls?: {
60
+ readonly id: string;
61
+ readonly name: string;
62
+ readonly arguments: Schema.Json;
63
+ }[] | undefined;
64
+ };
65
+ };
66
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
67
+ readonly type: "agent.spawn.requested";
68
+ readonly payload: {
69
+ readonly childThreadId: string;
70
+ readonly kind: string;
71
+ readonly definitionName: string;
72
+ readonly toolCallId: string;
73
+ readonly input: Schema.Json;
74
+ };
75
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
76
+ readonly type: "agent.steered";
77
+ readonly payload: {
78
+ readonly turn: number;
79
+ readonly message: {
80
+ readonly role: "assistant" | "system" | "tool" | "user";
81
+ readonly content: string;
82
+ readonly toolCallId?: string | undefined;
83
+ readonly name?: string | undefined;
84
+ readonly toolCalls?: {
85
+ readonly id: string;
86
+ readonly name: string;
87
+ readonly arguments: Schema.Json;
88
+ }[] | undefined;
89
+ };
90
+ readonly interrupt?: boolean | undefined;
91
+ };
92
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
93
+ readonly type: "agent.tool.result";
94
+ readonly payload: {
95
+ readonly turn: number;
96
+ readonly toolCallId: string;
97
+ readonly name: string;
98
+ readonly result: Schema.Json;
99
+ readonly error: string | null;
100
+ };
101
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
102
+ readonly type: "agent.tool_call.requested";
103
+ readonly payload: {
104
+ readonly turn: number;
105
+ readonly toolCall: {
106
+ readonly id: string;
107
+ readonly name: string;
108
+ readonly arguments: Schema.Json;
109
+ };
110
+ };
111
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
112
+ readonly type: "agent.turn.started";
113
+ readonly payload: {
114
+ readonly turn: number;
115
+ };
116
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
117
+ readonly type: "agent.turn.text_delta";
118
+ readonly payload: {
119
+ readonly turn: number;
120
+ readonly delta: string;
121
+ };
122
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
123
+ readonly type: "runtime.effect.failed";
124
+ readonly payload: {
125
+ readonly effectId: string;
126
+ readonly error: string;
127
+ };
128
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
129
+ readonly type: "runtime.run.completed";
130
+ readonly payload: {
131
+ readonly output: Schema.Json;
132
+ readonly error: string | null;
133
+ };
134
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
135
+ readonly type: "runtime.run.started";
136
+ readonly payload: {
137
+ readonly rootThreadId?: string | undefined;
138
+ readonly kind: string;
139
+ readonly definitionName: string;
140
+ readonly input: Schema.Json;
141
+ };
142
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
143
+ readonly type: "runtime.signal.received";
144
+ readonly payload: {
145
+ readonly signalType: string;
146
+ };
147
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
148
+ readonly type: "runtime.snapshot.taken";
149
+ readonly payload: {
150
+ readonly seq: number;
151
+ readonly stateHash: string;
152
+ readonly state?: Schema.Json | undefined;
153
+ };
154
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
155
+ readonly type: "runtime.thread.cancelled";
156
+ readonly payload: {
157
+ readonly threadId: string;
158
+ readonly reason?: string | undefined;
159
+ };
160
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
161
+ readonly type: "runtime.thread.completed";
162
+ readonly payload: {
163
+ readonly threadId: string;
164
+ readonly output: Schema.Json;
165
+ };
166
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
167
+ readonly type: "runtime.thread.failed";
168
+ readonly payload: {
169
+ readonly threadId: string;
170
+ readonly error: string;
171
+ };
172
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
173
+ readonly type: "runtime.thread.started";
174
+ readonly payload: {
175
+ readonly threadId: string;
176
+ readonly kind: string;
177
+ readonly definitionName: string;
178
+ readonly input: Schema.Json;
179
+ readonly parentThreadId: string | null;
180
+ };
181
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
182
+ readonly type: "runtime.timer.fired";
183
+ readonly payload: {
184
+ readonly timerId: string;
185
+ readonly waitId: string;
186
+ };
187
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
188
+ readonly type: "runtime.timer.set";
189
+ readonly payload: {
190
+ readonly timerId: string;
191
+ readonly waitId: string;
192
+ readonly wakeAt: number;
193
+ };
194
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
195
+ readonly type: "runtime.wait.registered";
196
+ readonly payload: {
197
+ readonly waitId: string;
198
+ readonly threadId?: string | undefined;
199
+ readonly on: {
200
+ readonly type: string | readonly string[];
201
+ readonly match?: Schema.Json | undefined;
202
+ } | {
203
+ readonly timerAt: number;
204
+ };
205
+ readonly tag?: Schema.Json | undefined;
206
+ };
207
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
208
+ readonly type: "runtime.wait.satisfied";
209
+ readonly payload: {
210
+ readonly waitId: string;
211
+ readonly tag?: Schema.Json | undefined;
212
+ readonly event: {
213
+ readonly id: string;
214
+ readonly type: string;
215
+ readonly payload: Schema.Json;
216
+ };
217
+ };
218
+ })>>;
219
+ export declare const executeToolEffect: NoInfer<import("@swirls/looms/core").EffectDefinition<{
220
+ readonly turn: number;
221
+ readonly definitionName?: string | undefined;
222
+ readonly toolCall: {
223
+ readonly id: string;
224
+ readonly name: string;
225
+ readonly arguments: Schema.Json;
226
+ };
227
+ }, AgentDefinitionsTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
228
+ readonly type: "agent.effects.requested";
229
+ readonly payload: {
230
+ readonly toolCallId: string;
231
+ readonly effects: readonly import("@swirls/looms/core").RuntimeEffect[];
232
+ readonly waitOn?: {
233
+ readonly type: string | readonly string[];
234
+ readonly match?: Schema.Json | undefined;
235
+ } | undefined;
236
+ };
237
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
238
+ readonly type: "agent.message";
239
+ readonly payload: {
240
+ readonly turn: number;
241
+ readonly message: {
242
+ readonly role: "assistant" | "system" | "tool" | "user";
243
+ readonly content: string;
244
+ readonly toolCallId?: string | undefined;
245
+ readonly name?: string | undefined;
246
+ readonly toolCalls?: {
247
+ readonly id: string;
248
+ readonly name: string;
249
+ readonly arguments: Schema.Json;
250
+ }[] | undefined;
251
+ };
252
+ readonly usage?: {
253
+ readonly input: number;
254
+ readonly output: number;
255
+ } | undefined;
256
+ };
257
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
258
+ readonly type: "agent.message.received";
259
+ readonly payload: {
260
+ readonly message: {
261
+ readonly role: "assistant" | "system" | "tool" | "user";
262
+ readonly content: string;
263
+ readonly toolCallId?: string | undefined;
264
+ readonly name?: string | undefined;
265
+ readonly toolCalls?: {
266
+ readonly id: string;
267
+ readonly name: string;
268
+ readonly arguments: Schema.Json;
269
+ }[] | undefined;
270
+ };
271
+ };
272
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
273
+ readonly type: "agent.spawn.requested";
274
+ readonly payload: {
275
+ readonly childThreadId: string;
276
+ readonly kind: string;
277
+ readonly definitionName: string;
278
+ readonly toolCallId: string;
279
+ readonly input: Schema.Json;
280
+ };
281
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
282
+ readonly type: "agent.steered";
283
+ readonly payload: {
284
+ readonly turn: number;
285
+ readonly message: {
286
+ readonly role: "assistant" | "system" | "tool" | "user";
287
+ readonly content: string;
288
+ readonly toolCallId?: string | undefined;
289
+ readonly name?: string | undefined;
290
+ readonly toolCalls?: {
291
+ readonly id: string;
292
+ readonly name: string;
293
+ readonly arguments: Schema.Json;
294
+ }[] | undefined;
295
+ };
296
+ readonly interrupt?: boolean | undefined;
297
+ };
298
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
299
+ readonly type: "agent.tool.result";
300
+ readonly payload: {
301
+ readonly turn: number;
302
+ readonly toolCallId: string;
303
+ readonly name: string;
304
+ readonly result: Schema.Json;
305
+ readonly error: string | null;
306
+ };
307
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
308
+ readonly type: "agent.tool_call.requested";
309
+ readonly payload: {
310
+ readonly turn: number;
311
+ readonly toolCall: {
312
+ readonly id: string;
313
+ readonly name: string;
314
+ readonly arguments: Schema.Json;
315
+ };
316
+ };
317
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
318
+ readonly type: "agent.turn.started";
319
+ readonly payload: {
320
+ readonly turn: number;
321
+ };
322
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
323
+ readonly type: "agent.turn.text_delta";
324
+ readonly payload: {
325
+ readonly turn: number;
326
+ readonly delta: string;
327
+ };
328
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
329
+ readonly type: "runtime.effect.failed";
330
+ readonly payload: {
331
+ readonly effectId: string;
332
+ readonly error: string;
333
+ };
334
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
335
+ readonly type: "runtime.run.completed";
336
+ readonly payload: {
337
+ readonly output: Schema.Json;
338
+ readonly error: string | null;
339
+ };
340
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
341
+ readonly type: "runtime.run.started";
342
+ readonly payload: {
343
+ readonly rootThreadId?: string | undefined;
344
+ readonly kind: string;
345
+ readonly definitionName: string;
346
+ readonly input: Schema.Json;
347
+ };
348
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
349
+ readonly type: "runtime.signal.received";
350
+ readonly payload: {
351
+ readonly signalType: string;
352
+ };
353
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
354
+ readonly type: "runtime.snapshot.taken";
355
+ readonly payload: {
356
+ readonly seq: number;
357
+ readonly stateHash: string;
358
+ readonly state?: Schema.Json | undefined;
359
+ };
360
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
361
+ readonly type: "runtime.thread.cancelled";
362
+ readonly payload: {
363
+ readonly threadId: string;
364
+ readonly reason?: string | undefined;
365
+ };
366
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
367
+ readonly type: "runtime.thread.completed";
368
+ readonly payload: {
369
+ readonly threadId: string;
370
+ readonly output: Schema.Json;
371
+ };
372
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
373
+ readonly type: "runtime.thread.failed";
374
+ readonly payload: {
375
+ readonly threadId: string;
376
+ readonly error: string;
377
+ };
378
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
379
+ readonly type: "runtime.thread.started";
380
+ readonly payload: {
381
+ readonly threadId: string;
382
+ readonly kind: string;
383
+ readonly definitionName: string;
384
+ readonly input: Schema.Json;
385
+ readonly parentThreadId: string | null;
386
+ };
387
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
388
+ readonly type: "runtime.timer.fired";
389
+ readonly payload: {
390
+ readonly timerId: string;
391
+ readonly waitId: string;
392
+ };
393
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
394
+ readonly type: "runtime.timer.set";
395
+ readonly payload: {
396
+ readonly timerId: string;
397
+ readonly waitId: string;
398
+ readonly wakeAt: number;
399
+ };
400
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
401
+ readonly type: "runtime.wait.registered";
402
+ readonly payload: {
403
+ readonly waitId: string;
404
+ readonly threadId?: string | undefined;
405
+ readonly on: {
406
+ readonly type: string | readonly string[];
407
+ readonly match?: Schema.Json | undefined;
408
+ } | {
409
+ readonly timerAt: number;
410
+ };
411
+ readonly tag?: Schema.Json | undefined;
412
+ };
413
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
414
+ readonly type: "runtime.wait.satisfied";
415
+ readonly payload: {
416
+ readonly waitId: string;
417
+ readonly tag?: Schema.Json | undefined;
418
+ readonly event: {
419
+ readonly id: string;
420
+ readonly type: string;
421
+ readonly payload: Schema.Json;
422
+ };
423
+ };
424
+ })>>;
425
+ export declare function readToolCall(value: JsonValue): ToolCall | null;