@@ -43,7 +43,12 @@ function Assert-Docker {
43
43
44
44
function New-RandomHex ($bytes ) {
45
45
$buffer = New-Object byte[] $bytes
46
- [System.Security.Cryptography.RandomNumberGenerator ]::Fill($buffer )
46
+ $rng = [System.Security.Cryptography.RandomNumberGenerator ]::Create()
47
+ try {
48
+ $rng.GetBytes ($buffer )
49
+ } finally {
50
+ $rng.Dispose ()
51
+ }
47
52
($buffer | ForEach-Object { $_.ToString (' x2' ) }) -join ' '
48
53
}
49
54
@@ -251,49 +256,49 @@ function Start-Stack($apiPort, $ui) {
251
256
# Create convenience startup script for Windows
252
257
$start = @ (
253
258
" Set-StrictMode -Version Latest" ,
254
- " $ErrorActionPreference = 'Stop'" ,
259
+ " ` $ ErrorActionPreference = 'Stop'" ,
255
260
" " ,
256
261
' function Write-Info($msg) { Write-Host "[INFO] $msg" -ForegroundColor Cyan }' ,
257
262
' function Write-Warn($msg) { Write-Host "[WARN] $msg" -ForegroundColor Yellow }' ,
258
263
" " ,
259
- " $apiPortVar = \ " $apiPort \ " " ,
264
+ " ` $ apiPortVar = ` "$apiPort ` "" ,
260
265
" # Read desired port from morphik.toml if available" ,
261
- " $desired = $apiPortVar " ,
266
+ " ` $ desired = ` $ apiPortVar" ,
262
267
" if (Test-Path 'morphik.toml') {" ,
263
- " $lines = Get-Content morphik.toml" ,
264
- " $inApi = $false ; $p = $null " ,
265
- " foreach ($l in $lines ) {" ,
266
- " if ($l -match '^\\s*\\[api\\]\\s*$') { $inApi = $true ; continue }" ,
267
- " if ($inApi -and $l -match '^\\s*\\[') { break }" ,
268
- " if ($inApi -and $l -match '^\\s*port\\s*=\\s*\ " ? (\\\\ d+ )\ " ?') {" ,
269
- " $p = $Matches [1]; break } }" ,
270
- " if ($p ) { $desired = $p }" ,
268
+ " ` $ lines = Get-Content morphik.toml" ,
269
+ " ` $ inApi = ` $ false; ` $ p = ` $ null" ,
270
+ " foreach (` $ l in ` $ lines) {" ,
271
+ " if (` $ l -match '^\\s*\\[api\\]\\s*` $ ') { ` $ inApi = ` $ true; continue }" ,
272
+ " if (` $ inApi -and ` $ l -match '^\\s*\\[') { break }" ,
273
+ " if (` $ inApi -and ` $ l -match '^\\s*port\\s*=\\s*` " ?(\\d+)` " ?') {" ,
274
+ " ` $ p = ` $ Matches[1]; break } }" ,
275
+ " if (` $ p) { ` $ desired = ` $ p }" ,
271
276
" }" ,
272
277
" " ,
273
278
" # Update port mapping in compose file if needed" ,
274
- " $compose = Get-Content 'docker-compose.run.yml' -Raw" ,
275
- " if ($compose -match '\ " (\\\ d+ ):(\\\ d+ )\ " ') {" ,
276
- " $current = $Matches [1]" ,
277
- " if ($current -ne $desired ) {" ,
278
- ' $compose = $compose -replace ' " ' + $current + ':' + $current + ' " ' , ' " ' + $ desired + ':' + $ desired + ' " ' ",
279
- " Set-Content ' docker- compose.run.yml' -Value $compose -Encoding UTF8 } }",
279
+ " ` $ compose = Get-Content 'docker-compose.run.yml' -Raw" ,
280
+ " if (` $ compose -match '` " (\\d+):(\\d+)` " ') {" ,
281
+ " ` $ current = ` $ Matches[1]" ,
282
+ " if (` $ current -ne ` $ desired) {" ,
283
+ " ` $ compose = ` $ compose -replace `"` $ current: ` $ current`" , `"`$ ( `$ desired): `$ ( `$ desired) `" " ,
284
+ " Set-Content 'docker-compose.run.yml' -Value ` $ compose -Encoding UTF8 } }" ,
280
285
" " ,
281
286
" # Warn if multimodal embeddings disabled" ,
282
287
" if (Test-Path 'morphik.toml') {" ,
283
- " $cfg = Get-Content morphik.toml -Raw",
284
- " if ($cfg -match ' (?m)^enable_colpali\\s*= \\s* false' ) {",
288
+ " ` $ cfg = Get-Content morphik.toml -Raw" ,
289
+ " if (` $ cfg -match '(?m)^enable_colpali\\s*=\\s*false') {" ,
285
290
" Write-Warn 'Multimodal embeddings are disabled. Enable in morphik.toml if you have a GPU.' } }" ,
286
291
" " ,
287
292
" # Include UI profile if installed" ,
288
- "$ui = $false",
293
+ " ` $ ui = ` $ false" ,
289
294
" if (Test-Path '.env') {" ,
290
- " $envText = Get-Content .env -Raw",
291
- " if ($envText -match ' UI_INSTALLED= true' ) { $ui = $true } }",
295
+ " ` $ envText = Get-Content .env -Raw" ,
296
+ " if (` $ envText -match 'UI_INSTALLED=true') { ` $ ui = ` $ true } }" ,
292
297
" " ,
293
- "$args = @(' -f ' ,' docker- compose.run.yml' )",
294
- "if ($ui) { $args += @(' -- profile' ,' ui' ) }",
298
+ " ` $ args = @('-f','docker-compose.run.yml')" ,
299
+ " if (` $ ui) { ` $ args += @('--profile','ui') }" ,
295
300
" docker compose @args up -d" ,
296
- ' Write-Host ( " Morphik is running on http://localhost:${ desired} " ) '
301
+ " Write-Host ` " Morphik is running on http://localhost:`$ ( `$ desired) `" "
297
302
) -join [Environment ]::NewLine
298
303
Set-Content - Path ' start-morphik.ps1' - Value $start - Encoding UTF8
299
304
}
0 commit comments