Support direct CF and CFE inputs in AI structure flow
CI / python (push) Has been cancelled
CI / rust (push) Has been cancelled

This commit is contained in:
2026-05-22 00:45:57 +03:00
parent b85bff6e06
commit de8b0eb795
3 changed files with 187 additions and 19 deletions
+100 -2
View File
@@ -694,6 +694,100 @@ function Export-CfOrCfeFromInfobase {
return $exportRoot
}
function Convert-LocalCfOrCfeToMetadataExport {
param([object]$Job, [string[]]$PlatformBins)
$payloadPath = [string]$Job.local_path
if ([string]::IsNullOrWhiteSpace($payloadPath)) {
throw "local_path is required for direct CF/CFE conversion."
}
if (!(Test-Path -LiteralPath $payloadPath)) {
throw "Local CF/CFE path not found on agent machine: $payloadPath"
}
$designerPath = Get-DesignerBinPath -Job $Job -PlatformBins $PlatformBins
$workRoot = Join-Path $env:TEMP "sfera-agent"
$exportRoot = Join-Path $workRoot "$($Job.job_id)-local-binary"
if (Test-Path -LiteralPath $exportRoot) { Remove-Item -LiteralPath $exportRoot -Recurse -Force }
New-Item -ItemType Directory -Force -Path $exportRoot | Out-Null
$builderInfobase = Join-Path $exportRoot "builder-infobase"
$createLog = Join-Path $exportRoot "create-builder-infobase.log"
Invoke-1CCommand `
-PlatformPath $designerPath `
-Arguments @("CREATEINFOBASE", "File=$builderInfobase;") `
-LogPath $createLog `
-JobId $Job.job_id `
-ActionTitle "1C CREATEINFOBASE for local CF/CFE conversion" `
-TimeoutSeconds 180
$builderArgs = @("/F", $builderInfobase)
$sourceKind = [string]$Job.source
$fileName = [System.IO.Path]::GetFileName($payloadPath)
$artifactsRoot = Join-Path $exportRoot "artifacts"
New-Item -ItemType Directory -Force -Path $artifactsRoot | Out-Null
Copy-Item -LiteralPath $payloadPath -Destination (Join-Path $artifactsRoot $fileName) -Force
if ($sourceKind -eq "CF_FILE") {
$loadLog = Join-Path $exportRoot "designer-loadcfg-local-cf.log"
Invoke-DesignerCommand `
-DesignerPath $designerPath `
-Arguments (@($builderArgs) + @("/LoadCfg", $payloadPath)) `
-LogPath $loadLog `
-JobId $Job.job_id `
-ActionTitle "1C LoadCfg local CF" `
-TimeoutSeconds 180
$metadataRoot = Join-Path $exportRoot "configuration"
New-Item -ItemType Directory -Force -Path $metadataRoot | Out-Null
$metadataLog = Join-Path $exportRoot "designer-dumpconfigtofiles-local-cf.log"
Invoke-DesignerCommand `
-DesignerPath $designerPath `
-Arguments (@($builderArgs) + @("/DumpConfigToFiles", $metadataRoot, "-Format", "Hierarchical")) `
-LogPath $metadataLog `
-JobId $Job.job_id `
-ActionTitle "1C DumpConfigToFiles from local CF" `
-TimeoutSeconds 180
Copy-Item -LiteralPath $payloadPath -Destination (Join-Path $metadataRoot $fileName) -Force
Send-JobLogs -JobId $Job.job_id -Logs @("Local .cf converted to metadata export for server-side parsing.")
return $exportRoot
}
if ($sourceKind -eq "CFE_FILE") {
$extensionName = Get-JobMetadataValue -Job $Job -Key "one_c_extension"
if ([string]::IsNullOrWhiteSpace($extensionName)) {
$extensionName = [System.IO.Path]::GetFileNameWithoutExtension($payloadPath)
}
if ([string]::IsNullOrWhiteSpace($extensionName)) {
throw "Extension name is required for local CFE conversion."
}
$loadLog = Join-Path $exportRoot "designer-loadcfg-local-cfe.log"
Invoke-DesignerCommand `
-DesignerPath $designerPath `
-Arguments (@($builderArgs) + @("/LoadCfg", $payloadPath, "-Extension", $extensionName, "/UpdateDBCfg")) `
-LogPath $loadLog `
-JobId $Job.job_id `
-ActionTitle "1C LoadCfg local CFE" `
-TimeoutSeconds 180
$metadataRoot = Join-Path $exportRoot "extension"
New-Item -ItemType Directory -Force -Path $metadataRoot | Out-Null
$metadataLog = Join-Path $exportRoot "designer-dumpconfigtofiles-local-cfe.log"
Invoke-DesignerCommand `
-DesignerPath $designerPath `
-Arguments (@($builderArgs) + @("/DumpConfigToFiles", $metadataRoot, "-Format", "Hierarchical", "-Extension", $extensionName)) `
-LogPath $metadataLog `
-JobId $Job.job_id `
-ActionTitle "1C DumpConfigToFiles from local CFE" `
-TimeoutSeconds 180
Copy-Item -LiteralPath $payloadPath -Destination (Join-Path $metadataRoot $fileName) -Force
Send-JobLogs -JobId $Job.job_id -Logs @("Local .cfe converted to metadata export for server-side parsing.")
return $exportRoot
}
throw "Unsupported source for local CF/CFE conversion: $sourceKind"
}
function Install-SferaExtensionJob {
param([object]$Job, [string[]]$PlatformBins)
$workRoot = Join-Path $env:TEMP "sfera-agent"
@@ -1138,8 +1232,12 @@ while ($true) {
continue
}
$payloadPath = $job.local_path
if (($job.source -eq "CF_FILE") -or (($job.source -eq "CFE_FILE") -and [string]::IsNullOrWhiteSpace($payloadPath))) {
$payloadPath = Export-CfOrCfeFromInfobase -Job $job -PlatformBins $platformBins
if (($job.source -eq "CF_FILE") -or ($job.source -eq "CFE_FILE")) {
if (![string]::IsNullOrWhiteSpace($payloadPath)) {
$payloadPath = Convert-LocalCfOrCfeToMetadataExport -Job $job -PlatformBins $platformBins
} else {
$payloadPath = Export-CfOrCfeFromInfobase -Job $job -PlatformBins $platformBins
}
}
if ([string]::IsNullOrWhiteSpace($payloadPath)) {
throw "Job does not contain local_path or enough 1C infobase settings for agent export."