refactor(telegram): keep one model selector command
This commit is contained in:
1 parent
2facb2be1b
commit
647537c00a
8 files changed
+29
-131
No files matched your search
@@ -150,3 +150,4 @@
|
||||
{"id":"int-6d6e840984054dec54aee42bb99042a5","kind":"field_change","created_at":"2026-07-26T19:29:37.633205149Z","actor":"Sam Catlow","issue_id":"archie-core-abg.17.43","extra":{"field":"status","new_value":"open","old_value":"in_progress"}}
|
||||
{"id":"int-e370a7bbd16c6f091d318dc5520481ef","kind":"field_change","created_at":"2026-07-26T19:29:37.633258328Z","actor":"Sam Catlow","issue_id":"archie-core-abg.17.43","extra":{"field":"assignee","new_value":"","old_value":"Sam Catlow"}}
|
||||
{"id":"int-98886b5c0eed086effa6684ec75bbb48","kind":"field_change","created_at":"2026-07-26T20:33:10.385698708Z","actor":"Sam Catlow","issue_id":"archie-core-3ro","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Shipped locally: Telegram calls the assistant Archie rather than Gateway; restart copy is Archie-facing; new sessions receive and preserve an Archie baseline identity; model selector shows provider in the header and provider-free model names; successful selections acknowledge the chosen model; model/provider callbacks use stable tokens so stale keyboards cannot select a different option. task check and lint pass; fresh review clean."}}
|
||||
{"id":"int-09fd2039fe043eb9110fa9bdb678b3e9","kind":"field_change","created_at":"2026-07-27T01:44:06.19963429Z","actor":"Sam Catlow","issue_id":"archie-core-n55","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Shipped locally: /models removed from Telegram menu, help, and Router; /model is the sole model selector/direct-switch command; /help menu text is now 'See what Archie can do'; command docs updated. task check passes and fresh review reports no findings."}}
|
||||
@@ -127,6 +127,7 @@
|
||||
{"_type":"issue","id":"archie-core-s1r","title":"Test forge fakes missing LinkBranch method broke go vet/test for whole module","description":"forge.Forge gained LinkBranch(ctx, owner, repo, issueNumber, branch) error in the branch-linking feature (ff4c51e) but the hand-rolled test doubles (stubForge in cmd/archied/main_test.go, prCapturingForge in cmd/archie-agent/taskrun_test.go, testForge in internal/daemon/daemon_test.go, fakeForge in internal/forgerpc/forgerpc_test.go) never got the method added, so they stopped satisfying forge.Forge. This broke go vet ./... and go test ./... for the entire module, not just those 4 packages, since go vet type-checks all test files as part of module vet. Fixed by adding LinkBranch stubs to all four fakes.","status":"closed","priority":1,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-07-24T03:04:53Z","created_by":"Sam Catlow","updated_at":"2026-07-24T03:04:58Z","closed_at":"2026-07-24T03:04:58Z","close_reason":"Added LinkBranch stub methods to stubForge, prCapturingForge, testForge, and fakeForge. go build/vet/test ./... now clean across the whole module.","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-633","title":"config.docker.toml missing required fields, no overlay merge implemented","description":"config.docker.toml was rewritten to be a docs-as-overlay file (comment says base+overlay merge) but internal/config.Load has no merge logic and docker-compose.yml mounts only config.docker.toml at /etc/archie/config.toml. It is missing bot_user, [forge], [dispatch], [models], [providers], [budgets] which Load requires -\u003e daemon fails to start in docker as currently configured. Implement real base+overlay config loading (or restore a full standalone docker config) so there is one source of truth.","status":"closed","priority":1,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-24T02:42:07Z","created_by":"Sam Catlow","updated_at":"2026-07-24T02:44:53Z","started_at":"2026-07-24T02:42:11Z","closed_at":"2026-07-24T02:44:53Z","close_reason":"Implemented config.LoadOverlay (base decode + overlay decode into same struct, then shared finalize/validate), wired -config-overlay flag in cmd/archied, fixed docker-compose.yml to mount both base config.toml and config.docker.toml overlay, minimized config.docker.toml to true diff-only overlay, added tests proving overlay-omitted required fields (bot_user, repos) still come from base.","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-u64","title":"Daemon: process multiple tasks concurrently (max_concurrency enforcement)","description":"Daemon currently processes one task at a time (docs/prds/archie-core-v2-architecture.md Phase 2). This is the core blocker between current state and any multi-agent scaling mode — needed before container max_concurrency or same-repo concurrency can matter. Wire the daemon's dispatch loop to run N tasks in parallel, respecting a configurable max_concurrency.","design":"internal/container/pool.go already enforces max_concurrency for container lifecycle — reuse that limit/pattern in the daemon's task dispatch rather than inventing a second concurrency control.","acceptance_criteria":"Daemon dispatch loop runs multiple tasks concurrently up to a configured max_concurrency limit; single-task-at-a-time behavior is gone.","status":"closed","priority":1,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-23T19:36:31Z","created_by":"Sam Catlow","updated_at":"2026-07-23T21:37:42Z","started_at":"2026-07-23T21:29:41Z","closed_at":"2026-07-23T21:37:42Z","close_reason":"Implemented concurrent SQLite and NATS task dispatch using containers.max_concurrency, with default same-repo serialization and race-tested dispatcher coverage.","dependency_count":0,"dependent_count":2,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-n55","title":"Simplify Telegram model command surface","description":"Remove the redundant /models command from Telegram's published and executable command surface; retain /model selector. Make /help menu copy useful rather than self-referential.","status":"closed","priority":2,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-27T01:41:43Z","created_by":"Sam Catlow","updated_at":"2026-07-27T01:44:06Z","started_at":"2026-07-27T01:41:50Z","closed_at":"2026-07-27T01:44:06Z","close_reason":"Shipped locally: /models removed from Telegram menu, help, and Router; /model is the sole model selector/direct-switch command; /help menu text is now 'See what Archie can do'; command docs updated. task check passes and fresh review reports no findings.","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-rqp","title":"Telegram: component-aware /update with approve or defer","description":"Add an /update control flow that checks for available releases, presents separate archied gateway and archie-agent runtime versions/changelog sections, and lets an authorized user approve or defer. Keep discovery and execution behind typed interfaces so Docker/Watchtower, package-manager, and other installations can supply their own updater without the Telegram gateway assuming a deployment mechanism.","acceptance_criteria":"/update reports whether gateway and runtime updates are available, with separate version and changelog sections and explicit no-change wording. Telegram provides Approve and Defer actions restricted to authorized users. Deferral is persisted and suppresses repeated prompts according to an explicit policy. Approval calls a typed installation updater and reports progress/failure without claiming success early. No Watchtower-only or Docker-only behavior exists in the gateway package. Commands, menu, help, callback authorization, concurrency, persistence, and failure paths are tested.","status":"open","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-07-26T19:47:21Z","created_by":"Sam Catlow","updated_at":"2026-07-26T19:47:21Z","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-b8t","title":"Telegram: announce newly installed Archie releases","description":"When archied starts after an installed release upgrade, notify authorized Telegram users once with an exact component-aware rundown from CHANGELOG.md. Present archied as THE GATEWAY and archie-agent as THE RUNTIME, explicitly saying when either component has no changes. Persist announced versions per recipient so ordinary restarts do not repeat notifications.","acceptance_criteria":"Repository has a maintained component-aware CHANGELOG.md. On an installed version advance, each configured authorized Telegram user receives one concise message with separate THE GATEWAY and THE RUNTIME sections and explicit no-change wording where applicable. Announced component versions are persisted and duplicate restarts do not repeat. First-run and development builds have explicit non-spam behavior. Parsing, version transition, persistence failure, and delivery failure paths are tested.","notes":"Component history decision: CHANGELOG.archied.md for gateway/control plane and CHANGELOG.archie.md for agent runtime, with root CHANGELOG.md as index. Installed/update messages render both sources and explicitly state when a component has no changes.","status":"in_progress","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-26T19:39:18Z","created_by":"Sam Catlow","updated_at":"2026-07-26T19:48:38Z","started_at":"2026-07-26T19:46:23Z","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-abg.16.36","title":"Telegram: /restore to revert the last change","description":"Operator escape hatch requested alongside /restart: revert the last change from chat when an agent-authored change breaks something, without needing shell access to the host. Gateway-scoped.","acceptance_criteria":"Admin-only (allowlisted sender). Reverts the last change and reports what was reverted. Safe to run when there is nothing to revert.","notes":"Design finding: /restore must restore the latest agent-authored filesystem checkpoint, not revert an arbitrary daemon checkout commit. The change boundary will be owned by the sandboxed MCP execution layer: capture a pre-change checkpoint once per mutating agent turn, retain enough metadata to report files, and make restore safe/idempotent when empty. Hermes reference behavior uses this same filesystem-checkpoint boundary for /rollback; /undo is conversation-only. Blocked on 17.43.","status":"in_progress","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-26T19:15:34Z","created_by":"Sam Catlow","updated_at":"2026-07-26T19:27:32Z","started_at":"2026-07-26T19:25:16Z","dependencies":[{"issue_id":"archie-core-abg.16.36","depends_on_id":"archie-core-abg.16","type":"parent-child","created_at":"2026-07-27T05:15:33Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-abg.16.36","depends_on_id":"archie-core-abg.17.43","type":"blocks","created_at":"2026-07-27T05:27:32Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0}
|
||||
|
||||
+1
-1
@@ -345,7 +345,7 @@ func run() int {
|
||||
}
|
||||
|
||||
// Build an LLM responder from the runtime. Gateway-local commands
|
||||
// (/status, /models, /model, /spawn) are handled directly; all
|
||||
// (/status, /model, /spawn) are handled directly; all
|
||||
// other messages are routed through the LLM with conversation
|
||||
// history from the session store.
|
||||
var llmResponder gateway.LLMResponder
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
| Gateway code | ~40 files | 3 files (gateway.go, tasks.go + tests) |
|
||||
| Platform adapters | 30+ (built-in + plugin) | 1 (Telegram) |
|
||||
| Built-in tools | 80+ | ~5 (capture, script) |
|
||||
| Slash commands | 42 | 5 (/status, /help, /model, /models, /spawn) |
|
||||
| Slash commands | 42 | 5 (/status, /help, /provider, /model, /spawn) |
|
||||
| Plugin system | Full hooks + MCP + middleware | Minimal Yaegi loader |
|
||||
| Memory | Pluggable providers (Honcho, Mem0) | Ephemeral in-memory notes |
|
||||
| CLI commands | 60+ | 4 flags |
|
||||
|
||||
@@ -20,14 +20,13 @@ type commandSpec struct {
|
||||
// together prevents a newly registered command from being omitted from help.
|
||||
var gatewayCommandSpecs = []commandSpec{
|
||||
{Command: "status", Description: "Show task counts by state", Usage: "/status"},
|
||||
{Command: "models", Description: "List available models", Usage: "/models"},
|
||||
{Command: "provider", Description: "Choose the provider used for chat", Usage: "/provider"},
|
||||
{Command: "model", Description: "Show the model selector or switch directly", Usage: "/model [provider/model]"},
|
||||
{Command: "spawn", Description: "Create a tracked task", Usage: "/spawn [identity=name] [repo=owner/name] [workflow=name] <title>"},
|
||||
{Command: "approve", Description: "Approve and requeue a waiting task", Usage: "/approve [identity=name] <task-id>"},
|
||||
{Command: "cancel", Description: "Cancel a queued or waiting task", Usage: "/cancel [identity=name] <task-id>"},
|
||||
{Command: "restart", Description: "Reload Archie and its configuration", Usage: "/restart"},
|
||||
{Command: "help", Description: "Show this guide", Usage: "/help"},
|
||||
{Command: "help", Description: "See what Archie can do", Usage: "/help"},
|
||||
}
|
||||
|
||||
var telegramOnlyCommands = []string{"provider", "restart", "help"}
|
||||
|
||||
@@ -101,6 +101,20 @@ func TestTelegramUserFacingCommandCopyDoesNotCallArchieAGateway(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommandSurfaceUsesOneModelSelectorAndUsefulHelpCopy(t *testing.T) {
|
||||
for _, spec := range gatewayCommandSpecs {
|
||||
if spec.Command == "models" {
|
||||
t.Fatal("/models is redundant beside /model and must not be published")
|
||||
}
|
||||
if spec.Command == "help" && spec.Description == "Show this guide" {
|
||||
t.Fatal("/help menu copy is self-referential")
|
||||
}
|
||||
}
|
||||
if strings.Contains(gatewayHelpText(), "/models") {
|
||||
t.Fatal("/help must not advertise the removed /models command")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStartHasDeterministicGatewayResponse(t *testing.T) {
|
||||
const allowedUserID = int64(42)
|
||||
g := New("1:test", "", "", []int64{allowedUserID}, slog.Default())
|
||||
|
||||
@@ -67,8 +67,8 @@ type LLMStreamResponder func(ctx context.Context, msg Message, onDelta func(stri
|
||||
|
||||
// ModelManager provides access to available models and allows switching the
|
||||
// active LLM model. The daemon supplies an implementation backed by its
|
||||
// runtime provider catalog. When nil on a Router, /model and /models
|
||||
// return "not configured" messages.
|
||||
// runtime provider catalog. When nil on a Router, /model returns a
|
||||
// "not configured" message.
|
||||
type ModelManager interface {
|
||||
// Models returns all available model references in "provider/model" format.
|
||||
Models() []string
|
||||
@@ -132,7 +132,7 @@ type TaskController interface {
|
||||
// message.
|
||||
type Router struct {
|
||||
Store StatusReader
|
||||
Models ModelManager // nil = /model and /models not configured
|
||||
Models ModelManager // nil = /model not configured
|
||||
Tasks TaskCreator // nil = /spawn not configured
|
||||
Controller TaskController // nil = /approve and /cancel not configured
|
||||
LLM LLMResponder // nil = LLM not wired yet
|
||||
@@ -156,7 +156,7 @@ func NewRouter(store StatusReader, llm LLMResponder, gatewayName string) *Router
|
||||
}
|
||||
|
||||
// Route dispatches msg and returns the reply. Gateway-local commands
|
||||
// (like /status, /model, /models) are handled directly; everything
|
||||
// (like /status and /model) are handled directly; everything
|
||||
// else goes to the LLM responder.
|
||||
func (r *Router) Route(ctx context.Context, msg Message) (string, error) {
|
||||
text := strings.TrimSpace(msg.Text)
|
||||
@@ -165,8 +165,6 @@ func (r *Router) Route(ctx context.Context, msg Message) (string, error) {
|
||||
switch cmd {
|
||||
case "/status":
|
||||
return r.handleStatus(ctx)
|
||||
case "/models":
|
||||
return r.handleModels(ctx)
|
||||
case "/model":
|
||||
return r.handleModel(ctx, arg)
|
||||
case "/spawn":
|
||||
@@ -209,7 +207,7 @@ func (r *Router) RouteStream(ctx context.Context, msg Message, onDelta func(stri
|
||||
return r.LLMStream(ctx, msg, onDelta)
|
||||
}
|
||||
|
||||
var localCommands = []string{"/status", "/models", "/model", "/spawn", "/approve", "/cancel"}
|
||||
var localCommands = []string{"/status", "/model", "/spawn", "/approve", "/cancel"}
|
||||
|
||||
// LocalCommands returns the command names Route answers from local state.
|
||||
// Gateways use this to verify that their published command surfaces match
|
||||
@@ -243,31 +241,6 @@ func parseCmd(text, gatewayName string) (cmd, arg string) {
|
||||
return raw, ""
|
||||
}
|
||||
|
||||
func (r *Router) handleModels(ctx context.Context) (string, error) {
|
||||
if r.Models == nil {
|
||||
return "Model management is not configured.", nil
|
||||
}
|
||||
models := r.Models.Models()
|
||||
if manager, ok := r.Models.(ProviderModelManager); ok {
|
||||
models = manager.ModelsForProvider(manager.ActiveProvider())
|
||||
}
|
||||
if len(models) == 0 {
|
||||
return "No models configured.", nil
|
||||
}
|
||||
active := r.Models.ActiveModel()
|
||||
|
||||
var b strings.Builder
|
||||
b.WriteString("Available models:\n")
|
||||
for _, m := range models {
|
||||
if m == active {
|
||||
fmt.Fprintf(&b, " %s (active)\n", m)
|
||||
} else {
|
||||
fmt.Fprintf(&b, " %s\n", m)
|
||||
}
|
||||
}
|
||||
return b.String(), nil
|
||||
}
|
||||
|
||||
func (r *Router) handleModel(ctx context.Context, arg string) (string, error) {
|
||||
if r.Models == nil {
|
||||
return "Model switching is not configured.", nil
|
||||
|
||||
@@ -135,7 +135,7 @@ func TestRouterRejectsUnknownCommand(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// -- ModelManager fakes for /model and /models tests --
|
||||
// -- ModelManager fakes for /model tests --
|
||||
|
||||
type fakeModelManager struct {
|
||||
models []string
|
||||
@@ -194,109 +194,19 @@ func (f *fakeModelManager) SetActiveModel(_ context.Context, ref string) error {
|
||||
return fmt.Errorf("unknown model: %s", ref)
|
||||
}
|
||||
|
||||
// -- /models tests --
|
||||
// -- /model tests --
|
||||
|
||||
func TestRouteModels(t *testing.T) {
|
||||
mgr := &fakeModelManager{
|
||||
models: []string{"a/b", "c/d"},
|
||||
}
|
||||
func TestRouteModelsIsNoLongerACommand(t *testing.T) {
|
||||
r := NewRouter(nil, nil, "test-gw")
|
||||
r.Models = mgr
|
||||
reply, err := r.Route(context.Background(), Message{Text: "/models"})
|
||||
if err != nil {
|
||||
t.Fatalf("Route: %v", err)
|
||||
}
|
||||
if !strings.Contains(reply, "a/b") || !strings.Contains(reply, "c/d") {
|
||||
t.Errorf("reply missing model names: %q", reply)
|
||||
}
|
||||
if strings.Contains(reply, "active") {
|
||||
t.Errorf("reply should not flag an active model when none is set: %q", reply)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRouteModelsFiltersActiveProvider(t *testing.T) {
|
||||
manager := &fakeProviderModelManager{
|
||||
fakeModelManager: fakeModelManager{
|
||||
models: []string{
|
||||
"openrouter/openai/gpt-5.6",
|
||||
"openai/gpt-5.6",
|
||||
"openai/o3",
|
||||
},
|
||||
activeModel: "openai/gpt-5.6",
|
||||
},
|
||||
}
|
||||
router := NewRouter(nil, nil, "test")
|
||||
router.Models = manager
|
||||
|
||||
reply, err := router.Route(context.Background(), Message{Text: "/models"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.Contains(reply, "openrouter/") {
|
||||
t.Fatalf("/models leaked another provider:\n%s", reply)
|
||||
}
|
||||
if !strings.Contains(reply, "openai/gpt-5.6") || !strings.Contains(reply, "openai/o3") {
|
||||
t.Fatalf("/models omitted active-provider models:\n%s", reply)
|
||||
if !strings.Contains(reply, "Unknown command /models") {
|
||||
t.Errorf("reply = %q, want /models to be unavailable", reply)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRouteModelsWithActive(t *testing.T) {
|
||||
mgr := &fakeModelManager{
|
||||
models: []string{"a/b", "c/d"},
|
||||
activeModel: "c/d",
|
||||
}
|
||||
r := NewRouter(nil, nil, "test-gw")
|
||||
r.Models = mgr
|
||||
reply, err := r.Route(context.Background(), Message{Text: "/models"})
|
||||
if err != nil {
|
||||
t.Fatalf("Route: %v", err)
|
||||
}
|
||||
if !strings.Contains(reply, "a/b") || !strings.Contains(reply, "c/d (active)") {
|
||||
t.Errorf("reply should flag active model: %q", reply)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRouteModelsAtMention(t *testing.T) {
|
||||
mgr := &fakeModelManager{
|
||||
models: []string{"a/b"},
|
||||
}
|
||||
r := NewRouter(nil, nil, "test-gw")
|
||||
r.Models = mgr
|
||||
reply, err := r.Route(context.Background(), Message{Text: "/models@test-gw"})
|
||||
if err != nil {
|
||||
t.Fatalf("Route: %v", err)
|
||||
}
|
||||
if !strings.Contains(reply, "a/b") {
|
||||
t.Errorf("reply missing model names: %q", reply)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRouteModelsEmpty(t *testing.T) {
|
||||
mgr := &fakeModelManager{}
|
||||
r := NewRouter(nil, nil, "test-gw")
|
||||
r.Models = mgr
|
||||
reply, err := r.Route(context.Background(), Message{Text: "/models"})
|
||||
if err != nil {
|
||||
t.Fatalf("Route: %v", err)
|
||||
}
|
||||
if !strings.Contains(reply, "No models") {
|
||||
t.Errorf("reply = %q, want 'No models' message", reply)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRouteModelsNoManager(t *testing.T) {
|
||||
r := NewRouter(nil, nil, "test-gw")
|
||||
reply, err := r.Route(context.Background(), Message{Text: "/models"})
|
||||
if err != nil {
|
||||
t.Fatalf("Route: %v", err)
|
||||
}
|
||||
if !strings.Contains(reply, "not configured") {
|
||||
t.Errorf("reply = %q, want 'not configured' message", reply)
|
||||
}
|
||||
}
|
||||
|
||||
// -- /model tests --
|
||||
|
||||
func TestRouteModelSwitch(t *testing.T) {
|
||||
mgr := &fakeModelManager{
|
||||
models: []string{"a/b", "c/d"},
|
||||
|
||||
Reference in new issue
Block a user