@company-semantics/contracts 9.0.0 → 9.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 (141) hide show
  1. package/package.json +6 -3
  2. package/src/__tests__/resource-keys.test.ts +30 -23
  3. package/src/admin/authz-simulate.ts +4 -4
  4. package/src/admin/direct-grants.ts +2 -2
  5. package/src/api/generated-spec-hash.ts +2 -2
  6. package/src/api/generated.ts +97 -0
  7. package/src/api/http/routes/ai-chat.ts +3 -3
  8. package/src/api/http/utils/resource-response.ts +5 -2
  9. package/src/api/index.ts +4 -4
  10. package/src/api/primitives.ts +6 -2
  11. package/src/auth/README.md +1 -0
  12. package/src/auth/index.ts +12 -5
  13. package/src/autotune.ts +5 -1
  14. package/src/billing/index.ts +1 -1
  15. package/src/billing/types.ts +1 -1
  16. package/src/chat/README.md +3 -0
  17. package/src/chat/__tests__/runtime-profile.test.ts +68 -48
  18. package/src/chat/index.ts +10 -4
  19. package/src/chat/runtime-profile.ts +25 -10
  20. package/src/chat/schemas.ts +49 -41
  21. package/src/chat/types.ts +48 -42
  22. package/src/ci-envelope/README.md +2 -0
  23. package/src/ci-envelope/__tests__/transitions.test.ts +56 -56
  24. package/src/ci-envelope/index.ts +2 -2
  25. package/src/ci-envelope/types.ts +20 -20
  26. package/src/ci-results/index.ts +2 -2
  27. package/src/ci-results/repo-ci-result.ts +15 -12
  28. package/src/compatibility.ts +6 -6
  29. package/src/content/index.ts +10 -4
  30. package/src/content/schemas.ts +42 -24
  31. package/src/dispatch/index.ts +18 -15
  32. package/src/email/__tests__/registry.test.ts +81 -77
  33. package/src/email/index.ts +3 -3
  34. package/src/email/registry.ts +25 -25
  35. package/src/email/types.ts +43 -43
  36. package/src/errors/index.ts +8 -8
  37. package/src/execution/__tests__/events.test.ts +42 -42
  38. package/src/execution/__tests__/lifecycle.test.ts +192 -190
  39. package/src/execution/__tests__/registry.test.ts +114 -114
  40. package/src/execution/audit-export.ts +4 -4
  41. package/src/execution/errors.ts +7 -7
  42. package/src/execution/event-metadata.ts +4 -4
  43. package/src/execution/events.ts +23 -21
  44. package/src/execution/expiry.ts +5 -5
  45. package/src/execution/hash-chain.ts +2 -2
  46. package/src/execution/index.ts +19 -28
  47. package/src/execution/kinds.ts +7 -7
  48. package/src/execution/lifecycle.ts +33 -33
  49. package/src/execution/registry.ts +63 -63
  50. package/src/execution/schemas.ts +31 -23
  51. package/src/execution/status.ts +45 -26
  52. package/src/execution/summary.ts +16 -17
  53. package/src/execution/timeline-ui.ts +9 -9
  54. package/src/execution/types.ts +31 -25
  55. package/src/generated/openapi-routes.ts +2 -0
  56. package/src/guards/config.ts +22 -18
  57. package/src/guards/index.ts +4 -4
  58. package/src/guards/types.ts +32 -24
  59. package/src/identity/__tests__/avatar.test.ts +68 -59
  60. package/src/identity/avatar.ts +8 -8
  61. package/src/identity/display-name.ts +3 -3
  62. package/src/identity/index.ts +8 -8
  63. package/src/identity/people-org-chart.ts +8 -4
  64. package/src/identity/schemas.ts +28 -18
  65. package/src/identity/types.ts +5 -5
  66. package/src/impersonation/index.ts +5 -5
  67. package/src/impersonation/schemas.ts +15 -9
  68. package/src/impersonation-events.ts +21 -21
  69. package/src/impersonation.ts +25 -24
  70. package/src/index.ts +118 -90
  71. package/src/interfaces/mcp/tools/help.ts +19 -19
  72. package/src/internal-admin.ts +6 -6
  73. package/src/mcp/README.md +2 -0
  74. package/src/mcp/__tests__/capability-graph.test.ts +290 -290
  75. package/src/mcp/capability-graph.ts +42 -40
  76. package/src/mcp/failure-context.ts +1 -3
  77. package/src/mcp/index.ts +69 -56
  78. package/src/mcp/resources.ts +9 -9
  79. package/src/meetings/index.ts +2 -2
  80. package/src/meetings/schemas.ts +51 -34
  81. package/src/message-parts/README.md +2 -0
  82. package/src/message-parts/__tests__/builder.test.ts +142 -142
  83. package/src/message-parts/__tests__/confirmation.test.ts +100 -86
  84. package/src/message-parts/__tests__/preview.test.ts +63 -63
  85. package/src/message-parts/__tests__/wire.test.ts +130 -124
  86. package/src/message-parts/builder.ts +23 -23
  87. package/src/message-parts/confirmation.ts +17 -14
  88. package/src/message-parts/execution.ts +7 -7
  89. package/src/message-parts/index.ts +10 -10
  90. package/src/message-parts/lifecycle.ts +25 -25
  91. package/src/message-parts/preview.ts +30 -30
  92. package/src/message-parts/types.ts +27 -27
  93. package/src/message-parts/wire.ts +24 -24
  94. package/src/mutations.ts +2 -2
  95. package/src/observability.ts +23 -11
  96. package/src/org/__tests__/org-units.test.ts +131 -96
  97. package/src/org/__tests__/tree-ordering.test.ts +57 -37
  98. package/src/org/__tests__/view-scopes.test.ts +40 -40
  99. package/src/org/domain.ts +9 -9
  100. package/src/org/index.ts +31 -21
  101. package/src/org/org-units.ts +34 -20
  102. package/src/org/schemas.ts +261 -124
  103. package/src/org/sharing.ts +17 -13
  104. package/src/org/tree-ordering.ts +3 -1
  105. package/src/org/types.ts +54 -47
  106. package/src/org/view-scopes.ts +9 -9
  107. package/src/permissions/access-levels.ts +7 -2
  108. package/src/permissions/access-source.ts +6 -6
  109. package/src/permissions/index.ts +5 -5
  110. package/src/permissions/orgchart-roles.ts +7 -7
  111. package/src/permissions/permission-introspection.ts +7 -5
  112. package/src/permissions/share-api.ts +19 -9
  113. package/src/pressure.ts +4 -4
  114. package/src/queryIntent.ts +21 -21
  115. package/src/ralph/__tests__/prd-groups.test.ts +159 -159
  116. package/src/ralph/__tests__/prd.test.ts +30 -30
  117. package/src/ralph/index.ts +3 -8
  118. package/src/ralph/prd.ts +33 -33
  119. package/src/ralph/progress.ts +1 -1
  120. package/src/rate-limit/README.md +4 -4
  121. package/src/rate-limit/index.ts +3 -3
  122. package/src/requests.ts +36 -8
  123. package/src/resource-keys.ts +207 -124
  124. package/src/resource-registry.ts +5 -5
  125. package/src/route-builder.ts +3 -3
  126. package/src/safe-mode.ts +2 -2
  127. package/src/security/index.ts +4 -4
  128. package/src/security/org-secrets.ts +13 -9
  129. package/src/security/secret.ts +3 -3
  130. package/src/sse.ts +3 -1
  131. package/src/system/README.md +3 -0
  132. package/src/system/capabilities.ts +22 -23
  133. package/src/system/diagram.ts +45 -45
  134. package/src/system/index.ts +14 -14
  135. package/src/tiers.ts +1 -1
  136. package/src/timeouts.ts +1 -1
  137. package/src/tracing.ts +30 -30
  138. package/src/types/analytics.ts +2 -2
  139. package/src/usage/README.md +3 -0
  140. package/src/usage/execution-types.ts +69 -69
  141. package/src/usage/types.ts +7 -3
@@ -4,105 +4,105 @@
4
4
  * See PRD-00200 for design rationale and invariants.
5
5
  */
6
6
 
7
- import type { ChatRuntimeProfile } from '../chat/runtime-profile'
7
+ import type { ChatRuntimeProfile } from "../chat/runtime-profile";
8
8
 
9
9
  export type ExecutionFailureReason =
10
- | 'tool_error'
11
- | 'timeout'
12
- | 'model_error'
13
- | 'budget_exceeded'
14
- | 'client_disconnect'
15
- | 'unknown'
10
+ | "tool_error"
11
+ | "timeout"
12
+ | "model_error"
13
+ | "budget_exceeded"
14
+ | "client_disconnect"
15
+ | "unknown";
16
16
 
17
17
  // @vocabulary-exempt reason: telemetry row is a single DB-aligned record; splitting risks consumer breakage
18
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
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
38
  }
39
39
 
40
40
  // --- Aggregation response types (PRD-00201) ---
41
41
 
42
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
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
51
  }
52
52
 
53
53
  export interface OrgExecutionSummary {
54
- dateRange: { start: string; end: string }
54
+ dateRange: { start: string; end: string };
55
55
  totals: {
56
- executions: number
57
- tokens: number
58
- costUsd: string
59
- avgDurationMs: number
60
- }
61
- byProfile: Record<ChatRuntimeProfile, ProfileStats>
56
+ executions: number;
57
+ tokens: number;
58
+ costUsd: string;
59
+ avgDurationMs: number;
60
+ };
61
+ byProfile: Record<ChatRuntimeProfile, ProfileStats>;
62
62
  }
63
63
 
64
64
  export interface DailyExecutionStats {
65
- date: string // YYYY-MM-DD
66
- executions: number
67
- totalCostUsd: string
68
- byProfile: Record<ChatRuntimeProfile, number>
65
+ date: string; // YYYY-MM-DD
66
+ executions: number;
67
+ totalCostUsd: string;
68
+ byProfile: Record<ChatRuntimeProfile, number>;
69
69
  }
70
70
 
71
71
  export interface ExecutionByUser {
72
- userId: string
73
- email: string
74
- executions: number
75
- totalCostUsd: string
76
- favoriteProfile: ChatRuntimeProfile
72
+ userId: string;
73
+ email: string;
74
+ executions: number;
75
+ totalCostUsd: string;
76
+ favoriteProfile: ChatRuntimeProfile;
77
77
  }
78
78
 
79
79
  export interface ExecutionDetail {
80
- execution: RuntimeExecutionTelemetry
80
+ execution: RuntimeExecutionTelemetry;
81
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
- }>
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
91
  }
92
92
 
93
93
  // --- Budget governance types (PRD-00232) ---
94
94
 
95
95
  export interface BudgetCheck {
96
- allowed: boolean
97
- reason?: 'monthly_budget_exceeded' | 'approaching_limit'
98
- remainingBudgetUsd?: string
99
- usedThisMonthUsd?: string
96
+ allowed: boolean;
97
+ reason?: "monthly_budget_exceeded" | "approaching_limit";
98
+ remainingBudgetUsd?: string;
99
+ usedThisMonthUsd?: string;
100
100
  }
101
101
 
102
102
  export interface OrgBudgetSettings {
103
- monthlyBudgetUsd: string | null
104
- maxCostPerExecution: string | null
105
- agenticMaxSteps: number | null
106
- alertThresholdPct: number
107
- enabled: boolean
103
+ monthlyBudgetUsd: string | null;
104
+ maxCostPerExecution: string | null;
105
+ agenticMaxSteps: number | null;
106
+ alertThresholdPct: number;
107
+ enabled: boolean;
108
108
  }
@@ -4,7 +4,12 @@
4
4
  * See PRD-00166 for design rationale and invariants.
5
5
  */
6
6
 
7
- export type AiFeature = 'chat' | 'chat_title' | 'ingest_summarize' | 'ingest_embedding' | 'company_md_extraction';
7
+ export type AiFeature =
8
+ | "chat"
9
+ | "chat_title"
10
+ | "ingest_summarize"
11
+ | "ingest_embedding"
12
+ | "company_md_extraction";
8
13
 
9
14
  export interface UsageSummary {
10
15
  totalTokens: number;
@@ -13,7 +18,7 @@ export interface UsageSummary {
13
18
  estimatedCostUsd: string;
14
19
  requestCount: number;
15
20
  periodStart: string; // UTC ISO8601
16
- periodEnd: string; // UTC ISO8601
21
+ periodEnd: string; // UTC ISO8601
17
22
  }
18
23
 
19
24
  export interface DailyUsage {
@@ -46,7 +51,6 @@ export interface UsageByUser {
46
51
  requestCount: number;
47
52
  }
48
53
 
49
-
50
54
  // ---------------------------------------------------------------------------
51
55
  // Unified Usage Response (PRD-00276/277)
52
56
  // ---------------------------------------------------------------------------