Skip to content

Archimedes 3.0: a personal-assistant application with Discord as a channel#26

Closed
HiLleywyn wants to merge 1 commit into
mainfrom
claude/kai-9000-discord-app-52sbu
Closed

Archimedes 3.0: a personal-assistant application with Discord as a channel#26
HiLleywyn wants to merge 1 commit into
mainfrom
claude/kai-9000-discord-app-52sbu

Conversation

@HiLleywyn
Copy link
Copy Markdown
Owner

Summary

A hard pivot from "Discord bot with AI features" to a personal-assistant application that lives in Discord. The agent is lifted out of the Discord cog into a coherent application layer (arch/), and Discord becomes a pluggable channel (channels/) following the session-keyed routing pattern from the OpenClaw channels reference. Same agent core could power a web, voice or CLI channel without rewriting any of the assistant logic.

Six headline features land as first-class concepts:

  • Soul -- editable system-prompt persona with named presets (default, short, tutor, creative, expert), persisted in the database, switchable at runtime.
  • Heartbeat -- optional autonomous self-check loop with an active-hours window and recent-activity log.
  • Scheduler -- durable cron and oneshot tasks that survive restarts and fire back into the channel that scheduled them.
  • MCP -- streamable HTTP and stdio Model Context Protocol client. Servers declared in env or added live; their tools bridge into the agent registry.
  • Dynamic UI -- channel-agnostic Card / Section / StatTile / Button / Suggestion primitives. Discord renders as embeds plus interactive views; plaintext channels get a sensible fallback.
  • Service Chain -- ordered model providers with per-provider circuit breakers and explicit fallback semantics.

Plus four built-in tools (arch.time, arch.location, arch.fetch_url, arch.open_url) and a focused, owner-only .app command group covering every 3.0 feature without leaving Discord.

Architecture

                  ArchAgent (arch/core.py)
                       ▲
                       │ handle(text, ctx) -> ArchResponse
        ┌──────────────┼──────────────┐
        │              │              │
  DiscordChannel    (web)         (cli, voice)
  • arch/ -- the application: Soul, Heartbeat, Scheduler, MCP, Memories, Services, Dynamic UI, built-in tools, config.
  • channels/ -- the transport abstraction: base Channel, Discord adapter, policy evaluator, session-key derivation, streaming preview, embed renderer.
  • cogs/arch_app.py -- the .app operator command group.
  • docs/architecture.md -- the full picture.

Tests

237 offline tests pass, including 59 new ones covering soul presets, heartbeat windowing, cron evaluation, oneshot delay parsing, dynamic UI builders, service-chain fallback and circuit-breaker behaviour, MCP spec parsing and registry bookkeeping, session-key derivation, and the DM/guild policy evaluator.

Backwards compatibility

Every new env var defaults to a no-op so an unchanged 2.x deployment behaves exactly as before. Existing tables, the Lua plugin runtime, the Node sidecar, cogs/chat, and ai/tools all keep their place; the application layer wraps them rather than replacing them.

Database additions (all idempotent)

archimedes_soul, archimedes_heartbeat_log, archimedes_scheduled_tasks, archimedes_mcp_servers, archimedes_settings.

Test plan

  • pytest tests/ -- 237 passed, no failures.
  • python -c "from arch import ArchAgent, Card, ArchResponse, Heartbeat, Scheduler, ServiceChain, SoulStore, MCPRegistry" -- clean.
  • python -c "import channels.discord_channel; import cogs.arch_app" -- clean.
  • ArchConfig.from_env() parses every documented ARCHIMEDES_* and DISCORD_*_POLICY env var.
  • ServiceChain.from_specs correctly builds the multi-provider chain from comma-separated ARCHIMEDES_SERVICES.
  • _parse_mcp handles HTTP, stdio and rejects unknown schemes silently.
  • No em-dashes, en-dashes or Unicode minus signs in any new source file.
  • End-to-end smoke against a live Discord token and PostgreSQL (manual, post-merge).

Generated by Claude Code

Lift the agent out of the Discord cog into a coherent personal-assistant
application (arch/) and re-wire Discord as a pluggable channel
(channels/) following the same session-keyed routing pattern documented
in the OpenClaw channels reference.

New application layer (arch/):
  - Soul: editable system prompt with named presets (default, short,
    tutor, creative, expert), persisted in archimedes_soul.
  - Heartbeat: optional autonomous self-check loop with active-hours
    window, configurable interval, and a recent-activity log
    (archimedes_heartbeat_log).
  - Scheduler: durable cron and oneshot tasks, surviving restarts
    (archimedes_scheduled_tasks). Includes a small no-dependency cron
    evaluator and a liberal "in N units" parser.
  - MCP: streamable HTTP and stdio Model Context Protocol client with
    discovery, registry and persistence (archimedes_mcp_servers).
  - Service Chain: ordered model providers with per-provider circuit
    breakers and explicit fallback semantics.
  - Dynamic UI: channel-agnostic Card, Section, StatTile, Button and
    Suggestion primitives, plus a plaintext renderer for transports
    that cannot render structure.
  - Memories: verb-named facade over ai.memory.MemoryService.
  - Built-in tools: arch.time, arch.location, arch.fetch_url,
    arch.open_url -- added to the existing registry without removing
    any prior tool.

New channel layer (channels/):
  - Channel ABC + NullChannel for tests.
  - DiscordChannel wraps ArchimedesBot, applies DM/guild policies,
    derives session keys (arch:discord:{dm,channel,thread}:<id>) and
    renders ArchResponse as embeds plus interactive views.
  - PreviewStreamer for token-by-token edit streaming.
  - Pure-logic policy and session-key modules.

Operator surface:
  - cogs/arch_app.py adds a focused, owner-only ".app" command group
    covering soul, heartbeat, schedule, mcp and services -- every 3.0
    feature controllable without leaving Discord.

Existing code preserved:
  - cogs/chat, ai/tools and the Node sidecar all keep their place.
  - Existing memory, traits, episodes, plugin runtime and conversation
    history tables are untouched.

Configuration:
  - 12 new ARCHIMEDES_* env vars plus DISCORD_DM_POLICY and
    DISCORD_GUILD_POLICY, every one defaulting to a no-op so an
    unchanged deployment behaves exactly as 2.x did.

Database:
  - Five idempotent CREATE TABLE IF NOT EXISTS additions
    (archimedes_soul, archimedes_heartbeat_log, archimedes_scheduled_tasks,
    archimedes_mcp_servers, archimedes_settings).

Tests:
  - 59 new offline tests covering soul presets, heartbeat windowing,
    cron evaluation, oneshot delay parsing, dynamic UI builders, service
    chain fallback and circuit-breaker behaviour, MCP spec parsing and
    registry bookkeeping, session-key derivation, and the DM/guild
    policy evaluator. Full suite passes (237 tests).

Docs:
  - docs/architecture.md describes the application and channel layers,
    the database additions, and the operator surface.
  - README.md leads with the application framing.

Project metadata:
  - Version bump to 3.0.0 with a new description that names the
    application rather than the bot.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
archimedes Error Error May 20, 2026 6:08am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants