Files
mulit-agent/mulit_agent/build.ps1
T
toot 9e01cbbec0 feat(agent): 预设本机工具、stdio MCP 传输与多轮上下文
- 预设 12 个本机工具并默认启用,装好即是可操作电脑的 Agent、无需总控配置或安装:
  文件与文件夹的查看/读取/写入/建目录/移动/删除(默认不覆盖、删目录需 recursive、
  拒绝删除系统目录与用户根目录)、用默认程序打开网址或文件、时间与时区换算
  (tzdata 已随包内置)、查看进程、屏幕截图、读写剪贴板。
- 工具下发改为通用:任意 HTTP MCP 服务与 stdio 本机命令(Agent 拉起子进程,
  容忍 stdout 噪声,命令缺失或进程崩溃会明确回报),支持多工具并存、
  定义未变更时复用连接、替换/删除/退出时回收子进程。
- 多轮上下文:task_dispatch.history 作为此前的 user/assistant 文本拼接到本次请求前,
  OpenAI 兼容、Anthropic、Gemini 分别适配;Agent 侧独立校验与限幅。
- 工具级实时进度以 progress 事件回传;使用预设工具的任务标记为 builtin 执行来源。
- Skill 与历史内容上限与总控对齐,多个已批准 Skill 不再被静默截断。
- 修复 build.ps1 缺 UTF-8 BOM 导致 build.bat 在 PowerShell 5.1 下语法报错。
2026-09-16 15:31:00 +08:00

63 lines
2.7 KiB
PowerShell

$ErrorActionPreference = "Stop"
$projectRoot = $PSScriptRoot
$venvPython = Join-Path $projectRoot ".venv\Scripts\python.exe"
Set-Location -LiteralPath $projectRoot
if (Get-Process -Name "MultiClawAgent" -ErrorAction SilentlyContinue) {
throw "请先退出正在运行的 MultiClawAgent,再执行编译。"
}
# A local rebuild replaces the whole dist folder. Preserve the user's portable
# settings so a developer build does not unexpectedly erase pairing or LLM
# endpoint preferences. Secrets remain in Windows Credential Manager.
$existingConfig = Join-Path $projectRoot "dist\MultiClawAgent\config\agent-config.json"
$preservedConfig = $null
if (Test-Path -LiteralPath $existingConfig) {
$preservedConfig = Join-Path ([System.IO.Path]::GetTempPath()) ("MultiClawAgent-config-" + [guid]::NewGuid() + ".json")
Copy-Item -LiteralPath $existingConfig -Destination $preservedConfig -Force
}
if (-not (Test-Path -LiteralPath $venvPython)) {
python -m venv (Join-Path $projectRoot ".venv")
}
& $venvPython -m pip install --disable-pip-version-check -e ".[dev]"
& $venvPython -m PyInstaller `
--noconfirm `
--clean `
--windowed `
--name "MultiClawAgent" `
--paths "src" `
--hidden-import "keyring.backends.Windows" `
--hidden-import "pystray._win32" `
--copy-metadata "keyring" `
--distpath "dist" `
--workpath "build" `
"app.py"
$configTarget = Join-Path $projectRoot "dist\MultiClawAgent\config"
Copy-Item -LiteralPath (Join-Path $projectRoot "config") -Destination $configTarget -Recurse -Force
if ($preservedConfig -and (Test-Path -LiteralPath $preservedConfig)) {
Copy-Item -LiteralPath $preservedConfig -Destination (Join-Path $configTarget "agent-config.json") -Force
Remove-Item -LiteralPath $preservedConfig -Force
}
# Older preview builds exposed local LLM fields. The production design keeps
# provider configuration under controller control, so remove those obsolete
# portable settings while retaining the pairing and display-name preferences.
$packagedConfig = Join-Path $configTarget "agent-config.json"
$configObject = Get-Content -LiteralPath $packagedConfig -Raw | ConvertFrom-Json
$configObject.PSObject.Properties.Remove("llm_base_url")
$configObject.PSObject.Properties.Remove("llm_model")
$configObject | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath $packagedConfig -Encoding utf8
# PyInstaller's build folder is an intermediate cache, not a distributable
# application. Remove it so users only see the complete package in dist.
$buildTarget = Join-Path $projectRoot "build\MultiClawAgent"
if (Test-Path -LiteralPath $buildTarget) {
Remove-Item -LiteralPath $buildTarget -Recurse -Force
}
Write-Host "编译完成:$(Join-Path $projectRoot 'dist\MultiClawAgent\MultiClawAgent.exe')"