@boardwalk-labs/runner 0.1.2
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 +68 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +214 -0
- package/dist/contract.d.ts +154 -0
- package/dist/contract.js +196 -0
- package/dist/daemon/daemon.d.ts +45 -0
- package/dist/daemon/daemon.js +129 -0
- package/dist/daemon/identity.d.ts +15 -0
- package/dist/daemon/identity.js +44 -0
- package/dist/daemon/index.d.ts +3 -0
- package/dist/daemon/index.js +4 -0
- package/dist/daemon/pool_client.d.ts +31 -0
- package/dist/daemon/pool_client.js +101 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8 -0
- package/dist/runtime/agent/budget.d.ts +123 -0
- package/dist/runtime/agent/budget.js +174 -0
- package/dist/runtime/agent/events.d.ts +46 -0
- package/dist/runtime/agent/events.js +8 -0
- package/dist/runtime/agent/model_rates.d.ts +7 -0
- package/dist/runtime/agent/model_rates.js +21 -0
- package/dist/runtime/agent/secret_redactor.d.ts +42 -0
- package/dist/runtime/agent/secret_redactor.js +98 -0
- package/dist/runtime/broker_artifact_store.d.ts +17 -0
- package/dist/runtime/broker_artifact_store.js +46 -0
- package/dist/runtime/broker_child_dispatcher.d.ts +31 -0
- package/dist/runtime/broker_child_dispatcher.js +88 -0
- package/dist/runtime/broker_event_publisher.d.ts +25 -0
- package/dist/runtime/broker_event_publisher.js +69 -0
- package/dist/runtime/broker_tool_host.d.ts +49 -0
- package/dist/runtime/broker_tool_host.js +240 -0
- package/dist/runtime/cancel_watcher.d.ts +31 -0
- package/dist/runtime/cancel_watcher.js +77 -0
- package/dist/runtime/credit_watcher.d.ts +30 -0
- package/dist/runtime/credit_watcher.js +78 -0
- package/dist/runtime/direct_inference.d.ts +29 -0
- package/dist/runtime/direct_inference.js +78 -0
- package/dist/runtime/index.d.ts +85 -0
- package/dist/runtime/index.js +525 -0
- package/dist/runtime/inference_transport.d.ts +5 -0
- package/dist/runtime/inference_transport.js +9 -0
- package/dist/runtime/leaf_executor.d.ts +104 -0
- package/dist/runtime/leaf_executor.js +333 -0
- package/dist/runtime/lease_renewer.d.ts +31 -0
- package/dist/runtime/lease_renewer.js +80 -0
- package/dist/runtime/main.d.ts +1 -0
- package/dist/runtime/main.js +7 -0
- package/dist/runtime/phase_tracker.d.ts +26 -0
- package/dist/runtime/phase_tracker.js +45 -0
- package/dist/runtime/program_log_capture.d.ts +20 -0
- package/dist/runtime/program_log_capture.js +79 -0
- package/dist/runtime/program_runner.d.ts +82 -0
- package/dist/runtime/program_runner.js +116 -0
- package/dist/runtime/program_worker.d.ts +177 -0
- package/dist/runtime/program_worker.js +272 -0
- package/dist/runtime/recording_secret_resolver.d.ts +9 -0
- package/dist/runtime/recording_secret_resolver.js +22 -0
- package/dist/runtime/run_abort.d.ts +16 -0
- package/dist/runtime/run_abort.js +38 -0
- package/dist/runtime/run_event_emitter.d.ts +24 -0
- package/dist/runtime/run_event_emitter.js +63 -0
- package/dist/runtime/runner_control_client.d.ts +184 -0
- package/dist/runtime/runner_control_client.js +501 -0
- package/dist/runtime/runtime_flusher.d.ts +41 -0
- package/dist/runtime/runtime_flusher.js +90 -0
- package/dist/runtime/sandbox_config.d.ts +21 -0
- package/dist/runtime/sandbox_config.js +34 -0
- package/dist/runtime/support/index.d.ts +53 -0
- package/dist/runtime/support/index.js +114 -0
- package/dist/runtime/suspension.d.ts +141 -0
- package/dist/runtime/suspension.js +120 -0
- package/dist/runtime/testing_artifact_build.d.ts +27 -0
- package/dist/runtime/testing_artifact_build.js +96 -0
- package/dist/runtime/tools/artifacts.d.ts +146 -0
- package/dist/runtime/tools/artifacts.js +125 -0
- package/dist/runtime/tools/types.d.ts +114 -0
- package/dist/runtime/tools/types.js +61 -0
- package/dist/runtime/tools/web_search.d.ts +66 -0
- package/dist/runtime/tools/web_search.js +165 -0
- package/dist/runtime/wire/artifact_storage.d.ts +37 -0
- package/dist/runtime/wire/artifact_storage.js +93 -0
- package/dist/runtime/wire/artifact_verify.d.ts +1 -0
- package/dist/runtime/wire/artifact_verify.js +8 -0
- package/dist/runtime/wire/human_input.d.ts +62 -0
- package/dist/runtime/wire/human_input.js +156 -0
- package/dist/runtime/wire/inference_proxy.d.ts +70 -0
- package/dist/runtime/wire/inference_proxy.js +157 -0
- package/dist/runtime/wire/manifest.d.ts +16 -0
- package/dist/runtime/wire/manifest.js +18 -0
- package/dist/runtime/wire/run.d.ts +54 -0
- package/dist/runtime/wire/run.js +2 -0
- package/dist/runtime/workflow_host.d.ts +194 -0
- package/dist/runtime/workflow_host.js +382 -0
- package/dist/runtime/workspace_store.d.ts +73 -0
- package/dist/runtime/workspace_store.js +118 -0
- package/package.json +70 -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 2026 Robot Networks Inc.
|
|
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
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @boardwalk-labs/runner
|
|
2
|
+
|
|
3
|
+
The [Boardwalk](https://boardwalk.sh) **self-hosted runner**: your machines execute runs that
|
|
4
|
+
hosted Boardwalk schedules — for data residency, special hardware, or internal-network access.
|
|
5
|
+
The mental model is a CI self-hosted runner; the contract is Boardwalk-native.
|
|
6
|
+
|
|
7
|
+
> Not to be confused with the [Boardwalk engine](https://github.com/boardwalk-labs/boardwalk):
|
|
8
|
+
> the engine runs the entire control plane on your hardware, with no hosted Boardwalk
|
|
9
|
+
> involvement. This runner executes hosted-Boardwalk-scheduled work on your machines.
|
|
10
|
+
|
|
11
|
+
## Status
|
|
12
|
+
|
|
13
|
+
**Pre-release, functional.** The package now carries all three layers:
|
|
14
|
+
|
|
15
|
+
- **`@boardwalk-labs/runner/contract`** — the canonical registration / offer / claim /
|
|
16
|
+
heartbeat payload types (Zod schemas, derived TS types). [`CONTRACT.md`](./CONTRACT.md) is
|
|
17
|
+
the prose half: flows, the lease state machine, and the security invariants.
|
|
18
|
+
- **`@boardwalk-labs/runner/runtime`** — the Boardwalk worker runtime itself: the same code a
|
|
19
|
+
Boardwalk-hosted Fargate worker boots executes each claimed run here (one worker, two homes).
|
|
20
|
+
- **`boardwalk-runner`** (the bin) + **`@boardwalk-labs/runner/daemon`** — the machine daemon:
|
|
21
|
+
register once, then poll → claim → run → heartbeat → clean.
|
|
22
|
+
|
|
23
|
+
## Quickstart
|
|
24
|
+
|
|
25
|
+
An org admin mints a one-time registration token (Boardwalk Settings > Runners), then on the
|
|
26
|
+
machine:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
boardwalk-runner register --url https://api.boardwalk.sh --token bwkreg_...
|
|
30
|
+
boardwalk-runner start --url https://api.boardwalk.sh --pool default
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`start` polls for runs targeting `runs_on: { kind: "self-hosted" }` and executes one at a
|
|
34
|
+
time; run more daemons (or machines) for concurrency. `Ctrl-C` drains: the current run
|
|
35
|
+
finishes, nothing new is claimed. Useful flags: `--once` (execute one run, then exit),
|
|
36
|
+
`--verbose` (debug-level daemon logs), `--debug` (also debug-logs inside each run process),
|
|
37
|
+
`--work-dir`, `--identity-dir`. Behind a corporate proxy, launch with `NODE_USE_ENV_PROXY=1`
|
|
38
|
+
and `HTTPS_PROXY` set; the daemon and the run processes both honor it. Runs inherit this
|
|
39
|
+
machine's network — a model or service reachable from the box is reachable from the run.
|
|
40
|
+
|
|
41
|
+
## Security model
|
|
42
|
+
|
|
43
|
+
This part of the contract is settled, even though the client isn't built yet:
|
|
44
|
+
|
|
45
|
+
- The runner **never receives broad credentials**: a single-purpose registration token to join,
|
|
46
|
+
a standing runner token that can only poll/claim/heartbeat, and a short-lived **run-scoped**
|
|
47
|
+
token as the only credential with reach into an org — authorized per call against that run's
|
|
48
|
+
manifest.
|
|
49
|
+
- Secrets are never in an assignment and never at rest on the runner; they resolve per run
|
|
50
|
+
through the control plane, fail-closed.
|
|
51
|
+
- Programs are content-addressed built artifacts: digest verified before extraction, no raw
|
|
52
|
+
source, no runtime installs.
|
|
53
|
+
- All control signals (cancel, drain) arrive in heartbeat _responses_ — there are no inbound
|
|
54
|
+
connections to your machines.
|
|
55
|
+
- Per-run isolation of workspace, credentials, artifacts, and logs; cross-run leakage is
|
|
56
|
+
treated as a critical (P0) bug.
|
|
57
|
+
|
|
58
|
+
## Develop
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
pnpm install
|
|
62
|
+
pnpm test
|
|
63
|
+
pnpm lint && pnpm typecheck && pnpm build
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
Apache-2.0
|
package/dist/bin.d.ts
ADDED
package/dist/bin.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// boardwalk-runner — the standalone self-hosted runner daemon (fleet installs: systemd,
|
|
4
|
+
// launchd, K8s, AMIs). The full Boardwalk CLI wraps the same daemon as `boardwalk runner …`
|
|
5
|
+
// with one-step enrollment; this binary is the two-step half: an admin mints a registration
|
|
6
|
+
// token (Settings > Runners / `boardwalk runner pools token`), the machine redeems it once,
|
|
7
|
+
// then `start` polls for work.
|
|
8
|
+
//
|
|
9
|
+
// boardwalk-runner register --url https://api.boardwalk.sh --token bwkreg_… \
|
|
10
|
+
// [--name <machine>] [--labels gpu,arm64]
|
|
11
|
+
// boardwalk-runner start --url https://api.boardwalk.sh --pool default \
|
|
12
|
+
// [--work-dir ~/.boardwalk/runner/work] [--once]
|
|
13
|
+
// boardwalk-runner deregister --url https://api.boardwalk.sh --pool default
|
|
14
|
+
//
|
|
15
|
+
// Corporate proxies: launch with NODE_USE_ENV_PROXY=1 and HTTPS_PROXY set — Node's fetch (the
|
|
16
|
+
// daemon) and the spawned run processes both honor it.
|
|
17
|
+
import { spawn as nodeSpawn } from "node:child_process";
|
|
18
|
+
import { readFileSync } from "node:fs";
|
|
19
|
+
import { fileURLToPath } from "node:url";
|
|
20
|
+
import * as path from "node:path";
|
|
21
|
+
import * as os from "node:os";
|
|
22
|
+
import { createLogger } from "./runtime/support/index.js";
|
|
23
|
+
import { runnerOsSchema, runnerArchSchema } from "./contract.js";
|
|
24
|
+
import { PoolClient, defaultIdentityDir, loadIdentity, removeIdentity, saveIdentity, startDaemon, } from "./daemon/index.js";
|
|
25
|
+
const log = createLogger("boardwalk-runner");
|
|
26
|
+
function flag(name) {
|
|
27
|
+
const i = process.argv.indexOf(`--${name}`);
|
|
28
|
+
const v = process.argv[i + 1];
|
|
29
|
+
return i === -1 || v === undefined || v.startsWith("--") ? undefined : v;
|
|
30
|
+
}
|
|
31
|
+
function hasFlag(name) {
|
|
32
|
+
return process.argv.includes(`--${name}`);
|
|
33
|
+
}
|
|
34
|
+
function requireFlag(name) {
|
|
35
|
+
const v = flag(name);
|
|
36
|
+
if (v === undefined) {
|
|
37
|
+
process.stderr.write(`Missing required --${name}\n`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
return v;
|
|
41
|
+
}
|
|
42
|
+
function machineOs() {
|
|
43
|
+
const map = { linux: "linux", darwin: "macos", win32: "windows" };
|
|
44
|
+
const parsed = runnerOsSchema.safeParse(map[process.platform]);
|
|
45
|
+
return parsed.success ? parsed.data : undefined;
|
|
46
|
+
}
|
|
47
|
+
function machineArch() {
|
|
48
|
+
const parsed = runnerArchSchema.safeParse(process.arch);
|
|
49
|
+
return parsed.success ? parsed.data : undefined;
|
|
50
|
+
}
|
|
51
|
+
/** Real spawner: one Node process per run, executing the SAME runtime a hosted worker boots.
|
|
52
|
+
* Env is exactly the platform contract + the claim's resolved vars, over a minimal base
|
|
53
|
+
* (PATH + proxy knobs from the daemon's own environment; HOME = the run's workspace). */
|
|
54
|
+
function realSpawn(opts) {
|
|
55
|
+
const base = {};
|
|
56
|
+
for (const key of [
|
|
57
|
+
"PATH",
|
|
58
|
+
"LANG",
|
|
59
|
+
"NODE_USE_ENV_PROXY",
|
|
60
|
+
"HTTPS_PROXY",
|
|
61
|
+
"https_proxy",
|
|
62
|
+
"HTTP_PROXY",
|
|
63
|
+
"http_proxy",
|
|
64
|
+
"NO_PROXY",
|
|
65
|
+
"no_proxy",
|
|
66
|
+
"BOARDWALK_RUNNER_DEBUG",
|
|
67
|
+
]) {
|
|
68
|
+
const v = process.env[key];
|
|
69
|
+
if (v !== undefined)
|
|
70
|
+
base[key] = v;
|
|
71
|
+
}
|
|
72
|
+
const child = nodeSpawn(process.execPath, [opts.entry], {
|
|
73
|
+
cwd: opts.cwd,
|
|
74
|
+
env: { ...base, HOME: opts.cwd, TMPDIR: path.join(opts.cwd, "..", "tmp"), ...opts.env },
|
|
75
|
+
stdio: "inherit",
|
|
76
|
+
});
|
|
77
|
+
const exit = new Promise((resolve) => {
|
|
78
|
+
child.on("exit", (code, signal) => {
|
|
79
|
+
resolve(code ?? (signal !== null ? 143 : 1));
|
|
80
|
+
});
|
|
81
|
+
child.on("error", () => {
|
|
82
|
+
resolve(1);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
wait: () => exit,
|
|
87
|
+
kill: () => {
|
|
88
|
+
child.kill("SIGTERM");
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
async function cmdRegister() {
|
|
93
|
+
const baseUrl = requireFlag("url");
|
|
94
|
+
const token = requireFlag("token");
|
|
95
|
+
const client = new PoolClient({ baseUrl });
|
|
96
|
+
const osName = machineOs();
|
|
97
|
+
const arch = machineArch();
|
|
98
|
+
const res = await client.register({
|
|
99
|
+
registration_token: token,
|
|
100
|
+
name: flag("name") ?? os.hostname(),
|
|
101
|
+
labels: (flag("labels") ?? "").split(",").filter((l) => l.length > 0),
|
|
102
|
+
...(osName !== undefined ? { os: osName } : {}),
|
|
103
|
+
...(arch !== undefined ? { arch } : {}),
|
|
104
|
+
runner_version: RUNNER_VERSION,
|
|
105
|
+
});
|
|
106
|
+
const file = await saveIdentity(flag("identity-dir") ?? defaultIdentityDir(), {
|
|
107
|
+
runner_id: res.runner_id,
|
|
108
|
+
runner_token: res.runner_token,
|
|
109
|
+
control_plane_url: baseUrl,
|
|
110
|
+
pool: res.pool,
|
|
111
|
+
name: flag("name") ?? os.hostname(),
|
|
112
|
+
created_at: Date.now(),
|
|
113
|
+
});
|
|
114
|
+
log.info("registered", { runnerId: res.runner_id, pool: res.pool, identity: file });
|
|
115
|
+
process.stdout.write(`Registered runner ${res.runner_id} in pool '${res.pool}'.\nStart it with: boardwalk-runner start --url ${baseUrl} --pool ${res.pool}\n`);
|
|
116
|
+
}
|
|
117
|
+
async function cmdStart() {
|
|
118
|
+
const baseUrl = requireFlag("url");
|
|
119
|
+
const pool = flag("pool") ?? "default";
|
|
120
|
+
const identityDir = flag("identity-dir") ?? defaultIdentityDir();
|
|
121
|
+
const identity = await loadIdentity(identityDir, baseUrl, pool);
|
|
122
|
+
if (identity === null) {
|
|
123
|
+
process.stderr.write(`No saved identity for ${baseUrl} pool '${pool}'. Run boardwalk-runner register first.\n`);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
const workDir = flag("work-dir") ?? path.join(identityDir, "work");
|
|
127
|
+
const runtimeEntry = fileURLToPath(new URL("./runtime/main.js", import.meta.url));
|
|
128
|
+
const client = new PoolClient({ baseUrl, runnerToken: identity.runner_token });
|
|
129
|
+
const daemon = startDaemon({
|
|
130
|
+
client,
|
|
131
|
+
runtimeEntry,
|
|
132
|
+
workDir,
|
|
133
|
+
runnerId: identity.runner_id,
|
|
134
|
+
spawn: realSpawn,
|
|
135
|
+
...(hasFlag("once") ? { once: true } : {}),
|
|
136
|
+
});
|
|
137
|
+
let interrupts = 0;
|
|
138
|
+
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
139
|
+
process.on(signal, () => {
|
|
140
|
+
interrupts += 1;
|
|
141
|
+
if (interrupts === 1) {
|
|
142
|
+
process.stderr.write("\nDraining: finishing the current run, claiming nothing new. Ctrl-C again to force-quit.\n");
|
|
143
|
+
daemon.drain();
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
process.exit(130);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
process.stdout.write(`Runner ${identity.name} online in pool '${pool}'. Waiting for runs...\n`);
|
|
151
|
+
await daemon.done;
|
|
152
|
+
}
|
|
153
|
+
async function cmdDeregister() {
|
|
154
|
+
const baseUrl = requireFlag("url");
|
|
155
|
+
const pool = flag("pool") ?? "default";
|
|
156
|
+
const identityDir = flag("identity-dir") ?? defaultIdentityDir();
|
|
157
|
+
const identity = await loadIdentity(identityDir, baseUrl, pool);
|
|
158
|
+
if (identity === null) {
|
|
159
|
+
process.stderr.write(`No saved identity for ${baseUrl} pool '${pool}'.\n`);
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|
|
162
|
+
await new PoolClient({ baseUrl, runnerToken: identity.runner_token }).deregister();
|
|
163
|
+
await removeIdentity(identityDir, baseUrl, pool);
|
|
164
|
+
process.stdout.write(`Deregistered runner ${identity.runner_id}.\n`);
|
|
165
|
+
}
|
|
166
|
+
// The client's own version (contract `runner_version`), read from package.json so a release
|
|
167
|
+
// bump is one file. Resolved relative to the compiled dist/bin.js.
|
|
168
|
+
const RUNNER_VERSION = (() => {
|
|
169
|
+
try {
|
|
170
|
+
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
171
|
+
if (typeof pkg === "object" && pkg !== null && "version" in pkg) {
|
|
172
|
+
const v = pkg.version;
|
|
173
|
+
if (typeof v === "string")
|
|
174
|
+
return v;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
// fall through
|
|
179
|
+
}
|
|
180
|
+
return "0.0.0";
|
|
181
|
+
})();
|
|
182
|
+
const USAGE = `boardwalk-runner <register|start|deregister> [flags]
|
|
183
|
+
|
|
184
|
+
register --url <control-plane> --token <bwkreg_…> [--name] [--labels a,b] [--identity-dir]
|
|
185
|
+
start --url <control-plane> [--pool default] [--work-dir] [--once] [--identity-dir]
|
|
186
|
+
deregister --url <control-plane> [--pool default] [--identity-dir]
|
|
187
|
+
|
|
188
|
+
--verbose debug-level daemon logs (poll cycles, heartbeats)
|
|
189
|
+
--debug --verbose, plus debug logging inside each spawned run process
|
|
190
|
+
`;
|
|
191
|
+
async function mainCli() {
|
|
192
|
+
// --verbose: debug-level daemon logs (poll cycles, heartbeats). --debug: the same, PLUS the
|
|
193
|
+
// spawned run processes log debug too (the env below is forwarded to children by realSpawn).
|
|
194
|
+
if (hasFlag("debug")) {
|
|
195
|
+
process.env.BOARDWALK_RUNNER_LOG_LEVEL = "debug";
|
|
196
|
+
process.env.BOARDWALK_RUNNER_DEBUG = "1";
|
|
197
|
+
}
|
|
198
|
+
else if (hasFlag("verbose")) {
|
|
199
|
+
process.env.BOARDWALK_RUNNER_LOG_LEVEL = "debug";
|
|
200
|
+
}
|
|
201
|
+
const cmd = process.argv[2];
|
|
202
|
+
if (cmd === "register")
|
|
203
|
+
return await cmdRegister();
|
|
204
|
+
if (cmd === "start")
|
|
205
|
+
return await cmdStart();
|
|
206
|
+
if (cmd === "deregister")
|
|
207
|
+
return await cmdDeregister();
|
|
208
|
+
process.stderr.write(USAGE);
|
|
209
|
+
process.exit(cmd === undefined || cmd === "--help" || cmd === "help" ? 0 : 1);
|
|
210
|
+
}
|
|
211
|
+
void mainCli().catch((err) => {
|
|
212
|
+
process.stderr.write(`${err instanceof Error ? err.message : String(err)}\n`);
|
|
213
|
+
process.exit(1);
|
|
214
|
+
});
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const runnerOsSchema: z.ZodEnum<{
|
|
3
|
+
linux: "linux";
|
|
4
|
+
macos: "macos";
|
|
5
|
+
windows: "windows";
|
|
6
|
+
}>;
|
|
7
|
+
export declare const runnerArchSchema: z.ZodEnum<{
|
|
8
|
+
x64: "x64";
|
|
9
|
+
arm64: "arm64";
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* POST /runner/v1/register, authenticated by the short-lived registration token in the body —
|
|
13
|
+
* the token IS the credential (single-purpose: it can register, nothing else) and it is BOUND
|
|
14
|
+
* to a pool at mint, so the request names no pool.
|
|
15
|
+
*/
|
|
16
|
+
export declare const runnerRegistrationRequestSchema: z.ZodObject<{
|
|
17
|
+
registration_token: z.ZodString;
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
labels: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
20
|
+
os: z.ZodOptional<z.ZodEnum<{
|
|
21
|
+
linux: "linux";
|
|
22
|
+
macos: "macos";
|
|
23
|
+
windows: "windows";
|
|
24
|
+
}>>;
|
|
25
|
+
arch: z.ZodOptional<z.ZodEnum<{
|
|
26
|
+
x64: "x64";
|
|
27
|
+
arm64: "arm64";
|
|
28
|
+
}>>;
|
|
29
|
+
runner_version: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strict>;
|
|
31
|
+
export type RunnerRegistrationRequest = z.infer<typeof runnerRegistrationRequestSchema>;
|
|
32
|
+
export declare const runnerRegistrationResponseSchema: z.ZodObject<{
|
|
33
|
+
runner_id: z.ZodString;
|
|
34
|
+
pool: z.ZodString;
|
|
35
|
+
runner_token: z.ZodString;
|
|
36
|
+
poll: z.ZodObject<{
|
|
37
|
+
url: z.ZodString;
|
|
38
|
+
interval_seconds: z.ZodNumber;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
export type RunnerRegistrationResponse = z.infer<typeof runnerRegistrationResponseSchema>;
|
|
42
|
+
/** The matched `runs_on` selector, echoed so the runner can re-verify it should run this. */
|
|
43
|
+
export declare const assignmentRunsOnSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
44
|
+
kind: z.ZodLiteral<"self-hosted">;
|
|
45
|
+
pool: z.ZodString;
|
|
46
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
47
|
+
}, z.core.$strict>, z.ZodString]>;
|
|
48
|
+
/**
|
|
49
|
+
* A polled offer is CREDENTIAL-FREE by design: identity + selector only. Committing to it
|
|
50
|
+
* (claim) is what mints credentials; the run's full context (manifest, program, workspace)
|
|
51
|
+
* is fetched after claim through the run-token'd Runner Control API.
|
|
52
|
+
*/
|
|
53
|
+
export declare const assignmentOfferSchema: z.ZodObject<{
|
|
54
|
+
assignment_id: z.ZodString;
|
|
55
|
+
run_id: z.ZodString;
|
|
56
|
+
org_id: z.ZodString;
|
|
57
|
+
runs_on: z.ZodUnion<readonly [z.ZodObject<{
|
|
58
|
+
kind: z.ZodLiteral<"self-hosted">;
|
|
59
|
+
pool: z.ZodString;
|
|
60
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
61
|
+
}, z.core.$strict>, z.ZodString]>;
|
|
62
|
+
queued_at: z.ZodNumber;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
export type AssignmentOffer = z.infer<typeof assignmentOfferSchema>;
|
|
65
|
+
/**
|
|
66
|
+
* Long-poll response: at most one offer. `action: "drain"` tells an idle runner to stop
|
|
67
|
+
* claiming (deregistration/update flow) — control signals are always brokered polls, never
|
|
68
|
+
* inbound connections to the runner.
|
|
69
|
+
*/
|
|
70
|
+
export declare const assignmentPollResponseSchema: z.ZodObject<{
|
|
71
|
+
assignment: z.ZodNullable<z.ZodObject<{
|
|
72
|
+
assignment_id: z.ZodString;
|
|
73
|
+
run_id: z.ZodString;
|
|
74
|
+
org_id: z.ZodString;
|
|
75
|
+
runs_on: z.ZodUnion<readonly [z.ZodObject<{
|
|
76
|
+
kind: z.ZodLiteral<"self-hosted">;
|
|
77
|
+
pool: z.ZodString;
|
|
78
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
79
|
+
}, z.core.$strict>, z.ZodString]>;
|
|
80
|
+
queued_at: z.ZodNumber;
|
|
81
|
+
}, z.core.$strict>>;
|
|
82
|
+
action: z.ZodOptional<z.ZodLiteral<"drain">>;
|
|
83
|
+
}, z.core.$strict>;
|
|
84
|
+
export type AssignmentPollResponse = z.infer<typeof assignmentPollResponseSchema>;
|
|
85
|
+
/**
|
|
86
|
+
* One BYO inference provider, as data: the runtime calls the endpoint directly (managed-lane
|
|
87
|
+
* inference stays brokered; managed providers are never listed). The auth secret resolves by
|
|
88
|
+
* NAME through the control plane with the run token — the value never rides this payload.
|
|
89
|
+
*/
|
|
90
|
+
export declare const byoInferenceProviderSchema: z.ZodObject<{
|
|
91
|
+
name: z.ZodString;
|
|
92
|
+
source: z.ZodString;
|
|
93
|
+
base_url: z.ZodNullable<z.ZodString>;
|
|
94
|
+
auth_secret_name: z.ZodNullable<z.ZodString>;
|
|
95
|
+
}, z.core.$strict>;
|
|
96
|
+
export type ByoInferenceProvider = z.infer<typeof byoInferenceProviderSchema>;
|
|
97
|
+
/**
|
|
98
|
+
* POST .../assignments/{assignment_id}/claim (runner-token authed; the bearer identifies the
|
|
99
|
+
* runner, the URL the assignment — no body). First claim wins; a loser gets a conflict and
|
|
100
|
+
* polls again. The response is the ONLY payload carrying per-run credentials.
|
|
101
|
+
*/
|
|
102
|
+
export declare const claimResponseSchema: z.ZodObject<{
|
|
103
|
+
lease_id: z.ZodString;
|
|
104
|
+
run_id: z.ZodString;
|
|
105
|
+
lease_expires_at: z.ZodNumber;
|
|
106
|
+
control_plane: z.ZodObject<{
|
|
107
|
+
base_url: z.ZodString;
|
|
108
|
+
run_token: z.ZodString;
|
|
109
|
+
api_token: z.ZodString;
|
|
110
|
+
}, z.core.$strict>;
|
|
111
|
+
env: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
112
|
+
byo_providers: z.ZodArray<z.ZodObject<{
|
|
113
|
+
name: z.ZodString;
|
|
114
|
+
source: z.ZodString;
|
|
115
|
+
base_url: z.ZodNullable<z.ZodString>;
|
|
116
|
+
auth_secret_name: z.ZodNullable<z.ZodString>;
|
|
117
|
+
}, z.core.$strict>>;
|
|
118
|
+
}, z.core.$strict>;
|
|
119
|
+
export type ClaimResponse = z.infer<typeof claimResponseSchema>;
|
|
120
|
+
export declare const heartbeatPhaseSchema: z.ZodEnum<{
|
|
121
|
+
preparing: "preparing";
|
|
122
|
+
running: "running";
|
|
123
|
+
finalizing: "finalizing";
|
|
124
|
+
}>;
|
|
125
|
+
/** The bearer identifies the runner; the body names the held lease. */
|
|
126
|
+
export declare const heartbeatRequestSchema: z.ZodObject<{
|
|
127
|
+
lease_id: z.ZodString;
|
|
128
|
+
run_id: z.ZodString;
|
|
129
|
+
phase: z.ZodEnum<{
|
|
130
|
+
preparing: "preparing";
|
|
131
|
+
running: "running";
|
|
132
|
+
finalizing: "finalizing";
|
|
133
|
+
}>;
|
|
134
|
+
}, z.core.$strict>;
|
|
135
|
+
export type HeartbeatRequest = z.infer<typeof heartbeatRequestSchema>;
|
|
136
|
+
/**
|
|
137
|
+
* The heartbeat response is the control channel: cancellation and drain arrive HERE (a
|
|
138
|
+
* brokered poll), never as an inbound connection to the runner.
|
|
139
|
+
*/
|
|
140
|
+
export declare const heartbeatResponseSchema: z.ZodObject<{
|
|
141
|
+
lease_expires_at: z.ZodNumber;
|
|
142
|
+
action: z.ZodEnum<{
|
|
143
|
+
drain: "drain";
|
|
144
|
+
continue: "continue";
|
|
145
|
+
cancel: "cancel";
|
|
146
|
+
}>;
|
|
147
|
+
}, z.core.$strict>;
|
|
148
|
+
export type HeartbeatResponse = z.infer<typeof heartbeatResponseSchema>;
|
|
149
|
+
/** Thrown when a contract payload fails validation. */
|
|
150
|
+
export declare class ContractValidationError extends Error {
|
|
151
|
+
constructor(message: string);
|
|
152
|
+
}
|
|
153
|
+
/** Parse with a readable multi-issue error (the schemas are strict — unknown fields fail). */
|
|
154
|
+
export declare function parseContract<T>(schema: z.ZodType<T>, payload: unknown, what: string): T;
|