@kb-labs/infra-worker-contracts 0.5.0

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,839 @@
1
+ import { PluginArtifactIds, PluginCommandIds, PluginRouteIds } from './contract.js';
2
+ export { PluginWorkflowIds, pluginContractsManifest } from './contract.js';
3
+ import { z } from 'zod';
4
+ export { CaptureSnapshotInput, CaptureSnapshotInputSchema, CaptureSnapshotOutput, CaptureSnapshotOutputSchema, PrepareInfraInput, PrepareInfraInputSchema, PrepareInfraOutput, PrepareInfraOutputSchema, RestoreSnapshotInput, RestoreSnapshotInputSchema, RestoreSnapshotOutput, RestoreSnapshotOutputSchema } from './schema.js';
5
+
6
+ /**
7
+ * Type-safe helper functions for contracts
8
+ * @module @kb-labs/plugin-template-contracts/helpers
9
+ */
10
+
11
+ /**
12
+ * Get artifact path pattern by ID (type-safe)
13
+ *
14
+ * @example
15
+ * const path = getArtifactPath('template.hello.greeting');
16
+ * // ✅ Автодополнение работает!
17
+ * // ✅ Проверка на этапе компиляции!
18
+ */
19
+ declare function getArtifactPath<T extends PluginArtifactIds>(id: T): string;
20
+ /**
21
+ * Get artifact metadata by ID (type-safe)
22
+ *
23
+ * @example
24
+ * const artifact = getArtifact('template.hello.greeting');
25
+ * // artifact.kind, artifact.description, и т.д.
26
+ */
27
+ declare function getArtifact<T extends PluginArtifactIds>(id: T): {
28
+ readonly 'infra.prepare.result': {
29
+ readonly id: "infra.prepare.result";
30
+ readonly kind: "json";
31
+ readonly description: "Result payload for infra preparation command.";
32
+ readonly pathPattern: "artifacts/infra/prepare/result.json";
33
+ readonly mediaType: "application/json";
34
+ readonly schemaRef: "@kb-labs/infra-worker-contracts/schema#PrepareInfraOutput";
35
+ readonly example: {
36
+ readonly summary: "Infra prepare output";
37
+ readonly payload: {
38
+ readonly workspaceId: "ws_123";
39
+ readonly environmentId: "env_456";
40
+ readonly snapshotId: "snap_789";
41
+ };
42
+ };
43
+ };
44
+ }[T];
45
+ /**
46
+ * Check if artifact ID exists in contracts (type-safe)
47
+ *
48
+ * @example
49
+ * if (hasArtifact('template.hello.greeting')) {
50
+ * // ✅ Типизировано!
51
+ * }
52
+ */
53
+ declare function hasArtifact(id: string): id is PluginArtifactIds;
54
+ /**
55
+ * Get command metadata by ID (type-safe)
56
+ *
57
+ * @example
58
+ * const command = getCommand('template:hello');
59
+ * // command.description, command.input, command.output, и т.д.
60
+ */
61
+ declare function getCommand<T extends PluginCommandIds>(id: T): {
62
+ readonly 'infra-worker:prepare': {
63
+ readonly id: "infra-worker:prepare";
64
+ readonly description: "Materialize workspace and optionally provision environment/snapshot.";
65
+ readonly input: {
66
+ readonly ref: "@kb-labs/infra-worker-contracts/schema#PrepareInfraInput";
67
+ readonly format: "zod";
68
+ };
69
+ readonly output: {
70
+ readonly ref: "@kb-labs/infra-worker-contracts/schema#PrepareInfraOutput";
71
+ readonly format: "zod";
72
+ };
73
+ readonly produces: ["infra.prepare.result"];
74
+ readonly examples: ["kb infra-worker prepare --sourceRef repo://main --basePath /workspace/main"];
75
+ };
76
+ readonly 'infra-worker:capture-snapshot': {
77
+ readonly id: "infra-worker:capture-snapshot";
78
+ readonly description: "Capture snapshot for workspace/environment.";
79
+ readonly input: {
80
+ readonly ref: "@kb-labs/infra-worker-contracts/schema#CaptureSnapshotInput";
81
+ readonly format: "zod";
82
+ };
83
+ readonly output: {
84
+ readonly ref: "@kb-labs/infra-worker-contracts/schema#CaptureSnapshotOutput";
85
+ readonly format: "zod";
86
+ };
87
+ readonly produces: [];
88
+ readonly examples: ["kb infra-worker capture-snapshot --workspaceId ws_123 --namespace runs/main"];
89
+ };
90
+ readonly 'infra-worker:restore-snapshot': {
91
+ readonly id: "infra-worker:restore-snapshot";
92
+ readonly description: "Restore snapshot to workspace/environment.";
93
+ readonly input: {
94
+ readonly ref: "@kb-labs/infra-worker-contracts/schema#RestoreSnapshotInput";
95
+ readonly format: "zod";
96
+ };
97
+ readonly output: {
98
+ readonly ref: "@kb-labs/infra-worker-contracts/schema#RestoreSnapshotOutput";
99
+ readonly format: "zod";
100
+ };
101
+ readonly produces: [];
102
+ readonly examples: ["kb infra-worker restore-snapshot --snapshotId snap_789 --workspaceId ws_123"];
103
+ };
104
+ }[T];
105
+ /**
106
+ * Check if command ID exists in contracts (type-safe)
107
+ *
108
+ * @example
109
+ * if (hasCommand('template:hello')) {
110
+ * // ✅ Типизировано!
111
+ * }
112
+ */
113
+ declare function hasCommand(id: string): id is PluginCommandIds;
114
+ /**
115
+ * Type-safe identity function for command IDs (useful for validation)
116
+ *
117
+ * @example
118
+ * const cmdId = getCommandId('template:hello'); // ✅ Проверка на этапе компиляции!
119
+ */
120
+ declare function getCommandId<T extends PluginCommandIds>(id: T): T;
121
+ /**
122
+ * Type-safe identity function for artifact IDs (useful for validation)
123
+ *
124
+ * @example
125
+ * const artifactId = getArtifactId('template.hello.greeting'); // ✅ Проверка!
126
+ */
127
+ declare function getArtifactId<T extends PluginArtifactIds>(id: T): T;
128
+ /**
129
+ * Get route metadata by ID (type-safe)
130
+ *
131
+ * @example
132
+ * const route = getRoute('template.rest.hello');
133
+ * // route.method, route.path, route.response, и т.д.
134
+ */
135
+ declare function getRoute<T extends PluginRouteIds>(id: T): never;
136
+ /**
137
+ * Check if route ID exists in contracts (type-safe)
138
+ *
139
+ * @example
140
+ * if (hasRoute('template.rest.hello')) {
141
+ * // ✅ Типизировано!
142
+ * }
143
+ */
144
+ declare function hasRoute(id: string): id is PluginRouteIds;
145
+ /**
146
+ * Type-safe identity function for route IDs (useful for validation)
147
+ *
148
+ * @example
149
+ * const routeId = getRouteId('template.rest.hello'); // ✅ Проверка!
150
+ */
151
+ declare function getRouteId<T extends PluginRouteIds>(id: T): T;
152
+
153
+ declare const pluginContractsSchema: z.ZodObject<{
154
+ schema: z.ZodLiteral<"kb.plugin.contracts/1">;
155
+ pluginId: z.ZodString;
156
+ contractsVersion: z.ZodString;
157
+ artifacts: z.ZodRecord<z.ZodString, z.ZodObject<{
158
+ id: z.ZodString;
159
+ kind: z.ZodEnum<["file", "json", "markdown", "binary", "dir", "log"]>;
160
+ description: z.ZodOptional<z.ZodString>;
161
+ pathPattern: z.ZodOptional<z.ZodString>;
162
+ mediaType: z.ZodOptional<z.ZodString>;
163
+ schemaRef: z.ZodOptional<z.ZodString>;
164
+ example: z.ZodOptional<z.ZodObject<{
165
+ summary: z.ZodOptional<z.ZodString>;
166
+ payload: z.ZodOptional<z.ZodUnknown>;
167
+ }, "strip", z.ZodTypeAny, {
168
+ summary?: string | undefined;
169
+ payload?: unknown;
170
+ }, {
171
+ summary?: string | undefined;
172
+ payload?: unknown;
173
+ }>>;
174
+ }, "strip", z.ZodTypeAny, {
175
+ id: string;
176
+ kind: "file" | "json" | "markdown" | "binary" | "dir" | "log";
177
+ description?: string | undefined;
178
+ pathPattern?: string | undefined;
179
+ mediaType?: string | undefined;
180
+ schemaRef?: string | undefined;
181
+ example?: {
182
+ summary?: string | undefined;
183
+ payload?: unknown;
184
+ } | undefined;
185
+ }, {
186
+ id: string;
187
+ kind: "file" | "json" | "markdown" | "binary" | "dir" | "log";
188
+ description?: string | undefined;
189
+ pathPattern?: string | undefined;
190
+ mediaType?: string | undefined;
191
+ schemaRef?: string | undefined;
192
+ example?: {
193
+ summary?: string | undefined;
194
+ payload?: unknown;
195
+ } | undefined;
196
+ }>>;
197
+ commands: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
198
+ id: z.ZodString;
199
+ description: z.ZodOptional<z.ZodString>;
200
+ input: z.ZodOptional<z.ZodObject<{
201
+ ref: z.ZodString;
202
+ format: z.ZodOptional<z.ZodEnum<["zod", "json-schema", "openapi"]>>;
203
+ description: z.ZodOptional<z.ZodString>;
204
+ }, "strip", z.ZodTypeAny, {
205
+ ref: string;
206
+ format?: "zod" | "json-schema" | "openapi" | undefined;
207
+ description?: string | undefined;
208
+ }, {
209
+ ref: string;
210
+ format?: "zod" | "json-schema" | "openapi" | undefined;
211
+ description?: string | undefined;
212
+ }>>;
213
+ output: z.ZodOptional<z.ZodObject<{
214
+ ref: z.ZodString;
215
+ format: z.ZodOptional<z.ZodEnum<["zod", "json-schema", "openapi"]>>;
216
+ description: z.ZodOptional<z.ZodString>;
217
+ }, "strip", z.ZodTypeAny, {
218
+ ref: string;
219
+ format?: "zod" | "json-schema" | "openapi" | undefined;
220
+ description?: string | undefined;
221
+ }, {
222
+ ref: string;
223
+ format?: "zod" | "json-schema" | "openapi" | undefined;
224
+ description?: string | undefined;
225
+ }>>;
226
+ produces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
227
+ consumes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
228
+ examples: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
229
+ }, "strip", z.ZodTypeAny, {
230
+ id: string;
231
+ description?: string | undefined;
232
+ produces?: string[] | undefined;
233
+ consumes?: string[] | undefined;
234
+ input?: {
235
+ ref: string;
236
+ format?: "zod" | "json-schema" | "openapi" | undefined;
237
+ description?: string | undefined;
238
+ } | undefined;
239
+ output?: {
240
+ ref: string;
241
+ format?: "zod" | "json-schema" | "openapi" | undefined;
242
+ description?: string | undefined;
243
+ } | undefined;
244
+ examples?: string[] | undefined;
245
+ }, {
246
+ id: string;
247
+ description?: string | undefined;
248
+ produces?: string[] | undefined;
249
+ consumes?: string[] | undefined;
250
+ input?: {
251
+ ref: string;
252
+ format?: "zod" | "json-schema" | "openapi" | undefined;
253
+ description?: string | undefined;
254
+ } | undefined;
255
+ output?: {
256
+ ref: string;
257
+ format?: "zod" | "json-schema" | "openapi" | undefined;
258
+ description?: string | undefined;
259
+ } | undefined;
260
+ examples?: string[] | undefined;
261
+ }>>>;
262
+ workflows: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
263
+ id: z.ZodString;
264
+ description: z.ZodOptional<z.ZodString>;
265
+ consumes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
266
+ produces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
267
+ steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
268
+ id: z.ZodString;
269
+ description: z.ZodOptional<z.ZodString>;
270
+ commandId: z.ZodOptional<z.ZodString>;
271
+ consumes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
272
+ produces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
273
+ }, "strip", z.ZodTypeAny, {
274
+ id: string;
275
+ description?: string | undefined;
276
+ produces?: string[] | undefined;
277
+ consumes?: string[] | undefined;
278
+ commandId?: string | undefined;
279
+ }, {
280
+ id: string;
281
+ description?: string | undefined;
282
+ produces?: string[] | undefined;
283
+ consumes?: string[] | undefined;
284
+ commandId?: string | undefined;
285
+ }>, "many">>;
286
+ }, "strip", z.ZodTypeAny, {
287
+ id: string;
288
+ description?: string | undefined;
289
+ produces?: string[] | undefined;
290
+ consumes?: string[] | undefined;
291
+ steps?: {
292
+ id: string;
293
+ description?: string | undefined;
294
+ produces?: string[] | undefined;
295
+ consumes?: string[] | undefined;
296
+ commandId?: string | undefined;
297
+ }[] | undefined;
298
+ }, {
299
+ id: string;
300
+ description?: string | undefined;
301
+ produces?: string[] | undefined;
302
+ consumes?: string[] | undefined;
303
+ steps?: {
304
+ id: string;
305
+ description?: string | undefined;
306
+ produces?: string[] | undefined;
307
+ consumes?: string[] | undefined;
308
+ commandId?: string | undefined;
309
+ }[] | undefined;
310
+ }>>>;
311
+ api: z.ZodOptional<z.ZodObject<{
312
+ rest: z.ZodOptional<z.ZodObject<{
313
+ basePath: z.ZodString;
314
+ routes: z.ZodRecord<z.ZodString, z.ZodObject<{
315
+ id: z.ZodString;
316
+ method: z.ZodString;
317
+ path: z.ZodString;
318
+ description: z.ZodOptional<z.ZodString>;
319
+ request: z.ZodOptional<z.ZodObject<{
320
+ ref: z.ZodString;
321
+ format: z.ZodOptional<z.ZodEnum<["zod", "json-schema", "openapi"]>>;
322
+ description: z.ZodOptional<z.ZodString>;
323
+ }, "strip", z.ZodTypeAny, {
324
+ ref: string;
325
+ format?: "zod" | "json-schema" | "openapi" | undefined;
326
+ description?: string | undefined;
327
+ }, {
328
+ ref: string;
329
+ format?: "zod" | "json-schema" | "openapi" | undefined;
330
+ description?: string | undefined;
331
+ }>>;
332
+ response: z.ZodOptional<z.ZodObject<{
333
+ ref: z.ZodString;
334
+ format: z.ZodOptional<z.ZodEnum<["zod", "json-schema", "openapi"]>>;
335
+ description: z.ZodOptional<z.ZodString>;
336
+ }, "strip", z.ZodTypeAny, {
337
+ ref: string;
338
+ format?: "zod" | "json-schema" | "openapi" | undefined;
339
+ description?: string | undefined;
340
+ }, {
341
+ ref: string;
342
+ format?: "zod" | "json-schema" | "openapi" | undefined;
343
+ description?: string | undefined;
344
+ }>>;
345
+ produces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
346
+ consumes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
347
+ }, "strip", z.ZodTypeAny, {
348
+ path: string;
349
+ id: string;
350
+ method: string;
351
+ description?: string | undefined;
352
+ request?: {
353
+ ref: string;
354
+ format?: "zod" | "json-schema" | "openapi" | undefined;
355
+ description?: string | undefined;
356
+ } | undefined;
357
+ response?: {
358
+ ref: string;
359
+ format?: "zod" | "json-schema" | "openapi" | undefined;
360
+ description?: string | undefined;
361
+ } | undefined;
362
+ produces?: string[] | undefined;
363
+ consumes?: string[] | undefined;
364
+ }, {
365
+ path: string;
366
+ id: string;
367
+ method: string;
368
+ description?: string | undefined;
369
+ request?: {
370
+ ref: string;
371
+ format?: "zod" | "json-schema" | "openapi" | undefined;
372
+ description?: string | undefined;
373
+ } | undefined;
374
+ response?: {
375
+ ref: string;
376
+ format?: "zod" | "json-schema" | "openapi" | undefined;
377
+ description?: string | undefined;
378
+ } | undefined;
379
+ produces?: string[] | undefined;
380
+ consumes?: string[] | undefined;
381
+ }>>;
382
+ }, "strip", z.ZodTypeAny, {
383
+ basePath: string;
384
+ routes: Record<string, {
385
+ path: string;
386
+ id: string;
387
+ method: string;
388
+ description?: string | undefined;
389
+ request?: {
390
+ ref: string;
391
+ format?: "zod" | "json-schema" | "openapi" | undefined;
392
+ description?: string | undefined;
393
+ } | undefined;
394
+ response?: {
395
+ ref: string;
396
+ format?: "zod" | "json-schema" | "openapi" | undefined;
397
+ description?: string | undefined;
398
+ } | undefined;
399
+ produces?: string[] | undefined;
400
+ consumes?: string[] | undefined;
401
+ }>;
402
+ }, {
403
+ basePath: string;
404
+ routes: Record<string, {
405
+ path: string;
406
+ id: string;
407
+ method: string;
408
+ description?: string | undefined;
409
+ request?: {
410
+ ref: string;
411
+ format?: "zod" | "json-schema" | "openapi" | undefined;
412
+ description?: string | undefined;
413
+ } | undefined;
414
+ response?: {
415
+ ref: string;
416
+ format?: "zod" | "json-schema" | "openapi" | undefined;
417
+ description?: string | undefined;
418
+ } | undefined;
419
+ produces?: string[] | undefined;
420
+ consumes?: string[] | undefined;
421
+ }>;
422
+ }>>;
423
+ }, "strip", z.ZodTypeAny, {
424
+ rest?: {
425
+ basePath: string;
426
+ routes: Record<string, {
427
+ path: string;
428
+ id: string;
429
+ method: string;
430
+ description?: string | undefined;
431
+ request?: {
432
+ ref: string;
433
+ format?: "zod" | "json-schema" | "openapi" | undefined;
434
+ description?: string | undefined;
435
+ } | undefined;
436
+ response?: {
437
+ ref: string;
438
+ format?: "zod" | "json-schema" | "openapi" | undefined;
439
+ description?: string | undefined;
440
+ } | undefined;
441
+ produces?: string[] | undefined;
442
+ consumes?: string[] | undefined;
443
+ }>;
444
+ } | undefined;
445
+ }, {
446
+ rest?: {
447
+ basePath: string;
448
+ routes: Record<string, {
449
+ path: string;
450
+ id: string;
451
+ method: string;
452
+ description?: string | undefined;
453
+ request?: {
454
+ ref: string;
455
+ format?: "zod" | "json-schema" | "openapi" | undefined;
456
+ description?: string | undefined;
457
+ } | undefined;
458
+ response?: {
459
+ ref: string;
460
+ format?: "zod" | "json-schema" | "openapi" | undefined;
461
+ description?: string | undefined;
462
+ } | undefined;
463
+ produces?: string[] | undefined;
464
+ consumes?: string[] | undefined;
465
+ }>;
466
+ } | undefined;
467
+ }>>;
468
+ }, "strict", z.ZodTypeAny, {
469
+ schema: "kb.plugin.contracts/1";
470
+ pluginId: string;
471
+ contractsVersion: string;
472
+ artifacts: Record<string, {
473
+ id: string;
474
+ kind: "file" | "json" | "markdown" | "binary" | "dir" | "log";
475
+ description?: string | undefined;
476
+ pathPattern?: string | undefined;
477
+ mediaType?: string | undefined;
478
+ schemaRef?: string | undefined;
479
+ example?: {
480
+ summary?: string | undefined;
481
+ payload?: unknown;
482
+ } | undefined;
483
+ }>;
484
+ commands?: Record<string, {
485
+ id: string;
486
+ description?: string | undefined;
487
+ produces?: string[] | undefined;
488
+ consumes?: string[] | undefined;
489
+ input?: {
490
+ ref: string;
491
+ format?: "zod" | "json-schema" | "openapi" | undefined;
492
+ description?: string | undefined;
493
+ } | undefined;
494
+ output?: {
495
+ ref: string;
496
+ format?: "zod" | "json-schema" | "openapi" | undefined;
497
+ description?: string | undefined;
498
+ } | undefined;
499
+ examples?: string[] | undefined;
500
+ }> | undefined;
501
+ workflows?: Record<string, {
502
+ id: string;
503
+ description?: string | undefined;
504
+ produces?: string[] | undefined;
505
+ consumes?: string[] | undefined;
506
+ steps?: {
507
+ id: string;
508
+ description?: string | undefined;
509
+ produces?: string[] | undefined;
510
+ consumes?: string[] | undefined;
511
+ commandId?: string | undefined;
512
+ }[] | undefined;
513
+ }> | undefined;
514
+ api?: {
515
+ rest?: {
516
+ basePath: string;
517
+ routes: Record<string, {
518
+ path: string;
519
+ id: string;
520
+ method: string;
521
+ description?: string | undefined;
522
+ request?: {
523
+ ref: string;
524
+ format?: "zod" | "json-schema" | "openapi" | undefined;
525
+ description?: string | undefined;
526
+ } | undefined;
527
+ response?: {
528
+ ref: string;
529
+ format?: "zod" | "json-schema" | "openapi" | undefined;
530
+ description?: string | undefined;
531
+ } | undefined;
532
+ produces?: string[] | undefined;
533
+ consumes?: string[] | undefined;
534
+ }>;
535
+ } | undefined;
536
+ } | undefined;
537
+ }, {
538
+ schema: "kb.plugin.contracts/1";
539
+ pluginId: string;
540
+ contractsVersion: string;
541
+ artifacts: Record<string, {
542
+ id: string;
543
+ kind: "file" | "json" | "markdown" | "binary" | "dir" | "log";
544
+ description?: string | undefined;
545
+ pathPattern?: string | undefined;
546
+ mediaType?: string | undefined;
547
+ schemaRef?: string | undefined;
548
+ example?: {
549
+ summary?: string | undefined;
550
+ payload?: unknown;
551
+ } | undefined;
552
+ }>;
553
+ commands?: Record<string, {
554
+ id: string;
555
+ description?: string | undefined;
556
+ produces?: string[] | undefined;
557
+ consumes?: string[] | undefined;
558
+ input?: {
559
+ ref: string;
560
+ format?: "zod" | "json-schema" | "openapi" | undefined;
561
+ description?: string | undefined;
562
+ } | undefined;
563
+ output?: {
564
+ ref: string;
565
+ format?: "zod" | "json-schema" | "openapi" | undefined;
566
+ description?: string | undefined;
567
+ } | undefined;
568
+ examples?: string[] | undefined;
569
+ }> | undefined;
570
+ workflows?: Record<string, {
571
+ id: string;
572
+ description?: string | undefined;
573
+ produces?: string[] | undefined;
574
+ consumes?: string[] | undefined;
575
+ steps?: {
576
+ id: string;
577
+ description?: string | undefined;
578
+ produces?: string[] | undefined;
579
+ consumes?: string[] | undefined;
580
+ commandId?: string | undefined;
581
+ }[] | undefined;
582
+ }> | undefined;
583
+ api?: {
584
+ rest?: {
585
+ basePath: string;
586
+ routes: Record<string, {
587
+ path: string;
588
+ id: string;
589
+ method: string;
590
+ description?: string | undefined;
591
+ request?: {
592
+ ref: string;
593
+ format?: "zod" | "json-schema" | "openapi" | undefined;
594
+ description?: string | undefined;
595
+ } | undefined;
596
+ response?: {
597
+ ref: string;
598
+ format?: "zod" | "json-schema" | "openapi" | undefined;
599
+ description?: string | undefined;
600
+ } | undefined;
601
+ produces?: string[] | undefined;
602
+ consumes?: string[] | undefined;
603
+ }>;
604
+ } | undefined;
605
+ } | undefined;
606
+ }>;
607
+ declare function parsePluginContracts(input: unknown): {
608
+ schema: "kb.plugin.contracts/1";
609
+ pluginId: string;
610
+ contractsVersion: string;
611
+ artifacts: Record<string, {
612
+ id: string;
613
+ kind: "file" | "json" | "markdown" | "binary" | "dir" | "log";
614
+ description?: string | undefined;
615
+ pathPattern?: string | undefined;
616
+ mediaType?: string | undefined;
617
+ schemaRef?: string | undefined;
618
+ example?: {
619
+ summary?: string | undefined;
620
+ payload?: unknown;
621
+ } | undefined;
622
+ }>;
623
+ commands?: Record<string, {
624
+ id: string;
625
+ description?: string | undefined;
626
+ produces?: string[] | undefined;
627
+ consumes?: string[] | undefined;
628
+ input?: {
629
+ ref: string;
630
+ format?: "zod" | "json-schema" | "openapi" | undefined;
631
+ description?: string | undefined;
632
+ } | undefined;
633
+ output?: {
634
+ ref: string;
635
+ format?: "zod" | "json-schema" | "openapi" | undefined;
636
+ description?: string | undefined;
637
+ } | undefined;
638
+ examples?: string[] | undefined;
639
+ }> | undefined;
640
+ workflows?: Record<string, {
641
+ id: string;
642
+ description?: string | undefined;
643
+ produces?: string[] | undefined;
644
+ consumes?: string[] | undefined;
645
+ steps?: {
646
+ id: string;
647
+ description?: string | undefined;
648
+ produces?: string[] | undefined;
649
+ consumes?: string[] | undefined;
650
+ commandId?: string | undefined;
651
+ }[] | undefined;
652
+ }> | undefined;
653
+ api?: {
654
+ rest?: {
655
+ basePath: string;
656
+ routes: Record<string, {
657
+ path: string;
658
+ id: string;
659
+ method: string;
660
+ description?: string | undefined;
661
+ request?: {
662
+ ref: string;
663
+ format?: "zod" | "json-schema" | "openapi" | undefined;
664
+ description?: string | undefined;
665
+ } | undefined;
666
+ response?: {
667
+ ref: string;
668
+ format?: "zod" | "json-schema" | "openapi" | undefined;
669
+ description?: string | undefined;
670
+ } | undefined;
671
+ produces?: string[] | undefined;
672
+ consumes?: string[] | undefined;
673
+ }>;
674
+ } | undefined;
675
+ } | undefined;
676
+ };
677
+
678
+ declare const contractsSchemaId: "kb.plugin.contracts/1";
679
+ type ContractsSchemaId = typeof contractsSchemaId;
680
+ declare const contractsVersion: "1.0.0";
681
+
682
+ type SchemaFormat = 'zod' | 'json-schema' | 'openapi';
683
+ interface SchemaReference {
684
+ /**
685
+ * Reference to the schema. Can be a URI, npm package export, or local module path.
686
+ */
687
+ ref: string;
688
+ /**
689
+ * Describes the format of the referenced schema.
690
+ */
691
+ format?: SchemaFormat;
692
+ description?: string;
693
+ }
694
+ interface RestRouteContract {
695
+ id: string;
696
+ method: string;
697
+ path: string;
698
+ description?: string;
699
+ request?: SchemaReference;
700
+ response?: SchemaReference;
701
+ produces?: string[];
702
+ consumes?: string[];
703
+ }
704
+ interface RestApiContract {
705
+ basePath: string;
706
+ routes: Record<string, RestRouteContract>;
707
+ }
708
+ interface ApiContract {
709
+ rest?: RestApiContract;
710
+ }
711
+
712
+ type ArtifactKind = 'file' | 'json' | 'markdown' | 'binary' | 'dir' | 'log';
713
+ interface ArtifactExample {
714
+ summary?: string;
715
+ payload?: unknown;
716
+ }
717
+ interface PluginArtifactContract {
718
+ id: string;
719
+ kind: ArtifactKind;
720
+ description?: string;
721
+ /**
722
+ * Relative path or glob pattern describing where the artifact is materialised.
723
+ * Example: "artifacts/template/hello/greeting.json"
724
+ */
725
+ pathPattern?: string;
726
+ /**
727
+ * IANA media type describing the artifact. Example: "application/json".
728
+ */
729
+ mediaType?: string;
730
+ /**
731
+ * Reference to a schema describing the artifact payload. Can be a URI or package export.
732
+ */
733
+ schemaRef?: string;
734
+ /**
735
+ * Optional example payload to help documentation and tooling.
736
+ */
737
+ example?: ArtifactExample;
738
+ }
739
+ type ArtifactContractsMap = Record<string, PluginArtifactContract>;
740
+
741
+ interface CommandContract {
742
+ id: string;
743
+ description?: string;
744
+ input?: SchemaReference;
745
+ output?: SchemaReference;
746
+ produces?: string[];
747
+ consumes?: string[];
748
+ examples?: string[];
749
+ }
750
+ type CommandContractsMap = Record<string, CommandContract>;
751
+
752
+ interface WorkflowStepContract {
753
+ id: string;
754
+ description?: string;
755
+ commandId?: string;
756
+ consumes?: string[];
757
+ produces?: string[];
758
+ }
759
+ interface WorkflowContract {
760
+ id: string;
761
+ description?: string;
762
+ consumes?: string[];
763
+ produces?: string[];
764
+ steps?: WorkflowStepContract[];
765
+ }
766
+ type WorkflowContractsMap = Record<string, WorkflowContract>;
767
+
768
+ /**
769
+ * Plugin Configuration Contract
770
+ *
771
+ * Defines the shape of plugin configuration stored in kb.config.json
772
+ * under plugins.template section.
773
+ *
774
+ * This type is the single source of truth for:
775
+ * - defineSetup (setup handler knows what config to create)
776
+ * - defineCommand (commands can access typed config)
777
+ * - REST handlers (API can access typed config)
778
+ */
779
+ /**
780
+ * Greeting configuration
781
+ */
782
+ interface GreetingConfig {
783
+ /** Path to greeting config file */
784
+ configPath: string;
785
+ /** Default name to greet */
786
+ defaultName: string;
787
+ }
788
+ /**
789
+ * Output configuration
790
+ */
791
+ interface OutputConfig {
792
+ /** Output directory for generated files */
793
+ directory: string;
794
+ }
795
+ /**
796
+ * Plugin configuration stored in kb.config.json
797
+ *
798
+ * @example
799
+ * ```json
800
+ * {
801
+ * "plugins": {
802
+ * "template": {
803
+ * "enabled": true,
804
+ * "greeting": {
805
+ * "configPath": ".kb/template/hello-config.json",
806
+ * "defaultName": "KB Labs"
807
+ * },
808
+ * "output": {
809
+ * "directory": ".kb/template/output"
810
+ * }
811
+ * }
812
+ * }
813
+ * }
814
+ * ```
815
+ */
816
+ interface PluginConfig {
817
+ /** Whether the plugin is enabled */
818
+ enabled: boolean;
819
+ /** Greeting configuration */
820
+ greeting: GreetingConfig;
821
+ /** Output configuration */
822
+ output: OutputConfig;
823
+ }
824
+ /**
825
+ * Default plugin configuration values
826
+ */
827
+ declare const defaultPluginConfig: PluginConfig;
828
+
829
+ interface PluginContracts {
830
+ schema: ContractsSchemaId;
831
+ pluginId: string;
832
+ contractsVersion: string;
833
+ artifacts: ArtifactContractsMap;
834
+ commands?: CommandContractsMap;
835
+ workflows?: WorkflowContractsMap;
836
+ api?: ApiContract;
837
+ }
838
+
839
+ export { type ApiContract, type ArtifactContractsMap, type ArtifactExample, type ArtifactKind, type CommandContract, type CommandContractsMap, type GreetingConfig, type OutputConfig, type PluginArtifactContract, PluginArtifactIds, PluginCommandIds, type PluginConfig, type PluginContracts, PluginRouteIds, type RestApiContract, type RestRouteContract, type SchemaReference, type WorkflowContract, type WorkflowContractsMap, type WorkflowStepContract, contractsSchemaId, contractsVersion, defaultPluginConfig, getArtifact, getArtifactId, getArtifactPath, getCommand, getCommandId, getRoute, getRouteId, hasArtifact, hasCommand, hasRoute, parsePluginContracts, pluginContractsSchema };