fix(ui): update AMCS references and add status handling
* Corrected "Advanced Module Control System" to "Avalon Memory Control Service" in documentation and UI components. * Added status handling to the LoginInfoPanel and LoginPage components. * Implemented new endpoints for robots.txt and llms.txt.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
amcsllm "git.warky.dev/wdevs/amcs/llm"
|
||||
)
|
||||
@@ -20,3 +22,74 @@ func serveLLMInstructions(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
_, _ = w.Write(amcsllm.MemoryInstructions)
|
||||
}
|
||||
|
||||
func serveRobotsTXT(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/robots.txt" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if r.Method != http.MethodGet && r.Method != http.MethodHead {
|
||||
w.Header().Set("Allow", "GET, HEAD")
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
w.Header().Set("Cache-Control", "public, max-age=300")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if r.Method == http.MethodHead {
|
||||
return
|
||||
}
|
||||
|
||||
body := fmt.Sprintf("User-agent: *\nAllow: /\n\n# LLM-friendly docs\nLLM: %s/llm\nLLMS: %s/llms.txt\n", requestBaseURL(r), requestBaseURL(r))
|
||||
_, _ = w.Write([]byte(body))
|
||||
}
|
||||
|
||||
func serveLLMSTXT(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/llms.txt" && r.URL.Path != "/.well-known/llms.txt" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if r.Method != http.MethodGet && r.Method != http.MethodHead {
|
||||
w.Header().Set("Allow", "GET, HEAD")
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
w.Header().Set("Cache-Control", "public, max-age=300")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if r.Method == http.MethodHead {
|
||||
return
|
||||
}
|
||||
|
||||
base := requestBaseURL(r)
|
||||
body := fmt.Sprintf(
|
||||
"# AMCS\n\n> A memory server for AI assistants (MCP tools, semantic retrieval, and structured project memory).\n\n## Endpoints\n- %s/llm\n- %s/status\n- %s/mcp\n- %s/.well-known/oauth-authorization-server\n",
|
||||
base,
|
||||
base,
|
||||
base,
|
||||
base,
|
||||
)
|
||||
_, _ = w.Write([]byte(body))
|
||||
}
|
||||
|
||||
func requestBaseURL(r *http.Request) string {
|
||||
scheme := "http"
|
||||
if r != nil && r.TLS != nil {
|
||||
scheme = "https"
|
||||
}
|
||||
if r != nil {
|
||||
if proto := strings.TrimSpace(r.Header.Get("X-Forwarded-Proto")); proto != "" {
|
||||
scheme = proto
|
||||
}
|
||||
}
|
||||
|
||||
host := "localhost"
|
||||
if r != nil {
|
||||
if v := strings.TrimSpace(r.Host); v != "" {
|
||||
host = v
|
||||
}
|
||||
}
|
||||
return scheme + "://" + host
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user