-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext.zig
More file actions
78 lines (65 loc) · 3.37 KB
/
context.zig
File metadata and controls
78 lines (65 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Application context for tool execution
const std = @import("std");
const state_module = @import("state");
const config_module = @import("config");
const zvdb = @import("zvdb");
const embedder_interface = @import("embedder_interface");
const llm_provider_module = @import("llm_provider");
const types = @import("types");
const agents_module = @import("agents");
const ProgressUpdateType = agents_module.ProgressUpdateType;
const task_store_module = @import("task_store");
const task_db_module = @import("task_db");
const git_sync_module = @import("git_sync");
const conversation_db_module = @import("conversation_db");
/// State for an active agent conversation session (slash command mode)
pub const ActiveAgentSession = struct {
/// Type-safe executor interface (use .ptr field to get underlying AgentExecutor when needed)
executor: agents_module.AgentExecutorInterface,
agent_name: []const u8,
system_prompt: []const u8,
capabilities: agents_module.AgentCapabilities,
};
pub const AppContext = struct {
allocator: std.mem.Allocator,
config: *const config_module.Config,
state: *state_module.AppState,
llm_provider: *llm_provider_module.LLMProvider,
// Vector DB components (kept for future semantic search)
vector_store: ?*zvdb.HNSW(f32) = null,
embedder: ?*embedder_interface.Embedder = null, // Generic interface - works with both Ollama and LM Studio
// Agent system (optional - only present if agents enabled)
agent_registry: ?*agents_module.AgentRegistry = null,
// Task memory system (Beads-inspired)
task_store: ?*task_store_module.TaskStore = null,
task_db: ?*task_db_module.TaskDB = null,
git_sync: ?*git_sync_module.GitSync = null,
// Conversation persistence for agent message tracking
conversation_db: ?*conversation_db_module.ConversationDB = null,
session_id: ?i64 = null,
// Arena allocator for task queries during tool execution
// Set by tools.zig executeToolCall(), used by TaskStore/TaskDB for task allocations
// All tasks allocated from arena are freed when tool execution completes
task_arena: ?*std.heap.ArenaAllocator = null,
// Recent conversation messages for context-aware tools
// Populated before tool execution, null otherwise
// Tools can use this to understand what the user is asking about
recent_messages: ?[]const types.Message = null,
// Agent progress callback for real-time streaming
// Set by app.zig before executing agent-powered tools
// Allows sub-agents (like file curator) to stream progress to UI
agent_progress_callback: ?agents_module.ProgressCallback = null,
agent_progress_user_data: ?*anyopaque = null,
// Active agent session for slash command conversations
// When a user starts an agent with /agentname, session is stored here
active_agent: ?*ActiveAgentSession = null,
// Pointer to executor's planning_complete flag (set by planning_done tool)
// When set to true, forces conversation_mode agent to complete
planning_complete_ptr: ?*bool = null,
// Pointer to executor's tinkering_complete flag (set by git_commit tool)
// When set to true, signals that implementation is ready for Judge review
tinkering_complete_ptr: ?*bool = null,
// Current agent name (set by executor when running an agent)
// Used by add_task_comment to attribute comments
current_agent_name: ?[]const u8 = null,
};