Skip to content

Commit 106e144

Browse files
committed
Release 1.252.2025
1 parent d803cf1 commit 106e144

10 files changed

Lines changed: 94 additions & 39 deletions

Functions/GenXdev.AI.Queries/Get-ScriptExecutionErrorFixPrompt.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ function Get-ScriptExecutionErrorFixPrompt {
714714
'Method=string',
715715
'UserAgent=string'
716716
)
717-
OutputText = $false
717+
OutputText = $true
718718
Confirm = $false
719719
JsonDepth = 6
720720
},

Functions/GenXdev.AI.Queries/Show-FoundImagesInBrowser.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ function Show-FoundImagesInBrowser {
609609

610610
# generate masonry layout html with specified parameters
611611
$null = GenXdev.AI\GenerateMasonryLayoutHtml @params `
612-
-Images $results
612+
-Images $results -FilePath $filePath
613613

614614
# log successful html generation
615615
Microsoft.PowerShell.Utility\Write-Verbose (

Functions/GenXdev.AI/Approve-NewTextFileContent.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
###############################################################################
1+
###############################################################################
22
<#
33
.SYNOPSIS
44
Interactive file content comparison and approval using WinMerge.
@@ -328,7 +328,7 @@ function Approve-NewTextFileContent {
328328
Microsoft.PowerShell.Utility\Write-Verbose "Created temp comparison file: $tempFile"
329329

330330
# write proposed content to temp file
331-
$NewContent | Microsoft.PowerShell.Utility\Out-File -FilePath $tempFile -Force
331+
$NewContent | Microsoft.PowerShell.Utility\Out-File $tempFile -Force
332332

333333
# launch winmerge for interactive comparison
334334
$null = GenXdev.AI\Invoke-WinMerge `

Functions/GenXdev.AI/GenerateMasonryLayoutHtml.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,13 @@ function GenerateMasonryLayoutHtml {
320320

321321
end {
322322
# Either return HTML string or save to file based on parameters
323-
if ($null -eq $FilePath) {
323+
if ([string]::IsNullOrWhiteSpace($FilePath)) {
324324
Microsoft.PowerShell.Utility\Write-Verbose 'Returning HTML as string output'
325325
return $html
326326
}
327327
else {
328328
Microsoft.PowerShell.Utility\Write-Verbose "Saving HTML gallery to: $FilePath"
329-
$html | Microsoft.PowerShell.Utility\Out-File -FilePath (GenXdev.FileSystem\Expand-Path $FilePath -CreateDirectory) -Encoding utf8
329+
$html | Microsoft.PowerShell.Utility\Out-File (GenXdev.FileSystem\Expand-Path $FilePath -CreateDirectory) -Encoding utf8
330330
}
331331
}
332332
}

Functions/GenXdev.AI/Invoke-CommandFromToolCall.ps1

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -485,28 +485,42 @@ function Invoke-CommandFromToolCall {
485485
}
486486
else {
487487

488-
if ($tmpResult -is [System.ValueType] -or
489-
$tmpResult -is [string]) {
490-
488+
# Convert to JSON directly with error handling
489+
try {
491490
$tmpResult = $tmpResult |
492491
Microsoft.PowerShell.Utility\ConvertTo-Json -Depth $jsonDepth `
493-
-ErrorAction SilentlyContinue `
494492
-WarningAction SilentlyContinue
495493
}
496-
else {
497-
498-
$tmpResult = $tmpResult | Microsoft.PowerShell.Core\ForEach-Object {
499-
$_ | Microsoft.PowerShell.Utility\ConvertTo-Json `
500-
-ErrorAction SilentlyContinue `
501-
-WarningAction SilentlyContinue `
502-
-Depth ($jsonDepth - 1) |
503-
Microsoft.PowerShell.Utility\ConvertFrom-Json `
504-
-ErrorAction SilentlyContinue `
505-
-WarningAction SilentlyContinue |
506-
GenXdev.Helpers\ConvertTo-HashTable
507-
} | Microsoft.PowerShell.Utility\ConvertTo-Json -Depth $jsonDepth `
508-
-ErrorAction SilentlyContinue `
509-
-WarningAction SilentlyContinue
494+
catch {
495+
# If JSON conversion fails, try to create a simplified representation
496+
Microsoft.PowerShell.Utility\Write-Verbose "JSON conversion failed for $($tmpResult.GetType().Name): $($_.Exception.Message)"
497+
498+
# Special handling for web response objects
499+
if ($tmpResult -is [Microsoft.PowerShell.Commands.WebResponseObject]) {
500+
$simplifiedWebResponse = @{
501+
StatusCode = $tmpResult.StatusCode
502+
StatusDescription = $tmpResult.StatusDescription
503+
Headers = @{}
504+
Content = if ($tmpResult.Content) { $tmpResult.Content.ToString() } else { "" }
505+
RawContentLength = $tmpResult.RawContentLength
506+
}
507+
508+
# Add headers safely
509+
foreach ($header in $tmpResult.Headers.GetEnumerator()) {
510+
try {
511+
$simplifiedWebResponse.Headers[$header.Name] = $header.Value -join ", "
512+
}
513+
catch {
514+
$simplifiedWebResponse.Headers[$header.Name] = "[Could not serialize header value]"
515+
}
516+
}
517+
518+
$tmpResult = $simplifiedWebResponse | Microsoft.PowerShell.Utility\ConvertTo-Json -Depth $jsonDepth
519+
}
520+
else {
521+
# For other types, fall back to string representation
522+
$tmpResult = $tmpResult | Microsoft.PowerShell.Utility\Out-String
523+
}
510524
}
511525
}
512526
}

Functions/GenXdev.AI/Invoke-LLMQuery.ps1

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -764,33 +764,48 @@ function Invoke-LLMQuery {
764764

765765
# store PSBoundParameters to avoid nested function issues
766766
$myPSBoundParameters = $PSBoundParameters
767+
Microsoft.PowerShell.Utility\Write-Verbose "PSBoundParameters keys: $($myPSBoundParameters.Keys -join ', ')"
768+
Microsoft.PowerShell.Utility\Write-Verbose "PSBoundParameters MaxToolcallBackLength: $($myPSBoundParameters['MaxToolcallBackLength'])"
767769

768770
# copy identical parameter values for llm configuration
769771
$llmConfigParams = GenXdev.Helpers\Copy-IdenticalParamValues `
770772
-BoundParameters $myPSBoundParameters `
771773
-FunctionName 'GenXdev.AI\Get-AILLMSettings' `
772774
-DefaultValues (Microsoft.PowerShell.Utility\Get-Variable `
773775
-Scope Local -ErrorAction SilentlyContinue)
776+
Microsoft.PowerShell.Utility\Write-Verbose "llmConfigParams keys: $($llmConfigParams.Keys -join ', ')"
777+
Microsoft.PowerShell.Utility\Write-Verbose "llmConfigParams MaxToolcallBackLength: $($llmConfigParams['MaxToolcallBackLength'])"
774778

775779
# get the llm settings configuration
776780
$llmConfig = GenXdev.AI\Get-AILLMSettings @llmConfigParams
781+
Microsoft.PowerShell.Utility\Write-Verbose "LLM Config keys: $($llmConfig.Keys -join ', ')"
782+
Microsoft.PowerShell.Utility\Write-Verbose "LLM Config MaxToolcallBackLength: $($llmConfig['MaxToolcallBackLength'])"
777783

778784
# apply configuration settings to local variables
779785
foreach ($param in $llmConfig.Keys) {
780786

781-
# check if variable exists in local scope
782-
if (($null -ne $llmConfig[$param]) -and (
787+
# check if variable exists in local scope and skip MaxToolcallBackLength to preserve user-specified value
788+
if (($null -ne $llmConfig[$param]) -and ($param -ne 'MaxToolcallBackLength') -and (
783789
Microsoft.PowerShell.Utility\Get-Variable -Name $param `
784790
-Scope Local -ErrorAction SilentlyContinue)) {
785791

792+
Microsoft.PowerShell.Utility\Write-Verbose "Setting $param to $($llmConfig[$param])"
786793
# set the variable value from configuration
787794
Microsoft.PowerShell.Utility\Set-Variable -Name $param `
788795
-Value $llmConfig[$param] -Scope Local -Force
789796
}
790797
}
798+
Microsoft.PowerShell.Utility\Write-Verbose "MaxToolcallBackLength after config override: $MaxToolcallBackLength"
791799

792800
# output verbose information about starting llm interaction
793801
Microsoft.PowerShell.Utility\Write-Verbose 'Starting LLM interaction...'
802+
Microsoft.PowerShell.Utility\Write-Verbose "MaxToolcallBackLength parameter value: $MaxToolcallBackLength"
803+
804+
# Ensure MaxToolcallBackLength has a reasonable minimum value
805+
if ($MaxToolcallBackLength -le 1000) {
806+
Microsoft.PowerShell.Utility\Write-Verbose "MaxToolcallBackLength was $MaxToolcallBackLength, forcing to 100000"
807+
$MaxToolcallBackLength = 100000
808+
}
794809

795810
# convert markup block types to lowercase for case-insensitive comparison
796811
$markupBlocksTypeFilter = $MarkupBlocksTypeFilter |
@@ -1632,14 +1647,26 @@ function Invoke-LLMQuery {
16321647

16331648
if ($isTextOnlyOutput) {
16341649
# For text-only output, convert everything to string first using Out-String
1650+
Microsoft.PowerShell.Utility\Write-Verbose "Tool '$($toolCall.function.name)' raw output type: $($invocationResult.Output.GetType().FullName)"
1651+
Microsoft.PowerShell.Utility\Write-Verbose "Tool '$($toolCall.function.name)' raw output count: $(if ($invocationResult.Output -is [Array]) { $invocationResult.Output.Count } else { '1 (not array)' })"
16351652
$outputText = "$(($invocationResult.Output | Microsoft.PowerShell.Utility\Out-String))".Trim()
1653+
Microsoft.PowerShell.Utility\Write-Verbose "Tool '$($toolCall.function.name)' text output length: $($outputText.Length) characters (max: $MaxToolcallBackLength)"
16361654

16371655
if ($outputText.Length -gt $MaxToolcallBackLength) {
16381656
$originalLength = $outputText.Length
16391657
$trimMessage = "TRIMMED OUTPUT (check parameter use!) invalid json on purpose, AI Agent: don't retry same function without check parameters! >>"
16401658
$maxContentLength = $MaxToolcallBackLength - $trimMessage.Length
1641-
$outputText = $trimMessage + $outputText.Substring(0, $maxContentLength)
1642-
Microsoft.PowerShell.Utility\Write-Verbose "Tool '$($toolCall.function.name)' output was trimmed from $originalLength to $MaxToolcallBackLength characters"
1659+
1660+
Microsoft.PowerShell.Utility\Write-Verbose "Tool '$($toolCall.function.name)' MaxToolcallBackLength: $MaxToolcallBackLength, trimMessage.Length: $($trimMessage.Length), maxContentLength: $maxContentLength"
1661+
1662+
# Handle output trimming with proper length validation
1663+
if ($maxContentLength -le 0) {
1664+
Microsoft.PowerShell.Utility\Write-Warning "MaxToolcallBackLength ($MaxToolcallBackLength) is too small for trim message ($($trimMessage.Length) chars)"
1665+
$outputText = "Output too large to display"
1666+
} else {
1667+
$outputText = $trimMessage + $outputText.Substring(0, $maxContentLength)
1668+
}
1669+
Microsoft.PowerShell.Utility\Write-Verbose "Tool '$($toolCall.function.name)' output was trimmed from $originalLength to $($outputText.Length) characters"
16431670
}
16441671

16451672
# Add tool response to history
@@ -1684,8 +1711,15 @@ function Invoke-LLMQuery {
16841711
$originalLength = $parsedOutput.Length
16851712
$trimMessage = "TRIMMED JSON OUTPUT (check parameter use!) incomplete json data, AI Agent: don't retry same function without checking parameters! >>"
16861713
$maxContentLength = $MaxToolcallBackLength - $trimMessage.Length
1687-
$content = $trimMessage + $parsedOutput.Substring(0, $maxContentLength)
1688-
Microsoft.PowerShell.Utility\Write-Verbose "Tool '$($toolCall.function.name)' JSON output was trimmed from $originalLength to $MaxToolcallBackLength characters (even at minimum depth 2)"
1714+
Microsoft.PowerShell.Utility\Write-Verbose "Tool '$($toolCall.function.name)' JSON MaxToolcallBackLength: $MaxToolcallBackLength, trimMessage.Length: $($trimMessage.Length), maxContentLength: $maxContentLength"
1715+
1716+
if ($maxContentLength -le 0) {
1717+
Microsoft.PowerShell.Utility\Write-Warning "MaxToolcallBackLength ($MaxToolcallBackLength) is too small for JSON trim message ($($trimMessage.Length) chars)"
1718+
$content = "JSON output too large to display"
1719+
} else {
1720+
$content = $trimMessage + $parsedOutput.Substring(0, $maxContentLength)
1721+
}
1722+
Microsoft.PowerShell.Utility\Write-Verbose "Tool '$($toolCall.function.name)' JSON output was trimmed from $originalLength to $($content.Length) characters (even at minimum depth 2)"
16891723
}
16901724
} catch {
16911725
# If JSON conversion fails, fall back to text with trimming
@@ -1694,8 +1728,15 @@ function Invoke-LLMQuery {
16941728
$originalLength = $outputText.Length
16951729
$trimMessage = "TRIMMED OUTPUT (check parameter use!) invalid json on purpose, AI Agent: don't retry same function without check parameters! >>"
16961730
$maxContentLength = $MaxToolcallBackLength - $trimMessage.Length
1697-
$outputText = $trimMessage + $outputText.Substring(0, $maxContentLength)
1698-
Microsoft.PowerShell.Utility\Write-Verbose "Tool '$($toolCall.function.name)' fallback output was trimmed from $originalLength to $MaxToolcallBackLength characters"
1731+
Microsoft.PowerShell.Utility\Write-Verbose "Tool '$($toolCall.function.name)' fallback MaxToolcallBackLength: $MaxToolcallBackLength, trimMessage.Length: $($trimMessage.Length), maxContentLength: $maxContentLength"
1732+
1733+
if ($maxContentLength -le 0) {
1734+
Microsoft.PowerShell.Utility\Write-Warning "MaxToolcallBackLength ($MaxToolcallBackLength) is too small for fallback trim message ($($trimMessage.Length) chars)"
1735+
$outputText = "Fallback output too large to display"
1736+
} else {
1737+
$outputText = $trimMessage + $outputText.Substring(0, $maxContentLength)
1738+
}
1739+
Microsoft.PowerShell.Utility\Write-Verbose "Tool '$($toolCall.function.name)' fallback output was trimmed from $originalLength to $($outputText.Length) characters"
16991740
}
17001741
$content = $outputText
17011742
}

Functions/GenXdev.AI/New-LLMAudioChat.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ function New-LLMAudioChat {
10161016
'Method=string',
10171017
'UserAgent=string'
10181018
)
1019-
OutputText = $false
1019+
OutputText = $true
10201020
Confirm = $false
10211021
JsonDepth = 6
10221022
},

Functions/GenXdev.AI/New-LLMTextChat.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ function New-LLMTextChat {
766766
'Method=string',
767767
'UserAgent=string'
768768
)
769-
OutputText = $false
769+
OutputText = $true
770770
Confirm = $false
771771
JsonDepth = 6
772772
},

Functions/GenXdev.AI/Start-GenXdevMCPServer.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function Start-GenXdevMCPServer {
9999
}
100100
serverInfo = @{
101101
name = 'GenXdev-PowerShell-MCP-Server'
102-
version = '1.250.2025'
102+
version = '1.252.2025'
103103
}
104104
}
105105
}
@@ -197,7 +197,7 @@ function Start-GenXdevMCPServer {
197197
}
198198
serverInfo = @{
199199
name = 'GenXdev-PowerShell-MCP-Server'
200-
version = '1.250.2025'
200+
version = '1.252.2025'
201201
}
202202
}
203203
}

GenXdev.AI.psd1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: genXdev
55
#
6-
# Generated on: 20/08/2025
6+
# Generated on: 21/08/2025
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
RootModule = 'GenXdev.AI.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.250.2025'
15+
ModuleVersion = '1.252.2025'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = 'Core'
@@ -51,7 +51,7 @@ ClrVersion = '9.0.0.1'
5151
ProcessorArchitecture = 'Amd64'
5252

5353
# Modules that must be imported into the global environment prior to importing this module
54-
RequiredModules = @(@{ModuleName = 'GenXdev.Queries'; ModuleVersion = '1.250.2025'; })
54+
RequiredModules = @(@{ModuleName = 'GenXdev.Queries'; ModuleVersion = '1.252.2025'; })
5555

5656
# Assemblies that must be loaded prior to importing this module
5757
# RequiredAssemblies = @()

0 commit comments

Comments
 (0)