@company-semantics/contracts 9.1.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 +4 -1
  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 +1 -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 +57 -57
  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 +24 -21
  101. package/src/org/org-units.ts +34 -20
  102. package/src/org/schemas.ts +201 -127
  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
@@ -13,9 +13,9 @@
13
13
  * @see decisions/ADR-CONT-026.md for design rationale
14
14
  */
15
15
 
16
- import type { ToolListMessagePart } from '../mcp/index'
17
- import type { PreviewPart } from './preview'
18
- import type { ConfirmationPart } from './confirmation'
16
+ import type { ToolListMessagePart } from "../mcp/index";
17
+ import type { PreviewPart } from "./preview";
18
+ import type { ConfirmationPart } from "./confirmation";
19
19
 
20
20
  // =============================================================================
21
21
  // Narrative Parts (Streamable)
@@ -28,9 +28,9 @@ import type { ConfirmationPart } from './confirmation'
28
28
  * Design: Aligns with AI SDK's TextPart for interoperability.
29
29
  */
30
30
  export interface TextPart {
31
- type: 'text'
31
+ type: "text";
32
32
  /** The text content (may be partial during streaming) */
33
- text: string
33
+ text: string;
34
34
  }
35
35
 
36
36
  // =============================================================================
@@ -40,18 +40,18 @@ export interface TextPart {
40
40
  /**
41
41
  * Re-export ToolListMessagePart as ToolListPart for consistency.
42
42
  */
43
- export type ToolListPart = ToolListMessagePart
43
+ export type ToolListPart = ToolListMessagePart;
44
44
 
45
45
  /**
46
46
  * Status panel surface part.
47
47
  * Displays system status, connection states, or progress indicators.
48
48
  */
49
49
  export interface StatusPanelPart {
50
- type: 'status-panel'
50
+ type: "status-panel";
51
51
  /** Panel title */
52
- title: string
52
+ title: string;
53
53
  /** Status entries */
54
- entries: StatusPanelEntry[]
54
+ entries: StatusPanelEntry[];
55
55
  }
56
56
 
57
57
  /**
@@ -59,11 +59,11 @@ export interface StatusPanelPart {
59
59
  */
60
60
  export interface StatusPanelEntry {
61
61
  /** Entry label */
62
- label: string
62
+ label: string;
63
63
  /** Current status */
64
- status: 'ok' | 'warning' | 'error' | 'pending'
64
+ status: "ok" | "warning" | "error" | "pending";
65
65
  /** Optional detail text */
66
- detail?: string
66
+ detail?: string;
67
67
  }
68
68
 
69
69
  /**
@@ -71,23 +71,23 @@ export interface StatusPanelEntry {
71
71
  * Renders a data visualization.
72
72
  */
73
73
  export interface ChartPart {
74
- type: 'chart'
74
+ type: "chart";
75
75
  /** Chart type */
76
- chartType: 'bar' | 'line' | 'pie' | 'area'
76
+ chartType: "bar" | "line" | "pie" | "area";
77
77
  /** Chart title */
78
- title?: string
78
+ title?: string;
79
79
  /** Data points */
80
- data: ChartDataPoint[]
80
+ data: ChartDataPoint[];
81
81
  }
82
82
 
83
83
  /**
84
84
  * Single data point for charts.
85
85
  */
86
86
  export interface ChartDataPoint {
87
- label: string
88
- value: number
87
+ label: string;
88
+ value: number;
89
89
  /** Optional color (CSS color string) */
90
- color?: string
90
+ color?: string;
91
91
  }
92
92
 
93
93
  /**
@@ -95,13 +95,13 @@ export interface ChartDataPoint {
95
95
  * Renders tabular data.
96
96
  */
97
97
  export interface TablePart {
98
- type: 'table'
98
+ type: "table";
99
99
  /** Table title */
100
- title?: string
100
+ title?: string;
101
101
  /** Column headers */
102
- headers: string[]
102
+ headers: string[];
103
103
  /** Row data (each row is an array of cell values) */
104
- rows: string[][]
104
+ rows: string[][];
105
105
  }
106
106
 
107
107
  // =============================================================================
@@ -118,13 +118,13 @@ export type SurfacePart =
118
118
  | ChartPart
119
119
  | TablePart
120
120
  | ConfirmationPart
121
- | PreviewPart
121
+ | PreviewPart;
122
122
 
123
123
  /**
124
124
  * All assistant message part types.
125
125
  * Union of narrative (text) and surface parts.
126
126
  */
127
- export type AssistantMessagePart = TextPart | SurfacePart
127
+ export type AssistantMessagePart = TextPart | SurfacePart;
128
128
 
129
129
  // =============================================================================
130
130
  // Type Guards
@@ -134,12 +134,12 @@ export type AssistantMessagePart = TextPart | SurfacePart
134
134
  * Type guard for TextPart.
135
135
  */
136
136
  export function isTextPart(part: AssistantMessagePart): part is TextPart {
137
- return part.type === 'text'
137
+ return part.type === "text";
138
138
  }
139
139
 
140
140
  /**
141
141
  * Type guard for SurfacePart.
142
142
  */
143
143
  export function isSurfacePart(part: AssistantMessagePart): part is SurfacePart {
144
- return part.type !== 'text'
144
+ return part.type !== "text";
145
145
  }
@@ -10,22 +10,19 @@
10
10
  * @see decisions/ADR-CONT-026.md for design rationale
11
11
  */
12
12
 
13
- import type { MCPToolDescriptor, ToolListDataPart } from '../mcp/index'
14
- import type { PreviewDataPart, PreviewData } from './preview'
15
- import type {
16
- ConfirmationData,
17
- ConfirmationDataPart,
18
- } from './confirmation'
13
+ import type { MCPToolDescriptor, ToolListDataPart } from "../mcp/index";
14
+ import type { PreviewDataPart, PreviewData } from "./preview";
15
+ import type { ConfirmationData, ConfirmationDataPart } from "./confirmation";
19
16
  import type {
20
17
  ExecutionResultData,
21
18
  ExecutionResultDataPart,
22
19
  UndoResultData,
23
20
  UndoResultDataPart,
24
- } from './execution'
21
+ } from "./execution";
25
22
  import type {
26
23
  MessageStartDataPart,
27
24
  MessageCompleteDataPart,
28
- } from './lifecycle'
25
+ } from "./lifecycle";
29
26
 
30
27
  /**
31
28
  * Factory for creating wire-format surface parts.
@@ -48,9 +45,9 @@ export const WireSurfaceBuilder = {
48
45
  */
49
46
  toolList(tools: MCPToolDescriptor[]): ToolListDataPart {
50
47
  return {
51
- type: 'data-tool-list',
48
+ type: "data-tool-list",
52
49
  data: { tools },
53
- }
50
+ };
54
51
  },
55
52
 
56
53
  /**
@@ -67,9 +64,9 @@ export const WireSurfaceBuilder = {
67
64
  */
68
65
  preview(data: PreviewData): PreviewDataPart {
69
66
  return {
70
- type: 'data-preview',
67
+ type: "data-preview",
71
68
  data,
72
- }
69
+ };
73
70
  },
74
71
 
75
72
  /**
@@ -85,9 +82,9 @@ export const WireSurfaceBuilder = {
85
82
  */
86
83
  confirmation(data: ConfirmationData): ConfirmationDataPart {
87
84
  return {
88
- type: 'data-confirmation',
85
+ type: "data-confirmation",
89
86
  data,
90
- }
87
+ };
91
88
  },
92
89
 
93
90
  /**
@@ -104,9 +101,9 @@ export const WireSurfaceBuilder = {
104
101
  */
105
102
  executionResult(data: ExecutionResultData): ExecutionResultDataPart {
106
103
  return {
107
- type: 'data-execution-result',
104
+ type: "data-execution-result",
108
105
  data,
109
- }
106
+ };
110
107
  },
111
108
 
112
109
  /**
@@ -123,9 +120,9 @@ export const WireSurfaceBuilder = {
123
120
  */
124
121
  undoResult(data: UndoResultData): UndoResultDataPart {
125
122
  return {
126
- type: 'data-undo-result',
123
+ type: "data-undo-result",
127
124
  data,
128
- }
125
+ };
129
126
  },
130
127
 
131
128
  // =========================================================================
@@ -145,13 +142,13 @@ export const WireSurfaceBuilder = {
145
142
  */
146
143
  messageStart(messageId: string): MessageStartDataPart {
147
144
  return {
148
- type: 'data-message-start',
145
+ type: "data-message-start",
149
146
  data: {
150
147
  version: 1,
151
148
  messageId,
152
149
  timestamp: new Date().toISOString(),
153
150
  },
154
- }
151
+ };
155
152
  },
156
153
 
157
154
  /**
@@ -167,15 +164,18 @@ export const WireSurfaceBuilder = {
167
164
  * @param narrativeLength - Total length of streamed narrative text
168
165
  * @returns Wire-format message complete event
169
166
  */
170
- messageComplete(messageId: string, narrativeLength: number): MessageCompleteDataPart {
167
+ messageComplete(
168
+ messageId: string,
169
+ narrativeLength: number,
170
+ ): MessageCompleteDataPart {
171
171
  return {
172
- type: 'data-message-complete',
172
+ type: "data-message-complete",
173
173
  data: {
174
174
  version: 1,
175
175
  messageId,
176
176
  narrativeLength,
177
177
  timestamp: new Date().toISOString(),
178
178
  },
179
- }
179
+ };
180
180
  },
181
- } as const
181
+ } as const;
package/src/mutations.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { MutationBehavior } from './requests';
1
+ export type { MutationBehavior } from "./requests";
2
2
 
3
3
  export type MutationPolicy = {
4
4
  /**
@@ -9,5 +9,5 @@ export type MutationPolicy = {
9
9
  * parallel — independent mutations on different resourceIds may run concurrently;
10
10
  * same-resource requests still serialize to avoid lost writes.
11
11
  */
12
- behavior: 'collapse' | 'queue' | 'parallel';
12
+ behavior: "collapse" | "queue" | "parallel";
13
13
  };
@@ -1,16 +1,28 @@
1
- export const REQUEST_ID_HEADER = 'x-request-id';
1
+ export const REQUEST_ID_HEADER = "x-request-id";
2
2
 
3
3
  export type Labels = Record<string, string>;
4
4
  export type MetricEnvelope =
5
- | { kind: 'counter'; name: string; value: number; labels?: Labels; ts: number }
6
- | { kind: 'gauge'; name: string; value: number; labels?: Labels; ts: number }
7
- | { kind: 'histogram'; name: string; value: number; labels?: Labels; ts: number };
5
+ | {
6
+ kind: "counter";
7
+ name: string;
8
+ value: number;
9
+ labels?: Labels;
10
+ ts: number;
11
+ }
12
+ | { kind: "gauge"; name: string; value: number; labels?: Labels; ts: number }
13
+ | {
14
+ kind: "histogram";
15
+ name: string;
16
+ value: number;
17
+ labels?: Labels;
18
+ ts: number;
19
+ };
8
20
 
9
21
  export type SchedulerMetricName =
10
- | 'scheduler.inflight_requests'
11
- | 'scheduler.queue_depth'
12
- | 'scheduler.queue_wait_ms'
13
- | 'scheduler.dedupe_hits'
14
- | 'scheduler.heap_used_bytes'
15
- | 'scheduler.rss_bytes'
16
- | 'scheduler.fetch_latency_ms';
22
+ | "scheduler.inflight_requests"
23
+ | "scheduler.queue_depth"
24
+ | "scheduler.queue_wait_ms"
25
+ | "scheduler.dedupe_hits"
26
+ | "scheduler.heap_used_bytes"
27
+ | "scheduler.rss_bytes"
28
+ | "scheduler.fetch_latency_ms";