omni-cortex 1.17.1__py3-none-any.whl → 1.17.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- omni_cortex/__init__.py +3 -0
- omni_cortex/_bundled/dashboard/backend/.env.example +12 -0
- omni_cortex/_bundled/dashboard/backend/backfill_summaries.py +280 -0
- omni_cortex/_bundled/dashboard/backend/chat_service.py +631 -0
- omni_cortex/_bundled/dashboard/backend/database.py +1773 -0
- omni_cortex/_bundled/dashboard/backend/image_service.py +552 -0
- omni_cortex/_bundled/dashboard/backend/logging_config.py +122 -0
- omni_cortex/_bundled/dashboard/backend/main.py +1888 -0
- omni_cortex/_bundled/dashboard/backend/models.py +472 -0
- omni_cortex/_bundled/dashboard/backend/project_config.py +170 -0
- omni_cortex/_bundled/dashboard/backend/project_scanner.py +164 -0
- omni_cortex/_bundled/dashboard/backend/prompt_security.py +111 -0
- omni_cortex/_bundled/dashboard/backend/pyproject.toml +23 -0
- omni_cortex/_bundled/dashboard/backend/security.py +104 -0
- omni_cortex/_bundled/dashboard/backend/uv.lock +1110 -0
- omni_cortex/_bundled/dashboard/backend/websocket_manager.py +104 -0
- omni_cortex/_bundled/hooks/post_tool_use.py +497 -0
- omni_cortex/_bundled/hooks/pre_tool_use.py +277 -0
- omni_cortex/_bundled/hooks/session_utils.py +186 -0
- omni_cortex/_bundled/hooks/stop.py +219 -0
- omni_cortex/_bundled/hooks/subagent_stop.py +120 -0
- omni_cortex/_bundled/hooks/user_prompt.py +220 -0
- omni_cortex/categorization/__init__.py +9 -0
- omni_cortex/categorization/auto_tags.py +166 -0
- omni_cortex/categorization/auto_type.py +165 -0
- omni_cortex/config.py +141 -0
- omni_cortex/dashboard.py +238 -0
- omni_cortex/database/__init__.py +24 -0
- omni_cortex/database/connection.py +137 -0
- omni_cortex/database/migrations.py +210 -0
- omni_cortex/database/schema.py +212 -0
- omni_cortex/database/sync.py +421 -0
- omni_cortex/decay/__init__.py +7 -0
- omni_cortex/decay/importance.py +147 -0
- omni_cortex/embeddings/__init__.py +35 -0
- omni_cortex/embeddings/local.py +442 -0
- omni_cortex/models/__init__.py +20 -0
- omni_cortex/models/activity.py +265 -0
- omni_cortex/models/agent.py +144 -0
- omni_cortex/models/memory.py +395 -0
- omni_cortex/models/relationship.py +206 -0
- omni_cortex/models/session.py +290 -0
- omni_cortex/resources/__init__.py +1 -0
- omni_cortex/search/__init__.py +22 -0
- omni_cortex/search/hybrid.py +197 -0
- omni_cortex/search/keyword.py +204 -0
- omni_cortex/search/ranking.py +127 -0
- omni_cortex/search/semantic.py +232 -0
- omni_cortex/server.py +360 -0
- omni_cortex/setup.py +284 -0
- omni_cortex/tools/__init__.py +13 -0
- omni_cortex/tools/activities.py +453 -0
- omni_cortex/tools/memories.py +536 -0
- omni_cortex/tools/sessions.py +311 -0
- omni_cortex/tools/utilities.py +477 -0
- omni_cortex/utils/__init__.py +13 -0
- omni_cortex/utils/formatting.py +282 -0
- omni_cortex/utils/ids.py +72 -0
- omni_cortex/utils/timestamps.py +129 -0
- omni_cortex/utils/truncation.py +111 -0
- {omni_cortex-1.17.1.dist-info → omni_cortex-1.17.3.dist-info}/METADATA +1 -1
- omni_cortex-1.17.3.dist-info/RECORD +86 -0
- omni_cortex-1.17.1.dist-info/RECORD +0 -26
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/dashboard/backend/.env.example +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/dashboard/backend/backfill_summaries.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/dashboard/backend/chat_service.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/dashboard/backend/database.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/dashboard/backend/image_service.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/dashboard/backend/logging_config.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/dashboard/backend/main.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/dashboard/backend/models.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/dashboard/backend/project_config.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/dashboard/backend/project_scanner.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/dashboard/backend/prompt_security.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/dashboard/backend/pyproject.toml +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/dashboard/backend/security.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/dashboard/backend/uv.lock +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/dashboard/backend/websocket_manager.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/hooks/post_tool_use.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/hooks/pre_tool_use.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/hooks/session_utils.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/hooks/stop.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/hooks/subagent_stop.py +0 -0
- {omni_cortex-1.17.1.data → omni_cortex-1.17.3.data}/data/share/omni-cortex/hooks/user_prompt.py +0 -0
- {omni_cortex-1.17.1.dist-info → omni_cortex-1.17.3.dist-info}/WHEEL +0 -0
- {omni_cortex-1.17.1.dist-info → omni_cortex-1.17.3.dist-info}/entry_points.txt +0 -0
- {omni_cortex-1.17.1.dist-info → omni_cortex-1.17.3.dist-info}/licenses/LICENSE +0 -0
omni_cortex/__init__.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Dashboard Backend Environment Configuration
|
|
2
|
+
#
|
|
3
|
+
# NOTE: This file is for reference only.
|
|
4
|
+
# The dashboard now loads from the PROJECT ROOT .env file.
|
|
5
|
+
#
|
|
6
|
+
# Copy the root .env.example to .env and configure there:
|
|
7
|
+
# cp ../../.env.example ../../.env
|
|
8
|
+
#
|
|
9
|
+
# Required settings in root .env:
|
|
10
|
+
# GEMINI_API_KEY=your-api-key-here
|
|
11
|
+
#
|
|
12
|
+
# See ../../.env.example for all available options.
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"""Backfill utility for generating activity summaries.
|
|
2
|
+
|
|
3
|
+
This module provides functions to retroactively generate natural language
|
|
4
|
+
summaries for existing activity records that don't have them.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
import sqlite3
|
|
9
|
+
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Optional
|
|
12
|
+
|
|
13
|
+
# Add parent paths for imports
|
|
14
|
+
sys.path.insert(0, str(Path(__file__).parent.parent.parent / "src"))
|
|
15
|
+
|
|
16
|
+
from database import get_write_connection, ensure_migrations
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def generate_activity_summary(
|
|
20
|
+
tool_name: Optional[str],
|
|
21
|
+
tool_input: Optional[str],
|
|
22
|
+
success: bool,
|
|
23
|
+
file_path: Optional[str],
|
|
24
|
+
event_type: str,
|
|
25
|
+
) -> tuple[str, str]:
|
|
26
|
+
"""Generate natural language summary for an activity.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
tuple of (short_summary, detailed_summary)
|
|
30
|
+
"""
|
|
31
|
+
short = ""
|
|
32
|
+
detail = ""
|
|
33
|
+
|
|
34
|
+
# Parse tool input if available
|
|
35
|
+
input_data = {}
|
|
36
|
+
if tool_input:
|
|
37
|
+
try:
|
|
38
|
+
input_data = json.loads(tool_input)
|
|
39
|
+
except (json.JSONDecodeError, TypeError):
|
|
40
|
+
pass
|
|
41
|
+
|
|
42
|
+
# Generate summaries based on tool type
|
|
43
|
+
if tool_name == "Read":
|
|
44
|
+
path = input_data.get("file_path", file_path or "unknown file")
|
|
45
|
+
filename = Path(path).name if path else "file"
|
|
46
|
+
short = f"Read file: {filename}"
|
|
47
|
+
detail = f"Reading contents of {path}"
|
|
48
|
+
|
|
49
|
+
elif tool_name == "Write":
|
|
50
|
+
path = input_data.get("file_path", file_path or "unknown file")
|
|
51
|
+
filename = Path(path).name if path else "file"
|
|
52
|
+
short = f"Write file: {filename}"
|
|
53
|
+
detail = f"Writing/creating file at {path}"
|
|
54
|
+
|
|
55
|
+
elif tool_name == "Edit":
|
|
56
|
+
path = input_data.get("file_path", file_path or "unknown file")
|
|
57
|
+
filename = Path(path).name if path else "file"
|
|
58
|
+
short = f"Edit file: {filename}"
|
|
59
|
+
detail = f"Editing {path} - replacing text content"
|
|
60
|
+
|
|
61
|
+
elif tool_name == "Bash":
|
|
62
|
+
cmd = input_data.get("command", "")[:50]
|
|
63
|
+
short = f"Run command: {cmd}..."
|
|
64
|
+
detail = f"Executing bash command: {input_data.get('command', 'unknown')}"
|
|
65
|
+
|
|
66
|
+
elif tool_name == "Grep":
|
|
67
|
+
pattern = input_data.get("pattern", "")
|
|
68
|
+
short = f"Search for: {pattern[:30]}"
|
|
69
|
+
detail = f"Searching codebase for pattern: {pattern}"
|
|
70
|
+
|
|
71
|
+
elif tool_name == "Glob":
|
|
72
|
+
pattern = input_data.get("pattern", "")
|
|
73
|
+
short = f"Find files: {pattern[:30]}"
|
|
74
|
+
detail = f"Finding files matching pattern: {pattern}"
|
|
75
|
+
|
|
76
|
+
elif tool_name == "Skill":
|
|
77
|
+
skill = input_data.get("skill", "unknown")
|
|
78
|
+
short = f"Run skill: /{skill}"
|
|
79
|
+
detail = f"Executing slash command /{skill}"
|
|
80
|
+
|
|
81
|
+
elif tool_name == "Task":
|
|
82
|
+
desc = input_data.get("description", "task")
|
|
83
|
+
short = f"Spawn agent: {desc[:30]}"
|
|
84
|
+
detail = f"Launching sub-agent for: {input_data.get('prompt', desc)[:100]}"
|
|
85
|
+
|
|
86
|
+
elif tool_name == "WebSearch":
|
|
87
|
+
query = input_data.get("query", "")
|
|
88
|
+
short = f"Web search: {query[:30]}"
|
|
89
|
+
detail = f"Searching the web for: {query}"
|
|
90
|
+
|
|
91
|
+
elif tool_name == "WebFetch":
|
|
92
|
+
url = input_data.get("url", "")
|
|
93
|
+
short = f"Fetch URL: {url[:40]}"
|
|
94
|
+
detail = f"Fetching content from: {url}"
|
|
95
|
+
|
|
96
|
+
elif tool_name == "TodoWrite":
|
|
97
|
+
todos = input_data.get("todos", [])
|
|
98
|
+
count = len(todos) if isinstance(todos, list) else 0
|
|
99
|
+
short = f"Update todo list: {count} items"
|
|
100
|
+
detail = f"Managing task list with {count} items"
|
|
101
|
+
|
|
102
|
+
elif tool_name == "AskUserQuestion":
|
|
103
|
+
questions = input_data.get("questions", [])
|
|
104
|
+
count = len(questions) if isinstance(questions, list) else 1
|
|
105
|
+
short = f"Ask user: {count} question(s)"
|
|
106
|
+
detail = f"Prompting user for input with {count} question(s)"
|
|
107
|
+
|
|
108
|
+
elif tool_name and tool_name.startswith("mcp__"):
|
|
109
|
+
parts = tool_name.split("__")
|
|
110
|
+
server = parts[1] if len(parts) > 1 else "unknown"
|
|
111
|
+
tool = parts[2] if len(parts) > 2 else tool_name
|
|
112
|
+
short = f"MCP call: {server}/{tool}"
|
|
113
|
+
detail = f"Calling {tool} tool from MCP server {server}"
|
|
114
|
+
|
|
115
|
+
elif tool_name == "cortex_remember" or (tool_name and "remember" in tool_name.lower()):
|
|
116
|
+
params = input_data.get("params", {})
|
|
117
|
+
content = params.get("content", "") if isinstance(params, dict) else ""
|
|
118
|
+
short = f"Store memory: {content[:30]}..." if content else "Store memory"
|
|
119
|
+
detail = f"Saving to memory system: {content[:100]}" if content else "Saving to memory system"
|
|
120
|
+
|
|
121
|
+
elif tool_name == "cortex_recall" or (tool_name and "recall" in tool_name.lower()):
|
|
122
|
+
params = input_data.get("params", {})
|
|
123
|
+
query = params.get("query", "") if isinstance(params, dict) else ""
|
|
124
|
+
short = f"Recall: {query[:30]}" if query else "Recall memories"
|
|
125
|
+
detail = f"Searching memories for: {query}" if query else "Retrieving memories"
|
|
126
|
+
|
|
127
|
+
elif tool_name == "NotebookEdit":
|
|
128
|
+
path = input_data.get("notebook_path", "")
|
|
129
|
+
filename = Path(path).name if path else "notebook"
|
|
130
|
+
short = f"Edit notebook: {filename}"
|
|
131
|
+
detail = f"Editing Jupyter notebook {path}"
|
|
132
|
+
|
|
133
|
+
else:
|
|
134
|
+
short = f"{event_type}: {tool_name or 'unknown'}"
|
|
135
|
+
detail = f"Activity type {event_type} with tool {tool_name}"
|
|
136
|
+
|
|
137
|
+
# Add status suffix for failures
|
|
138
|
+
if not success:
|
|
139
|
+
short = f"[FAILED] {short}"
|
|
140
|
+
detail = f"[FAILED] {detail}"
|
|
141
|
+
|
|
142
|
+
return short, detail
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def backfill_activity_summaries(db_path: str) -> int:
|
|
146
|
+
"""Generate summaries for activities that don't have them.
|
|
147
|
+
|
|
148
|
+
Args:
|
|
149
|
+
db_path: Path to the SQLite database
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
Number of activities updated
|
|
153
|
+
"""
|
|
154
|
+
# First ensure migrations are applied
|
|
155
|
+
ensure_migrations(db_path)
|
|
156
|
+
|
|
157
|
+
conn = get_write_connection(db_path)
|
|
158
|
+
|
|
159
|
+
# Check if summary column exists
|
|
160
|
+
columns = conn.execute("PRAGMA table_info(activities)").fetchall()
|
|
161
|
+
column_names = {col[1] for col in columns}
|
|
162
|
+
|
|
163
|
+
if "summary" not in column_names:
|
|
164
|
+
print(f"[Backfill] Summary column not found in {db_path}, skipping")
|
|
165
|
+
conn.close()
|
|
166
|
+
return 0
|
|
167
|
+
|
|
168
|
+
cursor = conn.execute("""
|
|
169
|
+
SELECT id, tool_name, tool_input, success, file_path, event_type
|
|
170
|
+
FROM activities
|
|
171
|
+
WHERE summary IS NULL OR summary = ''
|
|
172
|
+
""")
|
|
173
|
+
|
|
174
|
+
count = 0
|
|
175
|
+
for row in cursor.fetchall():
|
|
176
|
+
short, detail = generate_activity_summary(
|
|
177
|
+
row["tool_name"],
|
|
178
|
+
row["tool_input"],
|
|
179
|
+
bool(row["success"]),
|
|
180
|
+
row["file_path"],
|
|
181
|
+
row["event_type"],
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
conn.execute(
|
|
185
|
+
"""
|
|
186
|
+
UPDATE activities
|
|
187
|
+
SET summary = ?, summary_detail = ?
|
|
188
|
+
WHERE id = ?
|
|
189
|
+
""",
|
|
190
|
+
(short, detail, row["id"]),
|
|
191
|
+
)
|
|
192
|
+
count += 1
|
|
193
|
+
|
|
194
|
+
if count % 100 == 0:
|
|
195
|
+
conn.commit()
|
|
196
|
+
print(f"[Backfill] Processed {count} activities...")
|
|
197
|
+
|
|
198
|
+
conn.commit()
|
|
199
|
+
conn.close()
|
|
200
|
+
return count
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def backfill_mcp_servers(db_path: str) -> int:
|
|
204
|
+
"""Extract and populate mcp_server for existing activities.
|
|
205
|
+
|
|
206
|
+
Args:
|
|
207
|
+
db_path: Path to the SQLite database
|
|
208
|
+
|
|
209
|
+
Returns:
|
|
210
|
+
Number of activities updated
|
|
211
|
+
"""
|
|
212
|
+
# First ensure migrations are applied
|
|
213
|
+
ensure_migrations(db_path)
|
|
214
|
+
|
|
215
|
+
conn = get_write_connection(db_path)
|
|
216
|
+
|
|
217
|
+
# Check if mcp_server column exists
|
|
218
|
+
columns = conn.execute("PRAGMA table_info(activities)").fetchall()
|
|
219
|
+
column_names = {col[1] for col in columns}
|
|
220
|
+
|
|
221
|
+
if "mcp_server" not in column_names:
|
|
222
|
+
print(f"[Backfill] mcp_server column not found in {db_path}, skipping")
|
|
223
|
+
conn.close()
|
|
224
|
+
return 0
|
|
225
|
+
|
|
226
|
+
cursor = conn.execute("""
|
|
227
|
+
SELECT id, tool_name FROM activities
|
|
228
|
+
WHERE tool_name LIKE 'mcp__%'
|
|
229
|
+
AND (mcp_server IS NULL OR mcp_server = '')
|
|
230
|
+
""")
|
|
231
|
+
|
|
232
|
+
count = 0
|
|
233
|
+
for row in cursor.fetchall():
|
|
234
|
+
parts = row["tool_name"].split("__")
|
|
235
|
+
if len(parts) >= 2:
|
|
236
|
+
server = parts[1]
|
|
237
|
+
conn.execute(
|
|
238
|
+
"UPDATE activities SET mcp_server = ? WHERE id = ?",
|
|
239
|
+
(server, row["id"]),
|
|
240
|
+
)
|
|
241
|
+
count += 1
|
|
242
|
+
|
|
243
|
+
conn.commit()
|
|
244
|
+
conn.close()
|
|
245
|
+
return count
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def backfill_all(db_path: str) -> dict:
|
|
249
|
+
"""Run all backfill operations on a database.
|
|
250
|
+
|
|
251
|
+
Args:
|
|
252
|
+
db_path: Path to the SQLite database
|
|
253
|
+
|
|
254
|
+
Returns:
|
|
255
|
+
Dictionary with counts of updated records
|
|
256
|
+
"""
|
|
257
|
+
print(f"[Backfill] Starting backfill for {db_path}")
|
|
258
|
+
|
|
259
|
+
results = {
|
|
260
|
+
"summaries": backfill_activity_summaries(db_path),
|
|
261
|
+
"mcp_servers": backfill_mcp_servers(db_path),
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
print(f"[Backfill] Complete: {results['summaries']} summaries, {results['mcp_servers']} MCP servers")
|
|
265
|
+
return results
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
if __name__ == "__main__":
|
|
269
|
+
# Allow running from command line with database path as argument
|
|
270
|
+
if len(sys.argv) < 2:
|
|
271
|
+
print("Usage: python backfill_summaries.py <path-to-database>")
|
|
272
|
+
sys.exit(1)
|
|
273
|
+
|
|
274
|
+
db_path = sys.argv[1]
|
|
275
|
+
if not Path(db_path).exists():
|
|
276
|
+
print(f"Error: Database not found at {db_path}")
|
|
277
|
+
sys.exit(1)
|
|
278
|
+
|
|
279
|
+
results = backfill_all(db_path)
|
|
280
|
+
print(f"Backfill complete: {results}")
|