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,225 @@
|
|
|
1
|
+
"""Read published agent-local history without changing round or ownership policy.
|
|
2
|
+
|
|
3
|
+
The existing inspector keeps its compact round summaries. This on-demand reader
|
|
4
|
+
uses exact source IDs (and explicit projection members), paginates DOM nodes, and
|
|
5
|
+
pins the open snapshot until the reader explicitly refreshes it. It never fetches
|
|
6
|
+
new files, reconstructs hidden reasoning, or declares task success from text.
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
HISTORY_BROWSER_CSS = r"""
|
|
11
|
+
.execweave-history-entry{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin:0 0 12px}
|
|
12
|
+
.execweave-history-entry button{font:inherit;padding:7px 10px;cursor:pointer}
|
|
13
|
+
.execweave-history-entry small{color:var(--muted)}
|
|
14
|
+
#execweave-history-dialog{width:min(1000px,92vw);max-height:88vh;box-sizing:border-box;border:1px solid var(--border,#888);border-radius:10px;background:var(--panel,#fff);color:var(--text,#111);padding:16px}
|
|
15
|
+
#execweave-history-dialog::backdrop{background:rgba(0,0,0,.4)}
|
|
16
|
+
#execweave-history-dialog header,.execweave-history-controls{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:10px}
|
|
17
|
+
#execweave-history-title{flex:1;font-size:18px;margin:0}
|
|
18
|
+
#execweave-history-dialog button,#execweave-history-dialog input,#execweave-history-dialog select{font:inherit;padding:6px}
|
|
19
|
+
#execweave-history-search{flex:1;min-width:180px}
|
|
20
|
+
#execweave-history-status,#execweave-history-boundary,#execweave-history-updates{font-size:13px;overflow-wrap:anywhere}
|
|
21
|
+
#execweave-history-list{overflow:auto;max-height:52vh;overscroll-behavior:contain}
|
|
22
|
+
#execweave-history-list details{border:1px solid var(--border,#888);border-radius:8px;margin:8px 0}
|
|
23
|
+
#execweave-history-list summary{cursor:pointer;padding:10px;font-size:14px;overflow-wrap:anywhere}
|
|
24
|
+
#execweave-history-list .history-provenance{padding:0 10px;font-size:12px;overflow-wrap:anywhere;color:var(--muted)}
|
|
25
|
+
#execweave-history-list pre{padding:10px;margin:0;white-space:pre-wrap;overflow-wrap:anywhere;font:14px/1.5 ui-monospace,monospace}
|
|
26
|
+
#execweave-history-list .history-body-controls{padding:8px 10px;font-size:12px}
|
|
27
|
+
""".strip()
|
|
28
|
+
|
|
29
|
+
HISTORY_BROWSER_JS = r"""
|
|
30
|
+
function execweaveCreateHistoryBrowser(getGraph,getEntries){
|
|
31
|
+
const PAGE=25,TEXT_PAGE=16384,states=new Map();
|
|
32
|
+
let dialog=null,title,search,filter,status,boundary,updates,refreshButton,items,prev,next;
|
|
33
|
+
let active=null,published=null,currentState=null,runScope=null,viewKey=null;
|
|
34
|
+
const STORE='execweave.history.view.v1',STORE_LIMIT=131072;
|
|
35
|
+
const filters=new Set(['all','input','message','marker','encrypted','context']);
|
|
36
|
+
const list=value=>Array.isArray(value)?value:[];
|
|
37
|
+
const str=value=>typeof value==='string'?value:'';
|
|
38
|
+
const scope=()=>{const g=getGraph()||{};return JSON.stringify([g.run_id??null,g.session_id??null,g.source_path??null])};
|
|
39
|
+
const make=(tag,text)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=text;return n};
|
|
40
|
+
const button=(text,action)=>{const b=make('button',text);b.type='button';b.onclick=action;return b};
|
|
41
|
+
function recordsFor(node){
|
|
42
|
+
const ids=new Set([str(node?.id)]);
|
|
43
|
+
if(node?.type==='agent')for(const id of list(node.attributes?.viewer_agent_member_ids))if(typeof id==='string')ids.add(id);
|
|
44
|
+
ids.delete('');
|
|
45
|
+
const candidates=list(getEntries()).filter(e=>ids.has(e?.source_id)&&e?.conversation_preview&&typeof e.conversation_preview==='object');
|
|
46
|
+
const scopes=new Map();
|
|
47
|
+
for(const e of candidates){
|
|
48
|
+
const p=e.conversation_preview;
|
|
49
|
+
if(!['provider_native','execweave_derived'].includes(p.thread_id_source)||!str(p.provider_native_id))continue;
|
|
50
|
+
if(!scopes.has(e.source_id))scopes.set(e.source_id,new Set());
|
|
51
|
+
scopes.get(e.source_id).add(JSON.stringify([str(e.provider).toLowerCase(),p.provider_native_id]));
|
|
52
|
+
}
|
|
53
|
+
const ambiguous=new Set([...scopes].filter(([,values])=>values.size>1).map(([id])=>id));
|
|
54
|
+
return {records:candidates.filter(e=>!ambiguous.has(e.source_id)),ambiguous:ambiguous.size};
|
|
55
|
+
}
|
|
56
|
+
function persistenceKey(node){
|
|
57
|
+
const g=getGraph()||{};
|
|
58
|
+
// A filename or display label alone does not identify an execution.
|
|
59
|
+
if(![g.run_id,g.session_id].some(v=>typeof v==='string'&&v.length>0&&v.length<=4096))return null;
|
|
60
|
+
const selected=recordsFor(node);if(selected.ambiguous)return null;
|
|
61
|
+
const identities=selected.records.map(e=>[e.source_id,str(e.provider),str(e.conversation_preview.thread_id),str(e.conversation_preview.provider_native_id)]);
|
|
62
|
+
identities.sort((a,b)=>JSON.stringify(a).localeCompare(JSON.stringify(b)));
|
|
63
|
+
const key=JSON.stringify([scope(),node.id,identities]);return key.length<=8192?key:null;
|
|
64
|
+
}
|
|
65
|
+
function validView(v){
|
|
66
|
+
return v&&typeof v==='object'&&!Array.isArray(v)&&filters.has(v.filter)&&
|
|
67
|
+
Number.isSafeInteger(v.page)&&v.page>=0&&v.page<=100000&&Array.isArray(v.open)&&v.open.length<=64&&
|
|
68
|
+
v.open.every(x=>typeof x==='string'&&x.length<=2048);
|
|
69
|
+
}
|
|
70
|
+
function storedViews(){
|
|
71
|
+
try{
|
|
72
|
+
const text=window.sessionStorage.getItem(STORE);if(!text||text.length>STORE_LIMIT)return [];
|
|
73
|
+
const data=JSON.parse(text);if(data?.version!==1||!Array.isArray(data.views)||data.views.length>32)return [];
|
|
74
|
+
return data.views.filter(v=>Array.isArray(v)&&v.length===2&&typeof v[0]==='string'&&v[0].length<=8192&&validView(v[1])).map(([key,v])=>[key,{filter:v.filter,page:v.page,open:v.open}]);
|
|
75
|
+
}catch{return []}
|
|
76
|
+
}
|
|
77
|
+
function restoreView(key){
|
|
78
|
+
const saved=key?storedViews().find(v=>v[0]===key)?.[1]:null;
|
|
79
|
+
return {query:'',filter:saved?.filter||'all',page:saved?.page||0,open:new Set(saved?.open||[])};
|
|
80
|
+
}
|
|
81
|
+
function saveView(){
|
|
82
|
+
if(!viewKey||!currentState)return;
|
|
83
|
+
// Store presentation state and record identifiers only. Never serialize a
|
|
84
|
+
// transcript, message body, search term, URL token, or graph attributes.
|
|
85
|
+
const view={filter:currentState.filter,page:currentState.query?0:currentState.page,
|
|
86
|
+
open:[...currentState.open].filter(k=>k.length<=2048).slice(-64)};
|
|
87
|
+
if(!validView(view))return;
|
|
88
|
+
const views=storedViews().filter(v=>v[0]!==viewKey);views.push([viewKey,view]);
|
|
89
|
+
while(views.length>32)views.shift();
|
|
90
|
+
let text=JSON.stringify({version:1,views});
|
|
91
|
+
while(text.length>STORE_LIMIT&&views.length){views.shift();text=JSON.stringify({version:1,views})}
|
|
92
|
+
try{window.sessionStorage.setItem(STORE,text)}catch{/* Disabled/quota-limited storage must not break reading. */}
|
|
93
|
+
}
|
|
94
|
+
function category(m){
|
|
95
|
+
if(m.content_state==='provider_encrypted')return 'encrypted';
|
|
96
|
+
if(m.content_role==='shared_injected_context')return 'context';
|
|
97
|
+
if(m.sender==='user'||m.kind==='user_message')return 'input';
|
|
98
|
+
// Text matching is a presentation hint, never protocol or success evidence.
|
|
99
|
+
if(m.text_truncated!==true&&['assistant_message','assistant_response','subagent_final_response','agent_result','final_answer'].includes(m.kind)&&
|
|
100
|
+
['TERMINATE','<CAMEL_TASK_DONE>'].includes(str(m.text).trim()))return 'marker';
|
|
101
|
+
return 'message';
|
|
102
|
+
}
|
|
103
|
+
function snapshot(node){
|
|
104
|
+
const selection=recordsFor(node),records=selection.records,rows=[];let partial=false,routing=false;
|
|
105
|
+
records.forEach((e,ei)=>{
|
|
106
|
+
const p=e.conversation_preview,messages=list(p.messages);
|
|
107
|
+
partial=partial||p.messages_truncated===true||(Number.isSafeInteger(p.message_count)&&p.message_count>messages.length);
|
|
108
|
+
routing=routing||p.conversation_completeness==='routing_only'||['cross_agent_routing','provider_cross_agent_routing_record'].includes(p.evidence_scope);
|
|
109
|
+
messages.forEach((m,mi)=>{
|
|
110
|
+
if(!m||typeof m!=='object'||Array.isArray(m))return;
|
|
111
|
+
const row={};
|
|
112
|
+
for(const key of ['timestamp','ordinal','kind','phase','sender','recipient','text','content_state','content_role','occurrence_id','message_id','text_truncated'])row[key]=m[key]??null;
|
|
113
|
+
row.source_id=e.source_id;row.record_index=ei;row.message_index=mi;row.category=category(row);
|
|
114
|
+
// Never deduplicate by text. Already-normalized records remain separate.
|
|
115
|
+
row.key=JSON.stringify([e.source_id,p.thread_id,ei,m.occurrence_id,m.message_id,m.ordinal,mi,m.kind,m.sender,m.recipient]);
|
|
116
|
+
rows.push(row);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
return {rows,partial,routing,recordCount:records.length,ambiguous:selection.ambiguous};
|
|
120
|
+
}
|
|
121
|
+
function equal(a,b){return a&&a.ambiguous===b.ambiguous&&a.partial===b.partial&&a.routing===b.routing&&a.recordCount===b.recordCount&&a.rows.length===b.rows.length&&a.rows.every((r,i)=>Object.keys(r).every(k=>r[k]===b.rows[i][k]))}
|
|
122
|
+
function clear(){
|
|
123
|
+
saveView();viewKey=null;
|
|
124
|
+
if(dialog){dialog.close();items.replaceChildren();search.value='';status.textContent='';boundary.textContent='';updates.textContent='';title.textContent='Observed history'}
|
|
125
|
+
active=null;published=null;currentState=null;
|
|
126
|
+
}
|
|
127
|
+
function checkRun(){const now=scope();if(now!==runScope){clear();states.clear();runScope=now;return false}return true}
|
|
128
|
+
function ensure(){
|
|
129
|
+
if(dialog)return;
|
|
130
|
+
dialog=make('dialog');dialog.id='execweave-history-dialog';dialog.setAttribute('aria-labelledby','execweave-history-title');
|
|
131
|
+
const head=make('header');title=make('h2','Observed history');title.id='execweave-history-title';head.append(title,button('Close history',clear));
|
|
132
|
+
boundary=make('p');boundary.id='execweave-history-boundary';
|
|
133
|
+
const controls=make('form');controls.className='execweave-history-controls';
|
|
134
|
+
search=make('input');search.type='search';search.id='execweave-history-search';search.placeholder='Search loaded message text, sender, recipient, or kind';search.setAttribute('aria-label','Search observed history');
|
|
135
|
+
filter=make('select');filter.id='execweave-history-filter';filter.setAttribute('aria-label','History message category');
|
|
136
|
+
for(const [value,label] of [['all','All records'],['input','User inputs'],['message','Other messages'],['marker','Termination markers (text match)'],['encrypted','Encrypted records'],['context','Injected context']]){const o=make('option',label);o.value=value;filter.append(o)}
|
|
137
|
+
controls.onsubmit=e=>{e.preventDefault();if(!checkRun()||!active)return;currentState.query=search.value;currentState.filter=filter.value;currentState.page=0;draw()};
|
|
138
|
+
filter.onchange=()=>controls.requestSubmit();const find=button('Search',()=>controls.requestSubmit());controls.append(search,filter,find);
|
|
139
|
+
const pageControls=make('div');pageControls.className='execweave-history-controls';
|
|
140
|
+
prev=button('Previous records',()=>{if(checkRun()&&active){currentState.page--;draw()}});
|
|
141
|
+
next=button('Next records',()=>{if(checkRun()&&active){currentState.page++;draw()}});
|
|
142
|
+
refreshButton=button('Refresh history',()=>{if(!checkRun()||!active)return;published=snapshot(active);updates.textContent='';draw()});
|
|
143
|
+
pageControls.append(prev,next,refreshButton);
|
|
144
|
+
status=make('p');status.id='execweave-history-status';status.setAttribute('role','status');
|
|
145
|
+
updates=make('p');updates.id='execweave-history-updates';updates.setAttribute('role','status');
|
|
146
|
+
items=make('div');items.id='execweave-history-list';
|
|
147
|
+
dialog.append(head,boundary,controls,pageControls,status,updates,items);
|
|
148
|
+
dialog.addEventListener('cancel',e=>{e.preventDefault();clear()});document.body.append(dialog);
|
|
149
|
+
}
|
|
150
|
+
function draw(){
|
|
151
|
+
if(!active||!checkRun())return;
|
|
152
|
+
const query=currentState.query.toLocaleLowerCase(),kind=currentState.filter;
|
|
153
|
+
const rows=published.rows.filter(r=>(kind==='all'||r.category===kind)&&(!query||[r.category==='encrypted'?'':str(r.text),str(r.sender),str(r.recipient),str(r.kind),str(r.phase)].some(t=>t.toLocaleLowerCase().includes(query))));
|
|
154
|
+
const pages=Math.max(1,Math.ceil(rows.length/PAGE));currentState.page=Math.max(0,Math.min(currentState.page,pages-1));
|
|
155
|
+
prev.disabled=currentState.page===0;next.disabled=currentState.page===pages-1;
|
|
156
|
+
boundary.textContent='Published, normalized message records for this exact agent. Search covers the loaded text only, not every archived payload. Individual text may be a provider preview; use Recorded source content for captured bodies. Task success, message delivery, and hidden reasoning are not inferred.'+
|
|
157
|
+
(published.ambiguous?' Conflicting native execution identities were recorded for the same source ID; their histories are withheld rather than combined.':'')+
|
|
158
|
+
(published.partial?' This published history is truncated or has missing records; it is not a complete transcript.':'')+
|
|
159
|
+
(published.routing?' Routing-only evidence is present; it does not establish the recipient\'s own transcript or consumption.':'');
|
|
160
|
+
boundary.textContent+=' Page, category, and expanded records can be restored within this tab for the exact run and agent; message text and search terms are never stored. Browser storage may be unavailable.';
|
|
161
|
+
status.textContent=`${rows.length} matching / ${published.rows.length} loaded records. Page ${currentState.page+1}/${pages}.`;
|
|
162
|
+
if(!published.recordCount)status.textContent+=' No exact-source conversation record is available; no root or sibling content was substituted.';
|
|
163
|
+
items.replaceChildren();items.scrollTop=0;
|
|
164
|
+
for(const row of rows.slice(currentState.page*PAGE,(currentState.page+1)*PAGE)){
|
|
165
|
+
const fold=make('details');fold.className='execweave-history-message';fold.dataset.historyKey=row.key;
|
|
166
|
+
const head=make('summary');
|
|
167
|
+
const label=row.category==='marker'?'Termination marker (text match)':row.category==='encrypted'?'Encrypted record':str(row.kind)||'Message';
|
|
168
|
+
const preview=row.category==='encrypted'?'Plaintext not exposed':str(row.text).replace(/\s+/g,' ').slice(0,100);
|
|
169
|
+
head.textContent=[`#${row.message_index+1}`,str(row.timestamp),label,`${str(row.sender)||'Unknown sender'} → ${str(row.recipient)||'Recipient not recorded'}`,preview].filter(Boolean).join(' · ');
|
|
170
|
+
const meta=make('p',[`Source: ${row.source_id}`,row.occurrence_id?`Occurrence: ${row.occurrence_id}`:'',row.ordinal!==null?`Ordinal: ${row.ordinal}`:'',str(row.phase),str(row.content_state),str(row.content_role)].filter(Boolean).join(' · '));meta.className='history-provenance';
|
|
171
|
+
const content=make('pre');content.className='history-message-text';
|
|
172
|
+
const paging=make('div');paging.className='history-body-controls';let offset=0;
|
|
173
|
+
function showText(){
|
|
174
|
+
let text=row.category==='encrypted'?'Observed record; plaintext was not exposed by the provider.':typeof row.text==='string'?row.text:'No text supplied in this normalized record.';
|
|
175
|
+
const count=Math.max(1,Math.ceil(text.length/TEXT_PAGE));offset=Math.max(0,Math.min(offset,count-1));
|
|
176
|
+
let start=offset*TEXT_PAGE,end=Math.min(text.length,start+TEXT_PAGE);
|
|
177
|
+
if(start>0&&/[\uDC00-\uDFFF]/.test(text[start]))start--;
|
|
178
|
+
if(end<text.length&&/[\uD800-\uDBFF]/.test(text[end-1]))end--;
|
|
179
|
+
content.textContent=text.slice(start,end);paging.replaceChildren();
|
|
180
|
+
if(row.text==='')paging.append(make('span','The recorded text is an empty string. '));
|
|
181
|
+
if(row.text_truncated===true)paging.append(make('span','This record contains truncated text. '));
|
|
182
|
+
if(row.category==='marker')paging.append(make('span','Text matches a termination marker. This is not verified task completion. '));
|
|
183
|
+
if(count>1){const back=button('Previous text',()=>{offset--;showText()}),more=button('Next text',()=>{offset++;showText()});back.disabled=offset===0;more.disabled=offset===count-1;paging.append(make('span',`Loaded text page ${offset+1}/${count}. `),back,more)}
|
|
184
|
+
}
|
|
185
|
+
fold.append(head,meta,content,paging);let ready=false;
|
|
186
|
+
fold.open=currentState.open.has(row.key);
|
|
187
|
+
if(fold.open){showText();ready=true}
|
|
188
|
+
fold.addEventListener('toggle',()=>{
|
|
189
|
+
if(!fold.isConnected||!active||!checkRun())return;
|
|
190
|
+
if(fold.open){currentState.open.add(row.key);if(!ready){showText();ready=true}}else currentState.open.delete(row.key);
|
|
191
|
+
saveView();
|
|
192
|
+
});
|
|
193
|
+
// Toggle is queued. Preserve the reader's intent even when refresh follows
|
|
194
|
+
// the same click before the queued event has fired.
|
|
195
|
+
head.addEventListener('click',()=>{if(fold.open)currentState.open.delete(row.key);else{currentState.open.add(row.key);if(!ready){showText();ready=true}while(currentState.open.size>4096)currentState.open.delete(currentState.open.values().next().value)}saveView()});
|
|
196
|
+
items.append(fold);
|
|
197
|
+
}
|
|
198
|
+
saveView();
|
|
199
|
+
}
|
|
200
|
+
function open(node){
|
|
201
|
+
if(node?.type!=='agent'||!str(node.id))return;
|
|
202
|
+
checkRun();saveView();ensure();active={id:node.id,type:'agent',name:node.name,attributes:{viewer_agent_member_ids:[...list(node.attributes?.viewer_agent_member_ids)]}};
|
|
203
|
+
viewKey=persistenceKey(active);
|
|
204
|
+
const key=viewKey||JSON.stringify([runScope,node.id]);
|
|
205
|
+
if(!states.has(key))states.set(key,restoreView(viewKey));
|
|
206
|
+
currentState=states.get(key);if(states.size>32)states.delete(states.keys().next().value);
|
|
207
|
+
published=snapshot(active);title.textContent=`Observed history · ${node.name||node.id}`;
|
|
208
|
+
search.value=currentState.query;filter.value=currentState.filter;updates.textContent='';draw();
|
|
209
|
+
if(!dialog.open)dialog.showModal();
|
|
210
|
+
}
|
|
211
|
+
function changed(){if(checkRun()&&active&&dialog?.open&&!equal(published,snapshot(active)))updates.textContent='Updated history is available. The current page and expanded records are pinned until Refresh history is selected.'}
|
|
212
|
+
function nodeChanged(node){checkRun();if(active&&active.id!==node?.id)clear()}
|
|
213
|
+
function buttonFor(node){
|
|
214
|
+
const box=make('section');box.className='execweave-history-entry';
|
|
215
|
+
const count=recordsFor(node).records.reduce((n,e)=>n+list(e.conversation_preview.messages).length,0);
|
|
216
|
+
box.append(button('Browse observed history',()=>open(node)),make('small',`${count} loaded message records; summaries below are not the full history.`));return box;
|
|
217
|
+
}
|
|
218
|
+
window.addEventListener('pagehide',()=>{clear();states.clear()});
|
|
219
|
+
return {buttonFor,nodeChanged,changed,close:clear,open};
|
|
220
|
+
}
|
|
221
|
+
const historyBrowser=execweaveCreateHistoryBrowser(
|
|
222
|
+
()=>window.__execweaveCore?.getGraph?.()||window.__execweaveStaticGraph||{},()=>entries
|
|
223
|
+
);
|
|
224
|
+
window.__execweaveHistoryBrowser=historyBrowser;
|
|
225
|
+
""".strip()
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"""Searchable investigation workspace without changing graph geometry or evidence."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from .viewer_message_handoffs import MESSAGE_HANDOFFS_JS
|
|
5
|
+
|
|
6
|
+
INVESTIGATION_JS = r"""
|
|
7
|
+
(()=>{
|
|
8
|
+
'use strict';
|
|
9
|
+
if(window.__execweaveInvestigation)return;
|
|
10
|
+
const make=(tag,text)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=String(text);return n};
|
|
11
|
+
const list=x=>Array.isArray(x)?x:[],text=x=>typeof x==='string'?x:'';
|
|
12
|
+
const graph=()=>window.__execweaveCore?.getGraph?.()||window.__execweaveStaticGraph||{};
|
|
13
|
+
const scope=()=>JSON.stringify([graph().session_id||null,graph().source_path||null]);
|
|
14
|
+
const keyOf=x=>JSON.stringify([x?.session_id||null,x?.source_path||null]);
|
|
15
|
+
const PAGE=25,opened=new Set();
|
|
16
|
+
let liveIndex=null,pinned=null,currentScope=scope(),dialog=null,query,kind,status,notice,body,next,prev,refreshButton;
|
|
17
|
+
let page=0,focusId='',recordKey='',activeTab='agents',invoker=null,refreshGeneration=0;
|
|
18
|
+
const button=(label,action)=>{const b=make('button',label);b.type='button';b.onclick=action;return b};
|
|
19
|
+
function compatible(value){return typeof value?.session_id==='string'&&value.session_id.length>0&&value.schema_version==='0.1'&&value.scope==='recorded_event_investigation'&&keyOf(value)===scope()&&
|
|
20
|
+
['agents','messages','calls','artifacts'].every(k=>Array.isArray(value[k])&&value[k].length<=10000&&value[k].every(r=>r&&typeof r==='object'&&!Array.isArray(r)))}
|
|
21
|
+
function fallback(){
|
|
22
|
+
const g=graph(),seen=new Map(),agents=[];
|
|
23
|
+
for(const n of list(g.nodes).slice(0,100000))if(n?.type==='agent'&&typeof n.id==='string'){
|
|
24
|
+
seen.set(n.id,seen.has(n.id)?null:n);
|
|
25
|
+
}
|
|
26
|
+
for(const [id,n] of seen)if(n&&agents.length<10000)agents.push({id,name:n.name||id,role:n.attributes?.role||n.attributes?.agent_role||'',provider:n.attributes?.provider||'unknown'});
|
|
27
|
+
return {session_id:g.session_id,source_path:g.source_path,agents,messages:[],calls:[],artifacts:[],inspection:{state:'unavailable'}};
|
|
28
|
+
}
|
|
29
|
+
function clear(){
|
|
30
|
+
refreshGeneration++;if(refreshButton)refreshButton.disabled=false;
|
|
31
|
+
if(dialog){dialog.close();body.replaceChildren();query.value='';notice.textContent=''}
|
|
32
|
+
pinned=null;focusId='';recordKey='';page=0;
|
|
33
|
+
}
|
|
34
|
+
function checkScope(){
|
|
35
|
+
if(scope()===currentScope)return true;
|
|
36
|
+
currentScope=scope();liveIndex=null;opened.clear();clear();return false;
|
|
37
|
+
}
|
|
38
|
+
function setIndex(value){
|
|
39
|
+
checkScope();if(!compatible(value)){if(dialog?.open)notice.textContent='Index not accepted: missing, malformed, or different run identity.';return false}liveIndex=value;scheduleMessagePanel();
|
|
40
|
+
if(dialog?.open)notice.textContent='Index updated. Refresh to inspect the new snapshot; the open page is unchanged.';
|
|
41
|
+
}
|
|
42
|
+
function current(){return liveIndex|| (compatible(window.__execweaveStaticInvestigation)?window.__execweaveStaticInvestigation:null)||fallback()}
|
|
43
|
+
function ensure(){
|
|
44
|
+
if(dialog)return;
|
|
45
|
+
dialog=make('dialog');dialog.id='execweave-investigation-dialog';dialog.setAttribute('aria-labelledby','execweave-investigation-title');
|
|
46
|
+
const head=make('header'),title=make('h2','Explore run');title.id='execweave-investigation-title';
|
|
47
|
+
head.append(title,button('Close exploration',()=>{clear();invoker?.focus()}));
|
|
48
|
+
const tabs=make('nav');tabs.setAttribute('aria-label','Investigation category');
|
|
49
|
+
for(const [name,label] of [['agents','Agents'],['messages','Handoffs'],['calls','Model / tool calls'],['artifacts','Files / artifacts']]){
|
|
50
|
+
const b=button(label,()=>{activeTab=name;recordKey='';page=0;draw()});b.dataset.tab=name;tabs.append(b);
|
|
51
|
+
}
|
|
52
|
+
const form=make('form');query=make('input');query.type='search';query.setAttribute('aria-label','Search investigation');query.placeholder='Search names, exact IDs, events or relations';
|
|
53
|
+
kind=make('select');kind.setAttribute('aria-label','Investigation filter');
|
|
54
|
+
for(const [value,label] of [['all','All records'],['attention','Needs attention']]){const o=make('option',label);o.value=value;kind.append(o)}
|
|
55
|
+
const search=button('Search records',()=>form.requestSubmit());
|
|
56
|
+
form.onsubmit=e=>{e.preventDefault();if(checkScope()){page=0;draw()}};kind.onchange=()=>form.requestSubmit();form.append(query,kind,search);
|
|
57
|
+
const controls=make('div');controls.className='investigation-controls';
|
|
58
|
+
prev=button('Previous page',()=>{page--;draw()});next=button('Next page',()=>{page++;draw()});
|
|
59
|
+
refreshButton=button('Refresh index',async()=>{
|
|
60
|
+
if(!checkScope()||refreshButton.disabled)return;
|
|
61
|
+
const request=++refreshGeneration;refreshButton.disabled=true;
|
|
62
|
+
// Reuse the existing authenticated request and its terminal guard. No timer.
|
|
63
|
+
try{
|
|
64
|
+
if(!window.__execweaveStaticMode){
|
|
65
|
+
const refreshed=await window.__execweaveDashboard?.agentPanel?.refresh?.({includeInvestigation:true});
|
|
66
|
+
// The shared reader reports HTTP, scope and terminal failures as false,
|
|
67
|
+
// not rejected promises. Only its explicit success can replace this view.
|
|
68
|
+
if(refreshed!==true)throw new Error('Index refresh did not complete');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch{if(request===refreshGeneration)notice.textContent='Index refresh failed. The current snapshot is retained.';return}
|
|
72
|
+
finally{if(request===refreshGeneration)refreshButton.disabled=false}
|
|
73
|
+
if(request!==refreshGeneration||!checkScope()||!dialog.open)return;pinned=current();notice.textContent='';draw();
|
|
74
|
+
});
|
|
75
|
+
controls.append(prev,next,refreshButton,button('Clear agent filter',()=>{focusId='';page=0;draw()}));
|
|
76
|
+
status=make('p');status.id='execweave-investigation-status';status.setAttribute('role','status');
|
|
77
|
+
notice=make('p');notice.id='execweave-investigation-updates';notice.setAttribute('role','status');
|
|
78
|
+
body=make('div');body.id='execweave-investigation-rows';
|
|
79
|
+
dialog.append(head,tabs,form,controls,status,notice,body);
|
|
80
|
+
dialog.addEventListener('keydown',e=>{if(e.key==='Escape')e.stopPropagation()});
|
|
81
|
+
dialog.addEventListener('cancel',e=>{e.preventDefault();clear();invoker?.focus()});document.body.append(dialog);
|
|
82
|
+
}
|
|
83
|
+
function refs(parent,rows,context){
|
|
84
|
+
for(const item of list(rows)){
|
|
85
|
+
const labels={registered_not_read:'Recorded reference; verify by opening',not_recorded:'No body recorded in this observation',invalid_reference:'Invalid content reference',not_in_graph_inventory:'Reference absent from the exported graph inventory'};
|
|
86
|
+
parent.append(make('p',[item.phase||item.relation,labels[item.state]||item.state,item.timestamp].filter(Boolean).join(' · ')));
|
|
87
|
+
if(item.reference)window.__execweaveContentBrowser?.attach(parent,[item.reference],context);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function attention(row){
|
|
91
|
+
if(activeTab==='messages')return !row.identity_bound||!list(row.phases).includes('received');
|
|
92
|
+
if(activeTab==='calls')return list(row.phases).includes('failure')||!list(row.phases).includes('response')||list(row.references).some(x=>x.state!=='registered_not_read');
|
|
93
|
+
if(activeTab==='artifacts')return !list(row.snapshots).some(x=>x.reference);
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
function selectedRows(){
|
|
97
|
+
const q=query.value.toLocaleLowerCase();
|
|
98
|
+
return list(pinned?.[activeTab]).filter(row=>{
|
|
99
|
+
if(recordKey&&(row.key||row.id)!==recordKey)return false;
|
|
100
|
+
if(focusId&&activeTab!=='agents'&&row.owner_id!==focusId&&row.target_id!==focusId&&
|
|
101
|
+
!list(row.relations).some(e=>e.source===focusId||e.target===focusId))return false;
|
|
102
|
+
if(kind.value==='attention'&&!attention(row))return false;
|
|
103
|
+
// Only index metadata is searchable. Do not parse or auto-fetch body text.
|
|
104
|
+
return !q||JSON.stringify(row).toLocaleLowerCase().includes(q);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function inspectAgent(row){
|
|
108
|
+
const core=window.__execweaveCore,shown=list(core?.getDisplayGraph?.()?.nodes||graph().nodes);
|
|
109
|
+
const matches=shown.filter(n=>n?.type==='agent'&&(n.id===row.id||list(n.attributes?.viewer_agent_member_ids).includes(row.id)));
|
|
110
|
+
if(matches.length===1){clear();core?.selectNode?.(matches[0].id);window.__execweaveDashboard?.agentPanel?.render?.(matches[0]);return}
|
|
111
|
+
notice.textContent='This agent is not uniquely represented in the current canvas. Its indexed evidence remains available here.';
|
|
112
|
+
}
|
|
113
|
+
function card(row,tab=activeTab){
|
|
114
|
+
const article=make('details');article.className='investigation-row';article.dataset.recordId=row.key||row.id;
|
|
115
|
+
let summary;
|
|
116
|
+
if(tab==='agents')summary=[row.name,row.role,row.provider].filter(Boolean).join(' · ');
|
|
117
|
+
else if(tab==='artifacts')summary=[row.name,row.snapshot_count?'Snapshot reference recorded':'No file snapshot recorded'].join(' · ');
|
|
118
|
+
else if(tab==='messages')summary=[row.source_name+' → '+row.target_name,list(row.phases).includes('sent')?'Send observed':'Send not observed',list(row.phases).includes('received')?'Receipt observed':'Receipt not observed','Consumption not observed',row.native_id||'Message ID unavailable'].join(' · ');
|
|
119
|
+
else summary=[row.source_name,row.kind,row.target_name,list(row.phases).join(' / '),row.native_id||'Call ID unavailable'].join(' · ');
|
|
120
|
+
article.append(make('summary',summary));
|
|
121
|
+
const readingKey=JSON.stringify([tab,row.key||row.id]);
|
|
122
|
+
let rendered=false;
|
|
123
|
+
article.addEventListener('toggle',()=>{
|
|
124
|
+
if(article.open){opened.add(readingKey);if(opened.size>512)opened.delete(opened.values().next().value)}else opened.delete(readingKey);
|
|
125
|
+
if(!article.open||rendered)return;rendered=true;
|
|
126
|
+
if(tab==='agents'){
|
|
127
|
+
article.append(make('p','Exact source: '+row.id),button('Inspect agent',()=>inspectAgent(row)),
|
|
128
|
+
button('Show agent handoffs',()=>{focusId=row.id;activeTab='messages';query.value='';kind.value='all';page=0;draw()}),
|
|
129
|
+
button('Show agent calls',()=>{focusId=row.id;activeTab='calls';query.value='';kind.value='all';page=0;draw()}),
|
|
130
|
+
button('Show agent artifacts',()=>{focusId=row.id;activeTab='artifacts';query.value='';kind.value='all';page=0;draw()}));return;
|
|
131
|
+
}
|
|
132
|
+
if(tab==='artifacts'){
|
|
133
|
+
article.append(make('p','File identity: '+row.id));
|
|
134
|
+
if(!row.snapshot_count)article.append(make('p','Historical snapshot: not recorded. Only a file/path observation is available; the current workspace file is not read or presented as historical evidence.'));
|
|
135
|
+
else article.append(make('p','Historical snapshot reference(s) recorded at execution time. Current workspace bytes are not substituted.'));
|
|
136
|
+
for(const item of list(row.snapshots)){
|
|
137
|
+
const ref=item?.reference;
|
|
138
|
+
if(ref)article.append(make('p',`Historical snapshot SHA-256: ${ref.sha256} · ${ref.size_bytes} bytes${item.timestamp?' · observed '+item.timestamp:''}`));
|
|
139
|
+
}
|
|
140
|
+
refs(article,row.snapshots,row.id);
|
|
141
|
+
if(row.related_content_count){article.append(make('p','Associated content below has no recognized file-snapshot contract.'));refs(article,row.related_content,row.id)}
|
|
142
|
+
for(const e of list(row.relations))article.append(make('p',[e.source,e.relation,e.target,e.edge_id,e.causal===true?'Recorded causal edge':'Relationship only; no producer/consumer inference'].join(' · ')));
|
|
143
|
+
if(row.relation_count>list(row.relations).length||row.snapshot_count>list(row.snapshots).length)article.append(make('p','Additional relationships exceed this bounded metadata preview. Inspect the original graph for the remainder.'));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
article.append(make('p','Native occurrence: '+(row.native_id||'Unavailable')+' · '+(row.owner_id||'Unknown owner')+' → '+(row.target_id||'Unknown target')));
|
|
147
|
+
if(tab==='messages'){
|
|
148
|
+
const sent=list(row.phases).includes('sent'),received=list(row.phases).includes('received');
|
|
149
|
+
article.append(make('p',`Evidence states · addressed recipient: ${row.target_name||row.target_id||'unknown'} · send: ${sent?'observed':'not observed'} · receipt: ${received?'observed':'not observed'} · consumption evidence: not observed.`));
|
|
150
|
+
article.append(make('p','Sent, addressed and received are separate observations. Receipt is not proof of consumption, comprehension or successful work. Consumption: not observed by this contract.'));
|
|
151
|
+
}
|
|
152
|
+
else{
|
|
153
|
+
article.append(make('p','Request, response and failure are retained separately. A response does not imply task success. This view does not observe the internals of a remote tool.'));
|
|
154
|
+
article.append(button('Runtime evidence for this invocation',()=>{
|
|
155
|
+
if(!checkScope())return;
|
|
156
|
+
const matches=list(current().calls).filter(r=>r.key===row.key);
|
|
157
|
+
const identity=r=>JSON.stringify([r.kind,r.native_id,r.owner_id,r.target_id]);
|
|
158
|
+
if(matches.length!==1||identity(matches[0])!==identity(row)){
|
|
159
|
+
notice.textContent='The indexed invocation changed or is ambiguous. Refresh before opening its runtime evidence.';return;
|
|
160
|
+
}
|
|
161
|
+
const result=window.__execweaveRuntimeEvidence?.openInvocation?.(row);
|
|
162
|
+
if(result?.state!=='exact_invocation')notice.textContent=
|
|
163
|
+
'No unambiguous exact invocation node is available ('+(result?.state||'reader unavailable')+'). '+
|
|
164
|
+
'Agent-wide or shared-tool activity is not substituted for this call.';
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
if(!row.identity_bound)article.append(make('p','Occurrence/participant identity is incomplete; unrelated records are not joined.'));
|
|
168
|
+
if(row.observation_basis==='explicit_graph_call')article.append(make('p','Graph-backed call identity. Content relationships are not a complete invocation transcript.'));
|
|
169
|
+
if(list(row.owner_candidates).length>1)article.append(make('p','Conflicting owner candidates (not assigned): '+row.owner_candidates.join(', ')));
|
|
170
|
+
refs(article,row.references,row.native_id);
|
|
171
|
+
if(row.reference_count>list(row.references).length)article.append(make('p','Additional references exceed this bounded preview; inspect the original graph for the remainder.'));
|
|
172
|
+
for(const event of list(row.observations))article.append(make('p',[event.phase,event.timestamp,event.event_id,event.stream+':'+event.line,event.capture_mode].filter(Boolean).join(' · ')));
|
|
173
|
+
});
|
|
174
|
+
if(opened.has(readingKey))article.open=true;
|
|
175
|
+
return article;
|
|
176
|
+
}
|
|
177
|
+
function draw(){
|
|
178
|
+
if(!dialog.open||!checkScope())return;
|
|
179
|
+
const rows=selectedRows(),total=Math.max(1,Math.ceil(rows.length/PAGE));page=Math.min(Math.max(0,page),total-1);
|
|
180
|
+
body.replaceChildren();for(const row of rows.slice(page*PAGE,(page+1)*PAGE))body.append(card(row));
|
|
181
|
+
if(!rows.length)body.append(make('p','No matching indexed records. This does not establish that no activity occurred. Existing agent history and raw evidence remain available.'));
|
|
182
|
+
prev.disabled=page===0;next.disabled=page===total-1;
|
|
183
|
+
for(const b of dialog.querySelectorAll('[data-tab]'))b.setAttribute('aria-pressed',String(b.dataset.tab===activeTab));
|
|
184
|
+
const inventory=pinned?.inspection||{},partial=inventory.state!=='scanned_selected_streams'||inventory.graph_inventory_partial;
|
|
185
|
+
status.textContent=`${rows.length} indexed ${activeTab}; page ${page+1}/${total}. ${focusId?'Agent filter: '+focusId+'. ':''}`+
|
|
186
|
+
(partial?'Partial or unavailable event inventory. ':'Selected recorded streams inspected. ')+
|
|
187
|
+
'Counts refer to indexed records, not provider recall or task success. Body references are verified only when opened.';
|
|
188
|
+
if(inventory.scope_rejected||inventory.invalid_records||inventory.conflicting_event_ids)status.textContent+=
|
|
189
|
+
` Excluded: ${inventory.scope_rejected||0} foreign-scope, ${inventory.invalid_records||0} invalid, ${inventory.conflicting_event_ids||0} conflicting event ID(s).`;
|
|
190
|
+
if(inventory.limit_reached||inventory.agent_rows_omitted||inventory.call_rows_omitted||inventory.artifact_rows_omitted)status.textContent+=' Inspection/output limit reached; counts are lower bounds.';
|
|
191
|
+
if(activeTab==='calls'&&rows.length){
|
|
192
|
+
const known=rows.filter(r=>r.owner_id).length,outputs=rows.filter(r=>list(r.references).some(x=>x.phase==='response'&&x.state==='registered_not_read')).length;
|
|
193
|
+
status.textContent+=` Visible call inventory: owner identified ${known}/${rows.length}; response-content reference registered ${outputs}/${rows.length}. References have not been read or verified by these counts.`;
|
|
194
|
+
}
|
|
195
|
+
if(activeTab==='messages'&&rows.length){
|
|
196
|
+
const received=rows.filter(r=>list(r.phases).includes('received')).length;
|
|
197
|
+
status.textContent+=` Visible message inventory: receipt evidence ${received}/${rows.length}. Remaining receipts are unobserved, not proven delivery failures.`;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function open(){
|
|
201
|
+
checkScope();ensure();invoker=document.activeElement;pinned=current();page=0;notice.textContent='';dialog.showModal();draw();
|
|
202
|
+
if(!window.__execweaveStaticMode&&!liveIndex){
|
|
203
|
+
const request=refreshGeneration;
|
|
204
|
+
void Promise.resolve().then(()=>window.__execweaveDashboard?.agentPanel?.refresh?.({includeInvestigation:true})).then(refreshed=>{
|
|
205
|
+
if(request===refreshGeneration&&dialog.open&&checkScope())notice.textContent=refreshed===true?
|
|
206
|
+
'Index request completed. Use Refresh index to load available records.':
|
|
207
|
+
'Index request failed. Existing records remain readable.';
|
|
208
|
+
}).catch(()=>{if(request===refreshGeneration&&dialog.open&&checkScope())notice.textContent='Index request failed. Existing records remain readable.'});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const launcher=button('Explore run',open);launcher.id='execweave-explore-run';
|
|
212
|
+
const anchor=document.getElementById('theme-toggle');
|
|
213
|
+
if(anchor?.parentElement)anchor.parentElement.insertBefore(launcher,anchor);else document.getElementById('inspector')?.prepend(launcher);
|
|
214
|
+
const prior=window.__execweaveDashboard||{};
|
|
215
|
+
window.__execweaveDashboard={...prior,onPayload(...args){prior.onPayload?.(...args);checkScope();scheduleMessagePanel()},onFinished(...args){prior.onFinished?.(...args);checkScope();scheduleMessagePanel()}};
|
|
216
|
+
window.addEventListener('pagehide',()=>{clear();liveIndex=null;opened.clear()});
|
|
217
|
+
function openRecord(tab,key){
|
|
218
|
+
if(!['agents','messages','calls','artifacts'].includes(tab)||typeof key!=='string')return false;
|
|
219
|
+
checkScope();const rows=list(current()[tab]);if(rows.filter(r=>(r.key||r.id)===key).length!==1)return false;
|
|
220
|
+
activeTab=tab;recordKey=key;open();query.value='';kind.value='all';draw();return true;
|
|
221
|
+
}
|
|
222
|
+
/*EXECWEAVE_MESSAGE_HANDOFFS*/
|
|
223
|
+
function openTab(tab){
|
|
224
|
+
if(!['agents','messages','calls','artifacts'].includes(tab))return false;
|
|
225
|
+
checkScope();ensure();activeTab=tab;recordKey='';focusId='';query.value='';kind.value='all';
|
|
226
|
+
if(!dialog.open)open();else{pinned=current();page=0;draw()}
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
function openForAgent(tab,id){
|
|
230
|
+
if(!['messages','calls','artifacts'].includes(tab)||typeof id!=='string'||!id)return false;
|
|
231
|
+
checkScope();const index=current();if(!compatible(index)||list(index.agents).filter(r=>r?.id===id).length!==1)return false;
|
|
232
|
+
ensure();activeTab=tab;recordKey='';focusId=id;query.value='';kind.value='all';
|
|
233
|
+
if(!dialog.open){open();focusId=id;activeTab=tab;page=0;draw()}else{pinned=current();page=0;draw()}
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
window.__execweaveInvestigation={setIndex,open,openTab,openForAgent,close:clear,getIndex:()=>{checkScope();return current()},openRecord};
|
|
237
|
+
})();
|
|
238
|
+
""".strip().replace("/*EXECWEAVE_MESSAGE_HANDOFFS*/", MESSAGE_HANDOFFS_JS, 1)
|
|
239
|
+
|
|
240
|
+
INVESTIGATION_CSS = r"""
|
|
241
|
+
#execweave-message-handoffs{padding:10px;margin:10px 0;border:1px solid var(--border);border-radius:8px;overflow-wrap:anywhere}
|
|
242
|
+
#execweave-message-handoffs p{font-size:12px;line-height:1.5}
|
|
243
|
+
#execweave-message-handoffs button{font:inherit;padding:6px;cursor:pointer}
|
|
244
|
+
#execweave-message-handoffs details{margin:8px 0;padding:8px;border:1px solid var(--border);border-radius:6px}
|
|
245
|
+
#execweave-message-handoffs summary{cursor:pointer;font-size:13px}
|
|
246
|
+
#execweave-explore-run{font:inherit;cursor:pointer;padding:6px 10px}
|
|
247
|
+
#execweave-investigation-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}
|
|
248
|
+
#execweave-investigation-dialog::backdrop{background:rgba(0,0,0,.45)}
|
|
249
|
+
#execweave-investigation-dialog header,#execweave-investigation-dialog nav,#execweave-investigation-dialog form,.investigation-controls{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:0 0 10px}
|
|
250
|
+
#execweave-investigation-title{flex:1;font-size:20px;margin:0}
|
|
251
|
+
#execweave-investigation-dialog button,#execweave-investigation-dialog input,#execweave-investigation-dialog select{font:inherit;padding:7px;cursor:pointer}
|
|
252
|
+
#execweave-investigation-dialog input{flex:1;min-width:200px}
|
|
253
|
+
#execweave-investigation-dialog [aria-pressed=true]{font-weight:700;border-bottom:3px solid currentColor}
|
|
254
|
+
#execweave-investigation-status,#execweave-investigation-updates{font-size:13px;line-height:1.5;overflow-wrap:anywhere}
|
|
255
|
+
#execweave-investigation-rows{max-height:56vh;overflow:auto;overscroll-behavior:contain}
|
|
256
|
+
#execweave-investigation-rows details{padding:10px;border:1px solid var(--border,#888);border-radius:8px;margin:8px 0;overflow-wrap:anywhere}
|
|
257
|
+
#execweave-investigation-rows summary{font-size:15px;cursor:pointer}
|
|
258
|
+
#execweave-investigation-rows p{font-size:13px;line-height:1.5}
|
|
259
|
+
""".strip()
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def inject_investigation(html: str) -> str:
|
|
263
|
+
if 'id="execweave-investigation-script"' in html:
|
|
264
|
+
return html
|
|
265
|
+
if "</body>" not in html:
|
|
266
|
+
raise RuntimeError("investigation requires a dashboard body")
|
|
267
|
+
return html.replace("</body>", "<style>" + INVESTIGATION_CSS + '</style><script id="execweave-investigation-script">'
|
|
268
|
+
+ INVESTIGATION_JS + "</script>\n</body>", 1)
|