Files
archie/internal/app/archied/daemon_rpc.go
T
sam f92c5b4536
ci/woodpecker/pr/quality Pipeline was successful
Quality / check (pull_request) Canceled after 7m39s
chore(runtime): delete Kit and external agent harness support (#1877)
Archie runs its own agent loop only. Removes Kit resolution and launch,
the harness runner and adapters, the setup terminal and sandbox view,
harness secrets and OAuth capture (table dropped in migration 0075), the
task-tools contract that only Kit containers reached, and the
sandbox-kit-spec dependency. Agent profiles carry image and tools only.
The egress proxy keeps the model-session path; the sandbox relay code
stays for #1867.
2026-11-12 21:29:05 +11:00

60 lines
2.0 KiB
Go

package archied
import (
"context"
"errors"
"net"
"time"
"google.golang.org/grpc"
"github.com/samcharles93/archie-core/internal/app/servicekit"
"github.com/samcharles93/archie-core/internal/config"
daemonpb "github.com/samcharles93/archie-core/internal/contracts/daemon/v1"
"github.com/samcharles93/archie-core/internal/domain/access"
"github.com/samcharles93/archie-core/internal/domain/presence"
"github.com/samcharles93/archie-core/internal/infrastructure/rpcidentity"
)
// setupDaemonRPC serves the daemon contract. Without certificates it binds
// only loopback.
func (b *boot) setupDaemonRPC(ctx context.Context) {
conn := b.cfg.Services.Get(config.ServiceNameDaemon)
listen, err := servicekit.ResolveListen(config.ServiceNameDaemon, "", conn.Listen)
if err != nil {
b.log.WarnContext(ctx, "daemon contract disabled", "err", err)
return
}
id, err := servicekit.Identity(b.cfg.TLS, presence.Daemon)
if err != nil {
b.log.WarnContext(ctx, "daemon contract disabled", "err", err)
return
}
creds, err := id.ServerOption(listen, false)
if err != nil {
b.log.WarnContext(ctx, "daemon contract disabled", "err", err)
return
}
ln, err := (&net.ListenConfig{}).Listen(ctx, "tcp", listen)
if err != nil {
b.log.WarnContext(ctx, "daemon contract disabled: listen", "err", err)
return
}
workspaces, _ := b.stateStore.(access.WorkspaceLister)
callers := rpcidentity.Callers{Principals: b.d.Principals, Workspaces: workspaces}
srv := grpc.NewServer(append(servicekit.ServerLimits(), creds, grpc.ChainUnaryInterceptor(callers.Unary()), grpc.ChainStreamInterceptor(callers.Stream()))...)
daemonpb.RegisterDaemonServiceServer(srv, &repositoryServer{boot: b})
go func() {
if err := srv.Serve(ln); err != nil && !errors.Is(err, grpc.ErrServerStopped) {
b.log.ErrorContext(ctx, "daemon contract listener stopped", "err", err)
}
}()
b.addCleanup(func() {
timer := time.AfterFunc(10*time.Second, srv.Stop)
srv.GracefulStop()
timer.Stop()
_ = ln.Close()
})
b.log.InfoContext(ctx, "daemon contract serving", "addr", ln.Addr().String())
}