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,127 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
_FOCUS_JS = r"""
|
|
4
|
+
const execweaveDashboardGraphBase=execweaveDashboardGraph;
|
|
5
|
+
execweaveDashboardGraph=function(data){
|
|
6
|
+
const projected=execweaveDashboardGraphBase(data);
|
|
7
|
+
const hiddenTypes=new Set(['agent_trace_capability','session','command','inference_call','code_cell','agent_message']);
|
|
8
|
+
const mergeTypes=new Set(['model','directory','network_endpoint']);
|
|
9
|
+
const providerRootIds=new Set(['agent:Claude Code','agent:OpenAI Codex','agent:Codex','agent:Cursor','agent:OpenCode','agent:Antigravity','agent:Ollama','agent:ollama']);
|
|
10
|
+
const before=Array.isArray(projected.nodes)?projected.nodes:[];
|
|
11
|
+
let prepared=before.filter(node=>node&&!hiddenTypes.has(String(node.type||''))).map(node=>{
|
|
12
|
+
const attrs=node.attributes||{};
|
|
13
|
+
let name=node.name;
|
|
14
|
+
if(node.type==='agent'){
|
|
15
|
+
const provider=String(attrs.provider||'').toLowerCase();
|
|
16
|
+
const agentPath=String(attrs.agent_path||attrs.child_agent_path||attrs.root_agent_path||'').trim();
|
|
17
|
+
const agentId=String(attrs.agent_id||attrs.subagent_id||'');
|
|
18
|
+
const conversationId=String(attrs.conversation_id||'').trim();
|
|
19
|
+
const nickname=String(attrs.agent_nickname||'').trim();
|
|
20
|
+
const nativeLabel=String(nickname||attrs.agent_type||attrs.subagent_type||attrs.native_agent_name||'').trim();
|
|
21
|
+
const explicitChild=!!String(attrs.parent_agent_path||'').trim();
|
|
22
|
+
const explicitRoot=!explicitChild&&(attrs.agent_role==='root'||String(attrs.root_agent_path||'')==='/root'||providerRootIds.has(String(node.id||'')));
|
|
23
|
+
if(explicitRoot)name='/root';
|
|
24
|
+
else if(provider==='antigravity'&&nativeLabel&&!['default','agent','subagent','antigravity subagent'].includes(nativeLabel.toLowerCase()))name=nativeLabel;
|
|
25
|
+
else if(agentPath)name=agentPath;
|
|
26
|
+
else if(provider==='antigravity'&&conversationId)name=`conversation · ${conversationId.slice(0,8)}`;
|
|
27
|
+
else if(['default','agent','subagent','antigravity conversation'].includes(String(node.name||'').toLowerCase())){
|
|
28
|
+
// Never label by a timestamp-ordered id prefix: siblings spawned in the
|
|
29
|
+
// same millisecond share it and render as the same node.
|
|
30
|
+
if(nickname)name=`subagent · ${nickname}`;
|
|
31
|
+
else if(nativeLabel)name=`subagent · ${nativeLabel}`;
|
|
32
|
+
else if(agentId)name=`subagent · ${agentId.slice(0,13)}`;
|
|
33
|
+
else name=`agent · ${String(node.id||'').split(':').at(-1).slice(0,13)}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const occurrenceCount=Number(attrs.viewer_occurrence_count||0);
|
|
37
|
+
if(node.type==='process'&&occurrenceCount>1&&!/\s×\d+$/.test(String(name||'')))name=`${name||node.id} ×${occurrenceCount}`;
|
|
38
|
+
return name===node.name?node:{...node,name};
|
|
39
|
+
});
|
|
40
|
+
const presentationAlias=new Map();
|
|
41
|
+
const antigravityRoot=prepared.find(node=>String(node?.id||'')==='agent:Antigravity');
|
|
42
|
+
const antigravityScoped=prepared.filter(node=>{
|
|
43
|
+
const attrs=node?.attributes||{};
|
|
44
|
+
return node?.type==='agent'&&String(attrs.provider||'').toLowerCase()==='antigravity'&&
|
|
45
|
+
String(node.id||'').startsWith('agent:antigravity:conversation:');
|
|
46
|
+
});
|
|
47
|
+
const parentScopes=new Set(antigravityScoped.filter(node=>String(node?.attributes?.parent_agent_path||'').trim()).map(node=>String(node?.attributes?.parent_scope_id||'')).filter(Boolean));
|
|
48
|
+
const evidenceMains=antigravityScoped.filter(node=>{const attrs=node?.attributes||{};return !String(attrs.parent_agent_path||'').trim()&&parentScopes.has(String(attrs.conversation_id||''));});
|
|
49
|
+
const fallbackMains=antigravityScoped.filter(node=>{const attrs=node?.attributes||{};return !String(attrs.parent_agent_path||'').trim()&&!attrs.routing_identity_only;});
|
|
50
|
+
const antigravityMains=evidenceMains.length?evidenceMains:fallbackMains;
|
|
51
|
+
if(antigravityRoot&&antigravityMains.length===1){
|
|
52
|
+
const main=antigravityMains[0];presentationAlias.set(antigravityRoot.id,main.id);
|
|
53
|
+
prepared=prepared.filter(node=>node.id!==antigravityRoot.id).map(node=>node.id===main.id?{...node,name:'/root'}:node);
|
|
54
|
+
}else if(antigravityRoot&&antigravityScoped.length){
|
|
55
|
+
prepared=prepared.filter(node=>node.id!==antigravityRoot.id);
|
|
56
|
+
}
|
|
57
|
+
const ollamaRoots=prepared.filter(node=>node?.type==='agent'&&['agent:Ollama','agent:ollama'].includes(String(node.id||'')));
|
|
58
|
+
const ollamaRuntimes=prepared.filter(node=>node?.type==='model_runtime'&&String(node?.attributes?.provider||'').toLowerCase()==='ollama');
|
|
59
|
+
const runtimeContextSupport=new Map();
|
|
60
|
+
// Same provider/cardinality does not establish runtime ownership. Compress a
|
|
61
|
+
// context only when an explicit, unambiguous agent->runtime observation exists.
|
|
62
|
+
// Otherwise retain the runtime and its original catalog edges, including old
|
|
63
|
+
// failed-launch artifacts that contain observations of a pre-existing server.
|
|
64
|
+
for(const runtime of ollamaRuntimes){
|
|
65
|
+
const incoming=(projected.edges||[]).filter(e=>e?.target===runtime.id&&prepared.some(n=>n.id===e.source&&n.type==='agent'));
|
|
66
|
+
const owners=[...new Set(incoming.map(e=>e.source))];
|
|
67
|
+
const root=owners.length===1?ollamaRoots.find(n=>n.id===owners[0]):null;
|
|
68
|
+
const support=incoming.filter(e=>e.relation==='OBSERVED_MODEL_RUNTIME');
|
|
69
|
+
const conflict=(a,b)=>['provider','run_id','session_id','conversation_id','provider_session_id','agent_path'].some(k=>
|
|
70
|
+
a?.[k]&&b?.[k]&&String(a[k])!==String(b[k]));
|
|
71
|
+
const identities=[runtime.attributes||{},root?.attributes||{},...incoming.map(e=>e.attributes||{})];
|
|
72
|
+
if(!root||!support.length||identities.some((a,i)=>identities.slice(0,i).some(b=>conflict(a,b))))continue;
|
|
73
|
+
presentationAlias.set(runtime.id,root.id);runtimeContextSupport.set(runtime.id,support);
|
|
74
|
+
prepared=prepared.filter(node=>node.id!==runtime.id);
|
|
75
|
+
}
|
|
76
|
+
const normalized=value=>String(value||'').trim().replaceAll('\\\\','/').replace(/\/+$/,'').toLowerCase();
|
|
77
|
+
const canonicalKey=node=>{
|
|
78
|
+
const type=String(node?.type||''),attrs=node?.attributes||{};
|
|
79
|
+
if(!mergeTypes.has(type))return `id\u0000${node.id}`;
|
|
80
|
+
if(type==='model')return `${type}\u0000${normalized(attrs.provider)}\u0000${normalized(attrs.model||attrs.model_name||node.name)}`;
|
|
81
|
+
if(type==='directory')return `${type}\u0000${normalized(attrs.path||attrs.directory||attrs.cwd||attrs.real_path||node.name)}`;
|
|
82
|
+
const host=attrs.host||attrs.hostname||attrs.address||attrs.ip||attrs.remote_host||'',port=attrs.port||attrs.remote_port||'';
|
|
83
|
+
return `${type}\u0000${normalized(host||attrs.endpoint||node.name)}\u0000${normalized(port)}`;
|
|
84
|
+
};
|
|
85
|
+
const groups=new Map();for(const node of prepared){const key=canonicalKey(node);if(!groups.has(key))groups.set(key,[]);groups.get(key).push(node)}
|
|
86
|
+
const canonicalId=new Map(presentationAlias),nodes=[];let mergedContextNodeCount=0;
|
|
87
|
+
const earlier=(a,b)=>!a?b:!b?a:(String(a)<=String(b)?a:b),later=(a,b)=>!a?b:!b?a:(String(a)>=String(b)?a:b);
|
|
88
|
+
for(const group of groups.values()){
|
|
89
|
+
group.sort((a,b)=>String(a.first_seen||'').localeCompare(String(b.first_seen||''))||String(a.id).localeCompare(String(b.id)));
|
|
90
|
+
const base=group[0];for(const item of group)canonicalId.set(item.id,base.id);
|
|
91
|
+
if(group.length===1){nodes.push(base);continue}
|
|
92
|
+
mergedContextNodeCount+=group.length-1;
|
|
93
|
+
const firstSeen=group.reduce((value,item)=>earlier(value,item.first_seen),null),lastSeen=group.reduce((value,item)=>later(value,item.last_seen),null);
|
|
94
|
+
const baseName=String(base.name||base.id).replace(/\s×\d+$/,'');
|
|
95
|
+
nodes.push({...base,name:`${baseName} ×${group.length}`,first_seen:firstSeen||base.first_seen,last_seen:lastSeen||base.last_seen,attributes:{...(base.attributes||{}),viewer_canonicalized:true,viewer_occurrence_count:group.length,viewer_occurrence_ids:group.map(item=>item.id),viewer_occurrences:group.map(item=>({id:item.id,name:item.name||null,first_seen:item.first_seen||null,last_seen:item.last_seen||null}))}});
|
|
96
|
+
}
|
|
97
|
+
const ids=new Set(nodes.map(node=>node.id));
|
|
98
|
+
const remapped=[];for(const edge of(projected.edges||[])){
|
|
99
|
+
if(!edge)continue;const source=canonicalId.get(edge.source)||edge.source,target=canonicalId.get(edge.target)||edge.target;
|
|
100
|
+
if(!ids.has(source)||!ids.has(target)||source===target)continue;
|
|
101
|
+
const support=runtimeContextSupport.get(edge.source);
|
|
102
|
+
if(support){
|
|
103
|
+
remapped.push({...edge,source,target,viewer_only:true,inferred:true,causal:false,
|
|
104
|
+
viewer_runtime_context:true,viewer_original_source:edge.source,viewer_original_target:edge.target,
|
|
105
|
+
viewer_supporting_edges:[...support,edge]});
|
|
106
|
+
}else remapped.push(source===edge.source&&target===edge.target?edge:{...edge,source,target,viewer_canonicalized:true,viewer_original_source:edge.source,viewer_original_target:edge.target});
|
|
107
|
+
}
|
|
108
|
+
const edgeGroups=new Map();
|
|
109
|
+
for(const edge of remapped){const key=`${edge.source}\u0000${edge.relation||''}\u0000${edge.target}${edge.viewer_runtime_context?'\u0000'+edge.viewer_original_source:''}`,existing=edgeGroups.get(key);if(!existing){edgeGroups.set(key,{...edge,viewer_edge_occurrence_count:1,viewer_edge_occurrence_ids:[edge.id]});continue}existing.viewer_edge_occurrence_count+=1;existing.viewer_edge_occurrence_ids.push(edge.id);existing.count=Number(existing.count||1)+Number(edge.count||1);if(Number.isInteger(edge.first_sequence))existing.first_sequence=Number.isInteger(existing.first_sequence)?Math.min(existing.first_sequence,edge.first_sequence):edge.first_sequence;if(Number.isInteger(edge.last_sequence))existing.last_sequence=Number.isInteger(existing.last_sequence)?Math.max(existing.last_sequence,edge.last_sequence):edge.last_sequence;existing.first_seen=earlier(existing.first_seen,edge.first_seen);existing.last_seen=later(existing.last_seen,edge.last_seen)}
|
|
110
|
+
const edges=[...edgeGroups.values()];
|
|
111
|
+
return{...projected,nodes,edges,node_count:nodes.length,edge_count:edges.length,dashboard_projection:{...(projected.dashboard_projection||{}),hidden_context_node_count:before.length-prepared.length,merged_context_node_count:mergedContextNodeCount,hidden_orphan_file_node_count:0}};
|
|
112
|
+
};
|
|
113
|
+
""".strip()
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _inject(html: str, marker: str) -> str:
|
|
117
|
+
if "execweaveDashboardGraphBase" in html or marker not in html:
|
|
118
|
+
return html
|
|
119
|
+
return html.replace(marker, _FOCUS_JS + "\n" + marker, 1)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def inject_standalone_dashboard_focus(html: str) -> str:
|
|
123
|
+
return _inject(html, "function materializedGraph(){")
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def inject_live_dashboard_focus(html: str) -> str:
|
|
127
|
+
return _inject(html, "function setSnapshot(data){")
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def _replace_once(html: str, old: str, new: str, *, label: str) -> str:
|
|
5
|
+
if old not in html:
|
|
6
|
+
raise RuntimeError(f"dashboard hardening seam changed: {label}")
|
|
7
|
+
return html.replace(old, new, 1)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def harden_dashboard_html(html: str) -> str:
|
|
11
|
+
"""Close v0.8.3 live-layout/tool-panel gaps without changing evidence semantics."""
|
|
12
|
+
|
|
13
|
+
# PM-003: text measurement is synchronous browser layout work and is requested
|
|
14
|
+
# repeatedly by width, wrapping and ellipsis calculations on every live topology
|
|
15
|
+
# rebuild. Cache by the exact string while keeping real browser measurement as the
|
|
16
|
+
# authority. The label font does not change with the light/dark theme; cap the cache
|
|
17
|
+
# so a long-running session with ever-changing paths cannot grow it without bound.
|
|
18
|
+
html = _replace_once(
|
|
19
|
+
html,
|
|
20
|
+
"let execweaveRuler=null;",
|
|
21
|
+
"let execweaveRuler=null,execweaveMeasureCache=new Map();",
|
|
22
|
+
label="measurement cache state",
|
|
23
|
+
)
|
|
24
|
+
html = _replace_once(
|
|
25
|
+
html,
|
|
26
|
+
"""function execweaveMeasure(text){
|
|
27
|
+
const value=String(text||'');
|
|
28
|
+
if(!value)return 0;
|
|
29
|
+
try{
|
|
30
|
+
if(!execweaveRuler){
|
|
31
|
+
execweaveRuler=document.createElementNS('http://www.w3.org/2000/svg','text');
|
|
32
|
+
execweaveRuler.classList.add('name-label');
|
|
33
|
+
execweaveRuler.setAttribute('visibility','hidden');
|
|
34
|
+
execweaveRuler.setAttribute('x','-9999');
|
|
35
|
+
execweaveRuler.setAttribute('y','-9999');
|
|
36
|
+
svg.appendChild(execweaveRuler);
|
|
37
|
+
}
|
|
38
|
+
execweaveRuler.textContent=value;
|
|
39
|
+
const measured=execweaveRuler.getComputedTextLength();
|
|
40
|
+
if(Number.isFinite(measured)&&measured>0)return measured;
|
|
41
|
+
}catch(_){}
|
|
42
|
+
return value.length*7.1;
|
|
43
|
+
}""",
|
|
44
|
+
"""function execweaveRememberMeasure(value,measured){
|
|
45
|
+
if(execweaveMeasureCache.size>=4096)execweaveMeasureCache.clear();
|
|
46
|
+
execweaveMeasureCache.set(value,measured);return measured;
|
|
47
|
+
}
|
|
48
|
+
function execweaveMeasure(text){
|
|
49
|
+
const value=String(text||'');
|
|
50
|
+
if(!value)return 0;
|
|
51
|
+
if(execweaveMeasureCache.has(value))return execweaveMeasureCache.get(value);
|
|
52
|
+
try{
|
|
53
|
+
if(!execweaveRuler){
|
|
54
|
+
execweaveRuler=document.createElementNS('http://www.w3.org/2000/svg','text');
|
|
55
|
+
execweaveRuler.classList.add('name-label');
|
|
56
|
+
execweaveRuler.setAttribute('visibility','hidden');
|
|
57
|
+
execweaveRuler.setAttribute('x','-9999');
|
|
58
|
+
execweaveRuler.setAttribute('y','-9999');
|
|
59
|
+
svg.appendChild(execweaveRuler);
|
|
60
|
+
}
|
|
61
|
+
execweaveRuler.textContent=value;
|
|
62
|
+
const measured=execweaveRuler.getComputedTextLength();
|
|
63
|
+
if(Number.isFinite(measured)&&measured>0)return execweaveRememberMeasure(value,measured);
|
|
64
|
+
}catch(_){}
|
|
65
|
+
return execweaveRememberMeasure(value,value.length*7.1);
|
|
66
|
+
}""",
|
|
67
|
+
label="measurement function",
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# PM-004: childOrder is intentionally child-local for chronological subagent
|
|
71
|
+
# placement, but evidence-lane barycentres need every visible spine agent. Give the
|
|
72
|
+
# root an order coordinate at the centre where it is actually placed and use that
|
|
73
|
+
# broader map only for source-driven evidence ordering/bundle ordering.
|
|
74
|
+
html = _replace_once(
|
|
75
|
+
html,
|
|
76
|
+
""" const childOrder=new Map(children.map((node,index)=>[node.id,index]));
|
|
77
|
+
const rootY=children.length?100+((children.length-1)*EXECWEAVE_ROW_GAP)/2:100;""",
|
|
78
|
+
""" const childOrder=new Map(children.map((node,index)=>[node.id,index]));
|
|
79
|
+
const agentOrder=new Map(childOrder),rootOrder=children.length?(children.length-1)/2:0;
|
|
80
|
+
roots.forEach((node,index)=>agentOrder.set(node.id,rootOrder+index));
|
|
81
|
+
const rootY=children.length?100+((children.length-1)*EXECWEAVE_ROW_GAP)/2:100;""",
|
|
82
|
+
label="root evidence order",
|
|
83
|
+
)
|
|
84
|
+
html = _replace_once(
|
|
85
|
+
html,
|
|
86
|
+
""" const agentBarycenter=node=>{
|
|
87
|
+
const touching=edges.filter(edge=>edge.target===node.id&&childOrder.has(edge.source));
|
|
88
|
+
if(!touching.length)return Number.MAX_SAFE_INTEGER;
|
|
89
|
+
return touching.reduce((sum,edge)=>sum+(childOrder.get(edge.source)||0),0)/touching.length;
|
|
90
|
+
};""",
|
|
91
|
+
""" const agentBarycenter=node=>{
|
|
92
|
+
const touching=edges.filter(edge=>edge.target===node.id&&agentOrder.has(edge.source));
|
|
93
|
+
if(!touching.length)return Number.MAX_SAFE_INTEGER;
|
|
94
|
+
return touching.reduce((sum,edge)=>sum+(agentOrder.get(edge.source)||0),0)/touching.length;
|
|
95
|
+
};""",
|
|
96
|
+
label="tool barycentre source domain",
|
|
97
|
+
)
|
|
98
|
+
html = _replace_once(
|
|
99
|
+
html,
|
|
100
|
+
""" const sourceBarycentre=node=>{
|
|
101
|
+
const touching=edges.filter(edge=>edge.target===node.id&&childOrder.has(edge.source));
|
|
102
|
+
if(!touching.length)return Number.MAX_SAFE_INTEGER;
|
|
103
|
+
return touching.reduce((sum,edge)=>sum+(childOrder.get(edge.source)||0),0)/touching.length;
|
|
104
|
+
};""",
|
|
105
|
+
""" const sourceBarycentre=node=>{
|
|
106
|
+
const touching=edges.filter(edge=>edge.target===node.id&&agentOrder.has(edge.source));
|
|
107
|
+
if(!touching.length)return Number.MAX_SAFE_INTEGER;
|
|
108
|
+
return touching.reduce((sum,edge)=>sum+(agentOrder.get(edge.source)||0),0)/touching.length;
|
|
109
|
+
};""",
|
|
110
|
+
label="evidence barycentre source domain",
|
|
111
|
+
)
|
|
112
|
+
html = _replace_once(
|
|
113
|
+
html,
|
|
114
|
+
"members.sort((a,b)=>(childOrder.get(a.source)??Number.MAX_SAFE_INTEGER)-(childOrder.get(b.source)??Number.MAX_SAFE_INTEGER)||edgeId(a).localeCompare(edgeId(b)));",
|
|
115
|
+
"members.sort((a,b)=>(agentOrder.get(a.source)??Number.MAX_SAFE_INTEGER)-(agentOrder.get(b.source)??Number.MAX_SAFE_INTEGER)||edgeId(a).localeCompare(edgeId(b)));",
|
|
116
|
+
label="bundle source order",
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
# PM-001: adaptive lane x is recomputed from current labels. Preserve stable y, not
|
|
120
|
+
# stale x. The delta path must also move already-rendered nodes and reroute their
|
|
121
|
+
# edges when lane geometry changes; updating only newly-added nodes leaves the DOM
|
|
122
|
+
# visually attached to the previous lane table.
|
|
123
|
+
html = _replace_once(
|
|
124
|
+
html,
|
|
125
|
+
""" for(const id of nodeById.keys()){
|
|
126
|
+
const desired=execweaveDesiredPosition(id),old=prior.get(id);
|
|
127
|
+
next.set(id,old?{x:old.x,y:old.y}:execweavePlaceStable(id,desired,next,id));
|
|
128
|
+
}""",
|
|
129
|
+
""" for(const id of nodeById.keys()){
|
|
130
|
+
const desired=execweaveDesiredPosition(id),old=prior.get(id),stable=old?{x:desired.x,y:old.y}:desired;
|
|
131
|
+
next.set(id,execweavePlaceStable(id,stable,next));
|
|
132
|
+
}""",
|
|
133
|
+
label="full-layout adaptive x",
|
|
134
|
+
)
|
|
135
|
+
html = _replace_once(
|
|
136
|
+
html,
|
|
137
|
+
"""placeAddedNodes=function(ids){
|
|
138
|
+
execweaveTopology=execweaveBuildTopology();
|
|
139
|
+
for(const id of ids||[]){if(!nodeById.has(id)||positions.has(id))continue;positions.set(id,execweavePlaceStable(id,execweaveDesiredPosition(id),positions,id))}
|
|
140
|
+
svg.classList.toggle('execweave-crowded',execweaveTopology.crowded);
|
|
141
|
+
};""",
|
|
142
|
+
"""placeAddedNodes=function(ids){
|
|
143
|
+
const priorLaneX={...(execweaveTopology.laneX||{})};
|
|
144
|
+
execweaveTopology=execweaveBuildTopology();
|
|
145
|
+
const laneShifted=EXECWEAVE_LANE_ORDER.some(lane=>priorLaneX[lane]!==execweaveTopology.laneX[lane]);
|
|
146
|
+
if(laneShifted){
|
|
147
|
+
const next=new Map();
|
|
148
|
+
for(const [id,old] of positions){
|
|
149
|
+
if(!nodeById.has(id))continue;
|
|
150
|
+
const desired=execweaveDesiredPosition(id);
|
|
151
|
+
next.set(id,execweavePlaceStable(id,{x:desired.x,y:old.y},next));
|
|
152
|
+
}
|
|
153
|
+
positions=next;
|
|
154
|
+
}
|
|
155
|
+
for(const id of ids||[]){if(!nodeById.has(id)||positions.has(id))continue;positions.set(id,execweavePlaceStable(id,execweaveDesiredPosition(id),positions))}
|
|
156
|
+
if(laneShifted){
|
|
157
|
+
for(const [id] of nodeElements){const node=nodeById.get(id);if(node)updateNodeElement(node)}
|
|
158
|
+
for(const edge of edgeById.values())updateEdgeElement(edge);
|
|
159
|
+
}
|
|
160
|
+
svg.classList.toggle('execweave-crowded',execweaveTopology.crowded);
|
|
161
|
+
};""",
|
|
162
|
+
label="delta adaptive x",
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
# PM-002: camera geometry must come from the same authoritative dimensions used by
|
|
166
|
+
# the renderer. This also fixes the pre-existing maxY omission that adaptive height
|
|
167
|
+
# made visible.
|
|
168
|
+
html = _replace_once(
|
|
169
|
+
html,
|
|
170
|
+
"""function graphBounds(){if(!positions.size)return null;let minX=Infinity,maxX=-Infinity,minY=Infinity,maxY=-Infinity;positions.forEach(p=>{if(p.x<minX)minX=p.x;if(p.x>maxX)maxX=p.x;if(p.y<minY)minY=p.y});return{minX,maxX:maxX+160,minY,maxY:maxY+50}}
|
|
171
|
+
function fit(animate=true){const bounds=graphBounds();if(!bounds)return;const box=svg.getBoundingClientRect(),w=Math.max(1,bounds.maxX-bounds.minX),h=Math.max(1,bounds.maxY-bounds.minY),scale=Math.min(1.2,Math.max(.07,Math.min((box.width-72)/w,(box.height-72)/h))),next={x:36-bounds.minX*scale,y:36-bounds.minY*scale,scale};if(animate)animateTo(next);else{transform=next;applyTransform()}}
|
|
172
|
+
function latestScreenPoint(){if(!latestNodeId||!positions.has(latestNodeId))return null;const p=positions.get(latestNodeId);return{x:transform.x+(p.x+80)*transform.scale,y:transform.y+(p.y+25)*transform.scale}}
|
|
173
|
+
function latestInsideSafeZone(){const point=latestScreenPoint();if(!point)return true;const box=svg.getBoundingClientRect(),mx=box.width*.18,my=box.height*.18;return point.x>=mx&&point.x<=box.width-mx&&point.y>=my&&point.y<=box.height-my}
|
|
174
|
+
function followLatest(force=false){if(!latestNodeId||!positions.has(latestNodeId))return;if(!force&&latestInsideSafeZone())return;const box=svg.getBoundingClientRect(),p=positions.get(latestNodeId),next={x:box.width*.5-(p.x+80)*transform.scale,y:box.height*.5-(p.y+25)*transform.scale,scale:transform.scale};animateTo(next,240)}
|
|
175
|
+
function focusNode(id){if(!id||!positions.has(id))return;if(cameraMode!=='manual')setCameraMode('manual',{apply:false});const box=svg.getBoundingClientRect(),p=positions.get(id),scale=Math.min(1.2,Math.max(.72,transform.scale)),next={x:box.width*.5-(p.x+80)*scale,y:box.height*.5-(p.y+25)*scale,scale};animateTo(next,220);setTimeout(updateJumpLatest,230)}""",
|
|
176
|
+
"""function execweaveCameraWidth(id){try{const value=execweaveWidthOf(id);return Number.isFinite(value)?value:160}catch(_){return 160}}
|
|
177
|
+
function execweaveCameraHeight(id){try{const value=execweaveHeightOf(id);return Number.isFinite(value)?value:50}catch(_){return 50}}
|
|
178
|
+
try{window.execweaveCameraWidth=execweaveCameraWidth;window.execweaveCameraHeight=execweaveCameraHeight}catch(_){}
|
|
179
|
+
function graphBounds(){if(!positions.size)return null;let minX=Infinity,maxX=-Infinity,minY=Infinity,maxY=-Infinity;positions.forEach((p,id)=>{const w=execweaveCameraWidth(id),h=execweaveCameraHeight(id);if(p.x<minX)minX=p.x;if(p.x+w>maxX)maxX=p.x+w;if(p.y<minY)minY=p.y;if(p.y+h>maxY)maxY=p.y+h});return{minX,maxX,minY,maxY}}
|
|
180
|
+
function fit(animate=true){const bounds=graphBounds();if(!bounds)return;const box=svg.getBoundingClientRect(),w=Math.max(1,bounds.maxX-bounds.minX),h=Math.max(1,bounds.maxY-bounds.minY),scale=Math.min(1.2,Math.max(.07,Math.min((box.width-72)/w,(box.height-72)/h))),next={x:36-bounds.minX*scale,y:36-bounds.minY*scale,scale};if(animate)animateTo(next);else{transform=next;applyTransform()}}
|
|
181
|
+
function latestScreenPoint(){if(!latestNodeId||!positions.has(latestNodeId))return null;const p=positions.get(latestNodeId),w=execweaveCameraWidth(latestNodeId),h=execweaveCameraHeight(latestNodeId);return{x:transform.x+(p.x+w/2)*transform.scale,y:transform.y+(p.y+h/2)*transform.scale}}
|
|
182
|
+
function latestInsideSafeZone(){const point=latestScreenPoint();if(!point)return true;const box=svg.getBoundingClientRect(),mx=box.width*.18,my=box.height*.18;return point.x>=mx&&point.x<=box.width-mx&&point.y>=my&&point.y<=box.height-my}
|
|
183
|
+
function followLatest(force=false){if(!latestNodeId||!positions.has(latestNodeId))return;if(!force&&latestInsideSafeZone())return;const box=svg.getBoundingClientRect(),p=positions.get(latestNodeId),w=execweaveCameraWidth(latestNodeId),h=execweaveCameraHeight(latestNodeId),next={x:box.width*.5-(p.x+w/2)*transform.scale,y:box.height*.5-(p.y+h/2)*transform.scale,scale:transform.scale};animateTo(next,240)}
|
|
184
|
+
function focusNode(id){if(!id||!positions.has(id))return;if(cameraMode!=='manual')setCameraMode('manual',{apply:false});const box=svg.getBoundingClientRect(),p=positions.get(id),w=execweaveCameraWidth(id),h=execweaveCameraHeight(id),scale=Math.min(1.2,Math.max(.72,transform.scale)),next={x:box.width*.5-(p.x+w/2)*scale,y:box.height*.5-(p.y+h/2)*scale,scale};animateTo(next,220);setTimeout(updateJumpLatest,230)}""",
|
|
185
|
+
label="camera dynamic geometry",
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
# PM-006: build relation indexes once per raw graph collection instead of scanning
|
|
189
|
+
# E and then N for every card lookup. applyDelta replaces graph node/edge arrays, so
|
|
190
|
+
# reference+length invalidation is exact for the live path and static viewers remain
|
|
191
|
+
# stable.
|
|
192
|
+
html = _replace_once(
|
|
193
|
+
html,
|
|
194
|
+
"""function rawGraph(){const core=window.__execweaveCore;return core?.getGraph?.()||displayGraph()}
|
|
195
|
+
function rawEdges(){return Array.isArray(rawGraph().edges)?rawGraph().edges:[]}
|
|
196
|
+
function rawNode(id){return (rawGraph().nodes||[]).find(node=>String(node?.id||'')===String(id))||null}
|
|
197
|
+
function relatedTo(id,relation,{from=true}={}){
|
|
198
|
+
const wanted=String(relation).toUpperCase();
|
|
199
|
+
return rawEdges()
|
|
200
|
+
.filter(edge=>String(edge?.relation||'').toUpperCase()===wanted&&String(from?edge?.source:edge?.target)===String(id))
|
|
201
|
+
.map(edge=>rawNode(from?edge.target:edge.source))
|
|
202
|
+
.filter(Boolean);
|
|
203
|
+
}""",
|
|
204
|
+
"""function rawGraph(){const core=window.__execweaveCore;return core?.getGraph?.()||displayGraph()}
|
|
205
|
+
let rawIndexedGraph=null,rawIndexedNodesRef=null,rawIndexedEdgesRef=null,rawIndexedNodeCount=-1,rawIndexedEdgeCount=-1,rawNodeById=new Map(),rawOutById=new Map(),rawInById=new Map(),rawIndexedEdges=[];
|
|
206
|
+
function ensureRawIndex(){
|
|
207
|
+
const graph=rawGraph(),nodes=Array.isArray(graph.nodes)?graph.nodes:[],edges=Array.isArray(graph.edges)?graph.edges:[];
|
|
208
|
+
if(graph===rawIndexedGraph&&nodes===rawIndexedNodesRef&&edges===rawIndexedEdgesRef&&nodes.length===rawIndexedNodeCount&&edges.length===rawIndexedEdgeCount)return{nodes:rawNodeById,out:rawOutById,incoming:rawInById,edges:rawIndexedEdges};
|
|
209
|
+
rawIndexedGraph=graph;rawIndexedNodesRef=nodes;rawIndexedEdgesRef=edges;rawIndexedNodeCount=nodes.length;rawIndexedEdgeCount=edges.length;rawIndexedEdges=edges;
|
|
210
|
+
rawNodeById=new Map(nodes.map(node=>[String(node?.id||''),node]));rawOutById=new Map();rawInById=new Map();
|
|
211
|
+
for(const edge of edges){const source=String(edge?.source||''),target=String(edge?.target||'');if(!rawOutById.has(source))rawOutById.set(source,[]);rawOutById.get(source).push(edge);if(!rawInById.has(target))rawInById.set(target,[]);rawInById.get(target).push(edge)}
|
|
212
|
+
return{nodes:rawNodeById,out:rawOutById,incoming:rawInById,edges:rawIndexedEdges};
|
|
213
|
+
}
|
|
214
|
+
function rawEdges(){return ensureRawIndex().edges}
|
|
215
|
+
function rawNode(id){return ensureRawIndex().nodes.get(String(id))||null}
|
|
216
|
+
function relatedToAny(id,relations,{from=true}={}){
|
|
217
|
+
const index=ensureRawIndex(),wanted=new Set(relations.map(value=>String(value).toUpperCase())),key=String(id),candidates=(from?index.out:index.incoming).get(key)||[],seen=new Set(),out=[];
|
|
218
|
+
for(const edge of candidates){if(!wanted.has(String(edge?.relation||'').toUpperCase()))continue;const node=index.nodes.get(String(from?edge.target:edge.source));if(!node)continue;const nodeId=String(node?.id||'');if(seen.has(nodeId))continue;seen.add(nodeId);out.push(node)}
|
|
219
|
+
return out;
|
|
220
|
+
}
|
|
221
|
+
function relatedTo(id,relation,options={}){return relatedToAny(id,[relation],options)}""",
|
|
222
|
+
label="raw graph indexes",
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
# PM-005: presentation may group the repository's supported ownership relations,
|
|
226
|
+
# but it must not rewrite raw evidence. De-duplicate by call node ID if more than one
|
|
227
|
+
# compatible relation names the same logical call.
|
|
228
|
+
html = _replace_once(
|
|
229
|
+
html,
|
|
230
|
+
"""function toolCallsFor(agentId){
|
|
231
|
+
const calls=relatedTo(agentId,'REQUESTED_TOOL_CALL');
|
|
232
|
+
if(!calls.length)return '';
|
|
233
|
+
const ordered=[...calls].sort((a,b)=>String(b?.first_seen||'').localeCompare(String(a?.first_seen||'')));
|
|
234
|
+
const stamps=ordered.map(call=>String(call?.first_seen||'')).filter(Boolean);
|
|
235
|
+
const sameDay=stamps.length<2||stamps.every(value=>value.slice(0,10)===stamps[0].slice(0,10));
|
|
236
|
+
return ordered.map(call=>toolCallLine(call,sameDay)).join('\\n');
|
|
237
|
+
}
|
|
238
|
+
function callersOf(toolId){
|
|
239
|
+
const calls=rawEdges().filter(edge=>String(edge?.relation||'').toUpperCase()==='USES_TOOL'&&String(edge?.target)===String(toolId))
|
|
240
|
+
.map(edge=>rawNode(edge.source)).filter(Boolean);
|
|
241
|
+
const names=new Set();
|
|
242
|
+
for(const call of calls)for(const agent of relatedTo(call.id,'REQUESTED_TOOL_CALL',{from:false}))names.add(agent?.name||agent?.id);
|
|
243
|
+
return{count:calls.length,agents:[...names].sort()};
|
|
244
|
+
}""",
|
|
245
|
+
"""const TOOL_CALL_OWNERSHIP_RELATIONS=['REQUESTED_TOOL_CALL','OBSERVED_TOOL_CALL','OWNED_TOOL_CALL'];
|
|
246
|
+
function toolCallsFor(agentId){
|
|
247
|
+
const calls=relatedToAny(agentId,TOOL_CALL_OWNERSHIP_RELATIONS);
|
|
248
|
+
if(!calls.length)return '';
|
|
249
|
+
const ordered=[...calls].sort((a,b)=>String(b?.first_seen||'').localeCompare(String(a?.first_seen||''))||String(a?.id||'').localeCompare(String(b?.id||'')));
|
|
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),uniqueCalls=new Map(calls.map(call=>[String(call?.id||''),call]));
|
|
257
|
+
const names=new Set();
|
|
258
|
+
for(const call of uniqueCalls.values())for(const agent of relatedToAny(call.id,TOOL_CALL_OWNERSHIP_RELATIONS,{from:false}))names.add(agent?.name||agent?.id);
|
|
259
|
+
return{count:uniqueCalls.size,agents:[...names].sort()};
|
|
260
|
+
}""",
|
|
261
|
+
label="tool-call ownership relations",
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
return html
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from .viewer_dashboard_hardening import harden_dashboard_html as _harden_v1
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def _replace_once(html: str, old: str, new: str, *, label: str) -> str:
|
|
7
|
+
if old not in html:
|
|
8
|
+
raise RuntimeError(f"dashboard hardening v2 seam changed: {label}")
|
|
9
|
+
return html.replace(old, new, 1)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def harden_dashboard_html(html: str) -> str:
|
|
13
|
+
"""Apply the reviewed v0.8.3 hardening set and its live-delta fixups."""
|
|
14
|
+
html = _harden_v1(html)
|
|
15
|
+
|
|
16
|
+
# Only a real browser measurement is authoritative enough to cache. Detached/export
|
|
17
|
+
# contexts can fall back to the character estimate, but caching that estimate would
|
|
18
|
+
# prevent a later attached render from upgrading the same string to measured width.
|
|
19
|
+
html = _replace_once(
|
|
20
|
+
html,
|
|
21
|
+
"return execweaveRememberMeasure(value,value.length*7.1);",
|
|
22
|
+
"return value.length*7.1;",
|
|
23
|
+
label="measurement fallback cache",
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
# A pre-existing node may become wider/taller without moving a lane origin (for
|
|
27
|
+
# example the last occupied lane). Existing edge paths still depend on that
|
|
28
|
+
# dimension, so lane-shift detection alone is not enough to decide whether rendered
|
|
29
|
+
# geometry is stale. New nodes are deliberately excluded: their dimensions are new,
|
|
30
|
+
# not changed, and treating every addition as a dimension change would rerender the
|
|
31
|
+
# entire existing graph on every live node addition.
|
|
32
|
+
html = _replace_once(
|
|
33
|
+
html,
|
|
34
|
+
""" const priorLaneX={...(execweaveTopology.laneX||{})};
|
|
35
|
+
execweaveTopology=execweaveBuildTopology();
|
|
36
|
+
const laneShifted=EXECWEAVE_LANE_ORDER.some(lane=>priorLaneX[lane]!==execweaveTopology.laneX[lane]);""",
|
|
37
|
+
""" const priorLaneX={...(execweaveTopology.laneX||{})},priorWidth=new Map(execweaveTopology.width||[]),priorHeight=new Map(execweaveTopology.height||[]);
|
|
38
|
+
execweaveTopology=execweaveBuildTopology();
|
|
39
|
+
const laneShifted=EXECWEAVE_LANE_ORDER.some(lane=>priorLaneX[lane]!==execweaveTopology.laneX[lane]);
|
|
40
|
+
const dimensionsChanged=[...priorWidth.keys()].some(id=>nodeById.has(id)&&(priorWidth.get(id)!==execweaveTopology.width.get(id)||priorHeight.get(id)!==execweaveTopology.height.get(id)));
|
|
41
|
+
const geometryChanged=laneShifted||dimensionsChanged;""",
|
|
42
|
+
label="delta dimension change detection",
|
|
43
|
+
)
|
|
44
|
+
html = _replace_once(
|
|
45
|
+
html,
|
|
46
|
+
""" if(laneShifted){
|
|
47
|
+
for(const [id] of nodeElements){const node=nodeById.get(id);if(node)updateNodeElement(node)}
|
|
48
|
+
for(const edge of edgeById.values())updateEdgeElement(edge);
|
|
49
|
+
}""",
|
|
50
|
+
""" if(geometryChanged){
|
|
51
|
+
for(const [id,group] of nodeElements){
|
|
52
|
+
const p=positions.get(id),node=nodeById.get(id);
|
|
53
|
+
if(p)group.setAttribute('transform',`translate(${p.x} ${p.y})`);
|
|
54
|
+
if(node)updateNodeElement(node);
|
|
55
|
+
}
|
|
56
|
+
for(const edge of edgeById.values())updateEdgeElement(edge);
|
|
57
|
+
}""",
|
|
58
|
+
label="delta geometry rerender",
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# GIF captures measured SVG geometry directly; it has no separate layout.
|
|
62
|
+
return html
|