prizmkit 1.1.199 → 1.1.200
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.
package/bundled/VERSION.json
CHANGED
|
@@ -12,9 +12,22 @@ from contextlib import nullcontext
|
|
|
12
12
|
from dataclasses import dataclass
|
|
13
13
|
from datetime import datetime, timezone
|
|
14
14
|
from pathlib import Path
|
|
15
|
+
from urllib.parse import urlparse
|
|
16
|
+
from urllib.request import url2pathname
|
|
15
17
|
|
|
16
18
|
from .atomic_io import write_json_atomic
|
|
17
19
|
|
|
20
|
+
_SAFE_ANTIGRAVITY_SESSION_ID_RE = re.compile(r"^[A-Za-z0-9._-]+$")
|
|
21
|
+
_ANTIGRAVITY_SUBAGENT_HEADER_RE = re.compile(r"(?:^|\r?\n)Created the following subagent:\s*\{")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _is_safe_antigravity_session_id(session_id: str) -> bool:
|
|
25
|
+
return bool(
|
|
26
|
+
session_id
|
|
27
|
+
and session_id not in {".", ".."}
|
|
28
|
+
and _SAFE_ANTIGRAVITY_SESSION_ID_RE.fullmatch(session_id)
|
|
29
|
+
)
|
|
30
|
+
|
|
18
31
|
# Ordered pipeline phases — index defines forward-only progression.
|
|
19
32
|
# Phase detection is monotonic: once a phase is reached, earlier phases
|
|
20
33
|
# cannot be re-entered (prevents false positives from file content mentions).
|
|
@@ -987,6 +1000,12 @@ class ProgressTracker:
|
|
|
987
1000
|
self._codex_child_session_paths = {}
|
|
988
1001
|
self._claude_child_session_files = []
|
|
989
1002
|
self._cb_child_session_files = []
|
|
1003
|
+
self._ag_child_session_ids = set()
|
|
1004
|
+
self._ag_child_log_uris = {}
|
|
1005
|
+
self._ag_child_session_files = {}
|
|
1006
|
+
self._ag_parent_transcript_path = ""
|
|
1007
|
+
self._ag_parent_transcript_offset = 0
|
|
1008
|
+
self._ag_parent_transcript_mtime_ns = 0
|
|
990
1009
|
self._last_child_scan_at = 0.0
|
|
991
1010
|
self._last_claude_fallback_scan_at = 0.0
|
|
992
1011
|
self._last_claude_fallback_scan_key = ""
|
|
@@ -1125,6 +1144,14 @@ class ProgressTracker:
|
|
|
1125
1144
|
error_text = _cursor_compact_value(tool_err, 500)
|
|
1126
1145
|
self._append_error(error_text)
|
|
1127
1146
|
self._detect_terminal_error(error_text, require_error_context=False)
|
|
1147
|
+
if tool_name == "invoke_subagent" and info.get("output") is not None:
|
|
1148
|
+
for child_id, log_uri in self._extract_antigravity_subagent_refs(
|
|
1149
|
+
info.get("output"),
|
|
1150
|
+
parent_session_id=self.antigravity_session_id,
|
|
1151
|
+
):
|
|
1152
|
+
self._ag_child_session_ids.add(child_id)
|
|
1153
|
+
if log_uri and child_id not in self._ag_child_log_uris:
|
|
1154
|
+
self._ag_child_log_uris[child_id] = log_uri
|
|
1128
1155
|
step_err = payload.get("error")
|
|
1129
1156
|
if step_err:
|
|
1130
1157
|
error_text = _cursor_compact_value(step_err, 500)
|
|
@@ -2613,6 +2640,195 @@ class ProgressTracker:
|
|
|
2613
2640
|
return []
|
|
2614
2641
|
return []
|
|
2615
2642
|
|
|
2643
|
+
def _antigravity_brain_dir(self) -> Path:
|
|
2644
|
+
"""Return the Antigravity brain directory for transcript lookup."""
|
|
2645
|
+
brain_dir = os.environ.get("ANTIGRAVITY_BRAIN_DIR")
|
|
2646
|
+
if brain_dir:
|
|
2647
|
+
return Path(brain_dir).expanduser()
|
|
2648
|
+
app_data = os.environ.get("ANTIGRAVITY_APP_DATA_DIR")
|
|
2649
|
+
if app_data:
|
|
2650
|
+
return Path(app_data).expanduser() / "brain"
|
|
2651
|
+
ag_home = os.environ.get("ANTIGRAVITY_HOME")
|
|
2652
|
+
if ag_home:
|
|
2653
|
+
return Path(ag_home).expanduser() / "brain"
|
|
2654
|
+
gemini_home = os.environ.get("GEMINI_HOME")
|
|
2655
|
+
if gemini_home:
|
|
2656
|
+
return Path(gemini_home).expanduser() / "antigravity-cli" / "brain"
|
|
2657
|
+
return Path.home() / ".gemini" / "antigravity-cli" / "brain"
|
|
2658
|
+
|
|
2659
|
+
def _extract_antigravity_subagent_refs(
|
|
2660
|
+
self,
|
|
2661
|
+
payload: object,
|
|
2662
|
+
*,
|
|
2663
|
+
parent_session_id: str,
|
|
2664
|
+
) -> list[tuple[str, str]]:
|
|
2665
|
+
"""Extract safe Antigravity child (conversationId, logAbsoluteUri) pairs."""
|
|
2666
|
+
refs: list[tuple[str, str]] = []
|
|
2667
|
+
seen: set[str] = set()
|
|
2668
|
+
|
|
2669
|
+
def add_ref(raw_obj: object) -> None:
|
|
2670
|
+
if not isinstance(raw_obj, dict):
|
|
2671
|
+
return
|
|
2672
|
+
raw_id = raw_obj.get("conversationId") or raw_obj.get("conversation_id")
|
|
2673
|
+
if not isinstance(raw_id, str):
|
|
2674
|
+
return
|
|
2675
|
+
child_id = raw_id.strip()
|
|
2676
|
+
if not _is_safe_antigravity_session_id(child_id) or child_id == parent_session_id or child_id in seen:
|
|
2677
|
+
return
|
|
2678
|
+
raw_uri = raw_obj.get("logAbsoluteUri") or raw_obj.get("log_absolute_uri")
|
|
2679
|
+
log_uri = raw_uri.strip() if isinstance(raw_uri, str) else ""
|
|
2680
|
+
seen.add(child_id)
|
|
2681
|
+
refs.append((child_id, log_uri))
|
|
2682
|
+
|
|
2683
|
+
if isinstance(payload, dict):
|
|
2684
|
+
add_ref(payload)
|
|
2685
|
+
nested = payload.get("content") or payload.get("output")
|
|
2686
|
+
if isinstance(nested, dict):
|
|
2687
|
+
add_ref(nested)
|
|
2688
|
+
return refs
|
|
2689
|
+
if isinstance(nested, str):
|
|
2690
|
+
payload = nested
|
|
2691
|
+
else:
|
|
2692
|
+
return refs
|
|
2693
|
+
|
|
2694
|
+
if isinstance(payload, str):
|
|
2695
|
+
decoder = json.JSONDecoder()
|
|
2696
|
+
for match in _ANTIGRAVITY_SUBAGENT_HEADER_RE.finditer(payload):
|
|
2697
|
+
prefix = payload[: match.start()]
|
|
2698
|
+
if (
|
|
2699
|
+
"Command exited with code " in prefix
|
|
2700
|
+
or "Command output:" in prefix
|
|
2701
|
+
or "Showing lines " in prefix
|
|
2702
|
+
or "Partial read (" in prefix
|
|
2703
|
+
):
|
|
2704
|
+
continue
|
|
2705
|
+
brace_idx = match.end() - 1
|
|
2706
|
+
try:
|
|
2707
|
+
parsed, _ = decoder.raw_decode(payload, brace_idx)
|
|
2708
|
+
except (ValueError, json.JSONDecodeError):
|
|
2709
|
+
continue
|
|
2710
|
+
add_ref(parsed)
|
|
2711
|
+
return refs
|
|
2712
|
+
|
|
2713
|
+
def _resolve_antigravity_child_transcript(
|
|
2714
|
+
self,
|
|
2715
|
+
*,
|
|
2716
|
+
brain_dir: Path,
|
|
2717
|
+
child_id: str,
|
|
2718
|
+
log_uri: str = "",
|
|
2719
|
+
) -> Path | None:
|
|
2720
|
+
"""Resolve an Antigravity subagent transcript path confined to brain_dir."""
|
|
2721
|
+
if not _is_safe_antigravity_session_id(child_id):
|
|
2722
|
+
return None
|
|
2723
|
+
candidate = brain_dir / child_id / ".system_generated" / "logs" / "transcript.jsonl"
|
|
2724
|
+
try:
|
|
2725
|
+
if candidate.is_file():
|
|
2726
|
+
return candidate
|
|
2727
|
+
except OSError:
|
|
2728
|
+
return None
|
|
2729
|
+
if log_uri.startswith("file://"):
|
|
2730
|
+
try:
|
|
2731
|
+
parsed = urlparse(log_uri)
|
|
2732
|
+
if parsed.scheme != "file" or parsed.netloc not in ("", "localhost"):
|
|
2733
|
+
return None
|
|
2734
|
+
raw_path = url2pathname(parsed.path)
|
|
2735
|
+
if not raw_path:
|
|
2736
|
+
return None
|
|
2737
|
+
brain_resolved = brain_dir.resolve()
|
|
2738
|
+
target_resolved = Path(raw_path).resolve()
|
|
2739
|
+
if target_resolved.is_relative_to(brain_resolved) and target_resolved.is_file():
|
|
2740
|
+
return target_resolved
|
|
2741
|
+
except (OSError, ValueError):
|
|
2742
|
+
return None
|
|
2743
|
+
return None
|
|
2744
|
+
|
|
2745
|
+
def _find_antigravity_child_session_files(
|
|
2746
|
+
self,
|
|
2747
|
+
*,
|
|
2748
|
+
ag_session_id: str,
|
|
2749
|
+
known_child_ids: set[str],
|
|
2750
|
+
known_log_uris: dict[str, str],
|
|
2751
|
+
cached_files: dict[str, Path],
|
|
2752
|
+
parent_transcript_path: str,
|
|
2753
|
+
parent_offset: int,
|
|
2754
|
+
parent_mtime_ns: int,
|
|
2755
|
+
) -> tuple[dict[str, Path], set[str], dict[str, str], str, int, int]:
|
|
2756
|
+
"""Incrementally discover and resolve Antigravity child subagent transcripts."""
|
|
2757
|
+
discovered_ids: set[str] = set()
|
|
2758
|
+
discovered_uris: dict[str, str] = {}
|
|
2759
|
+
found_files: dict[str, Path] = {}
|
|
2760
|
+
for child_id, cached_path in cached_files.items():
|
|
2761
|
+
try:
|
|
2762
|
+
if os.path.isfile(cached_path):
|
|
2763
|
+
found_files[child_id] = cached_path
|
|
2764
|
+
except OSError:
|
|
2765
|
+
continue
|
|
2766
|
+
|
|
2767
|
+
if not _is_safe_antigravity_session_id(ag_session_id):
|
|
2768
|
+
return found_files, discovered_ids, discovered_uris, parent_transcript_path, parent_offset, parent_mtime_ns
|
|
2769
|
+
|
|
2770
|
+
brain_dir = self._antigravity_brain_dir()
|
|
2771
|
+
parent_transcript = brain_dir / ag_session_id / ".system_generated" / "logs" / "transcript.jsonl"
|
|
2772
|
+
parent_path_str = str(parent_transcript)
|
|
2773
|
+
offset = parent_offset if parent_path_str == parent_transcript_path else 0
|
|
2774
|
+
mtime_ns = parent_mtime_ns if parent_path_str == parent_transcript_path else 0
|
|
2775
|
+
|
|
2776
|
+
try:
|
|
2777
|
+
stat = os.stat(parent_transcript)
|
|
2778
|
+
except OSError:
|
|
2779
|
+
stat = None
|
|
2780
|
+
|
|
2781
|
+
if stat is not None:
|
|
2782
|
+
cur_mtime_ns = getattr(stat, "st_mtime_ns", int(stat.st_mtime * 1_000_000_000))
|
|
2783
|
+
if stat.st_size < offset:
|
|
2784
|
+
offset = 0
|
|
2785
|
+
if stat.st_size > offset or cur_mtime_ns != mtime_ns:
|
|
2786
|
+
try:
|
|
2787
|
+
with open(parent_transcript, "rb") as fh:
|
|
2788
|
+
fh.seek(offset)
|
|
2789
|
+
chunk = fh.read()
|
|
2790
|
+
except OSError:
|
|
2791
|
+
chunk = b""
|
|
2792
|
+
if chunk:
|
|
2793
|
+
last_nl = chunk.rfind(b"\n")
|
|
2794
|
+
if last_nl >= 0:
|
|
2795
|
+
complete_block = chunk[: last_nl + 1]
|
|
2796
|
+
offset += last_nl + 1
|
|
2797
|
+
for raw_line in complete_block.splitlines():
|
|
2798
|
+
if b"Created the following subagent" not in raw_line:
|
|
2799
|
+
continue
|
|
2800
|
+
try:
|
|
2801
|
+
obj = json.loads(raw_line.decode("utf-8", errors="replace"))
|
|
2802
|
+
except (ValueError, json.JSONDecodeError):
|
|
2803
|
+
continue
|
|
2804
|
+
if not isinstance(obj, dict):
|
|
2805
|
+
continue
|
|
2806
|
+
if obj.get("type") not in (None, "", "GENERIC"):
|
|
2807
|
+
continue
|
|
2808
|
+
for child_id, log_uri in self._extract_antigravity_subagent_refs(
|
|
2809
|
+
obj.get("content"),
|
|
2810
|
+
parent_session_id=ag_session_id,
|
|
2811
|
+
):
|
|
2812
|
+
discovered_ids.add(child_id)
|
|
2813
|
+
if log_uri:
|
|
2814
|
+
discovered_uris[child_id] = log_uri
|
|
2815
|
+
mtime_ns = cur_mtime_ns
|
|
2816
|
+
|
|
2817
|
+
merged_uris = dict(known_log_uris)
|
|
2818
|
+
merged_uris.update(discovered_uris)
|
|
2819
|
+
for child_id in sorted(known_child_ids | discovered_ids):
|
|
2820
|
+
if child_id in found_files:
|
|
2821
|
+
continue
|
|
2822
|
+
resolved = self._resolve_antigravity_child_transcript(
|
|
2823
|
+
brain_dir=brain_dir,
|
|
2824
|
+
child_id=child_id,
|
|
2825
|
+
log_uri=merged_uris.get(child_id, ""),
|
|
2826
|
+
)
|
|
2827
|
+
if resolved is not None:
|
|
2828
|
+
found_files[child_id] = resolved
|
|
2829
|
+
|
|
2830
|
+
return found_files, discovered_ids, discovered_uris, parent_path_str, offset, mtime_ns
|
|
2831
|
+
|
|
2616
2832
|
def refresh_child_session_activity(self, force=False, *, lock=None):
|
|
2617
2833
|
"""Refresh child transcript file stats (safe to perform I/O outside lock)."""
|
|
2618
2834
|
lock_ctx = lock if lock is not None else nullcontext()
|
|
@@ -2626,8 +2842,13 @@ class ProgressTracker:
|
|
|
2626
2842
|
has_tracked_claude = self._has_tracked_claude_subagent_task()
|
|
2627
2843
|
cb_sid = self.cb_session_id if provider_hint in {"", "codebuddy"} and event_format in {"", "stream-json"} else ""
|
|
2628
2844
|
cb_cwd = self.cb_cwd
|
|
2845
|
+
ag_sid = (
|
|
2846
|
+
self.antigravity_session_id
|
|
2847
|
+
if provider_hint in {"", "antigravity"} and event_format in {"", "antigravity-stream-json"}
|
|
2848
|
+
else ""
|
|
2849
|
+
)
|
|
2629
2850
|
|
|
2630
|
-
if not codex_ids and not claude_sid and not cb_sid:
|
|
2851
|
+
if not codex_ids and not claude_sid and not cb_sid and not ag_sid:
|
|
2631
2852
|
self.child_session_files = []
|
|
2632
2853
|
self.child_total_bytes = 0
|
|
2633
2854
|
self.child_activity_signature = ""
|
|
@@ -2643,9 +2864,18 @@ class ProgressTracker:
|
|
|
2643
2864
|
codex_paths = dict(self._codex_child_session_paths)
|
|
2644
2865
|
claude_files = list(self._claude_child_session_files)
|
|
2645
2866
|
cb_files = list(self._cb_child_session_files)
|
|
2867
|
+
ag_known_ids = set(self._ag_child_session_ids)
|
|
2868
|
+
ag_known_uris = dict(self._ag_child_log_uris)
|
|
2869
|
+
ag_files = dict(self._ag_child_session_files)
|
|
2870
|
+
ag_parent_path = self._ag_parent_transcript_path
|
|
2871
|
+
ag_parent_offset = self._ag_parent_transcript_offset
|
|
2872
|
+
ag_parent_mtime_ns = self._ag_parent_transcript_mtime_ns
|
|
2646
2873
|
last_fallback_key = self._last_claude_fallback_scan_key
|
|
2647
2874
|
last_fallback_at = self._last_claude_fallback_scan_at
|
|
2648
2875
|
|
|
2876
|
+
ag_discovered_ids: set[str] = set()
|
|
2877
|
+
ag_discovered_uris: dict[str, str] = {}
|
|
2878
|
+
|
|
2649
2879
|
# Perform all filesystem probes & stats outside lock so stdout reader never stalls.
|
|
2650
2880
|
if should_scan:
|
|
2651
2881
|
for thread_id in codex_ids:
|
|
@@ -2667,6 +2897,23 @@ class ProgressTracker:
|
|
|
2667
2897
|
cached_files=claude_files,
|
|
2668
2898
|
)
|
|
2669
2899
|
cb_files = self._find_cb_child_session_files(cb_session_id=cb_sid, cb_cwd=cb_cwd)
|
|
2900
|
+
if ag_sid:
|
|
2901
|
+
(
|
|
2902
|
+
ag_files,
|
|
2903
|
+
ag_discovered_ids,
|
|
2904
|
+
ag_discovered_uris,
|
|
2905
|
+
ag_parent_path,
|
|
2906
|
+
ag_parent_offset,
|
|
2907
|
+
ag_parent_mtime_ns,
|
|
2908
|
+
) = self._find_antigravity_child_session_files(
|
|
2909
|
+
ag_session_id=ag_sid,
|
|
2910
|
+
known_child_ids=ag_known_ids,
|
|
2911
|
+
known_log_uris=ag_known_uris,
|
|
2912
|
+
cached_files=ag_files,
|
|
2913
|
+
parent_transcript_path=ag_parent_path,
|
|
2914
|
+
parent_offset=ag_parent_offset,
|
|
2915
|
+
parent_mtime_ns=ag_parent_mtime_ns,
|
|
2916
|
+
)
|
|
2670
2917
|
scan_completed_at = time.monotonic()
|
|
2671
2918
|
else:
|
|
2672
2919
|
scan_completed_at = None
|
|
@@ -2712,6 +2959,9 @@ class ProgressTracker:
|
|
|
2712
2959
|
identifier = parent_name if parent_name.startswith("agent-") else path.name
|
|
2713
2960
|
add_file("codebuddy", identifier, path)
|
|
2714
2961
|
|
|
2962
|
+
for child_id, path in sorted(ag_files.items()):
|
|
2963
|
+
add_file("antigravity", child_id, path)
|
|
2964
|
+
|
|
2715
2965
|
new_signature = "|".join(signature_parts)
|
|
2716
2966
|
last_activity_at = (
|
|
2717
2967
|
datetime.fromtimestamp(max_mtime, timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
@@ -2724,6 +2974,12 @@ class ProgressTracker:
|
|
|
2724
2974
|
self._codex_child_session_paths.update(codex_paths)
|
|
2725
2975
|
self._claude_child_session_files = claude_files
|
|
2726
2976
|
self._cb_child_session_files = cb_files
|
|
2977
|
+
self._ag_child_session_ids.update(ag_discovered_ids)
|
|
2978
|
+
self._ag_child_log_uris.update(ag_discovered_uris)
|
|
2979
|
+
self._ag_child_session_files = ag_files
|
|
2980
|
+
self._ag_parent_transcript_path = ag_parent_path
|
|
2981
|
+
self._ag_parent_transcript_offset = ag_parent_offset
|
|
2982
|
+
self._ag_parent_transcript_mtime_ns = ag_parent_mtime_ns
|
|
2727
2983
|
self._last_claude_fallback_scan_key = last_fallback_key
|
|
2728
2984
|
self._last_claude_fallback_scan_at = last_fallback_at
|
|
2729
2985
|
if scan_completed_at is not None:
|