워크스페이스 기본 포트와 검증 문서를 실제 런타임 기본값에 맞추고, 브리지 경계에서 adapter config 타입 정보를 보존해야 이후 원격 smoke와 경계 안정화 작업이 같은 계약을 사용할 수 있다.
81 lines
2.4 KiB
Go
81 lines
2.4 KiB
Go
package node
|
|
|
|
import (
|
|
"iop/packages/go/config"
|
|
iop "iop/proto/gen/iop"
|
|
)
|
|
|
|
// BuildConfigPayload converts a NodeRecord's adapter config to the proto payload
|
|
// sent to node during registration.
|
|
func BuildConfigPayload(rec *NodeRecord) (*iop.NodeConfigPayload, error) {
|
|
payload := &iop.NodeConfigPayload{
|
|
Runtime: &iop.NodeRuntimeConfig{
|
|
Concurrency: int32(rec.Runtime.Concurrency),
|
|
WorkspaceRoot: rec.Runtime.WorkspaceRoot,
|
|
},
|
|
}
|
|
|
|
payload.Adapters = append(payload.Adapters, &iop.AdapterConfig{
|
|
Type: "mock",
|
|
Enabled: true,
|
|
Config: &iop.AdapterConfig_Mock{Mock: &iop.MockAdapterConfig{}},
|
|
})
|
|
|
|
if rec.Adapters.Ollama.Enabled {
|
|
payload.Adapters = append(payload.Adapters, &iop.AdapterConfig{
|
|
Type: "ollama",
|
|
Enabled: true,
|
|
Config: &iop.AdapterConfig_Ollama{
|
|
Ollama: &iop.OllamaAdapterConfig{
|
|
BaseUrl: rec.Adapters.Ollama.BaseURL,
|
|
ContextSize: int32(rec.Adapters.Ollama.ContextSize),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
if rec.Adapters.Vllm.Enabled {
|
|
payload.Adapters = append(payload.Adapters, &iop.AdapterConfig{
|
|
Type: "vllm",
|
|
Enabled: true,
|
|
Config: &iop.AdapterConfig_Vllm{
|
|
Vllm: &iop.VllmAdapterConfig{Endpoint: rec.Adapters.Vllm.Endpoint},
|
|
},
|
|
})
|
|
}
|
|
if rec.Adapters.CLI.Enabled {
|
|
profiles := make(map[string]*iop.CLIProfileConfig, len(rec.Adapters.CLI.Profiles))
|
|
for name, p := range rec.Adapters.CLI.Profiles {
|
|
profiles[name] = cliProfileToProto(p)
|
|
}
|
|
payload.Adapters = append(payload.Adapters, &iop.AdapterConfig{
|
|
Type: "cli",
|
|
Enabled: true,
|
|
Config: &iop.AdapterConfig_Cli{
|
|
Cli: &iop.CLIAdapterConfig{Profiles: profiles},
|
|
},
|
|
})
|
|
}
|
|
return payload, nil
|
|
}
|
|
|
|
func cliProfileToProto(p config.CLIProfileConf) *iop.CLIProfileConfig {
|
|
out := &iop.CLIProfileConfig{
|
|
Command: p.Command,
|
|
Args: append([]string(nil), p.Args...),
|
|
Env: append([]string(nil), p.Env...),
|
|
Persistent: p.Persistent,
|
|
Terminal: p.Terminal,
|
|
ResponseIdleTimeoutMs: int32(p.ResponseIdleTimeoutMS),
|
|
StartupIdleTimeoutMs: int32(p.StartupIdleTimeoutMS),
|
|
OutputFormat: p.OutputFormat,
|
|
Mode: p.Mode,
|
|
ResumeArgs: append([]string(nil), p.ResumeArgs...),
|
|
}
|
|
if !p.CompletionMarker.Empty() {
|
|
out.CompletionMarker = &iop.CLICompletionMarker{
|
|
Line: p.CompletionMarker.Line,
|
|
Regex: p.CompletionMarker.Regex,
|
|
}
|
|
}
|
|
return out
|
|
}
|