@kubb/studio 0.0.0-canary-20260903193839
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 +136 -0
- package/dist/configFile-DjzP1_Ln.cjs +575 -0
- package/dist/configFile-DjzP1_Ln.cjs.map +1 -0
- package/dist/configFile-ZnV5tPon.js +574 -0
- package/dist/configFile-ZnV5tPon.js.map +1 -0
- package/dist/index-BVn89Nw2.d.ts +562 -0
- package/dist/index.cjs +1330 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +274 -0
- package/dist/index.js +1319 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.cjs +42 -0
- package/dist/protocol.cjs.map +1 -0
- package/dist/protocol.d.ts +2 -0
- package/dist/protocol.js +37 -0
- package/dist/protocol.js.map +1 -0
- package/dist/resolveConfig-B9oGiNMi.js +179 -0
- package/dist/resolveConfig-B9oGiNMi.js.map +1 -0
- package/dist/resolveConfig-Ci-BVhN_.cjs +202 -0
- package/dist/resolveConfig-Ci-BVhN_.cjs.map +1 -0
- package/dist/rolldown-runtime-CRm0XQPb.js +9 -0
- package/dist/rolldown-runtime-qbf5tadS.cjs +38 -0
- package/package.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Stijn Van Hulle
|
|
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,136 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://kubb.dev" target="_blank" rel="noopener noreferrer">
|
|
3
|
+
<img src="https://kubb.dev/og.png" alt="Kubb banner">
|
|
4
|
+
</a>
|
|
5
|
+
|
|
6
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
7
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
8
|
+
[![Stars][stars-src]][stars-href]
|
|
9
|
+
[![License][license-src]][license-href]
|
|
10
|
+
[![Node][node-src]][node-href]
|
|
11
|
+
|
|
12
|
+
<h4>
|
|
13
|
+
<a href="https://kubb.dev" target="_blank">Documentation</a>
|
|
14
|
+
<span> · </span>
|
|
15
|
+
<a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
|
|
16
|
+
<span> · </span>
|
|
17
|
+
<a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Request Feature</a>
|
|
18
|
+
</h4>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<br />
|
|
22
|
+
|
|
23
|
+
# @kubb/studio
|
|
24
|
+
|
|
25
|
+
Kubb Studio client runtime.
|
|
26
|
+
|
|
27
|
+
Connects a Kubb project to [Kubb Studio](https://kubb.studio) over a WebSocket relay and streams
|
|
28
|
+
code generation events as they happen. It backs both front ends: the `kubb studio` CLI command and
|
|
29
|
+
the `kubblabs/kubb-agent` Docker image.
|
|
30
|
+
|
|
31
|
+
Most people never install this directly. Reach for `kubb studio` instead, which pairs your machine
|
|
32
|
+
and runs this for you.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```shell
|
|
37
|
+
npm install @kubb/studio
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { createClient, createFileStorage } from '@kubb/studio'
|
|
44
|
+
|
|
45
|
+
const client = createClient({
|
|
46
|
+
token: process.env.KUBB_AGENT_TOKEN!,
|
|
47
|
+
configPath: 'kubb.config.ts',
|
|
48
|
+
version: '1.0.0',
|
|
49
|
+
loadConfig: () => loadMyKubbConfig(),
|
|
50
|
+
storage: createFileStorage('./.kubb-cache'),
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
await client.connect()
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The runtime discovers nothing on its own: the host injects the config loader, the storage, and its
|
|
57
|
+
own version. That is what lets one runtime serve a CLI running in a developer's project and a
|
|
58
|
+
container running a fixed plugin set.
|
|
59
|
+
|
|
60
|
+
## Permissions
|
|
61
|
+
|
|
62
|
+
Every permission is off by default, and each covers one trust boundary:
|
|
63
|
+
|
|
64
|
+
| Option | What it grants |
|
|
65
|
+
| ------------ | ---------------------------------------------------------------------------------------------- |
|
|
66
|
+
| `allowWrite` | Generated files are written to disk. Off means they exist only in memory and stream to Studio. |
|
|
67
|
+
| `allowInput` | An OpenAPI spec sent by Studio replaces the one on disk. |
|
|
68
|
+
| `allowExec` | The formatter, the linter, and `output.postGenerate` run as child processes. |
|
|
69
|
+
|
|
70
|
+
## Connection flow
|
|
71
|
+
|
|
72
|
+
Both hosts follow the same steps and send the agent's bearer token with every call. `/api/agent` is
|
|
73
|
+
the machine-facing surface, singular because the caller is describing itself. The plural
|
|
74
|
+
`/api/agents` is the collection a signed-in user manages in the browser, and the runtime never
|
|
75
|
+
touches it.
|
|
76
|
+
|
|
77
|
+
| Step | Call | What it does |
|
|
78
|
+
| ---------- | ------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
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 `{ wsUrl, sessionId, expiresAt }` |
|
|
81
|
+
| Connect | `WS` on the returned `wsUrl` | Streams generation events until the session expires or is revoked |
|
|
82
|
+
| Disconnect | `POST /api/agent/sessions/{sessionId}/disconnect` | Closes the session on a clean shutdown |
|
|
83
|
+
|
|
84
|
+
The runtime reconnects on its own when a session drops, and keeps retrying while Studio is
|
|
85
|
+
unreachable.
|
|
86
|
+
|
|
87
|
+
### Pairing
|
|
88
|
+
|
|
89
|
+
No host starts with a token, so each one pairs over
|
|
90
|
+
[RFC 8628](https://www.rfc-editor.org/rfc/rfc8628.html) device authorization: it asks
|
|
91
|
+
`POST /api/auth/device/code` for a `device_code` and a short `user_code`, shows the code, and polls
|
|
92
|
+
`POST /api/agent/token` until someone approves in the browser. Studio mints the token once and stores only its hash, so
|
|
93
|
+
nothing can read it back.
|
|
94
|
+
|
|
95
|
+
`startPairing` defaults to the `kubb-cli` client, which `kubb studio login` uses and any signed-in
|
|
96
|
+
member can approve. A host that pairs a shared or tier-limited agent passes `clientId: 'kubb-agent'`
|
|
97
|
+
and an `agentKind`, whose codes only an admin can approve.
|
|
98
|
+
|
|
99
|
+
## Protocol
|
|
100
|
+
|
|
101
|
+
`@kubb/studio/protocol` holds the WebSocket message types shared by both ends, so the agent and
|
|
102
|
+
Studio itself compile against one definition rather than two hand-maintained copies.
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import { type AgentMessage, isDataMessage } from '@kubb/studio/protocol'
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Supporting Kubb
|
|
109
|
+
|
|
110
|
+
Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider:
|
|
111
|
+
|
|
112
|
+
- [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
|
|
113
|
+
- [See sponsorship tiers and our sponsors](https://kubb.dev/sponsors)
|
|
114
|
+
|
|
115
|
+
<p align="center">
|
|
116
|
+
<a href="https://github.com/sponsors/stijnvanhulle">
|
|
117
|
+
<img src="https://raw.githubusercontent.com/stijnvanhulle/sponsors/main/sponsors.svg" alt="My sponsors" />
|
|
118
|
+
</a>
|
|
119
|
+
</p>
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
[MIT](https://github.com/kubb-labs/kubb/blob/main/licenses/LICENSE-MIT)
|
|
124
|
+
|
|
125
|
+
<!-- Badges -->
|
|
126
|
+
|
|
127
|
+
[npm-version-src]: https://shieldcn.dev/npm/v/@kubb/studio.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
128
|
+
[npm-version-href]: https://npmx.dev/package/@kubb/studio
|
|
129
|
+
[npm-downloads-src]: https://shieldcn.dev/npm/dm/@kubb/studio.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
130
|
+
[npm-downloads-href]: https://npmx.dev/package/@kubb/studio
|
|
131
|
+
[stars-src]: https://shieldcn.dev/github/stars/kubb-labs/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
132
|
+
[stars-href]: https://github.com/kubb-labs/kubb
|
|
133
|
+
[license-src]: https://shieldcn.dev/npm/license/@kubb/studio.svg?variant=secondary&size=xs&theme=zinc
|
|
134
|
+
[license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
|
|
135
|
+
[node-src]: https://shieldcn.dev/npm/node/@kubb/studio.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
136
|
+
[node-href]: https://npmx.dev/package/@kubb/studio
|