Files
story/cmd/elder-agent/main.go
T
Codex Local bf1233d5df
ci / verify (push) Canceled after 0s
feat: expand companion platform, device controls, and memoir workflows
Add customer and operator login, BLE provisioning, device fleet controls, call memory, memoir generation, and refreshed family and maintenance portals. Include API contracts, migrations, firmware sources, tests, assets, and deployment documentation.
2026-10-08 10:06:44 +08:00

48 lines
1.3 KiB
Go

// Backfill an existing elder using the same provisioner as POST /subjects.
package main
import (
"context"
"flag"
"fmt"
"os"
"data-terminal-cloud/internal/config"
"data-terminal-cloud/internal/database"
"data-terminal-cloud/internal/elderagent"
)
func main() {
subject := flag.String("subject", "", "existing elder public ID")
flag.Parse()
if *subject == "" {
fmt.Fprintln(os.Stderr, "--subject is required")
os.Exit(2)
}
cfg, err := config.Load("api")
if err != nil {
panic(err)
}
ctx := context.Background()
p, err := database.Open(ctx, cfg.DatabaseURL, "elder-agent")
if err != nil {
panic(err)
}
defer p.Close()
path := os.Getenv("DIRECT_CHAT_TEMPLATE_FILE")
if path == "" {
path = cfg.VolcVoiceChatTemplate
}
template, err := os.ReadFile(path)
if err != nil {
panic(err)
}
s := elderagent.Service{Pool: p, Provider: elderagent.NewClient(cfg.VolcAccessKeyID, cfg.VolcSecretAccessKey, cfg.VolcSessionToken, cfg.VolcRTCBaseURL, cfg.VolcRTCRegion).ForProduct(cfg.VolcHardwareInstanceID, cfg.VolcHardwareProductKey), Template: template, CallbackURL: cfg.SubtitleCallbackURL, CallbackSecret: []byte(cfg.SubtitleCallbackSecret)}
info, err := s.Ensure(ctx, *subject)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Printf("subject=%s bot_id=%s status=%s\n", *subject, info.BotID, info.Status)
}