tracelabel 0.1.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.
Files changed (55) hide show
  1. tracelabel-0.1.0/.gitignore +49 -0
  2. tracelabel-0.1.0/LICENSE +201 -0
  3. tracelabel-0.1.0/PKG-INFO +176 -0
  4. tracelabel-0.1.0/README.md +137 -0
  5. tracelabel-0.1.0/pyproject.toml +71 -0
  6. tracelabel-0.1.0/src/tracelabel/__init__.py +1 -0
  7. tracelabel-0.1.0/src/tracelabel/__main__.py +4 -0
  8. tracelabel-0.1.0/src/tracelabel/api/__init__.py +0 -0
  9. tracelabel-0.1.0/src/tracelabel/api/app.py +40 -0
  10. tracelabel-0.1.0/src/tracelabel/api/labeling.py +202 -0
  11. tracelabel-0.1.0/src/tracelabel/api/models.py +92 -0
  12. tracelabel-0.1.0/src/tracelabel/api/routes.py +37 -0
  13. tracelabel-0.1.0/src/tracelabel/api/static.py +37 -0
  14. tracelabel-0.1.0/src/tracelabel/cli/__init__.py +0 -0
  15. tracelabel-0.1.0/src/tracelabel/cli/app.py +163 -0
  16. tracelabel-0.1.0/src/tracelabel/cli/commands.py +228 -0
  17. tracelabel-0.1.0/src/tracelabel/cli/options.py +30 -0
  18. tracelabel-0.1.0/src/tracelabel/cli/output.py +44 -0
  19. tracelabel-0.1.0/src/tracelabel/config/__init__.py +0 -0
  20. tracelabel-0.1.0/src/tracelabel/config/loader.py +51 -0
  21. tracelabel-0.1.0/src/tracelabel/config/models.py +96 -0
  22. tracelabel-0.1.0/src/tracelabel/config/presets.py +29 -0
  23. tracelabel-0.1.0/src/tracelabel/config/resolver.py +72 -0
  24. tracelabel-0.1.0/src/tracelabel/config/validation.py +144 -0
  25. tracelabel-0.1.0/src/tracelabel/ctf/__init__.py +0 -0
  26. tracelabel-0.1.0/src/tracelabel/ctf/content.py +35 -0
  27. tracelabel-0.1.0/src/tracelabel/ctf/hashing.py +31 -0
  28. tracelabel-0.1.0/src/tracelabel/ctf/models.py +78 -0
  29. tracelabel-0.1.0/src/tracelabel/ctf/validation.py +273 -0
  30. tracelabel-0.1.0/src/tracelabel/db/__init__.py +0 -0
  31. tracelabel-0.1.0/src/tracelabel/db/annotations.py +204 -0
  32. tracelabel-0.1.0/src/tracelabel/db/database.py +101 -0
  33. tracelabel-0.1.0/src/tracelabel/db/locking.py +100 -0
  34. tracelabel-0.1.0/src/tracelabel/db/migrations.py +94 -0
  35. tracelabel-0.1.0/src/tracelabel/db/tasks.py +159 -0
  36. tracelabel-0.1.0/src/tracelabel/db/traces.py +168 -0
  37. tracelabel-0.1.0/src/tracelabel/demo_data/traces.jsonl +25 -0
  38. tracelabel-0.1.0/src/tracelabel/errors.py +17 -0
  39. tracelabel-0.1.0/src/tracelabel/exporting/__init__.py +0 -0
  40. tracelabel-0.1.0/src/tracelabel/exporting/serializers.py +71 -0
  41. tracelabel-0.1.0/src/tracelabel/exporting/service.py +168 -0
  42. tracelabel-0.1.0/src/tracelabel/imports/__init__.py +0 -0
  43. tracelabel-0.1.0/src/tracelabel/imports/adapters/__init__.py +0 -0
  44. tracelabel-0.1.0/src/tracelabel/imports/adapters/adk.py +131 -0
  45. tracelabel-0.1.0/src/tracelabel/imports/adapters/base.py +65 -0
  46. tracelabel-0.1.0/src/tracelabel/imports/adapters/ctf.py +24 -0
  47. tracelabel-0.1.0/src/tracelabel/imports/adapters/datadog.py +149 -0
  48. tracelabel-0.1.0/src/tracelabel/imports/adapters/documents.py +45 -0
  49. tracelabel-0.1.0/src/tracelabel/imports/adapters/loose.py +144 -0
  50. tracelabel-0.1.0/src/tracelabel/imports/parsing.py +178 -0
  51. tracelabel-0.1.0/src/tracelabel/imports/service.py +113 -0
  52. tracelabel-0.1.0/src/tracelabel/suggestions/__init__.py +0 -0
  53. tracelabel-0.1.0/src/tracelabel/suggestions/client.py +75 -0
  54. tracelabel-0.1.0/src/tracelabel/suggestions/prompts.py +123 -0
  55. tracelabel-0.1.0/src/tracelabel/suggestions/service.py +203 -0
@@ -0,0 +1,49 @@
1
+ # Python bytecode and caches
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Virtual environments
7
+ .venv/
8
+ venv/
9
+
10
+ # Packaging/build artifacts
11
+ build/
12
+ dist/
13
+ *.egg-info/
14
+ pip-wheel-metadata/
15
+
16
+ # Test and type-checker caches
17
+ .pytest_cache/
18
+ .mypy_cache/
19
+ .ruff_cache/
20
+ .tox/
21
+ .nox/
22
+
23
+ # Coverage
24
+ .coverage
25
+ .coverage.*
26
+ htmlcov/
27
+
28
+ # Local environment files
29
+ .env
30
+ .env.*
31
+ .python-version
32
+
33
+ # Logs
34
+ *.log
35
+
36
+ # Jupyter
37
+ .ipynb_checkpoints/
38
+
39
+ # tracelabel runtime/build artifacts
40
+ src/tracelabel/static/
41
+ frontend/node_modules/
42
+ frontend/dist/
43
+ .tracelabel/
44
+ *.db
45
+
46
+ # OS/editor
47
+ .DS_Store
48
+ .idea/
49
+ *.iml
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work, excluding
103
+ those notices that do not pertain to any part of the Derivative
104
+ Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one of
111
+ the following places: within a NOTICE text file distributed as
112
+ part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and do
117
+ not modify the License. You may add Your own attribution notices
118
+ within Derivative Works that You distribute, alongside or as an
119
+ addendum to the NOTICE text from the Work, provided that such
120
+ additional attribution notices cannot be construed as modifying
121
+ the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions for
125
+ use, reproduction, or distribution of Your modifications, or for any
126
+ such Derivative Works as a whole, provided Your use, reproduction,
127
+ and distribution of the Work otherwise complies with the conditions
128
+ stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 2.4
2
+ Name: tracelabel
3
+ Version: 0.1.0
4
+ Summary: Local-first, zero-config labeling — keyboard-fast, no accounts, no server.
5
+ Project-URL: Homepage, https://github.com/Dkashkett/tracelabel
6
+ Project-URL: Repository, https://github.com/Dkashkett/tracelabel
7
+ Project-URL: Issues, https://github.com/Dkashkett/tracelabel/issues
8
+ Author: Daniel Kashkett
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: agents,annotation,eval,labeling,llm,traces
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Environment :: Web Environment
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Topic :: Software Development :: Libraries
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: fastapi
25
+ Requires-Dist: pydantic>=2
26
+ Requires-Dist: pyyaml
27
+ Requires-Dist: typer
28
+ Requires-Dist: uvicorn
29
+ Provides-Extra: ai
30
+ Requires-Dist: litellm; extra == 'ai'
31
+ Provides-Extra: dev
32
+ Requires-Dist: httpx; extra == 'dev'
33
+ Requires-Dist: hypothesis; extra == 'dev'
34
+ Requires-Dist: mypy; extra == 'dev'
35
+ Requires-Dist: pre-commit; extra == 'dev'
36
+ Requires-Dist: pytest; extra == 'dev'
37
+ Requires-Dist: ruff; extra == 'dev'
38
+ Description-Content-Type: text/markdown
39
+
40
+ # tracelabel [![Release](https://github.com/Dkashkett/tracelabel/actions/workflows/release.yml/badge.svg)](https://github.com/Dkashkett/tracelabel/actions/workflows/release.yml)
41
+
42
+ **Local-first, zero-config labeling for agent traces — keyboard-fast, no accounts, no server.**
43
+
44
+ One `pip install`. One command. Your browser opens on a keyboard-driven labeling UI over your
45
+ own traces. No sign-up, no cloud, no Node, no database to stand up. It's a single Python wheel
46
+ that bundles a FastAPI server, a prebuilt React app, and SQLite — one `.db` file per project.
47
+
48
+ ```bash
49
+ uvx tracelabel demo
50
+ ```
51
+
52
+ ![demo](https://raw.githubusercontent.com/Dkashkett/tracelabel/main/docs/demo.gif)
53
+
54
+ Press `j` to jump to the first labelable turn, `1` to mark it **pass**, `Enter` to commit and
55
+ advance. That's the whole loop.
56
+
57
+ ## Quickstart
58
+
59
+ ```bash
60
+ pip install tracelabel # or: uvx tracelabel ...
61
+ tracelabel serve traces.jsonl # opens http://127.0.0.1:8377 in your browser
62
+ tracelabel export # → <task>-annotations.jsonl
63
+ ```
64
+
65
+ Your traces are a UTF-8 [JSONL](https://github.com/Dkashkett/tracelabel/blob/main/docs/trace-format.md)
66
+ file, one trace per line. No config needed
67
+ — tracelabel defaults to a turn-level pass/fail task. Point it at a file and start labeling.
68
+
69
+ Labeling freeform documents (notes, transcripts, policy pages) instead of agent traces works
70
+ the same way — either a folder of files, or a JSONL of documents:
71
+
72
+ ```bash
73
+ tracelabel serve ./docs # every .md/.txt/.html/.htm file in the folder, one trace each
74
+ ```
75
+
76
+ ```jsonl
77
+ "A plain document is just a string."
78
+ {"content": "# Report\n\nFindings go here.", "content_type": "markdown", "id": "report-1"}
79
+ ```
80
+
81
+ Documents label at the trace level (there's nothing to break into turns) and Markdown renders
82
+ with real formatting in the UI.
83
+
84
+ ## Your traces never leave your machine
85
+
86
+ The server binds `127.0.0.1` only — there is no `--host` flag and no auth, because nothing is
87
+ ever exposed off your loopback interface. **There is no telemetry, period** — not opt-in, not
88
+ opt-out. The *only* outbound network call this package can make is a model call you explicitly
89
+ trigger by running `tracelabel suggest` (which uses your own API key from your own environment).
90
+
91
+ > **Your traces never leave your machine unless _you_ run `suggest`.**
92
+
93
+ API keys are read from environment variables only; putting an `api_key:` in your config is a
94
+ hard error, and keys are never logged and never written to the database.
95
+
96
+ ## Configuring the task
97
+
98
+ Drop a `config.yaml` next to your data (or pass `--config`). Everything not specified falls back
99
+ to sensible defaults; unknown keys are hard errors with a pointed message.
100
+
101
+ ```yaml
102
+ name: empathy
103
+ level: turn # label per-turn (default) or per-trace
104
+ label_roles: [assistant] # which roles are labelable
105
+ fields:
106
+ - name: verdict
107
+ type: single_select
108
+ options: [pass, fail]
109
+ required: true
110
+ - name: failure_modes
111
+ type: multi_select
112
+ options: [hallucination, refused, wrong_tool, formatting]
113
+ - name: notes
114
+ type: text
115
+ ```
116
+
117
+ Field types map one-to-one to UI controls and to export columns. Add a field, get a new keyboard
118
+ target and a new column — no redesign.
119
+
120
+ ## Export → pandas
121
+
122
+ Export is a pure database read with a stable column contract. Long format (one row per
123
+ annotation) by default; `--joined` folds in the turn/trace content so you never join back to the
124
+ source.
125
+
126
+ ```python
127
+ import pandas as pd
128
+ df = pd.read_json("empathy-annotations.jsonl", lines=True)
129
+ df.groupby("task")["values"].apply(lambda v: (pd.json_normalize(v)["verdict"] == "pass").mean())
130
+ ```
131
+
132
+ See [`docs/pandas.md`](https://github.com/Dkashkett/tracelabel/blob/main/docs/pandas.md) for a
133
+ groupby recipe per field type.
134
+
135
+ ## When to use something else
136
+
137
+ tracelabel is deliberately small. Reach for a full platform when you need what it doesn't do:
138
+
139
+ - **[Label Studio](https://labelstud.io/) / [Argilla](https://argilla.io/)** — hosted
140
+ multi-annotator platforms with accounts, projects, review workflows, and rich media (images,
141
+ audio, bounding boxes). tracelabel is single-player, text/JSON/HTML/Markdown only, and runs
142
+ on your laptop.
143
+ - Use tracelabel when you want to label agent traces *right now*, keyboard-fast, without standing
144
+ up infrastructure or sending your data anywhere.
145
+
146
+ ## Teams
147
+
148
+ tracelabel is single-player today — one annotator, one db file. But the schema is already
149
+ multi-annotator ready (every annotation carries an `annotator` and a `schema_hash`), so teams
150
+ aren't a dead end. The planned answer is:
151
+
152
+ ```bash
153
+ tracelabel merge alice.db bob.db # (planned) combine independent annotators' db files
154
+ ```
155
+
156
+ Each person labels locally into their own `.db`; you merge and compute agreement offline. Nothing
157
+ about the storage format needs to change to get there.
158
+
159
+ ## Security posture
160
+
161
+ - **Loopback only.** Binds `127.0.0.1`; no `--host` flag exists.
162
+ - **No telemetry, ever.** The only outbound calls are `suggest`'s explicit model calls.
163
+ - **Untrusted HTML is sandboxed.** HTML traces render in an iframe with an empty `sandbox`
164
+ attribute; there is no `dangerouslySetInnerHTML` anywhere in the app.
165
+ - **Strict config.** Unknown/typo'd config keys are hard errors; `api_key:` in YAML is rejected.
166
+ - **Tiny dependency surface.** Runtime core is `fastapi`, `uvicorn`, `pydantic`, `typer`,
167
+ `pyyaml`; `litellm` is an optional `[ai]` extra; shadcn/ui is vendored, not a dependency.
168
+
169
+ ## Install methods
170
+
171
+ Works via `pip install tracelabel`, `uvx tracelabel`, and `python -m tracelabel`. Requires
172
+ Python ≥ 3.10. Runs on macOS, Linux, and Windows.
173
+
174
+ ## License
175
+
176
+ [Apache-2.0](LICENSE).
@@ -0,0 +1,137 @@
1
+ # tracelabel [![Release](https://github.com/Dkashkett/tracelabel/actions/workflows/release.yml/badge.svg)](https://github.com/Dkashkett/tracelabel/actions/workflows/release.yml)
2
+
3
+ **Local-first, zero-config labeling for agent traces — keyboard-fast, no accounts, no server.**
4
+
5
+ One `pip install`. One command. Your browser opens on a keyboard-driven labeling UI over your
6
+ own traces. No sign-up, no cloud, no Node, no database to stand up. It's a single Python wheel
7
+ that bundles a FastAPI server, a prebuilt React app, and SQLite — one `.db` file per project.
8
+
9
+ ```bash
10
+ uvx tracelabel demo
11
+ ```
12
+
13
+ ![demo](https://raw.githubusercontent.com/Dkashkett/tracelabel/main/docs/demo.gif)
14
+
15
+ Press `j` to jump to the first labelable turn, `1` to mark it **pass**, `Enter` to commit and
16
+ advance. That's the whole loop.
17
+
18
+ ## Quickstart
19
+
20
+ ```bash
21
+ pip install tracelabel # or: uvx tracelabel ...
22
+ tracelabel serve traces.jsonl # opens http://127.0.0.1:8377 in your browser
23
+ tracelabel export # → <task>-annotations.jsonl
24
+ ```
25
+
26
+ Your traces are a UTF-8 [JSONL](https://github.com/Dkashkett/tracelabel/blob/main/docs/trace-format.md)
27
+ file, one trace per line. No config needed
28
+ — tracelabel defaults to a turn-level pass/fail task. Point it at a file and start labeling.
29
+
30
+ Labeling freeform documents (notes, transcripts, policy pages) instead of agent traces works
31
+ the same way — either a folder of files, or a JSONL of documents:
32
+
33
+ ```bash
34
+ tracelabel serve ./docs # every .md/.txt/.html/.htm file in the folder, one trace each
35
+ ```
36
+
37
+ ```jsonl
38
+ "A plain document is just a string."
39
+ {"content": "# Report\n\nFindings go here.", "content_type": "markdown", "id": "report-1"}
40
+ ```
41
+
42
+ Documents label at the trace level (there's nothing to break into turns) and Markdown renders
43
+ with real formatting in the UI.
44
+
45
+ ## Your traces never leave your machine
46
+
47
+ The server binds `127.0.0.1` only — there is no `--host` flag and no auth, because nothing is
48
+ ever exposed off your loopback interface. **There is no telemetry, period** — not opt-in, not
49
+ opt-out. The *only* outbound network call this package can make is a model call you explicitly
50
+ trigger by running `tracelabel suggest` (which uses your own API key from your own environment).
51
+
52
+ > **Your traces never leave your machine unless _you_ run `suggest`.**
53
+
54
+ API keys are read from environment variables only; putting an `api_key:` in your config is a
55
+ hard error, and keys are never logged and never written to the database.
56
+
57
+ ## Configuring the task
58
+
59
+ Drop a `config.yaml` next to your data (or pass `--config`). Everything not specified falls back
60
+ to sensible defaults; unknown keys are hard errors with a pointed message.
61
+
62
+ ```yaml
63
+ name: empathy
64
+ level: turn # label per-turn (default) or per-trace
65
+ label_roles: [assistant] # which roles are labelable
66
+ fields:
67
+ - name: verdict
68
+ type: single_select
69
+ options: [pass, fail]
70
+ required: true
71
+ - name: failure_modes
72
+ type: multi_select
73
+ options: [hallucination, refused, wrong_tool, formatting]
74
+ - name: notes
75
+ type: text
76
+ ```
77
+
78
+ Field types map one-to-one to UI controls and to export columns. Add a field, get a new keyboard
79
+ target and a new column — no redesign.
80
+
81
+ ## Export → pandas
82
+
83
+ Export is a pure database read with a stable column contract. Long format (one row per
84
+ annotation) by default; `--joined` folds in the turn/trace content so you never join back to the
85
+ source.
86
+
87
+ ```python
88
+ import pandas as pd
89
+ df = pd.read_json("empathy-annotations.jsonl", lines=True)
90
+ df.groupby("task")["values"].apply(lambda v: (pd.json_normalize(v)["verdict"] == "pass").mean())
91
+ ```
92
+
93
+ See [`docs/pandas.md`](https://github.com/Dkashkett/tracelabel/blob/main/docs/pandas.md) for a
94
+ groupby recipe per field type.
95
+
96
+ ## When to use something else
97
+
98
+ tracelabel is deliberately small. Reach for a full platform when you need what it doesn't do:
99
+
100
+ - **[Label Studio](https://labelstud.io/) / [Argilla](https://argilla.io/)** — hosted
101
+ multi-annotator platforms with accounts, projects, review workflows, and rich media (images,
102
+ audio, bounding boxes). tracelabel is single-player, text/JSON/HTML/Markdown only, and runs
103
+ on your laptop.
104
+ - Use tracelabel when you want to label agent traces *right now*, keyboard-fast, without standing
105
+ up infrastructure or sending your data anywhere.
106
+
107
+ ## Teams
108
+
109
+ tracelabel is single-player today — one annotator, one db file. But the schema is already
110
+ multi-annotator ready (every annotation carries an `annotator` and a `schema_hash`), so teams
111
+ aren't a dead end. The planned answer is:
112
+
113
+ ```bash
114
+ tracelabel merge alice.db bob.db # (planned) combine independent annotators' db files
115
+ ```
116
+
117
+ Each person labels locally into their own `.db`; you merge and compute agreement offline. Nothing
118
+ about the storage format needs to change to get there.
119
+
120
+ ## Security posture
121
+
122
+ - **Loopback only.** Binds `127.0.0.1`; no `--host` flag exists.
123
+ - **No telemetry, ever.** The only outbound calls are `suggest`'s explicit model calls.
124
+ - **Untrusted HTML is sandboxed.** HTML traces render in an iframe with an empty `sandbox`
125
+ attribute; there is no `dangerouslySetInnerHTML` anywhere in the app.
126
+ - **Strict config.** Unknown/typo'd config keys are hard errors; `api_key:` in YAML is rejected.
127
+ - **Tiny dependency surface.** Runtime core is `fastapi`, `uvicorn`, `pydantic`, `typer`,
128
+ `pyyaml`; `litellm` is an optional `[ai]` extra; shadcn/ui is vendored, not a dependency.
129
+
130
+ ## Install methods
131
+
132
+ Works via `pip install tracelabel`, `uvx tracelabel`, and `python -m tracelabel`. Requires
133
+ Python ≥ 3.10. Runs on macOS, Linux, and Windows.
134
+
135
+ ## License
136
+
137
+ [Apache-2.0](LICENSE).
@@ -0,0 +1,71 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "tracelabel"
7
+ version = "0.1.0"
8
+ description = "Local-first, zero-config labeling — keyboard-fast, no accounts, no server."
9
+ readme = "README.md"
10
+ authors = [{ name = "Daniel Kashkett" }]
11
+ requires-python = ">=3.10"
12
+ license = "Apache-2.0"
13
+ keywords = ["labeling", "annotation", "llm", "agents", "eval", "traces"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Environment :: Console",
17
+ "Environment :: Web Environment",
18
+ "Intended Audience :: Developers",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
25
+ "Topic :: Software Development :: Libraries",
26
+ ]
27
+ dependencies = [
28
+ "fastapi",
29
+ "uvicorn",
30
+ "pydantic>=2",
31
+ "typer",
32
+ "pyyaml",
33
+ ]
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/Dkashkett/tracelabel"
37
+ Repository = "https://github.com/Dkashkett/tracelabel"
38
+ Issues = "https://github.com/Dkashkett/tracelabel/issues"
39
+
40
+ [project.optional-dependencies]
41
+ ai = ["litellm"]
42
+ dev = ["pytest", "hypothesis", "httpx", "ruff", "mypy", "pre-commit"]
43
+
44
+ [project.scripts]
45
+ tracelabel = "tracelabel.cli.app:run"
46
+
47
+ [tool.hatch.build.targets.wheel]
48
+ packages = ["src/tracelabel"]
49
+ artifacts = [
50
+ "src/tracelabel/static/**",
51
+ "src/tracelabel/demo_data/**",
52
+ ]
53
+
54
+ [tool.hatch.build.targets.sdist]
55
+ include = [
56
+ "src/tracelabel/**",
57
+ "README.md",
58
+ ]
59
+
60
+ [tool.ruff]
61
+ target-version = "py310"
62
+ line-length = 100
63
+ src = ["src", "tests"]
64
+
65
+ [tool.ruff.lint]
66
+ select = ["E", "F", "I", "UP", "B"]
67
+
68
+ [tool.mypy]
69
+ python_version = "3.10"
70
+ strict = true
71
+ files = ["src/tracelabel"]
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -0,0 +1,4 @@
1
+ from tracelabel.cli.app import run
2
+
3
+ if __name__ == "__main__":
4
+ run()
File without changes