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,309 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
from copy import deepcopy
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
_VIEWER_CONTENT_SCHEMA_VERSION = "0.1"
|
|
8
|
+
_CONTENT_PATH_RE = re.compile(
|
|
9
|
+
r"^content/sha256/(?P<sha256>[0-9a-f]{64})\.(?P<suffix>json|txt|bin)$"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _content_category(content_kind: str) -> str:
|
|
14
|
+
value = content_kind.lower()
|
|
15
|
+
if "agent_message" in value:
|
|
16
|
+
return "Agent Message Payload"
|
|
17
|
+
if "subtask_prompt" in value:
|
|
18
|
+
return "Subtask Prompt"
|
|
19
|
+
if "subtask_description" in value:
|
|
20
|
+
return "Subtask Description"
|
|
21
|
+
if "agent_result" in value:
|
|
22
|
+
return "Agent Result"
|
|
23
|
+
if "prompt_expansion" in value:
|
|
24
|
+
return "Prompt Expansion"
|
|
25
|
+
if "permission" in value:
|
|
26
|
+
return "Permission Evidence"
|
|
27
|
+
if ".task." in value or value.endswith(".task"):
|
|
28
|
+
return "Agent Task"
|
|
29
|
+
if "compaction" in value:
|
|
30
|
+
return "Context Compaction"
|
|
31
|
+
if "elicitation" in value:
|
|
32
|
+
return "MCP Elicitation"
|
|
33
|
+
if "notification" in value:
|
|
34
|
+
return "Provider Notification"
|
|
35
|
+
if ".stop.background_tasks" in value or ".stop.session_crons" in value:
|
|
36
|
+
return "Agent Runtime State"
|
|
37
|
+
if "reasoning.encoded" in value or "encoded_reasoning" in value:
|
|
38
|
+
return "Encoded Reasoning"
|
|
39
|
+
if "reasoning.summary" in value or "reasoning_summary" in value:
|
|
40
|
+
return "Reasoning Summary"
|
|
41
|
+
if "reasoning.text" in value or value.endswith(".reasoning"):
|
|
42
|
+
return "Reasoning Text"
|
|
43
|
+
if "inference_request" in value:
|
|
44
|
+
return "Inference Request"
|
|
45
|
+
if "inference_response" in value:
|
|
46
|
+
return "Inference Response"
|
|
47
|
+
if "terminal.request" in value:
|
|
48
|
+
return "Terminal Request"
|
|
49
|
+
if "terminal.result" in value:
|
|
50
|
+
return "Terminal Result"
|
|
51
|
+
if "code_cell.source" in value:
|
|
52
|
+
return "Code Cell Source"
|
|
53
|
+
if "raw_payload" in value:
|
|
54
|
+
return "Raw Provider Payload"
|
|
55
|
+
if "provider_metadata" in value or "provider_request_config" in value or value.endswith("metadata"):
|
|
56
|
+
return "Provider Metadata"
|
|
57
|
+
if any(token in value for token in ("tool_output", "tool_result", "tool_response", "shell_output")):
|
|
58
|
+
return "Tool Output"
|
|
59
|
+
if any(token in value for token in ("tool_input", "tool_arguments")):
|
|
60
|
+
return "Tool Input"
|
|
61
|
+
if any(
|
|
62
|
+
token in value
|
|
63
|
+
for token in (
|
|
64
|
+
"assistant_response",
|
|
65
|
+
"completed_text",
|
|
66
|
+
"response_object",
|
|
67
|
+
"standard_logging_response",
|
|
68
|
+
".response",
|
|
69
|
+
)
|
|
70
|
+
):
|
|
71
|
+
return "Response"
|
|
72
|
+
if any(
|
|
73
|
+
token in value
|
|
74
|
+
for token in (
|
|
75
|
+
"user_prompt",
|
|
76
|
+
"system_prompt",
|
|
77
|
+
"request_messages",
|
|
78
|
+
"model_context",
|
|
79
|
+
"inference_message",
|
|
80
|
+
"request_prompt",
|
|
81
|
+
"request_input",
|
|
82
|
+
)
|
|
83
|
+
):
|
|
84
|
+
return "Prompt"
|
|
85
|
+
if "file_content" in value or "file_snapshot" in value:
|
|
86
|
+
return "File Content"
|
|
87
|
+
if "shell_command" in value or value.endswith(".command"):
|
|
88
|
+
return "Shell Command"
|
|
89
|
+
if "mcp" in value:
|
|
90
|
+
return "MCP Content"
|
|
91
|
+
if "tool_definition" in value or "tool_schema" in value:
|
|
92
|
+
return "Tool Definition"
|
|
93
|
+
return "Observed Content"
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def viewer_content_reference(node: dict[str, Any]) -> dict[str, Any] | None:
|
|
97
|
+
"""Return a safe viewer-only projection of an observed-content reference.
|
|
98
|
+
|
|
99
|
+
The viewer accepts only ExecWeave content-addressed paths whose filename hash
|
|
100
|
+
exactly matches the node's SHA-256 attribute. This prevents a hand-edited
|
|
101
|
+
graph from turning the inspector into an arbitrary relative-file link.
|
|
102
|
+
"""
|
|
103
|
+
if node.get("type") != "observed_content":
|
|
104
|
+
return None
|
|
105
|
+
attributes = node.get("attributes")
|
|
106
|
+
if not isinstance(attributes, dict):
|
|
107
|
+
return None
|
|
108
|
+
path = attributes.get("path")
|
|
109
|
+
sha256 = attributes.get("sha256")
|
|
110
|
+
content_kind = attributes.get("content_kind")
|
|
111
|
+
if not all(isinstance(value, str) and value for value in (path, sha256, content_kind)):
|
|
112
|
+
return None
|
|
113
|
+
match = _CONTENT_PATH_RE.fullmatch(path)
|
|
114
|
+
if match is None or match.group("sha256") != sha256:
|
|
115
|
+
return None
|
|
116
|
+
size_bytes = attributes.get("size_bytes")
|
|
117
|
+
if not isinstance(size_bytes, int) or isinstance(size_bytes, bool) or size_bytes < 0:
|
|
118
|
+
return None
|
|
119
|
+
media_type = attributes.get("media_type")
|
|
120
|
+
representation = attributes.get("representation")
|
|
121
|
+
complete = attributes.get("complete_from_source")
|
|
122
|
+
return {
|
|
123
|
+
"schema_version": _VIEWER_CONTENT_SCHEMA_VERSION,
|
|
124
|
+
"viewer_only": True,
|
|
125
|
+
"category": _content_category(content_kind),
|
|
126
|
+
"safe_relative_path": path,
|
|
127
|
+
"sha256": sha256,
|
|
128
|
+
"suffix": match.group("suffix"),
|
|
129
|
+
"size_bytes": size_bytes,
|
|
130
|
+
"media_type": media_type if isinstance(media_type, str) else None,
|
|
131
|
+
"representation": representation if isinstance(representation, str) else None,
|
|
132
|
+
"content_kind": content_kind,
|
|
133
|
+
"complete_from_source": complete if isinstance(complete, bool) else None,
|
|
134
|
+
"content_embedded_in_viewer": False,
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _node_lists(graph: dict[str, Any]) -> list[list[Any]]:
|
|
139
|
+
result: list[list[Any]] = []
|
|
140
|
+
nodes = graph.get("nodes")
|
|
141
|
+
if isinstance(nodes, list):
|
|
142
|
+
result.append(nodes)
|
|
143
|
+
expansion = graph.get("expansion")
|
|
144
|
+
clusters = expansion.get("clusters") if isinstance(expansion, dict) else None
|
|
145
|
+
if isinstance(clusters, dict):
|
|
146
|
+
for entry in clusters.values():
|
|
147
|
+
members = entry.get("nodes") if isinstance(entry, dict) else None
|
|
148
|
+
if isinstance(members, list):
|
|
149
|
+
result.append(members)
|
|
150
|
+
return result
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def decorate_viewer_content_references(graph: dict[str, Any]) -> dict[str, Any]:
|
|
154
|
+
"""Add safe display metadata without mutating the canonical graph or content."""
|
|
155
|
+
references = 0
|
|
156
|
+
for nodes in _node_lists(graph):
|
|
157
|
+
for node in nodes:
|
|
158
|
+
if isinstance(node, dict) and viewer_content_reference(node) is not None:
|
|
159
|
+
references += 1
|
|
160
|
+
if references == 0:
|
|
161
|
+
return dict(graph)
|
|
162
|
+
|
|
163
|
+
projected = deepcopy(graph)
|
|
164
|
+
decorated = 0
|
|
165
|
+
for nodes in _node_lists(projected):
|
|
166
|
+
for node in nodes:
|
|
167
|
+
if not isinstance(node, dict):
|
|
168
|
+
continue
|
|
169
|
+
reference = viewer_content_reference(node)
|
|
170
|
+
if reference is None:
|
|
171
|
+
continue
|
|
172
|
+
attributes = node.setdefault("attributes", {})
|
|
173
|
+
if not isinstance(attributes, dict):
|
|
174
|
+
continue
|
|
175
|
+
attributes["viewer_content"] = reference
|
|
176
|
+
node["name"] = reference["category"]
|
|
177
|
+
decorated += 1
|
|
178
|
+
projected["viewer_content_projection"] = {
|
|
179
|
+
"schema_version": _VIEWER_CONTENT_SCHEMA_VERSION,
|
|
180
|
+
"viewer_only": True,
|
|
181
|
+
"reference_count": decorated,
|
|
182
|
+
"content_embedded_in_viewer": False,
|
|
183
|
+
"http_content_serving_enabled": False,
|
|
184
|
+
}
|
|
185
|
+
return projected
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
_INSPECTOR_CSS = r"""
|
|
189
|
+
.content-inspector,.agent-inspector,.message-inspector,.delegation-inspector{margin:14px 0 4px;border:1px solid var(--border);border-radius:8px;background:var(--panel2);overflow:hidden}
|
|
190
|
+
.content-inspector summary,.agent-inspector summary,.message-inspector summary,.delegation-inspector summary{cursor:pointer;padding:9px 10px;font-weight:700;list-style:none}.content-inspector summary::-webkit-details-marker,.agent-inspector summary::-webkit-details-marker,.message-inspector summary::-webkit-details-marker,.delegation-inspector summary::-webkit-details-marker{display:none}
|
|
191
|
+
.content-inspector summary::before,.agent-inspector summary::before,.message-inspector summary::before,.delegation-inspector summary::before{content:'▸';display:inline-block;width:14px;color:var(--muted)}.content-inspector[open] summary::before,.agent-inspector[open] summary::before,.message-inspector[open] summary::before,.delegation-inspector[open] summary::before{content:'▾'}
|
|
192
|
+
.content-inspector-body,.agent-inspector-body,.message-inspector-body,.delegation-inspector-body{padding:0 10px 10px}.content-meta{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:4px 8px;margin:2px 0 9px;font:11px/1.4 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.content-meta dt{color:var(--muted)}.content-meta dd{margin:0;overflow-wrap:anywhere}
|
|
193
|
+
.content-note{margin:8px 0;color:var(--muted);font-size:11px}.content-open{display:inline-block;margin:3px 5px 9px 0;padding:5px 8px;border:1px solid var(--border);border-radius:6px;color:var(--text);text-decoration:none}.content-open:hover{border-color:var(--selected)}
|
|
194
|
+
.content-frame{display:block;width:100%;min-height:220px;border:1px solid var(--border);border-radius:6px;background:#fff}.content-unavailable{color:var(--muted);font-size:11px}
|
|
195
|
+
.agent-visibility{margin:7px 0 10px;padding:8px;border:1px solid var(--border);border-radius:7px;background:var(--panel)}.agent-visibility-head{display:flex;align-items:center;gap:7px;flex-wrap:wrap;margin-bottom:7px}.agent-visibility-title{font-weight:700;font-size:11px}.agent-visibility-provider{color:var(--muted);font:10px/1.3 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.agent-visibility-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}.agent-visibility-card{min-width:0;padding:7px;border:1px solid var(--border);border-radius:6px;background:var(--panel2)}.agent-visibility-label{color:var(--muted);font-size:9px;font-weight:700;text-transform:uppercase;letter-spacing:.05em}.agent-visibility-value{margin-top:3px;font-size:10px;line-height:1.35;overflow-wrap:anywhere}.agent-visibility-card.is-gap .agent-visibility-value{font-weight:700}.agent-visibility-note{margin-top:7px;color:var(--muted);font-size:10px;line-height:1.4}
|
|
196
|
+
.agent-activity-list{display:grid;gap:7px}.agent-activity{border:1px solid var(--border);border-radius:7px;padding:7px 8px;background:var(--panel)}.agent-activity-head{display:flex;gap:6px;align-items:center;flex-wrap:wrap;font-size:11px}.agent-activity-relation{font-weight:700;color:var(--text)}.agent-activity-direction{color:var(--selected);font-weight:800}.agent-activity-peer{margin-top:3px;color:var(--muted);font:11px/1.4 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;overflow-wrap:anywhere}.agent-activity-meta{margin-left:auto;color:var(--muted);font-size:10px}.agent-activity-actions{display:flex;gap:5px;flex-wrap:wrap;margin-top:6px}.agent-activity-actions button{padding:3px 6px;font-size:10px}.agent-empty{color:var(--muted);font-size:11px}.agent-section-title{margin:9px 0 6px;color:var(--muted);font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em}
|
|
197
|
+
.message-stage-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;margin:4px 0 9px}.message-stage{min-width:0;padding:7px;border:1px solid var(--border);border-radius:6px;background:var(--panel)}.message-stage-label{color:var(--muted);font-size:9px;font-weight:800;letter-spacing:.06em}.message-stage-value{margin-top:3px;font-size:10px;line-height:1.35}.message-stage.is-observed .message-stage-value{font-weight:800;color:var(--text)}.message-route{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:4px 8px;margin:7px 0 9px;font:10px/1.4 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.message-route dt{color:var(--muted)}.message-route dd{margin:0;overflow-wrap:anywhere}.message-inferences{display:grid;gap:6px;margin-top:7px}.message-inference{display:flex;align-items:center;gap:7px;padding:6px 7px;border:1px solid var(--border);border-radius:6px;background:var(--panel)}.message-inference-label{min-width:0;flex:1;color:var(--muted);font:10px/1.35 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;overflow-wrap:anywhere}.message-inference button{padding:3px 6px;font-size:10px}
|
|
198
|
+
.delegation-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin:4px 0 9px}.delegation-card{min-width:0;padding:8px;border:1px solid var(--border);border-radius:7px;background:var(--panel)}.delegation-card.is-exact{border-color:var(--selected)}.delegation-label{color:var(--muted);font-size:9px;font-weight:800;text-transform:uppercase;letter-spacing:.06em}.delegation-value{margin-top:3px;font-size:10px;line-height:1.4;overflow-wrap:anywhere}.delegation-card.is-exact .delegation-value{font-weight:800}.delegation-actions{display:flex;gap:5px;flex-wrap:wrap;margin:7px 0}.delegation-actions button{padding:3px 6px;font-size:10px}
|
|
199
|
+
@media(max-width:720px){.agent-visibility-grid,.message-stage-grid,.delegation-grid{grid-template-columns:1fr}}
|
|
200
|
+
""".strip()
|
|
201
|
+
|
|
202
|
+
_INSPECTOR_JS = r"""
|
|
203
|
+
function execweaveFormatBytes(value){const n=Number(value)||0;if(n<1024)return `${n} B`;if(n<1024*1024)return `${(n/1024).toFixed(1)} KiB`;return `${(n/(1024*1024)).toFixed(1)} MiB`}
|
|
204
|
+
function execweaveAppendMeta(list,key,value){if(value===null||value===undefined||value==='')return;const dt=document.createElement('dt');dt.textContent=key;const dd=document.createElement('dd');dd.textContent=String(value);list.append(dt,dd)}
|
|
205
|
+
function execweaveAppendContentInspector(kind,value){
|
|
206
|
+
if(kind!=='Node'||!value||value.type!=='observed_content')return;
|
|
207
|
+
const ref=value.attributes&&value.attributes.viewer_content;if(!ref||ref.viewer_only!==true)return;
|
|
208
|
+
const panel=document.createElement('details');panel.className='content-inspector';
|
|
209
|
+
const summary=document.createElement('summary');summary.textContent=`${ref.category||'Observed Content'} · ${execweaveFormatBytes(ref.size_bytes)}`;panel.appendChild(summary);
|
|
210
|
+
const body=document.createElement('div');body.className='content-inspector-body';const meta=document.createElement('dl');meta.className='content-meta';
|
|
211
|
+
execweaveAppendMeta(meta,'kind',ref.content_kind);execweaveAppendMeta(meta,'media',ref.media_type);execweaveAppendMeta(meta,'representation',ref.representation);execweaveAppendMeta(meta,'sha256',ref.sha256);execweaveAppendMeta(meta,'path',ref.safe_relative_path);body.appendChild(meta);
|
|
212
|
+
const complete=document.createElement('div');complete.className='content-note';complete.textContent=ref.complete_from_source===true?'Complete from source: the selected integration supplied this complete value. This does not imply visibility into hidden model/provider state.':'Completeness was not asserted by the selected integration point.';body.appendChild(complete);
|
|
213
|
+
if(location.protocol==='file:'){
|
|
214
|
+
const link=document.createElement('a');link.className='content-open';link.href=ref.safe_relative_path;link.target='_blank';link.rel='noreferrer';link.textContent='Open stored content';body.appendChild(link);
|
|
215
|
+
if(ref.suffix==='json'||ref.suffix==='txt'){
|
|
216
|
+
const frame=document.createElement('iframe');frame.className='content-frame';frame.setAttribute('sandbox','');frame.setAttribute('referrerpolicy','no-referrer');frame.loading='lazy';frame.title=`${ref.category||'Observed Content'} stored content`;panel.addEventListener('toggle',()=>{if(panel.open&&!frame.getAttribute('src'))frame.setAttribute('src',ref.safe_relative_path)});body.appendChild(frame);
|
|
217
|
+
}
|
|
218
|
+
}else{
|
|
219
|
+
const unavailable=document.createElement('div');unavailable.className='content-unavailable';unavailable.textContent='Content bytes are not fetched over HTTP by this inspector. Open the persisted viewer.html from the run directory to inspect the local content reference.';body.appendChild(unavailable);
|
|
220
|
+
}
|
|
221
|
+
panel.appendChild(body);details.appendChild(panel);
|
|
222
|
+
}
|
|
223
|
+
function execweaveActivitySequence(edge){return Number.isInteger(edge.first_sequence)?edge.first_sequence:Number.isInteger(edge.last_sequence)?edge.last_sequence:Number.MAX_SAFE_INTEGER}
|
|
224
|
+
function execweaveActivityTime(edge){return edge.first_seen||edge.last_seen||''}
|
|
225
|
+
function execweaveAgentNodeMap(){return new Map(possibleNodes.filter(node=>node&&node.id).map(node=>[node.id,node]))}
|
|
226
|
+
function execweaveIncidentEdges(nodeId){return possibleEdges.filter(edge=>edge&&(edge.source===nodeId||edge.target===nodeId)).sort((a,b)=>execweaveActivitySequence(a)-execweaveActivitySequence(b)||String(execweaveActivityTime(a)).localeCompare(String(execweaveActivityTime(b)))||String(a.id||'').localeCompare(String(b.id||'')))}
|
|
227
|
+
function execweaveAgentTraceCapability(agent,nodeMap){
|
|
228
|
+
const direct=possibleEdges.find(edge=>edge&&edge.relation==='DECLARES_AGENT_TRACE_VISIBILITY'&&edge.source===agent.id&&nodeMap.get(edge.target)&&nodeMap.get(edge.target).type==='agent_trace_capability');if(direct)return nodeMap.get(direct.target);
|
|
229
|
+
const provider=agent.attributes&&agent.attributes.provider;if(!provider)return null;
|
|
230
|
+
return possibleNodes.find(node=>node&&node.type==='agent_trace_capability'&&node.attributes&&node.attributes.provider===provider)||null;
|
|
231
|
+
}
|
|
232
|
+
function execweaveVisibilityText(value){
|
|
233
|
+
const known={not_exposed_by_source:'Not exposed by provider source',provider_root_only:'Root agent only',provider_exposed_subagent_id:'Provider exposes subagent ID',provider_exposed_lifecycle:'Provider exposes lifecycle',provider_exposed_thread_identity:'Provider exposes thread identity',provider_exposed_rollout_graph:'Provider exposes rollout graph',provider_exposed_plaintext_summary_or_encoded:'Provider exposes text / summary / encoded form',provider_exposed_when_subagent_id_present:'When provider supplies subagent ID',provider_exposed_thinking_text:'Provider exposes thinking text',provider_exposed_session_identity:'Provider exposes session identity',provider_exposed_session_parent_id:'Provider exposes session parent ID',provider_exposed_reasoning_part:'Provider exposes reasoning part',unknown:'Unknown'};if(known[value])return known[value];return String(value||'Unknown').replaceAll('_',' ');
|
|
234
|
+
}
|
|
235
|
+
function execweaveVisibilityCard(label,value){const card=document.createElement('div');card.className='agent-visibility-card';if(value==='not_exposed_by_source')card.classList.add('is-gap');const key=document.createElement('div');key.className='agent-visibility-label';key.textContent=label;const body=document.createElement('div');body.className='agent-visibility-value';body.textContent=execweaveVisibilityText(value);card.append(key,body);return card}
|
|
236
|
+
function execweaveAppendAgentVisibility(body,agent,nodeMap){
|
|
237
|
+
const capability=execweaveAgentTraceCapability(agent,nodeMap);if(!capability)return;const attrs=capability.attributes||{};const panel=document.createElement('div');panel.className='agent-visibility';const head=document.createElement('div');head.className='agent-visibility-head';const title=document.createElement('span');title.className='agent-visibility-title';title.textContent='Provider trace visibility';const provider=document.createElement('span');provider.className='agent-visibility-provider';provider.textContent=String(attrs.provider||'provider');head.append(title,provider);panel.appendChild(head);const grid=document.createElement('div');grid.className='agent-visibility-grid';grid.append(execweaveVisibilityCard('Identity',attrs.agent_identity_visibility),execweaveVisibilityCard('Subagents',attrs.subagent_visibility),execweaveVisibilityCard('Reasoning',attrs.reasoning_visibility));panel.appendChild(grid);const note=document.createElement('div');note.className='agent-visibility-note';note.textContent='This describes what the selected provider integration exposed. “Not exposed” is a source capability boundary, not evidence that ExecWeave dropped an event or that hidden provider state was unavailable internally.';panel.appendChild(note);body.appendChild(panel);
|
|
238
|
+
}
|
|
239
|
+
function execweavePayloadNodes(nodeId,nodeMap){
|
|
240
|
+
const result=[],seen=new Set(),current=nodeMap.get(nodeId);if(current&¤t.type==='observed_content'&¤t.attributes&¤t.attributes.viewer_content){seen.add(current.id);result.push(current)}
|
|
241
|
+
possibleEdges.forEach(edge=>{if(!edge||(edge.source!==nodeId&&edge.target!==nodeId))return;const peerId=edge.source===nodeId?edge.target:edge.source;const peer=nodeMap.get(peerId);const ref=peer&&peer.type==='observed_content'&&peer.attributes&&peer.attributes.viewer_content;if(!ref||seen.has(peer.id))return;seen.add(peer.id);result.push(peer)});
|
|
242
|
+
return result;
|
|
243
|
+
}
|
|
244
|
+
function execweaveAppendPayloadLinks(container,nodeId,nodeMap){
|
|
245
|
+
if(location.protocol!=='file:')return;
|
|
246
|
+
execweavePayloadNodes(nodeId,nodeMap).forEach(node=>{const ref=node.attributes.viewer_content;const link=document.createElement('a');link.className='content-open';link.href=ref.safe_relative_path;link.target='_blank';link.rel='noreferrer';link.textContent=`${ref.category||'Payload'} · ${execweaveFormatBytes(ref.size_bytes)}`;container.appendChild(link)});
|
|
247
|
+
}
|
|
248
|
+
function execweaveActivityRow(edge,agentId,nodeMap){
|
|
249
|
+
const outbound=edge.source===agentId,peerId=outbound?edge.target:edge.source,peer=nodeMap.get(peerId);const row=document.createElement('div');row.className='agent-activity';
|
|
250
|
+
const head=document.createElement('div');head.className='agent-activity-head';const direction=document.createElement('span');direction.className='agent-activity-direction';direction.textContent=outbound?'OUT':'IN';const relation=document.createElement('span');relation.className='agent-activity-relation';relation.textContent=edge.relation||'UNKNOWN';const meta=document.createElement('span');meta.className='agent-activity-meta';const seq=execweaveActivitySequence(edge);meta.textContent=`${seq===Number.MAX_SAFE_INTEGER?'seq —':`seq ${seq}`}${execweaveActivityTime(edge)?` · ${execweaveActivityTime(edge)}`:''}`;head.append(direction,relation,meta);row.appendChild(head);
|
|
251
|
+
const peerLabel=document.createElement('div');peerLabel.className='agent-activity-peer';peerLabel.textContent=`${peer&&peer.type?peer.type:'node'} · ${peer&&(peer.name||peer.id)?(peer.name||peer.id):peerId}`;row.appendChild(peerLabel);
|
|
252
|
+
const actions=document.createElement('div');actions.className='agent-activity-actions';const inspect=document.createElement('button');inspect.type='button';inspect.textContent='Inspect edge';inspect.addEventListener('click',()=>showDetails('Edge',edge));actions.appendChild(inspect);if(peer){const peerButton=document.createElement('button');peerButton.type='button';peerButton.textContent='Inspect peer';peerButton.addEventListener('click',()=>showDetails('Node',peer));actions.appendChild(peerButton)}row.appendChild(actions);
|
|
253
|
+
execweaveAppendPayloadLinks(row,peerId,nodeMap);return row;
|
|
254
|
+
}
|
|
255
|
+
function execweaveCommunicationEdges(agentId,nodeMap){
|
|
256
|
+
const communicationRelations=new Set(['SPAWNED_AGENT','ASSIGNED_AGENT_TASK','CREATED_AGENT_TASK','COMPLETED_AGENT_TASK','SENT_AGENT_MESSAGE','DELIVERED_AGENT_MESSAGE','RETURNED_AGENT_RESULT','CLOSED_AGENT','SUBAGENT_STOPPED','HAS_CHILD_AGENT_SESSION','SPAWNED_SUBAGENT','RETURNED_TO','REQUESTED_SUBTASK']);
|
|
257
|
+
return execweaveIncidentEdges(agentId).filter(edge=>{const peerId=edge.source===agentId?edge.target:edge.source,peer=nodeMap.get(peerId);return communicationRelations.has(edge.relation)||(peer&&['agent','agent_message','agent_interaction','subtask','agent_task'].includes(peer.type))});
|
|
258
|
+
}
|
|
259
|
+
function execweaveAppendActivitySection(body,title,edges,agentId,nodeMap){const heading=document.createElement('div');heading.className='agent-section-title';heading.textContent=`${title} · ${edges.length}`;body.appendChild(heading);if(!edges.length){const empty=document.createElement('div');empty.className='agent-empty';empty.textContent='No matching evidence in this graph.';body.appendChild(empty);return}const list=document.createElement('div');list.className='agent-activity-list';edges.forEach(edge=>list.appendChild(execweaveActivityRow(edge,agentId,nodeMap)));body.appendChild(list)}
|
|
260
|
+
function execweaveAppendAgentActivity(kind,value){
|
|
261
|
+
if(kind!=='Node'||!value||value.type!=='agent'||!value.id)return;
|
|
262
|
+
const nodeMap=execweaveAgentNodeMap(),all=execweaveIncidentEdges(value.id),communications=execweaveCommunicationEdges(value.id,nodeMap);const panel=document.createElement('details');panel.className='agent-inspector';panel.open=!document.querySelector('.execweave-said');const summary=document.createElement('summary');summary.textContent=`Agent trace · ${communications.length} communications · ${all.length} activities`;panel.appendChild(summary);const body=document.createElement('div');body.className='agent-inspector-body';execweaveAppendAgentVisibility(body,value,nodeMap);execweaveAppendActivitySection(body,'Agent communications',communications,value.id,nodeMap);execweaveAppendActivitySection(body,'Agent activity',all,value.id,nodeMap);panel.appendChild(body);details.appendChild(panel);
|
|
263
|
+
}
|
|
264
|
+
function execweaveMessageStageCard(label,relation,edges){const observed=edges.some(edge=>edge&&edge.relation===relation);const card=document.createElement('div');card.className=`message-stage${observed?' is-observed':''}`;const key=document.createElement('div');key.className='message-stage-label';key.textContent=label;const value=document.createElement('div');value.className='message-stage-value';value.textContent=observed?'Observed':'No evidence';card.title=relation;card.append(key,value);return card}
|
|
265
|
+
function execweaveAppendMessageInspector(kind,value){
|
|
266
|
+
if(kind!=='Node'||!value||value.type!=='agent_message'||!value.id)return;
|
|
267
|
+
const nodeMap=execweaveAgentNodeMap(),edges=execweaveIncidentEdges(value.id),attrs=value.attributes||{};const panel=document.createElement('details');panel.className='message-inspector';panel.open=true;const summary=document.createElement('summary');summary.textContent='Message Evidence';panel.appendChild(summary);const body=document.createElement('div');body.className='message-inspector-body';const stages=document.createElement('div');stages.className='message-stage-grid';stages.append(execweaveMessageStageCard('SEND','SENT_AGENT_MESSAGE',edges),execweaveMessageStageCard('DELIVER','DELIVERED_AGENT_MESSAGE',edges),execweaveMessageStageCard('CONTEXT','INCLUDED_AGENT_MESSAGE_IN_INFERENCE',edges),execweaveMessageStageCard('CONSUME','CONSUMED_AGENT_MESSAGE',edges));body.appendChild(stages);
|
|
268
|
+
const route=document.createElement('dl');route.className='message-route';execweaveAppendMeta(route,'author',attrs.author);execweaveAppendMeta(route,'recipient',attrs.recipient);execweaveAppendMeta(route,'conversation item',attrs.conversation_item_id);body.appendChild(route);
|
|
269
|
+
const inferenceEdges=edges.filter(edge=>edge&&edge.relation==='INCLUDED_AGENT_MESSAGE_IN_INFERENCE'&&edge.source===value.id);if(inferenceEdges.length){const title=document.createElement('div');title.className='agent-section-title';title.textContent=`Inference context · ${inferenceEdges.length}`;body.appendChild(title);const list=document.createElement('div');list.className='message-inferences';inferenceEdges.forEach(edge=>{const inference=nodeMap.get(edge.target);const row=document.createElement('div');row.className='message-inference';const label=document.createElement('div');label.className='message-inference-label';label.textContent=inference?(inference.name||inference.id):String(edge.target||'inference');row.appendChild(label);if(inference){const button=document.createElement('button');button.type='button';button.textContent='Inspect inference';button.addEventListener('click',()=>showDetails('Node',inference));row.appendChild(button)}list.appendChild(row)});body.appendChild(list)}
|
|
270
|
+
execweaveAppendPayloadLinks(body,value.id,nodeMap);const note=document.createElement('div');note.className='content-note';note.textContent='CONTEXT and CONSUME reflect provider-recorded request-context evidence. They are not proof that the model attended to, read, or semantically used the message. “No evidence” is not a failure state.';body.appendChild(note);panel.appendChild(body);details.appendChild(panel);
|
|
271
|
+
}
|
|
272
|
+
function execweaveDelegationCard(label,text,exact=false){const card=document.createElement('div');card.className=`delegation-card${exact?' is-exact':''}`;const key=document.createElement('div');key.className='delegation-label';key.textContent=label;const value=document.createElement('div');value.className='delegation-value';value.textContent=text;card.append(key,value);return card}
|
|
273
|
+
function execweaveDelegationPeer(edge,subtaskId,nodeMap){if(!edge)return null;const peerId=edge.source===subtaskId?edge.target:edge.source;return nodeMap.get(peerId)||null}
|
|
274
|
+
function execweaveAppendDelegationInspector(kind,value){
|
|
275
|
+
if(kind!=='Node'||!value||value.type!=='subtask'||!value.id)return;
|
|
276
|
+
const nodeMap=execweaveAgentNodeMap(),edges=execweaveIncidentEdges(value.id),attrs=value.attributes||{};
|
|
277
|
+
const requested=edges.find(edge=>edge&&edge.relation==='REQUESTED_SUBTASK'&&edge.target===value.id);const requester=execweaveDelegationPeer(requested,value.id,nodeMap);
|
|
278
|
+
const assigned=edges.find(edge=>edge&&edge.relation==='ASSIGNED_AGENT_TASK'&&edge.source===value.id&&nodeMap.get(edge.target)&&nodeMap.get(edge.target).type==='agent');const child=execweaveDelegationPeer(assigned,value.id,nodeMap);
|
|
279
|
+
const targeted=edges.find(edge=>edge&&edge.relation==='TARGETS_AGENT_PROFILE'&&edge.source===value.id);const profile=execweaveDelegationPeer(targeted,value.id,nodeMap);
|
|
280
|
+
const exact=Boolean(assigned&&child);const panel=document.createElement('details');panel.className='delegation-inspector';panel.open=true;const summary=document.createElement('summary');summary.textContent='Delegation Evidence';panel.appendChild(summary);const body=document.createElement('div');body.className='delegation-inspector-body';const grid=document.createElement('div');grid.className='delegation-grid';
|
|
281
|
+
grid.append(execweaveDelegationCard('Requester',requester?(requester.name||requester.id):'No requester evidence'),execweaveDelegationCard('Target',child?(child.name||child.id):profile?(profile.name||profile.id):'No target evidence'),execweaveDelegationCard('Child linkage',exact?'Exact child linkage':'Linkage not asserted',exact),execweaveDelegationCard('Provider',String(attrs.provider||'unknown')));body.appendChild(grid);
|
|
282
|
+
const actions=document.createElement('div');actions.className='delegation-actions';[[requester,'Inspect requester'],[child,'Inspect child'],[profile,'Inspect target profile']].forEach(([node,label])=>{if(!node)return;const button=document.createElement('button');button.type='button';button.textContent=label;button.addEventListener('click',()=>showDetails('Node',node));actions.appendChild(button)});if(actions.childElementCount)body.appendChild(actions);
|
|
283
|
+
execweaveAppendPayloadLinks(body,value.id,nodeMap);const note=document.createElement('div');note.className='content-note';note.textContent=exact?'Exact child linkage is shown only because the materialized graph contains an ASSIGNED_AGENT_TASK edge from this subtask to a provider-identified child agent.':'Linkage not asserted: the materialized evidence does not contain an exact subtask → child-agent assignment. A target agent profile or separate parent/child session relation must not be treated as that join.';body.appendChild(note);panel.appendChild(body);details.appendChild(panel);
|
|
284
|
+
}
|
|
285
|
+
""".strip()
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def inject_standalone_content_inspector(html: str) -> str:
|
|
289
|
+
"""Inject reference-only content, agent, message, and delegation inspectors.
|
|
290
|
+
|
|
291
|
+
Protective-mode HTML is intentionally left untouched. Full content bytes are
|
|
292
|
+
never embedded in the HTML and are never fetched over HTTP by this inspector.
|
|
293
|
+
Agent, message, and delegation views are derived only from graph evidence.
|
|
294
|
+
"""
|
|
295
|
+
marker = "function showDetails(kind,value){"
|
|
296
|
+
if marker not in html:
|
|
297
|
+
return html
|
|
298
|
+
result = html.replace("</style>", _INSPECTOR_CSS + "\n</style>", 1)
|
|
299
|
+
result = result.replace(marker, _INSPECTOR_JS + "\n" + marker, 1)
|
|
300
|
+
detail_end = " details.append(p);\n}"
|
|
301
|
+
replacement = (
|
|
302
|
+
" details.append(p);execweaveAppendContentInspector(kind,value);"
|
|
303
|
+
"execweaveAppendAgentActivity(kind,value);"
|
|
304
|
+
"execweaveAppendMessageInspector(kind,value);"
|
|
305
|
+
"execweaveAppendDelegationInspector(kind,value);\n}"
|
|
306
|
+
)
|
|
307
|
+
if detail_end not in result:
|
|
308
|
+
raise RuntimeError("standalone viewer detail seam changed; content inspector not injected")
|
|
309
|
+
return result.replace(detail_end, replacement, 1)
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"""Pinned-key verification for built-in byte predicates, never arbitrary task truth."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json as _json
|
|
6
|
+
|
|
7
|
+
from .controlled_checks import LIMITATION
|
|
8
|
+
|
|
9
|
+
CONTROLLED_CORE_JS = r"""
|
|
10
|
+
(()=>{
|
|
11
|
+
'use strict';if(globalThis.__execweaveControlledCore)return;
|
|
12
|
+
const FORMAT='execweave.controlled-checks.v1',PROFILE='execweave.verifier-profile.v1',POLICY='execweave.fixed-check-policy.v1';
|
|
13
|
+
const DOMAIN='ExecWeave fixed checks v1\0',LIMIT=2*1024*1024,FILE=8*1024*1024;
|
|
14
|
+
const own=(v,k)=>Object.prototype.hasOwnProperty.call(v,k),obj=v=>v&&typeof v==='object'&&!Array.isArray(v);
|
|
15
|
+
const fail=m=>{throw new Error(m)},match=(v,r)=>typeof v==='string'&&r.exec(v)?.[0]===v;
|
|
16
|
+
const hex=v=>match(v,/^[a-f0-9]{64}$/);
|
|
17
|
+
function fields(v,keys){if(!obj(v)||Object.keys(v).length!==keys.length||keys.some(k=>!own(v,k)))fail('Unsupported fields.');return v}
|
|
18
|
+
function text(v,max){if(typeof v!=='string'||!v.trim()||Array.from(v).length>max)fail('Invalid text.');return v}
|
|
19
|
+
function parse(raw,limit=LIMIT,safe=true){
|
|
20
|
+
if(typeof raw!=='string'||new TextEncoder().encode(raw).length>limit)fail('JSON byte limit exceeded.');
|
|
21
|
+
const parser=globalThis.__execweaveArchiveVerifier?.strictJSON;if(!parser)fail('Strict JSON reader unavailable.');
|
|
22
|
+
if(safe){
|
|
23
|
+
const tokens=raw.matchAll(/"(?:\\[\s\S]|[^"\\])*"|-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/g);
|
|
24
|
+
for(const token of tokens)if(token[0][0]!=='"'&&!match(token[0],/^-?(?:0|[1-9][0-9]*)$/))fail('Only literal safe JSON integers are supported.');
|
|
25
|
+
}
|
|
26
|
+
const value=parser(raw);
|
|
27
|
+
function walk(v,depth=0){
|
|
28
|
+
if(depth>32)fail('JSON nesting exceeds 32.');
|
|
29
|
+
if(typeof v==='number'&&(!Number.isFinite(v)||(safe&&!Number.isSafeInteger(v))))fail('Only safe JSON integers are supported.');
|
|
30
|
+
if(typeof v==='string'&&Array.from(v).some(c=>c.codePointAt(0)>=0xd800&&c.codePointAt(0)<=0xdfff))fail('Invalid Unicode.');
|
|
31
|
+
if(Array.isArray(v))for(const x of v)walk(x,depth+1);
|
|
32
|
+
else if(obj(v))for(const [k,x] of Object.entries(v)){walk(k,depth+1);walk(x,depth+1)}
|
|
33
|
+
}
|
|
34
|
+
walk(value);return value;
|
|
35
|
+
}
|
|
36
|
+
async function hash(value){
|
|
37
|
+
if(!globalThis.crypto?.subtle)fail('Native cryptography unavailable.');
|
|
38
|
+
const bytes=typeof value==='string'?new TextEncoder().encode(value):value;
|
|
39
|
+
return Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256',bytes)),v=>v.toString(16).padStart(2,'0')).join('');
|
|
40
|
+
}
|
|
41
|
+
function unbase64(value,size){
|
|
42
|
+
if(typeof value!=='string'||value.length!==4*Math.ceil(size/3))fail('Invalid signature/key encoding.');
|
|
43
|
+
let raw;try{raw=atob(value)}catch{fail('Invalid signature/key encoding.')}
|
|
44
|
+
if(raw.length!==size||btoa(raw)!==value)fail('Noncanonical signature/key encoding.');
|
|
45
|
+
return Uint8Array.from(raw,c=>c.charCodeAt(0));
|
|
46
|
+
}
|
|
47
|
+
function path(v){
|
|
48
|
+
text(v,512);
|
|
49
|
+
if(v.normalize('NFC')!==v||/[\\:*?"<>|\x00-\x1f\x7f]/.test(v)||v.split('/').some(p=>!p||p==='.'||p==='..'||/[ .]$/.test(p)||/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.|$)/i.test(p)))fail('Invalid relative artifact path.');
|
|
50
|
+
return v;
|
|
51
|
+
}
|
|
52
|
+
function policy(raw){
|
|
53
|
+
const p=fields(parse(raw,128*1024),['format','name','checks']);
|
|
54
|
+
if(p.format!==POLICY)fail('Unsupported fixed-check policy.');text(p.name,256);
|
|
55
|
+
if(!Array.isArray(p.checks)||!p.checks.length||p.checks.length>100)fail('Policy requires 1 to 100 checks.');
|
|
56
|
+
const ids=new Set(),names=new Map();
|
|
57
|
+
for(const c of p.checks){
|
|
58
|
+
fields(c,c?.op==='json_pointer_equals'?['id','path','op','expected','pointer']:['id','path','op','expected']);
|
|
59
|
+
if(!match(c.id,/^[A-Za-z0-9_.-]{1,96}$/)||ids.has(c.id))fail('Invalid or duplicate check identity.');ids.add(c.id);
|
|
60
|
+
path(c.path);const name=c.path.toLowerCase();if(names.has(name)&&names.get(name)!==c.path)fail('Case-colliding policy paths.');names.set(name,c.path);
|
|
61
|
+
if(c.op==='sha256_equals'){if(!hex(c.expected))fail('Invalid expected SHA-256.')}
|
|
62
|
+
else if(c.op==='utf8_contains')text(c.expected,65536);
|
|
63
|
+
else if(c.op==='json_pointer_equals'){
|
|
64
|
+
if(typeof c.pointer!=='string'||Array.from(c.pointer).length>2048||(c.pointer&&!c.pointer.startsWith('/'))||/~(?![01])/.test(c.pointer)||c.pointer.split('/').length-1>32)fail('Invalid JSON pointer.');
|
|
65
|
+
if(c.expected!==null&&!['string','number','boolean'].includes(typeof c.expected))fail('Expected JSON scalar required.');
|
|
66
|
+
if(typeof c.expected==='string'&&Array.from(c.expected).length>65536)fail('Expected scalar exceeds limit.');
|
|
67
|
+
}else fail('Executable or unknown check operation rejected.');
|
|
68
|
+
}
|
|
69
|
+
return p;
|
|
70
|
+
}
|
|
71
|
+
async function profile(value){
|
|
72
|
+
fields(value,['format','label','key_id','public_key_b64','policy_sha256']);
|
|
73
|
+
if(value.format!==PROFILE||!hex(value.key_id)||!hex(value.policy_sha256))fail('Invalid verifier profile.');text(value.label,256);
|
|
74
|
+
const raw=unbase64(value.public_key_b64,32);if(await hash(raw)!==value.key_id)fail('Profile key fingerprint mismatch.');
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
async function verify(envelope,pinned){
|
|
78
|
+
await profile(pinned);fields(envelope,['format','key_id','payload','signature_b64']);
|
|
79
|
+
if(envelope.format!==FORMAT||envelope.key_id!==pinned.key_id)fail('Receipt does not match the independently pinned key.');
|
|
80
|
+
if(typeof envelope.payload!=='string'||new TextEncoder().encode(envelope.payload).length>LIMIT/2)fail('Signed payload exceeds limit.');
|
|
81
|
+
let publicKey;try{publicKey=await crypto.subtle.importKey('raw',unbase64(pinned.public_key_b64,32),'Ed25519',false,['verify'])}catch{fail('Native Ed25519 verification unavailable; no authenticated result.')}
|
|
82
|
+
if(!await crypto.subtle.verify('Ed25519',publicKey,unbase64(envelope.signature_b64,64),new TextEncoder().encode(DOMAIN+envelope.payload)))fail('Signature verification failed.');
|
|
83
|
+
const p=fields(parse(envelope.payload),['format','scope','subject','task_snapshot_json','policy_json','policy_sha256','artifacts','results','execution_id','recorded_at','task_success_implied','limitation']);
|
|
84
|
+
if(p.format!=='execweave.fixed-check-execution.v1'||p.task_success_implied!==false||p.limitation!==__LIMITATION__)fail('Unsupported execution semantics.');
|
|
85
|
+
fields(p.scope,['session_id','run_id','source_path']);text(p.scope.session_id,4096);
|
|
86
|
+
for(const k of ['run_id','source_path'])if(p.scope[k]!==null)text(p.scope[k],4096);
|
|
87
|
+
fields(p.subject,['task_id','task_snapshot_sha256']);text(p.subject.task_id,4096);
|
|
88
|
+
const node=parse(p.task_snapshot_json,1024*1024,false);
|
|
89
|
+
if(!obj(node)||node.id!==p.subject.task_id||node.type!=='task'||[node,obj(node.attributes)?node.attributes:{}].some(o=>['inferred','viewer_only'].some(k=>o[k]!==undefined&&o[k]!==null&&o[k]!==false))||await hash(p.task_snapshot_json)!==p.subject.task_snapshot_sha256)fail('Signed task snapshot mismatch.');
|
|
90
|
+
const plan=policy(p.policy_json),policyHash=await hash(p.policy_json);
|
|
91
|
+
if(policyHash!==p.policy_sha256||policyHash!==pinned.policy_sha256)fail('Policy was not independently approved by this profile.');
|
|
92
|
+
if(!match(p.execution_id,/^[0-9a-f]{32}$/))fail('Invalid execution identity.');text(p.recorded_at,64);
|
|
93
|
+
const m=fields(p.artifacts,['format','entries','manifest_sha256']);
|
|
94
|
+
if(m.format!=='execweave.selected-artifact-versions.v1'||!Array.isArray(m.entries)||!m.entries.length||m.entries.length>100)fail('Invalid signed artifact inventory.');
|
|
95
|
+
const names=new Set(),byPath=new Map();let total=0;
|
|
96
|
+
for(const item of m.entries){
|
|
97
|
+
fields(item,['path','size_bytes','sha256']);path(item.path);const name=item.path.toLowerCase();
|
|
98
|
+
if(names.has(name)||!Number.isSafeInteger(item.size_bytes)||item.size_bytes<0||item.size_bytes>FILE||!hex(item.sha256))fail('Invalid or duplicate signed artifact.');
|
|
99
|
+
names.add(name);byPath.set(item.path,item);total+=item.size_bytes;if(total>64*1024*1024)fail('Artifact inventory exceeds limit.');
|
|
100
|
+
}
|
|
101
|
+
if(await hash(JSON.stringify(m.entries.map(e=>[e.path,e.size_bytes,e.sha256])))!==m.manifest_sha256)fail('Signed artifact manifest mismatch.');
|
|
102
|
+
if(byPath.size!==new Set(plan.checks.map(c=>c.path)).size||plan.checks.some(c=>!byPath.has(c.path)))fail('Policy/artifact coverage mismatch.');
|
|
103
|
+
if(!Array.isArray(p.results)||p.results.length!==plan.checks.length)fail('Missing or extra executed checks.');
|
|
104
|
+
const counts={passed:0,failed:0,error:0},reasons={passed:['predicate_true'],failed:['predicate_false','pointer_missing'],error:['invalid_utf8','invalid_json']};
|
|
105
|
+
for(let i=0;i<p.results.length;i++){
|
|
106
|
+
const r=fields(p.results[i],['id','path','op','artifact_sha256','outcome','reason']),c=plan.checks[i];
|
|
107
|
+
if(['id','path','op'].some(k=>r[k]!==c[k])||r.artifact_sha256!==byPath.get(c.path).sha256||!own(reasons,r.outcome)||!reasons[r.outcome].includes(r.reason))fail('Executed check identity, bytes or outcome mismatch.');
|
|
108
|
+
counts[r.outcome]++;
|
|
109
|
+
}
|
|
110
|
+
return {payload:p,counts,state:counts.passed===p.results.length?'checks_passed':'checks_failed',policy_name:plan.name,signer:pinned.label,key_id:pinned.key_id,receipt_hash:await hash(envelope.payload)};
|
|
111
|
+
}
|
|
112
|
+
globalThis.__execweaveControlledCore={parse,profile,verify,hash,path};
|
|
113
|
+
})();
|
|
114
|
+
""".strip()
|
|
115
|
+
# Use a JSON string literal rather than inserting executable text.
|
|
116
|
+
CONTROLLED_CORE_JS = CONTROLLED_CORE_JS.replace("__LIMITATION__", _json.dumps(LIMITATION))
|
|
117
|
+
|
|
118
|
+
CONTROLLED_VIEW_JS = r"""
|
|
119
|
+
(()=>{
|
|
120
|
+
'use strict';if(window.__execweaveControlledChecks)return;
|
|
121
|
+
const core=window.__execweaveControlledCore,make=(t,s)=>{const e=document.createElement(t);if(s!==undefined)e.textContent=String(s);return e};
|
|
122
|
+
const button=(s,f)=>{const e=make('button',s);e.type='button';e.onclick=f;return e};
|
|
123
|
+
const graph=()=>window.__execweaveCore?.getGraph?.()||window.__execweaveStaticGraph||{};
|
|
124
|
+
const scope=()=>{const g=graph();return JSON.stringify([g.session_id??null,g.run_id??null,g.source_path??null])};
|
|
125
|
+
let lastScope=scope(),latest=null,dialog,entry,status,body,trustInfo,trustPicker,receiptPicker,confirm,invoker,proposed=null,trusted=null,generation=0;
|
|
126
|
+
const records=new Map();
|
|
127
|
+
function target(p){
|
|
128
|
+
const g=graph(),a=latest||g.run_assessment||window.__execweaveStaticRunAssessment;
|
|
129
|
+
if(!p||g.live_payload_compact||!a||a.schema_version!=='0.1'||a.scope!=='published_graph_metadata'||a.inspection?.state!=='declared_graph')return false;
|
|
130
|
+
const aScope=JSON.stringify([a.session_id??null,a.run_id??null,a.source_path??null]);
|
|
131
|
+
if(aScope!==scope()||JSON.stringify([p.scope?.session_id??null,p.scope?.run_id??null,p.scope?.source_path??null])!==scope())return false;
|
|
132
|
+
const rows=a.task_validation?.external_report_subjects;
|
|
133
|
+
if(!Array.isArray(rows))return false;const found=rows.filter(s=>s.task_id===p.subject?.task_id);
|
|
134
|
+
return found.length===1&&found[0].task_snapshot_sha256===p.subject.task_snapshot_sha256;
|
|
135
|
+
}
|
|
136
|
+
function clearTrust(){generation++;proposed=null;trusted=null;records.clear();if(confirm)confirm.checked=false;if(receiptPicker)receiptPicker.value='';if(body)body.replaceChildren();if(trustInfo)trustInfo.textContent='No verifier key is trusted in this tab.'}
|
|
137
|
+
function reconcile(){
|
|
138
|
+
if(scope()!==lastScope){lastScope=scope();latest=null;clearTrust();dialog?.close();return}
|
|
139
|
+
let removed=false;for(const [id,r] of records)if(!target(r.payload)){records.delete(id);removed=true}
|
|
140
|
+
if(removed){generation++;if(status)status.textContent='Task evidence changed; prior accepted checks were revoked.'}
|
|
141
|
+
}
|
|
142
|
+
function close(){generation++;for(const r of records.values())delete r.comparison;dialog?.close();body?.replaceChildren();invoker?.focus()}
|
|
143
|
+
async function inputJSON(file,max){if(!file||file.size>max)throw new Error('File missing or above input limit.');const raw=await file.arrayBuffer();if(raw.byteLength!==file.size||raw.byteLength>max)throw new Error('File changed or exceeded its limit.');return core.parse(new TextDecoder('utf-8',{fatal:true}).decode(raw),max)}
|
|
144
|
+
function draw(){
|
|
145
|
+
if(!dialog?.open)return;body.replaceChildren();
|
|
146
|
+
for(const [id,r] of records){
|
|
147
|
+
const card=make('article');card.className='execweave-controlled-result';card.dataset.state=r.state;
|
|
148
|
+
card.append(make('h3',r.policy_name),make('strong',r.state==='checks_passed'?'Specified fixed checks passed':'Specified fixed checks did not all pass'),
|
|
149
|
+
make('p',`Pinned signer: ${r.signer}. ${r.counts.passed} passed; ${r.counts.failed} failed; ${r.counts.error} input errors. Signature verified under the profile you selected.`),
|
|
150
|
+
make('p','Task: '+r.payload.subject.task_id+' · snapshot '+r.payload.subject.task_snapshot_sha256),
|
|
151
|
+
make('p','Execution: '+r.payload.execution_id+' · signer-recorded time '+r.payload.recorded_at),make('p',r.payload.limitation));
|
|
152
|
+
const details=make('details');details.append(make('summary','Approved policy, signed task and executed checks'),make('pre',r.payload.policy_json),make('pre',r.payload.task_snapshot_json));
|
|
153
|
+
for(const row of r.payload.results)details.append(make('p',`${row.id} · ${row.path} · ${row.op} · ${row.outcome} · ${row.reason}`));card.append(details);
|
|
154
|
+
const compare=make('section');compare.className='execweave-controlled-comparison';compare.dataset.state=r.comparison?.state||'not_compared';
|
|
155
|
+
compare.append(make('h4','Compare delivered files with the evaluated bytes'),make('p',r.comparison?.message||'Not compared. The signature describes the evaluated snapshot, not your current directory.'));
|
|
156
|
+
const picker=make('input');picker.type='file';picker.multiple=true;picker.setAttribute('webkitdirectory','');picker.className='execweave-controlled-folder';picker.setAttribute('aria-label','Select delivered artifact folder');
|
|
157
|
+
picker.onchange=()=>compareFiles(id,Array.from(picker.files||[]));compare.append(picker);card.append(compare);body.append(card);
|
|
158
|
+
}
|
|
159
|
+
if(!records.size)body.append(make('p','No signed check execution is accepted for this run/task and trusted policy. External reports remain separate.'));
|
|
160
|
+
}
|
|
161
|
+
async function compareFiles(id,files){
|
|
162
|
+
reconcile();const r=records.get(id),pin=trusted,token=++generation,start=scope();if(!r||!pin)return;
|
|
163
|
+
const valid=()=>token===generation&&start===scope()&&dialog.open&&records.get(id)===r&&trusted===pin&&target(r.payload);
|
|
164
|
+
r.comparison={state:'checking',message:'Comparing only the listed evaluated bytes…'};draw();
|
|
165
|
+
try{
|
|
166
|
+
if(!files.length||files.length>10000)throw new Error('Select one folder with at most 10,000 files.');
|
|
167
|
+
let root=null;const mapped=new Map(),names=new Set();
|
|
168
|
+
for(const f of files){
|
|
169
|
+
const parts=f.webkitRelativePath?.split('/');if(!parts||parts.length<2)throw new Error('Directory identity unavailable.');
|
|
170
|
+
const top=parts.shift();if(!top||(root!==null&&top!==root))throw new Error('Select exactly one directory.');root=top;
|
|
171
|
+
const path=core.path(parts.join('/'));if(names.has(path.toLowerCase()))throw new Error('Duplicate selected relative path.');names.add(path.toLowerCase());mapped.set(path,f);
|
|
172
|
+
}
|
|
173
|
+
let matched=0;const lines=[];
|
|
174
|
+
for(const a of r.payload.artifacts.entries){
|
|
175
|
+
const f=mapped.get(a.path);let state='missing';if(f){
|
|
176
|
+
if(f.size!==a.size_bytes)state='size_mismatch';else{const raw=await f.arrayBuffer();if(!valid())return;
|
|
177
|
+
if(raw.byteLength!==a.size_bytes)throw new Error('File changed while reading.');state=await core.hash(raw)===a.sha256?'match':'hash_mismatch';if(!valid())return}
|
|
178
|
+
}
|
|
179
|
+
if(state==='match')matched++;lines.push(a.path+': '+state);
|
|
180
|
+
}
|
|
181
|
+
if(!valid())return;const count=r.payload.artifacts.entries.length;
|
|
182
|
+
r.comparison={state:matched===count?'match':'mismatch',message:`${matched}/${count} evaluated files match this selection. ${lines.join('; ')}. Unlisted files are not inspected. Past byte comparison only; no whole-task certification.`};draw();
|
|
183
|
+
}catch(e){if(valid()){r.comparison={state:'unavailable',message:'Comparison not completed: '+e.message};draw()}}
|
|
184
|
+
}
|
|
185
|
+
function ensure(){
|
|
186
|
+
if(dialog)return;dialog=make('dialog');dialog.id='execweave-controlled-dialog';dialog.setAttribute('aria-labelledby','execweave-controlled-title');
|
|
187
|
+
const head=make('header'),title=make('h2','Signed fixed-check executions');title.id='execweave-controlled-title';head.append(title,button('Close signed checks',close));
|
|
188
|
+
const intro=make('p','Run python -m execweave.controlled_checks --help on a trusted verifier host. These are built-in byte predicates, not imported JUnit or arbitrary program tests. Never obtain trust solely from the result you are checking.');
|
|
189
|
+
trustPicker=make('input');trustPicker.type='file';trustPicker.accept='.json';trustPicker.id='execweave-controlled-profile';trustPicker.setAttribute('aria-label','Select independently trusted verifier profile');
|
|
190
|
+
trustInfo=make('p','No verifier key is trusted in this tab.');trustInfo.id='execweave-controlled-profile-info';
|
|
191
|
+
confirm=make('input');confirm.type='checkbox';confirm.id='execweave-controlled-trust-confirm';
|
|
192
|
+
const label=make('label');label.append(confirm,document.createTextNode(' I independently trust this verifier key and approved policy fingerprint.'));
|
|
193
|
+
receiptPicker=make('input');receiptPicker.type='file';receiptPicker.accept='.json';receiptPicker.id='execweave-controlled-receipt';receiptPicker.setAttribute('aria-label','Select signed check receipt');
|
|
194
|
+
status=make('p');status.id='execweave-controlled-status';status.setAttribute('role','status');body=make('div');body.id='execweave-controlled-results';
|
|
195
|
+
trustPicker.onchange=async()=>{
|
|
196
|
+
reconcile();clearTrust();draw();const token=generation,start=scope();status.textContent='Checking the separately selected verifier profile…';
|
|
197
|
+
try{const p=await core.profile(await inputJSON(trustPicker.files?.[0],128*1024));
|
|
198
|
+
if(token!==generation||start!==scope()||!dialog.open)return;proposed=p;
|
|
199
|
+
trustInfo.textContent=`${p.label} · public key SHA-256 ${p.key_id} · approved policy SHA-256 ${p.policy_sha256}`;
|
|
200
|
+
status.textContent='Profile loaded but not trusted. Compare its fingerprints through a separate trusted channel, then confirm.';
|
|
201
|
+
}catch(e){if(token===generation&&start===scope()&&dialog.open)status.textContent='Profile not accepted: '+e.message}
|
|
202
|
+
};
|
|
203
|
+
confirm.onchange=()=>{generation++;records.clear();trusted=confirm.checked&&proposed?proposed:null;if(!trusted)confirm.checked=false;status.textContent=trusted?'Verifier profile explicitly trusted in this tab. Select a signed result.':'No verifier profile approved.';draw()};
|
|
204
|
+
receiptPicker.onchange=async()=>{
|
|
205
|
+
reconcile();const token=++generation,start=scope(),pin=trusted;status.textContent='Verifying signature, approved policy, exact task and executed checks…';
|
|
206
|
+
try{
|
|
207
|
+
if(!pin)throw new Error('An independently selected and confirmed verifier profile is required.');
|
|
208
|
+
const value=await inputJSON(receiptPicker.files?.[0],2*1024*1024),r=await core.verify(value,pin);
|
|
209
|
+
if(token!==generation||start!==scope()||trusted!==pin||!dialog.open)return;
|
|
210
|
+
if(!target(r.payload))throw new Error('Receipt is not bound to the current exact task snapshot.');
|
|
211
|
+
if(!records.has(r.receipt_hash)&&records.size>=5)throw new Error('Five-result limit reached; clear results first.');
|
|
212
|
+
records.set(r.receipt_hash,r);status.textContent='Signed execution accepted under the pinned key and policy. Only the specified checks are authenticated; the whole task is not certified.';draw();mount();
|
|
213
|
+
}catch(e){if(token===generation&&start===scope()&&dialog.open)status.textContent='Signed execution not accepted: '+e.message}
|
|
214
|
+
};
|
|
215
|
+
dialog.append(head,intro,trustPicker,trustInfo,label,make('p','Choose the result separately. Keys embedded in a result cannot establish trust.'),receiptPicker,
|
|
216
|
+
button('Forget verifier and signed results',()=>{clearTrust();status.textContent='Verifier trust and results cleared.';draw();mount()}),status,body);
|
|
217
|
+
dialog.addEventListener('keydown',e=>{if(e.key==='Escape')e.stopPropagation()});dialog.addEventListener('cancel',e=>{e.preventDefault();close()});document.body.append(dialog);
|
|
218
|
+
}
|
|
219
|
+
function open(){reconcile();ensure();invoker=document.activeElement;status.textContent=trusted?'Select a signed execution for the trusted policy.':'Select and independently confirm a verifier profile first.';dialog.showModal();draw()}
|
|
220
|
+
function mount(){reconcile();const host=document.querySelector('#execweave-run-assessment [data-axis="task"]');if(!host)return;
|
|
221
|
+
if(!entry?.isConnected||entry.parentElement!==host){entry?.remove();entry=make('div');entry.id='execweave-controlled-entry';entry.append(button('Review signed fixed checks',open));host.append(entry)}
|
|
222
|
+
}
|
|
223
|
+
const prior=window.__execweaveDashboard||{};
|
|
224
|
+
function changed(packet){reconcile();const a=packet?.run_assessment||packet?.graph?.run_assessment;if(a)latest=a;reconcile();mount();draw()}
|
|
225
|
+
window.__execweaveDashboard={...prior,onPayload(...a){prior.onPayload?.(...a);changed(a[0])},onFinished(...a){prior.onFinished?.(...a);changed()}};
|
|
226
|
+
window.addEventListener('pagehide',()=>{clearTrust();latest=null;dialog?.close()});
|
|
227
|
+
window.__execweaveControlledChecks={open,close};mount();
|
|
228
|
+
})();
|
|
229
|
+
""".strip()
|
|
230
|
+
|
|
231
|
+
CONTROLLED_CSS = """
|
|
232
|
+
#execweave-controlled-entry button{font:inherit;padding:6px;cursor:pointer}
|
|
233
|
+
#execweave-controlled-dialog{width:min(980px,94vw);max-height:88vh;box-sizing:border-box;background:var(--panel,#fff);color:var(--text,#111);border:1px solid var(--border,#888);border-radius:10px;padding:16px}
|
|
234
|
+
#execweave-controlled-dialog::backdrop{background:rgba(0,0,0,.45)}
|
|
235
|
+
#execweave-controlled-dialog header{display:flex;align-items:center;gap:10px}#execweave-controlled-title{flex:1;font-size:20px}
|
|
236
|
+
#execweave-controlled-dialog p,#execweave-controlled-dialog label{font-size:14px;line-height:1.5;overflow-wrap:anywhere}
|
|
237
|
+
#execweave-controlled-dialog input,#execweave-controlled-dialog button{font:inherit;padding:6px}
|
|
238
|
+
#execweave-controlled-dialog pre{white-space:pre-wrap;overflow-wrap:anywhere;font-size:12px}
|
|
239
|
+
#execweave-controlled-results{max-height:44vh;overflow:auto}.execweave-controlled-result{border:1px solid var(--border,#888);border-radius:8px;padding:12px;margin-top:12px}
|
|
240
|
+
""".strip()
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def inject_controlled_checks(html: str) -> str:
|
|
244
|
+
if 'id="execweave-controlled-script"' in html:
|
|
245
|
+
return html
|
|
246
|
+
if "</body>" not in html:
|
|
247
|
+
raise RuntimeError("signed checks require the shared Dashboard body")
|
|
248
|
+
return html.replace(
|
|
249
|
+
"</body>",
|
|
250
|
+
"<style>"
|
|
251
|
+
+ CONTROLLED_CSS
|
|
252
|
+
+ '</style><script id="execweave-controlled-script">'
|
|
253
|
+
+ CONTROLLED_CORE_JS
|
|
254
|
+
+ "\n"
|
|
255
|
+
+ CONTROLLED_VIEW_JS
|
|
256
|
+
+ "</script></body>",
|
|
257
|
+
1,
|
|
258
|
+
)
|