@root-signals/scorable-cli 0.7.0 → 0.9.0

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 (43) hide show
  1. package/README.md +222 -0
  2. package/dist/client.d.ts +10 -2
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +10 -6
  5. package/dist/commands/otel-filter/create.d.ts +3 -0
  6. package/dist/commands/otel-filter/create.d.ts.map +1 -0
  7. package/dist/commands/otel-filter/create.js +154 -0
  8. package/dist/commands/otel-filter/delete.d.ts +3 -0
  9. package/dist/commands/otel-filter/delete.d.ts.map +1 -0
  10. package/dist/commands/otel-filter/delete.js +25 -0
  11. package/dist/commands/otel-filter/index.d.ts +3 -0
  12. package/dist/commands/otel-filter/index.d.ts.map +1 -0
  13. package/dist/commands/otel-filter/index.js +15 -0
  14. package/dist/commands/otel-filter/list.d.ts +3 -0
  15. package/dist/commands/otel-filter/list.d.ts.map +1 -0
  16. package/dist/commands/otel-filter/list.js +29 -0
  17. package/dist/commands/otel-filter/update.d.ts +3 -0
  18. package/dist/commands/otel-filter/update.d.ts.map +1 -0
  19. package/dist/commands/otel-filter/update.js +53 -0
  20. package/dist/commands/otel-filter/validate.d.ts +3 -0
  21. package/dist/commands/otel-filter/validate.d.ts.map +1 -0
  22. package/dist/commands/otel-filter/validate.js +72 -0
  23. package/dist/commands/otel-trace/index.d.ts +3 -0
  24. package/dist/commands/otel-trace/index.d.ts.map +1 -0
  25. package/dist/commands/otel-trace/index.js +9 -0
  26. package/dist/commands/otel-trace/list.d.ts +3 -0
  27. package/dist/commands/otel-trace/list.d.ts.map +1 -0
  28. package/dist/commands/otel-trace/list.js +280 -0
  29. package/dist/commands/otel-trace/shared.d.ts +17 -0
  30. package/dist/commands/otel-trace/shared.d.ts.map +1 -0
  31. package/dist/commands/otel-trace/shared.js +73 -0
  32. package/dist/commands/otel-trace/spans.d.ts +3 -0
  33. package/dist/commands/otel-trace/spans.d.ts.map +1 -0
  34. package/dist/commands/otel-trace/spans.js +135 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +4 -0
  37. package/dist/lib/filter-yaml.d.ts +179 -0
  38. package/dist/lib/filter-yaml.d.ts.map +1 -0
  39. package/dist/lib/filter-yaml.js +111 -0
  40. package/examples/otel-filters/claude-code.yaml +31 -0
  41. package/examples/otel-filters/genai-explicit.yaml +16 -0
  42. package/examples/otel-filters/openinference-agent.yaml +17 -0
  43. package/package.json +4 -2
@@ -0,0 +1,179 @@
1
+ import { z } from "zod";
2
+ export declare const FilterYamlSchema: z.ZodObject<{
3
+ name: z.ZodString;
4
+ evaluator_id: z.ZodOptional<z.ZodString>;
5
+ judge_id: z.ZodOptional<z.ZodString>;
6
+ filter_criteria: z.ZodDefault<z.ZodObject<{
7
+ conditions: z.ZodDefault<z.ZodArray<z.ZodObject<{
8
+ column: z.ZodString;
9
+ operator: z.ZodString;
10
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
11
+ key: z.ZodOptional<z.ZodString>;
12
+ }, z.core.$strict>>>;
13
+ }, z.core.$strict>>;
14
+ sampling_rate: z.ZodOptional<z.ZodNumber>;
15
+ delay_seconds: z.ZodOptional<z.ZodNumber>;
16
+ is_active: z.ZodOptional<z.ZodBoolean>;
17
+ extractor_rules: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
18
+ emit: z.ZodLiteral<"text">;
19
+ match: z.ZodOptional<z.ZodObject<{
20
+ conditions: z.ZodDefault<z.ZodArray<z.ZodObject<{
21
+ column: z.ZodString;
22
+ operator: z.ZodString;
23
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
24
+ key: z.ZodOptional<z.ZodString>;
25
+ }, z.core.$strict>>>;
26
+ }, z.core.$strict>>;
27
+ role: z.ZodEnum<{
28
+ user: "user";
29
+ assistant: "assistant";
30
+ }>;
31
+ locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
32
+ kind: z.ZodLiteral<"span_attr">;
33
+ key: z.ZodString;
34
+ value_path: z.ZodOptional<z.ZodString>;
35
+ }, z.core.$strict>, z.ZodObject<{
36
+ kind: z.ZodLiteral<"resource_attr">;
37
+ key: z.ZodString;
38
+ value_path: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strict>, z.ZodObject<{
40
+ kind: z.ZodLiteral<"event_attr">;
41
+ key: z.ZodString;
42
+ event_name: z.ZodString;
43
+ value_path: z.ZodOptional<z.ZodString>;
44
+ }, z.core.$strict>], "kind">;
45
+ tool_name: z.ZodOptional<z.ZodString>;
46
+ }, z.core.$strict>, z.ZodObject<{
47
+ emit: z.ZodLiteral<"request_response">;
48
+ match: z.ZodOptional<z.ZodObject<{
49
+ conditions: z.ZodDefault<z.ZodArray<z.ZodObject<{
50
+ column: z.ZodString;
51
+ operator: z.ZodString;
52
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
53
+ key: z.ZodOptional<z.ZodString>;
54
+ }, z.core.$strict>>>;
55
+ }, z.core.$strict>>;
56
+ input_locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
57
+ kind: z.ZodLiteral<"span_attr">;
58
+ key: z.ZodString;
59
+ value_path: z.ZodOptional<z.ZodString>;
60
+ }, z.core.$strict>, z.ZodObject<{
61
+ kind: z.ZodLiteral<"resource_attr">;
62
+ key: z.ZodString;
63
+ value_path: z.ZodOptional<z.ZodString>;
64
+ }, z.core.$strict>, z.ZodObject<{
65
+ kind: z.ZodLiteral<"event_attr">;
66
+ key: z.ZodString;
67
+ event_name: z.ZodString;
68
+ value_path: z.ZodOptional<z.ZodString>;
69
+ }, z.core.$strict>], "kind">;
70
+ output_locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
71
+ kind: z.ZodLiteral<"span_attr">;
72
+ key: z.ZodString;
73
+ value_path: z.ZodOptional<z.ZodString>;
74
+ }, z.core.$strict>, z.ZodObject<{
75
+ kind: z.ZodLiteral<"resource_attr">;
76
+ key: z.ZodString;
77
+ value_path: z.ZodOptional<z.ZodString>;
78
+ }, z.core.$strict>, z.ZodObject<{
79
+ kind: z.ZodLiteral<"event_attr">;
80
+ key: z.ZodString;
81
+ event_name: z.ZodString;
82
+ value_path: z.ZodOptional<z.ZodString>;
83
+ }, z.core.$strict>], "kind">;
84
+ }, z.core.$strict>, z.ZodObject<{
85
+ emit: z.ZodLiteral<"tool_pair">;
86
+ match: z.ZodOptional<z.ZodObject<{
87
+ conditions: z.ZodDefault<z.ZodArray<z.ZodObject<{
88
+ column: z.ZodString;
89
+ operator: z.ZodString;
90
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
91
+ key: z.ZodOptional<z.ZodString>;
92
+ }, z.core.$strict>>>;
93
+ }, z.core.$strict>>;
94
+ input_locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
95
+ kind: z.ZodLiteral<"span_attr">;
96
+ key: z.ZodString;
97
+ value_path: z.ZodOptional<z.ZodString>;
98
+ }, z.core.$strict>, z.ZodObject<{
99
+ kind: z.ZodLiteral<"resource_attr">;
100
+ key: z.ZodString;
101
+ value_path: z.ZodOptional<z.ZodString>;
102
+ }, z.core.$strict>, z.ZodObject<{
103
+ kind: z.ZodLiteral<"event_attr">;
104
+ key: z.ZodString;
105
+ event_name: z.ZodString;
106
+ value_path: z.ZodOptional<z.ZodString>;
107
+ }, z.core.$strict>], "kind">;
108
+ output_locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
109
+ kind: z.ZodLiteral<"span_attr">;
110
+ key: z.ZodString;
111
+ value_path: z.ZodOptional<z.ZodString>;
112
+ }, z.core.$strict>, z.ZodObject<{
113
+ kind: z.ZodLiteral<"resource_attr">;
114
+ key: z.ZodString;
115
+ value_path: z.ZodOptional<z.ZodString>;
116
+ }, z.core.$strict>, z.ZodObject<{
117
+ kind: z.ZodLiteral<"event_attr">;
118
+ key: z.ZodString;
119
+ event_name: z.ZodString;
120
+ value_path: z.ZodOptional<z.ZodString>;
121
+ }, z.core.$strict>], "kind">;
122
+ tool_name: z.ZodOptional<z.ZodString>;
123
+ tool_name_locator: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
124
+ kind: z.ZodLiteral<"span_attr">;
125
+ key: z.ZodString;
126
+ value_path: z.ZodOptional<z.ZodString>;
127
+ }, z.core.$strict>, z.ZodObject<{
128
+ kind: z.ZodLiteral<"resource_attr">;
129
+ key: z.ZodString;
130
+ value_path: z.ZodOptional<z.ZodString>;
131
+ }, z.core.$strict>, z.ZodObject<{
132
+ kind: z.ZodLiteral<"event_attr">;
133
+ key: z.ZodString;
134
+ event_name: z.ZodString;
135
+ value_path: z.ZodOptional<z.ZodString>;
136
+ }, z.core.$strict>], "kind">>;
137
+ }, z.core.$strict>, z.ZodObject<{
138
+ emit: z.ZodLiteral<"genai_messages">;
139
+ match: z.ZodOptional<z.ZodObject<{
140
+ conditions: z.ZodDefault<z.ZodArray<z.ZodObject<{
141
+ column: z.ZodString;
142
+ operator: z.ZodString;
143
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
144
+ key: z.ZodOptional<z.ZodString>;
145
+ }, z.core.$strict>>>;
146
+ }, z.core.$strict>>;
147
+ input_locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
148
+ kind: z.ZodLiteral<"span_attr">;
149
+ key: z.ZodString;
150
+ value_path: z.ZodOptional<z.ZodString>;
151
+ }, z.core.$strict>, z.ZodObject<{
152
+ kind: z.ZodLiteral<"resource_attr">;
153
+ key: z.ZodString;
154
+ value_path: z.ZodOptional<z.ZodString>;
155
+ }, z.core.$strict>, z.ZodObject<{
156
+ kind: z.ZodLiteral<"event_attr">;
157
+ key: z.ZodString;
158
+ event_name: z.ZodString;
159
+ value_path: z.ZodOptional<z.ZodString>;
160
+ }, z.core.$strict>], "kind">;
161
+ output_locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
162
+ kind: z.ZodLiteral<"span_attr">;
163
+ key: z.ZodString;
164
+ value_path: z.ZodOptional<z.ZodString>;
165
+ }, z.core.$strict>, z.ZodObject<{
166
+ kind: z.ZodLiteral<"resource_attr">;
167
+ key: z.ZodString;
168
+ value_path: z.ZodOptional<z.ZodString>;
169
+ }, z.core.$strict>, z.ZodObject<{
170
+ kind: z.ZodLiteral<"event_attr">;
171
+ key: z.ZodString;
172
+ event_name: z.ZodString;
173
+ value_path: z.ZodOptional<z.ZodString>;
174
+ }, z.core.$strict>], "kind">;
175
+ }, z.core.$strict>], "emit">>>;
176
+ }, z.core.$strict>;
177
+ export type FilterYaml = z.infer<typeof FilterYamlSchema>;
178
+ export declare function loadFilterYaml(source: string): FilterYaml;
179
+ //# sourceMappingURL=filter-yaml.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-yaml.d.ts","sourceRoot":"","sources":["../../src/lib/filter-yaml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyFxB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAczB,CAAC;AAEL,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAczD"}
@@ -0,0 +1,111 @@
1
+ import { z } from "zod";
2
+ import yaml from "js-yaml";
3
+ const MatchCondition = z
4
+ .object({
5
+ column: z.string(),
6
+ operator: z.string(),
7
+ value: z.union([z.string(), z.number(), z.boolean()]).optional(),
8
+ key: z.string().optional(),
9
+ })
10
+ .strict();
11
+ const Match = z
12
+ .object({
13
+ conditions: z.array(MatchCondition).default([]),
14
+ })
15
+ .strict();
16
+ const Locator = z.discriminatedUnion("kind", [
17
+ z
18
+ .object({
19
+ kind: z.literal("span_attr"),
20
+ key: z.string(),
21
+ value_path: z.string().optional(),
22
+ })
23
+ .strict(),
24
+ z
25
+ .object({
26
+ kind: z.literal("resource_attr"),
27
+ key: z.string(),
28
+ value_path: z.string().optional(),
29
+ })
30
+ .strict(),
31
+ z
32
+ .object({
33
+ kind: z.literal("event_attr"),
34
+ key: z.string(),
35
+ event_name: z.string(),
36
+ value_path: z.string().optional(),
37
+ })
38
+ .strict(),
39
+ ]);
40
+ const TextRule = z
41
+ .object({
42
+ emit: z.literal("text"),
43
+ match: Match.optional(),
44
+ role: z.enum(["user", "assistant"]),
45
+ locator: Locator,
46
+ tool_name: z.string().optional(),
47
+ })
48
+ .strict();
49
+ const RequestResponseRule = z
50
+ .object({
51
+ emit: z.literal("request_response"),
52
+ match: Match.optional(),
53
+ input_locator: Locator,
54
+ output_locator: Locator,
55
+ })
56
+ .strict();
57
+ const ToolPairRule = z
58
+ .object({
59
+ emit: z.literal("tool_pair"),
60
+ match: Match.optional(),
61
+ input_locator: Locator,
62
+ output_locator: Locator,
63
+ tool_name: z.string().optional(),
64
+ tool_name_locator: Locator.optional(),
65
+ })
66
+ .strict();
67
+ const GenAiMessagesRule = z
68
+ .object({
69
+ emit: z.literal("genai_messages"),
70
+ match: Match.optional(),
71
+ input_locator: Locator,
72
+ output_locator: Locator,
73
+ })
74
+ .strict();
75
+ const ExtractorRule = z.discriminatedUnion("emit", [
76
+ TextRule,
77
+ RequestResponseRule,
78
+ ToolPairRule,
79
+ GenAiMessagesRule,
80
+ ]);
81
+ export const FilterYamlSchema = z
82
+ .object({
83
+ name: z.string(),
84
+ evaluator_id: z.string().optional(),
85
+ judge_id: z.string().optional(),
86
+ filter_criteria: Match.default({ conditions: [] }),
87
+ sampling_rate: z.number().min(0).max(1).optional(),
88
+ delay_seconds: z.number().int().min(0).optional(),
89
+ is_active: z.boolean().optional(),
90
+ extractor_rules: z.array(ExtractorRule).default([]),
91
+ })
92
+ .strict()
93
+ .refine((v) => Boolean(v.evaluator_id) !== Boolean(v.judge_id), {
94
+ message: "exactly one of evaluator_id or judge_id is required",
95
+ });
96
+ export function loadFilterYaml(source) {
97
+ let raw;
98
+ try {
99
+ raw = yaml.load(source);
100
+ }
101
+ catch (err) {
102
+ const msg = err instanceof Error ? err.message : String(err);
103
+ throw new Error(`Invalid YAML: ${msg}`);
104
+ }
105
+ const result = FilterYamlSchema.safeParse(raw);
106
+ if (!result.success) {
107
+ const issues = result.error.issues.map((i) => `${i.path.join(".") || "<root>"}: ${i.message}`);
108
+ throw new Error(`Invalid filter YAML:\n${issues.join("\n")}`);
109
+ }
110
+ return result.data;
111
+ }
@@ -0,0 +1,31 @@
1
+ name: claude-code-conversation-eval
2
+ judge_id: 0193b6a0-e75d-7a47-9c6f-2f3e3b8f7c91
3
+ sampling_rate: 1.0
4
+ delay_seconds: 60
5
+ is_active: true
6
+
7
+ filter_criteria:
8
+ conditions:
9
+ - column: span_name
10
+ operator: starts_with
11
+ value: claude_code.
12
+
13
+ extractor_rules:
14
+ - emit: text
15
+ match:
16
+ conditions:
17
+ - column: span_name
18
+ operator: "="
19
+ value: claude_code.interaction
20
+ role: user
21
+ locator: { kind: span_attr, key: user_prompt }
22
+
23
+ - emit: tool_pair
24
+ match:
25
+ conditions:
26
+ - column: span_name
27
+ operator: "="
28
+ value: claude_code.tool
29
+ tool_name: Bash
30
+ input_locator: { kind: event_attr, event_name: tool.output, key: bash_command }
31
+ output_locator: { kind: event_attr, event_name: tool.output, key: output }
@@ -0,0 +1,16 @@
1
+ name: custom-genai-keys-eval
2
+ judge_id: 0193b6a0-e75d-7a47-9c6f-2f3e3b8f7c91
3
+ sampling_rate: 1.0
4
+ delay_seconds: 60
5
+ is_active: true
6
+
7
+ filter_criteria:
8
+ conditions:
9
+ - column: span_name
10
+ operator: starts_with
11
+ value: my_framework.
12
+
13
+ extractor_rules:
14
+ - emit: genai_messages
15
+ input_locator: { kind: span_attr, key: my_framework.input.json }
16
+ output_locator: { kind: span_attr, key: my_framework.output.json }
@@ -0,0 +1,17 @@
1
+ name: openinference-agent-eval
2
+ judge_id: 0193b6a0-e75d-7a47-9c6f-2f3e3b8f7c91
3
+ sampling_rate: 1.0
4
+ delay_seconds: 60
5
+ is_active: true
6
+
7
+ filter_criteria:
8
+ conditions:
9
+ - column: attribute
10
+ key: openinference.span.kind
11
+ operator: eq
12
+ value: AGENT
13
+
14
+ extractor_rules:
15
+ - emit: request_response
16
+ input_locator: { kind: span_attr, key: input.value }
17
+ output_locator: { kind: span_attr, key: output.value }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@root-signals/scorable-cli",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "CLI for Scorable",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Scorable",
@@ -13,6 +13,7 @@
13
13
  "dist/**/*.js.map",
14
14
  "dist/**/*.d.ts",
15
15
  "dist/**/*.d.ts.map",
16
+ "examples/**/*.yaml",
16
17
  "README.md",
17
18
  "LICENSE"
18
19
  ],
@@ -36,7 +37,8 @@
36
37
  "cli-table3": "^0.6.5",
37
38
  "commander": "^14.0.3",
38
39
  "js-yaml": "^4.1.1",
39
- "ora": "^9.3.0"
40
+ "ora": "^9.3.0",
41
+ "zod": "^4.4.3"
40
42
  },
41
43
  "devDependencies": {
42
44
  "@types/js-yaml": "^4.0.9",