@craft_eco/craft-mcp 0.1.34-beta.3 → 0.1.34-beta.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.
Files changed (64) hide show
  1. package/README.md +7 -5
  2. package/bin/craft-mcp.mjs +3 -1
  3. package/dist-server/core/upload-limits.mjs +11 -0
  4. package/dist-server/game-workflow/art-previews.mjs +71 -71
  5. package/dist-server/game-workflow/bundle-files.mjs +6 -1
  6. package/dist-server/game-workflow/engines.mjs +18 -9
  7. package/dist-server/game-workflow/local-context.mjs +64 -64
  8. package/dist-server/game-workflow/project-art-previews.mjs +63 -63
  9. package/dist-server/game-workflow/project-context.mjs +4 -1
  10. package/dist-server/game-workflow/project-install.mjs +15 -7
  11. package/dist-server/game-workflow/projects.mjs +13 -3
  12. package/dist-server/integrations/distribution-targets.mjs +9 -0
  13. package/dist-server/integrations/install.mjs +49 -11
  14. package/dist-server/integrations/instance-skill.mjs +26 -26
  15. package/dist-server/integrations/instance.mjs +29 -29
  16. package/dist-server/integrations/launcher-start.mjs +5 -5
  17. package/dist-server/integrations/project-setup.mjs +2 -0
  18. package/dist-server/integrations/runtime-candidate.mjs +32 -6
  19. package/dist-server/integrations/runtime-file-diagnostics.mjs +68 -0
  20. package/dist-server/integrations/runtime-gc.mjs +8 -2
  21. package/dist-server/integrations/runtime-identity.mjs +56 -8
  22. package/dist-server/integrations/runtime.mjs +5 -2
  23. package/dist-server/integrations/uninstall.mjs +160 -160
  24. package/dist-server/integrations/updates.mjs +17 -20
  25. package/dist-server/launcher.mjs +47 -8
  26. package/dist-server/mcp/production-events.mjs +52 -29
  27. package/dist-server/mcp/server.mjs +5 -4
  28. package/dist-server/preview/preview-snapshot.mjs +3 -2
  29. package/package.json +5 -5
  30. package/resources/context-filter-report.json +1 -1
  31. package/resources/craft-create/SKILL.md +25 -25
  32. package/resources/craft-update/SKILL.md +27 -27
  33. package/resources/targets/claude/js/context-filter-report.json +1 -1
  34. package/resources/targets/claude/js3d/context-filter-report.json +1 -1
  35. package/resources/targets/codebuddy/js/context-filter-report.json +1 -1
  36. package/resources/targets/codebuddy/js3d/context-filter-report.json +1 -1
  37. package/resources/targets/codex/js/context-filter-report.json +1 -1
  38. package/resources/targets/codex/js3d/context-filter-report.json +1 -1
  39. package/resources/targets/comate/js/context-filter-report.json +1 -1
  40. package/resources/targets/comate/js3d/context-filter-report.json +1 -1
  41. package/resources/targets/cursor/js/context-filter-report.json +1 -1
  42. package/resources/targets/cursor/js3d/context-filter-report.json +1 -1
  43. package/resources/targets/dsh/js/context-filter-report.json +1 -1
  44. package/resources/targets/dsh/js3d/context-filter-report.json +1 -1
  45. package/resources/targets/kimi/js/context-filter-report.json +1 -1
  46. package/resources/targets/kimi/js3d/context-filter-report.json +1 -1
  47. package/resources/targets/opencode/js/context-filter-report.json +1 -1
  48. package/resources/targets/opencode/js3d/context-filter-report.json +1 -1
  49. package/resources/targets/qoder/js/context-filter-report.json +1 -1
  50. package/resources/targets/qoder/js3d/context-filter-report.json +1 -1
  51. package/resources/targets/qoder-cn/js/context-filter-report.json +1 -1
  52. package/resources/targets/qoder-cn/js3d/context-filter-report.json +1 -1
  53. package/resources/targets/qwen/js/context-filter-report.json +1 -1
  54. package/resources/targets/qwen/js3d/context-filter-report.json +1 -1
  55. package/resources/targets/trae/js/context-filter-report.json +1 -1
  56. package/resources/targets/trae/js3d/context-filter-report.json +1 -1
  57. package/resources/targets/workbuddy/js/context-filter-report.json +1 -1
  58. package/resources/targets/workbuddy/js3d/context-filter-report.json +1 -1
  59. package/resources/targets/zcode/js/context-filter-report.json +1 -1
  60. package/resources/targets/zcode/js3d/context-filter-report.json +1 -1
  61. package/vendor/craft-runtime/NOTICE.md +1 -1
  62. package/vendor/craft-runtime/SOURCE.json +10 -6
  63. package/vendor/craft-runtime/index.js +228 -164
  64. package/vendor/craft-runtime/package.json +1 -1
@@ -2,10 +2,13 @@ import { readFile, open, rename, rm } from 'node:fs/promises';
2
2
  import { randomUUID } from 'node:crypto';
3
3
  import { safeProjectFile } from './asset-import.mjs';
4
4
  import { compareVersions, parseVersion } from '../integrations/version-policy.mjs';
5
+ import { distributionTargets } from '../integrations/distribution-targets.mjs';
6
+ import pkg from '../../package.json' with { type: 'json' };
5
7
 
6
8
  export const projectInstallFile = '.craft/project-install.json';
7
- const packageName = '@craft_eco/craft-mcp';
8
- const defaultRegistry = 'https://registry.npmjs.org/';
9
+ // Local kits retain the public npm package as their portable recovery entry.
10
+ const distribution = pkg.name === distributionTargets.internal.package ? distributionTargets.internal : distributionTargets.public;
11
+ export const projectPackageName = distribution.package;
9
12
  const fields = ['schema', 'package_name', 'minimum_mcp_version', 'registry', 'channel', 'platform', 'engine'];
10
13
 
11
14
  function httpsUrl(value, { origin = false } = {}) {
@@ -22,13 +25,17 @@ function httpsUrl(value, { origin = false } = {}) {
22
25
  export function validateProjectInstall(value) {
23
26
  if (!value || typeof value !== 'object' || Array.isArray(value) ||
24
27
  Object.keys(value).length !== fields.length || Object.keys(value).some(key => !fields.includes(key)) ||
25
- value.schema !== 1 || value.package_name !== packageName || !['js', 'js3d'].includes(value.engine)) {
28
+ value.schema !== 1 || !Object.values(distributionTargets).some(target => target.package === value.package_name) || !['js', 'js3d'].includes(value.engine)) {
26
29
  throw new Error('Invalid Craft project installation contract');
27
30
  }
28
31
  parseVersion(value.minimum_mcp_version);
29
32
  if (typeof value.channel !== 'string' || !/^[a-zA-Z][a-zA-Z0-9._-]*$/.test(value.channel)) throw new Error('Project installation channel must be an npm dist-tag');
30
- return { schema: 1, package_name: packageName, minimum_mcp_version: value.minimum_mcp_version,
31
- registry: httpsUrl(value.registry), channel: value.channel, platform: httpsUrl(value.platform, { origin: true }), engine: value.engine };
33
+ const registry = httpsUrl(value.registry);
34
+ if (value.package_name === distributionTargets.internal.package && registry !== distributionTargets.internal.registry) {
35
+ throw new Error('The internal Craft package requires its company npm registry');
36
+ }
37
+ return { schema: 1, package_name: value.package_name, minimum_mcp_version: value.minimum_mcp_version,
38
+ registry, channel: value.channel, platform: httpsUrl(value.platform, { origin: true }), engine: value.engine };
32
39
  }
33
40
 
34
41
  async function snapshot(project) {
@@ -45,6 +52,7 @@ export async function readProjectInstall(project, { required = false } = {}) {
45
52
  }
46
53
 
47
54
  export function assertProjectInstallConnection(manifest, { engine, version, platform, registry, channel, requireKnownChannel = false }) {
55
+ if (manifest.package_name !== projectPackageName) throw new Error('Project installation package differs from the current Craft runtime');
48
56
  if (manifest.engine !== engine) throw new Error('Project installation engine differs from the existing game; keep its original engine');
49
57
  if (compareVersions(version, manifest.minimum_mcp_version) < 0) throw new Error('Project requires Craft MCP >= ' + manifest.minimum_mcp_version + '; the current runtime cannot downgrade its installation contract');
50
58
  if (httpsUrl(platform, { origin: true }) !== manifest.platform) throw new Error('Project installation platform differs from the current Craft connection; reconnect to the project platform before resuming');
@@ -57,8 +65,8 @@ export function assertProjectInstallConnection(manifest, { engine, version, plat
57
65
  export async function planProjectInstall(project, options) {
58
66
  const before = await snapshot(project), previous = before.manifest;
59
67
  if (previous) assertProjectInstallConnection(previous, options);
60
- const manifest = validateProjectInstall({ schema: 1, package_name: packageName,
61
- minimum_mcp_version: options.version, registry: options.registry ?? previous?.registry ?? defaultRegistry,
68
+ const manifest = validateProjectInstall({ schema: 1, package_name: projectPackageName,
69
+ minimum_mcp_version: options.version, registry: options.registry ?? previous?.registry ?? distribution.registry,
62
70
  channel: options.channel ?? previous?.channel ?? 'stable', platform: options.platform, engine: options.engine });
63
71
  return { manifest, previous, before: before.text, changed: JSON.stringify(manifest) !== JSON.stringify(previous) };
64
72
  }
@@ -6,6 +6,7 @@ import { seedProjectTemplate } from '#craft-sdk';
6
6
  import { atomicJson } from './request-store.mjs';
7
7
  import { assetConfig, safeProjectFile } from './asset-import.mjs';
8
8
  import { engineDefinition } from './engines.mjs';
9
+ import { verifyBundle } from './bundle-files.mjs';
9
10
  import { prepareProjectContext, projectContextPaths } from './project-context.mjs';
10
11
  import { clientIde } from '../integrations/hosts.mjs';
11
12
  import { ProjectBundles, readContextLock, contextBinding, checkProjectCompatibility, planContextRelease, assertContextRelease } from './project-bundles.mjs';
@@ -46,6 +47,13 @@ async function readRecord(file, project) {
46
47
  return record;
47
48
  }
48
49
 
50
+ async function verifySourceBeforeUse(source) {
51
+ if (source.deferPayload) {
52
+ await verifyBundle(source.resources,source.engine,source.bundle.id);
53
+ source.deferPayload = false;
54
+ }
55
+ }
56
+
49
57
  export class Projects {
50
58
  constructor(root, state, engines, ide = 'generic', installationProvider) {
51
59
  this.root = root; this.state = path.join(state,'projects'); this.engines = engines; this.ide = clientIde(ide);
@@ -135,19 +143,21 @@ export class Projects {
135
143
  signal?.throwIfAborted();
136
144
  if (requestedEngine !== undefined) engineDefinition(requestedEngine);
137
145
  const project = this.file(name);
146
+ const recordFile = path.join(this.state,name + '.json');
147
+ const record = await readRecord(recordFile,project);
148
+ if (record?.engine && requestedEngine && requestedEngine !== record.engine) throw new Error('Project engine is fixed to ' + record.engine + '; use a different name for another engine');
138
149
  let created = false;
139
150
  if(options.mode==='resume') await lstat(project);
140
151
  else {
152
+ await verifySourceBeforeUse(this.engines[requestedEngine ?? record?.engine ?? 'js']);
141
153
  try { await mkdir(project); created = true; }
142
154
  catch (error) { if (error.code !== 'EEXIST') throw error; if(options.mode==='create') throw new Error('Project already exists; use mode=resume to continue it'); }
143
155
  }
144
156
  if (await realpath(project) !== project || (await lstat(project)).isSymbolicLink()) throw new Error('Project must not be a symbolic link');
145
- const recordFile = path.join(this.state,name + '.json');
146
- const record = await readRecord(recordFile,project);
147
- if (record?.engine && requestedEngine && requestedEngine !== record.engine) throw new Error('Project engine is fixed to ' + record.engine + '; use a different name for another engine');
148
157
  if (created) await seedProjectTemplate(this.engines[requestedEngine ?? record?.engine ?? 'js'].template,project,{ signal });
149
158
  // Existing Craft games are adopted, never overwritten or silently converted from another engine.
150
159
  const engine = await inspectProject(project,record?.engine ?? requestedEngine);
160
+ if (!created) await verifySourceBeforeUse(this.engines[engine]);
151
161
  if(this.engines[engine].host) {
152
162
  if(options.upgrade_context!==undefined && typeof options.upgrade_context!=='boolean') throw new Error('upgrade_context must be boolean');
153
163
  if(options.context_bundle_id!==undefined && options.context_bundle_id!==this.engines[engine].bundle.id) throw new Error('Contexts follow the installed release; select the desired MCP release instead of pinning an older context');
@@ -0,0 +1,9 @@
1
+ export const distributionTargets = Object.freeze({
2
+ public: Object.freeze({ package: '@craft_eco/craft-mcp', registry: 'https://registry.npmjs.org/' }),
3
+ internal: Object.freeze({ package: '@tencent/craft-mcp', registry: 'https://mirrors.tencent.com/npm/' }),
4
+ });
5
+
6
+ // A project's @tencent:registry setting takes precedence over npx --registry.
7
+ export function internalRegistryArgs(packageName) {
8
+ return packageName === distributionTargets.internal.package ? ['--@tencent:registry=' + distributionTargets.internal.registry] : [];
9
+ }
@@ -18,6 +18,7 @@ import { sameInstallation, installationChanged } from './installation-transactio
18
18
  import { assertHostConfigScope } from './host-config-scope.mjs';
19
19
  import { registrationsForInstance, serverIdForChannel, validateServerId } from './instance.mjs';
20
20
  import { renderInstanceSkill } from './instance-skill.mjs';
21
+ import { verifyRuntimeProductFiles } from './runtime-file-diagnostics.mjs';
21
22
 
22
23
  const bootstrapMarker = '<!-- craft-mcp:bootstrap:v1 -->';
23
24
 
@@ -99,10 +100,13 @@ function hostRuntimeEnvironment(host, existing = {}) {
99
100
 
100
101
  export async function installHosts({ ide, workspace, platform, packageRoot, home = os.homedir(), codexHome, hostOptions = {},
101
102
  runtimeRoot = path.join(getAppDataRoot(), 'runtimes'), stateRoot = path.join(path.dirname(runtimeRoot), 'installations'),
102
- registry, channel, updates, serverId, selector = 'package', onlyIfMissing = false, materialize = stageRuntime, probe = probeRuntime,
103
+ registry, channel, updates, serverId, selector = 'package', repair = false, onlyIfMissing = false, materialize = stageRuntime, probe = probeRuntime,
103
104
  lookup = queryRegistry, materializeRegistry = stageRegistryRuntime }) {
104
105
  const targets = installTargets(ide);
105
106
  const instance = validateServerId(serverId ?? 'craft');
107
+ if (repair && (targets.length !== 1 || [workspace, platform, registry, channel, updates].some(value => value !== undefined))) {
108
+ throw new Error('Repair uses one existing installation and its recorded settings. Select it with --ide and --instance.');
109
+ }
106
110
  if (hostOptions.configPath && targets.length !== 1) throw new Error('--host-config requires exactly one --ide');
107
111
  if (workspace !== undefined && !path.isAbsolute(workspace)) throw new Error('--workspace must be absolute');
108
112
  if (platform !== undefined) platform = platformOrigin(platform);
@@ -140,6 +144,9 @@ export async function installHosts({ ide, workspace, platform, packageRoot, home
140
144
  const statePath = installationPath(stateRoot, host, paths.config, instance);
141
145
  const previousSnapshot = old?.env?.CRAFT_INSTALLATION_FILE ? await readInstallationSnapshot(old.env.CRAFT_INSTALLATION_FILE) : null;
142
146
  const previousState = previousSnapshot?.state;
147
+ if (repair && (previousState?.schema !== 2 || path.relative(runtimeRoot, previousState.runtime_root) !== '')) {
148
+ throw new Error('Repair requires the selected managed Craft installation and its original runtime root.');
149
+ }
143
150
  if (previousState) checkInstanceBinding(previousState, host, paths, instance, old.env.CRAFT_INSTALLATION_FILE);
144
151
  if (instance !== 'craft' && previousState && path.relative(old.env.CRAFT_INSTALLATION_FILE, statePath.file) !== '') throw new Error('Craft instance installation root differs from its registration');
145
152
  const previousChannel = previousState?.source.channel ?? legacySource?.channel;
@@ -206,7 +213,18 @@ export async function installHosts({ ide, workspace, platform, packageRoot, home
206
213
  const candidates = new Map(), releases = new Map();
207
214
  async function preparePlan(plan) {
208
215
  let remote;
209
- if (plan.followTag) {
216
+ if (repair) {
217
+ const target = plan.previousRuntime;
218
+ if (target.origin?.kind === 'npm') {
219
+ if (registryOrigin(target.origin.registry) !== plan.source.registry || !target.origin.integrity) throw new Error('Recorded Craft repair source or integrity is inconsistent');
220
+ remote = { package: target.package, version: target.version, integrity: target.origin.integrity };
221
+ } else if (selector !== 'package' || pkg.version !== target.version) {
222
+ remote = await lookup({ ...plan.source, channel: target.version });
223
+ if (remote.package !== target.package || remote.version !== target.version || !remote.integrity) {
224
+ throw new Error('Could not resolve the exact Craft version for repair; use the original installation package.');
225
+ }
226
+ }
227
+ } else if (plan.followTag) {
210
228
  const key = JSON.stringify(plan.source);
211
229
  if (!releases.has(key)) releases.set(key, await lookup(plan.source));
212
230
  remote = releases.get(key);
@@ -217,7 +235,7 @@ export async function installHosts({ ide, workspace, platform, packageRoot, home
217
235
  if (!candidates.has(key)) {
218
236
  const candidate = await prepareRuntimeCandidate(runtimeRoot, staging => remote
219
237
  ? materializeRegistry(plan.source, remote, staging)
220
- : materialize(packageRoot, staging, { registry }));
238
+ : materialize(packageRoot, staging, { registry }), { repair: true, deferExisting: true });
221
239
  candidates.set(key, candidate);
222
240
  const resources = path.join(candidate.identity.package_root, 'resources');
223
241
  candidate.createSkill = await readFile(path.join(resources,'craft-create/SKILL.md'),'utf8');
@@ -226,6 +244,9 @@ export async function installHosts({ ide, workspace, platform, packageRoot, home
226
244
  if (candidate.updateSkill !== null && !candidate.updateSkill.includes('<!-- craft-mcp:update:v1 -->')) throw new Error('Craft update Skill has an invalid distribution marker');
227
245
  }
228
246
  const candidate = candidates.get(key);
247
+ if (repair && (candidate.identity.version !== plan.previousRuntime.version || candidate.identity.build_id !== plan.previousRuntime.build_id)) {
248
+ throw new Error('Craft repair requires the original version and build; restore the original source or installation package.');
249
+ }
229
250
  if (candidate.identity.package !== pkg.name || (remote && candidate.identity.version !== remote.version)) throw new Error('Craft channel package does not match the resolved release');
230
251
  const managedUpdateSkill = plan.previousState?.skills?.['craft-update'] === plan.paths.updateSkill;
231
252
  plan.writeUpdateSkill = candidate.updateSkill !== null || managedUpdateSkill;
@@ -244,6 +265,7 @@ export async function installHosts({ ide, workspace, platform, packageRoot, home
244
265
  for (const plan of plans) {
245
266
  if (attempt > 0) {
246
267
  const original = initialPlans.find(initial => initial.host === plan.host);
268
+ if (repair && !sameRuntimeIdentity(original.previousRuntime, plan.previousRuntime)) throw new Error('The selected Craft target changed during repair; run doctor again.');
247
269
  const before = original.previousState?.source ?? original.legacySource ?? original.source;
248
270
  const after = plan.previousState?.source ?? plan.legacySource;
249
271
  if (after?.channel && (after.channel !== before.channel || (before.registry && before.registry !== after.registry))) {
@@ -258,15 +280,26 @@ export async function installHosts({ ide, workspace, platform, packageRoot, home
258
280
  env: { ...old?.env, ...hostRuntimeEnvironment(plan.host,old?.env), CRAFT_CLIENT_IDE: plan.host, CRAFT_SERVER_ID: instance, CRAFT_WEB_URL: plan.platform, CLIENT_WORKSPACE_ROOT: plan.workspace,
259
281
  CRAFT_INSTALLATION_FILE: plan.statePath.file, CRAFT_RUNTIME_REVISION: candidate.identity.build_id }, ...hostConnectionOptions(plan.host) };
260
282
  const expected = { version: candidate.identity.version, build_id: candidate.identity.build_id, host: plan.host, serverId: instance, workspace: plan.workspace, platform: plan.platform };
283
+ plan.probeRuntime = async runtime => {
284
+ const verified = await probe({ ...connection, args: [runtime.entry, '--workspace', plan.workspace] }, expected);
285
+ if (verified.runtime?.activation_mode !== activationMode) throw new Error('Craft runtime requires a legacy frontend; install a next_mcp_start distribution');
286
+ return verified;
287
+ };
261
288
  const key = JSON.stringify({ connection, expected });
262
- const verified = verifiedCache.get(key) ?? await probe(connection, expected);
263
- if (verified.runtime?.activation_mode !== activationMode) throw new Error('Craft runtime requires a legacy frontend; install a next_mcp_start distribution');
289
+ const verified = verifiedCache.get(key) ?? await plan.probeRuntime(candidate.identity);
264
290
  verifiedCache.set(key, verified);
265
291
  verifiedByHost.set(plan.host, verified);
266
292
  }
267
293
  for (const candidate of new Set(plans.map(plan => plan.candidate))) {
268
294
  if (!sameRuntimeIdentity(await getRuntimeIdentity(candidate.identity.package_root), candidate.identity)) throw new Error('Craft candidate changed during verification; installation refused');
269
- await refreshRuntimeCandidate(candidate);
295
+ const verifiedExisting = await refreshRuntimeCandidate(candidate, async runtime => {
296
+ const results = new Map();
297
+ for (const plan of plans) {
298
+ if (plan.candidate === candidate) results.set(plan.host, await plan.probeRuntime(runtime));
299
+ }
300
+ return results;
301
+ });
302
+ if (verifiedExisting) for (const [host, result] of verifiedExisting) verifiedByHost.set(host, result);
270
303
  }
271
304
  const lockPaths = [...new Set(plans.flatMap(plan => [plan.paths.config, plan.statePath.file, craftConfig(plan.configInput, plan.host, plan.previousName)?.env?.CRAFT_INSTALLATION_FILE].filter(Boolean)).map(file => path.resolve(file)))].sort();
272
305
  for (const file of lockPaths) {
@@ -360,9 +393,9 @@ async function verifyInstalledSkills(installation, paths, connection, snapshot)
360
393
  contents.set(name, content);
361
394
  }
362
395
  const candidates = installation ? installation.skills_runtime ? [installation.skills_runtime] : [installation.target, installation.anchor] : [await getRuntimeIdentity(path.resolve(path.dirname(connection.args[0]), '..'))];
396
+ if (installation) await verifyRuntimeProductFiles(installation.target, installation);
363
397
  for (const candidate of candidates) {
364
- const actual = await getRuntimeIdentity(candidate.package_root);
365
- if (actual.package !== candidate.package || actual.version !== candidate.version || actual.build_id !== candidate.build_id) throw new Error('Installed Skill runtime files differ from their recorded identity');
398
+ if (installation && !sameRuntimeIdentity(candidate, installation.target)) await verifyRuntimeProductFiles(candidate, installation);
366
399
  let matches = true;
367
400
  for (const { name, marker } of entries) {
368
401
  const expected = await optionalFile(path.join(candidate.package_root, 'resources', name, 'SKILL.md'));
@@ -478,10 +511,14 @@ export async function installWithLoginTask(options) {
478
511
 
479
512
  export async function runIntegrationCommand(args, packageRoot) {
480
513
  const [command, ...rest] = args, options = {};
481
- for (let i = 0; i < rest.length; i += 2) {
514
+ for (let i = 0; i < rest.length; i++) {
515
+ if (command === 'install' && rest[i] === '--repair' && options.repair === undefined) {
516
+ options.repair = true;
517
+ continue;
518
+ }
482
519
  const name = rest[i].replace(/^--/, '');
483
520
  if (!rest[i].startsWith('--') || !['ide', 'instance', 'host-config', 'trae-region', ...(command === 'install' ? ['workspace', 'platform', 'registry', 'channel', 'updates'] : [])].includes(name) || !rest[i + 1] || Object.hasOwn(options, name)) throw new Error('Invalid or repeated option. Use craft-mcp --help.');
484
- options[name] = rest[i + 1];
521
+ options[name] = rest[++i];
485
522
  }
486
523
  options.codexHome = process.env.CODEX_HOME;
487
524
  options.hostOptions = hostCommandOptions(options);
@@ -489,7 +526,8 @@ export async function runIntegrationCommand(args, packageRoot) {
489
526
  const { name } = JSON.parse(await readFile(path.join(packageRoot,'package.json'),'utf8'));
490
527
  const request = await npmInstallSelector(packageRoot, name);
491
528
  options.selector = request?.kind ?? 'management';
492
- options.channel ??= request?.tag;
529
+ if (options.repair) options.instance ??= serverIdForChannel(request?.tag === 'latest' ? 'stable' : request?.tag);
530
+ else options.channel ??= request?.tag;
493
531
  if (options.channel === 'latest') options.channel = 'stable';
494
532
  }
495
533
  options.serverId = validateServerId(options.instance ?? serverIdForChannel(options.channel));
@@ -1,26 +1,26 @@
1
- import { validateServerId } from './instance.mjs';
2
-
3
- export function instanceSkillName(logicalName, serverId = 'craft') {
4
- validateServerId(serverId);
5
- if (!['craft-create', 'craft-update'].includes(logicalName)) throw new Error('Unknown Craft entrypoint Skill');
6
- return serverId + logicalName.slice('craft'.length);
7
- }
8
-
9
- // Always render from this runtime's original template, including on update and
10
- // uninstall. Default installations must still match their installed bytes.
11
- export function renderInstanceSkill(content, logicalName, serverId = 'craft') {
12
- const name = instanceSkillName(logicalName, serverId);
13
- if (serverId === 'craft' || content == null) return content;
14
- const header = /^---\r?\n([\s\S]*?)\r?\n---(?=\r?\n)/.exec(content);
15
- if (!header || !header[1].split(/\r?\n/).includes('name: ' + logicalName)) {
16
- throw new Error('Invalid packaged Skill frontmatter for ' + logicalName);
17
- }
18
- const action = logicalName === 'craft-create' ? '创建、继续或上传游戏' : '检查和更新安装';
19
- const description = '仅在用户指定 ' + serverId + ',或当前项目已绑定其渠道和工作区时,使用该实例' + action + '。';
20
- const frontmatter = header[1].replace(/^name: .*$/m, 'name: ' + name)
21
- .replace(/^description: .*$/m, 'description: ' + description);
22
- return '---\n' + frontmatter + '\n---\n\n'
23
- + '本入口对应 MCP 服务 `' + serverId + '`。发现该服务的工具,调用其 `craft_game_info` 核对 server_id、渠道和工作区。'
24
- + '后续制作、上传、轮询、更新及重连均使用这条连接。\n'
25
- + content.slice(header[0].length);
26
- }
1
+ import { validateServerId } from './instance.mjs';
2
+
3
+ export function instanceSkillName(logicalName, serverId = 'craft') {
4
+ validateServerId(serverId);
5
+ if (!['craft-create', 'craft-update'].includes(logicalName)) throw new Error('Unknown Craft entrypoint Skill');
6
+ return serverId + logicalName.slice('craft'.length);
7
+ }
8
+
9
+ // Always render from this runtime's original template, including on update and
10
+ // uninstall. Default installations must still match their installed bytes.
11
+ export function renderInstanceSkill(content, logicalName, serverId = 'craft') {
12
+ const name = instanceSkillName(logicalName, serverId);
13
+ if (serverId === 'craft' || content == null) return content;
14
+ const header = /^---\r?\n([\s\S]*?)\r?\n---(?=\r?\n)/.exec(content);
15
+ if (!header || !header[1].split(/\r?\n/).includes('name: ' + logicalName)) {
16
+ throw new Error('Invalid packaged Skill frontmatter for ' + logicalName);
17
+ }
18
+ const action = logicalName === 'craft-create' ? '创建、继续或上传游戏' : '检查和更新安装';
19
+ const description = '仅在用户指定 ' + serverId + ',或当前项目已绑定其渠道和工作区时,使用该实例' + action + '。';
20
+ const frontmatter = header[1].replace(/^name: .*$/m, 'name: ' + name)
21
+ .replace(/^description: .*$/m, 'description: ' + description);
22
+ return '---\n' + frontmatter + '\n---\n\n'
23
+ + '本入口对应 MCP 服务 `' + serverId + '`。发现该服务的工具,调用其 `craft_game_info` 核对 server_id、渠道和工作区。'
24
+ + '后续制作、上传、轮询、更新及重连均使用这条连接。\n'
25
+ + content.slice(header[0].length);
26
+ }
@@ -1,29 +1,29 @@
1
- import { createHash } from 'node:crypto';
2
-
3
- export function validateServerId(id) {
4
- if (typeof id !== 'string' || id.length > 32 || !/^craft(?:-[a-z0-9]+(?:-[a-z0-9]+)*)?$/.test(id)) {
5
- throw new Error('Invalid Craft instance name; use craft or craft-<lowercase-identifier> (up to 32 characters)');
6
- }
7
- return id;
8
- }
9
-
10
- export function serverIdForChannel(channel) {
11
- if (channel === undefined || channel === 'stable' || channel === 'latest') return 'craft';
12
- if (typeof channel !== 'string' || !/^[a-zA-Z][a-zA-Z0-9._-]*$/.test(channel)) throw new Error('Update channel must be an npm dist-tag');
13
- const simple = 'craft-' + channel;
14
- if (simple.length <= 32 && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(channel)) return simple;
15
- // Host server names (including DSH) have a common limit of 32. Retain
16
- // distinct case-sensitive tags when the tag cannot be used verbatim.
17
- const prefix = channel.toLowerCase().replace(/[^a-z0-9]+/g, '-').slice(0, 13).replace(/-$/, '');
18
- return 'craft-' + prefix + '-' + createHash('sha256').update(channel).digest('hex').slice(0, 12);
19
- }
20
-
21
- // An unmarked renamed Craft registration belongs to the legacy default slot.
22
- // Managed named instances identify themselves even when several share a host.
23
- export function registrationsForInstance(registrations, serverId) {
24
- return registrations.filter(({ name, connection }) => {
25
- const marker = connection?.env?.CRAFT_SERVER_ID;
26
- if (marker !== undefined && marker !== name && (marker === serverId || name === serverId)) throw new Error('Craft instance marker differs from its registration: ' + name);
27
- return marker === undefined ? serverId === 'craft' : marker === serverId;
28
- });
29
- }
1
+ import { createHash } from 'node:crypto';
2
+
3
+ export function validateServerId(id) {
4
+ if (typeof id !== 'string' || id.length > 32 || !/^craft(?:-[a-z0-9]+(?:-[a-z0-9]+)*)?$/.test(id)) {
5
+ throw new Error('Invalid Craft instance name; use craft or craft-<lowercase-identifier> (up to 32 characters)');
6
+ }
7
+ return id;
8
+ }
9
+
10
+ export function serverIdForChannel(channel) {
11
+ if (channel === undefined || channel === 'stable' || channel === 'latest') return 'craft';
12
+ if (typeof channel !== 'string' || !/^[a-zA-Z][a-zA-Z0-9._-]*$/.test(channel)) throw new Error('Update channel must be an npm dist-tag');
13
+ const simple = 'craft-' + channel;
14
+ if (simple.length <= 32 && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(channel)) return simple;
15
+ // Host server names (including DSH) have a common limit of 32. Retain
16
+ // distinct case-sensitive tags when the tag cannot be used verbatim.
17
+ const prefix = channel.toLowerCase().replace(/[^a-z0-9]+/g, '-').slice(0, 13).replace(/-$/, '');
18
+ return 'craft-' + prefix + '-' + createHash('sha256').update(channel).digest('hex').slice(0, 12);
19
+ }
20
+
21
+ // An unmarked renamed Craft registration belongs to the legacy default slot.
22
+ // Managed named instances identify themselves even when several share a host.
23
+ export function registrationsForInstance(registrations, serverId) {
24
+ return registrations.filter(({ name, connection }) => {
25
+ const marker = connection?.env?.CRAFT_SERVER_ID;
26
+ if (marker !== undefined && marker !== name && (marker === serverId || name === serverId)) throw new Error('Craft instance marker differs from its registration: ' + name);
27
+ return marker === undefined ? serverId === 'craft' : marker === serverId;
28
+ });
29
+ }
@@ -1,5 +1,5 @@
1
1
  // Bundled into a self-contained file. No versioned dependency is loaded before
2
- // the installation lock is held and the selected package has been verified.
2
+ // the installation lock is held and the selected package receipt is checked.
3
3
  import path from 'node:path';
4
4
  import { pathToFileURL } from 'node:url';
5
5
  import { readFile, mkdir, writeFile, unlink } from 'node:fs/promises';
@@ -7,7 +7,7 @@ import { unlinkSync } from 'node:fs';
7
7
  import { randomUUID } from 'node:crypto';
8
8
  import lockfile from 'proper-lockfile';
9
9
  import { readInstallation, sameRuntimeIdentity } from './installation-state.mjs';
10
- import { getRuntimeIdentity } from './runtime-identity.mjs';
10
+ import { readRunningIdentity } from './runtime-identity.mjs';
11
11
  import { assertPlainPath } from './files.mjs';
12
12
  import { verifyLauncher, launcherPath } from './fixed-launcher.mjs';
13
13
 
@@ -38,8 +38,8 @@ async function start() {
38
38
  const relative = path.relative(path.resolve(state.runtime_root), state.target.package_root);
39
39
  if (!relative || relative === '..' || relative.startsWith('..' + path.sep) || path.isAbsolute(relative)) throw new Error('Craft target is outside the managed runtime root');
40
40
  await assertPlainPath(state.target.entry);
41
- identity = await getRuntimeIdentity(state.target.package_root);
42
- if (!sameRuntimeIdentity(identity, state.target)) throw new Error('Craft target package integrity mismatch');
41
+ identity = await readRunningIdentity(state.target.package_root, { managed: true });
42
+ if (!sameRuntimeIdentity(identity, state.target)) throw new Error('Craft target and installed runtime identity differ; run doctor for the selected instance');
43
43
  const leaseRoot = path.join(state.runtime_root, '.connections');
44
44
  await mkdir(leaseRoot, { recursive: true });
45
45
  lease = path.join(leaseRoot, 'launcher-' + randomUUID() + '.json');
@@ -53,7 +53,7 @@ async function start() {
53
53
  const targetEntry = preview ? path.join(identity.package_root, 'dist-server/preview/workbuddy-preview-task-worker.mjs') :
54
54
  loginPage ? path.join(identity.package_root, 'dist-server/mcp/workbuddy-login-task-worker.mjs') : identity.entry;
55
55
  process.argv = [process.execPath, targetEntry, ...(loginPage || preview ? [installationFile] : process.argv.slice(2))];
56
- try { await import(pathToFileURL(targetEntry).href); }
56
+ try { await assertPlainPath(targetEntry); await import(pathToFileURL(targetEntry).href); }
57
57
  catch (error) { await unlink(lease).catch(() => {}); throw error; }
58
58
  }
59
59
 
@@ -16,6 +16,7 @@ import { engineDefinition } from '../game-workflow/engines.mjs';
16
16
  import { verifyBundle } from '../game-workflow/bundle-files.mjs';
17
17
  import { assertHostConfigScope } from './host-config-scope.mjs';
18
18
  import { registrationsForInstance, validateServerId } from './instance.mjs';
19
+ import { internalRegistryArgs } from './distribution-targets.mjs';
19
20
 
20
21
  const samePath = (left, right) => typeof left === 'string' && typeof right === 'string' &&
21
22
  (process.platform === 'win32' ? path.resolve(left).toLowerCase() === path.resolve(right).toLowerCase() : path.resolve(left) === path.resolve(right));
@@ -33,6 +34,7 @@ function connectionRequirements(project, ide, manifest, serverId) {
33
34
 
34
35
  function bootstrapCommand(project, ide, manifest, paths, hostOptions) {
35
36
  return { command: 'npx', args: ['-y', '--registry=' + manifest.registry,
37
+ ...internalRegistryArgs(manifest.package_name),
36
38
  manifest.package_name + '@' + manifest.minimum_mcp_version,
37
39
  'project-setup', '--project', project, '--ide', ide,
38
40
  ...(hostOptions.serverId ? ['--instance', hostOptions.serverId] : []),
@@ -2,6 +2,7 @@ import path from 'node:path';
2
2
  import { mkdir, mkdtemp, lstat, readFile, rename, rm } from 'node:fs/promises';
3
3
  import { getRuntimeIdentity } from './runtime-identity.mjs';
4
4
  import { assertPlainPath } from './files.mjs';
5
+ import { verifyExistingFileList } from './runtime-file-diagnostics.mjs';
5
6
 
6
7
  const within = (root, file) => {
7
8
  const relative = path.relative(path.resolve(root), path.resolve(file));
@@ -26,14 +27,14 @@ function relocated(candidate) {
26
27
 
27
28
  // Preparation and complete content verification happen outside installation
28
29
  // locks. GC only visits the runtime root's direct version directories.
29
- export async function prepareRuntimeCandidate(runtimeRoot, materialize) {
30
+ export async function prepareRuntimeCandidate(runtimeRoot, materialize, { repair = false, deferExisting = false } = {}) {
30
31
  runtimeRoot = path.resolve(runtimeRoot);
31
32
  await assertPlainPath(path.join(runtimeRoot, '.candidate-path-check'));
32
33
  const parent = path.join(runtimeRoot, '.candidates');
33
34
  await mkdir(parent, { recursive: true });
34
35
  await assertPlainPath(path.join(parent, '.candidate-path-check'));
35
36
  const staging = await mkdtemp(path.join(parent, 'prepare-'));
36
- const candidate = { runtimeRoot, staging, managed: false };
37
+ const candidate = { runtimeRoot, staging, managed: false, repair };
37
38
  try {
38
39
  candidate.runtime = await materialize(staging);
39
40
  const runtime = candidate.runtime;
@@ -44,7 +45,7 @@ export async function prepareRuntimeCandidate(runtimeRoot, materialize) {
44
45
  if (path.dirname(candidate.sourceDirectory) !== staging || !within(candidate.sourceDirectory, candidate.identity.package_root) || !within(candidate.sourceDirectory, candidate.identity.entry)) throw new Error('Candidate runtime escaped its isolated directory');
45
46
  candidate.destination = path.join(runtimeRoot, path.basename(candidate.sourceDirectory));
46
47
  candidate.managed = true;
47
- await refreshRuntimeCandidate(candidate);
48
+ if (!deferExisting) await refreshRuntimeCandidate(candidate);
48
49
  }
49
50
  // Injectable materializers may return pre-existing fixture/runtime paths.
50
51
  // These are never moved or removed by candidate cleanup.
@@ -54,26 +55,51 @@ export async function prepareRuntimeCandidate(runtimeRoot, materialize) {
54
55
 
55
56
  // A concurrent publication may appear after preparation. Refresh its complete
56
57
  // identity outside locks before retrying the short commit section.
57
- export async function refreshRuntimeCandidate(candidate) {
58
+ export async function refreshRuntimeCandidate(candidate, checkExisting) {
58
59
  if (!candidate.managed) return;
59
- const before = await directoryStamp(candidate.destination);
60
60
  candidate.existing = null;
61
+ const base = path.join(candidate.runtimeRoot, path.basename(candidate.sourceDirectory));
62
+ for (let slot = 0; ; slot++) {
63
+ candidate.destination = slot === 0 ? base : base + '-repair-' + slot;
64
+ try { return await verifyExistingRuntime(candidate, checkExisting); }
65
+ catch (error) {
66
+ // An independently verified copy can occupy a sibling slot. Never mutate
67
+ // or move an existing directory that another MCP process could be using.
68
+ if (!candidate.repair || (error.code && error.code !== 'ENOENT')) throw error;
69
+ }
70
+ }
71
+ }
72
+
73
+ async function verifyExistingRuntime(candidate, checkExisting) {
74
+ const before = await directoryStamp(candidate.destination);
61
75
  if (before === null) return;
62
76
  try {
63
77
  const final = relocated(candidate);
78
+ await assertPlainPath(path.join(final.package_root, 'package.json'));
79
+ await assertPlainPath(path.join(candidate.destination, 'craft-runtime.json'));
64
80
  const identity = await getRuntimeIdentity(final.package_root);
65
81
  const metadataText = await readFile(path.join(candidate.destination, 'craft-runtime.json'), 'utf8');
66
82
  const metadata = JSON.parse(metadataText);
67
83
  if (identity.package !== final.package || identity.version !== final.version || identity.build_id !== final.build_id ||
68
84
  metadata.package !== final.package || metadata.version !== final.version || metadata.build_id !== final.build_id || metadata.sha256 !== candidate.runtime.sha256) throw new Error('Existing Craft runtime differs from the verified candidate');
85
+ await verifyExistingFileList(candidate.sourceDirectory,candidate.destination,metadata);
86
+ let verification;
87
+ if (checkExisting) {
88
+ // A product hash excludes npm dependencies. The existing installation,
89
+ // including its own dependencies, must start in every requested host.
90
+ try { verification = await checkExisting(final); }
91
+ catch (error) { throw new Error('Existing Craft runtime could not start: ' + error.message, { cause: error }); }
92
+ if ((await getRuntimeIdentity(final.package_root)).build_id !== final.build_id) throw new Error('Existing Craft runtime changed during startup verification');
93
+ }
69
94
  if (before !== await directoryStamp(candidate.destination)) throw changed('Craft runtime changed during candidate verification');
70
95
  candidate.existing = { stamp: before, metadataText };
96
+ return verification;
71
97
  } catch (error) {
72
98
  if (error.code === 'ENOENT') {
73
99
  // GC can remove an unreferenced former candidate while it is inspected.
74
100
  // Our private copy is still complete and can be published on retry.
75
101
  if (await directoryStamp(candidate.destination) === null) return;
76
- throw changed('Craft runtime was removed while its existing copy was being verified');
102
+ if (!candidate.repair) throw changed('Craft runtime was removed while its existing copy was being verified');
77
103
  }
78
104
  throw error;
79
105
  }
@@ -0,0 +1,68 @@
1
+ import path from 'node:path';
2
+ import { readFile, writeFile } from 'node:fs/promises';
3
+ import { createHash } from 'node:crypto';
4
+ import { assertPlainPath, optionalFile } from './files.mjs';
5
+ import { hashRuntimeFiles, runtimeDirectoryForPackage } from './runtime-identity.mjs';
6
+
7
+ // Store the installed bytes (after npm's bin normalization) outside the product tree.
8
+ const fileListName = 'craft-runtime-files.json';
9
+ const digest = bytes => createHash('sha256').update(bytes).digest('hex');
10
+
11
+ export async function writeRuntimeFileList(directory, identity, files) {
12
+ const text = JSON.stringify({ schema: 1, build_id: identity.build_id, files }) + '\n';
13
+ await writeFile(path.join(directory, fileListName), text, { flag: 'wx' });
14
+ return digest(text);
15
+ }
16
+
17
+ export async function verifyExistingFileList(sourceDirectory, existingDirectory, receipt) {
18
+ const expected = JSON.parse(await readFile(path.join(sourceDirectory,'craft-runtime.json'),'utf8')).files_sha256;
19
+ if (!expected) return;
20
+ const file = path.join(existingDirectory,fileListName);
21
+ await assertPlainPath(file);
22
+ const text = await optionalFile(file);
23
+ if (receipt.files_sha256 !== expected || text === null || digest(text) !== expected) {
24
+ throw new Error('Existing Craft runtime file-level baseline differs from the verified candidate');
25
+ }
26
+ }
27
+
28
+ async function describeFileChanges(candidate, runtimeRoot, actual) {
29
+ const directory = runtimeDirectoryForPackage(candidate.package_root);
30
+ const unavailable = 'No installed file-level baseline is available; compare against a clean installation of this build.';
31
+ if (!directory || !runtimeRoot || path.relative(runtimeRoot, path.dirname(directory)) !== '') return unavailable;
32
+ const receiptFile = path.join(directory, 'craft-runtime.json');
33
+ const listFile = path.join(directory, fileListName);
34
+ await assertPlainPath(receiptFile);
35
+ const receipt = JSON.parse(await optionalFile(receiptFile) ?? 'null');
36
+ if (!receipt?.files_sha256) return unavailable;
37
+ await assertPlainPath(listFile);
38
+ const text = await optionalFile(listFile);
39
+ if (receipt.build_id !== candidate.build_id || !text || digest(text) !== receipt.files_sha256) {
40
+ return 'The installed file-level baseline is missing or its checksum does not match; file differences could not be verified.';
41
+ }
42
+ const baseline = JSON.parse(text);
43
+ if (baseline.schema !== 1 || baseline.build_id !== candidate.build_id || !baseline.files || typeof baseline.files !== 'object' || Array.isArray(baseline.files)) {
44
+ return 'The installed file-level baseline is invalid; file differences could not be verified.';
45
+ }
46
+ const expected = baseline.files;
47
+ const differences = {
48
+ added: Object.keys(actual).filter(name => !Object.hasOwn(expected, name)),
49
+ changed: Object.keys(actual).filter(name => Object.hasOwn(expected, name) && actual[name] !== expected[name]),
50
+ missing: Object.keys(expected).filter(name => !Object.hasOwn(actual, name))
51
+ };
52
+ return Object.entries(differences).filter(([, names]) => names.length)
53
+ .map(([kind, names]) => kind + ': ' + JSON.stringify(names)).join('\n') || 'The file list has no differences; the recorded build identity disagrees.';
54
+ }
55
+
56
+ export async function verifyRuntimeProductFiles(candidate, installation) {
57
+ const files = Object.create(null);
58
+ await assertPlainPath(path.join(candidate.package_root, 'package.json'));
59
+ const actualBuild = await hashRuntimeFiles(candidate.package_root, files);
60
+ if (actualBuild !== candidate.build_id) {
61
+ const details = await describeFileChanges(candidate, installation.runtime_root, files)
62
+ .catch(() => 'The installed file-level baseline could not be read or verified; the differing files are unknown.');
63
+ const repair = 'craft-mcp install --repair --ide ' + installation.host + ' --instance ' + installation.server_id;
64
+ throw new Error('Craft runtime integrity mismatch at ' + candidate.package_root + ' (expected ' + candidate.build_id + ', actual ' + actualBuild + ').\n' + details + '\nRepair: ' + repair);
65
+ }
66
+ const pkg = JSON.parse(await readFile(path.join(candidate.package_root, 'package.json'), 'utf8'));
67
+ if (pkg.name !== candidate.package || pkg.version !== candidate.version) throw new Error('Craft package name or version differs from its installation record');
68
+ }
@@ -65,6 +65,12 @@ async function safeDirectory(directory) {
65
65
  await assertPlainPath(path.join(directory, '.craft-path-check'));
66
66
  }
67
67
 
68
+ function managedRuntimeName(name, metadata) {
69
+ const base = metadata.version + '-' + metadata.sha256.slice(0, 16);
70
+ return typeof name === 'string' && (name === base ||
71
+ (name.startsWith(base) && /^-repair-[1-9]\d*$/.test(name.slice(base.length))));
72
+ }
73
+
68
74
  async function ownedRuntimes(root, packageName) {
69
75
  const owned = [];
70
76
  for (const entry of await readdir(root, { withFileTypes: true })) {
@@ -74,7 +80,7 @@ async function ownedRuntimes(root, packageName) {
74
80
  await safeDirectory(directory);
75
81
  const metadataText = await readFile(path.join(directory, 'craft-runtime.json'), 'utf8');
76
82
  const metadata = JSON.parse(metadataText);
77
- if (metadata.package !== packageName || !/^[a-f0-9]{64}$/.test(metadata.sha256 ?? '') || !/^[a-f0-9]{64}$/.test(metadata.build_id ?? '') || entry.name !== metadata.version + '-' + metadata.sha256.slice(0, 16)) continue;
83
+ if (metadata.package !== packageName || !/^[a-f0-9]{64}$/.test(metadata.sha256 ?? '') || !/^[a-f0-9]{64}$/.test(metadata.build_id ?? '') || !managedRuntimeName(entry.name, metadata)) continue;
78
84
  compareVersions(metadata.version, metadata.version);
79
85
  const packageRoot = path.join(directory, 'node_modules', ...packageName.split('/'));
80
86
  await assertPlainPath(path.join(packageRoot, 'package.json'));
@@ -106,7 +112,7 @@ async function retiredRuntimes(root, packageName) {
106
112
  await assertPlainPath(manifestFile);
107
113
  const manifestText = await readFile(manifestFile, 'utf8'), manifest = JSON.parse(manifestText);
108
114
  if (manifest.schema !== 1 || manifest.package !== packageName || !/^[a-f0-9]{64}$/.test(manifest.sha256 ?? '') || !/^[a-f0-9]{64}$/.test(manifest.build_id ?? '') ||
109
- manifest.source_name !== manifest.version + '-' + manifest.sha256.slice(0, 16)) continue;
115
+ !managedRuntimeName(manifest.source_name, manifest)) continue;
110
116
  compareVersions(manifest.version, manifest.version);
111
117
  // The manifest authorizes only this private child. It never supplies a
112
118
  // deletion path. Keep it outside runtime/ so interrupted deletion can