@aikdna/kdna-core 0.17.0 → 0.19.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 +227 -64
- package/README.md +114 -77
- package/package.json +8 -2
- package/schema/agent-host-capabilities.schema.json +62 -0
- package/schema/agent-host-receipt.schema.json +371 -0
- package/schema/agent-host-request.schema.json +223 -0
- package/schema/{bundle-profile-v1.schema.json → bundle-profile.schema.json} +9 -5
- package/schema/checksums.schema.json +42 -3
- package/schema/consumption-plan.schema.json +428 -0
- package/schema/digest-evidence.schema.json +212 -0
- package/schema/{kdna-envelope-external-grant-v1.schema.json → external-grant-envelope.schema.json} +17 -4
- package/schema/{kdna-key-grant-v1.schema.json → external-key-grant.schema.json} +39 -7
- package/schema/judgment-trace.schema.json +1251 -0
- package/schema/load-plan.schema.json +7 -5
- package/schema/manifest.schema.json +70 -10
- package/schema/{payload-profile-v1.schema.json → payload-profile.schema.json} +30 -6
- package/schema/runtime-capsule.schema.json +116 -0
- package/src/asset-reader.js +106 -120
- package/src/{v1 → container}/index.js +566 -209
- package/src/container/index.mjs +20 -0
- package/src/container-dispatcher.js +10 -7
- package/src/crypto-profile.js +37 -107
- package/src/external-key-grant.js +41 -15
- package/src/index.js +11 -4
- package/src/index.mjs +143 -24
- package/src/loader-compatibility.js +59 -0
- package/src/loader.js +1 -1
- package/src/public-api.js +59 -163
- package/src/remote-runtime.d.ts +13 -0
- package/src/remote-runtime.js +27 -0
- package/src/remote-runtime.mjs +3 -0
- package/src/runtime-api.js +9 -10
- package/src/runtime-capsule.js +529 -0
- package/src/runtime-contract.js +1882 -0
- package/src/types.d.ts +1127 -136
- package/src/workpack-pure.js +1 -1
- package/src/lint-pure.js +0 -430
- package/src/v1/index.mjs +0 -20
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;
|
|
@@ -203,20 +198,42 @@ export interface KDNAFileDataMap {
|
|
|
203
198
|
}
|
|
204
199
|
|
|
205
200
|
export interface KDNAManifest {
|
|
206
|
-
|
|
207
|
-
|
|
201
|
+
format_version: '0.1.0';
|
|
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: 'kdna.payload.judgment' | 'kdna.payload.bundle';
|
|
213
|
+
profile_version: '0.1.0';
|
|
214
|
+
[key: string]: any;
|
|
215
|
+
};
|
|
216
|
+
payload: {
|
|
217
|
+
path: 'payload.kdnab';
|
|
218
|
+
encoding: 'cbor';
|
|
219
|
+
encrypted: boolean;
|
|
220
|
+
[key: string]: any;
|
|
221
|
+
};
|
|
222
|
+
creator?: {
|
|
223
|
+
name: string;
|
|
224
|
+
id?: string;
|
|
225
|
+
creator_type?: 'human' | 'agent' | 'tool' | 'organization';
|
|
226
|
+
pubkey?: string;
|
|
227
|
+
[key: string]: any;
|
|
228
|
+
};
|
|
229
|
+
access?: 'public' | 'licensed' | 'remote';
|
|
213
230
|
language?: string;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
description: string;
|
|
231
|
+
languages?: string[];
|
|
232
|
+
license?: string | { type: string; url?: string };
|
|
233
|
+
summary?: string;
|
|
234
|
+
description?: string;
|
|
219
235
|
keywords?: string[];
|
|
236
|
+
load_contract?: Record<string, any>;
|
|
220
237
|
encryption?: {
|
|
221
238
|
profile?: string;
|
|
222
239
|
encrypted_entries?: string[];
|
|
@@ -224,11 +241,7 @@ export interface KDNAManifest {
|
|
|
224
241
|
};
|
|
225
242
|
content_digest?: string;
|
|
226
243
|
signature?: string;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
export interface LintResult {
|
|
230
|
-
errors: string[];
|
|
231
|
-
warnings: string[];
|
|
244
|
+
[key: string]: any;
|
|
232
245
|
}
|
|
233
246
|
|
|
234
247
|
export interface ValidationResult {
|
|
@@ -243,9 +256,15 @@ export function loadCorePatternsFromData(
|
|
|
243
256
|
patternsData: KDNAPatterns,
|
|
244
257
|
): { core: KDNACore; patterns: KDNAPatterns } | null;
|
|
245
258
|
|
|
246
|
-
export function loadDomainFromData(
|
|
259
|
+
export function loadDomainFromData(
|
|
260
|
+
dataMap: KDNADataMap,
|
|
261
|
+
options?: LoadOptions,
|
|
262
|
+
): LoadedDomain | null;
|
|
247
263
|
|
|
248
|
-
export function loadDomainFromFiles(
|
|
264
|
+
export function loadDomainFromFiles(
|
|
265
|
+
fileDataMap: KDNAFileDataMap,
|
|
266
|
+
options?: LoadOptions,
|
|
267
|
+
): LoadedDomain | null;
|
|
249
268
|
|
|
250
269
|
export function classifyInput(text: string): string[];
|
|
251
270
|
|
|
@@ -254,6 +273,7 @@ export function formatContext(domain: LoadedDomain): string;
|
|
|
254
273
|
export const FILE_MAP: Record<string, string>;
|
|
255
274
|
|
|
256
275
|
// Asset reader — direct .kdna API
|
|
276
|
+
/** @deprecated Legacy source-tree entry names. Current Runtime assets use payload.kdnab. */
|
|
257
277
|
export const STANDARD_ENTRIES: string[];
|
|
258
278
|
|
|
259
279
|
export interface KdnaAsset {
|
|
@@ -307,16 +327,10 @@ export interface KdnaAssetReader {
|
|
|
307
327
|
readJson(asset: KdnaAsset, entryName: string, options?: KdnaDecryptOptions): Promise<any>;
|
|
308
328
|
readManifestSync(asset: KdnaAsset): KDNAManifest;
|
|
309
329
|
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>;
|
|
330
|
+
/** @deprecated Current payload.kdnab is not projected into legacy source files. */
|
|
331
|
+
readDataMapSync(asset: KdnaAsset, entries?: string[], options?: KdnaDecryptOptions): never;
|
|
332
|
+
/** @deprecated Current payload.kdnab is not projected into legacy source files. */
|
|
333
|
+
readDataMap(asset: KdnaAsset, entries?: string[], options?: KdnaDecryptOptions): Promise<never>;
|
|
320
334
|
contentDigestSync(asset: KdnaAsset): string;
|
|
321
335
|
contentDigest(asset: KdnaAsset): Promise<string>;
|
|
322
336
|
verifySync(
|
|
@@ -339,24 +353,14 @@ export interface KdnaAssetReader {
|
|
|
339
353
|
): Promise<KdnaAssetVerifyResult>;
|
|
340
354
|
loadProfileSync(
|
|
341
355
|
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;
|
|
356
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full' | string,
|
|
357
|
+
options?: { as?: 'json' | 'prompt' | string } & KdnaDecryptOptions,
|
|
358
|
+
): KDNARuntimeCapsule | Record<string, any>;
|
|
350
359
|
loadProfile(
|
|
351
360
|
asset: KdnaAsset,
|
|
352
|
-
profile
|
|
353
|
-
options?: {
|
|
354
|
-
): Promise<
|
|
355
|
-
loadProfile(
|
|
356
|
-
asset: KdnaAsset,
|
|
357
|
-
profile?: 'compact' | 'scenario' | 'full' | string,
|
|
358
|
-
options?: { input?: string; context?: boolean } & KdnaDecryptOptions,
|
|
359
|
-
): Promise<KdnaAssetLoadProfile>;
|
|
361
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full' | string,
|
|
362
|
+
options?: { as?: 'json' | 'prompt' | string } & KdnaDecryptOptions,
|
|
363
|
+
): Promise<KDNARuntimeCapsule | Record<string, any>>;
|
|
360
364
|
}
|
|
361
365
|
|
|
362
366
|
export interface KdnaDecryptOptions {
|
|
@@ -370,59 +374,185 @@ export interface KdnaDecryptOptions {
|
|
|
370
374
|
|
|
371
375
|
export function createKdnaAssetReader(): KdnaAssetReader;
|
|
372
376
|
|
|
373
|
-
export const LICENSED_ENTRY_PROFILE:
|
|
377
|
+
export const LICENSED_ENTRY_PROFILE: 'kdna.encryption.licensed-entry';
|
|
378
|
+
export const PASSWORD_PROTECTED_PROFILE: 'kdna.encryption.password';
|
|
379
|
+
export const PASSWORD_PROTECTED_SCRYPT_PROFILE: 'kdna.encryption.password.scrypt';
|
|
380
|
+
export const ENCRYPTION_PROFILE_VERSION: '0.1.0';
|
|
381
|
+
export const ALG: 'AES-256-GCM';
|
|
382
|
+
export const RFC_KDF: 'HKDF-SHA256';
|
|
383
|
+
export const RFC_KEY_WRAPPING: 'AES-256-KW';
|
|
384
|
+
export const PASSWORD_KDF: 'Argon2id';
|
|
385
|
+
export const SCRYPT_KDF: 'scrypt-sha256';
|
|
386
|
+
|
|
387
|
+
export type KDNACryptoInput = string | Uint8Array;
|
|
374
388
|
|
|
375
389
|
export interface LicensedEntryEnvelope {
|
|
376
|
-
profile:
|
|
390
|
+
profile: 'kdna.encryption.licensed-entry';
|
|
391
|
+
profile_version: '0.1.0';
|
|
377
392
|
alg: 'AES-256-GCM';
|
|
378
|
-
kdf: '
|
|
393
|
+
kdf: 'HKDF-SHA256';
|
|
394
|
+
key_wrapping: 'AES-256-KW';
|
|
395
|
+
wrapped_key: string;
|
|
396
|
+
iv: string;
|
|
397
|
+
tag: string;
|
|
398
|
+
ciphertext: string;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
export interface KDNAPasswordKdfParams {
|
|
379
402
|
salt: string;
|
|
403
|
+
memory_kib?: number;
|
|
404
|
+
iterations?: number;
|
|
405
|
+
parallelism?: number;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export interface KDNAPasswordKdfDescriptor {
|
|
409
|
+
name: 'Argon2id';
|
|
410
|
+
salt: string;
|
|
411
|
+
memory_kib: number;
|
|
412
|
+
iterations: number;
|
|
413
|
+
parallelism: number;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export interface KDNAScryptKdfParams {
|
|
417
|
+
salt: string;
|
|
418
|
+
N?: number;
|
|
419
|
+
r?: number;
|
|
420
|
+
p?: number;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export interface KDNAProtectedEntryEnvelope {
|
|
424
|
+
profile: 'kdna.encryption.password';
|
|
425
|
+
profile_version: '0.1.0';
|
|
426
|
+
alg: 'AES-256-GCM';
|
|
427
|
+
kdf: 'Argon2id';
|
|
428
|
+
key_wrapping: 'AES-256-KW';
|
|
429
|
+
password_kdf: KDNAPasswordKdfDescriptor;
|
|
430
|
+
key_slots: Array<{
|
|
431
|
+
slot: 'password' | 'recovery';
|
|
432
|
+
wrap: 'AES-256-KW';
|
|
433
|
+
wrapped_key: string;
|
|
434
|
+
}>;
|
|
380
435
|
iv: string;
|
|
381
436
|
tag: string;
|
|
382
437
|
ciphertext: string;
|
|
383
438
|
}
|
|
384
439
|
|
|
385
|
-
export
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
440
|
+
export interface KDNAScryptProtectedEntryEnvelope {
|
|
441
|
+
profile: 'kdna.encryption.password.scrypt';
|
|
442
|
+
profile_version: '0.1.0';
|
|
443
|
+
alg: 'AES-256-GCM';
|
|
444
|
+
kdf: 'scrypt-sha256';
|
|
445
|
+
key_wrapping: 'AES-256-KW';
|
|
446
|
+
scrypt_params: Required<KDNAScryptKdfParams>;
|
|
447
|
+
key_slots: Array<{
|
|
448
|
+
slot: 'password';
|
|
449
|
+
wrap: 'AES-256-KW';
|
|
450
|
+
wrapped_key: string;
|
|
451
|
+
}>;
|
|
452
|
+
iv: string;
|
|
453
|
+
tag: string;
|
|
454
|
+
ciphertext: string;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
export interface KDNALicensedEntryOptions {
|
|
458
|
+
entryName: string;
|
|
459
|
+
manifest?: KDNAManifest;
|
|
460
|
+
licenseKey: KDNACryptoInput;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
export function hkdfSha256(
|
|
464
|
+
ikm: KDNACryptoInput,
|
|
465
|
+
salt?: Uint8Array | null,
|
|
466
|
+
info?: KDNACryptoInput,
|
|
467
|
+
length?: number,
|
|
468
|
+
): Uint8Array;
|
|
469
|
+
export function aesWrap(key: Uint8Array, plaintext: Uint8Array): Uint8Array;
|
|
470
|
+
export function aesUnwrap(key: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
471
|
+
export function deriveWrappingKey(licenseKey: KDNACryptoInput, info?: KDNACryptoInput): Uint8Array;
|
|
472
|
+
export function generateCEK(): Uint8Array;
|
|
473
|
+
export function wrapCEK(cek: Uint8Array, wrappingKey: Uint8Array): Uint8Array;
|
|
474
|
+
export function unwrapCEK(wrappedCek: Uint8Array, wrappingKey: Uint8Array): Uint8Array;
|
|
391
475
|
|
|
392
476
|
export function encryptLicensedEntry(
|
|
393
|
-
plaintext:
|
|
477
|
+
plaintext: KDNACryptoInput,
|
|
478
|
+
options: KDNALicensedEntryOptions,
|
|
479
|
+
): LicensedEntryEnvelope;
|
|
480
|
+
export function decryptLicensedEntry(
|
|
481
|
+
envelope: KDNACryptoInput | LicensedEntryEnvelope,
|
|
482
|
+
options: KDNALicensedEntryOptions,
|
|
483
|
+
): Uint8Array;
|
|
484
|
+
export function derivePasswordKey(
|
|
485
|
+
password: KDNACryptoInput,
|
|
486
|
+
params: KDNAPasswordKdfParams,
|
|
487
|
+
): Uint8Array;
|
|
488
|
+
export function generateRecoveryCode(): string;
|
|
489
|
+
export function decodeRecoveryCode(code: string): Uint8Array;
|
|
490
|
+
export function encryptProtectedEntry(
|
|
491
|
+
plaintext: KDNACryptoInput,
|
|
394
492
|
options: {
|
|
395
493
|
entryName: string;
|
|
396
494
|
manifest?: KDNAManifest;
|
|
397
|
-
|
|
398
|
-
|
|
495
|
+
password: KDNACryptoInput;
|
|
496
|
+
includeRecovery?: boolean;
|
|
497
|
+
recoveryCode?: string;
|
|
399
498
|
},
|
|
400
|
-
):
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
499
|
+
): KDNAProtectedEntryEnvelope;
|
|
500
|
+
export function decryptProtectedEntry(
|
|
501
|
+
envelope: KDNACryptoInput | KDNAProtectedEntryEnvelope,
|
|
502
|
+
options: {
|
|
503
|
+
entryName: string;
|
|
504
|
+
manifest?: KDNAManifest;
|
|
505
|
+
} & (
|
|
506
|
+
| { password: KDNACryptoInput; recoveryCode?: string }
|
|
507
|
+
| { password?: undefined; recoveryCode: string }
|
|
508
|
+
),
|
|
509
|
+
): Uint8Array;
|
|
510
|
+
export function createPasswordDecryptEntry(options: {
|
|
511
|
+
password: KDNACryptoInput;
|
|
512
|
+
}): NonNullable<KdnaDecryptOptions['decryptEntry']>;
|
|
513
|
+
export function createRecoveryDecryptEntry(options: {
|
|
514
|
+
recoveryCode: string;
|
|
515
|
+
}): NonNullable<KdnaDecryptOptions['decryptEntry']>;
|
|
516
|
+
export function derivePasswordKeyScrypt(
|
|
517
|
+
password: KDNACryptoInput,
|
|
518
|
+
params: KDNAScryptKdfParams,
|
|
519
|
+
): Uint8Array;
|
|
520
|
+
export function encryptProtectedEntryScrypt(
|
|
521
|
+
plaintext: KDNACryptoInput,
|
|
404
522
|
options: {
|
|
405
523
|
entryName: string;
|
|
406
524
|
manifest?: KDNAManifest;
|
|
407
|
-
|
|
408
|
-
|
|
525
|
+
password: KDNACryptoInput;
|
|
526
|
+
},
|
|
527
|
+
): KDNAScryptProtectedEntryEnvelope;
|
|
528
|
+
export function decryptProtectedEntryScrypt(
|
|
529
|
+
envelope: KDNACryptoInput | KDNAScryptProtectedEntryEnvelope,
|
|
530
|
+
options: {
|
|
531
|
+
entryName: string;
|
|
532
|
+
manifest?: KDNAManifest;
|
|
533
|
+
password: KDNACryptoInput;
|
|
409
534
|
},
|
|
410
535
|
): Uint8Array;
|
|
411
|
-
|
|
536
|
+
export function createPasswordDecryptEntryScrypt(options: {
|
|
537
|
+
password: KDNACryptoInput;
|
|
538
|
+
}): NonNullable<KdnaDecryptOptions['decryptEntry']>;
|
|
412
539
|
export function createLicensedDecryptEntry(options: {
|
|
413
|
-
licenseKey:
|
|
414
|
-
machineFingerprint: string;
|
|
540
|
+
licenseKey: KDNACryptoInput;
|
|
415
541
|
}): NonNullable<KdnaDecryptOptions['decryptEntry']>;
|
|
416
542
|
|
|
417
|
-
export const EXTERNAL_ENVELOPE_PROFILE: 'kdna
|
|
418
|
-
export const EXTERNAL_GRANT_PROFILE: 'kdna-key
|
|
543
|
+
export const EXTERNAL_ENVELOPE_PROFILE: 'kdna.envelope.external-grant';
|
|
544
|
+
export const EXTERNAL_GRANT_PROFILE: 'kdna.grant.external-key';
|
|
545
|
+
export const EXTERNAL_AAD_PROFILE: 'kdna.key-context.asset-content';
|
|
546
|
+
export const DEVICE_KEK_PROFILE: 'kdna.key-context.device-grant';
|
|
547
|
+
export const EXTERNAL_GRANT_CONTRACT_VERSION: '0.1.0';
|
|
419
548
|
|
|
420
549
|
export class KDNAExternalGrantError extends Error {
|
|
421
550
|
code: string;
|
|
422
551
|
}
|
|
423
552
|
|
|
424
553
|
export interface KDNAExternalGrantEnvelope {
|
|
425
|
-
profile: 'kdna
|
|
554
|
+
profile: 'kdna.envelope.external-grant';
|
|
555
|
+
contract_version: '0.1.0';
|
|
426
556
|
alg: 'A256GCM';
|
|
427
557
|
cek_derivation: 'HKDF-SHA256';
|
|
428
558
|
key_ref: string;
|
|
@@ -435,7 +565,8 @@ export interface KDNAExternalGrantEnvelope {
|
|
|
435
565
|
}
|
|
436
566
|
|
|
437
567
|
export interface KDNAExternalKeyGrant {
|
|
438
|
-
profile: 'kdna-key
|
|
568
|
+
profile: 'kdna.grant.external-key';
|
|
569
|
+
contract_version: '0.1.0';
|
|
439
570
|
grant_id: string;
|
|
440
571
|
issuer: string;
|
|
441
572
|
signing_key_id: string;
|
|
@@ -477,7 +608,7 @@ export interface KDNADeviceKeyPairs {
|
|
|
477
608
|
/** Runtime-branded by authorizeExternalKeyGrant; a structurally similar object is not accepted. */
|
|
478
609
|
export interface KDNAVerifiedExternalEntitlement {
|
|
479
610
|
readonly status: 'active' | 'offline_grace';
|
|
480
|
-
readonly profile: 'kdna-key
|
|
611
|
+
readonly profile: 'kdna.grant.external-key';
|
|
481
612
|
readonly grant_id: string;
|
|
482
613
|
readonly entitlement_id: string;
|
|
483
614
|
readonly account_id: string;
|
|
@@ -504,7 +635,9 @@ export interface KDNAExternalAuthorization {
|
|
|
504
635
|
}
|
|
505
636
|
|
|
506
637
|
export function canonicalJson(value: unknown): string;
|
|
507
|
-
export function grantSigningPayload(
|
|
638
|
+
export function grantSigningPayload(
|
|
639
|
+
grant: Omit<KDNAExternalKeyGrant, 'signature'> | KDNAExternalKeyGrant,
|
|
640
|
+
): Uint8Array;
|
|
508
641
|
export function validateExternalEnvelope(value: unknown): KDNAExternalGrantEnvelope;
|
|
509
642
|
export function validateExternalKeyGrant(value: unknown): KDNAExternalKeyGrant;
|
|
510
643
|
export function externalEnvelopeAad(options: {
|
|
@@ -523,15 +656,20 @@ export function deriveExternalAssetCek(options: {
|
|
|
523
656
|
issuerKeyId: string;
|
|
524
657
|
}): Uint8Array;
|
|
525
658
|
export function encodeExternalEnvelope(value: KDNAExternalGrantEnvelope): Uint8Array;
|
|
526
|
-
export function decodeExternalEnvelope(
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
659
|
+
export function decodeExternalEnvelope(
|
|
660
|
+
value: KDNAExternalGrantEnvelope | Uint8Array,
|
|
661
|
+
): KDNAExternalGrantEnvelope;
|
|
662
|
+
export function encryptExternalGrantEntry(
|
|
663
|
+
plaintext: string | Uint8Array,
|
|
664
|
+
options: {
|
|
665
|
+
manifest: KDNAManifest;
|
|
666
|
+
entryName?: string;
|
|
667
|
+
issuerRootKey: string | Uint8Array;
|
|
668
|
+
keyRef: string;
|
|
669
|
+
issuerKeyId: string;
|
|
670
|
+
iv?: Uint8Array;
|
|
671
|
+
},
|
|
672
|
+
): KDNAExternalGrantEnvelope;
|
|
535
673
|
export function generateDeviceKeyPairs(): KDNADeviceKeyPairs;
|
|
536
674
|
export function createExternalKeyGrant(options: {
|
|
537
675
|
issuerRootKey: string | Uint8Array;
|
|
@@ -560,7 +698,8 @@ export function authorizeExternalKeyGrant(options: {
|
|
|
560
698
|
grant: KDNAExternalKeyGrant;
|
|
561
699
|
issuerPublicKeys: Map<string, unknown> | Record<string, unknown>;
|
|
562
700
|
manifest: KDNAManifest;
|
|
563
|
-
checksums
|
|
701
|
+
/** Final immutable container digest A; never checksums entry-set digest E. */
|
|
702
|
+
expectedAssetDigest: string;
|
|
564
703
|
envelope: KDNAExternalGrantEnvelope | Uint8Array;
|
|
565
704
|
deviceAgreementKey: KDNADeviceKeyPairs['agreement'] | unknown;
|
|
566
705
|
expectedAccountId: string;
|
|
@@ -571,20 +710,29 @@ export function authorizeExternalKeyGrant(options: {
|
|
|
571
710
|
networkAvailable?: boolean;
|
|
572
711
|
allowOffline?: boolean;
|
|
573
712
|
}): KDNAExternalAuthorization;
|
|
574
|
-
export function isVerifiedExternalEntitlement(
|
|
713
|
+
export function isVerifiedExternalEntitlement(
|
|
714
|
+
value: unknown,
|
|
715
|
+
): value is KDNAVerifiedExternalEntitlement;
|
|
575
716
|
|
|
576
717
|
// Stable public API — preferred entry points for third-party integrations.
|
|
577
718
|
export type KDNAAssetInput = string | Uint8Array | KdnaAsset;
|
|
578
719
|
|
|
579
720
|
export interface KDNAInspectResult {
|
|
580
|
-
|
|
721
|
+
format_version: '0.1.0' | null;
|
|
722
|
+
asset_id: string | null;
|
|
723
|
+
asset_uid: string | null;
|
|
724
|
+
asset_type: string | null;
|
|
725
|
+
title: string | null;
|
|
581
726
|
version: string | null;
|
|
582
727
|
judgment_version: string | null;
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
728
|
+
payload: string | null;
|
|
729
|
+
payload_encrypted: boolean | null;
|
|
730
|
+
profile: string | null;
|
|
731
|
+
loader_version: string;
|
|
732
|
+
min_loader_version: string | null;
|
|
733
|
+
loader_compatible: boolean | null;
|
|
734
|
+
load_contract_default_profile: string | null;
|
|
735
|
+
checksums_present?: boolean;
|
|
588
736
|
entries: string[];
|
|
589
737
|
asset_digest: string;
|
|
590
738
|
content_digest: string;
|
|
@@ -596,15 +744,492 @@ export interface KDNAInspectResult {
|
|
|
596
744
|
}
|
|
597
745
|
|
|
598
746
|
export interface KDNAValidationReport {
|
|
599
|
-
|
|
600
|
-
|
|
747
|
+
format_valid: boolean;
|
|
748
|
+
schema_valid: boolean;
|
|
749
|
+
payload_valid: boolean;
|
|
750
|
+
checksums_valid: boolean;
|
|
751
|
+
load_contract_valid: boolean;
|
|
752
|
+
loader_version: string;
|
|
753
|
+
min_loader_version: string | null;
|
|
754
|
+
loader_compatible: boolean | null;
|
|
755
|
+
overall_valid: boolean;
|
|
756
|
+
problems: string[];
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
export type KDNADigestComparisonState = 'matched' | 'mismatched' | 'not_compared' | 'unavailable';
|
|
760
|
+
|
|
761
|
+
export type KDNADigestComparisonSource =
|
|
762
|
+
| 'caller'
|
|
763
|
+
| 'registry'
|
|
764
|
+
| 'install_receipt'
|
|
765
|
+
| 'lockfile'
|
|
766
|
+
| 'kdna.json.content_digest'
|
|
767
|
+
| 'kdna.json.authoring.content_digest'
|
|
768
|
+
| 'checksums.json.entry_set_digest';
|
|
769
|
+
|
|
770
|
+
export interface KDNADigestComparison {
|
|
771
|
+
state: KDNADigestComparisonState;
|
|
772
|
+
against: 'external_expected' | 'manifest_declaration' | 'checksum_declaration' | null;
|
|
773
|
+
expected: string | null;
|
|
774
|
+
source: KDNADigestComparisonSource | null;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
export interface KDNADigestValue {
|
|
778
|
+
value: string | null;
|
|
779
|
+
basis: string;
|
|
780
|
+
comparison: KDNADigestComparison;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
export interface KDNADigestEvidence {
|
|
784
|
+
profile: 'kdna.digest-evidence';
|
|
785
|
+
profile_version: '0.1.0';
|
|
786
|
+
asset: KDNADigestValue;
|
|
787
|
+
content: KDNADigestValue;
|
|
788
|
+
runtime_entry_set: KDNADigestValue;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
export interface KDNARuntimeCapsule {
|
|
792
|
+
type: 'kdna.runtime-capsule';
|
|
793
|
+
contract_version: '0.1.0';
|
|
794
|
+
asset: {
|
|
795
|
+
asset_id: string;
|
|
796
|
+
asset_uid: string;
|
|
797
|
+
version: string;
|
|
798
|
+
judgment_version: string;
|
|
799
|
+
};
|
|
800
|
+
digests: KDNADigestEvidence;
|
|
801
|
+
signature: { state: 'verified' | 'not_checked' | 'absent'; issuer?: string };
|
|
802
|
+
access: 'public' | 'licensed' | 'remote';
|
|
803
|
+
risk_level: string | null;
|
|
804
|
+
profile: 'index' | 'compact' | 'scenario' | 'full';
|
|
805
|
+
context: Record<string, any>;
|
|
806
|
+
trace: {
|
|
807
|
+
payload_encoding: 'cbor';
|
|
808
|
+
loaded_by: 'kdna-core';
|
|
809
|
+
loaded_at: string;
|
|
810
|
+
input_kind: 'packaged_file' | 'packaged_bytes';
|
|
811
|
+
runtime_eligible: true;
|
|
812
|
+
schema_valid: true;
|
|
813
|
+
signature_state: 'verified' | 'not_checked' | 'absent';
|
|
814
|
+
profile: 'index' | 'compact' | 'scenario' | 'full';
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
export const DIGEST_PROFILE: 'kdna.digest-evidence';
|
|
819
|
+
export const DIGEST_PROFILE_VERSION: '0.1.0';
|
|
820
|
+
export const CAPSULE_DIGEST_PROFILE: 'kdna.canonicalization.runtime-capsule-jcs';
|
|
821
|
+
export const CANONICALIZATION_PROFILE_VERSION: '0.1.0';
|
|
822
|
+
export const RUNTIME_CAPSULE_CONTRACT_VERSION: '0.1.0';
|
|
823
|
+
export const BASIS: Readonly<{
|
|
824
|
+
asset: 'kdna.digest-basis.container-bytes';
|
|
825
|
+
content: 'kdna.digest-basis.content-tree';
|
|
826
|
+
runtime_entry_set: 'kdna.digest-basis.runtime-entry-set';
|
|
827
|
+
}>;
|
|
828
|
+
export function computeAssetDigest(assetBytes: Uint8Array): string;
|
|
829
|
+
export function computeRuntimeEntrySetDigest(
|
|
830
|
+
manifestBytes: Uint8Array,
|
|
831
|
+
payloadBytes: Uint8Array,
|
|
832
|
+
): string;
|
|
833
|
+
export function computeDigestEvidence(
|
|
834
|
+
input: string | Uint8Array,
|
|
835
|
+
options?: {
|
|
836
|
+
expectedDigests?: Partial<
|
|
837
|
+
Record<
|
|
838
|
+
'asset' | 'content' | 'runtime_entry_set',
|
|
839
|
+
| string
|
|
840
|
+
| {
|
|
841
|
+
value: string;
|
|
842
|
+
source: 'caller' | 'registry' | 'install_receipt' | 'lockfile';
|
|
843
|
+
}
|
|
844
|
+
>
|
|
845
|
+
>;
|
|
846
|
+
},
|
|
847
|
+
): KDNADigestEvidence;
|
|
848
|
+
export function canonicalizeJcs(value: unknown): string;
|
|
849
|
+
export function computeCapsuleDeliveryDigest(
|
|
850
|
+
capsule: KDNARuntimeCapsule | Record<string, any>,
|
|
851
|
+
): string;
|
|
852
|
+
export function buildRuntimeCapsule(input: {
|
|
853
|
+
projection: Record<string, any>;
|
|
854
|
+
manifest: KDNAManifest;
|
|
855
|
+
digests: KDNADigestEvidence;
|
|
856
|
+
signature: { state: 'verified' | 'not_checked' | 'absent'; issuer?: string };
|
|
857
|
+
inputKind: 'packaged_file' | 'packaged_bytes';
|
|
858
|
+
loadedAt?: string;
|
|
859
|
+
schemaValid?: boolean;
|
|
860
|
+
}): KDNARuntimeCapsule;
|
|
861
|
+
export function loadRuntimeCapsule(
|
|
862
|
+
input: string | Uint8Array,
|
|
863
|
+
options?: {
|
|
864
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full';
|
|
865
|
+
loadedAt?: string;
|
|
866
|
+
expectedDigests?: Partial<
|
|
867
|
+
Record<
|
|
868
|
+
'asset' | 'content' | 'runtime_entry_set',
|
|
869
|
+
| string
|
|
870
|
+
| {
|
|
871
|
+
value: string;
|
|
872
|
+
source: 'caller' | 'registry' | 'install_receipt' | 'lockfile';
|
|
873
|
+
}
|
|
874
|
+
>
|
|
875
|
+
>;
|
|
876
|
+
} & KdnaDecryptOptions,
|
|
877
|
+
): KDNARuntimeCapsule;
|
|
878
|
+
export type KDNAJsonValue =
|
|
879
|
+
null | boolean | number | string | KDNAJsonValue[] | { [key: string]: KDNAJsonValue };
|
|
880
|
+
|
|
881
|
+
export interface KDNAExecutionContractValidationError {
|
|
882
|
+
code: string;
|
|
883
|
+
message: string;
|
|
884
|
+
details?: unknown;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
export type KDNAExecutionContractValidationResult =
|
|
888
|
+
| { valid: true; code: null; errors: []; value?: unknown }
|
|
889
|
+
| { valid: false; code: string; errors: KDNAExecutionContractValidationError[] };
|
|
890
|
+
|
|
891
|
+
export class KDNARuntimeContractError extends Error {
|
|
892
|
+
code: string;
|
|
893
|
+
details?: unknown;
|
|
894
|
+
constructor(code: string, message: string, details?: unknown);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
export interface KDNAExpectedDigest {
|
|
898
|
+
value: string;
|
|
899
|
+
basis: string;
|
|
900
|
+
source:
|
|
901
|
+
| 'caller'
|
|
902
|
+
| 'registry'
|
|
903
|
+
| 'install_receipt'
|
|
904
|
+
| 'lockfile'
|
|
905
|
+
| 'kdna.json.content_digest'
|
|
906
|
+
| 'checksums.json.entry_set_digest';
|
|
907
|
+
comparison: 'matched' | 'not_compared';
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
export interface KDNAConsumptionPlan {
|
|
911
|
+
type: 'kdna.consumption-plan';
|
|
912
|
+
contract_version: '0.1.0';
|
|
913
|
+
plan_id: string;
|
|
914
|
+
created_at: string;
|
|
915
|
+
mode: 'single';
|
|
916
|
+
task: { summary: string; task_family: string | null; context: KDNAJsonValue };
|
|
917
|
+
asset_ref: {
|
|
918
|
+
asset_id: string;
|
|
919
|
+
asset_uid: string;
|
|
920
|
+
version: string;
|
|
921
|
+
judgment_version: string;
|
|
922
|
+
access: 'public' | 'licensed' | 'remote';
|
|
923
|
+
expected_digests: {
|
|
924
|
+
asset: KDNAExpectedDigest | null;
|
|
925
|
+
content: KDNAExpectedDigest | null;
|
|
926
|
+
runtime_entry_set: KDNAExpectedDigest | null;
|
|
927
|
+
};
|
|
928
|
+
};
|
|
929
|
+
projection_request: {
|
|
930
|
+
profile: 'index' | 'compact' | 'scenario' | 'full';
|
|
931
|
+
accepted_capsule_versions: ['0.1.0'];
|
|
932
|
+
required_digest_profile: 'kdna.digest-evidence';
|
|
933
|
+
required_digest_profile_version: '0.1.0';
|
|
934
|
+
require_packaged_asset: true;
|
|
935
|
+
};
|
|
936
|
+
host_request: { accepted_protocols: ['kdna.agent-host'] };
|
|
937
|
+
result_request: { shape: 'structured_judgment' };
|
|
938
|
+
budget: KDNAExecutionBudget;
|
|
939
|
+
constraints: { enforce_before_host: true; reject_on_exceed: true };
|
|
940
|
+
trace_policy: { emit: true; storage: 'ephemeral' | 'session' | 'persistent' };
|
|
941
|
+
integrity: {
|
|
942
|
+
profile: 'kdna.canonicalization.consumption-plan-jcs';
|
|
943
|
+
profile_version: '0.1.0';
|
|
944
|
+
plan_digest: string;
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
export interface KDNAExecutionBudget {
|
|
949
|
+
max_projection_chars: number;
|
|
950
|
+
max_task_chars: number;
|
|
951
|
+
deadline_ms: number;
|
|
952
|
+
max_tokens: number | null;
|
|
953
|
+
max_model_calls: number | null;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
export interface KDNAAgentHostCapabilities {
|
|
957
|
+
type: 'kdna.agent-host-capabilities';
|
|
958
|
+
protocol_version: '0.1.0';
|
|
959
|
+
capability_basis: 'registered_descriptor' | 'legacy_assumption';
|
|
960
|
+
host_protocols: Array<'kdna.agent-host'>;
|
|
961
|
+
capsule_versions: Array<'0.1.0'>;
|
|
962
|
+
capsule_digest_profiles: Array<'kdna.canonicalization.runtime-capsule-jcs'>;
|
|
963
|
+
capsule_digest_profile_versions: ['0.1.0'];
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
export interface KDNAAgentHostRequest {
|
|
967
|
+
protocol: 'kdna.agent-host';
|
|
968
|
+
protocol_version: '0.1.0';
|
|
969
|
+
request_id: string;
|
|
970
|
+
plan_ref: {
|
|
971
|
+
plan_id: string;
|
|
972
|
+
plan_digest_profile: 'kdna.canonicalization.consumption-plan-jcs';
|
|
973
|
+
plan_digest_profile_version: '0.1.0';
|
|
974
|
+
plan_digest: string;
|
|
975
|
+
};
|
|
976
|
+
runtime_contract: {
|
|
977
|
+
capsule_version: '0.1.0';
|
|
978
|
+
capsule_digest_profile: 'kdna.canonicalization.runtime-capsule-jcs';
|
|
979
|
+
capsule_digest_profile_version: '0.1.0';
|
|
980
|
+
capsule_delivery_digest: string;
|
|
981
|
+
};
|
|
982
|
+
projection_contract: KDNAConsumptionPlan['projection_request'] extends infer T
|
|
983
|
+
? Omit<Extract<T, object>, 'accepted_capsule_versions'>
|
|
984
|
+
: never;
|
|
985
|
+
result_contract: { shape: 'structured_judgment' };
|
|
986
|
+
budget: KDNAExecutionBudget;
|
|
987
|
+
constraints: KDNAConsumptionPlan['constraints'];
|
|
988
|
+
phase: 'single_judgment';
|
|
989
|
+
task: KDNAConsumptionPlan['task'];
|
|
990
|
+
authority: { asset_id: string; role: 'primary'; final_decision: true };
|
|
991
|
+
asset: KDNAConsumptionPlan['asset_ref'] & { role: 'primary' };
|
|
992
|
+
capsule: KDNARuntimeCapsule;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
export interface KDNAAgentHostReceipt {
|
|
996
|
+
protocol: 'kdna.agent-host';
|
|
997
|
+
protocol_version: '0.1.0';
|
|
998
|
+
request_id: string;
|
|
999
|
+
runtime_receipt: {
|
|
1000
|
+
type: 'kdna.agent-host.runtime-receipt';
|
|
1001
|
+
contract_version: '0.1.0';
|
|
1002
|
+
capsule_version: '0.1.0';
|
|
1003
|
+
capsule_digest_profile: 'kdna.canonicalization.runtime-capsule-jcs';
|
|
1004
|
+
capsule_digest_profile_version: '0.1.0';
|
|
1005
|
+
sender_capsule_delivery_digest: string;
|
|
1006
|
+
host_recomputed_capsule_delivery_digest: string;
|
|
1007
|
+
echoed_capsule_delivery_digest: string;
|
|
1008
|
+
capsule_delivery_comparison: 'matched' | 'mismatched';
|
|
1009
|
+
capsule_schema_validation: 'passed';
|
|
1010
|
+
asset_id_correlation: 'matched';
|
|
1011
|
+
provider_execution_status: 'completed' | 'not_started' | 'failed' | 'cancelled' | 'timed_out';
|
|
1012
|
+
semantic_consumption: { state: 'not_observed'; basis: null };
|
|
1013
|
+
model_identity: { value: string | null; basis: 'host_reported' | 'not_observed' };
|
|
1014
|
+
usage: {
|
|
1015
|
+
elapsed_ms: number;
|
|
1016
|
+
elapsed_basis: 'host_monotonic';
|
|
1017
|
+
tokens_used: number | null;
|
|
1018
|
+
model_calls: number | null;
|
|
1019
|
+
basis: 'host_reported' | 'not_observed';
|
|
1020
|
+
};
|
|
1021
|
+
};
|
|
1022
|
+
outcome: {
|
|
1023
|
+
judgment: { answer: string; reasoning: string[]; confidence: string | null };
|
|
1024
|
+
usage: { tokens_used: number; model_calls: number } | null;
|
|
1025
|
+
} | null;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
export interface KDNABudgetEvidence {
|
|
1029
|
+
limits: KDNAExecutionBudget;
|
|
1030
|
+
actual: {
|
|
1031
|
+
projection_chars: number | null;
|
|
1032
|
+
task_chars: number;
|
|
1033
|
+
elapsed_ms: number | null;
|
|
1034
|
+
elapsed_basis: 'host_monotonic' | 'not_observed';
|
|
1035
|
+
tokens_used: number | null;
|
|
1036
|
+
model_calls: number | null;
|
|
1037
|
+
usage_basis: 'host_reported' | 'not_observed';
|
|
1038
|
+
};
|
|
1039
|
+
comparison: {
|
|
1040
|
+
projection_chars: 'within_limit' | 'exceeded' | 'not_observed';
|
|
1041
|
+
task_chars: 'within_limit' | 'exceeded';
|
|
1042
|
+
elapsed_ms: 'within_limit' | 'exceeded' | 'not_observed';
|
|
1043
|
+
tokens_used: 'within_limit' | 'exceeded' | 'not_limited' | 'not_observed';
|
|
1044
|
+
model_calls: 'within_limit' | 'exceeded' | 'not_limited' | 'not_observed';
|
|
1045
|
+
overall: 'within_limit' | 'exceeded' | 'not_observed';
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
export interface KDNAJudgmentTraceIssue {
|
|
1050
|
+
code: string;
|
|
1051
|
+
message: string;
|
|
1052
|
+
phase: 'plan' | 'negotiation' | 'load' | 'budget' | 'delivery' | 'host' | 'execution';
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
export interface KDNAJudgmentTrace {
|
|
1056
|
+
type: 'kdna.judgment-trace';
|
|
1057
|
+
contract_version: '0.1.0';
|
|
1058
|
+
trace_id: string;
|
|
1059
|
+
plan_ref: {
|
|
1060
|
+
plan_id: string;
|
|
1061
|
+
plan_digest_profile: 'kdna.canonicalization.consumption-plan-jcs';
|
|
1062
|
+
plan_digest_profile_version: '0.1.0';
|
|
1063
|
+
plan_digest: string;
|
|
1064
|
+
comparison: 'matched';
|
|
1065
|
+
};
|
|
1066
|
+
parent_trace_id: string | null;
|
|
1067
|
+
timestamp: string;
|
|
1068
|
+
overall_status:
|
|
1069
|
+
'execution_completed' | 'blocked' | 'execution_failed' | 'cancelled' | 'timed_out';
|
|
1070
|
+
runtime_contract: {
|
|
1071
|
+
plan_capsule_versions: ['0.1.0'];
|
|
1072
|
+
core_capsule_versions: Array<'0.1.0'>;
|
|
1073
|
+
plan_host_protocols: ['kdna.agent-host'];
|
|
1074
|
+
host_capabilities: KDNAAgentHostCapabilities;
|
|
1075
|
+
negotiation_state: 'selected' | 'blocked' | 'not_started';
|
|
1076
|
+
selected_capsule_version: '0.1.0' | null;
|
|
1077
|
+
selected_host_protocol: 'kdna.agent-host' | null;
|
|
1078
|
+
issue_code:
|
|
1079
|
+
| 'KDNA_CAPSULE_CONTRACT_VERSION_UNSUPPORTED'
|
|
1080
|
+
| 'KDNA_HOST_PROTOCOL_UNSUPPORTED'
|
|
1081
|
+
| 'KDNA_HOST_CAPSULE_PAIR_UNSUPPORTED'
|
|
1082
|
+
| null;
|
|
1083
|
+
};
|
|
1084
|
+
asset_identity: {
|
|
1085
|
+
asset_id: string;
|
|
1086
|
+
asset_uid: string;
|
|
1087
|
+
version: string;
|
|
1088
|
+
judgment_version: string;
|
|
1089
|
+
access: 'public' | 'licensed' | 'remote';
|
|
1090
|
+
};
|
|
1091
|
+
digest_evidence: KDNADigestEvidence;
|
|
1092
|
+
capsule_delivery_evidence: {
|
|
1093
|
+
basis: 'kdna.canonicalization.runtime-capsule-jcs';
|
|
1094
|
+
basis_version: '0.1.0';
|
|
1095
|
+
observed: string | null;
|
|
1096
|
+
sender_computed: boolean;
|
|
1097
|
+
host_recomputed: string | null;
|
|
1098
|
+
host_echoed: string | null;
|
|
1099
|
+
delivered_capsule_version: '0.1.0' | null;
|
|
1100
|
+
host_boundary_comparison:
|
|
1101
|
+
'matched' | 'mismatched' | 'not_delivered' | 'not_observed' | 'unavailable';
|
|
1102
|
+
request_id: string | null;
|
|
1103
|
+
};
|
|
1104
|
+
projection_actual: {
|
|
1105
|
+
profile: 'index' | 'compact' | 'scenario' | 'full' | null;
|
|
1106
|
+
capsule_delivery_digest: string | null;
|
|
1107
|
+
profile_deviated_from_plan: boolean | null;
|
|
1108
|
+
};
|
|
1109
|
+
host_receipt: KDNAAgentHostReceipt | null;
|
|
1110
|
+
execution: {
|
|
1111
|
+
delivery_status: 'correlated_response' | 'rejected_before_execution' | 'not_delivered';
|
|
1112
|
+
semantic_consumption: { state: 'not_observed'; basis: null };
|
|
1113
|
+
execution_status: 'completed' | 'not_started' | 'failed' | 'cancelled' | 'timed_out';
|
|
1114
|
+
conformance_status: 'not_evaluated';
|
|
1115
|
+
model_identity: { value: string | null; basis: 'host_reported' | 'not_observed' };
|
|
1116
|
+
};
|
|
1117
|
+
budget: KDNABudgetEvidence;
|
|
1118
|
+
result_ref: {
|
|
1119
|
+
shape: 'structured_judgment';
|
|
1120
|
+
result_digest: string;
|
|
1121
|
+
basis: 'kdna.canonicalization.result-jcs';
|
|
1122
|
+
stored: boolean;
|
|
1123
|
+
} | null;
|
|
1124
|
+
errors: KDNAJudgmentTraceIssue[];
|
|
601
1125
|
warnings: string[];
|
|
602
|
-
asset: KdnaAssetVerifyResult;
|
|
603
|
-
lint: LintResult;
|
|
604
|
-
schema: ValidationResult;
|
|
605
|
-
cross_file: ValidationResult;
|
|
606
1126
|
}
|
|
607
1127
|
|
|
1128
|
+
export interface KDNARuntimePairContext {
|
|
1129
|
+
trustedPlanDigest: string;
|
|
1130
|
+
capabilities: KDNAAgentHostCapabilities;
|
|
1131
|
+
coreCapsuleVersions: readonly string[];
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
export interface KDNAAgentHostValidationContext extends KDNARuntimePairContext {
|
|
1135
|
+
plan: KDNAConsumptionPlan;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
export interface KDNAJudgmentTraceContext extends KDNAAgentHostValidationContext {
|
|
1139
|
+
request: KDNAAgentHostRequest | null;
|
|
1140
|
+
receipt: KDNAAgentHostReceipt | null;
|
|
1141
|
+
trustedDeliveryObservation: 'host_receipt' | 'not_delivered' | 'not_observed';
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
export interface KDNAPreHostBudgetBlockedTraceContext
|
|
1145
|
+
extends KDNAAgentHostValidationContext {
|
|
1146
|
+
capsule: KDNARuntimeCapsule;
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
export const PLAN_DIGEST_PROFILE: 'kdna.canonicalization.consumption-plan-jcs';
|
|
1150
|
+
export const PLAN_DIGEST_PROFILE_VERSION: '0.1.0';
|
|
1151
|
+
export const HOST_PROTOCOL: 'kdna.agent-host';
|
|
1152
|
+
export const HOST_PROTOCOL_VERSION: '0.1.0';
|
|
1153
|
+
export const DEFAULT_CORE_CAPSULE_CONTRACT_VERSIONS: readonly ['0.1.0'];
|
|
1154
|
+
export function parseRuntimeContractJson(
|
|
1155
|
+
input: string | Uint8Array,
|
|
1156
|
+
options?: { maxBytes?: number; maxDepth?: number },
|
|
1157
|
+
): KDNAJsonValue;
|
|
1158
|
+
export function computeConsumptionPlanDigest(plan: KDNAConsumptionPlan): string;
|
|
1159
|
+
export function buildConsumptionPlan(input: {
|
|
1160
|
+
plan_id: string;
|
|
1161
|
+
created_at: string;
|
|
1162
|
+
task: KDNAConsumptionPlan['task'];
|
|
1163
|
+
asset_ref: KDNAConsumptionPlan['asset_ref'];
|
|
1164
|
+
projection_profile: KDNAConsumptionPlan['projection_request']['profile'];
|
|
1165
|
+
budget: KDNAExecutionBudget;
|
|
1166
|
+
constraints: KDNAConsumptionPlan['constraints'];
|
|
1167
|
+
trace_policy: KDNAConsumptionPlan['trace_policy'];
|
|
1168
|
+
}): KDNAConsumptionPlan;
|
|
1169
|
+
export function validateConsumptionPlan(
|
|
1170
|
+
plan: unknown,
|
|
1171
|
+
context: { trustedPlanDigest: string },
|
|
1172
|
+
): KDNAExecutionContractValidationResult;
|
|
1173
|
+
export function negotiateRuntimePair(
|
|
1174
|
+
plan: KDNAConsumptionPlan,
|
|
1175
|
+
context: KDNARuntimePairContext,
|
|
1176
|
+
): {
|
|
1177
|
+
state: 'selected' | 'blocked';
|
|
1178
|
+
capsule_version: '0.1.0' | null;
|
|
1179
|
+
host_protocol: 'kdna.agent-host' | null;
|
|
1180
|
+
issue_code: string | null;
|
|
1181
|
+
};
|
|
1182
|
+
export function buildAgentHostRequest(
|
|
1183
|
+
input: { request_id: string; capsule: KDNARuntimeCapsule },
|
|
1184
|
+
context: KDNAAgentHostValidationContext,
|
|
1185
|
+
): KDNAAgentHostRequest;
|
|
1186
|
+
export function validateAgentHostRequest(
|
|
1187
|
+
request: unknown,
|
|
1188
|
+
context: KDNAAgentHostValidationContext,
|
|
1189
|
+
): KDNAExecutionContractValidationResult;
|
|
1190
|
+
export function validateAgentHostReceipt(
|
|
1191
|
+
receipt: unknown,
|
|
1192
|
+
context: { request: KDNAAgentHostRequest },
|
|
1193
|
+
): KDNAExecutionContractValidationResult;
|
|
1194
|
+
export function deriveBudgetEvidence(
|
|
1195
|
+
plan: KDNAConsumptionPlan,
|
|
1196
|
+
context: {
|
|
1197
|
+
trustedPlanDigest: string;
|
|
1198
|
+
request: KDNAAgentHostRequest | null;
|
|
1199
|
+
receipt: KDNAAgentHostReceipt | null;
|
|
1200
|
+
},
|
|
1201
|
+
): KDNABudgetEvidence;
|
|
1202
|
+
export function buildPreHostBudgetBlockedTrace(
|
|
1203
|
+
input: {
|
|
1204
|
+
trace_id: string;
|
|
1205
|
+
timestamp: string;
|
|
1206
|
+
capsule: KDNARuntimeCapsule;
|
|
1207
|
+
parent_trace_id?: string | null;
|
|
1208
|
+
warnings?: string[];
|
|
1209
|
+
},
|
|
1210
|
+
context: KDNAAgentHostValidationContext,
|
|
1211
|
+
): KDNAJudgmentTrace;
|
|
1212
|
+
export function validatePreHostBudgetBlockedTrace(
|
|
1213
|
+
trace: unknown,
|
|
1214
|
+
context: KDNAPreHostBudgetBlockedTraceContext,
|
|
1215
|
+
): KDNAExecutionContractValidationResult;
|
|
1216
|
+
export function buildJudgmentTrace(
|
|
1217
|
+
input: {
|
|
1218
|
+
trace_id: string;
|
|
1219
|
+
timestamp: string;
|
|
1220
|
+
overall_status: KDNAJudgmentTrace['overall_status'];
|
|
1221
|
+
parent_trace_id?: string | null;
|
|
1222
|
+
result_stored?: boolean;
|
|
1223
|
+
errors?: KDNAJudgmentTraceIssue[];
|
|
1224
|
+
warnings?: string[];
|
|
1225
|
+
},
|
|
1226
|
+
context: KDNAJudgmentTraceContext,
|
|
1227
|
+
): KDNAJudgmentTrace;
|
|
1228
|
+
export function validateJudgmentTrace(
|
|
1229
|
+
trace: unknown,
|
|
1230
|
+
context: KDNAJudgmentTraceContext,
|
|
1231
|
+
): KDNAExecutionContractValidationResult;
|
|
1232
|
+
|
|
608
1233
|
export interface KDNAMatchResult extends KDNAInspectResult {
|
|
609
1234
|
score: number;
|
|
610
1235
|
matched: string[];
|
|
@@ -623,52 +1248,172 @@ export interface KDNAComposeResult {
|
|
|
623
1248
|
|
|
624
1249
|
export function openKDNA(input: KDNAAssetInput): Promise<KdnaAsset>;
|
|
625
1250
|
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
|
-
|
|
1251
|
+
export function inspectKDNA(
|
|
1252
|
+
input: KDNAAssetInput,
|
|
1253
|
+
options?: { verify?: boolean } & KdnaDecryptOptions,
|
|
1254
|
+
): Promise<KDNAInspectResult>;
|
|
1255
|
+
export function inspectKDNASync(
|
|
1256
|
+
input: KDNAAssetInput,
|
|
1257
|
+
options?: { verify?: boolean } & KdnaDecryptOptions,
|
|
1258
|
+
): KDNAInspectResult;
|
|
1259
|
+
export function loadKDNA(
|
|
1260
|
+
input: KDNAAssetInput,
|
|
1261
|
+
options?: {
|
|
1262
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full' | string;
|
|
1263
|
+
as?: 'json' | 'prompt' | string;
|
|
1264
|
+
} & KdnaDecryptOptions,
|
|
1265
|
+
): Promise<KDNARuntimeCapsule | Record<string, any>>;
|
|
1266
|
+
export function loadKDNASync(
|
|
1267
|
+
input: KDNAAssetInput,
|
|
1268
|
+
options?: {
|
|
1269
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full' | string;
|
|
1270
|
+
as?: 'json' | 'prompt' | string;
|
|
1271
|
+
} & KdnaDecryptOptions,
|
|
1272
|
+
): KDNARuntimeCapsule | Record<string, any>;
|
|
1273
|
+
export function validateKDNA(
|
|
1274
|
+
input: KDNAAssetInput,
|
|
1275
|
+
options?: Record<string, any>,
|
|
1276
|
+
): Promise<KDNAValidationReport>;
|
|
1277
|
+
export function validateKDNASync(
|
|
1278
|
+
input: KDNAAssetInput,
|
|
1279
|
+
options?: Record<string, any>,
|
|
1280
|
+
): KDNAValidationReport;
|
|
1281
|
+
export function renderForAgent(
|
|
1282
|
+
input: KDNAAssetInput,
|
|
1283
|
+
options?: {
|
|
1284
|
+
profile?: 'compact' | 'scenario' | 'full' | string;
|
|
1285
|
+
input?: string;
|
|
1286
|
+
} & KdnaDecryptOptions,
|
|
1287
|
+
): Promise<string>;
|
|
1288
|
+
export function renderForAgentSync(
|
|
1289
|
+
input: KDNAAssetInput,
|
|
1290
|
+
options?: {
|
|
1291
|
+
profile?: 'compact' | 'scenario' | 'full' | string;
|
|
1292
|
+
input?: string;
|
|
1293
|
+
} & KdnaDecryptOptions,
|
|
1294
|
+
): string;
|
|
1295
|
+
export function verifyAsset(
|
|
1296
|
+
input: KDNAAssetInput,
|
|
1297
|
+
options?: {
|
|
1298
|
+
asset_digest?: string;
|
|
1299
|
+
content_digest?: string;
|
|
1300
|
+
requireSignature?: boolean;
|
|
1301
|
+
requireDecryption?: boolean;
|
|
1302
|
+
} & KdnaDecryptOptions,
|
|
1303
|
+
): Promise<KdnaAssetVerifyResult>;
|
|
1304
|
+
export function verifyAssetSync(
|
|
1305
|
+
input: KDNAAssetInput,
|
|
1306
|
+
options?: {
|
|
1307
|
+
asset_digest?: string;
|
|
1308
|
+
content_digest?: string;
|
|
1309
|
+
requireSignature?: boolean;
|
|
1310
|
+
requireDecryption?: boolean;
|
|
1311
|
+
} & KdnaDecryptOptions,
|
|
1312
|
+
): KdnaAssetVerifyResult;
|
|
1313
|
+
export function verifyDigest(
|
|
1314
|
+
input: KDNAAssetInput,
|
|
1315
|
+
expectedDigest: string,
|
|
1316
|
+
options?: KdnaDecryptOptions,
|
|
1317
|
+
): Promise<KdnaAssetVerifyResult>;
|
|
1318
|
+
export function verifyDigestSync(
|
|
1319
|
+
input: KDNAAssetInput,
|
|
1320
|
+
expectedDigest: string,
|
|
1321
|
+
options?: KdnaDecryptOptions,
|
|
1322
|
+
): KdnaAssetVerifyResult;
|
|
1323
|
+
export function verifySignature(
|
|
1324
|
+
input: KDNAAssetInput,
|
|
1325
|
+
options?: KdnaDecryptOptions,
|
|
1326
|
+
): Promise<KdnaAssetVerifyResult>;
|
|
1327
|
+
export function verifySignatureSync(
|
|
1328
|
+
input: KDNAAssetInput,
|
|
1329
|
+
options?: KdnaDecryptOptions,
|
|
1330
|
+
): KdnaAssetVerifyResult;
|
|
1331
|
+
export function matchDomain(
|
|
1332
|
+
input: string,
|
|
1333
|
+
candidates: Array<KDNAAssetInput | KDNAInspectResult>,
|
|
1334
|
+
options?: KdnaDecryptOptions,
|
|
1335
|
+
): Promise<KDNAMatchResult[]>;
|
|
1336
|
+
export function matchDomainSync(
|
|
1337
|
+
input: string,
|
|
1338
|
+
candidates: Array<KDNAAssetInput | KDNAInspectResult>,
|
|
1339
|
+
options?: KdnaDecryptOptions,
|
|
1340
|
+
): KDNAMatchResult[];
|
|
1341
|
+
/**
|
|
1342
|
+
* @deprecated Current Cluster/Capsule composition semantics are not yet
|
|
1343
|
+
* defined. This function rejects with KDNA_COMPOSE_PROTOCOL_UNAVAILABLE.
|
|
1344
|
+
*/
|
|
1345
|
+
export function composeKDNA(
|
|
1346
|
+
inputs: KDNAAssetInput[],
|
|
1347
|
+
options?: {
|
|
1348
|
+
input?: string;
|
|
1349
|
+
profile?: 'compact' | 'scenario' | 'full' | string;
|
|
1350
|
+
separator?: string;
|
|
1351
|
+
} & KdnaDecryptOptions,
|
|
1352
|
+
): Promise<never>;
|
|
643
1353
|
|
|
644
1354
|
// KDNA Core — authoring source and packaged runtime API
|
|
645
1355
|
export const MIMETYPE: string;
|
|
646
1356
|
export const REQUIRED_DIR_ENTRIES: string[];
|
|
647
1357
|
|
|
1358
|
+
export interface KDNALayoutEntry {
|
|
1359
|
+
name: string;
|
|
1360
|
+
data: Uint8Array;
|
|
1361
|
+
method: number;
|
|
1362
|
+
[key: string]: unknown;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
export interface KDNALayout {
|
|
1366
|
+
kind: 'dir' | 'file' | 'memory';
|
|
1367
|
+
map: Record<string, Uint8Array | null>;
|
|
1368
|
+
manifest: KDNAManifest;
|
|
1369
|
+
entries: KDNALayoutEntry[] | null;
|
|
1370
|
+
containerDigest: string | null;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
export function readLayout(inputPath: string): KDNALayout;
|
|
1374
|
+
|
|
648
1375
|
export interface KDNAChecksumEntry {
|
|
649
1376
|
algorithm: 'sha256';
|
|
650
1377
|
value: string;
|
|
651
1378
|
}
|
|
652
1379
|
|
|
653
1380
|
export interface KDNAChecksums {
|
|
1381
|
+
digest_profile?: 'kdna.digest-basis.runtime-entry-set';
|
|
1382
|
+
digest_profile_version?: '0.1.0';
|
|
1383
|
+
covered_entries?: ['kdna.json', 'payload.kdnab'];
|
|
654
1384
|
algorithm: 'sha256';
|
|
655
|
-
manifest_digest
|
|
656
|
-
payload_digest
|
|
657
|
-
|
|
658
|
-
entries
|
|
1385
|
+
manifest_digest?: string;
|
|
1386
|
+
payload_digest?: string;
|
|
1387
|
+
entry_set_digest?: string;
|
|
1388
|
+
entries?: Record<string, KDNAChecksumEntry>;
|
|
659
1389
|
}
|
|
660
1390
|
|
|
661
1391
|
export function isKdnaSourceDir(inputPath: string): boolean;
|
|
662
1392
|
export function detectContainerFormat(inputPath: string): 'kdna' | null;
|
|
663
|
-
export function inspect(
|
|
664
|
-
|
|
1393
|
+
export function inspect(
|
|
1394
|
+
input: string | Uint8Array,
|
|
1395
|
+
options?: Record<string, any>,
|
|
1396
|
+
): Record<string, any>;
|
|
1397
|
+
export const KDNA_LOADER_VERSION: '0.19.0';
|
|
1398
|
+
export const STRICT_LOADER_VERSION: RegExp;
|
|
1399
|
+
export function parseLoaderVersion(version: unknown): readonly [string, string, string] | null;
|
|
1400
|
+
export function compareLoaderVersions(left: string, right: string): -1 | 0 | 1;
|
|
1401
|
+
export function assessLoaderCompatibility(manifest: Partial<KDNAManifest> | null | undefined): {
|
|
1402
|
+
loader_version: string;
|
|
1403
|
+
min_loader_version: string | null;
|
|
1404
|
+
loader_compatible: boolean | null;
|
|
1405
|
+
};
|
|
1406
|
+
export function validate(
|
|
1407
|
+
input: string | Uint8Array,
|
|
1408
|
+
options?: Record<string, any>,
|
|
1409
|
+
): KDNAValidationReport;
|
|
665
1410
|
export interface KDNALoadPlanIssue {
|
|
666
1411
|
code: string;
|
|
667
1412
|
severity: 'info' | 'warning' | 'blocking' | string;
|
|
668
1413
|
message: string;
|
|
669
1414
|
}
|
|
670
1415
|
export interface KDNALoadPlan {
|
|
671
|
-
|
|
1416
|
+
format_version: '0.1.0' | null;
|
|
672
1417
|
asset: {
|
|
673
1418
|
asset_id: string | null;
|
|
674
1419
|
asset_uid: string | null;
|
|
@@ -704,28 +1449,67 @@ export interface KDNALoadPlan {
|
|
|
704
1449
|
| string;
|
|
705
1450
|
can_load_now: boolean;
|
|
706
1451
|
projection_policy: 'minimal' | 'remote' | 'none' | string;
|
|
707
|
-
input_fingerprint:
|
|
1452
|
+
input_fingerprint: {
|
|
1453
|
+
has_password_input: boolean;
|
|
1454
|
+
entitlement_input: 'active' | 'expired' | 'revoked' | 'offline_grace' | null;
|
|
1455
|
+
source_fingerprint: string;
|
|
1456
|
+
} | null;
|
|
708
1457
|
checks: Record<string, boolean>;
|
|
709
1458
|
issues: KDNALoadPlanIssue[];
|
|
710
1459
|
source: {
|
|
711
|
-
kind: 'dir' | 'file' | string | null;
|
|
712
|
-
path: string;
|
|
1460
|
+
kind: 'dir' | 'file' | 'memory' | string | null;
|
|
1461
|
+
path: string | null;
|
|
713
1462
|
};
|
|
714
1463
|
}
|
|
715
|
-
export function planLoad(
|
|
1464
|
+
export function planLoad(
|
|
1465
|
+
input: string | Uint8Array,
|
|
1466
|
+
options?: {
|
|
1467
|
+
password?: string;
|
|
1468
|
+
hasPassword?: boolean;
|
|
1469
|
+
entitlement?: KDNAVerifiedExternalEntitlement | Record<string, any>;
|
|
1470
|
+
},
|
|
1471
|
+
): KDNALoadPlan;
|
|
716
1472
|
export function buildChecksums(sourceDir: string): KDNAChecksums;
|
|
717
1473
|
export function pack(sourceDir: string, outputPath: string): void;
|
|
718
1474
|
export function unpack(inputPath: string, outputDir: string): void;
|
|
719
|
-
export function loadAuthorized(
|
|
720
|
-
|
|
721
|
-
|
|
1475
|
+
export function loadAuthorized(
|
|
1476
|
+
input: string | Uint8Array,
|
|
1477
|
+
options?: {
|
|
1478
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full' | string;
|
|
1479
|
+
as?: 'json' | 'prompt' | string;
|
|
1480
|
+
},
|
|
1481
|
+
): KDNARuntimeCapsule | Record<string, any>;
|
|
1482
|
+
export function load(
|
|
1483
|
+
input: string | Uint8Array,
|
|
1484
|
+
options?: {
|
|
1485
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full' | string;
|
|
1486
|
+
as?: 'json' | 'prompt' | string;
|
|
1487
|
+
},
|
|
1488
|
+
): KDNARuntimeCapsule | Record<string, any>;
|
|
1489
|
+
export function loadAsset(
|
|
1490
|
+
input: string | Uint8Array,
|
|
1491
|
+
options?: {
|
|
1492
|
+
profile?: 'index' | 'compact' | 'scenario' | 'full' | string;
|
|
1493
|
+
as?: 'json' | 'prompt' | string;
|
|
1494
|
+
},
|
|
1495
|
+
): KDNARuntimeCapsule | Record<string, any>;
|
|
722
1496
|
export const FORBIDDEN_OUTPUT_TERMS: readonly string[];
|
|
723
1497
|
|
|
724
|
-
|
|
725
|
-
|
|
1498
|
+
export interface KDNASemver {
|
|
1499
|
+
major: number;
|
|
1500
|
+
minor: number;
|
|
1501
|
+
patch: number;
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
export function parseSemver(version: string): KDNASemver | null;
|
|
1505
|
+
export function compareSemver(left: string, right: string): number;
|
|
1506
|
+
export function satisfies(version: string, range: string): boolean;
|
|
726
1507
|
|
|
727
1508
|
// Validate
|
|
728
|
-
export function validateDomainSchema(
|
|
1509
|
+
export function validateDomainSchema(
|
|
1510
|
+
dataMap: KDNAFileDataMap,
|
|
1511
|
+
schemaMap?: Record<string, any>,
|
|
1512
|
+
): ValidationResult;
|
|
729
1513
|
export function validateCrossFile(dataMap: KDNAFileDataMap): ValidationResult;
|
|
730
1514
|
|
|
731
1515
|
// Render
|
|
@@ -735,6 +1519,213 @@ export function renderCard(title: string, count: number | undefined, items: stri
|
|
|
735
1519
|
|
|
736
1520
|
// Compose
|
|
737
1521
|
export function composeContext(domains: LoadedDomain[], options?: { separator?: string }): string;
|
|
738
|
-
export function classifySignals(
|
|
739
|
-
|
|
740
|
-
|
|
1522
|
+
export function classifySignals(
|
|
1523
|
+
input: string,
|
|
1524
|
+
domains: Array<{ id: string; core: { trigger_signals?: string[] } }>,
|
|
1525
|
+
): number[];
|
|
1526
|
+
export function composeChecks(
|
|
1527
|
+
domains: Array<{
|
|
1528
|
+
id: string;
|
|
1529
|
+
core: { meta: { domain: string } };
|
|
1530
|
+
patterns: { self_check: string[] };
|
|
1531
|
+
}>,
|
|
1532
|
+
): string[];
|
|
1533
|
+
export function loadAndCompose(
|
|
1534
|
+
dataMaps: KDNAFileDataMap[],
|
|
1535
|
+
options?: LoadOptions & { separator?: string },
|
|
1536
|
+
): { domains: LoadedDomain[]; context: string; activeIndices: number[] };
|
|
1537
|
+
|
|
1538
|
+
export interface KDNAComposableAxiom {
|
|
1539
|
+
id: string;
|
|
1540
|
+
one_sentence: string;
|
|
1541
|
+
applies_when?: string[];
|
|
1542
|
+
does_not_apply_when?: string[];
|
|
1543
|
+
failure_risk?: string;
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
export interface KDNAComposableDomain {
|
|
1547
|
+
id: string;
|
|
1548
|
+
name?: string;
|
|
1549
|
+
role?: string;
|
|
1550
|
+
required?: boolean;
|
|
1551
|
+
core: {
|
|
1552
|
+
meta?: { domain?: string };
|
|
1553
|
+
axioms?: KDNAComposableAxiom[];
|
|
1554
|
+
stances?: Array<string | { stance: string }>;
|
|
1555
|
+
trigger_signals?: string[];
|
|
1556
|
+
negative_signals?: string[];
|
|
1557
|
+
[key: string]: unknown;
|
|
1558
|
+
};
|
|
1559
|
+
patterns?: {
|
|
1560
|
+
misunderstandings?: Array<{
|
|
1561
|
+
id: string;
|
|
1562
|
+
wrong: string;
|
|
1563
|
+
correct: string;
|
|
1564
|
+
failure_risk?: string;
|
|
1565
|
+
}>;
|
|
1566
|
+
terminology?: {
|
|
1567
|
+
banned_terms?: Array<string | { term: string; replace_with?: string }>;
|
|
1568
|
+
};
|
|
1569
|
+
self_check?: Array<string | { question: string }>;
|
|
1570
|
+
[key: string]: unknown;
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
export interface KDNAAttribution {
|
|
1575
|
+
domain: string;
|
|
1576
|
+
type: 'axiom' | 'misunderstanding' | 'banned_term' | 'self_check';
|
|
1577
|
+
index: number;
|
|
1578
|
+
id?: string;
|
|
1579
|
+
term?: string;
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
export function composeContextWithAttribution(
|
|
1583
|
+
domains: KDNAComposableDomain[],
|
|
1584
|
+
options?: { separator?: string },
|
|
1585
|
+
): { context: string; attributionMap: Record<string, KDNAAttribution> };
|
|
1586
|
+
|
|
1587
|
+
export interface KDNADomainSelection {
|
|
1588
|
+
id: string;
|
|
1589
|
+
name?: string;
|
|
1590
|
+
role?: string;
|
|
1591
|
+
reason: 'required' | 'signal_match' | 'blocked by does_not_apply_when' | 'no signal match';
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
export function classifySignalsAcrossDomains(
|
|
1595
|
+
input: string,
|
|
1596
|
+
domainEntries: KDNAComposableDomain[],
|
|
1597
|
+
): { selected: KDNADomainSelection[]; excluded: KDNADomainSelection[] };
|
|
1598
|
+
|
|
1599
|
+
export interface KDNAClusterManifest {
|
|
1600
|
+
domains?: Array<{ id: string; role?: string; required?: boolean }>;
|
|
1601
|
+
[key: string]: unknown;
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
export interface KDNALoadedClusterDomain extends KDNAComposableDomain {
|
|
1605
|
+
name: string;
|
|
1606
|
+
role: string;
|
|
1607
|
+
required: boolean;
|
|
1608
|
+
patterns: NonNullable<KDNAComposableDomain['patterns']>;
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
export function loadCluster(
|
|
1612
|
+
clusterManifestPath: string,
|
|
1613
|
+
domainLoader: (domainId: string) => {
|
|
1614
|
+
core: KDNAComposableDomain['core'];
|
|
1615
|
+
patterns: NonNullable<KDNAComposableDomain['patterns']>;
|
|
1616
|
+
} | null,
|
|
1617
|
+
): { manifest: KDNAClusterManifest; domains: KDNALoadedClusterDomain[]; errors: string[] };
|
|
1618
|
+
|
|
1619
|
+
export interface KDNADomainConflict {
|
|
1620
|
+
type: 'term_conflict' | 'stance_conflict';
|
|
1621
|
+
domains: string[];
|
|
1622
|
+
description: string;
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
export function detectDomainConflicts(domains: KDNAComposableDomain[]): KDNADomainConflict[];
|
|
1626
|
+
|
|
1627
|
+
export function generateClusterTrace(input: {
|
|
1628
|
+
input: string;
|
|
1629
|
+
loadedDomains: Array<{ id?: string; name?: string }>;
|
|
1630
|
+
activeDomains: Array<{ id?: string; name?: string }>;
|
|
1631
|
+
conflicts: KDNADomainConflict[];
|
|
1632
|
+
}): {
|
|
1633
|
+
input: string;
|
|
1634
|
+
timestamp: string;
|
|
1635
|
+
loaded_domains: string[];
|
|
1636
|
+
active_domains: string[];
|
|
1637
|
+
active_count: number;
|
|
1638
|
+
domains_excluded: number;
|
|
1639
|
+
conflicts: KDNADomainConflict[];
|
|
1640
|
+
};
|
|
1641
|
+
|
|
1642
|
+
export interface KDNAWorkPackAssetRef {
|
|
1643
|
+
name: string;
|
|
1644
|
+
version: string;
|
|
1645
|
+
digest?: string;
|
|
1646
|
+
role: 'primary' | 'constraint' | 'fallback';
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
export interface KDNAWorkPackSkill {
|
|
1650
|
+
name: string;
|
|
1651
|
+
type?: string;
|
|
1652
|
+
required?: boolean;
|
|
1653
|
+
mcp_server?: string | null;
|
|
1654
|
+
fallback?: string | null;
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
export interface KDNAWorkPackManifest {
|
|
1658
|
+
format: 'kdna-workpack';
|
|
1659
|
+
format_version: string;
|
|
1660
|
+
name: string;
|
|
1661
|
+
version: string;
|
|
1662
|
+
description: string;
|
|
1663
|
+
status: 'draft' | 'experimental' | 'stable' | 'deprecated';
|
|
1664
|
+
access?: 'public' | 'licensed' | 'remote' | 'enterprise' | 'partner';
|
|
1665
|
+
license?: string;
|
|
1666
|
+
kdna:
|
|
1667
|
+
| { mode: 'single'; asset: KDNAWorkPackAssetRef }
|
|
1668
|
+
| { mode: 'cluster'; assets: KDNAWorkPackAssetRef[] };
|
|
1669
|
+
skills?: KDNAWorkPackSkill[];
|
|
1670
|
+
templates?: { task?: string; output?: string };
|
|
1671
|
+
review_gates?: string[];
|
|
1672
|
+
risk_policy?: string;
|
|
1673
|
+
trace_policy?: string;
|
|
1674
|
+
evals?: string;
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
export interface KDNAWorkPackValidationResult {
|
|
1678
|
+
valid: boolean;
|
|
1679
|
+
errors: string[];
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
export interface KDNAWorkPackValidator {
|
|
1683
|
+
(manifest: KDNAWorkPackManifest): boolean;
|
|
1684
|
+
errors?: Array<{ instancePath?: string; message?: string }> | null;
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
export interface KDNAWorkPackAjv {
|
|
1688
|
+
compile(schema: unknown): KDNAWorkPackValidator;
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
export const WORK_PACK_SCHEMA: Readonly<Record<string, unknown>>;
|
|
1692
|
+
export function validateWorkPackManifest(
|
|
1693
|
+
manifest: KDNAWorkPackManifest,
|
|
1694
|
+
options?: { ajv?: KDNAWorkPackAjv },
|
|
1695
|
+
): KDNAWorkPackValidationResult;
|
|
1696
|
+
export function checkWorkPackStructure(
|
|
1697
|
+
manifest: KDNAWorkPackManifest,
|
|
1698
|
+
rootDir: string,
|
|
1699
|
+
): { complete: boolean; missing: string[] };
|
|
1700
|
+
export function inspectWorkPack(
|
|
1701
|
+
manifest: KDNAWorkPackManifest,
|
|
1702
|
+
rootDir: string,
|
|
1703
|
+
): {
|
|
1704
|
+
name: string;
|
|
1705
|
+
version: string;
|
|
1706
|
+
description: string;
|
|
1707
|
+
status: KDNAWorkPackManifest['status'];
|
|
1708
|
+
access: NonNullable<KDNAWorkPackManifest['access']>;
|
|
1709
|
+
license: string;
|
|
1710
|
+
format_version: string;
|
|
1711
|
+
kdna: {
|
|
1712
|
+
mode: 'single' | 'cluster';
|
|
1713
|
+
assets: Array<Pick<KDNAWorkPackAssetRef, 'name' | 'version' | 'role'>>;
|
|
1714
|
+
};
|
|
1715
|
+
skills: Array<{
|
|
1716
|
+
name: string;
|
|
1717
|
+
type: string;
|
|
1718
|
+
required: boolean;
|
|
1719
|
+
fallback: string | null;
|
|
1720
|
+
}>;
|
|
1721
|
+
templates: { task: string | null; output: string | null } | null;
|
|
1722
|
+
review_gates: number;
|
|
1723
|
+
has_risk_policy: boolean;
|
|
1724
|
+
has_trace_policy: boolean;
|
|
1725
|
+
has_evals: boolean;
|
|
1726
|
+
structural_complete: boolean;
|
|
1727
|
+
missing_files: string[];
|
|
1728
|
+
};
|
|
1729
|
+
export function loadWorkPack(
|
|
1730
|
+
dirPath: string,
|
|
1731
|
+
): { manifest: unknown; error: null } | { manifest: null; error: string };
|