oh-langfuse 0.1.46 → 0.1.47
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/codex_langfuse_notify.py +0 -73
- package/package.json +1 -1
package/codex_langfuse_notify.py
CHANGED
|
@@ -61,7 +61,6 @@ LOG_FILE = STATE_DIR / "codex_langfuse_notify.log"
|
|
|
61
61
|
|
|
62
62
|
DEBUG = os.environ.get("CODEX_LANGFUSE_DEBUG", "").lower() == "true"
|
|
63
63
|
MAX_CHARS = int(os.environ.get("CODEX_LANGFUSE_MAX_CHARS", "20000"))
|
|
64
|
-
MAX_SKILL_SCAN_CHARS = int(os.environ.get("CODEX_LANGFUSE_SKILL_SCAN_MAX_CHARS", "200000"))
|
|
65
64
|
METRICS_SCHEMA_VERSION = "1.1"
|
|
66
65
|
AGENT_NAME = "codex"
|
|
67
66
|
|
|
@@ -502,61 +501,6 @@ def _skill_usage(name: str, detected_by: str, skill_call_id: str = "") -> Dict[s
|
|
|
502
501
|
}
|
|
503
502
|
|
|
504
503
|
|
|
505
|
-
def _accept_skill_candidate(name: Any, known_skills: set, trusted: bool = False) -> str:
|
|
506
|
-
clean = str(name or "").strip()
|
|
507
|
-
if not clean:
|
|
508
|
-
return ""
|
|
509
|
-
if trusted or not known_skills or clean in known_skills:
|
|
510
|
-
return clean
|
|
511
|
-
return ""
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
def _collect_strings_limited(value: Any, out: List[str], remaining: List[int]) -> None:
|
|
515
|
-
if remaining[0] <= 0 or value is None:
|
|
516
|
-
return
|
|
517
|
-
if isinstance(value, str):
|
|
518
|
-
text = value[: remaining[0]]
|
|
519
|
-
if text:
|
|
520
|
-
out.append(text)
|
|
521
|
-
remaining[0] -= len(text)
|
|
522
|
-
return
|
|
523
|
-
if isinstance(value, (int, float, bool)):
|
|
524
|
-
return
|
|
525
|
-
if isinstance(value, list):
|
|
526
|
-
for item in value:
|
|
527
|
-
_collect_strings_limited(item, out, remaining)
|
|
528
|
-
if remaining[0] <= 0:
|
|
529
|
-
break
|
|
530
|
-
return
|
|
531
|
-
if isinstance(value, dict):
|
|
532
|
-
for item in value.values():
|
|
533
|
-
_collect_strings_limited(item, out, remaining)
|
|
534
|
-
if remaining[0] <= 0:
|
|
535
|
-
break
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
def _detect_skill_usages_from_text(text: str, known_skills: set) -> List[Dict[str, str]]:
|
|
539
|
-
found: List[Dict[str, str]] = []
|
|
540
|
-
if not text:
|
|
541
|
-
return found
|
|
542
|
-
seen: set = set()
|
|
543
|
-
for match in re.finditer(r"([A-Za-z]:)?[^\"'\n\r]*[\\/]+([^\\/\"'\n\r]+)[\\/]+SKILL\.md", text, re.IGNORECASE):
|
|
544
|
-
name = _accept_skill_candidate(match.group(2), known_skills)
|
|
545
|
-
if name and name not in seen:
|
|
546
|
-
seen.add(name)
|
|
547
|
-
found.append(_skill_usage(name, "skill_file_path"))
|
|
548
|
-
for match in re.finditer(r"Base directory for this skill:\s*([^\r\n]+)", text, re.IGNORECASE):
|
|
549
|
-
path_text = match.group(1)
|
|
550
|
-
path_match = re.search(r"[\\/](?:skills|skill)[\\/]([^\\/\"'\r\n]+)", path_text, re.IGNORECASE)
|
|
551
|
-
if not path_match:
|
|
552
|
-
continue
|
|
553
|
-
name = _accept_skill_candidate(path_match.group(1), known_skills)
|
|
554
|
-
if name and name not in seen:
|
|
555
|
-
seen.add(name)
|
|
556
|
-
found.append(_skill_usage(name, "skill_file_path"))
|
|
557
|
-
return found
|
|
558
|
-
|
|
559
|
-
|
|
560
504
|
def detect_skill_usages(tool_calls: List[Dict[str, Any]], known_skills: set) -> List[Dict[str, str]]:
|
|
561
505
|
found: List[Dict[str, str]] = []
|
|
562
506
|
seen_call_ids: set = set()
|
|
@@ -576,11 +520,6 @@ def detect_skill_usages(tool_calls: List[Dict[str, Any]], known_skills: set) ->
|
|
|
576
520
|
seen_call_ids.add(dedupe_key)
|
|
577
521
|
found.append(_skill_usage(name, "tool_call", call_id))
|
|
578
522
|
break
|
|
579
|
-
try:
|
|
580
|
-
text = json.dumps(input_obj, ensure_ascii=False)
|
|
581
|
-
except Exception:
|
|
582
|
-
text = str(input_obj)
|
|
583
|
-
found.extend(_detect_skill_usages_from_text(text, known_skills))
|
|
584
523
|
return found
|
|
585
524
|
|
|
586
525
|
|
|
@@ -612,18 +551,6 @@ def _dedupe_turn_skill_usages(usages: List[Dict[str, str]]) -> List[Dict[str, st
|
|
|
612
551
|
|
|
613
552
|
def detect_turn_skill_usages(material: Dict[str, Any], known_skills: set) -> List[Dict[str, str]]:
|
|
614
553
|
found = list(detect_skill_usages(material.get("tool_calls") or [], known_skills))
|
|
615
|
-
sources = [
|
|
616
|
-
material.get("user_text"),
|
|
617
|
-
material.get("assistant_text"),
|
|
618
|
-
material.get("skill_detection_sources"),
|
|
619
|
-
]
|
|
620
|
-
strings: List[str] = []
|
|
621
|
-
remaining = [max(0, MAX_SKILL_SCAN_CHARS)]
|
|
622
|
-
for source in sources:
|
|
623
|
-
_collect_strings_limited(source, strings, remaining)
|
|
624
|
-
if remaining[0] <= 0:
|
|
625
|
-
break
|
|
626
|
-
found.extend(_detect_skill_usages_from_text("\n".join(strings), known_skills))
|
|
627
554
|
return _dedupe_turn_skill_usages(found)
|
|
628
555
|
|
|
629
556
|
|