nullius-eval 0.1.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.
- _nullius_app/.env.example +55 -0
- _nullius_app/app.py +96 -0
- _nullius_app/requirements.txt +1 -0
- _nullius_app/static/brand/README.md +20 -0
- _nullius_app/static/brand/docker.svg +1 -0
- _nullius_app/static/brand/favicon.svg +1 -0
- _nullius_app/static/brand/huggingface.svg +37 -0
- _nullius_app/static/brand/mark-dark.svg +1 -0
- _nullius_app/static/brand/marks.svg +34 -0
- _nullius_app/static/brand/tokens.json +51 -0
- _nullius_app/static/brand/typesafe.png +0 -0
- _nullius_app/static/brand/wordmark-dark.svg +1 -0
- _nullius_app/static/builder/command-builder-core.js +763 -0
- _nullius_app/static/builder/command-builder.css +248 -0
- _nullius_app/static/builder/command-builder.js +997 -0
- _nullius_app/static/builder/model-picker.js +113 -0
- _nullius_app/static/catalogue/add.js +46 -0
- _nullius_app/static/catalogue/agents/README.md +19 -0
- _nullius_app/static/catalogue/agents/goose.svg +1 -0
- _nullius_app/static/catalogue/agents/jiuwenswarm.svg +33 -0
- _nullius_app/static/catalogue/agents/marks.json +8 -0
- _nullius_app/static/catalogue/agents/mini-swe-agent.svg +7 -0
- _nullius_app/static/catalogue/agents/opencode.svg +7 -0
- _nullius_app/static/catalogue/catalogue.css +436 -0
- _nullius_app/static/catalogue/catalogue.js +87 -0
- _nullius_app/static/catalogue/marks.svg +29 -0
- _nullius_app/static/catalogue/new.js +78 -0
- _nullius_app/static/catalogue/versions.js +27 -0
- _nullius_app/static/compare/comparison.css +117 -0
- _nullius_app/static/controls.js +117 -0
- _nullius_app/static/disclosures.js +70 -0
- _nullius_app/static/fonts/0569c822cab6c510.ttf +0 -0
- _nullius_app/static/fonts/DMSans-Medium.woff2 +0 -0
- _nullius_app/static/fonts/DMSans-Regular.woff2 +0 -0
- _nullius_app/static/fonts/IBMPlexMono-Medium.woff2 +0 -0
- _nullius_app/static/fonts/IBMPlexMono-Regular.woff2 +0 -0
- _nullius_app/static/fonts/InstrumentSerif-Italic.woff2 +0 -0
- _nullius_app/static/fonts/InstrumentSerif-Regular.woff2 +0 -0
- _nullius_app/static/fonts/README.md +11 -0
- _nullius_app/static/fonts/c1e7453ea26a1d1e.ttf +0 -0
- _nullius_app/static/fonts/dmsans-OFL.txt +93 -0
- _nullius_app/static/fonts/ibmplexmono-OFL.txt +93 -0
- _nullius_app/static/fonts/instrumentserif-OFL.txt +93 -0
- _nullius_app/static/fonts.css +49 -0
- _nullius_app/static/notifications.js +49 -0
- _nullius_app/static/onboarding.css +78 -0
- _nullius_app/static/onboarding.js +158 -0
- _nullius_app/static/runs/board.css +358 -0
- _nullius_app/static/runs/board.js +127 -0
- _nullius_app/static/runs/launches.css +88 -0
- _nullius_app/static/runs/live-board.css +186 -0
- _nullius_app/static/runs/live-board.js +394 -0
- _nullius_app/static/runs/path-suggestions.js +119 -0
- _nullius_app/static/runs/start.css +38 -0
- _nullius_app/static/settings/autosave.js +162 -0
- _nullius_app/static/settings/custom-keys.js +100 -0
- _nullius_app/static/settings/data-providers.js +88 -0
- _nullius_app/static/settings/judges.js +61 -0
- _nullius_app/static/settings/modal.css +32 -0
- _nullius_app/static/settings/modal.js +91 -0
- _nullius_app/static/settings/navigation.js +55 -0
- _nullius_app/static/settings/prices.js +68 -0
- _nullius_app/static/settings/providers.js +134 -0
- _nullius_app/static/settings/sandbox.js +20 -0
- _nullius_app/static/settings/settings.css +288 -0
- _nullius_app/static/style.css +1752 -0
- _nullius_app/static/traces/conversation.css +49 -0
- _nullius_app/static/traces/conversation.js +215 -0
- _nullius_app/templates/agents/entry.html +145 -0
- _nullius_app/templates/agents/kits.html +55 -0
- _nullius_app/templates/agents/standard.html +58 -0
- _nullius_app/templates/base.html +479 -0
- _nullius_app/templates/builder/new_run.html +55 -0
- _nullius_app/templates/catalogue/add_dialog.html +32 -0
- _nullius_app/templates/catalogue/benchmark.html +270 -0
- _nullius_app/templates/catalogue/benchmarks.html +91 -0
- _nullius_app/templates/catalogue/new.html +141 -0
- _nullius_app/templates/catalogue/use_bundle.html +11 -0
- _nullius_app/templates/compare/_detail.html +37 -0
- _nullius_app/templates/compare/compare.html +298 -0
- _nullius_app/templates/compare/compare_picker.html +51 -0
- _nullius_app/templates/compare/compare_task.html +329 -0
- _nullius_app/templates/runs/_execution.html +131 -0
- _nullius_app/templates/runs/_runtime.html +5 -0
- _nullius_app/templates/runs/ascii-mark.html +485 -0
- _nullius_app/templates/runs/feasibility.html +127 -0
- _nullius_app/templates/runs/index.html +609 -0
- _nullius_app/templates/runs/job.html +460 -0
- _nullius_app/templates/runs/preparing.html +14 -0
- _nullius_app/templates/runs/reconcile.html +124 -0
- _nullius_app/templates/runs/setup.html +272 -0
- _nullius_app/templates/runs/start.html +51 -0
- _nullius_app/templates/settings/custom_keys.html +82 -0
- _nullius_app/templates/settings/data_providers.html +27 -0
- _nullius_app/templates/settings/settings.html +564 -0
- _nullius_app/templates/traces/_charts.html +165 -0
- _nullius_app/templates/traces/_conversation.html +37 -0
- _nullius_app/templates/traces/_judgement.html +72 -0
- _nullius_app/templates/traces/artifact.html +15 -0
- _nullius_app/templates/traces/trial.html +838 -0
- _nullius_app/templates/workspaces/workspaces.html +54 -0
- _nullius_app/web/__init__.py +1 -0
- _nullius_app/web/agents.py +230 -0
- _nullius_app/web/builder.py +406 -0
- _nullius_app/web/catalogue.py +370 -0
- _nullius_app/web/compare.py +489 -0
- _nullius_app/web/core.py +17 -0
- _nullius_app/web/execute.py +223 -0
- _nullius_app/web/feasibility.py +60 -0
- _nullius_app/web/filters.py +231 -0
- _nullius_app/web/judge.py +623 -0
- _nullius_app/web/judge_tasks.py +33 -0
- _nullius_app/web/onboarding.py +20 -0
- _nullius_app/web/reconcile.py +47 -0
- _nullius_app/web/runs.py +464 -0
- _nullius_app/web/settings.py +324 -0
- _nullius_app/web/shared.py +507 -0
- _nullius_app/web/traces.py +306 -0
- _nullius_app/web/workspaces.py +84 -0
- nullius/__init__.py +32 -0
- nullius/__main__.py +5 -0
- nullius/catalogue/__init__.py +0 -0
- nullius/catalogue/agents/codex/agent.json +222 -0
- nullius/catalogue/agents/codex/config.toml +25 -0
- nullius/catalogue/agents/goose/agent.json +131 -0
- nullius/catalogue/agents/goose/config.yaml +20 -0
- nullius/catalogue/agents/jiuwenswarm/agent.json +197 -0
- nullius/catalogue/agents/jiuwenswarm/agent.py +355 -0
- nullius/catalogue/agents/mini-swe-agent/agent.json +68 -0
- nullius/catalogue/agents/mini-swe-agent/run.py +37 -0
- nullius/catalogue/agents/opencode/agent.json +135 -0
- nullius/catalogue/agents/opencode/opencode.json +32 -0
- nullius/catalogue/agents/reference/agent.json +89 -0
- nullius/catalogue/agents/reference/agent.py +209 -0
- nullius/catalogue/agents/terminus-2/agent.json +64 -0
- nullius/catalogue/agents/terminus-2/run.py +139 -0
- nullius/catalogue/benchmarks/gaia/benchmark.json +72 -0
- nullius/catalogue/benchmarks/gaia/data-source.json +29 -0
- nullius/catalogue/benchmarks/gaia/driver.py +188 -0
- nullius/catalogue/benchmarks/gaia/env/data.Dockerfile +1 -0
- nullius/catalogue/benchmarks/gaia/standard.json +278 -0
- nullius/catalogue/benchmarks/gaia/upstream-settings.json +275 -0
- nullius/catalogue/benchmarks/gsm8k/benchmark.json +34 -0
- nullius/catalogue/benchmarks/gsm8k/driver.py +101 -0
- nullius/catalogue/benchmarks/gsm8k/standard.json +124 -0
- nullius/catalogue/benchmarks/gsm8k/upstream-settings.json +86 -0
- nullius/catalogue/benchmarks/humaneval/benchmark.json +36 -0
- nullius/catalogue/benchmarks/humaneval/driver.py +243 -0
- nullius/catalogue/benchmarks/humaneval/standard.json +115 -0
- nullius/catalogue/benchmarks/humaneval/upstream-settings.json +72 -0
- nullius/catalogue/benchmarks/locomo/benchmark.json +43 -0
- nullius/catalogue/benchmarks/locomo/driver.py +270 -0
- nullius/catalogue/benchmarks/locomo/standard.json +265 -0
- nullius/catalogue/benchmarks/locomo/upstream-settings.json +112 -0
- nullius/catalogue/benchmarks/longmemeval/benchmark.json +65 -0
- nullius/catalogue/benchmarks/longmemeval/driver.py +379 -0
- nullius/catalogue/benchmarks/longmemeval/standard.json +733 -0
- nullius/catalogue/benchmarks/longmemeval/upstream-settings.json +76 -0
- nullius/catalogue/benchmarks/swe-bench-verified/benchmark.json +87 -0
- nullius/catalogue/benchmarks/swe-bench-verified/driver.py +116 -0
- nullius/catalogue/benchmarks/swe-bench-verified/images.json +502 -0
- nullius/catalogue/benchmarks/swe-bench-verified/standard.json +108 -0
- nullius/catalogue/benchmarks/swe-bench-verified/upstream-settings.json +32 -0
- nullius/catalogue/benchmarks/tau3-bench/benchmark.json +49 -0
- nullius/catalogue/benchmarks/tau3-bench/driver.py +608 -0
- nullius/catalogue/benchmarks/tau3-bench/mcp_server.py +114 -0
- nullius/catalogue/benchmarks/tau3-bench/search_relay.py +19 -0
- nullius/catalogue/benchmarks/tau3-bench/standard.json +547 -0
- nullius/catalogue/benchmarks/tau3-bench/upstream-settings.json +639 -0
- nullius/catalogue/benchmarks/terminal-bench/benchmark.json +69 -0
- nullius/catalogue/benchmarks/terminal-bench/driver.py +267 -0
- nullius/catalogue/benchmarks/terminal-bench/standard.json +166 -0
- nullius/catalogue/benchmarks/terminal-bench/upstream-settings.json +36 -0
- nullius/catalogue/capabilities/keyword-memory/capability.json +33 -0
- nullius/catalogue/capabilities/keyword-memory/capability.py +55 -0
- nullius/catalogue/capabilities/mem0/capability.json +135 -0
- nullius/catalogue/capabilities/mem0/capability.py +173 -0
- nullius/catalogue/catalog.py +426 -0
- nullius/catalogue/citation.py +116 -0
- nullius/catalogue/harbor_entry.py +367 -0
- nullius/catalogue/sources.py +107 -0
- nullius/catalogue/storage.py +125 -0
- nullius/cli.py +85 -0
- nullius/compare/__init__.py +0 -0
- nullius/compare/cli.py +265 -0
- nullius/compare/comparison.py +184 -0
- nullius/execution.py +1653 -0
- nullius/gitrefs.py +128 -0
- nullius/harbor/__init__.py +0 -0
- nullius/harbor/feed.py +228 -0
- nullius/harbor/source.py +582 -0
- nullius/hosts.py +368 -0
- nullius/importers/__init__.py +140 -0
- nullius/importers/atif.py +387 -0
- nullius/importers/cli.py +135 -0
- nullius/importers/otel.py +274 -0
- nullius/judge/__init__.py +14 -0
- nullius/judge/batch.py +122 -0
- nullius/judge/client.py +433 -0
- nullius/judge/floors.json +86 -0
- nullius/judge/lanes.py +89 -0
- nullius/judge/questions.py +309 -0
- nullius/judge/reconcile.py +176 -0
- nullius/judge/state.py +224 -0
- nullius/judge/store.py +167 -0
- nullius/migrate.py +268 -0
- nullius/onboarding.py +116 -0
- nullius/paths.py +89 -0
- nullius/prerequisites.py +129 -0
- nullius/prices.py +283 -0
- nullius/progress.py +294 -0
- nullius/providers.py +335 -0
- nullius/recipes/__init__.py +0 -0
- nullius/recipes/launch.py +78 -0
- nullius/redact.py +72 -0
- nullius/runs/__init__.py +0 -0
- nullius/runs/artifacts.py +67 -0
- nullius/runs/classify.py +216 -0
- nullius/runs/cli.py +316 -0
- nullius/runs/feasibility.py +442 -0
- nullius/runs/launches.py +149 -0
- nullius/runs/live.py +715 -0
- nullius/runs/parse.py +1016 -0
- nullius/runs/verifier.py +241 -0
- nullius/sandbox.py +109 -0
- nullius/secrets.py +218 -0
- nullius/settings.py +544 -0
- nullius/standard/__init__.py +15 -0
- nullius/standard/acp.py +305 -0
- nullius/standard/cancellation.py +19 -0
- nullius/standard/cli.py +703 -0
- nullius/standard/conform.py +149 -0
- nullius/standard/container.py +1870 -0
- nullius/standard/definitions.py +1651 -0
- nullius/standard/egress.py +192 -0
- nullius/standard/fidelity.py +256 -0
- nullius/standard/forward.py +139 -0
- nullius/standard/hostreq.py +105 -0
- nullius/standard/howto.py +220 -0
- nullius/standard/install.py +428 -0
- nullius/standard/job.py +551 -0
- nullius/standard/jsonl.py +129 -0
- nullius/standard/kits/agent-conversation-v1/driver.py +27 -0
- nullius/standard/kits/agent-conversation-v1/standard.json +26 -0
- nullius/standard/kits/agent-search-v1/driver.py +171 -0
- nullius/standard/kits/agent-search-v1/standard.json +99 -0
- nullius/standard/kits/agent-task-v1/driver.py +25 -0
- nullius/standard/kits/agent-task-v1/standard.json +100 -0
- nullius/standard/kits/agent-tools-v1/driver.py +206 -0
- nullius/standard/kits/agent-tools-v1/mcp_kit.py +209 -0
- nullius/standard/kits/agent-tools-v1/standard.json +119 -0
- nullius/standard/kits/agent-workspace-v1/driver.py +65 -0
- nullius/standard/kits/agent-workspace-v1/standard.json +95 -0
- nullius/standard/kits/cap-memory-v1/driver.py +39 -0
- nullius/standard/kits/cap-memory-v1/standard.json +91 -0
- nullius/standard/ledger.py +326 -0
- nullius/standard/match.py +66 -0
- nullius/standard/mcp_bridge.py +62 -0
- nullius/standard/mcp_machine.py +193 -0
- nullius/standard/merge.py +239 -0
- nullius/standard/names.py +37 -0
- nullius/standard/network_requirements.py +44 -0
- nullius/standard/pace.py +53 -0
- nullius/standard/payload.py +278 -0
- nullius/standard/pins.py +130 -0
- nullius/standard/ports.py +70 -0
- nullius/standard/prove.py +373 -0
- nullius/standard/recipe.py +746 -0
- nullius/standard/relay.py +785 -0
- nullius/standard/run.py +1781 -0
- nullius/standard/setup_container.py +208 -0
- nullius/standard/shard.py +71 -0
- nullius/standard/web_services.py +30 -0
- nullius/traces/__init__.py +0 -0
- nullius/traces/behavior.py +131 -0
- nullius/traces/charts.py +898 -0
- nullius/traces/conversation.py +159 -0
- nullius/traces/otel.py +608 -0
- nullius/traces/trace.py +1477 -0
- nullius/traces/trajectory.py +586 -0
- nullius/workspace.py +417 -0
- nullius/workspace_cli.py +119 -0
- nullius_eval-0.1.0.dist-info/METADATA +93 -0
- nullius_eval-0.1.0.dist-info/RECORD +291 -0
- nullius_eval-0.1.0.dist-info/WHEEL +5 -0
- nullius_eval-0.1.0.dist-info/entry_points.txt +2 -0
- nullius_eval-0.1.0.dist-info/licenses/LICENSE +202 -0
- nullius_eval-0.1.0.dist-info/licenses/app/static/fonts/dmsans-OFL.txt +93 -0
- nullius_eval-0.1.0.dist-info/licenses/app/static/fonts/ibmplexmono-OFL.txt +93 -0
- nullius_eval-0.1.0.dist-info/licenses/app/static/fonts/instrumentserif-OFL.txt +93 -0
- nullius_eval-0.1.0.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"""Bounded, read-only views of already parsed trajectory and trace evidence.
|
|
2
|
+
|
|
3
|
+
Search examines full redacted text; only twelve index entries and one 6,000
|
|
4
|
+
character content window leave this layer. Native step/call ids are retained.
|
|
5
|
+
Positions are separate zero-based navigation keys so gappy or repeated source
|
|
6
|
+
ids never change order. This module has no Flask or filesystem dependency.
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import json
|
|
11
|
+
import math
|
|
12
|
+
|
|
13
|
+
from nullius.redact import redact
|
|
14
|
+
|
|
15
|
+
PAGE_SIZE = 12
|
|
16
|
+
CHUNK_SIZE = 6000
|
|
17
|
+
KINDS = ("all", "messages", "tools", "errors")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _integer(value, default=0):
|
|
21
|
+
try:
|
|
22
|
+
return int(value)
|
|
23
|
+
except (TypeError, ValueError, OverflowError):
|
|
24
|
+
return default
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _text(value):
|
|
28
|
+
return redact(str(value)) if value is not None else ""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _preview(value, limit=135):
|
|
32
|
+
value = " ".join(_text(value).split())
|
|
33
|
+
return value[:limit] + ("…" if len(value) > limit else "")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _sections(step):
|
|
37
|
+
sections = []
|
|
38
|
+
if step.message and step.message != "(tool use)":
|
|
39
|
+
sections.append(("message", "Message", _text(step.message), {}))
|
|
40
|
+
for i, call in enumerate(step.tool_calls):
|
|
41
|
+
facts = {"tool_call_id": _text(call.get("tool_call_id")) if call.get("tool_call_id") is not None else None,
|
|
42
|
+
"tool": _text(call.get("name")),
|
|
43
|
+
"failure": _text(call.get("failure")),
|
|
44
|
+
"category": _text(call.get("category")),
|
|
45
|
+
"target": _preview(call.get("target"), 200),
|
|
46
|
+
"observation_characters": len(_text(call.get("observation")))}
|
|
47
|
+
sections.append((f"call-{i}-arguments", "Arguments", _text(call.get("arguments")), facts))
|
|
48
|
+
sections.append((f"call-{i}-observation", "Result", _text(call.get("observation")), facts))
|
|
49
|
+
return sections
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _content(sections, wanted, chunk):
|
|
53
|
+
"""Redact before slicing, including secrets crossing a chunk boundary."""
|
|
54
|
+
selected = next((s for s in sections if s[0] == wanted), sections[0] if sections else None)
|
|
55
|
+
if selected is None:
|
|
56
|
+
return None
|
|
57
|
+
key, label, text, facts = selected
|
|
58
|
+
pages = max(1, math.ceil(len(text) / CHUNK_SIZE))
|
|
59
|
+
index = min(max(0, _integer(chunk)), pages - 1)
|
|
60
|
+
start = index * CHUNK_SIZE
|
|
61
|
+
return {"key": key, "label": label, **facts,
|
|
62
|
+
"text": text[start:start + CHUNK_SIZE], "chunk": index,
|
|
63
|
+
"chunks": pages, "start": start, "end": min(start + CHUNK_SIZE, len(text)),
|
|
64
|
+
"characters": len(text)}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# A call's tool is the command it ran: the reader shows it whole, never cut.
|
|
68
|
+
FULL_FACTS = ("tool_call_id", "tool")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _section_index(sections):
|
|
72
|
+
return [{"key": key, "label": label, "characters": len(text),
|
|
73
|
+
**{k: _preview(v, 100) if isinstance(v, str) and k not in FULL_FACTS else v
|
|
74
|
+
for k, v in facts.items()}}
|
|
75
|
+
for key, label, text, facts in sections]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def page(traj, *, query="", kind="all", page=1, position=None, step=None,
|
|
79
|
+
section=None, chunk=0):
|
|
80
|
+
query = _text(query).strip()[:500]
|
|
81
|
+
kind = kind if kind in KINDS else "all"
|
|
82
|
+
result = {"query": query, "kind": kind, "page_size": PAGE_SIZE,
|
|
83
|
+
"page": 1, "pages": 1, "total": 0, "matches": 0,
|
|
84
|
+
"rows": [], "selected": None, "notice": ""}
|
|
85
|
+
if traj is None or traj.error:
|
|
86
|
+
result["notice"] = ("Trajectory unreadable: " + _text(traj.error)) if traj else "No trajectory recorded for this trial."
|
|
87
|
+
return result
|
|
88
|
+
result["total"] = len(traj.steps)
|
|
89
|
+
needle = query.casefold()
|
|
90
|
+
matching = []
|
|
91
|
+
for i, item in enumerate(traj.steps):
|
|
92
|
+
has_message = bool(item.message and item.message != "(tool use)")
|
|
93
|
+
has_tools = bool(item.tool_calls)
|
|
94
|
+
# Reuse the established reader's failure signals; an error-looking
|
|
95
|
+
# message is not a new failure classification or a benchmark verdict.
|
|
96
|
+
has_errors = any(c.get("failure") for c in item.tool_calls)
|
|
97
|
+
if not {"all": True, "messages": has_message, "tools": has_tools, "errors": has_errors}[kind]:
|
|
98
|
+
continue
|
|
99
|
+
texts = [str(item.step_id), _text(item.source), _text(item.message)]
|
|
100
|
+
for call in item.tool_calls:
|
|
101
|
+
texts.extend(_text(call.get(k)) for k in ("tool_call_id", "name", "arguments", "observation", "failure"))
|
|
102
|
+
if needle and not any(needle in text.casefold() for text in texts):
|
|
103
|
+
continue
|
|
104
|
+
matching.append(i)
|
|
105
|
+
result["matches"] = len(matching)
|
|
106
|
+
result["pages"] = max(1, math.ceil(len(matching) / PAGE_SIZE))
|
|
107
|
+
page_number = min(max(1, _integer(page, 1)), result["pages"])
|
|
108
|
+
selected_position = None
|
|
109
|
+
if step is not None:
|
|
110
|
+
selected_position = next((i for i in matching if str(traj.steps[i].step_id) == str(step)), None)
|
|
111
|
+
if selected_position is None:
|
|
112
|
+
result["notice"] = "That source step id is not in the current search and filter."
|
|
113
|
+
elif position is not None:
|
|
114
|
+
wanted = _integer(position, -1)
|
|
115
|
+
selected_position = wanted if wanted in matching else None
|
|
116
|
+
if selected_position is not None:
|
|
117
|
+
page_number = matching.index(selected_position) // PAGE_SIZE + 1
|
|
118
|
+
elif matching:
|
|
119
|
+
selected_position = matching[(page_number - 1) * PAGE_SIZE]
|
|
120
|
+
result["page"] = page_number
|
|
121
|
+
for i in matching[(page_number - 1) * PAGE_SIZE:page_number * PAGE_SIZE]:
|
|
122
|
+
item = traj.steps[i]
|
|
123
|
+
title = item.message if item.message and item.message != "(tool use)" else ", ".join(c.get("name", "Tool") for c in item.tool_calls)
|
|
124
|
+
result["rows"].append({"position": i, "step_id": item.step_id,
|
|
125
|
+
"source": _preview(item.source, 32), "preview": _preview(title) or "No message recorded",
|
|
126
|
+
"tools": len(item.tool_calls), "errors": sum(bool(c.get("failure")) for c in item.tool_calls)})
|
|
127
|
+
if selected_position is not None:
|
|
128
|
+
item = traj.steps[selected_position]
|
|
129
|
+
match_index = matching.index(selected_position)
|
|
130
|
+
sections = _sections(item)
|
|
131
|
+
result["selected"] = {"position": selected_position, "step_id": item.step_id,
|
|
132
|
+
"source": _text(item.source), "timestamp": _text(item.timestamp), "duration": item.dur,
|
|
133
|
+
"match_number": match_index + 1,
|
|
134
|
+
"previous": matching[match_index - 1] if match_index else None,
|
|
135
|
+
"next": matching[match_index + 1] if match_index + 1 < len(matching) else None,
|
|
136
|
+
"sections": _section_index(sections), "content": _content(sections, section, chunk)}
|
|
137
|
+
elif not result["notice"]:
|
|
138
|
+
result["notice"] = "No steps match this search and filter." if traj.steps else "The trajectory contains no recorded steps."
|
|
139
|
+
return result
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def span_detail(trace, span_id, *, section=None, chunk=0):
|
|
143
|
+
"""Select only a visible, normalised span; never rebuild from raw JSON."""
|
|
144
|
+
row = next((r for r in trace.rows if r.span.span_id == span_id), None) if trace else None
|
|
145
|
+
if row is None:
|
|
146
|
+
raise LookupError("Span not present in this trace view")
|
|
147
|
+
span = row.span
|
|
148
|
+
sections = [(f"content-{i}", _preview(label, 100), _text(text), {})
|
|
149
|
+
for i, (label, text) in enumerate(span.content)]
|
|
150
|
+
if span.tokens:
|
|
151
|
+
sections.append(("tokens", "Tokens", _text(json.dumps(span.tokens, indent=2, ensure_ascii=False)), {}))
|
|
152
|
+
if span.attributes:
|
|
153
|
+
sections.append(("attributes", "Attributes", _text("\n\n".join(f"{k}\n{v}" for k, v in span.attributes)), {}))
|
|
154
|
+
return {"span_id": span.span_id, "label": _preview(span.label, 200),
|
|
155
|
+
"name": _preview(span.name, 200), "kind": span.kind,
|
|
156
|
+
"timing_quality": span.timing_quality, "source": _preview(span.source, 100),
|
|
157
|
+
"merged": span.merged, "offset_ns": row.offset_ns,
|
|
158
|
+
"duration_ns": span.duration_ns, "sections": _section_index(sections),
|
|
159
|
+
"content": _content(sections, section, chunk)}
|