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,338 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from .antigravity_subagent_linkage import validated_transcript_path as _antigravity_transcript_path
|
|
7
|
+
from .agent_topology import (
|
|
8
|
+
EVIDENCE_ROLLOUT_SESSION_META,
|
|
9
|
+
EVIDENCE_VALIDATED_CHILD_TRANSCRIPT,
|
|
10
|
+
root_topology,
|
|
11
|
+
subagent_topology,
|
|
12
|
+
)
|
|
13
|
+
from .codex_conversation import codex_transcript_observed_field, validated_codex_transcript
|
|
14
|
+
from .content_evidence import content_observation_event
|
|
15
|
+
from .content_store import FullFidelityContentStore
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _entity(
|
|
19
|
+
entity_type: str,
|
|
20
|
+
entity_id: str,
|
|
21
|
+
*,
|
|
22
|
+
name: str | None = None,
|
|
23
|
+
attributes: dict[str, Any] | None = None,
|
|
24
|
+
) -> dict[str, Any]:
|
|
25
|
+
return {
|
|
26
|
+
"type": entity_type,
|
|
27
|
+
"id": entity_id,
|
|
28
|
+
"name": name,
|
|
29
|
+
"attributes": attributes or {},
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _canonical_absolute_path(value: object) -> Path | None:
|
|
34
|
+
if not isinstance(value, str) or not value:
|
|
35
|
+
return None
|
|
36
|
+
try:
|
|
37
|
+
path = Path(value).expanduser()
|
|
38
|
+
if not path.is_absolute():
|
|
39
|
+
return None
|
|
40
|
+
return path.resolve(strict=False)
|
|
41
|
+
except (OSError, RuntimeError, ValueError):
|
|
42
|
+
return None
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _claude_main_transcript(payload: dict[str, Any]) -> Path | None:
|
|
46
|
+
session_id = payload.get("session_id")
|
|
47
|
+
if not isinstance(session_id, str) or not session_id:
|
|
48
|
+
return None
|
|
49
|
+
path = _canonical_absolute_path(payload.get("transcript_path"))
|
|
50
|
+
if path is None or path.suffix.lower() != ".jsonl":
|
|
51
|
+
return None
|
|
52
|
+
if path.name != f"{session_id}.jsonl":
|
|
53
|
+
return None
|
|
54
|
+
return path
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _claude_subagent_transcript(payload: dict[str, Any]) -> Path | None:
|
|
58
|
+
parent = _claude_main_transcript(payload)
|
|
59
|
+
agent_id = payload.get("agent_id")
|
|
60
|
+
if parent is None or not isinstance(agent_id, str) or not agent_id:
|
|
61
|
+
return None
|
|
62
|
+
candidate = _canonical_absolute_path(payload.get("agent_transcript_path"))
|
|
63
|
+
if candidate is None:
|
|
64
|
+
return None
|
|
65
|
+
expected = (parent.with_suffix("") / "subagents" / f"agent-{agent_id}.jsonl").resolve(
|
|
66
|
+
strict=False
|
|
67
|
+
)
|
|
68
|
+
return candidate if candidate == expected else None
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _archive(
|
|
72
|
+
*,
|
|
73
|
+
path: Path,
|
|
74
|
+
store: FullFidelityContentStore,
|
|
75
|
+
timestamp: str,
|
|
76
|
+
provider: str,
|
|
77
|
+
source: dict[str, Any],
|
|
78
|
+
content_kind: str,
|
|
79
|
+
observed_field: str,
|
|
80
|
+
attribution: str,
|
|
81
|
+
evidence_source: str,
|
|
82
|
+
attributes: dict[str, Any],
|
|
83
|
+
) -> list[dict[str, Any]]:
|
|
84
|
+
if not path.is_file():
|
|
85
|
+
return []
|
|
86
|
+
try:
|
|
87
|
+
reference = store.put_file(
|
|
88
|
+
path,
|
|
89
|
+
content_kind=content_kind,
|
|
90
|
+
media_type="text/plain; charset=utf-8",
|
|
91
|
+
representation="provider_transcript_jsonl_snapshot",
|
|
92
|
+
)
|
|
93
|
+
except (OSError, RuntimeError, ValueError):
|
|
94
|
+
return []
|
|
95
|
+
return [
|
|
96
|
+
content_observation_event(
|
|
97
|
+
timestamp=timestamp,
|
|
98
|
+
provider=provider,
|
|
99
|
+
source=source,
|
|
100
|
+
reference=reference,
|
|
101
|
+
relation="HAS_CONVERSATION_TRANSCRIPT",
|
|
102
|
+
observed_field=observed_field,
|
|
103
|
+
evidence_source=evidence_source,
|
|
104
|
+
attribution=attribution,
|
|
105
|
+
event_type=f"semantic.{provider}.conversation.transcript.archived",
|
|
106
|
+
attributes={
|
|
107
|
+
"provider_transcript_snapshot": True,
|
|
108
|
+
"external_provider_path_copied_into_run": True,
|
|
109
|
+
"external_provider_path_required_for_later_inspection": False,
|
|
110
|
+
"original_external_path_exposed_on_archive_edge": False,
|
|
111
|
+
**attributes,
|
|
112
|
+
},
|
|
113
|
+
)
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def claude_conversation_archive_events(
|
|
118
|
+
payload: dict[str, Any],
|
|
119
|
+
*,
|
|
120
|
+
store: FullFidelityContentStore,
|
|
121
|
+
timestamp: str,
|
|
122
|
+
) -> list[dict[str, Any]]:
|
|
123
|
+
"""Snapshot provider-declared Claude transcripts into the run after strict path checks."""
|
|
124
|
+
hook = payload.get("hook_event_name")
|
|
125
|
+
session_id = payload.get("session_id")
|
|
126
|
+
if not isinstance(session_id, str) or not session_id:
|
|
127
|
+
return []
|
|
128
|
+
if hook == "SessionEnd":
|
|
129
|
+
path = _claude_main_transcript(payload)
|
|
130
|
+
if path is None:
|
|
131
|
+
return []
|
|
132
|
+
source = _entity(
|
|
133
|
+
"agent",
|
|
134
|
+
"agent:Claude Code",
|
|
135
|
+
name="Claude Code",
|
|
136
|
+
attributes={
|
|
137
|
+
"provider": "claude",
|
|
138
|
+
"session_id": session_id,
|
|
139
|
+
**root_topology(),
|
|
140
|
+
},
|
|
141
|
+
)
|
|
142
|
+
return _archive(
|
|
143
|
+
path=path,
|
|
144
|
+
store=store,
|
|
145
|
+
timestamp=timestamp,
|
|
146
|
+
provider="claude",
|
|
147
|
+
source=source,
|
|
148
|
+
content_kind="claude.conversation_transcript.main",
|
|
149
|
+
observed_field="transcript_path",
|
|
150
|
+
attribution="claude_hook",
|
|
151
|
+
evidence_source="provider_transcript",
|
|
152
|
+
attributes={
|
|
153
|
+
"claude_hook_event_name": hook,
|
|
154
|
+
"provider_session_id_exact": True,
|
|
155
|
+
"transcript_scope": "main_session",
|
|
156
|
+
},
|
|
157
|
+
)
|
|
158
|
+
if hook == "SubagentStop":
|
|
159
|
+
path = _claude_subagent_transcript(payload)
|
|
160
|
+
agent_id = payload.get("agent_id")
|
|
161
|
+
if path is None or not isinstance(agent_id, str) or not agent_id:
|
|
162
|
+
return []
|
|
163
|
+
agent_type = payload.get("agent_type")
|
|
164
|
+
name = agent_type if isinstance(agent_type, str) and agent_type else "Claude subagent"
|
|
165
|
+
source = _entity(
|
|
166
|
+
"agent",
|
|
167
|
+
f"agent:claude:{session_id}:subagent:{agent_id}",
|
|
168
|
+
name=name,
|
|
169
|
+
attributes={
|
|
170
|
+
"provider": "claude",
|
|
171
|
+
"session_id": session_id,
|
|
172
|
+
"agent_id": agent_id,
|
|
173
|
+
"agent_type": name,
|
|
174
|
+
"identity_semantics": "provider_exposed_agent_id",
|
|
175
|
+
**subagent_topology(
|
|
176
|
+
evidence=EVIDENCE_VALIDATED_CHILD_TRANSCRIPT,
|
|
177
|
+
parent_scope_id=session_id,
|
|
178
|
+
),
|
|
179
|
+
},
|
|
180
|
+
)
|
|
181
|
+
return _archive(
|
|
182
|
+
path=path,
|
|
183
|
+
store=store,
|
|
184
|
+
timestamp=timestamp,
|
|
185
|
+
provider="claude",
|
|
186
|
+
source=source,
|
|
187
|
+
content_kind="claude.conversation_transcript.subagent",
|
|
188
|
+
observed_field="agent_transcript_path",
|
|
189
|
+
attribution="claude_hook",
|
|
190
|
+
evidence_source="provider_transcript",
|
|
191
|
+
attributes={
|
|
192
|
+
"claude_hook_event_name": hook,
|
|
193
|
+
"provider_subagent_id_exact": True,
|
|
194
|
+
"transcript_scope": "subagent",
|
|
195
|
+
},
|
|
196
|
+
)
|
|
197
|
+
return []
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def codex_conversation_archive_events(
|
|
201
|
+
payload: dict[str, Any],
|
|
202
|
+
*,
|
|
203
|
+
store: FullFidelityContentStore,
|
|
204
|
+
timestamp: str,
|
|
205
|
+
) -> list[dict[str, Any]]:
|
|
206
|
+
"""Snapshot validated Codex rollout JSONL so later inspection never needs ~/.codex."""
|
|
207
|
+
hook = payload.get("hook_event_name")
|
|
208
|
+
if hook not in {"SubagentStop", "Stop", "SessionEnd"}:
|
|
209
|
+
return []
|
|
210
|
+
session_id = payload.get("session_id")
|
|
211
|
+
if not isinstance(session_id, str) or not session_id:
|
|
212
|
+
return []
|
|
213
|
+
validated = validated_codex_transcript(payload)
|
|
214
|
+
if validated is None:
|
|
215
|
+
return []
|
|
216
|
+
path, identity = validated
|
|
217
|
+
agent_id = payload.get("agent_id")
|
|
218
|
+
if hook == "SubagentStop" and isinstance(agent_id, str) and agent_id:
|
|
219
|
+
agent_path = identity.get("agent_path")
|
|
220
|
+
nickname = identity.get("agent_nickname")
|
|
221
|
+
agent_type = payload.get("agent_type")
|
|
222
|
+
name = next(
|
|
223
|
+
(
|
|
224
|
+
value
|
|
225
|
+
for value in (agent_path, nickname, agent_type, "Codex subagent")
|
|
226
|
+
if isinstance(value, str) and value
|
|
227
|
+
),
|
|
228
|
+
"Codex subagent",
|
|
229
|
+
)
|
|
230
|
+
source = _entity(
|
|
231
|
+
"agent",
|
|
232
|
+
f"agent:codex:{session_id}:subagent:{agent_id}",
|
|
233
|
+
name=name,
|
|
234
|
+
attributes={
|
|
235
|
+
"provider": "codex",
|
|
236
|
+
"session_id": session_id,
|
|
237
|
+
"agent_id": agent_id,
|
|
238
|
+
"agent_type": agent_type,
|
|
239
|
+
"agent_nickname": nickname,
|
|
240
|
+
"parent_thread_id": identity.get("parent_thread_id"),
|
|
241
|
+
"identity_semantics": "provider_rollout_session_meta",
|
|
242
|
+
**subagent_topology(
|
|
243
|
+
evidence=EVIDENCE_ROLLOUT_SESSION_META,
|
|
244
|
+
parent_scope_id=session_id,
|
|
245
|
+
agent_path=agent_path if isinstance(agent_path, str) else None,
|
|
246
|
+
),
|
|
247
|
+
},
|
|
248
|
+
)
|
|
249
|
+
return _archive(
|
|
250
|
+
path=path,
|
|
251
|
+
store=store,
|
|
252
|
+
timestamp=timestamp,
|
|
253
|
+
provider="codex",
|
|
254
|
+
source=source,
|
|
255
|
+
content_kind="codex.conversation_transcript.subagent",
|
|
256
|
+
observed_field=codex_transcript_observed_field(payload) or "agent_transcript_path",
|
|
257
|
+
attribution="codex_hook_plus_rollout",
|
|
258
|
+
evidence_source="provider_hook_plus_validated_transcript",
|
|
259
|
+
attributes={
|
|
260
|
+
"codex_hook_event_name": hook,
|
|
261
|
+
"provider_subagent_id_exact": True,
|
|
262
|
+
"provider_rollout_thread_id_exact": True,
|
|
263
|
+
"transcript_scope": "subagent",
|
|
264
|
+
},
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
if isinstance(agent_id, str) and agent_id:
|
|
268
|
+
return []
|
|
269
|
+
source = _entity(
|
|
270
|
+
"agent",
|
|
271
|
+
"agent:OpenAI Codex",
|
|
272
|
+
name="OpenAI Codex",
|
|
273
|
+
attributes={
|
|
274
|
+
"provider": "codex",
|
|
275
|
+
"session_id": session_id,
|
|
276
|
+
"thread_id": identity.get("thread_id"),
|
|
277
|
+
"identity_semantics": "provider_rollout_session_meta",
|
|
278
|
+
**root_topology(evidence=EVIDENCE_ROLLOUT_SESSION_META),
|
|
279
|
+
},
|
|
280
|
+
)
|
|
281
|
+
return _archive(
|
|
282
|
+
path=path,
|
|
283
|
+
store=store,
|
|
284
|
+
timestamp=timestamp,
|
|
285
|
+
provider="codex",
|
|
286
|
+
source=source,
|
|
287
|
+
content_kind="codex.conversation_transcript.main",
|
|
288
|
+
observed_field="transcript_path",
|
|
289
|
+
attribution="codex_hook_plus_rollout",
|
|
290
|
+
evidence_source="provider_hook_plus_validated_transcript",
|
|
291
|
+
attributes={
|
|
292
|
+
"codex_hook_event_name": hook,
|
|
293
|
+
"provider_session_id_exact": True,
|
|
294
|
+
"provider_rollout_thread_id_exact": True,
|
|
295
|
+
"transcript_scope": "main_session",
|
|
296
|
+
},
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def antigravity_conversation_archive_events(
|
|
301
|
+
payload: dict[str, Any],
|
|
302
|
+
*,
|
|
303
|
+
store: FullFidelityContentStore,
|
|
304
|
+
timestamp: str,
|
|
305
|
+
) -> list[dict[str, Any]]:
|
|
306
|
+
"""Snapshot only a validated Antigravity brain transcript supplied by a hook."""
|
|
307
|
+
conversation_id = payload.get("conversationId")
|
|
308
|
+
if not isinstance(conversation_id, str) or not conversation_id:
|
|
309
|
+
return []
|
|
310
|
+
path = _antigravity_transcript_path(payload)
|
|
311
|
+
if path is None:
|
|
312
|
+
return []
|
|
313
|
+
source = _entity(
|
|
314
|
+
"agent",
|
|
315
|
+
f"agent:antigravity:conversation:{conversation_id}",
|
|
316
|
+
name="Antigravity conversation",
|
|
317
|
+
attributes={
|
|
318
|
+
"provider": "antigravity",
|
|
319
|
+
"conversation_id": conversation_id,
|
|
320
|
+
"identity_semantics": "provider_conversation_id",
|
|
321
|
+
},
|
|
322
|
+
)
|
|
323
|
+
return _archive(
|
|
324
|
+
path=path,
|
|
325
|
+
store=store,
|
|
326
|
+
timestamp=timestamp,
|
|
327
|
+
provider="antigravity",
|
|
328
|
+
source=source,
|
|
329
|
+
content_kind="antigravity.conversation_transcript",
|
|
330
|
+
observed_field="transcriptPath",
|
|
331
|
+
attribution="antigravity_hook",
|
|
332
|
+
evidence_source="provider_hook_plus_validated_transcript",
|
|
333
|
+
attributes={
|
|
334
|
+
"provider_conversation_id_exact": True,
|
|
335
|
+
"transcript_scope": "conversation",
|
|
336
|
+
"transcript_wire_semantics": "live_verified_implementation_wire",
|
|
337
|
+
},
|
|
338
|
+
)
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from datetime import datetime, timezone
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
_LOGICAL_MESSAGE_WINDOW_SECONDS = 5.0
|
|
7
|
+
_SURFACE_PRIORITY = {
|
|
8
|
+
"owner_provider_transcript": 0,
|
|
9
|
+
"parent_routing_transcript": 1,
|
|
10
|
+
"hook_supplied_content": 2,
|
|
11
|
+
"other_provider_evidence": 9,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _surface(entry: dict[str, Any], preview: dict[str, Any]) -> str:
|
|
16
|
+
content_kind = str(entry.get("content_kind") or "").lower()
|
|
17
|
+
if content_kind.startswith("codex.conversation_transcript"):
|
|
18
|
+
if (
|
|
19
|
+
preview.get("conversation_completeness") == "routing_only"
|
|
20
|
+
or preview.get("evidence_scope") == "cross_agent_routing"
|
|
21
|
+
):
|
|
22
|
+
return "parent_routing_transcript"
|
|
23
|
+
return "owner_provider_transcript"
|
|
24
|
+
if content_kind.startswith("codex."):
|
|
25
|
+
return "hook_supplied_content"
|
|
26
|
+
return "other_provider_evidence"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _exact_key(message: dict[str, Any]) -> tuple[object, ...]:
|
|
30
|
+
return (
|
|
31
|
+
message.get("ordinal"),
|
|
32
|
+
message.get("kind"),
|
|
33
|
+
message.get("sender"),
|
|
34
|
+
message.get("recipient"),
|
|
35
|
+
message.get("text"),
|
|
36
|
+
message.get("content_state"),
|
|
37
|
+
message.get("phase"),
|
|
38
|
+
message.get("task_name"),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _sort_key(message: dict[str, Any], index: int, *, cross_source: bool) -> tuple[object, ...]:
|
|
43
|
+
ordinal = message.get("ordinal")
|
|
44
|
+
timestamp = message.get("timestamp")
|
|
45
|
+
if cross_source:
|
|
46
|
+
return (
|
|
47
|
+
0 if isinstance(timestamp, str) and timestamp else 1,
|
|
48
|
+
str(timestamp or ""),
|
|
49
|
+
ordinal if isinstance(ordinal, int) else 2**63 - 1,
|
|
50
|
+
index,
|
|
51
|
+
)
|
|
52
|
+
return (
|
|
53
|
+
0 if isinstance(ordinal, int) else 1,
|
|
54
|
+
ordinal if isinstance(ordinal, int) else 2**63 - 1,
|
|
55
|
+
str(timestamp or ""),
|
|
56
|
+
index,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _logical_key(message: dict[str, Any]) -> tuple[object, ...] | None:
|
|
61
|
+
text = message.get("text")
|
|
62
|
+
if (
|
|
63
|
+
message.get("content_state") != "plaintext"
|
|
64
|
+
or not isinstance(text, str)
|
|
65
|
+
or not text
|
|
66
|
+
):
|
|
67
|
+
return None
|
|
68
|
+
kind = str(message.get("kind") or "").lower()
|
|
69
|
+
phase = str(message.get("phase") or "").lower()
|
|
70
|
+
if kind == "user_message" and message.get("sender") == "user":
|
|
71
|
+
semantic_kind = "user_message"
|
|
72
|
+
elif phase == "final_answer" or kind in {"subagent_final_response", "final_answer"}:
|
|
73
|
+
semantic_kind = "final_answer"
|
|
74
|
+
else:
|
|
75
|
+
return None
|
|
76
|
+
return (
|
|
77
|
+
semantic_kind,
|
|
78
|
+
message.get("sender"),
|
|
79
|
+
message.get("recipient"),
|
|
80
|
+
text,
|
|
81
|
+
message.get("content_state"),
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _timestamp_seconds(value: object) -> float | None:
|
|
86
|
+
if not isinstance(value, str) or not value:
|
|
87
|
+
return None
|
|
88
|
+
try:
|
|
89
|
+
parsed = datetime.fromisoformat(value.replace("Z", "+00:00"))
|
|
90
|
+
except ValueError:
|
|
91
|
+
return None
|
|
92
|
+
if parsed.tzinfo is None:
|
|
93
|
+
parsed = parsed.replace(tzinfo=timezone.utc)
|
|
94
|
+
return parsed.timestamp()
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _observation(
|
|
98
|
+
entry: dict[str, Any],
|
|
99
|
+
preview: dict[str, Any],
|
|
100
|
+
message: dict[str, Any],
|
|
101
|
+
) -> dict[str, Any]:
|
|
102
|
+
return {
|
|
103
|
+
"surface": _surface(entry, preview),
|
|
104
|
+
"content_kind": entry.get("content_kind"),
|
|
105
|
+
"relation": entry.get("relation"),
|
|
106
|
+
"source_id": entry.get("source_id"),
|
|
107
|
+
"sha256": entry.get("sha256"),
|
|
108
|
+
"timestamp": message.get("timestamp"),
|
|
109
|
+
"ordinal": message.get("ordinal"),
|
|
110
|
+
"kind": message.get("kind"),
|
|
111
|
+
"phase": message.get("phase"),
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def _observation_key(observation: dict[str, Any]) -> tuple[object, ...]:
|
|
116
|
+
return tuple(
|
|
117
|
+
observation.get(field)
|
|
118
|
+
for field in (
|
|
119
|
+
"surface",
|
|
120
|
+
"content_kind",
|
|
121
|
+
"relation",
|
|
122
|
+
"source_id",
|
|
123
|
+
"sha256",
|
|
124
|
+
"timestamp",
|
|
125
|
+
"ordinal",
|
|
126
|
+
"kind",
|
|
127
|
+
"phase",
|
|
128
|
+
)
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def _dedupe_observations(observations: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
|
133
|
+
seen: set[tuple[object, ...]] = set()
|
|
134
|
+
result: list[dict[str, Any]] = []
|
|
135
|
+
for observation in observations:
|
|
136
|
+
key = _observation_key(observation)
|
|
137
|
+
if key in seen:
|
|
138
|
+
continue
|
|
139
|
+
seen.add(key)
|
|
140
|
+
result.append(observation)
|
|
141
|
+
return result
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def dedupe_codex_message_observations(
|
|
145
|
+
observed: list[tuple[dict[str, Any], dict[str, Any], dict[str, Any]]],
|
|
146
|
+
*,
|
|
147
|
+
cross_source: bool,
|
|
148
|
+
) -> list[dict[str, Any]]:
|
|
149
|
+
"""Collapse duplicate *observations* of one Codex logical message.
|
|
150
|
+
|
|
151
|
+
Raw content/evidence entries stay untouched. This only affects the visible timeline.
|
|
152
|
+
A collapse requires exact plaintext semantics plus complementary evidence surfaces
|
|
153
|
+
close in time. Two observations from the same surface never collapse merely because
|
|
154
|
+
their text matches, so a user or agent can legitimately repeat an identical message.
|
|
155
|
+
"""
|
|
156
|
+
if not observed:
|
|
157
|
+
return []
|
|
158
|
+
|
|
159
|
+
ordered = list(enumerate(observed))
|
|
160
|
+
ordered.sort(key=lambda pair: _sort_key(pair[1][0], pair[0], cross_source=cross_source))
|
|
161
|
+
|
|
162
|
+
# Preserve the old exact-observation dedupe first, but retain provenance when the
|
|
163
|
+
# exact same observation is carried by more than one stored evidence record.
|
|
164
|
+
items: list[dict[str, Any]] = []
|
|
165
|
+
exact_seen: dict[tuple[object, ...], int] = {}
|
|
166
|
+
for _original_index, (message, entry, preview) in ordered:
|
|
167
|
+
copied = dict(message)
|
|
168
|
+
observation = _observation(entry, preview, copied)
|
|
169
|
+
exact = _exact_key(copied)
|
|
170
|
+
existing = exact_seen.get(exact)
|
|
171
|
+
if existing is not None:
|
|
172
|
+
items[existing]["observations"].append(observation)
|
|
173
|
+
continue
|
|
174
|
+
exact_seen[exact] = len(items)
|
|
175
|
+
items.append(
|
|
176
|
+
{
|
|
177
|
+
"message": copied,
|
|
178
|
+
"surface": observation["surface"],
|
|
179
|
+
"priority": _SURFACE_PRIORITY.get(str(observation["surface"]), 9),
|
|
180
|
+
"time": _timestamp_seconds(copied.get("timestamp")),
|
|
181
|
+
"logical_key": _logical_key(copied),
|
|
182
|
+
"observations": [observation],
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
buckets: dict[tuple[object, ...], list[int]] = {}
|
|
187
|
+
passthrough: list[int] = []
|
|
188
|
+
for index, item in enumerate(items):
|
|
189
|
+
key = item["logical_key"]
|
|
190
|
+
if key is None:
|
|
191
|
+
passthrough.append(index)
|
|
192
|
+
else:
|
|
193
|
+
buckets.setdefault(key, []).append(index)
|
|
194
|
+
|
|
195
|
+
grouped: list[list[int]] = [[index] for index in passthrough]
|
|
196
|
+
for indices in buckets.values():
|
|
197
|
+
remaining = set(indices)
|
|
198
|
+
while remaining:
|
|
199
|
+
minimum_priority = min(int(items[index]["priority"]) for index in remaining)
|
|
200
|
+
anchors = sorted(
|
|
201
|
+
index for index in remaining if int(items[index]["priority"]) == minimum_priority
|
|
202
|
+
)
|
|
203
|
+
anchor_groups: dict[int, list[int]] = {index: [index] for index in anchors}
|
|
204
|
+
anchor_surface = str(items[anchors[0]]["surface"])
|
|
205
|
+
|
|
206
|
+
for surface in sorted(
|
|
207
|
+
{
|
|
208
|
+
str(items[index]["surface"])
|
|
209
|
+
for index in remaining
|
|
210
|
+
if str(items[index]["surface"]) != anchor_surface
|
|
211
|
+
},
|
|
212
|
+
key=lambda value: (_SURFACE_PRIORITY.get(value, 9), value),
|
|
213
|
+
):
|
|
214
|
+
candidates = [index for index in remaining if str(items[index]["surface"]) == surface]
|
|
215
|
+
pairs: list[tuple[float, int, int]] = []
|
|
216
|
+
for anchor in anchors:
|
|
217
|
+
anchor_time = items[anchor]["time"]
|
|
218
|
+
if not isinstance(anchor_time, float):
|
|
219
|
+
continue
|
|
220
|
+
for candidate in candidates:
|
|
221
|
+
candidate_time = items[candidate]["time"]
|
|
222
|
+
if not isinstance(candidate_time, float):
|
|
223
|
+
continue
|
|
224
|
+
distance = abs(anchor_time - candidate_time)
|
|
225
|
+
if distance <= _LOGICAL_MESSAGE_WINDOW_SECONDS:
|
|
226
|
+
pairs.append((distance, anchor, candidate))
|
|
227
|
+
pairs.sort()
|
|
228
|
+
used_anchors: set[int] = set()
|
|
229
|
+
used_candidates: set[int] = set()
|
|
230
|
+
for _distance, anchor, candidate in pairs:
|
|
231
|
+
if anchor in used_anchors or candidate in used_candidates:
|
|
232
|
+
continue
|
|
233
|
+
anchor_groups[anchor].append(candidate)
|
|
234
|
+
used_anchors.add(anchor)
|
|
235
|
+
used_candidates.add(candidate)
|
|
236
|
+
|
|
237
|
+
consumed = {index for group in anchor_groups.values() for index in group}
|
|
238
|
+
grouped.extend(anchor_groups.values())
|
|
239
|
+
remaining.difference_update(consumed)
|
|
240
|
+
|
|
241
|
+
logical_messages: list[tuple[dict[str, Any], int]] = []
|
|
242
|
+
for group in grouped:
|
|
243
|
+
anchor = min(
|
|
244
|
+
group,
|
|
245
|
+
key=lambda index: (
|
|
246
|
+
int(items[index]["priority"]),
|
|
247
|
+
str(items[index]["message"].get("timestamp") or ""),
|
|
248
|
+
index,
|
|
249
|
+
),
|
|
250
|
+
)
|
|
251
|
+
message = dict(items[anchor]["message"])
|
|
252
|
+
evidence: list[dict[str, Any]] = []
|
|
253
|
+
for index in group:
|
|
254
|
+
evidence.extend(items[index]["observations"])
|
|
255
|
+
evidence = _dedupe_observations(evidence)
|
|
256
|
+
if len(evidence) > 1:
|
|
257
|
+
message["evidence_observation_count"] = len(evidence)
|
|
258
|
+
message["evidence_observations"] = evidence
|
|
259
|
+
logical_messages.append((message, min(group)))
|
|
260
|
+
|
|
261
|
+
logical_messages.sort(
|
|
262
|
+
key=lambda pair: _sort_key(pair[0], pair[1], cross_source=cross_source)
|
|
263
|
+
)
|
|
264
|
+
return [message for message, _index in logical_messages]
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from .conversation_preview_antigravity import (
|
|
7
|
+
conversation_preview as _antigravity_conversation_preview,
|
|
8
|
+
)
|
|
9
|
+
from .conversation_preview_claude import conversation_preview as _claude_conversation_preview
|
|
10
|
+
from .conversation_preview_codex import _codex_preview
|
|
11
|
+
from .conversation_preview_codex import conversation_preview as _codex_conversation_preview
|
|
12
|
+
from .conversation_preview_common import ( # noqa: F401
|
|
13
|
+
_ANTIGRAVITY_USER_REQUEST_RE,
|
|
14
|
+
_ASSISTANT_FINAL_KINDS,
|
|
15
|
+
_ASSISTANT_RESPONSE_KINDS,
|
|
16
|
+
_MAX_PREVIEW_MESSAGES,
|
|
17
|
+
_MAX_PREVIEW_TEXT_CHARS,
|
|
18
|
+
_PROVIDER_LABELS,
|
|
19
|
+
_SUBAGENT_SUMMARY_KINDS,
|
|
20
|
+
_SUBAGENT_TASK_KINDS,
|
|
21
|
+
_USER_KINDS,
|
|
22
|
+
_agent_identity,
|
|
23
|
+
_antigravity_user_text,
|
|
24
|
+
_generic_content_messages,
|
|
25
|
+
_line_transcript_messages,
|
|
26
|
+
_message,
|
|
27
|
+
_provider_label,
|
|
28
|
+
_read_value,
|
|
29
|
+
_response_messages,
|
|
30
|
+
_routed_agent_message,
|
|
31
|
+
_source_attributes,
|
|
32
|
+
_structured_messages,
|
|
33
|
+
_text_parts,
|
|
34
|
+
_trim_text,
|
|
35
|
+
finish_transcript_preview,
|
|
36
|
+
)
|
|
37
|
+
from .conversation_preview_generic import conversation_preview as _generic_conversation_preview
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def conversation_preview(
|
|
41
|
+
path: str | Path,
|
|
42
|
+
*,
|
|
43
|
+
content_kind: str,
|
|
44
|
+
provider: str,
|
|
45
|
+
source: dict[str, Any] | None,
|
|
46
|
+
timestamp: object = None,
|
|
47
|
+
ordinal: object = None,
|
|
48
|
+
) -> dict[str, Any] | None:
|
|
49
|
+
"""Project provider-exposed run-local evidence into one dashboard conversation schema."""
|
|
50
|
+
kwargs = {
|
|
51
|
+
"content_kind": content_kind,
|
|
52
|
+
"provider": provider,
|
|
53
|
+
"source": source,
|
|
54
|
+
"timestamp": timestamp,
|
|
55
|
+
"ordinal": ordinal,
|
|
56
|
+
}
|
|
57
|
+
if content_kind.startswith("codex.conversation_transcript"):
|
|
58
|
+
return _codex_conversation_preview(path, **kwargs)
|
|
59
|
+
if content_kind.startswith("claude.conversation_transcript"):
|
|
60
|
+
return _claude_conversation_preview(path, **kwargs)
|
|
61
|
+
if content_kind.startswith("antigravity.conversation_transcript"):
|
|
62
|
+
return _antigravity_conversation_preview(path, **kwargs)
|
|
63
|
+
return _generic_conversation_preview(path, **kwargs)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
__all__ = ["conversation_preview", "_codex_preview"]
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from .conversation_preview_common import (
|
|
7
|
+
_agent_identity,
|
|
8
|
+
_line_transcript_messages,
|
|
9
|
+
finish_transcript_preview,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def conversation_preview(
|
|
14
|
+
path: str | Path,
|
|
15
|
+
*,
|
|
16
|
+
content_kind: str,
|
|
17
|
+
provider: str,
|
|
18
|
+
source: dict[str, Any] | None,
|
|
19
|
+
timestamp: object = None,
|
|
20
|
+
ordinal: object = None,
|
|
21
|
+
) -> dict[str, Any] | None:
|
|
22
|
+
del content_kind
|
|
23
|
+
source_path = Path(path).expanduser().resolve(strict=False)
|
|
24
|
+
identity = _agent_identity(provider, source)
|
|
25
|
+
messages = _line_transcript_messages(
|
|
26
|
+
source_path,
|
|
27
|
+
timestamp=timestamp,
|
|
28
|
+
ordinal=ordinal,
|
|
29
|
+
agent_path=str(identity["agent_path"]),
|
|
30
|
+
antigravity=True,
|
|
31
|
+
)
|
|
32
|
+
return finish_transcript_preview(identity, messages, preserve_history=True)
|