telegram: add /whoami, /profile, /sessions, /resume, /agents commands
Gateway-local commands that report from Archie-owned state: - /whoami: reports the Archie identity the user is talking to - /profile: shows active Archie profile (identity, provider, model, available models) - /sessions: lists recent sessions with last-active timestamps - /resume [id]: resumes a session by ID or prefix match - /agents: lists active agents and running/waiting tasks Adds SessionLister and AgentReader interfaces to Router, wired from the daemon composition root. SessionStore already satisfies SessionLister. AgentReader is a thin adapter over store.Task list filtered to active states (running, waiting_human, parked). All commands are published in Telegram's menu and /help, and respond with 'not configured' when their backing interface is nil. Closes archie-core-alm.2
This commit is contained in:
1 parent
d92ac87c25
commit
03a200d582
6 files changed
+546
-5
No files matched your search
@@ -14,6 +14,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
@@ -501,6 +502,8 @@ func run() int {
|
||||
router := gateway.NewRouter(st, llmResponder, "telegram")
|
||||
router.LLMStream = llmStream
|
||||
router.Models = chatModels
|
||||
router.Sessions = sessionStore
|
||||
router.Agents = agentReaderAdapter{tasks: st.Tasks}
|
||||
configureTaskCommands(router, chatTasks, chatController, defaultChatIdentity)
|
||||
startGateways = append(startGateways, func() {
|
||||
go func() {
|
||||
@@ -792,6 +795,40 @@ func run() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// agentReaderAdapter implements gateway.AgentReader from the store's Task list.
|
||||
type agentReaderAdapter struct {
|
||||
tasks func(ctx context.Context, limit int) ([]store.Task, error)
|
||||
}
|
||||
|
||||
func (a agentReaderAdapter) AgentList(ctx context.Context) ([]gateway.AgentInfo, error) {
|
||||
all, err := a.tasks(ctx, -1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Show tasks that are actively running or waiting for human input.
|
||||
active := []string{
|
||||
store.StatusRunning,
|
||||
store.StatusWaitingHuman,
|
||||
store.StatusParked,
|
||||
}
|
||||
isActive := func(status string) bool {
|
||||
return slices.Contains(active, status)
|
||||
}
|
||||
out := make([]gateway.AgentInfo, 0, len(all))
|
||||
for _, t := range all {
|
||||
if !isActive(t.Status) {
|
||||
continue
|
||||
}
|
||||
out = append(out, gateway.AgentInfo{
|
||||
ID: t.ID,
|
||||
Title: t.Title,
|
||||
Status: t.Status,
|
||||
Identity: t.Identity,
|
||||
})
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
type chatTaskWriterAdapter struct {
|
||||
enqueue func(
|
||||
ctx context.Context,
|
||||
|
||||
Reference in new issue
Block a user