跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

windows_resources.go

34 行 · 1.2 KB历史下载
1package guestos
2
3import (
4 "context"
5 _ "embed"
6)
7
8// WindowsVMResourceCeiling is the limit enforced by the Hyper-V management service.
9func WindowsVMResourceCeiling(hostMemoryGiB, hostCPUs int) (memoryGiB, cpus int) {
10 return min(256, hostMemoryGiB*3/4), min(64, hostCPUs)
11}
12
13type WindowsVMResourceState struct {
14 State string `json:"state"`
15 CPUs int `json:"cpus"`
16 MemoryStartup uint64 `json:"memory_startup_bytes"`
17 MemoryMinimum uint64 `json:"memory_minimum_bytes"`
18 MemoryMaximum uint64 `json:"memory_maximum_bytes"`
19 MemoryAssigned uint64 `json:"memory_assigned_bytes"`
20 DynamicMemory bool `json:"dynamic_memory"`
21}
22
23// MatchesAllocation checks the Hyper-V configuration applied on a cold start.
24func (s WindowsVMResourceState) MatchesAllocation(memoryGiB, cpus int) bool {
25 return s.DynamicMemory && s.MemoryMinimum == 4<<30 && s.MemoryStartup == 4<<30 &&
26 s.MemoryMaximum == uint64(memoryGiB)<<30 && s.CPUs == cpus
27}
28
29//go:embed windows_resources.ps1
30var windowsVMResourcesScript string
31
32func WindowsVMResources(ctx context.Context, root string, memoryGiB, cpus int) (WindowsVMResourceState, error) {
33 return windowsVMResources(ctx, root, memoryGiB, cpus)
34}