feat: add OpenAI-compatible local endpoint backend#770
Merged
Conversation
Collaborator
Author
Collaborator
Author
Comment on lines
+143
to
+147
| // A single-label DNS name is not proof of LAN scope: DNS may resolve it publicly. | ||
| if host.hasSuffix(".local") || host.hasPrefix("fc") || host.hasPrefix("fd") | ||
| || (host.hasPrefix("fe") && (host.dropFirst(2).first.map { "89ab".contains($0) } ?? false)) { | ||
| return .localNetwork | ||
| } |
Contributor
There was a problem hiding this comment.
This branch applies IPv6 local-prefix checks before proving the host is an IPv6 literal. A valid DNS name such as http://feast:11434/v1 is classified as local network because it starts with fea, so the public HTTP rejection does not run. If that name resolves outside the local network, typed text and enabled context are sent over plaintext HTTP while the UI treats the endpoint as local.
Suggested change
| // A single-label DNS name is not proof of LAN scope: DNS may resolve it publicly. | |
| if host.hasSuffix(".local") || host.hasPrefix("fc") || host.hasPrefix("fd") | |
| || (host.hasPrefix("fe") && (host.dropFirst(2).first.map { "89ab".contains($0) } ?? false)) { | |
| return .localNetwork | |
| } | |
| // A single-label DNS name is not proof of LAN scope: DNS may resolve it publicly. | |
| if host.hasSuffix(".local") { | |
| return .localNetwork | |
| } | |
| if host.contains(":"), host.hasPrefix("fc") || host.hasPrefix("fd") | |
| || (host.hasPrefix("fe") && (host.dropFirst(2).first.map { "89ab".contains($0) } ?? false)) { | |
| return .localNetwork | |
| } |
FuJacob
approved these changes
Jul 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Local Endpoint as a third suggestion engine for OpenAI-compatible servers such as Ollama, LM Studio, and vLLM. The integration keeps generation local-first while providing model discovery, streamed completions, Keychain-backed authentication, privacy warnings, and lifecycle handling that unloads the bundled llama runtime when an external endpoint is active.
Validation
xcodegen generate— completed successfullyxcodebuild ... build-for-testingwith repo-localbuild/DerivedData— passedtest-without-building— passedhttp://127.0.0.1:11434/v1: discovered and selectedgemma4:12b-mlx, streamed Chat Completions without an API key, and confirmed the in-process llama runtime shut downplutil -lint CotabbyInfo.plist— passedgit diff --check— passedLinked issues
Fixes #627
Risk / rollout notes
NSAllowsLocalNetworking; insecure public HTTP endpoints remain rejected.Greptile Summary
This PR adds a local OpenAI-compatible endpoint backend. The main changes are:
Confidence Score: 4/5
This is close, but the endpoint HTTP guard should be fixed before merging.
Cotabby/Models/OpenAICompatibleEndpointModels.swift
Security Review
The endpoint HTTP policy can still classify some DNS hostnames as local IPv6 addresses. This can allow plaintext HTTP to a host that resolves outside the local network.
Important Files Changed
Reviews (3): Last reviewed commit: "fix: invalidate stale endpoint connectio..." | Re-trigger Greptile