htmlgraph 0.26.20__py3-none-any.whl → 0.26.21__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.
htmlgraph/__init__.py CHANGED
@@ -95,7 +95,7 @@ from htmlgraph.types import (
95
95
  )
96
96
  from htmlgraph.work_type_utils import infer_work_type, infer_work_type_from_id
97
97
 
98
- __version__ = "0.26.20"
98
+ __version__ = "0.26.21"
99
99
  __all__ = [
100
100
  # Exceptions
101
101
  "HtmlGraphError",
@@ -709,6 +709,7 @@ def track_event(hook_type: str, hook_input: dict[str, Any]) -> dict[str, Any]:
709
709
  db = None
710
710
  try:
711
711
  from htmlgraph.config import get_database_path
712
+ from htmlgraph.db.schema import HtmlGraphDB
712
713
 
713
714
  db = HtmlGraphDB(str(get_database_path()))
714
715
  except Exception as e:
@@ -1129,36 +1130,51 @@ def track_event(hook_type: str, hook_input: dict[str, Any]) -> dict[str, Any]:
1129
1130
  # This handles Claude Code's session reuse where parent_session_id is NULL
1130
1131
  # When tool calls come from a subagent, they should be under the task_delegation parent,
1131
1132
  # NOT under UserQuery. So we MUST check for active tasks BEFORE falling back to UserQuery.
1132
- elif db:
1133
+ # IMPORTANT: This must work EVEN IF db is None, so try to get it from htmlgraph_db
1134
+ else:
1135
+ # Ensure we have a db connection (may not have been passed in for parent session)
1136
+ db_to_use = db
1137
+ if not db_to_use:
1138
+ try:
1139
+ from htmlgraph.config import get_database_path
1140
+ from htmlgraph.db.schema import HtmlGraphDB
1141
+
1142
+ db_to_use = HtmlGraphDB(str(get_database_path()))
1143
+ except Exception:
1144
+ db_to_use = None
1145
+
1133
1146
  # Try to find an active task_delegation event
1134
- try:
1135
- cursor = db.connection.cursor() # type: ignore[union-attr]
1136
- cursor.execute(
1137
- """
1138
- SELECT event_id
1139
- FROM agent_events
1140
- WHERE event_type = 'task_delegation'
1141
- AND status = 'started'
1142
- ORDER BY timestamp DESC
1143
- LIMIT 1
1144
- """,
1145
- )
1146
- task_row = cursor.fetchone()
1147
- if task_row:
1148
- parent_activity_id = task_row[0]
1147
+ if db_to_use:
1148
+ try:
1149
+ cursor = db_to_use.connection.cursor() # type: ignore[union-attr]
1150
+ cursor.execute(
1151
+ """
1152
+ SELECT event_id
1153
+ FROM agent_events
1154
+ WHERE event_type = 'task_delegation'
1155
+ AND status = 'started'
1156
+ ORDER BY timestamp DESC
1157
+ LIMIT 1
1158
+ """,
1159
+ )
1160
+ task_row = cursor.fetchone()
1161
+ if task_row:
1162
+ parent_activity_id = task_row[0]
1163
+ print(
1164
+ f"DEBUG: Found active task_delegation={parent_activity_id} in parent_activity_id fallback",
1165
+ file=sys.stderr,
1166
+ )
1167
+ except Exception as e:
1149
1168
  print(
1150
- f"DEBUG: Found active task_delegation={parent_activity_id} in parent_activity_id fallback",
1169
+ f"DEBUG: Error finding task_delegation in parent_activity_id: {e}",
1151
1170
  file=sys.stderr,
1152
1171
  )
1153
- except Exception as e:
1154
- print(
1155
- f"DEBUG: Error finding task_delegation in parent_activity_id: {e}",
1156
- file=sys.stderr,
1157
- )
1158
1172
 
1159
- # Only if no active task found, fall back to UserQuery
1160
- if not parent_activity_id:
1161
- parent_activity_id = get_parent_user_query(db, active_session_id)
1173
+ # Only if no active task found, fall back to UserQuery
1174
+ if not parent_activity_id:
1175
+ parent_activity_id = get_parent_user_query(
1176
+ db_to_use, active_session_id
1177
+ )
1162
1178
 
1163
1179
  # Track the activity
1164
1180
  nudge = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: htmlgraph
3
- Version: 0.26.20
3
+ Version: 0.26.21
4
4
  Summary: HTML is All You Need - Graph database on web standards
5
5
  Project-URL: Homepage, https://github.com/Shakes-tzd/htmlgraph
6
6
  Project-URL: Documentation, https://github.com/Shakes-tzd/htmlgraph#readme
@@ -1,4 +1,4 @@
1
- htmlgraph/__init__.py,sha256=MMtitVi79c3FBvO1Cphhy55Fkx6uPFnrqklQsUVH2fA,5718
1
+ htmlgraph/__init__.py,sha256=4LWHyu17HK4jYZaA6ntt6yu6ovb8wt5L3Fm1hY_WC6o,5718
2
2
  htmlgraph/agent_detection.py,sha256=wEmrDv4hssPX2OkEnJZBHPbalxcaloiJF_hOOow_5WE,3511
3
3
  htmlgraph/agent_registry.py,sha256=Usa_35by7p5gtpvHO7K3AcGimnorw-FzgPVa3cWTQ58,9448
4
4
  htmlgraph/agents.py,sha256=Yvu6x1nOfrW2WhRTAHiCuSpvqoVJXx1Mkzd59kwEczw,33466
@@ -192,7 +192,7 @@ htmlgraph/hooks/cigs_pretool_enforcer.py,sha256=Lyp4DDaw_sVHEcW-kzdegldyfXjvVD25
192
192
  htmlgraph/hooks/concurrent_sessions.py,sha256=qOiwDfynphVG0-2pVBakEzOwMORU8ebN1gMjcN4S0z0,6476
193
193
  htmlgraph/hooks/context.py,sha256=tJ4dIL8uTFHyqyuuMc-ETDuOikeD5cN3Mdjmfg6W0HE,13108
194
194
  htmlgraph/hooks/drift_handler.py,sha256=QckL5U5ooku51kI6mppGLsXzaKVt1Yx5uNu-iXZrgSk,17602
195
- htmlgraph/hooks/event_tracker.py,sha256=jb1LOGj1fJfI5-lR3lXNgBO9NuMk2_IULL864-FkM6A,51260
195
+ htmlgraph/hooks/event_tracker.py,sha256=IO5EedWYbgDnoRk25TXayduEOrrFdsfN8yNnRh5BUpw,52040
196
196
  htmlgraph/hooks/git_commands.py,sha256=NPzthfzGJ_bkDi7soehHOxI9FLL-6BL8Tie9Byb_zf4,4803
197
197
  htmlgraph/hooks/hooks-config.example.json,sha256=tXpk-U-FZzGOoNJK2uiDMbIHCYEHA794J-El0fBwkqg,197
198
198
  htmlgraph/hooks/installer.py,sha256=nOctCFDEV7BEh7ZzxNY-apu1KZG0SHPMq74UPIOChqY,11756
@@ -252,12 +252,12 @@ htmlgraph/templates/AGENTS.md.template,sha256=f96h7V6ygwj-v-fanVI48eYMxR6t_se4be
252
252
  htmlgraph/templates/CLAUDE.md.template,sha256=h1kG2hTX2XYig2KszsHBfzrwa_4Cfcq2Pj4SwqzeDlM,1984
253
253
  htmlgraph/templates/GEMINI.md.template,sha256=gAGzE53Avki87BM_otqy5HdcYCoLsHgqaKjVzNzPMX8,1622
254
254
  htmlgraph/templates/orchestration-view.html,sha256=DlS7LlcjH0oO_KYILjuF1X42t8QhKLH4F85rkO54alY,10472
255
- htmlgraph-0.26.20.data/data/htmlgraph/dashboard.html,sha256=MUT6SaYnazoyDcvHz5hN1omYswyIoUfeoZLf2M_iblo,251268
256
- htmlgraph-0.26.20.data/data/htmlgraph/styles.css,sha256=oDUSC8jG-V-hKojOBO9J88hxAeY2wJrBYTq0uCwX_Y4,7135
257
- htmlgraph-0.26.20.data/data/htmlgraph/templates/AGENTS.md.template,sha256=f96h7V6ygwj-v-fanVI48eYMxR6t_se4bet1H4ZsDpI,7642
258
- htmlgraph-0.26.20.data/data/htmlgraph/templates/CLAUDE.md.template,sha256=h1kG2hTX2XYig2KszsHBfzrwa_4Cfcq2Pj4SwqzeDlM,1984
259
- htmlgraph-0.26.20.data/data/htmlgraph/templates/GEMINI.md.template,sha256=gAGzE53Avki87BM_otqy5HdcYCoLsHgqaKjVzNzPMX8,1622
260
- htmlgraph-0.26.20.dist-info/METADATA,sha256=Wx03e3booGFqIReqKIrFcR2ncnpLWTDWb9GnI7zR4Mo,10237
261
- htmlgraph-0.26.20.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
262
- htmlgraph-0.26.20.dist-info/entry_points.txt,sha256=Wmdo5cx8pt6NoMsssVE2mZH1CZLSUsrg_3iSWatiyn0,103
263
- htmlgraph-0.26.20.dist-info/RECORD,,
255
+ htmlgraph-0.26.21.data/data/htmlgraph/dashboard.html,sha256=MUT6SaYnazoyDcvHz5hN1omYswyIoUfeoZLf2M_iblo,251268
256
+ htmlgraph-0.26.21.data/data/htmlgraph/styles.css,sha256=oDUSC8jG-V-hKojOBO9J88hxAeY2wJrBYTq0uCwX_Y4,7135
257
+ htmlgraph-0.26.21.data/data/htmlgraph/templates/AGENTS.md.template,sha256=f96h7V6ygwj-v-fanVI48eYMxR6t_se4bet1H4ZsDpI,7642
258
+ htmlgraph-0.26.21.data/data/htmlgraph/templates/CLAUDE.md.template,sha256=h1kG2hTX2XYig2KszsHBfzrwa_4Cfcq2Pj4SwqzeDlM,1984
259
+ htmlgraph-0.26.21.data/data/htmlgraph/templates/GEMINI.md.template,sha256=gAGzE53Avki87BM_otqy5HdcYCoLsHgqaKjVzNzPMX8,1622
260
+ htmlgraph-0.26.21.dist-info/METADATA,sha256=bnWDldDHf-mKvqDRWMiJvXC0z7YBWURtvKLYvGn29LY,10237
261
+ htmlgraph-0.26.21.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
262
+ htmlgraph-0.26.21.dist-info/entry_points.txt,sha256=Wmdo5cx8pt6NoMsssVE2mZH1CZLSUsrg_3iSWatiyn0,103
263
+ htmlgraph-0.26.21.dist-info/RECORD,,