@aikdna/kdna-core 0.16.0 → 0.18.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/CHANGELOG.md +164 -2
- package/README.md +151 -2
- package/package.json +3 -2
- package/schema/agent-host-2-receipt.schema.json +206 -0
- package/schema/agent-host-2-request.schema.json +135 -0
- package/schema/agent-host-capabilities-1.schema.json +40 -0
- package/schema/checksums.schema.json +40 -1
- package/schema/consumption-plan-1.schema.json +280 -0
- package/schema/digest-evidence.schema.json +123 -0
- package/schema/judgment-trace-1.schema.json +748 -0
- package/schema/load-plan.schema.json +2 -2
- package/schema/manifest.schema.json +4 -5
- package/schema/payload-profile-v1.schema.json +25 -0
- package/schema/runtime-capsule-1.schema.json +68 -0
- package/schema/runtime-capsule-2.schema.json +140 -0
- package/src/asset-reader.js +100 -120
- package/src/capsule-v2.js +687 -0
- package/src/container-dispatcher.js +4 -1
- package/src/execution-contract-v1.js +1850 -0
- package/src/index.js +4 -0
- package/src/index.mjs +136 -21
- package/src/lint-pure.js +6 -3
- package/src/public-api.js +59 -163
- package/src/runtime-api.js +5 -6
- package/src/types.d.ts +1181 -113
- package/src/v1/index.js +298 -56
- package/src/v1/index.mjs +1 -0
package/src/types.d.ts
CHANGED
|
@@ -159,12 +159,7 @@ export interface KDNAEvolution {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
export type KDNADomainFile =
|
|
162
|
-
|
|
|
163
|
-
| KDNAPatterns
|
|
164
|
-
| KDNAScenarios
|
|
165
|
-
| KDNACases
|
|
166
|
-
| KDNAReasoning
|
|
167
|
-
| KDNAEvolution;
|
|
162
|
+
KDNACore | KDNAPatterns | KDNAScenarios | KDNACases | KDNAReasoning | KDNAEvolution;
|
|
168
163
|
|
|
169
164
|
export interface LoadedDomain {
|
|
170
165
|
core: KDNACore;
|
|
@@ -204,26 +199,52 @@ export interface KDNAFileDataMap {
|
|
|
204
199
|
|
|
205
200
|
export interface KDNAManifest {
|
|
206
201
|
kdna_version: '1.0';
|
|
207
|
-
|
|
202
|
+
asset_id: string;
|
|
203
|
+
asset_uid: string;
|
|
204
|
+
asset_type: 'domain' | 'cluster' | 'tool' | 'sample' | 'fixture' | 'bundle';
|
|
205
|
+
title: string;
|
|
208
206
|
version: string;
|
|
209
207
|
judgment_version: string;
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
208
|
+
created_at: string;
|
|
209
|
+
updated_at: string;
|
|
210
|
+
compatibility: {
|
|
211
|
+
min_loader_version: string;
|
|
212
|
+
profile: 'judgment-profile-v1' | 'bundle-profile-v1';
|
|
213
|
+
[key: string]: any;
|
|
214
|
+
};
|
|
215
|
+
payload: {
|
|
216
|
+
path: 'payload.kdnab';
|
|
217
|
+
encoding: 'cbor';
|
|
218
|
+
encrypted: boolean;
|
|
219
|
+
[key: string]: any;
|
|
220
|
+
};
|
|
221
|
+
creator?: {
|
|
222
|
+
name: string;
|
|
223
|
+
id?: string;
|
|
224
|
+
creator_type?: 'human' | 'agent' | 'tool' | 'organization';
|
|
225
|
+
pubkey?: string;
|
|
226
|
+
[key: string]: any;
|
|
227
|
+
};
|
|
228
|
+
access?: 'public' | 'licensed' | 'remote';
|
|
213
229
|
language?: string;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
description: string;
|
|
230
|
+
languages?: string[];
|
|
231
|
+
license?: string | { type: string; url?: string };
|
|
232
|
+
summary?: string;
|
|
233
|
+
description?: string;
|
|
219
234
|
keywords?: string[];
|
|
235
|
+
load_contract?: Record<string, any>;
|
|
220
236
|
encryption?: {
|
|
221
237
|
profile?: string;
|
|
222
238
|
encrypted_entries?: string[];
|
|
223
239
|
[key: string]: any;
|
|
224
240
|
};
|
|
241
|
+
/** @deprecated Legacy source/signature compatibility only. */
|
|
242
|
+
name?: string;
|
|
243
|
+
/** @deprecated Legacy source/signature compatibility only. */
|
|
244
|
+
author?: { name: string; id?: string; pubkey?: string; public_key_pem?: string };
|
|
225
245
|
content_digest?: string;
|
|
226
246
|
signature?: string;
|
|
247
|
+
[key: string]: any;
|
|
227
248
|
}
|
|
228
249
|
|
|
229
250
|
export interface LintResult {
|
|
@@ -243,9 +264,15 @@ export function loadCorePatternsFromData(
|
|
|
243
264
|
patternsData: KDNAPatterns,
|
|
244
265
|
): { core: KDNACore; patterns: KDNAPatterns } | null;
|
|
245
266
|
|
|
246
|
-
export function loadDomainFromData(
|
|
267
|
+
export function loadDomainFromData(
|
|
268
|
+
dataMap: KDNADataMap,
|
|
269
|
+
options?: LoadOptions,
|
|
270
|
+
): LoadedDomain | null;
|
|
247
271
|
|
|
248
|
-
export function loadDomainFromFiles(
|
|
272
|
+
export function loadDomainFromFiles(
|
|
273
|
+
fileDataMap: KDNAFileDataMap,
|
|
274
|
+
options?: LoadOptions,
|
|
275
|
+
): LoadedDomain | null;
|
|
249
276
|
|
|
250
277
|
export function classifyInput(text: string): string[];
|
|
251
278
|
|
|
@@ -254,6 +281,7 @@ export function formatContext(domain: LoadedDomain): string;
|
|
|
254
281
|
export const FILE_MAP: Record<string, string>;
|
|
255
282
|
|
|
256
283
|
// Asset reader — direct .kdna API
|
|
284
|
+
/** @deprecated Legacy source-tree entry names. Current Runtime assets use payload.kdnab. */
|
|
257
285
|
export const STANDARD_ENTRIES: string[];
|
|
258
286
|
|
|
259
287
|
export interface KdnaAsset {
|
|
@@ -307,16 +335,10 @@ export interface KdnaAssetReader {
|
|
|
307
335
|
readJson(asset: KdnaAsset, entryName: string, options?: KdnaDecryptOptions): Promise<any>;
|
|
308
336
|
readManifestSync(asset: KdnaAsset): KDNAManifest;
|
|
309
337
|
readManifest(asset: KdnaAsset): Promise<KDNAManifest>;
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
): KDNAFileDataMap;
|
|
315
|
-
readDataMap(
|
|
316
|
-
asset: KdnaAsset,
|
|
317
|
-
entries?: string[],
|
|
318
|
-
options?: KdnaDecryptOptions,
|
|
319
|
-
): Promise<KDNAFileDataMap>;
|
|
338
|
+
/** @deprecated Current payload.kdnab is not projected into legacy source files. */
|
|
339
|
+
readDataMapSync(asset: KdnaAsset, entries?: string[], options?: KdnaDecryptOptions): never;
|
|
340
|
+
/** @deprecated Current payload.kdnab is not projected into legacy source files. */
|
|
341
|
+
readDataMap(asset: KdnaAsset, entries?: string[], options?: KdnaDecryptOptions): Promise<never>;
|
|
320
342
|
contentDigestSync(asset: KdnaAsset): string;
|
|
321
343
|
contentDigest(asset: KdnaAsset): Promise<string>;
|
|
322
344
|
verifySync(
|
|
@@ -339,24 +361,14 @@ export interface KdnaAssetReader {
|
|
|
339
361
|
): Promise<KdnaAssetVerifyResult>;
|
|
340
362
|
loadProfileSync(
|
|
341
363
|
asset: KdnaAsset,
|
|
342
|
-
profile
|
|
343
|
-
options?: {
|
|
344
|
-
):
|
|
345
|
-
loadProfileSync(
|
|
346
|
-
asset: KdnaAsset,
|
|
347
|
-
profile?: 'compact' | 'scenario' | 'full' | string,
|
|
348
|
-
options?: { input?: string; context?: boolean } & KdnaDecryptOptions,
|
|
349
|
-
): KdnaAssetLoadProfile;
|
|
350
|
-
loadProfile(
|
|
351
|
-
asset: KdnaAsset,
|
|
352
|
-
profile: 'index',
|
|
353
|
-
options?: { input?: string; context?: boolean } & KdnaDecryptOptions,
|
|
354
|
-
): Promise<KdnaAssetIndexProfile>;
|
|
364
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full' | string,
|
|
365
|
+
options?: { as?: 'json' | 'prompt' | string } & KdnaDecryptOptions,
|
|
366
|
+
): KDNARuntimeCapsule | Record<string, any>;
|
|
355
367
|
loadProfile(
|
|
356
368
|
asset: KdnaAsset,
|
|
357
|
-
profile?: 'compact' | 'scenario' | 'full' | string,
|
|
358
|
-
options?: {
|
|
359
|
-
): Promise<
|
|
369
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full' | string,
|
|
370
|
+
options?: { as?: 'json' | 'prompt' | string } & KdnaDecryptOptions,
|
|
371
|
+
): Promise<KDNARuntimeCapsule | Record<string, any>>;
|
|
360
372
|
}
|
|
361
373
|
|
|
362
374
|
export interface KdnaDecryptOptions {
|
|
@@ -370,10 +382,32 @@ export interface KdnaDecryptOptions {
|
|
|
370
382
|
|
|
371
383
|
export function createKdnaAssetReader(): KdnaAssetReader;
|
|
372
384
|
|
|
373
|
-
export const LICENSED_ENTRY_PROFILE:
|
|
385
|
+
export const LICENSED_ENTRY_PROFILE: 'kdna-licensed-entry-v1';
|
|
386
|
+
export const LICENSED_EXPERIMENTAL_PROFILE: 'kdna-licensed-entry-experimental';
|
|
387
|
+
export const PASSWORD_PROTECTED_PROFILE: 'kdna-password-protected-v1';
|
|
388
|
+
export const PASSWORD_PROTECTED_SCRYPT_PROFILE: 'kdna-password-protected-v1-scrypt';
|
|
389
|
+
export const ALG: 'AES-256-GCM';
|
|
390
|
+
export const RFC_KDF: 'HKDF-SHA256';
|
|
391
|
+
export const RFC_KEY_WRAPPING: 'AES-256-KW';
|
|
392
|
+
export const LEGACY_KDF: 'scrypt-sha256';
|
|
393
|
+
export const PASSWORD_KDF: 'Argon2id';
|
|
394
|
+
export const SCRYPT_KDF: 'scrypt-sha256';
|
|
395
|
+
|
|
396
|
+
export type KDNACryptoInput = string | Uint8Array;
|
|
374
397
|
|
|
375
398
|
export interface LicensedEntryEnvelope {
|
|
376
|
-
profile:
|
|
399
|
+
profile: 'kdna-licensed-entry-v1';
|
|
400
|
+
alg: 'AES-256-GCM';
|
|
401
|
+
kdf: 'HKDF-SHA256';
|
|
402
|
+
key_wrapping: 'AES-256-KW';
|
|
403
|
+
wrapped_key: string;
|
|
404
|
+
iv: string;
|
|
405
|
+
tag: string;
|
|
406
|
+
ciphertext: string;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export interface LicensedEntryLegacyEnvelope {
|
|
410
|
+
profile: 'kdna-licensed-entry-experimental';
|
|
377
411
|
alg: 'AES-256-GCM';
|
|
378
412
|
kdf: 'scrypt-sha256';
|
|
379
413
|
salt: string;
|
|
@@ -382,6 +416,70 @@ export interface LicensedEntryEnvelope {
|
|
|
382
416
|
ciphertext: string;
|
|
383
417
|
}
|
|
384
418
|
|
|
419
|
+
export interface KDNAPasswordKdfParams {
|
|
420
|
+
salt: string;
|
|
421
|
+
memory_kib?: number;
|
|
422
|
+
iterations?: number;
|
|
423
|
+
parallelism?: number;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export interface KDNAPasswordKdfDescriptor {
|
|
427
|
+
name: 'Argon2id';
|
|
428
|
+
salt: string;
|
|
429
|
+
memory_kib: number;
|
|
430
|
+
iterations: number;
|
|
431
|
+
parallelism: number;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export interface KDNAScryptKdfParams {
|
|
435
|
+
salt: string;
|
|
436
|
+
N?: number;
|
|
437
|
+
r?: number;
|
|
438
|
+
p?: number;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export interface KDNAProtectedEntryEnvelope {
|
|
442
|
+
profile: 'kdna-password-protected-v1';
|
|
443
|
+
alg: 'AES-256-GCM';
|
|
444
|
+
kdf: 'Argon2id';
|
|
445
|
+
key_wrapping: 'AES-256-KW';
|
|
446
|
+
password_kdf: KDNAPasswordKdfDescriptor;
|
|
447
|
+
key_slots: Array<{
|
|
448
|
+
slot: 'password' | 'recovery';
|
|
449
|
+
wrap: 'AES-256-KW';
|
|
450
|
+
wrapped_key: string;
|
|
451
|
+
}>;
|
|
452
|
+
iv: string;
|
|
453
|
+
tag: string;
|
|
454
|
+
ciphertext: string;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
export interface KDNAScryptProtectedEntryEnvelope {
|
|
458
|
+
profile: 'kdna-password-protected-v1-scrypt';
|
|
459
|
+
alg: 'AES-256-GCM';
|
|
460
|
+
kdf: 'scrypt-sha256';
|
|
461
|
+
key_wrapping: 'AES-256-KW';
|
|
462
|
+
scrypt_params: Required<KDNAScryptKdfParams>;
|
|
463
|
+
key_slots: Array<{
|
|
464
|
+
slot: 'password';
|
|
465
|
+
wrap: 'AES-256-KW';
|
|
466
|
+
wrapped_key: string;
|
|
467
|
+
}>;
|
|
468
|
+
iv: string;
|
|
469
|
+
tag: string;
|
|
470
|
+
ciphertext: string;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export interface KDNALicensedEntryOptions {
|
|
474
|
+
entryName: string;
|
|
475
|
+
manifest?: KDNAManifest;
|
|
476
|
+
licenseKey: KDNACryptoInput;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export interface KDNALicensedEntryLegacyOptions extends KDNALicensedEntryOptions {
|
|
480
|
+
machineFingerprint: string;
|
|
481
|
+
}
|
|
482
|
+
|
|
385
483
|
export function deriveLicensedEntryKey(options: {
|
|
386
484
|
licenseKey: string;
|
|
387
485
|
machineFingerprint: string;
|
|
@@ -389,33 +487,122 @@ export function deriveLicensedEntryKey(options: {
|
|
|
389
487
|
keyLength?: number;
|
|
390
488
|
}): Uint8Array;
|
|
391
489
|
|
|
392
|
-
export function
|
|
393
|
-
|
|
490
|
+
export function hkdfSha256(
|
|
491
|
+
ikm: KDNACryptoInput,
|
|
492
|
+
salt?: Uint8Array | null,
|
|
493
|
+
info?: KDNACryptoInput,
|
|
494
|
+
length?: number,
|
|
495
|
+
): Uint8Array;
|
|
496
|
+
export function aesWrap(key: Uint8Array, plaintext: Uint8Array): Uint8Array;
|
|
497
|
+
export function aesUnwrap(key: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
498
|
+
export function deriveWrappingKey(licenseKey: KDNACryptoInput, info?: KDNACryptoInput): Uint8Array;
|
|
499
|
+
export function generateCEK(): Uint8Array;
|
|
500
|
+
export function wrapCEK(cek: Uint8Array, wrappingKey: Uint8Array): Uint8Array;
|
|
501
|
+
export function unwrapCEK(wrappedCek: Uint8Array, wrappingKey: Uint8Array): Uint8Array;
|
|
502
|
+
|
|
503
|
+
export function encryptLicensedEntryV1(
|
|
504
|
+
plaintext: KDNACryptoInput,
|
|
505
|
+
options: KDNALicensedEntryOptions,
|
|
506
|
+
): LicensedEntryEnvelope;
|
|
507
|
+
export function decryptLicensedEntryV1(
|
|
508
|
+
envelope: KDNACryptoInput | LicensedEntryEnvelope,
|
|
509
|
+
options: KDNALicensedEntryOptions,
|
|
510
|
+
): Uint8Array;
|
|
511
|
+
export function derivePasswordKey(
|
|
512
|
+
password: KDNACryptoInput,
|
|
513
|
+
params: KDNAPasswordKdfParams,
|
|
514
|
+
): Uint8Array;
|
|
515
|
+
export function generateRecoveryCode(): string;
|
|
516
|
+
export function decodeRecoveryCode(code: string): Uint8Array;
|
|
517
|
+
export function encryptProtectedEntry(
|
|
518
|
+
plaintext: KDNACryptoInput,
|
|
394
519
|
options: {
|
|
395
520
|
entryName: string;
|
|
396
521
|
manifest?: KDNAManifest;
|
|
397
|
-
|
|
398
|
-
|
|
522
|
+
password: KDNACryptoInput;
|
|
523
|
+
includeRecovery?: boolean;
|
|
524
|
+
recoveryCode?: string;
|
|
399
525
|
},
|
|
400
|
-
):
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
526
|
+
): KDNAProtectedEntryEnvelope;
|
|
527
|
+
export function decryptProtectedEntry(
|
|
528
|
+
envelope: KDNACryptoInput | KDNAProtectedEntryEnvelope,
|
|
529
|
+
options: {
|
|
530
|
+
entryName: string;
|
|
531
|
+
manifest?: KDNAManifest;
|
|
532
|
+
} & (
|
|
533
|
+
| { password: KDNACryptoInput; recoveryCode?: string }
|
|
534
|
+
| { password?: undefined; recoveryCode: string }
|
|
535
|
+
),
|
|
536
|
+
): Uint8Array;
|
|
537
|
+
export function createPasswordDecryptEntry(options: {
|
|
538
|
+
password: KDNACryptoInput;
|
|
539
|
+
}): NonNullable<KdnaDecryptOptions['decryptEntry']>;
|
|
540
|
+
export function createRecoveryDecryptEntry(options: {
|
|
541
|
+
recoveryCode: string;
|
|
542
|
+
}): NonNullable<KdnaDecryptOptions['decryptEntry']>;
|
|
543
|
+
export function derivePasswordKeyScrypt(
|
|
544
|
+
password: KDNACryptoInput,
|
|
545
|
+
params: KDNAScryptKdfParams,
|
|
546
|
+
): Uint8Array;
|
|
547
|
+
export function encryptProtectedEntryScrypt(
|
|
548
|
+
plaintext: KDNACryptoInput,
|
|
404
549
|
options: {
|
|
405
550
|
entryName: string;
|
|
406
551
|
manifest?: KDNAManifest;
|
|
407
|
-
|
|
408
|
-
machineFingerprint: string;
|
|
552
|
+
password: KDNACryptoInput;
|
|
409
553
|
},
|
|
554
|
+
): KDNAScryptProtectedEntryEnvelope;
|
|
555
|
+
export function decryptProtectedEntryScrypt(
|
|
556
|
+
envelope: KDNACryptoInput | KDNAScryptProtectedEntryEnvelope,
|
|
557
|
+
options: {
|
|
558
|
+
entryName: string;
|
|
559
|
+
manifest?: KDNAManifest;
|
|
560
|
+
password: KDNACryptoInput;
|
|
561
|
+
},
|
|
562
|
+
): Uint8Array;
|
|
563
|
+
export function createPasswordDecryptEntryScrypt(options: {
|
|
564
|
+
password: KDNACryptoInput;
|
|
565
|
+
}): NonNullable<KdnaDecryptOptions['decryptEntry']>;
|
|
566
|
+
export function encryptLicensedEntryLegacy(
|
|
567
|
+
plaintext: KDNACryptoInput,
|
|
568
|
+
options: KDNALicensedEntryLegacyOptions,
|
|
569
|
+
): LicensedEntryLegacyEnvelope;
|
|
570
|
+
export function decryptLicensedEntryLegacy(
|
|
571
|
+
envelope: KDNACryptoInput | LicensedEntryLegacyEnvelope,
|
|
572
|
+
options: KDNALicensedEntryLegacyOptions,
|
|
573
|
+
): Uint8Array;
|
|
574
|
+
|
|
575
|
+
export function encryptLicensedEntry(
|
|
576
|
+
plaintext: string | Uint8Array,
|
|
577
|
+
options: KDNALicensedEntryOptions,
|
|
578
|
+
): LicensedEntryEnvelope;
|
|
579
|
+
|
|
580
|
+
export function decryptLicensedEntry(
|
|
581
|
+
envelope: LicensedEntryEnvelope,
|
|
582
|
+
options: KDNALicensedEntryOptions,
|
|
583
|
+
): Uint8Array;
|
|
584
|
+
export function decryptLicensedEntry(
|
|
585
|
+
envelope: LicensedEntryLegacyEnvelope,
|
|
586
|
+
options: KDNALicensedEntryLegacyOptions,
|
|
587
|
+
): Uint8Array;
|
|
588
|
+
export function decryptLicensedEntry(
|
|
589
|
+
envelope: KDNACryptoInput,
|
|
590
|
+
options: KDNALicensedEntryLegacyOptions,
|
|
591
|
+
): Uint8Array;
|
|
592
|
+
export function decryptLicensedEntry(
|
|
593
|
+
envelope: KDNACryptoInput | LicensedEntryEnvelope | LicensedEntryLegacyEnvelope,
|
|
594
|
+
options: KDNALicensedEntryLegacyOptions,
|
|
410
595
|
): Uint8Array;
|
|
411
596
|
|
|
412
597
|
export function createLicensedDecryptEntry(options: {
|
|
413
|
-
licenseKey:
|
|
414
|
-
machineFingerprint
|
|
598
|
+
licenseKey: KDNACryptoInput;
|
|
599
|
+
machineFingerprint?: string;
|
|
415
600
|
}): NonNullable<KdnaDecryptOptions['decryptEntry']>;
|
|
416
601
|
|
|
417
602
|
export const EXTERNAL_ENVELOPE_PROFILE: 'kdna-envelope-external-grant-v1';
|
|
418
603
|
export const EXTERNAL_GRANT_PROFILE: 'kdna-key-grant-v1';
|
|
604
|
+
export const EXTERNAL_AAD_PROFILE: 'kdna-external-asset-cek-v1';
|
|
605
|
+
export const DEVICE_KEK_PROFILE: 'kdna-device-grant-kek-v1';
|
|
419
606
|
|
|
420
607
|
export class KDNAExternalGrantError extends Error {
|
|
421
608
|
code: string;
|
|
@@ -504,7 +691,9 @@ export interface KDNAExternalAuthorization {
|
|
|
504
691
|
}
|
|
505
692
|
|
|
506
693
|
export function canonicalJson(value: unknown): string;
|
|
507
|
-
export function grantSigningPayload(
|
|
694
|
+
export function grantSigningPayload(
|
|
695
|
+
grant: Omit<KDNAExternalKeyGrant, 'signature'> | KDNAExternalKeyGrant,
|
|
696
|
+
): Uint8Array;
|
|
508
697
|
export function validateExternalEnvelope(value: unknown): KDNAExternalGrantEnvelope;
|
|
509
698
|
export function validateExternalKeyGrant(value: unknown): KDNAExternalKeyGrant;
|
|
510
699
|
export function externalEnvelopeAad(options: {
|
|
@@ -523,15 +712,20 @@ export function deriveExternalAssetCek(options: {
|
|
|
523
712
|
issuerKeyId: string;
|
|
524
713
|
}): Uint8Array;
|
|
525
714
|
export function encodeExternalEnvelope(value: KDNAExternalGrantEnvelope): Uint8Array;
|
|
526
|
-
export function decodeExternalEnvelope(
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
715
|
+
export function decodeExternalEnvelope(
|
|
716
|
+
value: KDNAExternalGrantEnvelope | Uint8Array,
|
|
717
|
+
): KDNAExternalGrantEnvelope;
|
|
718
|
+
export function encryptExternalGrantEntry(
|
|
719
|
+
plaintext: string | Uint8Array,
|
|
720
|
+
options: {
|
|
721
|
+
manifest: KDNAManifest;
|
|
722
|
+
entryName?: string;
|
|
723
|
+
issuerRootKey: string | Uint8Array;
|
|
724
|
+
keyRef: string;
|
|
725
|
+
issuerKeyId: string;
|
|
726
|
+
iv?: Uint8Array;
|
|
727
|
+
},
|
|
728
|
+
): KDNAExternalGrantEnvelope;
|
|
535
729
|
export function generateDeviceKeyPairs(): KDNADeviceKeyPairs;
|
|
536
730
|
export function createExternalKeyGrant(options: {
|
|
537
731
|
issuerRootKey: string | Uint8Array;
|
|
@@ -571,20 +765,26 @@ export function authorizeExternalKeyGrant(options: {
|
|
|
571
765
|
networkAvailable?: boolean;
|
|
572
766
|
allowOffline?: boolean;
|
|
573
767
|
}): KDNAExternalAuthorization;
|
|
574
|
-
export function isVerifiedExternalEntitlement(
|
|
768
|
+
export function isVerifiedExternalEntitlement(
|
|
769
|
+
value: unknown,
|
|
770
|
+
): value is KDNAVerifiedExternalEntitlement;
|
|
575
771
|
|
|
576
772
|
// Stable public API — preferred entry points for third-party integrations.
|
|
577
773
|
export type KDNAAssetInput = string | Uint8Array | KdnaAsset;
|
|
578
774
|
|
|
579
775
|
export interface KDNAInspectResult {
|
|
580
|
-
|
|
776
|
+
kdna_version: string | null;
|
|
777
|
+
asset_id: string | null;
|
|
778
|
+
asset_uid: string | null;
|
|
779
|
+
asset_type: string | null;
|
|
780
|
+
title: string | null;
|
|
581
781
|
version: string | null;
|
|
582
782
|
judgment_version: string | null;
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
783
|
+
payload: string | null;
|
|
784
|
+
payload_encrypted: boolean | null;
|
|
785
|
+
profile: string | null;
|
|
786
|
+
load_contract_default_profile: string | null;
|
|
787
|
+
checksums_present?: boolean;
|
|
588
788
|
entries: string[];
|
|
589
789
|
asset_digest: string;
|
|
590
790
|
content_digest: string;
|
|
@@ -596,15 +796,509 @@ export interface KDNAInspectResult {
|
|
|
596
796
|
}
|
|
597
797
|
|
|
598
798
|
export interface KDNAValidationReport {
|
|
599
|
-
|
|
600
|
-
|
|
799
|
+
format_valid: boolean;
|
|
800
|
+
schema_valid: boolean;
|
|
801
|
+
payload_valid: boolean;
|
|
802
|
+
checksums_valid: boolean;
|
|
803
|
+
load_contract_valid: boolean;
|
|
804
|
+
overall_valid: boolean;
|
|
805
|
+
problems: string[];
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
export interface KDNARuntimeCapsule {
|
|
809
|
+
type: 'kdna.context.capsule';
|
|
810
|
+
version: '1.0';
|
|
811
|
+
domain: string | null;
|
|
812
|
+
judgment_version: string | null;
|
|
813
|
+
asset_digest: string;
|
|
814
|
+
signature: { state: 'verified' | 'not_checked' | 'absent'; issuer?: string };
|
|
815
|
+
access: string;
|
|
816
|
+
risk_level: string | null;
|
|
817
|
+
profile: string;
|
|
818
|
+
context: Record<string, any>;
|
|
819
|
+
trace: Record<string, any>;
|
|
820
|
+
extends_chain?: Array<Record<string, any>>;
|
|
821
|
+
inheritance_applied?: boolean;
|
|
822
|
+
resolved_dependencies?: Array<Record<string, any>>;
|
|
823
|
+
rag_isolation_policy?: Record<string, any>;
|
|
824
|
+
[key: string]: any;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
export interface KDNACapsule1Extensions {
|
|
828
|
+
extends_chain?: Array<Record<string, any>>;
|
|
829
|
+
inheritance_applied?: boolean;
|
|
830
|
+
resolved_dependencies?: Array<Record<string, any>>;
|
|
831
|
+
rag_isolation_policy?: Record<string, any>;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
export type KDNADigestComparisonState = 'matched' | 'mismatched' | 'not_compared' | 'unavailable';
|
|
835
|
+
|
|
836
|
+
export type KDNADigestComparisonSource =
|
|
837
|
+
| 'caller'
|
|
838
|
+
| 'registry'
|
|
839
|
+
| 'install_receipt'
|
|
840
|
+
| 'lockfile'
|
|
841
|
+
| 'kdna.json.content_digest'
|
|
842
|
+
| 'kdna.json.authoring.content_digest'
|
|
843
|
+
| 'checksums.json.entry_set_digest'
|
|
844
|
+
| 'checksums.json.asset_digest';
|
|
845
|
+
|
|
846
|
+
export interface KDNADigestComparison {
|
|
847
|
+
state: KDNADigestComparisonState;
|
|
848
|
+
against: 'external_expected' | 'manifest_declaration' | 'checksum_declaration' | null;
|
|
849
|
+
expected: string | null;
|
|
850
|
+
source: KDNADigestComparisonSource | null;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
export interface KDNADigestValue {
|
|
854
|
+
value: string | null;
|
|
855
|
+
basis: string;
|
|
856
|
+
comparison: KDNADigestComparison;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
export interface KDNADigestEvidence {
|
|
860
|
+
profile: 'kdna-capsule-digests-v1';
|
|
861
|
+
asset: KDNADigestValue;
|
|
862
|
+
content: KDNADigestValue;
|
|
863
|
+
runtime_entry_set: KDNADigestValue;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
export interface KDNARuntimeCapsuleV2 {
|
|
867
|
+
type: 'kdna.context.capsule';
|
|
868
|
+
version: '2.0';
|
|
869
|
+
asset: {
|
|
870
|
+
asset_id: string;
|
|
871
|
+
asset_uid: string;
|
|
872
|
+
version: string;
|
|
873
|
+
judgment_version: string;
|
|
874
|
+
};
|
|
875
|
+
digests: KDNADigestEvidence;
|
|
876
|
+
signature: { state: 'verified' | 'not_checked' | 'absent'; issuer?: string };
|
|
877
|
+
access: 'public' | 'licensed' | 'remote';
|
|
878
|
+
risk_level: string | null;
|
|
879
|
+
profile: 'index' | 'compact' | 'scenario' | 'full';
|
|
880
|
+
context: Record<string, any>;
|
|
881
|
+
trace: {
|
|
882
|
+
payload_encoding: 'cbor';
|
|
883
|
+
loaded_by: 'kdna-core';
|
|
884
|
+
loaded_at: string;
|
|
885
|
+
input_kind: 'packaged_file' | 'packaged_bytes';
|
|
886
|
+
runtime_eligible: true;
|
|
887
|
+
schema_valid: true;
|
|
888
|
+
signature_state: 'verified' | 'not_checked' | 'absent';
|
|
889
|
+
profile: 'index' | 'compact' | 'scenario' | 'full';
|
|
890
|
+
};
|
|
891
|
+
compatibility?: {
|
|
892
|
+
capsule_1_domain?: string;
|
|
893
|
+
capsule_1_access?: 'open' | 'protected' | 'runtime';
|
|
894
|
+
capsule_1_extensions?: KDNACapsule1Extensions;
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
export const DIGEST_PROFILE: 'kdna-capsule-digests-v1';
|
|
899
|
+
export const CAPSULE_DIGEST_PROFILE: 'kdna-capsule-jcs-v1';
|
|
900
|
+
export const BASIS: Readonly<{
|
|
901
|
+
asset: 'kdna-container-bytes-v1';
|
|
902
|
+
content: 'kdna-content-tree-v1';
|
|
903
|
+
runtime_entry_set: 'kdna-runtime-entry-set-v1';
|
|
904
|
+
}>;
|
|
905
|
+
export function computeAssetDigest(assetBytes: Uint8Array): string;
|
|
906
|
+
export function computeRuntimeEntrySetDigest(
|
|
907
|
+
manifestBytes: Uint8Array,
|
|
908
|
+
payloadBytes: Uint8Array,
|
|
909
|
+
): string;
|
|
910
|
+
export function computeDigestEvidence(
|
|
911
|
+
input: string | Uint8Array,
|
|
912
|
+
options?: {
|
|
913
|
+
expectedDigests?: Partial<
|
|
914
|
+
Record<
|
|
915
|
+
'asset' | 'content' | 'runtime_entry_set',
|
|
916
|
+
| string
|
|
917
|
+
| {
|
|
918
|
+
value: string;
|
|
919
|
+
source: 'caller' | 'registry' | 'install_receipt' | 'lockfile';
|
|
920
|
+
}
|
|
921
|
+
>
|
|
922
|
+
>;
|
|
923
|
+
/** @deprecated Use expectedDigests.asset. */
|
|
924
|
+
expectedAssetDigest?:
|
|
925
|
+
string | { value: string; source: 'caller' | 'registry' | 'install_receipt' | 'lockfile' };
|
|
926
|
+
},
|
|
927
|
+
): KDNADigestEvidence;
|
|
928
|
+
export function canonicalizeJcs(value: unknown): string;
|
|
929
|
+
export function computeCapsuleDeliveryDigest(
|
|
930
|
+
capsule: KDNARuntimeCapsuleV2 | Record<string, any>,
|
|
931
|
+
): string;
|
|
932
|
+
export function buildCapsuleV2(input: {
|
|
933
|
+
capsule1: KDNARuntimeCapsule;
|
|
934
|
+
manifest: KDNAManifest;
|
|
935
|
+
digests: KDNADigestEvidence;
|
|
936
|
+
inputKind: 'packaged_file' | 'packaged_bytes';
|
|
937
|
+
loadedAt?: string;
|
|
938
|
+
}): KDNARuntimeCapsuleV2;
|
|
939
|
+
export function loadCapsuleV2(
|
|
940
|
+
input: string | Uint8Array,
|
|
941
|
+
options?: {
|
|
942
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full';
|
|
943
|
+
loadedAt?: string;
|
|
944
|
+
expectedDigests?: Partial<
|
|
945
|
+
Record<
|
|
946
|
+
'asset' | 'content' | 'runtime_entry_set',
|
|
947
|
+
| string
|
|
948
|
+
| {
|
|
949
|
+
value: string;
|
|
950
|
+
source: 'caller' | 'registry' | 'install_receipt' | 'lockfile';
|
|
951
|
+
}
|
|
952
|
+
>
|
|
953
|
+
>;
|
|
954
|
+
/** @deprecated Use expectedDigests.asset. */
|
|
955
|
+
expectedAssetDigest?:
|
|
956
|
+
string | { value: string; source: 'caller' | 'registry' | 'install_receipt' | 'lockfile' };
|
|
957
|
+
} & KdnaDecryptOptions,
|
|
958
|
+
): KDNARuntimeCapsuleV2;
|
|
959
|
+
export function adaptCapsuleV2ToV1(capsule: KDNARuntimeCapsuleV2): KDNARuntimeCapsule;
|
|
960
|
+
|
|
961
|
+
export type KDNAJsonValue =
|
|
962
|
+
null | boolean | number | string | KDNAJsonValue[] | { [key: string]: KDNAJsonValue };
|
|
963
|
+
|
|
964
|
+
export interface KDNAExecutionContractValidationError {
|
|
965
|
+
code: string;
|
|
966
|
+
message: string;
|
|
967
|
+
details?: unknown;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
export type KDNAExecutionContractValidationResult =
|
|
971
|
+
| { valid: true; code: null; errors: []; value?: unknown }
|
|
972
|
+
| { valid: false; code: string; errors: KDNAExecutionContractValidationError[] };
|
|
973
|
+
|
|
974
|
+
export class KDNAExecutionContractError extends Error {
|
|
975
|
+
code: string;
|
|
976
|
+
details?: unknown;
|
|
977
|
+
constructor(code: string, message: string, details?: unknown);
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
export interface KDNAExpectedDigestV1 {
|
|
981
|
+
value: string;
|
|
982
|
+
basis: string;
|
|
983
|
+
source:
|
|
984
|
+
| 'caller'
|
|
985
|
+
| 'registry'
|
|
986
|
+
| 'install_receipt'
|
|
987
|
+
| 'lockfile'
|
|
988
|
+
| 'kdna.json.content_digest'
|
|
989
|
+
| 'checksums.json.entry_set_digest'
|
|
990
|
+
| 'checksums.json.asset_digest';
|
|
991
|
+
comparison: 'matched' | 'not_compared';
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
export interface KDNAConsumptionPlanV1 {
|
|
995
|
+
type: 'kdna.consumption.plan';
|
|
996
|
+
plan_version: '1.0.0';
|
|
997
|
+
plan_id: string;
|
|
998
|
+
created_at: string;
|
|
999
|
+
mode: 'single';
|
|
1000
|
+
task: { summary: string; task_family: string | null; context: KDNAJsonValue };
|
|
1001
|
+
asset_ref: {
|
|
1002
|
+
asset_id: string;
|
|
1003
|
+
asset_uid: string;
|
|
1004
|
+
version: string;
|
|
1005
|
+
judgment_version: string;
|
|
1006
|
+
access: 'public' | 'licensed' | 'remote';
|
|
1007
|
+
expected_digests: {
|
|
1008
|
+
asset: KDNAExpectedDigestV1 | null;
|
|
1009
|
+
content: KDNAExpectedDigestV1 | null;
|
|
1010
|
+
runtime_entry_set: KDNAExpectedDigestV1 | null;
|
|
1011
|
+
};
|
|
1012
|
+
};
|
|
1013
|
+
projection_request: {
|
|
1014
|
+
profile: 'index' | 'compact' | 'scenario' | 'full';
|
|
1015
|
+
accepted_capsule_versions: ['2.0'];
|
|
1016
|
+
required_digest_profile: 'kdna-capsule-digests-v1';
|
|
1017
|
+
require_packaged_asset: true;
|
|
1018
|
+
};
|
|
1019
|
+
host_request: { accepted_protocols: ['kdna.agent-host/2'] };
|
|
1020
|
+
result_request: { shape: 'structured_judgment' };
|
|
1021
|
+
budget: KDNAExecutionBudgetV1;
|
|
1022
|
+
constraints: { enforce_before_host: true; reject_on_exceed: true };
|
|
1023
|
+
trace_policy: { emit: true; storage: 'ephemeral' | 'session' | 'persistent' };
|
|
1024
|
+
integrity: { profile: 'kdna-consumption-plan-jcs-v1'; plan_digest: string };
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
export interface KDNAExecutionBudgetV1 {
|
|
1028
|
+
max_projection_chars: number;
|
|
1029
|
+
max_task_chars: number;
|
|
1030
|
+
deadline_ms: number;
|
|
1031
|
+
max_tokens: number | null;
|
|
1032
|
+
max_model_calls: number | null;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
export interface KDNAAgentHostCapabilitiesV1 {
|
|
1036
|
+
type: 'kdna.agent-host.capabilities';
|
|
1037
|
+
version: '1.0';
|
|
1038
|
+
capability_basis: 'registered_descriptor' | 'legacy_assumption';
|
|
1039
|
+
host_protocols: string[];
|
|
1040
|
+
capsule_versions: string[];
|
|
1041
|
+
capsule_digest_profiles: string[];
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
export interface KDNAAgentHost2RequestV1 {
|
|
1045
|
+
protocol: 'kdna.agent-host/2';
|
|
1046
|
+
request_id: string;
|
|
1047
|
+
plan_ref: {
|
|
1048
|
+
plan_id: string;
|
|
1049
|
+
plan_digest_profile: 'kdna-consumption-plan-jcs-v1';
|
|
1050
|
+
plan_digest: string;
|
|
1051
|
+
};
|
|
1052
|
+
runtime_contract: {
|
|
1053
|
+
capsule_version: '2.0';
|
|
1054
|
+
capsule_digest_profile: 'kdna-capsule-jcs-v1';
|
|
1055
|
+
capsule_delivery_digest: string;
|
|
1056
|
+
};
|
|
1057
|
+
projection_contract: KDNAConsumptionPlanV1['projection_request'] extends infer T
|
|
1058
|
+
? Omit<Extract<T, object>, 'accepted_capsule_versions'>
|
|
1059
|
+
: never;
|
|
1060
|
+
result_contract: { shape: 'structured_judgment' };
|
|
1061
|
+
budget: KDNAExecutionBudgetV1;
|
|
1062
|
+
constraints: KDNAConsumptionPlanV1['constraints'];
|
|
1063
|
+
phase: 'single_judgment';
|
|
1064
|
+
task: KDNAConsumptionPlanV1['task'];
|
|
1065
|
+
authority: { asset_id: string; role: 'primary'; final_decision: true };
|
|
1066
|
+
asset: KDNAConsumptionPlanV1['asset_ref'] & { role: 'primary' };
|
|
1067
|
+
capsule: KDNARuntimeCapsuleV2;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
export interface KDNAAgentHost2ReceiptV1 {
|
|
1071
|
+
protocol: 'kdna.agent-host/2';
|
|
1072
|
+
request_id: string;
|
|
1073
|
+
runtime_receipt: {
|
|
1074
|
+
type: 'kdna.agent-host.runtime-receipt';
|
|
1075
|
+
receipt_version: '1.0.0';
|
|
1076
|
+
capsule_version: '2.0';
|
|
1077
|
+
capsule_digest_profile: 'kdna-capsule-jcs-v1';
|
|
1078
|
+
sender_capsule_delivery_digest: string;
|
|
1079
|
+
host_recomputed_capsule_delivery_digest: string;
|
|
1080
|
+
echoed_capsule_delivery_digest: string;
|
|
1081
|
+
capsule_delivery_comparison: 'matched' | 'mismatched';
|
|
1082
|
+
capsule_schema_validation: 'passed';
|
|
1083
|
+
asset_id_correlation: 'matched';
|
|
1084
|
+
provider_execution_status: 'completed' | 'not_started' | 'failed' | 'cancelled' | 'timed_out';
|
|
1085
|
+
semantic_consumption: { state: 'not_observed'; basis: null };
|
|
1086
|
+
model_identity: { value: string | null; basis: 'host_reported' | 'not_observed' };
|
|
1087
|
+
usage: {
|
|
1088
|
+
elapsed_ms: number;
|
|
1089
|
+
elapsed_basis: 'host_monotonic';
|
|
1090
|
+
tokens_used: number | null;
|
|
1091
|
+
model_calls: number | null;
|
|
1092
|
+
basis: 'host_reported' | 'not_observed';
|
|
1093
|
+
};
|
|
1094
|
+
};
|
|
1095
|
+
outcome: {
|
|
1096
|
+
judgment: { answer: string; reasoning: string[]; confidence: string | null };
|
|
1097
|
+
usage: { tokens_used: number; model_calls: number } | null;
|
|
1098
|
+
} | null;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
export interface KDNABudgetEvidenceV1 {
|
|
1102
|
+
limits: KDNAExecutionBudgetV1;
|
|
1103
|
+
actual: {
|
|
1104
|
+
projection_chars: number | null;
|
|
1105
|
+
task_chars: number;
|
|
1106
|
+
elapsed_ms: number | null;
|
|
1107
|
+
elapsed_basis: 'host_monotonic' | 'not_observed';
|
|
1108
|
+
tokens_used: number | null;
|
|
1109
|
+
model_calls: number | null;
|
|
1110
|
+
usage_basis: 'host_reported' | 'not_observed';
|
|
1111
|
+
};
|
|
1112
|
+
comparison: {
|
|
1113
|
+
projection_chars: 'within_limit' | 'exceeded' | 'not_observed';
|
|
1114
|
+
task_chars: 'within_limit' | 'exceeded';
|
|
1115
|
+
elapsed_ms: 'within_limit' | 'exceeded' | 'not_observed';
|
|
1116
|
+
tokens_used: 'within_limit' | 'exceeded' | 'not_limited' | 'not_observed';
|
|
1117
|
+
model_calls: 'within_limit' | 'exceeded' | 'not_limited' | 'not_observed';
|
|
1118
|
+
overall: 'within_limit' | 'exceeded' | 'not_observed';
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
export interface KDNAJudgmentTraceIssueV1 {
|
|
1123
|
+
code: string;
|
|
1124
|
+
message: string;
|
|
1125
|
+
phase: 'plan' | 'negotiation' | 'load' | 'budget' | 'delivery' | 'host' | 'execution';
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
export interface KDNAJudgmentTraceV1 {
|
|
1129
|
+
type: 'kdna.judgment.trace';
|
|
1130
|
+
trace_version: '1.0.0';
|
|
1131
|
+
trace_id: string;
|
|
1132
|
+
plan_ref: {
|
|
1133
|
+
plan_id: string;
|
|
1134
|
+
plan_digest_profile: 'kdna-consumption-plan-jcs-v1';
|
|
1135
|
+
plan_digest: string;
|
|
1136
|
+
comparison: 'matched';
|
|
1137
|
+
};
|
|
1138
|
+
parent_trace_id: string | null;
|
|
1139
|
+
timestamp: string;
|
|
1140
|
+
overall_status:
|
|
1141
|
+
'execution_completed' | 'blocked' | 'execution_failed' | 'cancelled' | 'timed_out';
|
|
1142
|
+
runtime_contract: {
|
|
1143
|
+
plan_capsule_versions: ['2.0'];
|
|
1144
|
+
core_capsule_versions: Array<'2.0' | '1.0'>;
|
|
1145
|
+
plan_host_protocols: ['kdna.agent-host/2'];
|
|
1146
|
+
host_capabilities: KDNAAgentHostCapabilitiesV1;
|
|
1147
|
+
negotiation_state: 'selected' | 'blocked' | 'not_started';
|
|
1148
|
+
selected_capsule_version: '2.0' | null;
|
|
1149
|
+
selected_host_protocol: 'kdna.agent-host/2' | null;
|
|
1150
|
+
issue_code:
|
|
1151
|
+
| 'KDNA_CAPSULE_VERSION_UNSUPPORTED'
|
|
1152
|
+
| 'KDNA_HOST_PROTOCOL_UNSUPPORTED'
|
|
1153
|
+
| 'KDNA_HOST_CAPSULE_PAIR_UNSUPPORTED'
|
|
1154
|
+
| null;
|
|
1155
|
+
};
|
|
1156
|
+
asset_identity: {
|
|
1157
|
+
asset_id: string;
|
|
1158
|
+
asset_uid: string;
|
|
1159
|
+
version: string;
|
|
1160
|
+
judgment_version: string;
|
|
1161
|
+
access: 'public' | 'licensed' | 'remote';
|
|
1162
|
+
};
|
|
1163
|
+
digest_evidence: KDNADigestEvidence;
|
|
1164
|
+
capsule_delivery_evidence: {
|
|
1165
|
+
basis: 'kdna-capsule-jcs-v1';
|
|
1166
|
+
observed: string | null;
|
|
1167
|
+
sender_computed: boolean;
|
|
1168
|
+
host_recomputed: string | null;
|
|
1169
|
+
host_echoed: string | null;
|
|
1170
|
+
delivered_capsule_version: '2.0' | null;
|
|
1171
|
+
host_boundary_comparison:
|
|
1172
|
+
'matched' | 'mismatched' | 'not_delivered' | 'not_observed' | 'unavailable';
|
|
1173
|
+
request_id: string | null;
|
|
1174
|
+
};
|
|
1175
|
+
projection_actual: {
|
|
1176
|
+
profile: 'index' | 'compact' | 'scenario' | 'full' | null;
|
|
1177
|
+
capsule_delivery_digest: string | null;
|
|
1178
|
+
profile_deviated_from_plan: boolean | null;
|
|
1179
|
+
};
|
|
1180
|
+
host_receipt: KDNAAgentHost2ReceiptV1 | null;
|
|
1181
|
+
execution: {
|
|
1182
|
+
delivery_status: 'correlated_response' | 'rejected_before_execution' | 'not_delivered';
|
|
1183
|
+
semantic_consumption: { state: 'not_observed'; basis: null };
|
|
1184
|
+
execution_status: 'completed' | 'not_started' | 'failed' | 'cancelled' | 'timed_out';
|
|
1185
|
+
conformance_status: 'not_evaluated';
|
|
1186
|
+
model_identity: { value: string | null; basis: 'host_reported' | 'not_observed' };
|
|
1187
|
+
};
|
|
1188
|
+
budget: KDNABudgetEvidenceV1;
|
|
1189
|
+
result_ref: {
|
|
1190
|
+
shape: 'structured_judgment';
|
|
1191
|
+
result_digest: string;
|
|
1192
|
+
basis: 'kdna-result-jcs-v1';
|
|
1193
|
+
stored: boolean;
|
|
1194
|
+
} | null;
|
|
1195
|
+
errors: KDNAJudgmentTraceIssueV1[];
|
|
601
1196
|
warnings: string[];
|
|
602
|
-
asset: KdnaAssetVerifyResult;
|
|
603
|
-
lint: LintResult;
|
|
604
|
-
schema: ValidationResult;
|
|
605
|
-
cross_file: ValidationResult;
|
|
606
1197
|
}
|
|
607
1198
|
|
|
1199
|
+
export interface KDNAExecutionPairContextV1 {
|
|
1200
|
+
trustedPlanDigest: string;
|
|
1201
|
+
capabilities: KDNAAgentHostCapabilitiesV1;
|
|
1202
|
+
coreCapsuleVersions: readonly string[];
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
export interface KDNAHost2ValidationContextV1 extends KDNAExecutionPairContextV1 {
|
|
1206
|
+
plan: KDNAConsumptionPlanV1;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
export interface KDNAJudgmentTraceContextV1 extends KDNAHost2ValidationContextV1 {
|
|
1210
|
+
request: KDNAAgentHost2RequestV1 | null;
|
|
1211
|
+
receipt: KDNAAgentHost2ReceiptV1 | null;
|
|
1212
|
+
trustedDeliveryObservation: 'host_receipt' | 'not_delivered' | 'not_observed';
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
export interface KDNAPreHostBudgetBlockedTraceContextV1
|
|
1216
|
+
extends KDNAHost2ValidationContextV1 {
|
|
1217
|
+
capsule: KDNARuntimeCapsuleV2;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
export const PLAN_DIGEST_PROFILE: 'kdna-consumption-plan-jcs-v1';
|
|
1221
|
+
export const HOST_PROTOCOL: 'kdna.agent-host/2';
|
|
1222
|
+
export const DEFAULT_CORE_CAPSULE_VERSIONS: readonly ['2.0', '1.0'];
|
|
1223
|
+
export function parseExecutionContractJsonV1(
|
|
1224
|
+
input: string | Uint8Array,
|
|
1225
|
+
options?: { maxBytes?: number; maxDepth?: number },
|
|
1226
|
+
): KDNAJsonValue;
|
|
1227
|
+
export function computeConsumptionPlanDigestV1(plan: KDNAConsumptionPlanV1): string;
|
|
1228
|
+
export function buildConsumptionPlanV1(input: {
|
|
1229
|
+
plan_id: string;
|
|
1230
|
+
created_at: string;
|
|
1231
|
+
task: KDNAConsumptionPlanV1['task'];
|
|
1232
|
+
asset_ref: KDNAConsumptionPlanV1['asset_ref'];
|
|
1233
|
+
projection_profile: KDNAConsumptionPlanV1['projection_request']['profile'];
|
|
1234
|
+
budget: KDNAExecutionBudgetV1;
|
|
1235
|
+
constraints: KDNAConsumptionPlanV1['constraints'];
|
|
1236
|
+
trace_policy: KDNAConsumptionPlanV1['trace_policy'];
|
|
1237
|
+
}): KDNAConsumptionPlanV1;
|
|
1238
|
+
export function validateConsumptionPlanV1(
|
|
1239
|
+
plan: unknown,
|
|
1240
|
+
context: { trustedPlanDigest: string },
|
|
1241
|
+
): KDNAExecutionContractValidationResult;
|
|
1242
|
+
export function negotiateExecutionPairV1(
|
|
1243
|
+
plan: KDNAConsumptionPlanV1,
|
|
1244
|
+
context: KDNAExecutionPairContextV1,
|
|
1245
|
+
): {
|
|
1246
|
+
state: 'selected' | 'blocked';
|
|
1247
|
+
capsule_version: '2.0' | null;
|
|
1248
|
+
host_protocol: 'kdna.agent-host/2' | null;
|
|
1249
|
+
issue_code: string | null;
|
|
1250
|
+
};
|
|
1251
|
+
export function buildAgentHost2RequestV1(
|
|
1252
|
+
input: { request_id: string; capsule: KDNARuntimeCapsuleV2 },
|
|
1253
|
+
context: KDNAHost2ValidationContextV1,
|
|
1254
|
+
): KDNAAgentHost2RequestV1;
|
|
1255
|
+
export function validateAgentHost2RequestV1(
|
|
1256
|
+
request: unknown,
|
|
1257
|
+
context: KDNAHost2ValidationContextV1,
|
|
1258
|
+
): KDNAExecutionContractValidationResult;
|
|
1259
|
+
export function validateAgentHost2ReceiptV1(
|
|
1260
|
+
receipt: unknown,
|
|
1261
|
+
context: { request: KDNAAgentHost2RequestV1 },
|
|
1262
|
+
): KDNAExecutionContractValidationResult;
|
|
1263
|
+
export function deriveBudgetEvidenceV1(
|
|
1264
|
+
plan: KDNAConsumptionPlanV1,
|
|
1265
|
+
context: {
|
|
1266
|
+
trustedPlanDigest: string;
|
|
1267
|
+
request: KDNAAgentHost2RequestV1 | null;
|
|
1268
|
+
receipt: KDNAAgentHost2ReceiptV1 | null;
|
|
1269
|
+
},
|
|
1270
|
+
): KDNABudgetEvidenceV1;
|
|
1271
|
+
export function buildPreHostBudgetBlockedTraceV1(
|
|
1272
|
+
input: {
|
|
1273
|
+
trace_id: string;
|
|
1274
|
+
timestamp: string;
|
|
1275
|
+
capsule: KDNARuntimeCapsuleV2;
|
|
1276
|
+
parent_trace_id?: string | null;
|
|
1277
|
+
warnings?: string[];
|
|
1278
|
+
},
|
|
1279
|
+
context: KDNAHost2ValidationContextV1,
|
|
1280
|
+
): KDNAJudgmentTraceV1;
|
|
1281
|
+
export function validatePreHostBudgetBlockedTraceV1(
|
|
1282
|
+
trace: unknown,
|
|
1283
|
+
context: KDNAPreHostBudgetBlockedTraceContextV1,
|
|
1284
|
+
): KDNAExecutionContractValidationResult;
|
|
1285
|
+
export function buildJudgmentTraceV1(
|
|
1286
|
+
input: {
|
|
1287
|
+
trace_id: string;
|
|
1288
|
+
timestamp: string;
|
|
1289
|
+
overall_status: KDNAJudgmentTraceV1['overall_status'];
|
|
1290
|
+
parent_trace_id?: string | null;
|
|
1291
|
+
result_stored?: boolean;
|
|
1292
|
+
errors?: KDNAJudgmentTraceIssueV1[];
|
|
1293
|
+
warnings?: string[];
|
|
1294
|
+
},
|
|
1295
|
+
context: KDNAJudgmentTraceContextV1,
|
|
1296
|
+
): KDNAJudgmentTraceV1;
|
|
1297
|
+
export function validateJudgmentTraceV1(
|
|
1298
|
+
trace: unknown,
|
|
1299
|
+
context: KDNAJudgmentTraceContextV1,
|
|
1300
|
+
): KDNAExecutionContractValidationResult;
|
|
1301
|
+
|
|
608
1302
|
export interface KDNAMatchResult extends KDNAInspectResult {
|
|
609
1303
|
score: number;
|
|
610
1304
|
matched: string[];
|
|
@@ -623,45 +1317,157 @@ export interface KDNAComposeResult {
|
|
|
623
1317
|
|
|
624
1318
|
export function openKDNA(input: KDNAAssetInput): Promise<KdnaAsset>;
|
|
625
1319
|
export function openKDNASync(input: KDNAAssetInput): KdnaAsset;
|
|
626
|
-
export function inspectKDNA(
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
export function
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
export function
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
export function
|
|
642
|
-
|
|
1320
|
+
export function inspectKDNA(
|
|
1321
|
+
input: KDNAAssetInput,
|
|
1322
|
+
options?: { verify?: boolean } & KdnaDecryptOptions,
|
|
1323
|
+
): Promise<KDNAInspectResult>;
|
|
1324
|
+
export function inspectKDNASync(
|
|
1325
|
+
input: KDNAAssetInput,
|
|
1326
|
+
options?: { verify?: boolean } & KdnaDecryptOptions,
|
|
1327
|
+
): KDNAInspectResult;
|
|
1328
|
+
export function loadKDNA(
|
|
1329
|
+
input: KDNAAssetInput,
|
|
1330
|
+
options?: {
|
|
1331
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full' | string;
|
|
1332
|
+
as?: 'json' | 'prompt' | string;
|
|
1333
|
+
} & KdnaDecryptOptions,
|
|
1334
|
+
): Promise<KDNARuntimeCapsule | Record<string, any>>;
|
|
1335
|
+
export function loadKDNASync(
|
|
1336
|
+
input: KDNAAssetInput,
|
|
1337
|
+
options?: {
|
|
1338
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full' | string;
|
|
1339
|
+
as?: 'json' | 'prompt' | string;
|
|
1340
|
+
} & KdnaDecryptOptions,
|
|
1341
|
+
): KDNARuntimeCapsule | Record<string, any>;
|
|
1342
|
+
export function validateKDNA(
|
|
1343
|
+
input: KDNAAssetInput,
|
|
1344
|
+
options?: Record<string, any>,
|
|
1345
|
+
): Promise<KDNAValidationReport>;
|
|
1346
|
+
export function validateKDNASync(
|
|
1347
|
+
input: KDNAAssetInput,
|
|
1348
|
+
options?: Record<string, any>,
|
|
1349
|
+
): KDNAValidationReport;
|
|
1350
|
+
export function renderForAgent(
|
|
1351
|
+
input: KDNAAssetInput,
|
|
1352
|
+
options?: {
|
|
1353
|
+
profile?: 'compact' | 'scenario' | 'full' | string;
|
|
1354
|
+
input?: string;
|
|
1355
|
+
} & KdnaDecryptOptions,
|
|
1356
|
+
): Promise<string>;
|
|
1357
|
+
export function renderForAgentSync(
|
|
1358
|
+
input: KDNAAssetInput,
|
|
1359
|
+
options?: {
|
|
1360
|
+
profile?: 'compact' | 'scenario' | 'full' | string;
|
|
1361
|
+
input?: string;
|
|
1362
|
+
} & KdnaDecryptOptions,
|
|
1363
|
+
): string;
|
|
1364
|
+
export function verifyAsset(
|
|
1365
|
+
input: KDNAAssetInput,
|
|
1366
|
+
options?: {
|
|
1367
|
+
asset_digest?: string;
|
|
1368
|
+
content_digest?: string;
|
|
1369
|
+
requireSignature?: boolean;
|
|
1370
|
+
requireDecryption?: boolean;
|
|
1371
|
+
} & KdnaDecryptOptions,
|
|
1372
|
+
): Promise<KdnaAssetVerifyResult>;
|
|
1373
|
+
export function verifyAssetSync(
|
|
1374
|
+
input: KDNAAssetInput,
|
|
1375
|
+
options?: {
|
|
1376
|
+
asset_digest?: string;
|
|
1377
|
+
content_digest?: string;
|
|
1378
|
+
requireSignature?: boolean;
|
|
1379
|
+
requireDecryption?: boolean;
|
|
1380
|
+
} & KdnaDecryptOptions,
|
|
1381
|
+
): KdnaAssetVerifyResult;
|
|
1382
|
+
export function verifyDigest(
|
|
1383
|
+
input: KDNAAssetInput,
|
|
1384
|
+
expectedDigest: string,
|
|
1385
|
+
options?: KdnaDecryptOptions,
|
|
1386
|
+
): Promise<KdnaAssetVerifyResult>;
|
|
1387
|
+
export function verifyDigestSync(
|
|
1388
|
+
input: KDNAAssetInput,
|
|
1389
|
+
expectedDigest: string,
|
|
1390
|
+
options?: KdnaDecryptOptions,
|
|
1391
|
+
): KdnaAssetVerifyResult;
|
|
1392
|
+
export function verifySignature(
|
|
1393
|
+
input: KDNAAssetInput,
|
|
1394
|
+
options?: KdnaDecryptOptions,
|
|
1395
|
+
): Promise<KdnaAssetVerifyResult>;
|
|
1396
|
+
export function verifySignatureSync(
|
|
1397
|
+
input: KDNAAssetInput,
|
|
1398
|
+
options?: KdnaDecryptOptions,
|
|
1399
|
+
): KdnaAssetVerifyResult;
|
|
1400
|
+
export function matchDomain(
|
|
1401
|
+
input: string,
|
|
1402
|
+
candidates: Array<KDNAAssetInput | KDNAInspectResult>,
|
|
1403
|
+
options?: KdnaDecryptOptions,
|
|
1404
|
+
): Promise<KDNAMatchResult[]>;
|
|
1405
|
+
export function matchDomainSync(
|
|
1406
|
+
input: string,
|
|
1407
|
+
candidates: Array<KDNAAssetInput | KDNAInspectResult>,
|
|
1408
|
+
options?: KdnaDecryptOptions,
|
|
1409
|
+
): KDNAMatchResult[];
|
|
1410
|
+
/**
|
|
1411
|
+
* @deprecated Current Cluster/Capsule composition semantics are not yet
|
|
1412
|
+
* defined. This function rejects with KDNA_COMPOSE_PROTOCOL_UNAVAILABLE.
|
|
1413
|
+
*/
|
|
1414
|
+
export function composeKDNA(
|
|
1415
|
+
inputs: KDNAAssetInput[],
|
|
1416
|
+
options?: {
|
|
1417
|
+
input?: string;
|
|
1418
|
+
profile?: 'compact' | 'scenario' | 'full' | string;
|
|
1419
|
+
separator?: string;
|
|
1420
|
+
} & KdnaDecryptOptions,
|
|
1421
|
+
): Promise<never>;
|
|
643
1422
|
|
|
644
1423
|
// KDNA Core — authoring source and packaged runtime API
|
|
645
1424
|
export const MIMETYPE: string;
|
|
646
1425
|
export const REQUIRED_DIR_ENTRIES: string[];
|
|
647
1426
|
|
|
1427
|
+
export interface KDNALayoutEntry {
|
|
1428
|
+
name: string;
|
|
1429
|
+
data: Uint8Array;
|
|
1430
|
+
method: number;
|
|
1431
|
+
[key: string]: unknown;
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
export interface KDNALayout {
|
|
1435
|
+
kind: 'dir' | 'file' | 'memory';
|
|
1436
|
+
map: Record<string, Uint8Array | null>;
|
|
1437
|
+
manifest: KDNAManifest;
|
|
1438
|
+
entries: KDNALayoutEntry[] | null;
|
|
1439
|
+
containerDigest: string | null;
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
export function readLayout(inputPath: string): KDNALayout;
|
|
1443
|
+
|
|
648
1444
|
export interface KDNAChecksumEntry {
|
|
649
1445
|
algorithm: 'sha256';
|
|
650
1446
|
value: string;
|
|
651
1447
|
}
|
|
652
1448
|
|
|
653
1449
|
export interface KDNAChecksums {
|
|
1450
|
+
digest_profile?: 'kdna-runtime-entry-set-v1';
|
|
1451
|
+
covered_entries?: ['kdna.json', 'payload.kdnab'];
|
|
654
1452
|
algorithm: 'sha256';
|
|
655
|
-
manifest_digest
|
|
656
|
-
payload_digest
|
|
657
|
-
|
|
658
|
-
|
|
1453
|
+
manifest_digest?: string;
|
|
1454
|
+
payload_digest?: string;
|
|
1455
|
+
entry_set_digest?: string;
|
|
1456
|
+
/** @deprecated Use entry_set_digest. This is not the final .kdna file digest. */
|
|
1457
|
+
asset_digest?: string;
|
|
1458
|
+
entries?: Record<string, KDNAChecksumEntry>;
|
|
659
1459
|
}
|
|
660
1460
|
|
|
661
1461
|
export function isKdnaSourceDir(inputPath: string): boolean;
|
|
662
1462
|
export function detectContainerFormat(inputPath: string): 'kdna' | null;
|
|
663
|
-
export function inspect(
|
|
664
|
-
|
|
1463
|
+
export function inspect(
|
|
1464
|
+
input: string | Uint8Array,
|
|
1465
|
+
options?: Record<string, any>,
|
|
1466
|
+
): Record<string, any>;
|
|
1467
|
+
export function validate(
|
|
1468
|
+
input: string | Uint8Array,
|
|
1469
|
+
options?: Record<string, any>,
|
|
1470
|
+
): KDNAValidationReport;
|
|
665
1471
|
export interface KDNALoadPlanIssue {
|
|
666
1472
|
code: string;
|
|
667
1473
|
severity: 'info' | 'warning' | 'blocking' | string;
|
|
@@ -708,24 +1514,79 @@ export interface KDNALoadPlan {
|
|
|
708
1514
|
checks: Record<string, boolean>;
|
|
709
1515
|
issues: KDNALoadPlanIssue[];
|
|
710
1516
|
source: {
|
|
711
|
-
kind: 'dir' | 'file' | string | null;
|
|
712
|
-
path: string;
|
|
1517
|
+
kind: 'dir' | 'file' | 'memory' | string | null;
|
|
1518
|
+
path: string | null;
|
|
713
1519
|
};
|
|
714
1520
|
}
|
|
715
|
-
export function planLoad(
|
|
1521
|
+
export function planLoad(
|
|
1522
|
+
input: string | Uint8Array,
|
|
1523
|
+
options?: {
|
|
1524
|
+
password?: string;
|
|
1525
|
+
hasPassword?: boolean;
|
|
1526
|
+
entitlement?: KDNAVerifiedExternalEntitlement | Record<string, any>;
|
|
1527
|
+
},
|
|
1528
|
+
): KDNALoadPlan;
|
|
716
1529
|
export function buildChecksums(sourceDir: string): KDNAChecksums;
|
|
717
1530
|
export function pack(sourceDir: string, outputPath: string): void;
|
|
718
1531
|
export function unpack(inputPath: string, outputDir: string): void;
|
|
719
|
-
export function loadAuthorized(
|
|
720
|
-
|
|
721
|
-
|
|
1532
|
+
export function loadAuthorized(
|
|
1533
|
+
input: string | Uint8Array,
|
|
1534
|
+
options?: {
|
|
1535
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full' | string;
|
|
1536
|
+
as?: 'json' | 'prompt' | string;
|
|
1537
|
+
},
|
|
1538
|
+
): KDNARuntimeCapsule | Record<string, any>;
|
|
1539
|
+
export function load(
|
|
1540
|
+
input: string | Uint8Array,
|
|
1541
|
+
options?: {
|
|
1542
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full' | string;
|
|
1543
|
+
as?: 'json' | 'prompt' | string;
|
|
1544
|
+
},
|
|
1545
|
+
): KDNARuntimeCapsule | Record<string, any>;
|
|
1546
|
+
export function loadAsset(
|
|
1547
|
+
input: string | Uint8Array,
|
|
1548
|
+
options?: {
|
|
1549
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full' | string;
|
|
1550
|
+
as?: 'json' | 'prompt' | string;
|
|
1551
|
+
},
|
|
1552
|
+
): KDNARuntimeCapsule | Record<string, any>;
|
|
1553
|
+
export function buildCapsule(
|
|
1554
|
+
loadResult: {
|
|
1555
|
+
profile: string;
|
|
1556
|
+
content?: Record<string, unknown>;
|
|
1557
|
+
extends_chain?: unknown[];
|
|
1558
|
+
inheritance_applied?: boolean;
|
|
1559
|
+
resolved_dependencies?: unknown[];
|
|
1560
|
+
rag_isolation_policy?: Record<string, unknown>;
|
|
1561
|
+
[key: string]: unknown;
|
|
1562
|
+
},
|
|
1563
|
+
layout: KDNALayout,
|
|
1564
|
+
profile: string,
|
|
1565
|
+
options?: {
|
|
1566
|
+
_validation?: { schema_valid?: boolean; signature_valid?: boolean | null };
|
|
1567
|
+
},
|
|
1568
|
+
): KDNARuntimeCapsule;
|
|
722
1569
|
export const FORBIDDEN_OUTPUT_TERMS: readonly string[];
|
|
723
1570
|
|
|
1571
|
+
export interface KDNASemver {
|
|
1572
|
+
major: number;
|
|
1573
|
+
minor: number;
|
|
1574
|
+
patch: number;
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
export function parseSemver(version: string): KDNASemver | null;
|
|
1578
|
+
export function compareSemver(left: string, right: string): number;
|
|
1579
|
+
export function satisfies(version: string, range: string): boolean;
|
|
1580
|
+
|
|
724
1581
|
// Lint
|
|
725
1582
|
export function lintDomain(dataMap: KDNAFileDataMap): LintResult;
|
|
1583
|
+
export function validateManifest(manifest: unknown): LintResult;
|
|
726
1584
|
|
|
727
1585
|
// Validate
|
|
728
|
-
export function validateDomainSchema(
|
|
1586
|
+
export function validateDomainSchema(
|
|
1587
|
+
dataMap: KDNAFileDataMap,
|
|
1588
|
+
schemaMap?: Record<string, any>,
|
|
1589
|
+
): ValidationResult;
|
|
729
1590
|
export function validateCrossFile(dataMap: KDNAFileDataMap): ValidationResult;
|
|
730
1591
|
|
|
731
1592
|
// Render
|
|
@@ -735,6 +1596,213 @@ export function renderCard(title: string, count: number | undefined, items: stri
|
|
|
735
1596
|
|
|
736
1597
|
// Compose
|
|
737
1598
|
export function composeContext(domains: LoadedDomain[], options?: { separator?: string }): string;
|
|
738
|
-
export function classifySignals(
|
|
739
|
-
|
|
740
|
-
|
|
1599
|
+
export function classifySignals(
|
|
1600
|
+
input: string,
|
|
1601
|
+
domains: Array<{ id: string; core: { trigger_signals?: string[] } }>,
|
|
1602
|
+
): number[];
|
|
1603
|
+
export function composeChecks(
|
|
1604
|
+
domains: Array<{
|
|
1605
|
+
id: string;
|
|
1606
|
+
core: { meta: { domain: string } };
|
|
1607
|
+
patterns: { self_check: string[] };
|
|
1608
|
+
}>,
|
|
1609
|
+
): string[];
|
|
1610
|
+
export function loadAndCompose(
|
|
1611
|
+
dataMaps: KDNAFileDataMap[],
|
|
1612
|
+
options?: LoadOptions & { separator?: string },
|
|
1613
|
+
): { domains: LoadedDomain[]; context: string; activeIndices: number[] };
|
|
1614
|
+
|
|
1615
|
+
export interface KDNAComposableAxiom {
|
|
1616
|
+
id: string;
|
|
1617
|
+
one_sentence: string;
|
|
1618
|
+
applies_when?: string[];
|
|
1619
|
+
does_not_apply_when?: string[];
|
|
1620
|
+
failure_risk?: string;
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
export interface KDNAComposableDomain {
|
|
1624
|
+
id: string;
|
|
1625
|
+
name?: string;
|
|
1626
|
+
role?: string;
|
|
1627
|
+
required?: boolean;
|
|
1628
|
+
core: {
|
|
1629
|
+
meta?: { domain?: string };
|
|
1630
|
+
axioms?: KDNAComposableAxiom[];
|
|
1631
|
+
stances?: Array<string | { stance: string }>;
|
|
1632
|
+
trigger_signals?: string[];
|
|
1633
|
+
negative_signals?: string[];
|
|
1634
|
+
[key: string]: unknown;
|
|
1635
|
+
};
|
|
1636
|
+
patterns?: {
|
|
1637
|
+
misunderstandings?: Array<{
|
|
1638
|
+
id: string;
|
|
1639
|
+
wrong: string;
|
|
1640
|
+
correct: string;
|
|
1641
|
+
failure_risk?: string;
|
|
1642
|
+
}>;
|
|
1643
|
+
terminology?: {
|
|
1644
|
+
banned_terms?: Array<string | { term: string; replace_with?: string }>;
|
|
1645
|
+
};
|
|
1646
|
+
self_check?: Array<string | { question: string }>;
|
|
1647
|
+
[key: string]: unknown;
|
|
1648
|
+
};
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
export interface KDNAAttribution {
|
|
1652
|
+
domain: string;
|
|
1653
|
+
type: 'axiom' | 'misunderstanding' | 'banned_term' | 'self_check';
|
|
1654
|
+
index: number;
|
|
1655
|
+
id?: string;
|
|
1656
|
+
term?: string;
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
export function composeContextWithAttribution(
|
|
1660
|
+
domains: KDNAComposableDomain[],
|
|
1661
|
+
options?: { separator?: string },
|
|
1662
|
+
): { context: string; attributionMap: Record<string, KDNAAttribution> };
|
|
1663
|
+
|
|
1664
|
+
export interface KDNADomainSelection {
|
|
1665
|
+
id: string;
|
|
1666
|
+
name?: string;
|
|
1667
|
+
role?: string;
|
|
1668
|
+
reason: 'required' | 'signal_match' | 'blocked by does_not_apply_when' | 'no signal match';
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
export function classifySignalsAcrossDomains(
|
|
1672
|
+
input: string,
|
|
1673
|
+
domainEntries: KDNAComposableDomain[],
|
|
1674
|
+
): { selected: KDNADomainSelection[]; excluded: KDNADomainSelection[] };
|
|
1675
|
+
|
|
1676
|
+
export interface KDNAClusterManifest {
|
|
1677
|
+
domains?: Array<{ id: string; role?: string; required?: boolean }>;
|
|
1678
|
+
[key: string]: unknown;
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
export interface KDNALoadedClusterDomain extends KDNAComposableDomain {
|
|
1682
|
+
name: string;
|
|
1683
|
+
role: string;
|
|
1684
|
+
required: boolean;
|
|
1685
|
+
patterns: NonNullable<KDNAComposableDomain['patterns']>;
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
export function loadCluster(
|
|
1689
|
+
clusterManifestPath: string,
|
|
1690
|
+
domainLoader: (domainId: string) => {
|
|
1691
|
+
core: KDNAComposableDomain['core'];
|
|
1692
|
+
patterns: NonNullable<KDNAComposableDomain['patterns']>;
|
|
1693
|
+
} | null,
|
|
1694
|
+
): { manifest: KDNAClusterManifest; domains: KDNALoadedClusterDomain[]; errors: string[] };
|
|
1695
|
+
|
|
1696
|
+
export interface KDNADomainConflict {
|
|
1697
|
+
type: 'term_conflict' | 'stance_conflict';
|
|
1698
|
+
domains: string[];
|
|
1699
|
+
description: string;
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
export function detectDomainConflicts(domains: KDNAComposableDomain[]): KDNADomainConflict[];
|
|
1703
|
+
|
|
1704
|
+
export function generateClusterTrace(input: {
|
|
1705
|
+
input: string;
|
|
1706
|
+
loadedDomains: Array<{ id?: string; name?: string }>;
|
|
1707
|
+
activeDomains: Array<{ id?: string; name?: string }>;
|
|
1708
|
+
conflicts: KDNADomainConflict[];
|
|
1709
|
+
}): {
|
|
1710
|
+
input: string;
|
|
1711
|
+
timestamp: string;
|
|
1712
|
+
loaded_domains: string[];
|
|
1713
|
+
active_domains: string[];
|
|
1714
|
+
active_count: number;
|
|
1715
|
+
domains_excluded: number;
|
|
1716
|
+
conflicts: KDNADomainConflict[];
|
|
1717
|
+
};
|
|
1718
|
+
|
|
1719
|
+
export interface KDNAWorkPackAssetRef {
|
|
1720
|
+
name: string;
|
|
1721
|
+
version: string;
|
|
1722
|
+
digest?: string;
|
|
1723
|
+
role: 'primary' | 'constraint' | 'fallback';
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
export interface KDNAWorkPackSkill {
|
|
1727
|
+
name: string;
|
|
1728
|
+
type?: string;
|
|
1729
|
+
required?: boolean;
|
|
1730
|
+
mcp_server?: string | null;
|
|
1731
|
+
fallback?: string | null;
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
export interface KDNAWorkPackManifest {
|
|
1735
|
+
format: 'kdna-workpack';
|
|
1736
|
+
format_version: string;
|
|
1737
|
+
name: string;
|
|
1738
|
+
version: string;
|
|
1739
|
+
description: string;
|
|
1740
|
+
status: 'draft' | 'experimental' | 'stable' | 'deprecated';
|
|
1741
|
+
access?: 'public' | 'licensed' | 'remote' | 'enterprise' | 'partner';
|
|
1742
|
+
license?: string;
|
|
1743
|
+
kdna:
|
|
1744
|
+
| { mode: 'single'; asset: KDNAWorkPackAssetRef }
|
|
1745
|
+
| { mode: 'cluster'; assets: KDNAWorkPackAssetRef[] };
|
|
1746
|
+
skills?: KDNAWorkPackSkill[];
|
|
1747
|
+
templates?: { task?: string; output?: string };
|
|
1748
|
+
review_gates?: string[];
|
|
1749
|
+
risk_policy?: string;
|
|
1750
|
+
trace_policy?: string;
|
|
1751
|
+
evals?: string;
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
export interface KDNAWorkPackValidationResult {
|
|
1755
|
+
valid: boolean;
|
|
1756
|
+
errors: string[];
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
export interface KDNAWorkPackValidator {
|
|
1760
|
+
(manifest: KDNAWorkPackManifest): boolean;
|
|
1761
|
+
errors?: Array<{ instancePath?: string; message?: string }> | null;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
export interface KDNAWorkPackAjv {
|
|
1765
|
+
compile(schema: unknown): KDNAWorkPackValidator;
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
export const WORK_PACK_SCHEMA: Readonly<Record<string, unknown>>;
|
|
1769
|
+
export function validateWorkPackManifest(
|
|
1770
|
+
manifest: KDNAWorkPackManifest,
|
|
1771
|
+
options?: { ajv?: KDNAWorkPackAjv },
|
|
1772
|
+
): KDNAWorkPackValidationResult;
|
|
1773
|
+
export function checkWorkPackStructure(
|
|
1774
|
+
manifest: KDNAWorkPackManifest,
|
|
1775
|
+
rootDir: string,
|
|
1776
|
+
): { complete: boolean; missing: string[] };
|
|
1777
|
+
export function inspectWorkPack(
|
|
1778
|
+
manifest: KDNAWorkPackManifest,
|
|
1779
|
+
rootDir: string,
|
|
1780
|
+
): {
|
|
1781
|
+
name: string;
|
|
1782
|
+
version: string;
|
|
1783
|
+
description: string;
|
|
1784
|
+
status: KDNAWorkPackManifest['status'];
|
|
1785
|
+
access: NonNullable<KDNAWorkPackManifest['access']>;
|
|
1786
|
+
license: string;
|
|
1787
|
+
format_version: string;
|
|
1788
|
+
kdna: {
|
|
1789
|
+
mode: 'single' | 'cluster';
|
|
1790
|
+
assets: Array<Pick<KDNAWorkPackAssetRef, 'name' | 'version' | 'role'>>;
|
|
1791
|
+
};
|
|
1792
|
+
skills: Array<{
|
|
1793
|
+
name: string;
|
|
1794
|
+
type: string;
|
|
1795
|
+
required: boolean;
|
|
1796
|
+
fallback: string | null;
|
|
1797
|
+
}>;
|
|
1798
|
+
templates: { task: string | null; output: string | null } | null;
|
|
1799
|
+
review_gates: number;
|
|
1800
|
+
has_risk_policy: boolean;
|
|
1801
|
+
has_trace_policy: boolean;
|
|
1802
|
+
has_evals: boolean;
|
|
1803
|
+
structural_complete: boolean;
|
|
1804
|
+
missing_files: string[];
|
|
1805
|
+
};
|
|
1806
|
+
export function loadWorkPack(
|
|
1807
|
+
dirPath: string,
|
|
1808
|
+
): { manifest: unknown; error: null } | { manifest: null; error: string };
|