-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
executable file
·102 lines (95 loc) · 4.64 KB
/
Copy pathsetup.ps1
File metadata and controls
executable file
·102 lines (95 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<#
.SYNOPSIS
Install Hermimo Link v1.0.5 on a Hermes or MiMo endpoint.
.EXAMPLE
.\setup.ps1 -Agent hermes -SharedDir C:\Users\me\.hermimo-link
.EXAMPLE
.\setup.ps1 -Agent mimo -SharedDir C:\Users\me\.hermimo-link -SkillDir C:\path\to\agent\skills
#>
param(
[string]$Agent = $env:HERMIMO_AGENT,
[string]$SharedDir = $(if ($env:HERMIMO_LINK_DIR) { $env:HERMIMO_LINK_DIR } elseif ($env:HANDSHAKE_DIR) { $env:HANDSHAKE_DIR } else { "$env:USERPROFILE\.hermimo-link" }),
[string]$SkillDir = '',
[double]$PollInterval = 0.2,
[switch]$SkipSelfTest,
[switch]$NoPersist
)
$ErrorActionPreference = 'Stop'
if ($Agent -notin @('hermes', 'mimo')) {
throw 'Specify -Agent hermes or -Agent mimo so automatic routing knows this endpoint.'
}
if ($PollInterval -le 0) {
throw '-PollInterval must be positive.'
}
$SourceDir = $PSScriptRoot
$SharedDir = [System.IO.Path]::GetFullPath($SharedDir)
$PollText = $PollInterval.ToString([System.Globalization.CultureInfo]::InvariantCulture)
$Folders = @(
'inbox\hermes', 'inbox\mimo', 'processing\hermes', 'processing\mimo',
'results', 'events', 'archive\hermes', 'archive\mimo',
'dead-letter\hermes', 'dead-letter\mimo', 'state', 'logs', 'scripts', 'references', 'instructions'
)
Write-Host "Hermimo Link v1.0.5 setup ($Agent)" -ForegroundColor Cyan
foreach ($Folder in $Folders) {
New-Item -ItemType Directory -Force -Path (Join-Path $SharedDir $Folder) | Out-Null
}
Copy-Item -Path (Join-Path $SourceDir 'scripts\*.py') -Destination (Join-Path $SharedDir 'scripts') -Force
Copy-Item -Path (Join-Path $SourceDir 'references\*.md') -Destination (Join-Path $SharedDir 'references') -Force
Copy-Item -Path (Join-Path $SourceDir 'instructions\*.md') -Destination (Join-Path $SharedDir 'instructions') -Force
Copy-Item -LiteralPath (Join-Path $SourceDir 'SKILL.md') -Destination $SharedDir -Force
foreach ($OptionalFile in @('README.md', 'LICENSE')) {
$OptionalPath = Join-Path $SourceDir $OptionalFile
if (Test-Path -LiteralPath $OptionalPath) {
Copy-Item -LiteralPath $OptionalPath -Destination $SharedDir -Force
}
}
if ($SkillDir) {
$SkillTarget = Join-Path ([System.IO.Path]::GetFullPath($SkillDir)) 'hermimo-link'
New-Item -ItemType Directory -Force -Path $SkillTarget | Out-Null
New-Item -ItemType Directory -Force -Path (Join-Path $SkillTarget 'scripts') | Out-Null
New-Item -ItemType Directory -Force -Path (Join-Path $SkillTarget 'references') | Out-Null
New-Item -ItemType Directory -Force -Path (Join-Path $SkillTarget 'agents') | Out-Null
Copy-Item -LiteralPath (Join-Path $SourceDir 'SKILL.md') -Destination $SkillTarget -Force
Copy-Item -Path (Join-Path $SourceDir 'scripts\*.py') -Destination (Join-Path $SkillTarget 'scripts') -Force
Copy-Item -Path (Join-Path $SourceDir 'references\*.md') -Destination (Join-Path $SkillTarget 'references') -Force
Copy-Item -Path (Join-Path $SourceDir 'agents\*.yaml') -Destination (Join-Path $SkillTarget 'agents') -Force
@{ agent = $Agent; package_version = '1.0.5' } | ConvertTo-Json | Set-Content -LiteralPath (Join-Path $SkillTarget 'endpoint.json') -Encoding UTF8
Write-Host "Skill installed: $SkillTarget" -ForegroundColor Green
}
$env:HERMIMO_LINK_DIR = $SharedDir
$env:HERMIMO_AGENT = $Agent
$env:HERMIMO_POLL_INTERVAL = $PollText
if (-not $NoPersist) {
[Environment]::SetEnvironmentVariable('HERMIMO_LINK_DIR', $SharedDir, 'User')
[Environment]::SetEnvironmentVariable('HERMIMO_AGENT', $null, 'User')
[Environment]::SetEnvironmentVariable('HERMIMO_POLL_INTERVAL', $PollText, 'User')
}
if (-not $SkipSelfTest) {
$PythonExe = $null
$PythonPrefix = @()
$PythonCommand = Get-Command python -ErrorAction SilentlyContinue
if ($PythonCommand) {
$PythonExe = $PythonCommand.Source
} else {
$PyCommand = Get-Command py -ErrorAction SilentlyContinue
if ($PyCommand) {
$PythonExe = $PyCommand.Source
$PythonPrefix = @('-3')
}
}
if ($PythonExe) {
& $PythonExe @PythonPrefix (Join-Path $SourceDir 'scripts\self_test.py')
if ($LASTEXITCODE -ne 0) {
throw 'Hermimo Link self-test failed.'
}
} else {
Write-Warning 'Python 3 was not found; runtime self-test was skipped.'
}
}
Write-Host "Shared directory: $SharedDir" -ForegroundColor Green
Write-Host "Endpoint identity: $Agent" -ForegroundColor Green
Write-Host "Polling interval: ${PollText}s" -ForegroundColor Green
Write-Host 'Open a new terminal, then start this endpoint worker:' -ForegroundColor Yellow
Write-Host " python $SharedDir\scripts\worker.py --agent $Agent"
Write-Host 'Both endpoints must use the same physical HERMIMO_LINK_DIR.' -ForegroundColor Yellow
Write-Host 'For an existing Windows MiMo + WSL Hermes installation, run upgrade.cmd instead.' -ForegroundColor Yellow