@reasonlayer/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 +201 -0
- package/README.md +35 -0
- package/bin/rl.mjs +75 -0
- package/dist/builder.d.ts +38 -0
- package/dist/builder.js +41 -0
- package/dist/bundler/index.d.ts +32 -0
- package/dist/bundler/index.js +143 -0
- package/dist/bundler/lint.d.ts +13 -0
- package/dist/bundler/lint.js +74 -0
- package/dist/bundler/node.d.ts +10 -0
- package/dist/bundler/node.js +55 -0
- package/dist/bundler/smoke.d.ts +12 -0
- package/dist/bundler/smoke.js +70 -0
- package/dist/bundler/worker.d.ts +31 -0
- package/dist/bundler/worker.js +214 -0
- package/dist/cli/args.d.ts +9 -0
- package/dist/cli/args.js +71 -0
- package/dist/cli/config.d.ts +38 -0
- package/dist/cli/config.js +94 -0
- package/dist/cli/convex.d.ts +9 -0
- package/dist/cli/convex.js +25 -0
- package/dist/cli/format.d.ts +11 -0
- package/dist/cli/format.js +140 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +721 -0
- package/dist/cli/keychain.d.ts +21 -0
- package/dist/cli/keychain.js +100 -0
- package/dist/cli/login-browser.d.ts +22 -0
- package/dist/cli/login-browser.js +106 -0
- package/dist/cli/mcp.d.ts +3 -0
- package/dist/cli/mcp.js +36 -0
- package/dist/cli/operations.d.ts +106 -0
- package/dist/cli/operations.js +623 -0
- package/dist/cli/sdk-package.d.ts +18 -0
- package/dist/cli/sdk-package.js +45 -0
- package/dist/cli/storage-upload.d.ts +9 -0
- package/dist/cli/storage-upload.js +21 -0
- package/dist/cli/watcher-compile.d.ts +1 -0
- package/dist/cli/watcher-compile.js +20 -0
- package/dist/cli/watcher-process.d.ts +1 -0
- package/dist/cli/watcher-process.js +312 -0
- package/dist/cli/worker-host.d.ts +10 -0
- package/dist/cli/worker-host.js +120 -0
- package/dist/cli/workspace-files.d.ts +12 -0
- package/dist/cli/workspace-files.js +91 -0
- package/dist/cli/workspace-local.d.ts +27 -0
- package/dist/cli/workspace-local.js +310 -0
- package/dist/cli/workspace-session.d.ts +13 -0
- package/dist/cli/workspace-session.js +12 -0
- package/dist/compile.d.ts +27 -0
- package/dist/compile.js +834 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +5 -0
- package/dist/schedule-validation.d.ts +1 -0
- package/dist/schedule-validation.js +16 -0
- package/dist/selector-schema.d.ts +26 -0
- package/dist/selector-schema.js +780 -0
- package/dist/selectors.d.ts +25 -0
- package/dist/selectors.js +99 -0
- package/dist/testkit.d.ts +32 -0
- package/dist/testkit.js +161 -0
- package/dist/types.d.ts +184 -0
- package/dist/types.js +110 -0
- package/node_modules/@reasonlayer/integrations/dist/catalog.d.ts +4937 -0
- package/node_modules/@reasonlayer/integrations/dist/catalog.js +20 -0
- package/node_modules/@reasonlayer/integrations/dist/generated/slack.d.ts +3014 -0
- package/node_modules/@reasonlayer/integrations/dist/generated/slack.js +3101 -0
- package/node_modules/@reasonlayer/integrations/dist/index.d.ts +2 -0
- package/node_modules/@reasonlayer/integrations/dist/index.js +1 -0
- package/node_modules/@reasonlayer/integrations/dist/internal/definitions.d.ts +44 -0
- package/node_modules/@reasonlayer/integrations/dist/internal/definitions.js +52 -0
- package/node_modules/@reasonlayer/integrations/dist/internal/transport.d.ts +7 -0
- package/node_modules/@reasonlayer/integrations/dist/internal/transport.js +48 -0
- package/node_modules/@reasonlayer/integrations/dist/testkit.d.ts +1 -0
- package/node_modules/@reasonlayer/integrations/dist/testkit.js +1 -0
- package/node_modules/@reasonlayer/integrations/package.json +26 -0
- package/node_modules/@reasonlayer/protocol/dist/dispatch.d.ts +10 -0
- package/node_modules/@reasonlayer/protocol/dist/dispatch.js +58 -0
- package/node_modules/@reasonlayer/protocol/dist/envelope.d.ts +9 -0
- package/node_modules/@reasonlayer/protocol/dist/envelope.js +1 -0
- package/node_modules/@reasonlayer/protocol/dist/environments.d.ts +7 -0
- package/node_modules/@reasonlayer/protocol/dist/environments.js +7 -0
- package/node_modules/@reasonlayer/protocol/dist/events.d.ts +313 -0
- package/node_modules/@reasonlayer/protocol/dist/events.js +20 -0
- package/node_modules/@reasonlayer/protocol/dist/index.d.ts +18 -0
- package/node_modules/@reasonlayer/protocol/dist/index.js +9 -0
- package/node_modules/@reasonlayer/protocol/dist/ir.d.ts +252 -0
- package/node_modules/@reasonlayer/protocol/dist/ir.js +116 -0
- package/node_modules/@reasonlayer/protocol/dist/permissions.d.ts +5 -0
- package/node_modules/@reasonlayer/protocol/dist/permissions.js +30 -0
- package/node_modules/@reasonlayer/protocol/dist/readmodels.d.ts +617 -0
- package/node_modules/@reasonlayer/protocol/dist/readmodels.js +36 -0
- package/node_modules/@reasonlayer/protocol/dist/runtime.d.ts +67 -0
- package/node_modules/@reasonlayer/protocol/dist/runtime.js +66 -0
- package/node_modules/@reasonlayer/protocol/dist/scheduling.d.ts +69 -0
- package/node_modules/@reasonlayer/protocol/dist/scheduling.js +126 -0
- package/node_modules/@reasonlayer/protocol/dist/selector.d.ts +23 -0
- package/node_modules/@reasonlayer/protocol/dist/selector.js +77 -0
- package/node_modules/@reasonlayer/protocol/dist/tasks.d.ts +69 -0
- package/node_modules/@reasonlayer/protocol/dist/tasks.js +6 -0
- package/node_modules/@reasonlayer/protocol/dist/validate.d.ts +6 -0
- package/node_modules/@reasonlayer/protocol/dist/validate.js +18 -0
- package/node_modules/@reasonlayer/protocol/package.json +21 -0
- package/node_modules/@reasonlayer/runner/dist/environment-materializer.d.ts +13 -0
- package/node_modules/@reasonlayer/runner/dist/environment-materializer.js +92 -0
- package/node_modules/@reasonlayer/runner/dist/flue-transcript.d.ts +17 -0
- package/node_modules/@reasonlayer/runner/dist/flue-transcript.js +182 -0
- package/node_modules/@reasonlayer/runner/dist/index.d.ts +184 -0
- package/node_modules/@reasonlayer/runner/dist/index.js +884 -0
- package/node_modules/@reasonlayer/runner/dist/mcp-supervisor.d.ts +15 -0
- package/node_modules/@reasonlayer/runner/dist/mcp-supervisor.js +142 -0
- package/node_modules/@reasonlayer/runner/dist/sandbox-env.d.ts +36 -0
- package/node_modules/@reasonlayer/runner/dist/sandbox-env.js +171 -0
- package/node_modules/@reasonlayer/runner/dist/task-child.d.ts +1 -0
- package/node_modules/@reasonlayer/runner/dist/task-child.js +72 -0
- package/node_modules/@reasonlayer/runner/package.json +21 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Overclock Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @reasonlayer/sdk
|
|
2
|
+
|
|
3
|
+
Author, validate, and compile workflows for Reasonlayer.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @reasonlayer/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Define a workflow
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { defineWorkflow, v } from "@reasonlayer/sdk";
|
|
15
|
+
|
|
16
|
+
export default defineWorkflow({
|
|
17
|
+
id: "hello",
|
|
18
|
+
input: v.object({ name: v.string() }),
|
|
19
|
+
output: v.object({ greeting: v.string() }),
|
|
20
|
+
})
|
|
21
|
+
.code("greet", {
|
|
22
|
+
output: v.object({ greeting: v.string() }),
|
|
23
|
+
run: ({ name }: { name: string }) => ({ greeting: `Hello, ${name}` }),
|
|
24
|
+
host: { kind: "cloud" },
|
|
25
|
+
})
|
|
26
|
+
.output((steps) => steps.greet);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Build
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
npx rl build workflow.ts --out-dir dist
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The build writes the workflow IR and executable step bundles to `dist/`.
|
package/bin/rl.mjs
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { realpath } from "node:fs/promises";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
async function findCheckoutCli(cwd, ownCliPath) {
|
|
8
|
+
const ownRealPath = await realpath(ownCliPath);
|
|
9
|
+
let current = resolve(cwd);
|
|
10
|
+
for (;;) {
|
|
11
|
+
const candidate = join(current, "node_modules", "@reasonlayer", "sdk", "bin", "rl.mjs");
|
|
12
|
+
try {
|
|
13
|
+
const candidateRealPath = await realpath(candidate);
|
|
14
|
+
if (candidateRealPath === ownRealPath) return undefined;
|
|
15
|
+
return candidate;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
if (error?.code !== "ENOENT") throw error;
|
|
18
|
+
}
|
|
19
|
+
const parent = dirname(current);
|
|
20
|
+
if (parent === current) return undefined;
|
|
21
|
+
current = parent;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function forwardSignals(child) {
|
|
26
|
+
const handlers = new Map();
|
|
27
|
+
const remove = () => {
|
|
28
|
+
for (const [signal, handler] of handlers) process.off(signal, handler);
|
|
29
|
+
};
|
|
30
|
+
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
31
|
+
const handler = () => child.kill(signal);
|
|
32
|
+
handlers.set(signal, handler);
|
|
33
|
+
process.on(signal, handler);
|
|
34
|
+
}
|
|
35
|
+
child.once("close", remove);
|
|
36
|
+
child.once("error", remove);
|
|
37
|
+
return remove;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function runCheckoutCli(path) {
|
|
41
|
+
const result = await new Promise((resolveRun, rejectRun) => {
|
|
42
|
+
const child = spawn(process.execPath, [path, ...process.argv.slice(2)], {
|
|
43
|
+
cwd: process.cwd(),
|
|
44
|
+
env: process.env,
|
|
45
|
+
stdio: "inherit",
|
|
46
|
+
});
|
|
47
|
+
const removeSignalHandlers = forwardSignals(child);
|
|
48
|
+
child.once("error", rejectRun);
|
|
49
|
+
child.once("close", (code, signal) => {
|
|
50
|
+
removeSignalHandlers();
|
|
51
|
+
resolveRun({ code: code ?? 1, signal });
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
if (result.signal) {
|
|
55
|
+
process.kill(process.pid, result.signal);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
process.exitCode = result.code;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function main() {
|
|
62
|
+
const ownCliPath = fileURLToPath(import.meta.url);
|
|
63
|
+
const checkoutCli = await findCheckoutCli(process.cwd(), ownCliPath);
|
|
64
|
+
if (checkoutCli) {
|
|
65
|
+
await runCheckoutCli(checkoutCli);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const { main: runCli } = await import("../dist/cli/index.js");
|
|
69
|
+
process.exitCode = await runCli(process.argv.slice(2));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
main().catch((error) => {
|
|
73
|
+
process.stderr.write(`rl: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
74
|
+
process.exitCode = 1;
|
|
75
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The accumulated workflow builder (spec §4). Declaration order is the type
|
|
3
|
+
* boundary: each step wires only to earlier steps; the builder is immutable —
|
|
4
|
+
* every step method returns a fresh builder.
|
|
5
|
+
*/
|
|
6
|
+
import type { CatalogActionDescriptor, CatalogActionOutput } from "@reasonlayer/integrations";
|
|
7
|
+
import type { ActionStepConfig, AgentStepConfig, AnySchema, ChildAgentStepConfig, ChildCodeStepConfig, ChildReviewStepConfig, ChildStepDef, CodeStepConfig, MapStepConfig, Out, ReviewStepConfig, WorkflowConfig, WorkflowDefinition } from "./types.js";
|
|
8
|
+
import type { StepsOf } from "./types.js";
|
|
9
|
+
import type { Wire } from "./selectors.js";
|
|
10
|
+
type CodeBuilderMethod<Input, Output, Steps extends Record<string, unknown>> = <Id extends string, TIn, OutS extends AnySchema>(id: Id extends keyof Steps ? never : Id, config: CodeStepConfig<Steps, Input, TIn, OutS>) => WorkflowBuilder<Input, Output, Steps & {
|
|
11
|
+
[K in Id]: Out<OutS>;
|
|
12
|
+
}>;
|
|
13
|
+
type AgentBuilderMethod<Input, Output, Steps extends Record<string, unknown>> = <Id extends string, TIn, OutS extends AnySchema>(id: Id extends keyof Steps ? never : Id, config: AgentStepConfig<Steps, Input, TIn, OutS>) => WorkflowBuilder<Input, Output, Steps & {
|
|
14
|
+
[K in Id]: Out<OutS>;
|
|
15
|
+
}>;
|
|
16
|
+
type ActionBuilderMethod<Input, Output, Steps extends Record<string, unknown>> = <Id extends string, Action extends CatalogActionDescriptor>(id: Id extends keyof Steps ? never : Id, config: ActionStepConfig<Steps, Input, Action>) => WorkflowBuilder<Input, Output, Steps & {
|
|
17
|
+
[K in Id]: CatalogActionOutput<Action>;
|
|
18
|
+
}>;
|
|
19
|
+
type ReviewBuilderMethod<Input, Output, Steps extends Record<string, unknown>> = <Id extends string, OutS extends AnySchema>(id: Id extends keyof Steps ? never : Id, config: ReviewStepConfig<Steps, Input, OutS>) => WorkflowBuilder<Input, Output, Steps & {
|
|
20
|
+
[K in Id]: Out<OutS>;
|
|
21
|
+
}>;
|
|
22
|
+
type MapBuilderMethod<Input, Output, Steps extends Record<string, unknown>> = <Id extends string, Item, ChildOutS extends AnySchema>(id: Id extends keyof Steps ? never : Id, config: MapStepConfig<Steps, Input, Item, ChildOutS>) => WorkflowBuilder<Input, Output, Steps & {
|
|
23
|
+
[K in Id]: Out<ChildOutS>[];
|
|
24
|
+
}>;
|
|
25
|
+
export interface WorkflowBuilder<Input, Output, Steps extends Record<string, unknown>> {
|
|
26
|
+
code: CodeBuilderMethod<Input, Output, Steps>;
|
|
27
|
+
agent: AgentBuilderMethod<Input, Output, Steps>;
|
|
28
|
+
action: ActionBuilderMethod<Input, Output, Steps>;
|
|
29
|
+
review: ReviewBuilderMethod<Input, Output, Steps>;
|
|
30
|
+
map: MapBuilderMethod<Input, Output, Steps>;
|
|
31
|
+
output(wiring: (steps: StepsOf<Steps>, input: Wire<Input>) => Wire<Output>): WorkflowDefinition<Input, Output>;
|
|
32
|
+
}
|
|
33
|
+
export declare function defineWorkflow<InS extends AnySchema, OutS extends AnySchema>(config: WorkflowConfig<InS, OutS>): WorkflowBuilder<Out<InS>, Out<OutS>, {}>;
|
|
34
|
+
/** Standalone child-step constructors, used inside `map` (spec §4.1). */
|
|
35
|
+
export declare function code<TIn, OutS extends AnySchema>(config: ChildCodeStepConfig<TIn, OutS>): ChildStepDef<OutS>;
|
|
36
|
+
export declare function agent<TIn, OutS extends AnySchema>(config: ChildAgentStepConfig<TIn, OutS>): ChildStepDef<OutS>;
|
|
37
|
+
export declare function review<OutS extends AnySchema>(config: ChildReviewStepConfig<OutS>): ChildStepDef<OutS>;
|
|
38
|
+
export {};
|
package/dist/builder.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The accumulated workflow builder (spec §4). Declaration order is the type
|
|
3
|
+
* boundary: each step wires only to earlier steps; the builder is immutable —
|
|
4
|
+
* every step method returns a fresh builder.
|
|
5
|
+
*/
|
|
6
|
+
function makeBuilder(config, steps) {
|
|
7
|
+
const add = (kind) => (id, stepConfig) => makeBuilder(config, [...steps, { kind, id, config: stepConfig }]);
|
|
8
|
+
const code = add("code");
|
|
9
|
+
const agent = add("agent");
|
|
10
|
+
const action = add("action");
|
|
11
|
+
const review = add("review");
|
|
12
|
+
const map = add("map");
|
|
13
|
+
return {
|
|
14
|
+
code,
|
|
15
|
+
agent,
|
|
16
|
+
action,
|
|
17
|
+
review,
|
|
18
|
+
map,
|
|
19
|
+
output(wiring) {
|
|
20
|
+
return {
|
|
21
|
+
__rlWorkflow: true,
|
|
22
|
+
config,
|
|
23
|
+
steps,
|
|
24
|
+
outputWiring: wiring,
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function defineWorkflow(config) {
|
|
30
|
+
return makeBuilder(config, []);
|
|
31
|
+
}
|
|
32
|
+
/** Standalone child-step constructors, used inside `map` (spec §4.1). */
|
|
33
|
+
export function code(config) {
|
|
34
|
+
return { __rlChildStep: "code", config };
|
|
35
|
+
}
|
|
36
|
+
export function agent(config) {
|
|
37
|
+
return { __rlChildStep: "agent", config };
|
|
38
|
+
}
|
|
39
|
+
export function review(config) {
|
|
40
|
+
return { __rlChildStep: "review", config };
|
|
41
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* rl build (spec §4.4): entry file → dist/{ir.json, steps.js,
|
|
3
|
+
* agents.js?, manifest.json}. Compile errors surface here, at build time.
|
|
4
|
+
*/
|
|
5
|
+
import { type WorkflowIR } from "@reasonlayer/protocol";
|
|
6
|
+
import { type CompileError } from "../types.js";
|
|
7
|
+
export interface BuildManifest {
|
|
8
|
+
workflowId: string;
|
|
9
|
+
stepIds: string[];
|
|
10
|
+
/** Code steps served by cloud/device runners. */
|
|
11
|
+
codeStepIds: string[];
|
|
12
|
+
/** Agent steps served by cloud/device runners. */
|
|
13
|
+
agentStepIds: string[];
|
|
14
|
+
environmentHashes: string[];
|
|
15
|
+
artifacts: {
|
|
16
|
+
ir: string;
|
|
17
|
+
steps: string;
|
|
18
|
+
agents?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export type BuildResult = {
|
|
22
|
+
ok: true;
|
|
23
|
+
ir: WorkflowIR;
|
|
24
|
+
outDir: string;
|
|
25
|
+
manifest: BuildManifest;
|
|
26
|
+
flueVersion?: string;
|
|
27
|
+
} | {
|
|
28
|
+
ok: false;
|
|
29
|
+
errors: CompileError[];
|
|
30
|
+
};
|
|
31
|
+
export declare function buildWorkflow(entry: string, outDir: string): Promise<BuildResult>;
|
|
32
|
+
export { buildAgentsBundle, buildStepsBundle } from "./node.js";
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* rl build (spec §4.4): entry file → dist/{ir.json, steps.js,
|
|
3
|
+
* agents.js?, manifest.json}. Compile errors surface here, at build time.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { readFile } from "node:fs/promises";
|
|
7
|
+
import { dirname, join, parse, resolve } from "node:path";
|
|
8
|
+
import { pathToFileURL } from "node:url";
|
|
9
|
+
import * as esbuild from "esbuild";
|
|
10
|
+
import { collectWorkflowEnvironments, } from "@reasonlayer/protocol";
|
|
11
|
+
import { compileWorkflow } from "../compile.js";
|
|
12
|
+
import { resetVariableRegistryForTests } from "../types.js";
|
|
13
|
+
import { buildAgentsBundle, buildStepsBundle } from "./node.js";
|
|
14
|
+
function collectCodeStepIds(ir) {
|
|
15
|
+
const ids = [];
|
|
16
|
+
for (const step of Object.values(ir.steps)) {
|
|
17
|
+
if (step.kind === "code")
|
|
18
|
+
ids.push(step.id);
|
|
19
|
+
if (step.kind === "map" && step.step.kind === "code")
|
|
20
|
+
ids.push(step.step.id);
|
|
21
|
+
}
|
|
22
|
+
return ids;
|
|
23
|
+
}
|
|
24
|
+
function collectAgentStepIds(ir) {
|
|
25
|
+
const ids = [];
|
|
26
|
+
for (const step of Object.values(ir.steps)) {
|
|
27
|
+
if (step.kind === "agent")
|
|
28
|
+
ids.push(step.id);
|
|
29
|
+
if (step.kind === "map" && step.step.kind === "agent")
|
|
30
|
+
ids.push(step.step.id);
|
|
31
|
+
}
|
|
32
|
+
return ids;
|
|
33
|
+
}
|
|
34
|
+
async function readVersion(packagePath) {
|
|
35
|
+
try {
|
|
36
|
+
const parsed = JSON.parse(await readFile(packagePath, "utf8"));
|
|
37
|
+
return typeof parsed.version === "string" && parsed.version.length > 0
|
|
38
|
+
? parsed.version
|
|
39
|
+
: undefined;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The Flue runtime the checkout compiled against, recorded for diagnosis only —
|
|
47
|
+
* so an unreadable or malformed package.json yields no version rather than
|
|
48
|
+
* failing the build. Stops at the checkout root instead of climbing to `/`,
|
|
49
|
+
* where an unrelated install would be recorded as the one that compiled.
|
|
50
|
+
*/
|
|
51
|
+
async function resolveFlueVersion(entryPath) {
|
|
52
|
+
let current = dirname(entryPath);
|
|
53
|
+
const root = parse(current).root;
|
|
54
|
+
for (;;) {
|
|
55
|
+
const version = await readVersion(join(current, "node_modules", "@flue", "runtime", "package.json"));
|
|
56
|
+
if (version !== undefined)
|
|
57
|
+
return version;
|
|
58
|
+
if (current === root || existsSync(join(current, "package.json")))
|
|
59
|
+
return undefined;
|
|
60
|
+
current = dirname(current);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function importDefinition(entryPath, tmpDir) {
|
|
64
|
+
const outfile = join(tmpDir, `workflow-${process.hrtime.bigint()}.mjs`);
|
|
65
|
+
const result = await esbuild.build({
|
|
66
|
+
entryPoints: [entryPath],
|
|
67
|
+
bundle: true,
|
|
68
|
+
format: "esm",
|
|
69
|
+
platform: "node",
|
|
70
|
+
target: "node22",
|
|
71
|
+
outfile,
|
|
72
|
+
logLevel: "silent",
|
|
73
|
+
write: true,
|
|
74
|
+
});
|
|
75
|
+
if (result.errors.length > 0) {
|
|
76
|
+
throw new Error(result.errors.map((e) => e.text).join("; "));
|
|
77
|
+
}
|
|
78
|
+
const mod = (await import(pathToFileURL(outfile).href));
|
|
79
|
+
const definition = mod.default;
|
|
80
|
+
if (!definition || definition.__rlWorkflow !== true) {
|
|
81
|
+
throw new Error(`${entryPath} must default-export a workflow built with defineWorkflow(...).output(...)`);
|
|
82
|
+
}
|
|
83
|
+
return definition;
|
|
84
|
+
}
|
|
85
|
+
export async function buildWorkflow(entry, outDir) {
|
|
86
|
+
const entryPath = resolve(entry);
|
|
87
|
+
const dist = resolve(outDir);
|
|
88
|
+
const tmpDir = join(dist, ".build-tmp");
|
|
89
|
+
mkdirSync(tmpDir, { recursive: true });
|
|
90
|
+
try {
|
|
91
|
+
let definition;
|
|
92
|
+
try {
|
|
93
|
+
resetVariableRegistryForTests();
|
|
94
|
+
definition = await importDefinition(entryPath, tmpDir);
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
return { ok: false, errors: [{ message: `cannot load workflow: ${err.message}` }] };
|
|
98
|
+
}
|
|
99
|
+
const compiled = compileWorkflow(definition, {
|
|
100
|
+
environmentFileBaseDir: dirname(entryPath),
|
|
101
|
+
inlineEnvironmentFiles: true,
|
|
102
|
+
});
|
|
103
|
+
if (!compiled.ok)
|
|
104
|
+
return compiled;
|
|
105
|
+
const { ir } = compiled;
|
|
106
|
+
const codeStepIds = collectCodeStepIds(ir);
|
|
107
|
+
const agentStepIds = collectAgentStepIds(ir);
|
|
108
|
+
const flueVersion = agentStepIds.length > 0
|
|
109
|
+
? await resolveFlueVersion(entryPath)
|
|
110
|
+
: undefined;
|
|
111
|
+
writeFileSync(join(dist, "ir.json"), JSON.stringify(ir, null, 2));
|
|
112
|
+
await buildStepsBundle({ entryPath, outfile: join(dist, "steps.js") });
|
|
113
|
+
let agentArtifact;
|
|
114
|
+
if (agentStepIds.length > 0) {
|
|
115
|
+
await buildAgentsBundle({ entryPath, outfile: join(dist, "agents.js") });
|
|
116
|
+
agentArtifact = "agents.js";
|
|
117
|
+
}
|
|
118
|
+
const manifest = {
|
|
119
|
+
workflowId: ir.id,
|
|
120
|
+
stepIds: Object.keys(ir.steps),
|
|
121
|
+
codeStepIds,
|
|
122
|
+
agentStepIds,
|
|
123
|
+
environmentHashes: collectWorkflowEnvironments(ir).map((environment) => environment.envHash),
|
|
124
|
+
artifacts: {
|
|
125
|
+
ir: "ir.json",
|
|
126
|
+
steps: "steps.js",
|
|
127
|
+
...(agentArtifact !== undefined ? { agents: agentArtifact } : {}),
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
writeFileSync(join(dist, "manifest.json"), JSON.stringify(manifest, null, 2));
|
|
131
|
+
return {
|
|
132
|
+
ok: true,
|
|
133
|
+
ir,
|
|
134
|
+
outDir: dist,
|
|
135
|
+
manifest,
|
|
136
|
+
...(flueVersion !== undefined ? { flueVersion } : {}),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
finally {
|
|
140
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export { buildAgentsBundle, buildStepsBundle } from "./node.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static lint over each function-hosted code step's own body (spec §7.5,
|
|
3
|
+
* mechanism 2). Only the step's function source is linted — shared imports
|
|
4
|
+
* are the bundler's problem (stubs), and import-time violations are caught
|
|
5
|
+
* by the cold-start smoke test instead.
|
|
6
|
+
*/
|
|
7
|
+
/** Strip string/template literals and comments so their contents can't false-positive. */
|
|
8
|
+
export declare function stripStringsAndComments(source: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the list of violations (empty = compatible). `source` is the step
|
|
11
|
+
* function's own text (`run.toString()`).
|
|
12
|
+
*/
|
|
13
|
+
export declare function lintWorkerStepSource(source: string): string[];
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static lint over each function-hosted code step's own body (spec §7.5,
|
|
3
|
+
* mechanism 2). Only the step's function source is linted — shared imports
|
|
4
|
+
* are the bundler's problem (stubs), and import-time violations are caught
|
|
5
|
+
* by the cold-start smoke test instead.
|
|
6
|
+
*/
|
|
7
|
+
/** Strip string/template literals and comments so their contents can't false-positive. */
|
|
8
|
+
export function stripStringsAndComments(source) {
|
|
9
|
+
let out = "";
|
|
10
|
+
let i = 0;
|
|
11
|
+
const n = source.length;
|
|
12
|
+
while (i < n) {
|
|
13
|
+
const ch = source[i];
|
|
14
|
+
const next = source[i + 1];
|
|
15
|
+
if (ch === "/" && next === "/") {
|
|
16
|
+
while (i < n && source[i] !== "\n")
|
|
17
|
+
i++;
|
|
18
|
+
}
|
|
19
|
+
else if (ch === "/" && next === "*") {
|
|
20
|
+
i += 2;
|
|
21
|
+
while (i < n && !(source[i] === "*" && source[i + 1] === "/"))
|
|
22
|
+
i++;
|
|
23
|
+
i += 2;
|
|
24
|
+
}
|
|
25
|
+
else if (ch === '"' || ch === "'" || ch === "`") {
|
|
26
|
+
const quote = ch;
|
|
27
|
+
i++;
|
|
28
|
+
while (i < n && source[i] !== quote) {
|
|
29
|
+
if (source[i] === "\\")
|
|
30
|
+
i++;
|
|
31
|
+
i++;
|
|
32
|
+
}
|
|
33
|
+
i++;
|
|
34
|
+
out += quote === "`" ? "``" : `${quote}${quote}`;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
out += ch;
|
|
38
|
+
i++;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
const BANNED = [
|
|
44
|
+
{ pattern: /\brequire\s*\(/, label: "require()" },
|
|
45
|
+
{ pattern: /\bimport\s*\(/, label: "dynamic import()" },
|
|
46
|
+
{ pattern: /\bnode:[a-z_/]+/, label: "node: builtin modules" },
|
|
47
|
+
{ pattern: /\bBuffer\b/, label: "Buffer (no global in Workers)" },
|
|
48
|
+
{ pattern: /\bBun\b/, label: "Bun" },
|
|
49
|
+
{ pattern: /\bDeno\b/, label: "Deno" },
|
|
50
|
+
{ pattern: /\b__dirname\b/, label: "__dirname" },
|
|
51
|
+
{ pattern: /\b__filename\b/, label: "__filename" },
|
|
52
|
+
{
|
|
53
|
+
pattern: /\bprocess\s*(?:\.(?!env\b)[a-zA-Z_$]|\[)/,
|
|
54
|
+
label: "process.* other than process.env",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
pattern: /\bfrom\s*(["'])(?:fs|child_process|worker_threads|cluster|net|tls|dgram)\1/,
|
|
58
|
+
label: "Node-only module import",
|
|
59
|
+
},
|
|
60
|
+
{ pattern: /\b(?:fs|child_process|worker_threads|cluster)\s*\./, label: "Node-only module use" },
|
|
61
|
+
];
|
|
62
|
+
/**
|
|
63
|
+
* Returns the list of violations (empty = compatible). `source` is the step
|
|
64
|
+
* function's own text (`run.toString()`).
|
|
65
|
+
*/
|
|
66
|
+
export function lintWorkerStepSource(source) {
|
|
67
|
+
const stripped = stripStringsAndComments(source);
|
|
68
|
+
const violations = [];
|
|
69
|
+
for (const { pattern, label } of BANNED) {
|
|
70
|
+
if (pattern.test(stripped))
|
|
71
|
+
violations.push(label);
|
|
72
|
+
}
|
|
73
|
+
return violations;
|
|
74
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Code bundle: re-exports compiled run functions for cloud/device runners. */
|
|
2
|
+
export declare function buildStepsBundle(options: {
|
|
3
|
+
entryPath: string;
|
|
4
|
+
outfile: string;
|
|
5
|
+
}): Promise<void>;
|
|
6
|
+
/** Agent bundle: re-exports compiled Flue defineAgent refs; the runner owns the runtime. */
|
|
7
|
+
export declare function buildAgentsBundle(options: {
|
|
8
|
+
entryPath: string;
|
|
9
|
+
outfile: string;
|
|
10
|
+
}): Promise<void>;
|