feat: optimize security and deployment of agent skills

This commit is contained in:
nullkey
2026-02-04 17:11:58 +08:00
committed by lyingbug
parent 3f21345546
commit 43a2c647ea
19 changed files with 1335 additions and 154 deletions
+47 -3
View File
@@ -310,6 +310,32 @@ check_platform() {
log_info "当前平台:$PLATFORM"
}
# 预拉取沙箱镜像(Agent Skills 执行所需,仅拉取不启动)
ensure_sandbox_image() {
local sandbox_image="wechatopenai/weknora-sandbox:${WEKNORA_VERSION:-latest}"
# 检查本地是否已存在沙箱镜像
if docker image inspect "$sandbox_image" &> /dev/null; then
log_success "沙箱镜像已就绪: $sandbox_image"
return 0
fi
log_info "沙箱镜像 ($sandbox_image) 未检测到,正在后台拉取..."
log_info "Agent Skills 功能依赖此镜像,首次执行前需要拉取完成"
# 后台拉取,不阻塞主流程
(
if PLATFORM=$PLATFORM "$DOCKER_COMPOSE_BIN" $DOCKER_COMPOSE_SUBCMD --profile sandbox pull sandbox 2>/dev/null; then
log_success "沙箱镜像拉取完成: $sandbox_image"
else
log_warning "沙箱镜像拉取失败,Agent Skills 功能可能不可用"
log_warning "可稍后手动拉取: $DOCKER_COMPOSE_BIN $DOCKER_COMPOSE_SUBCMD --profile sandbox pull sandbox"
fi
) &
return 0
}
# 启动Docker容器
start_docker() {
log_info "正在启动Docker容器..."
@@ -350,11 +376,14 @@ start_docker() {
fi
log_success "所有Docker容器已成功启动"
# 显示容器状态
log_info "当前容器状态:"
"$DOCKER_COMPOSE_BIN" $DOCKER_COMPOSE_SUBCMD ps
# 预拉取Sandbox镜像(Agent Skills 执行所需,仅拉取不启动)
ensure_sandbox_image
return 0
}
@@ -432,7 +461,12 @@ pull_images() {
log_error "镜像拉取失败"
return 1
fi
# 拉取 sandbox 镜像(sandbox 在 profile 中,需要单独拉取)
log_info "拉取沙箱镜像..."
PLATFORM=$PLATFORM "$DOCKER_COMPOSE_BIN" $DOCKER_COMPOSE_SUBCMD --profile sandbox pull sandbox 2>/dev/null || \
log_warning "沙箱镜像拉取失败(非必需,跳过)"
log_success "所有镜像已成功拉取到最新版本"
# 显示拉取的镜像信息
@@ -531,6 +565,16 @@ check_environment() {
fi
fi
# 检查沙箱镜像
log_info "检查沙箱镜像..."
local sandbox_image="wechatopenai/weknora-sandbox:${WEKNORA_VERSION:-latest}"
if docker image inspect "$sandbox_image" &> /dev/null; then
log_success "沙箱镜像已就绪: $sandbox_image"
else
log_warning "沙箱镜像未找到: $sandbox_image (Agent Skills 功能需要此镜像)"
log_info "可通过以下命令拉取: $0 -p 或 docker pull $sandbox_image"
fi
# 检查磁盘空间
log_info "检查磁盘空间..."
df -h | grep -E "(Filesystem|/$)"