@ancplua/qyl-api-schema 0.2.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 (54) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +89 -0
  3. package/VERSIONING.md +74 -0
  4. package/api/routes.tsp +1052 -0
  5. package/api/streaming.tsp +335 -0
  6. package/common/errors.tsp +206 -0
  7. package/common/pagination.tsp +254 -0
  8. package/common/types.tsp +345 -0
  9. package/generated/README.md +26 -0
  10. package/generated/otel-keys.gen.tsp +1648 -0
  11. package/index.tsp +55 -0
  12. package/intelligence/causal-rules.tsp +34 -0
  13. package/intelligence/diagnostic-patterns.tsp +54 -0
  14. package/intelligence/investigation-strategies.tsp +37 -0
  15. package/intelligence/main.tsp +19 -0
  16. package/intelligence/seed/patterns.tsp +172 -0
  17. package/intelligence/seed/rules.tsp +44 -0
  18. package/intelligence/seed/strategies.tsp +56 -0
  19. package/intelligence/signals.tsp +60 -0
  20. package/models/agent/agent-run.tsp +154 -0
  21. package/models/agent/tool-call.tsp +122 -0
  22. package/models/agent/workflow-checkpoint.tsp +50 -0
  23. package/models/agent/workflow-execution.tsp +136 -0
  24. package/models/alerting.tsp +436 -0
  25. package/models/configurator.tsp +433 -0
  26. package/models/control-graph.tsp +197 -0
  27. package/models/db.tsp +810 -0
  28. package/models/deployment.tsp +365 -0
  29. package/models/error.tsp +433 -0
  30. package/models/genai.tsp +1368 -0
  31. package/models/http.tsp +600 -0
  32. package/models/identity.tsp +213 -0
  33. package/models/issues.tsp +484 -0
  34. package/models/log.tsp +140 -0
  35. package/models/messaging.tsp +304 -0
  36. package/models/otel-config.tsp +455 -0
  37. package/models/retention.tsp +240 -0
  38. package/models/rpc.tsp +309 -0
  39. package/models/search.tsp +243 -0
  40. package/models/session.tsp +274 -0
  41. package/models/system.tsp +400 -0
  42. package/models/test.tsp +346 -0
  43. package/models/triage.tsp +113 -0
  44. package/models/workflow.tsp +396 -0
  45. package/models/workspace.tsp +435 -0
  46. package/otel/enums.tsp +392 -0
  47. package/otel/logs.tsp +135 -0
  48. package/otel/metrics.tsp +358 -0
  49. package/otel/otel-conventions.tsp +14 -0
  50. package/otel/profiles.tsp +335 -0
  51. package/otel/resource.tsp +257 -0
  52. package/otel/span.tsp +307 -0
  53. package/package.json +88 -0
  54. package/tspconfig.yaml +49 -0
package/models/rpc.tsp ADDED
@@ -0,0 +1,309 @@
1
+ // =============================================================================
2
+ // ANcpLua v2.0 - RPC Semantic Conventions (OTel v1.40)
3
+ // =============================================================================
4
+ // Remote Procedure Call telemetry attributes (gRPC, etc.).
5
+ // =============================================================================
6
+
7
+ import "../common/types.tsp";
8
+
9
+ using Qyl.Api.Contracts.Common;
10
+
11
+ namespace Qyl.Api.Contracts.Domains.Transport.Rpc;
12
+
13
+ // =============================================================================
14
+ // RPC Span Attributes
15
+ // =============================================================================
16
+
17
+ @doc("RPC span attributes")
18
+ model RpcAttributes {
19
+ @doc("The RPC system (e.g., grpc, wcf, java_rmi)")
20
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.System)
21
+ system: RpcSystem;
22
+
23
+ @doc("The RPC service name")
24
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.Service)
25
+ service?: string;
26
+
27
+ @doc("The RPC method name")
28
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.Method)
29
+ method?: string;
30
+
31
+ @doc("Server address")
32
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Server.Address)
33
+ serverAddress?: string;
34
+
35
+ @doc("Server port")
36
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Server.Port)
37
+ serverPort?: Port;
38
+
39
+ // ---------------------------------------------------------------------------
40
+ // gRPC-Specific Attributes
41
+ // ---------------------------------------------------------------------------
42
+
43
+ @doc("gRPC status code")
44
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.GrpcStatusCode)
45
+ grpcStatusCode?: GrpcStatusCode;
46
+
47
+ @doc("gRPC request metadata. Keys map to rpc.grpc.request.metadata.<key>")
48
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.GrpcRequestMetadata)
49
+ grpcRequestMetadata?: Record<string[]>;
50
+
51
+ @doc("gRPC response metadata. Keys map to rpc.grpc.response.metadata.<key>")
52
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.GrpcResponseMetadata)
53
+ grpcResponseMetadata?: Record<string[]>;
54
+
55
+ // ---------------------------------------------------------------------------
56
+ // Message Attributes
57
+ // ---------------------------------------------------------------------------
58
+
59
+ @doc("Message type (SENT or RECEIVED)")
60
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.MessageType)
61
+ messageType?: RpcMessageType;
62
+
63
+ @doc("Message ID (sequence number)")
64
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.MessageId)
65
+ messageId?: int64;
66
+
67
+ @doc("Compressed message size in bytes")
68
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.MessageCompressedSize)
69
+ messageCompressedSize?: ByteSize;
70
+
71
+ @doc("Uncompressed message size in bytes")
72
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.MessageUncompressedSize)
73
+ messageUncompressedSize?: ByteSize;
74
+
75
+ // ---------------------------------------------------------------------------
76
+ // Connect RPC Attributes
77
+ // ---------------------------------------------------------------------------
78
+
79
+ @doc("Connect RPC error code")
80
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.ConnectRpcErrorCode)
81
+ connectRpcErrorCode?: ConnectRpcErrorCode;
82
+
83
+ // ---------------------------------------------------------------------------
84
+ // JSON-RPC Attributes
85
+ // ---------------------------------------------------------------------------
86
+
87
+ @doc("JSON-RPC error code")
88
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.JsonrpcErrorCode)
89
+ jsonrpcErrorCode?: int32;
90
+
91
+ @doc("JSON-RPC error message")
92
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.JsonrpcErrorMessage)
93
+ jsonrpcErrorMessage?: string;
94
+
95
+ @doc("JSON-RPC request ID")
96
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.JsonrpcRequestId)
97
+ jsonrpcRequestId?: string;
98
+
99
+ @doc("JSON-RPC version")
100
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.JsonrpcVersion)
101
+ jsonrpcVersion?: string;
102
+ }
103
+
104
+ // =============================================================================
105
+ // RPC Enumerations
106
+ // =============================================================================
107
+
108
+ @doc("RPC systems")
109
+ enum RpcSystem {
110
+ @doc("gRPC protocol")
111
+ grpc: "grpc",
112
+
113
+ @doc("Apache Thrift")
114
+ apacheThrift: "apache_thrift",
115
+
116
+ @doc("Connect RPC")
117
+ connectRpc: "connect_rpc",
118
+
119
+ @doc("JSON-RPC")
120
+ jsonrpc: "jsonrpc",
121
+
122
+ @doc("Apache Dubbo")
123
+ apacheDubbo: "apache_dubbo",
124
+
125
+ @doc("Windows Communication Foundation")
126
+ wcf: "wcf",
127
+
128
+ @doc("Java RMI")
129
+ javaRmi: "java_rmi",
130
+
131
+ @doc(".NET Remoting")
132
+ dotnetRemoting: "dotnet_remoting",
133
+ }
134
+
135
+ @doc("gRPC status codes")
136
+ enum GrpcStatusCode {
137
+ @doc("Success")
138
+ ok: 0,
139
+
140
+ @doc("Cancelled by client")
141
+ cancelled: 1,
142
+
143
+ @doc("Unknown error")
144
+ `unknown`: 2,
145
+
146
+ @doc("Invalid argument")
147
+ invalidArgument: 3,
148
+
149
+ @doc("Deadline exceeded")
150
+ deadlineExceeded: 4,
151
+
152
+ @doc("Not found")
153
+ notFound: 5,
154
+
155
+ @doc("Already exists")
156
+ alreadyExists: 6,
157
+
158
+ @doc("Permission denied")
159
+ permissionDenied: 7,
160
+
161
+ @doc("Resource exhausted")
162
+ resourceExhausted: 8,
163
+
164
+ @doc("Failed precondition")
165
+ failedPrecondition: 9,
166
+
167
+ @doc("Aborted")
168
+ aborted: 10,
169
+
170
+ @doc("Out of range")
171
+ outOfRange: 11,
172
+
173
+ @doc("Unimplemented")
174
+ unimplemented: 12,
175
+
176
+ @doc("Internal error")
177
+ internal: 13,
178
+
179
+ @doc("Unavailable")
180
+ unavailable: 14,
181
+
182
+ @doc("Data loss")
183
+ dataLoss: 15,
184
+
185
+ @doc("Unauthenticated")
186
+ unauthenticated: 16,
187
+ }
188
+
189
+ @doc("Connect RPC error codes")
190
+ enum ConnectRpcErrorCode {
191
+ @doc("Cancelled")
192
+ cancelled: "cancelled",
193
+
194
+ @doc("Unknown")
195
+ `unknown`: "unknown",
196
+
197
+ @doc("Invalid argument")
198
+ invalidArgument: "invalid_argument",
199
+
200
+ @doc("Deadline exceeded")
201
+ deadlineExceeded: "deadline_exceeded",
202
+
203
+ @doc("Not found")
204
+ notFound: "not_found",
205
+
206
+ @doc("Already exists")
207
+ alreadyExists: "already_exists",
208
+
209
+ @doc("Permission denied")
210
+ permissionDenied: "permission_denied",
211
+
212
+ @doc("Resource exhausted")
213
+ resourceExhausted: "resource_exhausted",
214
+
215
+ @doc("Failed precondition")
216
+ failedPrecondition: "failed_precondition",
217
+
218
+ @doc("Aborted")
219
+ aborted: "aborted",
220
+
221
+ @doc("Out of range")
222
+ outOfRange: "out_of_range",
223
+
224
+ @doc("Unimplemented")
225
+ unimplemented: "unimplemented",
226
+
227
+ @doc("Internal")
228
+ internal: "internal",
229
+
230
+ @doc("Unavailable")
231
+ unavailable: "unavailable",
232
+
233
+ @doc("Data loss")
234
+ dataLoss: "data_loss",
235
+
236
+ @doc("Unauthenticated")
237
+ unauthenticated: "unauthenticated",
238
+ }
239
+
240
+ @doc("RPC message types")
241
+ enum RpcMessageType {
242
+ @doc("Message sent")
243
+ sent: "SENT",
244
+
245
+ @doc("Message received")
246
+ received: "RECEIVED",
247
+ }
248
+
249
+ // =============================================================================
250
+ // RPC Metrics
251
+ // =============================================================================
252
+
253
+ @doc("RPC server duration metric")
254
+ model RpcServerDurationMetric {
255
+ @doc("Metric name")
256
+ name: "rpc.server.duration";
257
+
258
+ @doc("Metric unit (seconds)")
259
+ unit: "s";
260
+
261
+ @doc("RPC system")
262
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.System)
263
+ system: RpcSystem;
264
+
265
+ @doc("RPC service")
266
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.Service)
267
+ service: string;
268
+
269
+ @doc("RPC method")
270
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.Method)
271
+ method: string;
272
+
273
+ @doc("gRPC status code")
274
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.GrpcStatusCode)
275
+ grpcStatusCode?: GrpcStatusCode;
276
+ }
277
+
278
+ @doc("RPC client duration metric")
279
+ model RpcClientDurationMetric {
280
+ @doc("Metric name")
281
+ name: "rpc.client.duration";
282
+
283
+ @doc("Metric unit (seconds)")
284
+ unit: "s";
285
+
286
+ @doc("RPC system")
287
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.System)
288
+ system: RpcSystem;
289
+
290
+ @doc("RPC service")
291
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.Service)
292
+ service: string;
293
+
294
+ @doc("RPC method")
295
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.Method)
296
+ method: string;
297
+
298
+ @doc("Server address")
299
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Server.Address)
300
+ serverAddress: string;
301
+
302
+ @doc("Server port")
303
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Server.Port)
304
+ serverPort: Port;
305
+
306
+ @doc("gRPC status code")
307
+ @encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.Rpc.GrpcStatusCode)
308
+ grpcStatusCode?: GrpcStatusCode;
309
+ }
@@ -0,0 +1,243 @@
1
+ // =============================================================================
2
+ // ANcpLua v2.0 - Unified Search Entities
3
+ // =============================================================================
4
+ // Search documents, inverted index, query telemetry.
5
+ // =============================================================================
6
+
7
+ import "@typespec/openapi";
8
+ import "../common/types.tsp";
9
+
10
+ using TypeSpec.OpenAPI;
11
+ using Qyl.Api.Contracts.Common;
12
+
13
+ namespace Qyl.Api.Contracts.Domains.Search;
14
+
15
+ // =============================================================================
16
+ // Search Document
17
+ // =============================================================================
18
+
19
+ @doc("Canonical search document across all entity types")
20
+ @extension("x-csharp-type", "SearchDocumentEntity")
21
+ model SearchDocumentEntity {
22
+ @doc("Document ID")
23
+ @key
24
+ id: string;
25
+
26
+ @doc("Source entity type (span, log, issue, workflow, etc.)")
27
+ @encodedName("application/json", "entity_type")
28
+ entityType: SearchEntityType;
29
+
30
+ @doc("Source entity ID")
31
+ @encodedName("application/json", "entity_id")
32
+ entityId: string;
33
+
34
+ @doc("Owning project")
35
+ @encodedName("application/json", "project_id")
36
+ projectId?: string;
37
+
38
+ @doc("Document title")
39
+ title: string;
40
+
41
+ @doc("Document body (searchable text)")
42
+ body?: string;
43
+
44
+ @doc("Link to source entity")
45
+ url?: string;
46
+
47
+ @doc("Document tags")
48
+ @encodedName("application/json", "tags_json")
49
+ tagsJson?: string;
50
+
51
+ @doc("Additional metadata")
52
+ @encodedName("application/json", "metadata_json")
53
+ metadataJson?: string;
54
+
55
+ @doc("Relevance boost factor")
56
+ boost: float64;
57
+
58
+ @doc("Last indexed timestamp")
59
+ @encodedName("application/json", "indexed_at")
60
+ indexedAt: utcDateTime;
61
+
62
+ @doc("Last update timestamp")
63
+ @encodedName("application/json", "updated_at")
64
+ updatedAt: utcDateTime;
65
+ }
66
+
67
+ @doc("Searchable entity types")
68
+ enum SearchEntityType {
69
+ @doc("Trace/span")
70
+ span: "span",
71
+
72
+ @doc("Log entry")
73
+ log: "log",
74
+
75
+ @doc("Error issue")
76
+ issue: "issue",
77
+
78
+ @doc("Workflow run")
79
+ workflow: "workflow",
80
+
81
+ @doc("Deployment")
82
+ deployment: "deployment",
83
+
84
+ @doc("Session")
85
+ session: "session",
86
+
87
+ @doc("Alert")
88
+ alert: "alert",
89
+
90
+ @doc("Fix run")
91
+ fix: "fix",
92
+ }
93
+
94
+ // =============================================================================
95
+ // Search Term (Inverted Index)
96
+ // =============================================================================
97
+
98
+ @doc("Inverted token index entry")
99
+ @extension("x-csharp-type", "SearchTermEntity")
100
+ model SearchTermEntity {
101
+ @doc("Normalized term")
102
+ term: string;
103
+
104
+ @doc("Document containing this term")
105
+ @encodedName("application/json", "document_id")
106
+ documentId: string;
107
+
108
+ @doc("Field where term appears (title, body, tags)")
109
+ field: string;
110
+
111
+ @doc("Term frequency in this document/field")
112
+ @encodedName("application/json", "term_frequency")
113
+ termFrequency: int32;
114
+
115
+ @doc("Position offsets for highlighting")
116
+ @encodedName("application/json", "position_offsets_json")
117
+ positionOffsetsJson?: string;
118
+ }
119
+
120
+ // =============================================================================
121
+ // Search Query Audit
122
+ // =============================================================================
123
+
124
+ @doc("Search query telemetry entry")
125
+ @extension("x-csharp-type", "SearchQueryAuditEntity")
126
+ model SearchQueryAuditEntity {
127
+ @doc("Audit entry ID")
128
+ @key
129
+ id: string;
130
+
131
+ @doc("Search query text")
132
+ @encodedName("application/json", "query_text")
133
+ queryText: string;
134
+
135
+ @doc("Query type")
136
+ @encodedName("application/json", "query_type")
137
+ queryType: string;
138
+
139
+ @doc("Filtered entity types")
140
+ @encodedName("application/json", "entity_types_json")
141
+ entityTypesJson?: string;
142
+
143
+ @doc("Project scope")
144
+ @encodedName("application/json", "project_id")
145
+ projectId?: string;
146
+
147
+ @doc("Number of results returned")
148
+ @encodedName("application/json", "result_count")
149
+ resultCount: int32;
150
+
151
+ @doc("Clicked result document ID")
152
+ @encodedName("application/json", "clicked_result_id")
153
+ clickedResultId?: string;
154
+
155
+ @doc("Position of clicked result")
156
+ @encodedName("application/json", "clicked_position")
157
+ clickedPosition?: int32;
158
+
159
+ @doc("Query execution time in ms")
160
+ @encodedName("application/json", "duration_ms")
161
+ durationMs?: int32;
162
+
163
+ @doc("Querying user")
164
+ @encodedName("application/json", "user_id")
165
+ userId?: string;
166
+
167
+ @doc("Query timestamp")
168
+ timestamp: utcDateTime;
169
+ }
170
+
171
+ // =============================================================================
172
+ // Search Request/Response (API models, not stored)
173
+ // =============================================================================
174
+
175
+ @doc("Unified search request")
176
+ model SearchRequest {
177
+ @doc("Search query text")
178
+ query: string;
179
+
180
+ @doc("Entity type filters")
181
+ @encodedName("application/json", "entity_types")
182
+ entityTypes?: SearchEntityType[];
183
+
184
+ @doc("Project scope")
185
+ @encodedName("application/json", "project_id")
186
+ projectId?: string;
187
+
188
+ @doc("Maximum results")
189
+ @minValue(1)
190
+ @maxValue(100)
191
+ limit?: int32 = 20;
192
+
193
+ @doc("Cursor for pagination")
194
+ cursor?: string;
195
+ }
196
+
197
+ @doc("Unified search response")
198
+ model SearchResponse {
199
+ @doc("Search results")
200
+ results: SearchResult[];
201
+
202
+ @doc("Total matching documents")
203
+ @encodedName("application/json", "total_count")
204
+ totalCount: int64;
205
+
206
+ @doc("Query execution time in ms")
207
+ @encodedName("application/json", "duration_ms")
208
+ durationMs: int32;
209
+
210
+ @doc("Next page cursor")
211
+ @encodedName("application/json", "next_cursor")
212
+ nextCursor?: string;
213
+
214
+ @doc("Search suggestions")
215
+ suggestions?: string[];
216
+ }
217
+
218
+ @doc("Individual search result")
219
+ model SearchResult {
220
+ @doc("Document ID")
221
+ @encodedName("application/json", "document_id")
222
+ documentId: string;
223
+
224
+ @doc("Entity type")
225
+ @encodedName("application/json", "entity_type")
226
+ entityType: SearchEntityType;
227
+
228
+ @doc("Entity ID")
229
+ @encodedName("application/json", "entity_id")
230
+ entityId: string;
231
+
232
+ @doc("Result title")
233
+ title: string;
234
+
235
+ @doc("Result snippet with highlights")
236
+ snippet?: string;
237
+
238
+ @doc("Relevance score")
239
+ score: float64;
240
+
241
+ @doc("Link to entity")
242
+ url?: string;
243
+ }