The dashboard's setup terminal was a 503: it had a WebSocket route, an authorizer and an xterm.js surface, but nothing owned a container. The daemon owns containers, so the session contract lands there and the dashboard consumes it over a new gRPC contract. One session concept, two targets. A setup session is addressed by Kit profile and is ephemeral; a run session (archie-core-qi91) is addressed by task and attempt and is bounded by the task. This slice serves setup and answers Unimplemented for run. The contract, the authorisation, the lifetime and the egress phase are settled in docs/prds/external-agent-harness.md, "Session contract". The short version: the daemon serves harness.v1.HarnessService; the dashboard authorizes the operator as an update on the secret and then dials the daemon with the harness service token, required even on loopback because a session is a shell holding an org's credential; the setup container runs no worker, mounts no worktree, holds a keepalive, and carries an empty container environment. Install hooks run at the install phase and the session enters runtime before the shell, so a runtime-phase credential's token endpoint is the one the proxy intercepts. Capture is gated by the egress proxy on a granted service, and a setup session has no task, so the daemon registers a session grant: the session's proxy token resolves to the org's bindings for the Kit's declared services. The real token never enters the container: the token endpoint response is sentinelized and stored as the org's harness secret. Every teardown path releases the pool slot, revokes the egress session and the grant, removes the sandbox network, and removes the session's volumes. The listener requires HARNESS_TOKEN and stops with a 10s grace before Stop, so an open session cannot hold shutdown to the watchdog leash.
67 lines
3.7 KiB
Go
67 lines
3.7 KiB
Go
// Command archie-ui serves the operator dashboard and the compiled SPA as its
|
|
// own process, against a Gateway and a State Store reached over their gRPC
|
|
// contracts. It is the .5.2 companion to archie-gateway and
|
|
// archie-state-store: a thin main that parses process inputs and hands them
|
|
// to archieui.Run.
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
"strconv"
|
|
"syscall"
|
|
|
|
"github.com/samcharles93/archie-core/internal/app/archieui"
|
|
"github.com/samcharles93/archie-core/internal/buildinfo"
|
|
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
|
)
|
|
|
|
func main() { os.Exit(run()) }
|
|
|
|
func run() int {
|
|
var options archieui.Options
|
|
showVersion := buildinfo.RegisterVersionFlag("archie-ui")
|
|
flag.StringVar(&options.Config, "config", configuration.DefaultConfigPath(), "configuration file or directory (only [services.*] targets and [web] are read)")
|
|
flag.StringVar(&options.Overlay, "config-overlay", "", "configuration overlay file or directory")
|
|
flag.StringVar(&options.Listen, "listen", "", "dashboard HTTP listen address (defaults to [web].listen, else 127.0.0.1:8484)")
|
|
flag.StringVar(&options.Token, "token", "", "dashboard token; required for a non-loopback listener")
|
|
flag.StringVar(&options.TokenFile, "token-file", "", "file holding the dashboard token, minted on first use")
|
|
flag.StringVar(&options.OidcIssuer, "oidc-issuer", "", "identity provider issuer URL; requests must then carry a token it signed")
|
|
flag.StringVar(&options.OidcAudience, "oidc-audience", "", "audience (resource identifier) this dashboard accepts tokens for; required with -oidc-issuer")
|
|
flag.StringVar(&options.OidcClientID, "oidc-client-id", "", "provider client id for browser sign-in; omitted means no sign-in flow")
|
|
flag.StringVar(&options.OidcClientSecretEnv, "oidc-client-secret-env", "", "name of the environment variable holding the sign-in client secret")
|
|
flag.StringVar(&options.OidcRedirectURL, "oidc-redirect-url", "", "callback URL registered at the provider (path must be /oauth2/callback)")
|
|
flag.StringVar(&options.Gateway.Target, "gateway-target", "", "archie-gateway gRPC address (defaults to [services.gateway].target)")
|
|
flag.StringVar(&options.Gateway.Token, "gateway-token", "", "bearer token presented to archie-gateway")
|
|
flag.StringVar(&options.State.Target, "state-target", "", "archie-state-store gRPC address (defaults to [services.state].target)")
|
|
flag.StringVar(&options.State.Token, "state-token", "", "bearer token presented to archie-state-store")
|
|
flag.StringVar(&options.Harness.Target, "harness-target", "", "archied harness session gRPC address (defaults to [services.harness].target); empty leaves the setup terminal unwired")
|
|
flag.StringVar(&options.Harness.Token, "harness-token", "", "bearer token presented to the daemon's harness contract")
|
|
flag.DurationVar(&options.DependencyTimeout, "dependency-timeout", 0, "per-dependency readiness probe timeout (default 5s)")
|
|
flag.DurationVar(&options.EventPollInterval, "event-poll-interval", 0, "how often the activity feed polls the State Store for new events (default 1s)")
|
|
// BoolFunc rather than BoolVar so an unset flag stays distinguishable
|
|
// from an explicit -trust-forwarded-headers=false, which must be able to
|
|
// override a configuration file that enables it.
|
|
flag.BoolFunc("trust-forwarded-headers", "trust X-Forwarded-Proto/Host when validating Origin (only behind a trusted proxy)", func(v string) error {
|
|
parsed, err := strconv.ParseBool(v)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
options.TrustForwardedHeaders = &parsed
|
|
return nil
|
|
})
|
|
flag.Parse()
|
|
showVersion()
|
|
|
|
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
|
defer stop()
|
|
if err := archieui.Run(ctx, options); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
return 1
|
|
}
|
|
return 0
|
|
}
|