@ancplua/qyl-api-schema 0.4.0 → 0.5.1

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 (61) hide show
  1. package/README.md +52 -64
  2. package/api/routes.tsp +90 -943
  3. package/api/runner.tsp +99 -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 -41
  8. package/generated/json-schema/qyl-api-schema.json +3868 -0
  9. package/generated/openapi/qyl.openapi.json +6919 -0
  10. package/generated/ts-runtime/api.d.ts +886 -0
  11. package/generated/ts-runtime/api.js +237 -0
  12. package/index.tsp +8 -34
  13. package/models/health.tsp +22 -0
  14. package/models/mcp-tools.tsp +217 -0
  15. package/models/runner-mcp.tsp +76 -0
  16. package/models/runner.tsp +67 -0
  17. package/models/session.tsp +1 -1
  18. package/otel/enums.tsp +1 -1
  19. package/otel/logs.tsp +1 -1
  20. package/otel/otel-conventions.tsp +0 -1
  21. package/otel/profiles.tsp +1 -1
  22. package/otel/resource.tsp +1 -1
  23. package/otel/span.tsp +9 -6
  24. package/package.json +56 -36
  25. package/VERSIONING.md +0 -88
  26. package/generated/README.md +0 -35
  27. package/intelligence/causal-rules.tsp +0 -34
  28. package/intelligence/diagnostic-patterns.tsp +0 -54
  29. package/intelligence/investigation-strategies.tsp +0 -37
  30. package/intelligence/main.tsp +0 -17
  31. package/intelligence/seed/patterns.tsp +0 -171
  32. package/intelligence/seed/rules.tsp +0 -43
  33. package/intelligence/seed/strategies.tsp +0 -55
  34. package/intelligence/signals.tsp +0 -60
  35. package/models/agent/agent-run.tsp +0 -154
  36. package/models/agent/tool-call.tsp +0 -122
  37. package/models/agent/workflow-checkpoint.tsp +0 -50
  38. package/models/agent/workflow-execution.tsp +0 -136
  39. package/models/alerting.tsp +0 -436
  40. package/models/configurator.tsp +0 -433
  41. package/models/control-graph.tsp +0 -197
  42. package/models/db.tsp +0 -767
  43. package/models/deployment.tsp +0 -365
  44. package/models/error.tsp +0 -433
  45. package/models/genai.tsp +0 -1305
  46. package/models/http.tsp +0 -547
  47. package/models/identity.tsp +0 -213
  48. package/models/issues.tsp +0 -484
  49. package/models/log.tsp +0 -140
  50. package/models/messaging.tsp +0 -304
  51. package/models/otel-config.tsp +0 -455
  52. package/models/retention.tsp +0 -240
  53. package/models/rpc.tsp +0 -309
  54. package/models/search.tsp +0 -243
  55. package/models/system.tsp +0 -400
  56. package/models/test.tsp +0 -346
  57. package/models/triage.tsp +0 -113
  58. package/models/workflow.tsp +0 -396
  59. package/models/workspace.tsp +0 -435
  60. package/otel/metrics.tsp +0 -358
  61. package/tspconfig.yaml +0 -49
@@ -1,43 +0,0 @@
1
- // =============================================================================
2
- // ANcpLua v2.0 - Seed Causal Rules (v1)
3
- // =============================================================================
4
- // 6 initial causal rules.
5
- // =============================================================================
6
-
7
- namespace Qyl.Api.Contracts.Intelligence.Seed;
8
-
9
- // ---------------------------------------------------------------------------
10
- // Rule: deploy_causes_regression
11
- // Cause: deployment_regression → Effect: http_5xx_cluster
12
- // Strength: 0.85, Window: 1h
13
- // ---------------------------------------------------------------------------
14
-
15
- // ---------------------------------------------------------------------------
16
- // Rule: rate_limit_causes_cascade
17
- // Cause: genai_rate_limit → Effect: cascading_timeout
18
- // Strength: 0.70, Window: 5m
19
- // ---------------------------------------------------------------------------
20
-
21
- // ---------------------------------------------------------------------------
22
- // Rule: db_timeout_causes_http_error
23
- // Cause: db_timeout → Effect: http_5xx_cluster
24
- // Strength: 0.80, Window: 1m
25
- // ---------------------------------------------------------------------------
26
-
27
- // ---------------------------------------------------------------------------
28
- // Rule: n_plus_one_causes_db_timeout
29
- // Cause: db_n_plus_one → Effect: db_timeout
30
- // Strength: 0.75, Window: 30s
31
- // ---------------------------------------------------------------------------
32
-
33
- // ---------------------------------------------------------------------------
34
- // Rule: memory_causes_timeout
35
- // Cause: memory_pressure_latency → Effect: cascading_timeout
36
- // Strength: 0.65, Window: 5m
37
- // ---------------------------------------------------------------------------
38
-
39
- // ---------------------------------------------------------------------------
40
- // Rule: token_exhaustion_causes_cost
41
- // Cause: genai_token_exhaustion → Effect: cost_spike
42
- // Strength: 0.60, Window: 1h
43
- // ---------------------------------------------------------------------------
@@ -1,55 +0,0 @@
1
- // =============================================================================
2
- // ANcpLua v2.0 - Seed Investigation Strategies (v1)
3
- // =============================================================================
4
- // 4 initial investigation strategies.
5
- //
6
- // Trigger patterns use category:X syntax for category-wide triggers.
7
- // Query templates are abstract qyl investigation hints; the runtime decides how to execute them.
8
- // =============================================================================
9
-
10
- namespace Qyl.Api.Contracts.Intelligence.Seed;
11
-
12
- // ---------------------------------------------------------------------------
13
- // Strategy: investigate_error_issue
14
- // Trigger: category:error (any error category pattern)
15
- // Steps:
16
- // 1. get_issue — SELECT * FROM error_issues WHERE id = ?
17
- // 2. get_events — SELECT * FROM error_issue_events WHERE issue_id = ? ORDER BY timestamp DESC LIMIT 10
18
- // 3. get_traces — SELECT * FROM spans WHERE trace_id IN (?) ORDER BY start_time_unix_nano
19
- // 4. get_code_location — SELECT code_filepath, code_function, code_lineno FROM spans WHERE span_id = ?
20
- // 5. correlate_deployment — SELECT * FROM deployments WHERE service_name = ? AND start_time <= ? ORDER BY start_time DESC LIMIT 1
21
- // 6. check_fix_history — SELECT * FROM fix_runs WHERE issue_id = ?
22
- // ---------------------------------------------------------------------------
23
-
24
- // ---------------------------------------------------------------------------
25
- // Strategy: investigate_latency
26
- // Trigger: category:latency (any latency category pattern)
27
- // Steps:
28
- // 1. identify_service — SELECT service_name, AVG(duration_ns), PERCENTILE_CONT(0.99) ... GROUP BY service_name
29
- // 2. compare_distributions — SELECT duration_ns FROM spans WHERE service_name = ? AND start_time BETWEEN ? AND ?
30
- // 3. find_regression_window — Time-series analysis of p99 latency
31
- // 4. correlate_deployment — SELECT * FROM deployments WHERE service_name = ? AND start_time <= ? ORDER BY start_time DESC LIMIT 1
32
- // 5. inspect_slow_spans — SELECT * FROM spans WHERE service_name = ? AND duration_ns > ? ORDER BY duration_ns DESC LIMIT 20
33
- // ---------------------------------------------------------------------------
34
-
35
- // ---------------------------------------------------------------------------
36
- // Strategy: investigate_cost
37
- // Trigger: category:cost (any cost category pattern)
38
- // Steps:
39
- // 1. identify_model — SELECT gen_ai_request_model, SUM(gen_ai_cost_usd) ... GROUP BY gen_ai_request_model
40
- // 2. identify_service — SELECT service_name, SUM(gen_ai_cost_usd) ... GROUP BY service_name
41
- // 3. identify_session — SELECT session_id, SUM(gen_ai_cost_usd) ... GROUP BY session_id ORDER BY 2 DESC
42
- // 4. trace_to_root — Follow session → traces → spans
43
- // 5. compare_to_baseline — Compare current period vs previous period
44
- // ---------------------------------------------------------------------------
45
-
46
- // ---------------------------------------------------------------------------
47
- // Strategy: investigate_genai
48
- // Trigger: category:genai (any genai category pattern)
49
- // Steps:
50
- // 1. get_error_details — SELECT * FROM spans WHERE status_code = 2 AND gen_ai_provider_name IS NOT NULL
51
- // 2. check_provider_status — Evaluate gen_ai_provider_name + error frequency
52
- // 3. analyze_token_usage — SELECT gen_ai_input_tokens, gen_ai_output_tokens FROM spans WHERE gen_ai_request_model = ?
53
- // 4. check_prompt_patterns — Inspect spans around the error for prompt size trends
54
- // 5. suggest_mitigation — Pattern-specific recommendation
55
- // ---------------------------------------------------------------------------
@@ -1,60 +0,0 @@
1
- // =============================================================================
2
- // ANcpLua v2.0 - Signal Primitive
3
- // =============================================================================
4
- // The atomic unit of telemetry observation. A single attribute condition.
5
- // Signals reference semconv attributes and qyl-derived attributes only.
6
- // =============================================================================
7
-
8
- import "@typespec/openapi";
9
-
10
- using TypeSpec.OpenAPI;
11
-
12
- namespace Qyl.Api.Contracts.Intelligence;
13
-
14
- @doc("Comparison operator for signal evaluation")
15
- enum SignalOperator {
16
- @doc("Equals")
17
- eq: "eq",
18
-
19
- @doc("Not equals")
20
- neq: "neq",
21
-
22
- @doc("Greater than")
23
- gt: "gt",
24
-
25
- @doc("Greater than or equal")
26
- gte: "gte",
27
-
28
- @doc("Less than")
29
- lt: "lt",
30
-
31
- @doc("Less than or equal")
32
- lte: "lte",
33
-
34
- @doc("String contains")
35
- contains: "contains",
36
-
37
- @doc("Attribute is non-null")
38
- exists: "exists",
39
-
40
- @doc("Attribute is null")
41
- not_exists: "not_exists",
42
-
43
- @doc("Regex match")
44
- matches: "matches",
45
-
46
- @doc("Value in set (comma-separated)")
47
- in_set: "in",
48
- }
49
-
50
- @doc("Atomic telemetry observation — a single attribute condition")
51
- model Signal {
52
- @doc("Telemetry attribute name (semconv or promoted column)")
53
- attribute: string;
54
-
55
- @doc("Comparison operator")
56
- operator: SignalOperator;
57
-
58
- @doc("Expected value (type-coerced at evaluation time). Omit for exists/not_exists.")
59
- value?: string;
60
- }
@@ -1,154 +0,0 @@
1
- // =============================================================================
2
- // ANcpLua v2.0 - Agent Run Contract Model
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
- }
@@ -1,122 +0,0 @@
1
- // =============================================================================
2
- // ANcpLua v2.0 - Tool Call Contract Model
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
- }
@@ -1,50 +0,0 @@
1
- // =============================================================================
2
- // ANcpLua v2.0 - Workflow Checkpoint Contract Model
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
- }
@@ -1,136 +0,0 @@
1
- // =============================================================================
2
- // ANcpLua v2.0 - Workflow Execution Contract Model
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
- }