@pome-sh/checks 0.1.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 (66) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +88 -0
  3. package/dist/_types/sdk/check-discrimination.d.ts +7 -0
  4. package/dist/_types/sdk/check-state-path.d.ts +71 -0
  5. package/dist/_types/sdk/checks.d.ts +93 -0
  6. package/dist/_types/sdk/db.d.ts +44 -0
  7. package/dist/_types/sdk/failure-injection-rules.d.ts +32 -0
  8. package/dist/_types/twin-github/src/check-kind.d.ts +3 -0
  9. package/dist/_types/twin-github/src/check-state.d.ts +77 -0
  10. package/dist/_types/twin-github/src/checks.d.ts +50 -0
  11. package/dist/_types/twin-github/src/seed.d.ts +92 -0
  12. package/dist/_types/twin-github/src/types.d.ts +244 -0
  13. package/dist/_types/twin-gmail/src/check-kind.d.ts +3 -0
  14. package/dist/_types/twin-gmail/src/check-state.d.ts +138 -0
  15. package/dist/_types/twin-gmail/src/checks.d.ts +19 -0
  16. package/dist/_types/twin-gmail/src/faults.d.ts +21 -0
  17. package/dist/_types/twin-gmail/src/seed.d.ts +247 -0
  18. package/dist/_types/twin-gmail/src/types.d.ts +150 -0
  19. package/dist/_types/twin-linear/src/check-kind.d.ts +3 -0
  20. package/dist/_types/twin-linear/src/check-state.d.ts +123 -0
  21. package/dist/_types/twin-linear/src/checks.d.ts +29 -0
  22. package/dist/_types/twin-linear/src/seed.d.ts +166 -0
  23. package/dist/_types/twin-linear/src/types.d.ts +366 -0
  24. package/dist/_types/twin-slack/src/check-kind.d.ts +3 -0
  25. package/dist/_types/twin-slack/src/check-state.d.ts +107 -0
  26. package/dist/_types/twin-slack/src/checks.d.ts +14 -0
  27. package/dist/_types/twin-slack/src/seed.d.ts +62 -0
  28. package/dist/_types/twin-slack/src/types.d.ts +182 -0
  29. package/dist/_types/twin-stripe/src/check-kind.d.ts +3 -0
  30. package/dist/_types/twin-stripe/src/check-state.d.ts +107 -0
  31. package/dist/_types/twin-stripe/src/checks.d.ts +22 -0
  32. package/dist/_types/twin-stripe/src/seed.d.ts +213 -0
  33. package/dist/_types/twin-stripe/src/types.d.ts +252 -0
  34. package/dist/_types/wire/index.d.ts +23 -0
  35. package/dist/_types/wire/otel/event-schema.d.ts +424 -0
  36. package/dist/_types/wire/otel/index.d.ts +25 -0
  37. package/dist/_types/wire/otel/legacy-shim.d.ts +105 -0
  38. package/dist/_types/wire/otel/map-span.d.ts +64 -0
  39. package/dist/_types/wire/otel/nano.d.ts +26 -0
  40. package/dist/_types/wire/otel/project.d.ts +42 -0
  41. package/dist/_types/wire/otel/semconv.d.ts +57 -0
  42. package/dist/_types/wire/otel/span-event.d.ts +198 -0
  43. package/dist/_types/wire/recorder-events.d.ts +526 -0
  44. package/dist/_types/wire/redaction.d.ts +2 -0
  45. package/dist/chunk-4WXX5VPA.js +238 -0
  46. package/dist/chunk-5SJ4PVO5.js +981 -0
  47. package/dist/chunk-GYFGMULG.js +1138 -0
  48. package/dist/chunk-IVENH4KX.js +814 -0
  49. package/dist/chunk-NORTPYDQ.js +1015 -0
  50. package/dist/chunk-SJ6SVRAA.js +432 -0
  51. package/dist/chunk-ZXE6LAM3.js +1 -0
  52. package/dist/dsl.d.ts +11 -0
  53. package/dist/dsl.js +2 -0
  54. package/dist/github.d.ts +2 -0
  55. package/dist/github.js +2 -0
  56. package/dist/gmail.d.ts +2 -0
  57. package/dist/gmail.js +2 -0
  58. package/dist/index.d.ts +163 -0
  59. package/dist/index.js +24 -0
  60. package/dist/linear.d.ts +2 -0
  61. package/dist/linear.js +2 -0
  62. package/dist/slack.d.ts +2 -0
  63. package/dist/slack.js +2 -0
  64. package/dist/stripe.d.ts +2 -0
  65. package/dist/stripe.js +2 -0
  66. package/package.json +93 -0
@@ -0,0 +1,25 @@
1
+ /**
2
+ * otel — OpenTelemetry-native trace surface (Open Telemetry Integration, M1).
3
+ *
4
+ * Barrel re-export. The golden-fixture corpus under `./fixtures/` is a
5
+ * test/dev artifact and is intentionally NOT re-exported from the public barrel.
6
+ *
7
+ * OWNERSHIP BOUNDARY (settled at FDRS-653; supersedes the earlier
8
+ * "pome-cloud mirrors this directory verbatim" claim, which no longer held):
9
+ * - FORMAT schemas are canonical HERE, in `pome-sh/pome-twins`
10
+ * `@pome-sh/shared-types` v0.5.0+ (now `@pome-sh/wire`): `span-event`, `event-schema`,
11
+ * `semconv`, `nano`, `project`, `map-span`, `legacy-shim`, and the
12
+ * `fixtures/` corpus. pome-cloud CONSUMES this surface (FDRS-654 swaps it
13
+ * onto the published package); it does not fork it.
14
+ * - INGEST-side utilities are cloud-owned consumers and intentionally do NOT
15
+ * live here: OTLP wire decoding (`decode-otlp.ts`), redaction/allowlist
16
+ * processors, storage helpers, and the raw OTLP envelope capture tooling +
17
+ * captured envelope fixtures that feed the decoder.
18
+ */
19
+ export * from "./semconv.js";
20
+ export * from "./nano.js";
21
+ export * from "./project.js";
22
+ export * from "./span-event.js";
23
+ export * from "./map-span.js";
24
+ export * from "./legacy-shim.js";
25
+ export * from "./event-schema.js";
@@ -0,0 +1,105 @@
1
+ /**
2
+ * otel/legacy-shim — legacy event → `OtelSpanEvent` translation (M1.2 / FDRS-481).
3
+ *
4
+ * The compatibility layer for the transition window: the CLI keeps uploading its
5
+ * current JSONL (no flag day), and OTel-aware downstream (M3 correlation, the
6
+ * native waterfall) reads `OtelSpanEvent`. This shim translates the three legacy
7
+ * variants — `TwinHttpEvent`, `LlmCallEvent`, `ToolUseEvent` — up into spans so
8
+ * legacy and new data share one path.
9
+ *
10
+ * Guarantees:
11
+ * - **Lossless.** The ENTIRE original record is preserved verbatim as a JSON
12
+ * string under `attributes["pome.legacy.record_json"]` — serialized from the
13
+ * raw input BEFORE Zod strips any additive fields (review finding #3). The
14
+ * mapped fields are ALSO written as canonical OTel attributes, from which
15
+ * the typed projections are derived by the SAME projector the schema checks.
16
+ * - **Deterministic.** No clock, no randomness. Same record (+ same `run_id`
17
+ * option) → byte-identical span, every run.
18
+ * - **OTel-correct status** (review findings #5/#9). HTTP client spans: 1xx–3xx
19
+ * leave status UNSET; 4xx/5xx and transport errors are ERROR. (OTel does not
20
+ * set OK on a merely-successful span.)
21
+ *
22
+ * IDs are namespaced `legacy:<source-id>` so a stored span always declares it
23
+ * originated from a pre-OTel record (the canonical schema accepts either real
24
+ * W3C ids or `legacy:` ids).
25
+ *
26
+ * Pinned convention: the shim targets `OTEL_GENAI_SCHEMA_VERSION` (see `./semconv`).
27
+ */
28
+ import { z } from "zod";
29
+ import { type OtelSpanEvent } from "./span-event.js";
30
+ export declare const LEGACY_SHIM_SEMCONV_VERSION: "1.42.0";
31
+ export declare const LEGACY_ATTR_NAMESPACE: "pome.legacy";
32
+ export declare const LEGACY_ID_PREFIX: "legacy:";
33
+ export declare const shimmableLegacyEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
34
+ ts: z.ZodString;
35
+ run_id: z.ZodString;
36
+ twin: z.ZodString;
37
+ request_id: z.ZodString;
38
+ correlation_id: z.ZodOptional<z.ZodString>;
39
+ task_step_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
40
+ scenario_step_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
41
+ step_id: z.ZodNullable<z.ZodString>;
42
+ tool_call_id: z.ZodNullable<z.ZodString>;
43
+ method: z.ZodString;
44
+ path: z.ZodString;
45
+ request_body: z.ZodUnknown;
46
+ request_headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
47
+ tool: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ status: z.ZodNumber;
49
+ response_body: z.ZodUnknown;
50
+ latency_ms: z.ZodNumber;
51
+ fidelity: z.ZodEnum<{
52
+ semantic: "semantic";
53
+ unsupported: "unsupported";
54
+ }>;
55
+ state_mutation: z.ZodBoolean;
56
+ state_delta: z.ZodNullable<z.ZodObject<{
57
+ before: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
58
+ after: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
59
+ }, z.core.$strip>>;
60
+ idempotency_dedupe: z.ZodOptional<z.ZodBoolean>;
61
+ error: z.ZodNullable<z.ZodString>;
62
+ kind: z.ZodLiteral<"TwinHttpEvent">;
63
+ event_id: z.ZodString;
64
+ parent_event_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
65
+ parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
66
+ }, z.core.$strip>, z.ZodObject<{
67
+ kind: z.ZodLiteral<"LlmCallEvent">;
68
+ host: z.ZodString;
69
+ port: z.ZodNumber;
70
+ latency_ms: z.ZodNumber;
71
+ bytes_in: z.ZodNumber;
72
+ bytes_out: z.ZodNumber;
73
+ url: z.ZodNullable<z.ZodString>;
74
+ method: z.ZodNullable<z.ZodString>;
75
+ status: z.ZodNullable<z.ZodNumber>;
76
+ model: z.ZodNullable<z.ZodString>;
77
+ prompt_tokens: z.ZodNullable<z.ZodNumber>;
78
+ completion_tokens: z.ZodNullable<z.ZodNumber>;
79
+ cost_usd: z.ZodNullable<z.ZodNumber>;
80
+ ts: z.ZodString;
81
+ event_id: z.ZodString;
82
+ parent_event_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
83
+ parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
84
+ }, z.core.$strip>, z.ZodObject<{
85
+ kind: z.ZodLiteral<"ToolUseEvent">;
86
+ tool_use_id: z.ZodString;
87
+ tool_name: z.ZodString;
88
+ input: z.ZodUnknown;
89
+ ts: z.ZodString;
90
+ event_id: z.ZodString;
91
+ parent_event_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
92
+ parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
93
+ }, z.core.$strip>], "kind">;
94
+ export type ShimmableLegacyEvent = z.infer<typeof shimmableLegacyEventSchema>;
95
+ export interface LegacyShimOptions {
96
+ run_id?: string;
97
+ }
98
+ /**
99
+ * Translate a single legacy `TwinHttpEvent` / `LlmCallEvent` / `ToolUseEvent`
100
+ * into a validated `OtelSpanEvent`.
101
+ *
102
+ * Throws a typed `ZodError` if `rawRecord` is not one of those three shapes,
103
+ * or a plain `Error` if an LLM/tool record is missing the required `run_id`.
104
+ */
105
+ export declare function shimLegacyEventToSpan(rawRecord: unknown, options?: LegacyShimOptions): OtelSpanEvent;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * otel/map-span — pure OTel span → `OtelSpanEvent` mapping (M1.1 / FDRS-480).
3
+ *
4
+ * Deterministic: same input → byte-identical event, every run. Has no clock,
5
+ * no randomness; `ts` is derived from the span's start time.
6
+ *
7
+ * Input is a NORMALIZED span: real W3C trace context (lowercase-hex ids) and a
8
+ * flat `attributes` `Record<string, value>`. Decoding raw OTLP/JSON `AnyValue`
9
+ * (`{ stringValue }`, kvlist, bytes) and the `[{ key, value }]` attribute array
10
+ * into this flat record is M2's job (the `@opentelemetry/otlp-transformer`
11
+ * dependency) — keeping M1.1 free of an OTLP decoder keeps the schema
12
+ * self-testable.
13
+ *
14
+ * Round-trip example:
15
+ *
16
+ * mapOtelSpanToEvent({
17
+ * trace_id: "4bf92f3577b34da6a3ce929d0e0e4736",
18
+ * span_id: "00f067aa0ba902b7",
19
+ * name: "chat google/gemini-2.5-flash",
20
+ * start_time_unix_nano: "1700000000000000000",
21
+ * attributes: {
22
+ * "gen_ai.provider.name": "google",
23
+ * "gen_ai.request.model": "gemini-2.5-flash",
24
+ * "gen_ai.usage.input_tokens": 42,
25
+ * },
26
+ * })
27
+ * // → { ts: "2023-11-14T22:13:20.000Z", event_id: "00f067aa0ba902b7", … }
28
+ */
29
+ import { z } from "zod";
30
+ import { type OtelSpanEvent } from "./span-event.js";
31
+ export declare const otelSpanInputSchema: z.ZodObject<{
32
+ trace_id: z.ZodString;
33
+ span_id: z.ZodString;
34
+ parent_span_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
35
+ name: z.ZodString;
36
+ kind: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
37
+ UNSPECIFIED: "UNSPECIFIED";
38
+ INTERNAL: "INTERNAL";
39
+ SERVER: "SERVER";
40
+ CLIENT: "CLIENT";
41
+ PRODUCER: "PRODUCER";
42
+ CONSUMER: "CONSUMER";
43
+ }>, z.ZodNumber]>>;
44
+ start_time_unix_nano: z.ZodString;
45
+ end_time_unix_nano: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
+ status: z.ZodOptional<z.ZodObject<{
47
+ code: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
48
+ UNSET: "UNSET";
49
+ OK: "OK";
50
+ ERROR: "ERROR";
51
+ }>, z.ZodNumber]>>;
52
+ message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
+ }, z.core.$strip>>;
54
+ attributes: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>;
55
+ }, z.core.$strip>;
56
+ export type OtelSpanInput = z.infer<typeof otelSpanInputSchema>;
57
+ /**
58
+ * Map a normalized OTLP span onto a validated `OtelSpanEvent`.
59
+ *
60
+ * Throws a `ZodError` (typed; names the offending field) when the input is
61
+ * malformed — a non-hex `trace_id`, an out-of-range unix-nano, a reversed span
62
+ * (end < start), a non-finite attribute value, etc.
63
+ */
64
+ export declare function mapOtelSpanToEvent(rawSpan: unknown): OtelSpanEvent;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * otel/nano — uint64 decimal-string arithmetic + nanosecond↔ISO conversion
3
+ * (M1.1 / FDRS-480).
4
+ *
5
+ * OTLP encodes `*_unix_nano` timestamps as uint64 decimal STRINGS because the
6
+ * values exceed Number.MAX_SAFE_INTEGER. These helpers validate and compare
7
+ * them WITHOUT `BigInt` — the dashboard compiles this source directly under a
8
+ * pre-ES2020 target where `BigInt` literals fail to typecheck (review-era
9
+ * portability fix). Everything here is pure and deterministic.
10
+ */
11
+ export declare const UINT64_MAX = "18446744073709551615";
12
+ /** True iff `value` is a non-negative decimal integer string within uint64. */
13
+ export declare function isUint64(value: string): boolean;
14
+ /**
15
+ * Compare two uint64 decimal strings. Returns <0 if a<b, 0 if equal, >0 if a>b.
16
+ * Assumes both are valid digit strings (callers validate via `isUint64` first).
17
+ */
18
+ export declare function compareUint64(a: string, b: string): number;
19
+ export declare function msToNanos(millis: number): string;
20
+ /**
21
+ * uint64 nanoseconds → ISO-8601 (UTC). Floors to milliseconds by dropping the
22
+ * last 6 decimal digits of the (uint64-validated) integer string. The resulting
23
+ * ms value is within Date's safe range for any valid uint64, so this never
24
+ * throws for input that passed `isUint64`. String-slicing avoids `BigInt`.
25
+ */
26
+ export declare function nanosToIso(unixNano: string): string;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * otel/project — the single attribute→projection function (M1.1 / FDRS-480).
3
+ *
4
+ * The typed `gen_ai_*` / `http_*` / `url_*` / `server_*` / `error_type` fields
5
+ * on an `OtelSpanEvent` are PROJECTIONS of the verbatim `attributes` bag, never
6
+ * an independent source of truth. This module is the ONE place that derivation
7
+ * lives, so:
8
+ * - the span mapper (`map-span.ts`) builds projections from `attributes`,
9
+ * - the legacy shim (`legacy-shim.ts`) builds them the same way, and
10
+ * - the schema (`span-event.ts`) re-derives them in a `superRefine` and
11
+ * rejects any event whose typed fields drift from `attributes`
12
+ * (review finding #4 — projection drift; finding #7 — centralize).
13
+ *
14
+ * Pure and deterministic. Reads only the pinned attribute names from `semconv`.
15
+ */
16
+ import { z } from "zod";
17
+ export declare const otelAttributeValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>;
18
+ export type OtelAttributeValue = z.infer<typeof otelAttributeValueSchema>;
19
+ export type OtelAttributeBag = Record<string, OtelAttributeValue>;
20
+ export declare const OTEL_PROJECTION_KEYS: readonly ["gen_ai_provider_name", "gen_ai_operation_name", "gen_ai_request_model", "gen_ai_agent_name", "gen_ai_agent_id", "gen_ai_tool_name", "gen_ai_usage_input_tokens", "gen_ai_usage_output_tokens", "http_request_method", "http_response_status_code", "url_full", "url_path", "server_address", "server_port", "error_type"];
21
+ export type OtelProjections = {
22
+ gen_ai_provider_name: string | null;
23
+ gen_ai_operation_name: string | null;
24
+ gen_ai_request_model: string | null;
25
+ gen_ai_agent_name: string | null;
26
+ gen_ai_agent_id: string | null;
27
+ gen_ai_tool_name: string | null;
28
+ gen_ai_usage_input_tokens: number | null;
29
+ gen_ai_usage_output_tokens: number | null;
30
+ http_request_method: string | null;
31
+ http_response_status_code: number | null;
32
+ url_full: string | null;
33
+ url_path: string | null;
34
+ server_address: string | null;
35
+ server_port: number | null;
36
+ error_type: string | null;
37
+ };
38
+ /**
39
+ * Derive the flat typed projections from a verbatim attribute bag. Canonical
40
+ * names win; deprecated/pre-1.27 aliases are accepted as fallbacks.
41
+ */
42
+ export declare function projectAttributes(attributes: OtelAttributeBag): OtelProjections;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * otel/semconv — pinned OpenTelemetry semantic-convention surface (M1.1 / FDRS-480).
3
+ *
4
+ * The ONE place an upstream spec change is absorbed. Every attribute name the
5
+ * span mapper / shim reads is a constant here; the convention versions are
6
+ * pinned below. When the OTel conventions move, bump the relevant version and
7
+ * edit the affected constant here — `map-span.ts`, `project.ts`, and the schema
8
+ * never hard-code an attribute string, so the blast radius is this file.
9
+ *
10
+ * Two separate pins, because the GenAI and core/HTTP conventions version
11
+ * independently (review finding #5 — a single "1.30.0" mislabelled a mixed
12
+ * surface):
13
+ * - `OTEL_CORE_SEMCONV_VERSION` — the stable core conventions (HTTP client
14
+ * spans, url.*, server.*, error.type) we project. Pinned to the v1.41.1
15
+ * core release.
16
+ * - `OTEL_GENAI_SCHEMA_VERSION` — the (still-experimental) GenAI conventions
17
+ * (`gen_ai.*`). Pinned to the GenAI schema 1.42.0, which introduces
18
+ * `gen_ai.provider.name` and deprecates `gen_ai.system`.
19
+ *
20
+ * Provenance for the pins:
21
+ * - core: https://github.com/open-telemetry/semantic-conventions/releases/tag/v1.41.1
22
+ * - genai: https://github.com/open-telemetry/semantic-conventions/tree/main/docs/gen-ai
23
+ * - http: https://opentelemetry.io/docs/specs/semconv/http/http-spans/
24
+ *
25
+ * This module is the canonical home of the pinned OTel convention surface;
26
+ * pome-cloud consumes it as part of `@pome-sh/wire` (ownership
27
+ * boundary settled at FDRS-653 — see `./index.ts`).
28
+ */
29
+ export declare const OTEL_CORE_SEMCONV_VERSION: "1.41.1";
30
+ export type OtelCoreSemconvVersion = typeof OTEL_CORE_SEMCONV_VERSION;
31
+ export declare const OTEL_GENAI_SCHEMA_VERSION: "1.42.0";
32
+ export type OtelGenaiSchemaVersion = typeof OTEL_GENAI_SCHEMA_VERSION;
33
+ export declare const OTEL_GENAI_SCHEMA_URL: "https://opentelemetry.io/schemas/1.42.0";
34
+ export declare const GEN_AI_PROVIDER_NAME = "gen_ai.provider.name";
35
+ export declare const GEN_AI_SYSTEM_DEPRECATED = "gen_ai.system";
36
+ export declare const GEN_AI_OPERATION_NAME = "gen_ai.operation.name";
37
+ export declare const GEN_AI_REQUEST_MODEL = "gen_ai.request.model";
38
+ export declare const GEN_AI_AGENT_NAME = "gen_ai.agent.name";
39
+ export declare const GEN_AI_AGENT_ID = "gen_ai.agent.id";
40
+ export declare const GEN_AI_TOOL_NAME = "gen_ai.tool.name";
41
+ export declare const GEN_AI_USAGE_INPUT_TOKENS = "gen_ai.usage.input_tokens";
42
+ export declare const GEN_AI_USAGE_OUTPUT_TOKENS = "gen_ai.usage.output_tokens";
43
+ export declare const GEN_AI_USAGE_PROMPT_TOKENS_LEGACY = "gen_ai.usage.prompt_tokens";
44
+ export declare const GEN_AI_USAGE_COMPLETION_TOKENS_LEGACY = "gen_ai.usage.completion_tokens";
45
+ export declare const OPENINFERENCE_LLM_MODEL_NAME = "llm.model_name";
46
+ export declare const OPENINFERENCE_LLM_PROVIDER = "llm.provider";
47
+ export declare const OPENINFERENCE_LLM_SYSTEM = "llm.system";
48
+ export declare const OPENINFERENCE_LLM_TOKEN_COUNT_PROMPT = "llm.token_count.prompt";
49
+ export declare const OPENINFERENCE_LLM_TOKEN_COUNT_COMPLETION = "llm.token_count.completion";
50
+ export declare const OPENINFERENCE_TOOL_NAME = "tool.name";
51
+ export declare const HTTP_REQUEST_METHOD = "http.request.method";
52
+ export declare const HTTP_RESPONSE_STATUS_CODE = "http.response.status_code";
53
+ export declare const URL_FULL = "url.full";
54
+ export declare const URL_PATH = "url.path";
55
+ export declare const SERVER_ADDRESS = "server.address";
56
+ export declare const SERVER_PORT = "server.port";
57
+ export declare const ERROR_TYPE = "error.type";
@@ -0,0 +1,198 @@
1
+ /**
2
+ * otel/span-event — the `OtelSpanEvent` Zod schema (M1.1 / FDRS-480).
3
+ *
4
+ * The canonical internal representation of a single OpenTelemetry span, mapped
5
+ * onto Pome's event union. From M1 on, OTel spans are the canonical model;
6
+ * legacy `TwinHttpEvent` / `LlmCallEvent` / `ToolUseEvent` rows are shimmed *up*
7
+ * into this shape (M1.2). `OtelSpanEvent` is a non-breaking `kind` extension of
8
+ * the event union (composed in `./event-schema.ts`, cloud-only).
9
+ *
10
+ * Invariants enforced (review finding #4 — the schema was too weak):
11
+ * - `*_unix_nano` are uint64 decimal strings WITHIN range (no overflow that
12
+ * could throw a RangeError downstream).
13
+ * - IDs are real W3C trace context (32-/16-char lowercase hex, non-zero) OR
14
+ * an explicit `legacy:<source-id>` (the shim's namespace). Nothing else.
15
+ * - `end_time_unix_nano >= start_time_unix_nano` (no reversed spans).
16
+ * - `event_id === span_id` and `parent_id === parent_span_id` (the base
17
+ * event-union chain mirrors span context).
18
+ * - `ts` is exactly `nanosToIso(start_time_unix_nano)`.
19
+ * - the typed `gen_ai_*` / `http_*` / `url_*` / `server_*` / `error_type`
20
+ * fields EQUAL `projectAttributes(attributes)` — they are projections of
21
+ * the verbatim bag and cannot drift from it.
22
+ *
23
+ * Field conventions: snake_case, flat. `attributes` holds the FULL verbatim
24
+ * attribute bag; the typed fields above are projections of it (see `project.ts`).
25
+ */
26
+ import { z } from "zod";
27
+ export declare const OTEL_SPAN_KINDS: readonly ["UNSPECIFIED", "INTERNAL", "SERVER", "CLIENT", "PRODUCER", "CONSUMER"];
28
+ export declare const otelSpanKindSchema: z.ZodEnum<{
29
+ UNSPECIFIED: "UNSPECIFIED";
30
+ INTERNAL: "INTERNAL";
31
+ SERVER: "SERVER";
32
+ CLIENT: "CLIENT";
33
+ PRODUCER: "PRODUCER";
34
+ CONSUMER: "CONSUMER";
35
+ }>;
36
+ export type OtelSpanKind = z.infer<typeof otelSpanKindSchema>;
37
+ export declare const OTEL_STATUS_CODES: readonly ["UNSET", "OK", "ERROR"];
38
+ export declare const otelStatusCodeSchema: z.ZodEnum<{
39
+ UNSET: "UNSET";
40
+ OK: "OK";
41
+ ERROR: "ERROR";
42
+ }>;
43
+ export type OtelStatusCode = z.infer<typeof otelStatusCodeSchema>;
44
+ export declare const unixNanoSchema: z.ZodString;
45
+ export declare const w3cTraceIdSchema: z.ZodString;
46
+ export declare const w3cSpanIdSchema: z.ZodString;
47
+ export declare const canonicalTraceIdSchema: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
48
+ export declare const canonicalSpanIdSchema: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
49
+ declare const otelSpanEventObjectSchema: z.ZodObject<{
50
+ ts: z.ZodString;
51
+ event_id: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
52
+ parent_event_id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>>;
53
+ parent_id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>>;
54
+ kind: z.ZodLiteral<"OtelSpanEvent">;
55
+ trace_id: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
56
+ span_id: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
57
+ parent_span_id: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
58
+ name: z.ZodString;
59
+ span_kind: z.ZodEnum<{
60
+ UNSPECIFIED: "UNSPECIFIED";
61
+ INTERNAL: "INTERNAL";
62
+ SERVER: "SERVER";
63
+ CLIENT: "CLIENT";
64
+ PRODUCER: "PRODUCER";
65
+ CONSUMER: "CONSUMER";
66
+ }>;
67
+ start_time_unix_nano: z.ZodString;
68
+ end_time_unix_nano: z.ZodNullable<z.ZodString>;
69
+ status_code: z.ZodEnum<{
70
+ UNSET: "UNSET";
71
+ OK: "OK";
72
+ ERROR: "ERROR";
73
+ }>;
74
+ status_message: z.ZodNullable<z.ZodString>;
75
+ gen_ai_provider_name: z.ZodNullable<z.ZodString>;
76
+ gen_ai_operation_name: z.ZodNullable<z.ZodString>;
77
+ gen_ai_request_model: z.ZodNullable<z.ZodString>;
78
+ gen_ai_agent_name: z.ZodNullable<z.ZodString>;
79
+ gen_ai_agent_id: z.ZodNullable<z.ZodString>;
80
+ gen_ai_tool_name: z.ZodNullable<z.ZodString>;
81
+ gen_ai_usage_input_tokens: z.ZodNullable<z.ZodNumber>;
82
+ gen_ai_usage_output_tokens: z.ZodNullable<z.ZodNumber>;
83
+ http_request_method: z.ZodNullable<z.ZodString>;
84
+ http_response_status_code: z.ZodNullable<z.ZodNumber>;
85
+ url_full: z.ZodNullable<z.ZodString>;
86
+ url_path: z.ZodNullable<z.ZodString>;
87
+ server_address: z.ZodNullable<z.ZodString>;
88
+ server_port: z.ZodNullable<z.ZodNumber>;
89
+ error_type: z.ZodNullable<z.ZodString>;
90
+ attributes: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>;
91
+ }, z.core.$strip>;
92
+ export declare const otelSpanEventSchema: z.ZodPipe<z.ZodObject<{
93
+ ts: z.ZodString;
94
+ event_id: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
95
+ parent_event_id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>>;
96
+ parent_id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>>;
97
+ kind: z.ZodLiteral<"OtelSpanEvent">;
98
+ trace_id: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
99
+ span_id: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
100
+ parent_span_id: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
101
+ name: z.ZodString;
102
+ span_kind: z.ZodEnum<{
103
+ UNSPECIFIED: "UNSPECIFIED";
104
+ INTERNAL: "INTERNAL";
105
+ SERVER: "SERVER";
106
+ CLIENT: "CLIENT";
107
+ PRODUCER: "PRODUCER";
108
+ CONSUMER: "CONSUMER";
109
+ }>;
110
+ start_time_unix_nano: z.ZodString;
111
+ end_time_unix_nano: z.ZodNullable<z.ZodString>;
112
+ status_code: z.ZodEnum<{
113
+ UNSET: "UNSET";
114
+ OK: "OK";
115
+ ERROR: "ERROR";
116
+ }>;
117
+ status_message: z.ZodNullable<z.ZodString>;
118
+ gen_ai_provider_name: z.ZodNullable<z.ZodString>;
119
+ gen_ai_operation_name: z.ZodNullable<z.ZodString>;
120
+ gen_ai_request_model: z.ZodNullable<z.ZodString>;
121
+ gen_ai_agent_name: z.ZodNullable<z.ZodString>;
122
+ gen_ai_agent_id: z.ZodNullable<z.ZodString>;
123
+ gen_ai_tool_name: z.ZodNullable<z.ZodString>;
124
+ gen_ai_usage_input_tokens: z.ZodNullable<z.ZodNumber>;
125
+ gen_ai_usage_output_tokens: z.ZodNullable<z.ZodNumber>;
126
+ http_request_method: z.ZodNullable<z.ZodString>;
127
+ http_response_status_code: z.ZodNullable<z.ZodNumber>;
128
+ url_full: z.ZodNullable<z.ZodString>;
129
+ url_path: z.ZodNullable<z.ZodString>;
130
+ server_address: z.ZodNullable<z.ZodString>;
131
+ server_port: z.ZodNullable<z.ZodNumber>;
132
+ error_type: z.ZodNullable<z.ZodString>;
133
+ attributes: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>;
134
+ }, z.core.$strip>, z.ZodTransform<{
135
+ parent_event_id: string | null;
136
+ ts: string;
137
+ event_id: string;
138
+ kind: "OtelSpanEvent";
139
+ trace_id: string;
140
+ span_id: string;
141
+ parent_span_id: string | null;
142
+ name: string;
143
+ span_kind: "UNSPECIFIED" | "INTERNAL" | "SERVER" | "CLIENT" | "PRODUCER" | "CONSUMER";
144
+ start_time_unix_nano: string;
145
+ end_time_unix_nano: string | null;
146
+ status_code: "UNSET" | "OK" | "ERROR";
147
+ status_message: string | null;
148
+ gen_ai_provider_name: string | null;
149
+ gen_ai_operation_name: string | null;
150
+ gen_ai_request_model: string | null;
151
+ gen_ai_agent_name: string | null;
152
+ gen_ai_agent_id: string | null;
153
+ gen_ai_tool_name: string | null;
154
+ gen_ai_usage_input_tokens: number | null;
155
+ gen_ai_usage_output_tokens: number | null;
156
+ http_request_method: string | null;
157
+ http_response_status_code: number | null;
158
+ url_full: string | null;
159
+ url_path: string | null;
160
+ server_address: string | null;
161
+ server_port: number | null;
162
+ error_type: string | null;
163
+ attributes: Record<string, string | number | boolean | (string | number | boolean)[]>;
164
+ parent_id?: string | null | undefined;
165
+ }, {
166
+ ts: string;
167
+ event_id: string;
168
+ kind: "OtelSpanEvent";
169
+ trace_id: string;
170
+ span_id: string;
171
+ parent_span_id: string | null;
172
+ name: string;
173
+ span_kind: "UNSPECIFIED" | "INTERNAL" | "SERVER" | "CLIENT" | "PRODUCER" | "CONSUMER";
174
+ start_time_unix_nano: string;
175
+ end_time_unix_nano: string | null;
176
+ status_code: "UNSET" | "OK" | "ERROR";
177
+ status_message: string | null;
178
+ gen_ai_provider_name: string | null;
179
+ gen_ai_operation_name: string | null;
180
+ gen_ai_request_model: string | null;
181
+ gen_ai_agent_name: string | null;
182
+ gen_ai_agent_id: string | null;
183
+ gen_ai_tool_name: string | null;
184
+ gen_ai_usage_input_tokens: number | null;
185
+ gen_ai_usage_output_tokens: number | null;
186
+ http_request_method: string | null;
187
+ http_response_status_code: number | null;
188
+ url_full: string | null;
189
+ url_path: string | null;
190
+ server_address: string | null;
191
+ server_port: number | null;
192
+ error_type: string | null;
193
+ attributes: Record<string, string | number | boolean | (string | number | boolean)[]>;
194
+ parent_event_id?: string | null | undefined;
195
+ parent_id?: string | null | undefined;
196
+ }>>;
197
+ export type OtelSpanEvent = z.infer<typeof otelSpanEventObjectSchema>;
198
+ export {};