@hue-run/sdk 0.21.1 → 0.22.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.
- package/CLI.md +246 -52
- package/README.md +54 -13
- package/WORLDS.md +6 -3
- package/dist/ai-sdk.d.ts +23 -1
- package/dist/ai-sdk.js +60 -2
- package/dist/cli/import-formats/adapter.d.ts +80 -0
- package/dist/cli/import-formats/adapter.js +1 -0
- package/dist/cli/import-formats/agent-events.d.ts +5 -0
- package/dist/cli/import-formats/agent-events.js +16 -0
- package/dist/cli/import-formats/atif.d.ts +3 -0
- package/dist/cli/import-formats/atif.js +15 -0
- package/dist/cli/import-formats/braintrust.d.ts +2 -0
- package/dist/cli/import-formats/braintrust.js +222 -0
- package/dist/cli/import-formats/containers.d.ts +32 -0
- package/dist/cli/import-formats/containers.js +399 -0
- package/dist/cli/import-formats/datadog.d.ts +2 -0
- package/dist/cli/import-formats/datadog.js +264 -0
- package/dist/cli/import-formats/helicone.d.ts +2 -0
- package/dist/cli/import-formats/helicone.js +161 -0
- package/dist/cli/import-formats/identity.d.ts +112 -0
- package/dist/cli/import-formats/identity.js +594 -0
- package/dist/cli/import-formats/jaeger.d.ts +3 -0
- package/dist/cli/import-formats/jaeger.js +266 -0
- package/dist/cli/import-formats/langfuse.d.ts +7 -0
- package/dist/cli/import-formats/langfuse.js +510 -0
- package/dist/cli/import-formats/langsmith.d.ts +2 -0
- package/dist/cli/import-formats/langsmith.js +244 -0
- package/dist/cli/import-formats/messages.d.ts +28 -0
- package/dist/cli/import-formats/messages.js +301 -0
- package/dist/cli/import-formats/mlflow.d.ts +2 -0
- package/dist/cli/import-formats/mlflow.js +260 -0
- package/dist/cli/import-formats/openai-agents.d.ts +2 -0
- package/dist/cli/import-formats/openai-agents.js +221 -0
- package/dist/cli/import-formats/opik.d.ts +2 -0
- package/dist/cli/import-formats/opik.js +193 -0
- package/dist/cli/import-formats/otel-family.d.ts +5 -0
- package/dist/cli/import-formats/otel-family.js +17 -0
- package/dist/cli/import-formats/otel-spans.d.ts +94 -0
- package/dist/cli/import-formats/otel-spans.js +262 -0
- package/dist/cli/import-formats/otlp-protobuf.d.ts +35 -0
- package/dist/cli/import-formats/otlp-protobuf.js +486 -0
- package/dist/cli/import-formats/otlp.d.ts +4 -0
- package/dist/cli/import-formats/otlp.js +15 -0
- package/dist/cli/import-formats/phoenix.d.ts +3 -0
- package/dist/cli/import-formats/phoenix.js +256 -0
- package/dist/cli/import-formats/raindrop.d.ts +21 -0
- package/dist/cli/import-formats/raindrop.js +255 -0
- package/dist/cli/import-formats/reader.d.ts +56 -0
- package/dist/cli/import-formats/reader.js +364 -0
- package/dist/cli/import-formats/registry.d.ts +36 -0
- package/dist/cli/import-formats/registry.js +71 -0
- package/dist/cli/import-formats/row-platform-fields.d.ts +32 -0
- package/dist/cli/import-formats/row-platform-fields.js +76 -0
- package/dist/cli/import-formats/rows.d.ts +165 -0
- package/dist/cli/import-formats/rows.js +638 -0
- package/dist/cli/import-formats/transcripts.d.ts +25 -0
- package/dist/cli/import-formats/transcripts.js +498 -0
- package/dist/cli/import-formats/weave.d.ts +2 -0
- package/dist/cli/import-formats/weave.js +159 -0
- package/dist/cli/import-formats/zipkin.d.ts +2 -0
- package/dist/cli/import-formats/zipkin.js +219 -0
- package/dist/cli/import.d.ts +1 -1
- package/dist/cli/import.js +4 -2
- package/dist/cli/traces-import-convert.d.ts +65 -33
- package/dist/cli/traces-import-convert.js +211 -214
- package/dist/cli/traces-import-prepare.d.ts +26 -22
- package/dist/cli/traces-import-prepare.js +51 -122
- package/dist/cli/traces-import.d.ts +4 -4
- package/dist/cli/traces-import.js +63 -11
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { type ConvertedTrace, type JsonValue, type Refusal } from "../traces-import-convert.js";
|
|
2
|
+
import type { ConvertContext, Location, TraceCollector } from "./adapter.js";
|
|
3
|
+
import { type IdentityKeys } from "./identity.js";
|
|
4
|
+
/**
|
|
5
|
+
* The canonical span row every row format maps its records to, and the one emitter that turns a
|
|
6
|
+
* trace's rows into the OTLP spans Hue reads: the GenAI conventions for the operation, model,
|
|
7
|
+
* messages, tool call and usage, the end user and conversation on the trace's root, and the
|
|
8
|
+
* source record whole beside them. Nothing else writes spans for a row format.
|
|
9
|
+
*/
|
|
10
|
+
/** What a span did, as the GenAI conventions name it (`gen_ai.operation.name`). A span of none of
|
|
11
|
+
* these (a task, a chain, a scorer) records no operation. */
|
|
12
|
+
export type SpanKind = "agent" | "llm" | "tool" | "embedding" | "retrieval";
|
|
13
|
+
export interface SpanRow {
|
|
14
|
+
/** The source's trace id. Kept when it is 32 hex digits, otherwise mapped by SHA-256 with the
|
|
15
|
+
* original kept as `hue.import.original_trace_id`. */
|
|
16
|
+
traceKey: string;
|
|
17
|
+
/** The source's span id: kept when it is 16 hex digits, otherwise mapped likewise. */
|
|
18
|
+
spanKey: string;
|
|
19
|
+
/** The parent's span id in the source. A parent the export does not hold leaves the span a
|
|
20
|
+
* root of the trace, with the original kept as `hue.import.original_parent_span_id`. */
|
|
21
|
+
parentKey?: string;
|
|
22
|
+
/** Further parents, emitted as span links. */
|
|
23
|
+
linkKeys?: string[];
|
|
24
|
+
/** Links the source records to a span of this trace or of another, by that trace's and span's
|
|
25
|
+
* keys as recorded, mapped to OpenTelemetry ids as their own spans' are. */
|
|
26
|
+
links?: {
|
|
27
|
+
traceKey: string;
|
|
28
|
+
spanKey: string;
|
|
29
|
+
attributes?: Record<string, JsonValue>;
|
|
30
|
+
}[];
|
|
31
|
+
name: string;
|
|
32
|
+
kind?: SpanKind;
|
|
33
|
+
/** `gen_ai.operation.name` when the kind's is not the source's. */
|
|
34
|
+
operation?: string;
|
|
35
|
+
/** Recorded instants, in Unix nanoseconds (see {@link nanosFrom}). A missing one is inferred by
|
|
36
|
+
* the documented rule and named in `hue.import.timing`. */
|
|
37
|
+
start?: bigint;
|
|
38
|
+
end?: bigint;
|
|
39
|
+
/** How the adapter took a recorded instant from another field, such as `start_from_created`;
|
|
40
|
+
* several rules are separated by `; `. */
|
|
41
|
+
timing?: string;
|
|
42
|
+
model?: string;
|
|
43
|
+
responseModel?: string;
|
|
44
|
+
provider?: string;
|
|
45
|
+
agentName?: string;
|
|
46
|
+
/** Content as recorded: chat messages in any common shape become `gen_ai.input.messages` and
|
|
47
|
+
* `gen_ai.output.messages`; anything else is kept as `input.value` and `output.value`. */
|
|
48
|
+
input?: JsonValue;
|
|
49
|
+
output?: JsonValue;
|
|
50
|
+
systemInstructions?: JsonValue;
|
|
51
|
+
/** A tool call's own fields; `arguments` and `result` default to `input` and `output`. */
|
|
52
|
+
tool?: {
|
|
53
|
+
name?: string;
|
|
54
|
+
callId?: string;
|
|
55
|
+
type?: string;
|
|
56
|
+
arguments?: JsonValue;
|
|
57
|
+
result?: JsonValue;
|
|
58
|
+
};
|
|
59
|
+
usage?: {
|
|
60
|
+
input?: number;
|
|
61
|
+
output?: number;
|
|
62
|
+
cacheRead?: number;
|
|
63
|
+
cacheWrite?: number;
|
|
64
|
+
reasoning?: number;
|
|
65
|
+
};
|
|
66
|
+
error?: {
|
|
67
|
+
message?: string;
|
|
68
|
+
type?: string;
|
|
69
|
+
};
|
|
70
|
+
/** The end user and conversation the record names. Never taken from a tool row: a tool's
|
|
71
|
+
* arguments and result may name the account it acted on, never who asked. */
|
|
72
|
+
user?: string;
|
|
73
|
+
session?: string;
|
|
74
|
+
/** Evaluation or simulation traffic, which Hue keeps out of production history. */
|
|
75
|
+
origin?: "evaluation" | "simulation";
|
|
76
|
+
/** The vendor's own evaluation recorded inside the trace (a scorer, a judge, an automation):
|
|
77
|
+
* this row and every row beneath it are emitted without a GenAI operation, model, messages,
|
|
78
|
+
* tool call, usage or identity attribute, their content kept as `input.value`/`output.value`,
|
|
79
|
+
* and never name the trace's user or conversation, as a tool's subtree never does. */
|
|
80
|
+
scoring?: boolean;
|
|
81
|
+
/** The deployment environment the source recorded (`deployment.environment.name`). */
|
|
82
|
+
environment?: string;
|
|
83
|
+
/** The format's own attributes, under its own names (never `hue.import.*`). */
|
|
84
|
+
attributes?: Record<string, JsonValue>;
|
|
85
|
+
resource?: Record<string, JsonValue>;
|
|
86
|
+
/** The whole source record, kept as `hue.import.source_record`. */
|
|
87
|
+
record: JsonValue;
|
|
88
|
+
/** Where a dotted `--user-key` or `--session-key` looks after the span's attributes. */
|
|
89
|
+
metadata?: JsonValue;
|
|
90
|
+
/** A revision of a record exported more than once: the highest is kept. Decimal digits compare
|
|
91
|
+
* as numbers. Without one, copies of a span must agree. */
|
|
92
|
+
revision?: string;
|
|
93
|
+
/** The record's position in its source, used to order an untimed trace. */
|
|
94
|
+
sequence?: number;
|
|
95
|
+
}
|
|
96
|
+
/** A point in time on a span (a log line, a message): a span event. */
|
|
97
|
+
export interface EventRow {
|
|
98
|
+
traceKey: string;
|
|
99
|
+
spanKey: string;
|
|
100
|
+
name: string;
|
|
101
|
+
time?: bigint;
|
|
102
|
+
attributes?: Record<string, JsonValue>;
|
|
103
|
+
record: JsonValue;
|
|
104
|
+
}
|
|
105
|
+
declare const UNITS: {
|
|
106
|
+
readonly s: 9;
|
|
107
|
+
readonly ms: 6;
|
|
108
|
+
readonly us: 3;
|
|
109
|
+
readonly ns: 0;
|
|
110
|
+
};
|
|
111
|
+
/** A timestamp in `unit` (a number or its decimal text, exponent allowed) as Unix nanoseconds,
|
|
112
|
+
* read from its decimal digits so no float rounding is added. */
|
|
113
|
+
export declare function nanosFrom(value: unknown, unit: keyof typeof UNITS): bigint;
|
|
114
|
+
/** Reads each record with `read`: a record that throws a ConversionError (or is too deep or
|
|
115
|
+
* large to walk) refuses the trace `traceKeyOf` names (or is reported alone), never the rest of
|
|
116
|
+
* the value. */
|
|
117
|
+
export declare function readRecords<T>(context: ConvertContext, records: readonly T[], traceKeyOf: (record: T) => string | undefined, read: (record: T) => void): void;
|
|
118
|
+
/** The OpenTelemetry trace id of a row format's trace: its own id when it is one, otherwise one
|
|
119
|
+
* derived from the format and the id by SHA-256. */
|
|
120
|
+
export declare const rowTraceId: (format: string, traceKey: string) => string;
|
|
121
|
+
/** Gathers one row format's rows by trace across files and lines, and emits each trace. */
|
|
122
|
+
export declare class RowTraceCollector implements TraceCollector {
|
|
123
|
+
private readonly format;
|
|
124
|
+
private readonly keys;
|
|
125
|
+
private readonly traces;
|
|
126
|
+
constructor(format: string, keys?: IdentityKeys);
|
|
127
|
+
private draft;
|
|
128
|
+
/**
|
|
129
|
+
* Adds a row read at `at`. Returns where an identical copy of the record was read before, when
|
|
130
|
+
* one was read somewhere else: the record is then read once, and the caller may say so.
|
|
131
|
+
*/
|
|
132
|
+
add(row: SpanRow, sourceDigest: string, at?: Location): Location | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* Adds an event. `repeats` counts, for one source value, the identical records it gave each span
|
|
135
|
+
* so far: an event the value repeats on a span is kept each time, the same value read again (a
|
|
136
|
+
* file read twice) adds nothing.
|
|
137
|
+
*/
|
|
138
|
+
addEvent(event: EventRow, sourceDigest: string, repeats?: Map<string, number>): void;
|
|
139
|
+
finish(): {
|
|
140
|
+
traces: ConvertedTrace[];
|
|
141
|
+
refused: Refusal[];
|
|
142
|
+
};
|
|
143
|
+
private emit;
|
|
144
|
+
}
|
|
145
|
+
/** Whether the parents of a trace's rows close on themselves anywhere; each row's ancestry is
|
|
146
|
+
* walked once, so the check takes time in proportion to the rows. */
|
|
147
|
+
export declare function cyclic(rows: ReadonlyMap<string, SpanRow>, parentOf: (row: SpanRow) => string | undefined): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Every span's start and end, the recorded ones kept and the rest inferred by these rules, each
|
|
150
|
+
* named in the span's `hue.import.timing` and the report:
|
|
151
|
+
* - `start_at_end`: no start but an end: the span starts at its end;
|
|
152
|
+
* - `start_from_parent`: no instant at all: the span starts with its parent;
|
|
153
|
+
* - `start_from_trace`: nor has its parent: it starts with the trace's earliest recorded instant;
|
|
154
|
+
* - `untimed_trace`: the trace records no instant: spans are placed at 2000-01-01T00:00:00Z, a
|
|
155
|
+
* millisecond apart in source order;
|
|
156
|
+
* - `end_from_children` / `end_at_start`: no end: the span ends with its last child, else at its
|
|
157
|
+
* start.
|
|
158
|
+
* A recorded end before its start refuses the trace.
|
|
159
|
+
*/
|
|
160
|
+
export declare function timesOf(rows: ReadonlyMap<string, SpanRow>, parentOf: (row: SpanRow) => string | undefined): {
|
|
161
|
+
starts: Map<string, bigint>;
|
|
162
|
+
ends: Map<string, bigint>;
|
|
163
|
+
notes: Map<string, string[]>;
|
|
164
|
+
};
|
|
165
|
+
export {};
|