@kubb/studio 5.3.5 → 5.3.7
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/README.md +32 -11
- package/dist/index.cjs +469 -516
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +19 -5
- package/dist/index.js +433 -506
- package/dist/index.js.map +1 -1
- package/dist/protocol.cjs +31 -45
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.ts +126 -275
- package/dist/protocol.js +31 -39
- package/dist/protocol.js.map +1 -1
- package/package.json +6 -4
- package/dist/rolldown-runtime-qbf5tadS.cjs +0 -38
package/README.md
CHANGED
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
|
|
25
25
|
Kubb Studio client runtime.
|
|
26
26
|
|
|
27
|
-
Connects a Kubb project to [Kubb Studio](https://kubb.studio)
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
Connects a Kubb project to [Kubb Studio](https://kubb.studio) through typed Cap'n Web RPC over an
|
|
28
|
+
authenticated WebSocket. It backs both front ends: the `kubb studio` CLI command and the
|
|
29
|
+
`kubblabs/kubb-agent` Docker image. Browser clients use Studio’s HTTP/SSE API, not this socket.
|
|
30
30
|
|
|
31
31
|
Most people never install this directly. Reach for `kubb studio` instead, which pairs your machine
|
|
32
32
|
and runs this for you.
|
|
@@ -77,12 +77,27 @@ touches it.
|
|
|
77
77
|
| Step | Call | What it does |
|
|
78
78
|
| ---------- | ------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
79
79
|
| Register | `POST /api/agent/connect` | Binds the token to this machine with a `machineToken`. A failure here is not fatal |
|
|
80
|
-
| Session | `POST /api/agent/sessions` | Returns `{
|
|
81
|
-
| Connect |
|
|
80
|
+
| Session | `POST /api/agent/sessions` | Returns `{ url, sessionId, expiresAt }` |
|
|
81
|
+
| Connect | Configured RPC connector on `url` | Attaches the typed `AgentApi`/`StudioApi` RPC session |
|
|
82
82
|
| Disconnect | `POST /api/agent/sessions/{sessionId}/disconnect` | Closes the session on a clean shutdown |
|
|
83
83
|
|
|
84
84
|
The runtime reconnects on its own when a session drops, and keeps retrying while Studio is
|
|
85
|
-
unreachable.
|
|
85
|
+
unreachable. Generation progress is a native Cap'n Web `ReadableStream` on the generation
|
|
86
|
+
capability; durable job status is read through the HTTP job API.
|
|
87
|
+
|
|
88
|
+
## Studio job events
|
|
89
|
+
|
|
90
|
+
`@kubb/studio` exposes a deliberately small public event API. Every live event uses the envelope
|
|
91
|
+
`{ version: 1, jobId, type, data, timestamp }`. The native stream preserves order and applies
|
|
92
|
+
backpressure; it is not a replay cursor. Job status and the terminal result remain authoritative
|
|
93
|
+
after a reconnect.
|
|
94
|
+
|
|
95
|
+
The stable catalog is `generationEventTypes`: generation and build progress, file processing,
|
|
96
|
+
plugin progress, log levels, diagnostics, command-hook output, and the terminal generation summary.
|
|
97
|
+
Each `type` is a lifecycle name registered by `@kubb/core`, while `data` is the JSON-safe projection
|
|
98
|
+
defined by `GenerationEventPayloads`. AST traversal, live config and adapter objects, storage, and
|
|
99
|
+
plugin implementations never leave the agent. New core hooks stay private until Studio explicitly
|
|
100
|
+
adds their name and serializer projection.
|
|
86
101
|
|
|
87
102
|
### Pairing
|
|
88
103
|
|
|
@@ -104,7 +119,7 @@ organization CI API key as `x-api-key`. They do not open a WebSocket.
|
|
|
104
119
|
| Step | Call | What it does |
|
|
105
120
|
| ------ | -------------------- | --------------------------------------------------------------------- |
|
|
106
121
|
| Queue | `POST /api/jobs` | Accepts a `generation` or `snapshot` job and returns `202` with an id |
|
|
107
|
-
| Status | `GET /api/jobs/{id}` | Returns the job until `success` or `
|
|
122
|
+
| Status | `GET /api/jobs/{id}` | Returns the job until `success`, `failed`, or `canceled` |
|
|
108
123
|
|
|
109
124
|
```typescript
|
|
110
125
|
import { createJob, waitForJob } from '@kubb/studio'
|
|
@@ -125,22 +140,28 @@ const finished = await waitForJob({
|
|
|
125
140
|
})
|
|
126
141
|
|
|
127
142
|
if (finished.status === 'failed') throw new Error(finished.error)
|
|
143
|
+
if (finished.status === 'canceled') throw new Error('Studio job was canceled')
|
|
128
144
|
const snapshot = finished.snapshot
|
|
129
145
|
```
|
|
130
146
|
|
|
131
147
|
A snapshot job packs the tarball on the agent, not on Studio. The agent `PUT`s an empty request to
|
|
132
148
|
a path Studio provides, gets back a redirect to a short-lived storage URL, and uploads the tarball
|
|
133
|
-
there. The storage URL never crosses the
|
|
149
|
+
there. The storage URL never crosses the RPC socket.
|
|
134
150
|
|
|
135
151
|
## Protocol
|
|
136
152
|
|
|
137
|
-
`@kubb/studio/protocol` holds the
|
|
138
|
-
|
|
153
|
+
`@kubb/studio/protocol` holds the RPC contracts both ends share, so the agent and Studio compile
|
|
154
|
+
against one definition rather than two hand-maintained copies. Its only import is `KubbHooks` from
|
|
155
|
+
`@kubb/core`, which the published event names are checked against.
|
|
139
156
|
|
|
140
157
|
```typescript
|
|
141
|
-
import {
|
|
158
|
+
import type { AgentApi, GenerationEvent, GenerationRun, RpcConnection, RpcConnector, StudioApi } from '@kubb/studio'
|
|
142
159
|
```
|
|
143
160
|
|
|
161
|
+
Hosts supply an `RpcConnector`, which keeps transport details in the CLI, Docker agent, or Studio
|
|
162
|
+
host rather than in the generation runtime. A `GenerationRun.cancel()` call aborts the matching
|
|
163
|
+
generation cooperatively, including configured formatter, linter, and `postGenerate` processes.
|
|
164
|
+
|
|
144
165
|
## Supporting Kubb
|
|
145
166
|
|
|
146
167
|
Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider:
|