@ancplua/qyl-api-schema 8.0.0 → 10.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.
@@ -1,629 +0,0 @@
1
- import "../common/types.tsp";
2
-
3
- using Qyl.Api.Contracts.Common;
4
-
5
- namespace Qyl.Api.Contracts.Workflow;
6
-
7
- @doc("Stable identifier of one observed Codex workflow run.")
8
- @minLength(1)
9
- @maxLength(128)
10
- scalar WorkflowRunId extends string;
11
-
12
- @doc("Opaque incarnation identifier for one workflow run's projected state.")
13
- @pattern("^[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15}$")
14
- @minLength(32)
15
- @maxLength(32)
16
- scalar WorkflowGeneration extends string;
17
-
18
- @doc("Opaque workflow-run list continuation scoped to the project and status filter. Reuse it unchanged; clients must not parse or construct it.")
19
- @minLength(1)
20
- @maxLength(512)
21
- scalar WorkflowRunCursor extends string;
22
-
23
- @doc("Stable identifier of one workflow attempt.")
24
- @minLength(1)
25
- @maxLength(128)
26
- scalar WorkflowAttemptId extends string;
27
-
28
- @doc("Stable identifier of one agent within a workflow run.")
29
- @minLength(1)
30
- @maxLength(128)
31
- scalar WorkflowAgentId extends string;
32
-
33
- @doc("Stable identifier of one tool call within a workflow run.")
34
- @minLength(1)
35
- @maxLength(128)
36
- scalar WorkflowToolCallId extends string;
37
-
38
- @doc("Stable identifier of one immutable journal event.")
39
- @minLength(1)
40
- @maxLength(160)
41
- scalar WorkflowEventId extends string;
42
-
43
- @doc("Stable identifier of one run-level control command.")
44
- @minLength(1)
45
- @maxLength(128)
46
- scalar WorkflowCommandId extends string;
47
-
48
- @doc("Stable identifier of one graph node. Canonical tuples structurally distinguish run scope from attempt scope, escape colon as \\c and backslash as \\\\, and never infer scope from a literal component value. A canonical identifier over 192 Unicode scalar values is replaced by its kind, a tilde, and the full lowercase 64-hex SHA-256 of the length-prefixed canonical tuple.")
49
- @minLength(1)
50
- @maxLength(192)
51
- scalar WorkflowNodeId extends string;
52
-
53
- @doc("Stable identifier of one graph edge. Endpoint tuples preserve the nodes' structural run-versus-attempt scope and ordinal component boundaries, escape colon as \\c and backslash as \\\\, and never infer scope from a literal component value. A canonical identifier over 192 Unicode scalar values is replaced by its edge kind, a tilde, and the full lowercase 64-hex SHA-256 of the length-prefixed canonical tuple.")
54
- @minLength(1)
55
- @maxLength(192)
56
- scalar WorkflowEdgeId extends string;
57
-
58
- @doc("Opaque node-page continuation scoped to one workflow run and generation. Reuse it unchanged; clients must not parse or construct it.")
59
- @minLength(1)
60
- @maxLength(1536)
61
- scalar WorkflowNodeCursor extends string;
62
-
63
- @doc("Opaque edge-page continuation scoped to one workflow run and generation. Reuse it unchanged; clients must not parse or construct it.")
64
- @minLength(1)
65
- @maxLength(1536)
66
- scalar WorkflowEdgeCursor extends string;
67
-
68
- @doc("Content-addressed reference to a captured workflow payload.")
69
- @pattern("^sha256:[a-f0-9]{64}$")
70
- @minLength(71)
71
- @maxLength(71)
72
- scalar WorkflowContentRef extends string;
73
-
74
- @doc("Unsigned source or collector journal sequence encoded without JavaScript precision loss.")
75
- @minValue(0)
76
- @encode(string)
77
- scalar WorkflowSequence extends uint64;
78
-
79
- @doc("Collector-assigned position in the authoritative workflow journal, encoded without JavaScript precision loss.")
80
- @minValue(0)
81
- @encode(string)
82
- scalar WorkflowJournalPosition extends uint64;
83
-
84
- @doc("Current lifecycle of a workflow run.")
85
- enum WorkflowRunStatus {
86
- active: "active",
87
- completed: "completed",
88
- failed: "failed",
89
- interrupted: "interrupted",
90
- }
91
-
92
- @doc("Current lifecycle of one workflow attempt.")
93
- enum WorkflowAttemptStatus {
94
- pending: "pending",
95
- running: "running",
96
- succeeded: "succeeded",
97
- failed: "failed",
98
- interrupted: "interrupted",
99
- }
100
-
101
- @doc("Current lifecycle of an observed workflow agent.")
102
- enum WorkflowAgentStatus {
103
- pending: "pending",
104
- running: "running",
105
- waiting: "waiting",
106
- succeeded: "succeeded",
107
- failed: "failed",
108
- interrupted: "interrupted",
109
- }
110
-
111
- @doc("Current lifecycle of an observed tool call.")
112
- enum WorkflowToolCallStatus {
113
- requested: "requested",
114
- running: "running",
115
- succeeded: "succeeded",
116
- failed: "failed",
117
- rejected: "rejected",
118
- }
119
-
120
- @doc("Kinds of execution node in the deterministic workflow graph.")
121
- enum WorkflowNodeKind {
122
- run: "run",
123
- attempt: "attempt",
124
- turn: "turn",
125
- agent: "agent",
126
- toolCall: "tool_call",
127
- message: "message",
128
- wait: "wait",
129
- gate: "gate",
130
- resource: "resource",
131
- }
132
-
133
- @doc("Semantic relationship represented by a workflow graph edge.")
134
- enum WorkflowEdgeKind {
135
- data: "data",
136
- control: "control",
137
- conflict: "conflict",
138
- resource: "resource",
139
- gate: "gate",
140
- temporal: "temporal",
141
- }
142
-
143
- @doc("Immutable journal event kinds accepted from a Codex observer.")
144
- enum WorkflowJournalEventKind {
145
- runCreated: "run_created",
146
- runCompleted: "run_completed",
147
- threadStarted: "thread_started",
148
- threadResumed: "thread_resumed",
149
- turnStarted: "turn_started",
150
- turnCompleted: "turn_completed",
151
- turnInterrupted: "turn_interrupted",
152
- attemptStarted: "attempt_started",
153
- attemptCompleted: "attempt_completed",
154
- agentSpawned: "agent_spawned",
155
- agentStarted: "agent_started",
156
- agentCompleted: "agent_completed",
157
- messageSent: "message_sent",
158
- messageReceived: "message_received",
159
- waitStarted: "wait_started",
160
- waitCompleted: "wait_completed",
161
- joined: "joined",
162
- itemStarted: "item_started",
163
- itemCompleted: "item_completed",
164
- toolStarted: "tool_started",
165
- toolCompleted: "tool_completed",
166
- approvalRequested: "approval_requested",
167
- approvalResolved: "approval_resolved",
168
- contentCaptured: "content_captured",
169
- fileWritten: "file_written",
170
- controlRequested: "control_requested",
171
- controlAccepted: "control_accepted",
172
- controlApplied: "control_applied",
173
- controlRejected: "control_rejected",
174
- controlFailed: "control_failed",
175
- }
176
-
177
- @doc("Control operation supported by the Codex app-server boundary.")
178
- enum WorkflowControlAction {
179
- steer: "steer",
180
- interrupt: "interrupt",
181
- resume: "resume",
182
- }
183
-
184
- @doc("Durable lifecycle of a workflow control command.")
185
- enum WorkflowControlStatus {
186
- requested: "requested",
187
- accepted: "accepted",
188
- applied: "applied",
189
- rejected: "rejected",
190
- failed: "failed",
191
- }
192
-
193
- @doc("Encoding used when lazily returning captured workflow content.")
194
- enum WorkflowContentEncoding {
195
- utf8: "utf8",
196
- base64: "base64",
197
- }
198
-
199
- @doc("A valid committed projection that can be served to readers.")
200
- model CommittedWorkflowProjectionStatus {
201
- state: "committed";
202
- generation: WorkflowGeneration;
203
-
204
- @encodedName("application/json", "journal_position")
205
- journalPosition: WorkflowJournalPosition;
206
- }
207
-
208
- @doc("The requested generation is being reconstructed from its authoritative journal.")
209
- model RebuildingWorkflowProjectionStatus {
210
- state: "rebuilding";
211
- generation: WorkflowGeneration;
212
-
213
- @encodedName("application/json", "target_journal_position")
214
- targetJournalPosition: WorkflowJournalPosition;
215
-
216
- @encodedName("application/json", "retry_after_ms")
217
- @minValue(1)
218
- retryAfterMs: int32;
219
- }
220
-
221
- @doc("Projection work is temporarily unavailable after a retryable storage failure.")
222
- model UnavailableWorkflowProjectionStatus {
223
- state: "unavailable";
224
- generation?: WorkflowGeneration;
225
-
226
- @encodedName("application/json", "retry_after_ms")
227
- @minValue(1)
228
- retryAfterMs: int32;
229
- }
230
-
231
- @doc("Derived projection state is corrupt or incompatible and cannot currently be served.")
232
- model CorruptWorkflowProjectionStatus {
233
- state: "corrupt";
234
- generation?: WorkflowGeneration;
235
- reason: "corrupt_derived_state" | "incompatible_derived_state";
236
- }
237
-
238
- @doc("Closed public availability state for one workflow projection. Storage paths, hashes, fingerprints, and database errors remain private.")
239
- union WorkflowProjectionStatus {
240
- committed: CommittedWorkflowProjectionStatus,
241
- rebuilding: RebuildingWorkflowProjectionStatus,
242
- unavailable: UnavailableWorkflowProjectionStatus,
243
- corrupt: CorruptWorkflowProjectionStatus,
244
- }
245
-
246
- @doc("One immutable workflow run.")
247
- model WorkflowRun {
248
- @encodedName("application/json", "run_id")
249
- runId: WorkflowRunId;
250
-
251
- generation: WorkflowGeneration;
252
-
253
- @encodedName("application/json", "thread_id")
254
- threadId?: string;
255
-
256
- title?: string;
257
- status: WorkflowRunStatus;
258
-
259
- @encodedName("application/json", "started_at")
260
- startedAt: utcDateTime;
261
-
262
- @encodedName("application/json", "ended_at")
263
- endedAt?: utcDateTime;
264
-
265
- @encodedName("application/json", "latest_journal_sequence")
266
- latestJournalSequence: WorkflowJournalPosition;
267
-
268
- @encodedName("application/json", "active_attempt_id")
269
- activeAttemptId?: WorkflowAttemptId;
270
-
271
- metadata?: Record<unknown>;
272
- }
273
-
274
- @doc("Request to create an observed workflow run before appending journal events.")
275
- model WorkflowRunCreateRequest {
276
- @encodedName("application/json", "run_id")
277
- runId: WorkflowRunId;
278
-
279
- @encodedName("application/json", "thread_id")
280
- threadId?: string;
281
-
282
- title?: string;
283
-
284
- @encodedName("application/json", "started_at")
285
- startedAt: utcDateTime;
286
-
287
- metadata?: Record<unknown>;
288
- }
289
-
290
- @doc("Cursor page of workflow runs.")
291
- model WorkflowRunPage {
292
- items: WorkflowRun[];
293
-
294
- @encodedName("application/json", "next_cursor")
295
- nextCursor?: WorkflowRunCursor;
296
-
297
- @encodedName("application/json", "has_more")
298
- hasMore: boolean;
299
- }
300
-
301
- @doc("One captured payload supplied with an append batch.")
302
- model WorkflowContentChunk {
303
- @encodedName("application/json", "content_ref")
304
- contentRef: WorkflowContentRef;
305
-
306
- @encodedName("application/json", "content_type")
307
- contentType: ContentType;
308
-
309
- encoding: WorkflowContentEncoding;
310
-
311
- @doc("UTF-8 text or base64 bytes, according to encoding.")
312
- @maxLength(1398104)
313
- content: string;
314
- }
315
-
316
- @doc("One source-ordered immutable journal event awaiting collector sequence assignment.")
317
- model WorkflowEventAppend {
318
- @encodedName("application/json", "event_id")
319
- eventId: WorkflowEventId;
320
-
321
- @encodedName("application/json", "source_sequence")
322
- sourceSequence: WorkflowSequence;
323
-
324
- timestamp: utcDateTime;
325
- kind: WorkflowJournalEventKind;
326
-
327
- @encodedName("application/json", "thread_id")
328
- threadId?: string;
329
-
330
- @encodedName("application/json", "turn_id")
331
- turnId?: string;
332
-
333
- @encodedName("application/json", "attempt_id")
334
- attemptId?: WorkflowAttemptId;
335
-
336
- @encodedName("application/json", "agent_id")
337
- agentId?: WorkflowAgentId;
338
-
339
- @encodedName("application/json", "parent_agent_id")
340
- parentAgentId?: WorkflowAgentId;
341
-
342
- @encodedName("application/json", "receiver_agent_id")
343
- receiverAgentId?: WorkflowAgentId;
344
-
345
- @encodedName("application/json", "tool_call_id")
346
- toolCallId?: WorkflowToolCallId;
347
-
348
- @encodedName("application/json", "content_refs")
349
- @maxItems(64)
350
- contentRefs?: WorkflowContentRef[];
351
-
352
- data?: Record<unknown>;
353
- }
354
-
355
- @doc("Idempotent append batch from one observer client.")
356
- model WorkflowEventBatchAppendRequest {
357
- @encodedName("application/json", "client_id")
358
- @minLength(1)
359
- @maxLength(128)
360
- clientId: string;
361
-
362
- @minItems(1)
363
- @maxItems(500)
364
- events: WorkflowEventAppend[];
365
-
366
- @maxItems(500)
367
- content?: WorkflowContentChunk[];
368
- }
369
-
370
- @doc("Collector acknowledgement for an idempotent workflow-event append.")
371
- model WorkflowEventBatchAppendResponse {
372
- @encodedName("application/json", "accepted_count")
373
- @minValue(0)
374
- acceptedCount: int32;
375
-
376
- @encodedName("application/json", "duplicate_count")
377
- @minValue(0)
378
- duplicateCount: int32;
379
-
380
- @encodedName("application/json", "acknowledged_source_sequence")
381
- acknowledgedSourceSequence: WorkflowSequence;
382
-
383
- @encodedName("application/json", "first_journal_sequence")
384
- firstJournalSequence?: WorkflowJournalPosition;
385
-
386
- @encodedName("application/json", "last_journal_sequence")
387
- lastJournalSequence?: WorkflowJournalPosition;
388
- }
389
-
390
- @doc("One immutable event after collector journal sequence assignment.")
391
- model WorkflowJournalEvent extends WorkflowEventAppend {
392
- @encodedName("application/json", "run_id")
393
- runId: WorkflowRunId;
394
-
395
- @encodedName("application/json", "client_id")
396
- clientId: string;
397
-
398
- @encodedName("application/json", "journal_sequence")
399
- journalSequence: WorkflowJournalPosition;
400
- }
401
-
402
- @doc("A bounded page of workflow journal events.")
403
- model WorkflowEventPage {
404
- events: WorkflowJournalEvent[];
405
-
406
- @encodedName("application/json", "next_sequence")
407
- nextSequence: WorkflowJournalPosition;
408
-
409
- @encodedName("application/json", "high_water_mark")
410
- highWaterMark: WorkflowJournalPosition;
411
-
412
- @encodedName("application/json", "cursor_gap")
413
- cursorGap: boolean;
414
- }
415
-
416
- @doc("Recorded edge provenance directly observed from Codex.")
417
- model RecordedWorkflowEdgeProvenance {
418
- type: "recorded";
419
-
420
- @encodedName("application/json", "event_ids")
421
- @minItems(1)
422
- eventIds: WorkflowEventId[];
423
- }
424
-
425
- @doc("Derived edge provenance with explicit evidence and confidence.")
426
- model DerivedWorkflowEdgeProvenance {
427
- type: "derived";
428
-
429
- @encodedName("application/json", "event_ids")
430
- @minItems(1)
431
- eventIds: WorkflowEventId[];
432
-
433
- evidence: string;
434
- confidence: Ratio;
435
- }
436
-
437
- @doc("Provenance for one workflow graph edge.")
438
- union WorkflowEdgeProvenance {
439
- recorded: RecordedWorkflowEdgeProvenance,
440
- derived: DerivedWorkflowEdgeProvenance,
441
- }
442
-
443
- @doc("One node in the deterministic workflow graph projection.")
444
- model WorkflowGraphNode {
445
- @encodedName("application/json", "node_id")
446
- nodeId: WorkflowNodeId;
447
-
448
- kind: WorkflowNodeKind;
449
- label: string;
450
- status: string;
451
-
452
- @encodedName("application/json", "attempt_id")
453
- attemptId?: WorkflowAttemptId;
454
-
455
- @encodedName("application/json", "agent_id")
456
- agentId?: WorkflowAgentId;
457
-
458
- @encodedName("application/json", "started_at")
459
- startedAt?: utcDateTime;
460
-
461
- @encodedName("application/json", "ended_at")
462
- endedAt?: utcDateTime;
463
-
464
- @encodedName("application/json", "duration_ms")
465
- durationMs?: DurationMs;
466
-
467
- @encodedName("application/json", "content_refs")
468
- contentRefs?: WorkflowContentRef[];
469
-
470
- attributes?: Record<unknown>;
471
- }
472
-
473
- @doc("One typed edge in the deterministic workflow graph projection. Data, Control, and Gate edges are causal dependencies. Temporal edges describe observed order, Resource edges describe resource use, and Conflict edges describe contention; Temporal, Resource, and Conflict edges are excluded from critical-path causality.")
474
- model WorkflowGraphEdge {
475
- @encodedName("application/json", "edge_id")
476
- edgeId: WorkflowEdgeId;
477
-
478
- @encodedName("application/json", "source_node_id")
479
- sourceNodeId: WorkflowNodeId;
480
-
481
- @encodedName("application/json", "target_node_id")
482
- targetNodeId: WorkflowNodeId;
483
-
484
- kind: WorkflowEdgeKind;
485
- provenance: WorkflowEdgeProvenance;
486
- }
487
-
488
- @doc("Work and critical-path statistics for a workflow graph. Every ToolCall, Wait, Gate, and duration-bearing Message or Item contributes an independently weighted interval even when it has no Agent owner. An Agent contributes its own-work fragments: its interval minus the union of precisely owned child intervals clipped to the Agent interval. Precisely owned children are Control-linked Agent and ToolCall nodes, Temporal-linked Wait nodes, Gate-linked Gate nodes, and Data-linked duration-bearing Message or Item nodes. Peak concurrency sweeps every positive independently weighted or Agent own-work fragment. Critical-path analysis uses only Data, Control, and Gate edges, condenses each causal strongly connected component, charges every component member exactly once, and expands selected component members in ordinal node-id order.")
489
- model WorkflowGraphStatistics {
490
- @encodedName("application/json", "t1_ms")
491
- t1Ms: DurationMs;
492
-
493
- @encodedName("application/json", "t_infinity_ms")
494
- tInfinityMs: DurationMs;
495
-
496
- @encodedName("application/json", "wall_time_ms")
497
- wallTimeMs: DurationMs;
498
-
499
- @encodedName("application/json", "peak_concurrency")
500
- @minValue(0)
501
- peakConcurrency: int32;
502
-
503
- @encodedName("application/json", "worker_count")
504
- @minValue(1)
505
- workerCount: int32;
506
-
507
- @encodedName("application/json", "parallel_lower_bound_ms")
508
- parallelLowerBoundMs: DurationMs;
509
-
510
- @encodedName("application/json", "critical_path_node_ids")
511
- criticalPathNodeIds: WorkflowNodeId[];
512
- }
513
-
514
- @doc("Deterministic graph projection at one journal cursor.")
515
- model WorkflowGraphSnapshot {
516
- run: WorkflowRun;
517
-
518
- @encodedName("application/json", "projection_status")
519
- projectionStatus: WorkflowProjectionStatus;
520
- nodes: WorkflowGraphNode[];
521
- edges: WorkflowGraphEdge[];
522
- statistics: WorkflowGraphStatistics;
523
-
524
- @encodedName("application/json", "journal_sequence")
525
- journalSequence: WorkflowJournalPosition;
526
-
527
- @encodedName("application/json", "next_node_cursor")
528
- @doc("Opaque node continuation for the next page. Reuse it unchanged as node_cursor on the next graph request; do not parse, construct, or modify it.")
529
- nextNodeCursor?: WorkflowNodeCursor;
530
-
531
- @encodedName("application/json", "next_edge_cursor")
532
- @doc("Opaque edge continuation for the next page. Reuse it unchanged as edge_cursor on the next graph request; do not parse, construct, or modify it.")
533
- nextEdgeCursor?: WorkflowEdgeCursor;
534
-
535
- @encodedName("application/json", "has_more_nodes")
536
- hasMoreNodes: boolean;
537
-
538
- @encodedName("application/json", "has_more_edges")
539
- hasMoreEdges: boolean;
540
-
541
- @encodedName("application/json", "total_node_count")
542
- @minValue(0)
543
- totalNodeCount: int32;
544
-
545
- @encodedName("application/json", "total_edge_count")
546
- @minValue(0)
547
- totalEdgeCount: int32;
548
- }
549
-
550
- @doc("Lazily retrieved captured workflow content.")
551
- model WorkflowContent {
552
- @encodedName("application/json", "content_ref")
553
- contentRef: WorkflowContentRef;
554
-
555
- @encodedName("application/json", "content_type")
556
- contentType: ContentType;
557
-
558
- encoding: WorkflowContentEncoding;
559
- content: string;
560
-
561
- @encodedName("application/json", "size_bytes")
562
- sizeBytes: ByteSize;
563
- }
564
-
565
- @doc("Request to enqueue one idempotent run-level control command.")
566
- model WorkflowControlRequest {
567
- action: WorkflowControlAction;
568
-
569
- @encodedName("application/json", "idempotency_key")
570
- @minLength(1)
571
- @maxLength(160)
572
- idempotencyKey: string;
573
-
574
- @doc("Text appended by steer or resume. Omit for interrupt.")
575
- @maxLength(32768)
576
- input?: string;
577
- }
578
-
579
- @doc("Durable run-level control command.")
580
- model WorkflowControlCommand {
581
- @encodedName("application/json", "command_id")
582
- commandId: WorkflowCommandId;
583
-
584
- @encodedName("application/json", "run_id")
585
- runId: WorkflowRunId;
586
-
587
- action: WorkflowControlAction;
588
- status: WorkflowControlStatus;
589
-
590
- @encodedName("application/json", "idempotency_key")
591
- idempotencyKey: string;
592
-
593
- input?: string;
594
-
595
- @encodedName("application/json", "requested_at")
596
- requestedAt: utcDateTime;
597
-
598
- @encodedName("application/json", "updated_at")
599
- updatedAt: utcDateTime;
600
-
601
- @encodedName("application/json", "command_sequence")
602
- commandSequence: WorkflowSequence;
603
-
604
- error?: string;
605
- }
606
-
607
- @doc("Page of control commands polled by the launcher-owned outbound adapter.")
608
- model WorkflowControlCommandPage {
609
- commands: WorkflowControlCommand[];
610
-
611
- @encodedName("application/json", "next_sequence")
612
- nextSequence: WorkflowSequence;
613
- }
614
-
615
- @doc("Adapter acknowledgement or terminal result for one control command.")
616
- model WorkflowControlStatusUpdateRequest {
617
- status: WorkflowControlStatus;
618
- error?: string;
619
-
620
- @doc("""
621
- When the reported transition actually occurred at the adapter that executed
622
- it. The journal event minted for this transition carries this clock — the
623
- originating agent's — so control events order and measure consistently with
624
- the agent-clocked events around them; omitted, the collector's receipt time
625
- is the fallback.
626
- """)
627
- @encodedName("application/json", "occurred_at")
628
- occurredAt?: utcDateTime;
629
- }