@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
@@ -0,0 +1,154 @@
1
+ // =============================================================================
2
+ // ANcpLua v2.0 - Agent Run Contract Model (OTel v1.40)
3
+ // =============================================================================
4
+ // Agent run records extracted from OTLP spans.
5
+ // Maps OTel GenAI semantic convention attributes to qyl API contract fields.
6
+ //
7
+ // OTel semconv mapping:
8
+ // gen_ai.agent.name → agent_name
9
+ // gen_ai.agent.id → agent_id
10
+ // gen_ai.agent.description → agent_description
11
+ // gen_ai.operation.name → operation_name
12
+ // gen_ai.request.model → gen_ai_request_model
13
+ // gen_ai.provider.name → gen_ai_provider_name
14
+ // gen_ai.usage.input_tokens → gen_ai_input_tokens
15
+ // gen_ai.usage.output_tokens → gen_ai_output_tokens
16
+ // =============================================================================
17
+
18
+ import "@typespec/openapi";
19
+ import "../../common/types.tsp";
20
+ import "../../otel/enums.tsp";
21
+
22
+ using TypeSpec.OpenAPI;
23
+ using Qyl.Api.Contracts.Common;
24
+ using Qyl.Api.Contracts.OTel.Enums;
25
+
26
+ namespace Qyl.Api.Contracts.Domains.Agent.Run;
27
+
28
+ // =============================================================================
29
+ // Agent Run Status
30
+ // =============================================================================
31
+
32
+ @doc("Agent run execution status")
33
+ enum AgentRunStatus {
34
+ @doc("Agent is currently executing")
35
+ running: "running",
36
+
37
+ @doc("Agent completed successfully")
38
+ completed: "completed",
39
+
40
+ @doc("Agent execution failed")
41
+ failed: "failed",
42
+
43
+ @doc("Agent execution was cancelled")
44
+ cancelled: "cancelled",
45
+ }
46
+
47
+ // =============================================================================
48
+ // Agent Run Entity
49
+ // =============================================================================
50
+
51
+ @doc("Agent run entity materialized from OTLP spans with gen_ai.agent.* attributes")
52
+ @TypeSpec.OpenAPI.extension("x-csharp-type", "AgentRunEntity")
53
+ model AgentRunEntity {
54
+ // === Identifiers ===
55
+
56
+ @doc("Unique agent run identifier")
57
+ @key
58
+ runId: string;
59
+
60
+ @doc("Parent OTel trace identifier")
61
+ traceId: TraceId;
62
+
63
+ @doc("Root span ID of the agent invocation")
64
+ spanId?: SpanId;
65
+
66
+ @doc("Parent run ID for nested agent invocations")
67
+ parentRunId?: string;
68
+
69
+ @doc("Session identifier for grouping related runs")
70
+ sessionId?: SessionId;
71
+
72
+ // === Agent Identity (OTel gen_ai.agent.*) ===
73
+
74
+ @doc("Agent name - OTel: gen_ai.agent.name")
75
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
76
+ agentName: string;
77
+
78
+ @doc("Agent identifier - OTel: gen_ai.agent.id")
79
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
80
+ agentId?: string;
81
+
82
+ @doc("Agent description - OTel: gen_ai.agent.description")
83
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
84
+ agentDescription?: string;
85
+
86
+ // === GenAI Attributes (OTel gen_ai.*) ===
87
+
88
+ @doc("Operation name - OTel: gen_ai.operation.name")
89
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
90
+ operationName?: string;
91
+
92
+ @doc("LLM model used - OTel: gen_ai.request.model")
93
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
94
+ genAiRequestModel?: string;
95
+
96
+ @doc("Provider name - OTel: gen_ai.provider.name")
97
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
98
+ genAiProviderName?: string;
99
+
100
+ // === Execution State ===
101
+
102
+ @doc("Execution status")
103
+ status: AgentRunStatus;
104
+
105
+ // === Token Usage (OTel gen_ai.usage.*) ===
106
+
107
+ @doc("Input/prompt tokens - OTel: gen_ai.usage.input_tokens")
108
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
109
+ genAiInputTokens?: TokenCount;
110
+
111
+ @doc("Output/completion tokens - OTel: gen_ai.usage.output_tokens")
112
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
113
+ genAiOutputTokens?: TokenCount;
114
+
115
+ @doc("Estimated cost in USD")
116
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
117
+ genAiCostUsd?: CostUsd;
118
+
119
+ @doc("Number of tool calls made")
120
+ toolCallCount?: int32;
121
+
122
+ // === Timing ===
123
+
124
+ @doc("Start timestamp in nanoseconds since epoch")
125
+ startTimeUnixNano: UnixNanos;
126
+
127
+ @doc("End timestamp in nanoseconds since epoch")
128
+ endTimeUnixNano?: UnixNanos;
129
+
130
+ @doc("Duration in nanoseconds")
131
+ durationNs?: DurationNs;
132
+
133
+ // === Service Info ===
134
+
135
+ @doc("Service name from resource attributes")
136
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
137
+ serviceName?: string;
138
+
139
+ // === Error ===
140
+
141
+ @doc("Error message if failed")
142
+ errorMessage?: string;
143
+
144
+ // === Attributes (JSON Blobs) ===
145
+
146
+ @doc("Additional attributes as JSON")
147
+ attributesJson?: string;
148
+
149
+ // === Internal ===
150
+
151
+ @doc("Row creation timestamp")
152
+ @TypeSpec.OpenAPI.extension("x-internal", true)
153
+ createdAt?: utcDateTime;
154
+ }
@@ -0,0 +1,122 @@
1
+ // =============================================================================
2
+ // ANcpLua v2.0 - Tool Call Contract Model (OTel v1.40)
3
+ // =============================================================================
4
+ // Tool call records extracted from OTLP spans.
5
+ // Maps OTel GenAI tool semantic convention attributes to qyl API contract fields.
6
+ //
7
+ // OTel semconv mapping:
8
+ // gen_ai.tool.name → tool_name
9
+ // gen_ai.tool.type → tool_type
10
+ // gen_ai.tool.call.id → call_id
11
+ // gen_ai.tool.call.arguments → arguments_json
12
+ // gen_ai.tool.call.result → result_json
13
+ // gen_ai.tool.description → tool_description
14
+ // gen_ai.operation.name → operation_name (= "execute_tool")
15
+ // =============================================================================
16
+
17
+ import "@typespec/openapi";
18
+ import "../../common/types.tsp";
19
+ import "../../otel/enums.tsp";
20
+
21
+ using TypeSpec.OpenAPI;
22
+ using Qyl.Api.Contracts.Common;
23
+ using Qyl.Api.Contracts.OTel.Enums;
24
+
25
+ namespace Qyl.Api.Contracts.Domains.Agent.ToolCall;
26
+
27
+ // =============================================================================
28
+ // Tool Call Status
29
+ // =============================================================================
30
+
31
+ @doc("Tool call execution status")
32
+ enum ToolCallStatus {
33
+ @doc("Tool is currently executing")
34
+ running: "running",
35
+
36
+ @doc("Tool completed successfully")
37
+ completed: "completed",
38
+
39
+ @doc("Tool execution failed")
40
+ failed: "failed",
41
+ }
42
+
43
+ // =============================================================================
44
+ // Tool Call Entity
45
+ // =============================================================================
46
+
47
+ @doc("Tool call entity materialized from OTLP spans with gen_ai.tool.* attributes")
48
+ @TypeSpec.OpenAPI.extension("x-csharp-type", "ToolCallEntity")
49
+ model ToolCallEntity {
50
+ // === Identifiers ===
51
+
52
+ @doc("Unique tool call identifier - OTel: gen_ai.tool.call.id")
53
+ @key
54
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
55
+ callId: string;
56
+
57
+ @doc("Parent agent run identifier")
58
+ runId: string;
59
+
60
+ @doc("Parent OTel trace identifier")
61
+ traceId: TraceId;
62
+
63
+ @doc("Associated OTel span identifier")
64
+ spanId: SpanId;
65
+
66
+ // === Tool Identity (OTel gen_ai.tool.*) ===
67
+
68
+ @doc("Tool name - OTel: gen_ai.tool.name (e.g., 'Read', 'Bash', 'Edit', 'TodoWrite')")
69
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
70
+ toolName: string;
71
+
72
+ @doc("Tool type categorization - OTel: gen_ai.tool.type (e.g., 'function', 'extension')")
73
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
74
+ toolType?: string;
75
+
76
+ @doc("Tool description - OTel: gen_ai.tool.description")
77
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
78
+ toolDescription?: string;
79
+
80
+ // === Tool Call Data (OTel gen_ai.tool.call.*) ===
81
+
82
+ @doc("Tool input arguments as JSON - OTel: gen_ai.tool.call.arguments")
83
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
84
+ argumentsJson?: string;
85
+
86
+ @doc("Tool output result as JSON - OTel: gen_ai.tool.call.result")
87
+ @TypeSpec.OpenAPI.extension("x-promoted", true)
88
+ resultJson?: string;
89
+
90
+ // === Execution State ===
91
+
92
+ @doc("Execution status")
93
+ status: ToolCallStatus;
94
+
95
+ // === Timing ===
96
+
97
+ @doc("Tool call start time in nanoseconds since epoch")
98
+ startTimeUnixNano: UnixNanos;
99
+
100
+ @doc("Tool call end time in nanoseconds since epoch")
101
+ endTimeUnixNano?: UnixNanos;
102
+
103
+ @doc("Duration in nanoseconds")
104
+ durationNs?: DurationNs;
105
+
106
+ // === Error ===
107
+
108
+ @doc("Error message if failed")
109
+ errorMessage?: string;
110
+
111
+ // === Ordering ===
112
+
113
+ @doc("Execution order within the agent run")
114
+ @minValue(0)
115
+ sequenceNumber: int32;
116
+
117
+ // === Internal ===
118
+
119
+ @doc("Row creation timestamp")
120
+ @TypeSpec.OpenAPI.extension("x-internal", true)
121
+ createdAt?: utcDateTime;
122
+ }
@@ -0,0 +1,50 @@
1
+ // =============================================================================
2
+ // ANcpLua v2.0 - Workflow Checkpoint Contract Model (OTel v1.40)
3
+ // =============================================================================
4
+ // Checkpoint state persistence for workflow execution recovery.
5
+ // Enables resume-from-checkpoint after failures or cancellations.
6
+ // =============================================================================
7
+
8
+ import "@typespec/openapi";
9
+ import "../../common/types.tsp";
10
+
11
+ using TypeSpec.OpenAPI;
12
+ using Qyl.Api.Contracts.Common;
13
+
14
+ namespace Qyl.Api.Contracts.Domains.Agent.Checkpoint;
15
+
16
+ // =============================================================================
17
+ // Workflow Checkpoint Entity
18
+ // =============================================================================
19
+
20
+ @doc("Workflow checkpoint entity for persisting workflow node state for recovery")
21
+ @TypeSpec.OpenAPI.extension("x-csharp-type", "WorkflowCheckpointEntity")
22
+ model WorkflowCheckpointEntity {
23
+ // === Identifiers ===
24
+
25
+ @doc("Unique checkpoint identifier")
26
+ @key
27
+ checkpointId: string;
28
+
29
+ @doc("Parent workflow execution identifier")
30
+ executionId: string;
31
+
32
+ // === Node State ===
33
+
34
+ @doc("Workflow node identifier")
35
+ nodeId: string;
36
+
37
+ @doc("Serialized node state as JSON")
38
+ stateJson: string;
39
+
40
+ // === Ordering ===
41
+
42
+ @doc("Checkpoint sequence number within the execution")
43
+ @minValue(0)
44
+ sequenceNumber: int32;
45
+
46
+ // === Timing ===
47
+
48
+ @doc("Checkpoint creation time in nanoseconds since epoch")
49
+ createdAtUnixNano: UnixNanos;
50
+ }
@@ -0,0 +1,136 @@
1
+ // =============================================================================
2
+ // ANcpLua v2.0 - Workflow Execution Contract Model (OTel v1.40)
3
+ // =============================================================================
4
+ // Workflow execution tracking for multi-step AI agent workflows.
5
+ // Defines the public qyl workflow execution contract.
6
+ // =============================================================================
7
+
8
+ import "@typespec/openapi";
9
+ import "../../common/types.tsp";
10
+ import "../../otel/enums.tsp";
11
+
12
+ using TypeSpec.OpenAPI;
13
+ using Qyl.Api.Contracts.Common;
14
+ using Qyl.Api.Contracts.OTel.Enums;
15
+
16
+ namespace Qyl.Api.Contracts.Domains.Agent.Workflow;
17
+
18
+ // =============================================================================
19
+ // Workflow Execution Status
20
+ // =============================================================================
21
+
22
+ @doc("Workflow execution status")
23
+ enum WorkflowExecutionStatus {
24
+ @doc("Workflow is pending execution")
25
+ pending: "pending",
26
+
27
+ @doc("Workflow is currently running")
28
+ running: "running",
29
+
30
+ @doc("Workflow completed successfully")
31
+ completed: "completed",
32
+
33
+ @doc("Workflow execution failed")
34
+ failed: "failed",
35
+
36
+ @doc("Workflow execution was cancelled")
37
+ cancelled: "cancelled",
38
+ }
39
+
40
+ // =============================================================================
41
+ // Workflow Trigger Type
42
+ // =============================================================================
43
+
44
+ @doc("What triggered a workflow execution")
45
+ enum WorkflowTrigger {
46
+ @doc("Manually triggered by user or agent")
47
+ manual: "manual",
48
+
49
+ @doc("Triggered by schedule/cron")
50
+ schedule: "schedule",
51
+
52
+ @doc("Triggered by event (e.g., error, alert)")
53
+ event: "event",
54
+
55
+ @doc("Triggered by another workflow")
56
+ workflow: "workflow",
57
+ }
58
+
59
+ // =============================================================================
60
+ // Workflow Execution Entity
61
+ // =============================================================================
62
+
63
+ @doc("Workflow execution entity for tracking multi-step agent workflows")
64
+ @TypeSpec.OpenAPI.extension("x-csharp-type", "WorkflowExecutionEntity")
65
+ model WorkflowExecutionEntity {
66
+ // === Identifiers ===
67
+
68
+ @doc("Unique execution identifier")
69
+ @key
70
+ executionId: string;
71
+
72
+ @doc("Associated OTel trace identifier")
73
+ traceId?: TraceId;
74
+
75
+ // === Workflow Identity ===
76
+
77
+ @doc("Workflow name identifier")
78
+ workflowName: string;
79
+
80
+ @doc("What triggered the workflow")
81
+ trigger: WorkflowTrigger;
82
+
83
+ // === Execution State ===
84
+
85
+ @doc("Execution status")
86
+ status: WorkflowExecutionStatus;
87
+
88
+ // === I/O ===
89
+
90
+ @doc("Workflow input as JSON")
91
+ inputJson?: string;
92
+
93
+ @doc("Workflow output as JSON")
94
+ outputJson?: string;
95
+
96
+ // === Token Usage (OTel gen_ai.usage.*) ===
97
+
98
+ @doc("Total input tokens - OTel: gen_ai.usage.input_tokens")
99
+ genAiInputTokens?: TokenCount;
100
+
101
+ @doc("Total output tokens - OTel: gen_ai.usage.output_tokens")
102
+ genAiOutputTokens?: TokenCount;
103
+
104
+ @doc("Estimated cost in USD")
105
+ genAiCostUsd?: CostUsd;
106
+
107
+ // === Progress ===
108
+
109
+ @doc("Total number of workflow nodes")
110
+ nodeCount?: int32;
111
+
112
+ @doc("Number of completed nodes")
113
+ completedNodes?: int32;
114
+
115
+ // === Timing ===
116
+
117
+ @doc("Start timestamp in nanoseconds since epoch")
118
+ startTimeUnixNano: UnixNanos;
119
+
120
+ @doc("End timestamp in nanoseconds since epoch")
121
+ endTimeUnixNano?: UnixNanos;
122
+
123
+ @doc("Duration in nanoseconds")
124
+ durationNs?: DurationNs;
125
+
126
+ // === Error ===
127
+
128
+ @doc("Error message if failed")
129
+ errorMessage?: string;
130
+
131
+ // === Internal ===
132
+
133
+ @doc("Row creation timestamp")
134
+ @TypeSpec.OpenAPI.extension("x-internal", true)
135
+ createdAt?: utcDateTime;
136
+ }