@kubb/studio 5.3.5 → 5.3.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.
@@ -1,34 +1,7 @@
1
1
  import { t as __name } from "./rolldown-runtime-CRm0XQPb.js";
2
2
  //#region src/protocol/index.d.ts
3
3
  /**
4
- * WebSocket message types for the agent ↔ Studio protocol. Every message name carries the side that
5
- * sent it, so direction reads off the name instead of the verb's tense:
6
- *
7
- * | Direction | Type | Purpose |
8
- * | ---------------- | --------------------- | -------------------------------------------------------------|
9
- * | Studio → agent | `studio:generate` | Run a generation. No dedicated reply, the result arrives as an `agent:data` message carrying `kubb:generation:end`, so it stays ordered against the rest of that run's event stream. The file list is on `kubb:build:end`; contents are fetched separately with `studio:files`. |
10
- * | Studio → agent | `studio:connect` | Ask the agent to resend its `agent:connect` handshake payload. |
11
- * | Studio → agent | `studio:save` | Edit `kubb.config.ts`. Replied to with `agent:save`. |
12
- * | Studio → agent | `studio:snapshot` | Pack the session's most recent generation into a tarball and upload it to a Studio path, which redirects to storage. Carries no file contents itself. Replied to with `agent:snapshot`. |
13
- * | Studio → agent | `studio:files` | Ask for the source of files the last generation produced, by path. Refused unless the agent was granted `allowRead`. Replied to with `agent:files`. |
14
- * | Studio → agent | `studio:pong` | Reply to an `agent:ping` heartbeat. |
15
- * | Studio → agent | `studio:ready` | Acknowledges `agent:connect`, so the session now counts as available for job dispatch. |
16
- * | Studio → agent | `studio:disconnect` | The session expired or was revoked, so the agent should not reconnect. |
17
- * | Studio → agent | `studio:error` | A failure outside a generation, e.g. a malformed command. |
18
- * | Agent → Studio | `agent:connect` | Handshake sent on open and after every `studio:connect`. |
19
- * | Agent → Studio | `agent:save` | Reply to `studio:save`. |
20
- * | Agent → Studio | `agent:snapshot` | Reply to `studio:snapshot`. The tarball itself already went out to storage, so this only carries the integrity hash, the resolved peer dependencies, or an error. |
21
- * | Agent → Studio | `agent:files` | Reply to `studio:files`, carrying only the source of the requested paths, or an error. |
22
- * | Agent → Studio | `agent:data` | One generation lifecycle event, `payload.type` a {@link KubbHook}. Carries `kubb:generation:end`, `studio:generate`'s closest thing to a reply, among many others. |
23
- * | Agent → Studio | `agent:ping` | Heartbeat, so the connection is not treated as idle. |
24
- * | Agent → Studio | `agent:disconnect` | The agent is shutting down. |
25
- *
26
- * `kubb:` stays reserved for generation lifecycle, so the {@link KubbHooks} events relayed inside an
27
- * `agent:data` payload keep their own names. The envelope says who sent it, the payload says what
28
- * happened.
29
- */
30
- /**
31
- * JSON-serializable Kubb config exchanged over the WebSocket. A live `kubb/kit` config holds
4
+ * JSON-serializable Kubb config exchanged over RPC. A live `kubb/kit` config holds
32
5
  * functions and class instances that cannot survive JSON, so both sides pass this flattened shape
33
6
  * and rebuild the real config from it.
34
7
  */
@@ -198,12 +171,19 @@ export type ConfigEditOutcome = {
198
171
  reason?: string;
199
172
  };
200
173
  /**
201
- * Typed events sent by the Kubb agent to Studio over WebSocket.
202
- * Mirrors the single-context-object tuple style of {@link KubbHooks} in `kubb/kit`,
203
- * using JSON-serializable shapes (e.g. `sources` as a `Record` instead of `Map`,
204
- * `error` as `{ message; stack? }` instead of `Error`).
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.
205
185
  */
206
- export type KubbHooks = {
186
+ export type GenerationEventPayloads = {
207
187
  'kubb:plugin:start': [ctx: {
208
188
  plugin: {
209
189
  name: string;
@@ -261,9 +241,18 @@ export type KubbHooks = {
261
241
  message: string;
262
242
  stack?: string;
263
243
  }];
264
- 'kubb:debug': [ctx: {
265
- logs: Array<string>;
266
- fileName?: string;
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;
267
256
  }];
268
257
  'kubb:generation:start': [ctx: {
269
258
  name?: string;
@@ -271,7 +260,7 @@ export type KubbHooks = {
271
260
  }];
272
261
  /**
273
262
  * A run finished. See `kubb:build:end` for files, `kubb:generation:summary` for the count, and
274
- * `studio:files` for contents.
263
+ * `readFiles` for contents.
275
264
  */
276
265
  'kubb:generation:end': [];
277
266
  'kubb:generation:summary': [ctx: {
@@ -308,89 +297,121 @@ export type KubbHooks = {
308
297
  };
309
298
  }];
310
299
  };
311
- export type KubbHook = keyof KubbHooks;
312
300
  /**
313
- * Run a generation with the given config. `payload` is the merged config Studio wants generated.
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.
314
303
  */
315
- export type StudioGenerateMessage = {
316
- type: 'studio:generate';
304
+ export type GenerationEvent = { [Type in GenerationEventType]: {
305
+ type: Type;
306
+ data: GenerationEventPayloads[Type];
307
+ }; }[GenerationEventType] & {
308
+ version: 1;
317
309
  jobId: string;
318
- payload: JSONKubbConfig;
310
+ timestamp: number;
319
311
  };
320
312
  /**
321
- * Ask the agent to send a fresh `agent:connect` payload. Permissions are fixed when the host starts
322
- * the agent; this message only triggers another read of disk config and saved Studio state.
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.
323
315
  */
324
- export type StudioConnectMessage = {
325
- type: 'studio:connect';
326
- jobId?: string;
327
- /**
328
- * Version of the Studio instance asking, which refreshes what the agent picked up when the
329
- * session was created. Absent when Studio predates the field.
330
- */
331
- version?: string;
316
+ export type GenerateInput = {
317
+ jobId: string;
318
+ config: JSONKubbConfig;
332
319
  };
333
320
  /**
334
- * Change plugin options in the user's `kubb.config.ts`. Applied only when the agent was granted
335
- * `allowConfigEdit`; otherwise every edit comes back refused.
321
+ * What a finished run produced. `files` holds paths relative to the output directory.
336
322
  */
337
- export type StudioSaveMessage = {
338
- type: 'studio:save';
339
- jobId: string;
323
+ export type GenerateResult = {
324
+ status: 'success' | 'failed';
325
+ files: Array<string>;
326
+ fileCount: number;
327
+ };
328
+ /**
329
+ * Asks the agent to apply a batch of edits to the config file on disk.
330
+ */
331
+ export type SaveConfigInput = {
340
332
  edits: Array<ConfigEdit>;
341
333
  };
342
334
  /**
343
- * Ask the agent to pack a previous generation's files into an npm-installable tarball and upload
344
- * it to Studio directly, rather than returning the bytes over this socket. Packs the files the
345
- * session's own most recent `studio:generate` produced, so it only works right after that
346
- * generation and never carries file contents itself. Refused for a sandbox agent, since it holds
347
- * no generated files worth packing, and refused when no prior generation exists to pack.
335
+ * Per-edit outcomes plus the rewritten file. `changed` is false when every edit was a no-op, so a
336
+ * caller can skip reloading.
348
337
  */
349
- export type StudioSnapshotMessage = {
350
- type: 'studio:snapshot';
351
- jobId: string;
352
- payload: {
353
- name: string;
354
- version: string;
355
- /**
356
- * Packages Studio already bundles, so a missing one is not a reason to refuse the snapshot.
357
- */
358
- bundledDependencies?: Array<string>;
359
- /**
360
- * Studio path the agent `PUT`s the finished tarball to. Studio answers with a redirect to
361
- * storage, so the storage URL stays out of this message.
362
- */
363
- uploadPath: string;
364
- };
338
+ export type SaveResult = {
339
+ outcomes: Array<ConfigEditOutcome>;
340
+ changed: boolean;
341
+ file?: ConfigFileView;
365
342
  };
366
343
  /**
367
- * Ask the agent for the source of files the last generation produced, by path. Refused unless the
368
- * agent was granted `allowRead`. Replied to with `agent:files`.
344
+ * Asks the agent to read generated files back. Capped at {@link MAX_FILES_PER_REQUEST} paths, all
345
+ * of which must sit inside the output directory.
369
346
  */
370
- export type StudioFilesMessage = {
371
- type: 'studio:files';
372
- jobId: string;
373
- payload: {
374
- /**
375
- * Paths as `kubb:build:end` listed them, at most `MAX_FILES_PER_REQUEST` of them.
376
- */
377
- paths: Array<string>;
378
- };
347
+ export type ReadFilesInput = {
348
+ paths: Array<string>;
349
+ };
350
+ /**
351
+ * Describes the package to pack and where to PUT it. `uploadPath` is resolved against the Studio
352
+ * origin, so it cannot redirect the upload elsewhere.
353
+ */
354
+ export type PublishSnapshotInput = {
355
+ name: string;
356
+ version: string;
357
+ bundledDependencies?: Array<string>;
358
+ uploadPath: string;
359
+ };
360
+ /**
361
+ * Identifies the uploaded snapshot. `integrity` is the subresource hash Studio verifies against.
362
+ */
363
+ export type PublishSnapshotResult = {
364
+ integrity: string;
365
+ peerDependencies: Record<string, string>;
366
+ };
367
+ /**
368
+ * A generation in flight. Cap'n Web keeps the three calls pointed at the same run, so a caller can
369
+ * read `events()` while `result()` is still pending and `cancel()` stops it early.
370
+ */
371
+ export type GenerationRun = {
372
+ events: () => Promise<ReadableStream<GenerationEvent>>;
373
+ result: () => Promise<GenerateResult>;
374
+ cancel: () => Promise<void>;
375
+ };
376
+ /**
377
+ * Operations Studio can invoke on an agent through a host-provided RPC transport.
378
+ */
379
+ export type AgentApi = {
380
+ connect: () => Promise<ConnectMessagePayload>;
381
+ startGeneration: (input: GenerateInput) => GenerationRun;
382
+ saveConfig: (input: SaveConfigInput) => Promise<SaveResult>;
383
+ publishSnapshot: (input: PublishSnapshotInput) => Promise<PublishSnapshotResult>;
384
+ readFiles: (input: ReadFilesInput) => Promise<{
385
+ files: Record<string, string>;
386
+ }>;
379
387
  };
380
388
  /**
381
- * Anything Studio asks the agent to do. Each command is its own `type`, so a handler switches once
382
- * instead of reading a `type` and then a nested `command` field.
389
+ * Operations an agent can invoke on Studio through a host-provided RPC transport.
383
390
  */
384
- export type CommandMessage = StudioGenerateMessage | StudioConnectMessage | StudioSaveMessage | StudioSnapshotMessage | StudioFilesMessage;
391
+ export type StudioApi = {
392
+ ping: () => Promise<void>;
393
+ };
394
+ /**
395
+ * A live RPC session. `closed` settles when the transport drops, whichever side ended it.
396
+ */
397
+ export type RpcConnection = {
398
+ studio: StudioApi;
399
+ closed: Promise<void>;
400
+ close: () => void;
401
+ };
385
402
  /**
386
- * The command names, for a host that needs the list rather than the union.
403
+ * Opens a transport and hands both sides their peer. Swapping this is how a test drives a session
404
+ * without a socket.
387
405
  */
388
- export declare const commandTypes: readonly ["studio:generate", "studio:connect", "studio:save", "studio:snapshot", "studio:files"];
406
+ export type RpcConnector = (input: {
407
+ url: string;
408
+ token: string;
409
+ local: AgentApi;
410
+ }) => Promise<RpcConnection>;
389
411
  /**
390
- * How many files a single `studio:files` request may ask for at once.
412
+ * How many files a single `readFiles` request may ask for at once.
391
413
  */
392
414
  export declare const MAX_FILES_PER_REQUEST = 50;
393
- export declare function createJobId(): string;
394
415
  /**
395
416
  * Identifies the host running the Kubb runtime. Local to the runtime, not part of the wire: it
396
417
  * picks which remedy a refused-permission warning names. Distinct from an agent's `type` (`user`,
@@ -404,8 +425,8 @@ export type ClientInfo = {
404
425
  kind: 'cli' | 'docker';
405
426
  };
406
427
  /**
407
- * Payload of the `agent:connect` handshake, sent when the agent attaches to a session. Carries only
408
- * what Studio renders, with everything about the config under one key.
428
+ * Connection payload returned by {@link AgentApi.connect}. Carries only what Studio renders, with
429
+ * everything about the config under one key.
409
430
  */
410
431
  export type ConnectMessagePayload = {
411
432
  /**
@@ -479,170 +500,21 @@ export type AgentPermissions = {
479
500
  */
480
501
  allowConfigEdit: boolean;
481
502
  /**
482
- * Whether the agent hands back file source in response to `studio:files`. Always true for a
503
+ * Whether the agent hands back file source in response to `readFiles`. Always true for a
483
504
  * sandbox agent; for a local agent it mirrors the agent's own opt-in.
484
505
  */
485
506
  allowRead: boolean;
486
507
  };
487
- /**
488
- * Agent → Studio handshake. Sent when the WebSocket opens and again after a `connect` command.
489
- * Carries the on-disk config baseline, granted permissions, and paths Studio needs to render the editor.
490
- */
491
- export type AgentConnectMessage = {
492
- type: 'agent:connect';
493
- payload: ConnectMessagePayload;
494
- };
495
- /**
496
- * Reply to a `save` command: what the agent did to the file on disk.
497
- */
498
- export type AgentSaveMessage = {
499
- type: 'agent:save';
500
- jobId: string;
501
- payload: {
502
- /**
503
- * Per-edit result, in the order the edits were sent.
504
- */
505
- outcomes: Array<ConfigEditOutcome>;
506
- /**
507
- * Whether the file on disk changed. False when every edit was refused, and when the applied
508
- * edits produced the text the file already had.
509
- */
510
- changed: boolean;
511
- /**
512
- * The config file as it now stands, so Studio can re-render without a round trip. Absent when
513
- * nothing was written. Named to match `config.file` in the connect payload.
514
- */
515
- file?: ConfigFileView;
516
- };
517
- };
518
- /**
519
- * Reply to `studio:snapshot`. The tarball already went to storage, so this reports whether the
520
- * upload succeeded plus the peer dependencies the agent resolved while packing it.
521
- */
522
- export type AgentSnapshotMessage = {
523
- type: 'agent:snapshot';
524
- jobId: string;
525
- payload: {
526
- status: 'ok';
527
- integrity: string;
528
- /**
529
- * Resolved peer dependencies of the packed generation, for Studio's snapshot metadata.
530
- */
531
- peerDependencies: Record<string, string>;
532
- } | {
533
- status: 'error';
534
- message: string;
535
- };
536
- };
537
- /**
538
- * Reply to `studio:files`, carrying the source of the requested paths.
539
- */
540
- export type AgentFilesMessage = {
541
- type: 'agent:files';
542
- jobId: string;
543
- payload: {
544
- status: 'ok';
545
- /**
546
- * Source keyed by the requested path. A path the last generation did not produce is left
547
- * out rather than reported, so one stale path does not fail the rest.
548
- */
549
- files: Record<string, string>;
550
- } | {
551
- status: 'error';
552
- message: string;
553
- };
554
- };
555
- /**
556
- * Failure notice from Studio for something that breaks outside a generation, such as a malformed
557
- * command. The agent's own failures travel as an `agent:data` message carrying a `kubb:error`
558
- * payload, which keeps them ordered against the generation events around them.
559
- */
560
- export type StudioErrorMessage = {
561
- type: 'studio:error';
562
- message: string;
563
- };
564
- /**
565
- * Heartbeat sent by the Agent to Studio so the connection is not treated as idle.
566
- */
567
- export type AgentPingMessage = {
568
- type: 'agent:ping';
569
- };
570
- /**
571
- * Studio's reply to an `agent:ping`, confirming the connection is still alive.
572
- */
573
- export type StudioPongMessage = {
574
- type: 'studio:pong';
575
- };
576
- /**
577
- * Studio's acknowledgement that an `agent:connect` handshake was received and the session is
578
- * fully registered: the connection now counts as available for job dispatch. Distinct from the
579
- * socket merely being open, which is not yet the same thing.
580
- */
581
- export type StudioReadyMessage = {
582
- type: 'studio:ready';
583
- };
584
- /**
585
- * Disconnect message sent from Studio to Agent when the session is expired or revoked.
586
- * The agent should close the connection without reconnecting.
587
- */
588
- export type StudioDisconnectMessage = {
589
- type: 'studio:disconnect';
590
- reason: 'expired' | 'revoked';
591
- };
592
- /**
593
- * The agent going away, so Studio marks the session offline instead of waiting out the heartbeat
594
- * window. The mirror of {@link StudioDisconnectMessage}.
595
- *
596
- * Only sent for a shutdown. An expired or revoked session was Studio's own decision, so echoing it
597
- * back says nothing new.
598
- */
599
- export type AgentDisconnectMessage = {
600
- type: 'agent:disconnect';
601
- reason: 'shutdown';
602
- };
603
- /**
604
- * Payload of an `agent:data` message: a single Kubb generation event forwarded to Studio in real time.
605
- * Generic over the hook name so `data` is typed to that hook's context tuple.
606
- */
607
- export type DataMessagePayload<T extends KubbHook = KubbHook> = {
608
- /**
609
- * The Kubb hook this event is for (e.g. `kubb:plugin:start`).
610
- */
611
- type: T;
612
- /**
613
- * The hook's context tuple, matching `KubbHooks[type]`.
614
- */
615
- data: KubbHooks[T];
616
- /**
617
- * When the agent emitted the event, epoch milliseconds.
618
- */
619
- timestamp: number;
620
- /**
621
- * Monotonic per-connection counter stamped in the order the agent emits events. Studio orders the
622
- * event log by this, since `timestamp` has millisecond resolution and a full generation fires
623
- * dozens of events per tick, and the relay can deliver them out of order.
624
- */
625
- seq: number;
626
- };
627
- /**
628
- * Envelope for a single generation event streamed from Agent to Studio. Wraps a
629
- * {@link DataMessagePayload} so both sides can switch on `type: 'agent:data'`.
630
- */
631
- export type DataMessage<T extends KubbHook = KubbHook> = {
632
- type: 'agent:data';
633
- jobId: string;
634
- payload: DataMessagePayload<T>;
635
- };
636
508
  /**
637
509
  * Response returned by the Studio `/api/agent/sessions` endpoint.
638
510
  */
639
511
  export type AgentConnectResponse = {
640
512
  /**
641
- * WebSocket URL the agent opens to reach the session, with the session token embedded.
513
+ * URL the agent opens to reach the session, with the session token embedded.
642
514
  */
643
- wsUrl: string;
515
+ url: string;
644
516
  /**
645
- * When the session expires and the wsUrl stops working (ISO 8601).
517
+ * When the session expires and the url stops working (ISO 8601).
646
518
  */
647
519
  expiresAt: string;
648
520
  /**
@@ -650,7 +522,7 @@ export type AgentConnectResponse = {
650
522
  */
651
523
  revokedAt: string | null;
652
524
  /**
653
- * Opaque session token, also embedded in `wsUrl`. Store it to revoke the session later.
525
+ * Opaque session token, also embedded in `url`. Store it to revoke the session later.
654
526
  */
655
527
  sessionId: string;
656
528
  /**
@@ -662,32 +534,11 @@ export type AgentConnectResponse = {
662
534
  */
663
535
  isSandbox: boolean;
664
536
  /**
665
- * The Studio instance's own version. Reported here rather than only on `studio:connect`, so the
666
- * agent knows it before it announces itself and can name both sides from the first connect.
537
+ * The Studio instance's own version. Returned with the RPC session so the agent can name both
538
+ * sides from the first connection.
667
539
  * Absent when Studio predates the field.
668
540
  */
669
541
  version?: string;
670
542
  };
671
- /**
672
- * Every message that can cross the agent WebSocket, in either direction. Narrow it with the
673
- * `is*Message` guards below before reading a variant's fields.
674
- */
675
- export type AgentMessage = CommandMessage | DataMessage | AgentConnectMessage | AgentSaveMessage | AgentSnapshotMessage | AgentFilesMessage | AgentPingMessage | AgentDisconnectMessage | StudioErrorMessage | StudioPongMessage | StudioReadyMessage | StudioDisconnectMessage;
676
- export declare function isCommandMessage(msg: AgentMessage): msg is CommandMessage;
677
- /**
678
- * Type guard to narrow a data message to a specific event type.
679
- *
680
- * @example
681
- * ```ts
682
- * if (isDataMessage(msg, 'kubb:plugin:start')) {
683
- * // msg.payload.data is now typed as [ctx: { plugin: { name: string } }]
684
- * const pluginName = msg.payload.data[0].plugin.name
685
- * }
686
- * ```
687
- */
688
- export declare function isDataMessage<T extends KubbHook>(msg: AgentMessage, type?: T): msg is DataMessage<T>;
689
- export declare function isStudioPongMessage(msg: AgentMessage): msg is StudioPongMessage;
690
- export declare function isStudioReadyMessage(msg: AgentMessage): msg is StudioReadyMessage;
691
- export declare function isDisconnectMessage(msg: AgentMessage): msg is StudioDisconnectMessage;
692
543
  //#endregion
693
544
  //# sourceMappingURL=protocol.d.ts.map
package/dist/protocol.js CHANGED
@@ -1,49 +1,41 @@
1
- import "./rolldown-runtime-CRm0XQPb.js";
2
1
  //#region src/protocol/index.ts
3
2
  /**
4
- * The command names, for a host that needs the list rather than the union.
3
+ * The public, JSON-safe subset of Kubb lifecycle hooks. The core registry remains extensible;
4
+ * adding a core hook does not publish it to Studio until it is listed here and projected below.
5
5
  */
6
- const commandTypes = [
7
- "studio:generate",
8
- "studio:connect",
9
- "studio:save",
10
- "studio:snapshot",
11
- "studio:files"
6
+ const generationEventTypes = [
7
+ "kubb:plugin:start",
8
+ "kubb:plugin:end",
9
+ "kubb:build:start",
10
+ "kubb:build:end",
11
+ "kubb:files:processing:start",
12
+ "kubb:files:processing:update",
13
+ "kubb:files:processing:end",
14
+ "kubb:info",
15
+ "kubb:success",
16
+ "kubb:warn",
17
+ "kubb:error",
18
+ "kubb:diagnostic",
19
+ "kubb:generation:start",
20
+ "kubb:generation:end",
21
+ "kubb:generation:summary",
22
+ "kubb:lifecycle:start",
23
+ "kubb:lifecycle:end",
24
+ "kubb:format:start",
25
+ "kubb:format:end",
26
+ "kubb:lint:start",
27
+ "kubb:lint:end",
28
+ "kubb:hooks:start",
29
+ "kubb:hooks:end",
30
+ "kubb:hook:start",
31
+ "kubb:hook:line",
32
+ "kubb:hook:end"
12
33
  ];
13
34
  /**
14
- * How many files a single `studio:files` request may ask for at once.
35
+ * How many files a single `readFiles` request may ask for at once.
15
36
  */
16
37
  const MAX_FILES_PER_REQUEST = 50;
17
- function createJobId() {
18
- return crypto.randomUUID();
19
- }
20
- function isCommandMessage(msg) {
21
- return commandTypes.includes(msg.type);
22
- }
23
- /**
24
- * Type guard to narrow a data message to a specific event type.
25
- *
26
- * @example
27
- * ```ts
28
- * if (isDataMessage(msg, 'kubb:plugin:start')) {
29
- * // msg.payload.data is now typed as [ctx: { plugin: { name: string } }]
30
- * const pluginName = msg.payload.data[0].plugin.name
31
- * }
32
- * ```
33
- */
34
- function isDataMessage(msg, type) {
35
- return msg.type === "agent:data" && (type ? msg.payload.type === type : true);
36
- }
37
- function isStudioPongMessage(msg) {
38
- return msg.type === "studio:pong";
39
- }
40
- function isStudioReadyMessage(msg) {
41
- return msg.type === "studio:ready";
42
- }
43
- function isDisconnectMessage(msg) {
44
- return msg.type === "studio:disconnect";
45
- }
46
38
  //#endregion
47
- export { MAX_FILES_PER_REQUEST, commandTypes, createJobId, isCommandMessage, isDataMessage, isDisconnectMessage, isStudioPongMessage, isStudioReadyMessage };
39
+ export { MAX_FILES_PER_REQUEST, generationEventTypes };
48
40
 
49
41
  //# sourceMappingURL=protocol.js.map