quilt-sdk 0.0.4 → 0.0.6

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.
Files changed (2) hide show
  1. package/README.md +184 -32
  2. package/package.json +20 -3
package/README.md CHANGED
@@ -1,51 +1,150 @@
1
1
  # quilt-sdk
2
2
 
3
- Type-safe TypeScript SDK for interacting with Quilt platform APIs.
3
+ Type-safe TypeScript SDK for Quilt production APIs.
4
4
 
5
- This package is the interaction plane for Quilt production APIs, including:
6
-
7
- - Core HTTP API resources (`containers`, `volumes`, `projects`, `clusters`, `functions`, etc.)
8
- - Production platform extensions (`platform` module: env/jobs/archive/ops/ICC and related endpoints)
9
- - Realtime APIs (SSE events and WebSocket terminal attach)
10
- - OpenAI-compatible tool schema export (`QUILT_TOOLS`)
5
+ `quilt-sdk` is the programmatic client for the live Quilt backend. It is intended to be the typed source of truth for production automation, not a thin convenience wrapper around ad hoc fetch calls.
11
6
 
12
7
  ## Install
13
8
 
9
+ ```bash
10
+ npm install quilt-sdk
11
+ ```
12
+
13
+ or
14
+
14
15
  ```bash
15
16
  bun add quilt-sdk
16
17
  ```
17
18
 
19
+ ## Requirements
20
+
21
+ - Node `>=20.10.0`
22
+ - Quilt backend URL, usually `https://backend.quilt.sh`
23
+ - either `QUILT_API_KEY` or `QUILT_JWT`
24
+
18
25
  ## Quick Start
19
26
 
20
27
  ```ts
21
28
  import { QuiltClient } from "quilt-sdk";
22
29
 
23
- const quilt = QuiltClient.connect({
24
- baseUrl: "https://backend.quilt.sh",
30
+ const client = QuiltClient.connect({
31
+ baseUrl: process.env.QUILT_BASE_URL ?? "https://backend.quilt.sh",
25
32
  apiKey: process.env.QUILT_API_KEY,
26
33
  });
27
34
 
28
- const containers = await quilt.containers.list();
29
- console.log(containers);
35
+ const health = await client.system.health();
36
+ const containers = await client.containers.list();
37
+
38
+ console.log(health.status);
39
+ console.log(containers.containers.length);
30
40
  ```
31
41
 
32
42
  ## Auth
33
43
 
34
44
  `QuiltClient.connect()` accepts:
35
45
 
36
- - `token` for bearer auth
37
46
  - `apiKey` for `X-Api-Key`
38
- - explicit `auth` union for advanced usage
47
+ - `token` for bearer auth
48
+ - `auth` for the explicit auth union when you need to control the transport directly
49
+
50
+ If both `apiKey` and `token` are provided, API key auth wins.
51
+
52
+ ## Core Client Shape
53
+
54
+ ```ts
55
+ import { QuiltClient } from "quilt-sdk";
56
+
57
+ const client = QuiltClient.connect({
58
+ baseUrl: "https://backend.quilt.sh",
59
+ apiKey: process.env.QUILT_API_KEY,
60
+ });
61
+ ```
62
+
63
+ Primary SDK surfaces:
64
+
65
+ - `client.system` for health, info, and activity
66
+ - `client.containers` for container lifecycle, exec, logs, metrics, snapshots, network, and GUI URLs
67
+ - `client.platform` for cross-cutting routes such as operations, env maps, archives, jobs, ICC, OCI, and helper control flows
68
+ - `client.volumes` for volume lifecycle and file browsing
69
+ - `client.clusters` for cluster, node, workload, placement, and join-token control-plane flows
70
+ - `client.agent` for join-token and node-token authenticated agent calls
71
+ - `client.functions` for serverless lifecycle, invoke, versions, invocations, and pool status
72
+ - `client.elasticity` for resize, pool targeting, and orchestrator-safe control actions
73
+ - `client.terminal` and `client.terminalRealtime` for terminal session lifecycle and WebSocket attach
74
+ - `client.events` for SSE streams
75
+ - `client.raw(...)` for authenticated access to backend routes that are intentionally still exposed as raw contract calls
76
+
77
+ ## Docker-Compatible Images
78
+
79
+ Quilt supports Docker-compatible registry image ingress through the OCI image routes and normal container create.
80
+
81
+ That means:
82
+
83
+ - pull an image from Docker Hub or another OCI-compatible registry
84
+ - inspect or list the stored image metadata
85
+ - create a container from that pulled image with `oci: true`
86
+
87
+ This is image compatibility, not Docker Engine API compatibility.
88
+
89
+ Registry pull:
90
+
91
+ ```ts
92
+ const pulled = await client.platform.ociPull({
93
+ reference: "docker.io/library/alpine:3.20",
94
+ });
95
+ ```
96
+
97
+ Create from the pulled image:
98
+
99
+ ```ts
100
+ const accepted = await client.containers.create(
101
+ {
102
+ name: "oci-demo",
103
+ image: "docker.io/library/alpine:3.20",
104
+ oci: true,
105
+ command: ["sleep", "60"],
106
+ },
107
+ "async",
108
+ );
109
+ ```
110
+
111
+ ## Public Types
39
112
 
40
- If both `token` and `apiKey` are provided, API key auth is used.
113
+ The SDK ships declarations automatically through the package export.
114
+
115
+ Use the client-owned type surface when you need explicit types:
116
+
117
+ ```ts
118
+ import { QuiltClient } from "quilt-sdk";
119
+
120
+ const options: QuiltClient.Options = {
121
+ baseUrl: "https://backend.quilt.sh",
122
+ apiKey: process.env.QUILT_API_KEY,
123
+ };
124
+
125
+ let invocation: QuiltClient.Functions.Invocation | null = null;
126
+ let resize: QuiltClient.Elasticity.ContainerResizeResponse | null = null;
127
+ ```
128
+
129
+ That keeps consumer imports simple while still exposing the production contract.
130
+
131
+ ## Execution Model
132
+
133
+ Use the SDK in the same execution style the backend expects:
134
+
135
+ - treat container lifecycle mutations as operation-driven when they return operation metadata
136
+ - treat exec as submit-and-track, not inline command execution
137
+ - use terminal attach and WebSocket flows for interactive sessions
138
+ - invoke a shell explicitly when shell parsing is required
139
+ - prefer typed module methods over `client.raw(...)`
41
140
 
42
141
  ## Realtime
43
142
 
44
143
  ### SSE
45
144
 
46
145
  ```ts
47
- const source = quilt.events.openEventSource();
48
- quilt.events.on(source, "container_update", (event) => {
146
+ const source = client.events.openEventSource();
147
+ client.events.on(source, "container_update", (event) => {
49
148
  console.log(event.data);
50
149
  });
51
150
  ```
@@ -53,42 +152,95 @@ quilt.events.on(source, "container_update", (event) => {
53
152
  ### WebSocket Terminal
54
153
 
55
154
  ```ts
56
- const ws = quilt.terminalRealtime.connect({ container_identifier: "ctr_123", cols: 120, rows: 30 });
155
+ const ws = client.terminalRealtime.connect({
156
+ container_identifier: "ctr_123",
157
+ cols: 120,
158
+ rows: 30,
159
+ });
160
+
57
161
  ws.addEventListener("message", (msg) => {
58
162
  if (typeof msg.data === "string") {
59
- const parsed = quilt.terminalRealtime.parseServerMessage(msg.data);
163
+ const parsed = client.terminalRealtime.parseServerMessage(msg.data);
60
164
  console.log(parsed);
61
165
  }
62
166
  });
63
167
  ```
64
168
 
65
- ## Production Platform Module
169
+ ## Examples
66
170
 
67
- The `platform` namespace exposes production endpoints that are part of live backend behavior and script-driven workflows, including:
171
+ The repository ships a production-validated example set in [`examples/`](./examples).
68
172
 
69
- - Container env, rename, archive, jobs, ready/resume/fork
70
- - Snapshot clone and operation status
71
- - Volume archive/files helpers
72
- - Network allocations and monitor process queries
73
- - ICC endpoints
173
+ Example files:
74
174
 
75
- ```ts
76
- const op = await quilt.containers.stop("ctr_123", "async");
77
- if ("operation_id" in (op as Record<string, unknown>)) {
78
- const done = await quilt.awaitOperation((op as { operation_id: string }).operation_id);
79
- console.log(done.status);
80
- }
175
+ - `examples/containers-volumes-and-network.ts`
176
+ - `examples/docker-and-oci-images.ts`
177
+ - `examples/sdk-runtime-and-functions.ts`
178
+ - `examples/clusters-nodes-workloads-and-k8s.ts`
179
+ - `examples/terminal-and-icc.ts`
180
+ - `examples/elasticity-control.ts`
181
+ - `examples/lifecycle-and-failures.ts`
182
+
183
+ The example guide is in [`examples/README.md`](./examples/README.md).
184
+
185
+ Run them from the repo root:
186
+
187
+ ```bash
188
+ bun run example:containers
189
+ bun run example:images
190
+ bun run example:sdk
191
+ bun run example:clusters
192
+ bun run example:terminal
193
+ bun run example:elasticity
194
+ bun run example:lifecycle
195
+ bun run examples:all
196
+ ```
197
+
198
+ Expected environment variables:
199
+
200
+ ```text
201
+ QUILT_BASE_URL=https://backend.quilt.sh
202
+ QUILT_API_KEY=<api_key>
203
+ ```
204
+
205
+ Alternative auth:
206
+
207
+ ```text
208
+ QUILT_JWT=<jwt>
81
209
  ```
82
210
 
83
- ## Scripts
211
+ ## Repository Validation
84
212
 
85
213
  ```bash
86
214
  bun run lint
87
215
  bun run typecheck
216
+ bun run examples:typecheck
88
217
  bun run test
89
218
  bun run build
219
+ bun run examples:all
90
220
  ```
91
221
 
222
+ `prepublishOnly` runs:
223
+
224
+ ```bash
225
+ bun run clean
226
+ bun run lint
227
+ bun run typecheck
228
+ bun run examples:typecheck
229
+ bun run test
230
+ bun run build
231
+ ```
232
+
233
+ ## Package Contents
234
+
235
+ The published npm package includes:
236
+
237
+ - compiled runtime in `dist/`
238
+ - generated `.d.ts` declarations
239
+ - `README.md`
240
+ - `LICENSE`
241
+
242
+ The repository also includes the example app and validation setup used to verify the SDK against production.
243
+
92
244
  ## License
93
245
 
94
246
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quilt-sdk",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Fully type-safe TypeScript SDK for Quilt HTTP APIs",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,19 +22,36 @@
22
22
  "generate:types": "node ./scripts/generate-contract-types.mjs",
23
23
  "build": "bun run generate:types && tsc -p tsconfig.build.json",
24
24
  "typecheck": "bun run generate:types && tsc -p tsconfig.json --noEmit",
25
+ "examples:typecheck": "tsc -p tsconfig.examples.json --noEmit",
25
26
  "lint": "biome check .",
26
27
  "lint:fix": "biome check --write .",
27
28
  "test": "bun test",
28
29
  "test:coverage": "bun test --coverage",
29
- "prepublishOnly": "bun run clean && bun run lint && bun run typecheck && bun run test && bun run build"
30
+ "examples:all": "bun run example:containers && bun run example:images && bun run example:sdk && bun run example:clusters && bun run example:terminal && bun run example:elasticity && bun run example:lifecycle",
31
+ "example:containers": "node --env-file=.env --import tsx examples/containers-volumes-and-network.ts",
32
+ "example:images": "node --env-file=.env --import tsx examples/docker-and-oci-images.ts",
33
+ "example:sdk": "node --env-file=.env --import tsx examples/sdk-runtime-and-functions.ts",
34
+ "example:clusters": "node --env-file=.env --import tsx examples/clusters-nodes-workloads-and-k8s.ts",
35
+ "example:terminal": "node --env-file=.env --import tsx examples/terminal-and-icc.ts",
36
+ "example:elasticity": "node --env-file=.env --import tsx examples/elasticity-control.ts",
37
+ "example:lifecycle": "node --env-file=.env --import tsx examples/lifecycle-and-failures.ts",
38
+ "prepublishOnly": "bun run clean && bun run lint && bun run typecheck && bun run examples:typecheck && bun run test && bun run build"
30
39
  },
31
40
  "keywords": ["quilt", "sdk", "api", "typescript", "bun"],
32
41
  "license": "MIT",
33
42
  "devDependencies": {
34
43
  "@biomejs/biome": "^1.9.4",
35
44
  "@types/node": "^24.0.0",
45
+ "@types/ws": "^8.18.1",
36
46
  "bun-types": "^1.3.0",
47
+ "eventsource": "^3.0.7",
37
48
  "openapi-typescript": "^7.6.1",
38
- "typescript": "^5.8.3"
49
+ "protobufjs": "^8.0.0",
50
+ "tsx": "^4.20.3",
51
+ "typescript": "^5.8.3",
52
+ "ws": "^8.20.0"
53
+ },
54
+ "dependencies": {
55
+ "quilt-sdk": "^0.0.5"
39
56
  }
40
57
  }