@alchemy.run/boat 0.0.0-stage → 2.0.0-beta.86
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 +70 -2
- package/lib/AiProxy.d.ts +89 -0
- package/lib/AiProxy.d.ts.map +1 -0
- package/lib/AiProxy.js +125 -0
- package/lib/AiProxy.js.map +1 -0
- package/lib/ApiKey.d.ts +105 -0
- package/lib/ApiKey.d.ts.map +1 -0
- package/lib/ApiKey.js +134 -0
- package/lib/ApiKey.js.map +1 -0
- package/lib/AuthProvider.d.ts +71 -0
- package/lib/AuthProvider.d.ts.map +1 -0
- package/lib/AuthProvider.js +322 -0
- package/lib/AuthProvider.js.map +1 -0
- package/lib/BoatBindings.d.ts +52 -0
- package/lib/BoatBindings.d.ts.map +1 -0
- package/lib/BoatBindings.js +104 -0
- package/lib/BoatBindings.js.map +1 -0
- package/lib/Bootstrap.d.ts +8 -0
- package/lib/Bootstrap.d.ts.map +1 -0
- package/lib/Bootstrap.js +28 -0
- package/lib/Bootstrap.js.map +1 -0
- package/lib/ConnectSandbox.d.ts +56 -0
- package/lib/ConnectSandbox.d.ts.map +1 -0
- package/lib/ConnectSandbox.js +3 -0
- package/lib/ConnectSandbox.js.map +1 -0
- package/lib/ConnectSandboxHttp.d.ts +21 -0
- package/lib/ConnectSandboxHttp.d.ts.map +1 -0
- package/lib/ConnectSandboxHttp.js +46 -0
- package/lib/ConnectSandboxHttp.js.map +1 -0
- package/lib/Contributions.d.ts +7 -0
- package/lib/Contributions.d.ts.map +1 -0
- package/lib/Contributions.js +6 -0
- package/lib/Contributions.js.map +1 -0
- package/lib/CreateSandbox.d.ts +134 -0
- package/lib/CreateSandbox.d.ts.map +1 -0
- package/lib/CreateSandbox.js +3 -0
- package/lib/CreateSandbox.js.map +1 -0
- package/lib/CreateSandboxHttp.d.ts +21 -0
- package/lib/CreateSandboxHttp.d.ts.map +1 -0
- package/lib/CreateSandboxHttp.js +93 -0
- package/lib/CreateSandboxHttp.js.map +1 -0
- package/lib/CredentialProfile.d.ts +157 -0
- package/lib/CredentialProfile.d.ts.map +1 -0
- package/lib/CredentialProfile.js +245 -0
- package/lib/CredentialProfile.js.map +1 -0
- package/lib/Credentials.d.ts +15 -0
- package/lib/Credentials.d.ts.map +1 -0
- package/lib/Credentials.js +23 -0
- package/lib/Credentials.js.map +1 -0
- package/lib/Environment.d.ts +219 -0
- package/lib/Environment.d.ts.map +1 -0
- package/lib/Environment.js +273 -0
- package/lib/Environment.js.map +1 -0
- package/lib/Errors.d.ts +50 -0
- package/lib/Errors.d.ts.map +1 -0
- package/lib/Errors.js +17 -0
- package/lib/Errors.js.map +1 -0
- package/lib/Providers.d.ts +33 -0
- package/lib/Providers.d.ts.map +1 -0
- package/lib/Providers.js +47 -0
- package/lib/Providers.js.map +1 -0
- package/lib/Sandbox.d.ts +205 -0
- package/lib/Sandbox.d.ts.map +1 -0
- package/lib/Sandbox.js +368 -0
- package/lib/Sandbox.js.map +1 -0
- package/lib/SandboxClient.d.ts +159 -0
- package/lib/SandboxClient.d.ts.map +1 -0
- package/lib/SandboxClient.js +1 -0
- package/lib/SandboxClient.js.map +1 -0
- package/lib/SandboxEvents.d.ts +111 -0
- package/lib/SandboxEvents.d.ts.map +1 -0
- package/lib/SandboxEvents.js +60 -0
- package/lib/SandboxEvents.js.map +1 -0
- package/lib/SandboxEventsLive.d.ts +13 -0
- package/lib/SandboxEventsLive.d.ts.map +1 -0
- package/lib/SandboxEventsLive.js +63 -0
- package/lib/SandboxEventsLive.js.map +1 -0
- package/lib/Snapshot.d.ts +123 -0
- package/lib/Snapshot.d.ts.map +1 -0
- package/lib/Snapshot.js +186 -0
- package/lib/Snapshot.js.map +1 -0
- package/lib/Webhook.d.ts +56 -0
- package/lib/Webhook.d.ts.map +1 -0
- package/lib/Webhook.js +98 -0
- package/lib/Webhook.js.map +1 -0
- package/lib/index.d.ts +19 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +19 -0
- package/lib/index.js.map +1 -0
- package/lib/internal/Declared.d.ts +34 -0
- package/lib/internal/Declared.d.ts.map +1 -0
- package/lib/internal/Declared.js +38 -0
- package/lib/internal/Declared.js.map +1 -0
- package/lib/internal/Org.d.ts +22 -0
- package/lib/internal/Org.d.ts.map +1 -0
- package/lib/internal/Org.js +23 -0
- package/lib/internal/Org.js.map +1 -0
- package/lib/internal/Ownership.d.ts +29 -0
- package/lib/internal/Ownership.d.ts.map +1 -0
- package/lib/internal/Ownership.js +50 -0
- package/lib/internal/Ownership.js.map +1 -0
- package/lib/internal/Program.d.ts +69 -0
- package/lib/internal/Program.d.ts.map +1 -0
- package/lib/internal/Program.js +178 -0
- package/lib/internal/Program.js.map +1 -0
- package/lib/internal/Ref.d.ts +14 -0
- package/lib/internal/Ref.d.ts.map +1 -0
- package/lib/internal/Ref.js +7 -0
- package/lib/internal/Ref.js.map +1 -0
- package/lib/internal/SandboxHandle.d.ts +17 -0
- package/lib/internal/SandboxHandle.d.ts.map +1 -0
- package/lib/internal/SandboxHandle.js +249 -0
- package/lib/internal/SandboxHandle.js.map +1 -0
- package/lib/internal/WebhookDelivery.d.ts +16 -0
- package/lib/internal/WebhookDelivery.d.ts.map +1 -0
- package/lib/internal/WebhookDelivery.js +109 -0
- package/lib/internal/WebhookDelivery.js.map +1 -0
- package/package.json +81 -3
- package/src/AiProxy.ts +171 -0
- package/src/ApiKey.ts +250 -0
- package/src/AuthProvider.ts +472 -0
- package/src/BoatBindings.ts +136 -0
- package/src/Bootstrap.ts +55 -0
- package/src/ConnectSandbox.ts +60 -0
- package/src/ConnectSandboxHttp.ts +59 -0
- package/src/Contributions.ts +9 -0
- package/src/CreateSandbox.ts +143 -0
- package/src/CreateSandboxHttp.ts +115 -0
- package/src/CredentialProfile.ts +350 -0
- package/src/Credentials.ts +33 -0
- package/src/Environment.ts +416 -0
- package/src/Errors.ts +34 -0
- package/src/Providers.ts +71 -0
- package/src/Sandbox.ts +647 -0
- package/src/SandboxClient.ts +199 -0
- package/src/SandboxEvents.ts +125 -0
- package/src/SandboxEventsLive.ts +88 -0
- package/src/Snapshot.ts +284 -0
- package/src/Webhook.ts +163 -0
- package/src/globals.d.ts +2 -0
- package/src/index.ts +18 -0
- package/src/internal/Declared.ts +87 -0
- package/src/internal/Org.ts +31 -0
- package/src/internal/Ownership.ts +75 -0
- package/src/internal/Program.ts +250 -0
- package/src/internal/Ref.ts +15 -0
- package/src/internal/SandboxHandle.ts +425 -0
- package/src/internal/WebhookDelivery.ts +179 -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 [yyyy] [name of copyright owner]
|
|
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
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @alchemy.run/boat
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Boat](https://boat.dev) for [Alchemy](https://alchemy.run). Boat runs sandboxes: Linux machines with Docker, passwordless `sudo` and a desktop that start in under a second, stop on a timer with their disk saved, and resume, fork or snapshot from where they stopped. Declare sandboxes, snapshots, environments and webhooks in your Stack, and create sandboxes from any Worker or Lambda.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install alchemy @alchemy.run/boat effect
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
A sandbox that runs a program. Alchemy bundles it, uploads it and starts it with Node.js, and serves its port at a URL:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
// src/Api.ts
|
|
13
|
+
import * as Boat from "@alchemy.run/boat";
|
|
14
|
+
import * as Effect from "effect/Effect";
|
|
15
|
+
import * as HttpServerResponse from "effect/http/HttpServerResponse";
|
|
16
|
+
|
|
17
|
+
export default class Api extends Boat.Sandbox<Api>()(
|
|
18
|
+
"Api",
|
|
19
|
+
{ main: import.meta.url, type: "small", noEnv: true, public: true },
|
|
20
|
+
Effect.gen(function* () {
|
|
21
|
+
return {
|
|
22
|
+
fetch: Effect.gen(function* () {
|
|
23
|
+
return yield* HttpServerResponse.json({ ok: true });
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
}),
|
|
27
|
+
) {}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
// alchemy.run.ts
|
|
32
|
+
import * as Boat from "@alchemy.run/boat";
|
|
33
|
+
import * as Alchemy from "alchemy";
|
|
34
|
+
import * as Effect from "effect/Effect";
|
|
35
|
+
import Api from "./src/Api.ts";
|
|
36
|
+
|
|
37
|
+
export default Alchemy.Stack(
|
|
38
|
+
"MyApp",
|
|
39
|
+
{ providers: Boat.providers(), state: Alchemy.localState() },
|
|
40
|
+
Effect.gen(function* () {
|
|
41
|
+
const api = yield* Api;
|
|
42
|
+
return { url: api.url.as<string>() };
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
A deploy that changes the code restarts the program in the same sandbox, so its disk and URL stay the same.
|
|
48
|
+
|
|
49
|
+
For a sandbox per request or per task, build a snapshot once at deploy and bind `Boat.CreateSandbox(Golden)` in a Worker or Lambda. Each sandbox starts with the snapshot's disk:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// src/Golden.ts
|
|
53
|
+
import * as Boat from "@alchemy.run/boat";
|
|
54
|
+
|
|
55
|
+
export const Golden = Boat.Snapshot("Golden", {
|
|
56
|
+
run: ["git clone --depth 1 https://github.com/sindresorhus/is ~/repo"],
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
const sandboxes = yield* Boat.CreateSandbox(Golden);
|
|
62
|
+
|
|
63
|
+
// per request
|
|
64
|
+
const sandbox = yield* Effect.acquireRelease(
|
|
65
|
+
sandboxes.create({ noEnv: true, autoStop: "5 minutes" }),
|
|
66
|
+
(sandbox) => Effect.ignore(sandbox.delete()),
|
|
67
|
+
);
|
|
68
|
+
const result = yield* sandbox.exec("npm test", { cwd: "/home/user/repo" });
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Docs: [alchemy.run/boat](https://alchemy.run/boat) · [Setup](https://alchemy.run/boat/setup) · [Tutorial](https://alchemy.run/boat/tutorial/part-1). Reference: [alchemy.run/providers](https://alchemy.run/providers).
|
package/lib/AiProxy.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as boat from "@distilled.cloud/boat-dev/boat";
|
|
2
|
+
import * as Provider from "alchemy/Provider";
|
|
3
|
+
import { Resource } from "alchemy/Resource";
|
|
4
|
+
import type { Providers } from "./Providers.ts";
|
|
5
|
+
export interface AiProxyProps {
|
|
6
|
+
/**
|
|
7
|
+
* Whether the account's AI credentials proxy is on. While it is on, Boat
|
|
8
|
+
* bills the account $1 a day, and $1 per 1,000 proxied requests to the
|
|
9
|
+
* wallet each sandbox bills.
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface AiProxyAttributes {
|
|
15
|
+
/** The account the switch belongs to: you, or an organization. */
|
|
16
|
+
accountId: string;
|
|
17
|
+
/**
|
|
18
|
+
* The organization whose switch this is, as the stack's `org` named it;
|
|
19
|
+
* `undefined` for your own.
|
|
20
|
+
*/
|
|
21
|
+
org: string | undefined;
|
|
22
|
+
/** Whether the proxy is on. */
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
/** Where sandboxes send proxied requests. */
|
|
25
|
+
proxyUrl: string;
|
|
26
|
+
/**
|
|
27
|
+
* What the switch was before Alchemy first changed it. Destroying the
|
|
28
|
+
* resource puts it back.
|
|
29
|
+
*/
|
|
30
|
+
initialEnabled: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface AiProxy extends Resource<"Boat.AiProxy", AiProxyProps, AiProxyAttributes, never, Providers> {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The AI credentials proxy switch of a Boat account.
|
|
36
|
+
*
|
|
37
|
+
* With the proxy on, a sandbox gets placeholders in place of the keys of
|
|
38
|
+
* its credential profile, and the proxy's URL in place of each base URL.
|
|
39
|
+
* Boat swaps in the real key as a request passes through, so the key never
|
|
40
|
+
* enters the sandbox, and a copied placeholder stops working when the
|
|
41
|
+
* sandbox stops.
|
|
42
|
+
*
|
|
43
|
+
* :::caution
|
|
44
|
+
* The proxy is billed: $1 for each day it is on, and $1 per 1,000 proxied
|
|
45
|
+
* requests. It is one switch for a whole account, so turning it on changes
|
|
46
|
+
* every sandbox that uses one of the account's credential profiles, at its
|
|
47
|
+
* next start.
|
|
48
|
+
* :::
|
|
49
|
+
*
|
|
50
|
+
* The switch is yours, or an organization's. With an `org` on the stack
|
|
51
|
+
* (`Boat.providers({ org })`, or the profile's) it is the organization's,
|
|
52
|
+
* which only an owner can change. That is the same account that owns the
|
|
53
|
+
* stack's `Boat.CredentialProfile`s.
|
|
54
|
+
*
|
|
55
|
+
* The switch always exists, so nothing is created or deleted. Destroying
|
|
56
|
+
* the resource puts the switch back the way it was found.
|
|
57
|
+
*
|
|
58
|
+
* ### Turning the proxy on
|
|
59
|
+
* **Example:** Proxy the credentials of sandboxes you hand to users
|
|
60
|
+
* ```typescript
|
|
61
|
+
* export const MyProfile = Boat.CredentialProfile("MyProfile", {
|
|
62
|
+
* anthropic: Config.Redacted("ANTHROPIC_API_KEY"),
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* export const Proxy = Boat.AiProxy("Proxy", { enabled: true });
|
|
66
|
+
*
|
|
67
|
+
* export const Tenants = Boat.Environment("Tenants", {
|
|
68
|
+
* safeForThirdParties: true,
|
|
69
|
+
* credentialProfile: MyProfile,
|
|
70
|
+
* proxyAiCredentials: Proxy,
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* `proxyAiCredentials` takes the proxy itself, so the environment is updated
|
|
75
|
+
* after the switch, and proxies only while it is on. Boat rejects
|
|
76
|
+
* `proxyAiCredentials: true` while the proxy is off.
|
|
77
|
+
*
|
|
78
|
+
* ### Turning the proxy off
|
|
79
|
+
* **Example:** Keep it off
|
|
80
|
+
* ```typescript
|
|
81
|
+
* export const Proxy = Boat.AiProxy("Proxy", { enabled: false });
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @resource
|
|
85
|
+
* @product AI Proxy
|
|
86
|
+
*/
|
|
87
|
+
export declare const AiProxy: import("alchemy/Resource").ResourceClass<AiProxy>;
|
|
88
|
+
export declare const AiProxyProvider: () => import("effect/Layer").Layer<Provider.Provider<AiProxy>, never, boat.BoatOpContext>;
|
|
89
|
+
//# sourceMappingURL=AiProxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiProxy.d.ts","sources":["../src/AiProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gCAAgC,CAAC;AACvD,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,+BAA+B;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,OAAQ,SAAQ,QAAQ,CACvC,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,KAAK,EACL,SAAS,CACV;CAAG;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,eAAO,MAAM,OAAO,mDAAoC,CAAC;AASzD,eAAO,MAAM,eAAe,2FAgEzB,CAAC"}
|
package/lib/AiProxy.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as boat from "@distilled.cloud/boat-dev/boat";
|
|
2
|
+
import * as Provider from "alchemy/Provider";
|
|
3
|
+
import { Resource } from "alchemy/Resource";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import { sameOrg, stackOrg } from "./internal/Org.js";
|
|
6
|
+
/**
|
|
7
|
+
* The AI credentials proxy switch of a Boat account.
|
|
8
|
+
*
|
|
9
|
+
* With the proxy on, a sandbox gets placeholders in place of the keys of
|
|
10
|
+
* its credential profile, and the proxy's URL in place of each base URL.
|
|
11
|
+
* Boat swaps in the real key as a request passes through, so the key never
|
|
12
|
+
* enters the sandbox, and a copied placeholder stops working when the
|
|
13
|
+
* sandbox stops.
|
|
14
|
+
*
|
|
15
|
+
* :::caution
|
|
16
|
+
* The proxy is billed: $1 for each day it is on, and $1 per 1,000 proxied
|
|
17
|
+
* requests. It is one switch for a whole account, so turning it on changes
|
|
18
|
+
* every sandbox that uses one of the account's credential profiles, at its
|
|
19
|
+
* next start.
|
|
20
|
+
* :::
|
|
21
|
+
*
|
|
22
|
+
* The switch is yours, or an organization's. With an `org` on the stack
|
|
23
|
+
* (`Boat.providers({ org })`, or the profile's) it is the organization's,
|
|
24
|
+
* which only an owner can change. That is the same account that owns the
|
|
25
|
+
* stack's `Boat.CredentialProfile`s.
|
|
26
|
+
*
|
|
27
|
+
* The switch always exists, so nothing is created or deleted. Destroying
|
|
28
|
+
* the resource puts the switch back the way it was found.
|
|
29
|
+
*
|
|
30
|
+
* ### Turning the proxy on
|
|
31
|
+
* **Example:** Proxy the credentials of sandboxes you hand to users
|
|
32
|
+
* ```typescript
|
|
33
|
+
* export const MyProfile = Boat.CredentialProfile("MyProfile", {
|
|
34
|
+
* anthropic: Config.Redacted("ANTHROPIC_API_KEY"),
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* export const Proxy = Boat.AiProxy("Proxy", { enabled: true });
|
|
38
|
+
*
|
|
39
|
+
* export const Tenants = Boat.Environment("Tenants", {
|
|
40
|
+
* safeForThirdParties: true,
|
|
41
|
+
* credentialProfile: MyProfile,
|
|
42
|
+
* proxyAiCredentials: Proxy,
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* `proxyAiCredentials` takes the proxy itself, so the environment is updated
|
|
47
|
+
* after the switch, and proxies only while it is on. Boat rejects
|
|
48
|
+
* `proxyAiCredentials: true` while the proxy is off.
|
|
49
|
+
*
|
|
50
|
+
* ### Turning the proxy off
|
|
51
|
+
* **Example:** Keep it off
|
|
52
|
+
* ```typescript
|
|
53
|
+
* export const Proxy = Boat.AiProxy("Proxy", { enabled: false });
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @resource
|
|
57
|
+
* @product AI Proxy
|
|
58
|
+
*/
|
|
59
|
+
export const AiProxy = Resource("Boat.AiProxy");
|
|
60
|
+
/**
|
|
61
|
+
* The account a call addresses. Without an `org`, Boat answers for the
|
|
62
|
+
* active wallet, which may be an organization's, so your own switch is
|
|
63
|
+
* named explicitly.
|
|
64
|
+
*/
|
|
65
|
+
const account = (org) => ({ org: org ?? "personal" });
|
|
66
|
+
export const AiProxyProvider = () => Provider.effect(AiProxy, Effect.gen(function* () {
|
|
67
|
+
return {
|
|
68
|
+
nuke: { singleton: true },
|
|
69
|
+
stables: ["accountId", "org", "initialEnabled"],
|
|
70
|
+
// Each account has its own switch.
|
|
71
|
+
diff: Effect.fn(function* ({ output }) {
|
|
72
|
+
if (output !== undefined && !sameOrg(output.org, yield* stackOrg)) {
|
|
73
|
+
return { action: "replace" };
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
// The switch always exists and belongs to nobody, so a cold read
|
|
77
|
+
// adopts it; what it shows then is what destroy restores.
|
|
78
|
+
read: Effect.fn(function* ({ output }) {
|
|
79
|
+
const org = output ? output.org : yield* stackOrg;
|
|
80
|
+
const observed = yield* boat.getAiProxy(account(org));
|
|
81
|
+
return {
|
|
82
|
+
accountId: observed.accountId,
|
|
83
|
+
org,
|
|
84
|
+
enabled: observed.enabled,
|
|
85
|
+
proxyUrl: observed.proxyUrl,
|
|
86
|
+
initialEnabled: output !== undefined ? output.initialEnabled : observed.enabled,
|
|
87
|
+
};
|
|
88
|
+
}),
|
|
89
|
+
reconcile: Effect.fn(function* ({ news, output, session }) {
|
|
90
|
+
const org = yield* stackOrg;
|
|
91
|
+
const desired = news.enabled ?? true;
|
|
92
|
+
// Observe.
|
|
93
|
+
const observed = yield* boat.getAiProxy(account(org));
|
|
94
|
+
// Capture what it was before the first change, for destroy.
|
|
95
|
+
const initialEnabled = output !== undefined ? output.initialEnabled : observed.enabled;
|
|
96
|
+
// Sync — only when it differs.
|
|
97
|
+
if (observed.enabled === desired) {
|
|
98
|
+
return {
|
|
99
|
+
accountId: observed.accountId,
|
|
100
|
+
org,
|
|
101
|
+
enabled: observed.enabled,
|
|
102
|
+
proxyUrl: observed.proxyUrl,
|
|
103
|
+
initialEnabled,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
yield* session.note(`Turning the AI credentials proxy ${desired ? "on" : "off"}...`);
|
|
107
|
+
const updated = yield* boat.updateAiProxy({ ...account(org), enabled: desired });
|
|
108
|
+
return {
|
|
109
|
+
accountId: updated.accountId,
|
|
110
|
+
org,
|
|
111
|
+
enabled: updated.enabled,
|
|
112
|
+
proxyUrl: updated.proxyUrl,
|
|
113
|
+
initialEnabled,
|
|
114
|
+
};
|
|
115
|
+
}),
|
|
116
|
+
// Put the switch back the way it was found.
|
|
117
|
+
delete: Effect.fn(function* ({ output }) {
|
|
118
|
+
const observed = yield* boat.getAiProxy(account(output.org));
|
|
119
|
+
if (observed.enabled === output.initialEnabled)
|
|
120
|
+
return;
|
|
121
|
+
yield* boat.updateAiProxy({ ...account(output.org), enabled: output.initialEnabled });
|
|
122
|
+
}),
|
|
123
|
+
};
|
|
124
|
+
}));
|
|
125
|
+
//# sourceMappingURL=AiProxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiProxy.js","sources":["../src/AiProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gCAAgC,CAAC;AACvD,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAwCtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAU,cAAc,CAAC,CAAC;AAEzD;;;;GAIG;AACH,MAAM,OAAO,GAAG,CAAC,GAAuB,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,UAAU,EAAE,CAAC,CAAC;AAE1E,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE,CAClC,QAAQ,CAAC,MAAM,CACb,OAAO,EACP,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,OAAO;QACL,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;QACzB,OAAO,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,gBAAgB,CAAC;QAC/C,mCAAmC;QACnC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ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CAAC;KACH,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
|
package/lib/ApiKey.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import * as boat from "@distilled.cloud/boat-dev/boat";
|
|
2
|
+
import * as Provider from "alchemy/Provider";
|
|
3
|
+
import { Resource } from "alchemy/Resource";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Redacted from "effect/Redacted";
|
|
6
|
+
import type { Providers } from "./Providers.ts";
|
|
7
|
+
/**
|
|
8
|
+
* What a key may do. `read-only` inspects; `full-sandbox` operates
|
|
9
|
+
* sandboxes without creating, resuming, forking or deleting them; `ci` adds
|
|
10
|
+
* create, resume, fork, and delete of the sandboxes the key created;
|
|
11
|
+
* `admin` is everything.
|
|
12
|
+
*/
|
|
13
|
+
export type ApiKeyPreset = "read-only" | "full-sandbox" | "ci" | "admin";
|
|
14
|
+
/**
|
|
15
|
+
* One permission. `sandbox.delete-own` deletes only the sandboxes the key
|
|
16
|
+
* created; `host` hosts a port; `account.admin` covers billing, teams,
|
|
17
|
+
* webhooks and keys.
|
|
18
|
+
* @see https://docs.boat.dev/api-keys/scopes
|
|
19
|
+
*/
|
|
20
|
+
export type ApiKeyAction = "sandbox.create" | "sandbox.read" | "sandbox.update" | "sandbox.stop" | "sandbox.resume" | "sandbox.fork" | "sandbox.delete" | "sandbox.delete-own" | "agent.prompt" | "exec" | "file.read" | "file.write" | "ssh" | "desktop" | "host" | "snapshot.read" | "snapshot.write" | "environment.read" | "environment.write" | "account.read" | "account.admin" | "*";
|
|
21
|
+
export interface ApiKeyProps {
|
|
22
|
+
/**
|
|
23
|
+
* Key name. If omitted, a unique name is generated from the stack, stage
|
|
24
|
+
* and logical ID. Changing it replaces the key.
|
|
25
|
+
*/
|
|
26
|
+
name?: string;
|
|
27
|
+
/**
|
|
28
|
+
* A preset set of actions. Use either `preset` or `actions`; with
|
|
29
|
+
* neither, the key is an `admin` key. Changing it replaces the key.
|
|
30
|
+
*/
|
|
31
|
+
preset?: ApiKeyPreset;
|
|
32
|
+
/** The actions the key may take. Changing them replaces the key. */
|
|
33
|
+
actions?: ApiKeyAction[];
|
|
34
|
+
/**
|
|
35
|
+
* The only sandboxes the key reaches, by id. Omit to reach every
|
|
36
|
+
* sandbox. Changing them replaces the key.
|
|
37
|
+
*/
|
|
38
|
+
sandboxIds?: string[];
|
|
39
|
+
/**
|
|
40
|
+
* Environments whose sandboxes the key reaches, by id. Changing them
|
|
41
|
+
* replaces the key.
|
|
42
|
+
*/
|
|
43
|
+
environmentIds?: string[];
|
|
44
|
+
/**
|
|
45
|
+
* How long the key works: `90d`, `24h`, a number of seconds, up to
|
|
46
|
+
* `365d`, or `never` for a key that works until it is revoked. A key
|
|
47
|
+
* can't outlive the key that creates it: omitted, the key never expires
|
|
48
|
+
* when the deployer's key doesn't, and otherwise expires with it.
|
|
49
|
+
* Changing it replaces the key.
|
|
50
|
+
*/
|
|
51
|
+
ttl?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface ApiKeyAttributes {
|
|
54
|
+
/** Boat's key id. */
|
|
55
|
+
apiKeyId: string;
|
|
56
|
+
name: string;
|
|
57
|
+
/** The key (`boat_…`), sent as a bearer token. Boat shows it once; Alchemy keeps it in state. */
|
|
58
|
+
key: Redacted.Redacted<string>;
|
|
59
|
+
/** The key's first characters, as the dashboard shows them. */
|
|
60
|
+
keyPrefix: string;
|
|
61
|
+
/** The key's last four characters. */
|
|
62
|
+
keyLastFour: string;
|
|
63
|
+
/** When the key stops working, or `undefined` for a key that never expires. */
|
|
64
|
+
expiresAt: string | undefined;
|
|
65
|
+
}
|
|
66
|
+
export interface ApiKey extends Resource<"Boat.ApiKey", ApiKeyProps, ApiKeyAttributes, never, Providers> {
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A scoped Boat API key: the actions it may take, and the sandboxes or
|
|
70
|
+
* environments it reaches. Give each app or CI system its own key with
|
|
71
|
+
* only what it needs.
|
|
72
|
+
*
|
|
73
|
+
* Boat shows a key once, when it is created, so Alchemy keeps it in state
|
|
74
|
+
* as a `Redacted` value. Changing any prop creates a new key and revokes
|
|
75
|
+
* the old one; destroying the resource revokes it.
|
|
76
|
+
*
|
|
77
|
+
* Creating a key needs a key with `account.admin`, such as the one
|
|
78
|
+
* `alchemy profile edit --add Boat` signs in with. A new key cannot have
|
|
79
|
+
* more actions, more sandboxes or a later expiry than the key creating it.
|
|
80
|
+
* The key a browser sign-in gets lasts a year, so keys it creates expire
|
|
81
|
+
* with it. An expired key is minted again on the next deploy.
|
|
82
|
+
*
|
|
83
|
+
* ### Creating an API key
|
|
84
|
+
* **Example:** A key for CI that manages the sandboxes it creates
|
|
85
|
+
* ```typescript
|
|
86
|
+
* export const Ci = Boat.ApiKey("Ci", { preset: "ci", ttl: "90d" });
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* **Example:** A key that only runs commands in one sandbox
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const box = yield* Boat.Sandbox("Box", {});
|
|
92
|
+
* const key = yield* Boat.ApiKey("BoxExec", {
|
|
93
|
+
* actions: ["sandbox.read", "exec", "file.read", "file.write"],
|
|
94
|
+
* sandboxIds: [box.sandboxId],
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @resource
|
|
99
|
+
* @product API key
|
|
100
|
+
*/
|
|
101
|
+
export declare const ApiKey: import("alchemy/Resource").ResourceClass<ApiKey>;
|
|
102
|
+
/** Revoke a key; revoking one that is gone succeeds. */
|
|
103
|
+
export declare const revokeApiKey: (apiKeyId: string) => Effect.Effect<void, import("@distilled.cloud/boat-dev").BadGateway | import("@distilled.cloud/core/errors").BadRequest | import("@distilled.cloud/boat-dev").BoatParseError | import("@distilled.cloud/boat-dev").ConfigError | import("@distilled.cloud/core/errors").Conflict | import("@distilled.cloud/core/errors").Forbidden | boat.Forbidden | import("@distilled.cloud/boat-dev").GatewayTimeout | import("effect/http/HttpClientError").HttpClientError | import("@distilled.cloud/boat-dev").InternalServerError | import("@distilled.cloud/core/protocol-http").InvalidInput | import("@distilled.cloud/boat-dev").Locked | import("@distilled.cloud/core/sdk-error").SdkError | import("@distilled.cloud/boat-dev").ServiceUnavailable | import("@distilled.cloud/boat-dev").TooManyRequests | import("@distilled.cloud/boat-dev").Unauthorized | import("@distilled.cloud/boat-dev").UnknownBoatError | import("@distilled.cloud/boat-dev").UnprocessableEntity, boat.BoatOpContext>;
|
|
104
|
+
export declare const ApiKeyProvider: () => import("effect/Layer").Layer<Provider.Provider<ApiKey>, never, import("alchemy/Stack").Stack | import("alchemy/Stage").Stage | boat.BoatOpContext>;
|
|
105
|
+
//# sourceMappingURL=ApiKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiKey.d.ts","sources":["../src/ApiKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gCAAgC,CAAC;AAGvD,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,cAAc,GAAG,IAAI,GAAG,OAAO,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GACpB,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAChB,oBAAoB,GACpB,cAAc,GACd,MAAM,GACN,WAAW,GACX,YAAY,GACZ,KAAK,GACL,SAAS,GACT,MAAM,GACN,eAAe,GACf,gBAAgB,GAChB,kBAAkB,GAClB,mBAAmB,GACnB,cAAc,GACd,eAAe,GACf,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