@wildo-ai/wildo-module-client 1.1.10 → 1.1.11

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,cAAc,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"_http-client.d.ts","sourceRoot":"","sources":["../../../src/services/_http-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAMH;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,QAAS,CAAC;AAExD,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,oBAAyB,GAC9B,OAAO,CAAC,QAAQ,CAAC,CA0BnB;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAQ7H;AAED,MAAM,WAAW,YAAa,SAAQ,oBAAoB;IACxD,wFAAwF;IACxF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IA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AAU,CAAC,CAAA;CAAE,CAAC,CAqD7I;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,oBAAyB,GAC9B,OAAO,CAAC,QAAQ,CAAC,CAQnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"_zod-issue-formatting.d.ts","sourceRoot":"","sources":["../../../src/services/_zod-issue-formatting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAiCpC;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAOnE"}
1
+ {"version":3,"file":"_zod-issue-formatting.d.ts","sourceRoot":"","sources":["../../../../src/services/_zod-issue-formatting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAiCpC;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAOnE"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC"}
@@ -15,6 +15,39 @@
15
15
  * read path; this service only owns module diagnostics.
16
16
  */
17
17
  import { type RegistryModulesLockEntry } from '@wildo-ai/platform-config-lib';
18
+ /**
19
+ * Why a provider module's install-script name cannot simply be written back into the application's root
20
+ * `package.json` → `pnpm.onlyBuiltDependencies` (#2809). Each is the application's own policy, which the install
21
+ * (#2801) also refuses to override, and pnpm 10.6.4 reads it as follows (measured in #2801):
22
+ */
23
+ export declare enum ApplicationInstallScriptPolicy {
24
+ /** The allow-list lives in `pnpm-workspace.yaml`, and a list in `package.json` would REPLACE it. */
25
+ WORKSPACE_ALLOW_LIST = "workspace-allow-list",
26
+ /** A `neverBuiltDependencies` list names the package, and pnpm refuses to install with both lists. */
27
+ NEVER_BUILT_LIST = "never-built-list",
28
+ /**
29
+ * The application declares an allow-list AND a `neverBuiltDependencies` list (in either file): pnpm 10.6.4 refuses to
30
+ * install at all (`ERR_PNPM_CONFIG_CONFLICT_BUILT_DEPENDENCIES`, measured in #2809's review), so writing a name changes
31
+ * nothing until the application keeps one of them.
32
+ */
33
+ CONFLICTING_LISTS = "conflicting-lists"
34
+ }
35
+ /**
36
+ * The install-script policy `pnpm-workspace.yaml` declares, each list `undefined` when the file does not declare it.
37
+ * Supplied by the caller, which owns the YAML reading (`wildo-cli`'s `readWorkspaceBuildPolicy`, the reader the install
38
+ * uses), so the inspector and the install judge one policy the same way.
39
+ */
40
+ export interface WorkspaceBuildPolicy {
41
+ onlyBuiltDependencies?: readonly string[];
42
+ neverBuiltDependencies?: readonly string[];
43
+ }
44
+ export interface LockfileRepairInspectOptions {
45
+ /**
46
+ * Required rather than defaulted: without it, a name missing from `package.json` could look restorable when the
47
+ * application keeps its list in `pnpm-workspace.yaml`, and `--fix` would then replace that list.
48
+ */
49
+ workspaceBuildPolicy: WorkspaceBuildPolicy;
50
+ }
18
51
  export type LockfileRepairFinding = {
19
52
  severity: 'error';
20
53
  kind: 'envelope-malformed';
@@ -30,6 +63,37 @@ export type LockfileRepairFinding = {
30
63
  kind: 'module-file-missing';
31
64
  moduleId: string;
32
65
  filePath: string;
66
+ } | {
67
+ /** A vendor pin the module's recorded wiring wrote (#2789) is gone from the root `pnpm.overrides`: restorable. */
68
+ severity: 'warn';
69
+ kind: 'vendor-pin-missing';
70
+ moduleId: string;
71
+ name: string;
72
+ version: string;
73
+ } | {
74
+ /** A recorded vendor pin the application moved since install: its decision, reported and never overwritten. */
75
+ severity: 'warn';
76
+ kind: 'vendor-pin-moved';
77
+ moduleId: string;
78
+ name: string;
79
+ version: string;
80
+ found: string;
81
+ } | {
82
+ /**
83
+ * An install-script name the module's recorded wiring wrote (#2801), not held by the application, that the
84
+ * application's allow-list no longer carries: restorable into `package.json` → `pnpm.onlyBuiltDependencies`.
85
+ */
86
+ severity: 'warn';
87
+ kind: 'only-built-missing';
88
+ moduleId: string;
89
+ name: string;
90
+ } | {
91
+ /** A recorded install-script name the application's own policy does not allow, and `--fix` must not write: reported only. */
92
+ severity: 'warn';
93
+ kind: 'only-built-blocked';
94
+ moduleId: string;
95
+ name: string;
96
+ policy: ApplicationInstallScriptPolicy;
33
97
  };
34
98
  export interface LockfileRepairReport {
35
99
  /** Absolute path the report covers. */
@@ -44,7 +108,7 @@ export declare const LockfileRepairService: {
44
108
  /**
45
109
  * Read the envelope + run every diagnostic. Read-only.
46
110
  */
47
- readonly inspect: (saasRoot: string) => Promise<LockfileRepairReport>;
111
+ readonly inspect: (saasRoot: string, options: LockfileRepairInspectOptions) => Promise<LockfileRepairReport>;
48
112
  /**
49
113
  * Missing-file diagnostics for an entry already validated by the strict section schema.
50
114
  */
@@ -1 +1 @@
1
- {"version":3,"file":"lockfile-repair.service.d.ts","sourceRoot":"","sources":["../../../src/services/lockfile-repair.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,EAGL,KAAK,wBAAwB,EAE9B,MAAM,+BAA+B,CAAC;AAcvC,MAAM,MAAM,qBAAqB,GAC7B;IACE,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,oBAAoB,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACD;IACE,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACD;IACE,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,qBAAqB,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEN,MAAM,WAAW,oBAAoB;IACnC,uCAAuC;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,SAAS,qBAAqB,EAAE,CAAC;CAC5C;AAWD,eAAO,MAAM,qBAAqB;IAChC,iDAAiD;iCAC/B,MAAM,KAAG,MAAM;IAIjC;;OAEG;iCACqB,MAAM,KAAG,OAAO,CAAC,oBAAoB,CAAC;IA8E9D;;OAEG;8CAES,MAAM,YACN,MAAM,SACT,wBAAwB,YACrB,qBAAqB,EAAE,KAChC,OAAO,CAAC,IAAI,CAAC;CAaR,CAAC"}
1
+ {"version":3,"file":"lockfile-repair.service.d.ts","sourceRoot":"","sources":["../../../../src/services/lockfile-repair.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,EAKL,KAAK,wBAAwB,EAE9B,MAAM,+BAA+B,CAAC;AAEvC;;;;GAIG;AACH,oBAAY,8BAA8B;IACxC,oGAAoG;IACpG,oBAAoB,yBAAyB;IAC7C,sGAAsG;IACtG,gBAAgB,qBAAqB;IACrC;;;;OAIG;IACH,iBAAiB,sBAAsB;CACxC;AAED;;;;GAI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,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,oBAAoB,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,8BAA8B,CAAC;CACxC,CAAC;AAEN,MAAM,WAAW,oBAAoB;IACnC,uCAAuC;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,SAAS,qBAAqB,EAAE,CAAC;CAC5C;AAoFD,eAAO,MAAM,qBAAqB;IAChC,iDAAiD;iCAC/B,MAAM,KAAG,MAAM;IAIjC;;OAEG;iCACqB,MAAM,WAAW,4BAA4B,KAAG,OAAO,CAAC,oBAAoB,CAAC;IAkFrG;;OAEG;8CAES,MAAM,YACN,MAAM,SACT,wBAAwB,YACrB,qBAAqB,EAAE,KAChC,OAAO,CAAC,IAAI,CAAC;CAaR,CAAC"}
@@ -18,16 +18,35 @@ import { promises as fs } from 'node:fs';
18
18
  import * as path from 'node:path';
19
19
  import { z } from 'zod';
20
20
  import { formatZodIssuesAsSingleLine } from './_zod-issue-formatting.js';
21
- import { RegistryModulesLockSectionSchema, getWildoSaasLockPath, } from '@wildo-ai/platform-config-lib';
21
+ import { PROVIDER_VENDOR_PINS_MANIFEST, RegistryModulesLockSectionSchema, getWildoSaasLockPath, withoutRetiredLockfileEnvelopeKeys, } from '@wildo-ai/platform-config-lib';
22
+ /**
23
+ * Why a provider module's install-script name cannot simply be written back into the application's root
24
+ * `package.json` → `pnpm.onlyBuiltDependencies` (#2809). Each is the application's own policy, which the install
25
+ * (#2801) also refuses to override, and pnpm 10.6.4 reads it as follows (measured in #2801):
26
+ */
27
+ export var ApplicationInstallScriptPolicy;
28
+ (function (ApplicationInstallScriptPolicy) {
29
+ /** The allow-list lives in `pnpm-workspace.yaml`, and a list in `package.json` would REPLACE it. */
30
+ ApplicationInstallScriptPolicy["WORKSPACE_ALLOW_LIST"] = "workspace-allow-list";
31
+ /** A `neverBuiltDependencies` list names the package, and pnpm refuses to install with both lists. */
32
+ ApplicationInstallScriptPolicy["NEVER_BUILT_LIST"] = "never-built-list";
33
+ /**
34
+ * The application declares an allow-list AND a `neverBuiltDependencies` list (in either file): pnpm 10.6.4 refuses to
35
+ * install at all (`ERR_PNPM_CONFIG_CONFLICT_BUILT_DEPENDENCIES`, measured in #2809's review), so writing a name changes
36
+ * nothing until the application keeps one of them.
37
+ */
38
+ ApplicationInstallScriptPolicy["CONFLICTING_LISTS"] = "conflicting-lists";
39
+ })(ApplicationInstallScriptPolicy || (ApplicationInstallScriptPolicy = {}));
22
40
  /**
23
41
  * Permissive envelope schema used by repair only — it accepts any
24
42
  * `sections.*` payload without delegating to per-section schemas
25
43
  * so the repair flow can isolate "envelope is malformed" from
26
- * "envelope is fine but modules section is malformed".
44
+ * "envelope is fine but modules section is malformed". Applied after
45
+ * `withoutRetiredLockfileEnvelopeKeys`, like every lockfile reader, so a
46
+ * file written before the envelope lost its `generatedAt` still parses.
27
47
  */
28
48
  const RelaxedEnvelopeSchema = z.strictObject({
29
49
  schemaVersion: z.literal(2),
30
- generatedAt: z.iso.datetime({ offset: true }),
31
50
  sections: z.record(z.string(), z.unknown()),
32
51
  });
33
52
  async function fileExists(absPath) {
@@ -39,6 +58,79 @@ async function fileExists(absPath) {
39
58
  return false;
40
59
  }
41
60
  }
61
+ /** The `pnpm` section of the application's root manifest, `{}` when the manifest is absent or not JSON (nothing to compare). */
62
+ async function readRootPnpmSection(saasRoot) {
63
+ try {
64
+ const section = JSON.parse(await fs.readFile(path.join(saasRoot, PROVIDER_VENDOR_PINS_MANIFEST), 'utf8')).pnpm;
65
+ return section !== null && typeof section === 'object' && !Array.isArray(section) ? section : {};
66
+ }
67
+ catch {
68
+ return {};
69
+ }
70
+ }
71
+ function asRecord(value) {
72
+ return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : {};
73
+ }
74
+ function asNames(value) {
75
+ return Array.isArray(value) ? value.filter((name) => typeof name === 'string') : undefined;
76
+ }
77
+ /**
78
+ * Each install-script name a provider module's recorded wiring WROTE (#2801; a held name is the application's own), judged
79
+ * as pnpm 10.6.4 will judge it, with the same precedence the install uses (`onlyBuiltStates` in `wildo-cli`):
80
+ * - an allow-list AND a `neverBuiltDependencies` list, in either file → pnpm installs nothing, so a name the allow-list
81
+ * lacks is blocked by `CONFLICTING_LISTS` and never written;
82
+ * - `package.json` carries an allow-list → it is the one pnpm reads (it replaces a workspace list), so a name it lacks is
83
+ * `only-built-missing`, restorable there;
84
+ * - otherwise a `pnpm-workspace.yaml` allow-list → a name it lacks is blocked by `WORKSPACE_ALLOW_LIST`;
85
+ * - otherwise a `neverBuiltDependencies` list (`package.json` first, as the install reads it) → a name it lists is blocked
86
+ * by `NEVER_BUILT_LIST`; any other name's script runs, so nothing is reported;
87
+ * - otherwise no policy at all → pnpm runs no script, and the name is `only-built-missing`: restoring it writes the list
88
+ * the install wrote.
89
+ */
90
+ function collectOnlyBuiltFindings(moduleId, entry, pnpmSection, workspace, findings) {
91
+ const wiring = entry.registration?.providerWiring;
92
+ const held = new Set(wiring?.heldOnlyBuiltDependencies ?? []);
93
+ const wrote = (wiring?.onlyBuiltDependencies ?? []).filter((name) => !held.has(name));
94
+ if (wrote.length === 0)
95
+ return;
96
+ const manifestList = asNames(pnpmSection.onlyBuiltDependencies);
97
+ const never = asNames(pnpmSection.neverBuiltDependencies) ?? workspace.neverBuiltDependencies;
98
+ const allowList = manifestList ?? workspace.onlyBuiltDependencies;
99
+ for (const name of wrote) {
100
+ if (allowList !== undefined && never !== undefined) {
101
+ if (!allowList.includes(name))
102
+ findings.push({ severity: 'warn', kind: 'only-built-blocked', moduleId, name, policy: ApplicationInstallScriptPolicy.CONFLICTING_LISTS });
103
+ }
104
+ else if (manifestList !== undefined) {
105
+ if (!manifestList.includes(name))
106
+ findings.push({ severity: 'warn', kind: 'only-built-missing', moduleId, name });
107
+ }
108
+ else if (workspace.onlyBuiltDependencies !== undefined) {
109
+ if (!workspace.onlyBuiltDependencies.includes(name)) {
110
+ findings.push({ severity: 'warn', kind: 'only-built-blocked', moduleId, name, policy: ApplicationInstallScriptPolicy.WORKSPACE_ALLOW_LIST });
111
+ }
112
+ }
113
+ else if (never !== undefined) {
114
+ if (never.includes(name))
115
+ findings.push({ severity: 'warn', kind: 'only-built-blocked', moduleId, name, policy: ApplicationInstallScriptPolicy.NEVER_BUILT_LIST });
116
+ }
117
+ else {
118
+ findings.push({ severity: 'warn', kind: 'only-built-missing', moduleId, name });
119
+ }
120
+ }
121
+ }
122
+ /**
123
+ * Each vendor pin a provider module's recorded wiring wrote (#2789), against the root overrides: missing (restorable by
124
+ * `--fix`), or moved by the application (reported only: a pin the application set is its own).
125
+ */
126
+ function collectVendorPinFindings(moduleId, entry, overrides, findings) {
127
+ for (const [name, version] of Object.entries(entry.registration?.providerWiring?.vendorPins ?? {})) {
128
+ if (!Object.hasOwn(overrides, name))
129
+ findings.push({ severity: 'warn', kind: 'vendor-pin-missing', moduleId, name, version });
130
+ else if (overrides[name] !== version)
131
+ findings.push({ severity: 'warn', kind: 'vendor-pin-moved', moduleId, name, version, found: String(overrides[name]) });
132
+ }
133
+ }
42
134
  export const LockfileRepairService = {
43
135
  /** Compute the lockfile path for a saas root. */
44
136
  pathFor(saasRoot) {
@@ -47,7 +139,7 @@ export const LockfileRepairService = {
47
139
  /**
48
140
  * Read the envelope + run every diagnostic. Read-only.
49
141
  */
50
- async inspect(saasRoot) {
142
+ async inspect(saasRoot, options) {
51
143
  const lockfilePath = getWildoSaasLockPath(saasRoot);
52
144
  const findings = [];
53
145
  // Read raw bytes ourselves so we can produce per-section
@@ -86,7 +178,7 @@ export const LockfileRepairService = {
86
178
  });
87
179
  return { lockfilePath, ok: false, findings };
88
180
  }
89
- const envelopeParsed = RelaxedEnvelopeSchema.safeParse(parsedJson);
181
+ const envelopeParsed = RelaxedEnvelopeSchema.safeParse(withoutRetiredLockfileEnvelopeKeys(parsedJson));
90
182
  if (!envelopeParsed.success) {
91
183
  findings.push({
92
184
  severity: 'error',
@@ -113,8 +205,12 @@ export const LockfileRepairService = {
113
205
  return { lockfilePath, ok: false, findings };
114
206
  }
115
207
  const modules = parsed.data;
208
+ const pnpmSection = await readRootPnpmSection(saasRoot);
209
+ const rootOverrides = asRecord(pnpmSection.overrides);
116
210
  for (const [moduleId, entry] of Object.entries(modules.installed)) {
117
211
  await this.collectEntryFindings(saasRoot, moduleId, entry, findings);
212
+ collectVendorPinFindings(moduleId, entry, rootOverrides, findings);
213
+ collectOnlyBuiltFindings(moduleId, entry, pnpmSection, options.workspaceBuildPolicy, findings);
118
214
  }
119
215
  const ok = findings.every((f) => f.severity !== 'error');
120
216
  return { lockfilePath, ok, findings };
@@ -1 +1 @@
1
- {"version":3,"file":"lockfile-repair.service.js","sourceRoot":"","sources":["../../../../src/services/lockfile-repair.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EACL,gCAAgC,EAChC,oBAAoB,GAGrB,MAAM,+BAA+B,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,qBAAqB,GAAG,CAAC,CAAC,YAAY,CAAC;IAC3C,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3B,WAAW,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC7C,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;CAC5C,CAAC,CAAC;AA8BH,KAAK,UAAU,UAAU,CAAC,OAAe;I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AEX,qEAAqE;AACrE,kEAAkE;AAClE,mEAAmE","sourcesContent":["/**\n * `LockfileRepairService` — read-only lockfile diagnostics.\n *\n * Backs `wildo registry repair-lockfile`. Strict envelope and module-section\n * validation runs before file inspection. Malformed records, including invalid\n * artifact digests, require restoration from a trusted record; they are never\n * admitted into the automatic repair path. Valid records can report missing\n * source files, which the CLI can re-fetch at their recorded exact version.\n * This inspector does not mutate files.\n *\n * `i18n` validation is intentionally NOT performed here (KD-15 +\n * Review-pass-2 / MEDIUM-5): repair is the wrong place to\n * second-guess companion-owned section semantics. The shared\n * lockfile library STILL validates i18n on the companion-owned\n * read path; this service only owns module diagnostics.\n */\n\nimport { promises as fs } from 'node:fs';\nimport * as path from 'node:path';\nimport { z } from 'zod';\nimport { formatZodIssuesAsSingleLine } from './_zod-issue-formatting';\nimport {\n RegistryModulesLockSectionSchema,\n getWildoSaasLockPath,\n type RegistryModulesLockEntry,\n type RegistryModulesLockSection,\n} from '@wildo-ai/platform-config-lib';\n\n/**\n * Permissive envelope schema used by repair only — it accepts any\n * `sections.*` payload without delegating to per-section schemas\n * so the repair flow can isolate \"envelope is malformed\" from\n * \"envelope is fine but modules section is malformed\".\n */\nconst RelaxedEnvelopeSchema = z.strictObject({\n schemaVersion: z.literal(2),\n generatedAt: z.iso.datetime({ offset: true }),\n sections: z.record(z.string(), z.unknown()),\n});\n\nexport type LockfileRepairFinding =\n | {\n severity: 'error';\n kind: 'envelope-malformed';\n message: string;\n detail?: string;\n }\n | {\n severity: 'error';\n kind: 'modules-section-malformed';\n message: string;\n detail?: string;\n }\n | {\n severity: 'warn';\n kind: 'module-file-missing';\n moduleId: string;\n filePath: string;\n };\n\nexport interface LockfileRepairReport {\n /** Absolute path the report covers. */\n lockfilePath: string;\n /** True when no errors were produced (warnings allowed). */\n ok: boolean;\n findings: readonly LockfileRepairFinding[];\n}\n\nasync function fileExists(absPath: string): Promise<boolean> {\n try {\n await fs.access(absPath);\n return true;\n } catch {\n return false;\n }\n}\n\nexport const LockfileRepairService = {\n /** Compute the lockfile path for a saas root. */\n pathFor(saasRoot: string): string {\n return getWildoSaasLockPath(saasRoot);\n },\n\n /**\n * Read the envelope + run every diagnostic. Read-only.\n */\n async inspect(saasRoot: string): Promise<LockfileRepairReport> {\n const lockfilePath = getWildoSaasLockPath(saasRoot);\n const findings: LockfileRepairFinding[] = [];\n\n // Read raw bytes ourselves so we can produce per-section\n // diagnostics: a malformed `modules` section under an\n // otherwise-valid envelope should report `modules-section-malformed`,\n // NOT `envelope-malformed` (the latter would tell the operator\n // to re-author the whole file when only one section is bad).\n let raw: string;\n try {\n raw = await fs.readFile(lockfilePath, 'utf8');\n } catch (err: unknown) {\n const errno = (err as NodeJS.ErrnoException)?.code;\n if (errno === 'ENOENT') {\n // Missing lockfile is \"ok\" from a repair POV.\n return { lockfilePath, ok: true, findings: [] };\n }\n findings.push({\n severity: 'error',\n kind: 'envelope-malformed',\n message: 'Failed to read lockfile bytes.',\n detail: err instanceof Error ? err.message : String(err),\n });\n return { lockfilePath, ok: false, findings };\n }\n\n let parsedJson: unknown;\n try {\n parsedJson = JSON.parse(raw);\n } catch (err) {\n findings.push({\n severity: 'error',\n kind: 'envelope-malformed',\n message: 'Lockfile is not valid JSON.',\n detail: err instanceof Error ? err.message : String(err),\n });\n return { lockfilePath, ok: false, findings };\n }\n\n const envelopeParsed = RelaxedEnvelopeSchema.safeParse(parsedJson);\n if (!envelopeParsed.success) {\n findings.push({\n severity: 'error',\n kind: 'envelope-malformed',\n message: 'Top-level envelope failed to parse.',\n detail: formatZodIssuesAsSingleLine(envelopeParsed.error),\n });\n return { lockfilePath, ok: false, findings };\n }\n const envelope = envelopeParsed.data;\n\n const modulesPayload = envelope.sections.modules;\n if (modulesPayload === undefined) {\n // No modules section present — nothing to inspect.\n return { lockfilePath, ok: true, findings };\n }\n\n const parsed = RegistryModulesLockSectionSchema.safeParse(modulesPayload);\n if (!parsed.success) {\n findings.push({\n severity: 'error',\n kind: 'modules-section-malformed',\n message: '`sections.modules` failed schema validation. Restore the affected record from a trusted lockfile revision; automatic repair does not infer missing or invalid metadata.',\n detail: formatZodIssuesAsSingleLine(parsed.error),\n });\n return { lockfilePath, ok: false, findings };\n }\n const modules: RegistryModulesLockSection = parsed.data;\n\n for (const [moduleId, entry] of Object.entries(modules.installed)) {\n await this.collectEntryFindings(saasRoot, moduleId, entry, findings);\n }\n\n const ok = findings.every((f) => f.severity !== 'error');\n return { lockfilePath, ok, findings };\n },\n\n /**\n * Missing-file diagnostics for an entry already validated by the strict section schema.\n */\n async collectEntryFindings(\n saasRoot: string,\n moduleId: string,\n entry: RegistryModulesLockEntry,\n findings: LockfileRepairFinding[],\n ): Promise<void> {\n for (const filePath of entry.files) {\n const abs = path.resolve(saasRoot, filePath);\n if (!(await fileExists(abs))) {\n findings.push({\n severity: 'warn',\n kind: 'module-file-missing',\n moduleId,\n filePath,\n });\n }\n }\n },\n} as const;\n\n// L6 (third-pass review): re-export removed — barrel-discipline rule\n// says \"Never re-export except in the root `index.ts`.\" Consumers\n// import the symbol directly from `@wildo-ai/platform-config-lib`.\n"]}
1
+ {"version":3,"file":"lockfile-repair.service.js","sourceRoot":"","sources":["../../../../src/services/lockfile-repair.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EACL,6BAA6B,EAC7B,gCAAgC,EAChC,oBAAoB,EACpB,kCAAkC,GAGnC,MAAM,+BAA+B,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAN,IAAY,8BAWX;AAXD,WAAY,8BAA8B;IACxC,oGAAoG;IACpG,+EAA6C,CAAA;IAC7C,sGAAsG;IACtG,uEAAqC,CAA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AC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;QACjG,CAAC;QAED,MAAM,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;QACzD,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,oBAAoB,CACxB,QAAgB,EAChB,QAAgB,EAChB,KAA+B,EAC/B,QAAiC;QAEjC,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YACnC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAC7C,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC7B,QAAQ,CAAC,IAAI,CAAC;oBACZ,QAAQ,EAAE,MAAM;oBAChB,IAAI,EAAE,qBAAqB;oBAC3B,QAAQ;oBACR,QAAQ;iBACT,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;CACO,CAAC;AAEX,qEAAqE;AACrE,kEAAkE;AAClE,mEAAmE","sourcesContent":["/**\n * `LockfileRepairService` — read-only lockfile diagnostics.\n *\n * Backs `wildo registry repair-lockfile`. Strict envelope and module-section\n * validation runs before file inspection. Malformed records, including invalid\n * artifact digests, require restoration from a trusted record; they are never\n * admitted into the automatic repair path. Valid records can report missing\n * source files, which the CLI can re-fetch at their recorded exact version.\n * This inspector does not mutate files.\n *\n * `i18n` validation is intentionally NOT performed here (KD-15 +\n * Review-pass-2 / MEDIUM-5): repair is the wrong place to\n * second-guess companion-owned section semantics. The shared\n * lockfile library STILL validates i18n on the companion-owned\n * read path; this service only owns module diagnostics.\n */\n\nimport { promises as fs } from 'node:fs';\nimport * as path from 'node:path';\nimport { z } from 'zod';\nimport { formatZodIssuesAsSingleLine } from './_zod-issue-formatting';\nimport {\n PROVIDER_VENDOR_PINS_MANIFEST,\n RegistryModulesLockSectionSchema,\n getWildoSaasLockPath,\n withoutRetiredLockfileEnvelopeKeys,\n type RegistryModulesLockEntry,\n type RegistryModulesLockSection,\n} from '@wildo-ai/platform-config-lib';\n\n/**\n * Why a provider module's install-script name cannot simply be written back into the application's root\n * `package.json` → `pnpm.onlyBuiltDependencies` (#2809). Each is the application's own policy, which the install\n * (#2801) also refuses to override, and pnpm 10.6.4 reads it as follows (measured in #2801):\n */\nexport enum ApplicationInstallScriptPolicy {\n /** The allow-list lives in `pnpm-workspace.yaml`, and a list in `package.json` would REPLACE it. */\n WORKSPACE_ALLOW_LIST = 'workspace-allow-list',\n /** A `neverBuiltDependencies` list names the package, and pnpm refuses to install with both lists. */\n NEVER_BUILT_LIST = 'never-built-list',\n /**\n * The application declares an allow-list AND a `neverBuiltDependencies` list (in either file): pnpm 10.6.4 refuses to\n * install at all (`ERR_PNPM_CONFIG_CONFLICT_BUILT_DEPENDENCIES`, measured in #2809's review), so writing a name changes\n * nothing until the application keeps one of them.\n */\n CONFLICTING_LISTS = 'conflicting-lists',\n}\n\n/**\n * The install-script policy `pnpm-workspace.yaml` declares, each list `undefined` when the file does not declare it.\n * Supplied by the caller, which owns the YAML reading (`wildo-cli`'s `readWorkspaceBuildPolicy`, the reader the install\n * uses), so the inspector and the install judge one policy the same way.\n */\nexport interface WorkspaceBuildPolicy {\n onlyBuiltDependencies?: readonly string[];\n neverBuiltDependencies?: readonly string[];\n}\n\nexport interface LockfileRepairInspectOptions {\n /**\n * Required rather than defaulted: without it, a name missing from `package.json` could look restorable when the\n * application keeps its list in `pnpm-workspace.yaml`, and `--fix` would then replace that list.\n */\n workspaceBuildPolicy: WorkspaceBuildPolicy;\n}\n\n/**\n * Permissive envelope schema used by repair only — it accepts any\n * `sections.*` payload without delegating to per-section schemas\n * so the repair flow can isolate \"envelope is malformed\" from\n * \"envelope is fine but modules section is malformed\". Applied after\n * `withoutRetiredLockfileEnvelopeKeys`, like every lockfile reader, so a\n * file written before the envelope lost its `generatedAt` still parses.\n */\nconst RelaxedEnvelopeSchema = z.strictObject({\n schemaVersion: z.literal(2),\n sections: z.record(z.string(), z.unknown()),\n});\n\nexport type LockfileRepairFinding =\n | {\n severity: 'error';\n kind: 'envelope-malformed';\n message: string;\n detail?: string;\n }\n | {\n severity: 'error';\n kind: 'modules-section-malformed';\n message: string;\n detail?: string;\n }\n | {\n severity: 'warn';\n kind: 'module-file-missing';\n moduleId: string;\n filePath: string;\n }\n | {\n /** A vendor pin the module's recorded wiring wrote (#2789) is gone from the root `pnpm.overrides`: restorable. */\n severity: 'warn';\n kind: 'vendor-pin-missing';\n moduleId: string;\n name: string;\n version: string;\n }\n | {\n /** A recorded vendor pin the application moved since install: its decision, reported and never overwritten. */\n severity: 'warn';\n kind: 'vendor-pin-moved';\n moduleId: string;\n name: string;\n version: string;\n found: string;\n }\n | {\n /**\n * An install-script name the module's recorded wiring wrote (#2801), not held by the application, that the\n * application's allow-list no longer carries: restorable into `package.json` → `pnpm.onlyBuiltDependencies`.\n */\n severity: 'warn';\n kind: 'only-built-missing';\n moduleId: string;\n name: string;\n }\n | {\n /** A recorded install-script name the application's own policy does not allow, and `--fix` must not write: reported only. */\n severity: 'warn';\n kind: 'only-built-blocked';\n moduleId: string;\n name: string;\n policy: ApplicationInstallScriptPolicy;\n };\n\nexport interface LockfileRepairReport {\n /** Absolute path the report covers. */\n lockfilePath: string;\n /** True when no errors were produced (warnings allowed). */\n ok: boolean;\n findings: readonly LockfileRepairFinding[];\n}\n\nasync function fileExists(absPath: string): Promise<boolean> {\n try {\n await fs.access(absPath);\n return true;\n } catch {\n return false;\n }\n}\n\n/** The `pnpm` section of the application's root manifest, `{}` when the manifest is absent or not JSON (nothing to compare). */\nasync function readRootPnpmSection(saasRoot: string): Promise<{ overrides?: unknown; onlyBuiltDependencies?: unknown; neverBuiltDependencies?: unknown }> {\n try {\n const section = (JSON.parse(await fs.readFile(path.join(saasRoot, PROVIDER_VENDOR_PINS_MANIFEST), 'utf8')) as { pnpm?: unknown }).pnpm;\n return section !== null && typeof section === 'object' && !Array.isArray(section) ? section : {};\n } catch {\n return {};\n }\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {};\n}\n\nfunction asNames(value: unknown): string[] | undefined {\n return Array.isArray(value) ? value.filter((name): name is string => typeof name === 'string') : undefined;\n}\n\n/**\n * Each install-script name a provider module's recorded wiring WROTE (#2801; a held name is the application's own), judged\n * as pnpm 10.6.4 will judge it, with the same precedence the install uses (`onlyBuiltStates` in `wildo-cli`):\n * - an allow-list AND a `neverBuiltDependencies` list, in either file → pnpm installs nothing, so a name the allow-list\n * lacks is blocked by `CONFLICTING_LISTS` and never written;\n * - `package.json` carries an allow-list → it is the one pnpm reads (it replaces a workspace list), so a name it lacks is\n * `only-built-missing`, restorable there;\n * - otherwise a `pnpm-workspace.yaml` allow-list → a name it lacks is blocked by `WORKSPACE_ALLOW_LIST`;\n * - otherwise a `neverBuiltDependencies` list (`package.json` first, as the install reads it) → a name it lists is blocked\n * by `NEVER_BUILT_LIST`; any other name's script runs, so nothing is reported;\n * - otherwise no policy at all → pnpm runs no script, and the name is `only-built-missing`: restoring it writes the list\n * the install wrote.\n */\nfunction collectOnlyBuiltFindings(\n moduleId: string,\n entry: RegistryModulesLockEntry,\n pnpmSection: { onlyBuiltDependencies?: unknown; neverBuiltDependencies?: unknown },\n workspace: WorkspaceBuildPolicy,\n findings: LockfileRepairFinding[],\n): void {\n const wiring = entry.registration?.providerWiring;\n const held = new Set(wiring?.heldOnlyBuiltDependencies ?? []);\n const wrote = (wiring?.onlyBuiltDependencies ?? []).filter((name) => !held.has(name));\n if (wrote.length === 0) return;\n const manifestList = asNames(pnpmSection.onlyBuiltDependencies);\n const never = asNames(pnpmSection.neverBuiltDependencies) ?? workspace.neverBuiltDependencies;\n const allowList = manifestList ?? workspace.onlyBuiltDependencies;\n for (const name of wrote) {\n if (allowList !== undefined && never !== undefined) {\n if (!allowList.includes(name)) findings.push({ severity: 'warn', kind: 'only-built-blocked', moduleId, name, policy: ApplicationInstallScriptPolicy.CONFLICTING_LISTS });\n } else if (manifestList !== undefined) {\n if (!manifestList.includes(name)) findings.push({ severity: 'warn', kind: 'only-built-missing', moduleId, name });\n } else if (workspace.onlyBuiltDependencies !== undefined) {\n if (!workspace.onlyBuiltDependencies.includes(name)) {\n findings.push({ severity: 'warn', kind: 'only-built-blocked', moduleId, name, policy: ApplicationInstallScriptPolicy.WORKSPACE_ALLOW_LIST });\n }\n } else if (never !== undefined) {\n if (never.includes(name)) findings.push({ severity: 'warn', kind: 'only-built-blocked', moduleId, name, policy: ApplicationInstallScriptPolicy.NEVER_BUILT_LIST });\n } else {\n findings.push({ severity: 'warn', kind: 'only-built-missing', moduleId, name });\n }\n }\n}\n\n/**\n * Each vendor pin a provider module's recorded wiring wrote (#2789), against the root overrides: missing (restorable by\n * `--fix`), or moved by the application (reported only: a pin the application set is its own).\n */\nfunction collectVendorPinFindings(moduleId: string, entry: RegistryModulesLockEntry, overrides: Record<string, unknown>, findings: LockfileRepairFinding[]): void {\n for (const [name, version] of Object.entries(entry.registration?.providerWiring?.vendorPins ?? {})) {\n if (!Object.hasOwn(overrides, name)) findings.push({ severity: 'warn', kind: 'vendor-pin-missing', moduleId, name, version });\n else if (overrides[name] !== version) findings.push({ severity: 'warn', kind: 'vendor-pin-moved', moduleId, name, version, found: String(overrides[name]) });\n }\n}\n\nexport const LockfileRepairService = {\n /** Compute the lockfile path for a saas root. */\n pathFor(saasRoot: string): string {\n return getWildoSaasLockPath(saasRoot);\n },\n\n /**\n * Read the envelope + run every diagnostic. Read-only.\n */\n async inspect(saasRoot: string, options: LockfileRepairInspectOptions): Promise<LockfileRepairReport> {\n const lockfilePath = getWildoSaasLockPath(saasRoot);\n const findings: LockfileRepairFinding[] = [];\n\n // Read raw bytes ourselves so we can produce per-section\n // diagnostics: a malformed `modules` section under an\n // otherwise-valid envelope should report `modules-section-malformed`,\n // NOT `envelope-malformed` (the latter would tell the operator\n // to re-author the whole file when only one section is bad).\n let raw: string;\n try {\n raw = await fs.readFile(lockfilePath, 'utf8');\n } catch (err: unknown) {\n const errno = (err as NodeJS.ErrnoException)?.code;\n if (errno === 'ENOENT') {\n // Missing lockfile is \"ok\" from a repair POV.\n return { lockfilePath, ok: true, findings: [] };\n }\n findings.push({\n severity: 'error',\n kind: 'envelope-malformed',\n message: 'Failed to read lockfile bytes.',\n detail: err instanceof Error ? err.message : String(err),\n });\n return { lockfilePath, ok: false, findings };\n }\n\n let parsedJson: unknown;\n try {\n parsedJson = JSON.parse(raw);\n } catch (err) {\n findings.push({\n severity: 'error',\n kind: 'envelope-malformed',\n message: 'Lockfile is not valid JSON.',\n detail: err instanceof Error ? err.message : String(err),\n });\n return { lockfilePath, ok: false, findings };\n }\n\n const envelopeParsed = RelaxedEnvelopeSchema.safeParse(withoutRetiredLockfileEnvelopeKeys(parsedJson));\n if (!envelopeParsed.success) {\n findings.push({\n severity: 'error',\n kind: 'envelope-malformed',\n message: 'Top-level envelope failed to parse.',\n detail: formatZodIssuesAsSingleLine(envelopeParsed.error),\n });\n return { lockfilePath, ok: false, findings };\n }\n const envelope = envelopeParsed.data;\n\n const modulesPayload = envelope.sections.modules;\n if (modulesPayload === undefined) {\n // No modules section present — nothing to inspect.\n return { lockfilePath, ok: true, findings };\n }\n\n const parsed = RegistryModulesLockSectionSchema.safeParse(modulesPayload);\n if (!parsed.success) {\n findings.push({\n severity: 'error',\n kind: 'modules-section-malformed',\n message: '`sections.modules` failed schema validation. Restore the affected record from a trusted lockfile revision; automatic repair does not infer missing or invalid metadata.',\n detail: formatZodIssuesAsSingleLine(parsed.error),\n });\n return { lockfilePath, ok: false, findings };\n }\n const modules: RegistryModulesLockSection = parsed.data;\n\n const pnpmSection = await readRootPnpmSection(saasRoot);\n const rootOverrides = asRecord(pnpmSection.overrides);\n for (const [moduleId, entry] of Object.entries(modules.installed)) {\n await this.collectEntryFindings(saasRoot, moduleId, entry, findings);\n collectVendorPinFindings(moduleId, entry, rootOverrides, findings);\n collectOnlyBuiltFindings(moduleId, entry, pnpmSection, options.workspaceBuildPolicy, findings);\n }\n\n const ok = findings.every((f) => f.severity !== 'error');\n return { lockfilePath, ok, findings };\n },\n\n /**\n * Missing-file diagnostics for an entry already validated by the strict section schema.\n */\n async collectEntryFindings(\n saasRoot: string,\n moduleId: string,\n entry: RegistryModulesLockEntry,\n findings: LockfileRepairFinding[],\n ): Promise<void> {\n for (const filePath of entry.files) {\n const abs = path.resolve(saasRoot, filePath);\n if (!(await fileExists(abs))) {\n findings.push({\n severity: 'warn',\n kind: 'module-file-missing',\n moduleId,\n filePath,\n });\n }\n }\n },\n} as const;\n\n// L6 (third-pass review): re-export removed — barrel-discipline rule\n// says \"Never re-export except in the root `index.ts`.\" Consumers\n// import the symbol directly from `@wildo-ai/platform-config-lib`.\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"module-adopter.service.d.ts","sourceRoot":"","sources":["../../../src/services/module-adopter.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,EAAuD,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACzH,OAAO,EAAyB,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAErF,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,wEAAwE;IACxE,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,YAAY,CAAC;IACtB,oDAAoD;IACpD,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAAC;CAChB;AAuCD,eAAO,MAAM,oBAAoB;IAC/B;;;OAGG;6CAES,MAAM,YACN,cAAc,KACvB,OAAO,CAAC,YAAY,CAAC;IAyBxB;;;OAGG;wCAES,MAAM,YACN,cAAc,KACvB,OAAO,CAAC,cAAc,CAAC;IAO1B;;;;OAIG;yCAES,MAAM,YACN,cAAc,QAClB,YAAY,KACjB,OAAO,CAAC;QAAE,OAAO,EAAE,YAAY,CAAC;QAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC;CAezD,CAAC"}
1
+ {"version":3,"file":"module-adopter.service.d.ts","sourceRoot":"","sources":["../../../../src/services/module-adopter.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,EAAuD,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACzH,OAAO,EAAyB,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAErF,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,wEAAwE;IACxE,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,YAAY,CAAC;IACtB,oDAAoD;IACpD,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAAC;CAChB;AAuCD,eAAO,MAAM,oBAAoB;IAC/B;;;OAGG;6CAES,MAAM,YACN,cAAc,KACvB,OAAO,CAAC,YAAY,CAAC;IAyBxB;;;OAGG;wCAES,MAAM,YACN,cAAc,KACvB,OAAO,CAAC,cAAc,CAAC;IAO1B;;;;OAIG;yCAES,MAAM,YACN,cAAc,QAClB,YAAY,KACjB,OAAO,CAAC;QAAE,OAAO,EAAE,YAAY,CAAC;QAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC;CAezD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"module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YG;8CACkC,MAAM,YAAY,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC;CAmBvE,CAAC"}
1
+ {"version":3,"file":"module-packager.service.d.ts","sourceRoot":"","sources":["../../../../src/services/module-packager.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAKH,OAAO,EAML,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAE9B,MAAM,+BAA+B,CAAC;AAEvC,eAAO,MAAM,8BAA8B,4CAA4C,CAAC;AAExF,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,CAyBtF;AA+BD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,wBAAwB,GAAG,SAAS,GAC/C,MAAM,CAgBR;AAED,eAAO,MAAM,qBAAqB;IAChC;;OAEG;+BACa,MAAM,YAAY,MAAM,KAAG,YAAY;IAIvD;;;;OAIG;oCACwB,MAAM,YAAY,MAAM,KAAG,OAAO,CAAC,YAAY,CAAC;IAO3E;;;;;;;;OAQG;8BACkB;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,EAAE,cAAc,CAAC;KAC1B,KAAG,OAAO,CAAC;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAehE;;;;OAIG;mCACuB;QACxB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,cAAc,CAAC;KAC1B,KAAG,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,cAAc,CAAA;KAAE,CAAC;IAQ/D;;;;;;;;;;;;OAYG;8CACkC,MAAM,YAAY,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC;CAmBvE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"provider-materialization-hook.d.ts","sourceRoot":"","sources":["../../../src/services/provider-materialization-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;IAC5D,GAAG,CAAC,EAAE,oBAAoB,CAAC;CAC5B;AAED,MAAM,WAAW,iCAAiC;IAChD,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,SAAS,GAAG,WAAW,CAAC;IAC9B,gBAAgB,EAAE,KAAK,CAAC;IACxB,yBAAyB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,0BAA0B,EAAE,MAAM,CAAC;IACnC,uBAAuB,EAAE,OAAO,0BAA0B,CAAC;IAC3D,MAAM,EAAE,gCAAgC,CAAC,QAAQ,CAAC,CAAC;CACpD;AAED,wBAAsB,8BAA8B,CAClD,KAAK,EAAE,gCAAgC,GACtC,OAAO,CAAC,iCAAiC,CAAC,CAgB5C"}
1
+ {"version":3,"file":"provider-materialization-hook.d.ts","sourceRoot":"","sources":["../../../../src/services/provider-materialization-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,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ACd;;;OAGG;IACH,IAAI,EAAE,WAAW,GAAG,SAAS,CAAC;IAC9B,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,MAAM,EAAE,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAC1C,8DAA8D;IAC9D,yBAAyB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,+CAA+C;IAC/C,0BAA0B,EAAE,MAAM,CAAC;IACnC,8DAA8D;IAC9D,uBAAuB,EAAE,OAAO,0BAA0B,CAAC;CAC5D;AAkJD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,wBAAwB,CAAC,CAuDnC"}
@@ -1 +1 @@
1
- {"version":3,"file":"registry-companion-client.d.ts","sourceRoot":"","sources":["../../../src/services/registry-companion-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,uBAAuB;IAClC;;;OAGG;kBACiB,8BAA8B,GAAG,OAAO,CAAC,OAAO,CAAC;CAatE,CAAC"}
1
+ {"version":3,"file":"registry-companion-client.d.ts","sourceRoot":"","sources":["../../../../src/services/registry-companion-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,uBAAuB;IAClC;;;OAGG;kBACiB,8BAA8B,GAAG,OAAO,CAAC,OAAO,CAAC;CAatE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"registry-lockfile.service.d.ts","sourceRoot":"","sources":["../../../src/services/registry-lockfile.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAIL,KAAK,0BAA0B,EAE/B,KAAK,6BAA6B,EACnC,MAAM,+BAA+B,CAAC;AAevC,eAAO,MAAM,uBAAuB;IAClC;;;;OAIG;8BACkB,MAAM,KAAG,OAAO,CAAC,0BAA0B,CAAC;IAOjE;;;;;;OAMG;gCAES,MAAM,WACP,CACP,OAAO,EAAE,0BAA0B,KAEjC,0BAA0B,GAC1B,IAAI,GACJ,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC,KAC7C,OAAO,CAAC,0BAA0B,CAAC;IAYtC;;;;OAIG;qCACyB,MAAM,SAAS,6BAA6B,KAAG,OAAO,CAAC,IAAI,CAAC;IAQxF;;;;;;;;;OASG;oCACwB;QACzB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;QACzB,eAAe,EAAE,MAAM,CAAC;KACzB,KAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAgB1B,CAAC"}
1
+ {"version":3,"file":"registry-lockfile.service.d.ts","sourceRoot":"","sources":["../../../../src/services/registry-lockfile.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAIL,KAAK,0BAA0B,EAE/B,KAAK,6BAA6B,EACnC,MAAM,+BAA+B,CAAC;AAevC,eAAO,MAAM,uBAAuB;IAClC;;;;OAIG;8BACkB,MAAM,KAAG,OAAO,CAAC,0BAA0B,CAAC;IAOjE;;;;;;OAMG;gCAES,MAAM,WACP,CACP,OAAO,EAAE,0BAA0B,KAEjC,0BAA0B,GAC1B,IAAI,GACJ,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC,KAC7C,OAAO,CAAC,0BAA0B,CAAC;IAYtC;;;;OAIG;qCACyB,MAAM,SAAS,6BAA6B,KAAG,OAAO,CAAC,IAAI,CAAC;IAQxF;;;;;;;;;OASG;oCACwB;QACzB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;QACzB,eAAe,EAAE,MAAM,CAAC;KACzB,KAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAgB1B,CAAC"}
@@ -15,7 +15,8 @@
15
15
  * `RegistryAuthRequiredError` (no key sent), `RegistryCredentialRejectedError` (a key sent and refused)
16
16
  * or `RegistryAuthForbiddenError`; a 429 is `RegistryRateLimitedError`.
17
17
  */
18
- import { type ModuleManifest, type ModuleSearchFilter, type ModuleSearchHit, type RegistryYankNotice, type ModuleVersionRecord } from '@wildo-ai/platform-config-lib';
18
+ import { z } from 'zod';
19
+ import { type RegistryArtifactVisibility, type ModuleManifest, type ModuleSearchFilter, type ModuleSearchHit, type RegistryYankNotice, type ModuleVersionRecord } from '@wildo-ai/platform-config-lib';
19
20
  export interface RegistryServerClientOptions {
20
21
  /** Registry origin (e.g. `https://registry.wildo.ai`). */
21
22
  baseUrl: string;
@@ -116,5 +117,26 @@ export declare const RegistryServerClient: {
116
117
  }) => Promise<{
117
118
  latest: string | null;
118
119
  }>;
120
+ /**
121
+ * Register a domain for the key's organization (#2024). Domains are first come, first served, and every module
122
+ * published into one inherits its `defaultVisibility`. A slug already registered throws `RegistryDomainTakenError`
123
+ * whoever holds it; `listMyDomains` tells whether that is the caller's own organization.
124
+ */
125
+ readonly createDomain: (options: RegistryServerClientOptions, args: {
126
+ domain: string;
127
+ defaultVisibility: RegistryArtifactVisibility;
128
+ }) => Promise<RegistryDomainRecord>;
129
+ /** The domains the key's organization owns (#2024). Needs a key holding the domain LIST role. */
130
+ readonly listMyDomains: (options: RegistryServerClientOptions) => Promise<RegistryDomainRecord[]>;
119
131
  };
132
+ /** A registry domain as the registry answers it: the slug and the visibility its modules inherit. */
133
+ declare const RegistryDomainRecordSchema: z.ZodObject<{
134
+ domain: z.ZodString;
135
+ defaultVisibility: z.ZodEnum<{
136
+ PUBLIC: "PUBLIC";
137
+ RESTRICTED: "RESTRICTED";
138
+ }>;
139
+ }, z.core.$strip>;
140
+ export type RegistryDomainRecord = z.infer<typeof RegistryDomainRecordSchema>;
141
+ export {};
120
142
  //# sourceMappingURL=registry-server-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry-server-client.d.ts","sourceRoot":"","sources":["../../../src/services/registry-server-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAwBL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACzB,MAAM,+BAA+B,CAAC;AAsBvC,MAAM,WAAW,2BAA2B;IAC1C,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA6DD,MAAM,WAAW,qBAAqB;IACpC,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,cAAc,CAAC;IACzB,QAAQ,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACzC,sDAAsD;IACtD,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACxC;AAED,+FAA+F;AAC/F,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAEhD,eAAO,MAAM,oBAAoB;IAC/B;;;;;;OAMG;6BACiB,2BAA2B,KAAG,OAAO,CAAC,OAAO,CAAC;IAalE;;;;OAIG;gCAEQ,2BAA2B,QAC9B;QAAE,MAAM,EAAE,MAA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B,KAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;CASlF,CAAC;AAEX,qGAAqG;AACrG,QAAA,MAAM,0BAA0B;;;;;;iBAA+F,CAAC;AAChI,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
@@ -17,7 +17,7 @@
17
17
  */
18
18
  import { z } from 'zod';
19
19
  import { formatZodIssuesAsSingleLine } from './_zod-issue-formatting.js';
20
- import { ModuleManifestSchema, ModuleVersionRecordSchema, RegistryArtifactIntegrityMismatchError, RegistryAuthForbiddenError, RegistryAuthRequiredError, RegistryCredentialRejectedError, RegistryRateLimitedError, isRegistryError, isRegistryReleaseStateConflictBody, RegistryMalformedPayloadError, RegistryModuleNotFoundError, RegistryUnexpectedStatusError, RegistryVersionNotFoundError, RegistryYankNoticeSchema, RegistryYankStateConflictError, RegistryYankVerb, REGISTRY_YANK_REASON_HEADER, REGISTRY_YANKED_AT_HEADER, Sha256DigestSchema, ModuleSearchHitSchema, moduleSearchFilterQueryPairs, moduleSearchHitMatchesFilter, } from '@wildo-ai/platform-config-lib';
20
+ import { ModuleManifestSchema, ModuleVersionRecordSchema, RegistryArtifactIntegrityMismatchError, RegistryAuthForbiddenError, RegistryAuthRequiredError, RegistryCredentialRejectedError, RegistryArtifactVisibilitySchema, RegistryDomainTakenError, RegistryRefusalCode, hasRegistryRefusalCode, RegistryRateLimitedError, isRegistryError, isRegistryReleaseStateConflictBody, RegistryMalformedPayloadError, RegistryModuleNotFoundError, RegistryUnexpectedStatusError, RegistryVersionNotFoundError, RegistryYankNoticeSchema, RegistryYankStateConflictError, RegistryYankVerb, REGISTRY_YANK_REASON_HEADER, REGISTRY_YANKED_AT_HEADER, Sha256DigestSchema, ModuleSearchHitSchema, moduleSearchFilterQueryPairs, moduleSearchHitMatchesFilter, } from '@wildo-ai/platform-config-lib';
21
21
  import { fetchJsonOk, fetchTransfer, fetchWithTimeout, joinUrl, readJsonBody } from './_http-client.js';
22
22
  /**
23
23
  * Zod schema for the `info()` response payload — mirrors
@@ -251,7 +251,50 @@ export const RegistryServerClient = {
251
251
  async unyank(options, args) {
252
252
  return changeYankState(options, args, RegistryYankVerb.UNYANK);
253
253
  },
254
+ /**
255
+ * Register a domain for the key's organization (#2024). Domains are first come, first served, and every module
256
+ * published into one inherits its `defaultVisibility`. A slug already registered throws `RegistryDomainTakenError`
257
+ * whoever holds it; `listMyDomains` tells whether that is the caller's own organization.
258
+ */
259
+ async createDomain(options, args) {
260
+ const url = joinUrl(options.baseUrl, '/v1/registry/domains');
261
+ const action = `create domain ${args.domain}`;
262
+ const res = await fetchWithTimeout(url, {
263
+ method: 'POST',
264
+ headers: { ...authHeaders(options), 'content-type': 'application/json' },
265
+ body: JSON.stringify({ domain: args.domain, defaultVisibility: args.defaultVisibility }),
266
+ timeoutMs: options.timeoutMs,
267
+ diagnosticLabel: DIAGNOSTIC_LABEL,
268
+ });
269
+ if (res.status === 409) {
270
+ // Only the registry's own code means "the slug is registered"; a bare 409 is shared by other refusals.
271
+ const body = await res.json().catch(() => undefined);
272
+ if (hasRegistryRefusalCode(body, RegistryRefusalCode.DOMAIN_TAKEN))
273
+ throw new RegistryDomainTakenError(args.domain);
274
+ throw new RegistryUnexpectedStatusError(options.baseUrl, res.status, res.statusText, action);
275
+ }
276
+ await refuseUnlessOk(res, options, action);
277
+ const parsed = RegistryCreateDomainResponseSchema.safeParse(await parseJsonOrThrow(res, options.baseUrl, action, options.timeoutMs));
278
+ if (!parsed.success)
279
+ throw new RegistryMalformedPayloadError(options.baseUrl, action, formatZodIssuesAsSingleLine(parsed.error));
280
+ return parsed.data.domain;
281
+ },
282
+ /** The domains the key's organization owns (#2024). Needs a key holding the domain LIST role. */
283
+ async listMyDomains(options) {
284
+ const url = joinUrl(options.baseUrl, '/v1/registry/my-domains');
285
+ const action = 'list domains';
286
+ const res = await fetchWithTimeout(url, { method: 'GET', headers: authHeaders(options), timeoutMs: options.timeoutMs, diagnosticLabel: DIAGNOSTIC_LABEL });
287
+ await refuseUnlessOk(res, options, action);
288
+ const parsed = RegistryListDomainsResponseSchema.safeParse(await parseJsonOrThrow(res, options.baseUrl, action, options.timeoutMs));
289
+ if (!parsed.success)
290
+ throw new RegistryMalformedPayloadError(options.baseUrl, action, formatZodIssuesAsSingleLine(parsed.error));
291
+ return parsed.data.domains;
292
+ },
254
293
  };
294
+ /** A registry domain as the registry answers it: the slug and the visibility its modules inherit. */
295
+ const RegistryDomainRecordSchema = z.object({ domain: z.string().min(1), defaultVisibility: RegistryArtifactVisibilitySchema });
296
+ const RegistryCreateDomainResponseSchema = z.object({ domain: RegistryDomainRecordSchema });
297
+ const RegistryListDomainsResponseSchema = z.object({ domains: z.array(RegistryDomainRecordSchema) });
255
298
  const RegistryYankResponseSchema = z.object({ ok: z.literal(true), latest: z.string().nullable().optional() });
256
299
  async function changeYankState(options, args, verb) {
257
300
  const url = joinUrl(options.baseUrl, `/v1/registry/${encodeURIComponent(args.domain)}/modules/${encodeURIComponent(args.moduleId)}/${verb}`);
@@ -1 +1 @@
1
- {"version":3,"file":"registry-server-client.js","sourceRoot":"","sources":["../../../../src/services/registry-server-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,sCAAsC,EACtC,0BAA0B,EAC1B,yBAAyB,EACzB,+BAA+B,EAE/B,wBAAwB,EACxB,eAAe,EACf,kCAAkC,EAClC,6BAA6B,EAC7B,2BAA2B,EAC3B,6BAA6B,EAC7B,4BAA4B,EAC5B,wBAAwB,EACxB,8BAA8B,EAC9B,gBAAgB,EAChB,2BAA2B,EAC3B,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,EACrB,4BAA4B,EAC5B,4BAA4B,GAM7B,MAAM,+BAA+B,CA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I,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,qGAAqG;QACrG,kGAAkG;QAClG,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,kCAAkC,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,8BAA8B,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC1H,MAAM,IAAI,6BAA6B,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC/F,CAAC;IACD,oFAAoF;IACpF,MAAM,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,4BAA4B,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAChH,MAAM,MAAM,GAAG,0BAA0B,CAAC,SAAS,CAAC,MAAM,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IAC7H,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,6BAA6B,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,2BAA2B,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9G,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;AAChD,CAAC","sourcesContent":["/**\n * `RegistryServerClient` — HTTP client for the central registry\n * server (`platform-module-registry`, KD-7).\n *\n * Phase 2 fills out the read + download surface (`resolve`,\n * `info`, `search`, `download`). The wire shapes mirror the\n * gateway endpoints documented in the analysis plan's \"Registry\n * HTTP API\" section. The actual server (Phase 3) ships these\n * routes; until it does, the client throws typed errors when it\n * can't reach the server.\n *\n * Auth (KD-11): if `authToken` is supplied, every request adds\n * `Authorization: Bearer <token>`. Public read paths work without\n * a token; restricted paths return 401/403, surfaced as\n * `RegistryAuthRequiredError` (no key sent), `RegistryCredentialRejectedError` (a key sent and refused)\n * or `RegistryAuthForbiddenError`; a 429 is `RegistryRateLimitedError`.\n */\n\nimport { z } from 'zod';\nimport { formatZodIssuesAsSingleLine } from './_zod-issue-formatting';\nimport {\n ModuleManifestSchema,\n ModuleVersionRecordSchema,\n RegistryArtifactIntegrityMismatchError,\n RegistryAuthForbiddenError,\n RegistryAuthRequiredError,\n RegistryCredentialRejectedError,\n RegistryError,\n RegistryRateLimitedError,\n isRegistryError,\n isRegistryReleaseStateConflictBody,\n RegistryMalformedPayloadError,\n RegistryModuleNotFoundError,\n RegistryUnexpectedStatusError,\n RegistryVersionNotFoundError,\n RegistryYankNoticeSchema,\n RegistryYankStateConflictError,\n RegistryYankVerb,\n REGISTRY_YANK_REASON_HEADER,\n REGISTRY_YANKED_AT_HEADER,\n Sha256DigestSchema,\n ModuleSearchHitSchema,\n moduleSearchFilterQueryPairs,\n moduleSearchHitMatchesFilter,\n type ModuleManifest,\n type ModuleSearchFilter,\n type ModuleSearchHit,\n type RegistryYankNotice,\n type ModuleVersionRecord,\n} from '@wildo-ai/platform-config-lib';\nimport { fetchJsonOk, fetchTransfer, fetchWithTimeout, joinUrl, readJsonBody } from './_http-client';\n\n/**\n * Zod schema for the `info()` response payload — mirrors\n * `RegistryInfoResult` and is enforced at the client boundary so a\n * server schema drift fails fast instead of returning malformed data\n * to downstream consumers.\n */\nconst RegistryInfoResponseSchema = z.object({\n moduleId: z.string().min(1),\n manifest: ModuleManifestSchema,\n versions: z.array(ModuleVersionRecordSchema),\n tags: z.record(z.string(), z.string()),\n});\n\nconst RegistrySearchResponseSchema = z.object({\n hits: z.array(ModuleSearchHitSchema),\n});\n\nconst DIAGNOSTIC_LABEL = 'Registry';\n\nexport interface RegistryServerClientOptions {\n /** Registry origin (e.g. `https://registry.wildo.ai`). */\n baseUrl: string;\n /** Optional bearer / API-key. CLI credentials are per-machine (KD-11). */\n authToken?: string;\n /** Request timeout in ms. */\n timeoutMs?: number;\n}\n\nfunction authHeaders(options: RegistryServerClientOptions): Record<string, string> {\n return options.authToken ? { Authorization: `Bearer ${options.authToken}` } : {};\n}\n\n/**\n * Throw the typed error for a non-2xx response, after releasing its body (#1763 review: an unread body\n * holds the connection until garbage collection). A 401 is told apart by whether a key was SENT — \"log\n * in\" and \"your key no longer works\" are different remedies (#1759 review).\n */\nasync function refuseUnlessOk(\n res: Response,\n options: RegistryServerClientOptions,\n action: string,\n notFound?: () => RegistryError,\n): Promise<void> {\n if (res.ok) return;\n let error: RegistryError;\n if (res.status === 404 && notFound) error = notFound();\n else if (res.status === 401) error = options.authToken ? new RegistryCredentialRejectedError(options.baseUrl) : new RegistryAuthRequiredError(options.baseUrl);\n else if (res.status === 403) error = new RegistryAuthForbiddenError(action);\n else if (res.status === 429) error = new RegistryRateLimitedError(options.baseUrl, action, parseRetryAfterSeconds(res.headers.get('retry-after')));\n else error = new RegistryUnexpectedStatusError(options.baseUrl, res.status, res.statusText, action);\n await res.body?.cancel().catch(() => undefined);\n throw error;\n}\n\n/** `Retry-After` in its delta-seconds form; the HTTP-date form is not produced by a Wildo backend. */\nfunction parseRetryAfterSeconds(value: string | null): number | undefined {\n if (!value || !/^\\d+$/.test(value.trim())) return undefined;\n return Number(value.trim());\n}\n\n/**\n * 6th-pass M3: typed JSON-parse helper. A misconfigured proxy that\n * returns HTML at 2xx (or a truncated stream) would otherwise throw a\n * bare `SyntaxError` from `await res.json()`, bypassing every\n * `isRegistryError(err)` handler. This helper translates the parse\n * failure into a `RegistryMalformedPayloadError` so the typed-error\n * contract is universal across the client surface.\n */\nasync function parseJsonOrThrow(\n res: Response,\n registryUrl: string,\n action: string,\n timeoutMs: number | undefined,\n): Promise<unknown> {\n try {\n return await readJsonBody(res, registryUrl, action, timeoutMs);\n } catch (err) {\n // A body cut short by the request budget is a timeout (#1763), not a malformed payload.\n if (isRegistryError(err)) throw err;\n throw new RegistryMalformedPayloadError(\n registryUrl,\n action,\n `response is not valid JSON: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n}\n\nexport interface RegistryResolveResult {\n /** Resolved exact version (matches `Sha256DigestSchema` for digest). */\n version: string;\n artifactDigest: string;\n /**\n * Present when the resolved release is yanked. Only an EXACT-version request can resolve to one\n * (#1758) — ranges and tags never do — so the caller is pinned to it and should warn, not refuse.\n */\n yanked?: RegistryYankNotice;\n}\n\nexport interface RegistryInfoResult {\n moduleId: string;\n manifest: ModuleManifest;\n versions: readonly ModuleVersionRecord[];\n /** dist-tag → version map (e.g. `latest → 1.2.3`). */\n tags: Readonly<Record<string, string>>;\n}\n\n/** One search hit: the module, its latest version, and (#2014) its kind and provider facts. */\nexport type RegistrySearchHit = ModuleSearchHit;\n\nexport const RegistryServerClient = {\n /**\n * Liveness probe against `/health`. Returns boolean — used by\n * `wildo registry ping` smoke. The registry server now relies on\n * the framework's auto-mounted `HealthController` at the engine\n * root (`GET /health` always 200; `GET /health/ready` enforces\n * dependency readiness), so the path has NO `/v1` prefix.\n */\n async ping(options: RegistryServerClientOptions): Promise<boolean> {\n try {\n await fetchJsonOk(joinUrl(options.baseUrl, '/health'), {\n method: 'GET',\n timeoutMs: options.timeoutMs,\n diagnosticLabel: DIAGNOSTIC_LABEL,\n });\n return true;\n } catch {\n return false;\n }\n },\n\n /**\n * Resolve a semver range / tag against a registry domain. The\n * server returns the concrete version + artifact digest so the\n * caller can verify the download against `artifactDigest`.\n */\n async resolve(\n options: RegistryServerClientOptions,\n args: { domain: string; moduleId: string; range: string },\n ): Promise<RegistryResolveResult> {\n const url = joinUrl(\n options.baseUrl,\n `/v1/registry/${encodeURIComponent(args.domain)}/modules/${encodeURIComponent(args.moduleId)}/resolve?range=${encodeURIComponent(args.range)}`,\n );\n const res = await fetchWithTimeout(url, {\n method: 'GET',\n headers: authHeaders(options),\n timeoutMs: options.timeoutMs,\n diagnosticLabel: DIAGNOSTIC_LABEL,\n });\n await refuseUnlessOk(res, options, `resolve ${args.moduleId}`, () => new RegistryVersionNotFoundError(args.moduleId, args.range));\n // 6th-pass M3: typed JSON-parse (was bare `SyntaxError` for\n // malformed proxy responses).\n const json = (await parseJsonOrThrow(res, options.baseUrl, `resolve ${args.moduleId}`, options.timeoutMs)) as {\n version?: unknown;\n artifactDigest?: unknown;\n yanked?: unknown;\n };\n const digest = String(json.artifactDigest ?? '');\n // 6th-pass M4: typed digest validation (was bare `ZodError`).\n const digestParse = Sha256DigestSchema.safeParse(digest);\n if (!digestParse.success) {\n throw new RegistryMalformedPayloadError(\n options.baseUrl,\n `resolve ${args.moduleId}`,\n `artifactDigest is not a valid sha256:<64-hex> string: ${formatZodIssuesAsSingleLine(digestParse.error)}`,\n );\n }\n if (typeof json.version !== 'string' || json.version.length === 0) {\n // 3rd-pass M6: typed `RegistryMalformedPayloadError` instead of\n // bare `Error` so callers' `isRegistryError(err)` handlers fire\n // correctly.\n throw new RegistryMalformedPayloadError(\n options.baseUrl,\n `resolve ${args.moduleId}`,\n 'response missing required `version` string',\n );\n }\n let yanked: RegistryYankNotice | undefined;\n if (json.yanked !== undefined) {\n const yankParse = RegistryYankNoticeSchema.safeParse(json.yanked);\n if (!yankParse.success) {\n throw new RegistryMalformedPayloadError(options.baseUrl, `resolve ${args.moduleId}`, `yanked: ${formatZodIssuesAsSingleLine(yankParse.error)}`);\n }\n yanked = yankParse.data;\n }\n return { version: json.version, artifactDigest: digest, ...(yanked ? { yanked } : {}) };\n },\n\n /**\n * Fetch full info for a module: manifest, every published\n * version, dist-tags. Used by `wildo registry info` (Phase 4).\n */\n async info(\n options: RegistryServerClientOptions,\n args: { domain: string; moduleId: string },\n ): Promise<RegistryInfoResult> {\n const url = joinUrl(\n options.baseUrl,\n `/v1/registry/${encodeURIComponent(args.domain)}/modules/${encodeURIComponent(args.moduleId)}`,\n );\n const res = await fetchWithTimeout(url, {\n method: 'GET',\n headers: authHeaders(options),\n timeoutMs: options.timeoutMs,\n diagnosticLabel: DIAGNOSTIC_LABEL,\n });\n await refuseUnlessOk(res, options, `info ${args.moduleId}`, () => new RegistryModuleNotFoundError(args.moduleId));\n // 6th-pass M3: typed JSON-parse.\n const json = await parseJsonOrThrow(res, options.baseUrl, `info ${args.moduleId}`, options.timeoutMs);\n const parsed = RegistryInfoResponseSchema.safeParse(json);\n if (!parsed.success) {\n throw new RegistryMalformedPayloadError(\n options.baseUrl,\n `info ${args.moduleId}`,\n formatZodIssuesAsSingleLine(parsed.error),\n );\n }\n return parsed.data;\n },\n\n /**\n * Search the registry's metadata index: a module-id substring, and (#2014) the manifest filters —\n * kind, engine capability and provider maturity. The server refuses an unknown filter value.\n */\n async search(\n options: RegistryServerClientOptions,\n args: { domain: string; query: string; filter?: ModuleSearchFilter },\n ): Promise<readonly RegistrySearchHit[]> {\n const params = new URLSearchParams([['q', args.query], ...moduleSearchFilterQueryPairs(args.filter ?? {})]);\n const url = joinUrl(\n options.baseUrl,\n `/v1/registry/${encodeURIComponent(args.domain)}/modules?${params.toString()}`,\n );\n const res = await fetchWithTimeout(url, {\n method: 'GET',\n headers: authHeaders(options),\n timeoutMs: options.timeoutMs,\n diagnosticLabel: DIAGNOSTIC_LABEL,\n });\n await refuseUnlessOk(res, options, 'search');\n // 6th-pass M3: typed JSON-parse.\n const json = await parseJsonOrThrow(res, options.baseUrl, 'search', options.timeoutMs);\n const parsed = RegistrySearchResponseSchema.safeParse(json);\n if (!parsed.success) {\n throw new RegistryMalformedPayloadError(\n options.baseUrl,\n 'search',\n formatZodIssuesAsSingleLine(parsed.error),\n );\n }\n // Re-applied here: a server that predates the filters ignores them and answers every module (#2014 review F9).\n return parsed.data.hits.filter((hit) => moduleSearchHitMatchesFilter(hit, args.filter ?? {}));\n },\n\n /**\n * Stream-download a published artifact's bytes and verify the\n * sha256 integrity matches `expectedDigest`. Throws\n * `RegistryArtifactIntegrityMismatchError` on mismatch — the\n * digest check is non-negotiable per KD-9 / Security model.\n */\n async download(\n options: RegistryServerClientOptions,\n args: {\n domain: string;\n moduleId: string;\n version: string;\n expectedDigest: string;\n },\n ): Promise<{ bytes: Uint8Array; integrity: string; yanked?: RegistryYankNotice }> {\n // 7th-pass C-M1: caller-supplied digest is a developer-contract\n // violation if malformed, not a registry-runtime condition.\n // Throw `TypeError` (matching `C-L3` precedent for\n // `getModuleStagingPaths` argument-shape violations) so the\n // typed `RegistryError` vocabulary stays reserved for\n // registry-runtime errors. Prior `Sha256DigestSchema.parse(...)`\n // leaked a bare `ZodError` that bypassed\n // `isRegistryError(err)` handlers but ALSO confused\n // typed-handler maintainers about the contract.\n const digestParse = Sha256DigestSchema.safeParse(args.expectedDigest);\n if (!digestParse.success) {\n throw new TypeError(\n `download() expectedDigest must be a valid sha256:<64-hex> string (got: ${JSON.stringify(args.expectedDigest)}). ${formatZodIssuesAsSingleLine(digestParse.error)}`,\n );\n }\n const url = joinUrl(\n options.baseUrl,\n `/v1/registry/${encodeURIComponent(args.domain)}/modules/${encodeURIComponent(args.moduleId)}/${encodeURIComponent(args.version)}/artifact`,\n );\n // A transfer, not a metadata call: the response is bounded by `timeoutMs`, the body by an IDLE budget\n // reset on every chunk, so a large artifact over a slow link installs and a stalled one fails (#1763).\n const { response: res, readAll } = await fetchTransfer(url, {\n method: 'GET',\n headers: authHeaders(options),\n timeoutMs: options.timeoutMs,\n diagnosticLabel: DIAGNOSTIC_LABEL,\n });\n await refuseUnlessOk(res, options, `download ${args.moduleId}@${args.version}`, () => new RegistryVersionNotFoundError(args.moduleId, args.version));\n const buf = await readAll();\n const { createHash } = await import('node:crypto');\n const observed = `sha256:${createHash('sha256').update(buf).digest('hex')}`;\n if (observed !== args.expectedDigest) {\n throw new RegistryArtifactIntegrityMismatchError(\n args.moduleId,\n args.version,\n args.expectedDigest,\n observed,\n );\n }\n // A yanked release is served by exact version (#1758) and says so in headers.\n const yankedAt = res.headers.get(REGISTRY_YANKED_AT_HEADER);\n const encodedReason = res.headers.get(REGISTRY_YANK_REASON_HEADER);\n let reason: string | undefined;\n if (encodedReason) {\n try { reason = decodeURIComponent(encodedReason); } catch { reason = encodedReason; }\n }\n return { bytes: buf, integrity: observed, ...(yankedAt ? { yanked: { yankedAt, ...(reason ? { reason } : {}) } } : {}) };\n },\n /**\n * Yank a release (#1758): ranges and `latest` stop selecting it, and `latest` moves to the highest\n * live release; an exact pin still installs it, with a warning. Needs a key holding the version UPDATE\n * role in the domain's owning organization. Returns where `latest` points afterwards.\n */\n async yank(\n options: RegistryServerClientOptions,\n args: { domain: string; moduleId: string; version: string; reason?: string },\n ): Promise<{ latest: string | null }> {\n return changeYankState(options, args, RegistryYankVerb.YANK);\n },\n\n /** Restore a yanked release (#1758); `latest` returns to it when it outranks the current target. */\n async unyank(\n options: RegistryServerClientOptions,\n args: { domain: string; moduleId: string; version: string },\n ): Promise<{ latest: string | null }> {\n return changeYankState(options, args, RegistryYankVerb.UNYANK);\n },\n} as const;\n\nconst RegistryYankResponseSchema = z.object({ ok: z.literal(true), latest: z.string().nullable().optional() });\n\nasync function changeYankState(\n options: RegistryServerClientOptions,\n args: { domain: string; moduleId: string; version: string; reason?: string },\n verb: RegistryYankVerb,\n): Promise<{ latest: string | null }> {\n const url = joinUrl(\n options.baseUrl,\n `/v1/registry/${encodeURIComponent(args.domain)}/modules/${encodeURIComponent(args.moduleId)}/${verb}`,\n );\n const action = `${verb} ${args.moduleId}@${args.version}`;\n const res = await fetchWithTimeout(url, {\n method: 'POST',\n headers: { ...authHeaders(options), 'content-type': 'application/json' },\n body: JSON.stringify({ version: args.version, ...(args.reason !== undefined ? { reason: args.reason } : {}) }),\n timeoutMs: options.timeoutMs,\n diagnosticLabel: DIAGNOSTIC_LABEL,\n });\n if (res.status === 409) {\n // Only the release-state refusal is the no-op; a 409 for anything else (the registry giving up after\n // lost optimistic checks) is a FAILED yank and must not be reported as done (#1758 re-review R3).\n const body = await res.json().catch(() => undefined);\n if (isRegistryReleaseStateConflictBody(body)) throw new RegistryYankStateConflictError(args.moduleId, args.version, verb);\n throw new RegistryUnexpectedStatusError(options.baseUrl, res.status, res.statusText, action);\n }\n // A 404 names the module or the version; the sanitized envelope does not say which.\n await refuseUnlessOk(res, options, action, () => new RegistryVersionNotFoundError(args.moduleId, args.version));\n const parsed = RegistryYankResponseSchema.safeParse(await parseJsonOrThrow(res, options.baseUrl, action, options.timeoutMs));\n if (!parsed.success) {\n throw new RegistryMalformedPayloadError(options.baseUrl, action, formatZodIssuesAsSingleLine(parsed.error));\n }\n return { latest: parsed.data.latest ?? null };\n}\n"]}
1
+ {"version":3,"file":"registry-server-client.js","sourceRoot":"","sources":["../../../../src/services/registry-server-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,sCAAsC,EACtC,0BAA0B,EAC1B,yBAAyB,EACzB,+BAA+B,EAC/B,gCAAgC,EAChC,wBAAwB,EAExB,mBAAmB,EACnB,sBAAsB,EAEtB,wBAAwB,EACxB,eAAe,EACf,kCAAkC,EAClC,6BAA6B,EAC7B,2BAA2B,EAC3B,6BAA6B,EAC7B,4BAA4B,EAC5B,wBAAwB,EACxB,8BAA8B,EAC9B,gBAAgB,EAChB,2BAA2B,EAC3B,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,EACrB,4BAA4B,EAC5B,4BAA4B,GAM7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAErG;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,QAAQ,E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,gBAAgB;KAClC,CAAC,CAAC;IACH,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,qGAAqG;QACrG,kGAAkG;QAClG,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,kCAAkC,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,8BAA8B,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC1H,MAAM,IAAI,6BAA6B,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC/F,CAAC;IACD,oFAAoF;IACpF,MAAM,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,4BAA4B,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAChH,MAAM,MAAM,GAAG,0BAA0B,CAAC,SAAS,CAAC,MAAM,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IAC7H,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,6BAA6B,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,2BAA2B,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9G,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;AAChD,CAAC","sourcesContent":["/**\n * `RegistryServerClient` — HTTP client for the central registry\n * server (`platform-module-registry`, KD-7).\n *\n * Phase 2 fills out the read + download surface (`resolve`,\n * `info`, `search`, `download`). The wire shapes mirror the\n * gateway endpoints documented in the analysis plan's \"Registry\n * HTTP API\" section. The actual server (Phase 3) ships these\n * routes; until it does, the client throws typed errors when it\n * can't reach the server.\n *\n * Auth (KD-11): if `authToken` is supplied, every request adds\n * `Authorization: Bearer <token>`. Public read paths work without\n * a token; restricted paths return 401/403, surfaced as\n * `RegistryAuthRequiredError` (no key sent), `RegistryCredentialRejectedError` (a key sent and refused)\n * or `RegistryAuthForbiddenError`; a 429 is `RegistryRateLimitedError`.\n */\n\nimport { z } from 'zod';\nimport { formatZodIssuesAsSingleLine } from './_zod-issue-formatting';\nimport {\n ModuleManifestSchema,\n ModuleVersionRecordSchema,\n RegistryArtifactIntegrityMismatchError,\n RegistryAuthForbiddenError,\n RegistryAuthRequiredError,\n RegistryCredentialRejectedError,\n RegistryArtifactVisibilitySchema,\n RegistryDomainTakenError,\n RegistryError,\n RegistryRefusalCode,\n hasRegistryRefusalCode,\n type RegistryArtifactVisibility,\n RegistryRateLimitedError,\n isRegistryError,\n isRegistryReleaseStateConflictBody,\n RegistryMalformedPayloadError,\n RegistryModuleNotFoundError,\n RegistryUnexpectedStatusError,\n RegistryVersionNotFoundError,\n RegistryYankNoticeSchema,\n RegistryYankStateConflictError,\n RegistryYankVerb,\n REGISTRY_YANK_REASON_HEADER,\n REGISTRY_YANKED_AT_HEADER,\n Sha256DigestSchema,\n ModuleSearchHitSchema,\n moduleSearchFilterQueryPairs,\n moduleSearchHitMatchesFilter,\n type ModuleManifest,\n type ModuleSearchFilter,\n type ModuleSearchHit,\n type RegistryYankNotice,\n type ModuleVersionRecord,\n} from '@wildo-ai/platform-config-lib';\nimport { fetchJsonOk, fetchTransfer, fetchWithTimeout, joinUrl, readJsonBody } from './_http-client';\n\n/**\n * Zod schema for the `info()` response payload — mirrors\n * `RegistryInfoResult` and is enforced at the client boundary so a\n * server schema drift fails fast instead of returning malformed data\n * to downstream consumers.\n */\nconst RegistryInfoResponseSchema = z.object({\n moduleId: z.string().min(1),\n manifest: ModuleManifestSchema,\n versions: z.array(ModuleVersionRecordSchema),\n tags: z.record(z.string(), z.string()),\n});\n\nconst RegistrySearchResponseSchema = z.object({\n hits: z.array(ModuleSearchHitSchema),\n});\n\nconst DIAGNOSTIC_LABEL = 'Registry';\n\nexport interface RegistryServerClientOptions {\n /** Registry origin (e.g. `https://registry.wildo.ai`). */\n baseUrl: string;\n /** Optional bearer / API-key. CLI credentials are per-machine (KD-11). */\n authToken?: string;\n /** Request timeout in ms. */\n timeoutMs?: number;\n}\n\nfunction authHeaders(options: RegistryServerClientOptions): Record<string, string> {\n return options.authToken ? { Authorization: `Bearer ${options.authToken}` } : {};\n}\n\n/**\n * Throw the typed error for a non-2xx response, after releasing its body (#1763 review: an unread body\n * holds the connection until garbage collection). A 401 is told apart by whether a key was SENT — \"log\n * in\" and \"your key no longer works\" are different remedies (#1759 review).\n */\nasync function refuseUnlessOk(\n res: Response,\n options: RegistryServerClientOptions,\n action: string,\n notFound?: () => RegistryError,\n): Promise<void> {\n if (res.ok) return;\n let error: RegistryError;\n if (res.status === 404 && notFound) error = notFound();\n else if (res.status === 401) error = options.authToken ? new RegistryCredentialRejectedError(options.baseUrl) : new RegistryAuthRequiredError(options.baseUrl);\n else if (res.status === 403) error = new RegistryAuthForbiddenError(action);\n else if (res.status === 429) error = new RegistryRateLimitedError(options.baseUrl, action, parseRetryAfterSeconds(res.headers.get('retry-after')));\n else error = new RegistryUnexpectedStatusError(options.baseUrl, res.status, res.statusText, action);\n await res.body?.cancel().catch(() => undefined);\n throw error;\n}\n\n/** `Retry-After` in its delta-seconds form; the HTTP-date form is not produced by a Wildo backend. */\nfunction parseRetryAfterSeconds(value: string | null): number | undefined {\n if (!value || !/^\\d+$/.test(value.trim())) return undefined;\n return Number(value.trim());\n}\n\n/**\n * 6th-pass M3: typed JSON-parse helper. A misconfigured proxy that\n * returns HTML at 2xx (or a truncated stream) would otherwise throw a\n * bare `SyntaxError` from `await res.json()`, bypassing every\n * `isRegistryError(err)` handler. This helper translates the parse\n * failure into a `RegistryMalformedPayloadError` so the typed-error\n * contract is universal across the client surface.\n */\nasync function parseJsonOrThrow(\n res: Response,\n registryUrl: string,\n action: string,\n timeoutMs: number | undefined,\n): Promise<unknown> {\n try {\n return await readJsonBody(res, registryUrl, action, timeoutMs);\n } catch (err) {\n // A body cut short by the request budget is a timeout (#1763), not a malformed payload.\n if (isRegistryError(err)) throw err;\n throw new RegistryMalformedPayloadError(\n registryUrl,\n action,\n `response is not valid JSON: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n}\n\nexport interface RegistryResolveResult {\n /** Resolved exact version (matches `Sha256DigestSchema` for digest). */\n version: string;\n artifactDigest: string;\n /**\n * Present when the resolved release is yanked. Only an EXACT-version request can resolve to one\n * (#1758) — ranges and tags never do — so the caller is pinned to it and should warn, not refuse.\n */\n yanked?: RegistryYankNotice;\n}\n\nexport interface RegistryInfoResult {\n moduleId: string;\n manifest: ModuleManifest;\n versions: readonly ModuleVersionRecord[];\n /** dist-tag → version map (e.g. `latest → 1.2.3`). */\n tags: Readonly<Record<string, string>>;\n}\n\n/** One search hit: the module, its latest version, and (#2014) its kind and provider facts. */\nexport type RegistrySearchHit = ModuleSearchHit;\n\nexport const RegistryServerClient = {\n /**\n * Liveness probe against `/health`. Returns boolean — used by\n * `wildo registry ping` smoke. The registry server now relies on\n * the framework's auto-mounted `HealthController` at the engine\n * root (`GET /health` always 200; `GET /health/ready` enforces\n * dependency readiness), so the path has NO `/v1` prefix.\n */\n async ping(options: RegistryServerClientOptions): Promise<boolean> {\n try {\n await fetchJsonOk(joinUrl(options.baseUrl, '/health'), {\n method: 'GET',\n timeoutMs: options.timeoutMs,\n diagnosticLabel: DIAGNOSTIC_LABEL,\n });\n return true;\n } catch {\n return false;\n }\n },\n\n /**\n * Resolve a semver range / tag against a registry domain. The\n * server returns the concrete version + artifact digest so the\n * caller can verify the download against `artifactDigest`.\n */\n async resolve(\n options: RegistryServerClientOptions,\n args: { domain: string; moduleId: string; range: string },\n ): Promise<RegistryResolveResult> {\n const url = joinUrl(\n options.baseUrl,\n `/v1/registry/${encodeURIComponent(args.domain)}/modules/${encodeURIComponent(args.moduleId)}/resolve?range=${encodeURIComponent(args.range)}`,\n );\n const res = await fetchWithTimeout(url, {\n method: 'GET',\n headers: authHeaders(options),\n timeoutMs: options.timeoutMs,\n diagnosticLabel: DIAGNOSTIC_LABEL,\n });\n await refuseUnlessOk(res, options, `resolve ${args.moduleId}`, () => new RegistryVersionNotFoundError(args.moduleId, args.range));\n // 6th-pass M3: typed JSON-parse (was bare `SyntaxError` for\n // malformed proxy responses).\n const json = (await parseJsonOrThrow(res, options.baseUrl, `resolve ${args.moduleId}`, options.timeoutMs)) as {\n version?: unknown;\n artifactDigest?: unknown;\n yanked?: unknown;\n };\n const digest = String(json.artifactDigest ?? '');\n // 6th-pass M4: typed digest validation (was bare `ZodError`).\n const digestParse = Sha256DigestSchema.safeParse(digest);\n if (!digestParse.success) {\n throw new RegistryMalformedPayloadError(\n options.baseUrl,\n `resolve ${args.moduleId}`,\n `artifactDigest is not a valid sha256:<64-hex> string: ${formatZodIssuesAsSingleLine(digestParse.error)}`,\n );\n }\n if (typeof json.version !== 'string' || json.version.length === 0) {\n // 3rd-pass M6: typed `RegistryMalformedPayloadError` instead of\n // bare `Error` so callers' `isRegistryError(err)` handlers fire\n // correctly.\n throw new RegistryMalformedPayloadError(\n options.baseUrl,\n `resolve ${args.moduleId}`,\n 'response missing required `version` string',\n );\n }\n let yanked: RegistryYankNotice | undefined;\n if (json.yanked !== undefined) {\n const yankParse = RegistryYankNoticeSchema.safeParse(json.yanked);\n if (!yankParse.success) {\n throw new RegistryMalformedPayloadError(options.baseUrl, `resolve ${args.moduleId}`, `yanked: ${formatZodIssuesAsSingleLine(yankParse.error)}`);\n }\n yanked = yankParse.data;\n }\n return { version: json.version, artifactDigest: digest, ...(yanked ? { yanked } : {}) };\n },\n\n /**\n * Fetch full info for a module: manifest, every published\n * version, dist-tags. Used by `wildo registry info` (Phase 4).\n */\n async info(\n options: RegistryServerClientOptions,\n args: { domain: string; moduleId: string },\n ): Promise<RegistryInfoResult> {\n const url = joinUrl(\n options.baseUrl,\n `/v1/registry/${encodeURIComponent(args.domain)}/modules/${encodeURIComponent(args.moduleId)}`,\n );\n const res = await fetchWithTimeout(url, {\n method: 'GET',\n headers: authHeaders(options),\n timeoutMs: options.timeoutMs,\n diagnosticLabel: DIAGNOSTIC_LABEL,\n });\n await refuseUnlessOk(res, options, `info ${args.moduleId}`, () => new RegistryModuleNotFoundError(args.moduleId));\n // 6th-pass M3: typed JSON-parse.\n const json = await parseJsonOrThrow(res, options.baseUrl, `info ${args.moduleId}`, options.timeoutMs);\n const parsed = RegistryInfoResponseSchema.safeParse(json);\n if (!parsed.success) {\n throw new RegistryMalformedPayloadError(\n options.baseUrl,\n `info ${args.moduleId}`,\n formatZodIssuesAsSingleLine(parsed.error),\n );\n }\n return parsed.data;\n },\n\n /**\n * Search the registry's metadata index: a module-id substring, and (#2014) the manifest filters —\n * kind, engine capability and provider maturity. The server refuses an unknown filter value.\n */\n async search(\n options: RegistryServerClientOptions,\n args: { domain: string; query: string; filter?: ModuleSearchFilter },\n ): Promise<readonly RegistrySearchHit[]> {\n const params = new URLSearchParams([['q', args.query], ...moduleSearchFilterQueryPairs(args.filter ?? {})]);\n const url = joinUrl(\n options.baseUrl,\n `/v1/registry/${encodeURIComponent(args.domain)}/modules?${params.toString()}`,\n );\n const res = await fetchWithTimeout(url, {\n method: 'GET',\n headers: authHeaders(options),\n timeoutMs: options.timeoutMs,\n diagnosticLabel: DIAGNOSTIC_LABEL,\n });\n await refuseUnlessOk(res, options, 'search');\n // 6th-pass M3: typed JSON-parse.\n const json = await parseJsonOrThrow(res, options.baseUrl, 'search', options.timeoutMs);\n const parsed = RegistrySearchResponseSchema.safeParse(json);\n if (!parsed.success) {\n throw new RegistryMalformedPayloadError(\n options.baseUrl,\n 'search',\n formatZodIssuesAsSingleLine(parsed.error),\n );\n }\n // Re-applied here: a server that predates the filters ignores them and answers every module (#2014 review F9).\n return parsed.data.hits.filter((hit) => moduleSearchHitMatchesFilter(hit, args.filter ?? {}));\n },\n\n /**\n * Stream-download a published artifact's bytes and verify the\n * sha256 integrity matches `expectedDigest`. Throws\n * `RegistryArtifactIntegrityMismatchError` on mismatch — the\n * digest check is non-negotiable per KD-9 / Security model.\n */\n async download(\n options: RegistryServerClientOptions,\n args: {\n domain: string;\n moduleId: string;\n version: string;\n expectedDigest: string;\n },\n ): Promise<{ bytes: Uint8Array; integrity: string; yanked?: RegistryYankNotice }> {\n // 7th-pass C-M1: caller-supplied digest is a developer-contract\n // violation if malformed, not a registry-runtime condition.\n // Throw `TypeError` (matching `C-L3` precedent for\n // `getModuleStagingPaths` argument-shape violations) so the\n // typed `RegistryError` vocabulary stays reserved for\n // registry-runtime errors. Prior `Sha256DigestSchema.parse(...)`\n // leaked a bare `ZodError` that bypassed\n // `isRegistryError(err)` handlers but ALSO confused\n // typed-handler maintainers about the contract.\n const digestParse = Sha256DigestSchema.safeParse(args.expectedDigest);\n if (!digestParse.success) {\n throw new TypeError(\n `download() expectedDigest must be a valid sha256:<64-hex> string (got: ${JSON.stringify(args.expectedDigest)}). ${formatZodIssuesAsSingleLine(digestParse.error)}`,\n );\n }\n const url = joinUrl(\n options.baseUrl,\n `/v1/registry/${encodeURIComponent(args.domain)}/modules/${encodeURIComponent(args.moduleId)}/${encodeURIComponent(args.version)}/artifact`,\n );\n // A transfer, not a metadata call: the response is bounded by `timeoutMs`, the body by an IDLE budget\n // reset on every chunk, so a large artifact over a slow link installs and a stalled one fails (#1763).\n const { response: res, readAll } = await fetchTransfer(url, {\n method: 'GET',\n headers: authHeaders(options),\n timeoutMs: options.timeoutMs,\n diagnosticLabel: DIAGNOSTIC_LABEL,\n });\n await refuseUnlessOk(res, options, `download ${args.moduleId}@${args.version}`, () => new RegistryVersionNotFoundError(args.moduleId, args.version));\n const buf = await readAll();\n const { createHash } = await import('node:crypto');\n const observed = `sha256:${createHash('sha256').update(buf).digest('hex')}`;\n if (observed !== args.expectedDigest) {\n throw new RegistryArtifactIntegrityMismatchError(\n args.moduleId,\n args.version,\n args.expectedDigest,\n observed,\n );\n }\n // A yanked release is served by exact version (#1758) and says so in headers.\n const yankedAt = res.headers.get(REGISTRY_YANKED_AT_HEADER);\n const encodedReason = res.headers.get(REGISTRY_YANK_REASON_HEADER);\n let reason: string | undefined;\n if (encodedReason) {\n try { reason = decodeURIComponent(encodedReason); } catch { reason = encodedReason; }\n }\n return { bytes: buf, integrity: observed, ...(yankedAt ? { yanked: { yankedAt, ...(reason ? { reason } : {}) } } : {}) };\n },\n /**\n * Yank a release (#1758): ranges and `latest` stop selecting it, and `latest` moves to the highest\n * live release; an exact pin still installs it, with a warning. Needs a key holding the version UPDATE\n * role in the domain's owning organization. Returns where `latest` points afterwards.\n */\n async yank(\n options: RegistryServerClientOptions,\n args: { domain: string; moduleId: string; version: string; reason?: string },\n ): Promise<{ latest: string | null }> {\n return changeYankState(options, args, RegistryYankVerb.YANK);\n },\n\n /** Restore a yanked release (#1758); `latest` returns to it when it outranks the current target. */\n async unyank(\n options: RegistryServerClientOptions,\n args: { domain: string; moduleId: string; version: string },\n ): Promise<{ latest: string | null }> {\n return changeYankState(options, args, RegistryYankVerb.UNYANK);\n },\n\n /**\n * Register a domain for the key's organization (#2024). Domains are first come, first served, and every module\n * published into one inherits its `defaultVisibility`. A slug already registered throws `RegistryDomainTakenError`\n * whoever holds it; `listMyDomains` tells whether that is the caller's own organization.\n */\n async createDomain(\n options: RegistryServerClientOptions,\n args: { domain: string; defaultVisibility: RegistryArtifactVisibility },\n ): Promise<RegistryDomainRecord> {\n const url = joinUrl(options.baseUrl, '/v1/registry/domains');\n const action = `create domain ${args.domain}`;\n const res = await fetchWithTimeout(url, {\n method: 'POST',\n headers: { ...authHeaders(options), 'content-type': 'application/json' },\n body: JSON.stringify({ domain: args.domain, defaultVisibility: args.defaultVisibility }),\n timeoutMs: options.timeoutMs,\n diagnosticLabel: DIAGNOSTIC_LABEL,\n });\n if (res.status === 409) {\n // Only the registry's own code means \"the slug is registered\"; a bare 409 is shared by other refusals.\n const body = await res.json().catch(() => undefined);\n if (hasRegistryRefusalCode(body, RegistryRefusalCode.DOMAIN_TAKEN)) throw new RegistryDomainTakenError(args.domain);\n throw new RegistryUnexpectedStatusError(options.baseUrl, res.status, res.statusText, action);\n }\n await refuseUnlessOk(res, options, action);\n const parsed = RegistryCreateDomainResponseSchema.safeParse(await parseJsonOrThrow(res, options.baseUrl, action, options.timeoutMs));\n if (!parsed.success) throw new RegistryMalformedPayloadError(options.baseUrl, action, formatZodIssuesAsSingleLine(parsed.error));\n return parsed.data.domain;\n },\n\n /** The domains the key's organization owns (#2024). Needs a key holding the domain LIST role. */\n async listMyDomains(options: RegistryServerClientOptions): Promise<RegistryDomainRecord[]> {\n const url = joinUrl(options.baseUrl, '/v1/registry/my-domains');\n const action = 'list domains';\n const res = await fetchWithTimeout(url, { method: 'GET', headers: authHeaders(options), timeoutMs: options.timeoutMs, diagnosticLabel: DIAGNOSTIC_LABEL });\n await refuseUnlessOk(res, options, action);\n const parsed = RegistryListDomainsResponseSchema.safeParse(await parseJsonOrThrow(res, options.baseUrl, action, options.timeoutMs));\n if (!parsed.success) throw new RegistryMalformedPayloadError(options.baseUrl, action, formatZodIssuesAsSingleLine(parsed.error));\n return parsed.data.domains;\n },\n} as const;\n\n/** A registry domain as the registry answers it: the slug and the visibility its modules inherit. */\nconst RegistryDomainRecordSchema = z.object({ domain: z.string().min(1), defaultVisibility: RegistryArtifactVisibilitySchema });\nexport type RegistryDomainRecord = z.infer<typeof RegistryDomainRecordSchema>;\nconst RegistryCreateDomainResponseSchema = z.object({ domain: RegistryDomainRecordSchema });\nconst RegistryListDomainsResponseSchema = z.object({ domains: z.array(RegistryDomainRecordSchema) });\n\nconst RegistryYankResponseSchema = z.object({ ok: z.literal(true), latest: z.string().nullable().optional() });\n\nasync function changeYankState(\n options: RegistryServerClientOptions,\n args: { domain: string; moduleId: string; version: string; reason?: string },\n verb: RegistryYankVerb,\n): Promise<{ latest: string | null }> {\n const url = joinUrl(\n options.baseUrl,\n `/v1/registry/${encodeURIComponent(args.domain)}/modules/${encodeURIComponent(args.moduleId)}/${verb}`,\n );\n const action = `${verb} ${args.moduleId}@${args.version}`;\n const res = await fetchWithTimeout(url, {\n method: 'POST',\n headers: { ...authHeaders(options), 'content-type': 'application/json' },\n body: JSON.stringify({ version: args.version, ...(args.reason !== undefined ? { reason: args.reason } : {}) }),\n timeoutMs: options.timeoutMs,\n diagnosticLabel: DIAGNOSTIC_LABEL,\n });\n if (res.status === 409) {\n // Only the release-state refusal is the no-op; a 409 for anything else (the registry giving up after\n // lost optimistic checks) is a FAILED yank and must not be reported as done (#1758 re-review R3).\n const body = await res.json().catch(() => undefined);\n if (isRegistryReleaseStateConflictBody(body)) throw new RegistryYankStateConflictError(args.moduleId, args.version, verb);\n throw new RegistryUnexpectedStatusError(options.baseUrl, res.status, res.statusText, action);\n }\n // A 404 names the module or the version; the sanitized envelope does not say which.\n await refuseUnlessOk(res, options, action, () => new RegistryVersionNotFoundError(args.moduleId, args.version));\n const parsed = RegistryYankResponseSchema.safeParse(await parseJsonOrThrow(res, options.baseUrl, action, options.timeoutMs));\n if (!parsed.success) {\n throw new RegistryMalformedPayloadError(options.baseUrl, action, formatZodIssuesAsSingleLine(parsed.error));\n }\n return { latest: parsed.data.latest ?? null };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildo-ai/wildo-module-client",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "description": "Module-registry runtime services consumed by wildo-cli and the dev companion (Phase 0.5 skeleton)",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Wildo AI",
@@ -30,7 +30,7 @@
30
30
  "test:watch": "vitest"
31
31
  },
32
32
  "dependencies": {
33
- "@wildo-ai/platform-config-lib": "1.1.10"
33
+ "@wildo-ai/platform-config-lib": "1.1.11"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "^24.0.15",
@@ -51,14 +51,14 @@ const validEntry = (overrides: Record<string, unknown> = {}) => ({
51
51
 
52
52
  describe('LockfileRepairService.inspect', () => {
53
53
  it('returns ok+empty when the lockfile does not exist', async () => {
54
- const report = await LockfileRepairService.inspect(saasRoot);
54
+ const report = await LockfileRepairService.inspect(saasRoot, { workspaceBuildPolicy: {} });
55
55
  expect(report.ok).toBe(true);
56
56
  expect(report.findings).toEqual([]);
57
57
  });
58
58
 
59
59
  it('reports envelope-malformed on top-level Zod failure', async () => {
60
60
  await writeEnvelope({ schemaVersion: 1, generatedAt: '2026', sections: {} });
61
- const report = await LockfileRepairService.inspect(saasRoot);
61
+ const report = await LockfileRepairService.inspect(saasRoot, { workspaceBuildPolicy: {} });
62
62
  expect(report.ok).toBe(false);
63
63
  expect(report.findings[0].kind).toBe('envelope-malformed');
64
64
  });
@@ -69,7 +69,7 @@ describe('LockfileRepairService.inspect', () => {
69
69
  generatedAt: '2026-05-05T12:00:00.000Z',
70
70
  sections: { modules: { installed: 'not-an-object' } },
71
71
  });
72
- const report = await LockfileRepairService.inspect(saasRoot);
72
+ const report = await LockfileRepairService.inspect(saasRoot, { workspaceBuildPolicy: {} });
73
73
  expect(report.ok).toBe(false);
74
74
  expect(report.findings[0].kind).toBe('modules-section-malformed');
75
75
  });
@@ -80,7 +80,7 @@ describe('LockfileRepairService.inspect', () => {
80
80
  generatedAt: '2026-05-05T12:00:00.000Z',
81
81
  sections: { modules: { installed: { 'acme/billing': validEntry() } } },
82
82
  });
83
- const report = await LockfileRepairService.inspect(saasRoot);
83
+ const report = await LockfileRepairService.inspect(saasRoot, { workspaceBuildPolicy: {} });
84
84
  expect(report.ok).toBe(true); // warnings only
85
85
  expect(report.findings).toHaveLength(1);
86
86
  expect(report.findings[0]).toMatchObject({
@@ -100,7 +100,7 @@ describe('LockfileRepairService.inspect', () => {
100
100
  generatedAt: '2026-05-05T12:00:00.000Z',
101
101
  sections: { modules: { installed: { 'acme/billing': validEntry() } } },
102
102
  });
103
- const report = await LockfileRepairService.inspect(saasRoot);
103
+ const report = await LockfileRepairService.inspect(saasRoot, { workspaceBuildPolicy: {} });
104
104
  expect(report.findings).toEqual([]);
105
105
  });
106
106
  });
@@ -105,8 +105,9 @@ describe('RegistryLockfileService', () => {
105
105
  expect(after.sections.i18n).toEqual(original.sections.i18n);
106
106
  expect(after.sections.future).toEqual(original.sections.future);
107
107
  expect(after.sections.modules.installed['acme/billing'].version).toBe('2.0.0');
108
- // generatedAt MUST be refreshed.
109
- expect(after.generatedAt).not.toBe(original.generatedAt);
108
+ // The fixture was written with the retired `generatedAt`; the write drops it rather than refresh it
109
+ // (#1765: the envelope carries no timestamp).
110
+ expect(after).not.toHaveProperty('generatedAt');
110
111
  });
111
112
 
112
113
  it('rejects an invalid module entry with a Zod parse error and never writes the section', async () => {
@@ -15,7 +15,9 @@ import {
15
15
  RegistryAuthForbiddenError,
16
16
  RegistryAuthRequiredError,
17
17
  RegistryCredentialRejectedError,
18
+ RegistryDomainTakenError,
18
19
  RegistryMalformedPayloadError,
20
+ RegistryRefusalCode,
19
21
  RegistryModuleNotFoundError,
20
22
  RegistryRateLimitedError,
21
23
  RegistryUnexpectedStatusError,
@@ -439,3 +441,45 @@ describe('RegistryServerClient.yank / unyank (#1758)', () => {
439
441
  }
440
442
  });
441
443
  });
444
+
445
+ describe('RegistryServerClient domains (#2024)', () => {
446
+ const conflict = (code?: string) => JSON.stringify({ error: { type: 'CONFLICT', customMessageReference: 'conflict', ...(code ? { details: { code } } : {}) } });
447
+
448
+ it('creates a domain with the visibility asked for, under the key, and returns the registry\'s record', async () => {
449
+ let seen: { url?: string; method?: string; body?: unknown; auth?: string } = {};
450
+ svc = await startServer(async (req, res) => {
451
+ let raw = '';
452
+ for await (const chunk of req) raw += chunk;
453
+ seen = { url: req.url, method: req.method, body: JSON.parse(raw), auth: req.headers.authorization };
454
+ res.writeHead(201, { 'content-type': 'application/json' });
455
+ res.end(JSON.stringify({ domain: { _id: 'd1', domain: 'wildo', defaultVisibility: 'PUBLIC', ownerOrganizationId: 'o1' } }));
456
+ });
457
+ const created = await RegistryServerClient.createDomain({ baseUrl: svc.baseUrl, authToken: 'sk_org_k' }, { domain: 'wildo', defaultVisibility: 'PUBLIC' });
458
+ expect(created).toEqual({ domain: 'wildo', defaultVisibility: 'PUBLIC' });
459
+ expect(seen).toEqual({ url: '/v1/registry/domains', method: 'POST', body: { domain: 'wildo', defaultVisibility: 'PUBLIC' }, auth: 'Bearer sk_org_k' });
460
+ });
461
+
462
+ it('types a registered slug as taken only on the registry\'s own code; any other 409 is unexpected', async () => {
463
+ for (const [body, expected] of [[conflict(RegistryRefusalCode.DOMAIN_TAKEN), RegistryDomainTakenError], [conflict(), RegistryUnexpectedStatusError], ['', RegistryUnexpectedStatusError]] as const) {
464
+ svc = await startServer((_req, res) => {
465
+ res.writeHead(409, { 'content-type': 'application/json' });
466
+ res.end(body);
467
+ });
468
+ const error = await RegistryServerClient.createDomain({ baseUrl: svc.baseUrl, authToken: 'k' }, { domain: 'wildo', defaultVisibility: 'PUBLIC' }).catch((err: unknown) => err);
469
+ expect(error, body).toBeInstanceOf(expected);
470
+ await svc.close();
471
+ svc = null;
472
+ }
473
+ });
474
+
475
+ it('lists the key organization\'s domains', async () => {
476
+ let path: string | undefined;
477
+ svc = await startServer((req, res) => {
478
+ path = req.url;
479
+ res.writeHead(200, { 'content-type': 'application/json' });
480
+ res.end(JSON.stringify({ domains: [{ domain: 'wildo', defaultVisibility: 'RESTRICTED', ownerOrganizationId: 'o1' }] }));
481
+ });
482
+ expect(await RegistryServerClient.listMyDomains({ baseUrl: svc.baseUrl, authToken: 'k' })).toEqual([{ domain: 'wildo', defaultVisibility: 'RESTRICTED' }]);
483
+ expect(path).toBe('/v1/registry/my-domains');
484
+ });
485
+ });
@@ -20,21 +20,60 @@ import * as path from 'node:path';
20
20
  import { z } from 'zod';
21
21
  import { formatZodIssuesAsSingleLine } from './_zod-issue-formatting';
22
22
  import {
23
+ PROVIDER_VENDOR_PINS_MANIFEST,
23
24
  RegistryModulesLockSectionSchema,
24
25
  getWildoSaasLockPath,
26
+ withoutRetiredLockfileEnvelopeKeys,
25
27
  type RegistryModulesLockEntry,
26
28
  type RegistryModulesLockSection,
27
29
  } from '@wildo-ai/platform-config-lib';
28
30
 
31
+ /**
32
+ * Why a provider module's install-script name cannot simply be written back into the application's root
33
+ * `package.json` → `pnpm.onlyBuiltDependencies` (#2809). Each is the application's own policy, which the install
34
+ * (#2801) also refuses to override, and pnpm 10.6.4 reads it as follows (measured in #2801):
35
+ */
36
+ export enum ApplicationInstallScriptPolicy {
37
+ /** The allow-list lives in `pnpm-workspace.yaml`, and a list in `package.json` would REPLACE it. */
38
+ WORKSPACE_ALLOW_LIST = 'workspace-allow-list',
39
+ /** A `neverBuiltDependencies` list names the package, and pnpm refuses to install with both lists. */
40
+ NEVER_BUILT_LIST = 'never-built-list',
41
+ /**
42
+ * The application declares an allow-list AND a `neverBuiltDependencies` list (in either file): pnpm 10.6.4 refuses to
43
+ * install at all (`ERR_PNPM_CONFIG_CONFLICT_BUILT_DEPENDENCIES`, measured in #2809's review), so writing a name changes
44
+ * nothing until the application keeps one of them.
45
+ */
46
+ CONFLICTING_LISTS = 'conflicting-lists',
47
+ }
48
+
49
+ /**
50
+ * The install-script policy `pnpm-workspace.yaml` declares, each list `undefined` when the file does not declare it.
51
+ * Supplied by the caller, which owns the YAML reading (`wildo-cli`'s `readWorkspaceBuildPolicy`, the reader the install
52
+ * uses), so the inspector and the install judge one policy the same way.
53
+ */
54
+ export interface WorkspaceBuildPolicy {
55
+ onlyBuiltDependencies?: readonly string[];
56
+ neverBuiltDependencies?: readonly string[];
57
+ }
58
+
59
+ export interface LockfileRepairInspectOptions {
60
+ /**
61
+ * Required rather than defaulted: without it, a name missing from `package.json` could look restorable when the
62
+ * application keeps its list in `pnpm-workspace.yaml`, and `--fix` would then replace that list.
63
+ */
64
+ workspaceBuildPolicy: WorkspaceBuildPolicy;
65
+ }
66
+
29
67
  /**
30
68
  * Permissive envelope schema used by repair only — it accepts any
31
69
  * `sections.*` payload without delegating to per-section schemas
32
70
  * so the repair flow can isolate "envelope is malformed" from
33
- * "envelope is fine but modules section is malformed".
71
+ * "envelope is fine but modules section is malformed". Applied after
72
+ * `withoutRetiredLockfileEnvelopeKeys`, like every lockfile reader, so a
73
+ * file written before the envelope lost its `generatedAt` still parses.
34
74
  */
35
75
  const RelaxedEnvelopeSchema = z.strictObject({
36
76
  schemaVersion: z.literal(2),
37
- generatedAt: z.iso.datetime({ offset: true }),
38
77
  sections: z.record(z.string(), z.unknown()),
39
78
  });
40
79
 
@@ -56,6 +95,41 @@ export type LockfileRepairFinding =
56
95
  kind: 'module-file-missing';
57
96
  moduleId: string;
58
97
  filePath: string;
98
+ }
99
+ | {
100
+ /** A vendor pin the module's recorded wiring wrote (#2789) is gone from the root `pnpm.overrides`: restorable. */
101
+ severity: 'warn';
102
+ kind: 'vendor-pin-missing';
103
+ moduleId: string;
104
+ name: string;
105
+ version: string;
106
+ }
107
+ | {
108
+ /** A recorded vendor pin the application moved since install: its decision, reported and never overwritten. */
109
+ severity: 'warn';
110
+ kind: 'vendor-pin-moved';
111
+ moduleId: string;
112
+ name: string;
113
+ version: string;
114
+ found: string;
115
+ }
116
+ | {
117
+ /**
118
+ * An install-script name the module's recorded wiring wrote (#2801), not held by the application, that the
119
+ * application's allow-list no longer carries: restorable into `package.json` → `pnpm.onlyBuiltDependencies`.
120
+ */
121
+ severity: 'warn';
122
+ kind: 'only-built-missing';
123
+ moduleId: string;
124
+ name: string;
125
+ }
126
+ | {
127
+ /** A recorded install-script name the application's own policy does not allow, and `--fix` must not write: reported only. */
128
+ severity: 'warn';
129
+ kind: 'only-built-blocked';
130
+ moduleId: string;
131
+ name: string;
132
+ policy: ApplicationInstallScriptPolicy;
59
133
  };
60
134
 
61
135
  export interface LockfileRepairReport {
@@ -75,6 +149,79 @@ async function fileExists(absPath: string): Promise<boolean> {
75
149
  }
76
150
  }
77
151
 
152
+ /** The `pnpm` section of the application's root manifest, `{}` when the manifest is absent or not JSON (nothing to compare). */
153
+ async function readRootPnpmSection(saasRoot: string): Promise<{ overrides?: unknown; onlyBuiltDependencies?: unknown; neverBuiltDependencies?: unknown }> {
154
+ try {
155
+ const section = (JSON.parse(await fs.readFile(path.join(saasRoot, PROVIDER_VENDOR_PINS_MANIFEST), 'utf8')) as { pnpm?: unknown }).pnpm;
156
+ return section !== null && typeof section === 'object' && !Array.isArray(section) ? section : {};
157
+ } catch {
158
+ return {};
159
+ }
160
+ }
161
+
162
+ function asRecord(value: unknown): Record<string, unknown> {
163
+ return value !== null && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {};
164
+ }
165
+
166
+ function asNames(value: unknown): string[] | undefined {
167
+ return Array.isArray(value) ? value.filter((name): name is string => typeof name === 'string') : undefined;
168
+ }
169
+
170
+ /**
171
+ * Each install-script name a provider module's recorded wiring WROTE (#2801; a held name is the application's own), judged
172
+ * as pnpm 10.6.4 will judge it, with the same precedence the install uses (`onlyBuiltStates` in `wildo-cli`):
173
+ * - an allow-list AND a `neverBuiltDependencies` list, in either file → pnpm installs nothing, so a name the allow-list
174
+ * lacks is blocked by `CONFLICTING_LISTS` and never written;
175
+ * - `package.json` carries an allow-list → it is the one pnpm reads (it replaces a workspace list), so a name it lacks is
176
+ * `only-built-missing`, restorable there;
177
+ * - otherwise a `pnpm-workspace.yaml` allow-list → a name it lacks is blocked by `WORKSPACE_ALLOW_LIST`;
178
+ * - otherwise a `neverBuiltDependencies` list (`package.json` first, as the install reads it) → a name it lists is blocked
179
+ * by `NEVER_BUILT_LIST`; any other name's script runs, so nothing is reported;
180
+ * - otherwise no policy at all → pnpm runs no script, and the name is `only-built-missing`: restoring it writes the list
181
+ * the install wrote.
182
+ */
183
+ function collectOnlyBuiltFindings(
184
+ moduleId: string,
185
+ entry: RegistryModulesLockEntry,
186
+ pnpmSection: { onlyBuiltDependencies?: unknown; neverBuiltDependencies?: unknown },
187
+ workspace: WorkspaceBuildPolicy,
188
+ findings: LockfileRepairFinding[],
189
+ ): void {
190
+ const wiring = entry.registration?.providerWiring;
191
+ const held = new Set(wiring?.heldOnlyBuiltDependencies ?? []);
192
+ const wrote = (wiring?.onlyBuiltDependencies ?? []).filter((name) => !held.has(name));
193
+ if (wrote.length === 0) return;
194
+ const manifestList = asNames(pnpmSection.onlyBuiltDependencies);
195
+ const never = asNames(pnpmSection.neverBuiltDependencies) ?? workspace.neverBuiltDependencies;
196
+ const allowList = manifestList ?? workspace.onlyBuiltDependencies;
197
+ for (const name of wrote) {
198
+ if (allowList !== undefined && never !== undefined) {
199
+ if (!allowList.includes(name)) findings.push({ severity: 'warn', kind: 'only-built-blocked', moduleId, name, policy: ApplicationInstallScriptPolicy.CONFLICTING_LISTS });
200
+ } else if (manifestList !== undefined) {
201
+ if (!manifestList.includes(name)) findings.push({ severity: 'warn', kind: 'only-built-missing', moduleId, name });
202
+ } else if (workspace.onlyBuiltDependencies !== undefined) {
203
+ if (!workspace.onlyBuiltDependencies.includes(name)) {
204
+ findings.push({ severity: 'warn', kind: 'only-built-blocked', moduleId, name, policy: ApplicationInstallScriptPolicy.WORKSPACE_ALLOW_LIST });
205
+ }
206
+ } else if (never !== undefined) {
207
+ if (never.includes(name)) findings.push({ severity: 'warn', kind: 'only-built-blocked', moduleId, name, policy: ApplicationInstallScriptPolicy.NEVER_BUILT_LIST });
208
+ } else {
209
+ findings.push({ severity: 'warn', kind: 'only-built-missing', moduleId, name });
210
+ }
211
+ }
212
+ }
213
+
214
+ /**
215
+ * Each vendor pin a provider module's recorded wiring wrote (#2789), against the root overrides: missing (restorable by
216
+ * `--fix`), or moved by the application (reported only: a pin the application set is its own).
217
+ */
218
+ function collectVendorPinFindings(moduleId: string, entry: RegistryModulesLockEntry, overrides: Record<string, unknown>, findings: LockfileRepairFinding[]): void {
219
+ for (const [name, version] of Object.entries(entry.registration?.providerWiring?.vendorPins ?? {})) {
220
+ if (!Object.hasOwn(overrides, name)) findings.push({ severity: 'warn', kind: 'vendor-pin-missing', moduleId, name, version });
221
+ else if (overrides[name] !== version) findings.push({ severity: 'warn', kind: 'vendor-pin-moved', moduleId, name, version, found: String(overrides[name]) });
222
+ }
223
+ }
224
+
78
225
  export const LockfileRepairService = {
79
226
  /** Compute the lockfile path for a saas root. */
80
227
  pathFor(saasRoot: string): string {
@@ -84,7 +231,7 @@ export const LockfileRepairService = {
84
231
  /**
85
232
  * Read the envelope + run every diagnostic. Read-only.
86
233
  */
87
- async inspect(saasRoot: string): Promise<LockfileRepairReport> {
234
+ async inspect(saasRoot: string, options: LockfileRepairInspectOptions): Promise<LockfileRepairReport> {
88
235
  const lockfilePath = getWildoSaasLockPath(saasRoot);
89
236
  const findings: LockfileRepairFinding[] = [];
90
237
 
@@ -124,7 +271,7 @@ export const LockfileRepairService = {
124
271
  return { lockfilePath, ok: false, findings };
125
272
  }
126
273
 
127
- const envelopeParsed = RelaxedEnvelopeSchema.safeParse(parsedJson);
274
+ const envelopeParsed = RelaxedEnvelopeSchema.safeParse(withoutRetiredLockfileEnvelopeKeys(parsedJson));
128
275
  if (!envelopeParsed.success) {
129
276
  findings.push({
130
277
  severity: 'error',
@@ -154,8 +301,12 @@ export const LockfileRepairService = {
154
301
  }
155
302
  const modules: RegistryModulesLockSection = parsed.data;
156
303
 
304
+ const pnpmSection = await readRootPnpmSection(saasRoot);
305
+ const rootOverrides = asRecord(pnpmSection.overrides);
157
306
  for (const [moduleId, entry] of Object.entries(modules.installed)) {
158
307
  await this.collectEntryFindings(saasRoot, moduleId, entry, findings);
308
+ collectVendorPinFindings(moduleId, entry, rootOverrides, findings);
309
+ collectOnlyBuiltFindings(moduleId, entry, pnpmSection, options.workspaceBuildPolicy, findings);
159
310
  }
160
311
 
161
312
  const ok = findings.every((f) => f.severity !== 'error');
@@ -25,7 +25,12 @@ import {
25
25
  RegistryAuthForbiddenError,
26
26
  RegistryAuthRequiredError,
27
27
  RegistryCredentialRejectedError,
28
+ RegistryArtifactVisibilitySchema,
29
+ RegistryDomainTakenError,
28
30
  RegistryError,
31
+ RegistryRefusalCode,
32
+ hasRegistryRefusalCode,
33
+ type RegistryArtifactVisibility,
29
34
  RegistryRateLimitedError,
30
35
  isRegistryError,
31
36
  isRegistryReleaseStateConflictBody,
@@ -386,8 +391,55 @@ export const RegistryServerClient = {
386
391
  ): Promise<{ latest: string | null }> {
387
392
  return changeYankState(options, args, RegistryYankVerb.UNYANK);
388
393
  },
394
+
395
+ /**
396
+ * Register a domain for the key's organization (#2024). Domains are first come, first served, and every module
397
+ * published into one inherits its `defaultVisibility`. A slug already registered throws `RegistryDomainTakenError`
398
+ * whoever holds it; `listMyDomains` tells whether that is the caller's own organization.
399
+ */
400
+ async createDomain(
401
+ options: RegistryServerClientOptions,
402
+ args: { domain: string; defaultVisibility: RegistryArtifactVisibility },
403
+ ): Promise<RegistryDomainRecord> {
404
+ const url = joinUrl(options.baseUrl, '/v1/registry/domains');
405
+ const action = `create domain ${args.domain}`;
406
+ const res = await fetchWithTimeout(url, {
407
+ method: 'POST',
408
+ headers: { ...authHeaders(options), 'content-type': 'application/json' },
409
+ body: JSON.stringify({ domain: args.domain, defaultVisibility: args.defaultVisibility }),
410
+ timeoutMs: options.timeoutMs,
411
+ diagnosticLabel: DIAGNOSTIC_LABEL,
412
+ });
413
+ if (res.status === 409) {
414
+ // Only the registry's own code means "the slug is registered"; a bare 409 is shared by other refusals.
415
+ const body = await res.json().catch(() => undefined);
416
+ if (hasRegistryRefusalCode(body, RegistryRefusalCode.DOMAIN_TAKEN)) throw new RegistryDomainTakenError(args.domain);
417
+ throw new RegistryUnexpectedStatusError(options.baseUrl, res.status, res.statusText, action);
418
+ }
419
+ await refuseUnlessOk(res, options, action);
420
+ const parsed = RegistryCreateDomainResponseSchema.safeParse(await parseJsonOrThrow(res, options.baseUrl, action, options.timeoutMs));
421
+ if (!parsed.success) throw new RegistryMalformedPayloadError(options.baseUrl, action, formatZodIssuesAsSingleLine(parsed.error));
422
+ return parsed.data.domain;
423
+ },
424
+
425
+ /** The domains the key's organization owns (#2024). Needs a key holding the domain LIST role. */
426
+ async listMyDomains(options: RegistryServerClientOptions): Promise<RegistryDomainRecord[]> {
427
+ const url = joinUrl(options.baseUrl, '/v1/registry/my-domains');
428
+ const action = 'list domains';
429
+ const res = await fetchWithTimeout(url, { method: 'GET', headers: authHeaders(options), timeoutMs: options.timeoutMs, diagnosticLabel: DIAGNOSTIC_LABEL });
430
+ await refuseUnlessOk(res, options, action);
431
+ const parsed = RegistryListDomainsResponseSchema.safeParse(await parseJsonOrThrow(res, options.baseUrl, action, options.timeoutMs));
432
+ if (!parsed.success) throw new RegistryMalformedPayloadError(options.baseUrl, action, formatZodIssuesAsSingleLine(parsed.error));
433
+ return parsed.data.domains;
434
+ },
389
435
  } as const;
390
436
 
437
+ /** A registry domain as the registry answers it: the slug and the visibility its modules inherit. */
438
+ const RegistryDomainRecordSchema = z.object({ domain: z.string().min(1), defaultVisibility: RegistryArtifactVisibilitySchema });
439
+ export type RegistryDomainRecord = z.infer<typeof RegistryDomainRecordSchema>;
440
+ const RegistryCreateDomainResponseSchema = z.object({ domain: RegistryDomainRecordSchema });
441
+ const RegistryListDomainsResponseSchema = z.object({ domains: z.array(RegistryDomainRecordSchema) });
442
+
391
443
  const RegistryYankResponseSchema = z.object({ ok: z.literal(true), latest: z.string().nullable().optional() });
392
444
 
393
445
  async function changeYankState(