Lines 72-112javascript
72 * ADR-0054 M4-G: the `policy` is `{ source: 'bundled' }` for a HOST import or the
73 * `inDispatchWorker` worker policy for an external import inside the dispatch
74 * worker. A bare external source can no longer be expressed (the type forbids it);
75 * the runtime check is defense-in-depth.
77 * Never throws: returns a discriminated result the caller acts on.
79export async function importToolRuntime(dir, policy) {
80 if (!isAuthorizedImportPolicy(policy)) {
83 reason: 'import-failed',
84 detail: 'external tool runtime import attempted without a bundled or worker policy; ' +
85 'load through the worker boundary instead (ADR-0054 M4-G capstone)',
88 const meta = readToolPackageMetadata(dir);
90 return { ok: false, reason: 'no-entry' };
93 mod = (await import(pathToFileURL(meta.mainEntry).href));
94 }
MediumDynamic Require
Package source references dynamic require/import behavior.
dist/bootstrap/admit-tool-package.jsView on unpkg · L92 98 reason: 'import-failed',
99 detail: error instanceof Error ? error.message : String(error),
102 if (!isValidTool(mod.tool)) {
105 reason: 'invalid-shape',
106 detail: toolValidationFailure(mod.tool) ?? 'tool export failed shape validation',
109 return { ok: true, tool: mod.tool };
112 * Run the admission pipeline over one package dir and report per-section