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,630 @@
1
+ from __future__ import annotations
2
+
3
+ from .viewer_fold_state import FOLD_STATE_JS
4
+ from .viewer_history_browser import HISTORY_BROWSER_CSS, HISTORY_BROWSER_JS
5
+ from .viewer_agent_panel_antigravity import ANTIGRAVITY_CHILD_ROUNDS_JS
6
+ from .viewer_agent_panel_claude import CLAUDE_CHILD_ROUNDS_JS
7
+ from .viewer_agent_panel_codex import CODEX_CHILD_ROUNDS_JS
8
+ from .viewer_agent_panel_cursor import CURSOR_CHILD_ROUNDS_JS
9
+ from .viewer_agent_panel_default import DEFAULT_CHILD_ROUNDS_JS
10
+ from .viewer_agent_panel_ollama import OLLAMA_CHILD_ROUNDS_JS
11
+ from .viewer_agent_panel_opencode import OPENCODE_CHILD_ROUNDS_JS
12
+
13
+ _AGENT_PANEL_CSS = r"""
14
+ #inspector .inspector-section:first-child{display:none!important}
15
+ #inspector .inspector-section:nth-child(2)>.eyebrow{display:none!important}
16
+ #inspector .raw-toggle{display:none!important}
17
+ #open-final{display:none!important}
18
+ .execweave-agent-view{display:grid;gap:12px}
19
+ .execweave-agent-card{border:1px solid var(--border);border-radius:10px;background:var(--panel2);overflow:hidden}
20
+ .execweave-agent-label,.execweave-communication-label{padding:9px 11px;border-bottom:1px solid var(--border);font-size:10px;font-weight:800;letter-spacing:.07em;text-transform:uppercase;color:var(--muted)}
21
+ .execweave-agent-body,.execweave-message-body{margin:0;padding:11px 12px;white-space:pre-wrap;overflow-wrap:anywhere;font:12px/1.55 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:var(--text)}
22
+ .execweave-agent-empty{color:var(--muted);font-style:italic}
23
+ .execweave-agent-rounds{display:grid;gap:10px}
24
+ .execweave-agent-round{display:grid;gap:12px}
25
+ :is(.execweave-agent-older,.execweave-agent-latest){border:1px solid var(--border);border-radius:10px;background:var(--panel2)}
26
+ :is(.execweave-agent-older,.execweave-agent-latest)>summary{cursor:pointer;list-style:none;padding:9px 11px;font-size:11px;color:var(--muted);overflow-wrap:anywhere}
27
+ :is(.execweave-agent-older,.execweave-agent-latest)>summary::-webkit-details-marker{display:none}
28
+ :is(.execweave-agent-older,.execweave-agent-latest)>summary::before{content:"\25b8 ";color:var(--muted)}
29
+ :is(.execweave-agent-older,.execweave-agent-latest)[open]>summary::before{content:"\25be "}
30
+ :is(.execweave-agent-older,.execweave-agent-latest)[open]>summary{border-bottom:1px solid var(--border)}
31
+ :is(.execweave-agent-older,.execweave-agent-latest)>.execweave-agent-round{padding:10px 11px 11px}
32
+ .execweave-agent-when{font-variant-numeric:tabular-nums;color:var(--text)}
33
+ .execweave-message-history{border:1px solid var(--border);border-radius:10px;background:var(--panel2);margin:6px 0}
34
+ .execweave-message-history>summary{cursor:pointer;padding:9px 11px;font-size:11px;color:var(--muted);overflow-wrap:anywhere}
35
+ """.strip()
36
+
37
+ _AGENT_PANEL_JS = r"""
38
+ (()=>{
39
+ const details=document.getElementById('details'),detailsEmpty=document.getElementById('details-empty');
40
+ if(!details||!detailsEmpty)return;
41
+ let entries=Array.isArray(window.__execweaveStaticConversations)?window.__execweaveStaticConversations:[];
42
+ let selectedNode=null,refreshing=false,selectedConversationSignature='';
43
+ const foldStateByAgent=new Map();
44
+ /*EXECWEAVE_HISTORY_BROWSER*/
45
+ const ROOT_NODE_IDS=new Set(['agent:Claude Code','agent:OpenAI Codex','agent:Codex','agent:Cursor','agent:OpenCode','agent:Antigravity','agent:Ollama','agent:ollama']);
46
+ const ENCRYPTED_NOTICE='Observed — plaintext not exposed by provider.';
47
+ const attrs=node=>node&&typeof node.attributes==='object'&&node.attributes?node.attributes:{};
48
+ const nodePath=node=>String(attrs(node).agent_path||attrs(node).child_agent_path||attrs(node).root_agent_path||node?.name||'').trim();
49
+ const agentKey=node=>String(node?.id||'')||nodePath(node);
50
+ const messageText=message=>typeof message?.text==='string'?message.text.trim():'';
51
+ const isEncrypted=message=>String(message?.content_state||'')==='provider_encrypted';
52
+ const isObserved=message=>!!message&&(isEncrypted(message)||!!messageText(message));
53
+ const displayText=message=>isEncrypted(message)?ENCRYPTED_NOTICE:messageText(message);
54
+ const isInjected=message=>String(message?.content_role||'')==='shared_injected_context';
55
+ const own=(message,path)=>!message?.sender||String(message.sender)===path;
56
+ const previewHasRootAuthority=preview=>!!preview&&preview.is_root===true&&String(preview.topology_state||'')!=='derived'&&String(preview.topology_evidence||'')!=='no_parent_evidence_observed';
57
+ const previewUsesRootRenderer=preview=>!!preview&&preview.is_root===true&&String(preview.agent_path||'')==='/root';
58
+ const nodeHasChildAuthority=node=>!!String(attrs(node).parent_agent_path||'').trim();
59
+ const legacyRootSignal=(node,path)=>path==='/root'||attrs(node).agent_role==='root'||attrs(node).root_agent_path==='/root';
60
+ const nodeHasRootAuthority=node=>!nodeHasChildAuthority(node)&&(legacyRootSignal(node,nodePath(node))||ROOT_NODE_IDS.has(String(node?.id||'')));
61
+ const entryHasRootAuthority=entry=>ROOT_NODE_IDS.has(String(entry?.source_id||''))||previewHasRootAuthority(entry?.conversation_preview);
62
+ function messageKey(message){if(message?.occurrence_id)return JSON.stringify(["occurrence",message.occurrence_id,message.sender??null,message.kind??null,message.phase??null,messageText(message)]);return JSON.stringify([message?.timestamp??null,message?.ordinal??null,message?.sender??null,message?.recipient??null,message?.kind??null,message?.phase??null,message?.content_state??null,message?.content_role??null,messageText(message)])}
63
+ function messageOrder(message,index){const stamp=String(message?.timestamp||''),ordinal=Number.isInteger(message?.ordinal)?message.ordinal:Number.MAX_SAFE_INTEGER;return{message,index,stamp,ordinal}}
64
+ function aggregate(matches){
65
+ if(!matches.length)return null;
66
+ let base=matches[0],baseCount=-1;
67
+ for(const entry of matches){const count=Array.isArray(entry?.conversation_preview?.messages)?entry.conversation_preview.messages.length:0;if(count>=baseCount){base=entry;baseCount=count}}
68
+ const seen=new Set(),ordered=[];let index=0;
69
+ for(const entry of matches){for(const message of(entry?.conversation_preview?.messages||[])){if(!message||typeof message!=='object')continue;const key=messageKey(message);if(seen.has(key))continue;seen.add(key);ordered.push(messageOrder(message,index++))}}
70
+ ordered.sort((a,b)=>{if(a.stamp&&b.stamp&&a.stamp!==b.stamp)return a.stamp.localeCompare(b.stamp);if(a.ordinal!==b.ordinal)return a.ordinal-b.ordinal;return a.index-b.index});
71
+ const preview=base?.conversation_preview&&typeof base.conversation_preview==='object'?base.conversation_preview:{};
72
+ return{...base,conversation_preview:{...preview,messages:ordered.map(item=>item.message)}};
73
+ }
74
+ function recordFor(node){
75
+ const nodeId=String(node?.id||'');
76
+ const exact=nodeId?entries.filter(entry=>String(entry?.source_id||'')===nodeId):[];
77
+ const aliases=new Set((Array.isArray(attrs(node).viewer_agent_member_ids)?attrs(node).viewer_agent_member_ids:[]).map(String).filter(alias=>alias&&alias!==nodeId));
78
+ if(aliases.size)exact.push(...entries.filter(entry=>aliases.has(String(entry?.source_id||''))));
79
+ if(exact.length)return aggregate(exact);
80
+ const path=nodePath(node);if(!path)return null;
81
+ return aggregate(entries.filter(entry=>{
82
+ const preview=entry?.conversation_preview;
83
+ if(!preview||!(String(entry?.conversation_preview?.agent_path||'')===path))return false;
84
+ if(String(preview.topology_state||'')==='derived')return false;
85
+ if(path==='/root'&&!entryHasRootAuthority(entry))return false;
86
+ return true;
87
+ }));
88
+ }
89
+ function canonicalRootRecord(){
90
+ const roots=entries.filter(entryHasRootAuthority);
91
+ const sourceIds=[...new Set(roots.map(entry=>String(entry?.source_id||'')).filter(Boolean))];
92
+ if(sourceIds.length!==1){
93
+ if(sourceIds.length)return null;
94
+ const agy=entries.filter(entry=>{
95
+ const preview=entry?.conversation_preview;
96
+ return String(entry?.provider||'').toLowerCase()==='antigravity'&&!!preview&&
97
+ String(entry?.source_id||'').startsWith('agent:antigravity:conversation:')&&
98
+ !String(preview.parent_agent_path||'').trim();
99
+ });
100
+ const agyIds=[...new Set(agy.map(entry=>String(entry?.source_id||'')).filter(Boolean))];
101
+ if(agyIds.length===1)return aggregate(agy.filter(entry=>String(entry?.source_id||'')===agyIds[0]));
102
+ }
103
+ if(sourceIds.length!==1)return null;
104
+ return aggregate(roots.filter(entry=>String(entry?.source_id||'')===sourceIds[0]));
105
+ }
106
+ function recordForPath(path){
107
+ if(String(path)==='/root')return canonicalRootRecord();
108
+ return aggregate(entries.filter(entry=>{
109
+ const preview=entry?.conversation_preview;
110
+ return !!preview&&String(entry?.conversation_preview?.agent_path||'')===String(path)&&String(preview.topology_state||'')!=='derived';
111
+ }));
112
+ }
113
+ function conversationSignature(node){
114
+ if(!node||String(node.type||'')!=='agent')return '';
115
+ const preview=recordFor(node)?.conversation_preview||{};
116
+ const messages=Array.isArray(preview.messages)?preview.messages:[];
117
+ return JSON.stringify([agentKey(node),messages.map(messageKey)]);
118
+ }
119
+ /*EXECWEAVE_FOLD_STATE*/
120
+ function uniqueTexts(messages){const seen=new Set(),out=[];for(const message of messages){const text=displayText(message);if(!text||seen.has(text))continue;seen.add(text);out.push(text)}return out}
121
+ function card(label,text){const box=document.createElement('section');box.className='execweave-agent-card';const head=document.createElement('div');head.className='execweave-agent-label';head.textContent=label;const body=document.createElement('pre');body.className='execweave-agent-body';body.textContent=text||'Not observed.';if(!text)body.classList.add('execweave-agent-empty');box.append(head,body);return box}
122
+ function stampOf(message){return String(message?.timestamp||'')}
123
+ function clock(stamp,sameDay){if(!stamp)return '';const at=new Date(stamp);if(Number.isNaN(at.getTime()))return '';
124
+ const pad=value=>String(value).padStart(2,'0');const time=`${pad(at.getHours())}:${pad(at.getMinutes())}`;
125
+ return sameDay?time:`${pad(at.getMonth()+1)}-${pad(at.getDate())} ${time}`}
126
+ function summarise(text){const line=String(text||'').split('\n').map(part=>part.trim()).find(Boolean)||'';
127
+ return line.length>52?line.slice(0,52)+'…':line}
128
+ // A run is a sequence of rounds, and every panel has to say which one it is showing.
129
+ // The root's rounds are the boundaries: a round opens on a user message and runs until
130
+ // the next one. A subagent's round is attributed to the root round whose interval
131
+ // contains its assignment, so the two panels fold on the same moment and can be read
132
+ // side by side. Root boundaries come from one exact root identity, never every record
133
+ // whose presentation path happens to be /root.
134
+ function rootPrompts(messages,path){return messages.filter(message=>isObserved(message)&&!isInjected(message)&&(String(message?.kind||'')==='user_message'||String(message?.sender||'')==='user')&&(!message?.recipient||String(message.recipient)===path))}
135
+ function runRounds(rootRecord=null){
136
+ const record=rootRecord||recordForPath('/root'),preview=record?.conversation_preview||{};
137
+ const messages=Array.isArray(preview.messages)?preview.messages:[];
138
+ const path=String(preview.agent_path||'/root');
139
+ return rootPrompts(messages,path).map(message=>({key:messageKey(message),start:stampOf(message),label:summarise(messageText(message))}));
140
+ }
141
+ function roundOf(stamp,rounds){let found=null;for(const round of rounds){if(round.start&&stamp&&round.start<=stamp)found=round}return found||rounds[0]||null}
142
+ function sameDayRun(rounds){const days=new Set(rounds.map(round=>String(round.start||'').slice(0,10)).filter(Boolean));return days.size<=1}
143
+ function windows(messages,openers){
144
+ if(!openers.length)return[{opener:null,messages}];
145
+ const out=[];
146
+ for(let index=0;index<openers.length;index++){
147
+ const from=messages.indexOf(openers[index]);
148
+ const next=index+1<openers.length?messages.indexOf(openers[index+1]):messages.length;
149
+ out.push({opener:openers[index],messages:messages.slice(from<0?0:from,next<0?messages.length:next)});
150
+ }
151
+ return out;
152
+ }
153
+ function rootRounds(messages,path){
154
+ return windows(messages,rootPrompts(messages,path)).map(window=>{
155
+ const inside=window.messages;
156
+ const finals=inside.filter(message=>isObserved(message)&&own(message,path)&&(String(message?.phase||'')==='final_answer'||/final[_ -]?response/i.test(String(message?.kind||''))));
157
+ const fallback=inside.filter(message=>isObserved(message)&&own(message,path)&&/assistant|response|message/i.test(String(message?.kind||'')));
158
+ return{
159
+ key:messageKey(window.opener),
160
+ start:stampOf(window.opener),
161
+ label:summarise(messageText(window.opener)),
162
+ cards:[['Prompt',displayText(window.opener)],['Final response',displayText(finals.at(-1)||fallback.at(-1))]],
163
+ };
164
+ });
165
+ }
166
+ /*EXECWEAVE_CHILD_POLICY*/
167
+ function childRounds(messages,path){
168
+ const record=selectedNode?recordFor(selectedNode):null;
169
+ const preview=record?.conversation_preview||{};
170
+ const provider=String(preview.provider||attrs(selectedNode).provider||record?.provider||'').toLowerCase();
171
+ const policy=({
172
+ codex:execweaveCodexChildRounds,
173
+ antigravity:execweaveAntigravityChildRounds,
174
+ claude:execweaveClaudeChildRounds,
175
+ ollama:execweaveOllamaChildRounds,
176
+ cursor:execweaveCursorChildRounds,
177
+ opencode:execweaveOpencodeChildRounds
178
+ })[provider]||execweaveDefaultChildRounds;
179
+ return policy(messages,path);
180
+ }
181
+ function roundView(round){const view=document.createElement('div');view.className='execweave-agent-round';for(const[label,text]of round.cards)view.appendChild(card(label,text));return view}
182
+ function stableRoundKey(round){
183
+ const raw=String(round?.key||'');
184
+ if(raw){
185
+ try{
186
+ const parts=JSON.parse(raw);
187
+ if(Array.isArray(parts)&&parts[0]==='occurrence')return JSON.stringify(parts.slice(0,-1));
188
+ // messageKey starts with observation timestamp followed by the provider
189
+ // ordinal. A cumulative provider snapshot can re-observe the same turn at
190
+ // a later timestamp, but its stable ordinal and content remain unchanged.
191
+ // Fold state is already scoped by exact agent identity, so when an ordinal
192
+ // exists the observation timestamp must not re-identify the historical round.
193
+ if(Array.isArray(parts)&&Number.isInteger(parts[1]))return JSON.stringify(['ordinal',...parts.slice(1)]);
194
+ }catch(_error){}
195
+ return raw;
196
+ }
197
+ return JSON.stringify([round?.start??null,round?.cards?.[0]?.[0]??null,round?.cards?.[0]?.[1]??null]);
198
+ }
199
+ function foldedRound(round,when,label,state,defaultOpen=false){
200
+ const fold=document.createElement('details');fold.className=defaultOpen?'execweave-agent-latest execweave-agent-round':'execweave-agent-older';
201
+ const key=stableRoundKey(round);bindFold(fold,state,key,defaultOpen);
202
+ const head=document.createElement('summary');
203
+ const time=document.createElement('span');time.className='execweave-agent-when';time.textContent=when;
204
+ head.append(time);
205
+ if(label){head.append(document.createTextNode(` \u00b7 ${label}`))}
206
+ fold.append(head,roundView(round));
207
+ return fold;
208
+ }
209
+ // A run graph is mostly not agents, and until now selecting one of those nodes showed
210
+ // its type and two timestamps. What each kind of node actually carries is listed here,
211
+ // and nothing that is not in the data is invented.
212
+ function displayGraph(){const core=window.__execweaveCore;return core?.getDisplayGraph?.()||core?.getGraph?.()||{}}
213
+ // tool_call and observed_content are hidden from the graph on purpose: a run makes one
214
+ // tool_call per invocation and drawing them buries everything else. Hiding them from
215
+ // the graph is not a reason to hide them from the reader, and the unprojected graph
216
+ // still carries both, so the panel reads that.
217
+ function rawGraph(){const core=window.__execweaveCore;return core?.getGraph?.()||displayGraph()}
218
+ function rawEdges(){return Array.isArray(rawGraph().edges)?rawGraph().edges:[]}
219
+ function rawNode(id){return (rawGraph().nodes||[]).find(node=>String(node?.id||'')===String(id))||null}
220
+ function relatedTo(id,relation,{from=true}={}){
221
+ const wanted=String(relation).toUpperCase();
222
+ return rawEdges()
223
+ .filter(edge=>String(edge?.relation||'').toUpperCase()===wanted&&String(from?edge?.source:edge?.target)===String(id))
224
+ .map(edge=>rawNode(from?edge.target:edge.source))
225
+ .filter(Boolean);
226
+ }
227
+ // What one call actually left behind. The command is a graph attribute and can be
228
+ // shown outright; the stored input is a digest and a size, and is described as that
229
+ // rather than as content the page has read.
230
+ function toolCallLine(call,sameDay){
231
+ const a=attrs(call),name=a.tool_name||call?.name||'tool';
232
+ const when=clock(call?.first_seen||call?.last_seen||'',sameDay);
233
+ const command=relatedTo(call.id,'DECLARED_COMMAND').map(node=>attrs(node).command||node?.name).filter(Boolean)[0];
234
+ const stored=relatedTo(call.id,'HAS_TOOL_INPUT').map(node=>attrs(node))[0];
235
+ const parts=[when,name].filter(Boolean);
236
+ let line=parts.join(' \u00b7 ');
237
+ if(command)line+=`\n ${commandText(command)}`;
238
+ else if(Array.isArray(a.input_keys)&&a.input_keys.length)line+=`\n ${a.input_keys.join(', ')}`;
239
+ if(stored?.sha256){
240
+ const size=Number(stored.size_bytes);
241
+ const complete=stored.complete_from_source===true?'complete':'partial';
242
+ line+=`\n input recorded \u00b7 ${Number.isFinite(size)?size:'?'} bytes \u00b7 ${complete} \u00b7 ${String(stored.sha256).slice(0,12)}`;
243
+ }
244
+ return line;
245
+ }
246
+ function toolCallsFor(agentId){
247
+ const calls=relatedTo(agentId,'REQUESTED_TOOL_CALL');
248
+ if(!calls.length)return '';
249
+ const ordered=[...calls].sort((a,b)=>String(b?.first_seen||'').localeCompare(String(a?.first_seen||'')));
250
+ const stamps=ordered.map(call=>String(call?.first_seen||'')).filter(Boolean);
251
+ const sameDay=stamps.length<2||stamps.every(value=>value.slice(0,10)===stamps[0].slice(0,10));
252
+ return ordered.map(call=>toolCallLine(call,sameDay)).join('\n');
253
+ }
254
+ function callersOf(toolId){
255
+ const calls=rawEdges().filter(edge=>String(edge?.relation||'').toUpperCase()==='USES_TOOL'&&String(edge?.target)===String(toolId))
256
+ .map(edge=>rawNode(edge.source)).filter(Boolean);
257
+ const names=new Set();
258
+ for(const call of calls)for(const agent of relatedTo(call.id,'REQUESTED_TOOL_CALL',{from:false}))names.add(agent?.name||agent?.id);
259
+ return{count:calls.length,agents:[...names].sort()};
260
+ }
261
+ function edgesTouching(id){return (displayGraph().edges||[]).filter(edge=>String(edge?.source||'')===id||String(edge?.target||'')===id)}
262
+ function nodeNamed(id){return (displayGraph().nodes||[]).find(node=>String(node?.id||'')===String(id))||null}
263
+ function moment(stamp){if(!stamp)return '';const at=new Date(stamp);if(Number.isNaN(at.getTime()))return String(stamp);
264
+ const pad=value=>String(value).padStart(2,'0');
265
+ return `${pad(at.getHours())}:${pad(at.getMinutes())}:${pad(at.getSeconds())}`}
266
+ function span(node){const from=moment(node?.first_seen),to=moment(node?.last_seen);
267
+ return from&&to&&from!==to?`${from} → ${to}`:from||to||''}
268
+ function commandText(value){
269
+ if(Array.isArray(value))return value.join(' ');
270
+ return value==null?'':String(value);
271
+ }
272
+ function fileHistory(id){
273
+ // An edge may be shared by many logical events and its first_seen can precede
274
+ // this file's actual observation. The canonical FILE NODE owns the interval
275
+ // and event_count; an edge.count is never a per-event-type histogram.
276
+ const node=rawNode(id)||nodeNamed(id);
277
+ if(!node||node.type!=='file')return '';
278
+ const count=Number.isSafeInteger(node.event_count)&&node.event_count>=0?node.event_count:null;
279
+ const interval=span(node),types=Array.isArray(node.event_types)?
280
+ node.event_types.filter(kind=>typeof kind==='string'&&kind.startsWith('filesystem.')).map(kind=>kind.slice(11)).sort():[];
281
+ return [interval,count===null?'':'Node events: '+count,
282
+ types.length?'Observed event types: '+[...new Set(types)].join(', '):'']
283
+ .filter(Boolean).join(' · ');
284
+ }
285
+ function reachedBy(id){
286
+ const names=new Set();
287
+ for(const edge of edgesTouching(id)){
288
+ const other=String(edge?.source||'')===id?edge?.target:edge?.source;
289
+ const node=nodeNamed(other);
290
+ if(node&&node.type!=='network_endpoint')names.add(`${node.name||other}`);
291
+ }
292
+ return [...names].join('\n');
293
+ }
294
+ function externalEndpointLine(item){
295
+ const address=String(item?.address||'').trim();
296
+ if(!address)return '';
297
+ const bits=[];
298
+ const from=moment(item?.first_seen),to=moment(item?.last_seen);
299
+ if(from&&to&&from!==to)bits.push(`${from} → ${to}`);
300
+ else if(from||to)bits.push(from||to);
301
+ const count=Number(item?.event_count||0);
302
+ if(count)bits.push(`${count} event${count===1?'':'s'}`);
303
+ return bits.length?`${address}\n ${bits.join(' · ')}`:address;
304
+ }
305
+ function foldedList(a){
306
+ const members=Array.isArray(a.viewer_folded_members)?a.viewer_folded_members:[];
307
+ return members
308
+ .slice()
309
+ .sort((x,y)=>String(y?.last_seen||'').localeCompare(String(x?.last_seen||'')))
310
+ .map(item=>`${moment(item?.last_seen||item?.first_seen)} ${item?.name||item?.id}`)
311
+ .join('\n');
312
+ }
313
+ function occurrenceList(a){
314
+ const rows=Array.isArray(a.viewer_occurrences)?a.viewer_occurrences:[];
315
+ if(rows.length<2)return '';
316
+ return rows
317
+ .slice()
318
+ .sort((x,y)=>String(y?.first_seen||'').localeCompare(String(x?.first_seen||'')))
319
+ .map(item=>`${moment(item?.first_seen)}${item?.pid?` pid ${item.pid}`:''}`)
320
+ .join('\n');
321
+ }
322
+ // A node the flow layout drew in place of others is still a real node with a panel of
323
+ // its own, so it keeps every card it would have had and says what it absorbed at the
324
+ // end. A node whose only purpose is to stand for others is the separate `viewer_folded`
325
+ // case below, and that one is a list of what it holds and nothing else.
326
+ function nodeCards(node){
327
+ const a=attrs(node),rows=execweaveNodeCardsBase(node);
328
+ if(!a.viewer_absorbed||a.viewer_folded)return rows;
329
+ const held=foldedList(a);
330
+ if(held)rows.push(['Also holding',held]);
331
+ return rows;
332
+ }
333
+ function execweaveNodeCardsBase(node){
334
+ const a=attrs(node),kind=String(node?.type||'');
335
+ const rows=[];
336
+ const add=(label,value)=>{const text=commandText(value);if(text)rows.push([label,text])};
337
+ if(a.viewer_folded){
338
+ // The budget folds the older nodes of a type into this one rather than dropping
339
+ // them, so it has to say what it holds.
340
+ add('Folded',`${a.viewer_folded_count} earlier ${String(a.viewer_folded_type||'').replace(/_/g,' ')} nodes`);
341
+ add('Holding',foldedList(a));
342
+ add('Observed at',span(node));
343
+ return rows;
344
+ }
345
+ if(kind==='process'){
346
+ if(Array.isArray(a.viewer_message_evidence)&&a.viewer_message_evidence.length)add('Unrouted callback messages',`${a.viewer_message_evidence.length} observations; sender/recipient not exposed. Original evidence retained in raw graph.`);
347
+ add('Command',a.cmdline);
348
+ add('Executable',a.exe);
349
+ add('Process',[a.pid&&`pid ${a.pid}`,a.ppid&&`parent ${a.ppid}`].filter(Boolean).join(' \u00b7 '));
350
+ if(Number.isSafeInteger(a.exit_code))add('Observed exit code',a.exit_code);
351
+ else if(typeof a.exit_signal==='string'&&a.exit_signal)add('Observed exit signal',a.exit_signal);
352
+ else add('Exit status','Not observed (not proof of success)');
353
+ add('Exit observed at',a.exit_observed_at);
354
+ add('Ran',occurrenceList(a));
355
+ }else if(kind==='file'){
356
+ add('Path',node?.name);
357
+ add('Observed',fileHistory(String(node?.id||'')));
358
+ }else if(kind==='tool_call'){
359
+ add('Tool',a.tool_name||node?.name);
360
+ add('Inputs',Array.isArray(a.input_keys)?a.input_keys.join(', '):a.input_keys);
361
+ add('Call',a.tool_use_id);
362
+ add('Model',a.codex_model);
363
+ add('Working directory',a.codex_cwd);
364
+ }else if(kind==='tool'){
365
+ add('Tool',node?.name);
366
+ add('Provider',a.provider);
367
+ const traffic=callersOf(String(node?.id||''));
368
+ const occurrences=Array.isArray(a.viewer_tool_call_occurrences)?a.viewer_tool_call_occurrences:[];
369
+ add('Calls',occurrences.length?String(occurrences.length):(traffic.count?String(traffic.count):''));
370
+ add('Requested by',traffic.agents.join('\n'));
371
+ }else if(kind==='session'){
372
+ add('Provider session',a.provider_session_id);
373
+ add('Command',a.command);
374
+ add('Working directory',a.cwd);
375
+ add('Backend',a.backend);
376
+ }else if(kind==='task'){
377
+ add('Task',a.task_prompt||a.prompt||a.description||node?.name);
378
+ add('Prompt',a.task_prompt||a.prompt||a.description);
379
+ add('Provider',a.provider);
380
+ }else if(kind==='network_endpoint'){
381
+ const endpoints=Array.isArray(a.endpoints)?a.endpoints:[];
382
+ if(endpoints.length){
383
+ add('Endpoints',endpoints.map(externalEndpointLine).filter(Boolean).join('\n'));
384
+ }else{
385
+ add('Address',node?.name);
386
+ }
387
+ add('Reached by',reachedBy(String(node?.id||'')));
388
+ }else{
389
+ add('Name',node?.name);
390
+ add('Provider',a.provider);
391
+ add('Session',a.session_id);
392
+ }
393
+ if(kind==='file'){
394
+ if(a.writer_identity==='unknown')add('Writer','unknown — attribution not established');
395
+ else if(typeof a.writer_identity==='string'&&a.writer_identity)add('Writer',a.writer_identity);
396
+ if(a.snapshot_state==='not_captured')add('Snapshot','not captured');
397
+ }
398
+ add('Observed at',span(node));
399
+ return rows;
400
+ }
401
+ function contentAvailability(occurrence,relation){
402
+ const refs=(occurrence?.content_references||[]).filter(ref=>String(ref?.relation||'')===relation);
403
+ return refs.length?{state:'archived_reference',note:'Full content is in the referenced run artifact; not an empty tool result.',references:refs}:{state:'not_observed',note:'A returned event does not establish that result content was captured.'};
404
+ }
405
+ function inferenceOccurrenceSection(node){
406
+ const rows=attrs(node).viewer_inference_occurrences;if(!Array.isArray(rows)||!rows.length)return null;
407
+ const section=document.createElement('section');section.className='execweave-inference-history execweave-agent-rounds';
408
+ const title=document.createElement('div');title.className='execweave-agent-label';title.textContent='Inference history';section.appendChild(title);
409
+ const state=foldStateFor(node),ordered=rows.slice().sort((a,b)=>String(a?.first_seen||'').localeCompare(String(b?.first_seen||''))||(Number(a?.first_sequence)||0)-(Number(b?.first_sequence)||0));
410
+ ordered.reverse().forEach((item,index)=>{
411
+ const fold=document.createElement('details');fold.className='execweave-agent-older execweave-inference-occurrence';
412
+ const identity=item?.request_ids||item?.call_ids||[item?.first_seen,item?.first_sequence,ordered.length-index];
413
+ bindFold(fold,state,'inference:'+JSON.stringify(identity),index===0);
414
+ const head=document.createElement('summary');head.textContent=[moment(item?.first_seen||item?.last_seen),`call ${ordered.length-index}`,index===0?'Latest':''].filter(Boolean).join(' · ');fold.appendChild(head);
415
+ for(const message of item?.messages||[]){fold.appendChild(card([message?.sender,message?.kind].filter(Boolean).join(' · ')||'Observed message',String(message?.text||'')));if(message?.text_truncated)fold.appendChild(card('Preview limit','This message preview is truncated. The complete content is in the references below.'))}
416
+ if(item?.content_references?.length)fold.appendChild(card('Content references',JSON.stringify(item.content_references,null,2)));
417
+ if(!item?.messages?.length&&!item?.content_references?.length)fold.appendChild(card('Content','Not observed.'));
418
+ section.appendChild(fold);
419
+ });return section;
420
+ }
421
+ function toolOccurrenceSection(node){
422
+ const occurrences=Array.isArray(attrs(node).viewer_tool_call_occurrences)?attrs(node).viewer_tool_call_occurrences:[];
423
+ if(!occurrences.length)return null;
424
+ const section=document.createElement('section');section.className='execweave-tool-occurrences';
425
+ const title=document.createElement('strong');title.textContent=`Invocations · ${occurrences.length} call${occurrences.length===1?'':'s'}`;section.appendChild(title);
426
+ occurrences.forEach((occurrence,index)=>{
427
+ const fold=document.createElement('details');fold.className='execweave-tool-occurrence';
428
+ const summary=document.createElement('summary');
429
+ const owner=nodeNamed(occurrence?.owner_id)?.name||occurrence?.owner_id||'unknown';
430
+ const when=moment(occurrence?.first_seen||occurrence?.last_seen);
431
+ summary.textContent=[when,owner,`call ${index+1}`].filter(Boolean).join(' · ');
432
+ const pre=document.createElement('pre');
433
+ pre.textContent=JSON.stringify({
434
+ first_seen:occurrence?.first_seen||null,
435
+ last_seen:occurrence?.last_seen||null,
436
+ first_sequence:occurrence?.first_sequence??null,
437
+ last_sequence:occurrence?.last_sequence??null,
438
+ input:occurrence?.input??contentAvailability(occurrence,'HAS_TOOL_INPUT'),
439
+ output:occurrence?.output??contentAvailability(occurrence,'HAS_TOOL_OUTPUT'),
440
+ call_ids:occurrence?.call_ids||[],
441
+ content_references:occurrence?.content_references||[]
442
+ },null,2);
443
+ bindFold(fold,foldStateFor(node),'tool:'+JSON.stringify(occurrence?.call_ids||[occurrence?.first_sequence,index]));
444
+ fold.append(summary,pre);section.appendChild(fold);
445
+ });
446
+ return section;
447
+ }
448
+ function execweaveAssignedTaskText(agent){
449
+ if(!agent||String(agent.type||'')!=='agent')return '';
450
+ const projected=attrs(agent),attached=projected.viewer_assigned_task_prompt||projected.viewer_assigned_task_name;
451
+ if(attached)return commandText(attached);
452
+ const graph=rawGraph(),nodes=Array.isArray(graph.nodes)?graph.nodes:[],edges=Array.isArray(graph.edges)?graph.edges:[];
453
+ const nodeMap=new Map(nodes.filter(node=>node&&node.id).map(node=>[String(node.id),node]));
454
+ const exactAssignment=['ASSIGNED','AGENT','TASK'].join('_');
455
+ const direct=edges.filter(edge=>edge&&String(edge.target||'')===String(agent.id||'')&&['ASSIGNED_TO',exactAssignment].includes(String(edge.relation||''))).sort((a,b)=>(Number(a.first_sequence)||0)-(Number(b.first_sequence)||0));
456
+ const owned=edges.filter(edge=>edge&&String(edge.source||'')===String(agent.id||'')&&String(edge.relation||'')==='TASK_CREATED').sort((a,b)=>(Number(a.first_sequence)||0)-(Number(b.first_sequence)||0));
457
+ const started=edges.filter(edge=>edge&&String(edge.source||'')===String(agent.id||'')&&String(edge.relation||'')==='TASK_STARTED').sort((a,b)=>(Number(a.first_sequence)||0)-(Number(b.first_sequence)||0));
458
+ const edge=direct.at(-1)||owned.at(-1)||started.at(-1);if(!edge)return '';
459
+ const taskId=direct.length?edge.source:edge.target,task=nodeMap.get(String(taskId||''));
460
+ if(!task||String(task.type||'')!=='task')return '';
461
+ const a=attrs(task);return commandText(a.task_prompt||a.prompt||a.description||task.name);
462
+ }
463
+ function execweaveFillAssignedTask(round,node,isRoot){
464
+ const task=execweaveAssignedTaskText(node);if(!task)return round;
465
+ const value=round||{cards:[]},cards=Array.isArray(value.cards)?value.cards.map(card=>[card[0],card[1]]):[];
466
+ const label=isRoot?'Prompt':'Task',index=cards.findIndex(card=>String(card[0]||'')===label);
467
+ if(index<0)cards.unshift([label,task]);else if(!commandText(cards[index][1]))cards[index][1]=task;
468
+ else if(attrs(node).conversation_scope==='framework_agent'&&commandText(cards[index][1])!==task)cards.unshift(['Assigned task',task]);
469
+ return{...value,cards};
470
+ }
471
+ function agentCommunicationHistory(node,messages){
472
+ // Read only this exact agent's conversation record. Never sweep sibling
473
+ // transcripts into the parent merely because they share a run or a model.
474
+ const candidates=messages.filter(message=>isObserved(message)&&!isInjected(message)&&(
475
+ String(message?.kind||'')==='agent_message'||
476
+ (String(message?.sender||'').startsWith('/')&&String(message?.recipient||'').startsWith('/')&&message.sender!==message.recipient)
477
+ ));
478
+ const byMessage=new Map(),phases=new Map();
479
+ for(const message of candidates){
480
+ // Receipt bodies need not be byte-identical to sent bodies. Match only
481
+ // explicit message occurrence identity and the exact direction.
482
+ const key=message.message_id?JSON.stringify([message.message_id,message.sender,message.recipient]):messageKey(message);
483
+ const previous=byMessage.get(key),state=phases.get(key)||new Set();
484
+ if(message.phase==='received'||message.phase==='sent')state.add(message.phase);
485
+ phases.set(key,state);
486
+ if(!previous||message.phase==='received')byMessage.set(key,message);
487
+ }
488
+ const gaps=rawGraph()?.observation_assessment?.message_delivery?.unconfirmed||[];
489
+ const unconfirmedRows=Array.isArray(gaps)?gaps:[];
490
+ const agentNodes=(rawGraph()?.nodes||[]).filter(candidate=>String(candidate?.type||'')==='agent');
491
+ // Presentation names are evidence only if exactly one graph agent owns them.
492
+ const gapAgentIds=new Set(unconfirmedRows.flatMap(row=>[row?.sender_id,row?.recipient_id]).filter(Boolean));
493
+ const canonicalAgentId=value=>{
494
+ const label=String(value||'').trim();if(!label)return null;
495
+ if(gapAgentIds.has(label))return label;
496
+ const matches=agentNodes.filter(candidate=>
497
+ String(candidate?.name||'').trim()===label||nodePath(candidate)===label);
498
+ return matches.length===1?String(matches[0].id):null;
499
+ };
500
+ const unconfirmedIds=new Set(unconfirmedRows.map(row=>
501
+ JSON.stringify([row?.message_id,row?.sender_id,row?.recipient_id])));
502
+ const gapKey=message=>{
503
+ if(!message?.message_id)return null;
504
+ const sender=canonicalAgentId(message.sender),recipient=canonicalAgentId(message.recipient);
505
+ return sender&&recipient?JSON.stringify([message.message_id,sender,recipient]):null;
506
+ };
507
+ const routed=[...byMessage.entries()];
508
+ if(!routed.length)return null;
509
+ const section=document.createElement('section');section.className='execweave-agent-communication';
510
+ section.dataset.agentId=String(node.id);
511
+ const title=document.createElement('div');title.className='execweave-communication-label';title.textContent='Agent communication';section.appendChild(title);
512
+ const state=foldStateFor(node);
513
+ for(const [identity,message] of [...routed].reverse()){
514
+ const fold=document.createElement('details');fold.className='execweave-message-history';
515
+ const key='message:'+messageKey(message);fold.open=state.get(key)===true;bindFold(fold,state,key);
516
+ const summary=document.createElement('summary');
517
+ const delivery=gapKey(message)&&unconfirmedIds.has(gapKey(message))?'Receive not observed':
518
+ phases.get(identity)?.has('received')?'Receive event observed':'Delivery not verified';
519
+ summary.textContent=[moment(message.timestamp),`${message.sender||'Unknown sender'} → ${message.recipient||'Recipient not recorded'}`,delivery].filter(Boolean).join(' · ');
520
+ const body=document.createElement('pre');body.className='execweave-message-body';body.textContent=displayText(message);
521
+ fold.append(summary,body);section.appendChild(fold);
522
+ }
523
+ return section;
524
+ }
525
+ function renderNode(node){
526
+ historyBrowser.nodeChanged(node);
527
+ const rows=nodeCards(node);
528
+ if(!rows.length)return false;
529
+ rememberVisibleFoldState();
530
+ selectedNode=null;selectedFoldNode=node;selectedConversationSignature='';detailsEmpty.hidden=true;details.replaceChildren();
531
+ const view=document.createElement('div');view.className='execweave-agent-view';
532
+ for(const[label,text]of rows)view.appendChild(card(label,text));
533
+ details.appendChild(view);
534
+ const occurrences=toolOccurrenceSection(node);if(occurrences)details.appendChild(occurrences);
535
+ const inferences=inferenceOccurrenceSection(node);if(inferences)details.appendChild(inferences);
536
+ return true;
537
+ }
538
+ function render(node){
539
+ if(!node)return false;
540
+ if(String(node.type||'')!=='agent')return renderNode(node);
541
+ rememberVisibleFoldState();
542
+ selectedNode=node;selectedFoldNode=node;selectedConversationSignature=conversationSignature(node);detailsEmpty.hidden=true;details.replaceChildren();
543
+ const record=recordFor(node),preview=record?.conversation_preview||{},path=String(preview.agent_path||nodePath(node)||'').trim(),messages=Array.isArray(preview.messages)?preview.messages:[];
544
+ historyBrowser.nodeChanged(node);
545
+ details.appendChild(historyBrowser.buttonFor(node));
546
+ const delivery=rawGraph()?.observation_assessment?.message_delivery;
547
+ const unconfirmed=Array.isArray(delivery?.unconfirmed)?delivery.unconfirmed.filter(row=>row?.recipient_id===node.id):[];
548
+ if(unconfirmed.length)details.appendChild(card('Incoming handoff — receive not observed',
549
+ unconfirmed.map(row=>`${row.sender_id} → ${row.recipient_id} · ${row.message_id}`).join('\n')+
550
+ '\nThis is missing receive telemetry, not proof of failed delivery.'));
551
+ const isRoot=nodeHasRootAuthority(node)||previewUsesRootRenderer(preview);
552
+ // Restrict this fallback to the selected agent's exact raw content edge.
553
+ // A provider may publish an explicit MODEL_REQUEST without a user-message
554
+ // round or framework_agent decoration; neither absence is evidence of no prompt.
555
+ const requestMessages=entries.filter(entry=>
556
+ String(entry?.source_id||'')===String(node.id||''))
557
+ .flatMap(entry=>Array.isArray(entry?.conversation_preview?.messages)?
558
+ entry.conversation_preview.messages:[])
559
+ .filter(message=>isObserved(message)&&!isInjected(message)&&
560
+ message?.kind==='model_request'&&message?.phase==='request'&&
561
+ commandText(message?.text));
562
+ const observedPrompt=requestMessages.length?displayText(requestMessages.at(-1)):'';
563
+ const rounds=(isRoot?rootRounds(messages,path||'/root'):childRounds(messages,path)).map(round=>execweaveFillAssignedTask(round,node,isRoot));
564
+ // An exact-agent request may be stored in a sibling response preview.
565
+ // Bind it to a single root round only when that round has no opener;
566
+ // never attribute one request to multiple rounds or a different agent.
567
+ const soleRootRound=isRoot&&rounds.length===1?rounds[0]:null;
568
+ const roundNeedsPrompt=!!observedPrompt&&!!soleRootRound?.cards?.some(
569
+ ([label,text])=>label==='Prompt'&&!text);
570
+ if(roundNeedsPrompt)soleRootRound.cards=soleRootRound.cards.map(
571
+ ([label,text])=>label==='Prompt'&&!text?[label,observedPrompt]:[label,text]);
572
+ if(observedPrompt&&!roundNeedsPrompt)details.appendChild(card('Prompt',observedPrompt));
573
+ const tools=toolCallsFor(String(node.id||''));
574
+ const communication=agentCommunicationHistory(node,messages);
575
+ const appendTools=()=>{if(communication)details.appendChild(communication);if(tools)details.appendChild(card('Tools',tools))};
576
+ if(!rounds.length){const fallback={cards:isRoot?[['Prompt',observedPrompt],['Final response','']]:[['Task',''],['Thinking',''],['Response','']]};details.appendChild(roundView(rounds[0]||execweaveFillAssignedTask(fallback,node,isRoot)));appendTools();return true}
577
+ // A subagent borrows the moment and the wording of the unique canonical root round
578
+ // it belongs to. If root identity is ambiguous, the child keeps its own timestamp.
579
+ const runs=isRoot?rounds:runRounds();
580
+ const sameDay=sameDayRun(runs.length?runs:rounds);
581
+ const naming=round=>isRoot?round:(round.label?round:(()=>{const parentRound=roundOf(round.start,runs);return{start:parentRound?.start||round.start,label:''}})());
582
+ const list=document.createElement('div');list.className='execweave-agent-rounds';
583
+ const ordered=[...rounds].reverse(),state=foldStateFor(node);
584
+ const newest=naming(ordered[0]);list.appendChild(foldedRound(ordered[0],clock(newest.start||ordered[0].start,sameDay),'Latest · '+(newest.label||''),state,true));
585
+ for(const round of ordered.slice(1)){const named=naming(round);list.appendChild(foldedRound(round,clock(named.start||round.start,sameDay),named.label||'',state))}
586
+ details.appendChild(list);appendTools();return true;
587
+ }
588
+ function graphNode(id){const core=window.__execweaveCore;if(!core)return null;const graph=core.getDisplayGraph?.()||core.getGraph?.()||{};return (graph.nodes||[]).find(node=>String(node?.id||'')===String(id||''))||null}
589
+ function syncSelection(){const selected=document.querySelector('.node.selected');if(!selected){historyBrowser.nodeChanged(null);rememberVisibleFoldState();selectedNode=null;selectedFoldNode=null;selectedConversationSignature='';return}const node=graphNode(selected.dataset.id);if(node)render(node);else selectedNode=null;if(!node)selectedConversationSignature=''}
590
+ function setEntries(next){
591
+ const candidate=Array.isArray(next)?next:[];
592
+ if(!selectedNode){entries=candidate;historyBrowser.changed();return}
593
+ const previousSignature=selectedConversationSignature;entries=candidate;historyBrowser.changed();
594
+ if(conversationSignature(selectedNode)!==previousSignature)render(selectedNode);
595
+ }
596
+ 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}}
597
+ const nodes=document.getElementById('nodes');if(nodes)new MutationObserver(syncSelection).observe(nodes,{subtree:true,attributes:true,attributeFilter:['class']});
598
+ document.addEventListener('click',event=>{if(event.target.closest?.('.node'))setTimeout(()=>{syncSelection();refresh()},0)},true);
599
+ if(!window.__execweaveStaticMode)setInterval(()=>{if(selectedNode)refresh()},800);
600
+ const previous=window.__execweaveDashboard||{};window.__execweaveDashboard={...previous,onPayload(data){previous.onPayload?.(data);if(selectedNode)refresh()},onFinished(){previous.onFinished?.();if(selectedNode)refresh()}};
601
+ const agentPanelAPI={render,setEntries,refresh};
602
+ window.__execweaveAgentPanel=agentPanelAPI;
603
+ // Shared surfaces consume the same inspector instance through the Dashboard host.
604
+ window.__execweaveDashboard={...(window.__execweaveDashboard||{}),agentPanel:agentPanelAPI};
605
+ })();
606
+ """.strip().replace("/*EXECWEAVE_HISTORY_BROWSER*/", HISTORY_BROWSER_JS).replace("/*EXECWEAVE_FOLD_STATE*/", FOLD_STATE_JS).replace(
607
+ "/*EXECWEAVE_CHILD_POLICY*/",
608
+ "\n".join(
609
+ (
610
+ DEFAULT_CHILD_ROUNDS_JS,
611
+ CODEX_CHILD_ROUNDS_JS,
612
+ ANTIGRAVITY_CHILD_ROUNDS_JS,
613
+ CLAUDE_CHILD_ROUNDS_JS,
614
+ OLLAMA_CHILD_ROUNDS_JS,
615
+ CURSOR_CHILD_ROUNDS_JS,
616
+ OPENCODE_CHILD_ROUNDS_JS,
617
+ )
618
+ ),
619
+ 1,
620
+ )
621
+
622
+
623
+ def inject_agent_panel(html: str) -> str:
624
+ if "window.__execweaveAgentPanel" in html:
625
+ return html
626
+ html = html.replace("</style>", _AGENT_PANEL_CSS + "\n" + HISTORY_BROWSER_CSS + "\n</style>", 1)
627
+ marker = html.rfind("</script>")
628
+ if marker < 0:
629
+ raise RuntimeError("dashboard script seam changed")
630
+ return html[:marker] + _AGENT_PANEL_JS + "\n" + html[marker:]