@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,252 @@
1
+ import type { TwinDatabase } from "../../sdk/db.js";
2
+ import type { FailureInjectionRule } from "../../sdk/failure-injection-rules.js";
3
+ import type { RecorderEvent } from "../../wire/index.js";
4
+ export type TwinStripeDatabase = TwinDatabase;
5
+ export type { RecorderEvent, StateDelta } from "../../wire/index.js";
6
+ export type Recorder = {
7
+ record(event: RecorderEvent): void;
8
+ };
9
+ export type StripeFidelity = "semantic" | "unsupported";
10
+ export type { FailureInjectionMode, FailureInjectionRule } from "../../sdk/failure-injection-rules.js";
11
+ export type SeedPaymentIntent = {
12
+ id: string;
13
+ account_id: string;
14
+ amount: number;
15
+ currency: string;
16
+ status: PIStatus;
17
+ payment_method_types: string[];
18
+ next_action?: unknown | null;
19
+ latest_charge_id?: string | null;
20
+ capture_method: string;
21
+ confirmation_method: string;
22
+ idempotency_key?: string | null;
23
+ metadata: Record<string, string>;
24
+ crypto_deposit?: unknown | null;
25
+ client_secret: string;
26
+ created: number;
27
+ updated: number;
28
+ canceled_at?: number | null;
29
+ captured_at?: number | null;
30
+ };
31
+ export type SeedCharge = {
32
+ id: string;
33
+ account_id: string;
34
+ payment_intent_id: string;
35
+ amount: number;
36
+ amount_captured: number;
37
+ amount_refunded: number;
38
+ status: "pending" | "succeeded" | "failed";
39
+ balance_transaction_id?: string | null;
40
+ captured: boolean;
41
+ currency: string;
42
+ created: number;
43
+ };
44
+ export type SeedRefund = {
45
+ id: string;
46
+ account_id: string;
47
+ charge_id: string;
48
+ payment_intent_id: string;
49
+ amount: number;
50
+ currency: string;
51
+ status: RefundStatus;
52
+ reason?: string | null;
53
+ balance_transaction_id?: string | null;
54
+ idempotency_key?: string | null;
55
+ created: number;
56
+ };
57
+ export type SeedBalanceTransaction = {
58
+ id: string;
59
+ account_id: string;
60
+ type: string;
61
+ amount: number;
62
+ fee: number;
63
+ net: number;
64
+ currency: string;
65
+ source_id?: string | null;
66
+ source_type?: string | null;
67
+ available_on: number;
68
+ status: "pending" | "available";
69
+ created: number;
70
+ };
71
+ export type SeedState = {
72
+ api_keys?: Array<{
73
+ key: string;
74
+ sid: string;
75
+ account_id?: string;
76
+ }>;
77
+ failure_injection?: FailureInjectionRule[];
78
+ payment_intents?: SeedPaymentIntent[];
79
+ charges?: SeedCharge[];
80
+ refunds?: SeedRefund[];
81
+ balance_transactions?: SeedBalanceTransaction[];
82
+ };
83
+ export type ApiKeyRow = {
84
+ key: string;
85
+ sid: string;
86
+ account_id: string;
87
+ created_at: string;
88
+ revoked_at: string | null;
89
+ };
90
+ export type IdempotencyKeyRow = {
91
+ key: string;
92
+ account_id: string;
93
+ method: string;
94
+ path: string;
95
+ request_hash: string;
96
+ response_status: number;
97
+ response_body_json: string;
98
+ created_at: string;
99
+ };
100
+ /**
101
+ * v1 PaymentIntent row. Stub — AGENT-B owns domain operations.
102
+ * Schema for v1 x402 crypto-deposit PIs
103
+ * (`crypto_deposit_json` carries deposit address + supported tokens).
104
+ */
105
+ export type PIStatus = "requires_payment_method" | "requires_confirmation" | "requires_action" | "processing" | "requires_capture" | "canceled" | "succeeded";
106
+ export type PIRow = {
107
+ id: string;
108
+ account_id: string;
109
+ amount: number;
110
+ currency: string;
111
+ status: PIStatus;
112
+ payment_method_types_json: string;
113
+ next_action_json: string | null;
114
+ latest_charge_id: string | null;
115
+ capture_method: string;
116
+ confirmation_method: string;
117
+ idempotency_key: string | null;
118
+ metadata_json: string;
119
+ crypto_deposit_json: string | null;
120
+ client_secret: string;
121
+ created: number;
122
+ updated: number;
123
+ canceled_at: number | null;
124
+ captured_at: number | null;
125
+ payment_method_id: string | null;
126
+ customer_id: string | null;
127
+ last_payment_error_json: string | null;
128
+ };
129
+ export type ChargeRow = {
130
+ id: string;
131
+ account_id: string;
132
+ payment_intent_id: string;
133
+ amount: number;
134
+ amount_captured: number;
135
+ amount_refunded: number;
136
+ status: "pending" | "succeeded" | "failed";
137
+ balance_transaction_id: string | null;
138
+ captured: 0 | 1;
139
+ created: number;
140
+ currency: string;
141
+ payment_method_id: string | null;
142
+ payment_method_details_json: string | null;
143
+ failure_code: string | null;
144
+ failure_decline_code: string | null;
145
+ failure_message: string | null;
146
+ customer_id: string | null;
147
+ };
148
+ export type BalanceTxRow = {
149
+ id: string;
150
+ account_id: string;
151
+ type: string;
152
+ amount: number;
153
+ fee: number;
154
+ net: number;
155
+ currency: string;
156
+ source_id: string | null;
157
+ source_type: string | null;
158
+ available_on: number;
159
+ created: number;
160
+ status: "pending" | "available";
161
+ };
162
+ export type EventRow = {
163
+ id: string;
164
+ account_id: string;
165
+ type: string;
166
+ data_json: string;
167
+ request_idempotency_key: string | null;
168
+ livemode: 0 | 1;
169
+ created: number;
170
+ api_version: string;
171
+ };
172
+ export type CustomerRow = {
173
+ id: string;
174
+ account_id: string;
175
+ name: string | null;
176
+ email: string | null;
177
+ description: string | null;
178
+ phone: string | null;
179
+ metadata_json: string;
180
+ deleted: 0 | 1;
181
+ created: number;
182
+ };
183
+ export type PaymentMethodRow = {
184
+ id: string;
185
+ account_id: string;
186
+ type: string;
187
+ card_brand: string;
188
+ card_last4: string;
189
+ card_exp_month: number;
190
+ card_exp_year: number;
191
+ card_fingerprint: string;
192
+ customer_id: string | null;
193
+ detached: 0 | 1;
194
+ created: number;
195
+ };
196
+ export type RefundStatus = "succeeded" | "pending" | "failed" | "canceled";
197
+ export type RefundRow = {
198
+ id: string;
199
+ account_id: string;
200
+ charge_id: string;
201
+ payment_intent_id: string;
202
+ amount: number;
203
+ currency: string;
204
+ status: RefundStatus;
205
+ reason: string | null;
206
+ balance_transaction_id: string | null;
207
+ idempotency_key: string | null;
208
+ created: number;
209
+ };
210
+ export type ProductRow = {
211
+ id: string;
212
+ account_id: string;
213
+ name: string;
214
+ description: string | null;
215
+ active: 0 | 1;
216
+ metadata_json: string;
217
+ created: number;
218
+ updated: number;
219
+ };
220
+ export type PriceRow = {
221
+ id: string;
222
+ account_id: string;
223
+ product_id: string;
224
+ currency: string;
225
+ unit_amount: number | null;
226
+ recurring_interval: string | null;
227
+ recurring_interval_count: number | null;
228
+ active: 0 | 1;
229
+ nickname: string | null;
230
+ lookup_key: string | null;
231
+ metadata_json: string;
232
+ created: number;
233
+ };
234
+ export type SubscriptionStatus = "active" | "canceled";
235
+ export type SubscriptionRow = {
236
+ id: string;
237
+ account_id: string;
238
+ customer_id: string;
239
+ status: SubscriptionStatus;
240
+ /** JSON array of {id, price, quantity} subscription items. */
241
+ items_json: string;
242
+ cancel_at_period_end: 0 | 1;
243
+ canceled_at: number | null;
244
+ ended_at: number | null;
245
+ metadata_json: string;
246
+ created: number;
247
+ };
248
+ export type ResolvedSession = {
249
+ sid: string;
250
+ account_id: string;
251
+ via?: "jwt" | "api_key";
252
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * wire — the trace surface every Pome process agrees on.
3
+ *
4
+ * Three clusters, and nothing else: the recorder-event union that twins write
5
+ * and the CLI reads (`recorder-events.ts`), the OpenTelemetry-native extension
6
+ * of that union (`otel/`), and the secret redactor applied on the way to disk
7
+ * (`redaction.ts`). Every twin, the sdk, the adapter and the CLI depend on this
8
+ * package; NOTHING here knows about sessions, tasks, runs or the cloud REST
9
+ * surface — those live in `cli/src/contract/` (F-942).
10
+ *
11
+ * Two SUBPATH-ONLY surfaces are deliberately absent from this barrel, because
12
+ * only some consumers should pay to load them: `@pome-sh/wire/otel/fixtures`
13
+ * (the golden-fixture corpus, a test/dev artifact) and
14
+ * `@pome-sh/wire/correlation` (F-950 — the agent-side AsyncLocalStorage +
15
+ * fetch-patching plumbing that stamps `x-pome-correlation-id`; importing it
16
+ * constructs an AsyncLocalStorage, and no twin is the agent side of that
17
+ * protocol). `test/export-surface.test.ts` pins both halves of that call.
18
+ *
19
+ * This file is a THIN BARREL: it re-exports only.
20
+ */
21
+ export * from "./recorder-events.js";
22
+ export * from "./redaction.js";
23
+ export * from "./otel/index.js";
@@ -0,0 +1,424 @@
1
+ /**
2
+ * otel/event-schema — the OTel-inclusive event union (M1.1 / FDRS-480).
3
+ *
4
+ * `eventSchema` in `recorder-events.ts` is the FROZEN v1 legacy union (the
5
+ * recording-spec contract under the repo's change-lock policy). Rather than
6
+ * mutate that frozen union, this file composes the OTel-extended union
7
+ * ADDITIVELY — a non-breaking superset:
8
+ *
9
+ * - `eventSchema` (recorder-events.ts) — the v1 legacy-only union.
10
+ * - `otelEventSchema` (this file) — legacy variants PLUS `OtelSpanEvent`.
11
+ *
12
+ * OTel-aware consumers (M3 correlation, the native trace renderer) import
13
+ * `otelEventSchema`; readers that only handle the v1 legacy shapes keep using
14
+ * `eventSchema` and recognize `OtelSpanEvent` separately.
15
+ *
16
+ * This union is FORMAT surface and canonical HERE (ownership boundary settled
17
+ * at FDRS-653 — see `./index.ts`). pome-cloud consumes it; its earlier
18
+ * cloud-local composition of the same union collapses into this one at the
19
+ * FDRS-654 consumer swap.
20
+ */
21
+ import { z } from "zod";
22
+ export declare const otelEventSchema: z.ZodUnion<readonly [z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
23
+ ts: z.ZodString;
24
+ run_id: z.ZodString;
25
+ twin: z.ZodString;
26
+ request_id: z.ZodString;
27
+ correlation_id: z.ZodOptional<z.ZodString>;
28
+ task_step_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
29
+ scenario_step_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
30
+ step_id: z.ZodNullable<z.ZodString>;
31
+ tool_call_id: z.ZodNullable<z.ZodString>;
32
+ method: z.ZodString;
33
+ path: z.ZodString;
34
+ request_body: z.ZodUnknown;
35
+ request_headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
36
+ tool: z.ZodOptional<z.ZodNullable<z.ZodString>>;
37
+ status: z.ZodNumber;
38
+ response_body: z.ZodUnknown;
39
+ latency_ms: z.ZodNumber;
40
+ fidelity: z.ZodEnum<{
41
+ semantic: "semantic";
42
+ unsupported: "unsupported";
43
+ }>;
44
+ state_mutation: z.ZodBoolean;
45
+ state_delta: z.ZodNullable<z.ZodObject<{
46
+ before: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
47
+ after: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
48
+ }, z.core.$strip>>;
49
+ idempotency_dedupe: z.ZodOptional<z.ZodBoolean>;
50
+ error: z.ZodNullable<z.ZodString>;
51
+ kind: z.ZodLiteral<"TwinHttpEvent">;
52
+ event_id: z.ZodString;
53
+ parent_event_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
54
+ parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
55
+ }, z.core.$strip>, z.ZodObject<{
56
+ kind: z.ZodLiteral<"LlmCallEvent">;
57
+ host: z.ZodString;
58
+ port: z.ZodNumber;
59
+ latency_ms: z.ZodNumber;
60
+ bytes_in: z.ZodNumber;
61
+ bytes_out: z.ZodNumber;
62
+ url: z.ZodNullable<z.ZodString>;
63
+ method: z.ZodNullable<z.ZodString>;
64
+ status: z.ZodNullable<z.ZodNumber>;
65
+ model: z.ZodNullable<z.ZodString>;
66
+ prompt_tokens: z.ZodNullable<z.ZodNumber>;
67
+ completion_tokens: z.ZodNullable<z.ZodNumber>;
68
+ cost_usd: z.ZodNullable<z.ZodNumber>;
69
+ ts: z.ZodString;
70
+ event_id: z.ZodString;
71
+ parent_event_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
+ parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
73
+ }, z.core.$strip>, z.ZodObject<{
74
+ kind: z.ZodLiteral<"ToolUseEvent">;
75
+ tool_use_id: z.ZodString;
76
+ tool_name: z.ZodString;
77
+ input: z.ZodUnknown;
78
+ ts: z.ZodString;
79
+ event_id: z.ZodString;
80
+ parent_event_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
81
+ parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
82
+ }, z.core.$strip>, z.ZodObject<{
83
+ kind: z.ZodLiteral<"ToolResultEvent">;
84
+ tool_use_id: z.ZodString;
85
+ output: z.ZodUnknown;
86
+ is_error: z.ZodBoolean;
87
+ ts: z.ZodString;
88
+ event_id: z.ZodString;
89
+ parent_event_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
90
+ parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
91
+ }, z.core.$strip>, z.ZodObject<{
92
+ kind: z.ZodLiteral<"SubagentSpawnEvent">;
93
+ parent_tool_use_id: z.ZodString;
94
+ ts: z.ZodString;
95
+ event_id: z.ZodString;
96
+ parent_event_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
97
+ parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
98
+ }, z.core.$strip>, z.ZodObject<{
99
+ kind: z.ZodLiteral<"HookEvent">;
100
+ hook_name: z.ZodString;
101
+ tool_name: z.ZodNullable<z.ZodString>;
102
+ causing_tool_use_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
103
+ ts: z.ZodString;
104
+ event_id: z.ZodString;
105
+ parent_event_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
106
+ parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
107
+ }, z.core.$strip>, z.ZodObject<{
108
+ kind: z.ZodLiteral<"LlmTurnEvent">;
109
+ turn_index: z.ZodNumber;
110
+ model: z.ZodNullable<z.ZodString>;
111
+ input_tokens: z.ZodNullable<z.ZodNumber>;
112
+ output_tokens: z.ZodNullable<z.ZodNumber>;
113
+ cache_read_input_tokens: z.ZodNullable<z.ZodNumber>;
114
+ cache_creation_input_tokens: z.ZodNullable<z.ZodNumber>;
115
+ finish_reasons: z.ZodNullable<z.ZodArray<z.ZodString>>;
116
+ latency_ms: z.ZodNumber;
117
+ latency_ms_estimated: z.ZodBoolean;
118
+ session_id: z.ZodNullable<z.ZodString>;
119
+ ts: z.ZodString;
120
+ event_id: z.ZodString;
121
+ parent_event_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
122
+ parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
123
+ }, z.core.$strip>], "kind">, z.ZodTransform<{
124
+ ts: string;
125
+ run_id: string;
126
+ twin: string;
127
+ request_id: string;
128
+ step_id: string | null;
129
+ tool_call_id: string | null;
130
+ method: string;
131
+ path: string;
132
+ request_body: unknown;
133
+ status: number;
134
+ response_body: unknown;
135
+ latency_ms: number;
136
+ fidelity: "semantic" | "unsupported";
137
+ state_mutation: boolean;
138
+ state_delta: {
139
+ before: Record<string, unknown> | null;
140
+ after: Record<string, unknown> | null;
141
+ } | null;
142
+ error: string | null;
143
+ kind: "TwinHttpEvent";
144
+ event_id: string;
145
+ correlation_id?: string | undefined;
146
+ task_step_id?: string | null | undefined;
147
+ scenario_step_id?: string | null | undefined;
148
+ request_headers?: Record<string, string> | undefined;
149
+ tool?: string | null | undefined;
150
+ idempotency_dedupe?: boolean | undefined;
151
+ parent_event_id?: string | null | undefined;
152
+ parent_id?: string | null | undefined;
153
+ } | {
154
+ kind: "LlmCallEvent";
155
+ host: string;
156
+ port: number;
157
+ latency_ms: number;
158
+ bytes_in: number;
159
+ bytes_out: number;
160
+ url: string | null;
161
+ method: string | null;
162
+ status: number | null;
163
+ model: string | null;
164
+ prompt_tokens: number | null;
165
+ completion_tokens: number | null;
166
+ cost_usd: number | null;
167
+ ts: string;
168
+ event_id: string;
169
+ parent_event_id?: string | null | undefined;
170
+ parent_id?: string | null | undefined;
171
+ } | {
172
+ kind: "ToolUseEvent";
173
+ tool_use_id: string;
174
+ tool_name: string;
175
+ input: unknown;
176
+ ts: string;
177
+ event_id: string;
178
+ parent_event_id?: string | null | undefined;
179
+ parent_id?: string | null | undefined;
180
+ } | {
181
+ kind: "ToolResultEvent";
182
+ tool_use_id: string;
183
+ output: unknown;
184
+ is_error: boolean;
185
+ ts: string;
186
+ event_id: string;
187
+ parent_event_id?: string | null | undefined;
188
+ parent_id?: string | null | undefined;
189
+ } | {
190
+ kind: "SubagentSpawnEvent";
191
+ parent_tool_use_id: string;
192
+ ts: string;
193
+ event_id: string;
194
+ parent_event_id?: string | null | undefined;
195
+ parent_id?: string | null | undefined;
196
+ } | {
197
+ kind: "HookEvent";
198
+ hook_name: string;
199
+ tool_name: string | null;
200
+ ts: string;
201
+ event_id: string;
202
+ causing_tool_use_id?: string | null | undefined;
203
+ parent_event_id?: string | null | undefined;
204
+ parent_id?: string | null | undefined;
205
+ } | {
206
+ kind: "LlmTurnEvent";
207
+ turn_index: number;
208
+ model: string | null;
209
+ input_tokens: number | null;
210
+ output_tokens: number | null;
211
+ cache_read_input_tokens: number | null;
212
+ cache_creation_input_tokens: number | null;
213
+ finish_reasons: string[] | null;
214
+ latency_ms: number;
215
+ latency_ms_estimated: boolean;
216
+ session_id: string | null;
217
+ ts: string;
218
+ event_id: string;
219
+ parent_event_id?: string | null | undefined;
220
+ parent_id?: string | null | undefined;
221
+ }, {
222
+ ts: string;
223
+ run_id: string;
224
+ twin: string;
225
+ request_id: string;
226
+ step_id: string | null;
227
+ tool_call_id: string | null;
228
+ method: string;
229
+ path: string;
230
+ request_body: unknown;
231
+ status: number;
232
+ response_body: unknown;
233
+ latency_ms: number;
234
+ fidelity: "semantic" | "unsupported";
235
+ state_mutation: boolean;
236
+ state_delta: {
237
+ before: Record<string, unknown> | null;
238
+ after: Record<string, unknown> | null;
239
+ } | null;
240
+ error: string | null;
241
+ kind: "TwinHttpEvent";
242
+ event_id: string;
243
+ correlation_id?: string | undefined;
244
+ task_step_id?: string | null | undefined;
245
+ scenario_step_id?: string | null | undefined;
246
+ request_headers?: Record<string, string> | undefined;
247
+ tool?: string | null | undefined;
248
+ idempotency_dedupe?: boolean | undefined;
249
+ parent_event_id?: string | null | undefined;
250
+ parent_id?: string | null | undefined;
251
+ } | {
252
+ kind: "LlmCallEvent";
253
+ host: string;
254
+ port: number;
255
+ latency_ms: number;
256
+ bytes_in: number;
257
+ bytes_out: number;
258
+ url: string | null;
259
+ method: string | null;
260
+ status: number | null;
261
+ model: string | null;
262
+ prompt_tokens: number | null;
263
+ completion_tokens: number | null;
264
+ cost_usd: number | null;
265
+ ts: string;
266
+ event_id: string;
267
+ parent_event_id?: string | null | undefined;
268
+ parent_id?: string | null | undefined;
269
+ } | {
270
+ kind: "ToolUseEvent";
271
+ tool_use_id: string;
272
+ tool_name: string;
273
+ input: unknown;
274
+ ts: string;
275
+ event_id: string;
276
+ parent_event_id?: string | null | undefined;
277
+ parent_id?: string | null | undefined;
278
+ } | {
279
+ kind: "ToolResultEvent";
280
+ tool_use_id: string;
281
+ output: unknown;
282
+ is_error: boolean;
283
+ ts: string;
284
+ event_id: string;
285
+ parent_event_id?: string | null | undefined;
286
+ parent_id?: string | null | undefined;
287
+ } | {
288
+ kind: "SubagentSpawnEvent";
289
+ parent_tool_use_id: string;
290
+ ts: string;
291
+ event_id: string;
292
+ parent_event_id?: string | null | undefined;
293
+ parent_id?: string | null | undefined;
294
+ } | {
295
+ kind: "HookEvent";
296
+ hook_name: string;
297
+ tool_name: string | null;
298
+ ts: string;
299
+ event_id: string;
300
+ causing_tool_use_id?: string | null | undefined;
301
+ parent_event_id?: string | null | undefined;
302
+ parent_id?: string | null | undefined;
303
+ } | {
304
+ kind: "LlmTurnEvent";
305
+ turn_index: number;
306
+ model: string | null;
307
+ input_tokens: number | null;
308
+ output_tokens: number | null;
309
+ cache_read_input_tokens: number | null;
310
+ cache_creation_input_tokens: number | null;
311
+ finish_reasons: string[] | null;
312
+ latency_ms: number;
313
+ latency_ms_estimated: boolean;
314
+ session_id: string | null;
315
+ ts: string;
316
+ event_id: string;
317
+ parent_event_id?: string | null | undefined;
318
+ parent_id?: string | null | undefined;
319
+ }>>, z.ZodPipe<z.ZodObject<{
320
+ ts: z.ZodString;
321
+ event_id: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
322
+ parent_event_id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>>;
323
+ parent_id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>>;
324
+ kind: z.ZodLiteral<"OtelSpanEvent">;
325
+ trace_id: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
326
+ span_id: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
327
+ parent_span_id: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
328
+ name: z.ZodString;
329
+ span_kind: z.ZodEnum<{
330
+ UNSPECIFIED: "UNSPECIFIED";
331
+ INTERNAL: "INTERNAL";
332
+ SERVER: "SERVER";
333
+ CLIENT: "CLIENT";
334
+ PRODUCER: "PRODUCER";
335
+ CONSUMER: "CONSUMER";
336
+ }>;
337
+ start_time_unix_nano: z.ZodString;
338
+ end_time_unix_nano: z.ZodNullable<z.ZodString>;
339
+ status_code: z.ZodEnum<{
340
+ UNSET: "UNSET";
341
+ OK: "OK";
342
+ ERROR: "ERROR";
343
+ }>;
344
+ status_message: z.ZodNullable<z.ZodString>;
345
+ gen_ai_provider_name: z.ZodNullable<z.ZodString>;
346
+ gen_ai_operation_name: z.ZodNullable<z.ZodString>;
347
+ gen_ai_request_model: z.ZodNullable<z.ZodString>;
348
+ gen_ai_agent_name: z.ZodNullable<z.ZodString>;
349
+ gen_ai_agent_id: z.ZodNullable<z.ZodString>;
350
+ gen_ai_tool_name: z.ZodNullable<z.ZodString>;
351
+ gen_ai_usage_input_tokens: z.ZodNullable<z.ZodNumber>;
352
+ gen_ai_usage_output_tokens: z.ZodNullable<z.ZodNumber>;
353
+ http_request_method: z.ZodNullable<z.ZodString>;
354
+ http_response_status_code: z.ZodNullable<z.ZodNumber>;
355
+ url_full: z.ZodNullable<z.ZodString>;
356
+ url_path: z.ZodNullable<z.ZodString>;
357
+ server_address: z.ZodNullable<z.ZodString>;
358
+ server_port: z.ZodNullable<z.ZodNumber>;
359
+ error_type: z.ZodNullable<z.ZodString>;
360
+ 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]>>]>>;
361
+ }, z.core.$strip>, z.ZodTransform<{
362
+ parent_event_id: string | null;
363
+ ts: string;
364
+ event_id: string;
365
+ kind: "OtelSpanEvent";
366
+ trace_id: string;
367
+ span_id: string;
368
+ parent_span_id: string | null;
369
+ name: string;
370
+ span_kind: "UNSPECIFIED" | "INTERNAL" | "SERVER" | "CLIENT" | "PRODUCER" | "CONSUMER";
371
+ start_time_unix_nano: string;
372
+ end_time_unix_nano: string | null;
373
+ status_code: "UNSET" | "OK" | "ERROR";
374
+ status_message: string | null;
375
+ gen_ai_provider_name: string | null;
376
+ gen_ai_operation_name: string | null;
377
+ gen_ai_request_model: string | null;
378
+ gen_ai_agent_name: string | null;
379
+ gen_ai_agent_id: string | null;
380
+ gen_ai_tool_name: string | null;
381
+ gen_ai_usage_input_tokens: number | null;
382
+ gen_ai_usage_output_tokens: number | null;
383
+ http_request_method: string | null;
384
+ http_response_status_code: number | null;
385
+ url_full: string | null;
386
+ url_path: string | null;
387
+ server_address: string | null;
388
+ server_port: number | null;
389
+ error_type: string | null;
390
+ attributes: Record<string, string | number | boolean | (string | number | boolean)[]>;
391
+ parent_id?: string | null | undefined;
392
+ }, {
393
+ ts: string;
394
+ event_id: string;
395
+ kind: "OtelSpanEvent";
396
+ trace_id: string;
397
+ span_id: string;
398
+ parent_span_id: string | null;
399
+ name: string;
400
+ span_kind: "UNSPECIFIED" | "INTERNAL" | "SERVER" | "CLIENT" | "PRODUCER" | "CONSUMER";
401
+ start_time_unix_nano: string;
402
+ end_time_unix_nano: string | null;
403
+ status_code: "UNSET" | "OK" | "ERROR";
404
+ status_message: string | null;
405
+ gen_ai_provider_name: string | null;
406
+ gen_ai_operation_name: string | null;
407
+ gen_ai_request_model: string | null;
408
+ gen_ai_agent_name: string | null;
409
+ gen_ai_agent_id: string | null;
410
+ gen_ai_tool_name: string | null;
411
+ gen_ai_usage_input_tokens: number | null;
412
+ gen_ai_usage_output_tokens: number | null;
413
+ http_request_method: string | null;
414
+ http_response_status_code: number | null;
415
+ url_full: string | null;
416
+ url_path: string | null;
417
+ server_address: string | null;
418
+ server_port: number | null;
419
+ error_type: string | null;
420
+ attributes: Record<string, string | number | boolean | (string | number | boolean)[]>;
421
+ parent_event_id?: string | null | undefined;
422
+ parent_id?: string | null | undefined;
423
+ }>>]>;
424
+ export type OtelEvent = z.infer<typeof otelEventSchema>;