@company-semantics/contracts 0.78.0 → 0.80.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@company-semantics/contracts",
3
- "version": "0.78.0",
3
+ "version": "0.80.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
package/src/index.ts CHANGED
@@ -477,3 +477,16 @@ export type {
477
477
  UsageByUser,
478
478
  OrgUsageResponse,
479
479
  } from './usage/types'
480
+
481
+ // Runtime execution telemetry types
482
+ // @see PRD-00200 for design rationale
483
+ export type {
484
+ ExecutionFailureReason,
485
+ RuntimeExecutionTelemetry,
486
+ // Aggregation response types (PRD-00201)
487
+ ProfileStats,
488
+ OrgExecutionSummary,
489
+ DailyExecutionStats,
490
+ ExecutionByUser,
491
+ ExecutionDetail,
492
+ } from './usage/execution-types'
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Runtime Execution Telemetry Types
3
+ * One execution = one user message -> full assistant response (including tool loops).
4
+ * See PRD-00200 for design rationale and invariants.
5
+ */
6
+
7
+ import type { ChatRuntimeProfile } from '../chat/runtime-profile'
8
+
9
+ export type ExecutionFailureReason =
10
+ | 'tool_error'
11
+ | 'timeout'
12
+ | 'model_error'
13
+ | 'budget_exceeded'
14
+ | 'client_disconnect'
15
+ | 'unknown'
16
+
17
+ // @vocabulary-exempt reason: telemetry row is a single DB-aligned record; splitting risks consumer breakage
18
+ export interface RuntimeExecutionTelemetry {
19
+ executionId: string
20
+ orgId: string
21
+ chatId?: string
22
+ messageId?: string
23
+ profile: ChatRuntimeProfile
24
+ provider: string
25
+ model: string
26
+ stepCount: number
27
+ toolCallCount: number
28
+ tokensInput: number
29
+ tokensOutput: number
30
+ tokensTotal: number
31
+ costInputUsd: string // 8 decimal places
32
+ costOutputUsd: string // 8 decimal places
33
+ costTotalUsd: string // 8 decimal places
34
+ durationMs: number
35
+ success: boolean
36
+ failureReason?: ExecutionFailureReason
37
+ createdAt: string // ISO 8601
38
+ }
39
+
40
+ // --- Aggregation response types (PRD-00201) ---
41
+
42
+ export interface ProfileStats {
43
+ executions: number
44
+ percentOfTotal: number
45
+ avgDurationMs: number
46
+ totalCostUsd: string
47
+ avgCostPerExecution: string
48
+ failureRate: number
49
+ avgStepCount: number
50
+ avgToolCallCount: number
51
+ }
52
+
53
+ export interface OrgExecutionSummary {
54
+ dateRange: { start: string; end: string }
55
+ totals: {
56
+ executions: number
57
+ tokens: number
58
+ costUsd: string
59
+ avgDurationMs: number
60
+ }
61
+ byProfile: Record<ChatRuntimeProfile, ProfileStats>
62
+ }
63
+
64
+ export interface DailyExecutionStats {
65
+ date: string // YYYY-MM-DD
66
+ executions: number
67
+ totalCostUsd: string
68
+ byProfile: Record<ChatRuntimeProfile, number>
69
+ }
70
+
71
+ export interface ExecutionByUser {
72
+ userId: string
73
+ email: string
74
+ executions: number
75
+ totalCostUsd: string
76
+ favoriteProfile: ChatRuntimeProfile
77
+ }
78
+
79
+ export interface ExecutionDetail {
80
+ execution: RuntimeExecutionTelemetry
81
+ llmCalls: Array<{
82
+ callId: string
83
+ model: string
84
+ provider: string
85
+ tokensInput: number
86
+ tokensOutput: number
87
+ costUsd: string
88
+ durationMs: number
89
+ toolCalls: number
90
+ }>
91
+ }