Files
archie/internal/gateway/session.go
T
sam 0314955587 feat: wire memory, guardrails, and tool registry into daemon agent loop
Memory:
- MemoryManager created in main.go with built-in file-backed provider
- SystemPromptBlock() injected into every agent stage request via ExtraRules
- memoryPrompt() helper on Daemon, threaded through TaskContext.SystemPrompt

Guardrails:
- GuardrailEngine created from DefaultGuardrailConfig in main.go
- RecordSuccess/RecordFailure called after every agent stage run
- Threaded through TaskContext.Guardrails for per-task guardrail enforcement

Tool registry:
- NewRegistry() created at startup, MCP servers started from config
- Passed to Daemon.ToolRegistry for dynamic tool discovery

Daemon changes:
- Memory, Guardrails, ToolRegistry fields added (nil-safe, backward compat)
- TaskContext gains SystemPrompt + Guardrails fields
- Agent stage injects memory context into ExtraRules
- Agent stage records guardrail state after each run

Telegram LLM routing deferred (TODO comment) — gateway commands work.
All 38 packages pass with -race.
2026-07-26 10:25:07 +10:00

46 lines
1.6 KiB
Go

package gateway
import "time"
// SessionSource identifies the platform, bot identity, and conversation a
// gateway session belongs to. It is the composite natural key for session
// lookup.
type SessionSource struct {
// Platform is the adapter name ("telegram", "discord", "web").
Platform string `json:"platform"`
// BotUser is the bot identity serving this session (e.g. "archie",
// "winter"). Distinct bot identities on the same platform and channel
// produce distinct sessions.
BotUser string `json:"bot_user"`
// ChannelID is the platform conversation identifier (chat ID, channel
// name, DM thread).
ChannelID string `json:"channel_id"`
// ThreadID identifies the topic thread within the conversation, for
// platforms that support threading (Telegram supergroup topics,
// Slack threads, Discord forum posts). Empty for flat chats and the
// General topic. When non-empty, distinct threads within the same
// channel produce distinct sessions.
ThreadID string `json:"thread_id,omitempty"`
}
// SessionContext holds the full metadata for an active gateway session.
// SessionStore is the persistence layer; callers treat SessionContext as
// a value object.
type SessionContext struct {
// SessionID is the unique session identifier (UUID).
SessionID string `json:"session_id"`
// Source identifies the platform, bot, and conversation.
Source SessionSource `json:"source"`
// CreatedAt is when the session was first established.
CreatedAt time.Time `json:"created_at"`
// LastActiveAt is the timestamp of the most recent message or event
// on this session. Updated by Touch.
LastActiveAt time.Time `json:"last_active_at"`
}