execweave 1.0.0__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.
Files changed (234) hide show
  1. execweave/__init__.py +3 -0
  2. execweave/__main__.py +5 -0
  3. execweave/_conversation_records_core.py +902 -0
  4. execweave/_dashboard_shell_base.py +148 -0
  5. execweave/_http_proxy_base.py +565 -0
  6. execweave/_http_proxy_bounded.py +560 -0
  7. execweave/_http_proxy_stage.py +509 -0
  8. execweave/acceptance_output.py +19 -0
  9. execweave/agent_bootstrap.py +395 -0
  10. execweave/agent_topology.py +313 -0
  11. execweave/agent_trace.py +1162 -0
  12. execweave/agy_preview_sanitize.py +102 -0
  13. execweave/analysis.py +427 -0
  14. execweave/anthropic.py +228 -0
  15. execweave/anthropic_cli.py +171 -0
  16. execweave/anthropic_full_fidelity.py +385 -0
  17. execweave/antigravity_adapter.py +112 -0
  18. execweave/antigravity_adapter_base.py +479 -0
  19. execweave/antigravity_full_fidelity.py +656 -0
  20. execweave/antigravity_full_fidelity_base.py +172 -0
  21. execweave/antigravity_full_fidelity_collaboration_base.py +451 -0
  22. execweave/antigravity_hook_cli.py +209 -0
  23. execweave/antigravity_record.py +96 -0
  24. execweave/antigravity_subagent_linkage.py +449 -0
  25. execweave/antigravity_trace_capability.py +39 -0
  26. execweave/auto_specialized.py +547 -0
  27. execweave/backends.py +102 -0
  28. execweave/benchmark.py +80 -0
  29. execweave/claude_adapter.py +517 -0
  30. execweave/claude_child_transcript.py +314 -0
  31. execweave/claude_delegation.py +136 -0
  32. execweave/claude_full_fidelity.py +396 -0
  33. execweave/claude_hook_cli.py +209 -0
  34. execweave/claude_hook_contract.py +943 -0
  35. execweave/claude_model_observer.py +353 -0
  36. execweave/claude_record.py +106 -0
  37. execweave/cli.py +629 -0
  38. execweave/codex_adapter.py +455 -0
  39. execweave/codex_conversation.py +621 -0
  40. execweave/codex_full_fidelity.py +287 -0
  41. execweave/codex_hook_cli.py +301 -0
  42. execweave/codex_hook_entry.py +207 -0
  43. execweave/codex_hook_lifecycle.py +363 -0
  44. execweave/codex_message_diagnostics.py +322 -0
  45. execweave/codex_message_transport_diagnostics.py +399 -0
  46. execweave/codex_record.py +199 -0
  47. execweave/codex_rollout_structures.py +402 -0
  48. execweave/codex_rollout_trace.py +56 -0
  49. execweave/codex_rollout_trace_base.py +1509 -0
  50. execweave/collector.py +768 -0
  51. execweave/command.py +157 -0
  52. execweave/command_privacy.py +20 -0
  53. execweave/content_evidence.py +101 -0
  54. execweave/content_integrity.py +289 -0
  55. execweave/content_store.py +273 -0
  56. execweave/controlled_checks.py +561 -0
  57. execweave/conversation_archive.py +338 -0
  58. execweave/conversation_message_identity.py +264 -0
  59. execweave/conversation_preview.py +66 -0
  60. execweave/conversation_preview_antigravity.py +32 -0
  61. execweave/conversation_preview_claude.py +31 -0
  62. execweave/conversation_preview_codex.py +107 -0
  63. execweave/conversation_preview_common.py +180 -0
  64. execweave/conversation_preview_generic.py +188 -0
  65. execweave/conversation_preview_lines.py +133 -0
  66. execweave/conversation_preview_transcript.py +121 -0
  67. execweave/conversation_records.py +349 -0
  68. execweave/conversation_records_antigravity.py +370 -0
  69. execweave/conversation_records_codex.py +83 -0
  70. execweave/conversation_records_common.py +17 -0
  71. execweave/conversation_records_ollama.py +39 -0
  72. execweave/correlation.py +818 -0
  73. execweave/cursor_adapter.py +349 -0
  74. execweave/cursor_delegation.py +87 -0
  75. execweave/cursor_delegation_base.py +220 -0
  76. execweave/cursor_full_fidelity.py +489 -0
  77. execweave/cursor_hook_cli.py +195 -0
  78. execweave/cursor_hook_contract.py +439 -0
  79. execweave/cursor_lifecycle.py +159 -0
  80. execweave/cursor_record.py +96 -0
  81. execweave/dashboard_shell.py +283 -0
  82. execweave/delivery_status.py +94 -0
  83. execweave/entry.py +98 -0
  84. execweave/evidence_availability.py +113 -0
  85. execweave/evidence_grade.py +166 -0
  86. execweave/fidelity.py +304 -0
  87. execweave/filesystem.py +327 -0
  88. execweave/finalization.py +92 -0
  89. execweave/focus.py +118 -0
  90. execweave/framework_adapters/__init__.py +34 -0
  91. execweave/framework_adapters/autogen.py +398 -0
  92. execweave/framework_adapters/base.py +580 -0
  93. execweave/framework_adapters/camel.py +270 -0
  94. execweave/framework_adapters/camel_channel.py +71 -0
  95. execweave/framework_adapters/metagpt.py +315 -0
  96. execweave/framework_adapters/metagpt_ollama_compat.py +54 -0
  97. execweave/framework_adapters/metagpt_recording.py +342 -0
  98. execweave/framework_adapters/registry.py +90 -0
  99. execweave/graph.py +590 -0
  100. execweave/graph_ops.py +472 -0
  101. execweave/hook_command.py +32 -0
  102. execweave/hook_delivery.py +32 -0
  103. execweave/hook_input.py +16 -0
  104. execweave/http_proxy.py +187 -0
  105. execweave/http_proxy_cli.py +84 -0
  106. execweave/inference_gateway.py +476 -0
  107. execweave/inference_gateway_cli.py +211 -0
  108. execweave/inference_gateway_full_fidelity.py +613 -0
  109. execweave/inference_identity.py +76 -0
  110. execweave/inference_identity_cli.py +60 -0
  111. execweave/integrity.py +235 -0
  112. execweave/integrity_cli.py +55 -0
  113. execweave/investigation_index.py +445 -0
  114. execweave/litellm_callback.py +211 -0
  115. execweave/litellm_callback_cli.py +42 -0
  116. execweave/live.py +445 -0
  117. execweave/live_core.py +972 -0
  118. execweave/live_view.py +109 -0
  119. execweave/live_view_extra_style.py +11 -0
  120. execweave/live_view_markup.py +29 -0
  121. execweave/live_view_process_layout.py +650 -0
  122. execweave/live_view_readability.py +502 -0
  123. execweave/live_view_script_a.py +59 -0
  124. execweave/live_view_script_b.py +97 -0
  125. execweave/live_view_script_c.py +59 -0
  126. execweave/live_view_script_d.py +40 -0
  127. execweave/live_view_style.py +34 -0
  128. execweave/model_runtime.py +560 -0
  129. execweave/model_runtime_cli.py +265 -0
  130. execweave/model_runtime_full_fidelity.py +519 -0
  131. execweave/observation.py +53 -0
  132. execweave/observation_demo.py +69 -0
  133. execweave/openai_agents.py +267 -0
  134. execweave/openai_agents_sdk.py +453 -0
  135. execweave/openai_compatible.py +239 -0
  136. execweave/openai_compatible_cli.py +189 -0
  137. execweave/openai_compatible_full_fidelity.py +438 -0
  138. execweave/opencode_adapter.py +325 -0
  139. execweave/opencode_event_contract.py +734 -0
  140. execweave/opencode_full_fidelity.py +198 -0
  141. execweave/opencode_hook_cli.py +119 -0
  142. execweave/opencode_plugin_cli.py +150 -0
  143. execweave/opencode_record.py +96 -0
  144. execweave/opencode_task_linkage.py +225 -0
  145. execweave/overhead_benchmark.py +440 -0
  146. execweave/privacy.py +84 -0
  147. execweave/private_io.py +465 -0
  148. execweave/provider_capability.py +578 -0
  149. execweave/provider_lifecycle.py +282 -0
  150. execweave/provider_record.py +290 -0
  151. execweave/reader_identity.py +13 -0
  152. execweave/redacted_archive.py +906 -0
  153. execweave/risk.py +106 -0
  154. execweave/rule_pack.py +359 -0
  155. execweave/rule_pack_cli.py +57 -0
  156. execweave/run_assessment.py +200 -0
  157. execweave/runtime_endpoint_availability.py +44 -0
  158. execweave/scalability_benchmark.py +195 -0
  159. execweave/schema.py +62 -0
  160. execweave/scope.py +85 -0
  161. execweave/semantic.py +453 -0
  162. execweave/session_summary.py +159 -0
  163. execweave/sink.py +71 -0
  164. execweave/strace_backend.py +927 -0
  165. execweave/stream_assembly.py +363 -0
  166. execweave/task_artifacts.py +192 -0
  167. execweave/task_validation.py +317 -0
  168. execweave/theme.py +40 -0
  169. execweave/top.py +599 -0
  170. execweave/top_cli.py +150 -0
  171. execweave/validate.py +196 -0
  172. execweave/vendor/dagre.min.js +815 -0
  173. execweave/view_cli.py +49 -0
  174. execweave/viewer.py +474 -0
  175. execweave/viewer_agent_panel.py +630 -0
  176. execweave/viewer_agent_panel_antigravity.py +31 -0
  177. execweave/viewer_agent_panel_claude.py +9 -0
  178. execweave/viewer_agent_panel_codex.py +50 -0
  179. execweave/viewer_agent_panel_cursor.py +9 -0
  180. execweave/viewer_agent_panel_default.py +79 -0
  181. execweave/viewer_agent_panel_ollama.py +20 -0
  182. execweave/viewer_agent_panel_opencode.py +9 -0
  183. execweave/viewer_agent_panel_registry.py +20 -0
  184. execweave/viewer_archive_verifier.py +178 -0
  185. execweave/viewer_background_files.py +86 -0
  186. execweave/viewer_content_browser.py +307 -0
  187. execweave/viewer_content_health.py +208 -0
  188. execweave/viewer_content_inspector.py +309 -0
  189. execweave/viewer_controlled_checks.py +258 -0
  190. execweave/viewer_conversation_sync.py +115 -0
  191. execweave/viewer_dashboard_clean.py +405 -0
  192. execweave/viewer_dashboard_focus.py +127 -0
  193. execweave/viewer_dashboard_hardening.py +264 -0
  194. execweave/viewer_dashboard_hardening_v2.py +62 -0
  195. execweave/viewer_dashboard_projection.py +261 -0
  196. execweave/viewer_delivery_status.py +155 -0
  197. execweave/viewer_edge_decross.py +117 -0
  198. execweave/viewer_execution_flow.py +611 -0
  199. execweave/viewer_execution_flow_provider_normalization.py +107 -0
  200. execweave/viewer_execution_flow_safety.py +349 -0
  201. execweave/viewer_external_endpoints.py +307 -0
  202. execweave/viewer_flow_canvas.py +1140 -0
  203. execweave/viewer_flow_layout.py +922 -0
  204. execweave/viewer_fold_state.py +31 -0
  205. execweave/viewer_framework_flow.py +68 -0
  206. execweave/viewer_framework_model_output.py +133 -0
  207. execweave/viewer_gif.py +278 -0
  208. execweave/viewer_history_browser.py +225 -0
  209. execweave/viewer_investigation.py +268 -0
  210. execweave/viewer_layout_geometry.py +192 -0
  211. execweave/viewer_layout_v2.py +429 -0
  212. execweave/viewer_layout_v2_detached.py +25 -0
  213. execweave/viewer_limits.py +93 -0
  214. execweave/viewer_live_layout.py +61 -0
  215. execweave/viewer_message_handoffs.py +114 -0
  216. execweave/viewer_projection.py +488 -0
  217. execweave/viewer_projection_base.py +522 -0
  218. execweave/viewer_projection_bridges.py +214 -0
  219. execweave/viewer_recorded_sources.py +146 -0
  220. execweave/viewer_run_assessment.py +274 -0
  221. execweave/viewer_run_guide.py +175 -0
  222. execweave/viewer_runtime_evidence.py +258 -0
  223. execweave/viewer_semantic_projection.py +641 -0
  224. execweave/viewer_session_flow.py +491 -0
  225. execweave/viewer_structure_share.py +132 -0
  226. execweave/viewer_task_validation.py +241 -0
  227. execweave/viewer_tool_mirror_identity.py +75 -0
  228. execweave/viewer_workflow_mode.py +127 -0
  229. execweave/workflow.py +183 -0
  230. execweave-1.0.0.dist-info/METADATA +462 -0
  231. execweave-1.0.0.dist-info/RECORD +234 -0
  232. execweave-1.0.0.dist-info/WHEEL +4 -0
  233. execweave-1.0.0.dist-info/entry_points.txt +30 -0
  234. execweave-1.0.0.dist-info/licenses/LICENSE +16 -0
@@ -0,0 +1,282 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Any
5
+
6
+ LIFECYCLE_SCHEMA_VERSION = "0.1"
7
+ SUPPORTED_PROVIDER_LIFECYCLES = frozenset(
8
+ {"claude", "codex", "antigravity", "cursor", "opencode"}
9
+ )
10
+
11
+
12
+ @dataclass(frozen=True, order=True)
13
+ class ProviderLifecycleAnnotation:
14
+ provider: str
15
+ kind: str
16
+ stage: str
17
+
18
+ def to_dict(self) -> dict[str, str]:
19
+ return {
20
+ "schema_version": LIFECYCLE_SCHEMA_VERSION,
21
+ "provider": self.provider,
22
+ "kind": self.kind,
23
+ "stage": self.stage,
24
+ "evidence_semantics": "classification_only",
25
+ }
26
+
27
+
28
+ _RELATION_MAP: dict[str, tuple[str, str]] = {
29
+ "STARTED_PROVIDER_SESSION": ("provider_session", "started"),
30
+ "OBSERVED_PROVIDER_SESSION": ("provider_session", "observed"),
31
+ "OBSERVED_PROVIDER_SESSION_END": ("provider_session", "ended"),
32
+ "OBSERVED_PROVIDER_SETUP": ("provider_setup", "observed"),
33
+ "STARTED_AGENT_SESSION": ("agent_session", "started"),
34
+ "OBSERVED_AGENT_SESSION_DELETED": ("agent_session", "deleted"),
35
+ "HAS_CHILD_AGENT_SESSION": ("subagent", "child_session"),
36
+ "HAS_AGENT_THREAD": ("subagent", "thread_observed"),
37
+ "SPAWNED_AGENT": ("subagent", "started"),
38
+ "ASSIGNED_AGENT_TASK": ("subagent", "task_assigned"),
39
+ "CREATED_AGENT_TASK": ("agent_task", "created"),
40
+ "COMPLETED_AGENT_TASK": ("agent_task", "completed"),
41
+ "HAS_TASK_SUBJECT": ("agent_task", "subject_observed"),
42
+ "HAS_TASK_DESCRIPTION": ("agent_task", "description_observed"),
43
+ "SENT_AGENT_MESSAGE": ("agent_message", "sent"),
44
+ "DELIVERED_AGENT_MESSAGE": ("agent_message", "delivered"),
45
+ "CONSUMED_AGENT_MESSAGE": ("agent_message", "consumed"),
46
+ "INCLUDED_AGENT_MESSAGE_IN_INFERENCE": ("agent_message", "included_in_inference"),
47
+ "HAS_AGENT_MESSAGE_PAYLOAD": ("agent_message", "payload_observed"),
48
+ "OBSERVED_MESSAGE_REMOVED": ("agent_message", "removed"),
49
+ "OBSERVED_MESSAGE_PART_REMOVED": ("agent_message_part", "removed"),
50
+ "RETURNED_AGENT_RESULT": ("subagent", "result_returned"),
51
+ "CLOSED_AGENT": ("subagent", "closed"),
52
+ "SUBAGENT_STOPPED": ("subagent", "stopped"),
53
+ "STARTED_AGENT_TURN": ("agent_turn", "started"),
54
+ "TRIGGERED_AGENT_TURN": ("agent_turn", "triggered"),
55
+ "OBSERVED_IN_AGENT_TURN": ("agent_turn", "item_observed"),
56
+ "ISSUED_INFERENCE_IN_TURN": ("agent_turn", "inference_issued"),
57
+ "STARTED_TOOL_CALL_IN_TURN": ("agent_turn", "tool_call_started"),
58
+ "EXECUTED_CODE_CELL_IN_TURN": ("agent_turn", "code_cell_executed"),
59
+ "OBSERVED_TURN_STOP": ("agent_turn", "stop_observed"),
60
+ "OBSERVED_TURN_FAILURE": ("agent_turn", "failure_observed"),
61
+ "OBSERVED_BACKGROUND_TASKS": ("agent_turn", "background_tasks_observed"),
62
+ "OBSERVED_SESSION_CRONS": ("agent_turn", "session_crons_observed"),
63
+ "OBSERVED_AGENT_TURN_START": ("agent_turn", "start_observed"),
64
+ "OBSERVED_AGENT_TURN_END": ("agent_turn", "end_observed"),
65
+ "OBSERVED_EXECUTION_STOP": ("agent_execution", "stopped"),
66
+ "OBSERVED_EXECUTION_ERROR": ("agent_execution", "error_observed"),
67
+ "OBSERVED_EXECUTION_ERROR_CONTENT": (
68
+ "agent_execution",
69
+ "error_content_observed",
70
+ ),
71
+ "USED_MODEL": ("model", "selected"),
72
+ "INVOKES_MODEL": ("model", "invocation_requested"),
73
+ "MODEL_INVOCATION_COMPLETED": ("model", "invocation_completed"),
74
+ "SERVED_BY_MODEL": ("model", "served"),
75
+ "SWITCHED_MODEL": ("model", "runtime_transition"),
76
+ "OBSERVED_MODEL_REQUEST_TARGET": ("model", "request_target_observed"),
77
+ "OBSERVED_TOOL_SELECTION_MODEL_REQUEST": ("model", "tool_selection_request_observed"),
78
+ "OBSERVED_MODEL_RESPONSE_CHUNK": ("assistant_response", "model_stream_chunk_observed"),
79
+ "RECEIVED_USER_PROMPT": ("prompt", "received"),
80
+ "DELIVERED_USER_MESSAGE": ("prompt", "delivered"),
81
+ "OBSERVED_CHAT_MESSAGE": ("prompt", "observed_message"),
82
+ "OBSERVED_CHAT_MESSAGE_PARTS": ("prompt", "observed_parts"),
83
+ "OBSERVED_AGENT_PROMPT": ("prompt", "observed"),
84
+ "OBSERVED_PROMPT_EXPANSION": ("prompt_expansion", "observed"),
85
+ "OBSERVED_EXPANSION_PROMPT": ("prompt_expansion", "prompt_observed"),
86
+ "OBSERVED_EXPANSION_ARGUMENTS": ("prompt_expansion", "arguments_observed"),
87
+ "OBSERVED_INFERENCE_MESSAGE": ("inference_request", "message_observed"),
88
+ "OBSERVED_INFERENCE_PARAMETERS": ("inference_request", "parameters_observed"),
89
+ "OBSERVED_REQUEST_HEADERS": ("inference_request", "headers_observed"),
90
+ "OBSERVED_MODEL_CONTEXT": ("inference_request", "model_context_observed"),
91
+ "OBSERVED_SYSTEM_PROMPT": ("inference_request", "system_prompt_observed"),
92
+ "OBSERVED_LLM_REQUEST_BEFORE_MODEL": ("inference_request", "before_model_observed"),
93
+ "OBSERVED_LLM_REQUEST_BEFORE_TOOL_SELECTION": (
94
+ "inference_request",
95
+ "before_tool_selection_observed",
96
+ ),
97
+ "OBSERVED_LLM_REQUEST_FOR_RESPONSE": ("inference_request", "response_request_observed"),
98
+ "RECEIVED_LLM_RESPONSE_CHUNK": ("assistant_response", "stream_chunk"),
99
+ "OBSERVED_AGENT_RESPONSE_CANDIDATE": ("assistant_response", "turn_candidate_observed"),
100
+ "PRODUCED_ASSISTANT_RESPONSE": ("assistant_response", "final"),
101
+ "PRODUCED_ASSISTANT_TEXT": ("assistant_response", "final"),
102
+ "PRODUCED_ASSISTANT_MESSAGE": ("assistant_response", "message"),
103
+ "OBSERVED_AGENT_THOUGHT": ("assistant_thought", "provider_labeled_observed"),
104
+ "PRODUCED_REASONING_TEXT": ("reasoning", "provider_exposed_text"),
105
+ "PRODUCED_REASONING_SUMMARY": ("reasoning", "provider_exposed_summary"),
106
+ "PRODUCED_ENCODED_REASONING": ("reasoning", "provider_exposed_encoded"),
107
+ "COMPLETED_AGENT_STEP": ("assistant_response", "step_completed"),
108
+ "EXPOSES_TOOL": ("tool_definition", "exposed"),
109
+ "OBSERVED_TOOL_DESCRIPTION": ("tool_definition", "description_observed"),
110
+ "OBSERVED_TOOL_SCHEMA": ("tool_definition", "schema_observed"),
111
+ "REQUESTED_TOOL_CALL": ("tool_call", "requested"),
112
+ "OWNED_TOOL_CALL": ("tool_call", "agent_owned"),
113
+ "OBSERVED_TOOL_CALL": ("tool_call", "observed"),
114
+ "USES_TOOL": ("tool_call", "tool_selected"),
115
+ "HAS_TOOL_INPUT": ("tool_call", "input_observed"),
116
+ "OBSERVED_TOOL_INPUT": ("tool_call", "input_observed"),
117
+ "OBSERVED_TOOL_INPUT_BEFORE_EXECUTION": ("tool_call", "input_observed_before_execution"),
118
+ "OBSERVED_TOOL_INPUT_AFTER_EXECUTION": ("tool_call", "input_observed_after_execution"),
119
+ "OBSERVED_TOOL_INPUT_FROM_PROVIDER_EVENT": ("tool_call", "event_input_observed"),
120
+ "HAS_TOOL_OUTPUT": ("tool_call", "output_observed"),
121
+ "RECEIVED_TOOL_OUTPUT": ("tool_call", "output_observed"),
122
+ "RECEIVED_TOOL_OUTPUT_FROM_PROVIDER_EVENT": ("tool_call", "event_output_observed"),
123
+ "MODEL_RECEIVED_TOOL_RESULT": ("tool_call", "model_visible_result_observed"),
124
+ "RECEIVED_TOOL_ERROR": ("tool_call", "error_observed"),
125
+ "OBSERVED_TOOL_ERROR": ("tool_call", "error_observed"),
126
+ "RECEIVED_TOOL_ERROR_FROM_PROVIDER_EVENT": ("tool_call", "event_error_observed"),
127
+ "TOOL_CALL_SUCCEEDED": ("tool_call", "succeeded"),
128
+ "TOOL_CALL_RETURNED": ("tool_call", "returned"),
129
+ "TOOL_CALL_FAILED": ("tool_call", "failed"),
130
+ "TOOL_RESULT_RETURNED": ("tool_result", "returned"),
131
+ "TOOL_RESULT_REPORTED_ERROR": ("tool_result", "provider_reported_error"),
132
+ "REQUESTED_PERMISSION_FOR_TOOL_INPUT": ("permission", "requested"),
133
+ "OBSERVED_PERMISSION_REQUEST": ("permission", "requested"),
134
+ "OBSERVED_PERMISSION_REPLY": ("permission", "replied"),
135
+ "PERMISSION_TARGETS_TOOL_CALL": ("permission", "tool_call_targeted"),
136
+ "PERMISSION_DENIED_TOOL_CALL": ("permission", "denied"),
137
+ "OBSERVED_PERMISSION_TOOL_INPUT": ("permission", "tool_input_observed"),
138
+ "OBSERVED_DENIED_TOOL_INPUT": ("permission", "denied_tool_input_observed"),
139
+ "OBSERVED_PERMISSION_DENIAL_REASON": ("permission", "denial_reason_observed"),
140
+ "DECLARED_COMMAND": ("shell_command", "declared"),
141
+ "OWNED_AGENT_OPERATION": ("agent_operation", "agent_owned"),
142
+ "OWNED_TERMINAL_SESSION": ("terminal_session", "agent_owned"),
143
+ "CREATED_TERMINAL_SESSION": ("terminal_session", "created"),
144
+ "HAS_TERMINAL_OPERATION": ("terminal_session", "operation_observed"),
145
+ "OBSERVED_SHELL_COMMAND_BEFORE_EXECUTION": ("shell_command", "before_execution"),
146
+ "OBSERVED_SHELL_COMMAND_AFTER_EXECUTION": ("shell_command", "after_execution"),
147
+ "RECEIVED_SHELL_OUTPUT": ("shell_command", "output_observed"),
148
+ "OBSERVED_COMMAND": ("shell_command", "observed"),
149
+ "OBSERVED_COMMAND_ARGUMENTS": ("shell_command", "arguments_observed"),
150
+ "OBSERVED_COMMAND_PARTS": ("shell_command", "parts_observed"),
151
+ "VIA_MCP": ("mcp", "invoked"),
152
+ "OBSERVED_MCP_SERVER_COMMAND": ("mcp", "server_command_observed"),
153
+ "OBSERVED_MCP_TOOL_INPUT": ("mcp", "tool_input_observed"),
154
+ "RECEIVED_MCP_TOOL_RESULT": ("mcp", "tool_result_observed"),
155
+ "OBSERVED_MCP_ELICITATION": ("mcp_elicitation", "requested"),
156
+ "OBSERVED_MCP_ELICITATION_RESULT": ("mcp_elicitation", "result_observed"),
157
+ "OBSERVED_ELICITATION_MESSAGE": ("mcp_elicitation", "message_observed"),
158
+ "OBSERVED_ELICITATION_SCHEMA": ("mcp_elicitation", "schema_observed"),
159
+ "OBSERVED_ELICITATION_URL": ("mcp_elicitation", "url_observed"),
160
+ "OBSERVED_ELICITATION_CONTENT": ("mcp_elicitation", "result_content_observed"),
161
+ "OBSERVED_FILE_CONTENT_BEFORE_READ": ("file_read", "pre_read_content_observed"),
162
+ "OBSERVED_FILE_EDITS": ("file_write", "edits_observed"),
163
+ "OBSERVED_FILE_CHANGE": ("file", "change_observed"),
164
+ "LOADED_INSTRUCTION_FILE": ("instruction", "loaded"),
165
+ "SPAWNED_SUBAGENT": ("subagent", "started"),
166
+ "RETURNED_TO": ("subagent", "returned"),
167
+ "REQUESTED_SUBTASK": ("subagent", "task_requested"),
168
+ "TARGETS_AGENT_PROFILE": ("subagent", "target_profile"),
169
+ "USED_AGENT_PROFILE": ("subagent", "agent_profile"),
170
+ "HAS_SUBTASK_PROMPT": ("subagent", "task_prompt_observed"),
171
+ "HAS_SUBTASK_DESCRIPTION": ("subagent", "task_description_observed"),
172
+ "OBSERVED_SUBAGENT_TASK": ("subagent", "task_observed"),
173
+ "OBSERVED_SUBAGENT_DESCRIPTION": ("subagent", "description_observed"),
174
+ "RECEIVED_SUBAGENT_SUMMARY": ("subagent", "summary_observed"),
175
+ "OBSERVED_TEAMMATE_IDLE": ("teammate_state", "idle_observed"),
176
+ "DECLARES_AGENT_TRACE_VISIBILITY": ("agent_trace_capability", "declared"),
177
+ "OBSERVED_PROVIDER_METADATA": ("provider_metadata", "observed"),
178
+ "OBSERVED_PROVIDER_EVENT": ("provider_event", "observed"),
179
+ "OBSERVED_PROVIDER_SESSION_STATUS": ("provider_session", "status_observed"),
180
+ "OBSERVED_PROVIDER_SESSION_IDLE": ("provider_session", "idle_observed"),
181
+ "OBSERVED_PROVIDER_SESSION_ERROR": ("provider_session", "error_observed"),
182
+ "OBSERVED_SESSION_DIFF": ("session_diff", "observed"),
183
+ "OBSERVED_TODO_STATE": ("todo_state", "observed"),
184
+ "OBSERVED_NOTIFICATION": ("notification", "observed"),
185
+ "OBSERVED_NOTIFICATION_MESSAGE": ("notification", "message_observed"),
186
+ "OBSERVED_NOTIFICATION_TITLE": ("notification", "title_observed"),
187
+ "OBSERVED_CONFIG_CHANGE": ("configuration", "changed"),
188
+ "CHANGED_WORKING_DIRECTORY": ("working_directory", "changed"),
189
+ "ADDED_WORKING_DIRECTORY": ("working_directory", "added"),
190
+ "REMOVED_WORKTREE": ("worktree", "removed"),
191
+ "OBSERVED_COMPACTION_CONTEXT": ("context_compaction", "context_observed"),
192
+ "OBSERVED_COMPACTION_PROMPT": ("context_compaction", "prompt_observed"),
193
+ "OBSERVED_PRE_COMPACTION": ("context_compaction", "pre_observed"),
194
+ "COMPACTED_CONTEXT": ("context_compaction", "completed"),
195
+ "OBSERVED_COMPACTION_INSTRUCTIONS": ("context_compaction", "instructions_observed"),
196
+ "OBSERVED_COMPACTION_SUMMARY": ("context_compaction", "summary_observed"),
197
+ "INSTALLED_COMPACTION": ("context_compaction", "installed"),
198
+ "INSTALLED_COMPACTION_IN_TURN": ("context_compaction", "installed_in_turn"),
199
+ "MARKED_BY_CONVERSATION_ITEM": ("context_compaction", "marker_observed"),
200
+ "INPUT_TO_COMPACTION": ("context_compaction", "input_observed"),
201
+ "INSTALLED_REPLACEMENT_ITEM": ("context_compaction", "replacement_installed"),
202
+ "COMPUTED_BY_COMPACTION_REQUEST": ("context_compaction", "request_linked"),
203
+ "MADE_COMPACTION_REQUEST": ("context_compaction", "request_made"),
204
+ "REQUESTED_COMPACTION_IN_TURN": ("context_compaction", "requested_in_turn"),
205
+ "HAS_COMPACTION_REQUEST_PAYLOAD": ("context_compaction", "request_payload_observed"),
206
+ "HAS_COMPACTION_RESPONSE_PAYLOAD": ("context_compaction", "response_payload_observed"),
207
+ }
208
+
209
+
210
+ _FILE_READ_TOOLS = frozenset({"read", "read_file"})
211
+ _FILE_WRITE_TOOLS = frozenset(
212
+ {"edit", "write", "notebookedit", "write_file", "replace", "apply_patch"}
213
+ )
214
+ _FILE_DELETE_TOOLS = frozenset({"delete", "delete_file", "remove", "unlink"})
215
+
216
+
217
+ def _provider(event: dict[str, Any]) -> str | None:
218
+ attributes = event.get("attributes")
219
+ if not isinstance(attributes, dict):
220
+ return None
221
+ value = attributes.get("provider")
222
+ if not isinstance(value, str):
223
+ return None
224
+ provider = value.strip().lower()
225
+ return provider if provider in SUPPORTED_PROVIDER_LIFECYCLES else None
226
+
227
+
228
+ def _declared_file_stage(event: dict[str, Any]) -> str | None:
229
+ target = event.get("target")
230
+ if not isinstance(target, dict) or target.get("type") != "file":
231
+ return None
232
+ source = event.get("source")
233
+ source_attributes = source.get("attributes") if isinstance(source, dict) else None
234
+ tool_name = source_attributes.get("tool_name") if isinstance(source_attributes, dict) else None
235
+ if not isinstance(tool_name, str) or not tool_name:
236
+ source_name = source.get("name") if isinstance(source, dict) else None
237
+ tool_name = source_name if isinstance(source_name, str) else ""
238
+ normalized = tool_name.strip().lower().replace("-", "_")
239
+ if normalized in _FILE_READ_TOOLS:
240
+ return "declared_read"
241
+ if normalized in _FILE_WRITE_TOOLS:
242
+ return "declared_write"
243
+ if normalized in _FILE_DELETE_TOOLS:
244
+ return "declared_delete"
245
+ return "declared_target"
246
+
247
+
248
+ def provider_lifecycle_annotation(
249
+ event: dict[str, Any],
250
+ ) -> ProviderLifecycleAnnotation | None:
251
+ """Classify provider evidence for cross-provider graph queries.
252
+
253
+ This function only classifies an already-observed provider event. It never
254
+ creates evidence, raises causal strength, links observations by timing, or
255
+ turns a declared/returned value into proof of successful execution.
256
+ """
257
+ provider = _provider(event)
258
+ if provider is None:
259
+ return None
260
+ relation = event.get("relation")
261
+ if not isinstance(relation, str) or not relation:
262
+ return None
263
+ if relation == "DECLARED_TARGET":
264
+ stage = _declared_file_stage(event)
265
+ return (
266
+ ProviderLifecycleAnnotation(provider, "file", stage)
267
+ if stage is not None
268
+ else None
269
+ )
270
+ if relation == "DISPLAYED_ASSISTANT_TEXT":
271
+ attributes = event.get("attributes")
272
+ final = attributes.get("final") if isinstance(attributes, dict) else None
273
+ return ProviderLifecycleAnnotation(
274
+ provider,
275
+ "assistant_response",
276
+ "final_display" if final is True else "display_chunk",
277
+ )
278
+ mapped = _RELATION_MAP.get(relation)
279
+ if mapped is None:
280
+ return None
281
+ kind, stage = mapped
282
+ return ProviderLifecycleAnnotation(provider, kind, stage)
@@ -0,0 +1,290 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import webbrowser
5
+ from collections.abc import Callable, Mapping
6
+ from dataclasses import dataclass
7
+ from pathlib import Path
8
+ from typing import Any
9
+ from uuid import uuid4
10
+
11
+ from .agent_bootstrap import AgentBootstrapResult, bootstrap_supported_agent
12
+ from .backends import BackendName
13
+ from .correlation import CorrelationResult, correlate_tool_process
14
+ from .graph import build_execution_graph, write_execution_graph
15
+ from .semantic import SemanticMergeResult, merge_semantic_sidecar
16
+ from .viewer_projection import strip_internal_hook_execution_graph, write_graph_html
17
+ from .workflow import RecordResult, record_to_viewer
18
+
19
+ _SEMANTIC_ENV = "EXECWEAVE_SEMANTIC_SIDECAR"
20
+
21
+ ProviderEnvironmentBuilder = Callable[[Path], Mapping[str, str]]
22
+ ProviderSemanticEnricher = Callable[[RecordResult, Path, Mapping[str, str]], object | None]
23
+
24
+
25
+ @dataclass(frozen=True)
26
+ class ProviderRecordResult:
27
+ runtime: RecordResult
28
+ specialized_observability: AgentBootstrapResult
29
+ provider_enrichment: dict[str, object] | None
30
+ semantic_status: str
31
+ semantic_sidecar: Path
32
+ merged_event_stream: Path | None
33
+ semantic_graph: Path | None
34
+ semantic_viewer: Path | None
35
+ semantic_merge: SemanticMergeResult | None
36
+ correlation_status: str
37
+ correlated_event_stream: Path | None
38
+ correlated_graph: Path | None
39
+ correlated_viewer: Path | None
40
+ correlation: CorrelationResult | None
41
+
42
+ def to_dict(self) -> dict[str, object]:
43
+ return {
44
+ "runtime": self.runtime.to_dict(),
45
+ "specialized_observability": self.specialized_observability.to_dict(),
46
+ "provider_enrichment": self.provider_enrichment,
47
+ "semantic_status": self.semantic_status,
48
+ "semantic_sidecar": str(self.semantic_sidecar),
49
+ "merged_event_stream": (
50
+ str(self.merged_event_stream) if self.merged_event_stream is not None else None
51
+ ),
52
+ "semantic_graph": str(self.semantic_graph) if self.semantic_graph is not None else None,
53
+ "semantic_viewer": str(self.semantic_viewer) if self.semantic_viewer is not None else None,
54
+ "semantic_merge": (
55
+ self.semantic_merge.to_dict() if self.semantic_merge is not None else None
56
+ ),
57
+ "correlation_status": self.correlation_status,
58
+ "correlated_event_stream": (
59
+ str(self.correlated_event_stream)
60
+ if self.correlated_event_stream is not None
61
+ else None
62
+ ),
63
+ "correlated_graph": (
64
+ str(self.correlated_graph) if self.correlated_graph is not None else None
65
+ ),
66
+ "correlated_viewer": (
67
+ str(self.correlated_viewer) if self.correlated_viewer is not None else None
68
+ ),
69
+ "correlation": self.correlation.to_dict() if self.correlation is not None else None,
70
+ }
71
+
72
+
73
+ def _artifact_paths(run_dir: Path) -> dict[str, Path]:
74
+ return {
75
+ "semantic_sidecar": run_dir / "semantic.jsonl",
76
+ "merged_event_stream": run_dir / "events.semantic.jsonl",
77
+ "semantic_graph": run_dir / "graph.semantic.json",
78
+ "semantic_viewer": run_dir / "viewer.semantic.html",
79
+ "correlated_event_stream": run_dir / "events.correlated.jsonl",
80
+ "correlated_graph": run_dir / "graph.correlated.json",
81
+ "correlated_viewer": run_dir / "viewer.correlated.html",
82
+ }
83
+
84
+
85
+ def _preflight(paths: list[Path], *, provider_name: str) -> None:
86
+ conflicts = [path for path in paths if path.exists() and path.stat().st_size > 0]
87
+ if conflicts:
88
+ rendered = ", ".join(str(path) for path in conflicts)
89
+ raise FileExistsError(
90
+ f"ExecWeave {provider_name} semantic artifacts already exist: {rendered}"
91
+ )
92
+
93
+
94
+ def _restore_environment(previous: Mapping[str, str | None]) -> None:
95
+ for key, value in previous.items():
96
+ if value is None:
97
+ os.environ.pop(key, None)
98
+ else:
99
+ os.environ[key] = value
100
+
101
+
102
+ def _enrichment_payload(value: object | None) -> dict[str, object] | None:
103
+ if value is None:
104
+ return None
105
+ to_dict = getattr(value, "to_dict", None)
106
+ if callable(to_dict):
107
+ rendered = to_dict()
108
+ if isinstance(rendered, dict):
109
+ return {str(key): child for key, child in rendered.items()}
110
+ if isinstance(value, dict):
111
+ return {str(key): child for key, child in value.items()}
112
+ return {"status": "completed", "result": str(value)}
113
+
114
+
115
+ def record_provider_to_viewer(
116
+ command: list[str],
117
+ *,
118
+ provider_name: str,
119
+ watch_root: str | Path,
120
+ output_dir: str | Path | None = None,
121
+ backend: BackendName = "auto",
122
+ poll_interval: float = 0.10,
123
+ collect_filesystem: bool = True,
124
+ collect_network: bool = True,
125
+ keep_raw_trace: bool = False,
126
+ correlation_window_ms: int = 3000,
127
+ open_browser: bool = False,
128
+ provider_environment_builder: ProviderEnvironmentBuilder | None = None,
129
+ post_runtime_semantic_enricher: ProviderSemanticEnricher | None = None,
130
+ ) -> ProviderRecordResult:
131
+ """Record runtime + provider semantic evidence into layered local artifacts.
132
+
133
+ Known supported Agent commands are bootstrapped before launch. Bootstrap is
134
+ fail-open: runtime collection still proceeds when specialized integration is
135
+ unavailable or cannot be configured. Raw runtime and semantic evidence remain
136
+ separate; correlation always derives a new stream and stays explicitly
137
+ inferred/non-causal.
138
+
139
+ Provider integrations may additionally opt the child process into richer local
140
+ diagnostic capture with ``provider_environment_builder`` and import that evidence
141
+ after the provider exits through ``post_runtime_semantic_enricher``. These hooks
142
+ are diagnostic and fail-open; their status is surfaced in ``provider_enrichment``.
143
+ """
144
+ if not command:
145
+ raise ValueError("command must not be empty")
146
+ if not provider_name.strip():
147
+ raise ValueError("provider_name must not be empty")
148
+ if correlation_window_ms <= 0:
149
+ raise ValueError("correlation_window_ms must be greater than zero")
150
+
151
+ root = Path(watch_root).expanduser().resolve()
152
+ run_dir = (
153
+ Path(output_dir).expanduser().resolve()
154
+ if output_dir is not None
155
+ else root / ".execweave" / "runs" / uuid4().hex
156
+ )
157
+ run_dir.mkdir(parents=True, exist_ok=True)
158
+ paths = _artifact_paths(run_dir)
159
+ _preflight(list(paths.values()), provider_name=provider_name)
160
+ specialized_observability = bootstrap_supported_agent(command)
161
+
162
+ semantic_sidecar = paths["semantic_sidecar"]
163
+ provider_environment: dict[str, str] = {}
164
+ if provider_environment_builder is not None:
165
+ raw_environment = provider_environment_builder(run_dir)
166
+ provider_environment = {
167
+ str(key): str(value)
168
+ for key, value in raw_environment.items()
169
+ if str(key) and value is not None
170
+ }
171
+
172
+ environment_updates = {_SEMANTIC_ENV: str(semantic_sidecar), **provider_environment}
173
+ previous_environment = {key: os.environ.get(key) for key in environment_updates}
174
+ os.environ.update(environment_updates)
175
+ try:
176
+ runtime = record_to_viewer(
177
+ command,
178
+ watch_root=root,
179
+ output_dir=run_dir,
180
+ backend=backend,
181
+ poll_interval=poll_interval,
182
+ collect_filesystem=collect_filesystem,
183
+ collect_network=collect_network,
184
+ keep_raw_trace=keep_raw_trace,
185
+ open_browser=False,
186
+ integrate_semantic=False,
187
+ )
188
+ finally:
189
+ _restore_environment(previous_environment)
190
+
191
+ provider_enrichment: dict[str, object] | None = None
192
+ if post_runtime_semantic_enricher is not None:
193
+ try:
194
+ enrichment_result = post_runtime_semantic_enricher(
195
+ runtime,
196
+ semantic_sidecar,
197
+ provider_environment,
198
+ )
199
+ provider_enrichment = _enrichment_payload(enrichment_result)
200
+ except Exception as exc: # diagnostic enrichment must never break the recorded run
201
+ provider_enrichment = {
202
+ "status": "import_failed",
203
+ "error_type": type(exc).__name__,
204
+ "detail": " ".join(str(exc).split())[:500],
205
+ }
206
+
207
+ if not semantic_sidecar.exists() or semantic_sidecar.stat().st_size == 0:
208
+ if open_browser:
209
+ webbrowser.open(runtime.viewer.resolve().as_uri())
210
+ return ProviderRecordResult(
211
+ runtime=runtime,
212
+ specialized_observability=specialized_observability,
213
+ provider_enrichment=provider_enrichment,
214
+ semantic_status="no_events",
215
+ semantic_sidecar=semantic_sidecar.resolve(),
216
+ merged_event_stream=None,
217
+ semantic_graph=None,
218
+ semantic_viewer=None,
219
+ semantic_merge=None,
220
+ correlation_status="not_run_no_semantic_events",
221
+ correlated_event_stream=None,
222
+ correlated_graph=None,
223
+ correlated_viewer=None,
224
+ correlation=None,
225
+ )
226
+
227
+ merged_event_stream = paths["merged_event_stream"]
228
+ semantic_graph = paths["semantic_graph"]
229
+ semantic_viewer = paths["semantic_viewer"]
230
+ correlated_event_stream = paths["correlated_event_stream"]
231
+ correlated_graph = paths["correlated_graph"]
232
+ correlated_viewer = paths["correlated_viewer"]
233
+
234
+ merge_result = merge_semantic_sidecar(
235
+ runtime.event_stream,
236
+ semantic_sidecar,
237
+ merged_event_stream,
238
+ )
239
+ execution_graph = strip_internal_hook_execution_graph(
240
+ build_execution_graph(merged_event_stream)
241
+ )
242
+ write_execution_graph(execution_graph, semantic_graph)
243
+ write_graph_html(execution_graph.to_dict(), semantic_viewer, open_browser=False)
244
+
245
+ correlation_result = correlate_tool_process(
246
+ merged_event_stream,
247
+ correlated_event_stream,
248
+ max_window_ms=correlation_window_ms,
249
+ )
250
+ correlated_execution_graph = strip_internal_hook_execution_graph(
251
+ build_execution_graph(correlated_event_stream)
252
+ )
253
+ correlation_metadata: dict[str, Any] = {
254
+ "correlation": correlation_result.to_dict(),
255
+ "provider_enrichment": provider_enrichment,
256
+ }
257
+ write_execution_graph(
258
+ correlated_execution_graph,
259
+ correlated_graph,
260
+ metadata=correlation_metadata,
261
+ )
262
+ correlated_graph_payload = correlated_execution_graph.to_dict()
263
+ correlated_graph_payload["metadata"] = correlation_metadata
264
+ write_graph_html(
265
+ correlated_graph_payload,
266
+ correlated_viewer,
267
+ open_browser=open_browser,
268
+ )
269
+
270
+ correlation_status = (
271
+ "correlated"
272
+ if correlation_result.correlated_tool_calls > 0
273
+ else "completed_no_matches"
274
+ )
275
+ return ProviderRecordResult(
276
+ runtime=runtime,
277
+ specialized_observability=specialized_observability,
278
+ provider_enrichment=provider_enrichment,
279
+ semantic_status="merged",
280
+ semantic_sidecar=semantic_sidecar.resolve(),
281
+ merged_event_stream=merged_event_stream.resolve(),
282
+ semantic_graph=semantic_graph.resolve(),
283
+ semantic_viewer=semantic_viewer.resolve(),
284
+ semantic_merge=merge_result,
285
+ correlation_status=correlation_status,
286
+ correlated_event_stream=correlated_event_stream.resolve(),
287
+ correlated_graph=correlated_graph.resolve(),
288
+ correlated_viewer=correlated_viewer.resolve(),
289
+ correlation=correlation_result,
290
+ )
@@ -0,0 +1,13 @@
1
+ """Reader provenance for CLI JSON, separate from the recorded producer version."""
2
+ from __future__ import annotations
3
+
4
+ from importlib.metadata import PackageNotFoundError, version
5
+
6
+
7
+ def reader_identity() -> dict[str, str]:
8
+ try:
9
+ installed = version("execweave")
10
+ except PackageNotFoundError:
11
+ from . import __version__
12
+ installed = __version__
13
+ return {"name": "execweave", "version": installed}