@forgeax/engine-pack 0.1.31 → 0.1.33

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.
Files changed (40) hide show
  1. package/README.md +2 -2
  2. package/dist/build.d.ts +1 -1
  3. package/dist/build.d.ts.map +1 -1
  4. package/dist/build.mjs +252 -22
  5. package/dist/build.mjs.map +1 -1
  6. package/dist/cli-asset.d.ts +63 -0
  7. package/dist/cli-asset.d.ts.map +1 -1
  8. package/dist/cli-asset.mjs +142 -4
  9. package/dist/cli-asset.mjs.map +1 -1
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/native-cooker-registry.d.ts.map +1 -1
  12. package/dist/native-cooker.mjs +13 -1
  13. package/dist/native-cooker.mjs.map +1 -1
  14. package/dist/pack-authoring-node.d.ts +6 -0
  15. package/dist/pack-authoring-node.d.ts.map +1 -1
  16. package/dist/pack-authoring-node.mjs +230 -16
  17. package/dist/pack-authoring-node.mjs.map +1 -1
  18. package/dist/pack-authoring.d.ts +26 -0
  19. package/dist/pack-authoring.d.ts.map +1 -1
  20. package/dist/pack-authoring.mjs.map +1 -1
  21. package/dist/runtime-publication.d.ts +8 -0
  22. package/dist/runtime-publication.d.ts.map +1 -1
  23. package/dist/scanner.d.ts +1 -1
  24. package/dist/scanner.mjs +5 -5
  25. package/dist/scanner.mjs.map +1 -1
  26. package/dist/scriptable-pack-node.mjs.map +1 -1
  27. package/dist/scriptable-pack.mjs.map +1 -1
  28. package/package.json +2 -2
  29. package/src/__tests__/cli.unit.test.ts +87 -0
  30. package/src/__tests__/native-cooker-registry.test.ts +16 -0
  31. package/src/__tests__/pack-authoring-gateway.unit.test.ts +120 -1
  32. package/src/__tests__/pack.unit.test.ts +6 -6
  33. package/src/__tests__/runtime-publication.unit.test.ts +27 -1
  34. package/src/build.ts +2 -0
  35. package/src/cli-asset.ts +227 -5
  36. package/src/native-cooker-registry.ts +14 -1
  37. package/src/pack-authoring-node.ts +278 -13
  38. package/src/pack-authoring.ts +26 -0
  39. package/src/runtime-publication.ts +44 -0
  40. package/src/scanner.ts +5 -5
package/README.md CHANGED
@@ -495,9 +495,9 @@ this package does not publish an independent executable.
495
495
 
496
496
  | Subcommand | Description | Exit code |
497
497
  |:--|:--|:--|
498
- | `forgeax asset list --root <project> --json` | Print discovered `PackEntry` objects | 0 on valid roots |
498
+ | `forgeax asset list --root <project> --json` | Print a bounded page (default `limit=100`, maximum 256); add `--type` and `--cursor` to continue | 0 on valid roots |
499
499
  | `forgeax asset inspect --subject <guid> --root <project> --json` | Print matching asset evidence | 0 found / 1 not found |
500
- | `forgeax asset verify --root <project> --json` | Run the fail-fast scanner and return the first structured `PackError` | 0 clean / 1 error |
500
+ | `forgeax asset verify --root <project> --json` | Run the fail-fast scanner and return a bounded `asset-verification-v1` source/output report | 0 clean / 1 error |
501
501
 
502
502
  ```bash
503
503
  # Direct invocation (after pnpm -F @forgeax/engine-pack build)
package/dist/build.d.ts CHANGED
@@ -17,7 +17,7 @@ export { type FinalizedPackageProduct, finalizePackageProduct, finalizePackageTr
17
17
  export { validateProducerContract, validateProducerOutputs } from './producer-contract.js';
18
18
  export { resolveAssetSource } from './resolve-asset-source.js';
19
19
  export { parsePackV2, validateMeta, validatePack, validatePackV2 } from './runtime.js';
20
- export { createRuntimePackPublication, type RuntimePackAssetInput, type RuntimePackEnvelope, type RuntimePackInput, type RuntimePackPublication, type RuntimePackPublicationInput, } from './runtime-publication.js';
20
+ export { bindRuntimePackScope, createRuntimePackPublication, type RuntimePackAssetInput, type RuntimePackEnvelope, type RuntimePackInput, type RuntimePackPublication, type RuntimePackPublicationInput, stripRuntimePackLifecycle, } from './runtime-publication.js';
21
21
  export { type InventoryDeclaration, type LegacyPackInventoryDocument, type PackInventoryAsset, type PackInventoryDocument, type PackSourceInventoryDocument, type ScanInventory, type ScanOptions, type ScanSourceDeclaration, type ScriptablePackInventoryDeclaration, type ScriptablePackScanOptions, STANDARD_SCRIPTABLE_PACK_SCAN_OPTIONS, scanInventory, } from './scanner.js';
22
22
  export { type AssetReader, isScriptablePackAssetKind, projectScriptablePackSceneComponents, SCRIPTABLE_PACK_ASSET_KINDS, type ScriptablePackAssetKind, type ScriptablePackReadError, type ScriptablePackSourceClosureEntry, } from './scriptable-pack.js';
23
23
  export { calculateTopologyDiff, diffTopology } from './topology.js';
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,aAAa,EACb,cAAc,EACd,KAAK,EACL,cAAc,EACd,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,EACT,MAAM,EACN,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,aAAa,EACb,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,UAAU,GACX,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EACL,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,6BAA6B,EAClC,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,oBAAoB,EACpB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,oBAAoB,EACpB,oBAAoB,EACpB,6BAA6B,EAC7B,KAAK,mBAAmB,EACxB,yBAAyB,EACzB,6BAA6B,EAC7B,qBAAqB,EACrB,wBAAwB,EACxB,KAAK,sBAAsB,GAC5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,oBAAoB,EACzB,uBAAuB,EACvB,4BAA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yBAAyB,EAC9B,qCAAqC,EACrC,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,WAAW,EAChB,yBAAyB,EACzB,oCAAoC,EACpC,2BAA2B,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,GACtC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
package/dist/build.mjs CHANGED
@@ -9254,11 +9254,11 @@ function record(value) {
9254
9254
  return value !== null && typeof value === "object" && !Array.isArray(value);
9255
9255
  }
9256
9256
  var STANDARD_SCRIPTABLE_PACK_SCAN_OPTIONS = Object.freeze({
9257
- // Scriptable Packs execute in an isolated worker. A cold worker must
9258
- // compile the authored source closure before it can return metadata;
9259
- // heavy procedural packs otherwise make the shared catalog fall back to
9260
- // an empty degraded projection at the old 15-second budget.
9261
- timeoutMs: 6e4
9257
+ // Scriptable Packs execute in an isolated worker. A cold worker must compile
9258
+ // the authored source closure before it can return metadata. Keep the bound
9259
+ // finite while allowing a heavy character/scene closure to complete on a
9260
+ // busy host.
9261
+ timeoutMs: 12e4
9262
9262
  });
9263
9263
  var BLACKLIST = /* @__PURE__ */ new Set([
9264
9264
  "node_modules",
@@ -10971,6 +10971,7 @@ function decodeMeshBinHeader(bytes, sourceKey2 = "<unknown mesh source>") {
10971
10971
  }
10972
10972
  };
10973
10973
  }
10974
+ var VERIFY_PROVENANCE_LIMIT = 256;
10974
10975
  function isRecord3(value) {
10975
10976
  return value !== null && typeof value === "object" && !Array.isArray(value);
10976
10977
  }
@@ -11267,6 +11268,54 @@ async function readMaterialized(options, operation) {
11267
11268
  );
11268
11269
  return ok(materialized);
11269
11270
  }
11271
+ async function readAdditionalKnownGuids(options, operation) {
11272
+ let rawGuids;
11273
+ try {
11274
+ rawGuids = await options.additionalKnownGuids?.() ?? [];
11275
+ } catch (cause) {
11276
+ return err(
11277
+ makeError(
11278
+ "pack-parameter-invalid",
11279
+ "the additionalKnownGuids callback to return current Catalog GUIDs",
11280
+ "repair the build-owner Catalog projection callback, then retry the Pack operation",
11281
+ {
11282
+ requestId: operation.requestId,
11283
+ cause: cause instanceof Error ? cause.message : String(cause)
11284
+ }
11285
+ )
11286
+ );
11287
+ }
11288
+ if (!Array.isArray(rawGuids)) {
11289
+ return err(
11290
+ makeError(
11291
+ "pack-parameter-invalid",
11292
+ "additionalKnownGuids to be an array of AssetGuid strings",
11293
+ "repair the build-owner Catalog projection before querying Pack authoring",
11294
+ { requestId: operation.requestId, actual: typeof rawGuids }
11295
+ )
11296
+ );
11297
+ }
11298
+ const guids = [];
11299
+ const seen = /* @__PURE__ */ new Set();
11300
+ for (const candidate of rawGuids) {
11301
+ if (typeof candidate !== "string" || !isValidAssetGuidString(candidate)) {
11302
+ return err(
11303
+ makeError(
11304
+ "pack-parameter-invalid",
11305
+ "additionalKnownGuids to contain valid AssetGuid strings",
11306
+ "repair the build-owner Catalog projection before querying Pack authoring",
11307
+ { requestId: operation.requestId, guid: candidate }
11308
+ )
11309
+ );
11310
+ }
11311
+ const guid = candidate.toLowerCase();
11312
+ if (!seen.has(guid)) {
11313
+ seen.add(guid);
11314
+ guids.push(guid);
11315
+ }
11316
+ }
11317
+ return ok(guids);
11318
+ }
11270
11319
  async function createSnapshot(options, operation) {
11271
11320
  const scanned = options.inventory === void 0 ? await scanInventory(scanRoots(options)) : await options.inventory();
11272
11321
  if (!scanned.ok) return err(scanFailure(operation, scanned.error));
@@ -11322,6 +11371,8 @@ async function createSnapshot(options, operation) {
11322
11371
  }
11323
11372
  const materializedResult = await readMaterialized(options, operation);
11324
11373
  if (!materializedResult.ok) return materializedResult;
11374
+ const additionalKnownGuidsResult = await readAdditionalKnownGuids(options, operation);
11375
+ if (!additionalKnownGuidsResult.ok) return additionalKnownGuidsResult;
11325
11376
  const materialized = materializedResult.value;
11326
11377
  const guidOwners = /* @__PURE__ */ new Map();
11327
11378
  const directPairs = /* @__PURE__ */ new Set();
@@ -11373,7 +11424,8 @@ async function createSnapshot(options, operation) {
11373
11424
  const knownGuids = /* @__PURE__ */ new Set([
11374
11425
  ...scanned.value.inventory.map((entry) => entry.guid.toLowerCase()),
11375
11426
  ...directAssets.map((asset) => asset.guid),
11376
- ...materialized.map((asset) => asset.guid)
11427
+ ...materialized.map((asset) => asset.guid),
11428
+ ...additionalKnownGuidsResult.value
11377
11429
  ]);
11378
11430
  return ok({ inventory: scanned.value, subjects, directAssets, materialized, knownGuids });
11379
11431
  }
@@ -11514,6 +11566,15 @@ async function inspectAsset(gameRoot, snapshot, operation) {
11514
11566
  const selected = subjectFor(gameRoot, snapshot, operation);
11515
11567
  if (!selected.ok) return selected;
11516
11568
  const subject = selected.value;
11569
+ const source = await readConfined({ gameRoot }, operation, subject.relativePath);
11570
+ if (!source.ok) return source;
11571
+ const inspectedSource = {
11572
+ ...sourceResult(subject, operation),
11573
+ revision: source.value.revision,
11574
+ ...subject.format === "source" ? {
11575
+ assets: snapshot.materialized.filter((asset) => asset.packageId === packageKey(subject.packageId)).map((asset) => ({ ...asset }))
11576
+ } : {}
11577
+ };
11517
11578
  if (operation.sourceKey !== void 0) {
11518
11579
  if (!isValidPackSourceKey(operation.sourceKey)) {
11519
11580
  return err(
@@ -11546,7 +11607,7 @@ async function inspectAsset(gameRoot, snapshot, operation) {
11546
11607
  (candidate) => candidate.packageId === packageKey(subject.packageId) && candidate.sourceKey === operation.sourceKey
11547
11608
  );
11548
11609
  return ok({
11549
- ...sourceResult(subject, operation),
11610
+ ...inspectedSource,
11550
11611
  sourceKey: asset.sourceKey,
11551
11612
  guid: asset.guid,
11552
11613
  kind: asset.kind,
@@ -11559,7 +11620,7 @@ async function inspectAsset(gameRoot, snapshot, operation) {
11559
11620
  (candidate) => candidate.packageId === packageKey(subject.packageId) && candidate.sourceKey === operation.sourceKey
11560
11621
  );
11561
11622
  return ok({
11562
- ...sourceResult(subject, operation),
11623
+ ...inspectedSource,
11563
11624
  sourceKey: operation.sourceKey,
11564
11625
  guid,
11565
11626
  ...materialized === void 0 ? { status: "identity" } : {
@@ -11583,7 +11644,7 @@ async function inspectAsset(gameRoot, snapshot, operation) {
11583
11644
  const resolved = await resolveInstance(snapshot, subject);
11584
11645
  if (!resolved.ok) return resolved;
11585
11646
  return ok({
11586
- ...sourceResult(subject, operation),
11647
+ ...inspectedSource,
11587
11648
  parameters: resolved.value.parameters.map((parameter) => ({
11588
11649
  name: parameter.name,
11589
11650
  type: parameter.type,
@@ -11597,7 +11658,7 @@ async function inspectAsset(gameRoot, snapshot, operation) {
11597
11658
  parentChain: resolved.value.parentChain
11598
11659
  });
11599
11660
  }
11600
- return ok(sourceResult(subject, operation));
11661
+ return ok(inspectedSource);
11601
11662
  }
11602
11663
  function listAssets(snapshot, operation) {
11603
11664
  const assets = snapshotAssets(snapshot).map((asset) => ({
@@ -11880,7 +11941,164 @@ async function resolveAsset(gameRoot, snapshot, operation) {
11880
11941
  }
11881
11942
  });
11882
11943
  }
11883
- async function verify(snapshot, operation) {
11944
+ function verificationSourceFormat(gameRoot, sourcePath, fallback = "pack.ts") {
11945
+ if (sourcePath === void 0) return fallback;
11946
+ const absolute = resolve(gameRoot, sourcePath);
11947
+ if (absolute.endsWith(".meta.json")) return "meta.json";
11948
+ if (absolute.endsWith(".pack.json")) return "pack.json";
11949
+ if (absolute.endsWith(".pack.ts")) return "pack.ts";
11950
+ return fallback;
11951
+ }
11952
+ function verificationAuthorFacts(snapshot, entry) {
11953
+ const declaration = snapshot.inventory.declarations.get(entry.sourcePath);
11954
+ if (declaration?.format === "meta.json") {
11955
+ const asset = declaration.value.subAssets.find(
11956
+ (candidate) => candidate.guid.toLowerCase() === entry.guid.toLowerCase()
11957
+ );
11958
+ return {
11959
+ ...asset?.name === void 0 && asset?.sourceKey === void 0 ? {} : { name: asset.name ?? asset.sourceKey },
11960
+ dependencies: []
11961
+ };
11962
+ }
11963
+ if (declaration?.format === "pack.json") {
11964
+ if (declaration.value.schemaVersion === "3.0.0") {
11965
+ const parsed = parsePackSourceJson(declaration.value);
11966
+ if (parsed.ok && parsed.value.format === "direct" && entry.sourceKey !== void 0) {
11967
+ const asset = parsed.value.assets[entry.sourceKey];
11968
+ return {
11969
+ ...asset?.name === void 0 ? {} : { name: asset.name },
11970
+ dependencies: asset?.refs ?? []
11971
+ };
11972
+ }
11973
+ } else {
11974
+ const asset = declaration.value.assets.find(
11975
+ (candidate) => candidate.guid.toLowerCase() === entry.guid.toLowerCase()
11976
+ );
11977
+ return {
11978
+ ...asset?.name === void 0 ? {} : { name: asset.name },
11979
+ dependencies: asset?.refs ?? []
11980
+ };
11981
+ }
11982
+ }
11983
+ return { dependencies: [] };
11984
+ }
11985
+ function verificationOutput(materialized, legacyPublished = false) {
11986
+ if (materialized !== void 0) {
11987
+ return {
11988
+ status: materialized.ready ? "produced" : "unknown",
11989
+ availability: materialized.ready ? "available" : "unknown",
11990
+ freshness: "unknown"
11991
+ };
11992
+ }
11993
+ if (legacyPublished) {
11994
+ return {
11995
+ status: "produced",
11996
+ availability: "unknown",
11997
+ freshness: "unknown"
11998
+ // A legacy Pack row is a validated published declaration. The bytes
11999
+ // remain outside this read-only gateway, so availability is unknown.
12000
+ };
12001
+ }
12002
+ return { status: "unproduced", availability: "unknown", freshness: "unknown" };
12003
+ }
12004
+ function createGatewayVerificationReport(gameRoot, snapshot) {
12005
+ const materializedByGuid = new Map(
12006
+ snapshot.materialized.map((asset) => [asset.guid.toLowerCase(), asset])
12007
+ );
12008
+ const rows = /* @__PURE__ */ new Map();
12009
+ for (const entry of snapshot.inventory.inventory) {
12010
+ const declaration = snapshot.inventory.declarations.get(entry.sourcePath);
12011
+ const format = declaration?.format ?? verificationSourceFormat(gameRoot, entry.sourcePath);
12012
+ const facts = verificationAuthorFacts(snapshot, entry);
12013
+ const materialized = materializedByGuid.get(entry.guid.toLowerCase());
12014
+ const legacyPublished = declaration?.format === "pack.json" && declaration.value.schemaVersion !== "3.0.0";
12015
+ rows.set(entry.guid.toLowerCase(), {
12016
+ guid: entry.guid,
12017
+ type: entry.kind,
12018
+ source: {
12019
+ path: entry.sourcePath,
12020
+ format,
12021
+ role: "author",
12022
+ ...entry.sourceRevision === void 0 ? {} : { revision: entry.sourceRevision }
12023
+ },
12024
+ output: verificationOutput(materialized, legacyPublished),
12025
+ dependencies: facts.dependencies,
12026
+ producer: {
12027
+ state: materialized !== void 0 ? "published" : legacyPublished ? "published" : "not-run"
12028
+ },
12029
+ ...facts.name === void 0 ? {} : { name: facts.name },
12030
+ ...entry.sourceKey === void 0 ? {} : { sourceKey: entry.sourceKey },
12031
+ ...entry.sourceIndex === void 0 ? {} : { sourceIndex: entry.sourceIndex }
12032
+ });
12033
+ }
12034
+ for (const asset of snapshot.materialized) {
12035
+ const key = asset.guid.toLowerCase();
12036
+ if (rows.has(key)) continue;
12037
+ const sourcePath = asset.sourcePath === void 0 ? void 0 : resolve(gameRoot, asset.sourcePath);
12038
+ const declaration = sourcePath === void 0 ? void 0 : snapshot.inventory.declarations.get(sourcePath);
12039
+ const format = declaration?.format ?? verificationSourceFormat(gameRoot, asset.sourcePath);
12040
+ rows.set(key, {
12041
+ guid: asset.guid,
12042
+ type: asset.kind,
12043
+ source: {
12044
+ path: sourcePath ?? `${asset.packageId}/${asset.sourceKey}`,
12045
+ format,
12046
+ role: "author",
12047
+ ...declaration === void 0 ? {} : { revision: declaration.sourceRevision }
12048
+ },
12049
+ output: verificationOutput(asset),
12050
+ dependencies: asset.refs ?? [],
12051
+ producer: { state: "published" },
12052
+ sourceKey: asset.sourceKey
12053
+ });
12054
+ }
12055
+ const assets = [...rows.values()].sort(
12056
+ (left, right) => `${left.source.path}:${left.guid}`.localeCompare(`${right.source.path}:${right.guid}`)
12057
+ );
12058
+ const emitted = assets.slice(0, VERIFY_PROVENANCE_LIMIT);
12059
+ const sourcePaths = [...snapshot.inventory.declarations.keys()].sort();
12060
+ const scriptablePackSources = [...snapshot.inventory.declarations.values()].filter((declaration) => declaration.format === "pack.ts").sort((left, right) => left.sourcePath.localeCompare(right.sourcePath));
12061
+ const unmaterializedScriptable = scriptablePackSources.filter(
12062
+ (source) => !snapshot.materialized.some(
12063
+ (asset) => asset.packageId === source.value.packageId.toLowerCase() || asset.sourcePath !== void 0 && resolve(gameRoot, asset.sourcePath) === source.sourcePath
12064
+ )
12065
+ );
12066
+ return {
12067
+ schemaVersion: "asset-verification-v1",
12068
+ root: resolve(gameRoot),
12069
+ operation: "asset.verify",
12070
+ requestId: "gateway",
12071
+ scope: {
12072
+ sourceCount: sourcePaths.length,
12073
+ assetCount: assets.length,
12074
+ sourcePaths: sourcePaths.slice(0, VERIFY_PROVENANCE_LIMIT),
12075
+ omittedSourceCount: Math.max(0, sourcePaths.length - VERIFY_PROVENANCE_LIMIT),
12076
+ assetLimit: VERIFY_PROVENANCE_LIMIT,
12077
+ truncated: assets.length > VERIFY_PROVENANCE_LIMIT,
12078
+ scriptablePackSourceCount: scriptablePackSources.length,
12079
+ scriptablePackSources: unmaterializedScriptable.slice(0, VERIFY_PROVENANCE_LIMIT).map((source) => ({
12080
+ sourcePath: source.sourcePath,
12081
+ packageId: source.value.packageId,
12082
+ output: "unproduced",
12083
+ reason: "producer-not-run"
12084
+ })),
12085
+ omittedScriptablePackSourceCount: Math.max(
12086
+ 0,
12087
+ unmaterializedScriptable.length - VERIFY_PROVENANCE_LIMIT
12088
+ )
12089
+ },
12090
+ assets: emitted,
12091
+ summary: {
12092
+ assetCount: assets.length,
12093
+ emittedAssetCount: emitted.length,
12094
+ materialCount: assets.filter((asset) => asset.type === "material").length,
12095
+ unproducedAssetCount: assets.filter((asset) => asset.output.status === "unproduced").length,
12096
+ unknownAssetCount: assets.filter((asset) => asset.output.status === "unknown").length,
12097
+ unmaterializedScriptablePackCount: unmaterializedScriptable.length
12098
+ }
12099
+ };
12100
+ }
12101
+ async function verify(gameRoot, snapshot, operation) {
11884
12102
  for (const subject of snapshot.subjects.values()) {
11885
12103
  if (subject.format === "instance") {
11886
12104
  const resolved = await resolveInstance(snapshot, subject);
@@ -11925,14 +12143,8 @@ async function verify(snapshot, operation) {
11925
12143
  );
11926
12144
  }
11927
12145
  }
11928
- return ok({
11929
- operation: operation.operation,
11930
- requestId: operation.requestId,
11931
- snapshot: {
11932
- sourceCount: snapshot.subjects.size,
11933
- assetCount: snapshotAssets(snapshot).length
11934
- }
11935
- });
12146
+ const report = createGatewayVerificationReport(gameRoot, snapshot);
12147
+ return ok({ ...report, operation: operation.operation, requestId: operation.requestId });
11936
12148
  }
11937
12149
  function packageIdFromOperation(snapshot, operation) {
11938
12150
  const value = operation.packageId === void 0 ? ok(PackageId.random()) : PackageId.parse(operation.packageId);
@@ -12032,7 +12244,8 @@ async function executeRaw(options, operation) {
12032
12244
  if (!snapshot.ok) return snapshot;
12033
12245
  if (operation.operation === "asset.resolve")
12034
12246
  return resolveAsset(options.gameRoot, snapshot.value, operation);
12035
- if (operation.operation === "asset.verify") return verify(snapshot.value, operation);
12247
+ if (operation.operation === "asset.verify")
12248
+ return verify(options.gameRoot, snapshot.value, operation);
12036
12249
  if (operation.operation === "asset-source.create") {
12037
12250
  const path = confinedPath(
12038
12251
  options.gameRoot,
@@ -12545,7 +12758,8 @@ async function executeRaw(options, operation) {
12545
12758
  refreshed.value.source,
12546
12759
  selected.value.packageId,
12547
12760
  {
12548
- format: refreshed.value.relative.endsWith(".pack.json") ? "pack.json" : "pack.ts"
12761
+ format: refreshed.value.relative.endsWith(".pack.json") ? "pack.json" : "pack.ts",
12762
+ assets: refreshedSnapshot.value.materialized.filter((asset) => asset.packageId === packageKey(selected.value.packageId)).map((asset) => ({ ...asset }))
12549
12763
  }
12550
12764
  );
12551
12765
  }
@@ -12799,6 +13013,22 @@ function parsePackV2(value) {
12799
13013
  }
12800
13014
  return ok(value);
12801
13015
  }
13016
+ function isRuntimePackEnvelope(value) {
13017
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
13018
+ const record2 = value;
13019
+ return record2.schemaVersion === "2.0.0" && record2.kind === "internal-text-package" && typeof record2.scopeId === "string" && record2.scopeId.length > 0 && typeof record2.generation === "number" && Number.isSafeInteger(record2.generation) && record2.generation > 0 && Array.isArray(record2.assets);
13020
+ }
13021
+ function stripRuntimePackLifecycle(value) {
13022
+ if (!isRuntimePackEnvelope(value)) return value;
13023
+ const { scopeId: _scopeId, generation: _generation, ...semantic } = value;
13024
+ return semantic;
13025
+ }
13026
+ function bindRuntimePackScope(value, scopeId, generation) {
13027
+ if (value === null || typeof value !== "object" || Array.isArray(value) || value.schemaVersion !== "2.0.0" || value.kind !== "internal-text-package" || !Array.isArray(value.assets)) {
13028
+ return value;
13029
+ }
13030
+ return { ...value, scopeId, generation };
13031
+ }
12802
13032
  function stable(value) {
12803
13033
  if (value instanceof Uint8Array) return `bytes:${Buffer.from(value).toString("base64")}`;
12804
13034
  if (Array.isArray(value)) return `[${value.map(stable).join(",")}]`;
@@ -12908,6 +13138,6 @@ function createRuntimePackPublication(input) {
12908
13138
  };
12909
13139
  }
12910
13140
 
12911
- export { AssetGuid, MESH_BIN_DIGEST_BYTES, MESH_BIN_HEADER_V4_BYTES, MESH_BIN_PROJECTION_VERSION, MESH_BIN_VERSION, PACK_AUTHORING_OPERATION_DESCRIPTORS, PACK_AUTHORING_OPERATION_IDS, PACK_PARAMETER_TYPES, PACK_SOURCE_KEY_RE, PackageId, SCRIPTABLE_PACK_ASSET_KINDS, STANDARD_SCRIPTABLE_PACK_SCAN_OPTIONS, buildCatalogProjection, buildOfflineAssetEvidence, calculateCatalogDelta, calculateTopologyDiff, catalogProjectionFor, catalogSourcePathFor, collectMaterialCookRefs, createFileSystemPackAuthoringGateway, createFileSystemPackAuthoringPort, createMaterialArtifactDigest, createPackAuthoringGateway, createRuntimePackPublication, currentProjectionFor, decodeMeshBinHeader, definePack, definePackageId, diffTopology, finalizePackageProduct, finalizePackageTransportSource, findReservedAssetKindConflict, hasPackParameters, inventoryDigest, isScriptablePackAssetKind, isValidAssetGuidString, isValidPackSourceKey, metaPathForGuid, packageTransportRevision, packageVerification, parsePackSourceJson, parsePackV2, projectAssetRefs, projectCookedMaterialRecord, projectCookedPackageEntry, projectDirectPackJson, projectExternalCatalogEntries, projectPackageCatalog, projectRuntimeCatalogRow, projectSceneEntityRefs, projectScriptablePackMeta, projectScriptablePackSceneComponents, resolveAssetSource, resolvePackInheritance, resolvePackParameterInheritance, resolvePackParameterValues, scanInventory, serializeCookedMaterialRecord, serializeMaterialCookReceipt, syncAuthorInventory, validateArtifactPath, validateAuthorInventory, validateCookedMaterialRecord, validateMaterialCookReceipt, validateMeta, validatePack, validatePackDefinition, validatePackV2, validateProducerContract, validateProducerOutputs, writeMeshBinHeader };
13141
+ export { AssetGuid, MESH_BIN_DIGEST_BYTES, MESH_BIN_HEADER_V4_BYTES, MESH_BIN_PROJECTION_VERSION, MESH_BIN_VERSION, PACK_AUTHORING_OPERATION_DESCRIPTORS, PACK_AUTHORING_OPERATION_IDS, PACK_PARAMETER_TYPES, PACK_SOURCE_KEY_RE, PackageId, SCRIPTABLE_PACK_ASSET_KINDS, STANDARD_SCRIPTABLE_PACK_SCAN_OPTIONS, bindRuntimePackScope, buildCatalogProjection, buildOfflineAssetEvidence, calculateCatalogDelta, calculateTopologyDiff, catalogProjectionFor, catalogSourcePathFor, collectMaterialCookRefs, createFileSystemPackAuthoringGateway, createFileSystemPackAuthoringPort, createMaterialArtifactDigest, createPackAuthoringGateway, createRuntimePackPublication, currentProjectionFor, decodeMeshBinHeader, definePack, definePackageId, diffTopology, finalizePackageProduct, finalizePackageTransportSource, findReservedAssetKindConflict, hasPackParameters, inventoryDigest, isScriptablePackAssetKind, isValidAssetGuidString, isValidPackSourceKey, metaPathForGuid, packageTransportRevision, packageVerification, parsePackSourceJson, parsePackV2, projectAssetRefs, projectCookedMaterialRecord, projectCookedPackageEntry, projectDirectPackJson, projectExternalCatalogEntries, projectPackageCatalog, projectRuntimeCatalogRow, projectSceneEntityRefs, projectScriptablePackMeta, projectScriptablePackSceneComponents, resolveAssetSource, resolvePackInheritance, resolvePackParameterInheritance, resolvePackParameterValues, scanInventory, serializeCookedMaterialRecord, serializeMaterialCookReceipt, stripRuntimePackLifecycle, syncAuthorInventory, validateArtifactPath, validateAuthorInventory, validateCookedMaterialRecord, validateMaterialCookReceipt, validateMeta, validatePack, validatePackDefinition, validatePackV2, validateProducerContract, validateProducerOutputs, writeMeshBinHeader };
12912
13142
  //# sourceMappingURL=build.mjs.map
12913
13143
  //# sourceMappingURL=build.mjs.map