@ancplua/qyl-api-schema 0.3.0 → 0.5.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 (58) hide show
  1. package/README.md +50 -64
  2. package/api/routes.tsp +90 -943
  3. package/api/runner.tsp +74 -0
  4. package/api/streaming.tsp +13 -299
  5. package/common/errors.tsp +14 -1
  6. package/common/pagination.tsp +1 -1
  7. package/common/types.tsp +2 -39
  8. package/generated/ts-runtime/api.d.ts +734 -0
  9. package/generated/ts-runtime/api.js +219 -0
  10. package/index.tsp +7 -34
  11. package/models/health.tsp +22 -0
  12. package/models/runner-mcp.tsp +47 -0
  13. package/models/runner.tsp +37 -0
  14. package/models/session.tsp +1 -1
  15. package/otel/enums.tsp +1 -1
  16. package/otel/logs.tsp +1 -1
  17. package/otel/otel-conventions.tsp +0 -1
  18. package/otel/profiles.tsp +1 -1
  19. package/otel/resource.tsp +1 -1
  20. package/otel/span.tsp +1 -1
  21. package/package.json +46 -34
  22. package/VERSIONING.md +0 -84
  23. package/generated/README.md +0 -35
  24. package/intelligence/causal-rules.tsp +0 -34
  25. package/intelligence/diagnostic-patterns.tsp +0 -54
  26. package/intelligence/investigation-strategies.tsp +0 -37
  27. package/intelligence/main.tsp +0 -17
  28. package/intelligence/seed/patterns.tsp +0 -171
  29. package/intelligence/seed/rules.tsp +0 -43
  30. package/intelligence/seed/strategies.tsp +0 -55
  31. package/intelligence/signals.tsp +0 -60
  32. package/models/agent/agent-run.tsp +0 -154
  33. package/models/agent/tool-call.tsp +0 -122
  34. package/models/agent/workflow-checkpoint.tsp +0 -50
  35. package/models/agent/workflow-execution.tsp +0 -136
  36. package/models/alerting.tsp +0 -436
  37. package/models/configurator.tsp +0 -433
  38. package/models/control-graph.tsp +0 -197
  39. package/models/db.tsp +0 -810
  40. package/models/deployment.tsp +0 -365
  41. package/models/error.tsp +0 -433
  42. package/models/genai.tsp +0 -1322
  43. package/models/http.tsp +0 -600
  44. package/models/identity.tsp +0 -213
  45. package/models/issues.tsp +0 -484
  46. package/models/log.tsp +0 -140
  47. package/models/messaging.tsp +0 -304
  48. package/models/otel-config.tsp +0 -455
  49. package/models/retention.tsp +0 -240
  50. package/models/rpc.tsp +0 -309
  51. package/models/search.tsp +0 -243
  52. package/models/system.tsp +0 -400
  53. package/models/test.tsp +0 -346
  54. package/models/triage.tsp +0 -113
  55. package/models/workflow.tsp +0 -396
  56. package/models/workspace.tsp +0 -435
  57. package/otel/metrics.tsp +0 -358
  58. package/tspconfig.yaml +0 -49
package/api/runner.tsp ADDED
@@ -0,0 +1,74 @@
1
+ import "@typespec/events";
2
+ import "@typespec/http";
3
+ import "@typespec/sse";
4
+
5
+ import "../common/errors.tsp";
6
+ import "../models/runner.tsp";
7
+ import "../models/runner-mcp.tsp";
8
+
9
+ using TypeSpec.Events;
10
+ using TypeSpec.Http;
11
+ using TypeSpec.SSE;
12
+
13
+ using Qyl.Api.Contracts.Common.Errors;
14
+ using Qyl.Api.Contracts.Runner.Mcp;
15
+
16
+ namespace Qyl.Api.Contracts.Runner {
17
+ @events
18
+ union RunnerResourceEvents {
19
+ RunnerResourceState,
20
+ }
21
+
22
+ @events
23
+ union RunnerLogEvents {
24
+ RunnerLogLine,
25
+ }
26
+
27
+ @route("/runner/resources")
28
+ @tag("Runner resources")
29
+ interface RunnerResourcesApi {
30
+ @get
31
+ snapshot(): RunnerResourceState[] | InternalServerError;
32
+
33
+ @get
34
+ @route("/stream")
35
+ stream(): SSEStream<RunnerResourceEvents> | InternalServerError;
36
+
37
+ @get
38
+ @route("/{resource}/logs")
39
+ logs(
40
+ @path resource: string,
41
+ ): RunnerLogLine[] | NotFoundError | InternalServerError;
42
+
43
+ @get
44
+ @route("/{resource}/logs/stream")
45
+ streamLogs(
46
+ @path resource: string,
47
+ ): SSEStream<RunnerLogEvents> | NotFoundError | InternalServerError;
48
+ }
49
+
50
+ @route("/runner/mcp/{resource}/tools")
51
+ @tag("Runner MCP")
52
+ interface RunnerMcpApi {
53
+ @get
54
+ listTools(
55
+ @path resource: string,
56
+ ): RunnerMcpToolsResponse
57
+ | NotFoundError
58
+ | ConflictError
59
+ | BadGatewayError
60
+ | InternalServerError;
61
+
62
+ @post
63
+ @route("/call")
64
+ callTool(
65
+ @path resource: string,
66
+ @body request: RunnerMcpToolCallRequest,
67
+ ): RunnerMcpToolCallResponse
68
+ | ValidationError
69
+ | NotFoundError
70
+ | ConflictError
71
+ | BadGatewayError
72
+ | InternalServerError;
73
+ }
74
+ }
package/api/streaming.tsp CHANGED
@@ -1,335 +1,49 @@
1
- // =============================================================================
2
- // qyl streaming API routes
3
- // =============================================================================
4
- // Server-Sent Events (SSE) streaming endpoints for real-time telemetry.
5
- // =============================================================================
6
-
1
+ import "@typespec/events";
7
2
  import "@typespec/http";
8
3
  import "@typespec/sse";
9
- import "@typespec/events";
10
- import "@typespec/versioning";
11
4
 
12
- import "../common/types.tsp";
13
- import "../common/pagination.tsp";
14
- import "../otel/span.tsp";
5
+ import "./routes.tsp";
6
+ import "../common/errors.tsp";
15
7
  import "../otel/logs.tsp";
16
- import "../otel/metrics.tsp";
17
- import "../models/deployment.tsp";
18
8
 
9
+ using TypeSpec.Events;
19
10
  using TypeSpec.Http;
20
11
  using TypeSpec.SSE;
21
- using TypeSpec.Events;
22
- using TypeSpec.Versioning;
23
12
 
24
- using Qyl.Api.Contracts.Common;
25
- using Qyl.Api.Contracts.OTel.Traces;
13
+ using Qyl.Api.Contracts.Common.Errors;
26
14
  using Qyl.Api.Contracts.OTel.Logs;
27
- using Qyl.Api.Contracts.OTel.Metrics;
28
- using Qyl.Api.Contracts.OTel.Enums;
29
- using Qyl.Api.Contracts.Domains.Ops.Deployment;
30
15
 
31
16
  namespace Qyl.Api.Contracts.Streaming;
32
17
 
33
- // =============================================================================
34
- // Stream Event Types
35
- // =============================================================================
36
-
37
- @doc("Trace stream event")
38
- model TraceStreamEvent {
39
- @doc("Event type")
40
- type: "trace";
41
-
42
- @doc("Trace data")
43
- data: Trace;
44
-
45
- @doc("Event timestamp")
46
- timestamp: utcDateTime;
47
- }
48
-
49
- @doc("Span stream event")
50
- model SpanStreamEvent {
51
- @doc("Event type")
52
- type: "span";
53
-
54
- @doc("Span data")
55
- data: Span;
56
-
57
- @doc("Event timestamp")
58
- timestamp: utcDateTime;
59
- }
60
-
61
- @doc("Log stream event")
18
+ @doc("One log delivered by the collector's live stream.")
62
19
  model LogStreamEvent {
63
- @doc("Event type")
64
20
  type: "log";
65
-
66
- @doc("Log data")
67
21
  data: LogRecord;
68
-
69
- @doc("Event timestamp")
70
- timestamp: utcDateTime;
71
- }
72
-
73
- @doc("Metric stream event")
74
- model MetricStreamEvent {
75
- @doc("Event type")
76
- type: "metric";
77
-
78
- @doc("Metric data")
79
- data: Metric;
80
-
81
- @doc("Event timestamp")
82
- timestamp: utcDateTime;
83
- }
84
-
85
- @doc("Deployment stream event")
86
- model DeploymentStreamEvent {
87
- @doc("Event type")
88
- type: "deployment";
89
-
90
- @doc("Deployment event data")
91
- data: DeploymentEvent;
92
-
93
- @doc("Event timestamp")
94
22
  timestamp: utcDateTime;
95
23
  }
96
24
 
97
- @doc("Heartbeat event for connection keep-alive")
25
+ @doc("Keep-alive event emitted while no new log is available.")
98
26
  model HeartbeatEvent {
99
- @doc("Event type")
100
27
  type: "heartbeat";
101
-
102
- @doc("Server timestamp")
103
28
  timestamp: utcDateTime;
104
29
  }
105
30
 
106
- // =============================================================================
107
- // Combined Stream Event Union
108
- // =============================================================================
109
-
110
- @doc("All possible stream event types")
111
- @events
112
- union TelemetryStreamEvent {
113
- trace: TraceStreamEvent,
114
- span: SpanStreamEvent,
115
- log: LogStreamEvent,
116
- metric: MetricStreamEvent,
117
- deployment: DeploymentStreamEvent,
118
- heartbeat: HeartbeatEvent,
119
- }
120
-
121
- @doc("Trace stream events")
122
- @events
123
- union TraceEvents {
124
- trace: TraceStreamEvent,
125
- heartbeat: HeartbeatEvent,
126
- }
127
-
128
- @doc("Span stream events")
129
- @events
130
- union SpanEvents {
131
- span: SpanStreamEvent,
132
- heartbeat: HeartbeatEvent,
133
- }
134
-
135
- @doc("Log stream events")
136
31
  @events
137
32
  union LogEvents {
138
33
  log: LogStreamEvent,
139
34
  heartbeat: HeartbeatEvent,
140
35
  }
141
36
 
142
- @doc("Metric stream events")
143
- @events
144
- union MetricEvents {
145
- metric: MetricStreamEvent,
146
- heartbeat: HeartbeatEvent,
147
- }
148
-
149
- @doc("Deployment stream events")
150
- @events
151
- union DeploymentEvents {
152
- deployment: DeploymentStreamEvent,
153
- heartbeat: HeartbeatEvent,
154
- }
155
-
156
- // =============================================================================
157
- // Stream Subscription Models
158
- // =============================================================================
159
-
160
- @doc("Stream subscription request")
161
- model StreamSubscription {
162
- @doc("Event types to subscribe to")
163
- @encodedName("application/json", "event_types")
164
- eventTypes: StreamEventType[];
165
-
166
- @doc("Service name filter")
167
- @encodedName("application/json", "service_name")
168
- serviceName?: string;
169
-
170
- @doc("Trace ID filter (for specific trace)")
171
- @encodedName("application/json", "trace_id")
172
- traceId?: TraceId;
173
-
174
- @doc("Minimum severity for logs (1-24)")
175
- @encodedName("application/json", "min_severity")
176
- @minValue(1)
177
- @maxValue(24)
178
- minSeverity?: int32;
179
-
180
- @doc("Attribute filters")
181
- filters?: Record<string>;
182
-
183
- @doc("Sample rate (0.0-1.0)")
184
- @encodedName("application/json", "sample_rate")
185
- @minValue(0)
186
- @maxValue(1)
187
- sampleRate?: float64;
188
- }
189
-
190
- @doc("Stream event types")
191
- enum StreamEventType {
192
- @doc("Trace events")
193
- traces: "traces",
194
-
195
- @doc("Span events")
196
- spans: "spans",
197
-
198
- @doc("Log events")
199
- logs: "logs",
200
-
201
- @doc("Metric events")
202
- metrics: "metrics",
203
-
204
- @doc("Deployment events")
205
- deployments: "deployments",
206
-
207
- @doc("All events")
208
- all: "all",
209
- }
210
-
211
- // =============================================================================
212
- // Streaming API Interfaces
213
- // =============================================================================
214
-
215
37
  @route("/api/v1/stream")
216
38
  @tag("Streaming")
217
39
  interface StreamingApi {
218
- @doc("Stream all telemetry events (SSE)")
219
- @get
220
- @route("/events")
221
- streamEvents(
222
- @query @doc("Event types") types?: StreamEventType[],
223
- @query @doc("Service name filter") serviceName?: string,
224
- @query @doc("Sample rate") sampleRate?: float64,
225
- ): SSEStream<TelemetryStreamEvent>;
226
-
227
- @doc("Stream traces in real-time")
228
- @get
229
- @route("/traces")
230
- streamTraces(
231
- @query @doc("Service name filter") serviceName?: string,
232
- @query @doc("Minimum duration filter") minDurationMs?: int64,
233
- ): SSEStream<TraceEvents>;
234
-
235
- @doc("Stream spans for a specific trace")
236
- @get
237
- @route("/traces/{traceId}/spans")
238
- streamTraceSpans(@path traceId: TraceId): SSEStream<SpanEvents>;
239
-
240
- @doc("Stream logs in real-time")
241
40
  @get
242
41
  @route("/logs")
42
+ @useAuth(Qyl.Api.Contracts.QylApiKeyHeaderAuth)
243
43
  streamLogs(
244
- @query @doc("Service name filter") serviceName?: string,
245
- @query @doc("Minimum severity") minSeverity?: int32,
246
- @query @doc("Query filter") query?: string,
247
- ): SSEStream<LogEvents>;
248
-
249
- @doc("Stream metrics in real-time")
250
- @get
251
- @route("/metrics")
252
- streamMetrics(
253
- @query @doc("Metric name filter") metricName?: string,
254
- @query @doc("Service name filter") serviceName?: string,
255
- ): SSEStream<MetricEvents>;
256
-
257
- @doc("Stream deployment events")
258
- @get
259
- @route("/deployments")
260
- streamDeployments(
261
- @query @doc("Service name filter") serviceName?: string,
262
- @query @doc("Environment filter") environment?: string,
263
- ): SSEStream<DeploymentEvents>;
264
- }
265
-
266
- // =============================================================================
267
- // WebSocket Streaming (Alternative)
268
- // =============================================================================
269
-
270
- @doc("WebSocket message wrapper")
271
- model WebSocketMessage<T> {
272
- @doc("Message ID")
273
- id: string;
274
-
275
- @doc("Message type")
276
- type: WebSocketMessageType;
277
-
278
- @doc("Message payload")
279
- payload?: T;
280
-
281
- @doc("Timestamp")
282
- timestamp: utcDateTime;
283
- }
284
-
285
- @doc("WebSocket message types")
286
- enum WebSocketMessageType {
287
- @doc("Subscribe to events")
288
- subscribe: "subscribe",
289
-
290
- @doc("Unsubscribe from events")
291
- unsubscribe: "unsubscribe",
292
-
293
- @doc("Data event")
294
- data: "data",
295
-
296
- @doc("Error message")
297
- error: "error",
298
-
299
- @doc("Acknowledgment")
300
- ack: "ack",
301
-
302
- @doc("Ping")
303
- ping: "ping",
304
-
305
- @doc("Pong")
306
- pong: "pong",
307
- }
308
-
309
- // =============================================================================
310
- // Tail-based Sampling Configuration
311
- // =============================================================================
312
-
313
- @doc("Tail-based sampling configuration for streaming")
314
- model TailSamplingConfig {
315
- @doc("Enable tail-based sampling")
316
- enabled: boolean;
317
-
318
- @doc("Sample error traces")
319
- @encodedName("application/json", "sample_errors")
320
- sampleErrors: boolean;
321
-
322
- @doc("Sample slow traces (above threshold)")
323
- @encodedName("application/json", "sample_slow")
324
- sampleSlow: boolean;
325
-
326
- @doc("Slow trace threshold in milliseconds")
327
- @encodedName("application/json", "slow_threshold_ms")
328
- slowThresholdMs?: int64;
329
-
330
- @doc("Random sample rate for remaining traces")
331
- @encodedName("application/json", "random_rate")
332
- @minValue(0)
333
- @maxValue(1)
334
- randomRate: float64;
44
+ ...Qyl.Api.Contracts.ProjectScopeHeader,
45
+ @query serviceName?: string,
46
+ @query @minValue(1) @maxValue(24) minSeverity?: int32,
47
+ @query query?: string,
48
+ ): SSEStream<LogEvents> | UnauthorizedError | InternalServerError;
335
49
  }
package/common/errors.tsp CHANGED
@@ -1,5 +1,5 @@
1
1
  // =============================================================================
2
- // ANcpLua v2.0 - Error Models
2
+ // qyl product API error models
3
3
  // =============================================================================
4
4
  // Standardized error responses following RFC 7807 Problem Details.
5
5
  // =============================================================================
@@ -159,6 +159,16 @@ model InternalServerError extends ProblemDetails {
159
159
  errorCode?: string;
160
160
  }
161
161
 
162
+ @doc("Upstream dependency failed while fulfilling the request (502)")
163
+ @error
164
+ model BadGatewayError extends ProblemDetails {
165
+ @statusCode _: 502;
166
+ title: "Bad Gateway";
167
+
168
+ @doc("Stable dependency category; never contains raw exception text")
169
+ dependency?: string;
170
+ }
171
+
162
172
  @doc("Service unavailable (503)")
163
173
  @error
164
174
  model ServiceUnavailableError extends ProblemDetails {
@@ -201,6 +211,9 @@ union ApiError {
201
211
  @doc("Server error")
202
212
  serverError: InternalServerError,
203
213
 
214
+ @doc("Upstream dependency failed")
215
+ badGateway: BadGatewayError,
216
+
204
217
  @doc("Service unavailable")
205
218
  unavailable: ServiceUnavailableError,
206
219
  }
@@ -1,5 +1,5 @@
1
1
  // =============================================================================
2
- // ANcpLua v2.0 - Pagination Templates
2
+ // Qyl API pagination templates
3
3
  // =============================================================================
4
4
  // Reusable pagination patterns for list operations.
5
5
  // =============================================================================
package/common/types.tsp CHANGED
@@ -6,56 +6,19 @@
6
6
  // (GenAI keys come from the dedicated GenAI registry since the 1.42 split).
7
7
  // =============================================================================
8
8
 
9
- import "@typespec/versioning";
10
9
  import "@typespec/json-schema";
11
10
  import "@typespec/openapi";
12
11
 
13
- using TypeSpec.Versioning;
14
12
  using TypeSpec.JsonSchema;
15
13
  using TypeSpec.OpenAPI;
16
14
 
17
15
  namespace Qyl.Api.Contracts.Common;
18
16
 
19
- // =============================================================================
20
- // Version Enum - OTel Semantic Convention Versions
21
- // =============================================================================
22
-
23
- @doc("OpenTelemetry semantic-convention versions supported by qyl compatibility models")
24
- enum OTelVersion {
25
- @doc("OTel Semconv v1.27 - Base version")
26
- v1_27: "1.27.0",
27
-
28
- @doc("OTel Semconv v1.28 - GenAI additions")
29
- v1_28: "1.28.0",
30
-
31
- @doc("OTel Semconv v1.29 - HTTP improvements")
32
- v1_29: "1.29.0",
33
-
34
- @doc("OTel Semconv v1.30 - Database updates")
35
- v1_30: "1.30.0",
36
-
37
- @doc("OTel Semconv v1.38 - GenAI.Agent support")
38
- v1_38: "1.38.0",
39
-
40
- @doc("OTel Semconv v1.39 - RPC metadata consolidation")
41
- v1_39: "1.39.0",
42
-
43
- @doc("OTel Semconv v1.40 - Oracle DB split, RPC cleanup, GenAI cache tokens")
44
- v1_40: "1.40.0",
45
-
46
- @doc("OTel Semconv v1.41 - GraphQL doc opt-in, RPC server client.* removal")
47
- v1_41: "1.41.0",
48
-
49
- @doc("OTel Semconv v1.42 - GenAI conventions moved to the dedicated GenAI registry; k8s/container registry attrs stable")
50
- v1_42: "1.42.0",
51
-
52
- @doc("OTel Semconv v1.43 - Current compatibility pin (core; GenAI keys from the GenAI dev registry)")
53
- v1_43: "1.43.0",
54
- }
55
-
56
17
  // =============================================================================
57
18
  // Identifier Scalars - Strongly Typed IDs
58
19
  // =============================================================================
20
+ // The semantic-conventions pin lives in the generated keys header and is
21
+ // machine-checked; a hand-maintained enum of upstream releases would only drift.
59
22
 
60
23
  @jsonSchema
61
24
  @doc("Unique trace identifier (32 lowercase hex characters)")