@skaile/provider-vercel-sandbox 0.0.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/CHANGELOG.md +5 -0
- package/LICENSE +201 -0
- package/README.md +59 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +100 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Skaile
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @skaile/provider-vercel-sandbox
|
|
2
|
+
|
|
3
|
+
A [Vercel Sandbox](https://vercel.com/docs/vercel-sandbox) deploy target for
|
|
4
|
+
[`@skaile/workspaces`](https://www.npmjs.com/package/@skaile/workspaces). It runs
|
|
5
|
+
a workspace inside a Vercel Sandbox and reaches it over the sandbox's public TLS
|
|
6
|
+
domain.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
skaile plugin install @skaile/provider-vercel-sandbox
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The `@vercel/sandbox` SDK is an **optional peer dependency** — install it in your
|
|
15
|
+
project so the provider can lazy-load it at runtime:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @vercel/sandbox
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Add it to `skaile.yaml`:
|
|
22
|
+
|
|
23
|
+
```yaml
|
|
24
|
+
plugins:
|
|
25
|
+
- "@skaile/provider-vercel-sandbox@^0.1.0"
|
|
26
|
+
|
|
27
|
+
deploy:
|
|
28
|
+
target: vercel-sandbox
|
|
29
|
+
config:
|
|
30
|
+
token: ${VERCEL_TOKEN}
|
|
31
|
+
runtime: node22
|
|
32
|
+
port: 8080
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Config
|
|
36
|
+
|
|
37
|
+
| Field | Type | Default | Notes |
|
|
38
|
+
|---|---|---|---|
|
|
39
|
+
| `token` | string | — | Vercel access token |
|
|
40
|
+
| `teamId` | string | — | Vercel team id |
|
|
41
|
+
| `projectId` | string | — | Vercel project id |
|
|
42
|
+
| `runtime` | string | `node22` | Sandbox runtime |
|
|
43
|
+
| `port` | number | `8080` | Workspace WS port |
|
|
44
|
+
| `timeout` | number | `300000` | Sandbox max lifetime (ms) |
|
|
45
|
+
| `buildStrategy` | `local \| remote \| managed` | `remote` | |
|
|
46
|
+
|
|
47
|
+
## How it works
|
|
48
|
+
|
|
49
|
+
- `@vercel/sandbox` is lazy-loaded via a dynamic `import()` inside
|
|
50
|
+
`create()`/`restore()`, so this package builds and typechecks without the SDK
|
|
51
|
+
installed (offline-safe).
|
|
52
|
+
- `wsUrl` is derived from `sandbox.domain(port)` with `https` → `wss`
|
|
53
|
+
(`tlsTermination: "edge"`).
|
|
54
|
+
|
|
55
|
+
## Limitations (v0.1.0)
|
|
56
|
+
|
|
57
|
+
- Requires `@vercel/sandbox` installed in the host project at runtime.
|
|
58
|
+
- `restore()` reads `VERCEL_TOKEN` from the environment (config is not persisted
|
|
59
|
+
in the handle payload).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { DeployTarget, PluginRegistry } from '@skaile/workspaces/plugin-registry';
|
|
2
|
+
import * as z from 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Minimal local interface for the `@vercel/sandbox` SDK — only the members this
|
|
6
|
+
* provider actually calls.
|
|
7
|
+
*
|
|
8
|
+
* We deliberately do NOT import the real package's types at compile time: the
|
|
9
|
+
* SDK is an *optional* peer dependency, lazy-loaded via a string-literal dynamic
|
|
10
|
+
* `import()` at runtime. Typing against this minimal surface keeps the package
|
|
11
|
+
* building + typechecking standalone (offline-safe), while the user's project
|
|
12
|
+
* supplies the real SDK at runtime.
|
|
13
|
+
*/
|
|
14
|
+
/** A live Vercel Sandbox instance (subset). */
|
|
15
|
+
interface VercelSandbox {
|
|
16
|
+
readonly sandboxId: string;
|
|
17
|
+
/** Public URL for a given exposed port. */
|
|
18
|
+
domain(port: number): string;
|
|
19
|
+
stop(): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/** The `@vercel/sandbox` module surface we depend on. */
|
|
22
|
+
interface VercelSandboxModule {
|
|
23
|
+
Sandbox: {
|
|
24
|
+
create(opts: {
|
|
25
|
+
token?: string;
|
|
26
|
+
teamId?: string;
|
|
27
|
+
projectId?: string;
|
|
28
|
+
runtime?: string;
|
|
29
|
+
timeout?: number;
|
|
30
|
+
ports?: number[];
|
|
31
|
+
}): Promise<VercelSandbox>;
|
|
32
|
+
get(opts: {
|
|
33
|
+
sandboxId: string;
|
|
34
|
+
token?: string;
|
|
35
|
+
}): Promise<VercelSandbox>;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** Loader seam: returns the SDK module. Default does a real dynamic import. */
|
|
39
|
+
type SdkLoader = () => Promise<VercelSandboxModule>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* `vercelSandboxDeployTarget` — deploy a workspace into a Vercel Sandbox and
|
|
43
|
+
* reach it over the sandbox's public TLS domain. `tlsTermination: "edge"`.
|
|
44
|
+
*
|
|
45
|
+
* `@vercel/sandbox` is an *optional* peer dependency, lazy-loaded inside
|
|
46
|
+
* `create()`/`restore()` via an injectable loader (`opts.loadSdk`, default
|
|
47
|
+
* `defaultSdkLoader`). This keeps the package building standalone offline; the
|
|
48
|
+
* test injects a fake loader so it never imports the real SDK.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
declare const vercelConfigSchema: z.ZodObject<{
|
|
52
|
+
token: z.ZodOptional<z.ZodString>;
|
|
53
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
54
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
55
|
+
runtime: z.ZodDefault<z.ZodString>;
|
|
56
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
57
|
+
timeout: z.ZodDefault<z.ZodNumber>;
|
|
58
|
+
buildStrategy: z.ZodDefault<z.ZodEnum<{
|
|
59
|
+
local: "local";
|
|
60
|
+
remote: "remote";
|
|
61
|
+
managed: "managed";
|
|
62
|
+
}>>;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
type VercelConfig = z.infer<typeof vercelConfigSchema>;
|
|
65
|
+
declare const vercelPayloadSchema: z.ZodObject<{
|
|
66
|
+
sandboxId: z.ZodString;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
type VercelPayload = z.infer<typeof vercelPayloadSchema>;
|
|
69
|
+
/** Injectable seams so tests never load the real `@vercel/sandbox`. */
|
|
70
|
+
interface VercelSandboxTargetOptions {
|
|
71
|
+
loadSdk?: SdkLoader;
|
|
72
|
+
}
|
|
73
|
+
/** Build the Vercel Sandbox deploy target with an optional injected SDK loader. */
|
|
74
|
+
declare function makeVercelSandboxDeployTarget(opts?: VercelSandboxTargetOptions): DeployTarget<VercelConfig, VercelPayload>;
|
|
75
|
+
/** Default Vercel Sandbox deploy target registered by `register()`. */
|
|
76
|
+
declare const vercelSandboxDeployTarget: DeployTarget<{
|
|
77
|
+
runtime: string;
|
|
78
|
+
port: number;
|
|
79
|
+
timeout: number;
|
|
80
|
+
buildStrategy: "local" | "remote" | "managed";
|
|
81
|
+
token?: string | undefined;
|
|
82
|
+
teamId?: string | undefined;
|
|
83
|
+
projectId?: string | undefined;
|
|
84
|
+
}, {
|
|
85
|
+
sandboxId: string;
|
|
86
|
+
}>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* `@skaile/provider-vercel-sandbox` — Vercel Sandbox deploy target for
|
|
90
|
+
* `@skaile/workspaces`.
|
|
91
|
+
*
|
|
92
|
+
* Requires the optional peer `@vercel/sandbox` to be installed in the host
|
|
93
|
+
* project (lazy-loaded at runtime). Install via
|
|
94
|
+
* `skaile plugin install @skaile/provider-vercel-sandbox`.
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
/** Register this plugin's deploy target with a registry. */
|
|
98
|
+
declare function register(registry: PluginRegistry): void;
|
|
99
|
+
|
|
100
|
+
export { type SdkLoader, type VercelSandbox, type VercelSandboxModule, type VercelSandboxTargetOptions, makeVercelSandboxDeployTarget, register, vercelSandboxDeployTarget };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// src/target.ts
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
|
|
4
|
+
// src/sdk-types.ts
|
|
5
|
+
var defaultSdkLoader = async () => {
|
|
6
|
+
const mod = await import("@vercel/sandbox");
|
|
7
|
+
if (!mod?.Sandbox) {
|
|
8
|
+
throw new Error(
|
|
9
|
+
"@vercel/sandbox is not installed. Run `skaile plugin install @skaile/provider-vercel-sandbox` and add @vercel/sandbox to your project."
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
return mod;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// src/target.ts
|
|
16
|
+
var vercelConfigSchema = z.object({
|
|
17
|
+
token: z.string().optional(),
|
|
18
|
+
teamId: z.string().optional(),
|
|
19
|
+
projectId: z.string().optional(),
|
|
20
|
+
runtime: z.string().default("node22"),
|
|
21
|
+
port: z.number().int().positive().default(8080),
|
|
22
|
+
timeout: z.number().int().positive().default(3e5),
|
|
23
|
+
buildStrategy: z.enum(["local", "remote", "managed"]).default("remote")
|
|
24
|
+
}).strict();
|
|
25
|
+
var vercelPayloadSchema = z.object({
|
|
26
|
+
sandboxId: z.string()
|
|
27
|
+
});
|
|
28
|
+
function buildHandle(sandbox, config, ctx, initialState) {
|
|
29
|
+
let state = initialState;
|
|
30
|
+
let stopped = false;
|
|
31
|
+
const wsUrl = sandbox.domain(config.port).replace(/^http/, "ws");
|
|
32
|
+
return {
|
|
33
|
+
wsUrl,
|
|
34
|
+
wsAuth: ctx.wsAuth ? "<redacted>" : void 0,
|
|
35
|
+
get state() {
|
|
36
|
+
return state;
|
|
37
|
+
},
|
|
38
|
+
payload: { sandboxId: sandbox.sandboxId },
|
|
39
|
+
async waitReady(timeoutMs) {
|
|
40
|
+
state = "ready";
|
|
41
|
+
void timeoutMs;
|
|
42
|
+
},
|
|
43
|
+
async health() {
|
|
44
|
+
return stopped ? { healthy: false, detail: `sandbox ${sandbox.sandboxId} stopped` } : { healthy: true };
|
|
45
|
+
},
|
|
46
|
+
async stop() {
|
|
47
|
+
state = "stopping";
|
|
48
|
+
if (!stopped) {
|
|
49
|
+
await sandbox.stop();
|
|
50
|
+
stopped = true;
|
|
51
|
+
}
|
|
52
|
+
state = "stopped";
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function makeVercelSandboxDeployTarget(opts = {}) {
|
|
57
|
+
const loadSdk = opts.loadSdk ?? defaultSdkLoader;
|
|
58
|
+
return {
|
|
59
|
+
id: "vercel-sandbox",
|
|
60
|
+
displayName: "Vercel Sandbox",
|
|
61
|
+
apiVersion: 1,
|
|
62
|
+
tlsTermination: "edge",
|
|
63
|
+
configSchema: vercelConfigSchema,
|
|
64
|
+
payloadSchema: vercelPayloadSchema,
|
|
65
|
+
async create(config, ctx) {
|
|
66
|
+
const { Sandbox } = await loadSdk();
|
|
67
|
+
const sandbox = await Sandbox.create({
|
|
68
|
+
token: config.token,
|
|
69
|
+
teamId: config.teamId,
|
|
70
|
+
projectId: config.projectId,
|
|
71
|
+
runtime: config.runtime,
|
|
72
|
+
timeout: config.timeout,
|
|
73
|
+
ports: [config.port]
|
|
74
|
+
});
|
|
75
|
+
ctx.log.info("vercel sandbox created", { sandboxId: sandbox.sandboxId });
|
|
76
|
+
return buildHandle(sandbox, config, ctx, "starting");
|
|
77
|
+
},
|
|
78
|
+
async restore(payload, ctx) {
|
|
79
|
+
const { Sandbox } = await loadSdk();
|
|
80
|
+
const sandbox = await Sandbox.get({
|
|
81
|
+
sandboxId: payload.sandboxId,
|
|
82
|
+
token: ctx.env.VERCEL_TOKEN
|
|
83
|
+
});
|
|
84
|
+
ctx.log.info("re-attached to vercel sandbox", { sandboxId: payload.sandboxId });
|
|
85
|
+
return buildHandle(sandbox, { port: 8080 }, ctx, "ready");
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
var vercelSandboxDeployTarget = makeVercelSandboxDeployTarget();
|
|
90
|
+
|
|
91
|
+
// src/index.ts
|
|
92
|
+
function register(registry) {
|
|
93
|
+
registry.register("deployTarget", vercelSandboxDeployTarget);
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
makeVercelSandboxDeployTarget,
|
|
97
|
+
register,
|
|
98
|
+
vercelSandboxDeployTarget
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/target.ts","../src/sdk-types.ts","../src/index.ts"],"sourcesContent":["/**\n * `vercelSandboxDeployTarget` — deploy a workspace into a Vercel Sandbox and\n * reach it over the sandbox's public TLS domain. `tlsTermination: \"edge\"`.\n *\n * `@vercel/sandbox` is an *optional* peer dependency, lazy-loaded inside\n * `create()`/`restore()` via an injectable loader (`opts.loadSdk`, default\n * `defaultSdkLoader`). This keeps the package building standalone offline; the\n * test injects a fake loader so it never imports the real SDK.\n */\n\nimport type { DeployContext, DeployHandle, DeployTarget } from \"@skaile/workspaces/plugin-registry\";\nimport * as z from \"zod\";\nimport { defaultSdkLoader, type SdkLoader, type VercelSandbox } from \"./sdk-types.js\";\n\nconst vercelConfigSchema = z\n .object({\n token: z.string().optional(),\n teamId: z.string().optional(),\n projectId: z.string().optional(),\n runtime: z.string().default(\"node22\"),\n port: z.number().int().positive().default(8080),\n timeout: z.number().int().positive().default(300_000),\n buildStrategy: z.enum([\"local\", \"remote\", \"managed\"]).default(\"remote\"),\n })\n .strict();\n\ntype VercelConfig = z.infer<typeof vercelConfigSchema>;\n\nconst vercelPayloadSchema = z.object({\n sandboxId: z.string(),\n});\n\ntype VercelPayload = z.infer<typeof vercelPayloadSchema>;\n\n/** Injectable seams so tests never load the real `@vercel/sandbox`. */\nexport interface VercelSandboxTargetOptions {\n loadSdk?: SdkLoader;\n}\n\nfunction buildHandle(\n sandbox: VercelSandbox,\n config: Pick<VercelConfig, \"port\">,\n ctx: DeployContext,\n initialState: DeployHandle[\"state\"],\n): DeployHandle<VercelPayload> {\n let state: DeployHandle[\"state\"] = initialState;\n let stopped = false;\n // Vercel exposes the sandbox over an https domain; swap to wss for the WS URL.\n const wsUrl = sandbox.domain(config.port).replace(/^http/, \"ws\");\n return {\n wsUrl,\n wsAuth: ctx.wsAuth ? \"<redacted>\" : undefined,\n get state() {\n return state;\n },\n payload: { sandboxId: sandbox.sandboxId },\n async waitReady(timeoutMs?: number) {\n // `Sandbox.create` resolves once the sandbox is up, so readiness is\n // immediate here; the marker just flips the handle state.\n state = \"ready\";\n void timeoutMs;\n },\n async health() {\n return stopped\n ? { healthy: false, detail: `sandbox ${sandbox.sandboxId} stopped` }\n : { healthy: true };\n },\n async stop() {\n state = \"stopping\";\n if (!stopped) {\n await sandbox.stop();\n stopped = true;\n }\n state = \"stopped\";\n },\n };\n}\n\n/** Build the Vercel Sandbox deploy target with an optional injected SDK loader. */\nexport function makeVercelSandboxDeployTarget(\n opts: VercelSandboxTargetOptions = {},\n): DeployTarget<VercelConfig, VercelPayload> {\n const loadSdk = opts.loadSdk ?? defaultSdkLoader;\n\n return {\n id: \"vercel-sandbox\",\n displayName: \"Vercel Sandbox\",\n apiVersion: 1,\n tlsTermination: \"edge\",\n configSchema: vercelConfigSchema as unknown as z.ZodType<VercelConfig>,\n payloadSchema: vercelPayloadSchema,\n\n async create(config, ctx) {\n const { Sandbox } = await loadSdk();\n const sandbox = await Sandbox.create({\n token: config.token,\n teamId: config.teamId,\n projectId: config.projectId,\n runtime: config.runtime,\n timeout: config.timeout,\n ports: [config.port],\n });\n ctx.log.info(\"vercel sandbox created\", { sandboxId: sandbox.sandboxId });\n return buildHandle(sandbox, config, ctx, \"starting\");\n },\n\n async restore(payload, ctx) {\n const { Sandbox } = await loadSdk();\n const sandbox = await Sandbox.get({\n sandboxId: payload.sandboxId,\n token: ctx.env.VERCEL_TOKEN,\n });\n ctx.log.info(\"re-attached to vercel sandbox\", { sandboxId: payload.sandboxId });\n return buildHandle(sandbox, { port: 8080 }, ctx, \"ready\");\n },\n };\n}\n\n/** Default Vercel Sandbox deploy target registered by `register()`. */\nexport const vercelSandboxDeployTarget = makeVercelSandboxDeployTarget();\n","/**\n * Minimal local interface for the `@vercel/sandbox` SDK — only the members this\n * provider actually calls.\n *\n * We deliberately do NOT import the real package's types at compile time: the\n * SDK is an *optional* peer dependency, lazy-loaded via a string-literal dynamic\n * `import()` at runtime. Typing against this minimal surface keeps the package\n * building + typechecking standalone (offline-safe), while the user's project\n * supplies the real SDK at runtime.\n */\n\n/** A live Vercel Sandbox instance (subset). */\nexport interface VercelSandbox {\n readonly sandboxId: string;\n /** Public URL for a given exposed port. */\n domain(port: number): string;\n stop(): Promise<void>;\n}\n\n/** The `@vercel/sandbox` module surface we depend on. */\nexport interface VercelSandboxModule {\n Sandbox: {\n create(opts: {\n token?: string;\n teamId?: string;\n projectId?: string;\n runtime?: string;\n timeout?: number;\n ports?: number[];\n }): Promise<VercelSandbox>;\n get(opts: { sandboxId: string; token?: string }): Promise<VercelSandbox>;\n };\n}\n\n/** Loader seam: returns the SDK module. Default does a real dynamic import. */\nexport type SdkLoader = () => Promise<VercelSandboxModule>;\n\n/**\n * Default loader: lazy `import(\"@vercel/sandbox\")`. The string literal keeps\n * bundlers from eagerly resolving the optional peer; it is only evaluated when\n * `create()`/`restore()` actually run.\n */\nexport const defaultSdkLoader: SdkLoader = async () => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const mod = (await import(\"@vercel/sandbox\" as string)) as unknown as VercelSandboxModule;\n if (!mod?.Sandbox) {\n throw new Error(\n \"@vercel/sandbox is not installed. Run `skaile plugin install @skaile/provider-vercel-sandbox` and add @vercel/sandbox to your project.\",\n );\n }\n return mod;\n};\n","/**\n * `@skaile/provider-vercel-sandbox` — Vercel Sandbox deploy target for\n * `@skaile/workspaces`.\n *\n * Requires the optional peer `@vercel/sandbox` to be installed in the host\n * project (lazy-loaded at runtime). Install via\n * `skaile plugin install @skaile/provider-vercel-sandbox`.\n */\n\nimport type { PluginRegistry } from \"@skaile/workspaces/plugin-registry\";\nimport { vercelSandboxDeployTarget } from \"./target.js\";\n\nexport {\n makeVercelSandboxDeployTarget,\n vercelSandboxDeployTarget,\n} from \"./target.js\";\nexport type { VercelSandboxTargetOptions } from \"./target.js\";\nexport type { SdkLoader, VercelSandbox, VercelSandboxModule } from \"./sdk-types.js\";\n\n/** Register this plugin's deploy target with a registry. */\nexport function register(registry: PluginRegistry): void {\n registry.register(\"deployTarget\", vercelSandboxDeployTarget);\n}\n"],"mappings":";AAWA,YAAY,OAAO;;;AC+BZ,IAAM,mBAA8B,YAAY;AAErD,QAAM,MAAO,MAAM,OAAO,iBAA2B;AACrD,MAAI,CAAC,KAAK,SAAS;AACjB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;ADrCA,IAAM,qBACH,SAAO;AAAA,EACN,OAAS,SAAO,EAAE,SAAS;AAAA,EAC3B,QAAU,SAAO,EAAE,SAAS;AAAA,EAC5B,WAAa,SAAO,EAAE,SAAS;AAAA,EAC/B,SAAW,SAAO,EAAE,QAAQ,QAAQ;AAAA,EACpC,MAAQ,SAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,IAAI;AAAA,EAC9C,SAAW,SAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,GAAO;AAAA,EACpD,eAAiB,OAAK,CAAC,SAAS,UAAU,SAAS,CAAC,EAAE,QAAQ,QAAQ;AACxE,CAAC,EACA,OAAO;AAIV,IAAM,sBAAwB,SAAO;AAAA,EACnC,WAAa,SAAO;AACtB,CAAC;AASD,SAAS,YACP,SACA,QACA,KACA,cAC6B;AAC7B,MAAI,QAA+B;AACnC,MAAI,UAAU;AAEd,QAAM,QAAQ,QAAQ,OAAO,OAAO,IAAI,EAAE,QAAQ,SAAS,IAAI;AAC/D,SAAO;AAAA,IACL;AAAA,IACA,QAAQ,IAAI,SAAS,eAAe;AAAA,IACpC,IAAI,QAAQ;AACV,aAAO;AAAA,IACT;AAAA,IACA,SAAS,EAAE,WAAW,QAAQ,UAAU;AAAA,IACxC,MAAM,UAAU,WAAoB;AAGlC,cAAQ;AACR,WAAK;AAAA,IACP;AAAA,IACA,MAAM,SAAS;AACb,aAAO,UACH,EAAE,SAAS,OAAO,QAAQ,WAAW,QAAQ,SAAS,WAAW,IACjE,EAAE,SAAS,KAAK;AAAA,IACtB;AAAA,IACA,MAAM,OAAO;AACX,cAAQ;AACR,UAAI,CAAC,SAAS;AACZ,cAAM,QAAQ,KAAK;AACnB,kBAAU;AAAA,MACZ;AACA,cAAQ;AAAA,IACV;AAAA,EACF;AACF;AAGO,SAAS,8BACd,OAAmC,CAAC,GACO;AAC3C,QAAM,UAAU,KAAK,WAAW;AAEhC,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,cAAc;AAAA,IACd,eAAe;AAAA,IAEf,MAAM,OAAO,QAAQ,KAAK;AACxB,YAAM,EAAE,QAAQ,IAAI,MAAM,QAAQ;AAClC,YAAM,UAAU,MAAM,QAAQ,OAAO;AAAA,QACnC,OAAO,OAAO;AAAA,QACd,QAAQ,OAAO;AAAA,QACf,WAAW,OAAO;AAAA,QAClB,SAAS,OAAO;AAAA,QAChB,SAAS,OAAO;AAAA,QAChB,OAAO,CAAC,OAAO,IAAI;AAAA,MACrB,CAAC;AACD,UAAI,IAAI,KAAK,0BAA0B,EAAE,WAAW,QAAQ,UAAU,CAAC;AACvE,aAAO,YAAY,SAAS,QAAQ,KAAK,UAAU;AAAA,IACrD;AAAA,IAEA,MAAM,QAAQ,SAAS,KAAK;AAC1B,YAAM,EAAE,QAAQ,IAAI,MAAM,QAAQ;AAClC,YAAM,UAAU,MAAM,QAAQ,IAAI;AAAA,QAChC,WAAW,QAAQ;AAAA,QACnB,OAAO,IAAI,IAAI;AAAA,MACjB,CAAC;AACD,UAAI,IAAI,KAAK,iCAAiC,EAAE,WAAW,QAAQ,UAAU,CAAC;AAC9E,aAAO,YAAY,SAAS,EAAE,MAAM,KAAK,GAAG,KAAK,OAAO;AAAA,IAC1D;AAAA,EACF;AACF;AAGO,IAAM,4BAA4B,8BAA8B;;;AEnGhE,SAAS,SAAS,UAAgC;AACvD,WAAS,SAAS,gBAAgB,yBAAyB;AAC7D;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@skaile/provider-vercel-sandbox",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Vercel Sandbox deploy target for @skaile/workspaces",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"CHANGELOG.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=20"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@skaile/workspaces": ">=0.22.0-0",
|
|
26
|
+
"@vercel/sandbox": ">=0.0.1"
|
|
27
|
+
},
|
|
28
|
+
"peerDependenciesMeta": {
|
|
29
|
+
"@vercel/sandbox": {
|
|
30
|
+
"optional": true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@skaile/workspaces": "0.21.0"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"test:watch": "vitest",
|
|
41
|
+
"format": "biome format --write .",
|
|
42
|
+
"lint": "biome lint .",
|
|
43
|
+
"check": "biome check ."
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/skaile-ai/workspaces.git",
|
|
51
|
+
"directory": "packages/provider-vercel-sandbox"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://github.com/skaile-ai/workspaces/tree/main/packages/provider-vercel-sandbox#readme",
|
|
54
|
+
"bugs": "https://github.com/skaile-ai/workspaces/issues",
|
|
55
|
+
"license": "Apache-2.0",
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"zod": "^4.4.0"
|
|
58
|
+
}
|
|
59
|
+
}
|