@ancplua/qyl-api-schema 7.4.0 → 9.0.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.
package/api/workflow.tsp DELETED
@@ -1,307 +0,0 @@
1
- import "@typespec/events";
2
- import "@typespec/http";
3
- import "@typespec/sse";
4
-
5
- import "../common/errors.tsp";
6
- import "../models/workflow.tsp";
7
- import "./routes.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.Workflow;
15
-
16
- namespace Qyl.Api.Contracts.Workflow;
17
-
18
- @doc("Keep-alive emitted while a workflow event stream has no new event.")
19
- model WorkflowHeartbeatEvent {
20
- type: "heartbeat";
21
-
22
- @encodedName("application/json", "high_water_mark")
23
- highWaterMark: WorkflowJournalPosition;
24
-
25
- timestamp: utcDateTime;
26
- }
27
-
28
- @doc("Signals that the requested cursor predates retained workflow history.")
29
- model WorkflowCursorGapEvent {
30
- type: "cursor_gap";
31
-
32
- @encodedName("application/json", "oldest_available_sequence")
33
- oldestAvailableSequence: WorkflowJournalPosition;
34
-
35
- @encodedName("application/json", "high_water_mark")
36
- highWaterMark: WorkflowJournalPosition;
37
-
38
- timestamp: utcDateTime;
39
- }
40
-
41
- @events
42
- union WorkflowStreamEvents {
43
- event: WorkflowJournalEvent,
44
- heartbeat: WorkflowHeartbeatEvent,
45
- cursorGap: WorkflowCursorGapEvent,
46
- }
47
-
48
- @doc("Which opaque graph cursor was rejected.")
49
- enum WorkflowCursorKind {
50
- node: "node",
51
- edge: "edge",
52
- }
53
-
54
- @doc("Why an opaque graph cursor cannot be reused for this request.")
55
- enum WorkflowCursorFailureReason {
56
- invalid: "invalid",
57
- wrongRun: "wrong_run",
58
- wrongGeneration: "wrong_generation",
59
- stale: "stale",
60
- }
61
-
62
- @doc("Opaque graph cursor is malformed, belongs to another run, or targets a stale generation.")
63
- @error
64
- model WorkflowCursorError extends ProblemDetails {
65
- @statusCode _: 409;
66
- title: "Invalid Workflow Cursor";
67
-
68
- @encodedName("application/json", "cursor_kind")
69
- cursorKind: WorkflowCursorKind;
70
-
71
- reason: WorkflowCursorFailureReason;
72
-
73
- @encodedName("application/json", "current_generation")
74
- currentGeneration?: WorkflowGeneration;
75
- }
76
-
77
- @doc("Workflow run was durably deleted and can no longer accept events or publish projections.")
78
- @error
79
- model WorkflowRunDeletedError extends ProblemDetails {
80
- @statusCode _: 410;
81
- title: "Workflow Run Deleted";
82
-
83
- @encodedName("application/json", "run_id")
84
- runId: WorkflowRunId;
85
- }
86
-
87
- @doc("Workflow projection is rebuilding or temporarily unavailable after a retryable storage failure.")
88
- @error
89
- model WorkflowProjectionUnavailableError extends ProblemDetails {
90
- @statusCode _: 503;
91
- title: "Workflow Projection Unavailable";
92
-
93
- @header("Retry-After")
94
- @encodedName("application/json", "retry_after")
95
- retryAfter: int32;
96
-
97
- @encodedName("application/json", "projection_status")
98
- projectionStatus: WorkflowProjectionStatus;
99
- }
100
-
101
- @doc("Workflow projection is non-retryably corrupt or incompatible. Internal storage details are intentionally omitted.")
102
- @error
103
- model WorkflowProjectionCorruptError extends ProblemDetails {
104
- @statusCode _: 500;
105
- title: "Workflow Projection Corrupt";
106
- @encodedName("application/json", "projection_status")
107
- projectionStatus: WorkflowProjectionStatus;
108
- }
109
-
110
- @route("/api/v1/workflow-runs")
111
- @tag("Workflow runs")
112
- @useAuth(Qyl.Api.Contracts.QylApiKeyHeaderAuth)
113
- interface WorkflowRunsApi {
114
- @post
115
- create(
116
- ...Qyl.Api.Contracts.ProjectScopeHeader,
117
- @body request: WorkflowRunCreateRequest,
118
- ):
119
- | WorkflowRun
120
- | ValidationError
121
- | UnauthorizedError
122
- | ConflictError
123
- | WorkflowRunDeletedError
124
- | ServiceUnavailableError
125
- | InternalServerError;
126
-
127
- @get
128
- list(
129
- ...Qyl.Api.Contracts.ProjectScopeHeader,
130
- @query status?: WorkflowRunStatus,
131
- @query
132
- @minValue(1)
133
- @maxValue(200)
134
- limit?: int32 = 50,
135
- @doc("Opaque continuation scoped to the project and status filter. Reuse it unchanged from next_cursor; do not parse, construct, or modify it.")
136
- @query cursor?: WorkflowRunCursor,
137
- ):
138
- | WorkflowRunPage
139
- | ValidationError
140
- | UnauthorizedError
141
- | ServiceUnavailableError
142
- | InternalServerError;
143
-
144
- @get
145
- @route("/{run_id}")
146
- get(
147
- ...Qyl.Api.Contracts.ProjectScopeHeader,
148
- @path("run_id") runId: WorkflowRunId,
149
- ):
150
- | WorkflowRun
151
- | UnauthorizedError
152
- | NotFoundError
153
- | WorkflowRunDeletedError
154
- | ServiceUnavailableError
155
- | InternalServerError;
156
-
157
- @post
158
- @route("/{run_id}/events")
159
- appendEvents(
160
- ...Qyl.Api.Contracts.ProjectScopeHeader,
161
- @path("run_id") runId: WorkflowRunId,
162
- @body request: WorkflowEventBatchAppendRequest,
163
- ):
164
- | WorkflowEventBatchAppendResponse
165
- | ValidationError
166
- | UnauthorizedError
167
- | NotFoundError
168
- | WorkflowRunDeletedError
169
- | ConflictError
170
- | ServiceUnavailableError
171
- | InternalServerError;
172
-
173
- @get
174
- @route("/{run_id}/events")
175
- readEvents(
176
- ...Qyl.Api.Contracts.ProjectScopeHeader,
177
- @path("run_id") runId: WorkflowRunId,
178
- @query("after_sequence") afterSequence?: WorkflowJournalPosition,
179
- @query
180
- @minValue(1)
181
- @maxValue(1000)
182
- limit?: int32 = 250,
183
- @query("wait_ms")
184
- @minValue(0)
185
- @maxValue(30000)
186
- waitMs?: int32 = 0,
187
- ):
188
- | WorkflowEventPage
189
- | ValidationError
190
- | UnauthorizedError
191
- | NotFoundError
192
- | WorkflowRunDeletedError
193
- | ServiceUnavailableError
194
- | InternalServerError;
195
-
196
- @get
197
- @route("/{run_id}/graph")
198
- getGraph(
199
- ...Qyl.Api.Contracts.ProjectScopeHeader,
200
- @path("run_id") runId: WorkflowRunId,
201
- @doc("Opaque node continuation. Reuse it unchanged from the preceding snapshot's next_node_cursor; do not parse, construct, or modify it.")
202
- @query("node_cursor") nodeCursor?: WorkflowNodeCursor,
203
- @query("node_limit")
204
- @minValue(1)
205
- @maxValue(1000)
206
- nodeLimit?: int32 = 250,
207
- @doc("Opaque edge continuation. Reuse it unchanged from the preceding snapshot's next_edge_cursor; do not parse, construct, or modify it.")
208
- @query("edge_cursor") edgeCursor?: WorkflowEdgeCursor,
209
- @query("edge_limit")
210
- @minValue(1)
211
- @maxValue(2000)
212
- edgeLimit?: int32 = 500,
213
- ):
214
- | WorkflowGraphSnapshot
215
- | ValidationError
216
- | UnauthorizedError
217
- | NotFoundError
218
- | WorkflowRunDeletedError
219
- | WorkflowCursorError
220
- | WorkflowProjectionUnavailableError
221
- | WorkflowProjectionCorruptError;
222
-
223
- @get
224
- @route("/{run_id}/content/{content_ref}")
225
- getContent(
226
- ...Qyl.Api.Contracts.ProjectScopeHeader,
227
- @path("run_id") runId: WorkflowRunId,
228
- @path("content_ref") contentRef: WorkflowContentRef,
229
- ):
230
- | WorkflowContent
231
- | UnauthorizedError
232
- | NotFoundError
233
- | WorkflowRunDeletedError
234
- | ServiceUnavailableError
235
- | InternalServerError;
236
-
237
- @get
238
- @route("/{run_id}/stream")
239
- stream(
240
- ...Qyl.Api.Contracts.ProjectScopeHeader,
241
- @path("run_id") runId: WorkflowRunId,
242
- @header("Last-Event-ID") lastEventId?: string,
243
- ):
244
- | SSEStream<WorkflowStreamEvents>
245
- | ValidationError
246
- | UnauthorizedError
247
- | NotFoundError
248
- | WorkflowRunDeletedError
249
- | ServiceUnavailableError
250
- | InternalServerError;
251
-
252
- @post
253
- @route("/{run_id}/commands")
254
- submitControl(
255
- ...Qyl.Api.Contracts.ProjectScopeHeader,
256
- @path("run_id") runId: WorkflowRunId,
257
- @body request: WorkflowControlRequest,
258
- ):
259
- | WorkflowControlCommand
260
- | ValidationError
261
- | UnauthorizedError
262
- | NotFoundError
263
- | WorkflowRunDeletedError
264
- | ConflictError
265
- | ServiceUnavailableError
266
- | InternalServerError;
267
-
268
- @get
269
- @route("/{run_id}/commands")
270
- pollControls(
271
- ...Qyl.Api.Contracts.ProjectScopeHeader,
272
- @path("run_id") runId: WorkflowRunId,
273
- @query("after_sequence") afterSequence?: WorkflowSequence,
274
- @query
275
- @minValue(1)
276
- @maxValue(100)
277
- limit?: int32 = 20,
278
- @query("wait_ms")
279
- @minValue(0)
280
- @maxValue(30000)
281
- waitMs?: int32 = 0,
282
- ):
283
- | WorkflowControlCommandPage
284
- | ValidationError
285
- | UnauthorizedError
286
- | NotFoundError
287
- | WorkflowRunDeletedError
288
- | ServiceUnavailableError
289
- | InternalServerError;
290
-
291
- @post
292
- @route("/{run_id}/commands/{command_id}/status")
293
- updateControl(
294
- ...Qyl.Api.Contracts.ProjectScopeHeader,
295
- @path("run_id") runId: WorkflowRunId,
296
- @path("command_id") commandId: WorkflowCommandId,
297
- @body request: WorkflowControlStatusUpdateRequest,
298
- ):
299
- | WorkflowControlCommand
300
- | ValidationError
301
- | UnauthorizedError
302
- | NotFoundError
303
- | WorkflowRunDeletedError
304
- | ConflictError
305
- | ServiceUnavailableError
306
- | InternalServerError;
307
- }
@@ -1,204 +0,0 @@
1
- import "./workflow.tsp";
2
-
3
- using Qyl.Api.Contracts.Workflow;
4
-
5
- namespace Qyl.Api.Contracts.Diagnostics;
6
-
7
- @doc("The versioned extension discriminator for a protected agent diagnostic snapshot.")
8
- enum AgentDiagnosticExtensionId {
9
- snapshot: "qyl.agent.diagnostic.snapshot",
10
- }
11
-
12
- @doc("Wire-format version of an agent diagnostic snapshot. Version 1 is the only accepted format.")
13
- @minValue(1)
14
- @maxValue(1)
15
- scalar AgentDiagnosticFormatVersion extends int32;
16
-
17
- @doc("Stable machine identifier of one diagnostic snapshot. This identifier is a value and must never be promoted to a telemetry key.")
18
- @pattern("^[A-Za-z0-9_][A-Za-z0-9._:/\\[\\]-]{0,127}$")
19
- @minLength(1)
20
- @maxLength(128)
21
- scalar AgentDiagnosticSnapshotId extends string;
22
-
23
- @doc("Stable machine identifier of the probe that captured a diagnostic snapshot. This identifier is a value and must never be promoted to a telemetry key.")
24
- @pattern("^[A-Za-z0-9_][A-Za-z0-9._:/\\[\\]-]{0,127}$")
25
- @minLength(1)
26
- @maxLength(128)
27
- scalar AgentDiagnosticProbeId extends string;
28
-
29
- @doc("Stable machine identifier of one diagnostic check. This identifier is a value and must never be promoted to a telemetry key.")
30
- @pattern("^[A-Za-z0-9_][A-Za-z0-9._:/\\[\\]-]{0,127}$")
31
- @minLength(1)
32
- @maxLength(128)
33
- scalar AgentDiagnosticCheckId extends string;
34
-
35
- @doc("Stable machine name of one dynamically captured variable. Names are data values, never telemetry attribute keys, event names, or span names.")
36
- @pattern("^[A-Za-z0-9_][A-Za-z0-9._:/\\[\\]-]{0,127}$")
37
- @minLength(1)
38
- @maxLength(128)
39
- scalar AgentDiagnosticVariableName extends string;
40
-
41
- @doc("Execution boundary at which the state frame was captured.")
42
- enum AgentDiagnosticPhase {
43
- input: "input",
44
- output: "output",
45
- error: "error",
46
- checkpoint: "checkpoint",
47
- }
48
-
49
- @doc("Machine-computed aggregate result of a diagnostic snapshot. unknown reports one or more unknown check outcomes. not_evaluated is reserved for a snapshot whose checks array is empty.")
50
- enum AgentDiagnosticOutcome {
51
- pass: "pass",
52
- fail: "fail",
53
- unknownResult: "unknown",
54
- notEvaluated: "not_evaluated",
55
- }
56
-
57
- @doc("Machine-computed result of one diagnostic check. For exists, an absent or null actual variable produces fail. For every other operator, missing required operands produce unknown; incompatible operand types also produce unknown. not_evaluated is deliberately not a check outcome.")
58
- enum AgentDiagnosticCheckOutcome {
59
- pass: "pass",
60
- fail: "fail",
61
- unknownResult: "unknown",
62
- }
63
-
64
- @doc("Declared JSON-level type of a diagnostic variable.")
65
- enum AgentDiagnosticValueType {
66
- null: "null",
67
- boolean: "boolean",
68
- integer: "integer",
69
- number: "number",
70
- string: "string",
71
- json: "json",
72
- }
73
-
74
- @doc("Data-handling classification assigned before a diagnostic variable is captured.")
75
- enum AgentDiagnosticClassification {
76
- public: "public",
77
- internal: "internal",
78
- sensitive: "sensitive",
79
- secret: "secret",
80
- }
81
-
82
- @doc("Closed operation evaluated by a diagnostic check. Checks are structural and never carry expression strings.")
83
- enum AgentDiagnosticOperator {
84
- equal: "equal",
85
- notEqual: "not_equal",
86
- exists: "exists",
87
- typeIs: "type_is",
88
- contains: "contains",
89
- lessThan: "less_than",
90
- greaterThan: "greater_than",
91
- }
92
-
93
- @doc("Common identity and policy fields for one dynamic diagnostic variable.")
94
- model AgentDiagnosticVariableBase {
95
- name: AgentDiagnosticVariableName;
96
- type: AgentDiagnosticValueType;
97
- classification: AgentDiagnosticClassification;
98
- }
99
-
100
- @doc("A variable whose typed JSON value is present in protected snapshot content. The value is required and must match type: null is JSON null; boolean is a JSON boolean; integer is a signed 64-bit JSON integer; number is a finite JSON number; string is a JSON string; json is a JSON object or array. The protected content boundary, not this model, controls access to all captured values.")
101
- model CapturedAgentDiagnosticVariable extends AgentDiagnosticVariableBase {
102
- capture: "value";
103
- value: unknown | null;
104
- }
105
-
106
- @doc("A variable observed by the probe whose value was replaced by policy. A value field is forbidden.")
107
- model RedactedAgentDiagnosticVariable extends AgentDiagnosticVariableBase {
108
- capture: "redacted";
109
- }
110
-
111
- @doc("A variable whose value was unavailable or deliberately not captured. A value field is forbidden.")
112
- model OmittedAgentDiagnosticVariable extends AgentDiagnosticVariableBase {
113
- capture: "omitted";
114
- }
115
-
116
- @doc("One dynamically named variable in a protected diagnostic snapshot. Capture is the discriminator and makes value presence unambiguous.")
117
- union AgentDiagnosticVariable {
118
- value: CapturedAgentDiagnosticVariable,
119
- redacted: RedactedAgentDiagnosticVariable,
120
- omitted: OmittedAgentDiagnosticVariable,
121
- }
122
-
123
- @doc("One structural, machine-computed check result. actual and expected reference variable names only. For equal, not_equal, contains, less_than, and greater_than, expected is required and expected_type is omitted. For exists, both are omitted and an absent or null actual variable produces fail. For type_is, expected is omitted and expected_type is required. For operators other than exists, missing required operands produce unknown; incompatible operand types also produce unknown. not_evaluated is reserved for the snapshot aggregate when checks is empty and is not emitted for an individual check.")
124
- model AgentDiagnosticCheckResult {
125
- @encodedName("application/json", "check_id")
126
- checkId: AgentDiagnosticCheckId;
127
-
128
- operator: AgentDiagnosticOperator;
129
- actual: AgentDiagnosticVariableName;
130
- expected?: AgentDiagnosticVariableName;
131
-
132
- @encodedName("application/json", "expected_type")
133
- expectedType?: AgentDiagnosticValueType;
134
-
135
- outcome: AgentDiagnosticCheckOutcome;
136
- }
137
-
138
- @doc("Version 1 protected JSON state frame captured for an artificial-intelligence agent. extension_id and format_version are its schema identity. capture_nonce is fresh entropy and is not a stable identifier. Variables and checks are bounded, dynamic names remain values, and no human-oriented message or expression text is part of the contract. Overall outcome is not_evaluated only when checks is empty. For a non-empty checks array it is fail if any check fails, otherwise unknown if any check is unknown, otherwise pass.")
139
- model AgentDiagnosticSnapshot {
140
- @encodedName("application/json", "extension_id")
141
- extensionId: AgentDiagnosticExtensionId;
142
-
143
- @encodedName("application/json", "format_version")
144
- formatVersion: AgentDiagnosticFormatVersion;
145
-
146
- @encodedName("application/json", "snapshot_id")
147
- snapshotId: AgentDiagnosticSnapshotId;
148
-
149
- @doc("Fresh 128-bit random nonce encoded as exactly 32 lowercase hexadecimal characters. It prevents equality inference across otherwise identical protected captures and must not be used as an identity key.")
150
- @encodedName("application/json", "capture_nonce")
151
- @pattern("^[0-9a-f]{32}$")
152
- @minLength(32)
153
- @maxLength(32)
154
- captureNonce: string;
155
-
156
- @encodedName("application/json", "probe_id")
157
- probeId: AgentDiagnosticProbeId;
158
-
159
- phase: AgentDiagnosticPhase;
160
-
161
- @maxItems(64)
162
- variables: AgentDiagnosticVariable[];
163
-
164
- @maxItems(64)
165
- checks: AgentDiagnosticCheckResult[];
166
-
167
- outcome: AgentDiagnosticOutcome;
168
- }
169
-
170
- @doc("Value-free event-data projection for a protected agent diagnostic snapshot. Encode this shape in WorkflowEventAppend.data on the existing content_captured event kind. content_ref must also occur in that event's content_refs and identifies UTF-8 JSON conforming to AgentDiagnosticSnapshot. Counts are computed from the referenced snapshot; failed_check_count counts checks whose outcome is fail. No variable names, values, human messages, expressions, nonce, or classifications may appear in this summary.")
171
- model AgentDiagnosticSnapshotSummary {
172
- @encodedName("application/json", "extension_id")
173
- extensionId: AgentDiagnosticExtensionId;
174
-
175
- @encodedName("application/json", "format_version")
176
- formatVersion: AgentDiagnosticFormatVersion;
177
-
178
- @encodedName("application/json", "snapshot_id")
179
- snapshotId: AgentDiagnosticSnapshotId;
180
-
181
- @encodedName("application/json", "probe_id")
182
- probeId: AgentDiagnosticProbeId;
183
-
184
- phase: AgentDiagnosticPhase;
185
- outcome: AgentDiagnosticOutcome;
186
-
187
- @encodedName("application/json", "variable_count")
188
- @minValue(0)
189
- @maxValue(64)
190
- variableCount: int32;
191
-
192
- @encodedName("application/json", "check_count")
193
- @minValue(0)
194
- @maxValue(64)
195
- checkCount: int32;
196
-
197
- @encodedName("application/json", "failed_check_count")
198
- @minValue(0)
199
- @maxValue(64)
200
- failedCheckCount: int32;
201
-
202
- @encodedName("application/json", "content_ref")
203
- contentRef: WorkflowContentRef;
204
- }