Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344package daemon
import ( "context" "net/http")
// The daemon alone reads and writes creds.json. A client changes a profile's// api key or an MCP server's secrets through these routes and only ever learns// which secrets are saved, never what they are.
// Credentials names the saved secrets.type Credentials struct { MCP map[string]MCPSecretNames `json:"mcp"` // Providers are the profiles with a saved api key. Providers []string `json:"providers"`}
// MCPSecretNames is what an MCP server has saved, by name only.type MCPSecretNames struct { Headers []string `json:"headers"` Env []string `json:"env"` BearerToken bool `json:"bearerToken"`}
// Any reports whether the server has any secret saved.func (n MCPSecretNames) Any() bool { return n.BearerToken || len(n.Headers) > 0 || len(n.Env) > 0}
// MCPSecretsPatch changes an MCP server's secrets field by field: a field left// out keeps its value and a nil one removes it. "headers" and "env" map a name// to its new value, or to nil to remove that one.type MCPSecretsPatch map[string]any
// TakeMigration names the files the daemon's start moved secrets out of, only// to the first client that asks, so the user hears about it once.func TakeMigration(ctx context.Context, conn *Connection) ([]string, error) { taken, err := RequestMethod[struct { Moved []string `json:"moved"` }](ctx, conn, http.MethodPost, "/auth/credentials/migration", map[string]string{}) return taken.Moved, err}