copilot-session-tools 0.19.2__tar.gz → 0.20.0__tar.gz
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.
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/PKG-INFO +1 -1
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/pyproject.toml +1 -1
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/pyproject.toml.orig +1 -1
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/__init__.py +1 -1
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/html_exporter.py +4 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/markdown_exporter.py +47 -2
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/scanner/__init__.py +1 -1
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/scanner/cli.py +178 -15
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/scanner/content.py +11 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/utils.py +60 -3
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/web/templates/session.html +125 -13
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/web/webapp.py +4 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/CHANGELOG.md +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/LICENSE +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/README.md +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/cli.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/content_types.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/database.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/db_retrieval.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/db_schema.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/db_search.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/db_storage.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/py.typed +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/refresh.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/scanner/diff.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/scanner/discovery.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/scanner/git.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/scanner/models.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/scanner/shared.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/scanner/vscode.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/sources.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/transcript_cleanup.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/version_check.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/web/__init__.py +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/web/templates/error.html +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/web/templates/index.html +0 -0
- {copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/web/templates/sources.html +0 -0
|
@@ -13,6 +13,7 @@ from .scanner import ChatSession
|
|
|
13
13
|
from .utils import (
|
|
14
14
|
build_block_metadata,
|
|
15
15
|
build_root_agent_markers,
|
|
16
|
+
compact_agent_label,
|
|
16
17
|
detect_language,
|
|
17
18
|
extract_filename,
|
|
18
19
|
format_timestamp,
|
|
@@ -24,6 +25,7 @@ from .utils import (
|
|
|
24
25
|
strip_ansi,
|
|
25
26
|
truncate_preview,
|
|
26
27
|
urldecode,
|
|
28
|
+
workflow_details,
|
|
27
29
|
)
|
|
28
30
|
from .utils import (
|
|
29
31
|
generate_session_filename as _generate_filename,
|
|
@@ -45,6 +47,8 @@ def _get_jinja_env() -> Environment:
|
|
|
45
47
|
env.filters["strip_ansi"] = strip_ansi
|
|
46
48
|
env.filters["truncate_preview"] = truncate_preview
|
|
47
49
|
env.filters["prettify_json"] = prettify_json
|
|
50
|
+
env.filters["workflow_details"] = workflow_details
|
|
51
|
+
env.filters["compact_agent_label"] = compact_agent_label
|
|
48
52
|
env.globals["detect_language"] = detect_language
|
|
49
53
|
env.globals["highlight_code"] = highlight_code
|
|
50
54
|
env.globals["match_tool_for_block"] = match_tool_for_block
|
|
@@ -26,6 +26,9 @@ from .utils import (
|
|
|
26
26
|
from .utils import (
|
|
27
27
|
urldecode as _urldecode,
|
|
28
28
|
)
|
|
29
|
+
from .utils import (
|
|
30
|
+
workflow_summary as _workflow_summary,
|
|
31
|
+
)
|
|
29
32
|
|
|
30
33
|
|
|
31
34
|
def _format_timestamp(value: str | int | None) -> str:
|
|
@@ -139,6 +142,11 @@ def _format_message_content(
|
|
|
139
142
|
include_thinking: bool = False,
|
|
140
143
|
include_agent_details: bool = True,
|
|
141
144
|
include_tools: bool = True,
|
|
145
|
+
include_system_messages: bool = False,
|
|
146
|
+
include_diffs: bool = False,
|
|
147
|
+
include_tool_inputs: bool = False,
|
|
148
|
+
include_commands: bool = True,
|
|
149
|
+
include_file_changes: bool = True,
|
|
142
150
|
) -> str:
|
|
143
151
|
"""Format message content, optionally including thinking blocks and agent details.
|
|
144
152
|
|
|
@@ -172,8 +180,38 @@ def _format_message_content(
|
|
|
172
180
|
parts.append(f"*🤖 {agent_name} — {status}*")
|
|
173
181
|
continue
|
|
174
182
|
# Full content in a collapsible details block
|
|
175
|
-
agent_content = block.content
|
|
176
|
-
|
|
183
|
+
agent_content = block.content
|
|
184
|
+
if block.child_message:
|
|
185
|
+
child_message = block.child_message
|
|
186
|
+
is_stream = (
|
|
187
|
+
not child_message.content
|
|
188
|
+
and bool(child_message.children)
|
|
189
|
+
and len(child_message.content_blocks) == len(child_message.children)
|
|
190
|
+
and all(part.kind == "subagent" and part.child_message is child for part, child in zip(child_message.content_blocks, child_message.children, strict=True))
|
|
191
|
+
)
|
|
192
|
+
nested_parts = []
|
|
193
|
+
for child in child_message.children if is_stream else [child_message]:
|
|
194
|
+
if child.role == "system" and not include_system_messages:
|
|
195
|
+
continue
|
|
196
|
+
child_content = message_to_markdown(
|
|
197
|
+
child,
|
|
198
|
+
include_thinking=include_thinking,
|
|
199
|
+
include_agent_details=include_agent_details,
|
|
200
|
+
include_tools=include_tools,
|
|
201
|
+
include_system_messages=include_system_messages,
|
|
202
|
+
include_diffs=include_diffs,
|
|
203
|
+
include_tool_inputs=include_tool_inputs,
|
|
204
|
+
include_commands=include_commands,
|
|
205
|
+
include_file_changes=include_file_changes,
|
|
206
|
+
)
|
|
207
|
+
if child_content:
|
|
208
|
+
nested_parts.append(f"**{child.role.title()}:**\n\n{child_content}" if is_stream else child_content)
|
|
209
|
+
agent_content = "\n\n".join(nested_parts)
|
|
210
|
+
agent_content = "\n".join(f"> {line}" if line else ">" for line in agent_content.splitlines())
|
|
211
|
+
parts.append(f"<details>\n<summary>{agent_name} — {status}</summary>\n\n{agent_content}\n\n</details>")
|
|
212
|
+
continue
|
|
213
|
+
elif block.kind == "status" and block.description == "workflow":
|
|
214
|
+
parts.append(_workflow_summary(block.content))
|
|
177
215
|
continue
|
|
178
216
|
elif block.kind == "status" and block.description == "task-complete":
|
|
179
217
|
tc_content = block.content.replace(chr(10), chr(10) + "> ")
|
|
@@ -312,6 +350,7 @@ def session_to_markdown(
|
|
|
312
350
|
include_tools=include_tools,
|
|
313
351
|
include_commands=include_commands,
|
|
314
352
|
include_file_changes=include_file_changes,
|
|
353
|
+
include_system_messages=include_system_messages,
|
|
315
354
|
)
|
|
316
355
|
lines.append(msg_md)
|
|
317
356
|
|
|
@@ -328,6 +367,7 @@ def message_to_markdown(
|
|
|
328
367
|
include_tools: bool = True,
|
|
329
368
|
include_commands: bool = True,
|
|
330
369
|
include_file_changes: bool = True,
|
|
370
|
+
include_system_messages: bool = False,
|
|
331
371
|
) -> str:
|
|
332
372
|
"""Convert a single message to markdown format.
|
|
333
373
|
|
|
@@ -363,6 +403,11 @@ def message_to_markdown(
|
|
|
363
403
|
include_thinking=include_thinking,
|
|
364
404
|
include_agent_details=include_agent_details,
|
|
365
405
|
include_tools=include_tools,
|
|
406
|
+
include_system_messages=include_system_messages,
|
|
407
|
+
include_diffs=include_diffs,
|
|
408
|
+
include_tool_inputs=include_tool_inputs,
|
|
409
|
+
include_commands=include_commands,
|
|
410
|
+
include_file_changes=include_file_changes,
|
|
366
411
|
)
|
|
367
412
|
lines.append(content)
|
|
368
413
|
|
|
@@ -216,6 +216,15 @@ def _format_session_event_status(event_type: str, event_data: dict) -> tuple[str
|
|
|
216
216
|
return f"MCP OAuth required: {server}" if server else "MCP OAuth required", "mcp-oauth"
|
|
217
217
|
if event_type == "mcp.oauth_completed":
|
|
218
218
|
return "MCP OAuth completed", "mcp-oauth"
|
|
219
|
+
if event_type == "mcp.oauth_recovery_completed":
|
|
220
|
+
server = _stringify_event_value(event_data.get("serverName"))
|
|
221
|
+
outcome = _stringify_event_value(event_data.get("outcome"))
|
|
222
|
+
return f"MCP OAuth recovery: {server} - {outcome}", "mcp-oauth"
|
|
223
|
+
if event_type == "session.permission_recovery":
|
|
224
|
+
status = _stringify_event_value(event_data.get("status"))
|
|
225
|
+
reason = _stringify_event_value(event_data.get("reason"))
|
|
226
|
+
label = f"Permission recovery: {status}"
|
|
227
|
+
return f"{label} - {reason}" if reason else label, "permission"
|
|
219
228
|
if event_type == "model.call_failure":
|
|
220
229
|
source = _stringify_event_value(event_data.get("source"))
|
|
221
230
|
error = _stringify_event_value(event_data.get("error") or event_data.get("message"))
|
|
@@ -246,6 +255,9 @@ def _format_session_event_status(event_type: str, event_data: dict) -> tuple[str
|
|
|
246
255
|
details = " ".join(part for part in (operation, path) if part)
|
|
247
256
|
return f"Workspace file changed: {details}" if details else "Workspace file changed", "workspace-file"
|
|
248
257
|
if event_type == "system.notification":
|
|
258
|
+
notification = event_data.get("kind")
|
|
259
|
+
if isinstance(notification, dict) and notification.get("type") == "workflow_completed":
|
|
260
|
+
return ssrjson.dumps(notification), "workflow"
|
|
249
261
|
content = _stringify_event_value(event_data.get("content"))
|
|
250
262
|
kind = _stringify_event_value(event_data.get("kind"))
|
|
251
263
|
if content:
|
|
@@ -260,6 +272,97 @@ def _format_session_event_status(event_type: str, event_data: dict) -> tuple[str
|
|
|
260
272
|
return None
|
|
261
273
|
|
|
262
274
|
|
|
275
|
+
def _format_human_response(response: dict) -> tuple[str, str] | None:
|
|
276
|
+
kind = response.get("responseKind")
|
|
277
|
+
if kind == "exit_plan_mode":
|
|
278
|
+
approved = response.get("approved")
|
|
279
|
+
decision = "approved" if approved is True else "rejected" if approved is False else "reviewed (decision unavailable)"
|
|
280
|
+
parts = [f"Plan {decision}"]
|
|
281
|
+
action = _stringify_event_value(response.get("selectedAction"))
|
|
282
|
+
if decision == "approved" and action:
|
|
283
|
+
parts[0] += f": {action}"
|
|
284
|
+
for key in ("summary", "planContent", "feedback"):
|
|
285
|
+
text = _stringify_event_value(response.get(key))
|
|
286
|
+
if text:
|
|
287
|
+
parts.append(f"Feedback: {text}" if key == "feedback" else text)
|
|
288
|
+
return "\n\n".join(parts), "plan-review"
|
|
289
|
+
if kind == "ask_user":
|
|
290
|
+
question = _stringify_event_value(response.get("message"))
|
|
291
|
+
answer = response.get("content")
|
|
292
|
+
if isinstance(answer, dict):
|
|
293
|
+
answer_text = ", ".join(f"{key}={_stringify_event_value(value)}" for key, value in answer.items())
|
|
294
|
+
else:
|
|
295
|
+
answer_text = _stringify_event_value(answer)
|
|
296
|
+
action = _stringify_event_value(response.get("action"))
|
|
297
|
+
outcome = action or answer_text
|
|
298
|
+
elif kind == "user_input":
|
|
299
|
+
question = _stringify_event_value(response.get("question"))
|
|
300
|
+
outcome = "dismissed" if response.get("dismissed") else _stringify_event_value(response.get("answer"))
|
|
301
|
+
else:
|
|
302
|
+
return None
|
|
303
|
+
return f"{question}\n\nResponse: {outcome}" if outcome else question, "user-input"
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
def _read_cli_events(file_path: Path) -> list[dict]:
|
|
307
|
+
"""Read original history across numbered journals, excluding replay checkpoints."""
|
|
308
|
+
pieces: list[list[dict]] = []
|
|
309
|
+
current = file_path
|
|
310
|
+
session_id: str | None = None
|
|
311
|
+
previous_number: int | None = None
|
|
312
|
+
while True:
|
|
313
|
+
records: list[dict] = []
|
|
314
|
+
line = ""
|
|
315
|
+
filename = ""
|
|
316
|
+
with current.open(encoding="utf-8") as stream:
|
|
317
|
+
for line in stream:
|
|
318
|
+
if not line.strip():
|
|
319
|
+
continue
|
|
320
|
+
try:
|
|
321
|
+
event = ssrjson.loads(line)
|
|
322
|
+
except ssrjson.JSONDecodeError:
|
|
323
|
+
if current != file_path:
|
|
324
|
+
raise ValueError("Invalid historical journal record") from None
|
|
325
|
+
continue
|
|
326
|
+
if isinstance(event, dict):
|
|
327
|
+
records.append(event)
|
|
328
|
+
if current != file_path and (not records or not line.endswith("\n")):
|
|
329
|
+
raise ValueError("Incomplete historical journal")
|
|
330
|
+
if not records:
|
|
331
|
+
return []
|
|
332
|
+
link = records[0] if records[0].get("type") == "session.journal_link" else None
|
|
333
|
+
if any(event.get("type") == "session.journal_link" for event in records[1:]):
|
|
334
|
+
raise ValueError("Journal link must be the first record")
|
|
335
|
+
if link:
|
|
336
|
+
data = link.get("data", {})
|
|
337
|
+
owner = data.get("sessionId")
|
|
338
|
+
filename = data.get("previousFile")
|
|
339
|
+
if type(data.get("version")) is not int or data["version"] != 1 or link.get("checkpoint"):
|
|
340
|
+
raise ValueError("Unsupported journal link")
|
|
341
|
+
if not isinstance(owner, str) or not owner or (session_id is not None and owner != session_id):
|
|
342
|
+
raise ValueError("Journal link belongs to another session")
|
|
343
|
+
session_id = owner
|
|
344
|
+
match = re.fullmatch(r"events\.([1-9][0-9]*)\.jsonl", filename) if isinstance(filename, str) else None
|
|
345
|
+
if not match:
|
|
346
|
+
raise ValueError("Invalid predecessor filename")
|
|
347
|
+
number = int(match.group(1))
|
|
348
|
+
if previous_number is not None and number >= previous_number:
|
|
349
|
+
raise ValueError("Journal predecessors must decrease")
|
|
350
|
+
previous_number = number
|
|
351
|
+
for event in records:
|
|
352
|
+
if session_id is not None and event.get("type") in ("session.start", "session.resume"):
|
|
353
|
+
owner = event.get("data", {}).get("sessionId")
|
|
354
|
+
if owner is not None and owner != session_id:
|
|
355
|
+
raise ValueError("Journal records belong to another session")
|
|
356
|
+
pieces.append([event for event in records if event is not link and not event.get("checkpoint")])
|
|
357
|
+
if link is None:
|
|
358
|
+
break
|
|
359
|
+
predecessor = file_path.parent / filename
|
|
360
|
+
if predecessor.resolve().parent != file_path.parent.resolve():
|
|
361
|
+
raise ValueError("Journal predecessor is outside the session directory")
|
|
362
|
+
current = predecessor
|
|
363
|
+
return [event for piece in reversed(pieces) for event in piece]
|
|
364
|
+
|
|
365
|
+
|
|
263
366
|
_FUSION_PHASE_LABELS = {
|
|
264
367
|
"primary": "Drafted answer",
|
|
265
368
|
"draft": "Drafted",
|
|
@@ -735,11 +838,19 @@ class _CliSessionIndex:
|
|
|
735
838
|
bg_agent_results: dict[str, str]
|
|
736
839
|
bg_agent_id_map: dict[str, str]
|
|
737
840
|
agent_display_names: dict[str, str]
|
|
841
|
+
represented_question_tools: set[str]
|
|
842
|
+
represented_question_requests: set[str]
|
|
738
843
|
root_agent_intervals: list[RootAgentInterval]
|
|
739
844
|
updated_at: str | None
|
|
740
845
|
|
|
741
846
|
|
|
742
847
|
def _index_cli_events(events: list[dict]) -> _CliSessionIndex:
|
|
848
|
+
program_events = {
|
|
849
|
+
"program.tool_execution_start": "tool.execution_start",
|
|
850
|
+
"program.tool_execution_complete": "tool.execution_complete",
|
|
851
|
+
"program.permission_requested": "permission.requested",
|
|
852
|
+
}
|
|
853
|
+
events = [{**event, "type": program_events[event["type"]]} if event.get("type") in program_events else event for event in events]
|
|
743
854
|
tool_executions: dict = {}
|
|
744
855
|
root_agent_intervals: list[RootAgentInterval] = []
|
|
745
856
|
active_root_agent: RootAgentInterval | None = None
|
|
@@ -752,6 +863,10 @@ def _index_cli_events(events: list[dict]) -> _CliSessionIndex:
|
|
|
752
863
|
bg_agent_id_map: dict[str, str] = {}
|
|
753
864
|
agent_display_names: dict[str, str] = {}
|
|
754
865
|
metadata_events: dict[str, dict] = {}
|
|
866
|
+
agent_streams: dict[str, str] = {}
|
|
867
|
+
agent_parents: dict[str, str | None] = {}
|
|
868
|
+
represented_question_requests: set[str] = set()
|
|
869
|
+
completed_question_requests: set[str] = set()
|
|
755
870
|
for event in events:
|
|
756
871
|
event_type = event.get("type", "")
|
|
757
872
|
event_data = event.get("data", {})
|
|
@@ -824,6 +939,11 @@ def _index_cli_events(events: list[dict]) -> _CliSessionIndex:
|
|
|
824
939
|
tool_call_id = event_data.get("toolCallId", "")
|
|
825
940
|
if tool_call_id:
|
|
826
941
|
subagent_started_ids.add(tool_call_id)
|
|
942
|
+
agent_streams[tool_call_id] = event.get("agentId") or tool_call_id
|
|
943
|
+
agent_parents[tool_call_id] = event_data.get("parentId")
|
|
944
|
+
display = event_data.get("agentDisplayName") or event_data.get("agentName") or tool_call_id
|
|
945
|
+
agent_display_names[agent_streams[tool_call_id]] = display
|
|
946
|
+
agent_display_names[tool_call_id] = display
|
|
827
947
|
elif event_type == "subagent.completed":
|
|
828
948
|
tool_call_id = event_data.get("toolCallId", "")
|
|
829
949
|
if tool_call_id:
|
|
@@ -847,6 +967,12 @@ def _index_cli_events(events: list[dict]) -> _CliSessionIndex:
|
|
|
847
967
|
active_root_agent.end_timestamp = timestamp
|
|
848
968
|
root_agent_intervals.append(active_root_agent)
|
|
849
969
|
active_root_agent = None
|
|
970
|
+
elif event_type in ("user_input.requested", "elicitation.requested"):
|
|
971
|
+
if event_data.get("requestId") and (event_data.get("question") or event_data.get("message")):
|
|
972
|
+
represented_question_requests.add(event_data["requestId"])
|
|
973
|
+
elif event_type in ("user_input.completed", "elicitation.completed"):
|
|
974
|
+
if event_data.get("requestId") and (event_data.get("answer") or event_data.get("action") or event_data.get("content")):
|
|
975
|
+
completed_question_requests.add(event_data["requestId"])
|
|
850
976
|
if active_root_agent is not None:
|
|
851
977
|
root_agent_intervals.append(active_root_agent)
|
|
852
978
|
for tcid in subagent_started_ids:
|
|
@@ -857,9 +983,20 @@ def _index_cli_events(events: list[dict]) -> _CliSessionIndex:
|
|
|
857
983
|
for event in events:
|
|
858
984
|
owner = event.get("agentId") or None
|
|
859
985
|
if event.get("type") in ("subagent.started", "subagent.completed", "subagent.failed"):
|
|
860
|
-
|
|
861
|
-
|
|
986
|
+
tool_call_id = event.get("data", {}).get("toolCallId")
|
|
987
|
+
execution = tool_executions.get(tool_call_id, {})
|
|
988
|
+
start = execution.get("start")
|
|
989
|
+
parent_id = agent_parents.get(tool_call_id)
|
|
990
|
+
owner = (start.get("agentId") or None) if start else agent_streams.get(parent_id, parent_id) if parent_id else None
|
|
862
991
|
events_by_agent.setdefault(owner, []).append(event)
|
|
992
|
+
represented_question_tools = {
|
|
993
|
+
tool_call_id
|
|
994
|
+
for tool_call_id, execution in tool_executions.items()
|
|
995
|
+
if (start := execution.get("start"))
|
|
996
|
+
and start.get("data", {}).get("toolName") == "ask_user"
|
|
997
|
+
and execution.get("complete")
|
|
998
|
+
and (_as_tool_argument_dict(start.get("data", {}).get("arguments")).get("question") or _as_tool_argument_dict(start.get("data", {}).get("arguments")).get("message"))
|
|
999
|
+
}
|
|
863
1000
|
return _CliSessionIndex(
|
|
864
1001
|
events_by_agent=events_by_agent,
|
|
865
1002
|
metadata_events=list(metadata_events.values()),
|
|
@@ -872,6 +1009,8 @@ def _index_cli_events(events: list[dict]) -> _CliSessionIndex:
|
|
|
872
1009
|
bg_agent_results=bg_agent_results,
|
|
873
1010
|
bg_agent_id_map=bg_agent_id_map,
|
|
874
1011
|
agent_display_names=agent_display_names,
|
|
1012
|
+
represented_question_tools=represented_question_tools,
|
|
1013
|
+
represented_question_requests=represented_question_requests & completed_question_requests,
|
|
875
1014
|
root_agent_intervals=root_agent_intervals,
|
|
876
1015
|
updated_at=events[-1].get("timestamp"),
|
|
877
1016
|
)
|
|
@@ -917,16 +1056,7 @@ def _parse_cli_jsonl_file(
|
|
|
917
1056
|
if _index is None:
|
|
918
1057
|
events = _events
|
|
919
1058
|
if events is None:
|
|
920
|
-
events =
|
|
921
|
-
with file_path.open(encoding="utf-8") as f:
|
|
922
|
-
for line in f:
|
|
923
|
-
line = line.strip()
|
|
924
|
-
if not line:
|
|
925
|
-
continue
|
|
926
|
-
try:
|
|
927
|
-
events.append(ssrjson.loads(line))
|
|
928
|
-
except ssrjson.JSONDecodeError:
|
|
929
|
-
continue
|
|
1059
|
+
events = _read_cli_events(file_path)
|
|
930
1060
|
if not events:
|
|
931
1061
|
return None
|
|
932
1062
|
_index = _index_cli_events(events)
|
|
@@ -1227,6 +1357,9 @@ def _parse_cli_jsonl_file(
|
|
|
1227
1357
|
completed = tool_call_id in builder.subagent_completions
|
|
1228
1358
|
# Title includes status indicator for template
|
|
1229
1359
|
title = f"{display_name}: {description}" if description else display_name
|
|
1360
|
+
workflow_run_id = _stringify_event_value(event_data.get("workflowRunId"))
|
|
1361
|
+
if workflow_run_id:
|
|
1362
|
+
title += f" · workflow {workflow_run_id}"
|
|
1230
1363
|
if failed:
|
|
1231
1364
|
title = f"❌ {title}"
|
|
1232
1365
|
# Build content: child tool summaries + result or error
|
|
@@ -1234,7 +1367,8 @@ def _parse_cli_jsonl_file(
|
|
|
1234
1367
|
for child_display in builder.subagent_child_tools.get(tool_call_id, []):
|
|
1235
1368
|
parts.append(f"*{child_display}*")
|
|
1236
1369
|
# Detect background agent (even for failed ones)
|
|
1237
|
-
|
|
1370
|
+
execution_mode = event_data.get("executionMode")
|
|
1371
|
+
is_bg = execution_mode == "background" or tool_call_id in builder.bg_agent_id_map
|
|
1238
1372
|
bg_id = builder.bg_agent_id_map.get(tool_call_id, "")
|
|
1239
1373
|
result_text = ""
|
|
1240
1374
|
if failed:
|
|
@@ -1253,7 +1387,8 @@ def _parse_cli_jsonl_file(
|
|
|
1253
1387
|
result_text = str(result_obj)
|
|
1254
1388
|
# Background agents return a placeholder — use read_agent result instead
|
|
1255
1389
|
if not result_text or result_text.startswith("Agent started in background"):
|
|
1256
|
-
|
|
1390
|
+
if execution_mode != "sync":
|
|
1391
|
+
is_bg = True
|
|
1257
1392
|
if bg_id:
|
|
1258
1393
|
result_text = builder.bg_agent_results.get(bg_id, "")
|
|
1259
1394
|
else:
|
|
@@ -1327,6 +1462,7 @@ def _parse_cli_jsonl_file(
|
|
|
1327
1462
|
file_changes=nested_consolidated_changes,
|
|
1328
1463
|
)
|
|
1329
1464
|
|
|
1465
|
+
prompt = _get_tool_arg_str(req_args, "prompt")
|
|
1330
1466
|
stream_agent_id = event.get("agentId")
|
|
1331
1467
|
if stream_agent_id and stream_agent_id != _agent_id:
|
|
1332
1468
|
child_session = _parse_cli_jsonl_file(
|
|
@@ -1339,6 +1475,8 @@ def _parse_cli_jsonl_file(
|
|
|
1339
1475
|
logger.error("Failed to parse delegated agent stream %s in %s", stream_agent_id, file_path)
|
|
1340
1476
|
return None
|
|
1341
1477
|
if child_session.messages:
|
|
1478
|
+
if not prompt:
|
|
1479
|
+
prompt = next((message.content for message in child_session.messages if message.role == "user"), "")
|
|
1342
1480
|
child_msg = ChatMessage(
|
|
1343
1481
|
role="assistant",
|
|
1344
1482
|
content="",
|
|
@@ -1363,7 +1501,7 @@ def _parse_cli_jsonl_file(
|
|
|
1363
1501
|
content=content,
|
|
1364
1502
|
description=title,
|
|
1365
1503
|
child_message=child_msg,
|
|
1366
|
-
prompt=
|
|
1504
|
+
prompt=prompt,
|
|
1367
1505
|
is_background=is_bg,
|
|
1368
1506
|
agent_id=stream_agent_id or (bg_id if is_bg else ""),
|
|
1369
1507
|
)
|
|
@@ -1537,9 +1675,25 @@ def _parse_cli_jsonl_file(
|
|
|
1537
1675
|
if answer:
|
|
1538
1676
|
builder.current_assistant_content_blocks.append(ContentBlock(kind="status", content=f"User answered: {answer}", description="user-input"))
|
|
1539
1677
|
|
|
1678
|
+
elif event_type == "human_response.recorded":
|
|
1679
|
+
response = event_data.get("response")
|
|
1680
|
+
if not isinstance(response, dict):
|
|
1681
|
+
continue
|
|
1682
|
+
if response.get("responseKind") != "exit_plan_mode" and (
|
|
1683
|
+
event_data.get("toolCallId") in _index.represented_question_tools or event_data.get("requestId") in _index.represented_question_requests
|
|
1684
|
+
):
|
|
1685
|
+
continue
|
|
1686
|
+
formatted = _format_human_response(response)
|
|
1687
|
+
if formatted:
|
|
1688
|
+
content, description = formatted
|
|
1689
|
+
if content:
|
|
1690
|
+
builder.note_assistant_event(event.get("id"))
|
|
1691
|
+
builder.current_assistant_content_blocks.append(ContentBlock(kind="ask_user", content=content, description=description))
|
|
1692
|
+
|
|
1540
1693
|
elif formatted_status := _format_session_event_status(event_type, event_data):
|
|
1541
1694
|
content, description = formatted_status
|
|
1542
1695
|
if content:
|
|
1696
|
+
builder.note_assistant_event(event.get("id"))
|
|
1543
1697
|
builder.current_assistant_content_blocks.append(ContentBlock(kind="status", content=content, description=description))
|
|
1544
1698
|
|
|
1545
1699
|
# Skip internal/metadata events (already parsed in metadata extraction or no user content)
|
|
@@ -1624,6 +1778,15 @@ def _parse_cli_jsonl_file(
|
|
|
1624
1778
|
"factory.run_started",
|
|
1625
1779
|
"factory.run_updated",
|
|
1626
1780
|
"factory.run_settled",
|
|
1781
|
+
"workflow.run_started",
|
|
1782
|
+
"workflow.run_updated",
|
|
1783
|
+
"workflow.run_settled",
|
|
1784
|
+
"instruction.update",
|
|
1785
|
+
"instruction.update_delivery",
|
|
1786
|
+
"session.mode_notice_delivered",
|
|
1787
|
+
"session.usage_record",
|
|
1788
|
+
"session.tool_outcomes_recorded",
|
|
1789
|
+
"program.execution",
|
|
1627
1790
|
):
|
|
1628
1791
|
pass
|
|
1629
1792
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Content extraction, formatting, and utility helpers for scanner."""
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
|
+
from typing import cast
|
|
4
5
|
|
|
5
6
|
from .models import ChatMessage, ContentBlock
|
|
6
7
|
|
|
@@ -344,6 +345,16 @@ def _format_tool_display_message(
|
|
|
344
345
|
) -> str:
|
|
345
346
|
"""Generate a display message for a tool invocation using data-driven formats."""
|
|
346
347
|
argument_dict: dict[str, object] = {str(key): value for key, value in arguments.items()} if isinstance(arguments, dict) else {}
|
|
348
|
+
if tool_name == "run_dynamic_workflow":
|
|
349
|
+
run_id = argument_dict.get("resumeFromRunId")
|
|
350
|
+
return f"Resuming workflow: {run_id}" if run_id else f"Running workflow: {argument_dict.get('name') or 'unknown'}"
|
|
351
|
+
if tool_name == "dynamic_workflows_manage":
|
|
352
|
+
operation = argument_dict.get("operation") or "list"
|
|
353
|
+
value = argument_dict.get("meta")
|
|
354
|
+
meta = cast("dict[str, object]", value) if isinstance(value, dict) else {}
|
|
355
|
+
name = meta.get("name")
|
|
356
|
+
target = argument_dict.get("runId") or argument_dict.get("name") or name
|
|
357
|
+
return f"Workflows: {operation} {target}" if target else f"Workflows: {operation}"
|
|
347
358
|
fmt = _TOOL_DISPLAY_FORMATS.get(tool_name)
|
|
348
359
|
if fmt:
|
|
349
360
|
template, arg_keys = fmt
|
{copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/utils.py
RENAMED
|
@@ -221,6 +221,58 @@ def prettify_json(text: str | None) -> str:
|
|
|
221
221
|
return text
|
|
222
222
|
|
|
223
223
|
|
|
224
|
+
def workflow_details(text: str) -> dict | None:
|
|
225
|
+
name = None
|
|
226
|
+
payload = text
|
|
227
|
+
match = re.fullmatch(
|
|
228
|
+
r'Workflow "(.*?)" run (\S+) (?:is still \w+\. Do not wait for it to finish\. Current run detail: |has terminal status \w+\. Full run result: )(\{.*\})',
|
|
229
|
+
text,
|
|
230
|
+
re.DOTALL,
|
|
231
|
+
)
|
|
232
|
+
if match:
|
|
233
|
+
name = match[1]
|
|
234
|
+
payload = match[3]
|
|
235
|
+
if not payload.lstrip().startswith("{"):
|
|
236
|
+
return None
|
|
237
|
+
try:
|
|
238
|
+
value = json.loads(payload)
|
|
239
|
+
except (json.JSONDecodeError, RecursionError):
|
|
240
|
+
return None
|
|
241
|
+
if not isinstance(value, dict) or not isinstance(value.get("runId"), str) or not isinstance(value.get("status"), str):
|
|
242
|
+
return None
|
|
243
|
+
if name is None and value.get("type") != "workflow_completed":
|
|
244
|
+
return None
|
|
245
|
+
if match and value["runId"] != match[2]:
|
|
246
|
+
return None
|
|
247
|
+
if name is not None:
|
|
248
|
+
value["workflowName"] = name
|
|
249
|
+
return value
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def workflow_summary(text: str) -> str:
|
|
253
|
+
value = workflow_details(text)
|
|
254
|
+
if value is None:
|
|
255
|
+
return text
|
|
256
|
+
parts = [f"Workflow {value.get('workflowName') or 'unknown'} ({value['runId']}): {value['status']}"]
|
|
257
|
+
if type(value.get("consumedSubagents")) is int:
|
|
258
|
+
parts.append(f"{value['consumedSubagents']} subagents")
|
|
259
|
+
if type(value.get("consumedNanoAiu")) in (int, float):
|
|
260
|
+
parts.append(f"{value['consumedNanoAiu'] / 1_000_000_000:g} AI credits")
|
|
261
|
+
if type(value.get("attempt")) is int:
|
|
262
|
+
parts.append(f"attempt {value['attempt']}")
|
|
263
|
+
if type(value.get("elapsedMs")) in (int, float):
|
|
264
|
+
parts.append(f"{value['elapsedMs'] / 1000:g}s active")
|
|
265
|
+
for key in ("resultPreview", "error", "reason", "retryGuidance"):
|
|
266
|
+
if isinstance(value.get(key), str) and value[key]:
|
|
267
|
+
parts.append(value[key])
|
|
268
|
+
return strip_ansi(" | ".join(parts))
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def compact_agent_label(label: str) -> str:
|
|
272
|
+
shortened = re.sub(r"-([0-9a-f]{24,64})$", lambda match: f" · {match[1][:8]}", label)
|
|
273
|
+
return shortened[:1].upper() + shortened[1:] if shortened != label else label
|
|
274
|
+
|
|
275
|
+
|
|
224
276
|
def detect_language(text: str, tool_name: str | None = None, *, is_output: bool = False) -> str | None:
|
|
225
277
|
"""Heuristically detect the language of *text* for syntax highlighting.
|
|
226
278
|
|
|
@@ -312,6 +364,10 @@ _md_converter = markdown.Markdown(
|
|
|
312
364
|
},
|
|
313
365
|
)
|
|
314
366
|
|
|
367
|
+
_md_literal_html_converter = markdown.Markdown(extensions=["tables", "fenced_code", "sane_lists", "smarty", "nl2br"])
|
|
368
|
+
_md_literal_html_converter.preprocessors.deregister("html_block")
|
|
369
|
+
_md_literal_html_converter.inlinePatterns.deregister("html")
|
|
370
|
+
|
|
315
371
|
|
|
316
372
|
def _extract_filename_from_file_uri(uri: str) -> str:
|
|
317
373
|
"""Extract the leaf filename from a ``file://`` URI."""
|
|
@@ -324,7 +380,7 @@ def _extract_filename_from_file_uri(uri: str) -> str:
|
|
|
324
380
|
return path
|
|
325
381
|
|
|
326
382
|
|
|
327
|
-
def markdown_to_html(text: str) -> str:
|
|
383
|
+
def markdown_to_html(text: str, *, literal_html: bool = False) -> str:
|
|
328
384
|
"""Convert markdown to HTML, normalizing common VS Code Copilot patterns."""
|
|
329
385
|
if not text:
|
|
330
386
|
return ""
|
|
@@ -343,8 +399,9 @@ def markdown_to_html(text: str) -> str:
|
|
|
343
399
|
text = re.sub(r"^((?:Now )?[Ll]et me [^:]+:)$", r"_\1_", text, flags=re.MULTILINE)
|
|
344
400
|
text = re.sub(r"^(Made changes\.)$", r"_\1_", text, flags=re.MULTILINE)
|
|
345
401
|
|
|
346
|
-
_md_converter
|
|
347
|
-
|
|
402
|
+
converter = _md_literal_html_converter if literal_html else _md_converter
|
|
403
|
+
converter.reset()
|
|
404
|
+
return Markup(converter.convert(text)) # noqa: S704 - markdown output is intentionally rendered as HTML
|
|
348
405
|
|
|
349
406
|
|
|
350
407
|
# ---------------------------------------------------------------------------
|
|
@@ -985,6 +985,50 @@ header h1 {
|
|
|
985
985
|
}
|
|
986
986
|
.subagent-prompt-content p { margin: 0 0 4px; }
|
|
987
987
|
|
|
988
|
+
.workflow-run {
|
|
989
|
+
flex-shrink: 0;
|
|
990
|
+
padding: 3px 7px;
|
|
991
|
+
border: 1px solid var(--border-color);
|
|
992
|
+
border-radius: 6px;
|
|
993
|
+
color: var(--text-secondary);
|
|
994
|
+
font-size: 0.72em;
|
|
995
|
+
}
|
|
996
|
+
.subagent-message > summary .subagent-label { color: var(--text-secondary); }
|
|
997
|
+
.diagnostic-block {
|
|
998
|
+
margin: 6px 0;
|
|
999
|
+
color: var(--text-secondary);
|
|
1000
|
+
font-size: 0.8em;
|
|
1001
|
+
}
|
|
1002
|
+
.diagnostic-block > summary { cursor: pointer; }
|
|
1003
|
+
.diagnostic-block pre { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
1004
|
+
.workflow-status {
|
|
1005
|
+
margin: 12px 0;
|
|
1006
|
+
padding: 14px 16px;
|
|
1007
|
+
border: 1px solid var(--border-color);
|
|
1008
|
+
border-left: 3px solid #6366f1;
|
|
1009
|
+
border-radius: 8px;
|
|
1010
|
+
background: var(--bg-secondary);
|
|
1011
|
+
overflow-wrap: anywhere;
|
|
1012
|
+
}
|
|
1013
|
+
.workflow-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
|
|
1014
|
+
.workflow-heading strong { font-size: 1.1em; margin-right: auto; }
|
|
1015
|
+
.workflow-eyebrow { color: var(--text-secondary); font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; }
|
|
1016
|
+
.workflow-metrics { display: flex; flex-wrap: wrap; gap: 20px; margin: 16px 0 0; }
|
|
1017
|
+
.workflow-metrics dt { font-size: 0.75em; color: var(--text-secondary); }
|
|
1018
|
+
.workflow-metrics dd { margin: 2px 0 0; font-weight: 600; }
|
|
1019
|
+
.workflow-description { margin: 14px 0 0; }
|
|
1020
|
+
.workflow-error { border-left: 2px solid #cf222e; padding-left: 12px; }
|
|
1021
|
+
.workflow-agents { margin-top: 16px; width: 100%; font-size: 0.85em; }
|
|
1022
|
+
.workflow-state { margin-top: 14px; }
|
|
1023
|
+
.workflow-state > summary { cursor: pointer; color: var(--text-secondary); font-size: 0.85em; }
|
|
1024
|
+
.workflow-state pre, pre.structured-result { max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
1025
|
+
.workflow-table-scroll { overflow-x: auto; }
|
|
1026
|
+
@media (max-width: 600px) {
|
|
1027
|
+
.subagent-block > summary { flex-wrap: wrap; }
|
|
1028
|
+
.subagent-label { min-width: 120px; white-space: normal; overflow-wrap: anywhere; }
|
|
1029
|
+
.subagent-content { padding: 8px; }
|
|
1030
|
+
}
|
|
1031
|
+
|
|
988
1032
|
@media (prefers-color-scheme: dark) {
|
|
989
1033
|
.subagent-prompt {
|
|
990
1034
|
background: rgba(99, 102, 241, 0.1);
|
|
@@ -2892,6 +2936,49 @@ input:checked + .toggle-switch::after {
|
|
|
2892
2936
|
|
|
2893
2937
|
{% if is_enriched %}
|
|
2894
2938
|
|
|
2939
|
+
{%- macro render_result(content) -%}
|
|
2940
|
+
{%- if detect_language(content, is_output=True) == 'json' -%}
|
|
2941
|
+
<pre class="structured-result">{{ highlight_code(content | prettify_json, 'json') }}</pre>
|
|
2942
|
+
{%- else -%}
|
|
2943
|
+
{{- content | markdown | safe -}}
|
|
2944
|
+
{%- endif -%}
|
|
2945
|
+
{%- endmacro %}
|
|
2946
|
+
|
|
2947
|
+
{%- macro render_workflow(workflow) -%}
|
|
2948
|
+
<article class="workflow-status" aria-label="Workflow run">
|
|
2949
|
+
<div class="workflow-eyebrow">Workflow</div>
|
|
2950
|
+
<div class="workflow-heading">
|
|
2951
|
+
<strong>{{ (workflow.get('workflowName') or 'Workflow') | strip_ansi }}</strong>
|
|
2952
|
+
<code class="workflow-run" title="{{ workflow.runId }}">run {{ workflow.runId[:8] }}</code>
|
|
2953
|
+
<span class="status-badge {{ workflow.status if workflow.status in ('completed', 'error', 'running', 'pending', 'paused', 'halted', 'cancelled') else '' }}">{{ workflow.status | strip_ansi }}</span>
|
|
2954
|
+
</div>
|
|
2955
|
+
<dl class="workflow-metrics">
|
|
2956
|
+
{% if workflow.get('attempt') is number %}<div><dt>Attempt</dt><dd>{{ workflow.attempt }}</dd></div>{% endif %}
|
|
2957
|
+
{% if workflow.get('consumedSubagents') is number %}<div><dt>Subagents</dt><dd>{{ workflow.consumedSubagents }}</dd></div>{% endif %}
|
|
2958
|
+
{% if workflow.get('elapsedMs') is number %}<div><dt>Active time</dt><dd>{{ '%.1f' | format(workflow.elapsedMs / 1000) }}s</dd></div>{% endif %}
|
|
2959
|
+
{% if workflow.get('consumedNanoAiu') is number %}<div><dt>AI credits</dt><dd>{{ '%.2f' | format(workflow.consumedNanoAiu / 1000000000) }}</dd></div>{% endif %}
|
|
2960
|
+
</dl>
|
|
2961
|
+
{% for key in ('error', 'reason', 'resultPreview', 'retryGuidance') %}
|
|
2962
|
+
{% if workflow.get(key) is string and workflow[key] %}<p class="workflow-description{% if key == 'error' %} workflow-error{% endif %}">{{ workflow[key] | strip_ansi }}</p>{% endif %}
|
|
2963
|
+
{% endfor %}
|
|
2964
|
+
{% if workflow.get('agents') is sequence and workflow.agents is not string and workflow.agents is not mapping and workflow.agents %}
|
|
2965
|
+
<div class="workflow-table-scroll"><table class="workflow-agents">
|
|
2966
|
+
<thead><tr><th>Agent</th><th>Status</th><th>Model</th><th>Active time</th></tr></thead>
|
|
2967
|
+
<tbody>{% for agent in workflow.agents if agent is mapping %}<tr>
|
|
2968
|
+
<td><code title="{{ agent.get('agentId', '') }}">{{ agent.get('agentId', '')[:8] }}</code></td>
|
|
2969
|
+
<td>{{ agent.get('status', 'unknown') }}</td>
|
|
2970
|
+
<td>{% set model = agent.get('model') %}{{ model.get('resolved') or model.get('requested') or '—' if model is mapping else '—' }}</td>
|
|
2971
|
+
<td>{% if agent.get('activeMs') is number %}{{ '%.1f' | format(agent.activeMs / 1000) }}s{% else %}—{% endif %}</td>
|
|
2972
|
+
</tr>{% endfor %}</tbody>
|
|
2973
|
+
</table></div>
|
|
2974
|
+
{% endif %}
|
|
2975
|
+
{% if 'result' in workflow %}<div class="workflow-description">{{ render_result(workflow.result if workflow.result is string else workflow.result | tojson(indent=2)) }}</div>{% endif %}
|
|
2976
|
+
{% for key, label in (('failure', 'Failure details'), ('pauseInfo', 'Pause details'), ('snapshot', 'Execution checkpoint')) %}
|
|
2977
|
+
{% if workflow.get(key) is not none %}<details class="workflow-state"><summary>{{ label }}</summary><pre>{{ workflow[key] | tojson(indent=2) }}</pre></details>{% endif %}
|
|
2978
|
+
{% endfor %}
|
|
2979
|
+
</article>
|
|
2980
|
+
{%- endmacro %}
|
|
2981
|
+
|
|
2895
2982
|
{# ===== Macro: render_content_blocks ===== #}
|
|
2896
2983
|
{# Renders content blocks, tool invocations, file changes, and command runs. #}
|
|
2897
2984
|
{# Used for both outer messages and nested subagent content (recursive). #}
|
|
@@ -2932,40 +3019,53 @@ input:checked + .toggle-switch::after {
|
|
|
2932
3019
|
<span class="status-badge fork">{{ block.content | markdown | safe }}</span>
|
|
2933
3020
|
{% elif block.description == 'context-change' %}
|
|
2934
3021
|
<span class="status-badge model-change context-change">{{ block.content }}</span>
|
|
3022
|
+
{% elif block.description == 'hook-error' %}
|
|
3023
|
+
<details class="diagnostic-block">
|
|
3024
|
+
<summary><span>{{ block.content.split(' - ', 1)[0] }}</span></summary>
|
|
3025
|
+
<pre>{{ block.content }}</pre>
|
|
3026
|
+
</details>
|
|
3027
|
+
{% elif block.description == 'workflow' %}
|
|
3028
|
+
{% set workflow = block.content | workflow_details %}
|
|
3029
|
+
{% if workflow %}{{ render_workflow(workflow) }}{% else %}<span class="status-badge workflow">{{ block.content }}</span>{% endif %}
|
|
2935
3030
|
{% else %}
|
|
2936
3031
|
<span class="status-badge {{ block.description or '' }}">{{ block.content }}</span>
|
|
2937
3032
|
{% endif %}
|
|
2938
3033
|
{% elif block.kind in ('subagent', 'subagent_failed', 'subagent_incomplete') %}
|
|
2939
|
-
{% set
|
|
3034
|
+
{% set workflow_parts = (block.description or 'Agent').split(' · workflow ', 1) -%}
|
|
3035
|
+
{% set is_stream_message = block.child_message and block.description in ('User', 'Assistant', 'System') -%}
|
|
3036
|
+
{% set is_nested_system = block.child_message and block.child_message.role == 'system' %}{% if not is_nested_system or not static or include_system_messages %}<details class="subagent-block{% if is_stream_message %} subagent-message{% endif %}{% if is_nested_system %} subagent-system-message{% endif %}{% if block.kind == 'subagent_failed' %} subagent-failed{% endif %}{% if block.is_background %} subagent-background{% endif %}"{% if block.agent_id %} id="agent-{{ block.agent_id }}"{% endif %}{% if workflow_parts | length == 1 and not (is_stream_message and block.child_message.role == 'user') %} open{% endif %}>
|
|
2940
3037
|
<summary>
|
|
2941
3038
|
<span class="collapsible-icon" aria-hidden="true">▼</span>
|
|
2942
|
-
<span class="subagent-label"
|
|
3039
|
+
<span class="subagent-label" title="{{ block.description or 'Agent' }}">{{ workflow_parts[0] | compact_agent_label if workflow_parts | length > 1 else workflow_parts[0] }}</span>
|
|
3040
|
+
{% if workflow_parts | length > 1 %}<code class="workflow-run" title="{{ workflow_parts[1] }}">run {{ workflow_parts[1][:8] }}</code>{% endif -%}
|
|
2943
3041
|
{% if block.is_background %}
|
|
2944
3042
|
<span class="subagent-background-badge">↗ background</span>
|
|
2945
3043
|
{% endif %}
|
|
2946
|
-
{% if block.kind == 'subagent_failed' %}
|
|
3044
|
+
{% if not is_stream_message %}{% if block.kind == 'subagent_failed' %}
|
|
2947
3045
|
<span class="status-badge error">failed</span>
|
|
2948
3046
|
{% elif block.kind == 'subagent_incomplete' %}
|
|
2949
3047
|
<span class="status-badge abort">incomplete</span>
|
|
2950
3048
|
{% else %}
|
|
2951
3049
|
<span class="status-badge success">completed</span>
|
|
2952
|
-
{% endif %}
|
|
3050
|
+
{% endif %}{% endif %}
|
|
2953
3051
|
</summary>
|
|
2954
3052
|
<div class="subagent-content">
|
|
2955
3053
|
{% if block.prompt %}
|
|
2956
|
-
<details class="subagent-prompt"
|
|
3054
|
+
<details class="subagent-prompt">
|
|
2957
3055
|
<summary class="subagent-prompt-label"><span class="collapsible-icon" aria-hidden="true">▼</span> Prompt</summary>
|
|
2958
3056
|
<div class="subagent-prompt-content">
|
|
2959
|
-
{{ block.prompt | markdown | safe }}
|
|
3057
|
+
{{ block.prompt | markdown(literal_html=true) | safe }}
|
|
2960
3058
|
</div>
|
|
2961
3059
|
</details>
|
|
2962
3060
|
{% endif %}
|
|
2963
|
-
{% if
|
|
3061
|
+
{% if block.child_message and block.child_message.role == 'user' %}
|
|
3062
|
+
{{ block.content | markdown(literal_html=true) | safe }}
|
|
3063
|
+
{% elif include_agent_details is not defined or include_agent_details %}
|
|
2964
3064
|
{# Full details: all tools, commands, file changes, result #}
|
|
2965
3065
|
{% if block.content_blocks %}
|
|
2966
3066
|
{{ render_content_blocks(block.content_blocks, block.tool_invocations, block.file_changes, block.command_runs, get_nested_meta(block), block.content) }}
|
|
2967
3067
|
{% else %}
|
|
2968
|
-
{{ block.content
|
|
3068
|
+
{{ render_result(block.content) }}
|
|
2969
3069
|
{% endif %}
|
|
2970
3070
|
{% else %}
|
|
2971
3071
|
{# Result only: just show text blocks (the agent's response) #}
|
|
@@ -2974,14 +3074,14 @@ input:checked + .toggle-switch::after {
|
|
|
2974
3074
|
{% for inner in block.content_blocks %}
|
|
2975
3075
|
{% if inner.kind == 'text' and inner.content.strip() %}
|
|
2976
3076
|
<div class="content-block content-block-text result-block">
|
|
2977
|
-
{{ inner.content
|
|
3077
|
+
{{ render_result(inner.content) }}
|
|
2978
3078
|
</div>
|
|
2979
3079
|
{% set has_result = true %}
|
|
2980
3080
|
{% endif %}
|
|
2981
3081
|
{% endfor %}
|
|
2982
3082
|
{% endif %}
|
|
2983
3083
|
{% if not has_result %}
|
|
2984
|
-
{{ block.content
|
|
3084
|
+
{{ render_result(block.content) }}
|
|
2985
3085
|
{% endif %}
|
|
2986
3086
|
{% endif %}
|
|
2987
3087
|
</div>
|
|
@@ -3112,8 +3212,20 @@ input:checked + .toggle-switch::after {
|
|
|
3112
3212
|
|
|
3113
3213
|
{# Determine the pretty header text - use invocation_message if available, else block content #}
|
|
3114
3214
|
{% set pretty_header = matched_tool.invocation_message if matched_tool.invocation_message else block.content %}
|
|
3215
|
+
{% set workflow = matched_tool.result | workflow_details if matched_tool.name in ('run_dynamic_workflow', 'dynamic_workflows_manage') and matched_tool.result else none -%}
|
|
3115
3216
|
|
|
3116
|
-
{% if
|
|
3217
|
+
{% if workflow %}
|
|
3218
|
+
<div class="content-block content-block-toolInvocation tool-invocation-inline">
|
|
3219
|
+
<details class="tool-invocation-wrapper" open>
|
|
3220
|
+
<summary>
|
|
3221
|
+
<span class="collapsible-icon" aria-hidden="true">▼</span>
|
|
3222
|
+
<span class="tool-invocation-message">{{ pretty_header | markdown | safe }}</span>
|
|
3223
|
+
</summary>
|
|
3224
|
+
{{ render_workflow(workflow) }}
|
|
3225
|
+
</details>
|
|
3226
|
+
<div class="tool-invocation-inline-fallback">{{ pretty_header | markdown | safe }}</div>
|
|
3227
|
+
</div>
|
|
3228
|
+
{% elif matched_tool.is_agent_backlink and matched_tool.backlink_agent_id %}
|
|
3117
3229
|
{# Determine backlink state from read_agent result text #}
|
|
3118
3230
|
{% set agent_result = matched_tool.result or '' %}
|
|
3119
3231
|
{% if 'status: running' in agent_result or 'still running' in agent_result %}
|
|
@@ -3215,7 +3327,7 @@ input:checked + .toggle-switch::after {
|
|
|
3215
3327
|
{% elif block.kind == 'text' %}
|
|
3216
3328
|
{% if block.content.strip() %}
|
|
3217
3329
|
<div class="content-block content-block-text result-block">
|
|
3218
|
-
{{ block.content
|
|
3330
|
+
{{ render_result(block.content) }}
|
|
3219
3331
|
</div>
|
|
3220
3332
|
{% endif %}
|
|
3221
3333
|
{% else %}
|
|
@@ -3226,7 +3338,7 @@ input:checked + .toggle-switch::after {
|
|
|
3226
3338
|
{% endfor %}
|
|
3227
3339
|
{% elif fallback_content %}
|
|
3228
3340
|
{# Fallback to flat content for backwards compatibility #}
|
|
3229
|
-
{{ fallback_content
|
|
3341
|
+
{{ render_result(fallback_content) }}
|
|
3230
3342
|
{% endif %}
|
|
3231
3343
|
|
|
3232
3344
|
{# Show unmatched tool invocations #}
|
|
@@ -14,6 +14,7 @@ from copilot_session_tools.sources import SessionIdentityConflictError, discover
|
|
|
14
14
|
from copilot_session_tools.utils import (
|
|
15
15
|
build_block_metadata,
|
|
16
16
|
build_root_agent_markers,
|
|
17
|
+
compact_agent_label,
|
|
17
18
|
detect_language,
|
|
18
19
|
extract_filename,
|
|
19
20
|
format_timestamp,
|
|
@@ -25,6 +26,7 @@ from copilot_session_tools.utils import (
|
|
|
25
26
|
strip_ansi,
|
|
26
27
|
truncate_preview,
|
|
27
28
|
urldecode,
|
|
29
|
+
workflow_details,
|
|
28
30
|
)
|
|
29
31
|
|
|
30
32
|
|
|
@@ -77,6 +79,8 @@ def create_app(
|
|
|
77
79
|
app.jinja_env.filters["truncate_preview"] = truncate_preview
|
|
78
80
|
app.jinja_env.filters["from_json"] = _from_json
|
|
79
81
|
app.jinja_env.filters["prettify_json"] = prettify_json
|
|
82
|
+
app.jinja_env.filters["workflow_details"] = workflow_details
|
|
83
|
+
app.jinja_env.filters["compact_agent_label"] = compact_agent_label
|
|
80
84
|
|
|
81
85
|
# Register global functions for template calls
|
|
82
86
|
app.jinja_env.globals["detect_language"] = detect_language
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/cli.py
RENAMED
|
File without changes
|
|
File without changes
|
{copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/database.py
RENAMED
|
File without changes
|
|
File without changes
|
{copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/db_schema.py
RENAMED
|
File without changes
|
{copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/db_search.py
RENAMED
|
File without changes
|
|
File without changes
|
{copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/py.typed
RENAMED
|
File without changes
|
{copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/refresh.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{copilot_session_tools-0.19.2 → copilot_session_tools-0.20.0}/src/copilot_session_tools/sources.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|