evalkit-py 0.3.0.dev28__py3-none-any.whl → 0.3.0.dev30__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.
Files changed (51) hide show
  1. evalkit/api/otel.py +10 -4
  2. evalkit/api/pull.py +1 -1
  3. evalkit/bundled/contracts/span-mapping-v1.json +178 -2
  4. evalkit/bundled/docs/mappings.md +21 -1
  5. evalkit/bundled/docs/tracing.md +11 -2
  6. evalkit/bundled/skills/authoring-eval-cases/SKILL.md +2 -1
  7. evalkit/bundled/skills/authoring-eval-cases/references/overlays.md +2 -1
  8. evalkit/bundled/skills/connect-traces/SKILL.md +24 -12
  9. evalkit/bundled/skills/connect-traces/references/span-mapping-schema.md +29 -3
  10. evalkit/bundled/skills/eval-driven-development/SKILL.md +40 -8
  11. evalkit/bundled/skills/eval-driven-development/references/analyze-run.md +1 -1
  12. evalkit/bundled/skills/eval-driven-development/references/synthesize-cases.md +4 -3
  13. evalkit/bundled/skills/evalkit-usage/SKILL.md +3 -1
  14. evalkit/bundled/ui/assets/{cssMode-C3N68ICz.js → cssMode-CB2UtVNz.js} +1 -1
  15. evalkit/bundled/ui/assets/{editor.api-D1rxHWTF.js → editor.api-fo8vSfal.js} +1 -1
  16. evalkit/bundled/ui/assets/{freemarker2-CtAJgev6.js → freemarker2-Houw5cwT.js} +1 -1
  17. evalkit/bundled/ui/assets/{handlebars-BwD-dTI2.js → handlebars-Cnd1GmWB.js} +1 -1
  18. evalkit/bundled/ui/assets/{html-qsGdzg3l.js → html-BEVo7glS.js} +1 -1
  19. evalkit/bundled/ui/assets/{htmlMode-Cai1v-Ix.js → htmlMode-BCUXe8vJ.js} +1 -1
  20. evalkit/bundled/ui/assets/{index-uL5Ox6Wl.js → index-D9CgZyHZ.js} +24 -4
  21. evalkit/bundled/ui/assets/{javascript-CjSrkLpv.js → javascript-CuU8gNyb.js} +1 -1
  22. evalkit/bundled/ui/assets/{jsonMode-BnVnDvgV.js → jsonMode-ChcfNbxH.js} +1 -1
  23. evalkit/bundled/ui/assets/{liquid-rQuWUkse.js → liquid-DDafCz9C.js} +1 -1
  24. evalkit/bundled/ui/assets/{lspLanguageFeatures-BieGLabF.js → lspLanguageFeatures-C5BxQo0O.js} +1 -1
  25. evalkit/bundled/ui/assets/{mdx-BgHduSm2.js → mdx-C-UsPZkO.js} +1 -1
  26. evalkit/bundled/ui/assets/{monacoEditor-DS_lvlYa.js → monacoEditor-gFD6ch3Y.js} +4 -4
  27. evalkit/bundled/ui/assets/{python-DoC0juMr.js → python-DO1OrfiE.js} +1 -1
  28. evalkit/bundled/ui/assets/{razor-Ddn-d7Oz.js → razor-DDIJV18w.js} +1 -1
  29. evalkit/bundled/ui/assets/{tsMode-Sno7luy5.js → tsMode-DWVZTlNB.js} +1 -1
  30. evalkit/bundled/ui/assets/{typescript-UXz5THvW.js → typescript-LrKYGQ1t.js} +1 -1
  31. evalkit/bundled/ui/assets/{workers-GTw2k376.js → workers-Bd9MSI6m.js} +1 -1
  32. evalkit/bundled/ui/assets/{xml-Bfn1M0Fx.js → xml-6GJQ1Yjv.js} +1 -1
  33. evalkit/bundled/ui/assets/{yaml-DjeJzq3Z.js → yaml-DPCmvdc2.js} +1 -1
  34. evalkit/bundled/ui/index.html +1 -1
  35. evalkit/cli/traces_commands.py +3 -98
  36. evalkit/contracts/esf.py +53 -3
  37. evalkit/core/pull.py +7 -1
  38. evalkit/core/traces/check.py +156 -0
  39. evalkit/core/traces/convert.py +51 -28
  40. evalkit/core/traces/mapping.py +48 -2
  41. evalkit/core/traces/raw.py +1 -0
  42. evalkit/core/traces/sessions.py +1 -1
  43. evalkit/db/alembic/versions/0015_span_scope.py +23 -0
  44. evalkit/db/models.py +1 -0
  45. evalkit/db/spans.py +3 -0
  46. evalkit/sdk/runner.py +4 -1
  47. {evalkit_py-0.3.0.dev28.dist-info → evalkit_py-0.3.0.dev30.dist-info}/METADATA +1 -1
  48. {evalkit_py-0.3.0.dev28.dist-info → evalkit_py-0.3.0.dev30.dist-info}/RECORD +51 -49
  49. {evalkit_py-0.3.0.dev28.dist-info → evalkit_py-0.3.0.dev30.dist-info}/WHEEL +0 -0
  50. {evalkit_py-0.3.0.dev28.dist-info → evalkit_py-0.3.0.dev30.dist-info}/entry_points.txt +0 -0
  51. {evalkit_py-0.3.0.dev28.dist-info → evalkit_py-0.3.0.dev30.dist-info}/licenses/LICENSE +0 -0
evalkit/api/otel.py CHANGED
@@ -75,7 +75,7 @@ def _iso(nanos: int) -> str | None:
75
75
  return at.isoformat() if at else None
76
76
 
77
77
 
78
- def _from_proto(span: ProtoSpan, resource: dict[str, Any]) -> RawSpan:
78
+ def _from_proto(span: ProtoSpan, resource: dict[str, Any], scope: str | None) -> RawSpan:
79
79
  start = _time(span.start_time_unix_nano)
80
80
  if start is None:
81
81
  raise HTTPException(status_code=400, detail=f"span {span.name!r} has no start time")
@@ -99,6 +99,7 @@ def _from_proto(span: ProtoSpan, resource: dict[str, Any]) -> RawSpan:
99
99
  for e in span.events
100
100
  ],
101
101
  resource=resource,
102
+ scope=scope,
102
103
  )
103
104
 
104
105
 
@@ -124,7 +125,7 @@ def _json_attributes(items: list[dict[str, Any]] | None) -> dict[str, Any]:
124
125
  return {kv["key"]: _json_any(kv.get("value", {})) for kv in items or []}
125
126
 
126
127
 
127
- def _from_json(span: dict[str, Any], resource: dict[str, Any]) -> RawSpan:
128
+ def _from_json(span: dict[str, Any], resource: dict[str, Any], scope: str | None) -> RawSpan:
128
129
  start = _time(int(span.get("startTimeUnixNano") or 0))
129
130
  if start is None:
130
131
  raise HTTPException(status_code=400, detail="span without startTimeUnixNano")
@@ -149,6 +150,7 @@ def _from_json(span: dict[str, Any], resource: dict[str, Any]) -> RawSpan:
149
150
  for e in span.get("events") or []
150
151
  ],
151
152
  resource=resource,
153
+ scope=scope,
152
154
  )
153
155
 
154
156
 
@@ -159,14 +161,18 @@ def _decode(body: bytes, content_type: str) -> list[RawSpan]:
159
161
  for resource_spans in request.resource_spans:
160
162
  resource = _attributes(resource_spans.resource.attributes)
161
163
  for scope_spans in resource_spans.scope_spans:
162
- spans.extend(_from_proto(span, resource) for span in scope_spans.spans)
164
+ scope = scope_spans.scope.name or None
165
+ spans.extend(_from_proto(span, resource, scope) for span in scope_spans.spans)
163
166
  return spans
164
167
  if content_type.startswith("application/json"):
165
168
  payload = json.loads(body)
166
169
  for resource_spans in payload.get("resourceSpans", []):
167
170
  resource = _json_attributes((resource_spans.get("resource") or {}).get("attributes"))
168
171
  for scope_spans in resource_spans.get("scopeSpans", []):
169
- spans.extend(_from_json(span, resource) for span in scope_spans.get("spans", []))
172
+ scope = (scope_spans.get("scope") or {}).get("name") or None
173
+ spans.extend(
174
+ _from_json(span, resource, scope) for span in scope_spans.get("spans", [])
175
+ )
170
176
  return spans
171
177
  raise HTTPException(
172
178
  status_code=415,
evalkit/api/pull.py CHANGED
@@ -99,7 +99,7 @@ async def _bundle(ctx: PullContext, session: AsyncSession, run: BrowserRun) -> R
99
99
  status=run.status,
100
100
  created_at=run.created_at,
101
101
  title=run.title,
102
- run=run_body(run.run_id, run.source, stored, context),
102
+ run=run_body(run.run_id, run.source, stored, context, created_at=run.created_at),
103
103
  eval=context,
104
104
  )
105
105
  try:
@@ -55,6 +55,136 @@
55
55
  "title": "AttributeRule",
56
56
  "type": "object"
57
57
  },
58
+ "SpanMatch": {
59
+ "additionalProperties": false,
60
+ "properties": {
61
+ "name": {
62
+ "anyOf": [
63
+ {
64
+ "type": "string"
65
+ },
66
+ {
67
+ "type": "null"
68
+ }
69
+ ],
70
+ "default": null,
71
+ "description": "Span name; glob patterns such as OpenAILike.* are allowed.",
72
+ "title": "Name"
73
+ },
74
+ "attribute": {
75
+ "anyOf": [
76
+ {
77
+ "type": "string"
78
+ },
79
+ {
80
+ "type": "null"
81
+ }
82
+ ],
83
+ "default": null,
84
+ "description": "A span attribute key to compare.",
85
+ "title": "Attribute"
86
+ },
87
+ "equals": {
88
+ "anyOf": [
89
+ {},
90
+ {
91
+ "type": "null"
92
+ }
93
+ ],
94
+ "default": null,
95
+ "description": "The value the attribute must hold, compared as text: 1, 1.0 and \"1\" match, and so do true and \"true\". Leave out to match any span that has the attribute.",
96
+ "title": "Equals"
97
+ },
98
+ "scope": {
99
+ "anyOf": [
100
+ {
101
+ "type": "string"
102
+ },
103
+ {
104
+ "type": "null"
105
+ }
106
+ ],
107
+ "default": null,
108
+ "description": "Instrumentation scope name, e.g. mcp; glob patterns are allowed.",
109
+ "title": "Scope"
110
+ }
111
+ },
112
+ "title": "SpanMatch",
113
+ "type": "object"
114
+ },
115
+ "SpanRekind": {
116
+ "additionalProperties": false,
117
+ "properties": {
118
+ "name": {
119
+ "anyOf": [
120
+ {
121
+ "type": "string"
122
+ },
123
+ {
124
+ "type": "null"
125
+ }
126
+ ],
127
+ "default": null,
128
+ "description": "Span name; glob patterns such as OpenAILike.* are allowed.",
129
+ "title": "Name"
130
+ },
131
+ "attribute": {
132
+ "anyOf": [
133
+ {
134
+ "type": "string"
135
+ },
136
+ {
137
+ "type": "null"
138
+ }
139
+ ],
140
+ "default": null,
141
+ "description": "A span attribute key to compare.",
142
+ "title": "Attribute"
143
+ },
144
+ "equals": {
145
+ "anyOf": [
146
+ {},
147
+ {
148
+ "type": "null"
149
+ }
150
+ ],
151
+ "default": null,
152
+ "description": "The value the attribute must hold, compared as text: 1, 1.0 and \"1\" match, and so do true and \"true\". Leave out to match any span that has the attribute.",
153
+ "title": "Equals"
154
+ },
155
+ "scope": {
156
+ "anyOf": [
157
+ {
158
+ "type": "string"
159
+ },
160
+ {
161
+ "type": "null"
162
+ }
163
+ ],
164
+ "default": null,
165
+ "description": "Instrumentation scope name, e.g. mcp; glob patterns are allowed.",
166
+ "title": "Scope"
167
+ },
168
+ "kind": {
169
+ "description": "The kind matching spans get instead of the kind rule's.",
170
+ "enum": [
171
+ "llm",
172
+ "tool",
173
+ "agent",
174
+ "chain",
175
+ "retriever",
176
+ "other"
177
+ ],
178
+ "title": "Kind",
179
+ "type": "string"
180
+ }
181
+ },
182
+ "required": [
183
+ "kind"
184
+ ],
185
+ "title": "SpanRekind",
186
+ "type": "object"
187
+ },
58
188
  "TokenRules": {
59
189
  "additionalProperties": false,
60
190
  "properties": {
@@ -298,12 +428,58 @@
298
428
  "type": "string"
299
429
  },
300
430
  "exclude_spans": {
301
- "description": "Span names left out of the trajectory.",
431
+ "description": "Spans left out of the trajectory: a span name (glob patterns allowed) or a match on name, attribute and scope; every field given must match.",
302
432
  "items": {
303
- "type": "string"
433
+ "anyOf": [
434
+ {
435
+ "type": "string"
436
+ },
437
+ {
438
+ "$ref": "#/$defs/SpanMatch"
439
+ }
440
+ ]
304
441
  },
305
442
  "title": "Exclude Spans",
306
443
  "type": "array"
444
+ },
445
+ "rekind_spans": {
446
+ "description": "Spans that get another kind than the kind rule gives, e.g. a graph node tagged agent that is only a step: {name: agent, kind: chain}. The first match wins.",
447
+ "items": {
448
+ "$ref": "#/$defs/SpanRekind"
449
+ },
450
+ "title": "Rekind Spans",
451
+ "type": "array"
452
+ },
453
+ "main_agent": {
454
+ "anyOf": [
455
+ {
456
+ "type": "string"
457
+ },
458
+ {
459
+ "$ref": "#/$defs/SpanMatch"
460
+ },
461
+ {
462
+ "type": "null"
463
+ }
464
+ ],
465
+ "default": null,
466
+ "description": "The agent span whose answer and id the trajectory carries, when the earliest top-level agent span is not it.",
467
+ "title": "Main Agent"
468
+ },
469
+ "subagent_spans": {
470
+ "description": "Agent spans that become subagent trajectories even when no tool span spawns them, e.g. sibling crew members to keep apart.",
471
+ "items": {
472
+ "anyOf": [
473
+ {
474
+ "type": "string"
475
+ },
476
+ {
477
+ "$ref": "#/$defs/SpanMatch"
478
+ }
479
+ ]
480
+ },
481
+ "title": "Subagent Spans",
482
+ "type": "array"
307
483
  }
308
484
  },
309
485
  "required": [
@@ -118,7 +118,27 @@ Rule shapes:
118
118
  | `{"attribute": K, "message_format": F}` | the messages laid out under `K` per format `F`: `openinference` (flattened indexed keys), `gen_ai` (JSON list of messages with parts), `openai` (JSON list of chat messages) |
119
119
  | `null` | never read |
120
120
 
121
- Two more fields shape the trajectory: `answer` (`root`, a span name, or `<span name>.<output key>`; default `root`) and `exclude_spans` (span names left out; default none).
121
+ More fields shape the trajectory:
122
+
123
+ - `answer`: where the run's answer comes from: `root`, a span name, or `<span name>.<output key>`. Default `root`.
124
+ - `exclude_spans`: spans left out of the trajectory. Default none.
125
+ - `rekind_spans`: spans that get another kind than the `kind` rule gives, e.g. `{"name": "agent", "kind": "chain"}` for a graph node tagged AGENT that is only a step. The first match wins.
126
+ - `main_agent`: the agent span whose answer and id the trajectory carries, when evalkit picks the wrong one. When it matches several spans (one per chat turn), the earliest gives the id and the latest the answer.
127
+ - `subagent_spans`: agent spans to keep as subagent trajectories even though no tool span starts them.
128
+
129
+ Each entry is a span match:
130
+
131
+ | Match | Matches a span when |
132
+ | -- | -- |
133
+ | `"OpenAILike.*"` | its name matches the glob |
134
+ | `{"name": G}` | its name matches the glob `G` |
135
+ | `{"attribute": K}` | it has attribute `K` |
136
+ | `{"attribute": K, "equals": V}` | attribute `K` holds `V`, compared as text: `1`, `1.0` and `"1"` match each other, and so do `true` and `"true"` |
137
+ | `{"scope": G}` | its instrumentation scope name (e.g. `mcp`) matches the glob `G` |
138
+
139
+ An object match may give several of `name`, `attribute` and `scope`; every one given must match.
140
+
141
+ The span name alone is not always enough: two LLM spans with the same name, or spans that come from another library's instrumentation. Match on an attribute or the scope then.
122
142
 
123
143
  Every mapping is complete on its own; there is no inheritance. The schema ships as `span-mapping-v1.json` with `evalkit contracts export`.
124
144
 
@@ -106,7 +106,7 @@ The server has two limits, both set in its config:
106
106
  | `otel.max_batch_bytes` | 16 MiB | One export request (after gzip is undone) gets `413` and its spans are dropped. Exporters do not split a refused batch, so keep batches small. |
107
107
  | `otel.max_session_bytes` | 384 MiB | Reading the session (a run's trajectory, `evalkit traces check`, the Mappings tab) gets `413` with the session's size and the limit. A run records the trajectory as `unavailable` and logs the message. `--dump spans.json` still works. |
108
108
 
109
- `otel.max_session_bytes` counts the span attributes a trajectory build loads, not everything stored. evalkit reads the input messages (and system prompt) of an LLM span only for the first LLM call of each agent and subagent; later calls add only their output, tool calls and tokens to the trajectory. So the build leaves the input of every later LLM call in the database and does not count it. The limit keeps one session from using up the server's memory, so raise it only together with the server's memory limit.
109
+ `otel.max_session_bytes` counts the span attributes a trajectory build loads, not everything stored. evalkit reads the input messages (and system prompt) of an LLM span only for the first LLM call under each root span and in each subagent; later calls add only their output, tool calls and tokens to the trajectory. So the build leaves the input of every later LLM call in the database and does not count it. The limit keeps one session from using up the server's memory, so raise it only together with the server's memory limit.
110
110
 
111
111
  For agents with large spans, send fewer spans per export and give each export more time. For the Python SDK, `tracing.register` included:
112
112
 
@@ -142,7 +142,16 @@ The collector speaks OTLP over HTTP only, not gRPC. Bodies may be chunked with n
142
142
 
143
143
  ## The main agent and subagents
144
144
 
145
- Mark the agent's top-level span as an AGENT span (`openinference.span.kind=AGENT`, or `gen_ai.operation.name=invoke_agent`). evalkit builds the main trajectory from it, and every AGENT span inside it becomes a subagent trajectory named by the span's `agent.name` (`gen_ai.agent.name`), or by the span name when that is missing. When the root span is not an AGENT span, as with the SDK's `evalkit.run` span, evalkit takes the earliest AGENT span that is not inside another one as the main agent. If that span is a tool call that starts a subagent partway through the run, the subagent's steps land in the main trajectory and the call has no result, so mark the top-level span as an AGENT span rather than relying on this.
145
+ An AGENT span (`openinference.span.kind=AGENT`, or `gen_ai.operation.name=invoke_agent`) becomes a subagent trajectory only when another agent started it: it sits under a tool span, or it carries the `tool_call_id` of the call that started it. The subagent is named by the span's `agent.name` (`gen_ai.agent.name`), or by the span name when that is missing. Every other AGENT span is part of the main agent's own work, so an outer wrapper span, graph nodes tagged AGENT and one root span per chat turn all end up in one trajectory.
146
+
147
+ The main agent is the root span when it is an AGENT span; otherwise, as with the SDK's `evalkit.run` span, the earliest AGENT span that is not inside another one. When a session holds several root spans, one per chat turn, evalkit puts them in time order and takes the answer from the last one.
148
+
149
+ Each user message appears in the trajectory once, as a `user` step, before the first LLM call that has it in its input. So a chat's later turns show up as new user steps. Two limits:
150
+
151
+ - evalkit loads the input messages only of the first LLM call under each root span (see the size limit above). When every turn of a chat runs inside one trace, only the first user message is loaded; give each turn its own root span to see them all.
152
+ - When a framework sends only the latest user message instead of the whole history, evalkit adds a user step for each text it has not seen yet. A user message repeated word for word ("yes", then "yes" again) then shows up once.
153
+
154
+ Two mapping fields change this when the shape is wrong for your agent: `main_agent` pins the main agent, and `subagent_spans` keeps sibling agents (a crew whose agents hand over without a tool call) as separate subagent trajectories. See [Mappings](mappings.md).
146
155
 
147
156
  ## Harness agents with traces
148
157
 
@@ -366,7 +366,8 @@ are advisory). `--dataset` is the dataset you will sync into; it lets the
366
366
  server check case ids and overlay targets against every other dataset.
367
367
  A jargon-leak error is fixed by rewording the case, never by renaming
368
368
  internals. Then `evalkit run <dataset> --agent <agent>` syncs the directory
369
- to your workspace and runs it; CI, logged in as `admin`, runs `evalkit sync
369
+ to your workspace and runs it (for a code-driven agent, one without a
370
+ `harness_url`: run the eval script with `case_ids=[...]`); CI, logged in as `admin`, runs `evalkit sync
370
371
  <dir> --workspace dev` (the team's shared workspace) on merge (see
371
372
  `evalkit --help` for exact flags).
372
373
 
@@ -57,7 +57,8 @@ Rules:
57
57
  ## Run-then-pin
58
58
 
59
59
  1. Run the case single-case (`evalkit run <dataset> --agent <agent>
60
- --case-id <id>`; the run syncs first); collect the experiment.
60
+ --case-id <id>`; the run syncs first; for a code-driven agent,
61
+ run the eval script with `case_ids=[<id>]`); collect the experiment.
61
62
  2. Read the observed trajectory from the collected bundle. Derive the
62
63
  enrichment from what actually happened:
63
64
  - required tools: the real data tools the run used;
@@ -33,7 +33,12 @@ two run-level settings:
33
33
 
34
34
  - `answer`: where the run's answer comes from. `root` (the usual value), a
35
35
  span name, or `<span name>.<output key>`.
36
- - `exclude_spans`: span names left out of the trajectory.
36
+ - `exclude_spans`: spans left out of the trajectory, by name glob
37
+ (`"OpenAILike.*"`), attribute (`{"attribute": K, "equals": V}`) or
38
+ instrumentation scope (`{"scope": "mcp"}`).
39
+ - `rekind_spans`, `main_agent`, `subagent_spans`: change a span's kind, pin the
40
+ main agent, or keep sibling agents apart. See
41
+ `references/span-mapping-schema.md`.
37
42
 
38
43
  A span the agent's mapping cannot read is not an error: it comes out as kind
39
44
  `other` with every attribute listed as unmapped, and the trajectory simply
@@ -141,21 +146,28 @@ lacks it. That is what a wrong mapping looks like in the check.
141
146
  | `tools` | spans read as `tool`, and how many carry a `tool_call_id` that matches a call the LLM spans emitted; a gap means tool spans exist but their call ids are not read, so results only match by time and order; `in no step` names tool spans that started before any LLM span and so are not in the trajectory |
142
147
  | `unmapped` | attributes no rule read, apart from the mapping's `known_attributes` |
143
148
  | `trajectory` | ATIF steps, tool calls, subagents |
144
-
145
- Then check the agent's top-level span is an AGENT span
146
- (`openinference.span.kind=AGENT` or `gen_ai.operation.name=invoke_agent`).
147
- evalkit builds the main trajectory from it, and every AGENT span inside it
148
- becomes a subagent named by its `agent.name` (`gen_ai.agent.name`). When
149
- the root span is not an AGENT span, evalkit takes the earliest AGENT span
150
- that is not inside another one as the main agent. If that span is a tool
151
- call that starts a subagent partway through the run, the subagent's steps
152
- end up in the main trajectory and its call has no result. Fix that in the
153
- agent's instrumentation: mark its top-level span as an AGENT span.
149
+ | `steps` | shown only when there are more LLM spans than LLM steps; check `exclude_spans` and the kind rule |
150
+ | `subagents` | shown only when subagents hold every LLM call and the main agent none; usually an outer wrapper span; set `main_agent` or `exclude_spans` |
151
+
152
+ Each line of the check output starts with `✓` (fine), `!` (a warning) or
153
+ `✗` (a failure). Read every `!` line, even when the check exits 0: each
154
+ one names a trajectory that is likely wrong, such as tool spans with no
155
+ tool calls in the trajectory, or subagents holding all the LLM calls while
156
+ the main agent has none.
157
+
158
+ An AGENT span (`openinference.span.kind=AGENT` or
159
+ `gen_ai.operation.name=invoke_agent`) becomes a subagent named by its
160
+ `agent.name` (`gen_ai.agent.name`) only when it sits under a tool span or
161
+ carries the `tool_call_id` that started it. Every other AGENT span (an
162
+ outer wrapper, graph nodes tagged AGENT, one root span per chat turn) is
163
+ merged into the main agent. When that is wrong for the agent, set
164
+ `main_agent` or `subagent_spans` in the mapping; drop duplicate spans with
165
+ `exclude_spans` and fix a wrong kind with `rekind_spans`.
154
166
 
155
167
  If the check fails with `413` and names `otel.max_session_bytes`, the
156
168
  session holds more span attributes than the server will build into a
157
169
  trajectory (384 MiB by default). The limit counts what a build loads: the
158
- input messages of each agent's first LLM call, and the output, tool calls
170
+ input messages of the first LLM call under each root span and in each subagent, and the output, tool calls
159
171
  and tokens of every LLM call, not the input of later calls. Check a shorter session, and tell the
160
172
  developer: the deployment's admin can raise the limit together with the
161
173
  server's memory.
@@ -31,15 +31,41 @@ complete on its own; there is no inheritance. The JSON Schema ships as
31
31
  "output": {"attribute": "...", "json": true},
32
32
  "known_attributes": ["...", "prefix.*"],
33
33
  "answer": "root",
34
- "exclude_spans": ["..."]
34
+ "exclude_spans": ["...", {"attribute": "...", "equals": "..."}, {"scope": "..."}],
35
+ "rekind_spans": [{"name": "...", "kind": "chain"}],
36
+ "main_agent": null,
37
+ "subagent_spans": []
35
38
  }
36
39
  ```
37
40
 
38
- Two fields apply to the whole run, not to one span:
41
+ These fields apply to the whole run, not to one span:
39
42
 
40
43
  - `answer` (default `root`): where the run's answer comes from. `root`, a
41
44
  span name, or `<span name>.<output key>`.
42
- - `exclude_spans` (default empty): span names left out of the trajectory.
45
+ - `exclude_spans` (default empty): spans left out of the trajectory.
46
+ - `rekind_spans` (default empty): spans that get another `kind` than the kind
47
+ rule gives. Each entry is a span match plus `kind`; the first match wins.
48
+ - `main_agent` (default null): the agent span whose answer and id the
49
+ trajectory carries. When it matches several spans, the earliest gives the
50
+ id and the latest the answer.
51
+ - `subagent_spans` (default empty): agent spans kept as subagent trajectories
52
+ even when no tool span starts them. An agent span also becomes a subagent
53
+ when it sits under a tool span, or when the `tool.call_id` rule reads a call
54
+ id on it. If an instrumentor stamps the current call id on every span below
55
+ a tool call, ordinary agent spans become subagents that way; look there
56
+ when the check shows subagents you did not expect.
57
+
58
+ Each entry is a span match:
59
+
60
+ | Match | Matches a span when |
61
+ | -- | -- |
62
+ | `"OpenAILike.*"` | its name matches the glob |
63
+ | `{"name": G}` | its name matches the glob `G` |
64
+ | `{"attribute": K}` | it has attribute `K` |
65
+ | `{"attribute": K, "equals": V}` | attribute `K` holds `V`, compared as text: `1`, `1.0` and `"1"` match each other, and so do `true` and `"true"` |
66
+ | `{"scope": G}` | its instrumentation scope name (e.g. `mcp`) matches the glob `G` |
67
+
68
+ An object match may give several of `name`, `attribute` and `scope`; every one given must match.
43
69
 
44
70
  ## Rule shapes
45
71
 
@@ -61,6 +61,25 @@ Every case is layered:
61
61
  overlay leaves a portable case. See the authoring skill's
62
62
  [`references/overlays.md`](../authoring-eval-cases/references/overlays.md).
63
63
 
64
+ ## How the agent is run
65
+
66
+ `evalkit skills install` puts the evalkit user docs in `evalkit-docs/`
67
+ beside this skill; links to `../evalkit-docs/` point there. In the evalkit
68
+ repository the same pages are in `docs/user/`.
69
+
70
+ Every run step below has two forms. `evalkit agents show <agent>` tells you
71
+ which applies:
72
+
73
+ - **Harness API agent** (`harness_url` set): `evalkit run <dataset> --agent
74
+ <agent>` drives it.
75
+ - **Code-driven agent** (no `harness_url`): `evalkit run` cannot drive it.
76
+ Run the client's eval script, which calls `run_experiment`; pass
77
+ `case_ids=[...]` or `tags=[...]` to run a subset.
78
+ `run_experiment(dataset=<dir name>)` syncs the directory when it is under
79
+ `cases` in `evalkit.yaml`; otherwise run `evalkit sync <dir>` first and pass
80
+ the dataset reference (`<name>@<workspace>`) (see
81
+ [`sdk-runs.md`](../evalkit-docs/sdk-runs.md)).
82
+
64
83
  ## Pick a loop
65
84
 
66
85
  | Developer gives | Wants back | Loop |
@@ -75,7 +94,8 @@ mix with Loop 1's Steps 1–6.
75
94
  ## Runs are history
76
95
 
77
96
  This applies to both loops. Every pulled run shows the agent as it was when
78
- the run happened (`run.json` `started_at`, `index.json` `created_at`), not as
97
+ the run happened (`run.json` `started_at`; `null` when the harness listing gave no creation
98
+ time), not as
79
99
  the code is now. Prompts,
80
100
  skills, tools and data may have changed since, so a failure in a run may
81
101
  already be fixed. Before diagnosing or proposing a fix, check the git history
@@ -86,6 +106,10 @@ git log --since=<run started_at> --oneline -- <paths of the surfaces involved>
86
106
  git log --since=<run started_at> --oneline -S '<tool or prompt text from the trajectory>'
87
107
  ```
88
108
 
109
+ If `started_at` is `null`, skip the `--since` commands, read the last few
110
+ commits that touch the surface instead, and say in the diagnosis that the
111
+ run's time was unknown.
112
+
89
113
  `--since` compares commit dates, which a rebase or squash merge resets, so
90
114
  treat it as a first pass: also read the last few commits that touch the
91
115
  surface (`git log -n 10 -- <path>`) whatever their date. Read any commit that
@@ -171,11 +195,17 @@ what correct output looks like for this input and every sibling like it.
171
195
 
172
196
  After authoring or editing any case YAML — in any entry point — run
173
197
  `evalkit lint <file> --dataset <slug>` first; errors block sync. Then
174
- `evalkit run <dataset> --agent <agent>`: with an `evalkit.yaml` in the repo
175
- this syncs the dataset directory to your workspace and runs your local agent
176
- from this machine. For a tight loop, run only the relevant cases
177
- (`evalkit run <dataset>/<file>.yaml`, `evalkit run <dataset>/<subfolder>`, or
178
- `--case-id`, repeatable) rather than the whole dataset.
198
+ run the dataset the way the agent is run (see "How the agent is run"):
199
+
200
+ - **Harness API agent** — `evalkit run <dataset> --agent <agent>`: with an
201
+ `evalkit.yaml` in the repo this syncs the dataset directory to your
202
+ workspace and runs your local agent from this machine. For a tight loop,
203
+ run only the relevant cases (`evalkit run <dataset>/<file>.yaml`,
204
+ `evalkit run <dataset>/<subfolder>`, or `--case-id`, repeatable) rather
205
+ than the whole dataset.
206
+ - **Code-driven agent** — run the eval script with `case_ids=[...]` (see
207
+ "How the agent is run"); if the script takes no case-subset option, add
208
+ one rather than running the whole dataset.
179
209
 
180
210
  `evalkit run` executes every selected case, in personal and shared datasets
181
211
  alike; review state never filters a run.
@@ -314,8 +344,10 @@ surfaces the proposal touches (search the case YAML for related scenarios).
314
344
  [`references/synthesize.md`](references/synthesize.md): describe the
315
345
  mechanism first, escalate to rule-style wording only when a re-run shows
316
346
  the behaviour persisted, prefer deterministic guards, no eval awareness.
317
- 2. `evalkit run <dataset> --agent <agent> --case-id <id> [--case-id …]`
318
- over the working set (the run syncs your edits first).
347
+ 2. Run the working set: `evalkit run <dataset> --agent <agent> --case-id
348
+ <id> [--case-id …]` for a Harness API agent (the run syncs your edits
349
+ first); for a code-driven agent, run the eval script with
350
+ `case_ids=[...]`.
319
351
  3. `evalkit runs pull --experiment <id>` for that experiment and pick the
320
352
  failures from the new `index.json`.
321
353
  4. Stop when no failure scores below threshold (**green**) or when the
@@ -66,7 +66,7 @@ trajectory alone.
66
66
  "run_id": "<from index.json>",
67
67
  "created_at": "<from index.json>",
68
68
  "intent": "<one line: what the user asked for>",
69
- "task_type": "<a case type from the authoring-eval-cases skill>",
69
+ "question_kind": "<free text: the kind of question, in a few words, e.g. 'monthly spend by category'>",
70
70
  "verdict": "failed | degraded | ok | unclear",
71
71
  "signals": ["<short label, e.g. 'user re-asked', 'tool error x3'>"],
72
72
  "failures": [
@@ -17,7 +17,8 @@ case YAML the new cases will join), and the path to write
17
17
 
18
18
  1. Read every observation and `index.json`.
19
19
  2. Cluster the `failed` and `degraded` observations into patterns. Two
20
- observations share a pattern when they have the same `task_type`, the same
20
+ observations share a pattern when they ask the same kind of question (`question_kind`; free text, so
21
+ treat close wordings as one), the same
21
22
  failure `kind`, and the evidence points at the same root cause (the same
22
23
  surface misbehaving the same way). Name each pattern in plain words.
23
24
  3. Score each pattern:
@@ -52,13 +53,13 @@ Surface: <kind> <file or "not located">
52
53
  Already covered by: none | <case id> (partly: <what is missing>)
53
54
  Fixed since the runs: no | yes, <sha> "<what changed>" (expected green)
54
55
  Proposed cases:
55
- - id: <kebab-id> type: <task_type> ground truth: known | NEEDS DEVELOPER
56
+ - id: <kebab-id> kind: <question_kind> ground truth: known | NEEDS DEVELOPER
56
57
  input: <time-anchored input>
57
58
  asserts: <the ideal behaviour, one line>
58
59
  Level: blackbox rubrics; overlay <check> if the check names harness tools
59
60
 
60
61
  ## Healthy
61
- - <task_type>: no failures in <n> runs
62
+ - <question_kind>: no failures in <n> runs
62
63
 
63
64
  ## Unclear or low confidence
64
65
  - <run_id>: <why>
@@ -145,7 +145,9 @@ evalkit agents list --workspace dev
145
145
  Put an `evalkit.yaml` in your repo. `evalkit run finance --agent myagent`
146
146
  then syncs `<cases>/finance` to `finance@<you>`, drives `myagent` from this
147
147
  machine, scores, and writes everything to the server. Run `finance@dev` to
148
- use the shared cases instead (Approved ones only, no sync). Fixture bytes are
148
+ use the shared cases instead (Approved ones only, no sync). `evalkit run`
149
+ drives agents with a `harness_url`; for a code-driven agent, run the eval
150
+ script with `case_ids=[...]` (see `sdk-runs.md`). Fixture bytes are
149
151
  read from the `fixtures` directory and uploaded by sha256 on every run or
150
152
  sync.
151
153
 
@@ -1 +1 @@
1
- import{m as e}from"./editor.api-D1rxHWTF.js";import{t}from"./workers-GTw2k376.js";import{_ as n,a as r,c as i,d as a,f as o,g as s,h as c,i as l,l as u,m as d,n as f,o as p,p as m,r as h,s as g,t as _,u as v,v as y}from"./lspLanguageFeatures-BieGLabF.js";var b=12e4,x=class{constructor(e){this._defaults=e,this._worker=null,this._client=null,this._idleCheckInterval=window.setInterval(()=>this._checkIfIdle(),3e4),this._lastUsedTime=0,this._configChangeListener=this._defaults.onDidChange(()=>this._stopWorker())}_stopWorker(){this._worker&&=(this._worker.dispose(),null),this._client=null}dispose(){clearInterval(this._idleCheckInterval),this._configChangeListener.dispose(),this._stopWorker()}_checkIfIdle(){this._worker&&Date.now()-this._lastUsedTime>b&&this._stopWorker()}_getClient(){return this._lastUsedTime=Date.now(),this._client||=(this._worker=t({moduleId:`vs/language/css/cssWorker`,createWorker:()=>new Worker(new URL(`/assets/css.worker-DwfUZ3fB.js`,``+import.meta.url),{type:`module`}),label:this._defaults.languageId,createData:{options:this._defaults.options,languageId:this._defaults.languageId}}),this._worker.getProxy()),this._client}getLanguageServiceWorker(...e){let t;return this._getClient().then(e=>{t=e}).then(t=>{if(this._worker)return this._worker.withSyncedResources(e)}).then(e=>t)}};function S(t){let n=[],s=[],c=new x(t);n.push(c);let g=(...e)=>c.getLanguageServiceWorker(...e);function y(){let{languageId:n,modeConfiguration:c}=t;w(s),c.completionItems&&s.push(e.registerCompletionItemProvider(n,new _(g,[`/`,`-`,`:`]))),c.hovers&&s.push(e.registerHoverProvider(n,new a(g))),c.documentHighlights&&s.push(e.registerDocumentHighlightProvider(n,new p(g))),c.definitions&&s.push(e.registerDefinitionProvider(n,new f(g))),c.references&&s.push(e.registerReferenceProvider(n,new o(g))),c.documentSymbols&&s.push(e.registerDocumentSymbolProvider(n,new u(g))),c.rename&&s.push(e.registerRenameProvider(n,new m(g))),c.colors&&s.push(e.registerColorProvider(n,new l(g))),c.foldingRanges&&s.push(e.registerFoldingRangeProvider(n,new v(g))),c.diagnostics&&s.push(new h(n,g,t.onDidChange)),c.selectionRanges&&s.push(e.registerSelectionRangeProvider(n,new d(g))),c.documentFormattingEdits&&s.push(e.registerDocumentFormattingEditProvider(n,new r(g))),c.documentRangeFormattingEdits&&s.push(e.registerDocumentRangeFormattingEditProvider(n,new i(g)))}return y(),n.push(C(s)),C(n)}function C(e){return{dispose:()=>w(e)}}function w(e){for(;e.length;)e.pop().dispose()}export{_ as CompletionAdapter,f as DefinitionAdapter,h as DiagnosticsAdapter,l as DocumentColorAdapter,r as DocumentFormattingEditProvider,p as DocumentHighlightAdapter,g as DocumentLinkAdapter,i as DocumentRangeFormattingEditProvider,u as DocumentSymbolAdapter,v as FoldingRangeAdapter,a as HoverAdapter,o as ReferenceAdapter,m as RenameAdapter,d as SelectionRangeAdapter,x as WorkerManager,c as fromPosition,s as fromRange,S as setupMode,n as toRange,y as toTextEdit};
1
+ import{m as e}from"./editor.api-fo8vSfal.js";import{t}from"./workers-Bd9MSI6m.js";import{_ as n,a as r,c as i,d as a,f as o,g as s,h as c,i as l,l as u,m as d,n as f,o as p,p as m,r as h,s as g,t as _,u as v,v as y}from"./lspLanguageFeatures-C5BxQo0O.js";var b=12e4,x=class{constructor(e){this._defaults=e,this._worker=null,this._client=null,this._idleCheckInterval=window.setInterval(()=>this._checkIfIdle(),3e4),this._lastUsedTime=0,this._configChangeListener=this._defaults.onDidChange(()=>this._stopWorker())}_stopWorker(){this._worker&&=(this._worker.dispose(),null),this._client=null}dispose(){clearInterval(this._idleCheckInterval),this._configChangeListener.dispose(),this._stopWorker()}_checkIfIdle(){this._worker&&Date.now()-this._lastUsedTime>b&&this._stopWorker()}_getClient(){return this._lastUsedTime=Date.now(),this._client||=(this._worker=t({moduleId:`vs/language/css/cssWorker`,createWorker:()=>new Worker(new URL(`/assets/css.worker-DwfUZ3fB.js`,``+import.meta.url),{type:`module`}),label:this._defaults.languageId,createData:{options:this._defaults.options,languageId:this._defaults.languageId}}),this._worker.getProxy()),this._client}getLanguageServiceWorker(...e){let t;return this._getClient().then(e=>{t=e}).then(t=>{if(this._worker)return this._worker.withSyncedResources(e)}).then(e=>t)}};function S(t){let n=[],s=[],c=new x(t);n.push(c);let g=(...e)=>c.getLanguageServiceWorker(...e);function y(){let{languageId:n,modeConfiguration:c}=t;w(s),c.completionItems&&s.push(e.registerCompletionItemProvider(n,new _(g,[`/`,`-`,`:`]))),c.hovers&&s.push(e.registerHoverProvider(n,new a(g))),c.documentHighlights&&s.push(e.registerDocumentHighlightProvider(n,new p(g))),c.definitions&&s.push(e.registerDefinitionProvider(n,new f(g))),c.references&&s.push(e.registerReferenceProvider(n,new o(g))),c.documentSymbols&&s.push(e.registerDocumentSymbolProvider(n,new u(g))),c.rename&&s.push(e.registerRenameProvider(n,new m(g))),c.colors&&s.push(e.registerColorProvider(n,new l(g))),c.foldingRanges&&s.push(e.registerFoldingRangeProvider(n,new v(g))),c.diagnostics&&s.push(new h(n,g,t.onDidChange)),c.selectionRanges&&s.push(e.registerSelectionRangeProvider(n,new d(g))),c.documentFormattingEdits&&s.push(e.registerDocumentFormattingEditProvider(n,new r(g))),c.documentRangeFormattingEdits&&s.push(e.registerDocumentRangeFormattingEditProvider(n,new i(g)))}return y(),n.push(C(s)),C(n)}function C(e){return{dispose:()=>w(e)}}function w(e){for(;e.length;)e.pop().dispose()}export{_ as CompletionAdapter,f as DefinitionAdapter,h as DiagnosticsAdapter,l as DocumentColorAdapter,r as DocumentFormattingEditProvider,p as DocumentHighlightAdapter,g as DocumentLinkAdapter,i as DocumentRangeFormattingEditProvider,u as DocumentSymbolAdapter,v as FoldingRangeAdapter,a as HoverAdapter,o as ReferenceAdapter,m as RenameAdapter,d as SelectionRangeAdapter,x as WorkerManager,c as fromPosition,s as fromRange,S as setupMode,n as toRange,y as toTextEdit};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./index-uL5Ox6Wl.js";function t(e){if(e.length===0)throw Error(`Invalid tail call`);return[e.slice(0,e.length-1),e[e.length-1]]}function n(e,t,n=(e,t)=>e===t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!n(e[r],t[r]))return!1;return!0}function r(e,t){let n=e.length-1;t<n&&(e[t]=e[n]),e.pop()}function i(e,t,n){return a(e.length,r=>n(e[r],t))}function a(e,t){let n=0,r=e-1;for(;n<=r;){let e=(n+r)/2|0,i=t(e);if(i<0)n=e+1;else if(i>0)r=e-1;else return e}return-(n+1)}function o(e,t,n){if(e|=0,e>=t.length)throw TypeError(`invalid index`);let r=t[Math.floor(t.length*Math.random())],i=[],a=[],s=[];for(let e of t){let t=n(e,r);t<0?i.push(e):t>0?a.push(e):s.push(e)}return e<i.length?o(e,i,n):e<i.length+s.length?s[0]:o(e-(i.length+s.length),a,n)}function s(e,t){let n=[],r;for(let i of e.slice(0).sort(t))!r||t(r[0],i)!==0?(r=[i],n.push(r)):r.push(i);return n}function*c(e,t){let n,r;for(let i of e)r!==void 0&&t(r,i)?n.push(i):(n&&(yield n),n=[i]),r=i;n&&(yield n)}function l(e,t){for(let n=0;n<=e.length;n++)t(n===0?void 0:e[n-1],n===e.length?void 0:e[n])}function u(e,t){for(let n=0;n<e.length;n++)t(n===0?void 0:e[n-1],e[n],n+1===e.length?void 0:e[n+1])}function d(e){return e.filter(e=>!!e)}function f(e){let t=0;for(let n=0;n<e.length;n++)e[n]&&(e[t]=e[n],t+=1);e.length=t}function p(e){return!Array.isArray(e)||e.length===0}function m(e){return Array.isArray(e)&&e.length>0}function h(e,t=e=>e){let n=new Set;return e.filter(e=>{let r=t(e);return!n.has(r)&&(n.add(r),!0)})}function g(e,t){let n=typeof t==`number`?e:0;typeof t==`number`?n=e:(n=0,t=e);let r=[];if(n<=t)for(let e=n;e<t;e++)r.push(e);else for(let e=n;e>t;e--)r.push(e);return r}function _(e,t,n){let r=e.slice(0,t),i=e.slice(t);return r.concat(n,i)}function v(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.unshift(t))}function y(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.push(t))}function b(e,t){for(let n of t)e.push(n)}function x(e,t){let n=[];for(let r of e){let e=t(r);e!==void 0&&n.push(e)}return n}function S(e){return Array.isArray(e)?e:[e]}function C(e,t,n){let r=ee(e,t),i=e.length,a=n.length;e.length=i+a;for(let t=i-1;t>=r;t--)e[t+a]=e[t];for(let t=0;t<a;t++)e[t+r]=n[t]}function w(e,t,n,r){let i=ee(e,t),a=e.splice(i,n);return a===void 0&&(a=[]),C(e,i,r),a}function ee(e,t){return t<0?Math.max(t+e.length,0):Math.min(t,e.length)}var te;(function(e){function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(te||={});function ne(e,t){return(n,r)=>t(e(n),e(r))}function re(...e){return(t,n)=>{for(let r of e){let e=r(t,n);if(!te.isNeitherLessOrGreaterThan(e))return e}return te.neitherLessOrGreaterThan}}var ie=(e,t)=>e-t,ae=(e,t)=>ie(+!!e,+!!t);function oe(e){return(t,n)=>-e(t,n)}function se(e){return(t,n)=>t===void 0?n===void 0?te.neitherLessOrGreaterThan:te.lessThan:n===void 0?te.greaterThan:e(t,n)}var ce=class{constructor(e){this.firstIdx=0,this.items=e,this.lastIdx=this.items.length-1}get length(){return this.lastIdx-this.firstIdx+1}takeWhile(e){let t=this.firstIdx;for(;t<=this.lastIdx&&e(this.items[t]);)t++;let n=t===this.firstIdx?null:this.items.slice(this.firstIdx,t);return this.firstIdx=t,n}peek(){if(this.length!==0)return this.items[this.firstIdx]}dequeue(){let e=this.items[this.firstIdx];return this.firstIdx++,e}takeCount(e){let t=this.items.slice(this.firstIdx,this.firstIdx+e);return this.firstIdx+=e,t}},le=class e{static{this.empty=new e(e=>{})}constructor(e){this.iterate=e}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||te.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}},ue=class e{constructor(e){this._indexMap=e}static createSortPermutation(t,n){let r=Array.from(t.keys()).sort((e,r)=>n(t[e],t[r]));return new e(r)}apply(e){return e.map((t,n)=>e[this._indexMap[n]])}inverse(){let t=this._indexMap.slice();for(let e=0;e<this._indexMap.length;e++)t[this._indexMap[e]]=e;return new e(t)}};function de(e){return e.reduce((e,t)=>e+t,0)}var fe=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?we.isErrorNoTelemetry(e)?new we(e.message+`
1
+ import{t as e}from"./index-D9CgZyHZ.js";function t(e){if(e.length===0)throw Error(`Invalid tail call`);return[e.slice(0,e.length-1),e[e.length-1]]}function n(e,t,n=(e,t)=>e===t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!n(e[r],t[r]))return!1;return!0}function r(e,t){let n=e.length-1;t<n&&(e[t]=e[n]),e.pop()}function i(e,t,n){return a(e.length,r=>n(e[r],t))}function a(e,t){let n=0,r=e-1;for(;n<=r;){let e=(n+r)/2|0,i=t(e);if(i<0)n=e+1;else if(i>0)r=e-1;else return e}return-(n+1)}function o(e,t,n){if(e|=0,e>=t.length)throw TypeError(`invalid index`);let r=t[Math.floor(t.length*Math.random())],i=[],a=[],s=[];for(let e of t){let t=n(e,r);t<0?i.push(e):t>0?a.push(e):s.push(e)}return e<i.length?o(e,i,n):e<i.length+s.length?s[0]:o(e-(i.length+s.length),a,n)}function s(e,t){let n=[],r;for(let i of e.slice(0).sort(t))!r||t(r[0],i)!==0?(r=[i],n.push(r)):r.push(i);return n}function*c(e,t){let n,r;for(let i of e)r!==void 0&&t(r,i)?n.push(i):(n&&(yield n),n=[i]),r=i;n&&(yield n)}function l(e,t){for(let n=0;n<=e.length;n++)t(n===0?void 0:e[n-1],n===e.length?void 0:e[n])}function u(e,t){for(let n=0;n<e.length;n++)t(n===0?void 0:e[n-1],e[n],n+1===e.length?void 0:e[n+1])}function d(e){return e.filter(e=>!!e)}function f(e){let t=0;for(let n=0;n<e.length;n++)e[n]&&(e[t]=e[n],t+=1);e.length=t}function p(e){return!Array.isArray(e)||e.length===0}function m(e){return Array.isArray(e)&&e.length>0}function h(e,t=e=>e){let n=new Set;return e.filter(e=>{let r=t(e);return!n.has(r)&&(n.add(r),!0)})}function g(e,t){let n=typeof t==`number`?e:0;typeof t==`number`?n=e:(n=0,t=e);let r=[];if(n<=t)for(let e=n;e<t;e++)r.push(e);else for(let e=n;e>t;e--)r.push(e);return r}function _(e,t,n){let r=e.slice(0,t),i=e.slice(t);return r.concat(n,i)}function v(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.unshift(t))}function y(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.push(t))}function b(e,t){for(let n of t)e.push(n)}function x(e,t){let n=[];for(let r of e){let e=t(r);e!==void 0&&n.push(e)}return n}function S(e){return Array.isArray(e)?e:[e]}function C(e,t,n){let r=ee(e,t),i=e.length,a=n.length;e.length=i+a;for(let t=i-1;t>=r;t--)e[t+a]=e[t];for(let t=0;t<a;t++)e[t+r]=n[t]}function w(e,t,n,r){let i=ee(e,t),a=e.splice(i,n);return a===void 0&&(a=[]),C(e,i,r),a}function ee(e,t){return t<0?Math.max(t+e.length,0):Math.min(t,e.length)}var te;(function(e){function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(te||={});function ne(e,t){return(n,r)=>t(e(n),e(r))}function re(...e){return(t,n)=>{for(let r of e){let e=r(t,n);if(!te.isNeitherLessOrGreaterThan(e))return e}return te.neitherLessOrGreaterThan}}var ie=(e,t)=>e-t,ae=(e,t)=>ie(+!!e,+!!t);function oe(e){return(t,n)=>-e(t,n)}function se(e){return(t,n)=>t===void 0?n===void 0?te.neitherLessOrGreaterThan:te.lessThan:n===void 0?te.greaterThan:e(t,n)}var ce=class{constructor(e){this.firstIdx=0,this.items=e,this.lastIdx=this.items.length-1}get length(){return this.lastIdx-this.firstIdx+1}takeWhile(e){let t=this.firstIdx;for(;t<=this.lastIdx&&e(this.items[t]);)t++;let n=t===this.firstIdx?null:this.items.slice(this.firstIdx,t);return this.firstIdx=t,n}peek(){if(this.length!==0)return this.items[this.firstIdx]}dequeue(){let e=this.items[this.firstIdx];return this.firstIdx++,e}takeCount(e){let t=this.items.slice(this.firstIdx,this.firstIdx+e);return this.firstIdx+=e,t}},le=class e{static{this.empty=new e(e=>{})}constructor(e){this.iterate=e}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||te.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}},ue=class e{constructor(e){this._indexMap=e}static createSortPermutation(t,n){let r=Array.from(t.keys()).sort((e,r)=>n(t[e],t[r]));return new e(r)}apply(e){return e.map((t,n)=>e[this._indexMap[n]])}inverse(){let t=this._indexMap.slice();for(let e=0;e<this._indexMap.length;e++)t[this._indexMap[e]]=e;return new e(t)}};function de(e){return e.reduce((e,t)=>e+t,0)}var fe=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?we.isErrorNoTelemetry(e)?new we(e.message+`
2
2
 
3
3
  `+e.stack):Error(e.message+`
4
4