Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119package tui
import ( "errors"
tea "charm.land/bubbletea/v2")
func init() { enter := tea.KeyPressMsg{Code: tea.KeyEnter} shiftEnter := tea.KeyPressMsg{Code: tea.KeyEnter, Mod: tea.ModShift} typed := func(text string) []tea.Msg { var keys []tea.Msg for _, r := range text { keys = append(keys, tea.KeyPressMsg{Code: r, Text: string(r)}) } return keys } registerShots("extensions", shotState{"list", extensionsShot(nil)}, shotState{"filtering", extensionsShot(nil, typed("codex")...)}, shotState{"no-match", extensionsShot(nil, typed("zzz")...)}, shotState{"quarantined", extensionsShot(func(m *ExtensionPickerModel) { m.input.SetValue("mcp"); m.refilter("") })}, shotState{"own-choice", extensionsShot(func(m *ExtensionPickerModel) { m.input.SetValue("cua"); m.refilter("") })}, shotState{"folded-shelf", extensionsShot(func(m *ExtensionPickerModel) { m.refilter("shelf:providers") })}, shotState{"builtins-open", extensionsShot(func(m *ExtensionPickerModel) { m.builtinsOpen = true; m.rebuildShelves(); m.refilter("python") })}, shotState{"confirm-memory", extensionsShot(func(m *ExtensionPickerModel) { m.refilter("persistent-agent") }, shiftEnter)}, shotState{"confirm-global", extensionsShot(func(m *ExtensionPickerModel) { m.refilter("cua") }, enter)}, shotState{"confirm-session", extensionsShot(func(m *ExtensionPickerModel) { m.refilter("cua") }, shiftEnter)}, shotState{"confirm-follow-global", extensionsShot(func(m *ExtensionPickerModel) { m.refilter("cua") }, tea.KeyPressMsg{Code: 'x', Mod: tea.ModCtrl})}, shotState{"saving", extensionsShot(func(m *ExtensionPickerModel) { m.refilter("cua") }, shiftEnter, enter)}, shotState{"save-failed", func(w, h int) string { m := extensionsModel(w, h, nil) m.refilter("cua") m, _ = m.Update(shiftEnter) m, _ = m.Update(enter) m, _ = m.Update(extensionToggledMsg{Gen: m.Generation, Err: errors.New("daemon refused the change")}) return m.View() }}, shotState{"notice", extensionsShot(func(m *ExtensionPickerModel) { m.Notice = "Saved the global default. Reload sessions to apply it." })}, shotState{"overridden-quarantined", extensionsShot(func(m *ExtensionPickerModel) { *m, _ = m.Update(extensionsLoadedMsg{Gen: m.Generation, Extensions: append(m.Extensions, ExtensionItem{ Name: "discord-extra", Shelf: "channels", Description: "a bot that answers in a channel", Enabled: true, Overridden: true, Quarantined: "token rejected on startup", Plugins: []string{"service"}, })}) m.refilter("discord-extra") })}, shotState{"reload-failed", func(w, h int) string { m := extensionsModel(w, h, nil) m, _ = m.Update(extensionsLoadedMsg{Gen: m.Generation, Err: errors.New("daemon connection unavailable")}) return m.View() }}, shotState{"loading", func(w, h int) string { m := NewExtensionPickerModel(nil, "s") m.SetSize(w, h) return m.View() }}, shotState{"empty", func(w, h int) string { m := NewExtensionPickerModel(nil, "s") m.SetSize(w, h) m, _ = m.Update(extensionsLoadedMsg{Gen: m.Generation}) return m.View() }}, shotState{"load-failed", func(w, h int) string { m := NewExtensionPickerModel(nil, "s") m.SetSize(w, h) m, _ = m.Update(extensionsLoadedMsg{Gen: m.Generation, Err: errors.New("daemon connection unavailable")}) return m.View() }}, )}
func extensionsModel(width, height int, setup func(*ExtensionPickerModel)) ExtensionPickerModel { m := NewExtensionPickerModel(nil, "s") m.SetSize(width, height) m, _ = m.Update(extensionsLoadedMsg{Gen: m.Generation, Extensions: []ExtensionItem{ {Name: "rolling", Shelf: "memory", Summary: "one running summary + recent tail", Description: "Keep one running summary alongside the recent conversation.", GlobalEnabled: true}, {Name: "coding-lcm", Shelf: "memory", Summary: "summaries tied to their sources", Description: "Linked summaries remain readable through the lcm tools.", Enabled: true, Overridden: true}, {Name: "persistent-agent", Shelf: "memory", Summary: "its own memories, across days", Description: "Persistent memories across sessions and days."}, {Name: "snapcompact", Shelf: "memory", Summary: "history as images, folds instantly", Description: "Compact history into rendered images."}, {Name: "notes", Shelf: "memory", Summary: "notes it rewrites at each fold", Enabled: true, GlobalEnabled: true}, {Name: "web-search", Shelf: "reach", Summary: "search via signed-in providers", Enabled: true, GlobalEnabled: true}, {Name: "exa", Shelf: "reach", Summary: "exa as a search provider", Enabled: true, GlobalEnabled: true}, {Name: "browser", Shelf: "reach", Summary: "drive chrome or chromium", Enabled: true, GlobalEnabled: true}, {Name: "cua", Shelf: "reach", Summary: "drive native desktop apps", Description: "Control native apps through cua-driver from Python.", Enabled: true, Overridden: true, Requires: []string{"python"}, PythonModules: []string{"cua"}}, {Name: "remote", Shelf: "reach", Summary: "run its kernel on another machine", Enabled: true, GlobalEnabled: true}, {Name: "colab", Shelf: "reach", Summary: "google colab gpu runtimes", Enabled: true, GlobalEnabled: true}, {Name: "view", Shelf: "reach", Summary: "see its own diffs as images", Description: "Show the model its changes as highlighted images.", Enabled: true, GlobalEnabled: true, Plugins: []string{"tool"}, Tools: []string{"view_diff"}}, {Name: "mcp", Shelf: "reach", Summary: "tool servers over mcp", Description: "Connect external tool servers.", GlobalEnabled: true, Quarantined: "failed to start: executable not found"}, {Name: "editor-mcp", Shelf: "reach", Summary: "mcp servers your editor shares", Enabled: true, GlobalEnabled: true}, {Name: "discord", Shelf: "channels", Summary: "a discord bot for the session"}, {Name: "webhooks", Shelf: "channels", Summary: "signed requests wake a session"}, {Name: "proxy", Shelf: "channels", Summary: "your models as an openai api"}, {Name: "hooks", Shelf: "channels", Summary: "claude code style command hooks"}, {Name: "codex", Shelf: "providers", Summary: "your chatgpt subscription", Enabled: true, GlobalEnabled: true}, {Name: "claude", Shelf: "providers", Summary: "anthropic models", Enabled: true, GlobalEnabled: true}, {Name: "openai", Shelf: "providers", Summary: "openai models", Enabled: true, GlobalEnabled: true}, {Name: "vertex", Shelf: "providers", Summary: "google cloud models"}, {Name: "python", Shelf: "builtins", Summary: "the persistent python kernel", Enabled: true, GlobalEnabled: true}, {Name: "run", Shelf: "builtins", Summary: "run programs", Enabled: true, GlobalEnabled: true}, {Name: "files", Shelf: "builtins", Summary: "read and edit files", Enabled: true, GlobalEnabled: true}, }}) if setup != nil { setup(&m) } return m}
func extensionsShot(setup func(*ExtensionPickerModel), keys ...tea.Msg) func(width, height int) string { return func(width, height int) string { m := extensionsModel(width, height, setup) for _, key := range keys { m, _ = m.Update(key) } return m.View() }}