Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
feat(model-source): carry a BYOK endpoint's path, endpoint and protocol
LeoXing5168e9dacba8
diff --git a/apps/computer/local-daemon/internal/daemon/connection.go b/apps/computer/local-daemon/internal/daemon/connection.goindex e2ed7d74..f45ae66a 100644--- a/apps/computer/local-daemon/internal/daemon/connection.go+++ b/apps/computer/local-daemon/internal/daemon/connection.go@@ -335,6 +335,7 @@ func (d *Daemon) acceptRunnerWelcome(ctx, connectionCtx context.Context, streamd.prewarmOnce.Do(func() { go p.Prewarm(ctx) })}d.setGatewayState("connected")+ d.byokEndpoint.Store(slices.Contains(command.ServiceFeatures, serviceFeatureByokEndpoint))localModels := slices.Contains(command.ServiceFeatures, serviceFeatureLocalModels)if err := d.activateStreamAndReplay(ctx, stream, command.ReconcileOperationIDs, localModels); err != nil {return errdiff --git a/apps/computer/local-daemon/internal/daemon/daemon.go b/apps/computer/local-daemon/internal/daemon/daemon.goindex d22f5b7a..41c11eae 100644--- a/apps/computer/local-daemon/internal/daemon/daemon.go+++ b/apps/computer/local-daemon/internal/daemon/daemon.go@@ -115,13 +115,16 @@ type Daemon struct {connectionEpoch uint64// contentURL is the current connection's context_content_url, read by// dispatch workers that bring a Context to its View.- contentURL atomic.Pointer[string]- welcomeSeen bool- prewarmOnce sync.Once- welcomedAt time.Time- daemonID string- activeMu sync.Mutex- admissionMu sync.Mutex+ contentURL atomic.Pointer[string]+ // byokEndpoint holds whether the current Agent Service declared+ // serviceFeatureByokEndpoint in its welcome.+ byokEndpoint atomic.Bool+ welcomeSeen bool+ prewarmOnce sync.Once+ welcomedAt time.Time+ daemonID string+ activeMu sync.Mutex+ admissionMu sync.Mutex// authorityRevision counts, under admissionMu, the commands that can change// what an accepted Operation may start with: Registration snapshots, Agent// Runner commands and Context commands. A start whose revision is unchangeddiff --git a/apps/computer/local-daemon/internal/daemon/local_models.go b/apps/computer/local-daemon/internal/daemon/local_models.goindex fc9a206c..8ff13195 100644--- a/apps/computer/local-daemon/internal/daemon/local_models.go+++ b/apps/computer/local-daemon/internal/daemon/local_models.go@@ -18,6 +18,10 @@ import (// An Agent Service that predates them closes the connection on the frame.const serviceFeatureLocalModels = "local_models"+// serviceFeatureByokEndpoint in runner.welcome's service_features says the+// Agent Service accepts a BYOK summary's path and endpoint.+const serviceFeatureByokEndpoint = "byok_endpoint"+// LocalModelLibrary runs the actions a Computer owner chooses on this// Computer's localmodels library. The Daemon never picks a model itself.type LocalModelLibrary interface {diff --git a/apps/computer/local-daemon/internal/daemon/model_source.go b/apps/computer/local-daemon/internal/daemon/model_source.goindex af289e97..3128765c 100644--- a/apps/computer/local-daemon/internal/daemon/model_source.go+++ b/apps/computer/local-daemon/internal/daemon/model_source.go@@ -17,7 +17,7 @@ import (// model source (local models, native subscriptions, or BYOK on Bifrost).type ModelSourceManager interface {Status(ctx context.Context) (wire.ModelSourceStatus, error)- TestByok(ctx context.Context, runtime string, input wire.ByokConfigInput) (wire.ByokTestResult, error)+ TestByok(ctx context.Context, input wire.ByokConfigInput) (wire.ByokTestResult, error)ListByokModels(ctx context.Context, input wire.ByokConfigInput) (wire.ByokModelList, error)Apply(ctx context.Context, apply localmodels.ModelSourceApply) (wire.ModelSourceStatus, error)}@@ -95,10 +95,10 @@ func (d *Daemon) handleModelSourceCommand(ctx context.Context, stream transport.status = &res}case "test":- if request.Byok == nil || request.Runtime == "" {- return sendFailed("BYOK_INVALID_CONFIG", "A BYOK endpoint and its AI runtime are required.", false)+ if request.Byok == nil {+ return sendFailed("BYOK_INVALID_CONFIG", "A BYOK endpoint is required.", false)}- res, err := d.modelSource.TestByok(commandCtx, request.Runtime, *request.Byok)+ res, err := d.modelSource.TestByok(commandCtx, *request.Byok)if err != nil {actionErr = err} else {@@ -142,6 +142,10 @@ func (d *Daemon) handleModelSourceCommand(ctx context.Context, stream transport.return sendFailed(localmodels.CodeToolFailed, "Could not complete the model source action on this Computer.", true)}+ if status != nil && !d.byokEndpoint.Load() {+ // An Agent Service that predates BYOK paths rejects the unknown keys.+ status.Byok.Path, status.Byok.Endpoint = "", ""+ }frame := wire.CapabilityModelSourceSucceeded{ProtocolVersion: request.ProtocolVersion,CommandID: request.CommandID,diff --git a/apps/computer/local-daemon/internal/daemon/model_source_test.go b/apps/computer/local-daemon/internal/daemon/model_source_test.goindex 80bb3495..95333d69 100644--- a/apps/computer/local-daemon/internal/daemon/model_source_test.go+++ b/apps/computer/local-daemon/internal/daemon/model_source_test.go@@ -26,12 +26,12 @@ func (f *fakeModelSourceManager) Status(ctx context.Context) (wire.ModelSourceSt}, nil}-func (f *fakeModelSourceManager) TestByok(ctx context.Context, _ string, input wire.ByokConfigInput) (wire.ByokTestResult, error) {+func (f *fakeModelSourceManager) TestByok(ctx context.Context, input wire.ByokConfigInput) (wire.ByokTestResult, error) {f.deadline, _ = ctx.Deadline()return wire.ByokTestResult{Ok: true,Protocol: "openai-chat",- BaseURL: input.BaseURL,+ URL: input.BaseURL + input.Path + input.Endpoint,ModelID: input.ModelID,ContextWindow: 128000,}, nil@@ -39,7 +39,7 @@ func (f *fakeModelSourceManager) TestByok(ctx context.Context, _ string, input wfunc (f *fakeModelSourceManager) ListByokModels(ctx context.Context, input wire.ByokConfigInput) (wire.ByokModelList, error) {f.deadline, _ = ctx.Deadline()- return wire.ByokModelList{BaseURL: input.BaseURL, Models: []wire.ByokModelListModelsItem{{ID: "vendor/model"}}}, nil+ return wire.ByokModelList{URL: input.BaseURL + input.Path + "/models", Models: []wire.ByokModelListModelsItem{{ID: "vendor/model"}}}, nil}func (f *fakeModelSourceManager) Apply(ctx context.Context, apply localmodels.ModelSourceApply) (wire.ModelSourceStatus, error) {@@ -50,7 +50,10 @@ func (f *fakeModelSourceManager) Apply(ctx context.Context, apply localmodels.MoRuntime: apply.Runtime,RuntimeModel: "localmodels-byok",GatewayURL: "http://127.0.0.1:43120",- Byok: wire.ByokSummary{Configured: true, KeySaved: true, Protocol: "openai-chat", BaseURL: "https://api.example.com/v1", ModelID: "gpt-5.4"},+ Byok: wire.ByokSummary{+ Configured: true, KeySaved: true, Protocol: "openai-chat",+ BaseURL: "https://api.example.com", Path: "/api/paas/v4", Endpoint: "/chat/completions", ModelID: "gpt-5.4",+ },}, nil}@@ -105,9 +108,12 @@ func TestHandleModelSourceCommandValidatesOwnerExpiryAndActions(t *testing.T) {Mode: "byok",Runtime: "claude",Byok: &wire.ByokConfigInput{- BaseURL: "https://api.example.com/v1",- APIKey: "sk-secret",- ModelID: "gpt-5.4",+ BaseURL: "https://api.example.com",+ Path: "/api/paas/v4",+ Endpoint: "/chat/completions",+ Protocol: "openai-chat",+ APIKey: "sk-secret",+ ModelID: "gpt-5.4",},})if err := d.handleModelSourceCommand(t.Context(), stream, protocol.Command{@@ -125,6 +131,26 @@ func TestHandleModelSourceCommandValidatesOwnerExpiryAndActions(t *testing.T) {if succeeded.Status == nil || succeeded.Status.Mode != "byok" || succeeded.Status.RuntimeModel != "localmodels-byok" {t.Fatalf("unexpected apply status payload: %+v", succeeded.Status)}+ // An Agent Service that did not declare byok_endpoint rejects the+ // summary's path and endpoint, so they are left out until it does.+ if succeeded.Status.Byok.Path != "" || succeeded.Status.Byok.Endpoint != "" ||+ succeeded.Status.Byok.BaseURL != "https://api.example.com" {+ t.Fatalf("summary for an Agent Service without byok_endpoint = %+v", succeeded.Status.Byok)+ }+ d.byokEndpoint.Store(true)+ if err := d.handleModelSourceCommand(t.Context(), stream, protocol.Command{+ Type: protocol.CommandCapabilityModelSource, CommandID: "cmd-apply", RunnerID: "comp-1", ConnectionEpoch: 1, Payload: applyCmd,+ }); err != nil {+ t.Fatal(err)+ }+ succeeded = wire.CapabilityModelSourceSucceeded{}+ if err := json.Unmarshal(stream.events[len(stream.events)-1].Payload, &succeeded); err != nil {+ t.Fatal(err)+ }+ if succeeded.Status == nil || succeeded.Status.Byok.Path != "/api/paas/v4" || succeeded.Status.Byok.Endpoint != "/chat/completions" {+ t.Fatalf("summary for an Agent Service with byok_endpoint = %+v", succeeded.Status)+ }+ stream.events = stream.events[:2]// 3. Another actor is rejected with MODEL_SOURCE_FORBIDDEN.intruderCmd, _ := json.Marshal(wire.CapabilityModelSource{diff --git a/apps/computer/local-daemon/internal/linger/transport/runner_wire_contract_test.go b/apps/computer/local-daemon/internal/linger/transport/runner_wire_contract_test.goindex 37e38588..53f79c7b 100644--- a/apps/computer/local-daemon/internal/linger/transport/runner_wire_contract_test.go+++ b/apps/computer/local-daemon/internal/linger/transport/runner_wire_contract_test.go@@ -236,7 +236,7 @@ func runnerWireDaemonEvents(t *testing.T) []protocol.Event {capability(protocol.EventCapabilityComputerPermissionFailed, "computer_permission", "failed", map[string]any{"action": "relaunch", "error": failure})capability(protocol.EventCapabilityLocalModelsAccepted, "local_models", "accepted", map[string]any{"action": "download", "model_id": "qwen3-4b:Q4_K_M"})capability(protocol.EventCapabilityLocalModelsRefused, "local_models", "refused", map[string]any{"action": "refresh", "refusal": map[string]any{"code": "TOOL_NOT_INSTALLED"}})- capability(protocol.EventCapabilityModelSourceSucceeded, "model_source", "succeeded", map[string]any{"action": "test", "test_result": map[string]any{"ok": true, "protocol": "anthropic", "base_url": "https://api.example.com", "model_id": "vendor/model", "context_window": 200000}})+ capability(protocol.EventCapabilityModelSourceSucceeded, "model_source", "succeeded", map[string]any{"action": "test", "test_result": map[string]any{"ok": true, "protocol": "anthropic", "url": "https://api.example.com/v1/messages", "model_id": "vendor/model", "context_window": 200000}})capability(protocol.EventCapabilityModelSourceFailed, "model_source", "failed", map[string]any{"action": "apply", "error": failure})appendEvent(protocol.EventLocalModels, map[string]any{"type": "runner.local_models", "protocol_version": "2", "runner_id": "computer-1", "sent_at": "2026-10-28T00:00:00Z", "revision": 1, "local_models": map[string]any{"available": false, "reason": map[string]any{"code": "TOOL_NOT_INSTALLED"}, "observed_at": "2026-10-28T00:00:00Z", "pools": []any{}, "models": []any{}}})appendEvent(protocol.EventOperationPrepared, map[string]any{"prepare_command_id": "prepare-1", "prepared": true, "outcome": "ready", "duration_ms": 1})diff --git a/apps/computer/local-daemon/internal/localmodels/source.go b/apps/computer/local-daemon/internal/localmodels/source.goindex fe322b51..ab36e826 100644--- a/apps/computer/local-daemon/internal/localmodels/source.go+++ b/apps/computer/local-daemon/internal/localmodels/source.go@@ -278,8 +278,13 @@ func NewModelSource(options ModelSourceOptions) *ModelSource {}}+// byokStdinPayload sends path and endpoint even when empty: an empty one+// appends nothing, which localmodels tells apart from a missing field.type byokStdinPayload struct {BaseURL string `json:"baseUrl"`+ Path string `json:"path"`+ Endpoint string `json:"endpoint"`+ Protocol string `json:"protocol"`APIKey string `json:"apiKey,omitempty"`ModelID string `json:"modelId"`ContextWindow *uint64 `json:"contextWindow,omitempty"`@@ -292,6 +297,9 @@ func encodeByokStdin(input *wire.ByokConfigInput) ([]byte, error) {}return json.Marshal(byokStdinPayload{BaseURL: input.BaseURL,+ Path: input.Path,+ Endpoint: input.Endpoint,+ Protocol: input.Protocol,APIKey: input.APIKey,ModelID: input.ModelID,ContextWindow: input.ContextWindow,@@ -344,29 +352,22 @@ func (m *ModelSource) Status(ctx context.Context) (wire.ModelSourceStatus, errorreturn parseSourceStatus(stdout)}-// TestByok probes a BYOK upstream endpoint for runtime, finding the wire-// format and address it answers, without persisting credentials or mutating-// the active model source.-func (m *ModelSource) TestByok(ctx context.Context, runtime string, input wire.ByokConfigInput) (wire.ByokTestResult, error) {- if !slices.Contains([]string{"claude", "codex", "pi"}, runtime) {- return wire.ByokTestResult{}, &ModelSourceError{- Code: "MODEL_SOURCE_INVALID",- Message: "Unsupported AI runtime.",- }- }+// TestByok sends one request to the BYOK endpoint's address in its wire+// format, without persisting credentials or mutating the active model source.+func (m *ModelSource) TestByok(ctx context.Context, input wire.ByokConfigInput) (wire.ByokTestResult, error) {var doc struct {Protocol string `json:"protocol"`- BaseURL string `json:"base_url"`+ URL string `json:"url"`ModelID string `json:"model_id"`ContextWindow uint64 `json:"context_window"`}- if err := m.runEndpointCommand(ctx, input, modelSourceCheckSchema, &doc, "check", "--runtime", runtime); err != nil {+ if err := m.runEndpointCommand(ctx, input, modelSourceCheckSchema, &doc, "check"); err != nil {return wire.ByokTestResult{}, err}return wire.ByokTestResult{Ok: true,Protocol: doc.Protocol,- BaseURL: doc.BaseURL,+ URL: doc.URL,ModelID: doc.ModelID,ContextWindow: doc.ContextWindow,}, nildiff --git a/apps/computer/local-daemon/internal/localmodels/source_test.go b/apps/computer/local-daemon/internal/localmodels/source_test.goindex 66602529..a8463b3d 100644--- a/apps/computer/local-daemon/internal/localmodels/source_test.go+++ b/apps/computer/local-daemon/internal/localmodels/source_test.go@@ -129,29 +129,35 @@ func TestModelSourceStatusTestAndApplyKeepSecretsOnStdin(t *testing.T) {"schema": "localmodels.byok-check/v1","ok": true,"protocol": "openai-responses",- "base_url": "https://api.example.com/v1",+ "url": "https://api.example.com/v1/responses","model_id": "gpt-5.4","context_window": 200000}`), 0o600)- testRes, err := ms.TestByok(t.Context(), "codex", wire.ByokConfigInput{- BaseURL: "https://api.example.com/v1",- APIKey: "sk-never-in-argv",- ModelID: "gpt-5.4",+ testRes, err := ms.TestByok(t.Context(), wire.ByokConfigInput{+ BaseURL: "https://api.example.com",+ Path: "/v1",+ Endpoint: "/responses",+ Protocol: "openai-responses",+ APIKey: "sk-never-in-argv",+ ModelID: "gpt-5.4",})if err != nil {t.Fatalf("TestByok error: %v", err)}- if !testRes.Ok || testRes.ContextWindow != 200000 || testRes.ModelID != "gpt-5.4" {+ if !testRes.Ok || testRes.ContextWindow != 200000 || testRes.ModelID != "gpt-5.4" ||+ testRes.URL != "https://api.example.com/v1/responses" {t.Fatalf("unexpected TestByok result: %+v", testRes)}recordedArgs, _ := os.ReadFile(filepath.Join(ft.state, "source-args.txt"))- if strings.Contains(string(recordedArgs), "sk-never-in-argv") || !strings.Contains(string(recordedArgs), "--runtime codex") {- t.Fatalf("check argv = %s, want the Runtime and no API key", string(recordedArgs))+ if strings.Contains(string(recordedArgs), "sk-never-in-argv") || strings.Contains(string(recordedArgs), "--runtime") {+ t.Fatalf("check argv = %s, want neither a Runtime nor the API key", string(recordedArgs))}recordedStdin, _ := os.ReadFile(filepath.Join(ft.state, "source-stdin.json"))- if !strings.Contains(string(recordedStdin), `"apiKey":"sk-never-in-argv"`) {- t.Fatalf("expected API key on stdin JSON, got: %s", string(recordedStdin))+ for _, want := range []string{`"apiKey":"sk-never-in-argv"`, `"path":"/v1"`, `"endpoint":"/responses"`, `"protocol":"openai-responses"`} {+ if !strings.Contains(string(recordedStdin), want) {+ t.Fatalf("stdin JSON %s lacks %s", recordedStdin, want)+ }}_ = os.WriteFile(filepath.Join(ft.state, "source-apply.json"), []byte(`{@@ -165,7 +171,9 @@ func TestModelSourceStatusTestAndApplyKeepSecretsOnStdin(t *testing.T) {"byok": {"configured": true,"protocol": "openai-responses",- "base_url": "https://api.example.com/v1",+ "base_url": "https://api.example.com",+ "path": "/v1",+ "endpoint": "/responses","model_id": "gpt-5.4","context_window": 200000,"key_saved": true@@ -176,16 +184,20 @@ func TestModelSourceStatusTestAndApplyKeepSecretsOnStdin(t *testing.T) {Mode: "byok",Runtime: "codex",Byok: &wire.ByokConfigInput{- BaseURL: "https://api.example.com/v1",- APIKey: "sk-never-in-argv",- ModelID: "gpt-5.4",+ BaseURL: "https://api.example.com",+ Path: "/v1",+ Endpoint: "/responses",+ Protocol: "openai-responses",+ APIKey: "sk-never-in-argv",+ ModelID: "gpt-5.4",},})if err != nil {t.Fatalf("Apply error: %v", err)}if status.Mode != "byok" || status.Runtime != "codex" || status.RuntimeModel != "localmodels-byok" ||- status.ReasoningEffort != "high" || !status.Byok.KeySaved {+ status.ReasoningEffort != "high" || !status.Byok.KeySaved ||+ status.Byok.Path != "/v1" || status.Byok.Endpoint != "/responses" {t.Fatalf("unexpected Apply status: %+v", status)}if appliedCalls != 1 {@@ -200,9 +212,12 @@ func TestModelSourceStatusTestAndApplyKeepSecretsOnStdin(t *testing.T) {"message": "Upstream endpoint returned HTTP 401."}`), 0o600)_ = os.WriteFile(filepath.Join(ft.state, "source-check-exit"), []byte("2"), 0o600)- _, err = ms.TestByok(t.Context(), "pi", wire.ByokConfigInput{- BaseURL: "https://api.example.com/v1",- ModelID: "gpt-5.4",+ _, err = ms.TestByok(t.Context(), wire.ByokConfigInput{+ BaseURL: "https://api.example.com",+ Path: "/v1",+ Endpoint: "/chat/completions",+ Protocol: "openai-chat",+ ModelID: "gpt-5.4",})var sourceErr *ModelSourceErrorif !errors.As(err, &sourceErr) || sourceErr.Code != "BYOK_UPSTREAM_REJECTED" {@@ -212,11 +227,13 @@ func TestModelSourceStatusTestAndApplyKeepSecretsOnStdin(t *testing.T) {_ = os.WriteFile(filepath.Join(ft.state, "source-models.json"), []byte(`{"schema": "localmodels.byok-models/v1","ok": true,- "base_url": "https://api.example.com",+ "url": "https://gw.example.com/full/models","models": [{"id": "alpha", "name": null, "context_window": null}, {"id": "zeta", "name": "Zeta", "context_window": 200000}]}`), 0o600)- list, err := ms.ListByokModels(t.Context(), wire.ByokConfigInput{BaseURL: "https://api.example.com/v1", APIKey: "sk-list"})- if err != nil || list.BaseURL != "https://api.example.com" || len(list.Models) != 2 ||+ list, err := ms.ListByokModels(t.Context(), wire.ByokConfigInput{+ BaseURL: "https://gw.example.com/full", Protocol: "anthropic", APIKey: "sk-list",+ })+ if err != nil || list.URL != "https://gw.example.com/full/models" || len(list.Models) != 2 ||list.Models[1].Name != "Zeta" || list.Models[1].ContextWindow == nil || *list.Models[1].ContextWindow != 200000 {t.Fatalf("ListByokModels = %+v, %v", list, err)}@@ -224,6 +241,12 @@ func TestModelSourceStatusTestAndApplyKeepSecretsOnStdin(t *testing.T) {if !strings.HasPrefix(string(recordedArgs), "models --config-stdin") || strings.Contains(string(recordedArgs), "sk-list") {t.Fatalf("models argv = %s", recordedArgs)}+ // An empty path or endpoint appends nothing, which localmodels tells apart+ // from a missing field, so both are sent.+ recordedStdin, _ = os.ReadFile(filepath.Join(ft.state, "source-stdin.json"))+ if !strings.Contains(string(recordedStdin), `"path":""`) || !strings.Contains(string(recordedStdin), `"endpoint":""`) {+ t.Fatalf("models stdin JSON %s lacks the empty path and endpoint", recordedStdin)+ }}func writeModelSourceJSON(t *testing.T, stateDir string, payload map[string]any) {@@ -294,16 +317,14 @@ func TestModelSourceReportsUnsupportedWhenToolLacksSourceCommand(t *testing.T) {_, err = ms.Apply(t.Context(), ModelSourceApply{Mode: "subscription", Runtime: "claude"})assertUnsupported("Apply", err)- _, err = ms.TestByok(t.Context(), "claude", wire.ByokConfigInput{- BaseURL: "https://api.example.com/v1",- APIKey: "sk-unused",- ModelID: "gpt-5.4",+ _, err = ms.TestByok(t.Context(), wire.ByokConfigInput{+ BaseURL: "https://api.example.com", Path: "/v1", Endpoint: "/messages", Protocol: "anthropic",+ APIKey: "sk-unused", ModelID: "gpt-5.4",})assertUnsupported("TestByok", err)_, err = ms.ListByokModels(t.Context(), wire.ByokConfigInput{- BaseURL: "https://api.example.com/v1",- APIKey: "sk-unused",+ BaseURL: "https://api.example.com", Path: "/v1", Protocol: "openai-chat", APIKey: "sk-unused",})assertUnsupported("ListByokModels", err)}diff --git a/apps/computer/package.json b/apps/computer/package.jsonindex f50a43e8..dc7a1eae 100644--- a/apps/computer/package.json+++ b/apps/computer/package.json@@ -1,6 +1,6 @@{"name": "@linger/computer",- "version": "0.55.0",+ "version": "0.56.0","description": "Local Computer: resident Daemon, control CLI, and Runner Gateway transport.","private": true,"type": "module",diff --git a/apps/computer/tests/runner-wire-contract.test.ts b/apps/computer/tests/runner-wire-contract.test.tsindex f6df0aeb..199df76a 100644--- a/apps/computer/tests/runner-wire-contract.test.ts+++ b/apps/computer/tests/runner-wire-contract.test.ts@@ -159,8 +159,13 @@ const agentFrames = [kind: "model_source",...localCapability,action: "test",- runtime: "claude",- byok: { base_url: "https://api.example.com/v1", model_id: "vendor/model" },+ byok: {+ base_url: "https://open.bigmodel.cn",+ path: "/api/paas/v4",+ endpoint: "/chat/completions",+ protocol: "openai-chat",+ model_id: "vendor/model",+ },},{type: "prepare",diff --git a/apps/node-services/src/agent/executor/http/local-computer-http.ts b/apps/node-services/src/agent/executor/http/local-computer-http.tsindex 5831135e..1a027bdf 100644--- a/apps/node-services/src/agent/executor/http/local-computer-http.ts+++ b/apps/node-services/src/agent/executor/http/local-computer-http.ts@@ -282,16 +282,13 @@ export const createLocalComputerRouteHandlers = (options: {const management = requireModelSourceManagement(options.localComputerManagement,);- const { runtime, byok } = parseByokTestRequest(- await options.readJsonBody(context),- );+ const byok = parseByokTestRequest(await options.readJsonBody(context));try {const { testResult } = await management.modelSource({tenantId: options.pathId(context, "tenantId"),ownerActorId: options.pathId(context, "ownerActorId"),computerId: options.pathId(context, "computerId"),action: "test",- runtime,byok,signal: context.req.raw.signal,});@@ -352,24 +349,60 @@ const requireModelSourceManagement = (};const BYOK_MODEL_ID_PATTERN = /^[-a-zA-Z0-9_./:@]{1,256}$/u;+// Empty, or whole segments each led by one slash, so a path or endpoint can+// only extend the base URL's path.+const BYOK_URL_PATH_PATTERN = /^(?:\/[^/?#\s\\]+)*$/u;++const isByokUrlPath = (value: unknown): value is string =>+ typeof value === "string" &&+ value.length <= 256 &&+ BYOK_URL_PATH_PATTERN.test(value);++const isByokProtocol = (value: unknown): value is ByokConfigInput["protocol"] =>+ value === "openai-chat" ||+ value === "openai-responses" ||+ value === "anthropic";++interface ByokAddress {+ readonly base_url: string;+ readonly path: string;+ readonly endpoint: string;+ readonly protocol: ByokConfigInput["protocol"];+}++const byokAddress = (value: Record<string, unknown>): ByokAddress | null =>+ typeof value.base_url === "string" &&+ value.base_url.trim().length > 0 &&+ value.base_url.length <= 2048 &&+ isByokUrlPath(value.path) &&+ isByokUrlPath(value.endpoint) &&+ isByokProtocol(value.protocol)+ ? {+ base_url: value.base_url.trim(),+ path: value.path,+ endpoint: value.endpoint,+ protocol: value.protocol,+ }+ : null;++const BYOK_ADDRESS_KEYS = ["base_url", "path", "endpoint", "protocol"];// Never include the request body in the error; it carries the API key.const parseByokInput = (value: unknown): ByokConfigInput => {+ const address = isRecord(value) ? byokAddress(value) : null;if (!isRecord(value) ||+ !address ||Object.keys(value).some((key) =>![- "base_url",+ ...BYOK_ADDRESS_KEYS,"api_key","model_id","context_window","reuse_saved_key",].includes(key),) ||- typeof value.base_url !== "string" ||- value.base_url.trim().length === 0 ||- value.base_url.length > 2048 ||typeof value.model_id !== "string" ||!BYOK_MODEL_ID_PATTERN.test(value.model_id.trim()) ||(value.api_key !== undefined &&@@ -388,7 +421,7 @@ const parseByokInput = (value: unknown): ByokConfigInput => {);}return {- base_url: value.base_url.trim(),+ ...address,...(value.api_key !== undefined ? { api_key: value.api_key } : {}),model_id: value.model_id.trim(),...(value.context_window !== undefined@@ -402,14 +435,14 @@ const parseByokInput = (value: unknown): ByokConfigInput => {// Never include the request body in the error; it carries the API key.const parseByokEndpointInput = (value: unknown): ByokConfigInput => {+ const address = isRecord(value) ? byokAddress(value) : null;if (!isRecord(value) ||+ !address ||Object.keys(value).some(- (key) => !["base_url", "api_key", "reuse_saved_key"].includes(key),+ (key) =>+ ![...BYOK_ADDRESS_KEYS, "api_key", "reuse_saved_key"].includes(key),) ||- typeof value.base_url !== "string" ||- value.base_url.trim().length === 0 ||- value.base_url.length > 2048 ||(value.api_key !== undefined &&(typeof value.api_key !== "string" || value.api_key.length > 4096)) ||(value.reuse_saved_key !== undefined &&@@ -422,7 +455,7 @@ const parseByokEndpointInput = (value: unknown): ByokConfigInput => {);}return {- base_url: value.base_url.trim(),+ ...address,...(value.api_key !== undefined ? { api_key: value.api_key } : {}),...(value.reuse_saved_key !== undefined? { reuse_saved_key: value.reuse_saved_key }@@ -435,24 +468,15 @@ const isModelSourceRuntime = (): value is NonNullable<LocalModelSourceCommand["runtime"]> =>value === "claude" || value === "codex" || value === "pi";-const parseByokTestRequest = (- value: unknown,-): {- readonly runtime: NonNullable<LocalModelSourceCommand["runtime"]>;- readonly byok: ByokConfigInput;-} => {- if (- !isRecord(value) ||- Object.keys(value).some((key) => !["runtime", "byok"].includes(key)) ||- !isModelSourceRuntime(value.runtime)- ) {+const parseByokTestRequest = (value: unknown): ByokConfigInput => {+ if (!isRecord(value) || Object.keys(value).some((key) => key !== "byok")) {throw new LocalComputerHttpError(400,"BYOK_INVALID_CONFIG","BYOK configuration is invalid",);}- return { runtime: value.runtime, byok: parseByokInput(value.byok) };+ return parseByokInput(value.byok);};interface ModelSourceApplyBody {diff --git a/apps/node-services/src/agent/runner-gateway/local-computer-management.ts b/apps/node-services/src/agent/runner-gateway/local-computer-management.tsindex abe1df61..7ffc6c92 100644--- a/apps/node-services/src/agent/runner-gateway/local-computer-management.ts+++ b/apps/node-services/src/agent/runner-gateway/local-computer-management.ts@@ -44,6 +44,10 @@ export const FIRST_MODEL_INVOKE_CANCEL_COMPUTER_VERSION = "0.53.0";export const FIRST_MODEL_SOURCE_COMPUTER_VERSION = "0.54.0";// Older Daemons do not decode Pi as a model_invoke Runtime.export const FIRST_PI_MODEL_INVOKE_COMPUTER_VERSION = "0.55.0";+// The first release that decodes a BYOK path, endpoint and protocol and+// reports them back. An older Computer closes the connection on a byok input+// that carries them, so it gets no BYOK command and no `byok_endpoint`.+export const FIRST_BYOK_ENDPOINT_COMPUTER_VERSION = "0.56.0";const COMPUTER_RELEASE_VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;diff --git a/apps/node-services/src/agent/runner-gateway/runner-connections.ts b/apps/node-services/src/agent/runner-gateway/runner-connections.tsindex 5ae20287..05ec3249 100644--- a/apps/node-services/src/agent/runner-gateway/runner-connections.ts+++ b/apps/node-services/src/agent/runner-gateway/runner-connections.ts@@ -26,6 +26,7 @@ import {MINIMUM_CURRENT_COMPUTER_VERSION,FIRST_MODEL_INVOKE_CANCEL_COMPUTER_VERSION,FIRST_PI_MODEL_INVOKE_COMPUTER_VERSION,+ FIRST_BYOK_ENDPOINT_COMPUTER_VERSION,FIRST_SERVICE_FEATURES_COMPUTER_VERSION,type LocalPlacementRequirement,type LocalReasoningEffort,@@ -456,7 +457,14 @@ export class RunnerConnections {connection.hello.daemon_version,FIRST_SERVICE_FEATURES_COMPUTER_VERSION,)- ? { service_features: ["local_models"] }+ ? {+ service_features: isComputerVersionAtLeast(+ connection.hello.daemon_version,+ FIRST_BYOK_ENDPOINT_COMPUTER_VERSION,+ )+ ? ["local_models", "byok_endpoint"]+ : ["local_models"],+ }: {}),};}diff --git a/apps/node-services/src/agent/runner-gateway/runner-local-capabilities.ts b/apps/node-services/src/agent/runner-gateway/runner-local-capabilities.tsindex 1383caab..6728ca46 100644--- a/apps/node-services/src/agent/runner-gateway/runner-local-capabilities.ts+++ b/apps/node-services/src/agent/runner-gateway/runner-local-capabilities.ts@@ -16,6 +16,7 @@ import {parseAgentToDaemonEnvelope,} from "@linger/wire-contracts/runner-gateway/validator";import {+ FIRST_BYOK_ENDPOINT_COMPUTER_VERSION,FIRST_MODEL_SOURCE_COMPUTER_VERSION,isComputerVersionAtLeast,LocalBrowserConnectionError,@@ -334,6 +335,17 @@ export class RunnerLocalCapabilities {"Local Computer must be upgraded to switch model sources",);}+ if (+ command.byok &&+ !isComputerVersionAtLeast(+ connection.hello.daemon_version,+ FIRST_BYOK_ENDPOINT_COMPUTER_VERSION,+ )+ ) {+ throw new LocalComputerCapabilityError(+ "Local Computer must be upgraded to use a BYOK endpoint",+ );+ }const timeoutMs =command.action === "apply"? MODEL_SOURCE_APPLY_TIMEOUT_MSdiff --git a/apps/node-services/tests/agent/executor/http/local-computer-model-source-http.test.ts b/apps/node-services/tests/agent/executor/http/local-computer-model-source-http.test.tsindex 506ddaa9..c751d329 100644--- a/apps/node-services/tests/agent/executor/http/local-computer-model-source-http.test.ts+++ b/apps/node-services/tests/agent/executor/http/local-computer-model-source-http.test.ts@@ -25,6 +25,8 @@ const sampleStatus = {configured: true,protocol: "anthropic",base_url: "https://api.anthropic.com",+ path: "/v1",+ endpoint: "/messages",model_id: "claude-sonnet-4-6",context_window: 200_000,key_saved: true,@@ -37,12 +39,12 @@ function buildTestApp(readonly testResult?: {readonly ok: boolean;readonly protocol: "anthropic";- readonly base_url: string;+ readonly url: string;readonly model_id: string;readonly context_window: number;};readonly modelList?: {- readonly base_url: string;+ readonly url: string;readonly models: readonly {readonly id: string;readonly name?: string;@@ -94,7 +96,7 @@ describe("Agent Management model-source routes", () => {testResult: {ok: true,protocol: "anthropic" as const,- base_url: "https://api.anthropic.com",+ url: "https://api.anthropic.com/v1/messages",model_id: "claude-sonnet-4-6",context_window: 200_000,},@@ -107,9 +109,11 @@ describe("Agent Management model-source routes", () => {method: "POST",headers: { "content-type": "application/json" },body: JSON.stringify({- runtime: "claude",byok: {base_url: "https://api.anthropic.com",+ path: "/v1",+ endpoint: "/messages",+ protocol: "anthropic",api_key: secretKey,model_id: "claude-sonnet-4-6",},@@ -119,8 +123,16 @@ describe("Agent Management model-source routes", () => {const testText = await testRes.text();expect(testText).not.toContain(secretKey);expect(fn).toHaveBeenCalledWith(- expect.objectContaining({ action: "test", runtime: "claude" }),+ expect.objectContaining({+ action: "test",+ byok: expect.objectContaining({+ path: "/v1",+ endpoint: "/messages",+ protocol: "anthropic",+ }),+ }),);+ expect(fn.mock.calls[0]?.[0]).not.toHaveProperty("runtime");const applyRes = await app.request(basePath, {method: "POST",@@ -130,6 +142,9 @@ describe("Agent Management model-source routes", () => {runtime: "claude",byok: {base_url: "https://api.anthropic.com",+ path: "/v1",+ endpoint: "/messages",+ protocol: "anthropic",api_key: secretKey,model_id: "claude-sonnet-4-6",},@@ -141,7 +156,7 @@ describe("Agent Management model-source routes", () => {it("lists a BYOK endpoint's models from the address and key alone", async () => {const modelList = {- base_url: "https://gateway.example.com/anthropic",+ url: "https://open.bigmodel.cn/api/paas/v4/models",models: [{ id: "glm-5", name: "GLM 5", context_window: 131_072 }],};const fn = vi.fn(async () => ({ modelList }));@@ -151,7 +166,10 @@ describe("Agent Management model-source routes", () => {method: "POST",headers: { "content-type": "application/json" },body: JSON.stringify({- base_url: " https://gateway.example.com/v1 ",+ base_url: " https://open.bigmodel.cn ",+ path: "/api/paas/v4",+ endpoint: "/chat/completions",+ protocol: "openai-chat",api_key: secretKey,}),});@@ -163,7 +181,10 @@ describe("Agent Management model-source routes", () => {expect.objectContaining({action: "models",byok: {- base_url: "https://gateway.example.com/v1",+ base_url: "https://open.bigmodel.cn",+ path: "/api/paas/v4",+ endpoint: "/chat/completions",+ protocol: "openai-chat",api_key: secretKey,},}),@@ -173,11 +194,32 @@ describe("Agent Management model-source routes", () => {method: "POST",headers: { "content-type": "application/json" },body: JSON.stringify({- base_url: "https://gateway.example.com/v1",+ base_url: "https://open.bigmodel.cn",+ path: "/api/paas/v4",+ endpoint: "/chat/completions",+ protocol: "openai-chat",model_id: "glm-5",}),});expect(withModel.status).toBe(400);++ for (const address of [+ { path: "api/paas/v4", endpoint: "/chat/completions" },+ { path: "/api/paas/v4/", endpoint: "/chat/completions" },+ { path: "", endpoint: "//evil.example.com/x" },+ { path: "", endpoint: "/chat?key=1" },+ ]) {+ const refused = await app.request(`${basePath}/models`, {+ method: "POST",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({+ base_url: "https://open.bigmodel.cn",+ protocol: "openai-chat",+ ...address,+ }),+ });+ expect(refused.status).toBe(400);+ }expect(fn).toHaveBeenCalledTimes(1);});@@ -195,9 +237,11 @@ describe("Agent Management model-source routes", () => {method: "POST",headers: { "content-type": "application/json" },body: JSON.stringify({- runtime: "gemini",byok: {base_url: "https://api.example.com",+ path: "/v1",+ endpoint: "/chat/completions",+ protocol: "gemini",api_key: secretKey,model_id: "gpt-5.4",},@@ -211,9 +255,11 @@ describe("Agent Management model-source routes", () => {method: "POST",headers: { "content-type": "application/json" },body: JSON.stringify({- runtime: "pi",byok: {base_url: "https://api.anthropic.com",+ path: "/v1",+ endpoint: "/messages",+ protocol: "anthropic",api_key: secretKey,model_id: "claude-sonnet-4-6",},diff --git a/apps/node-services/tests/agent/runner-gateway/runner-gateway-local-models.test.ts b/apps/node-services/tests/agent/runner-gateway/runner-gateway-local-models.test.tsindex 342f1747..f5c118f4 100644--- a/apps/node-services/tests/agent/runner-gateway/runner-gateway-local-models.test.ts+++ b/apps/node-services/tests/agent/runner-gateway/runner-gateway-local-models.test.ts@@ -187,9 +187,12 @@ const versions = (registry: TestLocalComputerRegistry) =>describe("Runner Gateway local models", () => {// A Computer sends runner.local_models only when the welcome names the// family; a release before 0.52.0 rejects the unknown welcome key, so it- // is welcomed without it and keeps receiving its target_release.+ // is welcomed without it and keeps receiving its target_release. BYOK+ // paths are named only to a release that decodes them.it.each([- ["dev", ["local_models"]],+ ["dev", ["local_models", "byok_endpoint"]],+ ["0.56.0", ["local_models", "byok_endpoint"]],+ ["0.55.0", ["local_models"]],["0.52.0", ["local_models"]],["0.51.0", undefined],])(diff --git a/apps/node-services/tests/agent/runner-gateway/runner-gateway-model-source.test.ts b/apps/node-services/tests/agent/runner-gateway/runner-gateway-model-source.test.tsindex a493c050..3740a77a 100644--- a/apps/node-services/tests/agent/runner-gateway/runner-gateway-model-source.test.ts+++ b/apps/node-services/tests/agent/runner-gateway/runner-gateway-model-source.test.ts@@ -102,4 +102,23 @@ describe("Runner Gateway model source", () => {).rejects.toBeInstanceOf(LocalComputerCapabilityError);expect(sent.some(isModelSourceCommand)).toBe(false);});++ // A Computer before 0.56.0 closes the connection on a BYOK path, endpoint+ // or protocol, so it gets only commands without a BYOK input.+ it("refuses a BYOK input to a Computer that predates BYOK paths", async () => {+ const { gateway, sent } = await connect("0.55.0");+ await expect(+ gateway.modelSource({+ ...target,+ action: "models",+ byok: {+ base_url: "https://open.bigmodel.cn",+ path: "/api/paas/v4",+ endpoint: "/chat/completions",+ protocol: "openai-chat",+ },+ }),+ ).rejects.toBeInstanceOf(LocalComputerCapabilityError);+ expect(sent.some(isModelSourceCommand)).toBe(false);+ });});diff --git a/apps/teamhub/internal/app/handlers_model_source.go b/apps/teamhub/internal/app/handlers_model_source.goindex 1904b1ca..ed8439e0 100644--- a/apps/teamhub/internal/app/handlers_model_source.go+++ b/apps/teamhub/internal/app/handlers_model_source.go@@ -5,6 +5,7 @@ import ("encoding/json""errors""net/http"+ "regexp""strings""time"@@ -33,7 +34,7 @@ var modelSourceRefusalCodes = map[string]httpapi.ModelSourceErrorCode{"MODEL_UNKNOWN": httpapi.ModelSourceErrorCodeLocalModelUnknown,"BYOK_INVALID_CONFIG": httpapi.ModelSourceErrorCodeByokInvalidConfig,"BYOK_AUTH_FAILED": httpapi.ModelSourceErrorCodeByokAuthFailed,- "BYOK_MODEL_NOT_FOUND": httpapi.ModelSourceErrorCodeByokModelNotFound,+ "BYOK_NOT_FOUND": httpapi.ModelSourceErrorCodeByokNotFound,"BYOK_UNREACHABLE": httpapi.ModelSourceErrorCodeByokUnreachable,"BYOK_UPSTREAM_REJECTED": httpapi.ModelSourceErrorCodeByokUpstreamRejected,"MODEL_SOURCE_TIMEOUT": httpapi.ModelSourceErrorCodeModelSourceUnconfirmed,@@ -50,7 +51,7 @@ var modelSourceErrorMessages = map[httpapi.ModelSourceErrorCode]string{httpapi.ModelSourceErrorCodeLocalModelUnknown: "The Computer does not know this model",httpapi.ModelSourceErrorCodeByokInvalidConfig: "The Computer rejected this endpoint configuration",httpapi.ModelSourceErrorCodeByokAuthFailed: "The endpoint rejected the API key",- httpapi.ModelSourceErrorCodeByokModelNotFound: "The endpoint does not serve this model",+ httpapi.ModelSourceErrorCodeByokNotFound: "Nothing answered at the endpoint address, or it does not serve this model",httpapi.ModelSourceErrorCodeByokUnreachable: "The Computer could not reach the endpoint",httpapi.ModelSourceErrorCodeByokUpstreamRejected: "The endpoint rejected the test request",httpapi.ModelSourceErrorCodeModelSourceFailed: "The Computer could not change its model source",@@ -190,7 +191,7 @@ func (a *App) switchLocalComputerModelSource(c *gin.Context) {// Computer without saving it anywhere.func (a *App) testLocalComputerModelSource(c *gin.Context) {var request httpapi.ByokTestRequest- if err := decodeJSON(c, &request); err != nil || !request.Runtime.Valid() || !validByokInput(request.Byok) {+ if err := decodeJSON(c, &request); err != nil || !validByokInput(request.Byok) {a.writeError(c, http.StatusBadRequest, "INVALID_REQUEST", "BYOK configuration is invalid")return}@@ -224,8 +225,9 @@ func (a *App) testLocalComputerModelSource(c *gin.Context) {// from the owner's Computer.func (a *App) listLocalComputerByokModels(c *gin.Context) {var endpoint httpapi.ByokEndpointInput- if err := decodeJSON(c, &endpoint); err != nil || strings.TrimSpace(endpoint.BaseUrl) == "" ||- len(endpoint.BaseUrl) > 2048 || (endpoint.ApiKey != nil && len(*endpoint.ApiKey) > 4096) {+ if err := decodeJSON(c, &endpoint); err != nil ||+ !validByokAddress(endpoint.BaseUrl, endpoint.Path, endpoint.Endpoint, endpoint.Protocol) ||+ (endpoint.ApiKey != nil && len(*endpoint.ApiKey) > 4096) {a.writeError(c, http.StatusBadRequest, "INVALID_REQUEST", "BYOK endpoint is invalid")return}@@ -384,8 +386,18 @@ func validModelSourceSwitch(request httpapi.ModelSourceSwitchRequest) bool {return false}+// byokURLPathPattern matches a BYOK path or endpoint: empty, or whole+// segments each led by one slash, so it can only extend the base URL's path.+var byokURLPathPattern = regexp.MustCompile(`^(/[^/?#\s\\]+)*$`)++func validByokAddress(baseURL, path, endpoint string, protocol httpapi.ByokProtocol) bool {+ return strings.TrimSpace(baseURL) != "" && len(baseURL) <= 2048 && protocol.Valid() &&+ len(path) <= 256 && byokURLPathPattern.MatchString(path) &&+ len(endpoint) <= 256 && byokURLPathPattern.MatchString(endpoint)+}+func validByokInput(input httpapi.ByokInput) bool {- return strings.TrimSpace(input.BaseUrl) != "" && len(input.BaseUrl) <= 2048 &&+ return validByokAddress(input.BaseUrl, input.Path, input.Endpoint, input.Protocol) &&strings.TrimSpace(input.ModelId) != "" && len(input.ModelId) <= 256 &&(input.ApiKey == nil || len(*input.ApiKey) <= 4096) &&(input.ContextWindow == nil || *input.ContextWindow >= 1)diff --git a/apps/teamhub/internal/app/handlers_model_source_test.go b/apps/teamhub/internal/app/handlers_model_source_test.goindex 068b928e..f10cc640 100644--- a/apps/teamhub/internal/app/handlers_model_source_test.go+++ b/apps/teamhub/internal/app/handlers_model_source_test.go@@ -11,8 +11,19 @@ func TestValidModelSourceSwitchMatchesRuntimeAndInputsToMode(t *testing.T) {unknown := httpapi.ModelSourceRuntime("gemini")model := "qwen3-4b:Q4_K_M"badModel := "../qwen"- byok := &httpapi.ByokInput{BaseUrl: "https://api.example.com", ModelId: "vendor/model"}- blankURL := &httpapi.ByokInput{BaseUrl: " ", ModelId: "vendor/model"}+ byok := &httpapi.ByokInput{+ BaseUrl: "https://open.bigmodel.cn", Path: "/api/paas/v4", Endpoint: "/chat/completions",+ Protocol: httpapi.ByokProtocolOpenaiChat, ModelId: "vendor/model",+ }+ fullAddress := &httpapi.ByokInput{+ BaseUrl: "https://gw.example.com/full", Protocol: httpapi.ByokProtocolAnthropic, ModelId: "vendor/model",+ }+ with := func(change func(*httpapi.ByokInput)) *httpapi.ByokInput {+ changed := *byok+ change(&changed)+ return &changed+ }+ blankURL := with(func(b *httpapi.ByokInput) { b.BaseUrl = " " })for _, test := range []struct {name stringrequest httpapi.ModelSourceSwitchRequest@@ -23,6 +34,12 @@ func TestValidModelSourceSwitchMatchesRuntimeAndInputsToMode(t *testing.T) {{"byok without runtime", httpapi.ModelSourceSwitchRequest{Mode: httpapi.ModelSourceModeByok, Byok: byok}, false},{"byok without endpoint", httpapi.ModelSourceSwitchRequest{Mode: httpapi.ModelSourceModeByok, Runtime: &claude}, false},{"byok blank URL", httpapi.ModelSourceSwitchRequest{Mode: httpapi.ModelSourceModeByok, Runtime: &claude, Byok: blankURL}, false},+ {"byok full address", httpapi.ModelSourceSwitchRequest{Mode: httpapi.ModelSourceModeByok, Runtime: &claude, Byok: fullAddress}, true},+ {"byok path without slash", httpapi.ModelSourceSwitchRequest{Mode: httpapi.ModelSourceModeByok, Runtime: &claude, Byok: with(func(b *httpapi.ByokInput) { b.Path = "v1" })}, false},+ {"byok path with trailing slash", httpapi.ModelSourceSwitchRequest{Mode: httpapi.ModelSourceModeByok, Runtime: &claude, Byok: with(func(b *httpapi.ByokInput) { b.Path = "/v1/" })}, false},+ {"byok endpoint with host", httpapi.ModelSourceSwitchRequest{Mode: httpapi.ModelSourceModeByok, Runtime: &claude, Byok: with(func(b *httpapi.ByokInput) { b.Endpoint = "//evil.example.com/x" })}, false},+ {"byok endpoint with query", httpapi.ModelSourceSwitchRequest{Mode: httpapi.ModelSourceModeByok, Runtime: &claude, Byok: with(func(b *httpapi.ByokInput) { b.Endpoint = "/chat?x=1" })}, false},+ {"byok unknown protocol", httpapi.ModelSourceSwitchRequest{Mode: httpapi.ModelSourceModeByok, Runtime: &claude, Byok: with(func(b *httpapi.ByokInput) { b.Protocol = "gemini" })}, false},{"subscription", httpapi.ModelSourceSwitchRequest{Mode: httpapi.ModelSourceModeSubscription, Runtime: &claude}, true},{"subscription on pi", httpapi.ModelSourceSwitchRequest{Mode: httpapi.ModelSourceModeSubscription, Runtime: &pi}, false},{"subscription with endpoint", httpapi.ModelSourceSwitchRequest{Mode: httpapi.ModelSourceModeSubscription, Runtime: &claude, Byok: byok}, false},diff --git a/apps/teamhub/internal/roomagent/model_source_test.go b/apps/teamhub/internal/roomagent/model_source_test.goindex 71641362..0bc68c1e 100644--- a/apps/teamhub/internal/roomagent/model_source_test.go+++ b/apps/teamhub/internal/roomagent/model_source_test.go@@ -39,7 +39,8 @@ func TestHTTPGatewayAppliesModelSourceAndMapsRefusals(t *testing.T) {runtime := nodeservicesinternal.ModelSourceRuntime("codex")key := "sk-test"command := nodeservicesinternal.ModelSourceApplyCommand{Mode: "byok", Runtime: &runtime, Byok: &nodeservicesinternal.ByokInput{- BaseUrl: "https://api.example.com/v1", ApiKey: &key, ModelId: "gpt-5.5",+ BaseUrl: "https://api.example.com", Path: "/v1", Endpoint: "/responses", Protocol: "openai-responses",+ ApiKey: &key, ModelId: "gpt-5.5",}}status, answer = http.StatusOK, `{"mode":"byok","runtime":"codex","runtime_model":"localmodels-byok","reasoning_effort":"high","byok":{"configured":true,"key_saved":true}}`@@ -80,11 +81,12 @@ func TestHTTPGatewayListsByokModelsFromTheComputer(t *testing.T) {t.Fatalf("%s %s", r.Method, r.URL.Path)}var body map[string]any- if err := json.NewDecoder(r.Body).Decode(&body); err != nil || body["api_key"] != "sk-test" || body["base_url"] != "https://api.example.com/v1" {+ if err := json.NewDecoder(r.Body).Decode(&body); err != nil || body["api_key"] != "sk-test" ||+ body["base_url"] != "https://api.example.com" || body["path"] != "/api/paas/v4" || body["protocol"] != "openai-chat" {t.Fatalf("body=%v err=%v", body, err)}w.Header().Set("Content-Type", "application/json")- _, _ = w.Write([]byte(`{"base_url":"https://api.example.com","models":[{"id":"glm-5","name":"GLM 5","context_window":131072}]}`))+ _, _ = w.Write([]byte(`{"url":"https://api.example.com/api/paas/v4/models","models":[{"id":"glm-5","name":"GLM 5","context_window":131072}]}`))}))t.Cleanup(server.Close)gateway, err := NewHTTPGateway(server.URL, "service-secret", server.Client())@@ -94,8 +96,10 @@ func TestHTTPGatewayListsByokModelsFromTheComputer(t *testing.T) {key := "sk-test"list, err := gateway.ListLocalComputerByokModels(context.Background(),ModelSourceTarget{TenantID: "tenant_1", OwnerActorID: "actor_owner", ComputerID: "computer_1"},- nodeservicesinternal.ByokEndpointInput{BaseUrl: "https://api.example.com/v1", ApiKey: &key})- if err != nil || list.BaseUrl != "https://api.example.com" || len(list.Models) != 1 ||+ nodeservicesinternal.ByokEndpointInput{+ BaseUrl: "https://api.example.com", Path: "/api/paas/v4", Endpoint: "/chat/completions", Protocol: "openai-chat", ApiKey: &key,+ })+ if err != nil || list.Url != "https://api.example.com/api/paas/v4/models" || len(list.Models) != 1 ||list.Models[0].ContextWindow == nil || *list.Models[0].ContextWindow != 131072 {t.Fatalf("list=%+v err=%v", list, err)}diff --git a/apps/teamhub/tests/integration/local_computer_model_source_test.go b/apps/teamhub/tests/integration/local_computer_model_source_test.goindex cd51f098..f74c3969 100644--- a/apps/teamhub/tests/integration/local_computer_model_source_test.go+++ b/apps/teamhub/tests/integration/local_computer_model_source_test.go@@ -53,7 +53,7 @@ func (c *modelSourceComputers) TestLocalComputerByok(_ context.Context, _ roomagif input.ApiKey == nil || *input.ApiKey != modelSourceTestAPIKey {return nodeservicesinternal.ByokTestResult{}, &roomagent.ModelSourceError{Code: "BYOK_AUTH_FAILED"}}- return nodeservicesinternal.ByokTestResult{Ok: true, Protocol: "anthropic", BaseUrl: input.BaseUrl, ModelId: input.ModelId, ContextWindow: 200000}, nil+ return nodeservicesinternal.ByokTestResult{Ok: true, Protocol: input.Protocol, Url: input.BaseUrl + input.Path + input.Endpoint, ModelId: input.ModelId, ContextWindow: 200000}, nil}func (c *modelSourceComputers) ListLocalComputerByokModels(_ context.Context, _ roomagent.ModelSourceTarget, endpoint nodeservicesinternal.ByokEndpointInput) (nodeservicesinternal.ByokModelList, error) {@@ -61,7 +61,7 @@ func (c *modelSourceComputers) ListLocalComputerByokModels(_ context.Context, _return nodeservicesinternal.ByokModelList{}, &roomagent.ModelSourceError{Code: "BYOK_AUTH_FAILED"}}window := 131072- return nodeservicesinternal.ByokModelList{BaseUrl: endpoint.BaseUrl, Models: []nodeservicesinternal.ByokModel{{Id: "vendor/model", ContextWindow: &window}}}, nil+ return nodeservicesinternal.ByokModelList{Url: endpoint.BaseUrl + endpoint.Path + "/models", Models: []nodeservicesinternal.ByokModel{{Id: "vendor/model", ContextWindow: &window}}}, nil}func (c *modelSourceComputers) appliedSnapshot() []nodeservicesinternal.ModelSourceApplyCommand {@@ -149,7 +149,8 @@ func TestLocalComputerModelSourceSwitchMovesAgentsAndEndsChosenWork(t *testing.Tt.Fatalf("member view: %d %s", status, body)}byokSwitch := map[string]any{"mode": "byok", "runtime": "claude", "byok": map[string]any{- "base_url": "https://api.example.com", "api_key": modelSourceTestAPIKey, "model_id": "vendor/model",+ "base_url": "https://api.example.com", "path": "/api/v3", "endpoint": "/messages", "protocol": "anthropic",+ "api_key": modelSourceTestAPIKey, "model_id": "vendor/model",}}status, _, body = env.request(bob, http.MethodPost, base, byokSwitch, "")if status != http.StatusForbidden || !containsJSONText(body, "MODEL_SOURCE_FORBIDDEN") {@@ -160,23 +161,28 @@ func TestLocalComputerModelSourceSwitchMovesAgentsAndEndsChosenWork(t *testing.Tt.Fatalf("subscription on pi: %d %s", status, body)}- status, _, body = env.request(alice, http.MethodPost, base+"/test", map[string]any{"runtime": "claude", "byok": byokSwitch["byok"]}, "")- if status != http.StatusOK || !containsJSONText(body, `"context_window":200000`) || containsJSONText(body, modelSourceTestAPIKey) {+ status, _, body = env.request(alice, http.MethodPost, base+"/test", map[string]any{"byok": byokSwitch["byok"]}, "")+ if status != http.StatusOK || !containsJSONText(body, `"context_window":200000`) ||+ !containsJSONText(body, `"url":"https://api.example.com/api/v3/messages"`) || containsJSONText(body, modelSourceTestAPIKey) {t.Fatalf("BYOK test: %d %s", status, body)}status, _, body = env.request(alice, http.MethodPost, base+"/test", byokSwitch["byok"], "")if status != http.StatusBadRequest {- t.Fatalf("BYOK test without a Runtime: %d %s", status, body)+ t.Fatalf("BYOK test without its envelope: %d %s", status, body)}- status, _, body = env.request(alice, http.MethodPost, base+"/test", map[string]any{"runtime": "claude", "byok": map[string]any{"base_url": "https://api.example.com", "api_key": "wrong", "model_id": "vendor/model"}}, "")+ status, _, body = env.request(alice, http.MethodPost, base+"/test", map[string]any{"byok": map[string]any{"base_url": "https://api.example.com", "path": "v1", "endpoint": "/messages", "protocol": "anthropic", "model_id": "vendor/model"}}, "")+ if status != http.StatusBadRequest {+ t.Fatalf("BYOK test with a path that is not a path: %d %s", status, body)+ }+ status, _, body = env.request(alice, http.MethodPost, base+"/test", map[string]any{"byok": map[string]any{"base_url": "https://api.example.com", "path": "/v1", "endpoint": "/messages", "protocol": "anthropic", "api_key": "wrong", "model_id": "vendor/model"}}, "")if status != http.StatusConflict || !containsJSONText(body, "BYOK_AUTH_FAILED") {t.Fatalf("BYOK test with a wrong key: %d %s", status, body)}- status, _, body = env.request(alice, http.MethodPost, base+"/models", map[string]any{"base_url": "https://api.example.com/v1", "api_key": modelSourceTestAPIKey}, "")+ status, _, body = env.request(alice, http.MethodPost, base+"/models", map[string]any{"base_url": "https://api.example.com", "path": "/v1", "endpoint": "/chat/completions", "protocol": "openai-chat", "api_key": modelSourceTestAPIKey}, "")if status != http.StatusOK || !containsJSONText(body, `"context_window":131072`) || containsJSONText(body, modelSourceTestAPIKey) {t.Fatalf("BYOK models: %d %s", status, body)}- status, _, body = env.request(bob, http.MethodPost, base+"/models", map[string]any{"base_url": "https://api.example.com/v1", "api_key": modelSourceTestAPIKey}, "")+ status, _, body = env.request(bob, http.MethodPost, base+"/models", map[string]any{"base_url": "https://api.example.com", "path": "/v1", "endpoint": "/chat/completions", "protocol": "openai-chat", "api_key": modelSourceTestAPIKey}, "")if status != http.StatusForbidden {t.Fatalf("member BYOK models: %d %s", status, body)}diff --git a/contracts/generated/go/nodeservicesinternal/openapi.gen.go b/contracts/generated/go/nodeservicesinternal/openapi.gen.goindex d49cea50..69681224 100644--- a/contracts/generated/go/nodeservicesinternal/openapi.gen.go+++ b/contracts/generated/go/nodeservicesinternal/openapi.gen.go@@ -1511,20 +1511,38 @@ type BrowserConnectionStatusState string// BrowserProfile A Chrome profile directory name inside the user's Chrome data directory.type BrowserProfile = string-// ByokEndpointInput A BYOK endpoint address and key, enough to list its models. The API key is never persisted in TeamHub or Agent Service.+// ByokEndpointInput A BYOK endpoint address and key, enough to list its models at base_url + path + /models with protocol's key header. The API key is never persisted in TeamHub or Agent Service.type ByokEndpointInput struct {- ApiKey *string `json:"api_key,omitempty"`- BaseUrl string `json:"base_url"`- ReuseSavedKey *bool `json:"reuse_saved_key,omitempty"`+ ApiKey *string `json:"api_key,omitempty"`+ BaseUrl string `json:"base_url"`++ // Endpoint A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path.+ Endpoint ByokUrlPath `json:"endpoint"`++ // Path A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path.+ Path ByokUrlPath `json:"path"`++ // Protocol Wire format of a BYOK upstream endpoint. The owner's client derives it from the end of the request address, else from the Runtime's own format; the Computer does not probe for it.+ Protocol ByokProtocol `json:"protocol"`+ ReuseSavedKey *bool `json:"reuse_saved_key,omitempty"`}-// ByokInput Upstream endpoint configuration supplied by the Computer owner. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file.+// ByokInput Upstream endpoint configuration supplied by the Computer owner. Requests go to base_url + path + endpoint in protocol, and models are listed at base_url + path + /models. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file.type ByokInput struct {ApiKey *string `json:"api_key,omitempty"`BaseUrl string `json:"base_url"`ContextWindow *int `json:"context_window,omitempty"`- ModelId string `json:"model_id"`- ReuseSavedKey *bool `json:"reuse_saved_key,omitempty"`++ // Endpoint A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path.+ Endpoint ByokUrlPath `json:"endpoint"`+ ModelId string `json:"model_id"`++ // Path A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path.+ Path ByokUrlPath `json:"path"`++ // Protocol Wire format of a BYOK upstream endpoint. The owner's client derives it from the end of the request address, else from the Runtime's own format; the Computer does not probe for it.+ Protocol ByokProtocol `json:"protocol"`+ ReuseSavedKey *bool `json:"reuse_saved_key,omitempty"`}// ByokModel A model a BYOK endpoint lists.@@ -1538,47 +1556,55 @@ type ByokModel struct {// ByokModelList The models a BYOK endpoint lists, sorted by id.type ByokModelList struct {- // BaseUrl The address that listed them.- BaseUrl string `json:"base_url"`- Models []ByokModel `json:"models"`+ Models []ByokModel `json:"models"`++ // Url The address that listed them.+ Url string `json:"url"`}-// ByokProtocol Wire format the Computer found a BYOK upstream endpoint answers, trying the active Runtime's own format first.+// ByokProtocol Wire format of a BYOK upstream endpoint. The owner's client derives it from the end of the request address, else from the Runtime's own format; the Computer does not probe for it.type ByokProtocol string-// ByokSummary Redacted BYOK configuration metadata reported by the Computer.+// ByokSummary Redacted BYOK configuration metadata reported by the Computer. path and endpoint are omitted when empty: a configured summary without them appends nothing there.type ByokSummary struct {BaseUrl *string `json:"base_url,omitempty"`Configured bool `json:"configured"`ContextWindow *int `json:"context_window,omitempty"`- KeySaved bool `json:"key_saved"`- ModelId *string `json:"model_id,omitempty"`- // Protocol Wire format the Computer found a BYOK upstream endpoint answers, trying the active Runtime's own format first.+ // Endpoint A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path.+ Endpoint *ByokUrlPath `json:"endpoint,omitempty"`+ KeySaved bool `json:"key_saved"`+ ModelId *string `json:"model_id,omitempty"`++ // Path A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path.+ Path *ByokUrlPath `json:"path,omitempty"`++ // Protocol Wire format of a BYOK upstream endpoint. The owner's client derives it from the end of the request address, else from the Runtime's own format; the Computer does not probe for it.Protocol *ByokProtocol `json:"protocol,omitempty"`}-// ByokTestRequest A BYOK endpoint to verify from the Computer for the Runtime that would serve it, which decides the order wire formats are tried.+// ByokTestRequest A BYOK endpoint to verify with one request from the Computer.type ByokTestRequest struct {- // Byok Upstream endpoint configuration supplied by the Computer owner. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file.+ // Byok Upstream endpoint configuration supplied by the Computer owner. Requests go to base_url + path + endpoint in protocol, and models are listed at base_url + path + /models. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file.Byok ByokInput `json:"byok"`-- // Runtime Agent runtime harness driving turns on the Computer.- Runtime ModelSourceRuntime `json:"runtime"`}-// ByokTestResult Outcome of probing an upstream BYOK endpoint from the Local Computer.+// ByokTestResult Outcome of one request to an upstream BYOK endpoint from the Local Computer.type ByokTestResult struct {- // BaseUrl The address that answered, which can add or drop the /anthropic of a gateway that serves OpenAI under /v1 and Anthropic under /anthropic.- BaseUrl string `json:"base_url"`ContextWindow int `json:"context_window"`ModelId string `json:"model_id"`Ok bool `json:"ok"`- // Protocol Wire format the Computer found a BYOK upstream endpoint answers, trying the active Runtime's own format first.+ // Protocol Wire format of a BYOK upstream endpoint. The owner's client derives it from the end of the request address, else from the Runtime's own format; the Computer does not probe for it.Protocol ByokProtocol `json:"protocol"`++ // Url The address the request went to.+ Url string `json:"url"`}+// ByokUrlPath A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path.+type ByokUrlPath = string+// CancelAgentRunRequest defines model for CancelAgentRunRequest.type CancelAgentRunRequest struct {ContextRef *AgentRuntimeContextRef `json:"context_ref,omitempty"`@@ -2274,7 +2300,7 @@ type ModelCallResult struct {// ModelSourceApplyCommand Internal command sent from TeamHub to Agent Service to switch a Computer's model source.type ModelSourceApplyCommand struct {- // Byok Upstream endpoint configuration supplied by the Computer owner. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file.+ // Byok Upstream endpoint configuration supplied by the Computer owner. Requests go to base_url + path + endpoint in protocol, and models are listed at base_url + path + /models. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file.Byok *ByokInput `json:"byok,omitempty"`// LocalModelId Stable localmodels library id: catalog id and variant, such as qwen3-4b:Q4_K_M.@@ -2295,7 +2321,7 @@ type ModelSourceRuntime string// ModelSourceStatus Active model source and redacted BYOK metadata on one Local Computer.type ModelSourceStatus struct {- // Byok Redacted BYOK configuration metadata reported by the Computer.+ // Byok Redacted BYOK configuration metadata reported by the Computer. path and endpoint are omitted when empty: a configured summary without them appends nothing there.Byok ByokSummary `json:"byok"`GatewayUrl *string `json:"gateway_url,omitempty"`diff --git a/contracts/generated/go/runnergateway/wire.gen.go b/contracts/generated/go/runnergateway/wire.gen.goindex d752713a..99d7491c 100644--- a/contracts/generated/go/runnergateway/wire.gen.go+++ b/contracts/generated/go/runnergateway/wire.gen.go@@ -869,6 +869,9 @@ func (CapabilityBrowserFailed) RequiredFields() []string {// ByokConfigInput mirrors the ByokConfigInput schema shape.type ByokConfigInput struct {BaseURL string `json:"base_url"`+ Path string `json:"path"`+ Endpoint string `json:"endpoint"`+ Protocol string `json:"protocol"`APIKey string `json:"api_key,omitempty"`ModelID string `json:"model_id,omitempty"`ContextWindow *uint64 `json:"context_window,omitempty"`@@ -879,13 +882,17 @@ type ByokConfigInput struct {func (ByokConfigInput) FixedFields() map[string]string { return nil }// RequiredFields lists the keys a ByokConfigInput must carry.-func (ByokConfigInput) RequiredFields() []string { return []string{"base_url"} }+func (ByokConfigInput) RequiredFields() []string {+ return []string{"base_url", "path", "endpoint", "protocol"}+}// ByokSummary mirrors the ByokSummary schema shape.type ByokSummary struct {Configured bool `json:"configured"`Protocol string `json:"protocol,omitempty"`BaseURL string `json:"base_url,omitempty"`+ Path string `json:"path,omitempty"`+ Endpoint string `json:"endpoint,omitempty"`ModelID string `json:"model_id,omitempty"`ContextWindow *uint64 `json:"context_window,omitempty"`KeySaved bool `json:"key_saved"`@@ -930,21 +937,21 @@ func (ByokModelListModelsItem) RequiredFields() []string { return []string{"id"}// ByokModelList mirrors the ByokModelList schema shape.type ByokModelList struct {- BaseURL string `json:"base_url"`- Models []ByokModelListModelsItem `json:"models"`+ URL string `json:"url"`+ Models []ByokModelListModelsItem `json:"models"`}// FixedFields lists the keys whose value the schema fixes for a ByokModelList.func (ByokModelList) FixedFields() map[string]string { return nil }// RequiredFields lists the keys a ByokModelList must carry.-func (ByokModelList) RequiredFields() []string { return []string{"base_url", "models"} }+func (ByokModelList) RequiredFields() []string { return []string{"url", "models"} }// ByokTestResult mirrors the ByokTestResult schema shape.type ByokTestResult struct {Ok bool `json:"ok"`Protocol string `json:"protocol"`- BaseURL string `json:"base_url"`+ URL string `json:"url"`ModelID string `json:"model_id"`ContextWindow uint64 `json:"context_window"`}@@ -954,7 +961,7 @@ func (ByokTestResult) FixedFields() map[string]string { return nil }// RequiredFields lists the keys a ByokTestResult must carry.func (ByokTestResult) RequiredFields() []string {- return []string{"ok", "protocol", "base_url", "model_id", "context_window"}+ return []string{"ok", "protocol", "url", "model_id", "context_window"}}// CapabilityModelSource mirrors the CapabilityModelSource schema shape.diff --git a/contracts/generated/go/teamhubpublic/openapi.gen.go b/contracts/generated/go/teamhubpublic/openapi.gen.goindex 1e08a1f2..72a55324 100644--- a/contracts/generated/go/teamhubpublic/openapi.gen.go+++ b/contracts/generated/go/teamhubpublic/openapi.gen.go@@ -2848,7 +2848,7 @@ const (ModelSourceErrorCodeAgentHasActiveRuns ModelSourceErrorCode = "AGENT_HAS_ACTIVE_RUNS"ModelSourceErrorCodeByokAuthFailed ModelSourceErrorCode = "BYOK_AUTH_FAILED"ModelSourceErrorCodeByokInvalidConfig ModelSourceErrorCode = "BYOK_INVALID_CONFIG"- ModelSourceErrorCodeByokModelNotFound ModelSourceErrorCode = "BYOK_MODEL_NOT_FOUND"+ ModelSourceErrorCodeByokNotFound ModelSourceErrorCode = "BYOK_NOT_FOUND"ModelSourceErrorCodeByokUnreachable ModelSourceErrorCode = "BYOK_UNREACHABLE"ModelSourceErrorCodeByokUpstreamRejected ModelSourceErrorCode = "BYOK_UPSTREAM_REJECTED"ModelSourceErrorCodeLocalComputerOffline ModelSourceErrorCode = "LOCAL_COMPUTER_OFFLINE"@@ -2871,7 +2871,7 @@ func (e ModelSourceErrorCode) Valid() bool {return truecase ModelSourceErrorCodeByokInvalidConfig:return true- case ModelSourceErrorCodeByokModelNotFound:+ case ModelSourceErrorCodeByokNotFound:return truecase ModelSourceErrorCodeByokUnreachable:return true@@ -4836,20 +4836,38 @@ type BrowserConnectionStatusState string// BrowserProfile A Chrome profile directory name inside the user's Chrome data directory.type BrowserProfile = string-// ByokEndpointInput A BYOK endpoint address and key, enough to list its models. The API key is never persisted in TeamHub or Agent Service.+// ByokEndpointInput A BYOK endpoint address and key, enough to list its models at base_url + path + /models with protocol's key header. The API key is never persisted in TeamHub or Agent Service.type ByokEndpointInput struct {- ApiKey *string `json:"api_key,omitempty"`- BaseUrl string `json:"base_url"`- ReuseSavedKey *bool `json:"reuse_saved_key,omitempty"`+ ApiKey *string `json:"api_key,omitempty"`+ BaseUrl string `json:"base_url"`++ // Endpoint A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path.+ Endpoint ByokUrlPath `json:"endpoint"`++ // Path A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path.+ Path ByokUrlPath `json:"path"`++ // Protocol Wire format of a BYOK upstream endpoint. The owner's client derives it from the end of the request address, else from the Runtime's own format; the Computer does not probe for it.+ Protocol ByokProtocol `json:"protocol"`+ ReuseSavedKey *bool `json:"reuse_saved_key,omitempty"`}-// ByokInput Upstream endpoint configuration supplied by the Computer owner. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file.+// ByokInput Upstream endpoint configuration supplied by the Computer owner. Requests go to base_url + path + endpoint in protocol, and models are listed at base_url + path + /models. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file.type ByokInput struct {ApiKey *string `json:"api_key,omitempty"`BaseUrl string `json:"base_url"`ContextWindow *int `json:"context_window,omitempty"`- ModelId string `json:"model_id"`- ReuseSavedKey *bool `json:"reuse_saved_key,omitempty"`++ // Endpoint A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path.+ Endpoint ByokUrlPath `json:"endpoint"`+ ModelId string `json:"model_id"`++ // Path A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path.+ Path ByokUrlPath `json:"path"`++ // Protocol Wire format of a BYOK upstream endpoint. The owner's client derives it from the end of the request address, else from the Runtime's own format; the Computer does not probe for it.+ Protocol ByokProtocol `json:"protocol"`+ ReuseSavedKey *bool `json:"reuse_saved_key,omitempty"`}// ByokModel A model a BYOK endpoint lists.@@ -4863,47 +4881,55 @@ type ByokModel struct {// ByokModelList The models a BYOK endpoint lists, sorted by id.type ByokModelList struct {- // BaseUrl The address that listed them.- BaseUrl string `json:"base_url"`- Models []ByokModel `json:"models"`+ Models []ByokModel `json:"models"`++ // Url The address that listed them.+ Url string `json:"url"`}-// ByokProtocol Wire format the Computer found a BYOK upstream endpoint answers, trying the active Runtime's own format first.+// ByokProtocol Wire format of a BYOK upstream endpoint. The owner's client derives it from the end of the request address, else from the Runtime's own format; the Computer does not probe for it.type ByokProtocol string-// ByokSummary Redacted BYOK configuration metadata reported by the Computer.+// ByokSummary Redacted BYOK configuration metadata reported by the Computer. path and endpoint are omitted when empty: a configured summary without them appends nothing there.type ByokSummary struct {BaseUrl *string `json:"base_url,omitempty"`Configured bool `json:"configured"`ContextWindow *int `json:"context_window,omitempty"`- KeySaved bool `json:"key_saved"`- ModelId *string `json:"model_id,omitempty"`- // Protocol Wire format the Computer found a BYOK upstream endpoint answers, trying the active Runtime's own format first.+ // Endpoint A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path.+ Endpoint *ByokUrlPath `json:"endpoint,omitempty"`+ KeySaved bool `json:"key_saved"`+ ModelId *string `json:"model_id,omitempty"`++ // Path A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path.+ Path *ByokUrlPath `json:"path,omitempty"`++ // Protocol Wire format of a BYOK upstream endpoint. The owner's client derives it from the end of the request address, else from the Runtime's own format; the Computer does not probe for it.Protocol *ByokProtocol `json:"protocol,omitempty"`}-// ByokTestRequest A BYOK endpoint to verify from the Computer for the Runtime that would serve it, which decides the order wire formats are tried.+// ByokTestRequest A BYOK endpoint to verify with one request from the Computer.type ByokTestRequest struct {- // Byok Upstream endpoint configuration supplied by the Computer owner. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file.+ // Byok Upstream endpoint configuration supplied by the Computer owner. Requests go to base_url + path + endpoint in protocol, and models are listed at base_url + path + /models. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file.Byok ByokInput `json:"byok"`-- // Runtime Agent runtime harness driving turns on the Computer.- Runtime ModelSourceRuntime `json:"runtime"`}-// ByokTestResult Outcome of probing an upstream BYOK endpoint from the Local Computer.+// ByokTestResult Outcome of one request to an upstream BYOK endpoint from the Local Computer.type ByokTestResult struct {- // BaseUrl The address that answered, which can add or drop the /anthropic of a gateway that serves OpenAI under /v1 and Anthropic under /anthropic.- BaseUrl string `json:"base_url"`ContextWindow int `json:"context_window"`ModelId string `json:"model_id"`Ok bool `json:"ok"`- // Protocol Wire format the Computer found a BYOK upstream endpoint answers, trying the active Runtime's own format first.+ // Protocol Wire format of a BYOK upstream endpoint. The owner's client derives it from the end of the request address, else from the Runtime's own format; the Computer does not probe for it.Protocol ByokProtocol `json:"protocol"`++ // Url The address the request went to.+ Url string `json:"url"`}+// ByokUrlPath A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path.+type ByokUrlPath = string+// CaptureSessionChangedPayload defines model for CaptureSessionChangedPayload.type CaptureSessionChangedPayload struct {Kind interface{} `json:"kind"`@@ -7348,7 +7374,7 @@ type ModelSourceRuntime string// ModelSourceStatus Active model source and redacted BYOK metadata on one Local Computer.type ModelSourceStatus struct {- // Byok Redacted BYOK configuration metadata reported by the Computer.+ // Byok Redacted BYOK configuration metadata reported by the Computer. path and endpoint are omitted when empty: a configured summary without them appends nothing there.Byok ByokSummary `json:"byok"`GatewayUrl *string `json:"gateway_url,omitempty"`@@ -7365,7 +7391,7 @@ type ModelSourceStatus struct {// ModelSourceSwitchRequest Owner request to switch a Computer between local models, native subscriptions, and BYOK on Bifrost. When active Runs exist on the Computer's affected Agents and force_terminate is false, TeamHub refuses with 409 AGENT_HAS_ACTIVE_RUNS; retrying with force_terminate true terminates those Runs and applies the switch.type ModelSourceSwitchRequest struct {- // Byok Upstream endpoint configuration supplied by the Computer owner. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file.+ // Byok Upstream endpoint configuration supplied by the Computer owner. Requests go to base_url + path + endpoint in protocol, and models are listed at base_url + path + /models. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file.Byok *ByokInput `json:"byok,omitempty"`// ForceTerminate True ends running work on the Computer's Agents; absent means false.diff --git a/contracts/generated/typescript/src/generated/linger-installer/types.ts b/contracts/generated/typescript/src/generated/linger-installer/types.tsindex ca6c9860..61873d2d 100644--- a/contracts/generated/typescript/src/generated/linger-installer/types.ts+++ b/contracts/generated/typescript/src/generated/linger-installer/types.ts@@ -300,6 +300,23 @@ export interface paths {patch?: never;trace?: never;};+ "/api/byok/models": {+ parameters: {+ query?: never;+ header?: never;+ path?: never;+ cookie?: never;+ };+ get?: never;+ put?: never;+ /** List the models a BYOK upstream endpoint serves via localmodels */+ post: operations["listInstallerByokModels"];+ delete?: never;+ options?: never;+ head?: never;+ patch?: never;+ trace?: never;+ };"/api/runtime-login": {parameters: {query?: never;@@ -415,19 +432,39 @@ export interface components {ModelCheckReport: {checks: components["schemas"]["CheckResult"][];};+ /** @description Empty, or whole path segments each led by one slash, appended to baseUrl. */+ ByokUrlPath: string;+ /** @enum {string} */+ ByokProtocol: "openai-chat" | "openai-responses" | "anthropic";+ /** @description Requests go to baseUrl + path + endpoint in protocol; models are listed at baseUrl + path + /models. */+ ByokEndpoint: {+ baseUrl: string;+ path: components["schemas"]["ByokUrlPath"];+ endpoint: components["schemas"]["ByokUrlPath"];+ protocol: components["schemas"]["ByokProtocol"];+ apiKey?: string;+ };ByokConfiguration: {baseUrl: string;+ path: components["schemas"]["ByokUrlPath"];+ endpoint: components["schemas"]["ByokUrlPath"];+ protocol: components["schemas"]["ByokProtocol"];apiKey?: string;modelId: string;contextWindow?: number;- /** @enum {string} */- runtime?: "claude" | "codex" | "pi";+ };+ ByokModelReport: {+ url: string;+ models: {+ id: string;+ name?: string;+ contextWindow?: number;+ }[];};ByokCheckReport: {ok: boolean;- /** @enum {string} */- protocol: "openai-chat" | "openai-responses" | "anthropic";- baseUrl: string;+ protocol: components["schemas"]["ByokProtocol"];+ url: string;modelId: string;contextWindow: number;};@@ -1612,6 +1649,48 @@ export interface operations {};};};+ listInstallerByokModels: {+ parameters: {+ query?: never;+ header?: never;+ path?: never;+ cookie?: never;+ };+ requestBody: {+ content: {+ "application/json": components["schemas"]["ByokEndpoint"];+ };+ };+ responses: {+ /** @description The endpoint's models, sorted by id */+ 200: {+ headers: {+ [name: string]: unknown;+ };+ content: {+ "application/json": components["schemas"]["ByokModelReport"];+ };+ };+ /** @description Invalid request */+ 400: {+ headers: {+ [name: string]: unknown;+ };+ content: {+ "application/json": components["schemas"]["InstallerError"];+ };+ };+ /** @description Local installer session required */+ 401: {+ headers: {+ [name: string]: unknown;+ };+ content: {+ "application/json": components["schemas"]["InstallerError"];+ };+ };+ };+ };inspectInstallerRuntimeLogin: {parameters: {query: {diff --git a/contracts/generated/typescript/src/generated/node-services-internal/types.ts b/contracts/generated/typescript/src/generated/node-services-internal/types.tsindex e5c615d3..8726d9a7 100644--- a/contracts/generated/typescript/src/generated/node-services-internal/types.ts+++ b/contracts/generated/typescript/src/generated/node-services-internal/types.ts@@ -1585,15 +1585,19 @@ export interface components {| "max"| "ultra";/**- * @description Wire format the Computer found a BYOK upstream endpoint answers, trying the active Runtime's own format first.+ * @description Wire format of a BYOK upstream endpoint. The owner's client derives it from the end of the request address, else from the Runtime's own format; the Computer does not probe for it.* @enum {string}*/ByokProtocol: "openai-chat" | "openai-responses" | "anthropic";- /** @description Redacted BYOK configuration metadata reported by the Computer. */+ /** @description A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path. */+ ByokUrlPath: string;+ /** @description Redacted BYOK configuration metadata reported by the Computer. path and endpoint are omitted when empty: a configured summary without them appends nothing there. */ByokSummary: {configured: boolean;protocol?: components["schemas"]["ByokProtocol"];base_url?: string;+ path?: components["schemas"]["ByokUrlPath"];+ endpoint?: components["schemas"]["ByokUrlPath"];model_id?: string;context_window?: number;key_saved: boolean;@@ -1608,9 +1612,12 @@ export interface components {gateway_url?: string;byok: components["schemas"]["ByokSummary"];};- /** @description Upstream endpoint configuration supplied by the Computer owner. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file. */+ /** @description Upstream endpoint configuration supplied by the Computer owner. Requests go to base_url + path + endpoint in protocol, and models are listed at base_url + path + /models. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file. */ByokInput: {base_url: string;+ path: components["schemas"]["ByokUrlPath"];+ endpoint: components["schemas"]["ByokUrlPath"];+ protocol: components["schemas"]["ByokProtocol"];api_key?: string;model_id: string;context_window?: number;@@ -1623,9 +1630,12 @@ export interface components {local_model_id?: components["schemas"]["LocalModelId"];byok?: components["schemas"]["ByokInput"];};- /** @description A BYOK endpoint address and key, enough to list its models. The API key is never persisted in TeamHub or Agent Service. */+ /** @description A BYOK endpoint address and key, enough to list its models at base_url + path + /models with protocol's key header. The API key is never persisted in TeamHub or Agent Service. */ByokEndpointInput: {base_url: string;+ path: components["schemas"]["ByokUrlPath"];+ endpoint: components["schemas"]["ByokUrlPath"];+ protocol: components["schemas"]["ByokProtocol"];api_key?: string;reuse_saved_key?: boolean;};@@ -1639,20 +1649,19 @@ export interface components {/** @description The models a BYOK endpoint lists, sorted by id. */ByokModelList: {/** @description The address that listed them. */- base_url: string;+ url: string;models: components["schemas"]["ByokModel"][];};- /** @description A BYOK endpoint to verify from the Computer for the Runtime that would serve it, which decides the order wire formats are tried. */+ /** @description A BYOK endpoint to verify with one request from the Computer. */ByokTestRequest: {- runtime: components["schemas"]["ModelSourceRuntime"];byok: components["schemas"]["ByokInput"];};- /** @description Outcome of probing an upstream BYOK endpoint from the Local Computer. */+ /** @description Outcome of one request to an upstream BYOK endpoint from the Local Computer. */ByokTestResult: {ok: boolean;protocol: components["schemas"]["ByokProtocol"];- /** @description The address that answered, which can add or drop the /anthropic of a gateway that serves OpenAI under /v1 and Anthropic under /anthropic. */- base_url: string;+ /** @description The address the request went to. */+ url: string;model_id: string;context_window: number;};diff --git a/contracts/generated/typescript/src/generated/runner-gateway/schema.ts b/contracts/generated/typescript/src/generated/runner-gateway/schema.tsindex 6266fd95..e0c9dfbe 100644--- a/contracts/generated/typescript/src/generated/runner-gateway/schema.ts+++ b/contracts/generated/typescript/src/generated/runner-gateway/schema.ts@@ -204,7 +204,7 @@ export const runnerGatewayEnvelopeSchema = {ServiceFeature: {description:"An optional Runner behavior the Agent Service accepts. An older service rejects its frames as a protocol violation.",- enum: ["local_models"],+ enum: ["local_models", "byok_endpoint"],},Timestamp: {type: "string",@@ -1699,18 +1699,37 @@ export const runnerGatewayEnvelopeSchema = {},],},+ ByokUrlPath: {+ description:+ "A path appended to a BYOK base URL: empty, or whole segments each led by one slash.",+ type: "string",+ maxLength: 256,+ pattern: "^(/[^/?#\\s\\\\]+)*$",+ },+ ByokProtocol: {+ enum: ["openai-chat", "openai-responses", "anthropic"],+ },ByokConfigInput: {description:- "A BYOK endpoint; model_id is required except to list the endpoint's models.",+ "A BYOK endpoint: requests go to base_url + path + endpoint in protocol, and models are listed at base_url + path + /models. model_id is required except to list the endpoint's models.",type: "object",additionalProperties: false,- required: ["base_url"],+ required: ["base_url", "path", "endpoint", "protocol"],properties: {base_url: {type: "string",minLength: 1,maxLength: 2048,},+ path: {+ $ref: "#/$defs/ByokUrlPath",+ },+ endpoint: {+ $ref: "#/$defs/ByokUrlPath",+ },+ protocol: {+ $ref: "#/$defs/ByokProtocol",+ },api_key: {type: "string",maxLength: 4096,@@ -1731,6 +1750,8 @@ export const runnerGatewayEnvelopeSchema = {},},ByokSummary: {+ description:+ "path and endpoint are sent only to an Agent Service that declares byok_endpoint, and are omitted when empty: a configured summary without them appends nothing there.",type: "object",additionalProperties: false,required: ["configured", "key_saved"],@@ -1739,12 +1760,18 @@ export const runnerGatewayEnvelopeSchema = {type: "boolean",},protocol: {- enum: ["openai-chat", "openai-responses", "anthropic"],+ $ref: "#/$defs/ByokProtocol",},base_url: {type: "string",maxLength: 2048,},+ path: {+ $ref: "#/$defs/ByokUrlPath",+ },+ endpoint: {+ $ref: "#/$defs/ByokUrlPath",+ },model_id: {type: "string",maxLength: 256,@@ -1793,9 +1820,9 @@ export const runnerGatewayEnvelopeSchema = {ByokModelList: {type: "object",additionalProperties: false,- required: ["base_url", "models"],+ required: ["url", "models"],properties: {- base_url: {+ url: {type: "string",minLength: 1,maxLength: 2048,@@ -1830,15 +1857,15 @@ export const runnerGatewayEnvelopeSchema = {ByokTestResult: {type: "object",additionalProperties: false,- required: ["ok", "protocol", "base_url", "model_id", "context_window"],+ required: ["ok", "protocol", "url", "model_id", "context_window"],properties: {ok: {type: "boolean",},protocol: {- enum: ["openai-chat", "openai-responses", "anthropic"],+ $ref: "#/$defs/ByokProtocol",},- base_url: {+ url: {type: "string",minLength: 1,maxLength: 2048,diff --git a/contracts/generated/typescript/src/generated/runner-gateway/types.ts b/contracts/generated/typescript/src/generated/runner-gateway/types.tsindex cfd2d1e5..cfbf80f4 100644--- a/contracts/generated/typescript/src/generated/runner-gateway/types.ts+++ b/contracts/generated/typescript/src/generated/runner-gateway/types.ts@@ -32,7 +32,7 @@ export type PositiveInteger = number;/*** An optional Runner behavior the Agent Service accepts. An older service rejects its frames as a protocol violation.*/-export type ServiceFeature = "local_models";+export type ServiceFeature = "local_models" | "byok_endpoint";export type JsonValue =| null| boolean@@ -124,6 +124,11 @@ export type CapabilityModelSource = LocalSkillCommandIdentity & {local_model_id?: LocalModelId;byok?: ByokConfigInput;};+/**+ * A path appended to a BYOK base URL: empty, or whole segments each led by one slash.+ */+export type ByokUrlPath = string;+export type ByokProtocol = "openai-chat" | "openai-responses" | "anthropic";export type OperationPrepare = OperationIdentity & {type: "prepare";command_id: Id;@@ -934,10 +939,13 @@ export interface LocalSkillCommandIdentity {expires_at: Timestamp;}/**- * A BYOK endpoint; model_id is required except to list the endpoint's models.+ * A BYOK endpoint: requests go to base_url + path + endpoint in protocol, and models are listed at base_url + path + /models. model_id is required except to list the endpoint's models.*/export interface ByokConfigInput {base_url: string;+ path: ByokUrlPath;+ endpoint: ByokUrlPath;+ protocol: ByokProtocol;api_key?: string;model_id?: string;context_window?: number;@@ -1908,23 +1916,28 @@ export interface ModelSourceStatus {gateway_url?: string;byok: ByokSummary;}+/**+ * path and endpoint are sent only to an Agent Service that declares byok_endpoint, and are omitted when empty: a configured summary without them appends nothing there.+ */export interface ByokSummary {configured: boolean;- protocol?: "openai-chat" | "openai-responses" | "anthropic";+ protocol?: ByokProtocol;base_url?: string;+ path?: ByokUrlPath;+ endpoint?: ByokUrlPath;model_id?: string;context_window?: number;key_saved: boolean;}export interface ByokTestResult {ok: boolean;- protocol: "openai-chat" | "openai-responses" | "anthropic";- base_url: string;+ protocol: ByokProtocol;+ url: string;model_id: string;context_window: number;}export interface ByokModelList {- base_url: string;+ url: string;/*** @maxItems 1000*/diff --git a/contracts/generated/typescript/src/generated/teamhub-public/types.ts b/contracts/generated/typescript/src/generated/teamhub-public/types.tsindex 14e519f1..7328f60e 100644--- a/contracts/generated/typescript/src/generated/teamhub-public/types.ts+++ b/contracts/generated/typescript/src/generated/teamhub-public/types.ts@@ -4869,15 +4869,19 @@ export interface components {*/ModelSourceRuntime: "claude" | "codex" | "pi";/**- * @description Wire format the Computer found a BYOK upstream endpoint answers, trying the active Runtime's own format first.+ * @description Wire format of a BYOK upstream endpoint. The owner's client derives it from the end of the request address, else from the Runtime's own format; the Computer does not probe for it.* @enum {string}*/ByokProtocol: "openai-chat" | "openai-responses" | "anthropic";- /** @description Redacted BYOK configuration metadata reported by the Computer. */+ /** @description A path appended to a BYOK base URL: empty, or whole segments each led by one slash, so it can only extend the base URL's path. */+ ByokUrlPath: string;+ /** @description Redacted BYOK configuration metadata reported by the Computer. path and endpoint are omitted when empty: a configured summary without them appends nothing there. */ByokSummary: {configured: boolean;protocol?: components["schemas"]["ByokProtocol"];base_url?: string;+ path?: components["schemas"]["ByokUrlPath"];+ endpoint?: components["schemas"]["ByokUrlPath"];model_id?: string;context_window?: number;key_saved: boolean;@@ -4915,7 +4919,7 @@ export interface components {| "LOCAL_MODEL_UNKNOWN"| "BYOK_INVALID_CONFIG"| "BYOK_AUTH_FAILED"- | "BYOK_MODEL_NOT_FOUND"+ | "BYOK_NOT_FOUND"| "BYOK_UNREACHABLE"| "BYOK_UPSTREAM_REJECTED"| "MODEL_SOURCE_FAILED"@@ -4932,9 +4936,12 @@ export interface components {ModelSourceErrorResponse: {error: components["schemas"]["ModelSourceError"];};- /** @description Upstream endpoint configuration supplied by the Computer owner. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file. */+ /** @description Upstream endpoint configuration supplied by the Computer owner. Requests go to base_url + path + endpoint in protocol, and models are listed at base_url + path + /models. The API key is never persisted in TeamHub or Agent Service; only the Local Computer stores it in a private 0600 file. */ByokInput: {base_url: string;+ path: components["schemas"]["ByokUrlPath"];+ endpoint: components["schemas"]["ByokUrlPath"];+ protocol: components["schemas"]["ByokProtocol"];api_key?: string;model_id: string;context_window?: number;@@ -4949,9 +4956,12 @@ export interface components {/** @description True ends running work on the Computer's Agents; absent means false. */force_terminate?: boolean;};- /** @description A BYOK endpoint address and key, enough to list its models. The API key is never persisted in TeamHub or Agent Service. */+ /** @description A BYOK endpoint address and key, enough to list its models at base_url + path + /models with protocol's key header. The API key is never persisted in TeamHub or Agent Service. */ByokEndpointInput: {base_url: string;+ path: components["schemas"]["ByokUrlPath"];+ endpoint: components["schemas"]["ByokUrlPath"];+ protocol: components["schemas"]["ByokProtocol"];api_key?: string;reuse_saved_key?: boolean;};@@ -4965,20 +4975,19 @@ export interface components {/** @description The models a BYOK endpoint lists, sorted by id. */ByokModelList: {/** @description The address that listed them. */- base_url: string;+ url: string;models: components["schemas"]["ByokModel"][];};- /** @description A BYOK endpoint to verify from the Computer for the Runtime that would serve it, which decides the order wire formats are tried. */+ /** @description A BYOK endpoint to verify with one request from the Computer. */ByokTestRequest: {- runtime: components["schemas"]["ModelSourceRuntime"];byok: components["schemas"]["ByokInput"];};- /** @description Outcome of probing an upstream BYOK endpoint from the Local Computer. */+ /** @description Outcome of one request to an upstream BYOK endpoint from the Local Computer. */ByokTestResult: {ok: boolean;protocol: components["schemas"]["ByokProtocol"];- /** @description The address that answered, which can add or drop the /anthropic of a gateway that serves OpenAI under /v1 and Anthropic under /anthropic. */- base_url: string;+ /** @description The address the request went to. */+ url: string;model_id: string;context_window: number;};diff --git a/contracts/openapi/components/model-source.yaml b/contracts/openapi/components/model-source.yamlindex cba5d362..0afcc1ce 100644--- a/contracts/openapi/components/model-source.yaml+++ b/contracts/openapi/components/model-source.yaml@@ -11,8 +11,9 @@ components:schemas:ByokProtocol:description: >-- Wire format the Computer found a BYOK upstream endpoint answers, trying- the active Runtime's own format first.+ Wire format of a BYOK upstream endpoint. The owner's client derives it+ from the end of the request address, else from the Runtime's own+ format; the Computer does not probe for it.type: stringenum: [openai-chat, openai-responses, anthropic]x-enum-varnames:@@ -37,19 +38,34 @@ components:ModelSourceRuntimeCodex,ModelSourceRuntimePi,]+ ByokUrlPath:+ description: >-+ A path appended to a BYOK base URL: empty, or whole segments each led+ by one slash, so it can only extend the base URL's path.+ type: string+ maxLength: 256+ pattern: '^(/[^/?#\s\\]+)*$'ByokInput:description: >-- Upstream endpoint configuration supplied by the Computer owner. The API- key is never persisted in TeamHub or Agent Service; only the Local- Computer stores it in a private 0600 file.+ Upstream endpoint configuration supplied by the Computer owner.+ Requests go to base_url + path + endpoint in protocol, and models are+ listed at base_url + path + /models. The API key is never persisted in+ TeamHub or Agent Service; only the Local Computer stores it in a+ private 0600 file.type: objectadditionalProperties: false- required: [base_url, model_id]+ required: [base_url, path, endpoint, protocol, model_id]properties:base_url:type: stringminLength: 1maxLength: 2048+ path:+ $ref: "#/components/schemas/ByokUrlPath"+ endpoint:+ $ref: "#/components/schemas/ByokUrlPath"+ protocol:+ $ref: "#/components/schemas/ByokProtocol"api_key:type: stringwriteOnly: true@@ -66,16 +82,23 @@ components:type: booleanByokEndpointInput:description: >-- A BYOK endpoint address and key, enough to list its models. The API- key is never persisted in TeamHub or Agent Service.+ A BYOK endpoint address and key, enough to list its models at+ base_url + path + /models with protocol's key header. The API key is+ never persisted in TeamHub or Agent Service.type: objectadditionalProperties: false- required: [base_url]+ required: [base_url, path, endpoint, protocol]properties:base_url:type: stringminLength: 1maxLength: 2048+ path:+ $ref: "#/components/schemas/ByokUrlPath"+ endpoint:+ $ref: "#/components/schemas/ByokUrlPath"+ protocol:+ $ref: "#/components/schemas/ByokProtocol"api_key:type: stringwriteOnly: true@@ -104,9 +127,9 @@ components:description: The models a BYOK endpoint lists, sorted by id.type: objectadditionalProperties: false- required: [base_url, models]+ required: [url, models]properties:- base_url:+ url:description: The address that listed them.type: stringminLength: 1@@ -117,19 +140,18 @@ components:items:$ref: "#/components/schemas/ByokModel"ByokTestRequest:- description: >-- A BYOK endpoint to verify from the Computer for the Runtime that would- serve it, which decides the order wire formats are tried.+ description: A BYOK endpoint to verify with one request from the Computer.type: objectadditionalProperties: false- required: [runtime, byok]+ required: [byok]properties:- runtime:- $ref: "#/components/schemas/ModelSourceRuntime"byok:$ref: "#/components/schemas/ByokInput"ByokSummary:- description: Redacted BYOK configuration metadata reported by the Computer.+ description: >-+ Redacted BYOK configuration metadata reported by the Computer. path and+ endpoint are omitted when empty: a configured summary without them+ appends nothing there.type: objectadditionalProperties: falserequired: [configured, key_saved]@@ -141,6 +163,10 @@ components:base_url:type: stringmaxLength: 2048+ path:+ $ref: "#/components/schemas/ByokUrlPath"+ endpoint:+ $ref: "#/components/schemas/ByokUrlPath"model_id:type: stringmaxLength: 256@@ -175,20 +201,17 @@ components:byok:$ref: "#/components/schemas/ByokSummary"ByokTestResult:- description: Outcome of probing an upstream BYOK endpoint from the Local Computer.+ description: Outcome of one request to an upstream BYOK endpoint from the Local Computer.type: objectadditionalProperties: false- required: [ok, protocol, base_url, model_id, context_window]+ required: [ok, protocol, url, model_id, context_window]properties:ok:type: booleanprotocol:$ref: "#/components/schemas/ByokProtocol"- base_url:- description: >-- The address that answered, which can add or drop the /anthropic of- a gateway that serves OpenAI under /v1 and Anthropic under- /anthropic.+ url:+ description: The address the request went to.type: stringminLength: 1maxLength: 2048@@ -283,7 +306,7 @@ components:- LOCAL_MODEL_UNKNOWN- BYOK_INVALID_CONFIG- BYOK_AUTH_FAILED- - BYOK_MODEL_NOT_FOUND+ - BYOK_NOT_FOUND- BYOK_UNREACHABLE- BYOK_UPSTREAM_REJECTED- MODEL_SOURCE_FAILED@@ -299,7 +322,7 @@ components:- ModelSourceErrorCodeLocalModelUnknown- ModelSourceErrorCodeByokInvalidConfig- ModelSourceErrorCodeByokAuthFailed- - ModelSourceErrorCodeByokModelNotFound+ - ModelSourceErrorCodeByokNotFound- ModelSourceErrorCodeByokUnreachable- ModelSourceErrorCodeByokUpstreamRejected- ModelSourceErrorCodeModelSourceFaileddiff --git a/contracts/openapi/linger-installer/openapi.yaml b/contracts/openapi/linger-installer/openapi.yamlindex 3da67e92..e0bffdb0 100644--- a/contracts/openapi/linger-installer/openapi.yaml+++ b/contracts/openapi/linger-installer/openapi.yaml@@ -408,6 +408,25 @@ paths:$ref: "#/components/schemas/ByokCheckReport""400": *a2"401": *a3+ /api/byok/models:+ post:+ operationId: listInstallerByokModels+ summary: List the models a BYOK upstream endpoint serves via localmodels+ requestBody:+ required: true+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ByokEndpoint"+ responses:+ "200":+ description: The endpoint's models, sorted by id+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ByokModelReport"+ "400": *a2+ "401": *a3/api/runtime-login:get:operationId: inspectInstallerRuntimeLogin@@ -655,17 +674,57 @@ components:type: arrayitems:$ref: "#/components/schemas/CheckResult"+ ByokUrlPath:+ description: Empty, or whole path segments each led by one slash, appended to baseUrl.+ type: string+ maxLength: 256+ pattern: '^(/[^/?#\s\\]+)*$'+ ByokProtocol:+ type: string+ enum: [openai-chat, openai-responses, anthropic]+ ByokEndpoint:+ description: Requests go to baseUrl + path + endpoint in protocol; models are listed at baseUrl + path + /models.+ type: object+ additionalProperties: false+ required:+ - baseUrl+ - path+ - endpoint+ - protocol+ properties:+ baseUrl:+ type: string+ minLength: 1+ maxLength: 2048+ path:+ $ref: "#/components/schemas/ByokUrlPath"+ endpoint:+ $ref: "#/components/schemas/ByokUrlPath"+ protocol:+ $ref: "#/components/schemas/ByokProtocol"+ apiKey:+ type: string+ maxLength: 4096ByokConfiguration:type: objectadditionalProperties: falserequired:- baseUrl+ - path+ - endpoint+ - protocol- modelIdproperties:baseUrl:type: stringminLength: 1maxLength: 2048+ path:+ $ref: "#/components/schemas/ByokUrlPath"+ endpoint:+ $ref: "#/components/schemas/ByokUrlPath"+ protocol:+ $ref: "#/components/schemas/ByokProtocol"apiKey:type: stringmaxLength: 4096@@ -677,25 +736,51 @@ components:type: integerminimum: 1maximum: 2147483647- runtime:+ ByokModelReport:+ type: object+ additionalProperties: false+ required:+ - url+ - models+ properties:+ url:type: string- enum: [claude, codex, pi]+ minLength: 1+ models:+ type: array+ maxItems: 1000+ items:+ type: object+ additionalProperties: false+ required:+ - id+ properties:+ id:+ type: string+ minLength: 1+ maxLength: 256+ name:+ type: string+ maxLength: 256+ contextWindow:+ type: integer+ minimum: 1+ maximum: 2147483647ByokCheckReport:type: objectadditionalProperties: falserequired:- ok- protocol- - baseUrl+ - url- modelId- contextWindowproperties:ok:type: booleanprotocol:- type: string- enum: [openai-chat, openai-responses, anthropic]- baseUrl: *a1+ $ref: "#/components/schemas/ByokProtocol"+ url: *a1modelId: *a1contextWindow:type: integerdiff --git a/contracts/runner-gateway/asyncapi.yaml b/contracts/runner-gateway/asyncapi.yamlindex a45d0fa5..1cfa369f 100644--- a/contracts/runner-gateway/asyncapi.yaml+++ b/contracts/runner-gateway/asyncapi.yaml@@ -66,6 +66,12 @@ info:which the Computer sends after a runner.welcome whose service_featuresnames local_models, after every library change, and at most every 2seconds while a download or load runs.+ execute with kind model_source reads or switches the Computer's model+ source. A BYOK input names its address as base_url, path and endpoint+ with an explicit protocol, and the Computer sends one request there; the+ service sends a BYOK input only to a Computer release that decodes it.+ The Computer's BYOK summary carries path and endpoint only after a+ runner.welcome whose service_features names byok_endpoint.x-frame-limits:maxBytes: 4194304maxDepth: 32diff --git a/contracts/runner-gateway/envelope.schema.json b/contracts/runner-gateway/envelope.schema.jsonindex d4330a76..2ac8bf9b 100644--- a/contracts/runner-gateway/envelope.schema.json+++ b/contracts/runner-gateway/envelope.schema.json@@ -201,7 +201,7 @@},"ServiceFeature": {"description": "An optional Runner behavior the Agent Service accepts. An older service rejects its frames as a protocol violation.",- "enum": ["local_models"]+ "enum": ["local_models", "byok_endpoint"]},"Timestamp": {"type": "string",@@ -1689,17 +1689,35 @@}]},+ "ByokUrlPath": {+ "description": "A path appended to a BYOK base URL: empty, or whole segments each led by one slash.",+ "type": "string",+ "maxLength": 256,+ "pattern": "^(/[^/?#\\s\\\\]+)*$"+ },+ "ByokProtocol": {+ "enum": ["openai-chat", "openai-responses", "anthropic"]+ },"ByokConfigInput": {- "description": "A BYOK endpoint; model_id is required except to list the endpoint's models.",+ "description": "A BYOK endpoint: requests go to base_url + path + endpoint in protocol, and models are listed at base_url + path + /models. model_id is required except to list the endpoint's models.","type": "object","additionalProperties": false,- "required": ["base_url"],+ "required": ["base_url", "path", "endpoint", "protocol"],"properties": {"base_url": {"type": "string","minLength": 1,"maxLength": 2048},+ "path": {+ "$ref": "#/$defs/ByokUrlPath"+ },+ "endpoint": {+ "$ref": "#/$defs/ByokUrlPath"+ },+ "protocol": {+ "$ref": "#/$defs/ByokProtocol"+ },"api_key": {"type": "string","maxLength": 4096@@ -1720,6 +1738,7 @@}},"ByokSummary": {+ "description": "path and endpoint are sent only to an Agent Service that declares byok_endpoint, and are omitted when empty: a configured summary without them appends nothing there.","type": "object","additionalProperties": false,"required": ["configured", "key_saved"],@@ -1728,12 +1747,18 @@"type": "boolean"},"protocol": {- "enum": ["openai-chat", "openai-responses", "anthropic"]+ "$ref": "#/$defs/ByokProtocol"},"base_url": {"type": "string","maxLength": 2048},+ "path": {+ "$ref": "#/$defs/ByokUrlPath"+ },+ "endpoint": {+ "$ref": "#/$defs/ByokUrlPath"+ },"model_id": {"type": "string","maxLength": 256@@ -1780,9 +1805,9 @@"ByokModelList": {"type": "object","additionalProperties": false,- "required": ["base_url", "models"],+ "required": ["url", "models"],"properties": {- "base_url": {+ "url": {"type": "string","minLength": 1,"maxLength": 2048@@ -1817,15 +1842,15 @@"ByokTestResult": {"type": "object","additionalProperties": false,- "required": ["ok", "protocol", "base_url", "model_id", "context_window"],+ "required": ["ok", "protocol", "url", "model_id", "context_window"],"properties": {"ok": {"type": "boolean"},"protocol": {- "enum": ["openai-chat", "openai-responses", "anthropic"]+ "$ref": "#/$defs/ByokProtocol"},- "base_url": {+ "url": {"type": "string","minLength": 1,"maxLength": 2048