@kubb/studio 5.6.0 → 5.6.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.
@@ -1,628 +1,2 @@
1
- import { t as __name } from "./rolldown-runtime-CRm0XQPb.js";
2
- //#region src/protocol/index.d.ts
3
- /**
4
- * JSON-serializable Kubb config exchanged over RPC. A live `kubb/kit` config holds
5
- * functions and class instances that cannot survive JSON, so both sides pass this flattened shape
6
- * and rebuild the real config from it.
7
- */
8
- export type JSONKubbConfig = {
9
- /**
10
- * Plugins with their serialized options. `name` is the package name (e.g. `@kubb/plugin-ts`)
11
- * and `options` is an opaque blob the agent forwards unchanged to the plugin factory. An entry
12
- * with `disabled: true` is dropped even when the disk config's `plugins` array still lists it.
13
- */
14
- plugins?: Array<{
15
- name: string;
16
- options?: object;
17
- disabled?: boolean;
18
- }>;
19
- /**
20
- * Raw OpenAPI / Swagger spec content (YAML or JSON string).
21
- * Only honored for a 'sandbox' agent, which has no disk config of its own. A non-sandbox agent
22
- * always reads its spec from disk, so this is ignored.
23
- */
24
- input?: string;
25
- /**
26
- * Adapter option overrides sent from Studio UI. Merged into the disk config's adapter options
27
- * and re-applied through the same adapter factory, since an adapter instance's functions
28
- * (`parse`, `getImports`, ...) can't survive JSON serialization over the WebSocket.
29
- */
30
- adapter?: object;
31
- };
32
- /**
33
- * Which `defineConfig(...)` entry an edit targets, for a config file that exports an array.
34
- *
35
- * A number selects by position, a string matches the entry's `name`. Omitted targets the only
36
- * entry, or the first one when the file exports an array.
37
- */
38
- export type ConfigRef = string | number;
39
- /**
40
- * A value the agent can read out of a plugin option in `kubb.config.ts` and round-trip through JSON.
41
- */
42
- export type OptionValue = string | number | boolean | null | Array<OptionValue> | {
43
- [key: string]: OptionValue;
44
- };
45
- /**
46
- * One change to a plugin's options in the user's `kubb.config.ts`.
47
- *
48
- * `plugin` is the package name (`@kubb/plugin-ts`), the same identity used in {@link JSONKubbConfig}.
49
- * The agent applies these to the file with an AST patch, so only the targeted values are rewritten.
50
- *
51
- * Declared here rather than in `configFile.ts` because this is the wire contract, and the patcher
52
- * imports it from here. Type-only, so nothing pulls `magicast` into this entry point.
53
- */
54
- export type ConfigEdit =
55
- /**
56
- * Write a literal option value. `path` walks nested objects, so `['enum', 'type']` targets
57
- * `pluginTs({ enum: { type } })`.
58
- */
59
- {
60
- operation: 'set';
61
- config?: ConfigRef;
62
- plugin: string;
63
- path: Array<string>;
64
- value: unknown;
65
- } |
66
- /**
67
- * Drop an option so the plugin falls back to its default.
68
- */
69
- {
70
- operation: 'remove';
71
- config?: ConfigRef;
72
- plugin: string;
73
- path: Array<string>;
74
- } |
75
- /**
76
- * Add a plugin factory call and its import to the `plugins` array.
77
- */
78
- {
79
- operation: 'add-plugin';
80
- config?: ConfigRef;
81
- plugin: string;
82
- importName?: string;
83
- options?: Record<string, unknown>;
84
- } |
85
- /**
86
- * Comment the plugin call out, keeping its options in the file so enabling it again restores them.
87
- */
88
- {
89
- operation: 'disable-plugin';
90
- config?: ConfigRef;
91
- plugin: string;
92
- } |
93
- /**
94
- * Uncomment a plugin call a previous `disable-plugin` commented out.
95
- */
96
- {
97
- operation: 'enable-plugin';
98
- config?: ConfigRef;
99
- plugin: string;
100
- };
101
- /**
102
- * A plugin factory call the agent found in the `plugins` array of a `defineConfig(...)`.
103
- */
104
- export type PluginView = {
105
- /**
106
- * Local identifier of the factory in the file, e.g. `pluginTs`. This is the alias when the plugin
107
- * was imported under one.
108
- */
109
- importName: string;
110
- /**
111
- * Module the factory is imported from, e.g. `@kubb/plugin-ts`.
112
- */
113
- packageName: string;
114
- /**
115
- * Top-level option keys, each flagged with whether the agent may write it and, when it can, the
116
- * value found in the file. An option marked `literal: false` holds a function or a reference the
117
- * agent will not overwrite, so Studio shows the control disabled rather than hiding it, and
118
- * `value` is absent since there is nothing safe to display as the current value.
119
- */
120
- options: Record<string, {
121
- literal: boolean;
122
- value?: OptionValue;
123
- }>;
124
- /**
125
- * Set when the plugin call is commented out in the file. Its options stay on disk but are not
126
- * readable, so `options` is empty until it is enabled again.
127
- */
128
- disabled?: true;
129
- };
130
- /**
131
- * One `defineConfig(...)` entry. A config file that exports a single object has exactly one.
132
- */
133
- export type ConfigView = {
134
- /**
135
- * The entry's `name`, when it sets one. Studio labels the config picker with it.
136
- */
137
- name?: string;
138
- /**
139
- * Each plugin call in the entry, with its top-level option keys.
140
- */
141
- plugins: Array<PluginView>;
142
- };
143
- /**
144
- * What the agent found in the user's config file, so Studio knows which controls it may offer.
145
- * Absent when the agent could not read the file at all.
146
- */
147
- export type ConfigFileView = {
148
- managed: true;
149
- /**
150
- * One entry per config the file exports, in source order. Every {@link ConfigEdit} names
151
- * which of these it targets through its `config` field.
152
- */
153
- configs: Array<ConfigView>;
154
- } | {
155
- managed: false;
156
- /**
157
- * Why the file is outside what the agent edits, for example a default export that is not a
158
- * `defineConfig(...)` call. Studio shows this and offers no property-level controls.
159
- */
160
- reason: string;
161
- };
162
- /**
163
- * Outcome of a single {@link ConfigEdit}, returned in a {@link ConfigSavedMessage}.
164
- */
165
- export type ConfigEditOutcome = {
166
- edit: ConfigEdit;
167
- applied: boolean;
168
- /**
169
- * Why the edit was refused, absent when it was applied.
170
- */
171
- reason?: string;
172
- };
173
- /**
174
- * The public, JSON-safe subset of Kubb lifecycle hooks. The core registry remains extensible;
175
- * adding a core hook does not publish it to Studio until it is listed here and projected below.
176
- */
177
- export declare const generationEventTypes: readonly ["kubb:plugin:start", "kubb:plugin:end", "kubb:build:start", "kubb:build:end", "kubb:files:processing:start", "kubb:files:processing:update", "kubb:files:processing:end", "kubb:info", "kubb:success", "kubb:warn", "kubb:error", "kubb:diagnostic", "kubb:generation:start", "kubb:generation:end", "kubb:generation:summary", "kubb:lifecycle:start", "kubb:lifecycle:end", "kubb:format:start", "kubb:format:end", "kubb:lint:start", "kubb:lint:end", "kubb:hooks:start", "kubb:hooks:end", "kubb:hook:start", "kubb:hook:line", "kubb:hook:end"];
178
- /**
179
- * One of the lifecycle hooks {@link generationEventTypes} publishes.
180
- */
181
- export type GenerationEventType = (typeof generationEventTypes)[number];
182
- /**
183
- * The JSON-safe payload each published event carries. These are flattened on purpose: a core hook
184
- * context holds live objects (a `Config`, a `Storage`) that cannot cross the wire.
185
- */
186
- export type GenerationEventPayloads = {
187
- 'kubb:plugin:start': [ctx: {
188
- plugin: {
189
- name: string;
190
- };
191
- }];
192
- 'kubb:plugin:end': [ctx: {
193
- plugin: {
194
- name: string;
195
- };
196
- duration: number;
197
- success: boolean;
198
- }];
199
- 'kubb:build:start': [ctx: {
200
- config: {
201
- name?: string;
202
- };
203
- adapter: {
204
- name: string;
205
- };
206
- }];
207
- 'kubb:build:end': [ctx: {
208
- files: Array<{
209
- path: string;
210
- name: string;
211
- }>;
212
- outputDir: string;
213
- }];
214
- 'kubb:files:processing:start': [ctx: {
215
- total: number;
216
- }];
217
- 'kubb:files:processing:update': [ctx: {
218
- files: Array<{
219
- file: string;
220
- processed: number;
221
- total: number;
222
- percentage: number;
223
- }>;
224
- }];
225
- 'kubb:files:processing:end': [ctx: {
226
- total: number;
227
- }];
228
- 'kubb:info': [ctx: {
229
- message: string;
230
- info?: string;
231
- }];
232
- 'kubb:success': [ctx: {
233
- message: string;
234
- info?: string;
235
- }];
236
- 'kubb:warn': [ctx: {
237
- message: string;
238
- info?: string;
239
- }];
240
- 'kubb:error': [ctx: {
241
- message: string;
242
- stack?: string;
243
- }];
244
- 'kubb:diagnostic': [ctx: {
245
- code: string;
246
- message: string;
247
- severity: string;
248
- location?: {
249
- kind: string;
250
- pointer?: string;
251
- ref?: string;
252
- };
253
- help?: string;
254
- plugin?: string;
255
- stack?: string;
256
- }];
257
- 'kubb:generation:start': [ctx: {
258
- name?: string;
259
- plugins: number;
260
- }];
261
- /**
262
- * A run finished. See `kubb:build:end` for files, `kubb:generation:summary` for the count, and
263
- * `readFiles` for contents.
264
- */
265
- 'kubb:generation:end': [];
266
- 'kubb:generation:summary': [ctx: {
267
- duration: number;
268
- fileCount: number;
269
- failedPlugins: number;
270
- status: 'success' | 'failed';
271
- }];
272
- 'kubb:lifecycle:start': [];
273
- 'kubb:lifecycle:end': [];
274
- 'kubb:format:start': [];
275
- 'kubb:format:end': [];
276
- 'kubb:lint:start': [];
277
- 'kubb:lint:end': [];
278
- 'kubb:hooks:start': [];
279
- 'kubb:hooks:end': [];
280
- 'kubb:hook:start': [ctx: {
281
- id?: string;
282
- command: string;
283
- args?: Array<string>;
284
- }];
285
- 'kubb:hook:line': [ctx: {
286
- id: string;
287
- line: string;
288
- }];
289
- 'kubb:hook:end': [ctx: {
290
- id?: string;
291
- command: string;
292
- args?: Array<string>;
293
- success: boolean;
294
- error?: {
295
- message: string;
296
- stack?: string;
297
- };
298
- }];
299
- };
300
- /**
301
- * Versioned envelope around one lifecycle event. Cap'n Web streams preserve the order the agent
302
- * emitted them in, so the receiver replays a run by reading the stream straight through.
303
- */
304
- export type GenerationEvent = { [Type in GenerationEventType]: {
305
- type: Type;
306
- data: GenerationEventPayloads[Type];
307
- }; }[GenerationEventType] & {
308
- version: 1;
309
- jobId: string;
310
- timestamp: number;
311
- };
312
- /**
313
- * Asks the agent to run one generation. `jobId` tags every event the run emits so a caller
314
- * watching several runs can tell them apart.
315
- */
316
- export type GenerateInput = {
317
- jobId: string;
318
- config: JSONKubbConfig;
319
- };
320
- /**
321
- * What a finished run produced.
322
- */
323
- export type GenerateResult = {
324
- status: 'success' | 'failed';
325
- /**
326
- * Paths of the generated files, relative to the output directory.
327
- */
328
- files: Array<string>;
329
- fileCount: number;
330
- /**
331
- * Content fingerprint per file in `files`, to tell changed files apart without reading them.
332
- */
333
- hashes: Record<string, string>;
334
- /**
335
- * Fingerprints of the output directory on disk before the run, for an agent with a project on disk.
336
- */
337
- disk?: {
338
- hashes: Record<string, string>;
339
- };
340
- };
341
- /**
342
- * Asks the agent to apply a batch of edits to the config file on disk.
343
- */
344
- export type SaveConfigInput = {
345
- edits: Array<ConfigEdit>;
346
- };
347
- /**
348
- * Per-edit outcomes plus the rewritten file. `changed` is false when every edit was a no-op, so a
349
- * caller can skip reloading.
350
- */
351
- export type SaveResult = {
352
- outcomes: Array<ConfigEditOutcome>;
353
- changed: boolean;
354
- file?: ConfigFileView;
355
- };
356
- /**
357
- * What a file read returns for a job: the files that job generated (`output`), or what the output
358
- * directory held on disk before that job ran (`disk`, only on an agent with a project on disk).
359
- */
360
- export type FileSource = 'output' | 'disk';
361
- /**
362
- * Asks the agent to read files of one generation job back.
363
- */
364
- export type ReadFilesInput = {
365
- /**
366
- * The job whose files to read, the only lookup key, so the caller decides whose jobs a reader may
367
- * see. A job the agent no longer keeps fails with {@link GENERATION_GONE_MESSAGE}.
368
- */
369
- jobId: string;
370
- /**
371
- * At most {@link MAX_FILES_PER_REQUEST} paths, each checked against what the job's set holds.
372
- */
373
- paths: Array<string>;
374
- /**
375
- * Which of the job's sets to read, `output` when left out.
376
- */
377
- source?: FileSource;
378
- /**
379
- * The line to start from (0-based), the `nextCursor` of the previous page. Defaults to 0.
380
- */
381
- cursor?: number;
382
- /**
383
- * Lines to read per file, at most {@link MAX_PAGE_LINES}. Left out, the whole file.
384
- */
385
- limit?: number;
386
- };
387
- /**
388
- * Where a paged read stands for one file: the cursor of the next page, `null` after the last one.
389
- */
390
- export type FilePage = {
391
- nextCursor: number | null;
392
- totalLines: number;
393
- };
394
- /**
395
- * What a file read returns. `pages` is set only for a paged read.
396
- */
397
- export type ReadFilesResult = {
398
- files: Record<string, string>;
399
- pages?: Record<string, FilePage>;
400
- };
401
- /**
402
- * The error a file read fails with once the agent no longer keeps the job's files.
403
- */
404
- export declare const GENERATION_GONE_MESSAGE = "The files of this generation are no longer kept on the agent, run the generation again";
405
- /**
406
- * Describes the package to pack and where to PUT it. `uploadPath` is resolved against the Studio
407
- * origin, so it cannot redirect the upload elsewhere.
408
- */
409
- export type PublishSnapshotInput = {
410
- name: string;
411
- version: string;
412
- bundledDependencies?: Array<string>;
413
- uploadPath: string;
414
- };
415
- /**
416
- * Identifies the uploaded snapshot. `integrity` is the subresource hash Studio verifies against.
417
- */
418
- export type PublishSnapshotResult = {
419
- integrity: string;
420
- peerDependencies: Record<string, string>;
421
- };
422
- /**
423
- * A generation in flight. Cap'n Web keeps the three calls pointed at the same run, so a caller can
424
- * read `events()` while `result()` is still pending and `cancel()` stops it early.
425
- */
426
- export type GenerationRun = {
427
- events: () => Promise<ReadableStream<GenerationEvent>>;
428
- result: () => Promise<GenerateResult>;
429
- cancel: () => Promise<void>;
430
- };
431
- /**
432
- * Operations Studio can invoke on an agent through a host-provided RPC transport.
433
- */
434
- export type AgentApi = {
435
- connect: () => Promise<ConnectMessagePayload>;
436
- startGeneration: (input: GenerateInput) => GenerationRun;
437
- saveConfig: (input: SaveConfigInput) => Promise<SaveResult>;
438
- publishSnapshot: (input: PublishSnapshotInput) => Promise<PublishSnapshotResult>;
439
- readFiles: (input: ReadFilesInput) => Promise<ReadFilesResult>;
440
- /**
441
- * Cancels the job named by `jobId`, if it is the one this agent is currently running. Reachable
442
- * by id alone, unlike {@link GenerationRun.cancel}, so a caller that no longer holds that object
443
- * (Studio, after its own restart re-attaches to a job by id) can still cancel it.
444
- */
445
- cancel: (jobId: string) => Promise<void>;
446
- };
447
- /**
448
- * Operations an agent can invoke on Studio through a host-provided RPC transport.
449
- */
450
- export type StudioApi = {
451
- /**
452
- * Keeps the connection alive. `load` reports what the agent is carrying right now. Absent from an
453
- * agent that predates it.
454
- */
455
- ping: (load?: AgentLoad) => Promise<void>;
456
- };
457
- /**
458
- * What an agent is carrying at one heartbeat.
459
- */
460
- export type AgentLoad = {
461
- /** Jobs running on this connection right now. */
462
- running: number;
463
- /** Resident memory of the agent process, in megabytes. */
464
- rssMb: number;
465
- /** Bytes of past generations the agent keeps for file reads and snapshots. */
466
- storeBytes: number;
467
- /** Whether the agent takes new jobs. Always `true` today; Studio skips a connection that reports `false`. */
468
- accepting: boolean;
469
- };
470
- /**
471
- * Close codes Studio sends when it ends an agent's connection on purpose. Any other code is an
472
- * ordinary drop, and the agent reconnects.
473
- */
474
- export declare const AgentCloseCode: {
475
- /** Register again before reconnecting, such as after Studio forgot this agent's machine token. */
476
- readonly REAUTHENTICATE: 4001;
477
- /** Another instance of the same agent took the connection over. Reconnecting would take it back. */
478
- readonly SUPERSEDED: 4002;
479
- /** This agent is too old for Studio, or was deleted. Reconnecting cannot succeed. */
480
- readonly INCOMPATIBLE: 4003;
481
- };
482
- /**
483
- * Why a transport closed. Absent when the transport cannot tell, such as an in-process test pair.
484
- */
485
- export type RpcClose = {
486
- code: number;
487
- reason: string;
488
- };
489
- /**
490
- * A live RPC session. `closed` settles when the transport drops, whichever side ended it.
491
- */
492
- export type RpcConnection = {
493
- studio: StudioApi;
494
- closed: Promise<RpcClose | void>;
495
- close: () => void;
496
- };
497
- /**
498
- * Opens a transport and hands both sides their peer. Swapping this is how a test drives a session
499
- * without a socket.
500
- */
501
- export type RpcConnector = (input: {
502
- url: string;
503
- token: string;
504
- instanceId: string;
505
- local: AgentApi;
506
- }) => Promise<RpcConnection>;
507
- /**
508
- * How many files a single `readFiles` request may ask for at once.
509
- */
510
- export declare const MAX_FILES_PER_REQUEST = 50;
511
- /** Most lines one page may ask for. */
512
- export declare const MAX_PAGE_LINES = 2000;
513
- /**
514
- * Connection payload returned by {@link AgentApi.connect}. Carries only what Studio renders, with
515
- * everything about the config under one key.
516
- */
517
- export type ConnectMessagePayload = {
518
- /**
519
- * Always sent, so a mismatch is visible on both sides: Studio badges the connection with these
520
- * and the host prints them.
521
- */
522
- versions: {
523
- /**
524
- * The version of the `@kubb/studio` runtime the agent runs.
525
- */
526
- kubb: string;
527
- /**
528
- * The version of the host itself (the `kubb.agent` package or the `kubb` CLI).
529
- */
530
- agent: string;
531
- };
532
- /**
533
- * The agent's project root (`KUBB_AGENT_ROOT`, or the working directory when unset). This is the
534
- * workspace that generation runs against.
535
- */
536
- root: string;
537
- /**
538
- * The baseline every generation starts from.
539
- */
540
- config: {
541
- /**
542
- * The config path as configured (`KUBB_AGENT_CONFIG`), relative to `root` unless absolute.
543
- */
544
- path: string;
545
- /**
546
- * What the agent read out of the config file itself, so Studio can render the plugin editor
547
- * against the real file. Absent when the agent could not read it, or was not granted
548
- * `allowConfigEdit`.
549
- */
550
- file?: ConfigFileView;
551
- /**
552
- * Plugins the config registers, with their serialized options.
553
- */
554
- plugins?: Array<{
555
- name: string;
556
- options?: object;
557
- }>;
558
- };
559
- permissions: AgentPermissions;
560
- };
561
- /**
562
- * What an agent may do in the project it serves. Every one is off unless the host granted it, and
563
- * a sandbox session narrows them further.
564
- */
565
- export type AgentPermissions = {
566
- /**
567
- * Whether the agent writes generated files to disk. False for a sandbox agent. For a local
568
- * agent it mirrors the agent's `KUBB_AGENT_ALLOW_WRITE`.
569
- */
570
- allowWrite: boolean;
571
- /**
572
- * Whether the agent runs the formatter, the linter, and `output.postGenerate` as child
573
- * processes after a generation. Always true for the Docker agent, where the image bounds what
574
- * can run. The CLI runs in the user's own project and defaults it off.
575
- */
576
- allowExec: boolean;
577
- /**
578
- * Whether the agent may change plugin options in the user's `kubb.config.ts`. Separate from
579
- * `allowWrite`, which covers generated output: this one edits a hand-authored source file.
580
- */
581
- allowConfigEdit: boolean;
582
- /**
583
- * Whether the agent hands back file source in response to `readFiles`. Always true for a
584
- * sandbox agent; for a local agent it mirrors the agent's own opt-in.
585
- */
586
- allowRead: boolean;
587
- };
588
- /**
589
- * Header naming which process of an agent a socket belongs to, next to the agent's bearer token.
590
- * Several processes may share one token (CI runners, sandbox containers). For a kind that allows
591
- * only one, a new id supersedes the old socket with {@link AgentCloseCode.SUPERSEDED}.
592
- */
593
- export declare const AGENT_INSTANCE_HEADER = "x-kubb-instance-id";
594
- /**
595
- * What an agent process can take on, reported at registration.
596
- */
597
- export type AgentCapacity = {
598
- /** Jobs the process runs at once. Studio clamps it to the agent kind's own cap. */
599
- maxConcurrent: number;
600
- };
601
- /**
602
- * Body of `POST /api/agent/connect`, authenticated with the agent's bearer token.
603
- */
604
- export type AgentRegisterInput = {
605
- /** Hash of this machine's secret, binding the token to one machine identity. */
606
- machineToken: string;
607
- /** This process, sent again as {@link AGENT_INSTANCE_HEADER} when it opens its socket. */
608
- instanceId: string;
609
- capacity: AgentCapacity;
610
- };
611
- /**
612
- * Response of `POST /api/agent/connect`: where this process opens its one socket, and what Studio
613
- * knows about the agent.
614
- */
615
- export type AgentRegisterResponse = {
616
- /** `wss:` URL of the agent socket. The agent authenticates it with its bearer token and instance id. */
617
- socketUrl: string;
618
- /** Whether the agent is a shared sandbox rather than one someone owns. */
619
- isSandbox: boolean;
620
- /** The Studio instance's own version, so both sides can be named from the first connection. */
621
- version?: string;
622
- /** This agent's slug, so a reconnect refreshes it the same way pairing did. */
623
- agentSlug?: string;
624
- /** This agent's organization slug. Absent for a sandbox or global agent, which has none. */
625
- organizationSlug?: string;
626
- };
627
- //#endregion
628
- //# sourceMappingURL=protocol.d.ts.map
1
+ import { A as ReadFilesInput, C as JSONKubbConfig, D as OptionValue, E as MAX_SNAPSHOT_BYTES, F as SnapshotUploadMetadata, I as StudioApi, L as generationEventTypes, M as SaveConfigInput, N as SaveResult, O as PluginView, P as SnapshotChanges, S as GenerationRun, T as MAX_PAGE_LINES, _ as GenerateInput, a as AgentConnectInfo, b as GenerationEventPayloads, c as ConfigEdit, d as ConfigRef, f as ConfigView, g as GENERATION_GONE_MESSAGE, h as FileSource, i as AgentCloseCode, j as ReadFilesResult, k as PublishedSnapshot, l as ConfigEditOutcome, m as FilePage, n as AGENT_SOCKET_PATH, o as AgentPermissions, p as ConnectMessagePayload, r as AgentApi, s as BranchSnapshotChanges, t as AGENT_INSTANCE_HEADER, u as ConfigFileView, v as GenerateResult, w as MAX_FILES_PER_REQUEST, x as GenerationEventType, y as GenerationEvent } from "./protocol-P0znFp9w.js";
2
+ export { AGENT_INSTANCE_HEADER, AGENT_SOCKET_PATH, AgentApi, AgentCloseCode, AgentConnectInfo, AgentPermissions, BranchSnapshotChanges, ConfigEdit, ConfigEditOutcome, ConfigFileView, ConfigRef, ConfigView, ConnectMessagePayload, FilePage, FileSource, GENERATION_GONE_MESSAGE, GenerateInput, GenerateResult, GenerationEvent, GenerationEventPayloads, GenerationEventType, GenerationRun, JSONKubbConfig, MAX_FILES_PER_REQUEST, MAX_PAGE_LINES, MAX_SNAPSHOT_BYTES, OptionValue, PluginView, PublishedSnapshot, ReadFilesInput, ReadFilesResult, SaveConfigInput, SaveResult, SnapshotChanges, SnapshotUploadMetadata, StudioApi, generationEventTypes };
package/dist/protocol.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/protocol/index.ts
1
+ //#region src/protocol.ts
2
2
  /**
3
3
  * The public, JSON-safe subset of Kubb lifecycle hooks. The core registry remains extensible;
4
4
  * adding a core hook does not publish it to Studio until it is listed here and projected below.
@@ -36,30 +36,28 @@ const generationEventTypes = [
36
36
  */
37
37
  const GENERATION_GONE_MESSAGE = "The files of this generation are no longer kept on the agent, run the generation again";
38
38
  /**
39
- * Close codes Studio sends when it ends an agent's connection on purpose. Any other code is an
40
- * ordinary drop, and the agent reconnects.
39
+ * Close codes Studio sends when it ends an agent socket on purpose. `UNAUTHORIZED` means the token
40
+ * was refused, so pair again. `SUPERSEDED` and `INCOMPATIBLE` mean stop. Any other code, `1011`
41
+ * included, is an ordinary drop and the agent reconnects.
41
42
  */
42
43
  const AgentCloseCode = {
43
- /** Register again before reconnecting, such as after Studio forgot this agent's machine token. */
44
- REAUTHENTICATE: 4001,
45
- /** Another instance of the same agent took the connection over. Reconnecting would take it back. */
44
+ UNAUTHORIZED: 4001,
46
45
  SUPERSEDED: 4002,
47
- /** This agent is too old for Studio, or was deleted. Reconnecting cannot succeed. */
48
46
  INCOMPATIBLE: 4003
49
47
  };
48
+ const AGENT_SOCKET_PATH = "/api/agent/socket";
49
+ /**
50
+ * Optional header naming the process a socket belongs to, for agents that run several processes.
51
+ */
52
+ const AGENT_INSTANCE_HEADER = "x-kubb-instance-id";
50
53
  /**
51
54
  * How many files a single `readFiles` request may ask for at once.
52
55
  */
53
56
  const MAX_FILES_PER_REQUEST = 50;
54
57
  /** Most lines one page may ask for. */
55
58
  const MAX_PAGE_LINES = 2e3;
56
- /**
57
- * Header naming which process of an agent a socket belongs to, next to the agent's bearer token.
58
- * Several processes may share one token (CI runners, sandbox containers). For a kind that allows
59
- * only one, a new id supersedes the old socket with {@link AgentCloseCode.SUPERSEDED}.
60
- */
61
- const AGENT_INSTANCE_HEADER = "x-kubb-instance-id";
59
+ const MAX_SNAPSHOT_BYTES = 52428800;
62
60
  //#endregion
63
- export { AGENT_INSTANCE_HEADER, AgentCloseCode, GENERATION_GONE_MESSAGE, MAX_FILES_PER_REQUEST, MAX_PAGE_LINES, generationEventTypes };
61
+ export { AGENT_INSTANCE_HEADER, AGENT_SOCKET_PATH, AgentCloseCode, GENERATION_GONE_MESSAGE, MAX_FILES_PER_REQUEST, MAX_PAGE_LINES, MAX_SNAPSHOT_BYTES, generationEventTypes };
64
62
 
65
63
  //# sourceMappingURL=protocol.js.map