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.
- execweave/__init__.py +3 -0
- execweave/__main__.py +5 -0
- execweave/_conversation_records_core.py +902 -0
- execweave/_dashboard_shell_base.py +148 -0
- execweave/_http_proxy_base.py +565 -0
- execweave/_http_proxy_bounded.py +560 -0
- execweave/_http_proxy_stage.py +509 -0
- execweave/acceptance_output.py +19 -0
- execweave/agent_bootstrap.py +395 -0
- execweave/agent_topology.py +313 -0
- execweave/agent_trace.py +1162 -0
- execweave/agy_preview_sanitize.py +102 -0
- execweave/analysis.py +427 -0
- execweave/anthropic.py +228 -0
- execweave/anthropic_cli.py +171 -0
- execweave/anthropic_full_fidelity.py +385 -0
- execweave/antigravity_adapter.py +112 -0
- execweave/antigravity_adapter_base.py +479 -0
- execweave/antigravity_full_fidelity.py +656 -0
- execweave/antigravity_full_fidelity_base.py +172 -0
- execweave/antigravity_full_fidelity_collaboration_base.py +451 -0
- execweave/antigravity_hook_cli.py +209 -0
- execweave/antigravity_record.py +96 -0
- execweave/antigravity_subagent_linkage.py +449 -0
- execweave/antigravity_trace_capability.py +39 -0
- execweave/auto_specialized.py +547 -0
- execweave/backends.py +102 -0
- execweave/benchmark.py +80 -0
- execweave/claude_adapter.py +517 -0
- execweave/claude_child_transcript.py +314 -0
- execweave/claude_delegation.py +136 -0
- execweave/claude_full_fidelity.py +396 -0
- execweave/claude_hook_cli.py +209 -0
- execweave/claude_hook_contract.py +943 -0
- execweave/claude_model_observer.py +353 -0
- execweave/claude_record.py +106 -0
- execweave/cli.py +629 -0
- execweave/codex_adapter.py +455 -0
- execweave/codex_conversation.py +621 -0
- execweave/codex_full_fidelity.py +287 -0
- execweave/codex_hook_cli.py +301 -0
- execweave/codex_hook_entry.py +207 -0
- execweave/codex_hook_lifecycle.py +363 -0
- execweave/codex_message_diagnostics.py +322 -0
- execweave/codex_message_transport_diagnostics.py +399 -0
- execweave/codex_record.py +199 -0
- execweave/codex_rollout_structures.py +402 -0
- execweave/codex_rollout_trace.py +56 -0
- execweave/codex_rollout_trace_base.py +1509 -0
- execweave/collector.py +768 -0
- execweave/command.py +157 -0
- execweave/command_privacy.py +20 -0
- execweave/content_evidence.py +101 -0
- execweave/content_integrity.py +289 -0
- execweave/content_store.py +273 -0
- execweave/controlled_checks.py +561 -0
- execweave/conversation_archive.py +338 -0
- execweave/conversation_message_identity.py +264 -0
- execweave/conversation_preview.py +66 -0
- execweave/conversation_preview_antigravity.py +32 -0
- execweave/conversation_preview_claude.py +31 -0
- execweave/conversation_preview_codex.py +107 -0
- execweave/conversation_preview_common.py +180 -0
- execweave/conversation_preview_generic.py +188 -0
- execweave/conversation_preview_lines.py +133 -0
- execweave/conversation_preview_transcript.py +121 -0
- execweave/conversation_records.py +349 -0
- execweave/conversation_records_antigravity.py +370 -0
- execweave/conversation_records_codex.py +83 -0
- execweave/conversation_records_common.py +17 -0
- execweave/conversation_records_ollama.py +39 -0
- execweave/correlation.py +818 -0
- execweave/cursor_adapter.py +349 -0
- execweave/cursor_delegation.py +87 -0
- execweave/cursor_delegation_base.py +220 -0
- execweave/cursor_full_fidelity.py +489 -0
- execweave/cursor_hook_cli.py +195 -0
- execweave/cursor_hook_contract.py +439 -0
- execweave/cursor_lifecycle.py +159 -0
- execweave/cursor_record.py +96 -0
- execweave/dashboard_shell.py +283 -0
- execweave/delivery_status.py +94 -0
- execweave/entry.py +98 -0
- execweave/evidence_availability.py +113 -0
- execweave/evidence_grade.py +166 -0
- execweave/fidelity.py +304 -0
- execweave/filesystem.py +327 -0
- execweave/finalization.py +92 -0
- execweave/focus.py +118 -0
- execweave/framework_adapters/__init__.py +34 -0
- execweave/framework_adapters/autogen.py +398 -0
- execweave/framework_adapters/base.py +580 -0
- execweave/framework_adapters/camel.py +270 -0
- execweave/framework_adapters/camel_channel.py +71 -0
- execweave/framework_adapters/metagpt.py +315 -0
- execweave/framework_adapters/metagpt_ollama_compat.py +54 -0
- execweave/framework_adapters/metagpt_recording.py +342 -0
- execweave/framework_adapters/registry.py +90 -0
- execweave/graph.py +590 -0
- execweave/graph_ops.py +472 -0
- execweave/hook_command.py +32 -0
- execweave/hook_delivery.py +32 -0
- execweave/hook_input.py +16 -0
- execweave/http_proxy.py +187 -0
- execweave/http_proxy_cli.py +84 -0
- execweave/inference_gateway.py +476 -0
- execweave/inference_gateway_cli.py +211 -0
- execweave/inference_gateway_full_fidelity.py +613 -0
- execweave/inference_identity.py +76 -0
- execweave/inference_identity_cli.py +60 -0
- execweave/integrity.py +235 -0
- execweave/integrity_cli.py +55 -0
- execweave/investigation_index.py +445 -0
- execweave/litellm_callback.py +211 -0
- execweave/litellm_callback_cli.py +42 -0
- execweave/live.py +445 -0
- execweave/live_core.py +972 -0
- execweave/live_view.py +109 -0
- execweave/live_view_extra_style.py +11 -0
- execweave/live_view_markup.py +29 -0
- execweave/live_view_process_layout.py +650 -0
- execweave/live_view_readability.py +502 -0
- execweave/live_view_script_a.py +59 -0
- execweave/live_view_script_b.py +97 -0
- execweave/live_view_script_c.py +59 -0
- execweave/live_view_script_d.py +40 -0
- execweave/live_view_style.py +34 -0
- execweave/model_runtime.py +560 -0
- execweave/model_runtime_cli.py +265 -0
- execweave/model_runtime_full_fidelity.py +519 -0
- execweave/observation.py +53 -0
- execweave/observation_demo.py +69 -0
- execweave/openai_agents.py +267 -0
- execweave/openai_agents_sdk.py +453 -0
- execweave/openai_compatible.py +239 -0
- execweave/openai_compatible_cli.py +189 -0
- execweave/openai_compatible_full_fidelity.py +438 -0
- execweave/opencode_adapter.py +325 -0
- execweave/opencode_event_contract.py +734 -0
- execweave/opencode_full_fidelity.py +198 -0
- execweave/opencode_hook_cli.py +119 -0
- execweave/opencode_plugin_cli.py +150 -0
- execweave/opencode_record.py +96 -0
- execweave/opencode_task_linkage.py +225 -0
- execweave/overhead_benchmark.py +440 -0
- execweave/privacy.py +84 -0
- execweave/private_io.py +465 -0
- execweave/provider_capability.py +578 -0
- execweave/provider_lifecycle.py +282 -0
- execweave/provider_record.py +290 -0
- execweave/reader_identity.py +13 -0
- execweave/redacted_archive.py +906 -0
- execweave/risk.py +106 -0
- execweave/rule_pack.py +359 -0
- execweave/rule_pack_cli.py +57 -0
- execweave/run_assessment.py +200 -0
- execweave/runtime_endpoint_availability.py +44 -0
- execweave/scalability_benchmark.py +195 -0
- execweave/schema.py +62 -0
- execweave/scope.py +85 -0
- execweave/semantic.py +453 -0
- execweave/session_summary.py +159 -0
- execweave/sink.py +71 -0
- execweave/strace_backend.py +927 -0
- execweave/stream_assembly.py +363 -0
- execweave/task_artifacts.py +192 -0
- execweave/task_validation.py +317 -0
- execweave/theme.py +40 -0
- execweave/top.py +599 -0
- execweave/top_cli.py +150 -0
- execweave/validate.py +196 -0
- execweave/vendor/dagre.min.js +815 -0
- execweave/view_cli.py +49 -0
- execweave/viewer.py +474 -0
- execweave/viewer_agent_panel.py +630 -0
- execweave/viewer_agent_panel_antigravity.py +31 -0
- execweave/viewer_agent_panel_claude.py +9 -0
- execweave/viewer_agent_panel_codex.py +50 -0
- execweave/viewer_agent_panel_cursor.py +9 -0
- execweave/viewer_agent_panel_default.py +79 -0
- execweave/viewer_agent_panel_ollama.py +20 -0
- execweave/viewer_agent_panel_opencode.py +9 -0
- execweave/viewer_agent_panel_registry.py +20 -0
- execweave/viewer_archive_verifier.py +178 -0
- execweave/viewer_background_files.py +86 -0
- execweave/viewer_content_browser.py +307 -0
- execweave/viewer_content_health.py +208 -0
- execweave/viewer_content_inspector.py +309 -0
- execweave/viewer_controlled_checks.py +258 -0
- execweave/viewer_conversation_sync.py +115 -0
- execweave/viewer_dashboard_clean.py +405 -0
- execweave/viewer_dashboard_focus.py +127 -0
- execweave/viewer_dashboard_hardening.py +264 -0
- execweave/viewer_dashboard_hardening_v2.py +62 -0
- execweave/viewer_dashboard_projection.py +261 -0
- execweave/viewer_delivery_status.py +155 -0
- execweave/viewer_edge_decross.py +117 -0
- execweave/viewer_execution_flow.py +611 -0
- execweave/viewer_execution_flow_provider_normalization.py +107 -0
- execweave/viewer_execution_flow_safety.py +349 -0
- execweave/viewer_external_endpoints.py +307 -0
- execweave/viewer_flow_canvas.py +1140 -0
- execweave/viewer_flow_layout.py +922 -0
- execweave/viewer_fold_state.py +31 -0
- execweave/viewer_framework_flow.py +68 -0
- execweave/viewer_framework_model_output.py +133 -0
- execweave/viewer_gif.py +278 -0
- execweave/viewer_history_browser.py +225 -0
- execweave/viewer_investigation.py +268 -0
- execweave/viewer_layout_geometry.py +192 -0
- execweave/viewer_layout_v2.py +429 -0
- execweave/viewer_layout_v2_detached.py +25 -0
- execweave/viewer_limits.py +93 -0
- execweave/viewer_live_layout.py +61 -0
- execweave/viewer_message_handoffs.py +114 -0
- execweave/viewer_projection.py +488 -0
- execweave/viewer_projection_base.py +522 -0
- execweave/viewer_projection_bridges.py +214 -0
- execweave/viewer_recorded_sources.py +146 -0
- execweave/viewer_run_assessment.py +274 -0
- execweave/viewer_run_guide.py +175 -0
- execweave/viewer_runtime_evidence.py +258 -0
- execweave/viewer_semantic_projection.py +641 -0
- execweave/viewer_session_flow.py +491 -0
- execweave/viewer_structure_share.py +132 -0
- execweave/viewer_task_validation.py +241 -0
- execweave/viewer_tool_mirror_identity.py +75 -0
- execweave/viewer_workflow_mode.py +127 -0
- execweave/workflow.py +183 -0
- execweave-1.0.0.dist-info/METADATA +462 -0
- execweave-1.0.0.dist-info/RECORD +234 -0
- execweave-1.0.0.dist-info/WHEEL +4 -0
- execweave-1.0.0.dist-info/entry_points.txt +30 -0
- execweave-1.0.0.dist-info/licenses/LICENSE +16 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"""Role-first discovery and selected-content priority without graph filtering."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
RUN_GUIDE_JS = r"""
|
|
6
|
+
(()=>{
|
|
7
|
+
'use strict';if(window.__execweaveRunGuide)return;
|
|
8
|
+
const make=(tag,text)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=String(text);return n};
|
|
9
|
+
const button=(label,fn)=>{const b=make('button',label);b.type='button';b.onclick=fn;return b};
|
|
10
|
+
const list=x=>Array.isArray(x)?x:[],label=x=>typeof x==='string'?x.slice(0,256):'';
|
|
11
|
+
const raw=()=>window.__execweaveCore?.getGraph?.()||window.__execweaveStaticGraph||{};
|
|
12
|
+
const protectedView=()=>document.getElementById('protective')?.hidden===false;
|
|
13
|
+
const scope=()=>JSON.stringify([raw().run_id??null,raw().session_id??null,raw().source_path??null]);
|
|
14
|
+
let roleInventoryCurrent=Array.isArray(raw().nodes)&&raw().live_payload_compact!==true;
|
|
15
|
+
const inventoryBlocked=()=>protectedView()&&!roleInventoryCurrent;
|
|
16
|
+
function payloadGraph(args){const value=args?.[0];return value?.graph&&typeof value.graph==='object'?value.graph:value}
|
|
17
|
+
function observePayload(args){const value=payloadGraph(args);if(value?.live_payload_compact===true)roleInventoryCurrent=false;else if(Array.isArray(value?.nodes))roleInventoryCurrent=true}
|
|
18
|
+
function evidenceCounts(id,index){
|
|
19
|
+
if(index?.schema_version!=='0.1'||index?.scope!=='recorded_event_investigation')return null;
|
|
20
|
+
const related=row=>row?.owner_id===id||row?.target_id===id||list(row?.relations).some(e=>e?.source===id||e?.target===id);
|
|
21
|
+
return {handoffs:list(index.messages).filter(related).length,calls:list(index.calls).filter(related).length,artifacts:list(index.artifacts).filter(related).length};
|
|
22
|
+
}
|
|
23
|
+
function roles(graph){
|
|
24
|
+
const nodes=list(graph.nodes),byId=new Map(),bad=new Set();let invalid=0;
|
|
25
|
+
for(const n of nodes.slice(0,100000)){
|
|
26
|
+
if(!n||typeof n.id!=='string'||!n.id||n.id.length>4096){invalid++;continue}
|
|
27
|
+
if(byId.has(n.id)){bad.add(n.id);continue}
|
|
28
|
+
// Register every identity first. A runtime/agent ID collision is not a role.
|
|
29
|
+
byId.set(n.id,n);
|
|
30
|
+
}
|
|
31
|
+
const rows=[];
|
|
32
|
+
for(const [id,n] of byId){
|
|
33
|
+
if(bad.has(id)||n.type!=='agent')continue;
|
|
34
|
+
rows.push({id,name:label(n.name)||id,role:label(n.attributes?.role)||label(n.attributes?.agent_role),
|
|
35
|
+
provider:label(n.attributes?.provider)||label(n.attributes?.framework)});
|
|
36
|
+
if(rows.length>=10000)break;
|
|
37
|
+
}
|
|
38
|
+
rows.sort((a,b)=>a.name.localeCompare(b.name)||a.id.localeCompare(b.id));
|
|
39
|
+
return {rows,ambiguous:bad.size,partial:invalid>0||bad.size>0||nodes.length>100000||rows.length>=10000||
|
|
40
|
+
!!graph.live_payload_compact||!!graph.viewer_projection};
|
|
41
|
+
}
|
|
42
|
+
const section=document.getElementById('details')?.closest('.inspector-section');if(!section)return;
|
|
43
|
+
const host=make('details');host.id='execweave-run-guide';host.open=true;
|
|
44
|
+
const summary=make('summary','Start with roles');
|
|
45
|
+
const search=make('input');search.type='search';search.placeholder='Find a recorded role';search.setAttribute('aria-label','Find role in run guide');
|
|
46
|
+
const status=make('p');status.id='execweave-run-guide-status';status.setAttribute('role','status');
|
|
47
|
+
const rowsHost=make('div');rowsHost.id='execweave-run-guide-roles';
|
|
48
|
+
const actions=make('div');actions.className='run-guide-actions';
|
|
49
|
+
for(const [tab,name] of [['agents','All roles'],['calls','Browse calls'],['messages','Browse handoffs'],['artifacts','Browse artifacts']]){
|
|
50
|
+
actions.append(button(name,()=>{if(!window.__execweaveInvestigation?.openTab?.(tab))status.textContent='The investigation reader is unavailable.'}));
|
|
51
|
+
}
|
|
52
|
+
const selected=make('div');selected.className='run-guide-selected';selected.hidden=true;
|
|
53
|
+
const selectedLabel=make('p');selected.append(selectedLabel);
|
|
54
|
+
let selectedRole=null;
|
|
55
|
+
function openSelected(tab){
|
|
56
|
+
if(!selectedRole||!window.__execweaveInvestigation?.openForAgent?.(tab,selectedRole.id)){
|
|
57
|
+
status.textContent='No unique accepted evidence index is available for this selected role.';return;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
for(const [tab,name] of [['messages','Handoffs for selected role'],['calls','Calls for selected role'],['artifacts','Artifacts for selected role']])selected.append(button(name,()=>openSelected(tab)));
|
|
61
|
+
selected.append(button('Content health',()=>{if(!window.__execweaveContentHealth?.open)status.textContent='Content health is unavailable.';else window.__execweaveContentHealth.open()}));
|
|
62
|
+
let pinned=null,lastScope=scope(),lastKey='',pending=false;
|
|
63
|
+
const refreshButton=button('Refresh role list',()=>{if(inventoryBlocked()){update();return}capture();draw()});actions.append(refreshButton);
|
|
64
|
+
host.append(summary,search,status,rowsHost,selected,actions);section.prepend(host);
|
|
65
|
+
// Discovery comes first only when there is no selected evidence to read.
|
|
66
|
+
// Move the existing guide, never close/recreate it: search, focus, buttons and
|
|
67
|
+
// disclosure intent survive selection and live history refreshes.
|
|
68
|
+
const evidence=document.getElementById('details'),empty=document.getElementById('details-empty');
|
|
69
|
+
function placeGuide(){
|
|
70
|
+
const reading=roleInventoryCurrent&&evidence.childElementCount>0&&empty?.hidden!==false;
|
|
71
|
+
const assessment=document.getElementById('execweave-run-assessment');
|
|
72
|
+
if(reading){
|
|
73
|
+
if(evidence.nextSibling!==host)evidence.after(host);
|
|
74
|
+
if(assessment?.parentElement===section&&host.nextSibling!==assessment)host.after(assessment);
|
|
75
|
+
}else{
|
|
76
|
+
if(section.firstChild!==host)section.prepend(host);
|
|
77
|
+
if(assessment?.parentElement===section&&host.nextSibling!==assessment)host.after(assessment);
|
|
78
|
+
}
|
|
79
|
+
// The separate delivery summary is deliberately not moved. Export/sync
|
|
80
|
+
// failures stay ahead of the selected body while full assessment stays reachable.
|
|
81
|
+
}
|
|
82
|
+
new MutationObserver(placeGuide).observe(evidence,{childList:true});
|
|
83
|
+
if(empty)new MutationObserver(placeGuide).observe(empty,{attributes:true,attributeFilter:['hidden']});
|
|
84
|
+
const protection=document.getElementById('protective');
|
|
85
|
+
if(protection)new MutationObserver(placeGuide).observe(protection,{attributes:true,attributeFilter:['hidden']});
|
|
86
|
+
placeGuide();
|
|
87
|
+
function capture(){
|
|
88
|
+
pinned=roles(raw());
|
|
89
|
+
const index=window.__execweaveInvestigation?.getIndex?.();
|
|
90
|
+
pinned.rows=pinned.rows.map(r=>({...r,evidence:evidenceCounts(r.id,index)}));
|
|
91
|
+
lastKey=JSON.stringify(roles(raw()));pending=false
|
|
92
|
+
}
|
|
93
|
+
function inspect(id){
|
|
94
|
+
if(inventoryBlocked()){update();return}
|
|
95
|
+
if(scope()!==lastScope){update();return}
|
|
96
|
+
const current=roles(raw()).rows.filter(r=>r.id===id);
|
|
97
|
+
if(current.length!==1){status.textContent='This exact role is no longer unique. Refresh the role list; no same-name replacement is used.';return}
|
|
98
|
+
const core=window.__execweaveCore;
|
|
99
|
+
if(protectedView()){
|
|
100
|
+
const matches=list(raw().nodes).filter(n=>n?.type==='agent'&&n.id===id);
|
|
101
|
+
if(matches.length!==1){status.textContent='This exact role is not uniquely available in the current full snapshot.';return}
|
|
102
|
+
window.__execweaveDashboard?.agentPanel?.render?.(matches[0]);
|
|
103
|
+
status.textContent='Canvas rendering is paused for safety; showing this exact role from the current full snapshot.';
|
|
104
|
+
}else{
|
|
105
|
+
const display=core?.getDisplayGraph?.()||raw();
|
|
106
|
+
const matches=list(display.nodes).filter(n=>n?.type==='agent'&&(n.id===id||list(n.attributes?.viewer_agent_member_ids).includes(id)));
|
|
107
|
+
if(matches.length!==1){status.textContent='This role is not uniquely represented in the current canvas. All roles retains its indexed evidence.';return}
|
|
108
|
+
core?.selectNode?.(matches[0].id);window.__execweaveDashboard?.agentPanel?.render?.(matches[0]);
|
|
109
|
+
}
|
|
110
|
+
selectedRole=(pinned?.rows||[]).find(r=>r.id===id)||current[0];selected.hidden=false;
|
|
111
|
+
const c=selectedRole.evidence;
|
|
112
|
+
selectedLabel.textContent='Selected exact role: '+selectedRole.name+(c?` · ${c.handoffs} handoff(s) · ${c.calls} call(s) · ${c.artifacts} artifact(s)`: ' · accepted detailed inventory unavailable');
|
|
113
|
+
// A role selection is an explicit action; bring its body into view without
|
|
114
|
+
// fitting the graph or changing the camera mode.
|
|
115
|
+
document.getElementById('details')?.scrollIntoView({block:'nearest'});
|
|
116
|
+
}
|
|
117
|
+
function draw(){
|
|
118
|
+
if(!pinned)return;
|
|
119
|
+
const q=search.value.toLocaleLowerCase(),matches=pinned.rows.filter(r=>!q||[r.id,r.name,r.role,r.provider].some(v=>v.toLocaleLowerCase().includes(q)));
|
|
120
|
+
const shown=matches.slice(0,q?25:6);rowsHost.replaceChildren();
|
|
121
|
+
for(const r of shown){
|
|
122
|
+
const counts=r.evidence,total=counts?counts.handoffs+counts.calls+counts.artifacts:0;
|
|
123
|
+
const suffix=counts&&total?` · ${counts.handoffs} handoff · ${counts.calls} call · ${counts.artifacts} artifact`:'';
|
|
124
|
+
const b=button([r.name,r.role,r.provider].filter(Boolean).join(' · ')+suffix,()=>inspect(r.id));
|
|
125
|
+
b.dataset.agentId=r.id;b.title=r.id;rowsHost.append(b);
|
|
126
|
+
}
|
|
127
|
+
status.textContent=`${matches.length} recorded role(s); showing ${shown.length}. `+
|
|
128
|
+
(pinned.partial?'Partial published inventory. ':'')+
|
|
129
|
+
(pinned.ambiguous?`${pinned.ambiguous} ambiguous identities withheld. `:'')+
|
|
130
|
+
(pending?'Updated roles are available; refresh to replace this list. ':'')+
|
|
131
|
+
'The complete graph and runtime evidence are unchanged.';
|
|
132
|
+
}
|
|
133
|
+
function update(){
|
|
134
|
+
const blocked=inventoryBlocked();search.disabled=blocked;
|
|
135
|
+
for(const b of actions.querySelectorAll('button'))b.disabled=blocked;
|
|
136
|
+
if(blocked){pinned=null;selectedRole=null;selected.hidden=true;rowsHost.replaceChildren();status.textContent='Large-graph protection received a compact/stale payload. The retained graph is not used as the current role inventory.';return}
|
|
137
|
+
const now=scope();
|
|
138
|
+
if(now!==lastScope){lastScope=now;search.value='';selectedRole=null;selected.hidden=true;capture();draw();return}
|
|
139
|
+
if(!pinned){capture();draw();return}
|
|
140
|
+
if(JSON.stringify(roles(raw()))!==lastKey){pending=true;status.textContent='Updated roles are available. Refresh the role list; current search and buttons are retained.';return}
|
|
141
|
+
if(protectedView())status.textContent='Large-graph canvas rendering is paused. Role discovery remains available from the current full snapshot; raw evidence is unchanged.';
|
|
142
|
+
}
|
|
143
|
+
search.addEventListener('input',draw);
|
|
144
|
+
const previous=window.__execweaveDashboard||{};
|
|
145
|
+
window.__execweaveDashboard={...previous,onPayload(...args){previous.onPayload?.(...args);observePayload(args);update()},onFinished(...args){previous.onFinished?.(...args);update()}};
|
|
146
|
+
window.addEventListener('pagehide',()=>{pinned=null;selectedRole=null;selected.hidden=true;rowsHost.replaceChildren();search.value=''});
|
|
147
|
+
window.__execweaveRunGuide={roles,refresh:()=>{if(inventoryBlocked()){update();return}capture();draw()}};update();
|
|
148
|
+
})();
|
|
149
|
+
""".strip()
|
|
150
|
+
|
|
151
|
+
RUN_GUIDE_CSS = r"""
|
|
152
|
+
#execweave-run-guide{margin:0 0 14px;padding:10px;border:1px solid var(--border,#888);border-radius:8px;font-size:13px}
|
|
153
|
+
#execweave-run-guide summary{font-size:15px;font-weight:600;cursor:pointer;margin-bottom:8px}
|
|
154
|
+
#execweave-run-guide input{box-sizing:border-box;width:100%;font:inherit;padding:6px;background:var(--panel);color:var(--text);border:1px solid var(--border);border-radius:5px}
|
|
155
|
+
#execweave-run-guide p{font-size:12px;line-height:1.4;overflow-wrap:anywhere}
|
|
156
|
+
#execweave-run-guide-roles{display:flex;flex-direction:column;gap:5px;max-height:140px;overflow:auto}
|
|
157
|
+
#execweave-run-guide button{font:inherit;background:var(--panel2);color:var(--text);border:1px solid var(--border);border-radius:5px;cursor:pointer;padding:6px;text-align:left;overflow-wrap:anywhere}
|
|
158
|
+
#execweave-run-guide .run-guide-actions{display:flex;flex-wrap:wrap;gap:5px;margin-top:8px}
|
|
159
|
+
""".strip()
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def inject_run_guide(html: str) -> str:
|
|
163
|
+
if 'id="execweave-run-guide-script"' in html:
|
|
164
|
+
return html
|
|
165
|
+
if "</body>" not in html:
|
|
166
|
+
raise RuntimeError("run guide requires a dashboard body")
|
|
167
|
+
return html.replace(
|
|
168
|
+
"</body>",
|
|
169
|
+
"<style>"
|
|
170
|
+
+ RUN_GUIDE_CSS
|
|
171
|
+
+ '</style><script id="execweave-run-guide-script">'
|
|
172
|
+
+ RUN_GUIDE_JS
|
|
173
|
+
+ "</script></body>",
|
|
174
|
+
1,
|
|
175
|
+
)
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"""Inspect recorded runtime neighborhoods without asserting semantic ownership.
|
|
2
|
+
|
|
3
|
+
The navigator reads the already-published graph only. Correlation remains labeled
|
|
4
|
+
as correlation, disconnected evidence remains searchable, and no workspace path
|
|
5
|
+
or remote endpoint is ever opened. Graph geometry and raw data are not mutated.
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
RUNTIME_EVIDENCE_JS = r"""
|
|
10
|
+
(()=>{
|
|
11
|
+
'use strict';
|
|
12
|
+
if(window.__execweaveRuntimeEvidence)return;
|
|
13
|
+
const PAGE=25,MAX_RECORDS=100000,MAX_ROWS=10000,MAX_RELATIONS=100,MAX_DEPTH=4;
|
|
14
|
+
const runtimeTypes=new Set(['process','file','directory','artifact','network_endpoint','network_connection','socket','provider','runtime','model_runtime','inference_runtime','inference_gateway','host']);
|
|
15
|
+
const transitTypes=new Set(['process','tool_call','model_call','inference_call','inference_request','agent_execution','agent_turn','command']);
|
|
16
|
+
const semanticTypes=new Set(['agent','tool_call','model_call','inference_call','inference_request','agent_execution']);
|
|
17
|
+
const list=x=>Array.isArray(x)?x:[],obj=x=>x&&typeof x==='object'&&!Array.isArray(x)?x:{};
|
|
18
|
+
const id=x=>typeof x==='string'&&x.length>0&&x.length<=4096?x:null;
|
|
19
|
+
const label=x=>typeof x==='string'?x.slice(0,2048):'';
|
|
20
|
+
const attrs=x=>obj(x?.attributes);
|
|
21
|
+
const viewOnly=x=>[x,attrs(x)].some(o=>o?.viewer_only!==undefined&&o?.viewer_only!==null&&o?.viewer_only!==false);
|
|
22
|
+
const inferred=x=>[x,attrs(x)].some(o=>o?.inferred!==undefined&&o?.inferred!==null&&o?.inferred!==false);
|
|
23
|
+
const raw=()=>window.__execweaveCore?.getGraph?.()||window.__execweaveStaticGraph||{};
|
|
24
|
+
const scope=()=>JSON.stringify([raw().run_id??null,raw().session_id??null,raw().source_path??null]);
|
|
25
|
+
const make=(tag,text)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=String(text);return n};
|
|
26
|
+
const button=(text,action)=>{const b=make('button',text);b.type='button';b.onclick=action;return b};
|
|
27
|
+
function buildIndex(graph,anchorIds=[]){
|
|
28
|
+
const byId=new Map(),bad=new Set(),edges=[],edgeIds=new Map(),badEdges=new Set();
|
|
29
|
+
let inspected=0,limited=false,invalid=0,omitted=0;
|
|
30
|
+
const containers=[graph],clusters=obj(obj(graph.expansion).clusters);
|
|
31
|
+
let clusterCount=0;
|
|
32
|
+
for(const cluster of Object.values(clusters)){if(++clusterCount>1000){limited=true;break}if(cluster&&typeof cluster==='object')containers.push(cluster)}
|
|
33
|
+
for(const container of containers)for(const key of ['nodes','edges']){
|
|
34
|
+
if(container[key]!==undefined&&!Array.isArray(container[key])){invalid++;continue}
|
|
35
|
+
for(const item of list(container[key])){
|
|
36
|
+
if(inspected++>=MAX_RECORDS){limited=true;break}
|
|
37
|
+
if(!item||typeof item!=='object'||Array.isArray(item)){invalid++;continue}
|
|
38
|
+
if(viewOnly(item))continue;
|
|
39
|
+
if(key==='nodes'){
|
|
40
|
+
const key=id(item.id);if(!key){invalid++;continue}
|
|
41
|
+
// Conflicting IDs are withheld. Labels never resolve an identity.
|
|
42
|
+
if(byId.has(key)){if(JSON.stringify(byId.get(key))!==JSON.stringify(item))bad.add(key)}else byId.set(key,item);
|
|
43
|
+
}else{
|
|
44
|
+
if(!id(item.source)||!id(item.target)||!id(item.relation)){invalid++;continue}
|
|
45
|
+
const key=id(item.id);
|
|
46
|
+
if(key&&edgeIds.has(key)){if(JSON.stringify(edgeIds.get(key))!==JSON.stringify(item))badEdges.add(key)}else{if(key)edgeIds.set(key,item);edges.push(item)}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
for(const key of bad)byId.delete(key);
|
|
51
|
+
const adjacency=new Map();
|
|
52
|
+
let dangling=0;
|
|
53
|
+
for(const e of edges){
|
|
54
|
+
if(badEdges.has(e.id))continue;
|
|
55
|
+
if(!byId.has(e.source)||!byId.has(e.target)){dangling++;continue}
|
|
56
|
+
for(const key of new Set([e.source,e.target])){if(!adjacency.has(key))adjacency.set(key,[]);adjacency.get(key).push(e)}
|
|
57
|
+
}
|
|
58
|
+
const edgeRow=e=>({id:id(e.id),source:e.source,target:e.target,relation:e.relation,
|
|
59
|
+
inferred:inferred(e),causal:e.causal===true&&attrs(e).causal!==false&&!inferred(e),timestamp:label(e.first_seen),
|
|
60
|
+
count:Number.isSafeInteger(e.count)&&e.count>=0?e.count:null});
|
|
61
|
+
const seeds=[...new Set(list(anchorIds).filter(x=>id(x)&&byId.has(x)))];
|
|
62
|
+
const callTypes=new Set(['tool_call','model_call','inference_call','inference_request']);
|
|
63
|
+
const invocationOnly=seeds.length===1&&callTypes.has(byId.get(seeds[0])?.type);
|
|
64
|
+
const paths=new Map(seeds.map(x=>[x,[]])),queue=[...seeds];let traversed=0,walkLimited=false;
|
|
65
|
+
for(let at=0;at<queue.length;at++){
|
|
66
|
+
const current=queue[at],path=paths.get(current);
|
|
67
|
+
if(path.length>=MAX_DEPTH){if((adjacency.get(current)||[]).length)walkLimited=true;continue}
|
|
68
|
+
for(const e of adjacency.get(current)||[]){
|
|
69
|
+
if(++traversed>MAX_RECORDS){walkLimited=true;break}
|
|
70
|
+
const next=e.source===current?e.target:e.source,node=byId.get(next);
|
|
71
|
+
if(!node||paths.has(next)||node.type==='agent')continue;
|
|
72
|
+
if(invocationOnly&&callTypes.has(node.type))continue;
|
|
73
|
+
// Never use shared model/tool/file/network resources to bridge siblings.
|
|
74
|
+
// Calls can be found from a selected shared resource, but not crossed
|
|
75
|
+
// through it while starting from a particular agent or invocation.
|
|
76
|
+
if(!runtimeTypes.has(node.type)&&!transitTypes.has(node.type))continue;
|
|
77
|
+
if(byId.get(current)?.type==='process'&&node.type==='process'&&e.source!==current)continue;
|
|
78
|
+
paths.set(next,[...path,edgeRow(e)]);
|
|
79
|
+
if(transitTypes.has(node.type))queue.push(next);
|
|
80
|
+
if(paths.size>=MAX_ROWS){walkLimited=true;break}
|
|
81
|
+
}
|
|
82
|
+
if(traversed>MAX_RECORDS||paths.size>=MAX_ROWS)break;
|
|
83
|
+
}
|
|
84
|
+
const rows=[];
|
|
85
|
+
for(const [key,n] of byId){
|
|
86
|
+
if(!runtimeTypes.has(n.type))continue;
|
|
87
|
+
if(rows.length>=MAX_ROWS){omitted++;continue}
|
|
88
|
+
const all=adjacency.get(key)||[],a=attrs(n),metadata={};
|
|
89
|
+
// Do not dump arbitrary attributes or fetch a body, file, or URL.
|
|
90
|
+
for(const k of ['pid','ppid','path','host','port','protocol','provider','runtime','executable','operation','status','return_code']){
|
|
91
|
+
const v=a[k];if(typeof v==='string')metadata[k]=label(v);else if(typeof v==='number'&&Number.isFinite(v))metadata[k]=v;else if(typeof v==='boolean')metadata[k]=v;
|
|
92
|
+
}
|
|
93
|
+
const links=all.map(edgeRow),direct=all.some(e=>semanticTypes.has(byId.get(e.source===key?e.target:e.source)?.type));
|
|
94
|
+
rows.push({id:key,name:label(n.name)||key,type:n.type,first_seen:label(n.first_seen),last_seen:label(n.last_seen),metadata,
|
|
95
|
+
path:paths.get(key)||null,direct_semantic_link:direct,relations:links.slice(0,MAX_RELATIONS),relation_count:links.length});
|
|
96
|
+
}
|
|
97
|
+
return {rows,seeds,requested_anchors:list(anchorIds),inspected:Math.min(inspected,MAX_RECORDS),invalid,
|
|
98
|
+
ambiguous_ids:bad.size,ambiguous_edge_ids:badEdges.size,dangling_edges:dangling,omitted,
|
|
99
|
+
partial:limited||omitted>0||bad.size>0||badEdges.size>0||invalid>0||dangling>0||!!graph.live_payload_compact||!!graph.viewer_projection,
|
|
100
|
+
walk_limited:walkLimited,max_depth:MAX_DEPTH};
|
|
101
|
+
}
|
|
102
|
+
let dialog=null,search,category,connection,status,notice,body,previous,next,reset;
|
|
103
|
+
let pinned=null,anchors=[],currentScope=scope(),page=0,invoker=null,selectionPanel=null,selectionKey='';
|
|
104
|
+
const opened=new Set();
|
|
105
|
+
function close(){if(dialog){dialog.close();body.replaceChildren();search.value='';notice.textContent=''}pinned=null;anchors=[];invoker?.focus()}
|
|
106
|
+
function checkScope(){if(scope()===currentScope)return true;currentScope=scope();opened.clear();close();return false}
|
|
107
|
+
function ensure(){
|
|
108
|
+
if(dialog)return;
|
|
109
|
+
dialog=make('dialog');dialog.id='execweave-runtime-dialog';dialog.setAttribute('aria-labelledby','execweave-runtime-title');
|
|
110
|
+
const head=make('header'),title=make('h2','Runtime evidence');title.id='execweave-runtime-title';head.append(title,button('Close runtime evidence',close));
|
|
111
|
+
const boundary=make('p','Recorded graph relationships are navigation evidence, not proof of agent ownership. Inferred correlation stays labeled. Remote-tool internals and unobserved file contents are not reconstructed. Display labels and metadata values are limited to 2,048 characters.');
|
|
112
|
+
const form=make('form');search=make('input');search.type='search';search.setAttribute('aria-label','Search runtime evidence');search.placeholder='Search exact IDs, paths, hosts, processes or relationships';
|
|
113
|
+
category=make('select');category.setAttribute('aria-label','Runtime category');
|
|
114
|
+
for(const [value,title] of [['all','All runtime records'],['process','Processes'],['files','Files and artifacts'],['network','Network'],['other','Providers and other runtime']]){const o=make('option',title);o.value=value;category.append(o)}
|
|
115
|
+
connection=make('select');connection.setAttribute('aria-label','Runtime link filter');
|
|
116
|
+
for(const [value,title] of [['all','All relationship evidence'],['inferred','Has inferred relationship'],['no_direct','No direct agent/call edge']]){const o=make('option',title);o.value=value;connection.append(o)}
|
|
117
|
+
form.onsubmit=e=>{e.preventDefault();page=0;draw()};category.onchange=()=>form.requestSubmit();connection.onchange=()=>form.requestSubmit();form.append(search,category,connection,button('Search runtime',()=>form.requestSubmit()));
|
|
118
|
+
const controls=make('div');controls.className='runtime-controls';
|
|
119
|
+
previous=button('Previous runtime records',()=>{page--;draw()});next=button('Next runtime records',()=>{page++;draw()});
|
|
120
|
+
reset=button('Show all runtime evidence',()=>{anchors=[];pinned=buildIndex(raw());page=0;search.value='';notice.textContent='';draw()});
|
|
121
|
+
controls.append(previous,next,reset,button('Refresh runtime snapshot',()=>{if(checkScope()){pinned=buildIndex(raw(),anchors);notice.textContent='';draw()}}));
|
|
122
|
+
status=make('p');status.id='execweave-runtime-status';status.setAttribute('role','status');notice=make('p');notice.id='execweave-runtime-updates';notice.setAttribute('role','status');
|
|
123
|
+
body=make('div');body.id='execweave-runtime-rows';dialog.append(head,boundary,form,controls,status,notice,body);
|
|
124
|
+
// Escape closes this modal, not the underlying canvas selection.
|
|
125
|
+
dialog.addEventListener('keydown',e=>{if(e.key==='Escape')e.stopPropagation()});
|
|
126
|
+
dialog.addEventListener('cancel',e=>{e.preventDefault();close()});document.body.append(dialog);
|
|
127
|
+
}
|
|
128
|
+
function inspect(id){
|
|
129
|
+
if(!checkScope())return;
|
|
130
|
+
window.__execweaveWorkflow?.reveal(id);
|
|
131
|
+
const core=window.__execweaveCore,display=core?.getDisplayGraph?.()||raw();
|
|
132
|
+
const matches=list(display.nodes).filter(n=>n?.id===id);
|
|
133
|
+
if(matches.length!==1){notice.textContent='This exact node is collapsed or absent in the current canvas. Its recorded identity and relationships remain readable here.';return}
|
|
134
|
+
close();core?.selectNode?.(id);
|
|
135
|
+
}
|
|
136
|
+
function rowCard(row){
|
|
137
|
+
const card=make('details');card.className='execweave-runtime-row';card.dataset.runtimeId=row.id;
|
|
138
|
+
card.append(make('summary',[row.type,row.name,row.id].join(' · ')));
|
|
139
|
+
let rendered=false;
|
|
140
|
+
function render(){
|
|
141
|
+
if(rendered)return;rendered=true;card.append(make('p','Exact recorded identity: '+row.id));
|
|
142
|
+
card.append(button('Inspect this runtime node',()=>inspect(row.id)));
|
|
143
|
+
for(const [key,value] of Object.entries(row.metadata))card.append(make('p',key+': '+value));
|
|
144
|
+
if(row.first_seen||row.last_seen)card.append(make('p','Observed: '+row.first_seen+' — '+row.last_seen));
|
|
145
|
+
if(anchors.length){
|
|
146
|
+
card.append(make('p','Recorded navigation path from the selected source (not an ownership claim):'));
|
|
147
|
+
for(const e of row.path||[])card.append(make('p',[e.source,e.relation,e.target,e.inferred?'INFERRED / CORRELATED':'Recorded relationship',e.id||'Edge ID unavailable'].join(' · ')));
|
|
148
|
+
}
|
|
149
|
+
if(!row.direct_semantic_link)card.append(make('p','No direct agent/call edge was recorded for this node. Indirect relationships may exist; no owner is invented.'));
|
|
150
|
+
card.append(make('p',`${row.relation_count} recorded incident relationship(s); showing ${Math.min(row.relation_count,MAX_RELATIONS)}.`));
|
|
151
|
+
for(const e of row.relations)card.append(make('p',[e.source,e.relation,e.target,e.inferred?'INFERRED / CORRELATED — not observed causality':e.causal?'Recorded causal edge':'Recorded relationship — causality not established',e.id||'Edge ID unavailable',e.timestamp].filter(Boolean).join(' · ')));
|
|
152
|
+
if(row.relation_count>MAX_RELATIONS)card.append(make('p','Relationship preview limit reached. The original graph is unchanged.'));
|
|
153
|
+
}
|
|
154
|
+
card.open=opened.has(row.id);if(card.open)render();
|
|
155
|
+
card.addEventListener('toggle',()=>{if(!card.isConnected)return;if(card.open){opened.add(row.id);render();while(opened.size>512)opened.delete(opened.values().next().value)}else opened.delete(row.id)});
|
|
156
|
+
return card;
|
|
157
|
+
}
|
|
158
|
+
function draw(){
|
|
159
|
+
if(!dialog?.open||!pinned||!checkScope())return;
|
|
160
|
+
const q=search.value.toLocaleLowerCase(),c=category.value,f=connection.value;
|
|
161
|
+
const rows=pinned.rows.filter(r=>{
|
|
162
|
+
if(anchors.length&&r.path===null)return false;
|
|
163
|
+
const group=r.type==='process'?'process':['file','directory','artifact'].includes(r.type)?'files':['network_endpoint','network_connection','socket'].includes(r.type)?'network':'other';
|
|
164
|
+
if(c!=='all'&&c!==group)return false;
|
|
165
|
+
if(f==='inferred'&&!r.relations.some(e=>e.inferred)&&!list(r.path).some(e=>e.inferred))return false;
|
|
166
|
+
if(f==='no_direct'&&r.direct_semantic_link)return false;
|
|
167
|
+
return !q||JSON.stringify(r).toLocaleLowerCase().includes(q);
|
|
168
|
+
});
|
|
169
|
+
const pages=Math.max(1,Math.ceil(rows.length/PAGE));page=Math.max(0,Math.min(page,pages-1));previous.disabled=page===0;next.disabled=page===pages-1;
|
|
170
|
+
reset.hidden=!anchors.length;
|
|
171
|
+
status.textContent=`${rows.length} matching / ${pinned.rows.length} indexed runtime nodes. Page ${page+1}/${pages}. `+
|
|
172
|
+
(anchors.length?'Selected source(s): '+anchors.join(', ')+`. Paths are limited to ${MAX_DEPTH} edges; shared resources do not bridge agents. `:'All indexed runtime nodes, including disconnected evidence. ')+
|
|
173
|
+
(pinned.partial?'Partial published inventory; counts are lower bounds, not total capture or attribution recall. ':'Counts describe this published graph, not real-world activity recall. ')+
|
|
174
|
+
(pinned.walk_limited?'Navigation boundary reached. ':'')+
|
|
175
|
+
(pinned.invalid||pinned.ambiguous_ids||pinned.ambiguous_edge_ids||pinned.dangling_edges?`Excluded: ${pinned.invalid} malformed records, ${pinned.ambiguous_ids} conflicting node IDs, ${pinned.ambiguous_edge_ids} conflicting edge IDs, ${pinned.dangling_edges} unresolved edges. `:'')+
|
|
176
|
+
(pinned.omitted?`${pinned.omitted} runtime rows exceed the output limit. `:'');
|
|
177
|
+
if(anchors.length&&pinned.seeds.length!==anchors.length)status.textContent+='One or more selected identities are missing or ambiguous in raw evidence; names are not substituted.';
|
|
178
|
+
body.replaceChildren();body.scrollTop=0;for(const row of rows.slice(page*PAGE,(page+1)*PAGE))body.append(rowCard(row));
|
|
179
|
+
if(!rows.length)body.append(make('p','No matching recorded runtime path. This does not prove no runtime activity occurred. Show all runtime evidence to inspect unlinked records.'));
|
|
180
|
+
}
|
|
181
|
+
function invocationTarget(row){
|
|
182
|
+
if(document.getElementById('protective')?.hidden===false)return {state:'partial',id:null};
|
|
183
|
+
const key=id(row?.native_id),allowed=row?.kind==='tool'?new Set(['tool_call']):
|
|
184
|
+
row?.kind==='model'?new Set(['model_call','inference_call','inference_request']):new Set();
|
|
185
|
+
if(!key||!allowed.size)return {state:'unavailable',id:null};
|
|
186
|
+
const g=raw(),records=list(g.nodes);
|
|
187
|
+
if(g.live_payload_compact||records.length>MAX_RECORDS)return {state:'partial',id:null};
|
|
188
|
+
const matches=records.filter(n=>n?.id===key);
|
|
189
|
+
if(matches.length!==1||!allowed.has(matches[0]?.type)||viewOnly(matches[0])||inferred(matches[0]))
|
|
190
|
+
return {state:matches.length>1?'ambiguous':'unavailable',id:null};
|
|
191
|
+
if(list(g.edges).length>MAX_RECORDS)return {state:'partial',id:null};
|
|
192
|
+
const owners=new Set(),targets=new Set();
|
|
193
|
+
for(const e of list(g.edges)){
|
|
194
|
+
if(!e||viewOnly(e)||inferred(e))continue;
|
|
195
|
+
if(e.target===key&&['REQUESTED_TOOL_CALL','REQUESTS_TOOL_CALL','ISSUED_TOOL_CALL','REQUESTS_MODEL_CALL'].includes(e.relation))owners.add(e.source);
|
|
196
|
+
if(e.source===key&&['USES_TOOL','USED_MODEL'].includes(e.relation))targets.add(e.target);
|
|
197
|
+
}
|
|
198
|
+
if(owners.size>1||targets.size>1||(row.owner_id&&owners.size&&!owners.has(row.owner_id))||
|
|
199
|
+
(row.target_id&&targets.size&&!targets.has(row.target_id)))return {state:'conflicting_participants',id:null};
|
|
200
|
+
return {state:'exact_invocation',id:key};
|
|
201
|
+
}
|
|
202
|
+
function openInvocation(row){const resolved=invocationTarget(row);if(resolved.id)open([resolved.id]);return resolved}
|
|
203
|
+
function open(ids=[]){checkScope();ensure();invoker=document.activeElement;anchors=typeof ids==='string'?[ids]:list(ids).filter(x=>id(x));pinned=buildIndex(raw(),anchors);page=0;search.value='';category.value='all';connection.value='all';notice.textContent='';dialog.showModal();draw()}
|
|
204
|
+
function attachSelection(){
|
|
205
|
+
const selected=document.querySelector('#nodes .node.selected'),details=document.getElementById('details');
|
|
206
|
+
if(!selected||!details){selectionPanel?.remove();selectionPanel=null;selectionKey='';return}
|
|
207
|
+
const id=selected.dataset.id,g=window.__execweaveCore?.getDisplayGraph?.()||raw(),node=list(g.nodes).find(n=>n?.id===id);
|
|
208
|
+
if(!node){selectionPanel?.remove();selectionPanel=null;selectionKey='';return}
|
|
209
|
+
const members=list(attrs(node).viewer_agent_member_ids);
|
|
210
|
+
// A projected agent can only refer to raw agent identities, never runtime
|
|
211
|
+
// nodes or a same-named peer. Missing members remain unresolved seeds.
|
|
212
|
+
const ids=node.type==='agent'&&members.length?members.filter(key=>{const n=list(raw().nodes).find(n=>n?.id===key);return !n||n.type==='agent'}):[id];
|
|
213
|
+
if(!ids.length)ids.push(id);
|
|
214
|
+
const key=JSON.stringify([scope(),id,ids]);if(selectionPanel?.isConnected&&selectionKey===key)return;
|
|
215
|
+
selectionPanel?.remove();selectionKey=key;selectionPanel=make('section');selectionPanel.id='execweave-runtime-selection';
|
|
216
|
+
selectionPanel.append(button('Runtime evidence for selection',()=>open(ids)));
|
|
217
|
+
// Keep navigation outside the evidence body: its label is not agent output.
|
|
218
|
+
details.before(selectionPanel);
|
|
219
|
+
}
|
|
220
|
+
let scheduled=false;
|
|
221
|
+
function schedule(){if(scheduled)return;scheduled=true;queueMicrotask(()=>{scheduled=false;attachSelection()})}
|
|
222
|
+
const details=document.getElementById('details');if(details)new MutationObserver(records=>{if(records.some(r=>!selectionPanel?.contains(r.target)))schedule()}).observe(details,{childList:true,subtree:true});
|
|
223
|
+
const nodes=document.getElementById('nodes');if(nodes)new MutationObserver(schedule).observe(nodes,{childList:true,subtree:true,attributes:true,attributeFilter:['class','data-id']});
|
|
224
|
+
const launch=button('Runtime evidence',()=>open());launch.id='execweave-runtime-launcher';const anchor=document.getElementById('theme-toggle');if(anchor?.parentElement)anchor.parentElement.insertBefore(launch,anchor);
|
|
225
|
+
const prior=window.__execweaveDashboard||{};
|
|
226
|
+
function changed(){if(!checkScope())return;if(dialog?.open)notice.textContent='New graph evidence is available. The current runtime snapshot remains pinned until you refresh it.';schedule()}
|
|
227
|
+
window.__execweaveDashboard={...prior,onPayload(...args){prior.onPayload?.(...args);changed()},onFinished(...args){prior.onFinished?.(...args);changed()}};
|
|
228
|
+
window.addEventListener('pagehide',()=>{close();opened.clear()});
|
|
229
|
+
window.__execweaveRuntimeEvidence={open,close,buildIndex,invocationTarget,openInvocation};schedule();
|
|
230
|
+
})();
|
|
231
|
+
""".strip()
|
|
232
|
+
|
|
233
|
+
RUNTIME_EVIDENCE_CSS = r"""
|
|
234
|
+
#execweave-runtime-launcher{font:inherit;cursor:pointer;padding:6px 10px}
|
|
235
|
+
#execweave-runtime-selection{margin:10px 0}#execweave-runtime-selection button{font:inherit;cursor:pointer;padding:7px 10px}
|
|
236
|
+
#execweave-runtime-dialog{width:min(1100px,94vw);max-height:90vh;box-sizing:border-box;background:var(--panel,#fff);color:var(--text,#111);border:1px solid var(--border,#888);border-radius:12px;padding:18px}
|
|
237
|
+
#execweave-runtime-dialog::backdrop{background:rgba(0,0,0,.45)}
|
|
238
|
+
#execweave-runtime-dialog header,#execweave-runtime-dialog form,.runtime-controls{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:10px}
|
|
239
|
+
#execweave-runtime-title{flex:1;font-size:20px;margin:0}
|
|
240
|
+
#execweave-runtime-dialog button,#execweave-runtime-dialog input,#execweave-runtime-dialog select{font:inherit;padding:7px;cursor:pointer}
|
|
241
|
+
#execweave-runtime-dialog input{flex:1;min-width:180px}
|
|
242
|
+
#execweave-runtime-dialog p{font-size:13px;line-height:1.5;overflow-wrap:anywhere}
|
|
243
|
+
#execweave-runtime-rows{max-height:52vh;overflow:auto;overscroll-behavior:contain}
|
|
244
|
+
#execweave-runtime-rows details{padding:10px;border:1px solid var(--border,#888);border-radius:8px;margin:8px 0;overflow-wrap:anywhere}
|
|
245
|
+
#execweave-runtime-rows summary{font-size:15px;cursor:pointer}
|
|
246
|
+
""".strip()
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def inject_runtime_evidence(html: str) -> str:
|
|
250
|
+
if 'id="execweave-runtime-script"' in html:
|
|
251
|
+
return html
|
|
252
|
+
if "</body>" not in html:
|
|
253
|
+
raise RuntimeError("runtime evidence requires a dashboard body")
|
|
254
|
+
return html.replace(
|
|
255
|
+
"</body>", "<style>" + RUNTIME_EVIDENCE_CSS
|
|
256
|
+
+ '</style><script id="execweave-runtime-script">' + RUNTIME_EVIDENCE_JS
|
|
257
|
+
+ "</script>\n</body>", 1,
|
|
258
|
+
)
|