@kubb/studio 5.10.2 → 5.10.4

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.
@@ -0,0 +1,778 @@
1
+ import { ExtensionKind, ExtensionManifest } from "@kubb/core";
2
+ import { InputNode } from "@kubb/ast";
3
+ //#region src/protocol.d.ts
4
+ /**
5
+ * JSON-serializable Kubb config exchanged over RPC. A live `kubb/kit` config holds
6
+ * functions and class instances that cannot survive JSON, so both sides pass this flattened shape
7
+ * and rebuild the real config from it.
8
+ */
9
+ type JSONKubbConfig = {
10
+ /**
11
+ * Plugins with their serialized options. `name` is the package name (e.g. `@kubb/plugin-ts`)
12
+ * and `options` is an opaque blob the agent forwards unchanged to the plugin factory. An entry
13
+ * with `disabled: true` is dropped even when the disk config's `plugins` array still lists it.
14
+ */
15
+ plugins?: Array<{
16
+ name: string;
17
+ options?: object;
18
+ disabled?: boolean;
19
+ }>;
20
+ /**
21
+ * Raw OpenAPI / Swagger spec content (YAML or JSON string), never a file path or URL.
22
+ * Required by a 'sandbox' agent, which has no disk config of its own and refuses anything else.
23
+ * A non-sandbox agent always reads its spec from disk, so this is ignored with a `kubb:warn`.
24
+ */
25
+ input?: string;
26
+ /**
27
+ * Adapter option overrides sent from Studio UI. Merged into the disk config's adapter options
28
+ * and re-applied through the same adapter factory, since an adapter instance's functions
29
+ * (`parse`, `getImports`, ...) can't survive JSON serialization over the WebSocket.
30
+ */
31
+ adapter?: object;
32
+ /**
33
+ * Parser option overrides from Studio, matched to the disk config's parsers by `name` and
34
+ * re-applied through each parser's factory, the same way `adapter` is.
35
+ */
36
+ parsers?: Array<{
37
+ name: string;
38
+ options?: object;
39
+ }>;
40
+ };
41
+ /**
42
+ * Which `defineConfig(...)` entry an edit targets, for a config file that exports an array.
43
+ *
44
+ * A number selects by position, a string matches the entry's `name`. Omitted targets the only
45
+ * entry, or the first one when the file exports an array.
46
+ */
47
+ type ConfigRef = string | number;
48
+ /**
49
+ * A value the agent can read out of a plugin option in `kubb.config.ts` and round-trip through JSON.
50
+ */
51
+ type OptionValue = string | number | boolean | null | Array<OptionValue> | {
52
+ [key: string]: OptionValue;
53
+ };
54
+ /**
55
+ * One change to a plugin's options in the user's `kubb.config.ts`.
56
+ *
57
+ * `plugin` is the package name (`@kubb/plugin-ts`), the same identity used in {@link JSONKubbConfig}.
58
+ * The agent applies these to the file with an AST patch, so only the targeted values are rewritten.
59
+ *
60
+ * Declared here rather than in `configFile.ts` because this is the wire contract, and the patcher
61
+ * imports it from here. Type-only, so nothing pulls `magicast` into this entry point.
62
+ */
63
+ type ConfigEdit =
64
+ /**
65
+ * Write a literal option value. `path` walks nested objects, so `['enum', 'type']` targets
66
+ * `pluginTs({ enum: { type } })`. `kind` names which factory call `plugin` is: one in `plugins`
67
+ * when left out, the config's `adapter`, or one in `parsers`.
68
+ */
69
+ {
70
+ operation: 'set';
71
+ config?: ConfigRef;
72
+ kind?: ExtensionKind;
73
+ plugin: string;
74
+ path: Array<string>;
75
+ value: unknown;
76
+ } |
77
+ /**
78
+ * Drop an option so the extension falls back to its default. `kind` as for `set`.
79
+ */
80
+ {
81
+ operation: 'remove';
82
+ config?: ConfigRef;
83
+ kind?: ExtensionKind;
84
+ plugin: string;
85
+ path: Array<string>;
86
+ } |
87
+ /**
88
+ * Add a plugin factory call and its import to the `plugins` array.
89
+ */
90
+ {
91
+ operation: 'add-plugin';
92
+ config?: ConfigRef;
93
+ plugin: string;
94
+ options?: Record<string, unknown>;
95
+ } |
96
+ /**
97
+ * Comment the plugin call out, keeping its options in the file so enabling it again restores them.
98
+ */
99
+ {
100
+ operation: 'disable-plugin';
101
+ config?: ConfigRef;
102
+ plugin: string;
103
+ } |
104
+ /**
105
+ * Uncomment a plugin call a previous `disable-plugin` commented out.
106
+ */
107
+ {
108
+ operation: 'enable-plugin';
109
+ config?: ConfigRef;
110
+ plugin: string;
111
+ };
112
+ /**
113
+ * A factory call the agent found in a `defineConfig(...)`: a plugin in `plugins`, the `adapter`, or
114
+ * a parser in `parsers`.
115
+ */
116
+ type PluginView = {
117
+ /**
118
+ * Local identifier of the factory in the file, e.g. `pluginTs`. This is the alias when the plugin
119
+ * was imported under one.
120
+ */
121
+ importName: string;
122
+ /**
123
+ * Module the factory is imported from, e.g. `@kubb/plugin-ts`.
124
+ */
125
+ packageName: string;
126
+ /**
127
+ * Top-level option keys, each flagged with whether the agent may write it and, when it can, the
128
+ * value found in the file. An option marked `literal: false` holds a function or a reference the
129
+ * agent will not overwrite, so Studio shows the control disabled rather than hiding it, and
130
+ * `value` is absent since there is nothing safe to display as the current value.
131
+ *
132
+ * An object option that holds code in only some members, such as
133
+ * `output: { path: './gen', banner: () => '' }`, also carries `value` with its literal members
134
+ * and `locked` with the paths of the members that are code, relative to the option
135
+ * (`[['banner']]`). A `set` at any deeper path outside `locked` succeeds, so Studio can edit
136
+ * `output.path` there.
137
+ */
138
+ options: Record<string, {
139
+ literal: boolean;
140
+ value?: OptionValue;
141
+ locked?: Array<Array<string>>;
142
+ }>;
143
+ /**
144
+ * Set when the plugin call is commented out in the file. Its options stay on disk but are not
145
+ * readable, so `options` is empty until it is enabled again.
146
+ */
147
+ disabled?: true;
148
+ };
149
+ /**
150
+ * One `defineConfig(...)` entry. A config file that exports a single object has exactly one.
151
+ */
152
+ type ConfigView = {
153
+ /**
154
+ * The entry's `name`, when it sets one. Studio labels the config picker with it.
155
+ */
156
+ name?: string;
157
+ /**
158
+ * Each plugin call in the entry, with its top-level option keys.
159
+ */
160
+ plugins: Array<PluginView>;
161
+ /**
162
+ * The `adapter` call, when the entry sets one through an imported factory.
163
+ */
164
+ adapter?: PluginView;
165
+ /**
166
+ * The parser calls in `parsers`, when the entry lists any through imported factories.
167
+ */
168
+ parsers?: Array<PluginView>;
169
+ };
170
+ /**
171
+ * What the agent found in the user's config file, so Studio knows which controls it may offer.
172
+ * Absent when the agent could not read the file at all.
173
+ */
174
+ type ConfigFileView = {
175
+ managed: true;
176
+ /**
177
+ * One entry per config the file exports, in source order. Every {@link ConfigEdit} names
178
+ * which of these it targets through its `config` field.
179
+ */
180
+ configs: Array<ConfigView>;
181
+ } | {
182
+ managed: false;
183
+ /**
184
+ * Why the file is outside what the agent edits, for example a default export that is not a
185
+ * `defineConfig(...)` call. Studio shows this and offers no property-level controls.
186
+ */
187
+ reason: string;
188
+ };
189
+ /**
190
+ * Outcome of a single {@link ConfigEdit}, returned in a {@link SaveResult}.
191
+ */
192
+ type ConfigEditOutcome = {
193
+ edit: ConfigEdit;
194
+ applied: boolean;
195
+ /**
196
+ * Why the edit was refused, absent when it was applied.
197
+ */
198
+ reason?: string;
199
+ };
200
+ /**
201
+ * The public, JSON-safe subset of Kubb lifecycle hooks. The core registry remains extensible;
202
+ * adding a core hook does not publish it to Studio until it is listed here and projected below.
203
+ */
204
+ 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"];
205
+ /**
206
+ * One of the lifecycle hooks {@link generationEventTypes} publishes.
207
+ */
208
+ type GenerationEventType = (typeof generationEventTypes)[number];
209
+ /**
210
+ * The JSON-safe payload each published event carries. These are flattened on purpose: a core hook
211
+ * context holds live objects (a `Config`, a `Storage`) that cannot cross the wire.
212
+ */
213
+ type GenerationEventPayloads = {
214
+ 'kubb:plugin:start': [ctx: {
215
+ plugin: {
216
+ name: string;
217
+ };
218
+ }];
219
+ 'kubb:plugin:end': [ctx: {
220
+ plugin: {
221
+ name: string;
222
+ };
223
+ duration: number;
224
+ success: boolean;
225
+ }];
226
+ 'kubb:build:start': [ctx: {
227
+ config: {
228
+ name?: string;
229
+ };
230
+ adapter: {
231
+ name: string;
232
+ };
233
+ }];
234
+ 'kubb:build:end': [ctx: {
235
+ files: Array<{
236
+ path: string;
237
+ name: string;
238
+ }>;
239
+ outputDir: string;
240
+ }];
241
+ 'kubb:files:processing:start': [ctx: {
242
+ total: number;
243
+ }];
244
+ 'kubb:files:processing:update': [ctx: {
245
+ files: Array<{
246
+ file: string;
247
+ processed: number;
248
+ total: number;
249
+ percentage: number;
250
+ }>;
251
+ }];
252
+ 'kubb:files:processing:end': [ctx: {
253
+ total: number;
254
+ }];
255
+ 'kubb:info': [ctx: {
256
+ message: string;
257
+ info?: string;
258
+ }];
259
+ 'kubb:success': [ctx: {
260
+ message: string;
261
+ info?: string;
262
+ }];
263
+ 'kubb:warn': [ctx: {
264
+ message: string;
265
+ info?: string;
266
+ }];
267
+ 'kubb:error': [ctx: {
268
+ message: string;
269
+ stack?: string;
270
+ }];
271
+ 'kubb:diagnostic': [ctx: {
272
+ code: string;
273
+ message: string;
274
+ severity: string;
275
+ location?: {
276
+ kind: string;
277
+ pointer?: string;
278
+ ref?: string;
279
+ };
280
+ help?: string;
281
+ plugin?: string;
282
+ stack?: string;
283
+ }];
284
+ 'kubb:generation:start': [ctx: {
285
+ name?: string;
286
+ plugins: number;
287
+ }];
288
+ /**
289
+ * A run finished. See `kubb:build:end` for files, `kubb:generation:summary` for the count, and
290
+ * `readFiles` for contents.
291
+ */
292
+ 'kubb:generation:end': [];
293
+ 'kubb:generation:summary': [ctx: {
294
+ duration: number;
295
+ fileCount: number;
296
+ failedPlugins: number;
297
+ status: 'success' | 'failed';
298
+ }];
299
+ 'kubb:lifecycle:start': [];
300
+ 'kubb:lifecycle:end': [];
301
+ 'kubb:format:start': [];
302
+ 'kubb:format:end': [];
303
+ 'kubb:lint:start': [];
304
+ 'kubb:lint:end': [];
305
+ 'kubb:hooks:start': [];
306
+ 'kubb:hooks:end': [];
307
+ 'kubb:hook:start': [ctx: {
308
+ id?: string;
309
+ command: string;
310
+ args?: Array<string>;
311
+ }];
312
+ 'kubb:hook:line': [ctx: {
313
+ id: string;
314
+ line: string;
315
+ }];
316
+ 'kubb:hook:end': [ctx: {
317
+ id?: string;
318
+ command: string;
319
+ args?: Array<string>;
320
+ success: boolean;
321
+ error?: {
322
+ message: string;
323
+ stack?: string;
324
+ };
325
+ }];
326
+ };
327
+ /**
328
+ * Versioned envelope around one lifecycle event. Cap'n Web streams preserve the order the agent
329
+ * emitted them in, so the receiver replays a run by reading the stream straight through.
330
+ */
331
+ type GenerationEvent = { [Type in GenerationEventType]: {
332
+ type: Type;
333
+ data: GenerationEventPayloads[Type];
334
+ }; }[GenerationEventType] & {
335
+ version: 1;
336
+ jobId: string;
337
+ timestamp: number;
338
+ };
339
+ /**
340
+ * Asks the agent to run one generation. `jobId` tags every event the run emits so a caller
341
+ * watching several runs can tell them apart.
342
+ */
343
+ type GenerateInput = {
344
+ jobId: string;
345
+ config: JSONKubbConfig;
346
+ };
347
+ /**
348
+ * What a finished run produced.
349
+ */
350
+ type GenerateResult = {
351
+ status: 'success' | 'failed';
352
+ /**
353
+ * Paths of the generated files, relative to the output directory.
354
+ */
355
+ files: Array<string>;
356
+ fileCount: number;
357
+ /**
358
+ * Content fingerprint per file in `files`, to tell changed files apart without reading them.
359
+ */
360
+ hashes: Record<string, string>;
361
+ /**
362
+ * Fingerprints of the output directory on disk before the run, for an agent with a project on disk.
363
+ */
364
+ disk?: {
365
+ hashes: Record<string, string>;
366
+ };
367
+ };
368
+ /**
369
+ * Asks the agent to apply a batch of edits to the config file on disk.
370
+ */
371
+ type SaveConfigInput = {
372
+ edits: Array<ConfigEdit>;
373
+ };
374
+ /**
375
+ * Per-edit outcomes. `changed` is false when every edit was a no-op, so a caller can skip reloading.
376
+ */
377
+ type SaveResult = {
378
+ outcomes: Array<ConfigEditOutcome>;
379
+ changed: boolean;
380
+ };
381
+ /**
382
+ * What a file read returns for a job: the files that job generated (`output`), or what the output
383
+ * directory held on disk before that job ran (`disk`, only on an agent with a project on disk).
384
+ */
385
+ declare const FileSource: {
386
+ readonly OUTPUT: "output";
387
+ readonly DISK: "disk";
388
+ };
389
+ type FileSource = (typeof FileSource)[keyof typeof FileSource];
390
+ /**
391
+ * Asks the agent to read files of one generation job back.
392
+ */
393
+ type ReadFilesInput = {
394
+ /**
395
+ * The job whose files to read, the only lookup key, so the caller decides whose jobs a reader may
396
+ * see. A job the agent no longer keeps fails with {@link AgentMessage.GENERATION_GONE}.
397
+ */
398
+ jobId: string;
399
+ /**
400
+ * At most {@link MAX_FILES_PER_REQUEST} paths, each checked against what the job's set holds.
401
+ */
402
+ paths: Array<string>;
403
+ /**
404
+ * Which of the job's sets to read, `output` when left out.
405
+ */
406
+ source?: FileSource;
407
+ /**
408
+ * The line to start from (0-based), the `nextCursor` of the previous page. Defaults to 0.
409
+ */
410
+ cursor?: number;
411
+ /**
412
+ * Lines to read per file, at most {@link MAX_PAGE_LINES}. Left out, the whole file.
413
+ */
414
+ limit?: number;
415
+ };
416
+ /**
417
+ * Where a paged read stands for one file: the cursor of the next page, `null` after the last one.
418
+ */
419
+ type FilePage = {
420
+ nextCursor: number | null;
421
+ totalLines: number;
422
+ };
423
+ /**
424
+ * What a file read returns. `pages` is set only for a paged read.
425
+ */
426
+ type ReadFilesResult = {
427
+ files: Record<string, string>;
428
+ pages?: Record<string, FilePage>;
429
+ };
430
+ /**
431
+ * Asks for one page of a file's line diff between two kept sets, so a large file never leaves the agent whole.
432
+ * `jobId`'s `output` is the newer side, `base` the older one. `cursor` and `limit` page the patch lines.
433
+ */
434
+ type ReadDiffInput = {
435
+ jobId: string;
436
+ path: string;
437
+ base: {
438
+ jobId: string;
439
+ source: FileSource;
440
+ };
441
+ cursor?: number;
442
+ limit: number;
443
+ };
444
+ /**
445
+ * One hunk of a diff page, with its `@@` header. Pages hold whole hunks, and only a hunk longer than a page is
446
+ * split: its parts keep `index` and the header.
447
+ */
448
+ type DiffHunk = {
449
+ index: number;
450
+ oldStart: number;
451
+ oldLines: number;
452
+ newStart: number;
453
+ newLines: number;
454
+ lines: Array<string>;
455
+ };
456
+ /**
457
+ * The size of the whole diff, sent with every page, so a viewer can summarize it before reading every page.
458
+ */
459
+ type DiffStats = {
460
+ additions: number;
461
+ deletions: number;
462
+ hunks: number;
463
+ /**
464
+ * Patch lines in all hunks, the range `cursor` pages through.
465
+ */
466
+ lines: number;
467
+ /**
468
+ * True when part of the diff ran out of time and shows as one block that replaces those lines.
469
+ */
470
+ coarse: boolean;
471
+ };
472
+ /**
473
+ * One page of a diff. `hasBase` is false, and the page empty, when the base set does not hold the path.
474
+ */
475
+ type ReadDiffResult = {
476
+ hunks: Array<DiffHunk>;
477
+ nextCursor: number | null;
478
+ hasBase: boolean;
479
+ stats: DiffStats;
480
+ };
481
+ /**
482
+ * Asks for the Kubb AST one job parsed its spec into. A job the agent no longer keeps fails with {@link AgentMessage.GENERATION_GONE}.
483
+ */
484
+ type ReadInputInput = {
485
+ jobId: string;
486
+ };
487
+ /**
488
+ * The job's `InputNode`, as JSON. A ref schema names its target, which `input.schemas` holds, without a copy.
489
+ */
490
+ type ReadInputResult = {
491
+ input: InputNode;
492
+ };
493
+ /**
494
+ * Why the agent refuses a request. Studio matches on these to answer with the right status.
495
+ */
496
+ declare const AgentMessage: {
497
+ /**
498
+ * A read for a job whose files the agent no longer keeps.
499
+ */
500
+ readonly GENERATION_GONE: "The files of this generation are no longer kept on the agent, run the generation again";
501
+ readonly READ_NOT_ALLOWED: "The agent was not granted permission to read generated files";
502
+ /**
503
+ * Reading the parsed spec is its own permission.
504
+ */
505
+ readonly READ_AST_NOT_ALLOWED: "The agent was not granted permission to read the parsed spec";
506
+ readonly NO_INPUT: "This job kept no API input";
507
+ };
508
+ type AgentMessage = (typeof AgentMessage)[keyof typeof AgentMessage];
509
+ /**
510
+ * A generation in flight. Cap'n Web keeps the three calls pointed at the same run, so a caller can
511
+ * read `events()` while `result()` is still pending and `cancel()` stops it early.
512
+ */
513
+ type GenerationRun = {
514
+ events: () => Promise<ReadableStream<GenerationEvent>>;
515
+ result: () => Promise<GenerateResult>;
516
+ cancel: () => Promise<void>;
517
+ };
518
+ /**
519
+ * What Studio knows about the agent on the other end of a socket. Studio passes it with every
520
+ * {@link AgentApi.connect} call, so it stays the authority on whether the agent is a sandbox.
521
+ */
522
+ type AgentConnectInfo = {
523
+ /**
524
+ * A shared `sandbox` or `global` agent. It keeps generations in memory, runs each job in a
525
+ * temporary root, generates from the spec Studio sends, and never writes to disk or edits config.
526
+ */
527
+ sandbox: boolean;
528
+ agentSlug: string;
529
+ /**
530
+ * Absent for a sandbox or global agent, which belongs to no organization.
531
+ */
532
+ organizationSlug?: string;
533
+ studioVersion: string;
534
+ };
535
+ /**
536
+ * Operations Studio invokes on an agent over its socket.
537
+ */
538
+ type AgentApi = {
539
+ /**
540
+ * The first call on every socket, and again whenever Studio needs the current config.
541
+ */
542
+ connect: (info: AgentConnectInfo) => Promise<ConnectMessagePayload>;
543
+ startGeneration: (input: GenerateInput) => GenerationRun;
544
+ saveConfig: (input: SaveConfigInput) => Promise<SaveResult>;
545
+ readFiles: (input: ReadFilesInput) => Promise<ReadFilesResult>;
546
+ /**
547
+ * Refused unless the agent was granted `allowRead`, like {@link AgentApi.readFiles}.
548
+ */
549
+ readInput: (input: ReadInputInput) => Promise<ReadInputResult>;
550
+ /**
551
+ * Refused unless the agent was granted `allowRead`, like {@link AgentApi.readFiles}.
552
+ */
553
+ readDiff: (input: ReadDiffInput) => Promise<ReadDiffResult>;
554
+ };
555
+ /**
556
+ * Operations an agent invokes on Studio over its socket.
557
+ */
558
+ type StudioApi = {
559
+ /**
560
+ * Keeps the connection alive. A ping that does not settle in time makes the agent reconnect.
561
+ */
562
+ ping: () => Promise<void>;
563
+ };
564
+ /**
565
+ * Close codes Studio sends when it ends an agent socket on purpose. `UNAUTHORIZED` means the token
566
+ * was refused, so pair again. `SUPERSEDED` and `INCOMPATIBLE` mean stop. Any other code, `1011`
567
+ * included, is an ordinary drop and the agent reconnects.
568
+ */
569
+ declare const AgentCloseCode: {
570
+ readonly UNAUTHORIZED: 4001;
571
+ readonly SUPERSEDED: 4002;
572
+ readonly INCOMPATIBLE: 4003;
573
+ };
574
+ declare const AGENT_SOCKET_PATH = "/api/agent/socket";
575
+ /**
576
+ * Optional header naming the process a socket belongs to, for agents that run several processes.
577
+ */
578
+ declare const AGENT_INSTANCE_HEADER = "x-kubb-instance-id";
579
+ /**
580
+ * How many files a single `readFiles` request may ask for at once.
581
+ */
582
+ declare const MAX_FILES_PER_REQUEST = 50;
583
+ /** Most lines one page may ask for. */
584
+ declare const MAX_PAGE_LINES = 2000;
585
+ declare const MAX_SNAPSHOT_BYTES: number;
586
+ /**
587
+ * Connection payload returned by {@link AgentApi.connect}. Carries only what Studio renders, with
588
+ * everything about the config under one key.
589
+ */
590
+ type ConnectMessagePayload = {
591
+ /**
592
+ * Always sent, so a mismatch is visible on both sides: Studio badges the connection with these
593
+ * and the host prints them.
594
+ */
595
+ versions: {
596
+ /**
597
+ * The version of the `@kubb/studio` runtime the agent runs.
598
+ */
599
+ kubb: string;
600
+ /**
601
+ * The version of the host itself (the `kubb.agent` package or the `kubb` CLI).
602
+ */
603
+ agent: string;
604
+ };
605
+ /**
606
+ * The agent's project root. This is the workspace that generation runs against.
607
+ */
608
+ root: string;
609
+ /**
610
+ * The baseline every generation starts from.
611
+ */
612
+ config: {
613
+ /**
614
+ * The config path as the host gave it, relative to `root` unless absolute.
615
+ */
616
+ path: string;
617
+ /**
618
+ * What the agent read out of the config file itself, so Studio can render the plugin editor
619
+ * against the real file. Absent when the agent could not read it, or was not granted
620
+ * `allowConfigEdit`.
621
+ */
622
+ file?: ConfigFileView;
623
+ /**
624
+ * Plugins the config registers, with a JSON copy of their options: anything JSON cannot hold,
625
+ * such as a function, is left out. A plugin defined in the project rather than installed as a
626
+ * `@kubb/plugin-*` package keeps its own `name`.
627
+ */
628
+ plugins?: Array<{
629
+ name: string;
630
+ options?: object;
631
+ }>;
632
+ /**
633
+ * The adapter and the parsers the config registers, named like `plugins` and with the same JSON
634
+ * copy of their options, so Studio can render their manifest options.
635
+ */
636
+ adapter?: {
637
+ name: string;
638
+ options?: object;
639
+ };
640
+ parsers?: Array<{
641
+ name: string;
642
+ options?: object;
643
+ }>;
644
+ /** Installed packages that ship a `kubb-extension.json`, including plugins the config does not use yet. */
645
+ extensions?: Array<ExtensionEntry>;
646
+ };
647
+ permissions: AgentPermissions;
648
+ };
649
+ /** An installed extension package and the manifest it ships. */
650
+ type ExtensionEntry = {
651
+ package: string;
652
+ version: string;
653
+ manifest: ExtensionManifest;
654
+ };
655
+ /** Installed extension packages by package name, the only ones Studio may import besides `@kubb/plugin-*`. */
656
+ type InstalledExtensions = ReadonlyMap<string, ExtensionEntry>;
657
+ /**
658
+ * What an agent may do in the project it serves. Every one is off unless the host granted it, and
659
+ * a sandbox narrows them further.
660
+ */
661
+ type AgentPermissions = {
662
+ /**
663
+ * Whether the agent writes generated files to disk. Always false for a sandbox.
664
+ */
665
+ allowWrite: boolean;
666
+ /**
667
+ * Whether the agent runs the formatter, the linter, and `output.postGenerate` as child
668
+ * processes after a generation.
669
+ */
670
+ allowExec: boolean;
671
+ /**
672
+ * Whether the agent may change plugin options in the user's `kubb.config.ts`. Separate from
673
+ * `allowWrite`, which covers generated output: this one edits a hand-authored source file.
674
+ */
675
+ allowConfigEdit: boolean;
676
+ /**
677
+ * Whether the agent hands back file source in response to `readFiles`. Always true for a
678
+ * sandbox.
679
+ */
680
+ allowRead: boolean;
681
+ /**
682
+ * Whether the agent hands back the parsed spec (the Kubb AST) in response to `readInput`.
683
+ * Separate from `allowRead`, which covers generated files. Always true for a sandbox.
684
+ */
685
+ allowReadAst: boolean;
686
+ };
687
+ /**
688
+ * The keys of {@link AgentPermissions}, such as the permission a refused request names.
689
+ */
690
+ declare const AgentPermission: {
691
+ readonly READ: "allowRead";
692
+ readonly READ_AST: "allowReadAst";
693
+ readonly WRITE: "allowWrite";
694
+ readonly CONFIG_EDIT: "allowConfigEdit";
695
+ readonly EXEC: "allowExec";
696
+ };
697
+ type AgentPermission = (typeof AgentPermission)[keyof typeof AgentPermission];
698
+ /**
699
+ * Metadata part of `POST /api/snapshots`. The `tarball` part carries the packed package.
700
+ */
701
+ type SnapshotUploadMetadata = {
702
+ /**
703
+ * Stable CI identity, such as `gh:<repoId>:<pr>`. Snapshots with the same `id` share one CI agent.
704
+ */
705
+ id: string;
706
+ name: string;
707
+ packageName: string;
708
+ version: string;
709
+ /**
710
+ * The commit the snapshot is built from, so the next one can name it as its base.
711
+ */
712
+ commit?: string;
713
+ /**
714
+ * The `id` of another CI agent, such as the base branch's, to also compare with.
715
+ */
716
+ baseId?: string;
717
+ /**
718
+ * Content fingerprint per generated file, keyed by path relative to the project root.
719
+ */
720
+ hashes: Record<string, string>;
721
+ peerDependencies: Record<string, string>;
722
+ };
723
+ /**
724
+ * How a snapshot's files differ from an earlier snapshot of the same package.
725
+ */
726
+ type SnapshotChanges = {
727
+ /**
728
+ * The snapshot these changes are measured against, `null` when there is none to compare with.
729
+ */
730
+ base: {
731
+ id: string;
732
+ version: string | null;
733
+ commit?: string;
734
+ createdAt: string;
735
+ } | null;
736
+ added: Array<string>;
737
+ changed: Array<string>;
738
+ removed: Array<string>;
739
+ };
740
+ /**
741
+ * {@link SnapshotChanges} against another CI agent. `baseFound` is `false` when Studio has no CI
742
+ * agent with that id yet, and `true` when it has one without a snapshot of this package.
743
+ */
744
+ type BranchSnapshotChanges = SnapshotChanges & {
745
+ baseFound: boolean;
746
+ };
747
+ /**
748
+ * Response body of `POST /api/snapshots`: `{ snapshot: PublishedSnapshot }`.
749
+ */
750
+ type PublishedSnapshot = {
751
+ id: string;
752
+ name: string | null;
753
+ version: string | null;
754
+ integrity: string | null;
755
+ agent: {
756
+ id: string;
757
+ name: string;
758
+ slug: string | null;
759
+ };
760
+ /**
761
+ * Readable download path, often `/packages/{agentSlug}/{name}.tgz`.
762
+ */
763
+ url: string;
764
+ snapshotIdUrl: string;
765
+ createdAt: string;
766
+ expiresAt: string;
767
+ /**
768
+ * What changed since the previous snapshot of this package on the same CI agent.
769
+ */
770
+ changes?: SnapshotChanges;
771
+ /**
772
+ * What differs from the latest snapshot of the CI agent `baseId` names. Absent without a base.
773
+ */
774
+ branchChanges?: BranchSnapshotChanges;
775
+ };
776
+ //#endregion
777
+ export { MAX_PAGE_LINES as A, ReadInputResult as B, GenerationEvent as C, InstalledExtensions as D, GenerationRun as E, ReadDiffInput as F, StudioApi as G, SaveResult as H, ReadDiffResult as I, generationEventTypes as K, ReadFilesInput as L, OptionValue as M, PluginView as N, JSONKubbConfig as O, PublishedSnapshot as P, ReadFilesResult as R, GenerateResult as S, GenerationEventType as T, SnapshotChanges as U, SaveConfigInput as V, SnapshotUploadMetadata as W, DiffStats as _, AgentConnectInfo as a, FileSource as b, AgentPermissions as c, ConfigEditOutcome as d, ConfigFileView as f, DiffHunk as g, ConnectMessagePayload as h, AgentCloseCode as i, MAX_SNAPSHOT_BYTES as j, MAX_FILES_PER_REQUEST as k, BranchSnapshotChanges as l, ConfigView as m, AGENT_SOCKET_PATH as n, AgentMessage as o, ConfigRef as p, AgentApi as r, AgentPermission as s, AGENT_INSTANCE_HEADER as t, ConfigEdit as u, ExtensionEntry as v, GenerationEventPayloads as w, GenerateInput as x, FilePage as y, ReadInputInput as z };
778
+ //# sourceMappingURL=protocol-CrMJymjT.d.cts.map