traceforge-toolkit 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.
- traceforge/__init__.py +72 -0
- traceforge/__main__.py +5 -0
- traceforge/_generated.py +254 -0
- traceforge/adapters/__init__.py +12 -0
- traceforge/adapters/base.py +82 -0
- traceforge/adapters/genai_otel.py +164 -0
- traceforge/adapters/mapped_json.py +297 -0
- traceforge/adapters/otel.py +220 -0
- traceforge/boundary/__init__.py +46 -0
- traceforge/boundary/data/boundary-model.joblib +0 -0
- traceforge/boundary/decode.py +87 -0
- traceforge/boundary/features.py +137 -0
- traceforge/boundary/inference.py +267 -0
- traceforge/boundary/inferencer.py +146 -0
- traceforge/classify/__init__.py +95 -0
- traceforge/classify/cmd.py +109 -0
- traceforge/classify/coding.py +213 -0
- traceforge/classify/config.py +554 -0
- traceforge/classify/core.py +266 -0
- traceforge/classify/data/binary_info.yaml +358 -0
- traceforge/classify/data/canonical_tools.yaml +251 -0
- traceforge/classify/data/effect_overrides.yaml +480 -0
- traceforge/classify/data/mcp_profiles.yaml +711 -0
- traceforge/classify/data/recommendation_rules.yaml +111 -0
- traceforge/classify/data/risk.yaml +534 -0
- traceforge/classify/data/shell_defaults.yaml +95 -0
- traceforge/classify/data/shell_rules.yaml +1192 -0
- traceforge/classify/data/tool_classifications.yaml +215 -0
- traceforge/classify/data/verb_inference.yaml +218 -0
- traceforge/classify/mcp.py +181 -0
- traceforge/classify/phases.py +75 -0
- traceforge/classify/powershell.py +93 -0
- traceforge/classify/registry.py +138 -0
- traceforge/classify/risk.py +553 -0
- traceforge/classify/rules.py +215 -0
- traceforge/classify/schema.yaml +282 -0
- traceforge/classify/shell.py +503 -0
- traceforge/classify/tools.py +91 -0
- traceforge/classify/workflow.py +32 -0
- traceforge/cli/__init__.py +42 -0
- traceforge/cli/config_cmd.py +130 -0
- traceforge/cli/detect.py +46 -0
- traceforge/cli/download_cmd.py +74 -0
- traceforge/cli/factory.py +60 -0
- traceforge/cli/gate_cmd.py +30 -0
- traceforge/cli/init_cmd.py +86 -0
- traceforge/cli/replay.py +130 -0
- traceforge/cli/runner.py +181 -0
- traceforge/cli/score.py +217 -0
- traceforge/cli/status.py +65 -0
- traceforge/cli/watch.py +297 -0
- traceforge/config/__init__.py +80 -0
- traceforge/config/defaults.py +149 -0
- traceforge/config/loader.py +239 -0
- traceforge/config/mappings.py +104 -0
- traceforge/config/models.py +579 -0
- traceforge/enricher.py +576 -0
- traceforge/formatting/__init__.py +12 -0
- traceforge/formatting/budget.py +92 -0
- traceforge/formatting/density.py +154 -0
- traceforge/gate/__init__.py +17 -0
- traceforge/gate/client.py +145 -0
- traceforge/gate/external.py +305 -0
- traceforge/gate/registry.py +108 -0
- traceforge/gate/server.py +174 -0
- traceforge/gates/__init__.py +8 -0
- traceforge/gates/pii.py +352 -0
- traceforge/gates/pii_patterns.yaml +228 -0
- traceforge/governance/__init__.py +121 -0
- traceforge/governance/assessor.py +441 -0
- traceforge/governance/budget.py +59 -0
- traceforge/governance/canonical.py +56 -0
- traceforge/governance/codec.py +414 -0
- traceforge/governance/context.py +249 -0
- traceforge/governance/drift.py +196 -0
- traceforge/governance/emitter.py +234 -0
- traceforge/governance/envelope.py +138 -0
- traceforge/governance/ifc.py +364 -0
- traceforge/governance/integrity.py +162 -0
- traceforge/governance/labeler.py +250 -0
- traceforge/governance/mcp_drift.py +328 -0
- traceforge/governance/monitor.py +539 -0
- traceforge/governance/observer.py +276 -0
- traceforge/governance/persistence.py +401 -0
- traceforge/governance/phase1.py +77 -0
- traceforge/governance/pii.py +276 -0
- traceforge/governance/pipeline.py +840 -0
- traceforge/governance/registry.py +110 -0
- traceforge/governance/results.py +183 -0
- traceforge/governance/risk_wrapper.py +113 -0
- traceforge/governance/rules.py +368 -0
- traceforge/governance/scorer.py +262 -0
- traceforge/governance/shield.py +318 -0
- traceforge/governance/state.py +466 -0
- traceforge/governance/types.py +176 -0
- traceforge/mappings/__init__.py +1 -0
- traceforge/mappings/aider.yaml +216 -0
- traceforge/mappings/aider_markdown.yaml +113 -0
- traceforge/mappings/amazonq.yaml +56 -0
- traceforge/mappings/antigravity.yaml +88 -0
- traceforge/mappings/claude.yaml +93 -0
- traceforge/mappings/cline.yaml +286 -0
- traceforge/mappings/codex.yaml +158 -0
- traceforge/mappings/continue_dev.yaml +57 -0
- traceforge/mappings/copilot.yaml +266 -0
- traceforge/mappings/copilot_markdown.yaml +72 -0
- traceforge/mappings/copilot_vscode.yaml +181 -0
- traceforge/mappings/crewai.yaml +592 -0
- traceforge/mappings/goose.yaml +128 -0
- traceforge/mappings/langgraph.yaml +165 -0
- traceforge/mappings/maf.yaml +90 -0
- traceforge/mappings/maf_transcript.yaml +99 -0
- traceforge/mappings/openai_agents.yaml +144 -0
- traceforge/mappings/opencode.yaml +473 -0
- traceforge/mappings/openhands.yaml +320 -0
- traceforge/mappings/pydantic_ai.yaml +183 -0
- traceforge/mappings/smolagents.yaml +89 -0
- traceforge/mappings/sweagent.yaml +82 -0
- traceforge/migrations/__init__.py +1 -0
- traceforge/migrations/env.py +60 -0
- traceforge/migrations/models.py +145 -0
- traceforge/migrations/runner.py +44 -0
- traceforge/migrations/script.py.mako +25 -0
- traceforge/migrations/versions/0001_initial.py +176 -0
- traceforge/migrations/versions/__init__.py +4 -0
- traceforge/models.py +29 -0
- traceforge/parsers/__init__.py +21 -0
- traceforge/parsers/aider.py +416 -0
- traceforge/parsers/base.py +226 -0
- traceforge/parsers/copilot.py +314 -0
- traceforge/phase/__init__.py +50 -0
- traceforge/phase/data/phase-model.joblib +0 -0
- traceforge/phase/data/potion-base-8M/README.md +99 -0
- traceforge/phase/data/potion-base-8M/config.json +13 -0
- traceforge/phase/data/potion-base-8M/model.safetensors +0 -0
- traceforge/phase/data/potion-base-8M/modules.json +14 -0
- traceforge/phase/data/potion-base-8M/tokenizer.json +1 -0
- traceforge/phase/event_rows.py +107 -0
- traceforge/phase/features.py +468 -0
- traceforge/phase/inference.py +279 -0
- traceforge/phase/inferencer.py +171 -0
- traceforge/phase/segmentation.py +258 -0
- traceforge/pipeline.py +891 -0
- traceforge/preprocessors/__init__.py +34 -0
- traceforge/preprocessors/amazonq.py +224 -0
- traceforge/preprocessors/antigravity.py +116 -0
- traceforge/preprocessors/claude.py +95 -0
- traceforge/preprocessors/cline.py +36 -0
- traceforge/preprocessors/codex.py +311 -0
- traceforge/preprocessors/continue_dev.py +119 -0
- traceforge/preprocessors/copilot_vscode.py +171 -0
- traceforge/preprocessors/goose.py +156 -0
- traceforge/preprocessors/maf_transcript.py +84 -0
- traceforge/preprocessors/openai_agents.py +86 -0
- traceforge/preprocessors/opencode.py +85 -0
- traceforge/preprocessors/openhands.py +36 -0
- traceforge/preprocessors/pydantic_ai.py +62 -0
- traceforge/preprocessors/registry.py +24 -0
- traceforge/preprocessors/smolagents.py +90 -0
- traceforge/py.typed +0 -0
- traceforge/sdk/__init__.py +59 -0
- traceforge/sdk/gate_policy.py +63 -0
- traceforge/sdk/gate_types.py +140 -0
- traceforge/sdk/pipeline.py +265 -0
- traceforge/sdk/verdict.py +81 -0
- traceforge/sinks/__init__.py +23 -0
- traceforge/sinks/base.py +95 -0
- traceforge/sinks/callback.py +132 -0
- traceforge/sinks/console.py +112 -0
- traceforge/sinks/factory.py +94 -0
- traceforge/sinks/jsonl.py +125 -0
- traceforge/sinks/otel_exporter.py +212 -0
- traceforge/sinks/parquet.py +260 -0
- traceforge/sinks/s3.py +206 -0
- traceforge/sinks/sqlite_output.py +234 -0
- traceforge/sinks/webhook.py +136 -0
- traceforge/sources/__init__.py +18 -0
- traceforge/sources/auto_detect.py +173 -0
- traceforge/sources/base.py +45 -0
- traceforge/sources/file_poll.py +136 -0
- traceforge/sources/file_watch.py +221 -0
- traceforge/sources/http_poll.py +141 -0
- traceforge/sources/replay.py +63 -0
- traceforge/sources/sqlite.py +187 -0
- traceforge/sources/sse.py +198 -0
- traceforge/telemetry/__init__.py +192 -0
- traceforge/title/__init__.py +23 -0
- traceforge/title/_resolve.py +79 -0
- traceforge/title/context.py +295 -0
- traceforge/title/data/boilerplate_files.json +14 -0
- traceforge/title/heuristics.py +429 -0
- traceforge/title/hygiene.py +90 -0
- traceforge/title/inference.py +314 -0
- traceforge/title/inferencer.py +477 -0
- traceforge/title/naming.py +398 -0
- traceforge/trace.py +291 -0
- traceforge/tracking/__init__.py +30 -0
- traceforge/tracking/models.py +115 -0
- traceforge/tracking/phase_tracker.py +288 -0
- traceforge/types.py +315 -0
- traceforge_toolkit-0.1.0.dist-info/METADATA +188 -0
- traceforge_toolkit-0.1.0.dist-info/RECORD +205 -0
- traceforge_toolkit-0.1.0.dist-info/WHEEL +4 -0
- traceforge_toolkit-0.1.0.dist-info/entry_points.txt +2 -0
- traceforge_toolkit-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# OpenHands event mapping for MappedJsonAdapter
|
|
2
|
+
# Targets: openhands >= 0.30 legacy events and >= 1.0 SDK event-store files
|
|
3
|
+
# Sources:
|
|
4
|
+
# - All-Hands-AI/OpenHands openhands/events/serialization/event.py (0.x)
|
|
5
|
+
# - OpenHands SDK event persistence (1.x): events/event-*.json
|
|
6
|
+
#
|
|
7
|
+
# NOTE: v1.0+ moved to SDK Pydantic events with kind=ActionEvent /
|
|
8
|
+
# ObservationEvent / MessageEvent / SystemPromptEvent. The preprocessor
|
|
9
|
+
# synthesizes ActionEvent.<tool_name>, ObservationEvent.<tool_name>, and
|
|
10
|
+
# MessageEvent.<source> discriminators for those rows.
|
|
11
|
+
#
|
|
12
|
+
# CRITICAL: OpenHands uses a COMPOUND discriminator:
|
|
13
|
+
# - Action events have: {"action": "run", "args": {...}}
|
|
14
|
+
# - Observation events have: {"observation": "run", "content": "...", "extras": {...}}
|
|
15
|
+
#
|
|
16
|
+
# An OpenHandsPreProcessor synthesizes compound types:
|
|
17
|
+
# "action" key → type = action value (e.g. "run")
|
|
18
|
+
# "observation" key → type = "observation.<value>" (e.g. "observation.run")
|
|
19
|
+
#
|
|
20
|
+
# Serialization rules (event_to_dict):
|
|
21
|
+
# - TOP_KEYS hoisted: id, timestamp, source, message, cause, action/observation,
|
|
22
|
+
# tool_call_metadata, llm_metrics
|
|
23
|
+
# - Actions: all dataclass fields → "args" dict
|
|
24
|
+
# - Observations: "content" hoisted to top-level, remaining fields → "extras" dict
|
|
25
|
+
# - CmdOutputMetadata: serialized via model_dump() into extras.metadata
|
|
26
|
+
|
|
27
|
+
framework: openhands
|
|
28
|
+
framework_version: ">=0.30,<2.0"
|
|
29
|
+
ingestion_mode: file_watch
|
|
30
|
+
type_field: action
|
|
31
|
+
timestamp_field: timestamp
|
|
32
|
+
preprocessor: openhands
|
|
33
|
+
|
|
34
|
+
events:
|
|
35
|
+
# ── OpenHands 1.x SDK event-store rows (real — discriminated by "kind") ──
|
|
36
|
+
SystemPromptEvent:
|
|
37
|
+
kind: message.system
|
|
38
|
+
payload:
|
|
39
|
+
content: system_prompt.text
|
|
40
|
+
tools: tools
|
|
41
|
+
source: source
|
|
42
|
+
MessageEvent.user:
|
|
43
|
+
kind: message.user
|
|
44
|
+
payload:
|
|
45
|
+
content: llm_message.content.0.text
|
|
46
|
+
source: source
|
|
47
|
+
MessageEvent.agent:
|
|
48
|
+
kind: message.assistant
|
|
49
|
+
payload:
|
|
50
|
+
content: llm_message.content.0.text
|
|
51
|
+
source: source
|
|
52
|
+
ActionEvent.terminal:
|
|
53
|
+
kind: command.started
|
|
54
|
+
payload:
|
|
55
|
+
command: action.command
|
|
56
|
+
summary: summary
|
|
57
|
+
tool_call_id: tool_call_id
|
|
58
|
+
source: source
|
|
59
|
+
ObservationEvent.terminal:
|
|
60
|
+
kind: command.completed
|
|
61
|
+
payload:
|
|
62
|
+
command: observation.command
|
|
63
|
+
content: observation.content.0.text
|
|
64
|
+
exit_code: observation.exit_code
|
|
65
|
+
tool_call_id: tool_call_id
|
|
66
|
+
source: source
|
|
67
|
+
ActionEvent.apply_patch:
|
|
68
|
+
kind: file.edited
|
|
69
|
+
payload:
|
|
70
|
+
patch: action.patch
|
|
71
|
+
summary: summary
|
|
72
|
+
tool_call_id: tool_call_id
|
|
73
|
+
source: source
|
|
74
|
+
ObservationEvent.apply_patch:
|
|
75
|
+
kind: tool.output
|
|
76
|
+
payload:
|
|
77
|
+
content: observation.content.0.text
|
|
78
|
+
is_error: observation.is_error
|
|
79
|
+
tool_call_id: tool_call_id
|
|
80
|
+
source: source
|
|
81
|
+
ActionEvent.task_tracker:
|
|
82
|
+
kind: session.info
|
|
83
|
+
payload:
|
|
84
|
+
command: action.command
|
|
85
|
+
summary: summary
|
|
86
|
+
tool_call_id: tool_call_id
|
|
87
|
+
source: source
|
|
88
|
+
ObservationEvent.task_tracker:
|
|
89
|
+
kind: session.info
|
|
90
|
+
payload:
|
|
91
|
+
content: observation.content.0.text
|
|
92
|
+
is_error: observation.is_error
|
|
93
|
+
tool_call_id: tool_call_id
|
|
94
|
+
source: source
|
|
95
|
+
ActionEvent.finish:
|
|
96
|
+
kind: session.ended
|
|
97
|
+
payload:
|
|
98
|
+
output: action.message
|
|
99
|
+
summary: summary
|
|
100
|
+
tool_call_id: tool_call_id
|
|
101
|
+
source: source
|
|
102
|
+
ObservationEvent.finish:
|
|
103
|
+
kind: session.ended
|
|
104
|
+
payload:
|
|
105
|
+
output: observation.content.0.text
|
|
106
|
+
is_error: observation.is_error
|
|
107
|
+
tool_call_id: tool_call_id
|
|
108
|
+
source: source
|
|
109
|
+
|
|
110
|
+
# ── Action events (real — discriminated by "action" field value) ──
|
|
111
|
+
run:
|
|
112
|
+
kind: command.started
|
|
113
|
+
payload:
|
|
114
|
+
command: args.command
|
|
115
|
+
thought: args.thought
|
|
116
|
+
source: source
|
|
117
|
+
run_ipython:
|
|
118
|
+
kind: command.started
|
|
119
|
+
payload:
|
|
120
|
+
command: args.code
|
|
121
|
+
source: source
|
|
122
|
+
think:
|
|
123
|
+
kind: reasoning.started
|
|
124
|
+
payload:
|
|
125
|
+
content: args.thought
|
|
126
|
+
source: source
|
|
127
|
+
finish:
|
|
128
|
+
kind: session.ended
|
|
129
|
+
payload:
|
|
130
|
+
output: args.outputs.content
|
|
131
|
+
source: source
|
|
132
|
+
message:
|
|
133
|
+
kind: message.user
|
|
134
|
+
payload:
|
|
135
|
+
content: args.content
|
|
136
|
+
source: source
|
|
137
|
+
delegate:
|
|
138
|
+
kind: agent.spawned
|
|
139
|
+
payload:
|
|
140
|
+
agent_id: args.agent
|
|
141
|
+
task: args.inputs.task
|
|
142
|
+
source: source
|
|
143
|
+
reject:
|
|
144
|
+
kind: session.abort
|
|
145
|
+
payload:
|
|
146
|
+
message: args.outputs.reason
|
|
147
|
+
source: source
|
|
148
|
+
browse:
|
|
149
|
+
kind: browser.launched
|
|
150
|
+
payload:
|
|
151
|
+
url: args.url
|
|
152
|
+
source: source
|
|
153
|
+
browse_interactive:
|
|
154
|
+
kind: browser.action
|
|
155
|
+
payload:
|
|
156
|
+
actions: args.browser_actions
|
|
157
|
+
source: source
|
|
158
|
+
read:
|
|
159
|
+
kind: file.read
|
|
160
|
+
payload:
|
|
161
|
+
path: args.path
|
|
162
|
+
source: source
|
|
163
|
+
write:
|
|
164
|
+
kind: file.edited
|
|
165
|
+
payload:
|
|
166
|
+
path: args.path
|
|
167
|
+
content: args.content
|
|
168
|
+
source: source
|
|
169
|
+
edit:
|
|
170
|
+
kind: file.edited
|
|
171
|
+
payload:
|
|
172
|
+
path: args.path
|
|
173
|
+
source: source
|
|
174
|
+
recall:
|
|
175
|
+
kind: memory.query.started
|
|
176
|
+
payload:
|
|
177
|
+
query: args.query
|
|
178
|
+
source: source
|
|
179
|
+
call_tool_mcp:
|
|
180
|
+
kind: mcp.tool.started
|
|
181
|
+
payload:
|
|
182
|
+
tool_name: args.name
|
|
183
|
+
arguments: args.arguments
|
|
184
|
+
thought: args.thought
|
|
185
|
+
source: source
|
|
186
|
+
condensation:
|
|
187
|
+
kind: session.info
|
|
188
|
+
payload:
|
|
189
|
+
summary: args.summary
|
|
190
|
+
source: source
|
|
191
|
+
change_agent_state:
|
|
192
|
+
kind: agent.state_changed
|
|
193
|
+
payload:
|
|
194
|
+
agent_state: args.agent_state
|
|
195
|
+
thought: args.thought
|
|
196
|
+
source: source
|
|
197
|
+
system:
|
|
198
|
+
kind: message.system
|
|
199
|
+
payload:
|
|
200
|
+
content: args.content
|
|
201
|
+
agent_class: args.agent_class
|
|
202
|
+
source: source
|
|
203
|
+
|
|
204
|
+
# ── New actions (#41: openhands 0.62 additive) ──
|
|
205
|
+
condensation_request:
|
|
206
|
+
kind: session.info
|
|
207
|
+
payload:
|
|
208
|
+
source: source
|
|
209
|
+
task_tracking:
|
|
210
|
+
kind: session.info
|
|
211
|
+
payload:
|
|
212
|
+
command: args.command
|
|
213
|
+
task_list: args.task_list
|
|
214
|
+
thought: args.thought
|
|
215
|
+
source: source
|
|
216
|
+
loop_recovery:
|
|
217
|
+
kind: session.info
|
|
218
|
+
payload:
|
|
219
|
+
option: args.option
|
|
220
|
+
source: source
|
|
221
|
+
|
|
222
|
+
# ── Observation events (preprocessor synthesizes action: "observation.<value>") ──
|
|
223
|
+
observation.run:
|
|
224
|
+
kind: command.completed
|
|
225
|
+
payload:
|
|
226
|
+
content: content
|
|
227
|
+
exit_code: extras.metadata.exit_code
|
|
228
|
+
source: source
|
|
229
|
+
observation.run_ipython:
|
|
230
|
+
kind: command.completed
|
|
231
|
+
payload:
|
|
232
|
+
content: content
|
|
233
|
+
source: source
|
|
234
|
+
observation.browse:
|
|
235
|
+
kind: browser.result
|
|
236
|
+
payload:
|
|
237
|
+
content: content
|
|
238
|
+
url: extras.url
|
|
239
|
+
source: source
|
|
240
|
+
observation.read:
|
|
241
|
+
kind: file.read
|
|
242
|
+
payload:
|
|
243
|
+
path: extras.path
|
|
244
|
+
content: content
|
|
245
|
+
source: source
|
|
246
|
+
observation.write:
|
|
247
|
+
kind: file.edited
|
|
248
|
+
payload:
|
|
249
|
+
path: extras.path
|
|
250
|
+
source: source
|
|
251
|
+
observation.edit:
|
|
252
|
+
kind: file.edited
|
|
253
|
+
payload:
|
|
254
|
+
path: extras.path
|
|
255
|
+
source: source
|
|
256
|
+
observation.error:
|
|
257
|
+
kind: session.error
|
|
258
|
+
payload:
|
|
259
|
+
message: content
|
|
260
|
+
source: source
|
|
261
|
+
observation.agent_state_changed:
|
|
262
|
+
kind: session.info
|
|
263
|
+
payload:
|
|
264
|
+
content: content
|
|
265
|
+
source: source
|
|
266
|
+
observation.delegate:
|
|
267
|
+
kind: agent.completed
|
|
268
|
+
payload:
|
|
269
|
+
output: content
|
|
270
|
+
source: source
|
|
271
|
+
observation.recall:
|
|
272
|
+
kind: memory.query.completed
|
|
273
|
+
payload:
|
|
274
|
+
content: content
|
|
275
|
+
source: source
|
|
276
|
+
observation.success:
|
|
277
|
+
kind: session.ended
|
|
278
|
+
payload:
|
|
279
|
+
output: content
|
|
280
|
+
source: source
|
|
281
|
+
observation.think:
|
|
282
|
+
kind: reasoning.completed
|
|
283
|
+
payload:
|
|
284
|
+
content: content
|
|
285
|
+
source: source
|
|
286
|
+
observation.user_rejected:
|
|
287
|
+
kind: session.abort
|
|
288
|
+
payload:
|
|
289
|
+
message: content
|
|
290
|
+
source: source
|
|
291
|
+
observation.condense:
|
|
292
|
+
kind: session.info
|
|
293
|
+
payload:
|
|
294
|
+
content: content
|
|
295
|
+
source: source
|
|
296
|
+
observation.mcp:
|
|
297
|
+
kind: mcp.tool.completed
|
|
298
|
+
payload:
|
|
299
|
+
content: content
|
|
300
|
+
source: source
|
|
301
|
+
|
|
302
|
+
# ── New observations (#41: openhands 0.62 additive) ──
|
|
303
|
+
observation.download:
|
|
304
|
+
kind: file.read
|
|
305
|
+
payload:
|
|
306
|
+
file_path: extras.file_path
|
|
307
|
+
content: content
|
|
308
|
+
source: source
|
|
309
|
+
observation.task_tracking:
|
|
310
|
+
kind: session.info
|
|
311
|
+
payload:
|
|
312
|
+
command: extras.command
|
|
313
|
+
task_list: extras.task_list
|
|
314
|
+
content: content
|
|
315
|
+
source: source
|
|
316
|
+
observation.loop_detection:
|
|
317
|
+
kind: session.info
|
|
318
|
+
payload:
|
|
319
|
+
content: content
|
|
320
|
+
source: source
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# PydanticAI event mapping for MappedJsonAdapter
|
|
2
|
+
# Targets: pydantic-ai >= 1.0.0 (preprocessor-emitted JSONL)
|
|
3
|
+
# Source: pydantic/pydantic-ai pydantic_ai_slim/pydantic_ai/messages.py
|
|
4
|
+
#
|
|
5
|
+
# CRITICAL: PydanticAI does NOT emit flat JSON events with a "type" field.
|
|
6
|
+
# Its native format uses multi-level discrimination:
|
|
7
|
+
# - Messages: "kind" = "request" | "response"
|
|
8
|
+
# - Parts: "part_kind" = "system-prompt" | "user-prompt" | "text" | "tool-call" | ...
|
|
9
|
+
# - Stream events: "event_kind" = "part_start" | "part_delta" | "part_end" | ...
|
|
10
|
+
# - Usage: ModelResponse.usage = {input_tokens, output_tokens, ...}
|
|
11
|
+
#
|
|
12
|
+
# This YAML assumes a PydanticAIPreProcessor normalizes the native format to
|
|
13
|
+
# flat JSONL with a "type" discriminator. The preprocessor MUST synthesize:
|
|
14
|
+
# {"type": "model_response", "usage": {...}, ...}
|
|
15
|
+
# {"type": "stream.part_start", "part": {...}, ...}
|
|
16
|
+
# {"type": "stream.part_delta", "delta": {...}, ...}
|
|
17
|
+
#
|
|
18
|
+
# Real UsageMetadata fields: input_tokens, output_tokens,
|
|
19
|
+
# cache_write_tokens, cache_read_tokens
|
|
20
|
+
# NOTE: total_tokens is a @property (input+output), NOT a stored field.
|
|
21
|
+
# It will NOT appear in model_dump() unless explicitly computed by preprocessor.
|
|
22
|
+
# Real tool call field: tool_call_id (not call_id — call_id is deprecated alias)
|
|
23
|
+
|
|
24
|
+
framework: pydantic_ai
|
|
25
|
+
framework_version: ">=1.0.0"
|
|
26
|
+
ingestion_mode: file_watch
|
|
27
|
+
type_field: type
|
|
28
|
+
timestamp_field: timestamp
|
|
29
|
+
preprocessor: pydantic_ai
|
|
30
|
+
|
|
31
|
+
motivation:
|
|
32
|
+
sources:
|
|
33
|
+
- events: ["model_text_response"]
|
|
34
|
+
field: content
|
|
35
|
+
role: intent
|
|
36
|
+
|
|
37
|
+
events:
|
|
38
|
+
# ── Agent lifecycle ──
|
|
39
|
+
agent_run_start:
|
|
40
|
+
kind: session.started
|
|
41
|
+
payload:
|
|
42
|
+
agent_name: agent_name
|
|
43
|
+
model: model_name
|
|
44
|
+
agent_run_end:
|
|
45
|
+
kind: session.ended
|
|
46
|
+
payload:
|
|
47
|
+
agent_name: agent_name
|
|
48
|
+
result: result
|
|
49
|
+
agent_run_error:
|
|
50
|
+
kind: session.error
|
|
51
|
+
payload:
|
|
52
|
+
agent_name: agent_name
|
|
53
|
+
message: error
|
|
54
|
+
|
|
55
|
+
# ── Model calls ──
|
|
56
|
+
model_request_start:
|
|
57
|
+
kind: llm.call.started
|
|
58
|
+
payload:
|
|
59
|
+
model: model_name
|
|
60
|
+
request_id: request_id
|
|
61
|
+
model_request:
|
|
62
|
+
kind: message.user
|
|
63
|
+
payload:
|
|
64
|
+
content: content
|
|
65
|
+
model_response:
|
|
66
|
+
kind: llm.call.completed
|
|
67
|
+
payload:
|
|
68
|
+
model: model_name
|
|
69
|
+
input_tokens: usage.input_tokens
|
|
70
|
+
output_tokens: usage.output_tokens
|
|
71
|
+
cache_read_tokens: usage.cache_read_tokens
|
|
72
|
+
cache_write_tokens: usage.cache_write_tokens
|
|
73
|
+
input_audio_tokens: usage.input_audio_tokens
|
|
74
|
+
output_audio_tokens: usage.output_audio_tokens
|
|
75
|
+
cache_audio_read_tokens: usage.cache_audio_read_tokens
|
|
76
|
+
content: content
|
|
77
|
+
model_request_error:
|
|
78
|
+
kind: llm.call.failed
|
|
79
|
+
payload:
|
|
80
|
+
model: model_name
|
|
81
|
+
error: error
|
|
82
|
+
|
|
83
|
+
# ── Tool calls ──
|
|
84
|
+
tool_call_start:
|
|
85
|
+
kind: tool.call.started
|
|
86
|
+
payload:
|
|
87
|
+
tool_name: tool_name
|
|
88
|
+
tool_call_id: tool_call_id
|
|
89
|
+
arguments: args
|
|
90
|
+
tool_call_end:
|
|
91
|
+
kind: tool.call.completed
|
|
92
|
+
payload:
|
|
93
|
+
tool_call_id: tool_call_id
|
|
94
|
+
tool_name: tool_name
|
|
95
|
+
result: result
|
|
96
|
+
tool_call_error:
|
|
97
|
+
kind: tool.call.failed
|
|
98
|
+
payload:
|
|
99
|
+
tool_call_id: tool_call_id
|
|
100
|
+
tool_name: tool_name
|
|
101
|
+
error: error
|
|
102
|
+
|
|
103
|
+
# ── Messages ──
|
|
104
|
+
user_message:
|
|
105
|
+
kind: message.user
|
|
106
|
+
payload:
|
|
107
|
+
content: content
|
|
108
|
+
model_text_response:
|
|
109
|
+
kind: message.assistant
|
|
110
|
+
payload:
|
|
111
|
+
content: content
|
|
112
|
+
model_structured_response:
|
|
113
|
+
kind: message.assistant
|
|
114
|
+
payload:
|
|
115
|
+
content: data
|
|
116
|
+
|
|
117
|
+
# ── Streaming (preprocessor synthesizes "stream.<event_kind>") ──
|
|
118
|
+
# PartStartEvent has .part (the part object), NOT .delta
|
|
119
|
+
stream.part_start:
|
|
120
|
+
kind: llm.output.chunk
|
|
121
|
+
payload:
|
|
122
|
+
content: part.content
|
|
123
|
+
part_kind: part.part_kind
|
|
124
|
+
# PartDeltaEvent has .delta with content_delta
|
|
125
|
+
# PartDeltaEvent: TextPartDelta has .content_delta; ToolCallPartDelta has .args_delta
|
|
126
|
+
# Discriminator: delta.part_delta_kind ("text" vs "tool_call")
|
|
127
|
+
stream.part_delta:
|
|
128
|
+
kind: llm.output.chunk
|
|
129
|
+
payload:
|
|
130
|
+
content: delta.content_delta
|
|
131
|
+
args_delta: delta.args_delta
|
|
132
|
+
part_delta_kind: delta.part_delta_kind
|
|
133
|
+
stream.part_end:
|
|
134
|
+
kind: message.assistant
|
|
135
|
+
payload:
|
|
136
|
+
content: part.content
|
|
137
|
+
# FinalResultEvent (event_kind="final_result") — signal-only, no content payload.
|
|
138
|
+
# Indicates which tool call produced the final result; actual data was in prior PartStart/Delta.
|
|
139
|
+
stream.final_result:
|
|
140
|
+
kind: session.ended
|
|
141
|
+
payload:
|
|
142
|
+
tool_name: tool_name
|
|
143
|
+
tool_call_id: tool_call_id
|
|
144
|
+
model_response_chunk:
|
|
145
|
+
kind: llm.output.chunk
|
|
146
|
+
payload:
|
|
147
|
+
content: chunk
|
|
148
|
+
|
|
149
|
+
# ── Retries / validation ──
|
|
150
|
+
validation_error:
|
|
151
|
+
kind: tool.validation.failed
|
|
152
|
+
payload:
|
|
153
|
+
tool_name: tool_name
|
|
154
|
+
error: error
|
|
155
|
+
retry_count: retry_count
|
|
156
|
+
retry:
|
|
157
|
+
kind: session.error
|
|
158
|
+
payload:
|
|
159
|
+
message: reason
|
|
160
|
+
attempt: attempt
|
|
161
|
+
|
|
162
|
+
# ── Telemetry (from model response usage) ──
|
|
163
|
+
token_usage:
|
|
164
|
+
kind: telemetry.usage
|
|
165
|
+
payload:
|
|
166
|
+
input_tokens: usage.input_tokens
|
|
167
|
+
output_tokens: usage.output_tokens
|
|
168
|
+
model: model_name
|
|
169
|
+
|
|
170
|
+
# ── Output validation (SDK calls this "output_validator") ──
|
|
171
|
+
output_validation_start:
|
|
172
|
+
kind: guardrail.started
|
|
173
|
+
payload:
|
|
174
|
+
validator: validator_name
|
|
175
|
+
output_validation_pass:
|
|
176
|
+
kind: guardrail.passed
|
|
177
|
+
payload:
|
|
178
|
+
validator: validator_name
|
|
179
|
+
output_validation_fail:
|
|
180
|
+
kind: guardrail.failed
|
|
181
|
+
payload:
|
|
182
|
+
validator: validator_name
|
|
183
|
+
reason: error
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# smolagents (HuggingFace) event mapping for MappedJsonAdapter
|
|
2
|
+
# Targets: smolagents >= 1.0 (preprocessor-emitted JSONL)
|
|
3
|
+
# Source: huggingface/smolagents src/smolagents/memory.py, agents.py
|
|
4
|
+
#
|
|
5
|
+
# CRITICAL: smolagents does NOT have a "step_type" discriminator field.
|
|
6
|
+
# Step type is inferred from FIELD PRESENCE in the serialized dict:
|
|
7
|
+
# - has "step_number" → ActionStep
|
|
8
|
+
# - has "plan" → PlanningStep
|
|
9
|
+
# - has "task" (and no step_number) → TaskStep
|
|
10
|
+
# - has "system_prompt" → SystemPromptStep
|
|
11
|
+
# - has ONLY "output" key → FinalAnswerStep
|
|
12
|
+
#
|
|
13
|
+
# Real ActionStep.dict() keys:
|
|
14
|
+
# step_number, timing (start_time, end_time, duration), model_input_messages,
|
|
15
|
+
# tool_calls, error, model_output_message, model_output, observations,
|
|
16
|
+
# action_output, code_action, observations_images, token_usage, is_final_answer
|
|
17
|
+
#
|
|
18
|
+
# Real ToolCall dict: {id, type: "function", function: {name, arguments}}
|
|
19
|
+
# Real TokenUsage: {input_tokens, output_tokens, total_tokens}
|
|
20
|
+
#
|
|
21
|
+
# FinalAnswer: When is_final_answer=true on ActionStep, the action_output IS the answer.
|
|
22
|
+
# There is also a bare FinalAnswerStep with only {"output": value}.
|
|
23
|
+
#
|
|
24
|
+
# ManagedAgent does NOT exist as a class. Multi-agent calls appear as regular ToolCalls.
|
|
25
|
+
#
|
|
26
|
+
# This YAML assumes a SmolagentsPreProcessor that adds a "step_type" field:
|
|
27
|
+
# {"step_type": "ActionStep", "step_number": 1, ...}
|
|
28
|
+
# {"step_type": "ToolCall", "tool_name": "web_search", ...}
|
|
29
|
+
|
|
30
|
+
framework: smolagents
|
|
31
|
+
framework_version: ">=1.0"
|
|
32
|
+
ingestion_mode: file_watch
|
|
33
|
+
type_field: step_type
|
|
34
|
+
timestamp_field: timestamp
|
|
35
|
+
preprocessor: smolagents
|
|
36
|
+
|
|
37
|
+
motivation:
|
|
38
|
+
sources:
|
|
39
|
+
- events: ["ActionStep"]
|
|
40
|
+
field: content
|
|
41
|
+
role: intent
|
|
42
|
+
targets: ["tool.call.started"]
|
|
43
|
+
|
|
44
|
+
events:
|
|
45
|
+
# ── Real step types (preprocessor infers from field presence) ──
|
|
46
|
+
ActionStep:
|
|
47
|
+
kind: message.assistant
|
|
48
|
+
payload:
|
|
49
|
+
content: model_output
|
|
50
|
+
observations: observations
|
|
51
|
+
step_number: step_number
|
|
52
|
+
code_action: code_action
|
|
53
|
+
error: error
|
|
54
|
+
action_output: action_output
|
|
55
|
+
input_tokens: token_usage.input_tokens
|
|
56
|
+
output_tokens: token_usage.output_tokens
|
|
57
|
+
start_time: timing.start_time
|
|
58
|
+
end_time: timing.end_time
|
|
59
|
+
duration: timing.duration
|
|
60
|
+
PlanningStep:
|
|
61
|
+
kind: planning.started
|
|
62
|
+
payload:
|
|
63
|
+
content: plan
|
|
64
|
+
input_tokens: token_usage.input_tokens
|
|
65
|
+
output_tokens: token_usage.output_tokens
|
|
66
|
+
start_time: timing.start_time
|
|
67
|
+
end_time: timing.end_time
|
|
68
|
+
duration: timing.duration
|
|
69
|
+
TaskStep:
|
|
70
|
+
kind: session.started
|
|
71
|
+
payload:
|
|
72
|
+
task: task
|
|
73
|
+
task_images: task_images
|
|
74
|
+
SystemPromptStep:
|
|
75
|
+
kind: message.system
|
|
76
|
+
payload:
|
|
77
|
+
content: system_prompt
|
|
78
|
+
FinalAnswer:
|
|
79
|
+
kind: session.ended
|
|
80
|
+
payload:
|
|
81
|
+
output: output
|
|
82
|
+
|
|
83
|
+
# ── Tool calls (preprocessor splits from ActionStep.tool_calls array) ──
|
|
84
|
+
ToolCall:
|
|
85
|
+
kind: tool.call.started
|
|
86
|
+
payload:
|
|
87
|
+
tool_name: tool_name
|
|
88
|
+
tool_call_id: call_id
|
|
89
|
+
arguments: tool_input
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# SWE-agent trajectory mapping for MappedJsonAdapter
|
|
2
|
+
# Targets: sweagent >= 1.0 (trajectory JSON files with history[] array)
|
|
3
|
+
# Source: SWE-agent/SWE-agent sweagent/types.py, sweagent/agent/agents.py
|
|
4
|
+
#
|
|
5
|
+
# SWE-agent stores two arrays in .traj files:
|
|
6
|
+
# - trajectory[]: action/observation pairs (unmapped — no role discriminator)
|
|
7
|
+
# - history[]: chat messages with role (system/user/assistant/tool)
|
|
8
|
+
#
|
|
9
|
+
# This YAML maps the history[] format (role-discriminated).
|
|
10
|
+
#
|
|
11
|
+
# IMPORTANT: history entries have NO per-entry timestamps.
|
|
12
|
+
# Each entry has: role, content, agent, message_type, and optionally
|
|
13
|
+
# tool_calls (OpenAI format), tool_call_ids, is_demo, tags, cache_control.
|
|
14
|
+
# NOTE: thinking_blocks exists in unreleased HEAD but NOT in v1.1.0 stable.
|
|
15
|
+
#
|
|
16
|
+
# message_type values: "action" (assistant), "observation" (user/tool),
|
|
17
|
+
# "system_prompt" (system), "demonstration" (user)
|
|
18
|
+
#
|
|
19
|
+
# Top-level .traj also has info.model_stats (InstanceStats) with:
|
|
20
|
+
# instance_cost, tokens_sent, tokens_received, api_calls
|
|
21
|
+
# These require a preprocessor to extract (not role-discriminated history entries).
|
|
22
|
+
|
|
23
|
+
framework: sweagent
|
|
24
|
+
framework_version: ">=1.0"
|
|
25
|
+
ingestion_mode: file_watch
|
|
26
|
+
type_field: role
|
|
27
|
+
timestamp_field: null
|
|
28
|
+
|
|
29
|
+
motivation:
|
|
30
|
+
sources:
|
|
31
|
+
- events: ["assistant"]
|
|
32
|
+
field: content
|
|
33
|
+
role: intent
|
|
34
|
+
targets: ["tool.output"]
|
|
35
|
+
|
|
36
|
+
events:
|
|
37
|
+
# ── Agent actions (assistant entries always have message_type="action") ──
|
|
38
|
+
assistant:
|
|
39
|
+
kind: message.assistant
|
|
40
|
+
payload:
|
|
41
|
+
content: content
|
|
42
|
+
thought: thought
|
|
43
|
+
action: action
|
|
44
|
+
tool_calls: tool_calls
|
|
45
|
+
thinking_blocks: thinking_blocks
|
|
46
|
+
agent: agent
|
|
47
|
+
message_type: message_type
|
|
48
|
+
is_demo: is_demo
|
|
49
|
+
tags: tags
|
|
50
|
+
cache_control: cache_control
|
|
51
|
+
|
|
52
|
+
# ── Tool responses (role: tool — OpenAI function-calling responses) ──
|
|
53
|
+
tool:
|
|
54
|
+
kind: tool.output
|
|
55
|
+
payload:
|
|
56
|
+
content: content
|
|
57
|
+
tool_call_ids: tool_call_ids
|
|
58
|
+
agent: agent
|
|
59
|
+
message_type: message_type
|
|
60
|
+
is_demo: is_demo
|
|
61
|
+
tags: tags
|
|
62
|
+
cache_control: cache_control
|
|
63
|
+
|
|
64
|
+
# ── System prompt (role: system, message_type="system_prompt") ──
|
|
65
|
+
system:
|
|
66
|
+
kind: message.system
|
|
67
|
+
payload:
|
|
68
|
+
content: content
|
|
69
|
+
agent: agent
|
|
70
|
+
message_type: message_type
|
|
71
|
+
cache_control: cache_control
|
|
72
|
+
|
|
73
|
+
# ── User messages (task setup, observations in non-FC mode, demos) ──
|
|
74
|
+
user:
|
|
75
|
+
kind: message.user
|
|
76
|
+
payload:
|
|
77
|
+
content: content
|
|
78
|
+
message_type: message_type
|
|
79
|
+
agent: agent
|
|
80
|
+
is_demo: is_demo
|
|
81
|
+
tags: tags
|
|
82
|
+
cache_control: cache_control
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Alembic migrations for traceforge system storage."""
|