halfcode-compiler.xnl 0.2.9 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/application-assembly.d.ts +3 -2
- package/dist/application-assembly.js +2 -2
- package/dist/authoring-runtime.d.ts +30 -9
- package/dist/authoring-runtime.js +2 -2
- package/dist/code-execution-closure-CXORuheJ.d.ts +59 -0
- package/dist/{effective-content-identities-DV5fTr5Q.js → effective-content-identities-CV6XFBZy.js} +8 -8
- package/dist/{effective-content-identities-CSVFi-N5.d.ts → effective-content-identities-Cf0ygCXk.d.ts} +2 -2
- package/dist/{index-B515mMkO.d.ts → index-B9Pp3Zgj.d.ts} +10 -6
- package/dist/index-By8x4reS.d.ts +443 -0
- package/dist/{index-CF4nEkOi.d.ts → index-Csi_AIoU.d.ts} +1 -1
- package/dist/{index-Cqh9pEBa.d.ts → index-DEikbOFh.d.ts} +2 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.js +6 -5
- package/dist/kind-definition.d.ts +118 -10
- package/dist/kind-definition.js +826 -15
- package/dist/resource-core-CoTu6FNS.d.ts +48 -0
- package/dist/resource-core.d.ts +5 -4
- package/dist/resource-core.js +25 -11
- package/dist/resource-package-read-port-BLBb4cz5.d.ts +33 -0
- package/dist/resource-projection.d.ts +1 -1
- package/dist/skill-capsule.d.ts +2 -2
- package/dist/skill-capsule.js +1 -1
- package/dist/{src-3pnDAjBD.js → src-BX7wrSq1.js} +330 -8
- package/dist/{src-3MZLm339.js → src-MPJZB76z.js} +122 -20
- package/dist/{src-CaQ25rMj.js → src-QI7NRyC8.js} +11 -7
- package/dist/{src-D3qSzGFn.js → src-jggOQtq3.js} +511 -113
- package/dist/system-skills/resource-dsl/KindDefinitions/SkillCapsule/manifest.xnl +15 -3
- package/dist/system-skills/resource-dsl/KindDefinitions/WikiPage/manifest.xnl +15 -3
- package/dist/system-skills/resource-dsl/SkillCapsules/System/SKILL.metadata.yaml +1 -0
- package/dist/system-skills/resource-dsl/SkillCapsules/System/manifest.xnl +1 -1
- package/dist/system-skills/resource-dsl/SkillCapsules/System/resource-mappings.xnl +1 -1
- package/dist/system-skills/resource-dsl/WikiPages/documents/manifest.xnl +1 -1
- package/dist/system-skills/resource-dsl/WikiPages/files/manifest.xnl +1 -1
- package/dist/system-skills/resource-dsl/WikiPages/index/manifest.xnl +1 -1
- package/dist/system-skills/resource-dsl/WikiPages/language/manifest.xnl +1 -1
- package/dist/system-skills/resource-dsl/WikiPages/migration/manifest.xnl +1 -1
- package/dist/system-skills/resource-dsl/WikiPages/projections/manifest.xnl +1 -1
- package/dist/system-skills/resource-dsl/WikiPages/skill-capsules/manifest.xnl +1 -1
- package/dist/system-skills/resource-dsl/documents.md +33 -17
- package/dist/system-skills/resource-dsl/examples/function.xnl +1 -1
- package/dist/system-skills/resource-dsl/examples/kind-definition.xnl +15 -3
- package/dist/system-skills/resource-dsl/examples/resource-mappings.xnl +1 -1
- package/dist/system-skills/resource-dsl/examples/resource-package.xnl +1 -1
- package/dist/system-skills/resource-dsl/examples/skill-capsule-authoring.xnl +1 -1
- package/dist/system-skills/resource-dsl/examples/skill-capsule-devops.xnl +1 -1
- package/dist/system-skills/resource-dsl/examples/skill-capsule-kind-definition.xnl +14 -3
- package/dist/system-skills/resource-dsl/examples/skill-capsule-resource-dsl.xnl +1 -1
- package/dist/system-skills/resource-dsl/examples/skill-capsule-run.xnl +1 -1
- package/dist/system-skills/resource-dsl/index.md +5 -5
- package/dist/system-skills/resource-dsl/language.md +10 -8
- package/dist/system-skills/resource-dsl/manifest.xnl +1 -1
- package/dist/system-skills/resource-dsl/migration.md +6 -3
- package/dist/system-skills/resource-dsl/projections.md +7 -6
- package/dist/system-skills/resource-dsl/skill-capsules.md +8 -7
- package/dist/system-skills/sys-halfcode-resource-dsl.plan.js +84 -59
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/dist/index-CDIT65pI.d.ts +0 -192
- package/dist/resource-core-C0Fj-VJA.d.ts +0 -29
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ct as ResourceDigestContribution, et as ResourceMetadata, i as AuthoredResourceTree, p as ResourceDiagnostic } from "./index-By8x4reS.js";
|
|
2
|
+
import { a as ResourcePackageReadPort } from "./resource-package-read-port-BLBb4cz5.js";
|
|
3
|
+
//#region ../resource-core/src/composition-error.d.ts
|
|
4
|
+
declare class ResourceCompositionError extends Error {
|
|
5
|
+
readonly diagnostics: readonly ResourceDiagnostic[];
|
|
6
|
+
constructor(diagnostics: readonly ResourceDiagnostic[]);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region ../resource-core/src/resource-material.d.ts
|
|
10
|
+
interface ReadResourceMaterialInput {
|
|
11
|
+
readonly tree: AuthoredResourceTree;
|
|
12
|
+
readonly rootDir: string;
|
|
13
|
+
readonly resourceId: string;
|
|
14
|
+
readonly uri: string;
|
|
15
|
+
}
|
|
16
|
+
interface ResourceMaterial {
|
|
17
|
+
readonly resourceId: string;
|
|
18
|
+
readonly uri: string;
|
|
19
|
+
readonly sourceUri: string;
|
|
20
|
+
readonly digest: string;
|
|
21
|
+
readonly contribution: ResourceDigestContribution;
|
|
22
|
+
bytes(): Uint8Array;
|
|
23
|
+
}
|
|
24
|
+
declare class ResourceMaterialError extends Error {
|
|
25
|
+
readonly diagnostics: readonly ResourceDiagnostic[];
|
|
26
|
+
constructor(diagnostics: readonly ResourceDiagnostic[]);
|
|
27
|
+
}
|
|
28
|
+
declare function readResourceMaterial(input: ReadResourceMaterialInput): Promise<ResourceMaterial>;
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region ../resource-core/src/directory-resource-package-read-port.d.ts
|
|
31
|
+
declare function createDirectoryResourcePackageReadPort(rootDir: string): Promise<ResourcePackageReadPort>;
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region ../resource-core/src/resource-envelope.d.ts
|
|
34
|
+
interface ResourceMetadataDecodeInput {
|
|
35
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
36
|
+
readonly removedFieldContainers?: readonly Readonly<Record<string, unknown>>[];
|
|
37
|
+
readonly lifecycle?: unknown;
|
|
38
|
+
readonly location: string;
|
|
39
|
+
readonly source: "XNL" | "Markdown";
|
|
40
|
+
}
|
|
41
|
+
type ResourceMetadataDecodeResult = Readonly<{
|
|
42
|
+
metadata: ResourceMetadata;
|
|
43
|
+
}> | Readonly<{
|
|
44
|
+
diagnostic: ResourceDiagnostic;
|
|
45
|
+
}>;
|
|
46
|
+
declare function decodeResourceMetadata(input: ResourceMetadataDecodeInput): ResourceMetadataDecodeResult;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { ReadResourceMaterialInput as a, readResourceMaterial as c, createDirectoryResourcePackageReadPort as i, ResourceCompositionError as l, ResourceMetadataDecodeResult as n, ResourceMaterial as o, decodeResourceMetadata as r, ResourceMaterialError as s, ResourceMetadataDecodeInput as t };
|
package/dist/resource-core.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { a as
|
|
3
|
-
import { n as
|
|
4
|
-
|
|
1
|
+
import { $ as RESOURCE_ENVELOPE_VERSION, A as validateResourceTreeFromReadPort, B as KindSpecRevision, C as ResourceValue, Ct as Sha256Digest, D as loadResourceTree, E as SourceShape, Et as digestCanonical, F as KindContractLockReader, G as ReaderProfile, H as KindWriterRegistration, I as KindReaderRegistration, J as ResourceResolutionReceipt, K as ReaderTarget, L as KindSemanticContract, M as JsonSchema, N as JsonSchemaValidator, O as loadResourceTreeFromReadPort, P as KindContractLock, Q as RESOURCE_ENVELOPE_FINGERPRINT, R as KindSourceContract, S as ResourceValidationError, St as composeLayeredResourceRegistry, T as ResourceValueMap, Tt as compareCodeUnits, U as PortableSpec, V as KindSubjectOwner, W as PortableValue, X as CORE_BOOTSTRAP_WRITER_SPEC_VERSIONS, Y as SpecResolutionDefinition, Z as RESOURCE_ENVELOPE_CONTRACT, _ as ResourceRecord, _t as ResourceLayerDescriptor, a as AuthoredResourceTreeBuildResult, at as ResourceContentIdentity, b as ResourceTree, bt as ResourceTombstone, c as RegisteredKindDefinition, ct as ResourceDigestContribution, d as ResolvedResourceTree, dt as createResourceContentIdentity, et as ResourceMetadata, f as ResourceDescriptor, ft as sha256Digest, g as ResourceNode, gt as EffectiveResourceRegistry, h as ResourceKindContract, ht as EffectiveResourceEntry, i as AuthoredResourceTree, it as CreateResourceContentIdentityInput, j as CompatibilityPolicy, k as validateResourceTree, l as ResolvedResourceRecord, lt as SnapshotResource, m as ResourceIdentity, mt as EffectiveKindDefinition, n as AuthoredResourceRegistry, nt as isSpecVersion, o as KindSpecRevisionDescriptor, ot as ResourceDependencyEdge, p as ResourceDiagnostic, pt as ComposeLayeredResourceRegistryInput, q as ResolvedSpec, r as AuthoredResourceSpec, rt as BuildResourceDependencySnapshotInput, s as LoadResourceTreeOptions, st as ResourceDependencySnapshot, t as AuthoredResourceRecord, tt as SpecVersion, u as ResolvedResourceRegistry, ut as buildResourceDependencySnapshot, v as ResourceRegistry, vt as ResourceLayerInput, w as ResourceValueList, wt as canonicalJson, x as ResourceTreeBuildResult, xt as ResourceTombstoneOrigin, y as ResourceScalar, yt as ResourceOrigin, z as KindSourceShape } from "./index-By8x4reS.js";
|
|
2
|
+
import { a as ResourcePackageReadPort, c as canonicalResourcePackageSourcePath, d as relativeResourcePackageSourcePath, i as ResourcePackageEntryKind, l as dirnameResourcePackageSourcePath, n as ResourcePackageDirectoryEntry, o as ResourcePackageReadPortOptions, r as ResourcePackageEntry, s as ResourcePackageSourcePathError, t as ResourcePackageAwaitable, u as joinResourcePackageSourcePath } from "./resource-package-read-port-BLBb4cz5.js";
|
|
3
|
+
import { a as ReadResourceMaterialInput, c as readResourceMaterial, i as createDirectoryResourcePackageReadPort, l as ResourceCompositionError, n as ResourceMetadataDecodeResult, o as ResourceMaterial, r as decodeResourceMetadata, s as ResourceMaterialError, t as ResourceMetadataDecodeInput } from "./resource-core-CoTu6FNS.js";
|
|
4
|
+
import { n as ResourceLayerContentIdentityInput, r as resolveEffectiveResourceContentIdentities, t as ResolveEffectiveResourceContentIdentitiesInput } from "./effective-content-identities-Cf0ygCXk.js";
|
|
5
|
+
export { AuthoredResourceRecord, AuthoredResourceRegistry, AuthoredResourceSpec, AuthoredResourceTree, AuthoredResourceTreeBuildResult, BuildResourceDependencySnapshotInput, CORE_BOOTSTRAP_WRITER_SPEC_VERSIONS, CompatibilityPolicy, ComposeLayeredResourceRegistryInput, CreateResourceContentIdentityInput, EffectiveKindDefinition, EffectiveResourceEntry, EffectiveResourceRegistry, JsonSchema, JsonSchemaValidator, KindContractLock, KindContractLockReader, KindReaderRegistration, KindSemanticContract, KindSourceContract, KindSourceShape, KindSpecRevision, KindSpecRevisionDescriptor, KindSubjectOwner, KindWriterRegistration, LoadResourceTreeOptions, PortableSpec, PortableValue, RESOURCE_ENVELOPE_CONTRACT, RESOURCE_ENVELOPE_FINGERPRINT, RESOURCE_ENVELOPE_VERSION, ReadResourceMaterialInput, ReaderProfile, ReaderTarget, RegisteredKindDefinition, ResolveEffectiveResourceContentIdentitiesInput, ResolvedResourceRecord, ResolvedResourceRegistry, ResolvedResourceTree, ResolvedSpec, ResourceCompositionError, ResourceContentIdentity, ResourceDependencyEdge, ResourceDependencySnapshot, ResourceDescriptor, ResourceDiagnostic, ResourceDigestContribution, ResourceIdentity, ResourceKindContract, ResourceLayerContentIdentityInput, ResourceLayerDescriptor, ResourceLayerInput, ResourceMaterial, ResourceMaterialError, ResourceMetadata, ResourceMetadataDecodeInput, ResourceMetadataDecodeResult, ResourceNode, ResourceOrigin, ResourcePackageAwaitable, ResourcePackageDirectoryEntry, ResourcePackageEntry, ResourcePackageEntryKind, ResourcePackageReadPort, ResourcePackageReadPortOptions, ResourcePackageSourcePathError, ResourceRecord, ResourceRegistry, ResourceResolutionReceipt, ResourceScalar, ResourceTombstone, ResourceTombstoneOrigin, ResourceTree, ResourceTreeBuildResult, ResourceValidationError, ResourceValue, ResourceValueList, ResourceValueMap, type Sha256Digest, SnapshotResource, SourceShape, SpecResolutionDefinition, SpecVersion, buildResourceDependencySnapshot, canonicalJson, canonicalResourcePackageSourcePath, compareCodeUnits, composeLayeredResourceRegistry, createDirectoryResourcePackageReadPort, createResourceContentIdentity, decodeResourceMetadata, digestCanonical, dirnameResourcePackageSourcePath, isSpecVersion, joinResourcePackageSourcePath, loadResourceTree, loadResourceTreeFromReadPort, readResourceMaterial, relativeResourcePackageSourcePath, resolveEffectiveResourceContentIdentities, sha256Digest, validateResourceTree, validateResourceTreeFromReadPort };
|
package/dist/resource-core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as resolveEffectiveResourceContentIdentities } from "./effective-content-identities-
|
|
1
|
+
import { C as digestCanonical, D as dirnameResourcePackageSourcePath, E as canonicalResourcePackageSourcePath, O as joinResourcePackageSourcePath, S as compareCodeUnits, T as ResourcePackageSourcePathError, a as validateResourceTreeFromReadPort, b as ResourceCompositionError, c as RESOURCE_ENVELOPE_CONTRACT, d as isSpecVersion, f as readonlyMap, g as sha256Digest, h as createResourceContentIdentity, i as validateResourceTree, k as relativeResourcePackageSourcePath, l as RESOURCE_ENVELOPE_FINGERPRINT, m as buildResourceDependencySnapshot, n as loadResourceTree, o as decodeResourceMetadata, p as isAuthoredResourceTreeAuthentic, r as loadResourceTreeFromReadPort, s as CORE_BOOTSTRAP_WRITER_SPEC_VERSIONS, t as ResourceValidationError, u as RESOURCE_ENVELOPE_VERSION, w as createDirectoryResourcePackageReadPort, x as canonicalJson, y as markEffectiveRegistryAuthentic } from "./src-jggOQtq3.js";
|
|
2
|
+
import { t as resolveEffectiveResourceContentIdentities } from "./effective-content-identities-CV6XFBZy.js";
|
|
3
3
|
import { lstat, readFile, realpath } from "node:fs/promises";
|
|
4
4
|
import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
5
5
|
//#region ../resource-core/src/layered-registry.ts
|
|
@@ -236,9 +236,9 @@ function cloneResourceRecord(resource) {
|
|
|
236
236
|
}
|
|
237
237
|
function cloneResourceMetadata(metadata) {
|
|
238
238
|
return Object.freeze({
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
...metadata.
|
|
239
|
+
envelopeVersion: metadata.envelopeVersion,
|
|
240
|
+
specVersion: metadata.specVersion,
|
|
241
|
+
...metadata.lifecycle === void 0 ? {} : { lifecycle: metadata.lifecycle }
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
function cloneResourceValue(value) {
|
|
@@ -252,10 +252,17 @@ function cloneRegisteredKindDefinition(definition) {
|
|
|
252
252
|
return Object.freeze({
|
|
253
253
|
resourceId: definition.resourceId,
|
|
254
254
|
resourceKind: definition.resourceKind,
|
|
255
|
+
subjectFqn: definition.subjectFqn,
|
|
255
256
|
sourceShapes: Object.freeze([...definition.sourceShapes].sort(compareCodeUnits)),
|
|
256
257
|
requiredFiles: Object.freeze([...definition.requiredFiles].sort(compareCodeUnits)),
|
|
257
|
-
|
|
258
|
-
|
|
258
|
+
specRevisions: Object.freeze(definition.specRevisions.map((revision) => Object.freeze({
|
|
259
|
+
specVersion: revision.specVersion,
|
|
260
|
+
schemaRef: revision.schemaRef,
|
|
261
|
+
schemaFingerprint: revision.schemaFingerprint,
|
|
262
|
+
contractFingerprint: revision.contractFingerprint,
|
|
263
|
+
semanticContract: Object.freeze({ ...revision.semanticContract }),
|
|
264
|
+
stability: revision.stability
|
|
265
|
+
})).sort((left, right) => left.specVersion - right.specVersion)),
|
|
259
266
|
documentCardinality: definition.documentCardinality,
|
|
260
267
|
documentUri: definition.documentUri
|
|
261
268
|
});
|
|
@@ -263,10 +270,17 @@ function cloneRegisteredKindDefinition(definition) {
|
|
|
263
270
|
function normalizedKindContract(definition) {
|
|
264
271
|
return {
|
|
265
272
|
resourceKind: definition.resourceKind,
|
|
273
|
+
subjectFqn: definition.subjectFqn,
|
|
266
274
|
sourceShapes: [...definition.sourceShapes].sort(compareCodeUnits),
|
|
267
275
|
requiredFiles: [...definition.requiredFiles].sort(compareCodeUnits),
|
|
268
|
-
|
|
269
|
-
|
|
276
|
+
specRevisions: definition.specRevisions.map((revision) => ({
|
|
277
|
+
specVersion: revision.specVersion,
|
|
278
|
+
schemaRef: revision.schemaRef,
|
|
279
|
+
schemaFingerprint: revision.schemaFingerprint,
|
|
280
|
+
contractFingerprint: revision.contractFingerprint,
|
|
281
|
+
semanticContract: revision.semanticContract,
|
|
282
|
+
stability: revision.stability
|
|
283
|
+
})),
|
|
270
284
|
documentCardinality: definition.documentCardinality
|
|
271
285
|
};
|
|
272
286
|
}
|
|
@@ -326,7 +340,7 @@ var ResourceMaterialError = class extends Error {
|
|
|
326
340
|
}
|
|
327
341
|
};
|
|
328
342
|
async function readResourceMaterial(input) {
|
|
329
|
-
if (!
|
|
343
|
+
if (!isAuthoredResourceTreeAuthentic(input.tree)) throw materialError("RESOURCE_MATERIAL_TREE_UNTRUSTED", input.resourceId, "Resource materials require an authentic AuthoredResourceTree.");
|
|
330
344
|
const record = findResource(input.tree, input.resourceId);
|
|
331
345
|
const identity = input.tree.contentIdentities.get(input.resourceId);
|
|
332
346
|
if (!record || record.sourceShape !== "directory" || !identity) throw materialError("RESOURCE_MATERIAL_RESOURCE_INVALID", input.resourceId, `Resource '${input.resourceId}' is not an authentic directory resource.`);
|
|
@@ -400,4 +414,4 @@ function materialError(code, resourceId, message) {
|
|
|
400
414
|
})]);
|
|
401
415
|
}
|
|
402
416
|
//#endregion
|
|
403
|
-
export { ResourceCompositionError, ResourceMaterialError, ResourceValidationError, buildResourceDependencySnapshot, composeLayeredResourceRegistry, createResourceContentIdentity, loadResourceTree, readResourceMaterial, resolveEffectiveResourceContentIdentities, sha256Digest, validateResourceTree };
|
|
417
|
+
export { CORE_BOOTSTRAP_WRITER_SPEC_VERSIONS, RESOURCE_ENVELOPE_CONTRACT, RESOURCE_ENVELOPE_FINGERPRINT, RESOURCE_ENVELOPE_VERSION, ResourceCompositionError, ResourceMaterialError, ResourcePackageSourcePathError, ResourceValidationError, buildResourceDependencySnapshot, canonicalJson, canonicalResourcePackageSourcePath, compareCodeUnits, composeLayeredResourceRegistry, createDirectoryResourcePackageReadPort, createResourceContentIdentity, decodeResourceMetadata, digestCanonical, dirnameResourcePackageSourcePath, isSpecVersion, joinResourcePackageSourcePath, loadResourceTree, loadResourceTreeFromReadPort, readResourceMaterial, relativeResourcePackageSourcePath, resolveEffectiveResourceContentIdentities, sha256Digest, validateResourceTree, validateResourceTreeFromReadPort };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region ../resource-core/src/resource-package-read-port.d.ts
|
|
2
|
+
type ResourcePackageAwaitable<T> = T | PromiseLike<T>;
|
|
3
|
+
type ResourcePackageEntryKind = "file" | "directory" | "symlink" | "other";
|
|
4
|
+
interface ResourcePackageEntry {
|
|
5
|
+
readonly kind: ResourcePackageEntryKind;
|
|
6
|
+
}
|
|
7
|
+
interface ResourcePackageDirectoryEntry extends ResourcePackageEntry {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Storage-neutral source effect for one already-materialized ResourcePackage
|
|
12
|
+
* file view. Paths are canonical POSIX absolute coordinates scoped to the
|
|
13
|
+
* provider; they are never semantic resource provenance.
|
|
14
|
+
*/
|
|
15
|
+
interface ResourcePackageReadPort {
|
|
16
|
+
stat(sourcePath: string): ResourcePackageAwaitable<ResourcePackageEntry | undefined>;
|
|
17
|
+
readDirectory(sourcePath: string): ResourcePackageAwaitable<readonly ResourcePackageDirectoryEntry[] | undefined>;
|
|
18
|
+
readBytes(sourcePath: string): ResourcePackageAwaitable<Uint8Array | undefined>;
|
|
19
|
+
}
|
|
20
|
+
interface ResourcePackageReadPortOptions {
|
|
21
|
+
readonly port: ResourcePackageReadPort;
|
|
22
|
+
readonly rootPath?: string;
|
|
23
|
+
readonly manifestPath?: string;
|
|
24
|
+
}
|
|
25
|
+
declare class ResourcePackageSourcePathError extends TypeError {
|
|
26
|
+
constructor(message: string);
|
|
27
|
+
}
|
|
28
|
+
declare function canonicalResourcePackageSourcePath(input: string): string;
|
|
29
|
+
declare function joinResourcePackageSourcePath(base: string, ...segments: readonly string[]): string;
|
|
30
|
+
declare function dirnameResourcePackageSourcePath(sourcePath: string): string;
|
|
31
|
+
declare function relativeResourcePackageSourcePath(rootPath: string, sourcePath: string): string | undefined;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { ResourcePackageReadPort as a, canonicalResourcePackageSourcePath as c, relativeResourcePackageSourcePath as d, ResourcePackageEntryKind as i, dirnameResourcePackageSourcePath as l, ResourcePackageDirectoryEntry as n, ResourcePackageReadPortOptions as o, ResourcePackageEntry as r, ResourcePackageSourcePathError as s, ResourcePackageAwaitable as t, joinResourcePackageSourcePath as u };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as resourceProjectionPackage, t as ResourceRegistry } from "./index-
|
|
1
|
+
import { n as resourceProjectionPackage, t as ResourceRegistry } from "./index-Csi_AIoU.js";
|
|
2
2
|
export { ResourceRegistry, resourceProjectionPackage };
|
package/dist/skill-capsule.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { I as SkillCapsuleDependency } from "./index-
|
|
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-
|
|
1
|
+
import { I as SkillCapsuleDependency } from "./index-DEikbOFh.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-B9Pp3Zgj.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 };
|
package/dist/skill-capsule.js
CHANGED
|
@@ -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-
|
|
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-QI7NRyC8.js";
|
|
2
2
|
export { SkillCapsuleDistributionError, applySkillCapsuleDistributionPlan, compileResourceSkillCapsule, compileSkillCapsule, compilerSkillPackage, planSkillCapsuleDistribution, skillCapsuleDistributionProjection };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { n as loadResourceTree } from "./src-
|
|
1
|
+
import { E as canonicalResourcePackageSourcePath, n as loadResourceTree } from "./src-jggOQtq3.js";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { parse } from "yaml";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
import ts from "typescript";
|
|
5
7
|
//#region ../application-assembly/src/internal-bindings.ts
|
|
6
8
|
const bindingsByDefinition = /* @__PURE__ */ new WeakMap();
|
|
7
9
|
const compilationsByAssembly = /* @__PURE__ */ new WeakMap();
|
|
@@ -24,6 +26,328 @@ function resolveObjectOperationCompilation(assembly, operationRef) {
|
|
|
24
26
|
return compilation;
|
|
25
27
|
}
|
|
26
28
|
//#endregion
|
|
29
|
+
//#region ../application-assembly/src/code-execution-closure.ts
|
|
30
|
+
/** The complete emit profile is versioned; changing it invalidates old closures. */
|
|
31
|
+
const CODE_CLOSURE_COMPILER_IDENTITY = "typescript@5.9.3/commonjs-es2022-interop/closure-v2";
|
|
32
|
+
var CodeClosureError = class extends Error {
|
|
33
|
+
code;
|
|
34
|
+
constructor(code, message) {
|
|
35
|
+
super(`${code}: ${message}`);
|
|
36
|
+
this.code = code;
|
|
37
|
+
this.name = "CodeClosureError";
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
function fail$1(code, message) {
|
|
41
|
+
throw new CodeClosureError(code, message);
|
|
42
|
+
}
|
|
43
|
+
/** Reject active objects before reading values or invoking JSON serialization. */
|
|
44
|
+
function assertJsonData(value, ancestors = /* @__PURE__ */ new Set()) {
|
|
45
|
+
if (value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value)) return;
|
|
46
|
+
if (typeof value !== "object") fail$1("invalid-closure-data", "Expected closed JSON data");
|
|
47
|
+
if (ancestors.has(value)) fail$1("invalid-closure-data", "Cyclic closure data is unsupported");
|
|
48
|
+
const prototype = Object.getPrototypeOf(value);
|
|
49
|
+
if (prototype !== (Array.isArray(value) ? Array.prototype : Object.prototype) && prototype !== null) fail$1("invalid-closure-data", "Exotic closure objects are unsupported");
|
|
50
|
+
ancestors.add(value);
|
|
51
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
52
|
+
if (Array.isArray(value) && key === "length") continue;
|
|
53
|
+
const property = Object.getOwnPropertyDescriptor(value, key);
|
|
54
|
+
if (typeof key !== "string" || !property.enumerable || !("value" in property)) fail$1("invalid-closure-data", "Accessors and non-JSON properties are unsupported");
|
|
55
|
+
if (Array.isArray(value) && (!/^(0|[1-9]\d*)$/.test(key) || Number(key) >= value.length)) fail$1("invalid-closure-data", "Array properties must be indexes");
|
|
56
|
+
assertJsonData(property.value, ancestors);
|
|
57
|
+
}
|
|
58
|
+
if (Array.isArray(value) && Object.keys(value).length !== value.length) fail$1("invalid-closure-data", "Sparse arrays are unsupported");
|
|
59
|
+
ancestors.delete(value);
|
|
60
|
+
}
|
|
61
|
+
function comparePaths(a, b) {
|
|
62
|
+
if (a < b) return -1;
|
|
63
|
+
return a > b ? 1 : 0;
|
|
64
|
+
}
|
|
65
|
+
function stable(value) {
|
|
66
|
+
if (Array.isArray(value)) return `[${value.map(stable).join(",")}]`;
|
|
67
|
+
if (value !== null && typeof value === "object") return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stable(value[key])}`).join(",")}}`;
|
|
68
|
+
return JSON.stringify(value);
|
|
69
|
+
}
|
|
70
|
+
function digest(value) {
|
|
71
|
+
return createHash("sha256").update(stable(value)).digest("hex");
|
|
72
|
+
}
|
|
73
|
+
function contentDigest(value) {
|
|
74
|
+
return createHash("sha256").update(value).digest("hex");
|
|
75
|
+
}
|
|
76
|
+
function freeze(value) {
|
|
77
|
+
if (value && typeof value === "object") {
|
|
78
|
+
for (const child of Object.values(value)) freeze(child);
|
|
79
|
+
Object.freeze(value);
|
|
80
|
+
}
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
function relativePath(path) {
|
|
84
|
+
if (!path || path.startsWith("/") || path.includes("\\") || path.includes("\0") || path.includes("?") || path.includes("#") || path.split("/").some((part) => !part || part === "." || part === "..")) fail$1("invalid-path", `Noncanonical closure path: ${path}`);
|
|
85
|
+
return path;
|
|
86
|
+
}
|
|
87
|
+
function localTarget(from, specifier) {
|
|
88
|
+
if (!specifier.startsWith("./") && !specifier.startsWith("../")) fail$1("outside-source-root", `Unsupported local path ${specifier}`);
|
|
89
|
+
if (/[\\\0?#]/.test(specifier)) fail$1("invalid-path", `Unsupported module specifier ${specifier}`);
|
|
90
|
+
const parts = from.split("/").slice(0, -1);
|
|
91
|
+
for (const part of specifier.split("/")) {
|
|
92
|
+
if (part === ".") continue;
|
|
93
|
+
if (part === "..") {
|
|
94
|
+
if (!parts.length) fail$1("outside-source-root", `${from} imports outside source root: ${specifier}`);
|
|
95
|
+
parts.pop();
|
|
96
|
+
} else {
|
|
97
|
+
if (!part) fail$1("invalid-path", specifier);
|
|
98
|
+
parts.push(part);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return relativePath(parts.join("/"));
|
|
102
|
+
}
|
|
103
|
+
const codeExtension = /\.(?:[cm]?[jt]s)$/;
|
|
104
|
+
function candidates(target) {
|
|
105
|
+
if (codeExtension.test(target)) {
|
|
106
|
+
const substituted = target.replace(/\.js$/, ".ts").replace(/\.mjs$/, ".mts").replace(/\.cjs$/, ".cts");
|
|
107
|
+
return [.../* @__PURE__ */ new Set([substituted, target])];
|
|
108
|
+
}
|
|
109
|
+
if (/\.[^/]+$/.test(target)) return [target];
|
|
110
|
+
return [target, ...[
|
|
111
|
+
".ts",
|
|
112
|
+
".js",
|
|
113
|
+
".mts",
|
|
114
|
+
".mjs",
|
|
115
|
+
".cts",
|
|
116
|
+
".cjs",
|
|
117
|
+
"/index.ts",
|
|
118
|
+
"/index.js"
|
|
119
|
+
].map((extension) => target + extension)];
|
|
120
|
+
}
|
|
121
|
+
function checkEnvironment(environment) {
|
|
122
|
+
assertJsonData(environment);
|
|
123
|
+
if (!environment || typeof environment.hostIdentity !== "string" || !environment.hostIdentity || !environment.ambient || Array.isArray(environment.ambient) || typeof environment.ambient !== "object") fail$1("invalid-environment", "Expected host identity and ambient identities");
|
|
124
|
+
for (const [specifier, identity] of Object.entries(environment.ambient)) if (!specifier || specifier.startsWith(".") || specifier.startsWith("/") || /[\\\0]/.test(specifier) || typeof identity !== "string" || !identity) fail$1("invalid-environment", `Invalid ambient identity: ${specifier}`);
|
|
125
|
+
}
|
|
126
|
+
function bindingEntry(binding) {
|
|
127
|
+
if (!binding || typeof binding.packageName !== "string" || !binding.packageName || typeof binding.exportName !== "string" || !binding.exportName || typeof binding.module !== "string" || !binding.module.startsWith("./")) fail$1("invalid-binding", "Closure binding requires a package-owned ./ module and export");
|
|
128
|
+
const entry = relativePath(binding.module.slice(2));
|
|
129
|
+
if (binding.moduleSpecifier !== `${binding.packageName}/${entry}`) fail$1("invalid-binding", "CodeBinding moduleSpecifier does not match package/module");
|
|
130
|
+
return entry;
|
|
131
|
+
}
|
|
132
|
+
function compile(path, source) {
|
|
133
|
+
if (ts.version !== "5.9.3") fail$1("compiler-mismatch", `Expected TypeScript 5.9.3; found ${ts.version}`);
|
|
134
|
+
const tree = ts.createSourceFile(path, source, ts.ScriptTarget.ES2022, true, /\.[cm]?js$/.test(path) ? ts.ScriptKind.JS : ts.ScriptKind.TS);
|
|
135
|
+
const specifiers = /* @__PURE__ */ new Set();
|
|
136
|
+
const walk = (node, functionDepth) => {
|
|
137
|
+
if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) fail$1("unsupported-dynamic-import", `${path}: dynamic import cannot be frozen`);
|
|
138
|
+
if (ts.isIdentifier(node) && node.text === "require") fail$1("unsupported-require", `${path}: require and aliases are unsupported; use static imports`);
|
|
139
|
+
if (ts.isImportEqualsDeclaration(node)) fail$1("unsupported-require", `${path}: import-equals is unsupported`);
|
|
140
|
+
if (ts.isMetaProperty(node) && node.keywordToken === ts.SyntaxKind.ImportKeyword) fail$1("unsupported-import-meta", `${path}: import.meta is unsupported`);
|
|
141
|
+
if (!functionDepth && (ts.isAwaitExpression(node) || ts.isForOfStatement(node) && node.awaitModifier)) fail$1("unsupported-top-level-await", `${path}: top-level await is unsupported`);
|
|
142
|
+
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier) {
|
|
143
|
+
if (ts.isImportDeclaration(node) && node.importClause) {
|
|
144
|
+
const clause = node.importClause;
|
|
145
|
+
if (clause.isTypeOnly || !clause.name && clause.namedBindings && ts.isNamedImports(clause.namedBindings) && clause.namedBindings.elements.length > 0 && clause.namedBindings.elements.every((element) => element.isTypeOnly)) return;
|
|
146
|
+
}
|
|
147
|
+
if (ts.isExportDeclaration(node) && (node.isTypeOnly || node.exportClause && ts.isNamedExports(node.exportClause) && node.exportClause.elements.length > 0 && node.exportClause.elements.every((element) => element.isTypeOnly))) return;
|
|
148
|
+
if (!ts.isStringLiteral(node.moduleSpecifier)) fail$1("unsupported-import", `${path}: module specifier must be a string literal`);
|
|
149
|
+
if (node.attributes) fail$1("unsupported-import-attributes", `${path}: use declared closure assets without import attributes`);
|
|
150
|
+
specifiers.add(node.moduleSpecifier.text);
|
|
151
|
+
}
|
|
152
|
+
ts.forEachChild(node, (child) => walk(child, functionDepth + (ts.isFunctionLike(node) ? 1 : 0)));
|
|
153
|
+
};
|
|
154
|
+
walk(tree, 0);
|
|
155
|
+
const emitPath = path.replace(/\.mts$/, ".ts").replace(/\.mjs$/, ".js");
|
|
156
|
+
const emitted = ts.transpileModule(source, {
|
|
157
|
+
fileName: emitPath,
|
|
158
|
+
reportDiagnostics: true,
|
|
159
|
+
compilerOptions: {
|
|
160
|
+
target: ts.ScriptTarget.ES2022,
|
|
161
|
+
module: ts.ModuleKind.CommonJS,
|
|
162
|
+
esModuleInterop: true,
|
|
163
|
+
sourceMap: false,
|
|
164
|
+
inlineSourceMap: false,
|
|
165
|
+
removeComments: false
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
const errors = emitted.diagnostics?.filter((item) => item.category === ts.DiagnosticCategory.Error) ?? [];
|
|
169
|
+
if (errors.length) fail$1("invalid-source", `${path}: ${errors.map((item) => ts.flattenDiagnosticMessageText(item.messageText, " ")).join("; ")}`);
|
|
170
|
+
return {
|
|
171
|
+
code: emitted.outputText,
|
|
172
|
+
specifiers: [...specifiers].sort()
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
async function captureCodeClosure(runtime, input) {
|
|
176
|
+
checkEnvironment(input.environment);
|
|
177
|
+
const root = canonicalResourcePackageSourcePath(input.sourceRoot);
|
|
178
|
+
const sourcePath = canonicalResourcePackageSourcePath(input.entryPath);
|
|
179
|
+
const bindingPath = bindingEntry(input.binding);
|
|
180
|
+
const absolute = (path) => root === "/" ? `/${path}` : `${root}/${path}`;
|
|
181
|
+
const entryPath = candidates(bindingPath).find((candidate) => absolute(candidate) === sourcePath);
|
|
182
|
+
if (!entryPath) fail$1("invalid-binding", "entryPath must resolve CodeBinding.module within sourceRoot");
|
|
183
|
+
const declarations = { ...input.assets };
|
|
184
|
+
for (const [path, format] of Object.entries(declarations)) {
|
|
185
|
+
relativePath(path);
|
|
186
|
+
if (format !== "text" && format !== "json") fail$1("invalid-asset", `Unsupported asset format: ${format}`);
|
|
187
|
+
if (codeExtension.test(path)) fail$1("invalid-asset", `Code cannot be declared as an asset: ${path}`);
|
|
188
|
+
}
|
|
189
|
+
const modules = /* @__PURE__ */ new Map();
|
|
190
|
+
const assets = /* @__PURE__ */ new Map();
|
|
191
|
+
const hasFile = async (path) => {
|
|
192
|
+
const segments = absolute(path).slice(1).split("/");
|
|
193
|
+
for (let i = 1; i <= segments.length; i++) {
|
|
194
|
+
const prefix = `/${segments.slice(0, i).join("/")}`;
|
|
195
|
+
const info = await runtime.source.stat(prefix);
|
|
196
|
+
if (info?.kind === "symlink") fail$1("symlink-source", `Symlink source is unsupported: ${prefix}`);
|
|
197
|
+
if (i === segments.length) return info?.kind === "file";
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
};
|
|
201
|
+
const read = async (path) => {
|
|
202
|
+
if (!await hasFile(path)) fail$1("missing-source", `Missing source file: ${path}`);
|
|
203
|
+
const bytes = await runtime.source.readBytes(absolute(path));
|
|
204
|
+
if (!bytes) fail$1("missing-source", `Unreadable source file: ${path}`);
|
|
205
|
+
try {
|
|
206
|
+
return new TextDecoder("utf-8", {
|
|
207
|
+
fatal: true,
|
|
208
|
+
ignoreBOM: true
|
|
209
|
+
}).decode(bytes);
|
|
210
|
+
} catch {
|
|
211
|
+
return fail$1("invalid-source", `Expected UTF-8: ${path}`);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const visit = async (path) => {
|
|
215
|
+
if (modules.has(path)) return;
|
|
216
|
+
if (!codeExtension.test(path) || /\.d\.[cm]?ts$/.test(path)) fail$1("unsupported-module", `Expected executable TS/JS module: ${path}`);
|
|
217
|
+
const source = await read(path);
|
|
218
|
+
const result = compile(path, source);
|
|
219
|
+
const dependencies = [];
|
|
220
|
+
modules.set(path, {
|
|
221
|
+
path,
|
|
222
|
+
source,
|
|
223
|
+
sourceDigest: contentDigest(source),
|
|
224
|
+
code: result.code,
|
|
225
|
+
codeDigest: contentDigest(result.code),
|
|
226
|
+
dependencies
|
|
227
|
+
});
|
|
228
|
+
for (const specifier of result.specifiers) if (specifier.startsWith(".")) {
|
|
229
|
+
const target = localTarget(path, specifier);
|
|
230
|
+
if (Object.hasOwn(declarations, target)) dependencies.push({
|
|
231
|
+
specifier,
|
|
232
|
+
kind: "asset",
|
|
233
|
+
target
|
|
234
|
+
});
|
|
235
|
+
else {
|
|
236
|
+
if (!codeExtension.test(target) && /\.[^/]+$/.test(target)) fail$1("undeclared-asset", `${path}: asset must be declared: ${specifier}`);
|
|
237
|
+
let resolved;
|
|
238
|
+
for (const candidate of candidates(target)) if (await hasFile(candidate)) {
|
|
239
|
+
resolved = candidate;
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
if (!resolved) fail$1("missing-module", `${path}: cannot freeze ${specifier}`);
|
|
243
|
+
dependencies.push({
|
|
244
|
+
specifier,
|
|
245
|
+
kind: "module",
|
|
246
|
+
target: resolved
|
|
247
|
+
});
|
|
248
|
+
await visit(resolved);
|
|
249
|
+
}
|
|
250
|
+
} else {
|
|
251
|
+
if (specifier.startsWith("/") || specifier.startsWith("file:") || specifier.includes("\\")) fail$1("outside-source-root", `${path}: ${specifier}`);
|
|
252
|
+
if (!Object.hasOwn(input.environment.ambient, specifier)) fail$1("undeclared-ambient", `${path}: ambient dependency not declared: ${specifier}`);
|
|
253
|
+
dependencies.push({
|
|
254
|
+
specifier,
|
|
255
|
+
kind: "ambient",
|
|
256
|
+
target: specifier
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
await visit(entryPath);
|
|
261
|
+
for (const [path, format] of Object.entries(declarations).sort(([a], [b]) => comparePaths(a, b))) {
|
|
262
|
+
const content = await read(path);
|
|
263
|
+
if (format === "json") try {
|
|
264
|
+
JSON.parse(content);
|
|
265
|
+
} catch {
|
|
266
|
+
fail$1("invalid-asset", `Invalid JSON asset: ${path}`);
|
|
267
|
+
}
|
|
268
|
+
assets.set(path, {
|
|
269
|
+
path,
|
|
270
|
+
format,
|
|
271
|
+
content,
|
|
272
|
+
contentDigest: contentDigest(content)
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
const payload = {
|
|
276
|
+
format: "halfcode-code-closure/v1",
|
|
277
|
+
compilerIdentity: CODE_CLOSURE_COMPILER_IDENTITY,
|
|
278
|
+
binding: { ...input.binding },
|
|
279
|
+
entryPath,
|
|
280
|
+
environment: {
|
|
281
|
+
hostIdentity: input.environment.hostIdentity,
|
|
282
|
+
ambient: { ...input.environment.ambient }
|
|
283
|
+
},
|
|
284
|
+
modules: [...modules.values()].sort((a, b) => comparePaths(a.path, b.path)),
|
|
285
|
+
assets: [...assets.values()]
|
|
286
|
+
};
|
|
287
|
+
const closure = {
|
|
288
|
+
...payload,
|
|
289
|
+
digest: digest(payload)
|
|
290
|
+
};
|
|
291
|
+
validateCodeClosure(closure, input.environment, closure.digest);
|
|
292
|
+
return freeze(closure);
|
|
293
|
+
}
|
|
294
|
+
/** Pure validation: no source reader, live imports, or module execution. */
|
|
295
|
+
function validateCodeClosure(closure, environment, expectedDigest) {
|
|
296
|
+
if (typeof expectedDigest !== "string" || !/^[a-f0-9]{64}$/.test(expectedDigest)) fail$1("invalid-digest", "A trusted expected digest is required");
|
|
297
|
+
assertJsonData(closure);
|
|
298
|
+
if (!closure || typeof closure !== "object" || closure.digest !== expectedDigest) fail$1("digest-mismatch", "Closure differs from the trusted expected digest");
|
|
299
|
+
const { digest: actualDigest, ...payload } = closure;
|
|
300
|
+
if (digest(payload) !== actualDigest) fail$1("digest-mismatch", "Closure contents do not match digest");
|
|
301
|
+
if (closure.format !== "halfcode-code-closure/v1") fail$1("unsupported-format", "Unsupported code closure format");
|
|
302
|
+
if (closure.compilerIdentity !== "typescript@5.9.3/commonjs-es2022-interop/closure-v2" || ts.version !== "5.9.3") fail$1("compiler-mismatch", "Closure compiler identity mismatch");
|
|
303
|
+
checkEnvironment(environment);
|
|
304
|
+
checkEnvironment(closure.environment);
|
|
305
|
+
if (stable(environment) !== stable(closure.environment)) fail$1("environment-mismatch", "Execution environment identity mismatch");
|
|
306
|
+
if (!candidates(bindingEntry(closure.binding)).includes(closure.entryPath)) fail$1("invalid-binding", "Closure entry does not match binding");
|
|
307
|
+
if (!Array.isArray(closure.modules) || !Array.isArray(closure.assets)) fail$1("invalid-closure", "Expected modules and assets");
|
|
308
|
+
const modules = /* @__PURE__ */ new Map();
|
|
309
|
+
const assets = /* @__PURE__ */ new Map();
|
|
310
|
+
for (const module of closure.modules) {
|
|
311
|
+
relativePath(module.path);
|
|
312
|
+
if (!codeExtension.test(module.path) || /\.d\.[cm]?ts$/.test(module.path) || modules.has(module.path) || typeof module.source !== "string" || typeof module.code !== "string" || !Array.isArray(module.dependencies)) fail$1("invalid-module", `Invalid module: ${module.path}`);
|
|
313
|
+
if (module.sourceDigest !== contentDigest(module.source) || module.codeDigest !== contentDigest(module.code)) fail$1("file-digest-mismatch", `Module content digest mismatch: ${module.path}`);
|
|
314
|
+
modules.set(module.path, module);
|
|
315
|
+
}
|
|
316
|
+
for (const asset of closure.assets) {
|
|
317
|
+
relativePath(asset.path);
|
|
318
|
+
if (assets.has(asset.path) || modules.has(asset.path) || codeExtension.test(asset.path) || typeof asset.content !== "string" || !["text", "json"].includes(asset.format)) fail$1("invalid-asset", `Invalid asset: ${asset.path}`);
|
|
319
|
+
if (asset.contentDigest !== contentDigest(asset.content)) fail$1("file-digest-mismatch", `Asset content digest mismatch: ${asset.path}`);
|
|
320
|
+
if (asset.format === "json") try {
|
|
321
|
+
JSON.parse(asset.content);
|
|
322
|
+
} catch {
|
|
323
|
+
fail$1("invalid-asset", `Invalid JSON asset: ${asset.path}`);
|
|
324
|
+
}
|
|
325
|
+
assets.set(asset.path, asset);
|
|
326
|
+
}
|
|
327
|
+
if (!modules.has(closure.entryPath)) fail$1("missing-entry", "Closure entry module is absent");
|
|
328
|
+
for (const module of modules.values()) {
|
|
329
|
+
const compiled = compile(module.path, module.source);
|
|
330
|
+
if (compiled.code !== module.code) fail$1("invalid-emit", `Compiled code differs from frozen source: ${module.path}`);
|
|
331
|
+
if (stable(compiled.specifiers) !== stable(module.dependencies.map((edge) => edge.specifier).sort())) fail$1("invalid-edge", `Dependency set differs from source: ${module.path}`);
|
|
332
|
+
for (const edge of module.dependencies) {
|
|
333
|
+
if (edge.specifier.startsWith(".")) {
|
|
334
|
+
const target = localTarget(module.path, edge.specifier);
|
|
335
|
+
if (edge.kind === "asset" && edge.target === target && assets.has(edge.target)) continue;
|
|
336
|
+
if (edge.kind === "module" && candidates(target).includes(edge.target) && modules.has(edge.target)) continue;
|
|
337
|
+
} else if (edge.kind === "ambient" && edge.target === edge.specifier && Object.hasOwn(environment.ambient, edge.target) && !edge.target.startsWith("/") && !edge.target.startsWith("file:")) continue;
|
|
338
|
+
fail$1("invalid-edge", `Invalid dependency target: ${module.path} -> ${edge.specifier}`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const reachable = /* @__PURE__ */ new Set();
|
|
342
|
+
const visit = (path) => {
|
|
343
|
+
if (reachable.has(path)) return;
|
|
344
|
+
reachable.add(path);
|
|
345
|
+
for (const edge of modules.get(path).dependencies) if (edge.kind === "module") visit(edge.target);
|
|
346
|
+
};
|
|
347
|
+
visit(closure.entryPath);
|
|
348
|
+
if (reachable.size !== modules.size) fail$1("invalid-closure", "Closure contains unreachable modules");
|
|
349
|
+
}
|
|
350
|
+
//#endregion
|
|
27
351
|
//#region ../application-assembly/src/index.ts
|
|
28
352
|
var ObjectOperationContractError = class extends TypeError {
|
|
29
353
|
code;
|
|
@@ -388,14 +712,11 @@ async function readTextResource(module, record, kind) {
|
|
|
388
712
|
async function readSkillCapsule(module, record) {
|
|
389
713
|
const metadataMaterial = await readRequiredMaterial(module, record, "SkillMetadata");
|
|
390
714
|
const template = await readRequiredMaterial(module, record, "Template");
|
|
391
|
-
const version = record.metadata.version;
|
|
392
|
-
const apiVersion = record.metadata.apiVersion;
|
|
393
|
-
if (!apiVersion) throw new Error(`SKILL_CAPSULE_API_VERSION_MISSING: ${record.logicalPath} is missing XNL metadata apiVersion`);
|
|
394
|
-
if (!version) throw new Error(`SKILL_CAPSULE_VERSION_MISSING: ${record.logicalPath} is missing XNL metadata version`);
|
|
395
715
|
const parsedMetadata = parse(metadataMaterial.content);
|
|
396
716
|
if (!parsedMetadata || typeof parsedMetadata !== "object" || Array.isArray(parsedMetadata)) throw new Error(`SKILL_CAPSULE_METADATA_INVALID: ${record.logicalPath} Skill metadata must be a YAML object`);
|
|
397
717
|
const yamlVersion = parsedMetadata.version;
|
|
398
|
-
if (yamlVersion !==
|
|
718
|
+
if (typeof yamlVersion !== "string" || !yamlVersion.trim()) throw new Error(`SKILL_CAPSULE_VERSION_MISSING: ${record.logicalPath} Skill metadata must declare a non-empty version`);
|
|
719
|
+
const version = yamlVersion.trim();
|
|
399
720
|
const hasXnlName = Object.prototype.hasOwnProperty.call(record.node.properties, "name");
|
|
400
721
|
const xnlName = stringResourceValue(record.node.properties.name);
|
|
401
722
|
if (hasXnlName && !xnlName) throw new Error(`SKILL_CAPSULE_NAME_INVALID: ${requiredFqn(record)} XNL name must be a non-empty string`);
|
|
@@ -404,7 +725,8 @@ async function readSkillCapsule(module, record) {
|
|
|
404
725
|
kind: "SkillCapsule",
|
|
405
726
|
fqn: requiredFqn(record),
|
|
406
727
|
...xnlName ? { name: xnlName } : {},
|
|
407
|
-
|
|
728
|
+
envelopeVersion: record.metadata.envelopeVersion,
|
|
729
|
+
specVersion: record.metadata.specVersion,
|
|
408
730
|
version,
|
|
409
731
|
description: requiredDescription(record),
|
|
410
732
|
metadata: {
|
|
@@ -644,4 +966,4 @@ const applicationAssemblyPackage = {
|
|
|
644
966
|
owns: "resource registry facts normalized for target-neutral compiler projections"
|
|
645
967
|
};
|
|
646
968
|
//#endregion
|
|
647
|
-
export { assertObjectOperationCatalog as a, resolveApplicationAssembly as c, assertObjectOperationCall as i, resourceRefToFqn as l, applicationAssemblyPackage as n, assertObjectOperationDefinition as o, assertExecuteObjectOperationRequest as r, loadApplicationAssembly as s, ObjectOperationContractError as t,
|
|
969
|
+
export { assertObjectOperationCatalog as a, resolveApplicationAssembly as c, CodeClosureError as d, captureCodeClosure as f, assertObjectOperationCall as i, resourceRefToFqn as l, resolveObjectOperationCompilation as m, applicationAssemblyPackage as n, assertObjectOperationDefinition as o, validateCodeClosure as p, assertExecuteObjectOperationRequest as r, loadApplicationAssembly as s, ObjectOperationContractError as t, CODE_CLOSURE_COMPILER_IDENTITY as u };
|