@fulcrum_io/sdk 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.
@@ -0,0 +1,254 @@
1
+ syntax = "proto3";
2
+
3
+ package fulcrum.eventstore.v1;
4
+
5
+ option go_package = "github.com/fulcrum-io/fulcrum/pkg/eventstore/v1;eventstorev1";
6
+
7
+ import "google/protobuf/timestamp.proto";
8
+ import "google/protobuf/struct.proto";
9
+
10
+ // EventStore service for persisting and querying execution events
11
+ service EventStoreService {
12
+ // Publish a single event to the event store
13
+ rpc PublishEvent(PublishEventRequest) returns (PublishEventResponse);
14
+
15
+ // Publish multiple events in batch
16
+ rpc PublishEventBatch(PublishEventBatchRequest) returns (PublishEventBatchResponse);
17
+
18
+ // Query events by various filters
19
+ rpc QueryEvents(QueryEventsRequest) returns (QueryEventsResponse);
20
+
21
+ // Get events for a specific execution
22
+ rpc GetExecutionEvents(GetExecutionEventsRequest) returns (GetExecutionEventsResponse);
23
+
24
+ // Stream events in real-time
25
+ rpc StreamEvents(StreamEventsRequest) returns (stream StoredEvent);
26
+
27
+ // Get event store statistics
28
+ rpc GetEventStoreStats(GetEventStoreStatsRequest) returns (GetEventStoreStatsResponse);
29
+ }
30
+
31
+ // StoredEvent represents a persisted event in the event store
32
+ message StoredEvent {
33
+ // Unique event ID (generated by event store)
34
+ string event_id = 1;
35
+
36
+ // Execution context
37
+ string execution_id = 2;
38
+ string envelope_id = 3;
39
+ string tenant_id = 4;
40
+ string workflow_id = 5;
41
+
42
+ // Event metadata
43
+ string event_type = 6; // execution_started, llm_call, tool_call, checkpoint_saved, etc.
44
+ google.protobuf.Timestamp timestamp = 7;
45
+ int64 sequence_number = 8; // Sequential number within execution
46
+
47
+ // Event payload
48
+ google.protobuf.Struct payload = 9;
49
+
50
+ // Trace context
51
+ string trace_id = 10;
52
+ string span_id = 11;
53
+
54
+ // Labels for filtering
55
+ map<string, string> labels = 12;
56
+
57
+ // Storage metadata
58
+ string stream_name = 13; // NATS stream name
59
+ int64 stream_sequence = 14; // NATS sequence number
60
+ google.protobuf.Timestamp stored_at = 15;
61
+ }
62
+
63
+ // PublishEventRequest publishes a single event
64
+ message PublishEventRequest {
65
+ // Event to publish
66
+ EventPayload event = 1;
67
+ }
68
+
69
+ message PublishEventResponse {
70
+ // Event ID assigned by the store
71
+ string event_id = 1;
72
+
73
+ // Stream sequence number
74
+ int64 stream_sequence = 2;
75
+
76
+ // Timestamp when stored
77
+ google.protobuf.Timestamp stored_at = 3;
78
+ }
79
+
80
+ // PublishEventBatchRequest publishes multiple events
81
+ message PublishEventBatchRequest {
82
+ repeated EventPayload events = 1;
83
+ }
84
+
85
+ message PublishEventBatchResponse {
86
+ // Number of events published
87
+ int32 published_count = 1;
88
+
89
+ // Event IDs assigned
90
+ repeated string event_ids = 2;
91
+
92
+ // First and last sequence numbers
93
+ int64 first_sequence = 3;
94
+ int64 last_sequence = 4;
95
+ }
96
+
97
+ // EventPayload is the input event before storage
98
+ message EventPayload {
99
+ // Execution context
100
+ string execution_id = 1;
101
+ string envelope_id = 2;
102
+ string tenant_id = 3;
103
+ string workflow_id = 4;
104
+
105
+ // Event metadata
106
+ string event_type = 5;
107
+ google.protobuf.Timestamp timestamp = 6;
108
+
109
+ // Event payload
110
+ google.protobuf.Struct payload = 7;
111
+
112
+ // Trace context
113
+ string trace_id = 8;
114
+ string span_id = 9;
115
+
116
+ // Labels for filtering
117
+ map<string, string> labels = 10;
118
+ }
119
+
120
+ // QueryEventsRequest queries events with filters
121
+ message QueryEventsRequest {
122
+ // Filters (AND logic)
123
+ string tenant_id = 1;
124
+ string execution_id = 2;
125
+ string workflow_id = 3;
126
+ string event_type = 4;
127
+
128
+ // Time range
129
+ google.protobuf.Timestamp start_time = 5;
130
+ google.protobuf.Timestamp end_time = 6;
131
+
132
+ // Label filters
133
+ map<string, string> labels = 7;
134
+
135
+ // Pagination
136
+ int32 limit = 8; // Max events to return (default: 100, max: 1000)
137
+ string page_token = 9; // For pagination
138
+
139
+ // Ordering
140
+ OrderDirection order = 10;
141
+
142
+ enum OrderDirection {
143
+ ORDER_DIRECTION_UNSPECIFIED = 0;
144
+ ASCENDING = 1;
145
+ DESCENDING = 2;
146
+ }
147
+ }
148
+
149
+ message QueryEventsResponse {
150
+ repeated StoredEvent events = 1;
151
+ string next_page_token = 2;
152
+ int32 total_count = 3; // Approximate total (if available)
153
+ }
154
+
155
+ // GetExecutionEventsRequest gets all events for an execution
156
+ message GetExecutionEventsRequest {
157
+ string execution_id = 1;
158
+
159
+ // Optional filters
160
+ string event_type = 2;
161
+ google.protobuf.Timestamp start_time = 3;
162
+ google.protobuf.Timestamp end_time = 4;
163
+
164
+ // Pagination
165
+ int32 limit = 5;
166
+ string page_token = 6;
167
+ }
168
+
169
+ message GetExecutionEventsResponse {
170
+ repeated StoredEvent events = 1;
171
+ string next_page_token = 2;
172
+
173
+ // Execution summary
174
+ google.protobuf.Timestamp execution_started_at = 3;
175
+ google.protobuf.Timestamp execution_ended_at = 4;
176
+ int32 total_event_count = 5;
177
+ }
178
+
179
+ // StreamEventsRequest streams events in real-time
180
+ message StreamEventsRequest {
181
+ // Filters (same as QueryEventsRequest)
182
+ string tenant_id = 1;
183
+ string execution_id = 2;
184
+ string workflow_id = 3;
185
+ string event_type = 4;
186
+
187
+ // Start from specific sequence or time
188
+ oneof start_position {
189
+ int64 start_sequence = 5;
190
+ google.protobuf.Timestamp start_time = 6;
191
+ }
192
+
193
+ // Label filters
194
+ map<string, string> labels = 7;
195
+ }
196
+
197
+ // GetEventStoreStatsRequest gets statistics
198
+ message GetEventStoreStatsRequest {
199
+ // Optional tenant filter
200
+ string tenant_id = 1;
201
+ }
202
+
203
+ message GetEventStoreStatsResponse {
204
+ // Total events stored
205
+ int64 total_events = 1;
206
+
207
+ // Events by type
208
+ map<string, int64> events_by_type = 2;
209
+
210
+ // Storage size
211
+ int64 storage_bytes = 3;
212
+
213
+ // Retention info
214
+ google.protobuf.Timestamp oldest_event = 4;
215
+ google.protobuf.Timestamp newest_event = 5;
216
+
217
+ // Stream info
218
+ repeated StreamInfo streams = 6;
219
+
220
+ message StreamInfo {
221
+ string stream_name = 1;
222
+ int64 message_count = 2;
223
+ int64 bytes = 3;
224
+ google.protobuf.Timestamp first_timestamp = 4;
225
+ google.protobuf.Timestamp last_timestamp = 5;
226
+ }
227
+ }
228
+
229
+ // EventFilter defines retention and storage policies
230
+ message EventFilter {
231
+ string filter_id = 1;
232
+ string name = 2;
233
+ string description = 3;
234
+
235
+ // Match criteria
236
+ repeated string event_types = 4;
237
+ repeated string tenant_ids = 5;
238
+ map<string, string> labels = 6;
239
+
240
+ // Retention policy
241
+ RetentionPolicy retention = 7;
242
+
243
+ message RetentionPolicy {
244
+ // Retention duration (e.g., "7d", "30d", "90d")
245
+ string duration = 1;
246
+
247
+ // Max storage size (bytes)
248
+ int64 max_bytes = 2;
249
+
250
+ // Max message count
251
+ int64 max_messages = 3;
252
+ }
253
+ }
254
+