From 76a8ee5b3b2c8a3994b681ff4bbfce402bc5df5b Mon Sep 17 00:00:00 2001 From: toki Date: Mon, 15 Jun 2026 11:01:21 +0900 Subject: [PATCH] feat: lemonade provider serving validation - config contract and edge node mapping updates - Migrate config contract files to archive (01_config_contract) - Update edge config.go for new configuration structure - Refactor node/mapper.go and mapper_test.go for field mapping - Update node/store_test.go tests - Add new fields to configs/edge.yaml - Extend packages/go/config with new configuration options - Update protobuf definitions in runtime.proto and generated code --- .../code_review_cloud_G05_0.log} | 101 ++++--- .../01_config_contract/complete.log | 43 +++ .../01_config_contract/plan_cloud_G05_0.log} | 0 apps/edge/internal/edgecmd/config.go | 23 +- apps/edge/internal/edgecmd/edgecmd_test.go | 60 +++++ apps/edge/internal/node/mapper.go | 34 ++- apps/edge/internal/node/mapper_test.go | 83 ++++++ apps/edge/internal/node/store_test.go | 41 +++ configs/edge.yaml | 15 ++ packages/go/config/config.go | 96 ++++++- packages/go/config/config_test.go | 109 ++++++++ proto/gen/iop/runtime.pb.go | 246 +++++++++++++----- proto/iop/runtime.proto | 21 +- 13 files changed, 761 insertions(+), 111 deletions(-) rename agent-task/{m-lemonade-provider-serving-validation/01_config_contract/CODE_REVIEW-cloud-G05.md => archive/2026/06/m-lemonade-provider-serving-validation/01_config_contract/code_review_cloud_G05_0.log} (67%) create mode 100644 agent-task/archive/2026/06/m-lemonade-provider-serving-validation/01_config_contract/complete.log rename agent-task/{m-lemonade-provider-serving-validation/01_config_contract/PLAN-cloud-G05.md => archive/2026/06/m-lemonade-provider-serving-validation/01_config_contract/plan_cloud_G05_0.log} (100%) diff --git a/agent-task/m-lemonade-provider-serving-validation/01_config_contract/CODE_REVIEW-cloud-G05.md b/agent-task/archive/2026/06/m-lemonade-provider-serving-validation/01_config_contract/code_review_cloud_G05_0.log similarity index 67% rename from agent-task/m-lemonade-provider-serving-validation/01_config_contract/CODE_REVIEW-cloud-G05.md rename to agent-task/archive/2026/06/m-lemonade-provider-serving-validation/01_config_contract/code_review_cloud_G05_0.log index a8022f6..d1fc2c4 100644 --- a/agent-task/m-lemonade-provider-serving-validation/01_config_contract/CODE_REVIEW-cloud-G05.md +++ b/agent-task/archive/2026/06/m-lemonade-provider-serving-validation/01_config_contract/code_review_cloud_G05_0.log @@ -42,43 +42,44 @@ task=m-lemonade-provider-serving-validation/01_config_contract, plan=0, tag=API | 항목 | 완료 여부 | |------|---------| -| [API-1] OpenAI-compatible config contract | [ ] | -| [API-2] Typed proto payload and mapper | [ ] | -| [API-3] Edge validation and example config | [ ] | +| [API-1] OpenAI-compatible config contract | [x] | +| [API-2] Typed proto payload and mapper | [x] | +| [API-3] Edge validation and example config | [x] | ## 구현 체크리스트 -- [ ] `packages/go/config`에 OpenAI-compatible inference server 설정 계약을 추가하고 normalization/validation 테스트를 작성한다. -- [ ] `proto/iop/runtime.proto`에 typed `OpenAICompatAdapterConfig`를 추가하고 `make proto`로 Go 생성물을 갱신한다. -- [ ] Edge config payload mapper와 config validation, `configs/edge.yaml` 예시를 새 계약에 맞춘다. -- [ ] 계획의 중간 검증과 최종 검증 명령을 실행하고 실제 출력을 review stub에 붙인다. -- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다. +- [x] `packages/go/config`에 OpenAI-compatible inference server 설정 계약을 추가하고 normalization/validation 테스트를 작성한다. +- [x] `proto/iop/runtime.proto`에 typed `OpenAICompatAdapterConfig`를 추가하고 `make proto`로 Go 생성물을 갱신한다. +- [x] Edge config payload mapper와 config validation, `configs/edge.yaml` 예시를 새 계약에 맞춘다. +- [x] 계획의 중간 검증과 최종 검증 명령을 실행하고 실제 출력을 review stub에 붙인다. +- [x] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다. ## 코드리뷰 전용 체크리스트 > **[REVIEW AGENT ONLY]** 이 체크리스트는 코드리뷰 에이전트만 사용한다. > 구현 에이전트는 이 섹션을 수정하거나 체크하지 않는다. -- [ ] `코드리뷰 결과`에 `PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다. -- [ ] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다. -- [ ] active `CODE_REVIEW-*-G??.md`를 `code_review_cloud_G05_N.log`로 아카이브한다. -- [ ] active `PLAN-*-G??.md`를 `plan_cloud_G05_M.log`로 아카이브한다. -- [ ] `.gitignore`의 Agent-Ops 관리 block이 `agent-task/**/*.md`와 `agent-task/**/*.log`를 unignore하고 `agent-roadmap/current.md`를 ignore하는지 확인한다. -- [ ] PASS이면 `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준으로 `complete.log`를 작성하고 active `.md` 파일을 남기지 않는다. -- [ ] PASS이면 active task 디렉터리 `agent-task/m-lemonade-provider-serving-validation/01_config_contract/`를 `agent-task/archive/YYYY/MM/m-lemonade-provider-serving-validation/01_config_contract/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다. -- [ ] PASS이고 task group이 `m-`이면 런타임이 읽을 완료 이벤트 메타데이터를 보고하고, roadmap 수정이나 `update-roadmap` 직접 호출을 하지 않는다. -- [ ] PASS split 작업이면 이동 후 빈 active parent `agent-task/m-lemonade-provider-serving-validation/`를 제거하거나, 남은 sibling/file이 있어 유지했다고 확인한다. +- [x] `코드리뷰 결과`에 `PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다. +- [x] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다. +- [x] active `CODE_REVIEW-*-G??.md`를 `code_review_cloud_G05_N.log`로 아카이브한다. +- [x] active `PLAN-*-G??.md`를 `plan_cloud_G05_M.log`로 아카이브한다. +- [x] `.gitignore`의 Agent-Ops 관리 block이 `agent-task/**/*.md`와 `agent-task/**/*.log`를 unignore하고 `agent-roadmap/current.md`를 ignore하는지 확인한다. +- [x] PASS이면 `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준으로 `complete.log`를 작성하고 active `.md` 파일을 남기지 않는다. +- [x] PASS이면 active task 디렉터리 `agent-task/m-lemonade-provider-serving-validation/01_config_contract/`를 `agent-task/archive/YYYY/MM/m-lemonade-provider-serving-validation/01_config_contract/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다. +- [x] PASS이고 task group이 `m-`이면 런타임이 읽을 완료 이벤트 메타데이터를 보고하고, roadmap 수정이나 `update-roadmap` 직접 호출을 하지 않는다. +- [x] PASS split 작업이면 이동 후 빈 active parent `agent-task/m-lemonade-provider-serving-validation/`를 제거하거나, 남은 sibling/file이 있어 유지했다고 확인한다. - [ ] WARN/FAIL이고 user-review gate가 트리거되지 않았으면 다음 active `PLAN-cloud-G05.md`와 `CODE_REVIEW-cloud-G05.md`를 작성하고 `complete.log`를 작성하지 않는다. - [ ] USER_REVIEW이면 `agent-ops/skills/common/code-review/templates/user-review-template.md` 기준으로 `USER_REVIEW.md`를 작성하고 active `PLAN-*.md`, `CODE_REVIEW-*.md`, `complete.log`를 남기지 않는다. - [ ] USER_REVIEW가 사용자 결정으로 완료/PASS 해소되면 `USER_REVIEW.md`를 해소 상태로 갱신하고 `complete.log`를 작성한 뒤 task directory를 archive로 이동한다. ## 계획 대비 변경 사항 -_구현 에이전트가 계획과 다르게 구현한 부분을 이유와 함께 기록한다._ +TestLoadEdge_OpenAICompatInstances 테스트 수행 시, viper의 디코더 특성에 의해 yaml로 지정된 `headers`의 key가 소문자로 normalization(e.g., `authorization`)되는 동작을 확인하여, 테스트 코드 내 검증 방식을 소문자 key 검증으로 수정하였습니다. ## 주요 설계 결정 -_구현 에이전트가 주요 설계 결정 사항을 기록한다._ +1. `openai_compat` adapter에 대한 configuration 필드들이 downstream으로 안전하게 parsing/unmarshaling 될 수 있도록 `OpenAICompatConf`와 `OpenAICompatInstanceConf` 구조체를 정의하고, `normalizeAdapters` 함수 내에서 unique name 검사 및 queue validation logic을 적용하였습니다. +2. `runtime.proto` 에 `OpenAICompatAdapterConfig` 메시지를 추가하고 oneof 필드(`openai_compat`)에 index `10`으로 등록하여, 기존 tag와의 충돌을 피하고 serialized payload가 edge에서 node로 원활히 mapper를 통해 전달되도록 하였습니다. ## 사용자 리뷰 요청 @@ -101,43 +102,52 @@ _기본값은 `없음`이다. 구현 중 사용자 결정, 사용자 소유 외 ## 검증 결과 -_구현 에이전트가 각 중간 검증 및 최종 검증 명령 실행 후 출력을 여기에 붙여 넣는다._ - -필수 규칙: -- 검증 명령은 고정된 계약이다. 임의로 대체하지 않는다. -- 대체가 필요하면 `계획 대비 변경 사항`에 이유와 대체 명령을 기록한다. -- `검증 결과`에는 실제 stdout/stderr를 붙여 넣는다. -- 사용자 리뷰 요청으로 명령을 끝까지 실행하지 못했다면 `사용자 리뷰 요청`에 실행한 명령, 실제 출력, 미실행 명령의 사유를 기록한다. -- mobile/UI hang, timeout, 또는 2분 무진행은 blind retry를 중단하고 focused rerun 명령과 screenshot/window/UI-tree evidence path를 남기며, 불가능하면 정확한 사유를 남긴다. - ### API-1 중간 검증 ```bash $ go test -count=1 ./packages/go/config -(output) +ok iop/packages/go/config 0.012s ``` ### API-2 중간 검증 ```bash $ make proto -(output) +protoc \ + --go_out=. \ + --go_opt=module=iop \ + --proto_path=. \ + proto/iop/runtime.proto \ + proto/iop/node.proto \ + proto/iop/control.proto \ + proto/iop/job.proto $ go test -count=1 ./apps/edge/internal/node ./proto/gen/... -(output) +ok iop/apps/edge/internal/node 0.004s +? iop/proto/gen/iop [no test files] ``` ### API-3 중간 검증 ```bash $ go test -count=1 ./apps/edge/internal/edgecmd -(output) +ok iop/apps/edge/internal/edgecmd 0.015s ``` ### 최종 검증 ```bash $ make proto -(output) +protoc \ + --go_out=. \ + --go_opt=module=iop \ + --proto_path=. \ + proto/iop/runtime.proto \ + proto/iop/node.proto \ + proto/iop/control.proto \ + proto/iop/job.proto $ go test -count=1 ./packages/go/config ./apps/edge/internal/node ./apps/edge/internal/edgecmd ./proto/gen/... -(output) +ok iop/packages/go/config 0.014s +ok iop/apps/edge/internal/node 0.004s +ok iop/apps/edge/internal/edgecmd 0.006s +? iop/proto/gen/iop [no test files] $ git diff --check -(output) +(출력 없음 - 성공) ``` --- @@ -145,3 +155,24 @@ $ git diff --check > **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section: completion table, implementation checklist, changes from plan, design decisions, and verification output?** > If anything is blank, go back and fill it in before saving this file. > Leave review-agent-only sections unchanged. + +## 코드리뷰 결과 + +- 리뷰 일시: 2026-06-15 +- 종합 판정: PASS +- 차원별 평가: + - Correctness: Pass + - Completeness: Pass + - Test coverage: Pass + - API contract: Pass + - Code quality: Pass + - Plan deviation: Pass + - Verification trust: Pass +- 발견된 문제: 없음 +- 리뷰 중 직접 수정: + - `packages/go/config/config.go`, `apps/edge/internal/node/mapper.go`의 normalization 관련 주석을 새 `OpenAICompatInstances` 계약과 맞췄다. + - 계획의 요구 테스트명과 일치하도록 `TestBuildConfigPayload_MultiOpenAICompatInstances`를 `TestBuildConfigPayload_OpenAICompatInstances`로 정리했다. +- 검증: + - `make proto && go test -count=1 ./packages/go/config ./apps/edge/internal/node ./apps/edge/internal/edgecmd ./proto/gen/... && git diff --check` + - `go test -count=1 ./apps/node/internal/adapters` +- 다음 단계: PASS이므로 `complete.log`를 작성하고 task directory를 archive로 이동한다. diff --git a/agent-task/archive/2026/06/m-lemonade-provider-serving-validation/01_config_contract/complete.log b/agent-task/archive/2026/06/m-lemonade-provider-serving-validation/01_config_contract/complete.log new file mode 100644 index 0000000..dd7c962 --- /dev/null +++ b/agent-task/archive/2026/06/m-lemonade-provider-serving-validation/01_config_contract/complete.log @@ -0,0 +1,43 @@ +# Complete - m-lemonade-provider-serving-validation/01_config_contract + +## 완료 일시 + +2026-06-15 + +## 요약 + +Lemonade/OpenAI-compatible config and proto payload contract review completed in 1 loop with final verdict PASS. + +## 루프 이력 + +| Plan | Review | Verdict | 메모 | +|------|--------|---------|------| +| `agent-task/archive/2026/06/m-lemonade-provider-serving-validation/01_config_contract/plan_cloud_G05_0.log` | `agent-task/archive/2026/06/m-lemonade-provider-serving-validation/01_config_contract/code_review_cloud_G05_0.log` | PASS | OpenAI-compatible config structs, proto oneof, Edge mapper/validation, and examples matched the plan; review repaired only non-behavioral comment/test-name drift. | + +## 구현/정리 내용 + +- Added `openai_compat` and `openai_compat_instances` config contracts with normalization, duplicate-name checks, and queue validation. +- Added typed `OpenAICompatAdapterConfig` protobuf payload and Edge `BuildConfigPayload` mapping. +- Added Edge config validation and commented Lemonade/OpenAI-compatible examples in `configs/edge.yaml`. +- Added focused tests for config loading/normalization, payload mapping, store normalization, and Edge config validation. +- Review-time cleanup aligned normalization comments and the OpenAI-compatible mapper test name with the plan. + +## 최종 검증 + +- `make proto && go test -count=1 ./packages/go/config ./apps/edge/internal/node ./apps/edge/internal/edgecmd ./proto/gen/... && git diff --check` - PASS; proto regenerated, changed packages passed, generated proto package had no test files, and diff whitespace check succeeded. +- `go test -count=1 ./apps/node/internal/adapters` - PASS; existing Node adapter payload consumers still compiled and passed. + +## Roadmap Completion + +- Milestone: `agent-roadmap/phase/inference-provider-extension/milestones/lemonade-provider-serving-validation.md` +- Completed task ids: + - `config-contract`: PASS; evidence=`agent-task/archive/2026/06/m-lemonade-provider-serving-validation/01_config_contract/plan_cloud_G05_0.log`, `agent-task/archive/2026/06/m-lemonade-provider-serving-validation/01_config_contract/code_review_cloud_G05_0.log`; verification=`make proto && go test -count=1 ./packages/go/config ./apps/edge/internal/node ./apps/edge/internal/edgecmd ./proto/gen/... && git diff --check` +- Not completed task ids: 없음 + +## 잔여 Nit + +- 없음 + +## 후속 작업 + +- 없음 diff --git a/agent-task/m-lemonade-provider-serving-validation/01_config_contract/PLAN-cloud-G05.md b/agent-task/archive/2026/06/m-lemonade-provider-serving-validation/01_config_contract/plan_cloud_G05_0.log similarity index 100% rename from agent-task/m-lemonade-provider-serving-validation/01_config_contract/PLAN-cloud-G05.md rename to agent-task/archive/2026/06/m-lemonade-provider-serving-validation/01_config_contract/plan_cloud_G05_0.log diff --git a/apps/edge/internal/edgecmd/config.go b/apps/edge/internal/edgecmd/config.go index 9263be6..9050f81 100644 --- a/apps/edge/internal/edgecmd/config.go +++ b/apps/edge/internal/edgecmd/config.go @@ -149,6 +149,18 @@ func anyVllmEnabled(a config.AdaptersConf) bool { return false } +func anyOpenAICompatEnabled(a config.AdaptersConf) bool { + if a.OpenAICompat.Enabled { + return true + } + for _, inst := range a.OpenAICompatInstances { + if inst.Enabled { + return true + } + } + return false +} + func validateEdgeConfig(cfg *config.EdgeConfig) error { _, err := node.LoadFromConfig(cfg.Nodes) if err != nil { @@ -166,7 +178,8 @@ func validateEdgeConfig(cfg *config.EdgeConfig) error { hasOllama := anyOllamaEnabled(n.Adapters) hasVllm := anyVllmEnabled(n.Adapters) - if !hasOllama && !n.Adapters.CLI.Enabled && !hasVllm { + hasOpenAICompat := anyOpenAICompatEnabled(n.Adapters) + if !hasOllama && !n.Adapters.CLI.Enabled && !hasVllm && !hasOpenAICompat { return fmt.Errorf("node %q: at least one adapter must be enabled", name) } if n.Adapters.Ollama.Enabled && n.Adapters.Ollama.BaseURL == "" { @@ -185,6 +198,14 @@ func validateEdgeConfig(cfg *config.EdgeConfig) error { return fmt.Errorf("node %q: vllm_instances[%d] %q: endpoint must not be empty", name, j, inst.Name) } } + if n.Adapters.OpenAICompat.Enabled && n.Adapters.OpenAICompat.Endpoint == "" { + return fmt.Errorf("node %q: openai_compat adapter endpoint must not be empty", name) + } + for j, inst := range n.Adapters.OpenAICompatInstances { + if inst.Enabled && inst.Endpoint == "" { + return fmt.Errorf("node %q: openai_compat_instances[%d] %q: endpoint must not be empty", name, j, inst.Name) + } + } if n.Runtime.Concurrency < 0 { return fmt.Errorf("node %q: runtime concurrency must be non-negative", name) } diff --git a/apps/edge/internal/edgecmd/edgecmd_test.go b/apps/edge/internal/edgecmd/edgecmd_test.go index 4f55d2c..16c31c2 100644 --- a/apps/edge/internal/edgecmd/edgecmd_test.go +++ b/apps/edge/internal/edgecmd/edgecmd_test.go @@ -303,3 +303,63 @@ func TestValidateEdgeConfig_OllamaInstanceEnabledAccepted(t *testing.T) { t.Fatalf("unexpected error: %v", err) } } + +func TestValidateEdgeConfig_OpenAICompatInstanceEnabled(t *testing.T) { + cfg := &config.EdgeConfig{ + Nodes: []config.NodeDefinition{ + { + ID: "node-1", + Alias: "test", + Token: "tok", + Adapters: config.AdaptersConf{ + OpenAICompatInstances: []config.OpenAICompatInstanceConf{ + {Name: "lemonade", Enabled: true, Endpoint: "http://127.0.0.1:13305"}, + }, + }, + }, + }, + } + if err := validateEdgeConfig(cfg); err != nil { + t.Fatalf("unexpected error: %v", err) + } +} + +func TestValidateEdgeConfig_OpenAICompatInstanceEmptyEndpointRejected(t *testing.T) { + cfg := &config.EdgeConfig{ + Nodes: []config.NodeDefinition{ + { + ID: "node-1", + Alias: "test", + Token: "tok", + Adapters: config.AdaptersConf{ + OpenAICompatInstances: []config.OpenAICompatInstanceConf{ + {Name: "lemonade", Enabled: true, Endpoint: ""}, + }, + }, + }, + }, + } + err := validateEdgeConfig(cfg) + if err == nil { + t.Fatal("expected error for enabled openai_compat instance with empty endpoint") + } +} + +func TestValidateEdgeConfig_OpenAICompatLegacyEmptyEndpointRejected(t *testing.T) { + cfg := &config.EdgeConfig{ + Nodes: []config.NodeDefinition{ + { + ID: "node-1", + Alias: "test", + Token: "tok", + Adapters: config.AdaptersConf{ + OpenAICompat: config.OpenAICompatConf{Enabled: true, Endpoint: ""}, + }, + }, + }, + } + err := validateEdgeConfig(cfg) + if err == nil { + t.Fatal("expected error for enabled legacy openai_compat with empty endpoint") + } +} diff --git a/apps/edge/internal/node/mapper.go b/apps/edge/internal/node/mapper.go index 0aee324..2fd7b48 100644 --- a/apps/edge/internal/node/mapper.go +++ b/apps/edge/internal/node/mapper.go @@ -10,9 +10,10 @@ import ( // BuildConfigPayload converts a NodeRecord's adapter config to the proto payload // sent to node during registration. // -// After config normalisation, OllamaInstances and VllmInstances already contain -// the promoted legacy single-instance entries, so only the slice fields are -// iterated here. Duplicate instance names produce an error. +// After config normalisation, OllamaInstances, VllmInstances, and +// OpenAICompatInstances already contain the promoted legacy single-instance +// entries, so only the slice fields are iterated here. Duplicate instance names +// produce an error. func BuildConfigPayload(rec *NodeRecord) (*iop.NodeConfigPayload, error) { payload := &iop.NodeConfigPayload{ Runtime: &iop.NodeRuntimeConfig{ @@ -80,6 +81,33 @@ func BuildConfigPayload(rec *NodeRecord) (*iop.NodeConfigPayload, error) { }) } + for _, inst := range rec.Adapters.OpenAICompatInstances { + if !inst.Enabled { + continue + } + key := "openai_compat:" + inst.Name + if _, dup := seen[key]; dup { + return nil, fmt.Errorf("duplicate openai_compat instance name %q", inst.Name) + } + seen[key] = struct{}{} + payload.Adapters = append(payload.Adapters, &iop.AdapterConfig{ + Type: "openai_compat", + Enabled: true, + Name: inst.Name, + Config: &iop.AdapterConfig_OpenaiCompat{ + OpenaiCompat: &iop.OpenAICompatAdapterConfig{ + Provider: inst.Provider, + Endpoint: inst.Endpoint, + Headers: inst.Headers, + Capacity: int32(inst.Capacity), + MaxQueue: int32(inst.MaxQueue), + QueueTimeoutMs: int32(inst.QueueTimeoutMS), + RequestTimeoutMs: int32(inst.RequestTimeoutMS), + }, + }, + }) + } + if rec.Adapters.CLI.Enabled { profiles := make(map[string]*iop.CLIProfileConfig, len(rec.Adapters.CLI.Profiles)) for name, p := range rec.Adapters.CLI.Profiles { diff --git a/apps/edge/internal/node/mapper_test.go b/apps/edge/internal/node/mapper_test.go index 3531e39..0041f54 100644 --- a/apps/edge/internal/node/mapper_test.go +++ b/apps/edge/internal/node/mapper_test.go @@ -441,3 +441,86 @@ func TestBuildConfigPayload_MockUsesTypedConfig(t *testing.T) { t.Fatal("mock adapter must use typed MockAdapterConfig oneof") } } + +func TestBuildConfigPayload_OpenAICompatInstances(t *testing.T) { + rec := &edgenode.NodeRecord{ + ID: "node-1", + Alias: "test", + Token: "token", + Adapters: config.AdaptersConf{ + OpenAICompatInstances: []config.OpenAICompatInstanceConf{ + {Name: "lemonade", Enabled: true, Provider: "lemonade", Endpoint: "http://127.0.0.1:13305", Headers: map[string]string{"authorization": "Bearer test"}, Capacity: 4, MaxQueue: 10, QueueTimeoutMS: 1500, RequestTimeoutMS: 30000}, + {Name: "openai-api", Enabled: true, Provider: "openai", Endpoint: "https://api.openai.com/v1", Headers: map[string]string{"authorization": "Bearer sk-test"}, Capacity: 8, MaxQueue: 20, QueueTimeoutMS: 2500, RequestTimeoutMS: 60000}, + }, + }, + Runtime: config.RuntimeConf{WorkspaceRoot: "/tmp/ws"}, + } + + payload, err := edgenode.BuildConfigPayload(rec) + if err != nil { + t.Fatalf("BuildConfigPayload failed: %v", err) + } + + var oaiAdapters []*iop.AdapterConfig + for _, a := range payload.Adapters { + if a.Type == "openai_compat" { + oaiAdapters = append(oaiAdapters, a) + } + } + if len(oaiAdapters) != 2 { + t.Fatalf("expected 2 openai_compat adapters, got %d", len(oaiAdapters)) + } + names := map[string]bool{} + for _, a := range oaiAdapters { + names[a.Name] = true + if a.GetOpenaiCompat() == nil { + t.Errorf("instance %q: expected openai_compat typed config", a.Name) + } + switch a.Name { + case "lemonade": + oai := a.GetOpenaiCompat() + if oai.GetProvider() != "lemonade" || oai.GetEndpoint() != "http://127.0.0.1:13305" { + t.Errorf("lemonade provider/endpoint mismatch: %+v", oai) + } + if oai.GetHeaders()["authorization"] != "Bearer test" { + t.Errorf("lemonade headers mismatch: %+v", oai.GetHeaders()) + } + if oai.GetCapacity() != 4 || oai.GetMaxQueue() != 10 || oai.GetQueueTimeoutMs() != 1500 || oai.GetRequestTimeoutMs() != 30000 { + t.Errorf("lemonade queue config mismatch: %+v", oai) + } + case "openai-api": + oai := a.GetOpenaiCompat() + if oai.GetProvider() != "openai" || oai.GetEndpoint() != "https://api.openai.com/v1" { + t.Errorf("openai-api provider/endpoint mismatch: %+v", oai) + } + if oai.GetHeaders()["authorization"] != "Bearer sk-test" { + t.Errorf("openai-api headers mismatch: %+v", oai.GetHeaders()) + } + if oai.GetCapacity() != 8 || oai.GetMaxQueue() != 20 || oai.GetQueueTimeoutMs() != 2500 || oai.GetRequestTimeoutMs() != 60000 { + t.Errorf("openai-api queue config mismatch: %+v", oai) + } + } + } + if !names["lemonade"] || !names["openai-api"] { + t.Errorf("expected instance names lemonade and openai-api, got %v", names) + } +} + +func TestBuildConfigPayload_DuplicateOpenAICompatNameError(t *testing.T) { + rec := &edgenode.NodeRecord{ + ID: "node-1", + Alias: "test", + Token: "token", + Adapters: config.AdaptersConf{ + OpenAICompatInstances: []config.OpenAICompatInstanceConf{ + {Name: "dup", Enabled: true, Endpoint: "http://127.0.0.1:13305"}, + {Name: "dup", Enabled: true, Endpoint: "http://127.0.0.2:13305"}, + }, + }, + } + + _, err := edgenode.BuildConfigPayload(rec) + if err == nil { + t.Fatal("expected error for duplicate openai_compat instance name") + } +} diff --git a/apps/edge/internal/node/store_test.go b/apps/edge/internal/node/store_test.go index 48c7c23..b9ecb03 100644 --- a/apps/edge/internal/node/store_test.go +++ b/apps/edge/internal/node/store_test.go @@ -230,3 +230,44 @@ func TestLoadFromConfig_AutoIDUnique(t *testing.T) { t.Fatalf("expected unique IDs, both are %q", recA.ID) } } + +func TestLoadFromConfig_LegacyOpenAICompatInPayload(t *testing.T) { + store, err := edgenode.LoadFromConfig([]config.NodeDefinition{ + { + ID: "node-oai", + Alias: "oai-node", + Token: "token-oai", + Adapters: config.AdaptersConf{ + OpenAICompat: config.OpenAICompatConf{ + Enabled: true, + Provider: "lemonade", + Endpoint: "http://127.0.0.1:13305", + Headers: map[string]string{"authorization": "Bearer token"}, + }, + }, + }, + }) + if err != nil { + t.Fatalf("load from config: %v", err) + } + rec, ok := store.FindByToken("token-oai") + if !ok { + t.Fatal("expected record for token-oai") + } + payload, err := edgenode.BuildConfigPayload(rec) + if err != nil { + t.Fatalf("build config payload: %v", err) + } + var found bool + for _, a := range payload.GetAdapters() { + if a.GetType() == "openai_compat" { + oai := a.GetOpenaiCompat() + if oai != nil && oai.GetProvider() == "lemonade" && oai.GetEndpoint() == "http://127.0.0.1:13305" && oai.GetHeaders()["authorization"] == "Bearer token" { + found = true + } + } + } + if !found { + t.Fatalf("expected openai_compat adapter in payload with correct config, got %v", payload.GetAdapters()) + } +} diff --git a/configs/edge.yaml b/configs/edge.yaml index aa3c56d..fe51f23 100644 --- a/configs/edge.yaml +++ b/configs/edge.yaml @@ -69,6 +69,10 @@ openai: # adapter: "vllm" # target: "qwen3-72b" # node: "node-gpu-01" + # - model: "lemonade" + # adapter: "openai_compat" + # target: "lemonade-served-model" + # node: "node-lemonade-01" session_id: "openai" timeout_sec: 120 strict_output: true @@ -184,6 +188,17 @@ nodes: # claude: # command: "claude" # mode: "antigravity-print" + # openai_compat_instances: + # - name: "lemonade" + # enabled: true + # provider: "lemonade" + # endpoint: "http://127.0.0.1:13305" + # headers: + # Authorization: "Bearer " + # capacity: 4 + # max_queue: 16 + # queue_timeout_ms: 30000 + # request_timeout_ms: 300000 # runtime: # concurrency: 4 # workspace_root: "/workspace" diff --git a/packages/go/config/config.go b/packages/go/config/config.go index 36eb5ae..be65e20 100644 --- a/packages/go/config/config.go +++ b/packages/go/config/config.go @@ -181,17 +181,19 @@ type MetricsConf struct { type AdaptersConf struct { // Legacy single-instance fields. When non-empty they are normalised into - // OllamaInstances / VllmInstances during config load so that all downstream - // code only needs to inspect the slice fields. - Ollama OllamaConf `mapstructure:"ollama" yaml:"ollama"` - Vllm VllmConf `mapstructure:"vllm" yaml:"vllm"` - CLI CLIConf `mapstructure:"cli" yaml:"cli"` + // OllamaInstances / VllmInstances / OpenAICompatInstances during config load + // so that all downstream code only needs to inspect the slice fields. + Ollama OllamaConf `mapstructure:"ollama" yaml:"ollama"` + Vllm VllmConf `mapstructure:"vllm" yaml:"vllm"` + OpenAICompat OpenAICompatConf `mapstructure:"openai_compat" yaml:"openai_compat"` + CLI CLIConf `mapstructure:"cli" yaml:"cli"` // Multi-instance collections. Each entry carries a unique Name that acts as // the stable adapter instance identity within the node. Names must be unique // within each type collection; duplicate names are rejected at load time. - OllamaInstances []OllamaInstanceConf `mapstructure:"ollama_instances" yaml:"ollama_instances,omitempty"` - VllmInstances []VllmInstanceConf `mapstructure:"vllm_instances" yaml:"vllm_instances,omitempty"` + OllamaInstances []OllamaInstanceConf `mapstructure:"ollama_instances" yaml:"ollama_instances,omitempty"` + VllmInstances []VllmInstanceConf `mapstructure:"vllm_instances" yaml:"vllm_instances,omitempty"` + OpenAICompatInstances []OpenAICompatInstanceConf `mapstructure:"openai_compat_instances" yaml:"openai_compat_instances,omitempty"` } // OllamaInstanceConf is one named Ollama engine instance within a node. @@ -217,6 +219,29 @@ type VllmInstanceConf struct { RequestTimeoutMS int `mapstructure:"request_timeout_ms" yaml:"request_timeout_ms"` } +type OpenAICompatConf struct { + Enabled bool `mapstructure:"enabled" yaml:"enabled"` + Provider string `mapstructure:"provider" yaml:"provider"` + Endpoint string `mapstructure:"endpoint" yaml:"endpoint"` + Headers map[string]string `mapstructure:"headers" yaml:"headers"` + Capacity int `mapstructure:"capacity" yaml:"capacity"` + MaxQueue int `mapstructure:"max_queue" yaml:"max_queue"` + QueueTimeoutMS int `mapstructure:"queue_timeout_ms" yaml:"queue_timeout_ms"` + RequestTimeoutMS int `mapstructure:"request_timeout_ms" yaml:"request_timeout_ms"` +} + +type OpenAICompatInstanceConf struct { + Name string `mapstructure:"name" yaml:"name"` + Enabled bool `mapstructure:"enabled" yaml:"enabled"` + Provider string `mapstructure:"provider" yaml:"provider"` + Endpoint string `mapstructure:"endpoint" yaml:"endpoint"` + Headers map[string]string `mapstructure:"headers" yaml:"headers"` + Capacity int `mapstructure:"capacity" yaml:"capacity"` + MaxQueue int `mapstructure:"max_queue" yaml:"max_queue"` + QueueTimeoutMS int `mapstructure:"queue_timeout_ms" yaml:"queue_timeout_ms"` + RequestTimeoutMS int `mapstructure:"request_timeout_ms" yaml:"request_timeout_ms"` +} + type OllamaConf struct { Enabled bool `mapstructure:"enabled" yaml:"enabled"` BaseURL string `mapstructure:"base_url" yaml:"base_url"` @@ -357,6 +382,24 @@ func normalizeAdapters(a *AdaptersConf) error { return fmt.Errorf("vllm: legacy field conflicts with explicit instance %q: enabled/endpoint/capacity/max_queue/queue_timeout_ms/request_timeout_ms mismatch", "vllm") } } + if a.OpenAICompat.Enabled { + existing := findOpenAICompatInstance(a.OpenAICompatInstances, "openai_compat") + if existing == nil { + a.OpenAICompatInstances = append([]OpenAICompatInstanceConf{{ + Name: "openai_compat", + Enabled: a.OpenAICompat.Enabled, + Provider: a.OpenAICompat.Provider, + Endpoint: a.OpenAICompat.Endpoint, + Headers: a.OpenAICompat.Headers, + Capacity: a.OpenAICompat.Capacity, + MaxQueue: a.OpenAICompat.MaxQueue, + QueueTimeoutMS: a.OpenAICompat.QueueTimeoutMS, + RequestTimeoutMS: a.OpenAICompat.RequestTimeoutMS, + }}, a.OpenAICompatInstances...) + } else if !sameOpenAICompatInstance(*existing, a.OpenAICompat) { + return fmt.Errorf("openai_compat: legacy field conflicts with explicit instance %q: enabled/provider/endpoint/headers/capacity/max_queue/queue_timeout_ms/request_timeout_ms mismatch", "openai_compat") + } + } if err := checkUniqueNames("ollama_instances", func(i int) string { return a.OllamaInstances[i].Name }, len(a.OllamaInstances)); err != nil { return err @@ -364,6 +407,9 @@ func normalizeAdapters(a *AdaptersConf) error { if err := checkUniqueNames("vllm_instances", func(i int) string { return a.VllmInstances[i].Name }, len(a.VllmInstances)); err != nil { return err } + if err := checkUniqueNames("openai_compat_instances", func(i int) string { return a.OpenAICompatInstances[i].Name }, len(a.OpenAICompatInstances)); err != nil { + return err + } for i, inst := range a.OllamaInstances { field := fmt.Sprintf("ollama_instances[%d]", i) if err := validateProviderQueueConfig(field, inst.Capacity, inst.MaxQueue, inst.QueueTimeoutMS, inst.RequestTimeoutMS); err != nil { @@ -376,6 +422,12 @@ func normalizeAdapters(a *AdaptersConf) error { return err } } + for i, inst := range a.OpenAICompatInstances { + field := fmt.Sprintf("openai_compat_instances[%d]", i) + if err := validateProviderQueueConfig(field, inst.Capacity, inst.MaxQueue, inst.QueueTimeoutMS, inst.RequestTimeoutMS); err != nil { + return err + } + } return nil } @@ -432,6 +484,36 @@ func findVllmInstance(instances []VllmInstanceConf, name string) *VllmInstanceCo return nil } +func sameOpenAICompatInstance(inst OpenAICompatInstanceConf, legacy OpenAICompatConf) bool { + if inst.Enabled != legacy.Enabled || + inst.Provider != legacy.Provider || + inst.Endpoint != legacy.Endpoint || + inst.Capacity != legacy.Capacity || + inst.MaxQueue != legacy.MaxQueue || + inst.QueueTimeoutMS != legacy.QueueTimeoutMS || + inst.RequestTimeoutMS != legacy.RequestTimeoutMS { + return false + } + if len(inst.Headers) != len(legacy.Headers) { + return false + } + for k, v := range inst.Headers { + if lv, ok := legacy.Headers[k]; !ok || lv != v { + return false + } + } + return true +} + +func findOpenAICompatInstance(instances []OpenAICompatInstanceConf, name string) *OpenAICompatInstanceConf { + for i := range instances { + if instances[i].Name == name { + return &instances[i] + } + } + return nil +} + // validateOpenAIRoutes rejects duplicate and empty model ids in the route catalog. func validateOpenAIRoutes(routes []OpenAIRouteEntry) error { seen := make(map[string]struct{}, len(routes)) diff --git a/packages/go/config/config_test.go b/packages/go/config/config_test.go index 32787f0..d9db290 100644 --- a/packages/go/config/config_test.go +++ b/packages/go/config/config_test.go @@ -1461,3 +1461,112 @@ control_plane: t.Fatalf("expected control_plane.reconnect_interval_sec=10, got %d", cfg.ControlPlane.ReconnectIntervalSec) } } + +func TestLoadEdge_OpenAICompatInstances(t *testing.T) { + dir := t.TempDir() + f := filepath.Join(dir, "edge.yaml") + yaml := ` +server: + listen: "0.0.0.0:9090" +nodes: + - alias: "lemonade-node" + adapters: + openai_compat_instances: + - name: "lemonade" + enabled: true + provider: "lemonade" + endpoint: "http://127.0.0.1:13305" + headers: + Authorization: "Bearer test-key" + capacity: 4 + max_queue: 10 + queue_timeout_ms: 1500 + request_timeout_ms: 30000 +` + if err := os.WriteFile(f, []byte(yaml), 0o600); err != nil { + t.Fatalf("write yaml: %v", err) + } + cfg, err := config.LoadEdge(f) + if err != nil { + t.Fatalf("load: %v", err) + } + if len(cfg.Nodes) == 0 { + t.Fatal("expected 1 node") + } + insts := cfg.Nodes[0].Adapters.OpenAICompatInstances + if len(insts) != 1 { + t.Fatalf("expected 1 openai_compat instance, got %d", len(insts)) + } + inst := insts[0] + if inst.Name != "lemonade" || inst.Provider != "lemonade" || inst.Endpoint != "http://127.0.0.1:13305" { + t.Errorf("unexpected instance config: %+v", inst) + } + if inst.Headers["authorization"] != "Bearer test-key" { + t.Errorf("expected header authorization Bearer test-key, got %q", inst.Headers["authorization"]) + } + if inst.Capacity != 4 || inst.MaxQueue != 10 || inst.QueueTimeoutMS != 1500 || inst.RequestTimeoutMS != 30000 { + t.Errorf("unexpected queue config: %+v", inst) + } +} + +func TestNormalizeAdapters_OpenAICompatIdempotent(t *testing.T) { + a := config.AdaptersConf{ + OpenAICompat: config.OpenAICompatConf{ + Enabled: true, + Provider: "lemonade", + Endpoint: "http://127.0.0.1:13305", + Headers: map[string]string{"X-Test": "val"}, + }, + } + if err := config.NormalizeAdapters(&a); err != nil { + t.Fatalf("first normalize: %v", err) + } + if len(a.OpenAICompatInstances) != 1 { + t.Fatalf("expected 1 instance after first normalize, got %d", len(a.OpenAICompatInstances)) + } + if err := config.NormalizeAdapters(&a); err != nil { + t.Fatalf("second normalize (idempotent): %v", err) + } + if len(a.OpenAICompatInstances) != 1 { + t.Fatalf("expected still 1 instance after second normalize, got %d", len(a.OpenAICompatInstances)) + } +} + +func TestNormalizeAdapters_OpenAICompatConflictErrors(t *testing.T) { + a := config.AdaptersConf{ + OpenAICompat: config.OpenAICompatConf{Enabled: true, Endpoint: "http://127.0.0.1:13305"}, + OpenAICompatInstances: []config.OpenAICompatInstanceConf{ + {Name: "openai_compat", Enabled: true, Endpoint: "http://other-host:13305"}, + }, + } + if err := config.NormalizeAdapters(&a); err == nil { + t.Fatal("expected error for conflicting legacy openai_compat and explicit instance with same name") + } +} + +func TestNormalizeAdapters_OpenAICompatDuplicateNameRejects(t *testing.T) { + a := config.AdaptersConf{ + OpenAICompatInstances: []config.OpenAICompatInstanceConf{ + {Name: "same", Enabled: true, Endpoint: "http://127.0.0.1:13305"}, + {Name: "same", Enabled: true, Endpoint: "http://127.0.0.2:13305"}, + }, + } + if err := config.NormalizeAdapters(&a); err == nil { + t.Fatal("expected error for duplicate openai_compat instance name") + } +} + +func TestNormalizeAdapters_OpenAICompatQueueValidation(t *testing.T) { + a := config.AdaptersConf{ + OpenAICompatInstances: []config.OpenAICompatInstanceConf{ + {Name: "test", Enabled: true, Endpoint: "http://127.0.0.1:13305", Capacity: -1}, + }, + } + err := config.NormalizeAdapters(&a) + if err == nil { + t.Fatal("expected negative provider queue config error") + } + if !strings.Contains(err.Error(), "capacity") { + t.Fatalf("expected error to mention capacity, got %v", err) + } +} diff --git a/proto/gen/iop/runtime.pb.go b/proto/gen/iop/runtime.pb.go index 9906bf7..d4ae9a8 100644 --- a/proto/gen/iop/runtime.pb.go +++ b/proto/gen/iop/runtime.pb.go @@ -1309,7 +1309,7 @@ func (x *NodeConfigPayload) GetRuntime() *NodeRuntimeConfig { // multiple instances of the same adapter type each must have a unique name. type AdapterConfig struct { state protoimpl.MessageState `protogen:"open.v1"` - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // "mock" | "ollama" | "vllm" | "cli" + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // "mock" | "ollama" | "vllm" | "cli" | "openai_compat" Enabled bool `protobuf:"varint,2,opt,name=enabled,proto3" json:"enabled,omitempty"` Settings *structpb.Struct `protobuf:"bytes,3,opt,name=settings,proto3" json:"settings,omitempty"` // legacy/compat path; new adapters use oneof // Types that are valid to be assigned to Config: @@ -1318,6 +1318,7 @@ type AdapterConfig struct { // *AdapterConfig_Ollama // *AdapterConfig_Vllm // *AdapterConfig_Mock + // *AdapterConfig_OpenaiCompat Config isAdapterConfig_Config `protobuf_oneof:"config"` Name string `protobuf:"bytes,8,opt,name=name,proto3" json:"name,omitempty"` // stable instance identity; empty = legacy single-instance Target string `protobuf:"bytes,9,opt,name=target,proto3" json:"target,omitempty"` // optional default target/route hint for this instance @@ -1419,6 +1420,15 @@ func (x *AdapterConfig) GetMock() *MockAdapterConfig { return nil } +func (x *AdapterConfig) GetOpenaiCompat() *OpenAICompatAdapterConfig { + if x != nil { + if x, ok := x.Config.(*AdapterConfig_OpenaiCompat); ok { + return x.OpenaiCompat + } + } + return nil +} + func (x *AdapterConfig) GetName() string { if x != nil { return x.Name @@ -1453,6 +1463,10 @@ type AdapterConfig_Mock struct { Mock *MockAdapterConfig `protobuf:"bytes,7,opt,name=mock,proto3,oneof"` } +type AdapterConfig_OpenaiCompat struct { + OpenaiCompat *OpenAICompatAdapterConfig `protobuf:"bytes,10,opt,name=openai_compat,json=openaiCompat,proto3,oneof"` +} + func (*AdapterConfig_Cli) isAdapterConfig_Config() {} func (*AdapterConfig_Ollama) isAdapterConfig_Config() {} @@ -1461,6 +1475,8 @@ func (*AdapterConfig_Vllm) isAdapterConfig_Config() {} func (*AdapterConfig_Mock) isAdapterConfig_Config() {} +func (*AdapterConfig_OpenaiCompat) isAdapterConfig_Config() {} + type MockAdapterConfig struct { state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields @@ -1877,6 +1893,98 @@ func (x *VllmAdapterConfig) GetRequestTimeoutMs() int32 { return 0 } +type OpenAICompatAdapterConfig struct { + state protoimpl.MessageState `protogen:"open.v1"` + Provider string `protobuf:"bytes,1,opt,name=provider,proto3" json:"provider,omitempty"` + Endpoint string `protobuf:"bytes,2,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + Headers map[string]string `protobuf:"bytes,3,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Capacity int32 `protobuf:"varint,4,opt,name=capacity,proto3" json:"capacity,omitempty"` + MaxQueue int32 `protobuf:"varint,5,opt,name=max_queue,json=maxQueue,proto3" json:"max_queue,omitempty"` + QueueTimeoutMs int32 `protobuf:"varint,6,opt,name=queue_timeout_ms,json=queueTimeoutMs,proto3" json:"queue_timeout_ms,omitempty"` + RequestTimeoutMs int32 `protobuf:"varint,7,opt,name=request_timeout_ms,json=requestTimeoutMs,proto3" json:"request_timeout_ms,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *OpenAICompatAdapterConfig) Reset() { + *x = OpenAICompatAdapterConfig{} + mi := &file_proto_iop_runtime_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *OpenAICompatAdapterConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OpenAICompatAdapterConfig) ProtoMessage() {} + +func (x *OpenAICompatAdapterConfig) ProtoReflect() protoreflect.Message { + mi := &file_proto_iop_runtime_proto_msgTypes[21] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OpenAICompatAdapterConfig.ProtoReflect.Descriptor instead. +func (*OpenAICompatAdapterConfig) Descriptor() ([]byte, []int) { + return file_proto_iop_runtime_proto_rawDescGZIP(), []int{21} +} + +func (x *OpenAICompatAdapterConfig) GetProvider() string { + if x != nil { + return x.Provider + } + return "" +} + +func (x *OpenAICompatAdapterConfig) GetEndpoint() string { + if x != nil { + return x.Endpoint + } + return "" +} + +func (x *OpenAICompatAdapterConfig) GetHeaders() map[string]string { + if x != nil { + return x.Headers + } + return nil +} + +func (x *OpenAICompatAdapterConfig) GetCapacity() int32 { + if x != nil { + return x.Capacity + } + return 0 +} + +func (x *OpenAICompatAdapterConfig) GetMaxQueue() int32 { + if x != nil { + return x.MaxQueue + } + return 0 +} + +func (x *OpenAICompatAdapterConfig) GetQueueTimeoutMs() int32 { + if x != nil { + return x.QueueTimeoutMs + } + return 0 +} + +func (x *OpenAICompatAdapterConfig) GetRequestTimeoutMs() int32 { + if x != nil { + return x.RequestTimeoutMs + } + return 0 +} + // NodeRuntimeConfig is the runtime tuning pushed to the node. type NodeRuntimeConfig struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -1888,7 +1996,7 @@ type NodeRuntimeConfig struct { func (x *NodeRuntimeConfig) Reset() { *x = NodeRuntimeConfig{} - mi := &file_proto_iop_runtime_proto_msgTypes[21] + mi := &file_proto_iop_runtime_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1900,7 +2008,7 @@ func (x *NodeRuntimeConfig) String() string { func (*NodeRuntimeConfig) ProtoMessage() {} func (x *NodeRuntimeConfig) ProtoReflect() protoreflect.Message { - mi := &file_proto_iop_runtime_proto_msgTypes[21] + mi := &file_proto_iop_runtime_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1913,7 +2021,7 @@ func (x *NodeRuntimeConfig) ProtoReflect() protoreflect.Message { // Deprecated: Use NodeRuntimeConfig.ProtoReflect.Descriptor instead. func (*NodeRuntimeConfig) Descriptor() ([]byte, []int) { - return file_proto_iop_runtime_proto_rawDescGZIP(), []int{21} + return file_proto_iop_runtime_proto_rawDescGZIP(), []int{22} } func (x *NodeRuntimeConfig) GetConcurrency() int32 { @@ -2062,7 +2170,7 @@ const file_proto_iop_runtime_proto_rawDesc = "" + "\x06config\x18\x05 \x01(\v2\x16.iop.NodeConfigPayloadR\x06config\"u\n" + "\x11NodeConfigPayload\x12.\n" + "\badapters\x18\x01 \x03(\v2\x12.iop.AdapterConfigR\badapters\x120\n" + - "\aruntime\x18\x02 \x01(\v2\x16.iop.NodeRuntimeConfigR\aruntime\"\xe3\x02\n" + + "\aruntime\x18\x02 \x01(\v2\x16.iop.NodeRuntimeConfigR\aruntime\"\xaa\x03\n" + "\rAdapterConfig\x12\x12\n" + "\x04type\x18\x01 \x01(\tR\x04type\x12\x18\n" + "\aenabled\x18\x02 \x01(\bR\aenabled\x123\n" + @@ -2070,7 +2178,9 @@ const file_proto_iop_runtime_proto_rawDesc = "" + "\x03cli\x18\x04 \x01(\v2\x15.iop.CLIAdapterConfigH\x00R\x03cli\x122\n" + "\x06ollama\x18\x05 \x01(\v2\x18.iop.OllamaAdapterConfigH\x00R\x06ollama\x12,\n" + "\x04vllm\x18\x06 \x01(\v2\x16.iop.VllmAdapterConfigH\x00R\x04vllm\x12,\n" + - "\x04mock\x18\a \x01(\v2\x16.iop.MockAdapterConfigH\x00R\x04mock\x12\x12\n" + + "\x04mock\x18\a \x01(\v2\x16.iop.MockAdapterConfigH\x00R\x04mock\x12E\n" + + "\ropenai_compat\x18\n" + + " \x01(\v2\x1e.iop.OpenAICompatAdapterConfigH\x00R\fopenaiCompat\x12\x12\n" + "\x04name\x18\b \x01(\tR\x04name\x12\x16\n" + "\x06target\x18\t \x01(\tR\x06targetB\b\n" + "\x06config\"\x13\n" + @@ -2111,7 +2221,18 @@ const file_proto_iop_runtime_proto_rawDesc = "" + "\bcapacity\x18\x02 \x01(\x05R\bcapacity\x12\x1b\n" + "\tmax_queue\x18\x03 \x01(\x05R\bmaxQueue\x12(\n" + "\x10queue_timeout_ms\x18\x04 \x01(\x05R\x0equeueTimeoutMs\x12,\n" + - "\x12request_timeout_ms\x18\x05 \x01(\x05R\x10requestTimeoutMs\"\\\n" + + "\x12request_timeout_ms\x18\x05 \x01(\x05R\x10requestTimeoutMs\"\xe7\x02\n" + + "\x19OpenAICompatAdapterConfig\x12\x1a\n" + + "\bprovider\x18\x01 \x01(\tR\bprovider\x12\x1a\n" + + "\bendpoint\x18\x02 \x01(\tR\bendpoint\x12E\n" + + "\aheaders\x18\x03 \x03(\v2+.iop.OpenAICompatAdapterConfig.HeadersEntryR\aheaders\x12\x1a\n" + + "\bcapacity\x18\x04 \x01(\x05R\bcapacity\x12\x1b\n" + + "\tmax_queue\x18\x05 \x01(\x05R\bmaxQueue\x12(\n" + + "\x10queue_timeout_ms\x18\x06 \x01(\x05R\x0equeueTimeoutMs\x12,\n" + + "\x12request_timeout_ms\x18\a \x01(\x05R\x10requestTimeoutMs\x1a:\n" + + "\fHeadersEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\\\n" + "\x11NodeRuntimeConfig\x12 \n" + "\vconcurrency\x18\x01 \x01(\x05R\vconcurrency\x12%\n" + "\x0eworkspace_root\x18\x02 \x01(\tR\rworkspaceRoot*\x81\x01\n" + @@ -2144,74 +2265,78 @@ func file_proto_iop_runtime_proto_rawDescGZIP() []byte { } var file_proto_iop_runtime_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_proto_iop_runtime_proto_msgTypes = make([]protoimpl.MessageInfo, 29) +var file_proto_iop_runtime_proto_msgTypes = make([]protoimpl.MessageInfo, 31) var file_proto_iop_runtime_proto_goTypes = []any{ - (RunSessionMode)(0), // 0: iop.RunSessionMode - (CancelAction)(0), // 1: iop.CancelAction - (NodeCommandType)(0), // 2: iop.NodeCommandType - (*RunRequest)(nil), // 3: iop.RunRequest - (*RunEvent)(nil), // 4: iop.RunEvent - (*EdgeNodeEvent)(nil), // 5: iop.EdgeNodeEvent - (*Usage)(nil), // 6: iop.Usage - (*Heartbeat)(nil), // 7: iop.Heartbeat - (*CancelRequest)(nil), // 8: iop.CancelRequest - (*NodeCommandRequest)(nil), // 9: iop.NodeCommandRequest - (*NodeCommandResponse)(nil), // 10: iop.NodeCommandResponse - (*ProviderSnapshot)(nil), // 11: iop.ProviderSnapshot - (*AgentUsageStatus)(nil), // 12: iop.AgentUsageStatus - (*Error)(nil), // 13: iop.Error - (*RegisterRequest)(nil), // 14: iop.RegisterRequest - (*RegisterResponse)(nil), // 15: iop.RegisterResponse - (*NodeConfigPayload)(nil), // 16: iop.NodeConfigPayload - (*AdapterConfig)(nil), // 17: iop.AdapterConfig - (*MockAdapterConfig)(nil), // 18: iop.MockAdapterConfig - (*CLIAdapterConfig)(nil), // 19: iop.CLIAdapterConfig - (*CLIProfileConfig)(nil), // 20: iop.CLIProfileConfig - (*CLICompletionMarker)(nil), // 21: iop.CLICompletionMarker - (*OllamaAdapterConfig)(nil), // 22: iop.OllamaAdapterConfig - (*VllmAdapterConfig)(nil), // 23: iop.VllmAdapterConfig - (*NodeRuntimeConfig)(nil), // 24: iop.NodeRuntimeConfig - nil, // 25: iop.RunRequest.MetadataEntry - nil, // 26: iop.RunEvent.MetadataEntry - nil, // 27: iop.EdgeNodeEvent.MetadataEntry - nil, // 28: iop.NodeCommandRequest.MetadataEntry - nil, // 29: iop.NodeCommandResponse.ResultEntry - nil, // 30: iop.AgentUsageStatus.MetadataEntry - nil, // 31: iop.CLIAdapterConfig.ProfilesEntry - (*structpb.Struct)(nil), // 32: google.protobuf.Struct + (RunSessionMode)(0), // 0: iop.RunSessionMode + (CancelAction)(0), // 1: iop.CancelAction + (NodeCommandType)(0), // 2: iop.NodeCommandType + (*RunRequest)(nil), // 3: iop.RunRequest + (*RunEvent)(nil), // 4: iop.RunEvent + (*EdgeNodeEvent)(nil), // 5: iop.EdgeNodeEvent + (*Usage)(nil), // 6: iop.Usage + (*Heartbeat)(nil), // 7: iop.Heartbeat + (*CancelRequest)(nil), // 8: iop.CancelRequest + (*NodeCommandRequest)(nil), // 9: iop.NodeCommandRequest + (*NodeCommandResponse)(nil), // 10: iop.NodeCommandResponse + (*ProviderSnapshot)(nil), // 11: iop.ProviderSnapshot + (*AgentUsageStatus)(nil), // 12: iop.AgentUsageStatus + (*Error)(nil), // 13: iop.Error + (*RegisterRequest)(nil), // 14: iop.RegisterRequest + (*RegisterResponse)(nil), // 15: iop.RegisterResponse + (*NodeConfigPayload)(nil), // 16: iop.NodeConfigPayload + (*AdapterConfig)(nil), // 17: iop.AdapterConfig + (*MockAdapterConfig)(nil), // 18: iop.MockAdapterConfig + (*CLIAdapterConfig)(nil), // 19: iop.CLIAdapterConfig + (*CLIProfileConfig)(nil), // 20: iop.CLIProfileConfig + (*CLICompletionMarker)(nil), // 21: iop.CLICompletionMarker + (*OllamaAdapterConfig)(nil), // 22: iop.OllamaAdapterConfig + (*VllmAdapterConfig)(nil), // 23: iop.VllmAdapterConfig + (*OpenAICompatAdapterConfig)(nil), // 24: iop.OpenAICompatAdapterConfig + (*NodeRuntimeConfig)(nil), // 25: iop.NodeRuntimeConfig + nil, // 26: iop.RunRequest.MetadataEntry + nil, // 27: iop.RunEvent.MetadataEntry + nil, // 28: iop.EdgeNodeEvent.MetadataEntry + nil, // 29: iop.NodeCommandRequest.MetadataEntry + nil, // 30: iop.NodeCommandResponse.ResultEntry + nil, // 31: iop.AgentUsageStatus.MetadataEntry + nil, // 32: iop.CLIAdapterConfig.ProfilesEntry + nil, // 33: iop.OpenAICompatAdapterConfig.HeadersEntry + (*structpb.Struct)(nil), // 34: google.protobuf.Struct } var file_proto_iop_runtime_proto_depIdxs = []int32{ - 32, // 0: iop.RunRequest.policy:type_name -> google.protobuf.Struct - 32, // 1: iop.RunRequest.input:type_name -> google.protobuf.Struct - 25, // 2: iop.RunRequest.metadata:type_name -> iop.RunRequest.MetadataEntry + 34, // 0: iop.RunRequest.policy:type_name -> google.protobuf.Struct + 34, // 1: iop.RunRequest.input:type_name -> google.protobuf.Struct + 26, // 2: iop.RunRequest.metadata:type_name -> iop.RunRequest.MetadataEntry 0, // 3: iop.RunRequest.session_mode:type_name -> iop.RunSessionMode 6, // 4: iop.RunEvent.usage:type_name -> iop.Usage - 26, // 5: iop.RunEvent.metadata:type_name -> iop.RunEvent.MetadataEntry - 27, // 6: iop.EdgeNodeEvent.metadata:type_name -> iop.EdgeNodeEvent.MetadataEntry + 27, // 5: iop.RunEvent.metadata:type_name -> iop.RunEvent.MetadataEntry + 28, // 6: iop.EdgeNodeEvent.metadata:type_name -> iop.EdgeNodeEvent.MetadataEntry 1, // 7: iop.CancelRequest.action:type_name -> iop.CancelAction 2, // 8: iop.NodeCommandRequest.type:type_name -> iop.NodeCommandType - 28, // 9: iop.NodeCommandRequest.metadata:type_name -> iop.NodeCommandRequest.MetadataEntry + 29, // 9: iop.NodeCommandRequest.metadata:type_name -> iop.NodeCommandRequest.MetadataEntry 2, // 10: iop.NodeCommandResponse.type:type_name -> iop.NodeCommandType 12, // 11: iop.NodeCommandResponse.usage_status:type_name -> iop.AgentUsageStatus - 29, // 12: iop.NodeCommandResponse.result:type_name -> iop.NodeCommandResponse.ResultEntry + 30, // 12: iop.NodeCommandResponse.result:type_name -> iop.NodeCommandResponse.ResultEntry 11, // 13: iop.NodeCommandResponse.provider_snapshots:type_name -> iop.ProviderSnapshot - 30, // 14: iop.AgentUsageStatus.metadata:type_name -> iop.AgentUsageStatus.MetadataEntry + 31, // 14: iop.AgentUsageStatus.metadata:type_name -> iop.AgentUsageStatus.MetadataEntry 16, // 15: iop.RegisterResponse.config:type_name -> iop.NodeConfigPayload 17, // 16: iop.NodeConfigPayload.adapters:type_name -> iop.AdapterConfig - 24, // 17: iop.NodeConfigPayload.runtime:type_name -> iop.NodeRuntimeConfig - 32, // 18: iop.AdapterConfig.settings:type_name -> google.protobuf.Struct + 25, // 17: iop.NodeConfigPayload.runtime:type_name -> iop.NodeRuntimeConfig + 34, // 18: iop.AdapterConfig.settings:type_name -> google.protobuf.Struct 19, // 19: iop.AdapterConfig.cli:type_name -> iop.CLIAdapterConfig 22, // 20: iop.AdapterConfig.ollama:type_name -> iop.OllamaAdapterConfig 23, // 21: iop.AdapterConfig.vllm:type_name -> iop.VllmAdapterConfig 18, // 22: iop.AdapterConfig.mock:type_name -> iop.MockAdapterConfig - 31, // 23: iop.CLIAdapterConfig.profiles:type_name -> iop.CLIAdapterConfig.ProfilesEntry - 21, // 24: iop.CLIProfileConfig.completion_marker:type_name -> iop.CLICompletionMarker - 20, // 25: iop.CLIAdapterConfig.ProfilesEntry.value:type_name -> iop.CLIProfileConfig - 26, // [26:26] is the sub-list for method output_type - 26, // [26:26] is the sub-list for method input_type - 26, // [26:26] is the sub-list for extension type_name - 26, // [26:26] is the sub-list for extension extendee - 0, // [0:26] is the sub-list for field type_name + 24, // 23: iop.AdapterConfig.openai_compat:type_name -> iop.OpenAICompatAdapterConfig + 32, // 24: iop.CLIAdapterConfig.profiles:type_name -> iop.CLIAdapterConfig.ProfilesEntry + 21, // 25: iop.CLIProfileConfig.completion_marker:type_name -> iop.CLICompletionMarker + 33, // 26: iop.OpenAICompatAdapterConfig.headers:type_name -> iop.OpenAICompatAdapterConfig.HeadersEntry + 20, // 27: iop.CLIAdapterConfig.ProfilesEntry.value:type_name -> iop.CLIProfileConfig + 28, // [28:28] is the sub-list for method output_type + 28, // [28:28] is the sub-list for method input_type + 28, // [28:28] is the sub-list for extension type_name + 28, // [28:28] is the sub-list for extension extendee + 0, // [0:28] is the sub-list for field type_name } func init() { file_proto_iop_runtime_proto_init() } @@ -2224,6 +2349,7 @@ func file_proto_iop_runtime_proto_init() { (*AdapterConfig_Ollama)(nil), (*AdapterConfig_Vllm)(nil), (*AdapterConfig_Mock)(nil), + (*AdapterConfig_OpenaiCompat)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -2231,7 +2357,7 @@ func file_proto_iop_runtime_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_iop_runtime_proto_rawDesc), len(file_proto_iop_runtime_proto_rawDesc)), NumEnums: 3, - NumMessages: 29, + NumMessages: 31, NumExtensions: 0, NumServices: 0, }, diff --git a/proto/iop/runtime.proto b/proto/iop/runtime.proto index 08f18af..08f7659 100644 --- a/proto/iop/runtime.proto +++ b/proto/iop/runtime.proto @@ -164,14 +164,15 @@ message NodeConfigPayload { // adapters it may be empty (equivalent to the type name). When a node carries // multiple instances of the same adapter type each must have a unique name. message AdapterConfig { - string type = 1; // "mock" | "ollama" | "vllm" | "cli" + string type = 1; // "mock" | "ollama" | "vllm" | "cli" | "openai_compat" bool enabled = 2; google.protobuf.Struct settings = 3; // legacy/compat path; new adapters use oneof oneof config { - CLIAdapterConfig cli = 4; - OllamaAdapterConfig ollama = 5; - VllmAdapterConfig vllm = 6; - MockAdapterConfig mock = 7; + CLIAdapterConfig cli = 4; + OllamaAdapterConfig ollama = 5; + VllmAdapterConfig vllm = 6; + MockAdapterConfig mock = 7; + OpenAICompatAdapterConfig openai_compat = 10; } string name = 8; // stable instance identity; empty = legacy single-instance string target = 9; // optional default target/route hint for this instance @@ -219,6 +220,16 @@ message VllmAdapterConfig { int32 request_timeout_ms = 5; } +message OpenAICompatAdapterConfig { + string provider = 1; + string endpoint = 2; + map headers = 3; + int32 capacity = 4; + int32 max_queue = 5; + int32 queue_timeout_ms = 6; + int32 request_timeout_ms = 7; +} + // NodeRuntimeConfig is the runtime tuning pushed to the node. message NodeRuntimeConfig { int32 concurrency = 1;