Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions demos/agent-secret/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ func main() {
}

func handleRequest(w http.ResponseWriter, r *http.Request) {
log.Printf("DEBUG: Request received. Path=%s Host=%s", r.URL.Path, r.Host)

// 1. Identify Actor (Robust extraction)
// New architecture uses Host: <actor-id>.actors.resources.substrate.k8s.io
// 1. Identify Actor
// Host: <actor-id>.actors.resources.substrate.ate.dev
actorID := r.Header.Get("X-AgentSet-Session")
if actorID == "" {
actorID = r.Header.Get("x-agentset-session")
Expand All @@ -70,7 +68,7 @@ func handleRequest(w http.ResponseWriter, r *http.Request) {
if host == "" {
host = r.Header.Get("Host")
}
// Extract prefix from <id>.actors.resources.substrate.k8s.io
// Extract prefix from <id>.actors.resources.substrate.ate.dev
parts := strings.Split(host, ".")
if len(parts) > 1 {
actorID = parts[0]
Expand All @@ -81,23 +79,15 @@ func handleRequest(w http.ResponseWriter, r *http.Request) {
actorID = "unknown"
}

log.Printf("DEBUG: Identified ActorID: [%s]", actorID)

body, _ := io.ReadAll(r.Body)
message := string(body)
if message == "" {
message = "Status Check"
}

// 1. Respond to user
// 2. Respond
var sb strings.Builder
sb.WriteString(fmt.Sprintf("Agent Response: [%s] | Identity: %s | Session: %s\n", message, residentSecret, actorID))
if actorID == "" {
sb.WriteString("DEBUG: ID Missing. Headers received:\n")
for k, v := range r.Header {
sb.WriteString(fmt.Sprintf(" %s: %v\n", k, v))
}
}
response := sb.String()
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
Expand Down
Loading