mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 00:47:01 +01:00
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
Python tests / test (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JThjboXTeZ3yJPBzxMx5wS
105 lines
2.4 KiB
Python
105 lines
2.4 KiB
Python
"""Row types one transcript file contributes to the store (see :mod:`walk`)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import TYPE_CHECKING, Any
|
|
|
|
from python_pkg.token_dashboard.detail_rows import DetailRows
|
|
|
|
if TYPE_CHECKING:
|
|
from python_pkg.token_dashboard import active
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class TurnRow:
|
|
"""One deduplicated API call, priced."""
|
|
|
|
ts: float
|
|
model: str
|
|
usd: float
|
|
context: int
|
|
prompt_idx: int
|
|
usage: dict[str, int]
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class PromptRow:
|
|
"""One typed user prompt."""
|
|
|
|
idx: int
|
|
ts: float
|
|
prompt_id: str
|
|
text: str
|
|
|
|
|
|
@dataclass
|
|
class ToolRow:
|
|
"""Calls of one tool inside one prompt."""
|
|
|
|
prompt_idx: int
|
|
name: str
|
|
calls: int = 0
|
|
result_tokens: int = 0
|
|
usd: float = 0.0
|
|
carry_usd: float = 0.0
|
|
# Settled by the carry tracker too, but not stored per tool (the calls
|
|
# table holds creation per call).
|
|
create_usd: float = 0.0
|
|
carry_calls: int = 0
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class AgentCall:
|
|
"""An ``Agent`` tool call: the spawn point of a subagent."""
|
|
|
|
tool_use_id: str
|
|
agent_id: str
|
|
prompt_idx: int
|
|
ts: float
|
|
description: str
|
|
subagent_type: str
|
|
model: str
|
|
result_ts: float
|
|
status: str
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Commit:
|
|
"""A commit hash printed by a Bash ``git commit`` in this file."""
|
|
|
|
prompt_idx: int
|
|
ts: float
|
|
end_ts: float
|
|
sha: str
|
|
repo: str
|
|
|
|
|
|
@dataclass
|
|
class FileRows:
|
|
"""The row lists one transcript file contributes."""
|
|
|
|
turns: list[TurnRow] = field(default_factory=list)
|
|
prompts: list[PromptRow] = field(default_factory=list)
|
|
tools: list[ToolRow] = field(default_factory=list)
|
|
agent_calls: list[AgentCall] = field(default_factory=list)
|
|
intervals: list[active.Span] = field(default_factory=list)
|
|
lever_tables: list[tuple[float, str]] = field(default_factory=list)
|
|
commits: list[Commit] = field(default_factory=list)
|
|
messages: list[tuple[float, str]] = field(default_factory=list)
|
|
detail: DetailRows = field(default_factory=DetailRows)
|
|
|
|
|
|
@dataclass
|
|
class FileFacts:
|
|
"""Everything one transcript file contributes to the store."""
|
|
|
|
key: str
|
|
session_id: str
|
|
parent_session: str | None
|
|
cwd: str | None
|
|
meta: dict[str, Any]
|
|
rows: FileRows = field(default_factory=FileRows)
|
|
final_tag: str | None = None
|
|
span: tuple[float, float] = (0.0, 0.0)
|