@theford/runly 0.0.0-stage → 0.20.0
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 +202 -0
- package/README.md +157 -2
- package/dist/cli/client.d.ts +80 -0
- package/dist/cli/client.js +294 -0
- package/dist/cli/client.js.map +1 -0
- package/dist/cli/daemon-unit.d.ts +58 -0
- package/dist/cli/daemon-unit.js +289 -0
- package/dist/cli/daemon-unit.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +1482 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/install.d.ts +9 -0
- package/dist/cli/install.js +53 -0
- package/dist/cli/install.js.map +1 -0
- package/dist/cli/logs.d.ts +43 -0
- package/dist/cli/logs.js +232 -0
- package/dist/cli/logs.js.map +1 -0
- package/dist/cli/tether.d.ts +3 -0
- package/dist/cli/tether.js +65 -0
- package/dist/cli/tether.js.map +1 -0
- package/dist/cli/watchdog.d.ts +1 -0
- package/dist/cli/watchdog.js +81 -0
- package/dist/cli/watchdog.js.map +1 -0
- package/dist/core/builds.d.ts +20 -0
- package/dist/core/builds.js +93 -0
- package/dist/core/builds.js.map +1 -0
- package/dist/core/caller-env.d.ts +17 -0
- package/dist/core/caller-env.js +77 -0
- package/dist/core/caller-env.js.map +1 -0
- package/dist/core/diagnostics.d.ts +68 -0
- package/dist/core/diagnostics.js +34 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/env-vars.d.ts +35 -0
- package/dist/core/env-vars.js +32 -0
- package/dist/core/env-vars.js.map +1 -0
- package/dist/core/events.d.ts +10 -0
- package/dist/core/events.js +42 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/exec.d.ts +22 -0
- package/dist/core/exec.js +84 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/journal.d.ts +227 -0
- package/dist/core/journal.js +395 -0
- package/dist/core/journal.js.map +1 -0
- package/dist/core/logs.d.ts +56 -0
- package/dist/core/logs.js +259 -0
- package/dist/core/logs.js.map +1 -0
- package/dist/core/manifest.d.ts +292 -0
- package/dist/core/manifest.js +179 -0
- package/dist/core/manifest.js.map +1 -0
- package/dist/core/namespaces.d.ts +7 -0
- package/dist/core/namespaces.js +59 -0
- package/dist/core/namespaces.js.map +1 -0
- package/dist/core/paths.d.ts +31 -0
- package/dist/core/paths.js +65 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/policy.d.ts +94 -0
- package/dist/core/policy.js +122 -0
- package/dist/core/policy.js.map +1 -0
- package/dist/core/ports.d.ts +52 -0
- package/dist/core/ports.js +94 -0
- package/dist/core/ports.js.map +1 -0
- package/dist/core/presets.d.ts +25 -0
- package/dist/core/presets.js +86 -0
- package/dist/core/presets.js.map +1 -0
- package/dist/core/procscan.d.ts +111 -0
- package/dist/core/procscan.js +342 -0
- package/dist/core/procscan.js.map +1 -0
- package/dist/core/retention.d.ts +97 -0
- package/dist/core/retention.js +322 -0
- package/dist/core/retention.js.map +1 -0
- package/dist/core/sleep.d.ts +51 -0
- package/dist/core/sleep.js +99 -0
- package/dist/core/sleep.js.map +1 -0
- package/dist/core/tree-ledger.d.ts +39 -0
- package/dist/core/tree-ledger.js +92 -0
- package/dist/core/tree-ledger.js.map +1 -0
- package/dist/core/types.d.ts +21 -0
- package/dist/core/types.js +6 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/units.d.ts +20 -0
- package/dist/core/units.js +69 -0
- package/dist/core/units.js.map +1 -0
- package/dist/core/upkeep.d.ts +90 -0
- package/dist/core/upkeep.js +176 -0
- package/dist/core/upkeep.js.map +1 -0
- package/dist/core/util.d.ts +46 -0
- package/dist/core/util.js +168 -0
- package/dist/core/util.js.map +1 -0
- package/dist/core/version.d.ts +39 -0
- package/dist/core/version.js +144 -0
- package/dist/core/version.js.map +1 -0
- package/dist/core/worktree.d.ts +51 -0
- package/dist/core/worktree.js +309 -0
- package/dist/core/worktree.js.map +1 -0
- package/dist/daemon/budget.d.ts +155 -0
- package/dist/daemon/budget.js +288 -0
- package/dist/daemon/budget.js.map +1 -0
- package/dist/daemon/election.d.ts +9 -0
- package/dist/daemon/election.js +140 -0
- package/dist/daemon/election.js.map +1 -0
- package/dist/daemon/engine.d.ts +1703 -0
- package/dist/daemon/engine.js +5305 -0
- package/dist/daemon/engine.js.map +1 -0
- package/dist/daemon/index.d.ts +2 -0
- package/dist/daemon/index.js +412 -0
- package/dist/daemon/index.js.map +1 -0
- package/dist/daemon/proxy.d.ts +108 -0
- package/dist/daemon/proxy.js +615 -0
- package/dist/daemon/proxy.js.map +1 -0
- package/dist/daemon/supervisor.d.ts +101 -0
- package/dist/daemon/supervisor.js +493 -0
- package/dist/daemon/supervisor.js.map +1 -0
- package/dist/drivers/appliances.d.ts +11 -0
- package/dist/drivers/appliances.js +174 -0
- package/dist/drivers/appliances.js.map +1 -0
- package/dist/drivers/datastores.d.ts +144 -0
- package/dist/drivers/datastores.js +775 -0
- package/dist/drivers/datastores.js.map +1 -0
- package/dist/drivers/preview.d.ts +69 -0
- package/dist/drivers/preview.js +605 -0
- package/dist/drivers/preview.js.map +1 -0
- package/dist/drivers/types.d.ts +70 -0
- package/dist/drivers/types.js +13 -0
- package/dist/drivers/types.js.map +1 -0
- package/package.json +63 -4
- package/schema/backlot.schema.json +549 -0
- package/schema/runly.schema.json +556 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,158 @@
|
|
|
1
|
-
#
|
|
1
|
+
# runly
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@theford/runly) [](https://github.com/ChristianKohlberg/backlot/actions/workflows/ci.yml) [](https://github.com/ChristianKohlberg/backlot/releases)
|
|
4
|
+
|
|
5
|
+
runly puts a running, seeded, authenticated instance of your web application in
|
|
6
|
+
front of a coding agent or a human. It runs your repo's own commands in the
|
|
7
|
+
worktree you call it from, one environment per worktree, described by one
|
|
8
|
+
`runly.yml`.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm i -g @theford/runly # requires Node ≥ 22.13 and git
|
|
14
|
+
runly update # after every upgrade: restarts the running daemon onto the installed build
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The daemon starts on first use (a unix socket in `~/.local/state/backlot`;
|
|
18
|
+
`BACKLOT_STATE_DIR` moves it). The `backlot` command and `backlot.yml` are
|
|
19
|
+
accepted aliases, and every setting is a `BACKLOT_*` environment variable
|
|
20
|
+
([list](docs/architecture.md#configuration)).
|
|
21
|
+
|
|
22
|
+
For Claude Code, install the bundled skill:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
/plugin marketplace add ChristianKohlberg/backlot
|
|
26
|
+
/plugin install runly
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quickstart
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
git clone https://github.com/ChristianKohlberg/backlot && cd backlot
|
|
33
|
+
npm ci && npm run build && npm link
|
|
34
|
+
cd examples/hello-multi
|
|
35
|
+
|
|
36
|
+
runly up web # upkeep, builds, data; start web and its depends_on (api); prints the context
|
|
37
|
+
runly up # add every other service; up never stops one
|
|
38
|
+
runly ps # services and database copies of this worktree
|
|
39
|
+
eval "$(runly ctx --env)" && node smoke.test.mjs # your tests, fed exported RUNLY_* variables
|
|
40
|
+
runly up --preset main=empty # reload one datastore; the others keep their data
|
|
41
|
+
runly db with main -- sh -c 'echo "$RUNLY_DB_URL"' # a fresh database copy for one command, dropped after
|
|
42
|
+
runly logs api -f --until 'listening' --timeout 60 # wait for the current process's line (124 on timeout)
|
|
43
|
+
runly down web # stop one service; lease, data and port stay
|
|
44
|
+
runly destroy # tear down everything this worktree holds
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
After an edit, run `runly up` again: it runs the due upkeep and the builds and
|
|
48
|
+
restarts only the services whose build output changed. Idle services stop after
|
|
49
|
+
10 minutes and start again on the next request. How an environment lives and
|
|
50
|
+
ends is in [the guide](docs/overview.md#an-environments-life).
|
|
51
|
+
|
|
52
|
+
## Manifest reference
|
|
53
|
+
|
|
54
|
+
`runly.yml` at the repo root ([JSON Schema](schema/runly.schema.json)). Commands
|
|
55
|
+
run under `sh` in the worktree; write POSIX sh.
|
|
56
|
+
|
|
57
|
+
| Field | Meaning |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| `name` | Stack name (`a-z0-9-`). Required. |
|
|
60
|
+
| `services.<svc>.run` | The supervised command. Required. |
|
|
61
|
+
| `services.<svc>.build` | Command run before the service starts, on every `up`. `{ run, when: [globs], serial }`: `when` skips it while the matched files are unchanged since the last successful build and its `outputs:` are still what that build left; `serial: true` runs it alone. |
|
|
62
|
+
| `services.<svc>.outputs` | Globs the build produces; a running service restarts only when they changed. `{ paths, compare: stat \| content }`. None declared = restart after every build. |
|
|
63
|
+
| `services.<svc>.port` | Symbolic port name. Omit for a portless worker. |
|
|
64
|
+
| `services.<svc>.env` | Environment variables; values may use templates (below). |
|
|
65
|
+
| `services.<svc>.env_from` | Caller variables to pass in: `NAME: required \| optional`. Not `BACKLOT_*`. |
|
|
66
|
+
| `services.<svc>.cwd` | Working directory, relative to the repo root. |
|
|
67
|
+
| `services.<svc>.ready` | Readiness: `http` (path answering 200), `log` (regex), or `cmd` (exit 0); `timeout` seconds (120). |
|
|
68
|
+
| `services.<svc>.fatal_logs` | Regex that fails the start at once when it appears in the log. |
|
|
69
|
+
| `services.<svc>.depends_on` | Services that must be ready first. |
|
|
70
|
+
| `services.<svc>.idle` | Idle time before the service is stopped (`90s`, `30m`, `2h`, seconds, or `never`). Default 10 minutes. |
|
|
71
|
+
| `services.<svc>.resources` | Cost for the load budget: `{ memory, cpu, build: { memory, cpu } }`. Default 512M / 0.5 cpu running, 1G / 1 cpu building. |
|
|
72
|
+
| `datastores.<ds>.driver` | `sqlite`, `postgres`, `mssql`, `mysql` or `redis`. Required. |
|
|
73
|
+
| `datastores.<ds>.create` | Creates and seeds a namespace; `{{ns}}`, `{{preset}}`. |
|
|
74
|
+
| `datastores.<ds>.drop` | Drops a namespace; `{{ns}}`. Needed for `runly db` copies of a server datastore. |
|
|
75
|
+
| `datastores.<ds>.template_restore` | Restores a baked template into a namespace; `{{template}}`, `{{ns}}`. Server drivers. |
|
|
76
|
+
| `datastores.<ds>.template` | `true`: bake a template file and restore by copy. sqlite only. |
|
|
77
|
+
| `datastores.<ds>.url` | Connection string handed to services; `{{ns}}`. Required for server drivers. |
|
|
78
|
+
| `datastores.<ds>.probe` | `host:port` checked before anything starts (unreachable = infra-error). |
|
|
79
|
+
| `datastores.<ds>.server` | `external` (the only value): runly never runs a database server. |
|
|
80
|
+
| `datastores.<ds>.presets` | Named seed states. |
|
|
81
|
+
| `datastores.<ds>.default_preset` | The preset a new datastore is created with (else the first preset). A name, or `{ session, run }` read as one value. |
|
|
82
|
+
| `datastores.<ds>.ephemeral` | `true`: no presets or templates; a reset runs `drop:` as a flush (Redis-class). |
|
|
83
|
+
| `datastores.<ds>.share_templates` | `false`: keep this datastore's templates per worktree. Default: a template keyed by an `@rebake-template` rule is baked once and shared by every worktree of the same stack name on this machine; `--pristine` bakes a private one for its worktree. |
|
|
84
|
+
| `datastores.<ds>.copies_only` | `true`: never provisioned for an environment; only the source of `runly db new\|with` copies (template baked on the first copy). No service may template it; `ctx` does not list it. |
|
|
85
|
+
| `datastores.<ds>.list` | Command printing the namespaces on the server, one per line; read only by `runly pool doctor`. |
|
|
86
|
+
| `appliances.<name>` | A shared backing server: `probe` (required), `start` (run once when the probe fails), `stop` (only for `runly appliance stop`), `ready`, `timeout` (60), `resources`. |
|
|
87
|
+
| `upkeep[]` | `{ when: <path or glob>, run: <cmd>, timeout: <s>, outputs: <path or list> }`: runs when the matched files' content changed since it last ran in this worktree, or when a declared `outputs` path is missing (a `git clean` removed it). `runly destroy` forgets the rules that declare no `outputs`, so they run again on the next `up`. `run: "@rebake-template <ds>"` makes the matched files part of that datastore's template key: changed content gets a new template (baked once, then reused) and reloads the store; `--pristine` rebakes. Timeout 300 s. |
|
|
88
|
+
| `builds` | `parallel` (default): builds run in `depends_on` waves, each wave at once. `serial`: one at a time, in manifest order. |
|
|
89
|
+
| `caches` | Build and install output in the worktree (`node_modules`, `**/obj`); never an upkeep trigger. |
|
|
90
|
+
| `sync.include` | Git-ignored files an upkeep `when:` may still match (`.env.local`). |
|
|
91
|
+
| `auth.logins` | One `{ user, password, role, description }` or a list; the first is the primary login. |
|
|
92
|
+
| `auth.token` | Command printing a token on stdout; `{{role}}`. |
|
|
93
|
+
| `preview.publisher` | `cloudflare-quick` (default), `cloudflare-named` or `tailscale`. |
|
|
94
|
+
| `preview.domain`, `preview.prefix` | `cloudflare-named`: the zone, and the hostname suffix (default: the environment id). |
|
|
95
|
+
| `preview.https_port` | `tailscale`: the tailnet HTTPS port (default: derived per environment and service). |
|
|
96
|
+
| `preview.forbidden` | `true`: `runly preview` is refused. |
|
|
97
|
+
|
|
98
|
+
Templates: `{{ports.<port>}}`, `{{public_ports.<port>}}`, `{{services.<svc>.url}}`,
|
|
99
|
+
`{{datastores.<ds>.url}}`, `{{datastores.<ds>.ns}}`. In a service's own `run:` and
|
|
100
|
+
`env:`, its own `{{ports.<port>}}` is the internal port it must listen on;
|
|
101
|
+
everywhere else ports and URLs are the stable public ones. Top-level `outputs`,
|
|
102
|
+
`checks` (with a warning), `sync.keep`, `watch_run` and `hot_reload` are accepted
|
|
103
|
+
and ignored.
|
|
104
|
+
|
|
105
|
+
## Command reference
|
|
106
|
+
|
|
107
|
+
Every verb takes `--json` (stdout is one JSON object). Exit codes: `0` ok, `1`
|
|
108
|
+
work-error (your code), `2` env-error (the environment), `3` infra-error
|
|
109
|
+
(something external), `64` usage.
|
|
110
|
+
|
|
111
|
+
| Command | What it does |
|
|
112
|
+
| --- | --- |
|
|
113
|
+
| `runly up [svc...]` | Lease this worktree's environment, run due upkeep and builds, start the named services and their `depends_on` (none named = all). Never stops a running service; with services named, the other running ones are not rebuilt or restarted. Prints a short summary (what started or restarted, and why a full rebind happened); `--json` the full context. |
|
|
114
|
+
| ` --preset [ds=]NAME` | Reload that datastore from its template (repeatable); the services that use it restart. Without it, data is kept. |
|
|
115
|
+
| ` --reset-data` / `--pristine` | Restore every datastore / that, plus re-run every upkeep rule and build (never deletes worktree files). |
|
|
116
|
+
| ` --rebuild` | Run every build, ignoring `when:`. |
|
|
117
|
+
| ` --ttl <minutes>` | Lease length (default 30), for an untethered lease: it skips the automatic tether, and is refused next to `--holder-pid`. |
|
|
118
|
+
| ` --env` | Print the `ctx --env` export lines instead of the summary. |
|
|
119
|
+
| ` --holder-pid <pid>` | Tie the environment to a process that outlives the command; torn down a minute after it exits. The summary then says `held by agent <pid>` instead of a deadline. |
|
|
120
|
+
| `runly down [svc...]` | Stop these services (none = all); lease, data and ports stay. |
|
|
121
|
+
| `runly ctx [--env]` | A short summary (service URLs and states, datastores, login, a failed last `up`); `--json` the full context; `--env` prints `export RUNLY_*=…` lines for `eval`. |
|
|
122
|
+
| `runly ps [--all]` | Services (state, ports, pid, idle, memory) and database copies of this worktree, or of the whole box (with a worktree column). A service that crash-looped, or failed its boot during an `up`, shows `failed` with its last exit; an `up` that failed (a build, upkeep, data) is named with its error. The next `up` retries both. |
|
|
123
|
+
| `runly plan [svc...] [--rebuild]` | What an `up` would build and start, what it costs, and whether it starts now or waits for the load budget. |
|
|
124
|
+
| `runly logs [svc...]` | Service logs, interleaved (last 40 lines). `--lines N`, `--since up\|10m`, `--grep <re>` (exit 1 when nothing matches), `--build` (the upkeep output and each service's last build, a section each with its own last N lines; the header says what was cut). |
|
|
125
|
+
| ` -f [--until <re>] [--timeout <s>]` | Follow; `--until` exits 0 on the first matching line of the current process (never an earlier one), `--timeout` exits 124. |
|
|
126
|
+
| `runly db with <ds> [--preset NAME] [--runly-exit N] -- <cmd>` | Run a command against a fresh copy (`RUNLY_DB_URL`; `RUNLY_DB_DATABASE`, the database's name on its server; `RUNLY_DB_COPY`, the handle), drop it after, exit with its code. The command dies with the CLI however the CLI dies. runly's own failures are marked on stderr (`runly db with:`, and a `{"runlyDbWith":…}` line with `--json`) and exit 1/2/3, or `N` with `--runly-exit N`. |
|
|
127
|
+
| `runly db new <ds> [--preset NAME]` | Make a copy and print `name=`, `url=`, `database=`, `preset=`. |
|
|
128
|
+
| `runly db ls [--all]` / `db drop <name>` | List copies / drop one now. |
|
|
129
|
+
| `runly exec <cmd...>` | Run a command in the worktree with your environment plus the `ctx --env` variables (and `BACKLOT_URL_*`, `BACKLOT_PORT_*`, `BACKLOT_DS_*`). Stopped services start first. Your terminal, its exit code; `--json` collects `stdout`, `stderr`, `exitCode`. No deadline unless `BACKLOT_CMD_TIMEOUT_S` is set. |
|
|
130
|
+
| `runly warm` | Run due upkeep and builds now, with no lease and no services. |
|
|
131
|
+
| `runly reset-data [--preset ds=NAME]` | Restore the data of the current lease. |
|
|
132
|
+
| `runly token [--role <r>] [--raw]` | Run `auth.token` (role default `admin`, also in `RUNLY_ROLE`); `--raw` prints the bare token. Stopped services start first. |
|
|
133
|
+
| `runly release` | End the lease; the environment stays for the next `up`. |
|
|
134
|
+
| `runly destroy` | Tear down everything runly holds for this worktree: services, data, copies, ports, lease. Its build records, templates and the upkeep rules that declare `outputs` stay. |
|
|
135
|
+
| `runly preview <svc> [--ttl <minutes>] [--https-port N]` | Publish one service through the preview publisher. Unauthenticated. Lasts as long as the lease; a daemon restart publishes it again (same address where the publisher can pin one). |
|
|
136
|
+
| `runly preview stop` | End the preview (also one a restart could not publish again). |
|
|
137
|
+
| `runly status` / `runly doctor` | Daemon, environments, budget and recent warnings (`--json` everything) / health and drift report. |
|
|
138
|
+
| `runly appliance ls\|start\|stop [name]` | Probe, start or stop shared backing servers. |
|
|
139
|
+
| `runly pool ls\|recycle [<env-id>] [--force]\|reconcile\|gc` | Environments; recycle one (or all); reap degraded ones; reclaim orphaned processes. |
|
|
140
|
+
| `runly pool doctor [--fix]` | List (and with `--fix` remove) what runly left behind. Only runly's own. |
|
|
141
|
+
| `runly update [--check] [--force]` | Restart the daemon onto the installed build. Leases survive. |
|
|
142
|
+
| `runly daemon stop` / `runly --version` | Stop the daemon, waiting up to 60 s (`BACKLOT_DAEMON_STOP_TIMEOUT_MS`) / print the CLI version. |
|
|
143
|
+
| `runly daemon install [--print] [--env NAME]` / `daemon uninstall` | Supervise the daemon with a systemd user unit (Linux) or launchd agent (macOS) that restarts it when it crashes; `--print` shows the unit. The unit carries `PATH`, an allowlist (`DOTNET_*`, `NODE_*`, `JAVA_HOME`, `DOCKER_*`, `LANG`/`LC_*`, proxies, `SSL_CERT_*`), `BACKLOT_*`, the variables the manifest's commands reference and each `--env NAME`, never an `env_from` input; install prints what it captured and left out. |
|
|
144
|
+
|
|
145
|
+
The verbs that act on a lease or copy take `--holder <name>` to act for a holder
|
|
146
|
+
other than the caller's worktree (the default; any subdirectory of it counts). `up`, `warm` and `reset-data` show progress on a terminal;
|
|
147
|
+
`--progress` forces it, `--quiet` silences it.
|
|
148
|
+
|
|
149
|
+
## More
|
|
150
|
+
|
|
151
|
+
- [docs/overview.md](docs/overview.md) — the guide: environment life, ports,
|
|
152
|
+
testing, data, builds, the load budget, previews, security.
|
|
153
|
+
- [docs/architecture.md](docs/architecture.md) — the design and every setting.
|
|
154
|
+
- [docs/decisions/](docs/decisions/) — why it is the way it is.
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
Apache-2.0.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classify a client-side failure for the exit-code contract (decision 0010).
|
|
3
|
+
*
|
|
4
|
+
* Agents branch on the class mechanically, so an unreachable or wedged daemon
|
|
5
|
+
* must NOT report env-error: that tells the agent to recycle an environment,
|
|
6
|
+
* which cannot fix a broken daemon. Anything that never became a classified
|
|
7
|
+
* daemon response is infrastructure.
|
|
8
|
+
*/
|
|
9
|
+
export declare function classifyClientError(err: unknown): 'infra-error' | 'env-error';
|
|
10
|
+
export interface RpcError {
|
|
11
|
+
class?: string;
|
|
12
|
+
code?: string;
|
|
13
|
+
message: string;
|
|
14
|
+
source?: string;
|
|
15
|
+
logExcerpt?: string;
|
|
16
|
+
}
|
|
17
|
+
export type RpcResponse = {
|
|
18
|
+
ok: true;
|
|
19
|
+
data: unknown;
|
|
20
|
+
} | {
|
|
21
|
+
ok: false;
|
|
22
|
+
error: RpcError;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The daemon streams newline-delimited frames: {type:'progress',phase} … then
|
|
26
|
+
* one {type:'result',ok,…}. `onProgress` (optional) sees each phase; the
|
|
27
|
+
* promise resolves on the result frame. Consumers that ignore progress (for example,
|
|
28
|
+
* ping, most verbs) just don't pass it — the frames are consumed and dropped.
|
|
29
|
+
*/
|
|
30
|
+
export declare function rpc(verb: string, args: Record<string, unknown>, onProgress?: (phase: string) => void, deadlineMs?: number): Promise<RpcResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* What the daemon answering the socket says it is.
|
|
33
|
+
*
|
|
34
|
+
* `version` is undefined for a daemon that predates version reporting (<= 0.8.0)
|
|
35
|
+
* — indistinguishable at the protocol level from "answered without it", which is
|
|
36
|
+
* why callers must treat undefined as skew rather than as "same version".
|
|
37
|
+
*/
|
|
38
|
+
export interface DaemonInfo {
|
|
39
|
+
pid?: number;
|
|
40
|
+
version?: string;
|
|
41
|
+
journalSchema?: number;
|
|
42
|
+
}
|
|
43
|
+
/** Inspect without spawning; only an absent socket/listener means no daemon. */
|
|
44
|
+
export declare function daemonInfo(): Promise<DaemonInfo | null>;
|
|
45
|
+
/**
|
|
46
|
+
* How long `daemon stop` waits for the acknowledged shutdown to finish. The
|
|
47
|
+
* engine serialises a verified group kill per service (SIGTERM grace plus a
|
|
48
|
+
* post-SIGKILL wait) across every supervisor before it reaps, so a shared box
|
|
49
|
+
* with many signal-trapping services legitimately needs more than `update`'s
|
|
50
|
+
* default window.
|
|
51
|
+
*/
|
|
52
|
+
export declare const DAEMON_STOP_TIMEOUT_MS = 60000;
|
|
53
|
+
/** The stop window, overridable (BACKLOT_DAEMON_STOP_TIMEOUT_MS) so a test of the timeout need not sit through a minute. */
|
|
54
|
+
export declare const daemonStopTimeoutMs: () => number;
|
|
55
|
+
/**
|
|
56
|
+
* Wait for the daemon to be really gone — not answering AND not running.
|
|
57
|
+
*
|
|
58
|
+
* `update` needs this between the restart request and the respawn, and
|
|
59
|
+
* `daemon stop` (with `DAEMON_STOP_TIMEOUT_MS`) before it reports `stopped`,
|
|
60
|
+
* for two distinct reasons:
|
|
61
|
+
*
|
|
62
|
+
* - `shutdown` returns its result frame ~50ms BEFORE the process exits, so
|
|
63
|
+
* pinging straight away is answered by the daemon that is about to die,
|
|
64
|
+
* ensureDaemon concludes one is already up, and the update silently does
|
|
65
|
+
* nothing.
|
|
66
|
+
* - The socket is removed a moment BEFORE the process exits and releases the
|
|
67
|
+
* election lock. A daemon spawned in that window finds the lock held by a
|
|
68
|
+
* still-live holder, and electSelf refuses to break a live claim (correctly —
|
|
69
|
+
* that check is what stops two daemons binding the same journal), so it
|
|
70
|
+
* concedes with exit 0. The client then reads "our child exited cleanly, a
|
|
71
|
+
* winner must exist" and waits out a full window for a winner that was never
|
|
72
|
+
* started. Waiting on the PID closes it.
|
|
73
|
+
*
|
|
74
|
+
* Each ping is cut at the remaining budget, and a ping that had to be cut is
|
|
75
|
+
* evidence of a daemon, not of its absence: a listener that never answered is
|
|
76
|
+
* still a listener. Only a probe that found no socket or no listener, with the
|
|
77
|
+
* recorded pid (when known) also dead, counts as gone.
|
|
78
|
+
*/
|
|
79
|
+
export declare function awaitDaemonGone(oldPid?: number, timeoutMs?: number): Promise<boolean>;
|
|
80
|
+
export declare function ensureDaemon(cwd?: string): Promise<DaemonInfo>;
|