@ultrst-armada/kloks 1.0.2 → 1.1.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.
package/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from './packages/state-graph/dist/index.d.ts';
3
3
  export * from './packages/audio-midi/dist/index.d.ts';
4
4
  export * from './packages/services/dist/index.d.ts';
5
5
  export * from './packages/orchestrations/dist/index.d.ts';
6
+ export * from './packages/contracts/dist/index.d.ts';
package/index.js CHANGED
@@ -3,3 +3,4 @@ export * from './packages/state-graph/dist/index.js';
3
3
  export * from './packages/audio-midi/dist/index.js';
4
4
  export * from './packages/services/dist/index.js';
5
5
  export * from './packages/orchestrations/dist/index.js';
6
+ export * from './packages/contracts/dist/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultrst-armada/kloks",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -88,6 +88,11 @@
88
88
  "types": "./packages/orchestrations/dist/index.d.ts",
89
89
  "import": "./packages/orchestrations/dist/index.js",
90
90
  "default": "./packages/orchestrations/dist/index.js"
91
+ },
92
+ "./contracts": {
93
+ "types": "./packages/contracts/dist/index.d.ts",
94
+ "import": "./packages/contracts/dist/index.js",
95
+ "default": "./packages/contracts/dist/index.js"
91
96
  }
92
97
  },
93
98
  "scripts": {
@@ -1,3 +1,11 @@
1
+ import {
2
+ CompositeBackend,
3
+ EndpointGenerator,
4
+ createBackend,
5
+ createCompositeService,
6
+ createLocalService,
7
+ createRemoteService
8
+ } from "./chunk-P4HL4C6V.js";
1
9
  import {
2
10
  CANONICAL_SRKL_URL,
3
11
  SrklClient,
@@ -7,14 +15,6 @@ import {
7
15
  srklListBackblazeBuckets,
8
16
  useSrklServices
9
17
  } from "./chunk-MN54ZIKZ.js";
10
- import {
11
- CompositeBackend,
12
- EndpointGenerator,
13
- createBackend,
14
- createCompositeService,
15
- createLocalService,
16
- createRemoteService
17
- } from "./chunk-P4HL4C6V.js";
18
18
  import "./chunk-LS3HWJBX.js";
19
19
  import {
20
20
  authorizeB2,
@@ -0,0 +1,552 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * @file surface.ts
5
+ * @description Canonical export surface definitions and consumer compatibility validator.
6
+ * Enforces: QwnsrRequiredSurface ⊆ KloksPublicContract
7
+ */
8
+ interface ExportSymbolEntry {
9
+ name: string;
10
+ subpath: string;
11
+ category: 'state-graph' | 'audio-midi' | 'orchestrations' | 'backend' | 'services' | 'functions' | 'contracts';
12
+ hasZodSchema: boolean;
13
+ }
14
+ /**
15
+ * Authoritative Canonical Public Contract Surface for Kloks.
16
+ */
17
+ declare const KLOKS_PUBLIC_SURFACE: ExportSymbolEntry[];
18
+ /**
19
+ * Surface required by Qwnsr consumer according to docs/01_CONTRACT_FOUNDATION.md & docs/03_LIBRARY_CONTRACT_MIGRATION.md.
20
+ */
21
+ declare const QWNSR_REQUIRED_SURFACE: string[];
22
+ interface CompatibilityCheckResult {
23
+ compatible: boolean;
24
+ missingSymbols: string[];
25
+ totalRequired: number;
26
+ totalPresent: number;
27
+ }
28
+ /**
29
+ * Verifies that all symbols in requiredSurface are exported by Kloks.
30
+ * Enforces Invariant: QwnsrRequiredSurface ⊆ KloksPublicContract
31
+ */
32
+ declare function validateConsumerSurfaceCompatibility(requiredSymbols?: string[], publicSurface?: ExportSymbolEntry[]): CompatibilityCheckResult;
33
+
34
+ /**
35
+ * @file schemas.ts
36
+ * @description Runtime Zod Schemas for Kloks Public Contracts and Canonical Models.
37
+ * Enforces: ∀ public runtime boundary: TypeScriptContract ∧ ZodRuntimeContract
38
+ */
39
+
40
+ declare const GraphEntityMetadataSchema: z.ZodObject<{
41
+ id: z.ZodString;
42
+ name: z.ZodString;
43
+ type: z.ZodString;
44
+ archetype: z.ZodString;
45
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
46
+ description: z.ZodOptional<z.ZodString>;
47
+ createdAt: z.ZodOptional<z.ZodNumber>;
48
+ updatedAt: z.ZodOptional<z.ZodNumber>;
49
+ customAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ type?: string;
52
+ id?: string;
53
+ name?: string;
54
+ archetype?: string;
55
+ tags?: string[];
56
+ description?: string;
57
+ createdAt?: number;
58
+ updatedAt?: number;
59
+ customAttributes?: Record<string, unknown>;
60
+ }, {
61
+ type?: string;
62
+ id?: string;
63
+ name?: string;
64
+ archetype?: string;
65
+ tags?: string[];
66
+ description?: string;
67
+ createdAt?: number;
68
+ updatedAt?: number;
69
+ customAttributes?: Record<string, unknown>;
70
+ }>;
71
+ type GraphEntityMetadata = z.infer<typeof GraphEntityMetadataSchema>;
72
+ declare const SocketPosition2DSchema: z.ZodObject<{
73
+ x: z.ZodNumber;
74
+ y: z.ZodNumber;
75
+ }, "strip", z.ZodTypeAny, {
76
+ x?: number;
77
+ y?: number;
78
+ }, {
79
+ x?: number;
80
+ y?: number;
81
+ }>;
82
+ type SocketPosition2D = z.infer<typeof SocketPosition2DSchema>;
83
+ declare const SocketDirectionSchema: z.ZodEnum<["input", "output", "bidirectional"]>;
84
+ type SocketDirection = z.infer<typeof SocketDirectionSchema>;
85
+ declare const SocketGeometryConfigSchema: z.ZodObject<{
86
+ radius: z.ZodDefault<z.ZodNumber>;
87
+ hitRadius: z.ZodDefault<z.ZodNumber>;
88
+ snapDistance: z.ZodDefault<z.ZodNumber>;
89
+ direction: z.ZodDefault<z.ZodEnum<["input", "output", "bidirectional"]>>;
90
+ relativeOffset: z.ZodDefault<z.ZodObject<{
91
+ x: z.ZodNumber;
92
+ y: z.ZodNumber;
93
+ }, "strip", z.ZodTypeAny, {
94
+ x?: number;
95
+ y?: number;
96
+ }, {
97
+ x?: number;
98
+ y?: number;
99
+ }>>;
100
+ }, "strip", z.ZodTypeAny, {
101
+ radius?: number;
102
+ hitRadius?: number;
103
+ snapDistance?: number;
104
+ direction?: "input" | "output" | "bidirectional";
105
+ relativeOffset?: {
106
+ x?: number;
107
+ y?: number;
108
+ };
109
+ }, {
110
+ radius?: number;
111
+ hitRadius?: number;
112
+ snapDistance?: number;
113
+ direction?: "input" | "output" | "bidirectional";
114
+ relativeOffset?: {
115
+ x?: number;
116
+ y?: number;
117
+ };
118
+ }>;
119
+ type SocketGeometryConfig = z.infer<typeof SocketGeometryConfigSchema>;
120
+ declare const SocketStyleConfigSchema: z.ZodObject<{
121
+ color: z.ZodString;
122
+ hoverColor: z.ZodOptional<z.ZodString>;
123
+ activeColor: z.ZodOptional<z.ZodString>;
124
+ borderColor: z.ZodOptional<z.ZodString>;
125
+ borderWidth: z.ZodOptional<z.ZodNumber>;
126
+ fillOpacity: z.ZodOptional<z.ZodNumber>;
127
+ }, "strip", z.ZodTypeAny, {
128
+ color?: string;
129
+ hoverColor?: string;
130
+ activeColor?: string;
131
+ borderColor?: string;
132
+ borderWidth?: number;
133
+ fillOpacity?: number;
134
+ }, {
135
+ color?: string;
136
+ hoverColor?: string;
137
+ activeColor?: string;
138
+ borderColor?: string;
139
+ borderWidth?: number;
140
+ fillOpacity?: number;
141
+ }>;
142
+ type SocketStyleConfig = z.infer<typeof SocketStyleConfigSchema>;
143
+ declare const WireEndpoint2DSchema: z.ZodObject<{
144
+ nodeId: z.ZodString;
145
+ socketId: z.ZodString;
146
+ position: z.ZodObject<{
147
+ x: z.ZodNumber;
148
+ y: z.ZodNumber;
149
+ }, "strip", z.ZodTypeAny, {
150
+ x?: number;
151
+ y?: number;
152
+ }, {
153
+ x?: number;
154
+ y?: number;
155
+ }>;
156
+ }, "strip", z.ZodTypeAny, {
157
+ nodeId?: string;
158
+ socketId?: string;
159
+ position?: {
160
+ x?: number;
161
+ y?: number;
162
+ };
163
+ }, {
164
+ nodeId?: string;
165
+ socketId?: string;
166
+ position?: {
167
+ x?: number;
168
+ y?: number;
169
+ };
170
+ }>;
171
+ type WireEndpoint2D = z.infer<typeof WireEndpoint2DSchema>;
172
+ declare const WireCurveStyleSchema: z.ZodEnum<["bezier", "linear", "orthogonal", "stepped"]>;
173
+ type WireCurveStyle = z.infer<typeof WireCurveStyleSchema>;
174
+ declare const WireAnimationConfigSchema: z.ZodObject<{
175
+ animated: z.ZodDefault<z.ZodBoolean>;
176
+ speed: z.ZodDefault<z.ZodNumber>;
177
+ direction: z.ZodDefault<z.ZodEnum<["forward", "reverse"]>>;
178
+ pulseFrequency: z.ZodOptional<z.ZodNumber>;
179
+ }, "strip", z.ZodTypeAny, {
180
+ direction?: "reverse" | "forward";
181
+ animated?: boolean;
182
+ speed?: number;
183
+ pulseFrequency?: number;
184
+ }, {
185
+ direction?: "reverse" | "forward";
186
+ animated?: boolean;
187
+ speed?: number;
188
+ pulseFrequency?: number;
189
+ }>;
190
+ type WireAnimationConfig = z.infer<typeof WireAnimationConfigSchema>;
191
+ declare const WireVisualConfigSchema: z.ZodObject<{
192
+ strokeColor: z.ZodString;
193
+ strokeWidth: z.ZodDefault<z.ZodNumber>;
194
+ strokeDashArray: z.ZodOptional<z.ZodString>;
195
+ curveStyle: z.ZodDefault<z.ZodEnum<["bezier", "linear", "orthogonal", "stepped"]>>;
196
+ curvature: z.ZodDefault<z.ZodNumber>;
197
+ opacity: z.ZodDefault<z.ZodNumber>;
198
+ glow: z.ZodDefault<z.ZodBoolean>;
199
+ glowColor: z.ZodOptional<z.ZodString>;
200
+ }, "strip", z.ZodTypeAny, {
201
+ strokeColor?: string;
202
+ strokeWidth?: number;
203
+ strokeDashArray?: string;
204
+ curveStyle?: "bezier" | "linear" | "orthogonal" | "stepped";
205
+ curvature?: number;
206
+ opacity?: number;
207
+ glow?: boolean;
208
+ glowColor?: string;
209
+ }, {
210
+ strokeColor?: string;
211
+ strokeWidth?: number;
212
+ strokeDashArray?: string;
213
+ curveStyle?: "bezier" | "linear" | "orthogonal" | "stepped";
214
+ curvature?: number;
215
+ opacity?: number;
216
+ glow?: boolean;
217
+ glowColor?: string;
218
+ }>;
219
+ type WireVisualConfig = z.infer<typeof WireVisualConfigSchema>;
220
+ declare const NodeDimensions2DSchema: z.ZodObject<{
221
+ width: z.ZodNumber;
222
+ height: z.ZodNumber;
223
+ minWidth: z.ZodOptional<z.ZodNumber>;
224
+ minHeight: z.ZodOptional<z.ZodNumber>;
225
+ maxWidth: z.ZodOptional<z.ZodNumber>;
226
+ maxHeight: z.ZodOptional<z.ZodNumber>;
227
+ }, "strip", z.ZodTypeAny, {
228
+ width?: number;
229
+ height?: number;
230
+ minWidth?: number;
231
+ minHeight?: number;
232
+ maxWidth?: number;
233
+ maxHeight?: number;
234
+ }, {
235
+ width?: number;
236
+ height?: number;
237
+ minWidth?: number;
238
+ minHeight?: number;
239
+ maxWidth?: number;
240
+ maxHeight?: number;
241
+ }>;
242
+ type NodeDimensions2D = z.infer<typeof NodeDimensions2DSchema>;
243
+ declare const NodeScreenRect2DSchema: z.ZodObject<{
244
+ x: z.ZodNumber;
245
+ y: z.ZodNumber;
246
+ width: z.ZodNumber;
247
+ height: z.ZodNumber;
248
+ }, "strip", z.ZodTypeAny, {
249
+ x?: number;
250
+ y?: number;
251
+ width?: number;
252
+ height?: number;
253
+ }, {
254
+ x?: number;
255
+ y?: number;
256
+ width?: number;
257
+ height?: number;
258
+ }>;
259
+ type NodeScreenRect2D = z.infer<typeof NodeScreenRect2DSchema>;
260
+ declare const NodeHeaderStyleSchema: z.ZodObject<{
261
+ backgroundColor: z.ZodOptional<z.ZodString>;
262
+ titleColor: z.ZodOptional<z.ZodString>;
263
+ iconColor: z.ZodOptional<z.ZodString>;
264
+ badgeColor: z.ZodOptional<z.ZodString>;
265
+ }, "strip", z.ZodTypeAny, {
266
+ backgroundColor?: string;
267
+ titleColor?: string;
268
+ iconColor?: string;
269
+ badgeColor?: string;
270
+ }, {
271
+ backgroundColor?: string;
272
+ titleColor?: string;
273
+ iconColor?: string;
274
+ badgeColor?: string;
275
+ }>;
276
+ type NodeHeaderStyle = z.infer<typeof NodeHeaderStyleSchema>;
277
+ declare const AudioBusConfigSchema: z.ZodObject<{
278
+ channelCount: z.ZodDefault<z.ZodNumber>;
279
+ sampleRate: z.ZodDefault<z.ZodNumber>;
280
+ bufferSize: z.ZodDefault<z.ZodNumber>;
281
+ latencyHint: z.ZodDefault<z.ZodEnum<["interactive", "balanced", "playback"]>>;
282
+ }, "strip", z.ZodTypeAny, {
283
+ channelCount?: number;
284
+ sampleRate?: number;
285
+ bufferSize?: number;
286
+ latencyHint?: "interactive" | "balanced" | "playback";
287
+ }, {
288
+ channelCount?: number;
289
+ sampleRate?: number;
290
+ bufferSize?: number;
291
+ latencyHint?: "interactive" | "balanced" | "playback";
292
+ }>;
293
+ type AudioBusConfig = z.infer<typeof AudioBusConfigSchema>;
294
+ declare const AudioHardwareStateSchema: z.ZodObject<{
295
+ contextState: z.ZodEnum<["suspended", "running", "closed", "uninitialized"]>;
296
+ sampleRate: z.ZodNumber;
297
+ inputChannels: z.ZodNumber;
298
+ outputChannels: z.ZodNumber;
299
+ activeInputDeviceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
300
+ activeOutputDeviceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
301
+ }, "strip", z.ZodTypeAny, {
302
+ sampleRate?: number;
303
+ contextState?: "suspended" | "running" | "closed" | "uninitialized";
304
+ inputChannels?: number;
305
+ outputChannels?: number;
306
+ activeInputDeviceId?: string;
307
+ activeOutputDeviceId?: string;
308
+ }, {
309
+ sampleRate?: number;
310
+ contextState?: "suspended" | "running" | "closed" | "uninitialized";
311
+ inputChannels?: number;
312
+ outputChannels?: number;
313
+ activeInputDeviceId?: string;
314
+ activeOutputDeviceId?: string;
315
+ }>;
316
+ type AudioHardwareState = z.infer<typeof AudioHardwareStateSchema>;
317
+ declare const MidiCommandTypeSchema: z.ZodEnum<["NOTE_ON", "NOTE_OFF", "CONTROL_CHANGE", "PITCH_BEND", "PROGRAM_CHANGE", "AFTERTOUCH", "POLY_PRESSURE", "CLOCK", "START", "CONTINUE", "STOP", "ACTIVE_SENSING", "SYSTEM_RESET"]>;
318
+ type MidiCommandType = z.infer<typeof MidiCommandTypeSchema>;
319
+ declare const MidiEventPayloadSchema: z.ZodObject<{
320
+ command: z.ZodEnum<["NOTE_ON", "NOTE_OFF", "CONTROL_CHANGE", "PITCH_BEND", "PROGRAM_CHANGE", "AFTERTOUCH", "POLY_PRESSURE", "CLOCK", "START", "CONTINUE", "STOP", "ACTIVE_SENSING", "SYSTEM_RESET"]>;
321
+ channel: z.ZodDefault<z.ZodNumber>;
322
+ note: z.ZodOptional<z.ZodNumber>;
323
+ velocity: z.ZodOptional<z.ZodNumber>;
324
+ controller: z.ZodOptional<z.ZodNumber>;
325
+ value: z.ZodOptional<z.ZodNumber>;
326
+ timestamp: z.ZodOptional<z.ZodNumber>;
327
+ }, "strip", z.ZodTypeAny, {
328
+ timestamp?: number;
329
+ value?: number;
330
+ command?: "NOTE_ON" | "NOTE_OFF" | "CONTROL_CHANGE" | "PITCH_BEND" | "PROGRAM_CHANGE" | "AFTERTOUCH" | "POLY_PRESSURE" | "CLOCK" | "START" | "CONTINUE" | "STOP" | "ACTIVE_SENSING" | "SYSTEM_RESET";
331
+ channel?: number;
332
+ note?: number;
333
+ velocity?: number;
334
+ controller?: number;
335
+ }, {
336
+ timestamp?: number;
337
+ value?: number;
338
+ command?: "NOTE_ON" | "NOTE_OFF" | "CONTROL_CHANGE" | "PITCH_BEND" | "PROGRAM_CHANGE" | "AFTERTOUCH" | "POLY_PRESSURE" | "CLOCK" | "START" | "CONTINUE" | "STOP" | "ACTIVE_SENSING" | "SYSTEM_RESET";
339
+ channel?: number;
340
+ note?: number;
341
+ velocity?: number;
342
+ controller?: number;
343
+ }>;
344
+ type MidiEventPayload = z.infer<typeof MidiEventPayloadSchema>;
345
+ declare const BackendOperationSchema: z.ZodObject<{
346
+ name: z.ZodString;
347
+ service: z.ZodString;
348
+ description: z.ZodOptional<z.ZodString>;
349
+ inputSchemaName: z.ZodOptional<z.ZodString>;
350
+ outputSchemaName: z.ZodOptional<z.ZodString>;
351
+ }, "strip", z.ZodTypeAny, {
352
+ name?: string;
353
+ description?: string;
354
+ service?: string;
355
+ inputSchemaName?: string;
356
+ outputSchemaName?: string;
357
+ }, {
358
+ name?: string;
359
+ description?: string;
360
+ service?: string;
361
+ inputSchemaName?: string;
362
+ outputSchemaName?: string;
363
+ }>;
364
+ type BackendOperation = z.infer<typeof BackendOperationSchema>;
365
+ declare const PublicContractDefinitionSchema: z.ZodObject<{
366
+ package: z.ZodString;
367
+ version: z.ZodString;
368
+ description: z.ZodString;
369
+ exports: z.ZodRecord<z.ZodString, z.ZodObject<{
370
+ types: z.ZodString;
371
+ import: z.ZodString;
372
+ default: z.ZodString;
373
+ }, "strip", z.ZodTypeAny, {
374
+ types?: string;
375
+ import?: string;
376
+ default?: string;
377
+ }, {
378
+ types?: string;
379
+ import?: string;
380
+ default?: string;
381
+ }>>;
382
+ symbols: z.ZodArray<z.ZodObject<{
383
+ name: z.ZodString;
384
+ subpath: z.ZodString;
385
+ kind: z.ZodEnum<["class", "type", "interface", "function", "const", "object"]>;
386
+ hasZodSchema: z.ZodBoolean;
387
+ }, "strip", z.ZodTypeAny, {
388
+ name?: string;
389
+ subpath?: string;
390
+ kind?: "object" | "function" | "type" | "class" | "interface" | "const";
391
+ hasZodSchema?: boolean;
392
+ }, {
393
+ name?: string;
394
+ subpath?: string;
395
+ kind?: "object" | "function" | "type" | "class" | "interface" | "const";
396
+ hasZodSchema?: boolean;
397
+ }>, "many">;
398
+ facades: z.ZodArray<z.ZodObject<{
399
+ id: z.ZodString;
400
+ name: z.ZodString;
401
+ subpath: z.ZodString;
402
+ runtime: z.ZodEnum<["client", "server"]>;
403
+ deployment: z.ZodEnum<["local", "remote"]>;
404
+ }, "strip", z.ZodTypeAny, {
405
+ id?: string;
406
+ name?: string;
407
+ subpath?: string;
408
+ runtime?: "client" | "server";
409
+ deployment?: "local" | "remote";
410
+ }, {
411
+ id?: string;
412
+ name?: string;
413
+ subpath?: string;
414
+ runtime?: "client" | "server";
415
+ deployment?: "local" | "remote";
416
+ }>, "many">;
417
+ invariants: z.ZodArray<z.ZodString, "many">;
418
+ }, "strip", z.ZodTypeAny, {
419
+ package?: string;
420
+ version?: string;
421
+ facades?: {
422
+ id?: string;
423
+ name?: string;
424
+ subpath?: string;
425
+ runtime?: "client" | "server";
426
+ deployment?: "local" | "remote";
427
+ }[];
428
+ description?: string;
429
+ exports?: Record<string, {
430
+ types?: string;
431
+ import?: string;
432
+ default?: string;
433
+ }>;
434
+ symbols?: {
435
+ name?: string;
436
+ subpath?: string;
437
+ kind?: "object" | "function" | "type" | "class" | "interface" | "const";
438
+ hasZodSchema?: boolean;
439
+ }[];
440
+ invariants?: string[];
441
+ }, {
442
+ package?: string;
443
+ version?: string;
444
+ facades?: {
445
+ id?: string;
446
+ name?: string;
447
+ subpath?: string;
448
+ runtime?: "client" | "server";
449
+ deployment?: "local" | "remote";
450
+ }[];
451
+ description?: string;
452
+ exports?: Record<string, {
453
+ types?: string;
454
+ import?: string;
455
+ default?: string;
456
+ }>;
457
+ symbols?: {
458
+ name?: string;
459
+ subpath?: string;
460
+ kind?: "object" | "function" | "type" | "class" | "interface" | "const";
461
+ hasZodSchema?: boolean;
462
+ }[];
463
+ invariants?: string[];
464
+ }>;
465
+ type PublicContractDefinition = z.infer<typeof PublicContractDefinitionSchema>;
466
+ declare const ContractSnapshotSchema: z.ZodObject<{
467
+ package: z.ZodString;
468
+ version: z.ZodString;
469
+ timestamp: z.ZodNumber;
470
+ checksum: z.ZodString;
471
+ publicSymbols: z.ZodArray<z.ZodString, "many">;
472
+ normalizedSignatures: z.ZodRecord<z.ZodString, z.ZodString>;
473
+ zodFingerprints: z.ZodRecord<z.ZodString, z.ZodString>;
474
+ facades: z.ZodArray<z.ZodString, "many">;
475
+ events: z.ZodArray<z.ZodString, "many">;
476
+ commands: z.ZodArray<z.ZodString, "many">;
477
+ errorCodes: z.ZodArray<z.ZodString, "many">;
478
+ }, "strip", z.ZodTypeAny, {
479
+ package?: string;
480
+ version?: string;
481
+ timestamp?: number;
482
+ checksum?: string;
483
+ publicSymbols?: string[];
484
+ normalizedSignatures?: Record<string, string>;
485
+ zodFingerprints?: Record<string, string>;
486
+ facades?: string[];
487
+ events?: string[];
488
+ commands?: string[];
489
+ errorCodes?: string[];
490
+ }, {
491
+ package?: string;
492
+ version?: string;
493
+ timestamp?: number;
494
+ checksum?: string;
495
+ publicSymbols?: string[];
496
+ normalizedSignatures?: Record<string, string>;
497
+ zodFingerprints?: Record<string, string>;
498
+ facades?: string[];
499
+ events?: string[];
500
+ commands?: string[];
501
+ errorCodes?: string[];
502
+ }>;
503
+ type ContractSnapshot = z.infer<typeof ContractSnapshotSchema>;
504
+
505
+ /**
506
+ * @file snapshot.ts
507
+ * @description Contract snapshot generator, diff engine, and semantic versioning rules.
508
+ * Enforces:
509
+ * implementation_only => PATCH
510
+ * additive_compatible => MINOR
511
+ * breaking_contract_change => MAJOR
512
+ */
513
+
514
+ interface ContractDiffResult {
515
+ versionRecommendation: 'PATCH' | 'MINOR' | 'MAJOR';
516
+ hasBreakingChanges: boolean;
517
+ hasAdditiveChanges: boolean;
518
+ isIdentical: boolean;
519
+ removedSymbols: string[];
520
+ addedSymbols: string[];
521
+ changedSignatures: string[];
522
+ summary: string;
523
+ }
524
+ /**
525
+ * Generate canonical contract snapshot for Kloks.
526
+ */
527
+ declare function createKloksSnapshot(version?: string, surface?: ExportSymbolEntry[]): ContractSnapshot;
528
+ /**
529
+ * Computes semantic diff between previous and current contract snapshots.
530
+ */
531
+ declare function diffContractSnapshots(previous: ContractSnapshot, current: ContractSnapshot): ContractDiffResult;
532
+
533
+ declare const KLOKS_CANONICAL_CONTRACT: {
534
+ package: string;
535
+ version: string;
536
+ getSnapshot: () => {
537
+ package?: string;
538
+ version?: string;
539
+ timestamp?: number;
540
+ checksum?: string;
541
+ publicSymbols?: string[];
542
+ normalizedSignatures?: Record<string, string>;
543
+ zodFingerprints?: Record<string, string>;
544
+ facades?: string[];
545
+ events?: string[];
546
+ commands?: string[];
547
+ errorCodes?: string[];
548
+ };
549
+ validateCompatibility: (consumerSymbols?: string[]) => CompatibilityCheckResult;
550
+ };
551
+
552
+ export { type AudioBusConfig, AudioBusConfigSchema, type AudioHardwareState, AudioHardwareStateSchema, type BackendOperation, BackendOperationSchema, type CompatibilityCheckResult, type ContractDiffResult, type ContractSnapshot, ContractSnapshotSchema, type ExportSymbolEntry, type GraphEntityMetadata, GraphEntityMetadataSchema, KLOKS_CANONICAL_CONTRACT, KLOKS_PUBLIC_SURFACE, type MidiCommandType, MidiCommandTypeSchema, type MidiEventPayload, MidiEventPayloadSchema, type NodeDimensions2D, NodeDimensions2DSchema, type NodeHeaderStyle, NodeHeaderStyleSchema, type NodeScreenRect2D, NodeScreenRect2DSchema, type PublicContractDefinition, PublicContractDefinitionSchema, QWNSR_REQUIRED_SURFACE, type SocketDirection, SocketDirectionSchema, type SocketGeometryConfig, SocketGeometryConfigSchema, type SocketPosition2D, SocketPosition2DSchema, type SocketStyleConfig, SocketStyleConfigSchema, type WireAnimationConfig, WireAnimationConfigSchema, type WireCurveStyle, WireCurveStyleSchema, type WireEndpoint2D, WireEndpoint2DSchema, type WireVisualConfig, WireVisualConfigSchema, createKloksSnapshot, diffContractSnapshots, validateConsumerSurfaceCompatibility };
@@ -0,0 +1,422 @@
1
+ // src/schemas.ts
2
+ import { z } from "zod";
3
+ var GraphEntityMetadataSchema = z.object({
4
+ id: z.string(),
5
+ name: z.string(),
6
+ type: z.string(),
7
+ archetype: z.string(),
8
+ tags: z.array(z.string()).optional(),
9
+ description: z.string().optional(),
10
+ createdAt: z.number().optional(),
11
+ updatedAt: z.number().optional(),
12
+ customAttributes: z.record(z.unknown()).optional()
13
+ });
14
+ var SocketPosition2DSchema = z.object({
15
+ x: z.number(),
16
+ y: z.number()
17
+ });
18
+ var SocketDirectionSchema = z.enum(["input", "output", "bidirectional"]);
19
+ var SocketGeometryConfigSchema = z.object({
20
+ radius: z.number().default(6),
21
+ hitRadius: z.number().default(12),
22
+ snapDistance: z.number().default(18),
23
+ direction: SocketDirectionSchema.default("input"),
24
+ relativeOffset: SocketPosition2DSchema.default({ x: 0, y: 0 })
25
+ });
26
+ var SocketStyleConfigSchema = z.object({
27
+ color: z.string(),
28
+ hoverColor: z.string().optional(),
29
+ activeColor: z.string().optional(),
30
+ borderColor: z.string().optional(),
31
+ borderWidth: z.number().optional(),
32
+ fillOpacity: z.number().optional()
33
+ });
34
+ var WireEndpoint2DSchema = z.object({
35
+ nodeId: z.string(),
36
+ socketId: z.string(),
37
+ position: SocketPosition2DSchema
38
+ });
39
+ var WireCurveStyleSchema = z.enum(["bezier", "linear", "orthogonal", "stepped"]);
40
+ var WireAnimationConfigSchema = z.object({
41
+ animated: z.boolean().default(false),
42
+ speed: z.number().default(1),
43
+ direction: z.enum(["forward", "reverse"]).default("forward"),
44
+ pulseFrequency: z.number().optional()
45
+ });
46
+ var WireVisualConfigSchema = z.object({
47
+ strokeColor: z.string(),
48
+ strokeWidth: z.number().default(2),
49
+ strokeDashArray: z.string().optional(),
50
+ curveStyle: WireCurveStyleSchema.default("bezier"),
51
+ curvature: z.number().default(0.5),
52
+ opacity: z.number().default(1),
53
+ glow: z.boolean().default(false),
54
+ glowColor: z.string().optional()
55
+ });
56
+ var NodeDimensions2DSchema = z.object({
57
+ width: z.number(),
58
+ height: z.number(),
59
+ minWidth: z.number().optional(),
60
+ minHeight: z.number().optional(),
61
+ maxWidth: z.number().optional(),
62
+ maxHeight: z.number().optional()
63
+ });
64
+ var NodeScreenRect2DSchema = z.object({
65
+ x: z.number(),
66
+ y: z.number(),
67
+ width: z.number(),
68
+ height: z.number()
69
+ });
70
+ var NodeHeaderStyleSchema = z.object({
71
+ backgroundColor: z.string().optional(),
72
+ titleColor: z.string().optional(),
73
+ iconColor: z.string().optional(),
74
+ badgeColor: z.string().optional()
75
+ });
76
+ var AudioBusConfigSchema = z.object({
77
+ channelCount: z.number().default(2),
78
+ sampleRate: z.number().default(44100),
79
+ bufferSize: z.number().default(512),
80
+ latencyHint: z.enum(["interactive", "balanced", "playback"]).default("interactive")
81
+ });
82
+ var AudioHardwareStateSchema = z.object({
83
+ contextState: z.enum(["suspended", "running", "closed", "uninitialized"]),
84
+ sampleRate: z.number(),
85
+ inputChannels: z.number(),
86
+ outputChannels: z.number(),
87
+ activeInputDeviceId: z.string().nullable().optional(),
88
+ activeOutputDeviceId: z.string().nullable().optional()
89
+ });
90
+ var MidiCommandTypeSchema = z.enum([
91
+ "NOTE_ON",
92
+ "NOTE_OFF",
93
+ "CONTROL_CHANGE",
94
+ "PITCH_BEND",
95
+ "PROGRAM_CHANGE",
96
+ "AFTERTOUCH",
97
+ "POLY_PRESSURE",
98
+ "CLOCK",
99
+ "START",
100
+ "CONTINUE",
101
+ "STOP",
102
+ "ACTIVE_SENSING",
103
+ "SYSTEM_RESET"
104
+ ]);
105
+ var MidiEventPayloadSchema = z.object({
106
+ command: MidiCommandTypeSchema,
107
+ channel: z.number().min(1).max(16).default(1),
108
+ note: z.number().min(0).max(127).optional(),
109
+ velocity: z.number().min(0).max(127).optional(),
110
+ controller: z.number().min(0).max(127).optional(),
111
+ value: z.number().min(0).max(127).optional(),
112
+ timestamp: z.number().optional()
113
+ });
114
+ var BackendOperationSchema = z.object({
115
+ name: z.string(),
116
+ service: z.string(),
117
+ description: z.string().optional(),
118
+ inputSchemaName: z.string().optional(),
119
+ outputSchemaName: z.string().optional()
120
+ });
121
+ var PublicContractDefinitionSchema = z.object({
122
+ package: z.string(),
123
+ version: z.string(),
124
+ description: z.string(),
125
+ exports: z.record(z.object({
126
+ types: z.string(),
127
+ import: z.string(),
128
+ default: z.string()
129
+ })),
130
+ symbols: z.array(z.object({
131
+ name: z.string(),
132
+ subpath: z.string(),
133
+ kind: z.enum(["class", "type", "interface", "function", "const", "object"]),
134
+ hasZodSchema: z.boolean()
135
+ })),
136
+ facades: z.array(z.object({
137
+ id: z.string(),
138
+ name: z.string(),
139
+ subpath: z.string(),
140
+ runtime: z.enum(["client", "server"]),
141
+ deployment: z.enum(["local", "remote"])
142
+ })),
143
+ invariants: z.array(z.string())
144
+ });
145
+ var ContractSnapshotSchema = z.object({
146
+ package: z.string(),
147
+ version: z.string(),
148
+ timestamp: z.number(),
149
+ checksum: z.string(),
150
+ publicSymbols: z.array(z.string()),
151
+ normalizedSignatures: z.record(z.string()),
152
+ zodFingerprints: z.record(z.string()),
153
+ facades: z.array(z.string()),
154
+ events: z.array(z.string()),
155
+ commands: z.array(z.string()),
156
+ errorCodes: z.array(z.string())
157
+ });
158
+
159
+ // src/surface.ts
160
+ var KLOKS_PUBLIC_SURFACE = [
161
+ // ── state-graph ──
162
+ { name: "GraphEntityParent", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
163
+ { name: "GraphEntityMetadata", subpath: "state-graph", category: "state-graph", hasZodSchema: true },
164
+ { name: "GraphSocketParent", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
165
+ { name: "SocketDirection", subpath: "state-graph", category: "state-graph", hasZodSchema: true },
166
+ { name: "SocketPosition2D", subpath: "state-graph", category: "state-graph", hasZodSchema: true },
167
+ { name: "SocketGeometryConfig", subpath: "state-graph", category: "state-graph", hasZodSchema: true },
168
+ { name: "SocketStyleConfig", subpath: "state-graph", category: "state-graph", hasZodSchema: true },
169
+ { name: "AudioStereoSocket", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
170
+ { name: "AudioMonoSocket", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
171
+ { name: "AudioPacketSocket", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
172
+ { name: "TriggerSocket", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
173
+ { name: "MidiStreamSocket", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
174
+ { name: "MidiPacketSocket", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
175
+ { name: "CurveStreamSocket", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
176
+ { name: "CurvePacketSocket", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
177
+ { name: "ComponentSocket", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
178
+ { name: "PrimitiveSocket", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
179
+ { name: "createSocketInstance", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
180
+ { name: "createQwnsrSocketInstance", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
181
+ { name: "GraphWireParent", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
182
+ { name: "WireEndpoint2D", subpath: "state-graph", category: "state-graph", hasZodSchema: true },
183
+ { name: "WireCurveStyle", subpath: "state-graph", category: "state-graph", hasZodSchema: true },
184
+ { name: "WireAnimationConfig", subpath: "state-graph", category: "state-graph", hasZodSchema: true },
185
+ { name: "WireVisualConfig", subpath: "state-graph", category: "state-graph", hasZodSchema: true },
186
+ { name: "AudioStereoWire", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
187
+ { name: "AudioMonoWire", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
188
+ { name: "AudioPacketWire", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
189
+ { name: "TriggerWire", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
190
+ { name: "MidiStreamWire", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
191
+ { name: "MidiPacketWire", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
192
+ { name: "CurveStreamWire", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
193
+ { name: "CurvePacketWire", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
194
+ { name: "ComponentWire", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
195
+ { name: "PrimitiveWire", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
196
+ { name: "createWireInstance", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
197
+ { name: "createQwnsrWireInstance", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
198
+ { name: "GraphNodeParent", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
199
+ { name: "DataProcessingNodeParent", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
200
+ { name: "SignalGeneratorNodeParent", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
201
+ { name: "RoutingNodeParent", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
202
+ { name: "ControlNodeParent", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
203
+ { name: "NodeDimensions2D", subpath: "state-graph", category: "state-graph", hasZodSchema: true },
204
+ { name: "NodeScreenRect2D", subpath: "state-graph", category: "state-graph", hasZodSchema: true },
205
+ { name: "NodeHeaderStyle", subpath: "state-graph", category: "state-graph", hasZodSchema: true },
206
+ { name: "TriggerNodeModel", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
207
+ { name: "ContainerNodeModel", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
208
+ { name: "ModuleNodeModel", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
209
+ { name: "EffectNodeModel", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
210
+ { name: "CodeNodeModel", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
211
+ { name: "ArrangementNodeModel", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
212
+ { name: "RouterNodeModel", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
213
+ { name: "StripNodeModel", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
214
+ { name: "ControlNodeModel", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
215
+ { name: "PrimitiveNodeModel", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
216
+ { name: "GroupNodeModel", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
217
+ { name: "createNodeInstance", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
218
+ { name: "createQwnsrNodeInstance", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
219
+ { name: "StateLifecycleServiceFacade", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
220
+ { name: "NodeGraphEngineServiceFacade", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
221
+ { name: "PredictiveGraphServiceFacade", subpath: "state-graph", category: "state-graph", hasZodSchema: false },
222
+ // ── audio-midi ──
223
+ { name: "AudioInputManager", subpath: "audio-midi", category: "audio-midi", hasZodSchema: false },
224
+ { name: "MidiManager", subpath: "audio-midi", category: "audio-midi", hasZodSchema: false },
225
+ { name: "AudioHardwareServiceFacade", subpath: "audio-midi", category: "audio-midi", hasZodSchema: false },
226
+ { name: "MidiServiceFacade", subpath: "audio-midi", category: "audio-midi", hasZodSchema: false },
227
+ { name: "AudioMidiOrchestratorFacade", subpath: "audio-midi", category: "audio-midi", hasZodSchema: false },
228
+ { name: "AudioBusConfig", subpath: "audio-midi", category: "audio-midi", hasZodSchema: true },
229
+ { name: "AudioHardwareState", subpath: "audio-midi", category: "audio-midi", hasZodSchema: true },
230
+ { name: "MidiCommandType", subpath: "audio-midi", category: "audio-midi", hasZodSchema: true },
231
+ { name: "MidiEventPayload", subpath: "audio-midi", category: "audio-midi", hasZodSchema: true },
232
+ // ── orchestrations ──
233
+ { name: "OrchestratorAFacade", subpath: "orchestrations", category: "orchestrations", hasZodSchema: false },
234
+ { name: "OrchestratorBFacade", subpath: "orchestrations", category: "orchestrations", hasZodSchema: false },
235
+ { name: "WorkspaceBackendFacade", subpath: "orchestrations", category: "orchestrations", hasZodSchema: false },
236
+ { name: "backendFacade", subpath: "orchestrations", category: "orchestrations", hasZodSchema: false },
237
+ { name: "workerExecutionBoundary", subpath: "orchestrations", category: "orchestrations", hasZodSchema: false },
238
+ // ── backend ──
239
+ { name: "AuthServiceFacade", subpath: "backend", category: "backend", hasZodSchema: false },
240
+ { name: "StorageServiceFacade", subpath: "backend", category: "backend", hasZodSchema: false },
241
+ { name: "WorkspaceServiceFacade", subpath: "backend", category: "backend", hasZodSchema: false },
242
+ { name: "ControlPlaneServiceFacade", subpath: "backend", category: "backend", hasZodSchema: false },
243
+ { name: "ExecutionServiceFacade", subpath: "backend", category: "backend", hasZodSchema: false },
244
+ { name: "ExecutableBackendFacade", subpath: "backend", category: "backend", hasZodSchema: false },
245
+ // ── services ──
246
+ { name: "ServiceAFacade", subpath: "services", category: "services", hasZodSchema: false },
247
+ { name: "ServiceBFacade", subpath: "services", category: "services", hasZodSchema: false },
248
+ { name: "ServiceCFacade", subpath: "services", category: "services", hasZodSchema: false },
249
+ { name: "ServiceDFacade", subpath: "services", category: "services", hasZodSchema: false },
250
+ // ── functions ──
251
+ { name: "FunctionsServiceFacade", subpath: "functions", category: "functions", hasZodSchema: false },
252
+ { name: "toKebabCase", subpath: "functions", category: "functions", hasZodSchema: false },
253
+ { name: "safeJsonParse", subpath: "functions", category: "functions", hasZodSchema: false },
254
+ // ── contracts ──
255
+ { name: "KLOKS_CANONICAL_CONTRACT", subpath: "contracts", category: "contracts", hasZodSchema: true },
256
+ { name: "createKloksSnapshot", subpath: "contracts", category: "contracts", hasZodSchema: true },
257
+ { name: "diffContractSnapshots", subpath: "contracts", category: "contracts", hasZodSchema: true },
258
+ { name: "validateConsumerSurfaceCompatibility", subpath: "contracts", category: "contracts", hasZodSchema: true }
259
+ ];
260
+ var QWNSR_REQUIRED_SURFACE = [
261
+ "GraphEntityMetadata",
262
+ "SocketPosition2D",
263
+ "SocketDirection",
264
+ "SocketGeometryConfig",
265
+ "SocketStyleConfig",
266
+ "AudioStereoSocket",
267
+ "AudioMonoSocket",
268
+ "TriggerSocket",
269
+ "createSocketInstance",
270
+ "GraphWireParent",
271
+ "WireEndpoint2D",
272
+ "WireVisualConfig",
273
+ "createWireInstance",
274
+ "GraphNodeParent",
275
+ "NodeDimensions2D",
276
+ "createNodeInstance",
277
+ "StateLifecycleServiceFacade",
278
+ "NodeGraphEngineServiceFacade",
279
+ "WorkspaceBackendFacade",
280
+ "AudioHardwareServiceFacade",
281
+ "MidiServiceFacade",
282
+ "AudioMidiOrchestratorFacade"
283
+ ];
284
+ function validateConsumerSurfaceCompatibility(requiredSymbols = QWNSR_REQUIRED_SURFACE, publicSurface = KLOKS_PUBLIC_SURFACE) {
285
+ const publicNames = new Set(publicSurface.map((s) => s.name));
286
+ const missingSymbols = requiredSymbols.filter((s) => !publicNames.has(s));
287
+ return {
288
+ compatible: missingSymbols.length === 0,
289
+ missingSymbols,
290
+ totalRequired: requiredSymbols.length,
291
+ totalPresent: requiredSymbols.length - missingSymbols.length
292
+ };
293
+ }
294
+
295
+ // src/snapshot.ts
296
+ function createKloksSnapshot(version = "1.0.2", surface = KLOKS_PUBLIC_SURFACE) {
297
+ const publicSymbols = surface.map((s) => s.name).sort();
298
+ const normalizedSignatures = {};
299
+ const zodFingerprints = {};
300
+ for (const item of surface) {
301
+ normalizedSignatures[item.name] = `${item.category}:${item.subpath}`;
302
+ zodFingerprints[item.name] = item.hasZodSchema ? "zod-verified" : "typescript-only";
303
+ }
304
+ const facades = surface.filter((s) => s.name.endsWith("Facade") || s.name.endsWith("facade")).map((s) => s.name).sort();
305
+ const events = [
306
+ "AudioServiceEvents.stateChange",
307
+ "MidiServiceEvents.midiEvent",
308
+ "TelemetryEvents.reading"
309
+ ];
310
+ const commands = [
311
+ "WorkspaceBackendFacade.project.list",
312
+ "WorkspaceBackendFacade.project.get",
313
+ "WorkspaceBackendFacade.project.save",
314
+ "WorkspaceBackendFacade.project.create",
315
+ "WorkspaceBackendFacade.project.delete",
316
+ "WorkspaceBackendFacade.sample.list",
317
+ "WorkspaceBackendFacade.sample.upload",
318
+ "WorkspaceBackendFacade.sample.delete",
319
+ "WorkspaceBackendFacade.asset.listPool",
320
+ "WorkspaceBackendFacade.asset.createFolder",
321
+ "WorkspaceBackendFacade.asset.upload",
322
+ "WorkspaceBackendFacade.asset.delete"
323
+ ];
324
+ const errorCodes = [
325
+ "ERR_CONTRACT_VIOLATION",
326
+ "ERR_INTERNAL_IMPORT_FORBIDDEN",
327
+ "ERR_LOCAL_SHIM_DETECTED",
328
+ "ERR_INCOMPATIBLE_SURFACE"
329
+ ];
330
+ const rawJson = JSON.stringify({ publicSymbols, facades, commands, events });
331
+ let hash = 0;
332
+ for (let i = 0; i < rawJson.length; i++) {
333
+ hash = (hash << 5) - hash + rawJson.charCodeAt(i);
334
+ hash |= 0;
335
+ }
336
+ const checksum = `sha256-${Math.abs(hash).toString(16)}`;
337
+ const snapshot = {
338
+ package: "@ultrst-armada/kloks",
339
+ version,
340
+ timestamp: 1760377e6,
341
+ checksum,
342
+ publicSymbols,
343
+ normalizedSignatures,
344
+ zodFingerprints,
345
+ facades,
346
+ events,
347
+ commands,
348
+ errorCodes
349
+ };
350
+ return ContractSnapshotSchema.parse(snapshot);
351
+ }
352
+ function diffContractSnapshots(previous, current) {
353
+ const prevSymbols = new Set(previous.publicSymbols);
354
+ const currSymbols = new Set(current.publicSymbols);
355
+ const removedSymbols = previous.publicSymbols.filter((s) => !currSymbols.has(s));
356
+ const addedSymbols = current.publicSymbols.filter((s) => !prevSymbols.has(s));
357
+ const changedSignatures = [];
358
+ for (const s of current.publicSymbols) {
359
+ if (prevSymbols.has(s)) {
360
+ const prevSig = previous.normalizedSignatures[s];
361
+ const currSig = current.normalizedSignatures[s];
362
+ if (prevSig && currSig && prevSig !== currSig) {
363
+ changedSignatures.push(`${s} (${prevSig} -> ${currSig})`);
364
+ }
365
+ }
366
+ }
367
+ const hasBreakingChanges = removedSymbols.length > 0;
368
+ const hasAdditiveChanges = addedSymbols.length > 0 || changedSignatures.length > 0;
369
+ const isIdentical = !hasBreakingChanges && !hasAdditiveChanges;
370
+ let versionRecommendation = "PATCH";
371
+ if (hasBreakingChanges) {
372
+ versionRecommendation = "MAJOR";
373
+ } else if (hasAdditiveChanges) {
374
+ versionRecommendation = "MINOR";
375
+ }
376
+ const summary = isIdentical ? "Identical public contract surface (PATCH compatible)." : hasBreakingChanges ? `Breaking contract change detected: ${removedSymbols.length} removed symbols (MAJOR bump required).` : `Additive compatible changes: ${addedSymbols.length} added symbols (MINOR bump required).`;
377
+ return {
378
+ versionRecommendation,
379
+ hasBreakingChanges,
380
+ hasAdditiveChanges,
381
+ isIdentical,
382
+ removedSymbols,
383
+ addedSymbols,
384
+ changedSignatures,
385
+ summary
386
+ };
387
+ }
388
+
389
+ // src/index.ts
390
+ var KLOKS_CANONICAL_CONTRACT = {
391
+ package: "@ultrst-armada/kloks",
392
+ version: "1.0.2",
393
+ getSnapshot: () => createKloksSnapshot("1.0.2", KLOKS_PUBLIC_SURFACE),
394
+ validateCompatibility: (consumerSymbols) => validateConsumerSurfaceCompatibility(consumerSymbols ?? QWNSR_REQUIRED_SURFACE, KLOKS_PUBLIC_SURFACE)
395
+ };
396
+ export {
397
+ AudioBusConfigSchema,
398
+ AudioHardwareStateSchema,
399
+ BackendOperationSchema,
400
+ ContractSnapshotSchema,
401
+ GraphEntityMetadataSchema,
402
+ KLOKS_CANONICAL_CONTRACT,
403
+ KLOKS_PUBLIC_SURFACE,
404
+ MidiCommandTypeSchema,
405
+ MidiEventPayloadSchema,
406
+ NodeDimensions2DSchema,
407
+ NodeHeaderStyleSchema,
408
+ NodeScreenRect2DSchema,
409
+ PublicContractDefinitionSchema,
410
+ QWNSR_REQUIRED_SURFACE,
411
+ SocketDirectionSchema,
412
+ SocketGeometryConfigSchema,
413
+ SocketPosition2DSchema,
414
+ SocketStyleConfigSchema,
415
+ WireAnimationConfigSchema,
416
+ WireCurveStyleSchema,
417
+ WireEndpoint2DSchema,
418
+ WireVisualConfigSchema,
419
+ createKloksSnapshot,
420
+ diffContractSnapshots,
421
+ validateConsumerSurfaceCompatibility
422
+ };
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://skipo.dev/schemas/kloks-manifest.v1.json",
3
+ "package": "@kloks/contracts",
4
+ "version": "1.0.0",
5
+ "services": [
6
+ {
7
+ "id": "canonical-contracts",
8
+ "name": "Canonical Contract & Snapshot Engine",
9
+ "version": "1.0.0",
10
+ "description": "Zod runtime schemas, export manifests, and contract snapshot diff engine.",
11
+ "backend": {
12
+ "package": "@kloks/contracts",
13
+ "export": "KLOKS_CANONICAL_CONTRACT",
14
+ "facade": "KLOKS_CANONICAL_CONTRACT"
15
+ },
16
+ "modes": ["backend"],
17
+ "targets": { "backend": ["BackendFacade.contracts"] }
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@kloks/contracts",
3
+ "version": "1.0.0",
4
+ "description": "Kloks Canonical Public Contracts, Zod Runtime Schemas, and Snapshot/Diff Validation Engine",
5
+ "type": "module",
6
+ "private": false,
7
+ "publishConfig": {
8
+ "access": "public",
9
+ "registry": "https://registry.npmjs.org/"
10
+ },
11
+ "skipoManifest": "./kloks.manifest.json",
12
+ "main": "./dist/index.js",
13
+ "module": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "import": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ }
21
+ },
22
+ "scripts": {
23
+ "build": "tsup src/index.ts --format esm --dts --clean --external zod",
24
+ "typecheck": "tsc --noEmit",
25
+ "clean": "rm -rf dist"
26
+ },
27
+ "dependencies": {
28
+ "zod": "^3.24.1"
29
+ },
30
+ "devDependencies": {
31
+ "@ultrst-armada/krnl": "^1.0.0"
32
+ }
33
+ }
@@ -19,6 +19,21 @@ import {
19
19
  WireTypeRegistry,
20
20
  initializeDefaultGraphRules
21
21
  } from "./chunk-QN74PLMF.js";
22
+ import "./chunk-Q5I42UX7.js";
23
+ import {
24
+ LifecycleCycleError,
25
+ LifecycleGraph,
26
+ SKIPO_STATE,
27
+ SkipoStateEngine,
28
+ useLifecycleScope,
29
+ useSkipoBind,
30
+ useSkipoState
31
+ } from "./chunk-SHIBCPGQ.js";
32
+ import {
33
+ AttractionEngine,
34
+ calculateSocketCoordinates,
35
+ getBeamPoints
36
+ } from "./chunk-YTWCH6P2.js";
22
37
  import {
23
38
  CommandApi,
24
39
  GhostStore,
@@ -33,11 +48,6 @@ import {
33
48
  CustomViewWindow,
34
49
  DEFAULT_GRAPH_SETTINGS
35
50
  } from "./chunk-KG6QYS26.js";
36
- import {
37
- AttractionEngine,
38
- calculateSocketCoordinates,
39
- getBeamPoints
40
- } from "./chunk-YTWCH6P2.js";
41
51
  import {
42
52
  AutoSolidify,
43
53
  SpatialEngine,
@@ -51,16 +61,6 @@ import {
51
61
  import {
52
62
  CompatibilityMatrix
53
63
  } from "./chunk-ISFNY7EZ.js";
54
- import "./chunk-Q5I42UX7.js";
55
- import {
56
- LifecycleCycleError,
57
- LifecycleGraph,
58
- SKIPO_STATE,
59
- SkipoStateEngine,
60
- useLifecycleScope,
61
- useSkipoBind,
62
- useSkipoState
63
- } from "./chunk-SHIBCPGQ.js";
64
64
  import "./chunk-3RG5ZIWI.js";
65
65
 
66
66
  // ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.0/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js