@computesdk/quilt 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/__tests__/index.test.d.ts +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +635 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +610 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 computesdk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# @computesdk/quilt
|
|
2
|
+
|
|
3
|
+
Quilt provider for ComputeSDK.
|
|
4
|
+
|
|
5
|
+
This package maps ComputeSDK's sandbox interface onto Quilt's tenant-scoped container API. It supports container lifecycle, synchronous command execution, published HTTP/WebSocket services, shell-backed filesystem operations, and Quilt snapshots.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Create, inspect, list, and destroy Quilt containers
|
|
10
|
+
- Run shell commands through Quilt's synchronous `/exec` API
|
|
11
|
+
- Expose HTTP or WebSocket URLs through Quilt published services
|
|
12
|
+
- Read and write files inside the container filesystem through exec
|
|
13
|
+
- Create, list, and delete Quilt snapshots
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install computesdk @computesdk/quilt
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Configuration
|
|
22
|
+
|
|
23
|
+
The provider accepts config directly and falls back to environment variables.
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { quilt } from '@computesdk/quilt';
|
|
27
|
+
|
|
28
|
+
const provider = quilt({
|
|
29
|
+
baseUrl: process.env.QUILT_BASE_URL,
|
|
30
|
+
apiKey: process.env.QUILT_API_KEY,
|
|
31
|
+
tenantId: process.env.QUILT_TENANT_ID,
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Supported config fields:
|
|
36
|
+
|
|
37
|
+
- `baseUrl` or `QUILT_BASE_URL`: Quilt backend base URL
|
|
38
|
+
- `apiKey` or `QUILT_API_KEY`: Quilt API key
|
|
39
|
+
- `accessToken` or `QUILT_ACCESS_TOKEN`: Bearer token for JWT-backed deployments
|
|
40
|
+
- `tenantId` or `QUILT_TENANT_ID`: required for snapshot operations
|
|
41
|
+
- `image` or `QUILT_IMAGE`: default container image, defaults to `prod`
|
|
42
|
+
- `timeout` or `QUILT_TIMEOUT_MS`: default provider timeout in milliseconds
|
|
43
|
+
- `publishedServiceAuthMode` or `QUILT_PUBLISHED_SERVICE_AUTH_MODE`: `service_token` or `public`
|
|
44
|
+
- `publishedServiceTtlSecs` or `QUILT_PUBLISHED_SERVICE_TTL_SECS`: optional published-service TTL
|
|
45
|
+
- `pollIntervalMs` or `QUILT_POLL_INTERVAL_MS`: async operation polling interval
|
|
46
|
+
|
|
47
|
+
At least one of `apiKey` or `accessToken` must be configured.
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { compute } from 'computesdk';
|
|
53
|
+
import { quilt } from '@computesdk/quilt';
|
|
54
|
+
|
|
55
|
+
compute.setConfig({
|
|
56
|
+
provider: quilt({
|
|
57
|
+
baseUrl: process.env.QUILT_BASE_URL,
|
|
58
|
+
apiKey: process.env.QUILT_API_KEY,
|
|
59
|
+
tenantId: process.env.QUILT_TENANT_ID,
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const sandbox = await compute.sandbox.create({
|
|
64
|
+
name: 'computesdk-demo',
|
|
65
|
+
envs: {
|
|
66
|
+
APP_ENV: 'dev',
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const result = await sandbox.runCommand('echo "hello from Quilt"');
|
|
71
|
+
console.log(result.stdout);
|
|
72
|
+
|
|
73
|
+
const url = await sandbox.getUrl({ port: 3000 });
|
|
74
|
+
console.log(url);
|
|
75
|
+
|
|
76
|
+
await sandbox.destroy();
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Snapshot Support
|
|
80
|
+
|
|
81
|
+
Snapshot operations require `tenantId` because Quilt validates `X-Tenant-Id` on snapshot routes.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
const snapshot = await provider.snapshot?.create(sandbox.sandboxId, {
|
|
85
|
+
name: 'baseline',
|
|
86
|
+
metadata: { branch: 'main' },
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Limitations
|
|
91
|
+
|
|
92
|
+
- `getUrl()` maps to Quilt published services, so it is HTTP/WebSocket only
|
|
93
|
+
- Filesystem operations are implemented over shell exec for portability across Quilt containers
|
|
94
|
+
- `template` operations are not exposed because Quilt's closest equivalents are image references and snapshots, which map differently
|
|
95
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Snapshot } from 'computesdk';
|
|
2
|
+
type QuiltAuthMode = 'apiKey' | 'accessToken';
|
|
3
|
+
type QuiltServiceAuthMode = 'service_token' | 'public';
|
|
4
|
+
type QuiltContainerState = 'created' | 'starting' | 'running' | 'exited' | 'error';
|
|
5
|
+
export interface QuiltConfig {
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
accessToken?: string;
|
|
9
|
+
tenantId?: string;
|
|
10
|
+
image?: string;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
publishedServiceAuthMode?: QuiltServiceAuthMode;
|
|
13
|
+
publishedServiceTtlSecs?: number;
|
|
14
|
+
pollIntervalMs?: number;
|
|
15
|
+
}
|
|
16
|
+
interface QuiltResolvedConfig {
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
authMode: QuiltAuthMode;
|
|
19
|
+
authToken: string;
|
|
20
|
+
tenantId?: string;
|
|
21
|
+
image: string;
|
|
22
|
+
timeout: number;
|
|
23
|
+
publishedServiceAuthMode: QuiltServiceAuthMode;
|
|
24
|
+
publishedServiceTtlSecs?: number;
|
|
25
|
+
pollIntervalMs: number;
|
|
26
|
+
}
|
|
27
|
+
interface QuiltContainer {
|
|
28
|
+
container_id: string;
|
|
29
|
+
tenant_id?: string;
|
|
30
|
+
name?: string;
|
|
31
|
+
state?: QuiltContainerState;
|
|
32
|
+
created_at?: string;
|
|
33
|
+
started_at?: string | null;
|
|
34
|
+
exited_at?: string | null;
|
|
35
|
+
ip_address?: string | null;
|
|
36
|
+
exec_ready?: boolean;
|
|
37
|
+
network_ready?: boolean;
|
|
38
|
+
labels?: Record<string, string>;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
interface QuiltSandboxHandle {
|
|
42
|
+
config: QuiltResolvedConfig;
|
|
43
|
+
sandboxId: string;
|
|
44
|
+
container: QuiltContainer;
|
|
45
|
+
}
|
|
46
|
+
export declare const quilt: (config: QuiltConfig) => import("@computesdk/provider").Provider<QuiltSandboxHandle, never, Snapshot>;
|
|
47
|
+
export {};
|