@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.
- package/LICENSE +190 -0
- package/README.md +9 -0
- package/dist/actor/cell.d.ts +27 -0
- package/dist/actor/cell.js +41 -0
- package/dist/actor/host.d.ts +27 -0
- package/dist/actor/host.js +82 -0
- package/dist/actor/index.d.ts +3 -0
- package/dist/actor/index.js +3 -0
- package/dist/actor/routing.d.ts +15 -0
- package/dist/actor/routing.js +80 -0
- package/dist/agent/definitions-store.d.ts +11 -0
- package/dist/agent/definitions-store.js +10 -0
- package/dist/agent/definitions.d.ts +152 -0
- package/dist/agent/definitions.js +74 -0
- package/dist/agent/effects.d.ts +425 -0
- package/dist/agent/effects.js +318 -0
- package/dist/agent/events.d.ts +170 -0
- package/dist/agent/events.js +61 -0
- package/dist/agent/index.d.ts +13 -0
- package/dist/agent/index.js +13 -0
- package/dist/agent/llm.d.ts +35 -0
- package/dist/agent/llm.js +48 -0
- package/dist/agent/module.d.ts +1037 -0
- package/dist/agent/module.js +27 -0
- package/dist/agent/projections.d.ts +17 -0
- package/dist/agent/projections.js +81 -0
- package/dist/agent/scope.d.ts +171 -0
- package/dist/agent/scope.js +7 -0
- package/dist/agent/signals.d.ts +17 -0
- package/dist/agent/signals.js +19 -0
- package/dist/agent/stop-when.d.ts +12 -0
- package/dist/agent/stop-when.js +6 -0
- package/dist/agent/threads.d.ts +34 -0
- package/dist/agent/threads.js +407 -0
- package/dist/agent/tool-schema.d.ts +21 -0
- package/dist/agent/tool-schema.js +67 -0
- package/dist/agent/types.d.ts +87 -0
- package/dist/agent/types.js +32 -0
- package/dist/ai-vercel/index.d.ts +2 -0
- package/dist/ai-vercel/index.js +2 -0
- package/dist/ai-vercel/messages.d.ts +9 -0
- package/dist/ai-vercel/messages.js +68 -0
- package/dist/ai-vercel/vercel-llm.d.ts +8 -0
- package/dist/ai-vercel/vercel-llm.js +98 -0
- package/dist/approval/effects.d.ts +133 -0
- package/dist/approval/effects.js +13 -0
- package/dist/approval/events.d.ts +52 -0
- package/dist/approval/events.js +28 -0
- package/dist/approval/index.d.ts +6 -0
- package/dist/approval/index.js +6 -0
- package/dist/approval/module.d.ts +342 -0
- package/dist/approval/module.js +10 -0
- package/dist/approval/projections.d.ts +42 -0
- package/dist/approval/projections.js +57 -0
- package/dist/approval/scope.d.ts +45 -0
- package/dist/approval/scope.js +7 -0
- package/dist/approval/signals.d.ts +19 -0
- package/dist/approval/signals.js +34 -0
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.js +6 -0
- package/dist/cli/commands.d.ts +13 -0
- package/dist/cli/commands.js +133 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/client/client.d.ts +69 -0
- package/dist/client/client.js +179 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +2 -0
- package/dist/client/sse.d.ts +10 -0
- package/dist/client/sse.js +103 -0
- package/dist/cloudflare/alarm-scheduler.d.ts +9 -0
- package/dist/cloudflare/alarm-scheduler.js +13 -0
- package/dist/cloudflare/durable-object.d.ts +24 -0
- package/dist/cloudflare/durable-object.js +43 -0
- package/dist/cloudflare/event-store.d.ts +10 -0
- package/dist/cloudflare/event-store.js +18 -0
- package/dist/cloudflare/index.d.ts +4 -0
- package/dist/cloudflare/index.js +4 -0
- package/dist/cloudflare/router.d.ts +12 -0
- package/dist/cloudflare/router.js +26 -0
- package/dist/core/bun-sqlite.d.ts +13 -0
- package/dist/core/bun-sqlite.js +19 -0
- package/dist/core/catalog.d.ts +49 -0
- package/dist/core/catalog.js +39 -0
- package/dist/core/coalesce.d.ts +21 -0
- package/dist/core/coalesce.js +178 -0
- package/dist/core/compose.d.ts +59 -0
- package/dist/core/compose.js +97 -0
- package/dist/core/cursor.d.ts +16 -0
- package/dist/core/cursor.js +46 -0
- package/dist/core/effects.d.ts +110 -0
- package/dist/core/effects.js +99 -0
- package/dist/core/envelope.d.ts +79 -0
- package/dist/core/envelope.js +68 -0
- package/dist/core/event-codec.d.ts +8 -0
- package/dist/core/event-codec.js +82 -0
- package/dist/core/event-index.d.ts +28 -0
- package/dist/core/event-index.js +86 -0
- package/dist/core/fold.d.ts +19 -0
- package/dist/core/fold.js +362 -0
- package/dist/core/ids.d.ts +11 -0
- package/dist/core/ids.js +47 -0
- package/dist/core/index.d.ts +26 -0
- package/dist/core/index.js +25 -0
- package/dist/core/match.d.ts +8 -0
- package/dist/core/match.js +58 -0
- package/dist/core/module-scope.d.ts +99 -0
- package/dist/core/module-scope.js +72 -0
- package/dist/core/module.d.ts +74 -0
- package/dist/core/module.js +3 -0
- package/dist/core/projection.d.ts +83 -0
- package/dist/core/projection.js +241 -0
- package/dist/core/protocol.d.ts +99 -0
- package/dist/core/protocol.js +101 -0
- package/dist/core/replay.d.ts +13 -0
- package/dist/core/replay.js +34 -0
- package/dist/core/schema.d.ts +35 -0
- package/dist/core/schema.js +130 -0
- package/dist/core/serialize.d.ts +14 -0
- package/dist/core/serialize.js +42 -0
- package/dist/core/snapshot-store.d.ts +39 -0
- package/dist/core/snapshot-store.js +53 -0
- package/dist/core/snapshots.d.ts +26 -0
- package/dist/core/snapshots.js +100 -0
- package/dist/core/sqlite-store.d.ts +31 -0
- package/dist/core/sqlite-store.js +328 -0
- package/dist/core/state.d.ts +43 -0
- package/dist/core/state.js +31 -0
- package/dist/core/store.d.ts +146 -0
- package/dist/core/store.js +229 -0
- package/dist/core/thread.d.ts +41 -0
- package/dist/core/thread.js +13 -0
- package/dist/core/types.d.ts +27 -0
- package/dist/core/types.js +42 -0
- package/dist/core/validate-event.d.ts +19 -0
- package/dist/core/validate-event.js +42 -0
- package/dist/debugger/components/debugger-split.d.ts +23 -0
- package/dist/debugger/components/debugger-split.js +25 -0
- package/dist/debugger/components/event-inspector.d.ts +5 -0
- package/dist/debugger/components/event-inspector.js +38 -0
- package/dist/debugger/components/event-stream.d.ts +13 -0
- package/dist/debugger/components/event-stream.js +119 -0
- package/dist/debugger/components/json-view.d.ts +5 -0
- package/dist/debugger/components/json-view.js +5 -0
- package/dist/debugger/components/run-tree.d.ts +14 -0
- package/dist/debugger/components/run-tree.js +38 -0
- package/dist/debugger/components/status-dot.d.ts +3 -0
- package/dist/debugger/components/status-dot.js +5 -0
- package/dist/debugger/contracts.d.ts +22 -0
- package/dist/debugger/contracts.js +1 -0
- package/dist/debugger/events/catalog.d.ts +6 -0
- package/dist/debugger/events/catalog.js +27 -0
- package/dist/debugger/events/domain-summarize.d.ts +3 -0
- package/dist/debugger/events/domain-summarize.js +107 -0
- package/dist/debugger/events/family.d.ts +8 -0
- package/dist/debugger/events/family.js +44 -0
- package/dist/debugger/events/protocol-summarize.d.ts +3 -0
- package/dist/debugger/events/protocol-summarize.js +70 -0
- package/dist/debugger/index.d.ts +17 -0
- package/dist/debugger/index.js +16 -0
- package/dist/debugger/lib/cn.d.ts +5 -0
- package/dist/debugger/lib/cn.js +17 -0
- package/dist/debugger/lib/event-counts.d.ts +5 -0
- package/dist/debugger/lib/event-counts.js +23 -0
- package/dist/debugger/lib/event-meta.d.ts +8 -0
- package/dist/debugger/lib/event-meta.js +20 -0
- package/dist/debugger/lib/project-run.d.ts +9 -0
- package/dist/debugger/lib/project-run.js +14 -0
- package/dist/debugger/lib/status.d.ts +3 -0
- package/dist/debugger/lib/status.js +31 -0
- package/dist/debugger/lib/visible-events.d.ts +8 -0
- package/dist/debugger/lib/visible-events.js +21 -0
- package/dist/debugger/styles.css +71 -0
- package/dist/debugger/ui/checkbox.d.ts +4 -0
- package/dist/debugger/ui/checkbox.js +9 -0
- package/dist/debugger/ui/input.d.ts +3 -0
- package/dist/debugger/ui/input.js +7 -0
- package/dist/debugger/ui/scroll-area.d.ts +9 -0
- package/dist/debugger/ui/scroll-area.js +10 -0
- package/dist/debugger/ui/tabs.d.ts +7 -0
- package/dist/debugger/ui/tabs.js +17 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/projectors/index-model.d.ts +56 -0
- package/dist/projectors/index-model.js +117 -0
- package/dist/projectors/index.d.ts +4 -0
- package/dist/projectors/index.js +3 -0
- package/dist/projectors/memory.d.ts +5 -0
- package/dist/projectors/memory.js +77 -0
- package/dist/projectors/postgres.d.ts +9 -0
- package/dist/projectors/postgres.js +108 -0
- package/dist/projectors/projector.d.ts +11 -0
- package/dist/projectors/projector.js +1 -0
- package/dist/projectors/schema.d.ts +5 -0
- package/dist/projectors/schema.js +43 -0
- package/dist/projectors/sqlite.d.ts +9 -0
- package/dist/projectors/sqlite.js +103 -0
- package/dist/projectors/with-projectors.d.ts +17 -0
- package/dist/projectors/with-projectors.js +55 -0
- package/dist/react/derived.d.ts +19 -0
- package/dist/react/derived.js +50 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.js +5 -0
- package/dist/react/materialize.d.ts +3 -0
- package/dist/react/materialize.js +86 -0
- package/dist/react/notify.d.ts +18 -0
- package/dist/react/notify.js +80 -0
- package/dist/react/react.d.ts +61 -0
- package/dist/react/react.js +187 -0
- package/dist/react/register.d.ts +31 -0
- package/dist/react/register.js +1 -0
- package/dist/react/sse.d.ts +1 -0
- package/dist/react/sse.js +1 -0
- package/dist/react/store.d.ts +56 -0
- package/dist/react/store.js +340 -0
- package/dist/react/tables.d.ts +21 -0
- package/dist/react/tables.js +6 -0
- package/dist/runtime/dispatch-effect.d.ts +3 -0
- package/dist/runtime/dispatch-effect.js +113 -0
- package/dist/runtime/events-api.d.ts +4 -0
- package/dist/runtime/events-api.js +84 -0
- package/dist/runtime/index.d.ts +5 -0
- package/dist/runtime/index.js +5 -0
- package/dist/runtime/looms.d.ts +74 -0
- package/dist/runtime/looms.js +109 -0
- package/dist/runtime/runtime-helpers.d.ts +51 -0
- package/dist/runtime/runtime-helpers.js +230 -0
- package/dist/runtime/runtime.d.ts +91 -0
- package/dist/runtime/runtime.js +531 -0
- package/dist/runtime/server.d.ts +17 -0
- package/dist/runtime/server.js +226 -0
- package/dist/runtime/sse.d.ts +15 -0
- package/dist/runtime/sse.js +96 -0
- package/dist/runtime/wake-scheduler.d.ts +8 -0
- package/dist/runtime/wake-scheduler.js +38 -0
- package/dist/s2/config.d.ts +27 -0
- package/dist/s2/config.js +54 -0
- package/dist/s2/index.d.ts +6 -0
- package/dist/s2/index.js +6 -0
- package/dist/s2/lite.d.ts +26 -0
- package/dist/s2/lite.js +150 -0
- package/dist/s2/projector.d.ts +8 -0
- package/dist/s2/projector.js +28 -0
- package/dist/s2/serialize.d.ts +1 -0
- package/dist/s2/serialize.js +1 -0
- package/dist/s2/snapshot-store.d.ts +17 -0
- package/dist/s2/snapshot-store.js +320 -0
- package/dist/s2/store.d.ts +35 -0
- package/dist/s2/store.js +337 -0
- package/dist/testing/index.d.ts +11 -0
- package/dist/testing/index.js +63 -0
- package/dist/workflow/definitions-store.d.ts +11 -0
- package/dist/workflow/definitions-store.js +8 -0
- package/dist/workflow/definitions.d.ts +82 -0
- package/dist/workflow/definitions.js +32 -0
- package/dist/workflow/effects.d.ts +305 -0
- package/dist/workflow/effects.js +208 -0
- package/dist/workflow/events.d.ts +60 -0
- package/dist/workflow/events.js +39 -0
- package/dist/workflow/index.d.ts +8 -0
- package/dist/workflow/index.js +8 -0
- package/dist/workflow/module.d.ts +926 -0
- package/dist/workflow/module.js +19 -0
- package/dist/workflow/projections.d.ts +30 -0
- package/dist/workflow/projections.js +43 -0
- package/dist/workflow/scope.d.ts +61 -0
- package/dist/workflow/scope.js +7 -0
- package/dist/workflow/threads.d.ts +171 -0
- package/dist/workflow/threads.js +287 -0
- package/package.json +183 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 ByteSlice
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @swirls/looms
|
|
2
|
+
|
|
3
|
+
Looms is an event-sourced runtime for durable agents and workflows.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
bun add @swirls/looms
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Import the core runtime from `@swirls/looms`, or use explicit modules such as `@swirls/looms/agent` and `@swirls/looms/react`. See the [repository README](https://github.com/ByteSliceHQ/looms#readme) for the full guide.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type AnyRuntimeModule, type EventStore, type RunState, type SnapshotStore } from '@swirls/looms/core';
|
|
2
|
+
import { type LoomsRuntime, type WakeScheduler } from '@swirls/looms/runtime';
|
|
3
|
+
export interface ActorCellOptions<TModules extends readonly AnyRuntimeModule[] = readonly AnyRuntimeModule[]> {
|
|
4
|
+
readonly runId: string;
|
|
5
|
+
readonly store: EventStore;
|
|
6
|
+
readonly scheduler?: WakeScheduler;
|
|
7
|
+
readonly modules: TModules;
|
|
8
|
+
readonly snapshotEvery?: number;
|
|
9
|
+
readonly maxWakeIterations?: number;
|
|
10
|
+
readonly snapshotStore?: SnapshotStore;
|
|
11
|
+
readonly trimAfterSnapshot?: {
|
|
12
|
+
keepSnapshots: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface ActorCell<TModules extends readonly AnyRuntimeModule[] = readonly AnyRuntimeModule[]> {
|
|
16
|
+
readonly runId: string;
|
|
17
|
+
readonly runtime: LoomsRuntime<TModules>;
|
|
18
|
+
readonly store: EventStore;
|
|
19
|
+
fetch(req: Request): Promise<Response>;
|
|
20
|
+
wake(): Promise<RunState>;
|
|
21
|
+
dispose(): void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates an in-process actor cell that owns a single `runId`.
|
|
25
|
+
* Encapsulates single-writer concurrency, local storage, and HTTP routing.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createActorCell<TModules extends readonly AnyRuntimeModule[] = readonly AnyRuntimeModule[]>(options: ActorCellOptions<TModules>): ActorCell<TModules>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { EventStoreTag, } from '@swirls/looms/core';
|
|
3
|
+
import { createFetchHandler, createRuntime, } from '@swirls/looms/runtime';
|
|
4
|
+
import { runIdFromRequest } from './routing.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates an in-process actor cell that owns a single `runId`.
|
|
7
|
+
* Encapsulates single-writer concurrency, local storage, and HTTP routing.
|
|
8
|
+
*/
|
|
9
|
+
export function createActorCell(options) {
|
|
10
|
+
const { runId, store, scheduler } = options;
|
|
11
|
+
const runtime = createRuntime({
|
|
12
|
+
modules: options.modules,
|
|
13
|
+
store,
|
|
14
|
+
scheduler,
|
|
15
|
+
snapshotEvery: options.snapshotEvery,
|
|
16
|
+
maxWakeIterations: options.maxWakeIterations,
|
|
17
|
+
snapshotStore: options.snapshotStore,
|
|
18
|
+
trimAfterSnapshot: options.trimAfterSnapshot,
|
|
19
|
+
});
|
|
20
|
+
const fetchHandler = createFetchHandler({ runtime, store });
|
|
21
|
+
return {
|
|
22
|
+
runId,
|
|
23
|
+
runtime,
|
|
24
|
+
store,
|
|
25
|
+
fetch: async (req) => {
|
|
26
|
+
const targetRunId = runIdFromRequest(req);
|
|
27
|
+
if (targetRunId && targetRunId !== runId) {
|
|
28
|
+
return new Response('Not Found', { status: 404 });
|
|
29
|
+
}
|
|
30
|
+
const res = await fetchHandler(req);
|
|
31
|
+
if (res === null) {
|
|
32
|
+
return new Response('Not Found', { status: 404 });
|
|
33
|
+
}
|
|
34
|
+
return res;
|
|
35
|
+
},
|
|
36
|
+
wake: () => Effect.runPromise(Effect.provideService(runtime.wake(runId), EventStoreTag, store)),
|
|
37
|
+
dispose: () => {
|
|
38
|
+
runtime.dispose();
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AnyRuntimeModule, EventStore, SnapshotStore } from '@swirls/looms/core';
|
|
2
|
+
import { type ActorCell } from './cell';
|
|
3
|
+
export interface LocalActorHostOptions<TModules extends readonly AnyRuntimeModule[] = readonly AnyRuntimeModule[]> {
|
|
4
|
+
readonly createStore: (runId: string) => EventStore | Promise<EventStore>;
|
|
5
|
+
readonly modules: TModules;
|
|
6
|
+
readonly snapshotStore?: SnapshotStore;
|
|
7
|
+
readonly snapshotEvery?: number;
|
|
8
|
+
readonly maxWakeIterations?: number;
|
|
9
|
+
readonly trimAfterSnapshot?: {
|
|
10
|
+
keepSnapshots: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* After creating a cell, rescan its store for pending timers (process restart).
|
|
14
|
+
* Default true. No-op for empty in-memory stores.
|
|
15
|
+
*/
|
|
16
|
+
readonly rescanTimers?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface LocalActorHost<TModules extends readonly AnyRuntimeModule[] = readonly AnyRuntimeModule[]> {
|
|
19
|
+
getCell(runId: string): Promise<ActorCell<TModules>>;
|
|
20
|
+
fetch(req: Request): Promise<Response | null>;
|
|
21
|
+
dispose(): void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates an in-process host that routes requests to distinct actor cells.
|
|
25
|
+
* Useful for local Bun actor backends, tests, and lightweight simulation.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createLocalActorHost<TModules extends readonly AnyRuntimeModule[] = readonly AnyRuntimeModule[]>(options: LocalActorHostOptions<TModules>): LocalActorHost<TModules>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { EventStoreTag } from '@swirls/looms/core';
|
|
3
|
+
import { createTimeoutScheduler, isLoomsApiPath } from '@swirls/looms/runtime';
|
|
4
|
+
import { createActorCell } from './cell.js';
|
|
5
|
+
import { resolveRunTarget } from './routing.js';
|
|
6
|
+
/**
|
|
7
|
+
* Creates an in-process host that routes requests to distinct actor cells.
|
|
8
|
+
* Useful for local Bun actor backends, tests, and lightweight simulation.
|
|
9
|
+
*/
|
|
10
|
+
export function createLocalActorHost(options) {
|
|
11
|
+
const cells = new Map();
|
|
12
|
+
const rescanTimers = options.rescanTimers !== false;
|
|
13
|
+
const getCell = (runId) => {
|
|
14
|
+
const existing = cells.get(runId);
|
|
15
|
+
if (existing) {
|
|
16
|
+
return existing;
|
|
17
|
+
}
|
|
18
|
+
const cellPromise = (async () => {
|
|
19
|
+
const store = await options.createStore(runId);
|
|
20
|
+
// Assign after createActorCell so the scheduler never closes over an unassigned cell.
|
|
21
|
+
let wake;
|
|
22
|
+
const scheduler = createTimeoutScheduler((scheduledRunId) => {
|
|
23
|
+
if (scheduledRunId !== runId) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
void wake?.().catch((err) => {
|
|
27
|
+
console.error('[actor host wake error]', err);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
const cell = createActorCell({
|
|
31
|
+
runId,
|
|
32
|
+
store,
|
|
33
|
+
scheduler,
|
|
34
|
+
modules: options.modules,
|
|
35
|
+
snapshotStore: options.snapshotStore,
|
|
36
|
+
snapshotEvery: options.snapshotEvery,
|
|
37
|
+
maxWakeIterations: options.maxWakeIterations,
|
|
38
|
+
trimAfterSnapshot: options.trimAfterSnapshot,
|
|
39
|
+
});
|
|
40
|
+
wake = () => cell.wake();
|
|
41
|
+
if (rescanTimers) {
|
|
42
|
+
await Effect.runPromise(Effect.provideService(cell.runtime.rescanTimers(), EventStoreTag, store)).catch((err) => {
|
|
43
|
+
console.error('[actor host rescan timers error]', err);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return cell;
|
|
47
|
+
})();
|
|
48
|
+
cells.set(runId, cellPromise);
|
|
49
|
+
return cellPromise;
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
getCell,
|
|
53
|
+
fetch: async (req) => {
|
|
54
|
+
const url = new URL(req.url);
|
|
55
|
+
if (!isLoomsApiPath(url.pathname)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
if (url.pathname === '/health') {
|
|
59
|
+
return Response.json({ ok: true });
|
|
60
|
+
}
|
|
61
|
+
if (req.method === 'GET' && url.pathname === '/runs') {
|
|
62
|
+
return Response.json({
|
|
63
|
+
error: 'Global run listing is not supported in the actor host without a global index',
|
|
64
|
+
}, { status: 501 });
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const { runId, request } = await resolveRunTarget(req);
|
|
68
|
+
const cell = await getCell(runId);
|
|
69
|
+
return cell.fetch(request);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return new Response('Not Found', { status: 404 });
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
dispose: () => {
|
|
76
|
+
for (const promise of cells.values()) {
|
|
77
|
+
void promise.then((cell) => cell.dispose());
|
|
78
|
+
}
|
|
79
|
+
cells.clear();
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the target `runId` from a Looms HTTP request.
|
|
3
|
+
* Inspects `x-looms-run-id`, `/runs/:runId/*`, and `/api/events?runId=*`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function runIdFromRequest(req: Request): string | null;
|
|
6
|
+
export interface ResolvedRunTarget {
|
|
7
|
+
readonly runId: string;
|
|
8
|
+
readonly request: Request;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolves the destination `runId` for routing to an actor cell.
|
|
12
|
+
* For `POST /runs` without a `runId`, creates a fresh `runId`, injects it
|
|
13
|
+
* into the body, and sets `x-looms-run-id`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveRunTarget(req: Request): Promise<ResolvedRunTarget>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Option, Schema } from 'effect';
|
|
2
|
+
import { createRunId, isJsonObject } from '@swirls/looms/core';
|
|
3
|
+
const RunTargetBodySchema = Schema.Struct({
|
|
4
|
+
runId: Schema.optional(Schema.NonEmptyString),
|
|
5
|
+
});
|
|
6
|
+
const decodeRunTargetBody = Schema.decodeUnknownOption(Schema.fromJsonString(RunTargetBodySchema));
|
|
7
|
+
const decodePayloadRecord = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Record(Schema.String, Schema.Json)));
|
|
8
|
+
/**
|
|
9
|
+
* Extracts the target `runId` from a Looms HTTP request.
|
|
10
|
+
* Inspects `x-looms-run-id`, `/runs/:runId/*`, and `/api/events?runId=*`.
|
|
11
|
+
*/
|
|
12
|
+
export function runIdFromRequest(req) {
|
|
13
|
+
const header = req.headers.get('x-looms-run-id');
|
|
14
|
+
if (header) {
|
|
15
|
+
return header;
|
|
16
|
+
}
|
|
17
|
+
const url = new URL(req.url);
|
|
18
|
+
const path = url.pathname;
|
|
19
|
+
const runsMatch = path.match(/^\/runs\/([^/]+)(?:\/.*)?$/);
|
|
20
|
+
if (runsMatch && runsMatch[1]) {
|
|
21
|
+
return decodeURIComponent(runsMatch[1]);
|
|
22
|
+
}
|
|
23
|
+
if (path.startsWith('/api/events')) {
|
|
24
|
+
const runId = url.searchParams.get('runId');
|
|
25
|
+
if (runId) {
|
|
26
|
+
return runId;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resolves the destination `runId` for routing to an actor cell.
|
|
33
|
+
* For `POST /runs` without a `runId`, creates a fresh `runId`, injects it
|
|
34
|
+
* into the body, and sets `x-looms-run-id`.
|
|
35
|
+
*/
|
|
36
|
+
export async function resolveRunTarget(req) {
|
|
37
|
+
const existing = runIdFromRequest(req);
|
|
38
|
+
if (existing) {
|
|
39
|
+
if (req.headers.get('x-looms-run-id') === existing) {
|
|
40
|
+
return { runId: existing, request: req };
|
|
41
|
+
}
|
|
42
|
+
const headers = new Headers(req.headers);
|
|
43
|
+
headers.set('x-looms-run-id', existing);
|
|
44
|
+
const request = new Request(req.url, {
|
|
45
|
+
method: req.method,
|
|
46
|
+
headers,
|
|
47
|
+
body: req.body,
|
|
48
|
+
// SAFETY: duplex 'half' is required when streaming request body in standard Fetch.
|
|
49
|
+
// @ts-expect-error duplex is supported in modern runtimes
|
|
50
|
+
duplex: req.body ? 'half' : undefined,
|
|
51
|
+
});
|
|
52
|
+
return { runId: existing, request };
|
|
53
|
+
}
|
|
54
|
+
const url = new URL(req.url);
|
|
55
|
+
if (req.method === 'POST' && url.pathname === '/runs') {
|
|
56
|
+
const text = await req.clone().text();
|
|
57
|
+
const decoded = decodeRunTargetBody(text);
|
|
58
|
+
let runId;
|
|
59
|
+
if (Option.isSome(decoded) && decoded.value.runId) {
|
|
60
|
+
runId = decoded.value.runId;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
runId = createRunId();
|
|
64
|
+
}
|
|
65
|
+
const decodedRecord = decodePayloadRecord(text);
|
|
66
|
+
const payloadObj = Option.isSome(decodedRecord) && isJsonObject(decodedRecord.value)
|
|
67
|
+
? { ...decodedRecord.value, runId }
|
|
68
|
+
: { runId };
|
|
69
|
+
const headers = new Headers(req.headers);
|
|
70
|
+
headers.set('x-looms-run-id', runId);
|
|
71
|
+
headers.set('content-type', 'application/json');
|
|
72
|
+
const request = new Request(req.url, {
|
|
73
|
+
method: req.method,
|
|
74
|
+
headers,
|
|
75
|
+
body: JSON.stringify(payloadObj),
|
|
76
|
+
});
|
|
77
|
+
return { runId, request };
|
|
78
|
+
}
|
|
79
|
+
throw new Error(`Cannot resolve runId from request: ${req.method} ${url.pathname}`);
|
|
80
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Context, Layer } from 'effect';
|
|
2
|
+
import type { AgentDefinition } from './definitions';
|
|
3
|
+
export interface AgentDefinitionStore {
|
|
4
|
+
get(name: string): AgentDefinition | undefined;
|
|
5
|
+
}
|
|
6
|
+
declare const AgentDefinitionsTag_base: Context.ServiceClass<AgentDefinitionsTag, "looms/AgentDefinitions", AgentDefinitionStore>;
|
|
7
|
+
export declare class AgentDefinitionsTag extends AgentDefinitionsTag_base {
|
|
8
|
+
}
|
|
9
|
+
export declare function makeAgentDefinitionStore(definitions: ReadonlyArray<AgentDefinition>): AgentDefinitionStore;
|
|
10
|
+
export declare const AgentDefinitionsLive: (definitions: ReadonlyArray<AgentDefinition>) => Layer.Layer<AgentDefinitionsTag, never, never>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Context, Layer } from 'effect';
|
|
2
|
+
export class AgentDefinitionsTag extends Context.Service()('looms/AgentDefinitions') {
|
|
3
|
+
}
|
|
4
|
+
export function makeAgentDefinitionStore(definitions) {
|
|
5
|
+
const map = new Map(definitions.map((def) => [def.name, def]));
|
|
6
|
+
return {
|
|
7
|
+
get: (name) => map.get(name),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export const AgentDefinitionsLive = (definitions) => Layer.succeed(AgentDefinitionsTag, makeAgentDefinitionStore(definitions));
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import type { Schema } from 'effect';
|
|
3
|
+
import type { InferDefinedSchema, JsonValue, RuntimeEffect, SchemaInput } from '@swirls/looms/core';
|
|
4
|
+
import type { StopWhen } from './stop-when';
|
|
5
|
+
import type { Message, ToolCall } from './types';
|
|
6
|
+
export interface ToolContext {
|
|
7
|
+
readonly threadId: string;
|
|
8
|
+
readonly turn: number;
|
|
9
|
+
readonly signal?: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
export interface FunctionTool<TName extends string = string, TInput = JsonValue, TOutput extends JsonValue = JsonValue> {
|
|
12
|
+
readonly kind: 'function';
|
|
13
|
+
readonly name: TName;
|
|
14
|
+
readonly description: string;
|
|
15
|
+
readonly input?: StandardSchemaV1<any, TInput> | Schema.Schema<TInput>;
|
|
16
|
+
readonly inputSchema?: JsonValue;
|
|
17
|
+
handler(input: TInput, ctx: ToolContext): Promise<TOutput> | TOutput;
|
|
18
|
+
}
|
|
19
|
+
export interface ThreadTool {
|
|
20
|
+
readonly kind: 'thread';
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly description: string;
|
|
23
|
+
readonly input?: SchemaInput;
|
|
24
|
+
readonly inputSchema?: JsonValue;
|
|
25
|
+
readonly childKind: string;
|
|
26
|
+
readonly childName: string;
|
|
27
|
+
readonly child: {
|
|
28
|
+
kind: string;
|
|
29
|
+
name: string;
|
|
30
|
+
};
|
|
31
|
+
mapInput?(input: JsonValue): JsonValue;
|
|
32
|
+
}
|
|
33
|
+
export interface EffectsTool {
|
|
34
|
+
readonly kind: 'effects';
|
|
35
|
+
readonly name: string;
|
|
36
|
+
readonly description: string;
|
|
37
|
+
readonly input?: SchemaInput;
|
|
38
|
+
readonly inputSchema?: JsonValue;
|
|
39
|
+
effects(input: JsonValue): RuntimeEffect[];
|
|
40
|
+
waitOn?: {
|
|
41
|
+
type: string | readonly string[];
|
|
42
|
+
match?: JsonValue;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export type ToolLike = FunctionTool | ThreadTool | EffectsTool;
|
|
46
|
+
export type AgentToolEntry = ToolLike | {
|
|
47
|
+
kind: string;
|
|
48
|
+
name: string;
|
|
49
|
+
instructions?: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
input?: SchemaInput;
|
|
52
|
+
};
|
|
53
|
+
export interface AgentTurnContext<TInput = JsonValue> {
|
|
54
|
+
readonly threadId: string;
|
|
55
|
+
readonly turn: number;
|
|
56
|
+
readonly messages: Message[];
|
|
57
|
+
readonly input: TInput;
|
|
58
|
+
readonly tools: ToolLike[];
|
|
59
|
+
readonly instructions: string;
|
|
60
|
+
}
|
|
61
|
+
export interface AgentTurnResult<TOutput extends JsonValue = JsonValue> {
|
|
62
|
+
message: Message;
|
|
63
|
+
toolCalls?: ToolCall[];
|
|
64
|
+
done?: boolean;
|
|
65
|
+
output?: TOutput;
|
|
66
|
+
usage?: {
|
|
67
|
+
input: number;
|
|
68
|
+
output: number;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export interface AgentDefinition<TName extends string = string, TInput = JsonValue, TOutput extends JsonValue = JsonValue> {
|
|
72
|
+
readonly kind: 'agent';
|
|
73
|
+
readonly name: TName;
|
|
74
|
+
readonly model?: string;
|
|
75
|
+
readonly instructions: string;
|
|
76
|
+
readonly input?: StandardSchemaV1<any, TInput> | Schema.Schema<TInput>;
|
|
77
|
+
readonly tools?: ToolLike[];
|
|
78
|
+
readonly maxTurns?: number;
|
|
79
|
+
readonly conversational?: boolean;
|
|
80
|
+
readonly stopWhen?: StopWhen;
|
|
81
|
+
runTurn?(ctx: AgentTurnContext<TInput>): Promise<AgentTurnResult<TOutput>> | AgentTurnResult<TOutput>;
|
|
82
|
+
}
|
|
83
|
+
export type AnyAgentDefinition = AgentDefinition;
|
|
84
|
+
export declare function normalizeTools(tools?: ReadonlyArray<AgentToolEntry>): ToolLike[];
|
|
85
|
+
export declare function defineTool<TName extends string, TSchema = undefined, TInput = InferDefinedSchema<TSchema>, TOutput extends JsonValue = JsonValue>(def: {
|
|
86
|
+
name: TName;
|
|
87
|
+
description: string;
|
|
88
|
+
input?: TSchema;
|
|
89
|
+
inputSchema?: JsonValue;
|
|
90
|
+
handler: (input: TInput, ctx: ToolContext) => Promise<TOutput> | TOutput;
|
|
91
|
+
}): FunctionTool<TName, TInput, TOutput>;
|
|
92
|
+
export declare function defineAgent<TName extends string, TSchema = undefined, TInput = InferDefinedSchema<TSchema>, TOutput extends JsonValue = JsonValue>(def: {
|
|
93
|
+
name: TName;
|
|
94
|
+
model?: string;
|
|
95
|
+
instructions: string;
|
|
96
|
+
input?: TSchema;
|
|
97
|
+
tools?: AgentToolEntry[];
|
|
98
|
+
maxTurns?: number;
|
|
99
|
+
conversational?: boolean;
|
|
100
|
+
stopWhen?: StopWhen;
|
|
101
|
+
runTurn?: (ctx: AgentTurnContext<TInput>) => Promise<AgentTurnResult<TOutput>> | AgentTurnResult<TOutput>;
|
|
102
|
+
}): AgentDefinition<TName, TInput, TOutput>;
|
|
103
|
+
export declare function asThreadTool(def: {
|
|
104
|
+
name?: string;
|
|
105
|
+
description?: string;
|
|
106
|
+
input?: SchemaInput;
|
|
107
|
+
inputSchema?: JsonValue;
|
|
108
|
+
child: {
|
|
109
|
+
kind: string;
|
|
110
|
+
name: string;
|
|
111
|
+
};
|
|
112
|
+
mapInput?: (input: JsonValue) => JsonValue;
|
|
113
|
+
}): ThreadTool;
|
|
114
|
+
export declare function asAgentTool(def: {
|
|
115
|
+
name?: string;
|
|
116
|
+
description?: string;
|
|
117
|
+
input?: SchemaInput;
|
|
118
|
+
inputSchema?: JsonValue;
|
|
119
|
+
agent: {
|
|
120
|
+
kind: 'agent';
|
|
121
|
+
name: string;
|
|
122
|
+
instructions?: string;
|
|
123
|
+
input?: SchemaInput;
|
|
124
|
+
inputSchema?: JsonValue;
|
|
125
|
+
};
|
|
126
|
+
mapInput?: (input: JsonValue) => JsonValue;
|
|
127
|
+
}): ThreadTool;
|
|
128
|
+
export declare function asWorkflowTool(def: {
|
|
129
|
+
name?: string;
|
|
130
|
+
description?: string;
|
|
131
|
+
input?: SchemaInput;
|
|
132
|
+
inputSchema?: JsonValue;
|
|
133
|
+
workflow: {
|
|
134
|
+
kind: 'workflow';
|
|
135
|
+
name: string;
|
|
136
|
+
description?: string;
|
|
137
|
+
input?: SchemaInput;
|
|
138
|
+
inputSchema?: JsonValue;
|
|
139
|
+
};
|
|
140
|
+
mapInput?: (input: JsonValue) => JsonValue;
|
|
141
|
+
}): ThreadTool;
|
|
142
|
+
export declare function asEffectsTool(def: {
|
|
143
|
+
name: string;
|
|
144
|
+
description: string;
|
|
145
|
+
input?: SchemaInput;
|
|
146
|
+
inputSchema?: JsonValue;
|
|
147
|
+
effects: (input: JsonValue) => RuntimeEffect[];
|
|
148
|
+
waitOn?: {
|
|
149
|
+
type: string | readonly string[];
|
|
150
|
+
match?: JsonValue;
|
|
151
|
+
};
|
|
152
|
+
}): EffectsTool;
|