@klickd/core 4.0.0-preview.1 → 4.0.1

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/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  Official JavaScript/TypeScript library for reading and writing `.klickd` portable AI context files.
4
4
 
5
- **One soul. Any model. Any body.**
5
+ **One soul. Any model. Any agent.** — open-source security and continuity layer for every actor in AI.
6
6
 
7
7
  Official page for the open `.klickd` format → **[klickd.app/klickdskill](https://klickd.app/klickdskill)**
8
8
 
9
9
  [![npm version](https://img.shields.io/npm/v/@klickd/core)](https://www.npmjs.com/package/@klickd/core)
10
10
  [![License: CC0-1.0](https://img.shields.io/badge/License-CC0_1.0-lightgrey.svg)](https://creativecommons.org/publicdomain/zero/1.0/)
11
- [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.20320480.svg)](https://doi.org/10.5281/zenodo.20320480)
11
+ [![DOI (v4.0.0)](https://zenodo.org/badge/DOI/10.5281/zenodo.20383133.svg)](https://doi.org/10.5281/zenodo.20383133)
12
12
 
13
13
  ---
14
14
 
@@ -110,6 +110,42 @@ const recovered = await loadKlickd(
110
110
 
111
111
  See `SPEC.md §33` and `examples/v4-preview/` for preview-track details.
112
112
 
113
+ ### Starter `.klickd` skills (v4.0 envelope — non-normative)
114
+
115
+ Four real, structured, downloadable starter `.klickd` skills ship under [`examples/v4/starter-skills/`](https://github.com/Davincc77/klickdskill/tree/main/examples/v4/starter-skills):
116
+
117
+ - [`user.klickd`](https://github.com/Davincc77/klickdskill/blob/main/examples/v4/starter-skills/user.klickd) — `x.klickd/user` (transversal base)
118
+ - [`student.klickd`](https://github.com/Davincc77/klickdskill/blob/main/examples/v4/starter-skills/student.klickd) — `x.klickd/student` (education)
119
+ - [`research.klickd`](https://github.com/Davincc77/klickdskill/blob/main/examples/v4/starter-skills/research.klickd) — `x.klickd/research` (research / evidence discipline)
120
+ - [`coding.klickd`](https://github.com/Davincc77/klickdskill/blob/main/examples/v4/starter-skills/coding.klickd) — `x.klickd/coding` (software engineering)
121
+
122
+ Each skill carries `base_transversal_core`, framework-anchored `competencies[]` (ESCO / DigComp / LifeComp / EQF / CEFR / SFIA), `levels[]`, `mastery[]` (pointer-only), `source_policy`, `evidence_policy`, `verification_gates`, `human_authority`, and a `structured_memory` slice scoped to `memory.x_klickd.<pack>`. They are **non-normative**, **do not claim v4.1 GA**, and trigger **no release**. SHA-256 manifest in [`manifest.json`](https://github.com/Davincc77/klickdskill/blob/main/examples/v4/starter-skills/manifest.json); offline verifier `scripts/verify_starter_skills.py`.
123
+
124
+ #### Bundled in `@klickd/core` 4.0.1
125
+
126
+ Starting with **`@klickd/core` 4.0.1** (a packaging-only patch — the stable
127
+ spec release remains **v4.0.0**), these four starter `.klickd` skills are
128
+ shipped inside the npm tarball under `starter-skills/` and exposed through a
129
+ small helper API. The on-the-wire `.klickd` format, the bundled JSON schemas,
130
+ and the spec are unchanged from v4.0.0. This patch does **not** ship any v4.1
131
+ material and does **not** carry any Chimera branding.
132
+
133
+ ```typescript
134
+ import {
135
+ listStarterSkills,
136
+ getStarterSkillBytes,
137
+ getStarterSkillsManifest,
138
+ getStarterSkillsDir,
139
+ } from '@klickd/core';
140
+
141
+ listStarterSkills();
142
+ // → ['coding.klickd', 'research.klickd', 'student.klickd', 'user.klickd']
143
+
144
+ const bytes = getStarterSkillBytes('user.klickd');
145
+ const manifest = getStarterSkillsManifest();
146
+ const dir = getStarterSkillsDir(); // absolute path to bundled starter-skills/
147
+ ```
148
+
113
149
  ---
114
150
 
115
151
  ## Cryptographic specification (v3.0)
@@ -144,12 +180,12 @@ See `SPEC.md §33` and `examples/v4-preview/` for preview-track details.
144
180
  - Format page: [klickd.app/klickdskill](https://klickd.app/klickdskill)
145
181
  - Specification: [SPEC.md](https://github.com/Davincc77/klickdskill/blob/main/SPEC.md)
146
182
  - Repository: [github.com/Davincc77/klickdskill](https://github.com/Davincc77/klickdskill)
147
- - DOI: [10.5281/zenodo.20320480](https://doi.org/10.5281/zenodo.20320480) (v3.5) · concept DOI (all versions): [10.5281/zenodo.20262530](https://doi.org/10.5281/zenodo.20262530)
148
- - Homepage: [klickd.app](https://klickd.app)
183
+ - DOI: [10.5281/zenodo.20383133](https://doi.org/10.5281/zenodo.20383133) (v4.0.0) · concept DOI (all versions): [10.5281/zenodo.20262530](https://doi.org/10.5281/zenodo.20262530)
184
+ - Homepage: [klickd.app/klickdskill](https://klickd.app/klickdskill)
149
185
 
150
186
  ---
151
187
 
152
188
  ## License
153
189
 
154
190
  [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/) — Public Domain Dedication.
155
- Author: Vince C. (Luxlearn, Luxembourg)
191
+ Author: Vincenzo Cirilli (.klickd / klickd.app, Luxembourg)
package/dist/index.cjs CHANGED
@@ -32,8 +32,19 @@ var index_exports = {};
32
32
  __export(index_exports, {
33
33
  HTTP_STATUS: () => HTTP_STATUS,
34
34
  KlickdError: () => KlickdError,
35
+ getBundledSchema: () => getBundledSchema,
36
+ getStarterSkillBytes: () => getStarterSkillBytes,
37
+ getStarterSkillsDir: () => getStarterSkillsDir,
38
+ getStarterSkillsManifest: () => getStarterSkillsManifest,
39
+ listBundledSchemas: () => listBundledSchemas,
40
+ listStarterSkills: () => listStarterSkills,
35
41
  loadKlickd: () => loadKlickd,
36
- saveKlickd: () => saveKlickd
42
+ migratePayload: () => migratePayload,
43
+ migratePayloadIterWarnings: () => migratePayloadIterWarnings,
44
+ needsMigration: () => needsMigration,
45
+ saveKlickd: () => saveKlickd,
46
+ validate: () => validate,
47
+ validateIterErrors: () => validateIterErrors
37
48
  });
38
49
  module.exports = __toCommonJS(index_exports);
39
50
 
@@ -321,10 +332,298 @@ async function loadKlickd(input, options = {}) {
321
332
  }
322
333
  return payload;
323
334
  }
335
+
336
+ // src/validate.ts
337
+ var import_klickd_payload_v4_schema = __toESM(require("./klickd-payload-v4.schema-7UPTEJOY.json"), 1);
338
+ var import_klickd_payload_v4_preview_schema = __toESM(require("./klickd-payload-v4-preview.schema-W7RY72VP.json"), 1);
339
+ var import_klickd_v4_schema = __toESM(require("./klickd-v4.schema-ZZGRYTLY.json"), 1);
340
+ var import_klickd_v4_preview_schema = __toESM(require("./klickd-v4-preview.schema-QHITWMK6.json"), 1);
341
+ var SCHEMAS = {
342
+ "payload-strict": import_klickd_payload_v4_schema.default,
343
+ "payload-preview": import_klickd_payload_v4_preview_schema.default,
344
+ "unified-strict": import_klickd_v4_schema.default,
345
+ "unified-preview": import_klickd_v4_preview_schema.default
346
+ };
347
+ function getBundledSchema(key) {
348
+ const s = SCHEMAS[key];
349
+ if (!s) {
350
+ throw new Error(`Unknown schema key: ${String(key)}`);
351
+ }
352
+ return JSON.parse(JSON.stringify(s));
353
+ }
354
+ function listBundledSchemas() {
355
+ return Object.keys(SCHEMAS);
356
+ }
357
+ var ajvBundle = null;
358
+ async function getAjv() {
359
+ if (ajvBundle) return ajvBundle;
360
+ let AjvCtor;
361
+ try {
362
+ const mod = await import("ajv/dist/2020.js");
363
+ AjvCtor = mod.default ?? mod;
364
+ } catch (e) {
365
+ throw new KlickdError(
366
+ "KLICKD_E_SCHEMA",
367
+ "validate() requires the optional 'ajv' dependency (>=8.12, Draft 2020-12). Install it with: npm install ajv",
368
+ HTTP_STATUS["KLICKD_E_SCHEMA"]
369
+ );
370
+ }
371
+ const ajv = new AjvCtor({ allErrors: true, strict: false, validateFormats: false });
372
+ for (const key of listBundledSchemas()) {
373
+ ajv.addSchema(SCHEMAS[key], `klickd:${key}`);
374
+ }
375
+ const validators = /* @__PURE__ */ new Map();
376
+ for (const key of listBundledSchemas()) {
377
+ validators.set(key, ajv.compile(SCHEMAS[key]));
378
+ }
379
+ ajvBundle = { validators };
380
+ return ajvBundle;
381
+ }
382
+ function keyFor(target, strict) {
383
+ return `${target}-${strict ? "strict" : "preview"}`;
384
+ }
385
+ function formatPath(instancePath) {
386
+ if (!instancePath || instancePath === "") return "<root>";
387
+ return instancePath.replace(/^\//, "");
388
+ }
389
+ async function validate(payload, options = {}) {
390
+ const strict = options.strict ?? true;
391
+ const target = options.target ?? "payload";
392
+ if (target !== "payload" && target !== "unified") {
393
+ throw new Error(`target must be 'payload' or 'unified', got ${String(target)}`);
394
+ }
395
+ const { validators } = await getAjv();
396
+ const validator = validators.get(keyFor(target, strict));
397
+ if (!validator) {
398
+ throw new Error(`No bundled validator for ${target}-${strict ? "strict" : "preview"}`);
399
+ }
400
+ if (validator(payload)) return;
401
+ const errors = validator.errors ?? [];
402
+ const summary = errors.slice(0, 8).map((e) => `${formatPath(e.instancePath)}: ${(e.message ?? "").slice(0, 200)}`);
403
+ const extra = errors.length > 8 ? ` (+${errors.length - 8} more)` : "";
404
+ throw new KlickdError(
405
+ "KLICKD_E_SCHEMA",
406
+ `v4 ${strict ? "strict" : "preview"} ${target} validation failed${extra}: ${summary.join(" | ")}`,
407
+ HTTP_STATUS["KLICKD_E_SCHEMA"]
408
+ );
409
+ }
410
+ async function validateIterErrors(payload, options = {}) {
411
+ const strict = options.strict ?? true;
412
+ const target = options.target ?? "payload";
413
+ if (target !== "payload" && target !== "unified") {
414
+ throw new Error(`target must be 'payload' or 'unified', got ${String(target)}`);
415
+ }
416
+ const { validators } = await getAjv();
417
+ const validator = validators.get(keyFor(target, strict));
418
+ if (!validator) {
419
+ throw new Error(`No bundled validator for ${target}-${strict ? "strict" : "preview"}`);
420
+ }
421
+ if (validator(payload)) return [];
422
+ return (validator.errors ?? []).map((e) => ({
423
+ path: formatPath(e.instancePath),
424
+ message: e.message ?? ""
425
+ }));
426
+ }
427
+
428
+ // src/migrate.ts
429
+ var V3_SCHEMA_VERSIONS = /* @__PURE__ */ new Set([
430
+ "3.0",
431
+ "3.1",
432
+ "3.2",
433
+ "3.3",
434
+ "3.4",
435
+ "3.5"
436
+ ]);
437
+ var V4_SCHEMA_VERSIONS = /* @__PURE__ */ new Set(["4.0", "4.0.0-preview.1"]);
438
+ var RESERVED_PROFILE_KINDS = /* @__PURE__ */ new Set([
439
+ "learner",
440
+ "agent",
441
+ "team",
442
+ "robot",
443
+ "creator"
444
+ ]);
445
+ function isPlainObject(value) {
446
+ return typeof value === "object" && value !== null && !Array.isArray(value);
447
+ }
448
+ function utcNowIso() {
449
+ const now = /* @__PURE__ */ new Date();
450
+ const pad = (n) => String(n).padStart(2, "0");
451
+ return `${now.getUTCFullYear()}-${pad(now.getUTCMonth() + 1)}-${pad(now.getUTCDate())}T${pad(now.getUTCHours())}:${pad(now.getUTCMinutes())}:${pad(now.getUTCSeconds())}Z`;
452
+ }
453
+ function deepClone(value) {
454
+ return structuredClone(value);
455
+ }
456
+ function needsMigration(payload) {
457
+ if (!isPlainObject(payload)) return false;
458
+ const ver = payload["payload_schema_version"];
459
+ if (ver === void 0 || ver === null) return true;
460
+ if (typeof ver !== "string") return false;
461
+ if (V4_SCHEMA_VERSIONS.has(ver)) return false;
462
+ if (V3_SCHEMA_VERSIONS.has(ver)) return true;
463
+ return false;
464
+ }
465
+ function migratePayload(payload, options = {}) {
466
+ if (!isPlainObject(payload)) {
467
+ throw new KlickdError(
468
+ "KLICKD_E_SCHEMA",
469
+ `migratePayload requires a plain object payload; got ${typeof payload}`,
470
+ HTTP_STATUS["KLICKD_E_SCHEMA"]
471
+ );
472
+ }
473
+ const incomingVersion = payload["payload_schema_version"];
474
+ if (incomingVersion !== void 0 && typeof incomingVersion === "string" && !V3_SCHEMA_VERSIONS.has(incomingVersion) && !V4_SCHEMA_VERSIONS.has(incomingVersion)) {
475
+ throw new KlickdError(
476
+ "KLICKD_E_SCHEMA",
477
+ `migratePayload does not recognize payload_schema_version=${JSON.stringify(incomingVersion)}; expected v3.x (3.0..3.5) or v4 (4.0 / 4.0.0-preview.1)`,
478
+ HTTP_STATUS["KLICKD_E_SCHEMA"]
479
+ );
480
+ }
481
+ const out = deepClone(payload);
482
+ const {
483
+ sourceVersion,
484
+ migratedAt,
485
+ profileKind = "learner",
486
+ migrationReportRef,
487
+ backupRef
488
+ } = options;
489
+ if (typeof incomingVersion === "string" && V4_SCHEMA_VERSIONS.has(incomingVersion)) {
490
+ if (migrationReportRef === void 0 && backupRef === void 0) {
491
+ return out;
492
+ }
493
+ const existing = isPlainObject(out["migration"]) ? out["migration"] : {};
494
+ if (migrationReportRef !== void 0) {
495
+ existing["migration_report_ref"] = migrationReportRef;
496
+ }
497
+ if (backupRef !== void 0) {
498
+ existing["backup_ref"] = backupRef;
499
+ }
500
+ if (existing["source_version"] === void 0) {
501
+ existing["source_version"] = incomingVersion;
502
+ }
503
+ existing["migrated_at"] = migratedAt ?? utcNowIso();
504
+ out["migration"] = existing;
505
+ return out;
506
+ }
507
+ out["payload_schema_version"] = "4.0";
508
+ if (out["profile_kind"] === void 0) {
509
+ out["profile_kind"] = profileKind;
510
+ }
511
+ const migrationBlock = {
512
+ source_version: sourceVersion ?? (typeof incomingVersion === "string" ? incomingVersion : "3.x"),
513
+ migrated_at: migratedAt ?? utcNowIso()
514
+ };
515
+ if (migrationReportRef !== void 0) {
516
+ migrationBlock["migration_report_ref"] = migrationReportRef;
517
+ }
518
+ if (backupRef !== void 0) {
519
+ migrationBlock["backup_ref"] = backupRef;
520
+ }
521
+ out["migration"] = migrationBlock;
522
+ return out;
523
+ }
524
+ function migratePayloadIterWarnings(payload) {
525
+ const warnings = [];
526
+ if (!isPlainObject(payload)) {
527
+ warnings.push({ path: "<root>", message: "payload is not a JSON object" });
528
+ return warnings;
529
+ }
530
+ const ver = payload["payload_schema_version"];
531
+ if (ver === void 0) {
532
+ if (payload["domain_schema_version"] === void 0) {
533
+ warnings.push({
534
+ path: "<root>",
535
+ message: "no payload_schema_version and no domain_schema_version; pin sourceVersion explicitly when migrating"
536
+ });
537
+ }
538
+ } else if (typeof ver === "string" && !V3_SCHEMA_VERSIONS.has(ver) && !V4_SCHEMA_VERSIONS.has(ver)) {
539
+ warnings.push({
540
+ path: "/payload_schema_version",
541
+ message: `unknown payload_schema_version ${JSON.stringify(ver)}; migrator will refuse`
542
+ });
543
+ }
544
+ const ctx = payload["context"];
545
+ if (isPlainObject(ctx)) {
546
+ const decisions = ctx["decisions_locked"];
547
+ if (Array.isArray(decisions)) {
548
+ decisions.forEach((d, i) => {
549
+ if (typeof d === "string" && d.length > 1024) {
550
+ warnings.push({
551
+ path: `/context/decisions_locked/${i}`,
552
+ message: `entry exceeds 1024 chars (${d.length}); some readers will truncate`
553
+ });
554
+ }
555
+ });
556
+ }
557
+ }
558
+ const ethics = payload["ethics"];
559
+ const veto = payload["human_veto_policy"];
560
+ if (isPlainObject(ethics) && isPlainObject(veto)) {
561
+ const locked = ethics["locked_actions"];
562
+ const appliesTo = veto["applies_to"];
563
+ if (Array.isArray(locked) && Array.isArray(appliesTo)) {
564
+ const lockedSet = new Set(locked.filter((x) => typeof x === "string"));
565
+ const overlap = appliesTo.filter((x) => typeof x === "string" && lockedSet.has(x)).sort();
566
+ if (overlap.length > 0) {
567
+ warnings.push({
568
+ path: "/human_veto_policy/applies_to",
569
+ message: "overlaps with /ethics/locked_actions: " + overlap.map((x) => JSON.stringify(x)).join(", ")
570
+ });
571
+ }
572
+ }
573
+ }
574
+ const pk = payload["profile_kind"];
575
+ if (typeof pk === "string" && !RESERVED_PROFILE_KINDS.has(pk)) {
576
+ warnings.push({
577
+ path: "/profile_kind",
578
+ message: `non-reserved profile_kind ${JSON.stringify(pk)}; readers MAY treat as extension`
579
+ });
580
+ }
581
+ return warnings;
582
+ }
583
+
584
+ // src/starter-skills.ts
585
+ var import_node_url = require("url");
586
+ var import_node_path = require("path");
587
+ var import_node_fs = require("fs");
588
+ var import_meta = {};
589
+ function starterSkillsDir() {
590
+ const here = (0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
591
+ return (0, import_node_path.join)(here, "..", "starter-skills");
592
+ }
593
+ function getStarterSkillsDir() {
594
+ return starterSkillsDir();
595
+ }
596
+ function listStarterSkills() {
597
+ return (0, import_node_fs.readdirSync)(starterSkillsDir()).filter((name) => name.endsWith(".klickd")).sort();
598
+ }
599
+ function getStarterSkillBytes(name) {
600
+ if (!name.endsWith(".klickd")) {
601
+ throw new Error(`starter skill name must end with .klickd: ${name}`);
602
+ }
603
+ if (name.includes("/") || name.includes("\\") || name.includes("..")) {
604
+ throw new Error(`invalid starter skill name: ${name}`);
605
+ }
606
+ return new Uint8Array((0, import_node_fs.readFileSync)((0, import_node_path.join)(starterSkillsDir(), name)));
607
+ }
608
+ function getStarterSkillsManifest() {
609
+ const raw = (0, import_node_fs.readFileSync)((0, import_node_path.join)(starterSkillsDir(), "manifest.json"), "utf8");
610
+ return JSON.parse(raw);
611
+ }
324
612
  // Annotate the CommonJS export names for ESM import in node:
325
613
  0 && (module.exports = {
326
614
  HTTP_STATUS,
327
615
  KlickdError,
616
+ getBundledSchema,
617
+ getStarterSkillBytes,
618
+ getStarterSkillsDir,
619
+ getStarterSkillsManifest,
620
+ listBundledSchemas,
621
+ listStarterSkills,
328
622
  loadKlickd,
329
- saveKlickd
623
+ migratePayload,
624
+ migratePayloadIterWarnings,
625
+ needsMigration,
626
+ saveKlickd,
627
+ validate,
628
+ validateIterErrors
330
629
  });
package/dist/index.d.cts CHANGED
@@ -84,9 +84,80 @@ interface KlickdPayload {
84
84
  context?: KlickdContext;
85
85
  knowledge?: KlickdKnowledge;
86
86
  memory?: KlickdMemoryEntry[];
87
+ profile_kind?: string;
88
+ preview?: string;
89
+ onboarding_trigger?: string;
90
+ media_profile?: KlickdMediaProfileV1 | Record<string, unknown> | null;
91
+ verification_gates?: KlickdVerificationGatesV1 | Record<string, KlickdGateLevel> | null;
92
+ human_veto_policy?: KlickdHumanVetoPolicy | null;
93
+ claim_sources?: KlickdClaimSources | null;
94
+ migration?: KlickdMigrationV1 | null;
95
+ risk_thresholds?: Record<string, unknown> | null;
96
+ preflight_checks?: unknown[] | null;
97
+ error_journal?: unknown[] | null;
98
+ verification_artifacts?: unknown[] | null;
99
+ contract_tests?: unknown[] | null;
100
+ success_criteria?: unknown;
101
+ reversibility?: Record<string, unknown> | null;
102
+ blast_radius?: Record<string, unknown> | null;
103
+ context_cost?: Record<string, unknown> | null;
104
+ gaming_profile?: Record<string, unknown> | null;
105
+ deprecated_fields?: Array<Record<string, unknown>> | null;
87
106
  /** Domain extension fields */
88
107
  [key: string]: unknown;
89
108
  }
109
+ type KlickdMediaModality = 'voice' | 'image' | 'document' | 'embedding';
110
+ interface KlickdMediaProfileEntryHash {
111
+ algo: 'blake3';
112
+ value: string;
113
+ }
114
+ interface KlickdMediaProfileEntry {
115
+ id: string;
116
+ modality: KlickdMediaModality;
117
+ hash: KlickdMediaProfileEntryHash;
118
+ label?: string;
119
+ language?: string;
120
+ uri?: string;
121
+ media_type?: string;
122
+ byte_size?: number;
123
+ duration_ms?: number;
124
+ bytes_b64?: string;
125
+ producer?: Record<string, unknown>;
126
+ consent?: Record<string, unknown>;
127
+ }
128
+ interface KlickdMediaProfileV1 {
129
+ version: 1;
130
+ entries: KlickdMediaProfileEntry[];
131
+ }
132
+ type KlickdGateLevel = 'silent' | 'warn' | 'confirm' | 'block' | 'require-owner';
133
+ interface KlickdGateEntry {
134
+ action_class: string;
135
+ level: KlickdGateLevel;
136
+ id?: string;
137
+ reason?: string;
138
+ }
139
+ interface KlickdVerificationGatesV1 {
140
+ version: 1;
141
+ gates: KlickdGateEntry[];
142
+ user_default?: KlickdGateLevel;
143
+ }
144
+ interface KlickdHumanVetoPolicy {
145
+ applies_to?: string[];
146
+ second_party?: string | null;
147
+ min_level?: KlickdGateLevel;
148
+ rationale?: string;
149
+ }
150
+ interface KlickdClaimSources {
151
+ prefer?: string[];
152
+ require_citation_for?: string[];
153
+ records?: Array<Record<string, unknown>>;
154
+ }
155
+ interface KlickdMigrationV1 {
156
+ source_version?: string;
157
+ migrated_at?: string;
158
+ migration_report_ref?: string;
159
+ backup_ref?: string;
160
+ }
90
161
  interface LoadKlickdOptions {
91
162
  passphrase?: string;
92
163
  /** Enable legacy v2.x PBKDF2-SHA256/600k reading. Default: false */
@@ -129,4 +200,115 @@ declare function saveKlickd(payload: KlickdPayload, options: SaveKlickdOptions):
129
200
  */
130
201
  declare function loadKlickd(input: string | Uint8Array, options?: LoadKlickdOptions): Promise<KlickdPayload>;
131
202
 
132
- export { type CipherName, HTTP_STATUS, type KdfName, type KlickdCipher, type KlickdContext, type KlickdDomain, type KlickdEnvelope, KlickdError, type KlickdErrorCode, type KlickdIdentity, type KlickdKdf, type KlickdKdfArgon2id, type KlickdKdfPbkdf2, type KlickdKnowledge, type KlickdMemoryEntry, type KlickdPayload, type LoadKlickdOptions, type MemoryModality, type MemoryRole, type SaveKlickdOptions, loadKlickd, saveKlickd };
203
+ type ValidationTarget = 'payload' | 'unified';
204
+ interface ValidateOptions {
205
+ /** True (default) = v4 GA strict schema; false = permissive preview. */
206
+ strict?: boolean;
207
+ /**
208
+ * "payload" (default) validates the inner payload schema.
209
+ * "unified" validates against the unified envelope+payload schema.
210
+ */
211
+ target?: ValidationTarget;
212
+ }
213
+ interface ValidationIssue {
214
+ /** JSON-pointer-like path ("" / "<root>" when at root). */
215
+ path: string;
216
+ /** Validator-produced human-readable message. */
217
+ message: string;
218
+ }
219
+ declare const SCHEMAS: {
220
+ readonly 'payload-strict': Record<string, unknown>;
221
+ readonly 'payload-preview': Record<string, unknown>;
222
+ readonly 'unified-strict': Record<string, unknown>;
223
+ readonly 'unified-preview': Record<string, unknown>;
224
+ };
225
+ type SchemaKey = keyof typeof SCHEMAS;
226
+ /**
227
+ * Return a parsed copy of one of the four bundled v4 schemas. Provides the
228
+ * same affordance as Python `klickd.validate._load_schema` — useful for
229
+ * tooling that wants to introspect the bundled JSON without reaching back
230
+ * into the repo.
231
+ */
232
+ declare function getBundledSchema(key: SchemaKey): Record<string, unknown>;
233
+ /** List of bundled schema keys (parity with Python `_SCHEMA_FILES`). */
234
+ declare function listBundledSchemas(): SchemaKey[];
235
+ /**
236
+ * Validate a .klickd payload (or unified envelope+payload) against the v4
237
+ * JSON schema bundled with this package. Throws KlickdError(KLICKD_E_SCHEMA)
238
+ * on validation failure or when the optional `ajv` peer is missing.
239
+ *
240
+ * Mirrors Python `klickd.validate`. See packages/pypi/klickd/src/klickd/validate.py.
241
+ */
242
+ declare function validate(payload: unknown, options?: ValidateOptions): Promise<void>;
243
+ /**
244
+ * Non-throwing variant. Returns an array of {path, message} issues — empty
245
+ * when the payload is valid. Mirrors Python `validate_iter_errors`.
246
+ */
247
+ declare function validateIterErrors(payload: unknown, options?: ValidateOptions): Promise<ValidationIssue[]>;
248
+
249
+ interface MigrateOptions {
250
+ /** Override the recorded source_version. Defaults to the input's
251
+ * payload_schema_version, or "3.x" when absent. */
252
+ sourceVersion?: string;
253
+ /** RFC 3339 UTC timestamp (must end with `Z`). Defaults to now().
254
+ * Tests SHOULD pin this for reproducibility. */
255
+ migratedAt?: string;
256
+ /** Default "learner" (v3.x is implicitly "learner"). */
257
+ profileKind?: string;
258
+ /** Optional pointer (URI / path) to a human-authored migration report. */
259
+ migrationReportRef?: string;
260
+ /** Optional pointer to a backup of the pre-migration file. */
261
+ backupRef?: string;
262
+ }
263
+ interface MigrationWarning {
264
+ /** JSON-pointer-ish path; `<root>` for the top-level object. */
265
+ path: string;
266
+ /** Human-readable warning message. */
267
+ message: string;
268
+ }
269
+ type JsonObject = Record<string, unknown>;
270
+ /**
271
+ * Return true iff `payload` is a v3.x payload that should be lifted to v4 GA.
272
+ *
273
+ * Mirrors Python `needs_migration`.
274
+ */
275
+ declare function needsMigration(payload: unknown): boolean;
276
+ /**
277
+ * Lift a v3.x .klickd payload to the v4 GA payload shape.
278
+ *
279
+ * Pure: the input is never mutated; a structurally cloned result is
280
+ * returned. Idempotent on already-v4 inputs (unchanged unless the caller
281
+ * passes pointer refs).
282
+ *
283
+ * Throws `KlickdError(KLICKD_E_SCHEMA)` when the input is not a plain
284
+ * object or carries an unrecognized `payload_schema_version`.
285
+ */
286
+ declare function migratePayload(payload: unknown, options?: MigrateOptions): JsonObject;
287
+ /**
288
+ * Return manual-review warnings without mutating `payload`. Mirrors
289
+ * Python `migrate_payload_iter_warnings`.
290
+ */
291
+ declare function migratePayloadIterWarnings(payload: unknown): MigrationWarning[];
292
+
293
+ interface StarterSkillEntry {
294
+ id: string;
295
+ file: string;
296
+ pack_version: string;
297
+ bytes: number;
298
+ sha256_file: string;
299
+ sha256_canonical_json: string;
300
+ }
301
+ interface StarterSkillManifest {
302
+ manifest_version: string;
303
+ kind: string;
304
+ non_normative: boolean;
305
+ claims_v41_ga: boolean;
306
+ packs: StarterSkillEntry[];
307
+ [key: string]: unknown;
308
+ }
309
+ declare function getStarterSkillsDir(): string;
310
+ declare function listStarterSkills(): string[];
311
+ declare function getStarterSkillBytes(name: string): Uint8Array;
312
+ declare function getStarterSkillsManifest(): StarterSkillManifest;
313
+
314
+ export { type CipherName, HTTP_STATUS, type KdfName, type KlickdCipher, type KlickdClaimSources, type KlickdContext, type KlickdDomain, type KlickdEnvelope, KlickdError, type KlickdErrorCode, type KlickdGateEntry, type KlickdGateLevel, type KlickdHumanVetoPolicy, type KlickdIdentity, type KlickdKdf, type KlickdKdfArgon2id, type KlickdKdfPbkdf2, type KlickdKnowledge, type KlickdMediaModality, type KlickdMediaProfileEntry, type KlickdMediaProfileEntryHash, type KlickdMediaProfileV1, type KlickdMemoryEntry, type KlickdMigrationV1, type KlickdPayload, type KlickdVerificationGatesV1, type LoadKlickdOptions, type MemoryModality, type MemoryRole, type MigrateOptions, type MigrationWarning, type SaveKlickdOptions, type StarterSkillEntry, type StarterSkillManifest, type ValidateOptions, type ValidationIssue, type ValidationTarget, getBundledSchema, getStarterSkillBytes, getStarterSkillsDir, getStarterSkillsManifest, listBundledSchemas, listStarterSkills, loadKlickd, migratePayload, migratePayloadIterWarnings, needsMigration, saveKlickd, validate, validateIterErrors };