halfcode-compiler.xnl 0.2.3 → 0.2.4

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,2 +1,2 @@
1
- import { a as assertObjectOperationCatalog, c as resolveApplicationAssembly, i as assertObjectOperationCall, l as resourceRefToFqn, n as applicationAssemblyPackage, o as assertObjectOperationDefinition, r as assertExecuteObjectOperationRequest, s as loadApplicationAssembly, t as ObjectOperationContractError } from "./src-DRIws6tY.js";
1
+ import { a as assertObjectOperationCatalog, c as resolveApplicationAssembly, i as assertObjectOperationCall, l as resourceRefToFqn, n as applicationAssemblyPackage, o as assertObjectOperationDefinition, r as assertExecuteObjectOperationRequest, s as loadApplicationAssembly, t as ObjectOperationContractError } from "./src-6nezdi57.js";
2
2
  export { ObjectOperationContractError, applicationAssemblyPackage, assertExecuteObjectOperationRequest, assertObjectOperationCall, assertObjectOperationCatalog, assertObjectOperationDefinition, loadApplicationAssembly, resolveApplicationAssembly, resourceRefToFqn };
@@ -1,5 +1,5 @@
1
1
  import { t as ApplicationAssembly } from "./index-Cqh9pEBa.js";
2
- import { t as ResourceRegistry } from "./index-D2mpux6L.js";
2
+ import { t as ResourceRegistry } from "./index-DjvNDidT.js";
3
3
  //#region ../compiler-skill/src/index.d.ts
4
4
  interface SkillDescriptor {
5
5
  name: string;
@@ -103,8 +103,38 @@ declare function sha256Digest(value: string | Uint8Array): Sha256Digest;
103
103
  declare function createResourceContentIdentity(input: CreateResourceContentIdentityInput): ResourceContentIdentity;
104
104
  declare function buildResourceDependencySnapshot(input: BuildResourceDependencySnapshotInput): ResourceDependencySnapshot;
105
105
  //#endregion
106
+ //#region ../resource-core/src/code-package.d.ts
107
+ declare const CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY = "code-binding:module";
108
+ interface CodePackageBinding {
109
+ readonly resourceId: string;
110
+ readonly moduleUri: string;
111
+ readonly exportName?: string;
112
+ }
113
+ interface LoadedCodePackageModule {
114
+ readonly resourceId: string;
115
+ readonly binding: CodePackageBinding;
116
+ readonly revision: string;
117
+ readonly moduleNamespace: Readonly<Record<string, unknown>>;
118
+ }
119
+ interface LoadCodePackageModuleInput {
120
+ readonly tree: LoadedResourceTree;
121
+ readonly resourceId: string;
122
+ readonly rootDir: string;
123
+ }
124
+ interface CodePackageExportContract<T> {
125
+ isDefinition(value: unknown): value is T;
126
+ identityOf(value: T): string;
127
+ }
128
+ declare class CodePackageLoadError extends Error {
129
+ readonly diagnostics: readonly ResourceDiagnostic[];
130
+ constructor(diagnostics: readonly ResourceDiagnostic[]);
131
+ }
132
+ declare function loadCodePackageModule(input: LoadCodePackageModuleInput): Promise<LoadedCodePackageModule>;
133
+ declare function admitCodePackageExports<T>(loaded: LoadedCodePackageModule, contract: CodePackageExportContract<T>): readonly T[];
134
+ declare function admitCodePackages<T>(loaded: readonly LoadedCodePackageModule[], contract: CodePackageExportContract<T>): readonly T[];
135
+ //#endregion
106
136
  //#region ../resource-core/src/index.d.ts
107
- type SourceShape = "single-file" | "directory" | "manifest";
137
+ type SourceShape = "single-file" | "directory" | "manifest" | "code-package";
108
138
  interface ResourceIdentity {
109
139
  kind: string;
110
140
  fqn?: string;
@@ -164,6 +194,7 @@ interface ResourceTree {
164
194
  }
165
195
  interface LoadedResourceTree extends ResourceTree {
166
196
  readonly contentIdentities: ReadonlyMap<string, ResourceContentIdentity>;
197
+ readonly codePackageBindings: ReadonlyMap<string, CodePackageBinding>;
167
198
  }
168
199
  interface ResourceDiagnostic {
169
200
  code: string;
@@ -189,4 +220,4 @@ declare class ResourceValidationError extends Error {
189
220
  declare function loadResourceTree(options: LoadResourceTreeOptions): Promise<LoadedResourceTree>;
190
221
  declare function validateResourceTree(options: LoadResourceTreeOptions): Promise<ResourceDiagnostic[]>;
191
222
  //#endregion
192
- export { buildResourceDependencySnapshot as A, ResourceTombstone as B, BuildResourceDependencySnapshotInput as C, ResourceDependencySnapshot as D, ResourceDependencyEdge as E, EffectiveResourceEntry as F, composeLayeredResourceRegistry as H, EffectiveResourceRegistry as I, ResourceLayerDescriptor as L, sha256Digest as M, ComposeLayeredResourceRegistryInput as N, ResourceDigestContribution as O, EffectiveKindDefinition as P, ResourceLayerInput as R, validateResourceTree as S, ResourceContentIdentity as T, Sha256Digest as U, ResourceTombstoneOrigin as V, ResourceValue as _, ResourceDescriptor as a, SourceShape as b, ResourceKindContract as c, ResourceRecord as d, ResourceRegistry as f, ResourceValidationError as g, ResourceTreeBuildResult as h, RegisteredKindDefinition as i, createResourceContentIdentity as j, SnapshotResource as k, ResourceMetadata as l, ResourceTree as m, LoadedResourceTree as n, ResourceDiagnostic as o, ResourceScalar as p, LoadedResourceTreeBuildResult as r, ResourceIdentity as s, LoadResourceTreeOptions as t, ResourceNode as u, ResourceValueList as v, CreateResourceContentIdentityInput as w, loadResourceTree as x, ResourceValueMap as y, ResourceOrigin as z };
223
+ export { admitCodePackages as A, createResourceContentIdentity as B, CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY as C, LoadCodePackageModuleInput as D, CodePackageLoadError as E, ResourceDependencyEdge as F, EffectiveResourceRegistry as G, ComposeLayeredResourceRegistryInput as H, ResourceDependencySnapshot as I, ResourceOrigin as J, ResourceLayerDescriptor as K, ResourceDigestContribution as L, BuildResourceDependencySnapshotInput as M, CreateResourceContentIdentityInput as N, LoadedCodePackageModule as O, ResourceContentIdentity as P, Sha256Digest as Q, SnapshotResource as R, validateResourceTree as S, CodePackageExportContract as T, EffectiveKindDefinition as U, sha256Digest as V, EffectiveResourceEntry as W, ResourceTombstoneOrigin as X, ResourceTombstone as Y, composeLayeredResourceRegistry as Z, ResourceValue as _, ResourceDescriptor as a, SourceShape as b, ResourceKindContract as c, ResourceRecord as d, ResourceRegistry as f, ResourceValidationError as g, ResourceTreeBuildResult as h, RegisteredKindDefinition as i, loadCodePackageModule as j, admitCodePackageExports as k, ResourceMetadata as l, ResourceTree as m, LoadedResourceTree as n, ResourceDiagnostic as o, ResourceScalar as p, ResourceLayerInput as q, LoadedResourceTreeBuildResult as r, ResourceIdentity as s, LoadResourceTreeOptions as t, ResourceNode as u, ResourceValueList as v, CodePackageBinding as w, loadResourceTree as x, ResourceValueMap as y, buildResourceDependencySnapshot as z };
@@ -1,4 +1,4 @@
1
- import { a as ResourceDescriptor } from "./index-DdRHFKSQ.js";
1
+ import { a as ResourceDescriptor } from "./index-DihSfO7X.js";
2
2
  //#region ../resource-projection/src/index.d.ts
3
3
  interface ResourceRegistry {
4
4
  readonly byKind: ReadonlyMap<string, readonly ResourceDescriptor[]>;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { A as ObjectTargets, B as applicationAssemblyPackage, C as ObjectOperationDefinition, D as ObjectOperationTargetDeclaration, E as ObjectOperationOwnerKind, F as ResourceSource, G as loadApplicationAssembly, H as assertObjectOperationCall, I as SkillCapsuleDependency, K as resolveApplicationAssembly, L as SkillCapsuleResource, M as ResolveApplicationAssemblyOptions, N as ResolvedAssemblyPortBinding, O as ObjectTargetKindDefinition, P as ResourceInclude, R as TextMaterial, S as ObjectOperationContractError, T as ObjectOperationHandler, U as assertObjectOperationCatalog, V as assertExecuteObjectOperationRequest, W as assertObjectOperationDefinition, _ as ObjectInvocationMode, a as AssemblyResource, b as ObjectOperationCatalog, c as BusinessObjectSopResource, d as ExecuteObjectOperationRequest, f as JsonObject, g as ObjectInvocation, h as LoadApplicationAssemblyOptions, i as AssemblyPortBinding, j as PageObjectResource, k as ObjectTargetRef, l as CodeBinding, m as JsonValue, n as ApplicationScope, o as AuthoringModuleDescriptor, p as JsonPrimitive, q as resourceRefToFqn, r as AssemblyPort, s as BusinessObjectResource, t as ApplicationAssembly, u as ContractedCallableResource, v as ObjectOperationBehavior, w as ObjectOperationEffect, x as ObjectOperationConfig, y as ObjectOperationCall, z as TextResource } from "./index-Cqh9pEBa.js";
2
- import { A as buildResourceDependencySnapshot, B as ResourceTombstone, C as BuildResourceDependencySnapshotInput, D as ResourceDependencySnapshot, E as ResourceDependencyEdge, F as EffectiveResourceEntry, H as composeLayeredResourceRegistry, I as EffectiveResourceRegistry, L as ResourceLayerDescriptor, M as sha256Digest, N as ComposeLayeredResourceRegistryInput, O as ResourceDigestContribution, P as EffectiveKindDefinition, R as ResourceLayerInput, S as validateResourceTree, T as ResourceContentIdentity, U as Sha256Digest, V as ResourceTombstoneOrigin, _ as ResourceValue, a as ResourceDescriptor, b as SourceShape, c as ResourceKindContract, d as ResourceRecord, f as ResourceRegistry, g as ResourceValidationError, h as ResourceTreeBuildResult, i as RegisteredKindDefinition, j as createResourceContentIdentity, k as SnapshotResource, l as ResourceMetadata, m as ResourceTree, n as LoadedResourceTree, o as ResourceDiagnostic, p as ResourceScalar, r as LoadedResourceTreeBuildResult, s as ResourceIdentity, t as LoadResourceTreeOptions, u as ResourceNode, v as ResourceValueList, w as CreateResourceContentIdentityInput, x as loadResourceTree, y as ResourceValueMap, z as ResourceOrigin } from "./index-DdRHFKSQ.js";
3
- import { i as ResourceCompositionError, n as ResourceLayerContentIdentityInput, r as resolveEffectiveResourceContentIdentities, t as ResolveEffectiveResourceContentIdentitiesInput } from "./resource-core-Byhqyadq.js";
4
- import { S as skillCapsuleDistributionProjection, _ as applySkillCapsuleDistributionPlan, a as PlannedSkillCapsule, b as compilerSkillPackage, c as SkillCapsuleContentDigest, d as SkillCapsuleDistributionReceipt, f as SkillCapsuleIdentity, g as SkillReference, h as SkillDescriptor, i as PlanSkillCapsuleDistributionInput, l as SkillCapsuleDistributionError, m as SkillCapsuleProvenanceManifest, n as CompileResourceSkillCapsuleInput, o as PlannedSkillFile, p as SkillCapsulePlan, r as CompileSkillCapsuleInput, s as SkillCapsuleApplyStep, t as ApplySkillCapsuleDistributionOptions, u as SkillCapsuleDistributionPlan, v as compileResourceSkillCapsule, x as planSkillCapsuleDistribution, y as compileSkillCapsule } from "./index-96qHPZj2.js";
2
+ import { A as admitCodePackages, B as createResourceContentIdentity, C as CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, D as LoadCodePackageModuleInput, E as CodePackageLoadError, F as ResourceDependencyEdge, G as EffectiveResourceRegistry, H as ComposeLayeredResourceRegistryInput, I as ResourceDependencySnapshot, J as ResourceOrigin, K as ResourceLayerDescriptor, L as ResourceDigestContribution, M as BuildResourceDependencySnapshotInput, N as CreateResourceContentIdentityInput, O as LoadedCodePackageModule, P as ResourceContentIdentity, Q as Sha256Digest, R as SnapshotResource, S as validateResourceTree, T as CodePackageExportContract, U as EffectiveKindDefinition, V as sha256Digest, W as EffectiveResourceEntry, X as ResourceTombstoneOrigin, Y as ResourceTombstone, Z as composeLayeredResourceRegistry, _ as ResourceValue, a as ResourceDescriptor, b as SourceShape, c as ResourceKindContract, d as ResourceRecord, f as ResourceRegistry, g as ResourceValidationError, h as ResourceTreeBuildResult, i as RegisteredKindDefinition, j as loadCodePackageModule, k as admitCodePackageExports, l as ResourceMetadata, m as ResourceTree, n as LoadedResourceTree, o as ResourceDiagnostic, p as ResourceScalar, q as ResourceLayerInput, r as LoadedResourceTreeBuildResult, s as ResourceIdentity, t as LoadResourceTreeOptions, u as ResourceNode, v as ResourceValueList, w as CodePackageBinding, x as loadResourceTree, y as ResourceValueMap, z as buildResourceDependencySnapshot } from "./index-DihSfO7X.js";
3
+ import { i as ResourceCompositionError, n as ResourceLayerContentIdentityInput, r as resolveEffectiveResourceContentIdentities, t as ResolveEffectiveResourceContentIdentitiesInput } from "./resource-core-UAvFx3m-.js";
4
+ import { S as skillCapsuleDistributionProjection, _ as applySkillCapsuleDistributionPlan, a as PlannedSkillCapsule, b as compilerSkillPackage, c as SkillCapsuleContentDigest, d as SkillCapsuleDistributionReceipt, f as SkillCapsuleIdentity, g as SkillReference, h as SkillDescriptor, i as PlanSkillCapsuleDistributionInput, l as SkillCapsuleDistributionError, m as SkillCapsuleProvenanceManifest, n as CompileResourceSkillCapsuleInput, o as PlannedSkillFile, p as SkillCapsulePlan, r as CompileSkillCapsuleInput, s as SkillCapsuleApplyStep, t as ApplySkillCapsuleDistributionOptions, u as SkillCapsuleDistributionPlan, v as compileResourceSkillCapsule, x as planSkillCapsuleDistribution, y as compileSkillCapsule } from "./index-D7UtYNm7.js";
5
5
  //#region src/bundled-system-skills.d.ts
6
6
  declare function loadHalfcodeResourceDslSystemSkillModule(): AuthoringModuleDescriptor;
7
7
  declare function loadHalfcodeResourceDslSystemSkillPlan(): Promise<SkillCapsuleDistributionPlan>;
8
8
  //#endregion
9
- export { type ApplicationAssembly, type ApplicationScope, ApplySkillCapsuleDistributionOptions, type AssemblyPort, type AssemblyPortBinding, type AssemblyResource, type AuthoringModuleDescriptor, BuildResourceDependencySnapshotInput, type BusinessObjectResource, type BusinessObjectSopResource, type CodeBinding, CompileResourceSkillCapsuleInput, CompileSkillCapsuleInput, ComposeLayeredResourceRegistryInput, type ContractedCallableResource, CreateResourceContentIdentityInput, EffectiveKindDefinition, EffectiveResourceEntry, EffectiveResourceRegistry, type ExecuteObjectOperationRequest, type JsonObject, type JsonPrimitive, type JsonValue, type LoadApplicationAssemblyOptions, LoadResourceTreeOptions, LoadedResourceTree, LoadedResourceTreeBuildResult, type ObjectInvocation, type ObjectInvocationMode, type ObjectOperationBehavior, type ObjectOperationCall, type ObjectOperationCatalog, type ObjectOperationConfig, ObjectOperationContractError, type ObjectOperationDefinition, type ObjectOperationEffect, type ObjectOperationHandler, type ObjectOperationOwnerKind, type ObjectOperationTargetDeclaration, type ObjectTargetKindDefinition, type ObjectTargetRef, type ObjectTargets, type PageObjectResource, PlanSkillCapsuleDistributionInput, PlannedSkillCapsule, PlannedSkillFile, RegisteredKindDefinition, type ResolveApplicationAssemblyOptions, ResolveEffectiveResourceContentIdentitiesInput, type ResolvedAssemblyPortBinding, ResourceCompositionError, ResourceContentIdentity, ResourceDependencyEdge, ResourceDependencySnapshot, ResourceDescriptor, ResourceDiagnostic, ResourceDigestContribution, ResourceIdentity, type ResourceInclude, ResourceKindContract, ResourceLayerContentIdentityInput, ResourceLayerDescriptor, ResourceLayerInput, ResourceMetadata, ResourceNode, ResourceOrigin, ResourceRecord, ResourceRegistry, ResourceScalar, type ResourceSource, ResourceTombstone, ResourceTombstoneOrigin, ResourceTree, ResourceTreeBuildResult, ResourceValidationError, ResourceValue, ResourceValueList, ResourceValueMap, type Sha256Digest, SkillCapsuleApplyStep, SkillCapsuleContentDigest, type SkillCapsuleDependency, SkillCapsuleDistributionError, SkillCapsuleDistributionPlan, SkillCapsuleDistributionReceipt, SkillCapsuleIdentity, SkillCapsulePlan, SkillCapsuleProvenanceManifest, type SkillCapsuleResource, SkillDescriptor, SkillReference, SnapshotResource, SourceShape, type TextMaterial, type TextResource, applicationAssemblyPackage, applySkillCapsuleDistributionPlan, assertExecuteObjectOperationRequest, assertObjectOperationCall, assertObjectOperationCatalog, assertObjectOperationDefinition, buildResourceDependencySnapshot, compileResourceSkillCapsule, compileSkillCapsule, compilerSkillPackage, composeLayeredResourceRegistry, createResourceContentIdentity, loadApplicationAssembly, loadHalfcodeResourceDslSystemSkillModule, loadHalfcodeResourceDslSystemSkillPlan, loadResourceTree, planSkillCapsuleDistribution, resolveApplicationAssembly, resolveEffectiveResourceContentIdentities, resourceRefToFqn, sha256Digest, skillCapsuleDistributionProjection, validateResourceTree };
9
+ export { type ApplicationAssembly, type ApplicationScope, ApplySkillCapsuleDistributionOptions, type AssemblyPort, type AssemblyPortBinding, type AssemblyResource, type AuthoringModuleDescriptor, BuildResourceDependencySnapshotInput, type BusinessObjectResource, type BusinessObjectSopResource, CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, type CodeBinding, type CodePackageBinding, type CodePackageExportContract, CodePackageLoadError, CompileResourceSkillCapsuleInput, CompileSkillCapsuleInput, ComposeLayeredResourceRegistryInput, type ContractedCallableResource, CreateResourceContentIdentityInput, EffectiveKindDefinition, EffectiveResourceEntry, EffectiveResourceRegistry, type ExecuteObjectOperationRequest, type JsonObject, type JsonPrimitive, type JsonValue, type LoadApplicationAssemblyOptions, type LoadCodePackageModuleInput, LoadResourceTreeOptions, type LoadedCodePackageModule, LoadedResourceTree, LoadedResourceTreeBuildResult, type ObjectInvocation, type ObjectInvocationMode, type ObjectOperationBehavior, type ObjectOperationCall, type ObjectOperationCatalog, type ObjectOperationConfig, ObjectOperationContractError, type ObjectOperationDefinition, type ObjectOperationEffect, type ObjectOperationHandler, type ObjectOperationOwnerKind, type ObjectOperationTargetDeclaration, type ObjectTargetKindDefinition, type ObjectTargetRef, type ObjectTargets, type PageObjectResource, PlanSkillCapsuleDistributionInput, PlannedSkillCapsule, PlannedSkillFile, RegisteredKindDefinition, type ResolveApplicationAssemblyOptions, ResolveEffectiveResourceContentIdentitiesInput, type ResolvedAssemblyPortBinding, ResourceCompositionError, ResourceContentIdentity, ResourceDependencyEdge, ResourceDependencySnapshot, ResourceDescriptor, ResourceDiagnostic, ResourceDigestContribution, ResourceIdentity, type ResourceInclude, ResourceKindContract, ResourceLayerContentIdentityInput, ResourceLayerDescriptor, ResourceLayerInput, ResourceMetadata, ResourceNode, ResourceOrigin, ResourceRecord, ResourceRegistry, ResourceScalar, type ResourceSource, ResourceTombstone, ResourceTombstoneOrigin, ResourceTree, ResourceTreeBuildResult, ResourceValidationError, ResourceValue, ResourceValueList, ResourceValueMap, type Sha256Digest, SkillCapsuleApplyStep, SkillCapsuleContentDigest, type SkillCapsuleDependency, SkillCapsuleDistributionError, SkillCapsuleDistributionPlan, SkillCapsuleDistributionReceipt, SkillCapsuleIdentity, SkillCapsulePlan, SkillCapsuleProvenanceManifest, type SkillCapsuleResource, SkillDescriptor, SkillReference, SnapshotResource, SourceShape, type TextMaterial, type TextResource, admitCodePackageExports, admitCodePackages, applicationAssemblyPackage, applySkillCapsuleDistributionPlan, assertExecuteObjectOperationRequest, assertObjectOperationCall, assertObjectOperationCatalog, assertObjectOperationDefinition, buildResourceDependencySnapshot, compileResourceSkillCapsule, compileSkillCapsule, compilerSkillPackage, composeLayeredResourceRegistry, createResourceContentIdentity, loadApplicationAssembly, loadCodePackageModule, loadHalfcodeResourceDslSystemSkillModule, loadHalfcodeResourceDslSystemSkillPlan, loadResourceTree, planSkillCapsuleDistribution, resolveApplicationAssembly, resolveEffectiveResourceContentIdentities, resourceRefToFqn, sha256Digest, skillCapsuleDistributionProjection, validateResourceTree };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { c as sha256Digest, f as ResourceCompositionError, n as loadResourceTree, o as buildResourceDependencySnapshot, r as validateResourceTree, s as createResourceContentIdentity, t as ResourceValidationError } from "./src-DCRih45n.js";
2
- import { a as assertObjectOperationCatalog, c as resolveApplicationAssembly, i as assertObjectOperationCall, l as resourceRefToFqn, n as applicationAssemblyPackage, o as assertObjectOperationDefinition, r as assertExecuteObjectOperationRequest, s as loadApplicationAssembly, t as ObjectOperationContractError } from "./src-DRIws6tY.js";
1
+ import { _ as ResourceCompositionError, a as CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, c as admitCodePackages, d as buildResourceDependencySnapshot, f as createResourceContentIdentity, l as loadCodePackageModule, n as loadResourceTree, o as CodePackageLoadError, p as sha256Digest, r as validateResourceTree, s as admitCodePackageExports, t as ResourceValidationError } from "./src-Bj7BZokJ.js";
2
+ import { a as assertObjectOperationCatalog, c as resolveApplicationAssembly, i as assertObjectOperationCall, l as resourceRefToFqn, n as applicationAssemblyPackage, o as assertObjectOperationDefinition, r as assertExecuteObjectOperationRequest, s as loadApplicationAssembly, t as ObjectOperationContractError } from "./src-6nezdi57.js";
3
3
  import "./application-assembly.js";
4
4
  import { composeLayeredResourceRegistry, resolveEffectiveResourceContentIdentities } from "./resource-core.js";
5
- import { a as compilerSkillPackage, i as compileSkillCapsule, n as applySkillCapsuleDistributionPlan, o as planSkillCapsuleDistribution, r as compileResourceSkillCapsule, s as skillCapsuleDistributionProjection, t as SkillCapsuleDistributionError } from "./src-D1Bmq7Lo.js";
5
+ import { a as compilerSkillPackage, i as compileSkillCapsule, n as applySkillCapsuleDistributionPlan, o as planSkillCapsuleDistribution, r as compileResourceSkillCapsule, s as skillCapsuleDistributionProjection, t as SkillCapsuleDistributionError } from "./src-ClihwpeP.js";
6
6
  import { fileURLToPath } from "node:url";
7
7
  //#region src/bundled-system-skills.ts
8
8
  function loadHalfcodeResourceDslSystemSkillModule() {
@@ -20,4 +20,4 @@ async function loadHalfcodeResourceDslSystemSkillPlan() {
20
20
  return bundled.default;
21
21
  }
22
22
  //#endregion
23
- export { ObjectOperationContractError, ResourceCompositionError, ResourceValidationError, SkillCapsuleDistributionError, applicationAssemblyPackage, applySkillCapsuleDistributionPlan, assertExecuteObjectOperationRequest, assertObjectOperationCall, assertObjectOperationCatalog, assertObjectOperationDefinition, buildResourceDependencySnapshot, compileResourceSkillCapsule, compileSkillCapsule, compilerSkillPackage, composeLayeredResourceRegistry, createResourceContentIdentity, loadApplicationAssembly, loadHalfcodeResourceDslSystemSkillModule, loadHalfcodeResourceDslSystemSkillPlan, loadResourceTree, planSkillCapsuleDistribution, resolveApplicationAssembly, resolveEffectiveResourceContentIdentities, resourceRefToFqn, sha256Digest, skillCapsuleDistributionProjection, validateResourceTree };
23
+ export { CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, CodePackageLoadError, ObjectOperationContractError, ResourceCompositionError, ResourceValidationError, SkillCapsuleDistributionError, admitCodePackageExports, admitCodePackages, applicationAssemblyPackage, applySkillCapsuleDistributionPlan, assertExecuteObjectOperationRequest, assertObjectOperationCall, assertObjectOperationCatalog, assertObjectOperationDefinition, buildResourceDependencySnapshot, compileResourceSkillCapsule, compileSkillCapsule, compilerSkillPackage, composeLayeredResourceRegistry, createResourceContentIdentity, loadApplicationAssembly, loadCodePackageModule, loadHalfcodeResourceDslSystemSkillModule, loadHalfcodeResourceDslSystemSkillPlan, loadResourceTree, planSkillCapsuleDistribution, resolveApplicationAssembly, resolveEffectiveResourceContentIdentities, resourceRefToFqn, sha256Digest, skillCapsuleDistributionProjection, validateResourceTree };
@@ -1,4 +1,4 @@
1
- import { a as ResourceDescriptor, c as ResourceKindContract } from "./index-DdRHFKSQ.js";
1
+ import { a as ResourceDescriptor, c as ResourceKindContract } from "./index-DihSfO7X.js";
2
2
  //#region ../kind-definition/src/index.d.ts
3
3
  interface KindDefinition extends ResourceDescriptor, ResourceKindContract {
4
4
  kind: "KindDefinition";
@@ -1,4 +1,4 @@
1
- import { I as EffectiveResourceRegistry, O as ResourceDigestContribution, T as ResourceContentIdentity, n as LoadedResourceTree, o as ResourceDiagnostic } from "./index-DdRHFKSQ.js";
1
+ import { G as EffectiveResourceRegistry, L as ResourceDigestContribution, P as ResourceContentIdentity, n as LoadedResourceTree, o as ResourceDiagnostic } from "./index-DihSfO7X.js";
2
2
  //#region ../resource-core/src/composition-error.d.ts
3
3
  declare class ResourceCompositionError extends Error {
4
4
  readonly diagnostics: readonly ResourceDiagnostic[];
@@ -1,3 +1,3 @@
1
- import { A as buildResourceDependencySnapshot, B as ResourceTombstone, C as BuildResourceDependencySnapshotInput, D as ResourceDependencySnapshot, E as ResourceDependencyEdge, F as EffectiveResourceEntry, H as composeLayeredResourceRegistry, I as EffectiveResourceRegistry, L as ResourceLayerDescriptor, M as sha256Digest, N as ComposeLayeredResourceRegistryInput, O as ResourceDigestContribution, P as EffectiveKindDefinition, R as ResourceLayerInput, S as validateResourceTree, T as ResourceContentIdentity, U as Sha256Digest, V as ResourceTombstoneOrigin, _ as ResourceValue, a as ResourceDescriptor, b as SourceShape, c as ResourceKindContract, d as ResourceRecord, f as ResourceRegistry, g as ResourceValidationError, h as ResourceTreeBuildResult, i as RegisteredKindDefinition, j as createResourceContentIdentity, k as SnapshotResource, l as ResourceMetadata, m as ResourceTree, n as LoadedResourceTree, o as ResourceDiagnostic, p as ResourceScalar, r as LoadedResourceTreeBuildResult, s as ResourceIdentity, t as LoadResourceTreeOptions, u as ResourceNode, v as ResourceValueList, w as CreateResourceContentIdentityInput, x as loadResourceTree, y as ResourceValueMap, z as ResourceOrigin } from "./index-DdRHFKSQ.js";
2
- import { i as ResourceCompositionError, n as ResourceLayerContentIdentityInput, r as resolveEffectiveResourceContentIdentities, t as ResolveEffectiveResourceContentIdentitiesInput } from "./resource-core-Byhqyadq.js";
3
- export { BuildResourceDependencySnapshotInput, ComposeLayeredResourceRegistryInput, CreateResourceContentIdentityInput, EffectiveKindDefinition, EffectiveResourceEntry, EffectiveResourceRegistry, LoadResourceTreeOptions, LoadedResourceTree, LoadedResourceTreeBuildResult, RegisteredKindDefinition, ResolveEffectiveResourceContentIdentitiesInput, ResourceCompositionError, ResourceContentIdentity, ResourceDependencyEdge, ResourceDependencySnapshot, ResourceDescriptor, ResourceDiagnostic, ResourceDigestContribution, ResourceIdentity, ResourceKindContract, ResourceLayerContentIdentityInput, ResourceLayerDescriptor, ResourceLayerInput, ResourceMetadata, ResourceNode, ResourceOrigin, ResourceRecord, ResourceRegistry, ResourceScalar, ResourceTombstone, ResourceTombstoneOrigin, ResourceTree, ResourceTreeBuildResult, ResourceValidationError, ResourceValue, ResourceValueList, ResourceValueMap, type Sha256Digest, SnapshotResource, SourceShape, buildResourceDependencySnapshot, composeLayeredResourceRegistry, createResourceContentIdentity, loadResourceTree, resolveEffectiveResourceContentIdentities, sha256Digest, validateResourceTree };
1
+ import { A as admitCodePackages, B as createResourceContentIdentity, C as CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, D as LoadCodePackageModuleInput, E as CodePackageLoadError, F as ResourceDependencyEdge, G as EffectiveResourceRegistry, H as ComposeLayeredResourceRegistryInput, I as ResourceDependencySnapshot, J as ResourceOrigin, K as ResourceLayerDescriptor, L as ResourceDigestContribution, M as BuildResourceDependencySnapshotInput, N as CreateResourceContentIdentityInput, O as LoadedCodePackageModule, P as ResourceContentIdentity, Q as Sha256Digest, R as SnapshotResource, S as validateResourceTree, T as CodePackageExportContract, U as EffectiveKindDefinition, V as sha256Digest, W as EffectiveResourceEntry, X as ResourceTombstoneOrigin, Y as ResourceTombstone, Z as composeLayeredResourceRegistry, _ as ResourceValue, a as ResourceDescriptor, b as SourceShape, c as ResourceKindContract, d as ResourceRecord, f as ResourceRegistry, g as ResourceValidationError, h as ResourceTreeBuildResult, i as RegisteredKindDefinition, j as loadCodePackageModule, k as admitCodePackageExports, l as ResourceMetadata, m as ResourceTree, n as LoadedResourceTree, o as ResourceDiagnostic, p as ResourceScalar, q as ResourceLayerInput, r as LoadedResourceTreeBuildResult, s as ResourceIdentity, t as LoadResourceTreeOptions, u as ResourceNode, v as ResourceValueList, w as CodePackageBinding, x as loadResourceTree, y as ResourceValueMap, z as buildResourceDependencySnapshot } from "./index-DihSfO7X.js";
2
+ import { i as ResourceCompositionError, n as ResourceLayerContentIdentityInput, r as resolveEffectiveResourceContentIdentities, t as ResolveEffectiveResourceContentIdentitiesInput } from "./resource-core-UAvFx3m-.js";
3
+ export { BuildResourceDependencySnapshotInput, CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, type CodePackageBinding, type CodePackageExportContract, CodePackageLoadError, ComposeLayeredResourceRegistryInput, CreateResourceContentIdentityInput, EffectiveKindDefinition, EffectiveResourceEntry, EffectiveResourceRegistry, type LoadCodePackageModuleInput, LoadResourceTreeOptions, type LoadedCodePackageModule, LoadedResourceTree, LoadedResourceTreeBuildResult, RegisteredKindDefinition, ResolveEffectiveResourceContentIdentitiesInput, ResourceCompositionError, ResourceContentIdentity, ResourceDependencyEdge, ResourceDependencySnapshot, ResourceDescriptor, ResourceDiagnostic, ResourceDigestContribution, ResourceIdentity, ResourceKindContract, ResourceLayerContentIdentityInput, ResourceLayerDescriptor, ResourceLayerInput, ResourceMetadata, ResourceNode, ResourceOrigin, ResourceRecord, ResourceRegistry, ResourceScalar, ResourceTombstone, ResourceTombstoneOrigin, ResourceTree, ResourceTreeBuildResult, ResourceValidationError, ResourceValue, ResourceValueList, ResourceValueMap, type Sha256Digest, SnapshotResource, SourceShape, admitCodePackageExports, admitCodePackages, buildResourceDependencySnapshot, composeLayeredResourceRegistry, createResourceContentIdentity, loadCodePackageModule, loadResourceTree, resolveEffectiveResourceContentIdentities, sha256Digest, validateResourceTree };
@@ -1,4 +1,4 @@
1
- import { a as isLoadedResourceTreeAuthentic, c as sha256Digest, d as markEffectiveRegistryAuthentic, f as ResourceCompositionError, i as readonlyMap, l as effectiveRegistryLayerBindings, m as digestCanonical, n as loadResourceTree, o as buildResourceDependencySnapshot, p as compareCodeUnits, r as validateResourceTree, s as createResourceContentIdentity, t as ResourceValidationError, u as isEffectiveRegistryAuthentic } from "./src-DCRih45n.js";
1
+ import { _ as ResourceCompositionError, a as CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, c as admitCodePackages, d as buildResourceDependencySnapshot, f as createResourceContentIdentity, g as markEffectiveRegistryAuthentic, h as isEffectiveRegistryAuthentic, i as readonlyMap, l as loadCodePackageModule, m as effectiveRegistryLayerBindings, n as loadResourceTree, o as CodePackageLoadError, p as sha256Digest, r as validateResourceTree, s as admitCodePackageExports, t as ResourceValidationError, u as isLoadedResourceTreeAuthentic, v as compareCodeUnits, y as digestCanonical } from "./src-Bj7BZokJ.js";
2
2
  //#region ../resource-core/src/layered-registry.ts
3
3
  function composeLayeredResourceRegistry(input) {
4
4
  const diagnostics = [];
@@ -368,7 +368,7 @@ function resolveEffectiveResourceContentIdentities(input) {
368
368
  const identity = createResourceContentIdentity({
369
369
  resourceId: entry.resourceId,
370
370
  authorityDigest: authorityIdentity.authorityDigest,
371
- contributions: input.contributions?.get(entry.resourceId) ?? []
371
+ contributions: [...authorityIdentity.contributions, ...input.contributions?.get(entry.resourceId) ?? []]
372
372
  });
373
373
  output.push([entry.resourceId, identity]);
374
374
  } catch (error) {
@@ -391,7 +391,7 @@ function validateLoadedIdentityCoverage(tree, layerId, diagnostics) {
391
391
  const normalized = createResourceContentIdentity({
392
392
  resourceId: identity.resourceId,
393
393
  authorityDigest: identity.authorityDigest,
394
- contributions: []
394
+ contributions: identity.contributions
395
395
  });
396
396
  if (identity.resourceId !== resource.resourceId || identity.contentDigest !== normalized.contentDigest) diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_INVALID", layerLocation(void 0, layerId, resource.resourceId), `Loaded resource '${resource.resourceId}' has an inconsistent authority identity.`));
397
397
  }
@@ -429,4 +429,4 @@ function contentLocation(resourceId) {
429
429
  return `content:${resourceId || "unnamed"}`;
430
430
  }
431
431
  //#endregion
432
- export { ResourceCompositionError, ResourceValidationError, buildResourceDependencySnapshot, composeLayeredResourceRegistry, createResourceContentIdentity, loadResourceTree, resolveEffectiveResourceContentIdentities, sha256Digest, validateResourceTree };
432
+ export { CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, CodePackageLoadError, ResourceCompositionError, ResourceValidationError, admitCodePackageExports, admitCodePackages, buildResourceDependencySnapshot, composeLayeredResourceRegistry, createResourceContentIdentity, loadCodePackageModule, loadResourceTree, resolveEffectiveResourceContentIdentities, sha256Digest, validateResourceTree };
@@ -1,2 +1,2 @@
1
- import { n as resourceProjectionPackage, t as ResourceRegistry } from "./index-D2mpux6L.js";
1
+ import { n as resourceProjectionPackage, t as ResourceRegistry } from "./index-DjvNDidT.js";
2
2
  export { ResourceRegistry, resourceProjectionPackage };
@@ -1,3 +1,3 @@
1
1
  import { I as SkillCapsuleDependency } from "./index-Cqh9pEBa.js";
2
- import { S as skillCapsuleDistributionProjection, _ as applySkillCapsuleDistributionPlan, a as PlannedSkillCapsule, b as compilerSkillPackage, c as SkillCapsuleContentDigest, d as SkillCapsuleDistributionReceipt, f as SkillCapsuleIdentity, g as SkillReference, h as SkillDescriptor, i as PlanSkillCapsuleDistributionInput, l as SkillCapsuleDistributionError, m as SkillCapsuleProvenanceManifest, n as CompileResourceSkillCapsuleInput, o as PlannedSkillFile, p as SkillCapsulePlan, r as CompileSkillCapsuleInput, s as SkillCapsuleApplyStep, t as ApplySkillCapsuleDistributionOptions, u as SkillCapsuleDistributionPlan, v as compileResourceSkillCapsule, x as planSkillCapsuleDistribution, y as compileSkillCapsule } from "./index-96qHPZj2.js";
2
+ import { S as skillCapsuleDistributionProjection, _ as applySkillCapsuleDistributionPlan, a as PlannedSkillCapsule, b as compilerSkillPackage, c as SkillCapsuleContentDigest, d as SkillCapsuleDistributionReceipt, f as SkillCapsuleIdentity, g as SkillReference, h as SkillDescriptor, i as PlanSkillCapsuleDistributionInput, l as SkillCapsuleDistributionError, m as SkillCapsuleProvenanceManifest, n as CompileResourceSkillCapsuleInput, o as PlannedSkillFile, p as SkillCapsulePlan, r as CompileSkillCapsuleInput, s as SkillCapsuleApplyStep, t as ApplySkillCapsuleDistributionOptions, u as SkillCapsuleDistributionPlan, v as compileResourceSkillCapsule, x as planSkillCapsuleDistribution, y as compileSkillCapsule } from "./index-D7UtYNm7.js";
3
3
  export { ApplySkillCapsuleDistributionOptions, CompileResourceSkillCapsuleInput, CompileSkillCapsuleInput, PlanSkillCapsuleDistributionInput, PlannedSkillCapsule, PlannedSkillFile, SkillCapsuleApplyStep, SkillCapsuleContentDigest, type SkillCapsuleDependency, SkillCapsuleDistributionError, SkillCapsuleDistributionPlan, SkillCapsuleDistributionReceipt, SkillCapsuleIdentity, SkillCapsulePlan, SkillCapsuleProvenanceManifest, SkillDescriptor, SkillReference, applySkillCapsuleDistributionPlan, compileResourceSkillCapsule, compileSkillCapsule, compilerSkillPackage, planSkillCapsuleDistribution, skillCapsuleDistributionProjection };
@@ -1,2 +1,2 @@
1
- import { a as compilerSkillPackage, i as compileSkillCapsule, n as applySkillCapsuleDistributionPlan, o as planSkillCapsuleDistribution, r as compileResourceSkillCapsule, s as skillCapsuleDistributionProjection, t as SkillCapsuleDistributionError } from "./src-D1Bmq7Lo.js";
1
+ import { a as compilerSkillPackage, i as compileSkillCapsule, n as applySkillCapsuleDistributionPlan, o as planSkillCapsuleDistribution, r as compileResourceSkillCapsule, s as skillCapsuleDistributionProjection, t as SkillCapsuleDistributionError } from "./src-ClihwpeP.js";
2
2
  export { SkillCapsuleDistributionError, applySkillCapsuleDistributionPlan, compileResourceSkillCapsule, compileSkillCapsule, compilerSkillPackage, planSkillCapsuleDistribution, skillCapsuleDistributionProjection };
@@ -1,4 +1,4 @@
1
- import { n as loadResourceTree } from "./src-DCRih45n.js";
1
+ import { n as loadResourceTree } from "./src-Bj7BZokJ.js";
2
2
  import { readFile } from "node:fs/promises";
3
3
  import { dirname, join } from "node:path";
4
4
  import { parse } from "yaml";
@@ -1,7 +1,8 @@
1
1
  import { n as wordToString, t as parseXnl } from "./dist-Bkv7YeVi.js";
2
2
  import { readFile, readdir, realpath, stat } from "node:fs/promises";
3
- import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
3
+ import { dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
4
4
  import { createHash } from "node:crypto";
5
+ import { Buffer } from "node:buffer";
5
6
  //#region ../resource-core/src/canonical.ts
6
7
  function compareCodeUnits(left, right) {
7
8
  if (left < right) return -1;
@@ -72,17 +73,17 @@ function createResourceContentIdentity(input) {
72
73
  strictCanonicalInput: false,
73
74
  validateClaimedDigest: false
74
75
  });
75
- if (diagnostics.length > 0 || !identity) throw new ResourceCompositionError(stableDiagnostics(diagnostics));
76
+ if (diagnostics.length > 0 || !identity) throw new ResourceCompositionError(stableDiagnostics$1(diagnostics));
76
77
  return identity;
77
78
  }
78
79
  function buildResourceDependencySnapshot(input) {
79
80
  const diagnostics = [];
80
- if (!isEffectiveRegistryAuthentic(input.registry) || input.registry.revision !== input.registry.compositionRevision) throw new ResourceCompositionError(Object.freeze([diagnostic("RESOURCE_EFFECTIVE_REGISTRY_UNTRUSTED", "effective-registry:revision", "Dependency snapshots require an authentic immutable registry returned by composeLayeredResourceRegistry().")]));
81
+ if (!isEffectiveRegistryAuthentic(input.registry) || input.registry.revision !== input.registry.compositionRevision) throw new ResourceCompositionError(Object.freeze([diagnostic$1("RESOURCE_EFFECTIVE_REGISTRY_UNTRUSTED", "effective-registry:revision", "Dependency snapshots require an authentic immutable registry returned by composeLayeredResourceRegistry().")]));
81
82
  const roots = validateRoots(input.roots, input.registry, diagnostics);
82
83
  const edges = validateEdges(input.edges, input.registry, diagnostics);
83
84
  validateContentIdentityIndex(input.contentIdentities, diagnostics);
84
85
  const validatedIdentities = validateEffectiveContentIdentities(input.registry, input.contentIdentities, diagnostics);
85
- if (diagnostics.length > 0) throw new ResourceCompositionError(stableDiagnostics(diagnostics));
86
+ if (diagnostics.length > 0) throw new ResourceCompositionError(stableDiagnostics$1(diagnostics));
86
87
  const registryRevision = digestCanonical({
87
88
  compositionRevision: input.registry.compositionRevision,
88
89
  resources: [...validatedIdentities.values()].sort((left, right) => compareCodeUnits(left.resourceId, right.resourceId)).map((identity) => ({
@@ -106,7 +107,7 @@ function buildResourceDependencySnapshot(input) {
106
107
  if (visiting.has(resourceId)) {
107
108
  const cycleStart = path.indexOf(resourceId);
108
109
  const cycle = [...path.slice(cycleStart), resourceId];
109
- diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_CYCLE", dependencyLocation(resourceId), `Resource dependency cycle detected: ${cycle.join(" -> ")}.`));
110
+ diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_CYCLE", dependencyLocation(resourceId), `Resource dependency cycle detected: ${cycle.join(" -> ")}.`));
110
111
  return;
111
112
  }
112
113
  if (visited.has(resourceId)) return;
@@ -122,7 +123,7 @@ function buildResourceDependencySnapshot(input) {
122
123
  visited.add(resourceId);
123
124
  };
124
125
  for (const root of roots) visit(root);
125
- if (diagnostics.length > 0) throw new ResourceCompositionError(stableDiagnostics(diagnostics));
126
+ if (diagnostics.length > 0) throw new ResourceCompositionError(stableDiagnostics$1(diagnostics));
126
127
  const closure = Object.freeze([...reachable].sort(compareCodeUnits).map((resourceId) => {
127
128
  const entry = input.registry.byId.get(resourceId);
128
129
  const identity = validatedIdentities.get(resourceId);
@@ -160,19 +161,19 @@ function validateRoots(inputRoots, registry, diagnostics) {
160
161
  for (const value of inputRoots) {
161
162
  const resourceId = value.trim();
162
163
  if (resourceId.length === 0) {
163
- diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_ROOT_EMPTY", "dependency-root:unnamed", "Dependency snapshot roots must be non-empty resource ids."));
164
+ diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_ROOT_EMPTY", "dependency-root:unnamed", "Dependency snapshot roots must be non-empty resource ids."));
164
165
  continue;
165
166
  }
166
167
  if (seen.has(resourceId)) {
167
- diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_ROOT_DUPLICATE", dependencyLocation(resourceId), `Dependency snapshot root '${resourceId}' is declared more than once.`));
168
+ diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_ROOT_DUPLICATE", dependencyLocation(resourceId), `Dependency snapshot root '${resourceId}' is declared more than once.`));
168
169
  continue;
169
170
  }
170
171
  seen.add(resourceId);
171
172
  roots.push(resourceId);
172
173
  const entry = registry.byId.get(resourceId);
173
- if (!entry || !entry.resource) diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_ROOT_MISSING", dependencyLocation(resourceId), `Dependency snapshot root '${resourceId}' is not an effective resource.`));
174
+ if (!entry || !entry.resource) diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_ROOT_MISSING", dependencyLocation(resourceId), `Dependency snapshot root '${resourceId}' is not an effective resource.`));
174
175
  }
175
- if (roots.length === 0 && diagnostics.length === 0) diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_ROOTS_EMPTY", "dependency-root:none", "Dependency snapshot requires at least one explicit root."));
176
+ if (roots.length === 0 && diagnostics.length === 0) diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_ROOTS_EMPTY", "dependency-root:none", "Dependency snapshot requires at least one explicit root."));
176
177
  return roots;
177
178
  }
178
179
  function validateEdges(inputEdges, registry, diagnostics) {
@@ -185,13 +186,13 @@ function validateEdges(inputEdges, registry, diagnostics) {
185
186
  declaredBy: inputEdge.declaredBy.trim()
186
187
  });
187
188
  if (!edge.fromResourceId || !edge.toResourceId || !edge.relation || !edge.declaredBy) {
188
- diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_EDGE_INVALID", `dependency-edge:${index}`, "Dependency edges require non-empty fromResourceId, toResourceId, relation, and declaredBy fields."));
189
+ diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_EDGE_INVALID", `dependency-edge:${index}`, "Dependency edges require non-empty fromResourceId, toResourceId, relation, and declaredBy fields."));
189
190
  return;
190
191
  }
191
192
  const source = registry.byId.get(edge.fromResourceId);
192
193
  const target = registry.byId.get(edge.toResourceId);
193
- if (!source?.resource) diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_SOURCE_MISSING", dependencyLocation(edge.fromResourceId), `Dependency edge source '${edge.fromResourceId}' is not an effective resource.`));
194
- if (!target?.resource) diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_TARGET_MISSING", dependencyLocation(edge.toResourceId), `Dependency edge target '${edge.toResourceId}' is not an effective resource.`));
194
+ if (!source?.resource) diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_SOURCE_MISSING", dependencyLocation(edge.fromResourceId), `Dependency edge source '${edge.fromResourceId}' is not an effective resource.`));
195
+ if (!target?.resource) diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_TARGET_MISSING", dependencyLocation(edge.toResourceId), `Dependency edge target '${edge.toResourceId}' is not an effective resource.`));
195
196
  values.set(edgeKey(edge), edge);
196
197
  });
197
198
  return [...values.values()].sort(compareEdges);
@@ -199,41 +200,41 @@ function validateEdges(inputEdges, registry, diagnostics) {
199
200
  function normalizeContentIdentity(input, diagnostics, options) {
200
201
  const initialDiagnosticCount = diagnostics.length;
201
202
  if (!isRecord(input)) {
202
- diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_INVALID", contentLocation(""), "Resource content identity must be an object fact."));
203
+ diagnostics.push(diagnostic$1("RESOURCE_CONTENT_IDENTITY_INVALID", contentLocation(""), "Resource content identity must be an object fact."));
203
204
  return;
204
205
  }
205
206
  const rawResourceId = input.resourceId;
206
207
  const resourceId = typeof rawResourceId === "string" ? rawResourceId.trim() : "";
207
- if (resourceId.length === 0) diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_ID_EMPTY", contentLocation(""), "Resource content identity requires a non-empty resource id."));
208
- else if (options.strictCanonicalInput && rawResourceId !== resourceId) diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_NON_CANONICAL", contentLocation(resourceId), `Resource content identity '${resourceId}' must use its canonical id without surrounding whitespace.`));
208
+ if (resourceId.length === 0) diagnostics.push(diagnostic$1("RESOURCE_CONTENT_IDENTITY_ID_EMPTY", contentLocation(""), "Resource content identity requires a non-empty resource id."));
209
+ else if (options.strictCanonicalInput && rawResourceId !== resourceId) diagnostics.push(diagnostic$1("RESOURCE_CONTENT_IDENTITY_NON_CANONICAL", contentLocation(resourceId), `Resource content identity '${resourceId}' must use its canonical id without surrounding whitespace.`));
209
210
  const authorityDigest = typeof input.authorityDigest === "string" ? input.authorityDigest : "";
210
- if (!isSha256Digest(authorityDigest)) diagnostics.push(diagnostic("RESOURCE_CONTENT_AUTHORITY_DIGEST_INVALID", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' has an invalid authority digest.`));
211
+ if (!isSha256Digest(authorityDigest)) diagnostics.push(diagnostic$1("RESOURCE_CONTENT_AUTHORITY_DIGEST_INVALID", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' has an invalid authority digest.`));
211
212
  const rawContributions = input.contributions;
212
213
  let contributionFacts = [];
213
214
  if (rawContributions === void 0 && !options.requireContributions) contributionFacts = [];
214
- else if (!Array.isArray(rawContributions)) diagnostics.push(diagnostic("RESOURCE_DIGEST_CONTRIBUTIONS_INVALID", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' must provide an explicit digest contribution array.`));
215
+ else if (!Array.isArray(rawContributions)) diagnostics.push(diagnostic$1("RESOURCE_DIGEST_CONTRIBUTIONS_INVALID", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' must provide an explicit digest contribution array.`));
215
216
  else contributionFacts = rawContributions;
216
217
  const contributions = /* @__PURE__ */ new Map();
217
218
  for (const fact of contributionFacts) {
218
219
  if (!isRecord(fact)) {
219
- diagnostics.push(diagnostic("RESOURCE_DIGEST_CONTRIBUTION_INVALID", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' has a non-object digest contribution.`));
220
+ diagnostics.push(diagnostic$1("RESOURCE_DIGEST_CONTRIBUTION_INVALID", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' has a non-object digest contribution.`));
220
221
  continue;
221
222
  }
222
223
  const rawKey = fact.key;
223
224
  const key = typeof rawKey === "string" ? rawKey.trim() : "";
224
225
  if (key.length === 0) {
225
- diagnostics.push(diagnostic("RESOURCE_DIGEST_CONTRIBUTION_KEY_EMPTY", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' has a digest contribution with an empty key.`));
226
+ diagnostics.push(diagnostic$1("RESOURCE_DIGEST_CONTRIBUTION_KEY_EMPTY", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' has a digest contribution with an empty key.`));
226
227
  continue;
227
228
  }
228
- if (options.strictCanonicalInput && rawKey !== key) diagnostics.push(diagnostic("RESOURCE_DIGEST_CONTRIBUTION_NON_CANONICAL", contentLocation(resourceId, key), `Digest contribution '${key}' for resource '${resourceId}' must use its canonical key.`));
229
+ if (options.strictCanonicalInput && rawKey !== key) diagnostics.push(diagnostic$1("RESOURCE_DIGEST_CONTRIBUTION_NON_CANONICAL", contentLocation(resourceId, key), `Digest contribution '${key}' for resource '${resourceId}' must use its canonical key.`));
229
230
  const digest = typeof fact.digest === "string" ? fact.digest : "";
230
231
  if (!isSha256Digest(digest)) {
231
- diagnostics.push(diagnostic("RESOURCE_DIGEST_CONTRIBUTION_INVALID", contentLocation(resourceId, key), `Digest contribution '${key}' for resource '${resourceId || "unnamed"}' is invalid.`));
232
+ diagnostics.push(diagnostic$1("RESOURCE_DIGEST_CONTRIBUTION_INVALID", contentLocation(resourceId, key), `Digest contribution '${key}' for resource '${resourceId || "unnamed"}' is invalid.`));
232
233
  continue;
233
234
  }
234
235
  const sourceUri = fact.sourceUri;
235
236
  if (sourceUri !== void 0 && typeof sourceUri !== "string") {
236
- diagnostics.push(diagnostic("RESOURCE_DIGEST_CONTRIBUTION_SOURCE_INVALID", contentLocation(resourceId, key), `Digest contribution '${key}' for resource '${resourceId}' has an invalid source URI.`));
237
+ diagnostics.push(diagnostic$1("RESOURCE_DIGEST_CONTRIBUTION_SOURCE_INVALID", contentLocation(resourceId, key), `Digest contribution '${key}' for resource '${resourceId}' has an invalid source URI.`));
237
238
  continue;
238
239
  }
239
240
  const contribution = Object.freeze({
@@ -244,7 +245,7 @@ function normalizeContentIdentity(input, diagnostics, options) {
244
245
  const current = contributions.get(key);
245
246
  if (current) {
246
247
  const conflicting = current.digest !== digest;
247
- diagnostics.push(diagnostic(conflicting ? "RESOURCE_DIGEST_CONTRIBUTION_CONFLICT" : "RESOURCE_DIGEST_CONTRIBUTION_DUPLICATE", contentLocation(resourceId, key), conflicting ? `Digest contribution '${key}' for resource '${resourceId || "unnamed"}' has conflicting digests.` : `Digest contribution '${key}' for resource '${resourceId || "unnamed"}' is declared more than once.`));
248
+ diagnostics.push(diagnostic$1(conflicting ? "RESOURCE_DIGEST_CONTRIBUTION_CONFLICT" : "RESOURCE_DIGEST_CONTRIBUTION_DUPLICATE", contentLocation(resourceId, key), conflicting ? `Digest contribution '${key}' for resource '${resourceId || "unnamed"}' has conflicting digests.` : `Digest contribution '${key}' for resource '${resourceId || "unnamed"}' is declared more than once.`));
248
249
  continue;
249
250
  }
250
251
  contributions.set(key, contribution);
@@ -262,11 +263,11 @@ function normalizeContentIdentity(input, diagnostics, options) {
262
263
  if (options.validateClaimedDigest) {
263
264
  const claimedDigest = input.contentDigest;
264
265
  if (typeof claimedDigest !== "string" || !isSha256Digest(claimedDigest)) {
265
- diagnostics.push(diagnostic("RESOURCE_CONTENT_DIGEST_INVALID", contentLocation(resourceId), `Resource '${resourceId}' has an invalid claimed content digest.`));
266
+ diagnostics.push(diagnostic$1("RESOURCE_CONTENT_DIGEST_INVALID", contentLocation(resourceId), `Resource '${resourceId}' has an invalid claimed content digest.`));
266
267
  return;
267
268
  }
268
269
  if (claimedDigest !== contentDigest) {
269
- diagnostics.push(diagnostic("RESOURCE_CONTENT_DIGEST_MISMATCH", contentLocation(resourceId), `Resource '${resourceId}' claimed a content digest that does not match its explicit authority and contributions.`));
270
+ diagnostics.push(diagnostic$1("RESOURCE_CONTENT_DIGEST_MISMATCH", contentLocation(resourceId), `Resource '${resourceId}' claimed a content digest that does not match its explicit authority and contributions.`));
270
271
  return;
271
272
  }
272
273
  }
@@ -283,7 +284,7 @@ function validateEffectiveContentIdentities(registry, identities, diagnostics) {
283
284
  for (const entry of effectiveEntries) {
284
285
  const input = identities.get(entry.resourceId);
285
286
  if (input === void 0) {
286
- diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_MISSING", dependencyLocation(entry.resourceId), `Effective resource '${entry.resourceId}' has no explicit content identity.`));
287
+ diagnostics.push(diagnostic$1("RESOURCE_CONTENT_IDENTITY_MISSING", dependencyLocation(entry.resourceId), `Effective resource '${entry.resourceId}' has no explicit content identity.`));
287
288
  continue;
288
289
  }
289
290
  const identity = normalizeContentIdentity(input, diagnostics, {
@@ -298,7 +299,7 @@ function validateEffectiveContentIdentities(registry, identities, diagnostics) {
298
299
  function validateContentIdentityIndex(identities, diagnostics) {
299
300
  for (const [key, identity] of [...identities.entries()].sort(([left], [right]) => compareCodeUnits(left, right))) {
300
301
  const identityResourceId = isRecord(identity) && typeof identity.resourceId === "string" ? identity.resourceId : void 0;
301
- if (key !== identityResourceId) diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_KEY_MISMATCH", dependencyLocation(key), `Content identity index key '${key}' does not match identity '${identityResourceId ?? "invalid"}'.`));
302
+ if (key !== identityResourceId) diagnostics.push(diagnostic$1("RESOURCE_CONTENT_IDENTITY_KEY_MISMATCH", dependencyLocation(key), `Content identity index key '${key}' does not match identity '${identityResourceId ?? "invalid"}'.`));
302
303
  }
303
304
  }
304
305
  function isSha256Digest(value) {
@@ -344,10 +345,10 @@ function cloneOrigin(origin) {
344
345
  ...origin.logicalPath === void 0 ? {} : { logicalPath: origin.logicalPath }
345
346
  });
346
347
  }
347
- function stableDiagnostics(diagnostics) {
348
+ function stableDiagnostics$1(diagnostics) {
348
349
  return Object.freeze([...diagnostics].sort((left, right) => compareCodeUnits(left.location, right.location) || compareCodeUnits(left.code, right.code)));
349
350
  }
350
- function diagnostic(code, location, message) {
351
+ function diagnostic$1(code, location, message) {
351
352
  return Object.freeze({
352
353
  code,
353
354
  location,
@@ -371,6 +372,184 @@ function isLoadedResourceTreeAuthentic(tree) {
371
372
  return authenticLoadedResourceTrees.has(tree);
372
373
  }
373
374
  //#endregion
375
+ //#region ../resource-core/src/code-package.ts
376
+ const CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY = "code-binding:module";
377
+ /** @internal Node effect implementation bound by the public facade. */
378
+ const nodeCodePackageRuntime = Object.freeze({
379
+ realpath,
380
+ readFile,
381
+ stat,
382
+ importModule: async (url) => import(url)
383
+ });
384
+ var CodePackageLoadError = class extends Error {
385
+ diagnostics;
386
+ constructor(diagnostics) {
387
+ super(`CodePackage loading failed with ${diagnostics.length} diagnostic(s)`);
388
+ this.name = "CodePackageLoadError";
389
+ this.diagnostics = Object.freeze([...diagnostics]);
390
+ }
391
+ };
392
+ /** @internal Used by the canonical XNL loader before it brands the completed tree. */
393
+ function normalizeCodePackageBinding(record) {
394
+ const diagnostics = [];
395
+ if (record.sourceShape !== "code-package") {
396
+ diagnostics.push(diagnostic("RESOURCE_CODE_PACKAGE_SHAPE_INVALID", record.documentUri, `Resource '${record.resourceId}' does not use the code-package source shape.`));
397
+ return { diagnostics };
398
+ }
399
+ const node = record.node.subdomains.CodeBinding;
400
+ if (!node || node.tag !== "CodeBinding") {
401
+ diagnostics.push(diagnostic("RESOURCE_CODE_PACKAGE_BINDING_MISSING", record.documentUri, `CodePackage resource '${record.resourceId}' requires one CodeBinding.`));
402
+ return { diagnostics };
403
+ }
404
+ if (node.properties.package !== void 0) diagnostics.push(diagnostic("RESOURCE_CODE_PACKAGE_BINDING_INVALID", record.documentUri, `CodePackage resource '${record.resourceId}' must bind a package-local module, not an external package.`));
405
+ const rawModule = stringValue(node.properties.module);
406
+ const moduleUri = rawModule === void 0 ? void 0 : normalizeModuleUri(rawModule);
407
+ if (!moduleUri) diagnostics.push(diagnostic("RESOURCE_CODE_PACKAGE_MODULE_INVALID", record.documentUri, `CodePackage resource '${record.resourceId}' requires a canonical package-local .js or .mjs module URI.`));
408
+ const rawExport = node.properties.export;
409
+ const exportName = stringValue(rawExport);
410
+ if (rawExport !== void 0 && (!exportName || !/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(exportName))) diagnostics.push(diagnostic("RESOURCE_CODE_PACKAGE_EXPORT_INVALID", record.documentUri, `CodePackage resource '${record.resourceId}' has an invalid named export binding.`));
411
+ if (diagnostics.length > 0 || !moduleUri) return { diagnostics: stableDiagnostics(diagnostics) };
412
+ return {
413
+ binding: Object.freeze({
414
+ resourceId: record.resourceId,
415
+ moduleUri,
416
+ ...exportName ? { exportName } : {}
417
+ }),
418
+ diagnostics: Object.freeze([])
419
+ };
420
+ }
421
+ /** @internal Resolves and reads the exact entry bytes under the descriptor directory. */
422
+ async function readCodePackageEntry(runtime, rootDir, record, binding) {
423
+ const diagnostics = [];
424
+ const realRoot = await runtime.realpath(resolve(rootDir)).catch(() => void 0);
425
+ if (!realRoot) return { diagnostics: [diagnostic("RESOURCE_CODE_PACKAGE_ROOT_MISSING", record.documentUri, `The resource root for '${record.resourceId}' is missing or unreadable.`)] };
426
+ if (!isSafeLogicalPath(record.logicalPath)) return { diagnostics: [diagnostic("RESOURCE_CODE_PACKAGE_PROVENANCE_INVALID", record.documentUri, `CodePackage resource '${record.resourceId}' has unsafe logical provenance.`)] };
427
+ const descriptorPath = resolve(realRoot, record.logicalPath);
428
+ const descriptorDirectory = await runtime.realpath(dirname(descriptorPath)).catch(() => void 0);
429
+ if (!descriptorDirectory || !isWithin(realRoot, descriptorDirectory)) return { diagnostics: [diagnostic("RESOURCE_CODE_PACKAGE_ENTRY_CONTAINMENT", record.documentUri, `CodePackage resource '${record.resourceId}' resolves outside the resource root.`)] };
430
+ const localPath = moduleLocalPath(binding.moduleUri);
431
+ if (!localPath) return { diagnostics: [diagnostic("RESOURCE_CODE_PACKAGE_MODULE_INVALID", record.documentUri, `CodePackage resource '${record.resourceId}' has an invalid module URI.`)] };
432
+ const entryPath = await runtime.realpath(resolve(descriptorDirectory, ...localPath.split("/"))).catch(() => void 0);
433
+ if (!entryPath) return { diagnostics: [diagnostic("RESOURCE_CODE_PACKAGE_ENTRY_MISSING", `${record.documentUri}#CodeBinding`, `CodePackage entry is missing for '${record.resourceId}'.`)] };
434
+ if (!isWithin(descriptorDirectory, entryPath) || entryPath === descriptorDirectory) diagnostics.push(diagnostic("RESOURCE_CODE_PACKAGE_ENTRY_CONTAINMENT", `${record.documentUri}#CodeBinding`, `CodePackage entry for '${record.resourceId}' resolves outside its package directory.`));
435
+ if (!(await runtime.stat(entryPath).catch(() => void 0))?.isFile()) diagnostics.push(diagnostic("RESOURCE_CODE_PACKAGE_ENTRY_INVALID", `${record.documentUri}#CodeBinding`, `CodePackage entry for '${record.resourceId}' must be a regular file.`));
436
+ if (diagnostics.length > 0) return { diagnostics: stableDiagnostics(diagnostics) };
437
+ const bytes = await runtime.readFile(entryPath).catch(() => void 0);
438
+ if (!bytes) return { diagnostics: [diagnostic("RESOURCE_CODE_PACKAGE_ENTRY_MISSING", `${record.documentUri}#CodeBinding`, `CodePackage entry is unreadable for '${record.resourceId}'.`)] };
439
+ const resourceDirectory = posix.dirname(record.logicalPath);
440
+ return {
441
+ entryPath,
442
+ bytes,
443
+ sourceUri: `vfs://@/${resourceDirectory === "." ? localPath : `${resourceDirectory}/${localPath}`}`,
444
+ diagnostics: Object.freeze([])
445
+ };
446
+ }
447
+ async function loadCodePackageModule(input) {
448
+ return loadCodePackageModuleWithRuntime(nodeCodePackageRuntime, input);
449
+ }
450
+ /** @internal Pure orchestration over an injected effect runtime; hidden by the package facade. */
451
+ async function loadCodePackageModuleWithRuntime(runtime, input) {
452
+ if (!isLoadedResourceTreeAuthentic(input.tree)) throw loadError("RESOURCE_CODE_PACKAGE_TREE_UNTRUSTED", `code-package:${input.resourceId}`, "CodePackage modules require an authentic LoadedResourceTree.");
453
+ const record = findResource(input.tree, input.resourceId);
454
+ const binding = input.tree.codePackageBindings.get(input.resourceId);
455
+ const identity = input.tree.contentIdentities.get(input.resourceId);
456
+ if (!record || record.sourceShape !== "code-package" || !binding || !identity) throw loadError("RESOURCE_CODE_PACKAGE_RESOURCE_INVALID", `code-package:${input.resourceId}`, `Resource '${input.resourceId}' is not a loaded CodePackage.`);
457
+ const entry = await readCodePackageEntry(runtime, input.rootDir, record, binding);
458
+ if (entry.diagnostics.length > 0 || !entry.entryPath || !entry.bytes) throw new CodePackageLoadError(entry.diagnostics);
459
+ const contribution = identity.contributions.find((item) => item.key === CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY);
460
+ if (!contribution || contribution.digest !== sha256Digest(entry.bytes) || contribution.sourceUri !== entry.sourceUri) throw loadError("RESOURCE_CODE_PACKAGE_REVISION_STALE", `${record.documentUri}#CodeBinding`, `CodePackage entry for '${record.resourceId}' changed after its ResourceTree was loaded.`);
461
+ const url = `data:text/javascript;base64,${Buffer.concat([Buffer.from(entry.bytes), Buffer.from(`\n/* halfcode_revision=${identity.contentDigest} */\n`)]).toString("base64")}`;
462
+ let moduleNamespace;
463
+ try {
464
+ moduleNamespace = await runtime.importModule(url);
465
+ } catch {
466
+ throw loadError("RESOURCE_CODE_PACKAGE_IMPORT_FAILED", `${record.documentUri}#CodeBinding`, `CodePackage entry for '${record.resourceId}' could not be imported.`);
467
+ }
468
+ if (binding.exportName && !(binding.exportName in moduleNamespace)) throw loadError("RESOURCE_CODE_PACKAGE_EXPORT_MISSING", `${record.documentUri}#CodeBinding`, `CodePackage entry for '${record.resourceId}' does not export '${binding.exportName}'.`);
469
+ const currentBytes = await runtime.readFile(entry.entryPath).catch(() => void 0);
470
+ if (!currentBytes || sha256Digest(currentBytes) !== contribution.digest) throw loadError("RESOURCE_CODE_PACKAGE_REVISION_STALE", `${record.documentUri}#CodeBinding`, `CodePackage entry for '${record.resourceId}' changed while it was being imported.`);
471
+ const frozenNamespace = Object.freeze(Object.fromEntries(Object.keys(moduleNamespace).sort(compareCodeUnits).map((name) => [name, moduleNamespace[name]])));
472
+ return Object.freeze({
473
+ resourceId: record.resourceId,
474
+ binding,
475
+ revision: identity.contentDigest,
476
+ moduleNamespace: frozenNamespace
477
+ });
478
+ }
479
+ function admitCodePackageExports(loaded, contract) {
480
+ return admitCandidates([{
481
+ loaded,
482
+ contract
483
+ }]);
484
+ }
485
+ function admitCodePackages(loaded, contract) {
486
+ return admitCandidates(loaded.map((item) => ({
487
+ loaded: item,
488
+ contract
489
+ })));
490
+ }
491
+ function admitCandidates(packages) {
492
+ const definitions = /* @__PURE__ */ new Map();
493
+ for (const { loaded, contract } of packages) {
494
+ const names = loaded.binding.exportName ? [loaded.binding.exportName] : Object.keys(loaded.moduleNamespace).sort(compareCodeUnits);
495
+ for (const name of names) {
496
+ const exported = loaded.moduleNamespace[name];
497
+ const candidates = Array.isArray(exported) ? exported : [exported];
498
+ for (const candidate of candidates) {
499
+ if (!contract.isDefinition(candidate)) continue;
500
+ const identity = contract.identityOf(candidate).trim();
501
+ if (!identity) throw new TypeError(`CodePackage definition from '${loaded.resourceId}' has an empty identity`);
502
+ if (definitions.has(identity)) throw new TypeError(`Duplicate CodePackage definition identity '${identity}'`);
503
+ definitions.set(identity, candidate);
504
+ }
505
+ }
506
+ }
507
+ return Object.freeze([...definitions.entries()].sort(([left], [right]) => compareCodeUnits(left, right)).map(([, definition]) => definition));
508
+ }
509
+ function normalizeModuleUri(value) {
510
+ const prefix = "vfs://./";
511
+ if (!value.startsWith(prefix) || value !== value.trim() || value.includes("%") || value.includes("\\") || value.includes("?") || value.includes("#")) return void 0;
512
+ const localPath = value.slice(8);
513
+ if (!localPath || isAbsolute(localPath) || posix.isAbsolute(localPath)) return void 0;
514
+ const parts = localPath.split("/");
515
+ if (parts.some((part) => !part || part === "." || part === "..")) return void 0;
516
+ const extension = extname(localPath).toLowerCase();
517
+ if (extension !== ".js" && extension !== ".mjs") return void 0;
518
+ return `${prefix}${parts.join("/")}`;
519
+ }
520
+ function moduleLocalPath(moduleUri) {
521
+ return normalizeModuleUri(moduleUri)?.slice(8);
522
+ }
523
+ function findResource(tree, resourceId) {
524
+ for (const records of tree.registry.byKind.values()) {
525
+ const record = records.find((item) => item.resourceId === resourceId);
526
+ if (record) return record;
527
+ }
528
+ }
529
+ function isSafeLogicalPath(value) {
530
+ return Boolean(value) && !isAbsolute(value) && !value.includes("\\") && !value.split("/").some((part) => !part || part === "." || part === "..");
531
+ }
532
+ function isWithin(boundary, candidate) {
533
+ const path = relative(boundary, candidate);
534
+ return path === "" || !path.startsWith(`..${sep}`) && path !== ".." && !isAbsolute(path);
535
+ }
536
+ function stringValue(value) {
537
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
538
+ }
539
+ function loadError(code, location, message) {
540
+ return new CodePackageLoadError([diagnostic(code, location, message)]);
541
+ }
542
+ function stableDiagnostics(diagnostics) {
543
+ return Object.freeze([...diagnostics].sort((left, right) => compareCodeUnits(left.location, right.location) || compareCodeUnits(left.code, right.code)));
544
+ }
545
+ function diagnostic(code, location, message) {
546
+ return Object.freeze({
547
+ code,
548
+ location,
549
+ message
550
+ });
551
+ }
552
+ //#endregion
374
553
  //#region ../resource-core/src/readonly-map.ts
375
554
  function readonlyMap(entries) {
376
555
  const values = new Map(entries);
@@ -413,7 +592,9 @@ async function buildXnlResourceTree(options) {
413
592
  resources: [],
414
593
  seenIdentities: /* @__PURE__ */ new Map(),
415
594
  authorityFiles: /* @__PURE__ */ new Map(),
416
- recordAuthorityDigests: /* @__PURE__ */ new WeakMap()
595
+ recordAuthorityDigests: /* @__PURE__ */ new WeakMap(),
596
+ recordContributions: /* @__PURE__ */ new WeakMap(),
597
+ codePackageBindings: /* @__PURE__ */ new Map()
417
598
  };
418
599
  const manifest = await loadManifest(resolve(context.rootDir, options.manifestPath), "manifest", context, true);
419
600
  if (!manifest || context.diagnostics.length > 0) return { diagnostics: context.diagnostics };
@@ -426,6 +607,7 @@ async function buildXnlResourceTree(options) {
426
607
  const frozenByKind = readonlyMap([...byKind.entries()].sort(([left], [right]) => compareCodeUnits(left, right)).map(([kind, records]) => [kind, Object.freeze([...records].sort((left, right) => compareCodeUnits(left.resourceId, right.resourceId)))]));
427
608
  const frozenKindDefinitions = readonlyMap([...context.kindDefinitions.entries()].sort(([left], [right]) => compareCodeUnits(left, right)));
428
609
  const contentIdentities = readonlyMap(context.resources.map((resource) => [resource.resourceId, loadedContentIdentity(resource, context)]).sort(([left], [right]) => compareCodeUnits(left, right)));
610
+ const codePackageBindings = readonlyMap([...context.codePackageBindings.entries()].sort(([left], [right]) => compareCodeUnits(left, right)));
429
611
  return {
430
612
  diagnostics: [],
431
613
  tree: markLoadedResourceTreeAuthentic(Object.freeze({
@@ -435,7 +617,8 @@ async function buildXnlResourceTree(options) {
435
617
  kindDefinitions: frozenKindDefinitions
436
618
  }),
437
619
  diagnostics: Object.freeze([]),
438
- contentIdentities
620
+ contentIdentities,
621
+ codePackageBindings
439
622
  }))
440
623
  };
441
624
  }
@@ -524,6 +707,7 @@ async function loadCatalog(catalog, manifestDir, context) {
524
707
  }
525
708
  validateResourceApiVersion(record, definition, context.diagnostics);
526
709
  await validateRequiredFiles(dirname(file), record, definition, context.diagnostics);
710
+ if (catalog.shape === "code-package" && !await prepareCodePackageRecord(record, context)) continue;
527
711
  validateIdentity(record, context);
528
712
  context.resources.push(record);
529
713
  }
@@ -559,7 +743,7 @@ async function catalogFiles(catalog, manifestDir, context) {
559
743
  context.diagnostics.push({
560
744
  code: "RESOURCE_CATALOG_ENTRY_INVALID",
561
745
  location: catalog.location,
562
- message: "Directory and manifest catalogs require a plain XNL entry filename."
746
+ message: "Directory, manifest and code-package catalogs require a plain XNL entry filename."
563
747
  });
564
748
  return [];
565
749
  }
@@ -640,8 +824,25 @@ function loadedContentIdentity(resource, context) {
640
824
  if (!authorityDigest) throw new Error(`Loader authority digest is missing for ${resource.resourceId}`);
641
825
  return createResourceContentIdentity({
642
826
  resourceId: resource.resourceId,
643
- authorityDigest
827
+ authorityDigest,
828
+ contributions: context.recordContributions.get(resource) ?? []
829
+ });
830
+ }
831
+ async function prepareCodePackageRecord(record, context) {
832
+ const normalized = normalizeCodePackageBinding(record);
833
+ context.diagnostics.push(...normalized.diagnostics);
834
+ if (!normalized.binding) return false;
835
+ const entry = await readCodePackageEntry(nodeCodePackageRuntime, context.rootDir, record, normalized.binding);
836
+ context.diagnostics.push(...entry.diagnostics);
837
+ if (!entry.bytes || !entry.sourceUri) return false;
838
+ const contribution = Object.freeze({
839
+ key: CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY,
840
+ digest: sha256Digest(entry.bytes),
841
+ sourceUri: entry.sourceUri
644
842
  });
843
+ context.recordContributions.set(record, Object.freeze([contribution]));
844
+ context.codePackageBindings.set(record.resourceId, normalized.binding);
845
+ return true;
645
846
  }
646
847
  function resourceRecordFromRoot(root, filePath, sourceShape, context) {
647
848
  const documentUri = documentUriFor(context.rootDir, filePath);
@@ -877,7 +1078,7 @@ function kindMismatch(actual, expected, location) {
877
1078
  };
878
1079
  }
879
1080
  function isXnlShape(value) {
880
- return value === "single-file" || value === "directory" || value === "manifest";
1081
+ return value === "single-file" || value === "directory" || value === "manifest" || value === "code-package";
881
1082
  }
882
1083
  function isDocumentCardinality(value) {
883
1084
  return value === "one" || value === "many";
@@ -944,4 +1145,4 @@ function unsupportedAuthorityDiagnostic(options) {
944
1145
  };
945
1146
  }
946
1147
  //#endregion
947
- export { isLoadedResourceTreeAuthentic as a, sha256Digest as c, markEffectiveRegistryAuthentic as d, ResourceCompositionError as f, readonlyMap as i, effectiveRegistryLayerBindings as l, digestCanonical as m, loadResourceTree as n, buildResourceDependencySnapshot as o, compareCodeUnits as p, validateResourceTree as r, createResourceContentIdentity as s, ResourceValidationError as t, isEffectiveRegistryAuthentic as u };
1148
+ export { ResourceCompositionError as _, CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY as a, admitCodePackages as c, buildResourceDependencySnapshot as d, createResourceContentIdentity as f, markEffectiveRegistryAuthentic as g, isEffectiveRegistryAuthentic as h, readonlyMap as i, loadCodePackageModule as l, effectiveRegistryLayerBindings as m, loadResourceTree as n, CodePackageLoadError as o, sha256Digest as p, validateResourceTree as r, admitCodePackageExports as s, ResourceValidationError as t, isLoadedResourceTreeAuthentic as u, compareCodeUnits as v, digestCanonical as y };
@@ -1,4 +1,4 @@
1
- import { l as resourceRefToFqn, u as resolveObjectOperationCompilation } from "./src-DRIws6tY.js";
1
+ import { l as resourceRefToFqn, u as resolveObjectOperationCompilation } from "./src-6nezdi57.js";
2
2
  import { c as unsafeUnicodeCodeUnitIssue, i as planResourceMappings, o as safePathLexicalIssue, r as parseResourceMappings, t as ResourceMappingPathError } from "./src-25wZPUyX.js";
3
3
  import { lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
4
4
  import { basename, dirname, join, posix, resolve } from "node:path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "halfcode-compiler.xnl",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Compile XNL-described applications into runtime-ready skill capsules.",
5
5
  "type": "module",
6
6
  "private": false,