@statelyai/sdk 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 ADDED
@@ -0,0 +1,678 @@
1
+ GNU AFFERO GENERAL PUBLIC LICENSE
2
+
3
+ Version 3, 19 November 2007
4
+
5
+ Copyright (C)
6
+ 2025 Stately Software, Inc.
7
+
8
+ Everyone is permitted to copy and distribute verbatim
9
+ copies of this license document, but changing it is not allowed.
10
+
11
+ Preamble
12
+
13
+ The
14
+ GNU Affero General Public License is a free, copyleft license for software and
15
+ other kinds of works, specifically designed to ensure cooperation with the
16
+ community in the case of network server software.
17
+
18
+ The licenses for most software
19
+ and other practical works are designed to take away your freedom to share and
20
+ change the works. By contrast, our General Public Licenses are intended to
21
+ guarantee your freedom to share and change all versions of a program--to make
22
+ sure it remains free software for all its users.
23
+
24
+ When we speak of free software,
25
+ we are referring to freedom, not price. Our General Public Licenses are designed
26
+ to make sure that you have the freedom to distribute copies of free software (and
27
+ charge for them if you wish), that you receive source code or can get it if you
28
+ want it, that you can change the software or use pieces of it in new free
29
+ programs, and that you know you can do these things.
30
+
31
+ Developers that use our
32
+ General Public Licenses protect your rights with two steps: (1) assert copyright
33
+ on the software, and (2) offer you this License which gives you legal permission
34
+ to copy, distribute and/or modify the software.
35
+
36
+ A secondary benefit of defending
37
+ all users' freedom is that improvements made in alternate versions of the
38
+ program, if they receive widespread use, become available for other developers to
39
+ incorporate. Many developers of free software are heartened and encouraged by the
40
+ resulting cooperation. However, in the case of software used on network servers,
41
+ this result may fail to come about. The GNU General Public License permits making
42
+ a modified version and letting the public access it on a server without ever
43
+ releasing its source code to the public.
44
+
45
+ The GNU Affero General Public License
46
+ is designed specifically to ensure that, in such cases, the modified source code
47
+ becomes available to the community. It requires the operator of a network server
48
+ to provide the source code of the modified version running there to the users of
49
+ that server. Therefore, public use of a modified version, on a publicly
50
+ accessible server, gives the public access to the source code of the modified
51
+ version.
52
+
53
+ An older license, called the Affero General Public License and
54
+ published by Affero, was designed to accomplish similar goals. This is a
55
+ different license, not a version of the Affero GPL, but Affero has released a new
56
+ version of the Affero GPL which permits relicensing under this license.
57
+
58
+ The
59
+ precise terms and conditions for copying, distribution and modification
60
+ follow.
61
+
62
+ TERMS AND CONDITIONS
63
+
64
+ 0. Definitions.
65
+
66
+ "This License" refers to
67
+ version 3 of the GNU Affero General Public License.
68
+
69
+ "Copyright" also means
70
+ copyright-like laws that apply to other kinds of works, such as semiconductor
71
+ masks.
72
+
73
+ "The Program" refers to any copyrightable work licensed under this
74
+ License. Each licensee is addressed as "you". "Licensees" and "recipients" may be
75
+ individuals or organizations.
76
+
77
+ To "modify" a work means to copy from or adapt
78
+ all or part of the work in a fashion requiring copyright permission, other than
79
+ the making of an exact copy. The resulting work is called a "modified version" of
80
+ the earlier work or a work "based on" the earlier work.
81
+
82
+ A "covered work"
83
+ means either the unmodified Program or a work based on the Program.
84
+
85
+ To
86
+ "propagate" a work means to do anything with it that, without permission, would
87
+ make you directly or secondarily liable for infringement under applicable
88
+ copyright law, except executing it on a computer or modifying a private copy.
89
+ Propagation includes copying, distribution (with or without modification), making
90
+ available to the public, and in some countries other activities as well.
91
+
92
+ To
93
+ "convey" a work means any kind of propagation that enables other parties to make
94
+ or receive copies. Mere interaction with a user through a computer network, with
95
+ no transfer of a copy, is not conveying.
96
+
97
+ An interactive user interface
98
+ displays "Appropriate Legal Notices" to the extent that it includes a convenient
99
+ and prominently visible feature that (1) displays an appropriate copyright
100
+ notice, and (2) tells the user that there is no warranty for the work (except to
101
+ the extent that warranties are provided), that licensees may convey the work
102
+ under this License, and how to view a copy of this License. If the interface
103
+ presents a list of user commands or options, such as a menu, a prominent item in
104
+ the list meets this criterion.
105
+
106
+ 1. Source Code.
107
+
108
+ The "source code" for a
109
+ work means the preferred form of the work for making modifications to it. "Object
110
+ code" means any non-source form of a work.
111
+
112
+ A "Standard Interface" means an
113
+ interface that either is an official standard defined by a recognized standards
114
+ body, or, in the case of interfaces specified for a particular programming
115
+ language, one that is widely used among developers working in that language.
116
+
117
+
118
+ The "System Libraries" of an executable work include anything, other than the
119
+ work as a whole, that (a) is included in the normal form of packaging a Major
120
+ Component, but which is not part of that Major Component, and (b) serves only to
121
+ enable use of the work with that Major Component, or to implement a Standard
122
+ Interface for which an implementation is available to the public in source code
123
+ form. A "Major Component", in this context, means a major essential component
124
+ (kernel, window system, and so on) of the specific operating system (if any) on
125
+ which the executable work runs, or a compiler used to produce the work, or an
126
+ object code interpreter used to run it.
127
+
128
+ The "Corresponding Source" for a work
129
+ in object code form means all the source code needed to generate, install, and
130
+ (for an executable work) run the object code and to modify the work, including
131
+ scripts to control those activities. However, it does not include the work's
132
+ System Libraries, or general-purpose tools or generally available free programs
133
+ which are used unmodified in performing those activities but which are not part
134
+ of the work. For example, Corresponding Source includes interface definition
135
+ files associated with source files for the work, and the source code for shared
136
+ libraries and dynamically linked subprograms that the work is specifically
137
+ designed to require, such as by intimate data communication or control flow
138
+ between those
139
+
140
+ subprograms and other parts of the work.
141
+
142
+ The Corresponding
143
+ Source need not include anything that users can regenerate automatically from
144
+ other parts of the Corresponding Source.
145
+
146
+ The Corresponding Source for a work
147
+ in source code form is that same work.
148
+
149
+ 2. Basic Permissions.
150
+
151
+ All rights
152
+ granted under this License are granted for the term of copyright on the Program,
153
+ and are irrevocable provided the stated conditions are met. This License
154
+ explicitly affirms your unlimited permission to run the unmodified Program. The
155
+ output from running a covered work is covered by this License only if the output,
156
+ given its content, constitutes a covered work. This License acknowledges your
157
+ rights of fair use or other equivalent, as provided by copyright law.
158
+
159
+ You may
160
+ make, run and propagate covered works that you do not convey, without conditions
161
+ so long as your license otherwise remains in force. You may convey covered works
162
+ to others for the sole purpose of having them make modifications exclusively for
163
+ you, or provide you with facilities for running those works, provided that you
164
+ comply with the terms of this License in conveying all material for which you do
165
+ not control copyright. Those thus making or running the covered works for you
166
+ must do so exclusively on your behalf, under your direction and control, on terms
167
+ that prohibit them from making any copies of your copyrighted material outside
168
+ their relationship with you.
169
+
170
+ Conveying under any other circumstances is
171
+ permitted solely under the conditions stated below. Sublicensing is not allowed;
172
+ section 10 makes it unnecessary.
173
+
174
+ 3. Protecting Users' Legal Rights From
175
+ Anti-Circumvention Law.
176
+
177
+ No covered work shall be deemed part of an effective
178
+ technological measure under any applicable law fulfilling obligations under
179
+ article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar
180
+ laws prohibiting or restricting circumvention of such measures.
181
+
182
+ When you
183
+ convey a covered work, you waive any legal power to forbid circumvention of
184
+ technological measures to the extent such circumvention is effected by exercising
185
+ rights under this License with respect to the covered work, and you disclaim any
186
+ intention to limit operation or modification of the work as a means of enforcing,
187
+ against the work's users, your or third parties' legal rights to forbid
188
+ circumvention of technological measures.
189
+
190
+ 4. Conveying Verbatim Copies.
191
+
192
+
193
+ You may convey verbatim copies of the Program's source code as you receive it, in
194
+ any medium, provided that you conspicuously and appropriately publish on each
195
+ copy an appropriate copyright notice; keep intact all notices stating that this
196
+ License and any non-permissive terms added in accord with section 7 apply to the
197
+ code; keep intact all notices of the absence of any warranty; and give all
198
+ recipients a copy of this License along with the Program.
199
+
200
+ You may charge any
201
+ price or no price for each copy that you convey, and you may offer support or
202
+ warranty protection for a fee.
203
+
204
+ 5. Conveying Modified Source Versions.
205
+
206
+ You
207
+ may convey a work based on the Program, or the modifications to produce it from
208
+ the Program, in the form of source code under the terms of section 4, provided
209
+ that you also meet all of these conditions:
210
+
211
+ a) The work must carry
212
+ prominent notices stating that you modified it, and giving a relevant date.
213
+
214
+
215
+ b) The work must carry prominent notices stating that it is released under this
216
+ License and any conditions added under section 7. This requirement modifies the
217
+ requirement in section 4 to "keep intact all notices".
218
+
219
+ c) You must license
220
+ the entire work, as a whole, under this License to anyone who comes into
221
+ possession of a copy. This License will therefore apply, along with any
222
+ applicable section 7 additional terms, to the whole of the work, and all its
223
+ parts, regardless of how they are packaged. This License gives no permission to
224
+ license the work in any other way, but it does not invalidate such permission if
225
+ you have separately received it.
226
+
227
+ d) If the work has interactive user
228
+ interfaces, each must display Appropriate Legal Notices; however, if the Program
229
+ has interactive interfaces that do not display Appropriate Legal Notices, your
230
+ work need not make them do so.
231
+
232
+ A compilation of a covered work with other
233
+ separate and independent works, which are not by their nature extensions of the
234
+ covered work, and which are not combined with it such as to form a larger
235
+ program, in or on a volume of a storage or distribution medium, is called an
236
+ "aggregate" if the compilation and its resulting copyright are not used to limit
237
+ the access or legal rights of the compilation's users beyond what the individual
238
+ works permit. Inclusion of a covered work in an aggregate does not cause this
239
+ License to apply to the other parts of the aggregate.
240
+
241
+ 6. Conveying Non-Source
242
+ Forms.
243
+
244
+ You may convey a covered work in object code form under the terms of
245
+ sections 4 and 5, provided that you also convey the machine-readable
246
+ Corresponding Source under the terms of this License, in one of these ways:
247
+
248
+
249
+ a) Convey the object code in, or embodied in, a physical product (including a
250
+ physical distribution medium), accompanied by the Corresponding Source fixed on a
251
+ durable physical medium customarily used for software interchange.
252
+
253
+ b)
254
+ Convey the object code in, or embodied in, a physical product (including a
255
+ physical distribution medium), accompanied by a written offer, valid for at least
256
+ three years and valid for as long as you offer spare parts or customer support
257
+ for that product model, to give anyone who possesses the object code either (1) a
258
+ copy of the Corresponding Source for all the software in the product that is
259
+ covered by this License, on a durable physical medium customarily used for
260
+ software interchange, for a price no more than your reasonable cost of physically
261
+ performing this conveying of source, or (2) access to copy the Corresponding
262
+ Source from a network server at no charge.
263
+
264
+ c) Convey individual copies of
265
+ the object code with a copy of the written offer to provide the Corresponding
266
+ Source. This alternative is allowed only occasionally and noncommercially, and
267
+ only if you received the object code with such an offer, in accord with
268
+ subsection 6b.
269
+
270
+ d) Convey the object code by offering access from a
271
+ designated place (gratis or for a charge), and offer equivalent access to the
272
+ Corresponding Source in the same way through the same place at no further charge.
273
+ You need not require recipients to copy the Corresponding Source along with the
274
+ object code. If the place to copy the object code is a network server, the
275
+ Corresponding Source may be on a different server (operated by you or a third
276
+ party) that supports equivalent copying facilities, provided you maintain clear
277
+ directions next to the object code saying where to find the Corresponding Source.
278
+ Regardless of what server hosts the Corresponding Source, you remain obligated to
279
+ ensure that it is available for as long as needed to satisfy these
280
+ requirements.
281
+
282
+ e) Convey the object code using peer-to-peer transmission,
283
+ provided you inform other peers where the object code and Corresponding Source of
284
+ the work are being offered to the general public at no charge under subsection
285
+ 6d.
286
+
287
+ A separable portion of the object code, whose source code is excluded
288
+ from the Corresponding Source as a System Library, need not be included in
289
+ conveying the object code work.
290
+
291
+ A "User Product" is either (1) a "consumer
292
+ product", which means any tangible personal property which is normally used for
293
+ personal, family, or household purposes, or (2) anything designed or sold for
294
+ incorporation into a dwelling. In determining whether a product is a consumer
295
+ product, doubtful cases shall be resolved in favor of coverage. For a particular
296
+ product received by a particular user, "normally used" refers to a typical or
297
+ common use of that class of product, regardless of the status of the particular
298
+ user or of the way in which the particular user actually uses, or expects or is
299
+ expected to use, the product. A product is a consumer product regardless of
300
+ whether the product has substantial commercial, industrial or non-consumer uses,
301
+ unless such uses represent the only significant mode of use of the product.
302
+
303
+
304
+ "Installation Information" for a User Product means any methods, procedures,
305
+ authorization keys, or other information required to install and execute modified
306
+ versions of a covered work in that User Product from a modified version of its
307
+ Corresponding Source. The information must suffice to ensure that the continued
308
+ functioning of the modified object code is in no case prevented or interfered
309
+ with solely because modification has been made.
310
+
311
+ If you convey an object code
312
+ work under this section in, or with, or specifically for use in, a User Product,
313
+ and the conveying occurs as part of a transaction in which the right of
314
+ possession and use of the User Product is transferred to the recipient in
315
+ perpetuity or for a fixed term (regardless of how the transaction is
316
+ characterized), the Corresponding Source conveyed under this section must be
317
+ accompanied by the Installation Information. But this requirement does not apply
318
+ if neither you nor any third party retains the ability to install modified object
319
+ code on the User Product (for example, the work has been installed in ROM).
320
+
321
+
322
+ The requirement to provide Installation Information does not include a
323
+ requirement to continue to provide support service, warranty, or updates for a
324
+ work that has been modified or installed by the recipient, or for the User
325
+ Product in which it has been modified or installed. Access to a network may be
326
+ denied when the modification itself materially and adversely affects the
327
+ operation of the network or violates the rules and protocols for communication
328
+ across the network.
329
+
330
+ Corresponding Source conveyed, and Installation
331
+ Information provided, in accord with this section must be in a format that is
332
+ publicly documented (and with an implementation available to the public in source
333
+ code form), and must require no special password or key for unpacking, reading or
334
+ copying.
335
+
336
+ 7. Additional Terms.
337
+
338
+ "Additional permissions" are terms that
339
+ supplement the terms of this License by making exceptions from one or more of its
340
+ conditions. Additional permissions that are applicable to the entire Program
341
+ shall be treated as though they were included in this License, to the extent that
342
+ they are valid under applicable law. If additional permissions apply only to part
343
+ of the Program, that part may be used separately under those permissions, but the
344
+ entire Program remains governed by this License without regard to the additional
345
+ permissions.
346
+
347
+ When you convey a copy of a covered work, you may at your option
348
+ remove any additional permissions from that copy, or from any part of it.
349
+ (Additional permissions may be written to require their own removal in certain
350
+ cases when you modify the work.) You may place additional permissions on
351
+ material, added by you to a covered work, for which you have or can give
352
+ appropriate copyright permission.
353
+
354
+ Notwithstanding any other provision of this
355
+ License, for material you add to a covered work, you may (if authorized by the
356
+ copyright holders of that material) supplement the terms of this License with
357
+ terms:
358
+
359
+ a) Disclaiming warranty or limiting liability differently from the
360
+ terms of sections 15 and 16 of this License; or
361
+
362
+ b) Requiring preservation
363
+ of specified reasonable legal notices or author attributions in that material or
364
+ in the Appropriate Legal Notices displayed by works containing it; or
365
+
366
+ c)
367
+ Prohibiting misrepresentation of the origin of that material, or requiring that
368
+ modified versions of such material be marked in reasonable ways as different from
369
+ the original version; or
370
+
371
+ d) Limiting the use for publicity purposes of
372
+ names of licensors or authors of the material; or
373
+
374
+ e) Declining to grant
375
+ rights under trademark law for use of some trade names, trademarks, or service
376
+ marks; or
377
+
378
+ f) Requiring indemnification of licensors and authors of that
379
+ material by anyone who conveys the material (or modified versions of it) with
380
+ contractual assumptions of liability to the recipient, for any liability that
381
+ these contractual assumptions directly impose on those licensors and authors.
382
+
383
+
384
+ All other non-permissive additional terms are considered "further restrictions"
385
+ within the meaning of section 10. If the Program as you received it, or any part
386
+ of it, contains a notice stating that it is governed by this License along with a
387
+ term that is a further restriction, you may remove that term. If a license
388
+ document contains a further restriction but permits relicensing or conveying
389
+ under this License, you may add to a covered work material governed by the terms
390
+ of that license document, provided that the further restriction does not survive
391
+ such relicensing or conveying.
392
+
393
+ If you add terms to a covered work in accord
394
+ with this section, you must place, in the relevant source files, a statement of
395
+ the additional terms that apply to those files, or a notice indicating where to
396
+ find the applicable terms.
397
+
398
+ Additional terms, permissive or non-permissive,
399
+ may be stated in the form of a separately written license, or stated as
400
+ exceptions; the above requirements apply either way.
401
+
402
+ 8. Termination.
403
+
404
+ You
405
+ may not propagate or modify a covered work except as expressly provided under
406
+ this License. Any attempt otherwise to propagate or modify it is void, and will
407
+ automatically terminate your rights under this License (including any patent
408
+ licenses granted under the third paragraph of section 11).
409
+
410
+ However, if you
411
+ cease all violation of this License, then your license from a particular
412
+ copyright holder is reinstated (a) provisionally, unless and until the copyright
413
+ holder explicitly and finally terminates your license, and (b) permanently, if
414
+ the copyright holder fails to notify you of the violation by some reasonable
415
+ means prior to 60 days after the cessation.
416
+
417
+ Moreover, your license from a
418
+ particular copyright holder is reinstated permanently if the copyright holder
419
+ notifies you of the violation by some reasonable means, this is the first time
420
+ you have received notice of violation of this License (for any work) from that
421
+ copyright holder, and you cure the violation prior to 30 days after your receipt
422
+ of the notice.
423
+
424
+ Termination of your rights under this section does not
425
+ terminate the licenses of parties who have received copies or rights from you
426
+ under this License. If your rights have been terminated and not permanently
427
+ reinstated, you do not qualify to receive new licenses for the same material
428
+ under section 10.
429
+
430
+ 9. Acceptance Not Required for Having Copies.
431
+
432
+ You are
433
+ not required to accept this License in order to receive or run a copy of the
434
+ Program. Ancillary propagation of a covered work occurring solely as a
435
+ consequence of using peer-to-peer transmission to receive a copy likewise does
436
+ not require acceptance. However, nothing other than this License grants you
437
+ permission to propagate or modify any covered work. These actions infringe
438
+ copyright if you do not accept this License. Therefore, by modifying or
439
+ propagating a covered work, you indicate your acceptance of this License to do
440
+ so.
441
+
442
+ 10. Automatic Licensing of Downstream Recipients.
443
+
444
+ Each time you
445
+ convey a covered work, the recipient automatically receives a license from the
446
+ original licensors, to run, modify and propagate that work, subject to this
447
+ License. You are not responsible for enforcing compliance by third parties with
448
+ this License.
449
+
450
+ An "entity transaction" is a transaction transferring control
451
+ of an organization, or substantially all assets of one, or subdividing an
452
+ organization, or merging organizations. If propagation of a covered work results
453
+ from an entity transaction, each party to that transaction who receives a copy of
454
+ the work also receives whatever licenses to the work the party's predecessor in
455
+ interest had or could give under the previous paragraph, plus a right to
456
+ possession of the Corresponding Source of the work from the predecessor in
457
+ interest, if the predecessor has it or can get it with reasonable efforts.
458
+
459
+
460
+ You may not impose any further restrictions on the exercise of the rights granted
461
+ or affirmed under this License. For example, you may not impose a license fee,
462
+ royalty, or other charge for exercise of rights granted under this License, and
463
+ you may not initiate litigation (including a cross-claim or counterclaim in a
464
+ lawsuit) alleging that any patent claim is infringed by making, using, selling,
465
+ offering for sale, or importing the Program or any portion of it.
466
+
467
+ 11.
468
+ Patents.
469
+
470
+ A "contributor" is a copyright holder who authorizes use under this
471
+ License of the Program or a work on which the Program is based. The work thus
472
+ licensed is called the contributor's "contributor version".
473
+
474
+ A contributor's
475
+ "essential patent claims" are all patent claims owned or controlled by the
476
+ contributor, whether already acquired or hereafter acquired, that would be
477
+ infringed by some manner, permitted by this License, of making, using, or selling
478
+ its contributor version, but do not include claims that would be infringed only
479
+ as a consequence of further modification of the contributor version. For purposes
480
+ of this definition, "control" includes the right to grant patent sublicenses in a
481
+ manner consistent with the requirements of this License.
482
+
483
+ Each contributor
484
+ grants you a non-exclusive, worldwide, royalty-free patent license under the
485
+ contributor's essential patent claims, to make, use, sell, offer for sale, import
486
+ and otherwise run, modify and propagate the contents of its contributor
487
+ version.
488
+
489
+ In the following three paragraphs, a "patent license" is any express
490
+ agreement or commitment, however denominated, not to enforce a patent (such as an
491
+ express permission to practice a patent or covenant not to s ue for patent
492
+ infringement). To "grant" such a patent license to a party means to make such an
493
+ agreement or commitment not to enforce a patent against the party.
494
+
495
+ If you
496
+ convey a covered work, knowingly relying on a patent license, and the
497
+ Corresponding Source of the work is not available for anyone to copy, free of
498
+ charge and under the terms of this License, through a publicly available network
499
+ server or other readily accessible means, then you must either (1) cause the
500
+ Corresponding Source to be so available, or (2) arrange to deprive yourself of
501
+ the benefit of the patent license for this particular work, or (3) arrange, in a
502
+ manner consistent with the requirements of this License, to extend the patent
503
+
504
+
505
+ license to downstream recipients. "Knowingly relying" means you have actual
506
+ knowledge that, but for the patent license, your conveying the covered work in a
507
+ country, or your recipient's use of the covered work in a country, would infringe
508
+ one or more identifiable patents in that country that you have reason to believe
509
+ are valid.
510
+
511
+ If, pursuant to or in connection with a single transaction or
512
+ arrangement, you convey, or propagate by procuring conveyance of, a covered work,
513
+ and grant a patent license to some of the parties receiving the covered work
514
+ authorizing them to use, propagate, modify or convey a specific copy of the
515
+ covered work, then the patent license you grant is automatically extended to all
516
+ recipients of the covered work and works based on it.
517
+
518
+ A patent license is
519
+ "discriminatory" if it does not include within the scope of its coverage,
520
+ prohibits the exercise of, or is conditioned on the non-exercise of one or more
521
+ of the rights that are specifically granted under this License. You may not
522
+ convey a covered work if you are a party to an arrangement with a third party
523
+ that is in the business of distributing software, under which you make payment to
524
+ the third party based on the extent of your activity of conveying the work, and
525
+ under which the third party grants, to any of the parties who would receive the
526
+ covered work from you, a discriminatory patent license (a) in connection with
527
+ copies of the covered work conveyed by you (or copies made from those copies), or
528
+ (b) primarily for and in connection with specific products or compilations that
529
+ contain the covered work, unless you entered into that arrangement, or that
530
+ patent license was granted, prior to 28 March 2007.
531
+
532
+ Nothing in this License
533
+ shall be construed as excluding or limiting any implied license or other defenses
534
+ to infringement that may otherwise be available to you under applicable patent
535
+ law.
536
+
537
+ 12. No Surrender of Others' Freedom.
538
+
539
+ If conditions are imposed on
540
+ you (whether by court order, agreement or otherwise) that contradict the
541
+ conditions of this License, they do not excuse you from the conditions of this
542
+ License. If you cannot convey a covered work so as to satisfy simultaneously your
543
+ obligations under this License and any other pertinent obligations, then as a
544
+ consequence you may
545
+
546
+ not convey it at all. For example, if you agree to terms
547
+ that obligate you to collect a royalty for further conveying from those to whom
548
+ you convey the Program, the only way you could satisfy both those terms and this
549
+ License would be to refrain entirely from conveying the Program.
550
+
551
+ 13. Remote
552
+ Network Interaction; Use with the GNU General Public License.
553
+
554
+ Notwithstanding
555
+ any other provision of this License, if you modify the Program, your modified
556
+ version must prominently offer all users interacting with it remotely through a
557
+ computer network (if your version supports such interaction) an opportunity to
558
+ receive the Corresponding Source of your version by providing access to the
559
+ Corresponding Source from a network server at no charge, through some standard or
560
+ customary means of facilitating copying of software. This Corresponding Source
561
+ shall include the Corresponding Source for any work covered by version 3 of the
562
+ GNU General Public License that is incorporated pursuant to the following
563
+ paragraph.
564
+
565
+ Notwithstanding any other provision of this License, you have
566
+ permission to link or combine any covered work with a work licensed under version
567
+ 3 of the GNU General Public License into a single combined work, and to convey
568
+ the resulting work. The terms of this License will continue to apply to the part
569
+ which is the covered work, but the work with which it is combined will remain
570
+ governed by version 3 of the GNU General Public License.
571
+
572
+ 14. Revised Versions
573
+ of this License.
574
+
575
+ The Free Software Foundation may publish revised and/or new
576
+ versions of the GNU Affero General Public License from time to time. Such new
577
+ versions will be similar in spirit to the present version, but may differ in
578
+ detail to address new problems or concerns.
579
+
580
+ Each version is given a
581
+ distinguishing version number. If the Program specifies that a certain numbered
582
+ version of the GNU Affero General Public License "or any later version" applies
583
+ to it, you have the option of following the terms and conditions either of that
584
+ numbered version or of any later version published by the Free Software
585
+ Foundation. If the Program does not specify a version number of the GNU Affero
586
+ General Public License, you may choose any version ever published by the Free
587
+ Software Foundation.
588
+
589
+ If the Program specifies that a proxy can decide which
590
+ future versions of the GNU Affero General Public License can be used, that
591
+ proxy's public statement of acceptance of a version permanently authorizes you to
592
+ choose that version for the Program.
593
+
594
+ Later license versions may give you
595
+ additional or different permissions. However, no additional obligations are
596
+ imposed on any author or copyright holder as a result of your choosing to follow
597
+ a later version.
598
+
599
+ 15. Disclaimer of Warranty.
600
+
601
+ THERE IS NO WARRANTY FOR THE
602
+ PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED
603
+ IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS"
604
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
605
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
606
+ PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
607
+ PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
608
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
609
+
610
+ 16. Limitation of Liability.
611
+
612
+
613
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY
614
+ COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS
615
+ PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
616
+ INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
617
+ THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
618
+ INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
619
+ PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY
620
+ HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
621
+
622
+ 17. Interpretation of
623
+ Sections 15 and 16.
624
+
625
+ If the disclaimer of warranty and limitation of liability
626
+ provided above cannot be given local legal effect according to their terms,
627
+ reviewing courts shall apply local law that most closely approximates an absolute
628
+ waiver of all civil liability in connection with the Program, unless a warranty
629
+ or assumption of liability accompanies a copy of the Program in return for a fee.
630
+ END OF TERMS AND CONDITIONS
631
+
632
+ How to Apply These Terms to Your New Programs
633
+
634
+ If
635
+ you develop a new program, and you want it to be of the greatest possible use to
636
+ the public, the best way to achieve this is to make it free software which
637
+ everyone can redistribute and change under these terms.
638
+
639
+ To do so, attach the
640
+ following notices to the program. It is safest to attach them to the start of
641
+ each source file to most effectively state the exclusion of warranty; and each
642
+ file should have at least the "copyright" line and a pointer to where the full
643
+ notice is found.
644
+
645
+ <one line to give the program's name and a brief idea of what
646
+ it does.>
647
+
648
+ Copyright (C) 2025 <name of author>
649
+
650
+ This program is free software:
651
+ you can redistribute it and/or modify it under the terms of the GNU Affero
652
+ General Public License as published by the Free Software Foundation, either
653
+ version 3 of the License, or (at your option) any later version.
654
+
655
+ This program is
656
+ distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
657
+ even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
658
+ See the GNU Affero General Public License for more details.
659
+
660
+ You should have
661
+ received a copy of the GNU Affero General Public License along with this program.
662
+ If not, see <https://www.gnu.org/licenses/>.
663
+
664
+ Also add information on how to
665
+ contact you by electronic and paper mail.
666
+
667
+ If your software can interact with
668
+ users remotely through a computer network, you should also make sure that it
669
+ provides a way for users to get its source. For example, if your program is a web
670
+ application, its interface could display a "Source" link that leads users to an
671
+ archive of the code. There are many ways you could offer source, and different
672
+ solutions will be better for different programs; see section 13 for the specific
673
+ requirements.
674
+
675
+ You should also get your employer (if you work as a programmer) or
676
+ school, if any, to sign a "copyright disclaimer" for the program, if necessary.
677
+ For more information on this, and how to apply and follow the GNU AGPL, see
678
+ <https://www.gnu.org/licenses/>.
@@ -0,0 +1,110 @@
1
+ //#region src/embed.d.ts
2
+ interface ExportFormatMap {
3
+ xstate: {
4
+ options: {
5
+ version?: 4 | 5;
6
+ addTSTypes?: boolean;
7
+ showIds?: boolean;
8
+ showDescriptions?: boolean;
9
+ };
10
+ result: string;
11
+ };
12
+ json: {
13
+ options: {
14
+ simplifyArrays?: boolean;
15
+ version?: 4 | 5;
16
+ };
17
+ result: Record<string, unknown>;
18
+ };
19
+ digraph: {
20
+ options: Record<string, never>;
21
+ result: Record<string, unknown>;
22
+ };
23
+ mermaid: {
24
+ options: Record<string, never>;
25
+ result: string;
26
+ };
27
+ scxml: {
28
+ options: Record<string, never>;
29
+ result: string;
30
+ };
31
+ }
32
+ type ExportFormat = keyof ExportFormatMap;
33
+ type ExportCallOptions<F extends ExportFormat> = ExportFormatMap[F]['options'] & {
34
+ timeout?: number;
35
+ };
36
+ type EmbedMode = 'editing' | 'viewing' | 'simulating';
37
+ interface InitOptions {
38
+ machine: unknown;
39
+ format?: string;
40
+ mode?: EmbedMode;
41
+ theme?: 'light' | 'dark';
42
+ readOnly?: boolean;
43
+ depth?: number;
44
+ panels?: {
45
+ leftPanels?: string[];
46
+ rightPanels?: string[];
47
+ activePanels?: string[];
48
+ };
49
+ }
50
+ interface EmbedEventMap {
51
+ ready: {
52
+ version: string;
53
+ };
54
+ loaded: {
55
+ graph: unknown;
56
+ };
57
+ change: {
58
+ graph: unknown;
59
+ machineConfig: unknown;
60
+ };
61
+ save: {
62
+ graph: unknown;
63
+ machineConfig: unknown;
64
+ };
65
+ error: {
66
+ code: string;
67
+ message: string;
68
+ };
69
+ }
70
+ type EmbedEventName = keyof EmbedEventMap;
71
+ type EmbedEventHandler<K extends EmbedEventName> = (data: EmbedEventMap[K]) => void;
72
+ interface StatelyEmbedOptions {
73
+ baseUrl: string;
74
+ origin?: string;
75
+ onReady?: () => void;
76
+ onLoaded?: (graph: unknown) => void;
77
+ onChange?: (graph: unknown, machineConfig: unknown) => void;
78
+ onSave?: (graph: unknown, machineConfig: unknown) => void;
79
+ onError?: (error: {
80
+ code: string;
81
+ message: string;
82
+ }) => void;
83
+ }
84
+ interface StatelyEmbed {
85
+ /** Attach to an existing iframe element. Sets src and begins handshake. */
86
+ attach(iframe: HTMLIFrameElement): void;
87
+ /** Create an iframe and mount it into a container element. */
88
+ mount(container: HTMLElement): HTMLIFrameElement;
89
+ /** Send init message (queued if iframe not ready yet). */
90
+ init(options: InitOptions): void;
91
+ /** Update the machine (shorthand for update message). */
92
+ updateMachine(machine: unknown, format?: string): void;
93
+ /** Change the embed mode. */
94
+ setMode(mode: EmbedMode): void;
95
+ /** Change the embed theme. */
96
+ setTheme(theme: 'light' | 'dark'): void;
97
+ /** Export the current machine in a given format. Returns a promise. */
98
+ export<F extends ExportFormat>(format: F, options?: ExportCallOptions<F>): Promise<ExportFormatMap[F]['result']>;
99
+ /** Subscribe to an embed event. */
100
+ on<K extends EmbedEventName>(event: K, handler: EmbedEventHandler<K>): void;
101
+ /** Unsubscribe from an embed event. */
102
+ off<K extends EmbedEventName>(event: K, handler: EmbedEventHandler<K>): void;
103
+ /** Show a toast message in the embed. */
104
+ toast(message: string, toastType?: 'success' | 'error' | 'info' | 'warning'): void;
105
+ /** Tear down: remove listener, reject pending promises, optionally remove iframe. */
106
+ destroy(): void;
107
+ }
108
+ declare function createStatelyEmbed(options: StatelyEmbedOptions): StatelyEmbed;
109
+ //#endregion
110
+ export { type EmbedEventMap, type EmbedMode, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type InitOptions, type StatelyEmbed, type StatelyEmbedOptions, createStatelyEmbed };
package/dist/index.mjs ADDED
@@ -0,0 +1,200 @@
1
+ //#region src/embed.ts
2
+ const PREFIX = "@statelyai.";
3
+ function createStatelyEmbed(options) {
4
+ const embedUrl = options.baseUrl.replace(/\/+$/, "") + "/embed";
5
+ const targetOrigin = options.origin ?? new URL(embedUrl).origin;
6
+ let iframe = null;
7
+ let ownedIframe = false;
8
+ let ready = false;
9
+ let destroyed = false;
10
+ const pendingMessages = [];
11
+ let pendingExport = null;
12
+ const jsonResultFormats = new Set(["digraph", "json"]);
13
+ const listeners = {};
14
+ function emit(event, data) {
15
+ const set = listeners[event];
16
+ if (set) set.forEach((fn) => fn(data));
17
+ }
18
+ function send(msg) {
19
+ if (!ready) {
20
+ pendingMessages.push(msg);
21
+ return;
22
+ }
23
+ iframe?.contentWindow?.postMessage(msg, targetOrigin);
24
+ }
25
+ function flush() {
26
+ while (pendingMessages.length > 0) {
27
+ const msg = pendingMessages.shift();
28
+ iframe?.contentWindow?.postMessage(msg, targetOrigin);
29
+ }
30
+ }
31
+ function handleMessage(e) {
32
+ if (destroyed) return;
33
+ if (e.source !== iframe?.contentWindow) return;
34
+ const data = e.data;
35
+ if (!data?.type?.startsWith?.(PREFIX)) return;
36
+ switch (data.type) {
37
+ case "@statelyai.ready":
38
+ ready = true;
39
+ flush();
40
+ options.onReady?.();
41
+ emit("ready", { version: data.version });
42
+ break;
43
+ case "@statelyai.loaded":
44
+ options.onLoaded?.(data.graph);
45
+ emit("loaded", { graph: data.graph });
46
+ break;
47
+ case "@statelyai.change":
48
+ options.onChange?.(data.graph, data.machineConfig);
49
+ emit("change", {
50
+ graph: data.graph,
51
+ machineConfig: data.machineConfig
52
+ });
53
+ break;
54
+ case "@statelyai.save":
55
+ options.onSave?.(data.graph, data.machineConfig);
56
+ emit("save", {
57
+ graph: data.graph,
58
+ machineConfig: data.machineConfig
59
+ });
60
+ break;
61
+ case "@statelyai.retrieved":
62
+ if (pendingExport) {
63
+ clearTimeout(pendingExport.timer);
64
+ let result = data.data;
65
+ if (jsonResultFormats.has(pendingExport.format) && typeof result === "string") result = JSON.parse(result);
66
+ pendingExport.resolve(result);
67
+ pendingExport = null;
68
+ }
69
+ break;
70
+ case "@statelyai.error": {
71
+ const err = {
72
+ code: data.code,
73
+ message: data.message
74
+ };
75
+ options.onError?.(err);
76
+ emit("error", err);
77
+ break;
78
+ }
79
+ }
80
+ }
81
+ function startListening() {
82
+ window.addEventListener("message", handleMessage);
83
+ }
84
+ return {
85
+ attach(el) {
86
+ if (destroyed) return;
87
+ iframe = el;
88
+ ownedIframe = false;
89
+ ready = false;
90
+ el.src = embedUrl;
91
+ startListening();
92
+ },
93
+ mount(container) {
94
+ if (destroyed) throw new Error("Embed is destroyed");
95
+ const el = document.createElement("iframe");
96
+ el.src = embedUrl;
97
+ el.style.border = "none";
98
+ el.style.width = "100%";
99
+ el.style.height = "100%";
100
+ el.setAttribute("sandbox", "allow-scripts allow-same-origin");
101
+ el.setAttribute("allow", "clipboard-read; clipboard-write");
102
+ container.appendChild(el);
103
+ iframe = el;
104
+ ownedIframe = true;
105
+ ready = false;
106
+ startListening();
107
+ return el;
108
+ },
109
+ init(opts) {
110
+ send({
111
+ type: "@statelyai.init",
112
+ machine: opts.machine,
113
+ format: opts.format,
114
+ mode: opts.mode,
115
+ theme: opts.theme,
116
+ readOnly: opts.readOnly,
117
+ depth: opts.depth,
118
+ leftPanels: opts.panels?.leftPanels,
119
+ rightPanels: opts.panels?.rightPanels,
120
+ activePanels: opts.panels?.activePanels
121
+ });
122
+ },
123
+ updateMachine(machine, format) {
124
+ send({
125
+ type: "@statelyai.update",
126
+ machine,
127
+ format
128
+ });
129
+ },
130
+ setMode(mode) {
131
+ send({
132
+ type: "@statelyai.setMode",
133
+ mode
134
+ });
135
+ },
136
+ setTheme(theme) {
137
+ send({
138
+ type: "@statelyai.setTheme",
139
+ theme
140
+ });
141
+ },
142
+ toast(message, toastType) {
143
+ send({
144
+ type: "@statelyai.toast",
145
+ message,
146
+ toastType
147
+ });
148
+ },
149
+ export(format, options) {
150
+ const { timeout = 1e4, ...formatOptions } = options ?? {};
151
+ return new Promise((resolve, reject) => {
152
+ if (destroyed) {
153
+ reject(/* @__PURE__ */ new Error("Embed is destroyed"));
154
+ return;
155
+ }
156
+ if (pendingExport) {
157
+ clearTimeout(pendingExport.timer);
158
+ pendingExport.reject(/* @__PURE__ */ new Error("Superseded by new export"));
159
+ }
160
+ pendingExport = {
161
+ resolve,
162
+ reject,
163
+ timer: setTimeout(() => {
164
+ pendingExport = null;
165
+ reject(/* @__PURE__ */ new Error("Export timed out"));
166
+ }, timeout),
167
+ format
168
+ };
169
+ send({
170
+ type: "@statelyai.retrieve",
171
+ format,
172
+ ...Object.keys(formatOptions).length > 0 && { options: formatOptions }
173
+ });
174
+ });
175
+ },
176
+ on(event, handler) {
177
+ if (!listeners[event]) listeners[event] = /* @__PURE__ */ new Set();
178
+ listeners[event].add(handler);
179
+ },
180
+ off(event, handler) {
181
+ listeners[event]?.delete(handler);
182
+ },
183
+ destroy() {
184
+ if (destroyed) return;
185
+ destroyed = true;
186
+ window.removeEventListener("message", handleMessage);
187
+ if (pendingExport) {
188
+ clearTimeout(pendingExport.timer);
189
+ pendingExport.reject(/* @__PURE__ */ new Error("Embed destroyed"));
190
+ pendingExport = null;
191
+ }
192
+ pendingMessages.length = 0;
193
+ if (ownedIframe && iframe) iframe.remove();
194
+ iframe = null;
195
+ }
196
+ };
197
+ }
198
+
199
+ //#endregion
200
+ export { createStatelyEmbed };
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@statelyai/sdk",
3
+ "version": "0.0.1",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "main": "./dist/index.mjs",
7
+ "types": "./dist/index.d.mts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "types": "./dist/index.d.mts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "devDependencies": {
18
+ "tsdown": "0.21.0-beta.2",
19
+ "typescript": "^5.9.3"
20
+ },
21
+ "scripts": {
22
+ "build": "tsdown"
23
+ }
24
+ }