import test from 'node:test'; import assert from 'node:assert/strict'; import fs from 'node:fs'; import path from 'node:path'; import capabilityDescriptor from '../capabilities/openclaw-watchdog-reference.json' with { type: 'json' }; import exampleDescriptor from '../examples/openclaw-watchdog-reference.descriptor.example.json' with { type: 'json' }; import { createDeploymentBindingContract } from '../src/storage/profile-artifact.mjs'; import profileArtifact from '../profiles/strict-manager-mode.profile.json' with { type: 'json' }; const packageRoot = path.resolve(import.meta.dirname, '..'); const repoRoot = path.resolve(packageRoot, '..', '..'); function resolvePackageEntrypoint(entrypoint) { return path.resolve(packageRoot, entrypoint); } test('capability descriptor and example entrypoint resolve from package root to the package-owned orchestrator', () => { const canonicalPath = path.resolve(packageRoot, 'scripts/watchdog_auto_notify_orchestrator.mjs'); const descriptorEntrypoint = resolvePackageEntrypoint(capabilityDescriptor.runtime.entrypoint); const exampleEntrypoint = resolvePackageEntrypoint(exampleDescriptor.runtime.entrypoint); assert.equal(capabilityDescriptor.runtime.entrypoint, 'scripts/watchdog_auto_notify_orchestrator.mjs'); assert.equal(exampleDescriptor.runtime.entrypoint, 'scripts/watchdog_auto_notify_orchestrator.mjs'); assert.equal(descriptorEntrypoint, canonicalPath); assert.equal(exampleEntrypoint, canonicalPath); assert.equal(fs.existsSync(canonicalPath), true); }); test('deployment profile binding stays repo-root-relative while targeting the same package-owned orchestrator', () => { const binding = createDeploymentBindingContract({ artifact: profileArtifact, repoRootOverride: repoRoot }); const canonicalPath = path.resolve(packageRoot, 'scripts/watchdog_auto_notify_orchestrator.mjs'); assert.equal(profileArtifact.spec.bindings.entrypoint, 'plugins/reporting-governance/scripts/watchdog_auto_notify_orchestrator.mjs'); assert.equal(binding.entrypoint, canonicalPath); assert.equal(binding.scripts.orchestrator, canonicalPath); });