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,283 @@
1
+ from __future__ import annotations
2
+
3
+ from .viewer_conversation_sync import SYNC_STATE_JS, SYNC_REFRESH_JS, SYNC_LIFECYCLE_JS
4
+ from . import _dashboard_shell_base as _base
5
+ from . import viewer_projection_base as _viewer_projection_base
6
+ from .viewer_flow_canvas import inject_flow_canvas
7
+ from .viewer_workflow_mode import inject_workflow_mode
8
+ from .viewer_content_health import inject_content_health
9
+ from .viewer_structure_share import inject_structure_share
10
+ from .viewer_run_guide import inject_run_guide
11
+ from .viewer_semantic_projection import project_provider_neutral_viewer_graph
12
+
13
+
14
+ def _route_bundle_edges_on_ordered_rails(html: str) -> str:
15
+ """Spread bundle members onto deterministic rails instead of one shared trunk.
16
+
17
+ The aggregate bundle semantics stay unchanged: members retain the same bundle key,
18
+ representative label, styling, and M-H-V-H route family. Only the vertical rail X
19
+ coordinate differs by source row and target slot, which keeps dense multi-agent
20
+ traffic traceable and prevents stacked trunks from turning into a visual braid.
21
+ """
22
+ needle = "trunkX=Math.max(sx+54,tx-82-(bundle.groupIndex%6)*24);"
23
+ replacement = (
24
+ "sourceRail=(typeof execweaveWorkflowRailOrder==='function'?execweaveWorkflowRailOrder(edge.source):null)"
25
+ "??Math.max(0,Number(sourceSpec.order)||0),"
26
+ "targetRail=Math.max(0,(Number(targetSpec.rank)||0)-(Number(sourceSpec.rank)||0)-1)"
27
+ "+((typeof execweaveWorkflowRailOrder==='function'?execweaveWorkflowRailOrder(edge.target):null)"
28
+ "??Math.max(0,Number(targetSpec.order)||0)),"
29
+ "railDistance=20+sourceRail*25+targetRail*10,"
30
+ "trunkX=tx>=sx?Math.min(tx,sx+railDistance):Math.max(tx,sx-railDistance);"
31
+ )
32
+ if needle not in html:
33
+ raise RuntimeError("bundle routing seam changed")
34
+ return html.replace(needle, replacement, 1)
35
+
36
+
37
+ def _start_in_fit_camera_mode(html: str) -> str:
38
+ """Follow live graph growth until the user explicitly takes the camera.
39
+
40
+ A live run can first render a tiny process-only snapshot and add file/network nodes
41
+ later. If that first automatic fit is followed by Manual mode, the tiny-snapshot
42
+ transform is frozen and later nodes can land under the inspector. Starting in Fit
43
+ keeps incremental growth in the graph viewport; existing pan/zoom handling still
44
+ switches to Manual on the user's first camera action.
45
+ """
46
+ seams = (
47
+ (
48
+ "protectedMode=false,cameraMode='manual',latestNodeId=null",
49
+ "protectedMode=false,cameraMode='fit',latestNodeId=null",
50
+ "camera mode state seam changed",
51
+ ),
52
+ (
53
+ '<button type="button" data-camera="manual" class="active">Manual</button><button type="button" data-camera="fit">Fit graph</button>',
54
+ '<button type="button" data-camera="manual">Manual</button><button type="button" data-camera="fit" class="active">Fit graph</button>',
55
+ "camera control markup seam changed",
56
+ ),
57
+ (
58
+ '<strong id="camera-label">Manual</strong>',
59
+ '<strong id="camera-label">Fit graph</strong>',
60
+ "camera label seam changed",
61
+ ),
62
+ )
63
+ for old, new, error in seams:
64
+ if html.count(old) != 1:
65
+ raise RuntimeError(error)
66
+ html = html.replace(old, new, 1)
67
+ return html
68
+
69
+
70
+ def _avoid_camera_fit_starvation(html: str) -> str:
71
+ """Guarantee a Fit pass during a dense live-delta burst.
72
+
73
+ The base scheduler debounces every delta by clearing the pending camera timer.
74
+ Native Windows telemetry can arrive faster than the 180 ms delay for long enough
75
+ that the fit never executes, leaving newly added endpoint nodes underneath the
76
+ inspector. Ordinary deltas now keep the first pending timer. Explicit force
77
+ scheduling can still replace it, preserving resize/resync behavior.
78
+ """
79
+ needle = (
80
+ "function scheduleCamera(force=false){clearTimeout(cameraTimer);"
81
+ "cameraTimer=setTimeout(()=>{if(cameraMode==='fit')fit(true);"
82
+ "else if(cameraMode==='follow')followLatest(force);updateJumpLatest()},180)}"
83
+ )
84
+ replacement = (
85
+ "function scheduleCamera(force=false){if(cameraTimer!==null){"
86
+ "if(!force)return;clearTimeout(cameraTimer)}cameraTimer=setTimeout(()=>{"
87
+ "cameraTimer=null;if(cameraMode==='fit')fit(true);"
88
+ "else if(cameraMode==='follow')followLatest(force);updateJumpLatest()},180)}"
89
+ )
90
+ if html.count(needle) != 1:
91
+ raise RuntimeError("camera scheduler seam changed")
92
+ return html.replace(needle, replacement, 1)
93
+
94
+
95
+ def _defer_camera_takeover_until_node_drag(html: str) -> str:
96
+ """Do not freeze Fit mode merely because a node was clicked.
97
+
98
+ The drag affordance historically called ``userTookCamera`` on pointer-down, before
99
+ it knew whether the reader intended to drag. A normal click could therefore switch
100
+ Fit to Manual and stop an in-flight fit animation. Fast native Windows telemetry
101
+ exposed the race: Process/File inspection could freeze the graph before a Network
102
+ endpoint had moved clear of the inspector. Keep pointer capture on press, but only
103
+ take the camera and move the node after the existing 3 px drag threshold is crossed.
104
+ """
105
+ pointer_down = """ event.stopPropagation();userTookCamera();stopAnimation();const point=execweaveGraphPoint(event);
106
+ execweaveNodeDrag={id:node.id,pointerId:event.pointerId,dx:point.x-current.x,dy:point.y-current.y,startX:event.clientX,startY:event.clientY,moved:false};
107
+ group.classList.add('dragging');try{group.setPointerCapture(event.pointerId)}catch(_){}"""
108
+ pointer_down_replacement = """ event.stopPropagation();
109
+ execweaveNodeDrag={id:node.id,pointerId:event.pointerId,originX:current.x,originY:current.y,startX:event.clientX,startY:event.clientY,moved:false};
110
+ try{group.setPointerCapture(event.pointerId)}catch(_){}"""
111
+ pointer_move = """ if(Math.abs(event.clientX-drag.startX)>3||Math.abs(event.clientY-drag.startY)>3)drag.moved=true;
112
+ const point=execweaveGraphPoint(event),next={x:point.x-drag.dx,y:point.y-drag.dy};positions.set(node.id,next);group.setAttribute('transform',`translate(${next.x} ${next.y})`);execweaveRefreshIncidentEdges(node.id);updateJumpLatest();"""
113
+ pointer_move_replacement = """ if(!drag.moved){
114
+ if(Math.abs(event.clientX-drag.startX)<=3&&Math.abs(event.clientY-drag.startY)<=3)return;
115
+ drag.moved=true;userTookCamera();stopAnimation();group.classList.add('dragging');
116
+ }
117
+ const scale=Math.max(.0001,Number(transform.scale)||1),next={x:drag.originX+(event.clientX-drag.startX)/scale,y:drag.originY+(event.clientY-drag.startY)/scale};positions.set(node.id,next);group.setAttribute('transform',`translate(${next.x} ${next.y})`);execweaveRefreshIncidentEdges(node.id);updateJumpLatest();"""
118
+ if html.count(pointer_down) != 1:
119
+ raise RuntimeError("node drag pointer-down seam changed")
120
+ if html.count(pointer_move) != 1:
121
+ raise RuntimeError("node drag pointer-move seam changed")
122
+ html = html.replace(pointer_down, pointer_down_replacement, 1)
123
+ return html.replace(pointer_move, pointer_move_replacement, 1)
124
+
125
+
126
+ def _preserve_readable_initial_camera(html: str) -> str:
127
+ """Use the same whole-graph Fit semantics for initial and explicit fitting.
128
+
129
+ Readability is addressed by evidence-preserving display clusters, not by
130
+ silently clipping nodes while the toolbar claims the entire graph fits.
131
+ """
132
+ signature = "function fit(animate=true){"
133
+ if html.count(signature) != 1:
134
+ raise RuntimeError("camera fit signature seam changed")
135
+ html = html.replace(signature, "function fit(animate=true,minScale=.07){", 1)
136
+
137
+ scale = (
138
+ "scale=Math.min(1.2,Math.max(.07,Math.min((box.width-72)/w,"
139
+ "(box.height-72)/h))),next="
140
+ )
141
+ scale_with_floor = (
142
+ "fitFloor=Math.min(1.2,Math.max(.07,Number(minScale)||.07)),"
143
+ "scale=Math.min(1.2,Math.max(fitFloor,Math.min((box.width-72)/w,"
144
+ "(box.height-72)/h))),next="
145
+ )
146
+ if html.count(scale) != 1:
147
+ raise RuntimeError("camera fit scale seam changed")
148
+ html = html.replace(scale, scale_with_floor, 1)
149
+
150
+ initial_fit = "if(!hasFitted&&positions.size){fit(false);hasFitted=true}"
151
+ if html.count(initial_fit) != 2:
152
+ raise RuntimeError("initial camera fit seams changed")
153
+ return html.replace(
154
+ initial_fit,
155
+ "if(!hasFitted&&positions.size){fit(false,.48);hasFitted=true}",
156
+ )
157
+
158
+
159
+ def _surface_provider_neutral_clusters(html: str) -> str:
160
+ """Expose collapsed files and model-call chronology in the shared inspector."""
161
+ helper_seam = "function nodeCards(node){"
162
+ if html.count(helper_seam) != 1:
163
+ raise RuntimeError("agent panel nodeCards seam changed")
164
+ helper = r"""
165
+ function execweaveInferenceHistory(a){
166
+ const rows=Array.isArray(a.viewer_inference_occurrences)?a.viewer_inference_occurrences:[];
167
+ return rows.slice().sort((x,y)=>String(x?.first_seen||'').localeCompare(String(y?.first_seen||''))).map((item,index)=>{
168
+ const messages=Array.isArray(item?.messages)?item.messages:[];
169
+ const user=messages.find(message=>String(message?.sender||'')==='user'||/user|request|prompt/i.test(String(message?.kind||'')));
170
+ const answers=messages.filter(message=>String(message?.phase||'')==='final_answer'||String(message?.sender||'')==='assistant'||/assistant|response|final/i.test(String(message?.kind||'')));
171
+ const answer=answers.length?answers[answers.length-1]:null;
172
+ const refs=Array.isArray(item?.content_references)?item.content_references:[];
173
+ const when=moment(item?.first_seen||item?.last_seen);
174
+ const head=[when,`call ${index+1}`].filter(Boolean).join(' · ');
175
+ const lines=[head];
176
+ if(user?.text)lines.push(`Prompt: ${user.text}`);
177
+ if(answer?.text)lines.push(`Answer: ${answer.text}`);
178
+ if(!user?.text&&!answer?.text&&refs.length)lines.push(`Evidence: ${refs.map(ref=>ref?.content_kind||ref?.relation||ref?.id).filter(Boolean).join(', ')}`);
179
+ return lines.join('\n');
180
+ }).join('\n\n');
181
+ }
182
+ function execweaveFileClusterHistory(a){
183
+ const rows=Array.isArray(a.entries)?a.entries:[];
184
+ return rows.slice().sort((x,y)=>String(x?.path||'').localeCompare(String(y?.path||''))).map(item=>{
185
+ const when=moment(item?.last_seen||item?.first_seen),kind=String(item?.type||'file');
186
+ return [when,kind,item?.path||item?.name||item?.id].filter(Boolean).join(' · ');
187
+ }).join('\n');
188
+ }
189
+ """ + helper_seam
190
+ html = html.replace(helper_seam, helper, 1)
191
+
192
+ branch_seam = """ }else if(kind==='file'){
193
+ add('Path',node?.name);
194
+ add('Observed',fileHistory(String(node?.id||'')));
195
+ }else if(kind==='tool_call'){"""
196
+ branch_replacement = """ }else if(kind==='file'){
197
+ add('Path',node?.name);
198
+ add('Observed',fileHistory(String(node?.id||'')));
199
+ }else if(kind==='file_cluster'){
200
+ add('Files / directories',`${Number(a.member_count||0)} collapsed entries`);
201
+ add('Observed',execweaveFileClusterHistory(a));
202
+ }else if(kind==='model'){
203
+ add('Model',node?.name);
204
+ add('Provider',a.provider||a.provider_name);
205
+ add('Inference calls',a.viewer_inference_count);
206
+ if(a.model_resource_id)add('Shared model resource',a.model_resource_id);
207
+ // Chronology is rendered below as persistent per-invocation accordions.
208
+ }else if(kind==='tool_call'){"""
209
+ if html.count(branch_seam) != 1:
210
+ raise RuntimeError("agent panel file/model branch seam changed")
211
+ return html.replace(branch_seam, branch_replacement, 1)
212
+
213
+
214
+ def _stop_conversation_polling_after_finish(html: str) -> str:
215
+ """Freeze polling after one authoritative finished conversation sync attempt.
216
+
217
+ The live graph announces ``live_finished`` while its HTTP server is still alive.
218
+ Stop periodic polling immediately, wait for any in-flight refresh, then perform
219
+ exactly one final fetch from the finished raw graph. A failed fetch must remain a
220
+ failed synchronization: stopping the polling loop is not itself proof that the
221
+ selected conversation matches the finalized viewer.
222
+ """
223
+
224
+ seams = (
225
+ (
226
+ "let selectedNode=null,refreshing=false,selectedConversationSignature='';",
227
+ SYNC_STATE_JS,
228
+ "agent conversation polling state seam changed",
229
+ ),
230
+ (
231
+ "async function refresh(){if(window.__execweaveStaticMode||refreshing)return;refreshing=true;try{const headers={};if(window.__execweaveToken)headers['X-ExecWeave-Token']=window.__execweaveToken;const response=await fetch('/conversations.json',{cache:'no-store',headers});if(response.ok){const payload=await response.json();setEntries(payload?.entries)}}catch(_){}finally{refreshing=false}}",
232
+ SYNC_REFRESH_JS,
233
+ "agent conversation refresh seam changed",
234
+ ),
235
+ (
236
+ "if(!window.__execweaveStaticMode)setInterval(()=>{if(selectedNode)refresh()},800);",
237
+ "if(!window.__execweaveStaticMode)conversationRefreshTimer=setInterval(()=>{if(selectedNode&&!conversationFinishing&&!conversationPollingFinished)refresh()},800);",
238
+ "agent conversation interval seam changed",
239
+ ),
240
+ (
241
+ "const previous=window.__execweaveDashboard||{};window.__execweaveDashboard={...previous,onPayload(data){previous.onPayload?.(data);if(selectedNode)refresh()},onFinished(){previous.onFinished?.();if(selectedNode)refresh()}};",
242
+ SYNC_LIFECYCLE_JS,
243
+ "agent conversation lifecycle seam changed",
244
+ ),
245
+ (
246
+ "const agentPanelAPI={render,setEntries,refresh};",
247
+ "const agentPanelAPI={render,setEntries,refresh,finishConversationPolling,stopConversationPolling,whenFinished:()=>conversationFinishPromise,isFinishedSynchronized:()=>conversationPollingFinished&&conversationFinishSynchronized&&conversationScopeKey===JSON.stringify(conversationScope()),getSynchronizationStatus:synchronizationStatus};",
248
+ "agent conversation export seam changed",
249
+ ),
250
+ )
251
+ for old, new, error in seams:
252
+ if html.count(old) != 1:
253
+ raise RuntimeError(error)
254
+ html = html.replace(old, new, 1)
255
+ return html
256
+
257
+
258
+ _viewer_projection_base.project_viewer_graph = project_provider_neutral_viewer_graph
259
+
260
+ _base.DASHBOARD_HTML = inject_flow_canvas(
261
+ _stop_conversation_polling_after_finish(
262
+ _surface_provider_neutral_clusters(
263
+ _defer_camera_takeover_until_node_drag(
264
+ _preserve_readable_initial_camera(
265
+ _avoid_camera_fit_starvation(
266
+ _start_in_fit_camera_mode(
267
+ _route_bundle_edges_on_ordered_rails(_base.DASHBOARD_HTML)
268
+ )
269
+ )
270
+ )
271
+ )
272
+ )
273
+ )
274
+ )
275
+ _base.DASHBOARD_HTML = inject_structure_share(inject_content_health(inject_workflow_mode(_base.DASHBOARD_HTML)))
276
+ _base.DASHBOARD_HTML = inject_run_guide(_base.DASHBOARD_HTML)
277
+ DASHBOARD_HTML = _base.DASHBOARD_HTML
278
+ render_static_dashboard_html = _base.render_static_dashboard_html
279
+
280
+
281
+ def __getattr__(name: str):
282
+ """Preserve access to internal helpers while this acceptance shim is isolated."""
283
+ return getattr(_base, name)
@@ -0,0 +1,94 @@
1
+ """Bounded publication of an in-process finalization result, not a new audit.
2
+
3
+ The receipt records what the existing verifier checked at export time. Publishing
4
+ it performs no filesystem reads and does not assert that files remain unchanged.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import re
10
+ from typing import Any
11
+
12
+ _HASH = re.compile(r"[0-9a-f]{64}")
13
+ _PRIMARY = ("graph.json", "conversations.json", "viewer.html")
14
+
15
+
16
+ def summarize_finalization(report: Any) -> dict[str, Any]:
17
+ result: dict[str, Any] = {
18
+ "schema_version": "0.1",
19
+ "scope": "recorded_finalization_result",
20
+ "state": "unavailable",
21
+ "reason": "no_finalization_report",
22
+ "verified_file_count": None,
23
+ "unique_file_count": None,
24
+ "error_count": None,
25
+ "diagnostics": [],
26
+ "rechecked_now": False,
27
+ }
28
+ if not isinstance(report, dict):
29
+ return result
30
+ if report.get("schema_version") != "0.2":
31
+ result["reason"] = "unsupported_finalization_schema"
32
+ return result
33
+ state = report.get("state")
34
+ if state in ("recording", "exporting"):
35
+ result.update(state=state, reason="export_not_terminal")
36
+ return result
37
+ if state not in ("complete", "incomplete", "failed"):
38
+ result["reason"] = "invalid_finalization_state"
39
+ return result
40
+ content = report.get("content_integrity")
41
+ content = content if isinstance(content, dict) else {}
42
+ for key in ("verified_file_count", "unique_file_count", "error_count"):
43
+ value = content.get(key)
44
+ result[key] = value if type(value) is int and 0 <= value <= 2**53 - 1 else None
45
+ errors = content.get("errors")
46
+ if isinstance(errors, list):
47
+ for entry in errors[:20]:
48
+ code = entry.get("code") if isinstance(entry, dict) else None
49
+ if isinstance(code, str) and re.fullmatch(r"[a-z_]{1,80}", code):
50
+ result["diagnostics"].append(code)
51
+ if state != "complete":
52
+ result.update(state=state, reason="recorded_export_failure")
53
+ return result
54
+
55
+ # A contradictory/incomplete receipt cannot be promoted merely by state=complete.
56
+ artifacts, indexes = report.get("artifacts"), content.get("index_files")
57
+ valid = (
58
+ isinstance(artifacts, dict)
59
+ and isinstance(indexes, dict)
60
+ and report.get("missing") == []
61
+ and report.get("artifact_errors") == {}
62
+ and content.get("schema_version") == "0.1"
63
+ and content.get("scope") == "declared_graph_and_conversation_content"
64
+ and content.get("state") == "complete"
65
+ and result["error_count"] == 0
66
+ and result["verified_file_count"] is not None
67
+ and result["verified_file_count"] == result["unique_file_count"]
68
+ and content.get("reference_count_truncated") is False
69
+ and content.get("errors_truncated") is False
70
+ and errors == []
71
+ and isinstance(content.get("verified_files"), dict)
72
+ and len(content["verified_files"]) == result["verified_file_count"]
73
+ )
74
+ if valid:
75
+ for name in _PRIMARY:
76
+ item = artifacts.get(name)
77
+ if not isinstance(item, dict):
78
+ valid = False
79
+ break
80
+ size, digest = item.get("size_bytes"), item.get("sha256")
81
+ if (
82
+ type(size) is not int
83
+ or size <= 0
84
+ or not isinstance(digest, str)
85
+ or not _HASH.fullmatch(digest)
86
+ ):
87
+ valid = False
88
+ if name != "viewer.html" and indexes.get(name) != item:
89
+ valid = False
90
+ if not valid:
91
+ result.update(state="unavailable", reason="inconsistent_finalization_report")
92
+ else:
93
+ result.update(state="complete", reason="recorded_export_verification")
94
+ return result
execweave/entry.py ADDED
@@ -0,0 +1,98 @@
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+ import argparse
5
+ import json
6
+ import os
7
+
8
+ from . import cli
9
+ from .agent_bootstrap import AgentBootstrapResult, bootstrap_supported_agent, inspect_supported_agent
10
+
11
+ _LIVE_VALUE_OPTIONS = {"--watch-root", "--output-dir", "--interval", "--port", "--linger"}
12
+ _LIVE_FLAG_OPTIONS = {"--no-files", "--no-network", "--open", "--capture-content", "--metadata-only"}
13
+
14
+
15
+ def _live_command(args: list[str]) -> list[str]:
16
+ if not args or args[0] != "live":
17
+ return []
18
+ tokens = args[1:]
19
+ if "--" in tokens:
20
+ separator = tokens.index("--")
21
+ return tokens[separator + 1 :]
22
+
23
+ index = 0
24
+ while index < len(tokens):
25
+ token = tokens[index]
26
+ if token in _LIVE_FLAG_OPTIONS:
27
+ index += 1
28
+ continue
29
+ if token in _LIVE_VALUE_OPTIONS:
30
+ index += 2
31
+ continue
32
+ if any(token.startswith(f"{option}=") for option in _LIVE_VALUE_OPTIONS):
33
+ index += 1
34
+ continue
35
+ if token.startswith("-"):
36
+ return []
37
+ return tokens[index:]
38
+ return []
39
+
40
+
41
+ def _announce_bootstrap(result: AgentBootstrapResult) -> None:
42
+ provider = result.provider or "command"
43
+ if result.status in {"active", "configured_unverified"}:
44
+ action = "updated" if result.changed else "ready"
45
+ print(
46
+ "ExecWeave specialized: configured, delivery unverified "
47
+ f"({provider}; configuration {action}; zero delivered events will be reported).",
48
+ file=sys.stderr,
49
+ flush=True,
50
+ )
51
+ return
52
+ if result.status == "bootstrap_failed":
53
+ detail = f" {result.detail}" if result.detail else ""
54
+ print(
55
+ "ExecWeave specialized: bootstrap failed "
56
+ f"({provider}); continuing with OS runtime evidence.{detail}",
57
+ file=sys.stderr,
58
+ flush=True,
59
+ )
60
+ return
61
+ detail = f" {result.detail}." if result.detail else ""
62
+ print(
63
+ "ExecWeave specialized: unavailable "
64
+ f"({provider}); collecting OS runtime evidence only.{detail}",
65
+ file=sys.stderr,
66
+ flush=True,
67
+ )
68
+
69
+
70
+ def main(argv: list[str] | None = None) -> int:
71
+ args = list(sys.argv[1:] if argv is None else argv)
72
+ if args and args[0] == "hooks":
73
+ parser = argparse.ArgumentParser(prog="execweave hooks")
74
+ parser.add_argument("action", choices=["install", "status"])
75
+ parser.add_argument("provider", choices=["claude", "codex", "antigravity", "cursor", "opencode"])
76
+ options = parser.parse_args(args[1:])
77
+ if options.action == "install":
78
+ if hasattr(os, "geteuid") and os.geteuid() == 0:
79
+ print("Refusing root hook installation. Run as the normal user without sudo.", file=sys.stderr)
80
+ return 2
81
+ result = bootstrap_supported_agent([options.provider])
82
+ else:
83
+ result = inspect_supported_agent([options.provider])
84
+ print(json.dumps(result.to_dict(), indent=2, sort_keys=True))
85
+ return 1 if result.status == "bootstrap_failed" else 0
86
+ if args and args[0] == "top":
87
+ from .top_cli import main as top_main
88
+
89
+ return top_main(args[1:])
90
+ if args and args[0] in {"view", "graph-view"}:
91
+ from .view_cli import main as view_main
92
+
93
+ return view_main(args[1:])
94
+ if args and args[0] == "live":
95
+ command = _live_command(args)
96
+ if command:
97
+ _announce_bootstrap(inspect_supported_agent(command))
98
+ return cli.main(args)
@@ -0,0 +1,113 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import asdict, dataclass
4
+
5
+ AVAILABLE = "available"
6
+ COMPLETE_FROM_SURFACE = "complete_from_surface"
7
+ SUMMARY = "summary"
8
+ REDACTED = "redacted"
9
+ OPAQUE_ENCRYPTED = "opaque_encrypted"
10
+ OPAQUE_SIGNED = "opaque_signed"
11
+ NOT_EXPOSED = "not_exposed"
12
+ NOT_OBSERVED = "not_observed"
13
+ CAPTURE_DISABLED = "capture_disabled"
14
+ CAPTURE_INTERRUPTED = "capture_interrupted"
15
+ UNKNOWN = "unknown"
16
+
17
+ FIELD_AVAILABILITY = (
18
+ AVAILABLE,
19
+ COMPLETE_FROM_SURFACE,
20
+ SUMMARY,
21
+ REDACTED,
22
+ OPAQUE_ENCRYPTED,
23
+ OPAQUE_SIGNED,
24
+ NOT_EXPOSED,
25
+ NOT_OBSERVED,
26
+ CAPTURE_DISABLED,
27
+ CAPTURE_INTERRUPTED,
28
+ UNKNOWN,
29
+ )
30
+
31
+ LOCALLY_DECRYPTABLE = "locally_decryptable"
32
+ NO_LOCAL_DECRYPTOR_OBSERVED = "no_local_decryptor_observed"
33
+ PROVIDER_DOCUMENTED_UNAVAILABLE = "provider_documented_unavailable"
34
+ DECRYPTABILITY_UNKNOWN = "unknown"
35
+
36
+ DECRYPTABILITY = (
37
+ LOCALLY_DECRYPTABLE,
38
+ NO_LOCAL_DECRYPTOR_OBSERVED,
39
+ PROVIDER_DOCUMENTED_UNAVAILABLE,
40
+ DECRYPTABILITY_UNKNOWN,
41
+ )
42
+
43
+ EVIDENCE_DIRECT_OBSERVATION = "direct_observation"
44
+ EVIDENCE_DIRECT_VERIFIABLE = "direct_verifiable_evidence"
45
+ EVIDENCE_PROVIDER_DOCUMENTATION = "provider_documentation"
46
+ EVIDENCE_INFERENCE = "inference"
47
+ EVIDENCE_NO_DATA = "no_data"
48
+
49
+ EVIDENCE_STRENGTH = (
50
+ EVIDENCE_DIRECT_OBSERVATION,
51
+ EVIDENCE_DIRECT_VERIFIABLE,
52
+ EVIDENCE_PROVIDER_DOCUMENTATION,
53
+ EVIDENCE_INFERENCE,
54
+ EVIDENCE_NO_DATA,
55
+ )
56
+
57
+ _STRONG_UNAVAILABLE_EVIDENCE = frozenset(
58
+ {EVIDENCE_DIRECT_VERIFIABLE, EVIDENCE_PROVIDER_DOCUMENTATION}
59
+ )
60
+
61
+
62
+ @dataclass(frozen=True)
63
+ class FieldEvidence:
64
+ """One field-level availability claim, separate from conversation completeness."""
65
+
66
+ field: str
67
+ availability: str
68
+ decryptability: str = DECRYPTABILITY_UNKNOWN
69
+ evidence_source: str = ""
70
+ evidence_strength: str = EVIDENCE_DIRECT_OBSERVATION
71
+ notes: str | None = None
72
+
73
+ def __post_init__(self) -> None:
74
+ if not self.field:
75
+ raise ValueError("field must not be empty")
76
+ validate_availability(self.availability)
77
+ validate_decryptability(self.decryptability, self.evidence_strength)
78
+ if self.evidence_strength not in EVIDENCE_STRENGTH:
79
+ raise ValueError(f"unsupported evidence strength: {self.evidence_strength}")
80
+
81
+ def to_dict(self) -> dict[str, object]:
82
+ return asdict(self)
83
+
84
+
85
+ def validate_availability(value: str) -> str:
86
+ if value not in FIELD_AVAILABILITY:
87
+ raise ValueError(f"unsupported field availability: {value}")
88
+ return value
89
+
90
+
91
+ def validate_decryptability(value: str, evidence_strength: str) -> str:
92
+ if value not in DECRYPTABILITY:
93
+ raise ValueError(f"unsupported decryptability: {value}")
94
+ if (
95
+ value == PROVIDER_DOCUMENTED_UNAVAILABLE
96
+ and evidence_strength not in _STRONG_UNAVAILABLE_EVIDENCE
97
+ ):
98
+ raise ValueError(
99
+ "provider_documented_unavailable requires provider documentation "
100
+ "or direct verifiable evidence"
101
+ )
102
+ return value
103
+
104
+
105
+ def readable_availability(*, complete_from_surface: bool) -> str:
106
+ """Apply the fixed precedence between readable field states.
107
+
108
+ A readable field is ``complete_from_surface`` only when the observed surface
109
+ boundary is known and the complete value supplied by that surface was kept.
110
+ Otherwise the weaker ``available`` state is used.
111
+ """
112
+
113
+ return COMPLETE_FROM_SURFACE if complete_from_surface else AVAILABLE